busybits 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/CHANGELOG.md +21 -0
  3. package/README.es.md +27 -27
  4. package/README.fr.md +26 -26
  5. package/README.md +63 -34
  6. package/README.pt-BR.md +28 -28
  7. package/dist/build.json +2 -2
  8. package/dist/cli/busybits.js +302 -35
  9. package/dist/client/bundle/app-BXRp9yel.js +24 -0
  10. package/dist/client/bundle/{app-CoDOLwxe.css → app-Y2N0l58V.css} +1 -1
  11. package/dist/client/bundle/city-SSVRvwxu.js +1 -0
  12. package/dist/client/bundle/{daystats-DGzYOP8l.js → daystats-B5wgtYEK.js} +1 -1
  13. package/dist/client/bundle/{dom-D2vx0KTo.js → dom-DTwIMOMe.js} +1 -1
  14. package/dist/client/bundle/{en-DBfNt5uV.js → en-C1UkXkY6.js} +25 -5
  15. package/dist/client/bundle/{es-pnWdszTE.js → es-DrTXrvU-.js} +25 -5
  16. package/dist/client/bundle/{format-C7qb6Cn-.js → format-COWnO8aN.js} +1 -1
  17. package/dist/client/bundle/{fr-CY8q9pj4.js → fr-DSvgQnax.js} +25 -5
  18. package/dist/client/bundle/{main-DktU0GfB.js → main-CjRdSA5N.js} +2 -2
  19. package/dist/client/bundle/{ptypane-NIZ2Y8QM.js → ptypane-BU6MDOyh.js} +1 -1
  20. package/dist/client/bundle/{room-name-CFJfHE5L.js → room-name-DefEKN7q.js} +1 -1
  21. package/dist/client/bundle/{simulator-BnBPS_Ws.js → simulator-BhSq5TwZ.js} +1 -1
  22. package/dist/client/bundle/world-model-D6tSJZPE.js +1 -0
  23. package/dist/client/bundle/{world-stream-BRkL9Eme.js → world-stream-pGb-glkT.js} +1 -1
  24. package/dist/client/index.html +1 -1
  25. package/dist/server/index.js +1030 -450
  26. package/mod/README.md +144 -144
  27. package/mod/habblaud/.claude-plugin/plugin.json +1 -1
  28. package/mod/habblaud-mensagens/.claude-plugin/plugin.json +1 -1
  29. package/mod/habblaud-permissoes/.claude-plugin/plugin.json +1 -1
  30. package/mod/habblaud-pi/package.json +1 -1
  31. package/package.json +7 -2
  32. package/dist/client/bundle/app-AwZeKIeu.js +0 -24
  33. package/dist/client/bundle/city-YoIG0FsX.js +0 -1
  34. package/dist/client/bundle/world-model-BIYmgAWC.js +0 -1
