1import{r as n,b as x,j as e,C as K,p as Q,H as X,L as $}from"./index-DdG4Nupj.js";import{P as V}from"./PageHeader-B0p-yXpn.js";import{L as Y}from"./LazyImage-CzTfhM5t.js";import{B as y}from"./book-open-CYmllWIH.js";import{E as G}from"./external-link-D-qJK3Md.js";import"./arrow-left-BVnlRxMv.js";import"./search-IEkXToFY.js";const I="almanaque_intro_seen";function ne(){const[c,w]=n.useState(null),[m,_]=n.useState(0),[N,q]=n.useState(null),[z,T]=n.useState({}),[B,R]=n.useState({}),[M,k]=n.useState({}),[v,g]=n.useState({}),[L,S]=n.useState(null),[C,A]=n.useState(!1),[P,W]=n.useState(!localStorage.getItem(I)),u=n.useRef(null);n.useEffect(()=>{let a=!1;return x.entities.Almanaque.filter({is_active:!0}).then(s=>{const l=(s||[]).sort((d,r)=>(d.display_order||0)-(r.display_order||0)||new Date(d.created_date)-new Date(r.created_date));a||(w(l),F(l))}).catch(()=>!a&&w([])),()=>{a=!0}},[]),n.useEffect(()=>{Promise.all([x.auth.me().catch(()=>null),x.entities.AlmanaqueLike.filter({}).catch(()=>[])]).then(([a,s])=>{q(a);const l={},d={};(s||[]).forEach(r=>{l[r.almanaque_id]=(l[r.almanaque_id]||0)+1,a&&r.created_by_id===a.id&&(d[r.almanaque_id]=r.id)}),k(l),g(d)})},[]);const F=async a=>{const s=[...new Set((a||[]).map(o=>o.song_id).filter(Boolean))],l=[...new Set((a||[]).map(o=>o.lyrics_version_id).filter(Boolean))],d={},r={};await Promise.all([...s.map(o=>x.entities.Song.get(o).then(b=>{d[o]=b}).catch(()=>{})),...l.map(o=>x.entities.Song.filter({lyrics_version_id:o,is_official_narrative_version:!0}).then(b=>{b&&b[0]&&(r[o]=b[0])}).catch(()=>{}))]),T(d),R(r)},i=(c==null?void 0:c.length)||0,h=n.useCallback(()=>_(a=>Math.min(a+1,i-1)),[i]),p=n.useCallback(()=>_(a=>Math.max(a-1,0)),[]);n.useEffect(()=>{const a=s=>{s.key==="ArrowRight"&&h(),s.key==="ArrowLeft"&&p()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[h,p]);const U=a=>{u.current=a.touches[0].clientX},D=a=>{if(u.current===null)return;const s=a.changedTouches[0].clientX-u.current;Math.abs(s)>50&&(s<0?h():p()),u.current=null},t=c==null?void 0:c[m],f=t?B[t.lyrics_version_id]||z[t.song_id]:null,j=t?!!v[t.id]:!1,E=t&&M[t.id]||0,O=async()=>{if(!(!t||C)){if(!N){window.location.href="/login";return}A(!0);try{const a=v[t.id];if(a)await x.entities.AlmanaqueLike.delete(a),g(s=>{const l={...s};return delete l[t.id],l}),k(s=>({...s,[t.id]:Math.max((s[t.id]||1)-1,0)}));else{const s=await x.entities.AlmanaqueLike.create({almanaque_id:t.id,user_email:N.email});g(l=>({...l,[t.id]:s.id})),k(l=>({...l,[t.id]:(l[t.id]||0)+1}))}}catch{}A(!1)}},H=()=>{localStorage.setItem(I,"1"),W(!1)};return e.jsxs("div",{className:"min-h-screen bg-app-bg pb-[80px]",children:[e.jsx(V,{}),e.jsx("div",{className:"px-3 md:px-6 pt-3",style:{height:"calc(100dvh - 150px)"},children:e.jsxs("div",{className:"h-full flex flex-col max-w-md mx-auto",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2 flex-shrink-0",children:[e.jsx(y,{size:18,strokeWidth:3,className:"text-black"}),e.jsx("h2",{className:"font-black text-lg text-black",children:"ALMANAQUE"}),i>0&&e.jsxs("span",{className:"ml-auto px-1.5 py-0.5 border-[2px] border-black bg-app-header font-black text-[10px] text-white",children:[m+1,"/",i]})]}),e.jsxs("div",{className:"relative flex-1 min-h-0",onTouchStart:U,onTouchEnd:D,children:[i>1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:p,disabled:m===0,className:"absolute left-0 top-0 h-full w-1/4 z-20 disabled:hidden","aria-label":"Anterior"}),e.jsx("button",{onClick:h,disabled:m===i-1,className:"absolute right-0 top-0 h-full w-1/4 z-20 disabled:hidden","aria-label":"Próximo"})]}),i>1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:p,disabled:m===0,className:"absolute left-2 top-1/2 -translate-y-1/2 z-30 w-9 h-9 border-[3px] border-black bg-white flex items-center justify-center shadow-[3px_3px_0px_#000] disabled:opacity-30","aria-label":"Anterior",children:e.jsx(K,{size:20,strokeWidth:3})}),e.jsx("button",{onClick:h,disabled:m===i-1,className:"absolute right-2 top-1/2 -translate-y-1/2 z-30 w-9 h-9 border-[3px] border-black bg-white flex items-center justify-center shadow-[3px_3px_0px_#000] disabled:opacity-30","aria-label":"Próximo",children:e.jsx(Q,{size:20,strokeWidth:3})})]}),e.jsx("div",{className:"h-full bg-white border-[4px] border-black shadow-[6px_6px_0px_#000] overflow-y-auto no-scrollbar",children:c===null?e.jsx("div",{className:"h-full flex items-center justify-center",children:e.jsx("div",{className:"w-8 h-8 border-[4px] border-black border-t-app-header rounded-full animate-spin"})}):i===0?e.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center p-6",children:[e.jsx(y,{size:48,className:"text-black/20 mb-3"}),e.jsx("p",{className:"font-black text-sm text-black/50",children:"Nada no almanaque por enquanto"})]}):e.jsxs("div",{className:"p-5 space-y-4",children:[t.title&&e.jsxs("h3",{className:"font-black text-xl text-black italic",children:['"',t.title,'"']}),t.text&&e.jsx("p",{className:"text-sm md:text-base text-black/80 whitespace-pre-wrap leading-relaxed",children:t.text}),t.image_url&&e.jsx("button",{onClick:()=>S(t.image_url),className:"block w-full","aria-label":"Ampliar imagem",children:e.jsx(Y,{src:t.image_url,alt:t.title||"",className:"w-full border-[3px] border-black"})}),t.link_url&&e.jsxs("a",{href:t.link_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 px-3 py-2 border-[3px] border-black font-black text-xs text-black bg-app-cyan hover:translate-x-[1px] hover:translate-y-[1px] transition-all",children:[e.jsx(G,{size:14,strokeWidth:2.5}),t.link_text||"Saiba mais"]})]})})]}),t&&e.jsxs("div",{className:"flex items-center gap-2 mt-2 flex-shrink-0",children:[e.jsxs("button",{onClick:O,disabled:C,className:`flex items-center gap-1.5 px-3 py-2 border-[3px] border-black font-black text-xs shadow-[3px_3px_0px_#000] hover:translate-x-[1px] hover:translate-y-[1px] hover:shadow-none transition-all min-h-[40px] disabled:opacity-50 ${j?"bg-app-pink text-white":"bg-white text-black"}
1`,children:[e.jsx(X,{size:14,strokeWidth:3,fill:j?"#FFF":"none"}),j?"CURTIDO":"CURTIR",E>0&&e.jsxs("span",{children:["(",E,")"]})]}),f&&f.slug&&e.jsxs($,{to:`/player/${f.slug}`,title:"Ver ritmo oficial",className:"ml-auto flex items-center gap-1 px-2 py-1.5 border-[2px] border-black bg-app-cyan font-black text-[10px] text-black hover:translate-x-[1px] hover:translate-y-[1px] transition-all max-w-[65%]",children:[e.jsxs("span",{className:"truncate",children:["⪠",f.title]}),e.jsx("span",{className:"flex-shrink-0",children:"â"})]})]}),i>1&&e.jsx("p",{className:"text-center text-[10px] font-bold text-black/40 mt-2 flex-shrink-0",children:"Toque nas laterais ou arraste para navegar"})]})}),L&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",style:{backgroundColor:"rgba(0,0,0,0.92)"},onClick:()=>S(null),children:e.jsx("img",{src:L,alt:"",className:"max-w-full max-h-full border-[4px] border-white object-contain"})}),P&&c!==null&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-6",style:{backgroundColor:"rgba(0,0,0,0.8)"},children:e.jsxs("div",{className:"bg-white border-[4px] border-black shadow-[8px_8px_0px_#000] p-6 max-w-sm w-full text-center",children:[e.jsx("div",{className:"w-14 h-14 mx-auto rounded-full border-[4px] border-black bg-app-cyan flex items-center justify-center mb-4",children:e.jsx(y,{size:26,strokeWidth:3,color:"#000"})}),e.jsx("h2",{className:"font-black text-xl text-black",children:"ALMANAQUE"}),e.jsx("p",{className:"text-sm font-bold text-black/60 mt-2",children:"Almanaque são referências relacionadas a uma letra. Aqui você pode ver todas juntas."}),e.jsx("button",{onClick:H,className:"mt-5 w-full py-3 border-[4px] border-black font-black text-sm text-black bg-app-cyan hover:translate-x-[2px] hover:translate-y-[2px] transition-all min-h-[44px]",children:"ENTENDI"})]})})]})}export{ne as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.