1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2063],{47523:function(e,t,a){Promise.resolve().then(a.t.bind(a,76341,23)),Promise.resolve().then(a.bind(a,61374)),Promise.resolve().then(a.t.bind(a,72972,23))},61374:function(e,t,a){"use strict";a.d(t,{default:function(){return v}});var s=a(57437),r=a(2265),n=a(71501);function l(e){return"".concat("goc_cypher_votes_v1:").concat(e)}function c(e){if(!e)return{};try{let t=window.localStorage.getItem(l(e));if(!t)return{};let a=JSON.parse(t);if(!a||"object"!=typeof a)return{};let s={};for(let[e,t]of Object.entries(a))("agree"===t||"disagree"===t)&&(s[e]=t);return s}catch(e){return{}}}function i(e){let t=Math.max(0,Math.floor(e.agreeCount)||0),a=Math.max(0,Math.floor(e.disagreeCount)||0),s=t+a;return{agree:t,disagree:a,total:s,agreeRatio:0===s?0:t/s,ranked:s>=10}}let o="goc_cypher_session_v1";function d(){return"undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID?crypto.randomUUID():"cyp-".concat(Date.now().toString(36),"-").concat(Math.random().toString(36).slice(2,10))}function u(){try{let e=window.localStorage.getItem(o);if(e)return e;let t=d();return window.localStorage.setItem(o,t),t}catch(e){return d()}}function p(e){let{onSelect:t,value:a,placeholder:n="Search a film or showâ¦",autoFocus:l=!1,disabled:c=!1,id:i}=e,[o,d]=(0,r.useState)(""),[u,p]=(0,r.useState)([]),[y,m]=(0,r.useState)(!1),[f,b]=(0,r.useState)(!1),[v,x]=(0,r.useState)(!1),[j,g]=(0,r.useState)(-1),[N,k]=(0,r.useState)(null),w=void 0!==a?a:N,C=(0,r.useRef)(null),S=(0,r.useRef)(null),T=(0,r.useRef)(0),D=(0,r.useRef)(null),I=(0,r.useId)(),_="".concat(I,"-list"),O=e=>"".concat(I,"-opt-").concat(e);(0,r.useEffect)(()=>{let e=o.trim();if(e.length<2){var t;p([]),b(!1),x(!1),null===(t=D.current)||void 0===t||t.abort();return}b(!0),x(!1);let a=setTimeout(async()=>{var t;let a=++T.current;null===(t=D.current)||void 0===t||t.abort();let s=new AbortController;D.current=s;try{let t=await fetch("/api/games/cypher/search?q=".concat(encodeURIComponent(e)),{signal:s.signal});if(a!==T.current)return;if(!t.ok)throw Error("search ".concat(t.status));let r=await t.json();if(a!==T.current)return;p(Array.isArray(r)?r:[]),g(-1),b(!1)}catch(e){if(s.signal.aborted||a!==T.current)return;console.warn("[TmdbAutocomplete] search failed:",e),p([]),x(!0),b(!1)}},300);return()=>clearTimeout(a)},[o]),(0,r.useEffect)(()=>{if(y)return document.addEventListener("pointerdown",e),()=>document.removeEventListener("pointerdown",e);function e(e){S.current&&!S.current.contains(e.target)&&m(!1)}},[y]);let A=(0,r.useCallback)(e=>{void 0===a&&k(e),t(e),m(!1),d(""),p([]),g(-1)},[t,a]),M=(0,r.useCallback)(()=>{void 0===a&&k(null),t(null),m(!0),requestAnimationFrame(()=>{var e;return null===(e=C.current)||void 0===e?void 0:e.focus()})},[t,a]);if(w)return(0,s.jsx)("div",{className:"cyp-ac",ref:S,children:(0,s.jsxs)("div",{className:"cyp-ac-selected",children:[(0,s.jsx)(h,{result:w}),(0,s.jsxs)("div",{className:"cyp-ac-meta",children:[(0,s.jsx)("div",{className:"cyp-ac-title",children:w.title}),(0,s.jsxs)("div",{className:"cyp-ac-sub",children:[(0,s.jsx)("span",{className:"cyp-ac-badge",children:"movie"===w.mediaType?"Film":"TV"}),w.year&&(0,s.jsx)("span",{children:w.year})]})]}),(0,s.jsx)("button",{type:"button",className:"cyp-ac-change",onClick:M,disabled:c,children:"Change"})]})});let R=o.trim(),E=y&&R.length>=2,U=E&&!f&&!v&&0===u.length;return(0,s.jsxs)("div",{className:"cyp-ac",ref:S,children:[(0,s.jsxs)("div",{className:"cyp-ac-field",role:"combobox","aria-expanded":E,"aria-owns":_,"aria-haspopup":"listbox",children:[(0,s.jsx)("input",{ref:C,id:i,className:"cyp-ac-input",type:"text",inputMode:"search",autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1,autoFocus:l,disabled:c,placeholder:n,value:o,role:"searchbox","aria-controls":_,"aria-autocomplete":"list","aria-activedescendant":j>=0?O(j):void 0,onChange:e=>{d(e.target.value),m(!0)},onFocus:()=>m(!0),onKeyDown:function(e){"ArrowDown"===e.key?(e.preventDefault(),y||m(!0),u.length&&g(e=>(e+1)%u.length)):"ArrowUp"===e.key?(e.preventDefault(),u.length&&g(e=>e<=0?u.length-1:e-1)):"Enter"===e.key?y&&j>=0&&u[j]&&(e.preventDefault(),A(u[j])):"Escape"===e.key&&y&&(e.preventDefault(),m(!1))}}),(0,s.jsx)("span",{className:"cyp-ac-trailing",children:f?(0,s.jsx)("span",{className:"cyp-ac-spinner","aria-hidden":"true"}):o?(0,s.jsx)("button",{type:"button",className:"cyp-ac-clear","aria-label":"Clear search",onClick:()=>{var e;d(""),p([]),x(!1),null===(e=C.current)||void 0===e||e.focus()},children:"\xd7"}):null})]}),E&&(0,s.jsxs)("ul",{className:"cyp-ac-panel",id:_,role:"listbox",children:[f&&0===u.length&&(0,s.jsx)("li",{className:"cyp-ac-status",role:"presentation",children:"Searchingâ¦"}),v&&(0,s.jsx)("li",{className:"cyp-ac-status","data-tone":"error",role:"presentation",children:"Couldn't reach search. Try again."}),U&&(0,s.jsxs)("li",{className:"cyp-ac-status",role:"presentation",children:["No films or shows match â",R,"â."]}),u.map((e,t)=>(0,s.jsx)("li",{role:"presentation",children:(0,s.jsxs)("button",{type:"button",id:O(t),role:"option","aria-selected":t===j,"data-active":t===j,className:"cyp-ac-option",onPointerDown:t=>{t.preventDefault(),A(e)},onMouseEnter:()=>g(t),children:[(0,s.jsx)(h,{result:e}),(0,s.jsxs)("div",{className:"cyp-ac-meta",children:[(0,s.jsx)("div",{className:"cyp-ac-title",children:e.title}),(0,s.jsxs)("div",{className:"cyp-ac-sub",children:[(0,s.jsx)("span",{className:"cyp-ac-badge",children:"movie"===e.mediaType?"Film":"TV"}),e.year&&(0,s.jsx)("span",{children:e.year})]})]})]})},"".concat(e.mediaType,"-").concat(e.id)))]})]})}function h(e){let{result:t}=e;return(0,s.jsx)("div",{className:"cyp-ac-poster",children:t.posterUrl?(0,s.jsx)("img",{src:t.posterUrl,alt:"",loading:"lazy",decoding:"async"}):(0,s.jsx)("span",{className:"cyp-ac-poster-fallback","aria-hidden":"true",children:"movie"===t.mediaType?"\uD83C\uDFAC":"\uD83D\uDCFA"})})}function y(e){let{promptId:t,question:a,onSubmitted:n,disabled:l=!1}=e,[c,i]=(0,r.useState)(null),[o,d]=(0,r.useState)(""),[h,y]=(0,r.useState)("idle"),[m,f]=(0,r.useState)(null),b=140-o.length,v=b<0,x="published"===h||"in_review"===h||"duplicate"===h,j=!l&&!!c&&!v&&"submitting"!==h&&!x;async function g(){if(c&&j){y("submitting"),f(null);try{var e,a;let s=await fetch("/api/games/cypher/submit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({promptId:t,tmdbId:c.id,mediaType:c.mediaType,title:c.title,year:c.year,posterUrl:c.posterUrl,reason:o.trim()||null,sessionId:u()})}),r=await s.json().catch(()=>({}));if(409===s.status||"duplicate"===r.status){y("duplicate"),f(null!==(e=r.error)&&void 0!==e?e:"Youâve already dropped a take on this one."),null==n||n({status:"duplicate"});return}if(!s.ok){y("idle"),f(null!==(a=r.error)&&void 0!==a?a:"Couldnât save your take. Try again.");return}let l="in_review"===r.status?"in_review":"published";y(l),null==n||n({submissionId:r.submissionId,status:l})}catch(e){y("idle"),f("Network hiccup. Try again.")}}}let N=(0,r.useMemo)(()=>{switch(h){case"published":return{tone:"success",text:"Take dropped. Itâs live in the cypher."};case"in_review":return{tone:"info",text:"Take received â itâs in review and will show once cleared."};case"duplicate":return{tone:"error",text:null!=m?m:"Youâve already dropped a take on this one."};default:return m?{tone:"error",text:m}:null}},[h,m]);return(0,s.jsxs)("div",{className:"cyp-submit",children:[a&&(0,s.jsx)("div",{className:"cyp-submit-prompt",children:a}),!x&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"cyp-submit-label",htmlFor:"cyp-submit-title",children:"Your pick"}),(0,s.jsx)(p,{id:"cyp-submit-title",value:c,onSelect:i,disabled:l||"submitting"===h,placeholder:"Search a film or showâ¦"})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("label",{className:"cyp-submit-label",htmlFor:"cyp-submit-reason",children:["Why? ",(0,s.jsx)("span",{style:{textTransform:"none",fontWeight:400},children:"(optional)"})]}),(0,s.jsx)("div",{className:"cyp-submit-reason-wrap",children:(0,s.jsx)("textarea",{id:"cyp-submit-reason",className:"cyp-submit-reason",value:o,maxLength:160,disabled:l||"submitting"===h,placeholder:"Make your case in a lineâ¦",onChange:e=>d(e.target.value)})}),(0,s.jsx)("div",{className:"cyp-submit-counter","data-over":v,children:b})]}),(0,s.jsx)("button",{type:"button",className:"cyp-submit-btn",disabled:!j,onClick:g,children:"submitting"===h?"Droppingâ¦":"Drop your take"})]}),N&&(0,s.jsx)("div",{className:"cyp-submit-msg","data-tone":N.tone,role:"status",children:N.text})]})}a(95300),a(99624);var m=a(33145);function f(e){var t;let{submission:a,initialChoice:n=null,votingDisabled:l=!1,onVoted:c}=e,[o,d]=(0,r.useState)(null),[p,h]=(0,r.useState)(()=>i(a)),[y,f]=(0,r.useState)(!1),[b,v]=(0,r.useState)(null),[x,j]=(0,r.useState)("idle"),g=null!==(t=null!=o?o:n)&&void 0!==t?t:null,N=null!==g,k=Math.round(100*p.agreeRatio);async function w(e){if(!N&&!y&&!l){f(!0),v(null);try{let s=await fetch("/api/games/cypher/vote",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({submissionId:a.id,choice:e,sessionId:u()})}),r=await s.json().catch(()=>({}));if(!s.ok||!r.tally){var t;v(null!==(t=r.error)&&void 0!==t?t:"Couldnât record your vote. Try again."),f(!1);return}h(r.tally),d(e),null==c||c(a.id,e)}catch(e){v("Network hiccup. Try again.")}finally{f(!1)}}}async function C(){j("sending");try{await fetch("/api/games/cypher/report",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({submissionId:a.id,sessionId:u()})})}catch(e){}j("done")}return(0,s.jsxs)("div",{className:"cyp-card","data-revealed":N,children:[(0,s.jsxs)("div",{className:"cyp-card-main",children:[a.posterUrl?(0,s.jsx)(m.default,{src:a.posterUrl,alt:"",width:46,height:69,className:"cyp-card-poster",unoptimized:!0}):(0,s.jsx)("div",{className:"cyp-card-poster cyp-card-poster-ph","aria-hidden":"true"}),(0,s.jsxs)("div",{className:"cyp-card-body",children:[(0,s.jsxs)("div",{className:"cyp-card-title",children:[a.title,a.year&&(0,s.jsxs)("span",{className:"cyp-card-year",children:[" \xb7 ",a.year]}
1)]}),a.reason&&(0,s.jsx)("p",{className:"cyp-card-reason",children:a.reason}),N?(0,s.jsxs)("div",{className:"cyp-card-result",children:[(0,s.jsx)("div",{className:"cyp-card-bar",role:"img","aria-label":"".concat(k,"% agree"),children:(0,s.jsx)("span",{className:"cyp-card-bar-fill",style:{width:"".concat(k,"%")}})}),(0,s.jsxs)("div",{className:"cyp-card-stats",children:[(0,s.jsxs)("span",{className:"cyp-card-pct",children:[k,"% agree"]}),(0,s.jsxs)("span",{className:"cyp-card-total",children:[p.total," vote",1===p.total?"":"s",p.ranked?"":" \xb7 needs 10 to rank"]})]}),g&&(0,s.jsxs)("div",{className:"cyp-card-you",children:["You ","agree"===g?"agreed":"disagreed"]})]}):(0,s.jsxs)("div",{className:"cyp-card-vote",children:[(0,s.jsx)("button",{type:"button",className:"cyp-vote-btn cyp-vote-agree",onClick:()=>w("agree"),disabled:y||l,children:"Agree"}),(0,s.jsx)("button",{type:"button",className:"cyp-vote-btn cyp-vote-disagree",onClick:()=>w("disagree"),disabled:y||l,children:"Disagree"})]}),b&&(0,s.jsx)("div",{className:"cyp-card-err",role:"status",children:b})]})]}),(0,s.jsxs)("div",{className:"cyp-card-report",children:["idle"===x&&(0,s.jsx)("button",{type:"button",className:"cyp-report-link",onClick:()=>j("confirm"),children:"Report"}),"confirm"===x&&(0,s.jsxs)("span",{className:"cyp-report-confirm",children:["Flag this take for review?",(0,s.jsx)("button",{type:"button",className:"cyp-report-yes",onClick:C,children:"Yes"}),(0,s.jsx)("button",{type:"button",className:"cyp-report-no",onClick:()=>j("idle"),children:"Cancel"})]}),"sending"===x&&(0,s.jsx)("span",{className:"cyp-report-note",children:"Sendingâ¦"}),"done"===x&&(0,s.jsx)("span",{className:"cyp-report-note",children:"Thanks â a mod will take a look."})]})]})}function b(e){let{submissions:t,unlocked:a}=e,r=t.filter(e=>i(e).ranked).slice().sort((e,t)=>{let a=i(e),s=i(t);return s.agreeRatio!==a.agreeRatio?s.agreeRatio-a.agreeRatio:s.total!==a.total?s.total-a.total:e.createdAt.localeCompare(t.createdAt)});return(0,s.jsxs)("section",{className:"cyp-lb","aria-label":"Leaderboard",children:[(0,s.jsx)("h2",{className:"cyp-lb-title",children:"Leaderboard"}),a?0===r.length?(0,s.jsx)("div",{className:"cyp-lb-empty",children:"No take has cleared 10 votes yet. Keep voting â the board fills as the week goes."}):(0,s.jsx)("ol",{className:"cyp-lb-list",children:r.map((e,t)=>{let a=i(e);return(0,s.jsxs)("li",{className:"cyp-lb-row",children:[(0,s.jsx)("span",{className:"cyp-lb-rank","data-top":0===t,children:t+1}),(0,s.jsxs)("span",{className:"cyp-lb-name",children:[e.title,e.year&&(0,s.jsxs)("span",{className:"cyp-lb-year",children:[" \xb7 ",e.year]})]}),(0,s.jsxs)("span",{className:"cyp-lb-pct",children:[Math.round(100*a.agreeRatio),"%"]}),(0,s.jsx)("span",{className:"cyp-lb-votes",children:a.total})]},e.id)})}):(0,s.jsxs)("div",{className:"cyp-lb-locked",children:[(0,s.jsx)("span",{className:"cyp-lb-lock","aria-hidden":"true",children:"\uD83D\uDD12"}),"Vote on a take to reveal the leaderboard."]})]})}function v(e){var t;let{prompt:a,submissions:i}=e,[o,d]=(0,r.useState)({}),[u,p]=(0,r.useState)(null),[h,m]=(0,r.useState)(!1);(0,r.useEffect)(()=>{d(c(a.id)),p(function(e){if(!e)return null;let t=Date.parse(e);if(Number.isNaN(t))return null;let a=t-Date.now();if(a<=0)return null;let s=Math.floor(a/36e5),r=Math.floor(s/24);return r>=1?"Closes in ".concat(r," day").concat(1===r?"":"s"):s>=1?"Closes in ".concat(s," hour").concat(1===s?"":"s"):"Closes soon"}(a.closesAt)),m(!0)},[a.id,a.closesAt]);let v="closed"===a.status,x=Object.keys(o).length;function j(e,t){let s=0===Object.keys(o).length;d(a=>({...a,[e]:t})),function(e,t,a){let s={...c(e),[t]:a};if(e&&t)try{window.localStorage.setItem(l(e),JSON.stringify(s))}catch(e){}}(a.id,e,t),s&&(0,n.$g)("the-cypher")}let g=(0,r.useMemo)(()=>i,[i]);return(0,s.jsxs)("div",{className:"cyp-board",children:[(0,s.jsxs)("header",{className:"cyp-head",children:[(0,s.jsxs)("div",{className:"cyp-kicker",children:["The Cypher",(0,s.jsxs)("span",{className:"cyp-vertical",children:[" \xb7 ",a.vertical]})]}),(0,s.jsx)("h1",{className:"cyp-question",children:a.question}),(0,s.jsx)("div",{className:"cyp-status","data-closed":v,children:v?"This weekâs cypher is closed":null!==(t=h?u:null)&&void 0!==t?t:"Open now"})]}),!v&&(0,s.jsx)("section",{className:"cyp-submit-section","aria-label":"Drop your take",children:(0,s.jsx)(y,{promptId:a.id})}),(0,s.jsxs)("section",{className:"cyp-pool","aria-label":"Vote on takes",children:[(0,s.jsxs)("div",{className:"cyp-pool-head",children:[(0,s.jsx)("h2",{className:"cyp-pool-title",children:"The takes"}),!v&&(0,s.jsx)("span",{className:"cyp-pool-hint",children:"Vote to reveal each tally"})]}),0===g.length?(0,s.jsx)("div",{className:"cyp-pool-empty",children:"No takes yet. Be the first to drop one."}):(0,s.jsx)("div",{className:"cyp-pool-list",children:g.map(e=>{var t;return(0,s.jsx)(f,{submission:e,initialChoice:null!==(t=o[e.id])&&void 0!==t?t:null,votingDisabled:v,onVoted:j},e.id)})})]}),(0,s.jsx)(b,{submissions:i,unlocked:x>0})]})}a(76341)},33145:function(e,t,a){"use strict";a.d(t,{default:function(){return r.a}});var s=a(48461),r=a.n(s)},48461:function(e,t,a){"use strict";
1Object.defineProperty(t,"__esModule",{value:!0}),function(e,t){for(var a in t)Object.defineProperty(e,a,{enumerable:!0,get:t[a]})}(t,{default:function(){return i},getImageProps:function(){return c}});let s=a(47043),r=a(55346),n=a(65878),l=s._(a(5084));function c(e){let{props:t}=(0,r.getImgProps)(e,{defaultLoader:l.default,imgConf:{deviceSizes:[640,828,1200,1920,2048],imageSizes:[64,256],path:"/_next/image",loader:"default",dangerouslyAllowSVG:!1,unoptimized:!1}});for(let[e,a]of Object.entries(t))void 0===a&&delete t[e];return{props:t}}let i=n.Image},76341:function(){},99624:function(){},95300:function(){}},function(e){e.O(0,[7853,2972,5878,8859,6073,1501,2971,6997,1744],function(){return e(e.s=47523)}),_N_E=e.O()}]);
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.