@cas0570/chat-widget 0.0.4 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -18
- package/dist/components/ChatWindow.d.ts +2 -1
- package/dist/components/HeaderMenu.d.ts +10 -0
- package/dist/components/MessageList.d.ts +2 -1
- package/dist/geoapps-chat-widget.js +527 -507
- package/dist/geoapps-chat-widget.umd.cjs +9 -10
- package/dist/hooks/useChat.d.ts +6 -0
- package/dist/index.d.ts +1 -1
- package/dist/types.d.ts +35 -8
- package/dist/utils/chatPersistence.d.ts +15 -24
- package/dist/utils/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,269 +1,220 @@
|
|
|
1
|
-
(function(){"use strict";try{if(typeof document<"u"){var r=document.createElement("style");r.appendChild(document.createTextNode(':root{--gcw-color-white: #fff;--gcw-color-gray-50: #f9fafb;--gcw-color-gray-100: #f3f4f6;--gcw-color-gray-200: #e5e7eb;--gcw-color-gray-300: #d1d5db;--gcw-color-gray-400: #9ca3af;--gcw-color-gray-500: #6b7280;--gcw-color-gray-600: #4b5563;--gcw-color-gray-700: #374151;--gcw-color-gray-800: #1f2937;--gcw-color-gray-900: #111827;--gcw-color-primary: #3b82f6;--gcw-color-primary-hover: #2563eb;--gcw-color-primary-light: #eff6ff;--gcw-color-error: #ef4444;--gcw-color-success: #22c55e;--gcw-font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;--gcw-font-size-xs: .625rem;--gcw-font-size-sm: .75rem;--gcw-font-size-base: .875rem;--gcw-font-size-lg: 1rem;--gcw-spacing-1: .25rem;--gcw-spacing-2: .5rem;--gcw-spacing-3: .75rem;--gcw-spacing-4: 1rem;--gcw-spacing-5: 1.25rem;--gcw-spacing-6: 1.5rem;--gcw-radius-sm: .25rem;--gcw-radius-md: .5rem;--gcw-radius-lg: .75rem;--gcw-radius-xl: 1rem;--gcw-radius-2xl: 1.25rem;--gcw-radius-full: 9999px;--gcw-shadow-sm: 0 1px 2px 0 rgb(0 0 0 / .05);--gcw-shadow-md: 0 4px 6px -1px rgb(0 0 0 / .1), 0 2px 4px -2px rgb(0 0 0 / .1);--gcw-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--gcw-shadow-xl: 0 20px 25px -5px rgb(0 0 0 / .1), 0 8px 10px -6px rgb(0 0 0 / .1);--gcw-shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / .25);--gcw-transition-fast: .15s ease;--gcw-transition-base: .2s ease;--gcw-transition-slow: .3s ease;--gcw-z-widget: 9999}.gcw-widget,.gcw-widget *,.gcw-widget *:before,.gcw-widget *:after{box-sizing:border-box;margin:0;padding:0;font-family:var(--gcw-font-family);line-height:1.5}.gcw-widget{font-family:var(--gcw-font-family);font-size:var(--gcw-font-size-base);line-height:1.5;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;color:var(--gcw-color-gray-800);text-align:left;letter-spacing:normal;word-spacing:normal;text-transform:none;text-indent:0;text-shadow:none;font-weight:400;font-style:normal}.gcw-container{position:fixed;z-index:var(--gcw-z-widget);display:flex;gap:var(--gcw-spacing-4)}.gcw-container--bottom-right{right:var(--gcw-spacing-4);bottom:var(--gcw-spacing-4);flex-direction:column-reverse;align-items:flex-end}.gcw-container--bottom-left{left:var(--gcw-spacing-4);bottom:var(--gcw-spacing-4);flex-direction:column-reverse;align-items:flex-start}.gcw-container--top-right{right:var(--gcw-spacing-4);top:var(--gcw-spacing-4);flex-direction:column;align-items:flex-end}.gcw-container--top-left{left:var(--gcw-spacing-4);top:var(--gcw-spacing-4);flex-direction:column;align-items:flex-start}.gcw-toggle{position:relative;width:3.5rem;height:3.5rem;border:none;border-radius:var(--gcw-radius-full);background-color:var(--gcw-color-primary);color:var(--gcw-color-white);cursor:pointer;display:flex;align-items:center;justify-content:center;box-shadow:var(--gcw-shadow-lg);transition:transform var(--gcw-transition-base),box-shadow var(--gcw-transition-base)}.gcw-toggle:hover{transform:scale(1.1);box-shadow:var(--gcw-shadow-xl)}.gcw-toggle:active{transform:scale(.95)}.gcw-toggle__icon{width:1.5rem;height:1.5rem;transition:transform var(--gcw-transition-slow)}.gcw-toggle__badge{position:absolute;top:-.25rem;right:-.25rem;width:1rem;height:1rem;border-radius:var(--gcw-radius-full);display:flex;align-items:center;justify-content:center;font-size:var(--gcw-font-size-xs);font-weight:700;animation:gcw-pulse 2s infinite}.gcw-toggle__badge--unread{background-color:var(--gcw-color-error);color:var(--gcw-color-white)}.gcw-toggle__badge--popout{background-color:var(--gcw-color-success)}.gcw-window{display:flex;flex-direction:column;background-color:var(--gcw-color-white);border-radius:var(--gcw-radius-2xl);box-shadow:var(--gcw-shadow-2xl);border:1px solid var(--gcw-color-gray-200);overflow:hidden;animation:gcw-slide-up var(--gcw-transition-slow) ease-out}.gcw-window--small{width:320px;height:450px}.gcw-window--medium{width:380px;height:560px}.gcw-window--large{width:480px;height:680px}.gcw-window--fullscreen{width:calc(100vw - 2rem);height:calc(100vh - 6rem);max-width:56rem}.gcw-window{max-height:90vh;transition:width var(--gcw-transition-base),height var(--gcw-transition-base)}.gcw-header{display:flex;align-items:center;justify-content:space-between;padding:var(--gcw-spacing-3) var(--gcw-spacing-4);color:var(--gcw-color-white);flex-shrink:0}.gcw-header__left{display:flex;align-items:center;gap:var(--gcw-spacing-3)}.gcw-header__avatar{width:2.5rem;height:2.5rem;border-radius:var(--gcw-radius-full);background-color:#fff3;display:flex;align-items:center;justify-content:center}.gcw-header__avatar-icon{width:1.25rem;height:1.25rem}.gcw-header__info{display:flex;flex-direction:column;min-width:0;flex:1}.gcw-header__title{font-size:var(--gcw-font-size-base);font-weight:600;line-height:1.4;margin:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.gcw-header__subtitle{font-size:var(--gcw-font-size-sm);font-weight:400;line-height:1.4;opacity:.9;margin:0;word-wrap:break-word;overflow-wrap:break-word}.gcw-header__actions{display:flex;align-items:center;gap:.125rem}.gcw-header__btn{width:2rem;height:2rem;border:none;border-radius:var(--gcw-radius-full);background-color:transparent;color:inherit;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background-color var(--gcw-transition-fast)}.gcw-header__btn:hover{background-color:#fff3}.gcw-header__btn-icon{width:1rem;height:1rem}.gcw-messages{flex:1;overflow-y:auto;padding:var(--gcw-spacing-4);display:flex;flex-direction:column;gap:var(--gcw-spacing-4)}.gcw-messages::-webkit-scrollbar{width:6px}.gcw-messages::-webkit-scrollbar-track{background:transparent}.gcw-messages::-webkit-scrollbar-thumb{background-color:var(--gcw-color-gray-300);border-radius:3px}.gcw-messages::-webkit-scrollbar-thumb:hover{background-color:var(--gcw-color-gray-400)}.gcw-empty{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:var(--gcw-spacing-6);color:var(--gcw-color-gray-400);text-align:center}.gcw-empty__icon{width:4rem;height:4rem;margin-bottom:var(--gcw-spacing-4);opacity:.5}.gcw-empty__text{font-size:var(--gcw-font-size-base);font-weight:400;line-height:1.5;margin:0}.gcw-bubble-row{display:flex}.gcw-bubble-row--user{justify-content:flex-end}.gcw-bubble-row--assistant{justify-content:flex-start}.gcw-bubble-wrapper{max-width:85%;display:flex;flex-direction:column}.gcw-bubble-wrapper--user{align-items:flex-end}.gcw-bubble-wrapper--assistant{align-items:flex-start}.gcw-bubble{padding:var(--gcw-spacing-2) var(--gcw-spacing-4);border-radius:var(--gcw-radius-2xl);font-size:var(--gcw-font-size-base);font-weight:400;line-height:1.6;letter-spacing:normal;word-wrap:break-word}.gcw-bubble--user{color:var(--gcw-color-white);border-bottom-right-radius:var(--gcw-radius-sm)}.gcw-bubble--assistant{background-color:var(--gcw-color-gray-100);color:var(--gcw-color-gray-800);border-bottom-left-radius:var(--gcw-radius-sm)}.gcw-bubble__timestamp{font-size:var(--gcw-font-size-xs);color:var(--gcw-color-gray-400);margin-top:var(--gcw-spacing-1);padding:0 var(--gcw-spacing-1)}.gcw-content p{margin-bottom:var(--gcw-spacing-2)}.gcw-content p:last-child{margin-bottom:0}.gcw-content strong{font-weight:600}.gcw-content em{font-style:italic}.gcw-content ul,.gcw-content ol{margin:var(--gcw-spacing-2) 0;padding-left:var(--gcw-spacing-6)}.gcw-content li{margin-bottom:var(--gcw-spacing-1)}.gcw-content code{background-color:#0000001a;padding:.125rem .375rem;border-radius:var(--gcw-radius-sm);font-size:.875em;font-family:SF Mono,Monaco,Consolas,monospace}.gcw-bubble--user .gcw-content code{background-color:#fff3}.gcw-content pre{background-color:var(--gcw-color-gray-800);color:var(--gcw-color-gray-100);padding:var(--gcw-spacing-3);border-radius:var(--gcw-radius-md);overflow-x:auto;margin:var(--gcw-spacing-2) 0}.gcw-content pre code{background-color:transparent;padding:0;font-size:var(--gcw-font-size-sm)}.gcw-content a{color:var(--gcw-color-primary);text-decoration:underline}.gcw-content a:hover{color:var(--gcw-color-primary-hover)}.gcw-bubble--user .gcw-content a{color:#ffffffe6}.gcw-md-heading{font-weight:600;margin-top:var(--gcw-spacing-3);margin-bottom:var(--gcw-spacing-1)}.gcw-md-heading--h2{font-size:var(--gcw-font-size-lg);font-weight:700}.gcw-md-heading--h3,.gcw-md-heading--h4{font-size:var(--gcw-font-size-base)}.gcw-md-heading--h5{font-size:var(--gcw-font-size-sm)}.gcw-md-paragraph{margin-bottom:var(--gcw-spacing-2)}.gcw-md-paragraph:last-child{margin-bottom:0}.gcw-md-list{margin:var(--gcw-spacing-2) 0;padding-left:var(--gcw-spacing-4)}.gcw-md-list--ul{list-style-type:disc}.gcw-md-list--ol{list-style-type:decimal}.gcw-md-list__item{font-size:var(--gcw-font-size-base);margin-bottom:var(--gcw-spacing-1)}.gcw-md-bold{font-weight:600}.gcw-md-italic{font-style:italic}.gcw-md-code{background-color:var(--gcw-color-gray-200);padding:.125rem var(--gcw-spacing-2);border-radius:var(--gcw-radius-sm);font-size:var(--gcw-font-size-sm);font-family:SF Mono,Monaco,Consolas,monospace}.gcw-bubble--user .gcw-md-code{background-color:#fff3}.gcw-md-code-block{background-color:var(--gcw-color-gray-800);color:var(--gcw-color-gray-100);padding:var(--gcw-spacing-3);border-radius:var(--gcw-radius-lg);font-size:var(--gcw-font-size-sm);overflow-x:auto;margin:var(--gcw-spacing-2) 0}.gcw-md-code-block code{font-family:SF Mono,Monaco,Consolas,monospace}.gcw-md-link{color:var(--gcw-color-primary);text-decoration:underline}.gcw-md-link:hover{color:var(--gcw-color-primary-hover)}.gcw-bubble--user .gcw-md-link{color:#ffffffe6}.gcw-sources{display:flex;flex-wrap:wrap;gap:var(--gcw-spacing-2);margin-top:var(--gcw-spacing-2)}.gcw-source{display:inline-flex;align-items:center;gap:var(--gcw-spacing-1);padding:var(--gcw-spacing-1) var(--gcw-spacing-2);border-radius:var(--gcw-radius-full);background-color:var(--gcw-color-primary-light);color:var(--gcw-color-primary);font-size:var(--gcw-font-size-sm);text-decoration:none;transition:background-color var(--gcw-transition-fast)}.gcw-source:hover{background-color:#dbeafe}.gcw-source__icon{width:.75rem;height:.75rem}.gcw-typing{display:flex;justify-content:flex-start}.gcw-typing__bubble{background-color:var(--gcw-color-gray-100);padding:var(--gcw-spacing-3) var(--gcw-spacing-4);border-radius:var(--gcw-radius-2xl);border-bottom-left-radius:var(--gcw-radius-sm)}.gcw-typing__dots{display:flex;gap:var(--gcw-spacing-1)}.gcw-typing__dot{width:.5rem;height:.5rem;background-color:var(--gcw-color-gray-400);border-radius:var(--gcw-radius-full);animation:gcw-typing-bounce 1.4s infinite ease-in-out both}.gcw-typing__dot:nth-child(1){animation-delay:-.32s}.gcw-typing__dot:nth-child(2){animation-delay:-.16s}.gcw-input-area{padding:var(--gcw-spacing-3);border-top:1px solid var(--gcw-color-gray-200);background-color:var(--gcw-color-white);flex-shrink:0}.gcw-input-row{display:flex;align-items:flex-end;gap:var(--gcw-spacing-2)}.gcw-input{flex:1;min-height:44px;max-height:120px;padding:var(--gcw-spacing-2) var(--gcw-spacing-4);border:1px solid var(--gcw-color-gray-200);border-radius:var(--gcw-radius-xl);background-color:var(--gcw-color-white);color:var(--gcw-color-gray-800);font-family:var(--gcw-font-family);font-size:var(--gcw-font-size-base);font-weight:400;line-height:1.5;letter-spacing:normal;resize:none;outline:none;transition:border-color var(--gcw-transition-fast),box-shadow var(--gcw-transition-fast)}.gcw-input:focus{border-color:var(--gcw-color-primary);box-shadow:0 0 0 3px #3b82f61a}.gcw-input:disabled{background-color:var(--gcw-color-gray-50);cursor:not-allowed}.gcw-input::placeholder{color:var(--gcw-color-gray-400)}.gcw-send-btn{width:2.5rem;height:2.5rem;flex-shrink:0;border:none;border-radius:var(--gcw-radius-lg);color:var(--gcw-color-white);cursor:pointer;display:flex;align-items:center;justify-content:center;transition:opacity var(--gcw-transition-fast),transform var(--gcw-transition-fast)}.gcw-send-btn:hover:not(:disabled){opacity:.9}.gcw-send-btn:active:not(:disabled){transform:scale(.95)}.gcw-send-btn:disabled{opacity:.5;cursor:not-allowed}.gcw-send-btn__icon{width:1.25rem;height:1.25rem}.gcw-input-hint{font-size:var(--gcw-font-size-xs);color:var(--gcw-color-gray-400);text-align:center;margin-top:var(--gcw-spacing-2)}@keyframes gcw-slide-up{0%{opacity:0;transform:translateY(1rem)}to{opacity:1;transform:translateY(0)}}@keyframes gcw-pulse{0%,to{opacity:1}50%{opacity:.5}}@keyframes gcw-typing-bounce{0%,80%,to{transform:scale(0)}40%{transform:scale(1)}}@keyframes gcw-spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.gcw-sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}.gcw-spin{animation:gcw-spin 1s linear infinite}')),document.head.appendChild(r)}}catch(o){console.error("vite-plugin-css-injected-by-js",o)}})();
|
|
2
|
-
import { jsx as
|
|
3
|
-
import
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return `${le}${e || "default"}`;
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var r=document.createElement("style");r.appendChild(document.createTextNode(':root{--gcw-color-white: #fff;--gcw-color-gray-50: #f9fafb;--gcw-color-gray-100: #f3f4f6;--gcw-color-gray-200: #e5e7eb;--gcw-color-gray-300: #d1d5db;--gcw-color-gray-400: #9ca3af;--gcw-color-gray-500: #6b7280;--gcw-color-gray-600: #4b5563;--gcw-color-gray-700: #374151;--gcw-color-gray-800: #1f2937;--gcw-color-gray-900: #111827;--gcw-color-primary: #3b82f6;--gcw-color-primary-hover: #2563eb;--gcw-color-primary-light: #eff6ff;--gcw-color-error: #ef4444;--gcw-color-success: #22c55e;--gcw-font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;--gcw-font-size-xs: .625rem;--gcw-font-size-sm: .75rem;--gcw-font-size-base: .875rem;--gcw-font-size-lg: 1rem;--gcw-spacing-1: .25rem;--gcw-spacing-2: .5rem;--gcw-spacing-3: .75rem;--gcw-spacing-4: 1rem;--gcw-spacing-6: 1.5rem;--gcw-spacing-8: 2rem;--gcw-spacing-10: 2.5rem;--gcw-spacing-12: 3rem;--gcw-spacing-16: 4rem;--gcw-spacing-20: 5rem;--gcw-radius-sm: .25rem;--gcw-radius-md: .5rem;--gcw-radius-lg: .75rem;--gcw-radius-xl: 1rem;--gcw-radius-2xl: 1.25rem;--gcw-radius-full: 9999px;--gcw-shadow-sm: 0 1px 2px 0 rgb(0 0 0 / .05);--gcw-shadow-md: 0 4px 6px -1px rgb(0 0 0 / .1), 0 2px 4px -2px rgb(0 0 0 / .1);--gcw-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--gcw-shadow-xl: 0 20px 25px -5px rgb(0 0 0 / .1), 0 8px 10px -6px rgb(0 0 0 / .1);--gcw-shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / .25);--gcw-transition-fast: .15s ease;--gcw-transition-base: .2s ease;--gcw-transition-slow: .3s ease;--gcw-z-widget: 9999}.gcw-widget,.gcw-widget *,.gcw-widget *:before,.gcw-widget *:after{box-sizing:border-box;margin:0;padding:0;font-family:var(--gcw-font-family);line-height:1.5}.gcw-widget{font-family:var(--gcw-font-family);font-size:var(--gcw-font-size-base);line-height:1.5;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;color:var(--gcw-color-gray-800);text-align:left;letter-spacing:normal;word-spacing:normal;text-transform:none;text-indent:0;text-shadow:none;font-weight:400;font-style:normal}.gcw-container{position:fixed;z-index:var(--gcw-z-widget);display:flex;gap:var(--gcw-spacing-4)}.gcw-container--bottom-right{right:var(--gcw-spacing-4);bottom:var(--gcw-spacing-4);flex-direction:column-reverse;align-items:flex-end}.gcw-container--bottom-left{left:var(--gcw-spacing-4);bottom:var(--gcw-spacing-4);flex-direction:column-reverse;align-items:flex-start}.gcw-container--top-right{right:var(--gcw-spacing-4);top:var(--gcw-spacing-4);flex-direction:column;align-items:flex-end}.gcw-container--top-left{left:var(--gcw-spacing-4);top:var(--gcw-spacing-4);flex-direction:column;align-items:flex-start}.gcw-container--custom{flex-direction:column-reverse;align-items:flex-end}.gcw-container--custom.gcw-container--align-left{align-items:flex-start}.gcw-container--custom.gcw-container--flow-down{flex-direction:column}.gcw-toggle{position:relative;width:3.5rem;height:3.5rem;border:none;border-radius:var(--gcw-radius-full);background-color:var(--gcw-color-primary);color:var(--gcw-color-white);cursor:pointer;display:flex;align-items:center;justify-content:center;box-shadow:var(--gcw-shadow-lg);transition:transform var(--gcw-transition-base),box-shadow var(--gcw-transition-base)}.gcw-toggle:hover{transform:scale(1.1);box-shadow:var(--gcw-shadow-xl)}.gcw-toggle:active{transform:scale(.95)}.gcw-toggle__icon{width:1.5rem;height:1.5rem;transition:transform var(--gcw-transition-slow)}.gcw-toggle__badge{position:absolute;top:-.25rem;right:-.25rem;width:1rem;height:1rem;border-radius:var(--gcw-radius-full);display:flex;align-items:center;justify-content:center;font-size:var(--gcw-font-size-xs);font-weight:700;animation:gcw-pulse 2s infinite}.gcw-toggle__badge--unread{background-color:var(--gcw-color-error);color:var(--gcw-color-white)}.gcw-toggle__badge--popout{background-color:var(--gcw-color-success)}.gcw-window{display:flex;flex-direction:column;background-color:var(--gcw-color-white);border-radius:var(--gcw-radius-2xl);box-shadow:var(--gcw-shadow-2xl);border:1px solid var(--gcw-color-gray-200);overflow:hidden;animation:gcw-slide-up var(--gcw-transition-slow) ease-out}.gcw-window--small{width:320px;height:450px}.gcw-window--medium{width:380px;height:560px}.gcw-window--large{width:480px;height:680px}.gcw-window--fullscreen{width:calc(100vw - 2rem);height:calc(100vh - 6rem);max-width:56rem}.gcw-window{max-height:90vh;transition:width var(--gcw-transition-base),height var(--gcw-transition-base)}.gcw-header{display:flex;align-items:center;justify-content:space-between;padding:var(--gcw-spacing-3) var(--gcw-spacing-4);color:var(--gcw-color-white);flex-shrink:0}.gcw-header__left{display:flex;align-items:center;gap:var(--gcw-spacing-3)}.gcw-header__avatar{width:2.5rem;height:2.5rem;border-radius:var(--gcw-radius-full);background-color:#fff3;display:flex;align-items:center;justify-content:center}.gcw-header__avatar-icon{width:1.25rem;height:1.25rem}.gcw-header__info{display:flex;flex-direction:column;min-width:0;flex:1}.gcw-header__title{font-size:var(--gcw-font-size-base);font-weight:600;line-height:1.4;margin:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.gcw-header__subtitle{font-size:var(--gcw-font-size-sm);font-weight:400;line-height:1.4;opacity:.9;margin:0;word-wrap:break-word;overflow-wrap:break-word}.gcw-header__actions{display:flex;align-items:center;gap:.125rem}.gcw-header__btn{width:2rem;height:2rem;border:none;border-radius:var(--gcw-radius-full);background-color:transparent;color:inherit;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background-color var(--gcw-transition-fast)}.gcw-header__btn:hover{background-color:#fff3}.gcw-header__btn-icon{width:1rem;height:1rem}.gcw-header-menu{position:relative}.gcw-header-menu__dropdown{position:absolute;top:calc(100% + .25rem);right:0;min-width:12rem;background-color:var(--gcw-color-white);border-radius:var(--gcw-radius-lg);box-shadow:var(--gcw-shadow-xl);border:1px solid var(--gcw-color-gray-200);padding:var(--gcw-spacing-1) 0;z-index:10;animation:gcw-menu-appear var(--gcw-transition-fast) ease-out}.gcw-header-menu__item{display:flex;align-items:center;gap:var(--gcw-spacing-3);width:100%;padding:var(--gcw-spacing-2) var(--gcw-spacing-3);border:none;background:none;color:var(--gcw-color-gray-700);font-family:var(--gcw-font-family);font-size:var(--gcw-font-size-sm);cursor:pointer;transition:background-color var(--gcw-transition-fast);text-align:left;white-space:nowrap}.gcw-header-menu__item:hover{background-color:var(--gcw-color-gray-100)}.gcw-header-menu__item--danger{color:var(--gcw-color-error)}.gcw-header-menu__item--danger:hover{background-color:#fef2f2}.gcw-header-menu__icon{width:1rem;height:1rem;flex-shrink:0}.gcw-header-menu__divider{height:1px;background-color:var(--gcw-color-gray-200);margin:var(--gcw-spacing-1) 0}@keyframes gcw-menu-appear{0%{opacity:0;transform:translateY(-.25rem)}to{opacity:1;transform:translateY(0)}}.gcw-messages{flex:1;overflow-y:auto;padding:var(--gcw-spacing-4);display:flex;flex-direction:column;gap:var(--gcw-spacing-4)}.gcw-messages::-webkit-scrollbar{width:6px}.gcw-messages::-webkit-scrollbar-track{background:transparent}.gcw-messages::-webkit-scrollbar-thumb{background-color:var(--gcw-color-gray-300);border-radius:3px}.gcw-messages::-webkit-scrollbar-thumb:hover{background-color:var(--gcw-color-gray-400)}.gcw-empty{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:var(--gcw-spacing-6);color:var(--gcw-color-gray-400);text-align:center}.gcw-empty__icon{width:4rem;height:4rem;margin-bottom:var(--gcw-spacing-4);opacity:.5}.gcw-empty__text{font-size:var(--gcw-font-size-base);font-weight:400;line-height:1.5;margin:0}.gcw-session-loading{display:flex;flex-direction:column;align-items:center;gap:var(--gcw-spacing-3)}.gcw-session-loading__spinner{width:2rem;height:2rem;border:3px solid var(--gcw-color-gray-200);border-top-color:var(--gcw-color-primary);border-radius:50%;animation:gcw-spin .8s linear infinite}@keyframes gcw-spin{to{transform:rotate(360deg)}}.gcw-bubble-row{display:flex}.gcw-bubble-row--user{justify-content:flex-end}.gcw-bubble-row--assistant{justify-content:flex-start}.gcw-bubble-wrapper{max-width:85%;display:flex;flex-direction:column}.gcw-bubble-wrapper--user{align-items:flex-end}.gcw-bubble-wrapper--assistant{align-items:flex-start}.gcw-bubble{padding:var(--gcw-spacing-2) var(--gcw-spacing-4);border-radius:var(--gcw-radius-2xl);font-size:var(--gcw-font-size-base);font-weight:400;line-height:1.6;letter-spacing:normal;word-wrap:break-word}.gcw-bubble--user{color:var(--gcw-color-white);border-bottom-right-radius:var(--gcw-radius-sm)}.gcw-bubble--assistant{background-color:var(--gcw-color-gray-100);color:var(--gcw-color-gray-800);border-bottom-left-radius:var(--gcw-radius-sm)}.gcw-bubble__timestamp{font-size:var(--gcw-font-size-xs);color:var(--gcw-color-gray-400);margin-top:var(--gcw-spacing-1);padding:0 var(--gcw-spacing-1)}.gcw-content p{margin-bottom:var(--gcw-spacing-2)}.gcw-content p:last-child{margin-bottom:0}.gcw-content strong{font-weight:600}.gcw-content em{font-style:italic}.gcw-content ul,.gcw-content ol{margin:var(--gcw-spacing-2) 0;padding-left:var(--gcw-spacing-6)}.gcw-content li{margin-bottom:var(--gcw-spacing-1)}.gcw-content code{background-color:#0000001a;padding:.125rem .375rem;border-radius:var(--gcw-radius-sm);font-size:.875em;font-family:SF Mono,Monaco,Consolas,monospace}.gcw-bubble--user .gcw-content code{background-color:#fff3}.gcw-content pre{background-color:var(--gcw-color-gray-800);color:var(--gcw-color-gray-100);padding:var(--gcw-spacing-3);border-radius:var(--gcw-radius-md);overflow-x:auto;margin:var(--gcw-spacing-2) 0}.gcw-content pre code{background-color:transparent;padding:0;font-size:var(--gcw-font-size-sm)}.gcw-content a{color:var(--gcw-color-primary);text-decoration:underline}.gcw-content a:hover{color:var(--gcw-color-primary-hover)}.gcw-bubble--user .gcw-content a{color:#ffffffe6}.gcw-md-heading{font-weight:600;margin-top:var(--gcw-spacing-3);margin-bottom:var(--gcw-spacing-1)}.gcw-md-heading--h2{font-size:var(--gcw-font-size-lg);font-weight:700}.gcw-md-heading--h3,.gcw-md-heading--h4{font-size:var(--gcw-font-size-base)}.gcw-md-heading--h5{font-size:var(--gcw-font-size-sm)}.gcw-md-paragraph{margin-bottom:var(--gcw-spacing-2)}.gcw-md-paragraph:last-child{margin-bottom:0}.gcw-md-list{margin:var(--gcw-spacing-2) 0;padding-left:var(--gcw-spacing-4)}.gcw-md-list--ul{list-style-type:disc}.gcw-md-list--ol{list-style-type:decimal}.gcw-md-list__item{font-size:var(--gcw-font-size-base);margin-bottom:var(--gcw-spacing-1)}.gcw-md-bold{font-weight:600}.gcw-md-italic{font-style:italic}.gcw-md-code{background-color:var(--gcw-color-gray-200);padding:.125rem var(--gcw-spacing-2);border-radius:var(--gcw-radius-sm);font-size:var(--gcw-font-size-sm);font-family:SF Mono,Monaco,Consolas,monospace}.gcw-bubble--user .gcw-md-code{background-color:#fff3}.gcw-md-code-block{background-color:var(--gcw-color-gray-800);color:var(--gcw-color-gray-100);padding:var(--gcw-spacing-3);border-radius:var(--gcw-radius-lg);font-size:var(--gcw-font-size-sm);overflow-x:auto;margin:var(--gcw-spacing-2) 0}.gcw-md-code-block code{font-family:SF Mono,Monaco,Consolas,monospace}.gcw-md-link{color:var(--gcw-color-primary);text-decoration:underline}.gcw-md-link:hover{color:var(--gcw-color-primary-hover)}.gcw-bubble--user .gcw-md-link{color:#ffffffe6}.gcw-sources{display:flex;flex-wrap:wrap;gap:var(--gcw-spacing-2);margin-top:var(--gcw-spacing-2)}.gcw-source{display:inline-flex;align-items:center;gap:var(--gcw-spacing-1);padding:var(--gcw-spacing-1) var(--gcw-spacing-2);border-radius:var(--gcw-radius-full);background-color:var(--gcw-color-primary-light);color:var(--gcw-color-primary);font-size:var(--gcw-font-size-sm);text-decoration:none;transition:background-color var(--gcw-transition-fast)}.gcw-source:hover{background-color:#dbeafe}.gcw-source__icon{width:.75rem;height:.75rem}.gcw-typing{display:flex;justify-content:flex-start}.gcw-typing__bubble{background-color:var(--gcw-color-gray-100);padding:var(--gcw-spacing-3) var(--gcw-spacing-4);border-radius:var(--gcw-radius-2xl);border-bottom-left-radius:var(--gcw-radius-sm)}.gcw-typing__dots{display:flex;gap:var(--gcw-spacing-1)}.gcw-typing__dot{width:.5rem;height:.5rem;background-color:var(--gcw-color-gray-400);border-radius:var(--gcw-radius-full);animation:gcw-typing-bounce 1.4s infinite ease-in-out both}.gcw-typing__dot:nth-child(1){animation-delay:-.32s}.gcw-typing__dot:nth-child(2){animation-delay:-.16s}.gcw-input-area{padding:var(--gcw-spacing-3);border-top:1px solid var(--gcw-color-gray-200);background-color:var(--gcw-color-white);flex-shrink:0}.gcw-input-row{display:flex;align-items:flex-end;gap:var(--gcw-spacing-2)}.gcw-input{flex:1;min-height:44px;max-height:120px;padding:var(--gcw-spacing-2) var(--gcw-spacing-4);border:1px solid var(--gcw-color-gray-200);border-radius:var(--gcw-radius-xl);background-color:var(--gcw-color-white);color:var(--gcw-color-gray-800);font-family:var(--gcw-font-family);font-size:var(--gcw-font-size-base);font-weight:400;line-height:1.5;letter-spacing:normal;resize:none;outline:none;transition:border-color var(--gcw-transition-fast),box-shadow var(--gcw-transition-fast)}.gcw-input:focus{border-color:var(--gcw-color-primary);box-shadow:0 0 0 3px #3b82f61a}.gcw-input:disabled{background-color:var(--gcw-color-gray-50);cursor:not-allowed}.gcw-input::placeholder{color:var(--gcw-color-gray-400)}.gcw-send-btn{width:2.5rem;height:2.5rem;flex-shrink:0;border:none;border-radius:var(--gcw-radius-lg);color:var(--gcw-color-white);cursor:pointer;display:flex;align-items:center;justify-content:center;transition:opacity var(--gcw-transition-fast),transform var(--gcw-transition-fast)}.gcw-send-btn:hover:not(:disabled){opacity:.9}.gcw-send-btn:active:not(:disabled){transform:scale(.95)}.gcw-send-btn:disabled{opacity:.5;cursor:not-allowed}.gcw-send-btn__icon{width:1.25rem;height:1.25rem}.gcw-input-hint{font-size:var(--gcw-font-size-xs);color:var(--gcw-color-gray-400);text-align:center;margin-top:var(--gcw-spacing-2)}@keyframes gcw-slide-up{0%{opacity:0;transform:translateY(1rem)}to{opacity:1;transform:translateY(0)}}@keyframes gcw-pulse{0%,to{opacity:1}50%{opacity:.5}}@keyframes gcw-typing-bounce{0%,80%,to{transform:scale(0)}40%{transform:scale(1)}}@keyframes gcw-spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.gcw-sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}.gcw-spin{animation:gcw-spin 1s linear infinite}')),document.head.appendChild(r)}}catch(o){console.error("vite-plugin-css-injected-by-js",o)}})();
|
|
2
|
+
import { jsx as n, jsxs as d } from "react/jsx-runtime";
|
|
3
|
+
import re, { useState as y, useRef as P, useCallback as D, useEffect as k } from "react";
|
|
4
|
+
const ie = "gcw_session_", ae = "gcw_popout_", le = "gcw_read_";
|
|
5
|
+
function R(e) {
|
|
6
|
+
return `${ie}${e || "default"}`;
|
|
8
7
|
}
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
role: r.role,
|
|
17
|
-
content: r.content,
|
|
18
|
-
timestamp: r.timestamp.toISOString(),
|
|
19
|
-
sources: r.sources
|
|
20
|
-
})),
|
|
21
|
-
sessionId: n,
|
|
22
|
-
lastUpdated: (/* @__PURE__ */ new Date()).toISOString()
|
|
23
|
-
};
|
|
24
|
-
localStorage.setItem(J(s), JSON.stringify(a));
|
|
25
|
-
} catch (a) {
|
|
26
|
-
console.warn("Failed to save chat state:", a);
|
|
27
|
-
} finally {
|
|
28
|
-
q = !1;
|
|
29
|
-
}
|
|
8
|
+
function ce(e, s) {
|
|
9
|
+
try {
|
|
10
|
+
const t = R(s);
|
|
11
|
+
e ? localStorage.setItem(t, e) : localStorage.removeItem(t);
|
|
12
|
+
} catch (t) {
|
|
13
|
+
console.warn("Failed to save session ID:", t);
|
|
14
|
+
}
|
|
30
15
|
}
|
|
31
|
-
function
|
|
16
|
+
function de(e) {
|
|
32
17
|
try {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return (Date.now() - a.getTime()) / (1e3 * 60 * 60) > 24 ? (se(e), null) : {
|
|
37
|
-
messages: s.messages.map((o) => ({
|
|
38
|
-
id: o.id,
|
|
39
|
-
role: o.role,
|
|
40
|
-
content: o.content,
|
|
41
|
-
timestamp: new Date(o.timestamp),
|
|
42
|
-
sources: o.sources
|
|
43
|
-
})),
|
|
44
|
-
sessionId: s.sessionId
|
|
45
|
-
};
|
|
46
|
-
} catch (n) {
|
|
47
|
-
return console.warn("Failed to load chat state:", n), null;
|
|
18
|
+
return localStorage.getItem(R(e));
|
|
19
|
+
} catch {
|
|
20
|
+
return null;
|
|
48
21
|
}
|
|
49
22
|
}
|
|
50
|
-
function
|
|
23
|
+
function O(e) {
|
|
51
24
|
try {
|
|
52
|
-
localStorage.removeItem(
|
|
53
|
-
} catch (
|
|
54
|
-
console.warn("Failed to clear
|
|
25
|
+
localStorage.removeItem(R(e)), localStorage.removeItem(K(e));
|
|
26
|
+
} catch (s) {
|
|
27
|
+
console.warn("Failed to clear session:", s);
|
|
55
28
|
}
|
|
56
29
|
}
|
|
57
|
-
function
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
if (!r.newValue) {
|
|
61
|
-
n(null);
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
try {
|
|
65
|
-
const o = JSON.parse(r.newValue);
|
|
66
|
-
n({
|
|
67
|
-
messages: o.messages.map((i) => ({
|
|
68
|
-
id: i.id,
|
|
69
|
-
role: i.role,
|
|
70
|
-
content: i.content,
|
|
71
|
-
timestamp: new Date(i.timestamp),
|
|
72
|
-
sources: i.sources
|
|
73
|
-
})),
|
|
74
|
-
sessionId: o.sessionId
|
|
75
|
-
});
|
|
76
|
-
} catch {
|
|
77
|
-
}
|
|
78
|
-
}
|
|
30
|
+
function ue(e, s) {
|
|
31
|
+
const t = R(e), a = (r) => {
|
|
32
|
+
r.key === t && s(r.newValue);
|
|
79
33
|
};
|
|
80
34
|
return window.addEventListener("storage", a), () => window.removeEventListener("storage", a);
|
|
81
35
|
}
|
|
82
|
-
function
|
|
83
|
-
return `${
|
|
36
|
+
function X(e) {
|
|
37
|
+
return `${ae}${e || "default"}`;
|
|
84
38
|
}
|
|
85
|
-
function
|
|
39
|
+
function F(e, s) {
|
|
86
40
|
try {
|
|
87
|
-
e ? localStorage.setItem(
|
|
88
|
-
} catch (
|
|
89
|
-
console.warn("Failed to save popout state:",
|
|
41
|
+
e ? localStorage.setItem(X(s), "true") : localStorage.removeItem(X(s));
|
|
42
|
+
} catch (t) {
|
|
43
|
+
console.warn("Failed to save popout state:", t);
|
|
90
44
|
}
|
|
91
45
|
}
|
|
92
46
|
function me(e) {
|
|
93
47
|
try {
|
|
94
|
-
return localStorage.getItem(
|
|
48
|
+
return localStorage.getItem(X(e)) === "true";
|
|
95
49
|
} catch {
|
|
96
50
|
return !1;
|
|
97
51
|
}
|
|
98
52
|
}
|
|
99
|
-
function
|
|
100
|
-
return `${
|
|
53
|
+
function K(e) {
|
|
54
|
+
return `${le}${e || "default"}`;
|
|
101
55
|
}
|
|
102
|
-
function
|
|
56
|
+
function J(e, s) {
|
|
103
57
|
try {
|
|
104
|
-
e ? localStorage.setItem(
|
|
105
|
-
} catch (
|
|
106
|
-
console.warn("Failed to save read state:",
|
|
58
|
+
e > 0 ? localStorage.setItem(K(s), String(e)) : localStorage.removeItem(K(s));
|
|
59
|
+
} catch (t) {
|
|
60
|
+
console.warn("Failed to save read state:", t);
|
|
107
61
|
}
|
|
108
62
|
}
|
|
109
|
-
function
|
|
63
|
+
function pe(e) {
|
|
110
64
|
try {
|
|
111
|
-
|
|
65
|
+
const s = localStorage.getItem(K(e));
|
|
66
|
+
return s && parseInt(s, 10) || 0;
|
|
112
67
|
} catch {
|
|
113
|
-
return
|
|
68
|
+
return 0;
|
|
114
69
|
}
|
|
115
70
|
}
|
|
116
|
-
function
|
|
117
|
-
const { apiUrl:
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
71
|
+
function he(e) {
|
|
72
|
+
const { apiUrl: s, tenantId: t, sessionId: a, headers: r = {}, onError: o, persist: i = !0 } = e, [u, c] = y([]), [l, f] = y(!1), [x, _] = y(!1), [E, p] = y(null), [m, v] = y(() => a || (i ? de(t) : null)), j = P(null), W = P(!1), V = D(() => s.replace(/\/chat\/?$/, ""), [s]), $ = D(async (T) => {
|
|
73
|
+
_(!0);
|
|
74
|
+
try {
|
|
75
|
+
const M = V(), I = await fetch(`${M}/sessions/${T}`, {
|
|
76
|
+
method: "GET",
|
|
77
|
+
headers: {
|
|
78
|
+
"Content-Type": "application/json",
|
|
79
|
+
...t && { "X-Tenant-ID": t },
|
|
80
|
+
...r
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
if (I.status === 401)
|
|
84
|
+
return console.info("Unauthorized while loading session, clearing session"), i && O(t), v(null), !1;
|
|
85
|
+
if (I.status === 404)
|
|
86
|
+
return console.info("Session not found, starting fresh"), i && O(t), v(null), !1;
|
|
87
|
+
if (I.status === 429)
|
|
88
|
+
return console.info("Rate limited while loading session, will retry later"), !1;
|
|
89
|
+
if (!I.ok)
|
|
90
|
+
throw new Error(`Failed to load session: ${I.status}`);
|
|
91
|
+
const b = (await I.json()).messages.map((C) => {
|
|
92
|
+
var B;
|
|
93
|
+
return {
|
|
94
|
+
id: C.id,
|
|
95
|
+
role: C.role,
|
|
96
|
+
content: C.content,
|
|
97
|
+
timestamp: new Date(C.timestamp),
|
|
98
|
+
sources: (B = C.citations) == null ? void 0 : B.map((g) => ({
|
|
99
|
+
title: g.title,
|
|
100
|
+
url: g.url,
|
|
101
|
+
relevance: g.relevance_score
|
|
102
|
+
}))
|
|
103
|
+
};
|
|
104
|
+
});
|
|
105
|
+
return c(b), v(T), !0;
|
|
106
|
+
} catch (M) {
|
|
107
|
+
return console.error("Failed to load session:", M), i && O(t), v(null), !1;
|
|
108
|
+
} finally {
|
|
109
|
+
_(!1);
|
|
110
|
+
}
|
|
111
|
+
}, [V, t, r, i]);
|
|
112
|
+
k(() => {
|
|
113
|
+
W.current || (W.current = !0, m && $(m));
|
|
114
|
+
}, []), k(() => {
|
|
115
|
+
i && ce(m, t);
|
|
116
|
+
}, [m, t, i]), k(() => i ? ue(t, (M) => {
|
|
117
|
+
M && M !== m ? $(M) : M || (c([]), v(null));
|
|
118
|
+
}) : void 0, [t, i, m, $]);
|
|
119
|
+
const h = D(async (T) => {
|
|
120
|
+
var I;
|
|
121
|
+
if (!T.trim() || l) return;
|
|
122
|
+
j.current && j.current.abort(), j.current = new AbortController();
|
|
123
|
+
const M = {
|
|
124
|
+
id: `temp_${Date.now()}`,
|
|
143
125
|
role: "user",
|
|
144
|
-
content:
|
|
126
|
+
content: T.trim(),
|
|
145
127
|
timestamp: /* @__PURE__ */ new Date()
|
|
146
128
|
};
|
|
147
|
-
|
|
148
|
-
const E = W(), O = {
|
|
149
|
-
id: E,
|
|
150
|
-
role: "assistant",
|
|
151
|
-
content: "",
|
|
152
|
-
timestamp: /* @__PURE__ */ new Date(),
|
|
153
|
-
isStreaming: !0
|
|
154
|
-
};
|
|
155
|
-
l((d) => [...d, O]);
|
|
129
|
+
c((w) => [...w, M]), f(!0), p(null);
|
|
156
130
|
try {
|
|
157
|
-
const
|
|
131
|
+
const w = await fetch(s, {
|
|
158
132
|
method: "POST",
|
|
159
133
|
headers: {
|
|
160
134
|
"Content-Type": "application/json",
|
|
161
|
-
...
|
|
135
|
+
...t && { "X-Tenant-ID": t },
|
|
162
136
|
...r
|
|
163
137
|
},
|
|
164
138
|
body: JSON.stringify({
|
|
165
|
-
message:
|
|
139
|
+
message: T.trim(),
|
|
166
140
|
session_id: m
|
|
167
141
|
}),
|
|
168
|
-
signal:
|
|
142
|
+
signal: j.current.signal
|
|
169
143
|
});
|
|
170
|
-
if (!
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
144
|
+
if (!w.ok) {
|
|
145
|
+
if (w.status === 401) {
|
|
146
|
+
const L = {
|
|
147
|
+
id: `temp_${Date.now()}_unauthorized`,
|
|
148
|
+
role: "assistant",
|
|
149
|
+
content: "Je sessie is verlopen of je hebt geen toegang. Vernieuw de pagina om opnieuw te verbinden.",
|
|
150
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
151
|
+
};
|
|
152
|
+
c((H) => [...H, L]), i && O(t), v(null);
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
if (w.status === 429) {
|
|
156
|
+
const L = {
|
|
157
|
+
id: `temp_${Date.now()}_ratelimit`,
|
|
158
|
+
role: "assistant",
|
|
159
|
+
content: "Je stuurt te veel berichten achter elkaar. Wacht even en probeer het dan opnieuw.",
|
|
160
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
161
|
+
};
|
|
162
|
+
c((H) => [...H, L]);
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
const g = await w.json().catch(() => ({}));
|
|
166
|
+
throw new Error(g.detail || `Request failed with status ${w.status}`);
|
|
191
167
|
}
|
|
192
|
-
|
|
193
|
-
|
|
168
|
+
const b = await w.json(), C = (I = b.message.citations) == null ? void 0 : I.map((g) => ({
|
|
169
|
+
title: g.title,
|
|
170
|
+
url: g.url,
|
|
171
|
+
relevance: g.relevance_score
|
|
172
|
+
})), B = {
|
|
173
|
+
id: `temp_${Date.now()}_assistant`,
|
|
174
|
+
role: "assistant",
|
|
175
|
+
content: b.message.content,
|
|
176
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
177
|
+
sources: C
|
|
178
|
+
};
|
|
179
|
+
c((g) => [...g, B]), b.session_id && v(b.session_id);
|
|
180
|
+
} catch (w) {
|
|
181
|
+
if (w.name === "AbortError")
|
|
194
182
|
return;
|
|
195
|
-
const
|
|
196
|
-
|
|
197
|
-
(I) => I.id === E ? {
|
|
198
|
-
...I,
|
|
199
|
-
content: "Sorry, an error occurred. Please try again.",
|
|
200
|
-
isStreaming: !1
|
|
201
|
-
} : I
|
|
202
|
-
));
|
|
183
|
+
const b = w instanceof Error ? w : new Error("An error occurred");
|
|
184
|
+
p(b), o == null || o(b);
|
|
203
185
|
} finally {
|
|
204
|
-
|
|
205
|
-
}
|
|
206
|
-
}, [n, s, m, r, g, o]), X = async (c, _) => {
|
|
207
|
-
var d;
|
|
208
|
-
const E = (d = c.body) == null ? void 0 : d.getReader();
|
|
209
|
-
if (!E) throw new Error("No response body");
|
|
210
|
-
const O = new TextDecoder();
|
|
211
|
-
let z = "";
|
|
212
|
-
try {
|
|
213
|
-
for (; ; ) {
|
|
214
|
-
const { done: y, value: h } = await E.read();
|
|
215
|
-
if (y) break;
|
|
216
|
-
const k = O.decode(h, { stream: !0 }).split(`
|
|
217
|
-
`);
|
|
218
|
-
for (const D of k)
|
|
219
|
-
if (D.startsWith("data: ")) {
|
|
220
|
-
const F = D.slice(6);
|
|
221
|
-
if (F === "[DONE]") continue;
|
|
222
|
-
try {
|
|
223
|
-
const S = JSON.parse(F);
|
|
224
|
-
S.type === "content" && S.content ? (z += S.content, l((H) => H.map(
|
|
225
|
-
(j) => j.id === _ ? { ...j, content: z } : j
|
|
226
|
-
))) : S.type === "sources" && S.sources ? l((H) => H.map(
|
|
227
|
-
(j) => j.id === _ ? { ...j, sources: S.sources } : j
|
|
228
|
-
)) : S.conversation_id && f(S.conversation_id);
|
|
229
|
-
} catch {
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
} finally {
|
|
234
|
-
l((y) => y.map(
|
|
235
|
-
(h) => h.id === _ ? { ...h, isStreaming: !1 } : h
|
|
236
|
-
));
|
|
186
|
+
f(!1), j.current = null;
|
|
237
187
|
}
|
|
238
|
-
},
|
|
239
|
-
|
|
240
|
-
}, [i,
|
|
188
|
+
}, [s, t, m, r, l, o]), G = D(() => {
|
|
189
|
+
c([]), v(null), p(null), W.current = !1, i && O(t);
|
|
190
|
+
}, [i, t]);
|
|
241
191
|
return {
|
|
242
|
-
messages:
|
|
243
|
-
isLoading:
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
192
|
+
messages: u,
|
|
193
|
+
isLoading: l,
|
|
194
|
+
isLoadingSession: x,
|
|
195
|
+
error: E,
|
|
196
|
+
sendMessage: h,
|
|
197
|
+
clearMessages: G,
|
|
247
198
|
sessionId: m
|
|
248
199
|
};
|
|
249
200
|
}
|
|
250
|
-
let
|
|
251
|
-
function
|
|
252
|
-
const [a, r] =
|
|
253
|
-
|
|
201
|
+
let A = null;
|
|
202
|
+
function ge(e, s, t) {
|
|
203
|
+
const [a, r] = y(() => me(e.tenantId)), o = P(A);
|
|
204
|
+
k(() => {
|
|
254
205
|
if (a && !o.current) {
|
|
255
206
|
const l = window.open("", "GeoAppsChatPopout");
|
|
256
|
-
l && l.location.href !== "about:blank" && !l.closed ? (o.current = l,
|
|
207
|
+
l && l.location.href !== "about:blank" && !l.closed ? (o.current = l, A = l) : (r(!1), F(!1, e.tenantId));
|
|
257
208
|
}
|
|
258
|
-
}, [a, e.tenantId]),
|
|
209
|
+
}, [a, e.tenantId]), k(() => {
|
|
259
210
|
if (!o.current) return;
|
|
260
211
|
const l = setInterval(() => {
|
|
261
|
-
var
|
|
262
|
-
(
|
|
212
|
+
var f;
|
|
213
|
+
(f = o.current) != null && f.closed && (r(!1), o.current = null, A = null, F(!1, e.tenantId));
|
|
263
214
|
}, 500);
|
|
264
215
|
return () => clearInterval(l);
|
|
265
|
-
}, [e.tenantId,
|
|
266
|
-
const i =
|
|
216
|
+
}, [e.tenantId, t]);
|
|
217
|
+
const i = D(() => {
|
|
267
218
|
if (o.current && !o.current.closed) {
|
|
268
219
|
o.current.focus();
|
|
269
220
|
return;
|
|
@@ -273,32 +224,32 @@ function fe(e, n, s) {
|
|
|
273
224
|
medium: { width: 440, height: 660 },
|
|
274
225
|
large: { width: 560, height: 780 },
|
|
275
226
|
fullscreen: { width: 700, height: 800 }
|
|
276
|
-
}, { width:
|
|
227
|
+
}, { width: f, height: x } = l[s], _ = (window.screen.width - f) / 2, E = (window.screen.height - x) / 2, p = window.open(
|
|
277
228
|
"",
|
|
278
229
|
"GeoAppsChatPopout",
|
|
279
|
-
`width=${
|
|
230
|
+
`width=${f},height=${x},left=${_},top=${E},resizable=yes,scrollbars=no`
|
|
280
231
|
);
|
|
281
|
-
if (!
|
|
232
|
+
if (!p) {
|
|
282
233
|
console.error("Failed to open popup window. Check if popups are blocked.");
|
|
283
234
|
return;
|
|
284
235
|
}
|
|
285
|
-
|
|
286
|
-
}, [e,
|
|
287
|
-
o.current && !o.current.closed && o.current.close(), o.current = null,
|
|
288
|
-
}, [e.tenantId]),
|
|
236
|
+
p.__CHAT_CONFIG__ = e, p.document.write(fe(e)), p.document.close(), o.current = p, A = p, r(!0), F(!0, e.tenantId);
|
|
237
|
+
}, [e, s]), u = D(() => {
|
|
238
|
+
o.current && !o.current.closed && o.current.close(), o.current = null, A = null, r(!1), F(!1, e.tenantId);
|
|
239
|
+
}, [e.tenantId]), c = D(() => {
|
|
289
240
|
o.current && !o.current.closed && o.current.focus();
|
|
290
241
|
}, []);
|
|
291
242
|
return {
|
|
292
243
|
isPoppedOut: a,
|
|
293
244
|
openPopout: i,
|
|
294
245
|
closePopout: u,
|
|
295
|
-
focusPopout:
|
|
246
|
+
focusPopout: c
|
|
296
247
|
};
|
|
297
248
|
}
|
|
298
|
-
function
|
|
299
|
-
const
|
|
300
|
-
...
|
|
301
|
-
timestamp:
|
|
249
|
+
function fe(e) {
|
|
250
|
+
const s = e.messages.map((t) => ({
|
|
251
|
+
...t,
|
|
252
|
+
timestamp: t.timestamp.toISOString()
|
|
302
253
|
}));
|
|
303
254
|
return `
|
|
304
255
|
<!DOCTYPE html>
|
|
@@ -306,7 +257,7 @@ function we(e) {
|
|
|
306
257
|
<head>
|
|
307
258
|
<meta charset="UTF-8">
|
|
308
259
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
309
|
-
<title>${
|
|
260
|
+
<title>${U(e.title)}</title>
|
|
310
261
|
<style>
|
|
311
262
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
312
263
|
html, body, #chat-root { height: 100%; width: 100%; }
|
|
@@ -605,8 +556,8 @@ function we(e) {
|
|
|
605
556
|
</svg>
|
|
606
557
|
</div>
|
|
607
558
|
<div class="popout-header-info">
|
|
608
|
-
<div class="popout-title">${
|
|
609
|
-
<div class="popout-subtitle">${
|
|
559
|
+
<div class="popout-title">${U(e.title)}</div>
|
|
560
|
+
<div class="popout-subtitle">${U(e.subtitle)}</div>
|
|
610
561
|
</div>
|
|
611
562
|
<div class="popout-header-actions">
|
|
612
563
|
<button class="popout-header-btn" id="clear-btn" title="Verwijder chatgeschiedenis">
|
|
@@ -622,7 +573,7 @@ function we(e) {
|
|
|
622
573
|
<textarea
|
|
623
574
|
class="popout-textarea"
|
|
624
575
|
id="message-input"
|
|
625
|
-
placeholder="${
|
|
576
|
+
placeholder="${U(e.placeholder)}"
|
|
626
577
|
rows="1"
|
|
627
578
|
></textarea>
|
|
628
579
|
<button
|
|
@@ -651,7 +602,7 @@ function we(e) {
|
|
|
651
602
|
|
|
652
603
|
const STORAGE_KEY = 'gcw_chat_' + (config.tenantId || 'default');
|
|
653
604
|
|
|
654
|
-
let messages = ${JSON.stringify(
|
|
605
|
+
let messages = ${JSON.stringify(s)}.map(m => ({
|
|
655
606
|
...m,
|
|
656
607
|
timestamp: new Date(m.timestamp)
|
|
657
608
|
}));
|
|
@@ -901,69 +852,69 @@ function we(e) {
|
|
|
901
852
|
</html>
|
|
902
853
|
`;
|
|
903
854
|
}
|
|
904
|
-
function
|
|
855
|
+
function U(e) {
|
|
905
856
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
906
857
|
}
|
|
907
|
-
function
|
|
858
|
+
function we({ content: e, className: s }) {
|
|
908
859
|
if (!e) return null;
|
|
909
|
-
const
|
|
910
|
-
return /* @__PURE__ */
|
|
860
|
+
const t = be(e);
|
|
861
|
+
return /* @__PURE__ */ n("div", { className: s, children: t.map((a, r) => /* @__PURE__ */ n(re.Fragment, { children: a }, r)) });
|
|
911
862
|
}
|
|
912
|
-
function
|
|
913
|
-
const
|
|
914
|
-
`),
|
|
863
|
+
function be(e) {
|
|
864
|
+
const s = e.split(`
|
|
865
|
+
`), t = [];
|
|
915
866
|
let a = null;
|
|
916
867
|
const r = () => {
|
|
917
|
-
a && (a.type === "ul" ?
|
|
918
|
-
/* @__PURE__ */
|
|
919
|
-
) :
|
|
920
|
-
/* @__PURE__ */
|
|
868
|
+
a && (a.type === "ul" ? t.push(
|
|
869
|
+
/* @__PURE__ */ n("ul", { className: "gcw-md-list gcw-md-list--ul", children: a.items.map((o, i) => /* @__PURE__ */ n("li", { className: "gcw-md-list__item", children: o }, i)) }, `list-${t.length}`)
|
|
870
|
+
) : t.push(
|
|
871
|
+
/* @__PURE__ */ n("ol", { className: "gcw-md-list gcw-md-list--ol", children: a.items.map((o, i) => /* @__PURE__ */ n("li", { className: "gcw-md-list__item", children: o }, i)) }, `list-${t.length}`)
|
|
921
872
|
), a = null);
|
|
922
873
|
};
|
|
923
|
-
for (let o = 0; o <
|
|
924
|
-
const i =
|
|
874
|
+
for (let o = 0; o < s.length; o++) {
|
|
875
|
+
const i = s[o];
|
|
925
876
|
if (i.startsWith("#### ")) {
|
|
926
|
-
r(),
|
|
927
|
-
/* @__PURE__ */
|
|
877
|
+
r(), t.push(
|
|
878
|
+
/* @__PURE__ */ n("h5", { className: "gcw-md-heading gcw-md-heading--h5", children: z(i.slice(5)) }, o)
|
|
928
879
|
);
|
|
929
880
|
continue;
|
|
930
881
|
}
|
|
931
882
|
if (i.startsWith("### ")) {
|
|
932
|
-
r(),
|
|
933
|
-
/* @__PURE__ */
|
|
883
|
+
r(), t.push(
|
|
884
|
+
/* @__PURE__ */ n("h4", { className: "gcw-md-heading gcw-md-heading--h4", children: z(i.slice(4)) }, o)
|
|
934
885
|
);
|
|
935
886
|
continue;
|
|
936
887
|
}
|
|
937
888
|
if (i.startsWith("## ")) {
|
|
938
|
-
r(),
|
|
939
|
-
/* @__PURE__ */
|
|
889
|
+
r(), t.push(
|
|
890
|
+
/* @__PURE__ */ n("h3", { className: "gcw-md-heading gcw-md-heading--h3", children: z(i.slice(3)) }, o)
|
|
940
891
|
);
|
|
941
892
|
continue;
|
|
942
893
|
}
|
|
943
894
|
if (i.startsWith("# ")) {
|
|
944
|
-
r(),
|
|
945
|
-
/* @__PURE__ */
|
|
895
|
+
r(), t.push(
|
|
896
|
+
/* @__PURE__ */ n("h2", { className: "gcw-md-heading gcw-md-heading--h2", children: z(i.slice(2)) }, o)
|
|
946
897
|
);
|
|
947
898
|
continue;
|
|
948
899
|
}
|
|
949
900
|
const u = i.match(/^[\s]*[-*•]\s+(.+)/);
|
|
950
901
|
if (u) {
|
|
951
|
-
(!a || a.type !== "ul") && (r(), a = { type: "ul", items: [] }), a.items.push(
|
|
902
|
+
(!a || a.type !== "ul") && (r(), a = { type: "ul", items: [] }), a.items.push(z(u[1]));
|
|
952
903
|
continue;
|
|
953
904
|
}
|
|
954
|
-
const
|
|
955
|
-
if (
|
|
956
|
-
(!a || a.type !== "ol") && (r(), a = { type: "ol", items: [] }), a.items.push(
|
|
905
|
+
const c = i.match(/^[\s]*(\d+)[.)]\s+(.+)/);
|
|
906
|
+
if (c) {
|
|
907
|
+
(!a || a.type !== "ol") && (r(), a = { type: "ol", items: [] }), a.items.push(z(c[2]));
|
|
957
908
|
continue;
|
|
958
909
|
}
|
|
959
910
|
if (i.startsWith("```")) {
|
|
960
911
|
r();
|
|
961
912
|
const l = [];
|
|
962
|
-
for (o++; o <
|
|
963
|
-
l.push(
|
|
964
|
-
|
|
965
|
-
/* @__PURE__ */
|
|
966
|
-
`) }) }, `code-${
|
|
913
|
+
for (o++; o < s.length && !s[o].startsWith("```"); )
|
|
914
|
+
l.push(s[o]), o++;
|
|
915
|
+
t.push(
|
|
916
|
+
/* @__PURE__ */ n("pre", { className: "gcw-md-code-block", children: /* @__PURE__ */ n("code", { children: l.join(`
|
|
917
|
+
`) }) }, `code-${t.length}`)
|
|
967
918
|
);
|
|
968
919
|
continue;
|
|
969
920
|
}
|
|
@@ -971,38 +922,38 @@ function ve(e) {
|
|
|
971
922
|
r();
|
|
972
923
|
continue;
|
|
973
924
|
}
|
|
974
|
-
r(),
|
|
975
|
-
/* @__PURE__ */
|
|
925
|
+
r(), t.push(
|
|
926
|
+
/* @__PURE__ */ n("p", { className: "gcw-md-paragraph", children: z(i) }, o)
|
|
976
927
|
);
|
|
977
928
|
}
|
|
978
|
-
return r(),
|
|
929
|
+
return r(), t;
|
|
979
930
|
}
|
|
980
|
-
function
|
|
931
|
+
function z(e) {
|
|
981
932
|
if (!e) return null;
|
|
982
|
-
const
|
|
983
|
-
let
|
|
984
|
-
for (;
|
|
985
|
-
const r =
|
|
933
|
+
const s = [];
|
|
934
|
+
let t = e, a = 0;
|
|
935
|
+
for (; t.length > 0; ) {
|
|
936
|
+
const r = t.match(/^\*\*(.+?)\*\*/);
|
|
986
937
|
if (r) {
|
|
987
|
-
|
|
938
|
+
s.push(/* @__PURE__ */ n("strong", { className: "gcw-md-bold", children: r[1] }, a++)), t = t.slice(r[0].length);
|
|
988
939
|
continue;
|
|
989
940
|
}
|
|
990
|
-
const o =
|
|
941
|
+
const o = t.match(/^\*([^*]+?)\*/);
|
|
991
942
|
if (o) {
|
|
992
|
-
|
|
943
|
+
s.push(/* @__PURE__ */ n("em", { className: "gcw-md-italic", children: o[1] }, a++)), t = t.slice(o[0].length);
|
|
993
944
|
continue;
|
|
994
945
|
}
|
|
995
|
-
const i =
|
|
946
|
+
const i = t.match(/^`([^`]+)`/);
|
|
996
947
|
if (i) {
|
|
997
|
-
|
|
998
|
-
/* @__PURE__ */
|
|
999
|
-
),
|
|
948
|
+
s.push(
|
|
949
|
+
/* @__PURE__ */ n("code", { className: "gcw-md-code", children: i[1] }, a++)
|
|
950
|
+
), t = t.slice(i[0].length);
|
|
1000
951
|
continue;
|
|
1001
952
|
}
|
|
1002
|
-
const u =
|
|
953
|
+
const u = t.match(/^\[([^\]]+)\]\(([^)]+)\)/);
|
|
1003
954
|
if (u) {
|
|
1004
|
-
|
|
1005
|
-
/* @__PURE__ */
|
|
955
|
+
s.push(
|
|
956
|
+
/* @__PURE__ */ n(
|
|
1006
957
|
"a",
|
|
1007
958
|
{
|
|
1008
959
|
href: u[2],
|
|
@@ -1013,45 +964,38 @@ function P(e) {
|
|
|
1013
964
|
},
|
|
1014
965
|
a++
|
|
1015
966
|
)
|
|
1016
|
-
),
|
|
967
|
+
), t = t.slice(u[0].length);
|
|
1017
968
|
continue;
|
|
1018
969
|
}
|
|
1019
|
-
const
|
|
1020
|
-
if (
|
|
1021
|
-
|
|
970
|
+
const c = t.search(/[\*`\[]/);
|
|
971
|
+
if (c === -1) {
|
|
972
|
+
s.push(t);
|
|
1022
973
|
break;
|
|
1023
|
-
} else
|
|
974
|
+
} else c === 0 ? (s.push(t[0]), t = t.slice(1)) : (s.push(t.slice(0, c)), t = t.slice(c));
|
|
1024
975
|
}
|
|
1025
|
-
return
|
|
1026
|
-
}
|
|
1027
|
-
function ye() {
|
|
1028
|
-
return /* @__PURE__ */ b("div", { className: "gcw-typing__dots", children: [
|
|
1029
|
-
/* @__PURE__ */ t("span", { className: "gcw-typing__dot" }),
|
|
1030
|
-
/* @__PURE__ */ t("span", { className: "gcw-typing__dot" }),
|
|
1031
|
-
/* @__PURE__ */ t("span", { className: "gcw-typing__dot" })
|
|
1032
|
-
] });
|
|
976
|
+
return s.length === 1 ? s[0] : s;
|
|
1033
977
|
}
|
|
1034
|
-
function
|
|
1035
|
-
return /* @__PURE__ */
|
|
978
|
+
function ve({ className: e }) {
|
|
979
|
+
return /* @__PURE__ */ n("svg", { className: e, fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ n("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1" }) });
|
|
1036
980
|
}
|
|
1037
|
-
function
|
|
981
|
+
function ye(e) {
|
|
1038
982
|
return e.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
|
|
1039
983
|
}
|
|
1040
|
-
function
|
|
1041
|
-
return e.length <=
|
|
984
|
+
function ke(e, s) {
|
|
985
|
+
return e.length <= s ? e : e.slice(0, s - 3) + "...";
|
|
1042
986
|
}
|
|
1043
|
-
function
|
|
1044
|
-
const
|
|
1045
|
-
return /* @__PURE__ */
|
|
1046
|
-
/* @__PURE__ */
|
|
987
|
+
function xe({ message: e, primaryColor: s }) {
|
|
988
|
+
const t = e.role === "user", a = t ? "user" : "assistant";
|
|
989
|
+
return /* @__PURE__ */ n("div", { className: `gcw-bubble-row gcw-bubble-row--${a}`, children: /* @__PURE__ */ d("div", { className: `gcw-bubble-wrapper gcw-bubble-wrapper--${a}`, children: [
|
|
990
|
+
/* @__PURE__ */ n(
|
|
1047
991
|
"div",
|
|
1048
992
|
{
|
|
1049
993
|
className: `gcw-bubble gcw-bubble--${a}`,
|
|
1050
|
-
style:
|
|
1051
|
-
children:
|
|
994
|
+
style: t ? { backgroundColor: s } : void 0,
|
|
995
|
+
children: /* @__PURE__ */ n(we, { content: e.content, className: "gcw-content" })
|
|
1052
996
|
}
|
|
1053
997
|
),
|
|
1054
|
-
e.sources && e.sources.length > 0 && /* @__PURE__ */
|
|
998
|
+
e.sources && e.sources.length > 0 && /* @__PURE__ */ n("div", { className: "gcw-sources", children: e.sources.slice(0, 3).map((r, o) => /* @__PURE__ */ d(
|
|
1055
999
|
"a",
|
|
1056
1000
|
{
|
|
1057
1001
|
href: r.url,
|
|
@@ -1059,56 +1003,59 @@ function _e({ message: e, primaryColor: n }) {
|
|
|
1059
1003
|
rel: "noopener noreferrer",
|
|
1060
1004
|
className: "gcw-source",
|
|
1061
1005
|
children: [
|
|
1062
|
-
/* @__PURE__ */
|
|
1063
|
-
|
|
1006
|
+
/* @__PURE__ */ n(ve, { className: "gcw-source__icon" }),
|
|
1007
|
+
ke(r.title, 25)
|
|
1064
1008
|
]
|
|
1065
1009
|
},
|
|
1066
1010
|
o
|
|
1067
1011
|
)) }),
|
|
1068
|
-
/* @__PURE__ */
|
|
1012
|
+
/* @__PURE__ */ n("span", { className: "gcw-bubble__timestamp", children: ye(e.timestamp) })
|
|
1069
1013
|
] }) });
|
|
1070
1014
|
}
|
|
1071
|
-
function
|
|
1072
|
-
return /* @__PURE__ */
|
|
1073
|
-
/* @__PURE__ */
|
|
1074
|
-
/* @__PURE__ */
|
|
1075
|
-
/* @__PURE__ */
|
|
1015
|
+
function _e() {
|
|
1016
|
+
return /* @__PURE__ */ n("div", { className: "gcw-typing", children: /* @__PURE__ */ n("div", { className: "gcw-typing__bubble", children: /* @__PURE__ */ d("div", { className: "gcw-typing__dots", children: [
|
|
1017
|
+
/* @__PURE__ */ n("span", { className: "gcw-typing__dot" }),
|
|
1018
|
+
/* @__PURE__ */ n("span", { className: "gcw-typing__dot" }),
|
|
1019
|
+
/* @__PURE__ */ n("span", { className: "gcw-typing__dot" })
|
|
1076
1020
|
] }) }) });
|
|
1077
1021
|
}
|
|
1078
|
-
function
|
|
1079
|
-
var
|
|
1080
|
-
const
|
|
1081
|
-
return
|
|
1082
|
-
var
|
|
1083
|
-
(
|
|
1084
|
-
}, [e,
|
|
1085
|
-
/* @__PURE__ */
|
|
1086
|
-
/* @__PURE__ */
|
|
1087
|
-
] }) : /* @__PURE__ */
|
|
1088
|
-
|
|
1089
|
-
|
|
1022
|
+
function Me({ messages: e, isLoading: s, isLoadingSession: t = !1, primaryColor: a }) {
|
|
1023
|
+
var o;
|
|
1024
|
+
const r = P(null);
|
|
1025
|
+
return k(() => {
|
|
1026
|
+
var i;
|
|
1027
|
+
(i = r.current) == null || i.scrollIntoView({ behavior: "smooth" });
|
|
1028
|
+
}, [e, s]), t ? /* @__PURE__ */ n("div", { className: "gcw-empty", children: /* @__PURE__ */ d("div", { className: "gcw-session-loading", children: [
|
|
1029
|
+
/* @__PURE__ */ n("div", { className: "gcw-session-loading__spinner" }),
|
|
1030
|
+
/* @__PURE__ */ n("p", { className: "gcw-empty__text", children: "Chatgeschiedenis laden..." })
|
|
1031
|
+
] }) }) : e.length === 0 && !s ? /* @__PURE__ */ d("div", { className: "gcw-empty", children: [
|
|
1032
|
+
/* @__PURE__ */ n("svg", { className: "gcw-empty__icon", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ n("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.5, d: "M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z" }) }),
|
|
1033
|
+
/* @__PURE__ */ n("p", { className: "gcw-empty__text", children: "Begin een gesprek door hieronder een bericht te typen" })
|
|
1034
|
+
] }) : /* @__PURE__ */ d("div", { className: "gcw-messages", children: [
|
|
1035
|
+
e.map((i) => /* @__PURE__ */ n(
|
|
1036
|
+
xe,
|
|
1090
1037
|
{
|
|
1091
|
-
message:
|
|
1092
|
-
primaryColor:
|
|
1038
|
+
message: i,
|
|
1039
|
+
primaryColor: a
|
|
1093
1040
|
},
|
|
1094
|
-
|
|
1041
|
+
i.id
|
|
1095
1042
|
)),
|
|
1096
|
-
|
|
1097
|
-
/* @__PURE__ */
|
|
1043
|
+
s && ((o = e[e.length - 1]) == null ? void 0 : o.role) !== "assistant" && /* @__PURE__ */ n(_e, {}),
|
|
1044
|
+
/* @__PURE__ */ n("div", { ref: r })
|
|
1098
1045
|
] });
|
|
1099
1046
|
}
|
|
1100
|
-
function
|
|
1101
|
-
const [r, o] =
|
|
1102
|
-
|
|
1047
|
+
function Ie({ placeholder: e, isLoading: s, onSendMessage: t, primaryColor: a }) {
|
|
1048
|
+
const [r, o] = y(""), i = P(null);
|
|
1049
|
+
k(() => {
|
|
1103
1050
|
const l = i.current;
|
|
1104
1051
|
l && (l.style.height = "auto", l.style.height = `${Math.min(l.scrollHeight, 120)}px`);
|
|
1105
1052
|
}, [r]);
|
|
1106
1053
|
const u = () => {
|
|
1107
|
-
r.trim() && !
|
|
1054
|
+
r.trim() && !s && (t(r), o(""), i.current && (i.current.style.height = "auto"));
|
|
1108
1055
|
};
|
|
1109
|
-
return /* @__PURE__ */
|
|
1110
|
-
/* @__PURE__ */
|
|
1111
|
-
/* @__PURE__ */
|
|
1056
|
+
return /* @__PURE__ */ d("div", { className: "gcw-input-area", children: [
|
|
1057
|
+
/* @__PURE__ */ d("div", { className: "gcw-input-row", children: [
|
|
1058
|
+
/* @__PURE__ */ n(
|
|
1112
1059
|
"textarea",
|
|
1113
1060
|
{
|
|
1114
1061
|
ref: i,
|
|
@@ -1118,52 +1065,140 @@ function Ce({ placeholder: e, isLoading: n, onSendMessage: s, primaryColor: a })
|
|
|
1118
1065
|
l.key === "Enter" && !l.shiftKey && (l.preventDefault(), u());
|
|
1119
1066
|
},
|
|
1120
1067
|
placeholder: e,
|
|
1121
|
-
disabled:
|
|
1068
|
+
disabled: s,
|
|
1122
1069
|
rows: 1,
|
|
1123
1070
|
className: "gcw-input"
|
|
1124
1071
|
}
|
|
1125
1072
|
),
|
|
1126
|
-
/* @__PURE__ */
|
|
1073
|
+
/* @__PURE__ */ n(
|
|
1127
1074
|
"button",
|
|
1128
1075
|
{
|
|
1129
1076
|
onClick: u,
|
|
1130
|
-
disabled: !r.trim() ||
|
|
1077
|
+
disabled: !r.trim() || s,
|
|
1131
1078
|
className: "gcw-send-btn",
|
|
1132
1079
|
style: { backgroundColor: a },
|
|
1133
1080
|
title: "Verstuur bericht",
|
|
1134
|
-
children:
|
|
1135
|
-
/* @__PURE__ */
|
|
1136
|
-
/* @__PURE__ */
|
|
1137
|
-
] }) : /* @__PURE__ */
|
|
1081
|
+
children: s ? /* @__PURE__ */ d("svg", { className: "gcw-send-btn__icon gcw-spin", fill: "none", viewBox: "0 0 24 24", children: [
|
|
1082
|
+
/* @__PURE__ */ n("circle", { style: { opacity: 0.25 }, cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
|
|
1083
|
+
/* @__PURE__ */ n("path", { style: { opacity: 0.75 }, fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })
|
|
1084
|
+
] }) : /* @__PURE__ */ n("svg", { className: "gcw-send-btn__icon", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ n("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 19l9 2-9-18-9 18 9-2zm0 0v-8" }) })
|
|
1138
1085
|
}
|
|
1139
1086
|
)
|
|
1140
1087
|
] }),
|
|
1141
|
-
/* @__PURE__ */
|
|
1088
|
+
/* @__PURE__ */ n("p", { className: "gcw-input-hint", children: "Druk op Enter om te verzenden, Shift+Enter voor een nieuwe regel" })
|
|
1142
1089
|
] });
|
|
1143
1090
|
}
|
|
1144
|
-
function
|
|
1091
|
+
function Ce({ size: e, className: s = "gcw-w-4 gcw-h-4" }) {
|
|
1145
1092
|
switch (e) {
|
|
1146
1093
|
case "small":
|
|
1147
|
-
return /* @__PURE__ */
|
|
1094
|
+
return /* @__PURE__ */ n("svg", { className: s, fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ n("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4" }) });
|
|
1148
1095
|
case "medium":
|
|
1149
|
-
return /* @__PURE__ */
|
|
1096
|
+
return /* @__PURE__ */ n("svg", { className: s, fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ n("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4" }) });
|
|
1150
1097
|
case "large":
|
|
1151
|
-
return /* @__PURE__ */
|
|
1098
|
+
return /* @__PURE__ */ n("svg", { className: s, fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ n("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4" }) });
|
|
1152
1099
|
case "fullscreen":
|
|
1153
|
-
return /* @__PURE__ */
|
|
1100
|
+
return /* @__PURE__ */ n("svg", { className: s, fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ n("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 9V4.5M9 9H4.5M9 9L3.75 3.75M9 15v4.5M9 15H4.5M9 15l-5.25 5.25M15 9h4.5M15 9V4.5M15 9l5.25-5.25M15 15h4.5M15 15v4.5m0-4.5l5.25 5.25" }) });
|
|
1154
1101
|
}
|
|
1155
1102
|
}
|
|
1156
|
-
function
|
|
1157
|
-
return /* @__PURE__ */
|
|
1103
|
+
function Se({ className: e = "gcw-w-4 gcw-h-4" }) {
|
|
1104
|
+
return /* @__PURE__ */ n("svg", { className: e, fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ n("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" }) });
|
|
1158
1105
|
}
|
|
1159
|
-
function
|
|
1160
|
-
return /* @__PURE__ */
|
|
1106
|
+
function Ne({ className: e = "gcw-w-4 gcw-h-4" }) {
|
|
1107
|
+
return /* @__PURE__ */ n("svg", { className: e, fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ n("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) });
|
|
1161
1108
|
}
|
|
1162
|
-
function
|
|
1163
|
-
return /* @__PURE__ */
|
|
1109
|
+
function Le({ className: e = "gcw-w-4 gcw-h-4" }) {
|
|
1110
|
+
return /* @__PURE__ */ n("svg", { className: e, fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ n("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" }) });
|
|
1164
1111
|
}
|
|
1165
1112
|
function Ee({ className: e = "gcw-w-6 gcw-h-6" }) {
|
|
1166
|
-
return /* @__PURE__ */
|
|
1113
|
+
return /* @__PURE__ */ n("svg", { className: e, fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ n("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z" }) });
|
|
1114
|
+
}
|
|
1115
|
+
const $e = {
|
|
1116
|
+
small: "Klein",
|
|
1117
|
+
medium: "Middel",
|
|
1118
|
+
large: "Groot",
|
|
1119
|
+
fullscreen: "Volledig scherm"
|
|
1120
|
+
};
|
|
1121
|
+
function Te({ size: e, onCycleSize: s, onPopout: t, onClear: a }) {
|
|
1122
|
+
const [r, o] = y(!1), i = P(null);
|
|
1123
|
+
k(() => {
|
|
1124
|
+
if (!r) return;
|
|
1125
|
+
const c = (f) => {
|
|
1126
|
+
i.current && !i.current.contains(f.target) && o(!1);
|
|
1127
|
+
}, l = setTimeout(() => {
|
|
1128
|
+
document.addEventListener("click", c);
|
|
1129
|
+
}, 0);
|
|
1130
|
+
return () => {
|
|
1131
|
+
clearTimeout(l), document.removeEventListener("click", c);
|
|
1132
|
+
};
|
|
1133
|
+
}, [r]), k(() => {
|
|
1134
|
+
if (!r) return;
|
|
1135
|
+
const c = (l) => {
|
|
1136
|
+
l.key === "Escape" && o(!1);
|
|
1137
|
+
};
|
|
1138
|
+
return document.addEventListener("keydown", c), () => document.removeEventListener("keydown", c);
|
|
1139
|
+
}, [r]);
|
|
1140
|
+
const u = (c) => {
|
|
1141
|
+
c(), o(!1);
|
|
1142
|
+
};
|
|
1143
|
+
return /* @__PURE__ */ d("div", { className: "gcw-header-menu", ref: i, children: [
|
|
1144
|
+
/* @__PURE__ */ n(
|
|
1145
|
+
"button",
|
|
1146
|
+
{
|
|
1147
|
+
onClick: () => o(!r),
|
|
1148
|
+
className: "gcw-header__btn",
|
|
1149
|
+
title: "Menu",
|
|
1150
|
+
"aria-expanded": r,
|
|
1151
|
+
"aria-haspopup": "true",
|
|
1152
|
+
children: /* @__PURE__ */ d("svg", { className: "gcw-header__btn-icon", fill: "currentColor", viewBox: "0 0 24 24", children: [
|
|
1153
|
+
/* @__PURE__ */ n("circle", { cx: "12", cy: "5", r: "2" }),
|
|
1154
|
+
/* @__PURE__ */ n("circle", { cx: "12", cy: "12", r: "2" }),
|
|
1155
|
+
/* @__PURE__ */ n("circle", { cx: "12", cy: "19", r: "2" })
|
|
1156
|
+
] })
|
|
1157
|
+
}
|
|
1158
|
+
),
|
|
1159
|
+
r && /* @__PURE__ */ d("div", { className: "gcw-header-menu__dropdown", role: "menu", children: [
|
|
1160
|
+
/* @__PURE__ */ d(
|
|
1161
|
+
"button",
|
|
1162
|
+
{
|
|
1163
|
+
className: "gcw-header-menu__item",
|
|
1164
|
+
onClick: () => u(s),
|
|
1165
|
+
role: "menuitem",
|
|
1166
|
+
children: [
|
|
1167
|
+
/* @__PURE__ */ n(Ce, { size: e, className: "gcw-header-menu__icon" }),
|
|
1168
|
+
/* @__PURE__ */ d("span", { children: [
|
|
1169
|
+
"Grootte: ",
|
|
1170
|
+
$e[e]
|
|
1171
|
+
] })
|
|
1172
|
+
]
|
|
1173
|
+
}
|
|
1174
|
+
),
|
|
1175
|
+
/* @__PURE__ */ d(
|
|
1176
|
+
"button",
|
|
1177
|
+
{
|
|
1178
|
+
className: "gcw-header-menu__item",
|
|
1179
|
+
onClick: () => u(t),
|
|
1180
|
+
role: "menuitem",
|
|
1181
|
+
children: [
|
|
1182
|
+
/* @__PURE__ */ n(Se, { className: "gcw-header-menu__icon" }),
|
|
1183
|
+
/* @__PURE__ */ n("span", { children: "Nieuw venster" })
|
|
1184
|
+
]
|
|
1185
|
+
}
|
|
1186
|
+
),
|
|
1187
|
+
/* @__PURE__ */ n("div", { className: "gcw-header-menu__divider" }),
|
|
1188
|
+
/* @__PURE__ */ d(
|
|
1189
|
+
"button",
|
|
1190
|
+
{
|
|
1191
|
+
className: "gcw-header-menu__item gcw-header-menu__item--danger",
|
|
1192
|
+
onClick: () => u(a),
|
|
1193
|
+
role: "menuitem",
|
|
1194
|
+
children: [
|
|
1195
|
+
/* @__PURE__ */ n(Le, { className: "gcw-header-menu__icon" }),
|
|
1196
|
+
/* @__PURE__ */ n("span", { children: "Geschiedenis wissen" })
|
|
1197
|
+
]
|
|
1198
|
+
}
|
|
1199
|
+
)
|
|
1200
|
+
] })
|
|
1201
|
+
] });
|
|
1167
1202
|
}
|
|
1168
1203
|
const je = {
|
|
1169
1204
|
small: "gcw-window--small",
|
|
@@ -1173,247 +1208,232 @@ const je = {
|
|
|
1173
1208
|
};
|
|
1174
1209
|
function Be({
|
|
1175
1210
|
title: e,
|
|
1176
|
-
subtitle:
|
|
1177
|
-
placeholder:
|
|
1211
|
+
subtitle: s,
|
|
1212
|
+
placeholder: t,
|
|
1178
1213
|
messages: a,
|
|
1179
1214
|
isLoading: r,
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1215
|
+
isLoadingSession: o = !1,
|
|
1216
|
+
onSendMessage: i,
|
|
1217
|
+
onClose: u,
|
|
1218
|
+
onClear: c,
|
|
1219
|
+
onSizeChange: l,
|
|
1220
|
+
onPopout: f,
|
|
1221
|
+
primaryColor: x,
|
|
1222
|
+
size: _
|
|
1187
1223
|
}) {
|
|
1188
|
-
const
|
|
1189
|
-
const
|
|
1190
|
-
p
|
|
1224
|
+
const E = () => {
|
|
1225
|
+
const p = ["small", "medium", "large", "fullscreen"], v = (p.indexOf(_) + 1) % p.length;
|
|
1226
|
+
l(p[v]);
|
|
1191
1227
|
};
|
|
1192
|
-
return /* @__PURE__ */
|
|
1193
|
-
/* @__PURE__ */
|
|
1194
|
-
/* @__PURE__ */
|
|
1195
|
-
/* @__PURE__ */
|
|
1196
|
-
/* @__PURE__ */
|
|
1197
|
-
/* @__PURE__ */
|
|
1198
|
-
/* @__PURE__ */
|
|
1228
|
+
return /* @__PURE__ */ d("div", { className: `gcw-window ${je[_]}`, children: [
|
|
1229
|
+
/* @__PURE__ */ d("div", { className: "gcw-header", style: { backgroundColor: x }, children: [
|
|
1230
|
+
/* @__PURE__ */ d("div", { className: "gcw-header__left", children: [
|
|
1231
|
+
/* @__PURE__ */ n("div", { className: "gcw-header__avatar", children: /* @__PURE__ */ n(Ee, { className: "gcw-header__avatar-icon" }) }),
|
|
1232
|
+
/* @__PURE__ */ d("div", { className: "gcw-header__info", children: [
|
|
1233
|
+
/* @__PURE__ */ n("h3", { className: "gcw-header__title", children: e }),
|
|
1234
|
+
/* @__PURE__ */ n("p", { className: "gcw-header__subtitle", children: s })
|
|
1199
1235
|
] })
|
|
1200
1236
|
] }),
|
|
1201
|
-
/* @__PURE__ */
|
|
1202
|
-
/* @__PURE__ */
|
|
1203
|
-
|
|
1237
|
+
/* @__PURE__ */ d("div", { className: "gcw-header__actions", children: [
|
|
1238
|
+
/* @__PURE__ */ n(
|
|
1239
|
+
Te,
|
|
1204
1240
|
{
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1241
|
+
size: _,
|
|
1242
|
+
onCycleSize: E,
|
|
1243
|
+
onPopout: f,
|
|
1244
|
+
onClear: c
|
|
1209
1245
|
}
|
|
1210
1246
|
),
|
|
1211
|
-
/* @__PURE__ */
|
|
1212
|
-
"button",
|
|
1213
|
-
{
|
|
1214
|
-
onClick: l,
|
|
1215
|
-
className: "gcw-header__btn",
|
|
1216
|
-
title: "Open in new window",
|
|
1217
|
-
children: /* @__PURE__ */ t(Le, { className: "gcw-header__btn-icon" })
|
|
1218
|
-
}
|
|
1219
|
-
),
|
|
1220
|
-
/* @__PURE__ */ t(
|
|
1247
|
+
/* @__PURE__ */ n(
|
|
1221
1248
|
"button",
|
|
1222
1249
|
{
|
|
1223
1250
|
onClick: u,
|
|
1224
1251
|
className: "gcw-header__btn",
|
|
1225
|
-
title: "Verwijder chatgeschiedenis",
|
|
1226
|
-
children: /* @__PURE__ */ t($e, { className: "gcw-header__btn-icon" })
|
|
1227
|
-
}
|
|
1228
|
-
),
|
|
1229
|
-
/* @__PURE__ */ t(
|
|
1230
|
-
"button",
|
|
1231
|
-
{
|
|
1232
|
-
onClick: i,
|
|
1233
|
-
className: "gcw-header__btn",
|
|
1234
1252
|
title: "Sluiten",
|
|
1235
|
-
children: /* @__PURE__ */
|
|
1253
|
+
children: /* @__PURE__ */ n(Ne, { className: "gcw-header__btn-icon" })
|
|
1236
1254
|
}
|
|
1237
1255
|
)
|
|
1238
1256
|
] })
|
|
1239
1257
|
] }),
|
|
1240
|
-
/* @__PURE__ */
|
|
1241
|
-
|
|
1258
|
+
/* @__PURE__ */ n(
|
|
1259
|
+
Me,
|
|
1242
1260
|
{
|
|
1243
1261
|
messages: a,
|
|
1244
1262
|
isLoading: r,
|
|
1245
|
-
|
|
1263
|
+
isLoadingSession: o,
|
|
1264
|
+
primaryColor: x
|
|
1246
1265
|
}
|
|
1247
1266
|
),
|
|
1248
|
-
/* @__PURE__ */
|
|
1249
|
-
|
|
1267
|
+
/* @__PURE__ */ n(
|
|
1268
|
+
Ie,
|
|
1250
1269
|
{
|
|
1251
|
-
placeholder:
|
|
1270
|
+
placeholder: t,
|
|
1252
1271
|
isLoading: r,
|
|
1253
|
-
onSendMessage:
|
|
1254
|
-
primaryColor:
|
|
1272
|
+
onSendMessage: i,
|
|
1273
|
+
primaryColor: x
|
|
1255
1274
|
}
|
|
1256
1275
|
)
|
|
1257
1276
|
] });
|
|
1258
1277
|
}
|
|
1259
|
-
function
|
|
1260
|
-
return /* @__PURE__ */
|
|
1278
|
+
function ze({ isOpen: e, onClick: s, primaryColor: t, hasUnread: a, isPoppedOut: r }) {
|
|
1279
|
+
return /* @__PURE__ */ d(
|
|
1261
1280
|
"button",
|
|
1262
1281
|
{
|
|
1263
|
-
onClick:
|
|
1282
|
+
onClick: s,
|
|
1264
1283
|
className: "gcw-toggle",
|
|
1265
|
-
style: { backgroundColor:
|
|
1284
|
+
style: { backgroundColor: t },
|
|
1266
1285
|
title: r ? "Chat is open in een ander venster" : e ? "Sluit chat" : "Open chat",
|
|
1267
1286
|
children: [
|
|
1268
|
-
a && !e && /* @__PURE__ */
|
|
1269
|
-
r && /* @__PURE__ */
|
|
1270
|
-
/* @__PURE__ */
|
|
1287
|
+
a && !e && /* @__PURE__ */ n("span", { className: "gcw-toggle__badge gcw-toggle__badge--unread", children: "!" }),
|
|
1288
|
+
r && /* @__PURE__ */ n("span", { className: "gcw-toggle__badge gcw-toggle__badge--popout" }),
|
|
1289
|
+
/* @__PURE__ */ n("div", { className: "gcw-toggle__icon", children: r ? /* @__PURE__ */ n("svg", { fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ n("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" }) }) : e ? /* @__PURE__ */ n("svg", { fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ n("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) }) : /* @__PURE__ */ n("svg", { fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ n("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z" }) }) })
|
|
1271
1290
|
]
|
|
1272
1291
|
}
|
|
1273
1292
|
);
|
|
1274
1293
|
}
|
|
1275
|
-
|
|
1294
|
+
const De = ["bottom-right", "bottom-left", "top-right", "top-left"];
|
|
1295
|
+
function Pe(e) {
|
|
1296
|
+
return typeof e == "string" && De.includes(e);
|
|
1297
|
+
}
|
|
1298
|
+
function We(e) {
|
|
1299
|
+
if (Pe(e))
|
|
1300
|
+
return { className: `gcw-container--${e}`, style: {} };
|
|
1301
|
+
const s = e, t = {}, a = ["gcw-container--custom"];
|
|
1302
|
+
return s.top != null && (t.top = s.top), s.bottom != null && (t.bottom = s.bottom), s.left != null && (t.left = s.left), s.right != null && (t.right = s.right), s.top != null && s.bottom == null && a.push("gcw-container--flow-down"), s.left != null && s.right == null && a.push("gcw-container--align-left"), { className: a.join(" "), style: t };
|
|
1303
|
+
}
|
|
1304
|
+
function Ae({
|
|
1276
1305
|
apiUrl: e,
|
|
1277
|
-
tenantId:
|
|
1278
|
-
title:
|
|
1306
|
+
tenantId: s,
|
|
1307
|
+
title: t = "Chat Assistent",
|
|
1279
1308
|
subtitle: a = "Hoe kan ik je helpen?",
|
|
1280
1309
|
placeholder: r = "Typ een bericht...",
|
|
1281
1310
|
greeting: o,
|
|
1282
1311
|
primaryColor: i = "#3b82f6",
|
|
1283
1312
|
position: u = "bottom-right",
|
|
1284
|
-
defaultOpen:
|
|
1313
|
+
defaultOpen: c = !1,
|
|
1285
1314
|
defaultSize: l = "medium",
|
|
1286
|
-
headers:
|
|
1287
|
-
onOpen:
|
|
1288
|
-
onClose:
|
|
1289
|
-
onMessageSent:
|
|
1290
|
-
onResponseReceived:
|
|
1315
|
+
headers: f,
|
|
1316
|
+
onOpen: x,
|
|
1317
|
+
onClose: _,
|
|
1318
|
+
onMessageSent: E,
|
|
1319
|
+
onResponseReceived: p
|
|
1291
1320
|
}) {
|
|
1292
|
-
const [
|
|
1321
|
+
const [m, v] = y(c), [j, W] = y(l), [V, $] = y(!1), { messages: h, isLoading: G, isLoadingSession: T, sendMessage: M, clearMessages: I, sessionId: w } = he({
|
|
1293
1322
|
apiUrl: e,
|
|
1294
|
-
tenantId:
|
|
1295
|
-
headers:
|
|
1296
|
-
}), [
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
}, [
|
|
1300
|
-
|
|
1301
|
-
}, [
|
|
1302
|
-
|
|
1323
|
+
tenantId: s,
|
|
1324
|
+
headers: f
|
|
1325
|
+
}), [b, C] = y(() => h.length > 0), [B, g] = y([]);
|
|
1326
|
+
k(() => {
|
|
1327
|
+
m && o && !b && h.length === 0 && C(!0);
|
|
1328
|
+
}, [m, o, b, h.length]), k(() => {
|
|
1329
|
+
h.length > 0 && C(!0);
|
|
1330
|
+
}, [h.length]), k(() => {
|
|
1331
|
+
b && o && h.length === 0 ? g([
|
|
1303
1332
|
{
|
|
1304
1333
|
id: "greeting",
|
|
1305
1334
|
role: "assistant",
|
|
1306
1335
|
content: o,
|
|
1307
1336
|
timestamp: /* @__PURE__ */ new Date()
|
|
1308
1337
|
}
|
|
1309
|
-
]) : o &&
|
|
1338
|
+
]) : o && h.length > 0 ? g([
|
|
1310
1339
|
{
|
|
1311
1340
|
id: "greeting",
|
|
1312
1341
|
role: "assistant",
|
|
1313
1342
|
content: o,
|
|
1314
1343
|
timestamp: /* @__PURE__ */ new Date()
|
|
1315
1344
|
},
|
|
1316
|
-
...
|
|
1317
|
-
]) :
|
|
1318
|
-
}, [
|
|
1319
|
-
const { isPoppedOut:
|
|
1345
|
+
...h
|
|
1346
|
+
]) : g(h);
|
|
1347
|
+
}, [h, b, o]);
|
|
1348
|
+
const { isPoppedOut: L, openPopout: H, focusPopout: q } = ge(
|
|
1320
1349
|
{
|
|
1321
1350
|
apiUrl: e,
|
|
1322
|
-
tenantId:
|
|
1323
|
-
title:
|
|
1351
|
+
tenantId: s,
|
|
1352
|
+
title: t,
|
|
1324
1353
|
subtitle: a,
|
|
1325
1354
|
placeholder: r,
|
|
1326
1355
|
primaryColor: i,
|
|
1327
|
-
sessionId:
|
|
1328
|
-
messages:
|
|
1329
|
-
headers:
|
|
1356
|
+
sessionId: w,
|
|
1357
|
+
messages: B,
|
|
1358
|
+
headers: f
|
|
1330
1359
|
},
|
|
1331
|
-
|
|
1360
|
+
j,
|
|
1332
1361
|
() => {
|
|
1333
1362
|
}
|
|
1334
1363
|
);
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
$(w.some((N) => N.role === "assistant"));
|
|
1347
|
-
return;
|
|
1348
|
-
}
|
|
1349
|
-
const U = w.findIndex((N) => N.id === M);
|
|
1350
|
-
if (U === -1) {
|
|
1351
|
-
$(w.some((N) => N.role === "assistant"));
|
|
1352
|
-
return;
|
|
1353
|
-
}
|
|
1354
|
-
const ae = w.slice(U + 1).some((N) => N.role === "assistant");
|
|
1355
|
-
$(ae);
|
|
1364
|
+
k(() => {
|
|
1365
|
+
const S = h.filter((N) => N.role === "assistant").length;
|
|
1366
|
+
if (S === 0) {
|
|
1367
|
+
$(!1);
|
|
1368
|
+
return;
|
|
1369
|
+
}
|
|
1370
|
+
if (m || L)
|
|
1371
|
+
J(S, s), $(!1);
|
|
1372
|
+
else {
|
|
1373
|
+
const N = pe(s);
|
|
1374
|
+
$(S > N);
|
|
1356
1375
|
}
|
|
1357
|
-
}, [
|
|
1358
|
-
const
|
|
1359
|
-
if (
|
|
1360
|
-
|
|
1376
|
+
}, [m, L, h, s]);
|
|
1377
|
+
const Y = () => {
|
|
1378
|
+
if (L) {
|
|
1379
|
+
q();
|
|
1361
1380
|
return;
|
|
1362
1381
|
}
|
|
1363
|
-
const
|
|
1364
|
-
if (
|
|
1365
|
-
|
|
1366
|
-
const
|
|
1367
|
-
|
|
1382
|
+
const S = !m;
|
|
1383
|
+
if (v(S), S) {
|
|
1384
|
+
x == null || x();
|
|
1385
|
+
const N = h.filter((oe) => oe.role === "assistant").length;
|
|
1386
|
+
N > 0 && J(N, s), $(!1);
|
|
1368
1387
|
} else
|
|
1369
|
-
|
|
1370
|
-
},
|
|
1371
|
-
|
|
1372
|
-
const
|
|
1373
|
-
(
|
|
1374
|
-
},
|
|
1375
|
-
|
|
1376
|
-
},
|
|
1377
|
-
|
|
1378
|
-
},
|
|
1379
|
-
|
|
1380
|
-
},
|
|
1381
|
-
return /* @__PURE__ */
|
|
1382
|
-
/* @__PURE__ */
|
|
1383
|
-
|
|
1388
|
+
_ == null || _();
|
|
1389
|
+
}, Q = async (S) => {
|
|
1390
|
+
E == null || E(S), await M(S);
|
|
1391
|
+
const N = h[h.length - 1];
|
|
1392
|
+
(N == null ? void 0 : N.role) === "assistant" && (p == null || p(N.content));
|
|
1393
|
+
}, Z = () => {
|
|
1394
|
+
I(), C(!1), g([]), $(!1), J(0, s);
|
|
1395
|
+
}, ee = (S) => {
|
|
1396
|
+
W(S);
|
|
1397
|
+
}, te = () => {
|
|
1398
|
+
v(!1), H();
|
|
1399
|
+
}, { className: ne, style: se } = We(u);
|
|
1400
|
+
return /* @__PURE__ */ d("div", { className: `gcw-widget gcw-container ${ne}`, style: se, children: [
|
|
1401
|
+
/* @__PURE__ */ n(
|
|
1402
|
+
ze,
|
|
1384
1403
|
{
|
|
1385
|
-
isOpen:
|
|
1386
|
-
onClick:
|
|
1404
|
+
isOpen: m,
|
|
1405
|
+
onClick: Y,
|
|
1387
1406
|
primaryColor: i,
|
|
1388
|
-
hasUnread:
|
|
1389
|
-
isPoppedOut:
|
|
1407
|
+
hasUnread: V && !m && !L,
|
|
1408
|
+
isPoppedOut: L
|
|
1390
1409
|
}
|
|
1391
1410
|
),
|
|
1392
|
-
|
|
1411
|
+
m && !L && /* @__PURE__ */ n(
|
|
1393
1412
|
Be,
|
|
1394
1413
|
{
|
|
1395
|
-
title:
|
|
1414
|
+
title: t,
|
|
1396
1415
|
subtitle: a,
|
|
1397
1416
|
placeholder: r,
|
|
1398
|
-
messages:
|
|
1399
|
-
isLoading:
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1417
|
+
messages: B,
|
|
1418
|
+
isLoading: G,
|
|
1419
|
+
isLoadingSession: T,
|
|
1420
|
+
onSendMessage: Q,
|
|
1421
|
+
onClose: Y,
|
|
1422
|
+
onClear: Z,
|
|
1423
|
+
onSizeChange: ee,
|
|
1424
|
+
onPopout: te,
|
|
1405
1425
|
primaryColor: i,
|
|
1406
|
-
size:
|
|
1426
|
+
size: j
|
|
1407
1427
|
}
|
|
1408
1428
|
)
|
|
1409
1429
|
] });
|
|
1410
1430
|
}
|
|
1411
1431
|
export {
|
|
1412
|
-
|
|
1413
|
-
|
|
1432
|
+
xe as ChatBubble,
|
|
1433
|
+
Ae as ChatWidget,
|
|
1414
1434
|
Be as ChatWindow,
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1435
|
+
Ie as MessageInput,
|
|
1436
|
+
Me as MessageList,
|
|
1437
|
+
ze as ToggleButton,
|
|
1438
|
+
he as useChat
|
|
1419
1439
|
};
|