dinesh-ai-chat-widget 1.0.11 → 1.0.13

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 CHANGED
@@ -17,12 +17,21 @@ Place the widget in your `app/layout.tsx`:
17
17
  ```tsx
18
18
  import { ChatWidget } from "dinesh-ai-chat-widget";
19
19
 
20
- export default function RootLayout({ children }: { children: React.ReactNode }) {
20
+ export default function RootLayout({
21
+ children,
22
+ }: {
23
+ children: React.ReactNode;
24
+ }) {
21
25
  return (
22
26
  <html lang="en">
23
27
  <body>
24
28
  {children}
25
- <ChatWidget />
29
+ <ChatWidget
30
+ key="YOUR-API-KEY"
31
+ title="Support Assistant"
32
+ subtitle="Online · Ask us anything"
33
+ primaryColor="#2563eb"
34
+ />
26
35
  </body>
27
36
  </html>
28
37
  );
@@ -61,4 +70,4 @@ Your backend should return a JSON response with a reply:
61
70
  {
62
71
  "reply": "Hello! How can I help?"
63
72
  }
64
- ```
73
+ ```
@@ -0,0 +1,8 @@
1
+ export type ChatWidgetProps = {
2
+ key?: string;
3
+ title?: string;
4
+ subtitle?: string;
5
+ primaryColor?: string;
6
+ };
7
+ export default function ChatWidget({ key, title, subtitle, primaryColor, }: ChatWidgetProps): "" | import('react').JSX.Element;
8
+ //# sourceMappingURL=ChatWidget.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatWidget.d.ts","sourceRoot":"","sources":["../src/ChatWidget.tsx"],"names":[],"mappings":"AAEA,OAAO,eAAe,CAAC;AAYvB,MAAM,MAAM,eAAe,GAAG;IAC5B,GAAG,CAAC,EAAC,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAmCF,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EACjC,GAAG,EACH,KAAsB,EACtB,QAAmC,EACnC,YAAwB,GACzB,EAAE,eAAe,oCA0LjB"}
package/dist/index.cjs CHANGED
@@ -1,14 +1,9 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t,t.exports),e=null),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,o)=>(o=n==null?{}:e(i(n)),s(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n));let l=require("react");var u=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),d=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),f=e=>{let t=d(e);return t.charAt(0).toUpperCase()+t.slice(1)},p=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),m=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0},h={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},g=(0,l.forwardRef)(({color:e=`currentColor`,size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...s},c)=>(0,l.createElement)(`svg`,{ref:c,...h,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:p(`lucide`,i),...!a&&!m(s)&&{"aria-hidden":`true`},...s},[...o.map(([e,t])=>(0,l.createElement)(e,t)),...Array.isArray(a)?a:[a]])),_=(e,t)=>{let n=(0,l.forwardRef)(({className:n,...r},i)=>(0,l.createElement)(g,{ref:i,iconNode:t,className:p(`lucide-${u(f(e))}`,`lucide-${e}`,n),...r}));return n.displayName=f(e),n},v=_(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),y=_(`message-circle`,[[`path`,{d:`M7.9 20A9 9 0 1 0 4 16.1L2 22Z`,key:`vv11sd`}]]),b=_(`minimize-2`,[[`path`,{d:`m14 10 7-7`,key:`oa77jy`}],[`path`,{d:`M20 10h-6V4`,key:`mjg0md`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M4 14h6v6`,key:`rmj7iw`}]]),x=_(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),S=_(`sparkles`,[[`path`,{d:`M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z`,key:`4pj2yx`}],[`path`,{d:`M20 3v4`,key:`1olli1`}],[`path`,{d:`M22 5h-4`,key:`1gvqau`}],[`path`,{d:`M4 17v2`,key:`vumght`}],[`path`,{d:`M5 18H3`,key:`zchphs`}]]),C=_(`user`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),w=_(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),T=o(((e,t,n)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):(n=typeof globalThis<`u`?globalThis:n||self).dayjs=r()})(n,(function(){"use strict";var e=1e3,t=6e4,n=36e5,r=`millisecond`,i=`second`,a=`minute`,o=`hour`,s=`day`,c=`week`,l=`month`,u=`quarter`,d=`year`,f=`date`,p=`Invalid Date`,m=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,h=/\[([^\]]+)]|YYYY|YY|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,g={name:`en`,weekdays:`Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday`.split(`_`),months:`January_February_March_April_May_June_July_August_September_October_November_December`.split(`_`),ordinal:function(e){var t=[`th`,`st`,`nd`,`rd`],n=e%100;return`[`+e+(t[(n-20)%10]||t[n]||t[0])+`]`}},_=function(e,t,n){var r=String(e);return!r||r.length>=t?e:``+Array(t+1-r.length).join(n)+e},v={s:_,z:function(e){var t=-e.utcOffset(),n=Math.abs(t),r=Math.floor(n/60),i=n%60;return(t<=0?`+`:`-`)+_(r,2,`0`)+`:`+_(i,2,`0`)},m:function e(t,n){if(t.date()<n.date())return-e(n,t);var r=12*(n.year()-t.year())+(n.month()-t.month()),i=t.clone().add(r,l),a=n-i<0,o=t.clone().add(r+(a?-1:1),l);return+(-(r+(n-i)/(a?i-o:o-i))||0)},a:function(e){return e<0?Math.ceil(e)||0:Math.floor(e)},p:function(e){return{M:l,y:d,w:c,d:s,D:f,h:o,m:a,s:i,ms:r,Q:u}[e]||String(e||``).toLowerCase().replace(/s$/,``)},u:function(e){return e===void 0}},y=`en`,b={};b[y]=g;var x=`$isDayjsObject`,S=function(e){return e instanceof E||!(!e||!e[x])},C=function e(t,n,r){var i;if(!t)return y;if(typeof t==`string`){var a=t.toLowerCase();b[a]&&(i=a),n&&(b[a]=n,i=a);var o=t.split(`-`);if(!i&&o.length>1)return e(o[0])}else{var s=t.name;b[s]=t,i=s}return!r&&i&&(y=i),i||!r&&y},w=function(e,t){if(S(e))return e.clone();var n=typeof t==`object`?t:{};return n.date=e,n.args=arguments,new E(n)},T=v;T.l=C,T.i=S,T.w=function(e,t){return w(e,{locale:t.$L,utc:t.$u,x:t.$x,$offset:t.$offset})};var E=function(){function g(e){this.$L=C(e.locale,null,!0),this.parse(e),this.$x=this.$x||e.x||{},this[x]=!0}var _=g.prototype;return _.parse=function(e){this.$d=function(e){var t=e.date,n=e.utc;if(t===null)return new Date(NaN);if(T.u(t))return new Date;if(t instanceof Date)return new Date(t);if(typeof t==`string`&&!/Z$/i.test(t)){var r=t.match(m);if(r){var i=r[2]-1||0,a=(r[7]||`0`).substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,a)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,a)}}return new Date(t)}(e),this.init()},_.init=function(){var e=this.$d;this.$y=e.getFullYear(),this.$M=e.getMonth(),this.$D=e.getDate(),this.$W=e.getDay(),this.$H=e.getHours(),this.$m=e.getMinutes(),this.$s=e.getSeconds(),this.$ms=e.getMilliseconds()},_.$utils=function(){return T},_.isValid=function(){return this.$d.toString()!==p},_.isSame=function(e,t){var n=w(e);return this.startOf(t)<=n&&n<=this.endOf(t)},_.isAfter=function(e,t){return w(e)<this.startOf(t)},_.isBefore=function(e,t){return this.endOf(t)<w(e)},_.$g=function(e,t,n){return T.u(e)?this[t]:this.set(n,e)},_.unix=function(){return Math.floor(this.valueOf()/1e3)},_.valueOf=function(){return this.$d.getTime()},_.startOf=function(e,t){var n=this,r=!!T.u(t)||t,u=T.p(e),p=function(e,t){var i=T.w(n.$u?Date.UTC(n.$y,t,e):new Date(n.$y,t,e),n);return r?i:i.endOf(s)},m=function(e,t){return T.w(n.toDate()[e].apply(n.toDate(`s`),(r?[0,0,0,0]:[23,59,59,999]).slice(t)),n)},h=this.$W,g=this.$M,_=this.$D,v=`set`+(this.$u?`UTC`:``);switch(u){case d:return r?p(1,0):p(31,11);case l:return r?p(1,g):p(0,g+1);case c:var y=this.$locale().weekStart||0,b=(h<y?h+7:h)-y;return p(r?_-b:_+(6-b),g);case s:case f:return m(v+`Hours`,0);case o:return m(v+`Minutes`,1);case a:return m(v+`Seconds`,2);case i:return m(v+`Milliseconds`,3);default:return this.clone()}},_.endOf=function(e){return this.startOf(e,!1)},_.$set=function(e,t){var n,c=T.p(e),u=`set`+(this.$u?`UTC`:``),p=(n={},n[s]=u+`Date`,n[f]=u+`Date`,n[l]=u+`Month`,n[d]=u+`FullYear`,n[o]=u+`Hours`,n[a]=u+`Minutes`,n[i]=u+`Seconds`,n[r]=u+`Milliseconds`,n)[c],m=c===s?this.$D+(t-this.$W):t;if(c===l||c===d){var h=this.clone().set(f,1);h.$d[p](m),h.init(),this.$d=h.set(f,Math.min(this.$D,h.daysInMonth())).$d}else p&&this.$d[p](m);return this.init(),this},_.set=function(e,t){return this.clone().$set(e,t)},_.get=function(e){return this[T.p(e)]()},_.add=function(r,u){var f,p=this;r=Number(r);var m=T.p(u),h=function(e){var t=w(p);return T.w(t.date(t.date()+Math.round(e*r)),p)};if(m===l)return this.set(l,this.$M+r);if(m===d)return this.set(d,this.$y+r);if(m===s)return h(1);if(m===c)return h(7);var g=(f={},f[a]=t,f[o]=n,f[i]=e,f)[m]||1,_=this.$d.getTime()+r*g;return T.w(_,this)},_.subtract=function(e,t){return this.add(-1*e,t)},_.format=function(e){var t=this,n=this.$locale();if(!this.isValid())return n.invalidDate||p;var r=e||`YYYY-MM-DDTHH:mm:ssZ`,i=T.z(this),a=this.$H,o=this.$m,s=this.$M,c=n.weekdays,l=n.months,u=n.meridiem,d=function(e,n,i,a){return e&&(e[n]||e(t,r))||i[n].slice(0,a)},f=function(e){return T.s(a%12||12,e,`0`)},m=u||function(e,t,n){var r=e<12?`AM`:`PM`;return n?r.toLowerCase():r};return r.replace(h,(function(e,r){return r||function(e){switch(e){case`YY`:return String(t.$y).slice(-2);case`YYYY`:return T.s(t.$y,4,`0`);case`M`:return s+1;case`MM`:return T.s(s+1,2,`0`);case`MMM`:return d(n.monthsShort,s,l,3);case`MMMM`:return d(l,s);case`D`:return t.$D;case`DD`:return T.s(t.$D,2,`0`);case`d`:return String(t.$W);case`dd`:return d(n.weekdaysMin,t.$W,c,2);case`ddd`:return d(n.weekdaysShort,t.$W,c,3);case`dddd`:return c[t.$W];case`H`:return String(a);case`HH`:return T.s(a,2,`0`);case`h`:return f(1);case`hh`:return f(2);case`a`:return m(a,o,!0);case`A`:return m(a,o,!1);case`m`:return String(o);case`mm`:return T.s(o,2,`0`);case`s`:return String(t.$s);case`ss`:return T.s(t.$s,2,`0`);case`SSS`:return T.s(t.$ms,3,`0`);case`Z`:return i}return null}(e)||i.replace(`:`,``)}))},_.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},_.diff=function(r,f,p){var m,h=this,g=T.p(f),_=w(r),v=(_.utcOffset()-this.utcOffset())*t,y=this-_,b=function(){return T.m(h,_)};switch(g){case d:m=b()/12;break;case l:m=b();break;case u:m=b()/3;break;case c:m=(y-v)/6048e5;break;case s:m=(y-v)/864e5;break;case o:m=y/n;break;case a:m=y/t;break;case i:m=y/e;break;default:m=y}return p?m:T.a(m)},_.daysInMonth=function(){return this.endOf(l).$D},_.$locale=function(){return b[this.$L]},_.locale=function(e,t){if(!e)return this.$L;var n=this.clone(),r=C(e,t,!0);return r&&(n.$L=r),n},_.clone=function(){return T.w(this.$d,this)},_.toDate=function(){return new Date(this.valueOf())},_.toJSON=function(){return this.isValid()?this.toISOString():null},_.toISOString=function(){return this.$d.toISOString()},_.toString=function(){return this.$d.toUTCString()},g}(),D=E.prototype;return w.prototype=D,[[`$ms`,r],[`$s`,i],[`$m`,a],[`$H`,o],[`$W`,s],[`$M`,l],[`$y`,d],[`$D`,f]].forEach((function(e){D[e[1]]=function(t){return this.$g(t,e[0],e[1])}})),w.extend=function(e,t){return e.$i||=(e(t,E,w),!0),w},w.locale=C,w.isDayjs=S,w.unix=function(e){return w(1e3*e)},w.en=b[y],w.Ls=b,w.p={},w}))})),E=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),D=o((e=>{process.env.NODE_ENV!==`production`&&(function(){function t(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===k?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case _:return`Fragment`;case y:return`Profiler`;case v:return`StrictMode`;case C:return`Suspense`;case w:return`SuspenseList`;case D:return`Activity`;case O:return`ViewTransition`}if(typeof e==`object`)switch(typeof e.tag==`number`&&console.error(`Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue.`),e.$$typeof){case g:return`Portal`;case x:return e.displayName||`Context`;case b:return(e._context.displayName||`Context`)+`.Consumer`;case S:var n=e.render;return e=e.displayName,e||=(e=n.displayName||n.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case T:return n=e.displayName||null,n===null?t(e.type)||`Memo`:n;case E:n=e._payload,e=e._init;try{return t(e(n))}catch{}}return null}function n(e){return``+e}function r(e){try{n(e);var t=!1}catch{t=!0}if(t){t=console;var r=t.error,i=typeof Symbol==`function`&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||`Object`;return r.call(t,`The provided key is an unsupported type %s. This value must be coerced to a string before using it here.`,i),n(e)}}function i(e){if(e===_)return`<>`;if(typeof e==`object`&&e&&e.$$typeof===E)return`<...>`;try{var n=t(e);return n?`<`+n+`>`:`<...>`}catch{return`<...>`}}function a(){var e=A.A;return e===null?null:e.getOwner()}function o(){return Error(`react-stack-top-frame`)}function s(e){if(j.call(e,`key`)){var t=Object.getOwnPropertyDescriptor(e,`key`).get;if(t&&t.isReactWarning)return!1}return e.key!==void 0}function c(e,t){function n(){P||(P=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",t))}n.isReactWarning=!0,Object.defineProperty(e,"key",{get:n,configurable:!0})}function l(){var e=t(this.type);return F[e]||(F[e]=!0,console.error(`Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.`)),e=this.props.ref,e===void 0?null:e}function u(e,t,n,r,i,a){var o=n.ref;return e={$$typeof:h,type:e,key:t,props:n,_owner:r},(o===void 0?null:o)===null?Object.defineProperty(e,"ref",{enumerable:!1,value:null}):Object.defineProperty(e,"ref",{enumerable:!1,get:l}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:i}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:a}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function d(e,n,i,o,l,d){var p=n.children;if(p!==void 0){if(o){if(M(p)){for(o=0;o<p.length;o++)f(p[o]);Object.freeze&&Object.freeze(p)}else console.error(`React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.`)}else f(p)}if(j.call(n,`key`)){p=t(e);var m=Object.keys(n).filter(function(e){return e!==`key`});o=0<m.length?`{key: someKey, `+m.join(`: ..., `)+`: ...}`:`{key: someKey}`,R[p+o]||(m=0<m.length?`{`+m.join(`: ..., `)+`: ...}`:`{}`,console.error(`A props object containing a "key" prop is being spread into JSX:
2
- let props = %s;
3
- <%s {...props} />
4
- React keys must be passed directly to JSX without using spread:
5
- let props = %s;
6
- <%s key={someKey} {...props} />`,o,p,m,p),R[p+o]=!0)}if(p=null,i!==void 0&&(r(i),p=``+i),s(n)&&(r(n.key),p=``+n.key),`key`in n)for(var h in i={},n)h!==`key`&&(i[h]=n[h]);else i=n;return p&&c(i,typeof e==`function`?e.displayName||e.name||`Unknown`:e),u(e,p,i,a(),l,d)}function f(e){p(e)?e._store&&(e._store.validated=1):typeof e==`object`&&e&&e.$$typeof===E&&(e._payload.status===`fulfilled`?p(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function p(e){return typeof e==`object`&&!!e&&e.$$typeof===h}var m=require("react"),h=Symbol.for(`react.transitional.element`),g=Symbol.for(`react.portal`),_=Symbol.for(`react.fragment`),v=Symbol.for(`react.strict_mode`),y=Symbol.for(`react.profiler`),b=Symbol.for(`react.consumer`),x=Symbol.for(`react.context`),S=Symbol.for(`react.forward_ref`),C=Symbol.for(`react.suspense`),w=Symbol.for(`react.suspense_list`),T=Symbol.for(`react.memo`),E=Symbol.for(`react.lazy`),D=Symbol.for(`react.activity`),O=Symbol.for(`react.view_transition`),k=Symbol.for(`react.client.reference`),A=m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,j=Object.prototype.hasOwnProperty,M=Array.isArray,N=console.createTask?console.createTask:function(){return null};m={react_stack_bottom_frame:function(e){return e()}};var P,F={},I=m.react_stack_bottom_frame.bind(m,o)(),L=N(i(o)),R={};e.Fragment=_,e.jsx=function(e,t,n){var r=1e4>A.recentlyCreatedOwnerStacks++;if(r){var a=Error.stackTraceLimit;Error.stackTraceLimit=10;var o=Error(`react-stack-top-frame`);Error.stackTraceLimit=a}else o=I;return d(e,t,n,!1,o,r?N(i(e)):L)},e.jsxs=function(e,t,n){var r=1e4>A.recentlyCreatedOwnerStacks++;if(r){var a=Error.stackTraceLimit;Error.stackTraceLimit=10;var o=Error(`react-stack-top-frame`);Error.stackTraceLimit=a}else o=I;return d(e,t,n,!0,o,r?N(i(e)):L)}})()})),O=o(((e,t)=>{t.exports=process.env.NODE_ENV===`production`?E():D()})),k=c(T()),A=O(),j=[`Check vehicle status`,`Schedule maintenance`,`Pricing information`],M=[{id:1,role:`assistant`,text:`Hello! 👋 I'm your AI assistant. How can I help you today?`,time:`Just now`}];function N(e){let t=e.toLowerCase();return t.includes(`vehicle`)||t.includes(`status`)?`I can help check vehicle status. Please provide the vehicle number plate, such as VDR6117.`:t.includes(`maintenance`)||t.includes(`repair`)?`I can help with maintenance! Please describe the vehicle issue, and I'll suggest the next steps.`:t.includes(`price`)||t.includes(`cost`)?`Pricing depends on your requirements. Tell me which service you're interested in, and I'll help estimate the cost.`:t.includes(`hello`)||t.includes(`hi`)?`Hello! 😊 What would you like help with today?`:`Thanks for your message: "${e}". This is a demo response. Configure apiUrl to connect your AI backend.`}function P({key:e,title:t=`AI Assistant`,subtitle:n=`Online · Ready to help`,primaryColor:r=`#2563eb`}){let[i,a]=(0,l.useState)(!1),[o,s]=(0,l.useState)(!1),[c,u]=(0,l.useState)(``),[d,f]=(0,l.useState)(!1),[p,m]=(0,l.useState)(M),h=(0,l.useRef)(null),g=(0,l.useRef)(null),[_,T]=(0,l.useState)(null);(0,l.useEffect)(()=>{h.current?.scrollIntoView({behavior:`smooth`})},[p,d,i,o]),(0,l.useEffect)(()=>{i&&!o&&g.current?.focus()},[i,o]);let E=process.env.NEXT_PUBLIC_API_URL;if(!E||!e)return``;async function D(t=c){let n=t.trim();if(!n||d)return;let r=(0,k.default)().format(`HH:mm`);m(e=>[...e,{id:Date.now(),role:`user`,text:n,time:r}]),u(``),f(!0),T(null);try{let t;if(E){let r;try{r=await fetch(E,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({message:n,key:e})})}catch(e){throw T(`Failed to fetch.
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));let c=require("react"),l=require("lucide-react"),u=require("dayjs");u=s(u);let d=require("react/jsx-runtime");var f=[`Check vehicle status`,`Schedule maintenance`,`Pricing information`],p=[{id:1,role:`assistant`,text:`Hello! 👋 I'm your AI assistant. How can I help you today?`,time:`Just now`}];function m(e){let t=e.toLowerCase();return t.includes(`vehicle`)||t.includes(`status`)?`I can help check vehicle status. Please provide the vehicle number plate, such as VDR6117.`:t.includes(`maintenance`)||t.includes(`repair`)?`I can help with maintenance! Please describe the vehicle issue, and I'll suggest the next steps.`:t.includes(`price`)||t.includes(`cost`)?`Pricing depends on your requirements. Tell me which service you're interested in, and I'll help estimate the cost.`:t.includes(`hello`)||t.includes(`hi`)?`Hello! 😊 What would you like help with today?`:`Thanks for your message: "${e}". This is a demo response. Configure apiUrl to connect your AI backend.`}function h({key:e,title:t=`AI Assistant`,subtitle:n=`Online · Ready to help`,primaryColor:r=`#2563eb`}){let[i,a]=(0,c.useState)(!1),[o,s]=(0,c.useState)(!1),[h,g]=(0,c.useState)(``),[_,v]=(0,c.useState)(!1),[y,b]=(0,c.useState)(p),x=(0,c.useRef)(null),S=(0,c.useRef)(null),[C,w]=(0,c.useState)(null);(0,c.useEffect)(()=>{x.current?.scrollIntoView({behavior:`smooth`})},[y,_,i,o]),(0,c.useEffect)(()=>{i&&!o&&S.current?.focus()},[i,o]);let T=process.env.NEXT_PUBLIC_API_URL;if(!T||!e)return``;async function E(t=h){let n=t.trim();if(!n||_)return;let r=(0,u.default)().format(`HH:mm`);b(e=>[...e,{id:Date.now(),role:`user`,text:n,time:r}]),g(``),v(!0),w(null);try{let t;if(T){let r;try{r=await fetch(T,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({message:n,key:e})})}catch(e){throw w(`Failed to fetch.
7
2
 
8
3
  Possible Reasons:
9
4
 
10
5
  - CORS
11
6
  - Network Failure
12
- - URL scheme must be "http" or "https" for CORS request.`),e}if(!r.ok)throw T(`Failed to fetch.\n\nPossible Reasons:\n\n- CORS\n- Network Failure\n- URL scheme must be "http" or "https" for CORS request.\n\nChat API returned ${r.status}`),Error(`Chat API returned ${r.status}`);let i=await r.json();t=i.reply??i.response??i.message??`I received a response, but it did not include a reply field.`}else await new Promise(e=>setTimeout(e,700)),t=N(n);m(e=>[...e,{id:Date.now()+1,role:`assistant`,text:t,time:(0,k.default)().format(`HH:mm`)}])}catch{m(e=>[...e,{id:Date.now()+1,role:`assistant`,text:_||`Sorry, I couldn't reach the chat service. Please try again.`,time:(0,k.default)().format(`HH:mm`)}])}finally{f(!1)}}return(0,A.jsxs)(`div`,{className:`acw-root`,style:{"--acw-primary":r},children:[i&&(0,A.jsxs)(`section`,{className:`acw-panel ${o?`acw-minimized`:``}`,"aria-label":`AI chat assistant`,children:[(0,A.jsxs)(`header`,{className:`acw-header`,children:[(0,A.jsx)(`div`,{className:`acw-brand-icon`,children:(0,A.jsx)(v,{size:23})}),(0,A.jsxs)(`div`,{className:`acw-heading`,children:[(0,A.jsx)(`h2`,{children:t}),(0,A.jsxs)(`p`,{children:[(0,A.jsx)(`span`,{className:`acw-online-dot`}),n]})]}),(0,A.jsx)(`button`,{className:`acw-header-button`,onClick:()=>s(!o),"aria-label":`Minimize chat`,children:(0,A.jsx)(b,{size:17})}),(0,A.jsx)(`button`,{className:`acw-header-button`,onClick:()=>a(!1),"aria-label":`Close chat`,children:(0,A.jsx)(w,{size:19})})]}),!o&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`div`,{className:`acw-messages`,children:[p.map((e,t)=>(0,A.jsxs)(`div`,{className:`acw-message-row ${e.role===`user`?`acw-user-row`:``}`,children:[e.role===`assistant`&&(0,A.jsx)(`div`,{className:`acw-avatar acw-bot-avatar`,children:(0,A.jsx)(v,{size:17})}),(0,A.jsxs)(`div`,{className:`acw-message-content`,children:[(0,A.jsx)(`div`,{className:`acw-bubble ${e.role===`user`?`acw-user-bubble`:`acw-assistant-bubble`}`,children:e.text.split(`
13
- `).map((t,n)=>(0,A.jsxs)(`span`,{children:[t,n<e.text.split(`
14
- `).length-1&&(0,A.jsx)(`br`,{})]},n))}),(0,A.jsx)(`span`,{className:`acw-time`,children:e.time})]}),e.role===`user`&&(0,A.jsx)(`div`,{className:`acw-avatar acw-user-avatar`,children:(0,A.jsx)(C,{size:17})})]},e.id)),d&&(0,A.jsxs)(`div`,{className:`acw-message-row`,children:[(0,A.jsx)(`div`,{className:`acw-avatar acw-bot-avatar`,children:(0,A.jsx)(v,{size:17})}),(0,A.jsxs)(`div`,{className:`acw-typing`,"aria-label":`Assistant is typing`,children:[(0,A.jsx)(`span`,{}),(0,A.jsx)(`span`,{}),(0,A.jsx)(`span`,{})]})]}),(0,A.jsx)(`div`,{ref:h})]}),p.length===1&&(0,A.jsxs)(`div`,{className:`acw-suggestions`,children:[(0,A.jsxs)(`p`,{children:[(0,A.jsx)(S,{size:13}),` Suggested questions`]}),(0,A.jsx)(`div`,{className:`acw-suggestion-list`,children:j.map(e=>(0,A.jsx)(`button`,{onClick:()=>void D(e),children:e},e))})]}),(0,A.jsxs)(`form`,{className:`acw-composer`,onSubmit:e=>{e.preventDefault(),D()},children:[(0,A.jsx)(`input`,{ref:g,value:c,onChange:e=>u(e.target.value),placeholder:`Type your message...`,"aria-label":`Type your message`}),(0,A.jsx)(`button`,{type:`submit`,disabled:!c.trim()||d,"aria-label":`Send message`,children:(0,A.jsx)(x,{size:18})})]}),(0,A.jsx)(`p`,{className:`acw-footer`,children:E?`Powered by your AI service`:`Demo mode · Connect your AI API`})]})]}),(0,A.jsxs)(`button`,{className:`acw-launcher`,onClick:()=>{a(!i),s(!1)},"aria-label":i?`Close chat widget`:`Open chat widget`,"aria-expanded":i,children:[!i&&(0,A.jsx)(`span`,{className:`acw-notification-dot`}),i?(0,A.jsx)(w,{size:25}):(0,A.jsx)(y,{size:26})]})]})}exports.ChatWidget=P;
7
+ - URL scheme must be "http" or "https" for CORS request.`),e}if(!r.ok)throw w(`Failed to fetch.\n\nPossible Reasons:\n\n- CORS\n- Network Failure\n- URL scheme must be "http" or "https" for CORS request.\n\nChat API returned ${r.status}`),Error(`Chat API returned ${r.status}`);let i=await r.json();t=i.reply??i.response??i.message??`I received a response, but it did not include a reply field.`}else await new Promise(e=>setTimeout(e,700)),t=m(n);b(e=>[...e,{id:Date.now()+1,role:`assistant`,text:t,time:(0,u.default)().format(`HH:mm`)}])}catch{b(e=>[...e,{id:Date.now()+1,role:`assistant`,text:C||`Sorry, I couldn't reach the chat service. Please try again.`,time:(0,u.default)().format(`HH:mm`)}])}finally{v(!1)}}return(0,d.jsxs)(`div`,{className:`acw-root`,style:{"--acw-primary":r},children:[i&&(0,d.jsxs)(`section`,{className:`acw-panel ${o?`acw-minimized`:``}`,"aria-label":`AI chat assistant`,children:[(0,d.jsxs)(`header`,{className:`acw-header`,children:[(0,d.jsx)(`div`,{className:`acw-brand-icon`,children:(0,d.jsx)(l.Bot,{size:23})}),(0,d.jsxs)(`div`,{className:`acw-heading`,children:[(0,d.jsx)(`h2`,{children:t}),(0,d.jsxs)(`p`,{children:[(0,d.jsx)(`span`,{className:`acw-online-dot`}),n]})]}),(0,d.jsx)(`button`,{className:`acw-header-button`,onClick:()=>s(!o),"aria-label":`Minimize chat`,children:(0,d.jsx)(l.Minimize2,{size:17})}),(0,d.jsx)(`button`,{className:`acw-header-button`,onClick:()=>a(!1),"aria-label":`Close chat`,children:(0,d.jsx)(l.X,{size:19})})]}),!o&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(`div`,{className:`acw-messages`,children:[y.map((e,t)=>(0,d.jsxs)(`div`,{className:`acw-message-row ${e.role===`user`?`acw-user-row`:``}`,children:[e.role===`assistant`&&(0,d.jsx)(`div`,{className:`acw-avatar acw-bot-avatar`,children:(0,d.jsx)(l.Bot,{size:17})}),(0,d.jsxs)(`div`,{className:`acw-message-content`,children:[(0,d.jsx)(`div`,{className:`acw-bubble ${e.role===`user`?`acw-user-bubble`:`acw-assistant-bubble`}`,children:e.text.split(`
8
+ `).map((t,n)=>(0,d.jsxs)(`span`,{children:[t,n<e.text.split(`
9
+ `).length-1&&(0,d.jsx)(`br`,{})]},n))}),(0,d.jsx)(`span`,{className:`acw-time`,children:e.time})]}),e.role===`user`&&(0,d.jsx)(`div`,{className:`acw-avatar acw-user-avatar`,children:(0,d.jsx)(l.User,{size:17})})]},e.id)),_&&(0,d.jsxs)(`div`,{className:`acw-message-row`,children:[(0,d.jsx)(`div`,{className:`acw-avatar acw-bot-avatar`,children:(0,d.jsx)(l.Bot,{size:17})}),(0,d.jsxs)(`div`,{className:`acw-typing`,"aria-label":`Assistant is typing`,children:[(0,d.jsx)(`span`,{}),(0,d.jsx)(`span`,{}),(0,d.jsx)(`span`,{})]})]}),(0,d.jsx)(`div`,{ref:x})]}),y.length===1&&(0,d.jsxs)(`div`,{className:`acw-suggestions`,children:[(0,d.jsxs)(`p`,{children:[(0,d.jsx)(l.Sparkles,{size:13}),` Suggested questions`]}),(0,d.jsx)(`div`,{className:`acw-suggestion-list`,children:f.map(e=>(0,d.jsx)(`button`,{onClick:()=>void E(e),children:e},e))})]}),(0,d.jsxs)(`form`,{className:`acw-composer`,onSubmit:e=>{e.preventDefault(),E()},children:[(0,d.jsx)(`input`,{ref:S,value:h,onChange:e=>g(e.target.value),placeholder:`Type your message...`,"aria-label":`Type your message`}),(0,d.jsx)(`button`,{type:`submit`,disabled:!h.trim()||_,"aria-label":`Send message`,children:(0,d.jsx)(l.Send,{size:18})})]}),(0,d.jsx)(`p`,{className:`acw-footer`,children:T?`Powered by your AI service`:`Demo mode · Connect your AI API`})]})]}),(0,d.jsxs)(`button`,{className:`acw-launcher`,onClick:()=>{a(!i),s(!1)},"aria-label":i?`Close chat widget`:`Open chat widget`,"aria-expanded":i,children:[!i&&(0,d.jsx)(`span`,{className:`acw-notification-dot`}),i?(0,d.jsx)(l.X,{size:25}):(0,d.jsx)(l.MessageCircle,{size:26})]})]})}exports.ChatWidget=h;
@@ -0,0 +1,3 @@
1
+ export { default as ChatWidget } from './ChatWidget';
2
+ export type { ChatWidgetProps } from './ChatWidget';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC"}
package/dist/index.js CHANGED
@@ -1,817 +1,200 @@
1
- import { createElement as e, forwardRef as t, useEffect as n, useRef as r, useState as i } from "react";
2
- // \0rolldown/runtime.js
3
- var a = Object.create, o = Object.defineProperty, s = Object.getOwnPropertyDescriptor, c = Object.getOwnPropertyNames, l = Object.getPrototypeOf, u = Object.prototype.hasOwnProperty, d = (e, t) => () => (t || (e((t = { exports: {} }).exports, t, t.exports), e = null), t.exports), f = (e, t, n, r) => {
4
- if (t && typeof t == "object" || typeof t == "function") for (var i = c(t), a = 0, l = i.length, d; a < l; a++) d = i[a], !u.call(e, d) && d !== n && o(e, d, {
5
- get: ((e) => t[e]).bind(null, d),
6
- enumerable: !(r = s(t, d)) || r.enumerable
7
- });
8
- return e;
9
- }, p = (e, t, n) => (n = e == null ? {} : a(l(e)), f(t || !e || !e.__esModule || !u.call(e, "default") ? o(n, "default", {
10
- value: e,
11
- enumerable: !0
12
- }) : n, e)), m = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(e, { get: (e, t) => (typeof require < "u" ? require : e)[t] }) : e)(function(e) {
13
- if (typeof require < "u") return require.apply(this, arguments);
14
- throw Error("Calling `require` for \"" + e + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
15
- }), h = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), g = (e) => e.replace(/^([A-Z])|[\s-_]+(\w)/g, (e, t, n) => n ? n.toUpperCase() : t.toLowerCase()), _ = (e) => {
16
- let t = g(e);
17
- return t.charAt(0).toUpperCase() + t.slice(1);
18
- }, v = (...e) => e.filter((e, t, n) => !!e && e.trim() !== "" && n.indexOf(e) === t).join(" ").trim(), y = (e) => {
19
- for (let t in e) if (t.startsWith("aria-") || t === "role" || t === "title") return !0;
20
- }, b = {
21
- xmlns: "http://www.w3.org/2000/svg",
22
- width: 24,
23
- height: 24,
24
- viewBox: "0 0 24 24",
25
- fill: "none",
26
- stroke: "currentColor",
27
- strokeWidth: 2,
28
- strokeLinecap: "round",
29
- strokeLinejoin: "round"
30
- }, x = t(({ color: t = "currentColor", size: n = 24, strokeWidth: r = 2, absoluteStrokeWidth: i, className: a = "", children: o, iconNode: s, ...c }, l) => e("svg", {
31
- ref: l,
32
- ...b,
33
- width: n,
34
- height: n,
35
- stroke: t,
36
- strokeWidth: i ? Number(r) * 24 / Number(n) : r,
37
- className: v("lucide", a),
38
- ...!o && !y(c) && { "aria-hidden": "true" },
39
- ...c
40
- }, [...s.map(([t, n]) => e(t, n)), ...Array.isArray(o) ? o : [o]])), S = (n, r) => {
41
- let i = t(({ className: t, ...i }, a) => e(x, {
42
- ref: a,
43
- iconNode: r,
44
- className: v(`lucide-${h(_(n))}`, `lucide-${n}`, t),
45
- ...i
46
- }));
47
- return i.displayName = _(n), i;
48
- }, C = S("bot", [
49
- ["path", {
50
- d: "M12 8V4H8",
51
- key: "hb8ula"
52
- }],
53
- ["rect", {
54
- width: "16",
55
- height: "12",
56
- x: "4",
57
- y: "8",
58
- rx: "2",
59
- key: "enze0r"
60
- }],
61
- ["path", {
62
- d: "M2 14h2",
63
- key: "vft8re"
64
- }],
65
- ["path", {
66
- d: "M20 14h2",
67
- key: "4cs60a"
68
- }],
69
- ["path", {
70
- d: "M15 13v2",
71
- key: "1xurst"
72
- }],
73
- ["path", {
74
- d: "M9 13v2",
75
- key: "rq6x2g"
76
- }]
77
- ]), w = S("message-circle", [["path", {
78
- d: "M7.9 20A9 9 0 1 0 4 16.1L2 22Z",
79
- key: "vv11sd"
80
- }]]), T = S("minimize-2", [
81
- ["path", {
82
- d: "m14 10 7-7",
83
- key: "oa77jy"
84
- }],
85
- ["path", {
86
- d: "M20 10h-6V4",
87
- key: "mjg0md"
88
- }],
89
- ["path", {
90
- d: "m3 21 7-7",
91
- key: "tjx5ai"
92
- }],
93
- ["path", {
94
- d: "M4 14h6v6",
95
- key: "rmj7iw"
96
- }]
97
- ]), E = S("send", [["path", {
98
- d: "M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",
99
- key: "1ffxy3"
100
- }], ["path", {
101
- d: "m21.854 2.147-10.94 10.939",
102
- key: "12cjpa"
103
- }]]), D = S("sparkles", [
104
- ["path", {
105
- d: "M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",
106
- key: "4pj2yx"
107
- }],
108
- ["path", {
109
- d: "M20 3v4",
110
- key: "1olli1"
111
- }],
112
- ["path", {
113
- d: "M22 5h-4",
114
- key: "1gvqau"
115
- }],
116
- ["path", {
117
- d: "M4 17v2",
118
- key: "vumght"
119
- }],
120
- ["path", {
121
- d: "M5 18H3",
122
- key: "zchphs"
123
- }]
124
- ]), O = S("user", [["path", {
125
- d: "M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",
126
- key: "975kel"
127
- }], ["circle", {
128
- cx: "12",
129
- cy: "7",
130
- r: "4",
131
- key: "17ys0d"
132
- }]]), k = S("x", [["path", {
133
- d: "M18 6 6 18",
134
- key: "1bl5f8"
135
- }], ["path", {
136
- d: "m6 6 12 12",
137
- key: "d8bk6v"
138
- }]]), A = /* @__PURE__ */ d(((e, t, n) => {
139
- (function(n, r) {
140
- typeof e == "object" && t !== void 0 ? t.exports = r() : typeof define == "function" && define.amd ? define(r) : (n = typeof globalThis < "u" ? globalThis : n || self).dayjs = r();
141
- })(n, (function() {
142
- var e = 1e3, t = 6e4, n = 36e5, r = "millisecond", i = "second", a = "minute", o = "hour", s = "day", c = "week", l = "month", u = "quarter", d = "year", f = "date", p = "Invalid Date", m = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/, h = /\[([^\]]+)]|YYYY|YY|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, g = {
143
- name: "en",
144
- weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),
145
- months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"),
146
- ordinal: function(e) {
147
- var t = [
148
- "th",
149
- "st",
150
- "nd",
151
- "rd"
152
- ], n = e % 100;
153
- return "[" + e + (t[(n - 20) % 10] || t[n] || t[0]) + "]";
154
- }
155
- }, _ = function(e, t, n) {
156
- var r = String(e);
157
- return !r || r.length >= t ? e : "" + Array(t + 1 - r.length).join(n) + e;
158
- }, v = {
159
- s: _,
160
- z: function(e) {
161
- var t = -e.utcOffset(), n = Math.abs(t), r = Math.floor(n / 60), i = n % 60;
162
- return (t <= 0 ? "+" : "-") + _(r, 2, "0") + ":" + _(i, 2, "0");
163
- },
164
- m: function e(t, n) {
165
- if (t.date() < n.date()) return -e(n, t);
166
- var r = 12 * (n.year() - t.year()) + (n.month() - t.month()), i = t.clone().add(r, l), a = n - i < 0, o = t.clone().add(r + (a ? -1 : 1), l);
167
- return +(-(r + (n - i) / (a ? i - o : o - i)) || 0);
168
- },
169
- a: function(e) {
170
- return e < 0 ? Math.ceil(e) || 0 : Math.floor(e);
171
- },
172
- p: function(e) {
173
- return {
174
- M: l,
175
- y: d,
176
- w: c,
177
- d: s,
178
- D: f,
179
- h: o,
180
- m: a,
181
- s: i,
182
- ms: r,
183
- Q: u
184
- }[e] || String(e || "").toLowerCase().replace(/s$/, "");
185
- },
186
- u: function(e) {
187
- return e === void 0;
188
- }
189
- }, y = "en", b = {};
190
- b[y] = g;
191
- var x = "$isDayjsObject", S = function(e) {
192
- return e instanceof E || !(!e || !e[x]);
193
- }, C = function e(t, n, r) {
194
- var i;
195
- if (!t) return y;
196
- if (typeof t == "string") {
197
- var a = t.toLowerCase();
198
- b[a] && (i = a), n && (b[a] = n, i = a);
199
- var o = t.split("-");
200
- if (!i && o.length > 1) return e(o[0]);
201
- } else {
202
- var s = t.name;
203
- b[s] = t, i = s;
204
- }
205
- return !r && i && (y = i), i || !r && y;
206
- }, w = function(e, t) {
207
- if (S(e)) return e.clone();
208
- var n = typeof t == "object" ? t : {};
209
- return n.date = e, n.args = arguments, new E(n);
210
- }, T = v;
211
- T.l = C, T.i = S, T.w = function(e, t) {
212
- return w(e, {
213
- locale: t.$L,
214
- utc: t.$u,
215
- x: t.$x,
216
- $offset: t.$offset
217
- });
218
- };
219
- var E = function() {
220
- function g(e) {
221
- this.$L = C(e.locale, null, !0), this.parse(e), this.$x = this.$x || e.x || {}, this[x] = !0;
222
- }
223
- var _ = g.prototype;
224
- return _.parse = function(e) {
225
- this.$d = function(e) {
226
- var t = e.date, n = e.utc;
227
- if (t === null) return /* @__PURE__ */ new Date(NaN);
228
- if (T.u(t)) return /* @__PURE__ */ new Date();
229
- if (t instanceof Date) return new Date(t);
230
- if (typeof t == "string" && !/Z$/i.test(t)) {
231
- var r = t.match(m);
232
- if (r) {
233
- var i = r[2] - 1 || 0, a = (r[7] || "0").substring(0, 3);
234
- return n ? new Date(Date.UTC(r[1], i, r[3] || 1, r[4] || 0, r[5] || 0, r[6] || 0, a)) : new Date(r[1], i, r[3] || 1, r[4] || 0, r[5] || 0, r[6] || 0, a);
235
- }
236
- }
237
- return new Date(t);
238
- }(e), this.init();
239
- }, _.init = function() {
240
- var e = this.$d;
241
- this.$y = e.getFullYear(), this.$M = e.getMonth(), this.$D = e.getDate(), this.$W = e.getDay(), this.$H = e.getHours(), this.$m = e.getMinutes(), this.$s = e.getSeconds(), this.$ms = e.getMilliseconds();
242
- }, _.$utils = function() {
243
- return T;
244
- }, _.isValid = function() {
245
- return this.$d.toString() !== p;
246
- }, _.isSame = function(e, t) {
247
- var n = w(e);
248
- return this.startOf(t) <= n && n <= this.endOf(t);
249
- }, _.isAfter = function(e, t) {
250
- return w(e) < this.startOf(t);
251
- }, _.isBefore = function(e, t) {
252
- return this.endOf(t) < w(e);
253
- }, _.$g = function(e, t, n) {
254
- return T.u(e) ? this[t] : this.set(n, e);
255
- }, _.unix = function() {
256
- return Math.floor(this.valueOf() / 1e3);
257
- }, _.valueOf = function() {
258
- return this.$d.getTime();
259
- }, _.startOf = function(e, t) {
260
- var n = this, r = !!T.u(t) || t, u = T.p(e), p = function(e, t) {
261
- var i = T.w(n.$u ? Date.UTC(n.$y, t, e) : new Date(n.$y, t, e), n);
262
- return r ? i : i.endOf(s);
263
- }, m = function(e, t) {
264
- return T.w(n.toDate()[e].apply(n.toDate("s"), (r ? [
265
- 0,
266
- 0,
267
- 0,
268
- 0
269
- ] : [
270
- 23,
271
- 59,
272
- 59,
273
- 999
274
- ]).slice(t)), n);
275
- }, h = this.$W, g = this.$M, _ = this.$D, v = "set" + (this.$u ? "UTC" : "");
276
- switch (u) {
277
- case d: return r ? p(1, 0) : p(31, 11);
278
- case l: return r ? p(1, g) : p(0, g + 1);
279
- case c:
280
- var y = this.$locale().weekStart || 0, b = (h < y ? h + 7 : h) - y;
281
- return p(r ? _ - b : _ + (6 - b), g);
282
- case s:
283
- case f: return m(v + "Hours", 0);
284
- case o: return m(v + "Minutes", 1);
285
- case a: return m(v + "Seconds", 2);
286
- case i: return m(v + "Milliseconds", 3);
287
- default: return this.clone();
288
- }
289
- }, _.endOf = function(e) {
290
- return this.startOf(e, !1);
291
- }, _.$set = function(e, t) {
292
- var n, c = T.p(e), u = "set" + (this.$u ? "UTC" : ""), p = (n = {}, n[s] = u + "Date", n[f] = u + "Date", n[l] = u + "Month", n[d] = u + "FullYear", n[o] = u + "Hours", n[a] = u + "Minutes", n[i] = u + "Seconds", n[r] = u + "Milliseconds", n)[c], m = c === s ? this.$D + (t - this.$W) : t;
293
- if (c === l || c === d) {
294
- var h = this.clone().set(f, 1);
295
- h.$d[p](m), h.init(), this.$d = h.set(f, Math.min(this.$D, h.daysInMonth())).$d;
296
- } else p && this.$d[p](m);
297
- return this.init(), this;
298
- }, _.set = function(e, t) {
299
- return this.clone().$set(e, t);
300
- }, _.get = function(e) {
301
- return this[T.p(e)]();
302
- }, _.add = function(r, u) {
303
- var f, p = this;
304
- r = Number(r);
305
- var m = T.p(u), h = function(e) {
306
- var t = w(p);
307
- return T.w(t.date(t.date() + Math.round(e * r)), p);
308
- };
309
- if (m === l) return this.set(l, this.$M + r);
310
- if (m === d) return this.set(d, this.$y + r);
311
- if (m === s) return h(1);
312
- if (m === c) return h(7);
313
- var g = (f = {}, f[a] = t, f[o] = n, f[i] = e, f)[m] || 1, _ = this.$d.getTime() + r * g;
314
- return T.w(_, this);
315
- }, _.subtract = function(e, t) {
316
- return this.add(-1 * e, t);
317
- }, _.format = function(e) {
318
- var t = this, n = this.$locale();
319
- if (!this.isValid()) return n.invalidDate || p;
320
- var r = e || "YYYY-MM-DDTHH:mm:ssZ", i = T.z(this), a = this.$H, o = this.$m, s = this.$M, c = n.weekdays, l = n.months, u = n.meridiem, d = function(e, n, i, a) {
321
- return e && (e[n] || e(t, r)) || i[n].slice(0, a);
322
- }, f = function(e) {
323
- return T.s(a % 12 || 12, e, "0");
324
- }, m = u || function(e, t, n) {
325
- var r = e < 12 ? "AM" : "PM";
326
- return n ? r.toLowerCase() : r;
327
- };
328
- return r.replace(h, (function(e, r) {
329
- return r || function(e) {
330
- switch (e) {
331
- case "YY": return String(t.$y).slice(-2);
332
- case "YYYY": return T.s(t.$y, 4, "0");
333
- case "M": return s + 1;
334
- case "MM": return T.s(s + 1, 2, "0");
335
- case "MMM": return d(n.monthsShort, s, l, 3);
336
- case "MMMM": return d(l, s);
337
- case "D": return t.$D;
338
- case "DD": return T.s(t.$D, 2, "0");
339
- case "d": return String(t.$W);
340
- case "dd": return d(n.weekdaysMin, t.$W, c, 2);
341
- case "ddd": return d(n.weekdaysShort, t.$W, c, 3);
342
- case "dddd": return c[t.$W];
343
- case "H": return String(a);
344
- case "HH": return T.s(a, 2, "0");
345
- case "h": return f(1);
346
- case "hh": return f(2);
347
- case "a": return m(a, o, !0);
348
- case "A": return m(a, o, !1);
349
- case "m": return String(o);
350
- case "mm": return T.s(o, 2, "0");
351
- case "s": return String(t.$s);
352
- case "ss": return T.s(t.$s, 2, "0");
353
- case "SSS": return T.s(t.$ms, 3, "0");
354
- case "Z": return i;
355
- }
356
- return null;
357
- }(e) || i.replace(":", "");
358
- }));
359
- }, _.utcOffset = function() {
360
- return 15 * -Math.round(this.$d.getTimezoneOffset() / 15);
361
- }, _.diff = function(r, f, p) {
362
- var m, h = this, g = T.p(f), _ = w(r), v = (_.utcOffset() - this.utcOffset()) * t, y = this - _, b = function() {
363
- return T.m(h, _);
364
- };
365
- switch (g) {
366
- case d:
367
- m = b() / 12;
368
- break;
369
- case l:
370
- m = b();
371
- break;
372
- case u:
373
- m = b() / 3;
374
- break;
375
- case c:
376
- m = (y - v) / 6048e5;
377
- break;
378
- case s:
379
- m = (y - v) / 864e5;
380
- break;
381
- case o:
382
- m = y / n;
383
- break;
384
- case a:
385
- m = y / t;
386
- break;
387
- case i:
388
- m = y / e;
389
- break;
390
- default: m = y;
391
- }
392
- return p ? m : T.a(m);
393
- }, _.daysInMonth = function() {
394
- return this.endOf(l).$D;
395
- }, _.$locale = function() {
396
- return b[this.$L];
397
- }, _.locale = function(e, t) {
398
- if (!e) return this.$L;
399
- var n = this.clone(), r = C(e, t, !0);
400
- return r && (n.$L = r), n;
401
- }, _.clone = function() {
402
- return T.w(this.$d, this);
403
- }, _.toDate = function() {
404
- return new Date(this.valueOf());
405
- }, _.toJSON = function() {
406
- return this.isValid() ? this.toISOString() : null;
407
- }, _.toISOString = function() {
408
- return this.$d.toISOString();
409
- }, _.toString = function() {
410
- return this.$d.toUTCString();
411
- }, g;
412
- }(), D = E.prototype;
413
- return w.prototype = D, [
414
- ["$ms", r],
415
- ["$s", i],
416
- ["$m", a],
417
- ["$H", o],
418
- ["$W", s],
419
- ["$M", l],
420
- ["$y", d],
421
- ["$D", f]
422
- ].forEach((function(e) {
423
- D[e[1]] = function(t) {
424
- return this.$g(t, e[0], e[1]);
425
- };
426
- })), w.extend = function(e, t) {
427
- return e.$i ||= (e(t, E, w), !0), w;
428
- }, w.locale = C, w.isDayjs = S, w.unix = function(e) {
429
- return w(1e3 * e);
430
- }, w.en = b[y], w.Ls = b, w.p = {}, w;
431
- }));
432
- })), j = /* @__PURE__ */ d(((e) => {
433
- var t = Symbol.for("react.transitional.element"), n = Symbol.for("react.fragment");
434
- function r(e, n, r) {
435
- var i = null;
436
- if (r !== void 0 && (i = "" + r), n.key !== void 0 && (i = "" + n.key), "key" in n) for (var a in r = {}, n) a !== "key" && (r[a] = n[a]);
437
- else r = n;
438
- return n = r.ref, {
439
- $$typeof: t,
440
- type: e,
441
- key: i,
442
- ref: n === void 0 ? null : n,
443
- props: r
444
- };
445
- }
446
- e.Fragment = n, e.jsx = r, e.jsxs = r;
447
- })), M = /* @__PURE__ */ d(((e) => {
448
- process.env.NODE_ENV !== "production" && (function() {
449
- function t(e) {
450
- if (e == null) return null;
451
- if (typeof e == "function") return e.$$typeof === A ? null : e.displayName || e.name || null;
452
- if (typeof e == "string") return e;
453
- switch (e) {
454
- case v: return "Fragment";
455
- case b: return "Profiler";
456
- case y: return "StrictMode";
457
- case w: return "Suspense";
458
- case T: return "SuspenseList";
459
- case O: return "Activity";
460
- case k: return "ViewTransition";
461
- }
462
- if (typeof e == "object") switch (typeof e.tag == "number" && console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), e.$$typeof) {
463
- case _: return "Portal";
464
- case S: return e.displayName || "Context";
465
- case x: return (e._context.displayName || "Context") + ".Consumer";
466
- case C:
467
- var n = e.render;
468
- return e = e.displayName, e ||= (e = n.displayName || n.name || "", e === "" ? "ForwardRef" : "ForwardRef(" + e + ")"), e;
469
- case E: return n = e.displayName || null, n === null ? t(e.type) || "Memo" : n;
470
- case D:
471
- n = e._payload, e = e._init;
472
- try {
473
- return t(e(n));
474
- } catch {}
475
- }
476
- return null;
477
- }
478
- function n(e) {
479
- return "" + e;
480
- }
481
- function r(e) {
482
- try {
483
- n(e);
484
- var t = !1;
485
- } catch {
486
- t = !0;
487
- }
488
- if (t) {
489
- t = console;
490
- var r = t.error, i = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
491
- return r.call(t, "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.", i), n(e);
492
- }
493
- }
494
- function i(e) {
495
- if (e === v) return "<>";
496
- if (typeof e == "object" && e && e.$$typeof === D) return "<...>";
497
- try {
498
- var n = t(e);
499
- return n ? "<" + n + ">" : "<...>";
500
- } catch {
501
- return "<...>";
502
- }
503
- }
504
- function a() {
505
- var e = j.A;
506
- return e === null ? null : e.getOwner();
507
- }
508
- function o() {
509
- return Error("react-stack-top-frame");
510
- }
511
- function s(e) {
512
- if (M.call(e, "key")) {
513
- var t = Object.getOwnPropertyDescriptor(e, "key").get;
514
- if (t && t.isReactWarning) return !1;
515
- }
516
- return e.key !== void 0;
517
- }
518
- function c(e, t) {
519
- function n() {
520
- F || (F = !0, console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)", t));
521
- }
522
- n.isReactWarning = !0, Object.defineProperty(e, "key", {
523
- get: n,
524
- configurable: !0
525
- });
526
- }
527
- function l() {
528
- var e = t(this.type);
529
- return I[e] || (I[e] = !0, console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")), e = this.props.ref, e === void 0 ? null : e;
530
- }
531
- function u(e, t, n, r, i, a) {
532
- var o = n.ref;
533
- return e = {
534
- $$typeof: g,
535
- type: e,
536
- key: t,
537
- props: n,
538
- _owner: r
539
- }, (o === void 0 ? null : o) === null ? Object.defineProperty(e, "ref", {
540
- enumerable: !1,
541
- value: null
542
- }) : Object.defineProperty(e, "ref", {
543
- enumerable: !1,
544
- get: l
545
- }), e._store = {}, Object.defineProperty(e._store, "validated", {
546
- configurable: !1,
547
- enumerable: !1,
548
- writable: !0,
549
- value: 0
550
- }), Object.defineProperty(e, "_debugInfo", {
551
- configurable: !1,
552
- enumerable: !1,
553
- writable: !0,
554
- value: null
555
- }), Object.defineProperty(e, "_debugStack", {
556
- configurable: !1,
557
- enumerable: !1,
558
- writable: !0,
559
- value: i
560
- }), Object.defineProperty(e, "_debugTask", {
561
- configurable: !1,
562
- enumerable: !1,
563
- writable: !0,
564
- value: a
565
- }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
566
- }
567
- function d(e, n, i, o, l, d) {
568
- var p = n.children;
569
- if (p !== void 0) {
570
- if (o) {
571
- if (N(p)) {
572
- for (o = 0; o < p.length; o++) f(p[o]);
573
- Object.freeze && Object.freeze(p);
574
- } else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
575
- } else f(p);
576
- }
577
- if (M.call(n, "key")) {
578
- p = t(e);
579
- var m = Object.keys(n).filter(function(e) {
580
- return e !== "key";
581
- });
582
- o = 0 < m.length ? "{key: someKey, " + m.join(": ..., ") + ": ...}" : "{key: someKey}", z[p + o] || (m = 0 < m.length ? "{" + m.join(": ..., ") + ": ...}" : "{}", console.error("A props object containing a \"key\" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />", o, p, m, p), z[p + o] = !0);
583
- }
584
- if (p = null, i !== void 0 && (r(i), p = "" + i), s(n) && (r(n.key), p = "" + n.key), "key" in n) for (var h in i = {}, n) h !== "key" && (i[h] = n[h]);
585
- else i = n;
586
- return p && c(i, typeof e == "function" ? e.displayName || e.name || "Unknown" : e), u(e, p, i, a(), l, d);
587
- }
588
- function f(e) {
589
- p(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e && e.$$typeof === D && (e._payload.status === "fulfilled" ? p(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
590
- }
591
- function p(e) {
592
- return typeof e == "object" && !!e && e.$$typeof === g;
593
- }
594
- var h = m("react"), g = Symbol.for("react.transitional.element"), _ = Symbol.for("react.portal"), v = Symbol.for("react.fragment"), y = Symbol.for("react.strict_mode"), b = Symbol.for("react.profiler"), x = Symbol.for("react.consumer"), S = Symbol.for("react.context"), C = Symbol.for("react.forward_ref"), w = Symbol.for("react.suspense"), T = Symbol.for("react.suspense_list"), E = Symbol.for("react.memo"), D = Symbol.for("react.lazy"), O = Symbol.for("react.activity"), k = Symbol.for("react.view_transition"), A = Symbol.for("react.client.reference"), j = h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, M = Object.prototype.hasOwnProperty, N = Array.isArray, P = console.createTask ? console.createTask : function() {
595
- return null;
596
- };
597
- h = { react_stack_bottom_frame: function(e) {
598
- return e();
599
- } };
600
- var F, I = {}, L = h.react_stack_bottom_frame.bind(h, o)(), R = P(i(o)), z = {};
601
- e.Fragment = v, e.jsx = function(e, t, n) {
602
- var r = 1e4 > j.recentlyCreatedOwnerStacks++;
603
- if (r) {
604
- var a = Error.stackTraceLimit;
605
- Error.stackTraceLimit = 10;
606
- var o = Error("react-stack-top-frame");
607
- Error.stackTraceLimit = a;
608
- } else o = L;
609
- return d(e, t, n, !1, o, r ? P(i(e)) : R);
610
- }, e.jsxs = function(e, t, n) {
611
- var r = 1e4 > j.recentlyCreatedOwnerStacks++;
612
- if (r) {
613
- var a = Error.stackTraceLimit;
614
- Error.stackTraceLimit = 10;
615
- var o = Error("react-stack-top-frame");
616
- Error.stackTraceLimit = a;
617
- } else o = L;
618
- return d(e, t, n, !0, o, r ? P(i(e)) : R);
619
- };
620
- })();
621
- })), N = /* @__PURE__ */ d(((e, t) => {
622
- t.exports = process.env.NODE_ENV === "production" ? j() : M();
623
- })), P = /* @__PURE__ */ p(A()), F = N(), I = [
1
+ import { useEffect as e, useRef as t, useState as n } from "react";
2
+ import { Bot as r, MessageCircle as i, Minimize2 as a, Send as o, Sparkles as s, User as c, X as l } from "lucide-react";
3
+ import u from "dayjs";
4
+ import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
5
+ // src/ChatWidget.tsx
6
+ var m = [
624
7
  "Check vehicle status",
625
8
  "Schedule maintenance",
626
9
  "Pricing information"
627
- ], L = [{
10
+ ], h = [{
628
11
  id: 1,
629
12
  role: "assistant",
630
13
  text: "Hello! 👋 I'm your AI assistant. How can I help you today?",
631
14
  time: "Just now"
632
15
  }];
633
- function R(e) {
16
+ function g(e) {
634
17
  let t = e.toLowerCase();
635
18
  return t.includes("vehicle") || t.includes("status") ? "I can help check vehicle status. Please provide the vehicle number plate, such as VDR6117." : t.includes("maintenance") || t.includes("repair") ? "I can help with maintenance! Please describe the vehicle issue, and I'll suggest the next steps." : t.includes("price") || t.includes("cost") ? "Pricing depends on your requirements. Tell me which service you're interested in, and I'll help estimate the cost." : t.includes("hello") || t.includes("hi") ? "Hello! 😊 What would you like help with today?" : `Thanks for your message: "${e}". This is a demo response. Configure apiUrl to connect your AI backend.`;
636
19
  }
637
- function z({ key: e, title: t = "AI Assistant", subtitle: a = "Online · Ready to help", primaryColor: o = "#2563eb" }) {
638
- let [s, c] = i(!1), [l, u] = i(!1), [d, f] = i(""), [p, m] = i(!1), [h, g] = i(L), _ = r(null), v = r(null), [y, b] = i(null);
639
- n(() => {
640
- _.current?.scrollIntoView({ behavior: "smooth" });
20
+ function _({ key: _, title: v = "AI Assistant", subtitle: y = "Online · Ready to help", primaryColor: b = "#2563eb" }) {
21
+ let [x, S] = n(!1), [C, w] = n(!1), [T, E] = n(""), [D, O] = n(!1), [k, A] = n(h), j = t(null), M = t(null), [N, P] = n(null);
22
+ e(() => {
23
+ j.current?.scrollIntoView({ behavior: "smooth" });
641
24
  }, [
642
- h,
643
- p,
644
- s,
645
- l
646
- ]), n(() => {
647
- s && !l && v.current?.focus();
648
- }, [s, l]);
649
- let x = process.env.NEXT_PUBLIC_API_URL;
650
- if (!x || !e) return "";
651
- async function S(t = d) {
652
- let n = t.trim();
653
- if (!n || p) return;
654
- let r = (0, P.default)().format("HH:mm");
655
- g((e) => [...e, {
25
+ k,
26
+ D,
27
+ x,
28
+ C
29
+ ]), e(() => {
30
+ x && !C && M.current?.focus();
31
+ }, [x, C]);
32
+ let F = process.env.NEXT_PUBLIC_API_URL;
33
+ if (!F || !_) return "";
34
+ async function I(e = T) {
35
+ let t = e.trim();
36
+ if (!t || D) return;
37
+ let n = u().format("HH:mm");
38
+ A((e) => [...e, {
656
39
  id: Date.now(),
657
40
  role: "user",
658
- text: n,
659
- time: r
660
- }]), f(""), m(!0), b(null);
41
+ text: t,
42
+ time: n
43
+ }]), E(""), O(!0), P(null);
661
44
  try {
662
- let t;
663
- if (x) {
664
- let r;
45
+ let e;
46
+ if (F) {
47
+ let n;
665
48
  try {
666
- r = await fetch(x, {
49
+ n = await fetch(F, {
667
50
  method: "POST",
668
51
  headers: { "Content-Type": "application/json" },
669
52
  body: JSON.stringify({
670
- message: n,
671
- key: e
53
+ message: t,
54
+ key: _
672
55
  })
673
56
  });
674
57
  } catch (e) {
675
- throw b("Failed to fetch.\n\nPossible Reasons:\n\n- CORS\n- Network Failure\n- URL scheme must be \"http\" or \"https\" for CORS request."), e;
58
+ throw P("Failed to fetch.\n\nPossible Reasons:\n\n- CORS\n- Network Failure\n- URL scheme must be \"http\" or \"https\" for CORS request."), e;
676
59
  }
677
- if (!r.ok) throw b(`Failed to fetch.\n\nPossible Reasons:\n\n- CORS\n- Network Failure\n- URL scheme must be "http" or "https" for CORS request.\n\nChat API returned ${r.status}`), Error(`Chat API returned ${r.status}`);
678
- let i = await r.json();
679
- t = i.reply ?? i.response ?? i.message ?? "I received a response, but it did not include a reply field.";
680
- } else await new Promise((e) => setTimeout(e, 700)), t = R(n);
681
- g((e) => [...e, {
60
+ if (!n.ok) throw P(`Failed to fetch.\n\nPossible Reasons:\n\n- CORS\n- Network Failure\n- URL scheme must be "http" or "https" for CORS request.\n\nChat API returned ${n.status}`), Error(`Chat API returned ${n.status}`);
61
+ let r = await n.json();
62
+ e = r.reply ?? r.response ?? r.message ?? "I received a response, but it did not include a reply field.";
63
+ } else await new Promise((e) => setTimeout(e, 700)), e = g(t);
64
+ A((t) => [...t, {
682
65
  id: Date.now() + 1,
683
66
  role: "assistant",
684
- text: t,
685
- time: (0, P.default)().format("HH:mm")
67
+ text: e,
68
+ time: u().format("HH:mm")
686
69
  }]);
687
70
  } catch {
688
- g((e) => [...e, {
71
+ A((e) => [...e, {
689
72
  id: Date.now() + 1,
690
73
  role: "assistant",
691
- text: y || "Sorry, I couldn't reach the chat service. Please try again.",
692
- time: (0, P.default)().format("HH:mm")
74
+ text: N || "Sorry, I couldn't reach the chat service. Please try again.",
75
+ time: u().format("HH:mm")
693
76
  }]);
694
77
  } finally {
695
- m(!1);
78
+ O(!1);
696
79
  }
697
80
  }
698
- return /* @__PURE__ */ (0, F.jsxs)("div", {
81
+ return /* @__PURE__ */ p("div", {
699
82
  className: "acw-root",
700
- style: { "--acw-primary": o },
701
- children: [s && /* @__PURE__ */ (0, F.jsxs)("section", {
702
- className: `acw-panel ${l ? "acw-minimized" : ""}`,
83
+ style: { "--acw-primary": b },
84
+ children: [x && /* @__PURE__ */ p("section", {
85
+ className: `acw-panel ${C ? "acw-minimized" : ""}`,
703
86
  "aria-label": "AI chat assistant",
704
- children: [/* @__PURE__ */ (0, F.jsxs)("header", {
87
+ children: [/* @__PURE__ */ p("header", {
705
88
  className: "acw-header",
706
89
  children: [
707
- /* @__PURE__ */ (0, F.jsx)("div", {
90
+ /* @__PURE__ */ f("div", {
708
91
  className: "acw-brand-icon",
709
- children: /* @__PURE__ */ (0, F.jsx)(C, { size: 23 })
92
+ children: /* @__PURE__ */ f(r, { size: 23 })
710
93
  }),
711
- /* @__PURE__ */ (0, F.jsxs)("div", {
94
+ /* @__PURE__ */ p("div", {
712
95
  className: "acw-heading",
713
- children: [/* @__PURE__ */ (0, F.jsx)("h2", { children: t }), /* @__PURE__ */ (0, F.jsxs)("p", { children: [/* @__PURE__ */ (0, F.jsx)("span", { className: "acw-online-dot" }), a] })]
96
+ children: [/* @__PURE__ */ f("h2", { children: v }), /* @__PURE__ */ p("p", { children: [/* @__PURE__ */ f("span", { className: "acw-online-dot" }), y] })]
714
97
  }),
715
- /* @__PURE__ */ (0, F.jsx)("button", {
98
+ /* @__PURE__ */ f("button", {
716
99
  className: "acw-header-button",
717
- onClick: () => u(!l),
100
+ onClick: () => w(!C),
718
101
  "aria-label": "Minimize chat",
719
- children: /* @__PURE__ */ (0, F.jsx)(T, { size: 17 })
102
+ children: /* @__PURE__ */ f(a, { size: 17 })
720
103
  }),
721
- /* @__PURE__ */ (0, F.jsx)("button", {
104
+ /* @__PURE__ */ f("button", {
722
105
  className: "acw-header-button",
723
- onClick: () => c(!1),
106
+ onClick: () => S(!1),
724
107
  "aria-label": "Close chat",
725
- children: /* @__PURE__ */ (0, F.jsx)(k, { size: 19 })
108
+ children: /* @__PURE__ */ f(l, { size: 19 })
726
109
  })
727
110
  ]
728
- }), !l && /* @__PURE__ */ (0, F.jsxs)(F.Fragment, { children: [
729
- /* @__PURE__ */ (0, F.jsxs)("div", {
111
+ }), !C && /* @__PURE__ */ p(d, { children: [
112
+ /* @__PURE__ */ p("div", {
730
113
  className: "acw-messages",
731
114
  children: [
732
- h.map((e, t) => /* @__PURE__ */ (0, F.jsxs)("div", {
115
+ k.map((e, t) => /* @__PURE__ */ p("div", {
733
116
  className: `acw-message-row ${e.role === "user" ? "acw-user-row" : ""}`,
734
117
  children: [
735
- e.role === "assistant" && /* @__PURE__ */ (0, F.jsx)("div", {
118
+ e.role === "assistant" && /* @__PURE__ */ f("div", {
736
119
  className: "acw-avatar acw-bot-avatar",
737
- children: /* @__PURE__ */ (0, F.jsx)(C, { size: 17 })
120
+ children: /* @__PURE__ */ f(r, { size: 17 })
738
121
  }),
739
- /* @__PURE__ */ (0, F.jsxs)("div", {
122
+ /* @__PURE__ */ p("div", {
740
123
  className: "acw-message-content",
741
- children: [/* @__PURE__ */ (0, F.jsx)("div", {
124
+ children: [/* @__PURE__ */ f("div", {
742
125
  className: `acw-bubble ${e.role === "user" ? "acw-user-bubble" : "acw-assistant-bubble"}`,
743
- children: e.text.split("\n").map((t, n) => /* @__PURE__ */ (0, F.jsxs)("span", { children: [t, n < e.text.split("\n").length - 1 && /* @__PURE__ */ (0, F.jsx)("br", {})] }, n))
744
- }), /* @__PURE__ */ (0, F.jsx)("span", {
126
+ children: e.text.split("\n").map((t, n) => /* @__PURE__ */ p("span", { children: [t, n < e.text.split("\n").length - 1 && /* @__PURE__ */ f("br", {})] }, n))
127
+ }), /* @__PURE__ */ f("span", {
745
128
  className: "acw-time",
746
129
  children: e.time
747
130
  })]
748
131
  }),
749
- e.role === "user" && /* @__PURE__ */ (0, F.jsx)("div", {
132
+ e.role === "user" && /* @__PURE__ */ f("div", {
750
133
  className: "acw-avatar acw-user-avatar",
751
- children: /* @__PURE__ */ (0, F.jsx)(O, { size: 17 })
134
+ children: /* @__PURE__ */ f(c, { size: 17 })
752
135
  })
753
136
  ]
754
137
  }, e.id)),
755
- p && /* @__PURE__ */ (0, F.jsxs)("div", {
138
+ D && /* @__PURE__ */ p("div", {
756
139
  className: "acw-message-row",
757
- children: [/* @__PURE__ */ (0, F.jsx)("div", {
140
+ children: [/* @__PURE__ */ f("div", {
758
141
  className: "acw-avatar acw-bot-avatar",
759
- children: /* @__PURE__ */ (0, F.jsx)(C, { size: 17 })
760
- }), /* @__PURE__ */ (0, F.jsxs)("div", {
142
+ children: /* @__PURE__ */ f(r, { size: 17 })
143
+ }), /* @__PURE__ */ p("div", {
761
144
  className: "acw-typing",
762
145
  "aria-label": "Assistant is typing",
763
146
  children: [
764
- /* @__PURE__ */ (0, F.jsx)("span", {}),
765
- /* @__PURE__ */ (0, F.jsx)("span", {}),
766
- /* @__PURE__ */ (0, F.jsx)("span", {})
147
+ /* @__PURE__ */ f("span", {}),
148
+ /* @__PURE__ */ f("span", {}),
149
+ /* @__PURE__ */ f("span", {})
767
150
  ]
768
151
  })]
769
152
  }),
770
- /* @__PURE__ */ (0, F.jsx)("div", { ref: _ })
153
+ /* @__PURE__ */ f("div", { ref: j })
771
154
  ]
772
155
  }),
773
- h.length === 1 && /* @__PURE__ */ (0, F.jsxs)("div", {
156
+ k.length === 1 && /* @__PURE__ */ p("div", {
774
157
  className: "acw-suggestions",
775
- children: [/* @__PURE__ */ (0, F.jsxs)("p", { children: [/* @__PURE__ */ (0, F.jsx)(D, { size: 13 }), " Suggested questions"] }), /* @__PURE__ */ (0, F.jsx)("div", {
158
+ children: [/* @__PURE__ */ p("p", { children: [/* @__PURE__ */ f(s, { size: 13 }), " Suggested questions"] }), /* @__PURE__ */ f("div", {
776
159
  className: "acw-suggestion-list",
777
- children: I.map((e) => /* @__PURE__ */ (0, F.jsx)("button", {
778
- onClick: () => void S(e),
160
+ children: m.map((e) => /* @__PURE__ */ f("button", {
161
+ onClick: () => void I(e),
779
162
  children: e
780
163
  }, e))
781
164
  })]
782
165
  }),
783
- /* @__PURE__ */ (0, F.jsxs)("form", {
166
+ /* @__PURE__ */ p("form", {
784
167
  className: "acw-composer",
785
168
  onSubmit: (e) => {
786
- e.preventDefault(), S();
169
+ e.preventDefault(), I();
787
170
  },
788
- children: [/* @__PURE__ */ (0, F.jsx)("input", {
789
- ref: v,
790
- value: d,
791
- onChange: (e) => f(e.target.value),
171
+ children: [/* @__PURE__ */ f("input", {
172
+ ref: M,
173
+ value: T,
174
+ onChange: (e) => E(e.target.value),
792
175
  placeholder: "Type your message...",
793
176
  "aria-label": "Type your message"
794
- }), /* @__PURE__ */ (0, F.jsx)("button", {
177
+ }), /* @__PURE__ */ f("button", {
795
178
  type: "submit",
796
- disabled: !d.trim() || p,
179
+ disabled: !T.trim() || D,
797
180
  "aria-label": "Send message",
798
- children: /* @__PURE__ */ (0, F.jsx)(E, { size: 18 })
181
+ children: /* @__PURE__ */ f(o, { size: 18 })
799
182
  })]
800
183
  }),
801
- /* @__PURE__ */ (0, F.jsx)("p", {
184
+ /* @__PURE__ */ f("p", {
802
185
  className: "acw-footer",
803
- children: x ? "Powered by your AI service" : "Demo mode · Connect your AI API"
186
+ children: F ? "Powered by your AI service" : "Demo mode · Connect your AI API"
804
187
  })
805
188
  ] })]
806
- }), /* @__PURE__ */ (0, F.jsxs)("button", {
189
+ }), /* @__PURE__ */ p("button", {
807
190
  className: "acw-launcher",
808
191
  onClick: () => {
809
- c(!s), u(!1);
192
+ S(!x), w(!1);
810
193
  },
811
- "aria-label": s ? "Close chat widget" : "Open chat widget",
812
- "aria-expanded": s,
813
- children: [!s && /* @__PURE__ */ (0, F.jsx)("span", { className: "acw-notification-dot" }), s ? /* @__PURE__ */ (0, F.jsx)(k, { size: 25 }) : /* @__PURE__ */ (0, F.jsx)(w, { size: 26 })]
194
+ "aria-label": x ? "Close chat widget" : "Open chat widget",
195
+ "aria-expanded": x,
196
+ children: [!x && /* @__PURE__ */ f("span", { className: "acw-notification-dot" }), x ? /* @__PURE__ */ f(l, { size: 25 }) : /* @__PURE__ */ f(i, { size: 26 })]
814
197
  })]
815
198
  });
816
199
  }
817
- export { z as ChatWidget };
200
+ export { _ as ChatWidget };
@@ -0,0 +1,2 @@
1
+ export * from '../index.js'
2
+ export {}
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "dinesh-ai-chat-widget",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "description": "Reusable floating AI chat widget for React and Next.js",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.cjs",
7
7
  "module": "./dist/index.js",
8
- "types": "./dist/index.d.ts",
8
+ "types": "./dist/types/index.d.ts",
9
9
  "exports": {
10
10
  ".": {
11
- "types": "./dist/index.d.ts",
11
+ "types": "./dist/types/index.d.ts",
12
12
  "import": "./dist/index.js",
13
13
  "require": "./dist/index.cjs"
14
14
  },
@@ -34,6 +34,8 @@
34
34
  "lucide-react": "^0.511.0"
35
35
  },
36
36
  "devDependencies": {
37
+ "react": "^19.0.0",
38
+ "react-dom": "^19.0.0",
37
39
  "@types/node": "^26.6.5",
38
40
  "@types/react": "^19.0.0",
39
41
  "@types/react-dom": "^19.0.0",
@@ -42,6 +44,7 @@
42
44
  "shx": "^0.4.0",
43
45
  "tsup": "^8.0.0",
44
46
  "typescript": "^5.9.3",
45
- "vite": "^8.3.5"
47
+ "vite": "^8.3.5",
48
+ "vite-plugin-dts": "^5.1.2"
46
49
  }
47
50
  }
File without changes