tybotflow-widget 0.3.5 → 0.3.6

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/dist/index.umd.js CHANGED
@@ -347,7 +347,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
347
347
  opacity: 0;
348
348
  }
349
349
  }
350
- `);var Pt=pe.memo(pe.forwardRef(function(e,t){var n=e.sequence,a=e.repeat,o=e.className,l=e.speed,u=l===void 0?40:l,d=e.deletionSpeed,f=e.omitDeletionAnimation,p=f!==void 0&&f,h=e.preRenderFirstString,m=h!==void 0&&h,y=e.wrapper,E=y===void 0?"span":y,v=e.splitter,A=v===void 0?function(S){return ur([],Qn(S),!1)}:v,w=e.cursor,x=w===void 0||w,N=e.style,C=function(S,H){var ee={};for(var L in S)Object.prototype.hasOwnProperty.call(S,L)&&H.indexOf(L)<0&&(ee[L]=S[L]);if(S!=null&&typeof Object.getOwnPropertySymbols=="function"){var le=0;for(L=Object.getOwnPropertySymbols(S);le<L.length;le++)H.indexOf(L[le])<0&&Object.prototype.propertyIsEnumerable.call(S,L[le])&&(ee[L[le]]=S[L[le]])}return ee}(e,["sequence","repeat","className","speed","deletionSpeed","omitDeletionAnimation","preRenderFirstString","wrapper","splitter","cursor","style"]),M=C["aria-label"],O=C["aria-hidden"],R=C.role;d||(d=u);var F=new Array(2).fill(40);[u,d].forEach(function(S,H){switch(typeof S){case"number":F[H]=Math.abs(S-100);break;case"object":var ee=S.type,L=S.value;if(typeof L!="number")break;ee==="keyStrokeDelayInMs"&&(F[H]=L)}});var U,P,B,q,W,_,Y=F[0],Z=F[1],j=function(S,H){H===void 0&&(H=null);var ee=pe.useRef(H);return pe.useEffect(function(){S&&(typeof S=="function"?S(ee.current):S.current=ee.current)},[S]),ee}(t),J=zY;U=o?"".concat(x?J+" ":"").concat(o):x?J:"",P=pe.useRef(function(){var S,H=n;a===1/0?S=R1:typeof a=="number"&&(H=Array(1+a).fill(n).flat());var ee=S?ur(ur([],Qn(H),!1),[S],!1):ur([],Qn(H),!1);return R1.apply(void 0,ur([j.current,A,Y,Z,p],Qn(ee),!1)),function(){j.current}}),B=pe.useRef(),q=pe.useRef(!1),W=pe.useRef(!1),_=Qn(pe.useState(0),2)[1],q.current&&(W.current=!0),pe.useEffect(function(){return q.current||(B.current=P.current(),q.current=!0),_(function(S){return S+1}),function(){W.current&&B.current&&B.current()}},[]);var X=E,oe=m?n.find(function(S){return typeof S=="string"})||"":null;return dn.createElement(X,{"aria-hidden":O,"aria-label":M,role:R,style:N,className:U,children:M?dn.createElement("span",{"aria-hidden":"true",ref:j,children:oe}):oe,ref:M?void 0:j})}),function(e,t){return!0});const C1="https://api.tybotflow.com/api/v1",k1="https://api.tybotflow.com/api/v1/web/send-message",jY="https://api.tybotflow.com/api/v1/chatbots-config",qY=({items:e,messageTitle:t,chatRoundness:n,agentChatResponseBgColor:a,agentChatResponseColor:o,buttonsBgColor:l,buttonColor:u,inputBackgroundColor:d,onButtonClick:f})=>{const[p,h]=dn.useState(0),m=e?.length||0,y=()=>{h(w=>(w+1)%m)},E=()=>{h(w=>(w-1+m)%m)},v=w=>{h(w)},A=(w,x)=>{const N=typeof w.payload=="string"?w.payload:JSON.stringify(w.payload);w.action==="Open URL"?window.open(w.url,"_blank"):w.title==="scan"?fetch(x.image).then(C=>C.blob()).then(C=>{const M=URL.createObjectURL(C),O=document.createElement("a");O.href=M,O.download="qrcode.png",document.body.appendChild(O),O.click(),document.body.removeChild(O),URL.revokeObjectURL(M)}).catch(()=>{alert("Failed to download image.")}):(w.action,f(x.title||"",N))};return k.jsx("div",{className:"mt-2 w-full",children:k.jsxs("div",{className:"relative max-w-md mx-auto",children:[k.jsx("div",{className:"overflow-hidden rounded-lg",style:{borderRadius:`${n}px`},children:k.jsx("div",{className:"flex transition-transform duration-300 ease-in-out",style:{transform:`translateX(-${p*100}%)`},children:e?.map((w,x)=>k.jsxs("div",{className:"w-full flex-shrink-0 p-4",style:{background:a},children:[k.jsxs("div",{className:"relative h-40 w-full mb-3 ",children:[k.jsx("img",{src:w.image,alt:w.title,className:"size-full object-cover rounded-lg"}),m>1&&k.jsxs(k.Fragment,{children:[p>0&&k.jsx("button",{onClick:E,className:"absolute -left-4 top-1/2 -translate-y-1/2 w-8 h-8 rounded-full flex items-center justify-center transition-all duration-200 hover:scale-110 shadow-lg backdrop-blur-sm",style:{backgroundColor:`${l}CC`,color:u},children:k.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:k.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}),p<m-1&&k.jsx("button",{onClick:y,className:"absolute -right-4 top-1/2 -translate-y-1/2 w-8 h-8 rounded-full flex items-center justify-center transition-all duration-200 hover:scale-110 shadow-lg backdrop-blur-sm",style:{backgroundColor:`${l}CC`,color:u},children:k.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:k.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})})]})]}),k.jsx("h3",{className:"text-sm font-bold mb-2",style:{color:o},children:w.title}),k.jsx("p",{className:"text-xs mb-3 leading-relaxed",style:{color:o},children:w.subtitle}),k.jsx("div",{className:"space-y-2",children:w.actions?.map((N,C)=>k.jsx("button",{className:"w-full px-4 py-2 text-sm font-medium hover:scale-[0.98] transition-all duration-200",onClick:()=>A(N,w),style:{background:l,borderRadius:`${n}px`,color:u},children:N.title},C))})]},x))})}),m>1&&k.jsxs("div",{className:"absolute top-2 right-2 px-2 py-1 text-xs font-medium rounded-full backdrop-blur-sm",style:{backgroundColor:`${d}CC`,color:o},children:[p+1," / ",m]}),m>1&&k.jsx("div",{className:"flex justify-center space-x-2 mt-3",children:e?.map((w,x)=>k.jsx("button",{onClick:()=>v(x),className:`w-2 h-2 rounded-full transition-all duration-200 ${x===p?"scale-125 opacity-100":"opacity-40 hover:opacity-70"}`,style:{backgroundColor:l}},x))})]})})},HY=({options:e,message:t,allowMultiple:n,chatRoundness:a,buttonsBgColor:o,buttonColor:l,agentChatResponseColor:u,isRtl:d,onSend:f,onScroll:p})=>{const[h,m]=dn.useState([]),y=v=>{n?m(A=>A.includes(v)?A.filter(x=>x!==v):[...A,v]):f(v)},E=()=>{h.length>0&&(f(h.join(",")),m([]))};return k.jsxs(k.Fragment,{children:[k.jsx("div",{className:"flex flex-wrap",dir:d?"rtl":"ltr",children:e?.map((v,A)=>{const w=n&&h.includes(v.value);return k.jsx("button",{className:`mb-1 mr-1 px-4 py-1 hover:scale-105 transition-all duration-100 ${w?"ring-2 ring-offset-1":""}`,onClick:()=>y(v.value),style:{background:w?`linear-gradient(135deg, ${o}, ${o}DD)`:o,borderRadius:`${a}px`,color:l,opacity:w?.8:1,transform:w?"scale(0.95)":"scale(1)"},dir:d?"rtl":"ltr",children:k.jsxs("div",{className:"flex items-center gap-1",children:[n&&w&&k.jsx(gd,{className:"w-3 h-3"}),k.jsx(Pt,{sequence:[v.label,0,p],wrapper:"span",cursor:!1,speed:90})]})},A)})}),n&&h.length>0&&k.jsx("div",{className:"mt-3 flex justify-end",dir:d?"rtl":"ltr",children:k.jsxs("button",{onClick:E,className:"px-6 py-2 font-semibold hover:scale-105 transition-all duration-200 flex items-center gap-2",style:{background:`linear-gradient(135deg, ${o}, ${o}AA)`,borderRadius:`${a}px`,color:l},children:[k.jsx(zw,{className:"w-4 h-4"}),k.jsxs("span",{children:["Send (",h.length,")"]})]})})]})};function O1({products:e,onValidate:t,agentChatResponseColor:n,agentChatResponseBgColor:a,buttonsBgColor:o,buttonColor:l,chatRoundness:u,panelWidth:d,inputBackgroundColor:f}){const[p,h]=pe.useState({}),[m,y]=pe.useState(!1),[E,v]=dn.useState(0),A=d<700,w=d>=1300,x=Math.ceil((e?.length||0)/(A?1:w?3:2)),N=()=>{v(_=>(_+1)%x)},C=()=>{v(_=>(_-1+x)%x)},M=_=>{v(_)},O=_=>{h(Y=>({...Y,[_]:(Y[_]||0)+1}))},R=_=>{h(Y=>{const Z={...Y};return Z[_]>1?Z[_]-=1:delete Z[_],Z})},F=()=>Object.entries(p).map(([_,Y])=>({id_produit:_,quantite:Y})),U=()=>Object.values(p).reduce((_,Y)=>_+Y,0),P=()=>{const Y={products:F()};t(Y)},B=()=>Object.entries(p).map(([_,Y])=>({product:e.find(j=>j.id===_),quantity:Y})).filter(_=>_.product),q=()=>B().reduce((_,{product:Y,quantity:Z})=>_+Y.price*Z,0),W=()=>{const _=[];for(let Y=0;Y<e.length;Y+=A?1:w?3:2)_.push(e.slice(Y,Y+(A?1:w?3:2)));return _};return k.jsxs("div",{className:"w-full mx-auto",style:{color:n},children:[k.jsxs("div",{className:"flex items-center justify-between mb-4",children:[k.jsx("h2",{className:"text-lg font-semibold",children:"Produits Disponibles"}),U()>0&&k.jsxs("button",{onClick:()=>y(!m),className:"flex items-center gap-2 px-3 py-2 rounded-lg transition-colors",style:{backgroundColor:o+"20",color:l,borderRadius:`${u}px`},children:[k.jsx(dz,{className:"w-4 h-4"}),k.jsxs("div",{className:"flex flex-col items-end text-xs",children:[k.jsxs("span",{children:[U()," articles"]}),k.jsxs("span",{children:[q().toFixed(2)," DH"]})]})]})]}),k.jsxs(k.Fragment,{children:[k.jsxs("div",{className:"relative overflow-hidden mb-6",children:[k.jsx("div",{className:"flex transition-transform duration-300 ease-in-out",style:{transform:`translateX(-${E*100}%)`},children:W().map((_,Y)=>k.jsx("div",{className:`w-full flex-shrink-0 grid ${A?"grid-cols-1":w&&e.length>=3?"grid-cols-3":"grid-cols-2"} gap-4 p-2`,children:_.map(Z=>k.jsxs("div",{className:"p-4 rounded-lg border border-opacity-20",style:{backgroundColor:a+"40",borderColor:n,borderRadius:`${u}px`},children:[k.jsx("div",{className:"relative w-full h-40 mb-3 rounded-md overflow-hidden",children:k.jsx("img",{src:Z?.image??"",alt:Z.nomProduit,className:"w-full h-full object-contain bg-gray-100"})}),k.jsx("h3",{className:"font-semibold text-sm mb-2",style:{color:n},children:Z.nomProduit}),k.jsx("p",{className:"text-xs text-opacity-70 mb-2 line-clamp-2",style:{color:n},title:Z.description,children:Z.description}),k.jsxs("div",{className:"flex items-center justify-between gap-4",children:[k.jsxs("div",{className:"text-xs",style:{color:n},children:["Stock: ",Z.stock,k.jsx("br",{}),"Prix: ",Z.price!=0?`${Z.price} DH`:"-"]}),k.jsx("div",{className:"flex items-center gap-2",children:p[Z.id]?k.jsxs("div",{className:"flex items-center gap-2",children:[k.jsx("button",{onClick:()=>R(Z.id),className:"w-8 h-8 rounded-full flex items-center justify-center transition-colors",style:{backgroundColor:o+"80",color:l},children:k.jsx(sz,{className:"w-4 h-4"})}),k.jsx("span",{className:"min-w-[20px] text-center text-sm font-semibold",children:p[Z.id]}),k.jsx("button",{onClick:()=>O(Z.id),disabled:p[Z.id]>=Z.stock,className:"w-8 h-8 rounded-full flex items-center justify-center transition-colors disabled:opacity-50",style:{backgroundColor:o,color:l},children:k.jsx(Pw,{className:"w-4 h-4"})})]}):k.jsx("button",{onClick:()=>O(Z.id),disabled:Z.stock===0,className:"px-3 py-1 text-xs rounded-lg transition-colors disabled:opacity-50",style:{backgroundColor:o,color:l,borderRadius:`${u}px`},children:Z.stock===0?"Ajouter au devis":"Ajouter au panier"})})]})]},Z.id))},Y))}),x>1&&k.jsxs(k.Fragment,{children:[E>0&&k.jsx("button",{onClick:C,className:"absolute left-0 top-24 w-8 h-8 rounded-full flex items-center justify-center transition-all duration-200 hover:scale-110 shadow-lg backdrop-blur-sm",style:{backgroundColor:`${o}CC`,color:l},children:k.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:k.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}),E<x-1&&k.jsx("button",{onClick:N,className:"absolute right-0 top-24 w-8 h-8 rounded-full flex items-center justify-center transition-all duration-200 hover:scale-110 shadow-lg backdrop-blur-sm",style:{backgroundColor:`${o}CC`,color:l},children:k.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:k.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})})]})]}),x>1&&k.jsx("div",{className:"flex justify-center space-x-2 mt-3",children:Array.from({length:x}).map((_,Y)=>k.jsx("button",{onClick:()=>M(Y),className:`w-2 h-2 rounded-full transition-all duration-200 ${Y===E?"scale-125 opacity-100":"opacity-40 hover:opacity-70"}`,style:{backgroundColor:o}},Y))})]}),m&&U()>0&&k.jsxs("div",{className:"mt-3 p-4 rounded-lg border border-opacity-20 mb-4",style:{backgroundColor:a+"60",borderColor:n,borderRadius:`${u}px`},children:[k.jsxs("h3",{className:"font-semibold mb-3",children:["Produits sélectionnés: (",U()," articles)"]}),k.jsx("div",{className:"space-y-2",children:B().map(({product:_,quantity:Y})=>k.jsxs("div",{className:"flex justify-between items-center text-sm",children:[k.jsxs("div",{className:"flex-1",children:[k.jsx("div",{children:_.nomProduit}),k.jsxs("div",{className:"text-xs opacity-70",children:[_.price.toFixed(2)," DH × ",Y]})]}),k.jsxs("span",{className:"ml-2 font-medium",children:[(_.price*Y).toFixed(2)," DH"]})]},_.id))}),k.jsx("div",{className:"border-t border-opacity-30 mt-3 pt-3",style:{borderColor:n},children:k.jsxs("div",{className:"flex justify-between items-center font-semibold",children:[k.jsx("span",{children:"Total:"}),k.jsxs("span",{children:[q().toFixed(2)," DH"]})]})})]}),U()>0&&k.jsxs("button",{onClick:P,className:"w-full px-6 py-3 mt-3 text-sm font-medium rounded-lg transition-colors flex items-center justify-center gap-2",style:{backgroundColor:o,color:l,borderRadius:`${u}px`},children:[k.jsx(gd,{className:"w-4 h-4"}),"Valider la sélection (",U()," articles) ",q()!==0?`- ${q().toFixed(2)} DH`:"-"]})]})}const GY=({attachment:e,formatFileSize:t,mainColor:n,secondaryColor:a,controlsColor:o})=>{const{type:l,url:u,name:d,size:f}=e;switch(l){case"image":return k.jsxs("div",{className:"relative group",children:[k.jsx("img",{src:u,alt:d,className:"max-w-xs max-h-48 size-full rounded-lg object-cover cursor-pointer hover:opacity-90 transition-opacity",onClick:()=>window.open(u,"_blank")}),k.jsx("div",{className:"absolute bottom-2 left-2 bg-black bg-opacity-60 text-white text-xs px-2 py-1 rounded",children:t(f)})]});case"video":return k.jsxs("div",{className:"max-w-xs",children:[k.jsx("video",{src:u,controls:!0,className:"w-full max-h-48 rounded-lg",preload:"metadata",onError:()=>{console.error("Video failed to load:",u)},children:"Your browser does not support the video tag."}),k.jsxs("div",{className:"flex text-xs text-white mt-1 w-full overflow-hidden whitespace-nowrap text-ellipsis",children:[k.jsx("span",{className:"block w-full overflow-hidden whitespace-nowrap text-ellipsis",title:d,children:d}),k.jsxs("span",{className:"ml-2",children:["• ",t(f)]})]})]});case"audio":return k.jsxs("div",{className:"bg-gray-800 bg-opacity-70 p-3 rounded-lg flex-1 w-full",children:[k.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[k.jsx(bd,{className:"w-4 h-4",style:{color:n}}),k.jsx("span",{className:"text-sm font-medium truncate text-white",title:d,children:d})]}),k.jsx(_Y,{src:u,mainColor:n,secondaryColor:a,controlsColor:o}),k.jsx("p",{className:"text-xs text-gray-400 mt-1",children:t(f)})]});case"document":return k.jsx("div",{className:"bg-gray-800 bg-opacity-50 p-3 rounded-lg max-w-xs cursor-pointer hover:bg-opacity-70 transition-colors",onClick:()=>window.open(u,"_blank"),children:k.jsxs("div",{className:"flex items-center gap-3",children:[k.jsx("div",{className:"w-10 h-10 bg-purple-600 rounded-lg flex items-center justify-center",children:k.jsx(md,{className:"w-5 h-5 text-white"})}),k.jsxs("div",{className:"flex-1 min-w-0",children:[k.jsx("p",{className:"text-sm font-medium truncate text-white",children:d}),k.jsx("p",{className:"text-xs text-gray-400",children:t(f)})]})]})});default:return null}},_Y=({src:e,mainColor:t,secondaryColor:n,controlsColor:a})=>{const o=pe.useRef(null),[l,u]=pe.useState(1),{wavesurfer:d,isPlaying:f}=MY({container:o,waveColor:t,progressColor:n,barWidth:2,height:50,url:e}),p=()=>{d&&d.playPause()},h=()=>{const E=l===0?1:0;u(E),d?.setVolume(E)},m=()=>{d?.skip(-.096)},y=()=>{d?.skip(.096)};return k.jsxs("div",{className:"flex w-full flex-col items-center rounded-xl pt-1",children:[k.jsx("div",{ref:o,className:"w-full px-2"}),k.jsxs("div",{className:"flex w-full items-center justify-between",children:[k.jsx("div",{className:"relative flex items-center",children:k.jsx("button",{className:"transition-colors",style:{color:a},onClick:h,"aria-label":"Toggle volume",children:l===0?k.jsx(yz,{size:20}):k.jsx(bz,{size:20})})}),k.jsxs("div",{className:"-ml-9 flex flex-1 cursor-auto justify-center gap-2 rounded-full py-2 text-white",children:[k.jsx("button",{onClick:m,className:"cursor-pointer hover:scale-110 transition-colors",style:{color:a},"aria-label":"Step back",children:k.jsx(pz,{})}),k.jsx("button",{onClick:p,className:"cursor-pointer hover:scale-110 transition-colors",style:{color:a},"aria-label":f?"Pause":"Play",children:f?k.jsx(lz,{}):k.jsx(uz,{})}),k.jsx("button",{onClick:y,className:"cursor-pointer hover:scale-110 transition-colors",style:{color:a},"aria-label":"Step forward",children:k.jsx(fz,{})})]})]})]})},VY=dn.memo(({attachment:e,onRemove:t})=>k.jsxs("div",{className:"relative group w-24 h-24 rounded-xl overflow-hidden bg-gray-900 shadow-md border border-gray-700",children:[e.type==="image"&&e.url?k.jsx("img",{src:e.url,alt:e.name,className:"w-full h-full object-cover"}):k.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center text-gray-300 px-1 text-center text-xs",children:[e.type==="video"&&k.jsx(jw,{className:"w-5 h-5 mb-1 text-red-400"}),e.type==="audio"&&k.jsx(bd,{className:"w-5 h-5 mb-1 text-green-400"}),e.type==="document"&&k.jsx(rz,{className:"w-5 h-5 mb-1 text-yellow-400"}),k.jsx("span",{className:"w-full truncate",title:e.name,children:e.name})]}),k.jsx("button",{onClick:t,className:"absolute top-1 right-1 w-5 h-5 bg-black bg-opacity-50 rounded-full text-white flex items-center justify-center hover:bg-opacity-80",title:"Remove",children:k.jsx(Oo,{className:"w-3 h-3"})})]})),YY=({config:e})=>{const t=pe.useRef(null),n=pe.useRef(null),a=pe.useRef(null),o=pe.useRef(null),l=pe.useRef(null),[u,d]=pe.useState(null),[f,p]=pe.useState(!0);pe.useEffect(()=>{(async()=>{p(!0),await Et.get(`${jY}/bot/${e.bot?.botId}`,{}).then(ae=>{d(ae.data)}).catch(ae=>{console.error("Error fetching bot config:",ae)}).finally(()=>{p(!1)})})()},[e.bot?.botId,e?.token]);const h=u?.mainColor||"#59168b",m=u?.secondaryColor||"#6366f1",y=u?.thirdColor||"#0f172b",E=u?.headerFirstColor||"#6e11b0",v=u?.headerSecondColor||"#372aac",A=u?.inputBackgroundColor||"#1f2937",w=u?.inputTextColor||"#fff",x=u?.roundness||24,N=u?.chatRoundness||16,C=(u?.minPanelWidth||434)>window.innerWidth?window.innerWidth:u?.minPanelWidth||434,M=(u?.maxPanelWidth||window.innerWidth)>window.innerWidth?window.innerWidth:u?.maxPanelWidth||window.innerWidth,O=u?.chatMaxWidth||88,R=u?.toggleBtnBorderTopLeftRadius||12,F=u?.toggleBtnBorderTopRightRadius||0,U=u?.toggleBtnBorderBottomLeftRadius||12,P=u?.toggleBtnBorderBottomRightRadius||0,B=u?.menuBackgroundColor||"#1f2937",q=u?.menuTextColor||"#e5e7eb",W=u?.menuHoverBackgroundColor||"#374151",_=u?.agentChatResponseColor||"#e5e7eb",Y=u?.agentChatResponseBgColor||"#1f2937",Z=u?.agentIconBgColor||"#59168b",j=u?.agentIconColor||"#fff",J=u?.userChatMessagesColor||"#fff",X=u?.userChatMessagesBgColor||"#7a1ebe",oe=u?.userIconBgColor||"#7a1ebe",S=u?.userIconColor||"#fff",H=u?.ButtonColor||"#fff",ee=u?.ButtonsBgColor||"#59168b",L=u?.fontSize||13,le=u?.toggleBtnPosition||"bottom-right",be=u?.autoOpenPanel??!0,Ae=(()=>{const D=u?.firstMessageKeyword;if(Array.isArray(D)){const ae=window.location.href,ge=D.find(Re=>Re.url&&Re.url===ae);if(ge)return ge.message;const Se=D.find(Re=>!Re.url||Re.url==="");return Se?Se.message:D[0]?.message||"hi"}return D||"hi"})(),Te=pe.useCallback(D=>{const ae=JSON.parse(localStorage.getItem("lastBotsMsgs")||"null");if(ae){const ge=ae.find(Se=>Se.botId===D);return ge?{...ge.lastMsg,timestamp:new Date(ge.lastMsg.timestamp)}:void 0}},[]),[_e,ut]=pe.useState(C),at=pe.useRef(!1),Gt=pe.useRef(0),Ot=pe.useRef(C),$t=D=>{at.current=!0,Gt.current=D.clientX,Ot.current=_e,document.body.style.cursor="ew-resize"};pe.useEffect(()=>{const D=ge=>{if(!at.current)return;const Se=Gt.current-ge.clientX;let Re=Ot.current+Se;Re=Math.max(C,Math.min(M,Re)),ut(Re)},ae=()=>{at.current&&(at.current=!1,document.body.style.cursor="")};return window.addEventListener("mousemove",D),window.addEventListener("mouseup",ae),()=>{window.removeEventListener("mousemove",D),window.removeEventListener("mouseup",ae)}},[_e,C,M]);const[fe,ye]=pe.useState(!1),[ze,Fe]=pe.useState(!1),[Ie,Be]=pe.useState(!1),[Ke,ct]=pe.useState(()=>le==="bottom-left"?{x:48,y:window.innerHeight-120}:le==="middle-right"?{x:window.innerWidth-80,y:window.innerHeight/2-35}:{x:window.innerWidth-123,y:window.innerHeight-100}),[ke,De]=pe.useState(!1),[Le,ne]=pe.useState({x:0,y:0}),se=pe.useRef(null),[me,Ee]=pe.useState(""),[qe,At]=pe.useState(!1),[bt,ft]=pe.useState([]),[It,it]=pe.useState(!1),dt=pe.useRef(0),[vt,Dt]=pe.useState(!1),[en,ht]=pe.useState(!1),xn=pe.useRef(!1),[Sr,cr]=pe.useState("00:00"),_t=pe.useRef(null),Rn=pe.useRef(0),[Qr,Vl]=pe.useState([]),[ja,wr]=pe.useState(()=>Te(e.bot?.botId||"")?[Te(e.bot?.botId||"")]:[]),{startRecording:dr,stopRecording:Ft,pauseRecording:tn,resumeRecording:Zr,status:Tt,error:Vo}=j4.useReactMediaRecorder({video:!1,onStop(D,ae){if(xn.current){xn.current=!1,cr("00:00"),Rn.current=0;return}ft(ge=>[...ge,{id:Date.now().toString()+Math.random().toString(36).substring(2,9),file:ae,type:"audio",url:D,name:`recording-${new Date().toISOString()}.webm`,size:ae.size}]),cr("00:00"),Rn.current=0}}),Ai=u?.icon||e?.bot.avatar_url||RY,Jr=u?.title||e?.bot.name||"Tybot webchat",[Zn,Ti]=pe.useState(()=>{if(!u?.botNeedsAuth){let D=localStorage.getItem("conversationId");if(!D){const ae=new Uint8Array(16);window.crypto.getRandomValues(ae),D=Array.from(ae).map(ge=>ge.toString(16).padStart(2,"0")).join("")}return localStorage.setItem("conversationId",D),D}}),[sn,$r]=pe.useState(()=>u?.botNeedsAuth?!!localStorage.getItem("conversationId"):!0),[Bn,ea]=pe.useState(""),[St,Yl]=pe.useState(""),[qa,Ar]=pe.useState(""),nn=pe.useRef(!1),Tr=ja.reduce((D,ae)=>ae.seen?D:D+(ae.sender==="agent"?ae.nMessage||1:0),0),xi=()=>{wr(D=>D.map(ae=>({...ae,seen:!0})))};pe.useEffect(()=>{let D;return!localStorage.getItem("webChatOpen")&&u&&be&&(D=setTimeout(()=>{ye(!0),nn.current=!0,xi(),localStorage.setItem("webChatOpen","true")},3200)),()=>clearTimeout(D)},[u]),pe.useEffect(()=>{const D=u?.widgetLoadBehavior;if(!D||!(()=>{if(!D.urls||D.urls.length===0)return!0;const Se=window.location.origin,Re=window.location.href;return D.urls.some(gt=>{if(!gt||gt.trim()==="")return!0;try{return Se.includes(gt)||Re.includes(gt)||gt.includes(Se)}catch{return console.warn("Invalid URL in widgetLoadBehavior:",gt),!1}})})())return;let ge;if(D.behavior==="after seconds")ge=setTimeout(()=>{Be(!0)},D.value*1e3);else if(D.behavior==="after scroll"){const Se=()=>{const Re=window.pageYOffset||document.documentElement.scrollTop,gt=document.documentElement.scrollHeight-document.documentElement.clientHeight;Re/gt*100>=D.value&&(Be(!0),window.removeEventListener("scroll",Se))};return window.addEventListener("scroll",Se),()=>{window.removeEventListener("scroll",Se)}}return()=>{ge&&clearTimeout(ge)}},[u?.widgetLoadBehavior]),pe.useEffect(()=>{fe&&Be(!1)},[fe]);const Ri=async D=>{if(e.bot){At(!0);try{const ae=await ln(Ae,e.bot?.botId,[],null,D),ge={id:Date.now().toString()+Math.random().toString(36).substring(2,9),sender:"agent",content:ae,timestamp:new Date,seen:nn.current,nMessage:1};wr([ge]);const Se=JSON.parse(localStorage.getItem("lastBotsMsgs")||"null");let Re;Se?Re=[...Se.filter(mt=>mt.botId!==e.bot?.botId),{botId:e.bot?.botId,lastMsg:ge}]:Re=[{botId:e.bot?.botId,lastMsg:ge}],localStorage.setItem("lastBotsMsgs",JSON.stringify(Re))}catch(ae){console.error("Error sending message:",ae)}finally{At(!1)}}};pe.useEffect(()=>{const D=Te(e?.bot?.botId||"");sn&&e?.bot&&ja.length===0&&u&&!D&&be&&(Ri(),localStorage.getItem("webChatAuth")&&JSON.parse(localStorage.getItem("webChatAuth"))&&u?.botNeedsAuth&&Zn&&(Bn||qa||St)&&(setTimeout(()=>{na(Zn)},2e3),localStorage.setItem("webChatAuth","true")))},[sn,e?.bot,Zn,u]),pe.useEffect(()=>(Tt==="recording"?_t.current||(_t.current=setInterval(()=>{Rn.current+=1;const D=Math.floor(Rn.current/60).toString().padStart(2,"0"),ae=(Rn.current%60).toString().padStart(2,"0");cr(`${D}:${ae}`)},1e3)):_t.current&&(clearInterval(_t.current),_t.current=null),()=>{_t.current&&(clearInterval(_t.current),_t.current=null)}),[Tt]),pe.useEffect(()=>{Vo&&Vo.toLowerCase().includes("permission_denied")&&(ht(!1),cr("00:00"),Rn.current=0,_t.current&&(clearInterval(_t.current),_t.current=null),alert("Microphone permission denied. Please allow access to record audio."))},[Vo]),pe.useEffect(()=>{Tt!=="recording"&&Tt!=="paused"&&(cr("00:00"),Rn.current=0)},[Tt]);const Ni=pe.useRef(null);pe.useEffect(()=>{if(Ni&&Ni.current){const D=Ni.current;D.style.height="auto";const ae=120;D.scrollHeight>ae?(D.style.height=ae+"px",D.style.overflowY="auto"):(D.style.height=D.scrollHeight+"px",D.style.overflowY="hidden")}},[me]),pe.useEffect(()=>{(fe||qe)&&t.current&&(t.current.scrollTop=t.current.scrollHeight)},[ja,qe,fe]);const Ci=D=>{const ae=D.type.toLowerCase();return ae.startsWith("image/")?"image":ae.startsWith("video/")?"video":ae.startsWith("audio/")?"audio":"document"},Jn=pe.useCallback((D,ae)=>{const ge=[];Array.from(D).forEach(Se=>{if(Se.size>10*1024*1024){alert(`File ${Se.name} is too large. Maximum size is 10MB.`);return}const Re={id:Date.now().toString()+Math.random().toString(36).substring(2,9),file:Se,type:Ci(Se),url:URL.createObjectURL(Se),name:Se.name,size:Se.size};ge.push(Re)}),ft(Se=>[...Se,...ge]),ae&&ae.current&&(ae.current.value="")},[]),$n=pe.useCallback(D=>{D.preventDefault(),dt.current=0,it(!1);const ae=D.dataTransfer.files;ae.length>0&&Jn(ae)},[Jn]),Yo=pe.useCallback(D=>{D.preventDefault(),dt.current+=1,it(!0)},[]),Wl=pe.useCallback(D=>{D.preventDefault()},[]),ta=pe.useCallback(D=>{D.preventDefault(),dt.current-=1,dt.current<=0&&it(!1)},[]),Wo=pe.useCallback(D=>{ft(ae=>{const ge=ae.find(Se=>Se.id===D);return ge&&URL.revokeObjectURL(ge.url),ae.filter(Se=>Se.id!==D)})},[]),Xo=D=>{if(D===0)return"0 Bytes";const ae=1024,ge=["Bytes","KB","MB","GB"],Se=Math.floor(Math.log(D)/Math.log(ae));return Number.parseFloat((D/Math.pow(ae,Se)).toFixed(2))+" "+ge[Se]},xr=async(D=me,ae)=>{if(D.trim()||bt.length!==0){const Se={id:Date.now().toString()+Math.random().toString(36).substring(2,9),sender:"user",content:D,attachments:[...bt],timestamp:new Date};if(wr(Re=>[...Re,Se]),Ee(""),ft([]),At(!0),e?.bot)try{try{const Re=await ln(D,e?.bot.botId,bt,ae||void 0),gt={id:Date.now().toString()+Math.random().toString(36).substring(2,9),sender:"agent",content:Re,timestamp:new Date,seen:nn.current,nMessage:typeof Re=="string"?1:Re.length};wr(Vt=>[...Vt,gt]);const mt=JSON.parse(localStorage.getItem("lastBotsMsgs")||"null");if(mt){const Vt=mt.filter(un=>un.botId!==e?.bot.botId);localStorage.setItem("lastBotsMsgs",JSON.stringify([...Vt,{botId:e?.bot.botId,lastMsg:gt}]))}else localStorage.setItem("lastBotsMsgs",JSON.stringify([{botId:e?.bot.botId,lastMsg:gt}]))}catch{wr(Re=>[...Re,{id:Date.now().toString()+Math.random().toString(36).substring(2,9),sender:"agent",content:"Erreur du serveur",timestamp:new Date,seen:nn.current,nMessage:1}])}}catch(Re){console.error("Error parsing selectedBotInfo:",Re)}else wr(Re=>[...Re,{id:Date.now().toString()+Math.random().toString(36).substring(2,9),sender:"agent",content:"Aucun bot sélectionné",timestamp:new Date,seen:nn.current,nMessage:1}]);At(!1)}else return},Ha=D=>{switch(Dt(!1),D){case"image":n.current?.click();break;case"video":a.current?.click();break;case"audio":o.current?.click();break;case"document":l.current?.click();break}},ln=async(D,ae,ge=[],Se,Re)=>{if(ge.length>0){const mt=new FormData;mt.append("type","image"),mt.append("file",ge[0].file),mt.append("botId",ae),mt.append("conversation_id",Zn??""),mt.append("host",window.location.origin);const{data:Vt}=await Et.post(e?.API_URL||k1,mt,{headers:{Authorization:`Bearer ${e?.token}`,"Content-Type":"multipart/form-data"}});return Vt}else{let mt;mt={type:"text",messageText:D,botId:ae,conversation_id:Re||Zn,isintern:!!e.token,host:window.location.origin},Se&&(mt={...mt,payload:Se,messageText:D});const{data:Vt}=await Et.post(e?.API_URL||k1,mt,{headers:{Authorization:`Bearer ${e?.token}`,"Content-Type":"application/json"}});return Vt}},[Xl,Ga]=pe.useState(!1),er=pe.useRef({x:0,y:0}),Kl=D=>{D.preventDefault(),D.stopPropagation(),De(!0),Ga(!1),er.current={x:D.clientX,y:D.clientY},ne({x:D.clientX-Ke.x,y:D.clientY-Ke.y}),document.body.style.cursor="grabbing",document.body.style.userSelect="none"},ki=D=>{D.preventDefault(),D.stopPropagation();const ae=D.touches[0];De(!0),Ga(!1),er.current={x:ae.clientX,y:ae.clientY},ne({x:ae.clientX-Ke.x,y:ae.clientY-Ke.y})},Ql=D=>{if(D.preventDefault(),D.stopPropagation(),Xl){Ga(!1);return}ye(ge=>!ge),nn.current=!fe,fe||xi();const ae=Te(e.bot?.botId||"");!be&&ae===void 0&&Ri()};pe.useEffect(()=>{const D=Re=>{if(!ke)return;const gt=Math.abs(Re.clientX-er.current.x),mt=Math.abs(Re.clientY-er.current.y);(gt>5||mt>5)&&Ga(!0);const Vt=Re.clientX-Le.x,un=Re.clientY-Le.y,aa=67,pr=window.innerWidth-document.body.clientWidth,Pn=Math.max(0,Math.min(window.innerWidth-aa-pr,Vt)),_a=Math.max(0,Math.min(window.innerHeight-aa,un));ct({x:Pn,y:_a})},ae=Re=>{if(!ke)return;Re.preventDefault();const gt=Re.touches[0],mt=Math.abs(gt.clientX-er.current.x),Vt=Math.abs(gt.clientY-er.current.y);(mt>5||Vt>5)&&Ga(!0);const un=gt.clientX-Le.x,aa=gt.clientY-Le.y,pr=67,Pn=window.innerWidth-document.body.clientWidth,_a=Math.max(0,Math.min(window.innerWidth-pr-Pn,un)),Ii=Math.max(0,Math.min(window.innerHeight-pr,aa));ct({x:_a,y:Ii})},ge=()=>{ke&&(De(!1),document.body.style.cursor="",document.body.style.userSelect="")},Se=()=>{ke&&De(!1)};return ke&&(document.addEventListener("mousemove",D),document.addEventListener("touchmove",ae,{passive:!1}),document.addEventListener("mouseup",ge),document.addEventListener("touchend",Se)),()=>{document.removeEventListener("mousemove",D),document.removeEventListener("touchmove",ae),document.removeEventListener("mouseup",ge),document.removeEventListener("touchend",Se)}},[ke,Le,Ke]),pe.useEffect(()=>{const D=()=>{const ge=window.innerWidth-67,Se=window.innerHeight-67;ct(Re=>({x:Math.max(0,Math.min(ge,Re.x)),y:Math.max(0,Math.min(Se,Re.y))}))};return window.addEventListener("resize",D),()=>window.removeEventListener("resize",D)},[]);const bn=/^[\u0600-\u06FF\u0750-\u077F\s\d\p{P}]+$/u,Ko=/[\u0600-\u06FF\u0750-\u077F]/,yn=D=>bn.test(D),Rr=D=>Ko.test(D),Un=pe.useMemo(()=>({h1:({children:D})=>k.jsx("h1",{className:"sm:text-2xl text-xl font-bold my-2",dir:yn(D)?"rtl":"ltr",children:k.jsx(Pt,{sequence:[D,0,()=>{t.current&&(t.current.scrollTop=t.current.scrollHeight)}],cursor:!1,speed:90})}),h2:({children:D})=>k.jsx("h2",{className:"sm:text-xl text-lg font-semibold my-2",dir:yn(D)?"rtl":"ltr",children:k.jsx(Pt,{sequence:[D,0,()=>{t.current&&(t.current.scrollTop=t.current.scrollHeight)}],cursor:!1,speed:90})}),h3:({children:D})=>k.jsx("h3",{className:"sm:text-lg text-base font-semibold my-2",dir:yn(D)?"rtl":"ltr",children:k.jsx(Pt,{sequence:[D,0,()=>{t.current&&(t.current.scrollTop=t.current.scrollHeight)}],cursor:!1,speed:90})}),h4:({children:D})=>k.jsx("h4",{className:"sm:text-base text-sm font-semibold my-2",dir:yn(D)?"rtl":"ltr",children:k.jsx(Pt,{sequence:[D,0,()=>{t.current&&(t.current.scrollTop=t.current.scrollHeight)}],cursor:!1,speed:90})}),h5:({children:D})=>k.jsx("h5",{className:"sm:text-base text-sm font-semibold my-2",dir:yn(D)?"rtl":"ltr",children:k.jsx(Pt,{sequence:[D,0,()=>{t.current&&(t.current.scrollTop=t.current.scrollHeight)}],cursor:!1,speed:90})}),h6:({children:D})=>k.jsx("h6",{className:"sm:text-base text-sm font-semibold my-2",dir:yn(D)?"rtl":"ltr",children:k.jsx(Pt,{sequence:[D,0,()=>{t.current&&(t.current.scrollTop=t.current.scrollHeight)}],cursor:!1,speed:90})}),p:({children:D})=>{let ae;return typeof D=="string"&&Rr(D)||typeof D=="object"&&!Array.isArray(D)&&D?.props?.children&&yn(D?.props?.children)||typeof D=="object"&&Array.isArray(D)&&D.some(ge=>Rr(ge))?ae="rtl":ae="ltr",k.jsx("div",{className:"leading-relaxed",dir:typeof D=="string"||!Array.isArray(D)?ae:"",children:Array.isArray(D)?D.map((ge,Se)=>typeof ge=="string"&&!new RegExp("^(?:\\p{Emoji_Presentation}|\\p{Emoji}\\uFE0F|\\s)+$","u").test(ge)?k.jsx("p",{dir:Rr(ge)?"rtl":"ltr",children:k.jsx(Pt,{sequence:[ge,0,()=>{t.current&&(t.current.scrollTop=t.current.scrollHeight)}],cursor:!1,speed:90})},Se):ge.type!=="br"?ge:null):k.jsx(k.Fragment,{children:D})})},ul:({children:D})=>k.jsx("ul",{className:"list-disc list-inside ml-4 my-2",style:{color:_},dir:Rr(D)?"rtl":"ltr",children:D}),ol:({children:D})=>{let ae=!1;return D.filter(ge=>typeof ge!="string").every(ge=>Rr(ge?.props?.children))?ae=!0:ae=!1,k.jsx("ol",{className:"list-decimal list-inside ml-4 my-2",style:{color:_},dir:ae?"rtl":"ltr",children:typeof D=="string"?k.jsx(Pt,{sequence:[D,0,()=>{t.current&&(t.current.scrollTop=t.current.scrollHeight)}],cursor:!1,speed:92}):D})},li:({children:D})=>k.jsx("li",{className:"my-1",dir:yn(D)?"rtl":"ltr",style:{color:_},children:typeof D=="string"?k.jsx(Pt,{sequence:[D,0,()=>{t.current&&(t.current.scrollTop=t.current.scrollHeight)}],cursor:!1,speed:92}):D}),a:({href:D,children:ae})=>k.jsx("a",{href:D,className:"text-blue-400 underline hover:text-blue-300",target:"_blank",rel:"noopener noreferrer",children:typeof ae=="string"?k.jsx(Pt,{sequence:[ae,0,()=>{t.current&&(t.current.scrollTop=t.current.scrollHeight)}],cursor:!1,speed:92}):ae}),blockquote:({children:D})=>k.jsx("blockquote",{className:"border-l-4 pl-4 italic my-2",style:{borderColor:ee,color:_},children:typeof D=="string"?k.jsx(Pt,{sequence:[D,0,()=>{t.current&&(t.current.scrollTop=t.current.scrollHeight)}],cursor:!1,speed:92}):D}),code({node:D,className:ae,children:ge,...Se}){const Re=/language-(\w+)/.exec(ae||"");return Re?k.jsx(S1,{...Se,PreTag:"div",children:String(ge).replace(/\n$/,""),language:Re[1],style:xY,customStyle:{scrollbarWidth:"thin"}}):k.jsx("code",{className:"px-1 rounded font-mono inline",style:{backgroundColor:A,color:_},...Se,children:typeof ge=="string"?k.jsx(Pt,{sequence:[ge,0,()=>{t.current&&(t.current.scrollTop=t.current.scrollHeight)}],cursor:!1,speed:92}):ge})},table:({children:D})=>k.jsx("table",{className:"min-w-full my-2",style:{border:`1px solid ${_}`,color:Y,backgroundColor:_},children:D}),thead:({children:D})=>k.jsx("thead",{children:D}),tbody:({children:D})=>k.jsx("tbody",{children:D}),tr:({children:D})=>k.jsx("tr",{style:{border:`1px solid ${Y}`},children:D}),th:({children:D})=>k.jsx("th",{className:"px-3 py-2 font-bold text-left",children:D}),td:({children:D})=>k.jsx("td",{className:"px-3 py-2",children:typeof D=="string"?k.jsx(Pt,{sequence:[D,0,()=>{t.current&&(t.current.scrollTop=t.current.scrollHeight)}],cursor:!1,speed:92}):D}),strong:({children:D})=>k.jsx("strong",{className:"font-bold",children:typeof D=="string"?k.jsx(Pt,{sequence:[D,0,()=>{t.current&&(t.current.scrollTop=t.current.scrollHeight)}],cursor:!1,speed:92}):D}),em:({children:D})=>k.jsx("em",{className:"italic ",children:typeof D=="string"?k.jsx(Pt,{sequence:[D,0,()=>{t.current&&(t.current.scrollTop=t.current.scrollHeight)}],cursor:!1,speed:92}):D}),hr:()=>k.jsx("hr",{className:"my-4",style:{borderColor:`1px solid ${_}`}})}),[w,_,ee,A,N]);pe.useEffect(()=>{const D=ae=>{vt&&ae.target instanceof Element&&!ae.composedPath().some(ge=>ge?.id==="upload-button-toggle"||ge?.id==="document-button"||ge?.id==="image-button"||ge?.id==="video-button"||ge?.id==="audio-button")&&Dt(!1)};return document.addEventListener("mousedown",D),()=>{document.removeEventListener("mousedown",D)}},[vt]);const Zl=D=>{switch(D.type){case"text":return Array.isArray(D.text)?k.jsx(O1,{products:D.text[0]?.items||[],onValidate:ae=>{xr("cart",ae)},agentChatResponseColor:_,agentChatResponseBgColor:Y,buttonsBgColor:ee,buttonColor:H,chatRoundness:N,panelWidth:_e}):k.jsx(No,{remarkPlugins:[ko],components:Un,children:D.text?.replace(/\n/g,`
350
+ `);var Pt=pe.memo(pe.forwardRef(function(e,t){var n=e.sequence,a=e.repeat,o=e.className,l=e.speed,u=l===void 0?40:l,d=e.deletionSpeed,f=e.omitDeletionAnimation,p=f!==void 0&&f,h=e.preRenderFirstString,m=h!==void 0&&h,y=e.wrapper,E=y===void 0?"span":y,v=e.splitter,A=v===void 0?function(S){return ur([],Qn(S),!1)}:v,w=e.cursor,x=w===void 0||w,N=e.style,C=function(S,H){var ee={};for(var L in S)Object.prototype.hasOwnProperty.call(S,L)&&H.indexOf(L)<0&&(ee[L]=S[L]);if(S!=null&&typeof Object.getOwnPropertySymbols=="function"){var le=0;for(L=Object.getOwnPropertySymbols(S);le<L.length;le++)H.indexOf(L[le])<0&&Object.prototype.propertyIsEnumerable.call(S,L[le])&&(ee[L[le]]=S[L[le]])}return ee}(e,["sequence","repeat","className","speed","deletionSpeed","omitDeletionAnimation","preRenderFirstString","wrapper","splitter","cursor","style"]),M=C["aria-label"],O=C["aria-hidden"],R=C.role;d||(d=u);var F=new Array(2).fill(40);[u,d].forEach(function(S,H){switch(typeof S){case"number":F[H]=Math.abs(S-100);break;case"object":var ee=S.type,L=S.value;if(typeof L!="number")break;ee==="keyStrokeDelayInMs"&&(F[H]=L)}});var U,P,B,q,W,_,Y=F[0],Z=F[1],j=function(S,H){H===void 0&&(H=null);var ee=pe.useRef(H);return pe.useEffect(function(){S&&(typeof S=="function"?S(ee.current):S.current=ee.current)},[S]),ee}(t),J=zY;U=o?"".concat(x?J+" ":"").concat(o):x?J:"",P=pe.useRef(function(){var S,H=n;a===1/0?S=R1:typeof a=="number"&&(H=Array(1+a).fill(n).flat());var ee=S?ur(ur([],Qn(H),!1),[S],!1):ur([],Qn(H),!1);return R1.apply(void 0,ur([j.current,A,Y,Z,p],Qn(ee),!1)),function(){j.current}}),B=pe.useRef(),q=pe.useRef(!1),W=pe.useRef(!1),_=Qn(pe.useState(0),2)[1],q.current&&(W.current=!0),pe.useEffect(function(){return q.current||(B.current=P.current(),q.current=!0),_(function(S){return S+1}),function(){W.current&&B.current&&B.current()}},[]);var X=E,oe=m?n.find(function(S){return typeof S=="string"})||"":null;return dn.createElement(X,{"aria-hidden":O,"aria-label":M,role:R,style:N,className:U,children:M?dn.createElement("span",{"aria-hidden":"true",ref:j,children:oe}):oe,ref:M?void 0:j})}),function(e,t){return!0});const C1="https://api.tybotflow.com/api/v1",k1="https://api.tybotflow.com/api/v1/web/send-message",jY="https://api.tybotflow.com/api/v1/chatbots-config",qY=({items:e,messageTitle:t,chatRoundness:n,agentChatResponseBgColor:a,agentChatResponseColor:o,buttonsBgColor:l,buttonColor:u,inputBackgroundColor:d,onButtonClick:f})=>{const[p,h]=dn.useState(0),m=e?.length||0,y=()=>{h(w=>(w+1)%m)},E=()=>{h(w=>(w-1+m)%m)},v=w=>{h(w)},A=(w,x)=>{const N=typeof w.payload=="string"?w.payload:JSON.stringify(w.payload);w.action==="Open URL"?window.open(w.url,"_blank"):w.title==="scan"?fetch(x.image).then(C=>C.blob()).then(C=>{const M=URL.createObjectURL(C),O=document.createElement("a");O.href=M,O.download="qrcode.png",document.body.appendChild(O),O.click(),document.body.removeChild(O),URL.revokeObjectURL(M)}).catch(()=>{alert("Failed to download image.")}):(w.action,f(x.title||"",N))};return k.jsx("div",{className:"mt-2 w-full",children:k.jsxs("div",{className:"relative max-w-md mx-auto",children:[k.jsx("div",{className:"overflow-hidden rounded-lg",style:{borderRadius:`${n}px`},children:k.jsx("div",{className:"flex transition-transform duration-300 ease-in-out",style:{transform:`translateX(-${p*100}%)`},children:e?.map((w,x)=>k.jsxs("div",{className:"w-full flex-shrink-0 p-4",style:{background:a},children:[k.jsxs("div",{className:"relative h-40 w-full mb-3 ",children:[k.jsx("img",{src:w.image,alt:w.title,className:"size-full object-cover rounded-lg"}),m>1&&k.jsxs(k.Fragment,{children:[p>0&&k.jsx("button",{onClick:E,className:"absolute -left-4 top-1/2 -translate-y-1/2 w-8 h-8 rounded-full flex items-center justify-center transition-all duration-200 hover:scale-110 shadow-lg backdrop-blur-sm",style:{backgroundColor:`${l}CC`,color:u},children:k.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:k.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}),p<m-1&&k.jsx("button",{onClick:y,className:"absolute -right-4 top-1/2 -translate-y-1/2 w-8 h-8 rounded-full flex items-center justify-center transition-all duration-200 hover:scale-110 shadow-lg backdrop-blur-sm",style:{backgroundColor:`${l}CC`,color:u},children:k.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:k.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})})]})]}),k.jsx("h3",{className:"text-sm font-bold mb-2",style:{color:o},children:w.title}),k.jsx("p",{className:"text-xs mb-3 leading-relaxed",style:{color:o},children:w.subtitle}),k.jsx("div",{className:"space-y-2",children:w.actions?.map((N,C)=>k.jsx("button",{className:"w-full px-4 py-2 text-sm font-medium hover:scale-[0.98] transition-all duration-200",onClick:()=>A(N,w),style:{background:l,borderRadius:`${n}px`,color:u},children:N.title},C))})]},x))})}),m>1&&k.jsxs("div",{className:"absolute top-2 right-2 px-2 py-1 text-xs font-medium rounded-full backdrop-blur-sm",style:{backgroundColor:`${d}CC`,color:o},children:[p+1," / ",m]}),m>1&&k.jsx("div",{className:"flex justify-center space-x-2 mt-3",children:e?.map((w,x)=>k.jsx("button",{onClick:()=>v(x),className:`w-2 h-2 rounded-full transition-all duration-200 ${x===p?"scale-125 opacity-100":"opacity-40 hover:opacity-70"}`,style:{backgroundColor:l}},x))})]})})},HY=({options:e,message:t,allowMultiple:n,chatRoundness:a,buttonsBgColor:o,buttonColor:l,agentChatResponseColor:u,isRtl:d,onSend:f,onScroll:p})=>{const[h,m]=dn.useState([]),y=v=>{n?m(A=>A.includes(v)?A.filter(x=>x!==v):[...A,v]):f(v)},E=()=>{h.length>0&&(f(h.join(",")),m([]))};return k.jsxs(k.Fragment,{children:[k.jsx("div",{className:"flex flex-wrap",dir:d?"rtl":"ltr",children:e?.map((v,A)=>{const w=n&&h.includes(v.value);return k.jsx("button",{className:`mb-1 mr-1 px-4 py-1 hover:scale-105 transition-all duration-100 ${w?"ring-2 ring-offset-1":""}`,onClick:()=>y(v.value),style:{background:w?`linear-gradient(135deg, ${o}, ${o}DD)`:o,borderRadius:`${a}px`,color:l,opacity:w?.8:1,transform:w?"scale(0.95)":"scale(1)"},dir:d?"rtl":"ltr",children:k.jsxs("div",{className:"flex items-center gap-1",children:[n&&w&&k.jsx(gd,{className:"w-3 h-3"}),k.jsx(Pt,{sequence:[v.label,0,p],wrapper:"span",cursor:!1,speed:90})]})},A)})}),n&&h.length>0&&k.jsx("div",{className:"mt-3 flex justify-end",dir:d?"rtl":"ltr",children:k.jsxs("button",{onClick:E,className:"px-6 py-2 font-semibold hover:scale-105 transition-all duration-200 flex items-center gap-2",style:{background:`linear-gradient(135deg, ${o}, ${o}AA)`,borderRadius:`${a}px`,color:l},children:[k.jsx(zw,{className:"w-4 h-4"}),k.jsxs("span",{children:["Send (",h.length,")"]})]})})]})};function O1({products:e,onValidate:t,agentChatResponseColor:n,agentChatResponseBgColor:a,buttonsBgColor:o,buttonColor:l,chatRoundness:u,panelWidth:d,inputBackgroundColor:f}){const[p,h]=pe.useState({}),[m,y]=pe.useState(!1),[E,v]=dn.useState(0),A=d<700,w=d>=1300,x=Math.ceil((e?.length||0)/(A?1:w?3:2)),N=()=>{v(_=>(_+1)%x)},C=()=>{v(_=>(_-1+x)%x)},M=_=>{v(_)},O=_=>{h(Y=>({...Y,[_]:(Y[_]||0)+1}))},R=_=>{h(Y=>{const Z={...Y};return Z[_]>1?Z[_]-=1:delete Z[_],Z})},F=()=>Object.entries(p).map(([_,Y])=>({id_produit:_,quantite:Y})),U=()=>Object.values(p).reduce((_,Y)=>_+Y,0),P=()=>{const Y={products:F()};t(Y)},B=()=>Object.entries(p).map(([_,Y])=>({product:e.find(j=>j.id===_),quantity:Y})).filter(_=>_.product),q=()=>B().reduce((_,{product:Y,quantity:Z})=>_+Y.price*Z,0),W=()=>{const _=[];for(let Y=0;Y<e.length;Y+=A?1:w?3:2)_.push(e.slice(Y,Y+(A?1:w?3:2)));return _};return k.jsxs("div",{className:"w-full mx-auto",style:{color:n},children:[k.jsxs("div",{className:"flex items-center justify-between mb-4",children:[k.jsx("h2",{className:"text-lg font-semibold",children:"Produits Disponibles"}),U()>0&&k.jsxs("button",{onClick:()=>y(!m),className:"flex items-center gap-2 px-3 py-2 rounded-lg transition-colors",style:{backgroundColor:o+"20",color:l,borderRadius:`${u}px`},children:[k.jsx(dz,{className:"w-4 h-4"}),k.jsxs("div",{className:"flex flex-col items-end text-xs",children:[k.jsxs("span",{children:[U()," articles"]}),k.jsx("span",{children:q()>0?`${q().toFixed(2)} DH`:""})]})]})]}),k.jsxs(k.Fragment,{children:[k.jsxs("div",{className:"relative overflow-hidden mb-6",children:[k.jsx("div",{className:"flex transition-transform duration-300 ease-in-out",style:{transform:`translateX(-${E*100}%)`},children:W().map((_,Y)=>k.jsx("div",{className:`w-full flex-shrink-0 grid ${A?"grid-cols-1":w&&e.length>=3?"grid-cols-3":"grid-cols-2"} gap-4 p-2`,children:_.map(Z=>k.jsxs("div",{className:"p-4 rounded-lg border border-opacity-20",style:{backgroundColor:a+"40",borderColor:n,borderRadius:`${u}px`},children:[k.jsx("div",{className:"relative w-full h-40 mb-3 rounded-md overflow-hidden",children:k.jsx("img",{src:Z?.image??"",alt:Z.nomProduit,className:"w-full h-full object-contain bg-gray-100"})}),k.jsx("h3",{className:"font-semibold text-sm mb-2",style:{color:n},children:Z.nomProduit}),k.jsx("p",{className:"text-xs text-opacity-70 mb-2 line-clamp-2",style:{color:n},title:Z.description,children:Z.description}),k.jsxs("div",{className:"flex items-center justify-between gap-4",children:[k.jsxs("div",{className:"text-xs",style:{color:n},children:["Stock: ",Z.stock,k.jsx("br",{}),"Prix: ",Z.price!=0?`${Z.price} DH`:"-"]}),k.jsx("div",{className:"flex items-center gap-2",children:p[Z.id]?k.jsxs("div",{className:"flex items-center gap-2",children:[k.jsx("button",{onClick:()=>R(Z.id),className:"w-8 h-8 rounded-full flex items-center justify-center transition-colors",style:{backgroundColor:o+"80",color:l},children:k.jsx(sz,{className:"w-4 h-4"})}),k.jsx("span",{className:"min-w-[20px] text-center text-sm font-semibold",children:p[Z.id]}),k.jsx("button",{onClick:()=>O(Z.id),disabled:p[Z.id]>=Z.stock,className:"w-8 h-8 rounded-full flex items-center justify-center transition-colors disabled:opacity-50",style:{backgroundColor:o,color:l},children:k.jsx(Pw,{className:"w-4 h-4"})})]}):k.jsx("button",{onClick:()=>O(Z.id),disabled:Z.stock===0,className:"px-3 py-1 text-xs rounded-lg transition-colors disabled:opacity-50",style:{backgroundColor:o,color:l,borderRadius:`${u}px`},children:Z.price===0?"Ajouter au devis":"Ajouter au panier"})})]})]},Z.id))},Y))}),x>1&&k.jsxs(k.Fragment,{children:[E>0&&k.jsx("button",{onClick:C,className:"absolute left-0 top-24 w-8 h-8 rounded-full flex items-center justify-center transition-all duration-200 hover:scale-110 shadow-lg backdrop-blur-sm",style:{backgroundColor:`${o}CC`,color:l},children:k.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:k.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}),E<x-1&&k.jsx("button",{onClick:N,className:"absolute right-0 top-24 w-8 h-8 rounded-full flex items-center justify-center transition-all duration-200 hover:scale-110 shadow-lg backdrop-blur-sm",style:{backgroundColor:`${o}CC`,color:l},children:k.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:k.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})})]})]}),x>1&&k.jsx("div",{className:"flex justify-center space-x-2 mt-3",children:Array.from({length:x}).map((_,Y)=>k.jsx("button",{onClick:()=>M(Y),className:`w-2 h-2 rounded-full transition-all duration-200 ${Y===E?"scale-125 opacity-100":"opacity-40 hover:opacity-70"}`,style:{backgroundColor:o}},Y))})]}),m&&U()>0&&k.jsxs("div",{className:"mt-3 p-4 rounded-lg border border-opacity-20 mb-4",style:{backgroundColor:a+"60",borderColor:n,borderRadius:`${u}px`},children:[k.jsxs("h3",{className:"font-semibold mb-3",children:["Produits sélectionnés: (",U()," articles)"]}),k.jsx("div",{className:"space-y-2",children:B().map(({product:_,quantity:Y})=>k.jsxs("div",{className:"flex justify-between items-center text-sm",children:[k.jsxs("div",{className:"flex-1",children:[k.jsx("div",{children:_.nomProduit}),k.jsx("div",{className:"text-xs opacity-70",children:_.price>0?`${_.price.toFixed(2)} DH × ${Y}`:`× ${Y}`})]}),k.jsx("span",{className:"ml-2 font-medium",children:_.price*Y>0?`${(_.price*Y).toFixed(2)} DH`:""})]},_.id))}),q()>0&&k.jsx("div",{className:"border-t border-opacity-30 mt-3 pt-3",style:{borderColor:n},children:k.jsxs("div",{className:"flex justify-between items-center font-semibold",children:[k.jsx("span",{children:"Total:"}),k.jsxs("span",{children:[q().toFixed(2)," DH"]})]})})]}),U()>0&&k.jsxs("button",{onClick:P,className:"w-full px-6 py-3 mt-3 text-sm font-medium rounded-lg transition-colors flex items-center justify-center gap-2",style:{backgroundColor:o,color:l,borderRadius:`${u}px`},children:[k.jsx(gd,{className:"w-4 h-4"}),"Valider la sélection (",U()," articles) ",q()!==0?`- ${q().toFixed(2)} DH`:""]})]})}const GY=({attachment:e,formatFileSize:t,mainColor:n,secondaryColor:a,controlsColor:o})=>{const{type:l,url:u,name:d,size:f}=e;switch(l){case"image":return k.jsxs("div",{className:"relative group",children:[k.jsx("img",{src:u,alt:d,className:"max-w-xs max-h-48 size-full rounded-lg object-cover cursor-pointer hover:opacity-90 transition-opacity",onClick:()=>window.open(u,"_blank")}),k.jsx("div",{className:"absolute bottom-2 left-2 bg-black bg-opacity-60 text-white text-xs px-2 py-1 rounded",children:t(f)})]});case"video":return k.jsxs("div",{className:"max-w-xs",children:[k.jsx("video",{src:u,controls:!0,className:"w-full max-h-48 rounded-lg",preload:"metadata",onError:()=>{console.error("Video failed to load:",u)},children:"Your browser does not support the video tag."}),k.jsxs("div",{className:"flex text-xs text-white mt-1 w-full overflow-hidden whitespace-nowrap text-ellipsis",children:[k.jsx("span",{className:"block w-full overflow-hidden whitespace-nowrap text-ellipsis",title:d,children:d}),k.jsxs("span",{className:"ml-2",children:["• ",t(f)]})]})]});case"audio":return k.jsxs("div",{className:"bg-gray-800 bg-opacity-70 p-3 rounded-lg flex-1 w-full",children:[k.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[k.jsx(bd,{className:"w-4 h-4",style:{color:n}}),k.jsx("span",{className:"text-sm font-medium truncate text-white",title:d,children:d})]}),k.jsx(_Y,{src:u,mainColor:n,secondaryColor:a,controlsColor:o}),k.jsx("p",{className:"text-xs text-gray-400 mt-1",children:t(f)})]});case"document":return k.jsx("div",{className:"bg-gray-800 bg-opacity-50 p-3 rounded-lg max-w-xs cursor-pointer hover:bg-opacity-70 transition-colors",onClick:()=>window.open(u,"_blank"),children:k.jsxs("div",{className:"flex items-center gap-3",children:[k.jsx("div",{className:"w-10 h-10 bg-purple-600 rounded-lg flex items-center justify-center",children:k.jsx(md,{className:"w-5 h-5 text-white"})}),k.jsxs("div",{className:"flex-1 min-w-0",children:[k.jsx("p",{className:"text-sm font-medium truncate text-white",children:d}),k.jsx("p",{className:"text-xs text-gray-400",children:t(f)})]})]})});default:return null}},_Y=({src:e,mainColor:t,secondaryColor:n,controlsColor:a})=>{const o=pe.useRef(null),[l,u]=pe.useState(1),{wavesurfer:d,isPlaying:f}=MY({container:o,waveColor:t,progressColor:n,barWidth:2,height:50,url:e}),p=()=>{d&&d.playPause()},h=()=>{const E=l===0?1:0;u(E),d?.setVolume(E)},m=()=>{d?.skip(-.096)},y=()=>{d?.skip(.096)};return k.jsxs("div",{className:"flex w-full flex-col items-center rounded-xl pt-1",children:[k.jsx("div",{ref:o,className:"w-full px-2"}),k.jsxs("div",{className:"flex w-full items-center justify-between",children:[k.jsx("div",{className:"relative flex items-center",children:k.jsx("button",{className:"transition-colors",style:{color:a},onClick:h,"aria-label":"Toggle volume",children:l===0?k.jsx(yz,{size:20}):k.jsx(bz,{size:20})})}),k.jsxs("div",{className:"-ml-9 flex flex-1 cursor-auto justify-center gap-2 rounded-full py-2 text-white",children:[k.jsx("button",{onClick:m,className:"cursor-pointer hover:scale-110 transition-colors",style:{color:a},"aria-label":"Step back",children:k.jsx(pz,{})}),k.jsx("button",{onClick:p,className:"cursor-pointer hover:scale-110 transition-colors",style:{color:a},"aria-label":f?"Pause":"Play",children:f?k.jsx(lz,{}):k.jsx(uz,{})}),k.jsx("button",{onClick:y,className:"cursor-pointer hover:scale-110 transition-colors",style:{color:a},"aria-label":"Step forward",children:k.jsx(fz,{})})]})]})]})},VY=dn.memo(({attachment:e,onRemove:t})=>k.jsxs("div",{className:"relative group w-24 h-24 rounded-xl overflow-hidden bg-gray-900 shadow-md border border-gray-700",children:[e.type==="image"&&e.url?k.jsx("img",{src:e.url,alt:e.name,className:"w-full h-full object-cover"}):k.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center text-gray-300 px-1 text-center text-xs",children:[e.type==="video"&&k.jsx(jw,{className:"w-5 h-5 mb-1 text-red-400"}),e.type==="audio"&&k.jsx(bd,{className:"w-5 h-5 mb-1 text-green-400"}),e.type==="document"&&k.jsx(rz,{className:"w-5 h-5 mb-1 text-yellow-400"}),k.jsx("span",{className:"w-full truncate",title:e.name,children:e.name})]}),k.jsx("button",{onClick:t,className:"absolute top-1 right-1 w-5 h-5 bg-black bg-opacity-50 rounded-full text-white flex items-center justify-center hover:bg-opacity-80",title:"Remove",children:k.jsx(Oo,{className:"w-3 h-3"})})]})),YY=({config:e})=>{const t=pe.useRef(null),n=pe.useRef(null),a=pe.useRef(null),o=pe.useRef(null),l=pe.useRef(null),[u,d]=pe.useState(null),[f,p]=pe.useState(!0);pe.useEffect(()=>{(async()=>{p(!0),await Et.get(`${jY}/bot/${e.bot?.botId}`,{}).then(ae=>{d(ae.data)}).catch(ae=>{console.error("Error fetching bot config:",ae)}).finally(()=>{p(!1)})})()},[e.bot?.botId,e?.token]);const h=u?.mainColor||"#59168b",m=u?.secondaryColor||"#6366f1",y=u?.thirdColor||"#0f172b",E=u?.headerFirstColor||"#6e11b0",v=u?.headerSecondColor||"#372aac",A=u?.inputBackgroundColor||"#1f2937",w=u?.inputTextColor||"#fff",x=u?.roundness||24,N=u?.chatRoundness||16,C=(u?.minPanelWidth||434)>window.innerWidth?window.innerWidth:u?.minPanelWidth||434,M=(u?.maxPanelWidth||window.innerWidth)>window.innerWidth?window.innerWidth:u?.maxPanelWidth||window.innerWidth,O=u?.chatMaxWidth||88,R=u?.toggleBtnBorderTopLeftRadius||12,F=u?.toggleBtnBorderTopRightRadius||0,U=u?.toggleBtnBorderBottomLeftRadius||12,P=u?.toggleBtnBorderBottomRightRadius||0,B=u?.menuBackgroundColor||"#1f2937",q=u?.menuTextColor||"#e5e7eb",W=u?.menuHoverBackgroundColor||"#374151",_=u?.agentChatResponseColor||"#e5e7eb",Y=u?.agentChatResponseBgColor||"#1f2937",Z=u?.agentIconBgColor||"#59168b",j=u?.agentIconColor||"#fff",J=u?.userChatMessagesColor||"#fff",X=u?.userChatMessagesBgColor||"#7a1ebe",oe=u?.userIconBgColor||"#7a1ebe",S=u?.userIconColor||"#fff",H=u?.ButtonColor||"#fff",ee=u?.ButtonsBgColor||"#59168b",L=u?.fontSize||13,le=u?.toggleBtnPosition||"bottom-right",be=u?.autoOpenPanel??!0,Ae=(()=>{const D=u?.firstMessageKeyword;if(Array.isArray(D)){const ae=window.location.href,ge=D.find(Re=>Re.url&&Re.url===ae);if(ge)return ge.message;const Se=D.find(Re=>!Re.url||Re.url==="");return Se?Se.message:D[0]?.message||"hi"}return D||"hi"})(),Te=pe.useCallback(D=>{const ae=JSON.parse(localStorage.getItem("lastBotsMsgs")||"null");if(ae){const ge=ae.find(Se=>Se.botId===D);return ge?{...ge.lastMsg,timestamp:new Date(ge.lastMsg.timestamp)}:void 0}},[]),[_e,ut]=pe.useState(C),at=pe.useRef(!1),Gt=pe.useRef(0),Ot=pe.useRef(C),$t=D=>{at.current=!0,Gt.current=D.clientX,Ot.current=_e,document.body.style.cursor="ew-resize"};pe.useEffect(()=>{const D=ge=>{if(!at.current)return;const Se=Gt.current-ge.clientX;let Re=Ot.current+Se;Re=Math.max(C,Math.min(M,Re)),ut(Re)},ae=()=>{at.current&&(at.current=!1,document.body.style.cursor="")};return window.addEventListener("mousemove",D),window.addEventListener("mouseup",ae),()=>{window.removeEventListener("mousemove",D),window.removeEventListener("mouseup",ae)}},[_e,C,M]);const[fe,ye]=pe.useState(!1),[ze,Fe]=pe.useState(!1),[Ie,Be]=pe.useState(!1),[Ke,ct]=pe.useState(()=>le==="bottom-left"?{x:48,y:window.innerHeight-120}:le==="middle-right"?{x:window.innerWidth-80,y:window.innerHeight/2-35}:{x:window.innerWidth-123,y:window.innerHeight-100}),[ke,De]=pe.useState(!1),[Le,ne]=pe.useState({x:0,y:0}),se=pe.useRef(null),[me,Ee]=pe.useState(""),[qe,At]=pe.useState(!1),[bt,ft]=pe.useState([]),[It,it]=pe.useState(!1),dt=pe.useRef(0),[vt,Dt]=pe.useState(!1),[en,ht]=pe.useState(!1),xn=pe.useRef(!1),[Sr,cr]=pe.useState("00:00"),_t=pe.useRef(null),Rn=pe.useRef(0),[Qr,Vl]=pe.useState([]),[ja,wr]=pe.useState(()=>Te(e.bot?.botId||"")?[Te(e.bot?.botId||"")]:[]),{startRecording:dr,stopRecording:Ft,pauseRecording:tn,resumeRecording:Zr,status:Tt,error:Vo}=j4.useReactMediaRecorder({video:!1,onStop(D,ae){if(xn.current){xn.current=!1,cr("00:00"),Rn.current=0;return}ft(ge=>[...ge,{id:Date.now().toString()+Math.random().toString(36).substring(2,9),file:ae,type:"audio",url:D,name:`recording-${new Date().toISOString()}.webm`,size:ae.size}]),cr("00:00"),Rn.current=0}}),Ai=u?.icon||e?.bot.avatar_url||RY,Jr=u?.title||e?.bot.name||"Tybot webchat",[Zn,Ti]=pe.useState(()=>{if(!u?.botNeedsAuth){let D=localStorage.getItem("conversationId");if(!D){const ae=new Uint8Array(16);window.crypto.getRandomValues(ae),D=Array.from(ae).map(ge=>ge.toString(16).padStart(2,"0")).join("")}return localStorage.setItem("conversationId",D),D}}),[sn,$r]=pe.useState(()=>u?.botNeedsAuth?!!localStorage.getItem("conversationId"):!0),[Bn,ea]=pe.useState(""),[St,Yl]=pe.useState(""),[qa,Ar]=pe.useState(""),nn=pe.useRef(!1),Tr=ja.reduce((D,ae)=>ae.seen?D:D+(ae.sender==="agent"?ae.nMessage||1:0),0),xi=()=>{wr(D=>D.map(ae=>({...ae,seen:!0})))};pe.useEffect(()=>{let D;return!localStorage.getItem("webChatOpen")&&u&&be&&(D=setTimeout(()=>{ye(!0),nn.current=!0,xi(),localStorage.setItem("webChatOpen","true")},3200)),()=>clearTimeout(D)},[u]),pe.useEffect(()=>{const D=u?.widgetLoadBehavior;if(!D||!(()=>{if(!D.urls||D.urls.length===0)return!0;const Se=window.location.origin,Re=window.location.href;return D.urls.some(gt=>{if(!gt||gt.trim()==="")return!0;try{return Se.includes(gt)||Re.includes(gt)||gt.includes(Se)}catch{return console.warn("Invalid URL in widgetLoadBehavior:",gt),!1}})})())return;let ge;if(D.behavior==="after seconds")ge=setTimeout(()=>{Be(!0)},D.value*1e3);else if(D.behavior==="after scroll"){const Se=()=>{const Re=window.pageYOffset||document.documentElement.scrollTop,gt=document.documentElement.scrollHeight-document.documentElement.clientHeight;Re/gt*100>=D.value&&(Be(!0),window.removeEventListener("scroll",Se))};return window.addEventListener("scroll",Se),()=>{window.removeEventListener("scroll",Se)}}return()=>{ge&&clearTimeout(ge)}},[u?.widgetLoadBehavior]),pe.useEffect(()=>{fe&&Be(!1)},[fe]);const Ri=async D=>{if(e.bot){At(!0);try{const ae=await ln(Ae,e.bot?.botId,[],null,D),ge={id:Date.now().toString()+Math.random().toString(36).substring(2,9),sender:"agent",content:ae,timestamp:new Date,seen:nn.current,nMessage:1};wr([ge]);const Se=JSON.parse(localStorage.getItem("lastBotsMsgs")||"null");let Re;Se?Re=[...Se.filter(mt=>mt.botId!==e.bot?.botId),{botId:e.bot?.botId,lastMsg:ge}]:Re=[{botId:e.bot?.botId,lastMsg:ge}],localStorage.setItem("lastBotsMsgs",JSON.stringify(Re))}catch(ae){console.error("Error sending message:",ae)}finally{At(!1)}}};pe.useEffect(()=>{const D=Te(e?.bot?.botId||"");sn&&e?.bot&&ja.length===0&&u&&!D&&be&&(Ri(),localStorage.getItem("webChatAuth")&&JSON.parse(localStorage.getItem("webChatAuth"))&&u?.botNeedsAuth&&Zn&&(Bn||qa||St)&&(setTimeout(()=>{na(Zn)},2e3),localStorage.setItem("webChatAuth","true")))},[sn,e?.bot,Zn,u]),pe.useEffect(()=>(Tt==="recording"?_t.current||(_t.current=setInterval(()=>{Rn.current+=1;const D=Math.floor(Rn.current/60).toString().padStart(2,"0"),ae=(Rn.current%60).toString().padStart(2,"0");cr(`${D}:${ae}`)},1e3)):_t.current&&(clearInterval(_t.current),_t.current=null),()=>{_t.current&&(clearInterval(_t.current),_t.current=null)}),[Tt]),pe.useEffect(()=>{Vo&&Vo.toLowerCase().includes("permission_denied")&&(ht(!1),cr("00:00"),Rn.current=0,_t.current&&(clearInterval(_t.current),_t.current=null),alert("Microphone permission denied. Please allow access to record audio."))},[Vo]),pe.useEffect(()=>{Tt!=="recording"&&Tt!=="paused"&&(cr("00:00"),Rn.current=0)},[Tt]);const Ni=pe.useRef(null);pe.useEffect(()=>{if(Ni&&Ni.current){const D=Ni.current;D.style.height="auto";const ae=120;D.scrollHeight>ae?(D.style.height=ae+"px",D.style.overflowY="auto"):(D.style.height=D.scrollHeight+"px",D.style.overflowY="hidden")}},[me]),pe.useEffect(()=>{(fe||qe)&&t.current&&(t.current.scrollTop=t.current.scrollHeight)},[ja,qe,fe]);const Ci=D=>{const ae=D.type.toLowerCase();return ae.startsWith("image/")?"image":ae.startsWith("video/")?"video":ae.startsWith("audio/")?"audio":"document"},Jn=pe.useCallback((D,ae)=>{const ge=[];Array.from(D).forEach(Se=>{if(Se.size>10*1024*1024){alert(`File ${Se.name} is too large. Maximum size is 10MB.`);return}const Re={id:Date.now().toString()+Math.random().toString(36).substring(2,9),file:Se,type:Ci(Se),url:URL.createObjectURL(Se),name:Se.name,size:Se.size};ge.push(Re)}),ft(Se=>[...Se,...ge]),ae&&ae.current&&(ae.current.value="")},[]),$n=pe.useCallback(D=>{D.preventDefault(),dt.current=0,it(!1);const ae=D.dataTransfer.files;ae.length>0&&Jn(ae)},[Jn]),Yo=pe.useCallback(D=>{D.preventDefault(),dt.current+=1,it(!0)},[]),Wl=pe.useCallback(D=>{D.preventDefault()},[]),ta=pe.useCallback(D=>{D.preventDefault(),dt.current-=1,dt.current<=0&&it(!1)},[]),Wo=pe.useCallback(D=>{ft(ae=>{const ge=ae.find(Se=>Se.id===D);return ge&&URL.revokeObjectURL(ge.url),ae.filter(Se=>Se.id!==D)})},[]),Xo=D=>{if(D===0)return"0 Bytes";const ae=1024,ge=["Bytes","KB","MB","GB"],Se=Math.floor(Math.log(D)/Math.log(ae));return Number.parseFloat((D/Math.pow(ae,Se)).toFixed(2))+" "+ge[Se]},xr=async(D=me,ae)=>{if(D.trim()||bt.length!==0){const Se={id:Date.now().toString()+Math.random().toString(36).substring(2,9),sender:"user",content:D,attachments:[...bt],timestamp:new Date};if(wr(Re=>[...Re,Se]),Ee(""),ft([]),At(!0),e?.bot)try{try{const Re=await ln(D,e?.bot.botId,bt,ae||void 0),gt={id:Date.now().toString()+Math.random().toString(36).substring(2,9),sender:"agent",content:Re,timestamp:new Date,seen:nn.current,nMessage:typeof Re=="string"?1:Re.length};wr(Vt=>[...Vt,gt]);const mt=JSON.parse(localStorage.getItem("lastBotsMsgs")||"null");if(mt){const Vt=mt.filter(un=>un.botId!==e?.bot.botId);localStorage.setItem("lastBotsMsgs",JSON.stringify([...Vt,{botId:e?.bot.botId,lastMsg:gt}]))}else localStorage.setItem("lastBotsMsgs",JSON.stringify([{botId:e?.bot.botId,lastMsg:gt}]))}catch{wr(Re=>[...Re,{id:Date.now().toString()+Math.random().toString(36).substring(2,9),sender:"agent",content:"Erreur du serveur",timestamp:new Date,seen:nn.current,nMessage:1}])}}catch(Re){console.error("Error parsing selectedBotInfo:",Re)}else wr(Re=>[...Re,{id:Date.now().toString()+Math.random().toString(36).substring(2,9),sender:"agent",content:"Aucun bot sélectionné",timestamp:new Date,seen:nn.current,nMessage:1}]);At(!1)}else return},Ha=D=>{switch(Dt(!1),D){case"image":n.current?.click();break;case"video":a.current?.click();break;case"audio":o.current?.click();break;case"document":l.current?.click();break}},ln=async(D,ae,ge=[],Se,Re)=>{if(ge.length>0){const mt=new FormData;mt.append("type","image"),mt.append("file",ge[0].file),mt.append("botId",ae),mt.append("conversation_id",Zn??""),mt.append("host",window.location.origin);const{data:Vt}=await Et.post(e?.API_URL||k1,mt,{headers:{Authorization:`Bearer ${e?.token}`,"Content-Type":"multipart/form-data"}});return Vt}else{let mt;mt={type:"text",messageText:D,botId:ae,conversation_id:Re||Zn,isintern:!!e.token,host:window.location.origin},Se&&(mt={...mt,payload:Se,messageText:D});const{data:Vt}=await Et.post(e?.API_URL||k1,mt,{headers:{Authorization:`Bearer ${e?.token}`,"Content-Type":"application/json"}});return Vt}},[Xl,Ga]=pe.useState(!1),er=pe.useRef({x:0,y:0}),Kl=D=>{D.preventDefault(),D.stopPropagation(),De(!0),Ga(!1),er.current={x:D.clientX,y:D.clientY},ne({x:D.clientX-Ke.x,y:D.clientY-Ke.y}),document.body.style.cursor="grabbing",document.body.style.userSelect="none"},ki=D=>{D.preventDefault(),D.stopPropagation();const ae=D.touches[0];De(!0),Ga(!1),er.current={x:ae.clientX,y:ae.clientY},ne({x:ae.clientX-Ke.x,y:ae.clientY-Ke.y})},Ql=D=>{if(D.preventDefault(),D.stopPropagation(),Xl){Ga(!1);return}ye(ge=>!ge),nn.current=!fe,fe||xi();const ae=Te(e.bot?.botId||"");!be&&ae===void 0&&Ri()};pe.useEffect(()=>{const D=Re=>{if(!ke)return;const gt=Math.abs(Re.clientX-er.current.x),mt=Math.abs(Re.clientY-er.current.y);(gt>5||mt>5)&&Ga(!0);const Vt=Re.clientX-Le.x,un=Re.clientY-Le.y,aa=67,pr=window.innerWidth-document.body.clientWidth,Pn=Math.max(0,Math.min(window.innerWidth-aa-pr,Vt)),_a=Math.max(0,Math.min(window.innerHeight-aa,un));ct({x:Pn,y:_a})},ae=Re=>{if(!ke)return;Re.preventDefault();const gt=Re.touches[0],mt=Math.abs(gt.clientX-er.current.x),Vt=Math.abs(gt.clientY-er.current.y);(mt>5||Vt>5)&&Ga(!0);const un=gt.clientX-Le.x,aa=gt.clientY-Le.y,pr=67,Pn=window.innerWidth-document.body.clientWidth,_a=Math.max(0,Math.min(window.innerWidth-pr-Pn,un)),Ii=Math.max(0,Math.min(window.innerHeight-pr,aa));ct({x:_a,y:Ii})},ge=()=>{ke&&(De(!1),document.body.style.cursor="",document.body.style.userSelect="")},Se=()=>{ke&&De(!1)};return ke&&(document.addEventListener("mousemove",D),document.addEventListener("touchmove",ae,{passive:!1}),document.addEventListener("mouseup",ge),document.addEventListener("touchend",Se)),()=>{document.removeEventListener("mousemove",D),document.removeEventListener("touchmove",ae),document.removeEventListener("mouseup",ge),document.removeEventListener("touchend",Se)}},[ke,Le,Ke]),pe.useEffect(()=>{const D=()=>{const ge=window.innerWidth-67,Se=window.innerHeight-67;ct(Re=>({x:Math.max(0,Math.min(ge,Re.x)),y:Math.max(0,Math.min(Se,Re.y))}))};return window.addEventListener("resize",D),()=>window.removeEventListener("resize",D)},[]);const bn=/^[\u0600-\u06FF\u0750-\u077F\s\d\p{P}]+$/u,Ko=/[\u0600-\u06FF\u0750-\u077F]/,yn=D=>bn.test(D),Rr=D=>Ko.test(D),Un=pe.useMemo(()=>({h1:({children:D})=>k.jsx("h1",{className:"sm:text-2xl text-xl font-bold my-2",dir:yn(D)?"rtl":"ltr",children:k.jsx(Pt,{sequence:[D,0,()=>{t.current&&(t.current.scrollTop=t.current.scrollHeight)}],cursor:!1,speed:90})}),h2:({children:D})=>k.jsx("h2",{className:"sm:text-xl text-lg font-semibold my-2",dir:yn(D)?"rtl":"ltr",children:k.jsx(Pt,{sequence:[D,0,()=>{t.current&&(t.current.scrollTop=t.current.scrollHeight)}],cursor:!1,speed:90})}),h3:({children:D})=>k.jsx("h3",{className:"sm:text-lg text-base font-semibold my-2",dir:yn(D)?"rtl":"ltr",children:k.jsx(Pt,{sequence:[D,0,()=>{t.current&&(t.current.scrollTop=t.current.scrollHeight)}],cursor:!1,speed:90})}),h4:({children:D})=>k.jsx("h4",{className:"sm:text-base text-sm font-semibold my-2",dir:yn(D)?"rtl":"ltr",children:k.jsx(Pt,{sequence:[D,0,()=>{t.current&&(t.current.scrollTop=t.current.scrollHeight)}],cursor:!1,speed:90})}),h5:({children:D})=>k.jsx("h5",{className:"sm:text-base text-sm font-semibold my-2",dir:yn(D)?"rtl":"ltr",children:k.jsx(Pt,{sequence:[D,0,()=>{t.current&&(t.current.scrollTop=t.current.scrollHeight)}],cursor:!1,speed:90})}),h6:({children:D})=>k.jsx("h6",{className:"sm:text-base text-sm font-semibold my-2",dir:yn(D)?"rtl":"ltr",children:k.jsx(Pt,{sequence:[D,0,()=>{t.current&&(t.current.scrollTop=t.current.scrollHeight)}],cursor:!1,speed:90})}),p:({children:D})=>{let ae;return typeof D=="string"&&Rr(D)||typeof D=="object"&&!Array.isArray(D)&&D?.props?.children&&yn(D?.props?.children)||typeof D=="object"&&Array.isArray(D)&&D.some(ge=>Rr(ge))?ae="rtl":ae="ltr",k.jsx("div",{className:"leading-relaxed",dir:typeof D=="string"||!Array.isArray(D)?ae:"",children:Array.isArray(D)?D.map((ge,Se)=>typeof ge=="string"&&!new RegExp("^(?:\\p{Emoji_Presentation}|\\p{Emoji}\\uFE0F|\\s)+$","u").test(ge)?k.jsx("p",{dir:Rr(ge)?"rtl":"ltr",children:k.jsx(Pt,{sequence:[ge,0,()=>{t.current&&(t.current.scrollTop=t.current.scrollHeight)}],cursor:!1,speed:90})},Se):ge.type!=="br"?ge:null):k.jsx(k.Fragment,{children:D})})},ul:({children:D})=>k.jsx("ul",{className:"list-disc list-inside ml-4 my-2",style:{color:_},dir:Rr(D)?"rtl":"ltr",children:D}),ol:({children:D})=>{let ae=!1;return D.filter(ge=>typeof ge!="string").every(ge=>Rr(ge?.props?.children))?ae=!0:ae=!1,k.jsx("ol",{className:"list-decimal list-inside ml-4 my-2",style:{color:_},dir:ae?"rtl":"ltr",children:typeof D=="string"?k.jsx(Pt,{sequence:[D,0,()=>{t.current&&(t.current.scrollTop=t.current.scrollHeight)}],cursor:!1,speed:92}):D})},li:({children:D})=>k.jsx("li",{className:"my-1",dir:yn(D)?"rtl":"ltr",style:{color:_},children:typeof D=="string"?k.jsx(Pt,{sequence:[D,0,()=>{t.current&&(t.current.scrollTop=t.current.scrollHeight)}],cursor:!1,speed:92}):D}),a:({href:D,children:ae})=>k.jsx("a",{href:D,className:"text-blue-400 underline hover:text-blue-300",target:"_blank",rel:"noopener noreferrer",children:typeof ae=="string"?k.jsx(Pt,{sequence:[ae,0,()=>{t.current&&(t.current.scrollTop=t.current.scrollHeight)}],cursor:!1,speed:92}):ae}),blockquote:({children:D})=>k.jsx("blockquote",{className:"border-l-4 pl-4 italic my-2",style:{borderColor:ee,color:_},children:typeof D=="string"?k.jsx(Pt,{sequence:[D,0,()=>{t.current&&(t.current.scrollTop=t.current.scrollHeight)}],cursor:!1,speed:92}):D}),code({node:D,className:ae,children:ge,...Se}){const Re=/language-(\w+)/.exec(ae||"");return Re?k.jsx(S1,{...Se,PreTag:"div",children:String(ge).replace(/\n$/,""),language:Re[1],style:xY,customStyle:{scrollbarWidth:"thin"}}):k.jsx("code",{className:"px-1 rounded font-mono inline",style:{backgroundColor:A,color:_},...Se,children:typeof ge=="string"?k.jsx(Pt,{sequence:[ge,0,()=>{t.current&&(t.current.scrollTop=t.current.scrollHeight)}],cursor:!1,speed:92}):ge})},table:({children:D})=>k.jsx("table",{className:"min-w-full my-2",style:{border:`1px solid ${_}`,color:Y,backgroundColor:_},children:D}),thead:({children:D})=>k.jsx("thead",{children:D}),tbody:({children:D})=>k.jsx("tbody",{children:D}),tr:({children:D})=>k.jsx("tr",{style:{border:`1px solid ${Y}`},children:D}),th:({children:D})=>k.jsx("th",{className:"px-3 py-2 font-bold text-left",children:D}),td:({children:D})=>k.jsx("td",{className:"px-3 py-2",children:typeof D=="string"?k.jsx(Pt,{sequence:[D,0,()=>{t.current&&(t.current.scrollTop=t.current.scrollHeight)}],cursor:!1,speed:92}):D}),strong:({children:D})=>k.jsx("strong",{className:"font-bold",children:typeof D=="string"?k.jsx(Pt,{sequence:[D,0,()=>{t.current&&(t.current.scrollTop=t.current.scrollHeight)}],cursor:!1,speed:92}):D}),em:({children:D})=>k.jsx("em",{className:"italic ",children:typeof D=="string"?k.jsx(Pt,{sequence:[D,0,()=>{t.current&&(t.current.scrollTop=t.current.scrollHeight)}],cursor:!1,speed:92}):D}),hr:()=>k.jsx("hr",{className:"my-4",style:{borderColor:`1px solid ${_}`}})}),[w,_,ee,A,N]);pe.useEffect(()=>{const D=ae=>{vt&&ae.target instanceof Element&&!ae.composedPath().some(ge=>ge?.id==="upload-button-toggle"||ge?.id==="document-button"||ge?.id==="image-button"||ge?.id==="video-button"||ge?.id==="audio-button")&&Dt(!1)};return document.addEventListener("mousedown",D),()=>{document.removeEventListener("mousedown",D)}},[vt]);const Zl=D=>{switch(D.type){case"text":return Array.isArray(D.text)?k.jsx(O1,{products:D.text[0]?.items||[],onValidate:ae=>{xr("cart",ae)},agentChatResponseColor:_,agentChatResponseBgColor:Y,buttonsBgColor:ee,buttonColor:H,chatRoundness:N,panelWidth:_e}):k.jsx(No,{remarkPlugins:[ko],components:Un,children:D.text?.replace(/\n/g,`
351
351
  `)});case"single-choice":return k.jsxs(k.Fragment,{children:[k.jsx(No,{remarkPlugins:[ko],components:Un,children:D.text?.replace(/\n/g,`
