import{I as o,$ as u,b$ as p}from"./index-c51caa49.js";const d=async e=>(await o.post("chats",{character_id:e})).data,h=async(e,{is_public:s,summary:t,summary_chat_id:a})=>(await o.patch(`chats/${e}`,{is_public:s,summary:t,summary_chat_id:a})).data,g=async e=>{await u.from("chats").delete().eq("id",e)},m=async e=>(await o.get(`/chats/${e}`)).data,l=async(e,s)=>await o.delete(`/chats/${e}/messages`,{data:{message_ids:s}}),_=async(e,s)=>await o.patch(`/chats/${e}/messages`,{message_ids:s}),y=async(e,s)=>{p(s,["message"]);const{message:t,is_bot:a,is_main:n,mid:r,is_retry:c}=s;return(await o.post(`/chats/${e}/messages`,{message:t,is_bot:a,is_main:n,mid:r,is_retry:c})).data},b=async(e,s,t)=>{p(t,["message"]);const{message:a,is_main:n,is_edited:r}=t;return(await o.patch(`/chats/${e}/messages/${s}`,{message:a,is_main:n,is_edited:r})).data},w=async(e,s,{reason:t,character_id:a,tag:n})=>(await o.post(`/chats/${e}/feedback/${s}`,{tag:n,reason:t,character_id:a})).data,C=(e,s)=>e?!!(e.api==="mock"||e.api==="nsfw"&&(s.messageQuotaCount||0)-(s.messageQuotaUsedCount||0)>0||e.api==="openai"&&(e.open_ai_mode==="api_key"&&s.openAIKey||e.open_ai_mode==="proxy"&&e.open_ai_reverse_proxy)||(e.api==="kobold"||e.api==="ooba")&&e.api_url):!1,f=(e,s="Anon",t="")=>e.replace(/{{char}}:/gi,"").replace(/{{user}}/gi,s).replace(/<user>/gi,s).replace(/{{bot}}/gi,t).replace(/{{char}}/gi,t).replace(/<bot>/gi,t).replace(/<START>/gi,""),$=()=>{let e="";const s="efabcd",t=Array.from({length:10},(a,n)=>n.toString());return e+=t.slice(0,6).join(""),e+=s.split("").join(""),e+=t.slice(6).join(""),e},i=$(),R=e=>{let s="";const t=function(a,n,r,c){return(a+n+r+c)%16};for(let a=0;a<e.length;a++){const n=e[a];if(n==="-"){s+=n;continue}const r=i.indexOf(n),c=t(r,a,1,6);s+=i[c]}return s},I={createChat:d,deleteChat:g,getChatById:m,createMessage:y,updateChat:h,updateMessage:b,deleteMessages:l,softDeleteMessages:_,createChatFeedback:w,readyToChat:C,formatChat:f,obscure:R};export{I as c,f};