@chatsystem/client 1.1.34 → 1.1.35

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.cjs CHANGED
@@ -34,7 +34,7 @@ Try polyfilling it using "@formatjs/intl-pluralrules"
34
34
  Try polyfilling it using "@formatjs/intl-relativetimeformat"
35
35
  `,ct.MISSING_INTL_API));try{return Fc(e,t,a).format(n,r)}catch(u){e.onError(new et("Error formatting relative time.",e.locale,u))}return String(n)}var Uc=["style","currency","unit","unitDisplay","useGrouping","minimumIntegerDigits","minimumFractionDigits","maximumFractionDigits","minimumSignificantDigits","maximumSignificantDigits","compactDisplay","currencyDisplay","currencySign","notation","signDisplay","unit","unitDisplay","numberingSystem","trailingZeroDisplay","roundingPriority","roundingIncrement","roundingMode"];function Ss(e,t,n){var r=e.locale,a=e.formats,i=e.onError;n===void 0&&(n={});var u=n.format,o=u&&Ua(a,"number",u,i)||{},l=Ft(n,Uc,o);return t(r,l)}function jc(e,t,n,r){r===void 0&&(r={});try{return Ss(e,t,r).format(n)}catch(a){e.onError(new et("Error formatting number.",e.locale,a))}return String(n)}function $c(e,t,n,r){r===void 0&&(r={});try{return Ss(e,t,r).formatToParts(n)}catch(a){e.onError(new et("Error formatting number.",e.locale,a))}return[]}function Yc(e){var t=e?e[Object.keys(e)[0]]:void 0;return typeof t=="string"}function Gc(e){e.onWarn&&e.defaultRichTextElements&&Yc(e.messages||{})&&e.onWarn(`[@formatjs/intl] "defaultRichTextElements" was specified but "message" was not pre-compiled.
36
36
  Please consider using "@formatjs/cli" to pre-compile your messages for performance.