352
352
  `)||""}),k.jsx("div",{className:"flex flex-wrap",dir:yn(D.text||"")?"rtl":"ltr",children:D.choices?.map((ae,ge)=>k.jsx("button",{className:"mb-1 mr-1 px-4 py-1 hover:scale-105 transition-all duration-100",onClick:()=>{xr(ae.title)},style:{background:ee,borderRadius:`${N}px`,color:H},dir:yn(ae.title)?"rtl":"ltr",children:k.jsx(Pt,{sequence:[ae.title,0,()=>{t.current&&(t.current.scrollTop=t.current.scrollHeight)}],wrapper:"span",cursor:!1,speed:92})},ge))})]});case"image":return k.jsx(k.Fragment,{children:k.jsx("div",{className:"relative group",children:k.jsx("img",{src:D.image,className:"max-w-xs max-h-48 rounded-lg object-cover cursor-pointer hover:opacity-90 transition-opacity",onClick:()=>window.open(D.image,"_blank")})})});case"dropdown":return k.jsxs(k.Fragment,{children:[k.jsx(No,{remarkPlugins:[ko],components:Un,children:D.message?.replace(/\n/g,`
353
353
  `)}),k.jsx(HY,{options:D.options||[],message:D.message,allowMultiple:D.allowMultiple||!1,chatRoundness:N,buttonsBgColor:ee,buttonColor:H,agentChatResponseColor:_,isRtl:yn(D.message||""),onSend:xr,onScroll:()=>{t.current&&(t.current.scrollTop=t.current.scrollHeight)}})]});case"carousel":return k.jsx(qY,{items:D.items||[],messageTitle:D.title,chatRoundness:N,agentChatResponseBgColor:Y,agentChatResponseColor:_,buttonsBgColor:ee,buttonColor:H,inputBackgroundColor:A,onButtonClick:xr});case"file":return k.jsx("div",{className:"p-2 rounded-lg max-w-xs cursor-pointer transition-colors",onClick:()=>window.open(D.file,"_blank"),onMouseEnter:ae=>ae.currentTarget.style.backgroundColor=ee,onMouseLeave:ae=>ae.currentTarget.style.backgroundColor="transparent",title:D.title,children:k.jsxs("div",{className:"flex items-center gap-3",children:[k.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center",style:{background:ee},children:k.jsx(md,{className:"w-5 h-5 ",style:{color:_}})}),k.jsx("div",{className:"flex-1 min-w-0",children:k.jsx("p",{className:"text-sm font-medium truncate",style:{color:_},children:D.title})})]})});case"products":return k.jsx(O1,{products:D.products||[],onValidate:ae=>{const ge=JSON.stringify(ae);xr("Vente ",ge)},agentChatResponseColor:_,agentChatResponseBgColor:Y,buttonsBgColor:ee,buttonColor:H,chatRoundness:N,panelWidth:_e,inputBackgroundColor:A})}},Jl=async D=>{if(!sn)return;const ae=await fetch(`${C1}/endusers/get-by-username`,{headers:{Authorization:`Bearer ${e?.token}`,"Content-Type":"application/json"},method:"POST",body:JSON.stringify({username:`web_user_${D}`})});if(!ae.ok)throw new Error(`HTTP error! status: ${ae.status}`);return(await ae.json()).id},na=async D=>{if(!sn)return;const ae=await Jl(D);let ge;Bn&&(ge={last_name:Bn.split(" ")[1]||Bn.split(" ")[0]||`web_user_${D}`,first_name:Bn.split(" ")[0]||`web_user_${D}`}),St&&(ge={...ge,phone:St}),qa&&(ge={...ge,email:qa});const Se=await fetch(`${C1}/endusers/${ae}`,{headers:{Authorization:`Bearer ${e?.token}`,"Content-Type":"application/json"},method:"PUT",body:JSON.stringify(ge)});if(!Se.ok)throw new Error(`HTTP error! status: ${Se.status}`);return await Se.json()},Qb=async D=>{D.preventDefault();const ae=new Uint8Array(16);window.crypto.getRandomValues(ae);const ge=Array.from(ae).map(Se=>Se.toString(16).padStart(2,"0")).join("");Ti(ge),localStorage.setItem("conversationId",ge),localStorage.setItem("webChatAuth","true"),$r(!0)},[$l,ra]=pe.useState(!1),Qo=async()=>{wr([]);const D=new Uint8Array(16);window.crypto.getRandomValues(D);const ae=Array.from(D).map(ge=>ge.toString(16).padStart(2,"0")).join("");return Ti(ae),localStorage.setItem("conversationId",ae),ae},Zb=`linear-gradient(to bottom right, ${y}, ${h}, ${y})`,eu=`linear-gradient(to right, ${h}, ${m})`,Oi=`linear-gradient(to right, ${E}, ${v})`;return f||!u?null:k.jsxs(k.Fragment,{children:[k.jsx("style",{children:`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tybotflow-widget",
3
- "version": "0.3.5",
3
+ "version": "0.3.6",
4
4
  "description": "A modern, customizable React widget for Tybot chat integration.",
5
5
  "license": "ISC",
6
6
  "main": "dist/index.umd.js",