PageSourceSearch

https://www.djclub.pro/_astro/ContestFinalizeModal.astro_astro_type_script_index_0_lang.5Mrqi8Bb.js

js djclub.pro collected 2026-10-04 20:23:21 UTC 5,521 bytes, 1 lines download raw bytes

1(function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{};e.SENTRY_RELEASE={id:`569cce8a29e15fc435f8f927b138254c8678c8a2`};var t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`b945b6f9-7985-4b30-9e15-e989fd1f292c`,e._sentryDebugIdIdentifier=`sentry-dbid-b945b6f9-7985-4b30-9e15-e989fd1f292c`)}catch{}})();import{t as e}from"./supabase.DfoaOUcG.js?dpl=dpl_4JkTYz25ye5TxcdU9jwo7MUexnCE";(function(){let t=document.getElementById(`contest-finalize-modal`);if(!t)return;let n=document.getElementById(`cfm-subtitle`),r=document.getElementById(`cfm-loading`),i=document.getElementById(`cfm-body`),a=document.getElementById(`cfm-winners-preview`),o=document.getElementById(`cfm-categories`),s=document.getElementById(`cfm-save`),c=document.getElementById(`cfm-category-template`),l=document.getElementById(`cfm-participant-template`),u=null;function d(){t.contains(document.activeElement)&&document.activeElement?.blur?.(),t.classList.remove(`is-open`),t.setAttribute(`inert`,``)}function f(e,r){u=e,n&&(n.textContent=r?`"${r}" — selecciona los ganadores de entre los inscritos.`:`Selecciona los ganadores de entre los inscritos.`),t.classList.add(`is-open`),t.removeAttribute(`inert`),m(e)}function p(){!a||!o||(a.innerHTML=``,o.querySelectorAll(`[data-cfm-category]`).forEach(e=>{let t=e.querySelector(`[data-cfm-category-title]`)?.textContent||``,n=[...e.querySelectorAll(`input[data-cfm-checkbox]:checked`)];if(!n.length)return;let r=document.createElement(`div`);r.className=`cfm-winner-group`;let i=document.createElement(`p`);i.className=`cfm-winner-group-label`,i.textContent=t;let o=document.createElement(`div`);o.className=`cfm-winner-chips`,n.forEach(e=>{let t=e.closest(`[data-cfm-participant]`)?.querySelector(`[data-cfm-name]`)?.textContent||``,n=document.createElement(`span`);n.className=`cfm-winner-chip`,n.appendChild(document.createTextNode(t)),o.appendChild(n)}),r.appendChild(i),r.appendChild(o),a.appendChild(r)}))}async function m(e){if(!(!r||!i||!o)){r.style.display=``,i.style.display=`none`,o.innerHTML=``;try{let t=await fetch(`/api/admin/opportunities-review/contest-finalize-data?opportunityId=${encodeURIComponent(e)}`),n=await t.json();if(!t.ok)throw Error(n.error||`Error cargando inscritos`);let a=n.participants||[],s=n.categories||[],u=new Map;if(s.length===0)u.set(`all`,{title:`TODOS`,participants:a});else{s.forEach(e=>u.set(e.id,{title:(e.title||`Categoría`).toUpperCase(),participants:[]}));let e=[];a.forEach(t=>{let n=t.section_id?u.get(t.section_id):null;n?n.participants.push(t):e.push(t)}),e.length&&u.set(`uncategorized`,{title:`SIN CATEGORÍA`,participants:e})}u.forEach((e,t)=>{if(!e.participants.length||!c||!l)return;let n=c.content.cloneNode(!0),r=n.querySelector(`[data-cfm-category]`);r.dataset.sectionId=t===`all`||t===`uncategorized`?``:t;let i=e.participants.length===1?`1 inscrito`:`${e.participants.length} inscritos`;n.querySelector(`[data-cfm-category-title]`).textContent=`${e.title} · ${i}`;let a=n.querySelector(`[data-cfm-participant-list]`);e.participants.slice().sort((e,t)=>(t.votes_count||0)-(e.votes_count||0)).forEach(e=>{let t=l.content.cloneNode(!0),n=t.querySelector(`[data-cfm-checkbox]`);n.value=e.id,n.checked=e.result_type===`winner`,n.addEventListener(`change`,p),t.querySelector(`[data-cfm-name]`).textContent=e.display_name,t.querySelector(`[data-cfm-votes]`).textContent=e.votes_count>0?`${e.votes_count} ${e.votes_count===1?`voto`:`votos`}`:``;let r=t.querySelector(`[data-cfm-avatar]`);if(r.dataset.initial=(e.display_name||`?`).charAt(0).toUpperCase(),e.avatar_url){let t=document.createElement(`img`);t.src=e.avatar_url,t.alt=``,t.loading=`lazy`,t.onerror=()=>t.remove(),r.appendChild(t)}a.appendChild(t)}),o.appendChild(n)}),p(),r.style.display=`none`,i.style.display=``}catch(e){r.textContent=`Error cargando inscritos: `+(e?.message||e)}}}s?.addEventListener(`click`,async()=>{if(!u||!o)return;let t=[],n=[];o.querySelectorAll(`[data-cfm-category]`).forEach(e=>{let r=e.dataset.sectionId||null;e.querySelectorAll(`input[data-cfm-checkbox]:checked`).forEach(e
1=>{t.push({participantId:e.value,sectionId:r}),n.push(e.closest(`[data-cfm-participant]`)?.querySelector(`[data-cfm-name]`)?.textContent?.trim()||``)})});let r=n.filter(Boolean).join(`, `),i=t.length===0?`No has marcado ningún ganador: el concurso se finalizará sin resultados. ¿Continuar?`:`Vas a finalizar el concurso con ${t.length} ${t.length===1?`ganador`:`ganadores`}${r?` (${r})`:``}. Se hará público de inmediato, se creará su acuerdo con los datos del concurso y, pasados unos minutos, se le avisará por correo. ¿Confirmas?`;if(!window.confirm(i))return;s.disabled=!0;let a=s.textContent;s.textContent=`Guardando…`;try{let{data:{session:n}}=await e.auth.getSession(),r=await fetch(`/api/admin/opportunities-review/finalize-contest`,{method:`POST`,headers:{"Content-Type":`application/json`,...n?.access_token?{Authorization:`Bearer ${n.access_token}`}:{}},body:JSON.stringify({opportunityId:u,winners:t})}),i=await r.json();if(!r.ok)throw Error(i.error||`Error guardando ganadores`);s.textContent=`✅ Guardado`,window.location.reload()}catch(e){alert(`Error guardando ganadores: `+(e?.message||e)),s.disabled=!1,s.textContent=a}}),t.querySelectorAll(`[data-cfm-close]`).forEach(e=>e.addEventListener(`click`,d)),document.addEventListener(`keydown`,e=>{e.key===`Escape`&&t.classList.contains(`is-open`)&&d()}),window.openContestFinalizeModal=f})();

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.