1import{u as he,j as r,B as H,d as Z}from"./index-DwG2mSgM.js";import{r as u}from"./react-CDlIlGS0.js";import{e as R,F as fe,_ as ge,C as me,r as J,f as ve,h as xe,j as ye,b as be,d as ke}from"./firebase-Csxny2TR.js";/** 2 * @license 3 * Copyright 2017 Google LLC 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */const we="type.googleapis.com/google.protobuf.Int64Value",Se="type.googleapis.com/google.protobuf.UInt64Value";function ee(e,n){const i={};for(const o in e)e.hasOwnProperty(o)&&(i[o]=n(e[o]));return i}function _(e){if(e==null)return null;if(e instanceof Number&&(e=e.valueOf()),typeof e=="number"&&isFinite(e)||e===!0||e===!1||Object.prototype.toString.call(e)==="[object String]")return e;if(e instanceof Date)return e.toISOString();if(Array.isArray(e))return e.map(n=>_(n));if(typeof e=="function"||typeof e=="object")return ee(e,n=>_(n));throw new Error("Data cannot be encoded in JSON: "+e)}function E(e){if(e==null)return e;if(e["@type"])switch(e["@type"]){case we:case Se:{const n=Number(e.value);if(isNaN(n))throw new Error("Data cannot be decoded from JSON: "+e);return n}default:throw new Error("Data cannot be decoded from JSON: "+e)}return Array.isArray(e)?e.map(n=>E(n)):typeof e=="function"||typeof e=="object"?ee(e,n=>E(n)):e}/** 17 * @license 18 * Copyright 2020 Google LLC 19 * 20 * Licensed under the Apache License, Version 2.0 (the "License"); 21 * you may not use this file except in compliance with the License. 22 * You may obtain a copy of the License at 23 * 24 * http://www.apache.org/licenses/LICENSE-2.0 25 * 26 * Unless required by applicable law or agreed to in writing, software 27 * distributed under the License is distributed on an "AS IS" BASIS, 28 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 29 * See the License for the specific language governing permissions and 30 * limitations under the License. 31 */const D="functions";/** 32 * @license 33 * Copyright 2017 Google LLC 34 * 35 * Licensed under the Apache License, Version 2.0 (the "License"); 36 * you may not use this file except in compliance with the License. 37 * You may obtain a copy of the License at 38 * 39 * http://www.apache.org/licenses/LICENSE-2.0 40 * 41 * Unless required by applicable law or agreed to in writing, software 42 * distributed under the License is distributed on an "AS IS" BASIS, 43 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 44 * See the License for the specific language governing permissions and 45 * limitations under the License. 46 */const Y={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"};class S extends fe{constructor(n,i,o){super(`${D}/${n}`,i||""),this.details=o}}function Ie(e){if(e>=200&&e<300)return"ok";switch(e){case 0:return"internal";case 400:return"invalid-argument";case 401:return"unauthenticated";case 403:return"permission-denied";case 404:return"not-found";case 409:return"aborted";case 429:return"resource-exhausted";case 499:return"cancelled";case 500:return"internal";case 501:return"unimplemented";case 503:return"unavailable";case 504:return"deadline-exceeded"}return"unknown"}function Te(e,n){let i=Ie(e),o=i,a;try{const l=n&&n.error;if(l){const s=l.status;if(typeof s=="string"){if(!Y[s])return new S("internal","internal");i=Y[s],o=s}const c=l.message;typeof c=="string"&&(o=c),a=l.details,a!==void 0&&(a=E(a))}}catch{}return i==="ok"?null:new S(i,o,a)}/** 47 * @license 48 * Copyright 2017 Google LLC 49 * 50 * Licensed under the Apache License, Version 2.0 (the "License");
51 * you may not use this file except in compliance with the License. 52 * You may obtain a copy of the License at 53 * 54 * http://www.apache.org/licenses/LICENSE-2.0 55 * 56 * Unless required by applicable law or agreed to in writing, software 57 * distributed under the License is distributed on an "AS IS" BASIS, 58 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 59 * See the License for the specific language governing permissions and 60 * limitations under the License. 61 */class je{constructor(n,i,o){this.auth=null,this.messaging=null,this.appCheck=null,this.auth=n.getImmediate({optional:!0}),this.messaging=i.getImmediate({optional:!0}),this.auth||n.get().then(a=>this.auth=a,()=>{}),this.messaging||i.get().then(a=>this.messaging=a,()=>{}),this.appCheck||o.get().then(a=>this.appCheck=a,()=>{})}async getAuthToken(){if(this.auth)try{const n=await this.auth.getToken();return n==null?void 0:n.accessToken}catch{return}}async getMessagingToken(){if(!(!this.messaging||!("Notification"in self)||Notification.permission!=="granted"))try{return await this.messaging.getToken()}catch{return}}
61async getAppCheckToken(n){if(this.appCheck){const i=n?await this.appCheck.getLimitedUseToken():await this.appCheck.getToken();return i.error?null:i.token}return null}async getContext(n){const i=await this.getAuthToken(),o=await this.getMessagingToken(),a=await this.getAppCheckToken(n);return{authToken:i,messagingToken:o,appCheckToken:a}}}/** 62 * @license 63 * Copyright 2017 Google LLC 64 * 65 * Licensed under the Apache License, Version 2.0 (the "License"); 66 * you may not use this file except in compliance with the License. 67 * You may obtain a copy of the License at 68 * 69 * http://www.apache.org/licenses/LICENSE-2.0 70 * 71 * Unless required by applicable law or agreed to in writing, software 72 * distributed under the License is distributed on an "AS IS" BASIS, 73 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 74 * See the License for the specific language governing permissions and 75 * limitations under the License. 76 */const P="us-central1";function Ce(e){let n=null;return{promise:new Promise((i,o)=>{n=setTimeout(()=>{o(new S("deadline-exceeded","deadline-exceeded"))},e)}),cancel:()=>{n&&clearTimeout(n)}}}class Ee{constructor(n,i,o,a,l=P,s){this.app=n,this.fetchImpl=s,this.emulatorOrigin=null,this.contextProvider=new je(i,o,a),this.cancelAllRequests=new Promise(c=>{this.deleteService=()=>Promise.resolve(c())});try{const c=new URL(l);this.customDomain=c.origin+(c.pathname==="/"?"":c.pathname),this.region=P}catch{this.customDomain=null,this.region=l}}_delete(){return this.deleteService()}_url(n){const i=this.app.options.projectId;return this.emulatorOrigin!==null?`${this.emulatorOrigin}/${i}/${this.region}/${n}`:this.customDomain!==null?`${this.customDomain}/${n}`:`https://${this.region}-${i}.cloudfunctions.net/${n}`}}function Ae(e,n,i){e.emulatorOrigin=`http://${n}:${i}`}function Ne(e,n,i){return o=>_e(e,n,o,{})}async function Oe(e,n,i,o){i["Content-Type"]="application/json";let a;try{a=await o(e,{method:"POST",body:JSON.stringify(n),headers:i})}catch{return{status:0,json:null}}let l=null;try{l=await a.json()}catch{}return{status:a.status,json:l}}function _e(e,n,i,o){const a=e._url(n);return Pe(e,a,i,o)}async function Pe(e,n,i,o){i=_(i);const a={data:i},l={},s=await e.contextProvider.getContext(o.limitedUseAppCheckTokens);s.authToken&&(l.Authorization="Bearer "+s.authToken),s.messagingToken&&(l["Firebase-Instance-ID-Token"]=s.messagingToken),s.appCheckToken!==null&&(l["X-Firebase-AppCheck"]=s.appCheckToken);const c=o.timeout||7e4,g=Ce(c),m=await Promise.race([Oe(n,a,l,e.fetchImpl),g.promise,e.cancelAllRequests]);if(g.cancel(),!m)throw new S("cancelled","Firebase Functions instance was deleted.");const v=Te(m.status,m.json);if(v)throw v;if(!m.json)throw new S("internal","Response is not valid JSON object.");let x=m.json.data;if(typeof x>"u"&&(x=m.json.result),typeof x>"u")throw new S("internal","Response is missing data field.");return{data:E(x)}}const X="@firebase/functions",K="0.11.8";/** 77 * @license 78 * Copyright 2019 Google LLC 79 * 80 * Licensed under the Apache License, Version 2.0 (the "License"); 81 * you may not use this file except in compliance with the License. 82 * You may obtain a copy of the License at 83 * 84 * http://www.apache.org/licenses/LICENSE-2.0 85 * 86 * Unless required by applicable law or agreed to in writing, software 87 * distributed under the License is distributed on an "AS IS" BASIS, 88 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 89 * See the License for the specific language governing permissions and 90 * limitations under the License. 91 */const Re="auth-internal",De="app-check-internal",ze="messaging-internal";function Fe(e,n){const i=(o,{instanceIdentifier:a})=>{const l=o.getProvider("app").getImmediate(),s=o.getProvider(Re),c=o.getProvider(ze),g=o.getProvider(De);return new Ee(l,s,c,g,a,e)};ge(new me(D,i,"PUBLIC").setMultipleInstances(!0)),J(X,K,n),J(X,K,"esm2017")}/** 92 * @license 93 * Copyright 2020 Google LLC 94 * 95 * Licensed under the Apache License, Version 2.0 (the "License"); 96 * you may not use this file except in compliance with the License. 97 * You may obtain a copy of the License at 98 * 99 * http://www.apache.org/licenses/LICENSE-2.0 100 * 101 * Unless required by applicable law or agreed to in writing, softw
101are 102 * distributed under the License is distributed on an "AS IS" BASIS, 103 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 104 * See the License for the specific language governing permissions and 105 * limitations under the License. 106 */function Ue(e=ye(),n=P){const o=ve(R(e),D).getImmediate({identifier:n}),a=xe("functions");return a&&Le(o,...a),o}function Le(e,n,i){Ae(R(e),n,i)}function te(e,n,i){return Ne(R(e),n)}Fe(fetch.bind(self));const ne=Ue(Z.app,"europe-west1"),Ve=te(ne,"requestVoteCode"),Q=te(ne,"castVote");function Me({song:e,position:n}){if(!e.previousRank)return null;const i=e.previousRank-n;return i>0?r.jsxs("span",{style:{color:"#4CAF50",fontSize:10,fontWeight:700},children:["â²",i]}):i<0?r.jsxs("span",{style:{color:"#f44336",fontSize:10,fontWeight:700},children:["â¼",Math.abs(i)]}):r.jsx("span",{style:{color:"var(--text-muted)",fontSize:10},children:"â"})}function qe(){const{config:e,stop:n,playEpisode:i,playerState:o,mode:a,episodeMeta:l}=he(),[s,c]=u.useState(null),[g,m]=u.useState(null),[v,x]=u.useState(null),[z,F]=u.useState("email"),[k,re]=u.useState(""),[T,A]=u.useState(""),[U,L]=u.useState(!1),[y,j]=u.useState(!1),[C,w]=u.useState(null),[ie,V]=u.useState(!1),[M,oe]=u.useState(new Set),[$,W]=u.useState(null),N=t=>oe(p=>new Set(p).add(t));function se(t){M.has(t.songId)||$||(ie?ce(t):G(t))}function G(t){x(t),F("email"),A(""),L(!1),w(null)}async function ae(){if(!y){j(!0),w(null);try{await Ve({email:k}),F("code")}catch(t){w((t==null?void 0:t.message)??"No se pudo enviar el código.")}finally{j(!1)}}}async function le(){if(!(y||!v||!s)){j(!0),w(null);try{await Q({weekId:s.id,songId:v.songId,email:k,code:T,marketingOptIn:U}),N(v.songId),V(!0),x(null)}catch(t){w((t==null?void 0:t.message)??"No se pudo registrar el voto.")}finally{j(!1)}}}async function ce(t){if(s){W(t.songId);try{await Q({weekId:s.id,songId:t.songId,email:k,code:T,marketingOptIn:!1}),N(t.songId)}catch(p){const d=(p==null?void 0:p.message)??"";d.includes("Ya has votado")?N(t.songId):(V(!1),A(""),G(t),w(d||"Tu sesión ha caducado, vuelve a validar tu email."))}finally{W(null)}}}u.useEffect(()=>{(a==="live"||o==="idle")&&m(null)},[a,o]),u.useEffect(()=>{if(!g)return;const t=s==null?void 0:s.songs.find(p=>p.songId===g);t&&(l==null?void 0:l.title)!==`${t.artist} â ${t.title}`&&m(null)},[l,g,s]);function de(t){if(t.previewUrl){if(g===t.songId){n(),m(null);return}i(t.previewUrl,{title:`${t.artist} â ${t.title}`,programName:"TOP 30 · Preview",artUri:t.coverUrl??null}),m(t.songId)}}const q=t=>g===t&&(o==="loading"||o==="buffering"),ue=t=>g===t&&o==="playing_stream";u.useEffect(()=>{const t=e.top30CurrentWeek;return t?be(ke(Z,"top30",t),d=>{if(!d.exists())return;const b=d.data();c({id:d.id,weekLabel:b.week_label??d.id,published:b.published??!1,votingOpen:b.voting_open??!1,songs:(b.songs??[]).map(h=>({songId:h.song_id,rank:h.rank,artist:h.artist,title:h.title,coverUrl:h.cover_url,previewUrl:h.preview_url,previousRank:h.previous_rank,weeksOnChart:h.weeks_on_chart,votesOverride:h.votes_override,locked:h.locked})),voteCounts:b.vote_counts??{}})}):void 0},[e.top30CurrentWeek]);const pe=s?[...s.songs].sort((t,p)=>{const d=(t.votesOverride??0)+(s.voteCounts[t.songId]??0);return(p.votesOverride??0)+(s.voteCounts[p.songId]??0)-d}):[];return r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"page-hero",children:r.jsxs("div",{className:"container",children:[r.jsx("p",{className:"section-label",children:"Ranking semanal"}),r.jsx("img",{loading:"lazy",decoding:"async",src:"https://gozadera.es/uploads/images/top30-logo.png",alt:"TOP 30 Gozadera",style:{display:"block",maxWidth:320,width:"100%",height:"auto",marginTop:4}}),r.jsx("h1",{style:{position:"absolute",left:-9999,top:"auto",width:1,height:1,overflow:"hidden"},children:"TOP 30 Gozadera"}),s&&r.jsxs("p",{style:{color:"var(--text-muted)",fontSize:14,marginTop:6,fontWeight:600},children:[s.weekLabel,s.votingOpen&&r.jsx("span",{style:{marginLeft:12,color:"#4CAF50"},children:"· Votaciones abiertas"})]})]})}),r.jsx("div",{className:"container",style:{padding:"16px 28px 0"},children:r.jsx(H,{zone:"top30",format:"leaderboard"})}),r.jsxs("div",{className:"container",style:{padding:"24px 28px 40px"},children:[!s&&r.jsx("p",{style:{color:"var(--text-muted)",fontWeight:600},children:"Cargando TOP30..."}),r.jsx("div",{style:{display:"flex",flexDirection:"column",gap:2},children:pe.map((t,p)=>{const d=p+1,b=d===10||d===20,h=(t.votesOverride??0)+(s.voteCounts[t.songId]??0),B=d<=3;return r.jsxs(r.Fragment,{children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,padding:"14px 0",borderBottom:"1px solid var(--border)"},children:[r.jsxs("div",{style:{width:40,textAlign:"center",flexShrink:0},children:[r.jsx("div",{style:{fontWeight:900,fontSize:B?24:17,color:B?"var(--accent)":"var(--text-muted)",lineHeight:1},children:d}),r.jsx("div",{style:{marginTop:3},children:r.jsx(Me,{song:t,position:d})})]}),r.jsxs("div",{style:{position:"relative",width:52,height:52,flexShrink:0},children:[t.coverUrl?r.jsx("img",{loading:"lazy",decoding:"async",src:t.coverUrl,alt:t.title,style:{width:52,height:52,borderRadius:8,objectFit:"cover",display:"block"}}):r.jsx("div",{style:{width:52,height:52,borderRadius:8,background:"var(--bg-card)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:22,border:"1px solid var(--border)"},children:"âª"}),t.previewUrl&&(()=>{const f=ue(t.songId)||q(t.songId),I=q(t.songId);return r.jsx("button",{onClick:()=>de(t),"aria-label":f?"Pausar":"Escuchar preview",style:{position:"absolute",inset:0,width:"100%",height:"100%",borderRadius:8,border:"none",cursor:"pointer",background:f?"rgba(0,0,0,0.55)":"rgba(0,0,0,0.35)",color:"#fff",fontSize:20,fontWeight:700,display:"flex",alignItems:"center",justifyContent:"center",opacity:f?1:.85,transition:"opacity 0.15s, background 0.15s"},onMouseEnter:O=>{O.currentTarget.style.opacity="1"},onMouseLeave:O=>{f||(O.currentTarget.style.opacity="0.85")},children:I?"â³":f?"â¸":"â¶"})})()]}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsx("p",{style:{fontWeight:700,color:"var(--text)",fontSize:15,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t.title}),r.jsx("p",{style:{color:"var(--text-muted)",fontSize:13,fontWeight:600,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginTop:2},children:t.artist}),t.weeksOnChart&&t.weeksOnChart>1&&r.jsxs("p",{style:{fontSize:11,color:"var(--text-muted)",marginTop:3},children:[t.weeksOnChart," semanas"]})]}),r.jsxs("div",{style:{flexShrink:0,textAlign:"right",minWidth:80},children:[h>0&&r.jsxs("p",{style:{fontSize:11,color:"var(--text-muted)",fontWeight:600,marginBottom:6}
106,children:[h.toLocaleString()," votos"]}),s.votingOpen&&(()=>{const f=M.has(t.songId),I=$===t.songId;return r.jsx("button",{onClick:()=>se(t),disabled:f||I,style:{padding:"6px 14px",borderRadius:999,fontSize:12,fontWeight:700,background:f?"rgba(76,175,80,0.15)":"var(--accent-muted)",color:f?"#4CAF50":"var(--accent)",border:`1px solid ${f?"rgba(76,175,80,0.35)":"var(--accent-border)"}`,cursor:f?"default":I?"wait":"pointer",transition:"opacity 0.15s"},children:f?"â Votada":I?"â¦":"⥠Votar"})})()]})]},t.songId),b&&r.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"16px 0"},children:r.jsx(H,{zone:"top30",format:"robapaginas"})})]})})})]}),v&&r.jsx("div",{role:"dialog","aria-modal":"true",style:{position:"fixed",inset:0,background:"rgba(0,0,0,.7)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:16},onClick:()=>x(null),children:r.jsx("div",{onClick:t=>t.stopPropagation(),style:{background:"var(--bg-card)",border:"1px solid var(--border)",borderRadius:16,padding:24,width:"min(420px,92vw)"},children:z==="email"?r.jsxs(r.Fragment,{children:[r.jsxs("h3",{style:{marginTop:0},children:["Vota a ",v.title]}),r.jsx("p",{style:{color:"var(--text-muted)",fontSize:14},children:"Valida tu email una vez y podrás votar todas las canciones que quieras con un toque. Te enviaremos un código."}),r.jsx("input",{type:"email",inputMode:"email",placeholder:"[email protected]",value:k,onChange:t=>re(t.target.value),style:{width:"100%",padding:12,margin:"12px 0",borderRadius:8,border:"1px solid var(--border)",background:"var(--bg)",color:"inherit"}}),r.jsxs("label",{style:{display:"flex",gap:8,fontSize:13,color:"var(--text-muted)",alignItems:"flex-start"},children:[r.jsx("input",{type:"checkbox",checked:U,onChange:t=>L(t.target.checked)}),r.jsx("span",{children:"Quiero recibir promociones, sorteos y novedades de Gozadera FM por email. (Opcional)"})]}),r.jsxs("p",{style:{fontSize:11,color:"var(--text-muted)",margin:"10px 0"},children:["Usamos tu email solo para validar que votas una vez. Al votar aceptas las ",r.jsx("a",{href:"/legal/bases-top30.html",target:"_blank",rel:"noreferrer",children:"bases"})," y la ",r.jsx("a",{href:"/legal/privacidad-top30.html",target:"_blank",rel:"noreferrer",children:"polÃtica de privacidad"}),". Solo te escribiremos si marcas la casilla, y podrás darte de baja cuando quieras."]}),C&&r.jsx("p",{style:{color:"#ff6b6b",fontSize:13},children:C}),r.jsx("button",{disabled:y||!k,onClick:ae,style:{padding:"10px 18px",borderRadius:8,border:"none",cursor:y?"wait":"pointer",fontWeight:700,width:"100%"},children:y?"Enviandoâ¦":"Enviar código"})]}):r.jsxs(r.Fragment,{children:[r.jsx("h3",{style:{marginTop:0},children:"Introduce el código"}),r.jsxs("p",{style:{color:"var(--text-muted)",fontSize:14},children:["Te hemos enviado un código de 6 dÃgitos a ",k,"."]}),r.jsx("input",{inputMode:"numeric",maxLength:6,placeholder:"______",value:T,onChange:t=>A(t.target.value.replace(/\D/g,"")),style:{width:"100%",padding:12,margin:"12px 0",borderRadius:8,letterSpacing:8,textAlign:"center",fontSize:22,border:"1px solid var(--border)",background:"var(--bg)",color:"inherit"}}),C&&r.jsx("p",{style:{color:"#ff6b6b",fontSize:13},children:C}),r.jsx("button",{disabled:y||T.length!==6,onClick:le,style:{padding:"10px 18px",borderRadius:8,border:"none",cursor:y?"wait":"pointer",fontWeight:700,width:"100%"},children:y?"Validandoâ¦":"Confirmar voto"})]})})})]})}export{qe 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.