+`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`${n}>
+`}strong({tokens:e}){return`${this.parser.parseInline(e)}`}em({tokens:e}){return`${this.parser.parseInline(e)}`}codespan({text:e}){return`${el(e,!0)}`}br(e){return" "}del({tokens:e}){return`${this.parser.parseInline(e)}`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=ea(e);if(null===i)return r;let s='"+r+""}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=ea(e);if(null===i)return el(n);e=i;let s=`"}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:el(e.text)}},eg=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}},em=class e{options;renderer;textRenderer;constructor(e){this.options=e||c,this.options.renderer=this.options.renderer||new ef,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new eg}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e,t=!0){let n="";for(let r=0;r{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error("extension name required");if("renderer"in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return!1===r&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if("tokenizer"in e){if(!e.level||"block"!==e.level&&"inline"!==e.level)throw Error("extension level must be 'block' or 'inline'");let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&("block"===e.level?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:"inline"===e.level&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}"childTokens"in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new ef(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if(["options","parser"].includes(n))continue;let r=e.renderer[n],i=t[n];t[n]=(...e)=>{let n=r.apply(t,e);return!1===n&&(n=i.apply(t,e)),n||""}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new ep(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if(["options","rules","lexer"].includes(n))continue;let r=e.tokenizer[n],i=t[n];t[n]=(...e)=>{let n=r.apply(t,e);return!1===n&&(n=i.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new ey;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if(["options","block"].includes(n))continue;let r=e.hooks[n],i=t[n];ey.passThroughHooks.has(n)?t[n]=e=>{if(this.defaults.async)return Promise.resolve(r.call(t,e)).then(e=>i.call(t,e));let n=r.call(t,e);return i.call(t,n)}:t[n]=(...e)=>{let n=r.apply(t,e);return!1===n&&(n=i.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return eh.lex(e,t??this.defaults)}parser(e,t){return em.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},s=this.onError(!!i.silent,!!i.async);if(!0===this.defaults.async&&!1===r.async)return s(Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||null===t)return s(Error("marked(): input parameter is undefined or null"));if("string"!=typeof t)return s(Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));i.hooks&&(i.hooks.options=i,i.hooks.block=e);let o=i.hooks?i.hooks.provideLexer():e?eh.lex:eh.lexInline,l=i.hooks?i.hooks.provideParser():e?em.parse:em.parseInline;if(i.async)return Promise.resolve(i.hooks?i.hooks.preprocess(t):t).then(e=>o(e,i)).then(e=>i.hooks?i.hooks.processAllTokens(e):e).then(e=>i.walkTokens?Promise.all(this.walkTokens(e,i.walkTokens)).then(()=>e):e).then(e=>l(e,i)).then(e=>i.hooks?i.hooks.postprocess(e):e).catch(s);try{i.hooks&&(t=i.hooks.preprocess(t));let e=o(t,i);i.hooks&&(e=i.hooks.processAllTokens(e)),i.walkTokens&&this.walkTokens(e,i.walkTokens);let n=l(e,i);return i.hooks&&(n=i.hooks.postprocess(n)),n}catch(e){return s(e)}}}onError(e,t){return n=>{if(n.message+=`
+Please report this to https://github.com/markedjs/marked.`,e){let e="
An error occurred:
"+el(n.message+"",!0)+"
";return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}},ex=new ev;function eb(e,t){return ex.parse(e,t)}eb.options=eb.setOptions=function(e){return ex.setOptions(e),eb.defaults=ex.defaults,c=eb.defaults,eb},eb.getDefaults=a,eb.defaults=c,eb.use=function(...e){return ex.use(...e),eb.defaults=ex.defaults,c=eb.defaults,eb},eb.walkTokens=function(e,t){return ex.walkTokens(e,t)},eb.parseInline=ex.parseInline,eb.Parser=em,eb.parser=em.parse,eb.Renderer=ef,eb.TextRenderer=eg,eb.Lexer=eh,eb.lexer=eh.lex,eb.Tokenizer=ep,eb.Hooks=ey,eb.parse=eb;var ek=eb.options,eS=eb.setOptions,e_=eb.use,ew=eb.walkTokens,eD=eb.parseInline,eE=eb,eC=em.parse,eT=eh.lex;return e.exports}(),c("gQG4c"),window.TranslationClient={translate:async function(e,t,n=null,r=null,i=""){try{let s={text:e,target_lang:t};n&&(s.source_lang=n),r&&(s.context=r);let o=`${i}/chat/api/translate`;console.log(`Vertaling aanvragen op endpoint: ${o}`);let l=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!l.ok){let e=await l.json();throw Error(e.error||"Onbekende fout bij vertalen")}return await l.json()}catch(e){throw console.error("Vertaalfout:",e),e}}},console.log("TranslationClient geladen en klaar voor gebruik");var f={};s(f,"LanguageSelector",function(){return g}),s(f,"ChatInput",function(){return m}),s(f,"MessageHistory",function(){return y}),s(f,"ChatMessage",function(){return c("lVdl4").default}),s(f,"TypingIndicator",function(){return c("aNcdg").default}),s(f,"ProgressTracker",function(){return c("3b050").default}),s(f,"DynamicForm",function(){return c("9J6tU").default}),s(f,"FormField",function(){return c("70gdv").default}),s(f,"FormMessage",function(){return w}),(e=c("lfk1t")).__esModule&&(e=e.default),e.render=c("esoaL").render,e.__cssModules={},c("6VrmS").default(e),e.__scopeId="data-v-9a7b49",e.__file="LanguageSelector.vue";var g=e;(t=c("13ZGu")).__esModule&&(t=t.default),t.render=c("dv6Fl").render,t.__cssModules={},c("dOnmI").default(t),t.__scopeId="data-v-df2e88",t.__file="ChatInput.vue";var m=t;(n=c("dwb6L")).__esModule&&(n=n.default),n.render=c("3LFpJ").render,n.__cssModules={},c("6hDPH").default(n),n.__scopeId="data-v-efbfed",n.__file="MessageHistory.vue";var y=n,x=c("lVdl4"),b=c("aNcdg"),k=c("3b050"),S=c("9J6tU"),_=c("70gdv");(r=c("eu21N")).__esModule&&(r=r.default),r.render=c("8lvfw").render,r.__cssModules={},c("4boaj").default(r),r.__scopeId="data-v-199543",r.__file="FormMessage.vue";var w=r;console.log("Vue components loaded successfully from barrel export");var b=c("aNcdg"),_=c("70gdv"),S=c("9J6tU"),x=c("lVdl4"),k=c("3b050");let D={name:"ChatApp",components:{TypingIndicator:b.default,FormField:_.default,DynamicForm:S.default,ChatMessage:x.default,MessageHistory:y,ProgressTracker:k.default,ChatInput:m},data(){let e=window.chatConfig||{},t=e.settings||{},n=e.language||"nl",r=e.explanation||"",i=e.tenantMake||{};return{tenantName:i.name||"EveAI",tenantLogoUrl:i.logo_url||"",currentLanguage:n,supportedLanguageDetails:e.supportedLanguageDetails||{},allowedLanguages:e.allowedLanguages||["nl","en","fr","de"],supportedLanguages:e.supportedLanguages||[],originalExplanation:r,explanation:e.explanation||"",currentMessage:"",allMessages:[],isTyping:!1,isLoading:!1,isSubmittingForm:!1,messageIdCounter:1,formValues:{},currentInputFormData:null,apiPrefix:e.apiPrefix||"",conversationId:e.conversationId||"default",userId:e.userId||null,userName:e.userName||"",settings:{maxMessageLength:t.maxMessageLength||2e3,allowFileUpload:!0===t.allowFileUpload,allowVoiceMessage:!0===t.allowVoiceMessage,autoScroll:!0===t.autoScroll},isMobile:window.innerWidth<=768,showSidebar:window.innerWidth>768,messageSearch:"",filteredMessages:[],isSearching:!1}},computed:{compiledExplanation(){return"function"==typeof marked?marked(this.explanation):marked&&"function"==typeof marked.parse?marked.parse(this.explanation.replace(/\[\[(.*?)\]\]/g,"$1")):(console.error("Marked library not properly loaded"),this.explanation)},displayMessages(){return this.isSearching?this.filteredMessages:this.allMessages},hasMessages(){return this.allMessages.length>0},displayLanguages(){return this.supportedLanguages&&this.allowedLanguages?this.supportedLanguages.filter(e=>this.allowedLanguages.includes(e.code)):[]}},mounted(){console.log("\uD83D\uDD0D [DEBUG] ChatApp mounted"),console.log("\uD83D\uDD0D [DEBUG] ChatApp data:",{tenantName:this.tenantName,currentLanguage:this.currentLanguage,allowedLanguages:this.allowedLanguages,conversationId:this.conversationId,userId:this.userId}),console.log("\uD83D\uDD0D [DEBUG] Geregistreerde componenten:",{messageHistory:!!this.$options.components.MessageHistory,chatInput:!!this.$options.components.ChatInput}),this.renderComponent(),console.log("\uD83D\uDD0D [DEBUG] ChatApp mounted"),console.log("\uD83D\uDD0D [DEBUG] Props en data:",{currentLanguage:this.currentLanguage,allowedLanguages:this.allowedLanguages,tenantName:this.tenantName}),this.initializeChat(),this.setupEventListeners(),this.renderComponent()},beforeUnmount(){this.cleanup()},renderComponent(){console.log("\uD83D\uDD0D [DEBUG] ChatApp.renderComponent() aangeroepen")},methods:{initializeChat(){console.log("Initializing chat application..."),this.loadHistoricalMessages(),console.log("Nr of messages:",this.allMessages.length),0===this.allMessages.length&&this.addWelcomeMessage(),this.$nextTick(()=>{this.focusChatInput()})},loadHistoricalMessages(){let e=(window.chatConfig||{}).messages||[];e.length>0&&(this.allMessages=e.filter(e=>null!=e).map(e=>({id:this.messageIdCounter++,content:"string"==typeof e?e:e.content||"",sender:e.sender||"ai",type:e.type||"text",timestamp:e.timestamp||new Date().toISOString(),formData:e.formData||null,status:e.status||"delivered"})),console.log(`Loaded ${this.allMessages.length} historical messages`))},async addWelcomeMessage(){console.log("Sending initialize message to backend"),this.isTyping=!0,this.isLoading=!0;try{let e={message:"Initialize",conversation_id:this.conversationId,user_id:this.userId,language:this.currentLanguage},t=await this.callAPI("/api/send_message",e);this.isTyping=!1;let n=this.addMessage("","ai","text");t.task_id&&(console.log("Monitoring Initialize Task ID: ",t.task_id),n.taskId=t.task_id)}catch(e){console.error("Error sending initialize message:",e),this.isTyping=!1,this.addMessage('Hallo! Ik ben je AI assistant. Vraag gerust om een formulier zoals "contactformulier" of "bestelformulier"!',"ai","text")}finally{this.isLoading=!1}},setupEventListeners(){window.addEventListener("resize",this.handleResize),document.addEventListener("keydown",this.handleGlobalKeydown),document.addEventListener("language-changed",e=>{e.detail&&e.detail.language&&(console.log("ChatApp received language-changed event:",e.detail.language),this.handleLanguageChange(e.detail.language))})},cleanup(){window.removeEventListener("resize",this.handleResize),document.removeEventListener("keydown",this.handleGlobalKeydown)},handleLanguageChange(e){if(this.currentLanguage!==e){console.log(`ChatApp: Taal gewijzigd van ${this.currentLanguage} naar ${e}`),this.currentLanguage=e,this.translateSidebar(e),this.storeLanguagePreference(e);let t=new CustomEvent("language-changed",{detail:{language:e}});document.dispatchEvent(t)}},__handleExternalLanguageChange(e){this.handleLanguageChange(e)},storeLanguagePreference(e){localStorage.setItem("preferredLanguage",e),window.chatConfig&&(window.chatConfig.language=e),console.log(`Taalvoorkeur opgeslagen: ${e}`)},async translateSidebar(e){console.log(`Sidebar wordt vertaald naar: ${e}`);let t=this.originalExplanation||this.explanation;try{if(!window.TranslationClient||"function"!=typeof window.TranslationClient.translate){console.error("TranslationClient.translate is niet beschikbaar"),this.showTranslationIndicator(e,"Vertaling niet beschikbaar",!1);return}this.showTranslationIndicator(e,"Bezig met vertalen..."),console.log("API prefix voor vertaling:",this.apiPrefix);let n=await window.TranslationClient.translate(t,e,null,"sidebar_explanation",this.apiPrefix);if(n.success){console.log("Translated text: "+n.translated_text),this.explanation=n.translated_text,window.__vueApp&&window.__vueApp._instance&&(window.__vueApp._instance.proxy.explanation=n.translated_text);let t=document.querySelector(".sidebar-explanation");if(t)console.log("DOM-element gevonden, directe update toepassen"),t.innerHTML="function"==typeof marked?marked(n.translated_text):marked&&"function"==typeof marked.parse?marked.parse(n.translated_text):n.translated_text;else console.error("Sidebar explanation element niet gevonden in DOM");this.showTranslationIndicator(e,"Vertaling voltooid!",!0)}else console.error("Vertaling mislukt:",n.error),this.showTranslationIndicator(e,"Vertaling mislukt",!1)}catch(t){console.error("Fout bij vertalen sidebar:",t),this.showTranslationIndicator(e,"Vertaling mislukt",!1)}},addMessage(e,t,n="text",r=null,i=null){let s={id:this.messageIdCounter++,content:e,sender:t,type:n,formData:r,formValues:i,timestamp:new Date().toISOString(),status:"user"===t?"sent":"delivered"};return this.allMessages.push(s),"form"===n&&r&&!i&&(this.formValues[s.id]={},r.fields.forEach(e=>{let t=e.name||e.id;t&&(this.formValues[s.id][t]=e.defaultValue||"")})),this.isSearching&&this.performSearch(),s},showTranslationIndicator(e,t,n=null){let r=document.querySelector(".sidebar-explanation");if(r){let e=r.querySelector(".language-change-indicator");e&&e.remove();let i=document.createElement("div");i.className="language-change-indicator",!0===n&&i.classList.add("success"),!1===n&&i.classList.add("error"),i.innerHTML=`${t}`,r.prepend(i),null!==n&&setTimeout(()=>{r.contains(i)&&i.remove()},3e3)}},attachFormDataToMessage(e,t,n){let r=this.allMessages.find(t=>t.id===e);r&&(r.formData=t,r.formValues=n)},updateCurrentMessage(e){this.currentMessage=e},async sendMessage(){let e=this.currentMessage.trim();if(!e||this.isLoading)return;console.log("Sending text message:",e);let t=this.addMessage(e,"user","text");this.currentMessage="",this.isTyping=!0,this.isLoading=!0;try{let n={message:e,conversation_id:this.conversationId,user_id:this.userId,language:this.currentLanguage},r=await this.callAPI("/api/send_message",n);if(this.isTyping=!1,t.status="delivered","form"===r.type)this.addMessage("","ai","form",r.formData);else{let e=this.addMessage("","ai","text");r.task_id&&(console.log("Monitoring Task ID: ",r.task_id),e.taskId=r.task_id)}}catch(e){console.error("Error sending message:",e),this.isTyping=!1,t.status="failed",this.addMessage("Sorry, er ging iets mis bij het verzenden van je bericht. Probeer het opnieuw.","ai","error")}finally{this.isLoading=!1}},async submitFormFromInput(e){if(this.isSubmittingForm=!0,!this.currentInputFormData)return void console.error("No form data available");console.log("Form values received:",e),console.log("Current input form data:",this.currentInputFormData);try{let t=this.addMessage(this.currentMessage.trim(),"user","text");t.formData=this.currentInputFormData,t.formValues=e,this.currentMessage="",this.$emit("update-message",""),this.isTyping=!0,this.isLoading=!0;let n={message:t.content,conversation_id:this.conversationId,user_id:this.userId,form_values:e},r=await this.callAPI("/api/send_message",n);this.isTyping=!1,t.status="delivered";let i=this.addMessage("","ai","text");r.task_id&&(console.log("Monitoring Task ID: ",r.task_id),i.taskId=r.task_id),this.currentInputFormData=null}catch(e){console.error("Error submitting form:",e),this.addMessage("Sorry, er ging iets mis bij het verzenden van het formulier. Probeer het opnieuw.","ai","text"),this.currentInputFormData=null}finally{this.isSubmittingForm=!1,this.isLoading=!1}},retryMessage(e){let t=this.allMessages.find(t=>t.id===e);t&&"failed"===t.status&&(this.currentMessage=t.content,this.removeMessage(e),this.sendMessage())},submitForm(e){console.log("\uD83D\uDD0D [DEBUG] Formulier verzenden:",e),e&&!this.isLoading&&(this.isSubmittingForm=!0,this.addFormMessage(e,"user"),this.sendFormToBackend(e),this.currentInputFormData=null)},sendFormToBackend(e){console.log("\uD83D\uDD0D [DEBUG] Formulier naar backend versturen",e),this.isSubmittingForm=!1},sendMessageToBackend(e){console.log("\uD83D\uDD0D [DEBUG] Bericht naar backend versturen",e)},addFormMessage(e,t){console.log("\uD83D\uDD0D [DEBUG] Formulier bericht toevoegen:",e)},focusChatInput(){this.$nextTick(()=>{if(!this.$el)return void console.warn("$el is niet beschikbaar in focusChatInput");try{let e=this.$el.querySelector(".chat-input-container");if(e){console.log("\uD83D\uDD0D [DEBUG] Focus op chat input");let t=e.querySelector("input, textarea");t&&t.focus()}}catch(e){console.error("Fout bij focussen op chat input:",e)}})},removeMessage(e){let t=this.allMessages.findIndex(t=>t.id===e);-1!==t&&(this.allMessages.splice(t,1),this.formValues[e]&&delete this.formValues[e])},async handleFileUpload(e){console.log("Uploading file:",e.name);let t=this.addMessage("","user","file",{fileName:e.name,fileSize:this.formatFileSize(e.size),fileType:e.type});try{setTimeout(()=>{t.fileUrl=URL.createObjectURL(e),t.status="delivered"},1e3)}catch(e){console.error("Error uploading file:",e),t.status="failed"}},async handleVoiceRecord(e){console.log("Processing voice recording"),this.addMessage("","user","voice",{audioBlob:e,duration:"00:05"})},performSearch(){if(!this.messageSearch.trim()){this.isSearching=!1,this.filteredMessages=[];return}this.isSearching=!0;let e=this.messageSearch.toLowerCase();this.filteredMessages=this.allMessages.filter(t=>t.content&&t.content.toLowerCase().includes(e))},clearSearch(){this.messageSearch="",this.isSearching=!1,this.filteredMessages=[]},handleSpecialistComplete(e){if(console.log("ChatApp received specialist-complete:",e),e.form_request){console.log("Setting form request in ChatInput:",e.form_request);try{let t=this.convertFormRequest(e.form_request);t&&t.title&&t.fields?this.currentInputFormData=t:console.error("Invalid form data after conversion:",t)}catch(e){console.error("Error processing form request:",e)}}},handleSpecialistError(e){console.log("ChatApp received specialist-error:",e),this.addMessage(e.message||"Er is een fout opgetreden bij het verwerken van uw verzoek.","ai","error")},convertFormRequest(e){let t;return(console.log("Converting form request:",e),e)?(e.fields&&"object"==typeof e.fields&&!Array.isArray(e.fields)?t=Object.entries(e.fields).map(([e,t])=>({id:e,name:t.name||e,type:t.type||"text",description:t.description||"",required:t.required||!1,default:t.default||"",allowedValues:t.allowed_values||null,context:t.context||null})):Array.isArray(e.fields)?t=e.fields.map(e=>({id:e.id||e.name,name:e.name||e.id,type:e.type||"text",description:e.description||"",required:e.required||!1,default:e.default||e.defaultValue||"",allowedValues:e.allowed_values||e.allowedValues||null,context:e.context||null})):(console.warn("Formulier heeft geen geldige velden"),t=[]),{title:e.name||e.title||"Formulier",description:e.description||"",icon:e.icon||"form",version:e.version||"1.0",fields:t}):(console.error("Geen geldig formRequest ontvangen"),null)},handleResize(){this.isMobile=window.innerWidth<=768,this.showSidebar=window.innerWidth>768},handleGlobalKeydown(e){(e.ctrlKey||e.metaKey)&&"k"===e.key&&(e.preventDefault(),this.focusSearch()),"Escape"===e.key&&this.isSearching&&this.clearSearch()},async callAPI(e,t){let n=this.apiPrefix+"/chat"+e;console.log("Calling API with prefix:",{prefix:this.apiPrefix,endpoint:e,fullEndpoint:n});let r=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok)throw Error(`HTTP error! status: ${r.status}`);return r.json()},formatFileSize(e){if(0===e)return"0 Bytes";let t=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,t)).toFixed(2))+" "+["Bytes","KB","MB","GB"][t]},focusSearch(){this.$refs.searchInput?.focus()},renderComponent(){console.log("\uD83D\uDD0D [DEBUG] ChatApp.renderComponent() aangeroepen"),console.log("\uD83D\uDD0D [DEBUG] window.Vue beschikbaar:",!!window.Vue),window.Vue&&(console.log("\uD83D\uDD0D [DEBUG] window.Vue.createApp beschikbaar:",!!window.Vue.createApp),console.log("\uD83D\uDD0D [DEBUG] window.Vue.version:",window.Vue.version));let e=document.querySelector(".chat-container");if(!e)return void console.error("Container niet gevonden voor ChatApp (.chat-container)");console.log("\uD83D\uDD0D [DEBUG] ChatApp container gevonden, inhoud wordt gerenderd"),console.log("\uD83D\uDD0D [DEBUG] Beschikbare components:",{MessageHistory:!!window.Components?.MessageHistory,ChatInput:!!window.Components?.ChatInput}),e.innerHTML=`
+
+
+
+
+
+
+
+ `;let t=document.getElementById("chat-message-history"),n=document.getElementById("chat-input-container");if(t){console.log("\uD83D\uDD0D [DEBUG] MessageHistory container gevonden, initialiseren...");try{let e={messages:this.allMessages,isTyping:this.isTyping,isSubmittingForm:this.isSubmittingForm,apiPrefix:this.apiPrefix,autoScroll:!0},n=window.Vue.createApp(y,e);n.component("chat-message",x.default),n.component("typing-indicator",b.default),n.component("progress-tracker",k.default),n.component("dynamic-form",S.default),n.config.errorHandler=(e,t,n)=>{console.error("\uD83D\uDEA8 [Vue Error in MessageHistory]",e),console.error("Component:",t),console.error("Error Info:",n)},n.config.globalProperties.$emit=(e,...t)=>{"specialist-complete"===e?this.handleSpecialistComplete(t[0]):"specialist-error"===e&&this.handleSpecialistError(t[0])};let r=null;"function"==typeof y.renderComponent?r=y.renderComponent(t,e,n):(r=n.mount(t),console.log("\uD83D\uDD0D [DEBUG] MessageHistory direct gemount via app.mount()")),this.$refs.messageHistory=r,console.log("\uD83D\uDD0D [DEBUG] MessageHistory component succesvol geïnitialiseerd")}catch(e){console.error("\uD83D\uDEA8 [ERROR] Fout bij initialiseren MessageHistory:",e)}}else console.error("MessageHistory container niet gevonden in de DOM");if(n){console.log("\uD83D\uDD0D [DEBUG] ChatInput container gevonden, initialiseren...");try{let e={currentMessage:this.currentMessage,isLoading:this.isLoading,maxLength:this.settings.maxMessageLength,formData:this.currentInputFormData,allowFileUpload:this.settings.allowFileUpload,allowVoiceMessage:this.settings.allowVoiceMessage},t=window.Vue.createApp(m,e);t.component("dynamic-form",S.default),t.component("form-field",_.default),t.config.errorHandler=(e,t,n)=>{console.error("\uD83D\uDEA8 [Vue Error in ChatInput]",e),console.error("Component:",t),console.error("Error Info:",n)},t.config.globalProperties.$emit=(e,...t)=>{"send-message"===e?this.sendMessage():"update-message"===e?this.updateCurrentMessage(t[0]):"submit-form"===e?this.submitFormFromInput(t[0]):"upload-file"===e?this.handleFileUpload(t[0]):"record-voice"===e&&this.handleVoiceRecord(t[0])};let r=null;"function"==typeof m.renderComponent?(console.log("\uD83D\uDD0D [DEBUG] ChatInput.renderComponent wordt aangeroepen met chatInputApp:",t),console.log("\uD83D\uDD0D [DEBUG] chatInputApp.mount type:",typeof t.mount),r=m.renderComponent(n,e,t)):(console.log("\uD83D\uDD0D [DEBUG] ChatInput wordt direct gemount via app.mount()"),r=t.mount(n),console.log("\uD83D\uDD0D [DEBUG] ChatInput direct gemount via app.mount()")),this.$refs.chatInput=r,console.log("\uD83D\uDD0D [DEBUG] ChatInput component succesvol geïnitialiseerd")}catch(e){console.error("\uD83D\uDEA8 [ERROR] Fout bij initialiseren ChatInput:",e)}}else console.error("ChatInput container niet gevonden in de DOM");console.log("\uD83D\uDD0D [DEBUG] ChatApp succesvol gerenderd met alle componenten")}},render:()=>document.createElement("div"),template:`
+
+
+
+
+
+
+
+
+ `};window.Vue={createApp:d.createApp,version:p.version},window.marked=h.marked,console.log("\uD83D\uDD0D [DEBUG] Vue object:",window.Vue),console.log("\uD83D\uDD0D [DEBUG] Vue.createApp:",typeof window.Vue.createApp),console.log("\uD83D\uDD0D [DEBUG] Vue.version:",window.Vue.version),window.Components=f,console.log("Components loaded:",Object.keys(f)),window.addEventListener("error",function(e){console.error("\uD83D\uDEA8 [Global Error]",e.error)}),document.addEventListener("DOMContentLoaded",function(){console.log("\uD83D\uDD0D [DEBUG] DOM content loaded, initializing application..."),window.chatConfig||(console.error("chatConfig is niet beschikbaar"),window.chatConfig={}),function(){let e=document.getElementById("sidebar-explanation");e&&window.chatConfig.explanation&&("function"==typeof window.marked?e.innerHTML=window.marked(window.chatConfig.explanation):window.marked&&"function"==typeof window.marked.parse?e.innerHTML=window.marked.parse(window.chatConfig.explanation.replace(/\[\[(.*?)\]\]/g,"$1")):e.innerHTML=window.chatConfig.explanation)}(),function(){console.log("\uD83D\uDD0D [DEBUG] Start initializeLanguageSelector");let e=document.getElementById("language-selector-container");if(console.log("\uD83D\uDD0D [DEBUG] Container element:",e),!e)return console.error("#language-selector-container niet gevonden");try{let t={initialLanguage:window.chatConfig.language||"nl",supportedLanguageDetails:window.chatConfig.supportedLanguageDetails||{},allowedLanguages:window.chatConfig.allowedLanguages||["nl","en","fr","de"]};console.log("\uD83D\uDD0D [DEBUG] Props voor LanguageSelector:",JSON.stringify(t,null,2));let n=window.Vue&&"function"==typeof window.Vue.createApp?window.Vue.createApp(g,t):(0,d.createApp)(g,t);n.config.errorHandler=(e,t,n)=>{console.error("\uD83D\uDEA8 [Vue Error]",e),console.error("Component:",t),console.error("Error Info:",n)};let r=n.mount(e);console.log("\uD83D\uDD0D [DEBUG] LanguageSelector successfully mounted with Vue template:",r),document.addEventListener("vue:language-changed",function(e){let t=e.detail.language;console.log(`Taal gewijzigd naar ${t}`),window.chatConfig&&(window.chatConfig.language=t);let n=new CustomEvent("language-changed",{detail:{language:t}});document.dispatchEvent(n),localStorage.setItem("preferredLanguage",t)}),console.log("\uD83D\uDD0D [DEBUG] Language selector setup voltooid")}catch(e){console.error("\uD83D\uDEA8 [CRITICAL ERROR] Bij initialiseren language selector:",e),console.error("Stack trace:",e.stack)}}(),function(){console.log("\uD83D\uDD0D [DEBUG] Start initializeChatApp");let e=document.querySelector(".chat-container");if(console.log("\uD83D\uDD0D [DEBUG] Chat container element:",e),!e)return console.error(".chat-container niet gevonden");try{if(console.log("\uD83D\uDD0D [DEBUG] ChatApp component beschikbaar:",D),console.log("\uD83D\uDD0D [DEBUG] Geïmporteerde componenten:",Object.keys(f)),console.log("\uD83D\uDD0D [DEBUG] MessageHistory component:",f.MessageHistory),console.log("\uD83D\uDD0D [DEBUG] ChatInput component:",f.ChatInput),!D)throw Error("ChatApp component niet gevonden");f.MessageHistory&&f.ChatInput&&f.TypingIndicator&&f.ChatMessage||console.warn("⚠️ [WARN] Niet alle benodigde sub-componenten zijn geladen!");let t={apiPrefix:window.chatConfig.apiPrefix||"",conversationId:window.chatConfig.conversationId||"default",userId:window.chatConfig.userId||null,userName:window.chatConfig.userName||"",initialLanguage:window.chatConfig.language||"nl",supportedLanguageDetails:window.chatConfig.supportedLanguageDetails||{},allowedLanguages:window.chatConfig.allowedLanguages||["nl","en","fr","de"]};console.log("\uD83D\uDD0D [DEBUG] Alle componenten registreren voor ChatApp..."),console.log("\uD83D\uDD0D [DEBUG] Props voor ChatApp:",JSON.stringify(t,null,2));let n=(0,d.createApp)(D,t);Object.entries(f).forEach(([e,t])=>{console.log(`\u{1F50D} [DEBUG] Registreer component globaal: ${e}`),n.component(e,t)}),n.config.errorHandler=(e,t,n)=>{console.error("\uD83D\uDEA8 [Vue Error in ChatApp]",e),console.error("Component:",t),console.error("Error Info:",n)},console.log("\uD83D\uDD0D [DEBUG] ChatApp Vue app object:",n),console.log("\uD83D\uDD0D [DEBUG] App.mount functie:",typeof n.mount);let r=n.mount(e);console.log("\uD83D\uDD0D [DEBUG] ChatApp gemount, instance:",r),window.__chatApp=r,window.__vueApp=n,console.log("\uD83D\uDD0D [DEBUG] Vue app instance globaal beschikbaar als window.__vueApp"),console.log("\uD83D\uDD0D [DEBUG] Belangrijke ChatApp methods beschikbaar:",{initializeChat:"function"==typeof r.initializeChat})}catch(t){console.error("\uD83D\uDEA8 [CRITICAL ERROR] Bij initialiseren chat app:",t),console.error("Stack trace:",t.stack),e.innerHTML="
Fout bij het initialiseren van de chat applicatie
"}}()}),console.log("Chat client modules geladen en gebundeld met moderne ES module structuur.")}();
\ No newline at end of file
diff --git a/test_language_selector.js b/test_language_selector.js
new file mode 100644
index 0000000..5c1e752
--- /dev/null
+++ b/test_language_selector.js
@@ -0,0 +1,141 @@
+#!/usr/bin/env node
+
+// Test script to verify LanguageSelector component functionality
+// This script tests if the component can be imported and has the correct structure
+
+const fs = require('fs');
+const path = require('path');
+
+console.log('🔍 Testing Vue component refactoring...');
+
+// Read the LanguageSelector component file
+const languageSelectorPath = path.join(__dirname, 'eveai_chat_client/static/assets/js/components/LanguageSelector.js');
+
+if (!fs.existsSync(languageSelectorPath)) {
+ console.error('❌ LanguageSelector.js file not found!');
+ process.exit(1);
+}
+
+const componentContent = fs.readFileSync(languageSelectorPath, 'utf8');
+
+// Test 1: Check that renderComponent method is removed
+console.log('🔍 Test 1: Checking renderComponent method is removed...');
+if (componentContent.includes('renderComponent()')) {
+ console.error('❌ FAIL: renderComponent method still exists!');
+ process.exit(1);
+} else {
+ console.log('✅ PASS: renderComponent method successfully removed');
+}
+
+// Test 2: Check that render() fallback method is removed
+console.log('🔍 Test 2: Checking render() fallback method is removed...');
+if (componentContent.includes('render()')) {
+ console.error('❌ FAIL: render() fallback method still exists!');
+ process.exit(1);
+} else {
+ console.log('✅ PASS: render() fallback method successfully removed');
+}
+
+// Test 3: Check that Vue template exists
+console.log('🔍 Test 3: Checking Vue template exists...');
+if (componentContent.includes('template:') && componentContent.includes('v-model="selectedLanguage"')) {
+ console.log('✅ PASS: Vue template with v-model exists');
+} else {
+ console.error('❌ FAIL: Vue template missing or incorrect!');
+ process.exit(1);
+}
+
+// Test 4: Check that component has proper Vue structure
+console.log('🔍 Test 4: Checking Vue component structure...');
+const hasName = componentContent.includes("name: 'LanguageSelector'");
+const hasProps = componentContent.includes('props:');
+const hasData = componentContent.includes('data()');
+const hasMethods = componentContent.includes('methods:');
+const hasMounted = componentContent.includes('mounted()');
+
+if (hasName && hasProps && hasData && hasMethods && hasMounted) {
+ console.log('✅ PASS: Component has proper Vue structure');
+} else {
+ console.error('❌ FAIL: Component missing Vue structure elements');
+ console.error(` - name: ${hasName}`);
+ console.error(` - props: ${hasProps}`);
+ console.error(` - data: ${hasData}`);
+ console.error(` - methods: ${hasMethods}`);
+ console.error(` - mounted: ${hasMounted}`);
+ process.exit(1);
+}
+
+// Test 5: Check that chat-client.js fallback logic is removed
+console.log('🔍 Test 5: Checking chat-client.js fallback logic is removed...');
+const chatClientPath = path.join(__dirname, 'nginx/frontend_src/js/chat-client.js');
+
+if (!fs.existsSync(chatClientPath)) {
+ console.error('❌ chat-client.js file not found!');
+ process.exit(1);
+}
+
+const chatClientContent = fs.readFileSync(chatClientPath, 'utf8');
+
+if (chatClientContent.includes('LanguageSelector.renderComponent') ||
+ chatClientContent.includes('Noodoplossing: Handmatige DOM manipulatie')) {
+ console.error('❌ FAIL: Fallback logic still exists in chat-client.js!');
+ process.exit(1);
+} else {
+ console.log('✅ PASS: Fallback logic successfully removed from chat-client.js');
+}
+
+// Test 6: Check build output exists
+console.log('🔍 Test 6: Checking build output exists...');
+const chatClientBundlePath = path.join(__dirname, 'nginx/static/dist/chat-client.js');
+
+if (!fs.existsSync(chatClientBundlePath)) {
+ console.error('❌ FAIL: chat-client.js bundle not found!');
+ process.exit(1);
+} else {
+ const bundleStats = fs.statSync(chatClientBundlePath);
+ console.log(`✅ PASS: chat-client.js bundle exists (${Math.round(bundleStats.size / 1024)} KB)`);
+}
+
+// Test 7: Check ChatInput component
+console.log('🔍 Test 7: Checking ChatInput component refactoring...');
+const chatInputPath = path.join(__dirname, 'eveai_chat_client/static/assets/js/components/ChatInput.js');
+
+if (!fs.existsSync(chatInputPath)) {
+ console.error('❌ ChatInput.js file not found!');
+ process.exit(1);
+}
+
+const chatInputContent = fs.readFileSync(chatInputPath, 'utf8');
+
+if (chatInputContent.includes('renderComponent(container, props, app)')) {
+ console.error('❌ FAIL: ChatInput renderComponent method still exists!');
+ process.exit(1);
+} else {
+ console.log('✅ PASS: ChatInput renderComponent method successfully removed');
+}
+
+// Check ChatInput has proper Vue template
+if (chatInputContent.includes('template:') && chatInputContent.includes('v-model="localMessage"')) {
+ console.log('✅ PASS: ChatInput Vue template with v-model exists');
+} else {
+ console.error('❌ FAIL: ChatInput Vue template missing or incorrect!');
+ process.exit(1);
+}
+
+console.log('\n🎉 All tests passed! LanguageSelector and ChatInput components successfully refactored to use pure Vue templates.');
+console.log('\n📋 Summary of changes:');
+console.log(' ✅ LanguageSelector: Removed renderComponent() method');
+console.log(' ✅ LanguageSelector: Removed render() fallback method');
+console.log(' ✅ LanguageSelector: Removed renderComponent() call from mounted()');
+console.log(' ✅ ChatInput: Removed renderComponent() method');
+console.log(' ✅ Removed fallback logic from chat-client.js');
+console.log(' ✅ Kept clean Vue templates with proper reactivity');
+console.log(' ✅ Build completed successfully');
+console.log('\n🔧 Next components to refactor:');
+console.log(' - MessageHistory.js');
+console.log(' - ChatMessage.js');
+console.log(' - TypingIndicator.js');
+console.log(' - ProgressTracker.js');
+console.log(' - DynamicForm.js');
+console.log(' - FormField.js');
+console.log(' - FormMessage.js');
\ No newline at end of file