import{_ as y,R as L,O as x,g as p,E as f,I as u}from"./v_7_4_2_28_54378c94-eda0-47d4-8f59-c666edac6a7111.js";import{r as R,j as N}from"./v_7_4_2_28_54378c94-eda0-47d4-8f59-c666edac6a71.js";import{u as m}from"./v_7_4_2_28_54378c94-eda0-47d4-8f59-c666edac6a7120.js";import{c as h}from"./v_7_4_2_28_54378c94-eda0-47d4-8f59-c666edac6a718.js";const C=R.lazy(() => __vitePreload(()=>import(chrome.runtime.getURL("content/assets/js/v_7_4_2_28_54378c94-eda0-47d4-8f59-c666edac6a7156.js")),[]));function z({id:t,userID:n,viwerModel:e}){return N.jsx(R.Suspense,{fallback:N.jsx(N.Fragment,{}),children:N.jsx(C,{id:t,userID:n,viwerModel:e})})}const d={useUserLogin:null,useModal:null,useModalOptions:null};function D({useUserLogin:t,useModal:n,useModalOptions:e}){d.useUserLogin=t,d.useModal=n,d.useModalOptions=e}const I=()=>h((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})}))})),_=h()((t,n)=>({container:{},getContainer:e=>{const{container:o}=n();if(o[e])return o[e];{const s=I();return t(a=>({container:{...a.container,[e]:s}})),s}},deleteContainer:e=>t(o=>{const s={...o.container};return delete s[e],{container:s}})})),w=async()=>{const t=await L("notes")||[];S.setState({notes:t})},E=x({createNote:t=>{S.setState(n=>({notes:[t.data,...n.notes]}))},editNote:t=>{S.setState(n=>({notes:n.notes.map(e=>e.id===t.data.id?t.data:e)}))},deleteNote:t=>{S.getState().deleteNote(t.data,!0)},notesBackup:t=>{w()}});chrome.runtime.onMessage.addListener(E);const S=h((t,n)=>({notes:[],createNote:(e,o=!1)=>{const{notes:s}=n(),{language:a}=m.getState(),{user:c}=d.useUserLogin.getState(),{openRendertype:i}=d.useModal.getState(),{getContainer:l}=_.getState(),{note:r,setRenderView:g}=l(e).getState();if(r.text.length<3&&r.base64.length===0){u({type:"Error",message:a.adicioneAnotacaoCom3,position:"top-right"});return}if(!c.estado&&s.length>=3){i("user_free");return}!o&&p("notes",[r,...s]),f({stopPropag:o,action:"createNote",waitForResponse:!1,data:r}),u({type:"Success",message:a.note_add,position:"top-right"}),g("list"),t({notes:[r,...s]})},createNoteSocket:(e,o,s)=>{const{notes:a}=n(),{language:c}=m.getState(),{user:i}=d.useUserLogin.getState(),{openRendertype:l}=d.useModal.getState(),r={id:Date.now(),userID:e,text:o,base64:s};if(!i.estado&&a.length>=3){l("user_free");return}p("notes",[r,...a]),f({stopPropag:!1,action:"createNote",waitForResponse:!1,data:r}),u({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}=m.getState(),{getContainer:c}=_.getState(),{note:i,setRenderView:l}=c(e).getState();if(i.text.length<3&&i.base64.length===0){u({type:"Error",message:a.adicioneAnotacaoCom3,position:"top-right"});return}const r=s.map(g=>g.id===i.id?i:g);!o&&p("notes",r),f({stopPropag:o,action:"editNote",waitForResponse:!1,data:i}),u({type:"Success",message:a.note_add,position:"top-right"}),l("list"),t({notes:r})},deleteNote:(e,o=!1)=>{const{notes:s}=n(),{language:a}=m.getState(),c=s.filter(i=>i.id!==e);!o&&p("notes",c),f({stopPropag:o,action:"deleteNote",waitForResponse:!1,data:e}),u({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)}}));w();export{z as N,S as a,d as b,D as s,_ as u};
