fiverunner 0.9.0 → 1.2.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.
Binary file
package/package.json CHANGED
@@ -1,11 +1,14 @@
1
1
  {
2
2
  "name": "fiverunner",
3
- "version": "0.9.0",
4
- "description": "Run FiveM resources (Lua + NUI) in your browser and in CI. No GTA V, no server, no restarts.",
3
+ "version": "1.2.0",
4
+ "description": "Run FiveM resources (Lua, JavaScript and NUI) in your browser and in CI. No GTA V, no server, no restarts.",
5
5
  "keywords": [
6
6
  "fivem",
7
7
  "cfx",
8
8
  "gta5",
9
+ "qbcore",
10
+ "qbox",
11
+ "esx",
9
12
  "lua",
10
13
  "nui",
11
14
  "emulator",
@@ -37,6 +40,7 @@
37
40
  "build:wasm": "node scripts/build-wasm.ts",
38
41
  "build:natives": "node scripts/generate-natives.ts",
39
42
  "build:mime": "node scripts/generate-mime.ts",
43
+ "build:playground": "vite build -c vite.playground.config.ts && vite build -c vite.playground-sw.config.ts",
40
44
  "test": "vitest run",
41
45
  "test:e2e": "vitest run -c vitest.e2e.config.ts",
42
46
  "typecheck": "tsc --noEmit",
@@ -46,10 +50,12 @@
46
50
  "devDependencies": {
47
51
  "@citizenfx/client": "2.0.37175-1",
48
52
  "@citizenfx/server": "2.0.37175-1",
53
+ "@jitl/quickjs-wasmfile-release-sync": "^0.32.0",
49
54
  "@sqlite.org/sqlite-wasm": "3.53.4-build2",
50
55
  "@types/node": "22.18.13",
51
56
  "mime": "2.4.0",
52
57
  "prettier": "3.9.9",
58
+ "quickjs-emscripten-core": "^0.32.0",
53
59
  "typescript": "6.0.3",
54
60
  "vite": "8.3.3",
55
61
  "vitest": "5.0.2"
@@ -1 +0,0 @@
1
- :root{--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark;--background:#111318;--panel:#1a1d24;--border:#2b2f39;--text:#d7dae0;--muted:#8a909c;--accent:#f0a030;--red:#ff5c5c;--green:#5fd068;--yellow:#f2d45c;--blue:#5c8dff;--cyan:#4fd6e0;--magenta:#d070f0;--orange:#f08a3c;--gray:#8a909c;font-family:system-ui,sans-serif;font-size:14px}*{box-sizing:border-box}body{background:var(--background);color:var(--text);margin:0}button,input,select,textarea{font:inherit;color:inherit;background:var(--panel);border:1px solid var(--border);border-radius:4px;padding:4px 8px}button{cursor:pointer}button:hover{border-color:var(--accent)}h1,h2{margin:0;font-weight:600}h1{color:var(--accent);font-size:16px}h2{text-transform:uppercase;letter-spacing:.06em;color:var(--muted);font-size:13px}.top{border-bottom:1px solid var(--border);align-items:center;gap:12px;padding:8px 16px;display:flex}#status{margin-left:auto;font-size:12px}#status.running{color:var(--green)}#status.starting{color:var(--yellow)}#status.failed{color:var(--red)}main{grid-template-rows:340px 300px 680px auto;grid-template-columns:minmax(0,1fr) 260px;gap:12px;padding:12px 16px;display:grid}.server,.resources,.events,.state,.map,.players{flex-direction:column;gap:8px;min-height:0;display:flex}.map,.players{grid-column:1/-1}.map .toolbar{align-items:center;gap:8px;display:flex}.map .hint{color:var(--muted);margin-left:auto;font-size:12px}.map .map-image{align-items:center;gap:6px;font-size:12px;display:flex}.map .map-image[open]{border:1px solid var(--border);border-radius:4px;padding:2px 6px}.map .map-image summary{cursor:pointer;color:var(--muted)}.map .map-image input[type=number]{width:72px}.map .map-image input[type=file]{max-width:190px;font-size:11px}.map .view{border:1px solid var(--border);background:#0b0c10;border-radius:4px;flex:1;min-height:0;position:relative;overflow:hidden}.map canvas{cursor:grab;width:100%;height:100%;display:block}.map .tooltip{pointer-events:none;background:var(--panel);border:1px solid var(--border);white-space:pre;border-radius:4px;padding:6px 8px;font-size:12px;position:absolute}.map .view[data-style=GTA] .tooltip{border:0;border-left:3px solid var(--accent);color:#fff;letter-spacing:.02em;background:#030609e6;border-radius:0;font-family:Bahnschrift,Arial Narrow,Roboto Condensed,Arial,sans-serif;font-stretch:87.5%}.map .view[data-style=Cartoon] .tooltip{color:#2d3142;background:#fff;border:2px solid #2b2d3a;border-radius:12px;font-family:Nunito,Varela Round,Segoe UI,system-ui,sans-serif;font-weight:700;box-shadow:0 3px #1e321e40}.console{border:1px solid var(--border);white-space:pre-wrap;overflow-wrap:anywhere;background:#0b0c10;border-radius:4px;flex:1;min-height:0;padding:8px;font-family:ui-monospace,Consolas,monospace;font-size:12px;line-height:1.45;overflow:auto}.console.small{flex:none;height:160px}.line .channel{color:var(--muted)}.line.kind-warning{color:var(--yellow)}.line.kind-diagnostic{color:var(--orange)}.line.note{color:var(--accent)}.line.kind-event .channel{color:var(--cyan)}#emit{gap:6px;display:flex}#emit input[name=name]{flex:1}#emit input[name=args]{flex:2}#bags{font-family:ui-monospace,Consolas,monospace;font-size:12px;overflow:auto}#bags h3{color:var(--accent);margin:8px 0 4px;font-size:12px}#bags dl{grid-template-columns:max-content 1fr;gap:2px 10px;margin:0;display:grid}#bags dt{color:var(--muted)}#bags dd{overflow-wrap:anywhere;margin:0}#bags .empty{color:var(--muted)}.color-red{color:var(--red)}.color-green{color:var(--green)}.color-yellow{color:var(--yellow)}.color-blue{color:var(--blue)}.color-cyan{color:var(--cyan)}.color-magenta{color:var(--magenta)}.color-orange{color:var(--orange)}.color-gray{color:var(--gray)}#command input{width:100%;font-family:ui-monospace,Consolas,monospace}#resources-list{margin:0;padding:0;list-style:none;overflow:auto}#resources-list li{border-bottom:1px solid var(--border);align-items:center;gap:6px;padding:4px 0;display:flex}#resources-list li span:first-child{text-overflow:ellipsis;flex:1;overflow:hidden}#resources-list button{padding:1px 6px;font-size:12px}.state{color:var(--muted);font-size:11px}.state.started{color:var(--green)}.toolbar{align-items:center;gap:12px;display:flex}#connect{gap:6px;display:flex}#player-list{grid-template-columns:repeat(auto-fill,minmax(520px,1fr));gap:12px;display:grid}.player{background:var(--panel);border:1px solid var(--border);border-radius:6px;flex-direction:column;gap:8px;padding:8px;display:flex}.player.gone{opacity:.55}.player.large{grid-column:1/-1}.player header{align-items:center;gap:8px;display:flex}.player .info{flex:1}.screen{aspect-ratio:16/9;cursor:crosshair;background:radial-gradient(circle at 50% 40%,#2a3140,#0d0f14);border-radius:4px;outline:none;position:relative;overflow:hidden}.screen.nui-cursor{cursor:default}.screen.nui-focus{box-shadow:0 0 0 2px var(--accent)}.screen .world,.screen .world .view,.screen .fade{position:absolute;inset:0}.screen .world canvas{width:100%;height:100%;display:block}.screen .world{transition:filter .2s,transform .2s}.screen.blurred .world{filter:blur(8px)brightness(.8);transform:scale(1.05)}.screen .fade{opacity:0;pointer-events:none;background:#000;transition:opacity 80ms linear}.viewport{color-scheme:normal;transform-origin:0 0;position:absolute;top:0;left:0}.viewport iframe{pointer-events:none;background:0 0;border:0;width:100%;height:100%;position:absolute;inset:0}.screen.nui-cursor .viewport iframe{pointer-events:auto}.card pre{max-height:120px;margin:0 0 6px;font-size:12px;overflow:auto}.card form{gap:6px;display:flex}.card textarea{flex:1;height:48px;font-family:ui-monospace,Consolas,monospace}@media (width<=800px){main{grid-template-rows:300px auto 300px auto 360px auto;grid-template-columns:1fr}#player-list{grid-template-columns:1fr}}
@@ -1 +0,0 @@
1
- import{t as e}from"./routes-DFIWFSAi.js";var t=`fiverunner.localhost`,n=new TextEncoder,r=new TextDecoder;function i({host:e,client:r,tab:i}){let a=e.replace(/[A-Z]/g,e=>e.toLowerCase());return`${/^[a-z0-9_-]+$/.test(a)?a:`${Array.from(n.encode(a),e=>e.toString(16).padStart(2,`0`)).join(``)}.x`}.c${r}.${i}.${t}`}function a(e){let t=/^(.+)\.c([1-9][0-9]*)\.([a-z0-9]+)\.fiverunner\.localhost$/.exec(e);if(t===null)return;let[,n=``,i=``,a=``]=t,o=Number(i);if(/^[a-z0-9_-]+$/.test(n))return{host:n,client:o,tab:a};let s=/^((?:[0-9a-f]{2})+)\.x$/.exec(n)?.[1];if(s===void 0)return;let c=Uint8Array.from(s.match(/../g),e=>parseInt(e,16));return{host:r.decode(c),client:o,tab:a}}function o(e,t,n,r){let a=/^(?:nui:\/\/|https:\/\/(?=cfx-nui-))([^/?#]*)(.*)$/i.exec(e);if(a===null)return e;let[,o=``,s=``]=a,c=s.startsWith(`/`)?s:`/${s}`;return`http://${i({host:o,client:t,tab:n})}${r===``?``:`:${r}`}${c}`}var s=`/__fiverunner/api/`;new TextDecoder;var c=[``,`red`,`green`,`yellow`,`blue`,`cyan`,`magenta`,``,`orange`,`gray`],l=2e3,u=class{element;constructor(e){this.element=e}add(e){this.entry(e.channel,e.text,`kind-${e.kind}`)}entry(e,t,n){let r=document.createElement(`div`);r.className=`line ${n}`;let i=document.createElement(`span`);i.className=`channel`,i.textContent=`[${e}] `,r.append(i,...d(t)),this.#e(r)}note(e){let t=document.createElement(`div`);t.className=`line note`,t.textContent=e,this.#e(t)}#e(e){let{element:t}=this,n=t.scrollHeight-t.scrollTop-t.clientHeight<4;for(t.append(e);t.childElementCount>l;)t.firstElementChild.remove();n&&(t.scrollTop=t.scrollHeight)}};function d(e){let t=[],n=``;for(let[r,i]of e.split(/\^(\d)/).entries())if(r%2==1)n=c[Number(i)]??``;else if(i!==``){let e=document.createElement(`span`);n!==``&&(e.className=`color-${n}`),e.textContent=i,t.push(e)}return t}var f=class{#e;#t;#n=new Map;constructor(e,t,n){this.#e=new u(e),this.#t=t.elements.namedItem(`target`);let r=t.elements.namedItem(`name`),i=t.elements.namedItem(`args`);t.addEventListener(`submit`,e=>{e.preventDefault();let t=p(this.#t.value);if(t===void 0||r.value.trim()===``)return;let a;try{a=JSON.parse(i.value.trim()===``?`[]`:i.value)}catch(e){this.#e.note(`The arguments are no JSON: ${String(e)}`);return}Array.isArray(a)?n.emit(r.value.trim(),a,t):this.#e.note(`The arguments are a JSON array, such as [100, "cash"]`)}),this.players([])}add({from:e,to:t,name:n,args:r}){this.#e.entry(`${this.#r(e)} -> ${this.#r(t)}`,`${n}(${r})`,`kind-event`)}note(e){this.#e.note(e)}players(e){this.#n.clear();for(let{client:t,name:n}of e)this.#n.set(t,n);let t=e.filter(({state:e})=>e===`joined`),n=[...t.map(({client:e,name:t})=>[`from:${e}`,`To the server, from ${t}`]),...t.map(({client:e,name:t})=>[`to:${e}`,`To ${t}, from the server`]),[`to:everyone`,`To every player, from the server`]],r=this.#t.value;this.#t.replaceChildren(...n.map(([e,t])=>{let n=document.createElement(`option`);return n.value=e,n.textContent=t,n})),n.some(([e])=>e===r)&&(this.#t.value=r)}#r(e){return e===`server`?`server`:this.#n.get(e)??`client ${e}`}};function p(e){let[t,n]=e.split(`:`);if(t===`to`&&n===`everyone`)return{to:`everyone`};let r=Number(n);if(!(!Number.isInteger(r)||r<1))return t===`from`?{from:r}:{to:r}}function m(e,t){if(t.length===0){let t=document.createElement(`p`);t.className=`empty`,t.textContent=`No state bag has keys.`,e.replaceChildren(t)}else e.replaceChildren(...t.map(({name:e,keys:t})=>{let n=document.createElement(`section`),r=document.createElement(`h3`);r.textContent=e;let i=document.createElement(`dl`);for(let{key:e,value:n}of t){let t=document.createElement(`dt`);t.textContent=e;let r=document.createElement(`dd`);r.textContent=n,i.append(t,r)}return n.append(r,i),n}))}var h=[657415,1708816,2497301,3351579,4140064,4994598,5914672,6834999,7755326,8675910,9662543,10649435,11570534,12360562,13085055,13743756,14336923,14864298,15326139,15721932,16051933,4004370,5382682,7023388,8729630,10370848,12078372,13393708,14251837,14914910,3874639,5580911,7485856,9523911,11894496,7149638,10231646,13184891,14899868,15765437,1780843,2311326,3106761,5215203,8830448,1003351,1407616,2073507,1923628,2787900,5749063,10802750,15255082,15769892,15232287,13185054,2829101,4474183,6250595,8158592,10263968,12369343,14343132,15987697],g=new Map([[8,`flag`],[40,`house`],[50,`car`],[52,`basket`],[56,`badge`],[59,`basket`],[60,`badge`],[61,`cross`],[67,`car`],[68,`lock`],[71,`scissors`],[72,`spray`],[73,`shirt`],[75,`heart`],[93,`bottle`],[102,`syringe`],[108,`dollar`],[110,`gun`],[198,`car`],[225,`car`],[273,`cutlery`],[326,`car`],[356,`boat`],[357,`parking`],[359,`plane`],[360,`plane`],[361,`fuel`],[366,`shirt`],[402,`wrench`],[403,`pill`],[423,`plane`],[424,`plane`],[427,`boat`],[477,`car`],[566,`anvil`],[729,`anchor`]]);function _(e){return g.get(e)}function v(e,t,n=!1){let r=0;for(let e=0;e<t.length;e+=2){let n=(e+2)%t.length;r+=t[e]*t[n+1]-t[n]*t[e+1]}let i=[...Array(t.length/2).keys()];r>0===n&&i.reverse(),i.forEach((n,r)=>{r===0?e.moveTo(t[2*n],t[2*n+1]):e.lineTo(t[2*n],t[2*n+1])}),e.closePath()}function y(e,t,n,r,i=!1){e.moveTo(t+r,n),e.arc(t,n,r,0,Math.PI*2,i),e.closePath()}function b(e,t){let n=new Path2D;return n.addPath(e,new DOMMatrix().rotate(t)),n}function x(e,t,n=0){let r=new Path2D;e(r);let i=n===0?r:b(r,n);return t===void 0?{path:i}:{path:i,width:t}}var S;function ee(){return{anchor:[x(e=>{y(e,0,-5.4,2.1),y(e,0,-5.4,1,!0),e.roundRect(-.95,-3.6,1.9,10.4,.6),e.roundRect(-3.8,-2.6,7.6,1.7,.85),v(e,[-7.4,1.2,-4.2,1.2,-5.8,3.6]),v(e,[7.4,1.2,4.2,1.2,5.8,3.6])}),x(e=>{e.moveTo(-5.8,2.4),e.quadraticCurveTo(-5,6.6,0,6.7),e.quadraticCurveTo(5,6.6,5.8,2.4)},1.7)],anvil:[x(e=>v(e,[-6.4,-4.4,4.2,-4.4,7.8,-3.4,4.6,-1.4,2.6,-1.4,2.6,1.6,4.8,4.4,4.8,6.2,-4.8,6.2,-4.8,4.4,-2.6,1.6,-2.6,-1.4,-6.4,-1.4]))],badge:[x(e=>{let t=[];for(let e=0;e<10;e++){let n=e*Math.PI/5-Math.PI/2,r=e%2==0?7.8:3.4;t.push(Math.cos(n)*r,Math.sin(n)*r+.6)}v(e,t)})],basket:[x(e=>{e.roundRect(-7.8,-2.4,15.6,2.4,1),v(e,[-6.8,-.4,6.8,-.4,5.2,6.6,-5.2,6.6]);for(let t of[-3.7,-.75,2.2])v(e,[t,1.2,t+1.5,1.2,t+1.5,5,t,5],!0)}),x(e=>{e.moveTo(-4.6,-2.4),e.arc(0,-2.4,4.6,Math.PI,Math.PI*2)},1.6)],boat:[x(e=>{v(e,[-7.6,2,7.6,2,5,6.6,-5,6.6]),v(e,[.6,-7.6,6,.8,.6,.8]),v(e,[-.6,-5.6,-.6,.8,-5,.8])})],bottle:[x(e=>{e.roundRect(-1.9,-7.8,3.8,1.6,.6),e.roundRect(-1.35,-6.6,2.7,3,.4),v(e,[-1.35,-4,1.35,-4,3.7,-1.4,-3.7,-1.4]),e.roundRect(-3.7,-2.4,7.4,10.2,1.8),v(e,[-2.3,.6,2.3,.6,2.3,4.2,-2.3,4.2],!0)})],car:[x(e=>{e.roundRect(-7.6,-1.6,15.2,5,1.8),v(e,[-4.8,-1.6,-2.9,-5.8,3.1,-5.8,5.2,-1.6]),v(e,[-2.9,-2.4,-.4,-2.4,-.4,-4.8,-2.1,-4.8],!0),v(e,[.5,-2.4,3.6,-2.4,2.6,-4.8,.5,-4.8],!0),y(e,-4.2,3.6,2.2),y(e,4.2,3.6,2.2)})],cross:[x(e=>{e.roundRect(-2.7,-7.4,5.4,14.8,1),e.roundRect(-7.4,-2.7,14.8,5.4,1)})],cutlery:[x(e=>{e.roundRect(-5.6,-3.4,5,2.6,1.3),v(e,[2,-7.6,4.9,-4.8,4.9,.6,2,.6])}),x(e=>{e.moveTo(-3.1,-1.4),e.lineTo(-3.1,7),e.moveTo(3.4,.6),e.lineTo(3.4,7)},1.9),x(e=>{for(let t of[-5,-3.1,-1.2])e.moveTo(t,-7.4),e.lineTo(t,-2.6)},1.1)],dollar:[x(e=>{e.moveTo(0,-7.6),e.lineTo(0,7.6)},1.6),x(e=>{e.moveTo(4.3,-3.9),e.bezierCurveTo(3.3,-6.3,-4.6,-6.3,-4.4,-2.6),e.bezierCurveTo(-4.2,.2,4.4,-.4,4.4,2.8),e.bezierCurveTo(4.4,6.5,-3.6,6.5,-4.6,3.8)},2.3)],flag:[x(e=>{e.roundRect(-5.4,-7.8,1.9,15.6,.9),e.moveTo(-3.8,-7.4),e.quadraticCurveTo(.8,-9.4,6.8,-6),e.quadraticCurveTo(.8,-2.4,-3.8,-1.2),e.closePath()})],fuel:[x(e=>{e.roundRect(-6.6,-7,8.6,14.4,1.6),v(e,[-5,-5.4,.4,-5.4,.4,-1.6,-5,-1.6],!0),e.roundRect(-7.6,5.6,10.6,1.8,.6)}),x(e=>{e.moveTo(2,-3.4),e.lineTo(4.6,-3.4),e.lineTo(5.8,-1.8),e.lineTo(5.8,4.2),e.quadraticCurveTo(5.8,5.4,4.6,5.2)},1.5)],gun:[x(e=>v(e,[-7.4,-4.6,7,-4.6,7,-1.4,-.4,-1.4,-1.1,1.8,-2.7,1.8,-3.6,6.6,-7.2,6.6,-5.7,-1.4,-7.4,-1.4])),x(e=>{e.moveTo(-.4,-1.4),e.quadraticCurveTo(.6,2.4,-2.4,2)},1.1)],heart:[x(e=>{y(e,-3.2,-2.4,3.8),y(e,3.2,-2.4,3.8),v(e,[-6.8,-1,6.8,-1,0,7])})],house:[x(e=>v(e,[0,-7.8,7.8,-.4,5.2,-.4,5.2,7.2,1.6,7.2,1.6,2.6,-1.6,2.6,-1.6,7.2,-5.2,7.2,-5.2,-.4,-7.8,-.4]))],lock:[x(e=>{e.moveTo(-3.7,-.6),e.lineTo(-3.7,-3.6),e.arc(0,-3.6,3.7,Math.PI,Math.PI*2),e.lineTo(3.7,-.6)},2),x(e=>{e.roundRect(-6.2,-1.8,12.4,9.4,1.8);let t=Math.sqrt(1.5**2-.6**2);e.moveTo(.6,1.8+t),e.arc(0,1.8,1.5,Math.atan2(t,.6),Math.atan2(t,-.6),!0),e.lineTo(-1,5.2),e.lineTo(1,5.2),e.closePath()})],parking:[x(e=>{e.roundRect(-7.2,-7.2,14.4,14.4,3),e.moveTo(-2.9,4.9),e.lineTo(-.8,4.9),e.lineTo(-.8,1.1),e.lineTo(.8,1.1),e.arc(.8,-1.9,3,Math.PI/2,-Math.PI/2,!0),e.lineTo(-2.9,-4.9),e.closePath(),e.moveTo(-.8,-3),e.lineTo(.7,-3),e.arc(.7,-1.9,1.1,-Math.PI/2,Math.PI/2),e.lineTo(-.8,-.8),e.closePath()})],pill:[x(e=>{e.roundRect(-3.1,-7.6,6.2,15.2,3.1),v(e,[-3.1,-.45,3.1,-.45,3.1,.45,-3.1,.45],!0)},void 0,45)],plane:[x(e=>{e.moveTo(0,-8),e.quadraticCurveTo(1.6,-7,1.6,-3),e.lineTo(8,1),e.lineTo(8,2.6),e.lineTo(1.6,.6),e.lineTo(1.1,5),e.lineTo(3.6,7),e.lineTo(3.6,8),e.lineTo(0,7),e.lineTo(-3.6,8),e.lineTo(-3.6,7),e.lineTo(-1.1,5),e.lineTo(-1.6,.6),e.lineTo(-8,2.6),e.lineTo(-8,1),e.lineTo(-1.6,-3),e.quadraticCurveTo(-1.6,-7,0,-8),e.closePath()})],scissors:[x(e=>{for(let t of[-3.5,3.5])y(e,t,4.3,2.8),y(e,t,4.3,1.35,!0);v(e,[-2.9,2,-1.3,2.5,3.9,-7.4,2.5,-7.8]),v(e,[2.9,2,1.3,2.5,-3.9,-7.4,-2.5,-7.8])})],shirt:[x(e=>{e.moveTo(-3,-7.2),e.lineTo(-7.8,-4.6),e.lineTo(-5.8,-.4),e.lineTo(-4.2,-1.4),e.lineTo(-4.2,7.2),e.lineTo(4.2,7.2),e.lineTo(4.2,-1.4),e.lineTo(5.8,-.4),e.lineTo(7.8,-4.6),e.lineTo(3,-7.2),e.quadraticCurveTo(0,-4.2,-3,-7.2),e.closePath()})],spray:[x(e=>{e.roundRect(-4.6,-3.2,7.2,11,1.6),v(e,[-3.4,0,1.4,0,1.4,3.4,-3.4,3.4],!0),e.roundRect(-3.2,-5.8,4.4,2.8,.8),e.roundRect(-1.8,-7.4,1.6,1.8,.4),y(e,2.6,-6.6,.9),y(e,4.6,-7.4,.8),y(e,4.8,-5.2,.9),y(e,6.8,-6.2,.8)})],syringe:[x(e=>{e.roundRect(-2.7,-4.2,5.4,8.2,.9),v(e,[-1.2,-2.8,1.2,-2.8,1.2,2.6,-1.2,2.6],!0),e.roundRect(-3.4,3.4,6.8,1.3,.5),e.roundRect(-.7,4.6,1.4,2.2,.3),e.roundRect(-2.6,6.6,5.2,1.3,.5),e.roundRect(-1,-5.4,2,1.4,.4),v(e,[-.55,-5.2,.55,-5.2,0,-8.4])},void 0,45)],wrench:[x(e=>{e.roundRect(-1.4,-1.4,2.8,9.4,1.4);let t=Math.sqrt(3.7**2-1.25**2);e.moveTo(1.25,-4.2-t),e.arc(0,-4.2,3.7,Math.atan2(-t,1.25),Math.atan2(-t,-1.25)+Math.PI*2),e.lineTo(-1.25,-3.5),e.lineTo(1.25,-3.5),e.closePath()},void 0,45)]}}function C(e,t,n,r=0){S??=ee();let i=S[t],a=n/16,o=e.fillStyle;if(e.save(),e.scale(a,a),e.lineJoin=`round`,e.lineCap=`round`,r>0)for(let{path:t,width:n}of i)e.lineWidth=(n??0)+r*2/a,e.stroke(t);e.strokeStyle=o;for(let{path:t,width:n}of i)n===void 0?e.fill(t):(e.lineWidth=n,e.stroke(t));e.restore()}var te=`#f0f0f0.#e04646.#6fcf6f.#5a9ef0.#f0f0f0.#f0d24a.#e57373.#b07ee0.#f080c0.#f0b070.#c8a070.#90e090.#80c8f0.#c8a0f0.#7050b0.#50d0d0.#f0e090.#f09030.#6aa8f0.#c05090.#c0a030.#d07020.#b0b0b0.#f0b0d0.#c0e050.#3a8a3a.#4060f0.#a040f0.#806050.#304090.#208080.#b09070.#90c0f0.#f0e8a0.#f0a8c0.#f08080.#e0d0a0.#f4f4f4.#3c78e0.#c0c0c0.#606060.#f06080.#4c8ce0.#a0e0a0.#f0c080.#f8f8f8.#e0b030.#f08c28.#f050a0.#d83c3c.#9070d0.#f09080.#2c7a3c.#a0d8f0.#3c6e7a.#c0c8d0.#8a5a30.#4a80e0.#4a5a8a.#e04848.#f0b040.#c04890.#d0d0d0.#3a7aa0.#c86020.#8a7a9a.#f0b440.#4a88e8.#5090e8.#58c058.#f0b848.#f0bc4c.#202020.#f0b040.#4888e0.#e04040.#a02828.#4888e8.#5090f0.#284080.#505050.#f0d840.#a0e040.#9050c0.#4878d8.#484848`.split(`.`),ne=[`#f0a030`,`#4fd6e0`,`#d070f0`,`#5fd068`,`#ff5c5c`,`#5c8dff`],re=[10,25,50,100,250,500,1e3,2e3],ie=`Bahnschrift, 'Arial Narrow', 'Roboto Condensed', 'Helvetica Neue', Arial, sans-serif`,w=`'Nunito', 'Varela Round', 'Segoe UI', system-ui, sans-serif`;function ae(e,t,n){let r=t*Math.min(n,1-n),i=t=>{let i=(t+e/30)%12,a=n-r*Math.max(-1,Math.min(i-3,9-i,1));return Math.round(a*255).toString(16).padStart(2,`0`)};return`#${i(0)}${i(8)}${i(4)}`}function T(e){return te[e]??ae(e*137.5%360,.7,.62)}function E(e){return ne[(e-1)%ne.length]}function D(e){let t=Number.parseInt(e.slice(1,7),16);return[t>>16&255,t>>8&255,t&255]}function O(e,t){let[n,r,i]=D(e).map(e=>Math.round(t<0?e*(1+t):e+(255-e)*t));return`rgb(${n} ${r} ${i})`}function k(e){let[t,n,r]=D(e).map(e=>(e/255)**2.2);return .2126*t+.7152*n+.0722*r}function A(e,t,n,r=[],i=0){let{context:a,width:o,height:s}=e,c=re.find(t=>t*e.scale>=70)??re.at(-1),[l,u]=e.toWorld(0,0),[d,f]=e.toWorld(o,s);a.lineWidth=1,a.font=n,a.fillStyle=t.text,a.setLineDash(r);for(let n=Math.ceil(l/c)*c;n<=d;n+=c){let[r]=e.toScreen(n,0);a.strokeStyle=n===0?t.axis:t.line,a.beginPath(),a.moveTo(Math.round(r)+.5,0),a.lineTo(Math.round(r)+.5,s),a.stroke(),e.bare!==!0&&a.fillText(String(n),r+3,i+12)}for(let n=Math.ceil(f/c)*c;n<=u;n+=c){let[,r]=e.toScreen(0,n);a.strokeStyle=n===0?t.axis:t.line,a.beginPath(),a.moveTo(0,Math.round(r)+.5),a.lineTo(o,Math.round(r)+.5),a.stroke(),r>i+20&&e.bare!==!0&&a.fillText(String(n),3,r-3)}a.setLineDash([])}function j(e,t,n,r,i){let a=r.findIndex(([r,i])=>e.claim(r,i,t,n));if(a>=0)return a;if(!i)return;let o=r.map(([r,i])=>e.crowding(r,i,t,n)),s=o.indexOf(Math.min(...o));return e.claim(...r[s],t,n,!0),s}function oe(e,t,n,r,i,a,o=!1){let{context:s}=e;s.font=a;let c=s.measureText(t).width,l=([e,,t])=>t===`center`?e-c/2:t===`right`?e-c:e,u=j(e,c+4,16,n.map(e=>[l(e)-2,e[1]-12]),o);if(u===void 0)return;let d=l(n[u]),f=n[u][1];s.lineJoin=`round`,s.lineWidth=3,s.strokeStyle=i,s.strokeText(t,d,f),s.fillStyle=r,s.fillText(t,d,f),s.lineWidth=1}var M=e=>-e.heading*Math.PI/180;function N(e,t){let n=Math.sin(e*127.1+t*311.7)*43758.5453;return n-Math.floor(n)}var se=Float64Array.from({length:512},(e,t)=>{let n=Math.floor(t/2)/256*Math.PI*2;return t%2==0?Math.cos(n):Math.sin(n)});function ce(e,t){let n=Math.imul(e|0,668265261)^Math.imul(t|0,374761393);return n=Math.imul(n^n>>>15,2246822507),((n^n>>>13)&255)*2}function le(e,t){let n=Math.floor(e),r=Math.floor(t),i=e=>e*e*e*(e*(e*6-15)+10),a=(n,r)=>{let i=ce(n,r);return se[i]*(e-n)+se[i+1]*(t-r)},o=i(e-n),s=i(t-r),c=a(n,r)+(a(n+1,r)-a(n,r))*o;return .5+(c+(a(n,r+1)+(a(n+1,r+1)-a(n,r+1))*o-c)*s)*.75}function ue(e,t){return le(e,t)*.68+le((e*.8-t*.6)*2.1+31,(e*.6+t*.8)*2.1-7)*.32}function P(e,t){return 2**Math.round(Math.log2(t/e.scale))}function de(e=1/0){let t,n=``;return(r,i,a=``)=>{let[o,s]=r.toWorld(0,0),c=`${r.width} ${r.height} ${r.ratio} ${o} ${s} ${r.scale} ${a}`;if(t??=document.createElement(`canvas`),c!==n){let a=Math.min(r.ratio,e),o=Math.round(r.width*a),s=Math.round(r.height*a);(t.width!==o||t.height!==s)&&(t.width=o,t.height=s);let l=t.getContext(`2d`);l.setTransform(1,0,0,1,0,0),l.clearRect(0,0,o,s),l.setTransform(a,0,0,a,0,0),i({...r,context:l,ratio:a}),n=c}r.context.drawImage(t,0,0,r.width,r.height)}}function fe(e){let t=e.length;for(let{x:n,y:r}of e)t=(t*31+Math.round(n)*7+Math.round(r))%1e9;return String(t)}var F={name:`Classic`,animated:!1,background(e){e.context.clearRect(0,0,e.width,e.height),A(e,{line:`#1f232b`,axis:`#3a404c`,text:`#5a606c`},`11px ui-monospace, Consolas, monospace`)},area(e,t,n,r){let{context:i}=e;if(i.globalAlpha=t.alpha/255*.35,i.fillStyle=T(t.colour),i.beginPath(),t.shape===`radius`)i.arc(n,r,(t.radius??0)*e.scale,0,Math.PI*2);else{let a=(t.width??0)*e.scale,o=(t.height??0)*e.scale;i.rect(n-a/2,r-o/2,a,o)}i.fill(),i.globalAlpha=1},route(e,t,n,r){let{context:i}=e;i.strokeStyle=r,i.lineWidth=2,i.setLineDash([6,5]),i.beginPath(),i.moveTo(...t),i.lineTo(...n),i.stroke(),i.setLineDash([]),i.lineWidth=1},blip(e,t,n,r){let{context:i}=e;e.claim(n-6,r-6,12,12,!0),i.globalAlpha=Math.max(t.alpha/255,.25),t.sprite===8?(i.fillStyle=`#d070f0`,i.beginPath(),i.moveTo(n,r-9),i.lineTo(n+7,r),i.lineTo(n,r+9),i.lineTo(n-7,r),i.closePath(),i.fill()):t.shape!==`radius`&&t.shape!==`area`&&(i.fillStyle=T(t.colour),i.strokeStyle=`#0b0c10`,i.beginPath(),i.arc(n,r,5,0,Math.PI*2),i.fill(),i.stroke()),i.globalAlpha=1},label(e,t,n,r,i){oe(e,t,[[n+8,r+4,`left`],[n-8,r+4,`right`]],`#c8ccd4`,`#0b0c10`,`12px system-ui, sans-serif`,i)},tag(e,t,n,r,i){oe(e,t,[[r,i+22,`center`],[r,i-14,`center`]],n,`#0b0c10`,`12px system-ui, sans-serif`,!0)},entity(e,t,n,r,i,a){let{context:o}=e;if(t.kind===`player`){let i=a?.colour??`#d7dae0`;e.claim(n-8,r-10,16,18,!0),o.save(),o.translate(n,r),o.rotate(M(t)),o.fillStyle=i,o.strokeStyle=`#0b0c10`,o.beginPath(),o.moveTo(0,-10),o.lineTo(7,7),o.lineTo(0,3),o.lineTo(-7,7),o.closePath(),o.fill(),o.stroke(),o.restore()}else t.kind===`vehicle`?(o.save(),o.translate(n,r),o.rotate(M(t)),o.fillStyle=`#8a909c`,o.fillRect(-4,-7,8,14),o.restore()):(o.fillStyle=t.kind===`ped`?`#a8adb8`:`#5a606c`,o.beginPath(),o.arc(n,r,t.kind===`ped`?3.5:2.5,0,Math.PI*2),o.fill());return[n,r]}},I={grass:`#8fcf68`,light:[166,220,127],dark:[124,192,88],tuft:`#6eb24c`,ink:`#2b2d3a`,text:`#2d3142`},pe=[`#ef5b5b`,`#3f8efc`,`#ffc145`,`#34c38f`,`#a66cff`,`#ff8a3d`,`#f2f4f8`],me=[`#8d99ae`,`#e9c46a`,`#2a9d8f`,`#e76f51`,`#9b5de5`,`#577590`],he=[`#f8d5b5`,`#eab78e`,`#c98d62`,`#9c6644`,`#6f4630`],ge=[`#3b2a20`,`#6b4423`,`#d8a93f`,`#a0522d`,`#23232b`,`#c8553d`],_e=[`#3d4a6b`,`#e9c46a`,`#2a9d8f`,`#e76f51`,`#9b5de5`,`#577590`,`#f4f1de`,`#ef476f`,`#118ab2`,`#06d6a0`,`#ffd166`,`#264653`,`#8d99ae`,`#f78c6b`,`#2b2d42`,`#b5838d`],ve=[`#f8d5b5`,`#f1c6a0`,`#eab78e`,`#d9a077`,`#c98d62`,`#b07650`,`#9c6644`,`#845437`,`#6f4630`];function ye(e){if(e===void 0)return;let t=([e,t],n)=>_e[Math.abs(e*5+t*3+n)%_e.length],n=e=>D(ve[Math.abs(e)%ve.length]),[r,i,a]=e.skin,[o,s]=[n(r),n(i)],c=o.map((e,t)=>Math.round(e+(s[t]-e)*a)),l=h[e.hair]??h[0];return{skin:`rgb(${c.join(` `)})`,hair:`#${l.toString(16).padStart(6,`0`)}`,top:t(e.top,1),legs:t(e.legs,0),shoes:t(e.shoes,14),long:e.hairStyle%2==1}}function L(e,t,n,r=1.6){e.lineWidth=r*2,e.strokeStyle=I.ink,e.stroke(t),e.fillStyle=n,e.fill(t)}function R(e,t,n,r,i,a=.22){e.fillStyle=`rgba(32, 70, 26, ${a})`,e.beginPath(),e.ellipse(t,n,r,i,0,0,Math.PI*2),e.fill()}function be(e,t,n,r,i){R(e,t+4*i,n+1,12*i,4.5*i);let a=new Path2D;a.roundRect(t-2.2*i,n-9*i,4.4*i,10*i,1.6*i),L(e,a,`#9a6a45`,1.1);let o=new Path2D;if(r){for(let[e,r,a]of[[-30,7,-18],[-24,9.5,-12],[-18,11.5,-6]])o.moveTo(t,n+e*i),o.lineTo(t+r*i,n+a*i),o.lineTo(t-r*i,n+a*i),o.closePath();L(e,o,`#3f9a54`,1.1),e.fillStyle=`rgba(255, 255, 255, 0.18)`,e.beginPath(),e.moveTo(t,n-29*i),e.lineTo(t-5*i,n-20*i),e.lineTo(t-1*i,n-20*i),e.closePath(),e.fill()}else{for(let[e,r,a]of[[-6,-14,7],[6,-14,7],[0,-20,8.5]])o.moveTo(t+(e+a)*i,n+r*i),o.arc(t+e*i,n+r*i,a*i,0,Math.PI*2);L(e,o,`#4caf50`,1.1),e.fillStyle=`#7bd06b`,e.beginPath(),e.arc(t-3*i,n-22*i,3.6*i,0,Math.PI*2),e.arc(t-7.5*i,n-15.5*i,2.4*i,0,Math.PI*2),e.fill()}}function xe(e,t,n,r){if(r<.12){R(e,t+2,n+1,9,3);let r=new Path2D;for(let[e,i,a]of[[-5,-4,4.6],[4.5,-4,4.6],[0,-7,5.4]])r.moveTo(t+e+a,n+i),r.arc(t+e,n+i,a,0,Math.PI*2);L(e,r,`#5cb85c`,1),e.fillStyle=`#86d176`,e.beginPath(),e.arc(t-1.5,n-8.5,2,0,Math.PI*2),e.fill()}else if(r<.19){let[i,a]=[[`#ffffff`,`#ffd23f`],[`#ff8fb1`,`#fff3b0`],[`#ffd23f`,`#f08a3c`]][Math.floor(r*1e3)%3];for(let[r,o]of[[0,0],[6,3],[-5,4]]){e.fillStyle=i,e.beginPath();for(let i=0;i<5;i++){let a=i*Math.PI*2/5;e.moveTo(t+r+Math.cos(a)*1.8+1.5,n+o+Math.sin(a)*1.8),e.arc(t+r+Math.cos(a)*1.8,n+o+Math.sin(a)*1.8,1.5,0,Math.PI*2)}e.fill(),e.fillStyle=a,e.beginPath(),e.arc(t+r,n+o,1.2,0,Math.PI*2),e.fill()}}else if(r<.215){R(e,t+2,n+1.5,7,2.5);let r=new Path2D;r.ellipse(t,n-2,6,4,0,0,Math.PI*2),L(e,r,`#c3ccd6`,1),e.fillStyle=`#e6ebf0`,e.beginPath(),e.ellipse(t-2,n-3.6,2.4,1.3,-.3,0,Math.PI*2),e.fill()}else{e.strokeStyle=I.tuft,e.lineWidth=1.8,e.lineCap=`round`,e.beginPath();for(let r of[-3,0,3])e.moveTo(t+r,n),e.quadraticCurveTo(t+r*1.1,n-3,t+r*1.7,n-6+Math.abs(r)*.4);e.stroke(),e.lineCap=`butt`}}function Se(e,t){let{context:n,width:r,height:i}=e;n.fillStyle=I.grass,n.fillRect(0,0,r,i);let a=P(e,380),o=Math.ceil(r/16)+1,s=Math.ceil(i/16)+1,c=document.createElement(`canvas`);c.width=o,c.height=s;let l=c.getContext(`2d`),u=l.createImageData(o,s),[d,f]=e.toWorld(0,0);for(let t=0;t<s;t++)for(let n=0;n<o;n++){let r=ue((d+n*16/e.scale)/a,(f-t*16/e.scale)/a),i=Math.min(Math.max((r-.55)/.09,0),1),s=Math.min(Math.max((.45-r)/.09,0),1),[c,l,p]=i>0?I.light:I.dark,m=i>0?i:s,h=(t*o+n)*4;u.data[h]=c,u.data[h+1]=l,u.data[h+2]=p,u.data[h+3]=Math.round(m*255)}l.putImageData(u,0,0),n.imageSmoothingQuality=`high`,n.drawImage(c,-8,-8,o*16,s*16);let p=new Set;for(let a of t){if(a.shape===`radius`||a.shape===`area`)continue;let[t,o]=e.toScreen(a.x,a.y);if(!(t<-30||o<-30||t>r+30||o>i+30)){for(let e=-1;e<=1;e++)for(let n=-1;n<=1;n++)p.add(`${Math.floor(t/30)+e} ${Math.floor(o/30)+n}`);e.scale>=.1&&a.sprite!==8&&(n.fillStyle=`rgba(244, 228, 178, 0.85)`,n.beginPath(),n.ellipse(t,o+6,19,8.5,0,0,Math.PI*2),n.fill(),n.fillStyle=`rgba(255, 246, 214, 0.7)`,n.beginPath(),n.ellipse(t,o+5,12,5,0,0,Math.PI*2),n.fill())}}let m=P(e,58),h=Math.log2(m),[g,_]=e.toWorld(-40,-40),[v,y]=e.toWorld(r+40,i+60),b=[];for(let t=Math.floor(g/m);t<=v/m;t++)for(let n=Math.floor(y/m);n<=_/m;n++){let r=N(t+h*7.3,n-h*3.1);if(r>.55)continue;let[i,a]=e.toScreen((t+.15+N(n,t+h)*.7)*m,(n+.15+N(t+3.7,n-h)*.7)*m);r<.215&&p.has(`${Math.floor(i/30)} ${Math.floor(a/30)}`)||b.push([i,a,r])}b.sort((e,t)=>e[1]-t[1]);for(let[e,t,r]of b)r<.07?be(n,e,t,r<.025,.85+r*97%1*.35):xe(n,e,t,r);A(e,{line:`rgba(255, 255, 255, 0.22)`,axis:`rgba(255, 255, 255, 0.6)`,text:`#3f6e2c`},`800 10px ${w}`,[2,6])}function Ce(e){let{context:t,width:n,height:r,time:i}=e;t.fillStyle=`rgba(28, 60, 36, 0.05)`;for(let e=0;e<4;e++){let a=n+600,o=(e*.31*a+i*.012)%a-300,s=(e*.37+.12)%1*r+Math.sin(i/9e3+e)*24;t.beginPath();for(let[e,n,r,i]of[[0,0,120,52],[90,-20,90,44],[-80,14,80,38]])t.moveTo(o+e+r,s+n),t.ellipse(o+e,s+n,r,i,0,0,Math.PI*2);t.fill()}}function we(e){return e.scale>=.1?12.5:e.scale>=.04?10.5:8.5}function Te(e){let t=k(e);return t>.8?`#5f6b7d`:t>.42?O(e,-.32):e}function Ee(e,t,n,r,i,a){let{context:o}=e;o.font=`800 12px ${w}`;let s=Math.ceil(o.measureText(t).width)+16,c=r.map(([e,t])=>t?e:e-20),l=j(e,s,26,r.map(([,,e=0],t)=>[n+e-s/2,c[t]-3]),a);if(l===void 0)return;let u=c[l],[,d,f=0]=r[l],p=n+f,m=new Path2D;m.roundRect(p-s/2,u,s,20,10);let h=d?u:u+20;m.moveTo(p-5,h),m.lineTo(p,h+(d?-5:5)),m.lineTo(p+5,h),o.fillStyle=`rgba(30, 50, 30, 0.18)`,o.save(),o.translate(0,2.5),o.fill(m),o.restore(),o.fillStyle=i,o.fill(m),o.fillStyle=I.text,o.textAlign=`center`,o.fillText(t,p,u+14.5),o.textAlign=`left`}function De(e){return[`back`,`right`,`front`,`left`][Math.round((e%(Math.PI*2)+Math.PI*2)/(Math.PI/2))%4]}function Oe(e,t,n,r,i,a,o=!1,s){let c=De(r),l=s?.skin??he[a%he.length],u=s?.hair??ge[Math.floor(a/5)%ge.length],d=s?.long??Math.floor(a/3)%2==0,f=t/105+a,p=n?Math.sin(f):0,m=n?-Math.abs(Math.sin(f))*2:Math.sin(t/420+a)*.5;o||R(e,0,.5,10-(n?Math.abs(p):0),3.6,.26),e.save(),e.translate(0,m);let h=c===`left`||c===`right`,g=c===`left`?-1:1,_=new Path2D,v=new Path2D;for(let[e,t]of[[-3,Math.max(0,p)],[3,Math.max(0,-p)]]){let n=h?p*(e<0?3:-3)*g:0,r=o?1.5:-t*2.6;_.roundRect((h?e*.35:e)-2.1+n,-8.5+r,4.2,8.5,2),v.roundRect((h?e*.35+g:e)-2.6+n,-2.8+r,5.2,3.2,1.5)}L(e,_,s?.legs??`#3d4a6b`,1.4),L(e,v,s?.shoes??`#2b2d42`,1.2);let y=new Path2D;for(let[e,t]of[[-8.2,-p],[8.2,p]]){if(h&&e*g<0)continue;let n=h?t*2.2*g:0;y.roundRect((h?1.5*g:e)-2+n,-18-(o?3:0)+t*1.2,4,8.5,2)}let b=new Path2D;b.roundRect(-7,-20,14,12.5,5),L(e,b,i,1.4),e.save(),e.clip(b),e.fillStyle=`rgba(0, 0, 0, 0.13)`,e.fillRect(h?-7*g:2,-20,h?6*g:5,13),e.restore(),L(e,y,O(i,-.08),1.4);let x=new Path2D;if(x.arc(0,-27.5,9,0,Math.PI*2),L(e,x,l,1.4),e.save(),e.clip(x),e.fillStyle=u,e.beginPath(),c===`back`?e.rect(-10,-40,20,16):h?(e.ellipse(-3*g,-32,9.5,6.5,0,0,Math.PI*2),e.rect(-10*g,-36,7*g,12)):e.ellipse(0,-33.5,11,6.5,0,0,Math.PI*2),e.fill(),e.restore(),d&&c!==`front`&&(e.fillStyle=u,e.strokeStyle=I.ink,e.lineWidth=1.4,e.beginPath(),e.roundRect(h?-9*g-2.5:-7,-28,5,10,2.5),h||e.roundRect(2,-28,5,10,2.5),e.fill(),e.stroke()),c!==`back`){let n=(t+a*977)%3800<130,r=h?[3.6*g]:[-3.2,3.2];e.fillStyle=I.ink,e.strokeStyle=I.ink,e.lineWidth=1.3;for(let t of r)e.beginPath(),n?(e.moveTo(t-1.4,-26.5),e.lineTo(t+1.4,-26.5),e.stroke()):(e.ellipse(t,-26.6,1.25,1.6,0,0,Math.PI*2),e.fill());e.fillStyle=`rgba(255, 120, 120, 0.35)`;for(let t of h?[2*g]:[-5.2,5.2])e.beginPath(),e.ellipse(t,-23.4,1.9,1.2,0,0,Math.PI*2),e.fill();h||(e.beginPath(),e.arc(0,-24,1.8,.15*Math.PI,.85*Math.PI),e.stroke())}e.restore()}function ke(e,t,n,r){let i=new Path2D;for(let[e,t]of[[-9,-11],[5.4,-11],[-9,5.5],[5.4,5.5]])i.roundRect(e,t,3.6,6.5,1.6);e.fillStyle=`#23232b`,e.fill(i);let a=new Path2D;a.roundRect(-8,-15.5,16,31,6.5),L(e,a,t,1.3),e.save(),e.clip(a),e.fillStyle=`rgba(255, 255, 255, 0.22)`,e.fillRect(-8,-15.5,4,31),e.fillStyle=`rgba(0, 0, 0, 0.12)`,e.fillRect(4.5,-15.5,4,31),e.restore();let o=e.createLinearGradient(0,-9,0,-3);o.addColorStop(0,`#d9f4ff`),o.addColorStop(1,`#7cc6ee`),e.fillStyle=o,e.strokeStyle=I.ink,e.lineWidth=1,e.beginPath(),e.roundRect(-6,-9.5,12,6,2),e.fill(),e.stroke(),e.fillStyle=O(t,.18),e.beginPath(),e.roundRect(-6,-2.5,12,9,2.5),e.fill(),e.stroke(),e.fillStyle=`#7cc6ee`,e.beginPath(),e.roundRect(-5.5,7.5,11,4,1.5),e.fill(),e.stroke(),e.strokeStyle=`rgba(255, 255, 255, 0.85)`,e.lineWidth=1.2,e.beginPath(),e.moveTo(-3.5,-8.5),e.lineTo(-1,-4.5),e.stroke();for(let[t,n,r]of[[-6,-15.4,`#ffe066`],[3.6,-15.4,`#ffe066`],[-6,13.6,`#ff6b6b`],[3.6,13.6,`#ff6b6b`]])e.fillStyle=r,e.beginPath(),e.roundRect(t,n,2.4,1.8,.8),e.fill();if(n)for(let t=0;t<3;t++){let n=(r/420+t/3)%1;e.fillStyle=`rgba(255, 255, 255, ${.55*(1-n)})`,e.beginPath(),e.arc(-3+Math.sin(t*2.1)*2,18+n*12,2+n*3,0,Math.PI*2),e.fill()}}function Ae(){let e=de();return{name:`Cartoon`,animated:!0,background(t,n){e(t,e=>Se(e,n),fe(n)),Ce(t)},area(e,t,n,r){let{context:i}=e,a=T(t.colour),o=new Path2D;if(t.shape===`radius`)o.arc(n,r,(t.radius??0)*e.scale,0,Math.PI*2);else{let i=(t.width??0)*e.scale,a=(t.height??0)*e.scale;o.roundRect(n-i/2,r-a/2,i,a,Math.min(16,i/4,a/4))}i.globalAlpha=t.alpha/255*.22,i.fillStyle=a,i.fill(o),i.globalAlpha=Math.max(t.alpha/255,.4),i.strokeStyle=O(a,-.15),i.lineWidth=2.5,i.setLineDash([8,6]),i.lineDashOffset=-e.time/45,i.stroke(o),i.setLineDash([]),i.lineDashOffset=0,i.globalAlpha=1,i.lineWidth=1},route(e,t,n,r){let{context:i,time:a}=e;i.strokeStyle=r,i.globalAlpha=.18,i.lineWidth=9,i.lineCap=`round`,i.beginPath(),i.moveTo(...t),i.lineTo(...n),i.stroke(),i.globalAlpha=1,i.lineCap=`butt`;let o=Math.hypot(n[0]-t[0],n[1]-t[1]),s=a/36%14;i.lineWidth=1.6,i.strokeStyle=O(r,-.25),i.fillStyle=`#ffffff`;for(let e=s;e<o-6;e+=14){let r=e/o;i.beginPath(),i.arc(t[0]+(n[0]-t[0])*r,t[1]+(n[1]-t[1])*r,3,0,Math.PI*2),i.fill(),i.stroke()}i.lineWidth=1},blip(e,t,n,r,i){let{context:a,time:o}=e,s=T(t.colour);if(a.globalAlpha=Math.max(t.alpha/255,.35),t.sprite===8){e.claim(n-3,r-30,22,32,!0);let t=o/1600%1;a.strokeStyle=`rgba(239, 71, 111, ${.7*(1-t)})`,a.lineWidth=2,a.beginPath(),a.ellipse(n,r,6+t*14,(6+t*14)*.4,0,0,Math.PI*2),a.stroke(),R(a,n+2,r,6,2.4);let i=new Path2D;i.roundRect(n-1.3,r-28,2.6,28,1.3),L(a,i,`#e8e2d4`,1);let s=new Path2D,c=e=>Math.sin(o/160-e/4)*1.6*(e/16);s.moveTo(n+1,r-27);for(let e=0;e<=16;e+=2)s.lineTo(n+1+e,r-27+c(e)+e*.06);for(let e=16;e>=0;e-=2)s.lineTo(n+1+e,r-17+c(e)-e*.06);s.closePath(),L(a,s,`#ef476f`,1)}else if(t.shape!==`radius`&&t.shape!==`area`){let c=we(e);e.claim(n-c,r-c*1.35-1,c*2,c*2.1+2,!0);let l=i?5:0,u=Math.sin(o/700+t.handle*1.7)*1.1-l;R(a,n,r+c*.75,c*.85-l*.3,c*.32),a.save(),a.translate(n,r+u-c*.35),i&&a.scale(1.12,1.12),a.fillStyle=O(k(s)>.8?`#9aa5b4`:s,-.35),a.beginPath(),a.arc(0,2.6,c,0,Math.PI*2),a.fill(),a.fillStyle=`#ffffff`,a.beginPath(),a.arc(0,0,c,0,Math.PI*2),a.fill(),a.strokeStyle=k(s)>.8?`#9aa5b4`:s,a.lineWidth=c>10?3:2.4,a.beginPath(),a.arc(0,0,c-1.5,0,Math.PI*2),a.stroke();let d=_(t.sprite);a.fillStyle=Te(s),d===void 0?(a.font=`900 ${Math.round(c)}px ${w}`,a.textAlign=`center`,a.fillText((t.name??`•`).slice(0,1).toUpperCase(),0,c*.36),a.textAlign=`left`):C(a,d,c*1.18),a.restore()}a.globalAlpha=1,a.lineWidth=1},label(e,t,n,r,i){let a=we(e);Ee(e,t,n,[[r+a*.75+9,!0],[r-a*1.45-7,!1]],`#ffffff`,i)},tag(e,t,n,r,i){Ee(e,t,r,[[i-47,!1],[i+10,!0],[i-47,!1,48],[i-47,!1,-48]],n,!0)},entity(e,t,n,r,i,a){let{context:o,time:s}=e;if(t.kind===`player`||t.kind===`ped`){let c=a?.colour??me[t.id%me.length],l=t.kind===`ped`?.86:1.08;if(e.claim(n-10*l,r-37*l,20*l,38*l,!0),a!==void 0){let e=s/2200%1;o.strokeStyle=c,o.lineWidth=2.5,o.beginPath(),o.ellipse(n,r,14,5.5,0,0,Math.PI*2),o.stroke(),o.globalAlpha=1-e,o.lineWidth=1.5,o.beginPath(),o.ellipse(n,r,14+e*12,5.5+e*4.5,0,0,Math.PI*2),o.stroke(),o.globalAlpha=1}o.save(),o.translate(n,r),o.scale(l,l);let u=ye(t.look);return Oe(o,s,i,M(t),u?.top??c,(a?.client??t.id)*7,!1,u),o.restore(),[n,r-14*l]}if(t.kind===`vehicle`){let a=Math.min(Math.max(e.scale/6,.8),1.4),c=M(t),l=i?Math.sin(s/55)*.5:0;return o.save(),o.translate(n+3*a,r+4*a),o.rotate(c),o.scale(a,a),o.fillStyle=`rgba(32, 70, 26, 0.24)`,o.beginPath(),o.roundRect(-9,-15,18,31,7),o.fill(),o.restore(),o.save(),o.translate(n,r+l),o.rotate(c),o.scale(a,a),ke(o,pe[t.id%pe.length],i,s),o.restore(),o.lineWidth=1,[n,r]}R(o,n+2,r+5,8,3);let c=new Path2D;return c.roundRect(n-6,r-6,12,12,2),L(o,c,`#c8915a`,1.2),o.strokeStyle=`#8a5a30`,o.lineWidth=1.2,o.beginPath(),o.moveTo(n-4.5,r-4.5),o.lineTo(n+4.5,r+4.5),o.moveTo(n+4.5,r-4.5),o.lineTo(n-4.5,r+4.5),o.stroke(),o.lineWidth=1,[n,r]},dragging(e,t,n,r){let{context:i,time:a}=e;i.fillStyle=`#ffffff`;let o=Math.hypot(n[0]-t[0],n[1]-t[1]);for(let e=8;e<o-24;e+=12){let r=e/o;i.beginPath(),i.arc(t[0]+(n[0]-t[0])*r,t[1]+(n[1]-t[1])*r,2.2,0,Math.PI*2),i.fill()}R(i,n[0],n[1]+26,9,3.2,.3),i.save(),i.translate(n[0],n[1]+16+Math.sin(a/160)*1.5),i.rotate(Math.sin(a/240)*.08);let s=ye(r.look);Oe(i,a,!1,Math.PI,s?.top??r.colour,r.client*7,!0,s),i.restore()},overlay(e){let{context:t,height:n,time:r}=e,i=n-34;t.fillStyle=`rgba(30, 50, 30, 0.2)`,t.beginPath(),t.arc(34,i+3,21,0,Math.PI*2),t.fill();let a=new Path2D;a.arc(34,i,21,0,Math.PI*2),L(t,a,`#ffffff`,1.2),t.save(),t.translate(34,i),t.rotate(Math.sin(r/900)*.07),t.fillStyle=`#ef476f`,t.beginPath(),t.moveTo(0,-15),t.lineTo(4.5,0),t.lineTo(-4.5,0),t.closePath(),t.fill(),t.fillStyle=`#b8c2cf`,t.beginPath(),t.moveTo(0,15),t.lineTo(4.5,0),t.lineTo(-4.5,0),t.closePath(),t.fill(),t.restore(),t.fillStyle=I.ink,t.beginPath(),t.arc(34,i,2,0,Math.PI*2),t.fill(),t.font=`900 9px ${w}`,t.textAlign=`center`,t.fillText(`N`,34,i-23-3);let o=[5,10,25,50,100,250,500,1e3,2500,5e3].find(t=>t*e.scale>=56)??5e3,s=o*e.scale,c=o>=1e3?`${o/1e3} km`:`${o} m`;t.font=`800 11px ${w}`;let l=Math.max(s,t.measureText(c).width)+20;t.fillStyle=`rgba(30, 50, 30, 0.2)`,t.beginPath(),t.roundRect(66,i-12+2.5,l,26,13),t.fill(),t.fillStyle=`#ffffff`,t.beginPath(),t.roundRect(66,i-12,l,26,13),t.fill(),t.fillStyle=I.text,t.fillText(c,66+l/2,i+1),t.fillStyle=I.ink,t.fillRect(66+(l-s)/2,i+6,s/2,3),t.fillStyle=`#b8c2cf`,t.fillRect(66+l/2,i+6,s/2,3),t.textAlign=`left`}}}var je=[[],[[3,2]],[[2,1]],[[3,1]],[[0,1]],[[0,3],[1,2]],[[0,2]],[[0,3]],[[0,3]],[[0,2]],[[0,1],[3,2]],[[0,1]],[[3,1]],[[1,2]],[[3,2]],[]];function Me(e){let{context:t,width:n,height:r}=e,i=P(e,520),a=Math.ceil(n/9)+1,o=Math.ceil(r/9)+1,[s,c]=e.toWorld(0,0),l=9/e.scale,u=new Float32Array(a*o);for(let e=0;e<o;e++)for(let t=0;t<a;t++)u[e*a+t]=ue((s+t*l)/i,(c-e*l)/i);let d=.3,f=.04,p=Array.from({length:12},()=>new Path2D);for(let e=0;e<o-1;e++)for(let t=0;t<a-1;t++){let n=u[e*a+t],r=u[e*a+t+1],i=u[(e+1)*a+t+1],o=u[(e+1)*a+t],s=Math.max(n,r,i,o);for(let a=Math.max(Math.ceil((Math.min(n,r,i,o)-d)/f),0);a<p.length&&d+a*f<=s;a++){let s=d+a*f,c=a=>a===0?[(t+(s-n)/(r-n))*9,e*9]:a===1?[(t+1)*9,(e+(s-r)/(i-r))*9]:a===2?[(t+(s-o)/(i-o))*9,(e+1)*9]:[t*9,(e+(s-n)/(o-n))*9],l=(n>s?8:0)|(r>s?4:0)|(i>s?2:0)|o>s;for(let[e,t]of je[l])p[a].moveTo(...c(e)),p[a].lineTo(...c(t))}}t.lineWidth=1,p.forEach((e,n)=>{t.strokeStyle=n%4==3?`rgba(150, 200, 235, 0.13)`:`rgba(150, 200, 235, 0.055)`,t.stroke(e)})}function Ne(e){let t=`#c65ad8`,n=`#05080b`,r=(e,t=600)=>`semi-condensed ${t} ${e}px ${ie}`,i=e=>e>=760,a=de(1),o=e=>{e.fillStyle=`rgba(0, 0, 0, 0.4)`,e.beginPath(),e.ellipse(0,0,4.5,1.8,0,0,Math.PI*2),e.fill();let r=new Path2D;r.moveTo(0,0),r.bezierCurveTo(-1.8,-5,-7,-8,-7,-13.5),r.arc(0,-13.5,7,Math.PI,0),r.bezierCurveTo(7,-8,1.8,-5,0,0),r.closePath(),e.lineWidth=3,e.lineJoin=`round`,e.strokeStyle=n,e.stroke(r),e.fillStyle=t,e.fill(r),e.fillStyle=`#ffffff`,e.beginPath(),e.arc(0,-13.5,2.6,0,Math.PI*2),e.fill()},s=(e,t)=>{let r=new Path2D;r.moveTo(0,-12),r.lineTo(8.5,9),r.lineTo(0,4.5),r.lineTo(-8.5,9),r.closePath(),e.lineJoin=`round`,e.lineWidth=3.5,e.strokeStyle=n,e.stroke(r),e.fillStyle=t,e.fill(r),e.fillStyle=`rgba(255, 255, 255, 0.35)`,e.beginPath(),e.moveTo(0,-12),e.lineTo(0,4.5),e.lineTo(-8.5,9),e.closePath(),e.fill()},c=(e,t,n,i)=>{e.strokeStyle=`#ffffff`,e.fillStyle=`#ffffff`,e.lineWidth=1.4,e.beginPath(),e.roundRect(t,n,11,16,5.5),e.stroke(),e.beginPath(),e.moveTo(t,n+6.5),e.lineTo(t+11,n+6.5),e.moveTo(t+5.5,n),e.lineTo(t+5.5,n+6.5),e.stroke(),e.beginPath(),i===`wheel`?e.roundRect(t+4.2,n+1.8,2.6,4,1.3):(e.moveTo(t+5.5,n+.7),e.lineTo(t+5.5,n+6.5),e.lineTo(t+.7,n+6.5),e.arc(t+5.5,n+5.5,4.8,Math.PI,Math.PI*1.5)),e.fill(),i===`twice`&&(e.font=r(9,700),e.fillText(`2`,t+13,n+6))};return{name:`GTA`,animated:!0,instructions:!0,insets:e=>({top:48,right:i(e)?260:0,bottom:42,left:0}),background(t){let{context:n,width:i,height:o}=t,s=n.createRadialGradient(i*.45,o*.55,0,i*.45,o*.55,Math.hypot(i,o)*.62);s.addColorStop(0,`#1d3448`),s.addColorStop(1,`#0c1824`),n.fillStyle=s,n.fillRect(0,0,i,o);let c=e();if(c!==void 0){let[e,r]=t.toScreen(c.left,c.top),[i,a]=t.toScreen(c.right,c.bottom);n.drawImage(c.image,e,r,i-e,a-r)}else a(t,Me);A(t,{line:`rgba(140, 180, 215, 0.09)`,axis:`rgba(140, 180, 215, 0.26)`,text:`rgba(180, 205, 228, 0.5)`},r(10),[],48);let l=n.createRadialGradient(i/2,o/2,Math.min(i,o)*.4,i/2,o/2,Math.hypot(i,o)*.6);l.addColorStop(0,`rgba(0, 0, 0, 0)`),l.addColorStop(1,`rgba(0, 0, 0, 0.45)`),n.fillStyle=l,n.fillRect(0,0,i,o)},area(e,t,n,r){let{context:i}=e,a=T(t.colour),o=new Path2D;if(t.shape===`radius`)o.arc(n,r,(t.radius??0)*e.scale,0,Math.PI*2);else{let i=(t.width??0)*e.scale,a=(t.height??0)*e.scale;o.rect(n-i/2,r-a/2,i,a)}i.globalAlpha=t.alpha/255*.3,i.fillStyle=a,i.fill(o),i.globalAlpha=Math.max(t.alpha/255,.3)*.7,i.strokeStyle=a,i.lineWidth=1.5,i.stroke(o),i.globalAlpha=1,i.lineWidth=1},route(e,n,r){let{context:i,time:a}=e;i.lineCap=`round`;for(let[e,a]of[[`#16081c`,8],[t,4.5]])i.strokeStyle=e,i.lineWidth=a,i.beginPath(),i.moveTo(...n),i.lineTo(...r),i.stroke();let o=Math.hypot(r[0]-n[0],r[1]-n[1]),s=Math.atan2(r[1]-n[1],r[0]-n[0]);i.strokeStyle=`rgba(255, 255, 255, 0.8)`,i.lineWidth=1.6;for(let e=a/24%26;e<o-14;e+=26){let t=e/o;i.save(),i.translate(n[0]+(r[0]-n[0])*t,n[1]+(r[1]-n[1])*t),i.rotate(s),i.beginPath(),i.moveTo(-1.8,-2.6),i.lineTo(1.4,0),i.lineTo(-1.8,2.6),i.stroke(),i.restore()}i.lineCap=`butt`,i.lineWidth=1},blip(e,t,r,i,a){let{context:s,time:c}=e;if(t.sprite===8?e.claim(r-8,i-22,16,24,!0):t.shape!==`radius`&&t.shape!==`area`&&e.claim(r-9,i-9,18,18,!0),s.globalAlpha=Math.max(t.alpha/255,.3),s.strokeStyle=n,s.save(),s.translate(r,i),t.sprite===8)o(s);else if(t.shape!==`radius`&&t.shape!==`area`){let e=_(t.sprite);s.fillStyle=T(t.colour),e===void 0?(s.lineWidth=3,s.beginPath(),s.arc(0,0,5.5,0,Math.PI*2),s.stroke(),s.fill()):C(s,e,17,1.6)}if(s.restore(),s.globalAlpha=1,a){let e=15+Math.sin(c/160);s.strokeStyle=`#ffffff`,s.lineWidth=2;for(let t=0;t<4;t++){let n=t*Math.PI/2+Math.PI/4;s.beginPath(),s.arc(r,i,e,n-.42,n+.42),s.stroke()}s.lineWidth=1}},label(e,t,i,a,o){oe(e,t.toUpperCase(),[[i+12,a+4,`left`],[i-12,a+4,`right`],[i,a+22,`center`],[i,a-14,`center`]],`#ffffff`,n,r(11,700),o)},tag(e,t,n,i,a){let{context:o}=e;o.font=r(11,700);let s=t.toUpperCase(),c=Math.ceil(o.measureText(s).width)+15,l=[[i-c/2,a+16],[i-c/2,a-33],[i+15,a-8.5],[i-15-c,a-8.5]],u=l[j(e,c,17,l,!0)];o.fillStyle=`rgba(0, 0, 0, 0.8)`,o.fillRect(u[0],u[1],c,17),o.fillStyle=n,o.fillRect(u[0],u[1],3,17),o.fillStyle=`#ffffff`,o.fillText(s,u[0]+9,u[1]+12.5)},entity(e,t,r,i,a,o){let{context:c,time:l}=e;if(t.kind===`player`){let n=o?.colour??`#ffffff`;e.claim(r-10,i-12,20,22,!0),c.save(),c.translate(r,i),c.rotate(M(t));let a=c.createRadialGradient(0,0,0,0,0,44);a.addColorStop(0,`rgba(255, 255, 255, 0.32)`),a.addColorStop(1,`rgba(255, 255, 255, 0)`),c.fillStyle=a,c.globalAlpha=.8+Math.sin(l/500)*.2,c.beginPath(),c.moveTo(0,0),c.arc(0,0,44,-Math.PI/2-.55,-Math.PI/2+.55),c.closePath(),c.fill(),c.globalAlpha=1,s(c,n),c.restore(),c.lineWidth=1}else if(t.kind===`vehicle`){c.save(),c.translate(r,i),c.rotate(M(t));let e=new Path2D;e.roundRect(-5,-9,10,18,3),c.lineWidth=3,c.strokeStyle=n,c.stroke(e),c.fillStyle=`#dbe3ea`,c.fill(e),c.fillStyle=`#2b3743`,c.beginPath(),c.roundRect(-3.6,-5,7.2,3.4,1),c.roundRect(-3.6,3.6,7.2,2.4,1),c.fill(),c.restore(),c.lineWidth=1}else c.lineWidth=2.5,c.strokeStyle=n,c.fillStyle=t.kind===`ped`?`#c9d1d9`:`#8b98a5`,c.beginPath(),t.kind===`ped`?c.arc(r,i,3.8,0,Math.PI*2):c.rect(r-3.5,i-3.5,7,7),c.stroke(),c.fill(),c.lineWidth=1;return[r,i]},dragging(e,t,n,r){let{context:i}=e;i.strokeStyle=`rgba(255, 255, 255, 0.7)`,i.lineWidth=1.5,i.setLineDash([5,5]),i.beginPath(),i.moveTo(...t),i.lineTo(...n),i.stroke(),i.setLineDash([]),i.save(),i.translate(...n),i.globalAlpha=.7,s(i,r.colour),i.restore(),i.globalAlpha=1,i.lineWidth=1},overlay(e,t,a,o){let{context:s,width:l,height:u}=e,d=s.createLinearGradient(0,0,0,48);d.addColorStop(0,`rgba(3, 6, 9, 0.94)`),d.addColorStop(1,`rgba(3, 6, 9, 0.78)`),s.fillStyle=d,s.fillRect(0,0,l,48),s.fillStyle=`rgba(255, 255, 255, 0.12)`,s.fillRect(0,47,l,1),s.fillStyle=`#ffffff`,s.font=`italic ${r(25,700)}`,s.fillText(`FIVERUNNER`,18,33);let f=s.measureText(`FIVERUNNER`).width,p=a.find(({client:e})=>e===o)?.colour??`#f0a030`;s.font=r(13,700);let m=s.measureText(`MAP`).width+28,h=18+f+18;s.fillStyle=`#ffffff`,s.fillRect(h,12,m,26),s.fillStyle=p,s.fillRect(h,12,m,3),s.fillStyle=`#05080b`,s.fillText(`MAP`,h+14,30.5),s.textAlign=`right`;let g=l-18;s.fillStyle=`rgba(220, 230, 240, 0.7)`,s.font=r(12,600);let v=`${t.length} ${t.length===1?`BLIP`:`BLIPS`}`;s.fillText(v,g,29),g-=s.measureText(v).width+22;for(let e of[...a].reverse()){if(e.name===void 0)continue;let t=e.name.toUpperCase();s.font=r(13,700),s.fillStyle=o===void 0||o===e.client?`#ffffff`:`rgba(255, 255, 255, 0.45)`,s.fillText(t,g,29);let n=s.measureText(t).width;if(s.fillStyle=e.colour,s.beginPath(),s.arc(g-n-9,25,4,0,Math.PI*2),s.fill(),g-=n+30,g<h+m+40)break}if(s.textAlign=`left`,i(l)){let e=new Map;for(let n of t){if(n.name===void 0)continue;let t=e.get(n.name);t===void 0?e.set(n.name,{blip:n,count:1}):t.count++}if(e.size>0){let t=[...e.entries()].sort(([e],[t])=>e.localeCompare(t)),i=l-236-14,a=Math.max(Math.floor((u-62-28-30-36)/22),1),o=t.length>a?t.slice(0,a-1):t,c=t.length-o.length,d=36+(o.length+ +(c>0))*22+6;s.fillStyle=`rgba(3, 6, 9, 0.78)`,s.fillRect(i,62,236,d),s.fillStyle=p,s.fillRect(i,62,236,2),s.fillStyle=`#ffffff`,s.font=r(14,700),s.fillText(`LEGEND`,i+12,86),s.textAlign=`right`,s.fillStyle=`rgba(220, 230, 240, 0.6)`,s.font=r(12,600),s.fillText(String(e.size),i+236-12,86),s.textAlign=`left`,o.forEach(([e,{blip:t,count:a}],o)=>{let c=98+o*22;o%2==0&&(s.fillStyle=`rgba(255, 255, 255, 0.035)`,s.fillRect(i,c,236,22)),s.save(),s.translate(i+22,c+11),s.fillStyle=T(t.colour),s.strokeStyle=n;let l=_(t.sprite);l===void 0?(s.lineWidth=2.4,s.beginPath(),s.arc(0,0,4.5,0,Math.PI*2),s.stroke(),s.fill()):C(s,l,14,1.2),s.restore(),s.font=r(12,600);let u=e.toUpperCase();for(;u.length>1&&s.measureText(u).width>146;)u=u.slice(0,-1);u!==e.toUpperCase()&&(u=`${u.trimEnd()}…`),s.fillStyle=`#eef3f8`,s.fillText(u,i+40,c+15.5),s.textAlign=`right`,s.fillStyle=`rgba(200, 215, 230, 0.55)`,s.font=r(11,600),s.fillText(`×${a}`,i+236-12,c+15.5),s.textAlign=`left`}),c>0&&(s.fillStyle=`rgba(200, 215, 230, 0.6)`,s.font=r(11,700),s.fillText(`+ ${c} MORE`,i+40,98+o.length*22+15.5))}}let y=[[`left`,`MOVE PLAYER`],[`twice`,`WAYPOINT`],[`wheel`,`ZOOM`]];s.font=r(11,700);let b=y.map(([,e])=>s.measureText(e).width+36),x=l-14-b.reduce((e,t)=>e+t,0)-8,S=u-14-28;s.fillStyle=`rgba(3, 6, 9, 0.78)`,s.fillRect(x,S,l-14-x,28),x+=12,y.forEach(([e,t],n)=>{c(s,x,S+6,e),s.fillStyle=`#ffffff`,s.font=r(11,700),s.fillText(t,x+22,S+18.5),x+=b[n]}),s.lineWidth=1}}}var Pe=7,z={left:-4e3,right:4500,bottom:-4e3,top:8e3},B={top:0,right:0,bottom:0,left:0},Fe=450,Ie=`fiverunner:map-style`,Le=`fiverunner:map-image`;function Re(e){try{return localStorage.getItem(e)}catch{return null}}function ze(e,t){try{localStorage.setItem(e,t)}catch{}}var Be=class{element;#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f={entities:[],blips:[]};#p=[];#m=(z.left+z.right)/2;#h=(z.bottom+z.top)/2;#g=.05;#_=!1;#v=[];#y=new Map;#b=new Map;#x=!1;#S=!0;#C;#w;constructor(e,t,n){this.element=e,this.#s=t,this.#l=n,this.#c=[F,Ae(),Ne(()=>this.#d)],this.#u=this.#c.find(({name:e})=>e===Re(Ie))??F;let r=document.createElement(`div`);r.className=`toolbar`;let i=document.createElement(`h2`);i.textContent=`Map`,this.#a=document.createElement(`select`),this.#a.setAttribute(`aria-label`,`Whose blips the map shows`),this.#a.addEventListener(`change`,()=>this.#R());let a=document.createElement(`select`);a.setAttribute(`aria-label`,`How the map looks`),a.append(...this.#c.map(({name:e})=>new Option(e,e))),a.value=this.#u.name,a.addEventListener(`change`,()=>{this.use(a.value),this.#s.styled?.(a.value)});let o=document.createElement(`button`);o.type=`button`,o.textContent=`Fit`,o.addEventListener(`click`,()=>{this.#_=!1,this.#M()}),this.#o=this.#E(),this.#i=document.createElement(`span`),this.#i.className=`hint`,this.#i.textContent=`Drag a player to move them, double-click to set their waypoint`,r.append(i,this.#a,a,o,this.#o,this.#i);let s=document.createElement(`div`);s.className=`view`,this.#n=s,this.#e=document.createElement(`canvas`),this.#t=this.#e.getContext(`2d`),this.#r=document.createElement(`div`),this.#r.className=`tooltip`,this.#r.hidden=!0,s.append(this.#e,this.#r),e.append(...n===void 0?[r,s]:[s]),new ResizeObserver(()=>this.#R()).observe(s),new IntersectionObserver(([e])=>{this.#S=e?.isIntersecting??!0,this.#T()}).observe(s),n===void 0&&this.#I(),this.use(this.#u.name)}show(e,t){let n=performance.now();for(let t of e.entities){let e=this.#b.get(t.id);if(this.#u.animated&&e!==void 0&&(e[0]!==t.x||e[1]!==t.y)){let[r,i]=this.#j(t.id,e,n);this.#y.set(t.id,{fromX:r,fromY:i,toX:t.x,toY:t.y,start:n})}this.#b.set(t.id,[t.x,t.y])}if(this.#f=e,t.map(({client:e,name:t})=>`${e} ${t}`).join()!==this.#p.map(({client:e,name:t})=>`${e} ${t}`).join()){let e=this.#a.value;this.#a.replaceChildren(new Option(`Blips of every player`,``),...t.map(({client:e,name:t})=>new Option(`Blips of ${t} (${e})`,String(e)))),this.#a.value=t.some(({client:t})=>String(t)===e)?e:``}this.#p=t,this.#_?this.#R():this.#M()}use(e){this.#u=this.#c.find(t=>t.name===e)??F,this.#l===void 0&&ze(Ie,this.#u.name),this.#y.clear(),this.#o.hidden=this.#u.name!==`GTA`,this.#i.hidden=this.#u.instructions===!0,this.#n.dataset.style=this.#u.name,this.#_?this.#R():this.#M(),this.#T()}#T(){if(this.#x||!this.#u.animated||!this.#S)return;this.#x=!0;let e=()=>{!this.#u.animated||!this.#S?this.#x=!1:(this.#R(),requestAnimationFrame(e))};requestAnimationFrame(e)}#E(){let e=document.createElement(`details`);e.className=`map-image`;let t=document.createElement(`summary`);t.textContent=`Map image`;let n=document.createElement(`input`);n.type=`file`,n.accept=`image/*`,n.setAttribute(`aria-label`,`An image of the world to show under the map`);let r=JSON.parse(Re(Le)??`null`)??[z.left,z.top,z.right,z.bottom],i=[`Left`,`Top`,`Right`,`Bottom`].map((e,t)=>{let n=document.createElement(`input`);return n.type=`number`,n.value=String(r[t]),n.setAttribute(`aria-label`,`The ${e.toLowerCase()} edge of the image, in metres of the world`),n.title=`${e} edge, in metres`,n}),a,o=()=>{let[e,t,n,r]=i.map(e=>Number(e.value));ze(Le,JSON.stringify([e,t,n,r])),this.#d=a===void 0?void 0:{image:a,left:e,top:t,right:n,bottom:r},this.#R()};n.addEventListener(`change`,()=>{let e=n.files?.[0];if(e===void 0)return;let t=new Image;t.addEventListener(`load`,()=>{a=t,o()}),t.src=URL.createObjectURL(e)});for(let e of i)e.addEventListener(`change`,o);return e.append(t,n,...i),e}get#D(){let e=this.#a.value;return e===``?this.#f.blips:this.#f.blips.filter(({client:t})=>String(t)===e)}get#O(){let e=this.#a.value;return e===``?void 0:Number(e)}get#k(){return this.#p.map(({client:e,name:t})=>{let n=this.#f.entities.find(({kind:t,owner:n})=>t===`player`&&n===e)?.look;return{client:e,name:t,colour:E(e),...n===void 0?{}:{look:n}}})}get#A(){let e=this.#a.value;return e===``?this.#p.find(({state:e})=>e===`joined`)?.client:Number(e)}#j(e,t,n){let r=this.#y.get(e);if(r===void 0)return[t[0],t[1]];let i=Math.min((n-r.start)/Fe,1);i===1&&this.#y.delete(e);let a=1-(1-i)**3;return[r.fromX+(r.toX-r.fromX)*a,r.fromY+(r.toY-r.fromY)*a]}#M(){if(this.#l!==void 0)return this.#R();let e=[...this.#D,...this.#f.entities],t=this.#e.getBoundingClientRect();if(t.width===0||t.height===0)return;let n=this.#u.insets?.(t.width,t.height)??B,r=Math.max(t.width-n.left-n.right,80),i=Math.max(t.height-n.top-n.bottom,80),a=z.left,o=z.right,s=z.bottom,c=z.top;e.length>0&&(a=Math.min(...e.map(({x:e})=>e)),o=Math.max(...e.map(({x:e})=>e)),s=Math.min(...e.map(({y:e})=>e)),c=Math.max(...e.map(({y:e})=>e)));let l=Math.max(o-a,c-s,200)*.15;this.#g=Math.min(r/(o-a+2*l),i/(c-s+2*l)),this.#m=(a+o)/2-(n.left-n.right)/2/this.#g,this.#h=(s+c)/2+(n.top-n.bottom)/2/this.#g,this.#R()}#N(){return this.#l??this.#e.getBoundingClientRect()}#P(e,t){let{width:n,height:r}=this.#N();return[(e-this.#m)*this.#g+n/2,(this.#h-t)*this.#g+r/2]}#F(e,t){let{width:n,height:r}=this.#N();return[(e-n/2)/this.#g+this.#m,this.#h-(t-r/2)/this.#g]}#I(){let e=this.#e,t=t=>{let n=e.getBoundingClientRect();return[t.clientX-n.left,t.clientY-n.top]};e.addEventListener(`wheel`,e=>{e.preventDefault(),this.#_=!0;let[n,r]=t(e),[i,a]=this.#F(n,r);this.#g=Math.min(Math.max(this.#g*(e.deltaY<0?1.25:.8),.005),40);let[o,s]=this.#F(n,r);this.#m+=i-o,this.#h+=a-s,this.#R()}),e.addEventListener(`mousedown`,e=>{let[n,r]=t(e),i=this.#L(n,r);i?.kind===`entity`&&i.entity.kind===`player`&&i.entity.owner!==void 0?(this.#_=!0,this.#w={kind:`player`,client:i.entity.owner,x:n,y:r}):this.#w={kind:`pan`,x:n,y:r,cx:this.#m,cy:this.#h}}),e.addEventListener(`mousemove`,e=>{let[n,r]=t(e),i=this.#w;i?.kind===`pan`?(this.#_=!0,this.#m=i.cx-(n-i.x)/this.#g,this.#h=i.cy+(r-i.y)/this.#g):i?.kind===`player`?(i.x=n,i.y=r):this.#C=this.#L(n,r)?.key,this.#R()}),e.addEventListener(`mouseup`,e=>{let n=this.#w;if(this.#w=void 0,n?.kind===`player`){let r=this.#L(...t(e),`blip`);r?.kind===`blip`?this.#s.teleport(n.client,r.blip.x,r.blip.y,r.blip.z):this.#s.teleport(n.client,...this.#F(...t(e)))}this.#R()}),e.addEventListener(`mouseleave`,()=>{this.#w=void 0,this.#C=void 0,this.#R()}),e.addEventListener(`dblclick`,e=>{let n=this.#A;if(n===void 0)return;let[r,i]=this.#F(...t(e));this.#s.waypoint(n,r,i)})}#L(e,t,n){let r,i=12;for(let a of this.#v){if(n!==void 0&&a.kind!==n)continue;let o=Math.hypot(a.sx-e,a.sy-t);o<=i&&(i=o,r=a)}return r}#R(){let e=this.#e,t=e.getBoundingClientRect();if(t.width===0||t.height===0)return;let{width:n,height:r}=this.#N(),i=devicePixelRatio*(t.width/n);(e.width!==Math.round(t.width*devicePixelRatio)||e.height!==Math.round(t.height*devicePixelRatio))&&(e.width=Math.round(t.width*devicePixelRatio),e.height=Math.round(t.height*devicePixelRatio));let a=performance.now(),o=this.#l;if(o!==void 0){let e=this.#f.entities.find(({kind:e,owner:t})=>e===`player`&&t===o.client);e!==void 0&&([this.#m,this.#h]=this.#j(e.id,[e.x,e.y],a)),this.#g=Pe}e.dataset.view=`${this.#m} ${this.#h} ${this.#g}`,e.dataset.players=JSON.stringify(this.#f.entities.flatMap(({kind:e,owner:t,x:n,y:r})=>e===`player`&&t!==void 0?[[t,n,r]]:[]));let s=this.#t;s.setTransform(i,0,0,i,0,0);let c=[],l={context:s,width:n,height:r,ratio:i,bare:o!==void 0,scale:this.#g,time:a,toScreen:(e,t)=>this.#P(e,t),toWorld:(e,t)=>this.#F(e,t),claim:(e,t,n,r,i=!1)=>{let a=!c.some(([i,a,o,s])=>e<i+o&&i<e+n&&t<a+s&&a<t+r);return(a||i)&&c.push([e,t,n,r]),a||i},crowding:(e,t,n,r)=>c.reduce((i,[a,o,s,c])=>i+Math.max(0,Math.min(e+n,a+s)-Math.max(e,a))*Math.max(0,Math.min(t+r,o+c)-Math.max(t,o)),0)},u=this.#u,d=this.#D,f=o===void 0?u.insets?.(n,r)??B:B;l.claim(0,0,n,f.top,!0),l.claim(n-f.right,0,f.right,r,!0),l.claim(0,r-f.bottom,n,f.bottom,!0),l.claim(0,0,f.left,r,!0),u.background(l,d),this.#v=[];let p=this.#f.entities.map(e=>{let t=this.#y.has(e.id),[n,r]=this.#j(e.id,[e.x,e.y],a);return{entity:e,moving:t,at:this.#P(n,r)}});for(let e of d)(e.shape===`radius`||e.shape===`area`)&&u.area(l,e,...this.#P(e.x,e.y));for(let e of d){if(!e.route)continue;let t=p.find(({entity:t})=>t.kind===`player`&&t.owner===e.client);t!==void 0&&u.route(l,t.at,this.#P(e.x,e.y),T(e.colour))}for(let e of d){let[t,n]=this.#P(e.x,e.y),r=`blip ${e.client} ${e.handle}`;this.#v.push({key:r,kind:`blip`,blip:e,sx:t,sy:n}),u.blip(l,e,t,n,this.#C===r)}let m=this.#k,h=[];for(let{entity:e,moving:t,at:n}of[...p].sort((e,t)=>e.at[1]-t.at[1])){let r=e.kind===`player`&&e.owner!==void 0?m.find(({client:t})=>t===e.owner)??{client:e.owner,name:void 0,colour:E(e.owner)}:void 0,[i,a]=u.entity(l,e,...n,t,r);this.#v.push({key:`entity ${e.id}`,kind:`entity`,entity:e,sx:i,sy:a}),r?.name!==void 0&&h.push([r.name,r.colour,...n])}for(let e of h)u.tag(l,...e);let g=this.#C,_=this.#v.filter(e=>e.kind===`blip`&&(e.key===g||this.#g>=.12));_.sort((e,t)=>Number(t.key===g)-Number(e.key===g));for(let e of _)e.kind===`blip`&&e.blip.name!==void 0&&u.label(l,e.blip.name,e.sx,e.sy,e.key===g);let v=this.#w;if(v?.kind===`player`){let e=p.find(({entity:e})=>e.kind===`player`&&e.owner===v.client)?.at,t=m.find(({client:e})=>e===v.client);u.dragging!==void 0&&e!==void 0&&t!==void 0?u.dragging(l,e,[v.x,v.y],t):(s.strokeStyle=E(v.client),s.setLineDash([4,4]),s.beginPath(),s.arc(v.x,v.y,9,0,Math.PI*2),s.stroke(),s.setLineDash([]))}o===void 0&&u.overlay?.(l,d,m,this.#O),this.#z()}#z(){let e=this.#w===void 0?this.#C:void 0,t=this.#v.find(({key:t})=>t===e);if(this.#r.hidden=t===void 0,t===void 0)return;let n=e=>this.#p.find(t=>t.client===e)?.name??`nobody`,r=(e,t)=>`${e.toFixed(1)}, ${t.toFixed(1)}`;this.#r.textContent=t.kind===`blip`?`${t.blip.name??(t.blip.sprite===8?`Waypoint`:`Blip`)}\n${r(t.blip.x,t.blip.y)}\nsprite ${t.blip.sprite}, colour ${t.blip.colour}\n${t.blip.script??`the player`}, on the map of ${n(t.blip.client)}`:`${t.entity.kind} ${t.entity.id}, model 0x${(t.entity.model>>>0).toString(16)}\n${r(t.entity.x,t.entity.y)}, z ${t.entity.z.toFixed(1)}, heading ${t.entity.heading.toFixed(0)}\nowned by ${n(t.entity.owner)}`,this.#r.style.left=`${t.sx+14}px`,this.#r.style.top=`${t.sy+14}px`}},V=1920,Ve=1080,He=250,Ue={Escape:`ESCAPE`,Enter:`RETURN`,Backspace:`BACK`,Tab:`TAB`,Space:`SPACE`,CapsLock:`CAPITAL`,ShiftLeft:`LSHIFT`,ShiftRight:`RSHIFT`,ControlLeft:`LCONTROL`,ControlRight:`RCONTROL`,AltLeft:`LMENU`,AltRight:`RMENU`,ArrowUp:`UP`,ArrowDown:`DOWN`,ArrowLeft:`LEFT`,ArrowRight:`RIGHT`,PageUp:`PAGEUP`,PageDown:`PAGEDOWN`,Home:`HOME`,End:`END`,Insert:`INSERT`,Delete:`DELETE`,NumpadMultiply:`MULTIPLY`,NumpadAdd:`ADD`,NumpadSubtract:`SUBTRACT`,NumpadDecimal:`DECIMAL`,NumpadDivide:`DIVIDE`};function We(e){return/^Key[A-Z]$/.test(e)?e.slice(3):/^Digit\d$/.test(e)?e.slice(5):/^F\d{1,2}$/.test(e)?e:/^Numpad\d$/.test(e)?`NUMPAD${e.slice(6)}`:Ue[e]}var Ge=class{element;world;#e;#t;#n;#r;#i;#a;#o=new Map;#s=new Map;#c=new Map;#l=0;#u=[];#d=[];#f=1;#p=new Set;constructor(e,t,n,r){this.#n=e,this.#r=t,this.#i=n,this.#a=r,this.element=document.createElement(`div`),this.element.className=`screen`,this.element.tabIndex=0;let i=document.createElement(`div`);i.className=`world`,this.world=new Be(i,{teleport:()=>{},waypoint:()=>{}},{client:e,width:V/2,height:Ve/2}),this.#e=document.createElement(`div`),this.#e.className=`fade`,this.element.append(i,this.#e),this.#t=document.createElement(`div`),this.#t.className=`viewport`,this.#t.style.width=`${V}px`,this.#t.style.height=`${Ve}px`,this.element.append(this.#t),new ResizeObserver(()=>{this.#f=this.element.clientWidth/V,this.#t.style.transform=`scale(${this.#f})`}).observe(this.element),this.element.addEventListener(`keydown`,e=>this.#_(e,!0)),this.element.addEventListener(`keyup`,e=>this.#_(e,!1)),this.element.addEventListener(`blur`,()=>{for(let e of this.#p)this.#a.key(e,!1);this.#p.clear()}),this.element.addEventListener(`mousedown`,()=>this.element.focus()),this.element.addEventListener(`mousemove`,e=>{let t=this.#t.getBoundingClientRect();this.#v((e.clientX-t.left)/this.#f,(e.clientY-t.top)/this.#f)})}frameOf(e){for(let[t,n]of this.#o)if(n.contentWindow===e)return t}fade(e){this.#e.style.opacity=String(e)}blur(e){this.element.classList.toggle(`blurred`,e)}cursorOver(e,t){this.#v(e,t)}async create({resource:e,url:t}){let n=++this.#l;this.#c.set(e,n),this.#s.set(e,[]);let r=o(t,this.#n,this.#r,this.#i);if(await this.#a.bridge(r),this.#c.get(e)!==n)return;this.#c.delete(e);let i=document.createElement(`iframe`);i.name=e,i.style.visibility=`hidden`,i.allow=`microphone *; camera *; autoplay; payment 'none'; geolocation 'none';`,i.sandbox.value=`allow-forms allow-scripts allow-same-origin`,i.src=r,i.tabIndex=-1,i.addEventListener(`load`,()=>{i.style.visibility=`visible`,setTimeout(()=>{for(let t of this.#s.get(e)??[])this.#m(i,t);this.#s.delete(e)},He)}),this.#o.set(e,i),this.#u.push(e);let a=document.activeElement;this.#t.append(i),a instanceof HTMLIFrameElement&&a!==i&&a.focus()}destroy(e){this.#c.delete(e),this.#s.delete(e);let t=this.#o.get(e);t!==void 0&&(this.#u=this.#u.filter(t=>t!==e),t.remove(),this.#o.delete(e))}message(e,t){let n=this.#s.get(e),r=this.#o.get(e);n===void 0?r!==void 0&&this.#m(r,t):n.push(t)}#m(e,t){e.contentWindow?.postMessage(JSON.parse(t),`*`)}frameFocus(e,t){t?this.#h(e):this.#g(e)}zIndex(e,t){let n=this.#o.get(e);n!==void 0&&(n.style.zIndex=String(t))}focus(e,t){this.element.classList.toggle(`nui-cursor`,t),this.element.classList.toggle(`nui-focus`,e);let n=document.activeElement;!e&&n instanceof HTMLIFrameElement&&this.frameOf(n.contentWindow)&&this.element.focus()}#h(e){this.#u=[...this.#u.filter(t=>t!==e),e],this.#d=[e,...this.#d.filter(t=>t!==e)],this.#u.forEach((e,t)=>{let n=this.#o.get(e);n!==void 0&&(n.style.zIndex=String(t))});let t=this.#o.get(e);t!==void 0&&(t.style.zIndex=`99999`,t.contentWindow?.focus())}#g(e){this.#d=this.#d.filter(t=>t!==e),this.#o.get(e)?.contentWindow?.blur();let[t]=this.#d;t!==void 0&&this.#h(t)}#_(e,t){let n=We(e.code);if(n!==void 0&&e.target===this.element&&(e.preventDefault(),!(t&&e.repeat))){if(t)this.#p.add(n);else if(!this.#p.delete(n))return;this.#a.key(n,t)}}#v(e,t){this.#a.cursor(Math.round(e),Math.round(t))}};function H(e){return document.getElementById(e)}function Ke(){let e=`fiverunner:tab`;try{let t=sessionStorage.getItem(e);if(t!==null&&/^[a-z0-9]{1,16}$/.test(t))return t;let n=Math.random().toString(36).slice(2,10);return sessionStorage.setItem(e,n),n}catch{return Math.random().toString(36).slice(2,10)}}var qe=Ke(),Je=location.port,Ye=new Worker(new URL(`/__fiverunner/assets/worker-BVHTktyY.js`,``+import.meta.url),{type:`module`}),U=e=>Ye.postMessage(e),Xe=H(`status`),Ze=H(`project`),W=new u(H(`console`)),Qe=H(`resources-list`),$e=H(`player-list`),G=new f(H(`events`),H(`emit`),{emit:(e,t,n)=>U({type:`emit`,name:e,args:t,target:n})}),et=H(`bags`),tt=new Be(H(`map`),{teleport:(e,t,n,r)=>U({type:`teleport`,client:e,x:t,y:n,...r===void 0?{}:{z:r}}),waypoint:(e,t,n)=>U({type:`waypoint`,client:e,x:t,y:n}),styled:e=>{for(let t of K.values())t.screen.world.use(e)}}),K=new Map,q=new Map,nt=new Map,J=new Map,rt=0;function Y(e,t){Xe.textContent=e,Xe.className=t}function it(t){let n=new URL(t);if(a(n.hostname)===void 0)return Promise.resolve();let{origin:r}=n,i=q.get(r);if(i===void 0){let t=document.createElement(`iframe`);t.src=`${r}${e}bridge.html`,t.title=`FiveRunner NUI bridge`,i={frame:t,ready:new Promise(e=>nt.set(r,e))},q.set(r,i),H(`bridges`).append(t)}return i.ready}function X(e){let t=K.get(e);if(t!==void 0)return t;let n=document.createElement(`article`);n.className=`player`;let r=document.createElement(`header`),i=document.createElement(`span`);i.className=`info`;let a=document.createElement(`button`);a.textContent=`Enlarge`,a.addEventListener(`click`,()=>{let e=n.classList.toggle(`large`);a.textContent=e?`Shrink`:`Enlarge`});let o=document.createElement(`button`);o.textContent=`Disconnect`,o.addEventListener(`click`,()=>U({type:`disconnect`,client:e})),r.append(i,a,o);let s=document.createElement(`div`);s.className=`card`,s.hidden=!0;let c=new Ge(e,qe,Je,{bridge:it,cursor:(t,n)=>U({type:`cursor`,client:e,x:t,y:n}),key:(t,n)=>U({type:`key`,client:e,key:t,down:n})}),l=document.createElement(`div`);return l.className=`console small`,n.append(r,c.element,s,l),$e.append(n),t={element:n,info:i,card:s,screen:c,console:new u(l),cardJson:void 0},K.set(e,t),t}function at(e,t,n){if(t.cardJson===n.card||(t.cardJson=n.card,t.card.replaceChildren(),t.card.hidden=n.card===void 0,n.card===void 0))return;let r=document.createElement(`pre`);r.textContent=n.card;let i=document.createElement(`form`),a=document.createElement(`textarea`);a.value=`{}`,a.setAttribute(`aria-label`,`What the card submits, as JSON`);let o=document.createElement(`button`);o.textContent=`Submit card`,i.append(a,o),i.addEventListener(`submit`,t=>{t.preventDefault(),U({type:`submitCard`,client:e,json:a.value})}),t.card.append(r,i)}function ot(e){Qe.replaceChildren(...e.resources.map(({name:e,state:t})=>{let n=document.createElement(`li`),r=document.createElement(`span`);r.textContent=e;let i=document.createElement(`span`);i.className=`state ${t}`,i.textContent=t,n.append(r,i);for(let r of t===`started`?[`restart`,`stop`]:[`start`]){let t=document.createElement(`button`);t.textContent=r,t.addEventListener(`click`,()=>U({type:`command`,line:`${r} "${e}"`})),n.append(t)}return n})),G.players(e.players),m(et,e.bags),tt.show(e.map,e.players);for(let t of e.players){let n=X(t.client),r=t.state===`dropped`||t.state===`rejected`,i=t.rejection??t.message?.trim();n.info.textContent=`${t.name} (id ${t.id}) ${t.state}${i?`: ${i}`:``}`,n.element.classList.toggle(`gone`,r),n.screen.world.show(e.map,e.players),n.screen.fade(t.fade??0),n.screen.blur(t.blurred===!0),at(t.client,n,t)}}function st(e,t){let{screen:n}=X(e);switch(t.type){case`create`:n.create(t.frame);break;case`destroy`:n.destroy(t.resource);break;case`message`:n.message(t.resource,t.json);break;case`frameFocus`:n.frameFocus(t.resource,t.focused);break;case`focus`:n.focus(t.focus,t.cursor);break;case`zIndex`:n.zIndex(t.resource,t.zIndex)}}function ct(e){let t=/^client (\d+)$/.exec(e.process)?.[1];t===void 0?W.add(e):X(Number(t)).console.add(e)}function Z(e){Y(`Starting`,`starting`),W.note(e),G.note(e);for(let e of K.values())e.element.remove();K.clear(),U({type:`start`})}Ye.addEventListener(`message`,e=>{let t=e.data;switch(t.type){case`started`:Ze.textContent=t.project.name,document.title=`${t.project.name} - FiveRunner`,Y(`Running`,`running`);break;case`failed`:Y(`Failed: ${t.message}`,`failed`),W.note(t.message);break;case`changed`:t.restarted===null?Z(`Files changed`):t.restarted.length>0&&W.note(`Files changed: restarted ${t.restarted.join(`, `)}`);break;case`event`:{let{event:e}=t;e.type===`output`?ct(e.line):e.type===`state`?ot(e.state):e.type===`nui`?st(e.client,e.event):e.type===`net`?G.add(e.event):(Y(`Crashed`,`failed`),W.note(e.message));break}case`answer`:{let e=J.get(t.id);if(e===void 0)break;J.delete(t.id);let n={type:`fiverunner:answer`,id:e.id,answer:t.answer};e.bridge.contentWindow?.postMessage(n,e.origin);break}}}),addEventListener(`message`,e=>{let t=q.get(e.origin);if(t!==void 0&&e.source===t.frame.contentWindow){let n=e.data;if(n.type===`fiverunner:bridge`)nt.get(e.origin)?.();else if(n.type===`fiverunner:ask`){let r=a(new URL(e.origin).hostname);if(r===void 0||r.tab!==qe)return;let i=rt++;J.set(i,{bridge:t.frame,origin:e.origin,id:n.id}),U({type:`ask`,id:i,client:r.client,host:r.host,ask:n.ask})}}else for(let t of K.values()){let n=t.screen.frameOf(e.source);if(n===void 0)continue;let r=e.data;r.type===`fiverunner:cursor`&&typeof r.x==`number`&&typeof r.y==`number`?t.screen.cursorOver(r.x,r.y):r.type===`fiverunner:invokeNative`&&t.console.note(`${n} called invokeNative('${String(r.native)}', '${String(r.arg)}')`);return}}),H(`command`).addEventListener(`submit`,e=>{e.preventDefault();let t=H(`command-line`),n=t.value;n.trim()!==``&&(Q.push(n),$=Q.length,W.note(`> ${n}`),U({type:`command`,line:n}),t.value=``)});var Q=[],$=0;H(`command-line`).addEventListener(`keydown`,e=>{(e.key===`ArrowUp`||e.key===`ArrowDown`)&&(e.preventDefault(),$=Math.max(0,Math.min(Q.length,$+(e.key===`ArrowUp`?-1:1))),e.target.value=Q[$]??``)}),H(`connect`).addEventListener(`submit`,e=>{e.preventDefault();let t=H(`player-name`).value.trim();U({type:`connect`,name:t===``?`Player`:t})}),H(`restart`).addEventListener(`click`,()=>Z(`Restarted`)),new EventSource(`${s}events`).addEventListener(`change`,e=>U({type:`change`,paths:JSON.parse(e.data)})),Z(`Started`);