1import{a as O,K as M,b as K,d as P,n as q,_ as G,i as H}from"./aiW85mRP.js";import{_ as X}from"./-D51eaz2.js";import{k as z,b,l as $,y as J,D as Q,n as W,J as d,N as p,u as i,X as l,E as C,Y as m,F as Y,W as j,L as V,an as Z,M as w,Q as B,R as ee,S as D,a2 as te,U as ae}from"./DgrxDae8.js";import{_ as ne}from"./CpCPz4iU.js";import{F as oe,T as se}from"./0KYRl-Fs.js";const re={class:"device"},ie={key:0,class:"content"},le={key:0},ue={class:"success-image"},ce={class:"success-header"},de={class:"success-text"},ve={key:1},me={class:"center instruction-text"},pe={class:"interactions"},fe={for:"code"},ge={class:"digits"},_e={class:"subtext"},u=6,ye=z({__name:"tvcode",setup(he){const S=O(),x=M(),N=K(),s=b(["","","","","",""]),I=N.query,A=I.code,f=b(!1);let y=!1,h=!1;const a=b({value:A||"",invalid:!1,label:"code",rules:[]}),L=$(()=>{switch(a.value.invalidationReason){case"codeFormat":return"Code needs to be 6 digits";case"codeInvalid":return"Invalid code";default:return null}}),T=$(()=>a.value.value.length===u&&a.value.invalid===!1),g=(t,e)=>{const n=Number(t.id.slice(-1))+1,r=e[n];r&&r.focus()},_=(t,e)=>{const n=Number(t.id.slice(-1))-1,r=e[n];r&&r.focus()},R=()=>{if(!y){y=!0;const t=document.querySelectorAll('[id^="input"]');t.forEach(e=>{e.addEventListener("input",()=>{a.value.value=s.value.toString().replace(/,/g,""),a.value.value.length===u&&v(u-1),e.value.length>=e.maxLength&&g(e,t)}),e.addEventListener("keydown",o=>{o.key.toLowerCase()==="arrowright"&&g(e,t)})}),t.forEach(e=>{e.addEventListener("keydown",o=>{const n=o.key.toLocaleLowerCase();n==="backspace"&&(a.value.invalid=!1,a.value.value=s.value.toString().replace(/,/g,""),e.value.length===0&&_(e,t)),n==="arrowleft"&&_(e,t)})}),document.getElementById("input0").addEventListener("paste",e=>{e.preventDefault();const o=/^[0-9]{6}$/,n=e.clipboardData.getData("text").toString();if(!o.test(n))return;s.value=Array.from(n);const r=s.value.length-1;document.getElementById(`input${r}`).focus(),a.value.value=n,v(r)}),document.getElementById("input0").focus()}},U=()=>{{y=!1;const t=document.querySelectorAll('[id^="input"]');t.forEach(e=>{e.removeEventListener("input",()=>{a.value.value=s.value.toString().replace(/,/g,""),a.value.value.length===u&&v(u-1),e.value.length>=e.maxLength&&g(e,t)}),e.removeEventListener("keydown",o=>{o.key.toLowerCase()==="arrowright"&&g(e,t)})}),t.forEach(e=>{e.removeEventListener("keydown",o=>{const n=o.key.toLocaleLowerCase();n==="backspace"&&(a.value.invalid=!1,a.value.value=s.value.toString().replace(/,/g,""),e.value.length===0&&_(e,t)),n==="arrowleft"&&_(e,t)})}),document.getElementById("input0").removeEventListener("paste",e=>{e.preventDefault();const o=/^[0-9]{6}$/,n=e.clipboardData.getData("text").toString();if(!o.test(n))return;s.value=Array.from(n);const r=s.value.length-1;document.getElementById(`input${r}`).focus(),a.value.value=n})}};P({title:"Enter Authentication Code"}),J(async()=>{try{if(await S.$user.getUserAuthStatus(),!x.isLoggedIn()){const t=I.plat_attr;t&&sessionStorage.setItem("plat_attr",t),sessionStorage.setItem("redirect",window.location.href),await q("/signin?streaming")}}catch{}}),Q(()=>{a.value.value&&(s.value=Array.from(a.value.value),W(()=>v(u-1)))});function v(t){if(t!==u-1)return;if(!new RegExp(`^\\d{${u}}$`).test(a.value.value)){a.value.invalid=!0,a.value.invalidationReason="codeFormat";return}a.value.invalid=!1,a.value.invalidationReason=null,T.value&&E()}function F(){return!1}async function E(){if(!h){h=!0;try{if((await S.$auth.consumeDeviceCode(a.value.value)).status===202){f.value=!0;return}f.value=!1}catch{a.value.invalid=!0,a.value.invalidationReason="codeInvalid"}finally{f.value||(h=!1)}}}return(t,e)=>{const o=G,n=X;return d(),p("div",re,[i(x).isLoggedIn()?(d(),p("div",ie,[i(f)?(d(),p("div",le,[l("div",ue,[C(o,{src:"/images/play/happy-critters.png",alt:"happy tko yokai"})]),l("p",ce,m(t.$t("TV.HEADER")),1),l("p",de,m(t.$t("TV.SUCCESS_MSG")),1)])):(d(),p("div",ve,[l("p",me,m(t.$t("TV.CODE_MSG")),1),l("form",{onSubmit:ae(F,["prevent"])},[l("div",pe,[l("label",fe,m(t.$t("TV.CODE")),1),l("div",ge,[(d(!0),p(Y,null,j(i(s),(r,c)=>(d(),V(se,{id:`input${c}`,key:c,modelValue:i(s)[c],"onUpdate:modelValue":k=>i(s)[c]=k,type:"text",maxlength:1,minlength:1,class:ee({error:i(a).invalid}),onBlur:k=>v(c),onKeydown:D(k=>v(c),["enter"]),onVnodeMounted:R,onVnodeBeforeUnmount:U},Z({_:2},[i(a).invalid&&c===5?{name:"flag",fn:w(()=>[i(a).invalid&&i(L)?(d(),V(oe,{key:0,"error-text":i(L)},null,8,["error-text"])):B("",!0)]),key:"0"}:void 0]),1032,["id","modelValue","onUpdate:modelValue","class","onBlur","onKeydown"]))),128))]),l("p",_e,m(t.$t("TV.CODE_SUBTEXT")),1),C(n,null,{default:w(()=>[C(ne,{type:"submit",disabled:!i(T),class:"submit-btn",onClick:E,onKeydown:D(E,["enter"])},{default:w(()=>
1[te(m(t.$t("FORM.CONTINUE")),1)]),_:1},8,["disabled"])]),_:1})])],32)]))])):B("",!0)])}}}),Se=H(ye,[["__scopeId","data-v-62b19e3b"]]);export{Se as default}; 2//# sourceMappingURL=DYWdeOt8.js.map
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.