@bryancheru/chat-widget 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +361 -0
- package/dist/App.d.ts +6 -0
- package/dist/App.d.ts.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3282 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +6 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +65 -0
package/README.md
ADDED
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
# @imaralogic/chat-widget
|
|
2
|
+
|
|
3
|
+
AI-powered chat widget for customer engagement and lead capture. Built with React, designed for seamless integration with Next.js, React, and other frameworks.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @imaralogic/chat-widget react react-dom
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
### Next.js (App Router)
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
// app/components/ChatWidget.tsx
|
|
17
|
+
'use client';
|
|
18
|
+
|
|
19
|
+
import { ChatWidget } from '@imaralogic/chat-widget';
|
|
20
|
+
import '@imaralogic/chat-widget/styles.css';
|
|
21
|
+
import { useUser } from '@auth0/nextjs-auth0/client'; // Optional
|
|
22
|
+
|
|
23
|
+
export function ImaraChat() {
|
|
24
|
+
const { user, isLoading } = useUser(); // Optional: for user context
|
|
25
|
+
|
|
26
|
+
if (isLoading) return null;
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<ChatWidget
|
|
30
|
+
config={{
|
|
31
|
+
apiKey: process.env.NEXT_PUBLIC_IMARA_API_KEY!,
|
|
32
|
+
botName: 'Support Assistant',
|
|
33
|
+
theme: 'dark',
|
|
34
|
+
primaryColor: '#06b6d4',
|
|
35
|
+
|
|
36
|
+
// Optional: Pass user context
|
|
37
|
+
userContext: user ? {
|
|
38
|
+
userId: user.sub,
|
|
39
|
+
email: user.email,
|
|
40
|
+
name: user.name,
|
|
41
|
+
} : undefined,
|
|
42
|
+
|
|
43
|
+
// Quick action buttons
|
|
44
|
+
quickActions: [
|
|
45
|
+
{ label: 'Get Started', text: 'How do I get started?' },
|
|
46
|
+
{ label: 'Pricing', text: 'Tell me about pricing' },
|
|
47
|
+
],
|
|
48
|
+
}}
|
|
49
|
+
/>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
```tsx
|
|
55
|
+
// app/layout.tsx
|
|
56
|
+
import { ImaraChat } from './components/ChatWidget';
|
|
57
|
+
|
|
58
|
+
export default function RootLayout({ children }) {
|
|
59
|
+
return (
|
|
60
|
+
<html>
|
|
61
|
+
<body>
|
|
62
|
+
{children}
|
|
63
|
+
<ImaraChat />
|
|
64
|
+
</body>
|
|
65
|
+
</html>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### React (Vite/CRA)
|
|
71
|
+
|
|
72
|
+
```tsx
|
|
73
|
+
// App.tsx
|
|
74
|
+
import { ChatWidget } from '@imaralogic/chat-widget';
|
|
75
|
+
import '@imaralogic/chat-widget/styles.css';
|
|
76
|
+
|
|
77
|
+
function App() {
|
|
78
|
+
return (
|
|
79
|
+
<div>
|
|
80
|
+
<ChatWidget
|
|
81
|
+
config={{
|
|
82
|
+
apiKey: import.meta.env.VITE_IMARA_API_KEY,
|
|
83
|
+
botName: 'Support Bot',
|
|
84
|
+
theme: 'light',
|
|
85
|
+
}}
|
|
86
|
+
/>
|
|
87
|
+
</div>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Configuration
|
|
93
|
+
|
|
94
|
+
### Complete Config Example
|
|
95
|
+
|
|
96
|
+
```tsx
|
|
97
|
+
<ChatWidget
|
|
98
|
+
config={{
|
|
99
|
+
// Required
|
|
100
|
+
apiKey: 'your-api-key',
|
|
101
|
+
|
|
102
|
+
// Branding
|
|
103
|
+
botName: 'Your Bot Name',
|
|
104
|
+
theme: 'dark', // 'light' | 'dark'
|
|
105
|
+
primaryColor: '#06b6d4',
|
|
106
|
+
accentColor: '#2563eb',
|
|
107
|
+
headerSubtitle: 'Online โข Replies instantly',
|
|
108
|
+
|
|
109
|
+
// Initial message
|
|
110
|
+
initialMessage: 'Welcome! How can I help you today?',
|
|
111
|
+
|
|
112
|
+
// Quick actions (buttons above input)
|
|
113
|
+
quickActions: [
|
|
114
|
+
{ label: 'Get Started', text: 'How do I get started?' },
|
|
115
|
+
{ label: 'Pricing', text: 'What are your prices?' },
|
|
116
|
+
{ label: 'Demo', text: 'Schedule a demo' },
|
|
117
|
+
],
|
|
118
|
+
|
|
119
|
+
// User context (for personalization)
|
|
120
|
+
userContext: {
|
|
121
|
+
userId: 'user-123',
|
|
122
|
+
email: 'user@example.com',
|
|
123
|
+
name: 'John Doe',
|
|
124
|
+
isSubscribed: true,
|
|
125
|
+
plan: 'pro',
|
|
126
|
+
metadata: {
|
|
127
|
+
company: 'Acme Inc',
|
|
128
|
+
role: 'admin',
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
|
|
132
|
+
// Features
|
|
133
|
+
enableYouTubeEmbed: true,
|
|
134
|
+
|
|
135
|
+
// Proactive popup
|
|
136
|
+
proactivePopup: {
|
|
137
|
+
enabled: true,
|
|
138
|
+
delay: 5000, // 5 seconds
|
|
139
|
+
message: '๐ Need help? Chat with us!',
|
|
140
|
+
},
|
|
141
|
+
|
|
142
|
+
// Booking integration (Cal.com)
|
|
143
|
+
booking: {
|
|
144
|
+
enabled: true,
|
|
145
|
+
calLink: 'your-username/30min',
|
|
146
|
+
buttonText: 'Schedule a Call',
|
|
147
|
+
triggerKeywords: ['demo', 'call', 'meeting'],
|
|
148
|
+
},
|
|
149
|
+
|
|
150
|
+
// Page rules
|
|
151
|
+
pageRules: {
|
|
152
|
+
showOnPages: ['/pricing', '/contact'],
|
|
153
|
+
hideOnPages: ['/admin', '/login'],
|
|
154
|
+
},
|
|
155
|
+
|
|
156
|
+
// Event callback
|
|
157
|
+
onEvent: (event) => {
|
|
158
|
+
console.log('Widget event:', event);
|
|
159
|
+
|
|
160
|
+
if (event.type === 'lead:created') {
|
|
161
|
+
// Track in analytics
|
|
162
|
+
analytics.track('Lead Captured', event.data);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (event.type === 'intent:subscribe') {
|
|
166
|
+
// Redirect to pricing
|
|
167
|
+
window.location.href = '/pricing';
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
}}
|
|
171
|
+
/>
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Events
|
|
175
|
+
|
|
176
|
+
Listen to widget events:
|
|
177
|
+
|
|
178
|
+
```tsx
|
|
179
|
+
<ChatWidget
|
|
180
|
+
config={{
|
|
181
|
+
apiKey: 'your-key',
|
|
182
|
+
onEvent: (event) => {
|
|
183
|
+
switch (event.type) {
|
|
184
|
+
case 'chat:opened':
|
|
185
|
+
console.log('Chat opened');
|
|
186
|
+
break;
|
|
187
|
+
|
|
188
|
+
case 'chat:closed':
|
|
189
|
+
console.log('Chat closed, messages:', event.messageCount);
|
|
190
|
+
break;
|
|
191
|
+
|
|
192
|
+
case 'lead:created':
|
|
193
|
+
console.log('Lead captured:', event.data);
|
|
194
|
+
// { email, phone, name }
|
|
195
|
+
break;
|
|
196
|
+
|
|
197
|
+
case 'message:sent':
|
|
198
|
+
console.log('User sent:', event.message);
|
|
199
|
+
break;
|
|
200
|
+
|
|
201
|
+
case 'message:received':
|
|
202
|
+
console.log('Bot replied:', event.message);
|
|
203
|
+
break;
|
|
204
|
+
|
|
205
|
+
case 'intent:subscribe':
|
|
206
|
+
// User expressed interest in subscribing
|
|
207
|
+
window.location.href = '/pricing';
|
|
208
|
+
break;
|
|
209
|
+
|
|
210
|
+
case 'intent:booking':
|
|
211
|
+
// User wants to book a call
|
|
212
|
+
console.log('Cal.com link:', event.calLink);
|
|
213
|
+
break;
|
|
214
|
+
|
|
215
|
+
case 'error':
|
|
216
|
+
console.error('Widget error:', event.message);
|
|
217
|
+
break;
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
}}
|
|
221
|
+
/>
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
## Styling
|
|
225
|
+
|
|
226
|
+
The widget includes default styles via `styles.css`. For custom styling:
|
|
227
|
+
|
|
228
|
+
```tsx
|
|
229
|
+
// Import default styles
|
|
230
|
+
import '@imaralogic/chat-widget/styles.css';
|
|
231
|
+
|
|
232
|
+
// Override with custom CSS
|
|
233
|
+
import './custom-widget-styles.css';
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
```css
|
|
237
|
+
/* custom-widget-styles.css */
|
|
238
|
+
#imara-chatbot-root {
|
|
239
|
+
/* Widget container customization */
|
|
240
|
+
}
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
## TypeScript
|
|
244
|
+
|
|
245
|
+
Full TypeScript support included:
|
|
246
|
+
|
|
247
|
+
```tsx
|
|
248
|
+
import type { ChatBotConfig, ImaraEvent } from '@imaralogic/chat-widget';
|
|
249
|
+
|
|
250
|
+
const config: ChatBotConfig = {
|
|
251
|
+
apiKey: 'your-key',
|
|
252
|
+
theme: 'dark',
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
function handleEvent(event: ImaraEvent) {
|
|
256
|
+
// Fully typed event handling
|
|
257
|
+
}
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
## TradePilot AI Example
|
|
261
|
+
|
|
262
|
+
```tsx
|
|
263
|
+
'use client';
|
|
264
|
+
|
|
265
|
+
import { useUser } from '@auth0/nextjs-auth0/client';
|
|
266
|
+
import { ChatWidget } from '@imaralogic/chat-widget';
|
|
267
|
+
import '@imaralogic/chat-widget/styles.css';
|
|
268
|
+
|
|
269
|
+
export function TradeCopilot() {
|
|
270
|
+
const { user, isLoading } = useUser();
|
|
271
|
+
|
|
272
|
+
return (
|
|
273
|
+
<ChatWidget
|
|
274
|
+
config={{
|
|
275
|
+
apiKey: process.env.NEXT_PUBLIC_IMARA_API_KEY!,
|
|
276
|
+
|
|
277
|
+
// Branding
|
|
278
|
+
botName: 'TradePilot AI Chatbot',
|
|
279
|
+
theme: 'dark',
|
|
280
|
+
primaryColor: '#06b6d4',
|
|
281
|
+
accentColor: '#2563eb',
|
|
282
|
+
headerSubtitle: 'Online โข Replies instantly',
|
|
283
|
+
|
|
284
|
+
// Trading bot specific greeting
|
|
285
|
+
initialMessage: `Welcome to TradePilot AI! I'm TradeCopilot...`,
|
|
286
|
+
|
|
287
|
+
// Quick actions for traders
|
|
288
|
+
quickActions: [
|
|
289
|
+
{ label: "I'm new to this", text: "I'm a beginner - which bot should I start with?" },
|
|
290
|
+
{ label: 'Show examples', text: 'Show me performance examples' },
|
|
291
|
+
{ label: 'Lifetime vs Monthly', text: 'Why choose lifetime over monthly?' },
|
|
292
|
+
{ label: 'Risk protection', text: 'How do I protect against losses?' },
|
|
293
|
+
],
|
|
294
|
+
|
|
295
|
+
// User context from Auth0
|
|
296
|
+
userContext: user ? {
|
|
297
|
+
userId: user.sub,
|
|
298
|
+
email: user.email,
|
|
299
|
+
name: user.name,
|
|
300
|
+
isSubscribed: !!(user['https://tradepilotai.com/subscription']),
|
|
301
|
+
plan: user['https://tradepilotai.com/subscription']?.plan,
|
|
302
|
+
} : undefined,
|
|
303
|
+
|
|
304
|
+
// Features
|
|
305
|
+
enableYouTubeEmbed: true,
|
|
306
|
+
proactivePopup: {
|
|
307
|
+
enabled: true,
|
|
308
|
+
delay: 5000,
|
|
309
|
+
message: '๐ฌ Chat with TradeCopilot',
|
|
310
|
+
},
|
|
311
|
+
|
|
312
|
+
// Track events
|
|
313
|
+
onEvent: (event) => {
|
|
314
|
+
if (event.type === 'intent:subscribe') {
|
|
315
|
+
window.location.href = '/trading-bots#pricing';
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
if (event.type === 'lead:created') {
|
|
319
|
+
window.gtag?.('event', 'lead_captured', {
|
|
320
|
+
event_category: 'chat',
|
|
321
|
+
event_label: 'imara_chatbot',
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
},
|
|
325
|
+
}}
|
|
326
|
+
/>
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
## Getting Your API Key
|
|
332
|
+
|
|
333
|
+
1. Sign up at [imaralogic.co.ke](https://imaralogic.co.ke)
|
|
334
|
+
2. Navigate to Settings โ API Keys
|
|
335
|
+
3. Create a new API key for your domain
|
|
336
|
+
4. Add to your environment variables:
|
|
337
|
+
|
|
338
|
+
```bash
|
|
339
|
+
# .env.local (Next.js)
|
|
340
|
+
NEXT_PUBLIC_IMARA_API_KEY=your_api_key_here
|
|
341
|
+
|
|
342
|
+
# .env (Vite)
|
|
343
|
+
VITE_IMARA_API_KEY=your_api_key_here
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
## Browser Support
|
|
347
|
+
|
|
348
|
+
- Chrome (last 2 versions)
|
|
349
|
+
- Firefox (last 2 versions)
|
|
350
|
+
- Safari (last 2 versions)
|
|
351
|
+
- Edge (last 2 versions)
|
|
352
|
+
|
|
353
|
+
## License
|
|
354
|
+
|
|
355
|
+
MIT
|
|
356
|
+
|
|
357
|
+
## Support
|
|
358
|
+
|
|
359
|
+
- Documentation: [imaralogic.co.ke/docs](https://imaralogic.co.ke/docs)
|
|
360
|
+
- Email: support@imaralogic.co.ke
|
|
361
|
+
- GitHub Issues: [github.com/imaralogic/chat-widget](https://github.com/imaralogic/chat-widget)
|
package/dist/App.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../src/App.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAe,MAAM,QAAQ,CAAC;AA+NpD,MAAM,CAAC,OAAO,UAAU,GAAG,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,aAAa,CAAA;CAAE,2CAu0BhE"}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("react");function o(e){var t,r,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var s=e.length;for(t=0;t<s;t++)e[t]&&(r=o(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}const r=e=>{const t=l(e),{conflictingClassGroups:o,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{const o=e.split("-");return""===o[0]&&1!==o.length&&o.shift(),n(o,t)||a(e)},getConflictingClassGroupIds:(e,t)=>{const n=o[e]||[];return t&&r[e]?[...n,...r[e]]:n}}},n=(e,t)=>{var o;if(0===e.length)return t.classGroupId;const r=e[0],s=t.nextPart.get(r),a=s?n(e.slice(1),s):void 0;if(a)return a;if(0===t.validators.length)return;const l=e.join("-");return null==(o=t.validators.find(({validator:e})=>e(l)))?void 0:o.classGroupId},s=/^\[(.+)\]$/,a=e=>{if(s.test(e)){const t=s.exec(e)[1],o=null==t?void 0:t.substring(0,t.indexOf(":"));if(o)return"arbitrary.."+o}},l=e=>{const{theme:t,prefix:o}=e,r={nextPart:new Map,validators:[]};return u(Object.entries(e.classGroups),o).forEach(([e,o])=>{i(o,r,e,t)}),r},i=(e,t,o,r)=>{e.forEach(e=>{if("string"==typeof e){return void((""===e?t:c(t,e)).classGroupId=o)}if("function"==typeof e)return d(e)?void i(e(r),t,o,r):void t.validators.push({validator:e,classGroupId:o});Object.entries(e).forEach(([e,n])=>{i(n,c(t,e),o,r)})})},c=(e,t)=>{let o=e;return t.split("-").forEach(e=>{o.nextPart.has(e)||o.nextPart.set(e,{nextPart:new Map,validators:[]}),o=o.nextPart.get(e)}),o},d=e=>e.isThemeGetter,u=(e,t)=>t?e.map(([e,o])=>[e,o.map(e=>"string"==typeof e?t+e:"object"==typeof e?Object.fromEntries(Object.entries(e).map(([e,o])=>[t+e,o])):e)]):e,p=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,o=new Map,r=new Map;const n=(n,s)=>{o.set(n,s),t++,t>e&&(t=0,r=o,o=new Map)};return{get(e){let t=o.get(e);return void 0!==t?t:void 0!==(t=r.get(e))?(n(e,t),t):void 0},set(e,t){o.has(e)?o.set(e,t):n(e,t)}}},g=e=>{const{separator:t,experimentalParseClassName:o}=e,r=1===t.length,n=t[0],s=t.length,a=e=>{const o=[];let a,l=0,i=0;for(let u=0;u<e.length;u++){let c=e[u];if(0===l){if(c===n&&(r||e.slice(u,u+s)===t)){o.push(e.slice(i,u)),i=u+s;continue}if("/"===c){a=u;continue}}"["===c?l++:"]"===c&&l--}const c=0===o.length?e:e.substring(i),d=c.startsWith("!");return{modifiers:o,hasImportantModifier:d,baseClassName:d?c.substring(1):c,maybePostfixModifierPosition:a&&a>i?a-i:void 0}};return o?e=>o({className:e,parseClassName:a}):a},b=e=>{if(e.length<=1)return e;const t=[];let o=[];return e.forEach(e=>{"["===e[0]?(t.push(...o.sort(),e),o=[]):o.push(e)}),t.push(...o.sort()),t},m=/\s+/;function h(){let e,t,o=0,r="";for(;o<arguments.length;)(e=arguments[o++])&&(t=f(e))&&(r&&(r+=" "),r+=t);return r}const f=e=>{if("string"==typeof e)return e;let t,o="";for(let r=0;r<e.length;r++)e[r]&&(t=f(e[r]))&&(o&&(o+=" "),o+=t);return o};function x(e,...t){let o,n,s,a=function(i){const c=t.reduce((e,t)=>t(e),e());return o=(e=>({cache:p(e.cacheSize),parseClassName:g(e),...r(e)}))(c),n=o.cache.get,s=o.cache.set,a=l,l(i)};function l(e){const t=n(e);if(t)return t;const r=((e,t)=>{const{parseClassName:o,getClassGroupId:r,getConflictingClassGroupIds:n}=t,s=[],a=e.trim().split(m);let l="";for(let i=a.length-1;i>=0;i-=1){const e=a[i],{modifiers:t,hasImportantModifier:c,baseClassName:d,maybePostfixModifierPosition:u}=o(e);let p=Boolean(u),g=r(p?d.substring(0,u):d);if(!g){if(!p){l=e+(l.length>0?" "+l:l);continue}if(g=r(d),!g){l=e+(l.length>0?" "+l:l);continue}p=!1}const m=b(t).join(":"),h=c?m+"!":m,f=h+g;if(s.includes(f))continue;s.push(f);const x=n(g,p);for(let o=0;o<x.length;++o){const e=x[o];s.push(h+e)}l=e+(l.length>0?" "+l:l)}return l})(e,o);return s(e,r),r}return function(){return a(h.apply(null,arguments))}}const y=e=>{const t=t=>t[e]||[];return t.isThemeGetter=!0,t},v=/^\[(?:([a-z-]+):)?(.+)\]$/i,w=/^\d+\/\d+$/,k=new Set(["px","full","screen"]),j=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,C=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,N=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,S=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,z=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,I=e=>E(e)||k.has(e)||w.test(e),L=e=>$(e,"length",U),E=e=>Boolean(e)&&!Number.isNaN(Number(e)),M=e=>$(e,"number",E),A=e=>Boolean(e)&&Number.isInteger(Number(e)),R=e=>e.endsWith("%")&&E(e.slice(0,-1)),T=e=>v.test(e),G=e=>j.test(e),P=new Set(["length","size","percentage"]),_=e=>$(e,P,Z),O=e=>$(e,"position",Z),B=new Set(["image","url"]),q=e=>$(e,B,K),D=e=>$(e,"",H),W=()=>!0,$=(e,t,o)=>{const r=v.exec(e);return!!r&&(r[1]?"string"==typeof t?r[1]===t:t.has(r[1]):o(r[2]))},U=e=>C.test(e)&&!N.test(e),Z=()=>!1,H=e=>S.test(e),K=e=>z.test(e),Y=x(()=>{const e=y("colors"),t=y("spacing"),o=y("blur"),r=y("brightness"),n=y("borderColor"),s=y("borderRadius"),a=y("borderSpacing"),l=y("borderWidth"),i=y("contrast"),c=y("grayscale"),d=y("hueRotate"),u=y("invert"),p=y("gap"),g=y("gradientColorStops"),b=y("gradientColorStopPositions"),m=y("inset"),h=y("margin"),f=y("opacity"),x=y("padding"),v=y("saturate"),w=y("scale"),k=y("sepia"),j=y("skew"),C=y("space"),N=y("translate"),S=()=>["auto",T,t],z=()=>[T,t],P=()=>["",I,L],B=()=>["auto",E,T],$=()=>["","0",T],U=()=>[E,T];return{cacheSize:500,separator:":",theme:{colors:[W],spacing:[I,L],blur:["none","",G,T],brightness:U(),borderColor:[e],borderRadius:["none","","full",G,T],borderSpacing:z(),borderWidth:P(),contrast:U(),grayscale:$(),hueRotate:U(),invert:$(),gap:z(),gradientColorStops:[e],gradientColorStopPositions:[R,L],inset:S(),margin:S(),opacity:U(),padding:z(),saturate:U(),scale:U(),sepia:$(),skew:U(),space:z(),translate:z()},classGroups:{aspect:[{aspect:["auto","square","video",T]}],container:["container"],columns:[{columns:[G]}],"break-after":[{"break-after":["auto","avoid","all","avoid-page","page","left","right","column"]}],"break-before":[{"break-before":["auto","avoid","all","avoid-page","page","left","right","column"]}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top",T]}],overflow:[{overflow:["auto","hidden","clip","visible","scroll"]}],"overflow-x":[{"overflow-x":["auto","hidden","clip","visible","scroll"]}],"overflow-y":[{"overflow-y":["auto","hidden","clip","visible","scroll"]}],overscroll:[{overscroll:["auto","contain","none"]}],"overscroll-x":[{"overscroll-x":["auto","contain","none"]}],"overscroll-y":[{"overscroll-y":["auto","contain","none"]}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[m]}],"inset-x":[{"inset-x":[m]}],"inset-y":[{"inset-y":[m]}],start:[{start:[m]}],end:[{end:[m]}],top:[{top:[m]}],right:[{right:[m]}],bottom:[{bottom:[m]}],left:[{left:[m]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",A,T]}],basis:[{basis:S()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",T]}],grow:[{grow:$()}],shrink:[{shrink:$()}],order:[{order:["first","last","none",A,T]}],"grid-cols":[{"grid-cols":[W]}],"col-start-end":[{col:["auto",{span:["full",A,T]},T]}],"col-start":[{"col-start":B()}],"col-end":[{"col-end":B()}],"grid-rows":[{"grid-rows":[W]}],"row-start-end":[{row:["auto",{span:[A,T]},T]}],"row-start":[{"row-start":B()}],"row-end":[{"row-end":B()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",T]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",T]}],gap:[{gap:[p]}],"gap-x":[{"gap-x":[p]}],"gap-y":[{"gap-y":[p]}],"justify-content":[{justify:["normal","start","end","center","between","around","evenly","stretch"]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal","start","end","center","between","around","evenly","stretch","baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":["start","end","center","between","around","evenly","stretch","baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[x]}],px:[{px:[x]}],py:[{py:[x]}],ps:[{ps:[x]}],pe:[{pe:[x]}],pt:[{pt:[x]}],pr:[{pr:[x]}],pb:[{pb:[x]}],pl:[{pl:[x]}],m:[{m:[h]}],mx:[{mx:[h]}],my:[{my:[h]}],ms:[{ms:[h]}],me:[{me:[h]}],mt:[{mt:[h]}],mr:[{mr:[h]}],mb:[{mb:[h]}],ml:[{ml:[h]}],"space-x":[{"space-x":[C]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[C]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",T,t]}],"min-w":[{"min-w":[T,t,"min","max","fit"]}],"max-w":[{"max-w":[T,t,"none","full","min","max","fit","prose",{screen:[G]},G]}],h:[{h:[T,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[T,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[T,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[T,t,"auto","min","max","fit"]}],"font-size":[{text:["base",G,L]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",M]}],"font-family":[{font:[W]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",T]}],"line-clamp":[{"line-clamp":["none",E,M]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",I,T]}],"list-image":[{"list-image":["none",T]}],"list-style-type":[{list:["none","disc","decimal",T]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[f]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[f]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:["solid","dashed","dotted","double","none","wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",I,L]}],"underline-offset":[{"underline-offset":["auto",I,T]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:z()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",T]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",T]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[f]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top",O]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",_]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},q]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[b]}],"gradient-via-pos":[{via:[b]}],"gradient-to-pos":[{to:[b]}],"gradient-from":[{from:[g]}],"gradient-via":[{via:[g]}],"gradient-to":[{to:[g]}],rounded:[{rounded:[s]}],"rounded-s":[{"rounded-s":[s]}],"rounded-e":[{"rounded-e":[s]}],"rounded-t":[{"rounded-t":[s]}],"rounded-r":[{"rounded-r":[s]}],"rounded-b":[{"rounded-b":[s]}],"rounded-l":[{"rounded-l":[s]}],"rounded-ss":[{"rounded-ss":[s]}],"rounded-se":[{"rounded-se":[s]}],"rounded-ee":[{"rounded-ee":[s]}],"rounded-es":[{"rounded-es":[s]}],"rounded-tl":[{"rounded-tl":[s]}],"rounded-tr":[{"rounded-tr":[s]}],"rounded-br":[{"rounded-br":[s]}],"rounded-bl":[{"rounded-bl":[s]}],"border-w":[{border:[l]}],"border-w-x":[{"border-x":[l]}],"border-w-y":[{"border-y":[l]}],"border-w-s":[{"border-s":[l]}],"border-w-e":[{"border-e":[l]}],"border-w-t":[{"border-t":[l]}],"border-w-r":[{"border-r":[l]}],"border-w-b":[{"border-b":[l]}],"border-w-l":[{"border-l":[l]}],"border-opacity":[{"border-opacity":[f]}],"border-style":[{border:["solid","dashed","dotted","double","none","hidden"]}],"divide-x":[{"divide-x":[l]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[l]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[f]}],"divide-style":[{divide:["solid","dashed","dotted","double","none"]}],"border-color":[{border:[n]}],"border-color-x":[{"border-x":[n]}],"border-color-y":[{"border-y":[n]}],"border-color-s":[{"border-s":[n]}],"border-color-e":[{"border-e":[n]}],"border-color-t":[{"border-t":[n]}],"border-color-r":[{"border-r":[n]}],"border-color-b":[{"border-b":[n]}],"border-color-l":[{"border-l":[n]}],"divide-color":[{divide:[n]}],"outline-style":[{outline:["","solid","dashed","dotted","double","none"]}],"outline-offset":[{"outline-offset":[I,T]}],"outline-w":[{outline:[I,L]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:P()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[f]}],"ring-offset-w":[{"ring-offset":[I,L]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",G,D]}],"shadow-color":[{shadow:[W]}],opacity:[{opacity:[f]}],"mix-blend":[{"mix-blend":["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity","plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"]}],filter:[{filter:["","none"]}],blur:[{blur:[o]}],brightness:[{brightness:[r]}],contrast:[{contrast:[i]}],"drop-shadow":[{"drop-shadow":["","none",G,T]}],grayscale:[{grayscale:[c]}],"hue-rotate":[{"hue-rotate":[d]}],invert:[{invert:[u]}],saturate:[{saturate:[v]}],sepia:[{sepia:[k]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[o]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[i]}],"backdrop-grayscale":[{"backdrop-grayscale":[c]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[d]}],"backdrop-invert":[{"backdrop-invert":[u]}],"backdrop-opacity":[{"backdrop-opacity":[f]}],"backdrop-saturate":[{"backdrop-saturate":[v]}],"backdrop-sepia":[{"backdrop-sepia":[k]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[a]}],"border-spacing-x":[{"border-spacing-x":[a]}],"border-spacing-y":[{"border-spacing-y":[a]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",T]}],duration:[{duration:U()}],ease:[{ease:["linear","in","out","in-out",T]}],delay:[{delay:U()}],animate:[{animate:["none","spin","ping","pulse","bounce",T]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[w]}],"scale-x":[{"scale-x":[w]}],"scale-y":[{"scale-y":[w]}],rotate:[{rotate:[A,T]}],"translate-x":[{"translate-x":[N]}],"translate-y":[{"translate-y":[N]}],"skew-x":[{"skew-x":[j]}],"skew-y":[{"skew-y":[j]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",T]}],accent:[{accent:["auto",e]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",T]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":z()}],"scroll-mx":[{"scroll-mx":z()}],"scroll-my":[{"scroll-my":z()}],"scroll-ms":[{"scroll-ms":z()}],"scroll-me":[{"scroll-me":z()}],"scroll-mt":[{"scroll-mt":z()}],"scroll-mr":[{"scroll-mr":z()}],"scroll-mb":[{"scroll-mb":z()}],"scroll-ml":[{"scroll-ml":z()}],"scroll-p":[{"scroll-p":z()}],"scroll-px":[{"scroll-px":z()}],"scroll-py":[{"scroll-py":z()}],"scroll-ps":[{"scroll-ps":z()}],"scroll-pe":[{"scroll-pe":z()}],"scroll-pt":[{"scroll-pt":z()}],"scroll-pr":[{"scroll-pr":z()}],"scroll-pb":[{"scroll-pb":z()}],"scroll-pl":[{"scroll-pl":z()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",T]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[I,L,M]}],stroke:[{stroke:[e,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}}),F=()=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z"})}),J=({size:t=20})=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M18 6 6 18"}),e.jsx("path",{d:"m6 6 12 12"})]}),V=()=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"m22 2-7 20-4-9-9-4Z"}),e.jsx("path",{d:"M22 2 11 13"})]}),Q=()=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"m12 3-1.912 5.813a2 2 0 0 1-1.275 1.275L3 12l5.813 1.912a2 2 0 0 1 1.275 1.275L12 21l1.912-5.813a2 2 0 0 1 1.275-1.275L21 12l-5.813-1.912a2 2 0 0 1-1.275-1.275L12 3Z"}),e.jsx("path",{d:"M5 3v4"}),e.jsx("path",{d:"M3 5h4"}),e.jsx("path",{d:"M19 17v4"}),e.jsx("path",{d:"M17 19h4"})]}),X=({filled:t})=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:t?"currentColor":"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M7 10v12"}),e.jsx("path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2h0a3.13 3.13 0 0 1 3 3.88Z"})]}),ee=({filled:t})=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:t?"currentColor":"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M17 14V2"}),e.jsx("path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22h0a3.13 3.13 0 0 1-3-3.88Z"})]});function te(...e){return Y(function(){for(var e,t,r=0,n="",s=arguments.length;r<s;r++)(e=arguments[r])&&(t=o(e))&&(n&&(n+=" "),n+=t);return n}(e))}function oe(e){const t=[/(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([a-zA-Z0-9_-]{11})/,/youtube\.com\/shorts\/([a-zA-Z0-9_-]{11})/];for(const o of t){const t=e.match(o);if(t)return t[1]}return null}function re({videoId:t}){return e.jsx("div",{className:"mt-2 rounded-lg overflow-hidden aspect-video",children:e.jsx("iframe",{width:"100%",height:"100%",src:`https://www.youtube.com/embed/${t}?rel=0`,title:"YouTube video",frameBorder:"0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,className:"w-full h-full"})})}function ne({content:o,enableYouTube:r,isDark:n}){const s=t.useMemo(()=>{if(!r)return[{type:"text",content:o}];const e=/(https?:\/\/[^\s]+)/g,t=[];let n,s=0;for(;null!==(n=e.exec(o));){n.index>s&&t.push({type:"text",content:o.slice(s,n.index)});const e=n[0],r=oe(e);r?t.push({type:"youtube",content:e,videoId:r}):t.push({type:"link",content:e}),s=n.index+e.length}return s<o.length&&t.push({type:"text",content:o.slice(s)}),t.length>0?t:[{type:"text",content:o}]},[o,r]);return e.jsx(e.Fragment,{children:s.map((t,o)=>"youtube"===t.type&&t.videoId?e.jsx(re,{videoId:t.videoId},o):"link"===t.type?e.jsx("a",{href:t.content,target:"_blank",rel:"noopener noreferrer",className:te("underline",n?"text-cyan-400 hover:text-cyan-300":"text-blue-600 hover:text-blue-800"),children:t.content},o):e.jsx("span",{children:t.content},o))})}const se=[{label:"๐ Save Time",text:"I am looking to save time by automating customer support."},{label:"๐ฐ Get More Leads",text:"I want to get more qualified leads. Show me the sales features."},{label:"๐ฌ WhatsApp Demo",text:"I want to see how the WhatsApp integration works."}];function ae({calLink:e,onClose:o,prefill:r}){return t.useEffect(()=>{const t=document.createElement("script");t.src="https://app.cal.com/embed/embed.js",t.async=!0,t.onload=()=>{const t=window.Cal;if(t){t("init",{origin:"https://cal.com"});let o=e;const n=new URLSearchParams;(null==r?void 0:r.name)&&n.append("name",r.name),(null==r?void 0:r.email)&&n.append("email",r.email);const s=n.toString();s&&(o+=(o.includes("?")?"&":"?")+s),t("modal",{calLink:o,config:{layout:"month_view"}})}},document.head.appendChild(t);const n=e=>{var t;"CAL:bookingSuccessful"===(null==(t=e.data)?void 0:t.type)&&(console.log("Booking successful:",e.data),o())};return window.addEventListener("message",n),()=>{document.head.removeChild(t),window.removeEventListener("message",n);const e=window.Cal;if(e)try{e("close")}catch{}}},[e,r,o]),null}exports.ChatWidget=function({config:o}){var r,n,s,a,l,i,c,d,u,p,g;const[b,m]=t.useState(!1),[h,f]=t.useState(!1),[x,y]=t.useState([]),[v,w]=t.useState(""),[k,j]=t.useState(!1),[C,N]=t.useState(!1),[S,z]=t.useState(!1),[I,L]=t.useState((null==(r=o.preChatForm)?void 0:r.enabled)??!1),[E,M]=t.useState({}),[A,R]=t.useState(null),T=t.useRef(null),[G,P]=t.useState(""),_=t.useRef(null),O=t.useRef(null),B=t.useCallback((e,t)=>{const o={type:e,timestamp:(new Date).toISOString(),...t};window.__imaraEmitEvent&&window.__imaraEmitEvent(o)},[]);t.useEffect(()=>{b&&B("chat:opened")},[b,B]);const q=t.useRef(0);t.useEffect(()=>{q.current=x.length},[x.length]);const D="dark"===o.theme,W=o.primaryColor||(D?"#06b6d4":"#000000"),$=t.useMemo(()=>({container:D?"bg-gray-900 ring-gray-700":"bg-white ring-black/5",header:D?"bg-gradient-to-r from-cyan-500 to-blue-600":"",headerStyle:D?{}:{backgroundColor:W},messagesArea:D?"bg-gray-950":"bg-slate-50",userMessage:D?"bg-gradient-to-r from-cyan-500 to-blue-600 text-white":"bg-slate-900 text-white",userMessageStyle:D?{}:{backgroundColor:W},botMessage:D?"bg-gray-800 text-gray-100":"bg-white text-slate-800",inputArea:D?"border-gray-700 bg-gray-900":"border-slate-100 bg-white",input:D?"border-gray-700 bg-gray-800 text-gray-100 placeholder:text-gray-500 focus:border-cyan-500":"border-slate-200 bg-slate-50 focus:border-slate-400",quickAction:D?"border-gray-700 bg-gray-800 text-gray-300 hover:border-cyan-500 hover:text-cyan-400 hover:bg-gray-700":"border-slate-200 bg-white text-slate-700 hover:border-purple-500 hover:text-purple-600",typingBg:D?"bg-gray-800":"bg-white",typingDot:D?"bg-cyan-400":"bg-slate-400",ratingInactive:D?"text-gray-600 hover:text-gray-400":"text-slate-300 hover:text-slate-500",footerText:D?"text-gray-500":"text-slate-400",footerLink:D?"hover:text-gray-300":"hover:text-slate-600"}),[D,W]);if(null===O.current){const e="imara_session_id";try{const t=localStorage.getItem(e);if(t)O.current=t;else{const t=crypto.randomUUID();localStorage.setItem(e,t),O.current=t}}catch{O.current=crypto.randomUUID()}}const U=o.apiUrl||"https://imara-logic.vercel.app",Z=t.useCallback(e=>{e.preventDefault(),L(!1),console.log("Pre-chat data collected:",E)},[E]),H=t.useCallback(async(e,t)=>{y(o=>o.map(o=>o.id===e?{...o,rating:t}:o));try{await fetch(`${U}/api/chat/rate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:O.current,messageId:e,rating:t,apiKey:o.apiKey})})}catch(r){console.warn("Failed to submit rating:",r)}},[U,o.apiKey]),K=`imara_messages_${o.apiKey||"demo"}`;t.useEffect(()=>{if(x.length>1)try{localStorage.setItem(K,JSON.stringify(x))}catch{}},[x,K]),t.useEffect(()=>{try{const e=localStorage.getItem(K);if(e){const t=JSON.parse(e);if(t.length>0)return void y(t)}}catch{}o.initialMessage&&y([{id:"init",role:"assistant",content:o.initialMessage}])},[]);const Y=!1!==(null==(n=o.proactivePopup)?void 0:n.enabled),oe=(null==(s=o.proactivePopup)?void 0:s.delay)??3e3,[re,le]=t.useState(""),[ie,ce]=t.useState(!1);t.useEffect(()=>{le((()=>{const e=window.location.pathname.toLowerCase(),t=window.location.hash.toLowerCase();return e.includes("pricing")||t.includes("pricing")?"Need help choosing a plan? ๐ฌ":e.includes("demo")||t.includes("demo")||t.includes("see-imara")?"Want to see Imara in action? ๐":e.includes("solution")||e.includes("industr")?"Questions about your industry? ๐ข":e.includes("contact")||e.includes("about")||t.includes("about")?"Let's chat! I'm here to help ๐":ie?"Have questions about what you've seen? ๐ค":"Curious how Imara works? โจ"})())},[ie]),t.useEffect(()=>{const e=()=>{window.scrollY/(document.documentElement.scrollHeight-window.innerHeight)*100>30&&!ie&&ce(!0)};return window.addEventListener("scroll",e,{passive:!0}),()=>window.removeEventListener("scroll",e)},[ie]);const de=(null==(a=o.proactivePopup)?void 0:a.message)||re||"Curious how Imara works? โจ";t.useEffect(()=>{if(!Y||S||b)return;const e=setTimeout(()=>{b||S||N(!0)},oe);return()=>clearTimeout(e)},[b,S,Y,oe]),t.useEffect(()=>{b&&N(!1)},[b]);const ue=t.useCallback(()=>{b&&T.current&&T.current.scrollIntoView({behavior:"smooth"})},[b]);t.useEffect(()=>{ue()},[x.length,G,ue]);const pe=t.useCallback(async(e,t=0)=>{var r;if(e.preventDefault(),!v.trim()||k)return;const n={id:Date.now().toString(),role:"user",content:v};0===t&&(y(e=>[...e,n]),w(""),B("message:sent",{message:n.content})),j(!0),R(null);const s=(Date.now()+1).toString();_.current=s,P("");const a={apiKey:o.apiKey,messages:[...x,n].map(e=>({role:e.role,content:e.content})),sessionId:O.current};o.userContext&&(a.userContext=o.userContext);try{const l=await fetch(`${U}/api/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!l.ok){const o=await l.text().catch(()=>"Unknown error");let r={};try{r=JSON.parse(o)}catch{}if(l.status>=500&&t<2)return console.warn(`[ChatBot] Retrying request (attempt ${t+2}/3)`),await new Promise(e=>setTimeout(e,1e3*(t+1))),pe(e,t+1);const n=r.error||`Request failed (${l.status})`;throw new Error(n)}if(!l.body)throw new Error("No response body");const i=l.body.getReader(),c=new TextDecoder;let d="",u="";for(;;){const{done:e,value:t}=await i.read();if(e)break;u+=c.decode(t,{stream:!0});const n=u.split("\n");u=n.pop()||"";for(const s of n){if(!s.trim())continue;const e=s.indexOf(":");if(-1===e)continue;const t=s.substring(0,e),n=s.substring(e+1);try{if("0"===t){const e=JSON.parse(n);if("string"==typeof e){if(e.includes("[TRIGGER_BOOKING]")||e.includes("[TRIGGER_CALENDLY_MODAL]")){f(!0),B("intent:booking",{calLink:null==(r=o.booking)?void 0:r.calLink});const t=e.replace("[TRIGGER_BOOKING]","").replace("[TRIGGER_CALENDLY_MODAL]","");d+=t}else e.includes("[TRIGGER_SUBSCRIBE]")?(B("intent:subscribe",{productId:void 0}),d+=e.replace("[TRIGGER_SUBSCRIBE]","")):d+=e;P(d)}}else if("e"===t){const e=JSON.parse(n);console.error("Stream error:",e),B("error",{message:e.message||"Stream error",code:"STREAM_ERROR"})}}catch{}}}y(e=>[...e,{id:s,role:"assistant",content:d}]),P(""),_.current=null,B("message:received",{message:d});const p=n.content.match(/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/),g=n.content.match(/(?:\+?1[-.\s]?)?\(?[0-9]{3}\)?[-.\s]?[0-9]{3}[-.\s]?[0-9]{4}/);(p||g)&&B("lead:created",{email:null==p?void 0:p[0],phone:null==g?void 0:g[0]})}catch(l){const e=l instanceof Error?l.message:"Unknown error";console.error("Chat error:",l),P(""),_.current=null,R(e),B("error",{message:e,code:"CHAT_ERROR"}),y(t=>[...t,{id:Date.now().toString(),role:"assistant",content:`Sorry, something went wrong: ${e}. Please try again.`}])}finally{j(!1)}},[v,k,x,U,o.apiKey,o.userContext,null==(l=o.booking)?void 0:l.calLink,B]),ge=t.useCallback(()=>{m(e=>{const t=!e;return t||B("chat:closed",{messageCount:q.current}),t})},[B]);return e.jsxs("div",{className:te("fixed bottom-4 right-4 z-[9999] font-sans",D?"text-gray-100":"text-slate-900"),children:[b&&e.jsxs("div",{className:te("mb-4 flex h-[600px] w-[380px] flex-col overflow-hidden rounded-2xl shadow-2xl ring-1 animate-chat-open",$.container),children:[e.jsxs("div",{className:te("flex items-center justify-between px-4 py-3 text-white",$.header),style:$.headerStyle,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:te("flex h-8 w-8 items-center justify-center rounded-full",D?"bg-white/20 animate-bounce":"bg-white/20"),children:D?e.jsx("span",{className:"text-lg",children:"๐ค"}):e.jsx(Q,{})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-bold",children:o.botName||"AI Assistant"}),e.jsx("p",{className:"text-xs opacity-90",children:o.headerSubtitle||"Powered by Imaralogic"})]})]}),e.jsx("button",{onClick:ge,className:"rounded-full p-1 hover:bg-white/20 transition-colors","aria-label":"Close chat",children:e.jsx(J,{size:20})})]}),I&&(null==(i=o.preChatForm)?void 0:i.fields)&&e.jsx("div",{className:"flex-1 overflow-y-auto bg-slate-50 p-4",children:e.jsxs("form",{onSubmit:Z,className:"space-y-4",children:[e.jsxs("div",{className:"text-center mb-4",children:[e.jsx("h4",{className:"text-lg font-semibold text-slate-800",children:o.preChatForm.title||"Before we chat..."}),e.jsx("p",{className:"text-sm text-slate-500",children:"Please tell us a bit about yourself"})]}),o.preChatForm.fields.map(t=>{var o;return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("label",{className:"text-sm font-medium text-slate-700",children:[t.label,t.required&&e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),"select"===t.type?e.jsxs("select",{className:"w-full rounded-lg border border-slate-200 px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-slate-900/20",required:t.required,value:E[t.name]||"",onChange:e=>M(o=>({...o,[t.name]:e.target.value})),children:[e.jsx("option",{value:"",children:t.placeholder||"Select..."}),null==(o=t.options)?void 0:o.map(t=>e.jsx("option",{value:t,children:t},t))]}):e.jsx("input",{type:t.type,className:"w-full rounded-lg border border-slate-200 px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-slate-900/20",placeholder:t.placeholder,required:t.required,value:E[t.name]||"",onChange:e=>M(o=>({...o,[t.name]:e.target.value}))})]},t.name)}),e.jsx("button",{type:"submit",className:"w-full rounded-lg py-2.5 text-sm font-semibold text-white transition-colors hover:opacity-90",style:{backgroundColor:W},children:"Start Chatting"})]})}),!I&&e.jsxs("div",{className:te("flex-1 overflow-y-auto p-4 space-y-4",$.messagesArea),children:[x.map(t=>e.jsxs("div",{className:te("flex flex-col gap-1","user"===t.role?"items-end":"items-start"),children:[e.jsx("div",{className:te("w-max max-w-[80%] rounded-2xl px-4 py-2 text-sm shadow-sm","user"===t.role?$.userMessage:$.botMessage),style:"user"===t.role?$.userMessageStyle:{},children:e.jsx(ne,{content:t.content,enableYouTube:o.enableYouTubeEmbed,isDark:D})}),"assistant"===t.role&&"init"!==t.id&&e.jsxs("div",{className:"flex items-center gap-1 mt-1 ml-1",children:[e.jsx("button",{onClick:()=>H(t.id,"positive"),className:te("p-1 rounded transition-colors","positive"===t.rating?"text-green-600":$.ratingInactive),"aria-label":"Helpful",title:"Helpful",children:e.jsx(X,{filled:"positive"===t.rating})}),e.jsx("button",{onClick:()=>H(t.id,"negative"),className:te("p-1 rounded transition-colors","negative"===t.rating?"text-red-500":$.ratingInactive),"aria-label":"Not helpful",title:"Not helpful",children:e.jsx(ee,{filled:"negative"===t.rating})})]})]},t.id)),G&&e.jsx("div",{className:te("flex w-max max-w-[80%] flex-col gap-1 rounded-2xl px-4 py-2 text-sm shadow-sm",$.botMessage),children:e.jsx(ne,{content:G,enableYouTube:o.enableYouTubeEmbed,isDark:D})}),k&&!G&&e.jsx("div",{className:te("flex w-max items-center gap-1 rounded-2xl px-4 py-3 text-sm shadow-sm",$.typingBg),children:e.jsxs("div",{className:te("typing-indicator",D&&"typing-dark"),children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]})}),e.jsx("div",{ref:T})]}),!I&&e.jsxs("form",{onSubmit:pe,className:te("p-4",$.inputArea),children:[(o.quickActions&&o.quickActions.length>0?o.quickActions:se).length>0&&e.jsx("div",{className:te("flex gap-2 overflow-x-auto pb-3 scrollbar-hide",D?"border-b border-gray-700 mb-3":"border-b border-slate-200 mb-3"),children:(o.quickActions&&o.quickActions.length>0?o.quickActions:se).map((t,o)=>e.jsx("button",{type:"button",onClick:()=>{w(t.text),setTimeout(()=>{const e=document.querySelector('input[type="text"]');null==e||e.focus()},50)},className:te("text-xs px-3 py-2 rounded-full whitespace-nowrap transition-all duration-200",D?"bg-gray-800 hover:bg-gray-700 text-gray-200 hover:scale-105":"bg-gray-100 hover:bg-gray-200 text-gray-700 hover:scale-105"),disabled:k,children:t.label},o))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{value:v,onChange:e=>w(e.target.value),placeholder:"Type a message...",className:te("flex-1 rounded-full border py-3 px-5 text-sm focus:outline-none focus:ring-2",D?"bg-gray-800 text-white border-gray-700 placeholder-gray-500 focus:ring-cyan-500":"bg-white text-slate-900 border-slate-200 placeholder-gray-400 focus:ring-blue-500")}),e.jsx("button",{type:"submit",disabled:k||!v.trim(),className:te("rounded-full p-3 transition-all duration-200 hover:scale-105 disabled:opacity-50 disabled:cursor-not-allowed text-white",D?"bg-gradient-to-r from-cyan-600 to-blue-600 hover:from-cyan-700 hover:to-blue-700 disabled:from-gray-700 disabled:to-gray-700":"disabled:bg-gray-200"),style:!D&&v.trim()?{backgroundColor:W}:void 0,"aria-label":"Send message",children:e.jsx(V,{})})]}),(null==(c=o.booking)?void 0:c.enabled)&&((null==(d=o.booking)?void 0:d.calLink)||(null==(u=o.booking)?void 0:u.calendlyUrl))&&e.jsxs("button",{type:"button",onClick:()=>f(!0),className:te("mt-2 w-full rounded-lg py-2 text-sm font-medium text-white transition-colors hover:opacity-90",D&&"bg-gradient-to-r from-cyan-500 to-blue-600"),style:D?{}:{backgroundColor:W},children:["๐
",o.booking.buttonText||"Book a Meeting"]}),e.jsxs("div",{className:te("mt-2 text-center text-[10px]",$.footerText),children:["Powered by ",e.jsx("a",{href:"https://imaralogic.co.ke?ref=widget",target:"_blank",rel:"noopener noreferrer",className:te("underline font-medium",$.footerLink),children:"Imara AI"})," ยท ",e.jsx("a",{href:"https://imaralogic.co.ke/terms",target:"_blank",rel:"noopener noreferrer",className:te("underline",$.footerLink),children:"Terms"})]})]})]}),C&&!b&&e.jsx("div",{className:"absolute bottom-16 right-0 mb-2 animate-nudge-in",children:e.jsxs("div",{className:te("relative flex items-center gap-2 rounded-full px-4 py-2.5 shadow-lg ring-1",D?"bg-gray-800 ring-gray-700":"bg-white ring-black/5"),children:[e.jsx("button",{onClick:e=>{e.stopPropagation(),N(!1),z(!0)},className:te("absolute -right-1.5 -top-1.5 flex h-5 w-5 items-center justify-center rounded-full transition-colors",D?"bg-gray-700 text-gray-400 hover:bg-gray-600 hover:text-gray-200":"bg-slate-100 text-slate-400 hover:bg-slate-200 hover:text-slate-600"),"aria-label":"Dismiss",children:e.jsx(J,{size:10})}),e.jsx("span",{className:te("flex h-6 w-6 items-center justify-center rounded-full text-white",D&&"bg-gradient-to-r from-cyan-500 to-blue-600"),style:D?{}:{backgroundColor:W},children:e.jsx(Q,{})}),e.jsx("span",{className:te("text-sm font-medium whitespace-nowrap pr-2",D?"text-gray-200":"text-slate-700"),children:de}),e.jsx("div",{className:te("absolute -bottom-1.5 right-6 h-3 w-3 rotate-45 ring-1",D?"bg-gray-800 ring-gray-700":"bg-white ring-black/5"),style:{clipPath:"polygon(100% 0, 0 100%, 100% 100%)"}})]})}),e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[!b&&!C&&e.jsx("div",{className:te("rounded-full px-3 py-1.5 text-xs font-medium shadow-lg ring-1 animate-fade-in max-w-[200px] text-center leading-tight",D?"bg-gray-800 ring-gray-700 shadow-gray-900/30":"bg-white ring-black/5 shadow-slate-900/10"),style:{color:W},children:de}),e.jsx("button",{onClick:ge,className:te("flex h-14 w-14 items-center justify-center rounded-full text-white shadow-lg transition-all duration-200 hover:scale-105 active:scale-95",C&&!b&&"animate-pulse-ring",D?"bg-gradient-to-r from-cyan-500 to-blue-600 shadow-cyan-500/30 animate-glow-pulse":"shadow-slate-900/20"),style:D?{}:{backgroundColor:W},"aria-label":b?"Close chat":"Open chat",children:b?e.jsx(J,{size:24}):e.jsx(F,{})})]}),h&&((null==(p=o.booking)?void 0:p.calLink)||(null==(g=o.booking)?void 0:g.calendlyUrl))&&e.jsx(ae,{calLink:o.booking.calLink||o.booking.calendlyUrl||"",onClose:()=>f(!1),prefill:E.email?{email:E.email,name:E.name||""}:void 0})]})};
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|