@@ -1 +0,0 @@
1
- import{a as e,s as t}from"./main-DktU0GfB.js";import{c as n,l as r}from"./simulator-BnBPS_Ws.js";import{$ as i,Dt as a,K as o,Mt as s,Nt as c,Q as l,Tt as u,V as d,W as f,X as p,Xt as m,Z as h,Zt as g,ct as _,dt as v,et as y,ft as b,ht as x,it as S,kt as C,lt as w,nt as T,ot as E,pt as ee,q as D,rt as O,st as k,tt as A,ut as te,wt as j}from"./world-model-BIYmgAWC.js";import{l as M,r as N,s as P}from"./dom-D2vx0KTo.js";import{A as F,B as I,C as L,D as R,E as ne,F as re,G as ie,H as ae,I as oe,K as se,L as z,M as ce,N as le,O as ue,P as B,R as V,S as de,T as fe,U as pe,V as me,W as H,a as he,b as ge,c as _e,d as ve,i as ye,j as be,k as xe,l as Se,n as Ce,o as we,q as Te,r as Ee,s as De,u as Oe,v as ke,w as Ae,x as je,y as Me,z as Ne}from"./app-AwZeKIeu.js";function Pe(e){if(!e||!/^[A-Za-z]{2}$/.test(e))return``;let t=e.toUpperCase();return String.fromCodePoint(127462+t.charCodeAt(0)-65,127462+t.charCodeAt(1)-65)}function Fe(t){if(!t||!/^[A-Za-z]{2}$/.test(t))return``;try{return new Intl.DisplayNames([e()],{type:`region`}).of(t.toUpperCase())??t.toUpperCase()}catch{return t.toUpperCase()}}function Ie(t){let n=/^(\d{4})-(\d{2})$/.exec(t??``);if(!n)return``;let r=Number(n[1]),i=Number(n[2]);if(i<1||i>12)return``;try{return new Intl.DateTimeFormat(e(),{month:`long`,year:`numeric`}).format(new Date(r,i-1,1))}catch{return`${n[2]}/${n[1]}`}}function Le(e){let n=Number.isFinite(e)?Math.max(0,Math.floor(e)):0;return n===0?t(`só o térreo`):n>24?t(`{0} andares`,[`24+`]):n===1?t(`1 andar`):t(`{0} andares`,[n])}function Re(n){let r=Number.isFinite(n)?Math.max(0,Math.floor(n)):0;return r===1?t(`1 curtida`):t(`{0} curtidas`,[r.toLocaleString(e())])}function ze(e,n=null){let r=e.state===`online`;return{owner:e.owner.name,flag:Pe(e.owner.country),country:Fe(e.owner.country),online:r,state:t(r?`Luzes acesas`:`Luzes apagadas`),floors:Le(e.floors),agents:e.agents?{working:e.agents.working,waiting:e.agents.waiting,idle:e.agents.idle}:null,likes:Re(e.likes),since:Ie(e.sinceMonth),closed:e.closed===!0,mine:!!n&&e.id===n}}function Be(e,t){return{name:e.name,flag:Pe(e.country),country:Fe(e.country),traits:(e.traits??[]).filter(u).map(e=>({emoji:j[e].emoji,label:j[e].label,desc:j[e].desc})),intro:e.intro?f(e.intro):``,likes:Re(e.likesReceived),building:t?{id:t.id,floors:Le(t.floors),online:t.state===`online`}:null,hasBuilding:!!e.buildingId}}var Ve=class{actions;el;title;flag;sub;body;avatar;closeBtn;kind=null;id=null;pinned=!1;sig=``;constructor(e){this.actions=e,this.avatar=N(`span`,{class:`ui-city-card__avatar`,hidden:!0,attrs:{"aria-hidden":`true`}}),this.flag=N(`span`,{class:`ui-city-card__flag`,attrs:{"aria-hidden":`true`}}),this.title=N(`strong`,{class:`ui-city-card__title`}),this.sub=N(`div`,{class:`ui-city-card__sub`}),this.body=N(`div`,{class:`ui-city-card__body`}),this.closeBtn=N(`button`,{class:`ui-city-card__close`,type:`button`,title:t(`Fechar`),attrs:{"aria-label":t(`Fechar`)},text:`×`,on:{click:()=>this.hide()}}),this.el=N(`section`,{class:`ui-city-card`,hidden:!0,role:`dialog`,attrs:{"aria-live":`polite`,"aria-label":t(`Cartão`)}},N(`div`,{class:`ui-city-card__head`},this.avatar,N(`div`,{class:`ui-city-card__names`},N(`div`,{class:`ui-city-card__line`},this.flag,this.title),this.sub),this.closeBtn),this.body)}get open(){return this.kind!==null}hide(){this.kind=null,this.id=null,this.pinned=!1,this.sig=``,this.el.hidden=!0}showBuilding(e,n,r,i){let a=ze(e,n),o=`b|${e.id}|${JSON.stringify(a)}`;if(this.kind=`building`,this.id=e.id,this.pinned=i||this.pinned&&this.id===e.id,this.el.classList.toggle(`is-pinned`,this.pinned),o!==this.sig){this.sig=o,P(this.avatar,!0),M(this.flag,a.flag),this.flag.title=a.country,M(this.title,a.owner),M(this.sub,[a.mine?t(`Seu prédio`):``,a.country].filter(Boolean).join(` · `)),this.el.classList.toggle(`is-online`,a.online);let n=[];n.push(N(`div`,{class:`ui-city-card__row`},N(`span`,{class:`ui-city-card__dot ${a.online?`is-on`:`is-off`}`}),N(`span`,{text:a.state}),N(`span`,{class:`ui-city-card__sep`,text:`·`}),N(`span`,{text:a.floors}))),a.agents?n.push(N(`div`,{class:`ui-city-card__agents`},N(`span`,{class:`ui-city-card__agent is-working`,title:t(`Agentes trabalhando`)},N(`b`,{text:String(a.agents.working)}),` ${t(`trabalhando`)}`),N(`span`,{class:`ui-city-card__agent is-waiting`,title:t(`Agentes esperando o dono`)},N(`b`,{text:String(a.agents.waiting)}),` ${t(`esperando`)}`),N(`span`,{class:`ui-city-card__agent is-idle`,title:t(`Agentes à toa`)},N(`b`,{text:String(a.agents.idle)}),` ${t(`à toa`)}`))):n.push(N(`div`,{class:`ui-city-card__muted`,text:t(`Modo discreto: o dono não mostra os agentes.`)})),a.closed&&n.push(N(`div`,{class:`ui-city-card__muted`,text:`🔒 ${t(`Fechado a visitas`)}`})),n.push(N(`div`,{class:`ui-city-card__row ui-city-card__foot`},N(`span`,{text:`❤️ ${a.likes}`}),a.since?N(`span`,{class:`ui-city-card__since`,text:t(`No mundo desde {0}`,[a.since])}):null));let r=this.actions.enter;if(a.mine&&r){let i=e.id;n.push(N(`button`,{class:`ui-city-card__link`,type:`button`,text:`👁 ${t(`Ver como os outros veem`)}`,on:{click:()=>r(i)}}))}let i=this.actions.extras?.(`building`,e.id);i&&n.push(i),this.body.replaceChildren(...n)}this.place(r),this.el.hidden=!1}showPlayer(e,r,i){let a=Be(e,r),o=`p|${e.id}|${JSON.stringify(a)}|${JSON.stringify(e.parts)}`;if(this.kind=`player`,this.id=e.id,this.pinned=!0,this.el.classList.add(`is-pinned`),this.el.classList.remove(`is-online`),o!==this.sig){this.sig=o,P(this.avatar,!1);try{let t=Te(n(e.id),{look:e.look,parts:e.parts,scale:2});t.className=`ui-city-card__avatar-img`,this.avatar.replaceChildren(t)}catch{this.avatar.replaceChildren()}M(this.flag,a.flag),this.flag.title=a.country,M(this.title,a.name),M(this.sub,a.country);let r=[];a.intro&&r.push(N(`div`,{class:`ui-city-card__intro`,text:`“${a.intro}”`})),a.traits.length&&r.push(N(`div`,{class:`ui-city-card__traits`},...a.traits.map(e=>N(`span`,{class:`ui-trait`,title:e.desc,text:`${e.emoji} ${e.label}`}))));let i=N(`div`,{class:`ui-city-card__row ui-city-card__foot`},N(`span`,{text:`❤️ ${t(`{0} recebidas`,[a.likes])}`}));if(a.building){let e=a.building;i.append(N(`button`,{class:`ui-city-card__link`,type:`button`,text:`🏢 ${t(`Ver o prédio`)} (${e.floors})`,on:{click:()=>this.actions.showBuilding(e.id)}}))}else i.append(N(`span`,{class:`ui-city-card__muted`,text:a.hasBuilding?t(`Prédio longe daqui`):t(`Ainda sem prédio`)}));r.push(i);let s=this.actions.extras?.(`player`,e.id);s&&r.push(s),this.body.replaceChildren(...r)}i&&this.place(i),this.el.hidden=!1}place(e){let t=window.innerWidth,n=window.innerHeight,r=this.el.offsetWidth||260,i=this.el.offsetHeight||140;if(t<=520){this.el.style.transform=``,this.el.classList.add(`is-docked`);return}this.el.classList.remove(`is-docked`);let a=this.actions.topInset()+8,o=e.x+16,s=e.y-i-12;o+r>t-8&&(o=e.x-r-16),s<a&&(s=e.y+18),o=Math.max(8,Math.min(t-r-8,o)),s=Math.max(a,Math.min(n-i-8,s)),this.el.style.transform=`translate(${Math.round(o)}px, ${Math.round(s)}px)`}},He=6,Ue={ArrowUp:[0,-1],ArrowDown:[0,1],ArrowLeft:[-1,0],ArrowRight:[1,0],w:[0,-1],s:[0,1],a:[-1,0],d:[1,0]};function We(e){let t=e;return!!t&&(t.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName??``)||t.getAttribute?.(`role`)===`radio`)}function Ge(e,t){let n=0,r=0;for(let t of e){let e=Ue[t];e&&(n+=e[0],r+=e[1])}return{dx:Math.sign(n),dy:Math.sign(r),run:t}}function Ke(e){if(Ue[e.key])return e.key;let t=e.key.length===1?e.key.toLowerCase():e.key;return Ue[t]?t:e.code===`KeyW`?`w`:e.code===`KeyA`?`a`:e.code===`KeyS`?`s`:e.code===`KeyD`?`d`:null}var qe=class{canvas;camera;h;keys=new Set;shift=!1;pointers=new Map;downX=0;downY=0;dragging=!1;pinch=null;wheelAcc=0;wheelSettle=null;off=[];constructor(e,t,n){this.canvas=e,this.camera=t,this.h=n,e.style.touchAction=`none`;let r=(e,t,n,r)=>{e.addEventListener(t,n,r),this.off.push(()=>e.removeEventListener(t,n,r))};r(e,`pointerdown`,e=>this.onDown(e)),r(e,`pointermove`,e=>this.onMove(e)),r(e,`pointerup`,e=>this.onUp(e)),r(e,`pointercancel`,e=>this.onCancel(e)),r(e,`pointerleave`,()=>this.h.hover(0,0,!1)),r(e,`wheel`,e=>this.onWheel(e),{passive:!1}),r(window,`keydown`,e=>this.onKey(e,!0)),r(window,`keyup`,e=>this.onKey(e,!1)),r(window,`blur`,()=>this.clearKeys()),r(document,`visibilitychange`,()=>this.clearKeys())}intent(){return Ge(this.keys,this.shift)}clearKeys(){this.keys.clear(),this.shift=!1}destroy(){for(let e of this.off.splice(0))e();this.wheelSettle&&clearTimeout(this.wheelSettle),this.clearKeys()}local(e){let t=this.canvas.getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top}}onKey(e,t){if(e.key===`Shift`?this.shift=t:typeof e.getModifierState==`function`&&(this.shift=e.getModifierState(`Shift`)),!t){let t=Ke(e);t&&this.keys.delete(t);return}if(!this.h.active()||e.defaultPrevented||e.ctrlKey||e.metaKey||e.altKey||We(e.target)||H(e.target))return;let n=Ke(e);if(n){e.preventDefault(),this.keys.add(n),this.h.moved();return}switch(e.key){case`e`:case`E`:case`Enter`:if(e.key===`Enter`&&e.target?.closest?.(`button, a`))return;e.preventDefault(),this.h.use();return;case`+`:case`=`:e.preventDefault(),this.h.zoomStep(1);return;case`-`:case`_`:e.preventDefault(),this.h.zoomStep(-1);return;case`0`:e.preventDefault(),this.h.recenter();return}}onDown(e){if(e.button!==0&&e.pointerType===`mouse`)return;let t=this.local(e);this.pointers.set(e.pointerId,t);try{this.canvas.setPointerCapture(e.pointerId)}catch{}if(this.pointers.size===1)this.downX=t.x,this.downY=t.y,this.dragging=!1;else if(this.pointers.size===2){let[e,t]=[...this.pointers.values()];this.pinch={dist:Math.hypot(e.x-t.x,e.y-t.y)||1,zoom:this.camera.zoom,cx:(e.x+t.x)/2,cy:(e.y+t.y)/2},this.dragging=!0,this.h.interact()}}onMove(e){let t=this.local(e),n=this.pointers.get(e.pointerId);if(!n){e.pointerType===`mouse`&&this.h.hover(t.x,t.y,!0);return}if(this.pointers.set(e.pointerId,t),this.pinch&&this.pointers.size>=2){let[e,t]=[...this.pointers.values()],n=Math.hypot(e.x-t.x,e.y-t.y)||1,r=(e.x+t.x)/2,i=(e.y+t.y)/2;this.camera.panBy(r-this.pinch.cx,i-this.pinch.cy),this.camera.zoomAt(this.pinch.zoom*(n/this.pinch.dist),r,i,Date.now(),!1),this.pinch.cx=r,this.pinch.cy=i;return}!this.dragging&&Math.hypot(t.x-this.downX,t.y-this.downY)>He&&(this.dragging=!0,this.canvas.style.cursor=`grabbing`,this.h.interact()),this.dragging&&this.camera.panBy(t.x-n.x,t.y-n.y)}onUp(e){let t=this.local(e);if(this.pointers.delete(e.pointerId)){if(this.pinch&&this.pointers.size<2){this.pinch=null,this.camera.settle(Date.now());return}if(!(this.pointers.size>0)){if(this.canvas.style.cursor=``,this.dragging){this.dragging=!1;return}this.h.click(t.x,t.y,{shift:e.shiftKey})}}}onCancel(e){this.pointers.delete(e.pointerId),this.pointers.size<2&&(this.pinch=null),this.pointers.size||(this.dragging=!1)}onWheel(e){e.preventDefault();let t=this.local(e),n=e.deltaMode===1?e.deltaY*33:e.deltaMode===2?e.deltaY*400:e.deltaY;if(e.ctrlKey){this.camera.zoomAt(this.camera.zoom*Math.exp(-n*.012),t.x,t.y,Date.now(),!1),this.wheelSettle&&clearTimeout(this.wheelSettle),this.wheelSettle=setTimeout(()=>this.camera.settle(Date.now()),180);return}this.wheelAcc+=n,Math.abs(this.wheelAcc)>=50&&(this.h.zoomStep(this.wheelAcc<0?1:-1,t.x,t.y),this.wheelAcc=0)}},Je={x:-2,y:-2,w:h.x,h:h.y};A.w-2;var U=e=>`${e.x},${e.y}`;function Ye(e){return n(`quarteirao:${e.x},${e.y}`)}function Xe(e){return n(`lote:${e.x},${e.y}`)}function Ze(e){return e.y-p.h*Math.floor(e.y/p.h)===0}function Qe(e){if(te(e))return[];let t=[];for(let n=0;n<p.h;n++)for(let r=0;r<p.w;r++)t.push({x:e.x*p.w+r,y:e.y*p.h+n});return t}function $e(e){let t=E(e);return{x:(t.x+Je.x)*16,y:(t.y+Je.y)*16,w:Je.w*16,h:Je.h*16}}function et(e,t=64){let n=h.x*16,r=h.y*16,i=Je.x*16,a=Je.y*16;return{bx0:Math.floor((e.x0-t-i)/n),by0:Math.floor((e.y0-t-a)/r),bx1:Math.floor((e.x1+t-i)/n),by1:Math.floor((e.y1+t-a)/r)}}function tt(){let e=l.w,t=l.h,n=e+4,r=t+4,i=[];for(let e=0;e<p.h;e++)for(let t=0;t<p.w;t++)i.push({x:2+t*A.w,y:2+e*A.h,w:A.w,h:A.h});let a=5/2;return{sidewalkOuter:{x:0,y:0,w:n,h:r},block:{x:2,y:2,w:e,h:t},streets:[{x:n,y:0,w:5,h:r},{x:0,y:r,w:n,h:5}],intersection:{x:n,y:r,w:5,h:5},crosswalks:[{rect:{x:0,y:r,w:2,h:5},across:`ns`},{rect:{x:n-2,y:r,w:2,h:5},across:`ns`},{rect:{x:n,y:0,w:5,h:2},across:`we`},{rect:{x:n,y:r-2,w:5,h:2},across:`we`}],laneMarks:[[3,r+a,n-2-1,r+a],[n+a,3,n+a,r-2-1]],lots:i}}var nt=()=>!0;function rt(e){let t=Math.floor(e.x),n=Math.floor(e.y),r=Math.max(1,Math.ceil(e.w)),i=Math.max(1,Math.ceil(e.h)),a=new xe(r,i);for(let e=0;e<i;e++)for(let i=0;i<r;i++)a.cells[e*r+i]=+!!v(t+i+.5,n+e+.5,nt);return{grid:a,ox:t,oy:n}}function it(e,t,n=Math.max(h.x,h.y)){let r=Math.floor(Math.min(e.x,t.x))-n,i=Math.floor(Math.min(e.y,t.y))-n,a=Math.ceil(Math.max(e.x,t.x))+n,o=Math.ceil(Math.max(e.y,t.y))+n;return{x:r,y:i,w:a-r,h:o-i}}function at(e,t,n=16){let r=Math.floor(e),i=Math.floor(t);if(v(r+.5,i+.5,nt))return{x:r,y:i};for(let a=1;a<=n;a++){let n=null,o=1/0;for(let s=-a;s<=a;s++)for(let c=-a;c<=a;c++){if(Math.max(Math.abs(c),Math.abs(s))!==a||!v(r+c+.5,i+s+.5,nt))continue;let l=(r+c+.5-e)**2+(i+s+.5-t)**2;l<o&&(o=l,n={x:r+c,y:i+s})}if(n)return n}return null}function ot(e,t){return v(e,t,nt)}function st(e,t,n,r=1.6){let{x:i,y:a}=S(e,t),o=null,s=r*r;for(let r=a-1;r<=a+1;r++)for(let a=i-1;a<=i+1;a++)for(let i of Qe({x:a,y:r})){let r=b(i),a=(r.front.x-e)**2+(r.front.y-t)**2;a<=s&&n(i)&&(s=a,o={lot:i,side:r.side,front:r.front})}return o}var ct=3;function lt(e){let t=E(e),n=Ye(e),a=r(n),o=[],s=e=>e*16,c=n&1,u=[0,1,2].map(e=>t.x+e*A.w+i.dx+i.w/2),d=e=>u.some(t=>Math.abs(e-t)<ct);for(let e of[`n`,`s`]){let r=e===`n`?t.y-2:t.y+l.h+2-1;if([0,A.w,2*A.w,3*A.w].forEach((i,l)=>{let u=t.x+i;d(u)||((l+c+ +(e===`s`))%2==0?o.push({kind:`lamp`,x:s(u)+(i===0?6:i===3*A.w?-6:0),y:s(r)+10,seed:n+l}):o.push({kind:a()<.22?`pine`:`tree`,x:s(u),y:s(r)+12,seed:Math.floor(a()*1e9)}))}),a()<.7){let e=Math.floor(a()*3),i=t.x+e*A.w+(a()<.5?2:A.w-3);if(!d(i+1)){let e=r;o.push({kind:`bench`,x:s(i+1),y:s(e)+13,seed:n+7,seat:{x:i+1,y:e+.85,dir:`down`}})}}}for(let e of[`w`,`e`]){let r=e===`w`?t.x-2:t.x+l.w+2-1;[3,Math.floor(l.h/2),l.h-3].forEach((e,i)=>{let c=t.y+e,l=s(r)+8;i===1?o.push({kind:`lamp`,x:l,y:s(c)+10,seed:n+20+i}):a()<.85?o.push({kind:a()<.25?`pine`:`tree`,x:l,y:s(c)+12,seed:Math.floor(a()*1e9)}):o.push({kind:`bush`,x:l,y:s(c)+12,seed:Math.floor(a()*1e9),small:!0})})}return o}var ut=[`park`,`pond`,`orchard`,`cafe`];function dt(e){return ut[Xe(e)%ut.length]}function ft(e,t){let n=ee(e),a=Xe(e),o=r(a^1540483477),s=[],c=e=>(n.x+e)*16,l=e=>(n.y+e)*16,u=()=>Math.floor(o()*1e9),d=Ze(e);if(t){let e=d?l(A.h)-2:l(0)+12;for(let t=1;t<A.w-1;t+=2)s.push({kind:`hedge`,x:c(t)+16,y:e,seed:a+t,small:!0});let t=l(d?A.h-1.4:1.6);return o()<.8&&s.push({kind:o()<.3?`pine`:`tree`,x:c(1.2),y:t,seed:u()}),o()<.8&&s.push({kind:o()<.3?`pine`:`tree`,x:c(A.w-1.2),y:t,seed:u()}),s}let f=dt(e),p=d?l(0)+13:l(A.h)-2;for(let e=0;e<A.w;e+=2)e>=i.dx-1&&e<=i.dx+1||s.push({kind:e/2%3==1?`flowers`:`hedge`,x:c(e)+16,y:p,seed:a+e*3,small:!0});let m=A.w/2,h=A.h/2;switch(f){case`park`:s.push({kind:`tree`,x:c(2.5),y:l(d?4.5:3.5),seed:u()}),s.push({kind:o()<.5?`pine`:`tree`,x:c(11.5),y:l(d?3.8:4.2),seed:u()}),s.push({kind:`tree`,x:c(10.5),y:l(d?9.5:8.8),seed:u()}),s.push({kind:`bush`,x:c(3.5),y:l(d?9.2:8.4),seed:u(),small:!0}),s.push({kind:`flowers`,x:c(m),y:l(h+.6),seed:u(),small:!0}),s.push({kind:`bench`,x:c(m),y:l(h-1.2),seed:u(),seat:{x:n.x+m,y:n.y+h-1.35,dir:`down`}});break;case`pond`:s.push({kind:`rock`,x:c(3.2),y:l(h+2.2),seed:u(),small:!0}),s.push({kind:`rock`,x:c(10.4),y:l(h-1.8),seed:u(),small:!0}),s.push({kind:`tree`,x:c(1.8),y:l(d?10.6:3.2),seed:u()}),s.push({kind:`pine`,x:c(12.2),y:l(d?10.2:3.6),seed:u()}),s.push({kind:`bush`,x:c(4.6),y:l(h-2.6),seed:u(),small:!0}),s.push({kind:`bush`,x:c(9.5),y:l(h+2.8),seed:u(),small:!0});break;case`orchard`:for(let e=0;e<2;e++)for(let t=0;t<4;t++)s.push({kind:`tree`,x:c(2.2+t*3.2),y:l((d?4.6:3.6)+e*4.4),seed:u()});break;case`cafe`:s.push({kind:`parasol`,x:c(4),y:l(h+.5),seed:u()}),s.push({kind:`parasol`,x:c(10),y:l(h+.5),seed:u()}),s.push({kind:`planter`,x:c(m),y:l(h-2.5),seed:u(),small:!0}),s.push({kind:`tree`,x:c(1.6),y:l(d?10.4:2.6),seed:u()}),s.push({kind:`tree`,x:c(12.4),y:l(d?10.4:2.6),seed:u()})}return s}function pt(){let e=E({x:0,y:0}),t=t=>(e.x+t)*16,n=t=>(e.y+t)*16,r=[],i=y;r.push({kind:`fountain`,x:t(i.x+i.w/2),y:n(i.y+i.h),seed:1});for(let a of[-5,5])r.push({kind:`bench`,x:t(i.x+i.w/2+a),y:n(i.y-1)+13,seed:3+a,seat:{x:e.x+i.x+i.w/2+a,y:e.y+i.y-1+.85,dir:`down`}}),r.push({kind:`bench`,x:t(i.x+i.w/2+a),y:n(i.y+i.h+2)+13,seed:4+a,seat:{x:e.x+i.x+i.w/2+a,y:e.y+i.y+i.h+2+.85,dir:`down`}});[[6,5],[l.w-6,5],[6,l.h-4],[l.w-6,l.h-4]].forEach(([e,i],a)=>{r.push({kind:a%2?`pine`:`tree`,x:t(e-1.5),y:n(i),seed:100+a*7}),r.push({kind:`tree`,x:t(e+1.5),y:n(i+.4),seed:200+a*11}),r.push({kind:`flowers`,x:t(e),y:n(i+1.6),seed:300+a,small:!0}),r.push({kind:`bush`,x:t(e-3),y:n(i+1.4),seed:400+a,small:!0}),r.push({kind:`bush`,x:t(e+3),y:n(i+1.2),seed:500+a,small:!0})});for(let[e,i]of[[12,4],[l.w-12,4],[12,l.h-5],[l.w-12,l.h-5]])r.push({kind:`lamp`,x:t(e)+8,y:n(i)+10,seed:e*3+i});return r.push({kind:`totem`,x:t(O.x-3)+8,y:n(O.y)+4,seed:2}),r.push({kind:`planter`,x:t(O.x+3)+8,y:n(O.y)+6,seed:9,small:!0}),r}function mt(e){let t=lt(e);return te(e)&&t.push(...pt()),t}var ht=p.w*p.h;function gt(e){return e>0?Math.min(1,.35+.65*Math.min(e,ht)/ht):0}function _t(e,t,n,r,i=4){let a=S(t.x,t.y),o=(2*i+1)*h.x,s=(2*i+1)*h.y,c=Math.min(r.w/o,r.h/s),u=a.x*h.x+l.w/2,d=a.y*h.y+l.h/2,f=e=>r.w/2+(e-u)*c,p=e=>r.h/2+(e-d)*c,m=new Map;for(let t of e)m.set(`${t.x},${t.y}`,t.lit);let g=[];for(let e=a.y-i-1;e<=a.y+i+1;e++)for(let t=a.x-i-1;t<=a.x+i+1;t++){let n=f(t*h.x),i=p(e*h.y),a=l.w*c,o=l.h*c;if(n+a<0||i+o<0||n>r.w||i>r.h)continue;let s=`${t},${e}`,u=m.get(s);g.push({bx:t,by:e,x:n,y:i,w:a,h:o,light:gt(u??0),occupied:u!==void 0,plaza:t===T.x&&e===T.y})}return{cells:g,me:{x:f(t.x),y:p(t.y)},view:{x:f(n.x),y:p(n.y),w:n.w*c,h:n.h*c},k:c,cx:u,cy:d}}function vt(e,t,n,r){return{x:e.cx+(n-t.w/2)/e.k,y:e.cy+(r-t.h/2)/e.k}}var yt=class{el;canvas;ctx;model=null;size={w:176,h:116};sig=``;constructor(e){this.canvas=N(`canvas`,{class:`ui-city-minimap__canvas`,attrs:{"aria-hidden":`true`}}),this.ctx=this.canvas.getContext(`2d`),this.el=N(`nav`,{class:`ui-city-minimap`,attrs:{"aria-label":t(`Minimapa: clique para levar a câmera até lá`)},title:t(`Minimapa: clique para levar a câmera até lá`)},this.canvas),this.canvas.addEventListener(`pointerdown`,t=>{if(t.preventDefault(),t.stopPropagation(),!this.model)return;let n=this.canvas.getBoundingClientRect();e(vt(this.model,this.size,t.clientX-n.left,t.clientY-n.top))})}draw(e,t,n,r){let i=this.canvas.clientWidth||this.size.w,a=this.canvas.clientHeight||this.size.h,o=Math.max(1,Math.min(3,window.devicePixelRatio||1)),s=`${t}|${Math.round(n.x*2)}|${Math.round(n.y*2)}|${Math.round(r.x)}|${Math.round(r.y)}|${Math.round(r.w)}|${i}|${a}|${o}`;if(s===this.sig)return;this.sig=s,this.size={w:i,h:a},(this.canvas.width!==Math.round(i*o)||this.canvas.height!==Math.round(a*o))&&(this.canvas.width=Math.round(i*o),this.canvas.height=Math.round(a*o));let c=this.model=_t(e,n,r,this.size),l=this.ctx;l.setTransform(o,0,0,o,0,0),l.clearRect(0,0,i,a),l.fillStyle=`#2a2f3a`,l.fillRect(0,0,i,a);for(let e of c.cells){let t=Math.round(e.x),n=Math.round(e.y),r=Math.max(2,Math.round(e.w)),i=Math.max(2,Math.round(e.h));l.fillStyle=e.plaza?`#b9b2a4`:e.light>0?`rgba(255,206,110,${(.25+e.light*.75).toFixed(3)})`:e.occupied?`#55607a`:`#3a5a45`,l.fillRect(t,n,r,i),e.light>0&&(l.fillStyle=`rgba(255,240,200,${(e.light*.5).toFixed(3)})`,l.fillRect(t+1,n+1,Math.max(1,r-2),1)),e.plaza&&(l.fillStyle=`#5ea8d6`,l.fillRect(Math.round(t+r/2-1),Math.round(n+i/2-1),2,2))}l.strokeStyle=`rgba(232,236,245,0.75)`,l.lineWidth=1,l.strokeRect(Math.round(c.view.x)+.5,Math.round(c.view.y)+.5,Math.max(2,Math.round(c.view.w)),Math.max(2,Math.round(c.view.h))),l.fillStyle=`#12151d`,l.fillRect(Math.round(c.me.x)-3,Math.round(c.me.y)-3,6,6),l.fillStyle=`#7cc8ff`,l.fillRect(Math.round(c.me.x)-2,Math.round(c.me.y)-2,4,4)}};function bt(e,n=`street`){switch(e){case`ignored`:case`invalid`:case`view_required`:return null;case`rate_limited`:return t(`Devagar: o mundo pediu um tempo entre as ações.`);case`not_found`:return t(n===`door`?`Este prédio não está no mundo agora.`:n===`inside`?`O prédio saiu do mundo: você voltou para a rua.`:`Essa pessoa não está mais por perto.`);case`street_left`:return t(`Você ficou um bom tempo parado e saiu da rua: ande para voltar.`);case`chunk_full`:return t(`A área está cheia: só os jogadores mais perto aparecem.`);case`afk`:return t(`Você ficou um tempo parado.`);case`server_restart`:return t(`O Habblaud World vai reiniciar: a conexão cai e volta sozinha.`);case`left`:return t(`Sua conta saiu do mundo: o prédio volta com "Voltar ao mundo", em Configurações.`);case`too_far`:return t(`Chegue mais perto da porta para entrar.`);case`closed`:return t(n===`inside`?`O prédio fechou a visitas: você voltou para a rua.`:`Este prédio está fechado a visitas.`);case`blocked`:return t(n===`inside`?`Você não pode mais ficar neste prédio: voltou para a rua.`:`Você não pode entrar neste prédio.`);case`full`:return t(`O prédio está lotado (20 visitantes). Tente daqui a pouco.`);case`daily_limit`:return t(`Limite do dia atingido: amanhã tem mais.`);case`already_done`:return t(`Você já fez isso hoje.`);case`reported`:return t(`Denúncia enviada. Obrigado: a moderação vai olhar.`);case`blocked_ok`:return t(`Bloqueio feito: vocês deixam de se ver.`);case`stamped`:return t(`Carimbo deixado na portaria.`);default:return t(`Aviso do Habblaud World.`)}}var xt=5e3,St=C;function Ct(e,t){let n=[];for(let r=0;r<e;r++){let i=-Math.PI/2+r/Math.max(1,e)*Math.PI*2;n.push({x:Math.round(Math.cos(i)*t),y:Math.round(Math.sin(i)*t),angle:i})}return n}function wt(e){return e===9?`0`:String(e+1)}function Tt(e){if(!/^[0-9]$/.test(e))return-1;let t=e===`0`?9:Number(e)-1;return t<St.length?t:-1}function Et(e,t,n={}){let r=n.range??12,i=null,a=r*r,o=new Set;for(let n of t){o.add(n.id);let t=(n.x-e.x)**2+(n.y-e.y)**2;t<=a&&(a=t,i=n.id)}return n.replyTo&&o.has(n.replyTo)?n.replyTo:n.selected&&o.has(n.selected)?n.selected:i}var Dt=class{map=new Map;add(e,t,n){this.map.set(e,{id:t,at:n})}get(e,t){let n=this.map.get(e);if(!n)return null;let r=t-n.at;return r>=5e3||r<0?(this.map.delete(e),null):{id:n.id,t:r/xt,age:r}}get size(){return this.map.size}ids(){return[...this.map.keys()]}clear(){this.map.clear()}},Ot=class{perMinute;gapMs;times=[];constructor(e,t=0){this.perMinute=e,this.gapMs=t}wait(e){for(;this.times.length&&e-this.times[0]>=6e4;)this.times.shift();let t=this.times[this.times.length-1],n=t===void 0?0:Math.max(0,t+this.gapMs-e);return this.times.length>=this.perMinute&&(n=Math.max(n,this.times[0]+6e4-e)),n}take(e){return this.wait(e)>0?!1:(this.times.push(e),!0)}};function kt(e){switch(e){case`hello`:case`wave`:return`nice_to_meet`;case`nice_building`:case`congrats`:case`clap`:case`good_luck`:return`thanks`;case`coffee`:return`coffee`;case`bye`:return`bye`;case`thanks`:return`clap`;case`nice_to_meet`:return`wave`}}var At=class{el;ring;center;to;hint;arrow;buttons=[];target=null;focused=0;pick=null;constructor(){this.to=N(`strong`,{class:`ui-city-wheel__to`}),this.hint=N(`span`,{class:`ui-city-wheel__hint`}),this.arrow=N(`span`,{class:`ui-city-wheel__arrow`,attrs:{"aria-hidden":`true`}}),this.center=N(`div`,{class:`ui-city-wheel__center`},N(`span`,{class:`ui-city-wheel__label`,text:t(`Cumprimentar`)}),this.to,this.hint),this.ring=N(`div`,{class:`ui-city-wheel__ring`,role:`menu`,attrs:{"aria-label":t(`Cumprimentos`)}});let e=Ct(St.length,96);St.forEach((t,n)=>{let r=e[n],i=N(`button`,{class:`ui-city-wheel__item`,type:`button`,role:`menuitem`,style:`--x:${r.x}px;--y:${r.y}px;--i:${n}`,attrs:{"aria-label":`${De(t)} (${wt(n)})`,"data-greeting":t},on:{click:()=>this.choose(n),pointerenter:()=>this.focus(n,!1),focus:()=>this.focus(n,!1)}},N(`span`,{class:`ui-city-wheel__emoji`,text:we(t),attrs:{"aria-hidden":`true`}}),N(`span`,{class:`ui-city-wheel__key`,text:wt(n),attrs:{"aria-hidden":`true`}}));this.buttons.push(i),this.ring.append(i)}),this.el=N(`div`,{class:`ui-city-wheel`,hidden:!0},this.arrow,this.ring,this.center),this.el.addEventListener(`pointerdown`,e=>{e.target===this.el&&this.close()})}get open(){return!this.el.hidden}get targetId(){return this.target?.id??null}show(e,t,n,r,i){this.target=e,this.pick=i,M(this.to,e.name);let a=window.innerWidth,o=window.innerHeight,s=Math.max(132,Math.min(a-132,t.x)),c=Math.max(172,Math.min(o-132,t.y));if(this.el.style.setProperty(`--cx`,`${Math.round(s)}px`),this.el.style.setProperty(`--cy`,`${Math.round(c)}px`),n){let e=Math.atan2(n.y-c,n.x-s);this.arrow.style.setProperty(`--a`,`${e}rad`),this.arrow.hidden=Math.hypot(n.x-s,n.y-c)<30}else this.arrow.hidden=!0;this.el.hidden=!1,this.el.classList.remove(`is-in`),this.el.offsetWidth,this.el.classList.add(`is-in`),this.focus(Math.max(0,r?St.indexOf(r):0),!0)}close(){this.el.hidden||(this.el.hidden=!0,this.target=null,this.pick=null)}key(e){if(!this.open)return!1;let t=Tt(e.key);if(t>=0)return this.choose(t),!0;switch(e.key){case`Escape`:case`g`:case`G`:return this.close(),!0;case`ArrowRight`:case`ArrowDown`:return this.focus((this.focused+1)%St.length,!0),!0;case`ArrowLeft`:case`ArrowUp`:return this.focus((this.focused+St.length-1)%St.length,!0),!0;case`Enter`:case` `:return this.choose(this.focused),!0}return!1}focus(e,t){this.focused=e,this.buttons.forEach((t,n)=>t.classList.toggle(`is-focus`,n===e));let n=St[e];M(this.hint,`${Ce[n].icon} ${De(n)}`),t&&this.buttons[e]?.focus({preventScroll:!0})}choose(e){let t=St[e],n=this.pick;t&&n&&(this.buttons[e]?.classList.add(`is-picked`),setTimeout(()=>this.buttons[e]?.classList.remove(`is-picked`),300),this.close(),n(t))}},jt=4e3;function Mt(e){return new Date(e).toISOString().slice(0,10)}function Nt(e){return`habblaud:world-stamp:${e}`}function Pt(e,t){if(!e)return null;try{let n=JSON.parse(e);return n.day===t&&c.includes(n.stampId)?n.stampId:null}catch{return null}}function Ft(e){return e===`stamped`?`ok`:e===`already_done`?`already`:`failed`}function It(e,t=0,n=8){let r=[...e].filter(e=>c.includes(e.stampId)).sort((e,t)=>Number(!!t.mine)-Number(!!e.mine)||(t.count??1)-(e.count??1)),i=Math.max(1,Math.ceil(Math.min(n,r.length)/4)),a=(t^2654435769)>>>0,o=()=>(a=Math.imul(a^a>>>15,2246822507)+1831565813>>>0,((a^a>>>13)>>>0)/4294967296);return r.slice(0,n).map((e,t)=>{let n=t%4,r=Math.floor(t/4);return{stampId:e.stampId,icon:Se(e.stampId),label:Oe(e.stampId),count:Math.max(1,e.count??1),mine:!!e.mine,x:(n+.5+(o()-.5)*.35)/4,y:(r+.5+(o()-.5)*.3)/i,rot:Math.round((o()-.5)*24)}})}function Lt(e,n){let r=()=>n.now?.()??Date.now(),i=Me(),a=0,o=!1,s=``,l=null,u=new Ot(9,400),d=N(`button`,{class:`ui-visit-social__like`,type:`button`,on:{click:()=>b()}}),f=N(`button`,{class:`ui-visit-social__stamp`,type:`button`,attrs:{"aria-expanded":`false`},on:{click:()=>S()}}),p=N(`div`,{class:`ui-visit-social__picker`,role:`group`,hidden:!0,attrs:{"aria-label":t(`Escolha um carimbo para a portaria`)}},N(`p`,{class:`ui-visit-social__hint`,text:t(`Um carimbo por prédio por dia. O dono vê quantos de cada recebeu, nunca quem deixou.`)}),N(`div`,{class:`ui-visit-social__grid`},...c.map(e=>N(`button`,{class:`ui-visit-social__choice`,type:`button`,title:Oe(e),attrs:{"data-stamp":e},on:{click:()=>C(e)}},N(`span`,{class:`ui-visit-social__choice-icon`,text:Ee[e].icon,attrs:{"aria-hidden":`true`}}),N(`span`,{text:Oe(e)}))))),m=N(`div`,{class:`ui-visit-social`},N(`div`,{class:`ui-visit-social__row`},d,f),p);e.append(m);let h=()=>s?Pt(g(s),Mt(r())):null;function g(e){try{return i?.getItem(Nt(e))??null}catch{return null}}function _(e,t){try{t?i?.setItem(Nt(e),JSON.stringify({day:Mt(r()),stampId:t})):i?.removeItem?.(Nt(e))}catch{}}function v(){let e=n.building(),r=n.mine();if(P(m,!e||r),!e)return;d.replaceChildren(N(`span`,{text:o?`💔`:`❤️`,attrs:{"aria-hidden":`true`}}),` ${t(o?`Descurtir`:`Curtir`)}`,N(`b`,{class:`ui-visit-social__count`,text:String(a)})),d.classList.toggle(`is-liked`,o),d.title=t(o?`Desfazer o like no prédio de {0}`:`Curtir o prédio de {0}`,[e.owner.name]);let i=h();f.disabled=!!i,f.replaceChildren(N(`span`,{text:i?Se(i):`📮`,attrs:{"aria-hidden":`true`}}),` ${i?t(`Carimbo de hoje: {0}`,[Oe(i)]):t(`Deixar um carimbo`)}`),i&&x()}function y(){let e=n.building();e&&e.id!==s&&(s=e.id,x()),e&&(a=e.likes,o=e.likedByMe===!0),v()}function b(){let e=n.building();if(!e||n.mine())return;if(!u.take(r())){n.toast(t(`Devagar com os likes: espere um pouquinho.`));return}let i=!o;n.send([{t:i?`like`:`unlike`,buildingId:e.id}]),l={kind:`like`,at:r()},o=i,a=Math.max(0,a+(i?1:-1)),d.classList.remove(`is-pop`),d.offsetWidth,i&&d.classList.add(`is-pop`),v()}function x(){P(p,!0),f.setAttribute(`aria-expanded`,`false`)}function S(){if(h())return;let e=p.hidden;P(p,!e),f.setAttribute(`aria-expanded`,String(e))}function C(e){let i=n.building();!i||n.mine()||h()||(n.send([{t:`stamp`,buildingId:i.id,stampId:e}]),l={kind:`stamp`,at:r(),stampId:e},_(i.id,e),n.toast(`${Se(e)} ${t(`Carimbo deixado na portaria: {0}`,[Oe(e)])}`),v())}function w(e){if(!e||typeof e!=`object`)return!1;let i=e;if(i.t===`like.update`&&i.buildingId===s&&typeof i.likes==`number`)return a=i.likes,o=i.likedByMe===!0,l?.kind===`like`&&(l=null),v(),!1;if(i.t!==`notice`||typeof i.text!=`string`||!l||r()-l.at>jt)return!1;let c=l;if(l=null,c.kind===`stamp`){let e=Ft(i.text);return e===`ok`?!0:e===`already`?(n.toast(t(`Você já deixou um carimbo aqui hoje.`)),!0):(_(s,null),v(),n.toast(i.text===`too_far`?t(`Entre no prédio ou chegue mais perto da porta para carimbar.`):t(`O carimbo não foi deixado. Tente de novo.`)),!0)}if(i.text===`daily_limit`)n.toast(t(`Você já deu os 50 likes de hoje. Amanhã tem mais!`));else if(i.text===`rate_limited`)n.toast(t(`Devagar com os likes: espere um pouquinho.`));else return!1;return o=!o,a=Math.max(0,a+(o?1:-1)),v(),!0}return y(),{el:m,message:w,sync:y,stampedToday:h,destroy:()=>m.remove()}}function Rt(e){return e.count>1?`${e.label} ×${e.count}`:e.label}function zt(e){return e.state===`away`?`away`:e.discreet===!0?`discreet`:`live`}function Bt(e){return e===1?t(`1 agente`):t(`{0} agentes`,[e])}function Vt(e){return e===1?t(`1 visitante agora`):t(`{0} visitantes agora`,[e])}function Ht(e){return Ae(e.building)?0:e.floors.reduce((e,t)=>e+(Array.isArray(t.agents)?t.agents.length:0),0)}function Ut(e,n){let r=e.building,i=zt(r),a=[Le(e.floors.length)];return i===`live`?a.push(Bt(Ht(e))):a.push(t(i===`away`?`apagado`:`modo discreto`)),{title:n?t(`Seu prédio, como os outros veem`):t(`Prédio de {0}`,[r.owner.name]),details:a,mode:i===`live`?null:i}}var Wt=[`working`,`waiting`,`idle`,`shell`];function Gt(e){switch(e){case`working`:return t(`trabalhando`);case`waiting`:return t(`esperando o dono`);case`shell`:return t(`de olho no terminal`);default:return t(`à toa`)}}function Kt(e){let n=Wt.includes(e.status)?e.status:`idle`,r=e.provider===`codex`?`codex`:`claude`;return{id:ne(e.id),name:typeof e.name==`string`&&e.name?e.name:t(`Agente`),role:e.kind===`sub`?t(`Subagente`):t(`Agente principal`),tool:je[r].name,status:n,statusText:Gt(n)}}function qt(e){let n=Ae(e.building),r=e.floors.map(e=>({id:e.id,name:R(typeof e.label==`string`?e.label:``),agents:n||!Array.isArray(e.agents)?[]:e.agents.map(Kt)})),i=zt(e.building);return{rooms:r,empty:i===`away`?t(`Prédio apagado: o dono pausou ou não está com o Habblaud aberto. As salas ficam escuras e vazias.`):i===`discreet`?t(`Modo discreto: o dono não mostra os agentes. As salas aparecem vazias, com a luz acesa.`):null}}function Jt(e,t){if(Ae(e.building))return null;for(let n of e.floors)for(let e of Array.isArray(n.agents)?n.agents:[])if(ne(e.id)===t)return{...Kt(e),room:R(n.label)};return null}var Yt=class{deps;id;rev;detail;snapshot;leaving=!1;resyncAt=-1/0;constructor(e,t){this.deps=t,this.id=e.id,this.rev=e.rev,this.detail=structuredClone(e.detail),this.snapshot=fe(this.detail,t.now(),{version:t.version}),t.push(this.snapshot)}get light(){return zt(this.detail.building)}replace(e){let t=structuredClone(e.detail),n=de(this.snapshot,{rev:e.rev,floors:t.floors,building:t.building},this.deps.now());this.rev=e.rev,this.detail=t,this.resyncAt=-1/0,this.publish(n.snapshot)}patch(e){let t=L(this.rev,e.rev);if(t===`stale`)return t;if(t===`resync`){let e=this.deps.now();return e-this.resyncAt>=5e3&&(this.resyncAt=e,this.deps.send([{t:`resync`,building:this.id}])),t}let n=de(this.snapshot,e,this.deps.now(),this.detail.building);return this.rev=e.rev,e.floors&&(this.detail.floors=structuredClone(e.floors)),e.building&&(this.detail.building=structuredClone(e.building)),typeof e.visitors==`number`&&(this.detail.visitors=e.visitors),this.publish(n.snapshot),t}leave(){return!this.leaving&&(this.leaving=!0,this.deps.send([{t:`leave`}]),this.deps.changed?.(),!0)}publish(e){e!==this.snapshot&&(this.snapshot=e,this.deps.push(e)),this.deps.changed?.()}},Xt=8e3,Zt=`(max-width: 760px)`;function Qt(e){let r=document.createElement(`canvas`);r.id=`visit`,e.after.after(r);let i=new g({search:``}),a=ke(r,i,{visit:!0}),o=typeof matchMedia==`function`?matchMedia(Zt):null,s=()=>!!o?.matches,c=!s(),l=!1,u=null,d=0,f=``;a.visit.setLight(zt(e.inside.detail.building));let p=new Yt(e.inside,{push:e=>i.pushReplay(e),send:t=>e.send(t),now:()=>Date.now(),version:e.version,changed:()=>ae()});a.visit.setVisitor({name:e.me.name,look:e.me.look,parts:e.me.parts});let m=N(`strong`,{class:`ui-visit-bar__title`}),h=N(`span`,{class:`ui-visit-bar__details`}),_=N(`span`,{class:`ui-visit-bar__mode`,hidden:!0}),v=N(`span`,{class:`ui-visit-bar__visitors`}),y=N(`button`,{class:`ui-btn ui-visit-bar__panel`,type:`button`,attrs:{"aria-expanded":`false`,"aria-controls":`ui-visit-panel`},on:{click:()=>z(!c)}}),b=N(`button`,{class:`ui-btn ui-btn--primary ui-visit-bar__leave`,type:`button`,text:t(`Sair do prédio`),title:t(`Sair do prédio (Esc)`),on:{click:()=>ye()}}),x=N(`header`,{class:`ui-visit-bar`,attrs:{"aria-label":t(`Visita`)}},N(`div`,{class:`ui-visit-bar__text`},N(`div`,{class:`ui-visit-bar__line`},m,_),N(`div`,{class:`ui-visit-bar__line`},h,v)),N(`div`,{class:`ui-visit-bar__actions`},y,b)),S=N(`strong`,{class:`ui-visit-card__name`}),C=N(`span`,{class:`ui-visit-card__meta`}),w=N(`span`,{class:`ui-visit-card__status`}),T=N(`span`,{class:`ui-visit-card__room`}),E=N(`section`,{class:`ui-visit-card`,hidden:!0,attrs:{"aria-live":`polite`,"aria-label":t(`Agente`)}},N(`div`,{class:`ui-visit-card__head`},S,N(`button`,{class:`ui-visit-card__close`,type:`button`,text:`×`,title:t(`Fechar`),attrs:{"aria-label":t(`Fechar`)},on:{click:()=>a.select(null)}})),C,N(`div`,{class:`ui-visit-card__row`},w,T)),ee=N(`p`,{class:`ui-visit-panel__empty`,hidden:!0}),D=N(`ul`,{class:`ui-visit-panel__rooms`}),O=N(`div`,{class:`ui-visit-panel__social`}),k=N(`aside`,{class:`ui-visit-panel`,attrs:{id:`ui-visit-panel`,"aria-label":t(`Salas do prédio`)}},O,N(`h3`,{class:`ui-visit-panel__title`,text:t(`Salas`)}),E,ee,D,N(`p`,{class:`ui-visit-panel__hint`,text:t(`Só o nome, o papel, a ferramenta e o status de cada agente: o resto do escritório não sai do computador do dono.`)})),A=N(`button`,{class:`ui-visit-exit`,type:`button`,hidden:!0,on:{click:()=>ve()}},N(`kbd`,{text:`E`}),t(`Sair pelo elevador`)),te=N(`div`,{class:`ui-visit-help`,attrs:{"aria-hidden":`true`}},N(`span`,{},N(`kbd`,{text:`WASD`}),` `,t(`andar`)),N(`span`,{},N(`kbd`,{text:`Shift`}),` `,t(`correr`)),N(`span`,{},N(`kbd`,{text:t(`clique`)}),` `,t(`ir até lá`)),N(`span`,{},N(`kbd`,{text:`E`}),` `,t(`elevador`)),N(`span`,{},N(`kbd`,{text:`Esc`}),` `,t(`sair`))),j=N(`div`,{class:`ui-visit-leaving`,hidden:!0,role:`status`,text:t(`Saindo do prédio…`)}),F=N(`div`,{class:`ui-visit-board__pins`}),I=N(`div`,{class:`ui-visit-board`,hidden:!0,role:`img`},F),L=N(`div`,{class:`ui-visit`},I,x,k,A,te,j);e.uiRoot.append(L),e.uiRoot.classList.add(`is-visit`);let R=Lt(O,{building:()=>l?null:p.detail.building,mine:()=>e.mine,send:t=>e.send(t),toast:t=>e.toast(t)}),ne=``;function re(){let r=R.stampedToday(),i=e.mine?(e.summaryStamps?.()??[]).map(e=>({stampId:e.stampId,count:e.count})):r?[{stampId:r,mine:!0}]:[],a=JSON.stringify(i);if(a===ne)return;ne=a;let o=It(i,n(p.id));F.replaceChildren(...o.map(e=>N(`span`,{class:`ui-visit-board__pin${e.mine?` is-mine`:``}`,text:e.icon,title:Rt(e),attrs:{style:`left:${(e.x*100).toFixed(1)}%;top:${(e.y*100).toFixed(1)}%;--rot:${e.rot}deg`}})));let s=o.length?`${t(`Carimbos da portaria`)}: ${o.map(Rt).join(`, `)}`:t(`Carimbos da portaria: nenhum ainda`);I.setAttribute(`aria-label`,s),I.title=s,I.classList.toggle(`is-empty`,!o.length)}let ie=``;function ae(){if(l)return;let n=p.detail,r=Ut(n,e.mine);M(m,r.title),M(h,r.details.join(` · `)),P(_,!r.mode),M(_,r.mode===`away`?`🌙 ${t(`apagado`)}`:r.mode===`discreet`?`🙈 ${t(`discreto`)}`:``),_.className=`ui-visit-bar__mode${r.mode?` is-${r.mode}`:``}`,M(v,n.visitors>0?`👀 ${Vt(n.visitors)}`:``),P(j,!p.leaving),b.disabled=p.leaving,a.visit.setLight(p.light);let i=n.building.theme;i!==f&&(f=i,a.setOptions({...e.options(),theme:i===`halloween`||i===`christmas`?i:`none`}));let o=qt(n);P(ee,!o.empty),M(ee,o.empty??``);let s=JSON.stringify(o.rooms);s!==ie&&(ie=s,D.replaceChildren(...o.rooms.map(e=>N(`li`,{class:`ui-visit-room`},N(`div`,{class:`ui-visit-room__head`},N(`span`,{class:`ui-visit-room__name`,text:e.name}),N(`span`,{class:`ui-visit-room__count`,text:String(e.agents.length)})),e.agents.length?N(`ul`,{class:`ui-visit-room__agents`},...e.agents.map(e=>N(`li`,{},N(`button`,{class:`ui-visit-agent is-${e.status}`,type:`button`,attrs:{"data-agent":e.id},on:{click:()=>se(e.id)}},N(`span`,{class:`ui-visit-agent__dot`,attrs:{"aria-hidden":`true`}}),N(`span`,{class:`ui-visit-agent__name`,text:e.name}),N(`span`,{class:`ui-visit-agent__meta`,text:`${e.role} · ${e.tool}`}),N(`span`,{class:`ui-visit-agent__status`,text:e.statusText}))))):null)))),oe(),M(y,`${t(`Salas`)} (${n.floors.length})`),re(),y.setAttribute(`aria-expanded`,String(c)),L.classList.toggle(`has-panel`,c),ce()}function oe(){let e=a.getSelection(),t=e?.type===`agent`?Jt(p.detail,e.id):null;if(P(E,!t),t){M(S,t.name),M(C,`${t.role} · ${t.tool}`),M(w,t.statusText),w.className=`ui-visit-card__status is-${t.status}`,M(T,t.room);for(let e of D.querySelectorAll(`.ui-visit-agent`))e.classList.toggle(`is-selected`,e.dataset.agent===t.id)}}function se(e){if(!e)return a.select(null);a.select({type:`agent`,id:e},{focus:!0})}function z(e){c=e,ae()}function ce(){L.style.setProperty(`--ui-visit-top`,`${Math.round(e.topInset()+8)}px`);let t=x.getBoundingClientRect().bottom||e.topInset()+56,n=k.getBoundingClientRect();a.setViewInsets?.({top:t+4,right:c&&!s()?Math.max(0,window.innerWidth-n.left):0,bottom:c&&s()?Math.max(0,window.innerHeight-n.top):0,left:0})}let le=a.onSelect(()=>oe()),ue=new Set,B=!1,V=()=>a.visit.setIntent(p.leaving?{dx:0,dy:0,run:!1}:Ge(ue,B)),de=e=>{let t=e;return!!t&&(t.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName??``))},fe=(e,t)=>{e.key===`Shift`?B=t:typeof e.getModifierState==`function`&&(B=e.getModifierState(`Shift`));let n=Ke(e);if(!t){n&&ue.delete(n),V();return}if(!(e.defaultPrevented||e.ctrlKey||e.metaKey||e.altKey||de(e.target)||H(e.target))){if(n){e.preventDefault(),ue.add(n),V();return}e.key===`e`||e.key===`E`||e.key===`Enter`&&!e.target?.closest?.(`button, a`)?(e.preventDefault(),ve()):e.key===`+`||e.key===`=`?(e.preventDefault(),a.zoomBy(1.25)):e.key===`-`||e.key===`_`?(e.preventDefault(),a.zoomBy(1/1.25)):e.key===`0`&&(e.preventDefault(),a.overview())}},pe=e=>fe(e,!0),me=e=>fe(e,!1),he=()=>{ue.clear(),B=!1,V()};addEventListener(`keydown`,pe),addEventListener(`keyup`,me),addEventListener(`blur`,he);let _e=()=>ce();addEventListener(`resize`,_e),o?.addEventListener(`change`,_e);function ve(){p.leaving||a.visit.atExit()&&a.visit.exit(()=>ye())&&(ue.clear(),V())}function ye(){p.leave()&&(ue.clear(),V(),u=setTimeout(()=>{u=null,l||e.stuck()},Xt))}let be=()=>{d=requestAnimationFrame(be);let e=!p.leaving&&a.visit.atExit()?a.visit.visitorScreen():null;P(A,!e);let t=a.visit.boardScreen(),n=!!t&&t.h>=18;if(P(I,!n),t&&n&&(I.style.transform=`translate(${Math.round(t.x)}px, ${Math.round(t.y)}px)`,I.style.width=`${Math.round(t.w)}px`,I.style.height=`${Math.round(t.h)}px`,I.style.setProperty(`--pin`,`${Math.max(8,Math.round(t.h*.3))}px`)),e){let t=A.offsetWidth||150,n=Math.max(8,Math.min(window.innerWidth-t-8,e.x-t/2));A.style.transform=`translate(${Math.round(n)}px, ${Math.round(e.y-34)}px)`}};return d=requestAnimationFrame(be),ae(),requestAnimationFrame(()=>ce()),{id:p.id,controller:p,world:a,replace(e){p.replace(e),R.sync()},patch(e){p.patch(e),e.building&&R.sync()},message(e){if(l)return!1;let t=R.message(e);return re(),t},leave:ye,escape(){return a.getSelection()?(a.select(null),!0):s()&&c?(z(!1),!0):(ye(),!0)},openPanel(e=!0){z(e)},selectAgent:se,destroy(){l||(l=!0,u&&clearTimeout(u),cancelAnimationFrame(d),le(),R.destroy(),removeEventListener(`keydown`,pe),removeEventListener(`keyup`,me),removeEventListener(`blur`,he),removeEventListener(`resize`,_e),o?.removeEventListener(`change`,_e),a.destroy(),r.remove(),L.remove(),e.uiRoot.classList.remove(`is-visit`),ge(Me()))}}}var $t=3.2,en=60,tn=1e3,nn=4,rn=.5,an=.25,on=10,sn={up:`n`,down:`s`,left:`w`,right:`e`},cn={n:`up`,s:`down`,w:`left`,e:`right`};function ln(e,t,n){return Math.abs(e)<1e-6&&Math.abs(t)<1e-6?n:Math.abs(e)>=Math.abs(t)?e>0?`right`:`left`:t>0?`down`:`up`}function un(e,t){let n=e[e.length-1];n&&t.t<n.t&&(t={...t,t:n.t}),e.push(t),e.length>on&&e.splice(0,e.length-on)}function dn(e){let t=0,n=0;for(let r=e.length-1;r>0&&n<nn;r--){let i=e[r].t-e[r-1].t;i<=0||i>tn||(t=Math.max(t,i),n++)}return Math.min(700,Math.max(150,t+en))}function fn(e,t,n){return t>e?Math.min(t,e+n*rn):Math.max(t,e-n*an)}function pn(e,t){let n=e.length;if(!n)return null;let r=e[0];if(t<=r.t)return{x:r.x,y:r.y,dir:r.dir,moving:r.moving&&n>1,speed:0};for(let r=1;r<n;r++){let n=e[r];if(t>n.t)continue;let i=e[r-1],a=Math.max(1,n.t-i.t),o=Math.min(1,Math.max(0,(t-i.t)/a)),s=Math.hypot(n.x-i.x,n.y-i.y);return{x:i.x+(n.x-i.x)*o,y:i.y+(n.y-i.y)*o,dir:n.dir,moving:s>.001||n.moving,speed:s*1e3/a}}let i=e[n-1],a=t-i.t>400;return{x:i.x,y:i.y,dir:i.dir,moving:i.moving&&!a,speed:0}}function mn(e,t,n,r,i=ot){let a=Math.max(1,Math.ceil(Math.max(Math.abs(n),Math.abs(r))/.5)),o=!1;for(let s=0;s<a;s++){let s=e+n/a;i(s,t)?e=s:o=!0;let c=t+r/a;i(e,c)?t=c:o=!0}return{x:e,y:t,blocked:o}}var hn=class{can;x;y;dir=`down`;moving=!1;running=!1;path=[];pathI=0;pathRun=!1;animT=0;constructor(e,t,n=ot){this.can=n,this.x=e,this.y=t}get hasPath(){return this.pathI<this.path.length}follow(e,t){this.path=e,this.pathI=0,this.pathRun=t}stopPath(){this.path=[],this.pathI=0}correct(e,t){this.x=e,this.y=t,this.stopPath()}update(e,t){let n=this.moving,r=this.running;e=Math.min(.1,Math.max(0,e));let i=t.dx,a=t.dy;if(i||a){this.stopPath();let n=Math.hypot(i,a);i/=n,a/=n;let r=(t.run?6:$t)*e,o=mn(this.x,this.y,i*r,a*r,this.can);this.dir=ln(i,a,this.dir),this.moving=Math.hypot(o.x-this.x,o.y-this.y)>1e-4,this.running=t.run&&this.moving,this.x=o.x,this.y=o.y}else if(this.hasPath){let t=(this.pathRun?6:$t)*e;for(this.moving=!0,this.running=this.pathRun;t>0&&this.hasPath;){let e=this.path[this.pathI],n=this.path[this.pathI+1],r=e-this.x,i=n-this.y,a=Math.hypot(r,i);a<=t?(this.x=e,this.y=n,t-=a,this.pathI+=2,a>1e-6&&(this.dir=ln(r,i,this.dir))):(this.x+=r/a*t,this.y+=i/a*t,this.dir=ln(r,i,this.dir),t=0)}this.hasPath||(this.moving=!1,this.running=!1)}else this.moving=!1,this.running=!1;n!==this.moving||r!==this.running?this.animT=0:this.animT+=e*1e3}};function gn(e,t,n,r){let i=[];for(let r=0;r<e.length;r+=2)i.push(e[r]+t+.5,e[r+1]+n+.5);return r&&i.length>=2?(i[i.length-2]=r.x,i[i.length-1]=r.y):r&&!i.length&&i.push(r.x,r.y),i}function _n(e){return Math.floor(e*100)/100}var vn=class{send;lastAt=-1/0;last=null;constructor(e){this.send=e}tick(e,t){if(e-this.lastAt<100)return!1;let n={x:_n(t.x),y:_n(t.y),dir:sn[t.dir],moving:t.moving},r=this.last;return r&&r.x===n.x&&r.y===n.y&&r.dir===n.dir&&r.moving===n.moving?!1:(this.lastAt=e,this.last=n,this.send({t:`move`,...n}),!0)}keepAlive(e){let t={x:_n(e.x),y:_n(e.y),dir:sn[e.dir],moving:!1};this.lastAt=-1/0,this.last=t,this.send({t:`move`,...t})}reset(){this.last=null,this.lastAt=-1/0}},yn={a:`010101111101101`,b:`110101110101110`,c:`011100100100011`,d:`110101101101110`,e:`111100110100111`,f:`111100110100100`,g:`011100101101011`,h:`101101111101101`,i:`111010010010111`,j:`001001001101010`,k:`101101110101101`,l:`100100100100111`,m:`101111111101101`,n:`110101101101101`,o:`010101101101010`,p:`110101110100100`,q:`010101101110011`,r:`110101110101101`,s:`011100010001110`,t:`111010010010010`,u:`101101101101111`,v:`101101101101010`,w:`101101111111101`,x:`101101010101101`,y:`101101010010010`,z:`111001010100111`,0:`111101101101111`,1:`010110010010111`,2:`110001010100111`,3:`110001010001110`,4:`101101111001001`,5:`111100110001110`,6:`011100111101111`,7:`111001010010010`,8:`111101111101111`,9:`111101111001110`,_:`000000000000111`,"-":`000000111000000`,"#":`101111101111101`,".":`000000000000010`,"(":`010100100100010`,")":`010001001001010`,"/":`001001010100100`," ":`000000000000000`,":":`000010000010000`,",":`000000000010100`,"×":`000101010101000`,"—":`000000111000000`,">":`100010001010100`,"<":`001010100010001`,"+":`000010111010000`},bn={acute:{dy:-3,rows:[`001`,`010`]},grave:{dy:-3,rows:[`100`,`010`]},circ:{dy:-3,rows:[`010`,`101`]},tilde:{dy:-3,rows:[`011`,`110`]},cedilla:{dy:5,rows:[`010`,`110`]}},xn={á:[`a`,`acute`],à:[`a`,`grave`],â:[`a`,`circ`],ã:[`a`,`tilde`],é:[`e`,`acute`],ê:[`e`,`circ`],í:[`i`,`acute`],ó:[`o`,`acute`],ô:[`o`,`circ`],õ:[`o`,`tilde`],ú:[`u`,`acute`],ç:[`c`,`cedilla`]};function Sn(e){return Math.max(0,[...e].length*4-1)}function Cn(e,t,n,r,i){e.fillStyle=i;let a=n;for(let n of t.toLowerCase()){let t=xn[n],i=yn[t?t[0]:n]??yn[` `];for(let t=0;t<15;t++)i[t]===`1`&&e.fillRect(a+t%3,r+Math.floor(t/3),1,1);if(t){let n=bn[t[1]];n.rows.forEach((t,i)=>{for(let o=0;o<3;o++)t[o]===`1`&&e.fillRect(a+o,r+n.dy+i,1,1)})}a+=4}return a-n}var W={w:192,shadow:6,roof:26,floor:11,ground:30,maxFloors:12,cols:11,winX:11,winPitch:16,winW:10,winH:7},wn=[{name:`tijolo`,wall:[`#7c3a2c`,`#9c4935`,`#b45a42`,`#c87256`],pattern:`brick`,trim:[`#cfc3b0`,`#ece4d6`],roof:[`#5d6470`,`#7a828e`],accent:[`#2f6fa8`,`#4f93cf`],frame:`#3a2a26`},{name:`tijolo claro`,wall:[`#9a7656`,`#b48c66`,`#c9a27a`,`#dcb990`],pattern:`brick`,trim:[`#e6ddd0`,`#f6f1e8`],roof:[`#646a74`,`#848a94`],accent:[`#1f7f75`,`#2fa597`],frame:`#4a3a2c`},{name:`concreto`,wall:[`#6f7884`,`#87909c`,`#9ea7b2`,`#b9c1ca`],pattern:`panel`,trim:[`#d6dce3`,`#eef1f4`],roof:[`#4b525c`,`#666d78`],accent:[`#d98a2b`,`#f2a33a`],frame:`#2e3648`},{name:`reboco`,wall:[`#c9c0b0`,`#ddd5c6`,`#ece6da`,`#f8f4ec`],pattern:`stucco`,trim:[`#a8977c`,`#c4b49a`],roof:[`#6f665e`,`#8e857b`],accent:[`#a8322a`,`#cf4a3c`],frame:`#4a4038`},{name:`vidro`,wall:[`#3f6f96`,`#5587b0`,`#6fa3c9`,`#9cc6e4`],pattern:`glass`,trim:[`#cdd8e2`,`#eef3f7`],roof:[`#353d48`,`#4c5562`],accent:[`#7451b8`,`#9a78dc`],frame:`#e8eef4`},{name:`tijolo escuro`,wall:[`#3e3433`,`#4f4241`,`#5f5150`,`#73625f`],pattern:`brick`,trim:[`#bdae98`,`#d8ccb8`],roof:[`#383b42`,`#50545c`],accent:[`#c8902a`,`#e8b04a`],frame:`#1f1a1a`},{name:`painel verde`,wall:[`#3a6e6a`,`#467f7b`,`#559491`,`#6caba7`],pattern:`panel`,trim:[`#dfe9e7`,`#f3f8f7`],roof:[`#3f4a53`,`#58646e`],accent:[`#d8603f`,`#f07c5a`],frame:`#24403e`},{name:`arenito`,wall:[`#b39b74`,`#c6ae86`,`#d8c39d`,`#e8d6b4`],pattern:`stone`,trim:[`#7f6a4c`,`#9c8562`],roof:[`#675e52`,`#83796b`],accent:[`#2f66b8`,`#3f7fd8`],frame:`#4a3d2c`},{name:`marinho`,wall:[`#1f2c4a`,`#283a5e`,`#314870`,`#3d5884`],pattern:`panel`,trim:[`#d58a24`,`#f2a33a`],roof:[`#262b36`,`#3a404c`],accent:[`#d58a24`,`#f2a33a`],frame:`#141b30`},{name:`menta`,wall:[`#7fae96`,`#93bea8`,`#a9cdb8`,`#c3dfcd`],pattern:`stucco`,trim:[`#f0ece2`,`#fbf9f4`],roof:[`#5f6871`,`#7b848d`],accent:[`#c95e8e`,`#e47aa8`],frame:`#3d5a4c`}];function Tn(e){let t=Math.max(0,Math.min(W.maxFloors,Math.floor(e)));return W.roof+t*W.floor+W.ground}function En(e,t){let n=Array.from({length:t},(e,t)=>t),i=r(e*2654435761>>>0);for(let e=t-1;e>0;e--){let t=Math.floor(i()*(e+1));[n[e],n[t]]=[n[t],n[e]]}return n}function Dn(e,t,n){let r=Number.isFinite(e.floors)?Math.max(0,Math.floor(e.floors)):0,i=Math.min(W.maxFloors,r),a=Math.max(0,r-W.maxFloors),o=(n>>>0)%40,s=i*W.cols,c=e.state===`online`?`online`:`away`,l=!e.agents,u=0,d=0;if(c===`online`){if(!e.agents)u=4;else{let t=Math.max(0,e.agents.total);if(t>0){let n=Math.max(0,Math.min(t,e.agents.working));u=Math.round(n/t*8),n>0&&u===0&&(u=1);let r=Math.max(0,Math.min(t,e.agents.waiting));r>0&&(d=Math.max(1,Math.round(r/t*s)))}}}let f=En(o,s),p=Math.round(s*u/8),m=f.slice(0,p),h=f.slice(p,Math.min(s,p+d)),g=e.theme===`halloween`||e.theme===`christmas`?e.theme:`none`;return{side:t,variant:o,style:o%wn.length,drawn:i,plus:a,state:c,theme:g,discreet:l,litLevel:u,lit:m,waiting:h,height:Tn(i)}}function On(e){return`${e.side}|${e.variant}|${e.drawn}|${Math.min(99,e.plus)}|${e.state}|${e.theme}|${e.litLevel}`}function kn(e,t){let n=t%W.cols,r=Math.floor(t/W.cols),i=e.drawn-1-r;return{x:W.winX+n*W.winPitch,y:W.roof+i*W.floor+2,w:W.winW,h:W.winH}}function An(e){return e.side===`front`?{x:34,y:e.height-W.ground+2,w:W.w-68,h:8}:{x:50,y:11,w:W.w-100,h:8}}var jn=new Map,Mn=600;function Nn(e){let t=On(e),n=jn.get(t);return n||(jn.size>=Mn&&jn.clear(),n=zn(e),jn.set(t,n),n)}function Pn(e){return jn.has(On(e))}function Fn(e,t){let n=document.createElement(`canvas`);n.width=e,n.height=t;let r=n.getContext(`2d`);return r.imageSmoothingEnabled=!1,[n,r]}var G=`#2e3648`,K=[`#c98f3c`,`#f2c66b`,`#ffe3a0`,`#fff4d2`],q=[`#1f3550`,`#2b4868`,`#3c5f84`,`#7fa6cc`],In=new Map;function Ln(e){let t=In.get(e);if(!t){let{buf:n}=ce(e);t=document.createElement(`canvas`),t.width=n.w,t.height=n.h,t.getContext(`2d`).putImageData(new ImageData(n.data,n.w,n.h),0,0),In.set(e,t)}return t}function Rn(e,t,n,r){let i=Ln(t);e.drawImage(i,Math.round(n-20),Math.round(r-60))}function J(e,t,n,r,i,a){e.fillStyle=a,e.fillRect(t,n,r,i)}function zn(e){let t=W.w+W.shadow,n=e.height,[i,a]=Fn(t,n),[o,s]=Fn(t,n),c=wn[e.style],l=r((e.variant+1)*2654435761>>>0),u=e.state===`online`,d=W.roof,f=n-W.ground,p=W.w;a.fillStyle=`rgba(28,36,52,0.22)`,a.fillRect(p,6,W.shadow,n-6),a.fillStyle=`rgba(28,36,52,0.12)`,a.fillRect(p,10,2,n-10),Bn(a,c,0,d,p,n-d,l);for(let t=0;t<=e.drawn;t++)J(a,0,d+t*W.floor-1,p,1,c.pattern===`glass`?c.trim[0]:Y(c.wall[0],-.08));J(a,0,d,3,n-d,c.trim[0]),J(a,p-3,d,3,n-d,c.trim[0]),J(a,0,d,1,n-d,c.trim[1]);let m=new Set(e.lit),h=e.drawn*W.cols;for(let t=0;t<h;t++){let n=kn(e,t);Vn(a,c,n.x,n.y,m.has(t),(e.variant*31+t)%7),m.has(t)&&Hn(s,n.x,n.y)}if(e.side===`back`&&e.drawn>0){Un(a,e.variant%2==0?W.winX+W.winPitch-3:W.winX+(W.cols-2)*W.winPitch-3,d,e.drawn);for(let t=0;t<e.drawn;t++)if(l()<.45){let n=2+Math.floor(l()*(W.cols-4)),r=kn(e,(e.drawn-1-t)*W.cols+n);Wn(a,r.x+1,r.y+r.h+1)}}if(e.side===`front`?Gn(a,s,c,e,f,u,l):Kn(a,s,c,e,f,u,l),Jn(a,s,c,e,l),Xn(a,s,e,f),e.side===`back`&&Yn(a,s,c,e),u||qn(a,p/2,e.side===`front`?f+16:1),e.plus>0){let t=`+${Math.min(99,e.plus)}`,n=Sn(t),r=e.side===`front`?p-n-18:16,i=e.side===`front`?6:13;J(a,r-3,i-3,n+6,11,G),J(a,r-2,i-2,n+4,9,u?c.accent[1]:`#5a6170`),J(a,r-2,i-2,n+4,1,u?er(c.accent[1],.25):`#6d7483`),Cn(a,t,r,i,`#ffffff`),J(a,r+n/2-1,i+8,2,3,G),u&&(s.fillStyle=`rgba(255,255,255,0.85)`,Cn(s,t,r,i,`#fff6dc`))}return{canvas:i,glow:o,w:t,h:n}}function Bn(e,t,n,r,i,a,o){let[s,c,l,u]=t.wall;switch(J(e,n,r,i,a,c),t.pattern){case`brick`:for(let t=r;t<r+a;t+=3){let a=(t-r)/3%2==0?0:3;J(e,n,t+2,i,1,s);for(let r=n+a;r<n+i;r+=6){J(e,r,t,1,2,s);let n=o();n<.18?J(e,r+1,t,5,2,l):n<.26&&J(e,r+1,t,5,2,Y(c,-.06))}}break;case`panel`:for(let t=n;t<n+i;t+=24)J(e,t,r,1,a,s);for(let t=r+5;t<r+a;t+=11)J(e,n,t,i,1,Y(c,-.05));J(e,n,r,i,1,l);break;case`stucco`:for(let t=0;t<i*a/40;t++)J(e,n+Math.floor(o()*i),r+Math.floor(o()*a),1,1,o()<.5?l:Y(c,-.04));break;case`stone`:for(let t=r;t<r+a;t+=5){J(e,n,t+4,i,1,s);let a=(t-r)/5%2==0?0:7;for(let r=n+a;r<n+i;r+=14)J(e,r,t,1,4,s),o()<.3&&J(e,r+1,t,13,1,u)}break;case`glass`:J(e,n,r,i,a,t.wall[1]);for(let o=r;o<r+a;o++)(o-r)%11<3&&J(e,n,o,i,1,t.wall[2]);for(let o=n+3;o<n+i;o+=16)J(e,o,r,1,a,t.frame);e.fillStyle=`rgba(255,255,255,0.12)`;for(let t=0;t<a;t++)e.fillRect(n+(t*2+40)%(i+40)-20,r+t,10,1)}}function Vn(e,t,n,r,i,a){let o=W.winW,s=W.winH;t.pattern!==`glass`&&(J(e,n-1,r-1,o+2,s+2,t.frame),J(e,n-1,r+s+1,o+2,1,t.trim[1]),J(e,n-1,r+s+2,o+2,1,Y(t.trim[0],-.15))),i?(J(e,n,r,o,s,K[2]),J(e,n,r,o,2,K[3]),J(e,n,r+s-2,o,2,K[1]),J(e,n+2+a%4,r+s-3,3,2,`#5fb8f0`),J(e,n+2+a%4,r+s-3,1,1,`#c8ecff`),(a===2||a===5)&&J(e,n+6-a%3,r+s-4,2,3,`#7a5a3a`)):(J(e,n,r,o,s,q[1]),J(e,n,r,o,2,q[0]),J(e,n,r+s-1,o,1,q[2]),J(e,n+1+a%3,r+2,1,3,q[3]),J(e,n+2+a%3,r+2,1,1,`#b8d2ea`),a===4&&J(e,n+1,r+1,o-2,2,`#c9cfd9`)),J(e,n+(o>>1),r,1,s,t.pattern===`glass`?t.frame:Y(t.frame,.1))}function Hn(e,t,n){let r=W.winW,i=W.winH;e.fillStyle=K[2],e.fillRect(t,n,r,i),e.fillStyle=K[3],e.fillRect(t,n,r,2),e.fillStyle=`#5fb8f0`,e.fillRect(t+3,n+i-3,3,2),e.fillStyle=`rgba(255,214,140,0.35)`,e.fillRect(t-1,n-1,r+2,i+2)}function Un(e,t,n,r){let i=`#2a2f3a`,a=`#5b6475`;for(let o=0;o<r;o++){let s=n+o*W.floor+W.floor-2;J(e,t-2,s,18,1,a),J(e,t-2,s+1,18,1,i),J(e,t-2,s-4,18,1,i);for(let n=0;n<18;n+=3)J(e,t-2+n,s-4,1,4,i);if(o<r-1){let n=o%2==0?1:-1;for(let r=0;r<W.floor;r++)J(e,t+7+n*(r-5),s+2+r,2,1,r%2?i:a)}}}function Wn(e,t,n){J(e,t,n,7,4,G),J(e,t+1,n,5,3,`#c9d0d8`),J(e,t+1,n,5,1,`#e8edf2`),J(e,t+2,n+1,3,1,`#8b95a3`)}function Gn(e,t,n,r,i,a,o){let s=W.w,c=r.height-2;J(e,0,i,s,W.ground,n.trim[0]),J(e,0,i,s,1,n.trim[1]),J(e,0,i+1,s,1,Y(n.trim[0],-.2));let l=An(r);J(e,l.x-2,l.y-1,l.w+4,l.h+2,G),J(e,l.x-1,l.y,l.w+2,l.h,a?n.accent[0]:`#4a505c`),J(e,l.x-1,l.y,l.w+2,1,a?n.accent[1]:`#5b6270`),a&&(t.fillStyle=`rgba(255,240,200,0.55)`,t.fillRect(l.x-1,l.y,l.w+2,l.h));let u=s/2-16,d=s/2+16,f=i+12,p=c-f-2;for(let[r,i]of[[6,u-6],[d+6,s-6]]){if(J(e,r-1,f-1,i-r+2,p+2,G),a){J(e,r,f,i-r,p,K[2]),J(e,r,f,i-r,2,K[3]),J(e,r,f+p-3,i-r,3,K[1]);for(let t=r+4;t<i-4;t+=9+Math.floor(o()*5))J(e,t,f+p-6,5,3,`#8a6243`),o()<.5?J(e,t+1,f+p-9,3,3,`#4b8a45`):J(e,t+1,f+p-8,3,2,`#5fb8f0`);t.fillStyle=K[2],t.fillRect(r,f,i-r,p),t.fillStyle=`rgba(255,214,140,0.3)`,t.fillRect(r-2,f-2,i-r+4,p+4)}else{J(e,r,f,i-r,p,q[1]),J(e,r,f,i-r,2,q[0]);for(let t=r+3;t<i;t+=13)J(e,t,f+2,2,p-3,q[2])}for(let t=r+16;t<i-2;t+=16)J(e,t,f,1,p,n.frame===`#e8eef4`?`#cdd8e2`:G);J(e,r-1,f-4,i-r+2,3,n.accent[0]);for(let t=r;t<i;t+=4)J(e,t,f-4,2,3,n.accent[1]);J(e,r-1,f-1,i-r+2,1,Y(n.accent[0],-.25))}let m=i+9;J(e,u-2,m-2,36,c-m+2,G),J(e,u-1,m-1,34,c-m+1,n.trim[1]);for(let n of[u,s/2+1])J(e,n,m,15,c-m,G),J(e,n+1,m+1,13,c-m-1,a?`#f6dd9a`:q[1]),J(e,n+1,m+1,13,2,a?K[3]:q[0]),J(e,n+2,m+3,1,c-m-6,a?`#fff6dc`:q[3]),J(e,n===u?n+12:n+2,m+9,1,4,`#c9cfd9`),a&&(t.fillStyle=`#f6dd9a`,t.fillRect(n+1,m+1,13,c-m-1));J(e,0,c,s,2,Y(n.trim[0],-.25)),J(e,u-4,c-1,40,3,`#c9cdd3`),J(e,u-4,c-1,40,1,`#e4e7eb`);for(let n of[u-6,d+4])J(e,n,m+2,3,4,G),J(e,n+1,m+3,1,2,a?`#fff1b8`:`#8b95a3`),a&&(t.fillStyle=`rgba(255,230,160,0.9)`,t.fillRect(n,m+2,3,4),t.fillStyle=`rgba(255,220,150,0.25)`,t.fillRect(n-3,m,9,10))}function Kn(e,t,n,r,i,a,o){let s=W.w,c=r.height-2;J(e,0,i,s,2,Y(n.wall[0],-.1));for(let r=12;r<s-12;r+=22){if(Math.abs(r+5-s/2)<18)continue;J(e,r-1,i+5,12,6,n.frame);let c=a&&o()<.5;J(e,r,i+6,10,4,c?K[2]:q[1]),J(e,r,i+6,10,1,c?K[3]:q[0]),c&&(t.fillStyle=K[2],t.fillRect(r,i+6,10,4))}let l=s/2-7;J(e,l-1,i+9,16,c-i-9,G),J(e,l,i+10,14,c-i-10,`#7d8794`),J(e,l,i+10,14,1,`#a9b2bd`),J(e,l+11,i+18,1,3,`#d9dee4`),J(e,l+3,i+12,8,2,`#5f6875`),J(e,l+5,i+6,4,2,a?`#fff1b8`:`#8b95a3`),a&&(t.fillStyle=`rgba(255,230,160,0.9)`,t.fillRect(l+5,i+6,4,2));for(let[t,n]of[[22,`#3f7f4f`],[32,`#2f5f9e`]])J(e,t-1,c-9,9,9,G),J(e,t,c-8,7,8,n),J(e,t,c-8,7,2,er(n,.2));let u=s-40;for(let t=0;t<2;t++){let n=u+t*12;e.strokeStyle=`#2a2f3a`,e.lineWidth=1,e.beginPath(),e.arc(n+2.5,c-3.5,3,0,Math.PI*2),e.arc(n+10.5,c-3.5,3,0,Math.PI*2),e.stroke(),J(e,n+3,c-6,7,1,t?`#cf4a3c`:`#2fa597`)}J(e,0,c,s,2,Y(n.trim[0],-.25))}function qn(e,n,r){let i=t(`Fechado`),a=Math.min(40,Sn(i)),o=a+6,s=Math.round(n-o/2);J(e,s+2,r-4,1,4,`#3a2a20`),J(e,s+o-3,r-4,1,4,`#3a2a20`),J(e,s-1,r-1,o+2,10,`#3a2a20`),J(e,s,r,o,8,`#c98f5a`),J(e,s,r,o,1,`#e3ad78`),e.save(),e.beginPath(),e.rect(s+3,r,a,8),e.clip(),Cn(e,i,s+3,r+2,`#3a2a20`),e.restore()}function Jn(e,t,n,r,i){let a=W.w,o=W.roof,s=r.state===`online`;J(e,0,0,a,o-5,G),J(e,1,1,a-2,o-6,n.roof[1]),J(e,3,3,a-6,o-10,n.roof[0]);for(let t=0;t<90;t++)J(e,3+Math.floor(i()*(a-6)),3+Math.floor(i()*(o-10)),1,1,i()<.5?n.roof[1]:Y(n.roof[0],-.12));J(e,0,o-5,a,4,n.trim[0]),J(e,0,o-5,a,1,n.trim[1]),J(e,0,o-2,a,1,Y(n.trim[0],-.3)),J(e,0,o-1,a,1,`rgba(28,36,52,0.35)`);let c=r.side===`back`?[14,150]:[14,60,120,160];for(let t of c){let n=i(),r=t+Math.floor(i()*10);n<.35?(J(e,r,4,12,12,G),J(e,r+1,5,10,10,`#9aa6b4`),J(e,r+1,5,10,3,`#c3ccd6`),J(e,r+3,6,6,1,`#e3e8ee`)):n<.7?(J(e,r,6,14,9,G),J(e,r+1,7,12,7,`#d4dae1`),J(e,r+1,7,12,2,`#eef1f4`),J(e,r+4,9,6,4,`#8b95a3`),J(e,r+6,10,2,2,`#5f6875`)):(J(e,r,6,16,9,G),J(e,r+1,7,14,7,s?`#9cc6e4`:`#3c5f84`),J(e,r+1,7,14,2,`#c8e2f4`),J(e,r+8,7,1,7,G))}if(i()<.5){let n=r.side===`back`?176:100+Math.floor(i()*40);J(e,n,1,1,9,`#4a5468`),J(e,n-2,3,5,1,`#4a5468`),J(e,n,1,1,1,s?`#ff5a4a`:`#8b95a3`),s&&(t.fillStyle=`#ff5a4a`,t.fillRect(n,1,1,1))}}function Yn(e,t,n,r){let i=W.w,a=r.state===`online`;{let o=An(r);J(e,o.x-2,o.y-1,o.w+4,o.h+2,G),J(e,o.x-1,o.y,o.w+2,o.h,a?n.accent[0]:`#4a505c`),J(e,o.x-1,o.y,o.w+2,1,a?n.accent[1]:`#5b6270`),a&&(t.fillStyle=`rgba(255,240,200,0.55)`,t.fillRect(o.x-1,o.y,o.w+2,o.h));let s=i/2-22;J(e,s-1,0,46,10,G);for(let t=0;t<44;t++){let r=Math.floor(t/4)%2==0;J(e,s+t,0,1,9,r?n.accent[1]:`#f6efe2`)}J(e,s,0,44,2,`rgba(255,255,255,0.35)`),J(e,s,7,44,2,`rgba(28,36,52,0.25)`);for(let n of[s+3,s+39])J(e,n,1,2,2,a?`#fff1b8`:`#8b95a3`),a&&(t.fillStyle=`rgba(255,230,160,0.95)`,t.fillRect(n,1,2,2))}}function Xn(e,t,n,r){if(n.theme===`none`){if(n.side===`front`){let t=W.w,r=n.height-2;for(let n of[t/2-26,t/2+20])J(e,n,r-6,6,6,G),J(e,n+1,r-5,4,5,`#c97a4a`),J(e,n-1,r-11,8,6,`#3f8550`),J(e,n,r-12,6,2,`#5aa45d`)}return}let i=W.w,a=W.roof,o=n.state===`online`,s=n.theme===`christmas`;if(s){e.fillStyle=`#f4f8fb`;for(let t=2;t<i-2;t+=1){let n=Math.sin(t*.35)+Math.sin(t*.11);n>-.4&&e.fillRect(t,2,1,2+ +(n>.8))}e.fillRect(0,a-6,i,2),e.fillStyle=`#dbe6ee`,e.fillRect(0,a-4,i,1);for(let t=6;t<i-6;t+=23)e.fillRect(t,6+t%7,6,2)}let c=s?[`#ff5a5a`,`#ffd76a`,`#6ad1ff`,`#7be07b`]:[`#b06ae6`,`#ff9a3c`];for(let n=4,r=0;n<i-2;n+=6,r++){let i=a+r%2;J(e,n,i-1,1,1,`#2e3648`),J(e,n,i,2,2,c[r%c.length]),o&&(t.fillStyle=c[r%c.length],t.fillRect(n,i,2,2),t.globalAlpha=.35,t.fillRect(n-1,i-1,4,4),t.globalAlpha=1)}if(!s){e.strokeStyle=`rgba(230,220,240,0.8)`,e.lineWidth=1;for(let t of[1,-1]){let n=t===1?3.5:i-3.5,r=a+.5;e.beginPath();for(let[i,a]of[[9,0],[7,5],[0,9]])e.moveTo(n,r),e.lineTo(n+t*i,r+a);e.moveTo(n+t*4,r),e.lineTo(n+t*3,r+3),e.lineTo(n,r+4),e.stroke()}for(let t of[40,132]){let n=a-9;J(e,t,n,3,2,`#47344f`),J(e,t-3,n-1,3,2,`#47344f`),J(e,t+3,n-1,3,2,`#47344f`),J(e,t+1,n,1,1,`#f5b95f`)}}let l=n.height-2;n.side===`front`?s?(Zn(e,t,i/2-19,r+6,38,o),Rn(e,`tree`,i-30,l+2),Rn(e,`gift`,i-52,l+2)):(Rn(e,`pumpkin`,i/2-28,l+2),Rn(e,`pumpkin`,i/2+28,l+2),n.drawn>0&&Rn(e,`ghost`,30,r+6)):s?(Zn(e,t,i/2-10,r+6,20,o),Rn(e,`tree`,i/2+30,l+2)):(Rn(e,`pumpkin`,i/2-22,l+2),Rn(e,`pumpkin`,i/2+22,l+2))}function Zn(e,t,n,r,i,a){for(let o=0;o<i;o++){let s=Math.round(Math.sin(o/i*Math.PI)*3);J(e,n+o,r+s,1,3,o%3==0?`#245644`:`#347653`),o%6==3&&(J(e,n+o,r+s+2,2,2,[`#ffd76a`,`#ff5a5a`,`#6ad1ff`][o/6%3|0]),a&&(t.fillStyle=`#ffe9a8`,t.fillRect(n+o,r+s+2,2,2)))}for(let t of[n-1,n+i-3])J(e,t,r-1,4,3,`#c93945`),J(e,t+1,r+2,1,3,`#a82d42`),J(e,t+2,r+2,1,2,`#a82d42`)}function Qn(e){let t=parseInt(e.slice(1,7),16);return[t>>16&255,t>>8&255,t&255]}function $n(e,t,n){let r=e=>Math.max(0,Math.min(255,Math.round(e))).toString(16).padStart(2,`0`);return`#${r(e)}${r(t)}${r(n)}`}function Y(e,t){let[n,r,i]=Qn(e);return t<0?$n(n*(1+t),r*(1+t),i*(1+t)):$n(n+(255-n)*t,r+(255-r)*t,i+(255-i)*t)}function er(e,t){return Y(e,Math.abs(t))}function tr(e,t){let n=document.createElement(`canvas`);n.width=e,n.height=t;let r=n.getContext(`2d`);return r.imageSmoothingEnabled=!1,[n,r]}var X=e=>e*16;function nr(e){try{e()}catch{}}function rr(e,t,n,r,i,a=.16){e.save();try{e.globalCompositeOperation=`saturation`,e.fillStyle=`rgba(128,128,128,${a})`,e.fillRect(t,n,r,i)}catch{}e.restore()}function ir(e,t,n,r,i,a){let o=`#e2dfd6`,s=`#8d8a82`,c=`#5f5c56`;a===`s`?(e.fillStyle=o,e.fillRect(t,n+i-3,r,1),e.fillStyle=s,e.fillRect(t,n+i-2,r,2),e.fillStyle=c,e.fillRect(t,n+i,r,1)):a===`n`?(e.fillStyle=c,e.fillRect(t,n,r,1),e.fillStyle=o,e.fillRect(t,n+1,r,1)):a===`e`?(e.fillStyle=o,e.fillRect(t+r-2,n,1,i),e.fillStyle=s,e.fillRect(t+r-1,n,1,i),e.fillStyle=`rgba(40,40,40,0.35)`,e.fillRect(t+r,n,1,i)):(e.fillStyle=`rgba(40,40,40,0.35)`,e.fillRect(t-1,n,1,i),e.fillStyle=s,e.fillRect(t,n,1,i),e.fillStyle=o,e.fillRect(t+1,n,1,i))}function ar(e,t,n){let i=tt();for(let n of[...i.streets,i.intersection])nr(()=>e.drawFloor(t,`street`,X(n.x),X(n.y),X(n.w),X(n.h),{seed:13}));t.fillStyle=`rgba(20,22,28,0.18)`;let a=X(i.sidewalkOuter.w),o=X(i.sidewalkOuter.h);t.fillRect(a,0,3,o),t.fillRect(0,o,a,3),t.fillStyle=`rgba(255,226,140,0.85)`;for(let[e,n,r,a]of i.laneMarks)if(n===a)for(let i=X(e);i<X(r)-8;i+=24)t.fillRect(i,X(n)-1,12,2);else for(let r=X(n);r<X(a)-8;r+=24)t.fillRect(X(e)-1,r,2,12);for(let e of i.crosswalks){let n=e.rect;if(t.fillStyle=`rgba(244,244,236,0.9)`,e.across===`ns`)for(let e=X(n.y)+4;e<X(n.y+n.h)-3;e+=6)t.fillRect(X(n.x)+3,e,X(n.w)-6,3);else for(let e=X(n.x)+4;e<X(n.x+n.w)-3;e+=6)t.fillRect(e,X(n.y)+3,3,X(n.h)-6)}t.fillStyle=`rgba(244,244,236,0.75)`,t.fillRect(a-2,o+2,2,X(2)-2),t.fillRect(a+X(3),o-2,X(2)-2,2);let s=r(n);for(let e=0;e<3;e++){let e=X(4+Math.floor(s()*36));t.fillStyle=`#3a3d44`,t.fillRect(e,o+4,10,3),t.fillStyle=`#2a2c31`;for(let n=1;n<10;n+=2)t.fillRect(e+n,o+4,1,3)}let c=a+X(2)+2,l=X(8+Math.floor(s()*10));t.fillStyle=`#3f4249`,t.beginPath(),t.ellipse(c+6,l+5,6,4.5,0,0,Math.PI*2),t.fill(),t.fillStyle=`#585c64`,t.fillRect(c+2,l+4,8,1),t.fillRect(c+3,l+6,6,1)}function or(e,t){let n=tt().sidewalkOuter;nr(()=>e.drawFloor(t,`sidewalk`,X(n.x),X(n.y),X(n.w),X(n.h),{seed:12})),ir(t,0,0,X(n.w),2,`n`),ir(t,0,X(n.h)-3,X(n.w),3,`s`),ir(t,0,0,2,X(n.h),`w`),ir(t,X(n.w)-3,0,3,X(n.h),`e`)}function sr(e,t){let n=tt(),r=n.block;nr(()=>e.drawFloor(t,`grass`,X(r.x),X(r.y),X(r.w),X(r.h),{seed:11})),rr(t,X(r.x),X(r.y),X(r.w),X(r.h)),t.fillStyle=`rgba(40,70,40,0.18)`;for(let e of n.lots)t.fillRect(X(e.x+e.w)-1,X(e.y),1,X(e.h)),t.fillRect(X(e.x),X(e.y+e.h)-1,X(e.w),1);let a=X(r.x),o=X(r.y),s=X(r.w),c=X(r.h);t.fillStyle=`#9a968c`,t.fillRect(a,o,s,2),t.fillRect(a,o+c-2,s,2),t.fillRect(a,o,2,c),t.fillRect(a+s-2,o,2,c),t.fillStyle=`#c9c5bb`,t.fillRect(a,o,s,1),t.fillRect(a,o+c-2,s,1),t.fillRect(a,o,1,c),t.fillRect(a+s-2,o,1,c);for(let a of n.lots){let n=a.y===r.y,s=X(a.x+i.dx);nr(()=>e.drawFloor(t,`sidewalk`,s,n?o:o+c-2,X(i.w),2,{seed:12}))}}function cr(e){let t=tt(),[n,r]=tr(X(t.sidewalkOuter.w+t.streets[0].w),X(t.sidewalkOuter.h+t.streets[1].h));return ar(e,r,77),or(e,r),sr(e,r),n}function lr(e){let t=tt(),[n,r]=tr(X(t.sidewalkOuter.w+t.streets[0].w),X(t.sidewalkOuter.h+t.streets[1].h));ar(e,r,99),or(e,r);let i=t.block,a=X(i.x),o=X(i.y),s=X(i.w),c=X(i.h);nr(()=>e.drawFloor(r,`sidewalk`,a,o,s,c,{seed:23})),r.fillStyle=`rgba(196,150,96,0.10)`,r.fillRect(a,o,s,c),r.fillStyle=`#9a8f80`,r.fillRect(a+X(1),o+X(1),s-X(2),3),r.fillRect(a+X(1),o+c-X(1)-3,s-X(2),3),r.fillRect(a+X(1),o+X(1),3,c-X(2)),r.fillRect(a+s-X(1)-3,o+X(1),3,c-X(2)),r.fillStyle=`rgba(255,248,232,0.5)`,r.fillRect(a+X(1),o+X(1),s-X(2),1);let l=a+X(y.x+y.w/2),u=o+X(y.y+y.h/2);r.fillStyle=`rgba(236,226,206,0.55)`,r.fillRect(l-X(1.5),o+X(1)+3,X(3),c-X(2)-6),r.fillRect(a+X(1)+3,u-X(1.5),s-X(2)-6,X(3)),r.fillStyle=`rgba(140,128,110,0.45)`;for(let e of[-1,1])r.fillRect(l+e*X(1.5)-+(e>0),o+X(1)+3,1,c-X(2)-6),r.fillRect(a+X(1)+3,u+e*X(1.5)-+(e>0),s-X(2)-6,1);let d=[[2,2,10,6],[i.w-12,2,10,6],[2,i.h-8,10,6],[i.w-12,i.h-8,10,6]];for(let[t,n,i,s]of d){let c=a+X(t),l=o+X(n);r.fillStyle=`#8d8a82`,r.fillRect(c-2,l-2,X(i)+4,X(s)+4),r.fillStyle=`#d8d4ca`,r.fillRect(c-2,l-2,X(i)+4,1),nr(()=>e.drawFloor(r,`grass`,c,l,X(i),X(s),{seed:31})),rr(r,c,l,X(i),X(s))}let f=y,p=a+X(f.x+f.w/2),m=o+X(f.y+f.h/2);r.save(),r.beginPath(),r.ellipse(p,m,X(7),X(5.2),0,0,Math.PI*2),r.clip(),nr(()=>e.drawFloor(r,`marble`,p-X(8),m-X(6),X(16),X(12),{seed:41})),r.restore(),r.strokeStyle=`#8f8676`,r.lineWidth=3,r.beginPath(),r.ellipse(p,m,X(7)-1,X(5.2)-1,0,0,Math.PI*2),r.stroke(),r.strokeStyle=`rgba(63,127,216,0.35)`,r.lineWidth=2,r.setLineDash([4,4]),r.beginPath(),r.ellipse(p,m+4,X(4.8),X(3.4),0,0,Math.PI*2),r.stroke(),r.setLineDash([]),r.strokeStyle=`rgba(255,255,255,0.5)`,r.lineWidth=1,r.beginPath(),r.ellipse(p,m-1,X(7)-2,X(5.2)-2,0,Math.PI,Math.PI*2),r.stroke();let h=a+X(21)+8,g=o+X(15)+8;return r.fillStyle=`#b9b2a4`,r.beginPath(),r.moveTo(h,g-12),r.lineTo(h+4,g),r.lineTo(h,g+12),r.lineTo(h-4,g),r.closePath(),r.fill(),r.beginPath(),r.moveTo(h-12,g),r.lineTo(h,g-4),r.lineTo(h+12,g),r.lineTo(h,g+4),r.closePath(),r.fill(),r.fillStyle=`#f2a33a`,r.fillRect(h-1,g-11,2,6),n}function ur(e,t,n,r){let[a,o]=tr(X(A.w),X(A.h)),s=X(i.dx),c=(t,n,i,a)=>{o.fillStyle=`#9a968c`,o.fillRect(t-1,n-1,i+2,a+2),nr(()=>e.drawFloor(o,`sidewalk`,t,n,i,a,{seed:12+r%3}))},l=X(A.h/2);switch(t){case`park`:n?c(s,0,X(2),l+8):c(s,l-8,X(2),X(A.h)-l+8),c(X(2),l-8,X(10),X(1)),o.fillStyle=`#6a4b35`,o.beginPath(),o.ellipse(X(7),l+14,18,7,0,0,Math.PI*2),o.fill(),o.strokeStyle=`#b9b5aa`,o.lineWidth=2,o.stroke();break;case`pond`:{n?c(s,0,X(2),X(2)):c(s,X(A.h-2),X(2),X(2));let e=X(7),t=l+(n?4:-4);o.fillStyle=`#8d8a82`,o.beginPath(),o.ellipse(e,t,X(4.6),X(2.8),0,0,Math.PI*2),o.fill(),o.fillStyle=`#3f7fa8`,o.beginPath(),o.ellipse(e,t,X(4.6)-3,X(2.8)-3,0,0,Math.PI*2),o.fill(),o.fillStyle=`#5aa0c8`,o.beginPath(),o.ellipse(e-6,t-6,X(3),X(1.4),0,0,Math.PI*2),o.fill(),o.fillStyle=`rgba(255,255,255,0.55)`;for(let[n,r]of[[e-30,t-4],[e+12,t+6],[e+28,t-8]])o.fillRect(n,r,5,1);o.fillStyle=`#4b8a45`;for(let[n,r]of[[e+20,t+3],[e-22,t+8]])o.beginPath(),o.ellipse(n,r,4,2.5,0,0,Math.PI*2),o.fill();o.fillStyle=`#f28fb0`,o.fillRect(e+19,t+2,2,1);break}case`orchard`:o.fillStyle=`rgba(106,75,53,0.55)`;for(let e=0;e<2;e++)o.fillRect(X(1),X((n?3.4:2.4)+e*4.4),X(12),6);n?c(s,0,X(2),X(1.4)):c(s,X(A.h-1.4),X(2),X(1.4));break;case`cafe`:o.fillStyle=`#8d8a82`,o.fillRect(X(2)-2,l-X(2)-2,X(10)+4,X(4)+4),nr(()=>e.drawFloor(o,`wood`,X(2),l-X(2),X(10),X(4),{seed:8})),n?c(s,0,X(2),l-X(2)):c(s,l+X(2),X(2),X(A.h)-l-X(2))}return a}function dr(){let e=X(6),t=X(5),[n,r]=tr(e,t),i=e/2,a=t-2,o=X(2.9),s=X(1.75),c=a-7-s,l=(e,t,n,i)=>{r.beginPath();for(let a=0;a<8;a++){let o=Math.PI/8+a*Math.PI/4,s=e+Math.cos(o)*n,c=t+Math.sin(o)*i;a===0?r.moveTo(s,c):r.lineTo(s,c)}r.closePath()};r.fillStyle=`rgba(28,36,52,0.22)`,l(i+4,c+7+3,o+2,s+1),r.fill(),r.fillStyle=`#6f6a62`,l(i,c+7,o,s),r.fill(),r.fillRect(i-o*.92,c,o*1.84,7),r.fillStyle=`#9a948a`,r.fillRect(i-o*.92,c+1,o*1.84,4),r.fillStyle=`rgba(255,255,255,0.18)`;for(let e=Math.round(i-o*.9);e<i+o*.9;e+=9)r.fillRect(e,c+2,1,3);r.fillStyle=`#c9c3b6`,l(i,c,o,s),r.fill(),r.fillStyle=`#e4dfd4`,l(i,c-1,o-2,s-1.5),r.fill(),r.fillStyle=`#2f75a8`,l(i,c+1,o-6,s-5),r.fill(),r.fillStyle=`#3f8bc2`,l(i,c,o-8,s-7),r.fill(),r.fillStyle=`rgba(160,214,245,0.55)`,r.beginPath(),r.ellipse(i-o*.35,c-s*.3,o*.32,s*.18,0,0,Math.PI*2),r.fill();let u=c-3;r.fillStyle=`#7d776d`,r.fillRect(i-4,u-10,8,12),r.fillStyle=`#c9c3b6`,r.fillRect(i-4,u-10,3,12);let d=(e,t)=>{r.fillStyle=`#6f6a62`,r.beginPath(),r.ellipse(i,e+2,t,t*.34,0,0,Math.PI*2),r.fill(),r.fillStyle=`#d8d2c6`,r.beginPath(),r.ellipse(i,e,t,t*.32,0,0,Math.PI*2),r.fill(),r.fillStyle=`#4b9ad0`,r.beginPath(),r.ellipse(i,e,t-3,t*.32-2,0,0,Math.PI*2),r.fill()};return d(u-11,15),r.fillStyle=`#7d776d`,r.fillRect(i-2,u-24,4,13),r.fillStyle=`#c9c3b6`,r.fillRect(i-2,u-24,2,13),d(u-25,8),r.fillStyle=`#d8d2c6`,r.fillRect(i-1,u-30,3,5),r.fillStyle=`#f2a33a`,r.fillRect(i,u-32,1,2),{canvas:n,ax:Math.round(i),ay:a,water:{x:i,y:c,rx:o-8,ry:s-7},jet:{x:i,y:u-31}}}function fr(e){let[t,n]=tr(24,16),i=r(e);n.fillStyle=`rgba(28,36,52,0.2)`,n.fillRect(3,13,20,2),n.fillStyle=`#7d7a73`,n.fillRect(2,7,20,7),n.fillStyle=`#b9b5aa`,n.fillRect(2,7,20,2),n.fillStyle=`#5b3c25`,n.fillRect(3,6,18,2);let a=[`#e8574a`,`#f2c94c`,`#f08bb0`,`#ffffff`,`#9b7be0`];for(let e=0;e<14;e++){let e=3+Math.floor(i()*18),t=1+Math.floor(i()*6);n.fillStyle=`#3f8550`,n.fillRect(e,t+1,1,2),n.fillStyle=a[Math.floor(i()*a.length)],n.fillRect(e,t,1,1)}return{canvas:t,ax:12,ay:14}}X(l.w+4+5),X(l.h+4+5);var pr=`ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif`,mr=`"Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif`,hr=.6,gr=1.05,_r=.85,vr=1200,yr=8,br=6,xr=2,Sr=null;function Cr(){if(Sr)return Sr;Sr=document.createElement(`canvas`),Sr.width=64,Sr.height=64;let e=Sr.getContext(`2d`),t=e.createRadialGradient(32,32,0,32,32,32);return t.addColorStop(0,`rgba(255,226,170,1)`),t.addColorStop(.4,`rgba(255,214,150,0.75)`),t.addColorStop(1,`rgba(255,214,150,0)`),e.fillStyle=t,e.fillRect(0,0,64,64),Sr}var wr=class{canvas;art;camera;state;ctx;buildingsDrawn=[];charsDrawn=[];nb=0;nc=0;bPool=[];cPool=[];ents=[];ePool=[];cell=null;plaza=null;gardens=new Map;blocks=new Map;lotDecors=new Map;facades=new Map;appearances=new Map;anims=new Map;fountain=null;planters=new Map;req={appearance:null,dir:`down`,pose:`stand`,frame:0,held:`none`,seated:!1};lamps=[];ambient=oe(12);target=this.ambient;ambientAt=-1e9;lastNow=0;mode=``;hourOverride=ae(typeof location>`u`?``:location.search);night=0;widths=new Map;signBoxes=[];labelBoxes=[];lastFrameMs=0;fx=null;constructor(e,t,n,r){this.canvas=e,this.art=t,this.camera=n,this.state=r,this.ctx=e.getContext(`2d`,{alpha:!1})}blockInfo(e,t){let n=(e+32768)*65536+(t+32768),r=this.blocks.get(n);if(!r){this.blocks.size>600&&this.blocks.clear();let i={x:e,y:t},a=Qe(i);r={bx:e,by:t,cell:$e(i),lots:a,keys:a.map(U),decor:mt(i),plaza:te(i)},this.blocks.set(n,r)}return r}lotDecor(e,t,n){let r=n?`${t}|p`:t,i=this.lotDecors.get(r);return i||(this.lotDecors.size>2e3&&this.lotDecors.clear(),i=ft(e,n),this.lotDecors.set(r,i)),i}garden(e){let t=dt(e),n=Ze(e),r=`${t}|${n?`n`:`s`}`,i=this.gardens.get(r);return i||this.gardens.set(r,i=ur(this.art,t,n,Xe(e))),i}facadeOf(e){let t=e.agents,n=`${e.floors}|${e.state}|${e.theme}|${t?`${t.total},${t.working},${t.waiting}`:`-`}|${e.lot.x},${e.lot.y}`,r=this.facades.get(e.id);return(!r||r.sig!==n)&&(this.facades.size>4e3&&this.facades.clear(),r={sig:n,m:Dn(e,Ze(e.lot)?`back`:`front`,Xe(e.lot))},this.facades.set(e.id,r)),r.m}appearanceOf(e,t,r){let i=`${t}|${m(r)}`,a=this.appearances.get(e);return(!a||a.key!==i)&&(this.appearances.size>500&&this.appearances.clear(),a={key:i,a:this.art.appearanceFromSeed(n(e),{look:t,parts:r})},this.appearances.set(e,a)),a.a}animOf(e,t,n){let r=this.anims.get(e);return r||this.anims.set(e,r={pose:t,t:0}),r.pose===t?r.t+=n*1e3:(r.pose=t,r.t=0),r.t}forget(e){this.anims.delete(e)}updateAmbient(e,t){let n=Ne(t),r=`${n}|${this.hourOverride??``}`;if(r!==this.mode||e-this.ambientAt>4e3){let t=this.mode===``;this.mode=r,this.ambientAt=e,this.target=oe(I(n,this.hourOverride,new Date)),t&&(this.ambient=this.target)}let i=Math.max(0,Math.min(250,e-this.lastNow));this.lastNow=e,this.ambient!==this.target&&(this.ambient=V(this.ambient,this.target,i/vr*3),z(this.ambient,this.target)<3&&(this.ambient=this.target)),this.night=this.ambient.night}map=null;lightMap(e,t){let n=Math.max(1,Math.ceil(e/xr)),r=Math.max(1,Math.ceil(t/xr));try{return this.map||=document.createElement(`canvas`),(this.map.width!==n||this.map.height!==r)&&(this.map.width=n,this.map.height=r),this.map}catch{return null}}frame(e,t,n,r,i){let a=performance.now(),{ctx:o,camera:s}=this;this.cell||=cr(this.art),this.plaza||=lr(this.art),this.updateAmbient(e,n);let c=this.canvas.width,l=this.canvas.height;o.setTransform(1,0,0,1,0,0),o.imageSmoothingEnabled=!1,o.globalAlpha=1,o.globalCompositeOperation=`source-over`,o.fillStyle=`#5e7f52`,o.fillRect(0,0,c,l);let{scale:u,ox:d,oy:f}=s.transform();o.setTransform(u,0,0,u,d,f);let p=-d/u,m=-f/u,h=p+c/u,g=m+l/u,_=(e,t,n,r)=>e<h&&e+n>p&&t<g&&t+r>m,v=s.zoom>=hr,y=et({x0:p,y0:m,x1:h,y1:g}),b=this.ents;b.length=0;let x=0,S=(e,t,n)=>{let r=this.ePool[x];r?(r.k=e,r.y=t,r.ref=n):this.ePool[x]=r={k:e,y:t,ref:n},x++,b.push(r)};this.nb=0,this.lamps.length=0;let C=0;for(let e=y.by0;e<=y.by1;e++)for(let t=y.bx0;t<=y.bx1;t++){let n=this.blockInfo(t,e),r=n.cell;if(_(r.x,r.y,r.w,r.h+32)){o.drawImage(n.plaza?this.plaza:this.cell,r.x,r.y);for(let e of n.decor)(!e.small||v)&&_(e.x-24,e.y-56,48,60)&&(S(0,e.y,e),e.kind===`lamp`&&this.lamps.push(e.x,e.y));for(let e=0;e<n.lots.length;e++){let t=n.lots[e],r=ee(t),i=r.x*16,a=r.y*16;if(!_(i,a,224,192))continue;let s=this.state.buildingAt(t);s||o.drawImage(this.garden(t),i,a);for(let r of this.lotDecor(t,n.keys[e],!!s))(!r.small||v)&&_(r.x-24,r.y-56,48,60)&&S(0,r.y,r);if(s){let e=this.facadeOf(s),t=e.side===`back`,n=i+16,r=t?a:a+192-e.height;if(!_(n,r,W.w+W.shadow,e.height))continue;let o=null;Pn(e)?o=Nn(e):C<yr&&(C++,o=Nn(e));let c=this.bPool[this.nb];c||(this.bPool[this.nb]=c={b:s,m:e,s:o,x:n,y:r,depth:0}),c.b=s,c.m=e,c.s=o,c.x=n,c.y=r,c.depth=r+e.height,this.buildingsDrawn[this.nb]=c,this.nb++,S(1,c.depth,c)}}}}this.buildingsDrawn.length=this.nb,this.nc=0;for(let[n,r]of this.state.players){let i=dn(r.samples);r.delay=r.delay===void 0?i:fn(r.delay,i,t*1e3);let a=this.charVis(n,r,e-r.delay,t,_);a&&S(2,a.y,a)}if(r){let e=r.player,n=!e.moving&&this.onBench(e.x,e.y),i=n?`sit`:e.moving?e.running?`run`:`walk`:`stand`,a=this.takeChar(r.self.id,r.self.name,!0,e.x*16,e.y*16,n?`down`:e.dir,i,this.animOf(r.self.id,i,t),this.appearanceOf(r.self.id,r.self.look,r.self.parts));_(a.x-24,a.y-48,48,56)?S(2,a.y+.25,a):a.visible=!1}this.charsDrawn.length=this.nc,this.fx?.props?.({x0:p,y0:m,x1:h,y1:g},e=>S(3,e.y,e)),b.sort((e,t)=>e.y-t.y||e.k-t.k);for(let t of b)t.k===0?this.drawDecor(t.ref,e):t.k===1?this.drawBuilding(t.ref,e,i.building===t.ref.b.id):t.k===3?t.ref.draw(o,e):this.drawChar(t.ref,i.player===t.ref.id);let w=this.ambient;if(!me(w)){let e=this.lightMap(c,l);if(e){let t=e.getContext(`2d`),n=xr;t.setTransform(1,0,0,1,0,0),t.globalCompositeOperation=`source-over`,t.globalAlpha=1,t.fillStyle=pe(w.outside),t.fillRect(0,0,e.width,e.height);let r=w.night;if(r>.02){t.setTransform(u/n,0,0,u/n,d/n,f/n),t.globalCompositeOperation=`lighten`,t.globalAlpha=Math.min(1,r*1.3);for(let e=0;e<this.nb;e++){let n=this.buildingsDrawn[e];n.s&&t.drawImage(n.s.glow,n.x,n.y)}let e=Cr();t.globalAlpha=Math.min(1,r*1.1);for(let n=0;n<this.lamps.length;n+=2)t.drawImage(e,this.lamps[n]-52,this.lamps[n+1]-46,104,70)}if(o.save(),o.setTransform(1,0,0,1,0,0),o.globalCompositeOperation=`multiply`,o.imageSmoothingEnabled=!0,o.drawImage(e,0,0,e.width,e.height,0,0,e.width*n,e.height*n),o.restore(),r>.02){o.save(),o.globalCompositeOperation=`lighter`;let e=le(`#fff1c8`,24);o.globalAlpha=r*.85;for(let t=0;t<this.lamps.length;t+=2)o.drawImage(e,this.lamps[t]-12,this.lamps[t+1]-42);o.restore()}}}this.drawWaiting(e),this.fx?.world?.(o,e,{x0:p,y0:m,x1:h,y1:g}),this.overlay(e,n,i),this.lastFrameMs=performance.now()-a}takeChar(e,t,n,r,i,a,o,s,c){let l=this.cPool[this.nc];return l||(this.cPool[this.nc]=l={id:e,name:t,me:n,x:r,y:i,dir:a,pose:o,animT:s,appearance:c,bx:0,by:0,bw:0,bh:0,headY:0,visible:!0}),l.id=e,l.name=t,l.me=n,l.x=r,l.y=i,l.dir=a,l.pose=o,l.animT=s,l.appearance=c,l.visible=!0,this.charsDrawn[this.nc]=l,this.nc++,l}charVis(e,t,n,r,i){let a=pn(t.samples,n);if(!a)return null;let o=a.x*16,s=a.y*16;if(!i(o-24,s-48,48,56))return null;let c=!a.moving&&this.onBench(a.x,a.y),l=c?`sit`:a.moving?a.speed>4.6?`run`:`walk`:`stand`,u=c?`down`:cn[a.dir]??`down`;return this.takeChar(e,t.info.name,!1,o,s,u,l,this.animOf(e,l,r),this.appearanceOf(e,t.info.look,t.info.parts))}seatsNear(e,t,n=[]){n.length=0;let r=S(e,t);for(let e=r.y-1;e<=r.y+1;e++)for(let t=r.x-1;t<=r.x+1;t++){let r=this.blockInfo(t,e);for(let e of r.decor)e.seat&&n.push(e);for(let e=0;e<r.lots.length;e++){let t=r.lots[e];if(!this.state.buildingAt(t))for(let i of this.lotDecor(t,r.keys[e],!1))i.seat&&n.push(i)}}return n}seatScratch=[];onBench(e,t){for(let n of this.seatsNear(e,t,this.seatScratch))if(n.seat&&Math.abs(n.seat.x-e)<.5&&Math.abs(n.seat.y-t)<.5)return!0;return!1}drawDecor(e,t){let{ctx:n}=this;if(e.kind===`fountain`){let r=this.fountain??=dr(),i=Math.round(e.x-r.ax),a=Math.round(e.y-r.ay);n.drawImage(r.canvas,i,a),this.drawFountainWater(i,a,r,t);return}if(e.kind===`planter`){let t=this.planters.get(e.seed%5);t||this.planters.set(e.seed%5,t=fr(e.seed%5)),n.drawImage(t.canvas,Math.round(e.x-t.ax),Math.round(e.y-t.ay));return}let r=B({kind:e.kind,x:e.x,y:e.y,seed:e.seed});n.drawImage(r.canvas,Math.round(e.x-r.ax),Math.round(e.y-r.ay))}drawFountainWater(e,t,n,r){let{ctx:i}=this,a=r/1e3,o=e+n.jet.x,s=t+n.jet.y;i.fillStyle=`rgba(220,240,255,0.95)`,i.fillRect(Math.round(o),Math.round(s-8),1,8);for(let e=0;e<14;e++){let t=(a*1.3+e/14)%1,n=o+(e%2?1:-1)*t*(6+e%3*2),r=s-8-Math.sin(t*Math.PI)*6+t*t*12;i.fillRect(Math.round(n),Math.round(r),1,1+e%2)}i.fillStyle=`rgba(200,232,252,0.7)`;for(let[r,o,s]of[[8,n.jet.y+7,12],[15,n.jet.y+20,14]])for(let c=-1;c<=1;c+=2){let l=e+n.jet.x+c*r;for(let e=0;e<3;e++){let n=(a*22+e*5)%s;i.fillRect(Math.round(l+n*.15*c),Math.round(t+o+n),1,2)}}let c=n.water;i.strokeStyle=`rgba(214,238,255,0.55)`,i.lineWidth=1;for(let n=0;n<2;n++){let r=(a*.45+n*.5)%1;i.globalAlpha=1-r,i.beginPath(),i.ellipse(e+c.x,t+c.y+2,10+r*(c.rx-10),3+r*(c.ry-3),0,0,Math.PI*2),i.stroke()}i.globalAlpha=1,i.fillStyle=`rgba(255,255,255,0.85)`;for(let n=0;n<7;n++){if((Math.floor(a*3)+n*2)%5!=0)continue;let r=n*.9+.3;i.fillRect(Math.round(e+c.x+Math.cos(r)*c.rx*.8),Math.round(t+c.y+Math.sin(r)*c.ry*.7),2,1)}}drawBuilding(e,t,n){let{ctx:r}=this;if(e.s)r.drawImage(e.s.canvas,e.x,e.y);else{let t=wn[e.m.style];r.fillStyle=t.roof[0],r.fillRect(e.x,e.y,W.w,W.roof),r.fillStyle=t.wall[1],r.fillRect(e.x,e.y+W.roof,W.w,e.m.height-W.roof)}n&&(r.save(),r.globalCompositeOperation=`lighter`,r.globalAlpha=.08+Math.sin(t/260)*.03,r.fillStyle=`#ffffff`,r.fillRect(e.x,e.y,W.w,e.m.height),r.restore()),this.fx?.building?.(r,e,t)}drawWaiting(e){let{ctx:t}=this,n=.5+.5*Math.sin(e/420);if(!(n<.08)){t.save();for(let e=0;e<this.nb;e++){let r=this.buildingsDrawn[e];if(r.m.waiting.length)for(let e of r.m.waiting){let i=kn(r.m,e);t.globalAlpha=.35+n*.6,t.fillStyle=`#ffb547`,t.fillRect(r.x+i.x,r.y+i.y,i.w,i.h),t.globalAlpha=n*.9,t.fillStyle=`#fff2c4`,t.fillRect(r.x+i.x+1,r.y+i.y+1,i.w-2,2)}}t.restore()}}drawChar(e,t){let{ctx:n}=this,r=Math.round(e.x),i=Math.round(e.y)-(e.pose===`sit`?br:0);if(e.pose!==`sit`){let e=re();n.drawImage(e.canvas,r-e.ax,i-e.ay)}(t||e.me)&&(n.save(),n.strokeStyle=e.me?`rgba(124,200,255,0.85)`:`rgba(255,255,255,0.85)`,n.lineWidth=1,n.beginPath(),n.ellipse(r,i,8,3,0,0,Math.PI*2),n.stroke(),n.restore());let a=null;try{let t=this.req;t.appearance=e.appearance,t.dir=e.dir,t.pose=e.pose,t.seated=e.pose===`sit`;let n=Math.max(1,this.art.poseFrameCount(e.pose)||1),r=Math.max(30,this.art.poseFrameDuration(e.pose)||500);t.frame=Math.floor(e.animT/r)%n,a=this.art.characterSprite(t)}catch{a=null}if(a){let t=r-a.ax,o=i-a.ay;n.drawImage(a.canvas,t,o),e.bx=t+2,e.by=o+2,e.bw=a.canvas.width-4,e.bh=a.canvas.height-2,e.headY=o+2}else e.bx=r-7,e.by=i-26,e.bw=14,e.bh=26,e.headY=i-26}measure(e,t){let n=`${e}|${t}`,r=this.widths.get(n);return r===void 0&&(this.widths.size>3e3&&this.widths.clear(),this.ctx.font=e,r=this.ctx.measureText(t).width,this.widths.set(n,r)),r}fit(e,t,n){if(this.measure(e,t)<=n)return t;let r=0,i=t.length;for(;r<i;){let a=r+i+1>>1;this.measure(e,`${t.slice(0,a).trimEnd()}…`)<=n?r=a:i=a-1}return r>0?`${t.slice(0,r).trimEnd()}…`:``}overlay(e,n,r){let{ctx:i,camera:a}=this,o=a.dpr,s=a.transform(),c=s.scale/o,l=e=>e*c+s.ox/o,u=e=>e*c+s.oy/o;i.setTransform(o,0,0,o,0,0),i.textBaseline=`middle`,i.textAlign=`left`;let d=a.zoom;this.night;let f=this.signBoxes;if(f.length=0,d>=gr)for(let e=0;e<this.nb;e++){let t=this.buildingsDrawn[e],n=An(t.m),r=l(t.x+n.x),a=u(t.y+n.y),o=n.w*c,s=n.h*c;if(s<9)continue;f.push(r,a,o,s);let d=Math.max(8,Math.min(13,s*.78)),p=`700 ${d.toFixed(1)}px ${pr}`,m=Pe(t.b.owner.country),h=`❤️ ${t.b.likes}`,g=this.measure(p,h),_=m?this.measure(`${d.toFixed(1)}px ${mr}`,m)+4:0,v=this.fit(p,t.b.owner.name,Math.max(0,o-g-_-14)),y=t.b.state===`online`;i.globalAlpha=y?1:.7;let b=r+5,x=a+s/2+.5;m&&(i.font=`${d.toFixed(1)}px ${mr}`,i.fillText(m,b,x),b+=_),i.font=p,i.fillStyle=`rgba(10,14,24,0.55)`,i.fillText(v,b+.5,x+1),i.fillStyle=y?`#fff8e6`:`#c4c9d4`,i.fillText(v,b,x),i.fillStyle=y?`#ffe2e6`:`#c4c9d4`,i.fillText(h,r+o-g-5,x),i.globalAlpha=1}if(d>=_r){let e=`600 10.5px ${pr}`;i.font=e;let t=this.labelBoxes;t.length=0;for(let a=0;a<this.nc;a++){let o=this.charsDrawn[a];if(!o.visible||!o.me&&!n.showNames&&r.player!==o.id)continue;let s=this.fit(e,o.name,140),c=this.measure(e,s)+10,d=l(o.x),p=u(o.headY)-17;for(let e=0;e<f.length;e+=4){let t=f[e],n=f[e+1];d+c/2>t&&d-c/2<t+f[e+2]&&p+14>n&&p<n+f[e+3]&&(p=n-16)}for(let e=0;e<4;e++){let e=!1;for(let n=0;n<t.length;n+=4)d+c/2>t[n]&&d-c/2<t[n]+t[n+2]&&p+14>t[n+1]&&p<t[n+1]+t[n+3]&&(p=t[n+1]-16,e=!0);if(!e)break}t.push(d-c/2,p,c,14),i.globalAlpha=.92,i.fillStyle=o.me?`rgba(24,52,84,0.88)`:`rgba(18,21,29,0.78)`,i.beginPath(),i.roundRect(Math.round(d-c/2),Math.round(p),Math.round(c),14,4),i.fill(),o.me&&(i.strokeStyle=`rgba(124,200,255,0.9)`,i.lineWidth=1,i.stroke()),i.globalAlpha=1,i.fillStyle=o.me?`#d6efff`:`#e8ecf5`,i.textAlign=`center`,i.fillText(s,Math.round(d),Math.round(p)+7.5),i.textAlign=`left`}}if(r.door&&r.me&&d>=.7){let n=l(r.me.x*16)+12+7*Math.min(2,d),a=u(r.me.y*16)-20*Math.min(2.2,Math.max(.8,d)),o=Math.round(Math.sin(e/240)*2),s=t(`Entrar (E)`);i.font=`700 11px ${pr}`;let c=Math.ceil(i.measureText(s).width)+16,f=Math.round(n-10),p=Math.round(a-10+o);i.fillStyle=`rgba(18,21,29,0.86)`,i.strokeStyle=`rgba(255,214,140,0.9)`,i.lineWidth=1.5,i.beginPath(),i.roundRect(f,p,c,20,5),i.fill(),i.stroke(),i.fillStyle=`#ffe3a0`,i.fillText(s,f+8,p+10.5)}this.fx?.screen?.(i,e,{sx:l,sy:u,k:c,zoom:d})}static doorFront(e){return b(e).front}};function Tr(e,t){return!e?.me||!t||!Number.isFinite(t.x)||!Number.isFinite(t.y)?`fresh`:Math.hypot(t.x-e.me.x,t.y-e.me.y)<=.6?`keep`:`snap`}var Er=2e4;function Dr(e){if(!e)return 0;let t=a.indexOf(e.label);return t<0?0:t+ +(e.progress>=e.target)}function Or(e){let n=e?.goal;if(!n||!(n.target>0))return null;let r=Math.max(0,Math.min(1,n.progress/n.target));return{pct:r,pctText:`${Math.floor(r*100)}%`,label:ye(n.label,n.target),progressText:t(`{0} de {1} h`,[he(Math.floor(n.progress)),he(n.target)]),reached:Dr(n)}}function kr(e){let n=e.slice(e.lastIndexOf(`:`)+1),r=a.indexOf(n);return r<0?null:{pct:1,pctText:`100%`,label:ye(n),progressText:t(`Meta batida!`),reached:r+1}}function Ar(e){return e?{tokens:e.tokensBand===void 0?t(`A soma aparece com 10 prédios ou mais.`):t(`A cidade consumiu ≈ {0} esta semana`,[ve(e.tokensBand)]),lit:e.lit===1?t(`1 prédio aceso agora`):t(`{0} prédios acesos agora`,[he(e.lit)])}:null}function jr(e){let t=e.getMonth();return t===9?`halloween`:t===10||t===11?`christmas`:`party`}var Mr=E(T),Nr=e=>(Mr.x+e)*16,Pr=e=>(Mr.y+e)*16,Z={goal:{x:Nr(15.5),y:Pr(7.6)},hall:{x:Nr(26.5),y:Pr(7.6)},w:84,h:52,posts:12},Fr={x:Nr(y.x+y.w/2),y:Pr(y.y+y.h/2)},Ir=[[Nr(12)+8,Pr(4)-30,Nr(30)+8,Pr(4)-30],[Nr(12)+8,Pr(19)-30,Nr(30)+8,Pr(19)-30]],Lr=[`#ff5d73`,`#ffd166`,`#7cf3ff`,`#b28dff`,`#6dff9e`,`#ff9f43`,`#ffffff`,`#ff7ad9`],Rr=6,zr=class{random;cap=2400;n=0;x=new Float32Array(this.cap);y=new Float32Array(this.cap);vx=new Float32Array(this.cap);vy=new Float32Array(this.cap);age=new Float32Array(this.cap);life=new Float32Array(this.cap);color=new Uint8Array(this.cap);rockets=[];flashes=[];confetti=new be(500);until=0;nextLaunch=0;started=0;clock=0;constructor(e=Math.random){this.random=e}get active(){return this.n>0||this.rockets.length>0||this.confetti.count>0||this.flashes.length>0}showing(e){return e<this.until}start(e,t=Er){this.started=e,this.until=e+t,this.nextLaunch=e+700;for(let e=0;e<4;e++)this.launch((e+.5)/4);for(let e=0;e<40;e++)this.confetti.confettiFall(Fr.x+(this.random()-.5)*560,Fr.y-200-this.random()*80,260+this.random()*80)}stop(){this.until=0,this.n=0,this.rockets.length=0,this.flashes.length=0,this.confetti.clear()}launch(e=this.random()){let t=Fr.x+(e-.5)*520,n=Fr.y-170-this.random()*120;this.rockets.push({x:t,y:Fr.y-6,vx:(this.random()-.5)*30,vy:-(250+this.random()*60),burstY:n,color:Math.floor(this.random()*Lr.length)})}spark(e,t,n,r,i,a){if(this.n>=this.cap)return;let o=this.n++;this.x[o]=e,this.y[o]=t,this.vx[o]=n,this.vy[o]=r,this.age[o]=0,this.life[o]=i,this.color[o]=a}burst(e){let t=this.random(),n=70+Math.floor(this.random()*40),r=120+this.random()*60,i=(e.color+1+Math.floor(this.random()*(Lr.length-1)))%Lr.length;for(let a=0;a<n;a++){let o=a/n*Math.PI*2+this.random()*.15,s=t<.3?r:r*Math.sqrt(.15+this.random()*.85),c=Math.cos(o),l=Math.sin(o);if(t>.85){let e=o;c=16*Math.sin(e)**3/17,l=-(13*Math.cos(e)-5*Math.cos(2*e)-2*Math.cos(3*e)-Math.cos(4*e))/17,s=r*.9}this.spark(e.x,e.y,c*s,l*s,1.3+this.random()*.8,t>.85?0:a%4==0?i:e.color)}this.flashes.push({x:e.x,y:e.y,color:e.color,at:this.clock})}update(e,t){let n=Math.min(.1,Math.max(0,t));if(this.clock=e,e<this.until&&e>=this.nextLaunch){this.launch(),this.random()<.45&&this.launch();let t=(e-this.started)/Math.max(1,this.until-this.started);this.nextLaunch=e+(t>.85?120:300+this.random()*380)}for(let e=this.rockets.length-1;e>=0;e--){let t=this.rockets[e];t.x+=t.vx*n,t.y+=t.vy*n,t.vy+=70*n,this.spark(t.x+(this.random()-.5)*2,t.y+3,(this.random()-.5)*10,14+this.random()*12,.45,Rr),(t.y<=t.burstY||t.vy>=-30)&&(this.burst(t),this.rockets.splice(e,1))}for(let t=this.flashes.length-1;t>=0;t--)e-this.flashes[t].at>320&&this.flashes.splice(t,1);let r=0;for(;r<this.n;){if(this.age[r]+=n,this.age[r]>=this.life[r]){let e=--this.n;this.x[r]=this.x[e],this.y[r]=this.y[e],this.vx[r]=this.vx[e],this.vy[r]=this.vy[e],this.age[r]=this.age[e],this.life[r]=this.life[e],this.color[r]=this.color[e];continue}this.vx[r]*=Math.max(0,1-1.15*n),this.vy[r]=this.vy[r]*Math.max(0,1-1.15*n)+52*n,this.x[r]+=this.vx[r]*n,this.y[r]+=this.vy[r]*n,r++}this.confetti.update(n)}draw(e,t,n,r){if(!this.active)return;e.save();let i=.35+r*.65;e.globalCompositeOperation=`lighter`;for(let n of this.flashes){let r=(t-n.at)/320;if(r<0||r>1)continue;let a=18+r*40,o=e.createRadialGradient(n.x,n.y,0,n.x,n.y,a);o.addColorStop(0,`rgba(255,255,255,${(.55*(1-r)*i).toFixed(3)})`),o.addColorStop(.4,`${Lr[n.color]}${Math.round(90*(1-r)*i).toString(16).padStart(2,`0`)}`),o.addColorStop(1,`rgba(0,0,0,0)`),e.fillStyle=o,e.fillRect(n.x-a,n.y-a,a*2,a*2)}for(let t=0;t<this.n;t+=2)e.globalAlpha=(1-this.age[t]/this.life[t])*.22*i,e.fillStyle=Lr[this.color[t]%Lr.length],e.fillRect(Math.round(this.x[t])-1,Math.round(this.y[t])-1,4,4);e.globalCompositeOperation=`source-over`;for(let t of this.rockets)e.globalAlpha=1,e.fillStyle=`#fff4c8`,e.fillRect(Math.round(t.x),Math.round(t.y),2,3);for(let r=0;r<this.n;r++){let i=Math.round(this.x[r]),a=Math.round(this.y[r]);if(i<n.x0-4||i>n.x1+4||a<n.y0-4||a>n.y1+4)continue;let o=1-this.age[r]/this.life[r];if(o<.35&&Math.sin(t/35+r*1.7)<0)continue;e.globalAlpha=Math.min(1,o*1.8),e.fillStyle=o>.75?`#fffbe8`:Lr[this.color[r]%Lr.length];let s=o>.45?2:1;e.fillRect(i,a,s,s)}e.globalAlpha=1,this.confetti.draw(e,n.x0,n.y0,n.x1,n.y1,t),e.restore()}};function Br(e,t,n,r){let i=Z.w,a=Z.h,o=Math.round(t-i/2),s=Math.round(n-Z.posts-a);e.fillStyle=`rgba(30,36,48,0.22)`,e.fillRect(o+4,n-2,i-4,3);for(let t of[o+8,o+i-11])e.fillStyle=`#3b2a1f`,e.fillRect(t,s+a-2,3,Z.posts+2),e.fillStyle=`#6b4a33`,e.fillRect(t,s+a-2,1,Z.posts+2);return e.fillStyle=`#2a1d16`,e.fillRect(o,s,i,a),e.fillStyle=`#8a5f3f`,e.fillRect(o+1,s+1,i-2,a-2),e.fillStyle=`#a8784f`,e.fillRect(o+1,s+1,i-2,1),e.fillStyle=`#1b2233`,e.fillRect(o+3,s+3,i-6,a-6),e.fillStyle=r,e.fillRect(o+3,s+3,i-6,8),e.fillStyle=`rgba(255,255,255,0.25)`,e.fillRect(o+3,s+3,i-6,1),{x:o+3,y:s+3,w:i-6,h:a-6}}function Vr(e,t,n){let r=Br(e,Z.goal.x,Z.goal.y,`#c8443c`),i=r.x+6,a=r.y+13,o=r.y+r.h-7;e.fillStyle=`#0d1018`,e.fillRect(i-1,a-1,6,o-a+2),e.fillStyle=`#d8e4f0`,e.fillRect(i,a,4,o-a),e.fillStyle=`#0d1018`,e.fillRect(i-2,o-1,8,6),e.fillStyle=`#e8473f`,e.fillRect(i-1,o,6,4);let s=t?.pct??0,c=Math.round((o-a)*s);c>0&&(e.fillStyle=`#e8473f`,e.fillRect(i+1,o-c,2,c),e.fillStyle=`#ff9c74`,e.fillRect(i+1,o-c,1,c),Math.sin(n/300)>0&&(e.fillStyle=`#ffd7a0`,e.fillRect(i+1,o-c,2,1))),e.fillStyle=`#7d8aa3`;for(let t=1;t<4;t++)e.fillRect(i+5,Math.round(o-(o-a)*t/4),2,1);e.fillStyle=`#ffd166`,e.fillRect(i+6,a-1,4,3),e.fillStyle=`#c9a24a`,e.fillRect(i+5,a-1,1,6)}function Hr(e,t){let n=Br(e,Z.hall.x,Z.hall.y,`#2f6fa8`),r=n.x+4,i=n.y+15;e.fillStyle=`#c9c2b2`,e.fillRect(r,i+5,14,11),e.fillStyle=`#e8e2d4`,e.fillRect(r-1,i+3,16,2),e.fillRect(r+2,i+1,10,2),e.fillRect(r+5,i,4,1),e.fillStyle=t?`#ffd27a`:`#4a5468`;for(let t of[r+2,r+6,r+10])e.fillRect(t,i+7,2,4);e.fillStyle=`#8f8676`,e.fillRect(r-1,i+16,16,1)}function Ur(){let e=e=>e-Z.posts-Z.h+3;return{goal:{x:Z.goal.x-Z.w/2+3,y:e(Z.goal.y),w:Z.w-6},hall:{x:Z.hall.x-Z.w/2+3,y:e(Z.hall.y),w:Z.w-6}}}function Wr(e,t,n,r,i){return{x:e+(n-e)*i,y:t+(r-t)*i+Math.sin(i*Math.PI)*14}}function Gr(e,t,n,r,i,a){e.fillStyle=`#4a3b2e`;for(let a=0;a<=120;a++){let o=Wr(t,n,r,i,a/120);e.fillRect(Math.round(o.x),Math.round(o.y),1,1)}for(let o=1;o<24;o++){let s=Wr(t,n,r,i,o/24),c=Math.round(s.x),l=Math.round(s.y),u=+(Math.sin(a/380+o*.9)>.4),d=F[o%F.length];e.fillStyle=`rgba(20,24,33,0.35)`,e.fillRect(c-2,l+2,7,1),e.fillStyle=d;for(let t=0;t<6;t++)e.fillRect(c-3+Math.floor(t/2)+(t>2?u:0),l+1+t,7-Math.floor(t/2)*2,1);e.fillStyle=`rgba(255,255,255,0.45)`,e.fillRect(c-3,l+1,7,1)}}function Kr(e,t,n,r,i,a,o){if(!(o<.15)){for(let s=0;s<24;s++){let c=Wr(t,n,r,i,(s+.5)/24),l=.55+.45*Math.sin(a/520+s*1.3);e.globalAlpha=o*l,e.fillStyle=s%3==0?`#ffd27a`:s%3==1?`#ff9db0`:`#9ae7ff`,e.fillRect(Math.round(c.x),Math.round(c.y),2,2),e.globalAlpha=o*l*.25,e.fillRect(Math.round(c.x)-2,Math.round(c.y)-2,6,6)}e.globalAlpha=1}}var qr=new Map;function Jr(e,t,n,r){let i=qr.get(t);if(!i){let{buf:e}=ce(t);i=document.createElement(`canvas`),i.width=e.w,i.height=e.h,i.getContext(`2d`).putImageData(new ImageData(e.data,e.w,e.h),0,0),qr.set(t,i)}e.drawImage(i,Math.round(n-20),Math.round(r-60))}function Yr(e){let t=y,n=[[t.x-2.5,t.y+1.2],[t.x+t.w+2.5,t.y+1.2],[t.x-1.2,t.y+t.h+1.1],[t.x+t.w+1.2,t.y+t.h+1.1]],r=e===`halloween`?[`pumpkin`,`pumpkin`,`ghost`,`pumpkin`]:e===`christmas`?[`tree`,`tree`,`gift`,`gift`]:[`gift`,`gift`,`gift`,`gift`];return n.map(([e,t],n)=>({kind:r[n],x:Nr(e),y:Pr(t)}))}var Xr=62e3;function Zr(e,t,n,r){let i=st(e.x,e.y,e=>{let r=t(e);return!!r&&r.id!==n},r);if(!i)return null;let a=t(i.lot);return a?{building:a,front:i.front,dist:Math.hypot(i.front.x-e.x,i.front.y-e.y)}:null}function Qr(e,t){let n=b(t.lot).front;return Math.hypot(n.x-e.x,n.y-e.y)}function $r(e,t,n){let r=!!n&&e.id===n,i=t?Qr(t,e):1/0;return{canLike:!r&&i<=4.000000001,canKnock:!r&&e.knocks===!0&&i<=2.000000001,liked:e.likedByMe===!0,mine:r}}var ei=class{at=new Map;wait(e,t){let n=this.at.get(e);return n===void 0?0:Math.max(0,n+Xr-t)}take(e,t){return this.wait(e,t)>0?!1:(this.at.set(e,t),!0)}};function ti(e,t){let n=(t-e.start)/900;if(n<0||n>=1)return null;if(e.broken)return{x:e.to.x+Math.sin(n*9)*3,y:e.to.y+n*n*26,scale:1,alpha:1-n};let r=1-(1-n)*(1-n),i=Math.sin(n*Math.PI)*26;return{x:e.from.x+(e.to.x-e.from.x)*r,y:e.from.y+(e.to.y-e.from.y)*r-i,scale:n<.15?.6+n/.15*.8:n>.8?1.4-(n-.8)/.2*.6:1.4,alpha:n>.9?(1-n)*10:1}}var ni=[`.11.11.`,`1211111`,`1111111`,`.11111.`,`..111..`,`...1...`],ri=/^HB-[2-9A-HJKMNP-TV-Z]{4}$/;function ii(e){let t=e.trim().toUpperCase().replace(/[\s_]+/g,``),n=`HB-${t.startsWith(`HB-`)?t.slice(3):t.startsWith(`HB`)&&t.length===6?t.slice(2):t}`;return ri.test(n)?n:null}var ai={out:320,wait:5e3,in:520},oi=class{phase=`idle`;since=0;landed=!1;get busy(){return this.phase!==`idle`}start(e){this.phase=`out`,this.since=e,this.landed=!1}arrived(){(this.phase===`out`||this.phase===`wait`)&&(this.landed=!0)}failed(){this.arrived()}tick(e){let t=!1;this.phase===`out`&&e-this.since>=ai.out&&(this.phase=`wait`,this.since=e),this.phase===`wait`&&(this.landed||e-this.since>=ai.wait)&&(t=!this.landed,this.phase=`in`,this.since=e),this.phase===`in`&&e-this.since>=ai.in&&(this.phase=`idle`);let n=e-this.since,r=this.phase===`out`?Math.min(1,n/ai.out):this.phase===`wait`?1:this.phase===`in`?Math.max(0,1-n/ai.in):0;return{phase:this.phase,dark:r,timedOut:t}}},si=class{actions;el;input;error;goBtn;diceBtn;constructor(e){this.actions=e,this.input=N(`input`,{class:`ui-city-tp__input`,type:`text`,attrs:{placeholder:`HB-XXXX`,maxlength:9,autocomplete:`off`,autocapitalize:`characters`,spellcheck:`false`,"aria-label":t(`Código do prédio`)}}),this.goBtn=N(`button`,{class:`ui-city-tp__go`,type:`submit`,text:t(`Ir`),title:t(`Ir até a porta deste prédio`)}),this.diceBtn=N(`button`,{class:`ui-city-tp__dice`,type:`button`,title:t(`Visitar um prédio aleatório`),attrs:{"aria-label":t(`Visitar um prédio aleatório`)},on:{click:()=>this.actions.random()}},N(`span`,{text:`🎲`,attrs:{"aria-hidden":`true`}}),N(`span`,{class:`ui-city-tp__dice-text`,text:t(`Aleatório`)})),this.error=N(`p`,{class:`ui-city-tp__error`,role:`alert`,hidden:!0});let n=N(`form`,{class:`ui-city-tp__form`,attrs:{"aria-label":t(`Ir para um prédio pelo código`)}},N(`span`,{class:`ui-city-tp__label`,text:t(`Ir para`),attrs:{"aria-hidden":`true`}}),this.input,this.goBtn);n.addEventListener(`submit`,e=>{e.preventDefault(),this.submit()}),this.input.addEventListener(`input`,()=>P(this.error,!0)),this.input.addEventListener(`keydown`,e=>{e.stopPropagation(),e.key===`Escape`&&this.input.blur()}),this.el=N(`div`,{class:`ui-city-tp`},n,this.diceBtn,this.error)}showError(e){M(this.error,e),P(this.error,!1)}setBusy(e){this.goBtn.disabled=e,this.diceBtn.disabled=e}clear(){this.input.value=``,P(this.error,!0)}submit(){let e=ii(this.input.value);if(!e){this.showError(t(`O código tem o formato HB-XXXX (letras e números, sem 0, O, 1, I, L e U).`));return}this.input.value=e,this.input.blur(),this.actions.go(e)}};function ci(e){return e===void 0||e<=0?0:e>=4?4:e}function li(e){return e===void 0?0:Math.max(0,Math.min(5,Math.floor(e)))}function ui(e){return e.side===`front`?{x:W.w/2-34,y:e.height-W.ground+12,w:11,h:15}:{x:W.w/2-37,y:0,w:11,h:15}}function di(e,t){if(!e||!t||typeof t!=`object`)return!1;let n=t;return typeof n.working!=`number`||typeof n.idle!=`number`?!1:n.working<e.working&&n.idle>e.idle}var fi=[`#4fd18b`,`#b7e05a`,`#ffd24a`,`#ff9a3c`,`#ff4f8b`];function pi(e,t,n,r,i,a,o){let s=Math.round(t),c=Math.round(n);e.fillStyle=`#1b1f28`,e.fillRect(s,c,11,15),e.fillStyle=`#5d6577`,e.fillRect(s+1,c+1,9,13),e.fillStyle=`#7d8699`,e.fillRect(s+1,c+1,9,1),e.fillStyle=o?`#efe6c8`:`#9aa3b2`,e.fillRect(s+2,c+2,7,4);let l=-Math.PI*.9+r/5*Math.PI*.8+Math.sin(i/60)*.55*a;e.fillStyle=`#c23a3a`,e.fillRect(s+5+Math.round(Math.cos(l)*2.4),c+5+Math.round(Math.sin(l)*2.4),1,1),e.fillStyle=`#20242e`,e.fillRect(s+5,c+5,1,1);for(let t=0;t<5;t++){let n=2+t;e.fillStyle=o&&t<r?fi[t]:`#2c313d`,e.fillRect(s+1+t*2,c+13-n,1,n)}}function mi(e,t,n,r,i){if(r<=0||i<.05)return;let a=Math.round(t),o=Math.round(n);e.globalAlpha=Math.min(1,i*1.1);for(let t=0;t<r;t++){let n=2+t;e.fillStyle=fi[t],e.fillRect(a+1+t*2,o+13-n,1,n)}e.globalAlpha=Math.min(.35,i*.35),e.fillStyle=fi[r-1],e.fillRect(a-2,o+5,15,11),e.globalAlpha=1}var hi=[``,`#ffd9a0`,`#ffe9b8`,`#7cf3ff`,`#ff6bd6`];function gi(e,t,n,r,i,a,o,s){if(i<=0)return;let c=An(r),l=Math.round(t+c.x),u=Math.round(n+c.y),d=hi[i];if(i<=2){e.globalAlpha=(i===1?.18:.32)*(.35+o*.65),e.fillStyle=d,e.fillRect(l-4,u-3,c.w+8,c.h+6),e.globalAlpha=(i===1?.12:.22)*(.35+o*.65),e.fillRect(l-8,u-6,c.w+16,c.h+12),e.globalAlpha=1;return}let f=(Math.floor(a/90)+s)%47==0?.35:1,p=i===4?.8+Math.sin(a/180+s)*.2:1;if(e.globalAlpha=(.55+o*.45)*f*p,e.fillStyle=d,e.fillRect(l-3,u-3,c.w+6,1),e.fillRect(l-3,u+c.h+2,c.w+6,1),e.fillRect(l-3,u-3,1,c.h+6),e.fillRect(l+c.w+2,u-3,1,c.h+6),e.globalAlpha=(.16+o*.3)*f*p,e.fillRect(l-6,u-6,c.w+12,c.h+12),e.globalAlpha=1,!(i<4)){for(let t=0;t<6;t++){let n=((a/700+t*.37+s*.13)%1+1)%1,r=(t+s)%4,i=r%2==0?l-3:l+c.w+2,o=r<2?u-3:u+c.h+2,f=i+(r%2==0?-1:1)*n*7,p=o-Math.sin(n*Math.PI)*6+n*n*8;e.globalAlpha=1-n,e.fillStyle=t%2?`#fff6b0`:d,e.fillRect(Math.round(f),Math.round(p),1,1)}e.globalAlpha=1}}var _i=`ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif`,vi=`"Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif`,yi=4e3,bi=1600,xi=1100,Si=1.05;function Ci(e){let t=e;return!!t&&(t.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName??``))}var wi=e=>!!e&&typeof e==`object`&&!Array.isArray(e),Ti=(e,t)=>{let n=_(S(e.x,e.y)),r=_(S(t.x,t.y));return n.x===r.x&&n.y===r.y},Ei=e=>typeof e==`number`&&Number.isFinite(e),Di=class{o;el;wheel=new At;balloons=new Dt;greetGate=new Ot(18,3300);likeGate=new Ot(9,400);teleportGate=new Ot(9,1500);reports={day:``,n:0};knocks=new ei;hearts=[];bumps=new Map;wiggles=new Map;pops=[];fireworks=new zr;confetti=new be(500);fade=new oi;fadeEl;panel;dock;testBtn=null;dockKey=``;city=null;celebrating=null;replyTo=null;pending=null;snapCamera=!1;heldPos=null;lastNow=0;reported=new Set;blocked=new Set;extras={building:null,player:null};propsPool=[];onKeyDown=e=>this.onKey(e);constructor(e){this.o=e,this.fadeEl=N(`div`,{class:`ui-city-fade`,hidden:!0,attrs:{"aria-hidden":`true`}}),this.panel=new si({go:e=>this.teleport(e),random:()=>this.teleport()}),this.dock=N(`div`,{class:`ui-city-dock`,role:`toolbar`,attrs:{"aria-label":t(`Ações perto de você`)}});let n=typeof location>`u`?null:new URLSearchParams(location.search);if(e.testFireworks&&n?.has(`fireworks`)){let n=e.testFireworks;this.testBtn=N(`button`,{class:`ui-city-testfw`,type:`button`,text:`🎆 ${t(`Testar os fogos`)}`,on:{click:()=>n()}})}this.el=N(`div`,{class:`ui-city-social`},this.dock,this.panel.el,this.wheel.el,this.fadeEl,this.testBtn),window.addEventListener(`keydown`,this.onKeyDown,!0)}helpItems(){return[N(`span`,{},N(`kbd`,{text:`L`}),` `,t(`curtir`)),N(`span`,{},N(`kbd`,{text:`G`}),` `,t(`cumprimentar`)),N(`span`,{},N(`kbd`,{text:`K`}),` `,t(`bater`))]}reset(){this.wheel.close(),this.balloons.clear(),this.hearts.length=0,this.bumps.clear(),this.wiggles.clear(),this.pops.length=0,this.fireworks.stop(),this.confetti.clear(),this.pending=null,this.replyTo=null,this.city=null,this.celebrating=null,this.blocked.clear(),this.snapCamera=!1,this.heldPos=null,this.fadeEl.hidden=!0,this.panel.setBusy(!1)}hide(){this.wheel.close()}escape(){return this.wheel.open?(this.wheel.close(),!0):!1}destroy(){window.removeEventListener(`keydown`,this.onKeyDown,!0),this.el.remove()}snapshot(e){this.city=e.city?D(e.city)??null:null}message(e,n){if(!wi(e)||typeof e.t!=`string`)return!1;let r=this.o.state();switch(e.t){case`greeting`:return this.onGreeting(e,n),!1;case`player.join`:return wi(e.player)&&typeof e.player.id==`string`&&this.blocked.delete(e.player.id),!1;case`like.update`:{let t=e.buildingId,i=typeof t==`string`?r.buildings.get(t):void 0;return i&&Ei(e.likes)&&e.likes>i.likes&&this.bumps.set(i.id,n),this.pending&&(this.pending.kind===`like`||this.pending.kind===`unlike`)&&this.pending.buildingId===t&&(this.pending=null),!1}case`area.patch`:return this.onPatch(e,r,n),!1;case`city`:{let t=D(e);return t&&(this.city=t),!1}case`city.fireworks`:{this.fireworks.start(n);let r=typeof e.goalId==`string`?kr(e.goalId):null;return r&&(this.celebrating={goal:r,until:n+Er}),this.o.toast(r?`🎆 ${t(`A cidade bateu a meta da semana: {0}!`,[r.label])}`:`🎆 ${t(`A cidade bateu a meta da semana!`)}`),!1}case`pos`:return this.pending?.kind===`teleport`&&(this.pending=null,this.fade.arrived(),this.heldPos=e,!0);case`notice`:return typeof e.text==`string`&&this.onNotice(e.text,n);default:return!1}}onGreeting(e,n){let r=e.from,i=e.greetingId;if(typeof r!=`string`||!(i in Ce))return;let a=this.o.state().me?.id;if(this.balloons.add(r,i,n),r===a){this.pending?.kind===`greet`&&(this.pending=null);return}if(e.to===a&&a){this.replyTo={id:r,at:n,got:i};let e=this.o.state().players.get(r)?.info.name??t(`Alguém`);this.o.toast(t(`{0}: {1} {2} — G para responder`,[e,we(i),De(i)]))}}onPatch(e,t,n){if(Array.isArray(e.changes))for(let r of e.changes){if(!wi(r)||typeof r.id!=`string`)continue;let e=t.buildings.get(r.id);if(!e)continue;Ei(r.likes)&&r.likes>e.likes&&this.bumps.set(r.id,n),di(e.agents,r.agents)&&this.celebrateShift(r.id,n);let i=wi(r.tokens)&&Ei(r.tokens.day)?r.tokens.day:void 0;i!==void 0&&i!==e.tokens?.day&&this.wiggles.set(r.id,{band:i,at:n})}}celebrateShift(e,t){let n=this.drawn(e);if(!n)return;let r=An(n.m),i=n.x+r.x+r.w/2,a=n.y+r.y;this.confetti.confetti(i,a,40),this.confetti.sparkle(i,a-4,10),this.pops.push({x:i,y:a-6,at:t,text:`🎉`})}onNotice(e,n){let r=this.pending;if(!r||n-r.at>yi)return!1;let i=null;switch(r.kind){case`like`:case`unlike`:e===`too_far`?i=t(`Chegue mais perto da porta para curtir (até 4 passos).`):e===`daily_limit`?i=t(`Você já deu os 50 likes de hoje. Amanhã tem mais!`):e===`invalid`?i=t(`Não dá para curtir o próprio prédio.`):e===`not_found`?i=t(`Este prédio não está mais aqui.`):e===`rate_limited`&&(i=t(`Devagar com os likes: espere um pouquinho.`));break;case`knock`:e===`too_far`?i=t(`Chegue mais perto da porta para bater (até 2 passos).`):e===`rate_limited`?i=t(`Você bateu nesta porta há pouco. Espere um minuto.`):e===`not_found`&&(i=t(`Este prédio não está mais aqui.`));break;case`stamp`:e===`already_done`?i=t(`Você já deixou um carimbo aqui hoje.`):e===`too_far`?i=t(`Chegue mais perto da porta para carimbar.`):e===`not_found`&&(i=t(`Este prédio não está mais aqui.`));break;case`teleport`:e===`not_found`?i=r.code?t(`Nenhum prédio com o código {0}.`,[r.code]):t(`Nenhum prédio aceso para visitar agora.`):e===`rate_limited`&&(i=t(`Devagar: espere um pouco antes de ir para outro prédio.`)),i&&(this.fade.failed(),r.code&&this.panel.showError(i));break;case`greet`:e===`not_found`?i=t(`Essa pessoa não está mais por perto.`):e===`rate_limited`&&(i=t(`Devagar: um cumprimento a cada 3 segundos.`));break;case`block`:case`report`:if(e===(r.kind===`block`?`blocked_ok`:`reported`))return this.pending=null,!0;e===`daily_limit`?i=t(`Você já mandou as 5 denúncias de hoje.`):e===`not_found`&&(i=t(`Essa pessoa não está mais por perto.`))}return i?(this.pending=null,this.o.toast(i),!0):!1}send(e,t){this.o.send([e]),t&&(this.pending=t)}likeNearest(e){let n=this.o.me(),r=this.o.state();if(!n)return;let i=Zr(n,e=>r.buildingAt(e),r.myBuildingId,4);if(!i){this.o.toast(t(`Chegue perto da porta de um prédio (até 4 passos) e aperte L para curtir.`));return}this.toggleLike(i.building,e)}toggleLike(e,n){let r=this.o.me(),i=this.o.state();if(!r||e.id===i.myBuildingId||this.fade.busy)return;if(!$r(e,r,i.myBuildingId).canLike){this.o.toast(t(`Chegue mais perto da porta para curtir (até 4 passos).`));return}if(!this.likeGate.take(n)){this.o.toast(t(`Devagar com os likes: espere um pouquinho.`));return}let a=!e.likedByMe;this.send({t:a?`like`:`unlike`,buildingId:e.id},{kind:a?`like`:`unlike`,at:n,buildingId:e.id});let o=this.drawn(e.id),s=o?this.likeSpot(o):{x:b(e.lot).front.x*16,y:b(e.lot).front.y*16-40};this.hearts.push({from:{x:r.x*16,y:r.y*16-30},to:s,start:n,...a?{}:{broken:!0}})}knockNearest(e){let n=this.o.me(),r=this.o.state();if(!n)return;let i=Zr(n,e=>r.buildingAt(e),r.myBuildingId,2);if(!i){this.o.toast(t(`Chegue a 2 passos da porta de um prédio e aperte K para bater.`));return}this.knock(i.building,e)}knock(e,n){let r=this.o.me();if(!r||this.fade.busy)return;let i=$r(e,r,this.o.state().myBuildingId);if(!e.knocks){this.o.toast(t(`O dono deste prédio não recebe batidas na porta.`));return}if(!i.canKnock){this.o.toast(t(`Chegue mais perto da porta para bater (até 2 passos).`));return}if(!this.knocks.take(e.id,n)){this.o.toast(t(`Você bateu nesta porta há pouco. Espere um minuto.`));return}this.send({t:`knock`,buildingId:e.id},{kind:`knock`,at:n,buildingId:e.id});let a=this.drawn(e.id);if(a){let t=b(e.lot).front;this.pops.push({x:t.x*16,y:a.m.side===`front`?a.y+a.m.height-26:a.y+8,at:n,text:`✊`})}this.o.toast(`🚪 ${t(`Toc, toc! Você bateu na porta de {0}.`,[e.owner.name])}`)}openWheel(e,n){let r=this.o.me(),i=this.o.state();if(!r||this.fade.busy)return;let a=[];for(let[e,t]of i.players)!this.blocked.has(e)&&Ti(r,t.info.pos)&&a.push({id:e,x:t.info.pos.x,y:t.info.pos.y});let o=this.replyTo&&e-this.replyTo.at<1e4?this.replyTo:null,s=n??(this.o.cards.kind===`player`?this.o.cards.id:null),c=n&&i.players.has(n)?n:Et(r,a,{selected:s,replyTo:o?.id??null});if(!c){this.o.toast(t(`Ninguém por perto para cumprimentar.`));return}let l=i.players.get(c);if(!l)return;let u={id:c,name:l.info.name},d=this.toWindow(r.x*16,r.y*16-24),f=this.toWindow(l.info.pos.x*16,l.info.pos.y*16-24),p=o&&o.id===c?kt(o.got):null;this.wheel.show(u,d,f,p,e=>this.greet(c,e,performance.now()))}greet(e,n,r){if(this.fade.busy)return;if(this.greetGate.wait(r)>0){this.o.toast(t(`Devagar: um cumprimento a cada 3 segundos.`));return}this.greetGate.take(r),this.send({t:`greet`,playerId:e,greetingId:n},{kind:`greet`,at:r,playerId:e});let i=this.o.state().me?.id;i&&this.balloons.add(i,n,r),this.replyTo?.id===e&&(this.replyTo=null)}teleport(e){let n=performance.now();if(this.o.me()&&!this.fade.busy){if(!this.teleportGate.take(n)){this.o.toast(t(`Devagar: espere um pouco antes de ir para outro prédio.`));return}this.wheel.close(),this.o.cards.hide(),this.send(e?{t:`teleport`,code:e}:{t:`teleport`},e?{kind:`teleport`,at:n,code:e}:{kind:`teleport`,at:n}),this.fade.start(n),this.panel.setBusy(!0)}}block(e,n,r){this.fade.busy||(this.send({t:`block`,playerId:e},{kind:`block`,at:r,playerId:e}),this.blocked.add(e),this.o.cards.hide(),this.o.toast(t(`{0} bloqueado. Para desfazer: Configurações › Habblaud World › Bloqueados.`,[n])))}report(e,n,r){if(this.fade.busy)return!1;let i=new Date().toISOString().slice(0,10);return this.reports.day!==i&&(this.reports={day:i,n:0}),this.reports.n>=5?(this.o.toast(t(`Você já mandou as 5 denúncias de hoje.`)),!1):(this.reports.n++,this.send({t:`report`,playerId:e,reason:n},{kind:`report`,at:r,playerId:e}),this.reported.add(e),this.o.toast(t(`Denúncia enviada. Obrigado: a moderação vai olhar.`)),!0)}onKey(e){if(!this.o.active())return;if(this.wheel.open){this.wheel.key(e)&&(e.preventDefault(),e.stopPropagation());return}if(e.defaultPrevented||e.ctrlKey||e.metaKey||e.altKey||e.repeat||Ci(e.target)||H(e.target)||this.fade.busy)return;let t=performance.now();switch(e.key){case`l`:case`L`:e.preventDefault(),this.likeNearest(t);return;case`g`:case`G`:e.preventDefault(),this.openWheel(t);return;case`k`:case`K`:e.preventDefault(),this.knockNearest(t);return}}frame(e,n){this.lastNow=e,this.fireworks.update(e,n),this.confetti.update(n);for(let t=this.hearts.length-1;t>=0;t--){let n=this.hearts[t];if(e-n.start>1e3&&(this.hearts.splice(t,1),!n.broken)){let t=this.findAt(n.to);t&&this.bumps.set(t.b.id,e)}}for(let t=this.pops.length-1;t>=0;t--)e-this.pops[t].at>1300&&this.pops.splice(t,1);let r=this.fade.tick(e);if(this.heldPos&&r.phase!==`out`){let e=this.heldPos;this.heldPos=null,this.o.replay(e),this.snapCamera=!0}this.fadeEl.hidden=r.phase===`idle`,r.phase!==`idle`&&(this.fadeEl.style.opacity=r.dark.toFixed(3)),(r.phase===`idle`||r.phase===`in`)&&this.panel.setBusy(!1),r.timedOut&&(this.pending=null,this.o.toast(t(`O mundo não respondeu a tempo. Tente de novo.`))),this.snapCamera&&this.o.me()&&(this.snapCamera=!1,this.o.teleported(),this.panel.clear()),this.syncDock(e),this.extras.building?.sync(),this.extras.player?.sync()}syncDock(e){let n=this.o.me(),r=this.o.state(),i=null,a=null,o=!1;if(n){i=Zr(n,e=>r.buildingAt(e),r.myBuildingId,4)?.building??null;let e=Zr(n,e=>r.buildingAt(e),r.myBuildingId,2)?.building??null;a=e?.knocks?e:null;for(let e of r.players.values())if((e.info.pos.x-n.x)**2+(e.info.pos.y-n.y)**2<=144&&!this.blocked.has(e.info.id)&&Ti(n,e.info.pos)){o=!0;break}}let s=`${i?.id??``}|${+!!i?.likedByMe}|${a?.id??``}|${+!!o}|${+!!this.wheel.open}`;if(s===this.dockKey)return;this.dockKey=s;let c=[],l=(e,t,n,r,i,a=``)=>N(`button`,{class:`ui-city-dock__btn ${a}`.trim(),type:`button`,title:r,attrs:{"aria-label":r,"aria-keyshortcuts":n},on:{click:i}},N(`span`,{class:`ui-city-dock__icon`,text:e,attrs:{"aria-hidden":`true`}}),N(`span`,{class:`ui-city-dock__text`,text:t}),N(`kbd`,{text:n}));if(i){let e=i;c.push(e.likedByMe?l(`💔`,t(`Descurtir`),`L`,t(`Desfazer o like no prédio de {0}`,[e.owner.name]),()=>this.toggleLike(this.o.state().buildings.get(e.id)??e,performance.now()),`is-liked`):l(`❤️`,t(`Curtir`),`L`,t(`Curtir o prédio de {0}`,[e.owner.name]),()=>this.toggleLike(this.o.state().buildings.get(e.id)??e,performance.now()),`is-like`))}if(a){let e=a;c.push(l(`🚪`,t(`Bater`),`K`,t(`Bater na porta de {0}`,[e.owner.name]),()=>this.knock(this.o.state().buildings.get(e.id)??e,performance.now())))}o&&c.push(l(`👋`,t(`Cumprimentar`),`G`,t(`Cumprimentar quem está perto`),()=>this.openWheel(performance.now()))),this.dock.replaceChildren(...c),P(this.dock,!c.length)}cardExtras(e,t){return e===`building`?(this.extras.building||(this.extras.building=new Oi(this)),this.extras.building.bind(t),this.extras.building.el):(this.extras.player||(this.extras.player=new ki(this)),this.extras.player.bind(t),this.extras.player.el)}get ctx(){return{state:this.o.state(),me:this.o.me(),reported:this.reported}}act={like:e=>this.toggleLike(e,performance.now()),knock:e=>this.knock(e,performance.now()),greet:e=>this.openWheel(performance.now(),e),block:(e,t)=>this.block(e,t,performance.now()),report:(e,t)=>this.report(e,t,performance.now())};drawn(e){for(let t of this.o.renderer().buildingsDrawn)if(t.b.id===e)return t}findAt(e){for(let t of this.o.renderer().buildingsDrawn)if(e.x>=t.x&&e.x<=t.x+192&&e.y>=t.y-4&&e.y<=t.y+t.m.height)return t}likeSpot(e){let t=An(e.m);return{x:e.x+t.x+t.w-10,y:e.y+t.y+t.h/2}}goal(e){return this.celebrating&&e<this.celebrating.until?this.celebrating.goal:Or(this.city)}toWindow(e,t){let n=this.o.camera.worldToScreen(e,t),r=this.o.canvas.getBoundingClientRect();return{x:r.left+n.x,y:r.top+n.y}}building(e,t,n){let r=t.b.tokens?.day;if(r===void 0||!t.s)return;let i=ui(t.m),a=this.wiggles.get(t.b.id),o=a?Math.max(0,1-(n-a.at)/bi):0;pi(e,t.x+i.x,t.y+i.y,li(r),n,o,t.b.state===`online`)}props(e,t){let n=this.propsPool,r=0,i=(e,i)=>{let a=n[r];a||(n[r]=a={y:e,draw:i}),a.y=e,a.draw=i,r++,t(a)},a=(t,n,r,i)=>t<e.x1&&t+r>e.x0&&n<e.y1&&n+i>e.y0,o=Z.w,s=Z.h+Z.posts;if(a(Z.goal.x-o/2,Z.goal.y-s,o,s)&&i(Z.goal.y,(e,t)=>Vr(e,this.goal(t),t)),a(Z.hall.x-o/2,Z.hall.y-s,o,s)&&i(Z.hall.y,e=>Hr(e,(this.city?.lit??0)>0)),!((this.goal(this.lastNow)?.reached??0)<1)){for(let[e,t,n,r]of Ir)a(e,t-4,n-e,30)&&i(t+40,(i,a)=>Gr(i,e,t,n,r,a));for(let e of Yr(jr(new Date)))a(e.x-20,e.y-60,40,64)&&i(e.y,t=>Jr(t,e.kind,e.x,e.y))}}world(e,t,n){let r=this.o.renderer(),i=r.night;e.save(),e.globalCompositeOperation=`lighter`;for(let n of r.buildingsDrawn){let r=n.b.tokens;if(!r||!n.s)continue;let a=n.b.state===`online`;if(a&&gi(e,n.x,n.y,n.m,ci(r.week),t,i,n.b.lot.x*7+n.b.lot.y*13&15),a){let t=ui(n.m);mi(e,n.x+t.x,n.y+t.y,li(r.day),i)}}e.restore();for(let n of this.hearts){let r=ti(n,t);r&&this.drawHeart(e,r.x,r.y,r.scale,r.alpha,n.broken===!0,i)}i>.15&&this.plazaLights(e,t,n,i),this.confetti.draw(e,n.x0,n.y0,n.x1,n.y1,t),this.fireworks.draw(e,t,n,i)}plazaLights(e,t,n,r){let i=(e,t,r,i)=>e<n.x1&&e+r>n.x0&&t<n.y1&&t+i>n.y0;e.save(),e.globalCompositeOperation=`lighter`;for(let[t,n]of[[Z.goal,`rgba(255,150,110,`],[Z.hall,`rgba(130,180,255,`]]){let a=t.x-Z.w/2+3,o=t.y-Z.posts-Z.h+3;i(a,o,Z.w,Z.h)&&(e.fillStyle=`${n}${(.16*r).toFixed(3)})`,e.fillRect(a,o,Z.w-6,Z.h-6),e.fillStyle=`${n}${(.07*r).toFixed(3)})`,e.fillRect(a-6,o-6,Z.w+6,Z.h+6))}if((this.goal(t)?.reached??0)>=1){for(let[n,a,o,s]of Ir)i(n,a-4,o-n,34)&&Kr(e,n,a,o,s,t,r);if(jr(new Date)===`halloween`)for(let n of Yr(`halloween`)){if(n.kind!==`pumpkin`||!i(n.x-20,n.y-30,40,40))continue;let a=.75+.25*Math.sin(t/90+n.x),o=e.createRadialGradient(n.x,n.y-10,0,n.x,n.y-10,18);o.addColorStop(0,`rgba(255,150,40,${(.32*r*a).toFixed(3)})`),o.addColorStop(1,`rgba(255,150,40,0)`),e.fillStyle=o,e.fillRect(n.x-18,n.y-28,36,36)}}e.restore()}drawHeart(e,t,n,r,i,a,o){let s=Math.max(1,Math.round(r*1.5))/1.5,c=Math.max(1,s),l=7*c,u=6*c,d=Math.round(t-l/2),f=Math.round(n-u/2);e.save(),e.globalAlpha=i,o>.2&&(e.globalCompositeOperation=`lighter`,e.fillStyle=`rgba(255,90,120,0.25)`,e.fillRect(d-3,f-3,l+6,u+6),e.globalCompositeOperation=`source-over`),ni.forEach((t,n)=>{for(let r=0;r<t.length;r++){let i=t[r];if(i===`.`)continue;let o=a&&r>=4?1:0;e.fillStyle=i===`2`?`#ffd1da`:a?`#9a6b78`:`#ff4f6d`,e.fillRect(d+r*c,f+(n+o)*c,c,c)}}),e.restore()}screen(e,t,n){let r=this.o.renderer();for(let i of r.buildingsDrawn){let r=An(i.m),a=n.sx(i.x+r.x),o=n.sy(i.y+r.y),s=r.w*n.k,c=r.h*n.k;i.b.unverified===!0&&n.zoom>=1.05&&c>=9&&this.drawSeal(e,a-2,o+c/2);let l=this.bumps.get(i.b.id);if(l!==void 0){let r=(t-l)/xi;r>=1?this.bumps.delete(i.b.id):this.drawBump(e,a+s-12*n.k,o+c/2,r)}}for(let r of this.pops){let i=(t-r.at)/1300;i<0||i>=1||(e.globalAlpha=i>.7?(1-i)/.3:1,e.font=`${Math.round(14+6*Math.sin(Math.min(1,i*3)*Math.PI*.5))}px ${vi}`,e.textAlign=`center`,e.fillText(r.text,n.sx(r.x),n.sy(r.y)-i*18),e.textAlign=`left`,e.globalAlpha=1)}n.zoom>=Si&&this.drawBoardTexts(e,n);let i=this.o.state().me?.id,a=this.placed;a.length=0;let o=[];for(let e of r.charsDrawn){if(!e.visible)continue;let r=e.me?i:e.id;if(!r)continue;let a=this.balloons.get(r,t);if(!a)continue;let s=n.zoom>=.85?20:4;o.push({x:n.sx(e.x),y:n.sy(e.headY)-s,id:a.id,age:a.age,me:e.me})}o.sort((e,t)=>t.y-e.y);for(let t of o){let r=this.balloonWidth(e,t.id,n.zoom),i=t.y;for(let e=0;e<6;e++){let e=!1;for(let n=0;n<a.length;n+=4)t.x+r/2>a[n]&&t.x-r/2<a[n]+a[n+2]&&i>a[n+1]&&i-30<a[n+1]+a[n+3]&&(i=a[n+1]-2,e=!0);if(!e)break}a.push(t.x-r/2,i-30,r,30),this.drawBalloon(e,t.x,i,t.id,t.age,t.me,n.zoom)}}placed=[];balloonWidth(e,t,n){return n<.85?28:(e.font=`700 11.5px ${_i}`,Math.round(22+Math.min(170,e.measureText(De(t)).width)+6+6))}drawSeal(e,t,n){e.save(),e.fillStyle=`rgba(20,24,33,0.85)`,e.strokeStyle=`rgba(200,206,220,0.8)`,e.lineWidth=1,e.beginPath(),e.arc(Math.round(t),Math.round(n),6,0,Math.PI*2),e.fill(),e.stroke(),e.fillStyle=`#c8cedc`,e.font=`800 9px ${_i}`,e.textAlign=`center`,e.textBaseline=`middle`,e.fillText(`?`,Math.round(t),Math.round(n)+.5),e.restore()}drawBump(e,t,n,r){e.save(),e.globalAlpha=(1-r)*.9,e.strokeStyle=`#ff7b93`,e.lineWidth=2,e.beginPath(),e.arc(t,n,6+r*16,0,Math.PI*2),e.stroke(),e.globalAlpha=r<.8?1:(1-r)/.2,e.font=`800 12px ${_i}`,e.textAlign=`center`,e.textBaseline=`middle`,e.fillStyle=`rgba(10,14,24,0.6)`,e.fillText(`+❤`,t+.5,n-12-r*16+1),e.fillStyle=`#ffd1da`,e.fillText(`+❤`,t,n-12-r*16),e.restore()}drawBalloon(e,t,n,r,i,a,o){let s=Math.min(1,i/180),c=s<1?.6+.4*(1-(1-s)*(1-s))+Math.sin(s*Math.PI)*.08:1,l=i>4600?Math.max(0,1-(i-4600)/400):1,u=we(r),d=o<.85?``:De(r);e.save(),e.globalAlpha=l,e.translate(Math.round(t),Math.round(n)),e.scale(c,c),e.font=`700 11.5px ${_i}`;let f=d?Math.min(170,e.measureText(d).width):0,p=Math.round(22+(d?f+6:0)+6),m=-p/2;if(e.fillStyle=`rgba(10,14,24,0.35)`,e.beginPath(),e.roundRect(m+1,-27,p,22,9),e.fill(),e.fillStyle=a?`#e6f4ff`:`#fffaf0`,e.strokeStyle=a?`#7cc8ff`:`#2a2f3a`,e.lineWidth=1.5,e.beginPath(),e.roundRect(m,-29,p,22,9),e.fill(),e.stroke(),e.beginPath(),e.moveTo(-5,-8),e.lineTo(0,-1),e.lineTo(5,-8),e.closePath(),e.fill(),e.beginPath(),e.moveTo(-5,-7),e.lineTo(0,-1),e.lineTo(5,-7),e.stroke(),e.fillStyle=a?`#e6f4ff`:`#fffaf0`,e.fillRect(-4,-9,8,2),e.textBaseline=`middle`,e.textAlign=`left`,e.font=`14px ${vi}`,e.fillText(u,m+6,-17),d){e.font=`700 11.5px ${_i}`,e.fillStyle=`#1b2030`;let t=d;for(;t.length>1&&e.measureText(t).width>170;)t=`${t.slice(0,-2).trimEnd()}…`;e.fillText(t,m+26,-17.5)}e.restore()}drawBoardTexts(e,n){let r=Ur(),i=n.k,a=this.goal(this.lastNow),o=Ar(this.city),s=(t,n,r,i,a,o,s=700,c=`left`)=>{e.font=`${s} ${a.toFixed(1)}px ${_i}`;let l=t;for(;l.length>1&&e.measureText(l).width>i;)l=`${l.slice(0,-2).trimEnd()}…`;e.textAlign=c,e.fillStyle=`rgba(5,8,14,0.6)`,e.fillText(l,n+.5,r+1),e.fillStyle=o,e.fillText(l,n,r)},c=(t,n,r,i=600)=>{e.font=`${i} ${r.toFixed(1)}px ${_i}`;let a=[],o=``;for(let r of t.split(` `)){let t=o?`${o} ${r}`:r;e.measureText(t).width<=n||!o?o=t:(a.push(o),o=r)}return o&&a.push(o),a};e.save(),e.textBaseline=`middle`;let l=Math.max(7,Math.min(11,4.2*i)),u=l*1.18;{let e=r.goal,o=n.sx(e.x),d=n.sy(e.y),f=e.w*i;s(t(`META DA CIDADE`),o+f/2,d+4*i,f-4,Math.max(7,Math.min(11,4.6*i)),`#fff1e0`,800,`center`);let p=o+16*i,m=f-19*i;if(a){let e=Math.max(10,Math.min(24,9.5*i));s(a.pctText,p,d+17*i,m,e,a.pct>=1?`#ffd166`:`#ff9c74`,800);let t=d+17*i+e*.75+u*.5;for(let e of c(a.label,m,l).slice(0,2))s(e,p,t,m,l,`#d6dcea`,600),t+=u;s(a.progressText,p,t,m,l*.92,`#9aa4b8`,600)}else{let e=d+17*i;for(let n of c(t(`A meta aparece com 10 prédios acesos.`),m,l).slice(0,4))s(n,p,e,m,l,`#9aa4b8`,600),e+=u}}{let e=r.hall,a=n.sx(e.x),d=n.sy(e.y),f=e.w*i;s(t(`PREFEITURA`),a+f/2,d+4*i,f-4,Math.max(7,Math.min(11,4.6*i)),`#e3f1ff`,800,`center`);let p=a+23*i,m=f-26*i;if(o){let e=d+15*i;for(let t of c(o.lit,m,l,700).slice(0,2))s(t,p,e,m,l,`#ffd27a`,700),e+=u;e+=u*.3;for(let t of c(o.tokens,m,l).slice(0,4))s(t,p,e,m,l,`#d6dcea`,600),e+=u}}e.restore()}},Oi=class{s;el;likeBtn;knockBtn;hint;code;seal;id=``;key=``;constructor(e){this.s=e,this.likeBtn=N(`button`,{class:`ui-city-x__btn`,type:`button`,on:{click:()=>this.like()}}),this.knockBtn=N(`button`,{class:`ui-city-x__btn`,type:`button`,on:{click:()=>this.knock()}},N(`span`,{text:`🚪`,attrs:{"aria-hidden":`true`}}),` ${t(`Bater`)}`),this.hint=N(`span`,{class:`ui-city-x__hint`}),this.code=N(`span`,{class:`ui-city-x__code`,title:t(`Código do prédio: "Ir para", no minimapa, leva até a porta`)}),this.seal=N(`div`,{class:`ui-city-x__seal`,text:`❔ ${t(`Não verificado: os dados deste prédio estão em revisão.`)}`}),this.el=N(`div`,{class:`ui-city-x`},N(`div`,{class:`ui-city-x__row`},this.likeBtn,this.knockBtn,this.code),this.hint,this.seal)}bind(e){this.id=e,this.key=``,this.sync()}building(){return this.s.ctx.state.buildings.get(this.id)}sync(){let e=this.building();if(!e||!this.el.isConnected)return;let{me:n,state:r}=this.s.ctx,i=$r(e,n,r.myBuildingId),a=`${e.id}|${i.canLike}|${i.canKnock}|${i.liked}|${i.mine}|${+!!e.knocks}|${e.code??``}|${+!!e.unverified}`;if(a===this.key)return;this.key=a,P(this.likeBtn,i.mine),this.likeBtn.replaceChildren(N(`span`,{text:i.liked?`💔`:`❤️`,attrs:{"aria-hidden":`true`}}),` ${i.liked?t(`Descurtir`):t(`Curtir`)}`),this.likeBtn.classList.toggle(`is-liked`,i.liked),this.likeBtn.disabled=!i.canLike,P(this.knockBtn,i.mine||!e.knocks),this.knockBtn.disabled=!i.canKnock,M(this.code,e.code??``),P(this.code,!e.code);let o=i.mine?t(`Seu prédio: os likes de hoje aparecem na barra do escritório.`):i.canLike?e.knocks&&!i.canKnock?t(`Mais perto da porta, dá para bater (K).`):``:t(`Chegue perto da porta para curtir (L).`);M(this.hint,o),P(this.hint,!o),P(this.seal,e.unverified!==!0)}like(){let e=this.building();e&&this.s.act.like(e)}knock(){let e=this.building();e&&this.s.act.knock(e)}},ki=class{s;el;greetBtn;blockBtn;reportBtn;reasons;done;id=``;confirming=!1;constructor(e){this.s=e,this.greetBtn=N(`button`,{class:`ui-city-x__btn is-primary`,type:`button`,on:{click:()=>this.s.act.greet(this.id)}},N(`span`,{text:`👋`,attrs:{"aria-hidden":`true`}}),` ${t(`Cumprimentar`)}`,N(`kbd`,{text:`G`})),this.blockBtn=N(`button`,{class:`ui-city-x__btn is-quiet`,type:`button`,on:{click:()=>this.block()}}),this.reportBtn=N(`button`,{class:`ui-city-x__btn is-quiet`,type:`button`,attrs:{"aria-expanded":`false`},on:{click:()=>this.toggleReasons()}}),this.reasons=N(`div`,{class:`ui-city-x__reasons`,hidden:!0,role:`group`,attrs:{"aria-label":t(`Motivo da denúncia`)}},N(`span`,{class:`ui-city-x__hint`,text:t(`Qual o motivo?`)}),...s.map(e=>N(`button`,{class:`ui-city-x__reason`,type:`button`,text:_e(e),on:{click:()=>this.report(e)}}))),this.done=N(`div`,{class:`ui-city-x__done`,hidden:!0,text:`✓ ${t(`Denúncia enviada.`)}`}),this.el=N(`div`,{class:`ui-city-x`},N(`div`,{class:`ui-city-x__row`},this.greetBtn,this.blockBtn,this.reportBtn),this.reasons,this.done)}bind(e){e!==this.id&&(this.confirming=!1,P(this.reasons,!0)),this.id=e,this.sync()}sync(){if(!this.el.isConnected)return;let e=this.s.ctx.reported.has(this.id);M(this.blockBtn,this.confirming?`🚫 ${t(`Confirmar: bloquear`)}`:`🚫 ${t(`Bloquear`)}`),this.blockBtn.classList.toggle(`is-danger`,this.confirming),this.blockBtn.title=t(`Vocês deixam de se ver: na rua, nos prédios, nos cumprimentos e nos carimbos.`),M(this.reportBtn,e?`✓ ${t(`Denunciado`)}`:`⚑ ${t(`Denunciar`)}`),this.reportBtn.disabled=e,P(this.done,!e),e&&P(this.reasons,!0)}block(){if(!this.confirming){this.confirming=!0,this.sync();return}this.confirming=!1;let e=this.s.ctx.state.players.get(this.id)?.info.name??``;this.s.act.block(this.id,e)}toggleReasons(){let e=this.reasons.hidden;P(this.reasons,!e),this.reportBtn.setAttribute(`aria-expanded`,String(e))}report(e){this.s.act.report(this.id,e)&&this.sync()}};function Q(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}var $=e=>typeof e==`number`&&Number.isFinite(e);function Ai(e){return Q(e)&&typeof e.id==`string`&&Q(e.lot)&&$(e.lot.x)&&$(e.lot.y)&&Q(e.owner)&&typeof e.owner.name==`string`}function ji(e){return Q(e)&&typeof e.id==`string`&&typeof e.name==`string`&&Q(e.pos)&&$(e.pos.x)&&$(e.pos.y)}function Mi(e){if(!Q(e)||!$(e.x)||!$(e.y))return null;let t=e.dir===`n`||e.dir===`s`||e.dir===`e`||e.dir===`w`?e.dir:`s`;return{x:e.x,y:e.y,dir:t,moving:e.moving===!0}}function Ni(e){return Q(e)&&typeof e.id==`string`&&$(e.rev)&&Q(e.detail)&&Ai(e.detail.building)&&Array.isArray(e.detail.floors)}var Pi=e=>Q(e)&&$(e.x)&&$(e.y)&&$(e.lit),Fi=class{me=null;startPos=null;myBuildingId=null;connected=!1;afk=!1;inside=null;district;buildings=new Map;lots=new Map;chunkIds=new Map;chunkRev=new Map;players=new Map;minimap=[];version=0;minimapVersion=0;buildingAt(e){let t=this.lots.get(U(e));return t?this.buildings.get(t):void 0}myBuilding(){return this.myBuildingId?this.buildings.get(this.myBuildingId):void 0}applySnapshot(e,t){this.buildings.clear(),this.lots.clear(),this.chunkIds.clear(),this.chunkRev.clear(),this.players.clear(),this.connected=e.connected!==!1,this.afk=e.afk===!0,this.inside=Ni(e.inside)?structuredClone(e.inside):null,this.district=typeof e.district==`string`?e.district:void 0,e.me&&(this.me=e.me,this.myBuildingId=e.me.buildingId??e.me.id);let n=Mi(e.pos);n&&(this.startPos={x:n.x,y:n.y});for(let t of Array.isArray(e.chunks)?e.chunks:[])Q(t)&&typeof t.chunk==`string`&&Array.isArray(t.buildings)&&this.applyArea(t.chunk,$(t.rev)?t.rev:0,t.buildings.filter(Ai));for(let n of Array.isArray(e.players)?e.players:[])ji(n)&&this.join(n,t);this.minimap=[],Array.isArray(e.minimap)&&this.setMinimap(e.minimap.filter(Pi)),this.minimapVersion++,this.version++}apply(e,t){if(!Q(e)||typeof e.t!=`string`)return null;switch(e.t){case`area`:return typeof e.chunk==`string`&&Array.isArray(e.buildings)&&(this.applyArea(e.chunk,$(e.rev)?e.rev:0,e.buildings.filter(Ai)),this.version++),null;case`area.patch`:return typeof e.chunk==`string`&&this.applyPatch(e.chunk,e),null;case`players`:if(Array.isArray(e.players))for(let n of e.players){if(!Q(n)||typeof n.id!=`string`||n.id===this.me?.id)continue;let e=this.players.get(n.id),r=Mi(n.pos);e&&r&&(e.info.pos=r,Q(n.greeting)&&(e.info.greeting=n.greeting),un(e.samples,{t,...r}))}return null;case`player.join`:return ji(e.player)&&this.join(e.player,t),null;case`player.leave`:return typeof e.id==`string`&&this.players.delete(e.id),null;case`profile`:if(ji(e.player)){let t=this.players.get(e.player.id);return t&&(t.info={...t.info,...e.player,pos:t.info.pos}),{type:`profile`,player:e.player}}return null;case`minimap`:return Array.isArray(e.blocks)&&(this.setMinimap(e.blocks.filter(Pi)),this.minimapVersion++),null;case`like.update`:{let t=typeof e.buildingId==`string`?this.buildings.get(e.buildingId):void 0;return t&&$(e.likes)&&(t.likes=e.likes,t.likedByMe=e.likedByMe===!0,this.version++),null}case`pos`:return $(e.x)&&$(e.y)?{type:`pos`,x:e.x,y:e.y}:null;case`afk`:return this.afk=!0,{type:`afk`};case`notice`:return typeof e.text==`string`?{type:`notice`,level:e.level===`warn`||e.level===`error`?e.level:`info`,text:e.text}:null;case`building`:{let t=e.detail;return!$(e.rev)||!Q(t)||!Ai(t.building)||!Array.isArray(t.floors)?null:{type:`building`,inside:{id:t.building.id,rev:e.rev,detail:{building:t.building,floors:t.floors,visitors:$(t.visitors)?t.visitors:0}}}}case`building.patch`:return $(e.rev)?{type:`building.patch`,msg:e}:null;default:return null}}keepAround(e,t){let n=this.district;if(n===void 0){for(let e of this.chunkIds.keys())if(n=x(e)?.district,n!==void 0)break}if(n===void 0)return!1;let r=n,i=new Set(w(_(S(e,t))).map(e=>k(r,e))),a=!1;for(let[e,t]of[...this.chunkIds])if(!i.has(e)){for(let e of t)this.removeBuilding(e);this.chunkIds.delete(e),this.chunkRev.delete(e),a=!0}return a&&this.version++,a}join(e,t){if(e.id===this.me?.id)return;let n=this.players.get(e.id),r=n?.samples??[];un(r,{t,...Mi(e.pos)}),this.players.set(e.id,{info:{...e},samples:r,...n?.delay===void 0?{}:{delay:n.delay}})}setMinimap(e){this.minimap=e.map(e=>({x:Math.floor(e.x),y:Math.floor(e.y),lit:Math.max(0,Math.floor(e.lit))}))}putBuilding(e,t){let n=this.buildings.get(e.id);n&&U(n.lot)!==U(e.lot)&&this.lots.get(U(n.lot))===e.id&&this.lots.delete(U(n.lot)),this.buildings.set(e.id,e),this.lots.set(U(e.lot),e.id);for(let[n,r]of this.chunkIds)n!==t&&r.delete(e.id);let r=this.chunkIds.get(t);r||this.chunkIds.set(t,r=new Set),r.add(e.id)}removeBuilding(e){let t=this.buildings.get(e);if(t){this.lots.get(U(t.lot))===e&&this.lots.delete(U(t.lot)),this.buildings.delete(e);for(let t of this.chunkIds.values())t.delete(e)}}applyArea(e,t,n){let r=new Set(n.map(e=>e.id));for(let t of this.chunkIds.get(e)??[])r.has(t)||this.removeBuilding(t);this.chunkIds.set(e,new Set),this.chunkRev.set(e,t);for(let t of n)this.putBuilding({...t},e)}applyPatch(e,t){$(t.rev)&&this.chunkRev.set(e,t.rev);for(let n of Array.isArray(t.changes)?t.changes:[]){if(!Q(n)||typeof n.id!=`string`)continue;if(n.lot!==void 0){Ai(n)&&this.putBuilding({...n},e);continue}let t=this.buildings.get(n.id);t&&this.putBuilding({...t,...n},e)}if(Array.isArray(t.removed))for(let e of t.removed)typeof e==`string`&&this.removeBuilding(e);this.version++}},Ii=se,Li=.28,Ri=[.375,.5,.75],zi=3e4,Bi=2,Vi=5e3,Hi=class extends ie{levels(){let e=new Set(super.levels());for(let t of Ri)t>=this.minZoom-1e-6&&e.add(t);return e.add(this.minZoom),[...e].sort((e,t)=>e-t)}};function Ui(e){let n=new Hi;n.minZoom=Li,n.bounds={x:-1e7,y:-1e7,w:2e7,h:2e7};let r=new Fi,i=new wr(e.canvas,Ii,n,r),a=null,s=null,c=null,l=!0,u=!1,f=0,p=0,m=null,h=null,g=``,v=null,y=null,x=!1,C=!1,w,T=null,E=!1,ee=new ue(rt({x:0,y:0,w:4,h:4}).grid),D=[],O=[],k=null,A=new Ve({showBuilding:e=>oe(e),topInset:()=>e.topInset(),enter:e=>z(e),extras:(e,t)=>k?.cardExtras(e,t)??null}),te=new yt(e=>{l=!1;let t=n.zoom,r=n.centerFor(e.x*16,e.y*16,t);n.animateTo(r.x,r.y,t,Date.now(),380)}),j=N(`div`,{class:`ui-city-toast`,role:`status`,attrs:{"aria-live":`polite`},hidden:!0}),M=N(`div`,{class:`ui-city-loading`,text:t(`Entrando na cidade…`)}),P=N(`div`,{class:`ui-city-help`,attrs:{"aria-hidden":`true`}},N(`span`,{},N(`kbd`,{text:`WASD`}),` `,t(`andar`)),N(`span`,{},N(`kbd`,{text:`Shift`}),` `,t(`correr`)),N(`span`,{},N(`kbd`,{text:t(`clique`)}),` `,t(`ir até lá`)),N(`span`,{},N(`kbd`,{text:`E`}),` `,t(`entrar`)),N(`span`,{},N(`kbd`,{text:`Esc`}),` `,t(`escritório`))),F=N(`div`,{class:`ui-city`,hidden:!0},A.el,te.el,P,j,M);e.uiRoot.append(F),k=new Di({state:()=>r,renderer:()=>i,camera:n,canvas:e.canvas,send:e=>a?.send(e),me:()=>s?{x:s.x,y:s.y}:null,cards:A,toast:e=>L(e),active:()=>u,teleported:()=>{if(!s)return;l=!0,n.stop();let e=n.centerFor(s.x*16,s.y*16-12,n.zoom);n.x=e.x,n.y=e.y,g=``},replay:e=>{let t=r.apply(e,performance.now());t&&se(t)},testFireworks:()=>a?.celebrate?.()}),F.append(k.el),P.append(...k.helpItems());let I=null,L=e=>{j.textContent=e,j.hidden=!1,j.classList.remove(`is-in`),j.offsetWidth,j.classList.add(`is-in`),I&&clearTimeout(I),I=setTimeout(()=>j.hidden=!0,2600)},R=()=>{let t=Math.max(1,Math.min(3,window.devicePixelRatio||1)),r=e.canvas.clientWidth||window.innerWidth,i=e.canvas.clientHeight||window.innerHeight,a=Math.floor(r*t),o=Math.floor(i*t);(e.canvas.width!==a||e.canvas.height!==o)&&(e.canvas.width=a,e.canvas.height=o),n.setView(r,i,t),n.insets={top:e.topInset(),right:0,bottom:0,left:0}},ne=()=>{let e=r.me,t=r.startPos;if(!e||s||!t)return;if(r.startPos=null,!ot(t.x,t.y)){let e=at(t.x,t.y);e&&(t={x:e.x+.5,y:e.y+.5})}s=new hn(t.x,t.y),c=new vn(e=>a?.send([e])),l=!0;let i=n.zoom,o=n.centerFor(s.x*16,s.y*16-12,i);n.stop(),n.x=o.x,n.y=o.y,M.hidden=!0},re=()=>{if(!s)return;l=!0;let e=n.centerFor(s.x*16,s.y*16-12,n.zoom);n.stop(),n.x=e.x,n.y=e.y},ie=()=>{x=!1;let e=r.startPos;if(!e){C=!0;return}let t=Tr(y,e);if(y=null,t===`keep`){r.startPos=null,c?.reset();return}s=null,c=null},ae=(e,t,n)=>{if(!s)return!1;let r={x:e,y:t};if(!ot(e,t)){let n=at(e,t,6);if(!n)return!1;r={x:n.x+.5,y:n.y+.5}}let i=rt(it(s,r));ee.setGrid(i.grid);let a=Math.floor(s.x)-i.ox,o=Math.floor(s.y)-i.oy,c=Math.floor(r.x)-i.ox,u=Math.floor(r.y)-i.oy,d=[];return ee.find(a,o,c,u,d)?(s.follow(gn(d,i.ox,i.oy,r),n),l=!0,!0):!1},oe=e=>{let t=r.buildings.get(e);if(!t)return;l=!1;let i=b(t.lot),a=Math.max(n.zoom,1.5),o=n.centerFor(i.front.x*16,i.front.y*16-60,a);n.animateTo(o.x,o.y,a,Date.now(),420)},se=e=>{switch(e.type){case`building`:le(e.inside);break;case`building.patch`:v?.patch(e.msg);break;case`pos`:if(v&&B(),s&&C){C=!1;let t=Tr(y,e);y=null,t!==`keep`&&(s.correct(e.x,e.y),re()),c?.reset()}else s?(s.correct(e.x,e.y),c?.reset()):(r.startPos={x:e.x,y:e.y},ne(),ce());break;case`afk`:break;case`profile`:if(A.kind===`player`&&A.id===e.player.id){let t=r.players.get(e.player.id),n=t?t.info:e.player;A.showPlayer(n,n.buildingId?r.buildings.get(n.buildingId):void 0,null)}break;case`notice`:{let t=v?`inside`:T&&Date.now()-T.at<Vi?`door`:`street`;t===`door`&&(T=null);let n=bt(e.text,t);n&&L(n);break}}},z=e=>{if(v||!a||!s){!s&&e===r.myBuildingId&&(E=!0);return}T={id:e,at:Date.now()},a.send([{t:`enter`,buildingId:e}])},ce=()=>{E&&s&&r.connected&&r.myBuildingId&&(E=!1,z(r.myBuildingId))},le=t=>{if(T=null,v&&v.id===t.id){v.replace(t);return}v&&B();let n=r.me;if(!n||!u)return;A.hide(),ve.clearKeys(),cancelAnimationFrame(f),e.canvas.hidden=!0,F.classList.add(`is-visiting`);let i=a;v=Qt({uiRoot:e.uiRoot,after:e.canvas,inside:t,me:n,mine:t.id===r.myBuildingId,options:()=>e.options(),version:e.version?.()??``,topInset:()=>e.topInset(),send:e=>i?.send(e),toast:e=>L(e),summaryStamps:()=>w?.stamps??[],stuck:()=>{B(),a?.send([{t:`view`}])}})},B=()=>{if(!v)return;let t=v;v=null,t.destroy(),F.classList.remove(`is-visiting`),u&&(e.canvas.hidden=!1,p=0,cancelAnimationFrame(f),f=requestAnimationFrame(be),l=!0)},V=()=>t(`Sem conexão com o Habblaud World agora; o Habblaud tenta de novo sozinho.`),de=e=>{switch(e.type){case`snapshot`:r.applySnapshot(e.snapshot,performance.now()),k?.snapshot(e.snapshot),w=e.snapshot.summary,x&&ie(),ne(),s&&(g=``),r.inside?le(r.inside):v&&B(),ce(),M.textContent=r.connected?t(`Entrando na cidade…`):V(),M.hidden=r.connected&&!!s;return;case`message`:{if(v?.message(e.msg)||k?.message(e.msg,performance.now()))return;e.msg.t===`away.summary`&&(w=o(e.msg)??w);let t=r.apply(e.msg,performance.now());t&&se(t);return}case`status`:e.status===`retrying`&&(M.textContent=V(),M.hidden=!1);return;case`error`:e.code===`not_connected`?(M.textContent=V(),M.hidden=!1):e.code!==`no_stream`&&L(d(e.code,`scene`));return}},fe=()=>{x=!!(y?.me&&s),C=!1,x||(y=null,r=new Fi,i=new wr(e.canvas,Ii,n,r),i.fx=k,s=null,c=null,M.textContent=t(`Entrando na cidade…`),M.hidden=!1),k?.reset(),g=``,A.hide();let o=e.openStream();a=o,o.on(e=>{if(a===o)try{de(e)}catch(e){console.error(`[cidade] evento do stream ignorado`,e)}})},pe=()=>{a?.close(),a=null},me=(e,t)=>{let r=n.screenToWorld(e,t),a=Math.max(1,3/n.zoom);for(let e=i.charsDrawn.length-1;e>=0;e--){let t=i.charsDrawn[e];if(t.visible&&!t.me&&r.x>=t.bx-a&&r.x<=t.bx+t.bw+a&&r.y>=t.by-a&&r.y<=t.by+t.bh+a)return{type:`player`,id:t.id}}let o=null,s=-1/0;for(let e of i.buildingsDrawn)r.x<e.x||r.x>e.x+192||r.y<e.y||r.y>e.y+e.m.height||e.depth>s&&(s=e.depth,o={type:`building`,id:e.b.id});return o},H=null,he=(e,t,i)=>{let o=me(e,t),s=ge(e,t);if(o?.type===`player`){let e=r.players.get(o.id);if(!e)return;A.showPlayer(e.info,e.info.buildingId?r.buildings.get(e.info.buildingId):void 0,s),a?.send([{t:`profile`,playerId:o.id}]);return}if(o?.type===`building`){let e=r.buildings.get(o.id);if(!e)return;A.showBuilding(e,r.myBuildingId,s,!0);let t=b(e.lot).front;ae(t.x,t.y+(b(e.lot).side===`s`?.3:-.3),i.shift);return}A.hide();let c=n.screenToWorld(e,t);ae(c.x/16,c.y/16,i.shift)},ge=(t,n)=>{let r=e.canvas.getBoundingClientRect();return{x:r.left+t,y:r.top+n}},_e=()=>{if(!m){H&&A.kind===`building`&&!A.pinned&&A.hide(),H=null,e.canvas.style.cursor=``;return}let t=me(m.x,m.y);if(H=t,e.canvas.style.cursor=t?`pointer`:`crosshair`,t?.type===`building`){let e=r.buildings.get(t.id);e&&(!A.pinned||A.id===e.id)&&A.showBuilding(e,r.myBuildingId,ge(m.x,m.y),!1)}else A.kind===`building`&&!A.pinned&&A.hide()},ve=new qe(e.canvas,n,{active:()=>u&&!v,hover:(e,t,n)=>{m=n?{x:e,y:t}:null},click:he,interact:()=>{l=!1,n.stop()},zoomStep:(e,t=n.viewW/2,r=n.viewH/2)=>n.zoomAt(n.stepZoom(e),t,r,Date.now(),!0),use:()=>{if(!s)return;let e=st(s.x,s.y,e=>!!r.buildingAt(e),2),n=e?r.buildingAt(e.lot):void 0;if(!n){L(t(`Chegue perto da porta de um prédio e aperte E.`));return}z(n.id)},recenter:()=>ye(),moved:()=>{l=!0}}),ye=()=>{if(v)return v.world.overview();if(l=!0,!s)return;let e=n.centerFor(s.x*16,s.y*16-12,n.zoom);n.animateTo(e.x,e.y,n.zoom,Date.now(),360)},be=t=>{f=requestAnimationFrame(be);let a=p?t-p:16.7,o=p?Math.min(.1,Math.max(0,a/1e3)):1/60;p=t,O.push(a),O.length>240&&O.shift();let u=performance.now();try{let t=Math.max(1,Math.min(3,window.devicePixelRatio||1));(e.canvas.clientWidth!==n.viewW||e.canvas.clientHeight!==n.viewH||t!==n.dpr)&&R();let a=r.me;if(s&&a&&!x){s.update(o,ve.intent()),c?.tick(u,s);let e=_(S(s.x,s.y)),t=`${e.x},${e.y}`;t!==g&&(g=t,r.keepAround(s.x,s.y))}k?.frame(u,o);let d=l&&s?n.centerFor(s.x*16,s.y*16-12,n.zoom):null;n.update(Date.now(),d,o);let f=s?st(s.x,s.y,e=>!!r.buildingAt(e),2):null;if(i.frame(u,o,e.options(),s&&a?{player:s,self:a}:null,{building:H?.type===`building`?H.id:A.kind===`building`?A.id:null,player:H?.type===`player`?H.id:A.kind===`player`?A.id:null,door:f?f.front:null,me:s?{x:s.x,y:s.y}:null}),D.push(i.lastFrameMs),D.length>240&&D.shift(),_e(),A.kind===`building`&&A.id&&!r.buildings.has(A.id)&&A.hide(),A.kind===`player`&&A.id&&!r.players.has(A.id)&&A.hide(),s){let e=n.screenToWorld(0,0),t=n.screenToWorld(n.viewW,n.viewH);te.draw(r.minimap,r.minimapVersion,s,{x:e.x/16,y:e.y/16,w:(t.x-e.x)/16,h:(t.y-e.y)/16})}}catch(e){console.error(`[cidade] erro no frame`,e)}},xe=()=>{p=0,ve.clearKeys(),document.hidden||c?.reset()},Se={get visible(){return u},show(){u||(u=!0,e.canvas.hidden=!1,F.hidden=!1,R(),y?(n.stop(),n.zoom=y.zoom,n.x=y.camX,n.y=y.camY,l=y.following):n.animating||(n.zoom=n.viewW<600?1.5:2),fe(),p=0,f=requestAnimationFrame(be),window.addEventListener(`resize`,R),document.addEventListener(`visibilitychange`,xe),h=setInterval(()=>{document.hidden&&s&&c&&!v&&c.keepAlive(s)},zi))},hide(){u&&(v&&B(),E=!1,y={camX:n.x,camY:n.y,zoom:n.zoom,following:l,me:s?{x:s.x,y:s.y}:null},u=!1,cancelAnimationFrame(f),e.canvas.hidden=!0,F.hidden=!0,A.hide(),k?.hide(),ve.clearKeys(),pe(),window.removeEventListener(`resize`,R),document.removeEventListener(`visibilitychange`,xe),h&&clearInterval(h),h=null)},zoomBy(e){if(!(!Number.isFinite(e)||e<=0||e===1)){if(v)return v.world.zoomBy(e);n.zoomAt(n.stepZoom(e>1?1:-1),n.viewW/2,n.viewH/2,Date.now(),!0)}},recenter:ye,lookAt(e,t,r=n.zoom){l=!1,n.stop(),n.zoom=Math.max(Li,Math.min(6,r));let i=n.centerFor(e*16,t*16,n.zoom);n.x=i.x,n.y=i.y},escape(){return v?v.escape():k?.escape()?!0:A.open?(A.hide(),!0):!1},destroy(){Se.hide(),ve.destroy(),k?.destroy(),F.remove()},perf(){let e=[...D].sort((e,t)=>e-t),t=D.reduce((e,t)=>e+t,0)/Math.max(1,D.length),r=e[Math.min(e.length-1,Math.floor(e.length*.95))]??0,a=O.reduce((e,t)=>e+t,0)/Math.max(1,O.length);return{frames:D.length,drawAvgMs:t,drawP95Ms:r,drawMaxMs:e[e.length-1]??0,fps:a?1e3/a:0,buildings:i.buildingsDrawn.length,zoom:n.zoom}},camera:n,get state(){return r},perfReset(){D.length=0,O.length=0},me:()=>s?{x:s.x,y:s.y,moving:s.moving,seated:!s.moving&&i.onBench(s.x,s.y)}:null,toScreen:(e,t)=>n.worldToScreen(e*16,t*16),enter:e=>z(e),visitOwn(){let e=r.myBuildingId;s&&a&&e&&r.connected?z(e):E=!0},visit:()=>v,walkTo:(e,t)=>ae(e,t,!1),doorOf(e){let t=r.buildings.get(e);return t?{...b(t.lot).front}:null}};return Se}export{Li as CITY_MIN_ZOOM,Bi as ENTER_RADIUS,Ui as createCityScene};
@@ -1 +0,0 @@
1
- import{s as e}from"./main-DktU0GfB.js";import{l as t,n}from"./simulator-BnBPS_Ws.js";import{c as r,g as i}from"./format-C7qb6Cn-.js";var a=32768;function o(e){let t=e.toBase64;if(typeof t==`function`)return t.call(e);let n=[];for(let t=0;t<e.length;t+=a)n.push(String.fromCharCode.apply(null,e.subarray(t,t+a)));return btoa(n.join(``))}async function s(t){try{return o(new Uint8Array(await t.arrayBuffer()))}catch{throw Error(e(`não deu para ler o arquivo`))}}function c(e=import.meta.url){try{return/\/bundle\/(main-[\w-]+)\.js$/.exec(new URL(e).pathname)?.[1]}catch{return}}function l(e){return e.behavior}var u=2,d=2e3,f=3e4;function p(e){return Math.min(f,d*2**Math.max(0,e))}function m(e){let t=new URLSearchParams(e),n=e=>{let n=t.get(e);if(n===null||n.trim()===``)return null;let r=Number(n);return Number.isFinite(r)?r:null},r=n(`speed`),i=n(`sessions`),a=n(`seed`);return{speed:r!==null&&r>0?Math.min(r,50):1,sessions:i!==null&&i>=0?Math.min(Math.floor(i),40):4,...a!==null&&a>=0?{seed:Math.floor(a)}:{},...t.get(`noquota`)===`1`?{codexNoQuota:!0}:{}}}var h=[{name:`compact`,description:e(`Resume a conversa para liberar contexto`),source:`builtin`},{name:`context`,description:e(`Mostra o uso do contexto`),source:`builtin`},{name:`review`,description:e(`Revisa um pull request`),source:`plugin`,plugin:`code-review`}],ee=class{snapshot=null;feed=[];connection=`connecting`;mock;listeners=new Map;agentIndex=new Map;roomIndex=new Map;source=null;mockTimer=null;search;openStream;attempts=0;retryTimer=null;retryAt=null;stopped=!0;onOnline=()=>{!this.stopped&&this.connection===`closed`&&this.reconnectNow()};replay=!1;live=null;constructor(e={}){this.mock=!!e.mock,this.search=e.search??(typeof location<`u`?location.search:``),this.openStream=e.eventSource??(e=>new EventSource(e))}on(e,t){let n=this.listeners.get(e);return n||this.listeners.set(e,n=new Set),n.add(t),()=>void n.delete(t)}connect(){if(this.stopped){if(this.stopped=!1,this.mock)return this.startMock();this.startSSE()}}disconnect(){this.stopped=!0,typeof removeEventListener==`function`&&removeEventListener(`online`,this.onOnline),this.clearRetry(),this.closeSource(),this.mockTimer&&clearInterval(this.mockTimer),this.mockTimer=null}reconnectNow(){this.mock||(this.clearRetry(),this.closeSource(),this.stopped=!1,this.startSSE())}get nextRetryAt(){return this.retryAt}agent(e){return this.agentIndex.get(e)}room(e){return this.roomIndex.get(e)}agentsInRoom(e){return(this.snapshot?.agents??[]).filter(t=>t.roomId===e)}async agentHistory(e){if(this.mock||this.replay)return this.agent(e)?.recent??[];let t=await fetch(`/api/agents/${encodeURIComponent(e)}`);return t.ok?(await t.json()).history:this.agent(e)?.recent??[]}async setDemo(e){return this.mock?!0:(await fetch(`/api/demo`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:e})})).ok}async checkUpdates(){return!this.mock&&(await fetch(`/api/updates/check`,{method:`POST`,headers:{"Content-Type":`application/json`},body:`{}`})).ok}async applyUpdate(){if(this.mock)return{ok:!1};let e=await fetch(`/api/updates/apply`,{method:`POST`,headers:{"Content-Type":`application/json`},body:`{}`});if(e.ok)return{ok:!0};let t=await e.json().catch(()=>({}));return t.error?{ok:!1,error:t.error}:{ok:!1}}get replaying(){return this.replay}get liveSnapshot(){return this.replay?this.live?.snap??null:this.snapshot}pushReplay(e){this.replay||(this.replay=!0,this.live=this.snapshot?{snap:this.snapshot,at:Date.now()}:null),this.setSnapshot(e)}stopReplay(){if(!this.replay)return;this.replay=!1;let e=this.live;this.live=null,e?this.setSnapshot({...e.snap,serverTime:e.snap.serverTime+(Date.now()-e.at)}):(this.snapshot=null,this.agentIndex=new Map,this.roomIndex=new Map)}async permissionDetail(e,t){let n=this.agent(e)?.permission;if(n?.id===t&&n.input!==void 0)return n;if(this.mock)return n?.id===t?n:void 0;let r=await fetch(`/api/permissions/${encodeURIComponent(t)}`);if(r.ok)return await r.json()}async decidePermission(t,n){let r=this.snapshot?.agents.find(e=>e.permission?.id===t)?.id,i=()=>{r&&this.emit(`decided`,{agentId:r,verdict:l(n)})};if(this.mock){let r=this.mockSim;if(!r?.decidePermission(t,n))return e(`Este pedido já foi respondido.`);this.applySnapshot(r.snapshot()),i();return}let a=await fetch(`/api/permissions/${encodeURIComponent(t)}/decision`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)});if(a.ok){i();return}try{let e=await a.json();if(typeof e.error==`string`)return e.error}catch{}return e(`Não foi possível responder (erro {0}).`,[a.status])}async saveCharacter(e,t){return this.characterRequest(e,`PUT`,t)}async resetCharacter(e){return this.characterRequest(e,`DELETE`,{})}async characterRequest(t,n,r){return this.mock||this.replay?e(`Editar o personagem só funciona com o escritório ao vivo.`):this.writeRequest(`/api/agents/${encodeURIComponent(t)}/character`,n,r,t=>e(`Não foi possível salvar o personagem (erro {0}).`,[t]))}async writeRequest(t,n,r,i){let a;try{a=await fetch(t,{method:n,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)})}catch{return e(`Sem conexão com o Habblaud.`)}if(!a.ok){try{let e=await a.json();if(typeof e.error==`string`)return e.error}catch{}return i(a.status)}}async loadAvatar(){if(this.mock||this.replay)return null;try{let e=await fetch(`/api/avatar`);return e.ok?await e.json():null}catch{return null}}async saveAvatar(e){return this.avatarRequest(`PUT`,e)}async resetAvatar(){return this.avatarRequest(`DELETE`,{})}async avatarRequest(t,n){return this.mock||this.replay?e(`Editar o personagem só funciona com o escritório ao vivo.`):this.writeRequest(`/api/avatar`,t,n,t=>e(`Não foi possível salvar o avatar (erro {0}).`,[t]))}get defaultLook(){return(this.liveSnapshot??this.snapshot)?.defaultLook??{parts:{},since:0}}async loadDefaultLook(){if(this.mock||this.replay)return null;try{let e=await fetch(`/api/settings/default-look`);return e.ok?await e.json():null}catch{return null}}async saveDefaultLook(t){return this.mock||this.replay?e(`Editar o personagem só funciona com o escritório ao vivo.`):this.writeRequest(`/api/settings/default-look`,`PUT`,t,t=>e(`Não foi possível salvar o estilo padrão (erro {0}).`,[t]))}async resetDefaultLook(){return this.mock||this.replay?e(`Editar o personagem só funciona com o escritório ao vivo.`):this.writeRequest(`/api/settings/default-look`,`DELETE`,{},t=>e(`Não foi possível salvar o estilo padrão (erro {0}).`,[t]))}async loadAttachmentSettings(){if(this.mock||this.replay)return null;try{let e=await fetch(`/api/settings/attachments`);if(!e.ok)return null;let t=(await e.json()).retentionDays;return t===null||typeof t==`number`?{retentionDays:t}:null}catch{return null}}async saveAttachmentSettings(t){return this.mock||this.replay?e(`Editar a limpeza dos anexos só funciona com o escritório ao vivo.`):this.writeRequest(`/api/settings/attachments`,`PUT`,t,t=>e(`Não foi possível salvar a limpeza dos anexos (erro {0}).`,[t]))}async loadMachines(){if(this.mock||this.replay)return null;try{let e=await fetch(`/api/central/machines`,{cache:`no-store`});if(!e.ok)return null;let t=(await e.json()).machines;return Array.isArray(t)?t:null}catch{return null}}async createPairing(){if(this.mock||this.replay)return{error:e(`Parear máquinas só funciona com o escritório ao vivo.`)};let t;try{t=await fetch(`/api/central/pairing`,{method:`POST`,headers:{"Content-Type":`application/json`},body:`{}`,cache:`no-store`})}catch{return{error:e(`Sem conexão com o Habblaud.`)}}try{let e=await t.json();if(t.ok&&typeof e.pairing==`string`&&typeof e.code==`string`&&typeof e.expiresAt==`number`&&typeof e.fingerprint==`string`)return{pairing:e.pairing,code:e.code,expiresAt:e.expiresAt,fingerprint:e.fingerprint};if(typeof e.error==`string`)return{error:e.error}}catch{}return{error:e(`Não foi possível gerar o código (erro {0}).`,[t.status])}}async revokeMachine(t){return this.mock||this.replay?e(`Revogar máquinas só funciona com o escritório ao vivo.`):this.writeRequest(`/api/central/machines/${encodeURIComponent(t)}/revoke`,`POST`,{},t=>e(`Não foi possível revogar a máquina (erro {0}).`,[t]))}async loadSatelliteLink(){if(this.mock||this.replay)return null;try{let e=await fetch(`/api/satellite/status`,{cache:`no-store`});if(!e.ok)return null;let t=await e.json();return(t.status===`up`||t.status===`down`||t.status===`revoked`||t.status===`unpaired`)&&typeof t.url==`string`&&typeof t.label==`string`?{status:t.status,url:t.url,label:t.label}:null}catch{return null}}async sendMessage(t,n,r=[]){if(this.mock){let e=this.mockSend(t,n);return`message`in e&&this.emit(`sent`,{agentId:t}),e}let i=r.length?{agentId:t,text:n,attachments:r}:{agentId:t,text:n},a=await fetch(`/api/messages`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(i)}),o;try{o=await a.json()}catch{}if(a.status===201&&o&&typeof o==`object`)return this.emit(`sent`,{agentId:t}),{message:o};let s=o?.error,c=typeof s==`string`?s:e(`erro {0}`,[a.status]);if(r.length>0&&a.status===410){let e=o?.expired,t=Array.isArray(e)?e.filter(e=>typeof e==`string`):[];return{error:c,expired:t.length?t:r}}return r.length>0&&a.status===500?{error:c,expired:r}:{error:c}}async uploadMessageImage(t){if(this.mock)return{error:e(`imagens só funcionam com o escritório ao vivo`)};let n=await s(t),r=await fetch(`/api/messages/attachments`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:t.name,type:t.type,data:n})}),i;try{i=await r.json()}catch{}let a=i;return r.ok&&typeof a?.id==`string`?{id:a.id}:{error:typeof a?.error==`string`?a.error:e(`erro {0}`,[r.status])}}async dropMessageImage(e){if(!this.mock)try{await fetch(`/api/messages/attachments/${encodeURIComponent(e)}`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:`{}`})}catch{}}async messageStatus(t){if(this.mock){let e=this.mockOutbox.get(t);return e?{...e}:null}let n=await fetch(`/api/messages/${encodeURIComponent(t)}`);if(n.status===404)return null;if(!n.ok)throw Error(e(`erro {0}`,[n.status]));return await n.json()}async slashCommands(e){if(this.mock)return h.map(e=>({...e}));try{let t=await fetch(`/api/messages/commands/${encodeURIComponent(e)}`);if(!t.ok)return[];let n=await t.json();return Array.isArray(n.commands)?n.commands:[]}catch{return[]}}mockOutbox=new Map;mockSeq=0;mockSend(t,n){let r=this.agent(t);if(!r)return{error:e(`agente desconhecido: ele já saiu do escritório?`)};if(!r.canMessage||r.kind!==`main`||r.status===`offline`)return{error:e(`este agente não recebe mensagens agora`)};let i=Date.now(),a={id:`mock-${i.toString(36)}-${++this.mockSeq}`,agentId:t,status:`queued`,createdAt:i,updatedAt:i};return this.mockOutbox.set(a.id,a),setTimeout(()=>{let r=this.mockSim,i=!!r?.receiveMessage(t,n);Object.assign(a,{status:i?`delivered`:`failed`,updatedAt:Date.now()},i?{}:{error:e(`o agente saiu do escritório`)}),i&&r&&this.applySnapshot(r.snapshot())},1e3),{message:{...a}}}emit(e,t){this.listeners.get(e)?.forEach(n=>{try{n(t)}catch(t){console.error(`[store] listener de "${e}" falhou`,t)}})}setConnection(e){this.connection!==e&&(this.connection=e,this.emit(`connection`,e))}applySnapshot(e){let t=this.replay?this.live?.snap:this.snapshot;t&&e.rev<t.rev&&e.meta.startedAt===t.meta.startedAt||(this.replay?this.live={snap:e,at:Date.now()}:this.setSnapshot(e),this.checkBuild(e.meta.build))}setSnapshot(e){this.snapshot=e,this.agentIndex=new Map(e.agents.map(e=>[e.id,e])),this.roomIndex=new Map(e.rooms.map(e=>[e.id,e])),this.emit(`snapshot`,e),this.emit(`defaultLook`,e.defaultLook??{parts:{},since:0})}updateAnnounced=!1;pageBuildId=c();checkBuild(e){if(this.updateAnnounced||this.mock||!e)return;let t=this.pageBuildId;t&&t!==e&&(this.updateAnnounced=!0,this.emit(`update`,{build:e,current:t}))}applyFeed(e){if(!e.length)return;let t=new Set(this.feed.map(e=>e.id)),n=e.filter(e=>!t.has(e.id));n.length&&(this.feed=[...this.feed,...n].slice(-200),this.emit(`feed`,n))}parse(e,t){try{return JSON.parse(e.data)}catch(e){return console.warn(`[store] ${t} inválido ignorado`,e),null}}startSSE(){typeof addEventListener==`function`&&addEventListener(`online`,this.onOnline),this.setConnection(`connecting`);let e;try{e=this.openStream(`/api/stream`)}catch(e){console.error(`[store] não foi possível abrir o stream`,e),this.setConnection(`closed`),this.scheduleRetry();return}this.source=e;let t=()=>this.source===e;e.addEventListener(`open`,()=>{t()&&(this.attempts=0,this.clearRetry(),this.setConnection(`open`))}),e.addEventListener(`error`,()=>{t()&&(e.readyState===u?(this.setConnection(`closed`),this.scheduleRetry()):this.setConnection(`connecting`))}),e.addEventListener(`snapshot`,e=>{if(!t())return;let n=this.parse(e,`snapshot`);n&&this.applySnapshot(n)}),e.addEventListener(`feed`,e=>{if(!t())return;let n=this.parse(e,`feed`);n&&this.applyFeed(n)}),e.addEventListener(`notice`,e=>{if(!t())return;let n=this.parse(e,`aviso`);n&&this.emit(`notice`,n)}),e.addEventListener(`attention`,e=>{if(!t())return;let n=this.parse(e,`attention`);n&&this.emit(`attention`,n)}),e.addEventListener(`presence`,e=>{if(!t())return;let n=this.parse(e,`presence`);n&&this.emit(`presence`,n)}),e.addEventListener(`avatar`,e=>{if(!t())return;let n=this.parse(e,`avatar`);n&&this.emit(`avatar`,n)}),e.addEventListener(`defaultLook`,e=>{if(!t())return;let n=this.parse(e,`defaultLook`);n&&this.emit(`defaultLook`,n)})}closeSource(){this.source?.close(),this.source=null}scheduleRetry(){if(this.retryTimer||this.mock||this.stopped)return;let e=p(this.attempts);this.attempts++,this.retryAt=Date.now()+e,this.retryTimer=setTimeout(()=>{this.retryTimer=null,this.retryAt=null,!this.stopped&&this.connection===`closed`&&(this.closeSource(),this.startSSE())},e)}clearRetry(){this.retryTimer&&clearTimeout(this.retryTimer),this.retryTimer=null,this.retryAt=null}mockSim=null;startMock(){if(this.mockTimer)return;this.setConnection(`mock`);let e=new n({...m(this.search),crowd:!0});this.mockSim=e,this.applySnapshot(e.snapshot()),this.mockTimer=setInterval(()=>{let t=Date.now(),n=e.tick(t);n.changed&&this.applySnapshot(e.snapshot(t)),this.applyFeed(n.feed),n.notices.forEach(e=>this.emit(`notice`,e))},250)}},g=[`short`,`buzz`,`spiky`,`side_part`,`curly`,`afro`,`bob`,`long`,`ponytail`,`bun`,`pigtails`,`mohawk`,`bald`,`wavy`],_=[`tshirt`,`hoodie`,`shirt_tie`,`sweater`,`jacket`,`blouse`,`polo`],v=[`none`,`glasses`,`sunglasses`,`headphones`,`cap`,`beanie`,`earrings`,`bow`],y=[`none`,`stubble`,`beard`,`mustache`,`goatee`],b=[`pants`,`shorts`,`skirt`],x=[`skin`,`hair`,`hairStyle`,`eyes`,`top`,`topAccent`,`topStyle`,`bottom`,`bottomStyle`,`shoes`,`accessory`,`accessoryColor`,`facialHair`],te={hairStyle:g,topStyle:_,bottomStyle:b,accessory:v,facialHair:y},ne=/^#[0-9a-f]{6}$/i,S=/[\p{Cc}\u2028\u2029\u200e\u200f\u202a-\u202e\u2066-\u2069]/u;function C(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e;for(let e of Object.keys(t))if(!x.includes(e))return null;let n={};for(let e of x){let r=t[e];if(r===void 0)continue;if(typeof r!=`string`)return null;let i=te[e];if(i?!i.includes(r):!ne.test(r))return null;n[e]=i?r:r.toLowerCase()}return n}function re(e){if(typeof e!=`string`)return null;let t=e.normalize(`NFC`).replace(/\s+/g,` `).trim();return!t||S.test(t)||[...t].length>24?null:t}function ie(e){return e?x.map(t=>e[t]??``).join(`,`):``}function ae(e,t){return e.custom||!t||typeof t.since!=`number`?!1:e.startedAt>=t.since}function oe(e,t){if(typeof e.startedAt!=`number`||!t||!ae({custom:e.custom,startedAt:e.startedAt},t))return e.parts;let n={};for(let r of x){let i=e.parts?.[r]??t.parts?.[r];i!==void 0&&(n[r]=i)}return Object.keys(n).length?n:void 0}var se=[`#ffe2cc`,`#f6cfb0`,`#eab894`,`#d69f78`,`#bd8560`,`#9a6444`,`#7a4a31`,`#5a3623`],ce=[[`#2b2530`,5],[`#3f2c22`,5],[`#5f3c28`,4],[`#87593a`,2.5],[`#b0703c`,1.2],[`#8e3b2b`,1],[`#d6ae68`,1.8],[`#ebdcb0`,.7],[`#8f929b`,.7],[`#d9dbe0`,.5]],le=[`#e47aa8`,`#5b8fe0`,`#8f6ad8`,`#3fb3a0`,`#e0584e`,`#7cc45a`,`#f0a24a`],ue=[`#2b2236`,`#2b2236`,`#4a2f22`,`#5a3b22`,`#2f5f9e`,`#3c7a52`],w=[`#e2604f`,`#4a86d8`,`#4bab72`,`#efb54a`,`#8d66cf`,`#36b0b0`,`#e47aa8`,`#3d4352`,`#f1efe9`,`#8a96a3`,`#2f4c7d`,`#c9713f`,`#76913f`,`#e3d3b2`,`#f29b72`,`#5bc0de`,`#b04a5a`,`#f2d16b`],T=[`#f4f4f0`,`#d3e3f4`,`#f3d6de`,`#dfe3e8`,`#e9f1dc`,`#fbf0d6`],de=[`#c0392b`,`#2f4c7d`,`#7b2d44`,`#2e7d4f`,`#d9a42e`,`#5b3a8c`,`#3d4352`],fe=[`#2f3b55`,`#3d4352`,`#6b4a35`,`#55613b`,`#262a33`,`#b08a5e`,`#7a2f3a`,`#4a6a8a`],E=[`#f4f4f0`,`#e8e3d6`,`#dfe7ef`,`#f6e7c8`,`#c9ced6`],pe=[[`#3f5f8c`,5],[`#2e3e5e`,4],[`#2c2c35`,4],[`#b49c72`,2],[`#6d7480`,2],[`#6e4c38`,1.5],[`#5f6845`,1.2],[`#2c3655`,2],[`#7f9cc4`,1.5],[`#e2ded5`,.5],[`#9b3b3b`,.4]],me=[[`#2b2b33`,5],[`#6b4630`,3],[`#ececec`,3],[`#d04848`,1],[`#3f63a8`,1],[`#b88752`,1.5],[`#7d8592`,1]],he={none:[`#2b2b33`],glasses:[`#2b2b33`,`#5a3a28`,`#3f63a8`,`#b03a3a`,`#8a8f99`],sunglasses:[`#22232b`],headphones:[`#2b2b33`,`#f1efe9`,`#e2604f`,`#4a86d8`,`#efb54a`,`#36b0b0`],cap:[`#e2604f`,`#4a86d8`,`#2b2b33`,`#4bab72`,`#efb54a`,`#f1efe9`,`#2f4c7d`],beanie:[`#e2604f`,`#efb54a`,`#4bab72`,`#8d66cf`,`#3d4352`,`#36b0b0`],earrings:[`#f2c14e`,`#d9dde3`],bow:[`#e2604f`,`#e47aa8`,`#efb54a`,`#4a86d8`,`#8d66cf`]},D=[`#f2b33d`,`#e2604f`,`#4a86d8`,`#4bab72`,`#8d66cf`,`#36b0b0`],ge={m:{short:16,buzz:9,spiky:9,side_part:12,curly:9,afro:6,bob:2,long:4,ponytail:3,bun:4,pigtails:.4,mohawk:4,bald:5,wavy:9},f:{short:4,buzz:1.2,spiky:2,side_part:4,curly:9,afro:7,bob:13,long:16,ponytail:13,bun:10,pigtails:6,mohawk:1,bald:.4,wavy:13}},_e={m:{tshirt:20,hoodie:16,shirt_tie:10,sweater:13,jacket:13,blouse:2,polo:14},f:{tshirt:17,hoodie:14,shirt_tie:5,sweater:14,jacket:12,blouse:20,polo:8}},ve={m:{none:40,glasses:18,sunglasses:4,headphones:13,cap:7,beanie:6,earrings:2,bow:.3},f:{none:36,glasses:16,sunglasses:4,headphones:11,cap:4,beanie:5,earrings:13,bow:7}},ye={none:62,stubble:12,beard:13,mustache:7,goatee:6},be={m:{pants:88,shorts:12,skirt:0},f:{pants:62,shorts:10,skirt:28}};function xe(e){let t=(e^2654435769)>>>0;return t=Math.imul(t^t>>>16,2246822507),t=Math.imul(t^t>>>13,3266489909),(t^t>>>16)>>>0}function O(e,n={}){let r=t(xe(e)),i=e=>e[Math.floor(r()*e.length)%e.length],a=e=>{let t=Object.entries(e),n=t.reduce((e,[,t])=>e+t,0),i=r()*n;for(let[e,n]of t)if(i-=n,i<0)return e;return t[t.length-1][0]},o=e=>a(Object.fromEntries(e)),s=r(),c=n.look??(s<.5?`f`:`m`),l=i(se),u=r()<.08?i(le):o(ce),d=a(ge[c]),f=i(ue),p=a(_e[c]),m,h;switch(p){case`shirt_tie`:m=i(T),h=i(de);break;case`jacket`:m=i(fe),h=r()<.7?i(E):i(w);break;case`hoodie`:case`polo`:m=i(w),h=r()<.6?i(E):i(w);break;default:m=i(w),h=i(w)}h===m&&(h=i(E));let ee=o(pe),g=o(me),_=a(ve[c]);(_===`cap`||_===`beanie`)&&(d===`afro`||d===`bun`||d===`mohawk`||d===`pigtails`)&&(_=`glasses`),_===`bow`&&(d===`bald`||d===`buzz`)&&(_=`earrings`);let v=i(he[_]),y=r(),b=a(ye),te=c===`m`?b:`none`,ne=a(be[c]);c===`f`&&d===`bald`&&(d=`buzz`);let S={skin:l,hair:u,hairStyle:d,eyes:f,top:m,topAccent:h,topStyle:p,bottom:ee,shoes:g,accessory:_,accessoryColor:v,lanyard:n.sub?D[Math.floor(y*D.length)%D.length]:null,look:c,facialHair:te,bottomStyle:ne},C=n.parts;if(!C)return S;let re=Object.fromEntries(x.filter(e=>C[e]!==void 0).map(e=>[e,C[e]]));return{...S,...re}}function Se(e,t,n){let r=O(e,{look:n,parts:t}),i={};for(let e of x){let t=r[e];t!==void 0&&(i[e]=t)}return i}function Ce(e){return[e.skin,e.hair,e.hairStyle,e.eyes,e.top,e.topAccent,e.topStyle,e.bottom,e.shoes,e.accessory,e.accessoryColor,e.lanyard??`-`,e.look,e.facialHair??`-`,e.bottomStyle??`-`].join(`|`)}var we=e=>[...new Set(e)],k=e=>e.map(([e])=>e),A=we([...E,...w]);function Te(e){switch(e){case`shirt_tie`:return{top:T,topAccent:de};case`jacket`:return{top:fe,topAccent:A};default:return{top:w,topAccent:A}}}function Ee(e){let t=Te(e.topStyle);return{skin:se,hair:[...k(ce),...le],hairStyle:g,eyes:we(ue),top:t.top,topAccent:t.topAccent,topStyle:_,bottom:k(pe),bottomStyle:b,shoes:k(me),accessory:v,accessoryColor:he[e.accessory],facialHair:y}}var De=[`afro`,`bun`,`mohawk`,`pigtails`],Oe=[`bald`,`buzz`];function ke(t,n,r){if(n===`accessory`&&((r===`cap`||r===`beanie`)&&De.includes(t.hairStyle)||r===`bow`&&Oe.includes(t.hairStyle)))return e(`Não combina com este cabelo`);if(n===`hairStyle`){if((t.accessory===`cap`||t.accessory===`beanie`)&&De.includes(r))return e(`Não combina com o boné ou o gorro`);if(t.accessory===`bow`&&Oe.includes(r))return e(`Não combina com o laço`)}}function Ae(e){let t=Ee(e),n=(e,t)=>t.includes(e)?e:t[0];return{...e,top:n(e.top,t.top),topAccent:n(e.topAccent,t.topAccent),accessoryColor:n(e.accessoryColor,t.accessoryColor)}}function je(e,t){if(e&&e!==`auto`)return e;let n=t.getMonth();return n===9?`halloween`:n===10||n===11&&t.getDate()<=26?`christmas`:`none`}var Me={showNames:!0,bubbles:`important`,liveliness:`normal`,followSelected:!1,dayNight:!0,theme:`auto`},Ne=[`competicao`,`apostas`,`games`,`series`,`fofoca`,`vaidade`,`cafeina`,`piadas`,`esporte`,`timidez`,`economia`,`sonecas`,`calma`,`leitura`],Pe=[[`timidez`,`piadas`],[`timidez`,`fofoca`],[`apostas`,`economia`],[`esporte`,`sonecas`],[`calma`,`competicao`]],j={min:2,max:3},Fe=[`night_owl`,`early_bird`,`coffee`,`tea`,`tabs`,`spaces`,`dark_mode`,`light_mode`,`vim`,`tests_first`,`ship_fast`,`refactor`,`pixel_art`,`music`,`silence`,`cats`,`dogs`,`open_source`,`learning`,`hello`],Ie=[`hello`,`nice_building`,`coffee`,`congrats`,`nice_to_meet`,`bye`,`thanks`,`good_luck`,`wave`,`clap`],Le=[`offensive_name`,`impersonation`,`harassment`,`greeting_spam`,`fake_building`,`other`],Re=[`visited`,`nice_building`,`keep_going`,`coffee`,`wave`,`star`,`heart`,`rocket`],ze=[`agent_hours_10k`,`agent_hours_50k`,`agent_hours_100k`],Be=[`deploy`,`other-device`,`banned`,`suspended`,`waiting`,`update`,`unauthorized`,`no_player`,`deleted`],Ve=[`schema`,`limits`,`name_pool`,`parts`,`ids`,`rate`,`internal`,`left`,`implausible`],He={floors:64,agentsPerFloor:64,agentsTotal:256,bytes:65536},M={min:3,max:20},Ue=[`habblaud`,`admin`,`staff`,`claude`,`anthropic`,`codex`,`openai`,`moderador`,`moderator`,`suporte`,`support`,`system`,`world`],We=`invalid.invalid_code.invalid_credentials.email_not_verified.banned.suspended.unauthorized.name_taken.name_invalid.name_blocked.name_cooldown.password_invalid.password_weak.password_pwned.altcha_required.altcha_invalid.device_limit.rate_limited.not_found.no_player.unavailable.maintenance.invalid_json.too_large.unsupported_media_type.method_not_allowed.internal`.split(`.`),Ge={competicao:{id:`competicao`,emoji:`🏆`,label:e(`Competição`),desc:e(`Adora competir: desafia os colegas no ping-pong, no videogame e no jokenpô.`)},apostas:{id:`apostas`,emoji:`🎲`,label:e(`Apostas`),desc:e(`Topa qualquer aposta e aposta alto no jokenpô.`)},games:{id:`games`,emoji:`🎮`,label:e(`Games`),desc:e(`Vive no videogame do lounge e nos fliperamas — e costuma ganhar.`)},series:{id:`series`,emoji:`📺`,label:e(`Séries e TV`),desc:e(`Não perde um programa na TV do lounge (de preferência com pipoca).`)},fofoca:{id:`fofoca`,emoji:`🗣️`,label:e(`Fofoca`),desc:e(`Puxa papo na copa e sabe de tudo o que acontece nas salas.`)},vaidade:{id:`vaidade`,emoji:`💄`,label:e(`Vaidade`),desc:e(`Passa no espelho do banheiro para se arrumar sempre que pode.`)},cafeina:{id:`cafeina`,emoji:`☕`,label:e(`Cafeína`),desc:e(`Movido a café: a cafeteira da copa é a segunda casa.`)},piadas:{id:`piadas`,emoji:`😂`,label:e(`Piadas`),desc:e(`Conta piada em toda conversa e faz a roda rir.`)},esporte:{id:`esporte`,emoji:`🏓`,label:e(`Esporte`),desc:e(`Joga ping-pong, se alonga e vibra com o futebol na TV.`)},timidez:{id:`timidez`,emoji:`🙈`,label:e(`Timidez`),desc:e(`Prefere ficar na sua: lê, olha a janela e entra menos nas rodas.`)},economia:{id:`economia`,emoji:`💰`,label:e(`Economia`),desc:e(`Pão-duro: aposta pouco e às vezes foge da aposta.`)},sonecas:{id:`sonecas`,emoji:`😴`,label:e(`Sonecas`),desc:e(`Qualquer sofá ou puff vira cama.`)},calma:{id:`calma`,emoji:`🧘`,label:e(`Calma`),desc:e(`Zen: alongamentos, janela e conversas tranquilas.`)},leitura:{id:`leitura`,emoji:`📚`,label:e(`Leitura`),desc:e(`Sempre com um livro da estante (ou o celular) na mão.`)}};function Ke(e){return typeof e==`string`&&Ne.includes(e)}function N(e,t){return Pe.some(([n,r])=>n===e&&r===t||n===t&&r===e)}function qe(e){if(!Array.isArray(e)||e.length<j.min||e.length>j.max)return null;let t=[];for(let n of e){if(!Ke(n)||t.includes(n)||t.some(e=>N(e,n)))return null;t.push(n)}return t}var Je=[`auto`,`none`,`halloween`,`christmas`];function Ye(e){return typeof e==`string`&&Je.includes(e)}var Xe={cmdsPerBatch:20,batchesPerSec:5,streams:4},Ze=[`area`,`area.patch`,`players`,`player.join`,`player.leave`,`pos`,`minimap`,`afk`,`profile`,`notice`,`like.update`,`greeting`,`building`,`building.patch`,`visitors`,`city`,`city.fireworks`,`likes.today`,`away.summary`,`knock`],Qe=[`not_configured`,`local_only`,`terminal_off`,`not_logged_in`,`session_expired`,`invalid_email`,`altcha_failed`,`world_unreachable`,`world_timeout`,`world_bad_response`,`world_error`,`storage_failed`,`too_many_streams`,`no_stream`,`not_connected`,`account_deleted`,`network`,`unknown`],$e=[...new Set([...We,...Qe])];function et(e){return typeof e==`string`&&$e.includes(e)}var tt=3,nt=/[\p{C}\p{Zl}\p{Zp}\p{Default_Ignorable_Code_Point}\p{Bidi_Control}]/u,rt=/(?! )[\p{Zs}\s]/u,it=/^\p{L}$/u,at=/^\p{M}$/u,ot=/^[0-9 _.-]$/,st=`Latin.Greek.Cyrillic.Armenian.Hebrew.Arabic.Syriac.Thaana.Devanagari.Bengali.Gurmukhi.Gujarati.Oriya.Tamil.Telugu.Kannada.Malayalam.Sinhala.Thai.Lao.Tibetan.Myanmar.Georgian.Hangul.Ethiopic.Khmer.Mongolian.Hiragana.Katakana.Bopomofo.Han`.split(`.`),ct=st.map(e=>[e,RegExp(`^\\p{Script_Extensions=${e}}$`,`u`)]),lt=`Other`,ut=[...st.map(e=>[e]),[`Han`,`Hiragana`,`Katakana`],[`Hangul`,`Han`],[`Han`,`Bopomofo`],[lt]];function dt(e){let t=ct.filter(([,t])=>t.test(e)).map(([e])=>e);return t.length?t:[lt]}function ft(e){let t=[...new Set(e)].map(dt);return ut.some(e=>t.every(t=>t.some(t=>e.includes(t))))}function pt(e){return e.normalize(`NFC`).trim().replace(/ {2,}/g,` `)}function mt(e){return e.normalize(`NFKC`).toLowerCase().normalize(`NFD`).replace(/[\p{Mn}\p{Me}]/gu,``).normalize(`NFC`).replace(/\s+/g,` `).trim()}function ht(e){return e.replace(/[ _.-]/g,``)}var P=e=>({ok:!1,code:`name_invalid`,problem:e});function gt(e){if(typeof e!=`string`)return P(`type`);if(e.length>M.max*8)return P(`length`);let t=pt(e);if(nt.test(t)||rt.test(t))return P(`invisible`);let n=[...t];if(n.length<M.min||n.length>M.max)return P(`length`);let r=[],i=0,a=!1;for(let e of n)if(it.test(e))r.push(e),i=0,a=!0;else if(at.test(e)){if(!a||++i>tt)return P(`chars`)}else if(ot.test(e))i=0,a=!1;else return P(`chars`);if(!r.length)return P(`no_letter`);if(!ft(r))return P(`scripts`);let o=mt(t);return Ue.includes(ht(o))?{ok:!1,code:`name_blocked`,problem:`reserved`}:{ok:!0,name:t,key:o}}var F={w:14,h:12},I={w:3,h:2},L={w:F.w*I.w,h:F.h*I.h},R={x:L.w+4+5,y:L.h+4+5},_t={w:2,h:2},z={x:0,y:0},B={x:19,y:10,w:4,h:3},V={x:21,y:15},H={dx:6,w:2},U=(e,t)=>Math.floor(e/t);function*vt(){let e=0,t=0;yield{x:e,y:t};let n=[[1,0],[0,1],[-1,0],[0,-1]];for(let r=1,i=0;;r++)for(let a=0;a<2;a++,i++){let a=n[i%4]??n[0];for(let n=0;n<r;n++)e+=a[0],t+=a[1],yield{x:e,y:t}}}function W(e){return e.x===z.x&&e.y===z.y}function*yt(){for(let e of vt())if(!W(e))for(let t=0;t<I.h;t++)for(let n=0;n<I.w;n++)yield{x:e.x*I.w+n,y:e.y*I.h+t}}function G(e){return{x:U(e.x,I.w),y:U(e.y,I.h)}}function bt(e){return{x:e.x*R.x,y:e.y*R.y}}function xt(e){let t=G(e),n=bt(t);return{x:n.x+F.w*(e.x-I.w*t.x),y:n.y+F.h*(e.y-I.h*t.y)}}function St(e){let t=xt(e),n=e.y-I.h*G(e).y===0,r=n?t.y:t.y+F.h-1;return{side:n?`n`:`s`,tiles:[{x:t.x+H.dx,y:r},{x:t.x+H.dx+1,y:r}],front:{x:t.x+H.dx+H.w/2,y:n?t.y-1:t.y+F.h}}}function Ct(e,t){let n=(R.x-L.w)/2,r=(R.y-L.h)/2;return{x:U(e+n,R.x),y:U(t+r,R.y)}}function wt(e){return{x:U(e.x,_t.w),y:U(e.y,_t.h)}}function Tt(e,t){return`${e}:${t.x},${t.y}`}function Et(e){let t=/^([a-z0-9_-]{1,32}):(-?\d{1,6}),(-?\d{1,6})$/.exec(e);return t?{district:t[1]??``,chunk:{x:Number(t[2]),y:Number(t[3])}}:null}function Dt(e,t=1){let n=[];for(let r=-t;r<=t;r++)for(let i=-t;i<=t;i++)n.push({x:e.x+i,y:e.y+r});return n}function Ot(e,t,n){if(!Number.isFinite(e)||!Number.isFinite(t))return!1;let r=Math.floor(e),i=Math.floor(t),a=U(r,R.x),o=U(i,R.y),s=r-a*R.x,c=i-o*R.y;return s>=L.w||c>=L.h?!0:W({x:a,y:o})?!(s>=B.x&&s<B.x+B.w&&c>=B.y&&c<B.y+B.h):!1}function kt(){return{x:V.x,y:V.y}}var K=e=>!!e&&typeof e==`object`&&!Array.isArray(e),q=e=>typeof e==`number`&&Number.isFinite(e),J=e=>q(e)&&Number.isInteger(e)&&e>=0&&e<=1e9;function At(e){if(!K(e)||!J(e.lit))return;let t={lit:e.lit},n=e.goal;return K(n)&&typeof n.id==`string`&&n.id.length<=64&&ze.includes(n.label)&&q(n.target)&&n.target>0&&q(n.progress)&&n.progress>=0&&q(n.until)&&(t.goal={id:n.id,label:n.label,target:n.target,progress:n.progress,until:n.until}),q(e.tokensBand)&&Number.isInteger(e.tokensBand)&&e.tokensBand>=0&&e.tokensBand<=5&&(t.tokensBand=e.tokensBand),t}function jt(e){if(!K(e)||typeof e.since!=`string`||!/^\d{4}-\d{2}-\d{2}$/.test(e.since)||!J(e.visits)||!J(e.likes))return;let t=[];for(let n of Array.isArray(e.stamps)?e.stamps:[])K(n)&&Re.includes(n.stampId)&&J(n.count)&&n.count!==0&&(t.some(e=>e.stampId===n.stampId)||t.push({stampId:n.stampId,count:n.count}));return{since:e.since,visits:e.visits,likes:e.likes,stamps:t}}function Mt(e){return!!e&&(e.visits>0||e.likes>0||e.stamps.some(e=>e.count>0))}function Nt(e){let t=-1;return e.forEach((e,n)=>{e.t===`move`&&(t=n)}),e.filter((e,n)=>e.t!==`move`||n===t)}var Pt={night_owl:()=>e(`Codo de madrugada`),early_bird:()=>e(`Acordo cedo para codar`),coffee:()=>e(`Movido a café`),tea:()=>e(`Time do chá`),tabs:()=>e(`Time dos tabs`),spaces:()=>e(`Time dos espaços`),dark_mode:()=>e(`Modo escuro sempre`),light_mode:()=>e(`Modo claro, sem medo`),vim:()=>e(`Vim até o fim`),tests_first:()=>e(`Testo antes de escrever`),ship_fast:()=>e(`Entrego rápido`),refactor:()=>e(`Refatorar é meu hobby`),pixel_art:()=>e(`Fã de pixel art`),music:()=>e(`Codo ouvindo música`),silence:()=>e(`Codo em silêncio`),cats:()=>e(`Gente de gato`),dogs:()=>e(`Gente de cachorro`),open_source:()=>e(`Vivo de código aberto`),learning:()=>e(`Sempre aprendendo`),hello:()=>e(`Oi, prazer!`)};function Ft(e){return typeof e==`string`&&Fe.includes(e)}function It(e){return Pt[e]?.()??String(e)}function Y(e,t){return!e?.enabled||!e.configured||e.state===`off`||t.remote?`hidden`:!t.fake&&(!t.local||!t.terminal)?`local_only`:`active`}function Lt(e){return!!e&&(e.scene!==void 0||e.building!==void 0)}var Rt=`habblaud:world-invite-seen`,zt=`habblaud:world-launch`,Bt=`habblaud:world-waitlist-seen`,Vt=`habblaud:world-approved-seen`,Ht={launch:null,waitlistSeen:!1,approvedSeen:!1};function Ut(e){let t=null;if(e.launch===`never`||e.legacy===`never`)t=`never`;else if(e.launch)try{let n=JSON.parse(e.launch);n&&typeof n==`object`&&typeof n.shown==`number`&&typeof n.last==`number`&&Number.isFinite(n.shown)&&Number.isFinite(n.last)&&(t={shown:Math.max(0,Math.floor(n.shown)),last:Math.max(0,n.last)})}catch{}return{launch:t,waitlistSeen:e.waitlist!==null,approvedSeen:e.approved!==null}}function Wt(e){return{launch:e.launch===`never`?`never`:e.launch?JSON.stringify(e.launch):null,waitlist:e.waitlistSeen?`1`:null,approved:e.approvedSeen?`1`:null}}function Gt(e,t,n,r){if(t.fake||t.replaying||Y(e,t)!==`active`||!e)return{show:null,memory:null};if(e.state===`logged_out`){let e=n.launch;return e===`never`||e&&(e.shown>=3||r-e.last<2592e5)?{show:null,memory:null}:{show:`launch`,memory:{...n,launch:{shown:(e?.shown??0)+1,last:r}}}}let i=n.launch===`never`?n:{...n,launch:`never`},a=i!==n;return e.state===`waiting`&&!n.waitlistSeen?{show:`waitlist`,memory:{...i,waitlistSeen:!0}}:e.state===`approved`&&!n.approvedSeen&&!Lt(e)?{show:`approved`,memory:{...i,approvedSeen:!0}}:{show:null,memory:a?i:null}}var Kt=[`welcome`,`register`,`login`,`verify`,`forgot`,`reset`],qt=[`home`,`character`,`visibility`,`devices`,`account`,`blocked`];function Jt(e){return e===`waiting`||e===`approved`?qt:e===`logged_out`?Kt:[]}function Yt(){return{server:null,screen:`welcome`,email:``,name:``,flash:null}}function X(e){if(!e.server)return e;let t=Jt(e.server);return!t.length||t.includes(e.screen)?e:{...e,screen:t[0]}}function Xt(e,t){switch(t.type){case`server`:return X({...e,server:t.state});case`go`:return X({...e,screen:t.screen,flash:null});case`code_sent`:return X({...e,screen:`verify`,email:t.email,name:t.name??e.name,flash:`code_sent`});case`reset_code_sent`:return X({...e,screen:`reset`,email:t.email,flash:`code_sent`});case`password_changed`:return X({...e,screen:`login`,flash:`password_changed`});case`signed_in`:return{...e,flash:null};case`flash`:return{...e,flash:t.flash}}}function Z(e){return e.normalize(`NFC`).trim()}function Zt(e){let t=Z(e);return t.length<=254&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)}function Qt(e){return e.replace(/\D/g,``).slice(0,6)}function $t(e){return/^\d{6}$/.test(Qt(e))}function en(e,t=``){let n=e.normalize(`NFC`),r=[...n].length;if(r<12)return`short`;if(r>128)return`long`;let i=Z(t).toLowerCase(),a=n.toLowerCase();return i&&(a===i||a===i.split(`@`)[0])?`email`:/^(.+?)\1+$/su.test(n)?`repeated`:null}function tn(t){switch(t){case`short`:return e(`A senha precisa ter pelo menos 12 caracteres.`);case`long`:return e(`A senha pode ter no máximo 128 caracteres.`);case`email`:return e(`A senha não pode ser o seu e-mail.`);case`repeated`:return e(`A senha não pode ser só uma repetição (como "aaaaaaaaaaaa").`)}}function nn(t){switch(t){case`type`:case`length`:return e(`O nome precisa ter de 3 a 20 caracteres.`);case`invisible`:return e(`Tire do nome os caracteres invisíveis e os espaços especiais.`);case`chars`:return e(`Use só letras, números, espaço, _ - e . no nome.`);case`scripts`:return e(`Use letras de um só alfabeto no nome.`);case`no_letter`:return e(`O nome precisa ter pelo menos uma letra.`);case`reserved`:return e(`Este nome é reservado. Escolha outro.`)}}function rn(e,t){if(e.includes(t))return null;let n=e.find(e=>N(e,t));return n?{reason:`clash`,with:n}:e.length>=j.max?{reason:`full`}:null}function an(e,t){return e.includes(t)?e.filter(e=>e!==t):rn(e,t)?[...e]:[...e,t]}function on(e){return qe(e)!==null}var sn=24301;function cn(e){let t={};for(let n of x)t[n]=n===`facialHair`?e.facialHair??`none`:n===`bottomStyle`?e.bottomStyle??`pants`:e[n];return t}function ln(e,t,n=sn){return O(n,{look:e,parts:t})}function un(e){let t=gt(e.name);return t.ok?on(e.traits)?!e.intro||!Ft(e.intro)?{field:`intro`}:null:{field:`traits`}:{field:`name`,problem:t.problem}}var dn={mode:`live`,closed:!1,hideCountry:!1,tokensVisible:!0,leaderboard:!1,compactions:!1,knocks:!1},fn=[`closed`,`hideCountry`,`tokensVisible`,`leaderboard`,`compactions`,`knocks`];function pn(e){return e?.notifyInactivity!==!1}var mn=`habblaud-world-dados.json`,Q=`privacidade@habblaud.com`,hn=`Recurso Habblaud World`;function gn(e){let t=e&&/^[A-Za-z0-9_-]{1,64}$/.test(e)?e:``;return`mailto:${Q}?subject=${encodeURIComponent(t?`${hn} ${t}`:hn)}`}function _n(t,n){switch(et(t)||t===`offline`||t===`forbidden`?t:`unknown`){case`invalid_code`:return e(`Código errado ou vencido. Confira o e-mail ou peça outro código.`);case`invalid_credentials`:return e(`E-mail ou senha não conferem.`);case`email_not_verified`:return e(`Falta confirmar o e-mail: mandamos um código novo.`);case`banned`:return e(`Esta conta foi banida do Habblaud World. Para recorrer, responda ao e-mail do banimento.`);case`suspended`:return e(`Esta conta está suspensa no Habblaud World por enquanto.`);case`unauthorized`:case`not_logged_in`:case`session_expired`:return e(`A sessão do Habblaud World neste computador terminou. Entre de novo.`);case`name_taken`:return e(`Este nome já está em uso no mundo. Escolha outro.`);case`name_invalid`:return e(`Nome inválido: de 3 a 20 caracteres, com letras de um só alfabeto, números, espaço, _ - e .`);case`name_blocked`:return e(`Este nome não é permitido. Escolha outro.`);case`name_cooldown`:return e(`O nome só pode ser trocado uma vez a cada 30 dias.`);case`password_invalid`:return e(`A senha precisa ter de 12 a 128 caracteres.`);case`password_weak`:return e(`Senha fraca: não use o e-mail, o nome de jogador nem só repetição.`);case`password_pwned`:return e(`Esta senha aparece em vazamentos de dados conhecidos. Escolha outra.`);case`invalid_email`:return e(`E-mail inválido. Confira o endereço.`);case`altcha_required`:case`altcha_invalid`:case`altcha_failed`:return e(`A verificação anti-robô não passou. Tente de novo em instantes.`);case`device_limit`:return e(`Esta conta já tem 3 computadores; revogue um em Dispositivos.`);case`no_player`:return e(`Crie o personagem primeiro.`);case`unavailable`:return e(`O Habblaud World está em manutenção. Tente de novo mais tarde.`);case`maintenance`:return e(`O mundo está em manutenção; tentamos de novo em instantes.`);case`not_found`:return e(n===`revoke`?`Este dispositivo não está mais na conta.`:`O servidor do Habblaud World não encontrou o que foi pedido.`);case`invalid_json`:case`too_large`:case`unsupported_media_type`:case`method_not_allowed`:return e(`O pedido saiu num formato que o servidor não aceita. Atualize o Habblaud e tente de novo.`);case`not_configured`:return e(`O Habblaud World não está ligado neste Habblaud (HABBLAUD_WORLD_URL recusada; veja o log do servidor).`);case`rate_limited`:return e(n===`export`?`Dá para baixar os dados uma vez por dia. Tente de novo amanhã.`:`Muitas tentativas seguidas. Espere alguns minutos e tente de novo.`);case`network`:case`world_unreachable`:case`world_timeout`:return e(`O servidor do Habblaud World não respondeu. Tente de novo em instantes.`);case`world_bad_response`:return e(`O servidor do Habblaud World respondeu algo inesperado. Tente de novo em instantes.`);case`account_deleted`:return e(`A conta do Habblaud World foi excluída. O prédio e o perfil saíram do mundo na hora; o resto é apagado do banco em 7 dias e dos backups em até 30.`);case`storage_failed`:return e(`Não deu para gravar a sessão neste computador: ela vale só até o Habblaud reiniciar.`);case`too_many_streams`:return e(`A cidade já está aberta em outras abas do Habblaud. Feche uma delas para abrir aqui.`);case`no_stream`:return e(`A cena Mundo perdeu a conexão com o Habblaud. Abra a cidade de novo.`);case`not_connected`:return e(n===`unblock`?`Sem conexão com o Habblaud World agora: desbloquear precisa do prédio aceso ou da cidade aberta.`:`Sem conexão com o Habblaud World agora; o Habblaud tenta de novo sozinho.`);case`offline`:return e(`Sem conexão com o Habblaud.`);case`forbidden`:case`local_only`:return e(`A conta do World só pode ser mexida pelo próprio computador, com o Habblaud aberto em localhost.`);case`terminal_off`:return e(`A conta do World só pode ser mexida com o Habblaud acessível apenas pelo próprio computador (acesso local, bind 127.0.0.1).`);case`invalid`:switch(n){case`register`:case`reset`:return e(`O servidor recusou o e-mail ou a senha. A senha precisa ter de 12 a 128 caracteres e não pode estar numa lista de senhas vazadas.`);case`character`:return e(`O servidor recusou o personagem. Confira o nome, os traços (2 ou 3) e a frase de apresentação.`);case`visibility`:case`inactivity`:return e(`O servidor recusou as opções de visibilidade.`);default:return e(`O servidor recusou o pedido. Confira os dados e tente de novo.`)}case`internal`:return e(`O servidor do mundo teve um erro; tente de novo.`);case`world_error`:case`unknown`:return e(`Algo deu errado. Tente de novo em instantes.`)}}function vn(e,t){return t?e?.left?`left`:e?.paused?`paused`:e?.stopped?`stopped`:e?.connected?`connected`:`reconnecting`:`no_player`}function yn(t){switch(t){case`update`:return{label:e(`Atualize o Habblaud`),desc:e(`Esta versão do Habblaud não entra mais no mundo. Atualize para o prédio voltar a acender.`),toggle:null};case`other-device`:return{label:e(`Conectado em outro computador`),desc:e(`A sua conta conectou o prédio em outro computador, e este parou de enviar.`),toggle:{action:`resume`,text:e(`Trazer para este computador`),hint:e(`O prédio volta a subir daqui, e o outro computador para de enviar.`)}};case`banned`:return{label:e(`Conta banida`),desc:e(`O Habblaud World baniu esta conta: o prédio saiu do mundo e nada mais sai deste computador.`),toggle:null};case`suspended`:return{label:e(`Conta suspensa`),desc:e(`Esta conta está suspensa no Habblaud World: o prédio fica apagado e nada sai deste computador.`),toggle:{action:`resume`,text:e(`Tentar de novo`),hint:e(`Se a suspensão já acabou, o prédio volta a acender.`)}};case`waiting`:return{label:e(`Na lista de espera`),desc:e(`A conta voltou para a lista de espera: o prédio sai do mundo até o acesso ser liberado de novo.`),toggle:null};case`no_player`:return{label:e(`Sem personagem`),desc:e(`O mundo não encontrou o seu personagem: crie de novo para o prédio voltar.`),toggle:null};case`unauthorized`:return{label:e(`Entre de novo`),desc:e(`O servidor do mundo não reconheceu este computador: entre de novo na conta.`),toggle:null};case`deleted`:return{label:e(`Conta excluída`),desc:e(`A conta do Habblaud World foi excluída: o prédio e o perfil saíram do mundo e nada mais sai deste computador.`),toggle:null}}}function bn(t){switch(t){case`schema`:return e(`O pacote saiu fora do formato do protocolo. Atualize o Habblaud.`);case`limits`:return e(`O escritório passou dos limites do mundo (64 andares, 64 agentes por andar, 256 agentes ou 64 KB).`);case`name_pool`:return e(`Um nome de personagem não está na lista de nomes do mundo.`);case`parts`:return e(`Uma peça de aparência está fora das paletas do editor.`);case`ids`:return e(`Um código de andar ou de agente está fora do formato.`);case`rate`:return e(`Remessas demais em pouco tempo (o limite é 12 por minuto). A próxima vai normalmente.`);case`internal`:return e(`Um erro no servidor do mundo. A próxima remessa tenta de novo.`);case`left`:return e(`A conta saiu do mundo (por este ou por outro computador): nada mais sai até você voltar ao mundo.`);case`implausible`:return e(`O pacote contradiz o anterior de um jeito que o Habblaud não produz: o mundo o descartou, e o prédio fica com o último aceito. As próximas remessas vão normalmente.`);default:return e(`Um motivo que esta versão do Habblaud não conhece.`)}}function xn(t){return t===`appeal`?{text:e(`Recorrer por e-mail`),hint:e(`Abre um e-mail para {0}: conte o que aconteceu, e uma pessoa revê o caso.`,[Q])}:{text:e(`Contestar por e-mail`),hint:e(`Abre um e-mail para {0}: se for engano, uma pessoa revê os números e tira o selo.`,[Q])}}function $(t){return t===1?e(`1 byte`):e(`{0} bytes`,[r(t)])}function Sn(t){return t===1?e(`1 andar`):e(`{0} andares`,[r(t)])}function Cn(t){return t===1?e(`1 agente`):e(`{0} agentes`,[r(t)])}function wn(t){return t===1?e(`1 visitante agora`):e(`{0} visitantes agora`,[r(t)])}var Tn={started:!1,last:void 0,notified:!1};function En(e,t,n){let r=typeof t==`number`&&t>0?t:t===0?0:void 0;if(!e.started)return{state:{started:!0,last:r,notified:r!==void 0&&r>0},notify:!1};if(r===void 0)return{state:{started:!0,last:void 0,notified:!1},notify:!1};let i=r>0&&(e.last??0)===0,a=i&&!e.notified&&n;return{state:{started:!0,last:r,notified:e.notified||i},notify:a}}function Dn(t,n,r,i={}){let a=On(t,n,r,i);return a.state===`stopped`&&(t?.stopped===`banned`||t?.stopped===`suspended`)?{...a,appeal:xn(`appeal`)}:t?.unverified&&a.state!==`stopped`&&a.state!==`left`&&a.state!==`no_player`?{...a,unverified:e(`O mundo marcou o seu prédio como "não verificado": os números pareceram fora do normal e estão em revisão. Ele continua no mundo, mas fora de placares e destaques.`),appeal:xn(`contest`)}:a}function On(t,n,r,a){let o=vn(t,n),s={unverified:null,appeal:null},c=t?.floors??0,l=t?.agents??0,u=o===`no_player`||o===`left`?[]:[Sn(c),Cn(l),t?.lastUplinkAt?e(`Última remessa: {0}`,[i(t.lastUplinkAt,r)]):e(`Nenhuma remessa ainda`),...t?.visitors?[`👀 ${wn(t.visitors)}`]:[]],d=(o===`connected`||o===`reconnecting`||o===`paused`)&&t?.lastAck?.ok===!1?bn(t.lastAck.error):null,f=e(`Pausado por 30 dias, o prédio some do mapa e, 30 dias depois, é retirado; retomar antes disso traz de volta, no mesmo lote.`);switch(o){case`no_player`:return{state:o,label:e(`Sem personagem`),desc:e(`Crie o seu personagem: o prédio entra no mundo junto com ele.`),stats:u,rejected:d,toggle:null,leave:!1,...s};case`left`:return{state:o,label:e(`Fora do mundo`),desc:e(`Você saiu do mundo: o prédio foi retirado e o lote, liberado. Dá para andar pela cidade; nada do escritório sai deste computador.`),stats:u,rejected:null,toggle:{action:`join`,text:e(`Voltar ao mundo`),hint:e(`Voltar cria um prédio novo, em outro lote; a conta e o personagem são os mesmos.`)},leave:!1,...s};case`stopped`:{let e=t.stopped;return{state:o,...yn(e),stats:u,rejected:d,leave:e===`update`||e===`other-device`||e===`suspended`,...s}}case`paused`:return{state:o,label:e(`Pausado`),desc:e(`Pausado: seu prédio está apagado, mas você pode andar pela cidade. Nada do escritório sai deste computador.`),stats:u,rejected:d,toggle:{action:`resume`,text:e(`Retomar`),hint:`${e(`Retomar volta a enviar e acende o prédio.`)} ${f}`},leave:!0,...s};case`connected`:case`reconnecting`:{let n=o===`connected`,r=!t?.lastUplinkAt,i=!n&&!!a.maintenance;return{state:o,label:e(n?`Conectado`:i?`Em manutenção`:r?`Conectando…`:`Reconectando…`),desc:e(n?`Aceso no mundo: um andar por sala aberta e cada personagem no status de agora. Os tokens, se você deixar, aparecem só em faixas, no medidor da fachada.`:i?`O mundo está em manutenção; tentamos de novo em instantes.`:r?`O prédio acende com a primeira remessa.`:`Sem conexão com o mundo agora: o Habblaud tenta de novo sozinho. Com 2 minutos sem notícias, o prédio apaga.`),stats:u,rejected:d,toggle:{action:`pause`,text:e(`Pausar`),hint:`${e(`Pausar interrompe o envio na hora e apaga o prédio no mundo.`)} ${f}`},leave:!0,...s}}}}function kn(){return e(`Pausar apaga o prédio e guarda o lote: retomar traz de volta, no mesmo lugar. Sair do mundo retira o prédio na hora e libera o lote; a conta e o personagem continuam, e voltar depois cria um prédio novo, em outro lote.`)}function An(t,n){if(!t)return{kind:`pending`,label:e(`Sem resposta do mundo ainda.`),reason:null};if(t.ok){let r=t.bytes===void 0?null:t.bytes===n?e(`O mundo recebeu os mesmos {0}.`,[$(t.bytes)]):e(`O mundo contou {0}.`,[$(t.bytes)]);return{kind:`accepted`,label:e(`Aceita pelo mundo.`),reason:r}}return{kind:`rejected`,label:e(`Recusada pelo mundo.`),reason:bn(t.error)}}function jn(e){return JSON.stringify(e,null,2)}function Mn(e,t){return Y(e,t)===`active`&&e?.state===`approved`}function Nn(e,t){let n=e?.building;return!n||n.left||e.state!==`approved`||Y(e,t)===`hidden`?null:n.paused?`paused`:n.stopped?`stopped`:n.connected?`live`:n.lastUplinkAt?`reconnecting`:null}export{H as $,s as $t,Ut as A,Fe as At,Nn as B,ke as Bt,kn as C,Ye as Ct,Qt as D,ze as Dt,Gt as E,N as Et,Mn as F,Ve as Ft,Ft as G,x as Gt,Xt as H,Ae as Ht,an as I,He as It,Nt as J,C as Jt,jt as K,ae as Kt,rn as L,Me as Lt,tn as M,Le as Mt,jn as N,Re as Nt,Z as O,Be as Ot,Wt as P,Ne as Pt,L as Q,p as Qt,on as R,je as Rt,Yt as S,Je as St,En as T,Ke as Tt,Y as U,O as Ut,_n as V,Ee as Vt,It as W,Se as Wt,I as X,ie as Xt,Mt as Y,re as Yt,R as Z,ee as Zt,$t as _,gt as _t,mn as a,G as at,Sn as b,Xe as bt,fn as c,wt as ct,An as d,Ot as dt,B as et,Cn as f,St as ft,un as g,kt as gt,$ as h,Et as ht,Ht as i,Ct as it,en as j,M as jt,pn as k,Ie as kt,Tn as l,Dt as lt,Dn as m,yt as mt,Vt as n,z as nt,Rt as o,bt as ot,gn as p,xt as pt,At as q,oe as qt,dn as r,V as rt,zt as s,Tt as st,Q as t,F as tt,Bt as u,W as ut,ln as v,mt as vt,nn as w,Ge as wt,cn as x,Ze as xt,Zt as y,$e as yt,wn as z,Ce as zt};