@useknest/widget-react 0.1.0-beta.16 → 0.1.0-beta.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ChatWidget.d.ts.map +1 -1
- package/dist/index.js +242 -211
- package/package.json +2 -2
package/dist/ChatWidget.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatWidget.d.ts","sourceRoot":"","sources":["../src/ChatWidget.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ChatWidget.d.ts","sourceRoot":"","sources":["../src/ChatWidget.tsx"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAMX,UAAU,EACV,UAAU,EACV,MAAM,uBAAuB,CAAC;AAK/B,4EAA4E;AAC5E,MAAM,WAAW,cAAc;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sBAAsB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED,MAAM,WAAW,eAAe;IAC/B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,qGAAqG;IACrG,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,uEAAuE;IACvE,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,+FAA+F;IAC/F,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,4EAA4E;IAC5E,SAAS,CAAC,EAAE,cAAc,CAAC;CAC3B;AAED,wBAAgB,UAAU,CAAC,EAC1B,iBAAiB,EACjB,IAAe,EACf,WAAmB,EACnB,IAAI,EACJ,SAAS,EACT,EAAE,eAAe,2CAgmBjB"}
|
package/dist/index.js
CHANGED
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".knest-chat-card{display:flex;flex-direction:column;height:100%;background:#fff;color:#374151;border-radius:1rem;box-shadow:0 10px 15px -3px #0000001a;overflow:hidden;font-family:system-ui,-apple-system,sans-serif}.knest-loading-container{display:flex;align-items:center;justify-content:center;height:100%;background:linear-gradient(135deg,#fdfbf7,#fff)}.knest-loading-content{display:flex;flex-direction:column;align-items:center;gap:1.5rem}.knest-spinner-ring{width:3rem;height:3rem;border:3px solid #f3f4f6;border-top-color:#3b82f6;border-radius:50%;animation:knest-spin .8s linear infinite}@keyframes knest-spin{to{transform:rotate(360deg)}}.knest-loading-text{font-size:.875rem;font-weight:500;color:#6b7280;margin:0}.knest-error-container{display:flex;align-items:center;justify-content:center;height:100%;background:linear-gradient(135deg,#fef2f2,#fff);padding:2rem}.knest-error-content{text-align:center;max-width:300px}.knest-error-text{font-size:.875rem;color:#991b1b;margin:0;line-height:1.5}.knest-header{border-bottom:1px solid #f3f4f6;padding:1rem}.knest-header-content{display:flex;align-items:center;gap:.75rem}.knest-avatar-img{width:2rem;height:2rem;object-fit:cover;border-radius:.25rem}.knest-header h2{font-size:1.125rem;font-weight:600;color:#111827;margin:0 0 .25rem}.knest-badge{display:inline-block;padding:.25rem .5rem;border-radius:9999px;font-size:.75rem;font-weight:500;color:#fff}.knest-messages-container{flex:1;overflow-y:auto}.knest-separator{margin:0 1.5rem;border-bottom:1px solid #e5e7eb}.knest-message-wrapper{display:flex;flex-direction:column}.knest-message{display:flex;gap:1rem;padding:1.25rem 1.5rem;align-items:center}.knest-message-avatar{display:flex;align-items:center;justify-content:center;width:2rem;height:2rem;flex-shrink:0}.knest-message-avatar .knest-avatar-img{width:100%;height:100%;border-radius:.25rem;object-fit:cover}.knest-user-avatar{width:2rem;height:2rem;border-radius:.25rem;display:flex;align-items:center;justify-content:center;color:#fff;font-size:.875rem;font-weight:500}.knest-message-content{flex:1;min-width:0}.knest-message-content p{margin:0 0 .5rem;font-size:.875rem;line-height:1.625;color:inherit;word-wrap:break-word}.knest-message-content p:last-child{margin-bottom:0}.knest-message-content code{background-color:#f3f4f6;padding:.125rem .375rem;border-radius:.25rem;font-family:ui-monospace,monospace;font-size:.8125rem;color:#ef4444}.knest-message-content pre{background-color:#1f2937;color:#f9fafb;padding:12px;border-radius:6px;overflow-x:auto;margin:8px 0}.knest-message-content pre code{background-color:transparent;padding:0;color:inherit;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;font-size:.8125rem;line-height:1.5}.knest-message-content .token.keyword,.knest-message-content .token.builtin,.knest-message-content .token.tag{color:#ff7b72}.knest-message-content .token.string,.knest-message-content .token.attr-value{color:#a5d6ff}.knest-message-content .token.number,.knest-message-content .token.boolean{color:#79c0ff}.knest-message-content .token.function,.knest-message-content .token.class-name{color:#d2a8ff}.knest-message-content .token.comment{color:#8b949e;font-style:italic}.knest-message-content .token.variable,.knest-message-content .token.property{color:#ffa657}.knest-message-content .token.operator,.knest-message-content .token.punctuation{color:#c9d1d9}.knest-message-content a{color:inherit;text-decoration:underline}.knest-message-content ul,.knest-message-content ol{margin:8px 0;padding-left:24px}.knest-message-content li{margin:4px 0;color:inherit}.knest-message-content strong{font-weight:600;color:inherit}.knest-message-content em{font-style:italic}.knest-loading{display:flex;gap:.25rem;align-items:center}.knest-dot{width:.5rem;height:.5rem;background:#9ca3af;border-radius:50%;animation:knest-bounce 1.4s infinite ease-in-out both}.knest-dot:nth-child(2){animation-delay:.16s}.knest-dot:nth-child(3){animation-delay:.32s}@keyframes knest-bounce{0%,80%,to{transform:scale(0)}40%{transform:scale(1)}}.knest-sources{margin-top:.75rem}.knest-sources-label{font-size:.75rem;font-weight:500;color:#6b7280;margin-bottom:.5rem}.knest-source-item{display:flex;gap:.5rem;padding:.5rem .75rem;margin-bottom:.25rem;border:1px solid #e5e7eb;border-radius:.375rem;background:#f9fafb;text-decoration:none;transition:all .15s}.knest-source-item:hover{border-color:#d1d5db;background:#f3f4f6}.knest-source-icon{width:1rem;height:1rem;color:#6b7280;flex-shrink:0}.knest-source-text{flex:1;min-width:0}.knest-source-breadcrumb{font-size:.75rem;color:#6b7280;margin-bottom:.125rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.knest-source-title{font-size:.875rem;font-weight:500;color:#374151;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.knest-examples{border-top:1px solid #e5e7eb;padding:1.25rem 1.5rem}.knest-examples h3{font-size:.75rem;font-weight:600;text-transform:uppercase;letter-spacing:.05em;color:#6b7280;margin:0 0 1rem}.knest-example-btn{width:100%;padding:.75rem;margin-bottom:.75rem;border:1px solid #e5e7eb;border-radius:.5rem;background:#fff;text-align:left;font-size:.875rem;color:#374151;cursor:pointer;transition:background .15s}.knest-example-btn:hover{background:#f9fafb}.knest-presence-caption{display:flex;align-items:center;gap:.375rem;font-size:.75rem;color:#6b7280;margin:0 0 .375rem}.knest-online-dot{display:inline-block;width:8px;height:8px;border-radius:50%;background:#22c55e;flex-shrink:0}.knest-human-takeover-caption{font-size:.75rem;color:#9ca3af;text-align:center;margin:.1875rem 0 .75rem}.knest-input-section{border-top:1px solid #f3f4f6;padding:1rem}.knest-input-wrapper{display:flex;align-items:center;gap:.5rem}.knest-input-field{flex:1;padding:.75rem 1rem;border:1px solid #e5e7eb;border-radius:.5rem;background:#f9fafb;font-size:.875rem;color:#374151;outline:none}.knest-input-field:focus{background:#fff;border-color:#d1d5db}.knest-input-field:disabled{opacity:.5}.knest-attach-btn{width:2.5rem;height:2.5rem;display:flex;align-items:center;justify-content:center;border:none;border-radius:.5rem;background:#e5e7eb;color:#6b7280;cursor:pointer;transition:background .15s;flex-shrink:0}.knest-attach-btn:hover:not(:disabled){background:#d1d5db}.knest-attach-btn:disabled{opacity:.4;cursor:not-allowed}.knest-attach-icon{width:1rem;height:1rem}.knest-file-preview{display:flex;flex-wrap:wrap;gap:.375rem;margin-bottom:.5rem}.knest-file-chip{display:inline-flex;align-items:center;gap:.25rem;padding:.25rem .5rem;background:#f3f4f6;border:1px solid #e5e7eb;border-radius:9999px;font-size:.75rem;color:#374151;max-width:160px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.knest-chip-remove{background:none;border:none;padding:0;font-size:1rem;line-height:1;color:#9ca3af;cursor:pointer;flex-shrink:0}.knest-chip-remove:hover{color:#374151}.knest-attach-error{font-size:.75rem;color:#dc2626;margin:0 0 .375rem}.knest-send-btn{width:2.5rem;height:2.5rem;display:flex;align-items:center;justify-content:center;border:none;border-radius:.5rem;background:#e5e7eb;color:#6b7280;cursor:pointer;transition:background .15s}.knest-send-btn:hover:not(:disabled){background:#d1d5db}.knest-send-btn:disabled{opacity:.5;cursor:not-allowed}.knest-send-icon{width:1rem;height:1rem}.knest-attachments{display:flex;flex-direction:column;gap:.5rem;margin-top:.5rem}.knest-attachment-image-link{display:inline-block}.knest-attachment-image{max-width:240px;border-radius:.5rem;display:block}.knest-attachment-file{display:inline-flex;align-items:center;gap:.375rem;padding:.375rem .625rem;border:1px solid #e5e7eb;border-radius:9999px;background:#f9fafb;text-decoration:none;font-size:.8125rem;color:#374151;transition:background .15s}.knest-attachment-file:hover:not(.knest-attachment-disabled){background:#f3f4f6}.knest-attachment-disabled{opacity:.5;pointer-events:none}.knest-attachment-file-icon{width:.875rem;height:.875rem;color:#6b7280;flex-shrink:0}.knest-attachment-file-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:160px}.knest-attachment-file-size{color:#9ca3af;flex-shrink:0}.knest-reset-row{display:flex;justify-content:center;margin-top:.5rem}.knest-reset-btn{background:none;border:none;padding:0;font-size:.75rem;color:#9ca3af;cursor:pointer;transition:color .15s}.knest-reset-btn:hover{color:#6b7280}.knest-footer{margin-top:.75rem;display:flex;justify-content:center}.knest-powered-by{display:flex;align-items:center;gap:.125rem;font-size:.75rem;color:#6b7280;text-decoration:none;transition:color .15s}.knest-powered-by:hover{color:#374151;text-decoration:underline}.knest-bubble-container{position:fixed;bottom:24px;right:24px;z-index:9999;display:flex;flex-direction:column;align-items:flex-end;gap:16px;font-family:system-ui,-apple-system,sans-serif}.knest-bubble-button{width:56px;height:56px;border-radius:50%;border:none;color:#fff;cursor:pointer;box-shadow:0 4px 12px #00000026;display:flex;align-items:center;justify-content:center;transition:transform .2s,box-shadow .2s}.knest-bubble-button:hover{transform:scale(1.05);box-shadow:0 6px 16px #0003}.knest-bubble-spinner{animation:knest-spin 1s linear infinite}.knest-bubble-panel{width:380px;height:520px;max-width:calc(100vw - 48px);max-height:calc(100vh - 100px);border-radius:1rem;border:1px solid rgba(0,0,0,.1);box-shadow:0 10px 15px -3px #0000001a;overflow:hidden}.knest-bubble-panel .knest-chat-card{height:100%}@media (max-width: 440px){.knest-bubble-container{bottom:16px;right:16px}.knest-bubble-panel{width:calc(100vw - 32px);height:calc(100vh - 100px)}}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".knest-chat-card{display:flex;flex-direction:column;height:100%;background:#fff;color:#374151;border-radius:1rem;box-shadow:0 10px 15px -3px #0000001a;overflow:hidden;font-family:system-ui,-apple-system,sans-serif}.knest-loading-container{display:flex;align-items:center;justify-content:center;height:100%;background:linear-gradient(135deg,#fdfbf7,#fff)}.knest-loading-content{display:flex;flex-direction:column;align-items:center;gap:1.5rem}.knest-spinner-ring{width:3rem;height:3rem;border:3px solid #f3f4f6;border-top-color:#3b82f6;border-radius:50%;animation:knest-spin .8s linear infinite}@keyframes knest-spin{to{transform:rotate(360deg)}}.knest-loading-text{font-size:.875rem;font-weight:500;color:#6b7280;margin:0}.knest-error-container{display:flex;align-items:center;justify-content:center;height:100%;background:linear-gradient(135deg,#fef2f2,#fff);padding:2rem}.knest-error-content{text-align:center;max-width:300px}.knest-error-text{font-size:.875rem;color:#991b1b;margin:0;line-height:1.5}.knest-header{border-bottom:1px solid #f3f4f6;padding:1rem}.knest-header-content{display:flex;align-items:center;gap:.75rem}.knest-avatar-img{width:2rem;height:2rem;object-fit:cover;border-radius:.25rem}.knest-header h2{font-size:1.125rem;font-weight:600;color:#111827;margin:0 0 .25rem}.knest-badge{display:inline-block;padding:.25rem .5rem;border-radius:9999px;font-size:.75rem;font-weight:500;color:#fff}.knest-messages-container{flex:1;overflow-y:auto}.knest-separator{margin:0 1.5rem;border-bottom:1px solid #e5e7eb}.knest-message-wrapper{display:flex;flex-direction:column}.knest-message{display:flex;gap:1rem;padding:1.25rem 1.5rem;align-items:center}.knest-message-avatar{display:flex;align-items:center;justify-content:center;width:2rem;height:2rem;flex-shrink:0}.knest-message-avatar .knest-avatar-img{width:100%;height:100%;border-radius:.25rem;object-fit:cover}.knest-user-avatar{width:2rem;height:2rem;border-radius:.25rem;display:flex;align-items:center;justify-content:center;color:#fff;font-size:.875rem;font-weight:500}.knest-message-content{flex:1;min-width:0}.knest-message-content p{margin:0 0 .5rem;font-size:.875rem;line-height:1.625;color:inherit;word-wrap:break-word}.knest-message-content p:last-child{margin-bottom:0}.knest-message-content code{background-color:#f3f4f6;padding:.125rem .375rem;border-radius:.25rem;font-family:ui-monospace,monospace;font-size:.8125rem;color:#ef4444}.knest-message-content pre{background-color:#1f2937;color:#f9fafb;padding:12px;border-radius:6px;overflow-x:auto;margin:8px 0}.knest-message-content pre code{background-color:transparent;padding:0;color:inherit;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;font-size:.8125rem;line-height:1.5}.knest-message-content .token.keyword,.knest-message-content .token.builtin,.knest-message-content .token.tag{color:#ff7b72}.knest-message-content .token.string,.knest-message-content .token.attr-value{color:#a5d6ff}.knest-message-content .token.number,.knest-message-content .token.boolean{color:#79c0ff}.knest-message-content .token.function,.knest-message-content .token.class-name{color:#d2a8ff}.knest-message-content .token.comment{color:#8b949e;font-style:italic}.knest-message-content .token.variable,.knest-message-content .token.property{color:#ffa657}.knest-message-content .token.operator,.knest-message-content .token.punctuation{color:#c9d1d9}.knest-message-content a{color:inherit;text-decoration:underline}.knest-message-content ul,.knest-message-content ol{margin:8px 0;padding-left:24px}.knest-message-content li{margin:4px 0;color:inherit}.knest-message-content strong{font-weight:600;color:inherit}.knest-message-content em{font-style:italic}.knest-loading{display:flex;gap:.25rem;align-items:center}.knest-dot{width:.5rem;height:.5rem;background:#9ca3af;border-radius:50%;animation:knest-bounce 1.4s infinite ease-in-out both}.knest-dot:nth-child(2){animation-delay:.16s}.knest-dot:nth-child(3){animation-delay:.32s}@keyframes knest-bounce{0%,80%,to{transform:scale(0)}40%{transform:scale(1)}}.knest-sources{margin-top:.75rem}.knest-sources-label{font-size:.75rem;font-weight:500;color:#6b7280;margin-bottom:.5rem}.knest-source-item{display:flex;gap:.5rem;padding:.5rem .75rem;margin-bottom:.25rem;border:1px solid #e5e7eb;border-radius:.375rem;background:#f9fafb;text-decoration:none;transition:all .15s}.knest-source-item:hover{border-color:#d1d5db;background:#f3f4f6}.knest-source-icon{width:1rem;height:1rem;color:#6b7280;flex-shrink:0}.knest-source-text{flex:1;min-width:0}.knest-source-breadcrumb{font-size:.75rem;color:#6b7280;margin-bottom:.125rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.knest-source-title{font-size:.875rem;font-weight:500;color:#374151;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.knest-examples{border-top:1px solid #e5e7eb;padding:1.25rem 1.5rem}.knest-examples h3{font-size:.75rem;font-weight:600;text-transform:uppercase;letter-spacing:.05em;color:#6b7280;margin:0 0 1rem}.knest-example-btn{width:100%;padding:.75rem;margin-bottom:.75rem;border:1px solid #e5e7eb;border-radius:.5rem;background:#fff;text-align:left;font-size:.875rem;color:#374151;cursor:pointer;transition:background .15s}.knest-example-btn:hover{background:#f9fafb}.knest-presence-caption{display:flex;align-items:center;gap:.375rem;font-size:.75rem;color:#6b7280;margin:0 0 .375rem}.knest-online-dot{display:inline-block;width:8px;height:8px;border-radius:50%;background:#22c55e;flex-shrink:0}.knest-human-takeover-caption{font-size:.75rem;color:#9ca3af;text-align:center;margin:.1875rem 0 .75rem}.knest-input-section{border-top:1px solid #f3f4f6;padding:1rem}.knest-input-wrapper{display:flex;align-items:center;gap:.5rem}.knest-input-field{flex:1;padding:.75rem 1rem;border:1px solid #e5e7eb;border-radius:.5rem;background:#f9fafb;font-size:.875rem;color:#374151;outline:none}.knest-input-field:focus{background:#fff;border-color:#d1d5db}.knest-input-field:disabled{opacity:.5}.knest-attach-btn{width:2.5rem;height:2.5rem;display:flex;align-items:center;justify-content:center;border:none;border-radius:.5rem;background:#e5e7eb;color:#6b7280;cursor:pointer;transition:background .15s;flex-shrink:0}.knest-attach-btn:hover:not(:disabled){background:#d1d5db}.knest-attach-btn:disabled{opacity:.4;cursor:not-allowed}.knest-attach-icon{width:1rem;height:1rem}.knest-file-preview{display:flex;flex-wrap:wrap;gap:.375rem;margin-bottom:.5rem}.knest-file-chip{display:inline-flex;align-items:center;gap:.25rem;padding:.25rem .5rem;background:#f3f4f6;border:1px solid #e5e7eb;border-radius:9999px;font-size:.75rem;color:#374151;max-width:160px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.knest-chip-remove{background:none;border:none;padding:0;font-size:1rem;line-height:1;color:#9ca3af;cursor:pointer;flex-shrink:0}.knest-chip-remove:hover{color:#374151}.knest-attach-error{font-size:.75rem;color:#dc2626;margin:0 0 .375rem}.knest-send-btn{width:2.5rem;height:2.5rem;display:flex;align-items:center;justify-content:center;border:none;border-radius:.5rem;background:#e5e7eb;color:#6b7280;cursor:pointer;transition:background .15s}.knest-send-btn:hover:not(:disabled){background:#d1d5db}.knest-send-btn:disabled{opacity:.5;cursor:not-allowed}.knest-send-icon{width:1rem;height:1rem}.knest-attachments{display:flex;flex-direction:column;gap:.5rem;margin-top:.5rem}.knest-attachment-image-link{display:inline-block}.knest-attachment-image{max-width:240px;border-radius:.5rem;display:block}.knest-attachment-file{display:inline-flex;align-items:center;gap:.375rem;padding:.375rem .625rem;border:1px solid #e5e7eb;border-radius:9999px;background:#f9fafb;text-decoration:none;font-size:.8125rem;color:#374151;transition:background .15s}.knest-attachment-file:hover:not(.knest-attachment-disabled){background:#f3f4f6}.knest-attachment-disabled{opacity:.5;pointer-events:none}.knest-attachment-file-icon{width:.875rem;height:.875rem;color:#6b7280;flex-shrink:0}.knest-attachment-file-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:160px}.knest-attachment-file-size{color:#9ca3af;flex-shrink:0}.knest-reset-row{display:flex;justify-content:center;margin-top:.5rem}.knest-reset-btn{background:none;border:none;padding:0;font-size:.75rem;color:#9ca3af;cursor:pointer;transition:color .15s}.knest-reset-btn:hover{color:#6b7280}.knest-footer{margin-top:.75rem;display:flex;justify-content:center}.knest-powered-by{display:flex;align-items:center;gap:.125rem;font-size:.75rem;color:#6b7280;text-decoration:none;transition:color .15s}.knest-powered-by:hover{color:#374151;text-decoration:underline}.knest-bubble-container{position:fixed;bottom:24px;right:24px;z-index:9999;display:flex;flex-direction:column;align-items:flex-end;gap:16px;font-family:system-ui,-apple-system,sans-serif}.knest-bubble-button{width:56px;height:56px;border-radius:50%;border:none;color:#fff;cursor:pointer;box-shadow:0 4px 12px #00000026;display:flex;align-items:center;justify-content:center;transition:transform .2s,box-shadow .2s}.knest-bubble-button:hover{transform:scale(1.05);box-shadow:0 6px 16px #0003}.knest-bubble-spinner{animation:knest-spin 1s linear infinite}.knest-bubble-panel{position:relative;width:380px;height:520px;max-width:calc(100vw - 48px);max-height:calc(100vh - 100px);border-radius:1rem;border:1px solid rgba(0,0,0,.1);box-shadow:0 10px 15px -3px #0000001a;overflow:hidden}.knest-bubble-panel .knest-chat-card{height:100%}.knest-bubble-close-btn{display:none;position:absolute;top:.75rem;right:.75rem;z-index:10;width:2rem;height:2rem;align-items:center;justify-content:center;border:none;border-radius:50%;background:#0000000f;color:#374151;cursor:pointer}.knest-bubble-close-btn:hover{background:#0000001f}@media (max-width: 440px){.knest-bubble-container.knest-bubble-open{inset:0}.knest-bubble-container.knest-bubble-open .knest-bubble-button{display:none}.knest-bubble-panel{width:100%;height:100dvh;max-width:none;max-height:none;border-radius:0;border:none;box-shadow:none;padding-top:env(safe-area-inset-top);padding-bottom:env(safe-area-inset-bottom)}.knest-bubble-close-btn{display:flex}.knest-bubble-panel .knest-messages-container>:first-child{padding-right:2.5rem}}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
|
|
2
2
|
import { jsx as e, jsxs as o } from "react/jsx-runtime";
|
|
3
|
-
import { useState as i, useEffect as
|
|
4
|
-
import { fetchSignedUrl as
|
|
5
|
-
function
|
|
3
|
+
import { useState as i, useEffect as A, useRef as J } from "react";
|
|
4
|
+
import { fetchSignedUrl as me, formatContent as ke, DEFAULT_BRAND_COLOR as ne, isImageType as fe, formatFileSize as ge, DEFAULT_AVATAR_URL as ve, DEFAULT_EXAMPLE_QUESTIONS as pe, initWidgetSentry as Z, PUBLIC_SUPABASE_URL as Ce, PUBLIC_SUPABASE_PUBLISHABLE_KEY as be, initWidgetAuth as Ne, saveChatStateDebounced as Ee, MOBILE_BREAKPOINT_PX as Le, lockBodyScroll as we, unlockBodyScroll as K, subscribeToThread as Me, AUTH_ERROR_MESSAGE as Ae, HUMAN_TAKEOVER_CAPTION as xe, PRESENCE_LABEL_WIDGET as Ue, ACCEPTED_FILE_TYPES_STRING as Se, fetchWidgetConfig as ye, loadChatState as Ie, DEFAULT_WELCOME_MESSAGE as ee, validateAttachment as Pe, MAX_ATTACHMENTS_PER_MESSAGE as Te, uploadAttachment as Be, captureWidgetException as te, streamChatMessage as _e, clearChatState as We } from "@useknest/widget-core";
|
|
5
|
+
function Re({
|
|
6
6
|
message: s,
|
|
7
|
-
isLoading:
|
|
8
|
-
avatarUrl:
|
|
9
|
-
brandColor:
|
|
10
|
-
showAvatar:
|
|
7
|
+
isLoading: _ = !1,
|
|
8
|
+
avatarUrl: W = "/default-avatar.svg",
|
|
9
|
+
brandColor: S = ne,
|
|
10
|
+
showAvatar: k = !0,
|
|
11
11
|
publishableApiKey: v,
|
|
12
|
-
baseUrl:
|
|
12
|
+
baseUrl: x
|
|
13
13
|
}) {
|
|
14
|
-
const [p,
|
|
15
|
-
|
|
14
|
+
const [p, y] = i(!1), [I, R] = i({});
|
|
15
|
+
A(() => {
|
|
16
16
|
if (!s.attachments?.length || !v) return;
|
|
17
17
|
const n = s.attachments.filter(
|
|
18
|
-
(l) => l.storagePath && !l.url && !
|
|
18
|
+
(l) => l.storagePath && !l.url && !I[l.storagePath]
|
|
19
19
|
);
|
|
20
20
|
n.length !== 0 && Promise.all(
|
|
21
21
|
n.map(async (l) => {
|
|
22
|
-
const c = await
|
|
22
|
+
const c = await me({
|
|
23
23
|
publishableApiKey: v,
|
|
24
24
|
storagePath: l.storagePath,
|
|
25
|
-
baseUrl:
|
|
25
|
+
baseUrl: x
|
|
26
26
|
});
|
|
27
27
|
return { storagePath: l.storagePath, url: c };
|
|
28
28
|
})
|
|
29
29
|
).then((l) => {
|
|
30
30
|
const c = {};
|
|
31
|
-
for (const { storagePath: g, url:
|
|
32
|
-
|
|
31
|
+
for (const { storagePath: g, url: w } of l)
|
|
32
|
+
w && (c[g] = w);
|
|
33
33
|
Object.keys(c).length > 0 && R((g) => ({ ...g, ...c }));
|
|
34
34
|
});
|
|
35
|
-
}, [s.attachments, v,
|
|
36
|
-
const
|
|
35
|
+
}, [s.attachments, v, x]);
|
|
36
|
+
const N = (n) => n.url || (n.storagePath ? I[n.storagePath] : void 0), O = () => y(!0), m = s.content ? ke(s.content) : "";
|
|
37
37
|
return /* @__PURE__ */ e("div", { className: "knest-message-wrapper", children: /* @__PURE__ */ o("div", { className: "knest-message", children: [
|
|
38
|
-
|
|
38
|
+
k && /* @__PURE__ */ e("div", { className: "knest-message-avatar", children: s.role === "assistant" ? p ? /* @__PURE__ */ e("div", { className: "knest-user-avatar", style: { backgroundColor: S }, children: "AI" }) : /* @__PURE__ */ e(
|
|
39
39
|
"img",
|
|
40
40
|
{
|
|
41
|
-
src:
|
|
41
|
+
src: W,
|
|
42
42
|
alt: "Avatar",
|
|
43
43
|
className: "knest-avatar-img",
|
|
44
44
|
onError: O
|
|
45
45
|
}
|
|
46
|
-
) : /* @__PURE__ */ e("div", { className: "knest-user-avatar", style: { backgroundColor:
|
|
46
|
+
) : /* @__PURE__ */ e("div", { className: "knest-user-avatar", style: { backgroundColor: S }, children: "U" }) }),
|
|
47
47
|
/* @__PURE__ */ o("div", { className: "knest-message-content", children: [
|
|
48
|
-
!s.content &&
|
|
48
|
+
!s.content && _ && s.role === "assistant" ? /* @__PURE__ */ o("div", { className: "knest-loading", children: [
|
|
49
49
|
/* @__PURE__ */ e("div", { className: "knest-dot" }),
|
|
50
50
|
/* @__PURE__ */ e("div", { className: "knest-dot" }),
|
|
51
51
|
/* @__PURE__ */ e("div", { className: "knest-dot" })
|
|
52
52
|
] }) : /* @__PURE__ */ e("div", { dangerouslySetInnerHTML: { __html: m } }),
|
|
53
53
|
s.attachments && s.attachments.length > 0 && /* @__PURE__ */ e("div", { className: "knest-attachments", children: s.attachments.map((n, l) => {
|
|
54
|
-
const c =
|
|
54
|
+
const c = N(n);
|
|
55
55
|
return fe(n.fileType) ? c ? /* @__PURE__ */ e(
|
|
56
56
|
"a",
|
|
57
57
|
{
|
|
@@ -89,7 +89,7 @@ function _e({
|
|
|
89
89
|
}
|
|
90
90
|
),
|
|
91
91
|
/* @__PURE__ */ e("span", { className: "knest-attachment-file-name", children: n.fileName }),
|
|
92
|
-
/* @__PURE__ */ e("span", { className: "knest-attachment-file-size", children:
|
|
92
|
+
/* @__PURE__ */ e("span", { className: "knest-attachment-file-size", children: ge(n.fileSize) })
|
|
93
93
|
]
|
|
94
94
|
},
|
|
95
95
|
l
|
|
@@ -135,56 +135,59 @@ function _e({
|
|
|
135
135
|
] })
|
|
136
136
|
] }) });
|
|
137
137
|
}
|
|
138
|
-
function
|
|
138
|
+
function Fe({
|
|
139
139
|
publishableApiKey: s,
|
|
140
|
-
mode:
|
|
141
|
-
defaultOpen:
|
|
142
|
-
user:
|
|
143
|
-
_internal:
|
|
140
|
+
mode: _ = "inline",
|
|
141
|
+
defaultOpen: W = !1,
|
|
142
|
+
user: S,
|
|
143
|
+
_internal: k
|
|
144
144
|
}) {
|
|
145
|
-
const [v,
|
|
146
|
-
|
|
147
|
-
typeof requestIdleCallback < "u" ? requestIdleCallback(() =>
|
|
148
|
-
const t =
|
|
145
|
+
const [v, x] = i(null), [p, y] = i(!0), [I, R] = i(null), [N, O] = i(!1), [m, n] = i([]), [l, c] = i(""), [g, w] = i(!1), [u, j] = i(void 0), [E, V] = i(W), [P, T] = i([]), [D, F] = i(!1), [Q, U] = i(null), [se, X] = i(!1), [re, $] = i(!1), z = J(null), q = J(null), ae = v?.avatarUrl || ve, oe = v?.exampleQuestions || pe, H = v?.brandColor || ne;
|
|
146
|
+
A(() => {
|
|
147
|
+
typeof requestIdleCallback < "u" ? requestIdleCallback(() => Z()) : setTimeout(() => Z(), 0);
|
|
148
|
+
const t = k?.supabaseUrl || Ce, a = k?.supabasePublishableKey || be, d = Ne(t, a);
|
|
149
149
|
(async () => {
|
|
150
|
-
const
|
|
150
|
+
const M = await ye(
|
|
151
151
|
s,
|
|
152
|
-
|
|
153
|
-
(
|
|
154
|
-
|
|
152
|
+
k?.baseUrl,
|
|
153
|
+
(B) => {
|
|
154
|
+
x(B);
|
|
155
155
|
}
|
|
156
156
|
);
|
|
157
|
-
if (
|
|
158
|
-
R(
|
|
157
|
+
if (M.error) {
|
|
158
|
+
R(M.error), y(!1);
|
|
159
159
|
return;
|
|
160
160
|
}
|
|
161
|
-
|
|
162
|
-
const
|
|
163
|
-
|
|
161
|
+
x(M.config), y(!1);
|
|
162
|
+
const f = Ie(s);
|
|
163
|
+
f && f.messages.length > 0 ? (n(f.messages), j(f.threadId), c(f.input)) : n([
|
|
164
164
|
{
|
|
165
165
|
role: "assistant",
|
|
166
|
-
content:
|
|
166
|
+
content: M.config?.welcomeMessage || ee
|
|
167
167
|
}
|
|
168
168
|
]);
|
|
169
|
-
const
|
|
170
|
-
|
|
169
|
+
const L = await d;
|
|
170
|
+
L || console.warn("Widget auth initialization failed"), O(L);
|
|
171
171
|
})();
|
|
172
|
-
}, [s,
|
|
172
|
+
}, [s, k]), A(() => {
|
|
173
173
|
m.length > 0 && z.current && z.current.scrollIntoView({ behavior: "smooth" });
|
|
174
|
-
}, [m]),
|
|
175
|
-
m.length <= 1 && !l ||
|
|
174
|
+
}, [m]), A(() => {
|
|
175
|
+
m.length <= 1 && !l || Ee(s, {
|
|
176
176
|
threadId: u,
|
|
177
177
|
messages: m,
|
|
178
178
|
input: l,
|
|
179
179
|
savedAt: Date.now()
|
|
180
180
|
});
|
|
181
|
-
}, [m, u, l, s]),
|
|
182
|
-
|
|
183
|
-
|
|
181
|
+
}, [m, u, l, s]), A(() => {
|
|
182
|
+
const t = window.matchMedia(`(max-width: ${Le}px)`);
|
|
183
|
+
return E && t.matches ? we() : K(), () => K();
|
|
184
|
+
}, [E]), A(() => {
|
|
185
|
+
if (!(!u || !N))
|
|
186
|
+
return Me(
|
|
184
187
|
u,
|
|
185
188
|
(t) => {
|
|
186
189
|
if (t.role !== "human") return;
|
|
187
|
-
const
|
|
190
|
+
const a = t.metadata?.attachments ?? [];
|
|
188
191
|
n(
|
|
189
192
|
(d) => d.some((h) => h.id === t.id) ? d : [
|
|
190
193
|
...d,
|
|
@@ -192,186 +195,186 @@ function Oe({
|
|
|
192
195
|
id: t.id,
|
|
193
196
|
role: "assistant",
|
|
194
197
|
content: t.content,
|
|
195
|
-
...
|
|
198
|
+
...a.length > 0 ? { attachments: a } : {}
|
|
196
199
|
}
|
|
197
200
|
]
|
|
198
201
|
);
|
|
199
202
|
},
|
|
200
|
-
{ role: "visitor", onPresenceChange: (t) =>
|
|
203
|
+
{ role: "visitor", onPresenceChange: (t) => $(t) }
|
|
201
204
|
);
|
|
202
|
-
}, [u,
|
|
205
|
+
}, [u, N]);
|
|
203
206
|
const le = (t) => {
|
|
204
|
-
const
|
|
207
|
+
const a = Array.from(t.target.files || []);
|
|
205
208
|
t.target.value = "", U(null);
|
|
206
|
-
for (const d of
|
|
207
|
-
const h =
|
|
209
|
+
for (const d of a) {
|
|
210
|
+
const h = Pe(d);
|
|
208
211
|
if (h) {
|
|
209
212
|
U(h);
|
|
210
213
|
return;
|
|
211
214
|
}
|
|
212
215
|
}
|
|
213
216
|
T((d) => {
|
|
214
|
-
const h =
|
|
215
|
-
return [...d, ...
|
|
217
|
+
const h = Te - d.length;
|
|
218
|
+
return [...d, ...a.slice(0, h)];
|
|
216
219
|
});
|
|
217
|
-
},
|
|
218
|
-
T((
|
|
220
|
+
}, ce = (t) => {
|
|
221
|
+
T((a) => a.filter((d, h) => h !== t));
|
|
219
222
|
}, G = async (t) => {
|
|
220
|
-
const
|
|
221
|
-
if (!
|
|
222
|
-
const d =
|
|
223
|
-
c(""),
|
|
223
|
+
const a = t ?? l;
|
|
224
|
+
if (!a.trim() || g || !N) return;
|
|
225
|
+
const d = a.trim();
|
|
226
|
+
c(""), w(!0), U(null);
|
|
224
227
|
let h = [];
|
|
225
228
|
if (P.length > 0 && u) {
|
|
226
229
|
F(!0);
|
|
227
230
|
try {
|
|
228
231
|
h = await Promise.all(
|
|
229
232
|
P.map(
|
|
230
|
-
(
|
|
233
|
+
(r) => Be({
|
|
231
234
|
publishableApiKey: s,
|
|
232
235
|
threadId: u,
|
|
233
|
-
file:
|
|
234
|
-
baseUrl:
|
|
236
|
+
file: r,
|
|
237
|
+
baseUrl: k?.baseUrl
|
|
235
238
|
})
|
|
236
239
|
)
|
|
237
240
|
);
|
|
238
|
-
} catch (
|
|
239
|
-
|
|
241
|
+
} catch (r) {
|
|
242
|
+
te(r instanceof Error ? r.message : "Upload failed", {
|
|
240
243
|
threadId: u,
|
|
241
|
-
baseUrl:
|
|
242
|
-
}), U(
|
|
244
|
+
baseUrl: k?.baseUrl
|
|
245
|
+
}), U(r instanceof Error ? r.message : "Upload failed."), w(!1), F(!1);
|
|
243
246
|
return;
|
|
244
247
|
}
|
|
245
248
|
F(!1), T([]);
|
|
246
249
|
}
|
|
247
|
-
const
|
|
248
|
-
n((
|
|
249
|
-
...
|
|
250
|
+
const M = h.length > 0 ? { attachments: h } : void 0;
|
|
251
|
+
n((r) => [
|
|
252
|
+
...r,
|
|
250
253
|
{ role: "user", content: d, ...h.length > 0 ? { attachments: h } : {} }
|
|
251
254
|
]);
|
|
252
|
-
const
|
|
253
|
-
n((
|
|
254
|
-
let
|
|
255
|
-
await
|
|
255
|
+
const f = m.length + 1;
|
|
256
|
+
n((r) => [...r, { role: "assistant", content: "" }]);
|
|
257
|
+
let L = "", B = [];
|
|
258
|
+
await _e({
|
|
256
259
|
publishableApiKey: s,
|
|
257
260
|
content: d,
|
|
258
261
|
threadId: u,
|
|
259
|
-
baseUrl:
|
|
260
|
-
metadata:
|
|
261
|
-
user:
|
|
262
|
+
baseUrl: k?.baseUrl,
|
|
263
|
+
metadata: M,
|
|
264
|
+
user: S,
|
|
262
265
|
callbacks: {
|
|
263
|
-
onInit: (
|
|
264
|
-
u ||
|
|
266
|
+
onInit: (r) => {
|
|
267
|
+
u || j(r);
|
|
265
268
|
},
|
|
266
|
-
onContent: (
|
|
267
|
-
|
|
268
|
-
const
|
|
269
|
-
return
|
|
269
|
+
onContent: (r) => {
|
|
270
|
+
L += r, n((C) => {
|
|
271
|
+
const b = [...C];
|
|
272
|
+
return b[f] = {
|
|
270
273
|
role: "assistant",
|
|
271
|
-
content:
|
|
272
|
-
},
|
|
274
|
+
content: L
|
|
275
|
+
}, b;
|
|
273
276
|
});
|
|
274
277
|
},
|
|
275
|
-
onComplete: (
|
|
276
|
-
|
|
277
|
-
const
|
|
278
|
-
return
|
|
278
|
+
onComplete: (r) => {
|
|
279
|
+
B = r, n((C) => {
|
|
280
|
+
const b = [...C];
|
|
281
|
+
return b[f] = {
|
|
279
282
|
role: "assistant",
|
|
280
|
-
content:
|
|
281
|
-
sources:
|
|
282
|
-
},
|
|
283
|
+
content: L,
|
|
284
|
+
sources: B
|
|
285
|
+
}, b;
|
|
283
286
|
});
|
|
284
287
|
},
|
|
285
|
-
onDone: ({ humanTakeover:
|
|
286
|
-
|
|
287
|
-
...C.slice(0,
|
|
288
|
-
...C.slice(
|
|
288
|
+
onDone: ({ humanTakeover: r }) => {
|
|
289
|
+
X(!!r), r && !L && n((C) => [
|
|
290
|
+
...C.slice(0, f),
|
|
291
|
+
...C.slice(f + 1)
|
|
289
292
|
]);
|
|
290
293
|
},
|
|
291
|
-
onError: (
|
|
292
|
-
|
|
293
|
-
const
|
|
294
|
-
return
|
|
294
|
+
onError: (r) => {
|
|
295
|
+
te(r, { userMessage: d, threadId: u, baseUrl: k?.baseUrl }), n((C) => {
|
|
296
|
+
const b = [...C];
|
|
297
|
+
return b[f] = {
|
|
295
298
|
role: "assistant",
|
|
296
|
-
content: `Error: ${
|
|
297
|
-
},
|
|
299
|
+
content: `Error: ${r}`
|
|
300
|
+
}, b;
|
|
298
301
|
});
|
|
299
302
|
}
|
|
300
303
|
}
|
|
301
|
-
}),
|
|
302
|
-
},
|
|
303
|
-
|
|
304
|
-
{ role: "assistant", content: v?.welcomeMessage ||
|
|
305
|
-
]), c(""), T([]), U(null),
|
|
306
|
-
}, ie = (t) => {
|
|
307
|
-
t.key === "Enter" && !t.shiftKey && (t.preventDefault(), G());
|
|
304
|
+
}), w(!1);
|
|
305
|
+
}, ie = () => {
|
|
306
|
+
We(s), j(void 0), n([
|
|
307
|
+
{ role: "assistant", content: v?.welcomeMessage || ee }
|
|
308
|
+
]), c(""), T([]), U(null), X(!1), $(!1);
|
|
308
309
|
}, de = (t) => {
|
|
310
|
+
t.key === "Enter" && !t.shiftKey && (t.preventDefault(), G());
|
|
311
|
+
}, he = (t) => {
|
|
309
312
|
G(t);
|
|
310
|
-
},
|
|
313
|
+
}, Y = p ? /* @__PURE__ */ e("div", { className: "knest-chat-card", children: /* @__PURE__ */ e("div", { className: "knest-loading-container", children: /* @__PURE__ */ o("div", { className: "knest-loading-content", children: [
|
|
311
314
|
/* @__PURE__ */ e("div", { className: "knest-spinner-ring" }),
|
|
312
315
|
/* @__PURE__ */ e("p", { className: "knest-loading-text", children: "Loading chat..." })
|
|
313
|
-
] }) }) }) :
|
|
316
|
+
] }) }) }) : I === "auth" ? /* @__PURE__ */ e("div", { className: "knest-chat-card", children: /* @__PURE__ */ e("div", { className: "knest-error-container", children: /* @__PURE__ */ e("div", { className: "knest-error-content", children: /* @__PURE__ */ e("p", { className: "knest-error-text", children: Ae }) }) }) }) : /* @__PURE__ */ o("div", { className: "knest-chat-card", children: [
|
|
314
317
|
/* @__PURE__ */ o("div", { className: "knest-messages-container", children: [
|
|
315
|
-
m.map((t,
|
|
318
|
+
m.map((t, a) => /* @__PURE__ */ o("div", { children: [
|
|
316
319
|
/* @__PURE__ */ e(
|
|
317
|
-
|
|
320
|
+
Re,
|
|
318
321
|
{
|
|
319
322
|
message: t,
|
|
320
323
|
isLoading: !t.content && g && t.role === "assistant",
|
|
321
324
|
avatarUrl: ae,
|
|
322
325
|
brandColor: H,
|
|
323
326
|
publishableApiKey: s,
|
|
324
|
-
baseUrl:
|
|
327
|
+
baseUrl: k?.baseUrl
|
|
325
328
|
}
|
|
326
329
|
),
|
|
327
|
-
|
|
328
|
-
] },
|
|
330
|
+
a < m.length - 1 && /* @__PURE__ */ e("div", { className: "knest-separator" })
|
|
331
|
+
] }, a)),
|
|
329
332
|
m.length === 1 && !p && /* @__PURE__ */ o("div", { className: "knest-examples", children: [
|
|
330
333
|
/* @__PURE__ */ e("h3", { children: "Example Questions" }),
|
|
331
|
-
|
|
334
|
+
oe.map((t, a) => /* @__PURE__ */ e(
|
|
332
335
|
"button",
|
|
333
336
|
{
|
|
334
|
-
onClick: () =>
|
|
337
|
+
onClick: () => he(t),
|
|
335
338
|
className: "knest-example-btn",
|
|
336
|
-
style:
|
|
339
|
+
style: a === 0 ? { borderColor: H, borderWidth: "2px" } : {},
|
|
337
340
|
children: t
|
|
338
341
|
},
|
|
339
|
-
|
|
342
|
+
a
|
|
340
343
|
))
|
|
341
344
|
] }),
|
|
342
|
-
|
|
345
|
+
se && /* @__PURE__ */ e("p", { className: "knest-human-takeover-caption", children: xe }),
|
|
343
346
|
/* @__PURE__ */ e("div", { ref: z })
|
|
344
347
|
] }),
|
|
345
348
|
/* @__PURE__ */ o("div", { className: "knest-input-section", children: [
|
|
346
|
-
|
|
349
|
+
re && /* @__PURE__ */ o("p", { className: "knest-presence-caption", children: [
|
|
347
350
|
/* @__PURE__ */ e("span", { className: "knest-online-dot" }),
|
|
348
|
-
|
|
351
|
+
Ue
|
|
349
352
|
] }),
|
|
350
353
|
/* @__PURE__ */ e(
|
|
351
354
|
"input",
|
|
352
355
|
{
|
|
353
|
-
ref:
|
|
356
|
+
ref: q,
|
|
354
357
|
type: "file",
|
|
355
|
-
accept:
|
|
358
|
+
accept: Se,
|
|
356
359
|
multiple: !0,
|
|
357
360
|
style: { display: "none" },
|
|
358
361
|
onChange: le
|
|
359
362
|
}
|
|
360
363
|
),
|
|
361
|
-
P.length > 0 && /* @__PURE__ */ e("div", { className: "knest-file-preview", children: P.map((t,
|
|
364
|
+
P.length > 0 && /* @__PURE__ */ e("div", { className: "knest-file-preview", children: P.map((t, a) => /* @__PURE__ */ o("span", { className: "knest-file-chip", children: [
|
|
362
365
|
t.name,
|
|
363
366
|
/* @__PURE__ */ e(
|
|
364
367
|
"button",
|
|
365
368
|
{
|
|
366
369
|
type: "button",
|
|
367
370
|
className: "knest-chip-remove",
|
|
368
|
-
onClick: () =>
|
|
371
|
+
onClick: () => ce(a),
|
|
369
372
|
"aria-label": `Remove ${t.name}`,
|
|
370
373
|
children: "×"
|
|
371
374
|
}
|
|
372
375
|
)
|
|
373
|
-
] },
|
|
374
|
-
|
|
376
|
+
] }, a)) }),
|
|
377
|
+
Q && /* @__PURE__ */ e("p", { className: "knest-attach-error", children: Q }),
|
|
375
378
|
/* @__PURE__ */ o("div", { className: "knest-input-wrapper", children: [
|
|
376
379
|
/* @__PURE__ */ e(
|
|
377
380
|
"input",
|
|
@@ -379,17 +382,17 @@ function Oe({
|
|
|
379
382
|
type: "text",
|
|
380
383
|
value: l,
|
|
381
384
|
onChange: (t) => c(t.target.value),
|
|
382
|
-
onKeyDown:
|
|
385
|
+
onKeyDown: de,
|
|
383
386
|
placeholder: "Ask me anything...",
|
|
384
|
-
disabled: g ||
|
|
387
|
+
disabled: g || D || !N,
|
|
385
388
|
className: "knest-input-field"
|
|
386
389
|
}
|
|
387
390
|
),
|
|
388
391
|
/* @__PURE__ */ e(
|
|
389
392
|
"button",
|
|
390
393
|
{
|
|
391
|
-
onClick: () =>
|
|
392
|
-
disabled: !u || g ||
|
|
394
|
+
onClick: () => q.current?.click(),
|
|
395
|
+
disabled: !u || g || D,
|
|
393
396
|
className: "knest-attach-btn",
|
|
394
397
|
type: "button",
|
|
395
398
|
title: u ? "Attach file" : "Send a message first to enable attachments",
|
|
@@ -418,7 +421,7 @@ function Oe({
|
|
|
418
421
|
"button",
|
|
419
422
|
{
|
|
420
423
|
onClick: () => G(),
|
|
421
|
-
disabled: g ||
|
|
424
|
+
disabled: g || D || !l.trim() || !N,
|
|
422
425
|
className: "knest-send-btn",
|
|
423
426
|
"aria-label": "Send message",
|
|
424
427
|
children: /* @__PURE__ */ e("svg", { className: "knest-send-icon", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ e(
|
|
@@ -433,7 +436,7 @@ function Oe({
|
|
|
433
436
|
}
|
|
434
437
|
)
|
|
435
438
|
] }),
|
|
436
|
-
m.length > 1 && !g && /* @__PURE__ */ e("div", { className: "knest-reset-row", children: /* @__PURE__ */ e("button", { onClick:
|
|
439
|
+
m.length > 1 && !g && /* @__PURE__ */ e("div", { className: "knest-reset-row", children: /* @__PURE__ */ e("button", { onClick: ie, className: "knest-reset-btn", children: "Clear chat" }) }),
|
|
437
440
|
/* @__PURE__ */ e("div", { className: "knest-footer", children: /* @__PURE__ */ o(
|
|
438
441
|
"a",
|
|
439
442
|
{
|
|
@@ -510,86 +513,114 @@ function Oe({
|
|
|
510
513
|
) })
|
|
511
514
|
] })
|
|
512
515
|
] });
|
|
513
|
-
if (
|
|
514
|
-
return
|
|
515
|
-
const
|
|
516
|
-
return /* @__PURE__ */ o(
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
"
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
viewBox: "0 0 24 24",
|
|
531
|
-
fill: "none",
|
|
532
|
-
className: "knest-bubble-spinner",
|
|
533
|
-
children: [
|
|
534
|
-
/* @__PURE__ */ e(
|
|
535
|
-
"circle",
|
|
536
|
-
{
|
|
537
|
-
cx: "12",
|
|
538
|
-
cy: "12",
|
|
539
|
-
r: "9",
|
|
540
|
-
stroke: "currentColor",
|
|
541
|
-
strokeOpacity: "0.25",
|
|
542
|
-
strokeWidth: "3",
|
|
543
|
-
fill: "none"
|
|
544
|
-
}
|
|
545
|
-
),
|
|
546
|
-
/* @__PURE__ */ e(
|
|
547
|
-
"path",
|
|
516
|
+
if (_ === "inline")
|
|
517
|
+
return Y;
|
|
518
|
+
const ue = p ? "#9ca3af" : H;
|
|
519
|
+
return /* @__PURE__ */ o(
|
|
520
|
+
"div",
|
|
521
|
+
{
|
|
522
|
+
className: ["knest-bubble-container", E && "knest-bubble-open"].filter(Boolean).join(" "),
|
|
523
|
+
children: [
|
|
524
|
+
E && /* @__PURE__ */ o("div", { className: "knest-bubble-panel", children: [
|
|
525
|
+
/* @__PURE__ */ e(
|
|
526
|
+
"button",
|
|
527
|
+
{
|
|
528
|
+
className: "knest-bubble-close-btn",
|
|
529
|
+
onClick: () => V(!1),
|
|
530
|
+
"aria-label": "Close chat",
|
|
531
|
+
children: /* @__PURE__ */ e(
|
|
532
|
+
"svg",
|
|
548
533
|
{
|
|
549
|
-
|
|
534
|
+
width: "20",
|
|
535
|
+
height: "20",
|
|
536
|
+
viewBox: "0 0 24 24",
|
|
537
|
+
fill: "none",
|
|
550
538
|
stroke: "currentColor",
|
|
551
|
-
strokeWidth: "
|
|
552
|
-
strokeLinecap: "round",
|
|
553
|
-
fill: "none"
|
|
539
|
+
strokeWidth: "2",
|
|
540
|
+
children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" })
|
|
554
541
|
}
|
|
555
542
|
)
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
height: "24",
|
|
563
|
-
viewBox: "0 0 24 24",
|
|
564
|
-
fill: "none",
|
|
565
|
-
stroke: "currentColor",
|
|
566
|
-
strokeWidth: "2",
|
|
567
|
-
children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" })
|
|
568
|
-
}
|
|
569
|
-
) : /* @__PURE__ */ e(
|
|
570
|
-
"svg",
|
|
543
|
+
}
|
|
544
|
+
),
|
|
545
|
+
Y
|
|
546
|
+
] }),
|
|
547
|
+
/* @__PURE__ */ e(
|
|
548
|
+
"button",
|
|
571
549
|
{
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
children: /* @__PURE__ */ e(
|
|
579
|
-
"path",
|
|
550
|
+
className: ["knest-bubble-button", p && "knest-bubble-loading"].filter(Boolean).join(" "),
|
|
551
|
+
onClick: () => V(!E),
|
|
552
|
+
"aria-label": p ? "Loading chat" : E ? "Close chat" : "Open chat",
|
|
553
|
+
style: { backgroundColor: ue },
|
|
554
|
+
children: p ? /* @__PURE__ */ o(
|
|
555
|
+
"svg",
|
|
580
556
|
{
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
557
|
+
width: "24",
|
|
558
|
+
height: "24",
|
|
559
|
+
viewBox: "0 0 24 24",
|
|
560
|
+
fill: "none",
|
|
561
|
+
className: "knest-bubble-spinner",
|
|
562
|
+
children: [
|
|
563
|
+
/* @__PURE__ */ e(
|
|
564
|
+
"circle",
|
|
565
|
+
{
|
|
566
|
+
cx: "12",
|
|
567
|
+
cy: "12",
|
|
568
|
+
r: "9",
|
|
569
|
+
stroke: "currentColor",
|
|
570
|
+
strokeOpacity: "0.25",
|
|
571
|
+
strokeWidth: "3",
|
|
572
|
+
fill: "none"
|
|
573
|
+
}
|
|
574
|
+
),
|
|
575
|
+
/* @__PURE__ */ e(
|
|
576
|
+
"path",
|
|
577
|
+
{
|
|
578
|
+
d: "M12 3a9 9 0 0 1 9 9",
|
|
579
|
+
stroke: "currentColor",
|
|
580
|
+
strokeWidth: "3",
|
|
581
|
+
strokeLinecap: "round",
|
|
582
|
+
fill: "none"
|
|
583
|
+
}
|
|
584
|
+
)
|
|
585
|
+
]
|
|
586
|
+
}
|
|
587
|
+
) : E ? /* @__PURE__ */ e(
|
|
588
|
+
"svg",
|
|
589
|
+
{
|
|
590
|
+
width: "24",
|
|
591
|
+
height: "24",
|
|
592
|
+
viewBox: "0 0 24 24",
|
|
593
|
+
fill: "none",
|
|
594
|
+
stroke: "currentColor",
|
|
595
|
+
strokeWidth: "2",
|
|
596
|
+
children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" })
|
|
597
|
+
}
|
|
598
|
+
) : /* @__PURE__ */ e(
|
|
599
|
+
"svg",
|
|
600
|
+
{
|
|
601
|
+
width: "24",
|
|
602
|
+
height: "24",
|
|
603
|
+
viewBox: "0 0 24 24",
|
|
604
|
+
fill: "none",
|
|
605
|
+
stroke: "currentColor",
|
|
606
|
+
strokeWidth: "2",
|
|
607
|
+
children: /* @__PURE__ */ e(
|
|
608
|
+
"path",
|
|
609
|
+
{
|
|
610
|
+
strokeLinecap: "round",
|
|
611
|
+
strokeLinejoin: "round",
|
|
612
|
+
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"
|
|
613
|
+
}
|
|
614
|
+
)
|
|
584
615
|
}
|
|
585
616
|
)
|
|
586
617
|
}
|
|
587
618
|
)
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
619
|
+
]
|
|
620
|
+
}
|
|
621
|
+
);
|
|
591
622
|
}
|
|
592
623
|
export {
|
|
593
|
-
|
|
594
|
-
|
|
624
|
+
Re as ChatMessage,
|
|
625
|
+
Fe as ChatWidget
|
|
595
626
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useknest/widget-react",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.17",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Native React component for Knest chat widget",
|
|
6
6
|
"files": [
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"react-dom": "^18.0.0 || ^19.0.0"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@useknest/widget-core": "0.1.0-beta.
|
|
25
|
+
"@useknest/widget-core": "0.1.0-beta.17"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/react": "^18.3.3",
|