@accurix/centrinfo-widget 5.3.1 → 5.4.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.
- package/README.md +229 -37
- package/dist/bundle-ar-D_Sk4igF.mjs +1 -0
- package/dist/bundle-ar-fKjs-fvS.cjs +1 -0
- package/dist/bundle-de-BST4qEm1.cjs +1 -0
- package/dist/bundle-de-BWnVOyv0.mjs +1 -0
- package/dist/bundle-es-Bes8ddxv.mjs +1 -0
- package/dist/bundle-es-Bfphsx9c.cjs +1 -0
- package/dist/bundle-fr-D1QlfFID.mjs +1 -0
- package/dist/bundle-fr-X5Ian15d.cjs +1 -0
- package/dist/bundle-it-9j6g91Cu.mjs +1 -0
- package/dist/bundle-it-C2HPnGql.cjs +1 -0
- package/dist/bundle-pt-BK9LBxix.mjs +1 -0
- package/dist/bundle-pt-BMcCSSgB.cjs +1 -0
- package/dist/bundle-sw-BKWnwk-0.cjs +1 -0
- package/dist/bundle-sw-DA2XuFS_.mjs +1 -0
- package/dist/cdn/centrinfo-widget-dev.js +35 -23
- package/dist/cdn/centrinfo-widget-locale-ar.js +4 -0
- package/dist/cdn/centrinfo-widget-locale-de.js +4 -0
- package/dist/cdn/centrinfo-widget-locale-es.js +4 -0
- package/dist/cdn/centrinfo-widget-locale-fr.js +4 -0
- package/dist/cdn/centrinfo-widget-locale-it.js +4 -0
- package/dist/cdn/centrinfo-widget-locale-pt.js +4 -0
- package/dist/cdn/centrinfo-widget-locale-sw.js +4 -0
- package/dist/cdn/centrinfo-widget-voice.js +272 -0
- package/dist/cdn/centrinfo-widget.js +171 -145
- package/dist/cdn/manifest.json +57 -9
- package/dist/dev-transports-DP4ilDW1.mjs +13 -0
- package/dist/dev-transports-uGHAao9W.cjs +13 -0
- package/dist/index.cjs +2 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +2 -1
- package/dist/runtime.cjs +2 -2
- package/dist/runtime.d.cts +126 -11
- package/dist/runtime.d.mts +120 -8
- package/dist/runtime.d.ts +479 -0
- package/dist/runtime.mjs +2 -2
- package/dist/speech-detector-runtime-D5GpV8VJ.cjs +68 -0
- package/dist/speech-detector-runtime-D7gguFpP.mjs +68 -0
- package/dist/styles-BWPJrttg.cjs +3563 -0
- package/dist/styles-C8MXPiR-.mjs +3563 -0
- package/dist/{types-CSrYnsOp.d.mts → types-M-juCXr7.d.mts} +551 -98
- package/dist/{types-eBuee08Q.d.cts → types-sRV3p0Gu.d.cts} +542 -92
- package/package.json +4 -3
- package/dist/dev-transports-DqSPyIEz.mjs +0 -1
- package/dist/dev-transports-KlSdSZpj.cjs +0 -1
- package/dist/styles-BUK2S5l_.mjs +0 -3543
- package/dist/styles-BVQRcZkH.cjs +0 -3543
package/dist/cdn/manifest.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"packageName": "@accurix/centrinfo-widget",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.4.0",
|
|
4
4
|
"fileName": "centrinfo-widget.js",
|
|
5
|
-
"cdnPath": "centrinfo/js/sdk-centrinfo-widget-v5.
|
|
6
|
-
"bytes":
|
|
7
|
-
"gzipBytes":
|
|
8
|
-
"sha256": "
|
|
9
|
-
"sri": "sha256
|
|
5
|
+
"cdnPath": "centrinfo/js/sdk-centrinfo-widget-v5.4.0/centrinfo-widget.js",
|
|
6
|
+
"bytes": 550650,
|
|
7
|
+
"gzipBytes": 164062,
|
|
8
|
+
"sha256": "1c63cd0d25e31a84aa246f96ff42623a56b2c4bbc66cbd6e80af16ffb97c3715",
|
|
9
|
+
"sri": "sha256-HGPNDSXjGoSqJG+W/0JiOlayxLvGbL1ugK8W/7l8NxU=",
|
|
10
10
|
"chunks": [
|
|
11
11
|
{
|
|
12
12
|
"fileName": "centrinfo-widget-charts.js",
|
|
@@ -16,9 +16,57 @@
|
|
|
16
16
|
},
|
|
17
17
|
{
|
|
18
18
|
"fileName": "centrinfo-widget-dev.js",
|
|
19
|
-
"bytes":
|
|
20
|
-
"gzipBytes":
|
|
21
|
-
"sri": "sha256-
|
|
19
|
+
"bytes": 18364,
|
|
20
|
+
"gzipBytes": 5610,
|
|
21
|
+
"sri": "sha256-BaSafv0Zt/NtDJYjsaMLjm/PZj9b1ObVU3JRAEAR6JA="
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"fileName": "centrinfo-widget-voice.js",
|
|
25
|
+
"bytes": 7389475,
|
|
26
|
+
"gzipBytes": 3166276,
|
|
27
|
+
"sri": "sha256-Yfdfd6zeARxpCTJ+2VzmcguVycOY8qIZc5ucF+P5aKU="
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"fileName": "centrinfo-widget-locale-fr.js",
|
|
31
|
+
"bytes": 28928,
|
|
32
|
+
"gzipBytes": 9669,
|
|
33
|
+
"sri": "sha256-tAimTupTTBwmLt70uWGSO4737cGLcyllj2aY2PjsWd0="
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"fileName": "centrinfo-widget-locale-es.js",
|
|
37
|
+
"bytes": 27338,
|
|
38
|
+
"gzipBytes": 9290,
|
|
39
|
+
"sri": "sha256-H3wfXNxOkuX7HWFlByE/qUnR49ygexCzlD+c4nukLuM="
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"fileName": "centrinfo-widget-locale-pt.js",
|
|
43
|
+
"bytes": 27498,
|
|
44
|
+
"gzipBytes": 9254,
|
|
45
|
+
"sri": "sha256-K3MQVp4EklSORPIYfVkincEkK+bUZod0r24E3c2p+UE="
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"fileName": "centrinfo-widget-locale-de.js",
|
|
49
|
+
"bytes": 28032,
|
|
50
|
+
"gzipBytes": 9572,
|
|
51
|
+
"sri": "sha256-VnJkULDGYGOE0hi38g6ikDic8u5KT3QfzHefGHI5HBk="
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"fileName": "centrinfo-widget-locale-it.js",
|
|
55
|
+
"bytes": 27422,
|
|
56
|
+
"gzipBytes": 9156,
|
|
57
|
+
"sri": "sha256-RYeeUshG3U8/e8HOo5MXs9chndpzR3mNxDOfCpEbZFw="
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"fileName": "centrinfo-widget-locale-ar.js",
|
|
61
|
+
"bytes": 34012,
|
|
62
|
+
"gzipBytes": 10082,
|
|
63
|
+
"sri": "sha256-6iZ144/8OLeGuu7CqeCTAHVtIJE2k49P8fdagSZeyRQ="
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"fileName": "centrinfo-widget-locale-sw.js",
|
|
67
|
+
"bytes": 26487,
|
|
68
|
+
"gzipBytes": 8890,
|
|
69
|
+
"sri": "sha256-pQ53ZaZvSNAlVmsZcJLR8XcqFRrvuWu5YksZwuM6f74="
|
|
22
70
|
}
|
|
23
71
|
]
|
|
24
72
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const e=e=>new Promise(t=>setTimeout(t,e)),t={agentName:`Accurix`,agentAvatarUrl:``,widgetModule:`assistant`,assistantMediaKind:`image`,assistantPrivacyUrl:`https://accurix.tech/privacy`,soundEnabled:!0,voiceOutputEnabled:!1,talkbackMode:`avatar`,avatarProvider:`demo`,avatarId:`accurix-demo`,greeting:`Hi! I'm Accurix, the AI assistant for Accurix. Ask me anything about products, pricing, or documentation — or book a demo.`,allowVoiceInput:!1,memoryEnabled:!0,memoryRetentionDays:30,memoryMessageCap:50,availableActions:[`public_book_demo`,`public_capture_contact`,`public_submit_inquiry`],agentDescription:`I help with Accurix products, pricing, and documentation.`,welcomeSubtitle:`Ask me anything — most answers are instant.`,disclaimerText:`Accurix is an AI assistant; answers may be imperfect.`,starterQuestions:[`What can Accurix help with?`,`How do I get started?`,`What's your pricing?`],featuredLinks:[{label:`Accurix founders`,url:`https://accurix.tech/about`},{label:`Pricing`,url:`https://accurix.tech/pricing`}]},n=[{match:/demo chart|monthly orders|orders by status/i,result:{answer:`Orders moved in different directions by status in the latest month. The chart below shows one line for submitted, approved, and fulfilled orders.`,sources:[],suggestedReplies:[`Show a demo KPI`,`Show a demo table`],handoffOffered:!1,visualization:{version:1,presentation:`chart`,type:`line`,title:`Monthly orders by status`,reportingPeriod:{label:`January–August 2025`,timezone:`Africa/Lagos`},timezone:`Africa/Lagos`,freshness:{status:`live`,answeredAt:`2026-10-09T10:00:00Z`},appliedFilters:[{field:`status`,operator:`in`,value:[`Submitted`,`Approved`,`Fulfilled`]}],columns:[`month`,`status`,`order_count`],rows:[{month:`2025-01-01`,status:`Submitted`,order_count:12},{month:`2025-01-01`,status:`Approved`,order_count:16},{month:`2025-01-01`,status:`Fulfilled`,order_count:14},{month:`2025-02-01`,status:`Submitted`,order_count:14},{month:`2025-02-01`,status:`Approved`,order_count:15},{month:`2025-02-01`,status:`Fulfilled`,order_count:15},{month:`2025-03-01`,status:`Submitted`,order_count:13},{month:`2025-03-01`,status:`Approved`,order_count:17},{month:`2025-03-01`,status:`Fulfilled`,order_count:16},{month:`2025-04-01`,status:`Submitted`,order_count:15},{month:`2025-04-01`,status:`Approved`,order_count:16},{month:`2025-04-01`,status:`Fulfilled`,order_count:17},{month:`2025-05-01`,status:`Submitted`,order_count:16},{month:`2025-05-01`,status:`Approved`,order_count:18},{month:`2025-05-01`,status:`Fulfilled`,order_count:17},{month:`2025-06-01`,status:`Submitted`,order_count:17},{month:`2025-06-01`,status:`Approved`,order_count:17},{month:`2025-06-01`,status:`Fulfilled`,order_count:18},{month:`2025-07-01`,status:`Submitted`,order_count:18},{month:`2025-07-01`,status:`Approved`,order_count:19},{month:`2025-07-01`,status:`Fulfilled`,order_count:18},{month:`2025-08-01`,status:`Submitted`,order_count:19},{month:`2025-08-01`,status:`Approved`,order_count:18},{month:`2025-08-01`,status:`Fulfilled`,order_count:19}],rowCount:24,columnMetadata:[{key:`month`,label:`Order month`,dataType:`date`,semanticRole:`date`},{key:`status`,label:`Status`,dataType:`text`,semanticRole:`dimension`},{key:`order_count`,label:`Distinct order count`,dataType:`number`,semanticRole:`measure`,aggregation:`count_distinct`}],chartRecommendation:{type:`line`,mode:`time_series`,categoryField:`month`,valueFields:[`order_count`],seriesField:`status`},expandable:!0,tableAvailable:!1,explanation:{headline:`The latest results moved in different directions by status.`,summary:`Submitted and fulfilled orders increased, while approved orders decreased.`,evidence:[`Submitted orders increased from 18 in July to 19 in August.`,`Approved orders decreased from 19 in July to 18 in August.`,`Fulfilled orders increased from 18 in July to 19 in August.`],businessMeaning:`Overall order activity is steady, but the small approval decline is worth watching if it continues.`,followUps:[`Which status changed the most?`,`How does this compare with the prior quarter?`],source:`governed_result`}}}},{match:/demo kpi|active accounts/i,result:{answer:`There are 5,632 active accounts in the current demo result.`,sources:[],suggestedReplies:[`Show a demo chart`,`Show a demo table`],handoffOffered:!1,visualization:{version:1,presentation:`kpi`,type:`kpi`,title:`Active accounts`,columns:[`active_accounts`],value:`active_accounts`,rows:[{active_accounts:5632}],rowCount:1,columnMetadata:[{key:`active_accounts`,label:`Active accounts`,dataType:`number`,semanticRole:`measure`,aggregation:`count_distinct`}],explanation:{headline:`Active accounts are 5,632.`,summary:`This is the latest value in the demo result.`,evidence:[`The displayed active-account count is 5,632.`],source:`governed_result`}}}},{match:/demo table|account health/i,result:{answer:`Nine accounts are included in this governed result. The table shows a compact preview and can be expanded to inspect every permitted row.`,sources:[],suggestedReplies:[`Show a demo chart`,`Test the hidden table response`],handoffOffered:!1,visualization:{version:1,presentation:`table`,type:`table`,title:`Account health`,columns:[`account_name`,`region`,`health_score`,`renewal_month`],rows:[{account_name:`Northstar Industries`,region:`West`,health_score:94,renewal_month:`August`},{account_name:`Apex Group`,region:`East`,health_score:91,renewal_month:`September`},{account_name:`Summit Retail`,region:`North`,health_score:88,renewal_month:`August`},{account_name:`Harbor Logistics`,region:`South`,health_score:86,renewal_month:`October`},{account_name:`Brightline Media`,region:`West`,health_score:84,renewal_month:`November`},{account_name:`Redwood Labs`,region:`East`,health_score:82,renewal_month:`September`},{account_name:`Atlas Foods`,region:`North`,health_score:79,renewal_month:`December`},{account_name:`Cedar Health`,region:`South`,health_score:77,renewal_month:`October`},{account_name:`Bluewave Energy`,region:`West`,health_score:74,renewal_month:`December`}],rowCount:9,columnMetadata:[{key:`account_name`,label:`Account`,dataType:`text`,semanticRole:`dimension`},{key:`region`,label:`Region`,dataType:`text`,semanticRole:`geography`},{key:`health_score`,label:`Health score`,dataType:`number`,semanticRole:`measure`},{key:`renewal_month`,label:`Renewal month`,dataType:`text`,semanticRole:`date`}],expandable:!0,tableAvailable:!0,downloadAvailable:!0,explanation:{headline:`Nine accounts are available for review.`,summary:`Health scores range from 74 to 94 across four regions.`,evidence:[`Northstar Industries has the highest health score at 94.`],source:`governed_result`}}}},{match:/demo ranking|most purchased/i,result:{answer:`Top 5 most purchased products this week: Security License Global 11 (352).
|
|
2
|
+
|
|
3
|
+
Top region for each product by quantity purchased this week:
|
|
4
|
+
1. Security License Global 11: 352 — Southeast (Brazil): 80
|
|
5
|
+
2. Sensor Pack Basic 18: 319 — West (Germany): 52
|
|
6
|
+
3. Cloud Backup Plus 4: 301 — APAC (Singapore): 61
|
|
7
|
+
4. Router Pro 7: 288 — North (Canada): 49
|
|
8
|
+
5. Analytics Seat 2: 270 — South (Mexico): 58`,sources:[],suggestedReplies:[`Show a demo chart`,`Show a demo table`],handoffOffered:!1,visualization:{version:1,presentation:`table`,type:`table`,title:`Top 5 most purchased products this week`,columns:[`name`,`region`,`ranked_total`,`breakdown_value`],rows:[{name:`Security License Global 11`,region:`Southeast (Brazil)`,ranked_total:352,breakdown_value:80},{name:`Sensor Pack Basic 18`,region:`West (Germany)`,ranked_total:319,breakdown_value:52},{name:`Cloud Backup Plus 4`,region:`APAC (Singapore)`,ranked_total:301,breakdown_value:61},{name:`Router Pro 7`,region:`North (Canada)`,ranked_total:288,breakdown_value:49},{name:`Analytics Seat 2`,region:`South (Mexico)`,ranked_total:270,breakdown_value:58}],rowCount:5,tableAvailable:!0,columnMetadata:[{key:`name`,label:`Product`,dataType:`text`,semanticRole:`dimension`},{key:`region`,label:`Region`,dataType:`text`,semanticRole:`dimension`},{key:`ranked_total`,label:`Quantity`,dataType:`number`,semanticRole:`measure`},{key:`breakdown_value`,label:`Quantity · Region`,dataType:`number`,semanticRole:`measure`}],rankedAnswer:{version:1,lead:`Top 5 most purchased products this week: Security License Global 11 (352).`,title:`Top 5 most purchased products this week`,detailTitle:`Top region for each product by quantity purchased this week`,itemField:`name`,detailFields:[`region`],labels:{item:`Product`,value:`Quantity`,detail:`Region`,detailValue:`Quantity · Region`},items:[{rank:1,label:`Security License Global 11`,value:352,display:`352`,details:[{rank:1,label:`Southeast (Brazil)`,value:80,display:`80`}]},{rank:2,label:`Sensor Pack Basic 18`,value:319,display:`319`,details:[{rank:1,label:`West (Germany)`,value:52,display:`52`}]},{rank:3,label:`Cloud Backup Plus 4`,value:301,display:`301`,details:[{rank:1,label:`APAC (Singapore)`,value:61,display:`61`}]},{rank:4,label:`Router Pro 7`,value:288,display:`288`,details:[{rank:1,label:`North (Canada)`,value:49,display:`49`}]},{rank:5,label:`Analytics Seat 2`,value:270,display:`270`,details:[{rank:1,label:`South (Mexico)`,value:58,display:`58`}]}],text:`Top region for each product by quantity purchased this week:
|
|
9
|
+
1. Security License Global 11: 352 — Southeast (Brazil): 80
|
|
10
|
+
2. Sensor Pack Basic 18: 319 — West (Germany): 52
|
|
11
|
+
3. Cloud Backup Plus 4: 301 — APAC (Singapore): 61
|
|
12
|
+
4. Router Pro 7: 288 — North (Canada): 49
|
|
13
|
+
5. Analytics Seat 2: 270 — South (Mexico): 58`}}}},{match:/hidden table|table response/i,result:{answer:`Three accounts need attention. The public widget explains the result without exposing its underlying rows.`,sources:[],suggestedReplies:[`Show a demo chart`,`Show a demo KPI`],handoffOffered:!1,visualization:{version:1,presentation:`table`,type:`table`,columns:[`account_name`,`risk_score`],rows:[{account_name:`Private account A`,risk_score:91},{account_name:`Private account B`,risk_score:87},{account_name:`Private account C`,risk_score:82}],rowCount:3,tableAvailable:!1,explanation:{headline:`Three accounts need attention.`,summary:`The written result is available without displaying a public data table.`,evidence:[`Three accounts matched the approved attention rule.`],source:`governed_result`}}}},{match:/^\s*(hi+|hey+|hello|yo|sup|howdy|hola|thanks|thank you|thx|good (morning|afternoon|evening))\b/i,result:{answer:`Hello! 👋 How can I help you today?`,sources:[],suggestedReplies:[`How do I track a shipment?`,`How does customs work?`],handoffOffered:!1}},{match:/track|shipment|where|status/i,result:{answer:`Centrinfo can answer from your indexed knowledge base, public website, connected files, and approved organization tools. It keeps answers grounded in your configured sources and can hand a conversation to your team when the AI is not enough.`,sources:[{title:`Centrinfo public widget`,url:`https://accurix.tech/centrinfo`}],suggestedReplies:[`How does the widget work?`,`Can a human take over?`],handoffOffered:!1}},{match:/custom|clear|duty|tariff|import/i,result:{answer:`Accurix connects your organization knowledge, channels, integrations, and public widget in one place. You can configure which sources the AI can use, which tools visitors can trigger, and when your team should take over live chat.`,sources:[{title:`Accurix documentation`,url:`https://accurix.tech/docs`}],suggestedReplies:[`Which tools can I connect?`,`How do permissions work?`],handoffOffered:!1}},{match:/price|cost|pricing|plan|quote/i,result:{answer:`Accurix uses a usage-based pricing model. Organizations keep an active subscription and spend credits as the AI answers, searches, and uses tools. Credit top-ups can extend usage when the subscription grant runs low.`,sources:[{title:`Pricing`,url:`https://accurix.tech/pricing`}],suggestedReplies:[`How do credits work?`,`Can I top up credits?`],handoffOffered:!1}}],r={answer:`That's a great question — I don't have a confident answer from Accurix's published docs yet. Want me to pass it to the team so a human can follow up? You can also book a quick demo.`,sources:[],suggestedReplies:[`What can you help with?`],handoffOffered:!0},i=e=>n.find(t=>t.match.test(e))?.result??r;var a=class{async history(){return{conversations:[]}}async bootstrap(){return await e(180),t}async stream(n,r,a){await e(550);let o=i(n),s=o.answer.split(/(\s+)/);for(let t of s){if(a.signal?.aborted)break;a.onChunk(t),await e(18+Math.min(40,t.length*6))}return{...o,availableActions:t.availableActions}}async liveEvents(){return{mode:`ai`,conversationEnded:!1,events:[]}}async presence(e){}async typing(){await e(20)}async action(t,n){return await e(450),{ok:!0,note:{"book-demo":`Demo requested. The team will follow up. 📅`,contact:`Got it — saved your details. ✅`,"contact-support":`Support request sent. The team can follow up from this chat. ✅`,inquiry:`Thanks! We'll get back to you shortly. ✉️`,"request-callback":`We'll call you back soon. 📞`,"schedule-callback":`Your callback has been scheduled.`,"subscribe-newsletter":`You're subscribed. 🎉`}[t]}}async speak(){return await e(120),{providerReady:!1,message:`Demo voice provider is not connected.`}}async transcribe(t,n,r,i){return await e(700),`How do I track a shipment?`}async uploadAttachment(e,t,n){return{id:`demo-${Date.now()}`,text:`Attached file: ${n}`,analysisFailed:!1}}async identify(t,n){await e(50)}async endConversation(t){await e(50)}async sendFeedback(){await e(50)}async sendExplanationFeedback(){await e(50)}async demoSlots(t,n){return await e(150),{taken:[[11,0],[15,0]].map(([e,t])=>{let n=new Date;return n.setHours(e,t,0,0),n.toISOString()}),busy:[]}}async searchGifs(t){await e(280);let n=t.trim().toLowerCase(),r=n?l.filter(e=>e.alt.includes(n)||e.tags.some(e=>e.includes(n)||n.includes(e))):l;return(r.length>0?r:l).map(e=>({id:e.id,url:c(e.emoji,e.anim),preview:c(e.emoji,e.anim),alt:e.alt}))}};const o=`<animateTransform attributeName='transform' attributeType='XML' type='translate' values='0 0;0 -16;0 0' dur='0.7s' repeatCount='indefinite'/>`,s=`<animateTransform attributeName='transform' attributeType='XML' type='rotate' values='-14 64 110;14 64 110;-14 64 110' dur='0.9s' repeatCount='indefinite'/>`,c=(e,t)=>{let n=`<svg xmlns='http://www.w3.org/2000/svg' width='128' height='128'><rect width='128' height='128' rx='14' fill='#eef1f4'/><text x='64' y='88' font-size='64' text-anchor='middle'>${e}${t}</text></svg>`;return`data:image/svg+xml,${encodeURIComponent(n)}`},l=[{id:`g1`,emoji:`👍`,alt:`thumbs up`,tags:[`thumbs`,`yes`,`ok`,`great`,`good`],anim:o},{id:`g2`,emoji:`🎉`,alt:`celebrate`,tags:[`party`,`yay`,`congrats`,`celebrate`],anim:s},{id:`g3`,emoji:`👋`,alt:`wave hello`,tags:[`hi`,`hello`,`hey`,`wave`,`bye`],anim:s},{id:`g4`,emoji:`❤️`,alt:`heart`,tags:[`love`,`thanks`,`heart`],anim:o},{id:`g5`,emoji:`🤔`,alt:`thinking`,tags:[`hmm`,`think`,`thinking`],anim:s},{id:`g6`,emoji:`😂`,alt:`laughing`,tags:[`lol`,`funny`,`haha`,`laugh`],anim:o},{id:`g7`,emoji:`🔥`,alt:`fire`,tags:[`fire`,`hot`,`lit`,`awesome`],anim:o},{id:`g8`,emoji:`🚀`,alt:`rocket`,tags:[`rocket`,`launch`,`fast`,`go`],anim:s}],u=e=>new Promise(t=>setTimeout(t,e));var d=class{constructor(e,t){this.real=e,this.strings=t}bootstrap(){return this.real.bootstrap()}async history(){return{conversations:[]}}async stream(e,t,n){await u(300);for(let e of this.strings.previewReply.split(/(\s+)/)){if(n.signal?.aborted)break;n.onChunk(e),await u(16)}return{answer:this.strings.previewReply,sources:[],suggestedReplies:[],availableActions:[],handoffOffered:!1}}async liveEvents(){return{mode:`ai`,conversationEnded:!1,events:[]}}async presence(e){}async typing(){}async action(){return await u(250),{ok:!0,note:this.strings.previewActionNote}}async speak(){return{providerReady:!1,message:`Preview voice provider is not connected.`}}async identify(){}async endConversation(){}async sendFeedback(){}async sendExplanationFeedback(){}async transcribe(e,t,n,r){return``}async uploadAttachment(e,t,n){return{id:`preview-${Date.now()}`,text:`Attached file: ${n}`,analysisFailed:!1}}async searchGifs(){return[]}async demoSlots(){return{taken:[],busy:[]}}};export{a as MockTransport,d as PreviewTransport};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const e=e=>new Promise(t=>setTimeout(t,e)),t={agentName:`Accurix`,agentAvatarUrl:``,widgetModule:`assistant`,assistantMediaKind:`image`,assistantPrivacyUrl:`https://accurix.tech/privacy`,soundEnabled:!0,voiceOutputEnabled:!1,talkbackMode:`avatar`,avatarProvider:`demo`,avatarId:`accurix-demo`,greeting:`Hi! I'm Accurix, the AI assistant for Accurix. Ask me anything about products, pricing, or documentation — or book a demo.`,allowVoiceInput:!1,memoryEnabled:!0,memoryRetentionDays:30,memoryMessageCap:50,availableActions:[`public_book_demo`,`public_capture_contact`,`public_submit_inquiry`],agentDescription:`I help with Accurix products, pricing, and documentation.`,welcomeSubtitle:`Ask me anything — most answers are instant.`,disclaimerText:`Accurix is an AI assistant; answers may be imperfect.`,starterQuestions:[`What can Accurix help with?`,`How do I get started?`,`What's your pricing?`],featuredLinks:[{label:`Accurix founders`,url:`https://accurix.tech/about`},{label:`Pricing`,url:`https://accurix.tech/pricing`}]},n=[{match:/demo chart|monthly orders|orders by status/i,result:{answer:`Orders moved in different directions by status in the latest month. The chart below shows one line for submitted, approved, and fulfilled orders.`,sources:[],suggestedReplies:[`Show a demo KPI`,`Show a demo table`],handoffOffered:!1,visualization:{version:1,presentation:`chart`,type:`line`,title:`Monthly orders by status`,reportingPeriod:{label:`January–August 2025`,timezone:`Africa/Lagos`},timezone:`Africa/Lagos`,freshness:{status:`live`,answeredAt:`2026-10-09T10:00:00Z`},appliedFilters:[{field:`status`,operator:`in`,value:[`Submitted`,`Approved`,`Fulfilled`]}],columns:[`month`,`status`,`order_count`],rows:[{month:`2025-01-01`,status:`Submitted`,order_count:12},{month:`2025-01-01`,status:`Approved`,order_count:16},{month:`2025-01-01`,status:`Fulfilled`,order_count:14},{month:`2025-02-01`,status:`Submitted`,order_count:14},{month:`2025-02-01`,status:`Approved`,order_count:15},{month:`2025-02-01`,status:`Fulfilled`,order_count:15},{month:`2025-03-01`,status:`Submitted`,order_count:13},{month:`2025-03-01`,status:`Approved`,order_count:17},{month:`2025-03-01`,status:`Fulfilled`,order_count:16},{month:`2025-04-01`,status:`Submitted`,order_count:15},{month:`2025-04-01`,status:`Approved`,order_count:16},{month:`2025-04-01`,status:`Fulfilled`,order_count:17},{month:`2025-05-01`,status:`Submitted`,order_count:16},{month:`2025-05-01`,status:`Approved`,order_count:18},{month:`2025-05-01`,status:`Fulfilled`,order_count:17},{month:`2025-06-01`,status:`Submitted`,order_count:17},{month:`2025-06-01`,status:`Approved`,order_count:17},{month:`2025-06-01`,status:`Fulfilled`,order_count:18},{month:`2025-07-01`,status:`Submitted`,order_count:18},{month:`2025-07-01`,status:`Approved`,order_count:19},{month:`2025-07-01`,status:`Fulfilled`,order_count:18},{month:`2025-08-01`,status:`Submitted`,order_count:19},{month:`2025-08-01`,status:`Approved`,order_count:18},{month:`2025-08-01`,status:`Fulfilled`,order_count:19}],rowCount:24,columnMetadata:[{key:`month`,label:`Order month`,dataType:`date`,semanticRole:`date`},{key:`status`,label:`Status`,dataType:`text`,semanticRole:`dimension`},{key:`order_count`,label:`Distinct order count`,dataType:`number`,semanticRole:`measure`,aggregation:`count_distinct`}],chartRecommendation:{type:`line`,mode:`time_series`,categoryField:`month`,valueFields:[`order_count`],seriesField:`status`},expandable:!0,tableAvailable:!1,explanation:{headline:`The latest results moved in different directions by status.`,summary:`Submitted and fulfilled orders increased, while approved orders decreased.`,evidence:[`Submitted orders increased from 18 in July to 19 in August.`,`Approved orders decreased from 19 in July to 18 in August.`,`Fulfilled orders increased from 18 in July to 19 in August.`],businessMeaning:`Overall order activity is steady, but the small approval decline is worth watching if it continues.`,followUps:[`Which status changed the most?`,`How does this compare with the prior quarter?`],source:`governed_result`}}}},{match:/demo kpi|active accounts/i,result:{answer:`There are 5,632 active accounts in the current demo result.`,sources:[],suggestedReplies:[`Show a demo chart`,`Show a demo table`],handoffOffered:!1,visualization:{version:1,presentation:`kpi`,type:`kpi`,title:`Active accounts`,columns:[`active_accounts`],value:`active_accounts`,rows:[{active_accounts:5632}],rowCount:1,columnMetadata:[{key:`active_accounts`,label:`Active accounts`,dataType:`number`,semanticRole:`measure`,aggregation:`count_distinct`}],explanation:{headline:`Active accounts are 5,632.`,summary:`This is the latest value in the demo result.`,evidence:[`The displayed active-account count is 5,632.`],source:`governed_result`}}}},{match:/demo table|account health/i,result:{answer:`Nine accounts are included in this governed result. The table shows a compact preview and can be expanded to inspect every permitted row.`,sources:[],suggestedReplies:[`Show a demo chart`,`Test the hidden table response`],handoffOffered:!1,visualization:{version:1,presentation:`table`,type:`table`,title:`Account health`,columns:[`account_name`,`region`,`health_score`,`renewal_month`],rows:[{account_name:`Northstar Industries`,region:`West`,health_score:94,renewal_month:`August`},{account_name:`Apex Group`,region:`East`,health_score:91,renewal_month:`September`},{account_name:`Summit Retail`,region:`North`,health_score:88,renewal_month:`August`},{account_name:`Harbor Logistics`,region:`South`,health_score:86,renewal_month:`October`},{account_name:`Brightline Media`,region:`West`,health_score:84,renewal_month:`November`},{account_name:`Redwood Labs`,region:`East`,health_score:82,renewal_month:`September`},{account_name:`Atlas Foods`,region:`North`,health_score:79,renewal_month:`December`},{account_name:`Cedar Health`,region:`South`,health_score:77,renewal_month:`October`},{account_name:`Bluewave Energy`,region:`West`,health_score:74,renewal_month:`December`}],rowCount:9,columnMetadata:[{key:`account_name`,label:`Account`,dataType:`text`,semanticRole:`dimension`},{key:`region`,label:`Region`,dataType:`text`,semanticRole:`geography`},{key:`health_score`,label:`Health score`,dataType:`number`,semanticRole:`measure`},{key:`renewal_month`,label:`Renewal month`,dataType:`text`,semanticRole:`date`}],expandable:!0,tableAvailable:!0,downloadAvailable:!0,explanation:{headline:`Nine accounts are available for review.`,summary:`Health scores range from 74 to 94 across four regions.`,evidence:[`Northstar Industries has the highest health score at 94.`],source:`governed_result`}}}},{match:/demo ranking|most purchased/i,result:{answer:`Top 5 most purchased products this week: Security License Global 11 (352).
|
|
2
|
+
|
|
3
|
+
Top region for each product by quantity purchased this week:
|
|
4
|
+
1. Security License Global 11: 352 — Southeast (Brazil): 80
|
|
5
|
+
2. Sensor Pack Basic 18: 319 — West (Germany): 52
|
|
6
|
+
3. Cloud Backup Plus 4: 301 — APAC (Singapore): 61
|
|
7
|
+
4. Router Pro 7: 288 — North (Canada): 49
|
|
8
|
+
5. Analytics Seat 2: 270 — South (Mexico): 58`,sources:[],suggestedReplies:[`Show a demo chart`,`Show a demo table`],handoffOffered:!1,visualization:{version:1,presentation:`table`,type:`table`,title:`Top 5 most purchased products this week`,columns:[`name`,`region`,`ranked_total`,`breakdown_value`],rows:[{name:`Security License Global 11`,region:`Southeast (Brazil)`,ranked_total:352,breakdown_value:80},{name:`Sensor Pack Basic 18`,region:`West (Germany)`,ranked_total:319,breakdown_value:52},{name:`Cloud Backup Plus 4`,region:`APAC (Singapore)`,ranked_total:301,breakdown_value:61},{name:`Router Pro 7`,region:`North (Canada)`,ranked_total:288,breakdown_value:49},{name:`Analytics Seat 2`,region:`South (Mexico)`,ranked_total:270,breakdown_value:58}],rowCount:5,tableAvailable:!0,columnMetadata:[{key:`name`,label:`Product`,dataType:`text`,semanticRole:`dimension`},{key:`region`,label:`Region`,dataType:`text`,semanticRole:`dimension`},{key:`ranked_total`,label:`Quantity`,dataType:`number`,semanticRole:`measure`},{key:`breakdown_value`,label:`Quantity · Region`,dataType:`number`,semanticRole:`measure`}],rankedAnswer:{version:1,lead:`Top 5 most purchased products this week: Security License Global 11 (352).`,title:`Top 5 most purchased products this week`,detailTitle:`Top region for each product by quantity purchased this week`,itemField:`name`,detailFields:[`region`],labels:{item:`Product`,value:`Quantity`,detail:`Region`,detailValue:`Quantity · Region`},items:[{rank:1,label:`Security License Global 11`,value:352,display:`352`,details:[{rank:1,label:`Southeast (Brazil)`,value:80,display:`80`}]},{rank:2,label:`Sensor Pack Basic 18`,value:319,display:`319`,details:[{rank:1,label:`West (Germany)`,value:52,display:`52`}]},{rank:3,label:`Cloud Backup Plus 4`,value:301,display:`301`,details:[{rank:1,label:`APAC (Singapore)`,value:61,display:`61`}]},{rank:4,label:`Router Pro 7`,value:288,display:`288`,details:[{rank:1,label:`North (Canada)`,value:49,display:`49`}]},{rank:5,label:`Analytics Seat 2`,value:270,display:`270`,details:[{rank:1,label:`South (Mexico)`,value:58,display:`58`}]}],text:`Top region for each product by quantity purchased this week:
|
|
9
|
+
1. Security License Global 11: 352 — Southeast (Brazil): 80
|
|
10
|
+
2. Sensor Pack Basic 18: 319 — West (Germany): 52
|
|
11
|
+
3. Cloud Backup Plus 4: 301 — APAC (Singapore): 61
|
|
12
|
+
4. Router Pro 7: 288 — North (Canada): 49
|
|
13
|
+
5. Analytics Seat 2: 270 — South (Mexico): 58`}}}},{match:/hidden table|table response/i,result:{answer:`Three accounts need attention. The public widget explains the result without exposing its underlying rows.`,sources:[],suggestedReplies:[`Show a demo chart`,`Show a demo KPI`],handoffOffered:!1,visualization:{version:1,presentation:`table`,type:`table`,columns:[`account_name`,`risk_score`],rows:[{account_name:`Private account A`,risk_score:91},{account_name:`Private account B`,risk_score:87},{account_name:`Private account C`,risk_score:82}],rowCount:3,tableAvailable:!1,explanation:{headline:`Three accounts need attention.`,summary:`The written result is available without displaying a public data table.`,evidence:[`Three accounts matched the approved attention rule.`],source:`governed_result`}}}},{match:/^\s*(hi+|hey+|hello|yo|sup|howdy|hola|thanks|thank you|thx|good (morning|afternoon|evening))\b/i,result:{answer:`Hello! 👋 How can I help you today?`,sources:[],suggestedReplies:[`How do I track a shipment?`,`How does customs work?`],handoffOffered:!1}},{match:/track|shipment|where|status/i,result:{answer:`Centrinfo can answer from your indexed knowledge base, public website, connected files, and approved organization tools. It keeps answers grounded in your configured sources and can hand a conversation to your team when the AI is not enough.`,sources:[{title:`Centrinfo public widget`,url:`https://accurix.tech/centrinfo`}],suggestedReplies:[`How does the widget work?`,`Can a human take over?`],handoffOffered:!1}},{match:/custom|clear|duty|tariff|import/i,result:{answer:`Accurix connects your organization knowledge, channels, integrations, and public widget in one place. You can configure which sources the AI can use, which tools visitors can trigger, and when your team should take over live chat.`,sources:[{title:`Accurix documentation`,url:`https://accurix.tech/docs`}],suggestedReplies:[`Which tools can I connect?`,`How do permissions work?`],handoffOffered:!1}},{match:/price|cost|pricing|plan|quote/i,result:{answer:`Accurix uses a usage-based pricing model. Organizations keep an active subscription and spend credits as the AI answers, searches, and uses tools. Credit top-ups can extend usage when the subscription grant runs low.`,sources:[{title:`Pricing`,url:`https://accurix.tech/pricing`}],suggestedReplies:[`How do credits work?`,`Can I top up credits?`],handoffOffered:!1}}],r={answer:`That's a great question — I don't have a confident answer from Accurix's published docs yet. Want me to pass it to the team so a human can follow up? You can also book a quick demo.`,sources:[],suggestedReplies:[`What can you help with?`],handoffOffered:!0},i=e=>n.find(t=>t.match.test(e))?.result??r;var a=class{async history(){return{conversations:[]}}async bootstrap(){return await e(180),t}async stream(n,r,a){await e(550);let o=i(n),s=o.answer.split(/(\s+)/);for(let t of s){if(a.signal?.aborted)break;a.onChunk(t),await e(18+Math.min(40,t.length*6))}return{...o,availableActions:t.availableActions}}async liveEvents(){return{mode:`ai`,conversationEnded:!1,events:[]}}async presence(e){}async typing(){await e(20)}async action(t,n){return await e(450),{ok:!0,note:{"book-demo":`Demo requested. The team will follow up. 📅`,contact:`Got it — saved your details. ✅`,"contact-support":`Support request sent. The team can follow up from this chat. ✅`,inquiry:`Thanks! We'll get back to you shortly. ✉️`,"request-callback":`We'll call you back soon. 📞`,"schedule-callback":`Your callback has been scheduled.`,"subscribe-newsletter":`You're subscribed. 🎉`}[t]}}async speak(){return await e(120),{providerReady:!1,message:`Demo voice provider is not connected.`}}async transcribe(t,n,r,i){return await e(700),`How do I track a shipment?`}async uploadAttachment(e,t,n){return{id:`demo-${Date.now()}`,text:`Attached file: ${n}`,analysisFailed:!1}}async identify(t,n){await e(50)}async endConversation(t){await e(50)}async sendFeedback(){await e(50)}async sendExplanationFeedback(){await e(50)}async demoSlots(t,n){return await e(150),{taken:[[11,0],[15,0]].map(([e,t])=>{let n=new Date;return n.setHours(e,t,0,0),n.toISOString()}),busy:[]}}async searchGifs(t){await e(280);let n=t.trim().toLowerCase(),r=n?l.filter(e=>e.alt.includes(n)||e.tags.some(e=>e.includes(n)||n.includes(e))):l;return(r.length>0?r:l).map(e=>({id:e.id,url:c(e.emoji,e.anim),preview:c(e.emoji,e.anim),alt:e.alt}))}};const o=`<animateTransform attributeName='transform' attributeType='XML' type='translate' values='0 0;0 -16;0 0' dur='0.7s' repeatCount='indefinite'/>`,s=`<animateTransform attributeName='transform' attributeType='XML' type='rotate' values='-14 64 110;14 64 110;-14 64 110' dur='0.9s' repeatCount='indefinite'/>`,c=(e,t)=>{let n=`<svg xmlns='http://www.w3.org/2000/svg' width='128' height='128'><rect width='128' height='128' rx='14' fill='#eef1f4'/><text x='64' y='88' font-size='64' text-anchor='middle'>${e}${t}</text></svg>`;return`data:image/svg+xml,${encodeURIComponent(n)}`},l=[{id:`g1`,emoji:`👍`,alt:`thumbs up`,tags:[`thumbs`,`yes`,`ok`,`great`,`good`],anim:o},{id:`g2`,emoji:`🎉`,alt:`celebrate`,tags:[`party`,`yay`,`congrats`,`celebrate`],anim:s},{id:`g3`,emoji:`👋`,alt:`wave hello`,tags:[`hi`,`hello`,`hey`,`wave`,`bye`],anim:s},{id:`g4`,emoji:`❤️`,alt:`heart`,tags:[`love`,`thanks`,`heart`],anim:o},{id:`g5`,emoji:`🤔`,alt:`thinking`,tags:[`hmm`,`think`,`thinking`],anim:s},{id:`g6`,emoji:`😂`,alt:`laughing`,tags:[`lol`,`funny`,`haha`,`laugh`],anim:o},{id:`g7`,emoji:`🔥`,alt:`fire`,tags:[`fire`,`hot`,`lit`,`awesome`],anim:o},{id:`g8`,emoji:`🚀`,alt:`rocket`,tags:[`rocket`,`launch`,`fast`,`go`],anim:s}],u=e=>new Promise(t=>setTimeout(t,e));var d=class{constructor(e,t){this.real=e,this.strings=t}bootstrap(){return this.real.bootstrap()}async history(){return{conversations:[]}}async stream(e,t,n){await u(300);for(let e of this.strings.previewReply.split(/(\s+)/)){if(n.signal?.aborted)break;n.onChunk(e),await u(16)}return{answer:this.strings.previewReply,sources:[],suggestedReplies:[],availableActions:[],handoffOffered:!1}}async liveEvents(){return{mode:`ai`,conversationEnded:!1,events:[]}}async presence(e){}async typing(){}async action(){return await u(250),{ok:!0,note:this.strings.previewActionNote}}async speak(){return{providerReady:!1,message:`Preview voice provider is not connected.`}}async identify(){}async endConversation(){}async sendFeedback(){}async sendExplanationFeedback(){}async transcribe(e,t,n,r){return``}async uploadAttachment(e,t,n){return{id:`preview-${Date.now()}`,text:`Attached file: ${n}`,analysisFailed:!1}}async searchGifs(){return[]}async demoSlots(){return{taken:[],busy:[]}}};exports.MockTransport=a,exports.PreviewTransport=d;
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
const e=require(`./styles-BVQRcZkH.cjs`);let t=require(`preact`),n=require(`preact/hooks`),r=require(`preact/jsx-runtime`);const i=(e,t)=>{if(typeof MutationObserver>`u`)return()=>void 0;let n=e.scrollHeight,r=0,i=()=>{r=0;let i=e.scrollHeight,a=i>n,o=t.isAtBottom()||n-e.scrollTop-e.clientHeight<80;n=i,a&&(o?(e.scrollTop=e.scrollHeight,t.onFollow?.()):t.onUnseen?.())},a=new MutationObserver(()=>{r||(r=typeof requestAnimationFrame==`function`?requestAnimationFrame(i):setTimeout(i,0))});return a.observe(e,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:[`style`,`height`]}),()=>{a.disconnect(),r&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(r)}},a=e=>e.startsWith(`image/`)?`image`:e===`application/pdf`?`pdf`:`other`,o=({state:t,onClose:i})=>{let o=e.q(),s=(0,n.useRef)(null);(0,n.useEffect)(()=>{s.current?.focus();let e=e=>{e.key===`Escape`&&(e.stopPropagation(),i())};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[i]);let c=t.status===`ready`?a(t.mimeType):`other`;return(0,r.jsx)(`div`,{class:`cf-preview`,role:`dialog`,"aria-modal":`true`,"aria-label":e.K(o.attachPreviewTitle,{name:t.name}),onClick:e=>{e.target===e.currentTarget&&i()},children:(0,r.jsxs)(`div`,{class:`cf-preview__frame`,children:[(0,r.jsxs)(`div`,{class:`cf-preview__bar`,children:[(0,r.jsx)(`span`,{class:`cf-preview__name`,title:t.name,children:t.name}),t.status===`ready`&&(0,r.jsx)(`a`,{class:`cf-preview__btn`,href:t.url,download:t.name,children:o.attachDownload}),(0,r.jsx)(`button`,{ref:s,type:`button`,class:`cf-preview__btn cf-preview__close`,"aria-label":o.attachPreviewClose,onClick:i,children:`✕`})]}),(0,r.jsxs)(`div`,{class:`cf-preview__body`,children:[t.status===`loading`&&(0,r.jsx)(`p`,{class:`cf-preview__note`,children:o.attachPreviewLoading}),t.status===`error`&&(0,r.jsx)(`p`,{class:`cf-preview__note`,children:o.attachPreviewFailed}),t.status===`ready`&&c===`image`&&(0,r.jsx)(`img`,{class:`cf-preview__image`,src:t.url,alt:t.name}),t.status===`ready`&&c===`pdf`&&(0,r.jsx)(`iframe`,{class:`cf-preview__pdf`,src:t.url,title:t.name}),t.status===`ready`&&c===`other`&&(0,r.jsx)(`p`,{class:`cf-preview__note`,children:o.attachPreviewUnsupported})]})]})})},s=({name:t,greeting:n})=>{let i=e.q();return(0,r.jsxs)(`section`,{class:`cf-empty-welcome`,"aria-label":e.K(i.welcomeLabel,{name:t}),children:[(0,r.jsx)(`span`,{class:`cf-empty-welcome__eyebrow`,children:i.welcomeEyebrow}),(0,r.jsx)(`h2`,{children:t}),(0,r.jsx)(`p`,{children:n||i.welcomePrompt})]})},c=(e,t,n)=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),n();return}if(e.key!==`Tab`)return;let r=Array.from(t.querySelectorAll(`button, [href], textarea, input, select, [tabindex]:not([tabindex="-1"])`)).filter(e=>!e.hasAttribute(`disabled`)&&e.getAttribute(`aria-hidden`)!==`true`&&e.tabIndex>=0);if(r.length===0)return;let i=t.getRootNode(),a=e.composedPath()[0],o=a instanceof HTMLElement?a:`activeElement`in i?i.activeElement:document.activeElement,s=r[0],c=r[r.length-1];e.shiftKey&&(o===s||!t.contains(o))?(e.preventDefault(),e.stopPropagation(),c.focus()):!e.shiftKey&&(o===c||!t.contains(o))&&(e.preventDefault(),e.stopPropagation(),s.focus())},l=new Map,ee=e=>{if(!e||typeof document>`u`||typeof CanvasRenderingContext2D>`u`)return;let t=document.createElement(`canvas`).getContext(`2d`);if(!t)return;t.fillStyle=`#010203`,t.fillStyle=e;let n=t.fillStyle;if(n===`#010203`&&e.trim().toLowerCase()!==`#010203`)return;let r=n.match(/^#([\da-f]{6})$/i)?.[1];if(r)return[Number.parseInt(r.slice(0,2),16),Number.parseInt(r.slice(2,4),16),Number.parseInt(r.slice(4,6),16),1];let i=n.match(/^rgba?\(([\d.]+)[, ]+([\d.]+)[, ]+([\d.]+)(?:[, /]+([\d.]+))?\)$/i);if(!i)return;let a=i.slice(1,5).map(Number);if(!a.some(e=>!Number.isFinite(e)))return[a[0],a[1],a[2],a[3]??1]},te=(e,t=`#ffffff`)=>{let n=`${e??``}|${t}`;if(l.has(n))return l.get(n);let r=ee(e),i=ee(t)??[255,255,255,1];if(!r){l.set(n,void 0);return}let a=r[3],o=r.slice(0,3).map((e,t)=>e*a+i[t]*(1-a)).map(e=>{let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}),s=o[0]*.2126+o[1]*.7152+o[2]*.0722,c=1.05/(s+.05)>=(s+.05)/.059?`#ffffff`:`#0f1e2a`;return l.set(n,c),c},ne=e=>{let[t,r]=(0,n.useState)(`light`);return(0,n.useEffect)(()=>{if(e!==`auto`||typeof matchMedia>`u`)return;let t=matchMedia(`(prefers-color-scheme: dark)`),n=()=>r(t.matches?`dark`:`light`);return n(),t.addEventListener(`change`,n),()=>t.removeEventListener(`change`,n)},[e]),e===`auto`?t:e},u=6e4,d=90,re={end:`end the call`,mute:`mute your microphone`,minimize:`minimize the chat`,expand:`expand the view`,shrink:`exit the expanded view`},ie=e=>e.trim().toLowerCase().replace(/[^\p{L}\p{N}\s']/gu,` `).replace(/\s+/g,` `).trim(),ae=[{action:`shrink`,re:/\b(?:exit|leave|quit|close)\b[\s\w]*\b(?:full ?screen|expanded|theat(?:er|re))\b|\bshrink\b|\bsmaller view\b/},{action:`end`,re:/\b(?:end|close|stop|finish|hang ?up|quit|exit)\b[\s\w]*\b(?:call|chat|conversation|convo|session|talking)\b|\bhang ?up\b|\bgood ?bye\b|^bye(?: bye)?$/},{action:`mute`,re:/\bmute\b|\bstop listening\b/},{action:`minimize`,re:/\bminimi[sz]e\b|\bhide\b[\s\w]*\b(?:chat|call|window|widget)\b/},{action:`expand`,re:/\bexpand\b|\bmaximi[sz]e\b|\bfull ?screen\b|\btheat(?:er|re) mode\b|\bbigger view\b/}],oe=/^(?:yes|yeah|yep|yup|sure|correct|confirm|affirmative|go ahead|do it|please do|ok(?:ay)?)\b/,se=/^(?:no|nope|nah|cancel|never ?mind|don'?t|stop)\b/,ce=/^(?:end|close|stop|finish|hang ?up|quit|exit|bye|good ?bye)\b/,le=e=>{let t=ie(e);if(!t)return null;for(let{action:e,re:n}of ae)if(n.test(t)){let n=t.split(` `).length;return{action:e,confident:e===`end`?n<=10:n<=6}}return null},ue=e=>`I didn't catch yes or no. Say yes to ${re[e]}, or no to keep talking.`,f=({transport:t,config:a,bindControls:l,composerDraftStore:ee})=>{let u=a.strings,[d,ae]=(0,n.useState)(a.openByDefault),{persona:f,messages:p,sending:m,assistantSpeaking:h,visitor:de,hasEmail:fe,liveMode:g,assignedAgentName:pe,agentTypingName:me,starters:he,featuredLinks:ge,send:_,sendGif:_e,notifyTyping:ve,stop:ye,amend:be,hold:xe,resumeHeld:Se,duckSpeaking:Ce,retry:we,rateMessage:Te,doubleCheckResponse:Ee,retryResponse:De,rateExplanation:Oe,explanationTransport:ke,injectAssistant:Ae,reconnectSupport:je,appendUserDraft:Me,patchMessage:v,removeMessage:Ne,submitCsat:Pe,submitForm:Fe,confirmHostedBooking:Ie,transcribe:Le,uploadAttachment:Re,loadAttachment:ze,searchGifs:Be,demoSlots:Ve,gifEnabled:He,identify:Ue,ended:y,endConversation:We,startNew:Ge,history:Ke,viewingSessionId:qe,viewMessages:Je,openConversation:Ye,closeHistoryView:Xe,shutdown:Ze,stopSpeaking:b,speakAssistantText:Qe,analyticsModels:$e,analyticsModelId:et,selectAnalyticsModel:tt}=e.o(t,a,d),nt=e.a(p,g),[rt,it]=(0,n.useState)(null),at=(0,n.useRef)(0),ot=(0,n.useCallback)((e,t,n)=>{n===at.current&&it({status:`ready`,name:t,url:URL.createObjectURL(e),mimeType:e.type||`application/octet-stream`})},[]),st=(0,n.useCallback)((e,t,n)=>{let r=t.name,i=++at.current;it({status:`loading`,name:r}),ze(e,t,n).then(e=>ot(e,r,i),()=>{i===at.current&&it({status:`error`,name:r})})},[ze,ot]),ct=(0,n.useCallback)((e,t)=>ot(e,t,++at.current),[ot]),lt=(0,n.useCallback)(()=>{at.current+=1,it(null)},[]);(0,n.useEffect)(()=>()=>{rt?.status===`ready`&&URL.revokeObjectURL(rt.url)},[rt]);let ut=!!e.i(f?.actions),[x,dt]=(0,n.useState)(0),[S,ft]=(0,n.useState)({mic:`off`,processing:!1}),[pt,mt]=(0,n.useState)(null),[ht,gt]=(0,n.useState)(!1),[C,_t]=(0,n.useState)(!1),[vt,yt]=(0,n.useState)(!1),[bt,xt]=(0,n.useState)(!1),[St,Ct]=(0,n.useState)(0),[w,T]=(0,n.useState)(!1),[wt,E]=(0,n.useState)(null),[Tt,Et]=(0,n.useState)(null),[Dt,Ot]=(0,n.useState)([]),[kt,At]=(0,n.useState)(``),[jt,Mt]=(0,n.useState)(()=>{try{return localStorage.getItem(`centrinfo:muted`)===`1`}catch{return!1}}),Nt=ne(a.theme),Pt=f?.soundEnabled??!0;(0,n.useEffect)(()=>{e.f(a.sound&&Pt&&!jt)},[a.sound,Pt,jt]);let Ft=(0,n.useCallback)(()=>{Mt(e=>{let t=!e;try{localStorage.setItem(`centrinfo:muted`,t?`1`:`0`)}catch{}return t})},[]),D=(0,n.useRef)(null),It=(0,n.useRef)(null),Lt=(0,n.useRef)(null),Rt=(0,n.useRef)(0),O=(0,n.useRef)(!1),k=(0,n.useRef)(!1),A=(0,n.useRef)(null),j=(0,n.useRef)(0),zt=(0,n.useRef)(void 0),Bt=(0,n.useRef)(0),M=(0,n.useRef)(null),N=(0,n.useRef)(!1),P=(0,n.useRef)(null),F=(0,n.useRef)(``),Vt=(0,n.useRef)(()=>{}),Ht=(0,n.useRef)(``),Ut=(0,n.useRef)(m),Wt=(0,n.useRef)(_);Wt.current=_;let Gt=(0,n.useRef)(be);Gt.current=be;let Kt=(0,n.useRef)(Le);Kt.current=Le;let I=(0,n.useRef)(!1),L=(0,n.useRef)(!1),qt=(0,n.useRef)(``);qt.current=[...p].reverse().find(e=>e.role===`assistant`)?.content??``;let Jt=(0,n.useRef)(h);Ut.current=m,Jt.current=h;let R=C?ht?`timeout`:bt||S.mic===`muted`?`muted`:S.mic===`unavailable`?S.reason===`permission-denied`||S.reason===`unsupported`?`denied`:`unavailable`:S.mic===`off`||S.mic===`starting`?`connecting`:S.mic===`hearing`?`hearing`:h?`speaking`:pt??(S.processing||m?`processing`:`listening`):`idle`,[Yt,Xt]=(0,n.useState)(!0),[Zt,z]=(0,n.useState)(!1),Qt=(0,n.useRef)(0),[B,V]=(0,n.useState)(!1),[H,U]=(0,n.useState)(!1),[W,G]=(0,n.useState)(!1),$t=(0,n.useRef)({value:``}),en=ee??$t.current,tn=(0,n.useRef)({confirmEnd:B,confirmClear:H,showHistory:W});tn.current={confirmEnd:B,confirmClear:H,showHistory:W};let[nn,rn]=(0,n.useState)(!1),K=!!qe,an=K?Je:p,on=an.find(e=>e.id===wt&&e.visualization)?.visualization,sn=an.find(e=>e.id===Tt&&e.visualization);(0,n.useEffect)(()=>{!Tt||sn||(Et(null),T(!1))},[Tt,sn]),(0,n.useEffect)(()=>{!wt||on||(E(null),T(!1))},[on,wt]);let q=(0,n.useCallback)(()=>{ae(!0),dt(0),e.d(`open`),a.onOpen?.(),a.onShow?.()},[a]),J=(0,n.useCallback)(()=>{ae(!1),T(!1),E(null),a.onClose?.(),a.onHide?.(),It.current?.focus()},[a]),cn=(0,n.useCallback)(()=>d?J():q(),[d,q,J]),ln=(0,n.useCallback)(()=>V(!0),[]),un=(0,n.useCallback)(()=>{We(),V(!1)},[We]),dn=(0,n.useCallback)(()=>{Ge(),z(!1),Xt(!0)},[Ge]);(0,n.useEffect)(()=>{l({open:q,close:J,toggle:cn,identify:Ue,startNew:Ge,endConversation:We,shutdown:Ze})},[l,q,J,cn,Ue,Ge,We,Ze]),(0,n.useEffect)(()=>{let e=p.filter(e=>e.role===`assistant`&&!e.pending).length;if(d){Rt.current=e;return}e>Rt.current&&dt(e-Rt.current)},[p,d]),(0,n.useEffect)(()=>{a.onUnreadChange?.(x)},[x,a]),(0,n.useEffect)(()=>{let e=a.sessionDurationMinutes;if(!e||e<=0)return;let t=setTimeout(()=>Ze(),e*60*1e3);return()=>clearTimeout(t)},[a.sessionDurationMinutes,p,d,Ze]),(0,n.useEffect)(()=>{let e=a.customLauncherSelector;if(!e||typeof document>`u`)return;let t=[];try{t=Array.from(document.querySelectorAll(e))}catch{return}let n=e=>{e.preventDefault(),cn()};return t.forEach(e=>e.addEventListener(`click`,n)),()=>t.forEach(e=>e.removeEventListener(`click`,n))},[a.customLauncherSelector,cn]);let fn=(0,n.useRef)(!1);(0,n.useEffect)(()=>{let e=a.proactiveMessage?.trim();if(!e||fn.current)return;let t=a.proactiveOnPaths??[],n=typeof location<`u`?location.pathname:``;if(t.length>0&&!t.some(e=>n.includes(e)))return;let r=`centrinfo:proactive:${a.token.slice(0,12)}`;try{if(sessionStorage.getItem(r)===`1`)return}catch{}let i=setTimeout(()=>{if(!(d||y||p.some(e=>e.role===`user`))){fn.current=!0;try{sessionStorage.setItem(r,`1`)}catch{}Ae(e),q()}},Math.max(0,a.proactiveDelaySeconds)*1e3);return()=>clearTimeout(i)},[a.proactiveMessage]),(0,n.useEffect)(()=>{let e=Lt.current;if(!d||!e)return;let t=p[p.length-1],n=Date.now()<Qt.current;t?.role===`user`||Yt||n?(requestAnimationFrame(()=>{e.scrollTop=e.scrollHeight}),z(!1),n&&Xt(!0)):z(!0)},[p,d,m,Yt]);let pn=(0,n.useRef)(!0);pn.current=Yt,(0,n.useEffect)(()=>{let e=Lt.current;if(!(!d||!e))return i(e,{isAtBottom:()=>pn.current,onUnseen:()=>z(!0)})},[d,K]);let mn=(0,n.useCallback)(()=>{let e=Lt.current;if(!e)return;let t=e.getRootNode(),n=t instanceof ShadowRoot?t.activeElement:e.ownerDocument.activeElement;if(n instanceof HTMLIFrameElement&&e.contains(n)&&(Qt.current=0),O.current&&!K){Xt(!0),z(!1);return}let r=e.scrollHeight-e.scrollTop-e.clientHeight<80;Xt(r),r&&z(!1)},[K]),Y=(0,n.useCallback)(()=>{let e=Lt.current;e&&(e.scrollTop=e.scrollHeight),z(!1),Xt(!0)},[]),hn=(0,n.useCallback)(()=>{Qt.current=Date.now()+3e3,requestAnimationFrame(Y)},[Y]);(0,n.useEffect)(()=>{if(!d||K||!C||R===`connecting`)return;Qt.current=Date.now()+6e4,Y();let e=requestAnimationFrame(()=>{Y(),requestAnimationFrame(Y)}),t=[80,180,360].map(e=>window.setTimeout(Y,e));return()=>{cancelAnimationFrame(e),t.forEach(e=>window.clearTimeout(e))}},[h,p,d,Y,m,C,K,R]);let gn=(0,n.useCallback)(()=>{D.current?.querySelector(`.cf-textarea`)?.focus()},[]),_n=(0,n.useCallback)((e,t)=>{mt(e),zt.current&&window.clearTimeout(zt.current),zt.current=window.setTimeout(()=>mt(null),3e3),t&&!k.current&&Qe(t)},[Qe]),vn=(0,n.useCallback)(e=>{let t=P.current;if(t)return t;hn();let n=Me(e);return P.current=n,v(n,{content:F.current||e,pending:!0,streaming:!1}),n},[Me,hn,v]),X=(0,n.useCallback)(()=>{let e=P.current;if(e){if(F.current){v(e,{content:F.current,pending:!0});return}P.current=null,Ne(e)}},[v,Ne]),Z=(0,n.useCallback)(()=>{L.current&&(L.current=!1,Ce(!1)),I.current&&(I.current=!1,Se())},[Ce,Se]),Q=(0,n.useCallback)(()=>{O.current=!1,A.current?.stop(`call-ended`),A.current=null,I.current=!1,L.current=!1,k.current=!1,M.current=null,N.current=!1;let e=P.current;P.current=null,F.current=``,e&&Ne(e),zt.current&&window.clearTimeout(zt.current),mt(null),gt(!1),ft({mic:`off`,processing:!1}),Ct(0),_t(!1),yt(!1),xt(!1),T(!1),E(null),b()},[Ne,b]),yn=(0,n.useCallback)(()=>{w&&E(null),T(!w)},[w]),bn=(0,n.useCallback)(e=>{E(e),T(!0)},[]),xn=(0,n.useCallback)(e=>{Et(e),T(!0)},[]),Sn=(0,n.useCallback)(()=>{let e=wt,t=Tt;E(null),Et(null),T(!1),window.requestAnimationFrame(()=>{(t?D.current?.querySelector(`[data-explanation-message="${t}"]`)?.querySelector(`[data-testid="analytics-explanation-expand"]`):Array.from(D.current?.querySelectorAll(`[data-visualization-message]`)??[]).find(t=>t.dataset.visualizationMessage===e))?.focus()})},[wt,Tt]),Cn=(0,n.useCallback)(()=>{E(null),Et(null),T(!1)},[]),wn=(0,n.useCallback)((e,t,n=!1)=>{if(hn(),t&&(v(t,{content:e,pending:!1,streaming:!1}),P.current===t&&(P.current=null)),F.current=``,n){b(),Gt.current(e,{forceVoicePlayback:!0,userMessageId:t});return}O.current&&(xe()?Gt.current(e,{forceVoicePlayback:!0,userMessageId:t}):Wt.current(e,{forceVoicePlayback:!0,userMessageId:t}))},[hn,xe,v,b]),$=(0,n.useCallback)(e=>{Ae(e),Qe(e)},[Ae,Qe]),Tn=(0,n.useCallback)(()=>{if(j.current=Date.now(),mt(null),Jt.current){L.current=!0,Ce(!0);return}I.current||(I.current=xe()),vn(`Listening...`)},[Ce,vn,xe]),En=(0,n.useCallback)(e=>{let t=P.current;!t||L.current||v(t,{content:`${[F.current,e].filter(Boolean).join(` `)} ...`,pending:!0})},[v]),Dn=(0,n.useCallback)(t=>{j.current=Date.now();let n=[F.current,t.text].map(e=>e.trim()).filter(Boolean).join(` `).replace(/\s+/g,` `).trim();if((L.current||t.overlappedOutput)&&e.V(t.text,qt.current)){X(),Z();return}if(!n||e.m(n)||e.h(n)){let e=L.current||I.current;X(),Z(),e||_n(`misunderstood`);return}L.current&&(L.current=!1,ye(),b());let r=M.current;if(r){F.current=``,X();let e=ie(n);if(oe.test(e)||r===`end`&&ce.test(e)){M.current=null,Vt.current(r);return}if(se.test(e)){M.current=null,$(`Okay, never mind — what would you like to know?`);return}$(ue(r));return}let i=le(n);if(i){if(F.current=``,X(),Z(),i.confident){Vt.current(i.action);return}M.current=i.action,$(`Just to confirm — you want me to ${re[i.action]}? Please say yes or no.`);return}let a=vn(n);v(a,{content:n,pending:!0});let o=I.current;I.current=!1,wn(n,a,o)},[vn,v,Z,wn,X,_n,$,ye,b]),On=(0,n.useCallback)(e=>{j.current=Date.now();let t=L.current||I.current;if(X(),Z(),!(t||e.overlappedOutput||e.reason===`too-short`)){if(e.reason===`transcribe-failed`){_n(`misunderstood`,`I couldn't transcribe that. Please try again, or type your question.`);return}_n(`noise`)}},[Z,X,_n]),kn=(0,n.useRef)({speechStart:Tn,partial:En,turn:Dn,noise:On});kn.current={speechStart:Tn,partial:En,turn:Dn,noise:On};let An=(0,n.useCallback)(()=>{navigator.mediaDevices?.enumerateDevices().then(e=>{Ot(e.filter(e=>e.kind===`audioinput`).map((e,t)=>({deviceId:e.deviceId,label:e.label||`Microphone ${t+1}`})))}).catch(()=>{})},[]),jn=(0,n.useCallback)(()=>{if(O.current){Q();return}if(gn(),!f?.allowVoiceInput||!f.talkbackMode||f.talkbackMode===`text`||Ut.current||y||K)return;j.current=Date.now(),k.current=!1,O.current=!0,xt(!1),_t(!0),yt(!1),gt(!1);let t=!1,n=new e.B({deviceId:Ht.current||void 0,transcribe:async({audio:t,mimeType:n,durationSeconds:r})=>{let i=typeof navigator<`u`&&(navigator.languages?.[0]||navigator.language)||void 0;return e.g(await Kt.current(t,n,i,r))},listener:{state:e=>{ft(e),e.mic!==`starting`&&e.mic!==`off`&&yt(!0),!t&&e.mic===`listening`&&(t=!0,An())},speechStart:()=>kn.current.speechStart(),partial:({text:e})=>kn.current.partial(e),turn:e=>kn.current.turn(e),noise:e=>kn.current.noise(e),level:e=>{let t=performance.now();t-Bt.current<90||(Bt.current=t,Ct(e))}}});A.current=n,n.setOutputActive(Jt.current),n.start()},[Q,y,gn,f,An,K]),Mn=(0,n.useCallback)(()=>{let e=!k.current;k.current=e,xt(e),A.current?.setMuted(e),e?(F.current=``,X(),Z()):j.current=Date.now()},[Z,X]),Nn=(0,n.useCallback)(e=>{switch(j.current=Date.now(),e){case`end`:N.current=!0,$(`Okay — ending our call now. Goodbye!`),window.setTimeout(()=>{N.current&&(N.current=!1,Q())},2e3);break;case`mute`:k.current||Mn(),$(`Muted. Tap the mic button when you want me to listen again.`);break;case`minimize`:J(),$(`Minimized — I'm still listening. Tap the call pill to bring the chat back.`);break;case`expand`:T(!0),$(`Sure — expanding the view.`);break;case`shrink`:E(null),T(!1),$(`Okay — back to the smaller view.`);break}},[J,Q,$,Mn]);(0,n.useEffect)(()=>{Vt.current=Nn},[Nn]);let Pn=(0,n.useRef)(!1);(0,n.useEffect)(()=>{Pn.current&&!h&&N.current&&(N.current=!1,Q()),Pn.current=h},[h,Q]);let Fn=(0,n.useCallback)(e=>{Ht.current=e,At(e),A.current?.selectDevice(e||void 0)},[]),In=(0,n.useCallback)(()=>{!O.current||k.current||(L.current=!1,I.current=!1,ye(),b(),j.current=Date.now())},[ye,b]);(0,n.useEffect)(()=>{A.current?.setOutputActive(h),j.current=Date.now()},[h]),(0,n.useEffect)(()=>{if(R!==`denied`)return;let e=window.setTimeout(()=>Q(),3500);return()=>window.clearTimeout(e)},[Q,R]),(0,n.useEffect)(()=>{if(!C)return;let e=window.setInterval(()=>{let e=A.current;!e||k.current||Ut.current||Jt.current||e.snapshot.mic===`hearing`||e.snapshot.processing||Date.now()-j.current<6e4||(A.current?.log.add(`call-timeout`),gt(!0),window.setTimeout(()=>Q(),2400))},5e3);return()=>window.clearInterval(e)},[Q,C]);let Ln=C&&!bt&&(m||h);(0,n.useEffect)(()=>()=>Q(),[Q]);let[Rn,zn]=(0,n.useState)(``),Bn=(0,n.useRef)(!1);(0,n.useEffect)(()=>{if(Bn.current&&!m){let e=[...p].reverse().find(e=>e.role===`assistant`&&!e.streaming&&!e.pending&&e.content);e&&zn(e.content)}Bn.current=m},[m,p]),(0,n.useLayoutEffect)(()=>{if(!d)return;let e=D.current,t=B||H?e?.querySelector(`.cf-confirm__card`):W?e?.querySelector(`.cf-history`):null;if(!t)return;let n=t.getRootNode(),r=`activeElement`in n?n.activeElement:document.activeElement;(!r||!t.contains(r))&&t.querySelector(`button, [href], textarea, input, [tabindex]:not([tabindex="-1"])`)?.focus()},[H,B,d,W]),(0,n.useEffect)(()=>{if(!d)return;let e=D.current,t=B||H?e?.querySelector(`.cf-confirm__card`):W?e?.querySelector(`.cf-history`):null,n=e?.querySelectorAll(`:scope > .cf-header, :scope > .cf-panel__video, :scope > .cf-panel__chat`);n?.forEach(e=>{t?(e.setAttribute(`inert`,``),e.setAttribute(`aria-hidden`,`true`)):(e.removeAttribute(`inert`),e.removeAttribute(`aria-hidden`))}),t||requestAnimationFrame(()=>e?.querySelector(`.cf-textarea`)?.focus());let r=n=>{if(n.key===`Escape`){n.preventDefault();let t=tn.current;if(t.confirmEnd){V(!1);return}if(t.confirmClear){U(!1);return}if(t.showHistory){G(!1);return}if(e?.querySelector(`.cf-action-drawer`))return;J();return}if(n.key!==`Tab`||!t)return;let r=t.querySelectorAll(`button, [href], textarea, input, [tabindex]:not([tabindex="-1"])`),i=Array.from(r).filter(e=>!e.hasAttribute(`disabled`));if(i.length===0)return;let a=i[0],o=i[i.length-1],s=t.getRootNode()instanceof ShadowRoot?t.getRootNode().activeElement:document.activeElement;n.shiftKey&&s===a?(n.preventDefault(),o.focus()):!n.shiftKey&&s===o&&(n.preventDefault(),a.focus())};return e?.addEventListener(`keydown`,r),()=>{e?.removeEventListener(`keydown`,r),n?.forEach(e=>{e.removeAttribute(`inert`),e.removeAttribute(`aria-hidden`)})}},[d,J,B,H,W]),(0,n.useEffect)(()=>{let e=D.current;e&&(d?e.removeAttribute(`inert`):e.setAttribute(`inert`,``))},[d]);let Vn=a.accentColor??a.themeTokens?.accent??f?.accentColor,Hn=a.themeTokens?.accentText??te(Vn,a.themeTokens?.background??(Nt===`dark`?`#0f1c27`:`#ffffff`)),Un={zIndex:a.zIndex,"--cf-h-pad":`${a.horizontalPadding}px`,"--cf-v-pad":`${a.verticalPadding}px`,...Hn?{"--cf-accent-ink":Hn}:{},...a.themeTokens?.accentStrong?{"--cf-accent-2":a.themeTokens.accentStrong}:{},...a.themeTokens?.background?{"--cf-bg":a.themeTokens.background}:{},...a.themeTokens?.surface?{"--cf-surface":a.themeTokens.surface}:{},...a.themeTokens?.surfaceMuted?{"--cf-surface-2":a.themeTokens.surfaceMuted}:{},...a.themeTokens?.text?{"--cf-text":a.themeTokens.text}:{},...a.themeTokens?.mutedText?{"--cf-muted":a.themeTokens.mutedText}:{},...a.themeTokens?.border?{"--cf-border":a.themeTokens.border}:{},...a.themeTokens?.shadow?{"--cf-shadow":a.themeTokens.shadow}:{},...a.themeTokens?.radius?{"--cf-radius":a.themeTokens.radius}:{},...a.themeTokens?.fontFamily?{"--cf-font":a.themeTokens.fontFamily}:{},...a.themeTokens?.success?{"--cf-success":a.themeTokens.success}:{},...a.themeTokens?.warning?{"--cf-warning":a.themeTokens.warning}:{},...a.themeTokens?.danger?{"--cf-danger":a.themeTokens.danger}:{},...Vn?{"--cf-accent":Vn,"--cf-accent-2":a.themeTokens?.accentStrong??`color-mix(in oklab, ${Vn} 76%, #14141f)`}:{}},Wn=e=>_(e),Gn=[...p].reverse().find(e=>e.role===`user`&&e.content.trim())?.content??``,Kn=p.some(e=>e.role===`user`),qn=!!(f?.allowVoiceInput&&f?.talkbackMode&&f.talkbackMode!==`text`),Jn=qn,Yn=!K&&Jn&&!Kn?an.filter((e,t)=>!(t===0&&e.role===`assistant`)):an,Xn=g===`human`&&pe?pe:f?.agentName??u.chatName,Zn=g===`human`?u.liveSupport:g===`queued`?u.waitingForTeam:f?.offline?u.statusOffline:u.statusOnline,Qn=!y&&!K?f?.availableActions:void 0,$n=!y&&!K?f?.actions:void 0,er=C&&!vt&&R===`connecting`&&!K;return(0,r.jsx)(e.G,{value:u,children:(0,r.jsx)(e.W,{value:a.locale,children:(0,r.jsxs)(`div`,{class:`cf-root`,dir:a.dir,"data-theme":Nt,"data-align":a.alignment,"data-display":`floating`,style:Un,children:[w&&d&&(0,r.jsx)(`div`,{class:`cf-theater-backdrop`,onClick:Cn}),(0,r.jsxs)(`div`,{ref:D,class:`cf-panel ${d?`is-open`:``} ${C?`cf-panel--call`:``} ${er?`cf-panel--voice-connecting`:``} ${w&&d?`cf-panel--theater`:``} ${on||sn?`cf-panel--analytics-focus`:``}`,role:`dialog`,"aria-modal":`false`,"aria-label":`${u.chatName}: ${f?.agentName??u.assistantName}`,"aria-hidden":!d,children:[rt&&d&&(0,r.jsx)(o,{state:rt,onClose:lt}),(0,r.jsxs)(`div`,{class:`cf-header`,children:[(0,r.jsx)(e.y,{persona:f,hideWhenMissing:!0}),(0,r.jsxs)(`div`,{class:`cf-header__meta`,children:[(0,r.jsx)(`div`,{class:`cf-header__name`,children:Xn}),a.token.startsWith(`pub_test_`)?(0,r.jsx)(`small`,{role:`status`,children:u.testMode}):null,(0,r.jsx)(`div`,{class:`cf-header__status ${g===`ai`&&f?.offline?`cf-header__status--offline`:``}`,children:(0,r.jsx)(`span`,{class:`cf-header__status-text`,children:Zn})})]}),(0,r.jsxs)(`div`,{class:`cf-header__actions`,children:[Ke.length>0&&(0,r.jsx)(`button`,{type:`button`,class:`cf-header__btn`,"aria-label":u.pastConversations,title:u.pastConversations,"aria-pressed":W,onClick:()=>G(e=>!e),children:(0,r.jsx)(e.N,{})}),Kn&&!y&&!K&&(0,r.jsx)(`button`,{type:`button`,class:`cf-header__btn`,"aria-label":u.endChat,title:u.endChat,onClick:ln,children:(0,r.jsx)(e.M,{})}),a.sound&&Pt&&(0,r.jsx)(`button`,{type:`button`,class:`cf-header__btn`,"aria-label":jt?u.unmuteSounds:u.muteSounds,"aria-pressed":jt,onClick:Ft,children:jt?(0,r.jsx)(e.P,{}):(0,r.jsx)(e.F,{})}),(0,r.jsx)(`button`,{type:`button`,class:`cf-header__btn cf-header__close`,"aria-label":u.closeChat,onClick:J,children:(0,r.jsx)(e.j,{})})]})]}),(0,r.jsx)(`div`,{class:`cf-panel__video`,children:on?(0,r.jsx)(`div`,{class:`cf-analytics-focus`,role:`region`,"aria-label":u.expandedAnalyticsResult,children:(0,r.jsx)(e.D,{visualization:on,explanationTransport:K?void 0:ke(`widget`),onExplanationFeedback:K?void 0:Oe,onOpenAnalyticsSource:a.onOpenAnalyticsSource,expanded:!0,onFollowUp:e=>{Sn(),_(e)},onClose:Sn})}):sn?.visualization?(0,r.jsx)(`div`,{class:`cf-analytics-focus`,role:`region`,"aria-label":u.expandedAnalyticsResult,children:(0,r.jsx)(e.E,{visualization:sn.visualization,onClose:Sn,onFollowUp:e=>{Sn(),_(e)},onFeedback:K?void 0:Oe,transport:K?void 0:ke(`widget`),onOpenSource:a.onOpenAnalyticsSource})}):!K&&Jn?(0,r.jsx)(e.b,{persona:f,starters:[],onPick:_,onFocusComposer:jn,speaking:h,voiceState:R,replyPending:C&&m&&!h,pinned:!0,muted:bt,onToggleMute:Mn,onEndCall:Q,onTalkNow:In,showTalkNow:Ln,micLevel:St,theaterMode:w,onToggleTheater:yn,onMinimize:J,audioDevices:Dt,selectedAudioDeviceId:kt,onSelectAudioDevice:Fn,connectingOnly:er}):null}),!er&&(0,r.jsxs)(`div`,{class:`cf-panel__chat`,children:[a.preview&&(0,r.jsx)(`div`,{class:`cf-preview-banner`,children:u.previewBanner}),K&&(0,r.jsx)(`div`,{class:`cf-viewing-banner`,children:u.viewingPast}),(0,r.jsxs)(`div`,{class:`cf-body`,ref:Lt,role:`log`,onScroll:mn,children:[Yn.map((t,n)=>(0,r.jsx)(e.w,{msg:t,persona:f,isLast:!K&&n===Yn.length-1,visitor:de,hasEmail:fe,lastQuestion:Gn,showActions:!K&&n===Yn.length-1&&!!(t.handoffOffered||t.selectedAction),onPickReply:Wn,onSubmitForm:Fe,onDemoSlots:Ve,onConfirmHostedBooking:Ie,onRetry:we,ratable:!K&&Yn.slice(0,n).some(e=>e.role===`user`),onRate:Te,onDoubleCheck:K||y?void 0:Ee,onRetryResponse:K||y||g!==`ai`?void 0:De,doubleCheckDisabled:m,onExplanationFeedback:K?void 0:Oe,explanationTransport:K?void 0:ke(`widget`),onOpenAnalyticsSource:a.onOpenAnalyticsSource,onExpandVisualization:K?void 0:bn,onExpandExplanation:K?void 0:xn,onOpenAttachment:st,onReconnect:!K&&!y&&ut&&t.id===nt?je:void 0},t.id)),!Kn&&!K&&(0,r.jsxs)(r.Fragment,{children:[Yn.length===0&&(0,r.jsx)(s,{name:f?.agentName??u.assistantName,greeting:f?.greeting}),(0,r.jsx)(e.T,{items:he,onPick:_}),(0,r.jsx)(e.S,{items:ge})]}),Zt&&(0,r.jsxs)(`button`,{type:`button`,class:`cf-newmsg`,onClick:Y,children:[(0,r.jsx)(e.k,{}),u.newMessages]})]}),(0,r.jsx)(`div`,{class:`cf-sr-live`,"aria-live":`polite`,"aria-atomic":`true`,children:Rn}),m&&!y&&!K&&(0,r.jsx)(`div`,{class:`cf-stopbar`,children:(0,r.jsxs)(`button`,{type:`button`,class:`cf-stop`,onClick:ye,children:[(0,r.jsx)(e.I,{}),u.stop]})}),K?(0,r.jsx)(`div`,{class:`cf-ended`,children:(0,r.jsx)(`button`,{type:`button`,class:`cf-ended__btn`,onClick:Xe,children:u.backToChat})}):y?(0,r.jsxs)(`div`,{class:`cf-ended`,children:[(0,r.jsx)(`p`,{class:`cf-ended__text`,children:u.conversationEnded}),a.csat&&Kn?nn?(0,r.jsx)(`p`,{class:`cf-ended__text`,children:u.feedbackThanks}):(0,r.jsxs)(`div`,{class:`cf-csat`,children:[(0,r.jsx)(`span`,{class:`cf-csat__q`,children:u.csatPrompt}),(0,r.jsx)(`button`,{type:`button`,class:`cf-csat__btn`,"aria-label":u.feedbackHelpful,onClick:()=>{Pe(`up`),rn(!0)},children:(0,r.jsx)(e.R,{})}),(0,r.jsx)(`button`,{type:`button`,class:`cf-csat__btn`,"aria-label":u.feedbackNotHelpful,onClick:()=>{Pe(`down`),rn(!0)},children:(0,r.jsx)(e.L,{})})]}):null,(0,r.jsx)(`button`,{type:`button`,class:`cf-ended__btn`,onClick:dn,children:u.startNewChat})]}):(0,r.jsxs)(r.Fragment,{children:[me?(0,r.jsx)(`div`,{class:`cf-live-typing`,"aria-live":`polite`,children:e.K(u.agentTyping,{name:me})}):null,Qn&&Qn.length>0&&(0,r.jsx)(`div`,{class:`cf-footer-actions`,children:(0,r.jsx)(e.v,{actions:Qn,descriptors:$n,visitor:de,onSubmitForm:Fe,onDemoSlots:Ve,onConfirmHostedBooking:Ie,scheduler:f?.scheduler,translations:a.actionTranslations})},`footer-actions`),(0,r.jsx)(e.x,{toolbarContent:a.showAnalyticsModelSelector?(0,r.jsx)(e.U,{models:$e,value:et,onChange:tt,disabled:m}):null,draftStore:en,onSend:_,onSendGif:_e,onTyping:ve,disabled:m,allowVoice:qn&&a.composer?.voice!==!1,onTranscribe:Le,gifEnabled:He,onSearchGifs:Be,allowAttach:a.attachments,analyzeAttachments:!0,onUpload:Re,onPreviewAttachment:ct},`composer`)]}),!y&&f?.disclaimerText&&(0,r.jsx)(`div`,{class:`cf-disclaimer`,children:f.disclaimerText}),(0,r.jsxs)(`div`,{class:`cf-footer`,children:[(0,r.jsx)(`button`,{type:`button`,class:`cf-footer__privacy`,"aria-label":u.clearDeviceData,onClick:()=>U(!0),children:u.privacyAndData}),(0,r.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),u.poweredBy,` `,(0,r.jsx)(`a`,{href:`https://accurixtech.com/centrinfo`,target:`_blank`,rel:`noopener noreferrer`,children:`Centrinfo`})]})]}),B&&(0,r.jsx)(`div`,{class:`cf-confirm`,onClick:()=>V(!1),children:(0,r.jsxs)(`div`,{class:`cf-confirm__card`,role:`alertdialog`,"aria-modal":`true`,"aria-label":u.endChatConfirm,onClick:e=>e.stopPropagation(),onKeyDownCapture:e=>c(e,e.currentTarget,()=>V(!1)),children:[(0,r.jsx)(`div`,{class:`cf-confirm__title`,children:u.endChatConfirm}),(0,r.jsx)(`div`,{class:`cf-confirm__body`,children:u.endChatConfirmBody}),(0,r.jsxs)(`div`,{class:`cf-confirm__actions`,children:[(0,r.jsx)(`button`,{type:`button`,class:`cf-confirm__btn cf-confirm__btn--cancel`,onClick:()=>V(!1),children:u.cancel}),(0,r.jsx)(`button`,{type:`button`,class:`cf-confirm__btn cf-confirm__btn--danger`,onClick:un,children:u.endConfirmCta})]})]})},`confirm-end`),W&&(0,r.jsx)(`div`,{class:`cf-confirm`,onClick:()=>G(!1),children:(0,r.jsxs)(`div`,{class:`cf-history`,role:`dialog`,"aria-modal":`true`,"aria-label":u.pastConversations,onClick:e=>e.stopPropagation(),onKeyDownCapture:e=>c(e,e.currentTarget,()=>G(!1)),children:[(0,r.jsxs)(`div`,{class:`cf-history__head`,children:[(0,r.jsx)(`span`,{children:u.pastConversations}),(0,r.jsx)(`button`,{type:`button`,class:`cf-header__btn`,"aria-label":u.closeHistory,onClick:()=>G(!1),children:(0,r.jsx)(e.j,{})})]}),(0,r.jsx)(`div`,{class:`cf-history__list`,children:Ke.map(e=>(0,r.jsxs)(`button`,{type:`button`,class:`cf-history__item ${e.sessionId===qe?`is-active`:``}`,onClick:()=>{Ye(e.sessionId),G(!1)},children:[(0,r.jsx)(`span`,{class:`cf-history__title`,children:e.title}),(0,r.jsxs)(`span`,{class:`cf-history__meta`,children:[new Date(e.ts).toLocaleDateString(void 0,{month:`short`,day:`numeric`}),e.ended?` · ${u.historyEnded}`:``]})]},e.sessionId))}),(0,r.jsx)(`div`,{class:`cf-history__footer`,children:(0,r.jsx)(`button`,{type:`button`,class:`cf-history__clear`,onClick:()=>{G(!1),U(!0)},children:u.clearDeviceData})})]})},`history`),H&&(0,r.jsx)(`div`,{class:`cf-confirm`,onClick:()=>U(!1),children:(0,r.jsxs)(`div`,{class:`cf-confirm__card`,role:`alertdialog`,"aria-modal":`true`,"aria-label":u.clearDeviceData,onClick:e=>e.stopPropagation(),onKeyDownCapture:e=>c(e,e.currentTarget,()=>U(!1)),children:[(0,r.jsx)(`div`,{class:`cf-confirm__title`,children:u.clearDeviceData}),(0,r.jsx)(`div`,{class:`cf-confirm__body`,children:u.clearDeviceDataBody}),(0,r.jsxs)(`div`,{class:`cf-confirm__actions`,children:[(0,r.jsx)(`button`,{type:`button`,class:`cf-confirm__btn cf-confirm__btn--cancel`,onClick:()=>U(!1),children:u.cancel}),(0,r.jsx)(`button`,{type:`button`,class:`cf-confirm__btn cf-confirm__btn--danger`,onClick:()=>{U(!1),Ze()},children:u.clearDeviceDataCta})]})]})},`confirm-clear`)]}),C&&!d?(0,r.jsx)(e.C,{persona:f,voiceState:R,muted:bt,onToggleMute:Mn,onEndCall:Q,micLevel:St,onExpand:q}):w&&d?null:!a.hideDefaultLauncher&&(0,r.jsxs)(`button`,{ref:It,type:`button`,class:`cf-launcher`,"aria-label":d?u.closeChat:x>0?`${u.openChat}. ${x===1?u.unreadMessage:e.K(u.unreadMessages,{count:String(x)})}`:u.openChat,"aria-expanded":d,onClick:cn,children:[a.launcherIcon?(0,r.jsx)(`img`,{class:`cf-launcher__img`,src:a.launcherIcon,alt:``}):(0,r.jsx)(e.A,{}),!d&&x>0&&(0,r.jsx)(`span`,{class:`cf-launcher__badge`,"aria-hidden":`true`,children:x>99?`99+`:x})]})]})})})},p=`centrinfo-widget`;var m=class extends HTMLElement{constructor(...t){super(...t),e.rt(this,`controls`,null),e.rt(this,`composerDraftStore`,{value:``})}mountWith(n){let i=e.n(n),a=this.shadowRoot??this.attachShadow({mode:`open`});if(this.style.zIndex=String(i.zIndex),`adoptedStyleSheets`in Document.prototype&&typeof CSSStyleSheet<`u`&&typeof CSSStyleSheet.prototype.replaceSync==`function`){let t=new CSSStyleSheet;t.replaceSync(e.t),a.adoptedStyleSheets=[t]}else{let t=document.createElement(`style`);i.styleNonce&&(t.nonce=i.styleNonce),t.textContent=e.t,a.appendChild(t)}let o=e.J(i);(0,t.render)((0,r.jsx)(e.Y,{value:i.analyticsRenderer===`local`?void 0:e.X(i.apiBaseUrl,i.workspaceUrl),children:(0,r.jsx)(f,{transport:o,config:i,bindControls:e=>this.controls=e,composerDraftStore:this.composerDraftStore})}),a)}open(){this.controls?.open()}close(){this.controls?.close()}toggle(){this.controls?.toggle()}identify(e){this.controls?.identify(e)}clear(){this.controls?.startNew()}shutdown(){this.controls?.shutdown()}unmount(){this.shadowRoot&&(0,t.render)(null,this.shadowRoot)}};typeof customElements<`u`&&!customElements.get(p)&&customElements.define(p,m);const h=(e,t=document.body)=>{if(typeof document>`u`)throw Error(`[centrinfo-widget] createWidget must run in a browser.`);let n=document.createElement(p);return n.style.pointerEvents=`none`,n.style.position=`fixed`,n.style.inset=`0`,n.style.width=`0`,n.style.height=`0`,t.appendChild(n),n.mountWith(e),{open:()=>n.open(),close:()=>n.close(),toggle:()=>n.toggle(),show:()=>n.open(),hide:()=>n.close(),identify:e=>n.identify(e),update:e=>n.identify(e),clear:()=>n.clear(),shutdown:()=>n.shutdown(),logout:()=>n.shutdown(),destroy:()=>{n.unmount(),n.remove()}}},de=e=>h(e);let fe=null;const g=e=>{fe?.destroy();let t=de(e);return fe=t,t},pe={init:g,createWidget:de};exports.Centrinfo=pe,exports.createWidget=de,exports.init=g;
|
|
1
|
+
const e=require(`./styles-BWPJrttg.cjs`);let t=require(`preact`),n=require(`preact/hooks`),r=require(`preact/jsx-runtime`);const i=(e,t)=>{if(typeof MutationObserver>`u`)return()=>void 0;let n=e.scrollHeight,r=0,i=()=>{r=0;let i=e.scrollHeight,a=i>n,o=t.isAtBottom()||n-e.scrollTop-e.clientHeight<80;n=i,a&&(o?(e.scrollTop=e.scrollHeight,t.onFollow?.()):t.onUnseen?.())},a=new MutationObserver(()=>{r||(r=typeof requestAnimationFrame==`function`?requestAnimationFrame(i):setTimeout(i,0))});return a.observe(e,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:[`style`,`height`]}),()=>{a.disconnect(),r&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(r)}},a={en:[`Still working on that, one moment.`,`Nearly there, thanks for waiting.`,`Still on it, just a little longer.`],fr:[`Je m’en occupe toujours, un instant.`,`Presque fini, merci de patienter.`,`Toujours en cours, encore un petit moment.`],es:[`Sigo con ello, un momento.`,`Ya casi está, gracias por esperar.`,`Todavía en ello, solo un poco más.`],pt:[`Ainda estou a tratar disso, um momento.`,`Quase pronto, obrigado por esperar.`,`Continuo nisso, só mais um pouco.`],de:[`Ich arbeite noch daran, einen Moment.`,`Fast fertig, danke fürs Warten.`,`Bin noch dran, nur noch kurz.`],it:[`Ci sto ancora lavorando, un momento.`,`Quasi fatto, grazie per l’attesa.`,`Ancora un attimo, ci sono quasi.`],ar:[`ما زلت أعمل على ذلك، لحظة من فضلك.`,`اقتربنا، شكرًا على انتظارك.`,`ما زلت أتابع، لحظات قليلة فقط.`],sw:[`Bado ninashughulikia hilo, subiri kidogo.`,`Karibu tayari, asante kwa kusubiri.`,`Bado niko kazini, muda mfupi tu.`]},o=e=>a[(e??``).replace(`_`,`-`).split(`-`)[0].trim().toLowerCase()]??a.en,s=(e,t)=>{let n=globalThis.speechSynthesis;if(!n||typeof SpeechSynthesisUtterance>`u`)return null;let r=new SpeechSynthesisUtterance(e);t&&(r.lang=t);let i=!1,a=new Promise(e=>{r.onend=r.onerror=()=>{i=!0,e()}});return n.speak(r),{done:a,stop:()=>{!i&&!n.pending&&n.cancel()}}},c=6e4,l=[`mute`,`end`,`wait`,`resume`],ee=2e3,u=2e4,d=5e3,f=250,p=6e3,te=14e3,ne=3,m={mic:`off`,processing:!1};var re=class{constructor(t){this.options=t,e.vt(this,`engine`,null),e.vt(this,`snapshot`,m),e.vt(this,`muted`,!1),e.vt(this,`partialText`,``),e.vt(this,`queue`,[]),e.vt(this,`overAnswer`,!1),e.vt(this,`overPending`,!1),e.vt(this,`answerEchoes`,!1),e.vt(this,`spokenAnswer`,``),e.vt(this,`lastActivity`,0),e.vt(this,`idleTimer`,null),e.vt(this,`outputActive`,!1),e.vt(this,`lastStateKey`,``),e.vt(this,`delivering`,null),e.vt(this,`ending`,null),e.vt(this,`waiting`,!1),e.vt(this,`progressTimer`,null),e.vt(this,`answeringSince`,0),e.vt(this,`progressSpoken`,0),e.vt(this,`lastProgressAt`,0),e.vt(this,`progressSpeech`,null),e.vt(this,`progressHeard`,[])}static supported(){return e.K()}get active(){return this.engine!==null}get voiceEngine(){return this.engine}get state(){let{chat:e}=this.options,t=this.engine!==null,n=t&&this.answering(),r=t&&e.speaking(),i=this.snapshot,a=this.muted||i.mic===`muted`;return{active:t,phase:t?i.mic===`off`||i.mic===`starting`?`connecting`:i.mic===`unavailable`?`unavailable`:a?r?`speaking`:n||this.queue.length?`thinking`:`muted`:i.mic===`hearing`?`hearing`:r?`speaking`:this.waiting?`waiting`:n||this.queue.length?`thinking`:i.processing?`transcribing`:`listening`:`off`,mic:i,muted:a,partial:this.partialText,queued:this.queue.map(e=>e.text),answerPending:n||this.queue.length>0,waiting:t&&this.waiting,stillWorking:t&&this.stillWorking(),reason:i.mic===`unavailable`?i.reason:void 0}}async start(){if(this.engine)return;let{options:t}=this;this.lastActivity=Date.now(),this.muted=!1,this.partialText=``,this.queue=[],this.overAnswer=!1,this.overPending=!1,this.waiting=!1,this.snapshot={mic:`starting`,processing:!1};let n=new e.G({live:t.live?{...t.live,controls:this.controls,delegate:(e,n)=>(this.touch(),t.live.delegate(e,n,{waiting:this.waiting}))}:void 0,transcribe:t.transcribe,deviceId:t.deviceId,endSilenceMs:t.endSilenceMs,media:t.media,listener:{speaking:e=>t.events?.liveSpeaking?.(e),state:e=>{this.engine===n&&this.onState(e)},speechStart:()=>{this.engine===n&&this.onSpeechStart()},partial:({text:e})=>{this.engine===n&&this.onPartial(e)},turn:e=>{this.engine===n&&this.onTurn(e)},noise:e=>{this.engine===n&&this.onDropped(e.reason,e.overlappedOutput)},level:e=>t.events?.level?.(e),control:e=>{this.engine===n&&this.control(e)}}});this.engine=n,this.outputActive=t.chat.speaking(),n.setOutputActive(this.outputActive),this.startIdleTimer(),this.startProgressTimer(),this.emit(!0),await n.start()}end(e=`user`){let t=this.engine;if(!t)return;this.engine=null,t.stop(`conversation-${e}`),this.idleTimer&&clearInterval(this.idleTimer),this.idleTimer=null;let{chat:n}=this.options;(this.delivering!==null||n.busy())&&n.cancel(),this.delivering&&clearTimeout(this.delivering),this.delivering=null,this.ending&&clearInterval(this.ending),this.ending=null,this.stopProgress(!0),this.waiting=!1,n.silence(),this.overAnswer=!1,this.overPending=!1,this.answerEchoes=!1,this.queue=[],this.partialText=``,this.muted=!1,this.snapshot=m,this.options.events?.ended?.(e),this.emit(!0)}setMuted(e){let t=this.engine;t&&(this.muted=e,t.setMuted(e),e?(this.partialText=``,t.snapshot.processing||this.release()):this.touch(),this.emit(!0))}toggleMute(){this.setMuted(!this.state.muted)}finishTurn(){this.engine?.finishTurn()}interrupt(){if(!this.engine)return;this.engine.interrupt(),this.overAnswer=!1,this.overPending=!1;let{chat:e}=this.options;e.cancel(),e.silence(),this.touch(),this.sync()}get controls(){return this.options.controls??l}control(t){let n=e.q(t,this.controls),r=this.engine;return!n||!r?null:(r.log.add(`voice-control`,{action:n}),this.touch(),n===`mute`?this.setMuted(!0):n===`end`?this.endAfterAnswer():n===`wait`?this.waiting=!0:n===`resume`&&(this.waiting=!1),this.options.events?.control?.(n),this.emit(!0),n)}wait(){!this.engine||this.waiting||(this.waiting=!0,this.touch(),this.emit(!0))}resume(){!this.engine||!this.waiting||(this.waiting=!1,this.touch(),this.emit(!0))}endAfterAnswer(){if(this.ending)return;let e=Date.now(),t=!1;this.ending=setInterval(()=>{if(!this.engine)return;let{chat:n}=this.options,r=n.speaking();r&&(t=!0);let i=Date.now()-e;(!r&&!this.answering()&&(t||i>=2e3)||i>=2e4)&&this.end(`user`)},200)}async selectDevice(e){await this.engine?.selectDevice(e)}sync(){if(!this.engine)return;let{chat:e}=this.options;this.delivering&&(e.busy()||e.speaking())&&(clearTimeout(this.delivering),this.delivering=null);let t=e.speaking();t&&this.rememberSpokenAnswer(),(t||!this.answering())&&this.stopProgress(),t!==this.outputActive&&!this.progressSpeech&&(this.outputActive=t,this.answerEchoes=!1,this.engine.setOutputActive(t),this.touch()),this.flush(),this.emit()}answering(){return this.delivering!==null||this.options.chat.busy()}rememberSpokenAnswer(){let e=this.options.chat.lastAnswer();e.trim()&&(this.spokenAnswer=e)}isEcho(t){return e.Y(t,this.options.chat.lastAnswer())||!!(this.spokenAnswer&&e.Y(t,this.spokenAnswer))||this.progressHeard.some(n=>e.Y(t,n))}touch(){this.lastActivity=Date.now()}flush(){let{chat:e}=this.options;if(!this.engine||!this.queue.length||this.answering()||e.speaking())return;let t=this.queue.shift();this.touch(),this.delivering=setTimeout(()=>{this.delivering=null,this.sync()},400),e.deliver(t.text,t.token,{waiting:this.waiting})}release(){return!this.overAnswer&&!this.overPending?!1:(this.overAnswer=!1,this.overPending=!1,this.options.chat.duck(!1),!0)}onState(e){if(this.snapshot=e,(e.mic===`muted`||e.mic===`listening`||e.mic===`hearing`)&&(this.muted=e.mic===`muted`),e.mic===`off`){this.end(`mic-off`);return}e.mic!==`hearing`&&!e.processing&&this.release(),this.emit()}onSpeechStart(){this.touch();let{chat:e}=this.options,t=e.speaking(),n=e.busy();t?(this.rememberSpokenAnswer(),this.overAnswer=!0,this.answerEchoes||e.duck(!0)):n&&(this.overPending=!0,e.duck(!0)),this.partialText=``,this.options.events?.speechStart?.({overAnswer:t,answerPending:n}),this.emit()}onPartial(e){this.touch(),!this.overAnswer&&(this.partialText=e,this.options.events?.partial?.(e),this.emit())}onDropped(e,t){this.touch(),this.partialText=``;let n=this.release();this.options.events?.dropped?.({reason:e,heldSomething:n,overlappedOutput:t}),this.emit()}onTurn(e){this.touch();let{chat:t,screen:n,intercept:r,events:i}=this.options,a=n?n(e.text):e.text.trim(),o=this.overAnswer||e.overlappedOutput;if(a&&o&&this.isEcho(a)){t.speaking()&&(this.answerEchoes=!0),this.onDropped(`echo`,e.overlappedOutput);return}if(!a){this.onDropped(`unusable`,e.overlappedOutput);return}if(this.partialText=``,r?.(a)){this.release(),this.emit();return}this.overAnswer||t.speaking()?(this.overAnswer=!1,this.overPending=!1,t.silence()):this.release();let s=this.answering()||this.queue.length>0,c=i?.heard?.(a,{queued:s});this.queue.push({text:a,token:c}),this.flush(),this.emit(!0)}stillWorking(){return this.answeringSince>0&&!this.waiting&&Date.now()-this.answeringSince>=(this.options.progress?.delayMs??6e3)}startProgressTimer(){this.progressTimer=setInterval(()=>this.checkProgress(),250)}checkProgress(){let e=this.engine;if(!e)return;let{chat:t}=this.options;if(!(this.answering()&&!t.speaking())){this.answeringSince&&(this.answeringSince=0,this.progressSpoken=0,this.stopProgress(),this.emit());return}let n=Date.now();this.answeringSince||(this.answeringSince=n);let r=this.options.progress??{},i=this.stillWorking(),a=r.repeatMs??14e3;i&&!this.progressSpeech&&!this.waiting&&!this.state.muted&&e.snapshot.mic!==`hearing`&&this.progressSpoken<(r.maxLines??3)&&(this.progressSpoken===0||n-this.lastProgressAt>=a)&&this.sayProgress(e),this.emit()}sayProgress(e){let t=this.options.progress??{},n=t.language?.(),r=t.lines?.().filter(e=>e.trim())??[],i=r.length?r:o(n),a=i[this.progressSpoken%i.length];this.progressSpoken+=1,this.lastProgressAt=Date.now(),this.progressHeard=[...this.progressHeard.slice(-5),a],e.log.add(`progress-line`,{index:this.progressSpoken}),this.options.events?.progress?.(a);let c=(t.say??s)(a,n);c&&(this.progressSpeech=c,e.setOutputActive(!0),c.done.then(()=>{this.progressSpeech===c&&(this.progressSpeech=null,this.engine&&this.engine.setOutputActive(this.outputActive))}))}stopProgress(e=!1){let t=this.progressSpeech;this.progressSpeech=null,t?.stop(),t&&this.engine&&this.engine.setOutputActive(this.options.chat.speaking()),e&&(this.progressTimer&&clearInterval(this.progressTimer),this.progressTimer=null,this.answeringSince=0,this.progressSpoken=0,this.progressHeard=[])}startIdleTimer(){let e=this.options.idleLimitMs??6e4;e&&(this.idleTimer=setInterval(()=>{let t=this.engine;if(!t)return;let{chat:n}=this.options,{mic:r,processing:i}=t.snapshot;this.state.muted||r===`hearing`||i||this.answering()||n.speaking()||this.queue.length||Date.now()-this.lastActivity<(this.waiting?e*5:e)||(t.log.add(`conversation-idle`),this.end(`idle`))},5e3))}emit(e=!1){let t=this.state,n=JSON.stringify(t);!e&&n===this.lastStateKey||(this.lastStateKey=n,this.options.events?.change?.(t))}};const ie=e=>e.startsWith(`image/`)?`image`:e===`application/pdf`?`pdf`:`other`,ae=({state:t,onClose:i})=>{let a=e.rt(),o=(0,n.useRef)(null);(0,n.useEffect)(()=>{o.current?.focus();let e=e=>{e.key===`Escape`&&(e.stopPropagation(),i())};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[i]);let s=t.status===`ready`?ie(t.mimeType):`other`;return(0,r.jsx)(`div`,{class:`cf-preview`,role:`dialog`,"aria-modal":`true`,"aria-label":e.nt(a.attachPreviewTitle,{name:t.name}),onClick:e=>{e.target===e.currentTarget&&i()},children:(0,r.jsxs)(`div`,{class:`cf-preview__frame`,children:[(0,r.jsxs)(`div`,{class:`cf-preview__bar`,children:[(0,r.jsx)(`span`,{class:`cf-preview__name`,title:t.name,children:t.name}),t.status===`ready`&&(0,r.jsx)(`a`,{class:`cf-preview__btn`,href:t.url,download:t.name,children:a.attachDownload}),(0,r.jsx)(`button`,{ref:o,type:`button`,class:`cf-preview__btn cf-preview__close`,"aria-label":a.attachPreviewClose,onClick:i,children:`✕`})]}),(0,r.jsxs)(`div`,{class:`cf-preview__body`,children:[t.status===`loading`&&(0,r.jsx)(`p`,{class:`cf-preview__note`,children:a.attachPreviewLoading}),t.status===`error`&&(0,r.jsx)(`p`,{class:`cf-preview__note`,children:a.attachPreviewFailed}),t.status===`ready`&&s===`image`&&(0,r.jsx)(`img`,{class:`cf-preview__image`,src:t.url,alt:t.name}),t.status===`ready`&&s===`pdf`&&(0,r.jsx)(`iframe`,{class:`cf-preview__pdf`,src:t.url,title:t.name}),t.status===`ready`&&s===`other`&&(0,r.jsx)(`p`,{class:`cf-preview__note`,children:a.attachPreviewUnsupported})]})]})})},oe=({name:t,greeting:n})=>{let i=e.rt();return(0,r.jsxs)(`section`,{class:`cf-empty-welcome`,"aria-label":e.nt(i.welcomeLabel,{name:t}),children:[(0,r.jsx)(`span`,{class:`cf-empty-welcome__eyebrow`,children:i.welcomeEyebrow}),(0,r.jsx)(`h2`,{children:t}),(0,r.jsx)(`p`,{children:n||i.welcomePrompt})]})},se=(e,t,n)=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),n();return}if(e.key!==`Tab`)return;let r=Array.from(t.querySelectorAll(`button, [href], textarea, input, select, [tabindex]:not([tabindex="-1"])`)).filter(e=>!e.hasAttribute(`disabled`)&&e.getAttribute(`aria-hidden`)!==`true`&&e.tabIndex>=0);if(r.length===0)return;let i=t.getRootNode(),a=e.composedPath()[0],o=a instanceof HTMLElement?a:`activeElement`in i?i.activeElement:document.activeElement,s=r[0],c=r[r.length-1];e.shiftKey&&(o===s||!t.contains(o))?(e.preventDefault(),e.stopPropagation(),c.focus()):!e.shiftKey&&(o===c||!t.contains(o))&&(e.preventDefault(),e.stopPropagation(),s.focus())},h=new Map,ce=e=>{if(!e||typeof document>`u`||typeof CanvasRenderingContext2D>`u`)return;let t=document.createElement(`canvas`).getContext(`2d`);if(!t)return;t.fillStyle=`#010203`,t.fillStyle=e;let n=t.fillStyle;if(n===`#010203`&&e.trim().toLowerCase()!==`#010203`)return;let r=n.match(/^#([\da-f]{6})$/i)?.[1];if(r)return[Number.parseInt(r.slice(0,2),16),Number.parseInt(r.slice(2,4),16),Number.parseInt(r.slice(4,6),16),1];let i=n.match(/^rgba?\(([\d.]+)[, ]+([\d.]+)[, ]+([\d.]+)(?:[, /]+([\d.]+))?\)$/i);if(!i)return;let a=i.slice(1,5).map(Number);if(!a.some(e=>!Number.isFinite(e)))return[a[0],a[1],a[2],a[3]??1]},le=(e,t=`#ffffff`)=>{let n=`${e??``}|${t}`;if(h.has(n))return h.get(n);let r=ce(e),i=ce(t)??[255,255,255,1];if(!r){h.set(n,void 0);return}let a=r[3],o=r.slice(0,3).map((e,t)=>e*a+i[t]*(1-a)).map(e=>{let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}),s=o[0]*.2126+o[1]*.7152+o[2]*.0722,c=1.05/(s+.05)>=(s+.05)/.059?`#ffffff`:`#0f1e2a`;return h.set(n,c),c},ue=e=>{let[t,r]=(0,n.useState)(`light`);return(0,n.useEffect)(()=>{if(e!==`auto`||typeof matchMedia>`u`)return;let t=matchMedia(`(prefers-color-scheme: dark)`),n=()=>r(t.matches?`dark`:`light`);return n(),t.addEventListener(`change`,n),()=>t.removeEventListener(`change`,n)},[e]),e===`auto`?t:e},de=6e4,g=90,fe=[`mute`,`end`,`minimize`,`expand`,`shrink`,`wait`,`resume`],pe=({transport:t,config:a,bindControls:o,composerDraftStore:s})=>{let c=a.strings,[l,ee]=(0,n.useState)(a.openByDefault),{persona:u,messages:d,sending:f,assistantSpeaking:p,visitor:te,hasEmail:ne,liveMode:m,assignedAgentName:ie,agentTypingName:h,starters:ce,featuredLinks:de,send:g,sendGif:pe,notifyTyping:me,stop:_,voiceForms:v,voiceReply:y,duckSpeaking:he,retry:ge,rateMessage:_e,doubleCheckResponse:ve,retryResponse:ye,rateExplanation:be,explanationTransport:xe,injectAssistant:Se,reconnectSupport:Ce,appendUserDraft:we,patchMessage:b,removeMessage:Te,submitCsat:Ee,submitForm:De,confirmHostedBooking:Oe,transcribe:ke,liveVoice:Ae,delegateVoice:je,setLiveSpeaking:Me,uploadAttachment:Ne,loadAttachment:Pe,searchGifs:Fe,demoSlots:Ie,gifEnabled:Le,identify:Re,ended:x,endConversation:ze,startNew:Be,history:Ve,viewingSessionId:He,viewMessages:Ue,openConversation:We,closeHistoryView:Ge,shutdown:S,stopSpeaking:C,speakAssistantText:Ke,analyticsModels:qe,analyticsModelId:Je,selectAnalyticsModel:Ye}=e.l(t,a,l),Xe=e.c(d,m),[w,Ze]=(0,n.useState)(null),T=(0,n.useRef)(0),Qe=(0,n.useCallback)((e,t,n)=>{n===T.current&&Ze({status:`ready`,name:t,url:URL.createObjectURL(e),mimeType:e.type||`application/octet-stream`})},[]),$e=(0,n.useCallback)((e,t,n)=>{let r=t.name,i=++T.current;Ze({status:`loading`,name:r}),Pe(e,t,n).then(e=>Qe(e,r,i),()=>{i===T.current&&Ze({status:`error`,name:r})})},[Pe,Qe]),et=(0,n.useCallback)((e,t)=>Qe(e,t,++T.current),[Qe]),tt=(0,n.useCallback)(()=>{T.current+=1,Ze(null)},[]);(0,n.useEffect)(()=>()=>{w?.status===`ready`&&URL.revokeObjectURL(w.url)},[w]);let nt=!!e.s(u?.actions),[E,rt]=(0,n.useState)(0),[it,at]=(0,n.useState)(null),ot=e.J(it),[D,st]=(0,n.useState)({mic:`off`,processing:!1}),[ct,lt]=(0,n.useState)(null),[ut,dt]=(0,n.useState)(!1),[O,ft]=(0,n.useState)(!1),[pt,mt]=(0,n.useState)(!1),[ht,gt]=(0,n.useState)(!1),[_t,vt]=(0,n.useState)(0),[k,A]=(0,n.useState)(!1),[j,M]=(0,n.useState)(null),[yt,bt]=(0,n.useState)(null),[xt,St]=(0,n.useState)([]),[Ct,wt]=(0,n.useState)(``),[N,Tt]=(0,n.useState)(()=>{try{return localStorage.getItem(`centrinfo:muted`)===`1`}catch{return!1}}),Et=ue(a.theme),Dt=u?.soundEnabled??!0;(0,n.useEffect)(()=>{e.h(a.sound&&Dt&&!N)},[a.sound,Dt,N]);let Ot=(0,n.useCallback)(()=>{Tt(e=>{let t=!e;try{localStorage.setItem(`centrinfo:muted`,t?`1`:`0`)}catch{}return t})},[]),P=(0,n.useRef)(null),kt=(0,n.useRef)(null),At=(0,n.useRef)(null),jt=(0,n.useRef)(0),F=(0,n.useRef)(!1),I=(0,n.useRef)(!1),L=(0,n.useRef)(null),R=(0,n.useRef)(0),Mt=(0,n.useRef)(void 0),Nt=(0,n.useRef)(0),z=(0,n.useRef)(null),B=(0,n.useRef)(``),Pt=(0,n.useRef)(()=>{}),Ft=(0,n.useRef)(``),It=(0,n.useRef)(f),Lt=(0,n.useRef)(g);Lt.current=g;let Rt=(0,n.useRef)(ke);Rt.current=ke;let zt=(0,n.useRef)(y);zt.current=y;let Bt=(0,n.useRef)({liveVoice:Ae,delegateVoice:je,messages:d});Bt.current={liveVoice:Ae,delegateVoice:je,messages:d};let Vt=(0,n.useRef)(``);Vt.current=[...d].reverse().find(e=>e.role===`assistant`&&e.content.trim())?.content??``;let Ht=(0,n.useRef)(p);It.current=f||v.busy,Ht.current=p;let Ut=O?ut?`timeout`:ht||D.mic===`muted`?`muted`:D.mic===`unavailable`?D.reason===`permission-denied`||D.reason===`unsupported`?`denied`:`unavailable`:D.mic===`off`||D.mic===`starting`?`connecting`:D.mic===`hearing`?`hearing`:p?`speaking`:ot.waiting?`waiting`:ct??(D.processing||f||v.busy?`processing`:`listening`):`idle`;(0,n.useEffect)(()=>{v.setEnabled(O&&pt&&!x&&!He&&m===`ai`,L.current?.voiceEngine?.usingLiveAudio)},[v,O,pt,x,He,m]);let[Wt,Gt]=(0,n.useState)(!0),[Kt,V]=(0,n.useState)(!1),qt=(0,n.useRef)(!0);qt.current=Wt;let[H,U]=(0,n.useState)(!1),[W,G]=(0,n.useState)(!1),[K,q]=(0,n.useState)(!1),Jt=(0,n.useRef)({value:``}),Yt=s??Jt.current,Xt=(0,n.useRef)({confirmEnd:H,confirmClear:W,showHistory:K});Xt.current={confirmEnd:H,confirmClear:W,showHistory:K};let[Zt,Qt]=(0,n.useState)(!1),J=!!He,$t=J?Ue:d,en=$t.find(e=>e.id===j&&e.visualization)?.visualization,tn=$t.find(e=>e.id===yt&&e.visualization);(0,n.useEffect)(()=>{!yt||tn||(bt(null),A(!1))},[yt,tn]),(0,n.useEffect)(()=>{!j||en||(M(null),A(!1))},[en,j]);let Y=(0,n.useCallback)(()=>{ee(!0),rt(0),e.m(`open`),a.onOpen?.(),a.onShow?.()},[a]),X=(0,n.useCallback)(()=>{ee(!1),A(!1),M(null),a.onClose?.(),a.onHide?.(),kt.current?.focus()},[a]),nn=(0,n.useCallback)(()=>l?X():Y(),[l,Y,X]),rn=(0,n.useCallback)(()=>U(!0),[]),an=(0,n.useCallback)(()=>{ze(),U(!1)},[ze]),on=(0,n.useCallback)(()=>{Be(),V(!1),Gt(!0)},[Be]);(0,n.useEffect)(()=>{o({open:Y,close:X,toggle:nn,identify:Re,startNew:Be,endConversation:ze,shutdown:S})},[o,Y,X,nn,Re,Be,ze,S]),(0,n.useEffect)(()=>{let e=d.filter(e=>e.role===`assistant`&&!e.pending).length;if(l){jt.current=e;return}e>jt.current&&rt(e-jt.current)},[d,l]),(0,n.useEffect)(()=>{a.onUnreadChange?.(E)},[E,a]),(0,n.useEffect)(()=>{let e=a.sessionDurationMinutes;if(!e||e<=0)return;let t=setTimeout(()=>S(),e*60*1e3);return()=>clearTimeout(t)},[a.sessionDurationMinutes,d,l,S]),(0,n.useEffect)(()=>{let e=a.customLauncherSelector;if(!e||typeof document>`u`)return;let t=[];try{t=Array.from(document.querySelectorAll(e))}catch{return}let n=e=>{e.preventDefault(),nn()};return t.forEach(e=>e.addEventListener(`click`,n)),()=>t.forEach(e=>e.removeEventListener(`click`,n))},[a.customLauncherSelector,nn]);let sn=(0,n.useRef)(!1);(0,n.useEffect)(()=>{let e=a.proactiveMessage?.trim();if(!e||sn.current)return;let t=a.proactiveOnPaths??[],n=typeof location<`u`?location.pathname:``;if(t.length>0&&!t.some(e=>n.includes(e)))return;let r=`centrinfo:proactive:${a.token.slice(0,12)}`;try{if(sessionStorage.getItem(r)===`1`)return}catch{}let i=setTimeout(()=>{if(!(l||x||d.some(e=>e.role===`user`))){sn.current=!0;try{sessionStorage.setItem(r,`1`)}catch{}Se(e),Y()}},Math.max(0,a.proactiveDelaySeconds)*1e3);return()=>clearTimeout(i)},[a.proactiveMessage]),(0,n.useEffect)(()=>{let e=At.current;if(!l||!e)return;let t=d[d.length-1];if(!O&&t?.role===`user`||Wt){let t=requestAnimationFrame(()=>{qt.current&&(e.scrollTop=e.scrollHeight)});return V(!1),()=>cancelAnimationFrame(t)}else V(!0)},[d,l,f,Wt,O]),(0,n.useEffect)(()=>{let e=At.current;if(!(!l||!e))return i(e,{isAtBottom:()=>qt.current,onUnseen:()=>V(!0)})},[l,J]);let cn=(0,n.useCallback)(()=>{let e=At.current;if(!e)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight<80;qt.current=t,Gt(t),t&&V(!1)},[]),ln=(0,n.useCallback)(()=>{let e=At.current;e&&(e.scrollTop=e.scrollHeight),qt.current=!0,V(!1),Gt(!0)},[]),un=(0,n.useCallback)(()=>{P.current?.querySelector(`.cf-textarea`)?.focus()},[]),dn=(0,n.useCallback)((e,t)=>{lt(e),Mt.current&&window.clearTimeout(Mt.current),Mt.current=window.setTimeout(()=>lt(null),3e3),t&&!I.current&&Ke(t)},[Ke]),fn=(0,n.useCallback)(e=>{let t=z.current;if(t)return t;let n=we(e);return z.current=n,b(n,{content:B.current||e,pending:!0,streaming:!1}),n},[we,b]),pn=(0,n.useCallback)(()=>{let e=z.current;if(e){if(B.current){b(e,{content:B.current,pending:!0});return}z.current=null,Te(e)}},[b,Te]),Z=(0,n.useCallback)(()=>{F.current&&_(),F.current=!1;let e=L.current;L.current=null,e?.end(`user`),I.current=!1;let t=z.current;z.current=null,B.current=``,t&&Te(t),Mt.current&&window.clearTimeout(Mt.current),lt(null),dt(!1),st({mic:`off`,processing:!1}),at(null),vt(0),ft(!1),mt(!1),gt(!1),A(!1),M(null),C()},[Te,_,C]),mn=(0,n.useCallback)(()=>{k&&M(null),A(!k)},[k]),hn=(0,n.useCallback)(e=>{M(e),A(!0)},[]),gn=(0,n.useCallback)(e=>{bt(e),A(!0)},[]),_n=(0,n.useCallback)(()=>{let e=j,t=yt;M(null),bt(null),A(!1),window.requestAnimationFrame(()=>{(t?P.current?.querySelector(`[data-explanation-message="${t}"]`)?.querySelector(`[data-testid="analytics-explanation-expand"]`):Array.from(P.current?.querySelectorAll(`[data-visualization-message]`)??[]).find(t=>t.dataset.visualizationMessage===e))?.focus()})},[j,yt]),vn=(0,n.useCallback)(()=>{M(null),bt(null),A(!1)},[]),yn=(0,n.useCallback)((e,t,n=!1)=>{t&&(b(t,{content:e,pending:!1,streaming:!1}),z.current===t&&(z.current=null)),B.current=``,F.current&&(_(),C(),!v.handleTranscript(e,t)&&Lt.current(e,{forceVoicePlayback:!0,userMessageId:t,voiceWaiting:n,onVoiceControl:e=>L.current?.control(e)}))},[b,_,C,v]),bn=(0,n.useCallback)(({overAnswer:e})=>{R.current=Date.now(),lt(null),e||fn(c.voiceDraftListening)},[fn,c.voiceDraftListening]),xn=(0,n.useCallback)(e=>{let t=z.current;t&&b(t,{content:`${[B.current,e].filter(Boolean).join(` `)} ...`,pending:!0})},[b]),Sn=(0,n.useCallback)(e=>{R.current=Date.now();let t=fn(e);return b(t,{content:e,pending:!0}),z.current===t&&(z.current=null),B.current=``,t},[fn,b]),Cn=(0,n.useCallback)(({reason:e,heldSomething:t,overlappedOutput:n})=>{R.current=Date.now(),pn(),!t&&(e===`unusable`?dn(`misunderstood`):e===`transcribe-failed`&&!n&&dn(`misunderstood`,`I couldn't transcribe that. Please try again, or type your question.`))},[pn,dn]),Q=(0,n.useRef)({speechStart:bn,partial:xn,heard:Sn,dropped:Cn,deliver:yn,stop:_,stopSpeaking:C,duckSpeaking:he});Q.current={speechStart:bn,partial:xn,heard:Sn,dropped:Cn,deliver:yn,stop:_,stopSpeaking:C,duckSpeaking:he};let wn=(0,n.useCallback)(()=>{navigator.mediaDevices?.enumerateDevices().then(t=>{St(t.filter(e=>e.kind===`audioinput`).map((t,n)=>({deviceId:t.deviceId,label:t.label||e.nt(a.strings.microphoneNumbered,{number:String(n+1)})})))}).catch(()=>{})},[a]),Tn=(0,n.useCallback)(()=>{if(F.current){Z();return}if(un(),!u?.allowVoiceInput||!u.talkbackMode||u.talkbackMode===`text`||It.current||x||J)return;R.current=Date.now(),I.current=!1,F.current=!0,gt(!1),ft(!0),mt(!1),dt(!1);let t=!1,n=new re({chat:{busy:()=>It.current||zt.current.status===`answering`,speaking:()=>Ht.current,lastAnswer:()=>Vt.current,deliver:(e,t,n)=>Q.current.deliver(e,t,n.waiting),cancel:()=>Q.current.stop(),silence:()=>Q.current.stopSpeaking(),duck:e=>Q.current.duckSpeaking(e)},live:Bt.current.liveVoice?{transport:(e,t)=>Bt.current.liveVoice(e,t),delegate:async(e,t,n)=>(R.current=Date.now(),Bt.current.delegateVoice(e,t,n)),context:()=>Bt.current.messages.slice(-8).map(e=>`${e.role}: ${e.content}`).join(`
|
|
2
|
+
`)}:void 0,deviceId:Ft.current||void 0,transcribe:async({audio:t,mimeType:n,durationSeconds:r})=>{let i=typeof navigator<`u`&&(navigator.languages?.[0]||navigator.language)||void 0;return e._(await Rt.current(t,n,i,r))},screen:e.v,controls:fe,progress:{language:()=>a.locale},idleLimitMs:0,events:{change:e=>{if(L.current!==n)return;let r=e.mic;at(e),I.current=e.muted,gt(e.muted),st(r),r.mic!==`starting`&&r.mic!==`off`&&mt(!0),!t&&r.mic===`listening`&&(t=!0,wn())},ended:()=>{L.current===n&&Z()},liveSpeaking:Me,control:e=>Pt.current(e),speechStart:e=>Q.current.speechStart(e),partial:e=>Q.current.partial(e),heard:e=>Q.current.heard(e),dropped:e=>Q.current.dropped(e),level:e=>{let t=performance.now();t-Nt.current<90||(Nt.current=t,vt(e))}}});L.current=n,n.start()},[a.locale,Z,x,un,u,wn,J,Me]),En=(0,n.useCallback)(()=>{let e=!I.current;I.current=e,gt(e);let t=L.current?.voiceEngine?.snapshot.processing;L.current?.setMuted(e),e&&!t?(B.current=``,pn()):e||(R.current=Date.now())},[pn]),Dn=(0,n.useCallback)(e=>{switch(R.current=Date.now(),e){case`minimize`:X();break;case`expand`:A(!0);break;case`shrink`:M(null),A(!1);break}},[X]);(0,n.useEffect)(()=>{Pt.current=Dn},[Dn]);let On=(0,n.useCallback)(e=>{Ft.current=e,wt(e),L.current?.selectDevice(e||void 0)},[]),kn=(0,n.useCallback)(()=>{!F.current||I.current||(L.current?.interrupt(),R.current=Date.now())},[]);(0,n.useEffect)(()=>{L.current?.sync(),R.current=Date.now()},[p]),(0,n.useEffect)(()=>{L.current?.sync()},[f,v.busy,y]),(0,n.useEffect)(()=>{if(Ut!==`denied`)return;let e=window.setTimeout(()=>Z(),3500);return()=>window.clearTimeout(e)},[Z,Ut]),(0,n.useEffect)(()=>{if(!O)return;let e=window.setInterval(()=>{let e=L.current?.voiceEngine;!e||(L.current?.state.queued.length??0)>0||I.current||It.current||Ht.current||e.snapshot.mic===`hearing`||e.snapshot.processing||Date.now()-R.current<6e4||(e.log.add(`call-timeout`),dt(!0),window.setTimeout(()=>Z(),2400))},5e3);return()=>window.clearInterval(e)},[Z,O]);let An=O&&!ht&&(f||p);(0,n.useEffect)(()=>()=>Z(),[Z]);let[jn,Mn]=(0,n.useState)(``),Nn=(0,n.useRef)(!1);(0,n.useEffect)(()=>{if(Nn.current&&!f){let e=[...d].reverse().find(e=>e.role===`assistant`&&!e.streaming&&!e.pending&&e.content);e&&Mn(e.content)}Nn.current=f},[f,d]),(0,n.useLayoutEffect)(()=>{if(!l)return;let e=P.current,t=H||W?e?.querySelector(`.cf-confirm__card`):K?e?.querySelector(`.cf-history`):null;if(!t)return;let n=t.getRootNode(),r=`activeElement`in n?n.activeElement:document.activeElement;(!r||!t.contains(r))&&t.querySelector(`button, [href], textarea, input, [tabindex]:not([tabindex="-1"])`)?.focus()},[W,H,l,K]),(0,n.useEffect)(()=>{if(!l)return;let e=P.current,t=H||W?e?.querySelector(`.cf-confirm__card`):K?e?.querySelector(`.cf-history`):null,n=e?.querySelectorAll(`:scope > .cf-header, :scope > .cf-panel__video, :scope > .cf-panel__chat`);n?.forEach(e=>{t?(e.setAttribute(`inert`,``),e.setAttribute(`aria-hidden`,`true`)):(e.removeAttribute(`inert`),e.removeAttribute(`aria-hidden`))}),t||requestAnimationFrame(()=>e?.querySelector(`.cf-textarea`)?.focus());let r=n=>{if(n.key===`Escape`){n.preventDefault();let t=Xt.current;if(t.confirmEnd){U(!1);return}if(t.confirmClear){G(!1);return}if(t.showHistory){q(!1);return}if(e?.querySelector(`.cf-action-drawer`))return;X();return}if(n.key!==`Tab`||!t)return;let r=t.querySelectorAll(`button, [href], textarea, input, [tabindex]:not([tabindex="-1"])`),i=Array.from(r).filter(e=>!e.hasAttribute(`disabled`));if(i.length===0)return;let a=i[0],o=i[i.length-1],s=t.getRootNode()instanceof ShadowRoot?t.getRootNode().activeElement:document.activeElement;n.shiftKey&&s===a?(n.preventDefault(),o.focus()):!n.shiftKey&&s===o&&(n.preventDefault(),a.focus())};return e?.addEventListener(`keydown`,r),()=>{e?.removeEventListener(`keydown`,r),n?.forEach(e=>{e.removeAttribute(`inert`),e.removeAttribute(`aria-hidden`)})}},[l,X,H,W,K]),(0,n.useEffect)(()=>{let e=P.current;e&&(l?e.removeAttribute(`inert`):e.setAttribute(`inert`,``))},[l]);let Pn=a.accentColor??a.themeTokens?.accent??u?.accentColor,Fn=a.themeTokens?.accentText??le(Pn,a.themeTokens?.background??(Et===`dark`?`#0f1c27`:`#ffffff`)),In={zIndex:a.zIndex,"--cf-h-pad":`${a.horizontalPadding}px`,"--cf-v-pad":`${a.verticalPadding}px`,...Fn?{"--cf-accent-ink":Fn}:{},...a.themeTokens?.accentStrong?{"--cf-accent-2":a.themeTokens.accentStrong}:{},...a.themeTokens?.background?{"--cf-bg":a.themeTokens.background}:{},...a.themeTokens?.surface?{"--cf-surface":a.themeTokens.surface}:{},...a.themeTokens?.surfaceMuted?{"--cf-surface-2":a.themeTokens.surfaceMuted}:{},...a.themeTokens?.text?{"--cf-text":a.themeTokens.text}:{},...a.themeTokens?.mutedText?{"--cf-muted":a.themeTokens.mutedText}:{},...a.themeTokens?.border?{"--cf-border":a.themeTokens.border}:{},...a.themeTokens?.shadow?{"--cf-shadow":a.themeTokens.shadow}:{},...a.themeTokens?.radius?{"--cf-radius":a.themeTokens.radius}:{},...a.themeTokens?.fontFamily?{"--cf-font":a.themeTokens.fontFamily}:{},...a.themeTokens?.success?{"--cf-success":a.themeTokens.success}:{},...a.themeTokens?.warning?{"--cf-warning":a.themeTokens.warning}:{},...a.themeTokens?.danger?{"--cf-danger":a.themeTokens.danger}:{},...Pn?{"--cf-accent":Pn,"--cf-accent-2":a.themeTokens?.accentStrong??`color-mix(in oklab, ${Pn} 76%, #14141f)`}:{}},Ln=e=>g(e),Rn=[...d].reverse().find(e=>e.role===`user`&&e.content.trim())?.content??``,zn=d.some(e=>e.role===`user`),Bn=!!(u?.allowVoiceInput&&u?.talkbackMode&&u.talkbackMode!==`text`),$=!J&&Bn&&!zn?$t.filter((e,t)=>!(t===0&&e.role===`assistant`)):$t,Vn=m===`human`&&ie?ie:u?.agentName??c.chatName,Hn=m===`human`?c.liveSupport:m===`queued`?c.waitingForTeam:u?.offline?c.statusOffline:c.statusOnline,Un=!x&&!J?u?.availableActions:void 0,Wn=!x&&!J?u?.actions:void 0,Gn=O&&!pt&&Ut===`connecting`&&!J;return(0,r.jsx)(e.et,{value:c,children:(0,r.jsx)(e.H,{value:v,children:(0,r.jsx)(e.$,{value:a.locale,children:(0,r.jsxs)(`div`,{class:`cf-root`,dir:a.dir,"data-theme":Et,"data-align":a.alignment,"data-display":`floating`,style:In,children:[k&&l&&(0,r.jsx)(`div`,{class:`cf-theater-backdrop`,onClick:vn}),(0,r.jsxs)(`div`,{ref:P,class:`cf-panel ${l?`is-open`:``} ${O?`cf-panel--call`:``} ${Gn?`cf-panel--voice-connecting`:``} ${k&&l?`cf-panel--theater`:``} ${en||tn?`cf-panel--analytics-focus`:``}`,role:`dialog`,"aria-modal":`false`,"aria-label":`${c.chatName}: ${u?.agentName??c.assistantName}`,"aria-hidden":!l,children:[w&&l&&(0,r.jsx)(ae,{state:w,onClose:tt}),(0,r.jsxs)(`div`,{class:`cf-header`,children:[(0,r.jsx)(e.b,{persona:u,hideWhenMissing:!0}),(0,r.jsxs)(`div`,{class:`cf-header__meta`,children:[(0,r.jsx)(`div`,{class:`cf-header__name`,children:Vn}),a.token.startsWith(`pub_test_`)?(0,r.jsx)(`small`,{role:`status`,children:c.testMode}):null,(0,r.jsx)(`div`,{class:`cf-header__status ${m===`ai`&&u?.offline?`cf-header__status--offline`:``}`,children:(0,r.jsx)(`span`,{class:`cf-header__status-text`,children:Hn})})]}),(0,r.jsxs)(`div`,{class:`cf-header__actions`,children:[Ve.length>0&&(0,r.jsx)(`button`,{type:`button`,class:`cf-header__btn`,"aria-label":c.pastConversations,title:c.pastConversations,"aria-pressed":K,onClick:()=>q(e=>!e),children:(0,r.jsx)(e.I,{})}),zn&&!x&&!J&&(0,r.jsx)(`button`,{type:`button`,class:`cf-header__btn`,"aria-label":c.endChat,title:c.endChat,onClick:rn,children:(0,r.jsx)(e.F,{})}),a.sound&&Dt&&(0,r.jsx)(`button`,{type:`button`,class:`cf-header__btn`,"aria-label":N?c.unmuteSounds:c.muteSounds,"aria-pressed":N,onClick:Ot,children:N?(0,r.jsx)(e.L,{}):(0,r.jsx)(e.R,{})}),(0,r.jsx)(`button`,{type:`button`,class:`cf-header__btn cf-header__close`,"aria-label":c.closeChat,onClick:X,children:(0,r.jsx)(e.P,{})})]})]}),(0,r.jsx)(`div`,{class:`cf-panel__video`,children:en?(0,r.jsx)(`div`,{class:`cf-analytics-focus`,role:`region`,"aria-label":c.expandedAnalyticsResult,children:(0,r.jsx)(e.A,{visualization:en,explanationTransport:J?void 0:xe(`widget`),onExplanationFeedback:J?void 0:be,onOpenAnalyticsSource:a.onOpenAnalyticsSource,expanded:!0,onFollowUp:e=>{_n(),g(e)},onClose:_n})}):tn?.visualization?(0,r.jsx)(`div`,{class:`cf-analytics-focus`,role:`region`,"aria-label":c.expandedAnalyticsResult,children:(0,r.jsx)(e.k,{visualization:tn.visualization,onClose:_n,onFollowUp:e=>{_n(),g(e)},onFeedback:J?void 0:be,transport:J?void 0:xe(`widget`),onOpenSource:a.onOpenAnalyticsSource})}):!J&&Bn?(0,r.jsx)(e.S,{persona:u,starters:[],onPick:g,onFocusComposer:Tn,speaking:p,voiceState:Ut,replyPending:O&&f&&!p,pinned:!0,muted:ht,onToggleMute:En,onEndCall:Z,onTalkNow:kn,showTalkNow:An,micLevel:_t,theaterMode:k,onToggleTheater:mn,onMinimize:X,audioDevices:xt,selectedAudioDeviceId:Ct,onSelectAudioDevice:On,connectingOnly:Gn,answerStillComing:ot.answerStillComing,stillWorking:ot.stillWorking,onResume:()=>L.current?.resume()}):null}),!Gn&&(0,r.jsxs)(`div`,{class:`cf-panel__chat`,children:[a.preview&&(0,r.jsx)(`div`,{class:`cf-preview-banner`,children:c.previewBanner}),J&&(0,r.jsx)(`div`,{class:`cf-viewing-banner`,children:c.viewingPast}),(0,r.jsxs)(`div`,{class:`cf-body`,ref:At,role:`log`,onScroll:cn,children:[$.map((t,n)=>(0,r.jsx)(e.E,{msg:t,persona:u,isLast:!J&&n===$.length-1,visitor:te,hasEmail:ne,lastQuestion:Rn,showActions:!J&&n===$.length-1&&!!(t.handoffOffered||t.selectedAction),onPickReply:Ln,onSubmitForm:De,onDemoSlots:Ie,onConfirmHostedBooking:Oe,onRetry:ge,ratable:!J&&$.slice(0,n).some(e=>e.role===`user`),onRate:_e,onDoubleCheck:J||x?void 0:ve,onRetryResponse:J||x||m!==`ai`?void 0:ye,doubleCheckDisabled:f,onExplanationFeedback:J?void 0:be,explanationTransport:J?void 0:xe(`widget`),onOpenAnalyticsSource:a.onOpenAnalyticsSource,onExpandVisualization:J?void 0:hn,onExpandExplanation:J?void 0:gn,onOpenAttachment:$e,onReconnect:!J&&!x&&nt&&t.id===Xe?Ce:void 0},t.id)),!zn&&!J&&(0,r.jsxs)(r.Fragment,{children:[$.length===0&&(0,r.jsx)(oe,{name:u?.agentName??c.assistantName,greeting:u?.greeting}),(0,r.jsx)(e.O,{items:ce,onPick:g}),(0,r.jsx)(e.w,{items:de})]}),Kt&&(0,r.jsxs)(`button`,{type:`button`,class:`cf-newmsg`,onClick:ln,children:[(0,r.jsx)(e.M,{}),c.newMessages]})]}),(0,r.jsx)(`div`,{class:`cf-sr-live`,"aria-live":`polite`,"aria-atomic":`true`,children:jn}),f&&!x&&!J&&(0,r.jsx)(`div`,{class:`cf-stopbar`,children:(0,r.jsxs)(`button`,{type:`button`,class:`cf-stop`,onClick:_,children:[(0,r.jsx)(e.z,{}),c.stop]})}),J?(0,r.jsx)(`div`,{class:`cf-ended`,children:(0,r.jsx)(`button`,{type:`button`,class:`cf-ended__btn`,onClick:Ge,children:c.backToChat})}):x?(0,r.jsxs)(`div`,{class:`cf-ended`,children:[(0,r.jsx)(`p`,{class:`cf-ended__text`,children:c.conversationEnded}),a.csat&&zn?Zt?(0,r.jsx)(`p`,{class:`cf-ended__text`,children:c.feedbackThanks}):(0,r.jsxs)(`div`,{class:`cf-csat`,children:[(0,r.jsx)(`span`,{class:`cf-csat__q`,children:c.csatPrompt}),(0,r.jsx)(`button`,{type:`button`,class:`cf-csat__btn`,"aria-label":c.feedbackHelpful,onClick:()=>{Ee(`up`),Qt(!0)},children:(0,r.jsx)(e.V,{})}),(0,r.jsx)(`button`,{type:`button`,class:`cf-csat__btn`,"aria-label":c.feedbackNotHelpful,onClick:()=>{Ee(`down`),Qt(!0)},children:(0,r.jsx)(e.B,{})})]}):null,(0,r.jsx)(`button`,{type:`button`,class:`cf-ended__btn`,onClick:on,children:c.startNewChat})]}):(0,r.jsxs)(r.Fragment,{children:[h?(0,r.jsx)(`div`,{class:`cf-live-typing`,"aria-live":`polite`,children:e.nt(c.agentTyping,{name:h})}):null,Un&&Un.length>0&&(0,r.jsx)(`div`,{class:`cf-footer-actions`,children:(0,r.jsx)(e.y,{actions:Un,descriptors:Wn,visitor:te,onSubmitForm:De,onDemoSlots:Ie,onConfirmHostedBooking:Oe,scheduler:u?.scheduler,translations:a.actionTranslations})},`footer-actions`),(0,r.jsx)(e.C,{toolbarContent:a.showAnalyticsModelSelector?(0,r.jsx)(e.Z,{models:qe,value:Je,onChange:Ye,disabled:f}):null,draftStore:Yt,onSend:g,onSendGif:pe,onTyping:me,disabled:f,allowVoice:!1,onTranscribe:ke,gifEnabled:Le,onSearchGifs:Fe,allowAttach:a.attachments,analyzeAttachments:!0,onUpload:Ne,onPreviewAttachment:et},`composer`)]}),!x&&u?.disclaimerText&&(0,r.jsx)(`div`,{class:`cf-disclaimer`,children:u.disclaimerText}),(0,r.jsxs)(`div`,{class:`cf-footer`,children:[(0,r.jsx)(`button`,{type:`button`,class:`cf-footer__privacy`,"aria-label":c.clearDeviceData,onClick:()=>G(!0),children:c.privacyAndData}),(0,r.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),c.poweredBy,` `,(0,r.jsx)(`a`,{href:`https://accurixtech.com/centrinfo`,target:`_blank`,rel:`noopener noreferrer`,children:`Centrinfo`})]})]}),H&&(0,r.jsx)(`div`,{class:`cf-confirm`,onClick:()=>U(!1),children:(0,r.jsxs)(`div`,{class:`cf-confirm__card`,role:`alertdialog`,"aria-modal":`true`,"aria-label":c.endChatConfirm,onClick:e=>e.stopPropagation(),onKeyDownCapture:e=>se(e,e.currentTarget,()=>U(!1)),children:[(0,r.jsx)(`div`,{class:`cf-confirm__title`,children:c.endChatConfirm}),(0,r.jsx)(`div`,{class:`cf-confirm__body`,children:c.endChatConfirmBody}),(0,r.jsxs)(`div`,{class:`cf-confirm__actions`,children:[(0,r.jsx)(`button`,{type:`button`,class:`cf-confirm__btn cf-confirm__btn--cancel`,onClick:()=>U(!1),children:c.cancel}),(0,r.jsx)(`button`,{type:`button`,class:`cf-confirm__btn cf-confirm__btn--danger`,onClick:an,children:c.endConfirmCta})]})]})},`confirm-end`),K&&(0,r.jsx)(`div`,{class:`cf-confirm`,onClick:()=>q(!1),children:(0,r.jsxs)(`div`,{class:`cf-history`,role:`dialog`,"aria-modal":`true`,"aria-label":c.pastConversations,onClick:e=>e.stopPropagation(),onKeyDownCapture:e=>se(e,e.currentTarget,()=>q(!1)),children:[(0,r.jsxs)(`div`,{class:`cf-history__head`,children:[(0,r.jsx)(`span`,{children:c.pastConversations}),(0,r.jsx)(`button`,{type:`button`,class:`cf-header__btn`,"aria-label":c.closeHistory,onClick:()=>q(!1),children:(0,r.jsx)(e.P,{})})]}),(0,r.jsx)(`div`,{class:`cf-history__list`,children:Ve.map(t=>(0,r.jsxs)(`button`,{type:`button`,class:`cf-history__item ${t.sessionId===He?`is-active`:``}`,onClick:()=>{We(t.sessionId),q(!1)},children:[(0,r.jsx)(`span`,{class:`cf-history__title`,children:t.title}),(0,r.jsxs)(`span`,{class:`cf-history__meta`,children:[e.gt(t.ts,a.locale,{month:`short`,day:`numeric`}),t.ended?` · ${c.historyEnded}`:``]})]},t.sessionId))}),(0,r.jsx)(`div`,{class:`cf-history__footer`,children:(0,r.jsx)(`button`,{type:`button`,class:`cf-history__clear`,onClick:()=>{q(!1),G(!0)},children:c.clearDeviceData})})]})},`history`),W&&(0,r.jsx)(`div`,{class:`cf-confirm`,onClick:()=>G(!1),children:(0,r.jsxs)(`div`,{class:`cf-confirm__card`,role:`alertdialog`,"aria-modal":`true`,"aria-label":c.clearDeviceData,onClick:e=>e.stopPropagation(),onKeyDownCapture:e=>se(e,e.currentTarget,()=>G(!1)),children:[(0,r.jsx)(`div`,{class:`cf-confirm__title`,children:c.clearDeviceData}),(0,r.jsx)(`div`,{class:`cf-confirm__body`,children:c.clearDeviceDataBody}),(0,r.jsxs)(`div`,{class:`cf-confirm__actions`,children:[(0,r.jsx)(`button`,{type:`button`,class:`cf-confirm__btn cf-confirm__btn--cancel`,onClick:()=>G(!1),children:c.cancel}),(0,r.jsx)(`button`,{type:`button`,class:`cf-confirm__btn cf-confirm__btn--danger`,onClick:()=>{G(!1),S()},children:c.clearDeviceDataCta})]})]})},`confirm-clear`)]}),O&&!l?(0,r.jsx)(e.T,{persona:u,voiceState:Ut,muted:ht,onToggleMute:En,onEndCall:Z,micLevel:_t,onExpand:Y}):k&&l?null:!a.hideDefaultLauncher&&(0,r.jsxs)(`button`,{ref:kt,type:`button`,class:`cf-launcher`,"aria-label":l?c.closeChat:E>0?`${c.openChat}. ${e.nt(e._t(a.locale,E,c.unreadMessage,c.unreadMessages),{count:String(E)})}`:c.openChat,"aria-expanded":l,onClick:nn,children:[a.launcherIcon?(0,r.jsx)(`img`,{class:`cf-launcher__img`,src:a.launcherIcon,alt:``}):(0,r.jsx)(e.N,{}),!l&&E>0&&(0,r.jsx)(`span`,{class:`cf-launcher__badge`,"aria-hidden":`true`,children:E>99?`99+`:E})]})]})})})})},me=`centrinfo-widget`;var _=class extends HTMLElement{constructor(...t){super(...t),e.vt(this,`controls`,null),e.vt(this,`composerDraftStore`,{value:``}),e.vt(this,`input`,null),e.vt(this,`resolved`,null),e.vt(this,`transport`,null),e.vt(this,`localeRequest`,0),e.vt(this,`localeAbort`,void 0),e.vt(this,`automaticLocale`,void 0)}mountWith(t){let n=e.a(t);this.input=t,this.resolved=n;let r=this.shadowRoot??this.attachShadow({mode:`open`});if(this.style.zIndex=String(n.zIndex),`adoptedStyleSheets`in Document.prototype&&typeof CSSStyleSheet<`u`&&typeof CSSStyleSheet.prototype.replaceSync==`function`){let t=new CSSStyleSheet;t.replaceSync(e.t),r.adoptedStyleSheets=[t]}else{let t=document.createElement(`style`);n.styleNonce&&(t.nonce=n.styleNonce),t.textContent=e.t,r.appendChild(t)}this.transport=e.it(n),n.autoTranslate&&this.transport.loadUITranslations&&!n.demo&&!n.preview&&(this.automaticLocale=e.at(this.transport.loadUITranslations.bind(this.transport))),this.renderApp(),this.applyLocale()}renderApp(){let n=this.shadowRoot,i=this.resolved,a=this.transport;!n||!i||!a||(0,t.render)((0,r.jsx)(e.st,{value:i.analyticsRenderer===`local`?void 0:e.ct(i.apiBaseUrl,i.workspaceUrl),children:(0,r.jsx)(pe,{transport:a,config:i,bindControls:e=>this.controls=e,composerDraftStore:this.composerDraftStore})}),n)}async applyLocale(){let t=this.input;if(!t||!this.resolved)return;this.localeAbort?.abort();let n=new AbortController;this.localeAbort=n;let r=++this.localeRequest,i=e.o(t),a=e.i(i).locale,o=await e.n(a);if(r!==this.localeRequest||!this.resolved||this.input!==t||(Object.assign(this.resolved,e.i(i,o)),this.renderApp(),!this.automaticLocale))return;let s={};for(let t of[`widget`,`results`,`viewer`])this.automaticLocale.load({namespace:t,locale:a,signal:n.signal,onCatalog:a=>{if(n.signal.aborted||r!==this.localeRequest||!this.resolved)return;s[t]=a;let c={widget:e.ot(o.widget,s.widget),results:e.ot(o.results,s.results,{viewerMessages:s.viewer??{}})};Object.assign(this.resolved,e.i(i,c)),this.renderApp()}})}setLocale(e){return this.input?(this.input={...this.input,...e.locale===void 0?{}:{locale:e.locale},...e.dir===void 0?{}:{dir:e.dir},...e.strings?{strings:{...this.input.strings,...e.strings}}:{}},this.applyLocale()):Promise.resolve()}open(){this.controls?.open()}close(){this.controls?.close()}toggle(){this.controls?.toggle()}identify(e){this.controls?.identify(e)}clear(){this.controls?.startNew()}shutdown(){this.controls?.shutdown()}unmount(){this.localeAbort?.abort(),this.localeRequest+=1,this.resolved=null,this.shadowRoot&&(0,t.render)(null,this.shadowRoot)}disconnectedCallback(){this.localeAbort?.abort()}};typeof customElements<`u`&&!customElements.get(me)&&customElements.define(me,_);const v=(e,t=document.body)=>{if(typeof document>`u`)throw Error(`[centrinfo-widget] createWidget must run in a browser.`);let n=document.createElement(me);return n.style.pointerEvents=`none`,n.style.position=`fixed`,n.style.inset=`0`,n.style.width=`0`,n.style.height=`0`,t.appendChild(n),n.mountWith(e),{open:()=>n.open(),close:()=>n.close(),toggle:()=>n.toggle(),show:()=>n.open(),hide:()=>n.close(),identify:e=>n.identify(e),update:e=>n.identify(e),clear:()=>n.clear(),shutdown:()=>n.shutdown(),logout:()=>n.shutdown(),setLocale:e=>n.setLocale(e),destroy:()=>{n.unmount(),n.remove()}}},y=e=>v(e);let he=null;const ge=e=>{he?.destroy();let t=y(e);return he=t,t},_e={init:ge,createWidget:y};exports.Centrinfo=_e,exports.SDK_LANGUAGES=e.ht,exports.createWidget=y,exports.init=ge;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as WidgetStrings, M as SDK_LANGUAGES, d as WidgetHandle, f as WidgetLocaleUpdate, m as WidgetUser, p as WidgetThemeTokens, u as WidgetConfig } from "./types-sRV3p0Gu.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/mount.d.ts
|
|
4
4
|
/** Create + mount the floating public messenger. */
|
|
@@ -15,4 +15,4 @@ declare const Centrinfo: {
|
|
|
15
15
|
createWidget: (config: WidgetConfig) => WidgetHandle;
|
|
16
16
|
};
|
|
17
17
|
//#endregion
|
|
18
|
-
export { Centrinfo, type WidgetConfig, type WidgetHandle, type WidgetStrings, type WidgetThemeTokens, type WidgetUser, createWidget, init };
|
|
18
|
+
export { Centrinfo, SDK_LANGUAGES, type WidgetConfig, type WidgetHandle, type WidgetLocaleUpdate, type WidgetStrings, type WidgetThemeTokens, type WidgetUser, createWidget, init };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as WidgetStrings, M as SDK_LANGUAGES, d as WidgetHandle, f as WidgetLocaleUpdate, m as WidgetUser, p as WidgetThemeTokens, u as WidgetConfig } from "./types-M-juCXr7.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/mount.d.ts
|
|
4
4
|
/** Create + mount the floating public messenger. */
|
|
@@ -15,4 +15,4 @@ declare const Centrinfo: {
|
|
|
15
15
|
createWidget: (config: WidgetConfig) => WidgetHandle;
|
|
16
16
|
};
|
|
17
17
|
//#endregion
|
|
18
|
-
export { Centrinfo, type WidgetConfig, type WidgetHandle, type WidgetStrings, type WidgetThemeTokens, type WidgetUser, createWidget, init };
|
|
18
|
+
export { Centrinfo, SDK_LANGUAGES, type WidgetConfig, type WidgetHandle, type WidgetLocaleUpdate, type WidgetStrings, type WidgetThemeTokens, type WidgetUser, createWidget, init };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as WidgetStrings, M as SDK_LANGUAGES, d as WidgetHandle, f as WidgetLocaleUpdate, m as WidgetUser, p as WidgetThemeTokens, u as WidgetConfig } from "./types-M-juCXr7.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/mount.d.ts
|
|
4
4
|
/** Create + mount the floating public messenger. */
|
|
@@ -15,4 +15,4 @@ declare const Centrinfo: {
|
|
|
15
15
|
createWidget: (config: WidgetConfig) => WidgetHandle;
|
|
16
16
|
};
|
|
17
17
|
//#endregion
|
|
18
|
-
export { Centrinfo, type WidgetConfig, type WidgetHandle, type WidgetStrings, type WidgetThemeTokens, type WidgetUser, createWidget, init };
|
|
18
|
+
export { Centrinfo, SDK_LANGUAGES, type WidgetConfig, type WidgetHandle, type WidgetLocaleUpdate, type WidgetStrings, type WidgetThemeTokens, type WidgetUser, createWidget, init };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import{A as e,B as t,C as n,D as r,E as i,F as a,G as o,I as s,J as ee,K as te,L as ne,M as re,N as ie,P as ae,R as oe,S as se,T as ce,U as le,V as ue,W as de,X as c,Y as fe,a as pe,b as me,d as he,f as ge,g as _e,h as ve,i as ye,j as be,k as xe,m as Se,n as Ce,o as we,q as l,rt as u,t as Te,v as Ee,w as De,x as Oe,y as ke}from"./styles-BUK2S5l_.mjs";import{render as d}from"preact";import{useCallback as f,useEffect as p,useLayoutEffect as Ae,useRef as m,useState as h}from"preact/hooks";import{Fragment as je,jsx as g,jsxs as _}from"preact/jsx-runtime";const Me=(e,t)=>{if(typeof MutationObserver>`u`)return()=>void 0;let n=e.scrollHeight,r=0,i=()=>{r=0;let i=e.scrollHeight,a=i>n,o=t.isAtBottom()||n-e.scrollTop-e.clientHeight<80;n=i,a&&(o?(e.scrollTop=e.scrollHeight,t.onFollow?.()):t.onUnseen?.())},a=new MutationObserver(()=>{r||(r=typeof requestAnimationFrame==`function`?requestAnimationFrame(i):setTimeout(i,0))});return a.observe(e,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:[`style`,`height`]}),()=>{a.disconnect(),r&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(r)}},v=e=>e.startsWith(`image/`)?`image`:e===`application/pdf`?`pdf`:`other`,Ne=({state:e,onClose:t})=>{let n=l(),r=m(null);p(()=>{r.current?.focus();let e=e=>{e.key===`Escape`&&(e.stopPropagation(),t())};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[t]);let i=e.status===`ready`?v(e.mimeType):`other`;return g(`div`,{class:`cf-preview`,role:`dialog`,"aria-modal":`true`,"aria-label":te(n.attachPreviewTitle,{name:e.name}),onClick:e=>{e.target===e.currentTarget&&t()},children:_(`div`,{class:`cf-preview__frame`,children:[_(`div`,{class:`cf-preview__bar`,children:[g(`span`,{class:`cf-preview__name`,title:e.name,children:e.name}),e.status===`ready`&&g(`a`,{class:`cf-preview__btn`,href:e.url,download:e.name,children:n.attachDownload}),g(`button`,{ref:r,type:`button`,class:`cf-preview__btn cf-preview__close`,"aria-label":n.attachPreviewClose,onClick:t,children:`✕`})]}),_(`div`,{class:`cf-preview__body`,children:[e.status===`loading`&&g(`p`,{class:`cf-preview__note`,children:n.attachPreviewLoading}),e.status===`error`&&g(`p`,{class:`cf-preview__note`,children:n.attachPreviewFailed}),e.status===`ready`&&i===`image`&&g(`img`,{class:`cf-preview__image`,src:e.url,alt:e.name}),e.status===`ready`&&i===`pdf`&&g(`iframe`,{class:`cf-preview__pdf`,src:e.url,title:e.name}),e.status===`ready`&&i===`other`&&g(`p`,{class:`cf-preview__note`,children:n.attachPreviewUnsupported})]})]})})},Pe=({name:e,greeting:t})=>{let n=l();return _(`section`,{class:`cf-empty-welcome`,"aria-label":te(n.welcomeLabel,{name:e}),children:[g(`span`,{class:`cf-empty-welcome__eyebrow`,children:n.welcomeEyebrow}),g(`h2`,{children:e}),g(`p`,{children:t||n.welcomePrompt})]})},Fe=(e,t,n)=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),n();return}if(e.key!==`Tab`)return;let r=Array.from(t.querySelectorAll(`button, [href], textarea, input, select, [tabindex]:not([tabindex="-1"])`)).filter(e=>!e.hasAttribute(`disabled`)&&e.getAttribute(`aria-hidden`)!==`true`&&e.tabIndex>=0);if(r.length===0)return;let i=t.getRootNode(),a=e.composedPath()[0],o=a instanceof HTMLElement?a:`activeElement`in i?i.activeElement:document.activeElement,s=r[0],ee=r[r.length-1];e.shiftKey&&(o===s||!t.contains(o))?(e.preventDefault(),e.stopPropagation(),ee.focus()):!e.shiftKey&&(o===ee||!t.contains(o))&&(e.preventDefault(),e.stopPropagation(),s.focus())},y=new Map,b=e=>{if(!e||typeof document>`u`||typeof CanvasRenderingContext2D>`u`)return;let t=document.createElement(`canvas`).getContext(`2d`);if(!t)return;t.fillStyle=`#010203`,t.fillStyle=e;let n=t.fillStyle;if(n===`#010203`&&e.trim().toLowerCase()!==`#010203`)return;let r=n.match(/^#([\da-f]{6})$/i)?.[1];if(r)return[Number.parseInt(r.slice(0,2),16),Number.parseInt(r.slice(2,4),16),Number.parseInt(r.slice(4,6),16),1];let i=n.match(/^rgba?\(([\d.]+)[, ]+([\d.]+)[, ]+([\d.]+)(?:[, /]+([\d.]+))?\)$/i);if(!i)return;let a=i.slice(1,5).map(Number);if(!a.some(e=>!Number.isFinite(e)))return[a[0],a[1],a[2],a[3]??1]},Ie=(e,t=`#ffffff`)=>{let n=`${e??``}|${t}`;if(y.has(n))return y.get(n);let r=b(e),i=b(t)??[255,255,255,1];if(!r){y.set(n,void 0);return}let a=r[3],o=r.slice(0,3).map((e,t)=>e*a+i[t]*(1-a)).map(e=>{let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}),s=o[0]*.2126+o[1]*.7152+o[2]*.0722,ee=1.05/(s+.05)>=(s+.05)/.059?`#ffffff`:`#0f1e2a`;return y.set(n,ee),ee},Le=e=>{let[t,n]=h(`light`);return p(()=>{if(e!==`auto`||typeof matchMedia>`u`)return;let t=matchMedia(`(prefers-color-scheme: dark)`),r=()=>n(t.matches?`dark`:`light`);return r(),t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[e]),e===`auto`?t:e},Re={end:`end the call`,mute:`mute your microphone`,minimize:`minimize the chat`,expand:`expand the view`,shrink:`exit the expanded view`},ze=e=>e.trim().toLowerCase().replace(/[^\p{L}\p{N}\s']/gu,` `).replace(/\s+/g,` `).trim(),Be=[{action:`shrink`,re:/\b(?:exit|leave|quit|close)\b[\s\w]*\b(?:full ?screen|expanded|theat(?:er|re))\b|\bshrink\b|\bsmaller view\b/},{action:`end`,re:/\b(?:end|close|stop|finish|hang ?up|quit|exit)\b[\s\w]*\b(?:call|chat|conversation|convo|session|talking)\b|\bhang ?up\b|\bgood ?bye\b|^bye(?: bye)?$/},{action:`mute`,re:/\bmute\b|\bstop listening\b/},{action:`minimize`,re:/\bminimi[sz]e\b|\bhide\b[\s\w]*\b(?:chat|call|window|widget)\b/},{action:`expand`,re:/\bexpand\b|\bmaximi[sz]e\b|\bfull ?screen\b|\btheat(?:er|re) mode\b|\bbigger view\b/}],Ve=/^(?:yes|yeah|yep|yup|sure|correct|confirm|affirmative|go ahead|do it|please do|ok(?:ay)?)\b/,He=/^(?:no|nope|nah|cancel|never ?mind|don'?t|stop)\b/,Ue=/^(?:end|close|stop|finish|hang ?up|quit|exit|bye|good ?bye)\b/,We=e=>{let t=ze(e);if(!t)return null;for(let{action:e,re:n}of Be)if(n.test(t)){let n=t.split(` `).length;return{action:e,confident:e===`end`?n<=10:n<=6}}return null},Ge=e=>`I didn't catch yes or no. Say yes to ${Re[e]}, or no to keep talking.`,Ke=({transport:ee,config:c,bindControls:fe,composerDraftStore:Ce})=>{let l=c.strings,[u,Te]=h(c.openByDefault),{persona:d,messages:v,sending:y,assistantSpeaking:b,visitor:Be,hasEmail:Ke,liveMode:x,assignedAgentName:qe,agentTypingName:Je,starters:Ye,featuredLinks:Xe,send:S,sendGif:Ze,notifyTyping:Qe,stop:$e,amend:et,hold:tt,resumeHeld:nt,duckSpeaking:rt,retry:it,rateMessage:at,doubleCheckResponse:ot,retryResponse:st,rateExplanation:ct,explanationTransport:lt,injectAssistant:ut,reconnectSupport:dt,appendUserDraft:ft,patchMessage:C,removeMessage:pt,submitCsat:mt,submitForm:ht,confirmHostedBooking:gt,transcribe:_t,uploadAttachment:vt,loadAttachment:yt,searchGifs:bt,demoSlots:xt,gifEnabled:St,identify:Ct,ended:w,endConversation:wt,startNew:Tt,history:Et,viewingSessionId:Dt,viewMessages:Ot,openConversation:kt,closeHistoryView:At,shutdown:jt,stopSpeaking:T,speakAssistantText:Mt,analyticsModels:Nt,analyticsModelId:Pt,selectAnalyticsModel:Ft}=we(ee,c,u),It=pe(v,x),[Lt,Rt]=h(null),zt=m(0),Bt=f((e,t,n)=>{n===zt.current&&Rt({status:`ready`,name:t,url:URL.createObjectURL(e),mimeType:e.type||`application/octet-stream`})},[]),Vt=f((e,t,n)=>{let r=t.name,i=++zt.current;Rt({status:`loading`,name:r}),yt(e,t,n).then(e=>Bt(e,r,i),()=>{i===zt.current&&Rt({status:`error`,name:r})})},[yt,Bt]),Ht=f((e,t)=>Bt(e,t,++zt.current),[Bt]),Ut=f(()=>{zt.current+=1,Rt(null)},[]);p(()=>()=>{Lt?.status===`ready`&&URL.revokeObjectURL(Lt.url)},[Lt]);let Wt=!!ye(d?.actions),[E,Gt]=h(0),[D,Kt]=h({mic:`off`,processing:!1}),[qt,Jt]=h(null),[Yt,Xt]=h(!1),[O,Zt]=h(!1),[Qt,$t]=h(!1),[en,tn]=h(!1),[nn,rn]=h(0),[k,A]=h(!1),[an,j]=h(null),[on,sn]=h(null),[cn,ln]=h([]),[un,dn]=h(``),[fn,pn]=h(()=>{try{return localStorage.getItem(`centrinfo:muted`)===`1`}catch{return!1}}),mn=Le(c.theme),hn=d?.soundEnabled??!0;p(()=>{ge(c.sound&&hn&&!fn)},[c.sound,hn,fn]);let gn=f(()=>{pn(e=>{let t=!e;try{localStorage.setItem(`centrinfo:muted`,t?`1`:`0`)}catch{}return t})},[]),M=m(null),_n=m(null),vn=m(null),yn=m(0),bn=m(!1),N=m(!1),P=m(null),F=m(0),xn=m(void 0),Sn=m(0),Cn=m(null),wn=m(!1),I=m(null),L=m(``),Tn=m(()=>{}),En=m(``),Dn=m(y),On=m(S);On.current=S;let kn=m(et);kn.current=et;let An=m(_t);An.current=_t;let R=m(!1),z=m(!1),jn=m(``);jn.current=[...v].reverse().find(e=>e.role===`assistant`)?.content??``;let Mn=m(b);Dn.current=y,Mn.current=b;let B=O?Yt?`timeout`:en||D.mic===`muted`?`muted`:D.mic===`unavailable`?D.reason===`permission-denied`||D.reason===`unsupported`?`denied`:`unavailable`:D.mic===`off`||D.mic===`starting`?`connecting`:D.mic===`hearing`?`hearing`:b?`speaking`:qt??(D.processing||y?`processing`:`listening`):`idle`,[Nn,Pn]=h(!0),[Fn,V]=h(!1),In=m(0),[H,Ln]=h(!1),[U,W]=h(!1),[G,K]=h(!1),Rn=m({value:``}),zn=Ce??Rn.current,Bn=m({confirmEnd:H,confirmClear:U,showHistory:G});Bn.current={confirmEnd:H,confirmClear:U,showHistory:G};let[Vn,Hn]=h(!1),q=!!Dt,Un=q?Ot:v,Wn=Un.find(e=>e.id===an&&e.visualization)?.visualization,Gn=Un.find(e=>e.id===on&&e.visualization);p(()=>{!on||Gn||(sn(null),A(!1))},[on,Gn]),p(()=>{!an||Wn||(j(null),A(!1))},[Wn,an]);let Kn=f(()=>{Te(!0),Gt(0),he(`open`),c.onOpen?.(),c.onShow?.()},[c]),J=f(()=>{Te(!1),A(!1),j(null),c.onClose?.(),c.onHide?.(),_n.current?.focus()},[c]),qn=f(()=>u?J():Kn(),[u,Kn,J]),Jn=f(()=>Ln(!0),[]),Yn=f(()=>{wt(),Ln(!1)},[wt]),Xn=f(()=>{Tt(),V(!1),Pn(!0)},[Tt]);p(()=>{fe({open:Kn,close:J,toggle:qn,identify:Ct,startNew:Tt,endConversation:wt,shutdown:jt})},[fe,Kn,J,qn,Ct,Tt,wt,jt]),p(()=>{let e=v.filter(e=>e.role===`assistant`&&!e.pending).length;if(u){yn.current=e;return}e>yn.current&&Gt(e-yn.current)},[v,u]),p(()=>{c.onUnreadChange?.(E)},[E,c]),p(()=>{let e=c.sessionDurationMinutes;if(!e||e<=0)return;let t=setTimeout(()=>jt(),e*60*1e3);return()=>clearTimeout(t)},[c.sessionDurationMinutes,v,u,jt]),p(()=>{let e=c.customLauncherSelector;if(!e||typeof document>`u`)return;let t=[];try{t=Array.from(document.querySelectorAll(e))}catch{return}let n=e=>{e.preventDefault(),qn()};return t.forEach(e=>e.addEventListener(`click`,n)),()=>t.forEach(e=>e.removeEventListener(`click`,n))},[c.customLauncherSelector,qn]);let Zn=m(!1);p(()=>{let e=c.proactiveMessage?.trim();if(!e||Zn.current)return;let t=c.proactiveOnPaths??[],n=typeof location<`u`?location.pathname:``;if(t.length>0&&!t.some(e=>n.includes(e)))return;let r=`centrinfo:proactive:${c.token.slice(0,12)}`;try{if(sessionStorage.getItem(r)===`1`)return}catch{}let i=setTimeout(()=>{if(!(u||w||v.some(e=>e.role===`user`))){Zn.current=!0;try{sessionStorage.setItem(r,`1`)}catch{}ut(e),Kn()}},Math.max(0,c.proactiveDelaySeconds)*1e3);return()=>clearTimeout(i)},[c.proactiveMessage]),p(()=>{let e=vn.current;if(!u||!e)return;let t=v[v.length-1],n=Date.now()<In.current;t?.role===`user`||Nn||n?(requestAnimationFrame(()=>{e.scrollTop=e.scrollHeight}),V(!1),n&&Pn(!0)):V(!0)},[v,u,y,Nn]);let Qn=m(!0);Qn.current=Nn,p(()=>{let e=vn.current;if(!(!u||!e))return Me(e,{isAtBottom:()=>Qn.current,onUnseen:()=>V(!0)})},[u,q]);let $n=f(()=>{let e=vn.current;if(!e)return;let t=e.getRootNode(),n=t instanceof ShadowRoot?t.activeElement:e.ownerDocument.activeElement;if(n instanceof HTMLIFrameElement&&e.contains(n)&&(In.current=0),bn.current&&!q){Pn(!0),V(!1);return}let r=e.scrollHeight-e.scrollTop-e.clientHeight<80;Pn(r),r&&V(!1)},[q]),Y=f(()=>{let e=vn.current;e&&(e.scrollTop=e.scrollHeight),V(!1),Pn(!0)},[]),er=f(()=>{In.current=Date.now()+3e3,requestAnimationFrame(Y)},[Y]);p(()=>{if(!u||q||!O||B===`connecting`)return;In.current=Date.now()+6e4,Y();let e=requestAnimationFrame(()=>{Y(),requestAnimationFrame(Y)}),t=[80,180,360].map(e=>window.setTimeout(Y,e));return()=>{cancelAnimationFrame(e),t.forEach(e=>window.clearTimeout(e))}},[b,v,u,Y,y,O,q,B]);let tr=f(()=>{M.current?.querySelector(`.cf-textarea`)?.focus()},[]),nr=f((e,t)=>{Jt(e),xn.current&&window.clearTimeout(xn.current),xn.current=window.setTimeout(()=>Jt(null),3e3),t&&!N.current&&Mt(t)},[Mt]),rr=f(e=>{let t=I.current;if(t)return t;er();let n=ft(e);return I.current=n,C(n,{content:L.current||e,pending:!0,streaming:!1}),n},[ft,er,C]),X=f(()=>{let e=I.current;if(e){if(L.current){C(e,{content:L.current,pending:!0});return}I.current=null,pt(e)}},[C,pt]),Z=f(()=>{z.current&&(z.current=!1,rt(!1)),R.current&&(R.current=!1,nt())},[rt,nt]),Q=f(()=>{bn.current=!1,P.current?.stop(`call-ended`),P.current=null,R.current=!1,z.current=!1,N.current=!1,Cn.current=null,wn.current=!1;let e=I.current;I.current=null,L.current=``,e&&pt(e),xn.current&&window.clearTimeout(xn.current),Jt(null),Xt(!1),Kt({mic:`off`,processing:!1}),rn(0),Zt(!1),$t(!1),tn(!1),A(!1),j(null),T()},[pt,T]),ir=f(()=>{k&&j(null),A(!k)},[k]),ar=f(e=>{j(e),A(!0)},[]),or=f(e=>{sn(e),A(!0)},[]),sr=f(()=>{let e=an,t=on;j(null),sn(null),A(!1),window.requestAnimationFrame(()=>{(t?M.current?.querySelector(`[data-explanation-message="${t}"]`)?.querySelector(`[data-testid="analytics-explanation-expand"]`):Array.from(M.current?.querySelectorAll(`[data-visualization-message]`)??[]).find(t=>t.dataset.visualizationMessage===e))?.focus()})},[an,on]),cr=f(()=>{j(null),sn(null),A(!1)},[]),lr=f((e,t,n=!1)=>{if(er(),t&&(C(t,{content:e,pending:!1,streaming:!1}),I.current===t&&(I.current=null)),L.current=``,n){T(),kn.current(e,{forceVoicePlayback:!0,userMessageId:t});return}bn.current&&(tt()?kn.current(e,{forceVoicePlayback:!0,userMessageId:t}):On.current(e,{forceVoicePlayback:!0,userMessageId:t}))},[er,tt,C,T]),$=f(e=>{ut(e),Mt(e)},[ut,Mt]),ur=f(()=>{if(F.current=Date.now(),Jt(null),Mn.current){z.current=!0,rt(!0);return}R.current||(R.current=tt()),rr(`Listening...`)},[rt,rr,tt]),dr=f(e=>{let t=I.current;!t||z.current||C(t,{content:`${[L.current,e].filter(Boolean).join(` `)} ...`,pending:!0})},[C]),fr=f(e=>{F.current=Date.now();let t=[L.current,e.text].map(e=>e.trim()).filter(Boolean).join(` `).replace(/\s+/g,` `).trim();if((z.current||e.overlappedOutput)&&ue(e.text,jn.current)){X(),Z();return}if(!t||Se(t)||ve(t)){let e=z.current||R.current;X(),Z(),e||nr(`misunderstood`);return}z.current&&(z.current=!1,$e(),T());let n=Cn.current;if(n){L.current=``,X();let e=ze(t);if(Ve.test(e)||n===`end`&&Ue.test(e)){Cn.current=null,Tn.current(n);return}if(He.test(e)){Cn.current=null,$(`Okay, never mind — what would you like to know?`);return}$(Ge(n));return}let r=We(t);if(r){if(L.current=``,X(),Z(),r.confident){Tn.current(r.action);return}Cn.current=r.action,$(`Just to confirm — you want me to ${Re[r.action]}? Please say yes or no.`);return}let i=rr(t);C(i,{content:t,pending:!0});let a=R.current;R.current=!1,lr(t,i,a)},[rr,C,Z,lr,X,nr,$,$e,T]),pr=f(e=>{F.current=Date.now();let t=z.current||R.current;if(X(),Z(),!(t||e.overlappedOutput||e.reason===`too-short`)){if(e.reason===`transcribe-failed`){nr(`misunderstood`,`I couldn't transcribe that. Please try again, or type your question.`);return}nr(`noise`)}},[Z,X,nr]),mr=m({speechStart:ur,partial:dr,turn:fr,noise:pr});mr.current={speechStart:ur,partial:dr,turn:fr,noise:pr};let hr=f(()=>{navigator.mediaDevices?.enumerateDevices().then(e=>{ln(e.filter(e=>e.kind===`audioinput`).map((e,t)=>({deviceId:e.deviceId,label:e.label||`Microphone ${t+1}`})))}).catch(()=>{})},[]),gr=f(()=>{if(bn.current){Q();return}if(tr(),!d?.allowVoiceInput||!d.talkbackMode||d.talkbackMode===`text`||Dn.current||w||q)return;F.current=Date.now(),N.current=!1,bn.current=!0,tn(!1),Zt(!0),$t(!1),Xt(!1);let e=!1,n=new t({deviceId:En.current||void 0,transcribe:async({audio:e,mimeType:t,durationSeconds:n})=>{let r=typeof navigator<`u`&&(navigator.languages?.[0]||navigator.language)||void 0;return _e(await An.current(e,t,r,n))},listener:{state:t=>{Kt(t),t.mic!==`starting`&&t.mic!==`off`&&$t(!0),!e&&t.mic===`listening`&&(e=!0,hr())},speechStart:()=>mr.current.speechStart(),partial:({text:e})=>mr.current.partial(e),turn:e=>mr.current.turn(e),noise:e=>mr.current.noise(e),level:e=>{let t=performance.now();t-Sn.current<90||(Sn.current=t,rn(e))}}});P.current=n,n.setOutputActive(Mn.current),n.start()},[Q,w,tr,d,hr,q]),_r=f(()=>{let e=!N.current;N.current=e,tn(e),P.current?.setMuted(e),e?(L.current=``,X(),Z()):F.current=Date.now()},[Z,X]),vr=f(e=>{switch(F.current=Date.now(),e){case`end`:wn.current=!0,$(`Okay — ending our call now. Goodbye!`),window.setTimeout(()=>{wn.current&&(wn.current=!1,Q())},2e3);break;case`mute`:N.current||_r(),$(`Muted. Tap the mic button when you want me to listen again.`);break;case`minimize`:J(),$(`Minimized — I'm still listening. Tap the call pill to bring the chat back.`);break;case`expand`:A(!0),$(`Sure — expanding the view.`);break;case`shrink`:j(null),A(!1),$(`Okay — back to the smaller view.`);break}},[J,Q,$,_r]);p(()=>{Tn.current=vr},[vr]);let yr=m(!1);p(()=>{yr.current&&!b&&wn.current&&(wn.current=!1,Q()),yr.current=b},[b,Q]);let br=f(e=>{En.current=e,dn(e),P.current?.selectDevice(e||void 0)},[]),xr=f(()=>{!bn.current||N.current||(z.current=!1,R.current=!1,$e(),T(),F.current=Date.now())},[$e,T]);p(()=>{P.current?.setOutputActive(b),F.current=Date.now()},[b]),p(()=>{if(B!==`denied`)return;let e=window.setTimeout(()=>Q(),3500);return()=>window.clearTimeout(e)},[Q,B]),p(()=>{if(!O)return;let e=window.setInterval(()=>{let e=P.current;!e||N.current||Dn.current||Mn.current||e.snapshot.mic===`hearing`||e.snapshot.processing||Date.now()-F.current<6e4||(P.current?.log.add(`call-timeout`),Xt(!0),window.setTimeout(()=>Q(),2400))},5e3);return()=>window.clearInterval(e)},[Q,O]);let Sr=O&&!en&&(y||b);p(()=>()=>Q(),[Q]);let[Cr,wr]=h(``),Tr=m(!1);p(()=>{if(Tr.current&&!y){let e=[...v].reverse().find(e=>e.role===`assistant`&&!e.streaming&&!e.pending&&e.content);e&&wr(e.content)}Tr.current=y},[y,v]),Ae(()=>{if(!u)return;let e=M.current,t=H||U?e?.querySelector(`.cf-confirm__card`):G?e?.querySelector(`.cf-history`):null;if(!t)return;let n=t.getRootNode(),r=`activeElement`in n?n.activeElement:document.activeElement;(!r||!t.contains(r))&&t.querySelector(`button, [href], textarea, input, [tabindex]:not([tabindex="-1"])`)?.focus()},[U,H,u,G]),p(()=>{if(!u)return;let e=M.current,t=H||U?e?.querySelector(`.cf-confirm__card`):G?e?.querySelector(`.cf-history`):null,n=e?.querySelectorAll(`:scope > .cf-header, :scope > .cf-panel__video, :scope > .cf-panel__chat`);n?.forEach(e=>{t?(e.setAttribute(`inert`,``),e.setAttribute(`aria-hidden`,`true`)):(e.removeAttribute(`inert`),e.removeAttribute(`aria-hidden`))}),t||requestAnimationFrame(()=>e?.querySelector(`.cf-textarea`)?.focus());let r=n=>{if(n.key===`Escape`){n.preventDefault();let t=Bn.current;if(t.confirmEnd){Ln(!1);return}if(t.confirmClear){W(!1);return}if(t.showHistory){K(!1);return}if(e?.querySelector(`.cf-action-drawer`))return;J();return}if(n.key!==`Tab`||!t)return;let r=t.querySelectorAll(`button, [href], textarea, input, [tabindex]:not([tabindex="-1"])`),i=Array.from(r).filter(e=>!e.hasAttribute(`disabled`));if(i.length===0)return;let a=i[0],o=i[i.length-1],s=t.getRootNode()instanceof ShadowRoot?t.getRootNode().activeElement:document.activeElement;n.shiftKey&&s===a?(n.preventDefault(),o.focus()):!n.shiftKey&&s===o&&(n.preventDefault(),a.focus())};return e?.addEventListener(`keydown`,r),()=>{e?.removeEventListener(`keydown`,r),n?.forEach(e=>{e.removeAttribute(`inert`),e.removeAttribute(`aria-hidden`)})}},[u,J,H,U,G]),p(()=>{let e=M.current;e&&(u?e.removeAttribute(`inert`):e.setAttribute(`inert`,``))},[u]);let Er=c.accentColor??c.themeTokens?.accent??d?.accentColor,Dr=c.themeTokens?.accentText??Ie(Er,c.themeTokens?.background??(mn===`dark`?`#0f1c27`:`#ffffff`)),Or={zIndex:c.zIndex,"--cf-h-pad":`${c.horizontalPadding}px`,"--cf-v-pad":`${c.verticalPadding}px`,...Dr?{"--cf-accent-ink":Dr}:{},...c.themeTokens?.accentStrong?{"--cf-accent-2":c.themeTokens.accentStrong}:{},...c.themeTokens?.background?{"--cf-bg":c.themeTokens.background}:{},...c.themeTokens?.surface?{"--cf-surface":c.themeTokens.surface}:{},...c.themeTokens?.surfaceMuted?{"--cf-surface-2":c.themeTokens.surfaceMuted}:{},...c.themeTokens?.text?{"--cf-text":c.themeTokens.text}:{},...c.themeTokens?.mutedText?{"--cf-muted":c.themeTokens.mutedText}:{},...c.themeTokens?.border?{"--cf-border":c.themeTokens.border}:{},...c.themeTokens?.shadow?{"--cf-shadow":c.themeTokens.shadow}:{},...c.themeTokens?.radius?{"--cf-radius":c.themeTokens.radius}:{},...c.themeTokens?.fontFamily?{"--cf-font":c.themeTokens.fontFamily}:{},...c.themeTokens?.success?{"--cf-success":c.themeTokens.success}:{},...c.themeTokens?.warning?{"--cf-warning":c.themeTokens.warning}:{},...c.themeTokens?.danger?{"--cf-danger":c.themeTokens.danger}:{},...Er?{"--cf-accent":Er,"--cf-accent-2":c.themeTokens?.accentStrong??`color-mix(in oklab, ${Er} 76%, #14141f)`}:{}},kr=e=>S(e),Ar=[...v].reverse().find(e=>e.role===`user`&&e.content.trim())?.content??``,jr=v.some(e=>e.role===`user`),Mr=!!(d?.allowVoiceInput&&d?.talkbackMode&&d.talkbackMode!==`text`),Nr=Mr,Pr=!q&&Nr&&!jr?Un.filter((e,t)=>!(t===0&&e.role===`assistant`)):Un,Fr=x===`human`&&qe?qe:d?.agentName??l.chatName,Ir=x===`human`?l.liveSupport:x===`queued`?l.waitingForTeam:d?.offline?l.statusOffline:l.statusOnline,Lr=!w&&!q?d?.availableActions:void 0,Rr=!w&&!q?d?.actions:void 0,zr=O&&!Qt&&B===`connecting`&&!q;return g(o,{value:l,children:g(de,{value:c.locale,children:_(`div`,{class:`cf-root`,dir:c.dir,"data-theme":mn,"data-align":c.alignment,"data-display":`floating`,style:Or,children:[k&&u&&g(`div`,{class:`cf-theater-backdrop`,onClick:cr}),_(`div`,{ref:M,class:`cf-panel ${u?`is-open`:``} ${O?`cf-panel--call`:``} ${zr?`cf-panel--voice-connecting`:``} ${k&&u?`cf-panel--theater`:``} ${Wn||Gn?`cf-panel--analytics-focus`:``}`,role:`dialog`,"aria-modal":`false`,"aria-label":`${l.chatName}: ${d?.agentName??l.assistantName}`,"aria-hidden":!u,children:[Lt&&u&&g(Ne,{state:Lt,onClose:Ut}),_(`div`,{class:`cf-header`,children:[g(ke,{persona:d,hideWhenMissing:!0}),_(`div`,{class:`cf-header__meta`,children:[g(`div`,{class:`cf-header__name`,children:Fr}),c.token.startsWith(`pub_test_`)?g(`small`,{role:`status`,children:l.testMode}):null,g(`div`,{class:`cf-header__status ${x===`ai`&&d?.offline?`cf-header__status--offline`:``}`,children:g(`span`,{class:`cf-header__status-text`,children:Ir})})]}),_(`div`,{class:`cf-header__actions`,children:[Et.length>0&&g(`button`,{type:`button`,class:`cf-header__btn`,"aria-label":l.pastConversations,title:l.pastConversations,"aria-pressed":G,onClick:()=>K(e=>!e),children:g(ie,{})}),jr&&!w&&!q&&g(`button`,{type:`button`,class:`cf-header__btn`,"aria-label":l.endChat,title:l.endChat,onClick:Jn,children:g(re,{})}),c.sound&&hn&&g(`button`,{type:`button`,class:`cf-header__btn`,"aria-label":fn?l.unmuteSounds:l.muteSounds,"aria-pressed":fn,onClick:gn,children:g(fn?ae:a,{})}),g(`button`,{type:`button`,class:`cf-header__btn cf-header__close`,"aria-label":l.closeChat,onClick:J,children:g(be,{})})]})]}),g(`div`,{class:`cf-panel__video`,children:Wn?g(`div`,{class:`cf-analytics-focus`,role:`region`,"aria-label":l.expandedAnalyticsResult,children:g(r,{visualization:Wn,explanationTransport:q?void 0:lt(`widget`),onExplanationFeedback:q?void 0:ct,onOpenAnalyticsSource:c.onOpenAnalyticsSource,expanded:!0,onFollowUp:e=>{sr(),S(e)},onClose:sr})}):Gn?.visualization?g(`div`,{class:`cf-analytics-focus`,role:`region`,"aria-label":l.expandedAnalyticsResult,children:g(i,{visualization:Gn.visualization,onClose:sr,onFollowUp:e=>{sr(),S(e)},onFeedback:q?void 0:ct,transport:q?void 0:lt(`widget`),onOpenSource:c.onOpenAnalyticsSource})}):!q&&Nr?g(me,{persona:d,starters:[],onPick:S,onFocusComposer:gr,speaking:b,voiceState:B,replyPending:O&&y&&!b,pinned:!0,muted:en,onToggleMute:_r,onEndCall:Q,onTalkNow:xr,showTalkNow:Sr,micLevel:nn,theaterMode:k,onToggleTheater:ir,onMinimize:J,audioDevices:cn,selectedAudioDeviceId:un,onSelectAudioDevice:br,connectingOnly:zr}):null}),!zr&&_(`div`,{class:`cf-panel__chat`,children:[c.preview&&g(`div`,{class:`cf-preview-banner`,children:l.previewBanner}),q&&g(`div`,{class:`cf-viewing-banner`,children:l.viewingPast}),_(`div`,{class:`cf-body`,ref:vn,role:`log`,onScroll:$n,children:[Pr.map((e,t)=>g(De,{msg:e,persona:d,isLast:!q&&t===Pr.length-1,visitor:Be,hasEmail:Ke,lastQuestion:Ar,showActions:!q&&t===Pr.length-1&&!!(e.handoffOffered||e.selectedAction),onPickReply:kr,onSubmitForm:ht,onDemoSlots:xt,onConfirmHostedBooking:gt,onRetry:it,ratable:!q&&Pr.slice(0,t).some(e=>e.role===`user`),onRate:at,onDoubleCheck:q||w?void 0:ot,onRetryResponse:q||w||x!==`ai`?void 0:st,doubleCheckDisabled:y,onExplanationFeedback:q?void 0:ct,explanationTransport:q?void 0:lt(`widget`),onOpenAnalyticsSource:c.onOpenAnalyticsSource,onExpandVisualization:q?void 0:ar,onExpandExplanation:q?void 0:or,onOpenAttachment:Vt,onReconnect:!q&&!w&&Wt&&e.id===It?dt:void 0},e.id)),!jr&&!q&&_(je,{children:[Pr.length===0&&g(Pe,{name:d?.agentName??l.assistantName,greeting:d?.greeting}),g(ce,{items:Ye,onPick:S}),g(se,{items:Xe})]}),Fn&&_(`button`,{type:`button`,class:`cf-newmsg`,onClick:Y,children:[g(xe,{}),l.newMessages]})]}),g(`div`,{class:`cf-sr-live`,"aria-live":`polite`,"aria-atomic":`true`,children:Cr}),y&&!w&&!q&&g(`div`,{class:`cf-stopbar`,children:_(`button`,{type:`button`,class:`cf-stop`,onClick:$e,children:[g(s,{}),l.stop]})}),q?g(`div`,{class:`cf-ended`,children:g(`button`,{type:`button`,class:`cf-ended__btn`,onClick:At,children:l.backToChat})}):w?_(`div`,{class:`cf-ended`,children:[g(`p`,{class:`cf-ended__text`,children:l.conversationEnded}),c.csat&&jr?Vn?g(`p`,{class:`cf-ended__text`,children:l.feedbackThanks}):_(`div`,{class:`cf-csat`,children:[g(`span`,{class:`cf-csat__q`,children:l.csatPrompt}),g(`button`,{type:`button`,class:`cf-csat__btn`,"aria-label":l.feedbackHelpful,onClick:()=>{mt(`up`),Hn(!0)},children:g(oe,{})}),g(`button`,{type:`button`,class:`cf-csat__btn`,"aria-label":l.feedbackNotHelpful,onClick:()=>{mt(`down`),Hn(!0)},children:g(ne,{})})]}):null,g(`button`,{type:`button`,class:`cf-ended__btn`,onClick:Xn,children:l.startNewChat})]}):_(je,{children:[Je?g(`div`,{class:`cf-live-typing`,"aria-live":`polite`,children:te(l.agentTyping,{name:Je})}):null,Lr&&Lr.length>0&&g(`div`,{class:`cf-footer-actions`,children:g(Ee,{actions:Lr,descriptors:Rr,visitor:Be,onSubmitForm:ht,onDemoSlots:xt,onConfirmHostedBooking:gt,scheduler:d?.scheduler,translations:c.actionTranslations})},`footer-actions`),g(Oe,{toolbarContent:c.showAnalyticsModelSelector?g(le,{models:Nt,value:Pt,onChange:Ft,disabled:y}):null,draftStore:zn,onSend:S,onSendGif:Ze,onTyping:Qe,disabled:y,allowVoice:Mr&&c.composer?.voice!==!1,onTranscribe:_t,gifEnabled:St,onSearchGifs:bt,allowAttach:c.attachments,analyzeAttachments:!0,onUpload:vt,onPreviewAttachment:Ht},`composer`)]}),!w&&d?.disclaimerText&&g(`div`,{class:`cf-disclaimer`,children:d.disclaimerText}),_(`div`,{class:`cf-footer`,children:[g(`button`,{type:`button`,class:`cf-footer__privacy`,"aria-label":l.clearDeviceData,onClick:()=>W(!0),children:l.privacyAndData}),g(`span`,{"aria-hidden":`true`,children:`·`}),l.poweredBy,` `,g(`a`,{href:`https://accurixtech.com/centrinfo`,target:`_blank`,rel:`noopener noreferrer`,children:`Centrinfo`})]})]}),H&&g(`div`,{class:`cf-confirm`,onClick:()=>Ln(!1),children:_(`div`,{class:`cf-confirm__card`,role:`alertdialog`,"aria-modal":`true`,"aria-label":l.endChatConfirm,onClick:e=>e.stopPropagation(),onKeyDownCapture:e=>Fe(e,e.currentTarget,()=>Ln(!1)),children:[g(`div`,{class:`cf-confirm__title`,children:l.endChatConfirm}),g(`div`,{class:`cf-confirm__body`,children:l.endChatConfirmBody}),_(`div`,{class:`cf-confirm__actions`,children:[g(`button`,{type:`button`,class:`cf-confirm__btn cf-confirm__btn--cancel`,onClick:()=>Ln(!1),children:l.cancel}),g(`button`,{type:`button`,class:`cf-confirm__btn cf-confirm__btn--danger`,onClick:Yn,children:l.endConfirmCta})]})]})},`confirm-end`),G&&g(`div`,{class:`cf-confirm`,onClick:()=>K(!1),children:_(`div`,{class:`cf-history`,role:`dialog`,"aria-modal":`true`,"aria-label":l.pastConversations,onClick:e=>e.stopPropagation(),onKeyDownCapture:e=>Fe(e,e.currentTarget,()=>K(!1)),children:[_(`div`,{class:`cf-history__head`,children:[g(`span`,{children:l.pastConversations}),g(`button`,{type:`button`,class:`cf-header__btn`,"aria-label":l.closeHistory,onClick:()=>K(!1),children:g(be,{})})]}),g(`div`,{class:`cf-history__list`,children:Et.map(e=>_(`button`,{type:`button`,class:`cf-history__item ${e.sessionId===Dt?`is-active`:``}`,onClick:()=>{kt(e.sessionId),K(!1)},children:[g(`span`,{class:`cf-history__title`,children:e.title}),_(`span`,{class:`cf-history__meta`,children:[new Date(e.ts).toLocaleDateString(void 0,{month:`short`,day:`numeric`}),e.ended?` · ${l.historyEnded}`:``]})]},e.sessionId))}),g(`div`,{class:`cf-history__footer`,children:g(`button`,{type:`button`,class:`cf-history__clear`,onClick:()=>{K(!1),W(!0)},children:l.clearDeviceData})})]})},`history`),U&&g(`div`,{class:`cf-confirm`,onClick:()=>W(!1),children:_(`div`,{class:`cf-confirm__card`,role:`alertdialog`,"aria-modal":`true`,"aria-label":l.clearDeviceData,onClick:e=>e.stopPropagation(),onKeyDownCapture:e=>Fe(e,e.currentTarget,()=>W(!1)),children:[g(`div`,{class:`cf-confirm__title`,children:l.clearDeviceData}),g(`div`,{class:`cf-confirm__body`,children:l.clearDeviceDataBody}),_(`div`,{class:`cf-confirm__actions`,children:[g(`button`,{type:`button`,class:`cf-confirm__btn cf-confirm__btn--cancel`,onClick:()=>W(!1),children:l.cancel}),g(`button`,{type:`button`,class:`cf-confirm__btn cf-confirm__btn--danger`,onClick:()=>{W(!1),jt()},children:l.clearDeviceDataCta})]})]})},`confirm-clear`)]}),O&&!u?g(n,{persona:d,voiceState:B,muted:en,onToggleMute:_r,onEndCall:Q,micLevel:nn,onExpand:Kn}):k&&u?null:!c.hideDefaultLauncher&&_(`button`,{ref:_n,type:`button`,class:`cf-launcher`,"aria-label":u?l.closeChat:E>0?`${l.openChat}. ${E===1?l.unreadMessage:te(l.unreadMessages,{count:String(E)})}`:l.openChat,"aria-expanded":u,onClick:qn,children:[c.launcherIcon?g(`img`,{class:`cf-launcher__img`,src:c.launcherIcon,alt:``}):g(e,{}),!u&&E>0&&g(`span`,{class:`cf-launcher__badge`,"aria-hidden":`true`,children:E>99?`99+`:E})]})]})})})},x=`centrinfo-widget`;var qe=class extends HTMLElement{constructor(...e){super(...e),u(this,`controls`,null),u(this,`composerDraftStore`,{value:``})}mountWith(e){let t=Ce(e),n=this.shadowRoot??this.attachShadow({mode:`open`});if(this.style.zIndex=String(t.zIndex),`adoptedStyleSheets`in Document.prototype&&typeof CSSStyleSheet<`u`&&typeof CSSStyleSheet.prototype.replaceSync==`function`){let e=new CSSStyleSheet;e.replaceSync(Te),n.adoptedStyleSheets=[e]}else{let e=document.createElement(`style`);t.styleNonce&&(e.nonce=t.styleNonce),e.textContent=Te,n.appendChild(e)}let r=ee(t);d(g(fe,{value:t.analyticsRenderer===`local`?void 0:c(t.apiBaseUrl,t.workspaceUrl),children:g(Ke,{transport:r,config:t,bindControls:e=>this.controls=e,composerDraftStore:this.composerDraftStore})}),n)}open(){this.controls?.open()}close(){this.controls?.close()}toggle(){this.controls?.toggle()}identify(e){this.controls?.identify(e)}clear(){this.controls?.startNew()}shutdown(){this.controls?.shutdown()}unmount(){this.shadowRoot&&d(null,this.shadowRoot)}};typeof customElements<`u`&&!customElements.get(x)&&customElements.define(x,qe);const Je=(e,t=document.body)=>{if(typeof document>`u`)throw Error(`[centrinfo-widget] createWidget must run in a browser.`);let n=document.createElement(x);return n.style.pointerEvents=`none`,n.style.position=`fixed`,n.style.inset=`0`,n.style.width=`0`,n.style.height=`0`,t.appendChild(n),n.mountWith(e),{open:()=>n.open(),close:()=>n.close(),toggle:()=>n.toggle(),show:()=>n.open(),hide:()=>n.close(),identify:e=>n.identify(e),update:e=>n.identify(e),clear:()=>n.clear(),shutdown:()=>n.shutdown(),logout:()=>n.shutdown(),destroy:()=>{n.unmount(),n.remove()}}},Ye=e=>Je(e);let Xe=null;const S=e=>{Xe?.destroy();let t=Ye(e);return Xe=t,t},Ze={init:S,createWidget:Ye};export{Ze as Centrinfo,Ye as createWidget,S as init};
|
|
1
|
+
import{$ as e,A as t,B as n,C as r,E as i,F as a,G as o,H as s,I as c,J as ee,K as l,L as te,M as ne,N as re,O as ie,P as ae,R as oe,S as se,T as ce,V as le,Y as ue,Z as de,_ as fe,_t as pe,a as me,at as u,b as he,c as ge,ct as d,et as _e,gt as ve,h as ye,ht as be,i as f,it as p,k as xe,l as Se,m as Ce,n as m,nt as we,o as h,ot as Te,q as Ee,rt as g,s as De,st as Oe,t as ke,v as Ae,vt as _,w as je,y as Me,z as Ne}from"./styles-C8MXPiR-.mjs";import{render as Pe}from"preact";import{useCallback as v,useEffect as y,useLayoutEffect as Fe,useRef as b,useState as x}from"preact/hooks";import{Fragment as Ie,jsx as S,jsxs as C}from"preact/jsx-runtime";const Le=(e,t)=>{if(typeof MutationObserver>`u`)return()=>void 0;let n=e.scrollHeight,r=0,i=()=>{r=0;let i=e.scrollHeight,a=i>n,o=t.isAtBottom()||n-e.scrollTop-e.clientHeight<80;n=i,a&&(o?(e.scrollTop=e.scrollHeight,t.onFollow?.()):t.onUnseen?.())},a=new MutationObserver(()=>{r||(r=typeof requestAnimationFrame==`function`?requestAnimationFrame(i):setTimeout(i,0))});return a.observe(e,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:[`style`,`height`]}),()=>{a.disconnect(),r&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(r)}},w={en:[`Still working on that, one moment.`,`Nearly there, thanks for waiting.`,`Still on it, just a little longer.`],fr:[`Je m’en occupe toujours, un instant.`,`Presque fini, merci de patienter.`,`Toujours en cours, encore un petit moment.`],es:[`Sigo con ello, un momento.`,`Ya casi está, gracias por esperar.`,`Todavía en ello, solo un poco más.`],pt:[`Ainda estou a tratar disso, um momento.`,`Quase pronto, obrigado por esperar.`,`Continuo nisso, só mais um pouco.`],de:[`Ich arbeite noch daran, einen Moment.`,`Fast fertig, danke fürs Warten.`,`Bin noch dran, nur noch kurz.`],it:[`Ci sto ancora lavorando, un momento.`,`Quasi fatto, grazie per l’attesa.`,`Ancora un attimo, ci sono quasi.`],ar:[`ما زلت أعمل على ذلك، لحظة من فضلك.`,`اقتربنا، شكرًا على انتظارك.`,`ما زلت أتابع، لحظات قليلة فقط.`],sw:[`Bado ninashughulikia hilo, subiri kidogo.`,`Karibu tayari, asante kwa kusubiri.`,`Bado niko kazini, muda mfupi tu.`]},Re=e=>w[(e??``).replace(`_`,`-`).split(`-`)[0].trim().toLowerCase()]??w.en,ze=(e,t)=>{let n=globalThis.speechSynthesis;if(!n||typeof SpeechSynthesisUtterance>`u`)return null;let r=new SpeechSynthesisUtterance(e);t&&(r.lang=t);let i=!1,a=new Promise(e=>{r.onend=r.onerror=()=>{i=!0,e()}});return n.speak(r),{done:a,stop:()=>{!i&&!n.pending&&n.cancel()}}},T=[`mute`,`end`,`wait`,`resume`],E={mic:`off`,processing:!1};var Be=class{constructor(e){this.options=e,_(this,`engine`,null),_(this,`snapshot`,E),_(this,`muted`,!1),_(this,`partialText`,``),_(this,`queue`,[]),_(this,`overAnswer`,!1),_(this,`overPending`,!1),_(this,`answerEchoes`,!1),_(this,`spokenAnswer`,``),_(this,`lastActivity`,0),_(this,`idleTimer`,null),_(this,`outputActive`,!1),_(this,`lastStateKey`,``),_(this,`delivering`,null),_(this,`ending`,null),_(this,`waiting`,!1),_(this,`progressTimer`,null),_(this,`answeringSince`,0),_(this,`progressSpoken`,0),_(this,`lastProgressAt`,0),_(this,`progressSpeech`,null),_(this,`progressHeard`,[])}static supported(){return l()}get active(){return this.engine!==null}get voiceEngine(){return this.engine}get state(){let{chat:e}=this.options,t=this.engine!==null,n=t&&this.answering(),r=t&&e.speaking(),i=this.snapshot,a=this.muted||i.mic===`muted`;return{active:t,phase:t?i.mic===`off`||i.mic===`starting`?`connecting`:i.mic===`unavailable`?`unavailable`:a?r?`speaking`:n||this.queue.length?`thinking`:`muted`:i.mic===`hearing`?`hearing`:r?`speaking`:this.waiting?`waiting`:n||this.queue.length?`thinking`:i.processing?`transcribing`:`listening`:`off`,mic:i,muted:a,partial:this.partialText,queued:this.queue.map(e=>e.text),answerPending:n||this.queue.length>0,waiting:t&&this.waiting,stillWorking:t&&this.stillWorking(),reason:i.mic===`unavailable`?i.reason:void 0}}async start(){if(this.engine)return;let{options:e}=this;this.lastActivity=Date.now(),this.muted=!1,this.partialText=``,this.queue=[],this.overAnswer=!1,this.overPending=!1,this.waiting=!1,this.snapshot={mic:`starting`,processing:!1};let t=new o({live:e.live?{...e.live,controls:this.controls,delegate:(t,n)=>(this.touch(),e.live.delegate(t,n,{waiting:this.waiting}))}:void 0,transcribe:e.transcribe,deviceId:e.deviceId,endSilenceMs:e.endSilenceMs,media:e.media,listener:{speaking:t=>e.events?.liveSpeaking?.(t),state:e=>{this.engine===t&&this.onState(e)},speechStart:()=>{this.engine===t&&this.onSpeechStart()},partial:({text:e})=>{this.engine===t&&this.onPartial(e)},turn:e=>{this.engine===t&&this.onTurn(e)},noise:e=>{this.engine===t&&this.onDropped(e.reason,e.overlappedOutput)},level:t=>e.events?.level?.(t),control:e=>{this.engine===t&&this.control(e)}}});this.engine=t,this.outputActive=e.chat.speaking(),t.setOutputActive(this.outputActive),this.startIdleTimer(),this.startProgressTimer(),this.emit(!0),await t.start()}end(e=`user`){let t=this.engine;if(!t)return;this.engine=null,t.stop(`conversation-${e}`),this.idleTimer&&clearInterval(this.idleTimer),this.idleTimer=null;let{chat:n}=this.options;(this.delivering!==null||n.busy())&&n.cancel(),this.delivering&&clearTimeout(this.delivering),this.delivering=null,this.ending&&clearInterval(this.ending),this.ending=null,this.stopProgress(!0),this.waiting=!1,n.silence(),this.overAnswer=!1,this.overPending=!1,this.answerEchoes=!1,this.queue=[],this.partialText=``,this.muted=!1,this.snapshot=E,this.options.events?.ended?.(e),this.emit(!0)}setMuted(e){let t=this.engine;t&&(this.muted=e,t.setMuted(e),e?(this.partialText=``,t.snapshot.processing||this.release()):this.touch(),this.emit(!0))}toggleMute(){this.setMuted(!this.state.muted)}finishTurn(){this.engine?.finishTurn()}interrupt(){if(!this.engine)return;this.engine.interrupt(),this.overAnswer=!1,this.overPending=!1;let{chat:e}=this.options;e.cancel(),e.silence(),this.touch(),this.sync()}get controls(){return this.options.controls??T}control(e){let t=Ee(e,this.controls),n=this.engine;return!t||!n?null:(n.log.add(`voice-control`,{action:t}),this.touch(),t===`mute`?this.setMuted(!0):t===`end`?this.endAfterAnswer():t===`wait`?this.waiting=!0:t===`resume`&&(this.waiting=!1),this.options.events?.control?.(t),this.emit(!0),t)}wait(){!this.engine||this.waiting||(this.waiting=!0,this.touch(),this.emit(!0))}resume(){!this.engine||!this.waiting||(this.waiting=!1,this.touch(),this.emit(!0))}endAfterAnswer(){if(this.ending)return;let e=Date.now(),t=!1;this.ending=setInterval(()=>{if(!this.engine)return;let{chat:n}=this.options,r=n.speaking();r&&(t=!0);let i=Date.now()-e;(!r&&!this.answering()&&(t||i>=2e3)||i>=2e4)&&this.end(`user`)},200)}async selectDevice(e){await this.engine?.selectDevice(e)}sync(){if(!this.engine)return;let{chat:e}=this.options;this.delivering&&(e.busy()||e.speaking())&&(clearTimeout(this.delivering),this.delivering=null);let t=e.speaking();t&&this.rememberSpokenAnswer(),(t||!this.answering())&&this.stopProgress(),t!==this.outputActive&&!this.progressSpeech&&(this.outputActive=t,this.answerEchoes=!1,this.engine.setOutputActive(t),this.touch()),this.flush(),this.emit()}answering(){return this.delivering!==null||this.options.chat.busy()}rememberSpokenAnswer(){let e=this.options.chat.lastAnswer();e.trim()&&(this.spokenAnswer=e)}isEcho(e){return ue(e,this.options.chat.lastAnswer())||!!(this.spokenAnswer&&ue(e,this.spokenAnswer))||this.progressHeard.some(t=>ue(e,t))}touch(){this.lastActivity=Date.now()}flush(){let{chat:e}=this.options;if(!this.engine||!this.queue.length||this.answering()||e.speaking())return;let t=this.queue.shift();this.touch(),this.delivering=setTimeout(()=>{this.delivering=null,this.sync()},400),e.deliver(t.text,t.token,{waiting:this.waiting})}release(){return!this.overAnswer&&!this.overPending?!1:(this.overAnswer=!1,this.overPending=!1,this.options.chat.duck(!1),!0)}onState(e){if(this.snapshot=e,(e.mic===`muted`||e.mic===`listening`||e.mic===`hearing`)&&(this.muted=e.mic===`muted`),e.mic===`off`){this.end(`mic-off`);return}e.mic!==`hearing`&&!e.processing&&this.release(),this.emit()}onSpeechStart(){this.touch();let{chat:e}=this.options,t=e.speaking(),n=e.busy();t?(this.rememberSpokenAnswer(),this.overAnswer=!0,this.answerEchoes||e.duck(!0)):n&&(this.overPending=!0,e.duck(!0)),this.partialText=``,this.options.events?.speechStart?.({overAnswer:t,answerPending:n}),this.emit()}onPartial(e){this.touch(),!this.overAnswer&&(this.partialText=e,this.options.events?.partial?.(e),this.emit())}onDropped(e,t){this.touch(),this.partialText=``;let n=this.release();this.options.events?.dropped?.({reason:e,heldSomething:n,overlappedOutput:t}),this.emit()}onTurn(e){this.touch();let{chat:t,screen:n,intercept:r,events:i}=this.options,a=n?n(e.text):e.text.trim(),o=this.overAnswer||e.overlappedOutput;if(a&&o&&this.isEcho(a)){t.speaking()&&(this.answerEchoes=!0),this.onDropped(`echo`,e.overlappedOutput);return}if(!a){this.onDropped(`unusable`,e.overlappedOutput);return}if(this.partialText=``,r?.(a)){this.release(),this.emit();return}this.overAnswer||t.speaking()?(this.overAnswer=!1,this.overPending=!1,t.silence()):this.release();let s=this.answering()||this.queue.length>0,c=i?.heard?.(a,{queued:s});this.queue.push({text:a,token:c}),this.flush(),this.emit(!0)}stillWorking(){return this.answeringSince>0&&!this.waiting&&Date.now()-this.answeringSince>=(this.options.progress?.delayMs??6e3)}startProgressTimer(){this.progressTimer=setInterval(()=>this.checkProgress(),250)}checkProgress(){let e=this.engine;if(!e)return;let{chat:t}=this.options;if(!(this.answering()&&!t.speaking())){this.answeringSince&&(this.answeringSince=0,this.progressSpoken=0,this.stopProgress(),this.emit());return}let n=Date.now();this.answeringSince||(this.answeringSince=n);let r=this.options.progress??{},i=this.stillWorking(),a=r.repeatMs??14e3;i&&!this.progressSpeech&&!this.waiting&&!this.state.muted&&e.snapshot.mic!==`hearing`&&this.progressSpoken<(r.maxLines??3)&&(this.progressSpoken===0||n-this.lastProgressAt>=a)&&this.sayProgress(e),this.emit()}sayProgress(e){let t=this.options.progress??{},n=t.language?.(),r=t.lines?.().filter(e=>e.trim())??[],i=r.length?r:Re(n),a=i[this.progressSpoken%i.length];this.progressSpoken+=1,this.lastProgressAt=Date.now(),this.progressHeard=[...this.progressHeard.slice(-5),a],e.log.add(`progress-line`,{index:this.progressSpoken}),this.options.events?.progress?.(a);let o=(t.say??ze)(a,n);o&&(this.progressSpeech=o,e.setOutputActive(!0),o.done.then(()=>{this.progressSpeech===o&&(this.progressSpeech=null,this.engine&&this.engine.setOutputActive(this.outputActive))}))}stopProgress(e=!1){let t=this.progressSpeech;this.progressSpeech=null,t?.stop(),t&&this.engine&&this.engine.setOutputActive(this.options.chat.speaking()),e&&(this.progressTimer&&clearInterval(this.progressTimer),this.progressTimer=null,this.answeringSince=0,this.progressSpoken=0,this.progressHeard=[])}startIdleTimer(){let e=this.options.idleLimitMs??6e4;e&&(this.idleTimer=setInterval(()=>{let t=this.engine;if(!t)return;let{chat:n}=this.options,{mic:r,processing:i}=t.snapshot;this.state.muted||r===`hearing`||i||this.answering()||n.speaking()||this.queue.length||Date.now()-this.lastActivity<(this.waiting?e*5:e)||(t.log.add(`conversation-idle`),this.end(`idle`))},5e3))}emit(e=!1){let t=this.state,n=JSON.stringify(t);!e&&n===this.lastStateKey||(this.lastStateKey=n,this.options.events?.change?.(t))}};const Ve=e=>e.startsWith(`image/`)?`image`:e===`application/pdf`?`pdf`:`other`,He=({state:e,onClose:t})=>{let n=g(),r=b(null);y(()=>{r.current?.focus();let e=e=>{e.key===`Escape`&&(e.stopPropagation(),t())};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[t]);let i=e.status===`ready`?Ve(e.mimeType):`other`;return S(`div`,{class:`cf-preview`,role:`dialog`,"aria-modal":`true`,"aria-label":we(n.attachPreviewTitle,{name:e.name}),onClick:e=>{e.target===e.currentTarget&&t()},children:C(`div`,{class:`cf-preview__frame`,children:[C(`div`,{class:`cf-preview__bar`,children:[S(`span`,{class:`cf-preview__name`,title:e.name,children:e.name}),e.status===`ready`&&S(`a`,{class:`cf-preview__btn`,href:e.url,download:e.name,children:n.attachDownload}),S(`button`,{ref:r,type:`button`,class:`cf-preview__btn cf-preview__close`,"aria-label":n.attachPreviewClose,onClick:t,children:`✕`})]}),C(`div`,{class:`cf-preview__body`,children:[e.status===`loading`&&S(`p`,{class:`cf-preview__note`,children:n.attachPreviewLoading}),e.status===`error`&&S(`p`,{class:`cf-preview__note`,children:n.attachPreviewFailed}),e.status===`ready`&&i===`image`&&S(`img`,{class:`cf-preview__image`,src:e.url,alt:e.name}),e.status===`ready`&&i===`pdf`&&S(`iframe`,{class:`cf-preview__pdf`,src:e.url,title:e.name}),e.status===`ready`&&i===`other`&&S(`p`,{class:`cf-preview__note`,children:n.attachPreviewUnsupported})]})]})})},Ue=({name:e,greeting:t})=>{let n=g();return C(`section`,{class:`cf-empty-welcome`,"aria-label":we(n.welcomeLabel,{name:e}),children:[S(`span`,{class:`cf-empty-welcome__eyebrow`,children:n.welcomeEyebrow}),S(`h2`,{children:e}),S(`p`,{children:t||n.welcomePrompt})]})},We=(e,t,n)=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),n();return}if(e.key!==`Tab`)return;let r=Array.from(t.querySelectorAll(`button, [href], textarea, input, select, [tabindex]:not([tabindex="-1"])`)).filter(e=>!e.hasAttribute(`disabled`)&&e.getAttribute(`aria-hidden`)!==`true`&&e.tabIndex>=0);if(r.length===0)return;let i=t.getRootNode(),a=e.composedPath()[0],o=a instanceof HTMLElement?a:`activeElement`in i?i.activeElement:document.activeElement,s=r[0],c=r[r.length-1];e.shiftKey&&(o===s||!t.contains(o))?(e.preventDefault(),e.stopPropagation(),c.focus()):!e.shiftKey&&(o===c||!t.contains(o))&&(e.preventDefault(),e.stopPropagation(),s.focus())},D=new Map,Ge=e=>{if(!e||typeof document>`u`||typeof CanvasRenderingContext2D>`u`)return;let t=document.createElement(`canvas`).getContext(`2d`);if(!t)return;t.fillStyle=`#010203`,t.fillStyle=e;let n=t.fillStyle;if(n===`#010203`&&e.trim().toLowerCase()!==`#010203`)return;let r=n.match(/^#([\da-f]{6})$/i)?.[1];if(r)return[Number.parseInt(r.slice(0,2),16),Number.parseInt(r.slice(2,4),16),Number.parseInt(r.slice(4,6),16),1];let i=n.match(/^rgba?\(([\d.]+)[, ]+([\d.]+)[, ]+([\d.]+)(?:[, /]+([\d.]+))?\)$/i);if(!i)return;let a=i.slice(1,5).map(Number);if(!a.some(e=>!Number.isFinite(e)))return[a[0],a[1],a[2],a[3]??1]},Ke=(e,t=`#ffffff`)=>{let n=`${e??``}|${t}`;if(D.has(n))return D.get(n);let r=Ge(e),i=Ge(t)??[255,255,255,1];if(!r){D.set(n,void 0);return}let a=r[3],o=r.slice(0,3).map((e,t)=>e*a+i[t]*(1-a)).map(e=>{let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}),s=o[0]*.2126+o[1]*.7152+o[2]*.0722,c=1.05/(s+.05)>=(s+.05)/.059?`#ffffff`:`#0f1e2a`;return D.set(n,c),c},qe=e=>{let[t,n]=x(`light`);return y(()=>{if(e!==`auto`||typeof matchMedia>`u`)return;let t=matchMedia(`(prefers-color-scheme: dark)`),r=()=>n(t.matches?`dark`:`light`);return r(),t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[e]),e===`auto`?t:e},Je=[`mute`,`end`,`minimize`,`expand`,`shrink`,`wait`,`resume`],Ye=({transport:o,config:l,bindControls:ue,composerDraftStore:me})=>{let u=l.strings,[d,be]=x(l.openByDefault),{persona:f,messages:p,sending:m,assistantSpeaking:h,visitor:Te,hasEmail:Ee,liveMode:g,assignedAgentName:Oe,agentTypingName:ke,starters:_,featuredLinks:Pe,send:w,sendGif:Re,notifyTyping:ze,stop:T,voiceForms:E,voiceReply:Ve,duckSpeaking:D,retry:Ge,rateMessage:Ye,doubleCheckResponse:Xe,retryResponse:Ze,rateExplanation:Qe,explanationTransport:O,injectAssistant:$e,reconnectSupport:et,appendUserDraft:tt,patchMessage:k,removeMessage:nt,submitCsat:rt,submitForm:it,confirmHostedBooking:at,transcribe:ot,liveVoice:st,delegateVoice:ct,setLiveSpeaking:lt,uploadAttachment:ut,loadAttachment:dt,searchGifs:ft,demoSlots:pt,gifEnabled:mt,identify:ht,ended:A,endConversation:gt,startNew:_t,history:vt,viewingSessionId:yt,viewMessages:bt,openConversation:xt,closeHistoryView:St,shutdown:Ct,stopSpeaking:j,speakAssistantText:wt,analyticsModels:Tt,analyticsModelId:Et,selectAnalyticsModel:Dt}=Se(o,l,d),Ot=ge(p,g),[kt,At]=x(null),jt=b(0),Mt=v((e,t,n)=>{n===jt.current&&At({status:`ready`,name:t,url:URL.createObjectURL(e),mimeType:e.type||`application/octet-stream`})},[]),Nt=v((e,t,n)=>{let r=t.name,i=++jt.current;At({status:`loading`,name:r}),dt(e,t,n).then(e=>Mt(e,r,i),()=>{i===jt.current&&At({status:`error`,name:r})})},[dt,Mt]),Pt=v((e,t)=>Mt(e,t,++jt.current),[Mt]),Ft=v(()=>{jt.current+=1,At(null)},[]);y(()=>()=>{kt?.status===`ready`&&URL.revokeObjectURL(kt.url)},[kt]);let It=!!De(f?.actions),[M,Lt]=x(0),[Rt,zt]=x(null),Bt=ee(Rt),[N,Vt]=x({mic:`off`,processing:!1}),[Ht,Ut]=x(null),[Wt,Gt]=x(!1),[P,Kt]=x(!1),[qt,Jt]=x(!1),[Yt,Xt]=x(!1),[Zt,Qt]=x(0),[F,I]=x(!1),[$t,L]=x(null),[en,tn]=x(null),[nn,rn]=x([]),[an,on]=x(``),[sn,cn]=x(()=>{try{return localStorage.getItem(`centrinfo:muted`)===`1`}catch{return!1}}),ln=qe(l.theme),un=f?.soundEnabled??!0;y(()=>{ye(l.sound&&un&&!sn)},[l.sound,un,sn]);let dn=v(()=>{cn(e=>{let t=!e;try{localStorage.setItem(`centrinfo:muted`,t?`1`:`0`)}catch{}return t})},[]),R=b(null),fn=b(null),pn=b(null),mn=b(0),z=b(!1),B=b(!1),V=b(null),H=b(0),hn=b(void 0),gn=b(0),U=b(null),W=b(``),_n=b(()=>{}),vn=b(``),yn=b(m),bn=b(w);bn.current=w;let xn=b(ot);xn.current=ot;let Sn=b(Ve);Sn.current=Ve;let Cn=b({liveVoice:st,delegateVoice:ct,messages:p});Cn.current={liveVoice:st,delegateVoice:ct,messages:p};let wn=b(``);wn.current=[...p].reverse().find(e=>e.role===`assistant`&&e.content.trim())?.content??``;let Tn=b(h);yn.current=m||E.busy,Tn.current=h;let En=P?Wt?`timeout`:Yt||N.mic===`muted`?`muted`:N.mic===`unavailable`?N.reason===`permission-denied`||N.reason===`unsupported`?`denied`:`unavailable`:N.mic===`off`||N.mic===`starting`?`connecting`:N.mic===`hearing`?`hearing`:h?`speaking`:Bt.waiting?`waiting`:Ht??(N.processing||m||E.busy?`processing`:`listening`):`idle`;y(()=>{E.setEnabled(P&&qt&&!A&&!yt&&g===`ai`,V.current?.voiceEngine?.usingLiveAudio)},[E,P,qt,A,yt,g]);let[Dn,On]=x(!0),[kn,An]=x(!1),jn=b(!0);jn.current=Dn;let[G,Mn]=x(!1),[K,q]=x(!1),[J,Y]=x(!1),Nn=b({value:``}),Pn=me??Nn.current,Fn=b({confirmEnd:G,confirmClear:K,showHistory:J});Fn.current={confirmEnd:G,confirmClear:K,showHistory:J};let[In,Ln]=x(!1),X=!!yt,Rn=X?bt:p,zn=Rn.find(e=>e.id===$t&&e.visualization)?.visualization,Bn=Rn.find(e=>e.id===en&&e.visualization);y(()=>{!en||Bn||(tn(null),I(!1))},[en,Bn]),y(()=>{!$t||zn||(L(null),I(!1))},[zn,$t]);let Vn=v(()=>{be(!0),Lt(0),Ce(`open`),l.onOpen?.(),l.onShow?.()},[l]),Z=v(()=>{be(!1),I(!1),L(null),l.onClose?.(),l.onHide?.(),fn.current?.focus()},[l]),Hn=v(()=>d?Z():Vn(),[d,Vn,Z]),Un=v(()=>Mn(!0),[]),Wn=v(()=>{gt(),Mn(!1)},[gt]),Gn=v(()=>{_t(),An(!1),On(!0)},[_t]);y(()=>{ue({open:Vn,close:Z,toggle:Hn,identify:ht,startNew:_t,endConversation:gt,shutdown:Ct})},[ue,Vn,Z,Hn,ht,_t,gt,Ct]),y(()=>{let e=p.filter(e=>e.role===`assistant`&&!e.pending).length;if(d){mn.current=e;return}e>mn.current&&Lt(e-mn.current)},[p,d]),y(()=>{l.onUnreadChange?.(M)},[M,l]),y(()=>{let e=l.sessionDurationMinutes;if(!e||e<=0)return;let t=setTimeout(()=>Ct(),e*60*1e3);return()=>clearTimeout(t)},[l.sessionDurationMinutes,p,d,Ct]),y(()=>{let e=l.customLauncherSelector;if(!e||typeof document>`u`)return;let t=[];try{t=Array.from(document.querySelectorAll(e))}catch{return}let n=e=>{e.preventDefault(),Hn()};return t.forEach(e=>e.addEventListener(`click`,n)),()=>t.forEach(e=>e.removeEventListener(`click`,n))},[l.customLauncherSelector,Hn]);let Kn=b(!1);y(()=>{let e=l.proactiveMessage?.trim();if(!e||Kn.current)return;let t=l.proactiveOnPaths??[],n=typeof location<`u`?location.pathname:``;if(t.length>0&&!t.some(e=>n.includes(e)))return;let r=`centrinfo:proactive:${l.token.slice(0,12)}`;try{if(sessionStorage.getItem(r)===`1`)return}catch{}let i=setTimeout(()=>{if(!(d||A||p.some(e=>e.role===`user`))){Kn.current=!0;try{sessionStorage.setItem(r,`1`)}catch{}$e(e),Vn()}},Math.max(0,l.proactiveDelaySeconds)*1e3);return()=>clearTimeout(i)},[l.proactiveMessage]),y(()=>{let e=pn.current;if(!d||!e)return;let t=p[p.length-1];if(!P&&t?.role===`user`||Dn){let t=requestAnimationFrame(()=>{jn.current&&(e.scrollTop=e.scrollHeight)});return An(!1),()=>cancelAnimationFrame(t)}else An(!0)},[p,d,m,Dn,P]),y(()=>{let e=pn.current;if(!(!d||!e))return Le(e,{isAtBottom:()=>jn.current,onUnseen:()=>An(!0)})},[d,X]);let qn=v(()=>{let e=pn.current;if(!e)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight<80;jn.current=t,On(t),t&&An(!1)},[]),Jn=v(()=>{let e=pn.current;e&&(e.scrollTop=e.scrollHeight),jn.current=!0,An(!1),On(!0)},[]),Yn=v(()=>{R.current?.querySelector(`.cf-textarea`)?.focus()},[]),Xn=v((e,t)=>{Ut(e),hn.current&&window.clearTimeout(hn.current),hn.current=window.setTimeout(()=>Ut(null),3e3),t&&!B.current&&wt(t)},[wt]),Zn=v(e=>{let t=U.current;if(t)return t;let n=tt(e);return U.current=n,k(n,{content:W.current||e,pending:!0,streaming:!1}),n},[tt,k]),Qn=v(()=>{let e=U.current;if(e){if(W.current){k(e,{content:W.current,pending:!0});return}U.current=null,nt(e)}},[k,nt]),Q=v(()=>{z.current&&T(),z.current=!1;let e=V.current;V.current=null,e?.end(`user`),B.current=!1;let t=U.current;U.current=null,W.current=``,t&&nt(t),hn.current&&window.clearTimeout(hn.current),Ut(null),Gt(!1),Vt({mic:`off`,processing:!1}),zt(null),Qt(0),Kt(!1),Jt(!1),Xt(!1),I(!1),L(null),j()},[nt,T,j]),$n=v(()=>{F&&L(null),I(!F)},[F]),er=v(e=>{L(e),I(!0)},[]),tr=v(e=>{tn(e),I(!0)},[]),nr=v(()=>{let e=$t,t=en;L(null),tn(null),I(!1),window.requestAnimationFrame(()=>{(t?R.current?.querySelector(`[data-explanation-message="${t}"]`)?.querySelector(`[data-testid="analytics-explanation-expand"]`):Array.from(R.current?.querySelectorAll(`[data-visualization-message]`)??[]).find(t=>t.dataset.visualizationMessage===e))?.focus()})},[$t,en]),rr=v(()=>{L(null),tn(null),I(!1)},[]),ir=v((e,t,n=!1)=>{t&&(k(t,{content:e,pending:!1,streaming:!1}),U.current===t&&(U.current=null)),W.current=``,z.current&&(T(),j(),!E.handleTranscript(e,t)&&bn.current(e,{forceVoicePlayback:!0,userMessageId:t,voiceWaiting:n,onVoiceControl:e=>V.current?.control(e)}))},[k,T,j,E]),ar=v(({overAnswer:e})=>{H.current=Date.now(),Ut(null),e||Zn(u.voiceDraftListening)},[Zn,u.voiceDraftListening]),or=v(e=>{let t=U.current;t&&k(t,{content:`${[W.current,e].filter(Boolean).join(` `)} ...`,pending:!0})},[k]),sr=v(e=>{H.current=Date.now();let t=Zn(e);return k(t,{content:e,pending:!0}),U.current===t&&(U.current=null),W.current=``,t},[Zn,k]),cr=v(({reason:e,heldSomething:t,overlappedOutput:n})=>{H.current=Date.now(),Qn(),!t&&(e===`unusable`?Xn(`misunderstood`):e===`transcribe-failed`&&!n&&Xn(`misunderstood`,`I couldn't transcribe that. Please try again, or type your question.`))},[Qn,Xn]),$=b({speechStart:ar,partial:or,heard:sr,dropped:cr,deliver:ir,stop:T,stopSpeaking:j,duckSpeaking:D});$.current={speechStart:ar,partial:or,heard:sr,dropped:cr,deliver:ir,stop:T,stopSpeaking:j,duckSpeaking:D};let lr=v(()=>{navigator.mediaDevices?.enumerateDevices().then(e=>{rn(e.filter(e=>e.kind===`audioinput`).map((e,t)=>({deviceId:e.deviceId,label:e.label||we(l.strings.microphoneNumbered,{number:String(t+1)})})))}).catch(()=>{})},[l]),ur=v(()=>{if(z.current){Q();return}if(Yn(),!f?.allowVoiceInput||!f.talkbackMode||f.talkbackMode===`text`||yn.current||A||X)return;H.current=Date.now(),B.current=!1,z.current=!0,Xt(!1),Kt(!0),Jt(!1),Gt(!1);let e=!1,t=new Be({chat:{busy:()=>yn.current||Sn.current.status===`answering`,speaking:()=>Tn.current,lastAnswer:()=>wn.current,deliver:(e,t,n)=>$.current.deliver(e,t,n.waiting),cancel:()=>$.current.stop(),silence:()=>$.current.stopSpeaking(),duck:e=>$.current.duckSpeaking(e)},live:Cn.current.liveVoice?{transport:(e,t)=>Cn.current.liveVoice(e,t),delegate:async(e,t,n)=>(H.current=Date.now(),Cn.current.delegateVoice(e,t,n)),context:()=>Cn.current.messages.slice(-8).map(e=>`${e.role}: ${e.content}`).join(`
|
|
2
|
+
`)}:void 0,deviceId:vn.current||void 0,transcribe:async({audio:e,mimeType:t,durationSeconds:n})=>{let r=typeof navigator<`u`&&(navigator.languages?.[0]||navigator.language)||void 0;return fe(await xn.current(e,t,r,n))},screen:Ae,controls:Je,progress:{language:()=>l.locale},idleLimitMs:0,events:{change:n=>{if(V.current!==t)return;let r=n.mic;zt(n),B.current=n.muted,Xt(n.muted),Vt(r),r.mic!==`starting`&&r.mic!==`off`&&Jt(!0),!e&&r.mic===`listening`&&(e=!0,lr())},ended:()=>{V.current===t&&Q()},liveSpeaking:lt,control:e=>_n.current(e),speechStart:e=>$.current.speechStart(e),partial:e=>$.current.partial(e),heard:e=>$.current.heard(e),dropped:e=>$.current.dropped(e),level:e=>{let t=performance.now();t-gn.current<90||(gn.current=t,Qt(e))}}});V.current=t,t.start()},[l.locale,Q,A,Yn,f,lr,X,lt]),dr=v(()=>{let e=!B.current;B.current=e,Xt(e);let t=V.current?.voiceEngine?.snapshot.processing;V.current?.setMuted(e),e&&!t?(W.current=``,Qn()):e||(H.current=Date.now())},[Qn]),fr=v(e=>{switch(H.current=Date.now(),e){case`minimize`:Z();break;case`expand`:I(!0);break;case`shrink`:L(null),I(!1);break}},[Z]);y(()=>{_n.current=fr},[fr]);let pr=v(e=>{vn.current=e,on(e),V.current?.selectDevice(e||void 0)},[]),mr=v(()=>{!z.current||B.current||(V.current?.interrupt(),H.current=Date.now())},[]);y(()=>{V.current?.sync(),H.current=Date.now()},[h]),y(()=>{V.current?.sync()},[m,E.busy,Ve]),y(()=>{if(En!==`denied`)return;let e=window.setTimeout(()=>Q(),3500);return()=>window.clearTimeout(e)},[Q,En]),y(()=>{if(!P)return;let e=window.setInterval(()=>{let e=V.current?.voiceEngine;!e||(V.current?.state.queued.length??0)>0||B.current||yn.current||Tn.current||e.snapshot.mic===`hearing`||e.snapshot.processing||Date.now()-H.current<6e4||(e.log.add(`call-timeout`),Gt(!0),window.setTimeout(()=>Q(),2400))},5e3);return()=>window.clearInterval(e)},[Q,P]);let hr=P&&!Yt&&(m||h);y(()=>()=>Q(),[Q]);let[gr,_r]=x(``),vr=b(!1);y(()=>{if(vr.current&&!m){let e=[...p].reverse().find(e=>e.role===`assistant`&&!e.streaming&&!e.pending&&e.content);e&&_r(e.content)}vr.current=m},[m,p]),Fe(()=>{if(!d)return;let e=R.current,t=G||K?e?.querySelector(`.cf-confirm__card`):J?e?.querySelector(`.cf-history`):null;if(!t)return;let n=t.getRootNode(),r=`activeElement`in n?n.activeElement:document.activeElement;(!r||!t.contains(r))&&t.querySelector(`button, [href], textarea, input, [tabindex]:not([tabindex="-1"])`)?.focus()},[K,G,d,J]),y(()=>{if(!d)return;let e=R.current,t=G||K?e?.querySelector(`.cf-confirm__card`):J?e?.querySelector(`.cf-history`):null,n=e?.querySelectorAll(`:scope > .cf-header, :scope > .cf-panel__video, :scope > .cf-panel__chat`);n?.forEach(e=>{t?(e.setAttribute(`inert`,``),e.setAttribute(`aria-hidden`,`true`)):(e.removeAttribute(`inert`),e.removeAttribute(`aria-hidden`))}),t||requestAnimationFrame(()=>e?.querySelector(`.cf-textarea`)?.focus());let r=n=>{if(n.key===`Escape`){n.preventDefault();let t=Fn.current;if(t.confirmEnd){Mn(!1);return}if(t.confirmClear){q(!1);return}if(t.showHistory){Y(!1);return}if(e?.querySelector(`.cf-action-drawer`))return;Z();return}if(n.key!==`Tab`||!t)return;let r=t.querySelectorAll(`button, [href], textarea, input, [tabindex]:not([tabindex="-1"])`),i=Array.from(r).filter(e=>!e.hasAttribute(`disabled`));if(i.length===0)return;let a=i[0],o=i[i.length-1],s=t.getRootNode()instanceof ShadowRoot?t.getRootNode().activeElement:document.activeElement;n.shiftKey&&s===a?(n.preventDefault(),o.focus()):!n.shiftKey&&s===o&&(n.preventDefault(),a.focus())};return e?.addEventListener(`keydown`,r),()=>{e?.removeEventListener(`keydown`,r),n?.forEach(e=>{e.removeAttribute(`inert`),e.removeAttribute(`aria-hidden`)})}},[d,Z,G,K,J]),y(()=>{let e=R.current;e&&(d?e.removeAttribute(`inert`):e.setAttribute(`inert`,``))},[d]);let yr=l.accentColor??l.themeTokens?.accent??f?.accentColor,br=l.themeTokens?.accentText??Ke(yr,l.themeTokens?.background??(ln===`dark`?`#0f1c27`:`#ffffff`)),xr={zIndex:l.zIndex,"--cf-h-pad":`${l.horizontalPadding}px`,"--cf-v-pad":`${l.verticalPadding}px`,...br?{"--cf-accent-ink":br}:{},...l.themeTokens?.accentStrong?{"--cf-accent-2":l.themeTokens.accentStrong}:{},...l.themeTokens?.background?{"--cf-bg":l.themeTokens.background}:{},...l.themeTokens?.surface?{"--cf-surface":l.themeTokens.surface}:{},...l.themeTokens?.surfaceMuted?{"--cf-surface-2":l.themeTokens.surfaceMuted}:{},...l.themeTokens?.text?{"--cf-text":l.themeTokens.text}:{},...l.themeTokens?.mutedText?{"--cf-muted":l.themeTokens.mutedText}:{},...l.themeTokens?.border?{"--cf-border":l.themeTokens.border}:{},...l.themeTokens?.shadow?{"--cf-shadow":l.themeTokens.shadow}:{},...l.themeTokens?.radius?{"--cf-radius":l.themeTokens.radius}:{},...l.themeTokens?.fontFamily?{"--cf-font":l.themeTokens.fontFamily}:{},...l.themeTokens?.success?{"--cf-success":l.themeTokens.success}:{},...l.themeTokens?.warning?{"--cf-warning":l.themeTokens.warning}:{},...l.themeTokens?.danger?{"--cf-danger":l.themeTokens.danger}:{},...yr?{"--cf-accent":yr,"--cf-accent-2":l.themeTokens?.accentStrong??`color-mix(in oklab, ${yr} 76%, #14141f)`}:{}},Sr=e=>w(e),Cr=[...p].reverse().find(e=>e.role===`user`&&e.content.trim())?.content??``,wr=p.some(e=>e.role===`user`),Tr=!!(f?.allowVoiceInput&&f?.talkbackMode&&f.talkbackMode!==`text`),Er=!X&&Tr&&!wr?Rn.filter((e,t)=>!(t===0&&e.role===`assistant`)):Rn,Dr=g===`human`&&Oe?Oe:f?.agentName??u.chatName,Or=g===`human`?u.liveSupport:g===`queued`?u.waitingForTeam:f?.offline?u.statusOffline:u.statusOnline,kr=!A&&!X?f?.availableActions:void 0,Ar=!A&&!X?f?.actions:void 0,jr=P&&!qt&&En===`connecting`&&!X;return S(_e,{value:u,children:S(s,{value:E,children:S(e,{value:l.locale,children:C(`div`,{class:`cf-root`,dir:l.dir,"data-theme":ln,"data-align":l.alignment,"data-display":`floating`,style:xr,children:[F&&d&&S(`div`,{class:`cf-theater-backdrop`,onClick:rr}),C(`div`,{ref:R,class:`cf-panel ${d?`is-open`:``} ${P?`cf-panel--call`:``} ${jr?`cf-panel--voice-connecting`:``} ${F&&d?`cf-panel--theater`:``} ${zn||Bn?`cf-panel--analytics-focus`:``}`,role:`dialog`,"aria-modal":`false`,"aria-label":`${u.chatName}: ${f?.agentName??u.assistantName}`,"aria-hidden":!d,children:[kt&&d&&S(He,{state:kt,onClose:Ft}),C(`div`,{class:`cf-header`,children:[S(he,{persona:f,hideWhenMissing:!0}),C(`div`,{class:`cf-header__meta`,children:[S(`div`,{class:`cf-header__name`,children:Dr}),l.token.startsWith(`pub_test_`)?S(`small`,{role:`status`,children:u.testMode}):null,S(`div`,{class:`cf-header__status ${g===`ai`&&f?.offline?`cf-header__status--offline`:``}`,children:S(`span`,{class:`cf-header__status-text`,children:Or})})]}),C(`div`,{class:`cf-header__actions`,children:[vt.length>0&&S(`button`,{type:`button`,class:`cf-header__btn`,"aria-label":u.pastConversations,title:u.pastConversations,"aria-pressed":J,onClick:()=>Y(e=>!e),children:S(c,{})}),wr&&!A&&!X&&S(`button`,{type:`button`,class:`cf-header__btn`,"aria-label":u.endChat,title:u.endChat,onClick:Un,children:S(a,{})}),l.sound&&un&&S(`button`,{type:`button`,class:`cf-header__btn`,"aria-label":sn?u.unmuteSounds:u.muteSounds,"aria-pressed":sn,onClick:dn,children:S(sn?te:oe,{})}),S(`button`,{type:`button`,class:`cf-header__btn cf-header__close`,"aria-label":u.closeChat,onClick:Z,children:S(ae,{})})]})]}),S(`div`,{class:`cf-panel__video`,children:zn?S(`div`,{class:`cf-analytics-focus`,role:`region`,"aria-label":u.expandedAnalyticsResult,children:S(t,{visualization:zn,explanationTransport:X?void 0:O(`widget`),onExplanationFeedback:X?void 0:Qe,onOpenAnalyticsSource:l.onOpenAnalyticsSource,expanded:!0,onFollowUp:e=>{nr(),w(e)},onClose:nr})}):Bn?.visualization?S(`div`,{class:`cf-analytics-focus`,role:`region`,"aria-label":u.expandedAnalyticsResult,children:S(xe,{visualization:Bn.visualization,onClose:nr,onFollowUp:e=>{nr(),w(e)},onFeedback:X?void 0:Qe,transport:X?void 0:O(`widget`),onOpenSource:l.onOpenAnalyticsSource})}):!X&&Tr?S(se,{persona:f,starters:[],onPick:w,onFocusComposer:ur,speaking:h,voiceState:En,replyPending:P&&m&&!h,pinned:!0,muted:Yt,onToggleMute:dr,onEndCall:Q,onTalkNow:mr,showTalkNow:hr,micLevel:Zt,theaterMode:F,onToggleTheater:$n,onMinimize:Z,audioDevices:nn,selectedAudioDeviceId:an,onSelectAudioDevice:pr,connectingOnly:jr,answerStillComing:Bt.answerStillComing,stillWorking:Bt.stillWorking,onResume:()=>V.current?.resume()}):null}),!jr&&C(`div`,{class:`cf-panel__chat`,children:[l.preview&&S(`div`,{class:`cf-preview-banner`,children:u.previewBanner}),X&&S(`div`,{class:`cf-viewing-banner`,children:u.viewingPast}),C(`div`,{class:`cf-body`,ref:pn,role:`log`,onScroll:qn,children:[Er.map((e,t)=>S(i,{msg:e,persona:f,isLast:!X&&t===Er.length-1,visitor:Te,hasEmail:Ee,lastQuestion:Cr,showActions:!X&&t===Er.length-1&&!!(e.handoffOffered||e.selectedAction),onPickReply:Sr,onSubmitForm:it,onDemoSlots:pt,onConfirmHostedBooking:at,onRetry:Ge,ratable:!X&&Er.slice(0,t).some(e=>e.role===`user`),onRate:Ye,onDoubleCheck:X||A?void 0:Xe,onRetryResponse:X||A||g!==`ai`?void 0:Ze,doubleCheckDisabled:m,onExplanationFeedback:X?void 0:Qe,explanationTransport:X?void 0:O(`widget`),onOpenAnalyticsSource:l.onOpenAnalyticsSource,onExpandVisualization:X?void 0:er,onExpandExplanation:X?void 0:tr,onOpenAttachment:Nt,onReconnect:!X&&!A&&It&&e.id===Ot?et:void 0},e.id)),!wr&&!X&&C(Ie,{children:[Er.length===0&&S(Ue,{name:f?.agentName??u.assistantName,greeting:f?.greeting}),S(ie,{items:_,onPick:w}),S(je,{items:Pe})]}),kn&&C(`button`,{type:`button`,class:`cf-newmsg`,onClick:Jn,children:[S(ne,{}),u.newMessages]})]}),S(`div`,{class:`cf-sr-live`,"aria-live":`polite`,"aria-atomic":`true`,children:gr}),m&&!A&&!X&&S(`div`,{class:`cf-stopbar`,children:C(`button`,{type:`button`,class:`cf-stop`,onClick:T,children:[S(Ne,{}),u.stop]})}),X?S(`div`,{class:`cf-ended`,children:S(`button`,{type:`button`,class:`cf-ended__btn`,onClick:St,children:u.backToChat})}):A?C(`div`,{class:`cf-ended`,children:[S(`p`,{class:`cf-ended__text`,children:u.conversationEnded}),l.csat&&wr?In?S(`p`,{class:`cf-ended__text`,children:u.feedbackThanks}):C(`div`,{class:`cf-csat`,children:[S(`span`,{class:`cf-csat__q`,children:u.csatPrompt}),S(`button`,{type:`button`,class:`cf-csat__btn`,"aria-label":u.feedbackHelpful,onClick:()=>{rt(`up`),Ln(!0)},children:S(le,{})}),S(`button`,{type:`button`,class:`cf-csat__btn`,"aria-label":u.feedbackNotHelpful,onClick:()=>{rt(`down`),Ln(!0)},children:S(n,{})})]}):null,S(`button`,{type:`button`,class:`cf-ended__btn`,onClick:Gn,children:u.startNewChat})]}):C(Ie,{children:[ke?S(`div`,{class:`cf-live-typing`,"aria-live":`polite`,children:we(u.agentTyping,{name:ke})}):null,kr&&kr.length>0&&S(`div`,{class:`cf-footer-actions`,children:S(Me,{actions:kr,descriptors:Ar,visitor:Te,onSubmitForm:it,onDemoSlots:pt,onConfirmHostedBooking:at,scheduler:f?.scheduler,translations:l.actionTranslations})},`footer-actions`),S(r,{toolbarContent:l.showAnalyticsModelSelector?S(de,{models:Tt,value:Et,onChange:Dt,disabled:m}):null,draftStore:Pn,onSend:w,onSendGif:Re,onTyping:ze,disabled:m,allowVoice:!1,onTranscribe:ot,gifEnabled:mt,onSearchGifs:ft,allowAttach:l.attachments,analyzeAttachments:!0,onUpload:ut,onPreviewAttachment:Pt},`composer`)]}),!A&&f?.disclaimerText&&S(`div`,{class:`cf-disclaimer`,children:f.disclaimerText}),C(`div`,{class:`cf-footer`,children:[S(`button`,{type:`button`,class:`cf-footer__privacy`,"aria-label":u.clearDeviceData,onClick:()=>q(!0),children:u.privacyAndData}),S(`span`,{"aria-hidden":`true`,children:`·`}),u.poweredBy,` `,S(`a`,{href:`https://accurixtech.com/centrinfo`,target:`_blank`,rel:`noopener noreferrer`,children:`Centrinfo`})]})]}),G&&S(`div`,{class:`cf-confirm`,onClick:()=>Mn(!1),children:C(`div`,{class:`cf-confirm__card`,role:`alertdialog`,"aria-modal":`true`,"aria-label":u.endChatConfirm,onClick:e=>e.stopPropagation(),onKeyDownCapture:e=>We(e,e.currentTarget,()=>Mn(!1)),children:[S(`div`,{class:`cf-confirm__title`,children:u.endChatConfirm}),S(`div`,{class:`cf-confirm__body`,children:u.endChatConfirmBody}),C(`div`,{class:`cf-confirm__actions`,children:[S(`button`,{type:`button`,class:`cf-confirm__btn cf-confirm__btn--cancel`,onClick:()=>Mn(!1),children:u.cancel}),S(`button`,{type:`button`,class:`cf-confirm__btn cf-confirm__btn--danger`,onClick:Wn,children:u.endConfirmCta})]})]})},`confirm-end`),J&&S(`div`,{class:`cf-confirm`,onClick:()=>Y(!1),children:C(`div`,{class:`cf-history`,role:`dialog`,"aria-modal":`true`,"aria-label":u.pastConversations,onClick:e=>e.stopPropagation(),onKeyDownCapture:e=>We(e,e.currentTarget,()=>Y(!1)),children:[C(`div`,{class:`cf-history__head`,children:[S(`span`,{children:u.pastConversations}),S(`button`,{type:`button`,class:`cf-header__btn`,"aria-label":u.closeHistory,onClick:()=>Y(!1),children:S(ae,{})})]}),S(`div`,{class:`cf-history__list`,children:vt.map(e=>C(`button`,{type:`button`,class:`cf-history__item ${e.sessionId===yt?`is-active`:``}`,onClick:()=>{xt(e.sessionId),Y(!1)},children:[S(`span`,{class:`cf-history__title`,children:e.title}),C(`span`,{class:`cf-history__meta`,children:[ve(e.ts,l.locale,{month:`short`,day:`numeric`}),e.ended?` · ${u.historyEnded}`:``]})]},e.sessionId))}),S(`div`,{class:`cf-history__footer`,children:S(`button`,{type:`button`,class:`cf-history__clear`,onClick:()=>{Y(!1),q(!0)},children:u.clearDeviceData})})]})},`history`),K&&S(`div`,{class:`cf-confirm`,onClick:()=>q(!1),children:C(`div`,{class:`cf-confirm__card`,role:`alertdialog`,"aria-modal":`true`,"aria-label":u.clearDeviceData,onClick:e=>e.stopPropagation(),onKeyDownCapture:e=>We(e,e.currentTarget,()=>q(!1)),children:[S(`div`,{class:`cf-confirm__title`,children:u.clearDeviceData}),S(`div`,{class:`cf-confirm__body`,children:u.clearDeviceDataBody}),C(`div`,{class:`cf-confirm__actions`,children:[S(`button`,{type:`button`,class:`cf-confirm__btn cf-confirm__btn--cancel`,onClick:()=>q(!1),children:u.cancel}),S(`button`,{type:`button`,class:`cf-confirm__btn cf-confirm__btn--danger`,onClick:()=>{q(!1),Ct()},children:u.clearDeviceDataCta})]})]})},`confirm-clear`)]}),P&&!d?S(ce,{persona:f,voiceState:En,muted:Yt,onToggleMute:dr,onEndCall:Q,micLevel:Zt,onExpand:Vn}):F&&d?null:!l.hideDefaultLauncher&&C(`button`,{ref:fn,type:`button`,class:`cf-launcher`,"aria-label":d?u.closeChat:M>0?`${u.openChat}. ${we(pe(l.locale,M,u.unreadMessage,u.unreadMessages),{count:String(M)})}`:u.openChat,"aria-expanded":d,onClick:Hn,children:[l.launcherIcon?S(`img`,{class:`cf-launcher__img`,src:l.launcherIcon,alt:``}):S(re,{}),!d&&M>0&&S(`span`,{class:`cf-launcher__badge`,"aria-hidden":`true`,children:M>99?`99+`:M})]})]})})})})},Xe=`centrinfo-widget`;var Ze=class extends HTMLElement{constructor(...e){super(...e),_(this,`controls`,null),_(this,`composerDraftStore`,{value:``}),_(this,`input`,null),_(this,`resolved`,null),_(this,`transport`,null),_(this,`localeRequest`,0),_(this,`localeAbort`,void 0),_(this,`automaticLocale`,void 0)}mountWith(e){let t=me(e);this.input=e,this.resolved=t;let n=this.shadowRoot??this.attachShadow({mode:`open`});if(this.style.zIndex=String(t.zIndex),`adoptedStyleSheets`in Document.prototype&&typeof CSSStyleSheet<`u`&&typeof CSSStyleSheet.prototype.replaceSync==`function`){let e=new CSSStyleSheet;e.replaceSync(ke),n.adoptedStyleSheets=[e]}else{let e=document.createElement(`style`);t.styleNonce&&(e.nonce=t.styleNonce),e.textContent=ke,n.appendChild(e)}this.transport=p(t),t.autoTranslate&&this.transport.loadUITranslations&&!t.demo&&!t.preview&&(this.automaticLocale=u(this.transport.loadUITranslations.bind(this.transport))),this.renderApp(),this.applyLocale()}renderApp(){let e=this.shadowRoot,t=this.resolved,n=this.transport;!e||!t||!n||Pe(S(Oe,{value:t.analyticsRenderer===`local`?void 0:d(t.apiBaseUrl,t.workspaceUrl),children:S(Ye,{transport:n,config:t,bindControls:e=>this.controls=e,composerDraftStore:this.composerDraftStore})}),e)}async applyLocale(){let e=this.input;if(!e||!this.resolved)return;this.localeAbort?.abort();let t=new AbortController;this.localeAbort=t;let n=++this.localeRequest,r=h(e),i=f(r).locale,a=await m(i);if(n!==this.localeRequest||!this.resolved||this.input!==e||(Object.assign(this.resolved,f(r,a)),this.renderApp(),!this.automaticLocale))return;let o={};for(let e of[`widget`,`results`,`viewer`])this.automaticLocale.load({namespace:e,locale:i,signal:t.signal,onCatalog:i=>{if(t.signal.aborted||n!==this.localeRequest||!this.resolved)return;o[e]=i;let s={widget:Te(a.widget,o.widget),results:Te(a.results,o.results,{viewerMessages:o.viewer??{}})};Object.assign(this.resolved,f(r,s)),this.renderApp()}})}setLocale(e){return this.input?(this.input={...this.input,...e.locale===void 0?{}:{locale:e.locale},...e.dir===void 0?{}:{dir:e.dir},...e.strings?{strings:{...this.input.strings,...e.strings}}:{}},this.applyLocale()):Promise.resolve()}open(){this.controls?.open()}close(){this.controls?.close()}toggle(){this.controls?.toggle()}identify(e){this.controls?.identify(e)}clear(){this.controls?.startNew()}shutdown(){this.controls?.shutdown()}unmount(){this.localeAbort?.abort(),this.localeRequest+=1,this.resolved=null,this.shadowRoot&&Pe(null,this.shadowRoot)}disconnectedCallback(){this.localeAbort?.abort()}};typeof customElements<`u`&&!customElements.get(Xe)&&customElements.define(Xe,Ze);const Qe=(e,t=document.body)=>{if(typeof document>`u`)throw Error(`[centrinfo-widget] createWidget must run in a browser.`);let n=document.createElement(Xe);return n.style.pointerEvents=`none`,n.style.position=`fixed`,n.style.inset=`0`,n.style.width=`0`,n.style.height=`0`,t.appendChild(n),n.mountWith(e),{open:()=>n.open(),close:()=>n.close(),toggle:()=>n.toggle(),show:()=>n.open(),hide:()=>n.close(),identify:e=>n.identify(e),update:e=>n.identify(e),clear:()=>n.clear(),shutdown:()=>n.shutdown(),logout:()=>n.shutdown(),setLocale:e=>n.setLocale(e),destroy:()=>{n.unmount(),n.remove()}}},O=e=>Qe(e);let $e=null;const et=e=>{$e?.destroy();let t=O(e);return $e=t,t},tt={init:et,createWidget:O};export{tt as Centrinfo,be as SDK_LANGUAGES,O as createWidget,et as init};
|