Files
den-repo/build/den.min.js

1 line
25 KiB
JavaScript

!function(){if(!window.__denCritter){window.__denCritter=!0;var e=document.createElement("style");e.textContent='.paw-trail{position:fixed;pointer-events:none;z-index:9999;animation:pawfade 1s linear forwards;filter:drop-shadow(0 0 3px currentColor);}@keyframes pawfade{0%{opacity:.9;transform:scale(1);}100%{opacity:0;transform:scale(.5) translateY(10px);}}.emote{position:fixed;pointer-events:none;z-index:9999;font-size:15px;animation:emoterise 1.2s ease-out forwards;}.emote.say{font-size:12px;font-weight:bold;color:#c9b8ff;text-shadow:0 0 6px #8f7bff,1px 1px 0 #120a20;white-space:nowrap;font-family:"Comic Sans MS","Comic Sans",cursive;}@keyframes emoterise{0%{opacity:0;transform:translateY(0) scale(.6);}15%{opacity:1;}100%{opacity:0;transform:translateY(-34px) scale(1.15);}}.denbed{position:fixed;z-index:9998;pointer-events:none;animation:bedin .6s ease-out;transition:opacity .45s ease;}@keyframes bedin{from{opacity:0;transform:translateY(10px);}to{opacity:1;transform:translateY(0);}}.denbed .lump{animation:breathe 2.8s ease-in-out infinite;transform-origin:38px 24px;}@keyframes breathe{0%,100%{transform:scaleY(1);}50%{transform:scaleY(1.17);}}body.denzoom *,body.denzoom *::before,body.denzoom *::after{animation-duration:.22s !important;}.denhole{position:fixed;z-index:9997;pointer-events:none;transition:opacity .55s ease;animation:holein .5s ease-out;}@keyframes holein{from{opacity:0;transform:scale(.6);}to{opacity:1;transform:scale(1);}}.dentab{position:fixed;right:14px;bottom:0;text-align:left;z-index:10000;background:#1b1229;color:#8f7bff;border:2px ridge #6b5a8a;border-bottom:none;border-radius:8px 8px 0 0;font-family:"Courier New",monospace;font-size:11px;padding:3px 10px;cursor:pointer;opacity:.55;transition:opacity .2s;user-select:none;}.dentab:hover{opacity:1;}.denterm{position:fixed;right:8px;bottom:0;z-index:10000;width:300px;max-width:86vw;background:#0d0818;border:3px ridge #6b5a8a;border-bottom:none;border-radius:10px 10px 0 0;font-family:"Courier New",monospace;font-size:12px;padding:8px;display:none;text-align:left;}.denterm.open{display:block;}.denterm .dout{height:170px;overflow-y:auto;white-space:pre-wrap;word-break:break-word;color:#c9b8ff;}.denterm .dline{display:flex;gap:6px;margin-top:5px;align-items:center;}.denterm .dprompt{color:#ff6ec7;white-space:nowrap;}.denterm input{flex:1;background:transparent;border:none;outline:none;color:#a8ffe0;font-family:inherit;font-size:12px;}.denwx{position:fixed;top:0;left:0;right:0;bottom:0;pointer-events:none;z-index:9996;overflow:hidden;}.denwx i{position:absolute;top:-24px;display:block;animation-name:denfall;animation-timing-function:linear;animation-fill-mode:forwards;}.denwx i.r{width:2px;height:15px;background:linear-gradient(180deg,rgba(79,195,255,0),rgba(79,195,255,.85));border-radius:1px;}.denwx i.s{color:#fff;font-size:12px;line-height:1;}@keyframes denfall{from{transform:translateY(0);}to{transform:translateY(104vh);}}.dentreat{position:fixed;z-index:9997;pointer-events:none;font-size:19px;line-height:1;animation:denbob 1.3s ease-in-out infinite;filter:drop-shadow(0 0 4px #ffb3de);}@keyframes denbob{0%,100%{transform:translateY(0);}50%{transform:translateY(-5px);}}',document.head.appendChild(e);var t=null;if(window.denYip=ce,window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches)window.denSay=function(){};else{var n,a,i=["#8f7bff","#4fc3ff"],o=Math.floor(4*Math.random());0===o?(n=70,a=80+Math.random()*Math.max(window.innerHeight-160,1)):1===o?(n=window.innerWidth-70,a=80+Math.random()*Math.max(window.innerHeight-160,1)):2===o?(n=80+Math.random()*Math.max(window.innerWidth-160,1),a=70):(n=80+Math.random()*Math.max(window.innerWidth-160,1),a=window.innerHeight-70);var r={x:n,y:a},s=Math.random()*Math.PI*2,l={x:r.x,y:r.y},d="rest",c=performance.now()+800,h=0,m=performance.now()+99999,p=0,f=1,u=0,y=performance.now(),w=150,x=340,v=24,g=performance.now(),M=0,b=0,k=0,C=!1,T=null,A=0,Y=1,z=1300,I="clear",E=null,q=null,L=null,S=0,P=null,N=null,H=performance.now(),R=window.scrollY||window.pageYOffset||0,F=0,B=null,O=null,W=null,_=null,D=!1,U=0,V=null,j=0,X=null,G=null,J=null,Q={v:0,pets:0,treats:0,name:null,last:0,id:null};try{var Z=JSON.parse(localStorage.getItem("denmem"));Z&&"object"==typeof Z&&(Q.v=0|Z.v,Q.pets=0|Z.pets,Q.treats=0|Z.treats,Q.name="string"==typeof Z.name&&Z.name?Z.name.slice(0,16):null,Q.last=Z.last||0,"string"==typeof Z.id&&/^[a-f0-9]{16}$/.test(Z.id)&&(Q.id=Z.id))}catch(e){}var $=Q.last;if(Q.v++,Q.last=Date.now(),!Q.id){var K="";try{var ee=new Uint8Array(8);crypto.getRandomValues(ee);for(var te=0;te<8;te++)K+=("0"+ee[te].toString(16)).slice(-2)}catch(e){for(var ne=0;ne<16;ne++)K+=Math.floor(16*Math.random()).toString(16)}Q.id=K}he(),window.denSetName=function(e){return(e=String(e||"").replace(/[^\w \-]/g,"").trim().slice(0,16))?(Q.name=e,he(),ge("yip!! (i am "+e+")"),xe("\ud83d\udc96",!0),J&&(J.textContent=fe()),e):null},window.denGetName=function(){return Q.name},window.denSay=ge,window.addEventListener("scroll",function(){var e=window.scrollY||window.pageYOffset||0,t=e-R;if(R=e,!C&&!M&&t){r.y-=t;var n=!1;r.y<18?(r.y=18,n=!0):r.y>window.innerHeight-18&&(r.y=window.innerHeight-18,n=!0),n&&Math.abs(t)>45&&(F=performance.now()+2500),P&&N&&(N.y-=t,P.style.top=N.y-10+"px",(N.y<0||N.y>window.innerHeight)&&(P.remove(),P=null,N=null,"treat"===d&&(d="wander",l=Se()))),L&&(L.y-=t)}},{passive:!0}),document.addEventListener("keydown",Me),document.addEventListener("scroll",Me,{passive:!0}),document.addEventListener("touchstart",Me,{passive:!0}),document.addEventListener("mousemove",function(e){if(l.x=e.clientX,l.y=e.clientY,Me(),"errand"!==d&&"mischief"!==d&&"treat"!==d&&("shelter"!==d||"rain"!==I)){var t=performance.now();t<h||t<b||("chase"!==d&&xe("\u2757"),d="chase")}}),document.addEventListener("click",function(e){Me(),e.target.closest&&e.target.closest("a,button,input,textarea,label,select")||Math.hypot(e.clientX-r.x,e.clientY-r.y)>48||be()}),window.denWeather=Ae,window.denTreat=ze,window.denEvent=function(e,t){t=t||{};var n=performance.now();if(g=n,C&&Me(),"mischief"===d&&"mischief"!==e&&ke(),"mischief"!==e)if("rain"!==e&&"snow"!==e&&"clear"!==e){if("treat"===e){var a=Ee(t);return a||(a=Ie(r.x+(220*Math.random()-110),r.y+(160*Math.random()-80))),void ze(a.x,a.y)}if("celebrate"===e)h=n+1100,d="rest",c=n+2800,m=n+99999,xe("\u2728",!0),setTimeout(function(){xe("\ud83d\udc95",!0)},300),setTimeout(function(){xe("\u2728",!0)},650),setTimeout(function(){ge(t.text||"YIP!!")},180),ce();else if("investigate"===e){var i=Ee(t);if(!i)return;W=i,_=t.text||null,D=!!t.run,U=n+9e3,d="errand"}else if("alarm"===e){xe("\u26a0\ufe0f",!0),ge(t.text||"YIP?!");var o=Math.random()*Math.PI*2;W=Ie(r.x+260*Math.cos(o),r.y+260*Math.sin(o)),_=null,D=!0,U=n+4e3,d="errand"}else"sleepy"===e?(k=n+800,M=n+1400,ge("*yawn*")):"zoomies"===e?qe():t.text&&ge(t.text)}else Ae(e);else Ce(!0)};var ae=["ArrowUp","ArrowUp","ArrowDown","ArrowDown","ArrowLeft","ArrowRight","ArrowLeft","ArrowRight","b","a"],ie=0;document.addEventListener("keydown",function(e){var t=1===e.key.length?e.key.toLowerCase():e.key;(ie=t===ae[ie]?ie+1:t===ae[0]?1:0)===ae.length&&(ie=0,qe())});var oe="";document.addEventListener("keydown",function(e){var t=e.target;t&&("INPUT"===t.tagName||"TEXTAREA"===t.tagName||t.isContentEditable)||1===e.key.length&&("yip"===(oe=(oe+e.key.toLowerCase()).slice(-12)).slice(-3)?(ge("yip!!"),oe=""):"owo"===oe.slice(-3)?(ge("*notices u*"),oe=""):"uwu"===oe.slice(-3)?(ge("yip (no)"),oe=""):"kobold"===oe.slice(-6)?(xe("\ud83d\udc95",!0),ge("yip!! (that is me)"),oe=""):"shrine"===oe.slice(-6)?(ge("YIP?! (how do u know about that)"),oe=""):"zoomies"===oe.slice(-7)?(qe(),oe=""):"sleep"===oe.slice(-5)&&(k=performance.now()+800,M=performance.now()+1400,ge("*yawn*"),oe=""))});var re=document.createElement("div");re.className="dentab",re.textContent=">_ den";var se=document.createElement("div");se.className="denterm",se.innerHTML='<div class="dout">den shell v2 (now portable)\ntype "help"\n</div><div class="dline"><span class="dprompt"></span><input autocomplete="off" spellcheck="false" aria-label="den shell input"></div>';var le=0,de=document.createElement("div");de.className="denhole",de.innerHTML='<svg width="56" height="34" viewBox="0 0 56 34" xmlns="http://www.w3.org/2000/svg"><ellipse cx="28" cy="17" rx="26" ry="14" fill="#0d0818" stroke="#8f7bff" stroke-width="2.5"/><ellipse cx="28" cy="19" rx="18" ry="8" fill="#000"/><ellipse cx="20" cy="10" rx="4" ry="1.6" fill="#3d2a55"/></svg>',de.style.left=r.x-28+"px",de.style.top=r.y-17+"px",document.body?Fe():document.addEventListener("DOMContentLoaded",Fe),requestAnimationFrame(function e(t){var n=Math.min((t-y)/1e3,.05);y=t;var a=Y;if(C)return t>A&&(xe("\ud83d\udca4",!0),A=t+2600),void requestAnimationFrame(e);if(M){if(t<M){s+=7*n;var i=49*n;r.x+=Math.cos(s)*i,r.y+=Math.sin(s)*i,(u+=i)>=.8*v&&(u=0,Pe())}else M=0,C=!0,r.x=Math.min(Math.max(r.x,44),window.innerWidth-44),r.y=Math.min(Math.max(r.y,40),window.innerHeight-30),(T=document.createElement("div")).className="denbed",T.innerHTML='<svg width="64" height="42" viewBox="0 0 64 42" xmlns="http://www.w3.org/2000/svg"><rect x="2" y="24" width="60" height="11" rx="5" fill="#3d2a55" stroke="#8f7bff" stroke-width="2"/><rect x="3" y="33" width="4" height="8" rx="1" fill="#8f7bff"/><rect x="57" y="33" width="4" height="8" rx="1" fill="#8f7bff"/><ellipse cx="13" cy="22" rx="9" ry="5" fill="#c9b8ff"/><path class="lump" d="M23 26 Q33 10 53 23 L53 26 Z" fill="#4fc3ff" stroke="#8f7bff" stroke-width="1.5"/></svg>',T.style.left=r.x-32+"px",T.style.top=r.y-26+"px",document.body.appendChild(T),ge("...zzz"),A=t+1800;requestAnimationFrame(e)}else{if(t-g>6e5&&t>h)return M=t+1400,ge("*yawn*"),void requestAnimationFrame(e);if(t<b)requestAnimationFrame(e);else{if(t<h){s+=9*n;var o=63*a*n;return r.x+=Math.cos(s)*o,r.y+=Math.sin(s)*o,(u+=o)>=.8*v&&(u=0,Pe()),void requestAnimationFrame(e)}if("mischief"!==d)if("shelter"!==d)if("treat"!==d)if("errand"!==d){var p=l.x-r.x,f=l.y-r.y,k=Math.hypot(p,f);if("chase"===d)k<26&&(d="rest",c=t+(me()>=25?4200:2500),m=t+1700,t<F?(F=0,ge("*wheeze* (u went so far)")):Math.random()<.5&&xe(me()>=10?"\ud83d\udc95":"\u2728"));else if("rest"===d)t>m&&(xe("\ud83d\udca4"),m=t+1600),pe()&&t>S&&(xe("\ud83c\udf56"),S=t+9e3),t>c&&("rain"===I&&Ye()||Ce(!1)||(l=Se(),d="wander"));else if(k<14)if(d="rest",m=t+99999,B)c=t+1200+1600*Math.random(),ge(B),B=null;else{c=t+600+1600*Math.random();var z=pe()&&Math.random()<.55?ve(["yip (hungry)","(food?)","yip? (snacks)"]):Q.v>=3&&0===me()&&Math.random()<.4?ve(["yip...","(is anyone there)","yip? (hello?)"]):me()>=25&&Math.random()<.4?ve(["yip (comfy)","uwu","yip yip (good day)"]):null;z?ge(z):xe(ve(["\ud83d\udc43","\u2753","\ud83c\udf38","\u2728","\ud83d\udc3e"]))}if("rest"!==d&&k>1){var E=Math.atan2(f,p),q=4*n*("chase"===d?2.2:1);s+=Math.max(-q,Math.min(q,Le(s,E)));var R="chase"===d&&k>160,O=("chase"===d?R?x:w:70)*a,j=R?38:v,X=Math.min(O*n,k);r.x+=Math.cos(s)*X,r.y+=Math.sin(s)*X,(u+=X)>=j&&(u=0,Pe())}requestAnimationFrame(e)}else{if(!W||t>U)W=null,d="wander",l=Se();else{var G=W.x-r.x,J=W.y-r.y,Z=Math.hypot(G,J);if(Z<16)_?ge(_):xe(ve(["\ud83d\udc43","\u2753"])),W=null,_=null,d="rest",c=t+1500,m=t+99999;else{var $=Math.atan2(J,G),K=4*n*2.2;s+=Math.max(-K,Math.min(K,Le(s,$)));var ee=(D?x:w)*a,te=D?38:v,ne=Math.min(ee*n,Z);r.x+=Math.cos(s)*ne,r.y+=Math.sin(s)*ne,(u+=ne)>=te&&(u=0,Pe())}}requestAnimationFrame(e)}else{if(N&&P){var ae=N.x-r.x,ie=N.y-r.y,oe=Math.hypot(ae,ie);if(oe<15)P.remove(),P=null,N=null,H=t,Q.treats++,he(),xe("\ud83d\udc96",!0),ge(ve(["*nom nom* yip!!","yip!! (thank u)","(best day)"])),ce(),d="rest",c=t+2600,m=t+99999;else{var re=Math.atan2(ie,ae),se=4*n*2.4;s+=Math.max(-se,Math.min(se,Le(s,re)));var le=Math.min(x*Y*n,oe);r.x+=Math.cos(s)*le,r.y+=Math.sin(s)*le,(u+=le)>=38&&(u=0,Pe())}}else d="wander",l=Se();requestAnimationFrame(e)}else{if("rain"!==I)L=null,d="wander",l=Se();else if(L){var de=L.x-r.x,fe=L.y-r.y,ue=Math.hypot(de,fe);if(ue<14)t>S&&(S=t+3200+2600*Math.random(),Math.random()<.5?xe(ve(["\u2614","\ud83d\udca7"])):ge(ve(["yip... (waiting it out)","(damp)","yip (i do not like this)"])));else{var ye=Math.atan2(fe,de),we=4*n*2.2;s+=Math.max(-we,Math.min(we,Le(s,ye)));var Me=(ue>150?x:w)*Y,be=Math.min(Me*n,ue);r.x+=Math.cos(s)*be,r.y+=Math.sin(s)*be,(u+=be)>=(ue>150?38:v)&&(u=0,Pe())}}else Ye()||(d="wander",l=Se());requestAnimationFrame(e)}else{if(!V)return d="wander",l=Se(),void requestAnimationFrame(e);if(t>V.deadline){if("carry"!==V.phase)return ke(),void requestAnimationFrame(e);V.phase="dropped",V.dropTime=t,V.deadline=t+12e3,ge(V.gift?"*wheeze* (u are fast. here)":"*wheeze* (fine)")}if("togo"===V.phase||"carry"===V.phase){var Te,Ae=(Te="togo"===V.phase?V.pt:V.gift?Ie(l.x,l.y):V.dropPt).x-r.x,ze=Te.y-r.y,Ee=Math.hypot(Ae,ze);if(Ee<16)"togo"===V.phase?function(){var e=V.el.getBoundingClientRect();V.clone=document.createElement("div"),V.clone.style.cssText="position:fixed;z-index:9998;pointer-events:none;margin:0;left:"+e.left+"px;top:"+e.top+"px;width:"+e.width+"px;height:"+e.height+"px;";var t=V.el.cloneNode(!0);if(t.style.margin="0",V.clone.appendChild(t),document.body.appendChild(V.clone),V.el.style.visibility="hidden",V.cw=e.width/2,V.ch=e.height,V.gift)ge("yip!");else{var n=Math.random()*Math.PI*2;V.dropPt=Ie(r.x+300*Math.cos(n),r.y+300*Math.sin(n)),ge(ve(["yip yip yip (mine now)","(catch me)","yip!! (tax)"]))}V.phase="carry"}():(V.phase="dropped",V.dropTime=t,V.gift?(ge(ve(["uwu (for u)","yip (i brought u this)","(i love u)"])),xe("\ud83d\udc95",!0),setTimeout(function(){xe("\ud83d\udc96",!0)},300)):ge(ve(["yip (u can have it back)","(hehe)","yip yip (a good crime)"])));else{var qe=Math.atan2(ze,Ae),Ne=4*n*2.2;s+=Math.max(-Ne,Math.min(Ne,Le(s,qe)));var He=("carry"!==V.phase||V.gift?w:x)*a,Re="carry"!==V.phase||V.gift?v:38,Fe=Math.min(He*n,Ee);r.x+=Math.cos(s)*Fe,r.y+=Math.sin(s)*Fe,(u+=Fe)>=Re&&(u=0,Pe())}V&&V.clone&&"carry"===V.phase&&(V.clone.style.left=r.x-V.cw+"px",V.clone.style.top=r.y-V.ch-14+"px")}else if("dropped"===V.phase){if(t>V.dropTime+(V.gift?4200:5200)){var Be=V.el.getBoundingClientRect();V.clone.style.transition="left .6s ease, top .6s ease, opacity .6s ease",V.clone.style.left=Be.left+"px",V.clone.style.top=Be.top+"px",V.phase="returning",V.retTime=t,V.gift||ge("yip (fine. take it back)")}}else"returning"===V.phase&&t>V.retTime+700&&(xe("\u2728",!0),ke());requestAnimationFrame(e)}}}})}}function ce(){try{t||(t=new(window.AudioContext||window.webkitAudioContext)),"suspended"===t.state&&t.resume();var e=t.createOscillator(),n=t.createGain(),a=t.currentTime;e.type="sine",e.frequency.setValueAtTime(700+200*Math.random(),a),e.frequency.exponentialRampToValueAtTime(1400+300*Math.random(),a+.07),e.frequency.exponentialRampToValueAtTime(600,a+.14),n.gain.setValueAtTime(.12,a),n.gain.exponentialRampToValueAtTime(.001,a+.16),e.connect(n),n.connect(t.destination),e.start(a),e.stop(a+.18)}catch(e){}}function he(){try{localStorage.setItem("denmem",JSON.stringify(Q))}catch(e){}}function me(){return Q.pets+Q.treats}function pe(){return performance.now()-H>24e4}function fe(){return(Q.name||"guest")+"@den ~>"}function ue(e){return e<=0?"just u + the kobold rn":1===e?"1 other is here rn":e+" others are here rn"}function ye(){window.fetch&&fetch("/den.php?id="+Q.id,{cache:"no-store"}).then(function(e){return e.ok?e.json():null}).then(function(e){if(e){var t=0|e.others;window.denOthers=t;for(var n=document.querySelectorAll("[data-den-others]"),a=0;a<n.length;a++)n[a].textContent=ue(t)}}).catch(function(){})}function we(){for(var e=[],t=document.querySelectorAll("[data-den-poi]"),n=0;n<t.length;n++){var a=t[n].getBoundingClientRect();a.width<10||a.height<10||a.bottom<40||a.top>window.innerHeight-40||a.right<40||a.left>window.innerWidth-40||e.push({el:t[n],r:a})}return e}function xe(e,t){var n=performance.now();if(t||!(n-p<500)){p=n;var a=document.createElement("span");a.className="emote",a.textContent=e,a.style.left=r.x+(16*Math.random()-8)+"px",a.style.top=r.y-18+"px",document.body.appendChild(a),setTimeout(function(){a.remove()},1250)}}function ve(e){return e[Math.floor(Math.random()*e.length)]}function ge(e){var t=document.createElement("span");t.className="emote say",t.textContent=e,t.style.left=r.x-10+"px",t.style.top=r.y-22+"px",document.body.appendChild(t),setTimeout(function(){t.remove()},1250)}function Me(){var e=performance.now();if(!(e<k)&&(g=e,M&&(M=0),C)){if(C=!1,T){var t=T;T=null,t.style.opacity="0",setTimeout(function(){t.remove()},500)}xe("\u2728",!0),ge("...yip?"),b=e+900}}function be(){var e=performance.now();"mischief"===d&&ke(),h=e+800,d="rest",c=e+2e3,m=e+99999,xe(ve(["\ud83d\udc95","\ud83d\udc96","\ud83d\udc97"]),!0),setTimeout(function(){xe("\ud83d\udc95",!0)},240),ce(),Q.pets++,he(),10===Q.pets?setTimeout(function(){ge("yip!! (we are friends now)")},420):25===Q.pets?setTimeout(function(){ge("yip (best friend)")},420):50===Q.pets?setTimeout(function(){ge("yip!! (bonded 4 life)")},420):100===Q.pets&&setTimeout(function(){ge("yip (soulmates)")},420)}function ke(){V&&V.clone&&(V.el.style.visibility="",V.clone.remove()),V&&(V=null,d="wander",l=Se())}function Ce(e){var t=performance.now();if(V)return!1;if(!e&&t-j<15e4)return!1;var n=function(){for(var e=[],t=document.querySelectorAll("[data-den-steal]"),n=0;n<t.length;n++){var a=t[n].getBoundingClientRect();a.width<8||a.width>220||a.height<8||a.height>90||a.bottom<40||a.top>window.innerHeight-60||a.right<40||a.left>window.innerWidth-60||"hidden"!==t[n].style.visibility&&e.push(t[n])}return e}();if(!n.length)return!1;if(!e&&Math.random()>.07)return!1;var a=n[Math.floor(Math.random()*n.length)],i=a.getBoundingClientRect();return V={el:a,phase:"togo",pt:Ie(i.left+i.width/2,i.top+i.height/2),deadline:t+18e3,gift:me()>=25},j=t,d="mischief",!0}function Te(){if(q){var e="rain"===I,t=document.createElement("i");t.className=e?"r":"s",e||(t.textContent="\u2744"),t.style.left=100*Math.random()+"vw";var n=e?.55+.35*Math.random():3.2+3.4*Math.random();t.style.animationDuration=n+"s",t.style.opacity=e?.3+.45*Math.random():.5+.5*Math.random(),q.appendChild(t),setTimeout(function(){t.remove()},1e3*n+300)}}function Ae(e){if("rain"!==e&&"snow"!==e&&(e="clear"),e!==I){if(I=e,E&&(clearInterval(E),E=null),q){var t=q;q=null,t.remove()}if(z="snow"===e?4200:1300,"clear"===e)return L=null,void("shelter"===d&&(d="wander",l=Se(),ge("yip!! (it stopped)")));(q=document.createElement("div")).className="denwx",document.body.appendChild(q),E=setInterval(Te,"rain"===e?85:240),C&&Me(),"rain"===e?(ge("yip?! (wet)"),xe("\u2614",!0),Ye()):(ge("YIP!! (snow!!)"),xe("\u2744",!0),Y=1.6,setTimeout(function(){1.6===Y&&(Y=1)},6e3))}}function Ye(){var e=we();if(!e.length)return L=null,!1;for(var t=null,n=1/0,a=0;a<e.length;a++){var i=e[a].r,o=i.left+.5*i.width,s=i.top+Math.min(.5*i.height,45),l=Math.hypot(o-r.x,s-r.y);l<n&&(n=l,t={x:o,y:s})}return!!t&&(L=Ie(t.x,t.y),S=performance.now()+2200,d="shelter",!0)}function ze(e,t){P&&(P.remove(),P=null),N=Ie(e,t),(P=document.createElement("div")).className="dentreat",P.textContent="\ud83c\udf56",P.style.left=N.x-10+"px",P.style.top=N.y-10+"px",document.body.appendChild(P),C&&Me(),V&&ke(),xe("\u2757",!0),d="treat"}function Ie(e,t){return{x:Math.min(Math.max(e,20),window.innerWidth-20),y:Math.min(Math.max(t,20),window.innerHeight-20)}}function Ee(e){var t=e.el;if("string"==typeof t&&(t=document.querySelector(t)),t&&t.getBoundingClientRect){var n=t.getBoundingClientRect();if(n.width>0)return Ie(n.left+.5*n.width,n.top+Math.min(.4*n.height,50))}return"number"==typeof e.x&&"number"==typeof e.y?Ie(e.x,e.y):null}function qe(){document.body.classList.add("denzoom"),Y=7.5;var e=document.title;document.title="YIP YIP YIP YIP YIP",ge("YIP YIP YIP YIP"),setTimeout(function(){document.body.classList.remove("denzoom"),Y=1,document.title=e},1e4)}function Le(e,t){var n=(t-e)%(2*Math.PI);return n>Math.PI&&(n-=2*Math.PI),n<-Math.PI&&(n+=2*Math.PI),n}function Se(){if(B=null,Math.random()<.45){var e=we().filter(function(e){return e.el!==O});if(e.length){var t=e[Math.floor(Math.random()*e.length)];O=t.el;var n=(t.el.getAttribute("data-den-poi")||"").split("|").filter(Boolean);return n.length&&(B=n[Math.floor(Math.random()*n.length)]),{x:Math.min(Math.max(t.r.left+t.r.width*(.25+.5*Math.random()),20),window.innerWidth-20),y:Math.min(Math.max(t.r.top+Math.min(.4*t.r.height,60)+20*Math.random(),20),window.innerHeight-20)}}}var a=60+120*Math.random(),i=s+2.6*(Math.random()-.5);return{x:Math.min(Math.max(r.x+Math.cos(i)*a,20),window.innerWidth-20),y:Math.min(Math.max(r.y+Math.sin(i)*a,20),window.innerHeight-20)}}function Pe(){f=-f;var e=document.createElement("span");e.className="paw-trail",e.innerHTML='<svg width="14" height="15" viewBox="0 0 20 21" xmlns="http://www.w3.org/2000/svg"><ellipse cx="10" cy="14.5" rx="5.2" ry="4.6"/><ellipse cx="3.2" cy="8.6" rx="2.1" ry="2.7"/><ellipse cx="7.6" cy="5.4" rx="2.1" ry="2.8"/><ellipse cx="12.4" cy="5.4" rx="2.1" ry="2.8"/><ellipse cx="16.8" cy="8.6" rx="2.1" ry="2.7"/></svg>';var t=i[f>0?0:1];e.querySelector("svg").style.fill=t,e.style.color=t;var n=180*s/Math.PI+90,a=7*-Math.sin(s)*f,o=7*Math.cos(s)*f;e.style.left=r.x+a-7+"px",e.style.top=r.y+o-7+"px",e.querySelector("svg").style.transform="rotate("+n+"deg) scaleX("+f+")",e.querySelector("svg").style.display="block",document.body.appendChild(e),setTimeout(function(){e.remove()},z)}function Ne(e){X.textContent+=e+"\n",X.scrollTop=X.scrollHeight}function He(){se.classList.add("open"),re.style.display="none",G.focus()}function Re(){se.classList.remove("open"),re.style.display=""}function Fe(){document.body.appendChild(re),document.body.appendChild(se),X=se.querySelector(".dout"),G=se.querySelector("input"),(J=se.querySelector(".dprompt")).textContent=fe(),re.addEventListener("click",He),G.addEventListener("keydown",function(e){if("Escape"!==e.key){if("Enter"===e.key){var t=G.value.trim();G.value="",t&&(Ne(fe()+" "+t),function(e){var t=e.toLowerCase();if(0!==t.indexOf("name "))if("name"!==t)if(0!==t.indexOf("sudo"))if(0!==t.indexOf("rm ")&&"rm"!==t)switch(t){case"help":Ne("commands: pet, treat, come, sit, fetch, rain, snow, sun, sleep, wake, zoomies, where, status, name <x>, ls, whoami, pwd, neofetch, yip, clear, exit");break;case"pet":case"pet kobold":le++,be(),Ne(le>=5?"*yip yip yip* (maximum happiness. further pets stored for later)":"*pets dispensed remotely* yip!");break;case"fetch":Ce(!0)?Ne(me()>=25?"he goes to find u something":"oh no"):Ne(V?"his paws are full":"nothing here worth taking. sad");break;case"treat":var n=se.getBoundingClientRect();ze(Math.max(n.left-60,40),Math.max(n.top-50,40)),Ne(pe()?"he was waiting for this":"a treat appears. he has noticed");break;case"rain":Ae("rain"),Ne("it rains. he does not care for it");break;case"snow":Ae("snow"),Ne("it snows. he cares for it a great deal");break;case"sun":case"clear":Ae("clear"),Ne("the sky clears");break;case"come":var a=se.getBoundingClientRect();l={x:Math.min(Math.max(a.left+40,20),window.innerWidth-20),y:Math.min(Math.max(a.top-40,20),window.innerHeight-20)},C&&Me(),d="chase",Ne("he is on his way");break;case"sit":d="rest",c=performance.now()+6e3,m=performance.now()+99999,ge("yip (sitting)"),Ne("he sits. a good boy");break;case"sleep":k=performance.now()+800,M=performance.now()+1400,ge("*yawn*"),Ne("bedtime initiated");break;case"wake":C?(Me(),Ne("he stirs")):Ne("he is already awake and probably watching u");break;case"zoomies":qe(),Ne("oh no");break;case"where":ge("yip!! (here)"),xe("\u2728",!0),Ne("listen for the yip");break;case"status":Ne("mode: "+(C?"asleep":d)+" | pets: "+Q.pets+" | treats: "+Q.treats+" | name: "+(Q.name||"(unnamed)")+" | visits: "+Q.v+" | weather: "+I+(pe()?" | hungry":""));break;case"ls":Ne("den/ hoard/ guestbook.txt do_not_open/ retopo_FINAL_v2/");break;case"whoami":Ne("a guest in the den");break;case"pwd":Ne("/home/den/u");break;case"yip":ge("yip!!"),Ne("yip!!");break;case"neofetch":Ne(" /\\_/\\ guest@den\n ( o.o ) ----------\n > ^ < OS: DenOS (yes it is just apache)\n kobold btw Shell: den shell 2.0\n Uptime: emotionally? unclear");break;case"clear":X.textContent="";break;case"exit":Ne("u can check out any time u like..."),setTimeout(Re,600);break;default:Ne("fish: Unknown command: '"+e.split(" ")[0].replace(/[^\w.-]/g,"")+"'")}else Ne("rm: the hoard is load-bearing. request denied");else Ne("no.");else Ne(Q.name?'the kobold is named "'+Q.name+'"':"the kobold has no name yet. try: name <something>");else{var i=window.denSetName(e.slice(5));Ne(i?'the kobold accepts the name "'+i+'". this is legally binding':"that name did not survive processing. try letters")}}(t))}}else Re()}),ye(),setInterval(ye,6e4),document.body.appendChild(de),setTimeout(function(){var e;xe("\u2728",!0),ge((e=$?Date.now()-$:0,Q.v<=1?"*yip* (hello)":e>6048e5?"YIP!! (where were u)":Q.name?"*yip* ("+Q.name+" missed u)":Q.v>=8?"yip (welcome home)":"yip!! (u came back)"));var t=window.innerWidth/2,n=window.innerHeight/2,a=Math.atan2(n-r.y,t-r.x);s=a;var i=160+120*Math.random();l={x:Math.min(Math.max(r.x+Math.cos(a)*i,20),window.innerWidth-20),y:Math.min(Math.max(r.y+Math.sin(a)*i,20),window.innerHeight-20)},B=null,d="wander"},700),setTimeout(function(){de.style.opacity="0",setTimeout(function(){de.remove()},600)},2600),setTimeout(function(){var e=0|window.denOthers;e>0&&ge("yip ("+e+(1===e?" other is":" others are")+" here... i can smell them)")},9e3)}}();