@doclessai/sdk 0.3.6 → 0.4.0

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.
@@ -0,0 +1,96 @@
1
+ var T=class{appKey;baseUrl;constructor(r){this.appKey=r.appKey,this.baseUrl=r.baseUrl||"https://doclessai.vercel.app/api/v1"}async ask(r){let v=new AbortController,u="",a=null;try{let c=new FormData;c.append("appKey",this.appKey),c.append("query",r.query),r.file&&c.append("image",r.file);let g=await fetch("https://doclessai.vercel.app/api/v2/chat",{method:"POST",signal:v.signal,body:c});if(!g.ok)throw new Error(`Request failed with status ${g.status}`);if(!g.body)throw new Error("Empty response body");let h=g.body.getReader(),f=new TextDecoder,x="";for(;;){let{done:C,value:b}=await h.read();if(C)break;x+=f.decode(b,{stream:!0});let s=x.split(`
2
+
3
+ `);x=s.pop()||"";for(let k of s){if(!k.startsWith("data: "))continue;let I=k.replace("data: ","");try{let d=JSON.parse(I);switch(d.type){case"text":u+=d.chunk,a||(a=setTimeout(()=>{r.onText?.(u),u="",a=null},35));break;case"meta":r.onMeta?.({route:d.route,elementId:d.elementId});break;case"status":r.onStatus?.(d.message);break;case"done":a&&(clearTimeout(a),r.onText?.(u),u="",a=null),r.onDone?.();break;case"error":r.onError?.(d.message);break}}catch(d){console.error("Failed to parse SSE event:",d)}}}}catch(c){if(c?.name==="AbortError"){r.onError?.("Request was aborted");return}r.onError?.(c?.message||"Unknown DoclessAI error")}}};import{useState as y,useRef as R,useEffect as H,useMemo as F}from"react";import{toast as z,Toaster as U}from"react-hot-toast";import A from"react-markdown";import q from"remark-gfm";import{jsx as e,jsxs as n}from"react/jsx-runtime";var B=p=>{if(!p)return;let r=document.getElementById(p);r&&(r.scrollIntoView({behavior:"smooth",block:"center"}),r.classList.add("docless-highlight"),setTimeout(()=>{r.classList.remove("docless-highlight")},3e3))},K=(p,r)=>{p&&window.location.pathname!==p?(window.location.href=p,setTimeout(()=>{B(r)},700)):B(r)};function O({name:p="Assistant",appKey:r}){let[v,u]=y(!1),[a,c]=y(""),[g,h]=y([{id:crypto.randomUUID(),role:"assistant",content:"Hello! How can I help you today?"}]),[f,x]=y(!1),[C,b]=y(""),[s,k]=y(null),[I,d]=y(null),D=R(null),S=R(null),L=F(()=>new T({appKey:r}),[r]);H(()=>{S.current&&(S.current.scrollTop=S.current.scrollHeight)},[g,f]);let E=async()=>{if(!a.trim()&&!s||f)return;let t=a.trim(),o=s;c(""),k(null),h(i=>[...i,{id:crypto.randomUUID(),role:"user",content:t}]);let m=crypto.randomUUID();h(i=>[...i,{id:m,role:"assistant",content:""}]),x(!0);try{await L.ask({query:t,...o?{file:o}:{},onStatus(i){b(i)},onText(i){h(w=>w.map(l=>l.id===m?{...l,content:l.content+i}:l))},onMeta(i){h(w=>w.map(l=>l.id===m?{...l,route:i.route,elementId:i.elementId}:l))},onDone(){x(!1),b("")},onError(i){x(!1),b(""),z.error(i),h(w=>w.map(l=>l.id===m?{...l,content:i}:l))}})}catch(i){x(!1),b(""),z.error(i?.message||"Something went wrong")}},W={backgroundColor:"#4f46e5",color:"white",padding:"8px 14px",borderRadius:"8px",fontSize:"13px",fontWeight:500,border:"none",cursor:"pointer"},M={backgroundColor:"#eef2ff",color:"#4338ca",padding:"8px 14px",borderRadius:"8px",fontSize:"13px",fontWeight:500,border:"1px solid #c7d2fe",cursor:"pointer"};return n("div",{style:{fontFamily:"Inter, system-ui, sans-serif"},children:[e(U,{position:"top-center",reverseOrder:!1}),e("style",{children:`
4
+ @keyframes float {
5
+ 0%, 100% {
6
+ transform: translateY(0px);
7
+ }
8
+ 50% {
9
+ transform: translateY(-5px);
10
+ }
11
+ }
12
+
13
+ @keyframes blink {
14
+ 0%, 90%, 100% {
15
+ opacity: 1;
16
+ }
17
+ 95% {
18
+ opacity: 0.3;
19
+ }
20
+ }
21
+
22
+ @keyframes fadeIn {
23
+ from {
24
+ opacity: 0;
25
+ transform: translateY(10px);
26
+ }
27
+ to {
28
+ opacity: 1;
29
+ transform: translateY(0);
30
+ }
31
+ }
32
+
33
+ .chat-bubble {
34
+ animation: float 2s ease-in-out infinite;
35
+ }
36
+
37
+ .robot-eye {
38
+ animation: blink 3s ease-in-out infinite;
39
+ }
40
+
41
+ .markdown-container {
42
+ line-height: 1.7;
43
+ }
44
+
45
+ .markdown-container pre {
46
+ overflow-x: auto;
47
+ }
48
+
49
+ .markdown-container code {
50
+ font-family: monospace;
51
+ }
52
+
53
+ .markdown-container table {
54
+ border-collapse: collapse;
55
+ width: 100%;
56
+ }
57
+
58
+ .markdown-container th,
59
+ .markdown-container td {
60
+ border: 1px solid #e5e7eb;
61
+ padding: 8px;
62
+ }
63
+
64
+ .markdown-container strong {
65
+ font-weight: 700;
66
+ color: #111827;
67
+ }
68
+
69
+ .markdown-container a {
70
+ color: #4f46e5;
71
+ text-decoration: underline;
72
+ }
73
+
74
+ .markdown-container pre {
75
+ white-space: pre-wrap;
76
+ word-wrap: break-word;
77
+ }
78
+
79
+ @keyframes pulseHighlight {
80
+ 0% {
81
+ box-shadow: 0 0 0 0 rgba(99,102,241,0.6);
82
+ }
83
+ 70% {
84
+ box-shadow: 0 0 0 12px rgba(99,102,241,0);
85
+ }
86
+ 100% {
87
+ box-shadow: 0 0 0 0 rgba(99,102,241,0);
88
+ }
89
+ }
90
+
91
+ .docless-highlight {
92
+ animation: pulseHighlight 1.5s ease-out 2;
93
+ outline: 3px solid #6366f1;
94
+ border-radius: 8px;
95
+ }
96
+ `}),I&&n("div",{onClick:()=>d(null),style:{position:"fixed",inset:0,backgroundColor:"rgba(0,0,0,0.8)",backdropFilter:"blur(5px)",zIndex:2e4,display:"flex",alignItems:"center",justifyContent:"center",cursor:"zoom-out",padding:"20px"},children:[e("button",{style:{position:"absolute",top:"20px",right:"20px",background:"#fff",border:"none",borderRadius:"50%",width:"40px",height:"40px",cursor:"pointer",fontSize:"20px"},children:"\u2715"}),e("img",{src:I,alt:"Zoomed reference",style:{maxWidth:"100%",maxHeight:"90vh",borderRadius:"8px",boxShadow:"0 0 30px rgba(0,0,0,0.5)"}})]}),!v&&e("svg",{width:"60",height:"60",viewBox:"0 0 60 60",fill:"none",style:{cursor:"pointer",position:"fixed",bottom:"20px",right:"20px",zIndex:9999,filter:"drop-shadow(0px 4px 12px rgba(0, 0, 0, 0.15))"},onClick:()=>u(!0),children:n("g",{className:"chat-bubble",children:[e("ellipse",{cx:"30",cy:"52",rx:"15",ry:"3",fill:"#000",opacity:"0.1"}),e("path",{d:"M45 15C45 8.37258 39.6274 3 33 3H15C8.37258 3 3 8.37258 3 15V33C3 39.6274 8.37258 45 15 45H18V52L26 45H33C39.6274 45 45 39.6274 45 33V15Z",fill:"#4F46E5"}),n("g",{transform:"translate(12, 14)",children:[e("line",{x1:"12",y1:"0",x2:"12",y2:"3",stroke:"white",strokeWidth:"1.5",strokeLinecap:"round"}),e("circle",{cx:"12",cy:"0",r:"1.5",fill:"white"}),e("rect",{x:"6",y:"3",width:"12",height:"10",rx:"2",fill:"white"}),e("circle",{className:"robot-eye",cx:"9.5",cy:"8",r:"1.5",fill:"#4F46E5"}),e("circle",{className:"robot-eye",cx:"14.5",cy:"8",r:"1.5",fill:"#4F46E5"}),e("line",{x1:"9",y1:"11",x2:"15",y2:"11",stroke:"#4F46E5",strokeWidth:"1",strokeLinecap:"round"}),e("rect",{x:"7",y:"14",width:"10",height:"6",rx:"1",fill:"white"}),e("rect",{x:"4",y:"15",width:"2",height:"4",rx:"1",fill:"white"}),e("rect",{x:"18",y:"15",width:"2",height:"4",rx:"1",fill:"white"})]})]})}),v&&n("div",{style:{position:"fixed",bottom:"20px",right:"20px",width:"min(400px, 90vw)",height:"min(600px, 85vh)",backgroundColor:"#fff",boxShadow:"0 12px 40px rgba(79, 70, 229, 0.25)",borderRadius:"16px",display:"flex",flexDirection:"column",zIndex:1e4,overflow:"hidden",border:"1px solid #e5e7eb",animation:"fadeIn 0.2s ease-out"},children:[n("div",{style:{backgroundColor:"#4f46e5",padding:"14px 18px",display:"flex",alignItems:"center",justifyContent:"space-between",color:"#fff"},children:[n("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[e("div",{style:{width:"8px",height:"8px",backgroundColor:"#22c55e",borderRadius:"50%",boxShadow:"0 0 8px #22c55e"}}),e("span",{style:{fontWeight:600,fontSize:"15px"},children:p})]}),e("span",{style:{cursor:"pointer",fontSize:"18px",opacity:.8},onClick:()=>u(!1),children:"\u2715"})]}),n("div",{ref:S,style:{flex:1,overflowY:"auto",padding:"16px",display:"flex",flexDirection:"column",gap:"12px",backgroundColor:"#f9fafb"},children:[g.map(t=>e("div",{style:{alignSelf:t.role==="user"?"flex-end":"flex-start",maxWidth:"85%",display:"flex",flexDirection:"column",gap:"4px"},children:n("div",{style:{backgroundColor:t.role==="user"?"#4f46e5":"#fff",color:t.role==="user"?"#fff":"#374151",padding:"12px 16px",borderRadius:"12px",fontSize:"14px",border:t.role==="user"?"none":"1px solid #e5e7eb",boxShadow:t.role==="user"?"0 2px 4px rgba(79,70,229,0.2)":"0 1px 2px rgba(0,0,0,0.05)"},children:[t.image&&e("div",{style:{marginBottom:"10px"},children:e("img",{src:t.image,alt:"Reference",onClick:()=>d(t.image),style:{width:"100%",borderRadius:"8px",cursor:"zoom-in"}})}),t.role==="assistant"?n("div",{className:"markdown-container",children:[e(A,{remarkPlugins:[q],components:{code(o){let{children:m,className:i}=o;return i?.includes("language-")?e("pre",{style:{background:"#111827",color:"#f9fafb",padding:"14px",borderRadius:"10px",overflowX:"auto",marginTop:"10px",marginBottom:"10px",fontSize:"13px",lineHeight:1.6},children:e("code",{children:m})}):e("code",{style:{background:"#eef2ff",color:"#4338ca",padding:"2px 6px",borderRadius:"6px",fontSize:"13px",fontFamily:"monospace"},children:m})},p(o){return e("p",{style:{marginTop:"8px",marginBottom:"8px",lineHeight:1.7},children:o.children})},ul(o){return e("ul",{style:{paddingLeft:"20px",marginTop:"10px",marginBottom:"10px"},children:o.children})},ol(o){return e("ol",{style:{paddingLeft:"20px",marginTop:"10px",marginBottom:"10px"},children:o.children})},li(o){return e("li",{style:{marginBottom:"6px",lineHeight:1.6},children:o.children})},h1(o){return e("h1",{style:{fontSize:"22px",fontWeight:700,marginTop:"16px",marginBottom:"10px",color:"#111827"},children:o.children})},h2(o){return e("h2",{style:{fontSize:"18px",fontWeight:700,marginTop:"14px",marginBottom:"8px",color:"#111827"},children:o.children})},h3(o){return e("h3",{style:{fontSize:"16px",fontWeight:600,marginTop:"12px",marginBottom:"6px",color:"#111827"},children:o.children})},a(o){return e("a",{href:o.href,target:"_blank",rel:"noreferrer",style:{color:"#4f46e5",textDecoration:"underline",fontWeight:500},children:o.children})},blockquote(o){return e("blockquote",{style:{borderLeft:"4px solid #6366f1",paddingLeft:"12px",marginLeft:0,color:"#4b5563",fontStyle:"italic",marginTop:"10px",marginBottom:"10px"},children:o.children})}},children:t.content}),(t.route||t.elementId)&&n("div",{style:{marginTop:"12px",borderTop:"1px solid #f3f4f6",paddingTop:"10px",display:"flex",gap:"8px",flexWrap:"wrap"},children:[t.route&&e("button",{onClick:()=>window.location.href=t.route,style:W,children:"Explore Page"}),t.elementId&&e("button",{onClick:()=>K(t.route,t.elementId),style:M,children:"View"})]})]}):e("div",{style:{whiteSpace:"pre-wrap"},children:t.content})]})},t.id)),f&&e("div",{style:{fontSize:"12px",color:"#6b7280",marginLeft:"4px"},children:C||`${p} is thinking...`})]}),n("div",{style:{padding:"16px",borderTop:"1px solid #e5e7eb",backgroundColor:"#fff"},children:[n("div",{style:{display:"flex",alignItems:"center",gap:"10px",backgroundColor:"#f3f4f6",padding:"6px 14px",borderRadius:"28px"},children:[n("button",{style:{background:"none",border:"none",cursor:"pointer",padding:"4px",display:"flex"},onClick:()=>D.current?.click(),children:[n("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"#9ca3af",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),e("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),e("polyline",{points:"21 15 16 10 5 21"})]}),e("input",{type:"file",accept:"image/*",ref:D,style:{display:"none"},onChange:t=>{let o=t.target.files?.[0];o&&(k(o),z.success(`Attached: ${o.name}`))}})]}),s&&n("div",{style:{fontSize:"11px",color:"#4f46e5",maxWidth:"80px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:["\u{1F4CE} ",s.name]}),e("input",{type:"text",value:a,onChange:t=>c(t.target.value),onKeyDown:t=>t.key==="Enter"&&E(),placeholder:"Type a message...",style:{flex:1,border:"none",background:"none",padding:"10px 0",outline:"none",fontSize:"14px",color:"#1f2937"}}),e("button",{onClick:E,disabled:!a.trim()&&!s||f,style:{background:(a.trim()||s)&&!f?"#4f46e5":"transparent",border:"none",borderRadius:"50%",width:"34px",height:"34px",display:"flex",alignItems:"center",justifyContent:"center",cursor:(a.trim()||s)&&!f?"pointer":"default",transition:"all 0.2s"},children:n("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:(a.trim()||s)&&!f?"#fff":"#9ca3af",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),e("polyline",{points:"22 2 15 22 11 13 2 9 22 2"})]})})]}),n("div",{style:{textAlign:"center",fontSize:"11px",color:"#9ca3af",marginTop:"10px"},children:["Powered by ",e("strong",{children:"DoclessAI"})]})]})]})]})}export{T as a,O as b};
package/dist/index.cjs CHANGED
@@ -1,13 +1,64 @@
1
- "use strict";var H=Object.create;var h=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var K=Object.getPrototypeOf,U=Object.prototype.hasOwnProperty;var j=(i,r)=>{for(var s in r)h(i,s,{get:r[s],enumerable:!0})},T=(i,r,s,d)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of M(r))!U.call(i,n)&&n!==s&&h(i,n,{get:()=>r[n],enumerable:!(d=B(r,n))||d.enumerable});return i};var q=(i,r,s)=>(s=i!=null?H(K(i)):{},T(r||!i||!i.__esModule?h(s,"default",{value:i,enumerable:!0}):s,i)),N=i=>T(h({},"__esModule",{value:!0}),i);var P={};j(P,{ChatWidget:()=>m,DoclessClient:()=>x});module.exports=N(P);var x=class{appKey;baseUrl;constructor(r){this.appKey=r.appKey,this.baseUrl=r.baseUrl||"https://doclessai.vercel.app/api/v1"}async ask(r,s){let d=new AbortController;try{let n=new FormData;n.append("appKey",this.appKey),n.append("query",r),s&&n.append("image",s);let a=await fetch(`${this.baseUrl}/chat`,{method:"POST",signal:d.signal,headers:{"X-SDK-Name":"@doclessai/sdk","X-SDK-Version":"0.3.6"},body:n});if(!a.ok){let u=await a.json().catch(()=>({}));throw new Error(u.message||`DoclessAI Request failed with status ${a.status}`)}return await a.json()}catch(n){throw n instanceof Error&&n.name==="AbortError"?new Error("DoclessAI Error: Request timed out."):new Error(`DoclessAI Error: ${n instanceof Error?n.message:"Unknown error"}`)}}};var l=require("react");var g=require("react-hot-toast"),W=q(require("react-markdown"),1),e=require("react/jsx-runtime"),L=i=>{if(!i)return;let r=document.getElementById(i);r&&(r.scrollIntoView({behavior:"smooth",block:"center"}),r.classList.add("docless-highlight"),setTimeout(()=>{r.classList.remove("docless-highlight")},3e3))},V=(i,r)=>{i&&window.location.pathname!==i?(window.location.href=i,setTimeout(()=>{L(r)},700)):L(r)};function m({name:i="Assistant",appKey:r}){let[s,d]=(0,l.useState)(!1),[n,a]=(0,l.useState)(""),[u,w]=(0,l.useState)([{role:"assistant",content:"Hello! How can I help you today?"}]),[p,v]=(0,l.useState)(!1),[y,k]=(0,l.useState)(null),[C,S]=(0,l.useState)(null),I=(0,l.useRef)(null),f=(0,l.useRef)(null),D=(0,l.useMemo)(()=>new x({appKey:r}),[r]);(0,l.useEffect)(()=>{f.current&&f.current.scrollTo({top:f.current.scrollHeight,behavior:"smooth"})},[u,p]);let R=async()=>{if(!n.trim()||p)return;let o=n.trim(),c=y;a(""),w(t=>[...t,{role:"user",content:o}]),v(!0);try{let t=await D.ask(o,c||void 0);k(null),w(b=>[...b,{role:"assistant",content:t.res,image:t.image,route:t.route,elementId:t.elementId}])}catch(t){g.toast.error(t?.message||"Something went wrong"),a(o)}finally{v(!1)}},A={backgroundColor:"#4f46e5",color:"white",padding:"8px 14px",borderRadius:"8px",fontSize:"13px",fontWeight:500,border:"none",cursor:"pointer"},F={backgroundColor:"#eef2ff",color:"#4338ca",padding:"8px 14px",borderRadius:"8px",fontSize:"13px",fontWeight:500,border:"1px solid #c7d2fe",cursor:"pointer"};return(0,e.jsxs)("div",{style:{fontFamily:"Inter, system-ui, sans-serif"},children:[(0,e.jsx)(g.Toaster,{position:"top-center",reverseOrder:!1}),(0,e.jsx)("style",{children:`
2
- @keyframes float { 0%, 100% { transform: translateY(0px); } 50% { transform: translateY(-5px); } }
3
- @keyframes blink { 0%, 90%, 100% { opacity: 1; } 95% { opacity: 0.3; } }
4
- @keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
5
-
6
- .chat-bubble { animation: float 2s ease-in-out infinite; }
7
- .robot-eye { animation: blink 3s ease-in-out infinite; }
1
+ "use strict";var q=Object.create;var T=Object.defineProperty;var K=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var N=Object.getPrototypeOf,P=Object.prototype.hasOwnProperty;var j=(n,t)=>{for(var s in t)T(n,s,{get:t[s],enumerable:!0})},W=(n,t,s,p)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of O(t))!P.call(n,i)&&i!==s&&T(n,i,{get:()=>t[i],enumerable:!(p=K(t,i))||p.enumerable});return n};var B=(n,t,s)=>(s=n!=null?q(N(n)):{},W(t||!n||!n.__esModule?T(s,"default",{value:n,enumerable:!0}):s,n)),V=n=>W(T({},"__esModule",{value:!0}),n);var Z={};j(Z,{ChatWidget:()=>D,DoclessClient:()=>I});module.exports=V(Z);var I=class{appKey;baseUrl;constructor(t){this.appKey=t.appKey,this.baseUrl=t.baseUrl||"https://doclessai.vercel.app/api/v1"}async ask(t){let s=new AbortController,p="",i=null;try{let x=new FormData;x.append("appKey",this.appKey),x.append("query",t.query),t.file&&x.append("image",t.file);let h=await fetch("https://doclessai.vercel.app/api/v2/chat",{method:"POST",signal:s.signal,body:x});if(!h.ok)throw new Error(`Request failed with status ${h.status}`);if(!h.body)throw new Error("Empty response body");let m=h.body.getReader(),u=new TextDecoder,g="";for(;;){let{done:z,value:b}=await m.read();if(z)break;g+=u.decode(b,{stream:!0});let c=g.split(`
2
+
3
+ `);g=c.pop()||"";for(let v of c){if(!v.startsWith("data: "))continue;let S=v.replace("data: ","");try{let f=JSON.parse(S);switch(f.type){case"text":p+=f.chunk,i||(i=setTimeout(()=>{t.onText?.(p),p="",i=null},35));break;case"meta":t.onMeta?.({route:f.route,elementId:f.elementId});break;case"status":t.onStatus?.(f.message);break;case"done":i&&(clearTimeout(i),t.onText?.(p),p="",i=null),t.onDone?.();break;case"error":t.onError?.(f.message);break}}catch(f){console.error("Failed to parse SSE event:",f)}}}}catch(x){if(x?.name==="AbortError"){t.onError?.("Request was aborted");return}t.onError?.(x?.message||"Unknown DoclessAI error")}}};var l=require("react");var k=require("react-hot-toast"),M=B(require("react-markdown"),1),H=B(require("remark-gfm"),1),e=require("react/jsx-runtime"),L=n=>{if(!n)return;let t=document.getElementById(n);t&&(t.scrollIntoView({behavior:"smooth",block:"center"}),t.classList.add("docless-highlight"),setTimeout(()=>{t.classList.remove("docless-highlight")},3e3))},Y=(n,t)=>{n&&window.location.pathname!==n?(window.location.href=n,setTimeout(()=>{L(t)},700)):L(t)};function D({name:n="Assistant",appKey:t}){let[s,p]=(0,l.useState)(!1),[i,x]=(0,l.useState)(""),[h,m]=(0,l.useState)([{id:crypto.randomUUID(),role:"assistant",content:"Hello! How can I help you today?"}]),[u,g]=(0,l.useState)(!1),[z,b]=(0,l.useState)(""),[c,v]=(0,l.useState)(null),[S,f]=(0,l.useState)(null),E=(0,l.useRef)(null),C=(0,l.useRef)(null),F=(0,l.useMemo)(()=>new I({appKey:t}),[t]);(0,l.useEffect)(()=>{C.current&&(C.current.scrollTop=C.current.scrollHeight)},[h,u]);let R=async()=>{if(!i.trim()&&!c||u)return;let o=i.trim(),r=c;x(""),v(null),m(a=>[...a,{id:crypto.randomUUID(),role:"user",content:o}]);let y=crypto.randomUUID();m(a=>[...a,{id:y,role:"assistant",content:""}]),g(!0);try{await F.ask({query:o,...r?{file:r}:{},onStatus(a){b(a)},onText(a){m(w=>w.map(d=>d.id===y?{...d,content:d.content+a}:d))},onMeta(a){m(w=>w.map(d=>d.id===y?{...d,route:a.route,elementId:a.elementId}:d))},onDone(){g(!1),b("")},onError(a){g(!1),b(""),k.toast.error(a),m(w=>w.map(d=>d.id===y?{...d,content:a}:d))}})}catch(a){g(!1),b(""),k.toast.error(a?.message||"Something went wrong")}},U={backgroundColor:"#4f46e5",color:"white",padding:"8px 14px",borderRadius:"8px",fontSize:"13px",fontWeight:500,border:"none",cursor:"pointer"},A={backgroundColor:"#eef2ff",color:"#4338ca",padding:"8px 14px",borderRadius:"8px",fontSize:"13px",fontWeight:500,border:"1px solid #c7d2fe",cursor:"pointer"};return(0,e.jsxs)("div",{style:{fontFamily:"Inter, system-ui, sans-serif"},children:[(0,e.jsx)(k.Toaster,{position:"top-center",reverseOrder:!1}),(0,e.jsx)("style",{children:`
4
+ @keyframes float {
5
+ 0%, 100% {
6
+ transform: translateY(0px);
7
+ }
8
+ 50% {
9
+ transform: translateY(-5px);
10
+ }
11
+ }
12
+
13
+ @keyframes blink {
14
+ 0%, 90%, 100% {
15
+ opacity: 1;
16
+ }
17
+ 95% {
18
+ opacity: 0.3;
19
+ }
20
+ }
21
+
22
+ @keyframes fadeIn {
23
+ from {
24
+ opacity: 0;
25
+ transform: translateY(10px);
26
+ }
27
+ to {
28
+ opacity: 1;
29
+ transform: translateY(0);
30
+ }
31
+ }
32
+
33
+ .chat-bubble {
34
+ animation: float 2s ease-in-out infinite;
35
+ }
36
+
37
+ .robot-eye {
38
+ animation: blink 3s ease-in-out infinite;
39
+ }
8
40
 
9
41
  .markdown-container {
10
- word-break: break-word;
42
+ line-height: 1.7;
43
+ }
44
+
45
+ .markdown-container pre {
46
+ overflow-x: auto;
47
+ }
48
+
49
+ .markdown-container code {
50
+ font-family: monospace;
51
+ }
52
+
53
+ .markdown-container table {
54
+ border-collapse: collapse;
55
+ width: 100%;
56
+ }
57
+
58
+ .markdown-container th,
59
+ .markdown-container td {
60
+ border: 1px solid #e5e7eb;
61
+ padding: 8px;
11
62
  }
12
63
 
13
64
  .markdown-container strong {
@@ -24,11 +75,17 @@
24
75
  white-space: pre-wrap;
25
76
  word-wrap: break-word;
26
77
  }
27
-
78
+
28
79
  @keyframes pulseHighlight {
29
- 0% { box-shadow: 0 0 0 0 rgba(99,102,241,0.6); }
30
- 70% { box-shadow: 0 0 0 12px rgba(99,102,241,0); }
31
- 100% { box-shadow: 0 0 0 0 rgba(99,102,241,0); }
80
+ 0% {
81
+ box-shadow: 0 0 0 0 rgba(99,102,241,0.6);
82
+ }
83
+ 70% {
84
+ box-shadow: 0 0 0 12px rgba(99,102,241,0);
85
+ }
86
+ 100% {
87
+ box-shadow: 0 0 0 0 rgba(99,102,241,0);
88
+ }
32
89
  }
33
90
 
34
91
  .docless-highlight {
@@ -36,4 +93,4 @@
36
93
  outline: 3px solid #6366f1;
37
94
  border-radius: 8px;
38
95
  }
39
- `}),C&&(0,e.jsxs)("div",{onClick:()=>S(null),style:{position:"fixed",inset:0,backgroundColor:"rgba(0,0,0,0.8)",backdropFilter:"blur(5px)",zIndex:2e4,display:"flex",alignItems:"center",justifyContent:"center",cursor:"zoom-out",padding:"20px"},children:[(0,e.jsx)("button",{style:{position:"absolute",top:"20px",right:"20px",background:"#fff",border:"none",borderRadius:"50%",width:"40px",height:"40px",cursor:"pointer",fontSize:"20px"},children:"\u2715"}),(0,e.jsx)("img",{src:C,style:{maxWidth:"100%",maxHeight:"90vh",borderRadius:"8px",boxShadow:"0 0 30px rgba(0,0,0,0.5)"},alt:"Zoomed reference"})]}),!s&&(0,e.jsx)("svg",{width:"60",height:"60",viewBox:"0 0 60 60",fill:"none",style:{cursor:"pointer",position:"fixed",bottom:"20px",right:"20px",zIndex:9999,filter:"drop-shadow(0px 4px 12px rgba(0, 0, 0, 0.15))"},onClick:()=>d(!0),children:(0,e.jsxs)("g",{className:"chat-bubble",children:[(0,e.jsx)("ellipse",{cx:"30",cy:"52",rx:"15",ry:"3",fill:"#000",opacity:"0.1"}),(0,e.jsx)("path",{d:"M45 15C45 8.37258 39.6274 3 33 3H15C8.37258 3 3 8.37258 3 15V33C3 39.6274 8.37258 45 15 45H18V52L26 45H33C39.6274 45 45 39.6274 45 33V15Z",fill:"#4F46E5"}),(0,e.jsxs)("g",{transform:"translate(12, 14)",children:[(0,e.jsx)("line",{x1:"12",y1:"0",x2:"12",y2:"3",stroke:"white",strokeWidth:"1.5",strokeLinecap:"round"}),(0,e.jsx)("circle",{cx:"12",cy:"0",r:"1.5",fill:"white"}),(0,e.jsx)("rect",{x:"6",y:"3",width:"12",height:"10",rx:"2",fill:"white"}),(0,e.jsx)("circle",{className:"robot-eye",cx:"9.5",cy:"8",r:"1.5",fill:"#4F46E5"}),(0,e.jsx)("circle",{className:"robot-eye",cx:"14.5",cy:"8",r:"1.5",fill:"#4F46E5"}),(0,e.jsx)("line",{x1:"9",y1:"11",x2:"15",y2:"11",stroke:"#4F46E5",strokeWidth:"1",strokeLinecap:"round"}),(0,e.jsx)("rect",{x:"7",y:"14",width:"10",height:"6",rx:"1",fill:"white"}),(0,e.jsx)("rect",{x:"4",y:"15",width:"2",height:"4",rx:"1",fill:"white"}),(0,e.jsx)("rect",{x:"18",y:"15",width:"2",height:"4",rx:"1",fill:"white"})]})]})}),s&&(0,e.jsxs)("div",{style:{position:"fixed",bottom:"20px",right:"20px",width:"min(400px, 90vw)",height:"min(600px, 85vh)",backgroundColor:"#fff",boxShadow:"0 12px 40px rgba(79, 70, 229, 0.25)",borderRadius:"16px",display:"flex",flexDirection:"column",zIndex:1e4,overflow:"hidden",border:"1px solid #e5e7eb",animation:"fadeIn 0.2s ease-out"},children:[(0,e.jsxs)("div",{style:{backgroundColor:"#4f46e5",padding:"14px 18px",display:"flex",alignItems:"center",justifyContent:"space-between",color:"#fff"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[(0,e.jsx)("div",{style:{width:"8px",height:"8px",backgroundColor:"#22c55e",borderRadius:"50%",boxShadow:"0 0 8px #22c55e"}}),(0,e.jsx)("span",{style:{fontWeight:600,fontSize:"15px"},children:i})]}),(0,e.jsx)("span",{style:{cursor:"pointer",fontSize:"18px",opacity:.8},onClick:()=>d(!1),children:"\u2715"})]}),(0,e.jsxs)("div",{ref:f,style:{flex:1,overflowY:"auto",padding:"16px",display:"flex",flexDirection:"column",gap:"12px",backgroundColor:"#f9fafb"},children:[u.map((o,c)=>(0,e.jsx)("div",{style:{alignSelf:o.role==="user"?"flex-end":"flex-start",maxWidth:"85%",display:"flex",flexDirection:"column",gap:"4px"},children:(0,e.jsxs)("div",{style:{backgroundColor:o.role==="user"?"#4f46e5":"#fff",color:o.role==="user"?"#fff":"#374151",padding:"12px 16px",borderRadius:"12px",fontSize:"14px",border:o.role==="user"?"none":"1px solid #e5e7eb",boxShadow:o.role==="user"?"0 2px 4px rgba(79,70,229,0.2)":"0 1px 2px rgba(0,0,0,0.05)"},children:[o.image&&(0,e.jsx)("div",{style:{marginBottom:"10px"},children:(0,e.jsx)("img",{src:o.image,onClick:()=>S(o.image),style:{width:"100%",borderRadius:"8px",cursor:"zoom-in"},alt:"Reference"})}),o.role==="assistant"?(0,e.jsxs)("div",{className:"markdown-container",children:[(0,e.jsx)(W.default,{components:{p:({children:t})=>(0,e.jsx)("p",{style:{marginBottom:"12px",lineHeight:"1.6"},children:t}),ul:({children:t})=>(0,e.jsx)("ul",{style:{listStyleType:"disc",marginLeft:"20px",marginBottom:"12px"},children:t}),ol:({children:t})=>(0,e.jsx)("ol",{style:{listStyleType:"decimal",marginLeft:"20px",marginBottom:"12px"},children:t}),li:({children:t})=>(0,e.jsx)("li",{style:{marginBottom:"4px"},children:t}),h1:({children:t})=>(0,e.jsx)("h1",{style:{fontSize:"1.25rem",fontWeight:"bold",margin:"16px 0 8px"},children:t}),h2:({children:t})=>(0,e.jsx)("h2",{style:{fontSize:"1.1rem",fontWeight:"bold",margin:"14px 0 7px"},children:t}),h3:({children:t})=>(0,e.jsx)("h3",{style:{fontSize:"1rem",fontWeight:"bold",margin:"12px 0 6px"},children:t}),code:({node:t,inline:b,className:Y,children:z,...E})=>b?(0,e.jsx)("code",{style:{backgroundColor:"#f3f4f6",padding:"2px 5px",borderRadius:"4px",fontSize:"13px",color:"#e03e2d",fontFamily:"monospace"},...E,children:z}):(0,e.jsx)("div",{style:{backgroundColor:"#f8fafc",border:"1px solid #e2e8f0",borderRadius:"8px",padding:"12px",margin:"12px 0",overflowX:"auto"},children:(0,e.jsx)("code",{style:{fontSize:"13px",color:"#1e293b",fontFamily:"monospace",whiteSpace:"pre"},...E,children:z})}),blockquote:({children:t})=>(0,e.jsx)("blockquote",{style:{borderLeft:"4px solid #4f46e5",paddingLeft:"12px",color:"#4b5563",fontStyle:"italic",margin:"12px 0"},children:t}),table:({children:t})=>(0,e.jsx)("div",{style:{overflowX:"auto",margin:"12px 0"},children:(0,e.jsx)("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"13px"},children:t})}),th:({children:t})=>(0,e.jsx)("th",{style:{border:"1px solid #e5e7eb",padding:"8px",backgroundColor:"#f9fafb",textAlign:"left"},children:t}),td:({children:t})=>(0,e.jsx)("td",{style:{border:"1px solid #e5e7eb",padding:"8px"},children:t})},children:o.content}),(o.route||o.elementId)&&(0,e.jsxs)("div",{style:{marginTop:"12px",borderTop:"1px solid #f3f4f6",paddingTop:"10px",display:"flex",gap:"8px",flexWrap:"wrap"},children:[o.route&&(0,e.jsx)("button",{onClick:()=>window.location.href=o.route,style:A,children:"Explore Page"}),o.elementId&&(0,e.jsx)("button",{onClick:()=>V(o.route,o.elementId),style:F,children:"View"})]})]}):(0,e.jsx)("div",{style:{whiteSpace:"pre-wrap"},children:o.content})]})},c)),(0,e.jsx)("div",{ref:f}),p&&(0,e.jsxs)("div",{style:{fontSize:"12px",color:"#6b7280",marginLeft:"4px"},children:[i," is thinking..."]})]}),(0,e.jsxs)("div",{style:{padding:"16px",borderTop:"1px solid #e5e7eb",backgroundColor:"#fff"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"10px",backgroundColor:"#f3f4f6",padding:"6px 14px",borderRadius:"28px"},children:[(0,e.jsxs)("button",{style:{background:"none",border:"none",cursor:"pointer",padding:"4px",display:"flex"},onClick:()=>I.current?.click(),children:[(0,e.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"#9ca3af",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,e.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),(0,e.jsx)("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),(0,e.jsx)("polyline",{points:"21 15 16 10 5 21"})]}),(0,e.jsx)("input",{type:"file",accept:"image/*",ref:I,style:{display:"none"},onChange:o=>{let c=o.target.files?.[0];c&&(k(c),g.toast.success(`Attached: ${c.name}`))}})]}),y&&(0,e.jsxs)("div",{style:{fontSize:"11px",color:"#4f46e5",maxWidth:"80px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:["\u{1F4CE} ",y.name]}),(0,e.jsx)("input",{type:"text",value:n,onChange:o=>a(o.target.value),onKeyDown:o=>o.key==="Enter"&&R(),placeholder:"Type a message...",style:{flex:1,border:"none",background:"none",padding:"10px 0",outline:"none",fontSize:"14px",color:"#1f2937"}}),(0,e.jsx)("button",{onClick:R,disabled:!n.trim()||p,style:{background:n.trim()&&!p?"#4f46e5":"transparent",border:"none",borderRadius:"50%",width:"34px",height:"34px",display:"flex",alignItems:"center",justifyContent:"center",cursor:n.trim()&&!p?"pointer":"default",transition:"all 0.2s"},children:(0,e.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:n.trim()&&!p?"#fff":"#9ca3af",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,e.jsx)("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),(0,e.jsx)("polyline",{points:"22 2 15 22 11 13 2 9 22 2"})]})})]}),(0,e.jsxs)("div",{style:{textAlign:"center",fontSize:"11px",color:"#9ca3af",marginTop:"10px"},children:["Powered by ",(0,e.jsx)("strong",{children:"DoclessAI"})]})]})]})]})}0&&(module.exports={ChatWidget,DoclessClient});
96
+ `}),S&&(0,e.jsxs)("div",{onClick:()=>f(null),style:{position:"fixed",inset:0,backgroundColor:"rgba(0,0,0,0.8)",backdropFilter:"blur(5px)",zIndex:2e4,display:"flex",alignItems:"center",justifyContent:"center",cursor:"zoom-out",padding:"20px"},children:[(0,e.jsx)("button",{style:{position:"absolute",top:"20px",right:"20px",background:"#fff",border:"none",borderRadius:"50%",width:"40px",height:"40px",cursor:"pointer",fontSize:"20px"},children:"\u2715"}),(0,e.jsx)("img",{src:S,alt:"Zoomed reference",style:{maxWidth:"100%",maxHeight:"90vh",borderRadius:"8px",boxShadow:"0 0 30px rgba(0,0,0,0.5)"}})]}),!s&&(0,e.jsx)("svg",{width:"60",height:"60",viewBox:"0 0 60 60",fill:"none",style:{cursor:"pointer",position:"fixed",bottom:"20px",right:"20px",zIndex:9999,filter:"drop-shadow(0px 4px 12px rgba(0, 0, 0, 0.15))"},onClick:()=>p(!0),children:(0,e.jsxs)("g",{className:"chat-bubble",children:[(0,e.jsx)("ellipse",{cx:"30",cy:"52",rx:"15",ry:"3",fill:"#000",opacity:"0.1"}),(0,e.jsx)("path",{d:"M45 15C45 8.37258 39.6274 3 33 3H15C8.37258 3 3 8.37258 3 15V33C3 39.6274 8.37258 45 15 45H18V52L26 45H33C39.6274 45 45 39.6274 45 33V15Z",fill:"#4F46E5"}),(0,e.jsxs)("g",{transform:"translate(12, 14)",children:[(0,e.jsx)("line",{x1:"12",y1:"0",x2:"12",y2:"3",stroke:"white",strokeWidth:"1.5",strokeLinecap:"round"}),(0,e.jsx)("circle",{cx:"12",cy:"0",r:"1.5",fill:"white"}),(0,e.jsx)("rect",{x:"6",y:"3",width:"12",height:"10",rx:"2",fill:"white"}),(0,e.jsx)("circle",{className:"robot-eye",cx:"9.5",cy:"8",r:"1.5",fill:"#4F46E5"}),(0,e.jsx)("circle",{className:"robot-eye",cx:"14.5",cy:"8",r:"1.5",fill:"#4F46E5"}),(0,e.jsx)("line",{x1:"9",y1:"11",x2:"15",y2:"11",stroke:"#4F46E5",strokeWidth:"1",strokeLinecap:"round"}),(0,e.jsx)("rect",{x:"7",y:"14",width:"10",height:"6",rx:"1",fill:"white"}),(0,e.jsx)("rect",{x:"4",y:"15",width:"2",height:"4",rx:"1",fill:"white"}),(0,e.jsx)("rect",{x:"18",y:"15",width:"2",height:"4",rx:"1",fill:"white"})]})]})}),s&&(0,e.jsxs)("div",{style:{position:"fixed",bottom:"20px",right:"20px",width:"min(400px, 90vw)",height:"min(600px, 85vh)",backgroundColor:"#fff",boxShadow:"0 12px 40px rgba(79, 70, 229, 0.25)",borderRadius:"16px",display:"flex",flexDirection:"column",zIndex:1e4,overflow:"hidden",border:"1px solid #e5e7eb",animation:"fadeIn 0.2s ease-out"},children:[(0,e.jsxs)("div",{style:{backgroundColor:"#4f46e5",padding:"14px 18px",display:"flex",alignItems:"center",justifyContent:"space-between",color:"#fff"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[(0,e.jsx)("div",{style:{width:"8px",height:"8px",backgroundColor:"#22c55e",borderRadius:"50%",boxShadow:"0 0 8px #22c55e"}}),(0,e.jsx)("span",{style:{fontWeight:600,fontSize:"15px"},children:n})]}),(0,e.jsx)("span",{style:{cursor:"pointer",fontSize:"18px",opacity:.8},onClick:()=>p(!1),children:"\u2715"})]}),(0,e.jsxs)("div",{ref:C,style:{flex:1,overflowY:"auto",padding:"16px",display:"flex",flexDirection:"column",gap:"12px",backgroundColor:"#f9fafb"},children:[h.map(o=>(0,e.jsx)("div",{style:{alignSelf:o.role==="user"?"flex-end":"flex-start",maxWidth:"85%",display:"flex",flexDirection:"column",gap:"4px"},children:(0,e.jsxs)("div",{style:{backgroundColor:o.role==="user"?"#4f46e5":"#fff",color:o.role==="user"?"#fff":"#374151",padding:"12px 16px",borderRadius:"12px",fontSize:"14px",border:o.role==="user"?"none":"1px solid #e5e7eb",boxShadow:o.role==="user"?"0 2px 4px rgba(79,70,229,0.2)":"0 1px 2px rgba(0,0,0,0.05)"},children:[o.image&&(0,e.jsx)("div",{style:{marginBottom:"10px"},children:(0,e.jsx)("img",{src:o.image,alt:"Reference",onClick:()=>f(o.image),style:{width:"100%",borderRadius:"8px",cursor:"zoom-in"}})}),o.role==="assistant"?(0,e.jsxs)("div",{className:"markdown-container",children:[(0,e.jsx)(M.default,{remarkPlugins:[H.default],components:{code(r){let{children:y,className:a}=r;return a?.includes("language-")?(0,e.jsx)("pre",{style:{background:"#111827",color:"#f9fafb",padding:"14px",borderRadius:"10px",overflowX:"auto",marginTop:"10px",marginBottom:"10px",fontSize:"13px",lineHeight:1.6},children:(0,e.jsx)("code",{children:y})}):(0,e.jsx)("code",{style:{background:"#eef2ff",color:"#4338ca",padding:"2px 6px",borderRadius:"6px",fontSize:"13px",fontFamily:"monospace"},children:y})},p(r){return(0,e.jsx)("p",{style:{marginTop:"8px",marginBottom:"8px",lineHeight:1.7},children:r.children})},ul(r){return(0,e.jsx)("ul",{style:{paddingLeft:"20px",marginTop:"10px",marginBottom:"10px"},children:r.children})},ol(r){return(0,e.jsx)("ol",{style:{paddingLeft:"20px",marginTop:"10px",marginBottom:"10px"},children:r.children})},li(r){return(0,e.jsx)("li",{style:{marginBottom:"6px",lineHeight:1.6},children:r.children})},h1(r){return(0,e.jsx)("h1",{style:{fontSize:"22px",fontWeight:700,marginTop:"16px",marginBottom:"10px",color:"#111827"},children:r.children})},h2(r){return(0,e.jsx)("h2",{style:{fontSize:"18px",fontWeight:700,marginTop:"14px",marginBottom:"8px",color:"#111827"},children:r.children})},h3(r){return(0,e.jsx)("h3",{style:{fontSize:"16px",fontWeight:600,marginTop:"12px",marginBottom:"6px",color:"#111827"},children:r.children})},a(r){return(0,e.jsx)("a",{href:r.href,target:"_blank",rel:"noreferrer",style:{color:"#4f46e5",textDecoration:"underline",fontWeight:500},children:r.children})},blockquote(r){return(0,e.jsx)("blockquote",{style:{borderLeft:"4px solid #6366f1",paddingLeft:"12px",marginLeft:0,color:"#4b5563",fontStyle:"italic",marginTop:"10px",marginBottom:"10px"},children:r.children})}},children:o.content}),(o.route||o.elementId)&&(0,e.jsxs)("div",{style:{marginTop:"12px",borderTop:"1px solid #f3f4f6",paddingTop:"10px",display:"flex",gap:"8px",flexWrap:"wrap"},children:[o.route&&(0,e.jsx)("button",{onClick:()=>window.location.href=o.route,style:U,children:"Explore Page"}),o.elementId&&(0,e.jsx)("button",{onClick:()=>Y(o.route,o.elementId),style:A,children:"View"})]})]}):(0,e.jsx)("div",{style:{whiteSpace:"pre-wrap"},children:o.content})]})},o.id)),u&&(0,e.jsx)("div",{style:{fontSize:"12px",color:"#6b7280",marginLeft:"4px"},children:z||`${n} is thinking...`})]}),(0,e.jsxs)("div",{style:{padding:"16px",borderTop:"1px solid #e5e7eb",backgroundColor:"#fff"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"10px",backgroundColor:"#f3f4f6",padding:"6px 14px",borderRadius:"28px"},children:[(0,e.jsxs)("button",{style:{background:"none",border:"none",cursor:"pointer",padding:"4px",display:"flex"},onClick:()=>E.current?.click(),children:[(0,e.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"#9ca3af",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,e.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),(0,e.jsx)("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),(0,e.jsx)("polyline",{points:"21 15 16 10 5 21"})]}),(0,e.jsx)("input",{type:"file",accept:"image/*",ref:E,style:{display:"none"},onChange:o=>{let r=o.target.files?.[0];r&&(v(r),k.toast.success(`Attached: ${r.name}`))}})]}),c&&(0,e.jsxs)("div",{style:{fontSize:"11px",color:"#4f46e5",maxWidth:"80px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:["\u{1F4CE} ",c.name]}),(0,e.jsx)("input",{type:"text",value:i,onChange:o=>x(o.target.value),onKeyDown:o=>o.key==="Enter"&&R(),placeholder:"Type a message...",style:{flex:1,border:"none",background:"none",padding:"10px 0",outline:"none",fontSize:"14px",color:"#1f2937"}}),(0,e.jsx)("button",{onClick:R,disabled:!i.trim()&&!c||u,style:{background:(i.trim()||c)&&!u?"#4f46e5":"transparent",border:"none",borderRadius:"50%",width:"34px",height:"34px",display:"flex",alignItems:"center",justifyContent:"center",cursor:(i.trim()||c)&&!u?"pointer":"default",transition:"all 0.2s"},children:(0,e.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:(i.trim()||c)&&!u?"#fff":"#9ca3af",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,e.jsx)("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),(0,e.jsx)("polyline",{points:"22 2 15 22 11 13 2 9 22 2"})]})})]}),(0,e.jsxs)("div",{style:{textAlign:"center",fontSize:"11px",color:"#9ca3af",marginTop:"10px"},children:["Powered by ",(0,e.jsx)("strong",{children:"DoclessAI"})]})]})]})]})}0&&(module.exports={ChatWidget,DoclessClient});
package/dist/index.d.cts CHANGED
@@ -1,10 +1,17 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
 
3
- interface AssistantResponse {
4
- res: string;
5
- image: string | null;
6
- elementId: string | null;
3
+ interface MetaData {
7
4
  route: string | null;
5
+ elementId: string | null;
6
+ }
7
+ interface AskOptions {
8
+ query: string;
9
+ file?: File;
10
+ onText?: (chunk: string) => void;
11
+ onMeta?: (meta: MetaData) => void;
12
+ onStatus?: (message: string) => void;
13
+ onDone?: () => void;
14
+ onError?: (message: string) => void;
8
15
  }
9
16
  interface DoclessConfig {
10
17
  appKey: string;
@@ -14,7 +21,7 @@ declare class DoclessClient {
14
21
  private appKey;
15
22
  private baseUrl;
16
23
  constructor(config: DoclessConfig);
17
- ask(query: string, file?: File): Promise<AssistantResponse>;
24
+ ask(options: AskOptions): Promise<void>;
18
25
  }
19
26
 
20
27
  declare function ChatWidget({ name, appKey }: {
@@ -22,4 +29,4 @@ declare function ChatWidget({ name, appKey }: {
22
29
  appKey: string;
23
30
  }): react_jsx_runtime.JSX.Element;
24
31
 
25
- export { type AssistantResponse, ChatWidget, DoclessClient, type DoclessConfig };
32
+ export { type AskOptions, ChatWidget, DoclessClient, type DoclessConfig, type MetaData };
package/dist/index.d.ts CHANGED
@@ -1,10 +1,17 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
 
3
- interface AssistantResponse {
4
- res: string;
5
- image: string | null;
6
- elementId: string | null;
3
+ interface MetaData {
7
4
  route: string | null;
5
+ elementId: string | null;
6
+ }
7
+ interface AskOptions {
8
+ query: string;
9
+ file?: File;
10
+ onText?: (chunk: string) => void;
11
+ onMeta?: (meta: MetaData) => void;
12
+ onStatus?: (message: string) => void;
13
+ onDone?: () => void;
14
+ onError?: (message: string) => void;
8
15
  }
9
16
  interface DoclessConfig {
10
17
  appKey: string;
@@ -14,7 +21,7 @@ declare class DoclessClient {
14
21
  private appKey;
15
22
  private baseUrl;
16
23
  constructor(config: DoclessConfig);
17
- ask(query: string, file?: File): Promise<AssistantResponse>;
24
+ ask(options: AskOptions): Promise<void>;
18
25
  }
19
26
 
20
27
  declare function ChatWidget({ name, appKey }: {
@@ -22,4 +29,4 @@ declare function ChatWidget({ name, appKey }: {
22
29
  appKey: string;
23
30
  }): react_jsx_runtime.JSX.Element;
24
31
 
25
- export { type AssistantResponse, ChatWidget, DoclessClient, type DoclessConfig };
32
+ export { type AskOptions, ChatWidget, DoclessClient, type DoclessConfig, type MetaData };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{a as e,b as t}from"./chunk-YUCACKUS.js";export{t as ChatWidget,e as DoclessClient};
1
+ import{a as e,b as t}from"./chunk-LLCLTLYW.js";export{t as ChatWidget,e as DoclessClient};
package/dist/loader.cjs CHANGED
@@ -1,13 +1,64 @@
1
- "use strict";var K=Object.create;var A=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,N=Object.prototype.hasOwnProperty;var O=(n,r,s,l)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of U(r))!N.call(n,i)&&i!==s&&A(n,i,{get:()=>r[i],enumerable:!(l=q(r,i))||l.enumerable});return n};var m=(n,r,s)=>(s=n!=null?K(j(n)):{},O(r||!n||!n.__esModule?A(s,"default",{value:n,enumerable:!0}):s,n));var W=m(require("react"),1),F=m(require("react-dom/client"),1);var a=require("react");var u=class{appKey;baseUrl;constructor(r){this.appKey=r.appKey,this.baseUrl=r.baseUrl||"https://doclessai.vercel.app/api/v1"}async ask(r,s){let l=new AbortController;try{let i=new FormData;i.append("appKey",this.appKey),i.append("query",r),s&&i.append("image",s);let d=await fetch(`${this.baseUrl}/chat`,{method:"POST",signal:l.signal,headers:{"X-SDK-Name":"@doclessai/sdk","X-SDK-Version":"0.3.6"},body:i});if(!d.ok){let g=await d.json().catch(()=>({}));throw new Error(g.message||`DoclessAI Request failed with status ${d.status}`)}return await d.json()}catch(i){throw i instanceof Error&&i.name==="AbortError"?new Error("DoclessAI Error: Request timed out."):new Error(`DoclessAI Error: ${i instanceof Error?i.message:"Unknown error"}`)}}};var x=require("react-hot-toast"),T=m(require("react-markdown"),1),e=require("react/jsx-runtime"),L=n=>{if(!n)return;let r=document.getElementById(n);r&&(r.scrollIntoView({behavior:"smooth",block:"center"}),r.classList.add("docless-highlight"),setTimeout(()=>{r.classList.remove("docless-highlight")},3e3))},V=(n,r)=>{n&&window.location.pathname!==n?(window.location.href=n,setTimeout(()=>{L(r)},700)):L(r)};function b({name:n="Assistant",appKey:r}){let[s,l]=(0,a.useState)(!1),[i,d]=(0,a.useState)(""),[g,w]=(0,a.useState)([{role:"assistant",content:"Hello! How can I help you today?"}]),[p,v]=(0,a.useState)(!1),[h,k]=(0,a.useState)(null),[C,S]=(0,a.useState)(null),I=(0,a.useRef)(null),f=(0,a.useRef)(null),H=(0,a.useMemo)(()=>new u({appKey:r}),[r]);(0,a.useEffect)(()=>{f.current&&f.current.scrollTo({top:f.current.scrollHeight,behavior:"smooth"})},[g,p]);let R=async()=>{if(!i.trim()||p)return;let o=i.trim(),c=h;d(""),w(t=>[...t,{role:"user",content:o}]),v(!0);try{let t=await H.ask(o,c||void 0);k(null),w(y=>[...y,{role:"assistant",content:t.res,image:t.image,route:t.route,elementId:t.elementId}])}catch(t){x.toast.error(t?.message||"Something went wrong"),d(o)}finally{v(!1)}},M={backgroundColor:"#4f46e5",color:"white",padding:"8px 14px",borderRadius:"8px",fontSize:"13px",fontWeight:500,border:"none",cursor:"pointer"},B={backgroundColor:"#eef2ff",color:"#4338ca",padding:"8px 14px",borderRadius:"8px",fontSize:"13px",fontWeight:500,border:"1px solid #c7d2fe",cursor:"pointer"};return(0,e.jsxs)("div",{style:{fontFamily:"Inter, system-ui, sans-serif"},children:[(0,e.jsx)(x.Toaster,{position:"top-center",reverseOrder:!1}),(0,e.jsx)("style",{children:`
2
- @keyframes float { 0%, 100% { transform: translateY(0px); } 50% { transform: translateY(-5px); } }
3
- @keyframes blink { 0%, 90%, 100% { opacity: 1; } 95% { opacity: 0.3; } }
4
- @keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
5
-
6
- .chat-bubble { animation: float 2s ease-in-out infinite; }
7
- .robot-eye { animation: blink 3s ease-in-out infinite; }
1
+ "use strict";var K=Object.create;var L=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,V=Object.prototype.hasOwnProperty;var Y=(n,t,s,d)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of P(t))!V.call(n,i)&&i!==s&&L(n,i,{get:()=>t[i],enumerable:!(d=N(t,i))||d.enumerable});return n};var I=(n,t,s)=>(s=n!=null?K(j(n)):{},Y(t||!n||!n.__esModule?L(s,"default",{value:n,enumerable:!0}):s,n));var A=I(require("react"),1),F=I(require("react-dom/client"),1);var l=require("react");var T=class{appKey;baseUrl;constructor(t){this.appKey=t.appKey,this.baseUrl=t.baseUrl||"https://doclessai.vercel.app/api/v1"}async ask(t){let s=new AbortController,d="",i=null;try{let c=new FormData;c.append("appKey",this.appKey),c.append("query",t.query),t.file&&c.append("image",t.file);let h=await fetch("https://doclessai.vercel.app/api/v2/chat",{method:"POST",signal:s.signal,body:c});if(!h.ok)throw new Error(`Request failed with status ${h.status}`);if(!h.body)throw new Error("Empty response body");let m=h.body.getReader(),x=new TextDecoder,g="";for(;;){let{done:E,value:b}=await m.read();if(E)break;g+=x.decode(b,{stream:!0});let f=g.split(`
2
+
3
+ `);g=f.pop()||"";for(let v of f){if(!v.startsWith("data: "))continue;let S=v.replace("data: ","");try{let u=JSON.parse(S);switch(u.type){case"text":d+=u.chunk,i||(i=setTimeout(()=>{t.onText?.(d),d="",i=null},35));break;case"meta":t.onMeta?.({route:u.route,elementId:u.elementId});break;case"status":t.onStatus?.(u.message);break;case"done":i&&(clearTimeout(i),t.onText?.(d),d="",i=null),t.onDone?.();break;case"error":t.onError?.(u.message);break}}catch(u){console.error("Failed to parse SSE event:",u)}}}}catch(c){if(c?.name==="AbortError"){t.onError?.("Request was aborted");return}t.onError?.(c?.message||"Unknown DoclessAI error")}}};var k=require("react-hot-toast"),W=I(require("react-markdown"),1),B=I(require("remark-gfm"),1),e=require("react/jsx-runtime"),M=n=>{if(!n)return;let t=document.getElementById(n);t&&(t.scrollIntoView({behavior:"smooth",block:"center"}),t.classList.add("docless-highlight"),setTimeout(()=>{t.classList.remove("docless-highlight")},3e3))},Z=(n,t)=>{n&&window.location.pathname!==n?(window.location.href=n,setTimeout(()=>{M(t)},700)):M(t)};function R({name:n="Assistant",appKey:t}){let[s,d]=(0,l.useState)(!1),[i,c]=(0,l.useState)(""),[h,m]=(0,l.useState)([{id:crypto.randomUUID(),role:"assistant",content:"Hello! How can I help you today?"}]),[x,g]=(0,l.useState)(!1),[E,b]=(0,l.useState)(""),[f,v]=(0,l.useState)(null),[S,u]=(0,l.useState)(null),D=(0,l.useRef)(null),C=(0,l.useRef)(null),U=(0,l.useMemo)(()=>new T({appKey:t}),[t]);(0,l.useEffect)(()=>{C.current&&(C.current.scrollTop=C.current.scrollHeight)},[h,x]);let z=async()=>{if(!i.trim()&&!f||x)return;let o=i.trim(),r=f;c(""),v(null),m(a=>[...a,{id:crypto.randomUUID(),role:"user",content:o}]);let y=crypto.randomUUID();m(a=>[...a,{id:y,role:"assistant",content:""}]),g(!0);try{await U.ask({query:o,...r?{file:r}:{},onStatus(a){b(a)},onText(a){m(w=>w.map(p=>p.id===y?{...p,content:p.content+a}:p))},onMeta(a){m(w=>w.map(p=>p.id===y?{...p,route:a.route,elementId:a.elementId}:p))},onDone(){g(!1),b("")},onError(a){g(!1),b(""),k.toast.error(a),m(w=>w.map(p=>p.id===y?{...p,content:a}:p))}})}catch(a){g(!1),b(""),k.toast.error(a?.message||"Something went wrong")}},q={backgroundColor:"#4f46e5",color:"white",padding:"8px 14px",borderRadius:"8px",fontSize:"13px",fontWeight:500,border:"none",cursor:"pointer"},O={backgroundColor:"#eef2ff",color:"#4338ca",padding:"8px 14px",borderRadius:"8px",fontSize:"13px",fontWeight:500,border:"1px solid #c7d2fe",cursor:"pointer"};return(0,e.jsxs)("div",{style:{fontFamily:"Inter, system-ui, sans-serif"},children:[(0,e.jsx)(k.Toaster,{position:"top-center",reverseOrder:!1}),(0,e.jsx)("style",{children:`
4
+ @keyframes float {
5
+ 0%, 100% {
6
+ transform: translateY(0px);
7
+ }
8
+ 50% {
9
+ transform: translateY(-5px);
10
+ }
11
+ }
12
+
13
+ @keyframes blink {
14
+ 0%, 90%, 100% {
15
+ opacity: 1;
16
+ }
17
+ 95% {
18
+ opacity: 0.3;
19
+ }
20
+ }
21
+
22
+ @keyframes fadeIn {
23
+ from {
24
+ opacity: 0;
25
+ transform: translateY(10px);
26
+ }
27
+ to {
28
+ opacity: 1;
29
+ transform: translateY(0);
30
+ }
31
+ }
32
+
33
+ .chat-bubble {
34
+ animation: float 2s ease-in-out infinite;
35
+ }
36
+
37
+ .robot-eye {
38
+ animation: blink 3s ease-in-out infinite;
39
+ }
8
40
 
9
41
  .markdown-container {
10
- word-break: break-word;
42
+ line-height: 1.7;
43
+ }
44
+
45
+ .markdown-container pre {
46
+ overflow-x: auto;
47
+ }
48
+
49
+ .markdown-container code {
50
+ font-family: monospace;
51
+ }
52
+
53
+ .markdown-container table {
54
+ border-collapse: collapse;
55
+ width: 100%;
56
+ }
57
+
58
+ .markdown-container th,
59
+ .markdown-container td {
60
+ border: 1px solid #e5e7eb;
61
+ padding: 8px;
11
62
  }
12
63
 
13
64
  .markdown-container strong {
@@ -24,11 +75,17 @@
24
75
  white-space: pre-wrap;
25
76
  word-wrap: break-word;
26
77
  }
27
-
78
+
28
79
  @keyframes pulseHighlight {
29
- 0% { box-shadow: 0 0 0 0 rgba(99,102,241,0.6); }
30
- 70% { box-shadow: 0 0 0 12px rgba(99,102,241,0); }
31
- 100% { box-shadow: 0 0 0 0 rgba(99,102,241,0); }
80
+ 0% {
81
+ box-shadow: 0 0 0 0 rgba(99,102,241,0.6);
82
+ }
83
+ 70% {
84
+ box-shadow: 0 0 0 12px rgba(99,102,241,0);
85
+ }
86
+ 100% {
87
+ box-shadow: 0 0 0 0 rgba(99,102,241,0);
88
+ }
32
89
  }
33
90
 
34
91
  .docless-highlight {
@@ -36,4 +93,4 @@
36
93
  outline: 3px solid #6366f1;
37
94
  border-radius: 8px;
38
95
  }
39
- `}),C&&(0,e.jsxs)("div",{onClick:()=>S(null),style:{position:"fixed",inset:0,backgroundColor:"rgba(0,0,0,0.8)",backdropFilter:"blur(5px)",zIndex:2e4,display:"flex",alignItems:"center",justifyContent:"center",cursor:"zoom-out",padding:"20px"},children:[(0,e.jsx)("button",{style:{position:"absolute",top:"20px",right:"20px",background:"#fff",border:"none",borderRadius:"50%",width:"40px",height:"40px",cursor:"pointer",fontSize:"20px"},children:"\u2715"}),(0,e.jsx)("img",{src:C,style:{maxWidth:"100%",maxHeight:"90vh",borderRadius:"8px",boxShadow:"0 0 30px rgba(0,0,0,0.5)"},alt:"Zoomed reference"})]}),!s&&(0,e.jsx)("svg",{width:"60",height:"60",viewBox:"0 0 60 60",fill:"none",style:{cursor:"pointer",position:"fixed",bottom:"20px",right:"20px",zIndex:9999,filter:"drop-shadow(0px 4px 12px rgba(0, 0, 0, 0.15))"},onClick:()=>l(!0),children:(0,e.jsxs)("g",{className:"chat-bubble",children:[(0,e.jsx)("ellipse",{cx:"30",cy:"52",rx:"15",ry:"3",fill:"#000",opacity:"0.1"}),(0,e.jsx)("path",{d:"M45 15C45 8.37258 39.6274 3 33 3H15C8.37258 3 3 8.37258 3 15V33C3 39.6274 8.37258 45 15 45H18V52L26 45H33C39.6274 45 45 39.6274 45 33V15Z",fill:"#4F46E5"}),(0,e.jsxs)("g",{transform:"translate(12, 14)",children:[(0,e.jsx)("line",{x1:"12",y1:"0",x2:"12",y2:"3",stroke:"white",strokeWidth:"1.5",strokeLinecap:"round"}),(0,e.jsx)("circle",{cx:"12",cy:"0",r:"1.5",fill:"white"}),(0,e.jsx)("rect",{x:"6",y:"3",width:"12",height:"10",rx:"2",fill:"white"}),(0,e.jsx)("circle",{className:"robot-eye",cx:"9.5",cy:"8",r:"1.5",fill:"#4F46E5"}),(0,e.jsx)("circle",{className:"robot-eye",cx:"14.5",cy:"8",r:"1.5",fill:"#4F46E5"}),(0,e.jsx)("line",{x1:"9",y1:"11",x2:"15",y2:"11",stroke:"#4F46E5",strokeWidth:"1",strokeLinecap:"round"}),(0,e.jsx)("rect",{x:"7",y:"14",width:"10",height:"6",rx:"1",fill:"white"}),(0,e.jsx)("rect",{x:"4",y:"15",width:"2",height:"4",rx:"1",fill:"white"}),(0,e.jsx)("rect",{x:"18",y:"15",width:"2",height:"4",rx:"1",fill:"white"})]})]})}),s&&(0,e.jsxs)("div",{style:{position:"fixed",bottom:"20px",right:"20px",width:"min(400px, 90vw)",height:"min(600px, 85vh)",backgroundColor:"#fff",boxShadow:"0 12px 40px rgba(79, 70, 229, 0.25)",borderRadius:"16px",display:"flex",flexDirection:"column",zIndex:1e4,overflow:"hidden",border:"1px solid #e5e7eb",animation:"fadeIn 0.2s ease-out"},children:[(0,e.jsxs)("div",{style:{backgroundColor:"#4f46e5",padding:"14px 18px",display:"flex",alignItems:"center",justifyContent:"space-between",color:"#fff"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[(0,e.jsx)("div",{style:{width:"8px",height:"8px",backgroundColor:"#22c55e",borderRadius:"50%",boxShadow:"0 0 8px #22c55e"}}),(0,e.jsx)("span",{style:{fontWeight:600,fontSize:"15px"},children:n})]}),(0,e.jsx)("span",{style:{cursor:"pointer",fontSize:"18px",opacity:.8},onClick:()=>l(!1),children:"\u2715"})]}),(0,e.jsxs)("div",{ref:f,style:{flex:1,overflowY:"auto",padding:"16px",display:"flex",flexDirection:"column",gap:"12px",backgroundColor:"#f9fafb"},children:[g.map((o,c)=>(0,e.jsx)("div",{style:{alignSelf:o.role==="user"?"flex-end":"flex-start",maxWidth:"85%",display:"flex",flexDirection:"column",gap:"4px"},children:(0,e.jsxs)("div",{style:{backgroundColor:o.role==="user"?"#4f46e5":"#fff",color:o.role==="user"?"#fff":"#374151",padding:"12px 16px",borderRadius:"12px",fontSize:"14px",border:o.role==="user"?"none":"1px solid #e5e7eb",boxShadow:o.role==="user"?"0 2px 4px rgba(79,70,229,0.2)":"0 1px 2px rgba(0,0,0,0.05)"},children:[o.image&&(0,e.jsx)("div",{style:{marginBottom:"10px"},children:(0,e.jsx)("img",{src:o.image,onClick:()=>S(o.image),style:{width:"100%",borderRadius:"8px",cursor:"zoom-in"},alt:"Reference"})}),o.role==="assistant"?(0,e.jsxs)("div",{className:"markdown-container",children:[(0,e.jsx)(T.default,{components:{p:({children:t})=>(0,e.jsx)("p",{style:{marginBottom:"12px",lineHeight:"1.6"},children:t}),ul:({children:t})=>(0,e.jsx)("ul",{style:{listStyleType:"disc",marginLeft:"20px",marginBottom:"12px"},children:t}),ol:({children:t})=>(0,e.jsx)("ol",{style:{listStyleType:"decimal",marginLeft:"20px",marginBottom:"12px"},children:t}),li:({children:t})=>(0,e.jsx)("li",{style:{marginBottom:"4px"},children:t}),h1:({children:t})=>(0,e.jsx)("h1",{style:{fontSize:"1.25rem",fontWeight:"bold",margin:"16px 0 8px"},children:t}),h2:({children:t})=>(0,e.jsx)("h2",{style:{fontSize:"1.1rem",fontWeight:"bold",margin:"14px 0 7px"},children:t}),h3:({children:t})=>(0,e.jsx)("h3",{style:{fontSize:"1rem",fontWeight:"bold",margin:"12px 0 6px"},children:t}),code:({node:t,inline:y,className:P,children:z,...E})=>y?(0,e.jsx)("code",{style:{backgroundColor:"#f3f4f6",padding:"2px 5px",borderRadius:"4px",fontSize:"13px",color:"#e03e2d",fontFamily:"monospace"},...E,children:z}):(0,e.jsx)("div",{style:{backgroundColor:"#f8fafc",border:"1px solid #e2e8f0",borderRadius:"8px",padding:"12px",margin:"12px 0",overflowX:"auto"},children:(0,e.jsx)("code",{style:{fontSize:"13px",color:"#1e293b",fontFamily:"monospace",whiteSpace:"pre"},...E,children:z})}),blockquote:({children:t})=>(0,e.jsx)("blockquote",{style:{borderLeft:"4px solid #4f46e5",paddingLeft:"12px",color:"#4b5563",fontStyle:"italic",margin:"12px 0"},children:t}),table:({children:t})=>(0,e.jsx)("div",{style:{overflowX:"auto",margin:"12px 0"},children:(0,e.jsx)("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"13px"},children:t})}),th:({children:t})=>(0,e.jsx)("th",{style:{border:"1px solid #e5e7eb",padding:"8px",backgroundColor:"#f9fafb",textAlign:"left"},children:t}),td:({children:t})=>(0,e.jsx)("td",{style:{border:"1px solid #e5e7eb",padding:"8px"},children:t})},children:o.content}),(o.route||o.elementId)&&(0,e.jsxs)("div",{style:{marginTop:"12px",borderTop:"1px solid #f3f4f6",paddingTop:"10px",display:"flex",gap:"8px",flexWrap:"wrap"},children:[o.route&&(0,e.jsx)("button",{onClick:()=>window.location.href=o.route,style:M,children:"Explore Page"}),o.elementId&&(0,e.jsx)("button",{onClick:()=>V(o.route,o.elementId),style:B,children:"View"})]})]}):(0,e.jsx)("div",{style:{whiteSpace:"pre-wrap"},children:o.content})]})},c)),(0,e.jsx)("div",{ref:f}),p&&(0,e.jsxs)("div",{style:{fontSize:"12px",color:"#6b7280",marginLeft:"4px"},children:[n," is thinking..."]})]}),(0,e.jsxs)("div",{style:{padding:"16px",borderTop:"1px solid #e5e7eb",backgroundColor:"#fff"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"10px",backgroundColor:"#f3f4f6",padding:"6px 14px",borderRadius:"28px"},children:[(0,e.jsxs)("button",{style:{background:"none",border:"none",cursor:"pointer",padding:"4px",display:"flex"},onClick:()=>I.current?.click(),children:[(0,e.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"#9ca3af",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,e.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),(0,e.jsx)("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),(0,e.jsx)("polyline",{points:"21 15 16 10 5 21"})]}),(0,e.jsx)("input",{type:"file",accept:"image/*",ref:I,style:{display:"none"},onChange:o=>{let c=o.target.files?.[0];c&&(k(c),x.toast.success(`Attached: ${c.name}`))}})]}),h&&(0,e.jsxs)("div",{style:{fontSize:"11px",color:"#4f46e5",maxWidth:"80px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:["\u{1F4CE} ",h.name]}),(0,e.jsx)("input",{type:"text",value:i,onChange:o=>d(o.target.value),onKeyDown:o=>o.key==="Enter"&&R(),placeholder:"Type a message...",style:{flex:1,border:"none",background:"none",padding:"10px 0",outline:"none",fontSize:"14px",color:"#1f2937"}}),(0,e.jsx)("button",{onClick:R,disabled:!i.trim()||p,style:{background:i.trim()&&!p?"#4f46e5":"transparent",border:"none",borderRadius:"50%",width:"34px",height:"34px",display:"flex",alignItems:"center",justifyContent:"center",cursor:i.trim()&&!p?"pointer":"default",transition:"all 0.2s"},children:(0,e.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:i.trim()&&!p?"#fff":"#9ca3af",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,e.jsx)("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),(0,e.jsx)("polyline",{points:"22 2 15 22 11 13 2 9 22 2"})]})})]}),(0,e.jsxs)("div",{style:{textAlign:"center",fontSize:"11px",color:"#9ca3af",marginTop:"10px"},children:["Powered by ",(0,e.jsx)("strong",{children:"DoclessAI"})]})]})]})]})}var D=()=>{let n=document.querySelectorAll("script[data-app-key]"),r=n[n.length-1],s=r?.getAttribute("data-app-key")||"",l=r?.getAttribute("data-name")||"Assistant";if(!s)return;let i=document.createElement("div");i.id="docless-ai-root",document.body.appendChild(i),F.default.createRoot(i).render(W.default.createElement(b,{appKey:s,name:l}))};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",D):D();
96
+ `}),S&&(0,e.jsxs)("div",{onClick:()=>u(null),style:{position:"fixed",inset:0,backgroundColor:"rgba(0,0,0,0.8)",backdropFilter:"blur(5px)",zIndex:2e4,display:"flex",alignItems:"center",justifyContent:"center",cursor:"zoom-out",padding:"20px"},children:[(0,e.jsx)("button",{style:{position:"absolute",top:"20px",right:"20px",background:"#fff",border:"none",borderRadius:"50%",width:"40px",height:"40px",cursor:"pointer",fontSize:"20px"},children:"\u2715"}),(0,e.jsx)("img",{src:S,alt:"Zoomed reference",style:{maxWidth:"100%",maxHeight:"90vh",borderRadius:"8px",boxShadow:"0 0 30px rgba(0,0,0,0.5)"}})]}),!s&&(0,e.jsx)("svg",{width:"60",height:"60",viewBox:"0 0 60 60",fill:"none",style:{cursor:"pointer",position:"fixed",bottom:"20px",right:"20px",zIndex:9999,filter:"drop-shadow(0px 4px 12px rgba(0, 0, 0, 0.15))"},onClick:()=>d(!0),children:(0,e.jsxs)("g",{className:"chat-bubble",children:[(0,e.jsx)("ellipse",{cx:"30",cy:"52",rx:"15",ry:"3",fill:"#000",opacity:"0.1"}),(0,e.jsx)("path",{d:"M45 15C45 8.37258 39.6274 3 33 3H15C8.37258 3 3 8.37258 3 15V33C3 39.6274 8.37258 45 15 45H18V52L26 45H33C39.6274 45 45 39.6274 45 33V15Z",fill:"#4F46E5"}),(0,e.jsxs)("g",{transform:"translate(12, 14)",children:[(0,e.jsx)("line",{x1:"12",y1:"0",x2:"12",y2:"3",stroke:"white",strokeWidth:"1.5",strokeLinecap:"round"}),(0,e.jsx)("circle",{cx:"12",cy:"0",r:"1.5",fill:"white"}),(0,e.jsx)("rect",{x:"6",y:"3",width:"12",height:"10",rx:"2",fill:"white"}),(0,e.jsx)("circle",{className:"robot-eye",cx:"9.5",cy:"8",r:"1.5",fill:"#4F46E5"}),(0,e.jsx)("circle",{className:"robot-eye",cx:"14.5",cy:"8",r:"1.5",fill:"#4F46E5"}),(0,e.jsx)("line",{x1:"9",y1:"11",x2:"15",y2:"11",stroke:"#4F46E5",strokeWidth:"1",strokeLinecap:"round"}),(0,e.jsx)("rect",{x:"7",y:"14",width:"10",height:"6",rx:"1",fill:"white"}),(0,e.jsx)("rect",{x:"4",y:"15",width:"2",height:"4",rx:"1",fill:"white"}),(0,e.jsx)("rect",{x:"18",y:"15",width:"2",height:"4",rx:"1",fill:"white"})]})]})}),s&&(0,e.jsxs)("div",{style:{position:"fixed",bottom:"20px",right:"20px",width:"min(400px, 90vw)",height:"min(600px, 85vh)",backgroundColor:"#fff",boxShadow:"0 12px 40px rgba(79, 70, 229, 0.25)",borderRadius:"16px",display:"flex",flexDirection:"column",zIndex:1e4,overflow:"hidden",border:"1px solid #e5e7eb",animation:"fadeIn 0.2s ease-out"},children:[(0,e.jsxs)("div",{style:{backgroundColor:"#4f46e5",padding:"14px 18px",display:"flex",alignItems:"center",justifyContent:"space-between",color:"#fff"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[(0,e.jsx)("div",{style:{width:"8px",height:"8px",backgroundColor:"#22c55e",borderRadius:"50%",boxShadow:"0 0 8px #22c55e"}}),(0,e.jsx)("span",{style:{fontWeight:600,fontSize:"15px"},children:n})]}),(0,e.jsx)("span",{style:{cursor:"pointer",fontSize:"18px",opacity:.8},onClick:()=>d(!1),children:"\u2715"})]}),(0,e.jsxs)("div",{ref:C,style:{flex:1,overflowY:"auto",padding:"16px",display:"flex",flexDirection:"column",gap:"12px",backgroundColor:"#f9fafb"},children:[h.map(o=>(0,e.jsx)("div",{style:{alignSelf:o.role==="user"?"flex-end":"flex-start",maxWidth:"85%",display:"flex",flexDirection:"column",gap:"4px"},children:(0,e.jsxs)("div",{style:{backgroundColor:o.role==="user"?"#4f46e5":"#fff",color:o.role==="user"?"#fff":"#374151",padding:"12px 16px",borderRadius:"12px",fontSize:"14px",border:o.role==="user"?"none":"1px solid #e5e7eb",boxShadow:o.role==="user"?"0 2px 4px rgba(79,70,229,0.2)":"0 1px 2px rgba(0,0,0,0.05)"},children:[o.image&&(0,e.jsx)("div",{style:{marginBottom:"10px"},children:(0,e.jsx)("img",{src:o.image,alt:"Reference",onClick:()=>u(o.image),style:{width:"100%",borderRadius:"8px",cursor:"zoom-in"}})}),o.role==="assistant"?(0,e.jsxs)("div",{className:"markdown-container",children:[(0,e.jsx)(W.default,{remarkPlugins:[B.default],components:{code(r){let{children:y,className:a}=r;return a?.includes("language-")?(0,e.jsx)("pre",{style:{background:"#111827",color:"#f9fafb",padding:"14px",borderRadius:"10px",overflowX:"auto",marginTop:"10px",marginBottom:"10px",fontSize:"13px",lineHeight:1.6},children:(0,e.jsx)("code",{children:y})}):(0,e.jsx)("code",{style:{background:"#eef2ff",color:"#4338ca",padding:"2px 6px",borderRadius:"6px",fontSize:"13px",fontFamily:"monospace"},children:y})},p(r){return(0,e.jsx)("p",{style:{marginTop:"8px",marginBottom:"8px",lineHeight:1.7},children:r.children})},ul(r){return(0,e.jsx)("ul",{style:{paddingLeft:"20px",marginTop:"10px",marginBottom:"10px"},children:r.children})},ol(r){return(0,e.jsx)("ol",{style:{paddingLeft:"20px",marginTop:"10px",marginBottom:"10px"},children:r.children})},li(r){return(0,e.jsx)("li",{style:{marginBottom:"6px",lineHeight:1.6},children:r.children})},h1(r){return(0,e.jsx)("h1",{style:{fontSize:"22px",fontWeight:700,marginTop:"16px",marginBottom:"10px",color:"#111827"},children:r.children})},h2(r){return(0,e.jsx)("h2",{style:{fontSize:"18px",fontWeight:700,marginTop:"14px",marginBottom:"8px",color:"#111827"},children:r.children})},h3(r){return(0,e.jsx)("h3",{style:{fontSize:"16px",fontWeight:600,marginTop:"12px",marginBottom:"6px",color:"#111827"},children:r.children})},a(r){return(0,e.jsx)("a",{href:r.href,target:"_blank",rel:"noreferrer",style:{color:"#4f46e5",textDecoration:"underline",fontWeight:500},children:r.children})},blockquote(r){return(0,e.jsx)("blockquote",{style:{borderLeft:"4px solid #6366f1",paddingLeft:"12px",marginLeft:0,color:"#4b5563",fontStyle:"italic",marginTop:"10px",marginBottom:"10px"},children:r.children})}},children:o.content}),(o.route||o.elementId)&&(0,e.jsxs)("div",{style:{marginTop:"12px",borderTop:"1px solid #f3f4f6",paddingTop:"10px",display:"flex",gap:"8px",flexWrap:"wrap"},children:[o.route&&(0,e.jsx)("button",{onClick:()=>window.location.href=o.route,style:q,children:"Explore Page"}),o.elementId&&(0,e.jsx)("button",{onClick:()=>Z(o.route,o.elementId),style:O,children:"View"})]})]}):(0,e.jsx)("div",{style:{whiteSpace:"pre-wrap"},children:o.content})]})},o.id)),x&&(0,e.jsx)("div",{style:{fontSize:"12px",color:"#6b7280",marginLeft:"4px"},children:E||`${n} is thinking...`})]}),(0,e.jsxs)("div",{style:{padding:"16px",borderTop:"1px solid #e5e7eb",backgroundColor:"#fff"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"10px",backgroundColor:"#f3f4f6",padding:"6px 14px",borderRadius:"28px"},children:[(0,e.jsxs)("button",{style:{background:"none",border:"none",cursor:"pointer",padding:"4px",display:"flex"},onClick:()=>D.current?.click(),children:[(0,e.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"#9ca3af",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,e.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),(0,e.jsx)("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),(0,e.jsx)("polyline",{points:"21 15 16 10 5 21"})]}),(0,e.jsx)("input",{type:"file",accept:"image/*",ref:D,style:{display:"none"},onChange:o=>{let r=o.target.files?.[0];r&&(v(r),k.toast.success(`Attached: ${r.name}`))}})]}),f&&(0,e.jsxs)("div",{style:{fontSize:"11px",color:"#4f46e5",maxWidth:"80px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:["\u{1F4CE} ",f.name]}),(0,e.jsx)("input",{type:"text",value:i,onChange:o=>c(o.target.value),onKeyDown:o=>o.key==="Enter"&&z(),placeholder:"Type a message...",style:{flex:1,border:"none",background:"none",padding:"10px 0",outline:"none",fontSize:"14px",color:"#1f2937"}}),(0,e.jsx)("button",{onClick:z,disabled:!i.trim()&&!f||x,style:{background:(i.trim()||f)&&!x?"#4f46e5":"transparent",border:"none",borderRadius:"50%",width:"34px",height:"34px",display:"flex",alignItems:"center",justifyContent:"center",cursor:(i.trim()||f)&&!x?"pointer":"default",transition:"all 0.2s"},children:(0,e.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:(i.trim()||f)&&!x?"#fff":"#9ca3af",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,e.jsx)("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),(0,e.jsx)("polyline",{points:"22 2 15 22 11 13 2 9 22 2"})]})})]}),(0,e.jsxs)("div",{style:{textAlign:"center",fontSize:"11px",color:"#9ca3af",marginTop:"10px"},children:["Powered by ",(0,e.jsx)("strong",{children:"DoclessAI"})]})]})]})]})}var H=()=>{let n=document.querySelectorAll("script[data-app-key]"),t=n[n.length-1],s=t?.getAttribute("data-app-key")||"",d=t?.getAttribute("data-name")||"Assistant";if(!s)return;let i=document.createElement("div");i.id="docless-ai-root",document.body.appendChild(i),F.default.createRoot(i).render(A.default.createElement(R,{appKey:s,name:d}))};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",H):H();
package/dist/loader.js CHANGED
@@ -1 +1 @@
1
- import{b as a}from"./chunk-YUCACKUS.js";import c from"react";import i from"react-dom/client";var r=()=>{let e=document.querySelectorAll("script[data-app-key]"),o=e[e.length-1],n=o?.getAttribute("data-app-key")||"",d=o?.getAttribute("data-name")||"Assistant";if(!n)return;let t=document.createElement("div");t.id="docless-ai-root",document.body.appendChild(t),i.createRoot(t).render(c.createElement(a,{appKey:n,name:d}))};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",r):r();
1
+ import{b as a}from"./chunk-LLCLTLYW.js";import c from"react";import i from"react-dom/client";var r=()=>{let e=document.querySelectorAll("script[data-app-key]"),o=e[e.length-1],n=o?.getAttribute("data-app-key")||"",d=o?.getAttribute("data-name")||"Assistant";if(!n)return;let t=document.createElement("div");t.id="docless-ai-root",document.body.appendChild(t),i.createRoot(t).render(c.createElement(a,{appKey:n,name:d}))};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",r):r();