lulichat 1.0.2 → 1.0.4

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
@@ -30,6 +30,7 @@ import Lulichat from "lulichat";
30
30
  ```tsx
31
31
  import React from "react";
32
32
  import Lulichat from "lulichat";
33
+ import "lulichat/style.css";
33
34
 
34
35
  const App = () => {
35
36
  return (
@@ -0,0 +1,3 @@
1
+ import React from "react";
2
+ import { LuliChatConfig } from "../types";
3
+ export declare const LuliChat: React.FC<LuliChatConfig>;
@@ -0,0 +1,4 @@
1
+ import { LuliChat } from "./components/LuliChat";
2
+ export * from "./types";
3
+ import "./index.css";
4
+ export default LuliChat;
@@ -1,4 +1,4 @@
1
- (function(N,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("react"),require("clsx")):typeof define=="function"&&define.amd?define(["exports","react","clsx"],i):(N=typeof globalThis<"u"?globalThis:N||self,i(N.LulichatSupport={},N.React,N.clsx))})(this,function(N,i,$){"use strict";var It=Object.defineProperty;var $t=(N,i,$)=>i in N?It(N,i,{enumerable:!0,configurable:!0,writable:!0,value:$}):N[i]=$;var A=(N,i,$)=>$t(N,typeof i!="symbol"?i+"":i,$);var te={exports:{}},U={};/**
1
+ (function(i,R){typeof exports=="object"&&typeof module<"u"?module.exports=R(require("react"),require("clsx")):typeof define=="function"&&define.amd?define(["react","clsx"],R):(i=typeof globalThis<"u"?globalThis:i||self,i.LulichatSupport=R(i.React,i.clsx))})(this,function(i,R){"use strict";var At=Object.defineProperty;var Mt=(i,R,M)=>R in i?At(i,R,{enumerable:!0,configurable:!0,writable:!0,value:M}):i[R]=M;var F=(i,R,M)=>Mt(i,typeof R!="symbol"?R+"":R,M);var M={exports:{}},U={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var ue;function Ye(){if(ue)return U;ue=1;var s=i,o=Symbol.for("react.element"),u=Symbol.for("react.fragment"),l=Object.prototype.hasOwnProperty,p=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,h={key:!0,ref:!0,__self:!0,__source:!0};function b(j,d,m){var g,S={},_=null,O=null;m!==void 0&&(_=""+m),d.key!==void 0&&(_=""+d.key),d.ref!==void 0&&(O=d.ref);for(g in d)l.call(d,g)&&!h.hasOwnProperty(g)&&(S[g]=d[g]);if(j&&j.defaultProps)for(g in d=j.defaultProps,d)S[g]===void 0&&(S[g]=d[g]);return{$$typeof:o,type:j,key:_,ref:O,props:S,_owner:p.current}}return U.Fragment=u,U.jsx=b,U.jsxs=b,U}var H={};/**
9
+ */var ce;function ze(){if(ce)return U;ce=1;var s=i,o=Symbol.for("react.element"),u=Symbol.for("react.fragment"),l=Object.prototype.hasOwnProperty,p=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,h={key:!0,ref:!0,__self:!0,__source:!0};function b(j,f,m){var g,S={},_=null,O=null;m!==void 0&&(_=""+m),f.key!==void 0&&(_=""+f.key),f.ref!==void 0&&(O=f.ref);for(g in f)l.call(f,g)&&!h.hasOwnProperty(g)&&(S[g]=f[g]);if(j&&j.defaultProps)for(g in f=j.defaultProps,f)S[g]===void 0&&(S[g]=f[g]);return{$$typeof:o,type:j,key:_,ref:O,props:S,_owner:p.current}}return U.Fragment=u,U.jsx=b,U.jsxs=b,U}var H={};/**
10
10
  * @license React
11
11
  * react-jsx-runtime.development.js
12
12
  *
@@ -14,17 +14,17 @@
14
14
  *
15
15
  * This source code is licensed under the MIT license found in the
16
16
  * LICENSE file in the root directory of this source tree.
17
- */var de;function qe(){return de||(de=1,process.env.NODE_ENV!=="production"&&function(){var s=i,o=Symbol.for("react.element"),u=Symbol.for("react.portal"),l=Symbol.for("react.fragment"),p=Symbol.for("react.strict_mode"),h=Symbol.for("react.profiler"),b=Symbol.for("react.provider"),j=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),g=Symbol.for("react.suspense_list"),S=Symbol.for("react.memo"),_=Symbol.for("react.lazy"),O=Symbol.for("react.offscreen"),M=Symbol.iterator,D="@@iterator";function w(e){if(e===null||typeof e!="object")return null;var r=M&&e[M]||e[D];return typeof r=="function"?r:null}var P=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function a(e){{for(var r=arguments.length,n=new Array(r>1?r-1:0),c=1;c<r;c++)n[c-1]=arguments[c];k("error",e,n)}}function k(e,r,n){{var c=P.ReactDebugCurrentFrame,x=c.getStackAddendum();x!==""&&(r+="%s",n=n.concat([x]));var y=n.map(function(v){return String(v)});y.unshift("Warning: "+r),Function.prototype.apply.call(console[e],console,y)}}var L=!1,st=!1,at=!1,ot=!1,it=!1,ye;ye=Symbol.for("react.module.reference");function lt(e){return!!(typeof e=="string"||typeof e=="function"||e===l||e===h||it||e===p||e===m||e===g||ot||e===O||L||st||at||typeof e=="object"&&e!==null&&(e.$$typeof===_||e.$$typeof===S||e.$$typeof===b||e.$$typeof===j||e.$$typeof===d||e.$$typeof===ye||e.getModuleId!==void 0))}function ct(e,r,n){var c=e.displayName;if(c)return c;var x=r.displayName||r.name||"";return x!==""?n+"("+x+")":n}function be(e){return e.displayName||"Context"}function I(e){if(e==null)return null;if(typeof e.tag=="number"&&a("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case l:return"Fragment";case u:return"Portal";case h:return"Profiler";case p:return"StrictMode";case m:return"Suspense";case g:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case j:var r=e;return be(r)+".Consumer";case b:var n=e;return be(n._context)+".Provider";case d:return ct(e,e.render,"ForwardRef");case S:var c=e.displayName||null;return c!==null?c:I(e.type)||"Memo";case _:{var x=e,y=x._payload,v=x._init;try{return I(v(y))}catch{return null}}}return null}var V=Object.assign,J=0,je,we,ke,Ce,Ee,Se,_e;function Ne(){}Ne.__reactDisabledLog=!0;function ut(){{if(J===0){je=console.log,we=console.info,ke=console.warn,Ce=console.error,Ee=console.group,Se=console.groupCollapsed,_e=console.groupEnd;var e={configurable:!0,enumerable:!0,value:Ne,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}J++}}function dt(){{if(J--,J===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:V({},e,{value:je}),info:V({},e,{value:we}),warn:V({},e,{value:ke}),error:V({},e,{value:Ce}),group:V({},e,{value:Ee}),groupCollapsed:V({},e,{value:Se}),groupEnd:V({},e,{value:_e})})}J<0&&a("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var re=P.ReactCurrentDispatcher,ne;function Z(e,r,n){{if(ne===void 0)try{throw Error()}catch(x){var c=x.stack.trim().match(/\n( *(at )?)/);ne=c&&c[1]||""}return`
18
- `+ne+e}}var se=!1,X;{var ft=typeof WeakMap=="function"?WeakMap:Map;X=new ft}function Te(e,r){if(!e||se)return"";{var n=X.get(e);if(n!==void 0)return n}var c;se=!0;var x=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var y;y=re.current,re.current=null,ut();try{if(r){var v=function(){throw Error()};if(Object.defineProperty(v.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(v,[])}catch(R){c=R}Reflect.construct(e,[],v)}else{try{v.call()}catch(R){c=R}e.call(v.prototype)}}else{try{throw Error()}catch(R){c=R}e()}}catch(R){if(R&&c&&typeof R.stack=="string"){for(var f=R.stack.split(`
19
- `),T=c.stack.split(`
20
- `),C=f.length-1,E=T.length-1;C>=1&&E>=0&&f[C]!==T[E];)E--;for(;C>=1&&E>=0;C--,E--)if(f[C]!==T[E]){if(C!==1||E!==1)do if(C--,E--,E<0||f[C]!==T[E]){var F=`
21
- `+f[C].replace(" at new "," at ");return e.displayName&&F.includes("<anonymous>")&&(F=F.replace("<anonymous>",e.displayName)),typeof e=="function"&&X.set(e,F),F}while(C>=1&&E>=0);break}}}finally{se=!1,re.current=y,dt(),Error.prepareStackTrace=x}var q=e?e.displayName||e.name:"",W=q?Z(q):"";return typeof e=="function"&&X.set(e,W),W}function ht(e,r,n){return Te(e,!1)}function mt(e){var r=e.prototype;return!!(r&&r.isReactComponent)}function Q(e,r,n){if(e==null)return"";if(typeof e=="function")return Te(e,mt(e));if(typeof e=="string")return Z(e);switch(e){case m:return Z("Suspense");case g:return Z("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case d:return ht(e.render);case S:return Q(e.type,r,n);case _:{var c=e,x=c._payload,y=c._init;try{return Q(y(x),r,n)}catch{}}}return""}var K=Object.prototype.hasOwnProperty,Re={},Oe=P.ReactDebugCurrentFrame;function ee(e){if(e){var r=e._owner,n=Q(e.type,e._source,r?r.type:null);Oe.setExtraStackFrame(n)}else Oe.setExtraStackFrame(null)}function vt(e,r,n,c,x){{var y=Function.call.bind(K);for(var v in e)if(y(e,v)){var f=void 0;try{if(typeof e[v]!="function"){var T=Error((c||"React class")+": "+n+" type `"+v+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[v]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw T.name="Invariant Violation",T}f=e[v](r,v,c,n,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(C){f=C}f&&!(f instanceof Error)&&(ee(x),a("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",c||"React class",n,v,typeof f),ee(null)),f instanceof Error&&!(f.message in Re)&&(Re[f.message]=!0,ee(x),a("Failed %s type: %s",n,f.message),ee(null))}}}var pt=Array.isArray;function ae(e){return pt(e)}function gt(e){{var r=typeof Symbol=="function"&&Symbol.toStringTag,n=r&&e[Symbol.toStringTag]||e.constructor.name||"Object";return n}}function xt(e){try{return Pe(e),!1}catch{return!0}}function Pe(e){return""+e}function Fe(e){if(xt(e))return a("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",gt(e)),Pe(e)}var Ae=P.ReactCurrentOwner,yt={key:!0,ref:!0,__self:!0,__source:!0},Me,De;function bt(e){if(K.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return e.ref!==void 0}function jt(e){if(K.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function wt(e,r){typeof e.ref=="string"&&Ae.current}function kt(e,r){{var n=function(){Me||(Me=!0,a("%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://reactjs.org/link/special-props)",r))};n.isReactWarning=!0,Object.defineProperty(e,"key",{get:n,configurable:!0})}}function Ct(e,r){{var n=function(){De||(De=!0,a("%s: `ref` 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://reactjs.org/link/special-props)",r))};n.isReactWarning=!0,Object.defineProperty(e,"ref",{get:n,configurable:!0})}}var Et=function(e,r,n,c,x,y,v){var f={$$typeof:o,type:e,key:r,ref:n,props:v,_owner:y};return f._store={},Object.defineProperty(f._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(f,"_self",{configurable:!1,enumerable:!1,writable:!1,value:c}),Object.defineProperty(f,"_source",{configurable:!1,enumerable:!1,writable:!1,value:x}),Object.freeze&&(Object.freeze(f.props),Object.freeze(f)),f};function St(e,r,n,c,x){{var y,v={},f=null,T=null;n!==void 0&&(Fe(n),f=""+n),jt(r)&&(Fe(r.key),f=""+r.key),bt(r)&&(T=r.ref,wt(r,x));for(y in r)K.call(r,y)&&!yt.hasOwnProperty(y)&&(v[y]=r[y]);if(e&&e.defaultProps){var C=e.defaultProps;for(y in C)v[y]===void 0&&(v[y]=C[y])}if(f||T){var E=typeof e=="function"?e.displayName||e.name||"Unknown":e;f&&kt(v,E),T&&Ct(v,E)}return Et(e,f,T,x,c,Ae.current,v)}}var oe=P.ReactCurrentOwner,Ie=P.ReactDebugCurrentFrame;function Y(e){if(e){var r=e._owner,n=Q(e.type,e._source,r?r.type:null);Ie.setExtraStackFrame(n)}else Ie.setExtraStackFrame(null)}var ie;ie=!1;function le(e){return typeof e=="object"&&e!==null&&e.$$typeof===o}function $e(){{if(oe.current){var e=I(oe.current.type);if(e)return`
17
+ */var ue;function Ve(){return ue||(ue=1,process.env.NODE_ENV!=="production"&&function(){var s=i,o=Symbol.for("react.element"),u=Symbol.for("react.portal"),l=Symbol.for("react.fragment"),p=Symbol.for("react.strict_mode"),h=Symbol.for("react.profiler"),b=Symbol.for("react.provider"),j=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),g=Symbol.for("react.suspense_list"),S=Symbol.for("react.memo"),_=Symbol.for("react.lazy"),O=Symbol.for("react.offscreen"),A=Symbol.iterator,I="@@iterator";function w(e){if(e===null||typeof e!="object")return null;var r=A&&e[A]||e[I];return typeof r=="function"?r:null}var D=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function a(e){{for(var r=arguments.length,n=new Array(r>1?r-1:0),c=1;c<r;c++)n[c-1]=arguments[c];k("error",e,n)}}function k(e,r,n){{var c=D.ReactDebugCurrentFrame,x=c.getStackAddendum();x!==""&&(r+="%s",n=n.concat([x]));var y=n.map(function(v){return String(v)});y.unshift("Warning: "+r),Function.prototype.apply.call(console[e],console,y)}}var W=!1,rt=!1,nt=!1,st=!1,at=!1,pe;pe=Symbol.for("react.module.reference");function ot(e){return!!(typeof e=="string"||typeof e=="function"||e===l||e===h||at||e===p||e===m||e===g||st||e===O||W||rt||nt||typeof e=="object"&&e!==null&&(e.$$typeof===_||e.$$typeof===S||e.$$typeof===b||e.$$typeof===j||e.$$typeof===f||e.$$typeof===pe||e.getModuleId!==void 0))}function it(e,r,n){var c=e.displayName;if(c)return c;var x=r.displayName||r.name||"";return x!==""?n+"("+x+")":n}function ge(e){return e.displayName||"Context"}function L(e){if(e==null)return null;if(typeof e.tag=="number"&&a("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case l:return"Fragment";case u:return"Portal";case h:return"Profiler";case p:return"StrictMode";case m:return"Suspense";case g:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case j:var r=e;return ge(r)+".Consumer";case b:var n=e;return ge(n._context)+".Provider";case f:return it(e,e.render,"ForwardRef");case S:var c=e.displayName||null;return c!==null?c:L(e.type)||"Memo";case _:{var x=e,y=x._payload,v=x._init;try{return L(v(y))}catch{return null}}}return null}var z=Object.assign,J=0,xe,ye,be,je,we,ke,Ce;function Ee(){}Ee.__reactDisabledLog=!0;function lt(){{if(J===0){xe=console.log,ye=console.info,be=console.warn,je=console.error,we=console.group,ke=console.groupCollapsed,Ce=console.groupEnd;var e={configurable:!0,enumerable:!0,value:Ee,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}J++}}function ct(){{if(J--,J===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:z({},e,{value:xe}),info:z({},e,{value:ye}),warn:z({},e,{value:be}),error:z({},e,{value:je}),group:z({},e,{value:we}),groupCollapsed:z({},e,{value:ke}),groupEnd:z({},e,{value:Ce})})}J<0&&a("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var te=D.ReactCurrentDispatcher,re;function Z(e,r,n){{if(re===void 0)try{throw Error()}catch(x){var c=x.stack.trim().match(/\n( *(at )?)/);re=c&&c[1]||""}return`
18
+ `+re+e}}var ne=!1,X;{var ut=typeof WeakMap=="function"?WeakMap:Map;X=new ut}function Se(e,r){if(!e||ne)return"";{var n=X.get(e);if(n!==void 0)return n}var c;ne=!0;var x=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var y;y=te.current,te.current=null,lt();try{if(r){var v=function(){throw Error()};if(Object.defineProperty(v.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(v,[])}catch(T){c=T}Reflect.construct(e,[],v)}else{try{v.call()}catch(T){c=T}e.call(v.prototype)}}else{try{throw Error()}catch(T){c=T}e()}}catch(T){if(T&&c&&typeof T.stack=="string"){for(var d=T.stack.split(`
19
+ `),N=c.stack.split(`
20
+ `),C=d.length-1,E=N.length-1;C>=1&&E>=0&&d[C]!==N[E];)E--;for(;C>=1&&E>=0;C--,E--)if(d[C]!==N[E]){if(C!==1||E!==1)do if(C--,E--,E<0||d[C]!==N[E]){var P=`
21
+ `+d[C].replace(" at new "," at ");return e.displayName&&P.includes("<anonymous>")&&(P=P.replace("<anonymous>",e.displayName)),typeof e=="function"&&X.set(e,P),P}while(C>=1&&E>=0);break}}}finally{ne=!1,te.current=y,ct(),Error.prepareStackTrace=x}var q=e?e.displayName||e.name:"",V=q?Z(q):"";return typeof e=="function"&&X.set(e,V),V}function ft(e,r,n){return Se(e,!1)}function dt(e){var r=e.prototype;return!!(r&&r.isReactComponent)}function Q(e,r,n){if(e==null)return"";if(typeof e=="function")return Se(e,dt(e));if(typeof e=="string")return Z(e);switch(e){case m:return Z("Suspense");case g:return Z("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case f:return ft(e.render);case S:return Q(e.type,r,n);case _:{var c=e,x=c._payload,y=c._init;try{return Q(y(x),r,n)}catch{}}}return""}var K=Object.prototype.hasOwnProperty,_e={},Ne=D.ReactDebugCurrentFrame;function ee(e){if(e){var r=e._owner,n=Q(e.type,e._source,r?r.type:null);Ne.setExtraStackFrame(n)}else Ne.setExtraStackFrame(null)}function ht(e,r,n,c,x){{var y=Function.call.bind(K);for(var v in e)if(y(e,v)){var d=void 0;try{if(typeof e[v]!="function"){var N=Error((c||"React class")+": "+n+" type `"+v+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[v]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw N.name="Invariant Violation",N}d=e[v](r,v,c,n,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(C){d=C}d&&!(d instanceof Error)&&(ee(x),a("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",c||"React class",n,v,typeof d),ee(null)),d instanceof Error&&!(d.message in _e)&&(_e[d.message]=!0,ee(x),a("Failed %s type: %s",n,d.message),ee(null))}}}var mt=Array.isArray;function se(e){return mt(e)}function vt(e){{var r=typeof Symbol=="function"&&Symbol.toStringTag,n=r&&e[Symbol.toStringTag]||e.constructor.name||"Object";return n}}function pt(e){try{return Re(e),!1}catch{return!0}}function Re(e){return""+e}function Te(e){if(pt(e))return a("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",vt(e)),Re(e)}var Oe=D.ReactCurrentOwner,gt={key:!0,ref:!0,__self:!0,__source:!0},De,Pe;function xt(e){if(K.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return e.ref!==void 0}function yt(e){if(K.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function bt(e,r){typeof e.ref=="string"&&Oe.current}function jt(e,r){{var n=function(){De||(De=!0,a("%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://reactjs.org/link/special-props)",r))};n.isReactWarning=!0,Object.defineProperty(e,"key",{get:n,configurable:!0})}}function wt(e,r){{var n=function(){Pe||(Pe=!0,a("%s: `ref` 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://reactjs.org/link/special-props)",r))};n.isReactWarning=!0,Object.defineProperty(e,"ref",{get:n,configurable:!0})}}var kt=function(e,r,n,c,x,y,v){var d={$$typeof:o,type:e,key:r,ref:n,props:v,_owner:y};return d._store={},Object.defineProperty(d._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(d,"_self",{configurable:!1,enumerable:!1,writable:!1,value:c}),Object.defineProperty(d,"_source",{configurable:!1,enumerable:!1,writable:!1,value:x}),Object.freeze&&(Object.freeze(d.props),Object.freeze(d)),d};function Ct(e,r,n,c,x){{var y,v={},d=null,N=null;n!==void 0&&(Te(n),d=""+n),yt(r)&&(Te(r.key),d=""+r.key),xt(r)&&(N=r.ref,bt(r,x));for(y in r)K.call(r,y)&&!gt.hasOwnProperty(y)&&(v[y]=r[y]);if(e&&e.defaultProps){var C=e.defaultProps;for(y in C)v[y]===void 0&&(v[y]=C[y])}if(d||N){var E=typeof e=="function"?e.displayName||e.name||"Unknown":e;d&&jt(v,E),N&&wt(v,E)}return kt(e,d,N,x,c,Oe.current,v)}}var ae=D.ReactCurrentOwner,Fe=D.ReactDebugCurrentFrame;function Y(e){if(e){var r=e._owner,n=Q(e.type,e._source,r?r.type:null);Fe.setExtraStackFrame(n)}else Fe.setExtraStackFrame(null)}var oe;oe=!1;function ie(e){return typeof e=="object"&&e!==null&&e.$$typeof===o}function Ae(){{if(ae.current){var e=L(ae.current.type);if(e)return`
22
22
 
23
- Check the render method of \``+e+"`."}return""}}function _t(e){return""}var ze={};function Nt(e){{var r=$e();if(!r){var n=typeof e=="string"?e:e.displayName||e.name;n&&(r=`
23
+ Check the render method of \``+e+"`."}return""}}function Et(e){return""}var Me={};function St(e){{var r=Ae();if(!r){var n=typeof e=="string"?e:e.displayName||e.name;n&&(r=`
24
24
 
25
- Check the top-level render call using <`+n+">.")}return r}}function Le(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var n=Nt(r);if(ze[n])return;ze[n]=!0;var c="";e&&e._owner&&e._owner!==oe.current&&(c=" It was passed a child from "+I(e._owner.type)+"."),Y(e),a('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',n,c),Y(null)}}function Ve(e,r){{if(typeof e!="object")return;if(ae(e))for(var n=0;n<e.length;n++){var c=e[n];le(c)&&Le(c,r)}else if(le(e))e._store&&(e._store.validated=!0);else if(e){var x=w(e);if(typeof x=="function"&&x!==e.entries)for(var y=x.call(e),v;!(v=y.next()).done;)le(v.value)&&Le(v.value,r)}}}function Tt(e){{var r=e.type;if(r==null||typeof r=="string")return;var n;if(typeof r=="function")n=r.propTypes;else if(typeof r=="object"&&(r.$$typeof===d||r.$$typeof===S))n=r.propTypes;else return;if(n){var c=I(r);vt(n,e.props,"prop",c,e)}else if(r.PropTypes!==void 0&&!ie){ie=!0;var x=I(r);a("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",x||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&a("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Rt(e){{for(var r=Object.keys(e.props),n=0;n<r.length;n++){var c=r[n];if(c!=="children"&&c!=="key"){Y(e),a("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",c),Y(null);break}}e.ref!==null&&(Y(e),a("Invalid attribute `ref` supplied to `React.Fragment`."),Y(null))}}var We={};function Be(e,r,n,c,x,y){{var v=lt(e);if(!v){var f="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(f+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var T=_t();T?f+=T:f+=$e();var C;e===null?C="null":ae(e)?C="array":e!==void 0&&e.$$typeof===o?(C="<"+(I(e.type)||"Unknown")+" />",f=" Did you accidentally export a JSX literal instead of a component?"):C=typeof e,a("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",C,f)}var E=St(e,r,n,x,y);if(E==null)return E;if(v){var F=r.children;if(F!==void 0)if(c)if(ae(F)){for(var q=0;q<F.length;q++)Ve(F[q],e);Object.freeze&&Object.freeze(F)}else a("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 Ve(F,e)}if(K.call(r,"key")){var W=I(e),R=Object.keys(r).filter(function(Dt){return Dt!=="key"}),ce=R.length>0?"{key: someKey, "+R.join(": ..., ")+": ...}":"{key: someKey}";if(!We[W+ce]){var Mt=R.length>0?"{"+R.join(": ..., ")+": ...}":"{}";a(`A props object containing a "key" prop is being spread into JSX:
25
+ Check the top-level render call using <`+n+">.")}return r}}function Ie(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var n=St(r);if(Me[n])return;Me[n]=!0;var c="";e&&e._owner&&e._owner!==ae.current&&(c=" It was passed a child from "+L(e._owner.type)+"."),Y(e),a('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',n,c),Y(null)}}function Le(e,r){{if(typeof e!="object")return;if(se(e))for(var n=0;n<e.length;n++){var c=e[n];ie(c)&&Ie(c,r)}else if(ie(e))e._store&&(e._store.validated=!0);else if(e){var x=w(e);if(typeof x=="function"&&x!==e.entries)for(var y=x.call(e),v;!(v=y.next()).done;)ie(v.value)&&Ie(v.value,r)}}}function _t(e){{var r=e.type;if(r==null||typeof r=="string")return;var n;if(typeof r=="function")n=r.propTypes;else if(typeof r=="object"&&(r.$$typeof===f||r.$$typeof===S))n=r.propTypes;else return;if(n){var c=L(r);ht(n,e.props,"prop",c,e)}else if(r.PropTypes!==void 0&&!oe){oe=!0;var x=L(r);a("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",x||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&a("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Nt(e){{for(var r=Object.keys(e.props),n=0;n<r.length;n++){var c=r[n];if(c!=="children"&&c!=="key"){Y(e),a("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",c),Y(null);break}}e.ref!==null&&(Y(e),a("Invalid attribute `ref` supplied to `React.Fragment`."),Y(null))}}var $e={};function We(e,r,n,c,x,y){{var v=ot(e);if(!v){var d="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(d+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var N=Et();N?d+=N:d+=Ae();var C;e===null?C="null":se(e)?C="array":e!==void 0&&e.$$typeof===o?(C="<"+(L(e.type)||"Unknown")+" />",d=" Did you accidentally export a JSX literal instead of a component?"):C=typeof e,a("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",C,d)}var E=Ct(e,r,n,x,y);if(E==null)return E;if(v){var P=r.children;if(P!==void 0)if(c)if(se(P)){for(var q=0;q<P.length;q++)Le(P[q],e);Object.freeze&&Object.freeze(P)}else a("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 Le(P,e)}if(K.call(r,"key")){var V=L(e),T=Object.keys(r).filter(function(Ft){return Ft!=="key"}),le=T.length>0?"{key: someKey, "+T.join(": ..., ")+": ...}":"{key: someKey}";if(!$e[V+le]){var Pt=T.length>0?"{"+T.join(": ..., ")+": ...}":"{}";a(`A props object containing a "key" prop is being spread into JSX:
26
26
  let props = %s;
27
27
  <%s {...props} />
28
28
  React keys must be passed directly to JSX without using spread:
29
29
  let props = %s;
30
- <%s key={someKey} {...props} />`,ce,W,Mt,W),We[W+ce]=!0}}return e===l?Rt(E):Tt(E),E}}function Ot(e,r,n){return Be(e,r,n,!0)}function Pt(e,r,n){return Be(e,r,n,!1)}var Ft=Pt,At=Ot;H.Fragment=l,H.jsx=Ft,H.jsxs=At}()),H}process.env.NODE_ENV==="production"?te.exports=Ye():te.exports=qe();var t=te.exports;class fe{constructor(o){A(this,"config");A(this,"baseUrl");this.config=o,this.baseUrl=o.baseUrl||"http://localhost:8000"}async getCompanyInfo(){try{const o=await fetch(`${this.baseUrl}/companies/e/info`,{headers:{Authorization:`Bearer ${this.config.apiKey}`,"Content-Type":"application/json"}});if(!o.ok)throw new Error(`HTTP error! status: ${o.status}`);return await o.json()}catch(o){throw console.error("Failed to fetch company info:",o),o}}async submitContactInfo(o){try{const u=await fetch(`${this.baseUrl}/companies/e/chat/init`,{method:"POST",headers:{Authorization:`Bearer ${this.config.apiKey}`,"Content-Type":"application/json"},body:JSON.stringify(o||{})});if(!u.ok)throw new Error(`HTTP error! status: ${u.status}`);return await u.json()}catch(u){throw console.error("Failed to submit contact info:",u),u}}async startAnonymousChat(){return this.submitContactInfo()}}function he(...s){return $.clsx(s)}const G=i.forwardRef((s,o)=>t.jsx("input",{...s,autoComplete:s.autoComplete||s.name||"off",ref:o,className:he("lulichat-input",s.className)}));i.forwardRef((s,o)=>t.jsx("input",{className:"",...s,ref:o}));const me=i.createContext(void 0),B=i.forwardRef(({children:s,onValuesChange:o,initialValues:u,...l},p)=>{const h=i.useRef(u||{}),b=i.useRef(null),j=i.useCallback((m,g)=>{h.current[m]=g,o&&o({...h.current})},[o]),d={getValues:()=>h.current,getFieldValue:m=>{var g;return(g=h.current)==null?void 0:g[m]},elementRef:()=>b.current,setFieldValue:j};return i.useImperativeHandle(p,()=>d),t.jsx(me.Provider,{value:d,children:t.jsx("form",{...l,ref:b,onSubmit:l.onSubmit,children:s})})}),Ue=i.forwardRef(({name:s,children:o,...u},l)=>{const p=i.useContext(me),h=function(d){var m,g;p&&s&&p.setFieldValue(s,d.target.value),(g=(m=this.props).onChange)==null||g.call(m,d)},b=i.Children.map(o,d=>{if(i.isValidElement(d)&&s&&d.type===G){let m=d;return i.cloneElement(m,{...m.props,name:s,value:(p==null?void 0:p.getFieldValue(s))??"",onChange:h.bind(m),required:u.required})}return d}),j=Object.create(u);return delete j.required,delete j.label,t.jsxs("div",{className:"lulichat-form-item",ref:l,...j,children:[u.label&&t.jsx(ve,{htmlFor:s,required:u.required,children:u.label}),b,u.error&&t.jsx("p",{className:"error",children:u.error})]})}),ve=i.forwardRef((s,o)=>{const u=s.required,l=s.children;return t.jsxs("label",{...s,className:he("lulichat-form-label",s.className),ref:o,children:[l,u&&t.jsx("b",{style:{color:"red"},children:"*"})]})}),He=s=>{const o=i.useRef(s||{}),u=i.useRef(null),l=i.useCallback((h,b)=>{o.current[h]=b},[]);return[{getValues:()=>o.current,getFieldValue:h=>{var b;return(b=o.current)==null?void 0:b[h]},elementRef:()=>u.current,setFieldValue:l}]};B.Item=Ue,B.Label=ve,B.useForm=He;const Je=s=>t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 18 18",...s,children:t.jsx("path",{fill:"none",stroke:"currentColor","stroke-dasharray":"10","stroke-dashoffset":"10","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 15l-5 -5M12 15l5 -5",children:t.jsx("animate",{fill:"freeze",attributeName:"stroke-dashoffset",dur:"0.3s",values:"10;0"})})}),Ke=s=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 24 24",...s,children:[t.jsx("mask",{id:"lineMdFileDocumentFilled0",children:t.jsxs("g",{fill:"none",stroke:"#fff","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",children:[t.jsxs("path",{fill:"#fff","fill-opacity":"0","stroke-dasharray":"64","stroke-dashoffset":"64",d:"M13.5 3l5.5 5.5v11.5c0 0.55 -0.45 1 -1 1h-12c-0.55 0 -1 -0.45 -1 -1v-16c0 -0.55 0.45 -1 1 -1Z",children:[t.jsx("animate",{fill:"freeze",attributeName:"fill-opacity",begin:"0.6s",dur:"0.5s",values:"0;1"}),t.jsx("animate",{fill:"freeze",attributeName:"stroke-dashoffset",dur:"0.6s",values:"64;0"})]}),t.jsx("path",{fill:"#000",stroke:"#000",d:"M14.5 3.5l0 4.5l4.5 0z",opacity:"0",children:t.jsx("set",{fill:"freeze",attributeName:"opacity",begin:"0.6s",to:"1"})}),t.jsx("path",{d:"M13.5 3l5.5 5.5",opacity:"0",children:t.jsx("set",{fill:"freeze",attributeName:"opacity",begin:"0.6s",to:"1"})}),t.jsx("path",{stroke:"#000","stroke-dasharray":"12","stroke-dashoffset":"12",d:"M7 13h10",children:t.jsx("animate",{fill:"freeze",attributeName:"stroke-dashoffset",begin:"1.1s",dur:"0.2s",values:"12;0"})}),t.jsx("path",{stroke:"#000","stroke-dasharray":"8","stroke-dashoffset":"8",d:"M7 17h7",children:t.jsx("animate",{fill:"freeze",attributeName:"stroke-dashoffset",begin:"1.3s",dur:"0.2s",values:"8;0"})})]})}),t.jsx("rect",{width:"24",height:"24",fill:"currentColor",mask:"url(#lineMdFileDocumentFilled0)"})]}),Ge=s=>t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 22 22",...s,children:t.jsx("path",{fill:"currentColor",d:"M1.5 4v1.5c0 4.15 2.21 7.78 5.5 9.8V20h15v-2c0-2.66-5.33-4-8-4h-.25C9 14 5 10 5 5.5V4m9 0a4 4 0 0 0-4 4a4 4 0 0 0 4 4a4 4 0 0 0 4-4a4 4 0 0 0-4-4"})}),Ze=s=>t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",...s,children:t.jsx("path",{fill:"currentColor",d:"M12 2.25A9.75 9.75 0 0 0 2.25 12v5q0 .04.004.08v.05c-.003 1.278.602 2.682 1.963 3.25l.071.03c.11.044.22.12.362.25c.07.064.138.132.22.213l.008.008c.08.08.175.175.277.265c.204.183.474.388.83.506c.37.122.77.131 1.208.022c.723-.18 1.266-.752 1.469-1.454c.089-.309.089-.668.088-1.084v-4.094c0-.285 0-.528-.01-.728a2.3 2.3 0 0 0-.107-.627c-.23-.683-.786-1.223-1.504-1.377a2.25 2.25 0 0 0-1.264.065c-.37.133-.652.354-.87.558c-.12.11-.269.267-.391.396l-.164.17a1.8 1.8 0 0 1-.427.338q-.136.07-.263.152V12a8.25 8.25 0 1 1 16.5 0v1.864a3 3 0 0 0-.538-.274a1.2 1.2 0 0 1-.362-.25c-.07-.064-.138-.132-.22-.213l-.008-.008a7 7 0 0 0-.277-.265a2.4 2.4 0 0 0-.83-.506q-.553-.184-1.208-.022c-.723.18-1.266.752-1.469 1.454c-.089.309-.088.668-.088 1.085v4.093c0 .285 0 .528.01.728c.012.208.037.418.107.627c.23.683.786 1.223 1.504 1.377c.463.1.883.073 1.264-.065c.37-.133.652-.354.87-.558c.12-.11.269-.267.391-.395c.065-.069.123-.13.164-.17a1.8 1.8 0 0 1 .427-.34c1.11-.573 1.755-1.724 1.758-2.936v-.143L21.75 17v-5A9.75 9.75 0 0 0 12 2.25"})}),Xe=s=>t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",...s,children:t.jsxs("g",{fill:"none",stroke:"currentColor","stroke-dasharray":"28","stroke-dashoffset":"28","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",children:[t.jsx("path",{d:"M4 21v-1c0 -3.31 2.69 -6 6 -6h4c3.31 0 6 2.69 6 6v1",children:t.jsx("animate",{fill:"freeze",attributeName:"stroke-dashoffset",dur:"0.4s",values:"28;0"})}),t.jsx("path",{d:"M12 11c-2.21 0 -4 -1.79 -4 -4c0 -2.21 1.79 -4 4 -4c2.21 0 4 1.79 4 4c0 2.21 -1.79 4 -4 4Z",children:t.jsx("animate",{fill:"freeze",attributeName:"stroke-dashoffset",begin:"0.4s",dur:"0.4s",values:"28;0"})})]})}),pe=()=>t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",children:t.jsx("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",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.11zm7.318-19.539l-10.94 10.939"})}),ge=s=>t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",...s,children:t.jsxs("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",children:[t.jsxs("path",{"stroke-dasharray":"16","stroke-dashoffset":"16",d:"M12 3c4.97 0 9 4.03 9 9",children:[t.jsx("animate",{fill:"freeze",attributeName:"stroke-dashoffset",dur:"0.3s",values:"16;0"}),t.jsx("animateTransform",{attributeName:"transform",dur:"1.5s",repeatCount:"indefinite",type:"rotate",values:"0 12 12;360 12 12"})]}),t.jsx("path",{"stroke-dasharray":"64","stroke-dashoffset":"64","stroke-opacity":"0.3",d:"M12 3c4.97 0 9 4.03 9 9c0 4.97 -4.03 9 -9 9c-4.97 0 -9 -4.03 -9 -9c0 -4.97 4.03 -9 9 -9Z",children:t.jsx("animate",{fill:"freeze",attributeName:"stroke-dashoffset",dur:"1.2s",values:"64;0"})})]})}),Qe=s=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",...s,children:[t.jsxs("mask",{id:"lineMdChatRoundDotsFilled0",children:[t.jsxs("path",{fill:"#fff","fill-opacity":"0",d:"M5 15.5c1 1 2.5 2 4 2.5c-0.71 -0.24 -1.43 -0.59 -2.09 -1c-0.72 -0.45 -1.39 -0.98 -1.91 -1.5Z",children:[t.jsx("animate",{fill:"freeze",attributeName:"d",begin:"0.6s",dur:"0.2s",values:"M5 15.5c1 1 2.5 2 4 2.5c-0.71 -0.24 -1.43 -0.59 -2.09 -1c-0.72 -0.45 -1.39 -0.98 -1.91 -1.5Z;M5 15.5c1 1 2.5 2 4 2.5c-2 2 -5 3 -7 3c2 -2 3 -3.5 3 -5.5Z"}),t.jsx("set",{fill:"freeze",attributeName:"fill-opacity",begin:"0.6s",to:"1"})]}),t.jsxs("g",{fill:"none",stroke:"#fff","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",children:[t.jsxs("path",{fill:"transparent","fill-opacity":"0","stroke-dasharray":"56","stroke-dashoffset":"56",d:"M7 16.82c-2.41 -1.25 -4 -3.39 -4 -5.82c0 -3.87 4.03 -7 9 -7c4.97 0 9 3.13 9 7c0 3.87 -4.03 7 -9 7c-1.85 0 -3.57 -0.43 -5 -1.18Z",children:[t.jsx("animate",{fill:"freeze",attributeName:"fill-opacity",begin:"0.9s",dur:"0.5s",values:"0;1"}),t.jsx("animate",{fill:"freeze",attributeName:"stroke-dashoffset",dur:"0.6s",values:"56;0"})]}),t.jsx("path",{stroke:"currentColor","stroke-dasharray":"2","stroke-dashoffset":"2",d:"M8 11h0.01",children:t.jsx("animate",{fill:"freeze",attributeName:"stroke-dashoffset",begin:"1.4s",dur:"0.2s",values:"2;0"})}),t.jsx("path",{stroke:"currentColor","stroke-dasharray":"2","stroke-dashoffset":"2",d:"M12 11h0.01",children:t.jsx("animate",{fill:"freeze",attributeName:"stroke-dashoffset",begin:"1.7s",dur:"0.2s",values:"2;0"})}),t.jsx("path",{stroke:"currentColor","stroke-dasharray":"2","stroke-dashoffset":"2",d:"M16 11h0.01",children:t.jsx("animate",{fill:"freeze",attributeName:"stroke-dashoffset",begin:"2s",dur:"0.2s",values:"2;0"})})]})]}),t.jsx("rect",{width:"24",height:"24",fill:"currentColor",mask:"url(#lineMdChatRoundDotsFilled0)"})]}),z=i.forwardRef(({className:s,variant:o="outline",size:u="md",shape:l="rounded",...p},h)=>t.jsx("button",{className:$("lulichat-btn",`lulichat-btn-${o}`,`lulichat-btn-${u}`,`lulichat-btn-${l}`,s),ref:h,...p}));z.displayName="Button";const et=({companyName:s,onSubmit:o,onSkip:u,allowAnonymous:l,isLoading:p})=>{const[h,b]=i.useState(!1),[j,d]=i.useState({name:"",email:"",phone:"",company:""}),[m,g]=i.useState({}),[S,_]=i.useState({email:"",name:""}),O=()=>{const w={};return j.name.trim()||(w.name="Name is required"),j.email.trim()?/\S+@\S+\.\S+/.test(j.email)||(w.email="Email is invalid"):w.email="Email is required",g(w),Object.keys(w).length===0},M=w=>{w.preventDefault(),O()&&o(j)},D=(w,P)=>{d(a=>({...a,[w]:P})),m[w]&&g(a=>({...a,[w]:void 0}))};return t.jsxs(B,{autoComplete:"off",onSubmit:M,onValuesChange:_,className:"lulichat-contact-form",children:[t.jsxs("div",{className:"lulichat-form-header",children:[t.jsxs("div",{style:{marginBottom:"20px",display:"flex",alignItems:"end",columnGap:8},children:[t.jsx(Ge,{style:{display:"block"},color:"#DEDEDE6A",height:40,width:50}),t.jsx("h3",{style:{fontWeight:500},children:"Hello,"})]}),t.jsxs("h3",{style:{marginBottom:8},className:"lulichat-title",children:["Welcome to ",s," Live Chat"]}),t.jsxs("p",{role:"button",onClickCapture:()=>b(!h),style:{textDecoration:"underline",lineHeight:"1rem",cursor:"pointer"},children:["Please provide your details for a better support experience"," ",t.jsx(Je,{style:{display:"inline-block",marginBottom:-2},height:20,width:20})]})]}),t.jsxs("div",{className:`lulichat-form-group${h?" open":""}`,children:[t.jsx(B.Item,{error:m.name,label:"Name (Optional)",name:"name",children:t.jsx(G,{id:"name",placeholder:"Enter your name",type:"text",value:j.name,onChange:w=>D("name",w.target.value),className:"transparent"+(m.name?" error":"")})}),t.jsx(B.Item,{name:"email",error:m.email,label:"Email",children:t.jsx(G,{id:"email",type:"email",placeholder:"Enter your valid email",value:j.email,onChange:w=>D("email",w.target.value),className:"transparent"+(m.name?" error":"")})}),t.jsx(z,{type:"submit",disabled:p||!S.email,style:{width:"100%",marginTop:10},className:"lulichat-contact-form-btn",children:p?t.jsxs(t.Fragment,{children:[t.jsx(ge,{}),"Submitting..."]}):"Submit"})]})]})};class xe{constructor(o,u,l="wss://ws.lulichat.com"){A(this,"socket",null);A(this,"token");A(this,"sessionId");A(this,"onMessageCallback");A(this,"onStatusCallback");A(this,"reconnectAttempts",0);A(this,"maxReconnectAttempts",5);this.token=o,this.sessionId=u,this.connect(l)}connect(o){var u;try{this.socket=new WebSocket(`${o}/chat?token=${this.token}&session=${this.sessionId}`),this.socket.onopen=()=>{var l;console.log("Socket connected"),this.reconnectAttempts=0,(l=this.onStatusCallback)==null||l.call(this,"connected")},this.socket.onmessage=l=>{var p;try{const h=JSON.parse(l.data);(p=this.onMessageCallback)==null||p.call(this,h)}catch(h){console.error("Failed to parse message:",h)}},this.socket.onclose=()=>{var l;console.log("Socket disconnected"),(l=this.onStatusCallback)==null||l.call(this,"disconnected"),this.handleReconnect(o)},this.socket.onerror=l=>{var p;console.error("Socket error:",l),(p=this.onStatusCallback)==null||p.call(this,"error")}}catch(l){console.error("Failed to connect socket:",l),(u=this.onStatusCallback)==null||u.call(this,"error")}}handleReconnect(o){this.reconnectAttempts<this.maxReconnectAttempts&&(this.reconnectAttempts++,setTimeout(()=>{console.log(`Reconnecting... attempt ${this.reconnectAttempts}`),this.connect(o)},2e3*this.reconnectAttempts))}sendMessage(o){var u;if(((u=this.socket)==null?void 0:u.readyState)===WebSocket.OPEN){const l={type:"message",content:o,timestamp:new Date().toISOString()};this.socket.send(JSON.stringify(l))}}onMessage(o){this.onMessageCallback=o}onStatus(o){this.onStatusCallback=o}disconnect(){this.socket&&(this.socket.close(),this.socket=null)}}const tt=({session:s,companyInfo:o,onClose:u})=>{const[l,p]=i.useState([]),[h,b]=i.useState(""),[j,d]=i.useState(!1),[m,g]=i.useState("disconnected"),S=i.useRef(null),_=i.useRef(null);i.useEffect(()=>(_.current=new xe(s.token,s.id),_.current.onMessage(k=>{p(L=>[...L,k]),d(!1)}),_.current.onStatus(k=>{g(k)}),p([{id:"welcome",content:"",timestamp:new Date,sender:"system"}]),()=>{var k;(k=_.current)==null||k.disconnect()}),[s,o]),i.useEffect(()=>{O()},[l]);const O=()=>{var a;(a=S.current)==null||a.scrollIntoView({behavior:"smooth"})},M=()=>{var k;if(!h.trim()||m!=="connected")return;const a={id:Date.now().toString(),content:h,timestamp:new Date,sender:"user"};p(L=>[...L,a]),(k=_.current)==null||k.sendMessage(h),b(""),d(!0)},D=a=>{a.key==="Enter"&&!a.shiftKey&&(a.preventDefault(),M())},w=a=>new Intl.DateTimeFormat("en-US",{hour:"2-digit",minute:"2-digit"}).format(a),P=a=>{switch(a){case"agent":return t.jsx(Ze,{className:"w-4 h-4"});case"user":return t.jsx(Xe,{className:"w-4 h-4"});default:return null}};return t.jsxs("div",{className:"flex flex-col h-full",children:[t.jsxs("div",{className:"bg-primary text-primary-foreground p-4 rounded-t-lg",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("div",{className:"w-2 h-2 rounded-full bg-green-400"}),t.jsx("span",{className:"font-medium",children:o.name})]}),t.jsx(z,{variant:"ghost",size:"sm",onClick:u,className:"text-primary-foreground hover:bg-primary-foreground/20",children:"×"})]}),t.jsx("div",{className:"text-xs opacity-80 mt-1",children:m==="connected"?"Online":"Connecting..."})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4 bg-background",children:[l.map(a=>t.jsx("div",{className:`flex ${a.sender==="user"?"justify-end":"justify-start"}`,children:t.jsxs("div",{className:`max-w-xs lg:max-w-md px-4 py-2 rounded-lg ${a.sender==="user"?"bg-primary text-primary-foreground":a.sender==="system"?"bg-muted text-muted-foreground text-center":"bg-muted text-foreground"}`,children:[a.sender!=="system"&&t.jsxs("div",{className:"flex items-center space-x-1 mb-1",children:[P(a.sender),t.jsx("span",{className:"text-xs opacity-70",children:a.senderName||(a.sender==="user"?"You":"Support")})]}),t.jsx("p",{className:"text-sm",children:a.content}),t.jsx("p",{className:"text-xs opacity-60 mt-1",children:w(a.timestamp)})]})},a.id)),j&&t.jsx("div",{className:"flex justify-start",children:t.jsx("div",{className:"bg-muted text-foreground px-4 py-2 rounded-lg",children:t.jsxs("div",{className:"flex space-x-1",children:[t.jsx("div",{className:"w-2 h-2 bg-current rounded-full animate-bounce"}),t.jsx("div",{className:"w-2 h-2 bg-current rounded-full animate-bounce",style:{animationDelay:"0.1s"}}),t.jsx("div",{className:"w-2 h-2 bg-current rounded-full animate-bounce",style:{animationDelay:"0.2s"}})]})})}),t.jsx("div",{ref:S})]}),t.jsxs("div",{className:"p-4 border-t bg-background",children:[t.jsxs("div",{className:"flex space-x-2",children:[t.jsx("input",{value:h,onChange:a=>b(a.target.value),onKeyPress:D,placeholder:"Type your message...",disabled:m!=="connected",className:"flex-1"}),t.jsx(z,{onClick:M,disabled:!h.trim()||m!=="connected",size:"icon",children:t.jsx(pe,{className:"w-4 h-4"})})]}),m!=="connected"&&t.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:m==="error"?"Connection error. Retrying...":"Connecting..."})]})]})},rt=({config:s})=>{const[o,u]=i.useState("contact-form"),[l,p]=i.useState(null),[h,b]=i.useState(null),[j,d]=i.useState(!1),[m,g]=i.useState(null),[S,_]=i.useState(!1),O=new fe(s);i.useEffect(()=>{M()},[s]);const M=async()=>{try{const a=await O.getCompanyInfo();p(a.data)}catch(a){g("Failed to load chat configuration"),console.error("Failed to load company info:",a)}},D=async a=>{d(!0);try{const k=await O.submitContactInfo(a),L={id:k.sessionId,token:k.token,isActive:!0};b(L),u("chat")}catch(k){g("Failed to start chat. Please try again."),console.error("Failed to submit contact info:",k)}finally{d(!1)}},w=async()=>{d(!0);try{const a=await O.startAnonymousChat(),k={id:a.sessionId,token:a.token,isActive:!0};b(k),u("chat")}catch(a){g("Failed to start chat. Please try again."),console.error("Failed to start anonymous chat:",a)}finally{d(!1)}},P=()=>{u("closed"),b(null),g(null)};return console.log({companyInfo:l}),t.jsxs("div",{className:`lulichat lulichat-${s.position}`,children:[S&&t.jsxs("div",{className:"lulichat-main",children:[m&&t.jsxs("div",{className:"p-4 bg-destructive/10 border-b",children:[t.jsx("p",{className:"text-sm text-destructive",children:m}),t.jsx("button",{onClick:()=>g(null),className:"mt-2",children:"Retry"})]}),t.jsx(et,{companyName:l==null?void 0:l.name,onSubmit:D,onSkip:s.allowAnonymous?w:void 0,allowAnonymous:s.allowAnonymous||!1,isLoading:j}),t.jsxs("div",{style:{padding:16},children:[t.jsx("div",{style:{display:"flex",gap:10,flexWrap:"wrap"},children:l==null?void 0:l.queues.map(a=>{var k;return t.jsx("div",{className:"lulichat-tag",children:(k=a.name)==null?void 0:k.toLocaleLowerCase()},a.id)})}),t.jsx("div",{style:{height:2,backgroundColor:"hsl(var(--border))",marginBlock:16}}),t.jsxs("div",{style:{display:"flex",alignItems:"center",columnGap:10},className:"form-control",children:[t.jsx(G,{name:"message",autoComplete:"off",style:{border:"none",paddingInline:0},placeholder:"What can we help you with ?."}),t.jsxs("div",{className:"lulichat-btn-group",children:[t.jsx(z,{style:{color:"#00000080"},size:"icon",children:t.jsx(Ke,{height:24})}),t.jsx(z,{style:{color:"#00000080"},size:"icon",children:t.jsx(pe,{})})]})]})]}),o==="chat"&&h&&l&&t.jsx(tt,{session:h,companyInfo:l,onClose:P})]}),t.jsx(z,{onClick:()=>_(!S),className:"",shape:"circle",size:"icon",style:{backgroundColor:s.primaryColor,height:"4rem",width:"4rem",padding:0,color:"#fff",alignSelf:"end"},disabled:!l&&!m,children:!l&&!m?t.jsx(ge,{}):t.jsx(Qe,{height:40,width:40})})]})},nt=({apiKey:s,baseUrl:o,position:u="bottom-right",primaryColor:l="#007bff",companyName:p="Support",welcomeMessage:h="Hello! How can we help you today?",requireContactInfo:b=!0,allowAnonymous:j=!0})=>{const d={apiKey:s,baseUrl:o,position:u,primaryColor:l,companyName:p,welcomeMessage:h,requireContactInfo:b,allowAnonymous:j};return s?t.jsx(rt,{config:d}):(console.error("LuliChat: API key is required"),null)};N.ChatSocket=xe,N.LuliChat=nt,N.LuliChatAPI=fe,Object.defineProperty(N,Symbol.toStringTag,{value:"Module"})});
30
+ <%s key={someKey} {...props} />`,le,V,Pt,V),$e[V+le]=!0}}return e===l?Nt(E):_t(E),E}}function Rt(e,r,n){return We(e,r,n,!0)}function Tt(e,r,n){return We(e,r,n,!1)}var Ot=Tt,Dt=Rt;H.Fragment=l,H.jsx=Ot,H.jsxs=Dt}()),H}process.env.NODE_ENV==="production"?M.exports=ze():M.exports=Ve();var t=M.exports;class Be{constructor(o){F(this,"config");F(this,"baseUrl");this.config=o,this.baseUrl=o.baseUrl||"http://localhost:8000"}async getCompanyInfo(){try{const o=await fetch(`${this.baseUrl}/companies/e/info`,{headers:{Authorization:`Bearer ${this.config.apiKey}`,"Content-Type":"application/json"}});if(!o.ok)throw new Error(`HTTP error! status: ${o.status}`);return await o.json()}catch(o){throw console.error("Failed to fetch company info:",o),o}}async submitContactInfo(o){try{const u=await fetch(`${this.baseUrl}/companies/e/chat/init`,{method:"POST",headers:{Authorization:`Bearer ${this.config.apiKey}`,"Content-Type":"application/json"},body:JSON.stringify(o||{})});if(!u.ok)throw new Error(`HTTP error! status: ${u.status}`);return await u.json()}catch(u){throw console.error("Failed to submit contact info:",u),u}}async startAnonymousChat(){return this.submitContactInfo()}}function fe(...s){return R.clsx(s)}const G=i.forwardRef((s,o)=>t.jsx("input",{...s,autoComplete:s.autoComplete||s.name||"off",ref:o,className:fe("lulichat-input",s.className)}));i.forwardRef((s,o)=>t.jsx("input",{className:"",...s,ref:o}));const de=i.createContext(void 0),B=i.forwardRef(({children:s,onValuesChange:o,initialValues:u,...l},p)=>{const h=i.useRef(u||{}),b=i.useRef(null),j=i.useCallback((m,g)=>{h.current[m]=g,o&&o({...h.current})},[o]),f={getValues:()=>h.current,getFieldValue:m=>{var g;return(g=h.current)==null?void 0:g[m]},elementRef:()=>b.current,setFieldValue:j};return i.useImperativeHandle(p,()=>f),t.jsx(de.Provider,{value:f,children:t.jsx("form",{...l,ref:b,onSubmit:l.onSubmit,children:s})})}),Ye=i.forwardRef(({name:s,children:o,...u},l)=>{const p=i.useContext(de),h=function(f){var m,g;p&&s&&p.setFieldValue(s,f.target.value),(g=(m=this.props).onChange)==null||g.call(m,f)},b=i.Children.map(o,f=>{if(i.isValidElement(f)&&s&&f.type===G){let m=f;return i.cloneElement(m,{...m.props,name:s,value:(p==null?void 0:p.getFieldValue(s))??"",onChange:h.bind(m),required:u.required})}return f}),j=Object.create(u);return delete j.required,delete j.label,t.jsxs("div",{className:"lulichat-form-item",ref:l,...j,children:[u.label&&t.jsx(he,{htmlFor:s,required:u.required,children:u.label}),b,u.error&&t.jsx("p",{className:"error",children:u.error})]})}),he=i.forwardRef((s,o)=>{const u=s.required,l=s.children;return t.jsxs("label",{...s,className:fe("lulichat-form-label",s.className),ref:o,children:[l,u&&t.jsx("b",{style:{color:"red"},children:"*"})]})}),qe=s=>{const o=i.useRef(s||{}),u=i.useRef(null),l=i.useCallback((h,b)=>{o.current[h]=b},[]);return[{getValues:()=>o.current,getFieldValue:h=>{var b;return(b=o.current)==null?void 0:b[h]},elementRef:()=>u.current,setFieldValue:l}]};B.Item=Ye,B.Label=he,B.useForm=qe;const Ue=s=>t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 18 18",...s,children:t.jsx("path",{fill:"none",stroke:"currentColor",strokeDasharray:"10",strokeDashoffset:"10",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 15l-5 -5M12 15l5 -5",children:t.jsx("animate",{fill:"freeze",attributeName:"stroke-dashoffset",dur:"0.3s",values:"10;0"})})}),He=s=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 24 24",...s,children:[t.jsx("mask",{id:"lineMdFileDocumentFilled0",children:t.jsxs("g",{fill:"none",stroke:"#fff",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[t.jsxs("path",{fill:"#fff",fillOpacity:"0",strokeDasharray:"64",strokeDashoffset:"64",d:"M13.5 3l5.5 5.5v11.5c0 0.55 -0.45 1 -1 1h-12c-0.55 0 -1 -0.45 -1 -1v-16c0 -0.55 0.45 -1 1 -1Z",children:[t.jsx("animate",{fill:"freeze",attributeName:"fill-opacity",begin:"0.6s",dur:"0.5s",values:"0;1"}),t.jsx("animate",{fill:"freeze",attributeName:"stroke-dashoffset",dur:"0.6s",values:"64;0"})]}),t.jsx("path",{fill:"#000",stroke:"#000",d:"M14.5 3.5l0 4.5l4.5 0z",opacity:"0",children:t.jsx("set",{fill:"freeze",attributeName:"opacity",begin:"0.6s",to:"1"})}),t.jsx("path",{d:"M13.5 3l5.5 5.5",opacity:"0",children:t.jsx("set",{fill:"freeze",attributeName:"opacity",begin:"0.6s",to:"1"})}),t.jsx("path",{stroke:"#000",strokeDasharray:"12",strokeDashoffset:"12",d:"M7 13h10",children:t.jsx("animate",{fill:"freeze",attributeName:"stroke-dashoffset",begin:"1.1s",dur:"0.2s",values:"12;0"})}),t.jsx("path",{stroke:"#000",strokeDasharray:"8",strokeDashoffset:"8",d:"M7 17h7",children:t.jsx("animate",{fill:"freeze",attributeName:"stroke-dashoffset",begin:"1.3s",dur:"0.2s",values:"8;0"})})]})}),t.jsx("rect",{width:"24",height:"24",fill:"currentColor",mask:"url(#lineMdFileDocumentFilled0)"})]}),Je=s=>t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 22 22",...s,children:t.jsx("path",{fill:"currentColor",d:"M1.5 4v1.5c0 4.15 2.21 7.78 5.5 9.8V20h15v-2c0-2.66-5.33-4-8-4h-.25C9 14 5 10 5 5.5V4m9 0a4 4 0 0 0-4 4a4 4 0 0 0 4 4a4 4 0 0 0 4-4a4 4 0 0 0-4-4"})}),Ke=s=>t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",...s,children:t.jsx("path",{fill:"currentColor",d:"M12 2.25A9.75 9.75 0 0 0 2.25 12v5q0 .04.004.08v.05c-.003 1.278.602 2.682 1.963 3.25l.071.03c.11.044.22.12.362.25c.07.064.138.132.22.213l.008.008c.08.08.175.175.277.265c.204.183.474.388.83.506c.37.122.77.131 1.208.022c.723-.18 1.266-.752 1.469-1.454c.089-.309.089-.668.088-1.084v-4.094c0-.285 0-.528-.01-.728a2.3 2.3 0 0 0-.107-.627c-.23-.683-.786-1.223-1.504-1.377a2.25 2.25 0 0 0-1.264.065c-.37.133-.652.354-.87.558c-.12.11-.269.267-.391.396l-.164.17a1.8 1.8 0 0 1-.427.338q-.136.07-.263.152V12a8.25 8.25 0 1 1 16.5 0v1.864a3 3 0 0 0-.538-.274a1.2 1.2 0 0 1-.362-.25c-.07-.064-.138-.132-.22-.213l-.008-.008a7 7 0 0 0-.277-.265a2.4 2.4 0 0 0-.83-.506q-.553-.184-1.208-.022c-.723.18-1.266.752-1.469 1.454c-.089.309-.088.668-.088 1.085v4.093c0 .285 0 .528.01.728c.012.208.037.418.107.627c.23.683.786 1.223 1.504 1.377c.463.1.883.073 1.264-.065c.37-.133.652-.354.87-.558c.12-.11.269-.267.391-.395c.065-.069.123-.13.164-.17a1.8 1.8 0 0 1 .427-.34c1.11-.573 1.755-1.724 1.758-2.936v-.143L21.75 17v-5A9.75 9.75 0 0 0 12 2.25"})}),Ge=s=>t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",...s,children:t.jsxs("g",{fill:"none",stroke:"currentColor",strokeDasharray:"28",strokeDashoffset:"28",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[t.jsx("path",{d:"M4 21v-1c0 -3.31 2.69 -6 6 -6h4c3.31 0 6 2.69 6 6v1",children:t.jsx("animate",{fill:"freeze",attributeName:"stroke-dashoffset",dur:"0.4s",values:"28;0"})}),t.jsx("path",{d:"M12 11c-2.21 0 -4 -1.79 -4 -4c0 -2.21 1.79 -4 4 -4c2.21 0 4 1.79 4 4c0 2.21 -1.79 4 -4 4Z",children:t.jsx("animate",{fill:"freeze",attributeName:"stroke-dashoffset",begin:"0.4s",dur:"0.4s",values:"28;0"})})]})}),me=()=>t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",children:t.jsx("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",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.11zm7.318-19.539l-10.94 10.939"})}),ve=s=>t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",...s,children:t.jsxs("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[t.jsxs("path",{strokeDasharray:"16",strokeDashoffset:"16",d:"M12 3c4.97 0 9 4.03 9 9",children:[t.jsx("animate",{fill:"freeze",attributeName:"stroke-dashoffset",dur:"0.3s",values:"16;0"}),t.jsx("animateTransform",{attributeName:"transform",dur:"1.5s",repeatCount:"indefinite",type:"rotate",values:"0 12 12;360 12 12"})]}),t.jsx("path",{strokeDasharray:"64",strokeDashoffset:"64",strokeOpacity:"0.3",d:"M12 3c4.97 0 9 4.03 9 9c0 4.97 -4.03 9 -9 9c-4.97 0 -9 -4.03 -9 -9c0 -4.97 4.03 -9 9 -9Z",children:t.jsx("animate",{fill:"freeze",attributeName:"stroke-dashoffset",dur:"1.2s",values:"64;0"})})]})}),Ze=s=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",...s,children:[t.jsxs("mask",{id:"lineMdChatRoundDotsFilled0",children:[t.jsxs("path",{fill:"#fff",fillOpacity:"0",d:"M5 15.5c1 1 2.5 2 4 2.5c-0.71 -0.24 -1.43 -0.59 -2.09 -1c-0.72 -0.45 -1.39 -0.98 -1.91 -1.5Z",children:[t.jsx("animate",{fill:"freeze",attributeName:"d",begin:"0.6s",dur:"0.2s",values:"M5 15.5c1 1 2.5 2 4 2.5c-0.71 -0.24 -1.43 -0.59 -2.09 -1c-0.72 -0.45 -1.39 -0.98 -1.91 -1.5Z;M5 15.5c1 1 2.5 2 4 2.5c-2 2 -5 3 -7 3c2 -2 3 -3.5 3 -5.5Z"}),t.jsx("set",{fill:"freeze",attributeName:"fill-opacity",begin:"0.6s",to:"1"})]}),t.jsxs("g",{fill:"none",stroke:"#fff",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[t.jsxs("path",{fill:"transparent",fillOpacity:"0",strokeDasharray:"56",strokeDashoffset:"56",d:"M7 16.82c-2.41 -1.25 -4 -3.39 -4 -5.82c0 -3.87 4.03 -7 9 -7c4.97 0 9 3.13 9 7c0 3.87 -4.03 7 -9 7c-1.85 0 -3.57 -0.43 -5 -1.18Z",children:[t.jsx("animate",{fill:"freeze",attributeName:"fill-opacity",begin:"0.9s",dur:"0.5s",values:"0;1"}),t.jsx("animate",{fill:"freeze",attributeName:"stroke-dashoffset",dur:"0.6s",values:"56;0"})]}),t.jsx("path",{stroke:"currentColor",strokeDasharray:"2",strokeDashoffset:"2",d:"M8 11h0.01",children:t.jsx("animate",{fill:"freeze",attributeName:"stroke-dashoffset",begin:"1.4s",dur:"0.2s",values:"2;0"})}),t.jsx("path",{stroke:"currentColor",strokeDasharray:"2",strokeDashoffset:"2",d:"M12 11h0.01",children:t.jsx("animate",{fill:"freeze",attributeName:"stroke-dashoffset",begin:"1.7s",dur:"0.2s",values:"2;0"})}),t.jsx("path",{stroke:"currentColor",strokeDasharray:"2",strokeDashoffset:"2",d:"M16 11h0.01",children:t.jsx("animate",{fill:"freeze",attributeName:"stroke-dashoffset",begin:"2s",dur:"0.2s",values:"2;0"})})]})]}),t.jsx("rect",{width:"24",height:"24",fill:"currentColor",mask:"url(#lineMdChatRoundDotsFilled0)"})]}),$=i.forwardRef(({className:s,variant:o="outline",size:u="md",shape:l="rounded",...p},h)=>t.jsx("button",{className:R("lulichat-btn",`lulichat-btn-${o}`,`lulichat-btn-${u}`,`lulichat-btn-${l}`,s),ref:h,...p}));$.displayName="Button";const Xe=({companyName:s,onSubmit:o,onSkip:u,allowAnonymous:l,isLoading:p})=>{const[h,b]=i.useState(!1),[j,f]=i.useState({name:"",email:"",phone:"",company:""}),[m,g]=i.useState({}),[S,_]=i.useState({email:"",name:""}),O=()=>{const w={};return j.name.trim()||(w.name="Name is required"),j.email.trim()?/\S+@\S+\.\S+/.test(j.email)||(w.email="Email is invalid"):w.email="Email is required",g(w),Object.keys(w).length===0},A=w=>{w.preventDefault(),O()&&o(j)},I=(w,D)=>{f(a=>({...a,[w]:D})),m[w]&&g(a=>({...a,[w]:void 0}))};return t.jsxs(B,{autoComplete:"off",onSubmit:A,onValuesChange:_,className:"lulichat-contact-form",children:[t.jsxs("div",{className:"lulichat-form-header",children:[t.jsxs("div",{style:{marginBottom:"20px",display:"flex",alignItems:"end",columnGap:8},children:[t.jsx(Je,{style:{display:"block"},color:"#DEDEDE6A",height:40,width:50}),t.jsx("h3",{style:{fontWeight:500},children:"Hello,"})]}),t.jsxs("h3",{style:{marginBottom:8},className:"lulichat-title",children:["Welcome to ",s," Live Chat"]}),t.jsxs("p",{role:"button",onClickCapture:()=>b(!h),style:{textDecoration:"underline",lineHeight:"1rem",cursor:"pointer"},children:["Please provide your details for a better support experience"," ",t.jsx(Ue,{style:{display:"inline-block",marginBottom:-2},height:20,width:20})]})]}),t.jsxs("div",{className:`lulichat-form-group${h?" open":""}`,children:[t.jsx(B.Item,{error:m.name,label:"Name (Optional)",name:"name",children:t.jsx(G,{id:"name",placeholder:"Enter your name",type:"text",value:j.name,onChange:w=>I("name",w.target.value),className:"transparent"+(m.name?" error":"")})}),t.jsx(B.Item,{name:"email",error:m.email,label:"Email",children:t.jsx(G,{id:"email",type:"email",placeholder:"Enter your valid email",value:j.email,onChange:w=>I("email",w.target.value),className:"transparent"+(m.name?" error":"")})}),t.jsx($,{type:"submit",disabled:p||!S.email,style:{width:"100%",marginTop:10},className:"lulichat-contact-form-btn",children:p?t.jsxs(t.Fragment,{children:[t.jsx(ve,{}),"Submitting..."]}):"Submit"})]})]})};class Qe{constructor(o,u,l="wss://ws.lulichat.com"){F(this,"socket",null);F(this,"token");F(this,"sessionId");F(this,"onMessageCallback");F(this,"onStatusCallback");F(this,"reconnectAttempts",0);F(this,"maxReconnectAttempts",5);this.token=o,this.sessionId=u,this.connect(l)}connect(o){var u;try{this.socket=new WebSocket(`${o}/chat?token=${this.token}&session=${this.sessionId}`),this.socket.onopen=()=>{var l;console.log("Socket connected"),this.reconnectAttempts=0,(l=this.onStatusCallback)==null||l.call(this,"connected")},this.socket.onmessage=l=>{var p;try{const h=JSON.parse(l.data);(p=this.onMessageCallback)==null||p.call(this,h)}catch(h){console.error("Failed to parse message:",h)}},this.socket.onclose=()=>{var l;console.log("Socket disconnected"),(l=this.onStatusCallback)==null||l.call(this,"disconnected"),this.handleReconnect(o)},this.socket.onerror=l=>{var p;console.error("Socket error:",l),(p=this.onStatusCallback)==null||p.call(this,"error")}}catch(l){console.error("Failed to connect socket:",l),(u=this.onStatusCallback)==null||u.call(this,"error")}}handleReconnect(o){this.reconnectAttempts<this.maxReconnectAttempts&&(this.reconnectAttempts++,setTimeout(()=>{console.log(`Reconnecting... attempt ${this.reconnectAttempts}`),this.connect(o)},2e3*this.reconnectAttempts))}sendMessage(o){var u;if(((u=this.socket)==null?void 0:u.readyState)===WebSocket.OPEN){const l={type:"message",content:o,timestamp:new Date().toISOString()};this.socket.send(JSON.stringify(l))}}onMessage(o){this.onMessageCallback=o}onStatus(o){this.onStatusCallback=o}disconnect(){this.socket&&(this.socket.close(),this.socket=null)}}const et=({session:s,companyInfo:o,onClose:u})=>{const[l,p]=i.useState([]),[h,b]=i.useState(""),[j,f]=i.useState(!1),[m,g]=i.useState("disconnected"),S=i.useRef(null),_=i.useRef(null);i.useEffect(()=>(_.current=new Qe(s.token,s.id),_.current.onMessage(k=>{p(W=>[...W,k]),f(!1)}),_.current.onStatus(k=>{g(k)}),p([{id:"welcome",content:"",timestamp:new Date,sender:"system"}]),()=>{var k;(k=_.current)==null||k.disconnect()}),[s,o]),i.useEffect(()=>{O()},[l]);const O=()=>{var a;(a=S.current)==null||a.scrollIntoView({behavior:"smooth"})},A=()=>{var k;if(!h.trim()||m!=="connected")return;const a={id:Date.now().toString(),content:h,timestamp:new Date,sender:"user"};p(W=>[...W,a]),(k=_.current)==null||k.sendMessage(h),b(""),f(!0)},I=a=>{a.key==="Enter"&&!a.shiftKey&&(a.preventDefault(),A())},w=a=>new Intl.DateTimeFormat("en-US",{hour:"2-digit",minute:"2-digit"}).format(a),D=a=>{switch(a){case"agent":return t.jsx(Ke,{className:"w-4 h-4"});case"user":return t.jsx(Ge,{className:"w-4 h-4"});default:return null}};return t.jsxs("div",{className:"flex flex-col h-full",children:[t.jsxs("div",{className:"bg-primary text-primary-foreground p-4 rounded-t-lg",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("div",{className:"w-2 h-2 rounded-full bg-green-400"}),t.jsx("span",{className:"font-medium",children:o.name})]}),t.jsx($,{variant:"ghost",size:"sm",onClick:u,className:"text-primary-foreground hover:bg-primary-foreground/20",children:"×"})]}),t.jsx("div",{className:"text-xs opacity-80 mt-1",children:m==="connected"?"Online":"Connecting..."})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4 bg-background",children:[l.map(a=>t.jsx("div",{className:`flex ${a.sender==="user"?"justify-end":"justify-start"}`,children:t.jsxs("div",{className:`max-w-xs lg:max-w-md px-4 py-2 rounded-lg ${a.sender==="user"?"bg-primary text-primary-foreground":a.sender==="system"?"bg-muted text-muted-foreground text-center":"bg-muted text-foreground"}`,children:[a.sender!=="system"&&t.jsxs("div",{className:"flex items-center space-x-1 mb-1",children:[D(a.sender),t.jsx("span",{className:"text-xs opacity-70",children:a.senderName||(a.sender==="user"?"You":"Support")})]}),t.jsx("p",{className:"text-sm",children:a.content}),t.jsx("p",{className:"text-xs opacity-60 mt-1",children:w(a.timestamp)})]})},a.id)),j&&t.jsx("div",{className:"flex justify-start",children:t.jsx("div",{className:"bg-muted text-foreground px-4 py-2 rounded-lg",children:t.jsxs("div",{className:"flex space-x-1",children:[t.jsx("div",{className:"w-2 h-2 bg-current rounded-full animate-bounce"}),t.jsx("div",{className:"w-2 h-2 bg-current rounded-full animate-bounce",style:{animationDelay:"0.1s"}}),t.jsx("div",{className:"w-2 h-2 bg-current rounded-full animate-bounce",style:{animationDelay:"0.2s"}})]})})}),t.jsx("div",{ref:S})]}),t.jsxs("div",{className:"p-4 border-t bg-background",children:[t.jsxs("div",{className:"flex space-x-2",children:[t.jsx("input",{value:h,onChange:a=>b(a.target.value),onKeyPress:I,placeholder:"Type your message...",disabled:m!=="connected",className:"flex-1"}),t.jsx($,{onClick:A,disabled:!h.trim()||m!=="connected",size:"icon",children:t.jsx(me,{className:"w-4 h-4"})})]}),m!=="connected"&&t.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:m==="error"?"Connection error. Retrying...":"Connecting..."})]})]})},tt=({config:s})=>{const[o,u]=i.useState("contact-form"),[l,p]=i.useState(null),[h,b]=i.useState(null),[j,f]=i.useState(!1),[m,g]=i.useState(null),[S,_]=i.useState(!1),O=new Be(s);i.useEffect(()=>{A()},[s]);const A=async()=>{try{const a=await O.getCompanyInfo();p(a.data)}catch(a){g("Failed to load chat configuration"),console.error("Failed to load company info:",a)}},I=async a=>{f(!0);try{const k=await O.submitContactInfo(a),W={id:k.sessionId,token:k.token,isActive:!0};b(W),u("chat")}catch(k){g("Failed to start chat. Please try again."),console.error("Failed to submit contact info:",k)}finally{f(!1)}},w=async()=>{f(!0);try{const a=await O.startAnonymousChat(),k={id:a.sessionId,token:a.token,isActive:!0};b(k),u("chat")}catch(a){g("Failed to start chat. Please try again."),console.error("Failed to start anonymous chat:",a)}finally{f(!1)}},D=()=>{u("closed"),b(null),g(null)};return console.log({companyInfo:l}),t.jsxs("div",{className:`lulichat lulichat-${s.position}`,children:[S&&t.jsxs("div",{className:"lulichat-main",children:[m&&t.jsxs("div",{className:"p-4 bg-destructive/10 border-b",children:[t.jsx("p",{className:"text-sm text-destructive",children:m}),t.jsx("button",{onClick:()=>g(null),className:"mt-2",children:"Retry"})]}),t.jsx(Xe,{companyName:l==null?void 0:l.name,onSubmit:I,onSkip:s.allowAnonymous?w:void 0,allowAnonymous:s.allowAnonymous||!1,isLoading:j}),t.jsxs("div",{style:{padding:16},children:[t.jsx("div",{style:{display:"flex",gap:10,flexWrap:"wrap"},children:l==null?void 0:l.queues.map(a=>{var k;return t.jsx("div",{className:"lulichat-tag",children:(k=a.name)==null?void 0:k.toLocaleLowerCase()},a.id)})}),t.jsx("div",{style:{height:2,backgroundColor:"hsl(var(--border))",marginBlock:16}}),t.jsxs("div",{style:{display:"flex",alignItems:"center",columnGap:10},className:"form-control",children:[t.jsx(G,{name:"message",autoComplete:"off",style:{border:"none",paddingInline:0},placeholder:"What can we help you with ?."}),t.jsxs("div",{className:"lulichat-btn-group",children:[t.jsx($,{style:{color:"#00000080"},size:"icon",children:t.jsx(He,{height:24})}),t.jsx($,{style:{color:"#00000080"},size:"icon",children:t.jsx(me,{})})]})]})]}),o==="chat"&&h&&l&&t.jsx(et,{session:h,companyInfo:l,onClose:D})]}),t.jsx($,{onClick:()=>_(!S),className:"",shape:"circle",size:"icon",style:{backgroundColor:s.primaryColor,height:"4rem",width:"4rem",padding:0,color:"#fff",alignSelf:"end"},disabled:!l&&!m,children:!l&&!m?t.jsx(ve,{}):t.jsx(Ze,{height:40,width:40})})]})};return({apiKey:s,baseUrl:o,position:u="bottom-right",primaryColor:l="#007bff",companyName:p="Support",welcomeMessage:h="Hello! How can we help you today?",requireContactInfo:b=!0,allowAnonymous:j=!0})=>{const f={apiKey:s,baseUrl:o,position:u,primaryColor:l,companyName:p,welcomeMessage:h,requireContactInfo:b,allowAnonymous:j};return s?t.jsx(tt,{config:f}):(console.error("LuliChat: API key is required"),null)}});
@@ -0,0 +1,85 @@
1
+ export interface LuliChatConfig {
2
+ apiKey: string;
3
+ baseUrl?: string;
4
+ position?: "bottom-right" | "bottom-left" | "top-right" | "top-left";
5
+ primaryColor?: string;
6
+ companyName?: string;
7
+ welcomeMessage?: string;
8
+ requireContactInfo?: boolean;
9
+ allowAnonymous?: boolean;
10
+ }
11
+ export interface ContactInfo {
12
+ name: string;
13
+ email: string;
14
+ phone?: string;
15
+ company?: string;
16
+ }
17
+ export interface ChatMessage {
18
+ id: string;
19
+ content: string;
20
+ timestamp: Date;
21
+ sender: "user" | "agent" | "system";
22
+ senderName?: string;
23
+ }
24
+ export interface ChatSession {
25
+ id: string;
26
+ token: string;
27
+ isActive: boolean;
28
+ agentInfo?: {
29
+ name: string;
30
+ avatar?: string;
31
+ status: "online" | "away" | "busy";
32
+ };
33
+ }
34
+ export interface CompanyInfo {
35
+ status: string;
36
+ success: boolean;
37
+ data: Data;
38
+ }
39
+ interface Data {
40
+ id: number;
41
+ name: string;
42
+ email: null;
43
+ website: null;
44
+ description: null;
45
+ settings: Settings;
46
+ plan: null;
47
+ queues: Queue[];
48
+ }
49
+ interface Queue {
50
+ id: number;
51
+ name: string;
52
+ color: string;
53
+ greetingMessage: string;
54
+ outOfHoursMessage: string;
55
+ schedules: Schedule[];
56
+ companyId: number;
57
+ orderQueue: null | number;
58
+ leadId: null | number;
59
+ mediaId: null;
60
+ createdAt: string;
61
+ updatedAt: string;
62
+ }
63
+ interface Schedule {
64
+ endTime: string;
65
+ startTime: string;
66
+ weekdayEn: string;
67
+ weekday?: string;
68
+ }
69
+ interface Settings {
70
+ id: number;
71
+ chatBotType: string;
72
+ sendGreetingAccepted: string;
73
+ sendMsgTransfTicket: string;
74
+ sendGreetingMessageOneQueues: string;
75
+ userRating: string;
76
+ scheduleType: string;
77
+ CheckMsgIsGroup: string;
78
+ call: string;
79
+ companyId: number;
80
+ type: string;
81
+ createdAt: string;
82
+ updatedAt: string;
83
+ }
84
+ export type ChatState = "closed" | "contact-form" | "chat" | "loading";
85
+ export {};
package/package.json CHANGED
@@ -1,16 +1,17 @@
1
1
  {
2
2
  "name": "lulichat",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "A React library for integrating a support chat feature into web applications.",
5
5
  "main": "dist/lulichat-support.umd.js",
6
6
  "module": "dist/lulichat-support.es.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "scripts": {
9
9
  "build": "vite build",
10
+ "build:types": "tsc --emitDeclarationOnly",
10
11
  "dev": "vite",
11
12
  "test": "jest",
12
13
  "lint": "eslint .",
13
- "prepare": "npm run build"
14
+ "prepare": "npm run build && npm run build:types"
14
15
  },