37
- For more details see https://formatjs.io/docs/getting-started/message-distribution`)}function zc(e,t){var n=Sc(t),r=q(q({},As),e),a=r.locale,i=r.defaultLocale,u=r.onError;return a?!Intl.NumberFormat.supportedLocalesOf(a).length&&u?u(new Si('Missing locale data for locale: "'.concat(a,'" in Intl.NumberFormat. Using default locale: "').concat(i,'" as fallback. See https://formatjs.io/docs/react-intl#runtime-requirements for more details'))):!Intl.DateTimeFormat.supportedLocalesOf(a).length&&u&&u(new Si('Missing locale data for locale: "'.concat(a,'" in Intl.DateTimeFormat. Using default locale: "').concat(i,'" as fallback. See https://formatjs.io/docs/react-intl#runtime-requirements for more details'))):(u&&u(new Ac('"locale" was not configured, using "'.concat(i,'" as fallback. See https://formatjs.io/docs/react-intl/api#intlshape for more details'))),r.locale=r.defaultLocale||"en"),Gc(r),q(q({},r),{formatters:n,formatNumber:jc.bind(null,r,n.getNumberFormat),formatNumberToParts:$c.bind(null,r,n.getNumberFormat),formatRelativeTime:Hc.bind(null,r,n.getRelativeTimeFormat),formatDate:Cc.bind(null,r,n.getDateTimeFormat),formatDateToParts:Oc.bind(null,r,n.getDateTimeFormat),formatTime:Ic.bind(null,r,n.getDateTimeFormat),formatDateTimeRange:Nc.bind(null,r,n.getDateTimeFormat),formatTimeToParts:Lc.bind(null,r,n.getDateTimeFormat),formatPlural:Mc.bind(null,r,n.getPluralRules),formatMessage:ma.bind(null,r,n),$t:ma.bind(null,r,n),formatList:kc.bind(null,r,n.getListFormat),formatListToParts:xs.bind(null,r,n.getListFormat),formatDisplayName:vc.bind(null,r,n.getDisplayNames)})}function Cs(e){ts(e,"[React Intl] Could not find required `intl` object. <IntlProvider> needs to exist in the component ancestry.")}var Is=q(q({},As),{textComponent:De.Fragment});function Vc(e){return function(t){return e(De.Children.toArray(t))}}function qc(e,t){if(e===t)return!0;if(!e||!t)return!1;var n=Object.keys(e),r=Object.keys(t),a=n.length;if(r.length!==a)return!1;for(var i=0;i<a;i++){var u=n[i];if(e[u]!==t[u]||!Object.prototype.hasOwnProperty.call(t,u))return!1}return!0}var ja=typeof window<"u"&&!window.__REACT_INTL_BYPASS_GLOBAL_CONTEXT__?window.__REACT_INTL_CONTEXT__||(window.__REACT_INTL_CONTEXT__=De.createContext(null)):De.createContext(null);ja.Consumer;var Wc=ja.Provider,Xc=Wc,Qc=ja;function Pn(){var e=De.useContext(Qc);return Cs(e),e}var pa;(function(e){e.formatDate="FormattedDate",e.formatTime="FormattedTime",e.formatNumber="FormattedNumber",e.formatList="FormattedList",e.formatDisplayName="FormattedDisplayName"})(pa||(pa={}));var Ea;(function(e){e.formatDate="FormattedDateParts",e.formatTime="FormattedTimeParts",e.formatNumber="FormattedNumberParts",e.formatList="FormattedListParts"})(Ea||(Ea={}));function Ns(e){var t=function(n){var r=Pn(),a=n.value,i=n.children,u=pr(n,["value","children"]),o=typeof a=="string"?new Date(a||0):a,l=e==="formatDate"?r.formatDateToParts(o,u):r.formatTimeToParts(o,u);return i(l)};return t.displayName=Ea[e],t}function Dn(e){var t=function(n){var r=Pn(),a=n.value,i=n.children,u=pr(n,["value","children"]),o=r[e](a,u);if(typeof i=="function")return i(o);var l=r.textComponent||De.Fragment;return De.createElement(l,null,o)};return t.displayName=pa[e],t}function Os(e){return e&&Object.keys(e).reduce(function(t,n){var r=e[n];return t[n]=gs(r)?Vc(r):r,t},{})}var Oi=function(e,t,n,r){for(var a=[],i=4;i<arguments.length;i++)a[i-4]=arguments[i];var u=Os(r),o=ma.apply(void 0,st([e,t,n,u],a,!1));return Array.isArray(o)?De.Children.toArray(o):o},Li=function(e,t){var n=e.defaultRichTextElements,r=pr(e,["defaultRichTextElements"]),a=Os(n),i=zc(q(q(q({},Is),r),{defaultRichTextElements:a}),t),u={locale:i.locale,timeZone:i.timeZone,fallbackOnEmptyString:i.fallbackOnEmptyString,formats:i.formats,defaultLocale:i.defaultLocale,defaultFormats:i.defaultFormats,messages:i.messages,onError:i.onError,defaultRichTextElements:a};return q(q({},i),{formatMessage:Oi.bind(null,u,i.formatters),$t:Oi.bind(null,u,i.formatters)})};function Dr(e){return{locale:e.locale,timeZone:e.timeZone,fallbackOnEmptyString:e.fallbackOnEmptyString,formats:e.formats,textComponent:e.textComponent,messages:e.messages,defaultLocale:e.defaultLocale,defaultFormats:e.defaultFormats,onError:e.onError,onWarn:e.onWarn,wrapRichTextChunksInFragment:e.wrapRichTextChunksInFragment,defaultRichTextElements:e.defaultRichTextElements}}var Kc=(function(e){Je(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.cache=_s(),n.state={cache:n.cache,intl:Li(Dr(n.props),n.cache),prevConfig:Dr(n.props)},n}return t.getDerivedStateFromProps=function(n,r){var a=r.prevConfig,i=r.cache,u=Dr(n);return qc(a,u)?null:{intl:Li(u,i),prevConfig:u}},t.prototype.render=function(){return Cs(this.state.intl),De.createElement(Xc,{value:this.state.intl},this.props.children)},t.displayName="IntlProvider",t.defaultProps=Is,t})(De.PureComponent);Dn("formatDate");Dn("formatTime");Dn("formatNumber");Dn("formatList");Dn("formatDisplayName");Ns("formatDate");Ns("formatTime");const Zc={"generic.language.english":"English","generic.language.french":"French","generic.connect.google":"Connect with Google","generic.button.title.save":"Save","page.login.button.login":"Login / Register","page.login.google.login":"Continue with Google","navbar.button.home":"Home","navbar.button.pricing":"Pricing","navbar.button.login":"Login","navbar.button.demo":"Demo","navbar.userMenu.logout":"Log out","navbar.userMenu.profile":"Profile","navbar.userMenu.backOffice":"Back-office","home.header.catchphase":"The catchphrase you wanted","home.header.subcatchphase":"Discover the new software that will change it all","home.header.CTA":"See more","home.section.bulletsPointParagraphe1.title":"Management","home.section.bulletsPointParagraphe1.text":"Take advantage of a complete solution to have a direct point of view on all of your units.","home.section.bulletsPointParagraphe2.title":"Automation","home.section.bulletsPointParagraphe2.text":"In just a few clicks, manage your entire fleet. Implement macros and synergies on your systems.","home.section.bulletsPointParagraphe3.title":"Reporting","home.section.bulletsPointParagraphe3.text":"With its BI module, our software allows you to monitor performance and optimize your costs.","home.realm.title":"See the root of your business in a few clicks","home.realm.text":"The security of your data is at the heart of our concerns. Our software was created in France, we are ISO 27001 certified and all our servers are located in Europe.","home.realm.cta":"Discover our solution","home.testimonials.title":"What our customers say","home.testimonials.1.text":"Since using the software, we have better control of the flow of goods and relevant performance monitoring.","home.testimonials.1.job":"Developer @Wordpress","home.testimonials.1.name":"Loic Martins","home.testimonials.2.text":"Putting the software solution into production allowed us to completely reorganize the teams.","home.testimonials.2.job":"Community Manager @Comet","home.testimonials.2.name":"Anna Wang","home.testimonials.3.text":"Mastery of the logistics subject is obvious with the software solution.","home.testimonials.3.job":"Product Owner @April","home.testimonials.3.name":"Louis Bachant","home.test.section.title":"Try it out now","home.test.section.CTA":"See our solution","pricing.CTA.pleaseLogin":"Login to buy","pricing.page.title":"Choose your plan","pricing.page.subtitle":"No obligation: cancel at any time with one click.","subscribe.paymentRecap.title":"Payment Summary","subscribe.paymentRecap.customerName":"Name","subscribe.paymentRecap.customerMail":"Email","subscribe.paymentRecap.additionnalMention":"Mention to add","subscribe.paymentRecap.totalAmount":"Total Amount","subscribe.paymentForm.title":"Bank card","subscribe.paymentForm.cardNumber":"Card number","subscribe.paymentForm.expiresAt":"Expires at","subscribe.paymentForm.CVCNumber":"CVC number","subscribe.paymentForm.CTA.loading":"Loading ...","subscribe.paymentForm.CTA.pay":"Pay now","subscribe.success.title":"Payment successful","subscribe.success.paragraph1":"Your payment has been processed successfully. You are now suscribed !","subscribe.success.paragraph2":"Your new options are now available.","myAccount.page.leftMenu.general":"General","myAccount.page.leftMenu.profile":"Profile","chatbot.placeholder.content":"Message the assistant...","chatbot.DiscussionLimitReached.title":"Discussion limit reached","chatbot.DiscussionLimitReached.explaination":"The discussion has reached its maximum number of messages. Please start a new one.","chatbot.DiscussionLimitReached.cta":"Restart","chatbot.error.api.409":"Oups ! The discussion if full. Please start a new one.","chatbot.error.api.429":"⏳ The chatbot is a little busy at the time. Please try again later.","chatbot.error.api.500":"Oops ! There has been an error. Please try again later.","chatbot.chatline.label.user":"You","chatbot.chatline.label.assistant":"Assistant","chatbot.chatline.loading.function.genericSearchMessage":"I'm looking for products","chatbot.chatline.loading.function.search":"Search","chatbot.chatline.loading.function.extractProductName":"Looking into the cavern","chatbot.chatline.loading.function.suggestProductName":"Consulting the shadocks","chatbot.chatline.loading.function.criteriaDefinition":"Looking for ziboublis","chatbot.chatline.loading.function.searchStock":"Searching Stock","chatbot.chatline.loading.function.step":"Step","chatbot.chatline.loading.cancel":"Cancel","footer.tab.title.general":"General","footer.tab.title.about":"About","footer.tab.title.resources":"Resources","footer.tab.title.legal":"Legal","footer.tab.title.social":"Social","footer.tab.search":"Search","footer.tab.pricing":"Pricing","footer.tab.termsAndConditions":"Terms and conditions","footer.tab.finalCopyright":"Copyright © 2023 Logiciel, Inc. All rights reserved."},Jc={"generic.language.english":"Anglais","generic.language.french":"Français","generic.connect.google":"Se connecter avec Google","generic.button.title.save":"Sauvegarder","page.login.button.login":"Se connecter / S'inscrire","page.login.google.login":"Continuer avec Google","navbar.button.home":"Accueil","navbar.button.pricing":"Tarifs","navbar.button.login":"Se Connecter","navbar.button.demo":"Demo","navbar.userMenu.logout":"Déconnection","navbar.userMenu.profile":"Profil","navbar.userMenu.backOffice":"Back-office","home.header.catchphase":"Catchphrase de l'espace","home.header.subcatchphase":"Découvrez le logiciel qui met fin à vos problèmes","home.header.CTA":"Voir notre solution","home.section.bulletsPointParagraphe1.title":"Management","home.section.bulletsPointParagraphe1.text":"Profitez d'une solution complète pour avoir un point de vue direct sur l'ensemble de vos unités.","home.section.bulletsPointParagraphe2.title":"Automatisation","home.section.bulletsPointParagraphe2.text":"En quelques clicks, gérez l'ensemble de votre flotte. Mettez en place des macros et des synergies sur vos systèmes.","home.section.bulletsPointParagraphe3.title":"Reporting","home.section.bulletsPointParagraphe3.text":"Avec son module BI, notre logiciel vous permet de monitorer la performance et d'optimiser vos coûts. A l'euro prêt","home.realm.title":"Le coeur du métier en quelques clics","home.realm.text":"La sécurité de vos données est au cœur de nos préoccupations. Notre logiciel a été créé en France, nous sommes certifiés ISO 27001 et tous nos serveurs sont situés en Europe.","home.realm.cta":"Voir notre solution","home.testimonials.title":"Nos clients parlent de nous","home.testimonials.1.text":"Depuis notre utilisation du logiciel, nous avons un meilleur contrôle du flux de marchandises et un suivi de performance pertinent.","home.testimonials.1.job":"Developpeur @Wordpress","home.testimonials.1.name":"Loic Martins","home.testimonials.2.text":"La mise en production de la solution logicielle nous a permis de réorganiser complètement les équipes.","home.testimonials.2.job":"Community Manager @Comet","home.testimonials.2.name":"Anna Wang","home.testimonials.3.text":"La maitrise du sujet logistique est une évidence avec la solution logicielle.","home.testimonials.3.job":"Product Owner @April","home.testimonials.3.name":"Louis Bachant","home.test.section.title":"Testez dès maintenant","home.test.section.CTA":"Voir notre solution","pricing.CTA.pleaseLogin":"Connectez-vous","pricing.page.title":"Choisissez votre plan","pricing.page.subtitle":"Sans engagement : annulez à tout moment en un clic.","subscribe.paymentRecap.title":"Récapitulatif de paiement","subscribe.paymentRecap.customerName":"Nom","subscribe.paymentRecap.customerMail":"Email","subscribe.paymentRecap.additionnalMention":"Mention à ajouter","subscribe.paymentRecap.totalAmount":"Total","subscribe.paymentForm.title":"Carte bancaire","subscribe.paymentForm.cardNumber":"Numéro de carte","subscribe.paymentForm.expiresAt":"Expire le","subscribe.paymentForm.CVCNumber":"Numéro CVV","subscribe.paymentForm.CTA.loading":"Chargement ...","subscribe.paymentForm.CTA.pay":"S'abonner","subscribe.success.title":"Paiement effectué avec succès","subscribe.success.paragraph1":"Votre paiement a bien été accepté. Vous êtes désormais abonné !","subscribe.success.paragraph2":"Toutes vos options sont maintenant disponibles.","myAccount.page.leftMenu.general":"Général","myAccount.page.leftMenu.profile":"Profil","chatbot.placeholder.content":"Envoyez un message à l'assistant ...","chatbot.DiscussionLimitReached.title":"Maximum de messages envoyés atteint.","chatbot.DiscussionLimitReached.explaination":"Le robot est à son maximum et ne peut plus envoyer de message. Merci de relancer une conversation.","chatbot.DiscussionLimitReached.cta":"Relancer une nouvelle conversation","chatbot.error.api.409":"Oups ! La discussion est à son maximum. Merci d'en commencer une nouvelle.","chatbot.error.api.429":"⏳ Le robot est un peu occupé actuellement. Merci de réessayer plus tard.","chatbot.error.api.500":"Oups ! Une erreur est survenue. Merci de réessayer plus tard !","chatbot.chatline.label.user":"Vous","chatbot.chatline.label.assistant":"Assistant","chatbot.chatline.loading.function.search":"Recherche","chatbot.chatline.loading.function.genericSearchMessage":"Je cherche des produits","chatbot.chatline.loading.function.extractProductName":"Recherche dans la caverne","chatbot.chatline.loading.function.suggestProductName":"Consultation des shadocks","chatbot.chatline.loading.function.criteriaDefinition":"Recherche des ziboublis","chatbot.chatline.loading.function.searchStock":"Recherche en stock","chatbot.chatline.loading.function.step":"Etape","chatbot.chatline.loading.cancel":"Annuler","footer.tab.title.general":"Général","footer.tab.title.about":"A propos","footer.tab.title.resources":"Ressources","footer.tab.title.legal":"Mentions Légales","footer.tab.title.social":"Social","footer.tab.search":"Rechercher","footer.tab.pricing":"Tarifs","footer.tab.termsAndConditions":"Termes et conditions","footer.tab.finalCopyright":"Copyright © 2023 Logiciel, Inc. Tous droits réservés."};var Xe=(e=>(e.FRENCH="fr-FR",e.ENGLISH="en-US",e))(Xe||{});const br={[Xe.ENGLISH]:{translatedText:Zc,pictureName:Xe.ENGLISH,langID:0,locale:Xe.ENGLISH},[Xe.FRENCH]:{translatedText:Jc,pictureName:Xe.FRENCH,langID:1,locale:Xe.FRENCH}},ef=Object.keys(br);ef.reduce((e,t)=>{const n=br[t];return[...e,n]},[]);const tf="languageSettings",nf=(e,t)=>{let n,r;return typeof window<"u"&&(r=window.localStorage.getItem(tf)),r&&e?.[r]!==void 0?n=e[r]:(n=e[t],n.isDefault=!0),n},rf=(e,t)=>{const[n,r]=N.useState(e[t]),a=i=>{Object.keys(e).includes(i?.locale)?r(i):r(e[Xe.ENGLISH])};return N.useEffect(()=>{let i=nf(e,t);i.locale!==t&&r(e[i.locale])},[]),{appCurrentLang:n,handleSetContextCurrentLang:a}},Ls=N.createContext({appCurrentLang:br[Xe.ENGLISH],setAppCurrentLang:()=>{}}),Rs=N.createContext({conversation:[],setConversation:()=>{}});var Rt={},Ri;function af(){if(Ri)return Rt;Ri=1,Object.defineProperty(Rt,"__esModule",{value:!0}),Rt.AgentDisplayFacetRoleType=Rt.AgentDisplayFacetModeType=void 0;var e;(function(n){n.SPRITESHEET="spritesheet",n.LOTTIE="lottie",n.IMAGE="image",n.SVG="svg",n.VIDEO="video"})(e||(Rt.AgentDisplayFacetModeType=e={}));var t;return(function(n){n.LAUNCHER="launcher",n.ASSISTANT="assistant",n.SEARCH="search"})(t||(Rt.AgentDisplayFacetRoleType=t={})),Rt}var Ye=af();const kr=e=>({mode:Ye.AgentDisplayFacetModeType.SVG,role:e}),uf=()=>({agent:{display:{name:"",CSSRules:"",[Ye.AgentDisplayFacetRoleType.LAUNCHER]:kr(Ye.AgentDisplayFacetRoleType.LAUNCHER),[Ye.AgentDisplayFacetRoleType.ASSISTANT]:kr(Ye.AgentDisplayFacetRoleType.ASSISTANT),[Ye.AgentDisplayFacetRoleType.SEARCH]:kr(Ye.AgentDisplayFacetRoleType.SEARCH)},text:{initialText:""}},api:{settings:{maxUserMessagesPerDiscussion:20}}}),kn=N.createContext({companySettings:uf(),setCompanySettings:()=>{}}),vs=()=>({hasFetchedSettings:!1,hasDisplayedCSS:!1}),sf=()=>{const[e,t]=N.useState(vs());return{appInternalContext:e,setAppInternalContext:t,setHasFetchedSettings:()=>{t(a=>({...a,hasFetchedSettings:!0}))},setHasDisplayedCss:()=>{t(a=>({...a,hasDisplayedCSS:!0}))}}},Ps=N.createContext({appInternalContext:vs(),setAppInternalContext:()=>{},setHasFetchedSettings:()=>{}}),of=e=>Object.values(Xe).includes(e),lf=e=>of(e)?e:(console.log(`Language ${e} not handled for now. Using ${Xe.ENGLISH}.`),Xe.ENGLISH);class Nn{constructor(){}static getApiUrl=()=>process.env.NODE_ENV==="development"?"http://localhost:3001":"https://www.api.chatsystem.ai";static getHeaders=({contentType:t="text/plain"})=>({"Content-Type":t});static getFetchConfig=({contentType:t="text/plain",httpVerb:n="GET",body:r,options:a={}})=>{const i={method:n,headers:this.getHeaders({contentType:t}),...a};return r&&(i.body=JSON.stringify(r)),i}}const cf=({agentId:e,appToken:t,onFetched:n})=>{const[r,a]=N.useState({}),i={companySettings:r,setCompanySettings:a},[u,o]=N.useState([]),l={conversation:u,setConversation:o};return N.useEffect(()=>{const c=Nn.getApiUrl(),f=Nn.getFetchConfig({httpVerb:"GET",contentType:"application/json"});fetch(`${c}/company/settings/${t}/${e}`,f).then(async d=>{const h=await d.json();a(h),o([{userType:"assistant",content:h.agent.text.initialText}]),n?.()}).catch(d=>console.log("error in settings fetch",d))},[t,e]),{contextCompanySettings:i,contextInitialChatbotStartingText:l}};function ff(e,t={},n,r){const{id:a,nonce:i,target:u,disableConstructable:o}=t,l=u??document.head,c=N.useRef(null),f=N.useRef(null);N.useEffect(()=>{if(!e){n&&(console.log("No custom css found."),r?.());return}if(!o&&"adoptedStyleSheets"in l&&typeof CSSStyleSheet<"u"&&"replaceSync"in CSSStyleSheet.prototype)return c.current||(c.current=new CSSStyleSheet,l.adoptedStyleSheets=[...l.adoptedStyleSheets,c.current]),c.current.replaceSync(e),console.log("Loading custom css via stylesheet."),r?.(),()=>{const h=l.adoptedStyleSheets||[],m=h.indexOf(c.current);if(m>=0){const _=h.slice();_.splice(m,1),l.adoptedStyleSheets=_}c.current=null};if(!f.current){const h=document.createElement("style");h.type="text/css",a&&(h.id=a),i&&(h.nonce=i),(l instanceof Document&&l.head||l).appendChild(h),f.current=h}return f.current.textContent=e,console.log("Loading custom css via style tag."),r?.(),()=>{f.current?.parentNode?.removeChild(f.current),f.current=null}},[e,a,i,u,o])}const Jt=globalThis;Jt.__WIDGET_ASSET_CACHE__||(Jt.__WIDGET_ASSET_CACHE__={svg:new Map,img:new Map,lot:new Map,spr:new Map});Jt.__WIDGET_PRELOAD_KEYS__||(Jt.__WIDGET_PRELOAD_KEYS__=new Set);const wr=Jt.__WIDGET_PRELOAD_KEYS__,_t=Jt.__WIDGET_ASSET_CACHE__,df="widget-assets-v1";async function gr(e,t){try{const n=await caches.open(df),r=await n.match(e,{ignoreSearch:!1});if(r)return r.clone();const a=await fetch(e,{cache:"force-cache",mode:"cors",keepalive:!0,...t});if(!a.ok)throw new Error(`HTTP ${a.status} for ${e}`);return n.put(e,a.clone()),a}catch(n){return console.log("error while fetching",n),new Response(null,{status:520,statusText:"Error in client - Fetch failed"})}}async function Ds(e){const t=_t.svg.get(e);if(t)return t.promise;const n=(async()=>{const a=await(await gr(e)).text();if(typeof globalThis.DOMPurify<"u"&&typeof globalThis.DOMPurify.sanitize=="function")try{const u=new DOMParser().parseFromString(a,"image/svg+xml"),o=new XMLSerializer().serializeToString(u.documentElement);return{sanitized:globalThis.DOMPurify.sanitize(o,{USE_PROFILES:{svg:!0,svgFilters:!0}})}}catch{return{sanitized:globalThis.DOMPurify.sanitize(a,{USE_PROFILES:{svg:!0,svgFilters:!0}})}}else return{sanitized:a}})();return _t.svg.set(e,{promise:n,ts:Date.now()}),n}function ks(e){const t=_t.img.get(e);if(t)return t.promise;const n=(async()=>{const a=await(await gr(e)).blob();return{blobUrl:URL.createObjectURL(a)}})();return _t.img.set(e,{promise:n,ts:Date.now()}),n}function ws(e){const t=_t.lot.get(e);if(t)return t.promise;const n=(async()=>{const a=await(await gr(e)).arrayBuffer(),i=new Uint8Array(a);if(i.length>=4&&i[0]===80&&i[1]===75&&i[2]===3&&i[3]===4||e.endsWith(".lottie"))return{kind:"zip",blobUrl:URL.createObjectURL(new Blob([a],{type:"application/zip"}))};const o=new TextDecoder().decode(i);return{kind:"json",data:JSON.parse(o)}})();return _t.lot.set(e,{promise:n,ts:Date.now()}),n}function Ms(e){const t=_t.spr.get(e);if(t)return t.promise;const n=(async()=>{const a=await(await gr(e)).blob();let i=null;try{i=await createImageBitmap(a)}catch{i=null}const{imgEl:u,width:o,height:l}=await new Promise((c,f)=>{const d=URL.createObjectURL(a),h=new Image;h.crossOrigin="anonymous",h.onload=()=>{const m=h.naturalWidth,_=h.naturalHeight;c({imgEl:h,width:m,height:_})},h.onerror=()=>{URL.revokeObjectURL(d),f(new Error("Spritesheet image decode failed"))},h.src=d,h.decode?.().catch(()=>{})});return{imgEl:u,bitmap:i,width:o,height:l}})();return _t.spr.set(e,{promise:n,ts:Date.now()}),n}function hf(e){e.images?.forEach(t=>void ks(t)),e.svgs?.forEach(t=>void Ds(t)),e.lotties?.forEach(t=>void ws(t)),e.sprites?.forEach(t=>void Ms(t))}function mf(e){try{const t=document.createElement("link");t.rel="preconnect",t.href=e,t.crossOrigin="anonymous",document.head.appendChild(t);const n=document.createElement("link");n.rel="dns-prefetch",n.href=e,document.head.appendChild(n)}catch(t){console.log("error in injectPreconnect",t)}}function Bs(e){return new URL(e,document.baseURI).toString()}function pf(e,t){const n=document.head.querySelectorAll('link[rel="preload"]');for(const r of n)if((e?r.as===e||r.getAttribute("as")===e:!0)&&r.href===t)return!0;return!1}function zn(e,t,n,r){const a=Bs(n),i=`${e}|${t??""}|${a}`;if(wr.has(i))return;if(pf(t,a)){wr.add(i);return}const u=document.createElement("link");u.rel=e,t&&(u.as=t),u.href=a,u.crossOrigin="anonymous",r&&(u.type=r),u.setAttribute("data-chatsystem-preload","1"),document.head.appendChild(u),wr.add(i)}function Ef(e){const t=u=>Array.from(new Set((u??[]).map(Bs))),n=t(e.images),r=t(e.svgs),a=t(e.lotties),i=t(e.sprites);n.forEach(u=>zn("preload","image",u)),r.forEach(u=>zn("preload","fetch",u,"image/svg+xml")),a.forEach(u=>zn("preload","fetch",u,"application/zip")),i.forEach(u=>zn("preload","fetch",u))}function bf(e){const{manifest:t,origins:n}=gf(e);n.forEach(mf),Ef(t),hf(t)}function gf(e){const t=Tf(e),n=new Set,r=new Set,a=new Set,i=new Set;for(const{url:l,mode:c}of t)switch(Af(c,l)){case"svg":r.add(l);break;case"lottie":a.add(l);break;case"spritesheet":i.add(l);break;case"image":n.add(l);break}const u={images:Array.from(n),svgs:Array.from(r),lotties:Array.from(a),sprites:Array.from(i)},o=_f(u);return{manifest:u,origins:o}}function Tf(e){if(!e?.agent?.display)return[];const t=e.agent.display,n=[t.launcher,t.assistant,t.search].filter(Boolean),r=[];for(const a of n)a?.assetUrl&&r.push({url:a.assetUrl,mode:a.mode});return r}function Af(e,t){if(e)switch(e){case"svg":return"svg";case"lottie":return"lottie";case"spritesheet":return"spritesheet";case"image":return"image";case"video":return"video"}try{const r=new URL(t,document.baseURI).pathname.toLowerCase();if(r.endsWith(".svg"))return"svg";if(r.endsWith(".lottie")||r.endsWith(".zip")||r.endsWith(".json"))return r.endsWith(".json"),"lottie";if(/\.(png|webp|jpg|jpeg|gif|avi,ef)$/.test(r))return"image";if(/\.(mp4|webm|mov|m4v|ogg)$/.test(r))return"video"}catch(n){console.log("error in normalizeKind:",n)}return"unknown"}function _f(e){const t=new Set,n=r=>{if(r)try{const a=new URL(r,document.baseURI);t.add(`${a.protocol}//${a.host}`)}catch(a){console.log("error in uniqueOriginsFromManifest",a)}};return(e.images??[]).forEach(n),(e.svgs??[]).forEach(n),(e.lotties??[]).forEach(n),(e.sprites??[]).forEach(n),Array.from(t)}const yf=({children:e,appToken:t,agentId:n})=>{var r=navigator.language;console.log("App boot"),console.log("Brower language",r);const a=lf(r),{appCurrentLang:i,handleSetContextCurrentLang:u}=rf(br,a),o={appCurrentLang:i,setAppCurrentLang:u},l=sf(),{contextCompanySettings:c,contextInitialChatbotStartingText:f}=cf({agentId:n,appToken:t,onFetched:l.setHasFetchedSettings});return bf(c.companySettings),ff(c.companySettings?.agent?.display?.CSSRules,{id:`${n}`},l.appInternalContext.hasFetchedSettings,l.setHasDisplayedCss),L.jsx(L.Fragment,{children:L.jsx(Kc,{locale:i?.locale,messages:i?.translatedText,children:L.jsx(Ls.Provider,{value:o,children:L.jsx(Ps.Provider,{value:l,children:L.jsx(kn.Provider,{value:c,children:L.jsx(Rs.Provider,{value:f,children:l.appInternalContext.hasDisplayedCSS&&e})})})})})})},xf=e=>Object.values(nn).includes(e),Sf=e=>xf(e)?e:(console.warn(`Display mode not valid. Using ${nn.LAUNCHER} as default.`),nn.LAUNCHER),Cf=e=>De.createElement("svg",{fill:"#000000",height:"800px",width:"800px",id:"Layer_1",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",viewBox:"0 0 330 330",xmlSpace:"preserve",...e},De.createElement("path",{id:"XMLID_102_",d:"M325.607,79.393c-5.857-5.857-15.355-5.858-21.213,0.001l-139.39,139.393L25.607,79.393 c-5.857-5.857-15.355-5.858-21.213,0.001c-5.858,5.858-5.858,15.355,0,21.213l150.004,150c2.813,2.813,6.628,4.393,10.606,4.393 s7.794-1.581,10.606-4.394l149.996-150C331.465,94.749,331.465,85.251,325.607,79.393z"})),If=({src:e})=>{const[t,n]=N.useState(null);return N.useEffect(()=>{let r=!1;return ks(e).then(({blobUrl:a})=>{n(a)}).catch(()=>n(null)),()=>{t&&!r&&(URL.revokeObjectURL(t),r=!0)}},[e]),L.jsx("img",{src:t??e,decoding:"async",loading:"eager"})};function Nf(e){return!!e&&typeof e=="object"&&"blob"in e&&e.blob instanceof Blob}function Of({src:e,autoplay:t=!0,loop:n=!0,className:r,style:a,placeholder:i,fallback:u,onLoaded:o,onError:l}){const[c,f]=N.useState({kind:"loading"});return N.useEffect(()=>{let d=null,h=!1;return f({kind:"loading"}),ws(e).then(async m=>{if(!h)if(m.kind==="zip"){const _=Nf(m)?m.blob:await(await fetch(m.blobUrl)).blob();d=URL.createObjectURL(_),f({kind:"lottieZip",blobUrl:d}),o?.(d)}else f({kind:"json",data:m.data}),o?.(m.data)}).catch(m=>!h&&(f({kind:"error",err:m}),l?.(m))),()=>{h=!0,d&&URL.revokeObjectURL(d)}},[e]),c.kind==="loading"?L.jsx("div",{className:"flex items-center justify-center rounded-xl border border-dashed p-6 text-sm opacity-70 "+(r??""),style:{minHeight:96,...a},children:i??"Loading animation…"}):c.kind==="error"?L.jsx("div",{className:"flex items-center justify-center rounded-xl border p-6 text-sm text-red-600 "+(r??""),style:{minHeight:96,...a},children:u??"Failed to load animation"}):c.kind==="json"?L.jsx(Cl,{animationData:c.data,loop:n,autoplay:t,className:r,style:a,rendererSettings:{preserveAspectRatio:"xMidYMid meet"}}):L.jsx(Il.DotLottieReact,{src:c.blobUrl,loop:n,autoplay:t,className:r,style:a})}async function Lf(e,t={}){const{minPeriod:n=8,maxPeriod:r=Math.floor(Math.min(e.width,e.height)/2),gutterSearchRadius:a=3,debug:i=!1}=t;if(e.width<n*2||e.height<n*2)return i&&console.warn("detectGrid: image too small"),null;const u=document.createElement("canvas");u.width=e.naturalWidth,u.height=e.naturalHeight;const o=u.getContext("2d");if(!o)return null;o.drawImage(e,0,0);const{data:l}=o.getImageData(0,0,u.width,u.height),c=u.width,f=u.height,d=new Uint8ClampedArray(c*f);for(let z=0;z<f;z++){let j=z*c;for(let F=0;F<c;F++){const $=(j+F)*4;d[j+F]=.299*l[$]+.587*l[$+1]+.114*l[$+2]|0}}const h=new Float32Array(c),m=new Float32Array(f);for(let z=1;z<c-1;z++){let j=0;for(let F=0;F<f;F++){const $=F*c+z,Y=d[$+1]-d[$-1];j+=Math.abs(Y)}h[z]=j}for(let z=1;z<f-1;z++){let j=0;for(let F=0;F<c;F++){const $=z*c+F,Y=d[$+c]-d[$-c];j+=Math.abs(Y)}m[z]=j}const _=vi(h,n,Math.min(r,c/2)),A=vi(m,n,Math.min(r,f/2));if(!_||!A)return i&&console.warn("detectGrid: could not find periods"),null;const v=Math.max(1,Math.round(c/_)),x=Math.max(1,Math.round(f/A)),P=Pi(h,_,v,a),R=Pi(m,A,x,a),B=Math.max(1,_-P),C=Math.max(1,A-R);if(B*v>c+2||C*x>f+2)return i&&console.warn("detectGrid: sanity check failed"),null;const O=ba(h,60),Q=ba(m,60),de=Math.max(0,Di(h,O)),re=Math.max(0,Di(m,Q));return i&&console.log({periodX:_,periodY:A,columns:v,rows:x,gutterX:P,gutterY:R,frameWidth:B,frameHeight:C,originX:de,originY:re}),{columns:v,rows:x,frameWidth:B,frameHeight:C,gutterX:P,gutterY:R,originX:de,originY:re}}function vi(e,t,n){const r=Fs(e);let a=0;for(let m=0;m<e.length;m++){const _=e[m]-r;a+=_*_}if(a===0)return null;const i=new Float32Array(n+1);let u=0,o=-1/0;for(let m=t;m<=n;m++){let _=0;for(let v=0;v+m<e.length;v++)_+=(e[v]-r)*(e[v+m]-r);const A=_/a;i[m]=A,A>o&&(o=A,u=m)}if(u<=t||u>=n)return u||null;const l=i[u-1],c=i[u],f=i[u+1],d=l-2*c+f,h=d===0?0:.5*(l-f)/d;return u+h}function Pi(e,t,n,r){const a=[];for(let o=1;o<n;o++){const l=o*t;let c=1/0,f=l;for(let d=-r;d<=r;d++){const h=l+d;if(h<=0||h>=e.length)continue;const m=e[h];m<c&&(c=m,f=h)}a.push(f)}if(a.length<1)return 0;let i=[];for(const o of a){const l=e[o]*1.5+ba(e,10)*.5;let c=o,f=o;for(;c>1&&e[c-1]<=l;)c--;for(;f<e.length-2&&e[f+1]<=l;)f++;i.push(Math.max(0,f-c+1))}const u=Math.round(Fs(i));return Math.max(0,Math.min(u,Math.floor(t/4)))}function Fs(e){let t=0;for(let n=0;n<e.length;n++)t+=e[n];return t/e.length}function ba(e,t){const n=Array.from(e);n.sort((a,i)=>a-i);const r=Math.max(0,Math.min(n.length-1,Math.floor(t/100*n.length)));return n[r]}function Di(e,t){for(let n=0;n<e.length;n++)if(e[n]>t)return n;return 0}function Rf(e,t,n,r,a){const{data:i}=e.getImageData(t,n,r,a);let u=0;for(let o=3;o<i.length;o+=4)u+=i[o];return u/(255*(i.length/4))<.03}const vf=N.forwardRef(function({src:t,frameWidth:n,frameHeight:r,columns:a,rows:i,gutterX:u=0,gutterY:o=0,frameCount:l,atlasFrames:c,fps:f=12,autoplay:d=!0,loop:h=!0,startFrame:m=0,direction:_="forward",scale:A=1,backgroundColor:v,className:x,style:P,pauseWhenHidden:R=!1,originX:B,originY:C,onLoad:O,onEnd:Q,onFrame:de},re){const z=N.useRef(null),j=N.useRef(null),[F,$]=N.useState(null),[Y,Z]=N.useState(null),[he,se]=N.useState(null),[Ee,Le]=N.useState(!1),[p,H]=N.useState(!!d),[G,g]=N.useState(m),W=N.useRef(1),[K,V]=N.useState(null),J=Math.max(1,Math.floor(typeof window<"u"&&window.devicePixelRatio||1));N.useEffect(()=>{let ue=!1;return Le(!1),Ms(t).then(({imgEl:ce,bitmap:_e})=>{ue||($(ce),Z(_e),se({w:ce.naturalWidth,h:ce.naturalHeight}),Le(!0),O?.())}).catch(()=>{}),()=>{ue=!0}},[t,O]),N.useEffect(()=>{let ue=!1;return(async()=>{if(!F)return;if(c&&c.length){V(null);return}if(!(!n||!r||!a||!i)){V(null);return}const _e=await Lf(F,{debug:!0});ue||(_e?V({frameWidth:_e.frameWidth,frameHeight:_e.frameHeight,columns:_e.columns,rows:_e.rows,gutterX:_e.gutterX,gutterY:_e.gutterY}):(V(null),console.warn("RemoteSpritesheet: auto-detect failed; please provide grid props.")))})(),()=>{ue=!0}},[F,c,n,r,a,i]);const ee=K?.frameWidth??n,te=K?.frameHeight??r,ae=K?.columns??a,Oe=K?.rows??i,U=K?.gutterX??u,Re=K?.gutterY??o,ke=K?.originX??B??0,ze=K?.originY??C??0,Ct=N.useMemo(()=>{if(c&&c.length>0)return{cols:0,rows:0};if(!he||!ee||!te)return{cols:0,rows:0};const ue=ae??Math.floor((he.w+U)/(ee+U)),ce=Oe??Math.floor((he.h+Re)/(te+Re));return{cols:Math.max(0,ue),rows:Math.max(0,ce)}},[c,he,ee,te,ae,Oe,U,Re]),He=N.useMemo(()=>{if(c?.length)return c;if(!ee||!te)return[];const{cols:ue,rows:ce}=Ct;if(!ue||!ce)return[];const _e=Math.min(l??ue*ce,ue*ce),ge=[];for(let Ne=0;Ne<_e;Ne++){const I=Ne%ue,k=Math.floor(Ne/ue),X=ke+I*(ee+U),le=ze+k*(te+Re);ge.push({x:X,y:le,w:ee,h:te})}if(F&&ge.length){const Ne=document.createElement("canvas");Ne.width=F.naturalWidth,Ne.height=F.naturalHeight;const I=Ne.getContext("2d");if(I){I.drawImage(F,0,0);let k=ge.length;for(;k>0&&Rf(I,ge[k-1].x,ge[k-1].y,ge[k-1].w,ge[k-1].h);)k--;return ge.slice(0,k)}}return ge},[c,Ct,l,ee,te,U,Re,F,ke,ze]),It=()=>{const ue=z.current;if(!ue||He.length===0)return;const ce=He[Math.max(0,Math.min(G,He.length-1))],_e=Math.max(1,Math.round(ce.w*A)),ge=Math.max(1,Math.round(ce.h*A));ue.style.width=_e+"px",ue.style.height=ge+"px",ue.width=_e*J,ue.height=ge*J};N.useEffect(()=>{It()},[Ee,A,He.length,J,G]);const Nt=ue=>{const ce=Y??F??null,_e=z.current;if(!_e||!ce||He.length===0)return;const ge=_e.getContext("2d");if(!ge)return;ge.save(),ge.setTransform(1,0,0,1,0,0),ge.clearRect(0,0,_e.width,_e.height),v&&(ge.fillStyle=v,ge.fillRect(0,0,_e.width,_e.height));const Ne=He[ue];ge.scale(J,J),ge.drawImage(ce,Ne.x,Ne.y,Ne.w,Ne.h,0,0,Math.round(Ne.w*A),Math.round(Ne.h*A)),ge.restore()};return N.useEffect(()=>{if(!Ee||He.length===0)return;let ue=performance.now();const ce=1e3/Math.max(1,Math.min(120,f)),_e=ge=>{if(j.current=requestAnimationFrame(_e),!p){Nt(G);return}const Ne=ge-ue;if(Ne<ce){Nt(G);return}ue=ge-Ne%ce,g(I=>{const k=He.length-1;let X=I;return _==="forward"?X=I+1:_==="backward"?X=I-1:((I>=k&&W.current===1||I<=0&&W.current===-1)&&(W.current*=-1),X=I+W.current),(X>k||X<0)&&(h?X=_==="backward"?k:0:(X=Math.max(0,Math.min(X,k)),H(!1),Q?.())),X})};return j.current=requestAnimationFrame(_e),()=>{j.current&&cancelAnimationFrame(j.current)}},[Ee,f,p,h,_,He.length,G]),N.useEffect(()=>{Nt(G),de?.(G)},[G,Ee,A,J]),N.useEffect(()=>{if(!R)return;const ue=()=>{document.hidden&&H(!1)};return document.addEventListener("visibilitychange",ue),()=>document.removeEventListener("visibilitychange",ue)},[R]),N.useImperativeHandle(re,()=>({play:()=>H(!0),pause:()=>H(!1),toggle:()=>H(ue=>!ue),gotoFrame:ue=>g(()=>Math.max(0,Math.min(ue,Math.max(0,He.length-1)))),isPlaying:()=>p,currentFrame:()=>G}),[p,G,He.length]),L.jsx("div",{className:x,style:P,children:L.jsx("canvas",{ref:z,"aria-label":"spritesheet animation"})})});function Pf({url:e,className:t}){const[n,r]=N.useState(""),[a,i]=N.useState(null);return N.useEffect(()=>{let u=!1;return Ds(e).then(({sanitized:o})=>{u||(r(o),i(null))}).catch(o=>!u&&i(o.message??"Failed to load")),()=>{u=!0}},[e]),a?L.jsxs("div",{className:t,role:"alert",children:["Couldn’t load SVG: ",a]}):n?L.jsx("div",{className:t,dangerouslySetInnerHTML:{__html:n}}):L.jsx("div",{className:t})}const $a=({facet:e})=>{const{mode:t,assetUrl:n,spr_columns:r,spr_fps:a,spr_frameCount:i,spr_frameHeight:u,spr_frameWidth:o,spr_gutterX:l,spr_gutterY:c,spr_rows:f,spr_originX:d,spr_originY:h}=e;return L.jsxs("div",{className:"assetContainer",children:[t===Ye.AgentDisplayFacetModeType.LOTTIE&&L.jsx(Of,{src:n,autoplay:!0,onError:m=>console.error(m)}),t===Ye.AgentDisplayFacetModeType.SVG&&L.jsx("div",{children:L.jsx(Pf,{url:n})}),t===Ye.AgentDisplayFacetModeType.IMAGE&&L.jsx(If,{src:n}),t===Ye.AgentDisplayFacetModeType.SPRITESHEET&&L.jsx(vf,{src:n,frameCount:i,columns:r,rows:f,fps:a,frameHeight:u,frameWidth:o,gutterX:l,gutterY:c,originX:d,originY:h,autoplay:!0})]})},Df=({isWidgetOpen:e,setIsWidgetOpen:t})=>{const{companySettings:n}=N.useContext(kn);return L.jsxs("div",{className:`launcher
37
+ For more details see https://formatjs.io/docs/getting-started/message-distribution`)}function zc(e,t){var n=Sc(t),r=q(q({},As),e),a=r.locale,i=r.defaultLocale,u=r.onError;return a?!Intl.NumberFormat.supportedLocalesOf(a).length&&u?u(new Si('Missing locale data for locale: "'.concat(a,'" in Intl.NumberFormat. Using default locale: "').concat(i,'" as fallback. See https://formatjs.io/docs/react-intl#runtime-requirements for more details'))):!Intl.DateTimeFormat.supportedLocalesOf(a).length&&u&&u(new Si('Missing locale data for locale: "'.concat(a,'" in Intl.DateTimeFormat. Using default locale: "').concat(i,'" as fallback. See https://formatjs.io/docs/react-intl#runtime-requirements for more details'))):(u&&u(new Ac('"locale" was not configured, using "'.concat(i,'" as fallback. See https://formatjs.io/docs/react-intl/api#intlshape for more details'))),r.locale=r.defaultLocale||"en"),Gc(r),q(q({},r),{formatters:n,formatNumber:jc.bind(null,r,n.getNumberFormat),formatNumberToParts:$c.bind(null,r,n.getNumberFormat),formatRelativeTime:Hc.bind(null,r,n.getRelativeTimeFormat),formatDate:Cc.bind(null,r,n.getDateTimeFormat),formatDateToParts:Oc.bind(null,r,n.getDateTimeFormat),formatTime:Ic.bind(null,r,n.getDateTimeFormat),formatDateTimeRange:Nc.bind(null,r,n.getDateTimeFormat),formatTimeToParts:Lc.bind(null,r,n.getDateTimeFormat),formatPlural:Mc.bind(null,r,n.getPluralRules),formatMessage:ma.bind(null,r,n),$t:ma.bind(null,r,n),formatList:kc.bind(null,r,n.getListFormat),formatListToParts:xs.bind(null,r,n.getListFormat),formatDisplayName:vc.bind(null,r,n.getDisplayNames)})}function Cs(e){ts(e,"[React Intl] Could not find required `intl` object. <IntlProvider> needs to exist in the component ancestry.")}var Is=q(q({},As),{textComponent:De.Fragment});function Vc(e){return function(t){return e(De.Children.toArray(t))}}function qc(e,t){if(e===t)return!0;if(!e||!t)return!1;var n=Object.keys(e),r=Object.keys(t),a=n.length;if(r.length!==a)return!1;for(var i=0;i<a;i++){var u=n[i];if(e[u]!==t[u]||!Object.prototype.hasOwnProperty.call(t,u))return!1}return!0}var ja=typeof window<"u"&&!window.__REACT_INTL_BYPASS_GLOBAL_CONTEXT__?window.__REACT_INTL_CONTEXT__||(window.__REACT_INTL_CONTEXT__=De.createContext(null)):De.createContext(null);ja.Consumer;var Wc=ja.Provider,Xc=Wc,Qc=ja;function Pn(){var e=De.useContext(Qc);return Cs(e),e}var pa;(function(e){e.formatDate="FormattedDate",e.formatTime="FormattedTime",e.formatNumber="FormattedNumber",e.formatList="FormattedList",e.formatDisplayName="FormattedDisplayName"})(pa||(pa={}));var Ea;(function(e){e.formatDate="FormattedDateParts",e.formatTime="FormattedTimeParts",e.formatNumber="FormattedNumberParts",e.formatList="FormattedListParts"})(Ea||(Ea={}));function Ns(e){var t=function(n){var r=Pn(),a=n.value,i=n.children,u=pr(n,["value","children"]),o=typeof a=="string"?new Date(a||0):a,l=e==="formatDate"?r.formatDateToParts(o,u):r.formatTimeToParts(o,u);return i(l)};return t.displayName=Ea[e],t}function Dn(e){var t=function(n){var r=Pn(),a=n.value,i=n.children,u=pr(n,["value","children"]),o=r[e](a,u);if(typeof i=="function")return i(o);var l=r.textComponent||De.Fragment;return De.createElement(l,null,o)};return t.displayName=pa[e],t}function Os(e){return e&&Object.keys(e).reduce(function(t,n){var r=e[n];return t[n]=gs(r)?Vc(r):r,t},{})}var Oi=function(e,t,n,r){for(var a=[],i=4;i<arguments.length;i++)a[i-4]=arguments[i];var u=Os(r),o=ma.apply(void 0,st([e,t,n,u],a,!1));return Array.isArray(o)?De.Children.toArray(o):o},Li=function(e,t){var n=e.defaultRichTextElements,r=pr(e,["defaultRichTextElements"]),a=Os(n),i=zc(q(q(q({},Is),r),{defaultRichTextElements:a}),t),u={locale:i.locale,timeZone:i.timeZone,fallbackOnEmptyString:i.fallbackOnEmptyString,formats:i.formats,defaultLocale:i.defaultLocale,defaultFormats:i.defaultFormats,messages:i.messages,onError:i.onError,defaultRichTextElements:a};return q(q({},i),{formatMessage:Oi.bind(null,u,i.formatters),$t:Oi.bind(null,u,i.formatters)})};function Dr(e){return{locale:e.locale,timeZone:e.timeZone,fallbackOnEmptyString:e.fallbackOnEmptyString,formats:e.formats,textComponent:e.textComponent,messages:e.messages,defaultLocale:e.defaultLocale,defaultFormats:e.defaultFormats,onError:e.onError,onWarn:e.onWarn,wrapRichTextChunksInFragment:e.wrapRichTextChunksInFragment,defaultRichTextElements:e.defaultRichTextElements}}var Kc=(function(e){Je(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.cache=_s(),n.state={cache:n.cache,intl:Li(Dr(n.props),n.cache),prevConfig:Dr(n.props)},n}return t.getDerivedStateFromProps=function(n,r){var a=r.prevConfig,i=r.cache,u=Dr(n);return qc(a,u)?null:{intl:Li(u,i),prevConfig:u}},t.prototype.render=function(){return Cs(this.state.intl),De.createElement(Xc,{value:this.state.intl},this.props.children)},t.displayName="IntlProvider",t.defaultProps=Is,t})(De.PureComponent);Dn("formatDate");Dn("formatTime");Dn("formatNumber");Dn("formatList");Dn("formatDisplayName");Ns("formatDate");Ns("formatTime");const Zc={"generic.language.english":"English","generic.language.french":"French","generic.connect.google":"Connect with Google","generic.button.title.save":"Save","page.login.button.login":"Login / Register","page.login.google.login":"Continue with Google","navbar.button.home":"Home","navbar.button.pricing":"Pricing","navbar.button.login":"Login","navbar.button.demo":"Demo","navbar.userMenu.logout":"Log out","navbar.userMenu.profile":"Profile","navbar.userMenu.backOffice":"Back-office","home.header.catchphase":"The catchphrase you wanted","home.header.subcatchphase":"Discover the new software that will change it all","home.header.CTA":"See more","home.section.bulletsPointParagraphe1.title":"Management","home.section.bulletsPointParagraphe1.text":"Take advantage of a complete solution to have a direct point of view on all of your units.","home.section.bulletsPointParagraphe2.title":"Automation","home.section.bulletsPointParagraphe2.text":"In just a few clicks, manage your entire fleet. Implement macros and synergies on your systems.","home.section.bulletsPointParagraphe3.title":"Reporting","home.section.bulletsPointParagraphe3.text":"With its BI module, our software allows you to monitor performance and optimize your costs.","home.realm.title":"See the root of your business in a few clicks","home.realm.text":"The security of your data is at the heart of our concerns. Our software was created in France, we are ISO 27001 certified and all our servers are located in Europe.","home.realm.cta":"Discover our solution","home.testimonials.title":"What our customers say","home.testimonials.1.text":"Since using the software, we have better control of the flow of goods and relevant performance monitoring.","home.testimonials.1.job":"Developer @Wordpress","home.testimonials.1.name":"Loic Martins","home.testimonials.2.text":"Putting the software solution into production allowed us to completely reorganize the teams.","home.testimonials.2.job":"Community Manager @Comet","home.testimonials.2.name":"Anna Wang","home.testimonials.3.text":"Mastery of the logistics subject is obvious with the software solution.","home.testimonials.3.job":"Product Owner @April","home.testimonials.3.name":"Louis Bachant","home.test.section.title":"Try it out now","home.test.section.CTA":"See our solution","pricing.CTA.pleaseLogin":"Login to buy","pricing.page.title":"Choose your plan","pricing.page.subtitle":"No obligation: cancel at any time with one click.","subscribe.paymentRecap.title":"Payment Summary","subscribe.paymentRecap.customerName":"Name","subscribe.paymentRecap.customerMail":"Email","subscribe.paymentRecap.additionnalMention":"Mention to add","subscribe.paymentRecap.totalAmount":"Total Amount","subscribe.paymentForm.title":"Bank card","subscribe.paymentForm.cardNumber":"Card number","subscribe.paymentForm.expiresAt":"Expires at","subscribe.paymentForm.CVCNumber":"CVC number","subscribe.paymentForm.CTA.loading":"Loading ...","subscribe.paymentForm.CTA.pay":"Pay now","subscribe.success.title":"Payment successful","subscribe.success.paragraph1":"Your payment has been processed successfully. You are now suscribed !","subscribe.success.paragraph2":"Your new options are now available.","myAccount.page.leftMenu.general":"General","myAccount.page.leftMenu.profile":"Profile","chatbot.placeholder.content":"Message the assistant...","chatbot.DiscussionLimitReached.title":"Discussion limit reached","chatbot.DiscussionLimitReached.explaination":"The discussion has reached its maximum number of messages. Please start a new one.","chatbot.DiscussionLimitReached.cta":"Restart","chatbot.error.api.409":"Oups ! The discussion if full. Please start a new one.","chatbot.error.api.429":"⏳ The chatbot is a little busy at the time. Please try again later.","chatbot.error.api.500":"Oops ! There has been an error. Please try again later.","chatbot.chatline.label.user":"You","chatbot.chatline.label.assistant":"Assistant","chatbot.chatline.loading.function.genericSearchMessage":"I'm looking for products","chatbot.chatline.loading.function.search":"Search","chatbot.chatline.loading.function.extractProductName":"Looking into the cavern","chatbot.chatline.loading.function.suggestProductName":"Consulting the shadocks","chatbot.chatline.loading.function.criteriaDefinition":"Looking for ziboublis","chatbot.chatline.loading.function.searchStock":"Searching Stock","chatbot.chatline.loading.function.step":"Step","chatbot.chatline.loading.cancel":"Cancel","footer.tab.title.general":"General","footer.tab.title.about":"About","footer.tab.title.resources":"Resources","footer.tab.title.legal":"Legal","footer.tab.title.social":"Social","footer.tab.search":"Search","footer.tab.pricing":"Pricing","footer.tab.termsAndConditions":"Terms and conditions","footer.tab.finalCopyright":"Copyright © 2023 Logiciel, Inc. All rights reserved."},Jc={"generic.language.english":"Anglais","generic.language.french":"Français","generic.connect.google":"Se connecter avec Google","generic.button.title.save":"Sauvegarder","page.login.button.login":"Se connecter / S'inscrire","page.login.google.login":"Continuer avec Google","navbar.button.home":"Accueil","navbar.button.pricing":"Tarifs","navbar.button.login":"Se Connecter","navbar.button.demo":"Demo","navbar.userMenu.logout":"Déconnection","navbar.userMenu.profile":"Profil","navbar.userMenu.backOffice":"Back-office","home.header.catchphase":"Catchphrase de l'espace","home.header.subcatchphase":"Découvrez le logiciel qui met fin à vos problèmes","home.header.CTA":"Voir notre solution","home.section.bulletsPointParagraphe1.title":"Management","home.section.bulletsPointParagraphe1.text":"Profitez d'une solution complète pour avoir un point de vue direct sur l'ensemble de vos unités.","home.section.bulletsPointParagraphe2.title":"Automatisation","home.section.bulletsPointParagraphe2.text":"En quelques clicks, gérez l'ensemble de votre flotte. Mettez en place des macros et des synergies sur vos systèmes.","home.section.bulletsPointParagraphe3.title":"Reporting","home.section.bulletsPointParagraphe3.text":"Avec son module BI, notre logiciel vous permet de monitorer la performance et d'optimiser vos coûts. A l'euro prêt","home.realm.title":"Le coeur du métier en quelques clics","home.realm.text":"La sécurité de vos données est au cœur de nos préoccupations. Notre logiciel a été créé en France, nous sommes certifiés ISO 27001 et tous nos serveurs sont situés en Europe.","home.realm.cta":"Voir notre solution","home.testimonials.title":"Nos clients parlent de nous","home.testimonials.1.text":"Depuis notre utilisation du logiciel, nous avons un meilleur contrôle du flux de marchandises et un suivi de performance pertinent.","home.testimonials.1.job":"Developpeur @Wordpress","home.testimonials.1.name":"Loic Martins","home.testimonials.2.text":"La mise en production de la solution logicielle nous a permis de réorganiser complètement les équipes.","home.testimonials.2.job":"Community Manager @Comet","home.testimonials.2.name":"Anna Wang","home.testimonials.3.text":"La maitrise du sujet logistique est une évidence avec la solution logicielle.","home.testimonials.3.job":"Product Owner @April","home.testimonials.3.name":"Louis Bachant","home.test.section.title":"Testez dès maintenant","home.test.section.CTA":"Voir notre solution","pricing.CTA.pleaseLogin":"Connectez-vous","pricing.page.title":"Choisissez votre plan","pricing.page.subtitle":"Sans engagement : annulez à tout moment en un clic.","subscribe.paymentRecap.title":"Récapitulatif de paiement","subscribe.paymentRecap.customerName":"Nom","subscribe.paymentRecap.customerMail":"Email","subscribe.paymentRecap.additionnalMention":"Mention à ajouter","subscribe.paymentRecap.totalAmount":"Total","subscribe.paymentForm.title":"Carte bancaire","subscribe.paymentForm.cardNumber":"Numéro de carte","subscribe.paymentForm.expiresAt":"Expire le","subscribe.paymentForm.CVCNumber":"Numéro CVV","subscribe.paymentForm.CTA.loading":"Chargement ...","subscribe.paymentForm.CTA.pay":"S'abonner","subscribe.success.title":"Paiement effectué avec succès","subscribe.success.paragraph1":"Votre paiement a bien été accepté. Vous êtes désormais abonné !","subscribe.success.paragraph2":"Toutes vos options sont maintenant disponibles.","myAccount.page.leftMenu.general":"Général","myAccount.page.leftMenu.profile":"Profil","chatbot.placeholder.content":"Envoyez un message à l'assistant ...","chatbot.DiscussionLimitReached.title":"Maximum de messages envoyés atteint.","chatbot.DiscussionLimitReached.explaination":"Le robot est à son maximum et ne peut plus envoyer de message. Merci de relancer une conversation.","chatbot.DiscussionLimitReached.cta":"Relancer une nouvelle conversation","chatbot.error.api.409":"Oups ! La discussion est à son maximum. Merci d'en commencer une nouvelle.","chatbot.error.api.429":"⏳ Le robot est un peu occupé actuellement. Merci de réessayer plus tard.","chatbot.error.api.500":"Oups ! Une erreur est survenue. Merci de réessayer plus tard !","chatbot.chatline.label.user":"Vous","chatbot.chatline.label.assistant":"Assistant","chatbot.chatline.loading.function.search":"Recherche","chatbot.chatline.loading.function.genericSearchMessage":"Je cherche des produits","chatbot.chatline.loading.function.extractProductName":"Recherche dans la caverne","chatbot.chatline.loading.function.suggestProductName":"Consultation des shadocks","chatbot.chatline.loading.function.criteriaDefinition":"Recherche des ziboublis","chatbot.chatline.loading.function.searchStock":"Recherche en stock","chatbot.chatline.loading.function.step":"Etape","chatbot.chatline.loading.cancel":"Annuler","footer.tab.title.general":"Général","footer.tab.title.about":"A propos","footer.tab.title.resources":"Ressources","footer.tab.title.legal":"Mentions Légales","footer.tab.title.social":"Social","footer.tab.search":"Rechercher","footer.tab.pricing":"Tarifs","footer.tab.termsAndConditions":"Termes et conditions","footer.tab.finalCopyright":"Copyright © 2023 Logiciel, Inc. Tous droits réservés."};var Xe=(e=>(e.FRENCH="fr-FR",e.ENGLISH="en-US",e))(Xe||{});const br={[Xe.ENGLISH]:{translatedText:Zc,pictureName:Xe.ENGLISH,langID:0,locale:Xe.ENGLISH},[Xe.FRENCH]:{translatedText:Jc,pictureName:Xe.FRENCH,langID:1,locale:Xe.FRENCH}},ef=Object.keys(br);ef.reduce((e,t)=>{const n=br[t];return[...e,n]},[]);const tf="languageSettings",nf=(e,t)=>{let n,r;return typeof window<"u"&&(r=window.localStorage.getItem(tf)),r&&e?.[r]!==void 0?n=e[r]:(n=e[t],n.isDefault=!0),n},rf=(e,t)=>{const[n,r]=N.useState(e[t]),a=i=>{Object.keys(e).includes(i?.locale)?r(i):r(e[Xe.ENGLISH])};return N.useEffect(()=>{let i=nf(e,t);i.locale!==t&&r(e[i.locale])},[]),{appCurrentLang:n,handleSetContextCurrentLang:a}},Ls=N.createContext({appCurrentLang:br[Xe.ENGLISH],setAppCurrentLang:()=>{}}),Rs=N.createContext({conversation:[],setConversation:()=>{},discussionId:null,setDiscussionId:()=>{}});var Rt={},Ri;function af(){if(Ri)return Rt;Ri=1,Object.defineProperty(Rt,"__esModule",{value:!0}),Rt.AgentDisplayFacetRoleType=Rt.AgentDisplayFacetModeType=void 0;var e;(function(n){n.SPRITESHEET="spritesheet",n.LOTTIE="lottie",n.IMAGE="image",n.SVG="svg",n.VIDEO="video"})(e||(Rt.AgentDisplayFacetModeType=e={}));var t;return(function(n){n.LAUNCHER="launcher",n.ASSISTANT="assistant",n.SEARCH="search"})(t||(Rt.AgentDisplayFacetRoleType=t={})),Rt}var Ye=af();const kr=e=>({mode:Ye.AgentDisplayFacetModeType.SVG,role:e}),uf=()=>({agent:{display:{name:"",CSSRules:"",[Ye.AgentDisplayFacetRoleType.LAUNCHER]:kr(Ye.AgentDisplayFacetRoleType.LAUNCHER),[Ye.AgentDisplayFacetRoleType.ASSISTANT]:kr(Ye.AgentDisplayFacetRoleType.ASSISTANT),[Ye.AgentDisplayFacetRoleType.SEARCH]:kr(Ye.AgentDisplayFacetRoleType.SEARCH)},text:{initialText:""}},api:{settings:{maxUserMessagesPerDiscussion:20}}}),kn=N.createContext({companySettings:uf(),setCompanySettings:()=>{}}),vs=()=>({hasFetchedSettings:!1,hasDisplayedCSS:!1}),sf=()=>{const[e,t]=N.useState(vs());return{appInternalContext:e,setAppInternalContext:t,setHasFetchedSettings:()=>{t(a=>({...a,hasFetchedSettings:!0}))},setHasDisplayedCss:()=>{t(a=>({...a,hasDisplayedCSS:!0}))}}},Ps=N.createContext({appInternalContext:vs(),setAppInternalContext:()=>{},setHasFetchedSettings:()=>{}}),of=e=>Object.values(Xe).includes(e),lf=e=>of(e)?e:(console.log(`Language ${e} not handled for now. Using ${Xe.ENGLISH}.`),Xe.ENGLISH);class Nn{constructor(){}static getApiUrl=()=>process.env.NODE_ENV==="development"?"http://localhost:3001":"https://www.api.chatsystem.ai";static getHeaders=({contentType:t="text/plain"})=>({"Content-Type":t});static getFetchConfig=({contentType:t="text/plain",httpVerb:n="GET",body:r,options:a={}})=>{const i={method:n,headers:this.getHeaders({contentType:t}),...a};return r&&(i.body=JSON.stringify(r)),i}}const cf=({agentId:e,appToken:t,onFetched:n})=>{const[r,a]=N.useState({}),i={companySettings:r,setCompanySettings:a},[u,o]=N.useState([]),[l,c]=N.useState(null),f={conversation:u,setConversation:o,discussionId:l,setDiscussionId:c};return N.useEffect(()=>{const d=Nn.getApiUrl(),h=Nn.getFetchConfig({httpVerb:"GET",contentType:"application/json"});fetch(`${d}/company/settings/${t}/${e}`,h).then(async m=>{const _=await m.json();a(_),o([{userType:"assistant",content:_.agent.text.initialText}]),n?.()}).catch(m=>console.log("error in settings fetch",m))},[t,e]),{contextCompanySettings:i,contextInitialChatbotStartingText:f}};function ff(e,t={},n,r){const{id:a,nonce:i,target:u,disableConstructable:o}=t,l=u??document.head,c=N.useRef(null),f=N.useRef(null);N.useEffect(()=>{if(!e){n&&(console.log("No custom css found."),r?.());return}if(!o&&"adoptedStyleSheets"in l&&typeof CSSStyleSheet<"u"&&"replaceSync"in CSSStyleSheet.prototype)return c.current||(c.current=new CSSStyleSheet,l.adoptedStyleSheets=[...l.adoptedStyleSheets,c.current]),c.current.replaceSync(e),console.log("Loading custom css via stylesheet."),r?.(),()=>{const h=l.adoptedStyleSheets||[],m=h.indexOf(c.current);if(m>=0){const _=h.slice();_.splice(m,1),l.adoptedStyleSheets=_}c.current=null};if(!f.current){const h=document.createElement("style");h.type="text/css",a&&(h.id=a),i&&(h.nonce=i),(l instanceof Document&&l.head||l).appendChild(h),f.current=h}return f.current.textContent=e,console.log("Loading custom css via style tag."),r?.(),()=>{f.current?.parentNode?.removeChild(f.current),f.current=null}},[e,a,i,u,o])}const Jt=globalThis;Jt.__WIDGET_ASSET_CACHE__||(Jt.__WIDGET_ASSET_CACHE__={svg:new Map,img:new Map,lot:new Map,spr:new Map});Jt.__WIDGET_PRELOAD_KEYS__||(Jt.__WIDGET_PRELOAD_KEYS__=new Set);const wr=Jt.__WIDGET_PRELOAD_KEYS__,_t=Jt.__WIDGET_ASSET_CACHE__,df="widget-assets-v1";async function gr(e,t){try{const n=await caches.open(df),r=await n.match(e,{ignoreSearch:!1});if(r)return r.clone();const a=await fetch(e,{cache:"force-cache",mode:"cors",keepalive:!0,...t});if(!a.ok)throw new Error(`HTTP ${a.status} for ${e}`);return n.put(e,a.clone()),a}catch(n){return console.log("error while fetching",n),new Response(null,{status:520,statusText:"Error in client - Fetch failed"})}}async function Ds(e){const t=_t.svg.get(e);if(t)return t.promise;const n=(async()=>{const a=await(await gr(e)).text();if(typeof globalThis.DOMPurify<"u"&&typeof globalThis.DOMPurify.sanitize=="function")try{const u=new DOMParser().parseFromString(a,"image/svg+xml"),o=new XMLSerializer().serializeToString(u.documentElement);return{sanitized:globalThis.DOMPurify.sanitize(o,{USE_PROFILES:{svg:!0,svgFilters:!0}})}}catch{return{sanitized:globalThis.DOMPurify.sanitize(a,{USE_PROFILES:{svg:!0,svgFilters:!0}})}}else return{sanitized:a}})();return _t.svg.set(e,{promise:n,ts:Date.now()}),n}function ks(e){const t=_t.img.get(e);if(t)return t.promise;const n=(async()=>{const a=await(await gr(e)).blob();return{blobUrl:URL.createObjectURL(a)}})();return _t.img.set(e,{promise:n,ts:Date.now()}),n}function ws(e){const t=_t.lot.get(e);if(t)return t.promise;const n=(async()=>{const a=await(await gr(e)).arrayBuffer(),i=new Uint8Array(a);if(i.length>=4&&i[0]===80&&i[1]===75&&i[2]===3&&i[3]===4||e.endsWith(".lottie"))return{kind:"zip",blobUrl:URL.createObjectURL(new Blob([a],{type:"application/zip"}))};const o=new TextDecoder().decode(i);return{kind:"json",data:JSON.parse(o)}})();return _t.lot.set(e,{promise:n,ts:Date.now()}),n}function Ms(e){const t=_t.spr.get(e);if(t)return t.promise;const n=(async()=>{const a=await(await gr(e)).blob();let i=null;try{i=await createImageBitmap(a)}catch{i=null}const{imgEl:u,width:o,height:l}=await new Promise((c,f)=>{const d=URL.createObjectURL(a),h=new Image;h.crossOrigin="anonymous",h.onload=()=>{const m=h.naturalWidth,_=h.naturalHeight;c({imgEl:h,width:m,height:_})},h.onerror=()=>{URL.revokeObjectURL(d),f(new Error("Spritesheet image decode failed"))},h.src=d,h.decode?.().catch(()=>{})});return{imgEl:u,bitmap:i,width:o,height:l}})();return _t.spr.set(e,{promise:n,ts:Date.now()}),n}function hf(e){e.images?.forEach(t=>void ks(t)),e.svgs?.forEach(t=>void Ds(t)),e.lotties?.forEach(t=>void ws(t)),e.sprites?.forEach(t=>void Ms(t))}function mf(e){try{const t=document.createElement("link");t.rel="preconnect",t.href=e,t.crossOrigin="anonymous",document.head.appendChild(t);const n=document.createElement("link");n.rel="dns-prefetch",n.href=e,document.head.appendChild(n)}catch(t){console.log("error in injectPreconnect",t)}}function Bs(e){return new URL(e,document.baseURI).toString()}function pf(e,t){const n=document.head.querySelectorAll('link[rel="preload"]');for(const r of n)if((e?r.as===e||r.getAttribute("as")===e:!0)&&r.href===t)return!0;return!1}function zn(e,t,n,r){const a=Bs(n),i=`${e}|${t??""}|${a}`;if(wr.has(i))return;if(pf(t,a)){wr.add(i);return}const u=document.createElement("link");u.rel=e,t&&(u.as=t),u.href=a,u.crossOrigin="anonymous",r&&(u.type=r),u.setAttribute("data-chatsystem-preload","1"),document.head.appendChild(u),wr.add(i)}function Ef(e){const t=u=>Array.from(new Set((u??[]).map(Bs))),n=t(e.images),r=t(e.svgs),a=t(e.lotties),i=t(e.sprites);n.forEach(u=>zn("preload","image",u)),r.forEach(u=>zn("preload","fetch",u,"image/svg+xml")),a.forEach(u=>zn("preload","fetch",u,"application/zip")),i.forEach(u=>zn("preload","fetch",u))}function bf(e){const{manifest:t,origins:n}=gf(e);n.forEach(mf),Ef(t),hf(t)}function gf(e){const t=Tf(e),n=new Set,r=new Set,a=new Set,i=new Set;for(const{url:l,mode:c}of t)switch(Af(c,l)){case"svg":r.add(l);break;case"lottie":a.add(l);break;case"spritesheet":i.add(l);break;case"image":n.add(l);break}const u={images:Array.from(n),svgs:Array.from(r),lotties:Array.from(a),sprites:Array.from(i)},o=_f(u);return{manifest:u,origins:o}}function Tf(e){if(!e?.agent?.display)return[];const t=e.agent.display,n=[t.launcher,t.assistant,t.search].filter(Boolean),r=[];for(const a of n)a?.assetUrl&&r.push({url:a.assetUrl,mode:a.mode});return r}function Af(e,t){if(e)switch(e){case"svg":return"svg";case"lottie":return"lottie";case"spritesheet":return"spritesheet";case"image":return"image";case"video":return"video"}try{const r=new URL(t,document.baseURI).pathname.toLowerCase();if(r.endsWith(".svg"))return"svg";if(r.endsWith(".lottie")||r.endsWith(".zip")||r.endsWith(".json"))return r.endsWith(".json"),"lottie";if(/\.(png|webp|jpg|jpeg|gif|avi,ef)$/.test(r))return"image";if(/\.(mp4|webm|mov|m4v|ogg)$/.test(r))return"video"}catch(n){console.log("error in normalizeKind:",n)}return"unknown"}function _f(e){const t=new Set,n=r=>{if(r)try{const a=new URL(r,document.baseURI);t.add(`${a.protocol}//${a.host}`)}catch(a){console.log("error in uniqueOriginsFromManifest",a)}};return(e.images??[]).forEach(n),(e.svgs??[]).forEach(n),(e.lotties??[]).forEach(n),(e.sprites??[]).forEach(n),Array.from(t)}const yf=({children:e,appToken:t,agentId:n})=>{var r=navigator.language;console.log("App boot"),console.log("Brower language",r);const a=lf(r),{appCurrentLang:i,handleSetContextCurrentLang:u}=rf(br,a),o={appCurrentLang:i,setAppCurrentLang:u},l=sf(),{contextCompanySettings:c,contextInitialChatbotStartingText:f}=cf({agentId:n,appToken:t,onFetched:l.setHasFetchedSettings});return bf(c.companySettings),ff(c.companySettings?.agent?.display?.CSSRules,{id:`${n}`},l.appInternalContext.hasFetchedSettings,l.setHasDisplayedCss),L.jsx(L.Fragment,{children:L.jsx(Kc,{locale:i?.locale,messages:i?.translatedText,children:L.jsx(Ls.Provider,{value:o,children:L.jsx(Ps.Provider,{value:l,children:L.jsx(kn.Provider,{value:c,children:L.jsx(Rs.Provider,{value:f,children:l.appInternalContext.hasDisplayedCSS&&e})})})})})})},xf=e=>Object.values(nn).includes(e),Sf=e=>xf(e)?e:(console.warn(`Display mode not valid. Using ${nn.LAUNCHER} as default.`),nn.LAUNCHER),Cf=e=>De.createElement("svg",{fill:"#000000",height:"800px",width:"800px",id:"Layer_1",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",viewBox:"0 0 330 330",xmlSpace:"preserve",...e},De.createElement("path",{id:"XMLID_102_",d:"M325.607,79.393c-5.857-5.857-15.355-5.858-21.213,0.001l-139.39,139.393L25.607,79.393 c-5.857-5.857-15.355-5.858-21.213,0.001c-5.858,5.858-5.858,15.355,0,21.213l150.004,150c2.813,2.813,6.628,4.393,10.606,4.393 s7.794-1.581,10.606-4.394l149.996-150C331.465,94.749,331.465,85.251,325.607,79.393z"})),If=({src:e})=>{const[t,n]=N.useState(null);return N.useEffect(()=>{let r=!1;return ks(e).then(({blobUrl:a})=>{n(a)}).catch(()=>n(null)),()=>{t&&!r&&(URL.revokeObjectURL(t),r=!0)}},[e]),L.jsx("img",{src:t??e,decoding:"async",loading:"eager"})};function Nf(e){return!!e&&typeof e=="object"&&"blob"in e&&e.blob instanceof Blob}function Of({src:e,autoplay:t=!0,loop:n=!0,className:r,style:a,placeholder:i,fallback:u,onLoaded:o,onError:l}){const[c,f]=N.useState({kind:"loading"});return N.useEffect(()=>{let d=null,h=!1;return f({kind:"loading"}),ws(e).then(async m=>{if(!h)if(m.kind==="zip"){const _=Nf(m)?m.blob:await(await fetch(m.blobUrl)).blob();d=URL.createObjectURL(_),f({kind:"lottieZip",blobUrl:d}),o?.(d)}else f({kind:"json",data:m.data}),o?.(m.data)}).catch(m=>!h&&(f({kind:"error",err:m}),l?.(m))),()=>{h=!0,d&&URL.revokeObjectURL(d)}},[e]),c.kind==="loading"?L.jsx("div",{className:"flex items-center justify-center rounded-xl border border-dashed p-6 text-sm opacity-70 "+(r??""),style:{minHeight:96,...a},children:i??"Loading animation…"}):c.kind==="error"?L.jsx("div",{className:"flex items-center justify-center rounded-xl border p-6 text-sm text-red-600 "+(r??""),style:{minHeight:96,...a},children:u??"Failed to load animation"}):c.kind==="json"?L.jsx(Cl,{animationData:c.data,loop:n,autoplay:t,className:r,style:a,rendererSettings:{preserveAspectRatio:"xMidYMid meet"}}):L.jsx(Il.DotLottieReact,{src:c.blobUrl,loop:n,autoplay:t,className:r,style:a})}async function Lf(e,t={}){const{minPeriod:n=8,maxPeriod:r=Math.floor(Math.min(e.width,e.height)/2),gutterSearchRadius:a=3,debug:i=!1}=t;if(e.width<n*2||e.height<n*2)return i&&console.warn("detectGrid: image too small"),null;const u=document.createElement("canvas");u.width=e.naturalWidth,u.height=e.naturalHeight;const o=u.getContext("2d");if(!o)return null;o.drawImage(e,0,0);const{data:l}=o.getImageData(0,0,u.width,u.height),c=u.width,f=u.height,d=new Uint8ClampedArray(c*f);for(let z=0;z<f;z++){let j=z*c;for(let F=0;F<c;F++){const $=(j+F)*4;d[j+F]=.299*l[$]+.587*l[$+1]+.114*l[$+2]|0}}const h=new Float32Array(c),m=new Float32Array(f);for(let z=1;z<c-1;z++){let j=0;for(let F=0;F<f;F++){const $=F*c+z,Y=d[$+1]-d[$-1];j+=Math.abs(Y)}h[z]=j}for(let z=1;z<f-1;z++){let j=0;for(let F=0;F<c;F++){const $=z*c+F,Y=d[$+c]-d[$-c];j+=Math.abs(Y)}m[z]=j}const _=vi(h,n,Math.min(r,c/2)),A=vi(m,n,Math.min(r,f/2));if(!_||!A)return i&&console.warn("detectGrid: could not find periods"),null;const v=Math.max(1,Math.round(c/_)),x=Math.max(1,Math.round(f/A)),P=Pi(h,_,v,a),R=Pi(m,A,x,a),B=Math.max(1,_-P),C=Math.max(1,A-R);if(B*v>c+2||C*x>f+2)return i&&console.warn("detectGrid: sanity check failed"),null;const O=ba(h,60),Q=ba(m,60),de=Math.max(0,Di(h,O)),re=Math.max(0,Di(m,Q));return i&&console.log({periodX:_,periodY:A,columns:v,rows:x,gutterX:P,gutterY:R,frameWidth:B,frameHeight:C,originX:de,originY:re}),{columns:v,rows:x,frameWidth:B,frameHeight:C,gutterX:P,gutterY:R,originX:de,originY:re}}function vi(e,t,n){const r=Fs(e);let a=0;for(let m=0;m<e.length;m++){const _=e[m]-r;a+=_*_}if(a===0)return null;const i=new Float32Array(n+1);let u=0,o=-1/0;for(let m=t;m<=n;m++){let _=0;for(let v=0;v+m<e.length;v++)_+=(e[v]-r)*(e[v+m]-r);const A=_/a;i[m]=A,A>o&&(o=A,u=m)}if(u<=t||u>=n)return u||null;const l=i[u-1],c=i[u],f=i[u+1],d=l-2*c+f,h=d===0?0:.5*(l-f)/d;return u+h}function Pi(e,t,n,r){const a=[];for(let o=1;o<n;o++){const l=o*t;let c=1/0,f=l;for(let d=-r;d<=r;d++){const h=l+d;if(h<=0||h>=e.length)continue;const m=e[h];m<c&&(c=m,f=h)}a.push(f)}if(a.length<1)return 0;let i=[];for(const o of a){const l=e[o]*1.5+ba(e,10)*.5;let c=o,f=o;for(;c>1&&e[c-1]<=l;)c--;for(;f<e.length-2&&e[f+1]<=l;)f++;i.push(Math.max(0,f-c+1))}const u=Math.round(Fs(i));return Math.max(0,Math.min(u,Math.floor(t/4)))}function Fs(e){let t=0;for(let n=0;n<e.length;n++)t+=e[n];return t/e.length}function ba(e,t){const n=Array.from(e);n.sort((a,i)=>a-i);const r=Math.max(0,Math.min(n.length-1,Math.floor(t/100*n.length)));return n[r]}function Di(e,t){for(let n=0;n<e.length;n++)if(e[n]>t)return n;return 0}function Rf(e,t,n,r,a){const{data:i}=e.getImageData(t,n,r,a);let u=0;for(let o=3;o<i.length;o+=4)u+=i[o];return u/(255*(i.length/4))<.03}const vf=N.forwardRef(function({src:t,frameWidth:n,frameHeight:r,columns:a,rows:i,gutterX:u=0,gutterY:o=0,frameCount:l,atlasFrames:c,fps:f=12,autoplay:d=!0,loop:h=!0,startFrame:m=0,direction:_="forward",scale:A=1,backgroundColor:v,className:x,style:P,pauseWhenHidden:R=!1,originX:B,originY:C,onLoad:O,onEnd:Q,onFrame:de},re){const z=N.useRef(null),j=N.useRef(null),[F,$]=N.useState(null),[Y,Z]=N.useState(null),[he,se]=N.useState(null),[Ee,Le]=N.useState(!1),[p,H]=N.useState(!!d),[G,g]=N.useState(m),W=N.useRef(1),[K,V]=N.useState(null),J=Math.max(1,Math.floor(typeof window<"u"&&window.devicePixelRatio||1));N.useEffect(()=>{let ue=!1;return Le(!1),Ms(t).then(({imgEl:ce,bitmap:_e})=>{ue||($(ce),Z(_e),se({w:ce.naturalWidth,h:ce.naturalHeight}),Le(!0),O?.())}).catch(()=>{}),()=>{ue=!0}},[t,O]),N.useEffect(()=>{let ue=!1;return(async()=>{if(!F)return;if(c&&c.length){V(null);return}if(!(!n||!r||!a||!i)){V(null);return}const _e=await Lf(F,{debug:!0});ue||(_e?V({frameWidth:_e.frameWidth,frameHeight:_e.frameHeight,columns:_e.columns,rows:_e.rows,gutterX:_e.gutterX,gutterY:_e.gutterY}):(V(null),console.warn("RemoteSpritesheet: auto-detect failed; please provide grid props.")))})(),()=>{ue=!0}},[F,c,n,r,a,i]);const ee=K?.frameWidth??n,te=K?.frameHeight??r,ae=K?.columns??a,Oe=K?.rows??i,U=K?.gutterX??u,Re=K?.gutterY??o,ke=K?.originX??B??0,ze=K?.originY??C??0,Ct=N.useMemo(()=>{if(c&&c.length>0)return{cols:0,rows:0};if(!he||!ee||!te)return{cols:0,rows:0};const ue=ae??Math.floor((he.w+U)/(ee+U)),ce=Oe??Math.floor((he.h+Re)/(te+Re));return{cols:Math.max(0,ue),rows:Math.max(0,ce)}},[c,he,ee,te,ae,Oe,U,Re]),He=N.useMemo(()=>{if(c?.length)return c;if(!ee||!te)return[];const{cols:ue,rows:ce}=Ct;if(!ue||!ce)return[];const _e=Math.min(l??ue*ce,ue*ce),ge=[];for(let Ne=0;Ne<_e;Ne++){const I=Ne%ue,k=Math.floor(Ne/ue),X=ke+I*(ee+U),le=ze+k*(te+Re);ge.push({x:X,y:le,w:ee,h:te})}if(F&&ge.length){const Ne=document.createElement("canvas");Ne.width=F.naturalWidth,Ne.height=F.naturalHeight;const I=Ne.getContext("2d");if(I){I.drawImage(F,0,0);let k=ge.length;for(;k>0&&Rf(I,ge[k-1].x,ge[k-1].y,ge[k-1].w,ge[k-1].h);)k--;return ge.slice(0,k)}}return ge},[c,Ct,l,ee,te,U,Re,F,ke,ze]),It=()=>{const ue=z.current;if(!ue||He.length===0)return;const ce=He[Math.max(0,Math.min(G,He.length-1))],_e=Math.max(1,Math.round(ce.w*A)),ge=Math.max(1,Math.round(ce.h*A));ue.style.width=_e+"px",ue.style.height=ge+"px",ue.width=_e*J,ue.height=ge*J};N.useEffect(()=>{It()},[Ee,A,He.length,J,G]);const Nt=ue=>{const ce=Y??F??null,_e=z.current;if(!_e||!ce||He.length===0)return;const ge=_e.getContext("2d");if(!ge)return;ge.save(),ge.setTransform(1,0,0,1,0,0),ge.clearRect(0,0,_e.width,_e.height),v&&(ge.fillStyle=v,ge.fillRect(0,0,_e.width,_e.height));const Ne=He[ue];ge.scale(J,J),ge.drawImage(ce,Ne.x,Ne.y,Ne.w,Ne.h,0,0,Math.round(Ne.w*A),Math.round(Ne.h*A)),ge.restore()};return N.useEffect(()=>{if(!Ee||He.length===0)return;let ue=performance.now();const ce=1e3/Math.max(1,Math.min(120,f)),_e=ge=>{if(j.current=requestAnimationFrame(_e),!p){Nt(G);return}const Ne=ge-ue;if(Ne<ce){Nt(G);return}ue=ge-Ne%ce,g(I=>{const k=He.length-1;let X=I;return _==="forward"?X=I+1:_==="backward"?X=I-1:((I>=k&&W.current===1||I<=0&&W.current===-1)&&(W.current*=-1),X=I+W.current),(X>k||X<0)&&(h?X=_==="backward"?k:0:(X=Math.max(0,Math.min(X,k)),H(!1),Q?.())),X})};return j.current=requestAnimationFrame(_e),()=>{j.current&&cancelAnimationFrame(j.current)}},[Ee,f,p,h,_,He.length,G]),N.useEffect(()=>{Nt(G),de?.(G)},[G,Ee,A,J]),N.useEffect(()=>{if(!R)return;const ue=()=>{document.hidden&&H(!1)};return document.addEventListener("visibilitychange",ue),()=>document.removeEventListener("visibilitychange",ue)},[R]),N.useImperativeHandle(re,()=>({play:()=>H(!0),pause:()=>H(!1),toggle:()=>H(ue=>!ue),gotoFrame:ue=>g(()=>Math.max(0,Math.min(ue,Math.max(0,He.length-1)))),isPlaying:()=>p,currentFrame:()=>G}),[p,G,He.length]),L.jsx("div",{className:x,style:P,children:L.jsx("canvas",{ref:z,"aria-label":"spritesheet animation"})})});function Pf({url:e,className:t}){const[n,r]=N.useState(""),[a,i]=N.useState(null);return N.useEffect(()=>{let u=!1;return Ds(e).then(({sanitized:o})=>{u||(r(o),i(null))}).catch(o=>!u&&i(o.message??"Failed to load")),()=>{u=!0}},[e]),a?L.jsxs("div",{className:t,role:"alert",children:["Couldn’t load SVG: ",a]}):n?L.jsx("div",{className:t,dangerouslySetInnerHTML:{__html:n}}):L.jsx("div",{className:t})}const $a=({facet:e})=>{const{mode:t,assetUrl:n,spr_columns:r,spr_fps:a,spr_frameCount:i,spr_frameHeight:u,spr_frameWidth:o,spr_gutterX:l,spr_gutterY:c,spr_rows:f,spr_originX:d,spr_originY:h}=e;return L.jsxs("div",{className:"assetContainer",children:[t===Ye.AgentDisplayFacetModeType.LOTTIE&&L.jsx(Of,{src:n,autoplay:!0,onError:m=>console.error(m)}),t===Ye.AgentDisplayFacetModeType.SVG&&L.jsx("div",{children:L.jsx(Pf,{url:n})}),t===Ye.AgentDisplayFacetModeType.IMAGE&&L.jsx(If,{src:n}),t===Ye.AgentDisplayFacetModeType.SPRITESHEET&&L.jsx(vf,{src:n,frameCount:i,columns:r,rows:f,fps:a,frameHeight:u,frameWidth:o,gutterX:l,gutterY:c,originX:d,originY:h,autoplay:!0})]})},Df=({isWidgetOpen:e,setIsWidgetOpen:t})=>{const{companySettings:n}=N.useContext(kn);return L.jsxs("div",{className:`launcher
38
38
  fixed
