import{_ as x,R as C,O as I,W as g,E as p,I as d}from"./v_7_4_3_17_17ffe662-3f12-45a2-ae5d-997b41d0d61b11.js";import{r as w,j as m}from"./v_7_4_3_17_17ffe662-3f12-45a2-ae5d-997b41d0d61b.js";import{u as f,a as h}from"./v_7_4_3_17_17ffe662-3f12-45a2-ae5d-997b41d0d61b20.js";import{c as _}from"./v_7_4_3_17_17ffe662-3f12-45a2-ae5d-997b41d0d61b8.js";const E=w.lazy(() => __vitePreload(()=>import(chrome.runtime.getURL("content/assets/js/v_7_4_3_17_17ffe662-3f12-45a2-ae5d-997b41d0d61b57.js")),[]));function D({id:t,userID:n,viwerModel:e}){return m.jsx(w.Suspense,{fallback:m.jsx(m.Fragment,{}),children:m.jsx(E,{id:t,userID:n,viwerModel:e})})}const S={useModal:null,useModalOptions:null};function F({useModal:t,useModalOptions:n}){S.useModal=t,S.useModalOptions=n}const L=()=>_((t,n)=>({renderView:"list",setRenderView:e=>t({renderView:e}),userID:"",viwerModel:"modal",note:{id:NaN,userID:"",text:"",base64:""},setNote:(e,o)=>t(s=>({note:Object.freeze({...s.note,[e]:o})}))})),R=_()((t,n)=>({container:{},getContainer:e=>{const{container:o}=n();if(o[e])return o[e];{const s=L();return t(a=>({container:{...a.container,[e]:s}})),s}},deleteContainer:e=>t(o=>{const s={...o.container};return delete s[e],{container:s}})})),y=async()=>{const t=await C("notes")||[];N.setState({notes:t})},M=I({createNote:t=>{N.setState(n=>({notes:[t.data,...n.notes]}))},editNote:t=>{N.setState(n=>({notes:n.notes.map(e=>e.id===t.data.id?t.data:e)}))},deleteNote:t=>{N.getState().deleteNote(t.data,!0)},notesBackup:t=>{y()}});chrome.runtime.onMessage.addListener(M);const N=_((t,n)=>({notes:[],createNote:(e,o=!1)=>{const{notes:s}=n(),{language:a}=f.getState(),{session:c}=h.getState(),{openRendertype:i}=S.useModal.getState(),{getContainer:l}=R.getState(),{note:r,setRenderView:u}=l(e).getState();if(r.text.length<3&&r.base64.length===0){d({type:"Error",message:a.adicioneAnotacaoCom3,position:"top-right"});return}if(!c.is_premium&&s.length>=3){i("user_free");return}!o&&g("notes",[r,...s]),p({stopPropag:o,action:"createNote",waitForResponse:!1,data:r}),d({type:"Success",message:a.note_add,position:"top-right"}),u("list"),t({notes:[r,...s]})},createNoteSocket:(e,o,s)=>{const{notes:a}=n(),{language:c}=f.getState(),{session:i}=h.getState(),{openRendertype:l}=S.useModal.getState(),r={id:Date.now(),userID:e,text:o,base64:s};if(!i.is_premium&&a.length>=3){l("user_free");return}g("notes",[r,...a]),p({stopPropag:!1,action:"createNote",waitForResponse:!1,data:r}),d({type:"Success",message:c.note_add+" via API",position:"top-right"}),t({notes:[r,...a]})},editNote:(e,o=!1)=>{const{notes:s}=n(),{language:a}=f.getState(),{getContainer:c}=R.getState(),{note:i,setRenderView:l}=c(e).getState();if(i.text.length<3&&i.base64.length===0){d({type:"Error",message:a.adicioneAnotacaoCom3,position:"top-right"});return}const r=s.map(u=>u.id===i.id?i:u);!o&&g("notes",r),p({stopPropag:o,action:"editNote",waitForResponse:!1,data:i}),d({type:"Success",message:a.note_add,position:"top-right"}),l("list"),t({notes:r})},deleteNote:(e,o=!1)=>{const{notes:s}=n(),{language:a}=f.getState(),c=s.filter(i=>i.id!==e);!o&&g("notes",c),p({stopPropag:o,action:"deleteNote",waitForResponse:!1,data:e}),d({type:"Success",message:a.note_delete,position:"top-right"}),t({notes:c})},getNotes:e=>{const{notes:o}=n();return o.filter(s=>s.userID===e)}}));y();export{D as N,N as a,S as b,F as s,R as u};