15
16
  "keywords": [
16
17
  "react",
@@ -22,12 +23,18 @@
22
23
  "license": "MIT",
23
24
  "dependencies": {
24
25
  "class-variance-authority": "^0.7.1",
25
- "lulichat": "^1.0.1",
26
+ "lulichat": "^1.0.3",
26
27
  "react": "^18.0.0",
27
28
  "react-dom": "^18.0.0",
28
29
  "socket.io-client": "^4.5.0"
29
30
  },
30
31
  "devDependencies": {
32
+ "@babel/preset-env": "^7.28.0",
33
+ "@babel/preset-react": "^7.27.1",
34
+ "@babel/preset-typescript": "^7.27.1",
35
+ "@testing-library/jest-dom": "^6.6.3",
36
+ "@testing-library/react": "^16.3.0",
37
+ "@types/jest": "^30.0.0",
31
38
  "@types/node": "^22.5.5",
32
39
  "@types/react": "^18.3.3",
33
40
  "@types/react-dom": "^18.3.0",
@@ -36,6 +43,7 @@
36
43
  "eslint-plugin-react-hooks": "^5.1.0-rc.0",
37
44
  "eslint-plugin-react-refresh": "^0.4.9",
38
45
  "jest": "^29.0.0",
46
+ "jest-environment-jsdom": "^30.0.4",
39
47
  "typescript": "^5.5.3",
40
48
  "vite": "^5.4.1"
41
49
  },
@@ -44,8 +52,10 @@
44
52
  "react-dom": "^18.0.0"
45
53
  },
46
54
  "files": [
47
- "dist",
48
- "src"
55
+ "dist/index.d.ts",
56
+ "dist/types",
57
+ "dist/components/LuliChat.js",
58
+ "dist/components/LuliChat.d.ts"
49
59
  ],
50
60
  "homepage": "https://github.com/tjdibbs/lulichat-support",
51
61
  "repository": {