PageSourceSearch

https://assets.lichess.dev/assets/compiled/lib.HT2GCF6V.js

js lichess.dev collected 2026-10-08 10:49:42 UTC 18,052 bytes, 1 lines download raw bytes

1import{A as ae,B as ne,F as de,e as ee,n as re,o as ie,x as C}from"./lib.DUDSTP4N.js";import{c as oe}from"./lib.G7SYKZIX.js";import{b as X,l as Z}from"./lib.UUBXHZNG.js";import{a as u}from"./lib.OZU3XCSV.js";import{a as d}from"./lib.P3MBULVA.js";import{g as te,i as g,j as se,l as y}from"./lib.7AP57XS6.js";import{p as V,q as Q,t as T}from"./lib.DHQDBWMO.js";import{D as x,F as a,M as Y,P as J,a as G,f as O,i as D,j as U,n as H,y as v,z as l}from"./lib.QSN4SHRN.js";import{a as _,b as i,d as q,e as j}from"./lib.BVGQPJTT.js";var m=class{constructor(r){this.root=r;this.getVar=r=>parseInt(window.getComputedStyle(document.body).getPropertyValue(`---${r}`));this.postPref=T(r=>{let e=()=>site.announce({msg:`Failed to save ${r}`});if(r==="zoom")return g(`/pref/zoom?v=${this.getVar("zoom")}`,{method:"post"}).catch(e);let t=new FormData;t.set(H(r),this.getVar(r).toString());let s=`/pref/${H(r)}`;return g(s,{body:t,method:"post"}).catch(e)},1e3)}get redraw(){return this.root.redraw}get close(){return this.root.close}get dimension(){return this.root.data.board.is3d?"d3":"d2"}get is3d(){return this.root.data.board.is3d}};var b=(n,r)=>a("button.head.text",{attrs:{"data-icon":d.LessThan,type:"button"},hook:l("click",r)},n),M=n=>a("button.button.more",{attrs:{title:n()?i18n.site.less:i18n.site.more},hook:l("click",n.toggle)},n()?"-":"+"),N=U(()=>{let n=document.createElement("div");n.style.position="absolute",n.style.overflow="scroll",n.style.visibility="hidden",document.body.appendChild(n);let r=n.offsetWidth-n.clientWidth;return document.body.removeChild(n),r});var I=class extends m{constructor(e){super(e);this.sliderKey=Date.now();this.featured={d2:[],d3:[]};this.render=()=>a(`div.sub.board.${this.dimension}`,[b(i18n.site.board,this.close),a("div.selector.large",[a("button.text",{class:{active:!this.is3d},attrs:{"data-icon":d.Checkmark,type:"button"},hook:l("click",()=>this.set3d(!1))},"2D"),a("button.text",{class:{active:this.is3d},attrs:{"data-icon":d.Checkmark,type:"button"},hook:l("click",()=>this.set3d(!0))},"3D")]),this.propSliders(),this.showReset()&&a("button.text.reset",{attrs:{"data-icon":d.Back,type:"button"},hook:l("click",this.reset)},i18n.site.boardReset),a("div.list",this.boardList.map(e=>a("button",{key:e,hook:l("click",()=>this.setBoard(e)),attrs:{title:e,type:"button"},class:{active:this.current===e}},a("span."+e)))),M(this.more)]);this.setBoard=e=>{this.apply(e);let t=`theme${this.is3d?"3d":""}`;g(`/pref/${t}`,{body:y({[t]:e}),method:"post"}).catch(()=>site.announce({msg:"Failed to save theme preference"})),this.redraw()};this.reset=()=>{this.defaults.filter(([e,t])=>this.getVar(e)!==t).forEach(([e,t],s)=>{this.setVar(e,t),setTimeout(()=>this.postPref(e),s*1100)}),this.showReset(!1),this.sliderKey=Date.now(),document.body.classList.add("simple-board"),this.redraw()};this.setVar=(e,t)=>{this.showReset(this.showReset()||!this.isDefault()),document.body.style.setProperty(`---${e}`,t.toString()),document.body.classList.toggle("simple-board",this.isDefault()),e==="zoom"&&window.dispatchEvent(new Event("resize"))};this.set3d=async e=>{this.is3d!==e&&(this.data.is3d=e,g("/pref/is3d",{body:y({is3d:e}),method:"post"}).catch(()=>site.announce({msg:"Failed to save preference"})),e?await site.asset.loadCssPath("lib.board-3d"):site.asset.removeCssPath("lib.board-3d"),$("#main-wrap").removeClass(e?"is2d":"is3d").addClass(e?"is3d":"is2d"),this.apply(),this.redraw())};this.apply=(e=this.current)=>{var t;this.current=e,document.body.dataset[this.is3d?"board3d":"board"]=e,u.emit("board.change",this.is3d),(t=this.root)==null||t.piece.apply()};this.defaults=[["board-opacity",100],["board-brightness",100],["board-contrast",100],["board-hue",0]];this.isDefault=()=>this.defaults.every(([e,t])=>this.getVar(e)===t);this.showReset=D(!this.isDefault());this.propSliders=()=>{var t;let e=[];return Number.isNaN(this.getVar("zoom"))||e.push(this.propSlider("zoom",i18n.site.size,{min:0,max:100,step:1})),(t=document.body.dataset.theme)!=null&&t.includes("transp")&&e.push(this.propSlider("board-opacity",i18n.site.opacity,{min:0,max:100,step:1})),e.push(this.propSlider("board-brightness",i18n.site.brightness,{min:20,max:140,step:1}),this.propSlider("board-contrast",i18n.site.contrast,{min:40,max:200,step:2}),this.propSlider("board-hue",i18n.site.hue,{min:0,max:100,step:1},s=>`+ ${Math.round(s*3.6)}\xB0`)),e};this.propSlider=(e,t,s,o)=>a(`div.${e}`,{attrs:{title:o?o(this.getVar(e)):`${Math.round(this.getVar(e))}%`}},[a("label",t),a("input.range",{key:this.sliderKey+e,attrs:{...s,type:"range",value:this.getVar(e)},hook:v(h=>{let p=c=>{c<s.min||c>s.max||(this.setVar(e,c),this.redraw(),this.postPref(e))};$(h).on("input",()=>p(parseInt(h.value))).on("wheel",c=>{c.preventDefault(),p(this.getVar(e)+(c.deltaY>0?-s.step:s.step))})})})]);this.more=D(!1,e.redraw);for(let t of["d2","d3"])this.featured[t]=this.data[t].list.filter(s=>s.featured).map(s=>s.name)}get boardList(){let e=this.data[this.dimension].list.map(s=>s.name),t=this.featured[this.dimension].slice();return t.includes(this.current)||t.push(this.current),this.more()?e:t}get data(){return this.root.data.board}get current(){return this.data[this.dimension].current}set current(e){this.data[this.dimension].current=e}};var L=class extends m{constructor(){super(...arguments);this.render=()=>i("div.sub.langs",[b(i18n.site.language,this.close),i("form",{attrs:{method:"post",action:"/translation/select"}}
1,this.list().map(([e,t])=>i("button",{class:{current:this.isCurrent(e),accepted:this.isAccepted(e)},attrs:{type:"submit",name:"lang",value:e,title:e}},t))),i("a.help.text",{attrs:{href:"https://crowdin.com/project/lichess","data-icon":d.Heart}},"Help translate Lichess")]);this.isCurrent=e=>this.data.current===e;this.isAccepted=e=>this.data.accepted.includes(e);this.list=()=>[...this.data.list.filter(([e,t])=>this.isCurrent(e)||this.isAccepted(e)),...this.data.list]}get data(){return this.root.data.lang}};var P=class extends m{constructor(){super(...arguments);this.render=()=>{let e=this.modeCfg;return a("div",[this.userLinks(),a("div.subs",[a("button.sub.language",e("langs"),i18n.site.language),a("button.sub",e("sound"),i18n.site.sound),a("button.sub",e("theme"),i18n.site.theme),a("button.sub",e("board"),i18n.site.board),a("button.sub",e("piece"),i18n.site.pieceSet),this.root.opts.zenable&&a("div.zen.selector",[a("button.text",{attrs:{"data-icon":d.DiscBigOutline,title:"Keyboard: z",type:"button"},hook:l("click",()=>u.emit("zen"))},i18n.preferences.zenMode)])]),this.root.ping.render()])};this.modeCfg=e=>({hook:l("click",()=>this.root.setMode(e))});this.linkCfg=(e,t,s)=>({attrs:{href:e,"data-icon":t,...s}})}get data(){return this.root.data}userLinks(){let e=this.data,t=this.linkCfg;return e.user?a("div.links",[a("a.user-link.online",{attrs:{href:Y(e.user.name)}},[J(e.user),i18n.site.profile]),a("a.text",t("/inbox",d.Envelope),i18n.site.inbox),a("a.text",t("/account/profile",d.Gear,this.root.opts.playing?{target:"_blank"}:void 0),i18n.preferences.preferences),e.coach&&a("a.text",t("/coach/edit",d.GraduateCap),i18n.site.coachManager),e.streamer&&a("a.text",t("/streamer/edit",d.Mic),i18n.site.streamerManager),a("form.logout",{attrs:{method:"post",action:"/logout"}},[a("button.text",{attrs:{type:"submit","data-icon":d.Power}},i18n.site.logOut)])]):null}};var R=class extends m{constructor(e){super(e);this.featured={d2:[],d3:[]};this.apply=(e=this.dimData.current)=>{this.dimData.current=e,document.body.dataset[this.is3d?"pieceSet3d":"pieceSet"]=e,this.is3d||me(e)};this.set=e=>{this.apply(e);let t=`pieceSet${this.is3d?"3d":""}`;g(`/pref/${t}`,{body:y({[t]:e}),method:"post"}).catch(()=>site.announce({msg:"Failed to save piece set  preference"})),this.redraw()};this.more=D(!1,e.redraw);for(let t of["d2","d3"])this.featured[t]=this.root.data.piece[t].list.filter(s=>s.featured).map(s=>s.name)}get pieceList(){let e=this.dimData.list.map(s=>s.name),t=this.featured[this.dimension].slice();return t.includes(this.dimData.current)||t.push(this.dimData.current),this.more()?e:t}render(){let e=window.innerHeight-150,t=(222-N())/(this.more()?4:3),s=o=>this.is3d?`images/staunton/piece/${o}/White-Knight${o==="Staunton"?"-Preview":""}.webp`:site.manifest.hashed[`piece/${o}/wN.webp`]?`piece/${o}/wN.webp`:`piece/${o}/wN.svg`;return i("div.sub.piece."+this.dimension,[b(i18n.site.pieceSet,()=>this.close()),i("div.list",{attrs:{style:`max-height:${e}px;`}},this.pieceList.map(o=>i("button.no-square",{key:o,attrs:{title:o,type:"button",style:`width: ${t}px; height: ${t}px`},hook:l("click",()=>this.set(o)),class:{active:this.dimData.current===o}},[i("piece",{attrs:{style:`background-image:url(${site.asset.url(s(o))})`}})]))),M(this.more)])}get dimData(){return this.root.data.piece[this.dimension]}},ce=[["---white-pawn","wP"],["---black-pawn","bP"],["---white-knight","wN"],["---black-knight","bN"],["---white-bishop","wB"],["---black-bishop","bB"],["---white-rook","wR"],["---black-rook","bR"],["---white-queen","wQ"],["---black-queen","bQ"],["---white-king","wK"],["---black-king","bK"]];function me(n){let r=site.manifest.hashed[`piece/${n}/wP.webp`]?"webp":"svg";for(let[e,t]of ce){let s=site.asset.url(`piece/${n}/${t}.${r}`,{pathOnly:!0});document.body.style.setProperty(e,`url(${s})`)}}var B=class{constructor(r){this.root=r;this.onLag=r=>{this.ping=Math.round(r),this.root.redraw()};this.onMlat=r=>{this.server=r,this.root.redraw()};this.connect=()=>{u.emit("socket.send","moveLat",!0),u.on("socket.lag",this.onLag),u.on("socket.in.mlat",this.onMlat)};this.disconnect=()=>{u.off("socket.lag",this.onLag),u.off("socket.in.mlat",this.onMlat)};this.render=()=>i("a.status",{attrs:{href:"/lag"},hook:{insert:this.connect,destroy:this.disconnect}},[this.signalBars(),i("span.ping",{attrs:{title:"PING: "+i18n.site.networkLagBetweenYouAndLichess}},this.showMillis("PING",this.ping)),i("span.server",{attrs:{title:"SERVER: "+i18n.site.timeToProcessAMoveOnLichessServer}},this.showMillis("SERVER",this.server))]);this.showMillis=(r,e)=>[i("em",r),i("strong",G(e)?e:"?"),i("em","ms")]}signalBars(){let r=this.ping?this.ping<150?4:this.ping<300?3:this.ping<500?2:1:0,e=[];for(let t=1;t<=4;t++)e.push(i(t<=r?"i":"i.off"));return i("signal.q"+r,e)}};var E=class extends m{constructor(e){super(e);this.showVoiceSelection=!1;this.render=()=>i("div.sub.sound."+this.getCurrent(),{hook:{insert:()=>{window.speechSynthesis&&(window.speechSynthesis.onvoiceschanged=this.redraw)}}},[b(i18n.site.sound,this.close),i("div.content.force-ltr",[i("input",{attrs:{type:"range",min:0,max:1,step:.
101,value:site.sound.getVolume(),orient:"vertical",style:Z({below:"18"})?"appearance: slider-vertical":""},hook:v(e=>{let t=Q(150,this.volume);$(e).on("input",()=>t(parseFloat(e.value)))})}),i("div.selector",this.makeList().map(e=>i("button.text",{hook:l("click",()=>this.set(e[0])),class:{active:this.getCurrent()===e[0]},attrs:{...x(d.Checkmark),type:"button"}},[e[1],e[0]==="speech"?"...":""])))]),this.voiceSelectionDialog()]);this.voiceSelectionDialog=()=>{if(!this.showVoiceSelection)return;let e=this.renderVoiceSelection();if(e)return oe({onClose:()=>{this.showVoiceSelection=!1,this.redraw()},modal:!0,easyClose:"clickOutside",vnodes:e,onInsert:t=>{var s;t.show(),(s=t.view.querySelector(".active"))==null||s.scrollIntoView({behavior:"smooth",block:"center"})}})};this.getCurrent=()=>site.sound.speech()?"speech":site.sound.theme;this.setVoiceRate=e=>{localStorage.setItem("speech.rate",e),this.rateInput&&(this.rateInput.value=e),site.sound.say("Speech synthesis ready")};this.postSet=V(()=>1e3,e=>g("/pref/soundSet",{body:y({soundSet:e}),method:"post"}).catch(()=>site.announce({msg:"Failed to save sound preference"})));this.makeList=()=>{var t;let e=(t=window.speechSynthesis)==null?void 0:t.getVoices().length;return this.list.filter(s=>s[0]!=="speech"||e)};this.set=e=>{site.sound.speech(e==="speech"),site.sound.speech()?(this.showVoiceSelection=!0,site.sound.say("Speech synthesis ready"),site.sound.changeSet("speech"),this.postSet("speech")):(site.sound.changeSet(e),site.sound.play("genericNotify"),this.postSet(e)),this.redraw()};this.volume=e=>{site.sound.setVolume(e),site.sound.sayOrPlay("move","knight F 7",!0)};this.list=this.root.data.sound.list.map(t=>t.split(" "))}renderVoiceSelection(){let e=site.sound.getVoice(),t=site.sound.getVoiceMap(),s=Number(localStorage.getItem("speech.rate"))||1;return t.size===0?!1:[i("div.rate",["Speech rate",i("input.rate",{attrs:{...site.sound.voiceRateRange,step:.05,type:"range",value:s},hook:v(o=>{this.rateInput=o,o.onchange=()=>this.setVoiceRate(o.value)})}),i("button",{attrs:{type:"button",...x(d.Back)},hook:l("click",()=>this.setVoiceRate("1"))})]),i("div.selector",[...t.keys()].sort((o,h)=>o.localeCompare(h)).map(o=>i("button.text",{hook:l("click",h=>{let p=h.target;site.sound.setVoice(t.get(p.textContent)),site.sound.say("Speech synthesis ready"),this.redraw()}),class:{active:o===(e==null?void 0:e.name)},attrs:{...o===(e==null?void 0:e.name)?x(d.Checkmark):{},type:"button"}},o)))]}};var z=class extends m{constructor(e){super(e);this.sliderKey=Date.now();this.set=V(()=>700,e=>(this.backgroundData.current=e,this.apply(),this.redraw(),g("/pref/bg",{body:y({bg:e}),method:"post"}).then(this.reloadAllTheThings,this.announceFail)));this.announceFail=e=>site.announce({msg:`Failed to save background preference: ${e}`});this.reloadAllTheThings=()=>{$("canvas").length&&site.reload()};this.getThemeData=()=>{let e=this.get();return{theme:e,isTransp:e.includes("transp"),isSystem:e.includes("system"),systemPrefersLight:X().matches}};this.get=()=>this.backgroundData.current;this.getImage=()=>this.backgroundData.image;this.setImage=e=>{this.backgroundData.image=e.startsWith("/assets/")?e.slice(8):e,se("/pref/bgImg",{body:y({bgImg:e}),method:"post"}).then(t=>t.ok?t.text():Promise.reject(t.text())).then(this.reloadAllTheThings,t=>t.then(this.announceFail)),this.apply(),this.redraw()};this.apply=()=>{let{theme:e,isTransp:t,isSystem:s,systemPrefersLight:o}=this.getThemeData();if(document.body.dataset.theme=e,t){let h=s?o?"transp light":"transp dark":e;document.documentElement.className=h;let p=document.getElementById("bg-data"),c=`html.${h.replace(" ",".")}::before{background-image:url(${this.backgroundData.image});opacity:calc(var(---bg-opacity)/100);}`;p?p.innerHTML=c:$("head").append(`<style id="bg-data">${c}</style>`)}else document.documentElement.className=s?o?"light":"dark":e;u.emit("theme",e)};this.imageInput=()=>i("div.image",[i("label",{attrs:{for:"dasher-theme-backgroundUrl"}},i18n.site.backgroundImageUrl),i("input#dasher-theme-backgroundUrl",{attrs:{type:"text",placeholder:"https://",value:this.getImage()},hook:v(e=>{$(e).on("change keyup paste",T(t=>{let s=e.value.trim();(s.startsWith("https://")||s.startsWith("//"))&&s.length>=10&&s.length<=400&&this.setImage(s)},300))})})]);this.galleryInput=()=>{var K,W;let{theme:e,isSystem:t,systemPrefersLight:s}=this.getThemeData(),o=t?s:e.includes("light"),h=w=>w.replace(/[^\w]/g,"_"),p=w=>{$("#dasher-theme-images-grid .selected").removeClass("selected"),$(`#${h(w)}`).addClass("selected"),this.setImage(w)},c=o?(K=this.backgroundData.gallery)==null?void 0:K.light:(W=this.backgroundData.gallery)==null?void 0:W.dark,k=window.matchMedia("(min-width: 650px)").matches?4:2,S=site.asset.url(c[`montage${k}`]),f=k*162+(c.images.length>k*4?N():0);return i("div#dasher-theme-gallery",{attrs:{style:`width: ${f}px`}},[i("div#dasher-theme-images-viewport",[i("div#dasher-theme-images-grid",{attrs:{style:`background-image: url(${S});`}},c.images.map(w=>
1{let F=site.asset.url(w),he=this.backgroundData.image.endsWith(F)?".selected":"";return i(`div#${h(F)}${he}`,{hook:l("click",()=>p(F))})}))]),this.imageInput()])};this.setVar=(e,t,s="px")=>{document.documentElement.style.setProperty(`---${e}`,`${t.toString()}${s}`)};this.propSlider=(e,t,s,o,h="px")=>{let p=this.getVar(e),c=o?o(p):`${p}${h}`;return C(`.${e}`,{title:c},[C(".slider-label",[de(t),ne(c)]),i("input.range",{key:this.sliderKey+e,attrs:{...s,type:"range",value:p},hook:v(k=>{let S=f=>{f<s.min||f>s.max||(this.setVar(e,f,h),this.redraw(),this.postPref(e))};$(k).on("input",()=>S(parseInt(k.value))).on("wheel",f=>{f.preventDefault(),S(this.getVar(e)+(f.deltaY>0?-s.step:s.step))})})})])};this.list=[{key:"system",name:i18n.site.deviceTheme},{key:"light",name:i18n.site.light},{key:"dark",name:i18n.site.dark}]}render(){let{theme:e,isTransp:t}=this.getThemeData();return C(".sub.theme",[b(i18n.site.theme,this.close),C(".selector.large",[this.list.map(s=>ae(".text",{class:{active:e.includes(s.key)},...x(d.Checkmark),title:s.title||"",type:"button",hook:l("click",()=>{this.get().includes("transp")?this.set(`transp ${s.key}`):this.set(s.key)})},s.name)),this.propSlider("ui-roundness",i18n.site.roundness,{min:0,max:15,step:1}),ee({id:"background-picture-toggle",name:i18n.site.backgroundImage,checked:t,change:()=>{let{theme:s,isTransp:o}=this.getThemeData();this.set(o?s.replace("transp ",""):`transp ${s}`)},redraw:this.redraw}),t?this.propSlider("bg-opacity",i18n.site.imageOpacity,{min:5,max:100,step:1},s=>`${s}%`,""):null]),t?this.backgroundData.gallery?this.galleryInput():this.imageInput():null])}get backgroundData(){return this.root.data.background}};var le="links",A=class{constructor(r,e){this.data=r;this.redraw=e;this.opts={playing:$("body").hasClass("playing"),zenable:$("body").hasClass("zenable")};this.mode=O(le);this.render=()=>{var r;return((r=this[this.mode()])==null?void 0:r.render())||null};this.setMode=r=>{this.mode(r),this.redraw()};this.close=()=>this.setMode(le);this.ping=new B(this),this.langs=new L(this),this.sound=new E(this),this.theme=new z(this),this.board=new I(this),this.piece=new R(this),this.links=new P(this)}};var pe=_([j,q]);function It(){return site.asset.loadEsm("dasher")}async function ue(){let n,r,t=$("#dasher_app").html(`<div class="initiating">${re}</div>`).empty()[0],s=()=>{var h;n=pe(n||t,i("div#dasher_app.dropdown",(h=r==null?void 0:r.render())!=null?h:i("div.initiating",ie())))};s();let o=await te("/dasher");return r=new A(o,s),s(),r}export{It as a,ue as b};

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.