@doderasoftware/restify-ai 0.1.0-beta.9 → 0.2.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +196 -19
- package/dist/components/AiAvatar.vue.d.ts.map +1 -1
- package/dist/components/AiChatDrawer.vue.d.ts +1 -5
- package/dist/components/AiChatDrawer.vue.d.ts.map +1 -1
- package/dist/components/AiEmptyState.vue.d.ts.map +1 -1
- package/dist/components/ChatInput.vue.d.ts +4 -2
- package/dist/components/ChatInput.vue.d.ts.map +1 -1
- package/dist/components/ChatMessage.vue.d.ts.map +1 -1
- package/dist/components/ChatMessageActions.vue.d.ts.map +1 -1
- package/dist/components/ErrorBoundary.vue.d.ts.map +1 -1
- package/dist/components/LoadingIndicator.vue.d.ts +19 -0
- package/dist/components/LoadingIndicator.vue.d.ts.map +1 -0
- package/dist/components/UserAvatar.vue.d.ts.map +1 -1
- package/dist/components/drawer/ConfirmDialog.vue.d.ts.map +1 -1
- package/dist/components/drawer/DrawerHeader.vue.d.ts.map +1 -1
- package/dist/components/drawer/DrawerMessageList.vue.d.ts.map +1 -1
- package/dist/components/drawer/SetupGuide.vue.d.ts.map +1 -1
- package/dist/components/icons/IconChatBubble.vue.d.ts +3 -0
- package/dist/components/icons/IconChatBubble.vue.d.ts.map +1 -0
- package/dist/components/icons/IconCheck.vue.d.ts +3 -0
- package/dist/components/icons/IconCheck.vue.d.ts.map +1 -0
- package/dist/components/icons/IconClock.vue.d.ts +3 -0
- package/dist/components/icons/IconClock.vue.d.ts.map +1 -0
- package/dist/components/icons/IconClose.vue.d.ts +29 -0
- package/dist/components/icons/IconClose.vue.d.ts.map +1 -0
- package/dist/components/icons/IconCopy.vue.d.ts +3 -0
- package/dist/components/icons/IconCopy.vue.d.ts.map +1 -0
- package/dist/components/icons/IconDocument.vue.d.ts +3 -0
- package/dist/components/icons/IconDocument.vue.d.ts.map +1 -0
- package/dist/components/icons/IconExitFullscreen.vue.d.ts +3 -0
- package/dist/components/icons/IconExitFullscreen.vue.d.ts.map +1 -0
- package/dist/components/icons/IconFullscreen.vue.d.ts +3 -0
- package/dist/components/icons/IconFullscreen.vue.d.ts.map +1 -0
- package/dist/components/icons/IconMinimize.vue.d.ts +3 -0
- package/dist/components/icons/IconMinimize.vue.d.ts.map +1 -0
- package/dist/components/icons/IconPaperclip.vue.d.ts +3 -0
- package/dist/components/icons/IconPaperclip.vue.d.ts.map +1 -0
- package/dist/components/icons/IconQuestionCircle.vue.d.ts +29 -0
- package/dist/components/icons/IconQuestionCircle.vue.d.ts.map +1 -0
- package/dist/components/icons/IconRefresh.vue.d.ts +3 -0
- package/dist/components/icons/IconRefresh.vue.d.ts.map +1 -0
- package/dist/components/icons/IconSend.vue.d.ts +3 -0
- package/dist/components/icons/IconSend.vue.d.ts.map +1 -0
- package/dist/components/icons/IconSparkles.vue.d.ts +3 -0
- package/dist/components/icons/IconSparkles.vue.d.ts.map +1 -0
- package/dist/components/icons/IconStop.vue.d.ts +3 -0
- package/dist/components/icons/IconStop.vue.d.ts.map +1 -0
- package/dist/components/icons/IconSupport.vue.d.ts +3 -0
- package/dist/components/icons/IconSupport.vue.d.ts.map +1 -0
- package/dist/components/icons/IconUser.vue.d.ts +3 -0
- package/dist/components/icons/IconUser.vue.d.ts.map +1 -0
- package/dist/components/icons/IconWarning.vue.d.ts +17 -0
- package/dist/components/icons/IconWarning.vue.d.ts.map +1 -0
- package/dist/components/icons/index.d.ts +19 -0
- package/dist/components/icons/index.d.ts.map +1 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/input/AttachmentsPreview.vue.d.ts.map +1 -1
- package/dist/components/input/InputActions.vue.d.ts.map +1 -1
- package/dist/composables/index.d.ts +2 -0
- package/dist/composables/index.d.ts.map +1 -1
- package/dist/composables/useAiSuggestions.d.ts.map +1 -1
- package/dist/composables/useAutoScroll.d.ts +7 -0
- package/dist/composables/useAutoScroll.d.ts.map +1 -0
- package/dist/composables/useChatInput.d.ts +3 -2
- package/dist/composables/useChatInput.d.ts.map +1 -1
- package/dist/composables/useSuggestionFilter.d.ts +12 -0
- package/dist/composables/useSuggestionFilter.d.ts.map +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/restify-ai.js +2916 -2723
- package/dist/restify-ai.umd.cjs +34 -34
- package/dist/store/store.d.ts +5 -3
- package/dist/store/store.d.ts.map +1 -1
- package/dist/store/utils.d.ts +1 -1
- package/dist/store/utils.d.ts.map +1 -1
- package/dist/style.css +1 -1
- package/dist/types/api.d.ts +8 -6
- package/dist/types/api.d.ts.map +1 -1
- package/dist/types/chat.d.ts +1 -0
- package/dist/types/chat.d.ts.map +1 -1
- package/dist/types/config.d.ts +5 -0
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/texts.d.ts +1 -0
- package/dist/types/texts.d.ts.map +1 -1
- package/dist/types/ui.d.ts +1 -0
- package/dist/types/ui.d.ts.map +1 -1
- package/dist/utils/fileHelpers.d.ts +11 -0
- package/dist/utils/fileHelpers.d.ts.map +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/package.json +10 -8
- package/tailwind.config.cjs +1 -30
- package/dist/composables/useSuggestions.d.ts +0 -2
- package/dist/composables/useSuggestions.d.ts.map +0 -1
package/dist/restify-ai.umd.cjs
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
`+p:p;break;case"event":o.event=p;break;case"id":r(o.id=p);break;case"retry":const f=parseInt(p,10);isNaN(f)||t(o.retry=f);break}}}}function Sr(r,t){const n=new Uint8Array(r.length+t.length);return n.set(r),n.set(t,r.length),n}function nn(){return{data:"",event:"",id:"",retry:void 0}}var Tr=function(r,t){var n={};for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&t.indexOf(o)<0&&(n[o]=r[o]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,o=Object.getOwnPropertySymbols(r);s<o.length;s++)t.indexOf(o[s])<0&&Object.prototype.propertyIsEnumerable.call(r,o[s])&&(n[o[s]]=r[o[s]]);return n};const St="text/event-stream",Ar=1e3,rn="last-event-id";function Mr(r,t){var{signal:n,headers:o,onopen:s,onmessage:a,onclose:i,onerror:l,openWhenHidden:u,fetch:d}=t,p=Tr(t,["signal","headers","onopen","onmessage","onclose","onerror","openWhenHidden","fetch"]);return new Promise((f,k)=>{const g=Object.assign({},o);g.accept||(g.accept=St);let m;function E(){m.abort(),document.hidden||z()}u||document.addEventListener("visibilitychange",E);let y=Ar,h=0;function b(){document.removeEventListener("visibilitychange",E),window.clearTimeout(h),m.abort()}n==null||n.addEventListener("abort",()=>{b(),f()});const C=d??window.fetch,w=s??Nr;async function z(){var $;m=new AbortController;try{const F=await C(r,Object.assign(Object.assign({},p),{headers:g,signal:m.signal}));await w(F),await br(F.body,Er(Cr(S=>{S?g[rn]=S:delete g[rn]},S=>{y=S},a))),i==null||i(),b(),f()}catch(F){if(!m.signal.aborted)try{const S=($=l==null?void 0:l(F))!==null&&$!==void 0?$:y;window.clearTimeout(h),h=window.setTimeout(z,S)}catch(S){b(),k(S)}}}z()})}function Nr(r){const t=r.headers.get("content-type");if(!(t!=null&&t.startsWith(St)))throw new Error(`Expected content-type to be ${St}, Actual: ${t}`)}function nt(r){if(!r)throw console.error("[RestifyAi] Endpoint is undefined. Check your endpoints configuration."),new Error("AI service endpoint is not configured. Please contact support.");const t=q(),n=(t==null?void 0:t.baseUrl)||"";if(!n||r.startsWith("http://")||r.startsWith("https://"))return r;const o=n.endsWith("/")?n.slice(0,-1):n,s=r.startsWith("/")?r:`/${r}`;return`${o}${s}`}function Rr(r){const n=(r instanceof Error?r.message:String(r)).toLowerCase();return n.includes("failed to fetch")||n.includes("network")||n.includes("fetch")?"Unable to connect to the AI service. Please check your internet connection and try again.":n.includes("500")||n.includes("internal server error")?"The AI service is temporarily unavailable. Please try again in a few moments.":n.includes("timeout")||n.includes("timed out")?"The request took too long. Please try again.":n.includes("401")||n.includes("unauthorized")||n.includes("authentication")?"Your session has expired. Please refresh the page and try again.":n.includes("429")||n.includes("rate limit")||n.includes("too many requests")?"Too many requests. Please wait a moment before trying again.":n.includes("cors")||n.includes("cross-origin")?"Unable to connect to the AI service. Please contact support.":n.includes("endpoint is not configured")?"AI service endpoint is not configured. Please contact support.":"Something went wrong. Please try again later."}function Br(r){var t,n,o;try{if(r==="[DONE]")return"[DONE]";const s=JSON.parse(r);return((o=(n=(t=s==null?void 0:s.choices)==null?void 0:t[0])==null?void 0:n.delta)==null?void 0:o.content)||""}catch{return null}}function Lr(r){return new Promise(t=>setTimeout(t,r))}function Dr(r){const t={};return r.forEach(n=>{var o;(o=n.attachments)==null||o.forEach(s=>{s!=null&&s.id&&(t[s.id]=s)})}),t}function Ee(r){const t=q();return r==="chatHistory"?(t==null?void 0:t.chatHistoryKey)||"restify_ai_chat_history":r==="setupComplete"?"restify_ai_setup_complete":(t==null?void 0:t.drawerStateKey)||"restify_ai_drawer_open"}function rt(r){try{sessionStorage.setItem(Ee("chatHistory"),JSON.stringify(r))}catch(t){console.warn("[RestifyAi] Failed to save chat history:",t)}}function Ir(){try{const r=sessionStorage.getItem(Ee("chatHistory"));if(r){const t=JSON.parse(r),n=t.filter(a=>{var i;return!(a.role===Ae.Assistant&&a.loading||a.role===Ae.Assistant&&!((i=a.message)!=null&&i.trim()))}).map(a=>({...a,streaming:!1,loading:!1}));n.length!==t.length&&sessionStorage.setItem(Ee("chatHistory"),JSON.stringify(n));const o=n[n.length-1],s=(o==null?void 0:o.role)===Ae.User;return{history:n,hasOrphanedUserMessage:s,orphanedMessage:s?{question:o.message,attachments:o.attachments||[]}:void 0}}}catch(r){console.warn("[RestifyAi] Failed to load chat history:",r)}return{history:[],hasOrphanedUserMessage:!1}}function zr(){try{sessionStorage.removeItem(Ee("chatHistory"))}catch(r){console.warn("[RestifyAi] Failed to clear chat history:",r)}}function $r(r){try{r.message||r.failedQuestion?sessionStorage.setItem("restify_ai_error_state",JSON.stringify(r)):sessionStorage.removeItem("restify_ai_error_state")}catch(t){console.warn("[RestifyAi] Failed to save error state:",t)}}function Or(){try{const r=sessionStorage.getItem("restify_ai_error_state");if(r)return JSON.parse(r)}catch(r){console.warn("[RestifyAi] Failed to load error state:",r)}return null}function Vr(){try{sessionStorage.removeItem("restify_ai_error_state")}catch(r){console.warn("[RestifyAi] Failed to clear error state:",r)}}function Tt(r){try{localStorage.setItem(Ee("drawerState"),JSON.stringify(r))}catch(t){console.warn("[RestifyAi] Failed to save drawer state:",t)}}function Pr(){try{const r=localStorage.getItem(Ee("drawerState"));if(r!==null)return JSON.parse(r)}catch(r){console.warn("[RestifyAi] Failed to load drawer state:",r)}return!1}function _r(){try{return localStorage.getItem(Ee("setupComplete"))==="true"}catch{return!1}}function on(){try{localStorage.setItem(Ee("setupComplete"),"true")}catch(r){console.warn("[RestifyAi] Failed to mark setup complete:",r)}}function sn(){return{isActive:!1,currentStep:"welcome",testApiKey:null,connectionStatus:"idle",backendConfigured:!1,lastError:null}}let He=new AbortController;const Ce=Ie.defineStore("restifyAiStore",{state:()=>{const r=Ir(),t=Or();let n={message:null,failedQuestion:null,failedAttachments:null,timestamp:null,quotaExceeded:!1};return t!=null&&t.message?n={message:t.message,failedQuestion:t.failedQuestion,failedAttachments:t.failedAttachments,timestamp:Date.now(),quotaExceeded:!1}:r.hasOrphanedUserMessage&&r.orphanedMessage&&(n={message:"Previous request failed. Click retry to try again.",failedQuestion:r.orphanedMessage.question,failedAttachments:r.orphanedMessage.attachments,timestamp:Date.now(),quotaExceeded:!1}),{chatHistoryLimit:Te("chatHistoryLimit")||20,chatHistory:r.history,uploadedFiles:Dr(r.history),loading:!1,showChat:Pr(),isFullscreen:!1,sending:!1,pageContext:null,quota:{limit:100,used:0,remaining:100},error:n,supportRequestMode:!1,setupState:!Ct()&&!_r()?{...sn(),isActive:!0}:sn()}},getters:{hasMessages:r=>r.chatHistory.length>0,isInSetupMode:r=>r.setupState.isActive,canChat:r=>!r.setupState.isActive||r.setupState.connectionStatus==="connected"},actions:{async scrollToBottom(){await e.nextTick();const r=document.getElementById("rai-chat-bottom");r&&r.scrollIntoView({behavior:"smooth"})},parseStreamContent(r){const t=q(),n=t==null?void 0:t.parseStreamContent;return n?n(r.data):Br(r.data)},async askQuestion(r,t=[],n=[],o=!1){var g;const s=q();if(!s)return console.warn("[RestifyAi] Cannot ask question - plugin not configured"),!1;let a="",i=!1;const l=s.retry||{},u=l.maxRetries??0,d=l.retryDelay??1e3;let p=0;const f=t.map(m=>({id:m.id,name:m.name,url:m.url,type:m.type,size:m.size,extractedText:m.extractedText}));this.chatHistory.push({id:crypto.randomUUID(),role:Ae.User,message:r,loading:!1,attachments:f,mentions:n,timestamp:Date.now()}),f.forEach(m=>this.registerUploadedFile(m)),rt(this.chatHistory),this.sending=!0,this.chatHistory.length>=this.chatHistoryLimit&&((g=s.onError)==null||g.call(s,new Error("Chat history limit reached")));const k=async()=>{var m,E,y;try{const h=this.chatHistory.map(M=>({role:M.role,message:M.message,attachments:M.attachments??[]})),b={},C=M=>{M!=null&&M.id&&(b[M.id]={extracted_text:M.extractedText||"",file_name:M.name,mime_type:M.type||"",...M.size?{file_size:M.size}:{},...M.url?{file_url:M.url}:{}})};Object.values(this.uploadedFiles).forEach(C),this.chatHistory.forEach(M=>{var Q;return(Q=M.attachments)==null?void 0:Q.forEach(C)}),f.forEach(C);const w=Object.values(b),z=this.chatHistory.length;this.chatHistory.push({id:crypto.randomUUID(),role:Ae.Assistant,message:"",loading:!0,timestamp:Date.now()}),rt(this.chatHistory),He=new AbortController;const $=await s.getAuthToken(),S={"Content-Type":"application/json",Accept:"application/vnd.api+json",...s.getCustomHeaders?await s.getCustomHeaders():{}};this.setupState.isActive&&this.setupState.testApiKey?S["X-Test-Api-Key"]=this.setupState.testApiKey:$&&(S.Authorization=`Bearer ${$}`);let T={question:r,history:h,stream:!0,...w.length>0&&{files:w},...n.length>0&&{mentions:n},...this.supportRequestMode&&{contact_support:!0}};s.beforeSend&&(T=await s.beforeSend(T)),s.buildRequest&&(T=await s.buildRequest(T)),(m=s.onMessageSent)==null||m.call(s,this.chatHistory[z-1]);const N=nt(s.endpoints.ask);let D={method:"POST",body:JSON.stringify(T),headers:S};return s.requestInterceptor&&(D=await s.requestInterceptor(N,D)),(E=s.onStreamStart)==null||E.call(s),await Mr(N,{method:"POST",body:JSON.stringify(T),signal:He.signal,headers:D.headers,openWhenHidden:!0,async onopen(M){if(!M.ok){if(M.status===429){const Q=Ce();throw Q.error={message:J("noQuota"),failedQuestion:r,failedAttachments:f,timestamp:Date.now(),quotaExceeded:!0},await Q.fetchQuota(),new Error("Quota exceeded")}throw new Error(`Failed to connect: ${M.status}`)}},onmessage:async M=>{var Re,ye,Be;const Q=this.parseStreamContent(M);if(!Q)return;this.chatHistory[z].loading=!1;const fe={content:Q,done:Q==="[DONE]",raw:M.data};(Re=s.onStreamChunk)==null||Re.call(s,fe),a?Q==="[DONE]"?(this.chatHistory[z].streaming=!1,rt(this.chatHistory),(ye=s.onStreamEnd)==null||ye.call(s,a),this.quota.remaining>0&&!this.supportRequestMode&&(this.quota.remaining--,this.quota.used++,this.quota.remaining===0&&s.enableSupportMode!==!1&&(this.supportRequestMode=!0)),this.supportRequestMode&&this.quota.remaining>0&&(this.supportRequestMode=!1),s.afterResponse&&await s.afterResponse(this.chatHistory[z]),(Be=s.onResponseReceived)==null||Be.call(s,this.chatHistory[z])):(a+=Q,this.chatHistory[z].message=a):(a=Q,this.chatHistory[z].message=a,this.chatHistory[z].streaming=!0),await this.scrollToBottom()},onerror(M){throw i=!0,M}}),!0}catch(h){i=!0;const b=this.chatHistory.length-1;return this.chatHistory.splice(b,1),h.name==="AbortError"?!0:p<u&&(l.shouldRetry?l.shouldRetry(h,p):!0)?(p++,await Lr(d*p),k()):(this.error={message:Rr(h),failedQuestion:r,failedAttachments:f,timestamp:Date.now()},$r({message:this.error.message,failedQuestion:this.error.failedQuestion,failedAttachments:this.error.failedAttachments||null}),(y=s.onError)==null||y.call(s,h),!1)}finally{this.sending=!1}};return k()},cancelRequest(){He==null||He.abort(),this.chatHistory=this.chatHistory.map(r=>({...r,streaming:!1,loading:!1})),this.sending=!1},clearChatHistory(){var t;const r=q();this.chatHistory=[],this.sending=!1,this.uploadedFiles={},this.clearError(),this.quota.remaining>0&&(this.supportRequestMode=!1),zr(),(t=r==null?void 0:r.onNewChat)==null||t.call(r)},async retry(){if(!this.error.failedQuestion)return!1;const r=this.error.failedQuestion,t=this.error.failedAttachments||[],n=this.chatHistory[this.chatHistory.length-1];return(n==null?void 0:n.role)===Ae.User&&n.message===r&&(this.chatHistory.pop(),rt(this.chatHistory)),this.clearError(),await this.askQuestion(r,t)},clearError(){this.error={message:null,failedQuestion:null,failedAttachments:null,timestamp:null,quotaExceeded:!1},Vr()},toggleSupportMode(){this.supportRequestMode=!this.supportRequestMode},async fetchQuota(){var t,n;const r=q();if((t=r==null?void 0:r.endpoints)!=null&&t.quota)try{const o=await r.getAuthToken(),s=r.getCustomHeaders?await r.getCustomHeaders():{},a=nt(r.endpoints.quota),i=await fetch(a,{headers:{Accept:"application/json",...o?{Authorization:`Bearer ${o}`}:{},...s}});if(i.ok){const l=await i.json(),u=l.data??l;this.quota={limit:u.limit??this.quota.limit,used:u.used??this.quota.used,remaining:u.remaining??this.quota.remaining},this.quota.remaining===0&&r.enableSupportMode!==!1&&(this.supportRequestMode=!0),(n=r.onQuotaFetched)==null||n.call(r,this.quota)}}catch(o){console.error("[RestifyAi] Failed to fetch quota:",o)}},async uploadFile(r){var s,a,i,l,u;const t=q();if(!((s=t==null?void 0:t.endpoints)!=null&&s.uploadFile))return console.warn("[RestifyAi] No uploadFile endpoint configured"),null;const o={id:crypto.randomUUID(),name:r.name,type:r.type,size:r.size,uploading:!0,progress:0};(a=t.onFileUploadStart)==null||a.call(t,o);try{const d=await t.getAuthToken(),p=t.getCustomHeaders?await t.getCustomHeaders():{},f=nt(t.endpoints.uploadFile),k=new FormData;k.append("file",r);const g=await new Promise((m,E)=>{const y=new XMLHttpRequest;y.upload.addEventListener("progress",h=>{var b;if(h.lengthComputable){const C=Math.round(h.loaded/h.total*100);o.progress=C,(b=t.onFileUploadProgress)==null||b.call(t,o,C)}}),y.addEventListener("load",()=>{var h,b;if(y.status>=200&&y.status<300)try{const C=JSON.parse(y.responseText),w={...o,url:C.url||((h=C.data)==null?void 0:h.url),extractedText:C.extracted_text||((b=C.data)==null?void 0:b.extracted_text),uploading:!1,progress:100};m(w)}catch{E(new Error("Failed to parse upload response"))}else E(new Error(`Upload failed: ${y.status}`))}),y.addEventListener("error",()=>E(new Error("Upload failed"))),y.open("POST",f),d&&y.setRequestHeader("Authorization",`Bearer ${d}`),Object.entries(p).forEach(([h,b])=>y.setRequestHeader(h,b)),y.send(k)});return(i=t.onFileUploadComplete)==null||i.call(t,g),g}catch(d){const p={...o,uploading:!1};return(l=t.onFileUploadError)==null||l.call(t,p,d),(u=t.onError)==null||u.call(t,d),null}},setPageContext(r){this.pageContext=r},toggleDrawer(){var r,t;this.showChat=!this.showChat,Tt(this.showChat),(t=(r=q())==null?void 0:r.onDrawerToggle)==null||t.call(r,this.showChat)},openDrawer(){var r,t;this.showChat=!0,Tt(!0),(t=(r=q())==null?void 0:r.onDrawerToggle)==null||t.call(r,!0)},closeDrawer(){var r,t;this.showChat=!1,Tt(!1),(t=(r=q())==null?void 0:r.onDrawerToggle)==null||t.call(r,!1)},startSupportRequest(){this.supportRequestMode=!0},cancelSupportRequest(){this.quota.remaining>0&&(this.supportRequestMode=!1)},registerUploadedFile(r){r!=null&&r.id&&(this.uploadedFiles[r.id]={...r})},startSetupMode(){this.setupState={isActive:!0,currentStep:"welcome",testApiKey:null,connectionStatus:"idle",backendConfigured:!1,lastError:null}},setSetupStep(r){this.setupState.currentStep=r},setTestApiKey(r){this.setupState.testApiKey=r},async testConnection(){this.setupState.connectionStatus="testing",this.setupState.lastError=null;const r=q();if(!r)return this.setupState.connectionStatus="failed",this.setupState.lastError="Plugin not configured",!1;try{const t={"Content-Type":"application/json",Accept:"application/json"};this.setupState.testApiKey&&(t["X-Test-Api-Key"]=this.setupState.testApiKey);const n=r.endpoints.quota||r.endpoints.ask,o=nt(n),s=await fetch(o,{method:r.endpoints.quota?"GET":"POST",headers:t,...r.endpoints.quota?{}:{body:JSON.stringify({question:"test",stream:!1})}});return s.ok?(this.setupState.connectionStatus="connected",this.setupState.backendConfigured=!0,!0):(this.setupState.connectionStatus="failed",this.setupState.lastError=`Connection failed: ${s.status} ${s.statusText}`,!1)}catch(t){return this.setupState.connectionStatus="failed",this.setupState.lastError=t.message||"Connection failed",!1}},completeSetup(){var r,t;this.setupState.isActive=!1,this.setupState.currentStep="complete",on(),(t=(r=q())==null?void 0:r.onSetupComplete)==null||t.call(r)},skipSetup(){this.setupState.isActive=!1,on()}}});function an(r){const t=/@\[([^\]]+)\]\(([^)]+)\)/g,n=[];let o=r,s;for(;(s=t.exec(r))!==null;){const[a,i,l]=s,[u,d]=l.includes(":")?l.split(":"):["default",l];n.push({id:d,name:i,type:u}),o=o.replace(a,i)}return{cleanText:o,mentions:n}}function Fr(r){const{cleanText:t}=an(r);return t}function ln(r){return r.replace(/@([A-Z][a-z]+(?:\s+[A-Z][a-z]+)*)/g,'<span class="rai-mention">@$1</span>')}function cn(r,t){const o=r.substring(0,t).match(/@(\w*)$/);return o?{inMention:!0,query:o[1],startPos:t-o[0].length}:{inMention:!1,query:"",startPos:-1}}function At(r,t){var n,o;return t!=null&&t.getDisplayName?t.getDisplayName(r):r.name||r.title||((n=r.attributes)==null?void 0:n.name)||((o=r.attributes)==null?void 0:o.title)||"Unknown"}function un(r,t){var n,o;return t!=null&&t.getSubtitle?t.getSubtitle(r):((n=r.attributes)==null?void 0:n.email)||((o=r.attributes)==null?void 0:o.description)||null}function Hr(r,t){return t!=null&&t.buildMentionText?t.buildMentionText(r):`@[${At(r,t)}](${r.type}:${r.id})`}function dn(r){var n;const t=q();return(n=t==null?void 0:t.mentionProviders)==null?void 0:n.find(o=>o.type===r)}function pn(r){const t=q(),n=(t==null?void 0:t.mentionProviders)||[];return r?n.filter(o=>o.routes?o.routes.some(s=>s.endsWith("*")?r.startsWith(s.slice(0,-1)):r===s||r.startsWith(s+"/")):!0):n}function fn(r){return r.map(t=>({type:t.type,id:t.id,name:t.name}))}function mn(r){return r.reduce((t,n)=>{const o=n.type||"default";return t[o]||(t[o]=[]),t[o].push(n),t},{})}function Ur(){return{extractMentions:an,parseAndCleanMessage:Fr,renderMentionsInHtml:ln,detectMentionContext:cn,getMentionDisplayName:At,getMentionSubtitle:un,buildMentionText:Hr,getMentionProvider:dn,getActiveMentionProviders:pn,formatMentionsForApi:fn,groupMentionsByType:mn}}function Mt(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let Me=Mt();function hn(r){Me=r}const gn=/[&<>"']/,qr=new RegExp(gn.source,"g"),yn=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,vr=new RegExp(yn.source,"g"),jr={"&":"&","<":"<",">":">",'"':""","'":"'"},kn=r=>jr[r];function ie(r,t){if(t){if(gn.test(r))return r.replace(qr,kn)}else if(yn.test(r))return r.replace(vr,kn);return r}const Wr=/(^|[^\[])\^/g;function V(r,t){let n=typeof r=="string"?r:r.source;t=t||"";const o={replace:(s,a)=>{let i=typeof a=="string"?a:a.source;return i=i.replace(Wr,"$1"),n=n.replace(s,i),o},getRegex:()=>new RegExp(n,t)};return o}function xn(r){try{r=encodeURI(r).replace(/%25/g,"%")}catch{return null}return r}const Ue={exec:()=>null};function wn(r,t){const n=r.replace(/\|/g,(a,i,l)=>{let u=!1,d=i;for(;--d>=0&&l[d]==="\\";)u=!u;return u?"|":" |"}),o=n.split(/ \|/);let s=0;if(o[0].trim()||o.shift(),o.length>0&&!o[o.length-1].trim()&&o.pop(),t)if(o.length>t)o.splice(t);else for(;o.length<t;)o.push("");for(;s<o.length;s++)o[s]=o[s].trim().replace(/\\\|/g,"|");return o}function qe(r,t,n){const o=r.length;if(o===0)return"";let s=0;for(;s<o&&r.charAt(o-s-1)===t;)s++;return r.slice(0,o-s)}function Kr(r,t){if(r.indexOf(t[1])===-1)return-1;let n=0;for(let o=0;o<r.length;o++)if(r[o]==="\\")o++;else if(r[o]===t[0])n++;else if(r[o]===t[1]&&(n--,n<0))return o;return-1}function bn(r,t,n,o){const s=t.href,a=t.title?ie(t.title):null,i=r[1].replace(/\\([\[\]])/g,"$1");if(r[0].charAt(0)!=="!"){o.state.inLink=!0;const l={type:"link",raw:n,href:s,title:a,text:i,tokens:o.inlineTokens(i)};return o.state.inLink=!1,l}return{type:"image",raw:n,href:s,title:a,text:ie(i)}}function Gr(r,t){const n=r.match(/^(\s+)(?:```)/);if(n===null)return t;const o=n[1];return t.split(`
|
|
1
|
+
(function(R,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("pinia")):typeof define=="function"&&define.amd?define(["exports","vue","pinia"],e):(R=typeof globalThis<"u"?globalThis:R||self,e(R.RestifyAi={},R.Vue,R.Pinia))})(this,function(R,e,De){"use strict";var Oi=Object.defineProperty;var Pi=(R,e,De)=>e in R?Oi(R,e,{enumerable:!0,configurable:!0,writable:!0,value:De}):R[e]=De;var q=(R,e,De)=>Pi(R,typeof e!="symbol"?e+"":e,De);let Ne=null;const Mr=e.ref(null),Bt={title:"AI Assistant",aiName:"AI Assistant",you:"You",newChat:"New chat",placeholder:"Ask me anything...",inputPlaceholder:"Ask me anything...",supportPlaceholder:"Describe your support request...",loadingText:"Thinking...",analyzingText:"Analyzing...",craftingText:"Crafting response...",quotaRemaining:"{count} questions remaining",noQuota:"No AI credit available",rateLimitExceeded:"Rate limit exceeded. Please try again in a moment.",contactSupport:"Contact Support",close:"Close",minimize:"Minimize",fullscreen:"Fullscreen",exitFullscreen:"Exit fullscreen",copyToClipboard:"Copy to clipboard",copied:"Copied!",showMore:"Show more",showLess:"Show less",retry:"Retry",attachFiles:"Attach files",emptyStateTitle:"How can I help you today?",emptyStateDescription:"Ask me anything or choose a suggestion below",keyboardShortcutHint:"Press ⌘G to toggle",sendMessage:"Send message",attachFile:"Attach file",closeConfirmTitle:"Close conversation?",closeConfirmMessage:"This will clear your chat history. Are you sure you want to close?",confirmClose:"Close & Clear",cancel:"Cancel",toggleSupportMode:"Toggle support mode",exitSupportMode:"Exit support mode",historyLimitWarningTitle:"Approaching Chat Limit",historyLimitWarningMessage:"You are approaching the maximum number of messages in this conversation.",historyLimitReachedTitle:"Chat Limit Reached",historyLimitReachedMessage:"You have reached the maximum number of messages. Start a new chat to continue.",startNewChat:"Start New Chat",continueChat:"Continue",setupWelcomeTitle:"Welcome to AI Assistant",setupWelcomeDescription:"Let's get you set up to start using AI features.",setupApiKeyTitle:"API Key Configuration",setupApiKeyDescription:"Enter your API key to test the connection",setupTestingTitle:"Testing Connection...",setupBackendTitle:"Backend Configuration",setupBackendDescription:"Configure your backend endpoint",setupCompleteTitle:"Setup Complete!"};function ln(r){Ne=r,Mr.value=r}function K(){return Ne}function Br(){if(!Ne)throw new Error("[restify-ai] Plugin not initialized. Make sure to call app.use(RestifyAiPlugin, config) before using the components.");return Ne}function Nt(){return Ne!==null}function te(r,t){const n=Ne,o=(n==null?void 0:n.labels)||{},s=n==null?void 0:n.translate;if(s){const i=s(r,t);if(i!==r)return i}let a=o[r]||Bt[r];return t&&Object.entries(t).forEach(([i,l])=>{a=a.replace(`{${i}}`,String(l))}),a}function cn(r){return{chatHistoryLimit:15,maxAttachments:5,maxFileSize:10485760,acceptedFileTypes:"image/*,.pdf,.txt,.doc,.docx,.xls,.xlsx,.csv",chatHistoryKey:"restify_ai_chat_history",drawerStateKey:"restify_ai_drawer_open",keyboardShortcut:"cmd+g",enableSupportMode:!1}[r]}function ke(r){const t=Ne;return t?t[r]??cn(r):cn(r)}function it(r){return(r.type||"").startsWith("image/")?!0:/(png|jpe?g|gif|webp)$/i.test(r.name||"")}function lt(r){if(r==null)return"";const t=typeof r=="string"?parseInt(r,10):r;return Number.isNaN(t)?"":t>=1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:t>=1024?`${Math.round(t/1024)} KB`:`${t} B`}const Re={Assistant:"assistant",User:"user",System:"system"};async function Nr(r,t){const n=r.getReader();let o;for(;!(o=await n.read()).done;)t(o.value)}function Rr(r){let t,n,o,s=!1;return function(i){t===void 0?(t=i,n=0,o=-1):t=Lr(t,i);const l=t.length;let u=0;for(;n<l;){s&&(t[n]===10&&(u=++n),s=!1);let d=-1;for(;n<l&&d===-1;++n)switch(t[n]){case 58:o===-1&&(o=n-u);break;case 13:s=!0;case 10:d=n;break}if(d===-1)break;r(t.subarray(u,d),o),u=n,o=-1}u===l?t=void 0:u!==0&&(t=t.subarray(u),n-=u)}}function _r(r,t,n){let o=un();const s=new TextDecoder;return function(i,l){if(i.length===0)n==null||n(o),o=un();else if(l>0){const u=s.decode(i.subarray(0,l)),d=l+(i[l+1]===32?2:1),m=s.decode(i.subarray(d));switch(u){case"data":o.data=o.data?o.data+`
|
|
2
|
+
`+m:m;break;case"event":o.event=m;break;case"id":r(o.id=m);break;case"retry":const h=parseInt(m,10);isNaN(h)||t(o.retry=h);break}}}}function Lr(r,t){const n=new Uint8Array(r.length+t.length);return n.set(r),n.set(t,r.length),n}function un(){return{data:"",event:"",id:"",retry:void 0}}var Ir=function(r,t){var n={};for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&t.indexOf(o)<0&&(n[o]=r[o]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,o=Object.getOwnPropertySymbols(r);s<o.length;s++)t.indexOf(o[s])<0&&Object.prototype.propertyIsEnumerable.call(r,o[s])&&(n[o[s]]=r[o[s]]);return n};const Rt="text/event-stream",$r=1e3,dn="last-event-id";function Dr(r,t){var{signal:n,headers:o,onopen:s,onmessage:a,onclose:i,onerror:l,openWhenHidden:u,fetch:d}=t,m=Ir(t,["signal","headers","onopen","onmessage","onclose","onerror","openWhenHidden","fetch"]);return new Promise((h,g)=>{const y=Object.assign({},o);y.accept||(y.accept=Rt);let f;function S(){f.abort(),document.hidden||I()}u||document.addEventListener("visibilitychange",S);let p=$r,w=0;function M(){document.removeEventListener("visibilitychange",S),window.clearTimeout(w),f.abort()}n==null||n.addEventListener("abort",()=>{M(),h()});const x=d??window.fetch,C=s??zr;async function I(){var b;f=new AbortController;try{const N=await x(r,Object.assign(Object.assign({},m),{headers:y,signal:f.signal}));await C(N),await Nr(N.body,Rr(_r(L=>{L?y[dn]=L:delete y[dn]},L=>{p=L},a))),i==null||i(),M(),h()}catch(N){if(!f.signal.aborted)try{const L=(b=l==null?void 0:l(N))!==null&&b!==void 0?b:p;window.clearTimeout(w),w=window.setTimeout(I,L)}catch(L){M(),g(L)}}}I()})}function zr(r){const t=r.headers.get("content-type");if(!(t!=null&&t.startsWith(Rt)))throw new Error(`Expected content-type to be ${Rt}, Actual: ${t}`)}function ct(r){if(!r)throw console.error("[RestifyAi] Endpoint is undefined. Check your endpoints configuration."),new Error("AI service endpoint is not configured. Please contact support.");const t=K(),n=(t==null?void 0:t.baseUrl)||"";if(!n||r.startsWith("http://")||r.startsWith("https://"))return r;const o=n.endsWith("/")?n.slice(0,-1):n,s=r.startsWith("/")?r:`/${r}`;return`${o}${s}`}function Or(r){const n=(r instanceof Error?r.message:String(r)).toLowerCase();return n.includes("failed to fetch")||n.includes("network")||n.includes("fetch")?"Unable to connect to the AI service. Please check your internet connection and try again.":n.includes("500")||n.includes("internal server error")?"The AI service is temporarily unavailable. Please try again in a few moments.":n.includes("timeout")||n.includes("timed out")?"The request took too long. Please try again.":n.includes("401")||n.includes("unauthorized")||n.includes("authentication")?"Your session has expired. Please refresh the page and try again.":n.includes("429")||n.includes("rate limit")||n.includes("too many requests")?"Too many requests. Please wait a moment before trying again.":n.includes("cors")||n.includes("cross-origin")?"Unable to connect to the AI service. Please contact support.":n.includes("endpoint is not configured")?"AI service endpoint is not configured. Please contact support.":"Something went wrong. Please try again later."}function Pr(r,t){var n,o,s;try{if(t==="done"||r==="[DONE]")return"[DONE]";const a=JSON.parse(r);return(a==null?void 0:a.content)!==void 0?a.content:((s=(o=(n=a==null?void 0:a.choices)==null?void 0:n[0])==null?void 0:o.delta)==null?void 0:s.content)||null}catch{return null}}function Vr(r){return new Promise(t=>setTimeout(t,r))}function Fr(r){const t={};return r.forEach(n=>{var o;(o=n.attachments)==null||o.forEach(s=>{s!=null&&s.id&&(t[s.id]=s)})}),t}function Te(r){const t=K();return r==="chatHistory"?(t==null?void 0:t.chatHistoryKey)||"restify_ai_chat_history":r==="setupComplete"?"restify_ai_setup_complete":(t==null?void 0:t.drawerStateKey)||"restify_ai_drawer_open"}function qe(r){try{sessionStorage.setItem(Te("chatHistory"),JSON.stringify(r))}catch(t){console.warn("[RestifyAi] Failed to save chat history:",t)}}function Hr(){try{const r=sessionStorage.getItem(Te("chatHistory"));if(r){const t=JSON.parse(r),n=t.filter(a=>{var i;return!(a.role===Re.Assistant&&a.loading||a.role===Re.Assistant&&!((i=a.message)!=null&&i.trim()))}).map(a=>({...a,streaming:!1,loading:!1}));n.length!==t.length&&sessionStorage.setItem(Te("chatHistory"),JSON.stringify(n));const o=n[n.length-1],s=(o==null?void 0:o.role)===Re.User;return{history:n,hasOrphanedUserMessage:s,orphanedMessage:s?{question:o.message,attachments:o.attachments||[]}:void 0}}}catch(r){console.warn("[RestifyAi] Failed to load chat history:",r)}return{history:[],hasOrphanedUserMessage:!1}}function Ur(){try{sessionStorage.removeItem(Te("chatHistory"))}catch(r){console.warn("[RestifyAi] Failed to clear chat history:",r)}}function qr(r){try{r.message||r.failedQuestion?sessionStorage.setItem("restify_ai_error_state",JSON.stringify(r)):sessionStorage.removeItem("restify_ai_error_state")}catch(t){console.warn("[RestifyAi] Failed to save error state:",t)}}function jr(){try{const r=sessionStorage.getItem("restify_ai_error_state");if(r)return JSON.parse(r)}catch(r){console.warn("[RestifyAi] Failed to load error state:",r)}return null}function Wr(){try{sessionStorage.removeItem("restify_ai_error_state")}catch(r){console.warn("[RestifyAi] Failed to clear error state:",r)}}function _t(r){try{localStorage.setItem(Te("drawerState"),JSON.stringify(r))}catch(t){console.warn("[RestifyAi] Failed to save drawer state:",t)}}function Kr(){try{const r=localStorage.getItem(Te("drawerState"));if(r!==null)return JSON.parse(r)}catch(r){console.warn("[RestifyAi] Failed to load drawer state:",r)}return!1}function Gr(){try{return localStorage.getItem(Te("setupComplete"))==="true"}catch{return!1}}function mn(){try{localStorage.setItem(Te("setupComplete"),"true")}catch(r){console.warn("[RestifyAi] Failed to mark setup complete:",r)}}function fn(){return{isActive:!1,currentStep:"welcome",testApiKey:null,connectionStatus:"idle",backendConfigured:!1,lastError:null}}let je=new AbortController;function Qr(r,t){return r!=null&&r.message?{message:r.message,failedQuestion:r.failedQuestion,failedAttachments:r.failedAttachments,timestamp:Date.now(),quotaExceeded:!1}:t.hasOrphanedUserMessage&&t.orphanedMessage?{message:"Previous request failed. Click retry to try again.",failedQuestion:t.orphanedMessage.question,failedAttachments:t.orphanedMessage.attachments,timestamp:Date.now(),quotaExceeded:!1}:{message:null,failedQuestion:null,failedAttachments:null,timestamp:null,quotaExceeded:!1}}function Zr(r){const t=ke("chatHistoryLimit")||10;return{limit:t,used:r,remaining:Math.max(0,t-r)}}function Yr(){return!Nt()&&!Gr()?{...fn(),isActive:!0}:fn()}const Ae=De.defineStore("restifyAiStore",{state:()=>{const r=Hr(),t=jr(),n=r.history.filter(o=>o.role==="user").length;return{chatHistoryLimit:ke("chatHistoryLimit")||20,chatHistory:r.history,uploadedFiles:Fr(r.history),loading:!1,showChat:Kr(),isFullscreen:!1,sending:!1,pageContext:null,quota:Zr(n),error:Qr(t,r),supportRequestMode:!1,setupState:Yr()}},getters:{hasMessages:r=>r.chatHistory.length>0,isInSetupMode:r=>r.setupState.isActive,canChat:r=>!r.setupState.isActive||r.setupState.connectionStatus==="connected"},actions:{async scrollToBottom(r=0){await e.nextTick(),r>0&&await new Promise(n=>setTimeout(n,r));const t=document.getElementById("rai-chat-bottom");t&&t.scrollIntoView({behavior:"smooth"})},parseStreamContent(r,t){const n=K(),o=n==null?void 0:n.parseStreamContent;return o?o(t,r):Pr(t,r)},async askQuestion(r,t=[],n=[],o=!1){var y;const s=K();if(!s)return console.warn("[RestifyAi] Cannot ask question - plugin not configured"),!1;let a="",i=!1;const l=s.retry||{},u=l.maxRetries??0,d=l.retryDelay??1e3;let m=0;const h=t.map(f=>({id:f.id,name:f.name,url:f.url,type:f.type,size:f.size,extractedText:f.extractedText}));this.chatHistory.push({id:crypto.randomUUID(),role:Re.User,message:r,loading:!1,attachments:h,mentions:n,timestamp:Date.now()}),h.forEach(f=>this.registerUploadedFile(f)),qe(this.chatHistory),this.sending=!0,this.quota.remaining>0&&!o&&(this.quota.remaining--,this.quota.used++),this.scrollToBottom(),this.chatHistory.length>=this.chatHistoryLimit&&((y=s.onError)==null||y.call(s,new Error("Chat history limit reached")));const g=async()=>{var f,S,p;try{const w=this.chatHistory.map(_=>({role:_.role,content:_.message})),M={},x=_=>{_!=null&&_.id&&(M[_.id]={extracted_text:_.extractedText||"",file_name:_.name,mime_type:_.type||"",..._.size?{file_size:_.size}:{},..._.url?{file_url:_.url}:{}})};Object.values(this.uploadedFiles).forEach(x),this.chatHistory.forEach(_=>{var O;return(O=_.attachments)==null?void 0:O.forEach(x)}),h.forEach(x);const C=Object.values(M),I=this.chatHistory.length;this.chatHistory.push({id:crypto.randomUUID(),role:Re.Assistant,message:"",loading:!0,timestamp:Date.now()}),qe(this.chatHistory),je=new AbortController,this.scrollToBottom();const b=await s.getAuthToken(),L={"Content-Type":"application/json",Accept:"application/vnd.api+json",...s.getCustomHeaders?await s.getCustomHeaders():{}};this.setupState.isActive&&this.setupState.testApiKey?L["X-Test-Api-Key"]=this.setupState.testApiKey:b&&(L.Authorization=`Bearer ${b}`);const A={};if(typeof window<"u"){A.route=window.location.pathname;const _=new URLSearchParams(window.location.search),O={};_.forEach((z,ne)=>{O[ne]=z}),Object.keys(O).length>0&&(A.query=O),document.title&&(A.pageTitle=document.title)}n.length>0&&(A.mentionedEntities=n.map(_=>({type:_.type,id:_.id,displayName:_.name,metadata:_.metadata})));let B={message:r,history:w,stream:!0,...C.length>0&&{files:C},...Object.keys(A).length>0&&{context:A},...this.supportRequestMode&&{contact_support:!0},...s.model&&{model:s.model},...s.temperature&&{temperature:s.temperature},...s.maxTokens&&{max_tokens:s.maxTokens}};s.beforeSend&&(B=await s.beforeSend(B)),s.buildRequest&&(B=await s.buildRequest(B)),(f=s.onMessageSent)==null||f.call(s,this.chatHistory[I-1]);const V=ct(s.endpoints.ask);let G={method:"POST",body:JSON.stringify(B),headers:L};return s.requestInterceptor&&(G=await s.requestInterceptor(V,G)),(S=s.onStreamStart)==null||S.call(s),await Dr(V,{method:"POST",body:JSON.stringify(B),signal:je.signal,headers:G.headers,openWhenHidden:!0,async onopen(_){if(!_.ok){if(_.status===429){const O=Ae();throw O.error={message:te("rateLimitExceeded"),failedQuestion:r,failedAttachments:h,timestamp:Date.now(),quotaExceeded:!0,rateLimited:!0},s.useQuota!==!1&&await O.fetchQuota(),new Error("Rate limit exceeded")}throw new Error(`Failed to connect: ${_.status}`)}},onmessage:async _=>{var ne,be,U;const O=this.parseStreamContent(_.event,_.data);if(!O)return;this.chatHistory[I].loading=!1;const z={content:O,done:O==="[DONE]",raw:_.data};(ne=s.onStreamChunk)==null||ne.call(s,z),a?O==="[DONE]"?(this.chatHistory[I].streaming=!1,qe(this.chatHistory),(be=s.onStreamEnd)==null||be.call(s,a),this.quota.remaining===0&&s.enableSupportMode!==!1&&(this.supportRequestMode=!0),this.supportRequestMode&&this.quota.remaining>0&&(this.supportRequestMode=!1),s.afterResponse&&await s.afterResponse(this.chatHistory[I]),(U=s.onResponseReceived)==null||U.call(s,this.chatHistory[I])):(a+=O,this.chatHistory[I].message=a):(a=O,this.chatHistory[I].message=a,this.chatHistory[I].streaming=!0),await this.scrollToBottom()},onclose:()=>{var _,O;a&&!i&&(this.chatHistory[I].streaming=!1,this.chatHistory[I].loading=!1,qe(this.chatHistory),(_=s.onStreamEnd)==null||_.call(s,a),s.afterResponse&&s.afterResponse(this.chatHistory[I]),(O=s.onResponseReceived)==null||O.call(s,this.chatHistory[I]))},onerror:_=>{if(!a)throw i=!0,_}}),!0}catch(w){i=!0;const M=this.chatHistory.length-1;return this.chatHistory.splice(M,1),w.name==="AbortError"?!0:m<u&&(l.shouldRetry?l.shouldRetry(w,m):!0)?(m++,await Vr(d*m),g()):(this.error={message:Or(w),failedQuestion:r,failedAttachments:h,timestamp:Date.now()},qr({message:this.error.message,failedQuestion:this.error.failedQuestion,failedAttachments:this.error.failedAttachments||null}),(p=s.onError)==null||p.call(s,w),!1)}finally{this.sending=!1}};return g()},cancelRequest(){je==null||je.abort(),this.chatHistory=this.chatHistory.map(r=>({...r,streaming:!1,loading:!1})),this.sending=!1},clearChatHistory(){var n;const r=K();this.chatHistory=[],this.sending=!1,this.uploadedFiles={},this.clearError(),this.quota.remaining>0&&(this.supportRequestMode=!1);const t=ke("chatHistoryLimit")||10;this.quota={limit:t,used:0,remaining:t},Ur(),(n=r==null?void 0:r.onNewChat)==null||n.call(r)},async retry(){if(!this.error.failedQuestion)return!1;const r=this.error.failedQuestion,t=this.error.failedAttachments||[],n=this.chatHistory[this.chatHistory.length-1];return(n==null?void 0:n.role)===Re.User&&n.message===r&&(this.chatHistory.pop(),qe(this.chatHistory)),this.clearError(),await this.askQuestion(r,t)},clearError(){this.error={message:null,failedQuestion:null,failedAttachments:null,timestamp:null,quotaExceeded:!1},Wr()},toggleSupportMode(){this.supportRequestMode=!this.supportRequestMode},async fetchQuota(){var t,n;const r=K();if((r==null?void 0:r.useQuota)!==!1&&(t=r==null?void 0:r.endpoints)!=null&&t.quota)try{const o=await r.getAuthToken(),s=r.getCustomHeaders?await r.getCustomHeaders():{},a=ct(r.endpoints.quota),i=await fetch(a,{headers:{Accept:"application/json",...o?{Authorization:`Bearer ${o}`}:{},...s}});if(i.ok){const l=await i.json(),u=l.data??l;this.quota={limit:u.limit??this.quota.limit,used:u.used??this.quota.used,remaining:u.remaining??this.quota.remaining},this.quota.remaining===0&&r.enableSupportMode!==!1&&(this.supportRequestMode=!0),(n=r.onQuotaFetched)==null||n.call(r,this.quota)}}catch(o){console.error("[RestifyAi] Failed to fetch quota:",o)}},async uploadFile(r){var s,a,i,l,u;const t=K();if(!((s=t==null?void 0:t.endpoints)!=null&&s.uploadFile))return console.warn("[RestifyAi] No uploadFile endpoint configured"),null;const o={id:crypto.randomUUID(),name:r.name,type:r.type,size:r.size,uploading:!0,progress:0};(a=t.onFileUploadStart)==null||a.call(t,o);try{const d=await t.getAuthToken(),m=t.getCustomHeaders?await t.getCustomHeaders():{},h=ct(t.endpoints.uploadFile),g=new FormData;g.append("file",r);const y=await new Promise((f,S)=>{const p=new XMLHttpRequest;p.upload.addEventListener("progress",w=>{var M;if(w.lengthComputable){const x=Math.round(w.loaded/w.total*100);o.progress=x,(M=t.onFileUploadProgress)==null||M.call(t,o,x)}}),p.addEventListener("load",()=>{var w,M;if(p.status>=200&&p.status<300)try{const x=JSON.parse(p.responseText),C={...o,url:x.url||((w=x.data)==null?void 0:w.url),extractedText:x.extracted_text||((M=x.data)==null?void 0:M.extracted_text),uploading:!1,progress:100};f(C)}catch{S(new Error("Failed to parse upload response"))}else S(new Error(`Upload failed: ${p.status}`))}),p.addEventListener("error",()=>S(new Error("Upload failed"))),p.open("POST",h),d&&p.setRequestHeader("Authorization",`Bearer ${d}`),Object.entries(m).forEach(([w,M])=>p.setRequestHeader(w,M)),p.send(g)});return(i=t.onFileUploadComplete)==null||i.call(t,y),y}catch(d){const m={...o,uploading:!1};return(l=t.onFileUploadError)==null||l.call(t,m,d),(u=t.onError)==null||u.call(t,d),null}},setPageContext(r){this.pageContext=r},toggleDrawer(){var r,t;this.showChat=!this.showChat,_t(this.showChat),(t=(r=K())==null?void 0:r.onDrawerToggle)==null||t.call(r,this.showChat),this.showChat&&this.scrollToBottom(100)},openDrawer(){var r,t;this.showChat=!0,_t(!0),(t=(r=K())==null?void 0:r.onDrawerToggle)==null||t.call(r,!0),this.scrollToBottom(100)},closeDrawer(){var r,t;this.showChat=!1,_t(!1),(t=(r=K())==null?void 0:r.onDrawerToggle)==null||t.call(r,!1)},startSupportRequest(){this.supportRequestMode=!0},cancelSupportRequest(){this.quota.remaining>0&&(this.supportRequestMode=!1)},registerUploadedFile(r){r!=null&&r.id&&(this.uploadedFiles[r.id]={...r})},startSetupMode(){this.setupState={isActive:!0,currentStep:"welcome",testApiKey:null,connectionStatus:"idle",backendConfigured:!1,lastError:null}},setSetupStep(r){this.setupState.currentStep=r},setTestApiKey(r){this.setupState.testApiKey=r},async testConnection(){this.setupState.connectionStatus="testing",this.setupState.lastError=null;const r=K();if(!r)return this.setupState.connectionStatus="failed",this.setupState.lastError="Plugin not configured",!1;try{const t={"Content-Type":"application/json",Accept:"application/json"};this.setupState.testApiKey&&(t["X-Test-Api-Key"]=this.setupState.testApiKey);const n=r.endpoints.quota||r.endpoints.ask,o=ct(n),s=await fetch(o,{method:r.endpoints.quota?"GET":"POST",headers:t,...r.endpoints.quota?{}:{body:JSON.stringify({question:"test",stream:!1})}});return s.ok?(this.setupState.connectionStatus="connected",this.setupState.backendConfigured=!0,!0):(this.setupState.connectionStatus="failed",this.setupState.lastError=`Connection failed: ${s.status} ${s.statusText}`,!1)}catch(t){return this.setupState.connectionStatus="failed",this.setupState.lastError=t.message||"Connection failed",!1}},completeSetup(){var r,t;this.setupState.isActive=!1,this.setupState.currentStep="complete",mn(),(t=(r=K())==null?void 0:r.onSetupComplete)==null||t.call(r)},skipSetup(){this.setupState.isActive=!1,mn()}}});function pn(r){const t=/@\[([^\]]+)\]\(([^)]+)\)/g,n=[];let o=r,s;for(;(s=t.exec(r))!==null;){const[a,i,l]=s,[u,d]=l.includes(":")?l.split(":"):["default",l];n.push({id:d,name:i,type:u}),o=o.replace(a,i)}return{cleanText:o,mentions:n}}function Xr(r){const{cleanText:t}=pn(r);return t}function hn(r){return r.replace(/@([A-Z][a-z]+(?:\s+[A-Z][a-z]+)*)/g,'<span class="rai-mention">@$1</span>')}function gn(r,t){const o=r.substring(0,t).match(/@(\w*)$/);return o?{inMention:!0,query:o[1],startPos:t-o[0].length}:{inMention:!1,query:"",startPos:-1}}function Lt(r,t){var n,o;return t!=null&&t.getDisplayName?t.getDisplayName(r):r.name||r.title||((n=r.attributes)==null?void 0:n.name)||((o=r.attributes)==null?void 0:o.title)||"Unknown"}function yn(r,t){var n,o;return t!=null&&t.getSubtitle?t.getSubtitle(r):((n=r.attributes)==null?void 0:n.email)||((o=r.attributes)==null?void 0:o.description)||null}function Jr(r,t){return t!=null&&t.buildMentionText?t.buildMentionText(r):`@[${Lt(r,t)}](${r.type}:${r.id})`}function kn(r){var n;const t=K();return(n=t==null?void 0:t.mentionProviders)==null?void 0:n.find(o=>o.type===r)}function xn(r){const t=K(),n=(t==null?void 0:t.mentionProviders)||[];return r?n.filter(o=>o.routes?o.routes.some(s=>s.endsWith("*")?r.startsWith(s.slice(0,-1)):r===s||r.startsWith(s+"/")):!0):n}function bn(r){return r.map(t=>({type:t.type,id:t.id,name:t.name}))}function wn(r){return r.reduce((t,n)=>{const o=n.type||"default";return t[o]||(t[o]=[]),t[o].push(n),t},{})}function vr(){return{extractMentions:pn,parseAndCleanMessage:Xr,renderMentionsInHtml:hn,detectMentionContext:gn,getMentionDisplayName:Lt,getMentionSubtitle:yn,buildMentionText:Jr,getMentionProvider:kn,getActiveMentionProviders:xn,formatMentionsForApi:bn,groupMentionsByType:wn}}function It(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let _e=It();function Cn(r){_e=r}const En=/[&<>"']/,eo=new RegExp(En.source,"g"),Sn=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,to=new RegExp(Sn.source,"g"),no={"&":"&","<":"<",">":">",'"':""","'":"'"},Tn=r=>no[r];function de(r,t){if(t){if(En.test(r))return r.replace(eo,Tn)}else if(Sn.test(r))return r.replace(to,Tn);return r}const ro=/(^|[^\[])\^/g;function H(r,t){let n=typeof r=="string"?r:r.source;t=t||"";const o={replace:(s,a)=>{let i=typeof a=="string"?a:a.source;return i=i.replace(ro,"$1"),n=n.replace(s,i),o},getRegex:()=>new RegExp(n,t)};return o}function An(r){try{r=encodeURI(r).replace(/%25/g,"%")}catch{return null}return r}const We={exec:()=>null};function Mn(r,t){const n=r.replace(/\|/g,(a,i,l)=>{let u=!1,d=i;for(;--d>=0&&l[d]==="\\";)u=!u;return u?"|":" |"}),o=n.split(/ \|/);let s=0;if(o[0].trim()||o.shift(),o.length>0&&!o[o.length-1].trim()&&o.pop(),t)if(o.length>t)o.splice(t);else for(;o.length<t;)o.push("");for(;s<o.length;s++)o[s]=o[s].trim().replace(/\\\|/g,"|");return o}function Ke(r,t,n){const o=r.length;if(o===0)return"";let s=0;for(;s<o&&r.charAt(o-s-1)===t;)s++;return r.slice(0,o-s)}function oo(r,t){if(r.indexOf(t[1])===-1)return-1;let n=0;for(let o=0;o<r.length;o++)if(r[o]==="\\")o++;else if(r[o]===t[0])n++;else if(r[o]===t[1]&&(n--,n<0))return o;return-1}function Bn(r,t,n,o){const s=t.href,a=t.title?de(t.title):null,i=r[1].replace(/\\([\[\]])/g,"$1");if(r[0].charAt(0)!=="!"){o.state.inLink=!0;const l={type:"link",raw:n,href:s,title:a,text:i,tokens:o.inlineTokens(i)};return o.state.inLink=!1,l}return{type:"image",raw:n,href:s,title:a,text:de(i)}}function so(r,t){const n=r.match(/^(\s+)(?:```)/);if(n===null)return t;const o=n[1];return t.split(`
|
|
3
3
|
`).map(s=>{const a=s.match(/^\s+/);if(a===null)return s;const[i]=a;return i.length>=o.length?s.slice(o.length):s}).join(`
|
|
4
|
-
`)}class
|
|
5
|
-
`)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const o=n[0],s=
|
|
6
|
-
`)}}blockquote(t){const n=this.rules.block.blockquote.exec(t);if(n){let o=
|
|
4
|
+
`)}class ut{constructor(t){q(this,"options");q(this,"rules");q(this,"lexer");this.options=t||_e}space(t){const n=this.rules.block.newline.exec(t);if(n&&n[0].length>0)return{type:"space",raw:n[0]}}code(t){const n=this.rules.block.code.exec(t);if(n){const o=n[0].replace(/^(?: {1,4}| {0,3}\t)/gm,"");return{type:"code",raw:n[0],codeBlockStyle:"indented",text:this.options.pedantic?o:Ke(o,`
|
|
5
|
+
`)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const o=n[0],s=so(o,n[3]||"");return{type:"code",raw:o,lang:n[2]?n[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):n[2],text:s}}}heading(t){const n=this.rules.block.heading.exec(t);if(n){let o=n[2].trim();if(/#$/.test(o)){const s=Ke(o,"#");(this.options.pedantic||!s||/ $/.test(s))&&(o=s.trim())}return{type:"heading",raw:n[0],depth:n[1].length,text:o,tokens:this.lexer.inline(o)}}}hr(t){const n=this.rules.block.hr.exec(t);if(n)return{type:"hr",raw:Ke(n[0],`
|
|
6
|
+
`)}}blockquote(t){const n=this.rules.block.blockquote.exec(t);if(n){let o=Ke(n[0],`
|
|
7
7
|
`).split(`
|
|
8
|
-
`),s="",a="";const i=[];for(;o.length>0;){let l=!1;const u=[];let d;for(d=0;d<o.length;d++)if(/^ {0,3}>/.test(o[d]))u.push(o[d]),l=!0;else if(!l)u.push(o[d]);else break;o=o.slice(d);const
|
|
9
|
-
`),
|
|
8
|
+
`),s="",a="";const i=[];for(;o.length>0;){let l=!1;const u=[];let d;for(d=0;d<o.length;d++)if(/^ {0,3}>/.test(o[d]))u.push(o[d]),l=!0;else if(!l)u.push(o[d]);else break;o=o.slice(d);const m=u.join(`
|
|
9
|
+
`),h=m.replace(/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,`
|
|
10
10
|
$1`).replace(/^ {0,3}>[ \t]?/gm,"");s=s?`${s}
|
|
11
|
-
${
|
|
12
|
-
${
|
|
11
|
+
${m}`:m,a=a?`${a}
|
|
12
|
+
${h}`:h;const g=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(h,i,!0),this.lexer.state.top=g,o.length===0)break;const y=i[i.length-1];if((y==null?void 0:y.type)==="code")break;if((y==null?void 0:y.type)==="blockquote"){const f=y,S=f.raw+`
|
|
13
13
|
`+o.join(`
|
|
14
|
-
`),
|
|
14
|
+
`),p=this.blockquote(S);i[i.length-1]=p,s=s.substring(0,s.length-f.raw.length)+p.raw,a=a.substring(0,a.length-f.text.length)+p.text;break}else if((y==null?void 0:y.type)==="list"){const f=y,S=f.raw+`
|
|
15
15
|
`+o.join(`
|
|
16
|
-
`),
|
|
17
|
-
`);continue}}return{type:"blockquote",raw:s,tokens:i,text:a}}}list(t){let n=this.rules.block.list.exec(t);if(n){let o=n[1].trim();const s=o.length>1,a={type:"list",raw:"",ordered:s,start:s?+o.slice(0,-1):"",loose:!1,items:[]};o=s?`\\d{1,9}\\${o.slice(-1)}`:`\\${o}`,this.options.pedantic&&(o=s?o:"[*+-]");const i=new RegExp(`^( {0,3}${o})((?:[ ][^\\n]*)?(?:\\n|$))`);let l=!1;for(;t;){let u=!1,d="",
|
|
18
|
-
`,1)[0].replace(/^\t+/,
|
|
19
|
-
`,1)[0],
|
|
20
|
-
`,t=t.substring(
|
|
21
|
-
`,1)[0];let
|
|
22
|
-
`+
|
|
23
|
-
`+
|
|
24
|
-
`,t=t.substring(
|
|
25
|
-
`):[],i={type:"table",raw:n[0],header:[],align:[],rows:[]};if(o.length===s.length){for(const l of s)/^ *-+: *$/.test(l)?i.align.push("right"):/^ *:-+: *$/.test(l)?i.align.push("center"):/^ *:-+ *$/.test(l)?i.align.push("left"):i.align.push(null);for(let l=0;l<o.length;l++)i.header.push({text:o[l],tokens:this.lexer.inline(o[l]),header:!0,align:i.align[l]});for(const l of a)i.rows.push(
|
|
26
|
-
`?n[1].slice(0,-1):n[1];return{type:"paragraph",raw:n[0],text:o,tokens:this.lexer.inline(o)}}}text(t){const n=this.rules.block.text.exec(t);if(n)return{type:"text",raw:n[0],text:n[0],tokens:this.lexer.inline(n[0])}}escape(t){const n=this.rules.inline.escape.exec(t);if(n)return{type:"escape",raw:n[0],text:
|
|
27
|
-
]`).replace("lheading",
|
|
16
|
+
`),p=this.list(S);i[i.length-1]=p,s=s.substring(0,s.length-y.raw.length)+p.raw,a=a.substring(0,a.length-f.raw.length)+p.raw,o=S.substring(i[i.length-1].raw.length).split(`
|
|
17
|
+
`);continue}}return{type:"blockquote",raw:s,tokens:i,text:a}}}list(t){let n=this.rules.block.list.exec(t);if(n){let o=n[1].trim();const s=o.length>1,a={type:"list",raw:"",ordered:s,start:s?+o.slice(0,-1):"",loose:!1,items:[]};o=s?`\\d{1,9}\\${o.slice(-1)}`:`\\${o}`,this.options.pedantic&&(o=s?o:"[*+-]");const i=new RegExp(`^( {0,3}${o})((?:[ ][^\\n]*)?(?:\\n|$))`);let l=!1;for(;t;){let u=!1,d="",m="";if(!(n=i.exec(t))||this.rules.block.hr.test(t))break;d=n[0],t=t.substring(d.length);let h=n[2].split(`
|
|
18
|
+
`,1)[0].replace(/^\t+/,w=>" ".repeat(3*w.length)),g=t.split(`
|
|
19
|
+
`,1)[0],y=!h.trim(),f=0;if(this.options.pedantic?(f=2,m=h.trimStart()):y?f=n[1].length+1:(f=n[2].search(/[^ ]/),f=f>4?1:f,m=h.slice(f),f+=n[1].length),y&&/^[ \t]*$/.test(g)&&(d+=g+`
|
|
20
|
+
`,t=t.substring(g.length+1),u=!0),!u){const w=new RegExp(`^ {0,${Math.min(3,f-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),M=new RegExp(`^ {0,${Math.min(3,f-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),x=new RegExp(`^ {0,${Math.min(3,f-1)}}(?:\`\`\`|~~~)`),C=new RegExp(`^ {0,${Math.min(3,f-1)}}#`),I=new RegExp(`^ {0,${Math.min(3,f-1)}}<(?:[a-z].*>|!--)`,"i");for(;t;){const b=t.split(`
|
|
21
|
+
`,1)[0];let N;if(g=b,this.options.pedantic?(g=g.replace(/^ {1,4}(?=( {4})*[^ ])/g," "),N=g):N=g.replace(/\t/g," "),x.test(g)||C.test(g)||I.test(g)||w.test(g)||M.test(g))break;if(N.search(/[^ ]/)>=f||!g.trim())m+=`
|
|
22
|
+
`+N.slice(f);else{if(y||h.replace(/\t/g," ").search(/[^ ]/)>=4||x.test(h)||C.test(h)||M.test(h))break;m+=`
|
|
23
|
+
`+g}!y&&!g.trim()&&(y=!0),d+=b+`
|
|
24
|
+
`,t=t.substring(b.length+1),h=N.slice(f)}}a.loose||(l?a.loose=!0:/\n[ \t]*\n[ \t]*$/.test(d)&&(l=!0));let S=null,p;this.options.gfm&&(S=/^\[[ xX]\] /.exec(m),S&&(p=S[0]!=="[ ] ",m=m.replace(/^\[[ xX]\] +/,""))),a.items.push({type:"list_item",raw:d,task:!!S,checked:p,loose:!1,text:m,tokens:[]}),a.raw+=d}a.items[a.items.length-1].raw=a.items[a.items.length-1].raw.trimEnd(),a.items[a.items.length-1].text=a.items[a.items.length-1].text.trimEnd(),a.raw=a.raw.trimEnd();for(let u=0;u<a.items.length;u++)if(this.lexer.state.top=!1,a.items[u].tokens=this.lexer.blockTokens(a.items[u].text,[]),!a.loose){const d=a.items[u].tokens.filter(h=>h.type==="space"),m=d.length>0&&d.some(h=>/\n.*\n/.test(h.raw));a.loose=m}if(a.loose)for(let u=0;u<a.items.length;u++)a.items[u].loose=!0;return a}}html(t){const n=this.rules.block.html.exec(t);if(n)return{type:"html",block:!0,raw:n[0],pre:n[1]==="pre"||n[1]==="script"||n[1]==="style",text:n[0]}}def(t){const n=this.rules.block.def.exec(t);if(n){const o=n[1].toLowerCase().replace(/\s+/g," "),s=n[2]?n[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",a=n[3]?n[3].substring(1,n[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):n[3];return{type:"def",tag:o,raw:n[0],href:s,title:a}}}table(t){const n=this.rules.block.table.exec(t);if(!n||!/[:|]/.test(n[2]))return;const o=Mn(n[1]),s=n[2].replace(/^\||\| *$/g,"").split("|"),a=n[3]&&n[3].trim()?n[3].replace(/\n[ \t]*$/,"").split(`
|
|
25
|
+
`):[],i={type:"table",raw:n[0],header:[],align:[],rows:[]};if(o.length===s.length){for(const l of s)/^ *-+: *$/.test(l)?i.align.push("right"):/^ *:-+: *$/.test(l)?i.align.push("center"):/^ *:-+ *$/.test(l)?i.align.push("left"):i.align.push(null);for(let l=0;l<o.length;l++)i.header.push({text:o[l],tokens:this.lexer.inline(o[l]),header:!0,align:i.align[l]});for(const l of a)i.rows.push(Mn(l,i.header.length).map((u,d)=>({text:u,tokens:this.lexer.inline(u),header:!1,align:i.align[d]})));return i}}lheading(t){const n=this.rules.block.lheading.exec(t);if(n)return{type:"heading",raw:n[0],depth:n[2].charAt(0)==="="?1:2,text:n[1],tokens:this.lexer.inline(n[1])}}paragraph(t){const n=this.rules.block.paragraph.exec(t);if(n){const o=n[1].charAt(n[1].length-1)===`
|
|
26
|
+
`?n[1].slice(0,-1):n[1];return{type:"paragraph",raw:n[0],text:o,tokens:this.lexer.inline(o)}}}text(t){const n=this.rules.block.text.exec(t);if(n)return{type:"text",raw:n[0],text:n[0],tokens:this.lexer.inline(n[0])}}escape(t){const n=this.rules.inline.escape.exec(t);if(n)return{type:"escape",raw:n[0],text:de(n[1])}}tag(t){const n=this.rules.inline.tag.exec(t);if(n)return!this.lexer.state.inLink&&/^<a /i.test(n[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(n[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(n[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(n[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:n[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:n[0]}}link(t){const n=this.rules.inline.link.exec(t);if(n){const o=n[2].trim();if(!this.options.pedantic&&/^</.test(o)){if(!/>$/.test(o))return;const i=Ke(o.slice(0,-1),"\\");if((o.length-i.length)%2===0)return}else{const i=oo(n[2],"()");if(i>-1){const u=(n[0].indexOf("!")===0?5:4)+n[1].length+i;n[2]=n[2].substring(0,i),n[0]=n[0].substring(0,u).trim(),n[3]=""}}let s=n[2],a="";if(this.options.pedantic){const i=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(s);i&&(s=i[1],a=i[3])}else a=n[3]?n[3].slice(1,-1):"";return s=s.trim(),/^</.test(s)&&(this.options.pedantic&&!/>$/.test(o)?s=s.slice(1):s=s.slice(1,-1)),Bn(n,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:a&&a.replace(this.rules.inline.anyPunctuation,"$1")},n[0],this.lexer)}}reflink(t,n){let o;if((o=this.rules.inline.reflink.exec(t))||(o=this.rules.inline.nolink.exec(t))){const s=(o[2]||o[1]).replace(/\s+/g," "),a=n[s.toLowerCase()];if(!a){const i=o[0].charAt(0);return{type:"text",raw:i,text:i}}return Bn(o,a,o[0],this.lexer)}}emStrong(t,n,o=""){let s=this.rules.inline.emStrongLDelim.exec(t);if(!s||s[3]&&o.match(/[\p{L}\p{N}]/u))return;if(!(s[1]||s[2]||"")||!o||this.rules.inline.punctuation.exec(o)){const i=[...s[0]].length-1;let l,u,d=i,m=0;const h=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(h.lastIndex=0,n=n.slice(-1*t.length+i);(s=h.exec(n))!=null;){if(l=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!l)continue;if(u=[...l].length,s[3]||s[4]){d+=u;continue}else if((s[5]||s[6])&&i%3&&!((i+u)%3)){m+=u;continue}if(d-=u,d>0)continue;u=Math.min(u,u+d+m);const g=[...s[0]][0].length,y=t.slice(0,i+s.index+g+u);if(Math.min(i,u)%2){const S=y.slice(1,-1);return{type:"em",raw:y,text:S,tokens:this.lexer.inlineTokens(S)}}const f=y.slice(2,-2);return{type:"strong",raw:y,text:f,tokens:this.lexer.inlineTokens(f)}}}}codespan(t){const n=this.rules.inline.code.exec(t);if(n){let o=n[2].replace(/\n/g," ");const s=/[^ ]/.test(o),a=/^ /.test(o)&&/ $/.test(o);return s&&a&&(o=o.substring(1,o.length-1)),o=de(o,!0),{type:"codespan",raw:n[0],text:o}}}br(t){const n=this.rules.inline.br.exec(t);if(n)return{type:"br",raw:n[0]}}del(t){const n=this.rules.inline.del.exec(t);if(n)return{type:"del",raw:n[0],text:n[2],tokens:this.lexer.inlineTokens(n[2])}}autolink(t){const n=this.rules.inline.autolink.exec(t);if(n){let o,s;return n[2]==="@"?(o=de(n[1]),s="mailto:"+o):(o=de(n[1]),s=o),{type:"link",raw:n[0],text:o,href:s,tokens:[{type:"text",raw:o,text:o}]}}}url(t){var o;let n;if(n=this.rules.inline.url.exec(t)){let s,a;if(n[2]==="@")s=de(n[0]),a="mailto:"+s;else{let i;do i=n[0],n[0]=((o=this.rules.inline._backpedal.exec(n[0]))==null?void 0:o[0])??"";while(i!==n[0]);s=de(n[0]),n[1]==="www."?a="http://"+n[0]:a=n[0]}return{type:"link",raw:n[0],text:s,href:a,tokens:[{type:"text",raw:s,text:s}]}}}inlineText(t){const n=this.rules.inline.text.exec(t);if(n){let o;return this.lexer.state.inRawBlock?o=n[0]:o=de(n[0]),{type:"text",raw:n[0],text:o}}}}const ao=/^(?:[ \t]*(?:\n|$))+/,io=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,lo=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Ge=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,co=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Nn=/(?:[*+-]|\d{1,9}[.)])/,Rn=H(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,Nn).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).getRegex(),$t=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,uo=/^[^\n]+/,Dt=/(?!\s*\])(?:\\.|[^\[\]\\])+/,mo=H(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Dt).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),fo=H(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Nn).getRegex(),dt="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",zt=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,po=H("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",zt).replace("tag",dt).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),_n=H($t).replace("hr",Ge).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",dt).getRegex(),Ot={blockquote:H(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",_n).getRegex(),code:io,def:mo,fences:lo,heading:co,hr:Ge,html:po,lheading:Rn,list:fo,newline:ao,paragraph:_n,table:We,text:uo},Ln=H("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Ge).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",dt).getRegex(),ho={...Ot,table:Ln,paragraph:H($t).replace("hr",Ge).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Ln).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",dt).getRegex()},go={...Ot,html:H(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",zt).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:We,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:H($t).replace("hr",Ge).replace("heading",` *#{1,6} *[^
|
|
27
|
+
]`).replace("lheading",Rn).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},In=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,yo=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,$n=/^( {2,}|\\)\n(?!\s*$)/,ko=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Qe="\\p{P}\\p{S}",xo=H(/^((?![*_])[\spunctuation])/,"u").replace(/punctuation/g,Qe).getRegex(),bo=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,wo=H(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,"u").replace(/punct/g,Qe).getRegex(),Co=H("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])","gu").replace(/punct/g,Qe).getRegex(),Eo=H("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])","gu").replace(/punct/g,Qe).getRegex(),So=H(/\\([punct])/,"gu").replace(/punct/g,Qe).getRegex(),To=H(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Ao=H(zt).replace("(?:-->|$)","-->").getRegex(),Mo=H("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",Ao).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),mt=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,Bo=H(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",mt).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Dn=H(/^!?\[(label)\]\[(ref)\]/).replace("label",mt).replace("ref",Dt).getRegex(),zn=H(/^!?\[(ref)\](?:\[\])?/).replace("ref",Dt).getRegex(),No=H("reflink|nolink(?!\\()","g").replace("reflink",Dn).replace("nolink",zn).getRegex(),Pt={_backpedal:We,anyPunctuation:So,autolink:To,blockSkip:bo,br:$n,code:yo,del:We,emStrongLDelim:wo,emStrongRDelimAst:Co,emStrongRDelimUnd:Eo,escape:In,link:Bo,nolink:zn,punctuation:xo,reflink:Dn,reflinkSearch:No,tag:Mo,text:ko,url:We},Ro={...Pt,link:H(/^!?\[(label)\]\((.*?)\)/).replace("label",mt).getRegex(),reflink:H(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",mt).getRegex()},Vt={...Pt,escape:H(In).replace("])","~|])").getRegex(),url:H(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},_o={...Vt,br:H($n).replace("{2,}","*").getRegex(),text:H(Vt.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},ft={normal:Ot,gfm:ho,pedantic:go},Ze={normal:Pt,gfm:Vt,breaks:_o,pedantic:Ro};class me{constructor(t){q(this,"tokens");q(this,"options");q(this,"state");q(this,"tokenizer");q(this,"inlineQueue");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||_e,this.options.tokenizer=this.options.tokenizer||new ut,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const n={block:ft.normal,inline:Ze.normal};this.options.pedantic?(n.block=ft.pedantic,n.inline=Ze.pedantic):this.options.gfm&&(n.block=ft.gfm,this.options.breaks?n.inline=Ze.breaks:n.inline=Ze.gfm),this.tokenizer.rules=n}static get rules(){return{block:ft,inline:Ze}}static lex(t,n){return new me(n).lex(t)}static lexInline(t,n){return new me(n).inlineTokens(t)}lex(t){t=t.replace(/\r\n|\r/g,`
|
|
28
28
|
`),this.blockTokens(t,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){const o=this.inlineQueue[n];this.inlineTokens(o.src,o.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,n=[],o=!1){this.options.pedantic&&(t=t.replace(/\t/g," ").replace(/^ +$/gm,""));let s,a,i;for(;t;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(l=>(s=l.call({lexer:this},t,n))?(t=t.substring(s.raw.length),n.push(s),!0):!1))){if(s=this.tokenizer.space(t)){t=t.substring(s.raw.length),s.raw.length===1&&n.length>0?n[n.length-1].raw+=`
|
|
29
29
|
`:n.push(s);continue}if(s=this.tokenizer.code(t)){t=t.substring(s.raw.length),a=n[n.length-1],a&&(a.type==="paragraph"||a.type==="text")?(a.raw+=`
|
|
30
30
|
`+s.raw,a.text+=`
|
|
31
31
|
`+s.text,this.inlineQueue[this.inlineQueue.length-1].src=a.text):n.push(s);continue}if(s=this.tokenizer.fences(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.heading(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.hr(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.blockquote(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.list(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.html(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.def(t)){t=t.substring(s.raw.length),a=n[n.length-1],a&&(a.type==="paragraph"||a.type==="text")?(a.raw+=`
|
|
32
32
|
`+s.raw,a.text+=`
|
|
33
|
-
`+s.raw,this.inlineQueue[this.inlineQueue.length-1].src=a.text):this.tokens.links[s.tag]||(this.tokens.links[s.tag]={href:s.href,title:s.title});continue}if(s=this.tokenizer.table(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.lheading(t)){t=t.substring(s.raw.length),n.push(s);continue}if(i=t,this.options.extensions&&this.options.extensions.startBlock){let l=1/0;const u=t.slice(1);let d;this.options.extensions.startBlock.forEach(
|
|
33
|
+
`+s.raw,this.inlineQueue[this.inlineQueue.length-1].src=a.text):this.tokens.links[s.tag]||(this.tokens.links[s.tag]={href:s.href,title:s.title});continue}if(s=this.tokenizer.table(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.lheading(t)){t=t.substring(s.raw.length),n.push(s);continue}if(i=t,this.options.extensions&&this.options.extensions.startBlock){let l=1/0;const u=t.slice(1);let d;this.options.extensions.startBlock.forEach(m=>{d=m.call({lexer:this},u),typeof d=="number"&&d>=0&&(l=Math.min(l,d))}),l<1/0&&l>=0&&(i=t.substring(0,l+1))}if(this.state.top&&(s=this.tokenizer.paragraph(i))){a=n[n.length-1],o&&(a==null?void 0:a.type)==="paragraph"?(a.raw+=`
|
|
34
34
|
`+s.raw,a.text+=`
|
|
35
35
|
`+s.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=a.text):n.push(s),o=i.length!==t.length,t=t.substring(s.raw.length);continue}if(s=this.tokenizer.text(t)){t=t.substring(s.raw.length),a=n[n.length-1],a&&a.type==="text"?(a.raw+=`
|
|
36
36
|
`+s.raw,a.text+=`
|
|
37
|
-
`+s.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=a.text):n.push(s);continue}if(t){const l="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(l);break}else throw new Error(l)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){let o,s,a,i=t,l,u,d;if(this.tokens.links){const
|
|
38
|
-
`;return s?'<pre><code class="language-'+
|
|
39
|
-
`:"<pre><code>"+(o?a:
|
|
37
|
+
`+s.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=a.text):n.push(s);continue}if(t){const l="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(l);break}else throw new Error(l)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){let o,s,a,i=t,l,u,d;if(this.tokens.links){const m=Object.keys(this.tokens.links);if(m.length>0)for(;(l=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)m.includes(l[0].slice(l[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,l.index)+"["+"a".repeat(l[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(l=this.tokenizer.rules.inline.blockSkip.exec(i))!=null;)i=i.slice(0,l.index)+"["+"a".repeat(l[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(l=this.tokenizer.rules.inline.anyPunctuation.exec(i))!=null;)i=i.slice(0,l.index)+"++"+i.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;t;)if(u||(d=""),u=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(m=>(o=m.call({lexer:this},t,n))?(t=t.substring(o.raw.length),n.push(o),!0):!1))){if(o=this.tokenizer.escape(t)){t=t.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.tag(t)){t=t.substring(o.raw.length),s=n[n.length-1],s&&o.type==="text"&&s.type==="text"?(s.raw+=o.raw,s.text+=o.text):n.push(o);continue}if(o=this.tokenizer.link(t)){t=t.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(o.raw.length),s=n[n.length-1],s&&o.type==="text"&&s.type==="text"?(s.raw+=o.raw,s.text+=o.text):n.push(o);continue}if(o=this.tokenizer.emStrong(t,i,d)){t=t.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.codespan(t)){t=t.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.br(t)){t=t.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.del(t)){t=t.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.autolink(t)){t=t.substring(o.raw.length),n.push(o);continue}if(!this.state.inLink&&(o=this.tokenizer.url(t))){t=t.substring(o.raw.length),n.push(o);continue}if(a=t,this.options.extensions&&this.options.extensions.startInline){let m=1/0;const h=t.slice(1);let g;this.options.extensions.startInline.forEach(y=>{g=y.call({lexer:this},h),typeof g=="number"&&g>=0&&(m=Math.min(m,g))}),m<1/0&&m>=0&&(a=t.substring(0,m+1))}if(o=this.tokenizer.inlineText(a)){t=t.substring(o.raw.length),o.raw.slice(-1)!=="_"&&(d=o.raw.slice(-1)),u=!0,s=n[n.length-1],s&&s.type==="text"?(s.raw+=o.raw,s.text+=o.text):n.push(o);continue}if(t){const m="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(m);break}else throw new Error(m)}}return n}}class pt{constructor(t){q(this,"options");q(this,"parser");this.options=t||_e}space(t){return""}code({text:t,lang:n,escaped:o}){var i;const s=(i=(n||"").match(/^\S*/))==null?void 0:i[0],a=t.replace(/\n$/,"")+`
|
|
38
|
+
`;return s?'<pre><code class="language-'+de(s)+'">'+(o?a:de(a,!0))+`</code></pre>
|
|
39
|
+
`:"<pre><code>"+(o?a:de(a,!0))+`</code></pre>
|
|
40
40
|
`}blockquote({tokens:t}){return`<blockquote>
|
|
41
41
|
${this.parser.parse(t)}</blockquote>
|
|
42
42
|
`}html({text:t}){return t}heading({tokens:t,depth:n}){return`<h${n}>${this.parser.parseInline(t)}</h${n}>
|
|
@@ -52,12 +52,12 @@ ${this.parser.parse(t)}</blockquote>
|
|
|
52
52
|
`}tablerow({text:t}){return`<tr>
|
|
53
53
|
${t}</tr>
|
|
54
54
|
`}tablecell(t){const n=this.parser.parseInline(t.tokens),o=t.header?"th":"td";return(t.align?`<${o} align="${t.align}">`:`<${o}>`)+n+`</${o}>
|
|
55
|
-
`}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${t}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:n,tokens:o}){const s=this.parser.parseInline(o),a=
|
|
56
|
-
`+this.renderer.text(l);n?o+=this.renderer.paragraph({type:"paragraph",raw:u,text:u,tokens:[{type:"text",raw:u,text:u}]}):o+=u;continue}default:{const l='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return o}parseInline(t,n){n=n||this.renderer;let o="";for(let s=0;s<t.length;s++){const a=t[s];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[a.type]){const l=this.options.extensions.renderers[a.type].call({parser:this},a);if(l!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){o+=l||"";continue}}const i=a;switch(i.type){case"escape":{o+=n.text(i);break}case"html":{o+=n.html(i);break}case"link":{o+=n.link(i);break}case"image":{o+=n.image(i);break}case"strong":{o+=n.strong(i);break}case"em":{o+=n.em(i);break}case"codespan":{o+=n.codespan(i);break}case"br":{o+=n.br(i);break}case"del":{o+=n.del(i);break}case"text":{o+=n.text(i);break}default:{const l='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return o}}class
|
|
57
|
-
Please report this to https://github.com/markedjs/marked.`,t){const s="<p>An error occurred:</p><pre>"+ie(o.message+"",!0)+"</pre>";return n?Promise.resolve(s):s}if(n)return Promise.reject(o);throw o}}}const Ne=new bo;function O(r,t){return Ne.parse(r,t)}O.options=O.setOptions=function(r){return Ne.setOptions(r),O.defaults=Ne.defaults,hn(O.defaults),O},O.getDefaults=Mt,O.defaults=Me,O.use=function(...r){return Ne.use(...r),O.defaults=Ne.defaults,hn(O.defaults),O},O.walkTokens=function(r,t){return Ne.walkTokens(r,t)},O.parseInline=Ne.parseInline,O.Parser=ce,O.parser=ce.parse,O.Renderer=lt,O.TextRenderer=zt,O.Lexer=le,O.lexer=le.lex,O.Tokenizer=ot,O.Hooks=Ke,O.parse=O,O.options,O.setOptions,O.use,O.walkTokens,O.parseInline,ce.parse,le.lex;/*! @license DOMPurify 3.3.0 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.0/LICENSE */const{entries:Bn,setPrototypeOf:Ln,isFrozen:Eo,getPrototypeOf:Co,getOwnPropertyDescriptor:So}=Object;let{freeze:ne,seal:ue,create:$t}=Object,{apply:Ot,construct:Vt}=typeof Reflect<"u"&&Reflect;ne||(ne=function(t){return t}),ue||(ue=function(t){return t}),Ot||(Ot=function(t,n){for(var o=arguments.length,s=new Array(o>2?o-2:0),a=2;a<o;a++)s[a-2]=arguments[a];return t.apply(n,s)}),Vt||(Vt=function(t){for(var n=arguments.length,o=new Array(n>1?n-1:0),s=1;s<n;s++)o[s-1]=arguments[s];return new t(...o)});const ct=oe(Array.prototype.forEach),To=oe(Array.prototype.lastIndexOf),Dn=oe(Array.prototype.pop),Ge=oe(Array.prototype.push),Ao=oe(Array.prototype.splice),ut=oe(String.prototype.toLowerCase),Pt=oe(String.prototype.toString),_t=oe(String.prototype.match),Qe=oe(String.prototype.replace),Mo=oe(String.prototype.indexOf),No=oe(String.prototype.trim),de=oe(Object.prototype.hasOwnProperty),re=oe(RegExp.prototype.test),Ze=Ro(TypeError);function oe(r){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,o=new Array(n>1?n-1:0),s=1;s<n;s++)o[s-1]=arguments[s];return Ot(r,t,o)}}function Ro(r){return function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return Vt(r,n)}}function I(r,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ut;Ln&&Ln(r,null);let o=t.length;for(;o--;){let s=t[o];if(typeof s=="string"){const a=n(s);a!==s&&(Eo(t)||(t[o]=a),s=a)}r[s]=!0}return r}function Bo(r){for(let t=0;t<r.length;t++)de(r,t)||(r[t]=null);return r}function ge(r){const t=$t(null);for(const[n,o]of Bn(r))de(r,n)&&(Array.isArray(o)?t[n]=Bo(o):o&&typeof o=="object"&&o.constructor===Object?t[n]=ge(o):t[n]=o);return t}function Ye(r,t){for(;r!==null;){const o=So(r,t);if(o){if(o.get)return oe(o.get);if(typeof o.value=="function")return oe(o.value)}r=Co(r)}function n(){return null}return n}const In=ne(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Ft=ne(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Ht=ne(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Lo=ne(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Ut=ne(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),Do=ne(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),zn=ne(["#text"]),$n=ne(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),qt=ne(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),On=ne(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),dt=ne(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Io=ue(/\{\{[\w\W]*|[\w\W]*\}\}/gm),zo=ue(/<%[\w\W]*|[\w\W]*%>/gm),$o=ue(/\$\{[\w\W]*/gm),Oo=ue(/^data-[\-\w.\u00B7-\uFFFF]+$/),Vo=ue(/^aria-[\-\w]+$/),Vn=ue(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Po=ue(/^(?:\w+script|data):/i),_o=ue(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Pn=ue(/^html$/i),Fo=ue(/^[a-z][.\w]*(-[.\w]+)+$/i);var _n=Object.freeze({__proto__:null,ARIA_ATTR:Vo,ATTR_WHITESPACE:_o,CUSTOM_ELEMENT:Fo,DATA_ATTR:Oo,DOCTYPE_NAME:Pn,ERB_EXPR:zo,IS_ALLOWED_URI:Vn,IS_SCRIPT_OR_DATA:Po,MUSTACHE_EXPR:Io,TMPLIT_EXPR:$o});const Xe={element:1,text:3,progressingInstruction:7,comment:8,document:9},Ho=function(){return typeof window>"u"?null:window},Uo=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let o=null;const s="data-tt-policy-suffix";n&&n.hasAttribute(s)&&(o=n.getAttribute(s));const a="dompurify"+(o?"#"+o:"");try{return t.createPolicy(a,{createHTML(i){return i},createScriptURL(i){return i}})}catch{return console.warn("TrustedTypes policy "+a+" could not be created."),null}},Fn=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Hn(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Ho();const t=R=>Hn(R);if(t.version="3.3.0",t.removed=[],!r||!r.document||r.document.nodeType!==Xe.document||!r.Element)return t.isSupported=!1,t;let{document:n}=r;const o=n,s=o.currentScript,{DocumentFragment:a,HTMLTemplateElement:i,Node:l,Element:u,NodeFilter:d,NamedNodeMap:p=r.NamedNodeMap||r.MozNamedAttrMap,HTMLFormElement:f,DOMParser:k,trustedTypes:g}=r,m=u.prototype,E=Ye(m,"cloneNode"),y=Ye(m,"remove"),h=Ye(m,"nextSibling"),b=Ye(m,"childNodes"),C=Ye(m,"parentNode");if(typeof i=="function"){const R=n.createElement("template");R.content&&R.content.ownerDocument&&(n=R.content.ownerDocument)}let w,z="";const{implementation:$,createNodeIterator:F,createDocumentFragment:S,getElementsByTagName:T}=n,{importNode:N}=o;let D=Fn();t.isSupported=typeof Bn=="function"&&typeof C=="function"&&$&&$.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:M,ERB_EXPR:Q,TMPLIT_EXPR:fe,DATA_ATTR:Re,ARIA_ATTR:ye,IS_SCRIPT_OR_DATA:Be,ATTR_WHITESPACE:pt,CUSTOM_ELEMENT:Wt}=_n;let{IS_ALLOWED_URI:ft}=_n,j=null;const Je=I({},[...In,...Ft,...Ht,...Ut,...zn]);let Z=null;const mt=I({},[...$n,...qt,...On,...dt]);let v=Object.seal($t(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Le=null,ze=null;const ke=Object.seal($t(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let ht=!0,$e=!0,L=!1,_=!0,H=!1,G=!0,W=!1,K=!1,se=!1,me=!1,gt=!1,yt=!1,tr=!0,nr=!1;const Pa="user-content-";let Kt=!0,et=!1,Oe={},Ve=null;const rr=I({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let or=null;const sr=I({},["audio","video","img","source","image","track"]);let Gt=null;const ar=I({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),kt="http://www.w3.org/1998/Math/MathML",xt="http://www.w3.org/2000/svg",xe="http://www.w3.org/1999/xhtml";let Pe=xe,Qt=!1,Zt=null;const _a=I({},[kt,xt,xe],Pt);let wt=I({},["mi","mo","mn","ms","mtext"]),bt=I({},["annotation-xml"]);const Fa=I({},["title","style","font","a","script"]);let tt=null;const Ha=["application/xhtml+xml","text/html"],Ua="text/html";let X=null,_e=null;const qa=n.createElement("form"),ir=function(c){return c instanceof RegExp||c instanceof Function},Yt=function(){let c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(_e&&_e===c)){if((!c||typeof c!="object")&&(c={}),c=ge(c),tt=Ha.indexOf(c.PARSER_MEDIA_TYPE)===-1?Ua:c.PARSER_MEDIA_TYPE,X=tt==="application/xhtml+xml"?Pt:ut,j=de(c,"ALLOWED_TAGS")?I({},c.ALLOWED_TAGS,X):Je,Z=de(c,"ALLOWED_ATTR")?I({},c.ALLOWED_ATTR,X):mt,Zt=de(c,"ALLOWED_NAMESPACES")?I({},c.ALLOWED_NAMESPACES,Pt):_a,Gt=de(c,"ADD_URI_SAFE_ATTR")?I(ge(ar),c.ADD_URI_SAFE_ATTR,X):ar,or=de(c,"ADD_DATA_URI_TAGS")?I(ge(sr),c.ADD_DATA_URI_TAGS,X):sr,Ve=de(c,"FORBID_CONTENTS")?I({},c.FORBID_CONTENTS,X):rr,Le=de(c,"FORBID_TAGS")?I({},c.FORBID_TAGS,X):ge({}),ze=de(c,"FORBID_ATTR")?I({},c.FORBID_ATTR,X):ge({}),Oe=de(c,"USE_PROFILES")?c.USE_PROFILES:!1,ht=c.ALLOW_ARIA_ATTR!==!1,$e=c.ALLOW_DATA_ATTR!==!1,L=c.ALLOW_UNKNOWN_PROTOCOLS||!1,_=c.ALLOW_SELF_CLOSE_IN_ATTR!==!1,H=c.SAFE_FOR_TEMPLATES||!1,G=c.SAFE_FOR_XML!==!1,W=c.WHOLE_DOCUMENT||!1,me=c.RETURN_DOM||!1,gt=c.RETURN_DOM_FRAGMENT||!1,yt=c.RETURN_TRUSTED_TYPE||!1,se=c.FORCE_BODY||!1,tr=c.SANITIZE_DOM!==!1,nr=c.SANITIZE_NAMED_PROPS||!1,Kt=c.KEEP_CONTENT!==!1,et=c.IN_PLACE||!1,ft=c.ALLOWED_URI_REGEXP||Vn,Pe=c.NAMESPACE||xe,wt=c.MATHML_TEXT_INTEGRATION_POINTS||wt,bt=c.HTML_INTEGRATION_POINTS||bt,v=c.CUSTOM_ELEMENT_HANDLING||{},c.CUSTOM_ELEMENT_HANDLING&&ir(c.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(v.tagNameCheck=c.CUSTOM_ELEMENT_HANDLING.tagNameCheck),c.CUSTOM_ELEMENT_HANDLING&&ir(c.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(v.attributeNameCheck=c.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),c.CUSTOM_ELEMENT_HANDLING&&typeof c.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(v.allowCustomizedBuiltInElements=c.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),H&&($e=!1),gt&&(me=!0),Oe&&(j=I({},zn),Z=[],Oe.html===!0&&(I(j,In),I(Z,$n)),Oe.svg===!0&&(I(j,Ft),I(Z,qt),I(Z,dt)),Oe.svgFilters===!0&&(I(j,Ht),I(Z,qt),I(Z,dt)),Oe.mathMl===!0&&(I(j,Ut),I(Z,On),I(Z,dt))),c.ADD_TAGS&&(typeof c.ADD_TAGS=="function"?ke.tagCheck=c.ADD_TAGS:(j===Je&&(j=ge(j)),I(j,c.ADD_TAGS,X))),c.ADD_ATTR&&(typeof c.ADD_ATTR=="function"?ke.attributeCheck=c.ADD_ATTR:(Z===mt&&(Z=ge(Z)),I(Z,c.ADD_ATTR,X))),c.ADD_URI_SAFE_ATTR&&I(Gt,c.ADD_URI_SAFE_ATTR,X),c.FORBID_CONTENTS&&(Ve===rr&&(Ve=ge(Ve)),I(Ve,c.FORBID_CONTENTS,X)),Kt&&(j["#text"]=!0),W&&I(j,["html","head","body"]),j.table&&(I(j,["tbody"]),delete Le.tbody),c.TRUSTED_TYPES_POLICY){if(typeof c.TRUSTED_TYPES_POLICY.createHTML!="function")throw Ze('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof c.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Ze('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');w=c.TRUSTED_TYPES_POLICY,z=w.createHTML("")}else w===void 0&&(w=Uo(g,s)),w!==null&&typeof z=="string"&&(z=w.createHTML(""));ne&&ne(c),_e=c}},lr=I({},[...Ft,...Ht,...Lo]),cr=I({},[...Ut,...Do]),va=function(c){let x=C(c);(!x||!x.tagName)&&(x={namespaceURI:Pe,tagName:"template"});const A=ut(c.tagName),U=ut(x.tagName);return Zt[c.namespaceURI]?c.namespaceURI===xt?x.namespaceURI===xe?A==="svg":x.namespaceURI===kt?A==="svg"&&(U==="annotation-xml"||wt[U]):!!lr[A]:c.namespaceURI===kt?x.namespaceURI===xe?A==="math":x.namespaceURI===xt?A==="math"&&bt[U]:!!cr[A]:c.namespaceURI===xe?x.namespaceURI===xt&&!bt[U]||x.namespaceURI===kt&&!wt[U]?!1:!cr[A]&&(Fa[A]||!lr[A]):!!(tt==="application/xhtml+xml"&&Zt[c.namespaceURI]):!1},he=function(c){Ge(t.removed,{element:c});try{C(c).removeChild(c)}catch{y(c)}},De=function(c,x){try{Ge(t.removed,{attribute:x.getAttributeNode(c),from:x})}catch{Ge(t.removed,{attribute:null,from:x})}if(x.removeAttribute(c),c==="is")if(me||gt)try{he(x)}catch{}else try{x.setAttribute(c,"")}catch{}},ur=function(c){let x=null,A=null;if(se)c="<remove></remove>"+c;else{const Y=_t(c,/^[\r\n\t ]+/);A=Y&&Y[0]}tt==="application/xhtml+xml"&&Pe===xe&&(c='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+c+"</body></html>");const U=w?w.createHTML(c):c;if(Pe===xe)try{x=new k().parseFromString(U,tt)}catch{}if(!x||!x.documentElement){x=$.createDocument(Pe,"template",null);try{x.documentElement.innerHTML=Qt?z:U}catch{}}const te=x.body||x.documentElement;return c&&A&&te.insertBefore(n.createTextNode(A),te.childNodes[0]||null),Pe===xe?T.call(x,W?"html":"body")[0]:W?x.documentElement:te},dr=function(c){return F.call(c.ownerDocument||c,c,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT|d.SHOW_PROCESSING_INSTRUCTION|d.SHOW_CDATA_SECTION,null)},Xt=function(c){return c instanceof f&&(typeof c.nodeName!="string"||typeof c.textContent!="string"||typeof c.removeChild!="function"||!(c.attributes instanceof p)||typeof c.removeAttribute!="function"||typeof c.setAttribute!="function"||typeof c.namespaceURI!="string"||typeof c.insertBefore!="function"||typeof c.hasChildNodes!="function")},pr=function(c){return typeof l=="function"&&c instanceof l};function we(R,c,x){ct(R,A=>{A.call(t,c,x,_e)})}const fr=function(c){let x=null;if(we(D.beforeSanitizeElements,c,null),Xt(c))return he(c),!0;const A=X(c.nodeName);if(we(D.uponSanitizeElement,c,{tagName:A,allowedTags:j}),G&&c.hasChildNodes()&&!pr(c.firstElementChild)&&re(/<[/\w!]/g,c.innerHTML)&&re(/<[/\w!]/g,c.textContent)||c.nodeType===Xe.progressingInstruction||G&&c.nodeType===Xe.comment&&re(/<[/\w]/g,c.data))return he(c),!0;if(!(ke.tagCheck instanceof Function&&ke.tagCheck(A))&&(!j[A]||Le[A])){if(!Le[A]&&hr(A)&&(v.tagNameCheck instanceof RegExp&&re(v.tagNameCheck,A)||v.tagNameCheck instanceof Function&&v.tagNameCheck(A)))return!1;if(Kt&&!Ve[A]){const U=C(c)||c.parentNode,te=b(c)||c.childNodes;if(te&&U){const Y=te.length;for(let ae=Y-1;ae>=0;--ae){const be=E(te[ae],!0);be.__removalCount=(c.__removalCount||0)+1,U.insertBefore(be,h(c))}}}return he(c),!0}return c instanceof u&&!va(c)||(A==="noscript"||A==="noembed"||A==="noframes")&&re(/<\/no(script|embed|frames)/i,c.innerHTML)?(he(c),!0):(H&&c.nodeType===Xe.text&&(x=c.textContent,ct([M,Q,fe],U=>{x=Qe(x,U," ")}),c.textContent!==x&&(Ge(t.removed,{element:c.cloneNode()}),c.textContent=x)),we(D.afterSanitizeElements,c,null),!1)},mr=function(c,x,A){if(tr&&(x==="id"||x==="name")&&(A in n||A in qa))return!1;if(!($e&&!ze[x]&&re(Re,x))){if(!(ht&&re(ye,x))){if(!(ke.attributeCheck instanceof Function&&ke.attributeCheck(x,c))){if(!Z[x]||ze[x]){if(!(hr(c)&&(v.tagNameCheck instanceof RegExp&&re(v.tagNameCheck,c)||v.tagNameCheck instanceof Function&&v.tagNameCheck(c))&&(v.attributeNameCheck instanceof RegExp&&re(v.attributeNameCheck,x)||v.attributeNameCheck instanceof Function&&v.attributeNameCheck(x,c))||x==="is"&&v.allowCustomizedBuiltInElements&&(v.tagNameCheck instanceof RegExp&&re(v.tagNameCheck,A)||v.tagNameCheck instanceof Function&&v.tagNameCheck(A))))return!1}else if(!Gt[x]){if(!re(ft,Qe(A,pt,""))){if(!((x==="src"||x==="xlink:href"||x==="href")&&c!=="script"&&Mo(A,"data:")===0&&or[c])){if(!(L&&!re(Be,Qe(A,pt,"")))){if(A)return!1}}}}}}}return!0},hr=function(c){return c!=="annotation-xml"&&_t(c,Wt)},gr=function(c){we(D.beforeSanitizeAttributes,c,null);const{attributes:x}=c;if(!x||Xt(c))return;const A={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Z,forceKeepAttr:void 0};let U=x.length;for(;U--;){const te=x[U],{name:Y,namespaceURI:ae,value:be}=te,Fe=X(Y),Jt=be;let ee=Y==="value"?Jt:No(Jt);if(A.attrName=Fe,A.attrValue=ee,A.keepAttr=!0,A.forceKeepAttr=void 0,we(D.uponSanitizeAttribute,c,A),ee=A.attrValue,nr&&(Fe==="id"||Fe==="name")&&(De(Y,c),ee=Pa+ee),G&&re(/((--!?|])>)|<\/(style|title|textarea)/i,ee)){De(Y,c);continue}if(Fe==="attributename"&&_t(ee,"href")){De(Y,c);continue}if(A.forceKeepAttr)continue;if(!A.keepAttr){De(Y,c);continue}if(!_&&re(/\/>/i,ee)){De(Y,c);continue}H&&ct([M,Q,fe],kr=>{ee=Qe(ee,kr," ")});const yr=X(c.nodeName);if(!mr(yr,Fe,ee)){De(Y,c);continue}if(w&&typeof g=="object"&&typeof g.getAttributeType=="function"&&!ae)switch(g.getAttributeType(yr,Fe)){case"TrustedHTML":{ee=w.createHTML(ee);break}case"TrustedScriptURL":{ee=w.createScriptURL(ee);break}}if(ee!==Jt)try{ae?c.setAttributeNS(ae,Y,ee):c.setAttribute(Y,ee),Xt(c)?he(c):Dn(t.removed)}catch{De(Y,c)}}we(D.afterSanitizeAttributes,c,null)},ja=function R(c){let x=null;const A=dr(c);for(we(D.beforeSanitizeShadowDOM,c,null);x=A.nextNode();)we(D.uponSanitizeShadowNode,x,null),fr(x),gr(x),x.content instanceof a&&R(x.content);we(D.afterSanitizeShadowDOM,c,null)};return t.sanitize=function(R){let c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},x=null,A=null,U=null,te=null;if(Qt=!R,Qt&&(R="<!-->"),typeof R!="string"&&!pr(R))if(typeof R.toString=="function"){if(R=R.toString(),typeof R!="string")throw Ze("dirty is not a string, aborting")}else throw Ze("toString is not a function");if(!t.isSupported)return R;if(K||Yt(c),t.removed=[],typeof R=="string"&&(et=!1),et){if(R.nodeName){const be=X(R.nodeName);if(!j[be]||Le[be])throw Ze("root node is forbidden and cannot be sanitized in-place")}}else if(R instanceof l)x=ur("<!---->"),A=x.ownerDocument.importNode(R,!0),A.nodeType===Xe.element&&A.nodeName==="BODY"||A.nodeName==="HTML"?x=A:x.appendChild(A);else{if(!me&&!H&&!W&&R.indexOf("<")===-1)return w&&yt?w.createHTML(R):R;if(x=ur(R),!x)return me?null:yt?z:""}x&&se&&he(x.firstChild);const Y=dr(et?R:x);for(;U=Y.nextNode();)fr(U),gr(U),U.content instanceof a&&ja(U.content);if(et)return R;if(me){if(gt)for(te=S.call(x.ownerDocument);x.firstChild;)te.appendChild(x.firstChild);else te=x;return(Z.shadowroot||Z.shadowrootmode)&&(te=N.call(o,te,!0)),te}let ae=W?x.outerHTML:x.innerHTML;return W&&j["!doctype"]&&x.ownerDocument&&x.ownerDocument.doctype&&x.ownerDocument.doctype.name&&re(Pn,x.ownerDocument.doctype.name)&&(ae="<!DOCTYPE "+x.ownerDocument.doctype.name+`>
|
|
58
|
-
`+ae),H&&ct([M,Q,fe],be=>{ae=Qe(ae,be," ")}),w&&yt?w.createHTML(ae):ae},t.setConfig=function(){let R=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Yt(R),K=!0},t.clearConfig=function(){_e=null,K=!1},t.isValidAttribute=function(R,c,x){_e||Yt({});const A=X(R),U=X(c);return mr(A,U,x)},t.addHook=function(R,c){typeof c=="function"&&Ge(D[R],c)},t.removeHook=function(R,c){if(c!==void 0){const x=To(D[R],c);return x===-1?void 0:Ao(D[R],x,1)[0]}return Dn(D[R])},t.removeHooks=function(R){D[R]=[]},t.removeAllHooks=function(){D=Fn()},t}var qo=Hn();function Un(){return{parseMarkdown:t=>{if(!t||typeof t!="string")return"";const n=ln(t),o=O.parse(n,{async:!1,breaks:!0,gfm:!0});return qo.sanitize(o,{ALLOWED_TAGS:["p","br","strong","em","b","i","code","pre","ul","ol","li","h1","h2","h3","h4","h5","h6","a","blockquote","span","div","table","thead","tbody","tr","th","td"],ALLOWED_ATTR:["href","class","target","rel","data-mention-id","data-mention-type"],ALLOW_UNKNOWN_PROTOCOLS:!1,FORBID_ATTR:["onerror","onload","onclick","onmouseover"],KEEP_CONTENT:!0})}}}function vo(){let r=null;function t(a){const i=a||document.querySelector("[data-rai-chat-container]");i&&requestAnimationFrame(()=>{i.scrollTo({top:i.scrollHeight,behavior:"smooth"})})}function n(a,i=100){const{scrollTop:l,scrollHeight:u,clientHeight:d}=a;return u-l-d<i}function o(a){a&&(s(),r=new MutationObserver(()=>{(a.scrollTop===0||n(a))&&requestAnimationFrame(()=>{a.scrollTo({top:a.scrollHeight,behavior:"smooth"})})}),r.observe(a,{childList:!0,subtree:!0}))}function s(){r&&(r.disconnect(),r=null)}return e.onUnmounted(()=>{s()}),{scrollToBottom:t,setupAutoScroll:o,cleanupAutoScroll:s}}function jo(){const r=Ce(),t=e.computed(()=>r.error),n=e.computed(()=>{var a,i;return((a=t.value)==null?void 0:a.message)!==null&&((i=t.value)==null?void 0:i.message)!==void 0});return{errorState:t,hasError:n,retry:async()=>await r.retry(),clearError:()=>{r.clearError()}}}function vt(){const r=Ce(),t=e.computed(()=>r.pageContext);function n(a){r.setPageContext(a)}function o(){r.setPageContext(null)}function s(a){const i=r.pageContext;i&&r.setPageContext({...i,...a,metadata:{...i.metadata,...a.metadata}})}return{context:t,setContext:n,clearContext:o,updateContext:s}}const pe=[],qn={id:"default",matcher:()=>!0,priority:0,getSuggestions:()=>{const r=q();return(r==null?void 0:r.defaultSuggestions)||[]}};function Wo(){pe.length=0;const r=q();r!=null&&r.suggestionProviders&&pe.push(...r.suggestionProviders),pe.push(qn)}function Ko(r,t){const n=[...pe].sort((o,s)=>(s.priority||0)-(o.priority||0));for(const o of n)if(o.matcher&&o.matcher(r,t)||o.routes&&o.routes.some(a=>a.endsWith("*")?r.startsWith(a.slice(0,-1)):r===a||r.startsWith(a+"/")))return o;return qn}function vn(r,t){pe.length===0&&Wo();const n=Ko(r,t),o=t||{pageType:"default",routePath:r};return n.extractContext&&(o.metadata={...o.metadata,...n.extractContext(r)}),n.getSuggestions(o)||[]}function Go(r){const t=pe.findIndex(n=>n.id===r.id);if(t>=0)pe[t]=r;else{const n=pe.findIndex(o=>o.id==="default");n>=0?pe.splice(n,0,r):pe.push(r)}}const Qo=Go;function jt(){const{context:r}=vt(),t=Ce(),n=e.computed(()=>{var u;if(t.quota.remaining===0){const d=q();return(d==null?void 0:d.enableSupportMode)!==!1?[{id:"contact-support-quota",title:J("contactSupport"),description:J("noQuota"),prompt:"I need help with my account",className:"rai-suggestion--warning",isSupportRequest:!0}]:[]}const a=((u=r.value)==null?void 0:u.routePath)||(typeof window<"u"?window.location.pathname:"/"),i=vn(a,r.value)||[],l=q();return l!=null&&l.can?i.filter(d=>!(d.permission&&!l.can(d.permission))):i}),o=e.computed(()=>r.value!==null&&r.value.pageType!=="default");function s(a){return typeof a.prompt=="function"?a.prompt(r.value||{pageType:"default"}):a.prompt}return{suggestions:n,hasContextualSuggestions:o,resolvePrompt:s}}function Zo(r,t){const{setContext:n,clearContext:o,updateContext:s}=vt();function a(){if(!t)return{};const l={};for(const[u,d]of Object.entries(t))l[u]=e.isRef(d)?d.value:d;return l}function i(){const l={pageType:r,routePath:typeof window<"u"?window.location.pathname:void 0,metadata:a()};n(l)}return e.onMounted(()=>{i()}),e.onUnmounted(()=>{o()}),t&&e.watch(()=>a(),l=>{s({metadata:l})},{deep:!0}),{setupContext:i}}function Yo(r){const t=r.toLowerCase().split("+");return{key:t.pop()||"",meta:t.includes("cmd")||t.includes("meta")||t.includes("command"),ctrl:t.includes("ctrl")||t.includes("control"),shift:t.includes("shift"),alt:t.includes("alt")||t.includes("option"),mod:t.includes("mod")}}function Xo(r,t){const n=r.key.toLowerCase();if(t.mod){const d=navigator.platform.toUpperCase().indexOf("MAC")>=0||navigator.userAgent.toUpperCase().indexOf("MAC")>=0?r.metaKey:r.ctrlKey,p=t.shift?r.shiftKey:!r.shiftKey,f=t.alt?r.altKey:!r.altKey;return n===t.key&&d&&p&&f}const o=t.meta?r.metaKey:!r.metaKey,s=t.ctrl?r.ctrlKey:!r.ctrlKey,a=t.shift?r.shiftKey:!r.shiftKey,i=t.alt?r.altKey:!r.altKey;let l=o&&s&&a&&i;return(t.meta&&!t.ctrl||!t.meta&&t.ctrl)&&(l=(r.metaKey||r.ctrlKey)&&a&&i),n===t.key&&l}function jn(r){const{onToggle:t,enabled:n=!0}=r,o=e.ref(!1),s=r.shortcut!==void 0?r.shortcut:Te("keyboardShortcut")??"mod+g";if(s===null)return{isActive:o};const a=Yo(s);function i(l){if(!n)return;const u=l.target,d=u.tagName==="INPUT"||u.tagName==="TEXTAREA",p=u.isContentEditable,f=u.closest("[data-ai-input]");if(!((d||p)&&!f)&&Xo(l,a)){l.preventDefault(),l.stopPropagation();const k=q();if(k!=null&&k.canToggle&&!k.canToggle())return;o.value=!o.value,t()}}return e.onMounted(()=>{window.addEventListener("keydown",i,!0)}),e.onUnmounted(()=>{window.removeEventListener("keydown",i,!0)}),{isActive:o}}function Jo(r){const t=Ce();return jn({onToggle:()=>{r?r.value=!r.value:t.showChat=!t.showChat}})}function es(r,t){const n=e.ref(J("loadingText"));let o=[];function s(){return[J("loadingText"),J("analyzingText"),J("craftingText")]}function a(){return[0,2e3,5e3]}function i(){o.forEach(d=>clearTimeout(d)),o=[]}function l(){i();const d=t==null?void 0:t(),p=(d==null?void 0:d.messages)??s();n.value=p[0]||J("loadingText")}function u(){i();const d=t==null?void 0:t(),p=(d==null?void 0:d.messages)??s(),f=(d==null?void 0:d.intervals)??a();n.value=p[0]||J("loadingText");let k=0;for(let g=1;g<p.length;g++){k+=f[g]||2e3;const m=g,E=window.setTimeout(()=>{r()&&(n.value=p[m])},k);o.push(E)}}return e.onUnmounted(()=>{i()}),{loadingMessage:n,startLoadingText:u,resetLoadingText:l,clearLoadingTextTimers:i}}function ts(r){const{getHistoryLength:t,getStoreLimit:n,getConfig:o,getTexts:s,onStartNewChat:a,onNewChatEmit:i}=r,l=e.ref({showWarning:!1,isReached:!1,pendingMessage:null}),u=e.computed(()=>{var C;return((C=o())==null?void 0:C.limit)??n()}),d=e.computed(()=>{var C;return((C=o())==null?void 0:C.showWarningAt)??u.value-2}),p=e.computed(()=>Math.max(0,u.value-t())),f=e.computed(()=>p.value<=u.value-d.value&&p.value>0),k=e.computed(()=>p.value===0),g=e.computed(()=>{var C,w;return l.value.isReached?((C=s())==null?void 0:C.historyLimitReachedTitle)??"Chat Limit Reached":((w=s())==null?void 0:w.historyLimitWarningTitle)??"Approaching Chat Limit"}),m=e.computed(()=>{var C,w,z,$;return l.value.isReached?((C=o())==null?void 0:C.limitMessage)??((w=s())==null?void 0:w.historyLimitReachedMessage)??"You have reached the maximum number of messages in this conversation. Start a new chat to continue.":((z=o())==null?void 0:z.warningMessage)??(($=s())==null?void 0:$.historyLimitWarningMessage)??`You have ${p.value} message${p.value===1?"":"s"} remaining in this conversation.`});function E(){l.value.showWarning=!1,l.value.isReached=!1,l.value.pendingMessage=null}async function y(){l.value.showWarning=!1;const C=o();if(C!=null&&C.onLimitReached&&!await C.onLimitReached())return l.value.isReached=!1,null;if(a(),i(),l.value.isReached=!1,l.value.pendingMessage){const w=l.value.pendingMessage;return l.value.pendingMessage=null,w}return null}function h(){return k.value?(l.value.isReached=!0,l.value.showWarning=!0,!1):(f.value&&!l.value.showWarning&&(l.value.showWarning=!0),!0)}function b(C){l.value.pendingMessage=C}return{showHistoryLimitWarning:e.computed(()=>l.value.showWarning),historyLimitReached:e.computed(()=>l.value.isReached),historyLimit:u,remainingMessages:p,historyLimitDialogTitle:g,historyLimitDialogMessage:m,dismissHistoryLimitWarning:E,handleHistoryLimitAction:y,checkHistoryLimit:h,setPendingMessage:b}}function ns(){const r=Ce(),t=e.ref([]),n=e.ref(!1),o=e.ref(0),s=Te("maxAttachments")||5,a=Te("maxFileSize")||10*1024*1024,i=Te("acceptedFileTypes")||"image/*,.pdf,.txt,.doc,.docx,.xls,.xlsx,.csv",l=e.computed(()=>t.value.length>0),u=e.computed(()=>t.value.some(S=>S.uploading)),d=e.computed(()=>t.value.length<s);function p(S){return(S.type||"").startsWith("image/")?!0:/(png|jpe?g|gif|webp)$/i.test(S.name)}function f(S){if(S==null)return"";const T=typeof S=="string"?parseInt(S,10):S;return Number.isNaN(T)?"":T>=1024*1024?`${(T/(1024*1024)).toFixed(1)} MB`:T>=1024?`${Math.round(T/1024)} KB`:`${T} B`}function k(S){var fe;const T=crypto.randomUUID(),N=S.type.startsWith("image/")?URL.createObjectURL(S):void 0,D=q(),M=!!((fe=D==null?void 0:D.endpoints)!=null&&fe.uploadFile),Q={id:T,name:S.name,type:S.type,size:S.size,uploading:M,progress:M?0:100,previewUrl:N};t.value.push(Q),M&&g(S,T)}async function g(S,T){try{const N=await r.uploadFile(S),D=t.value.findIndex(M=>M.id===T);if(D===-1)return;if(N){const M=t.value[D].previewUrl;t.value[D]={...t.value[D],id:N.id||T,url:N.url,extractedText:N.extractedText,uploading:!1,progress:100,previewUrl:M||N.previewUrl}}else m(T)}catch{m(T)}}function m(S){const T=t.value.findIndex(D=>D.id===S);if(T===-1)return;const[N]=t.value.splice(T,1);N!=null&&N.previewUrl&&URL.revokeObjectURL(N.previewUrl)}function E(){t.value.forEach(S=>{S.previewUrl&&URL.revokeObjectURL(S.previewUrl)}),t.value=[]}function y(){return t.value.filter(S=>!S.uploading).map(S=>({id:S.id,name:S.name,url:S.url,type:S.type,size:S.size}))}function h(S){if(!S)return;const T=Array.from(S);for(const N of T){if(t.value.length>=s)break;N.size>a||k(N)}}function b(S){var T;return Array.from(((T=S.dataTransfer)==null?void 0:T.types)||[]).includes("Files")}function C(S){b(S)&&(o.value+=1,n.value=!0)}function w(S){b(S)||S.preventDefault()}function z(S){b(S)&&(o.value=Math.max(0,o.value-1),o.value===0&&(n.value=!1))}function $(S){var T;b(S)&&(o.value=0,n.value=!1,h(((T=S.dataTransfer)==null?void 0:T.files)||null))}function F(S){const T=S.target,N=T.files;N&&N.length&&h(N),T.value=""}return e.onBeforeUnmount(()=>{E()}),{attachments:t,isDraggingFiles:n,hasAttachments:l,isUploading:u,canAddMore:d,acceptedFileTypes:i,isImage:p,formatFileSize:f,removeAttachment:m,clearAttachments:E,buildPayload:y,processFiles:h,handleFileSelect:F,handleDragEnter:C,handleDragOver:w,handleDragLeave:z,handleDrop:$}}function rs(r,t,n){const o=e.ref(!1),s=e.ref([]),a=e.ref(0),i=e.ref({inMention:!1,query:"",startPos:0}),l=e.ref([]),u=e.computed(()=>{const E=q();return(E==null?void 0:E.mentionProviders)||[]});function d(E){const y=n();if(!y)return;const h=y.selectionStart,b=cn(E,h);i.value=b,b.inMention&&b.query.length>=0?p(b.query):(o.value=!1,s.value=[])}async function p(E){const y=pn();if(y.length===0){o.value=!1;return}const h=[];for(const b of y)try{const C=await b.search(E);h.push(...C.map(w=>({...w,type:b.type})))}catch(C){console.warn(`Mention provider ${b.type} failed:`,C)}s.value=h.slice(0,10),o.value=h.length>0,a.value=0}function f(E){const{startPos:y}=i.value,h=r(),b=n(),C=h.slice(0,y),w=h.slice((b==null?void 0:b.selectionStart)||y),z=E.name||E.label||E.title||E.id;t(`${C}@${z} ${w}`),l.value.push({id:E.id,name:z,type:E.type,metadata:E.attributes}),o.value=!1,s.value=[],setTimeout(()=>{const $=n();$==null||$.focus();const F=C.length+z.length+2;$==null||$.setSelectionRange(F,F)},0)}function k(E){if(!o.value||s.value.length===0)return!1;if(E.key==="ArrowDown")return E.preventDefault(),a.value=Math.min(a.value+1,s.value.length-1),!0;if(E.key==="ArrowUp")return E.preventDefault(),a.value=Math.max(a.value-1,0),!0;if(E.key==="Enter"||E.key==="Tab"){E.preventDefault();const y=s.value[a.value];return y&&f(y),!0}return E.key==="Escape"?(E.preventDefault(),o.value=!1,!0):!1}function g(){l.value=[]}function m(){return[...l.value]}return{showMentions:o,mentionItems:s,selectedMentionIndex:a,mentionProviders:u,checkForMentions:d,handleMentionSelect:f,handleMentionKeyDown:k,clearMentions:g,getMentions:m}}function os(r,t,n,o,s){const a=e.ref(!1),i=e.ref(-1),l=e.ref(null);function u(){setTimeout(()=>{const g=l.value;if(!g)return;const m=g.querySelector(`li:nth-child(${i.value+1})`);m&&m.scrollIntoView({block:"nearest",behavior:"smooth"})},0)}function d(g){const m=r();if(!a.value||m.length===0)return!1;if(g.key==="ArrowDown")return g.preventDefault(),i.value=Math.min(i.value+1,m.length-1),u(),!0;if(g.key==="ArrowUp")return g.preventDefault(),i.value=Math.max(i.value-1,0),u(),!0;if(g.key==="Enter"&&i.value>=0){g.preventDefault();const E=m[i.value];return E&&p(E),!0}return g.key==="Escape"?(g.preventDefault(),a.value=!1,i.value=-1,!0):!1}function p(g){s(g),a.value=!1,i.value=-1}function f(){const g=o(),m=t(),E=n(),y=r();g&&!m&&E&&y.length>0?a.value=!0:a.value=!1}function k(){a.value=!1,i.value=-1}return{showSuggestions:a,selectedSuggestionIndex:i,dropdownRef:l,handleSuggestionKeyDown:d,handleSuggestionClick:p,updateSuggestionsVisibility:f,hideSuggestions:k}}function ss(r,t=300){function n(){const o=r();if(!o)return;o.style.height="auto";const s=Math.min(o.scrollHeight,t);o.style.height=`${s}px`,o.style.overflowY=o.scrollHeight>t?"auto":"hidden"}return e.onMounted(()=>{setTimeout(n,0)}),{adjustTextareaHeight:n}}const Wn=e.defineComponent({__name:"AiAvatar",props:{ui:{}},setup(r){return(t,n)=>{var o;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["w-6 h-6 min-w-[24px] flex items-center justify-center rounded-full border border-gray-300 dark:border-gray-600",(o=r.ui)==null?void 0:o.container])},[e.renderSlot(t.$slots,"default",{},()=>{var s;return[(e.openBlock(),e.createElementBlock("svg",{class:e.normalizeClass(["w-4 h-4 text-gray-400 dark:text-gray-500",(s=r.ui)==null?void 0:s.icon]),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},[...n[0]||(n[0]=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9.813 15.904 9 18.75l-.813-2.846a4.5 4.5 0 0 0-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 0 0 3.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 0 0 3.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 0 0-3.09 3.09Z"},null,-1)])],2))]})],2)}}}),as=e.defineComponent({__name:"UserAvatar",props:{ui:{}},setup(r){return(t,n)=>{var o;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["w-8 h-8 rounded-full bg-gray-200 dark:bg-gray-700 flex items-center justify-center flex-shrink-0",(o=r.ui)==null?void 0:o.container])},[e.renderSlot(t.$slots,"default",{},()=>{var s;return[(e.openBlock(),e.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",class:e.normalizeClass(["w-5 h-5 text-gray-500 dark:text-gray-400",(s=r.ui)==null?void 0:s.icon])},[...n[0]||(n[0]=[e.createElementVNode("path",{"fill-rule":"evenodd",d:"M7.5 6a4.5 4.5 0 1 1 9 0 4.5 4.5 0 0 1-9 0ZM3.751 20.105a8.25 8.25 0 0 1 16.498 0 .75.75 0 0 1-.437.695A18.683 18.683 0 0 1 12 22.5c-2.786 0-5.433-.608-7.812-1.7a.75.75 0 0 1-.437-.695Z","clip-rule":"evenodd"},null,-1)])],2))]})],2)}}}),is=["onClick","onMouseenter"],Kn=e.defineComponent({__name:"MentionList",props:{items:{},selectedIndex:{default:0},providers:{default:()=>[]},ui:{},texts:{}},emits:["select","update:selectedIndex"],setup(r,{emit:t}){const n=r,o=e.computed(()=>n.ui||{}),s=t,a=e.ref(n.selectedIndex);e.watch(()=>n.selectedIndex,y=>{a.value=y}),e.watch(a,y=>{s("update:selectedIndex",y)});const i=e.computed(()=>{const y={};return n.items.forEach(h=>{const b=h.type||"default";y[b]||(y[b]=[]),y[b].push(h)}),y});function l(y){return n.providers.find(h=>h.type===y)||dn(y)}function u(y){const h=l(y);return(h==null?void 0:h.label)||y.charAt(0).toUpperCase()+y.slice(1)+"s"}function d(y,h){let b=0;const C=Object.keys(i.value);for(const w of C){if(w===y)return b+h;b+=i.value[w].length}return b}function p(y){s("select",y)}function f(y){a.value=y,s("update:selectedIndex",y)}function k(y){const h=l(y.type);return At(y,h)}function g(y){const h=l(y.type);return un(y,h)}function m(y){const h={employee:"bg-blue-100 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400",job:"bg-green-100 dark:bg-green-900/30 text-green-600 dark:text-green-400",candidate:"bg-purple-100 dark:bg-purple-900/30 text-purple-600 dark:text-purple-400",project:"bg-orange-100 dark:bg-orange-900/30 text-orange-600 dark:text-orange-400",default:"bg-primary/10 text-primary"};return h[y]||h.default}function E(y){return y.split(" ").map(h=>h[0]).join("").slice(0,2).toUpperCase()}return(y,h)=>r.items.length>0?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["absolute bottom-full left-0 right-0 mb-2 bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 shadow-lg max-h-60 overflow-y-auto z-50",o.value.root])},[e.createElementVNode("div",{class:e.normalizeClass(["p-2",o.value.container])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,(b,C)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:C},[Object.keys(i.value).length>1?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["px-3 py-1.5 text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wide",o.value.groupHeader])},e.toDisplayString(u(C)),3)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(b,(w,z)=>(e.openBlock(),e.createElementBlock("button",{key:w.id,type:"button",class:e.normalizeClass(["w-full flex items-center gap-3 px-3 py-2 rounded-lg text-left transition-colors mb-0.5",[o.value.item,{[o.value.itemSelected||"bg-primary/10"]:d(C,z)===a.value,"hover:bg-gray-50 dark:hover:bg-gray-700":d(C,z)!==a.value}]]),onClick:$=>p(w),onMouseenter:$=>f(d(C,z))},[e.renderSlot(y.$slots,"item-icon",{item:w,type:C},()=>[e.createElementVNode("span",{class:e.normalizeClass(["w-8 h-8 flex items-center justify-center rounded-full text-xs font-semibold flex-shrink-0",[o.value.itemIcon,m(w.type)]])},e.toDisplayString(E(k(w))),3)]),e.createElementVNode("div",{class:e.normalizeClass(["flex-1 min-w-0",o.value.itemContent])},[e.createElementVNode("p",{class:e.normalizeClass(["text-sm font-medium text-gray-900 dark:text-gray-100 truncate",o.value.itemName])},e.toDisplayString(k(w)),3),g(w)?(e.openBlock(),e.createElementBlock("p",{key:0,class:e.normalizeClass(["text-xs text-gray-500 dark:text-gray-400 truncate",o.value.itemSubtitle])},e.toDisplayString(g(w)),3)):e.createCommentVNode("",!0)],2)],42,is))),128))],64))),128))],2)],2)):e.createCommentVNode("",!0)}}),ls=["title"],cs={key:0,class:"w-4 h-4 text-gray-500 dark:text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},Gn=e.defineComponent({__name:"ChatMessageActions",props:{message:{},ui:{},texts:{}},emits:["copy"],setup(r,{emit:t}){const n=r,o=t,s=u=>{var p;return(p=n.texts)!=null&&p[u]?n.texts[u]:J({copyToClipboard:"copyToClipboard",copied:"copied"}[u])},a=e.computed(()=>n.ui||{}),i=e.ref(!1);async function l(){try{await navigator.clipboard.writeText(n.message.message),i.value=!0,o("copy",n.message),setTimeout(()=>{i.value=!1},2e3)}catch(u){console.error("Failed to copy:",u)}}return(u,d)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",a.value.container])},[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors",[a.value.button,a.value.copyButton]]),title:i.value?s("copied"):s("copyToClipboard"),onClick:l},[i.value?(e.openBlock(),e.createElementBlock("svg",{key:1,class:e.normalizeClass(["w-4 h-4 text-green-500",a.value.successState]),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[...d[1]||(d[1]=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 13l4 4L19 7"},null,-1)])],2)):(e.openBlock(),e.createElementBlock("svg",cs,[...d[0]||(d[0]=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.5",d:"M15.666 3.888A2.25 2.25 0 0013.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 01-.75.75H9a.75.75 0 01-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 01-2.25 2.25H6.75A2.25 2.25 0 014.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 011.927-.184"},null,-1)])]))],10,ls)],2))}}),us={class:"h-12 w-12 flex items-center justify-center rounded-lg bg-white/20 overflow-hidden"},ds=["src"],ps={key:1,class:"w-5 h-5 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},fs={class:"flex-1 min-w-0"},ms={class:"text-sm font-semibold text-white truncate"},hs={class:"text-xs text-white/70"},gs={key:0,class:"text-xs font-medium text-white/90"},ys=["src"],ks={key:1,class:"h-4 w-4 text-white",viewBox:"0 0 24 24",fill:"currentColor"},xs={class:"flex-shrink-0 mt-0.5"},ws={class:"text-gray-600 dark:text-gray-400"},bs=["id","innerHTML"],Es={class:"h-12 w-12 flex items-center justify-center rounded-lg bg-white dark:bg-gray-800 overflow-hidden border border-gray-200 dark:border-gray-600"},Cs=["src"],Ss={key:1,class:"w-5 h-5 text-gray-500 dark:text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},Ts={class:"flex-1 min-w-0"},As={class:"text-sm font-semibold text-gray-800 dark:text-gray-200 truncate"},Ms={class:"text-xs text-gray-500 dark:text-gray-400"},Ns={key:0,class:"text-xs font-medium text-primary"},Rs=e.defineComponent({__name:"ChatMessage",props:{message:{},showActions:{type:Boolean,default:!0},loadingText:{default:"Gathering data..."},ui:{},texts:{}},emits:["copy"],setup(r,{emit:t}){const n=r,o=t,s=h=>{var C;return(C=n.texts)!=null&&C[h]?n.texts[h]:{loadingText:"Gathering data...",showMore:"Show more",showLess:"Show less",openAttachment:"Open",attachment:"Attachment"}[h]||h},a=e.computed(()=>n.ui||{}),{parseMarkdown:i}=Un(),l=e.ref(!1),u=e.computed(()=>n.message.attachments??[]),d=e.computed(()=>u.value.length>0),p=e.computed(()=>{if(n.message.role!=="user")return!1;const h=n.message.message||"",b=h.split(`
|
|
59
|
-
`).length;return
|
|
60
|
-
`),i(h)}return n.message.message});function y(h){o("copy",h)}return(h,b)=>{var C;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["group relative animate-in fade-in slide-in-from-bottom-2 duration-300",[a.value.root,{"flex justify-end":r.message.role==="user","flex justify-start":r.message.role==="assistant"}]])},[r.message.role==="user"?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["flex gap-3 justify-end",a.value.userMessage])},[e.createElementVNode("div",{class:e.normalizeClass(["rounded-2xl px-4 py-3 bg-primary-500 text-white max-w-fit",a.value.userBubble])},[r.message.message?(e.openBlock(),e.createElementBlock("p",{key:0,class:e.normalizeClass(["text-sm whitespace-pre-wrap",[a.value.content,{"line-clamp-4":!l.value&&p.value}]])},e.toDisplayString(r.message.message),3)):e.createCommentVNode("",!0),p.value?(e.openBlock(),e.createElementBlock("button",{key:1,class:e.normalizeClass(["mt-2 text-xs text-white/80 hover:text-white underline",a.value.showMoreButton]),onClick:f},e.toDisplayString(l.value?s("showLess"):s("showMore")),3)):e.createCommentVNode("",!0),d.value?(e.openBlock(),e.createElementBlock("div",{key:2,class:e.normalizeClass(["mt-3 space-y-2",a.value.attachmentsContainer])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(u.value,w=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(w.url?"a":"div"),{key:w.id,href:w.url||void 0,target:w.url?"_blank":void 0,rel:"noopener noreferrer",class:e.normalizeClass(["flex items-center gap-3 rounded-xl border border-white/20 bg-white/10 p-2 transition",[a.value.attachmentItem,w.url?"hover:bg-white/20 cursor-pointer":""]])},{default:e.withCtx(()=>[e.createElementVNode("div",us,[w.url&&k(w)?(e.openBlock(),e.createElementBlock("img",{key:0,src:w.url,class:"object-cover h-full w-full",alt:""},null,8,ds)):(e.openBlock(),e.createElementBlock("svg",ps,[...b[0]||(b[0]=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.5",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"},null,-1)])]))]),e.createElementVNode("div",fs,[e.createElementVNode("p",ms,e.toDisplayString(w.name||s("attachment")),1),e.createElementVNode("p",hs,e.toDisplayString(m(w.size)),1)]),w.url?(e.openBlock(),e.createElementBlock("span",gs,e.toDisplayString(s("openAttachment")),1)):e.createCommentVNode("",!0)]),_:2},1032,["href","target","class"]))),128))],2)):e.createCommentVNode("",!0)],2),e.createElementVNode("div",{class:e.normalizeClass(["flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary-500 overflow-hidden",a.value.userAvatar])},[g.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:g.value,alt:"User",class:"h-full w-full object-cover"},null,8,ys)):(e.openBlock(),e.createElementBlock("svg",ks,[...b[1]||(b[1]=[e.createElementVNode("path",{"fill-rule":"evenodd",d:"M7.5 6a4.5 4.5 0 1 1 9 0 4.5 4.5 0 0 1-9 0ZM3.751 20.105a8.25 8.25 0 0 1 16.498 0 .75.75 0 0 1-.437.695A18.683 18.683 0 0 1 12 22.5c-2.786 0-5.433-.608-7.812-1.7a.75.75 0 0 1-.437-.695Z","clip-rule":"evenodd"},null,-1)])]))],2)],2)):(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["flex items-start gap-3",a.value.assistantMessage])},[e.createElementVNode("div",xs,[e.createVNode(Wn)]),e.createElementVNode("div",{class:e.normalizeClass(["bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 px-5 py-4 shadow-sm rounded-2xl transition-all duration-200 flex-1",a.value.assistantBubble])},[r.message.loading?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["flex items-center gap-2 text-sm min-w-[150px]",a.value.loadingIndicator])},[e.createElementVNode("div",{class:e.normalizeClass(["flex space-x-1",a.value.loadingDots])},[...b[2]||(b[2]=[e.createElementVNode("div",{class:"w-2 h-2 bg-gray-400 rounded-full animate-bounce",style:{"animation-delay":"0ms"}},null,-1),e.createElementVNode("div",{class:"w-2 h-2 bg-gray-400 rounded-full animate-bounce",style:{"animation-delay":"150ms"}},null,-1),e.createElementVNode("div",{class:"w-2 h-2 bg-gray-400 rounded-full animate-bounce",style:{"animation-delay":"300ms"}},null,-1)])],2),e.createElementVNode("span",ws,e.toDisplayString(((C=r.texts)==null?void 0:C.loadingText)||r.loadingText),1)],2)):r.message.message?(e.openBlock(),e.createElementBlock("div",{key:1,id:r.message.id,class:e.normalizeClass(["prose prose-sm max-w-none prose-gray dark:prose-invert",a.value.content]),innerHTML:E.value},null,10,bs)):e.createCommentVNode("",!0),!r.message.loading&&d.value?(e.openBlock(),e.createElementBlock("div",{key:2,class:e.normalizeClass(["mt-4 space-y-2",a.value.attachmentsContainer])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(u.value,w=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(w.url?"a":"div"),{key:w.id,href:w.url||void 0,target:w.url?"_blank":void 0,rel:"noopener noreferrer",class:e.normalizeClass(["flex items-center gap-3 rounded-xl border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 p-3 transition",[a.value.attachmentItem,w.url?"hover:bg-white dark:hover:bg-gray-600 cursor-pointer":""]])},{default:e.withCtx(()=>[e.createElementVNode("div",Es,[w.url&&k(w)?(e.openBlock(),e.createElementBlock("img",{key:0,src:w.url,class:"object-cover h-full w-full",alt:""},null,8,Cs)):(e.openBlock(),e.createElementBlock("svg",Ss,[...b[3]||(b[3]=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.5",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"},null,-1)])]))]),e.createElementVNode("div",Ts,[e.createElementVNode("p",As,e.toDisplayString(w.name||s("attachment")),1),e.createElementVNode("p",Ms,e.toDisplayString(m(w.size)),1)]),w.url?(e.openBlock(),e.createElementBlock("span",Ns,e.toDisplayString(s("openAttachment")),1)):e.createCommentVNode("",!0)]),_:2},1032,["href","target","class"]))),128))],2)):e.createCommentVNode("",!0)],2)],2)),r.message.role==="assistant"&&!r.message.loading&&!r.message.streaming&&r.showActions?(e.openBlock(),e.createBlock(Gn,{key:2,message:r.message,class:e.normalizeClass(["absolute -bottom-8 left-14",a.value.actionsContainer]),onCopy:y},null,8,["message","class"])):e.createCommentVNode("",!0)],2)}}}),Qn=(r,t)=>{const n=r.__vccOpts||r;for(const[o,s]of t)n[o]=s;return n},Zn=Qn(Rs,[["__scopeId","data-v-5f7bccb0"]]),Bs={class:"text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wide"},Ls={class:"space-y-2"},Ds=["src"],Is={key:1,class:"w-5 h-5 text-gray-500 dark:text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},zs={class:"flex-1 min-w-0"},$s={class:"text-sm font-medium text-gray-800 dark:text-gray-200 truncate"},Os={class:"text-xs text-gray-500 dark:text-gray-400"},Vs={key:0,class:"mt-1 h-1 bg-gray-200 dark:bg-gray-600 rounded-full overflow-hidden"},Ps={key:0,class:"text-xs text-gray-400"},_s=["disabled","onClick"],Fs=e.defineComponent({__name:"AttachmentsPreview",props:{attachments:{},ui:{},texts:{},isImage:{type:Function},formatFileSize:{type:Function}},emits:["remove"],setup(r){return(t,n)=>{var o;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["border border-gray-200 dark:border-gray-700 rounded-2xl p-3 bg-gray-50 dark:bg-gray-800 space-y-3",r.ui.attachmentsContainer])},[e.createElementVNode("p",Bs,e.toDisplayString(((o=r.texts)==null?void 0:o.attachedFiles)||"Attached files"),1),e.createElementVNode("ul",Ls,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.attachments,s=>(e.openBlock(),e.createElementBlock("li",{key:s.id,class:e.normalizeClass(["flex items-center gap-3 rounded-xl bg-white dark:bg-gray-700 p-2 shadow-sm border border-gray-100 dark:border-gray-600",r.ui.attachmentItem])},[e.createElementVNode("div",{class:e.normalizeClass(["h-10 w-10 flex items-center justify-center rounded-lg bg-gray-100 dark:bg-gray-600 overflow-hidden",r.ui.attachmentThumbnail])},[r.isImage(s)?(e.openBlock(),e.createElementBlock("img",{key:0,src:s.previewUrl||s.url,class:"object-cover h-full w-full",alt:""},null,8,Ds)):(e.openBlock(),e.createElementBlock("svg",Is,[...n[0]||(n[0]=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.5",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"},null,-1)])]))],2),e.createElementVNode("div",zs,[e.createElementVNode("p",$s,e.toDisplayString(s.name),1),e.createElementVNode("p",Os,e.toDisplayString(r.formatFileSize(s.size)),1),s.uploading?(e.openBlock(),e.createElementBlock("div",Vs,[e.createElementVNode("div",{class:"h-full bg-primary transition-all",style:e.normalizeStyle({width:`${s.progress??10}%`})},null,4)])):e.createCommentVNode("",!0)]),s.uploading?(e.openBlock(),e.createElementBlock("span",Ps,e.toDisplayString(Math.round(s.progress??0))+"% ",1)):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["p-1 rounded-full hover:bg-gray-100 dark:hover:bg-gray-600 disabled:opacity-50 disabled:cursor-not-allowed",r.ui.attachmentRemove]),disabled:s.uploading,onClick:a=>t.$emit("remove",s.id)},[...n[1]||(n[1]=[e.createElementVNode("svg",{class:"w-4 h-4 text-gray-500 dark:text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.5",d:"M6 18L18 6M6 6l12 12"})],-1)])],10,_s)],2))),128))])],2)}}}),Hs={class:"py-1"},Us=["onClick","onMouseenter"],qs={class:"flex items-start gap-3"},vs={class:"flex-1 min-w-0"},js={class:"text-sm font-medium text-gray-900 dark:text-gray-100"},Ws={class:"text-xs text-gray-500 dark:text-gray-400 mt-0.5 line-clamp-2"},Ks=e.defineComponent({__name:"SuggestionsDropdown",props:{suggestions:{},selectedIndex:{},ui:{}},emits:["select","hover"],setup(r,{expose:t}){const n=e.ref(null);return t({dropdownRef:n}),(o,s)=>(e.openBlock(),e.createBlock(e.Transition,{"enter-active-class":"transition ease-out duration-100","enter-from-class":"transform opacity-0 scale-95","enter-to-class":"transform opacity-100 scale-100","leave-active-class":"transition ease-in duration-75","leave-from-class":"transform opacity-100 scale-100","leave-to-class":"transform opacity-0 scale-95"},{default:e.withCtx(()=>[e.createElementVNode("div",{ref_key:"dropdownRef",ref:n,class:e.normalizeClass(["absolute bottom-full left-0 right-0 mb-2 bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 shadow-lg max-h-80 overflow-y-auto z-10",r.ui.suggestionsDropdown])},[e.createElementVNode("ul",Hs,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.suggestions,(a,i)=>(e.openBlock(),e.createElementBlock("li",{key:a.id,class:e.normalizeClass(["px-4 py-3 cursor-pointer transition-colors border-b border-gray-100 dark:border-gray-700 last:border-b-0",[r.ui.suggestionItem,{[r.ui.suggestionItemSelected||"bg-primary/10"]:i===r.selectedIndex,"hover:bg-gray-50 dark:hover:bg-gray-700":i!==r.selectedIndex}]]),onClick:l=>o.$emit("select",a),onMouseenter:l=>o.$emit("hover",i)},[e.createElementVNode("div",qs,[e.createElementVNode("div",vs,[e.createElementVNode("p",js,e.toDisplayString(a.title),1),e.createElementVNode("p",Ws,e.toDisplayString(a.description),1)])])],42,Us))),128))])],2)]),_:1}))}}),Gs={class:"absolute right-3 top-1/2 -translate-y-1/2 flex items-center gap-1 z-10"},Qs=["title"],Zs=["title"],Ys=["disabled"],Xs={key:0,class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},Js={key:1,class:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor"},ea=e.defineComponent({__name:"InputActions",props:{sending:{type:Boolean},canSend:{type:Boolean},supportRequestMode:{type:Boolean},showSupportModeToggle:{type:Boolean},ui:{},texts:{}},emits:["toggle-support-mode","click"],setup(r){const t=r,n=e.computed(()=>t.sending?[t.ui.stopButton||"bg-red-500 text-white hover:bg-red-600"]:t.canSend?[t.ui.sendButtonActive||"bg-primary-500 text-white hover:bg-primary-600"]:[t.ui.sendButtonDisabled||"bg-gray-200 dark:bg-gray-700 text-gray-400 dark:text-gray-500 cursor-not-allowed opacity-60"]);return(o,s)=>{var a,i,l;return e.openBlock(),e.createElementBlock("div",Gs,[r.showSupportModeToggle&&!r.supportRequestMode?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:e.normalizeClass(["h-9 w-9 rounded-xl flex items-center justify-center text-gray-400 hover:text-primary hover:bg-gray-100 dark:hover:bg-gray-700 transition flex-shrink-0",r.ui.supportToggle]),title:((a=r.texts)==null?void 0:a.toggleSupportMode)||"Toggle support mode",onClick:s[0]||(s[0]=u=>o.$emit("toggle-support-mode"))},[...s[3]||(s[3]=[e.createElementVNode("svg",{class:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827v.75M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9 5.25h.008v.008H12v-.008z"})],-1)])],10,Qs)):e.createCommentVNode("",!0),r.showSupportModeToggle&&r.supportRequestMode?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:e.normalizeClass(["h-7 px-2 rounded-lg flex items-center gap-1 text-xs font-medium bg-amber-100 dark:bg-amber-900/30 text-amber-700 dark:text-amber-400 hover:bg-amber-200 dark:hover:bg-amber-900/50 transition flex-shrink-0",r.ui.supportBadge]),title:((i=r.texts)==null?void 0:i.exitSupportMode)||"Exit support mode",onClick:s[1]||(s[1]=u=>o.$emit("toggle-support-mode"))},[s[4]||(s[4]=e.createElementVNode("svg",{class:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827v.75M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9 5.25h.008v.008H12v-.008z"})],-1)),e.createElementVNode("span",null,e.toDisplayString(((l=r.texts)==null?void 0:l.supportLabel)||"Support"),1),s[5]||(s[5]=e.createElementVNode("svg",{class:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M6 18L18 6M6 6l12 12"})],-1))],10,Zs)):e.createCommentVNode("",!0),e.createElementVNode("button",{disabled:!r.canSend&&!r.sending,class:e.normalizeClass(["h-9 w-9 rounded-xl flex items-center justify-center transition-all duration-200 flex-shrink-0",n.value]),type:"button",onClick:s[2]||(s[2]=e.withModifiers(u=>o.$emit("click"),["prevent"]))},[r.sending?(e.openBlock(),e.createElementBlock("svg",Js,[...s[7]||(s[7]=[e.createElementVNode("path",{"fill-rule":"evenodd",d:"M4.5 7.5a3 3 0 013-3h9a3 3 0 013 3v9a3 3 0 01-3 3h-9a3 3 0 01-3-3v-9z","clip-rule":"evenodd"},null,-1)])])):(e.openBlock(),e.createElementBlock("svg",Xs,[...s[6]||(s[6]=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 12L3.269 3.126A59.768 59.768 0 0121.485 12 59.77 59.77 0 013.27 20.876L5.999 12zm0 0h7.5"},null,-1)])]))],10,Ys)])}}}),ta={class:"max-w-3xl mx-auto space-y-3"},na=["accept"],ra=["title"],oa={class:"flex items-center"},sa=["placeholder","disabled"],aa={key:0,class:"flex justify-center"},Yn=e.defineComponent({__name:"ChatInput",props:{modelValue:{},disabled:{type:Boolean,default:!1},sending:{type:Boolean,default:!1},placeholder:{default:"Ask me anything..."},supportPlaceholder:{default:"Describe your support request..."},minLength:{default:3},suggestions:{default:()=>[]},hasHistory:{type:Boolean,default:!1},supportRequestMode:{type:Boolean,default:!1},showSupportModeToggle:{type:Boolean,default:!1},contextLinkText:{default:""},ui:{},texts:{}},emits:["update:modelValue","submit","cancel","suggestion-select","toggle-support-mode","context-link-click"],setup(r,{emit:t}){const n=r,o=e.computed(()=>n.ui||{}),s=t,a=e.ref(n.modelValue),i=e.ref(null),l=e.ref(null),u=e.ref(!1),d=ns(),p=rs(()=>a.value,T=>{a.value=T},()=>i.value),f=os(()=>n.suggestions,()=>n.hasHistory,()=>u.value,()=>a.value,T=>{s("suggestion-select",T),e.nextTick(()=>{var N;return(N=i.value)==null?void 0:N.focus()})}),{adjustTextareaHeight:k}=ss(()=>i.value),g=e.computed(()=>n.supportRequestMode?n.supportPlaceholder:n.placeholder),m=e.computed(()=>n.showSupportModeToggle?n.supportRequestMode?{paddingLeft:"3rem",paddingRight:"8rem"}:{paddingLeft:"3rem",paddingRight:"6rem"}:{paddingLeft:"3rem",paddingRight:"3.5rem"}),E=e.computed(()=>{var N;return(((N=a.value)==null?void 0:N.trim())??"").length>=n.minLength?!0:d.hasAttachments.value}),y=e.computed(()=>!n.disabled&&!n.sending&&E.value&&!d.isUploading.value);e.watch(()=>n.modelValue,T=>{a.value=T,e.nextTick(k)}),e.watch(a,T=>{s("update:modelValue",T),e.nextTick(k),p.checkForMentions(T),f.updateSuggestionsVisibility()}),e.watch(()=>n.suggestions,()=>{f.updateSuggestionsVisibility()});function h(){k()}function b(T){if(!p.handleMentionKeyDown(T)&&!f.handleSuggestionKeyDown(T)&&T.key==="Enter"){if(T.shiftKey)return;!n.sending&&y.value&&(T.preventDefault(),C())}}function C(){if(!y.value)return;const T=d.buildPayload(),N=a.value.trim(),D=p.getMentions();s("submit",{message:N,attachments:T,mentions:D,isSupportRequest:n.supportRequestMode}),a.value="",d.clearAttachments(),p.clearMentions(),e.nextTick(k)}function w(){n.sending?s("cancel"):y.value&&C()}function z(){var T;n.disabled||n.sending||d.canAddMore.value&&((T=l.value)==null||T.click())}function $(T){f.handleSuggestionClick(T)}function F(){u.value=!0,f.updateSuggestionsVisibility()}function S(){u.value=!1,setTimeout(()=>{f.hideSuggestions(),p.showMentions.value=!1},200)}return e.onMounted(()=>{e.nextTick(k)}),(T,N)=>{var D;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["px-4 pb-4 bg-white dark:bg-gray-900 sticky bottom-0",o.value.root]),onDragenter:N[6]||(N[6]=e.withModifiers((...M)=>e.unref(d).handleDragEnter&&e.unref(d).handleDragEnter(...M),["prevent"])),onDragover:N[7]||(N[7]=e.withModifiers((...M)=>e.unref(d).handleDragOver&&e.unref(d).handleDragOver(...M),["prevent"])),onDragleave:N[8]||(N[8]=e.withModifiers((...M)=>e.unref(d).handleDragLeave&&e.unref(d).handleDragLeave(...M),["prevent"])),onDrop:N[9]||(N[9]=e.withModifiers((...M)=>e.unref(d).handleDrop&&e.unref(d).handleDrop(...M),["prevent"]))},[e.createElementVNode("form",{class:e.normalizeClass(o.value.form),onSubmit:e.withModifiers(C,["prevent"])},[e.createElementVNode("div",ta,[e.createElementVNode("input",{ref_key:"fileInputRef",ref:l,type:"file",class:"hidden",multiple:"",accept:e.unref(d).acceptedFileTypes,onChange:N[0]||(N[0]=(...M)=>e.unref(d).handleFileSelect&&e.unref(d).handleFileSelect(...M))},null,40,na),e.unref(d).hasAttachments.value?(e.openBlock(),e.createBlock(Fs,{key:0,attachments:e.unref(d).attachments.value,ui:o.value,texts:r.texts,"is-image":e.unref(d).isImage,"format-file-size":e.unref(d).formatFileSize,onRemove:e.unref(d).removeAttachment},null,8,["attachments","ui","texts","is-image","format-file-size","onRemove"])):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["relative",o.value.inputContainer])},[e.unref(f).showSuggestions.value&&r.suggestions.length>0?(e.openBlock(),e.createBlock(Ks,{key:0,ref:"suggestionsHandler.dropdownRef.value",suggestions:r.suggestions,"selected-index":e.unref(f).selectedSuggestionIndex.value,ui:o.value,onSelect:$,onHover:N[1]||(N[1]=M=>e.unref(f).selectedSuggestionIndex.value=M)},null,8,["suggestions","selected-index","ui"])):e.createCommentVNode("",!0),e.createVNode(e.Transition,{"enter-active-class":"transition ease-out duration-100","enter-from-class":"transform opacity-0 scale-95","enter-to-class":"transform opacity-100 scale-100","leave-active-class":"transition ease-in duration-75","leave-from-class":"transform opacity-100 scale-100","leave-to-class":"transform opacity-0 scale-95"},{default:e.withCtx(()=>[e.unref(p).showMentions.value&&e.unref(p).mentionItems.value.length>0?(e.openBlock(),e.createBlock(Kn,{key:0,items:e.unref(p).mentionItems.value,"selected-index":e.unref(p).selectedMentionIndex.value,providers:e.unref(p).mentionProviders.value,onSelect:e.unref(p).handleMentionSelect,"onUpdate:selectedIndex":N[2]||(N[2]=M=>e.unref(p).selectedMentionIndex.value=M)},null,8,["items","selected-index","providers","onSelect"])):e.createCommentVNode("",!0)]),_:1}),e.createElementVNode("div",{class:e.normalizeClass(["rounded-2xl border shadow-lg transition-all duration-200 bg-white dark:bg-gray-800",[o.value.inputWrapper,{"border-primary shadow-primary/30":u.value||e.unref(d).isDraggingFiles.value,"border-gray-200 dark:border-gray-700 shadow-gray-100 dark:shadow-gray-900":!u.value&&!e.unref(d).isDraggingFiles.value}]])},[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["absolute left-3 top-1/2 -translate-y-1/2 h-9 w-9 rounded-xl flex items-center justify-center text-gray-500 dark:text-gray-400 hover:text-primary transition z-10",o.value.attachButton]),title:((D=r.texts)==null?void 0:D.attachFiles)||"Attach files",onClick:z},[...N[10]||(N[10]=[e.createElementVNode("svg",{class:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.5",d:"M18.375 12.739l-7.693 7.693a4.5 4.5 0 01-6.364-6.364l10.94-10.94A3 3 0 1119.5 7.372L8.552 18.32m.009-.01l-.01.01m5.699-9.941l-7.81 7.81a1.5 1.5 0 002.112 2.13"})],-1)])],10,ra),e.createElementVNode("div",oa,[e.withDirectives(e.createElementVNode("textarea",{ref_key:"textareaRef",ref:i,"onUpdate:modelValue":N[3]||(N[3]=M=>a.value=M),rows:"1","data-ai-input":"",placeholder:g.value,disabled:r.disabled,class:e.normalizeClass(["block w-full bg-transparent py-3 text-sm leading-5 text-gray-900 dark:text-gray-100 placeholder:text-gray-400 dark:placeholder:text-gray-500 border-0 focus:outline-none focus-visible:outline-none resize-none",o.value.textarea]),style:e.normalizeStyle(m.value),onInput:h,onKeydown:b,onFocus:F,onBlur:S},null,46,sa),[[e.vModelText,a.value]])]),e.createVNode(ea,{sending:r.sending,"can-send":y.value,"support-request-mode":r.supportRequestMode,"show-support-mode-toggle":r.showSupportModeToggle,ui:o.value,texts:r.texts,onToggleSupportMode:N[4]||(N[4]=M=>T.$emit("toggle-support-mode")),onClick:w},null,8,["sending","can-send","support-request-mode","show-support-mode-toggle","ui","texts"])],2)],2),e.renderSlot(T.$slots,"context-link",{},()=>[r.contextLinkText?(e.openBlock(),e.createElementBlock("div",aa,[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["text-xs text-gray-400 hover:text-primary transition-colors",o.value.contextLink]),onClick:N[5]||(N[5]=M=>T.$emit("context-link-click"))},e.toDisplayString(r.contextLinkText),3)])):e.createCommentVNode("",!0)])])],34)],34)}}}),ia=["onClick"],Xn=e.defineComponent({__name:"AiEmptyState",props:{ui:{},texts:{}},emits:["item-click"],setup(r,{emit:t}){const n=r,o=t,s=k=>{var m;return(m=n.texts)!=null&&m[k]?n.texts[k]:J({aiName:"aiName",title:"emptyStateTitle",description:"emptyStateDescription"}[k])},a=e.computed(()=>n.ui||{}),{suggestions:i,resolvePrompt:l}=jt();function u(k){const g={...k,prompt:l(k)};o("item-click",g)}function d(k){return k.gradientClass?k.gradientClass:k.className?k.className:"bg-gradient-to-br from-white to-gray-50 dark:from-gray-800 dark:to-gray-900"}function p(k){const g=k.category||"default",m={hr:"bg-blue-100 dark:bg-blue-900/30",finance:"bg-green-100 dark:bg-green-900/30",analytics:"bg-purple-100 dark:bg-purple-900/30",support:"bg-amber-100 dark:bg-amber-900/30",default:"bg-primary/10"};return m[g]||m.default}function f(k){const g=k.category||"default",m={hr:"text-blue-600 dark:text-blue-400",finance:"text-green-600 dark:text-green-400",analytics:"text-purple-600 dark:text-purple-400",support:"text-amber-600 dark:text-amber-400",default:"text-primary"};return m[g]||m.default}return(k,g)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["flex items-center justify-center p-4 h-full",a.value.root])},[e.createElementVNode("div",{class:e.normalizeClass(["w-full max-w-4xl",a.value.content])},[e.createElementVNode("div",{class:e.normalizeClass(["mb-8 text-center",a.value.header])},[e.createElementVNode("div",{class:e.normalizeClass(["mb-3 inline-flex items-center gap-2 rounded-full bg-primary/10 px-4 py-2 text-sm font-medium text-primary",a.value.badge])},[g[0]||(g[0]=e.createElementVNode("svg",{class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9.813 15.904 9 18.75l-.813-2.846a4.5 4.5 0 0 0-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 0 0 3.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 0 0 3.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 0 0-3.09 3.09Z"})],-1)),e.createElementVNode("span",null,e.toDisplayString(s("aiName")),1)],2),e.createElementVNode("h1",{class:e.normalizeClass(["mb-3 text-4xl font-bold tracking-tight text-gray-900 dark:text-white",a.value.title])},e.toDisplayString(s("title")),3),e.createElementVNode("p",{class:e.normalizeClass(["text-gray-600 dark:text-gray-400",a.value.description])},e.toDisplayString(s("description")),3)],2),e.createElementVNode("div",{class:e.normalizeClass(["mb-8 grid gap-3 sm:grid-cols-2 lg:grid-cols-3",a.value.grid])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(i),(m,E)=>(e.openBlock(),e.createElementBlock("button",{key:m.id||E,class:e.normalizeClass(["group relative overflow-hidden rounded-xl border border-gray-300 dark:border-gray-600 p-4 text-left transition-all hover:shadow-md hover:scale-[1.02]",[a.value.suggestionCard,d(m)]]),onClick:y=>u(m)},[e.createElementVNode("div",{class:e.normalizeClass(["mb-2 inline-flex h-10 w-10 items-center justify-center rounded-lg",[a.value.suggestionIconContainer,p(m)]])},[m.icon?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(m.icon),{key:0,class:e.normalizeClass(["h-5 w-5",[a.value.suggestionIcon,f(m)]])},null,8,["class"])):(e.openBlock(),e.createElementBlock("svg",{key:1,class:e.normalizeClass(["h-5 w-5",[a.value.suggestionIcon,f(m)]]),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},[...g[1]||(g[1]=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9.813 15.904 9 18.75l-.813-2.846a4.5 4.5 0 0 0-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 0 0 3.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 0 0 3.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 0 0-3.09 3.09Z"},null,-1)])],2))],2),e.createElementVNode("h3",{class:e.normalizeClass(["mb-1 text-sm font-semibold text-gray-900 dark:text-white",a.value.suggestionTitle])},e.toDisplayString(m.title),3),e.createElementVNode("p",{class:e.normalizeClass(["text-xs text-gray-600 dark:text-gray-400",a.value.suggestionDescription])},e.toDisplayString(m.description),3)],10,ia))),128))],2)],2)],2))}}),la={class:"flex items-center gap-3"},ca={key:1,class:"text-xs text-gray-400 dark:text-gray-500 font-medium"},ua={key:1,class:"flex items-center gap-2"},da={key:0,class:"flex items-center gap-3 ml-auto mr-3"},pa=["title"],fa=["title"],ma=["title"],ha={key:0,class:"w-5 h-5 text-gray-600 dark:text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},ga={key:1,class:"w-5 h-5 text-gray-600 dark:text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},ya=e.defineComponent({__name:"DrawerHeader",props:{ui:{},isSetupMode:{type:Boolean},showNewChatButton:{type:Boolean},hasHistory:{type:Boolean},showQuota:{type:Boolean},quota:{},showCloseButton:{type:Boolean},showMinimizeButton:{type:Boolean},showFullscreenToggle:{type:Boolean},isFullscreen:{type:Boolean},showMessageCount:{type:Boolean},messageCount:{},messageLimit:{},t:{type:Function}},emits:["new-chat","close","minimize","toggle-fullscreen"],setup(r){const t=r,n=e.computed(()=>{const o=t.messageCount/t.messageLimit;return o>=1?"text-red-600 dark:text-red-400 font-medium":o>=.8?"text-amber-600 dark:text-amber-400":"text-gray-500 dark:text-gray-400"});return(o,s)=>{var a,i,l,u,d,p;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["flex items-center justify-between px-4 sm:px-6 pt-4 border-b border-gray-200 dark:border-gray-700 pb-4",(a=r.ui)==null?void 0:a.header])},[e.createElementVNode("div",la,[r.isSetupMode?(e.openBlock(),e.createElementBlock("div",ua,[...s[5]||(s[5]=[e.createElementVNode("span",{class:"flex h-2 w-2 rounded-full bg-amber-500 animate-pulse"},null,-1),e.createElementVNode("span",{class:"text-sm font-medium text-gray-700 dark:text-gray-300"},"Setup Required",-1)])])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[r.showNewChatButton&&r.hasHistory?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:e.normalizeClass(["inline-flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium text-gray-700 dark:text-gray-200 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 hover:border-gray-400 transition-all duration-200 shadow-sm",(i=r.ui)==null?void 0:i.newChatButton]),onClick:s[0]||(s[0]=f=>o.$emit("new-chat"))},[s[4]||(s[4]=e.createElementVNode("svg",{class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9.813 15.904 9 18.75l-.813-2.846a4.5 4.5 0 0 0-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 0 0 3.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 0 0 3.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 0 0-3.09 3.09Z"})],-1)),e.createElementVNode("span",null,e.toDisplayString(r.t("newChat")),1)],2)):(e.openBlock(),e.createElementBlock("span",ca,e.toDisplayString(r.t("keyboardShortcutHint")),1))],64))]),r.isSetupMode?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",da,[r.showMessageCount&&r.hasHistory?(e.openBlock(),e.createElementBlock("span",{key:0,class:e.normalizeClass(["text-xs",n.value])},[e.renderSlot(o.$slots,"message-count",{},()=>[e.createTextVNode(e.toDisplayString(r.messageCount)+" / "+e.toDisplayString(r.messageLimit),1)])],2)):e.createCommentVNode("",!0),r.showQuota?e.renderSlot(o.$slots,"quota",{key:1},()=>{var f,k;return[r.quota.remaining>0?(e.openBlock(),e.createElementBlock("span",{key:0,class:e.normalizeClass(["text-xs text-green-600 dark:text-green-400",(f=r.ui)==null?void 0:f.quotaDisplay])},e.toDisplayString(r.quota.remaining)+" "+e.toDisplayString(r.t("quotaRemaining")),3)):r.quota.remaining===0?(e.openBlock(),e.createElementBlock("span",{key:1,class:e.normalizeClass(["text-xs text-red-600 dark:text-red-400",(k=r.ui)==null?void 0:k.quotaDisplay])},e.toDisplayString(r.t("noQuota")),3)):e.createCommentVNode("",!0)]}):e.createCommentVNode("",!0)])),e.createElementVNode("div",{class:e.normalizeClass(["flex items-center gap-1",(l=r.ui)==null?void 0:l.headerActions])},[r.showCloseButton?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:e.normalizeClass(["p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors",(u=r.ui)==null?void 0:u.headerActionButton]),title:r.t("close"),onClick:s[1]||(s[1]=f=>o.$emit("close"))},[...s[6]||(s[6]=[e.createElementVNode("svg",{class:"w-5 h-5 text-gray-600 dark:text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M6 18L18 6M6 6l12 12"})],-1)])],10,pa)):e.createCommentVNode("",!0),r.showMinimizeButton?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:e.normalizeClass(["p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors",(d=r.ui)==null?void 0:d.headerActionButton]),title:r.t("minimize"),onClick:s[2]||(s[2]=f=>o.$emit("minimize"))},[...s[7]||(s[7]=[e.createElementVNode("svg",{class:"w-5 h-5 text-gray-600 dark:text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M5 12h14"})],-1)])],10,fa)):e.createCommentVNode("",!0),r.showFullscreenToggle?(e.openBlock(),e.createElementBlock("button",{key:2,type:"button",class:e.normalizeClass(["p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors",(p=r.ui)==null?void 0:p.headerActionButton]),title:r.isFullscreen?r.t("exitFullscreen"):r.t("fullscreen"),onClick:s[3]||(s[3]=f=>o.$emit("toggle-fullscreen"))},[r.isFullscreen?(e.openBlock(),e.createElementBlock("svg",ga,[...s[9]||(s[9]=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9 9V4.5M9 9H4.5M9 9L3.75 3.75M9 15v4.5M9 15H4.5M9 15l-5.25 5.25M15 9h4.5M15 9V4.5M15 9l5.25-5.25M15 15h4.5M15 15v4.5m0-4.5l5.25 5.25"},null,-1)])])):(e.openBlock(),e.createElementBlock("svg",ha,[...s[8]||(s[8]=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M3.75 3.75v4.5m0-4.5h4.5m-4.5 0L9 9M3.75 20.25v-4.5m0 4.5h4.5m-4.5 0L9 15M20.25 3.75h-4.5m4.5 0v4.5m0-4.5L15 9m5.25 11.25h-4.5m4.5 0v-4.5m0 4.5L15 15"},null,-1)])]))],10,ma)):e.createCommentVNode("",!0)],2)],2)}}}),ka={class:"max-w-3xl mx-auto px-4 space-y-6"},xa={class:"flex justify-center"},wa={class:"inline-flex items-center gap-2 rounded-full bg-primary/10 px-4 py-2 text-sm font-medium text-primary"},ba={key:0,class:"flex justify-center"},Ea=["title"],Ca=e.defineComponent({__name:"DrawerMessageList",props:{messages:{},loadingMessage:{},quota:{},error:{},ui:{},t:{type:Function}},emits:["copy","contact-support","retry"],setup(r){return(t,n)=>{var o,s,a;return e.openBlock(),e.createElementBlock("div",ka,[e.createElementVNode("div",xa,[e.createElementVNode("div",wa,[n[3]||(n[3]=e.createElementVNode("svg",{class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9.813 15.904 9 18.75l-.813-2.846a4.5 4.5 0 0 0-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 0 0 3.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 0 0 3.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 0 0-3.09 3.09Z"})],-1)),e.createElementVNode("span",null,e.toDisplayString(r.t("title")||e.unref(J)("aiName")),1)])]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.messages,(i,l)=>e.renderSlot(t.$slots,"message",{key:i.id||l,message:i,isUser:i.role==="user",isLoading:i.loading,isStreaming:i.streaming},()=>[e.createVNode(Zn,{message:i,"loading-text":r.loadingMessage,onCopy:n[0]||(n[0]=u=>t.$emit("copy",u))},null,8,["message","loading-text"])])),128)),r.quota.remaining===0?(e.openBlock(),e.createElementBlock("div",ba,[e.createElementVNode("button",{type:"button",class:"inline-flex items-center gap-2 px-6 py-3 bg-primary-500 text-white rounded-lg hover:bg-primary-600 transition-all shadow-sm",onClick:n[1]||(n[1]=i=>t.$emit("contact-support"))},[n[4]||(n[4]=e.createElementVNode("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z"})],-1)),e.createElementVNode("span",null,e.toDisplayString(e.unref(J)("contactSupport")),1)])])):e.createCommentVNode("",!0),r.error.message?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["flex items-center gap-2 text-sm text-red-600 dark:text-red-400 px-2 py-1 pb-6",(o=r.ui)==null?void 0:o.errorContainer])},[e.createElementVNode("span",{class:e.normalizeClass((s=r.ui)==null?void 0:s.errorMessage)},e.toDisplayString(r.error.message),3),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["inline-flex items-center gap-1 text-red-700 dark:text-red-300 hover:text-red-800 dark:hover:text-red-200 font-medium",(a=r.ui)==null?void 0:a.retryButton]),title:r.t("retry"),onClick:n[2]||(n[2]=i=>t.$emit("retry"))},[...n[5]||(n[5]=[e.createElementVNode("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})],-1)])],10,Ea)],2)):e.createCommentVNode("",!0)])}}}),Sa={class:"w-full max-w-md"},Ta={class:"bg-gray-900 rounded-xl overflow-hidden"},Aa={class:"flex items-center justify-between px-4 py-2 bg-gray-800/50 border-b border-gray-700"},Ma=e.defineComponent({__name:"SetupGuide",props:{copied:{type:Boolean}},emits:["copy"],setup(r){return(t,n)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[n[4]||(n[4]=e.createStaticVNode('<div class="w-14 h-14 rounded-2xl bg-primary/10 flex items-center justify-center mb-5"><svg class="w-7 h-7 text-primary" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.5"><path stroke-linecap="round" stroke-linejoin="round" d="M9.813 15.904 9 18.75l-.813-2.846a4.5 4.5 0 0 0-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 0 0 3.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 0 0 3.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 0 0-3.09 3.09Z"></path></svg></div><h2 class="text-lg font-semibold text-gray-900 dark:text-white mb-1"> Almost there! </h2><p class="text-sm text-gray-500 dark:text-gray-400 mb-6 max-w-sm text-center"> Configure the plugin in your app entry file to start using AI. </p>',3)),e.createElementVNode("div",Sa,[e.createElementVNode("div",Ta,[e.createElementVNode("div",Aa,[n[1]||(n[1]=e.createElementVNode("span",{class:"text-xs text-gray-400"},"main.ts",-1)),e.createElementVNode("button",{type:"button",class:"text-xs text-gray-400 hover:text-white transition-colors",onClick:n[0]||(n[0]=o=>t.$emit("copy"))},e.toDisplayString(r.copied?"✓ Copied":"Copy"),1)]),n[2]||(n[2]=e.createStaticVNode(`<pre class="text-xs text-gray-100 p-4 overflow-x-auto leading-relaxed"><code class="language-typescript"><span class="text-purple-400">import</span> { RestifyAiPlugin } <span class="text-purple-400">from</span> <span class="text-green-400">'@doderasoftware/restify-ai'</span>
|
|
55
|
+
`}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${t}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:n,tokens:o}){const s=this.parser.parseInline(o),a=An(t);if(a===null)return s;t=a;let i='<a href="'+t+'"';return n&&(i+=' title="'+n+'"'),i+=">"+s+"</a>",i}image({href:t,title:n,text:o}){const s=An(t);if(s===null)return o;t=s;let a=`<img src="${t}" alt="${o}"`;return n&&(a+=` title="${n}"`),a+=">",a}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):t.text}}class Ft{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}}class fe{constructor(t){q(this,"options");q(this,"renderer");q(this,"textRenderer");this.options=t||_e,this.options.renderer=this.options.renderer||new pt,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Ft}static parse(t,n){return new fe(n).parse(t)}static parseInline(t,n){return new fe(n).parseInline(t)}parse(t,n=!0){let o="";for(let s=0;s<t.length;s++){const a=t[s];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[a.type]){const l=a,u=this.options.extensions.renderers[l.type].call({parser:this},l);if(u!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(l.type)){o+=u||"";continue}}const i=a;switch(i.type){case"space":{o+=this.renderer.space(i);continue}case"hr":{o+=this.renderer.hr(i);continue}case"heading":{o+=this.renderer.heading(i);continue}case"code":{o+=this.renderer.code(i);continue}case"table":{o+=this.renderer.table(i);continue}case"blockquote":{o+=this.renderer.blockquote(i);continue}case"list":{o+=this.renderer.list(i);continue}case"html":{o+=this.renderer.html(i);continue}case"paragraph":{o+=this.renderer.paragraph(i);continue}case"text":{let l=i,u=this.renderer.text(l);for(;s+1<t.length&&t[s+1].type==="text";)l=t[++s],u+=`
|
|
56
|
+
`+this.renderer.text(l);n?o+=this.renderer.paragraph({type:"paragraph",raw:u,text:u,tokens:[{type:"text",raw:u,text:u}]}):o+=u;continue}default:{const l='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return o}parseInline(t,n){n=n||this.renderer;let o="";for(let s=0;s<t.length;s++){const a=t[s];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[a.type]){const l=this.options.extensions.renderers[a.type].call({parser:this},a);if(l!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){o+=l||"";continue}}const i=a;switch(i.type){case"escape":{o+=n.text(i);break}case"html":{o+=n.html(i);break}case"link":{o+=n.link(i);break}case"image":{o+=n.image(i);break}case"strong":{o+=n.strong(i);break}case"em":{o+=n.em(i);break}case"codespan":{o+=n.codespan(i);break}case"br":{o+=n.br(i);break}case"del":{o+=n.del(i);break}case"text":{o+=n.text(i);break}default:{const l='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return o}}class Ye{constructor(t){q(this,"options");q(this,"block");this.options=t||_e}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}provideLexer(){return this.block?me.lex:me.lexInline}provideParser(){return this.block?fe.parse:fe.parseInline}}q(Ye,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));class Lo{constructor(...t){q(this,"defaults",It());q(this,"options",this.setOptions);q(this,"parse",this.parseMarkdown(!0));q(this,"parseInline",this.parseMarkdown(!1));q(this,"Parser",fe);q(this,"Renderer",pt);q(this,"TextRenderer",Ft);q(this,"Lexer",me);q(this,"Tokenizer",ut);q(this,"Hooks",Ye);this.use(...t)}walkTokens(t,n){var s,a;let o=[];for(const i of t)switch(o=o.concat(n.call(this,i)),i.type){case"table":{const l=i;for(const u of l.header)o=o.concat(this.walkTokens(u.tokens,n));for(const u of l.rows)for(const d of u)o=o.concat(this.walkTokens(d.tokens,n));break}case"list":{const l=i;o=o.concat(this.walkTokens(l.items,n));break}default:{const l=i;(a=(s=this.defaults.extensions)==null?void 0:s.childTokens)!=null&&a[l.type]?this.defaults.extensions.childTokens[l.type].forEach(u=>{const d=l[u].flat(1/0);o=o.concat(this.walkTokens(d,n))}):l.tokens&&(o=o.concat(this.walkTokens(l.tokens,n)))}}return o}use(...t){const n=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(o=>{const s={...o};if(s.async=this.defaults.async||s.async||!1,o.extensions&&(o.extensions.forEach(a=>{if(!a.name)throw new Error("extension name required");if("renderer"in a){const i=n.renderers[a.name];i?n.renderers[a.name]=function(...l){let u=a.renderer.apply(this,l);return u===!1&&(u=i.apply(this,l)),u}:n.renderers[a.name]=a.renderer}if("tokenizer"in a){if(!a.level||a.level!=="block"&&a.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const i=n[a.level];i?i.unshift(a.tokenizer):n[a.level]=[a.tokenizer],a.start&&(a.level==="block"?n.startBlock?n.startBlock.push(a.start):n.startBlock=[a.start]:a.level==="inline"&&(n.startInline?n.startInline.push(a.start):n.startInline=[a.start]))}"childTokens"in a&&a.childTokens&&(n.childTokens[a.name]=a.childTokens)}),s.extensions=n),o.renderer){const a=this.defaults.renderer||new pt(this.defaults);for(const i in o.renderer){if(!(i in a))throw new Error(`renderer '${i}' does not exist`);if(["options","parser"].includes(i))continue;const l=i,u=o.renderer[l],d=a[l];a[l]=(...m)=>{let h=u.apply(a,m);return h===!1&&(h=d.apply(a,m)),h||""}}s.renderer=a}if(o.tokenizer){const a=this.defaults.tokenizer||new ut(this.defaults);for(const i in o.tokenizer){if(!(i in a))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;const l=i,u=o.tokenizer[l],d=a[l];a[l]=(...m)=>{let h=u.apply(a,m);return h===!1&&(h=d.apply(a,m)),h}}s.tokenizer=a}if(o.hooks){const a=this.defaults.hooks||new Ye;for(const i in o.hooks){if(!(i in a))throw new Error(`hook '${i}' does not exist`);if(["options","block"].includes(i))continue;const l=i,u=o.hooks[l],d=a[l];Ye.passThroughHooks.has(i)?a[l]=m=>{if(this.defaults.async)return Promise.resolve(u.call(a,m)).then(g=>d.call(a,g));const h=u.call(a,m);return d.call(a,h)}:a[l]=(...m)=>{let h=u.apply(a,m);return h===!1&&(h=d.apply(a,m)),h}}s.hooks=a}if(o.walkTokens){const a=this.defaults.walkTokens,i=o.walkTokens;s.walkTokens=function(l){let u=[];return u.push(i.call(this,l)),a&&(u=u.concat(a.call(this,l))),u}}this.defaults={...this.defaults,...s}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,n){return me.lex(t,n??this.defaults)}parser(t,n){return fe.parse(t,n??this.defaults)}parseMarkdown(t){return(o,s)=>{const a={...s},i={...this.defaults,...a},l=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&a.async===!1)return l(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof o>"u"||o===null)return l(new Error("marked(): input parameter is undefined or null"));if(typeof o!="string")return l(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(o)+", string expected"));i.hooks&&(i.hooks.options=i,i.hooks.block=t);const u=i.hooks?i.hooks.provideLexer():t?me.lex:me.lexInline,d=i.hooks?i.hooks.provideParser():t?fe.parse:fe.parseInline;if(i.async)return Promise.resolve(i.hooks?i.hooks.preprocess(o):o).then(m=>u(m,i)).then(m=>i.hooks?i.hooks.processAllTokens(m):m).then(m=>i.walkTokens?Promise.all(this.walkTokens(m,i.walkTokens)).then(()=>m):m).then(m=>d(m,i)).then(m=>i.hooks?i.hooks.postprocess(m):m).catch(l);try{i.hooks&&(o=i.hooks.preprocess(o));let m=u(o,i);i.hooks&&(m=i.hooks.processAllTokens(m)),i.walkTokens&&this.walkTokens(m,i.walkTokens);let h=d(m,i);return i.hooks&&(h=i.hooks.postprocess(h)),h}catch(m){return l(m)}}}onError(t,n){return o=>{if(o.message+=`
|
|
57
|
+
Please report this to https://github.com/markedjs/marked.`,t){const s="<p>An error occurred:</p><pre>"+de(o.message+"",!0)+"</pre>";return n?Promise.resolve(s):s}if(n)return Promise.reject(o);throw o}}}const Le=new Lo;function F(r,t){return Le.parse(r,t)}F.options=F.setOptions=function(r){return Le.setOptions(r),F.defaults=Le.defaults,Cn(F.defaults),F},F.getDefaults=It,F.defaults=_e,F.use=function(...r){return Le.use(...r),F.defaults=Le.defaults,Cn(F.defaults),F},F.walkTokens=function(r,t){return Le.walkTokens(r,t)},F.parseInline=Le.parseInline,F.Parser=fe,F.parser=fe.parse,F.Renderer=pt,F.TextRenderer=Ft,F.Lexer=me,F.lexer=me.lex,F.Tokenizer=ut,F.Hooks=Ye,F.parse=F,F.options,F.setOptions,F.use,F.walkTokens,F.parseInline,fe.parse,me.lex;/*! @license DOMPurify 3.3.0 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.0/LICENSE */const{entries:On,setPrototypeOf:Pn,isFrozen:Io,getPrototypeOf:$o,getOwnPropertyDescriptor:Do}=Object;let{freeze:se,seal:pe,create:Ht}=Object,{apply:Ut,construct:qt}=typeof Reflect<"u"&&Reflect;se||(se=function(t){return t}),pe||(pe=function(t){return t}),Ut||(Ut=function(t,n){for(var o=arguments.length,s=new Array(o>2?o-2:0),a=2;a<o;a++)s[a-2]=arguments[a];return t.apply(n,s)}),qt||(qt=function(t){for(var n=arguments.length,o=new Array(n>1?n-1:0),s=1;s<n;s++)o[s-1]=arguments[s];return new t(...o)});const ht=ie(Array.prototype.forEach),zo=ie(Array.prototype.lastIndexOf),Vn=ie(Array.prototype.pop),Xe=ie(Array.prototype.push),Oo=ie(Array.prototype.splice),gt=ie(String.prototype.toLowerCase),jt=ie(String.prototype.toString),Wt=ie(String.prototype.match),Je=ie(String.prototype.replace),Po=ie(String.prototype.indexOf),Vo=ie(String.prototype.trim),he=ie(Object.prototype.hasOwnProperty),ae=ie(RegExp.prototype.test),ve=Fo(TypeError);function ie(r){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,o=new Array(n>1?n-1:0),s=1;s<n;s++)o[s-1]=arguments[s];return Ut(r,t,o)}}function Fo(r){return function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return qt(r,n)}}function D(r,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:gt;Pn&&Pn(r,null);let o=t.length;for(;o--;){let s=t[o];if(typeof s=="string"){const a=n(s);a!==s&&(Io(t)||(t[o]=a),s=a)}r[s]=!0}return r}function Ho(r){for(let t=0;t<r.length;t++)he(r,t)||(r[t]=null);return r}function xe(r){const t=Ht(null);for(const[n,o]of On(r))he(r,n)&&(Array.isArray(o)?t[n]=Ho(o):o&&typeof o=="object"&&o.constructor===Object?t[n]=xe(o):t[n]=o);return t}function et(r,t){for(;r!==null;){const o=Do(r,t);if(o){if(o.get)return ie(o.get);if(typeof o.value=="function")return ie(o.value)}r=$o(r)}function n(){return null}return n}const Fn=se(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Kt=se(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Gt=se(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Uo=se(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Qt=se(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),qo=se(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Hn=se(["#text"]),Un=se(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),Zt=se(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),qn=se(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),yt=se(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),jo=pe(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Wo=pe(/<%[\w\W]*|[\w\W]*%>/gm),Ko=pe(/\$\{[\w\W]*/gm),Go=pe(/^data-[\-\w.\u00B7-\uFFFF]+$/),Qo=pe(/^aria-[\-\w]+$/),jn=pe(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Zo=pe(/^(?:\w+script|data):/i),Yo=pe(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Wn=pe(/^html$/i),Xo=pe(/^[a-z][.\w]*(-[.\w]+)+$/i);var Kn=Object.freeze({__proto__:null,ARIA_ATTR:Qo,ATTR_WHITESPACE:Yo,CUSTOM_ELEMENT:Xo,DATA_ATTR:Go,DOCTYPE_NAME:Wn,ERB_EXPR:Wo,IS_ALLOWED_URI:jn,IS_SCRIPT_OR_DATA:Zo,MUSTACHE_EXPR:jo,TMPLIT_EXPR:Ko});const tt={element:1,text:3,progressingInstruction:7,comment:8,document:9},Jo=function(){return typeof window>"u"?null:window},vo=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let o=null;const s="data-tt-policy-suffix";n&&n.hasAttribute(s)&&(o=n.getAttribute(s));const a="dompurify"+(o?"#"+o:"");try{return t.createPolicy(a,{createHTML(i){return i},createScriptURL(i){return i}})}catch{return console.warn("TrustedTypes policy "+a+" could not be created."),null}},Gn=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Qn(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Jo();const t=T=>Qn(T);if(t.version="3.3.0",t.removed=[],!r||!r.document||r.document.nodeType!==tt.document||!r.Element)return t.isSupported=!1,t;let{document:n}=r;const o=n,s=o.currentScript,{DocumentFragment:a,HTMLTemplateElement:i,Node:l,Element:u,NodeFilter:d,NamedNodeMap:m=r.NamedNodeMap||r.MozNamedAttrMap,HTMLFormElement:h,DOMParser:g,trustedTypes:y}=r,f=u.prototype,S=et(f,"cloneNode"),p=et(f,"remove"),w=et(f,"nextSibling"),M=et(f,"childNodes"),x=et(f,"parentNode");if(typeof i=="function"){const T=n.createElement("template");T.content&&T.content.ownerDocument&&(n=T.content.ownerDocument)}let C,I="";const{implementation:b,createNodeIterator:N,createDocumentFragment:L,getElementsByTagName:A}=n,{importNode:B}=o;let V=Gn();t.isSupported=typeof On=="function"&&typeof x=="function"&&b&&b.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:G,ERB_EXPR:_,TMPLIT_EXPR:O,DATA_ATTR:z,ARIA_ATTR:ne,IS_SCRIPT_OR_DATA:be,ATTR_WHITESPACE:U,CUSTOM_ELEMENT:nt}=Kn;let{IS_ALLOWED_URI:Ie}=Kn,Q=null;const xt=D({},[...Fn,...Kt,...Gt,...Qt,...Hn]);let Y=null;const bt=D({},[...Un,...Zt,...qn,...yt]);let j=Object.seal(Ht(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Me=null,rt=null;const Be=Object.seal(Ht(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let wt=!0,Oe=!0,ot=!1,Ct=!0,we=!1,$=!0,P=!1,X=!1,le=!1,J=!1,v=!1,ce=!1,Et=!0,ur=!1;const Ni="user-content-";let en=!0,st=!1,Pe={},Ve=null;const dr=D({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let mr=null;const fr=D({},["audio","video","img","source","image","track"]);let tn=null;const pr=D({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),St="http://www.w3.org/1998/Math/MathML",Tt="http://www.w3.org/2000/svg",Ce="http://www.w3.org/1999/xhtml";let Fe=Ce,nn=!1,rn=null;const Ri=D({},[St,Tt,Ce],jt);let At=D({},["mi","mo","mn","ms","mtext"]),Mt=D({},["annotation-xml"]);const _i=D({},["title","style","font","a","script"]);let at=null;const Li=["application/xhtml+xml","text/html"],Ii="text/html";let ee=null,He=null;const $i=n.createElement("form"),hr=function(c){return c instanceof RegExp||c instanceof Function},on=function(){let c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(He&&He===c)){if((!c||typeof c!="object")&&(c={}),c=xe(c),at=Li.indexOf(c.PARSER_MEDIA_TYPE)===-1?Ii:c.PARSER_MEDIA_TYPE,ee=at==="application/xhtml+xml"?jt:gt,Q=he(c,"ALLOWED_TAGS")?D({},c.ALLOWED_TAGS,ee):xt,Y=he(c,"ALLOWED_ATTR")?D({},c.ALLOWED_ATTR,ee):bt,rn=he(c,"ALLOWED_NAMESPACES")?D({},c.ALLOWED_NAMESPACES,jt):Ri,tn=he(c,"ADD_URI_SAFE_ATTR")?D(xe(pr),c.ADD_URI_SAFE_ATTR,ee):pr,mr=he(c,"ADD_DATA_URI_TAGS")?D(xe(fr),c.ADD_DATA_URI_TAGS,ee):fr,Ve=he(c,"FORBID_CONTENTS")?D({},c.FORBID_CONTENTS,ee):dr,Me=he(c,"FORBID_TAGS")?D({},c.FORBID_TAGS,ee):xe({}),rt=he(c,"FORBID_ATTR")?D({},c.FORBID_ATTR,ee):xe({}),Pe=he(c,"USE_PROFILES")?c.USE_PROFILES:!1,wt=c.ALLOW_ARIA_ATTR!==!1,Oe=c.ALLOW_DATA_ATTR!==!1,ot=c.ALLOW_UNKNOWN_PROTOCOLS||!1,Ct=c.ALLOW_SELF_CLOSE_IN_ATTR!==!1,we=c.SAFE_FOR_TEMPLATES||!1,$=c.SAFE_FOR_XML!==!1,P=c.WHOLE_DOCUMENT||!1,J=c.RETURN_DOM||!1,v=c.RETURN_DOM_FRAGMENT||!1,ce=c.RETURN_TRUSTED_TYPE||!1,le=c.FORCE_BODY||!1,Et=c.SANITIZE_DOM!==!1,ur=c.SANITIZE_NAMED_PROPS||!1,en=c.KEEP_CONTENT!==!1,st=c.IN_PLACE||!1,Ie=c.ALLOWED_URI_REGEXP||jn,Fe=c.NAMESPACE||Ce,At=c.MATHML_TEXT_INTEGRATION_POINTS||At,Mt=c.HTML_INTEGRATION_POINTS||Mt,j=c.CUSTOM_ELEMENT_HANDLING||{},c.CUSTOM_ELEMENT_HANDLING&&hr(c.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(j.tagNameCheck=c.CUSTOM_ELEMENT_HANDLING.tagNameCheck),c.CUSTOM_ELEMENT_HANDLING&&hr(c.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(j.attributeNameCheck=c.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),c.CUSTOM_ELEMENT_HANDLING&&typeof c.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(j.allowCustomizedBuiltInElements=c.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),we&&(Oe=!1),v&&(J=!0),Pe&&(Q=D({},Hn),Y=[],Pe.html===!0&&(D(Q,Fn),D(Y,Un)),Pe.svg===!0&&(D(Q,Kt),D(Y,Zt),D(Y,yt)),Pe.svgFilters===!0&&(D(Q,Gt),D(Y,Zt),D(Y,yt)),Pe.mathMl===!0&&(D(Q,Qt),D(Y,qn),D(Y,yt))),c.ADD_TAGS&&(typeof c.ADD_TAGS=="function"?Be.tagCheck=c.ADD_TAGS:(Q===xt&&(Q=xe(Q)),D(Q,c.ADD_TAGS,ee))),c.ADD_ATTR&&(typeof c.ADD_ATTR=="function"?Be.attributeCheck=c.ADD_ATTR:(Y===bt&&(Y=xe(Y)),D(Y,c.ADD_ATTR,ee))),c.ADD_URI_SAFE_ATTR&&D(tn,c.ADD_URI_SAFE_ATTR,ee),c.FORBID_CONTENTS&&(Ve===dr&&(Ve=xe(Ve)),D(Ve,c.FORBID_CONTENTS,ee)),en&&(Q["#text"]=!0),P&&D(Q,["html","head","body"]),Q.table&&(D(Q,["tbody"]),delete Me.tbody),c.TRUSTED_TYPES_POLICY){if(typeof c.TRUSTED_TYPES_POLICY.createHTML!="function")throw ve('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof c.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw ve('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');C=c.TRUSTED_TYPES_POLICY,I=C.createHTML("")}else C===void 0&&(C=vo(y,s)),C!==null&&typeof I=="string"&&(I=C.createHTML(""));se&&se(c),He=c}},gr=D({},[...Kt,...Gt,...Uo]),yr=D({},[...Qt,...qo]),Di=function(c){let k=x(c);(!k||!k.tagName)&&(k={namespaceURI:Fe,tagName:"template"});const E=gt(c.tagName),W=gt(k.tagName);return rn[c.namespaceURI]?c.namespaceURI===Tt?k.namespaceURI===Ce?E==="svg":k.namespaceURI===St?E==="svg"&&(W==="annotation-xml"||At[W]):!!gr[E]:c.namespaceURI===St?k.namespaceURI===Ce?E==="math":k.namespaceURI===Tt?E==="math"&&Mt[W]:!!yr[E]:c.namespaceURI===Ce?k.namespaceURI===Tt&&!Mt[W]||k.namespaceURI===St&&!At[W]?!1:!yr[E]&&(_i[E]||!gr[E]):!!(at==="application/xhtml+xml"&&rn[c.namespaceURI]):!1},ye=function(c){Xe(t.removed,{element:c});try{x(c).removeChild(c)}catch{p(c)}},$e=function(c,k){try{Xe(t.removed,{attribute:k.getAttributeNode(c),from:k})}catch{Xe(t.removed,{attribute:null,from:k})}if(k.removeAttribute(c),c==="is")if(J||v)try{ye(k)}catch{}else try{k.setAttribute(c,"")}catch{}},kr=function(c){let k=null,E=null;if(le)c="<remove></remove>"+c;else{const Z=Wt(c,/^[\r\n\t ]+/);E=Z&&Z[0]}at==="application/xhtml+xml"&&Fe===Ce&&(c='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+c+"</body></html>");const W=C?C.createHTML(c):c;if(Fe===Ce)try{k=new g().parseFromString(W,at)}catch{}if(!k||!k.documentElement){k=b.createDocument(Fe,"template",null);try{k.documentElement.innerHTML=nn?I:W}catch{}}const oe=k.body||k.documentElement;return c&&E&&oe.insertBefore(n.createTextNode(E),oe.childNodes[0]||null),Fe===Ce?A.call(k,P?"html":"body")[0]:P?k.documentElement:oe},xr=function(c){return N.call(c.ownerDocument||c,c,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT|d.SHOW_PROCESSING_INSTRUCTION|d.SHOW_CDATA_SECTION,null)},sn=function(c){return c instanceof h&&(typeof c.nodeName!="string"||typeof c.textContent!="string"||typeof c.removeChild!="function"||!(c.attributes instanceof m)||typeof c.removeAttribute!="function"||typeof c.setAttribute!="function"||typeof c.namespaceURI!="string"||typeof c.insertBefore!="function"||typeof c.hasChildNodes!="function")},br=function(c){return typeof l=="function"&&c instanceof l};function Ee(T,c,k){ht(T,E=>{E.call(t,c,k,He)})}const wr=function(c){let k=null;if(Ee(V.beforeSanitizeElements,c,null),sn(c))return ye(c),!0;const E=ee(c.nodeName);if(Ee(V.uponSanitizeElement,c,{tagName:E,allowedTags:Q}),$&&c.hasChildNodes()&&!br(c.firstElementChild)&&ae(/<[/\w!]/g,c.innerHTML)&&ae(/<[/\w!]/g,c.textContent)||c.nodeType===tt.progressingInstruction||$&&c.nodeType===tt.comment&&ae(/<[/\w]/g,c.data))return ye(c),!0;if(!(Be.tagCheck instanceof Function&&Be.tagCheck(E))&&(!Q[E]||Me[E])){if(!Me[E]&&Er(E)&&(j.tagNameCheck instanceof RegExp&&ae(j.tagNameCheck,E)||j.tagNameCheck instanceof Function&&j.tagNameCheck(E)))return!1;if(en&&!Ve[E]){const W=x(c)||c.parentNode,oe=M(c)||c.childNodes;if(oe&&W){const Z=oe.length;for(let ue=Z-1;ue>=0;--ue){const Se=S(oe[ue],!0);Se.__removalCount=(c.__removalCount||0)+1,W.insertBefore(Se,w(c))}}}return ye(c),!0}return c instanceof u&&!Di(c)||(E==="noscript"||E==="noembed"||E==="noframes")&&ae(/<\/no(script|embed|frames)/i,c.innerHTML)?(ye(c),!0):(we&&c.nodeType===tt.text&&(k=c.textContent,ht([G,_,O],W=>{k=Je(k,W," ")}),c.textContent!==k&&(Xe(t.removed,{element:c.cloneNode()}),c.textContent=k)),Ee(V.afterSanitizeElements,c,null),!1)},Cr=function(c,k,E){if(Et&&(k==="id"||k==="name")&&(E in n||E in $i))return!1;if(!(Oe&&!rt[k]&&ae(z,k))){if(!(wt&&ae(ne,k))){if(!(Be.attributeCheck instanceof Function&&Be.attributeCheck(k,c))){if(!Y[k]||rt[k]){if(!(Er(c)&&(j.tagNameCheck instanceof RegExp&&ae(j.tagNameCheck,c)||j.tagNameCheck instanceof Function&&j.tagNameCheck(c))&&(j.attributeNameCheck instanceof RegExp&&ae(j.attributeNameCheck,k)||j.attributeNameCheck instanceof Function&&j.attributeNameCheck(k,c))||k==="is"&&j.allowCustomizedBuiltInElements&&(j.tagNameCheck instanceof RegExp&&ae(j.tagNameCheck,E)||j.tagNameCheck instanceof Function&&j.tagNameCheck(E))))return!1}else if(!tn[k]){if(!ae(Ie,Je(E,U,""))){if(!((k==="src"||k==="xlink:href"||k==="href")&&c!=="script"&&Po(E,"data:")===0&&mr[c])){if(!(ot&&!ae(be,Je(E,U,"")))){if(E)return!1}}}}}}}return!0},Er=function(c){return c!=="annotation-xml"&&Wt(c,nt)},Sr=function(c){Ee(V.beforeSanitizeAttributes,c,null);const{attributes:k}=c;if(!k||sn(c))return;const E={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Y,forceKeepAttr:void 0};let W=k.length;for(;W--;){const oe=k[W],{name:Z,namespaceURI:ue,value:Se}=oe,Ue=ee(Z),an=Se;let re=Z==="value"?an:Vo(an);if(E.attrName=Ue,E.attrValue=re,E.keepAttr=!0,E.forceKeepAttr=void 0,Ee(V.uponSanitizeAttribute,c,E),re=E.attrValue,ur&&(Ue==="id"||Ue==="name")&&($e(Z,c),re=Ni+re),$&&ae(/((--!?|])>)|<\/(style|title|textarea)/i,re)){$e(Z,c);continue}if(Ue==="attributename"&&Wt(re,"href")){$e(Z,c);continue}if(E.forceKeepAttr)continue;if(!E.keepAttr){$e(Z,c);continue}if(!Ct&&ae(/\/>/i,re)){$e(Z,c);continue}we&&ht([G,_,O],Ar=>{re=Je(re,Ar," ")});const Tr=ee(c.nodeName);if(!Cr(Tr,Ue,re)){$e(Z,c);continue}if(C&&typeof y=="object"&&typeof y.getAttributeType=="function"&&!ue)switch(y.getAttributeType(Tr,Ue)){case"TrustedHTML":{re=C.createHTML(re);break}case"TrustedScriptURL":{re=C.createScriptURL(re);break}}if(re!==an)try{ue?c.setAttributeNS(ue,Z,re):c.setAttribute(Z,re),sn(c)?ye(c):Vn(t.removed)}catch{$e(Z,c)}}Ee(V.afterSanitizeAttributes,c,null)},zi=function T(c){let k=null;const E=xr(c);for(Ee(V.beforeSanitizeShadowDOM,c,null);k=E.nextNode();)Ee(V.uponSanitizeShadowNode,k,null),wr(k),Sr(k),k.content instanceof a&&T(k.content);Ee(V.afterSanitizeShadowDOM,c,null)};return t.sanitize=function(T){let c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},k=null,E=null,W=null,oe=null;if(nn=!T,nn&&(T="<!-->"),typeof T!="string"&&!br(T))if(typeof T.toString=="function"){if(T=T.toString(),typeof T!="string")throw ve("dirty is not a string, aborting")}else throw ve("toString is not a function");if(!t.isSupported)return T;if(X||on(c),t.removed=[],typeof T=="string"&&(st=!1),st){if(T.nodeName){const Se=ee(T.nodeName);if(!Q[Se]||Me[Se])throw ve("root node is forbidden and cannot be sanitized in-place")}}else if(T instanceof l)k=kr("<!---->"),E=k.ownerDocument.importNode(T,!0),E.nodeType===tt.element&&E.nodeName==="BODY"||E.nodeName==="HTML"?k=E:k.appendChild(E);else{if(!J&&!we&&!P&&T.indexOf("<")===-1)return C&&ce?C.createHTML(T):T;if(k=kr(T),!k)return J?null:ce?I:""}k&&le&&ye(k.firstChild);const Z=xr(st?T:k);for(;W=Z.nextNode();)wr(W),Sr(W),W.content instanceof a&&zi(W.content);if(st)return T;if(J){if(v)for(oe=L.call(k.ownerDocument);k.firstChild;)oe.appendChild(k.firstChild);else oe=k;return(Y.shadowroot||Y.shadowrootmode)&&(oe=B.call(o,oe,!0)),oe}let ue=P?k.outerHTML:k.innerHTML;return P&&Q["!doctype"]&&k.ownerDocument&&k.ownerDocument.doctype&&k.ownerDocument.doctype.name&&ae(Wn,k.ownerDocument.doctype.name)&&(ue="<!DOCTYPE "+k.ownerDocument.doctype.name+`>
|
|
58
|
+
`+ue),we&&ht([G,_,O],Se=>{ue=Je(ue,Se," ")}),C&&ce?C.createHTML(ue):ue},t.setConfig=function(){let T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};on(T),X=!0},t.clearConfig=function(){He=null,X=!1},t.isValidAttribute=function(T,c,k){He||on({});const E=ee(T),W=ee(c);return Cr(E,W,k)},t.addHook=function(T,c){typeof c=="function"&&Xe(V[T],c)},t.removeHook=function(T,c){if(c!==void 0){const k=zo(V[T],c);return k===-1?void 0:Oo(V[T],k,1)[0]}return Vn(V[T])},t.removeHooks=function(T){V[T]=[]},t.removeAllHooks=function(){V=Gn()},t}var es=Qn();function Zn(){return{parseMarkdown:t=>{if(!t||typeof t!="string")return"";const n=hn(t),o=F.parse(n,{async:!1,breaks:!0,gfm:!0});return es.sanitize(o,{ALLOWED_TAGS:["p","br","strong","em","b","i","code","pre","ul","ol","li","h1","h2","h3","h4","h5","h6","a","blockquote","span","div","table","thead","tbody","tr","th","td"],ALLOWED_ATTR:["href","class","target","rel","data-mention-id","data-mention-type"],ALLOW_UNKNOWN_PROTOCOLS:!1,FORBID_ATTR:["onerror","onload","onclick","onmouseover"],KEEP_CONTENT:!0})}}}function ts(){let r=null;function t(a){const i=a||document.querySelector("[data-rai-chat-container]");i&&requestAnimationFrame(()=>{i.scrollTo({top:i.scrollHeight,behavior:"smooth"})})}function n(a,i=100){const{scrollTop:l,scrollHeight:u,clientHeight:d}=a;return u-l-d<i}function o(a){a&&(s(),r=new MutationObserver(()=>{(a.scrollTop===0||n(a))&&requestAnimationFrame(()=>{a.scrollTo({top:a.scrollHeight,behavior:"smooth"})})}),r.observe(a,{childList:!0,subtree:!0}))}function s(){r&&(r.disconnect(),r=null)}return e.onUnmounted(()=>{s()}),{scrollToBottom:t,setupAutoScroll:o,cleanupAutoScroll:s}}function ns(){const r=Ae(),t=e.computed(()=>r.error),n=e.computed(()=>{var a,i;return((a=t.value)==null?void 0:a.message)!==null&&((i=t.value)==null?void 0:i.message)!==void 0});return{errorState:t,hasError:n,retry:async()=>await r.retry(),clearError:()=>{r.clearError()}}}function Yt(){const r=Ae(),t=e.computed(()=>r.pageContext);function n(a){r.setPageContext(a)}function o(){r.setPageContext(null)}function s(a){const i=r.pageContext;i&&r.setPageContext({...i,...a,metadata:{...i.metadata,...a.metadata}})}return{context:t,setContext:n,clearContext:o,updateContext:s}}const ge=[],Yn={id:"default",matcher:()=>!0,priority:0,getSuggestions:()=>{const r=K();return(r==null?void 0:r.defaultSuggestions)||[]}};function rs(){ge.length=0;const r=K();r!=null&&r.suggestionProviders&&ge.push(...r.suggestionProviders),ge.push(Yn)}function os(r,t){const n=[...ge].sort((o,s)=>(s.priority||0)-(o.priority||0));for(const o of n)if(o.matcher&&o.matcher(r,t)||o.routes&&o.routes.some(a=>a.endsWith("*")?r.startsWith(a.slice(0,-1)):r===a||r.startsWith(a+"/")))return o;return Yn}function Xn(r,t){ge.length===0&&rs();const n=os(r,t),o=t||{pageType:"default",routePath:r};return n.extractContext&&(o.metadata={...o.metadata,...n.extractContext(r)}),n.getSuggestions(o)||[]}function ss(r){const t=ge.findIndex(n=>n.id===r.id);if(t>=0)ge[t]=r;else{const n=ge.findIndex(o=>o.id==="default");n>=0?ge.splice(n,0,r):ge.push(r)}}const as=ss;function Xt(){const{context:r}=Yt(),t=Ae(),n=K();function o(){var u;return(u=r.value)!=null&&u.routePath?r.value.routePath:typeof window<"u"?window.location.pathname:"/"}function s(u){return n!=null&&n.can?u.filter(d=>d.permission?n.can(d.permission):!0):u}const a=e.computed(()=>{if(t.quota.remaining===0)return(n==null?void 0:n.enableSupportMode)!==!1?[{id:"contact-support-quota",title:te("contactSupport"),description:te("noQuota"),prompt:"I need help with my account",className:"rai-suggestion--warning",isSupportRequest:!0}]:[];const u=o(),d=Xn(u,r.value)||[];return s(d)}),i=e.computed(()=>r.value!==null&&r.value.pageType!=="default");function l(u){return typeof u.prompt=="function"?u.prompt(r.value||{pageType:"default"}):u.prompt}return{suggestions:a,hasContextualSuggestions:i,resolvePrompt:l}}function is(r,t){const{setContext:n,clearContext:o,updateContext:s}=Yt();function a(){if(!t)return{};const l={};for(const[u,d]of Object.entries(t))l[u]=e.isRef(d)?d.value:d;return l}function i(){const l={pageType:r,routePath:typeof window<"u"?window.location.pathname:void 0,metadata:a()};n(l)}return e.onMounted(()=>{i()}),e.onUnmounted(()=>{o()}),t&&e.watch(()=>a(),l=>{s({metadata:l})},{deep:!0}),{setupContext:i}}function ls(r){const t=r.toLowerCase().split("+");return{key:t.pop()||"",meta:t.includes("cmd")||t.includes("meta")||t.includes("command"),ctrl:t.includes("ctrl")||t.includes("control"),shift:t.includes("shift"),alt:t.includes("alt")||t.includes("option"),mod:t.includes("mod")}}function cs(r,t){const n=r.key.toLowerCase();if(t.mod){const d=navigator.platform.toUpperCase().indexOf("MAC")>=0||navigator.userAgent.toUpperCase().indexOf("MAC")>=0?r.metaKey:r.ctrlKey,m=t.shift?r.shiftKey:!r.shiftKey,h=t.alt?r.altKey:!r.altKey;return n===t.key&&d&&m&&h}const o=t.meta?r.metaKey:!r.metaKey,s=t.ctrl?r.ctrlKey:!r.ctrlKey,a=t.shift?r.shiftKey:!r.shiftKey,i=t.alt?r.altKey:!r.altKey;let l=o&&s&&a&&i;return(t.meta&&!t.ctrl||!t.meta&&t.ctrl)&&(l=(r.metaKey||r.ctrlKey)&&a&&i),n===t.key&&l}function Jn(r){const{onToggle:t,enabled:n=!0}=r,o=e.ref(!1),s=r.shortcut!==void 0?r.shortcut:ke("keyboardShortcut")??"mod+g";if(s===null)return{isActive:o};const a=ls(s);function i(l){if(!n)return;const u=l.target,d=u.tagName==="INPUT"||u.tagName==="TEXTAREA",m=u.isContentEditable,h=u.closest("[data-ai-input]");if(!((d||m)&&!h)&&cs(l,a)){l.preventDefault(),l.stopPropagation();const g=K();if(g!=null&&g.canToggle&&!g.canToggle())return;o.value=!o.value,t()}}return e.onMounted(()=>{window.addEventListener("keydown",i,!0)}),e.onUnmounted(()=>{window.removeEventListener("keydown",i,!0)}),{isActive:o}}function us(r){const t=Ae();return Jn({onToggle:()=>{r?r.value=!r.value:t.showChat=!t.showChat}})}function ds(r,t){const n=e.ref(te("loadingText"));let o=[];function s(){return[te("loadingText"),te("analyzingText"),te("craftingText")]}function a(){return[0,2e3,5e3]}function i(){o.forEach(d=>clearTimeout(d)),o=[]}function l(){i();const d=t==null?void 0:t(),m=(d==null?void 0:d.messages)??s();n.value=m[0]||te("loadingText")}function u(){i();const d=t==null?void 0:t(),m=(d==null?void 0:d.messages)??s(),h=(d==null?void 0:d.intervals)??a();n.value=m[0]||te("loadingText");let g=0;for(let y=1;y<m.length;y++){g+=h[y]||2e3;const f=y,S=window.setTimeout(()=>{r()&&(n.value=m[f])},g);o.push(S)}}return e.onUnmounted(()=>{i()}),{loadingMessage:n,startLoadingText:u,resetLoadingText:l,clearLoadingTextTimers:i}}function ms(r){const{getHistoryLength:t,getStoreLimit:n,getConfig:o,getTexts:s,onStartNewChat:a,onNewChatEmit:i}=r,l=e.ref({showWarning:!1,isReached:!1,pendingMessage:null}),u=e.computed(()=>{var x;return((x=o())==null?void 0:x.limit)??n()}),d=e.computed(()=>{var x;return((x=o())==null?void 0:x.showWarningAt)??u.value-2}),m=e.computed(()=>Math.max(0,u.value-t())),h=e.computed(()=>m.value<=u.value-d.value&&m.value>0),g=e.computed(()=>m.value===0),y=e.computed(()=>{var x,C;return l.value.isReached||g.value?((x=s())==null?void 0:x.historyLimitReachedTitle)??"Chat Limit Reached":((C=s())==null?void 0:C.historyLimitWarningTitle)??"Approaching Chat Limit"}),f=e.computed(()=>{var x,C,I,b;return l.value.isReached||g.value?((x=o())==null?void 0:x.limitMessage)??((C=s())==null?void 0:C.historyLimitReachedMessage)??"You have reached the maximum number of messages in this conversation. Start a new chat to continue.":((I=o())==null?void 0:I.warningMessage)??((b=s())==null?void 0:b.historyLimitWarningMessage)??`You have ${m.value} message${m.value===1?"":"s"} remaining in this conversation.`});function S(){l.value.showWarning=!1,l.value.isReached=!1,l.value.pendingMessage=null}async function p(){l.value.showWarning=!1;const x=o();if(x!=null&&x.onLimitReached&&!await x.onLimitReached())return l.value.isReached=!1,null;if(a(),i(),l.value.isReached=!1,l.value.pendingMessage){const C=l.value.pendingMessage;return l.value.pendingMessage=null,C}return null}function w(){return g.value?(l.value.isReached=!0,l.value.showWarning=!0,!1):(h.value&&!l.value.showWarning&&(l.value.showWarning=!0),!0)}function M(x){l.value.pendingMessage=x}return{showHistoryLimitWarning:e.computed(()=>l.value.showWarning),historyLimitReached:e.computed(()=>l.value.isReached),historyLimit:u,remainingMessages:m,historyLimitDialogTitle:y,historyLimitDialogMessage:f,dismissHistoryLimitWarning:S,handleHistoryLimitAction:p,checkHistoryLimit:w,setPendingMessage:M}}function fs(){const r=Ae(),t=e.ref([]),n=e.ref(!1),o=e.ref(0),s=ke("maxAttachments")||5,a=ke("maxFileSize")||10*1024*1024,i=ke("acceptedFileTypes")||"image/*,.pdf,.txt,.doc,.docx,.xls,.xlsx,.csv",l=e.computed(()=>t.value.length>0),u=e.computed(()=>t.value.some(b=>b.uploading)),d=e.computed(()=>t.value.length<s);function m(b){var G;const N=crypto.randomUUID(),L=b.type.startsWith("image/")?URL.createObjectURL(b):void 0,A=K(),B=!!((G=A==null?void 0:A.endpoints)!=null&&G.uploadFile),V={id:N,name:b.name,type:b.type,size:b.size,uploading:B,progress:B?0:100,previewUrl:L};t.value.push(V),B&&h(b,N)}async function h(b,N){try{const L=await r.uploadFile(b),A=t.value.findIndex(B=>B.id===N);if(A===-1)return;if(L){const B=t.value[A].previewUrl;t.value[A]={...t.value[A],id:L.id||N,url:L.url,extractedText:L.extractedText,uploading:!1,progress:100,previewUrl:B||L.previewUrl}}else g(N)}catch{g(N)}}function g(b){const N=t.value.findIndex(A=>A.id===b);if(N===-1)return;const[L]=t.value.splice(N,1);L!=null&&L.previewUrl&&URL.revokeObjectURL(L.previewUrl)}function y(){t.value.forEach(b=>{b.previewUrl&&URL.revokeObjectURL(b.previewUrl)}),t.value=[]}function f(){return t.value.filter(b=>!b.uploading).map(b=>({id:b.id,name:b.name,url:b.url,type:b.type,size:b.size}))}function S(b){if(!b)return;const N=Array.from(b);for(const L of N){if(t.value.length>=s)break;L.size>a||m(L)}}function p(b){var N;return Array.from(((N=b.dataTransfer)==null?void 0:N.types)||[]).includes("Files")}function w(b){p(b)&&(o.value+=1,n.value=!0)}function M(b){p(b)||b.preventDefault()}function x(b){p(b)&&(o.value=Math.max(0,o.value-1),o.value===0&&(n.value=!1))}function C(b){var N;p(b)&&(o.value=0,n.value=!1,S(((N=b.dataTransfer)==null?void 0:N.files)||null))}function I(b){const N=b.target,L=N.files;L&&L.length&&S(L),N.value=""}return e.onBeforeUnmount(()=>{y()}),{attachments:t,isDraggingFiles:n,hasAttachments:l,isUploading:u,canAddMore:d,acceptedFileTypes:i,isImage:it,formatFileSize:lt,removeAttachment:g,clearAttachments:y,buildPayload:f,processFiles:S,handleFileSelect:I,handleDragEnter:w,handleDragOver:M,handleDragLeave:x,handleDrop:C}}function ps(r,t,n){const o=e.ref(!1),s=e.ref([]),a=e.ref(0),i=e.ref({inMention:!1,query:"",startPos:0}),l=e.ref(!1),u=e.ref([]),d=e.computed(()=>{const p=K();return(p==null?void 0:p.mentionProviders)||[]});function m(p){if(l.value){l.value=!1;return}const w=n();if(!w)return;const M=w.selectionStart,x=gn(p,M);i.value=x,x.inMention&&x.query.length>=0?h(x.query):(o.value=!1,s.value=[])}async function h(p){const w=xn();if(w.length===0){o.value=!1;return}const M=[];for(const x of w)try{const C=await x.search(p);M.push(...C.map(I=>({...I,type:x.type})))}catch(C){console.warn(`Mention provider ${x.type} failed:`,C)}s.value=M.slice(0,10),o.value=M.length>0,a.value=0}function g(p){const{startPos:w}=i.value,M=r(),x=n(),C=M.slice(0,w),I=M.slice((x==null?void 0:x.selectionStart)||w),b=p.name||p.label||p.title||p.id;l.value=!0,t(`${C}@${b} ${I}`),u.value.push({id:p.id,name:b,type:p.type,metadata:p.attributes}),o.value=!1,s.value=[],setTimeout(()=>{const N=n();N==null||N.focus();const L=C.length+b.length+2;N==null||N.setSelectionRange(L,L)},0)}function y(p){if(!o.value||s.value.length===0)return!1;if(p.key==="ArrowDown")return p.preventDefault(),a.value=Math.min(a.value+1,s.value.length-1),!0;if(p.key==="ArrowUp")return p.preventDefault(),a.value=Math.max(a.value-1,0),!0;if(p.key==="Enter"||p.key==="Tab"){p.preventDefault();const w=s.value[a.value];return w&&g(w),!0}return p.key==="Escape"?(p.preventDefault(),o.value=!1,!0):!1}function f(){u.value=[]}function S(){return[...u.value]}return{showMentions:o,mentionItems:s,selectedMentionIndex:a,mentionProviders:d,checkForMentions:m,handleMentionSelect:g,handleMentionKeyDown:y,clearMentions:f,getMentions:S}}function hs(r,t,n,o,s){const a=e.ref(!1),i=e.ref(-1),l=e.ref(null);function u(){setTimeout(()=>{const y=l.value;if(!y)return;const f=y.querySelector(`li:nth-child(${i.value+1})`);f&&f.scrollIntoView({block:"nearest",behavior:"smooth"})},0)}function d(y){const f=r();if(!a.value||f.length===0)return!1;if(y.key==="ArrowDown")return y.preventDefault(),i.value=Math.min(i.value+1,f.length-1),u(),!0;if(y.key==="ArrowUp")return y.preventDefault(),i.value=Math.max(i.value-1,0),u(),!0;if(y.key==="Enter"&&i.value>=0){y.preventDefault();const S=f[i.value];return S&&m(S),!0}return y.key==="Escape"?(y.preventDefault(),a.value=!1,i.value=-1,!0):!1}function m(y){s(y),a.value=!1,i.value=-1}function h(){const y=o(),f=t(),S=n(),p=r();y&&!f&&S&&p.length>0?a.value=!0:a.value=!1}function g(){a.value=!1,i.value=-1}return{showSuggestions:a,selectedSuggestionIndex:i,dropdownRef:l,handleSuggestionKeyDown:d,handleSuggestionClick:m,updateSuggestionsVisibility:h,hideSuggestions:g}}function gs(r,t=300){function n(){const o=r();if(!o)return;o.style.height="auto";const s=Math.min(o.scrollHeight,t);o.style.height=`${s}px`,o.style.overflowY=o.scrollHeight>t?"auto":"hidden"}return e.onMounted(()=>{setTimeout(n,0)}),{adjustTextareaHeight:n}}const ys=new Set(["a","an","the","and","or","but","in","on","at","to","for","of","with","by"]);function ks(r,t,n=5){function o(a,i){if(!a)return i;const l=a.toLowerCase().trim().split(/\s+/).filter(u=>!ys.has(u));return l.length===0?i:i.filter(u=>{const d=`${u.title} ${u.description||""}`.toLowerCase();return l.every(m=>d.includes(m))})}return{filteredSuggestions:e.computed(()=>{const a=r.value||[],i=t.value.toLowerCase().trim();return o(i,a).slice(0,n).map(l=>({id:l.id,title:l.title,description:l.description||""}))})}}function xs(r){async function t(){await e.nextTick();const o=r.value;o&&(o.scrollTop=o.scrollHeight)}function n(o,s){e.watch(o,t),e.watch(s,t)}return{scrollToBottom:t,watchForScroll:n}}const bs=["stroke-width"],kt=e.defineComponent({inheritAttrs:!1,__name:"IconWarning",props:e.mergeModels({class:{},strokeWidth:{default:2}},{class:{default:"w-5 h-5"},classModifiers:{}}),emits:["update:class"],setup(r){const t=e.useModel(r,"class");return(n,o)=>(e.openBlock(),e.createElementBlock("svg",{class:e.normalizeClass(t.value),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":r.strokeWidth},[...o[0]||(o[0]=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"},null,-1)])],10,bs))}}),ws={viewBox:"0 0 24 24",fill:"currentColor"},vn=e.defineComponent({inheritAttrs:!0,__name:"IconUser",setup(r){return(t,n)=>(e.openBlock(),e.createElementBlock("svg",ws,[...n[0]||(n[0]=[e.createElementVNode("path",{"fill-rule":"evenodd",d:"M7.5 6a4.5 4.5 0 1 1 9 0 4.5 4.5 0 0 1-9 0ZM3.751 20.105a8.25 8.25 0 0 1 16.498 0 .75.75 0 0 1-.437.695A18.683 18.683 0 0 1 12 22.5c-2.786 0-5.433-.608-7.812-1.7a.75.75 0 0 1-.437-.695Z","clip-rule":"evenodd"},null,-1)])]))}}),Cs={viewBox:"0 0 24 24",fill:"currentColor"},ze=e.defineComponent({inheritAttrs:!0,__name:"IconSparkles",setup(r){return(t,n)=>(e.openBlock(),e.createElementBlock("svg",Cs,[...n[0]||(n[0]=[e.createElementVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M9 4.5a.75.75 0 0 1 .721.544l.813 2.846a3.75 3.75 0 0 0 2.576 2.576l2.846.813a.75.75 0 0 1 0 1.442l-2.846.813a3.75 3.75 0 0 0-2.576 2.576l-.813 2.846a.75.75 0 0 1-1.442 0l-.813-2.846a3.75 3.75 0 0 0-2.576-2.576l-2.846-.813a.75.75 0 0 1 0-1.442l2.846-.813A3.75 3.75 0 0 0 7.466 7.89l.813-2.846A.75.75 0 0 1 9 4.5ZM18 1.5a.75.75 0 0 1 .728.568l.258 1.036a2.63 2.63 0 0 0 1.91 1.91l1.036.258a.75.75 0 0 1 0 1.456l-1.036.258a2.63 2.63 0 0 0-1.91 1.91l-.258 1.036a.75.75 0 0 1-1.456 0l-.258-1.036a2.63 2.63 0 0 0-1.91-1.91l-1.036-.258a.75.75 0 0 1 0-1.456l1.036-.258a2.63 2.63 0 0 0 1.91-1.91l.258-1.036A.75.75 0 0 1 18 1.5ZM16.5 15a.75.75 0 0 1 .712.513l.394 1.183c.15.447.5.799.948.948l1.183.395a.75.75 0 0 1 0 1.422l-1.183.395a1.5 1.5 0 0 0-.948.948l-.395 1.183a.75.75 0 0 1-1.422 0l-.395-1.183a1.5 1.5 0 0 0-.948-.948l-1.183-.395a.75.75 0 0 1 0-1.422l1.183-.395a1.5 1.5 0 0 0 .948-.948l.395-1.183A.75.75 0 0 1 16.5 15Z"},null,-1)])]))}}),Es={fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},Jt=e.defineComponent({inheritAttrs:!0,__name:"IconDocument",setup(r){return(t,n)=>(e.openBlock(),e.createElementBlock("svg",Es,[...n[0]||(n[0]=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.5",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"},null,-1)])]))}}),Ss={fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},Ts=e.defineComponent({inheritAttrs:!0,__name:"IconPaperclip",setup(r){return(t,n)=>(e.openBlock(),e.createElementBlock("svg",Ss,[...n[0]||(n[0]=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.5",d:"M18.375 12.739l-7.693 7.693a4.5 4.5 0 01-6.364-6.364l10.94-10.94A3 3 0 1119.5 7.372L8.552 18.32m.009-.01l-.01.01m5.699-9.941l-7.81 7.81a1.5 1.5 0 002.112 2.13"},null,-1)])]))}}),As=["stroke-width"],er=e.defineComponent({inheritAttrs:!0,__name:"IconQuestionCircle",props:{strokeWidth:{default:1.5}},setup(r){return(t,n)=>(e.openBlock(),e.createElementBlock("svg",{fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":r.strokeWidth},[...n[0]||(n[0]=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827v.75M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9 5.25h.008v.008H12v-.008z"},null,-1)])],8,As))}}),Ms=["stroke-width"],vt=e.defineComponent({inheritAttrs:!0,__name:"IconClose",props:{strokeWidth:{default:1.5}},setup(r){return(t,n)=>(e.openBlock(),e.createElementBlock("svg",{fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":r.strokeWidth},[...n[0]||(n[0]=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M6 18L18 6M6 6l12 12"},null,-1)])],8,Ms))}}),Bs={fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},Ns=e.defineComponent({inheritAttrs:!0,__name:"IconSend",setup(r){return(t,n)=>(e.openBlock(),e.createElementBlock("svg",Bs,[...n[0]||(n[0]=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 12L3.269 3.126A59.768 59.768 0 0121.485 12 59.77 59.77 0 013.27 20.876L5.999 12zm0 0h7.5"},null,-1)])]))}}),Rs={viewBox:"0 0 24 24",fill:"currentColor"},_s=e.defineComponent({inheritAttrs:!0,__name:"IconStop",setup(r){return(t,n)=>(e.openBlock(),e.createElementBlock("svg",Rs,[...n[0]||(n[0]=[e.createElementVNode("path",{"fill-rule":"evenodd",d:"M4.5 7.5a3 3 0 013-3h9a3 3 0 013 3v9a3 3 0 01-3 3h-9a3 3 0 01-3-3v-9z","clip-rule":"evenodd"},null,-1)])]))}}),Ls={fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},Is=e.defineComponent({inheritAttrs:!0,__name:"IconCopy",setup(r){return(t,n)=>(e.openBlock(),e.createElementBlock("svg",Ls,[...n[0]||(n[0]=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.5",d:"M15.666 3.888A2.25 2.25 0 0013.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 01-.75.75H9a.75.75 0 01-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 01-2.25 2.25H6.75A2.25 2.25 0 014.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 011.927-.184"},null,-1)])]))}}),$s={fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},Ds=e.defineComponent({inheritAttrs:!0,__name:"IconCheck",setup(r){return(t,n)=>(e.openBlock(),e.createElementBlock("svg",$s,[...n[0]||(n[0]=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 13l4 4L19 7"},null,-1)])]))}}),zs={fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"2"},Os=e.defineComponent({inheritAttrs:!0,__name:"IconChatBubble",setup(r){return(t,n)=>(e.openBlock(),e.createElementBlock("svg",zs,[...n[0]||(n[0]=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",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"},null,-1)])]))}}),Ps={fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},Vs=e.defineComponent({inheritAttrs:!0,__name:"IconMinimize",setup(r){return(t,n)=>(e.openBlock(),e.createElementBlock("svg",Ps,[...n[0]||(n[0]=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M5 12h14"},null,-1)])]))}}),Fs={fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},Hs=e.defineComponent({inheritAttrs:!0,__name:"IconFullscreen",setup(r){return(t,n)=>(e.openBlock(),e.createElementBlock("svg",Fs,[...n[0]||(n[0]=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M3.75 3.75v4.5m0-4.5h4.5m-4.5 0L9 9M3.75 20.25v-4.5m0 4.5h4.5m-4.5 0L9 15M20.25 3.75h-4.5m4.5 0v4.5m0-4.5L15 9m5.25 11.25h-4.5m4.5 0v-4.5m0 4.5L15 15"},null,-1)])]))}}),Us={fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"1.5"},qs=e.defineComponent({inheritAttrs:!0,__name:"IconExitFullscreen",setup(r){return(t,n)=>(e.openBlock(),e.createElementBlock("svg",Us,[...n[0]||(n[0]=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M9 9V4.5M9 9H4.5M9 9L3.75 3.75M9 15v4.5M9 15H4.5M9 15l-5.25 5.25M15 9h4.5M15 9V4.5M15 9l5.25-5.25M15 15h4.5M15 15v4.5m0-4.5l5.25 5.25"},null,-1)])]))}}),js={fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},Ws=e.defineComponent({inheritAttrs:!0,__name:"IconClock",setup(r){return(t,n)=>(e.openBlock(),e.createElementBlock("svg",js,[...n[0]||(n[0]=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"},null,-1)])]))}}),Ks={fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},Gs=e.defineComponent({inheritAttrs:!0,__name:"IconRefresh",setup(r){return(t,n)=>(e.openBlock(),e.createElementBlock("svg",Ks,[...n[0]||(n[0]=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"},null,-1)])]))}}),Qs={fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},Zs=e.defineComponent({inheritAttrs:!0,__name:"IconSupport",setup(r){return(t,n)=>(e.openBlock(),e.createElementBlock("svg",Qs,[...n[0]||(n[0]=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z"},null,-1)])]))}}),tr=e.defineComponent({__name:"AiAvatar",props:{ui:{}},setup(r){return(t,n)=>{var o;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["w-8 h-8 min-w-[32px] flex items-center justify-center rounded-full border border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-800",(o=r.ui)==null?void 0:o.container])},[e.renderSlot(t.$slots,"default",{},()=>{var s;return[e.createVNode(e.unref(ze),{class:e.normalizeClass(["w-4 h-4 text-gray-500 dark:text-gray-400",(s=r.ui)==null?void 0:s.icon])},null,8,["class"])]})],2)}}}),Ys=e.defineComponent({__name:"UserAvatar",props:{ui:{}},setup(r){return(t,n)=>{var o;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["w-8 h-8 rounded-full bg-gray-200 dark:bg-gray-700 flex items-center justify-center flex-shrink-0",(o=r.ui)==null?void 0:o.container])},[e.renderSlot(t.$slots,"default",{},()=>{var s;return[e.createVNode(e.unref(vn),{class:e.normalizeClass(["w-5 h-5 text-gray-500 dark:text-gray-400",(s=r.ui)==null?void 0:s.icon])},null,8,["class"])]})],2)}}}),Xs=["onClick","onMouseenter"],nr=e.defineComponent({__name:"MentionList",props:{items:{},selectedIndex:{default:0},providers:{default:()=>[]},ui:{},texts:{}},emits:["select","update:selectedIndex"],setup(r,{emit:t}){const n=r,o=e.computed(()=>n.ui||{}),s=t,a=e.ref(n.selectedIndex);e.watch(()=>n.selectedIndex,p=>{a.value=p}),e.watch(a,p=>{s("update:selectedIndex",p)});const i=e.computed(()=>{const p={};return n.items.forEach(w=>{const M=w.type||"default";p[M]||(p[M]=[]),p[M].push(w)}),p});function l(p){return n.providers.find(w=>w.type===p)||kn(p)}function u(p){const w=l(p);return(w==null?void 0:w.label)||p.charAt(0).toUpperCase()+p.slice(1)+"s"}function d(p,w){let M=0;const x=Object.keys(i.value);for(const C of x){if(C===p)return M+w;M+=i.value[C].length}return M}function m(p){s("select",p)}function h(p){a.value=p,s("update:selectedIndex",p)}function g(p){const w=l(p.type);return Lt(p,w)}function y(p){const w=l(p.type);return yn(p,w)}function f(p){const w={employee:"bg-blue-100 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400",job:"bg-green-100 dark:bg-green-900/30 text-green-600 dark:text-green-400",candidate:"bg-purple-100 dark:bg-purple-900/30 text-purple-600 dark:text-purple-400",project:"bg-orange-100 dark:bg-orange-900/30 text-orange-600 dark:text-orange-400",default:"bg-primary/10 text-primary"};return w[p]||w.default}function S(p){return p.split(" ").map(w=>w[0]).join("").slice(0,2).toUpperCase()}return(p,w)=>r.items.length>0?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["absolute bottom-full left-0 right-0 mb-2 bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 shadow-lg max-h-60 overflow-y-auto z-50",o.value.root])},[e.createElementVNode("div",{class:e.normalizeClass(["p-2",o.value.container])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,(M,x)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:x},[Object.keys(i.value).length>1?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["px-3 py-1.5 text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wide",o.value.groupHeader])},e.toDisplayString(u(x)),3)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(M,(C,I)=>(e.openBlock(),e.createElementBlock("button",{key:C.id,type:"button",class:e.normalizeClass(["w-full flex items-center gap-3 px-3 py-2 rounded-lg text-left transition-colors mb-0.5",[o.value.item,{[o.value.itemSelected||"bg-primary/10"]:d(x,I)===a.value,"hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer":d(x,I)!==a.value}]]),onClick:b=>m(C),onMouseenter:b=>h(d(x,I))},[e.renderSlot(p.$slots,"item-icon",{item:C,type:x},()=>[e.createElementVNode("span",{class:e.normalizeClass(["w-8 h-8 flex items-center justify-center rounded-full text-xs font-semibold flex-shrink-0",[o.value.itemIcon,f(C.type)]])},e.toDisplayString(S(g(C))),3)]),e.createElementVNode("div",{class:e.normalizeClass(["flex-1 min-w-0",o.value.itemContent])},[e.createElementVNode("p",{class:e.normalizeClass(["text-sm font-medium text-gray-900 dark:text-gray-100 truncate",o.value.itemName])},e.toDisplayString(g(C)),3),y(C)?(e.openBlock(),e.createElementBlock("p",{key:0,class:e.normalizeClass(["text-xs text-gray-500 dark:text-gray-400 truncate",o.value.itemSubtitle])},e.toDisplayString(y(C)),3)):e.createCommentVNode("",!0)],2)],42,Xs))),128))],64))),128))],2)],2)):e.createCommentVNode("",!0)}}),Js=["title"],rr=e.defineComponent({__name:"ChatMessageActions",props:{message:{},ui:{},texts:{}},emits:["copy"],setup(r,{emit:t}){const n=r,o=t,s=u=>{var m;return(m=n.texts)!=null&&m[u]?n.texts[u]:te({copyToClipboard:"copyToClipboard",copied:"copied"}[u])},a=e.computed(()=>n.ui||{}),i=e.ref(!1);async function l(){try{await navigator.clipboard.writeText(n.message.message),i.value=!0,o("copy",n.message),setTimeout(()=>{i.value=!1},2e3)}catch(u){console.error("Failed to copy:",u)}}return(u,d)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",a.value.container])},[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors",[a.value.button,a.value.copyButton]]),title:i.value?s("copied"):s("copyToClipboard"),onClick:l},[i.value?(e.openBlock(),e.createBlock(e.unref(Ds),{key:1,class:e.normalizeClass(["w-4 h-4 text-green-500",a.value.successState])},null,8,["class"])):(e.openBlock(),e.createBlock(e.unref(Is),{key:0,class:"w-4 h-4 text-gray-500 dark:text-gray-400"}))],10,Js)],2))}}),vs={class:"text-gray-600 dark:text-gray-400"},ea=e.defineComponent({__name:"LoadingIndicator",props:{text:{},ui:{}},setup(r){return(t,n)=>{var o,s;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["flex items-center gap-2 text-sm min-w-[150px]",(o=r.ui)==null?void 0:o.loadingIndicator])},[e.createElementVNode("div",{class:e.normalizeClass(["flex space-x-1",(s=r.ui)==null?void 0:s.loadingDots])},[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(3,a=>e.createElementVNode("div",{key:a,class:"w-2 h-2 bg-gray-400 rounded-full animate-bounce",style:e.normalizeStyle({animationDelay:`${(a-1)*150}ms`})},null,4)),64))],2),e.createElementVNode("span",vs,e.toDisplayString(r.text),1)],2)}}}),ta={class:"h-12 w-12 flex items-center justify-center rounded-lg bg-white/20 overflow-hidden"},na=["src"],ra={class:"flex-1 min-w-0"},oa={class:"text-sm font-semibold text-white truncate"},sa={class:"text-xs text-white/70"},aa={key:0,class:"text-xs font-medium text-white/90"},ia=["src"],la={class:"flex-shrink-0 group-hover:opacity-0 transition-opacity"},ca=["id","innerHTML"],ua={class:"h-12 w-12 flex items-center justify-center rounded-lg bg-white dark:bg-gray-800 overflow-hidden border border-gray-200 dark:border-gray-600"},da=["src"],ma={class:"flex-1 min-w-0"},fa={class:"text-sm font-semibold text-gray-800 dark:text-gray-200 truncate"},pa={class:"text-xs text-gray-500 dark:text-gray-400"},ha={key:0,class:"text-xs font-medium text-primary"},ga=e.defineComponent({__name:"ChatMessage",props:{message:{},showActions:{type:Boolean,default:!0},loadingText:{default:"Gathering data..."},ui:{},texts:{}},emits:["copy"],setup(r,{emit:t}){const n=r,o=t,s=f=>{var p;return(p=n.texts)!=null&&p[f]?n.texts[f]:{loadingText:"Gathering data...",showMore:"Show more",showLess:"Show less",openAttachment:"Open",attachment:"Attachment"}[f]||f},{parseMarkdown:a}=Zn(),i=e.ref(!1),l=e.computed(()=>n.message.attachments??[]),u=e.computed(()=>l.value.length>0),d=e.computed(()=>{if(n.message.role!=="user")return!1;const f=n.message.message||"",S=f.split(`
|
|
59
|
+
`).length;return f.length>200||S>4});function m(){i.value=!i.value}const h=e.computed(()=>{const f=K();return f!=null&&f.userAvatar?typeof f.userAvatar=="string"?f.userAvatar:typeof f.userAvatar=="function"?f.userAvatar():null:null}),g=e.computed(()=>{if(n.message.role==="assistant"){let f=n.message.message;return f=f.replace(/\\n/g,`
|
|
60
|
+
`),a(f)}return n.message.message});function y(f){o("copy",f)}return(f,S)=>{var p,w,M,x,C,I,b,N,L,A,B,V,G,_,O;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["group relative animate-in fade-in slide-in-from-bottom-2 duration-300",[(p=r.ui)==null?void 0:p.root,{"flex justify-end":r.message.role==="user","flex justify-start":r.message.role==="assistant"}]])},[r.message.role==="user"?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["flex gap-3 justify-end",(w=r.ui)==null?void 0:w.userMessage])},[e.createElementVNode("div",{class:e.normalizeClass(["rounded-2xl px-4 py-3 bg-primary-500 text-white max-w-fit",(M=r.ui)==null?void 0:M.userBubble])},[r.message.message?(e.openBlock(),e.createElementBlock("p",{key:0,class:e.normalizeClass(["text-sm whitespace-pre-wrap",[(x=r.ui)==null?void 0:x.content,{"line-clamp-4":!i.value&&d.value}]])},e.toDisplayString(r.message.message),3)):e.createCommentVNode("",!0),d.value?(e.openBlock(),e.createElementBlock("button",{key:1,class:e.normalizeClass(["mt-2 text-xs text-white/80 hover:text-white underline",(C=r.ui)==null?void 0:C.showMoreButton]),onClick:m},e.toDisplayString(i.value?s("showLess"):s("showMore")),3)):e.createCommentVNode("",!0),u.value?(e.openBlock(),e.createElementBlock("div",{key:2,class:e.normalizeClass(["mt-3 space-y-2",(I=r.ui)==null?void 0:I.attachmentsContainer])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value,z=>{var ne;return e.openBlock(),e.createBlock(e.resolveDynamicComponent(z.url?"a":"div"),{key:z.id,href:z.url||void 0,target:z.url?"_blank":void 0,rel:"noopener noreferrer",class:e.normalizeClass(["flex items-center gap-3 rounded-xl border border-white/20 bg-white/10 p-2 transition",[(ne=r.ui)==null?void 0:ne.attachmentItem,z.url?"hover:bg-white/20 cursor-pointer":""]])},{default:e.withCtx(()=>[e.createElementVNode("div",ta,[z.url&&e.unref(it)(z)?(e.openBlock(),e.createElementBlock("img",{key:0,src:z.url,class:"object-cover h-full w-full",alt:""},null,8,na)):(e.openBlock(),e.createBlock(e.unref(Jt),{key:1,class:"w-5 h-5 text-white"}))]),e.createElementVNode("div",ra,[e.createElementVNode("p",oa,e.toDisplayString(z.name||s("attachment")),1),e.createElementVNode("p",sa,e.toDisplayString(e.unref(lt)(z.size)),1)]),z.url?(e.openBlock(),e.createElementBlock("span",aa,e.toDisplayString(s("openAttachment")),1)):e.createCommentVNode("",!0)]),_:2},1032,["href","target","class"])}),128))],2)):e.createCommentVNode("",!0)],2),e.createElementVNode("div",{class:e.normalizeClass(["flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary-500 overflow-hidden",(b=r.ui)==null?void 0:b.userAvatar])},[h.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:h.value,alt:"User",class:"h-full w-full object-cover"},null,8,ia)):(e.openBlock(),e.createBlock(e.unref(vn),{key:1,class:"h-4 w-4 text-white"}))],2)],2)):(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["flex items-start gap-3",(N=r.ui)==null?void 0:N.assistantMessage])},[e.createElementVNode("div",la,[e.createVNode(tr)]),e.createElementVNode("div",{class:e.normalizeClass(["bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 px-4 py-3 shadow-sm rounded-2xl transition-all duration-200 max-w-[85%]",(L=r.ui)==null?void 0:L.assistantBubble])},[r.message.loading?(e.openBlock(),e.createBlock(ea,{key:0,text:((A=r.texts)==null?void 0:A.loadingText)||r.loadingText,ui:{loadingIndicator:(B=r.ui)==null?void 0:B.loadingIndicator,loadingDots:(V=r.ui)==null?void 0:V.loadingDots}},null,8,["text","ui"])):r.message.message?(e.openBlock(),e.createElementBlock("div",{key:1,id:r.message.id,class:e.normalizeClass(["text-sm text-gray-700 dark:text-gray-200 leading-relaxed",(G=r.ui)==null?void 0:G.content]),innerHTML:g.value},null,10,ca)):e.createCommentVNode("",!0),!r.message.loading&&u.value?(e.openBlock(),e.createElementBlock("div",{key:2,class:e.normalizeClass(["mt-4 space-y-2",(_=r.ui)==null?void 0:_.attachmentsContainer])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value,z=>{var ne;return e.openBlock(),e.createBlock(e.resolveDynamicComponent(z.url?"a":"div"),{key:z.id,href:z.url||void 0,target:z.url?"_blank":void 0,rel:"noopener noreferrer",class:e.normalizeClass(["flex items-center gap-3 rounded-xl border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 p-3 transition",[(ne=r.ui)==null?void 0:ne.attachmentItem,z.url?"hover:bg-white dark:hover:bg-gray-600 cursor-pointer":""]])},{default:e.withCtx(()=>[e.createElementVNode("div",ua,[z.url&&e.unref(it)(z)?(e.openBlock(),e.createElementBlock("img",{key:0,src:z.url,class:"object-cover h-full w-full",alt:""},null,8,da)):(e.openBlock(),e.createBlock(e.unref(Jt),{key:1,class:"w-5 h-5 text-gray-500 dark:text-gray-400"}))]),e.createElementVNode("div",ma,[e.createElementVNode("p",fa,e.toDisplayString(z.name||s("attachment")),1),e.createElementVNode("p",pa,e.toDisplayString(e.unref(lt)(z.size)),1)]),z.url?(e.openBlock(),e.createElementBlock("span",ha,e.toDisplayString(s("openAttachment")),1)):e.createCommentVNode("",!0)]),_:2},1032,["href","target","class"])}),128))],2)):e.createCommentVNode("",!0)],2)],2)),r.message.role==="assistant"&&!r.message.loading&&!r.message.streaming&&r.showActions?(e.openBlock(),e.createBlock(rr,{key:2,message:r.message,class:e.normalizeClass(["absolute top-0 left-0",(O=r.ui)==null?void 0:O.actionsContainer]),onCopy:y},null,8,["message","class"])):e.createCommentVNode("",!0)],2)}}}),or=(r,t)=>{const n=r.__vccOpts||r;for(const[o,s]of t)n[o]=s;return n},sr=or(ga,[["__scopeId","data-v-458d9332"]]),ya={class:"text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wide"},ka={class:"space-y-2"},xa=["src"],ba={class:"flex-1 min-w-0"},wa={class:"text-sm font-medium text-gray-800 dark:text-gray-200 truncate"},Ca={class:"text-xs text-gray-500 dark:text-gray-400"},Ea={key:0,class:"mt-1 h-1 bg-gray-200 dark:bg-gray-600 rounded-full overflow-hidden"},Sa={key:0,class:"text-xs text-gray-400"},Ta=["disabled","onClick"],Aa=e.defineComponent({__name:"AttachmentsPreview",props:{attachments:{},ui:{},texts:{},isImage:{type:Function},formatFileSize:{type:Function}},emits:["remove"],setup(r){return(t,n)=>{var o;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["border border-gray-200 dark:border-gray-700 rounded-2xl p-3 bg-gray-50 dark:bg-gray-800 space-y-3",r.ui.attachmentsContainer])},[e.createElementVNode("p",ya,e.toDisplayString(((o=r.texts)==null?void 0:o.attachedFiles)||"Attached files"),1),e.createElementVNode("ul",ka,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.attachments,s=>(e.openBlock(),e.createElementBlock("li",{key:s.id,class:e.normalizeClass(["flex items-center gap-3 rounded-xl bg-white dark:bg-gray-700 p-2 shadow-sm border border-gray-100 dark:border-gray-600",r.ui.attachmentItem])},[e.createElementVNode("div",{class:e.normalizeClass(["h-10 w-10 flex items-center justify-center rounded-lg bg-gray-100 dark:bg-gray-600 overflow-hidden",r.ui.attachmentThumbnail])},[r.isImage(s)?(e.openBlock(),e.createElementBlock("img",{key:0,src:s.previewUrl||s.url,class:"object-cover h-full w-full",alt:""},null,8,xa)):(e.openBlock(),e.createBlock(e.unref(Jt),{key:1,class:"w-5 h-5 text-gray-500 dark:text-gray-400"}))],2),e.createElementVNode("div",ba,[e.createElementVNode("p",wa,e.toDisplayString(s.name),1),e.createElementVNode("p",Ca,e.toDisplayString(r.formatFileSize(s.size)),1),s.uploading?(e.openBlock(),e.createElementBlock("div",Ea,[e.createElementVNode("div",{class:"h-full bg-primary transition-all",style:e.normalizeStyle({width:`${s.progress??10}%`})},null,4)])):e.createCommentVNode("",!0)]),s.uploading?(e.openBlock(),e.createElementBlock("span",Sa,e.toDisplayString(Math.round(s.progress??0))+"% ",1)):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["p-1 rounded-full hover:bg-gray-100 dark:hover:bg-gray-600 disabled:opacity-50 disabled:cursor-not-allowed",r.ui.attachmentRemove]),disabled:s.uploading,onClick:a=>t.$emit("remove",s.id)},[e.createVNode(e.unref(vt),{class:"w-4 h-4 text-gray-500 dark:text-gray-400"})],10,Ta)],2))),128))])],2)}}}),Ma={class:"py-1"},Ba=["onClick","onMouseenter"],Na={class:"flex items-start gap-3"},Ra={class:"flex-1 min-w-0"},_a={class:"text-sm font-medium text-gray-900 dark:text-gray-100"},La={class:"text-xs text-gray-500 dark:text-gray-400 mt-0.5 line-clamp-2"},Ia=e.defineComponent({__name:"SuggestionsDropdown",props:{suggestions:{},selectedIndex:{},ui:{}},emits:["select","hover"],setup(r,{expose:t}){const n=e.ref(null);return t({dropdownRef:n}),(o,s)=>(e.openBlock(),e.createBlock(e.Transition,{"enter-active-class":"transition ease-out duration-100","enter-from-class":"transform opacity-0 scale-95","enter-to-class":"transform opacity-100 scale-100","leave-active-class":"transition ease-in duration-75","leave-from-class":"transform opacity-100 scale-100","leave-to-class":"transform opacity-0 scale-95"},{default:e.withCtx(()=>[e.createElementVNode("div",{ref_key:"dropdownRef",ref:n,class:e.normalizeClass(["absolute bottom-full left-0 right-0 mb-2 bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 shadow-lg max-h-80 overflow-y-auto z-10",r.ui.suggestionsDropdown])},[e.createElementVNode("ul",Ma,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.suggestions,(a,i)=>(e.openBlock(),e.createElementBlock("li",{key:a.id,class:e.normalizeClass(["px-4 py-3 cursor-pointer transition-colors border-b border-gray-100 dark:border-gray-700 last:border-b-0",[r.ui.suggestionItem,{[r.ui.suggestionItemSelected||"bg-primary/10"]:i===r.selectedIndex,"hover:bg-gray-50 dark:hover:bg-gray-700":i!==r.selectedIndex}]]),onClick:l=>o.$emit("select",a),onMouseenter:l=>o.$emit("hover",i)},[e.createElementVNode("div",Na,[e.createElementVNode("div",Ra,[e.createElementVNode("p",_a,e.toDisplayString(a.title),1),e.createElementVNode("p",La,e.toDisplayString(a.description),1)])])],42,Ba))),128))])],2)]),_:1}))}}),$a={class:"absolute right-3 top-1/2 -translate-y-1/2 flex items-center gap-1 z-10"},Da=["title"],za=["title"],Oa=["disabled"],Pa=e.defineComponent({__name:"InputActions",props:{sending:{type:Boolean},canSend:{type:Boolean},supportRequestMode:{type:Boolean},showSupportModeToggle:{type:Boolean},ui:{},texts:{}},emits:["toggle-support-mode","click"],setup(r){const t=r,n=e.computed(()=>t.sending?[t.ui.stopButton||"bg-red-500 text-white hover:bg-red-600"]:t.canSend?[t.ui.sendButtonActive||"bg-primary-500 text-white hover:bg-primary-600"]:[t.ui.sendButtonDisabled||"bg-gray-200 dark:bg-gray-700 text-gray-400 dark:text-gray-500 cursor-not-allowed opacity-60"]);return(o,s)=>{var a,i,l;return e.openBlock(),e.createElementBlock("div",$a,[r.showSupportModeToggle&&!r.supportRequestMode?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:e.normalizeClass(["h-9 w-9 rounded-xl flex items-center justify-center text-gray-400 hover:text-primary hover:bg-gray-100 dark:hover:bg-gray-700 transition flex-shrink-0",r.ui.supportToggle]),title:((a=r.texts)==null?void 0:a.toggleSupportMode)||"Toggle support mode",onClick:s[0]||(s[0]=u=>o.$emit("toggle-support-mode"))},[e.createVNode(e.unref(er),{class:"w-5 h-5"})],10,Da)):e.createCommentVNode("",!0),r.showSupportModeToggle&&r.supportRequestMode?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:e.normalizeClass(["h-7 px-2 rounded-lg flex items-center gap-1 text-xs font-medium bg-amber-100 dark:bg-amber-900/30 text-amber-700 dark:text-amber-400 hover:bg-amber-200 dark:hover:bg-amber-900/50 transition flex-shrink-0",r.ui.supportBadge]),title:((i=r.texts)==null?void 0:i.exitSupportMode)||"Exit support mode",onClick:s[1]||(s[1]=u=>o.$emit("toggle-support-mode"))},[e.createVNode(e.unref(er),{class:"w-3.5 h-3.5","stroke-width":2}),e.createElementVNode("span",null,e.toDisplayString(((l=r.texts)==null?void 0:l.supportLabel)||"Support"),1),e.createVNode(e.unref(vt),{class:"w-3 h-3","stroke-width":2})],10,za)):e.createCommentVNode("",!0),e.createElementVNode("button",{disabled:!r.canSend&&!r.sending,class:e.normalizeClass(["h-9 w-9 rounded-xl flex items-center justify-center transition-all duration-200 flex-shrink-0",n.value]),type:"button",onClick:s[2]||(s[2]=e.withModifiers(u=>o.$emit("click"),["prevent"]))},[r.sending?(e.openBlock(),e.createBlock(e.unref(_s),{key:1,class:"w-4 h-4"})):(e.openBlock(),e.createBlock(e.unref(Ns),{key:0,class:"w-4 h-4"}))],10,Oa)])}}}),Va={class:"max-w-3xl mx-auto space-y-3"},Fa=["accept"],Ha=["title"],Ua={class:"flex items-center"},qa=["placeholder","disabled"],ja={key:0,class:"flex justify-center"},ar=e.defineComponent({__name:"ChatInput",props:{modelValue:{},disabled:{type:Boolean,default:!1},sending:{type:Boolean,default:!1},placeholder:{default:"Ask me anything..."},supportPlaceholder:{default:"Describe your support request..."},minLength:{default:3},suggestions:{default:()=>[]},hasHistory:{type:Boolean,default:!1},supportRequestMode:{type:Boolean,default:!1},showSupportModeToggle:{type:Boolean,default:!1},contextLinkText:{default:""},ui:{},texts:{}},emits:["update:modelValue","submit","cancel","suggestion-select","toggle-support-mode","context-link-click"],setup(r,{expose:t,emit:n}){const o=r,s=n,a=e.ref(o.modelValue),i=e.ref(null),l=e.ref(null),u=e.ref(!1),d=fs(),m=ps(()=>a.value,A=>{a.value=A},()=>i.value),h=hs(()=>o.suggestions,()=>o.hasHistory,()=>u.value,()=>a.value,A=>{s("suggestion-select",A),e.nextTick(()=>{var B;return(B=i.value)==null?void 0:B.focus()})}),{adjustTextareaHeight:g}=gs(()=>i.value),y=e.computed(()=>o.supportRequestMode?o.supportPlaceholder:o.placeholder),f=e.computed(()=>o.showSupportModeToggle?o.supportRequestMode?{paddingLeft:"3rem",paddingRight:"8rem"}:{paddingLeft:"3rem",paddingRight:"6rem"}:{paddingLeft:"3rem",paddingRight:"3.5rem"}),S=e.computed(()=>{var B;return(((B=a.value)==null?void 0:B.trim())??"").length>=o.minLength||d.hasAttachments.value}),p=e.computed(()=>!o.disabled&&!o.sending&&S.value&&!d.isUploading.value);e.watch(()=>o.modelValue,A=>{a.value=A,e.nextTick(g)}),e.watch(a,A=>{s("update:modelValue",A),e.nextTick(g),m.checkForMentions(A),h.updateSuggestionsVisibility()}),e.watch(()=>o.suggestions,()=>{h.updateSuggestionsVisibility()});function w(){g()}function M(A){if(!m.handleMentionKeyDown(A)&&!h.handleSuggestionKeyDown(A)&&A.key==="Enter"){if(A.shiftKey)return;!o.sending&&p.value&&(A.preventDefault(),x())}}function x(){if(!p.value)return;const A=d.buildPayload(),B=a.value.trim(),V=m.getMentions();s("submit",{message:B,attachments:A,mentions:V,isSupportRequest:o.supportRequestMode}),a.value="",d.clearAttachments(),m.clearMentions(),e.nextTick(g)}function C(){o.sending?s("cancel"):p.value&&x()}function I(){var A;o.disabled||o.sending||d.canAddMore.value&&((A=l.value)==null||A.click())}function b(A){h.handleSuggestionClick(A)}function N(){u.value=!0,h.updateSuggestionsVisibility()}function L(){u.value=!1,setTimeout(()=>{h.hideSuggestions(),m.showMentions.value=!1},200)}return t({focus:()=>{var A;return(A=i.value)==null?void 0:A.focus()}}),e.onMounted(()=>{e.nextTick(g)}),(A,B)=>{var V,G,_,O,z,ne,be;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["px-4 pb-4 bg-white dark:bg-gray-900 sticky bottom-0",(V=r.ui)==null?void 0:V.root]),onDragenter:B[6]||(B[6]=e.withModifiers((...U)=>e.unref(d).handleDragEnter&&e.unref(d).handleDragEnter(...U),["prevent"])),onDragover:B[7]||(B[7]=e.withModifiers((...U)=>e.unref(d).handleDragOver&&e.unref(d).handleDragOver(...U),["prevent"])),onDragleave:B[8]||(B[8]=e.withModifiers((...U)=>e.unref(d).handleDragLeave&&e.unref(d).handleDragLeave(...U),["prevent"])),onDrop:B[9]||(B[9]=e.withModifiers((...U)=>e.unref(d).handleDrop&&e.unref(d).handleDrop(...U),["prevent"]))},[e.createElementVNode("form",{class:e.normalizeClass((G=r.ui)==null?void 0:G.form),onSubmit:e.withModifiers(x,["prevent"])},[e.createElementVNode("div",Va,[e.createElementVNode("input",{ref_key:"fileInputRef",ref:l,type:"file",class:"hidden",multiple:"",accept:e.unref(d).acceptedFileTypes,onChange:B[0]||(B[0]=(...U)=>e.unref(d).handleFileSelect&&e.unref(d).handleFileSelect(...U))},null,40,Fa),e.unref(d).hasAttachments.value?(e.openBlock(),e.createBlock(Aa,{key:0,attachments:e.unref(d).attachments.value,ui:r.ui||{},texts:r.texts,"is-image":e.unref(d).isImage,"format-file-size":e.unref(d).formatFileSize,onRemove:e.unref(d).removeAttachment},null,8,["attachments","ui","texts","is-image","format-file-size","onRemove"])):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["relative",(_=r.ui)==null?void 0:_.inputContainer])},[e.unref(h).showSuggestions.value&&r.suggestions.length>0?(e.openBlock(),e.createBlock(Ia,{key:0,ref:"suggestionsHandler.dropdownRef.value",suggestions:r.suggestions,"selected-index":e.unref(h).selectedSuggestionIndex.value,ui:r.ui||{},onSelect:b,onHover:B[1]||(B[1]=U=>e.unref(h).selectedSuggestionIndex.value=U)},null,8,["suggestions","selected-index","ui"])):e.createCommentVNode("",!0),e.createVNode(e.Transition,{"enter-active-class":"transition ease-out duration-100","enter-from-class":"transform opacity-0 scale-95","enter-to-class":"transform opacity-100 scale-100","leave-active-class":"transition ease-in duration-75","leave-from-class":"transform opacity-100 scale-100","leave-to-class":"transform opacity-0 scale-95"},{default:e.withCtx(()=>[e.unref(m).showMentions.value&&e.unref(m).mentionItems.value.length>0?(e.openBlock(),e.createBlock(nr,{key:0,items:e.unref(m).mentionItems.value,"selected-index":e.unref(m).selectedMentionIndex.value,providers:e.unref(m).mentionProviders.value,onSelect:e.unref(m).handleMentionSelect,"onUpdate:selectedIndex":B[2]||(B[2]=U=>e.unref(m).selectedMentionIndex.value=U)},null,8,["items","selected-index","providers","onSelect"])):e.createCommentVNode("",!0)]),_:1}),e.createElementVNode("div",{class:e.normalizeClass(["rounded-2xl border shadow-lg transition-all duration-200 bg-white dark:bg-gray-800",[(O=r.ui)==null?void 0:O.inputWrapper,{"border-primary shadow-primary/30":u.value||e.unref(d).isDraggingFiles.value,"border-gray-200 dark:border-gray-700 shadow-gray-100 dark:shadow-gray-900":!u.value&&!e.unref(d).isDraggingFiles.value}]])},[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["absolute left-3 top-1/2 -translate-y-1/2 h-9 w-9 rounded-xl flex items-center justify-center text-gray-500 dark:text-gray-400 hover:text-primary transition z-10",(z=r.ui)==null?void 0:z.attachButton]),title:((ne=r.texts)==null?void 0:ne.attachFiles)||"Attach files",onClick:I},[e.createVNode(e.unref(Ts),{class:"w-5 h-5"})],10,Ha),e.createElementVNode("div",Ua,[e.withDirectives(e.createElementVNode("textarea",{ref_key:"textareaRef",ref:i,"onUpdate:modelValue":B[3]||(B[3]=U=>a.value=U),rows:"1","data-ai-input":"",placeholder:y.value,disabled:r.disabled,class:e.normalizeClass(["block w-full bg-transparent py-3 text-sm leading-5 text-gray-900 dark:text-gray-100 placeholder:text-gray-400 dark:placeholder:text-gray-500 border-0 focus:outline-none focus-visible:outline-none resize-none",(be=r.ui)==null?void 0:be.textarea]),style:e.normalizeStyle(f.value),onInput:w,onKeydown:M,onFocus:N,onBlur:L},null,46,qa),[[e.vModelText,a.value]])]),e.createVNode(Pa,{sending:r.sending,"can-send":p.value,"support-request-mode":r.supportRequestMode,"show-support-mode-toggle":r.showSupportModeToggle,ui:r.ui||{},texts:r.texts,onToggleSupportMode:B[4]||(B[4]=U=>A.$emit("toggle-support-mode")),onClick:C},null,8,["sending","can-send","support-request-mode","show-support-mode-toggle","ui","texts"])],2)],2),e.renderSlot(A.$slots,"context-link",{},()=>{var U;return[r.contextLinkText?(e.openBlock(),e.createElementBlock("div",ja,[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["text-xs text-gray-400 hover:text-primary transition-colors",(U=r.ui)==null?void 0:U.contextLink]),onClick:B[5]||(B[5]=nt=>A.$emit("context-link-click"))},e.toDisplayString(r.contextLinkText),3)])):e.createCommentVNode("",!0)]})])],34)],34)}}}),Wa=["onClick"],ir=e.defineComponent({__name:"AiEmptyState",props:{ui:{},texts:{}},emits:["item-click"],setup(r,{emit:t}){const n=r,o=t,s=g=>{var f;return(f=n.texts)!=null&&f[g]?n.texts[g]:te({aiName:"aiName",title:"emptyStateTitle",description:"emptyStateDescription"}[g])},a=e.computed(()=>n.ui||{}),{suggestions:i,resolvePrompt:l}=Xt();function u(g){const y={...g,prompt:l(g)};o("item-click",y)}function d(g){return g.gradientClass?g.gradientClass:g.className?g.className:"bg-gradient-to-br from-white to-gray-50 dark:from-gray-800 dark:to-gray-900"}function m(g){const y=g.category||"default",f={hr:"bg-blue-100 dark:bg-blue-900/30",finance:"bg-green-100 dark:bg-green-900/30",analytics:"bg-purple-100 dark:bg-purple-900/30",support:"bg-amber-100 dark:bg-amber-900/30",default:"bg-primary/10"};return f[y]||f.default}function h(g){const y=g.category||"default",f={hr:"text-blue-600 dark:text-blue-400",finance:"text-green-600 dark:text-green-400",analytics:"text-purple-600 dark:text-purple-400",support:"text-amber-600 dark:text-amber-400",default:"text-primary"};return f[y]||f.default}return(g,y)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["flex items-center justify-center p-4 h-full",a.value.root])},[e.createElementVNode("div",{class:e.normalizeClass(["w-full max-w-4xl",a.value.content])},[e.createElementVNode("div",{class:e.normalizeClass(["mb-8 text-center",a.value.header])},[e.createElementVNode("div",{class:e.normalizeClass(["mb-3 inline-flex items-center gap-2 rounded-full bg-primary/10 px-4 py-2 text-sm font-medium text-primary",a.value.badge])},[e.createVNode(e.unref(ze),{class:"w-4 h-4"}),e.createElementVNode("span",null,e.toDisplayString(s("aiName")),1)],2),e.createElementVNode("h1",{class:e.normalizeClass(["mb-3 text-4xl font-bold tracking-tight text-gray-900 dark:text-white",a.value.title])},e.toDisplayString(s("title")),3),e.createElementVNode("p",{class:e.normalizeClass(["text-gray-600 dark:text-gray-400",a.value.description])},e.toDisplayString(s("description")),3)],2),e.createElementVNode("div",{class:e.normalizeClass(["mb-8 grid gap-3 sm:grid-cols-2 lg:grid-cols-3",a.value.grid])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(i),(f,S)=>(e.openBlock(),e.createElementBlock("button",{key:f.id||S,class:e.normalizeClass(["group relative overflow-hidden rounded-xl border border-gray-300 dark:border-gray-600 p-4 text-left transition-all hover:shadow-md hover:scale-[1.02]",[a.value.suggestionCard,d(f)]]),onClick:p=>u(f)},[e.createElementVNode("div",{class:e.normalizeClass(["mb-2 inline-flex h-10 w-10 items-center justify-center rounded-lg",[a.value.suggestionIconContainer,m(f)]])},[f.icon?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(f.icon),{key:0,class:e.normalizeClass(["h-5 w-5",[a.value.suggestionIcon,h(f)]])},null,8,["class"])):(e.openBlock(),e.createBlock(e.unref(ze),{key:1,class:e.normalizeClass(["h-5 w-5",[a.value.suggestionIcon,h(f)]])},null,8,["class"]))],2),e.createElementVNode("h3",{class:e.normalizeClass(["mb-1 text-sm font-semibold text-gray-900 dark:text-white",a.value.suggestionTitle])},e.toDisplayString(f.title),3),e.createElementVNode("p",{class:e.normalizeClass(["text-xs text-gray-600 dark:text-gray-400",a.value.suggestionDescription])},e.toDisplayString(f.description),3)],10,Wa))),128))],2)],2)],2))}}),Ka={class:"flex items-center gap-3"},Ga={key:1,class:"text-xs text-gray-400 dark:text-gray-500 font-medium"},Qa={key:1,class:"flex items-center gap-2"},Za={key:0,class:"flex items-center gap-2 ml-auto mr-4"},Ya={key:1,class:"text-gray-300 dark:text-gray-600"},Xa={class:"text-green-600 dark:text-green-400 font-medium tabular-nums"},Ja={class:"text-gray-500 dark:text-gray-400"},va={key:1,class:"flex items-center gap-1.5 px-2 py-1 rounded-md bg-red-50 dark:bg-red-900/20"},ei={class:"text-xs text-red-600 dark:text-red-400 font-medium"},ti=["title"],ni=["title"],ri=["title"],oi=e.defineComponent({__name:"DrawerHeader",props:{ui:{},isSetupMode:{type:Boolean},showNewChatButton:{type:Boolean},hasHistory:{type:Boolean},showQuota:{type:Boolean},quota:{},showCloseButton:{type:Boolean},showMinimizeButton:{type:Boolean},showFullscreenToggle:{type:Boolean},isFullscreen:{type:Boolean},showMessageCount:{type:Boolean},messageCount:{},messageLimit:{},t:{type:Function}},emits:["new-chat","close","minimize","toggle-fullscreen"],setup(r){const t=r;function n(){const l=t.messageCount/t.messageLimit;return l>=1?"danger":l>=.8?"warning":"default"}const o={icon:{danger:"text-red-500 dark:text-red-400",warning:"text-amber-500 dark:text-amber-400",default:"text-gray-400 dark:text-gray-500"},text:{danger:"text-red-600 dark:text-red-400",warning:"text-amber-600 dark:text-amber-400",default:"text-gray-600 dark:text-gray-300"}},s=e.computed(()=>o.text[n()]),a=e.computed(()=>o.icon[n()]),i=e.computed(()=>t.showMessageCount&&t.hasHistory&&t.showQuota&&t.quota.remaining>=0);return(l,u)=>{var d,m,h,g,y,f,S;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["flex items-center justify-between px-4 sm:px-6 pt-4 border-b border-gray-200 dark:border-gray-700 pb-4",(d=r.ui)==null?void 0:d.header])},[e.createElementVNode("div",Ka,[r.isSetupMode?(e.openBlock(),e.createElementBlock("div",Qa,[...u[4]||(u[4]=[e.createElementVNode("span",{class:"flex h-2 w-2 rounded-full bg-amber-500 animate-pulse"},null,-1),e.createElementVNode("span",{class:"text-sm font-medium text-gray-700 dark:text-gray-300"},"Setup Required",-1)])])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[r.showNewChatButton&&r.hasHistory?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:e.normalizeClass(["inline-flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium text-gray-700 dark:text-gray-200 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 hover:border-gray-400 transition-all duration-200 shadow-sm",(m=r.ui)==null?void 0:m.newChatButton]),onClick:u[0]||(u[0]=p=>l.$emit("new-chat"))},[e.createVNode(e.unref(ze),{class:"w-4 h-4"}),e.createElementVNode("span",null,e.toDisplayString(r.t("newChat")),1)],2)):(e.openBlock(),e.createElementBlock("span",Ga,e.toDisplayString(r.t("keyboardShortcutHint")),1))],64))]),!r.isSetupMode&&(r.showMessageCount||r.showQuota)?(e.openBlock(),e.createElementBlock("div",Za,[r.showMessageCount&&r.hasHistory?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["flex items-center gap-1.5 px-2 py-1 rounded-md bg-gray-100 dark:bg-gray-800",(h=r.ui)==null?void 0:h.messageCountBadge])},[e.createVNode(e.unref(Os),{class:e.normalizeClass(["w-3.5 h-3.5",a.value])},null,8,["class"]),e.createElementVNode("span",{class:e.normalizeClass(["text-xs font-medium tabular-nums",s.value])},[e.renderSlot(l.$slots,"message-count",{},()=>[e.createTextVNode(e.toDisplayString(r.messageCount),1),u[5]||(u[5]=e.createElementVNode("span",{class:"text-gray-400 dark:text-gray-500"},"/",-1)),e.createTextVNode(e.toDisplayString(r.messageLimit),1)])],2)],2)):e.createCommentVNode("",!0),i.value?(e.openBlock(),e.createElementBlock("span",Ya," • ")):e.createCommentVNode("",!0),r.showQuota?e.renderSlot(l.$slots,"quota",{key:2},()=>{var p;return[r.quota.remaining>0?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["flex items-center gap-1.5 text-xs",(p=r.ui)==null?void 0:p.quotaDisplay])},[e.createElementVNode("span",Xa,e.toDisplayString(r.quota.remaining),1),e.createElementVNode("span",Ja,e.toDisplayString(r.t("quotaRemaining")),1)],2)):r.quota.remaining===0?(e.openBlock(),e.createElementBlock("div",va,[e.createVNode(e.unref(kt),{class:"w-3.5 h-3.5 text-red-500"}),e.createElementVNode("span",ei,e.toDisplayString(r.t("noQuota")),1)])):e.createCommentVNode("",!0)]}):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["flex items-center gap-1",(g=r.ui)==null?void 0:g.headerActions])},[r.showCloseButton?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:e.normalizeClass(["p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors",(y=r.ui)==null?void 0:y.headerActionButton]),title:r.t("close"),onClick:u[1]||(u[1]=p=>l.$emit("close"))},[e.createVNode(e.unref(vt),{class:"w-5 h-5 text-gray-600 dark:text-gray-400"})],10,ti)):e.createCommentVNode("",!0),r.showMinimizeButton?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:e.normalizeClass(["p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors",(f=r.ui)==null?void 0:f.headerActionButton]),title:r.t("minimize"),onClick:u[2]||(u[2]=p=>l.$emit("minimize"))},[e.createVNode(e.unref(Vs),{class:"w-5 h-5 text-gray-600 dark:text-gray-400"})],10,ni)):e.createCommentVNode("",!0),r.showFullscreenToggle?(e.openBlock(),e.createElementBlock("button",{key:2,type:"button",class:e.normalizeClass(["p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors",(S=r.ui)==null?void 0:S.headerActionButton]),title:r.isFullscreen?r.t("exitFullscreen"):r.t("fullscreen"),onClick:u[3]||(u[3]=p=>l.$emit("toggle-fullscreen"))},[r.isFullscreen?(e.openBlock(),e.createBlock(e.unref(qs),{key:1,class:"w-5 h-5 text-gray-600 dark:text-gray-400"})):(e.openBlock(),e.createBlock(e.unref(Hs),{key:0,class:"w-5 h-5 text-gray-600 dark:text-gray-400"}))],10,ri)):e.createCommentVNode("",!0)],2)],2)}}}),si={class:"max-w-3xl mx-auto px-4 space-y-6"},ai={class:"flex justify-center"},ii={class:"inline-flex items-center gap-2 rounded-full bg-primary/10 px-4 py-2 text-sm font-medium text-primary"},li={key:0,class:"flex justify-center"},ci={class:"flex items-start gap-3"},ui={class:"flex-1 min-w-0"},di={key:0,class:"text-xs text-amber-600 dark:text-amber-400 mt-1"},mi=["title"],fi=e.defineComponent({__name:"DrawerMessageList",props:{messages:{},loadingMessage:{},quota:{},error:{},ui:{},t:{type:Function}},emits:["copy","contact-support","retry"],setup(r){return(t,n)=>{var o,s,a;return e.openBlock(),e.createElementBlock("div",si,[e.createElementVNode("div",ai,[e.createElementVNode("div",ii,[e.createVNode(e.unref(ze),{class:"w-4 h-4"}),e.createElementVNode("span",null,e.toDisplayString(r.t("title")||e.unref(te)("aiName")),1)])]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.messages,(i,l)=>e.renderSlot(t.$slots,"message",{key:i.id||l,message:i,isUser:i.role==="user",isLoading:i.loading,isStreaming:i.streaming},()=>[e.createVNode(sr,{message:i,"loading-text":r.loadingMessage,onCopy:n[0]||(n[0]=u=>t.$emit("copy",u))},null,8,["message","loading-text"])])),128)),r.quota.remaining===0?(e.openBlock(),e.createElementBlock("div",li,[e.createElementVNode("button",{type:"button",class:"inline-flex items-center gap-2 px-6 py-3 bg-primary-500 text-white rounded-lg hover:bg-primary-600 transition-all shadow-sm",onClick:n[1]||(n[1]=i=>t.$emit("contact-support"))},[e.createVNode(e.unref(Zs),{class:"w-5 h-5"}),e.createElementVNode("span",null,e.toDisplayString(e.unref(te)("contactSupport")),1)])])):e.createCommentVNode("",!0),r.error.message?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["rounded-lg p-4 mb-4",[(o=r.ui)==null?void 0:o.errorContainer,r.error.rateLimited?"bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800":"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800"]])},[e.createElementVNode("div",ci,[e.createElementVNode("div",{class:e.normalizeClass(["flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center",r.error.rateLimited?"bg-amber-100 dark:bg-amber-900/40":"bg-red-100 dark:bg-red-900/40"])},[r.error.rateLimited?(e.openBlock(),e.createBlock(e.unref(Ws),{key:0,class:"w-4 h-4 text-amber-600 dark:text-amber-400"})):(e.openBlock(),e.createBlock(e.unref(kt),{key:1,class:"w-4 h-4 text-red-600 dark:text-red-400"}))],2),e.createElementVNode("div",ui,[e.createElementVNode("p",{class:e.normalizeClass(["text-sm font-medium",[(s=r.ui)==null?void 0:s.errorMessage,r.error.rateLimited?"text-amber-800 dark:text-amber-200":"text-red-800 dark:text-red-200"]])},e.toDisplayString(r.error.message),3),r.error.rateLimited?(e.openBlock(),e.createElementBlock("p",di,e.toDisplayString(r.t("retryHint")||"Please wait a moment before trying again."),1)):e.createCommentVNode("",!0)]),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["flex-shrink-0 inline-flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium rounded-md transition-colors",[(a=r.ui)==null?void 0:a.retryButton,r.error.rateLimited?"text-amber-700 dark:text-amber-300 bg-amber-100 dark:bg-amber-900/40 hover:bg-amber-200 dark:hover:bg-amber-900/60":"text-red-700 dark:text-red-300 bg-red-100 dark:bg-red-900/40 hover:bg-red-200 dark:hover:bg-red-900/60"]]),title:r.t("retry"),onClick:n[2]||(n[2]=i=>t.$emit("retry"))},[e.createVNode(e.unref(Gs),{class:"w-4 h-4"}),e.createTextVNode(" "+e.toDisplayString(r.t("retry")),1)],10,mi)])],2)):e.createCommentVNode("",!0)])}}}),pi={class:"w-14 h-14 rounded-2xl bg-primary/10 flex items-center justify-center mb-5"},hi={class:"w-full max-w-md"},gi={class:"bg-gray-900 rounded-xl overflow-hidden"},yi={class:"flex items-center justify-between px-4 py-2 bg-gray-800/50 border-b border-gray-700"},ki=e.defineComponent({__name:"SetupGuide",props:{copied:{type:Boolean}},emits:["copy"],setup(r){return(t,n)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",pi,[e.createVNode(e.unref(ze),{class:"w-7 h-7 text-primary"})]),n[4]||(n[4]=e.createElementVNode("h2",{class:"text-lg font-semibold text-gray-900 dark:text-white mb-1"}," Almost there! ",-1)),n[5]||(n[5]=e.createElementVNode("p",{class:"text-sm text-gray-500 dark:text-gray-400 mb-6 max-w-sm text-center"}," Configure the plugin in your app entry file to start using AI. ",-1)),e.createElementVNode("div",hi,[e.createElementVNode("div",gi,[e.createElementVNode("div",yi,[n[1]||(n[1]=e.createElementVNode("span",{class:"text-xs text-gray-400"},"main.ts",-1)),e.createElementVNode("button",{type:"button",class:"text-xs text-gray-400 hover:text-white transition-colors",onClick:n[0]||(n[0]=o=>t.$emit("copy"))},e.toDisplayString(r.copied?"✓ Copied":"Copy"),1)]),n[2]||(n[2]=e.createStaticVNode(`<pre class="text-xs text-gray-100 p-4 overflow-x-auto leading-relaxed"><code class="language-typescript"><span class="text-purple-400">import</span> { RestifyAiPlugin } <span class="text-purple-400">from</span> <span class="text-green-400">'@doderasoftware/restify-ai'</span>
|
|
61
61
|
|
|
62
62
|
app.<span class="text-yellow-300">use</span>(RestifyAiPlugin, {
|
|
63
63
|
<span class="text-blue-300">endpoints</span>: {
|
|
@@ -65,7 +65,7 @@ app.<span class="text-yellow-300">use</span>(RestifyAiPlugin, {
|
|
|
65
65
|
<span class="text-blue-300">quota</span>: <span class="text-green-400">'/api/ai/quota'</span>, <span class="text-gray-500">// optional</span>
|
|
66
66
|
},
|
|
67
67
|
<span class="text-blue-300">getAuthToken</span>: () => <span class="text-yellow-300">getToken</span>(),
|
|
68
|
-
})</code></pre>`,1))]),n[3]||(n[3]=e.createElementVNode("p",{class:"text-xs text-gray-400 dark:text-gray-500 mt-4 text-center"},[e.createTextVNode(" Need help? Check the "),e.createElementVNode("a",{href:"https://github.com/
|
|
68
|
+
})</code></pre>`,1))]),n[3]||(n[3]=e.createElementVNode("p",{class:"text-xs text-gray-400 dark:text-gray-500 mt-4 text-center"},[e.createTextVNode(" Need help? Check the "),e.createElementVNode("a",{href:"https://github.com/BinarCode/restify-chatbot",target:"_blank",class:"text-primary hover:underline"},"documentation")],-1))])],64))}}),xi={key:0,class:"flex items-center gap-3 mb-4"},bi={class:"flex-shrink-0 w-10 h-10 rounded-full bg-amber-100 dark:bg-amber-900/30 flex items-center justify-center"},wi={class:"text-lg font-semibold text-gray-900 dark:text-white"},Ci={key:1,class:"text-lg font-semibold text-gray-900 dark:text-white mb-2"},Ei={class:"text-sm text-gray-600 dark:text-gray-400 mb-6"},Si={class:"flex justify-end gap-3"},lr=e.defineComponent({__name:"ConfirmDialog",props:{show:{type:Boolean},title:{},message:{},confirmText:{},cancelText:{},ui:{},icon:{default:null},confirmVariant:{default:"danger"}},emits:["confirm","cancel"],setup(r){const t=r,n=e.computed(()=>{var s,a;return t.icon==="warning"?(s=t.ui)==null?void 0:s.historyLimitModal:(a=t.ui)==null?void 0:a.closeConfirmModal}),o=e.computed(()=>{var i,l;const s=t.confirmVariant==="danger"?"bg-red-600 hover:bg-red-700":"bg-primary-500 hover:bg-primary-600",a=t.confirmVariant==="danger"?(i=t.ui)==null?void 0:i.closeConfirmButton:(l=t.ui)==null?void 0:l.historyLimitButton;return[s,a]});return(s,a)=>(e.openBlock(),e.createBlock(e.Transition,{"enter-active-class":"transition ease-out duration-200","enter-from-class":"opacity-0","enter-to-class":"opacity-100","leave-active-class":"transition ease-in duration-150","leave-from-class":"opacity-100","leave-to-class":"opacity-0"},{default:e.withCtx(()=>{var i;return[r.show?(e.openBlock(),e.createElementBlock("div",{key:0,class:"absolute inset-0 bg-black/50 flex items-center justify-center z-10",onClick:a[2]||(a[2]=e.withModifiers(l=>s.$emit("cancel"),["self"]))},[e.createElementVNode("div",{class:e.normalizeClass(["bg-white dark:bg-gray-800 rounded-xl p-6 m-4 max-w-sm w-full shadow-xl",n.value])},[r.icon==="warning"?(e.openBlock(),e.createElementBlock("div",xi,[e.createElementVNode("div",bi,[e.createVNode(e.unref(kt),{class:"w-5 h-5 text-amber-600 dark:text-amber-400"})]),e.createElementVNode("h3",wi,e.toDisplayString(r.title),1)])):(e.openBlock(),e.createElementBlock("h3",Ci,e.toDisplayString(r.title),1)),e.createElementVNode("p",Ei,e.toDisplayString(r.message),1),e.createElementVNode("div",Si,[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-700 rounded-lg hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors",(i=r.ui)==null?void 0:i.cancelButton]),onClick:a[0]||(a[0]=l=>s.$emit("cancel"))},e.toDisplayString(r.cancelText),3),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["px-4 py-2 text-sm font-medium text-white rounded-lg transition-colors",o.value]),onClick:a[1]||(a[1]=l=>s.$emit("confirm"))},e.toDisplayString(r.confirmText),3)])],2)])):e.createCommentVNode("",!0)]}),_:1}))}}),Ti={key:0,class:"flex-1 flex flex-col items-center justify-center p-6 overflow-y-auto"},Ai={key:0,class:"flex-1 flex flex-col overflow-y-auto"},Mi=or(e.defineComponent({__name:"AiChatDrawer",props:{modelValue:{type:Boolean},ui:{},texts:{},width:{default:"600px"},fullscreenWidth:{default:"90vw"},topOffset:{default:"0"},position:{default:"right"},showBackdrop:{type:Boolean,default:!1},closeOnBackdropClick:{type:Boolean,default:!0},closeOnEscape:{type:Boolean,default:!0},showQuota:{type:Boolean,default:!0},showMessageCount:{type:Boolean,default:!0},showFullscreenToggle:{type:Boolean,default:!0},showMinimizeButton:{type:Boolean,default:!0},showCloseButton:{type:Boolean,default:!0},showNewChatButton:{type:Boolean,default:!0},confirmClose:{type:Boolean,default:!0},historyLimit:{},loadingText:{},autoFetchQuota:{type:Boolean,default:!0}},emits:["update:modelValue","close","contact-support","new-chat"],setup(r,{emit:t}){const n=r,o=t,s=e.computed({get:()=>n.modelValue,set:$=>o("update:modelValue",$)});function a($,P){var le;const X=(le=n.texts)==null?void 0:le[$];if(X){let J=X;if(P)for(const[v,ce]of Object.entries(P))J=J.replace(`{${v}}`,String(ce));return J}return te($,P)}const i=Ae(),l=e.ref(""),u=e.ref(null),d=e.ref(null),m=e.ref(!1),h=e.ref(!1),g=e.ref(!1),{loadingMessage:y,startLoadingText:f,resetLoadingText:S}=ds(()=>i.sending,()=>n.loadingText),{showHistoryLimitWarning:p,historyLimitReached:w,historyLimitDialogTitle:M,historyLimitDialogMessage:x,dismissHistoryLimitWarning:C,handleHistoryLimitAction:I,checkHistoryLimit:b,setPendingMessage:N}=ms({getHistoryLength:()=>i.quota.limit-i.quota.remaining,getStoreLimit:()=>i.quota.limit,getConfig:()=>n.historyLimit,getTexts:()=>n.texts,onStartNewChat:()=>i.clearChatHistory(),onNewChatEmit:()=>o("new-chat")}),L=e.computed(()=>!Nt()),A=e.computed(()=>ke("enableSupportMode")??!1),{suggestions:B,resolvePrompt:V}=Xt(),{scrollToBottom:G,watchForScroll:_}=xs(u),O=e.computed(()=>L.value?[]:B.value||[]),{filteredSuggestions:z}=ks(O,l),ne=e.computed(()=>({quota:i.quota,isFullscreen:m.value,hasHistory:i.chatHistory.length>0,onNewChat:Me,onClose:Q,onMinimize:Ie,onToggleFullscreen:nt})),be=e.computed(()=>({modelValue:l.value,sending:i.sending,disabled:!1,onSubmit:ot,onCancel:()=>i.cancelRequest()}));function U($){const P=(B.value||[]).find(X=>X.id===$.id);P&&(l.value=V(P))}function nt(){m.value=!m.value}function Ie(){s.value=!1}function Q(){n.confirmClose&&!L.value&&i.chatHistory.length>0?g.value=!0:(s.value=!1,o("close"))}function xt(){g.value=!1,i.clearChatHistory(),s.value=!1,o("close")}function Y(){o("contact-support")}function bt(){i.toggleSupportMode()}function j($){l.value=$.prompt,i.clearError()}function Me(){i.clearChatHistory(),o("new-chat")}function rt($){}function Be(){navigator.clipboard.writeText(`import { RestifyAiPlugin } from '@doderasoftware/restify-ai'
|
|
69
69
|
|
|
70
70
|
app.use(RestifyAiPlugin, {
|
|
71
71
|
endpoints: {
|
|
@@ -73,4 +73,4 @@ app.use(RestifyAiPlugin, {
|
|
|
73
73
|
quota: '/api/ai/quota', // optional
|
|
74
74
|
},
|
|
75
75
|
getAuthToken: () => getToken(),
|
|
76
|
-
})`),p.value=!0,setTimeout(()=>{p.value=!1},2e3)}async function Le(){const L=await w();L&&(await e.nextTick(),await ze(L.message,L.attachments,L.mentions,L.isSupportRequest))}async function ze(L,_,H,G){i.clearError(),g(),await e.nextTick(),j();const W=await i.askQuestion(L,_,H,G);m(),W&&j()}async function ke(L){const{message:_,attachments:H,mentions:G,isSupportRequest:W}=L;if(i.sending)return;const K=G.map(se=>({id:se.id,name:se.name,type:se.type||"unknown",metadata:se.metadata}));if(!z()){$({message:_,attachments:H,mentions:K,isSupportRequest:W});return}await ze(_,H,K,W)}async function ht(){g();const L=await i.retry();m(),L&&j()}function $e(L){n.closeOnEscape&&L.key==="Escape"&&s.value&&(f.value?f.value=!1:ye())}return e.watch(()=>n.modelValue,L=>{L&&n.autoFetchQuota&&i.fetchQuota()},{immediate:!0}),e.onMounted(()=>{window.addEventListener("keydown",$e)}),e.onUnmounted(()=>{window.removeEventListener("keydown",$e)}),(L,_)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[e.createVNode(e.Transition,{name:"rai-fade"},{default:e.withCtx(()=>{var H;return[s.value&&r.showBackdrop?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["fixed inset-0 bg-black/30 z-40",(H=r.ui)==null?void 0:H.backdrop]),onClick:_[0]||(_[0]=G=>r.closeOnBackdropClick&&ye())},null,2)):e.createCommentVNode("",!0)]}),_:1}),e.createVNode(e.Transition,{name:r.position==="left"?"rai-slide-right":"rai-slide-left"},{default:e.withCtx(()=>{var H,G,W;return[s.value?(e.openBlock(),e.createElementBlock("aside",{key:0,class:e.normalizeClass(["fixed bottom-0 z-50 flex-shrink-0 border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-900 shadow-2xl will-change-transform",[r.position==="left"?"left-0 border-r":"right-0 border-l",(H=r.ui)==null?void 0:H.drawer]]),style:e.normalizeStyle({width:d.value?r.fullscreenWidth:r.width,top:r.topOffset,height:`calc(100vh - ${r.topOffset})`})},[e.createElementVNode("div",{class:e.normalizeClass(["h-full flex flex-col relative bg-white dark:bg-gray-900",(G=r.ui)==null?void 0:G.panel])},[e.renderSlot(L.$slots,"header",e.normalizeProps(e.guardReactiveProps(M.value)),()=>[e.createVNode(ya,{ui:r.ui,"is-setup-mode":F.value,"show-new-chat-button":r.showNewChatButton,"has-history":e.unref(i).chatHistory.length>0,"show-quota":r.showQuota,quota:e.unref(i).quota,"show-close-button":r.showCloseButton,"show-minimize-button":r.showMinimizeButton,"show-fullscreen-toggle":r.showFullscreenToggle,"is-fullscreen":d.value,"show-message-count":r.showMessageCount,"message-count":e.unref(i).chatHistory.length,"message-limit":e.unref(i).chatHistoryLimit,t:a,onNewChat:Z,onClose:Be,onMinimize:ye,onToggleFullscreen:Re},{quota:e.withCtx(()=>[e.renderSlot(L.$slots,"quota",{quota:e.unref(i).quota},void 0,!0)]),_:3},8,["ui","is-setup-mode","show-new-chat-button","has-history","show-quota","quota","show-close-button","show-minimize-button","show-fullscreen-toggle","is-fullscreen","show-message-count","message-count","message-limit"])],!0),e.createElementVNode("div",{class:e.normalizeClass(["h-full flex flex-col mx-auto w-full overflow-hidden",[{"max-w-5xl":d.value},(W=r.ui)==null?void 0:W.body]])},[F.value?(e.openBlock(),e.createElementBlock("div",za,[e.renderSlot(L.$slots,"setup",{},()=>[e.createVNode(Ma,{copied:p.value,onCopy:v},null,8,["copied"])],!0)])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.unref(i).chatHistory.length===0?(e.openBlock(),e.createElementBlock("div",$a,[e.renderSlot(L.$slots,"empty-state",{suggestions:D.value,onClick:Je},()=>[e.createVNode(Xn,{onItemClick:Je})],!0)])):(e.openBlock(),e.createElementBlock("div",{key:1,ref_key:"chatContainer",ref:u,class:"flex-1 overflow-y-auto py-6 pb-24"},[e.createVNode(Ca,{messages:e.unref(i).chatHistory,"loading-message":e.unref(k),quota:e.unref(i).quota,error:e.unref(i).error,ui:r.ui,t:a,onCopy:mt,onContactSupport:Wt,onRetry:ht},{message:e.withCtx(K=>[e.renderSlot(L.$slots,"message",{message:K.message,isUser:K.isUser,isLoading:K.isLoading,isStreaming:K.isStreaming},void 0,!0)]),_:3},8,["messages","loading-message","quota","error","ui"])],512)),_[3]||(_[3]=e.createElementVNode("div",{id:"rai-chat-bottom",class:"h-8"},null,-1)),e.renderSlot(L.$slots,"input",e.normalizeProps(e.guardReactiveProps(Q.value)),()=>{var K,se;return[e.createVNode(Yn,{modelValue:l.value,"onUpdate:modelValue":_[1]||(_[1]=me=>l.value=me),sending:e.unref(i).sending,placeholder:((K=n.texts)==null?void 0:K.placeholder)||e.unref(J)("inputPlaceholder"),"support-placeholder":((se=n.texts)==null?void 0:se.supportPlaceholder)||e.unref(J)("supportPlaceholder"),suggestions:D.value,"has-history":e.unref(i).chatHistory.length>0,"support-request-mode":e.unref(i).supportRequestMode,"show-support-mode-toggle":S.value,onSubmit:ke,onCancel:e.unref(i).cancelRequest,onSuggestionSelect:fe,onToggleSupportMode:ft},{"context-link":e.withCtx(()=>[e.renderSlot(L.$slots,"context-link",{},void 0,!0)]),_:3},8,["modelValue","sending","placeholder","support-placeholder","suggestions","has-history","support-request-mode","show-support-mode-toggle","onCancel"])]},!0)],64))],2)],2),e.createVNode(Jn,{show:f.value,title:a("closeConfirmTitle"),message:a("closeConfirmMessage"),"confirm-text":a("confirmClose"),"cancel-text":a("cancel"),ui:r.ui,"confirm-variant":"danger",onConfirm:pt,onCancel:_[2]||(_[2]=K=>f.value=!1)},null,8,["show","title","message","confirm-text","cancel-text","ui"]),e.createVNode(Jn,{show:e.unref(E),title:e.unref(h),message:e.unref(b),"confirm-text":a("startNewChat"),"cancel-text":e.unref(y)?a("continueChat"):a("cancel"),ui:r.ui,icon:"warning","confirm-variant":"primary",onConfirm:Le,onCancel:e.unref(C)},null,8,["show","title","message","confirm-text","cancel-text","ui","onCancel"])],6)):e.createCommentVNode("",!0)]}),_:3},8,["name"])]))}}),[["__scopeId","data-v-02153e6b"]]),Va=e.defineComponent({__name:"ErrorBoundary",props:{title:{default:"Something went wrong"},message:{default:"An unexpected error occurred. Please try again."},retryText:{default:"Try Again"},showRetry:{type:Boolean,default:!0},ui:{},onError:{}},emits:["error","reset"],setup(r,{expose:t,emit:n}){const o=r,s=n,a=e.ref(!1),i=e.ref(null);e.onErrorCaptured((u,d,p)=>{var f;return a.value=!0,i.value=u,(f=o.onError)==null||f.call(o,u,p),s("error",u,p),!1});function l(){a.value=!1,i.value=null,s("reset")}return t({hasError:a,error:i,reset:l}),(u,d)=>a.value?e.renderSlot(u.$slots,"error",{key:1,error:i.value,reset:l},()=>{var p,f,k,g,m;return[e.createElementVNode("div",{class:e.normalizeClass(["flex flex-col items-center justify-center p-6 text-center",(p=r.ui)==null?void 0:p.container])},[e.createElementVNode("div",{class:e.normalizeClass(["w-12 h-12 mb-4 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",(f=r.ui)==null?void 0:f.iconContainer])},[...d[0]||(d[0]=[e.createElementVNode("svg",{class:"w-6 h-6 text-red-600 dark:text-red-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})],-1)])],2),e.createElementVNode("h3",{class:e.normalizeClass(["text-lg font-semibold text-gray-900 dark:text-white mb-2",(k=r.ui)==null?void 0:k.title])},e.toDisplayString(r.title),3),e.createElementVNode("p",{class:e.normalizeClass(["text-sm text-gray-600 dark:text-gray-400 mb-4",(g=r.ui)==null?void 0:g.message])},e.toDisplayString(r.message),3),r.showRetry?(e.openBlock(),e.createElementBlock("button",{key:0,class:e.normalizeClass(["px-4 py-2 text-sm font-medium text-white bg-primary rounded-lg hover:bg-primary/90 transition-colors",(m=r.ui)==null?void 0:m.retryButton]),onClick:l},e.toDisplayString(r.retryText),3)):e.createCommentVNode("",!0)],2)]}):e.renderSlot(u.$slots,"default",{key:0})}}),er={install(r,t){if(!t.endpoints||!t.getAuthToken){console.warn("[@doderasoftware/restify-ai] Plugin requires endpoints and getAuthToken options.");return}const n={endpoints:t.endpoints,baseUrl:t.baseUrl,getAuthToken:t.getAuthToken,getCustomHeaders:t.getCustomHeaders,buildRequest:t.buildRequest,parseStreamContent:t.parseStreamContent,requestInterceptor:t.requestInterceptor,responseInterceptor:t.responseInterceptor,retry:t.retry,translate:t.translate,can:t.can,labels:{...Et,...t.labels},mentionProviders:t.mentionProviders,suggestionProviders:t.suggestionProviders,defaultSuggestions:t.defaultSuggestions,theme:t.theme,chatHistoryLimit:t.chatHistoryLimit,maxAttachments:t.maxAttachments,maxFileSize:t.maxFileSize,acceptedFileTypes:t.acceptedFileTypes,chatHistoryKey:t.chatHistoryKey,drawerStateKey:t.drawerStateKey,keyboardShortcut:t.keyboardShortcut,enableSupportMode:t.enableSupportMode,canToggle:t.canToggle,assistantAvatar:t.assistantAvatar,userAvatar:t.userAvatar,onQuotaFetched:t.onQuotaFetched,onError:t.onError,onMessageSent:t.onMessageSent,onResponseReceived:t.onResponseReceived,onDrawerToggle:t.onDrawerToggle,onNewChat:t.onNewChat,onStreamStart:t.onStreamStart,onStreamEnd:t.onStreamEnd,onStreamChunk:t.onStreamChunk,beforeSend:t.beforeSend,afterResponse:t.afterResponse,onFileUploadStart:t.onFileUploadStart,onFileUploadProgress:t.onFileUploadProgress,onFileUploadComplete:t.onFileUploadComplete,onFileUploadError:t.onFileUploadError};en(n),r.provide("restify-ai-config",n)}};B.AiAvatar=Wn,B.AiChatDrawer=Oa,B.AiEmptyState=Xn,B.ChatInput=Yn,B.ChatMessage=Zn,B.ChatMessageActions=Gn,B.ChatRoles=Ae,B.ErrorBoundary=Va,B.MentionList=Kn,B.RestifyAiPlugin=er,B.UserAvatar=as,B.default=er,B.defaultLabels=Et,B.formatMentionsForApi=fn,B.getConfigValue=Te,B.getLabel=J,B.getRestifyAiConfig=q,B.getRestifyAiConfigOrThrow=wr,B.getSuggestionsForPath=vn,B.groupMentionsByType=mn,B.isConfigured=Ct,B.registerSuggestionProvider=Qo,B.setRestifyAiConfig=en,B.useAiContext=vt,B.useAiDrawerShortcut=Jo,B.useAiSuggestions=jt,B.useChatErrorHandling=jo,B.useChatMarkdown=Un,B.useChatScroll=vo,B.useKeyboardShortcut=jn,B.useMentionParsing=Ur,B.usePageAiContext=Zo,B.useRestifyAiStore=Ce,Object.defineProperties(B,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
76
|
+
})`),h.value=!0,setTimeout(()=>{h.value=!1},2e3)}async function wt(){const $=await I();$&&(await e.nextTick(),await Oe($.message,$.attachments,$.mentions,$.isSupportRequest))}async function Oe($,P,X,le){i.clearError(),f(),await e.nextTick(),G();const J=await i.askQuestion($,P,X,le);S(),J&&G()}async function ot($){const{message:P,attachments:X,mentions:le,isSupportRequest:J}=$;if(i.sending)return;const v=le.map(ce=>({id:ce.id,name:ce.name,type:ce.type||"unknown",metadata:ce.metadata}));if(!b()){N({message:P,attachments:X,mentions:v,isSupportRequest:J});return}await Oe(P,X,v,J)}async function Ct(){f();const $=await i.retry();S(),$&&G()}function we($){n.closeOnEscape&&$.key==="Escape"&&s.value&&(g.value?g.value=!1:Ie())}return _(()=>i.chatHistory.length,()=>i.chatHistory.map($=>$.message).join("")),e.watch(()=>n.modelValue,async $=>{var P;$&&(await G(),(P=d.value)==null||P.focus()),$&&n.autoFetchQuota&&i.fetchQuota()},{immediate:!0}),e.onMounted(()=>{window.addEventListener("keydown",we)}),e.onUnmounted(()=>{window.removeEventListener("keydown",we)}),($,P)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[e.createVNode(e.Transition,{name:"rai-fade"},{default:e.withCtx(()=>{var X;return[s.value&&r.showBackdrop?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["fixed inset-0 bg-black/30 z-40",(X=r.ui)==null?void 0:X.backdrop]),onClick:P[0]||(P[0]=le=>r.closeOnBackdropClick&&Ie())},null,2)):e.createCommentVNode("",!0)]}),_:1}),e.createVNode(e.Transition,{name:r.position==="left"?"rai-slide-right":"rai-slide-left"},{default:e.withCtx(()=>{var X,le,J;return[s.value?(e.openBlock(),e.createElementBlock("aside",{key:0,class:e.normalizeClass(["fixed bottom-0 z-50 flex-shrink-0 border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-900 shadow-2xl will-change-transform",[r.position==="left"?"left-0 border-r":"right-0 border-l",(X=r.ui)==null?void 0:X.drawer]]),style:e.normalizeStyle({width:m.value?r.fullscreenWidth:r.width,top:r.topOffset,height:`calc(100vh - ${r.topOffset})`})},[e.createElementVNode("div",{class:e.normalizeClass(["h-full flex flex-col relative bg-white dark:bg-gray-900",(le=r.ui)==null?void 0:le.panel])},[e.renderSlot($.$slots,"header",e.normalizeProps(e.guardReactiveProps(ne.value)),()=>[e.createVNode(oi,{ui:r.ui,"is-setup-mode":L.value,"show-new-chat-button":r.showNewChatButton,"has-history":e.unref(i).chatHistory.length>0,"show-quota":r.showQuota,quota:e.unref(i).quota,"show-close-button":r.showCloseButton,"show-minimize-button":r.showMinimizeButton,"show-fullscreen-toggle":r.showFullscreenToggle,"is-fullscreen":m.value,"show-message-count":r.showMessageCount,"message-count":e.unref(i).quota.used,"message-limit":e.unref(i).quota.limit,t:a,onNewChat:Me,onClose:Q,onMinimize:Ie,onToggleFullscreen:nt},{quota:e.withCtx(()=>[e.renderSlot($.$slots,"quota",{quota:e.unref(i).quota},void 0,!0)]),_:3},8,["ui","is-setup-mode","show-new-chat-button","has-history","show-quota","quota","show-close-button","show-minimize-button","show-fullscreen-toggle","is-fullscreen","show-message-count","message-count","message-limit"])],!0),e.createElementVNode("div",{class:e.normalizeClass(["h-full flex flex-col mx-auto w-full overflow-hidden",[{"max-w-5xl":m.value},(J=r.ui)==null?void 0:J.body]])},[L.value?(e.openBlock(),e.createElementBlock("div",Ti,[e.renderSlot($.$slots,"setup",{},()=>[e.createVNode(ki,{copied:h.value,onCopy:Be},null,8,["copied"])],!0)])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.unref(i).chatHistory.length===0?(e.openBlock(),e.createElementBlock("div",Ai,[e.renderSlot($.$slots,"empty-state",{suggestions:e.unref(z),onClick:j},()=>[e.createVNode(ir,{onItemClick:j})],!0)])):(e.openBlock(),e.createElementBlock("div",{key:1,ref_key:"chatContainer",ref:u,class:"flex-1 overflow-y-auto py-6 pb-24"},[e.createVNode(fi,{messages:e.unref(i).chatHistory,"loading-message":e.unref(y),quota:e.unref(i).quota,error:e.unref(i).error,ui:r.ui,t:a,onCopy:rt,onContactSupport:Y,onRetry:Ct},{message:e.withCtx(v=>[e.renderSlot($.$slots,"message",{message:v.message,isUser:v.isUser,isLoading:v.isLoading,isStreaming:v.isStreaming},void 0,!0)]),_:3},8,["messages","loading-message","quota","error","ui"])],512)),P[3]||(P[3]=e.createElementVNode("div",{id:"rai-chat-bottom",class:"h-8"},null,-1)),e.renderSlot($.$slots,"input",e.normalizeProps(e.guardReactiveProps(be.value)),()=>{var v,ce;return[e.createVNode(ar,{ref_key:"chatInputRef",ref:d,modelValue:l.value,"onUpdate:modelValue":P[1]||(P[1]=Et=>l.value=Et),sending:e.unref(i).sending,placeholder:((v=n.texts)==null?void 0:v.placeholder)||e.unref(te)("inputPlaceholder"),"support-placeholder":((ce=n.texts)==null?void 0:ce.supportPlaceholder)||e.unref(te)("supportPlaceholder"),suggestions:e.unref(z),"has-history":e.unref(i).chatHistory.length>0,"support-request-mode":e.unref(i).supportRequestMode,"show-support-mode-toggle":A.value,onSubmit:ot,onCancel:e.unref(i).cancelRequest,onSuggestionSelect:U,onToggleSupportMode:bt},{"context-link":e.withCtx(()=>[e.renderSlot($.$slots,"context-link",{},void 0,!0)]),_:3},8,["modelValue","sending","placeholder","support-placeholder","suggestions","has-history","support-request-mode","show-support-mode-toggle","onCancel"])]},!0)],64))],2)],2),e.createVNode(lr,{show:g.value,title:a("closeConfirmTitle"),message:a("closeConfirmMessage"),"confirm-text":a("confirmClose"),"cancel-text":a("cancel"),ui:r.ui,"confirm-variant":"danger",onConfirm:xt,onCancel:P[2]||(P[2]=v=>g.value=!1)},null,8,["show","title","message","confirm-text","cancel-text","ui"]),e.createVNode(lr,{show:e.unref(p),title:e.unref(M),message:e.unref(x),"confirm-text":a("startNewChat"),"cancel-text":e.unref(w)?a("continueChat"):a("cancel"),ui:r.ui,icon:"warning","confirm-variant":"primary",onConfirm:wt,onCancel:e.unref(C)},null,8,["show","title","message","confirm-text","cancel-text","ui","onCancel"])],6)):e.createCommentVNode("",!0)]}),_:3},8,["name"])]))}}),[["__scopeId","data-v-25c9b34d"]]),Bi=e.defineComponent({__name:"ErrorBoundary",props:{title:{default:"Something went wrong"},message:{default:"An unexpected error occurred. Please try again."},retryText:{default:"Try Again"},showRetry:{type:Boolean,default:!0},ui:{},onError:{}},emits:["error","reset"],setup(r,{expose:t,emit:n}){const o=r,s=n,a=e.ref(!1),i=e.ref(null);e.onErrorCaptured((u,d,m)=>{var h;return a.value=!0,i.value=u,(h=o.onError)==null||h.call(o,u,m),s("error",u,m),!1});function l(){a.value=!1,i.value=null,s("reset")}return t({hasError:a,error:i,reset:l}),(u,d)=>a.value?e.renderSlot(u.$slots,"error",{key:1,error:i.value,reset:l},()=>{var m,h,g,y,f;return[e.createElementVNode("div",{class:e.normalizeClass(["flex flex-col items-center justify-center p-6 text-center",(m=r.ui)==null?void 0:m.container])},[e.createElementVNode("div",{class:e.normalizeClass(["w-12 h-12 mb-4 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",(h=r.ui)==null?void 0:h.iconContainer])},[e.createVNode(e.unref(kt),{class:"w-6 h-6 text-red-600 dark:text-red-400"})],2),e.createElementVNode("h3",{class:e.normalizeClass(["text-lg font-semibold text-gray-900 dark:text-white mb-2",(g=r.ui)==null?void 0:g.title])},e.toDisplayString(r.title),3),e.createElementVNode("p",{class:e.normalizeClass(["text-sm text-gray-600 dark:text-gray-400 mb-4",(y=r.ui)==null?void 0:y.message])},e.toDisplayString(r.message),3),r.showRetry?(e.openBlock(),e.createElementBlock("button",{key:0,class:e.normalizeClass(["px-4 py-2 text-sm font-medium text-white bg-primary rounded-lg hover:bg-primary/90 transition-colors",(f=r.ui)==null?void 0:f.retryButton]),onClick:l},e.toDisplayString(r.retryText),3)):e.createCommentVNode("",!0)],2)]}):e.renderSlot(u.$slots,"default",{key:0})}}),cr={install(r,t){if(!t.endpoints||!t.getAuthToken){console.warn("[restify-ai] Plugin requires endpoints and getAuthToken options.");return}const n={endpoints:t.endpoints,baseUrl:t.baseUrl,getAuthToken:t.getAuthToken,getCustomHeaders:t.getCustomHeaders,buildRequest:t.buildRequest,parseStreamContent:t.parseStreamContent,requestInterceptor:t.requestInterceptor,responseInterceptor:t.responseInterceptor,retry:t.retry,translate:t.translate,can:t.can,labels:{...Bt,...t.labels},mentionProviders:t.mentionProviders,suggestionProviders:t.suggestionProviders,defaultSuggestions:t.defaultSuggestions,theme:t.theme,chatHistoryLimit:t.chatHistoryLimit,maxAttachments:t.maxAttachments,maxFileSize:t.maxFileSize,acceptedFileTypes:t.acceptedFileTypes,chatHistoryKey:t.chatHistoryKey,drawerStateKey:t.drawerStateKey,keyboardShortcut:t.keyboardShortcut,enableSupportMode:t.enableSupportMode,useQuota:t.useQuota,canToggle:t.canToggle,assistantAvatar:t.assistantAvatar,userAvatar:t.userAvatar,onQuotaFetched:t.onQuotaFetched,onError:t.onError,onMessageSent:t.onMessageSent,onResponseReceived:t.onResponseReceived,onDrawerToggle:t.onDrawerToggle,onNewChat:t.onNewChat,onStreamStart:t.onStreamStart,onStreamEnd:t.onStreamEnd,onStreamChunk:t.onStreamChunk,beforeSend:t.beforeSend,afterResponse:t.afterResponse,onFileUploadStart:t.onFileUploadStart,onFileUploadProgress:t.onFileUploadProgress,onFileUploadComplete:t.onFileUploadComplete,onFileUploadError:t.onFileUploadError};ln(n),r.provide("restify-ai-config",n)}};R.AiAvatar=tr,R.AiChatDrawer=Mi,R.AiEmptyState=ir,R.ChatInput=ar,R.ChatMessage=sr,R.ChatMessageActions=rr,R.ChatRoles=Re,R.ErrorBoundary=Bi,R.MentionList=nr,R.RestifyAiPlugin=cr,R.UserAvatar=Ys,R.default=cr,R.defaultLabels=Bt,R.formatFileSize=lt,R.formatMentionsForApi=bn,R.getConfigValue=ke,R.getLabel=te,R.getRestifyAiConfig=K,R.getRestifyAiConfigOrThrow=Br,R.getSuggestionsForPath=Xn,R.groupMentionsByType=wn,R.isConfigured=Nt,R.isImageFile=it,R.registerSuggestionProvider=as,R.setRestifyAiConfig=ln,R.useAiContext=Yt,R.useAiDrawerShortcut=us,R.useAiSuggestions=Xt,R.useChatErrorHandling=ns,R.useChatMarkdown=Zn,R.useChatScroll=ts,R.useKeyboardShortcut=Jn,R.useMentionParsing=vr,R.usePageAiContext=is,R.useRestifyAiStore=Ae,Object.defineProperties(R,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|