PageSourceSearch

https://www.trouwassistent.nl/assets/ChatWidget-CrSQNPQk.js

js trouwassistent.nl collected 2026-10-02 01:06:59 UTC 14,171 bytes, 13 lines download raw bytes

1import{j as e}from"./ui-DGDVfbFn.js";import{a as t}from"./react-vendor-CG7WfdSN.js";import{c as s,s as a,p as n,e as r,g as i,B as o,l}from"./index-BEigjK7B.js";import{I as c}from"./input-B3Vwc5ya.js";import{M as d}from"./Dashboard-Cl7VXt-l.js";import{T as m}from"./triangle-alert-Df82UXXT.js";import{c as g,d as p,e as h,f as u,g as f,h as b,i as j,j as x,k as y}from"./RentFilters-DhbsBOZl.js";import{X as v}from"./x-DrAs1Mgh.js";import{L as k}from"./loader-circle-D0ynUUPP.js";import{A as w}from"./arrow-left-DMim9f-g.js";import{L as N}from"./lightbulb-2jAGfrTO.js";import{M as _}from"./message-circle-BmeZ5G2O.js";import"./supabase-BrKiwD5U.js";import"./charts-ChniAfy4.js";import"./tabs-B1_Akm-4.js";import"./alert-BIJxlNbR.js";import"./circle-alert-GW5rml9-.js";import"./skeleton-Dm1_2Jqn.js";import"./chevron-up-4D_9MAig.js";import"./shirt-DWP1wz7p.js";import"./gift-CTP1WrRA.js";import"./file-text-DRKEyj1h.js";import"./external-link-DZWSR7nl.js";import"./check-DiZDg0W7.js";import"./message-square-D0EIAY7o.js";import"./dialog-BQwBs0Sb.js";import"./euro-59vdKXL9.js";import"./map-pin-CJYtqSBn.js";import"./users-BfwDHXIU.js";import"./package-C0InTtLz.js";import"./building-2-B0zm9mZs.js";import"./star-CDBKbOje.js";import"./list-D0zLeKwA.js";import"./smartphone-bUy1fNU5.js";import"./collaborationsService-CQbVRZim.js";import"./eye-CPrD0zy6.js";import"./checkbox-DBFHEayd.js";import"./label-DFtUkIV6.js";
2/**
3 * @license lucide-react v0.462.0 - ISC
4 *
5 * This source code is licensed under the ISC license.
6 * See the LICENSE file in the root directory of this source tree.
7 */const M=s("Bug",[["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M9 7.13v-1a3.003 3.003 0 1 1 6 0v1",key:"d7y7pr"}],["path",{d:"M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6",key:"xs1cw7"}],["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M6.53 9C4.6 8.8 3 7.1 3 5",key:"32zzws"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"M3 21c0-2.1 1.7-3.9 3.8-4",key:"4p0ekp"}],["path",{d:"M20.97 5c0 2.1-1.6 3.8-3.5 4",key:"18gb23"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M17.2 17c2.1.1 3.8 1.9 3.8 4",key:"k3fwyw"}]]),S=s("MessageSquarePlus",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]),C=s("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]),z=({message:t,onReport:s})=>{const a="user"===t.role,n=t.created_at?new Date(t.created_at).toLocaleTimeString("nl-NL",{hour:"2-digit",minute:"2-digit"}):"";return e.jsxs("div",{className:`flex flex-col ${a?"items-end":"items-start"} mb-3`,children:[e.jsx("div",{className:"max-w-[85%] rounded-2xl px-3 py-2 text-sm "+(a?"bg-[#a2c4c9] text-white rounded-br-sm":"bg-gray-100 text-gray-800 rounded-bl-sm"),children:a?e.jsx("p",{className:"whitespace-pre-wrap break-words",children:t.content}):e.jsx("div",{className:"prose prose-sm max-w-none prose-p:my-1 prose-ul:my-1 prose-li:my-0",children:e.jsx(d,{children:t.content})})}),n&&e.jsx("span",{className:"text-xs text-gray-400 mt-1 px-1",children:n}),s&&e.jsxs("button",{onClick:s,className:"flex items-center gap-1 text-xs text-gray-400 hover:text-amber-500 mt-0.5 px-1 transition-colors",children:[e.jsx(m,{className:"h-3 w-3"}),"Meld dit probleem"]})]})};
8/**
9 * @license lucide-react v0.462.0 - ISC
10 *
11 * This source code is licensed under the ISC license.
12 * See the LICENSE file in the root directory of this source tree.
13 */const I=new class{async getAuthUserId(){const{data:{session:e}}=await a.auth.getSession();if(!e?.user)throw new Error("Niet ingelogd");return e.user.id}async loadHistory(){const e=await this.getAuthUserId(),{data:t,error:s}=await a.from("chat_messages").select("id, vendor_id, role, content, created_at").eq("vendor_id",e).order("created_at",{ascending:!1}).limit(20);if(s)throw s;return(t??[]).reverse()}async saveMessage(e,t,s=!1){const n=await this.getAuthUserId(),{data:r,error:i}=await a.from("chat_messages").insert({vendor_id:n,role:e,content:t,is_analysis:s}).select("id, vendor_id, role, content, created_at").single();if(i)throw i;return r}async sendChat(e){const{data:t,error:s}=await a.functions.invoke("vendor-chatbot",{body:{messages:e}});if(s)throw s;if(t?.error)throw new Error(t.error);return{reply:t.reply,message:t.message??null}}async saveFeedback(e,t){const s=await this.getAuthUserId(),{error:n}=await a.from("vendor_feedback").insert({vendor_id:s,type:e,message:t});if(n)throw n}async analyze(e,t,s,n){const{data:r,error:i}=await a.functions.invoke("vendor-chatbot",{body:{...e,vendorType:t,availableFilters:s,userMessage:n}});if(i)throw i;if(r?.error)throw new Error(r.error);return r.suggestions??null}},$={location:x,artist:j,contentcreator:b,transport:f,clothing:u,babs:h,rent:p,caterer:g};const B="local";function E({vendorType:e,onSuggestionsReady:s}){const[a,r]=t.useState([]),[i,o]=t.useState(!0),[l,c]=t.useState(!1),[d,m]=t.useState(!1),[g,p]=t.useState(null),h=t.useRef(!1),u=t.useCallback(e=>{r(t=>[...t,{vendor_id:B,role:"assistant",content:e}])},[]),f=t.useCallback(()=>{g&&(s?.(g),p(null))},[g,s]),b=t.useCallback(async()=>
13{if(!h.current){h.current=!0,o(!0);try{const e=await I.loadHistory();r(e)}catch{}finally{o(!1)}}},[]),j=t.useCallback(async t=>{if(!t.trim()||l||d)return;const s={vendor_id:B,role:"user",content:t};r(e=>[...e,s]);const i=function(e){return(e.match(/https?:\/\/[^\s]+/g)??[]).map(e=>e.replace(/[,;.!?)]+$/,""))}(t),o=t.trim().length>300;if(o||i.length>0){m(!0);try{const s={vendor_id:B,role:"assistant",content:i.length>0?`Bezig met het analyseren van ${1===i.length?"je website":`${i.length} pagina's`}...`:"Bezig met het analyseren van de ingeplakte tekst..."};r(e=>[...e,s]);const a=await I.analyze(o?{rawText:t}:{urls:i},e,function(e){const t={...y,...$[e]??{}},s={};for(const[a,n]of Object.entries(t)){const e=n;e.options?s[a]=e.options:e.groups&&(s[a]=e.groups.flatMap(e=>e.options))}return s}(e),t);let n;if(a&&(a.short_description||a.description||Object.values(a.filter_suggestions??{}).some(e=>e.length>0)||a.pricing_suggestion?.starting_price)){const e=a.description??"",t=a.filter_suggestions,s=Object.entries(t??{}).filter(([,e])=>Array.isArray(e)&&e.length>0).map(([e,t])=>`- **${e}:** ${t.join(", ")}`),r=a.pricing_suggestion?.starting_price,i=r?`- **Prijs:** €${r.toLocaleString()}`:"";n=`Ik heb het volgende gevonden ${o?"in de ingeplakte tekst":"op je website"}:\n\n`+(a.short_description?`**Korte beschrijving:**\n${a.short_description}\n\n`:"")+(e?`**Beschrijving:**\n${e}\n\n`:"")+(s.length||i?`**Overige gegevens:**\n${[...s,i].filter(Boolean).join("\n")}\n\n`:"")+'Klik op **"Toepassen in profiel"** hieronder om de lege velden in te vullen.',p(a)}else n=o?"Ik kon geen bruikbare informatie vinden in de ingeplakte tekst. Controleer of de tekst voldoende informatie over je bedrijf bevat.":'Ik kon weinig vinden op deze pagina — de meeste websites laden hun inhoud via JavaScript, waardoor ik de tekst niet kan lezen.\n\nKopieer de tekst van je website (bijv. je "Over ons"-pagina) en plak die hier in de chat. Dan analyseer ik die voor je.';const l=await I.saveMessage("assistant",n,!0);r(e=>[...e.slice(0,-1),l])}catch(g){const e=g instanceof Error?g.message:"Onbekende fout",t=e.startsWith("Je hebt het dagelijks maximum");t||n(g,{tags:{page:"ChatBot",action:"analyze"}});const s=t?e:`Er ging iets mis: ${e}`,a=await I.saveMessage("assistant",s,!0).catch(()=>({vendor_id:B,role:"assistant",content:s}));r(e=>[...e.slice(0,-1),a])}finally{m(!1)}}else{c(!0);try{const e=[...a,s].slice(-10).map(e=>({role:e.role,content:e.content})),{reply:t,message:n}=await I.sendChat(e);r(e=>[...e,n??{vendor_id:B,role:"assistant",content:t}])}catch(g){const e=g instanceof Error?g.message:"Onbekende fout",t=e.startsWith("Je hebt het dagelijks maximum");t||n(g,{tags:{page:"ChatBot",action:"send_message"}});const s={vendor_id:B,role:"assistant",content:t?e:"Er ging iets mis. Probeer het opnieuw."};r(e=>[...e,s])}finally{c(!1)}}},[e,a,l,d]),x=t.useCallback(async(e,t)=>{const s={feedback:"Feedback",feature_request:"Functieverzoek",bug:"Bug melding"},a={vendor_id:B,role:"user",content:`${s[e]}: ${t}`};r(e=>[...e,a]);try{await Promise.all([I.saveMessage("user",a.content),I.saveFeedback(e,t)]);const n=await I.saveMessage("assistant",`Bedankt voor je **${s[e].toLowerCase()}**. We nemen het mee in de doorontwikkeling van TrouwAssistent.`);r(e=>[...e,n])}catch(i){n(i,{tags:{page:"ChatBot",action:"submit_feedback"}}),r(e=>[...e,{vendor_id:B,role:"assistant",content:"Er ging iets mis bij het opslaan. Probeer het opnieuw."}])}},[]);return{messages:a,isLoading:i,isSending:l,isAnalyzing:d,pendingSuggestions:g,applySuggestions:f,sendMessage:j,submitFeedback:x,loadHistory:b,addLocalMessage:u}}const R=[{type:"feedback",label:"Feedback",icon:S,placeholder:"Wat vind je van TrouwAssistent?"},{type:"feature_request",label:"Functie aanvragen",icon:N,placeholder:"Welke functie zou je willen zien?"},{type:"bug",label:"Bug melden",icon:M,placeholder:"Beschrijf wat er mis ging..."}],T=({vendorType:s,showProfileImportIntro:a,onClose:n,onSuggestionsReady:d})=>{const[m,g]=t.useState(""),[p,h]=t.useState(null),u=t.useRef(null),f=t.useRef(null),b=t.useRef(!1),{messages:j,isLoading:x,isSending:y,isAnalyzing:N,pendingSuggestions:_,applySuggestions:M,sendMessage:S,submitFeedback:I,loadHistory:$,addLocalMessage:B}
13=E({vendorType:s,onSuggestionsReady:d});t.useEffect(()=>{$()},[$]),t.useEffect(()=>{x||b.current||0!==j.length||!a||(b.current=!0,B("Welkom.\n\nOm je profiel automatisch te vullen met informatie van jouw website, heb ik de URL van je website nodig. Je kunt ook teksten of informatie van je website hier plakken.\n\nOp basis daarvan vul ik automatisch je beschrijving, filters en andere relevante velden aan. Ik pas alleen lege velden aan, dus bestaande informatie blijft intact.\n\nPlak de link(s) of informatie gerust hier in de chat."))},[x,j.length,a,B]),t.useEffect(()=>{u.current?.scrollIntoView({behavior:"smooth"})},[j]),t.useEffect(()=>{p&&(g(""),setTimeout(()=>f.current?.focus(),50))},[p]);const T=()=>{const e=m.trim();e&&(g(""),p?(I(p.type,e),h(null)):S(e),f.current?.focus())},L=y||N;return e.jsxs(r,{className:"flex flex-col w-80 sm:w-96 h-[500px] shadow-xl border-gray-200",children:[e.jsxs(i,{className:"flex flex-row items-center justify-between py-3 px-4 border-b border-gray-100 shrink-0",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm text-gray-800",children:"TrouwAssistent Hulp"}),e.jsx("p",{className:"text-xs text-gray-400",children:"Stel gerust een vraag"})]}),e.jsx(o,{variant:"ghost",size:"icon",onClick:n,className:"h-7 w-7 text-gray-400 hover:text-gray-600",children:e.jsx(v,{className:"h-4 w-4"})})]}),e.jsxs(l,{className:"flex-1 overflow-y-auto py-3 px-4 min-h-0",children:[x?e.jsx("div",{className:"flex justify-center items-center h-full",children:e.jsx(k,{className:"h-5 w-5 animate-spin text-[#a2c4c9]"})}):0===j.length?e.jsx("p",{className:"text-sm text-gray-400 text-center mt-8",children:"Hoi! Stel een vraag over het platform of geef een website-URL om je profiel automatisch in te vullen."}):j.map((t,s)=>e.jsx(z,{message:t,onReport:"assistant"===t.role&&t.content.startsWith("Er ging iets mis")&&!t.content.startsWith("Je hebt het dagelijks maximum")?()=>{g(t.content),h({type:"bug",label:"Bug melden",placeholder:"Beschrijf wat er mis ging..."})}:void 0},t.id??s)),L&&e.jsx("div",{className:"flex items-start mb-3",children:e.jsx("div",{className:"bg-gray-100 rounded-2xl rounded-bl-sm px-3 py-2",children:e.jsxs("span",{className:"flex gap-1",children:[e.jsx("span",{className:"w-1.5 h-1.5 bg-gray-400 rounded-full animate-bounce [animation-delay:0ms]"}),e.jsx("span",{className:"w-1.5 h-1.5 bg-gray-400 rounded-full animate-bounce [animation-delay:150ms]"}),e.jsx("span",{className:"w-1.5 h-1.5 bg-gray-400 rounded-full animate-bounce [animation-delay:300ms]"})]})})}),_&&e.jsx("div",{className:"flex justify-center mb-3",children:e.jsx(o,{onClick:()=>{M(),n()},className:"bg-[#a2c4c9] hover:bg-[#8bb1b6] text-white text-sm",children:"Toepassen in profiel"})}),e.jsx("div",{ref:u})]}),e.jsxs("div",{className:"px-4 pb-4 pt-2 border-t border-gray-100 shrink-0 space-y-2",children:[p?e.jsxs("div",{className:"flex items-center gap-1 text-xs text-[#a2c4c9] font-medium",children:[e.jsx("button",{onClick:()=>{h(null),g("")},className:"hover:text-[#8bb1b6]",children:e.jsx(w,{className:"h-3 w-3"})}),p.label]}):e.jsx("div",{className:"flex gap-1.5 flex-wrap",children:R.map(({type:t,label:s,icon:a,placeholder:n})=>e.jsxs("button",{disabled:L,onClick:()=>h({type:t,label:s,placeholder:n}),className:"flex items-center gap-1 text-xs px-2 py-1 rounded-full border border-gray-200 text-gray-500 hover:border-[#a2c4c9] hover:text-[#a2c4c9] transition-colors disabled:opacity-40",children:[e.jsx(a,{className:"h-3 w-3"}),s]},t))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(c,{ref:f,value:m,onChange:e=>g(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),T()),"Escape"===e.key&&p&&(h(null),g(""))},placeholder:p?p.placeholder:"Stel een vraag of plak een URL/tekst...",disabled:L,className:"text-sm"}),e.jsx(o,{onClick:T,disabled:!m.trim()||L,size:"icon",className:"bg-[#a2c4c9] hover:bg-[#8bb1b6] shrink-0",children:e.jsx(C,{className:"h-4 w-4"})})]})]})]})},L=({vendorType:s,showProfileImportIntro:a,onSuggestionsReady:n})=>{const[r,i]=t.useState(!1),[o,l]=t.useState(!1);return e.jsxs("div",{className:"fixed bottom-24 right-6 z-50 flex flex-col items-end gap-3",children:[o&&e.jsx("div",{className:r?"block":"hidden",children:e.jsx(T,{vendorType:s,showProfileImportIntro:a,onClose:()=>i(!1),onSuggestionsReady:n})}),e.jsx("button",{onClick:()=>{i(e=>!e),l(!0)}
13,className:"w-14 h-14 rounded-full bg-[#a2c4c9] hover:bg-[#8bb1b6] shadow-lg flex items-center justify-center transition-colors","aria-label":"Open chat",children:e.jsx(_,{className:"h-6 w-6 text-white"})})]})};export{L as ChatWidget};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.