PageSourceSearch

https://loothing.xyz/assets/VoteResults-xwmRaWKC.js

js loothing.xyz collected 2026-10-02 02:12:32 UTC 6,862 bytes, 1 lines download raw bytes

1import{r as e,j as t}from"./react-vendor-BR2bEzcq.js";import{z as s}from"./axios-ClGXtqae.js";import{u as o,V as a}from"./VoteResultsDisplay-DmXPiP3s.js";import{l as i}from"./socket-BtQC6gv9.js";import{d as r,a5 as n,b as l,m as c,a2 as d,B as u,L as m,C as p,R as x}from"./index-CpSDEIFT.js";import{V as h}from"./VoteStatusBadge-DAgK6gvA.js";import{L as v}from"./loader-circle-D91B_GSQ.js";import{A as f}from"./arrow-left-BrJfR4cx.js";import{C as g}from"./clock-7p0Hl2bb.js";import{S as j}from"./share-2-BlQHCczL.js";import"./charts-D40XXgWa.js";import"./index-CPMAuWS8.js";import"./trophy-B30ncVk3.js";import"./vote-BSWsIZzN.js";import"./circle-check-REcAsX_P.js";function y({children:e}){return t.jsx("div",{className:"container mx-auto max-w-6xl px-4 py-6 lg:py-8",children:e})}const b=()=>{const{voteId:b}=n(),w=l(),{fetchResults:N,resultsData:k,isFetchingResults:R,resultsError:I}=o(),C="active"===k?.vote?.status,{ballotCount:V,isConnected:S,lastUpdate:E}=function(t,s=!0){const{user:o,selectedGuild:a}=r(),[n,l]=e.useState(null),[c,d]=e.useState(!1),[u,m]=e.useState(null),p=e.useRef(null);return e.useEffect(()=>{if(!(s&&t&&o&&a))return;const e=i(window.location.origin,{path:"/votes/socket.io",withCredentials:!0,reconnection:!0,reconnectionDelay:1e3,reconnectionAttempts:5});return p.current=e,e.on("connect",()=>{console.log("[WebSocket] Connected to vote monitoring"),d(!0),e.emit("monitor_vote",{voteId:t,userId:o.discordId,guildId:a.id})}),e.on("disconnect",()=>{console.log("[WebSocket] Disconnected from vote monitoring"),d(!1)}),e.on("monitoring_started",({voteId:e})=>{console.log(`[WebSocket] Monitoring started for vote ${e}`)}),e.on("ballot_count_update",({ballotCount:e,timestamp:t})=>{console.log(`[WebSocket] Ballot count updated: ${e}`),l(e),m(new Date(t))}),e.on("vote_status_changed",({status:e})=>{console.log(`[WebSocket] Vote status changed to: ${e}`),window.dispatchEvent(new CustomEvent("vote-status-changed",{detail:{voteId:t,status:e}}))}),e.on("results_updated",()=>{console.log("[WebSocket] Results updated"),window.dispatchEvent(new CustomEvent("vote-results-updated",{detail:{voteId:t}}))}),e.on("error",({message:e})=>{console.error("[WebSocket] Error:",e)}),()=>{p.current&&(p.current.emit("stop_monitoring",{voteId:t}),p.current.disconnect())}},[t,s,o,a]),{ballotCount:n,isConnected:c,lastUpdate:u}}(b,C),L=e.useRef(null);if(e.useEffect(()=>{b&&L.current!==b&&(L.current=b,N({voteId:b}).catch(e=>{console.error("[VoteResults] Failed to fetch results:",e)}))},[b]),e.useEffect(()=>{if(!C)return;const e=e=>{e.detail.voteId===b&&N({voteId:b}).catch(e=>{console.error("[VoteResults] Failed to refetch results:",e)})};return window.addEventListener("vote-results-updated",e),()=>window.removeEventListener("vote-results-updated",e)},[b,C]),R)return t.jsx(c.div,{initial:{opacity:0}
1,animate:{opacity:1},children:t.jsx(y,{children:t.jsx("div",{className:"flex items-center justify-center min-h-[50vh]",children:t.jsx(v,{className:"h-12 w-12 animate-spin text-gray-400"})})})});if(I){const e=403===I.response?.status,s=404===I.response?.status;return t.jsx(c.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{type:"spring",stiffness:400,damping:30},children:t.jsxs(y,{children:[t.jsx("div",{className:"mb-4 rounded-lg border border-red-700/50 bg-red-900/30 px-4 py-3 text-sm text-red-100",children:s?"Vote not found":e?d(I,"Results not available. Vote must be closed to view results."):`Failed to load results: ${I.message}`}),t.jsx(u,{variant:"outline",onClick:()=>w("/votes"),leftIcon:t.jsx(f,{className:"h-4 w-4"}),children:"Back to Votes"})]})})}return k?t.jsx(c.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.3},children:t.jsxs(y,{children:[t.jsxs(c.nav,{"aria-label":"Breadcrumb",initial:{opacity:0,x:-16},animate:{opacity:1,x:0},transition:{delay:.05,type:"spring",stiffness:400,damping:30},className:"mb-4 flex items-center gap-1 text-sm text-gray-400 flex-wrap",children:[t.jsx(m,{to:"/votes",className:"hover:text-(--theme-primary-color,#bb86fc) hover:underline",children:"Votes"}),t.jsx(p,{className:"h-4 w-4"}),t.jsx(m,{to:`/votes/${b}`,className:"hover:text-(--theme-primary-color,#bb86fc) hover:underline truncate max-w-[20rem]",children:k.vote?.title||"Vote"}),t.jsx(p,{className:"h-4 w-4"}),t.jsx("span",{className:"text-gray-200",children:"Results"})]}),t.jsxs(c.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{delay:.1,type:"spring",stiffness:400,damping:30},className:"mb-5 flex items-center gap-2 flex-wrap",children:[t.jsx(h,{status:k.vote?.status,size:"medium"}),C&&null!==V&&t.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-gray-600 px-2.5 py-1 text-sm text-gray-300",children:[t.jsx(g,{className:"h-3.5 w-3.5"}),V," ballots"]}),C&&S&&t.jsx("span",{className:"inline-flex items-center rounded-full border border-green-700/50 bg-green-900/30 px-2 py-0.5 text-xs font-medium text-green-200 animate-pulse",children:"Live"})]}),C&&t.jsxs("div",{className:"mb-5 rounded-lg border border-yellow-700/50 bg-yellow-900/30 px-3 py-2 text-sm text-yellow-100",children:[t.jsx("strong",{children:"⚠️ Live Results:"})," Voting is still in progress. These results will update as new ballots are submitted.",E&&` Last updated: ${E.toLocaleTimeString()}`]}),t.jsx(c.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{delay:.15,type:"spring",stiffness:400,damping:30},children:t.jsx(a,{voteData:k.vote,results:k.results,ballotCount:k.ballot_count})}),t.jsxs(c.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{delay:.2,type:"spring",stiffness:400,damping:30},className:"mt-6 flex flex-wrap gap-2",children:[t.jsx(u,{variant:"outline",onClick:()=>w("/votes"),leftIcon:t.jsx(f,{className:"h-4 w-4"}),"aria-label":"Back to votes list",children:"Back to Votes"}),C&&t.jsx(u,{variant:"outline",onClick:()=>{N({voteId:b}).catch(e=>{console.error("[VoteResults] Failed to refresh results:",e)})},disabled:R,leftIcon:t.jsx(x,{className:"h-4 w-4"}),"aria-label":"Refresh live results",children:R?"Refreshing...":"Refresh Results"}),t.jsx(u,{variant:"outline",onClick:async()=>{try{const e=window.location.href;await navigator.clipboard.writeText(e),s.success("Link copied to clipboard")}catch(e){console.error("[VoteResults] Failed to copy link:",e),s.error("Failed to copy link")}},leftIcon:t.jsx(j,{className:"h-4 w-4"}),"aria-label":"Share vote results link",children:"Share Results"})]})]})}):t.jsx(c.div,{initial:{opacity:0}
1,animate:{opacity:1},transition:{duration:.3},children:t.jsxs(y,{children:[t.jsx("div",{className:"mb-4 rounded-lg border border-blue-700/50 bg-blue-900/30 px-4 py-3 text-sm text-blue-100",children:"No results available"}),t.jsx(u,{variant:"outline",onClick:()=>w("/votes"),leftIcon:t.jsx(f,{className:"h-4 w-4"}),children:"Back to Votes"})]})})};export{b 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.