39
39
  z-[999999999]
40
40
  transition
@@ -97,7 +97,7 @@ For more details see https://formatjs.io/docs/getting-started/message-distributi
97
97
  ring-1 ring-inset ring-blue-600/20 hover:ring-blue-600/30
98
98
  shadow-sm transition-all duration-200
99
99
  focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600/50
100
- active:scale-[0.98]`,children:[L.jsx(Rg,{"aria-hidden":"true",className:"w-5 h-5 transition-transform duration-200 group-hover:rotate-180"}),L.jsx("span",{children:t})]})})]})]})})})};let Kn=new AbortController;const Tl=({appToken:e,containerClassName:t})=>{e||console.log("Dev - Admin settings");const n=N.useRef(null),{placeholderTranslation:r,genericErrorTranslation:a,tooManyRequestsTranslation:i,conflictErrorTranslation:u}=Ya(),{conversation:o,setConversation:l}=N.useContext(Rs),[c,f]=N.useState("notLoading"),[d,h]=N.useState(null),{defaultStartingStep:m}=gl(),[_,A]=N.useState(null),[v,x]=N.useState(m),[P,R]=N.useState(null),{companySettings:B}=N.useContext(kn),{appCurrentLang:C}=N.useContext(Ls),Q={...c!=="notLoading"||(o?.length??0)>0?{maxHeight:"100vh"}:{height:"250px"}},de=yg(o)>=B?.api?.settings?.maxUserMessagesPerDiscussion,{scrollToBottom:re,showScrollButton:z,messagesContainerRef:j,removeStickyNess:F}=Og(o),$=(se,Ee,Le)=>{l(p=>[...p,{content:se,userType:Ee,metaData:Le}])},Y=()=>{Kn.abort("cancelling"),console.log("Stream request aborted"),f("notLoading"),l(se=>se.filter(Ee=>!(Ee.content?.length===0&&Ee.userType==="assistant")))},{resetDiscussion:Z}=kf({companySettings:B,setConversation:l,setDiscussionId:h});console.log("conversation",o);const he=async se=>{f("loadingIntermediaryStates");const Ee=Nn.getApiUrl(),Le={query:se,language:C.locale};l(G=>[...G,{userType:"assistant",content:""}]),requestAnimationFrame(()=>re({smooth:!1,sticky:!1})),d&&(Le.discussionId=d);const p=Kn.signal,H=Nn.getFetchConfig({httpVerb:"POST",body:Le,contentType:"application/json",options:{signal:p}});fetch(`${Ee}/ai/prompt/${e}`,H).then(async G=>{const g=G?.body?.getReader(),W=new TextDecoder;let K="",V="",J=!1,ee=!1,te=null;const ae=G.headers.get("discussionId");h(parseInt(ae,10)),await new ReadableStream({start(U){return Re();async function Re(){if(!G.ok){f("notLoading");let ke=a;G.status===409?ke=u:G.status===429?ke=i:(G.status,ke=a),l(ze=>(ze.pop(),ze)),$(ke,"assistant",{isErrorMessage:!0}),Kn=new AbortController;return}return g?.read().then(ke=>{const{done:ze,value:Ct}=ke,He=W.decode(Ct),It=zt.transformStringifiedObjectIntoArrayOfObjects(He);zt.containsObjectWithLastAnswerToTrue(It)&&f("loadingFinalAnswer");for(const ue of It)if(zt.isObjectOutputstreamTextDTO(ue)){const{content:ce,isLastAnswer:_e,streamSourceUuid:ge,shouldStopStream:Ne}=ue;te&&te!==ge&&(K+='<span style="display:block;height:1rem;"></span>'),te=ge,(_e||Ne)&&(ee=!0),U.enqueue(ce),_g(ce)?(V+=ce,K+=V,V="",J=!1):J||Ag(ce)?(V+=ce,J=!0):K+=ce,l(I=>{const k=[...I],X=k.length-1,le=k[X];return k[X]={...le,content:le.content=K,metaData:{isErrorMessage:Ne}},[...k]})}else if(zt.isObjectOutputstreamLoadingCurrentStepNumberDTO(ue)){const{content:ce}=ue;U.enqueue(ce),R(ce)}else if(zt.isObjectOutputstreamLoadingCurrentStepNameDTO(ue)){const{content:ce}=ue;U.enqueue(ce),x(ce)}else if(zt.isObjectOutputstreamLoadingNumberOfStepsDTO(ue)){const{content:ce}=ue;U.enqueue(ce),A(ce)}else console.warn(`Object not handled - ${ue}`);if(ze&&ee){U.close(),f("notLoading"),x(m),R(null);return}return Re()})}}}).pipeTo(new WritableStream)}).catch(G=>{console.error(G),console.log("Cancelling stream"),f("notLoading"),Kn=new AbortController})};return L.jsxs("div",{className:["relative p-2","flex flex-col min-h-0 overflow-hidden","h-auto",t??"max-w-[90%] mx-auto"].join(" "),ref:n,style:Q,children:[L.jsxs("div",{className:"flex-1 overflow-y-auto min-h-0 messagesContainer",ref:j,children:[o.map((se,Ee)=>L.jsx(fb,{content:se.content,userType:se.userType,metaData:se.metaData,context:{discussionId:d,messageIndex:Ee,appToken:e},seenRootEl:j.current},Ee)),L.jsx(Ig,{currentStepName:v,currentStepNumber:P,loadingStatus:c,numberOfSteps:_})]}),z&&L.jsx("button",{onClick:()=>re({smooth:!0,sticky:!0}),className:"absolute bottom-[120px] right-4 bg-blue-500 hover:bg-blue-600 text-white p-3 rounded-full shadow-lg transition-all duration-300 z-10","aria-label":"Scroll to bottom",children:L.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:L.jsx("path",{d:"M12 16L6 10L7.4 8.6L12 13.2L16.6 8.6L18 10L12 16Z",fill:"currentColor"})})}),de&&L.jsx(vg,{resetDiscussion:Z}),L.jsx("div",{className:"flex-shrink-0",children:L.jsx(gg,{classNameTextarea:"",classNameContainer:"relative mt-6 mt-3 border-slate-400 border-[1px] rounded-lg p-1",SubmitComponent:Tg,isDisabled:c!=="notLoading"||de,shouldDisableIfInputIsEmpty:!0,"aria-label":"TextArea For Bot Conversation",onSubmit:se=>{if(xg(se)){const Ee=Sg(se,d);$(Ee,"user"),F(),re({smooth:!0,sticky:!1})}else $(se,"user"),F(),re({smooth:!0,sticky:!1}),he(se)},placeholder:r,autoFocus:!0,isLoadingStream:c==="loadingFinalAnswer"||c==="loadingIntermediaryStates",LoadingComponent:Ng,onPressLoadingButton:Y})})]})};function mr(){return mr=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},mr.apply(this,arguments)}function Al(e,t){if(e==null)return{};var n={},r=Object.keys(e),a,i;for(i=0;i<r.length;i++)a=r[i],!(t.indexOf(a)>=0)&&(n[a]=e[a]);return n}function wa(e,t){return wa=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,a){return r.__proto__=a,r},wa(e,t)}function _l(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,wa(e,t)}var Zn={exports:{}};/*
100
+ active:scale-[0.98]`,children:[L.jsx(Rg,{"aria-hidden":"true",className:"w-5 h-5 transition-transform duration-200 group-hover:rotate-180"}),L.jsx("span",{children:t})]})})]})]})})})};let Kn=new AbortController;const Tl=({appToken:e,containerClassName:t})=>{e||console.log("Dev - Admin settings");const n=N.useRef(null),{placeholderTranslation:r,genericErrorTranslation:a,tooManyRequestsTranslation:i,conflictErrorTranslation:u}=Ya(),{conversation:o,setConversation:l,discussionId:c,setDiscussionId:f}=N.useContext(Rs),[d,h]=N.useState("notLoading"),{defaultStartingStep:m}=gl(),[_,A]=N.useState(null),[v,x]=N.useState(m),[P,R]=N.useState(null),{companySettings:B}=N.useContext(kn),{appCurrentLang:C}=N.useContext(Ls),Q={...d!=="notLoading"||(o?.length??0)>0?{maxHeight:"100vh"}:{height:"250px"}},de=yg(o)>=B?.api?.settings?.maxUserMessagesPerDiscussion,{scrollToBottom:re,showScrollButton:z,messagesContainerRef:j,removeStickyNess:F}=Og(o),$=(se,Ee,Le)=>{l(p=>[...p,{content:se,userType:Ee,metaData:Le}])},Y=()=>{Kn.abort("cancelling"),console.log("Stream request aborted"),h("notLoading"),l(se=>se.filter(Ee=>!(Ee.content?.length===0&&Ee.userType==="assistant")))},{resetDiscussion:Z}=kf({companySettings:B,setConversation:l,setDiscussionId:f});console.log("conversation",o);const he=async se=>{h("loadingIntermediaryStates");const Ee=Nn.getApiUrl(),Le={query:se,language:C.locale};l(G=>[...G,{userType:"assistant",content:""}]),requestAnimationFrame(()=>re({smooth:!1,sticky:!1})),c&&(Le.discussionId=c);const p=Kn.signal,H=Nn.getFetchConfig({httpVerb:"POST",body:Le,contentType:"application/json",options:{signal:p}});fetch(`${Ee}/ai/prompt/${e}`,H).then(async G=>{const g=G?.body?.getReader(),W=new TextDecoder;let K="",V="",J=!1,ee=!1,te=null;const ae=G.headers.get("discussionId");f(parseInt(ae,10)),await new ReadableStream({start(U){return Re();async function Re(){if(!G.ok){h("notLoading");let ke=a;G.status===409?ke=u:G.status===429?ke=i:(G.status,ke=a),l(ze=>(ze.pop(),ze)),$(ke,"assistant",{isErrorMessage:!0}),Kn=new AbortController;return}return g?.read().then(ke=>{const{done:ze,value:Ct}=ke,He=W.decode(Ct),It=zt.transformStringifiedObjectIntoArrayOfObjects(He);zt.containsObjectWithLastAnswerToTrue(It)&&h("loadingFinalAnswer");for(const ue of It)if(zt.isObjectOutputstreamTextDTO(ue)){const{content:ce,isLastAnswer:_e,streamSourceUuid:ge,shouldStopStream:Ne}=ue;te&&te!==ge&&(K+='<span style="display:block;height:1rem;"></span>'),te=ge,(_e||Ne)&&(ee=!0),U.enqueue(ce),_g(ce)?(V+=ce,K+=V,V="",J=!1):J||Ag(ce)?(V+=ce,J=!0):K+=ce,l(I=>{const k=[...I],X=k.length-1,le=k[X];return k[X]={...le,content:le.content=K,metaData:{isErrorMessage:Ne}},[...k]})}else if(zt.isObjectOutputstreamLoadingCurrentStepNumberDTO(ue)){const{content:ce}=ue;U.enqueue(ce),R(ce)}else if(zt.isObjectOutputstreamLoadingCurrentStepNameDTO(ue)){const{content:ce}=ue;U.enqueue(ce),x(ce)}else if(zt.isObjectOutputstreamLoadingNumberOfStepsDTO(ue)){const{content:ce}=ue;U.enqueue(ce),A(ce)}else console.warn(`Object not handled - ${ue}`);if(ze&&ee){U.close(),h("notLoading"),x(m),R(null);return}return Re()})}}}).pipeTo(new WritableStream)}).catch(G=>{console.error(G),console.log("Cancelling stream"),h("notLoading"),Kn=new AbortController})};return L.jsxs("div",{className:["relative p-2","flex flex-col min-h-0 overflow-hidden","h-auto",t??"max-w-[90%] mx-auto"].join(" "),ref:n,style:Q,children:[L.jsxs("div",{className:"flex-1 overflow-y-auto min-h-0 messagesContainer",ref:j,children:[o.map((se,Ee)=>L.jsx(fb,{content:se.content,userType:se.userType,metaData:se.metaData,context:{discussionId:c,messageIndex:Ee,appToken:e},seenRootEl:j.current},Ee)),L.jsx(Ig,{currentStepName:v,currentStepNumber:P,loadingStatus:d,numberOfSteps:_})]}),z&&L.jsx("button",{onClick:()=>re({smooth:!0,sticky:!0}),className:"absolute bottom-[120px] right-4 bg-blue-500 hover:bg-blue-600 text-white p-3 rounded-full shadow-lg transition-all duration-300 z-10","aria-label":"Scroll to bottom",children:L.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:L.jsx("path",{d:"M12 16L6 10L7.4 8.6L12 13.2L16.6 8.6L18 10L12 16Z",fill:"currentColor"})})}),de&&L.jsx(vg,{resetDiscussion:Z}),L.jsx("div",{className:"flex-shrink-0",children:L.jsx(gg,{classNameTextarea:"",classNameContainer:"relative mt-6 mt-3 border-slate-400 border-[1px] rounded-lg p-1",SubmitComponent:Tg,isDisabled:d!=="notLoading"||de,shouldDisableIfInputIsEmpty:!0,"aria-label":"TextArea For Bot Conversation",onSubmit:se=>{if(xg(se)){const Ee=Sg(se,c);$(Ee,"user"),F(),re({smooth:!0,sticky:!1})}else $(se,"user"),F(),re({smooth:!0,sticky:!1}),he(se)},placeholder:r,autoFocus:!0,isLoadingStream:d==="loadingFinalAnswer"||d==="loadingIntermediaryStates",LoadingComponent:Ng,onPressLoadingButton:Y})})]})};function mr(){return mr=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},mr.apply(this,arguments)}function Al(e,t){if(e==null)return{};var n={},r=Object.keys(e),a,i;for(i=0;i<r.length;i++)a=r[i],!(t.indexOf(a)>=0)&&(n[a]=e[a]);return n}function wa(e,t){return wa=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,a){return r.__proto__=a,r},wa(e,t)}function _l(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,wa(e,t)}var Zn={exports:{}};/*
101
101
  object-assign
102
102
  (c) Sindre Sorhus
103
103
  @license MIT