@idosgames/game-kit 0.1.1 → 0.1.2
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.
- package/dist/index.cjs +3 -3
- package/dist/index.js +2 -2
- package/package.json +70 -70
package/dist/index.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
'use strict';function Vr(e){if(!ap.test(e))throw new Error(`registry: bad kind name "${e}"`);return Object.freeze({name:e})}var Oc=/^[a-z0-9][a-z0-9-]*(?:\.[a-z0-9][a-z0-9-]*)*$/,ap=/^[a-z][a-z0-9-]*$/;function Ls(e){let t=new Map,r=n=>{let s=t.get(n);return s||(s=new Map,t.set(n,s)),s},o={define(n,s,a){if(!s||typeof s!="object")throw new Error(`registry: ${n.name} entry must be an object`);if(typeof s.id!="string"||!Oc.test(s.id))throw new Error(`registry: ${n.name} has a bad id "${String(s.id)}"`);if(!Number.isInteger(s.version)||s.version<1)throw new Error(`registry: ${n.name} "${s.id}" needs an integer version \u2265 1`);let i=r(n.name);if((i.has(s.id)||(e?.has(n,s.id)??false))&&!a?.override)throw new Error(`registry: ${n.name} "${s.id}" is already defined (pass { override: true } to replace it)`);let m=Object.freeze({...s});return i.set(s.id,m),m},get(n,s){let a=t.get(n.name)?.get(s);return a||e?.get(n,s)},require(n,s){let a=o.get(n,s);if(!a)throw new Error(`registry: no ${n.name} "${s}"`);return a},has(n,s){return o.get(n,s)!==void 0},list(n){let s=new Map;for(let a of e?.list(n)??[])s.set(a.id,a);for(let[a,i]of t.get(n.name)??[])s.set(a,i);return [...s.values()].sort((a,i)=>a.id<i.id?-1:a.id>i.id?1:0)},extend(){return Ls(o)}};return o}function ip(e){let t=1779033703^e.length;for(let r=0;r<e.length;r++)t=Math.imul(t^e.charCodeAt(r),3432918353),t=t<<13|t>>>19;return ()=>(t=Math.imul(t^t>>>16,2246822507),t=Math.imul(t^t>>>13,3266489909),t^=t>>>16,t>>>0)}function lp(e,t,r,o){return ()=>{e>>>=0,t>>>=0,r>>>=0,o>>>=0;let n=e+t|0;return e=t^t>>>9,t=r+(r<<3)|0,r=r<<21|r>>>11,o=o+1|0,n=n+o|0,r=r+n|0,(n>>>0)/4294967296}}function _s(e){let t=String(e),r=ip(t),o=lp(r(),r(),r(),r());for(let s=0;s<12;s++)o();return {seed:t,next:o,int(s,a){if(!Number.isFinite(s)||!Number.isFinite(a))throw new RangeError("int: bounds must be finite");let i=Math.ceil(Math.min(s,a)),
|
|
2
|
-
`||o==="\r"){r++;continue}if(o>="0"&&o<="9"||o==="."&&/[0-9]/.test(e[r+1]??"")){let s=/^(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/.exec(e.slice(r));if(!s)throw new dr("bad number",e,r);t.push({t:"num",v:Number(s[0]),at:r}),r+=s[0].length;continue}if(o==="'"||o==='"'){let s=e.indexOf(o,r+1);if(s<0)throw new dr("unclosed string",e,r);t.push({t:"str",v:e.slice(r+1,s),at:r}),r=s+1;continue}if(/[A-Za-z_$]/.test(o)){let s=/^[A-Za-z_$][A-Za-z0-9_$]*(?:\.[A-Za-z_$][A-Za-z0-9_$]*)*/.exec(e.slice(r));if(!s)throw new dr("bad name",e,r);t.push({t:"id",v:s[0],at:r}),r+=s[0].length;continue}let n=cp.find(s=>e.startsWith(s,r));if(!n)throw new dr(`unexpected "${o}"`,e,r);t.push({t:"op",v:n,at:r}),r+=n.length;}return t.push({t:"end",at:e.length}),t}var Pc={"||":1,"&&":2,"==":3,"!=":3,"<":4,"<=":4,">":4,">=":4,"+":5,"-":5,"*":6,"/":6,"%":6,"^":8};function fp(e){let t=dp(e),r=0,o=()=>t[r],n=()=>t[r++],s=C=>{let z=o();return z.t==="op"&&z.v===C},a=C=>{let z=n();if(z.t!=="op"||z.v!==C)throw new dr(`expected "${C}"`,e,z.at)},i=C=>{if(C>vi)throw new dr("formula is nested too deep",e,o().at);let z=p(0,C+1);if(!s("?"))return z;n();let F=i(C+1);a(":");let ne=i(C+1);return {k:"cond",c:z,a:F,b:ne}},p=(C,z)=>{if(z>vi)throw new dr("formula is nested too deep",e,o().at);let F=m(z+1);for(;;){let ne=o();if(ne.t!=="op")break;let X=Pc[ne.v];if(X===void 0||X<C)break;n();let ye=ne.v==="^"?p(X,z+1):p(X+1,z+1);F={k:"bin",op:ne.v,a:F,b:ye};}return F},m=C=>{if(C>vi)throw new dr("formula is nested too deep",e,o().at);return s("-")||s("!")?{k:"un",op:n().v,a:p(Pc["^"],C+1)}:$(C+1)},$=C=>{let z=n();if(z.t==="num")return {k:"num",v:z.v};if(z.t==="str")return {k:"str",v:z.v};if(z.t==="op"&&z.v==="("){let F=i(C+1);return a(")"),F}if(z.t==="id"){if(z.v==="true")return {k:"bool",v:true};if(z.v==="false")return {k:"bool",v:false};if(s("(")){if(!Object.prototype.hasOwnProperty.call($i,z.v))throw new dr(`unknown function "${z.v}"`,e,z.at);n();let F=[];if(!s(")"))for(;;){if(F.push(i(C+1)),s(",")){n();continue}break}return a(")"),{k:"call",fn:z.v,args:F}}return {k:"var",path:z.v.split(".")}}throw new dr(z.t==="end"?"unexpected end":"unexpected token",e,z.at)},k=i(0),O=o();if(O.t!=="end")throw new dr("unexpected token",e,O.at);return k}function pp(e,t){let r=e;for(let o of t){if(r===null||typeof r!="object"||!Object.prototype.hasOwnProperty.call(r,o))return 0;r=r[o];}return typeof r=="number"||typeof r=="string"||typeof r=="boolean"?r:0}function cr(e,t){switch(e.k){case "num":case "str":case "bool":return e.v;case "var":return pp(t,e.path);case "un":return e.op==="-"?-ct(cr(e.a,t)):!En(cr(e.a,t));case "cond":return En(cr(e.c,t))?cr(e.a,t):cr(e.b,t);case "call":return ct($i[e.fn](...e.args.map(r=>ct(cr(r,t)))));case "bin":{if(e.op==="&&")return En(cr(e.a,t))&&En(cr(e.b,t));if(e.op==="||")return En(cr(e.a,t))||En(cr(e.b,t));let r=cr(e.a,t),o=cr(e.b,t);switch(e.op){case "==":return typeof r=="string"||typeof o=="string"?String(r)===String(o):ct(r)===ct(o);case "!=":return typeof r=="string"||typeof o=="string"?String(r)!==String(o):ct(r)!==ct(o);case "<":return ct(r)<ct(o);case "<=":return ct(r)<=ct(o);case ">":return ct(r)>ct(o);case ">=":return ct(r)>=ct(o);case "+":return typeof r=="string"||typeof o=="string"?`${r}${o}`:ct(r)+ct(o);case "-":return ct(r)-ct(o);case "*":return ct(r)*ct(o);case "/":{let n=ct(o);return n===0?0:ct(r)/n}case "%":{let n=ct(o);return n===0?0:ct(r)%n}case "^":return ct(Math.pow(ct(r),ct(o)))}return 0}}}function cn(e,t){switch(e.k){case "var":t.add(e.path.join("."));return;case "un":cn(e.a,t);return;case "bin":cn(e.a,t),cn(e.b,t);return;case "cond":cn(e.c,t),cn(e.a,t),cn(e.b,t);return;case "call":for(let r of e.args)cn(r,t);return;default:return}}var Rs=new Map;function Er(e){let t=Rs.get(e);if(t)return t;if(e.length>Cc)throw new dr("formula is too long",e,Cc);let r=fp(e),o=new Set;cn(r,o);let n={source:e,reads:[...o],eval:s=>cr(r,s),num:s=>ct(cr(r,s)),bool:s=>En(cr(r,s))};return Rs.size>5e3&&Rs.clear(),Rs.set(e,n),n}function Mi(e){try{return Er(e),null}catch(t){return t instanceof Error?t.message:String(t)}}function wi(e,t,r=0){return e===void 0?r:typeof e=="number"?Number.isFinite(e)?e:r:Er(e).num(t)}var hp=/^[a-z][a-z0-9-]*(?:\.[a-z0-9-]+)*$/;function ve(e){if(!hp.test(e))throw new Error(`world: bad component name "${e}"`);return Object.freeze({name:e})}var zo=class{rng;vars;tick=0;time=0;nextId=1;alive=new Set;stores=new Map;doomed=new Set;systems=[];systemSeq=0;handlers=new Map;queue=[];maxEventRounds;stepping=false;constructor(t={}){this.rng=_s(t.seed??"world"),this.vars={...t.vars??{}},this.maxEventRounds=t.maxEventRounds??16;}create(){let t=this.nextId++;return this.alive.add(t),t}destroy(t){this.alive.has(t)&&(this.stepping?this.doomed.add(t):this.purge(t));}isAlive(t){return this.alive.has(t)&&!this.doomed.has(t)}get entityCount(){return this.alive.size-this.doomed.size}set(t,r,o){if(!this.alive.has(t))throw new Error(`world: entity ${t} does not exist`);let n=this.stores.get(r.name);return n||(n=new Map,this.stores.set(r.name,n)),n.set(t,o),t}get(t,r){return this.stores.get(r.name)?.get(t)}need(t,r){let o=this.get(t,r);if(o===void 0)throw new Error(`world: entity ${t} has no ${r.name}`);return o}has(t,r){return this.stores.get(r.name)?.has(t)??false}remove(t,r){this.stores.get(r.name)?.delete(t);}query(...t){if(t.length===0)return [...this.alive].filter(a=>!this.doomed.has(a)).sort((a,i)=>a-i);let r=t.map(a=>this.stores.get(a.name));if(r.some(a=>!a||a.size===0))return [];let o=r,n=o.reduce((a,i)=>i.size<a.size?i:a),s=[];for(let a of n.keys())this.doomed.has(a)||o.every(i=>i.has(a))&&s.push(a);return s.sort((a,i)=>a-i)}addSystem(t){if(this.systems.some(r=>r.system.id===t.id))throw new Error(`world: system "${t.id}" is already added`);this.systems.push({system:t,seq:this.systemSeq++}),this.systems.sort((r,o)=>(r.system.order??0)-(o.system.order??0)||r.seq-o.seq);}removeSystem(t){this.systems=this.systems.filter(r=>r.system.id!==t);}get systemIds(){return this.systems.map(t=>t.system.id)}on(t,r){let o=this.handlers.get(t)??[];return o.push(r),this.handlers.set(t,o),()=>{let n=this.handlers.get(t);if(!n)return;let s=n.indexOf(r);s>=0&&n.splice(s,1);}}emit(t,r={}){this.queue.push({topic:t,payload:r});}flushEvents(){for(let t=0;t<this.maxEventRounds&&this.queue.length>0;t++){let r=this.queue;this.queue=[];for(let{topic:o,payload:n}of r){let s=this.handlers.get(o);if(!s)continue;for(let i of s.slice())i(n,this);let a=this.handlers.get("*");if(a)for(let i of a.slice())i({...n,topic:o},this);}}this.queue.length>0&&(this.queue=[],this.overflowed++);}overflowed=0;step(t){if(!(t>=0)||!Number.isFinite(t))throw new RangeError("world: dt must be a finite number \u2265 0");this.stepping=true;try{this.tick++,this.time+=t;for(let{system:r}of this.systems.slice())r.run(this,t);this.flushEvents();}finally{this.stepping=false;for(let r of this.doomed)this.purge(r);this.doomed.clear();}}purge(t){this.alive.delete(t);for(let r of this.stores.values())r.delete(t);}};function up(e,t={}){let r=t.step??.016666666666666666,o=t.maxSteps??5,n=0;return {step:r,advance(s){if(!(s>0)||!Number.isFinite(s))return 0;n+=s;let a=0;for(;n>=r&&a<o;)e.step(r),n-=r,a++;return a===o&&(n=0),a},get alpha(){return n/r}}}var Bo=Vr("effect"),mp=/^[a-z][a-z0-9_]*$/,Ic=e=>{let t=e.name;if(typeof t!="string"||!mp.test(t))throw new Error(`effect ${e.type}: bad var name`);return t},Nc=[{id:"set-var",version:1,required:["name","value"],formulas:["value"],run(e,t){let r=t.value,o=typeof r=="string"?Er(r).eval(e.scope):typeof r=="number"||typeof r=="boolean"?r:0;e.world.vars[Ic(t)]=o;}},{id:"add-var",version:1,required:["name","amount"],formulas:["amount","min","max"],run(e,t){let r=Ic(t),o=e.world.vars[r],n=(typeof o=="number"?o:0)+e.num(t.amount);t.min!==void 0&&(n=Math.max(n,e.num(t.min))),t.max!==void 0&&(n=Math.min(n,e.num(t.max))),e.world.vars[r]=n;}},{id:"emit",version:1,required:["topic"],run(e,t){let r=t.topic;if(typeof r!="string"||r.length===0)throw new Error("effect emit: topic required");let o=t.payload,n={};if(o&&typeof o=="object")for(let[s,a]of Object.entries(o))n[s]=typeof a=="string"?Er(a).eval(e.scope):a;e.world.emit(r,n);}}];function Ho(e){for(let t of Nc)e.has(Bo,t.id)||e.define(Bo,t);}function As(e,t,r,o){let n=new Set;e.forEach((s,a)=>{let i=`${r}.${a}`;if(!s||typeof s!="object"){o.push({level:"error",path:i,code:"RULE_SHAPE",message:"a rule must be an object"});return}if(typeof s.id!="string"||s.id.length===0?o.push({level:"error",path:`${i}.id`,code:"RULE_ID",message:"a rule needs an id"}):n.has(s.id)?o.push({level:"error",path:`${i}.id`,code:"RULE_DUPLICATE",message:`rule "${s.id}" is defined twice`}):n.add(s.id),(typeof s.on!="string"||s.on.length===0)&&o.push({level:"error",path:`${i}.on`,code:"RULE_TRIGGER",message:"a rule needs an event topic in `on`"}),s.when!==void 0)try{Er(String(s.when));}catch(p){o.push({level:"error",path:`${i}.when`,code:"RULE_FORMULA",message:p.message});}if(!Array.isArray(s.do)||s.do.length===0){o.push({level:"error",path:`${i}.do`,code:"RULE_EFFECTS",message:"a rule needs at least one effect"});return}s.do.forEach((p,m)=>{let $=`${i}.do.${m}`,k=typeof p?.type=="string"?t.get(Bo,p.type):void 0;if(!k){o.push({level:"error",path:`${$}.type`,code:"EFFECT_UNKNOWN",message:`unknown effect "${String(p?.type)}"`});return}for(let O of k.required??[])p[O]===void 0&&o.push({level:"error",path:`${$}.${O}`,code:"EFFECT_PARAM",message:`effect "${k.id}" needs "${O}"`});for(let O of k.formulas??[]){let C=p[O];if(typeof C=="string")try{Er(C);}catch(z){o.push({level:"error",path:`${$}.${O}`,code:"RULE_FORMULA",message:z.message});}}});});}function Ei(e,t,r,o={}){let n=t.map(i=>({def:i,...i.when!==void 0?{when:Er(i.when)}:{},effects:i.do.map(p=>({spec:p,def:r.require(Bo,p.type)})),hits:0,runs:0,lastRunAt:Number.NEGATIVE_INFINITY})),s=new Map;for(let i of n){let p=s.get(i.def.on)??[];p.push(i),s.set(i.def.on,p);}let a=[...s.entries()].map(([i,p])=>e.on(i,m=>{for(let $ of p){if($.def.once&&$.runs>0)continue;let k={event:m,vars:e.vars,tick:e.tick,time:e.time};if($.when&&!$.when.bool(k)||($.hits++,$.def.every!==void 0&&$.def.every>1&&$.hits%$.def.every!==0)||$.def.cooldown!==void 0&&e.time-$.lastRunAt<$.def.cooldown)continue;$.runs++,$.lastRunAt=e.time;let O={world:e,rule:$.def,event:m,scope:k,num:(C,z=0)=>typeof C=="number"||typeof C=="string"?wi(C,k,z):z};for(let C of $.effects)try{C.def.run(O,C.spec);}catch(z){o.onError?.($.def,z);}}}));return ()=>a.forEach(i=>i())}var Si=e=>e.some(t=>t.level==="error");function Ts(e,t,r,o){let n={};for(let[s,a]of Object.entries(e))n[s]=a.default;if(!t)return n;for(let[s,a]of Object.entries(t)){let i=e[s],p=`${r}.${s}`;if(!i){o.push({level:"warning",path:p,code:"PARAM_UNKNOWN",message:`unknown parameter "${s}"`});continue}switch(i.type){case "number":{if(typeof a!="number"||!Number.isFinite(a)){o.push({level:"warning",path:p,code:"PARAM_TYPE",message:"expected a number, default used"});break}let m=i.integer?Math.round(a):a;i.min!==void 0&&m<i.min&&(m=i.min),i.max!==void 0&&m>i.max&&(m=i.max),m!==a&&o.push({level:"warning",path:p,code:"PARAM_CLAMPED",message:`${a} \u2192 ${m}`}),n[s]=m;break}case "enum":typeof a=="string"&&i.values.includes(a)?n[s]=a:o.push({level:"warning",path:p,code:"PARAM_ENUM",message:`not one of ${i.values.join(", ")}, default used`});break;case "boolean":typeof a=="boolean"?n[s]=a:o.push({level:"warning",path:p,code:"PARAM_TYPE",message:"expected true/false, default used"});break;case "string":if(typeof a=="string"){let m=i.maxLength??500;n[s]=a.length>m?a.slice(0,m):a,a.length>m&&o.push({level:"warning",path:p,code:"PARAM_CLAMPED",message:`cut to ${m} characters`});}else o.push({level:"warning",path:p,code:"PARAM_TYPE",message:"expected text, default used"});break}}return n}var Ds=["phaser","three","dom"],dn=Vr("block"),fn=Vr("preset");var zc=["store","premium","character","inventory","lootboxes","boosts","leaderboard","rewards","quests","collections","craft","marketplace","deals","events","coop-events","season","pvp","mailbox","reward-window","idle"],yp=/^system:([a-z][a-z0-9-]*)$/,gp=new Set(["currency","item"]);function Li(e,t,r,o){let n=new Set(e.map(p=>p.id)),s=new Set(t.map(p=>p.id)),a=new Map,i=new Map;r.forEach((p,m)=>{let $=`flows.${m}`;s.has(p.resource)||o.push({level:"error",path:`${$}.resource`,code:"FLOW_RESOURCE_UNKNOWN",message:`no resource "${p.resource}"`});let k=yp.exec(p.by);k?zc.includes(k[1])||o.push({level:"warning",path:`${$}.by`,code:"FLOW_SYSTEM_UNKNOWN",message:`"${p.by}" is not a platform system`}):n.has(p.by)||o.push({level:"error",path:`${$}.by`,code:"FLOW_BY_UNKNOWN",message:`"${p.by}" is neither a mode of the spec nor "system:<id>"`}),p.kind!=="source"&&p.kind!=="sink"&&o.push({level:"error",path:`${$}.kind`,code:"FLOW_KIND",message:'kind is "source" or "sink"'});let O=p.kind==="source"?a:i;O.set(p.resource,(O.get(p.resource)??0)+1);}),t.forEach((p,m)=>{let $=`resources.${m}`,k=a.get(p.id)??0,O=i.get(p.id)??0;k===0&&o.push({level:"error",path:$,code:"RESOURCE_NO_SOURCE",message:`nothing produces "${p.id}"`}),gp.has(p.kind)&&O===0&&o.push({level:"error",path:$,code:"RESOURCE_NO_SINK",message:`nothing spends "${p.id}"`});});}var K=ve("transform"),ie=ve("visual"),Ri=Object.freeze({background:"#1b2133",ground:"#273047",lane:"#313b56",primary:"#4fc3f7",secondary:"#ba68c8",danger:"#ef5350",coin:"#ffd54f",accent:"#66bb6a",text:"#ffffff",muted:"#9aa3b8",piece1:"#ef5350",piece2:"#42a5f5",piece3:"#66bb6a",piece4:"#ffd54f",piece5:"#ab47bc",piece6:"#ff8a3d",panel:"#2b3550"}),_i=/^#[0-9a-fA-F]{6}(?:[0-9a-fA-F]{2})?$/;function Ai(e,t){let r=_i.test(e)?e:t[e]??Ri[e]??t.text??"#ffffff";return _i.test(r)?r.slice(0,7):"#ffffff"}function Ti(e){let t={...Ri};for(let[r,o]of Object.entries(e??{}))typeof o=="string"&&_i.test(o)&&(t[r]=o);return t}var Nt="input",qt="view-resized",Os=Object.freeze({hero:{preset:"knight",races:["human"]},foe:{preset:"berserker",parts:{Hat:null,Offhand:null,Weapon:"weapon/battle_axe"},races:["orc"]},foe2:{preset:"crossbowman",parts:{Weapon:"weapon/broadsword"},races:["undead"]},boss:{preset:"dark_knight",races:["orc"]},helper:{preset:"camper",parts:{Weapon:null,Back:null,Glasses:null},races:["human","elf","dwarf"]},foe3:{preset:"crossbowman",races:["undead"]},foe4:{preset:"viking",parts:{Weapon:"weapon/warhammer"},races:["orc"]},foe5:{preset:"hunter",parts:{Hat:null,Back:null,Weapon:"weapon/dagger"},races:["undead"]},hero2:{preset:"crusader",races:["human"]},hero3:{preset:"archmage",races:["elf"]}}),Di=Object.freeze({style:"default",cast:Os}),Oi="fx";var Fn=Vr("asset-pack"),Wo=Vr("link"),bp=(e,t="en")=>e.names[t]??e.names.en??e.id;function xp(e,t,r){let o=[],n=r.get(Wo,t);if(!n)return o.push({level:"error",path:"link",code:"LINK_UNKNOWN",message:`no link "${t}"`}),{spec:e,systems:[],issues:o};let s=e.modes.find(i=>i.role==="core")??e.modes[0],a=s?r.get(fn,s.preset)?.genre:void 0;return !a||!n.core.includes(a)?(o.push({level:"error",path:"link",code:"LINK_GENRE",message:`link "${t}" fits ${n.core.join(", ")}, not "${a??"?"}"`}),{spec:e,systems:[],issues:o}):{spec:n.apply(e),systems:n.systems,issues:o}}var Vo=1;function Sr(e,t,r){let o=e?.content[t];if(!o||o.length===0)return r;let n=r.filter(s=>!o.includes(s));return n.length>0?n:r}var Hc=Object.freeze({window:"round",adMultiplier:3,vipMultiplier:5}),kp={};function Wc(e,t){let r={...e},o=r.v===void 0?1:r.v;if(typeof o!="number"||!Number.isInteger(o)||o<1)return t.push({level:"error",path:"v",code:"SPEC_VERSION",message:"v must be an integer \u2265 1"}),null;if(o>Vo)return t.push({level:"error",path:"v",code:"SPEC_TOO_NEW",message:`spec v${o} is newer than this kit (v${Vo})`}),null;for(;o<Vo;){let n=kp[o];if(!n)return t.push({level:"error",path:"v",code:"SPEC_NO_MIGRATION",message:`no migration from v${o}`}),null;r=n(r),o++;}return r.v=Vo,r}var Ci=/^[a-z][a-z0-9_]*$/,vp=/^#[0-9a-fA-F]{6}(?:[0-9a-fA-F]{2})?$/,$p=/^[a-z]{2}(?:-[A-Z]{2})?$/,Mp=/^[a-z][a-z0-9_.-]*$/,Bc=["none","async","coop","pvp"],xt=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),jo=e=>Array.isArray(e)?e:[];function wp(e,t){let r=[];if(!xt(e))return r.push({level:"error",path:"",code:"SPEC_SHAPE",message:"a spec must be an object"}),{ok:false,issues:r};let o=Wc(e,r);if(!o)return {ok:false,issues:r};let n=o;Ds.includes(n.engine)||r.push({level:"error",path:"engine",code:"SPEC_ENGINE",message:`engine is one of ${Ds.join(", ")}`});let s=jo(n.modes);s.length===0&&r.push({level:"error",path:"modes",code:"SPEC_NO_MODES",message:"a game needs at least one mode"});let a=new Set,i=[];s.forEach((X,ye)=>{let be=`modes.${ye}`;if(!xt(X)){r.push({level:"error",path:be,code:"MODE_SHAPE",message:"a mode must be an object"});return}typeof X.id!="string"||!Ci.test(X.id)?r.push({level:"error",path:`${be}.id`,code:"MODE_ID",message:"mode id: snake_case, starts with a letter"}):a.has(X.id)?r.push({level:"error",path:`${be}.id`,code:"MODE_DUPLICATE",message:`mode "${X.id}" is defined twice`}):a.add(X.id);let fe=typeof X.preset=="string"?t.get(fn,X.preset):void 0;if(!fe){r.push({level:"error",path:`${be}.preset`,code:"MODE_PRESET_UNKNOWN",message:`no preset "${String(X.preset)}"`});return}fe.engine!==n.engine&&r.push({level:"error",path:`${be}.preset`,code:"MODE_ENGINE",message:`preset "${fe.id}" runs on ${fe.engine}, the spec on ${String(n.engine)}`}),X.role!==void 0&&!["core","meta","embedded"].includes(X.role)&&r.push({level:"error",path:`${be}.role`,code:"MODE_ROLE",message:"role is core, meta or embedded"});let we=Ts(fe.params??{},xt(X.params)?X.params:void 0,`${be}.params`,r),de={},Re=new Set(fe.blocks);for(let ce of fe.blocks){let ue=t.get(dn,ce);if(!ue){r.push({level:"error",path:`${be}.preset`,code:"PRESET_BLOCK_UNKNOWN",message:`preset "${fe.id}" uses unknown block "${ce}"`});continue}ue.engines&&!ue.engines.includes(fe.engine)&&r.push({level:"error",path:`${be}.preset`,code:"BLOCK_ENGINE",message:`block "${ce}" is not drawn by ${fe.engine}`});for(let oe of ue.requires??[])Re.has(oe)||r.push({level:"error",path:`${be}.preset`,code:"BLOCK_REQUIRES",message:`block "${ce}" needs "${oe}" in the same preset`});let Pe={};for(let[oe,Ee]of Object.entries(fe.blockParams?.[ce]??{})){let tt=ue.params?.[oe];if(typeof Ee=="string"&&(tt?.type==="number"||tt?.type==="boolean"))try{let Ne=Er(Ee).eval({params:we});Pe[oe]=tt.type==="number"?Number(Ne):!!Ne;}catch(Ne){r.push({level:"error",path:`${be}.preset`,code:"PRESET_FORMULA",message:`preset "${fe.id}", ${ce}.${oe}: ${Ne.message}`});}else Pe[oe]=Ee;}let Le={...Pe,...xt(X.blockParams)&&xt(X.blockParams[ce])?X.blockParams[ce]:{}};de[ce]=Ts(ue.params??{},Le,`${be}.blockParams.${ce}`,r);}if(xt(X.blockParams))for(let ce of Object.keys(X.blockParams))Re.has(ce)||r.push({level:"warning",path:`${be}.blockParams.${ce}`,code:"BLOCK_NOT_IN_PRESET",message:`preset "${fe.id}" has no block "${ce}"`});let Ce=[...fe.rules??[],...jo(X.rules)];As(Ce,t,`${be}.rules`,r);let Me={};if(X.content!==void 0)if(!xt(X.content))r.push({level:"warning",path:`${be}.content`,code:"CONTENT_SHAPE",message:"content is { kind: { without: [ids] } }; ignored"});else for(let[ce,ue]of Object.entries(X.content)){let Pe=xt(ue)?ue.without:void 0;Array.isArray(Pe)&&Pe.every(Le=>typeof Le=="string")?Me[ce]=[...Pe]:r.push({level:"warning",path:`${be}.content.${ce}`,code:"CONTENT_SHAPE",message:"expected { without: [ids] }; ignored"});}i.push({id:X.id,role:X.role??(ye===0?"core":"meta"),preset:fe,params:we,blockParams:de,rules:Ce,content:Me});}),s.length>0&&!s.some((X,ye)=>xt(X)?(X.role??(ye===0?"core":"meta"))==="core":false)&&r.push({level:"error",path:"modes",code:"SPEC_NO_CORE",message:"one mode must be the core (what the player plays)"});let p=jo(n.resources),m=new Set;p.forEach((X,ye)=>{let be=`resources.${ye}`;if(!xt(X)||typeof X.id!="string"||!Ci.test(X.id)){r.push({level:"error",path:be,code:"RESOURCE_ID",message:"resource id: snake_case, starts with a letter"});return}m.has(X.id)&&r.push({level:"error",path:`${be}.id`,code:"RESOURCE_DUPLICATE",message:`resource "${X.id}" is defined twice`}),m.add(X.id),["currency","item","score","local"].includes(X.kind)||r.push({level:"error",path:`${be}.kind`,code:"RESOURCE_KIND",message:"kind is currency, item, score or local"}),(X.kind==="currency"||X.kind==="item")&&X.ref!==void 0&&(typeof X.ref!="string"||X.ref.length===0)&&r.push({level:"error",path:`${be}.ref`,code:"RESOURCE_REF",message:"ref is the engine currency or item id"});});let $=jo(n.flows);$.forEach((X,ye)=>{if(typeof X?.amount=="string"){let be=Mi(X.amount);be&&r.push({level:"error",path:`flows.${ye}.amount`,code:"FLOW_FORMULA",message:be});}}),Li(s.filter(xt),p.filter(X=>xt(X)&&typeof X.id=="string"),$.filter(xt),r);let k=jo(n.rules);As(k,t,"rules",r);let O={};if(n.vars!==void 0)if(!xt(n.vars))r.push({level:"error",path:"vars",code:"VARS_SHAPE",message:"vars must be an object"});else for(let[X,ye]of Object.entries(n.vars))Ci.test(X)?typeof ye=="number"||typeof ye=="string"||typeof ye=="boolean"?O[X]=ye:r.push({level:"error",path:`vars.${X}`,code:"VAR_TYPE",message:"a var is a number, text or true/false"}):r.push({level:"error",path:`vars.${X}`,code:"VAR_NAME",message:"var name: snake_case"});let C=typeof n.assets=="string"&&n.assets?t.get(Fn,n.assets):void 0;if(n.assets!==void 0&&!C&&r.push({level:"warning",path:"assets",code:"ASSETS_UNKNOWN",message:`no asset pack "${String(n.assets)}"; the default look is used`}),n.palette!==void 0)if(!xt(n.palette))r.push({level:"error",path:"palette",code:"PALETTE_SHAPE",message:"palette must be an object"});else for(let[X,ye]of Object.entries(n.palette))(typeof ye!="string"||!vp.test(ye))&&r.push({level:"warning",path:`palette.${X}`,code:"PALETTE_COLOR",message:"a colour is #rrggbb or #rrggbbaa; ignored"});if(n.texts!==void 0)if(!xt(n.texts))r.push({level:"error",path:"texts",code:"TEXTS_SHAPE",message:"texts must be an object"});else for(let[X,ye]of Object.entries(n.texts)){if(Mp.test(X)||r.push({level:"error",path:`texts.${X}`,code:"TEXT_KEY",message:"text key: lower case, digits, _ . -"}),!xt(ye)){r.push({level:"error",path:`texts.${X}`,code:"TEXT_SHAPE",message:"a text is { lang: text }"});continue}for(let[be,fe]of Object.entries(ye))(!$p.test(be)||typeof fe!="string")&&r.push({level:"error",path:`texts.${X}.${be}`,code:"TEXT_LANG",message:"language code like en or pt-BR, value text"});ye.en===void 0&&r.push({level:"warning",path:`texts.${X}`,code:"TEXT_NO_EN",message:"no English text: other languages fall back to it"});}let z={...Hc};if(n.rewards!==void 0)if(!xt(n.rewards))r.push({level:"error",path:"rewards",code:"REWARDS_SHAPE",message:"rewards must be an object"});else {let X=(be,fe,we)=>{let de=n.rewards[be];if(de===void 0)return;if(typeof de!="number"||!Number.isFinite(de)){r.push({level:"warning",path:`rewards.${be}`,code:"PARAM_TYPE",message:"expected a number, default used"});return}let Re=Math.min(Math.max(de,fe),we);Re!==de&&r.push({level:"warning",path:`rewards.${be}`,code:"PARAM_CLAMPED",message:`${de} \u2192 ${Re}`}),z[be]=Re;};X("adMultiplier",1,10),X("vipMultiplier",1,20);let ye=n.rewards.window;ye!==void 0&&(typeof ye=="string"&&/^[A-Za-z0-9_-]{1,64}$/.test(ye)?z.window=ye:r.push({level:"warning",path:"rewards.window",code:"PARAM_TYPE",message:"expected a window id, default used"}));}let F=n.multiplayer??"none";Bc.includes(F)||r.push({level:"error",path:"multiplayer",code:"SPEC_MULTIPLAYER",message:`multiplayer is one of ${Bc.join(", ")}`});let ne=!Si(r);return {ok:ne,issues:r,spec:n,...ne?{resolved:{spec:n,engine:n.engine,seed:typeof n.seed=="string"&&n.seed.length>0?n.seed:"game",modes:i,resources:p,flows:$,rules:k,vars:O,rewards:z,multiplayer:F,palette:Ti({...C?.palette,...xt(n.palette)?n.palette:{}}),texts:Sp(C?.texts,xt(n.texts)?n.texts:void 0),look:{style:C?C.style??C.id:Di.style,cast:Ep({...Os,...C?.cast},n.cast)}}}:{}}}function Ep(e,t){let r={...e};if(!xt(t))return r;for(let[o,n]of Object.entries(t)){if(!xt(n))continue;let s={...r[o]};typeof n.preset=="string"&&(s.preset=n.preset),Array.isArray(n.races)&&n.races.every(a=>typeof a=="string")&&n.races.length>0&&(s.races=n.races),xt(n.parts)&&(s.parts={...s.parts,...n.parts}),xt(n.colors)&&(s.colors={...s.colors,...n.colors}),r[o]=s;}return r}function Sp(e,t){let r={};for(let o of [e,t])for(let[n,s]of Object.entries(o??{}))if(s&&typeof s=="object")for(let[a,i]of Object.entries(s))typeof i=="string"&&((r[n]??={})[a]=i);return r}function Lp(){let e=Ls();return Ho(e),e}function _p(e,t,r,o={}){let n=e.modes.find(i=>i.id===t);if(!n)throw new Error(`game: no mode "${t}"`);let s=new zo({seed:`${e.seed}/${n.id}${o.salt!==void 0?`/${o.salt}`:""}`,vars:e.vars});for(let i of n.preset.blocks)r.require(dn,i).setup?.({world:s,spec:e,mode:n,params:n.blockParams[i]??{},registry:r});let a=Ei(s,[...n.rules,...e.rules],r,{...o.onRuleError?{onError:o.onRuleError}:{}});return s.emit("mode-started",{mode:n.id}),s.flushEvents(),{world:s,mode:n,stop:a}}var Rp=(e,t=0,r=255)=>Math.min(r,Math.max(t,e)),Pi=e=>{let t=/^#[0-9a-fA-F]{6}/.test(e)?e.slice(1,7):"ffffff";return [Number.parseInt(t.slice(0,2),16),Number.parseInt(t.slice(2,4),16),Number.parseInt(t.slice(4,6),16)]},Ap=(e,t,r)=>`#${[e,t,r].map(o=>Math.round(Rp(o)).toString(16).padStart(2,"0")).join("")}`;function qn(e,t,r){let o=Pi(e),n=Pi(t);return Ap(o[0]+(n[0]-o[0])*r,o[1]+(n[1]-o[1])*r,o[2]+(n[2]-o[2])*r)}var W=(e,t)=>qn(e,"#000000",t),Z=(e,t)=>qn(e,"#ffffff",t),Cs=e=>{let[t,r,o]=Pi(e);return (t*.299+r*.587+o*.114)/255},pe=(e,t,r=false)=>`<linearGradient id="${e}" x1="0" y1="0" x2="${r?1:0}" y2="${r?0:1}">${t.map(([o,n,s])=>`<stop offset="${o}" stop-color="${n}"${s===void 0?"":` stop-opacity="${s}"`}/>`).join("")}</linearGradient>`,qe=(e,t,r=.5,o=.5,n=.5)=>`<radialGradient id="${e}" cx="${r}" cy="${o}" r="${n}">${t.map(([s,a,i])=>`<stop offset="${s}" stop-color="${a}"${i===void 0?"":` stop-opacity="${i}"`}/>`).join("")}</radialGradient>`,ae=(...e)=>`<defs>${e.join("")}</defs>`,Sn=e=>(Math.round(e*10)/10).toString(),et=(e,t,r,o,n=5,s=-Math.PI/2)=>{let a=[];for(let i=0;i<n*2;i++){let p=i%2===0?r:o,m=s+i*Math.PI/n;a.push(`${Sn(e+Math.cos(m)*p)},${Sn(t+Math.sin(m)*p)}`);}return a.join(" ")},Tt=(e,t,r,o,n=-Math.PI/2)=>{let s=[];for(let a=0;a<o;a++){let i=n+a*2*Math.PI/o;s.push(`${Sn(e+Math.cos(i)*r)},${Sn(t+Math.sin(i)*r)}`);}return s.join(" ")},Go=(e,t,r,o,n)=>{let s=[],a=o*4;for(let i=0;i<a;i++){let p=i/a*Math.PI*2,m=i%4<2?r:r-n;s.push(`${Sn(e+Math.cos(p)*m)},${Sn(t+Math.sin(p)*m)}`);}return `M${s.join("L")}Z`};function Mr(e){let t=e>>>0||1;return ()=>(t=t*1664525+1013904223>>>0,t/4294967296)}var jc=e=>e==="cozy"?"#5b3b33":e==="sci-fi"?"#05070f":e==="post-apocalypse"?"#1a120c":"#1c1622",q=Sn;var Dt=(e,t,r,o,n=.28)=>`<ellipse cx="${e}" cy="${t}" rx="${r}" ry="${o}" fill="#000" opacity="${n}"/>`,Gr=(e,t=4,r=.55)=>`<path d="${e}" fill="none" stroke="#fff" stroke-width="${t}" stroke-linecap="round" opacity="${r}"/>`,Tp={w:64,h:64,main:"coin",draw({main:e,ink:t,style:r}){let o=W(e,.25),n;return r==="sci-fi"?n=`<polygon points="${Tt(32,31,11,6)}" fill="none" stroke="${W(e,.45)}" stroke-width="3.5"/><circle cx="32" cy="31" r="3.5" fill="${W(e,.45)}"/>`:r==="cozy"?n=`<path d="M32 41 C22 34 19 29 22 25 C25 21 30 22 32 26 C34 22 39 21 42 25 C45 29 42 34 32 41Z" fill="${W(e,.35)}"/>`:r==="post-apocalypse"?n=`<path d="${Go(32,31,13,10,3)}" fill="${W(e,.4)}"/><circle cx="32" cy="31" r="5" fill="${e}"/>`:n=`<polygon points="${et(32,31,12,5.5)}" fill="${W(e,.35)}"/>`,ae(pe("g",[[0,Z(e,.45)],[.55,e],[1,W(e,.2)]]))+`<circle cx="32" cy="35" r="26" fill="${W(e,.5)}" stroke="${t}" stroke-width="3"/><circle cx="32" cy="31" r="26" fill="url(#g)" stroke="${t}" stroke-width="3"/><circle cx="32" cy="31" r="19" fill="none" stroke="${o}" stroke-width="2.5"/>`+n+Gr("M15 24 A19 19 0 0 1 28 12")}},Dp={w:64,h:64,main:"accent",draw({main:e,ink:t}){return Dt(32,59,14,3.5)+`<polygon points="32,4 52,22 44,57 20,57 12,22" fill="${e}" stroke="${t}" stroke-width="3" stroke-linejoin="round"/><polygon points="32,4 12,22 26,24" fill="${Z(e,.5)}"/><polygon points="32,4 26,24 38,24" fill="${Z(e,.3)}"/><polygon points="32,4 38,24 52,22" fill="${W(e,.1)}"/><polygon points="12,22 26,24 20,57" fill="${Z(e,.15)}"/><polygon points="52,22 38,24 44,57" fill="${W(e,.3)}"/><polygon points="26,24 38,24 44,57 20,57" fill="${e}"/>`+Gr("M22 18 L28 10",3,.8)}},Op={w:64,h:64,main:"danger",draw({main:e,ink:t}){return ae(pe("g",[[0,Z(e,.3)],[1,W(e,.25)]]))+`<path d="M32 56 C12 42 5 32 8 21 C11 10 25 8 32 19 C39 8 53 10 56 21 C59 32 52 42 32 56Z" fill="url(#g)" stroke="${t}" stroke-width="3.5" stroke-linejoin="round"/>`+Gr("M16 22 C17 16 22 14 26 17",4,.7)}},Cp={w:100,h:100,draw({style:e,ink:t,c:r}){if(e==="sci-fi"){let n=r("primary");return ae(pe("m",[[0,"#5d6f96"],[1,"#2a3452"]]),qe("o",[[0,Z(n,.6)],[.5,n,.9],[1,n,0]]))+Dt(50,95,40,5)+`<rect x="12" y="18" width="76" height="74" rx="10" fill="url(#m)" stroke="${t}" stroke-width="4"/><rect x="20" y="26" width="60" height="10" rx="3" fill="#1a2238"/><rect x="22" y="28" width="56" height="6" rx="2" fill="${n}" opacity="0.85"/><circle cx="50" cy="62" r="20" fill="url(#o)"/><circle cx="50" cy="62" r="11" fill="${Z(n,.3)}" stroke="${t}" stroke-width="3"/><circle cx="22" cy="84" r="3" fill="#9fb2d8"/><circle cx="78" cy="84" r="3" fill="#9fb2d8"/>`}if(e==="cozy"){let n="#f2c862";return ae(pe("h",[[0,Z(n,.25)],[1,W(n,.2)]]))+Dt(50,94,42,5)+`<rect x="8" y="26" width="84" height="66" rx="22" fill="url(#h)" stroke="${t}" stroke-width="4"/>`+[36,50,64,78].map(s=>`<path d="M18 ${s} Q50 ${s-5} 82 ${s}" stroke="${W(n,.25)}" stroke-width="2.5" fill="none"/>`).join("")+`<rect x="30" y="24" width="7" height="70" fill="#c0563d" stroke="${t}" stroke-width="2"/><rect x="63" y="24" width="7" height="70" fill="#c0563d" stroke="${t}" stroke-width="2"/>`+Gr("M20 38 Q30 32 44 33",4,.5)}if(e==="post-apocalypse"){let n="#9a4a26";return ae(pe("r",[[0,"#6a2e18"],[.35,Z(n,.15)],[.7,n],[1,"#4a2010"]],true))+Dt(50,95,34,5)+`<rect x="18" y="10" width="64" height="84" rx="8" fill="url(#r)" stroke="${t}" stroke-width="4"/><rect x="16" y="28" width="68" height="6" fill="#5a2814" stroke="${t}" stroke-width="2"/><rect x="16" y="68" width="68" height="6" fill="#5a2814" stroke="${t}" stroke-width="2"/><polygon points="50,40 62,60 38,60" fill="#e8c23a" stroke="${t}" stroke-width="2.5" stroke-linejoin="round"/><rect x="48.5" y="45" width="3" height="8" fill="${t}"/><circle cx="50" cy="56.5" r="1.8" fill="${t}"/><path d="M24 82 q6 -6 10 2 q4 6 9 0" stroke="#3a1608" stroke-width="3" fill="none" opacity="0.6"/>`}if(e==="fantasy"){let n="#9a6234";return ae(pe("w",[[0,"#5a3418"],[.3,Z(n,.15)],[.7,n],[1,"#4a2a12"]],true))+Dt(50,95,36,5)+`<path d="M24 10 Q14 52 24 94 L76 94 Q86 52 76 10Z" fill="url(#w)" stroke="${t}" stroke-width="4" stroke-linejoin="round"/>`+[38,50,62].map(s=>`<path d="M${s} 12 Q${s+(s-50)*.25} 52 ${s} 92" stroke="${W(n,.35)}" stroke-width="2" fill="none"/>`).join("")+[24,76].map(s=>`<path d="M19 ${s} Q50 ${s+4} 81 ${s}" stroke="#4d525c" stroke-width="7" fill="none"/><path d="M19 ${s-2} Q50 ${s+2} 81 ${s-2}" stroke="#8d939e" stroke-width="2" fill="none"/>`).join("")+Gr("M28 30 Q26 50 28 66",4,.35)}let o="#b07a44";return Dt(50,95,42,5)+`<rect x="10" y="14" width="80" height="80" rx="6" fill="${o}" stroke="${t}" stroke-width="4"/><rect x="18" y="22" width="64" height="64" fill="${W(o,.12)}" stroke="${W(o,.4)}" stroke-width="3"/><path d="M20 24 L80 84 M80 24 L20 84" stroke="${Z(o,.15)}" stroke-width="9"/><path d="M20 24 L80 84 M80 24 L20 84" stroke="${W(o,.4)}" stroke-width="2" fill="none" opacity="0.5"/>`+[18,82].flatMap(n=>[22,86].map(s=>`<circle cx="${n}" cy="${s}" r="3" fill="#6b6f78"/>`)).join("")}},Pp={w:100,h:60,draw({style:e,ink:t,c:r}){let o=[18,50,82];if(e==="sci-fi"){let s=r("danger");return ae(pe("l",[[0,Z(s,.6),.95],[1,s,.2]]))+o.map(a=>`<polygon points="${a-9},52 ${a},6 ${a+9},52" fill="url(#l)"/>`).join("")+o.map(a=>`<line x1="${a}" y1="10" x2="${a}" y2="50" stroke="#fff" stroke-width="2" opacity="0.8"/>`).join("")+`<rect x="2" y="48" width="96" height="11" rx="3" fill="#2a3452" stroke="${t}" stroke-width="3"/>`+o.map(a=>`<circle cx="${a}" cy="53" r="3" fill="${s}"/>`).join("")}if(e==="cozy")return `<path d="M6 58 C2 40 14 26 26 30 C30 14 48 10 54 24 C64 12 86 18 84 34 C98 36 100 52 94 58Z" fill="#6cbf5c" stroke="${t}" stroke-width="3.5" stroke-linejoin="round"/>`+[[18,36],[36,24],[56,22],[74,30],[88,44],[28,48],[62,44]].map(([a,i])=>`<polygon points="${a-3},${i+2} ${a},${i-7} ${a+3},${i+2}" fill="#fff4e6" stroke="${t}" stroke-width="1.5"/>`).join("")+'<circle cx="44" cy="40" r="4" fill="#ff8fab"/><circle cx="72" cy="46" r="3.5" fill="#ff8fab"/>';let n=e==="post-apocalypse"?"#8a6a52":"#b9c1cd";return ae(pe("s",[[0,Z(n,.4)],[.5,n],[1,W(n,.45)]],true))+o.map(s=>`<polygon points="${s-14},50 ${s},4 ${s+14},50" fill="url(#s)" stroke="${t}" stroke-width="3" stroke-linejoin="round"/>`).join("")+(e==="post-apocalypse"?'<path d="M2 40 q8 -10 16 0 q8 10 16 0 q8 -10 16 0 q8 10 16 0 q8 -10 16 0 q8 10 16 0" stroke="#5a4a3a" stroke-width="3" fill="none"/>':"")+`<rect x="2" y="47" width="96" height="12" rx="3" fill="${e==="post-apocalypse"?"#4a3a2a":"#5a4636"}" stroke="${t}" stroke-width="3"/>`}},Ip={w:60,h:180,main:"accent",draw({style:e,ink:t,main:r,c:o}){if(e==="sci-fi"){let a=o("primary");return ae(qe("b",[[0,"#fff"],[.4,a],[1,a,0]]))+`<rect x="24" y="30" width="10" height="146" rx="3" fill="#4a5a80" stroke="${t}" stroke-width="3"/><circle cx="29" cy="24" r="22" fill="url(#b)"/><circle cx="29" cy="24" r="8" fill="#fff" stroke="${t}" stroke-width="2"/><rect x="34" y="50" width="24" height="34" rx="3" fill="${r}" opacity="0.75" stroke="${Z(r,.5)}" stroke-width="2"/><rect x="14" y="166" width="30" height="12" rx="3" fill="#2a3452" stroke="${t}" stroke-width="3"/>`}let n=e==="post-apocalypse"?"#7a6a5a":e==="cozy"?"#e8d8c8":"#c8a060",s=e==="post-apocalypse"?`<path d="M30 22 L58 28 L52 40 L58 52 L40 50 L44 60 L30 58Z" fill="${r}" stroke="${t}" stroke-width="3" stroke-linejoin="round"/>`:e==="cozy"?`<path d="M30 22 Q46 16 58 26 Q50 40 58 54 Q44 46 30 56Z" fill="${r}" stroke="${t}" stroke-width="3" stroke-linejoin="round"/><path d="M44 44 C38 40 37 37 39 35 C41 33 43 34 44 36 C45 34 47 33 49 35 C51 37 50 40 44 44Z" fill="#fff"/>`:`<path d="M30 22 L58 22 L58 62 L44 54 L30 62Z" fill="${r}" stroke="${t}" stroke-width="3" stroke-linejoin="round"/><polygon points="${et(44,38,8,3.5)}" fill="${o("coin")}"/>`;return Dt(30,176,18,3.5)+`<rect x="25" y="14" width="8" height="162" rx="3" fill="${n}" stroke="${t}" stroke-width="3"/>`+s+`<circle cx="29" cy="12" r="7" fill="${o("coin")}" stroke="${t}" stroke-width="3"/>`}},Vc={w:64,h:32,main:"primary",draw({style:e,main:t,c:r}){return e==="sci-fi"?ae(pe("t",[[0,t,0],[1,t,.9]],true))+`<rect x="2" y="11" width="44" height="10" rx="5" fill="url(#t)"/><rect x="22" y="9" width="40" height="14" rx="7" fill="${t}"/><rect x="28" y="13" width="30" height="6" rx="3" fill="#fff"/>`:e==="post-apocalypse"?ae(pe("t",[[0,r("coin"),0],[1,r("coin"),.8]],true))+'<rect x="0" y="13" width="44" height="6" rx="3" fill="url(#t)"/><path d="M40 10 L54 10 Q62 16 54 22 L40 22Z" fill="#c9a24a" stroke="#3a2a12" stroke-width="2"/>':e==="cozy"?ae(pe("t",[[0,t,0],[1,t,.7]],true))+`<rect x="0" y="12" width="40" height="8" rx="4" fill="url(#t)"/><polygon points="${et(46,16,14,6)}" fill="${r("coin")}" stroke="#5b3b33" stroke-width="2" stroke-linejoin="round"/>`:ae(pe("t",[[0,t,0],[1,t,.85]],true),qe("o",[[0,"#fff"],[.45,Z(t,.4)],[1,t,0]]))+'<path d="M2 16 Q20 8 40 10 L40 22 Q20 24 2 16Z" fill="url(#t)"/><circle cx="46" cy="16" r="15" fill="url(#o)"/><circle cx="46" cy="16" r="6" fill="#fff"/>'}},Np=e=>({w:100,h:100,main:`piece${e}`,draw({main:t,ink:r}){let o=Z(t,.55),n=Z(t,.2),s=W(t,.32),a=ae(pe("g",[[0,Z(t,.35)],[1,W(t,.25)]])),i=`stroke="${r}" stroke-width="4" stroke-linejoin="round"`,p;switch(e){case 1:p=`<circle cx="50" cy="52" r="40" fill="url(#g)" ${i}/><polygon points="${Tt(50,52,22,8,-Math.PI/8)}" fill="${n}"/><polygon points="${Tt(50,52,22,8,-Math.PI/8).split(" ").slice(5,8).join(" ")} 50,52" fill="${o}"/><polygon points="${Tt(50,52,22,8,-Math.PI/8).split(" ").slice(1,4).join(" ")} 50,52" fill="${s}"/>`;break;case 2:p=`<path d="M50 8 C66 30 84 46 84 64 C84 82 68 92 50 92 C32 92 16 82 16 64 C16 46 34 30 50 8Z" fill="url(#g)" ${i}/><path d="M50 24 C60 40 70 50 70 64 C70 76 60 82 50 82Z" fill="${s}" opacity="0.6"/><path d="M50 24 C40 40 30 50 30 64 C30 76 40 82 50 82Z" fill="${n}" opacity="0.7"/>`;break;case 3:p=`<polygon points="28,10 72,10 90,28 90,72 72,90 28,90 10,72 10,28" fill="url(#g)" ${i}/><polygon points="32,24 68,24 76,32 76,68 68,76 32,76 24,68 24,32" fill="${n}"/><polygon points="28,10 72,10 68,24 32,24" fill="${o}"/><polygon points="90,28 90,72 76,68 76,32" fill="${s}"/><polygon points="36,34 64,34 64,66 36,66" fill="${t}"/>`;break;case 4:p=`<polygon points="${et(50,54,44,20)}" fill="url(#g)" ${i}/><polygon points="${et(50,54,22,10)}" fill="${n}"/><polygon points="50,10 50,54 30,44" fill="${o}" opacity="0.7"/>`;break;case 5:p=`<polygon points="50,6 90,50 50,94 10,50" fill="url(#g)" ${i}/><polygon points="50,6 10,50 50,50" fill="${o}"/><polygon points="50,6 90,50 50,50" fill="${n}"/><polygon points="10,50 50,94 50,50" fill="${t}"/><polygon points="90,50 50,94 50,50" fill="${s}"/><polygon points="50,30 64,50 50,70 36,50" fill="${Z(t,.35)}"/>`;break;default:p=`<polygon points="${Tt(50,50,42,6)}" fill="url(#g)" ${i}/><polygon points="${Tt(50,50,24,6)}" fill="${n}"/><polygon points="${Tt(50,50,42,6).split(" ").slice(4,6).join(" ")} ${Tt(50,50,42,6).split(" ")[0]} 50,50" fill="${o}" opacity="0.6"/><polygon points="${Tt(50,50,42,6).split(" ").slice(1,4).join(" ")} 50,50" fill="${s}" opacity="0.55"/>`;}return a+Dt(50,94,30,4,.22)+p+Gr("M28 30 Q32 22 40 20",5,.75)}}),Ps=e=>`<path d="M24 86 Q50 72 76 86 Q76 94 50 94 Q24 94 24 86Z" fill="#7a5032" stroke="${e}" stroke-width="3"/>`,Un=(e,t,r,o,n,s)=>`<path transform="translate(${e} ${t}) rotate(${r}) scale(${o})" d="M0 0 C6 -10 18 -10 22 0 C18 8 6 8 0 0Z" fill="${n}" stroke="${s}" stroke-width="${q(2.4/o)}"/>`,Ko=(e,t,r,o,n)=>`<circle cx="${e-r*.55}" cy="${t+r*.2}" r="${r*.7}" fill="${W(o,.1)}" stroke="${n}" stroke-width="3"/><circle cx="${e+r*.55}" cy="${t+r*.2}" r="${r*.7}" fill="${W(o,.1)}" stroke="${n}" stroke-width="3"/><circle cx="${e}" cy="${t-r*.15}" r="${r*.85}" fill="${o}" stroke="${n}" stroke-width="3"/><circle cx="${e-r*.3}" cy="${t-r*.4}" r="${r*.3}" fill="${Z(o,.3)}"/>`,Ii=(e,t=50)=>`<path d="M45 92 L47 ${t} L53 ${t} L55 92Z" fill="#8a5a32" stroke="${e}" stroke-width="3" stroke-linejoin="round"/>`;function zp(e,t){let{ink:r}=t,o=t.style==="cozy"?"#7fd36e":"#58b04a",n=t.c("primary");switch(e){case 1:return Dt(50,84,18,4)+`<ellipse cx="50" cy="64" rx="15" ry="20" fill="#b07a44" stroke="${r}" stroke-width="3.5"/>`+Gr("M44 54 Q46 48 50 47",3.5,.6);case 2:return Ps(r)+`<path d="M50 84 Q48 66 50 56" stroke="${W(o,.2)}" stroke-width="5" fill="none" stroke-linecap="round"/>`+Un(50,60,-150,1,o,r)+Un(50,60,-30,1,o,r);case 3:return Ps(r)+`<path d="M50 84 Q47 60 50 38" stroke="${W(o,.2)}" stroke-width="5" fill="none" stroke-linecap="round"/>`+Un(50,66,-160,1.1,o,r)+Un(50,62,-20,1.1,o,r)+Un(50,44,-130,.9,Z(o,.15),r)+Un(50,42,-50,.9,Z(o,.15),r);case 4:return Ps(r)+Ko(50,62,26,o,r);case 5:return Ps(r)+Ko(50,62,28,o,r)+[[34,56],[56,44],[66,64],[46,70]].map(([s,a])=>`<polygon points="${et(s,a,7,3.5,5)}" fill="${n}" stroke="${r}" stroke-width="1.5"/><circle cx="${s}" cy="${a}" r="2" fill="#fff6c0"/>`).join("");case 6:return Dt(50,93,26,4)+Ii(r,52)+Ko(50,40,32,o,r);case 7:return Dt(50,93,28,4)+Ii(r,54)+Ko(50,40,34,W(o,.05),r)+[[34,36],[58,26],[66,46],[44,52],[52,38]].map(([s,a])=>`<circle cx="${s}" cy="${a}" r="5.5" fill="${t.c("danger")}" stroke="${r}" stroke-width="2"/><circle cx="${s-1.5}" cy="${a-1.5}" r="1.6" fill="#fff" opacity="0.8"/>`).join("");default:{let s=t.c("coin");return Dt(50,93,30,4)+Ii(r,54)+Ko(50,38,36,s,r)+[[22,18],[80,22],[74,64],[24,60],[50,6]].map(([a,i])=>`<polygon points="${et(a,i,6,2,4)}" fill="#fff"/>`).join("")}}}function Bp(e,t){let{ink:r}=t,o=t.style==="post-apocalypse"?"#9a8a72":"#a9b8d6",n=t.style==="post-apocalypse"?t.c("coin"):t.c("primary"),s=ae(pe("m",[[0,Z(o,.35)],[1,W(o,.35)]]));switch(e){case 1:return s+Dt(50,88,16,4)+`<rect x="44" y="34" width="12" height="50" rx="2" fill="url(#m)" stroke="${r}" stroke-width="3"/>`+[44,54,64,74].map(a=>`<line x1="44" y1="${a}" x2="56" y2="${a-4}" stroke="${W(o,.45)}" stroke-width="2"/>`).join("")+`<rect x="32" y="22" width="36" height="14" rx="5" fill="url(#m)" stroke="${r}" stroke-width="3"/><line x1="42" y1="29" x2="58" y2="29" stroke="${r}" stroke-width="3"/>`;case 2:return s+Dt(50,86,26,4)+`<polygon points="${Tt(50,54,30,6)}" fill="url(#m)" stroke="${r}" stroke-width="3.5"/><circle cx="50" cy="54" r="12" fill="${W(o,.5)}" stroke="${r}" stroke-width="3"/>`+Gr("M30 42 L42 34",3.5,.6);case 3:return s+Dt(50,90,30,4)+`<path d="${Go(50,52,36,10,8)}" fill="url(#m)" stroke="${r}" stroke-width="3"/><circle cx="50" cy="52" r="12" fill="${W(o,.5)}" stroke="${r}" stroke-width="3"/>`;case 4:return s+Dt(50,90,34,4)+`<path d="${Go(36,60,26,9,6)}" fill="url(#m)" stroke="${r}" stroke-width="3"/><path d="${Go(66,38,22,8,6)}" fill="${Z(o,.1)}" stroke="${r}" stroke-width="3"/><circle cx="36" cy="60" r="8" fill="${n}" stroke="${r}" stroke-width="2.5"/><circle cx="66" cy="38" r="7" fill="${W(o,.5)}" stroke="${r}" stroke-width="2.5"/>`;case 5:return s+Dt(50,90,34,4)+[26,38,50,62,74].map(a=>`<rect x="${a-2}" y="12" width="4" height="12" fill="#c9a24a"/><rect x="${a-2}" y="76" width="4" height="12" fill="#c9a24a"/>`).join("")+`<rect x="18" y="22" width="64" height="56" rx="6" fill="#2a3040" stroke="${r}" stroke-width="3.5"/><rect x="32" y="36" width="36" height="28" rx="3" fill="${n}" opacity="0.85"/><path d="M36 50 H46 V42 H54 V58 H64" stroke="#fff" stroke-width="2.5" fill="none"/>`;case 6:return s+Dt(50,92,22,4)+`<rect x="28" y="20" width="44" height="70" rx="8" fill="url(#m)" stroke="${r}" stroke-width="3.5"/><rect x="40" y="10" width="20" height="12" rx="3" fill="${W(o,.3)}" stroke="${r}" stroke-width="3"/><rect x="34" y="30" width="32" height="52" rx="4" fill="#1d2230"/>`+[0,1,2].map(a=>`<rect x="38" y="${66-a*15}" width="24" height="11" rx="2" fill="${n}" opacity="${.95-a*.25}"/>`).join("");case 7:return s+Dt(50,94,32,4)+`<line x1="50" y1="6" x2="50" y2="20" stroke="${r}" stroke-width="3"/><circle cx="50" cy="6" r="5" fill="${t.c("danger")}" stroke="${r}" stroke-width="2"/><rect x="16" y="20" width="68" height="60" rx="16" fill="url(#m)" stroke="${r}" stroke-width="3.5"/><rect x="26" y="34" width="48" height="24" rx="10" fill="#1d2230"/><circle cx="40" cy="46" r="7" fill="${n}"/><circle cx="60" cy="46" r="7" fill="${n}"/><rect x="38" y="64" width="24" height="6" rx="3" fill="${W(o,.5)}"/><rect x="6" y="38" width="10" height="22" rx="4" fill="${W(o,.2)}" stroke="${r}" stroke-width="3"/><rect x="84" y="38" width="10" height="22" rx="4" fill="${W(o,.2)}" stroke="${r}" stroke-width="3"/>`;default:return s+ae(qe("f",[[0,"#fff"],[.4,t.c("coin")],[1,t.c("danger"),0]]))+`<ellipse cx="50" cy="88" rx="16" ry="12" fill="url(#f)"/><path d="M50 4 C66 18 70 40 66 70 L34 70 C30 40 34 18 50 4Z" fill="url(#m)" stroke="${r}" stroke-width="3.5"/><circle cx="50" cy="34" r="9" fill="${n}" stroke="${r}" stroke-width="3"/><path d="M34 54 L20 76 L34 72Z M66 54 L80 76 L66 72Z" fill="${t.c("danger")}" stroke="${r}" stroke-width="3" stroke-linejoin="round"/>`}}var Hp=e=>({w:100,h:100,draw(t){return t.style==="sci-fi"||t.style==="post-apocalypse"?Bp(e,t):zp(e,t)}}),Wp={w:100,h:100,main:"accent",draw({style:e,ink:t,c:r}){let o=e==="sci-fi"?"#4a5a80":e==="post-apocalypse"?"#5e6a3a":e==="cozy"?"#e09a5a":"#9a5a2c",n=e==="sci-fi"?r("primary"):e==="post-apocalypse"?"#8a8a7a":r("coin");return ae(pe("b",[[0,Z(o,.2)],[1,W(o,.3)]]),pe("l",[[0,Z(o,.35)],[1,o]]))+Dt(50,92,40,5)+`<rect x="10" y="44" width="80" height="46" rx="6" fill="url(#b)" stroke="${t}" stroke-width="4"/><path d="M10 46 L10 34 Q50 4 90 34 L90 46Z" fill="url(#l)" stroke="${t}" stroke-width="4" stroke-linejoin="round"/><rect x="10" y="42" width="80" height="8" fill="${n}" stroke="${t}" stroke-width="3"/><rect x="20" y="18" width="8" height="72" fill="${n}" opacity="0.9"/><rect x="72" y="18" width="8" height="72" fill="${n}" opacity="0.9"/><rect x="40" y="44" width="20" height="22" rx="4" fill="${n}" stroke="${t}" stroke-width="3"/><circle cx="50" cy="54" r="3.5" fill="${t}"/>`+Gr("M18 32 Q34 18 48 16",4,.45)}},Gc={coin:Tp,crystal:Dp,heart:Op,obstacle:Cp,spike:Pp,flag:Ip,shot:Vc,bolt:Vc,chest:Wp,...Object.fromEntries([1,2,3,4,5,6].map(e=>[`gem${e}`,Np(e)])),...Object.fromEntries([1,2,3,4,5,6,7,8].map(e=>[`item${e}`,Hp(e)]))};var pn=(e,t,r)=>q(Math.min(e,t)*r),jp={w:0,h:0,exact:true,main:"panel",draw({w:e,h:t,main:r,ink:o}){let n=Math.max(2,Math.min(Math.min(e,t)*.035,7)),s=q(Math.min(Math.min(e,t)*.14,24)),a=Cs(r)>.6;return ae(pe("p",[[0,Z(r,a?.3:.12)],[1,W(r,a?.06:.25)]]))+`<rect x="${q(n/2)}" y="${q(n*1.5)}" width="${q(e-n)}" height="${q(t-n*2)}" rx="${s}" fill="#000" opacity="0.25"/><rect x="${q(n/2)}" y="${q(n/2)}" width="${q(e-n)}" height="${q(t-n*2)}" rx="${s}" fill="url(#p)" stroke="${a?W(r,.3):o}" stroke-width="${q(n)}"/><rect x="${q(n*2)}" y="${q(n*2)}" width="${q(e-n*4)}" height="${q(Math.max(1,t*.12))}" rx="${pn(e,t,.06)}" fill="#fff" opacity="0.1"/>`}},Vp={w:0,h:0,exact:true,main:"panel",draw({w:e,h:t,main:r,ink:o,c:n}){let s=Math.max(3,e*.03),a=n("coin");return ae(pe("p",[[0,Z(r,.18)],[1,W(r,.3)]]),pe("g",[[0,Z(a,.35)],[1,W(a,.25)]]))+`<rect x="${q(s)}" y="${q(s*2)}" width="${q(e-s*2)}" height="${q(t-s*2.5)}" rx="${pn(e,t,.1)}" fill="#000" opacity="0.35"/><rect x="${q(s)}" y="${q(s)}" width="${q(e-s*2)}" height="${q(t-s*2.5)}" rx="${pn(e,t,.1)}" fill="url(#g)" stroke="${o}" stroke-width="${q(s*.8)}"/><rect x="${q(s*2.4)}" y="${q(s*2.4)}" width="${q(e-s*4.8)}" height="${q(t-s*5.3)}" rx="${pn(e,t,.07)}" fill="url(#p)"/><circle cx="${q(e/2)}" cy="${q(t*.3)}" r="${q(e*.2)}" fill="${a}" opacity="0.18"/>`}},Gp={w:0,h:0,exact:true,main:"accent",draw({w:e,h:t,main:r,ink:o}){let n=Math.max(2,Math.min(e,t)*.06),s=t*.12;return ae(pe("b",[[0,Z(r,.3)],[1,W(r,.1)]]))+`<rect x="${q(n/2)}" y="${q(s)}" width="${q(e-n)}" height="${q(t-s-n/2)}" rx="${pn(e,t,.3)}" fill="${W(r,.45)}" stroke="${o}" stroke-width="${q(n)}"/><rect x="${q(n/2)}" y="${q(n/2)}" width="${q(e-n)}" height="${q(t-s-n/2)}" rx="${pn(e,t,.3)}" fill="url(#b)" stroke="${o}" stroke-width="${q(n)}"/><rect x="${q(e*.12)}" y="${q(t*.12)}" width="${q(e*.76)}" height="${q(t*.16)}" rx="${q(t*.08)}" fill="#fff" opacity="0.35"/>`}},Kp={w:0,h:0,exact:true,main:"ground",draw({w:e,h:t,main:r}){let o=Cs(r)>.55;return ae(pe("c",[[0,W(r,o?.12:.3)],[1,Z(r,o?.1:.06)]]))+`<rect x="1.5" y="1.5" width="${q(e-3)}" height="${q(t-3)}" rx="${pn(e,t,.16)}" fill="url(#c)"/><rect x="1.5" y="1.5" width="${q(e-3)}" height="${q(t-3)}" rx="${pn(e,t,.16)}" fill="none" stroke="#000" stroke-opacity="0.18" stroke-width="2"/>`}},Fp={w:0,h:0,exact:true,main:"panel",draw({w:e,h:t,main:r,ink:o}){let n=t*.16,s=Math.max(2,Math.min(e,t)*.05),i=Cs(r)>.6?Z(r,.4):Z(r,.85);return `<path d="M${q(s)} ${q(s)} H${q(e-s)} V${q(t-n-s)} H${q(e*.58)} L${q(e*.5)} ${q(t-s)} L${q(e*.42)} ${q(t-n-s)} H${q(s)}Z" fill="${i}" stroke="${o}" stroke-width="${q(s)}" stroke-linejoin="round"/>`}},qp={w:100,h:100,draw(){let e="#1c1622",t="#ffffff",r="#d9dde8";return `<ellipse cx="60" cy="96" rx="26" ry="4" fill="#000" opacity="0.18"/><path d="M30 52 L30 14 Q30 5 39 5 Q48 5 48 14 L48 44 Q50 38 57 38 Q64 38 65 45 Q67 40 73 40 Q80 41 80 49 Q82 45 86 46 Q92 48 91 56 L89 76 Q86 92 70 94 L48 94 Q36 93 31 82 L17 64 Q13 58 18 54 Q23 50 28 55 Z" fill="${t}" stroke="${e}" stroke-width="4" stroke-linejoin="round"/><path d="M48 44 L48 58 M65 45 L65 58 M80 49 L80 60" stroke="${e}" stroke-width="3" stroke-linecap="round"/><path d="M34 86 Q44 92 58 91" stroke="${r}" stroke-width="5" fill="none" stroke-linecap="round"/><path d="M35 14 Q36 9 40 9" stroke="${r}" stroke-width="3" fill="none" stroke-linecap="round"/>`}},Up={w:100,h:100,main:"accent",draw({main:e,ink:t}){return ae(pe("p",[[0,Z(e,.35)],[1,W(e,.15)]]))+`<circle cx="50" cy="54" r="44" fill="${W(e,.45)}"/><circle cx="50" cy="50" r="44" fill="url(#p)" stroke="${t}" stroke-width="4"/><circle cx="50" cy="50" r="36" fill="none" stroke="#fff" stroke-opacity="0.35" stroke-width="3"/><path d="M41 30 L72 50 L41 70 Z" fill="#fff" stroke="${t}" stroke-width="3.5" stroke-linejoin="round"/><path d="M22 38 Q28 22 44 16" stroke="#fff" stroke-width="5" fill="none" stroke-linecap="round" opacity="0.55"/>`}},Kc={panel:jp,card:Vp,button:Gp,cell:Kp,ticket:Fp,hand:qp,play:Up};var Lr=(e,t=4,r=.55)=>`<path d="${e}" fill="none" stroke="#fff" stroke-width="${t}" stroke-linecap="round" opacity="${r}"/>`,mr=(e,t)=>({w:64,h:64,main:e,draw:({main:r,ink:o})=>t(r,o)}),Xp=mr("primary",(e,t)=>ae(pe("b",[[0,Z(e,.55)],[1,W(e,.15)]]))+`<path d="M32 4 C50 10 58 28 52 46 C48 34 40 26 30 24 C28 16 29 9 32 4Z" fill="url(#b)" stroke="${t}" stroke-width="3" stroke-linejoin="round"/><path d="M32 60 C14 54 6 36 12 18 C16 30 24 38 34 40 C36 48 35 55 32 60Z" fill="url(#b)" stroke="${t}" stroke-width="3" stroke-linejoin="round"/><circle cx="32" cy="32" r="8" fill="${W(e,.35)}" stroke="${t}" stroke-width="3"/><circle cx="32" cy="32" r="3" fill="${Z(e,.6)}"/>`+Lr("M36 9 C44 13 49 20 51 28",3,.7)),Zp=mr("secondary",(e,t)=>ae(qe("a",[[0,Z(e,.7),.95],[.55,e,.55],[1,e,0]]))+`<circle cx="32" cy="32" r="29" fill="url(#a)"/><circle cx="32" cy="32" r="20" fill="none" stroke="${Z(e,.4)}" stroke-width="3" stroke-dasharray="7 5"/><circle cx="32" cy="32" r="10" fill="${Z(e,.5)}" stroke="${t}" stroke-width="2.5"/>`),Qp={w:100,h:100,main:"secondary",draw:({main:e})=>ae(qe("a",[[0,e,.05],[.7,e,.18],[.94,Z(e,.3),.5],[1,Z(e,.4),0]]))+`<circle cx="50" cy="50" r="50" fill="url(#a)"/><circle cx="50" cy="50" r="46" fill="none" stroke="${Z(e,.5)}" stroke-width="1.5" stroke-dasharray="6 6" opacity="0.7"/>`},Yp=mr("accent",(e,t)=>ae(pe("g",[[0,Z(e,.4)],[1,W(e,.25)]]))+`<path d="M8 14 C22 10 34 18 38 30 C46 32 54 42 56 54 C48 50 40 46 32 44 C28 32 20 24 8 14Z" fill="url(#g)" stroke="${t}" stroke-width="3.5" stroke-linejoin="round"/><path d="M14 16 C24 16 31 22 34 32" fill="none" stroke="${W(e,.35)}" stroke-width="2.5"/>`+Lr("M14 15 C22 14 28 18 31 24",3,.7)),Jp=mr("primary",(e,t)=>ae(pe("l",[[0,Z(e,.7)],[1,e]]))+`<polygon points="36,3 12,36 28,36 22,61 52,24 35,24 44,3" fill="url(#l)" stroke="${t}" stroke-width="3.5" stroke-linejoin="round"/>`+Lr("M33 9 L20 30",3,.75)),e0={w:100,h:20,main:"primary",draw:({main:e})=>`<polyline points="0,10 14,4 26,15 40,5 54,14 66,4 80,15 92,6 100,10" fill="none" stroke="${Z(e,.4)}" stroke-width="7" stroke-linejoin="round" opacity="0.55"/><polyline points="0,10 14,4 26,15 40,5 54,14 66,4 80,15 92,6 100,10" fill="none" stroke="#fff" stroke-width="2.5" stroke-linejoin="round"/>`},t0=mr("piece6",(e,t)=>ae(pe("d",[[0,Z(e,.45)],[1,W(e,.2)]]))+`<rect x="4" y="18" width="20" height="5" rx="2.5" fill="${W(e,.4)}" stroke="${t}" stroke-width="2"/><rect x="40" y="18" width="20" height="5" rx="2.5" fill="${W(e,.4)}" stroke="${t}" stroke-width="2"/><path d="M14 23 L22 32 M50 23 L42 32" stroke="${t}" stroke-width="3"/><ellipse cx="32" cy="38" rx="17" ry="13" fill="url(#d)" stroke="${t}" stroke-width="3"/><circle cx="32" cy="38" r="6" fill="#16223a" stroke="${t}" stroke-width="2"/><circle cx="33.5" cy="36.5" r="2" fill="#7fe7ff"/>`+Lr("M21 32 C24 28 28 27 31 27",3,.6)),r0=mr("danger",(e,t)=>ae(pe("f",[[0,Z(e,.35)],[1,W(e,.2)]]))+`<path d="M14 26 C14 18 20 14 26 15 L46 15 C52 15 54 20 54 25 L54 40 C54 50 46 58 36 58 L28 58 C20 58 14 52 14 44Z" fill="url(#f)" stroke="${t}" stroke-width="3.5" stroke-linejoin="round"/>`+[24,34,44].map(r=>`<path d="M${r} 16 L${r} 30" stroke="${W(e,.4)}" stroke-width="2.5"/>`).join("")+`<path d="M14 34 C22 30 30 32 32 38" fill="none" stroke="${t}" stroke-width="3"/>`+Lr("M20 20 C22 18 26 18 30 18",3,.6)),n0=mr("primary",(e,t)=>`<rect x="12" y="5" width="40" height="7" rx="3" fill="${W(e,.3)}" stroke="${t}" stroke-width="3"/><rect x="12" y="52" width="40" height="7" rx="3" fill="${W(e,.3)}" stroke="${t}" stroke-width="3"/><path d="M17 12 C17 26 30 28 30 32 C30 36 17 38 17 52 L47 52 C47 38 34 36 34 32 C34 28 47 26 47 12Z" fill="${Z(e,.75)}" stroke="${t}" stroke-width="3" stroke-linejoin="round"/><path d="M22 49 C24 42 30 40 32 40 C34 40 40 42 42 49Z" fill="${e}"/><path d="M24 16 L40 16 C38 22 34 24 32 26 C30 24 26 22 24 16Z" fill="${e}"/>`),o0=mr("accent",(e,t)=>ae(pe("b",[[0,Z(e,.35)],[1,W(e,.25)]]))+`<path d="M18 6 L38 6 L38 34 L54 40 C58 42 58 50 54 52 L14 52 C12 52 11 50 12 48 L18 34Z" fill="url(#b)" stroke="${t}" stroke-width="3.5" stroke-linejoin="round"/><rect x="12" y="52" width="46" height="6" rx="3" fill="${W(e,.45)}" stroke="${t}" stroke-width="3"/><path d="M6 22 L14 22 M3 30 L13 30 M7 38 L13 38" stroke="${Z(e,.5)}" stroke-width="3" stroke-linecap="round"/>`+Lr("M23 11 L23 30",3,.6)),s0=mr("muted",(e,t)=>ae(pe("s",[[0,Z(e,.45)],[1,W(e,.3)]]))+`<path d="M32 4 L54 12 C54 34 46 50 32 60 C18 50 10 34 10 12Z" fill="url(#s)" stroke="${t}" stroke-width="3.5" stroke-linejoin="round"/><path d="M32 12 L46 17 C46 32 41 43 32 51Z" fill="${Z(e,.25)}" opacity="0.6"/>`+Lr("M17 16 C17 26 19 34 23 40",3,.55)),a0=mr("danger",(e,t)=>`<path d="M10 8 L24 8 L24 34 C24 40 28 44 32 44 C36 44 40 40 40 34 L40 8 L54 8 L54 34 C54 48 44 58 32 58 C20 58 10 48 10 34Z" fill="${e}" stroke="${t}" stroke-width="3.5" stroke-linejoin="round"/><rect x="10" y="8" width="14" height="10" fill="#e8edf5" stroke="${t}" stroke-width="3"/><rect x="40" y="8" width="14" height="10" fill="#e8edf5" stroke="${t}" stroke-width="3"/>`+Lr("M15 26 C15 38 20 46 26 50",3,.55)),i0=mr("accent",(e,t)=>[[32,18],[46,32],[32,46],[18,32]].map(([r,o])=>`<circle cx="${r}" cy="${o}" r="12" fill="${e}" stroke="${t}" stroke-width="3"/>`).join("")+`<circle cx="32" cy="32" r="7" fill="${Z(e,.3)}"/><path d="M36 40 C40 50 44 56 50 60" fill="none" stroke="${t}" stroke-width="3.5" stroke-linecap="round"/>`+Lr("M26 12 C28 9 32 8 35 9",3,.6)),l0=mr("accent",(e,t)=>ae(pe("p",[[0,Z(e,.4)],[1,W(e,.2)]]))+`<rect x="25" y="4" width="14" height="8" rx="2" fill="#b07a44" stroke="${t}" stroke-width="3"/><path d="M26 12 L38 12 L38 22 C48 26 54 34 54 42 C54 52 44 60 32 60 C20 60 10 52 10 42 C10 34 16 26 26 22Z" fill="#e8f2ff" stroke="${t}" stroke-width="3.5" stroke-linejoin="round"/><path d="M13 40 C20 36 44 36 51 40 C51 50 43 57 32 57 C21 57 13 50 13 40Z" fill="url(#p)"/>`+Lr("M18 32 C20 28 24 26 27 25",3,.7)),c0=mr("muted",(e,t)=>ae(qe("b",[[0,"#6a7080"],[1,"#1c1f28"]],.35,.35,.7))+`<circle cx="30" cy="38" r="22" fill="url(#b)" stroke="${t}" stroke-width="3.5"/><rect x="34" y="12" width="12" height="10" rx="2" transform="rotate(35 40 17)" fill="#4a4f5c" stroke="${t}" stroke-width="3"/><path d="M44 12 C48 6 54 6 56 10" fill="none" stroke="#b07a44" stroke-width="3"/><polygon points="${et(57,9,7,3,6)}" fill="#ffd54f" stroke="${t}" stroke-width="1.5"/>`+Lr("M18 30 C20 25 24 22 28 21",4,.5)+`<circle cx="30" cy="38" r="22" fill="${e}" opacity="0.08"/>`),d0={w:40,h:40,main:"danger",draw:({main:e,ink:t})=>ae(qe("o",[[0,"#fff"],[.45,Z(e,.3)],[1,e]]))+`<circle cx="20" cy="20" r="17" fill="${e}" opacity="0.35"/><circle cx="20" cy="20" r="11" fill="url(#o)" stroke="${t}" stroke-width="2.5"/>`},f0=mr("text",(e,t)=>`<path d="M32 6 C18 6 9 16 9 28 C9 36 13 41 18 44 L18 54 C18 57 20 58 22 58 L42 58 C44 58 46 57 46 54 L46 44 C51 41 55 36 55 28 C55 16 46 6 32 6Z" fill="${Z(e,.1)}" stroke="${t}" stroke-width="3.5" stroke-linejoin="round"/><circle cx="22" cy="30" r="7" fill="${t}"/><circle cx="42" cy="30" r="7" fill="${t}"/><path d="M32 38 L28 45 L36 45Z" fill="${t}"/>`+[26,32,38].map(r=>`<path d="M${r} 50 L${r} 58" stroke="${t}" stroke-width="2.5"/>`).join("")),p0={w:64,h:64,main:"coin",draw:({main:e,ink:t})=>`<polygon points="${et(32,32,29,17,10)}" fill="${Z(e,.25)}" stroke="${t}" stroke-width="3" stroke-linejoin="round"/><polygon points="${Tt(32,32,12,6)}" fill="${e}"/>`},Fc={blade:Xp,aura:Zp,aura_field:Qp,boomerang:Yp,lightning:Jp,zap:e0,drone:t0,fist:r0,hourglass:n0,boot:o0,shield:s0,magnet:a0,clover:i0,potion:l0,bomb:c0,orb:d0,skull:f0,burst:p0};var Ni=(e,t=4,r=.5)=>`<path d="${e}" fill="none" stroke="#fff" stroke-width="${t}" stroke-linecap="round" opacity="${r}"/>`,Is=(e,t)=>e==="sci-fi"?{body:"#4f5f86",trim:t("primary"),dark:"#232c47"}:e==="cozy"?{body:"#d9935a",trim:"#f6d38a",dark:"#7a4a2e"}:e==="post-apocalypse"?{body:"#8a6a52",trim:"#c9a14a",dark:"#3d2f24"}:{body:"#9a6b43",trim:t("accent"),dark:"#4a3322"},h0={w:100,h:60,draw({style:e,ink:t,c:r}){let o=Is(e,r),n=r("danger");return ae(pe("b",[[0,Z(o.trim,.4)],[1,W(o.trim,.15)]]))+`<ellipse cx="50" cy="57" rx="44" ry="3" fill="#000" opacity="0.25"/><rect x="10" y="14" width="9" height="44" rx="3" fill="${o.body}" stroke="${t}" stroke-width="3"/><rect x="81" y="14" width="9" height="44" rx="3" fill="${o.body}" stroke="${t}" stroke-width="3"/><rect x="4" y="10" width="92" height="17" rx="5" fill="url(#b)" stroke="${t}" stroke-width="3.5"/>`+[16,38,60,82].map(s=>`<path d="M${s} 11 L${s+10} 11 L${s+2} 26 L${s-8} 26Z" fill="${n}" opacity="0.9"/>`).join("")+`<rect x="4" y="10" width="92" height="17" rx="5" fill="none" stroke="${t}" stroke-width="3.5"/><rect x="14" y="32" width="72" height="8" rx="3" fill="${W(o.trim,.1)}" stroke="${t}" stroke-width="2.5"/>`+Ni("M12 15 L88 15",2.5,.55)}},u0={w:120,h:40,draw({style:e,ink:t,c:r}){let o=Is(e,r);return ae(qe("p",[[0,"#000000",1],[.7,"#0b0d14",.95],[1,W(o.dark,.2),.9]]))+`<path d="M8 20 C10 6 32 3 60 4 C90 3 112 7 112 20 C112 33 90 37 60 36 C30 37 8 34 8 20Z" fill="${o.dark}" stroke="${t}" stroke-width="3"/><path d="M16 21 C18 11 36 9 60 9 C86 9 104 12 104 21 C104 30 86 32 60 32 C34 32 16 30 16 21Z" fill="url(#p)"/><path d="M20 12 L28 16 L34 10 L44 15 L52 9 L62 14 L72 9 L82 14 L92 10 L100 15" fill="none" stroke="${Z(o.dark,.25)}" stroke-width="2.5" stroke-linejoin="round"/>`}},m0={w:300,h:100,draw({style:e,ink:t,c:r}){let o=Is(e,r),n=r("secondary");return ae(pe("w",[[0,Z(n,.35)],[1,W(n,.3)]]))+`<rect x="4" y="8" width="292" height="72" rx="10" fill="url(#w)" stroke="${t}" stroke-width="4"/><rect x="4" y="8" width="292" height="12" rx="6" fill="${Z(n,.45)}" stroke="${t}" stroke-width="3"/>`+[30,100,170,240].map(s=>`<rect x="${s}" y="30" width="40" height="24" rx="4" fill="${Z(o.trim,.55)}" stroke="${t}" stroke-width="3"/>`).join("")+`<rect x="4" y="64" width="292" height="10" fill="${W(n,.4)}"/>`+[40,90,210,260].map(s=>`<circle cx="${s}" cy="84" r="12" fill="${o.dark}" stroke="${t}" stroke-width="3.5"/><circle cx="${s}" cy="84" r="4" fill="${o.trim}"/>`).join("")+Ni("M14 26 L120 26",3,.4)}},y0={w:140,h:100,draw({style:e,ink:t,c:r}){let o=Is(e,r);return ae(pe("r",[[0,Z(o.trim,.3)],[1,W(o.trim,.25)]]))+`<path d="M4 96 L136 8 L136 96Z" fill="${o.body}" stroke="${t}" stroke-width="4" stroke-linejoin="round"/><path d="M4 96 L136 8 L136 20 L22 96Z" fill="url(#r)" stroke="${t}" stroke-width="3" stroke-linejoin="round"/>`+[0,1,2].map(n=>{let s=60+n*22,a=70-n*15;return `<path d="M${s-8} ${a+6} L${s} ${a-4} L${s+8} ${a+6}" fill="none" stroke="#fff" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" opacity="0.8"/>`}).join("")}},g0={w:100,h:100,draw({style:e,ink:t,c:r}){let o=e==="sci-fi"?"#7c86a8":e==="cozy"?"#b8a99a":"#8f8a82",n=e==="cozy"?"#7ccf6a":e==="sci-fi"?r("primary"):"#6b8f4a";return ae(pe("s",[[0,Z(o,.35)],[1,W(o,.35)]]))+`<ellipse cx="50" cy="95" rx="42" ry="5" fill="#000" opacity="0.28"/><path d="M10 92 C4 70 14 44 30 32 C40 14 66 10 80 26 C96 40 98 70 90 92Z" fill="url(#s)" stroke="${t}" stroke-width="4" stroke-linejoin="round"/><path d="M34 50 L46 62 M62 40 L70 54 M28 74 L40 70" stroke="${W(o,.45)}" stroke-width="3" stroke-linecap="round"/><path d="M30 34 C40 26 52 24 62 28" fill="none" stroke="${n}" stroke-width="6" stroke-linecap="round" opacity="0.85"/>`+Ni("M24 48 C28 38 36 32 44 30",4,.45)}},b0={w:100,h:30,draw:()=>ae(qe("d",[[0,"#000000",.8],[.7,"#000000",.5],[1,"#000000",0]]))+'<ellipse cx="50" cy="15" rx="50" ry="15" fill="url(#d)"/>'},x0={w:60,h:300,draw({ink:e,c:t}){let r="#ffffff",o="#1b1d24",n=[];for(let s=0;s<14;s++)for(let a=0;a<2;a++)n.push(`<rect x="${16+a*14}" y="${18+s*18}" width="14" height="18" fill="${(s+a)%2===0?r:o}"/>`);return `<rect x="10" y="10" width="40" height="270" rx="4" fill="${o}" stroke="${e}" stroke-width="4"/>`+n.join("")+`<rect x="10" y="10" width="40" height="270" rx="4" fill="none" stroke="${e}" stroke-width="4"/><rect x="4" y="276" width="52" height="20" rx="5" fill="${t("accent")}" stroke="${e}" stroke-width="3.5"/><circle cx="30" cy="8" r="7" fill="${t("coin")}" stroke="${e}" stroke-width="3"/>`}},k0={w:64,h:64,main:"coin",draw:({main:e,ink:t})=>ae(qe("c",[[0,Z(e,.5)],[.7,e],[1,W(e,.2)]]))+`<circle cx="24" cy="36" r="18" fill="url(#c)" stroke="${t}" stroke-width="3.5"/><circle cx="40" cy="26" r="18" fill="url(#c)" stroke="${t}" stroke-width="3.5"/><circle cx="40" cy="26" r="11" fill="none" stroke="${W(e,.25)}" stroke-width="2.5"/><rect x="30" y="40" width="30" height="20" rx="7" fill="${W(e,.55)}" stroke="${t}" stroke-width="3"/><path d="M36 45 L43 55 M43 45 L36 55" stroke="#fff" stroke-width="3.2" stroke-linecap="round"/><path d="M47 47 C48 43 55 43 55 47 C55 50 47 53 47 55 L55 55" fill="none" stroke="#fff" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/>`},v0={w:64,h:64,main:"secondary",draw:({main:e,ink:t})=>ae(pe("g",[[0,Z(e,.6)],[1,W(e,.15)]]))+`<path d="M32 40 C22 22 10 14 4 14 C6 26 10 40 20 48 C10 48 8 52 6 56 C18 58 28 54 32 48Z" fill="url(#g)" stroke="${t}" stroke-width="3" stroke-linejoin="round"/><path d="M32 40 C42 22 54 14 60 14 C58 26 54 40 44 48 C54 48 56 52 58 56 C46 58 36 54 32 48Z" fill="url(#g)" stroke="${t}" stroke-width="3" stroke-linejoin="round"/><path d="M12 22 C16 30 20 36 26 40 M52 22 C48 30 44 36 38 40" fill="none" stroke="${Z(e,.7)}" stroke-width="2.5" stroke-linecap="round"/><circle cx="32" cy="44" r="5" fill="${Z(e,.4)}" stroke="${t}" stroke-width="2.5"/>`},qc={hurdle:h0,pit:u0,wagon:m0,ramp:y0,rock:g0,shadow:b0,finish:x0,coin2x:k0,wing:v0};var zi=(e,t=4,r=.55)=>`<path d="${e}" fill="none" stroke="#fff" stroke-width="${t}" stroke-linecap="round" opacity="${r}"/>`,$0={w:100,h:100,main:"coin",draw:({main:e,ink:t})=>ae(qe("g",[[0,Z(e,.6),.75],[.6,e,.25],[1,e,0]]),pe("s",[[0,Z(e,.55)],[1,W(e,.25)]]))+`<circle cx="50" cy="52" r="48" fill="url(#g)"/><polygon points="${et(50,54,40,18)}" fill="url(#s)" stroke="${t}" stroke-width="4.5" stroke-linejoin="round"/><polygon points="${et(50,54,22,10)}" fill="${Z(e,.45)}" opacity="0.7"/>`+zi("M38 32 L46 22",4,.75)},M0={w:64,h:64,main:"coin",draw:({main:e,ink:t})=>ae(pe("k",[[0,Z(e,.45)],[1,W(e,.25)]]))+`<circle cx="20" cy="22" r="14" fill="url(#k)" stroke="${t}" stroke-width="3.5"/><circle cx="20" cy="22" r="5.5" fill="${W(e,.5)}"/><path d="M29 31 L54 56 M44 46 L50 40 M50 52 L56 46" stroke="${t}" stroke-width="9" stroke-linecap="round"/><path d="M29 31 L54 56 M44 46 L50 40 M50 52 L56 46" stroke="url(#k)" stroke-width="4.5" stroke-linecap="round"/>`+zi("M12 18 C13 13 16 11 20 10",3,.7)},w0={w:80,h:60,main:"accent",draw:({main:e,ink:t})=>ae(pe("p",[[0,Z(e,.4)],[1,W(e,.2)]]))+`<rect x="14" y="50" width="52" height="8" rx="3" fill="#5a6070" stroke="${t}" stroke-width="3"/><path d="M24 50 L56 44 L24 38 L56 32 L24 26 L56 20" fill="none" stroke="${t}" stroke-width="7" stroke-linejoin="round"/><path d="M24 50 L56 44 L24 38 L56 32 L24 26 L56 20" fill="none" stroke="#c9d1dc" stroke-width="3.5" stroke-linejoin="round"/><rect x="6" y="6" width="68" height="14" rx="6" fill="url(#p)" stroke="${t}" stroke-width="3.5"/>`+zi("M14 10 L60 10",2.5,.6)},Uc={bigstar:$0,key:M0,spring:w0};var Ns=(e,t=4,r=.5)=>`<path d="${e}" fill="none" stroke="#fff" stroke-width="${t}" stroke-linecap="round" opacity="${r}"/>`,Kr=e=>e==="sci-fi"?{stone:"#5d6f96",wood:"#2f3a5c",metal:"#8fa3c8"}:e==="cozy"?{stone:"#f1e2cf",wood:"#c98b5a",metal:"#9aa3b0"}:e==="post-apocalypse"?{stone:"#8a7a62",wood:"#5e4a36",metal:"#7d7466"}:{stone:"#aeb0b8",wood:"#8a5a34",metal:"#6a7080"},Bi=e=>78-e*12,zs='<ellipse cx="50" cy="123" rx="38" ry="7" fill="#000" opacity="0.28"/>';function Xc(e,t,r,o,n){let s="";for(let a=r+10;a<116;a+=11){s+=`<line x1="${e+2}" y1="${a}" x2="${e+t-2}" y2="${a}" stroke="${W(o,.25)}" stroke-width="2"/>`;for(let i=1;i<3;i++){let p=e+t*i/3+((a-r)/11%2?6:0);s+=`<line x1="${p}" y1="${a}" x2="${p}" y2="${a+11}" stroke="${W(o,.25)}" stroke-width="2"/>`;}}return ae(pe("s",[[0,Z(o,.25)],[1,W(o,.22)]],true))+`<rect x="${e}" y="${r}" width="${t}" height="${118-r}" fill="url(#s)" stroke="${n}" stroke-width="3.5"/>`+s+`<path d="M43 118 L43 105 A7 7 0 0 1 57 105 L57 118Z" fill="#3a2a1e" stroke="${n}" stroke-width="2.5"/>`}function E0(e,t,r){let{style:o,ink:n,c:s}=e,a=Kr(o),i=Bi(t)-(r?8:0),p=s(r==="sniper"?"danger":r==="ranger"?"coin":"accent"),m=Xc(28,44,i+18,a.stone,n),$=`<rect x="20" y="${i+8}" width="60" height="12" rx="2" fill="${a.wood}" stroke="${n}" stroke-width="3"/>`+[26,38,50,62,74].map(F=>`<rect x="${F-2}" y="${i-6}" width="4" height="15" fill="${Z(a.wood,.15)}" stroke="${n}" stroke-width="1.5"/>`).join("")+`<rect x="20" y="${i-8}" width="60" height="5" rx="2" fill="${Z(a.wood,.2)}" stroke="${n}" stroke-width="2.5"/>`,k=t>=2?`<polygon points="14,${i-8} 50,${i-36} 86,${i-8}" fill="${p}" stroke="${n}" stroke-width="3.5" stroke-linejoin="round"/><polygon points="14,${i-8} 50,${i-36} 38,${i-8}" fill="${Z(p,.25)}"/>`:"",O=t>=3?`<line x1="50" y1="${i-36}" x2="50" y2="${i-54}" stroke="${n}" stroke-width="3"/><path d="M50 ${i-54} L70 ${i-48} L50 ${i-42}Z" fill="${s("coin")}" stroke="${n}" stroke-width="2"/>`:"",C=(F,ne,X=1)=>`<path d="M${F} ${ne-12*X} Q${F+9*X} ${ne} ${F} ${ne+12*X}" fill="none" stroke="${a.wood}" stroke-width="${3.5*X}" stroke-linecap="round"/><line x1="${F}" y1="${ne-12*X}" x2="${F}" y2="${ne+12*X}" stroke="#eee" stroke-width="1.5"/>`,z=C(66,i-2);return r==="ranger"&&(z=C(30,i-2)+C(68,i-2)),r==="sniper"&&(z=`<rect x="44" y="${i-6}" width="44" height="6" rx="2" fill="${a.metal}" stroke="${n}" stroke-width="2.5"/><rect x="56" y="${i-13}" width="14" height="6" rx="2" fill="${W(a.metal,.3)}" stroke="${n}" stroke-width="2"/>`),zs+m+$+z+k+O+Ns(`M24 ${i+11} L44 ${i+11}`,2.5,.45)}function S0(e,t,r){let{style:o,ink:n,c:s}=e,a=Kr(o),i=Bi(t)+14-(r?6:0),p=ae(pe("b",[[0,Z(a.stone,.3)],[1,W(a.stone,.25)]],true),pe("m",[[0,Z(a.metal,.35)],[1,W(a.metal,.35)]]))+`<path d="M20 118 L24 ${i} L76 ${i} L80 118Z" fill="url(#b)" stroke="${n}" stroke-width="3.5" stroke-linejoin="round"/>`+[0,1,2].map(ne=>`<rect x="${22+ne*20}" y="${i-9}" width="14" height="11" fill="${a.stone}" stroke="${n}" stroke-width="2.5"/>`).join("")+(t>=2?`<rect x="22" y="${i+14}" width="56" height="7" fill="${W(a.stone,.2)}" stroke="${n}" stroke-width="2"/>`:"")+(t>=3?`<rect x="22" y="${i+30}" width="56" height="7" fill="${s("coin")}" stroke="${n}" stroke-width="2"/>`:""),m=r==="bombard"?1.45:1+t*.08,$=34*m,k=13*m,O=`<g transform="rotate(-28 50 ${i-4})"><rect x="46" y="${i-4-k/2}" width="${$}" height="${k}" rx="${k/3}" fill="url(#m)" stroke="${n}" stroke-width="3"/><rect x="${46+$-7}" y="${i-4-k/2-2}" width="8" height="${k+4}" rx="2" fill="${W(a.metal,.3)}" stroke="${n}" stroke-width="2.5"/></g><circle cx="50" cy="${i-4}" r="${9*m}" fill="${W(a.metal,.2)}" stroke="${n}" stroke-width="3"/>`,C=44+$,z=r==="flamer"?`<g transform="rotate(-28 50 ${i-4})"><path d="M${C} ${i-16} C${C+14} ${i-22} ${C+30} ${i-10} ${C+22} ${i-4} C${C+30} ${i+2} ${C+14} ${i+14} ${C} ${i+8}Z" fill="#ff7a1a" stroke="${n}" stroke-width="2.5" stroke-linejoin="round"/><path d="M${C+2} ${i-9} C${C+12} ${i-12} ${C+18} ${i-6} ${C+13} ${i-3} C${C+18} ${i} ${C+10} ${i+6} ${C+2} ${i+2}Z" fill="#ffd34a"/></g>`:"",F=r==="bombard"?`<polygon points="${et(50,i+24,8,3.5)}" fill="${s("danger")}" stroke="${n}" stroke-width="2"/>`:"";return zs+p+O+z+F+Ns(`M28 ${i+4} L28 ${i+40}`,3,.4)}function L0(e,t,r){let{style:o,ink:n,c:s}=e,a=Kr(o),i=64-t*6-(r?4:0),p=r==="storm"?s("coin"):r==="arcane"?Z(s("secondary"),.2):s("secondary"),m=Xc(32,36,i,a.stone,n)+`<rect x="44" y="${i+16}" width="12" height="16" rx="6" fill="${p}" stroke="${n}" stroke-width="2.5" opacity="0.9"/>`,$=i-28,k=`<polygon points="26,${i+2} 50,${$} 74,${i+2}" fill="${s("secondary")}" stroke="${n}" stroke-width="3.5" stroke-linejoin="round"/><polygon points="26,${i+2} 50,${$} 42,${i+2}" fill="${Z(s("secondary"),.25)}"/>`,O=7+t*1.3+(r==="arcane"?3:0),C=Math.max(O+6+(r==="arcane"?8:0),$-O*.5),z=ae(qe("o",[[0,"#ffffff",1],[.45,p,.95],[1,p,.3]]))+`<circle cx="50" cy="${C}" r="${O+7}" fill="${p}" opacity="0.25"/><circle cx="50" cy="${C}" r="${O}" fill="url(#o)" stroke="${n}" stroke-width="2.5"/>`,F=r==="storm"?[-1,1].map(ne=>`<path d="M${50+ne*(O+3)} ${C-6} L${50+ne*(O+10)} ${C} L${50+ne*(O+5)} ${C+2} L${50+ne*(O+13)} ${C+10}" fill="none" stroke="${s("coin")}" stroke-width="3" stroke-linejoin="round"/>`).join(""):r==="arcane"?`<circle cx="50" cy="${C}" r="${O+11}" fill="none" stroke="${p}" stroke-width="2.5" stroke-dasharray="5 4"/>`:"";return zs+m+k+z+F}function _0(e,t,r){let{style:o,ink:n,c:s}=e,a=Kr(o),i=Bi(t)+10-(r?6:0),p=r==="glacier"?W(s("primary"),.15):Z(s("primary"),.35),m=ae(pe("p",[[0,Z(a.stone,.25)],[1,W(a.stone,.25)]],true),pe("i",[[0,"#ffffff"],[.5,p],[1,W(p,.25)]]))+`<path d="M24 118 L28 ${i+18} L72 ${i+18} L76 118Z" fill="url(#p)" stroke="${n}" stroke-width="3.5" stroke-linejoin="round"/>`,$=(C,z,F,ne)=>`<g transform="rotate(${ne} ${C} ${i+20})"><polygon points="${C-F},${i+20} ${C-F*.8},${i+20-z*.75} ${C},${i+20-z} ${C+F*.8},${i+20-z*.75} ${C+F},${i+20}" fill="url(#i)" stroke="${n}" stroke-width="2.5" stroke-linejoin="round"/><line x1="${C}" y1="${i+20-z}" x2="${C}" y2="${i+18}" stroke="#fff" stroke-width="1.5" opacity="0.6"/></g>`,k=$(50,38+t*6,10,0);t>=2&&(k=$(36,26+t*3,7,-14)+$(64,26+t*3,7,14)+k),t>=3&&(k=$(28,20,5,-26)+$(72,20,5,26)+k),r==="glacier"&&(k+=$(50,70,15,0));let O=r==="blizzard"?[0,1,2,3,4].map(C=>`<polygon points="${et(22+C*14,i-30+C%2*12,5,2,6)}" fill="#fff" stroke="${n}" stroke-width="1.2"/>`).join(""):"";return zs+m+k+O}var R0={archer:E0,cannon:S0,mage:L0,frost:_0},Ot=(e,t,r="")=>({w:100,h:130,draw:o=>R0[e](o,t,r)}),A0={w:100,h:64,draw({style:e,ink:t,c:r}){let o=Kr(e),n=Array.from({length:10},(s,a)=>{let i=a/10*Math.PI*2;return `<ellipse cx="${(50+Math.cos(i)*38).toFixed(1)}" cy="${(34+Math.sin(i)*20).toFixed(1)}" rx="9" ry="6" fill="${a%2?o.stone:Z(o.stone,.15)}" stroke="${t}" stroke-width="2.5"/>`}).join("");return `<ellipse cx="50" cy="34" rx="40" ry="22" fill="${W(o.stone,.45)}" opacity="0.55"/>`+n+`<line x1="78" y1="30" x2="78" y2="6" stroke="${t}" stroke-width="2.5"/><path d="M78 6 L92 10 L78 15Z" fill="${r("coin")}" stroke="${t}" stroke-width="1.5"/>`}},T0={w:100,h:100,draw({style:e,ink:t,c:r}){let o=Kr(e),n=a=>`<rect x="${a}" y="22" width="22" height="72" fill="${o.stone}" stroke="${t}" stroke-width="3"/>`+[0,1].map(i=>`<rect x="${a+i*13}" y="13" width="9" height="11" fill="${o.stone}" stroke="${t}" stroke-width="2.5"/>`).join("")+`<polygon points="${a-3},22 ${a+11},2 ${a+25},22" fill="${r("danger")}" stroke="${t}" stroke-width="3" stroke-linejoin="round"/>`,s="";for(let a=38;a<=62;a+=6)s+=`<line x1="${a}" y1="52" x2="${a}" y2="94" stroke="${W(o.metal,.3)}" stroke-width="3"/>`;return `<ellipse cx="50" cy="95" rx="46" ry="5" fill="#000" opacity="0.28"/><rect x="22" y="36" width="56" height="58" fill="${Z(o.stone,.1)}" stroke="${t}" stroke-width="3.5"/><path d="M34 94 L34 60 A16 16 0 0 1 66 60 L66 94Z" fill="#241a14" stroke="${t}" stroke-width="3"/>`+s+n(8)+n(70)+`<rect x="44" y="40" width="12" height="9" fill="${r("coin")}" stroke="${t}" stroke-width="2"/>`}},D0={w:100,h:90,draw({style:e,ink:t}){let r=Kr(e);return `<path d="M6 86 C6 40 26 10 50 10 C74 10 94 40 94 86Z" fill="${W(r.stone,.15)}" stroke="${t}" stroke-width="4" stroke-linejoin="round"/><path d="M24 86 C24 52 36 30 50 30 C64 30 76 52 76 86Z" fill="#120c10" stroke="${t}" stroke-width="3"/><circle cx="42" cy="58" r="3" fill="#ff5a3a"/><circle cx="56" cy="58" r="3" fill="#ff5a3a"/>`}},O0={w:100,h:130,draw({style:e,ink:t,c:r}){let o=Kr(e),n=e==="post-apocalypse"?"#6b6a3a":e==="sci-fi"?r("secondary"):e==="cozy"?"#6fcf6a":"#3f8f3a";return e==="post-apocalypse"?`<ellipse cx="50" cy="124" rx="26" ry="5" fill="#000" opacity="0.28"/><path d="M46 124 L48 60 L30 40 M48 70 L68 46 M48 84 L32 74" fill="none" stroke="${o.wood}" stroke-width="8" stroke-linecap="round"/><path d="M46 124 L48 60" stroke="${t}" stroke-width="2" opacity="0.4"/>`:ae(qe("l",[[0,Z(n,.35),1],[1,W(n,.2),1]],.4,.35,.65))+`<ellipse cx="50" cy="124" rx="30" ry="6" fill="#000" opacity="0.28"/><rect x="42" y="78" width="16" height="46" rx="4" fill="${o.wood}" stroke="${t}" stroke-width="3"/>`+(e==="sci-fi"?`<polygon points="${Tt(50,50,36,6)}" fill="url(#l)" stroke="${t}" stroke-width="3.5"/>`:`<circle cx="34" cy="62" r="24" fill="url(#l)" stroke="${t}" stroke-width="3.5"/><circle cx="66" cy="62" r="24" fill="url(#l)" stroke="${t}" stroke-width="3.5"/><circle cx="50" cy="38" r="28" fill="url(#l)" stroke="${t}" stroke-width="3.5"/>`)+Ns("M36 26 C42 20 50 18 56 20",4,.4)}},C0={w:100,h:70,draw({style:e,ink:t,c:r}){let o=e==="post-apocalypse"?"#7a6a3a":e==="sci-fi"?r("secondary"):e==="cozy"?"#7fd87a":"#4a9a3e";return `<ellipse cx="50" cy="64" rx="40" ry="5" fill="#000" opacity="0.25"/><circle cx="30" cy="44" r="20" fill="${o}" stroke="${t}" stroke-width="3"/><circle cx="70" cy="44" r="20" fill="${o}" stroke="${t}" stroke-width="3"/><circle cx="50" cy="32" r="24" fill="${Z(o,.12)}" stroke="${t}" stroke-width="3"/>`+[30,54,70].map((n,s)=>`<circle cx="${n}" cy="${36+s%2*10}" r="4" fill="${r(s===1?"coin":"danger")}"/>`).join("")}},P0={w:100,h:30,draw:({ink:e})=>`<line x1="10" y1="15" x2="80" y2="15" stroke="#8a5a34" stroke-width="5" stroke-linecap="round"/><polygon points="78,6 98,15 78,24" fill="#d8dde6" stroke="${e}" stroke-width="2.5" stroke-linejoin="round"/><path d="M4 7 L20 15 L4 23 M12 7 L26 15 L12 23" fill="none" stroke="#e8e0d0" stroke-width="3"/>`},I0={w:100,h:100,main:"danger",draw:({main:e,ink:t})=>ae(qe("f",[[0,"#fff6c0",1],[.4,"#ffb23a",1],[1,e,.9]]))+`<path d="M62 10 C82 18 96 30 98 40 L70 62 Z" fill="#ff8a2a" opacity="0.75"/><path d="M50 16 C70 26 84 40 86 52 L60 66 Z" fill="#ffd34a" opacity="0.6"/><circle cx="40" cy="62" r="26" fill="url(#f)" stroke="${t}" stroke-width="3.5"/><circle cx="32" cy="56" r="5" fill="${W(e,.35)}"/><circle cx="48" cy="70" r="4" fill="${W(e,.35)}"/>`},N0={w:100,h:80,main:"coin",draw:({main:e,ink:t})=>{let r=(o,n)=>`<polygon points="${o},${n+18} ${o+6},${n} ${o+34},${n} ${o+40},${n+18}" fill="url(#g)" stroke="${t}" stroke-width="3" stroke-linejoin="round"/>`+Ns(`M${o+10} ${n+5} L${o+24} ${n+5}`,2.5,.7);return ae(pe("g",[[0,Z(e,.5)],[1,W(e,.25)]]))+'<ellipse cx="50" cy="74" rx="44" ry="5" fill="#000" opacity="0.25"/>'+r(8,52)+r(52,52)+r(30,32)+r(30,12)}},z0={w:100,h:100,draw:({ink:e})=>`<path d="M14 86 L86 14 M14 14 L86 86" stroke="#d8dde6" stroke-width="9" stroke-linecap="round"/><path d="M14 86 L86 14 M14 14 L86 86" stroke="${e}" stroke-width="2.5" stroke-linecap="round" opacity="0.6"/><path d="M26 46 C26 24 38 14 50 14 C62 14 74 24 74 46 C74 58 68 62 64 64 L64 76 L36 76 L36 64 C32 62 26 58 26 46Z" fill="#f4efe4" stroke="${e}" stroke-width="4" stroke-linejoin="round"/><circle cx="40" cy="46" r="8" fill="#2a1e1e"/><circle cx="60" cy="46" r="8" fill="#2a1e1e"/><path d="M50 54 L46 62 L54 62Z" fill="#2a1e1e"/><path d="M42 76 L42 68 M50 76 L50 68 M58 76 L58 68" stroke="${e}" stroke-width="2.5"/>`},B0={w:100,h:100,draw({style:e,ink:t,c:r}){let o=Kr(e),n=r("danger");return `<rect x="30" y="30" width="34" height="56" fill="${o.stone}" stroke="${t}" stroke-width="3.5"/>`+[30,41,52].map(s=>`<rect x="${s+1}" y="20" width="8" height="11" fill="${o.stone}" stroke="${t}" stroke-width="2.5"/>`).join("")+`<path d="M41 86 L41 74 A6 6 0 0 1 53 74 L53 86Z" fill="#3a2a1e" stroke="${t}" stroke-width="2.5"/><circle cx="47" cy="52" r="38" fill="none" stroke="${t}" stroke-width="13"/><circle cx="47" cy="52" r="38" fill="none" stroke="${n}" stroke-width="8"/><line x1="20" y1="79" x2="74" y2="25" stroke="${t}" stroke-width="13" stroke-linecap="round"/><line x1="20" y1="79" x2="74" y2="25" stroke="${n}" stroke-width="8" stroke-linecap="round"/>`+ae(pe("g",[[0,Z(r("coin"),.45)],[1,W(r("coin"),.2)]]))+`<circle cx="78" cy="80" r="17" fill="url(#g)" stroke="${t}" stroke-width="3.5"/><path d="M78 71 L78 89 M69 80 L87 80" stroke="${W(r("coin"),.45)}" stroke-width="4" stroke-linecap="round"/>`}},Zc={td_sell:B0,td_archer1:Ot("archer",1),td_archer2:Ot("archer",2),td_archer3:Ot("archer",3),td_archer_ranger:Ot("archer",3,"ranger"),td_archer_sniper:Ot("archer",3,"sniper"),td_cannon1:Ot("cannon",1),td_cannon2:Ot("cannon",2),td_cannon3:Ot("cannon",3),td_cannon_bombard:Ot("cannon",3,"bombard"),td_cannon_flamer:Ot("cannon",3,"flamer"),td_mage1:Ot("mage",1),td_mage2:Ot("mage",2),td_mage3:Ot("mage",3),td_mage_arcane:Ot("mage",3,"arcane"),td_mage_storm:Ot("mage",3,"storm"),td_frost1:Ot("frost",1),td_frost2:Ot("frost",2),td_frost3:Ot("frost",3),td_frost_glacier:Ot("frost",3,"glacier"),td_frost_blizzard:Ot("frost",3,"blizzard"),td_spot:A0,td_gate:T0,td_portal:D0,td_tree:O0,td_bush:C0,td_arrow:P0,td_meteor:I0,td_gold:N0,td_call:z0};var Fo=(e,t=4,r=.5)=>`<path d="${e}" fill="none" stroke="#fff" stroke-width="${t}" stroke-linecap="round" opacity="${r}"/>`,H0={w:100,h:100,draw:({ink:e})=>{let r=["#ff5a5a","#ffb03a","#ffe14a","#5ad35a","#4aa8ff","#a26bff"].map((o,n)=>{let s=n/6*Math.PI*2,a=(n+1)/6*Math.PI*2,i=p=>`${(50+Math.cos(p)*38).toFixed(1)} ${(50+Math.sin(p)*38).toFixed(1)}`;return `<path d="M50 50 L${i(s)} A38 38 0 0 1 ${i(a)}Z" fill="${o}"/>`});return ae(qe("g",[[0,"#ffffff",.95],[.5,"#ffffff",.2],[1,"#ffffff",0]],.38,.35,.5))+'<circle cx="50" cy="50" r="46" fill="#ffffff" opacity="0.25"/>'+r.join("")+`<circle cx="50" cy="50" r="38" fill="url(#g)" stroke="${e}" stroke-width="4"/><polygon points="${et(50,50,13,6)}" fill="#fff" opacity="0.9"/>`}},Qc=e=>({w:100,h:100,draw:({ink:t})=>{let r=`<path d="M8 50 L24 38 L24 45 L76 45 L76 38 L92 50 L76 62 L76 55 L24 55 L24 62Z" fill="#fff" stroke="${t}" stroke-width="3" stroke-linejoin="round"/>`;return `<g ${e?'transform="rotate(90 50 50)"':""} opacity="0.95">${r}</g>`}}),W0={w:100,h:100,draw:({ink:e})=>`<circle cx="50" cy="50" r="40" fill="none" stroke="#fff" stroke-width="7" opacity="0.9"/><circle cx="50" cy="50" r="40" fill="none" stroke="${e}" stroke-width="2" opacity="0.6"/><polygon points="${et(78,20,13,5,8)}" fill="#ffd34a" stroke="${e}" stroke-width="2"/>`},Yc=e=>({w:100,h:100,draw:({ink:t})=>ae(pe("i",[[0,"#e6f6ff",.75],[1,"#7cc4ff",e>1?.85:.6]]))+`<rect x="3" y="3" width="94" height="94" rx="12" fill="url(#i)" stroke="${t}" stroke-width="3" opacity="0.95"/>`+(e>1?'<rect x="12" y="12" width="76" height="76" rx="8" fill="none" stroke="#fff" stroke-width="4" opacity="0.8"/>':"")+Fo("M14 30 L30 14",5,.8)+Fo("M70 88 L86 72",4,.5)}),j0={w:100,h:100,draw:({ink:e})=>`<path d="M4 20 C4 8 14 4 24 6 C36 0 56 10 64 4 C78 0 96 8 96 22 L96 80 C96 94 84 98 72 94 C60 100 44 90 30 96 C16 100 4 92 4 80Z" fill="#8edc4a" opacity="0.6" stroke="${e}" stroke-width="3"/><circle cx="28" cy="70" r="6" fill="#c6f58a" opacity="0.9"/><circle cx="72" cy="30" r="5" fill="#c6f58a" opacity="0.9"/>`},V0={w:100,h:100,draw:({ink:e})=>{let t=(r,o,n)=>`<rect x="${r-14}" y="${o-8}" width="28" height="16" rx="8" fill="none" stroke="#9aa3b0" stroke-width="7" transform="rotate(${n} ${r} ${o})"/><rect x="${r-14}" y="${o-8}" width="28" height="16" rx="8" fill="none" stroke="${e}" stroke-width="1.5" transform="rotate(${n} ${r} ${o})"/>`;return [t(18,18,45),t(36,36,45),t(64,64,45),t(82,82,45),t(82,18,-45),t(64,36,-45),t(36,64,-45),t(18,82,-45)].join("")+`<circle cx="50" cy="50" r="12" fill="#c9a14a" stroke="${e}" stroke-width="3"/><rect x="46" y="48" width="8" height="10" fill="${e}"/>`}},Jc=e=>({w:100,h:100,draw:({style:t,ink:r})=>{let o=t==="sci-fi"?"#7c86a8":t==="cozy"?"#b8a99a":"#8f8a82";return ae(pe("s",[[0,Z(o,.35)],[1,W(o,.35)]]))+`<path d="M10 30 L28 8 L72 6 L92 26 L94 72 L74 94 L26 94 L6 72Z" fill="url(#s)" stroke="${r}" stroke-width="4" stroke-linejoin="round"/>`+(e?"":`<path d="M30 30 L44 50 L36 70 M60 24 L66 44 L80 54" fill="none" stroke="${W(o,.5)}" stroke-width="3.5" stroke-linecap="round"/>`)+(e?`<path d="M30 40 L70 40 M30 60 L70 60" stroke="${W(o,.4)}" stroke-width="4"/>`:"")+Fo("M20 30 L34 14",4,.45)}}),G0={w:100,h:100,draw:({ink:e,c:t})=>{let r="";for(let o=18;o<=82;o+=16)r+=`<line x1="${o}" y1="18" x2="${o}" y2="88" stroke="#b07a3a" stroke-width="5"/>`;return `<circle cx="50" cy="58" r="22" fill="${t("coin")}" stroke="${e}" stroke-width="3"/><circle cx="42" cy="54" r="4" fill="${e}"/><circle cx="58" cy="54" r="4" fill="${e}"/><path d="M44 66 Q50 71 56 66" fill="none" stroke="${e}" stroke-width="3" stroke-linecap="round"/><path d="M34 40 L30 28 L42 36Z M66 40 L70 28 L58 36Z" fill="${t("coin")}" stroke="${e}" stroke-width="2.5"/>`+r+`<rect x="10" y="10" width="80" height="10" rx="4" fill="#8a5a2a" stroke="${e}" stroke-width="3"/><rect x="10" y="86" width="80" height="10" rx="4" fill="#8a5a2a" stroke="${e}" stroke-width="3"/>`}},K0={w:100,h:100,draw:({ink:e})=>ae(pe("w",[[0,"#d9a066"],[1,"#9a6236"]]))+`<rect x="8" y="8" width="84" height="84" rx="6" fill="url(#w)" stroke="${e}" stroke-width="4"/><rect x="16" y="16" width="68" height="68" fill="none" stroke="#7a4a26" stroke-width="4"/><path d="M18 18 L82 82 M82 18 L18 82" stroke="#7a4a26" stroke-width="6"/><path d="M50 30 L50 64 M38 54 L50 66 L62 54" fill="none" stroke="#fff4d0" stroke-width="7" stroke-linecap="round" stroke-linejoin="round"/>`},F0={w:100,h:100,main:"danger",draw:({main:e,ink:t})=>ae(pe("h",[[0,Z(e,.45)],[1,W(e,.2)]]))+`<path d="M50 88 C20 66 8 50 8 32 C8 18 20 8 32 8 C40 8 46 12 50 20 C54 12 60 8 68 8 C80 8 92 18 92 32 C92 50 80 66 50 88Z" fill="url(#h)" stroke="${t}" stroke-width="4.5" stroke-linejoin="round"/>`+Fo("M22 30 C22 22 28 18 34 18",5,.7)},q0={w:100,h:100,main:"primary",draw:({main:e,ink:t})=>ae(pe("s",[[0,Z(e,.45)],[1,W(e,.25)]]))+`<path d="M50 6 L88 18 L86 52 C84 74 68 88 50 96 C32 88 16 74 14 52 L12 18Z" fill="url(#s)" stroke="${t}" stroke-width="4.5" stroke-linejoin="round"/><path d="M50 20 L74 28 L72 52 C70 66 60 76 50 82Z" fill="${Z(e,.3)}" opacity="0.7"/>`+Fo("M24 26 L36 22",4,.7)},U0={w:100,h:100,draw:({ink:e})=>ae(qe("f",[[0,"#fff6c0",1],[.45,"#ffb23a",1],[1,"#e0442e",1]]))+`<polygon points="${et(50,50,46,22,10)}" fill="url(#f)" stroke="${e}" stroke-width="4" stroke-linejoin="round"/><circle cx="50" cy="50" r="12" fill="#fff6c0"/>`},X0={w:100,h:100,draw:({ink:e,c:t})=>`<path d="M40 6 L60 6 L60 40 L94 40 L94 60 L60 60 L60 94 L40 94 L40 60 L6 60 L6 40 L40 40Z" fill="${t("coin")}" stroke="${e}" stroke-width="4" stroke-linejoin="round"/><circle cx="50" cy="50" r="13" fill="#fffbe0" stroke="${e}" stroke-width="3"/>`},Z0={w:100,h:100,draw:({ink:e,c:t})=>`<path d="M20 44 C10 44 6 34 12 26 C16 18 26 18 30 22 C34 10 52 8 60 18 C70 12 86 18 86 30 C96 32 96 46 84 48Z" fill="#d8e2f0" stroke="${e}" stroke-width="4" stroke-linejoin="round"/><path d="M48 48 L36 72 L50 72 L42 96 L68 62 L54 62 L62 48Z" fill="${t("coin")}" stroke="${e}" stroke-width="3.5" stroke-linejoin="round"/>`},ed={m3_rainbow:H0,m3_row:Qc(false),m3_col:Qc(true),m3_bomb:W0,m3_ice:Yc(1),m3_ice2:Yc(2),m3_slime:j0,m3_chain:V0,m3_stone:Jc(false),m3_stone2:Jc(true),m3_cage:G0,m3_crate:K0,m3_heart:F0,m3_shield:q0,m3_skill_blast:U0,m3_skill_cross:X0,m3_skill_storm:Z0};var St=(e,t,r,o,n=.28)=>`<ellipse cx="${e}" cy="${t}" rx="${r}" ry="${o}" fill="#000" opacity="${n}"/>`,br=(e,t=4,r=.55)=>`<path d="${e}" fill="none" stroke="#fff" stroke-width="${t}" stroke-linecap="round" opacity="${r}"/>`,Jt=e=>({w:100,h:100,draw:({ink:t})=>e(t)}),qo="#e8b84a",Ln="#c9803a",Q0=e=>Jt(t=>{switch(e){case 1:{let r=[0,1,2,3].map(o=>`<ellipse cx="${44-o%2*0}" cy="${30+o*11}" rx="7" ry="5" fill="${qo}" stroke="${t}" stroke-width="2.5" transform="rotate(-30 44 ${30+o*11})"/><ellipse cx="57" cy="${30+o*11}" rx="7" ry="5" fill="${Z(qo,.1)}" stroke="${t}" stroke-width="2.5" transform="rotate(30 57 ${30+o*11})"/>`);return St(50,90,14,3)+`<path d="M50 90 L50 22" stroke="${W(qo,.3)}" stroke-width="4" stroke-linecap="round"/>`+r.join("")+`<ellipse cx="50" cy="20" rx="5" ry="8" fill="${qo}" stroke="${t}" stroke-width="2.5"/>`}case 2:return ae(pe("s",[[0,"#f6ecd6"],[1,"#d6c29a"]]))+St(50,90,28,5)+`<path d="M24 40 Q22 86 30 88 L70 88 Q78 86 76 40 Q50 30 24 40Z" fill="url(#s)" stroke="${t}" stroke-width="3.5"/><path d="M28 40 Q38 22 50 30 Q62 22 72 40" fill="#f6ecd6" stroke="${t}" stroke-width="3"/><path d="M36 38 L64 38" stroke="${Ln}" stroke-width="5"/><path d="M50 52 L56 62 L50 72 L44 62Z" fill="${qo}" stroke="${t}" stroke-width="2"/><circle cx="50" cy="20" r="6" fill="#fff" opacity="0.9"/><circle cx="58" cy="16" r="4" fill="#fff" opacity="0.8"/>`;case 3:return ae(qe("d",[[0,"#fff6e6"],[1,"#e8cfa2"]],.4,.35))+St(50,86,30,5)+`<path d="M18 70 Q14 44 36 38 Q50 30 64 38 Q86 44 82 70 Q78 84 50 84 Q22 84 18 70Z" fill="url(#d)" stroke="${t}" stroke-width="3.5"/>`+br("M30 52 Q36 44 46 42",4,.7);case 4:return ae(pe("b",[[0,"#f0b25a"],[1,Ln]]))+St(50,86,32,5)+`<path d="M16 72 Q14 40 50 34 Q86 40 84 72 Q80 84 50 84 Q20 84 16 72Z" fill="url(#b)" stroke="${t}" stroke-width="3.5"/>`+[[36,50],[50,46],[64,50],[44,60],[58,60]].map(([r,o])=>`<ellipse cx="${r}" cy="${o}" rx="3" ry="1.8" fill="#fff6d6" stroke="${t}" stroke-width="1"/>`).join("")+br("M26 56 Q30 46 40 42",4,.5);case 5:return ae(pe("l",[[0,"#f2bb66"],[1,W(Ln,.1)]]))+St(50,84,40,5)+`<path d="M8 66 Q8 36 50 32 Q92 36 92 66 Q92 80 50 80 Q8 80 8 66Z" fill="url(#l)" stroke="${t}" stroke-width="3.5"/>`+[26,42,58,74].map(r=>`<path d="M${r-6} 52 Q${r} 42 ${r+6} 40" stroke="${W(Ln,.35)}" stroke-width="4" fill="none" stroke-linecap="round"/>`).join("")+br("M16 60 Q18 46 30 40",4,.45);case 6:return ae(pe("p",[[0,"#f4c070"],[1,Ln]]))+St(50,86,42,5)+`<path d="M8 60 L14 80 L86 80 L92 60Z" fill="#b8b8c8" stroke="${t}" stroke-width="3.5"/><ellipse cx="50" cy="58" rx="42" ry="16" fill="url(#p)" stroke="${t}" stroke-width="3.5"/><ellipse cx="50" cy="56" rx="32" ry="10" fill="#c43a5a"/>`+[-20,-7,6,19].map(r=>`<line x1="${50+r}" y1="46" x2="${50+r+6}" y2="67" stroke="${Z(Ln,.2)}" stroke-width="4"/>`).join("")+[-20,0,20].map(r=>`<line x1="20" y1="${56+r*.3}" x2="80" y2="${56+r*.3}" stroke="${Z(Ln,.2)}" stroke-width="4" opacity="0.9"/>`).join("")+`<ellipse cx="50" cy="58" rx="42" ry="16" fill="none" stroke="${t}" stroke-width="3.5"/>`;default:return ae(pe("c",[[0,"#fff4f6"],[1,"#f2c6d2"]]),pe("t",[[0,"#ffd6e0"],[1,"#e89ab0"]]))+St(50,94,40,4)+`<rect x="12" y="62" width="76" height="28" rx="6" fill="url(#c)" stroke="${t}" stroke-width="3.5"/><rect x="24" y="38" width="52" height="26" rx="6" fill="url(#t)" stroke="${t}" stroke-width="3.5"/><path d="M12 70 Q20 78 28 70 Q36 78 44 70 Q52 78 60 70 Q68 78 76 70 Q84 78 88 70" fill="none" stroke="#fff" stroke-width="4"/><path d="M24 46 Q32 52 40 46 Q48 52 56 46 Q64 52 76 46" fill="none" stroke="#fff" stroke-width="4"/>`+[36,50,64].map(r=>`<rect x="${r-2.5}" y="22" width="5" height="16" rx="2" fill="#7cc4ff" stroke="${t}" stroke-width="1.5"/><path d="M${r} 12 Q${r+4} 18 ${r} 21 Q${r-4} 18 ${r} 12Z" fill="#ffc83a"/>`).join("")+`<circle cx="50" cy="40" r="5" fill="#d62a3a" stroke="${t}" stroke-width="2"/>`}}),Or="#4ac8ff",Uo="#ffc83a",Xn=(e,t,r,o,n,s)=>`<path d="M${e} ${t-r} L${e+o} ${t-r*.6} L${e+o*.8} ${t} L${e-o*.8} ${t} L${e-o} ${t-r*.6}Z" fill="${n}" stroke="${s}" stroke-width="3" stroke-linejoin="round"/><path d="M${e} ${t-r} L${e} ${t}" stroke="#fff" stroke-width="2" opacity="0.6"/>`,Y0=e=>Jt(t=>{switch(e){case 1:return ae(qe("r",[[0,"#c8ccd6"],[1,"#7a8090"]],.4,.35))+St(50,84,28,5)+`<path d="M20 70 Q16 48 34 40 Q52 30 70 42 Q86 54 78 72 Q66 84 44 82 Q24 80 20 70Z" fill="url(#r)" stroke="${t}" stroke-width="3.5"/><path d="M58 52 L66 58 L60 64Z" fill="${Or}" stroke="${t}" stroke-width="1.5"/>`+br("M30 52 Q36 44 46 42",4,.5);case 2:return St(50,88,22,4)+Xn(50,86,66,18,Or,t)+br("M44 40 L46 30",3,.7);case 3:return St(50,90,34,5)+Xn(30,88,44,13,W(Or,.15),t)+Xn(70,88,48,13,"#a88aff",t)+Xn(50,88,70,16,Or,t);case 4:return ae(pe("g",[[0,Z(Or,.4)],[1,W(Or,.3)]]))+St(50,90,30,5)+`<path d="M20 38 L34 20 L66 20 L80 38 L50 86Z" fill="url(#g)" stroke="${t}" stroke-width="3.5" stroke-linejoin="round"/><path d="M20 38 L80 38 M34 20 L42 38 L50 86 L58 38 L66 20 M42 38 L50 20 L58 38" fill="none" stroke="${t}" stroke-width="2" opacity="0.7"/><path d="M28 34 L36 24" stroke="#fff" stroke-width="4" stroke-linecap="round" opacity="0.8"/>`;case 5:return St(50,90,26,4)+`<circle cx="50" cy="62" r="24" fill="none" stroke="${t}" stroke-width="13"/><circle cx="50" cy="62" r="24" fill="none" stroke="${Uo}" stroke-width="8"/><path d="M50 62 m-16 -20" stroke="#fff" stroke-width="3" opacity="0.5"/><path d="M36 32 L42 22 L58 22 L64 32 L50 48Z" fill="#ff4a8a" stroke="${t}" stroke-width="3" stroke-linejoin="round"/>`+br("M30 70 Q30 54 40 46",3,.6);case 6:return St(50,92,24,4)+`<path d="M18 16 Q20 58 50 66 Q80 58 82 16" fill="none" stroke="${t}" stroke-width="7"/><path d="M18 16 Q20 58 50 66 Q80 58 82 16" fill="none" stroke="${Uo}" stroke-width="4" stroke-dasharray="5 3"/><path d="M50 62 L64 74 L50 92 L36 74Z" fill="${Or}" stroke="${t}" stroke-width="3" stroke-linejoin="round"/><circle cx="34" cy="52" r="4" fill="#ff4a8a" stroke="${t}" stroke-width="1.5"/><circle cx="66" cy="52" r="4" fill="#ff4a8a" stroke="${t}" stroke-width="1.5"/>`+br("M44 72 L50 66",3,.7);default:return ae(pe("k",[[0,Z(Uo,.3)],[1,W(Uo,.25)]]))+St(50,90,38,5)+`<path d="M12 80 L8 30 L30 50 L50 18 L70 50 L92 30 L88 80Z" fill="url(#k)" stroke="${t}" stroke-width="3.5" stroke-linejoin="round"/><rect x="12" y="72" width="76" height="12" rx="3" fill="${W(Uo,.15)}" stroke="${t}" stroke-width="3"/><circle cx="50" cy="60" r="7" fill="#ff4a8a" stroke="${t}" stroke-width="2.5"/><circle cx="30" cy="64" r="5" fill="${Or}" stroke="${t}" stroke-width="2"/><circle cx="70" cy="64" r="5" fill="${Or}" stroke="${t}" stroke-width="2"/>`+[[8,30],[50,18],[92,30]].map(([r,o])=>`<circle cx="${r}" cy="${o}" r="5" fill="#fff6c0" stroke="${t}" stroke-width="2"/>`).join("")}}),Fr="#a26bff",td="#dff2ff",J0=e=>Jt(t=>{switch(e){case 1:return St(50,90,18,4)+'<path d="M50 90 Q46 60 52 30" stroke="#3f8a3a" stroke-width="4" fill="none" stroke-linecap="round"/>'+[[52,34,-40],[49,50,210],[51,64,-30],[48,76,200]].map(([r,o,n])=>`<ellipse cx="${r+12*Math.cos(n*Math.PI/180)}" cy="${o+12*Math.sin(n*Math.PI/180)}" rx="13" ry="6" fill="#5ad35a" stroke="${t}" stroke-width="2.5" transform="rotate(${n} ${r+12*Math.cos(n*Math.PI/180)} ${o+12*Math.sin(n*Math.PI/180)})"/>`).join("");case 2:return ae(qe("d",[[0,Z(Fr,.5)],[1,W(Fr,.2)]],.4,.55))+St(50,90,18,4)+`<path d="M50 12 Q74 46 74 62 A24 24 0 0 1 26 62 Q26 46 50 12Z" fill="url(#d)" stroke="${t}" stroke-width="3.5"/>`+br("M38 58 Q38 48 44 40",4,.7);case 3:return St(50,92,14,3)+`<rect x="38" y="12" width="24" height="8" rx="2" fill="#a8774a" stroke="${t}" stroke-width="2.5"/><path d="M40 20 L40 78 A10 10 0 0 0 60 78 L60 20Z" fill="${td}" stroke="${t}" stroke-width="3" opacity="0.95"/><path d="M41 52 L41 78 A9 9 0 0 0 59 78 L59 52Z" fill="#4ad3a0"/>`+br("M45 26 L45 72",3,.7);case 4:return St(50,92,26,4)+`<rect x="42" y="10" width="16" height="10" rx="2" fill="#a8774a" stroke="${t}" stroke-width="2.5"/><path d="M44 20 L44 40 A26 26 0 1 0 56 40 L56 20Z" fill="${td}" stroke="${t}" stroke-width="3"/><path d="M27 62 A23 23 0 0 0 73 62Z" fill="#ff6a5a"/><circle cx="44" cy="70" r="3" fill="#fff" opacity="0.7"/><circle cx="56" cy="74" r="2" fill="#fff" opacity="0.7"/>`+br("M34 52 Q32 62 36 70",3.5,.7);case 5:return ae(pe("b",[[0,Z(Fr,.3)],[1,W(Fr,.3)]]))+St(50,94,26,4)+`<rect x="40" y="6" width="20" height="12" rx="3" fill="#a8774a" stroke="${t}" stroke-width="2.5"/><path d="M42 18 L42 30 Q22 38 22 60 L22 82 Q22 90 30 90 L70 90 Q78 90 78 82 L78 60 Q78 38 58 30 L58 18Z" fill="url(#b)" stroke="${t}" stroke-width="3.5"/><rect x="30" y="56" width="40" height="22" rx="4" fill="#fff6e6" stroke="${t}" stroke-width="2"/><path d="M50 74 L40 64 A5 5 0 0 1 50 60 A5 5 0 0 1 60 64Z" fill="#e8384a"/>`+br("M30 44 Q28 52 28 60",4,.6);case 6:return ae(pe("k",[[0,"#5a5a6a"],[1,"#22222c"]]))+St(50,94,36,4)+[[30,30,6],[46,20,8],[62,28,5]].map(([r,o,n])=>`<circle cx="${r}" cy="${o}" r="${n}" fill="${Z("#4ad3a0",.2)}" stroke="${t}" stroke-width="2"/>`).join("")+`<ellipse cx="50" cy="44" rx="38" ry="10" fill="#4ad3a0" stroke="${t}" stroke-width="3"/><path d="M12 44 Q12 86 50 86 Q88 86 88 44Z" fill="url(#k)" stroke="${t}" stroke-width="3.5"/><path d="M26 86 L22 94 M74 86 L78 94" stroke="${t}" stroke-width="5" stroke-linecap="round"/>`+br("M20 54 Q22 68 30 76",4,.35);default:return ae(qe("o",[[0,"#ffffff"],[.35,Z(Fr,.4)],[1,W(Fr,.35)]],.4,.35))+St(50,94,26,4)+`<path d="M28 94 L34 76 L66 76 L72 94Z" fill="#a8774a" stroke="${t}" stroke-width="3"/><circle cx="50" cy="44" r="34" fill="${Fr}" opacity="0.25"/><circle cx="50" cy="46" r="28" fill="url(#o)" stroke="${t}" stroke-width="3.5"/><polygon points="${et(50,46,12,5,4)}" fill="#fff" opacity="0.85"/>`+[[18,20],[84,26],[80,70],[16,66]].map(([r,o])=>`<polygon points="${et(r,o,5,2,4)}" fill="#fff6c0"/>`).join("")}}),Bs=(e,t)=>ae(pe("pad",[[0,Z(e,.25)],[1,W(e,.25)]]))+`<rect x="6" y="6" width="88" height="88" rx="20" fill="url(#pad)" stroke="${t}" stroke-width="4"/><rect x="12" y="12" width="76" height="40" rx="14" fill="#fff" opacity="0.18"/>`,eh=Jt(e=>Bs("#5ab04a",e)+`<path d="M26 44 Q24 84 32 84 L68 84 Q76 84 74 44 Q50 36 26 44Z" fill="#d8b884" stroke="${e}" stroke-width="3.5"/><path d="M30 46 Q40 32 50 40 Q60 32 70 46" fill="#e8cc9a" stroke="${e}" stroke-width="3"/><path d="M50 40 Q48 26 50 18" stroke="#3f8a3a" stroke-width="4" fill="none" stroke-linecap="round"/><ellipse cx="41" cy="22" rx="9" ry="5" fill="#7fd36e" stroke="${e}" stroke-width="2.5" transform="rotate(-25 41 22)"/><ellipse cx="59" cy="20" rx="9" ry="5" fill="#7fd36e" stroke="${e}" stroke-width="2.5" transform="rotate(25 59 20)"/>`+[[42,64],[52,70],[58,60]].map(([t,r])=>`<ellipse cx="${t}" cy="${r}" rx="3" ry="4" fill="#8a5a32"/>`).join("")),th=Jt(e=>Bs("#e09a3a",e)+`<path d="M16 84 L16 50 Q16 20 50 20 Q84 20 84 50 L84 84Z" fill="#c8634a" stroke="${e}" stroke-width="3.5"/>`+[30,44,58].map(t=>`<path d="M18 ${t} L82 ${t}" stroke="${W("#c8634a",.3)}" stroke-width="2"/>`).join("")+`<path d="M30 84 L30 60 Q30 46 50 46 Q70 46 70 84Z" fill="#2a1a14" stroke="${e}" stroke-width="3"/><path d="M38 84 Q36 70 44 64 Q44 72 50 70 Q50 60 58 58 Q66 70 62 84Z" fill="#ffb03a"/><path d="M44 84 Q44 76 50 74 Q56 76 56 84Z" fill="#ffe66a"/>`),rh=Jt(e=>Bs("#4a7ad3",e)+`<path d="M14 84 L22 46 L42 28 L66 32 L84 54 L86 84Z" fill="#8a8a9a" stroke="${e}" stroke-width="3.5" stroke-linejoin="round"/><path d="M22 46 L40 56 L42 28 M40 56 L66 32 M40 56 L60 84 M66 32 L68 60 L84 54 M68 60 L60 84" fill="none" stroke="${W("#8a8a9a",.3)}" stroke-width="2"/>`+Xn(36,76,18,6,Or,e)+Xn(70,78,14,5,"#ff4a8a",e)+`<path d="M58 14 L84 26" stroke="#8a5a32" stroke-width="5" stroke-linecap="round"/><path d="M76 12 Q86 20 90 34 L82 30 Q80 22 72 18Z" fill="#c8ccd6" stroke="${e}" stroke-width="2.5"/>`),nh=Jt(e=>Bs("#8a4ad3",e)+`<rect x="16" y="20" width="68" height="66" rx="6" fill="#8a5a32" stroke="${e}" stroke-width="3.5"/><path d="M16 52 L84 52" stroke="${e}" stroke-width="3"/>`+[[30,44,"#4ad3a0"],[50,44,"#ff6a5a"],[70,44,Fr],[30,78,Fr],[50,78,"#ffc83a"],[70,78,"#4ad3a0"]].map(([t,r,o])=>`<rect x="${Number(t)-4}" y="${Number(r)-20}" width="8" height="6" fill="#d8b884"/><path d="M${Number(t)-6} ${Number(r)-14} L${Number(t)+6} ${Number(r)-14} L${Number(t)+7} ${r} L${Number(t)-7} ${r}Z" fill="${o}" stroke="${e}" stroke-width="2"/>`).join("")),rd=e=>Jt(t=>{let r="#c08a4a";return ae(pe("w",[[0,Z(r,.15)],[1,W(r,.2)]]))+`<rect x="6" y="6" width="88" height="88" rx="8" fill="url(#w)" stroke="${t}" stroke-width="4"/>`+[30,50,70].map(o=>`<line x1="8" y1="${o}" x2="92" y2="${o}" stroke="${W(r,.35)}" stroke-width="2"/>`).join("")+`<path d="M14 14 L86 86 M86 14 L14 86" stroke="${W(r,.3)}" stroke-width="7"/><rect x="6" y="6" width="88" height="88" rx="8" fill="none" stroke="${t}" stroke-width="4"/>`+(e?`<rect x="6" y="22" width="88" height="10" fill="#8a96aa" stroke="${t}" stroke-width="2.5"/><rect x="6" y="68" width="88" height="10" fill="#8a96aa" stroke="${t}" stroke-width="2.5"/>`+[16,50,84].map(o=>`<circle cx="${o}" cy="27" r="2.5" fill="${t}"/><circle cx="${o}" cy="73" r="2.5" fill="${t}"/>`).join(""):"")}),oh={w:100,h:100,draw:()=>ae(qe("f",[[0,"#ffffff"],[1,"#c8d2e0"]],.45,.4,.6))+'<rect x="2" y="2" width="96" height="96" rx="14" fill="url(#f)" opacity="0.97"/>'+[[28,34,18],[62,30,20],[44,58,22],[76,64,16],[22,70,14]].map(([e,t,r])=>`<circle cx="${e}" cy="${t}" r="${r}" fill="#ffffff" opacity="0.75"/>`).join("")+'<text x="50" y="62" font-size="30" font-family="sans-serif" font-weight="900" text-anchor="middle" fill="#8a96aa" opacity="0.8">?</text>'},sh=Jt(e=>'<g stroke="#ffffff" stroke-width="2.5" fill="none" opacity="0.9">'+[0,45,90,135].map(t=>`<line x1="${50-46*Math.cos(t*Math.PI/180)}" y1="${50-46*Math.sin(t*Math.PI/180)}" x2="${50+46*Math.cos(t*Math.PI/180)}" y2="${50+46*Math.sin(t*Math.PI/180)}"/>`).join("")+[14,28,42].map(t=>`<polygon points="${Tt(50,50,t,8,0)}"/>`).join("")+`</g><g stroke="${e}" stroke-width="1" fill="none" opacity="0.35">`+[14,28,42].map(t=>`<polygon points="${Tt(50,50,t,8,0)}"/>`).join("")+"</g>"),ah={w:100,h:100,draw:()=>ae(qe("u",[[0,"#ffffff",0],[.75,"#9ad8ff",.25],[1,"#4ab0ff",.7]]))+'<circle cx="50" cy="50" r="46" fill="url(#u)" stroke="#ffffff" stroke-width="3" opacity="0.95"/>'+br("M24 38 Q28 24 42 18",6,.85)+'<circle cx="72" cy="72" r="4" fill="#fff" opacity="0.7"/>'},ih=Jt(e=>ae(pe("j",[[0,"#ff6a8a"],[.35,"#ffc83a"],[.7,"#5ad35a"],[1,"#4aa8ff"]]))+St(50,90,26,4)+`<circle cx="50" cy="50" r="40" fill="#fff" opacity="0.25"/><polygon points="${et(50,50,40,18,5)}" fill="url(#j)" stroke="${e}" stroke-width="3.5" stroke-linejoin="round"/><circle cx="42" cy="46" r="4" fill="${e}"/><circle cx="58" cy="46" r="4" fill="${e}"/><path d="M42 58 Q50 64 58 58" stroke="${e}" stroke-width="3" fill="none" stroke-linecap="round"/>`),lh=Jt(e=>St(50,92,22,4)+`<path d="M50 54 L26 12 L34 10 L54 48Z" fill="#d8dee8" stroke="${e}" stroke-width="3" stroke-linejoin="round"/><path d="M50 54 L74 12 L66 10 L46 48Z" fill="#eef2f8" stroke="${e}" stroke-width="3" stroke-linejoin="round"/><circle cx="34" cy="74" r="14" fill="none" stroke="${e}" stroke-width="10"/><circle cx="34" cy="74" r="14" fill="none" stroke="#e8384a" stroke-width="6"/><circle cx="66" cy="74" r="14" fill="none" stroke="${e}" stroke-width="10"/><circle cx="66" cy="74" r="14" fill="none" stroke="#e8384a" stroke-width="6"/><circle cx="50" cy="54" r="5" fill="#ffc83a" stroke="${e}" stroke-width="2"/>`),ch=Jt(e=>ae(qe("e",[[0,"#fff6a0"],[1,"#ffb000"]],.4,.35))+`<circle cx="50" cy="50" r="44" fill="url(#e)" stroke="${e}" stroke-width="4"/><path d="M56 12 L26 56 L46 56 L40 88 L74 40 L54 40Z" fill="#fff" stroke="${e}" stroke-width="3.5" stroke-linejoin="round"/>`),dh=Jt(e=>ae(pe("t",[[0,"#9aa6ba"],[1,"#5a6478"]],true))+`<rect x="36" y="8" width="28" height="10" rx="4" fill="#5a6478" stroke="${e}" stroke-width="3"/><rect x="14" y="16" width="72" height="12" rx="4" fill="#7a869a" stroke="${e}" stroke-width="3.5"/><path d="M20 30 L26 90 L74 90 L80 30Z" fill="url(#t)" stroke="${e}" stroke-width="3.5" stroke-linejoin="round"/>`+[36,50,64].map(t=>`<line x1="${t}" y1="40" x2="${t}" y2="80" stroke="${e}" stroke-width="3" stroke-linecap="round" opacity="0.6"/>`).join("")),fh=Jt(e=>`<path d="M50 10 L80 44 L62 44 L62 84 L38 84 L38 44 L20 44Z" fill="#7cf0a0" stroke="${e}" stroke-width="4" stroke-linejoin="round"/>`+[[18,20],[84,66],[16,74]].map(([t,r])=>`<polygon points="${et(t,r,9,3.5,4)}" fill="#fff6a0" stroke="${e}" stroke-width="1.5"/>`).join("")),ph=Jt(e=>`<path d="M40 8 L16 50 L32 50 L26 90 L56 40 L40 40Z" fill="#ffd34a" stroke="${e}" stroke-width="3.5" stroke-linejoin="round"/><path d="M70 18 L52 50 L64 50 L60 82 L84 44 L72 44Z" fill="#fff6a0" stroke="${e}" stroke-width="3" stroke-linejoin="round"/>`),hh=Jt(e=>`<path d="M22 84 L64 42" stroke="${e}" stroke-width="12" stroke-linecap="round"/><path d="M22 84 L64 42" stroke="#8a5a32" stroke-width="7" stroke-linecap="round"/><polygon points="${et(70,34,24,10,5)}" fill="#ffc83a" stroke="${e}" stroke-width="3.5" stroke-linejoin="round"/>`+[[30,22],[88,70],[52,82]].map(([t,r])=>`<polygon points="${et(t,r,7,2.5,4)}" fill="#fff"/>`).join("")),nd={...Object.fromEntries([1,2,3,4,5,6,7].map(e=>[`mg_bake${e}`,Q0(e)])),...Object.fromEntries([1,2,3,4,5,6,7].map(e=>[`mg_jewel${e}`,Y0(e)])),...Object.fromEntries([1,2,3,4,5,6,7].map(e=>[`mg_potion${e}`,J0(e)])),mg_gen_garden:eh,mg_gen_bake:th,mg_gen_jewel:rh,mg_gen_potion:nh,mg_box:rd(false),mg_box2:rd(true),mg_fog:oh,mg_web:sh,mg_bubble:ah,mg_joker:ih,mg_scissors:lh,mg_energy:ch,mg_bin:dh,mg_sk_merge:fh,mg_sk_free:ph,mg_sk_joker:hh};var od={fantasy:{skyTop:"#3f6aa8",skyBottom:"#f4c98e",far1:"#7b8fb8",far2:"#566f94",near:"#2c5638",crust:"#6dbb45",soil:"#7a5232",deep:"#4e331e",floor:"#5f9a3e",detail:"#7ab552",road:"#a57d4f",edge:"#7a5a36",wall:"#e8d9b8",roof:"#b8483a"},"sci-fi":{skyTop:"#050816",skyBottom:"#3b1f63",far1:"#232b5c",far2:"#161c40",near:"#0e1430",crust:"#36e3ff",soil:"#2a3452",deep:"#151b30",floor:"#1b2340",detail:"#2a3762",road:"#2b3868",edge:"#36e3ff",wall:"#3a4a72",roof:"#232c4a"},cozy:{skyTop:"#8fd3ff",skyBottom:"#fff3d6",far1:"#b6e2a2",far2:"#8fcc7e",near:"#5fae5a",crust:"#8ed46f",soil:"#c98b5a",deep:"#9e6a42",floor:"#a8dc8a",detail:"#c6ecab",road:"#efc89a",edge:"#d9a676",wall:"#fff1e0",roof:"#ff8f8f"},"post-apocalypse":{skyTop:"#3b2a26",skyBottom:"#d0803e",far1:"#7a5442",far2:"#4e3a2e",near:"#2a201a",crust:"#5a5248",soil:"#6b6358",deep:"#3e3832",floor:"#5e5648",detail:"#4a4438",road:"#46423c",edge:"#2e2a26",wall:"#8a7a62",roof:"#5a3a2a"},default:{skyTop:"#25365e",skyBottom:"#7d9fd6",far1:"#4f6494",far2:"#3a4b72",near:"#283958",crust:"#5fae5a",soil:"#6b4a2e",deep:"#45301c",floor:"#3e5a46",detail:"#4b6a52",road:"#5a5f78",edge:"#454a60",wall:"#e6dccb",roof:"#5a6fae"}},fr=e=>od[e]??od.default,uh={w:100,h:200,draw({style:e}){let t=fr(e),r="";if(e==="sci-fi"){let o=Mr(7);r=Array.from({length:60},()=>`<circle cx="${q(o()*100)}" cy="${q(o()*150)}" r="${q(.3+o()*.6)}" fill="#fff" opacity="${q(.3+o()*.7)}"/>`).join("");}return ae(pe("s",[[0,t.skyTop],[.75,qn(t.skyTop,t.skyBottom,.7)],[1,t.skyBottom]]))+'<rect width="100" height="200" fill="url(#s)"/>'+r}},mh={w:100,h:100,draw({style:e}){if(e==="sci-fi")return ae(pe("p",[[0,"#ff9ad5"],[1,"#6a3cc8"]]),qe("h",[[0,"#ff9ad5",.5],[1,"#ff9ad5",0]]))+'<circle cx="50" cy="50" r="48" fill="url(#h)"/><circle cx="50" cy="50" r="26" fill="url(#p)"/><ellipse cx="50" cy="52" rx="44" ry="9" fill="none" stroke="#ffd0f0" stroke-width="3" opacity="0.8" transform="rotate(-14 50 52)"/>';let t=e==="post-apocalypse"?"#ff7a3a":e==="cozy"?"#fff2a8":"#fff0c0",r=e==="post-apocalypse"?"#ff5a2a":"#fff6d0";return ae(qe("h",[[0,r,.85],[.45,r,.35],[1,r,0]]))+`<circle cx="50" cy="50" r="50" fill="url(#h)"/><circle cx="50" cy="50" r="20" fill="${t}"/>`}},Hs=(e,t,r,o,n,s)=>{let a=Mr(e),i=Array.from({length:s},()=>o-a()*n);i.push(i[0]);let p=i.map((m,$)=>`${q($/s*t)},${q(m)}`);return `M0 ${r} L${p.join(" L")} L${t} ${r}Z`},yh={w:512,h:200,band:true,draw({style:e}){let t=fr(e),r=qn(t.far1,t.skyBottom,.35);if(e==="sci-fi"){let p=Mr(11),m=0,$="",k="";for(;m<500;){let O=26+Math.floor(p()*40),C=50+Math.floor(p()*130),z=Math.min(O,512-m);$+=`<rect x="${m}" y="${200-C}" width="${z}" height="${C}" fill="${p()<.5?t.far1:t.far2}"/>`,p()<.3&&($+=`<rect x="${m+z/2-1}" y="${200-C-18}" width="2" height="18" fill="${t.far1}"/><circle cx="${m+z/2}" cy="${200-C-18}" r="2" fill="#ff3d6e"/>`);for(let F=200-C+8;F<196;F+=10)for(let ne=m+4;ne<m+z-4;ne+=7)p()<.35&&(k+=`<rect x="${ne}" y="${F}" width="3" height="4" fill="${p()<.5?"#36e3ff":"#ffd36e"}" opacity="0.8"/>`);m+=z+2;}return $+k}if(e==="post-apocalypse"){let p=Mr(13),m=6,$=`<path d="${Hs(3,512,200,170,22,8)}" fill="${r}"/>`;for(;m<490;){let k=30+Math.floor(p()*36),C=200-(60+Math.floor(p()*110)),z=p()*20;$+=`<path d="M${m} 200 L${m} ${C+z} L${m+k*.3} ${C} L${m+k*.55} ${C+14+z} L${m+k} ${C+6} L${m+k} 200Z" fill="${p()<.5?t.far1:t.far2}"/>`;for(let F=C+20;F<190;F+=14)for(let ne=m+5;ne<m+k-6;ne+=10)p()<.5&&($+=`<rect x="${ne}" y="${F}" width="4" height="6" fill="${t.near}" opacity="0.7"/>`);m+=k+8+Math.floor(p()*20);}return $+'<ellipse cx="380" cy="60" rx="60" ry="14" fill="#2a1a14" opacity="0.25"/>'}if(e==="cozy"){let p=[80,230,400].map((m,$)=>`<rect x="${m}" y="${132-$*6}" width="22" height="18" fill="#fff4e8"/><polygon points="${m-3},${133-$*6} ${m+11},${120-$*6} ${m+25},${133-$*6}" fill="${["#ff8f8f","#8fb8ff","#ffb86b"][$]}"/><rect x="${m+8}" y="${140-$*6}" width="6" height="10" fill="#c98b5a"/>`).join("");return `<path d="${Hs(5,512,200,140,30,6)}" fill="${t.far1}"/>`+p+`<path d="${Hs(9,512,200,168,22,5)}" fill="${t.far2}"/>`+[40,170,300,460].map(m=>`<circle cx="${m}" cy="158" r="12" fill="${W(t.far2,.12)}"/>`).join("")}let o=Mr(17),n=[],s=[],a=(p,m)=>{n.push(`M${q(p-110)} 200 L${q(p)} ${q(m)} L${q(p+110)} 200Z`),s.push(`M${q(p-24)} ${q(m+26)} L${q(p)} ${q(m)} L${q(p+24)} ${q(m+26)} L${q(p+10)} ${q(m+20)} L${q(p)} ${q(m+28)} L${q(p-10)} ${q(m+20)}Z`);};for(let p=0;p<4;p++){let m=64+p*128+(o()-.5)*30,$=30+o()*40;a(m,$),m-110<0&&a(m+512,$),m+110>512&&a(m-512,$);}let i=e==="fantasy"?`<g fill="${W(t.far2,.15)}"><rect x="300" y="120" width="40" height="80"/><rect x="292" y="104" width="14" height="96"/><rect x="334" y="100" width="14" height="100"/><polygon points="290,104 299,84 308,104"/><polygon points="332,100 341,78 350,100"/>${[300,310,320,330].map(p=>`<rect x="${p}" y="114" width="6" height="8"/>`).join("")}</g><rect x="340" y="82" width="10" height="6" fill="#d0483b"/>`:"";return `<path d="${n.join(" ")}" fill="${r}"/><path d="${s.join(" ")}" fill="#f4f6ff" opacity="0.85"/><path d="${Hs(21,512,200,160,40,9)}" fill="${t.far2}"/>`+i}},gh={w:512,h:160,band:true,draw({style:e}){let t=fr(e),r=Mr(29),o=`<rect x="0" y="146" width="512" height="14" fill="${t.near}"/>`;if(e==="sci-fi"){let s=o;for(let a=30;a<500;a+=90+Math.floor(r()*40)){let i=60+r()*70;s+=`<rect x="${a}" y="${150-i}" width="8" height="${i}" fill="${t.near}"/><rect x="${a-14}" y="${150-i}" width="36" height="5" fill="${t.near}"/><circle cx="${a+4}" cy="${146-i}" r="3" fill="#36e3ff"/>`;}return s+=`<path d="M180 150 A40 40 0 0 1 260 150Z" fill="${t.near}"/><path d="M200 140 A22 22 0 0 1 240 140" stroke="#36e3ff" stroke-width="2" fill="none" opacity="0.7"/>`,s}if(e==="post-apocalypse"){let s=o,a=(i,p)=>`<path d="M${i} 150 L${i+3} ${150-p} M${i+2} ${150-p*.6} L${i-14} ${150-p*.85} M${i+2} ${150-p*.45} L${i+18} ${150-p*.7} M${i+3} ${150-p*.8} L${i+12} ${150-p}" stroke="${t.near}" stroke-width="5" stroke-linecap="round" fill="none"/>`;return s+=a(40,90)+a(300,110)+a(460,70),s+=`<rect x="150" y="18" width="5" height="132" fill="${t.near}"/><rect x="138" y="28" width="30" height="4" fill="${t.near}"/><path d="M0 34 Q75 54 152 30 Q260 58 360 34 Q440 50 512 34" stroke="${t.near}" stroke-width="1.5" fill="none"/>`,s+=`<path d="M180 150 L188 128 L232 124 L246 136 L262 138 L262 150Z" fill="${t.near}"/><circle cx="198" cy="150" r="8" fill="#1a120c"/><circle cx="246" cy="150" r="8" fill="#1a120c"/>`,s}if(e==="cozy"){let s=o;for(let a=20;a<500;a+=100+Math.floor(r()*30)){let i=50+r()*30;s+=`<rect x="${a+16}" y="${150-i*.5}" width="8" height="${i*.5}" fill="#9e6a42"/><circle cx="${a+20}" cy="${150-i*.6}" r="${i*.36}" fill="${t.near}"/><circle cx="${a+12}" cy="${150-i*.7}" r="${i*.12}" fill="${Z(t.near,.25)}"/>`;}for(let a=4;a<512;a+=16)s+=`<rect x="${a}" y="128" width="8" height="22" rx="3" fill="#fff8f0"/>`;return s+='<rect x="0" y="134" width="512" height="4" fill="#fff8f0"/>',s}let n=o;for(let s=14;s<500;s+=44+Math.floor(r()*50)){let a=70+r()*60,i=a*.36;n+=`<rect x="${s-3}" y="${150-a*.18}" width="6" height="${a*.18}" fill="${W(t.near,.3)}"/>`;for(let p=0;p<3;p++){let m=150-a*.15-p*a*.26,$=i*(1-p*.25);n+=`<polygon points="${q(s-$)},${q(m)} ${q(s)},${q(m-a*.42)} ${q(s+$)},${q(m)}" fill="${p===2?Z(t.near,.08):t.near}"/>`;}}return n}};function sd(e,t){let r=fr(e.style);if(e.style==="sci-fi")return `<rect x="0" y="0" width="${t}" height="16" fill="#3a4a72"/><rect x="0" y="0" width="${t}" height="4" fill="${e.c("primary")}"/><rect x="0" y="14" width="${t}" height="3" fill="#11172a"/>`+[16,48,80,112].filter(n=>n<t).map(n=>`<rect x="${n}" y="6" width="14" height="4" rx="2" fill="${e.c("primary")}" opacity="0.5"/>`).join("");if(e.style==="post-apocalypse")return `<path d="M0 0 L${t} 0 L${t} 14 L${t*.8} 18 L${t*.62} 12 L${t*.4} 20 L${t*.2} 13 L0 16Z" fill="#3a3530"/><path d="M${t*.15} 4 L${t*.3} 8 M${t*.6} 3 L${t*.75} 9" stroke="#24201c" stroke-width="2"/>`;if(e.style==="cozy"){let n="";for(let s=0;s<t;s+=32)n+=`<circle cx="${s+16}" cy="14" r="16" fill="${r.crust}"/>`;return `<rect x="0" y="0" width="${t}" height="14" fill="${r.crust}"/>${n}<circle cx="${t*.3}" cy="8" r="3" fill="#fff"/><circle cx="${t*.75}" cy="10" r="3" fill="#ff8fab"/>`}let o="";for(let n=2;n<t;n+=8)o+=`<polygon points="${n},12 ${n+3},${2+n*7%5} ${n+6},12" fill="${Z(r.crust,.15)}"/>`;return `<rect x="0" y="6" width="${t}" height="16" fill="${r.crust}"/>${o}<rect x="0" y="20" width="${t}" height="4" fill="${W(r.crust,.3)}"/>`}var bh={w:128,h:512,draw(e){let t=fr(e.style),r=Mr(41),o="";for(let n=0;n<14;n++)o+=`<ellipse cx="${q(8+r()*112)}" cy="${q(40+r()*460)}" rx="${q(4+r()*7)}" ry="${q(3+r()*4)}" fill="${W(t.soil,.2+r()*.15)}"/>`;return e.style==="sci-fi"&&(o=[80,180,280,380].map(n=>`<rect x="0" y="${n}" width="128" height="2" fill="#11172a"/>`).join("")+'<rect x="62" y="20" width="2" height="492" fill="#11172a"/>'+[100,300].map(n=>`<circle cx="20" cy="${n}" r="3" fill="#4a5a88"/><circle cx="108" cy="${n}" r="3" fill="#4a5a88"/>`).join("")),ae(pe("d",[[0,t.soil],[1,t.deep]]))+'<rect width="128" height="512" fill="url(#d)"/>'+o+sd(e,128)}},xh={w:128,h:40,draw(e){let t=fr(e.style);return ae(pe("d",[[0,t.soil],[1,t.deep]]))+'<path d="M0 10 L128 10 L128 26 Q96 40 64 36 Q32 40 0 26Z" fill="url(#d)"/>'+sd(e,128)+`<path d="M0 26 Q32 40 64 36 Q96 40 128 26" stroke="${e.ink}" stroke-width="2.5" fill="none" opacity="0.5"/>`}},kh={w:128,h:100,draw(e){let t=fr(e.style);if(e.style==="sci-fi")return `<rect width="128" height="100" fill="${t.road}"/><rect y="0" width="128" height="5" fill="${e.c("primary")}" opacity="0.8"/><rect y="95" width="128" height="5" fill="${e.c("primary")}" opacity="0.8"/><path d="M40 38 L58 50 L40 62 M74 38 L92 50 L74 62" stroke="${e.c("primary")}" stroke-width="5" fill="none" opacity="0.35"/>`;if(e.style==="cozy"){let s="";for(let a=0;a<5;a++)for(let i=a%2*-16;i<128;i+=32)s+=`<rect x="${i+1}" y="${a*20+1}" width="30" height="18" rx="4" fill="${a%2?t.road:Z(t.road,.08)}" stroke="${t.edge}" stroke-width="2"/>`;return `<rect width="128" height="100" fill="${t.edge}"/>${s}`}let r=Mr(53),o="";for(let s=0;s<12;s++)o+=`<ellipse cx="${q(r()*128)}" cy="${q(10+r()*80)}" rx="${q(2+r()*3)}" ry="${q(1.5+r()*2)}" fill="${W(t.road,.25)}"/>`;let n=e.style==="post-apocalypse"?'<rect x="20" y="47" width="40" height="6" fill="#c9a43a" opacity="0.75"/><path d="M80 20 L96 36 L90 52" stroke="#2a2622" stroke-width="2" fill="none"/>':"";return `<rect width="128" height="100" fill="${t.road}"/><rect width="128" height="6" fill="${t.edge}"/><rect y="94" width="128" height="6" fill="${t.edge}"/>${o}${n}`}},vh={w:128,h:128,draw({style:e}){let t=fr(e),r=Mr(61),o="";if(e==="sci-fi")o=`<rect x="2" y="2" width="60" height="60" rx="4" fill="${t.detail}"/><rect x="66" y="66" width="60" height="60" rx="4" fill="${t.detail}"/><rect x="66" y="2" width="60" height="60" rx="4" fill="${Z(t.floor,.05)}"/><rect x="2" y="66" width="60" height="60" rx="4" fill="${Z(t.floor,.05)}"/><rect x="62" y="0" width="4" height="128" fill="#36e3ff" opacity="0.18"/><rect x="0" y="62" width="128" height="4" fill="#36e3ff" opacity="0.18"/>`;else if(e==="post-apocalypse")o=`<path d="M10 20 L40 44 L36 70 L60 96 M80 10 L92 40 L120 52 M70 80 L100 110" stroke="${t.detail}" stroke-width="2.5" fill="none"/>`;else for(let n=0;n<18;n++){let s=6+r()*116,a=6+r()*116;o+=`<path d="M${q(s)} ${q(a)} l-3 -6 M${q(s)} ${q(a)} l0 -7 M${q(s)} ${q(a)} l3 -6" stroke="${t.detail}" stroke-width="2" stroke-linecap="round"/>`,e==="cozy"&&n%5===0&&(o+=`<circle cx="${q(s+6)}" cy="${q(a)}" r="2.5" fill="${["#fff","#ff8fab","#ffd166"][n%3]}"/>`);}return `<rect width="128" height="128" fill="${t.floor}"/>${o}`}},$h=e=>({w:64,h:64,draw({style:t,ink:r}){let o=fr(t),n='<ellipse cx="32" cy="50" rx="20" ry="6" fill="#000" opacity="0.22"/>';if(t==="sci-fi"){let i=[`<rect x="14" y="16" width="36" height="32" rx="4" fill="#4a5a80" stroke="${r}" stroke-width="3"/><rect x="20" y="24" width="24" height="5" fill="#36e3ff"/>`,`<circle cx="32" cy="32" r="16" fill="#2a3452" stroke="${r}" stroke-width="3"/>${[0,1,2,3].map(p=>`<rect x="22" y="${23+p*5}" width="20" height="2" fill="#11172a"/>`).join("")}`,`<rect x="6" y="28" width="52" height="10" rx="5" fill="#5d6f96" stroke="${r}" stroke-width="3"/><circle cx="18" cy="33" r="3" fill="#ff3d6e"/>`,'<circle cx="32" cy="32" r="8" fill="#b45cff"/><circle cx="32" cy="32" r="14" fill="none" stroke="#b45cff" stroke-width="2" opacity="0.5"/>'];return n+i[(e-1)%4]}if(t==="post-apocalypse"){let i=[`<circle cx="32" cy="32" r="18" fill="#1e1a16" stroke="${r}" stroke-width="3"/><circle cx="32" cy="32" r="8" fill="${o.floor}"/>`,`<circle cx="32" cy="32" r="16" fill="#8a3d24" stroke="${r}" stroke-width="3"/><circle cx="32" cy="32" r="10" fill="none" stroke="#5a2814" stroke-width="2"/>`,`<polygon points="10,40 22,22 38,30 52,18 54,44 30,48" fill="#6b6358" stroke="${r}" stroke-width="3" stroke-linejoin="round"/>`,'<path d="M20 44 L24 20 M32 46 L32 16 M42 44 L38 22" stroke="#7a6a3a" stroke-width="3" stroke-linecap="round"/>'];return n+i[(e-1)%4]}let s=t==="cozy"?"#6fc46a":"#3f7f3a",a=[`<circle cx="22" cy="34" r="12" fill="${s}" stroke="${r}" stroke-width="3"/><circle cx="42" cy="34" r="12" fill="${s}" stroke="${r}" stroke-width="3"/><circle cx="32" cy="24" r="13" fill="${Z(s,.1)}" stroke="${r}" stroke-width="3"/>`,`<path d="M12 44 Q14 22 32 20 Q50 22 52 44Z" fill="#9aa0a8" stroke="${r}" stroke-width="3"/><path d="M22 28 Q30 24 36 26" stroke="#fff" stroke-width="3" opacity="0.5" fill="none"/>`,[[22,28],[40,24],[32,40],[46,40]].map(([i,p],m)=>`<polygon points="${et(i,p,7,3,5)}" fill="${["#ff8fab","#ffd166","#fff","#c39bff"][m]}" stroke="${r}" stroke-width="1.5"/>`).join(""),t==="cozy"?`<rect x="28" y="30" width="8" height="16" fill="#fff4e6" stroke="${r}" stroke-width="2.5"/><path d="M14 32 Q32 8 50 32Z" fill="#ff6b6b" stroke="${r}" stroke-width="3"/><circle cx="26" cy="24" r="3" fill="#fff"/><circle cx="38" cy="26" r="2.5" fill="#fff"/>`:`<ellipse cx="32" cy="38" rx="16" ry="9" fill="#8a5a32" stroke="${r}" stroke-width="3"/><ellipse cx="32" cy="34" rx="16" ry="9" fill="#c49a6a" stroke="${r}" stroke-width="3"/><ellipse cx="32" cy="34" rx="8" ry="4" fill="none" stroke="#8a5a32" stroke-width="2"/>`];return n+a[(e-1)%4]}}),Mh={w:0,h:0,exact:true,main:"ground",draw({style:e,w:t,h:r}){let o=fr(e),n=Mr(Math.round(t*13+r)),s="";for(let a=0;a<4;a++){let i=t*(.15+n()*.7),p=r*(.2+n()*.65);s+=e==="sci-fi"?`<circle cx="${q(i)}" cy="${q(p)}" r="${q(t*.02)}" fill="#4a5a88"/>`:`<path d="M${q(i)} ${q(p)} l${q(-t*.04)} ${q(-r*.08)} M${q(i)} ${q(p)} l0 ${q(-r*.1)} M${q(i)} ${q(p)} l${q(t*.04)} ${q(-r*.08)}" stroke="${o.detail}" stroke-width="${q(t*.025)}" stroke-linecap="round"/>`;}return `<rect width="${t}" height="${r}" fill="${o.floor}"/><rect x="0.5" y="0.5" width="${t-1}" height="${r-1}" fill="none" stroke="${W(o.floor,.25)}" stroke-opacity="0.35" stroke-width="1"/>${s}`}},wh={w:0,h:0,exact:true,main:"lane",draw({style:e,w:t,h:r,c:o}){let n=fr(e),s=Mr(Math.round(t*7+r*3)),a="";for(let p=0;p<5;p++)a+=`<ellipse cx="${q(t*(.15+s()*.7))}" cy="${q(r*(.15+s()*.7))}" rx="${q(t*(.04+s()*.05))}" ry="${q(r*.035)}" fill="${W(n.road,.18)}"/>`;let i=e==="sci-fi"?`<rect x="${q(t*.42)}" y="${q(r*.42)}" width="${q(t*.16)}" height="${q(r*.16)}" rx="2" fill="${o("primary")}" opacity="0.45"/>`:"";return `<rect width="${t}" height="${r}" fill="${n.road}"/>${a}${i}`}},Eh=e=>({w:100,h:130,main:"primary",draw({style:t,ink:r,main:o,c:n}){let s='<ellipse cx="50" cy="122" rx="38" ry="8" fill="#000" opacity="0.28"/>';if(t==="sci-fi"||t==="post-apocalypse"){let C=t==="sci-fi"?"#5d6f96":"#7a6a52",z=t==="sci-fi"?o:n("coin"),F=Array.from({length:e},(X,ye)=>`<rect x="50" y="${52-(e-1)*5+ye*10}" width="${36+e*2}" height="8" rx="3" fill="${W(C,.25)}" stroke="${r}" stroke-width="2.5"/>`).join(""),ne=t==="post-apocalypse"?[0,1,2].map(X=>`<ellipse cx="${26+X*24}" cy="106" rx="14" ry="9" fill="#a89070" stroke="${r}" stroke-width="2.5"/>`).join("")+[0,1].map(X=>`<ellipse cx="${38+X*24}" cy="94" rx="14" ry="9" fill="#b8a080" stroke="${r}" stroke-width="2.5"/>`).join(""):`<polygon points="${Tt(50,100,34,6,0)}" fill="#2a3452" stroke="${r}" stroke-width="3.5"/><polygon points="${Tt(50,100,22,6,0)}" fill="${z}" opacity="0.4"/>`;return s+ne+`<rect x="38" y="64" width="24" height="30" fill="${C}" stroke="${r}" stroke-width="3"/>`+F+`<path d="M24 68 A26 26 0 0 1 76 68Z" fill="${Z(C,.15)}" stroke="${r}" stroke-width="3.5"/><circle cx="50" cy="56" r="${5+e}" fill="${z}" stroke="${r}" stroke-width="2.5"/>`}let a=t==="cozy"?"#f4e6d4":"#a7a9b2",i=t==="cozy"?n("primary"):o,p=70-e*14,m="";for(let C=p+10;C<112;C+=12)m+=`<line x1="26" y1="${C}" x2="74" y2="${C}" stroke="${W(a,.25)}" stroke-width="2"/>`+[0,1].map(z=>`<line x1="${36+z*16+C/12%2*8}" y1="${C}" x2="${36+z*16+C/12%2*8}" y2="${C+12}" stroke="${W(a,.25)}" stroke-width="2"/>`).join("");let $=[26,40,54,68].map(C=>`<rect x="${C}" y="${p-10}" width="8" height="12" fill="${a}" stroke="${r}" stroke-width="2.5"/>`).join(""),k=e>=2?`<polygon points="20,${p-2} 50,${p-44} 80,${p-2}" fill="${i}" stroke="${r}" stroke-width="3.5" stroke-linejoin="round"/><polygon points="20,${p-2} 50,${p-44} 40,${p-2}" fill="${Z(i,.2)}"/>`:$,O=e>=3?`<line x1="50" y1="${p-44}" x2="50" y2="${p-64}" stroke="${r}" stroke-width="3"/><path d="M50 ${p-64} L70 ${p-58} L50 ${p-52}Z" fill="${n("coin")}" stroke="${r}" stroke-width="2"/>`:"";return s+ae(pe("s",[[0,Z(a,.2)],[1,W(a,.2)]],true))+`<rect x="24" y="${p}" width="52" height="${116-p}" fill="url(#s)" stroke="${r}" stroke-width="3.5"/>`+m+`<rect x="44" y="${p+16}" width="12" height="18" rx="6" fill="#2a2030" stroke="${r}" stroke-width="2.5"/><path d="M42 116 L42 100 A8 8 0 0 1 58 100 L58 116Z" fill="#6a4628" stroke="${r}" stroke-width="2.5"/>`+k+O}}),Sh=e=>({w:120,h:120,main:`piece${e}`,draw({style:t,ink:r,main:o,c:n}){let s=fr(t),a=t==="cozy"?Z(o,.6):s.wall,i=t==="sci-fi"?n("primary"):t==="post-apocalypse"?"#3a3530":"#9fd2f0",p=(k,O,C=12,z=14)=>`<rect x="${k}" y="${O}" width="${C}" height="${z}" rx="2" fill="${i}" stroke="${r}" stroke-width="2"/>`+(t==="post-apocalypse"?`<path d="M${k} ${O+3} L${k+C} ${O+z-3}" stroke="#8a6a3a" stroke-width="3"/>`:`<rect x="${k+2}" y="${O+2}" width="${C*.3}" height="${z*.4}" fill="#fff" opacity="0.5"/>`),m='<ellipse cx="60" cy="114" rx="50" ry="6" fill="#000" opacity="0.25"/>',$=(k,O,C)=>{let z="";for(let F=0;F<C;F+=12)z+=`<path d="M${k+F} ${O} h12 v10 q-6 6 -12 0Z" fill="${F/12%2?"#fff":o}" stroke="${r}" stroke-width="2"/>`;return z};switch(e){case 1:return m+`<rect x="22" y="64" width="76" height="46" fill="${a}" stroke="${r}" stroke-width="3"/><rect x="16" y="60" width="88" height="8" fill="${W(a,.2)}" stroke="${r}" stroke-width="3"/><rect x="28" y="30" width="4" height="34" fill="${r}"/><rect x="88" y="30" width="4" height="34" fill="${r}"/>`+$(22,24,76)+`<circle cx="44" cy="56" r="6" fill="${n("coin")}" stroke="${r}" stroke-width="2"/><circle cx="60" cy="54" r="7" fill="${o}" stroke="${r}" stroke-width="2"/><circle cx="76" cy="56" r="6" fill="${n("accent")}" stroke="${r}" stroke-width="2"/>`;case 2:return m+`<rect x="18" y="40" width="84" height="70" fill="${a}" stroke="${r}" stroke-width="3"/><polygon points="12,42 60,14 108,42" fill="${s.roof}" stroke="${r}" stroke-width="3" stroke-linejoin="round"/>`+$(22,54,76)+p(28,72,28,24)+`<rect x="68" y="72" width="22" height="38" fill="${W(o,.2)}" stroke="${r}" stroke-width="3"/>`;case 3:return m+`<rect x="20" y="26" width="80" height="84" fill="${a}" stroke="${r}" stroke-width="3"/><rect x="14" y="18" width="92" height="10" fill="${s.roof}" stroke="${r}" stroke-width="3"/>`+p(30,36)+p(54,36)+p(78,36)+$(20,62,80)+p(30,78,26,22)+`<rect x="66" y="78" width="22" height="32" fill="${W(o,.25)}" stroke="${r}" stroke-width="3"/><rect x="42" y="4" width="36" height="16" rx="4" fill="${o}" stroke="${r}" stroke-width="2.5"/><path d="M54 8 h10 v6 a4 4 0 0 1 -10 0Z" fill="#fff"/>`;case 4:return m+`<rect x="80" y="14" width="12" height="40" fill="${W(s.wall,.35)}" stroke="${r}" stroke-width="3"/><circle cx="90" cy="8" r="7" fill="#cfcfd8" opacity="0.75"/><circle cx="100" cy="2" r="5" fill="#cfcfd8" opacity="0.5"/><path d="M12 110 L12 50 L36 36 L36 50 L60 36 L60 50 L84 36 L84 50 L108 50 L108 110Z" fill="${W(a,.08)}" stroke="${r}" stroke-width="3" stroke-linejoin="round"/>`+p(22,62)+p(46,62)+p(70,62)+`<rect x="40" y="84" width="40" height="26" fill="${o}" stroke="${r}" stroke-width="3"/>`+[0,1,2].map(k=>`<line x1="40" y1="${90+k*7}" x2="80" y2="${90+k*7}" stroke="${W(o,.35)}" stroke-width="2"/>`).join("");case 5:return m+`<polygon points="8,42 60,12 112,42" fill="${Z(s.wall,.15)}" stroke="${r}" stroke-width="3" stroke-linejoin="round"/><circle cx="60" cy="32" r="8" fill="${n("coin")}" stroke="${r}" stroke-width="2.5"/><rect x="14" y="42" width="92" height="8" fill="${W(s.wall,.1)}" stroke="${r}" stroke-width="3"/>`+[20,40,72,92].map(k=>`<rect x="${k}" y="50" width="8" height="52" fill="${Z(s.wall,.2)}" stroke="${r}" stroke-width="2.5"/>`).join("")+`<rect x="50" y="62" width="20" height="40" fill="${o}" stroke="${r}" stroke-width="3"/><rect x="10" y="102" width="100" height="8" fill="${W(s.wall,.15)}" stroke="${r}" stroke-width="3"/>`;default:{let k="";for(let O=22;O<92;O+=18)k+=p(40,O,12,12)+p(62,O,12,12);return m+`<rect x="58" y="2" width="3" height="14" fill="${r}"/><circle cx="59.5" cy="2" r="3" fill="${n("danger")}"/><rect x="32" y="14" width="56" height="96" fill="${t==="cozy"?a:qn(s.wall,o,.25)}" stroke="${r}" stroke-width="3"/>`+k+`<rect x="50" y="94" width="20" height="16" fill="${W(o,.25)}" stroke="${r}" stroke-width="2.5"/>`}}}}),ad={sky:uh,sun:mh,far:yh,near:gh,ground:bh,platform:xh,road:kh,floor:vh,tile_grass:Mh,tile_road:wh,...Object.fromEntries([1,2,3,4].map(e=>[`decor${e}`,$h(e)])),...Object.fromEntries([1,2,3].map(e=>[`tower${e}`,Eh(e)])),...Object.fromEntries([1,2,3,4,5,6].map(e=>[`biz${e}`,Sh(e)]))};var Xo=(e,t,r,o,n=.28)=>`<ellipse cx="${e}" cy="${t}" rx="${r}" ry="${o}" fill="#000" opacity="${n}"/>`,Hi=(e,t=4,r=.55)=>`<path d="${e}" fill="none" stroke="#fff" stroke-width="${t}" stroke-linecap="round" opacity="${r}"/>`,qr=e=>({w:100,h:100,draw:({ink:t})=>e(t)}),Lh={w:120,h:120,main:"danger",draw({style:e,ink:t,main:r,c:o}){let n=fr(e),s=Array.from({length:9},(a,i)=>`<circle cx="${24+i*9}" cy="30" r="2.6" fill="${o("coin")}" stroke="${t}" stroke-width="1"/>`).join("");return Xo(60,114,50,6,.25)+`<rect x="14" y="40" width="92" height="70" fill="${n.wall}" stroke="${t}" stroke-width="3"/><rect x="10" y="18" width="100" height="24" rx="4" fill="${r}" stroke="${t}" stroke-width="3"/>`+s+`<rect x="34" y="46" width="52" height="22" rx="3" fill="${W(n.wall,.6)}" stroke="${t}" stroke-width="2.5"/><polygon points="54,51 54,63 66,57" fill="${o("coin")}"/><rect x="24" y="76" width="30" height="34" fill="${W(r,.25)}" stroke="${t}" stroke-width="3"/><rect x="66" y="76" width="30" height="34" fill="${W(r,.25)}" stroke="${t}" stroke-width="3"/><line x1="39" y1="76" x2="39" y2="110" stroke="${t}" stroke-width="2"/><line x1="81" y1="76" x2="81" y2="110" stroke="${t}" stroke-width="2"/><polygon points="${et(60,9,8,3.5)}" fill="${o("coin")}" stroke="${t}" stroke-width="2"/>`}},_h={w:120,h:120,main:"primary",draw({style:e,ink:t,main:r,c:o}){let n=fr(e);return Xo(60,114,52,6,.25)+`<path d="M8 110 L8 84 Q60 62 112 84 L112 110Z" fill="${n.wall}" stroke="${t}" stroke-width="3" stroke-linejoin="round"/><rect x="16" y="90" width="14" height="10" rx="2" fill="#9fd2f0" stroke="${t}" stroke-width="2"/><rect x="90" y="90" width="14" height="10" rx="2" fill="#9fd2f0" stroke="${t}" stroke-width="2"/><rect x="78" y="22" width="6" height="66" fill="${W(n.wall,.35)}" stroke="${t}" stroke-width="2.5"/>`+[34,50,66].map(s=>`<line x1="84" y1="${s}" x2="70" y2="${s}" stroke="${t}" stroke-width="2.5"/>`).join("")+`<path d="M60 6 Q72 22 70 64 L50 64 Q48 22 60 6Z" fill="${Z(r,.75)}" stroke="${t}" stroke-width="3" stroke-linejoin="round"/><circle cx="60" cy="34" r="6" fill="#9fd2f0" stroke="${t}" stroke-width="2.5"/><path d="M50 52 L40 70 L50 66Z M70 52 L80 70 L70 66Z" fill="${r}" stroke="${t}" stroke-width="2.5" stroke-linejoin="round"/><path d="M54 64 L60 82 L66 64Z" fill="${o("coin")}" stroke="${t}" stroke-width="2"/><path d="M57 64 L60 74 L63 64Z" fill="#fff"/>`}},id=(e,t)=>qr(r=>`<circle cx="50" cy="50" r="44" fill="${Z(e,.7)}" stroke="${r}" stroke-width="4"/><path d="M50 12 L76 40 L60 40 L60 62 L40 62 L40 40 L24 40Z" fill="${e}" stroke="${r}" stroke-width="3.5" stroke-linejoin="round"/><text x="50" y="88" text-anchor="middle" font-family="Arial, sans-serif" font-weight="900" font-size="24" fill="${r}">${t}</text>`),Rh=qr(e=>`<circle cx="50" cy="50" r="44" fill="#ffe8a8" stroke="${e}" stroke-width="4"/>`+[30,50,70].map((t,r)=>`<path d="M${t} ${16+(r===1?0:8)} L${t+13} ${32+(r===1?0:8)} L${t+6} ${32+(r===1?0:8)} L${t+6} 56 L${t-6} 56 L${t-6} ${32+(r===1?0:8)} L${t-13} ${32+(r===1?0:8)}Z" fill="#ffb21a" stroke="${e}" stroke-width="2.5" stroke-linejoin="round"/>`).join("")+`<text x="50" y="88" text-anchor="middle" font-family="Arial, sans-serif" font-weight="900" font-size="24" fill="${e}">\xD72</text>`),Ah=qr(e=>ae(qe("r",[[0,"#fff6a0"],[1,"#ff7a1a"]],.5,.6))+`<path d="M50 8 Q70 30 66 46 Q78 40 76 26 Q92 46 86 66 Q80 90 50 92 Q20 90 14 66 Q10 46 26 30 Q28 46 38 48 Q30 26 50 8Z" fill="url(#r)" stroke="${e}" stroke-width="3.5" stroke-linejoin="round"/><text x="50" y="76" text-anchor="middle" font-family="Arial, sans-serif" font-weight="900" font-size="30" fill="#fff" stroke="${e}" stroke-width="2">\xD73</text>`),Th=qr(e=>Xo(50,92,24,4)+`<path d="M30 80 L62 46" stroke="${e}" stroke-width="16" stroke-linecap="round"/><path d="M30 80 L62 46" stroke="#a8b2c2" stroke-width="10" stroke-linecap="round"/><path d="M58 24 A20 20 0 1 0 80 50 L70 50 L62 42 L62 30Z" fill="#c8d0dc" stroke="${e}" stroke-width="3.5" stroke-linejoin="round"/>`+Hi("M66 22 Q76 24 80 32",3,.7)+`<circle cx="26" cy="22" r="10" fill="#e8384a" stroke="${e}" stroke-width="3"/><path d="M26 15 L26 23 M26 27 L26 28" stroke="#fff" stroke-width="3.5" stroke-linecap="round"/>`),Dh=qr(e=>ae(pe("c",[[0,"#8a5a32"],[1,"#5a381c"]]))+Xo(50,90,34,5)+`<path d="M38 26 L38 18 Q38 14 42 14 L58 14 Q62 14 62 18 L62 26" fill="none" stroke="${e}" stroke-width="5"/><rect x="12" y="26" width="76" height="56" rx="8" fill="url(#c)" stroke="${e}" stroke-width="4"/><line x1="12" y1="46" x2="88" y2="46" stroke="${e}" stroke-width="3"/><rect x="44" y="40" width="12" height="12" rx="2" fill="#ffc83a" stroke="${e}" stroke-width="2.5"/><text x="50" y="74" text-anchor="middle" font-family="Arial, sans-serif" font-weight="900" font-size="20" fill="#ffd34a">$</text>`+Hi("M20 32 L40 32",3,.5)),Oh=qr(e=>`<circle cx="50" cy="50" r="44" fill="#d8ecff" stroke="${e}" stroke-width="4"/><circle cx="50" cy="36" r="14" fill="#f4c9a0" stroke="${e}" stroke-width="3"/><path d="M36 30 Q50 14 64 30 Q60 22 50 22 Q40 22 36 30Z" fill="#5a381c" stroke="${e}" stroke-width="2"/><path d="M22 86 Q22 56 50 54 Q78 56 78 86Z" fill="#3a4a72" stroke="${e}" stroke-width="3" stroke-linejoin="round"/><path d="M46 56 L54 56 L56 76 L50 82 L44 76Z" fill="#e8384a" stroke="${e}" stroke-width="2" stroke-linejoin="round"/>`),Ch=qr(e=>`<circle cx="48" cy="54" r="34" fill="#fff" stroke="${e}" stroke-width="4"/><path d="M48 54 L48 32 M48 54 L64 62" stroke="${e}" stroke-width="5" stroke-linecap="round"/><path d="M74 10 Q86 22 82 34 Q92 30 90 20 Q100 34 92 46 Q84 56 72 50 Q62 42 68 30 Q72 36 76 34 Q70 22 74 10Z" fill="#ff7a1a" stroke="${e}" stroke-width="2.5" stroke-linejoin="round"/><rect x="40" y="12" width="16" height="8" rx="3" fill="#8a96aa" stroke="${e}" stroke-width="2.5"/>`),Ph=qr(e=>ae(qe("i",[[0,"#fff6a0"],[1,"#ffb000"]],.45,.4))+`<circle cx="50" cy="50" r="42" fill="url(#i)" stroke="${e}" stroke-width="4"/><path d="M58 10 L28 54 L48 54 L40 90 L74 42 L54 42Z" fill="#fff" stroke="${e}" stroke-width="3.5" stroke-linejoin="round"/>`+[[18,24],[82,74],[20,78]].map(([t,r])=>`<polygon points="${et(t,r,7,2.5,4)}" fill="#fff" stroke="${e}" stroke-width="1.5"/>`).join("")),Ih=qr(e=>Xo(50,92,24,4)+`<path d="M14 46 L46 12 L86 12 L86 52 L52 86Z" fill="#ff5a7a" stroke="${e}" stroke-width="4" stroke-linejoin="round"/><circle cx="72" cy="26" r="7" fill="#fff" stroke="${e}" stroke-width="3"/><text x="54" y="62" text-anchor="middle" font-family="Arial, sans-serif" font-weight="900" font-size="24" fill="#fff" stroke="${e}" stroke-width="1.5" transform="rotate(-45 54 54)">%</text>`+Hi("M48 18 L24 44",3,.6)),ld={ty_cinema:Lh,ty_port:_h,ty_up:id("#5ad35a","\xD72"),ty_up3:id("#4aa8ff","\xD73"),ty_upall:Rh,ty_rush:Ah,ty_wrench:Th,ty_investor:Dh,ty_manager:Oh,ty_sk_rush:Ch,ty_sk_instant:Ph,ty_sk_sale:Ih};var Ws=Object.freeze({...Gc,...Fc,...qc,...Uc,...Zc,...ed,...nd,...ld,...ad,...Kc}),Nh=e=>Object.prototype.hasOwnProperty.call(Ws,e);function zh(e,t){let r=Ws[e];return r?r.exact?t.w/Math.max(1,t.h):r.w/r.h:1}function Bh(e,t){let r=Ws[e];if(!r)return null;let{palette:o,style:n,box:s,px:a}=t,i=z=>Ai(z,o),p=r.exact?s.w:r.w,m=r.exact?s.h:r.h,$=r.draw({style:n,c:i,main:i(t.color??r.main??"primary"),ink:jc(n),w:p,h:m}),k=Math.max(1,Math.round(a.h)),O=Math.max(0,Math.round(t.padBottom??0)),C=O>0?m*(k+O)/k:m;return `<svg xmlns="http://www.w3.org/2000/svg" width="${Math.max(1,Math.round(a.w))}" height="${k+O}" viewBox="0 0 ${p} ${C}" preserveAspectRatio="none">${$}</svg>`}var He=e=>({w:Number(e.vars.view_w??720),h:Number(e.vars.view_h??1280)}),st=e=>e.vars.state==="playing",hn=e=>e.vars.started_tick===e.tick,Je=(e,t,r)=>{let o=Number(e.vars[t]??0)+r;return e.vars[t]=o,o},yr=(e,t)=>Number(e[t]);function Ct(e,t,r,o,n){let s=e.create();return e.set(s,K,{x:t,y:r}),e.set(s,ie,o),n&&e.set(s,n.type,n.data),s}var dt=(e,t)=>{for(let r of e.query(t))e.destroy(r);};function Jn(e){let t=new Set,r={down:false,x:0,y:0};return e.on(Nt,o=>{let n=o;n.type==="key"?t.add(n.key):n.type==="key-up"?t.delete(n.key):n.type==="press"||n.type==="move"?(r.down=true,r.x=n.x,r.y=n.y):n.type==="release"&&(r.down=false);}),{keys:t,pointer:r,axis(){return {x:(t.has("right")?1:0)-(t.has("left")?1:0),y:(t.has("down")?1:0)-(t.has("up")?1:0)}}}}function un(e,t,r,o){let n=e.h*(o.bottom-o.top),s=Math.floor(Math.min(e.w*(o.widthShare??.94)/t,n/r)),a=(e.w-s*t)/2,i=e.h*o.top+(n-s*r)/2;return {cols:t,rows:r,cell:s,left:a,top:i}}var at=(e,t,r)=>({x:e.left+e.cell*(t+.5),y:e.top+e.cell*(r+.5)});function Ur(e,t,r){let o=Math.floor((t-e.left)/e.cell),n=Math.floor((r-e.top)/e.cell);return o>=0&&o<e.cols&&n>=0&&n<e.rows?{col:o,row:n}:null}var fd=["piece1","piece2","piece3","piece4","piece5","piece6"];ve("kit.status");var Vs=e=>{let t=Math.max(0,Math.ceil(e));return `${Math.floor(t/60)}:${String(t%60).padStart(2,"0")}`},G=(e,t)=>e.emit(Oi,t),Yn=ve("kit.backdrop");function zt(e,t,r,o={}){for(let $ of e.query(Yn))e.destroy($);let n=He(e),s=($,k,O,C)=>Ct(e,k,O,C,{type:Yn,data:{speed:$}});if(t==="top"){let $=o.pan?1:0;s($,n.w/2,n.h/2,{shape:"tile",art:"floor",w:n.w,h:n.h,unit:Math.min(n.w,n.h)*.24,depth:-100});let k=e.rng.stream("backdrop"),O=Math.round(n.w*n.h/52e3),C=Math.min(n.w,n.h);for(let z=0;z<O;z++){let F=C*k.range(.06,.1);s($,k.range(0,n.w),k.range(0,n.h),{shape:"sprite",art:`decor${k.int(1,4)}`,w:F,h:F,depth:-95});}return}let a=r??n.h*.62;s(0,n.w/2,n.h/2,{shape:"sprite",art:"sky",w:n.w,h:n.h,depth:-100});let i=Math.min(n.w,n.h)*.34;s(.02,n.w*.74,a*.3,{shape:"sprite",art:"sun",w:i,h:i,depth:-99});let p=Math.min(n.h*.32,n.w*.55);s(.12,n.w/2,a-p/2,{shape:"tile",art:"far",w:n.w,h:p,depth:-90});let m=p*.62;s(.4,n.w/2,a-m/2+2,{shape:"tile",art:"near",w:n.w,h:m,depth:-80}),t==="board"?s(0,n.w/2,(n.h+a)/2,{shape:"tile",art:"ground",w:n.w,h:n.h-a+4,unit:p*.7,depth:-79}):s(0,n.w/2,(n.h+a)/2,{shape:"rect",w:n.w,h:n.h-a,color:"#140f0c",alpha:.92,depth:-79});}function Zo(e,t){for(let r of e.query(Yn)){let o=e.need(r,Yn).speed;if(o<=0)continue;let n=e.need(r,ie);n.shape==="tile"&&(n.scrollX=(n.scrollX??0)+t*o);}}function pd(e,t,r){let o=He(e),n=Math.min(o.w,o.h)*.1;for(let s of e.query(Yn)){if(e.need(s,Yn).speed<=0)continue;let a=e.need(s,ie);if(a.shape==="tile"){a.scrollX=(a.scrollX??0)+t,a.scrollY=(a.scrollY??0)+r;continue}let i=e.need(s,K);i.x-=t,i.y-=r,i.x<-n?i.x+=o.w+2*n:i.x>o.w+n&&(i.x-=o.w+2*n),i.y<-n?i.y+=o.h+2*n:i.y>o.h+n&&(i.y-=o.h+2*n);}}function it(e,t,r){let o=e.get(t,ie);o?.shape==="actor"&&(o.pose=r);}function Fe(e,t,r){let o=e.get(t,ie);o?.shape==="actor"&&(o.act=r,o.actN=(o.actN??0)+1);}var Qn=ve("kit.fading"),cd=new WeakSet;function _n(e,t,r){e.set(t,Qn,{left:r,total:r}),!cd.has(e)&&(cd.add(e),e.addSystem({id:"kit.fading",order:90,run(o,n){for(let s of o.query(Qn)){let a=o.need(s,Qn);a.left-=n;let i=o.get(s,ie);i&&(i.alpha=Math.max(0,Math.min(1,a.left/a.total*2))),a.left<=0&&o.destroy(s);}}}));}var er=(e,t,r=5)=>r+t/Math.max(1,He(e).h),Zn=ve("kit.hint"),dd=new WeakSet,js=(e,t,r)=>({x:e+r*.11,y:t+r*.42});function kt(e,t,r,o=r,n){Bt(e);let s=n??Math.min(He(e).w,He(e).h)*.13,a={kind:t,ax:r.x,ay:r.y,bx:o.x,by:o.y,size:s,t:0},i=js(r.x,r.y,s);Ct(e,r.x,r.y,{shape:"circle",r:s*.22,color:"#ffffff",alpha:0,depth:89},{type:Zn,data:{...a,part:"ring"}}),Ct(e,i.x,i.y,{shape:"sprite",art:"hand",w:s,h:s,alpha:0,depth:90},{type:Zn,data:{...a,part:"hand"}}),!dd.has(e)&&(dd.add(e),e.addSystem({id:"kit.hints",order:95,run(p,m){for(let $ of p.query(Zn)){let k=p.need($,Zn);k.t+=m;let O=p.need($,K),C=p.need($,ie);if(k.kind==="tap"){let z=k.t%1.2/1.2,F=z>.35&&z<.55;if(k.part==="hand"){let ne=js(k.ax,k.ay+(F?k.size*.06:0),k.size);O.x=ne.x,O.y=ne.y,O.scale=F?.9:1,C.alpha=Math.min(1,k.t*4);}else {let ne=z<.4?0:(z-.4)/.6;O.scale=1+ne*2.2,C.alpha=z<.4?0:.55*(1-ne);}}else if(k.kind==="swipe"){let z=k.t%1.6/1.6,F=z<.15?0:z>.75?1:(z-.15)/.6,ne=F*F*(3-2*F),X=k.ax+(k.bx-k.ax)*ne,ye=k.ay+(k.by-k.ay)*ne;if(k.part==="hand"){let be=js(X,ye,k.size);O.x=be.x,O.y=be.y,C.alpha=z<.1?z*10:z>.85?Math.max(0,(1-z)/.15):1;}else O.x=X,O.y=ye,C.alpha=z>.15&&z<.8?.35:0;}else {let z=k.t*3,F=k.ax+Math.cos(z)*k.bx,ne=k.ay+Math.sin(z)*k.bx;if(k.part==="hand"){let X=js(F,ne,k.size);O.x=X.x,O.y=X.y,C.alpha=Math.min(1,k.t*3);}else O.x=F,O.y=ne,C.alpha=.3;}}}}));}function Bt(e){for(let t of e.query(Zn))e.destroy(t);}var _r=e=>e.query(Zn).length>0,vt=(e,t)=>e.vars[`learned:${t}`]===true;function Lt(e,t){vt(e,t)||(e.vars[`learned:${t}`]=true,Bt(e));}var eo=ve("round.start"),Ut="round-started",Xt="round-over",Zt="round-ended",Wi="start-round",Qt="show-start",tr="revive-offer",rr="revive",nr="give-up",Gs={id:"round",version:1,setup({world:e}){e.vars.state="ready",e.vars.score=0,e.vars.coins=0,e.vars.best=typeof e.vars.best=="number"?e.vars.best:0,e.vars.round=0;let t=o=>{for(let i of o.query(eo))o.destroy(i);if(o.vars.state!=="ready")return;let n=He(o),s=Math.min(n.w,n.h)*.26,a={x:n.w/2,y:n.h*.55};Ct(o,n.w/2,n.h/2,{shape:"rect",w:n.w,h:n.h,color:"#05040a",alpha:.4,depth:84},{type:eo,data:{t:-1}}),Ct(o,a.x,a.y,{shape:"sprite",art:"play",w:s,h:s,color:"accent",depth:85},{type:eo,data:{t:0}}),kt(o,"tap",{x:a.x+s*.12,y:a.y+s*.1});},r=()=>{for(let o of e.query(eo))e.destroy(o);Bt(e),e.vars.state="playing",e.vars.score=0,e.vars.coins=0,e.vars.round=Number(e.vars.round??0)+1,e.vars.started_tick=e.tick,e.emit(Ut,{round:e.vars.round});};e.on(Nt,o=>{let n=o;e.vars.state==="ready"&&(n.type==="tap"||n.type==="key"&&n.key==="action")&&r();}),e.on(Wi,()=>{e.vars.state!=="playing"&&r();}),e.on(Qt,()=>{e.vars.state==="ended"&&(e.vars.state="ready",t(e));}),e.on(qt,()=>t(e)),e.addSystem({id:"round.start",order:96,run(o,n){for(let s of o.query(eo)){let a=o.need(s,eo);a.t<0||(a.t+=n,o.need(s,K).scale=1+.06*Math.sin(a.t*5));}}}),t(e),e.on(Xt,o=>{if(e.vars.state!=="playing")return;e.vars.state="ended",Bt(e);let n=Number(e.vars.score??0),s=Math.max(Number(e.vars.best??0),n);e.vars.best=s,e.emit(Zt,{score:n,coins:Number(e.vars.coins??0),best:s,reason:typeof o.reason=="string"?o.reason:"over",...o.stats&&typeof o.stats=="object"?{stats:o.stats}:{}});});}};var Ks=["wall","barrier","pit","mover","train","rock"];var Yo=["magnet","shield","double","dash","flight"],Rr={magnet:{art:"magnet",color:"danger",seconds:6,var:"meta:magnet_t",weight:3},shield:{art:"shield",color:"muted",seconds:8,var:"meta:shield_t",weight:2.5},double:{art:"coin2x",color:"coin",seconds:8,var:"meta:double_t",weight:2.5},dash:{art:"boot",color:"accent",seconds:2.5,var:"meta:dash_t",weight:1.5},flight:{art:"wing",color:"secondary",seconds:4,var:"meta:flight_t",weight:1}},Qo=20,hd={wall:1,barrier:2,pit:3,mover:4,train:5,rock:6};function to(e,t=.5){let r=Math.max(1,Math.min(Qo,Math.floor(e))),o=(r-1)/(Qo-1),n=Ks.filter(i=>hd[i]<=r),s=Ks.find(i=>hd[i]===r)??null,a=330+t*120+o*220;return {level:r,length:Math.round(16e3+(r-1)*3e3),speed:a,topSpeed:a*(1.25+o*.1),density:Math.min(.72,.3+t*.12+o*.3),kinds:n,fresh:s,coinStar:.6,firstClearGold:60+(r-1)*25}}var ro=e=>Math.floor(e/30),no=[{id:"hero",cast:"hero",gems:0,perk:"none"},{id:"hero2",cast:"hero2",gems:150,perk:"heart"},{id:"hero3",cast:"hero3",gems:300,perk:"power"}],ji="kit-runner",Vi=[{id:"MagnetTime",var:"meta:magnet_t",art:"magnet",color:"danger",perLevel:.6,unit:"s",maxLevel:15,price:20,growth:.12},{id:"ShieldTime",var:"meta:shield_t",art:"shield",color:"muted",perLevel:.8,unit:"s",maxLevel:15,price:25,growth:.12},{id:"DoubleTime",var:"meta:double_t",art:"coin2x",color:"coin",perLevel:.8,unit:"s",maxLevel:15,price:25,growth:.12},{id:"DashTime",var:"meta:dash_t",art:"boot",color:"accent",perLevel:.3,unit:"s",maxLevel:15,price:30,growth:.12},{id:"FlightTime",var:"meta:flight_t",art:"wing",color:"secondary",perLevel:.4,unit:"s",maxLevel:15,price:35,growth:.12},{id:"Luck",var:"meta:luck",art:"clover",color:"accent",perLevel:5,unit:"%",maxLevel:20,price:30,growth:.1},{id:"HeadStart",var:"meta:head_start",art:"lightning",color:"primary",perLevel:.4,unit:"s",maxLevel:10,price:50,growth:.15},{id:"Greed",var:"meta:greed",art:"coin",color:"coin",perLevel:2,unit:"%",maxLevel:25,price:40,growth:.1}],ud={game:"runner",character:ji,stats:Vi,heroes:no,levels:Qo,firstClearGold:e=>to(e).firstClearGold,stars:3};var _t=ve("runner.item"),Xr=ve("runner.player"),Fs=ve("runner.stripe"),md=ve("runner.hud"),Wt=(e,t)=>{let r=Number(e.vars.view_w??720),o=Number(e.vars.view_h??1280),n=Math.min(o*.11,r*.2,o*.5/t),s=o*.6-n*t/2;return {viewW:r,viewH:o,top:s,laneH:n,playerX:Math.min(r*.24,o*.3)}},oo=(e,t)=>e.top+e.laneH*(t+.72),Jo=(e,t)=>{let r=Number(e.vars[t]??0);return Number.isFinite(r)?r:0},Pt={wall:1.3,barrier:.5,mover:1,train:.95,rock:1.05,jump:1.25,flight:1.9},qs={id:"lane-runner",version:2,engines:["phaser"],requires:["round"],params:{lanes:{type:"number",default:3,min:2,max:5,integer:true},difficulty:{type:"number",default:.5,min:0,max:1},coinRate:{type:"number",default:.7,min:0,max:1},powerRate:{type:"number",default:.22,min:0,max:1},lives:{type:"number",default:3,min:1,max:9,integer:true},coinScore:{type:"number",default:10,min:0,max:1e3,integer:true},graceTime:{type:"number",default:1.2,min:0,max:5},jumpTime:{type:"number",default:.62,min:.3,max:1.5},lengthScale:{type:"number",default:1,min:.05,max:5}},setup({world:e,params:t,mode:r}){let o=u=>yr(t,u),n=o("lanes"),s=e.rng.stream("lane-runner"),a=null,i=u=>({...u,kinds:[...Sr(r,"obstacles",u.kinds)]}),p=Sr(r,"powers",Yo),m=i(to(1,o("difficulty"))),$=m.length,k=0,O=0,C=0,z=false,F=false,ne=false,X=0,ye=0,be=0,fe=0,we=0,de=0,Re=0,Ce=3,Me=0,ce=false,ue=new Map,Pe=new Map,Le=()=>no.find(u=>u.id===e.vars["meta:hero"])??no[0],oe=u=>(Rr[u].seconds+Jo(e,Rr[u].var))*(Le().perk==="power"?1.25:1),Ee=()=>e.vars.reviving===true,tt=()=>{for(let b of e.query(Fs))e.destroy(b);let u=Wt(e,n);zt(e,"side",u.top+2);for(let b=0;b<n;b++){let d=e.create();e.set(d,Fs,{index:b}),e.set(d,K,{x:u.viewW/2,y:u.top+u.laneH*(b+.5)}),e.set(d,ie,{shape:"tile",art:"road",w:u.viewW,h:u.laneH,unit:u.laneH*1.28,depth:-20+b*.1});}let g=u.viewH-(u.top+u.laneH*n),f=e.create();e.set(f,Fs,{index:-1}),e.set(f,K,{x:u.viewW/2,y:u.viewH-g/2+1}),e.set(f,ie,{shape:"tile",art:"ground",w:u.viewW,h:g+2,unit:u.laneH*1.2,depth:-21});},Ne=(u,g,f)=>oo(u,g.lane)-g.alt-f/2,se=(u,g,f,b,d)=>{let h=u.laneH,v=9+f;switch(g){case "wall":return {v:{shape:"sprite",art:"obstacle",w:b,h:h*Pt.wall,depth:v},h:h*Pt.wall};case "barrier":return {v:{shape:"sprite",art:"hurdle",w:b,h:h*Pt.barrier,depth:v},h:h*Pt.barrier};case "pit":return {v:{shape:"sprite",art:"pit",w:b,h:h*.42,depth:-19+f*.1+.05},h:-h*.42};case "mover":return {v:{shape:"actor",cast:"foe",h:h*1.5,pose:"run",facing:-1,depth:v},h:h*1.5};case "train":return {v:{shape:"sprite",art:"wagon",w:b,h:h*Pt.train,depth:v},h:h*Pt.train};case "ramp":return {v:{shape:"sprite",art:"ramp",w:b,h:h*Pt.train,depth:v},h:h*Pt.train};case "rock":return {v:{shape:"sprite",art:"shadow",w:b,h:h*.3,alpha:.5,depth:-19+f*.1+.06},h:-h*.3};case "coin":return {v:{shape:"sprite",art:"coin",w:b,h:b,depth:v+.2},h:b};case "power":return {v:{shape:"sprite",art:Rr[d??"magnet"].art,color:Rr[d??"magnet"].color,w:b,h:b,depth:v+.2},h:b};case "finish":return {v:{shape:"sprite",art:"finish",w:h*.7,h:h*n+h*.9,depth:8},h:0}}},ke=(u,g,f,b={})=>{let d=Wt(e,n),h=b.size??(u==="coin"?d.laneH*.42:u==="power"?d.laneH*.62:d.laneH*.85),v=b.alt??(u==="coin"?d.laneH*.5:u==="power"?d.laneH*.6:0),A=e.create();e.set(A,_t,{lane:g,kind:u,size:h,alt:v,...b.power!==void 0?{power:b.power}:{}});let{v:N,h:B}=se(d,u,g,h,b.power),Q=d.viewW+d.laneH+h/2+f,J=u==="finish"?d.top+d.laneH*n/2:B<0?oo(d,g)+B/2+d.laneH*.08:Ne(d,{lane:g,alt:v},B);return e.set(A,K,{x:Q,y:J}),e.set(A,ie,N),u==="coin"&&fe++,A},_e=(u,g,f,b)=>{let d=Wt(e,n);for(let h=0;h<f;h++)ke("coin",u,g+h*d.laneH*.75,b!==void 0?{alt:b}:{});},Te=(u,g)=>{let f=1+Jo(e,"meta:luck");s.chance(Math.min(.9,o("powerRate")*f))&&ke("power",u,g,{power:s.weighted(p,b=>Rr[b].weight)});},Be=u=>m.kinds.includes(u),ee=()=>[...Array(n).keys()],Ie=u=>{let g=["wall",...Be("barrier")?["barrier"]:[],...Be("pit")?["pit"]:[]],f=new Map;for(let h of ee())s.chance(m.density)&&f.set(h,s.pick(g));f.size>=n&&f.delete(s.int(0,n-1));let b=Wt(e,n);for(let[h,v]of f)ke(v,h,u,v==="pit"?{size:b.laneH*1.25}:{});let d=ee().filter(h=>!f.has(h));d.length>0&&s.chance(o("coinRate"))&&_e(s.pick(d),u-b.laneH,3);for(let[h,v]of f)(v==="barrier"||v==="pit")&&s.chance(.5)&&_e(h,u-b.laneH*.75,3,b.laneH*1.3);},nt=()=>{let g=Wt(e,n).laneH,f=d=>d+Math.round(m.density*3),b=[{id:"scatter",weight:3,make:d=>{let h=f(2);for(let v=0;v<h;v++)Ie(v*d);return Te(s.int(0,n-1),h*d-d/2),h*d}},{id:"rest",weight:1,make:d=>{let h=s.int(0,n-1);for(let v=0;v<4;v++)_e(h,v*d*.8,3),h=Math.max(0,Math.min(n-1,h+(s.chance(.5)?1:-1)));return Te(h,4*d*.8),4*d*.8}}];return m.level>=3&&b.push({id:"corridor",weight:2,make:d=>{let h=f(3),v=s.int(0,n-1);for(let A=0;A<h;A++){for(let N of ee())N!==v&&ke("wall",N,A*d);_e(v,A*d-g*.4,2),A%2===1&&(v=Math.max(0,Math.min(n-1,v+(s.chance(.5)?1:-1))));}return h*d}}),(Be("barrier")||Be("pit"))&&b.push({id:"hurdles",weight:2,make:()=>{let d=Math.max(g*3.6,m.speed*o("jumpTime")*1.45),h=2+Math.round(m.density*2),v=[...Be("barrier")?["barrier"]:[],...Be("pit")?["pit"]:[]],A=s.int(0,n-1);for(let N=0;N<h;N++){for(let B of ee()){let Q=s.pick(v);ke(Q,B,N*d,Q==="pit"?{size:g*1.25}:{});}_e(A,N*d-g*.75,3,g*1.3);}return h*d}}),Be("train")&&b.push({id:"train",weight:2,make:d=>{let h=s.int(0,n-1),v=g*s.int(5,8),A=s.chance(.75),N=g*1.4;A&&ke("ramp",h,0,{size:N}),ke("train",h,(A?N:0)+v/2-g*.42,{size:v}),A&&_e(h,N+g*.4,Math.floor(v/(g*.75))-1,g*(Pt.train+.5));let B=ee().filter(J=>J!==h),Q=s.pick(B);if(s.chance(.5))ke("train",Q,d*.5+v/2,{size:v*.8});else for(let J=0;J<2;J++)ke("wall",Q,d*(.5+J*1.4));return (A?N:0)+v+d*.5}}),Be("mover")&&b.push({id:"movers",weight:1.5,make:d=>{let h=1+(s.chance(m.density)?1:0),v=new Set;for(let N=0;N<h;N++){let B=s.int(0,n-1);v.has(B)&&(B=(B+1)%n),v.add(B),ke("mover",B,N*d*1.6,{size:g*.6});}let A=ee().filter(N=>!v.has(N));return A.length>0&&_e(s.pick(A),0,4),h*d*1.6}}),Be("rock")&&b.push({id:"rocks",weight:1.5,make:d=>{let h=2+(s.chance(m.density)?1:0);for(let v=0;v<h;v++){let A=s.int(0,n-1);ke("rock",A,v*d*1.2,{size:g*.9});let N=ee().filter(B=>B!==A);_e(s.pick(N),v*d*1.2,2);}return h*d*1.2}}),b},ht=u=>{let g=Wt(e,n),f=Math.floor(n/2),b=m.fresh;if(b===null||b==="wall")return 0;if(b==="barrier"||b==="pit"){for(let d=0;d<3;d++)ke(b,f,d*u*1.6,b==="pit"?{size:g.laneH*1.25}:{}),_e(f,d*u*1.6-g.laneH*.75,3,g.laneH*1.3);return 3*u*1.6}return b==="train"?(ke("ramp",f,0,{size:g.laneH*1.4}),ke("train",f,g.laneH*1.4+g.laneH*3-g.laneH*.42,{size:g.laneH*6}),_e(f,g.laneH*1.8,7,g.laneH*(Pt.train+.5)),g.laneH*8+u):(ke(b,f,0,{size:b==="mover"?g.laneH*.6:g.laneH*.9}),u*1.5)},Ae=()=>{let u=Math.max(Wt(e,n).laneH*2.1,300-m.density*110),g;if(!ce&&m.fresh!==null&&m.fresh!=="wall")ce=true,g=ht(u);else {let f=nt();g=(C>0&&C%4===3?f.find(d=>d.id==="rest"):s.weighted(f,d=>d.weight)).make(u);}C++,O=Number(e.vars.distance??0)+g+u*1.2;},Gt=(u,g,f)=>{let b=u.laneH*1.05;return {x:u.playerX,y:oo(u,g)-f-b/2,h:b}},Xe=()=>{let u=Wt(e,n);(a===null||!e.isAlive(a))&&(a=e.create(),e.set(a,Xr,{lane:Math.floor(n/2),size:u.laneH*.5,alt:0,vy:0}),e.set(a,ie,{shape:"actor",cast:Le().cast,h:0,pose:"idle",depth:10}));let g=e.need(a,Xr);g.size=u.laneH*.5;let f=Gt(u,g.lane,g.alt);e.set(a,K,{x:f.x,y:f.y});let b=e.need(a,ie);b.shape==="actor"&&(b.cast=Le().cast,b.h=f.h,b.depth=10+g.lane);},rt=()=>{for(let g of e.query(_t))e.destroy(g);It(),m=i(to(Jo(e,"meta:chapter")||1,o("difficulty"))),$=Math.round(m.length*o("lengthScale")),Ce=o("lives")+(Le().perk==="heart"?1:0),e.vars.distance=0,e.vars.meters=0,e.vars.level_length=$,e.vars.runner_length_scale=o("lengthScale"),e.vars.runner_level=m.level,e.vars.speed=m.speed,e.vars.lives=Ce,e.vars.coins=0,e.vars.score=0,e.vars.mult=1,e.vars.stars=0,e.vars.reviving=false,k=0,O=Wt(e,n).laneH*2,C=0,z=false,F=false,ne=false,X=0,ye=0,be=0,fe=0,we=0,de=0,Re=0,Me=0,ce=false,ue.clear();let u=Jo(e,"meta:head_start");if(u>0&&ue.set("dash",u),a!==null&&e.isAlive(a)){let g=e.need(a,Xr);g.lane=Math.floor(n/2),g.alt=0,g.vy=0;}Xe();},lt=u=>{if(!st(e)||Ee()||a===null)return;let g=e.need(a,Xr),f=Math.min(n-1,Math.max(0,g.lane+u));f!==g.lane&&Lt(e,"runner-lanes"),g.lane=f;},ft=()=>{let u=Wt(e,n),g=o("jumpTime");return 8*u.laneH*Pt.jump/(g*g)},yt=(u,g,f)=>{let b=Wt(u,n),d=b.playerX,h=b.laneH*.22,v=0;for(let A of u.query(_t)){let N=u.need(A,_t);if(N.lane!==g||N.kind!=="train"&&N.kind!=="ramp")continue;let B=u.need(A,K),Q=B.x-N.size/2,J=B.x+N.size/2;if(d+h<Q||d-h>J)continue;let $e=b.laneH*Pt.train;if(N.kind==="ramp")v=Math.max(v,$e*Math.max(0,Math.min(1,(d-Q)/N.size)));else if(f>=$e-b.laneH*.12)v=Math.max(v,$e);else return null}return v},ut=()=>{if(!st(e)||Ee()||a===null||ue.has("flight"))return;let u=e.need(a,Xr),g=yt(e,u.lane,u.alt)??0;u.alt-g>2||(u.vy=ft()*o("jumpTime")/2,Re++,Lt(e,"runner-jump"),Bt(e),e.emit("jumped",{}),Fe(e,a,"jump"));},Et=()=>{if(vt(e,"runner-lanes")||a===null)return;let u=Wt(e,n),g=u.playerX+u.laneH*1.6,f=oo(u,Math.floor(n/2))-u.laneH*.4;kt(e,"swipe",{x:g,y:f+u.laneH*.5},{x:g,y:f-u.laneH*.9},u.laneH);},Ze=(u,g,f,b)=>{let d=Pe.get(u);(d===void 0||!e.isAlive(d))&&(d=e.create(),e.set(d,md,{id:u}),Pe.set(u,d)),e.set(d,K,{x:g,y:f}),e.set(d,ie,b);},Ge=u=>{let g=Pe.get(u);g!==void 0&&e.destroy(g),Pe.delete(u);};function It(){for(let u of Pe.values())e.destroy(u);Pe.clear(),dt(e,md);}let Qe=(u,g,f,b,d,h,v,A=41)=>{let N=Math.max(0,Math.min(1,Math.round(h*100)/100));Ze(`${u}:bg`,g,f,{shape:"rect",w:b,h:d,color:"#000000",alpha:.45,radius:d/2,depth:A});let B=Math.max(0,(b-4)*N);B<1?Ge(`${u}:fill`):Ze(`${u}:fill`,g-(b-4)/2+B/2,f,{shape:"rect",w:B,h:d-4,color:v,radius:(d-4)/2,depth:A+.01});},Kt=u=>{let g=Wt(u,n),f=Math.min(g.viewW,g.viewH),b=g.viewH*.085,d=g.viewW*.66,h=Math.max(10,f*.026),v=Number(u.vars.distance??0)/Math.max(1,$);Qe("way",g.viewW/2,b,d,h,v,"accent");let A=f*.055;Ze("flag",g.viewW/2+d/2+A*.45,b-A*.25,{shape:"sprite",art:"flag",w:A,h:A,depth:42}),Ze("lvl",g.viewW/2-d/2-f*.05,b,{shape:"text",text:`${m.level}`,size:Math.round(f*.04),color:"text",bold:true,depth:42});let N=b+f*.07,B=f*.05,Q=Number(u.vars.lives??0);for(let ze=0;ze<Ce;ze++)Ze(`h${ze}`,g.viewW*.07+ze*B*1.1,N,{shape:"sprite",art:"heart",w:B,h:B,alpha:ze<Q?1:.25,depth:42});for(let ze=Ce;ze<10;ze++)Ge(`h${ze}`);let J=f*.045,$e=String(u.vars.coins??0);Ze("coin:i",g.viewW*.93-$e.length*J*.6-J*.7,N,{shape:"sprite",art:"coin",w:J,h:J,depth:42}),Ze("coin",g.viewW*.93-$e.length*J*.6/2,N,{shape:"text",text:$e,size:Math.round(J),color:"text",bold:true,depth:42});let Se=Number(u.vars.mult??1);Se>1?Ze("mult",g.viewW*.9,N+J*1.2,{shape:"text",text:`x${Se}`,size:Math.round(J*1.05),color:"coin",bold:true,depth:42}):Ge("mult");let Ye=f*.055,pt=0;for(let ze of Yo){let le=ue.get(ze);if(le===void 0){Ge(`p:${ze}`),Ge(`pb:${ze}:bg`),Ge(`pb:${ze}:fill`);continue}let V=g.viewW*.07+pt*Ye*1.25,te=N+B*1.25;Ze(`p:${ze}`,V,te,{shape:"sprite",art:Rr[ze].art,color:Rr[ze].color,w:Ye,h:Ye,depth:42}),Qe(`pb:${ze}`,V,te+Ye*.7,Ye,Math.max(6,f*.011),le/Math.max(.1,oe(ze)),"coin",42),pt++;}},Yt=(u,g)=>{if(!st(u)||F)return;F=true;let f=g==="cleared",b=f?1+(fe>0&&we>=fe*m.coinStar?1:0)+(de===0?1:0):0;u.vars.stars=b,f&&u.vars["meta:first_clear"]===true&&Je(u,"coins",m.firstClearGold);let d=ro(Number(u.vars.distance??0));u.vars.score=Me+d*2+(f?500*b:0),u.vars.reviving=false,u.emit(Xt,{reason:g,stats:{chapter:m.level,seconds:Math.floor(X),cleared:f,stars:b,coins:we,meters:d,jumps:Re,hits:de}});},Ft=u=>{if(u.vars.revive_ready===true&&!ne){u.vars.reviving=true,Bt(u),u.emit(tr,{});return}Yt(u,"crashed");},ur=u=>{if(!Ee())return;ne=true,u.vars.reviving=false,u.vars.lives=Math.max(1,Math.ceil(Ce/2)),k=2.5,ue.set("shield",Math.max(ue.get("shield")??0,3));let g=Wt(u,n);for(let f of u.query(_t)){let b=u.need(f,_t);if(b.kind==="coin"||b.kind==="power"||b.kind==="finish")continue;let d=u.need(f,K);d.x-b.size/2<g.playerX+g.laneH*6&&(G(u,{kind:"burst",x:d.x,y:d.y,color:"coin",n:8,size:g.laneH*.6}),u.destroy(f));}if(a!==null){let f=u.need(a,Xr);f.alt=0,f.vy=0,it(u,a,"run");let b=u.need(a,K);G(u,{kind:"ring",x:b.x,y:b.y,color:"coin",size:g.laneH*4});}G(u,{kind:"flash",color:"coin"});},bt=(u,g)=>{if(a===null)return;let f=u.need(g,K),b=Wt(u,n);if(ue.has("dash")){G(u,{kind:"burst",x:f.x,y:f.y,color:"accent",n:14,size:b.laneH*.8}),G(u,{kind:"shake",power:.6}),u.need(g,_t).kind!=="pit"&&u.destroy(g);return}if(k>0)return;if(ue.has("shield")){ue.delete("shield"),k=.8,G(u,{kind:"ring",x:b.playerX,y:u.need(a,K).y,color:"muted",size:b.laneH*2}),u.need(g,_t).kind!=="pit"&&u.destroy(g);return}de++,ye=0,u.vars.mult=1;let d=Number(u.vars.lives??1)-1;u.vars.lives=d,u.emit("player-hit",{lives:d}),G(u,{kind:"burst",x:f.x,y:f.y,color:"danger",n:14,size:b.laneH*.9}),G(u,{kind:"shake",power:1.5}),Fe(u,a,"hit"),u.need(g,_t).kind!=="pit"&&u.destroy(g),k=o("graceTime"),d<=0&&Ft(u);},D=(u,g)=>{let f=u.need(g,_t),b=u.need(g,K),d=Wt(u,n);if(f.kind==="power"&&f.power!==void 0){ue.set(f.power,oe(f.power)),u.emit("power-up",{id:f.power}),G(u,{kind:"ring",x:b.x,y:b.y,color:Rr[f.power].color,size:d.laneH*1.6}),u.destroy(g);return}ye++;let h=Math.min(5,1+Math.floor(ye/12));h>Number(u.vars.mult??1)&&G(u,{kind:"pop",x:d.playerX,y:b.y-d.laneH,text:`x${h}`,color:"coin",size:Math.round(d.laneH*.42)}),u.vars.mult=h;let v=(ue.has("double")?2:1)*(1+Jo(u,"meta:greed"));be+=v;let A=Math.floor(be);be-=A,A>0&&Je(u,"coins",A),we++,Me+=Math.round(v*o("coinScore")*h),u.emit("coin-collected",{value:v}),G(u,{kind:"burst",x:b.x,y:b.y,color:"coin",n:6,size:f.size*1.3}),u.destroy(g);};e.on(Nt,u=>{let g=u;e.vars.started_tick!==e.tick&&(g.type==="swipe"&&(g.dir==="up"||g.dir==="down")?lt(g.dir==="up"?-1:1):g.type==="swipe"&&g.dir==="right"?ut():g.type==="key"&&(g.key==="left"||g.key==="up")?lt(-1):g.type==="key"&&(g.key==="right"||g.key==="down")?lt(1):(g.type==="key"&&g.key==="action"||g.type==="tap")&&ut());}),e.on(Ut,()=>{rt(),a!==null&&it(e,a,"run"),Et();}),e.on(Qt,rt),e.on(rr,()=>ur(e)),e.on(nr,()=>{Ee()&&(e.vars.reviving=false,Yt(e,"crashed"));}),e.on(Zt,u=>{a!==null&&e.isAlive(a)&&it(e,a,u.reason==="cleared"?"dance":"die");for(let g of e.query(_t))e.need(g,_t).kind==="mover"&&it(e,g,"idle");It();}),e.on(qt,()=>{tt(),a!==null&&Xe();let u=Wt(e,n);for(let g of e.query(_t)){let f=e.need(g,_t),{v:b,h:d}=se(u,f.kind,f.lane,f.size,f.power);e.set(g,ie,b),e.need(g,K).y=f.kind==="finish"?u.top+u.laneH*n/2:d<0?oo(u,f.lane)+d/2+u.laneH*.08:Ne(u,f,d);}}),e.addSystem({id:"lane-runner",order:0,run(u,g){if(!st(u)||a===null||F||Ee())return;let f=Wt(u,n),b=f.laneH;X+=g;let d=Number(u.vars.distance??0),v=(m.speed+(m.topSpeed-m.speed)*Math.min(1,d/Math.max(1,$)))*(ue.has("dash")?1.6:1);u.vars.speed=Math.round(v);let A=v*g;u.vars.distance=d+A,u.vars.meters=ro(d+A),k>0&&(k=Math.max(0,k-g));for(let[le,V]of [...ue])V-g<=0?(ue.delete(le),le==="flight"&&(k=Math.max(k,.8))):ue.set(le,V-g);Zo(u,A);for(let le of u.query(Fs)){let V=u.need(le,ie);V.shape==="tile"&&(V.scrollX=(V.scrollX??0)+A);}let N=$-(d+A);if(!z&&N<=f.viewW-f.playerX+b){z=true;let le=ke("finish",0,0);u.need(le,K).x=f.playerX+N;}else !z&&d>=O&&N>f.viewW&&Ae();let B=u.need(a,Xr),Q=ue.has("flight");if(Q)B.alt+=(b*Pt.flight-B.alt)*Math.min(1,g*6),B.vy=0,Math.floor((d+A)/(b*.9))!==Math.floor(d/(b*.9))&&ke("coin",B.lane,0,{alt:b*(Pt.flight+.4)});else {B.vy-=ft()*g,B.alt+=B.vy*g;let le=yt(u,B.lane,B.alt);if(le===null){let V=u.query(_t).find(te=>{let Y=u.need(te,_t);return Y.lane===B.lane&&Y.kind==="train"&&Math.abs(u.need(te,K).x-f.playerX)<Y.size/2+b*.22});if(V!==void 0&&bt(u,V),F||Ee())return;B.alt=Math.max(0,B.alt);}else B.alt<=le&&(B.alt=le,B.vy=0);}let J=u.need(a,K),$e=Gt(f,B.lane,B.alt);J.y+=($e.y-J.y)*Math.min(1,g*14),J.x=$e.x;let Se=u.need(a,ie);Se.shape==="actor"&&(Se.alpha=k>0&&Math.floor(u.time*12)%2===0?.35:1,Se.depth=10+B.lane+.5,Se.speed=v,Se.pose=B.alt>2&&B.vy!==0?"air":"run");let Ye=b*.24,pt=ue.has("magnet"),ze=B.alt+b*.5;for(let le of u.query(_t)){if(!u.isAlive(le)||!u.has(le,_t))continue;let V=u.need(le,_t),te=u.need(le,K);if(te.x-=A,V.kind==="mover"){if(te.x-=v*.35*g,V.to===void 0&&te.x-f.playerX<b*6&&te.x-f.playerX>b*3){let S=[V.lane-1,V.lane+1].filter(l=>l>=0&&l<n);V.to=B.lane!==V.lane&&S.includes(B.lane)?B.lane:s.pick(S),V.warn=.45;}if(V.warn!==void 0&&V.warn>0){V.warn-=g;let S=u.need(le,ie);S.alpha=Math.floor(u.time*14)%2===0?.4:1,V.warn<=0&&V.to!==void 0&&(V.lane=V.to,S.alpha=1,S.depth=9+V.lane);}te.y+=(Ne(f,V,b*1.5)-te.y)*Math.min(1,g*10);}if(V.kind==="rock"&&!V.landed&&te.x-f.playerX<b*2.6&&(V.landed=true,u.set(le,ie,{shape:"sprite",art:"rock",w:V.size,h:b*Pt.rock,depth:9+V.lane}),te.y=oo(f,V.lane)-b*Pt.rock/2,G(u,{kind:"burst",x:te.x,y:te.y+b*.4,color:"muted",n:10,size:b*.7}),G(u,{kind:"shake",power:.5})),V.kind==="rock"&&!V.landed){let S=u.need(le,ie);S.shape==="sprite"&&(S.alpha=.35+.3*Math.abs(Math.sin(u.time*6)));}if(V.kind==="power"&&(te.y=Ne(f,V,V.size)+Math.sin(u.time*4+te.x*.01)*b*.06),te.x+V.size/2<-b*2){u.destroy(le);continue}if(V.kind==="finish"){if(te.x<=f.playerX){G(u,{kind:"flash",color:"coin"}),Yt(u,"cleared");return}continue}if(V.kind==="coin"&&pt&&te.x>f.playerX-b*.5&&te.x<f.playerX+b*4&&(V.pulled=true),V.kind==="coin"&&V.pulled){te.x+=(f.playerX-te.x)*Math.min(1,g*10),te.y+=(J.y-te.y)*Math.min(1,g*10),Math.hypot(te.x-f.playerX,te.y-J.y)<b*.4&&D(u,le);continue}let Y=V.kind==="barrier"?V.size*.3:V.size/2;if(Math.abs(te.x-f.playerX)>Ye+Y||V.lane!==B.lane)continue;if(V.kind==="coin"||V.kind==="power"){(Math.abs(V.alt-ze)<b*.6||Q)&&D(u,le);continue}if(Q||V.kind==="ramp"||V.kind==="train"||V.kind==="rock"&&!V.landed)continue;let w=V.kind==="wall"?Pt.wall:V.kind==="barrier"?Pt.barrier*.85:V.kind==="mover"?Pt.mover:V.kind==="rock"?Pt.rock:0;if(V.kind==="pit"?B.alt<2&&Math.abs(te.x-f.playerX)<V.size*.32&&bt(u,le):B.alt<b*w&&bt(u,le),F||Ee())return}vt(u,"runner-jump")||u.query(_t).find(V=>{let te=u.need(V,_t),Y=u.need(V,K).x-f.playerX;return (te.kind==="barrier"||te.kind==="pit")&&te.lane===B.lane&&Y>b*1.5&&Y<b*3.2})!==void 0&&!_r(u)&&kt(u,"tap",{x:f.playerX+b*1.2,y:J.y}),u.vars.score=Me+ro(d+A)*2,Kt(u);}}),tt(),rt();}};var Rn=[{id:"rainbow",shape:"color",art:"m3_rainbow",make:e=>e>=5},{id:"bomb",shape:"area:1",art:"m3_bomb",make:(e,t)=>t},{id:"col",shape:"col",art:"m3_col",make:(e,t,r)=>e===4&&r==="h"},{id:"row",shape:"row",art:"m3_row",make:(e,t,r)=>e===4&&r==="v"}],yd=[{a:"row",b:"row",effect:"cross"},{a:"col",b:"col",effect:"cross"},{a:"row",b:"col",effect:"cross"},{a:"bomb",b:"row",effect:"cross:1"},{a:"bomb",b:"col",effect:"cross:1"},{a:"bomb",b:"bomb",effect:"area:2"},{a:"rainbow",b:"plain",effect:"color"},{a:"rainbow",b:"row",effect:"turn"},{a:"rainbow",b:"col",effect:"turn"},{a:"rainbow",b:"bomb",effect:"turn"},{a:"rainbow",b:"rainbow",effect:"all"}],Zr={ice:{id:"ice",layer:"under",hp:1,art:"m3_ice",max:20},slime:{id:"slime",layer:"under",hp:1,art:"m3_slime",spreads:true,max:16},chain:{id:"chain",layer:"over",hp:1,art:"m3_chain",max:10},stone:{id:"stone",layer:"block",hp:1,art:"m3_stone",hitByNear:true,max:10},cage:{id:"cage",layer:"block",hp:1,art:"m3_cage",hitByNear:true}},Gi={"-":{},".":{hole:true},i:{under:{id:"ice",hp:1}},I:{under:{id:"ice",hp:2}},m:{under:{id:"slime",hp:1}},c:{over:{id:"chain",hp:1}},s:{block:{id:"stone",hp:1}},S:{block:{id:"stone",hp:2}},g:{block:{id:"cage",hp:1}}},rs={fire:{beats:["nature"],color:"piece1"},water:{beats:["fire"],color:"piece2"},nature:{beats:["water"],color:"piece3"},light:{beats:["dark"],color:"piece4"},dark:{beats:["light"],color:"piece5"}},Ki=[{index:0,art:"gem1",color:"piece1",role:"attack",element:"fire"},{index:1,art:"gem2",color:"piece2",role:"attack",element:"water"},{index:2,art:"gem3",color:"piece3",role:"attack",element:"nature"},{index:3,art:"gem4",color:"piece4",role:"attack",element:"light"},{index:4,art:"gem5",color:"piece5",role:"attack",element:"dark"},{index:5,art:"m3_heart",color:"danger",role:"heal"},{index:6,art:"m3_shield",color:"primary",role:"shield"},{index:7,art:"gem6",color:"piece6",role:"attack"}],ns=e=>Ki.find(t=>t.index===e),Fi=[{id:"goblin",cast:"foe5",element:"nature",hp:1,attack:1,every:3,size:.8},{id:"wolf",cast:"foe",element:"nature",hp:.8,attack:.7,every:2,size:.85},{id:"orc",cast:"foe",variant:5,element:"fire",hp:1.4,attack:1.3,every:3,skill:{kind:"sow",obstacle:"stone",count:2},size:.95},{id:"frost-imp",cast:"foe3",element:"water",hp:1,attack:.9,every:3,skill:{kind:"sow",obstacle:"ice",count:3},size:.85},{id:"spider",cast:"foe4",element:"dark",hp:1.1,attack:1,every:3,skill:{kind:"sow",obstacle:"chain",count:3},size:.85},{id:"golem",cast:"foe2",element:"light",hp:2,attack:1.5,every:4,skill:{kind:"sow",obstacle:"stone",count:3},size:1.05},{id:"slime-beast",cast:"foe2",variant:9,element:"water",hp:1.3,attack:1.1,every:3,skill:{kind:"sow",obstacle:"slime",count:2},size:.95},{id:"shaman",cast:"foe4",variant:7,element:"dark",hp:1,attack:.9,every:3,skill:{kind:"heal",share:.15},size:.9},{id:"troll",cast:"boss",element:"nature",hp:3,attack:1.6,every:3,skill:{kind:"sow",obstacle:"stone",count:3},boss:true,enrage:.5,size:1.2},{id:"frost-queen",cast:"boss",variant:4,element:"water",hp:3.5,attack:1.5,every:3,skill:{kind:"sow",obstacle:"ice",count:5},boss:true,enrage:.5,size:1.2},{id:"spider-queen",cast:"boss",variant:9,element:"dark",hp:4,attack:1.7,every:3,skill:{kind:"sow",obstacle:"chain",count:4},boss:true,enrage:.5,size:1.2},{id:"lich",cast:"boss",variant:13,element:"dark",hp:4.5,attack:1.8,every:3,skill:{kind:"sow",obstacle:"slime",count:3},boss:true,enrage:.5,size:1.25}],os=e=>Fi.find(t=>t.id===e),Us=100,gd=4,bd=1.5,xd=2,kd=1,qi=[{id:"blast",art:"m3_skill_blast",mana:30,kind:"shape",shape:"area:1",bigShape:"area:2",bigAt:1.5,damage:6},{id:"cross",art:"m3_skill_cross",mana:28,kind:"shape",shape:"cross",bigShape:"cross:1",bigAt:1.5,damage:5},{id:"storm",art:"m3_skill_storm",mana:34,kind:"storm",count:4,damage:4}],Xs=e=>qi.find(t=>t.id===e),so=[{id:"hero",cast:"hero",gems:0,element:"fire",skill:"blast"},{id:"hero2",cast:"hero2",gems:150,element:"light",skill:"cross"},{id:"hero3",cast:"hero3",gems:300,element:"water",skill:"storm"}],Zs={plain:["--------","--------","--------","--------","--------","--------","--------","--------"],diamond:["..----..",".------.","--------","--------","--------","--------",".------.","..----.."],"ice-mid":["--------","--------","--iiii--","--iiii--","--iiii--","--iiii--","--------","--------"],"ice-low":["--------","--------","--------","--------","iiiiiiii","iiiiiiii","IIIIIIII","IIIIIIII"],stones:["--------","--------","--------","ss-ss-ss","--------","--------","--------","--------"],chains:["--------","-c----c-","--c--c--","---cc---","---cc---","--c--c--","-c----c-","--------"],cages:["--------","-g----g-","--------","---gg---","--------","--------","-g----g-","--------"],slime:["--------","--------","--------","--------","--------","--------","mm----mm","mmm--mmm"],hourglass:["--------","--------",".------.","..----..","..----..",".------.","--------","--------"],ring:["--------","--------","--------","---..---","---..---","--------","--------","--------"],"ice-stone":["--------","-S----S-","--IIII--","--IIII--","--IIII--","--IIII--","-S----S-","--------"],fortress:["s------s","-iiiiii-","-i-cc-i-","-ic--ci-","-ic--ci-","-i-cc-i-","-iiiiii-","s------s"],"slime-cages":["-g----g-","--------","--------","---mm---","---mm---","--------","--------","-g----g-"],"cross-holes":["---..---","--------","--------",".------.",".------.","--------","--------","---..---"]},$t=(e,t,r,o,n)=>({kind:"goal",board:e,moves:t,colors:r,goals:o,...n?{drops:n}:{}}),or=(e,t,...r)=>({kind:"battle",board:e,elements:t,enemies:r}),xr=(e,t)=>({kind:"color",color:e,count:t}),Rt=e=>({kind:"clear",obstacle:e}),es=e=>({kind:"drops",count:e}),Qs=[$t("plain",20,5,[xr(0,12),xr(1,12)]),$t("diamond",20,5,[xr(2,15),xr(3,15)]),or("plain",3,"goblin"),$t("ice-mid",22,5,[Rt("ice")]),$t("ring",20,5,[xr(0,20),xr(4,20)]),or("plain",3,"goblin","wolf"),$t("stones",22,5,[Rt("stone"),xr(1,15)]),$t("ice-low",25,5,[Rt("ice")]),or("diamond",3,"wolf","orc"),or("plain",3,"troll"),$t("chains",24,5,[Rt("chain")]),$t("plain",25,5,[es(3)],3),or("plain",4,"frost-imp","goblin"),$t("cages",22,5,[Rt("cage")]),$t("slime",25,5,[Rt("slime")]),or("ice-mid",4,"orc","frost-imp"),$t("hourglass",24,5,[es(3),xr(2,20)],3),$t("ice-low",26,5,[Rt("ice")]),or("plain",4,"spider","frost-imp","wolf"),or("plain",4,"frost-queen"),$t("ice-stone",26,5,[Rt("ice"),Rt("stone")]),$t("cross-holes",26,6,[xr(0,20),xr(3,20)]),or("chains",4,"spider","golem"),$t("fortress",28,5,[Rt("ice"),Rt("chain")]),$t("slime-cages",26,5,[Rt("cage"),Rt("slime")]),or("plain",4,"slime-beast","golem"),$t("diamond",28,5,[es(3)],3),$t("ice-low",28,5,[Rt("ice"),xr(4,20)]),or("ring",5,"shaman","golem","spider"),or("plain",5,"spider-queen"),$t("fortress",28,6,[Rt("ice"),Rt("chain")]),$t("slime",28,5,[Rt("slime"),es(3)],3),or("ice-stone",5,"golem","shaman"),$t("ice-stone",28,6,[Rt("ice"),Rt("stone")]),$t("slime-cages",28,6,[Rt("cage"),Rt("slime")]),or("plain",5,"slime-beast","shaman","orc"),$t("cross-holes",30,5,[es(3),xr(1,18)],3),$t("fortress",32,5,[Rt("ice"),Rt("chain"),xr(2,15)]),or("diamond",5,"golem","shaman","spider"),or("plain",5,"lich")],ts=10,vd=4,Ys=Qs.length,Ui=[0,18,45,75];function Hh(e){return e.kind==="goal"?[0,1,2,3,4,7].slice(0,Math.max(3,Math.min(6,e.colors))):[...[0,1,2,3,4].slice(0,Math.max(2,Math.min(5,e.elements))),5,6]}function ao(e,t=.5){let r=Math.max(1,Math.min(Ys,Math.floor(e))),o=Qs[r-1],n=Math.ceil(r/ts),s=o.kind==="battle"&&o.enemies.some(a=>os(a)?.boss);return {level:r,world:n,index:r-(n-1)*ts,def:o,boss:s,colors:Hh(o),enemyHp:180*Math.pow(1.07,r-1)*(.8+t*.4),enemyAttack:14*Math.pow(1.06,r-1)*(.8+t*.4),firstClearGold:(s?120:50)+(r-1)*10}}var Xi=e=>Ui[Math.ceil(Math.max(1,e)/ts)-1]??0,Zi=(e,t)=>t?e>=.7?3:e>=.35?2:1:e>=.3?3:e>=.1?2:1,$d=5,Md=.5,Qi="kit-match3",Yi=[{id:"Attack",var:"meta:attack",art:"m3_skill_blast",color:"danger",perLevel:5,unit:"%",maxLevel:20,price:40,growth:.12},{id:"Health",var:"meta:health",art:"m3_heart",color:"danger",perLevel:6,unit:"%",maxLevel:20,price:40,growth:.12},{id:"Defense",var:"meta:defense",art:"m3_shield",color:"primary",perLevel:5,unit:"%",maxLevel:15,price:45,growth:.12},{id:"SkillPower",var:"meta:skill",art:"m3_skill_cross",color:"secondary",perLevel:8,unit:"%",maxLevel:10,price:50,growth:.12},{id:"ManaGain",var:"meta:mana",art:"m3_skill_storm",color:"secondary",perLevel:5,unit:"%",maxLevel:10,price:50,growth:.12},{id:"Moves",var:"meta:moves",art:"m3_bomb",color:"coin",perLevel:1,unit:"",maxLevel:5,price:120,growth:.2}],wd={game:"match3",character:Qi,stats:Yi,heroes:so,levels:Ys,firstClearGold:e=>ao(e).firstClearGold,stars:3,starsToEnter:Xi};var tl=()=>({cleared:[],created:[],fired:[],hits:[],spawned:[],dropsCollected:0,slimeCleared:false}),rl=-1,Qr=-2,ta=(e,t,r)=>t>=0&&r>=0&&t<e.cols&&r<e.rows,mn=(e,t,r)=>ta(e,t,r)?e.cells[r][t]:null,ra=(e,t)=>t[Math.floor(e.rnd()*t.length)%t.length],Ed=[[1,0],[-1,0],[0,1],[0,-1]],Ji=e=>e.hole||e.block!==null||e.over!==null,Wh=e=>e!==null&&e.color>=0;function na(e,t,r,o,n=0){let s={cols:e[0].length,rows:e.length,cells:e.map(a=>[...a].map(i=>{let p=o[i]??{};return {hole:p.hole===true,piece:null,under:p.under?{...p.under}:null,over:p.over?{...p.over}:null,block:p.block?{...p.block}:null}})),colors:t,nextId:1,dropsToSpawn:n,rnd:r};return el(s),s}var ea=(e,t,r=null)=>({id:e.nextId++,color:t,special:r});function el(e){for(let t=0;t<50;t++){for(let r=0;r<e.rows;r++)for(let o=0;o<e.cols;o++){let n=e.cells[r][o];if(n.hole||n.block||n.piece&&n.piece.color<0||n.piece?.special)continue;let s=new Set,a=mn(e,o-1,r)?.piece,i=mn(e,o-2,r)?.piece;a&&i&&a.color>=0&&a.color===i.color&&s.add(a.color);let p=mn(e,o,r-1)?.piece,m=mn(e,o,r-2)?.piece;p&&m&&p.color>=0&&p.color===m.color&&s.add(p.color);let $=e.colors.filter(O=>!s.has(O)),k=ra(e,$.length>0?$:e.colors);n.piece?n.piece.color=k:n.piece=ea(e,k);}if(io(oa(e)).size===0&&lo(e)!==null)return}}function nl(e){for(let t=0;t<e.rows;t++)for(let r=0;r<e.cols;r++){let o=e.cells[t][r].piece;o&&o.color>=0&&!o.special&&!e.cells[t][r].over&&(o.color=-100);}for(let t=0;t<e.rows;t++)for(let r=0;r<e.cols;r++)e.cells[t][r].piece?.color===-100&&(e.cells[t][r].piece.color=ra(e,e.colors));if(el(e),lo(e)===null){for(let t of e.cells)for(let r of t)r.over=null;el(e);}}var oa=e=>e.cells.map(t=>t.map(r=>r.piece&&r.piece.color>=0&&!r.block?r.piece.color:null));function io(e){let t=new Set;for(let r of Sd(e))for(let[o,n]of r.cells)t.add(`${o},${n}`);return t}function Sd(e){let t=[],r=e.length,o=e[0]?.length??0;for(let n=0;n<r;n++)for(let s=0;s<o;){let a=e[n][s],i=1;for(;a!=null&&s+i<o&&e[n][s+i]===a;)i++;a!=null&&i>=3&&t.push({cells:Array.from({length:i},(p,m)=>[s+m,n]),dir:"h"}),s+=i;}for(let n=0;n<o;n++)for(let s=0;s<r;){let a=e[s][n],i=1;for(;a!=null&&s+i<r&&e[s+i][n]===a;)i++;a!=null&&i>=3&&t.push({cells:Array.from({length:i},(p,m)=>[n,s+m]),dir:"v"}),s+=i;}return t}function ol(e){return jh(e)!==null}function jh(e){let t=e.length,r=e[0]?.length??0,o=(n,s)=>{let a=e[n[1]][n[0]];e[n[1]][n[0]]=e[s[1]][s[0]],e[s[1]][s[0]]=a;};for(let n=0;n<t;n++)for(let s=0;s<r;s++)for(let[a,i]of [[1,0],[0,1]]){if(s+a>=r||n+i>=t||e[n][s]===null||e[n+i][s+a]===null)continue;o([s,n],[s+a,n+i]);let p=io(e).size>0;if(o([s,n],[s+a,n+i]),p)return [[s,n],[s+a,n+i]]}return null}function ss(e,t,r){if(Math.abs(t.col-r.col)+Math.abs(t.row-r.row)!==1)return false;let o=mn(e,t.col,t.row),n=mn(e,r.col,r.row);if(!o||!n)return false;for(let s of [o,n])if(s.hole||s.block||s.over||!s.piece)return false;return true}function lo(e){let t=oa(e);for(let r=0;r<e.rows;r++)for(let o=0;o<e.cols;o++)for(let[n,s]of [[1,0],[0,1]]){let a={col:o,row:r},i={col:o+n,row:r+s};if(!ss(e,a,i))continue;let p=e.cells[r][o].piece,m=e.cells[i.row][i.col].piece;if(p.color===Qr&&m.color===Qr)continue;if(p.special==="rainbow"||m.special==="rainbow")return [a,i];if(p.special&&m.special)return [a,i];let $=t[r][o];t[r][o]=t[i.row][i.col],t[i.row][i.col]=$;let k=io(t).size>0;if(t[i.row][i.col]=t[r][o],t[r][o]=$,k)return [a,i]}return null}function sl(e){let t=new Map;for(let r=0;r<e.rows;r++)for(let o=0;o<e.cols;o++){let n=e.cells[r][o].piece;n&&t.set(n.id,{col:o,row:r,piece:n});}return t}function sa(e,t){let r=0;for(let o of e.cells)for(let n of o)for(let s of [n.under,n.over,n.block])s?.id===t&&r++;return r}function al(e,t,r){if(!ss(e,t,r))return null;let o=e.cells[t.row][t.col],n=e.cells[r.row][r.col],s=o.piece,a=n.piece;if(s.special==="rainbow"||a.special==="rainbow"||s.special&&a.special){o.piece=a,n.piece=s;let p=tl();return Fh(e,p,r,s,t,a),fl(e,p),p}o.piece=a,n.piece=s;let i=Ld(e,[t,r]);return i||(o.piece=s,n.piece=a,null)}function aa(e){return Ld(e,[])}function ia(e,t,r="skill"){let o=tl(),n=t.filter(s=>ta(e,s.col,s.row)).map(s=>({...s,match:false}));return t[0]&&o.fired.push({...t[0],kind:r}),cl(e,o,n),fl(e,o),o}function il(e,t){let r=[];if(t)return r;let o=Object.values(Zr).filter(n=>n.spreads);for(let n of o){let s=[];for(let p=0;p<e.rows;p++)for(let m=0;m<e.cols;m++)e.cells[p][m].under?.id===n.id&&s.push({col:m,row:p});if(s.length===0)continue;let a=[];for(let p of s)for(let[m,$]of Ed){let k=mn(e,p.col+m,p.row+$);k&&!k.hole&&!k.block&&!k.under&&a.push({col:p.col+m,row:p.row+$});}if(a.length===0)continue;let i=ra(e,a);e.cells[i.row][i.col].under={id:n.id,hp:1},r.push(i);}return r}function ll(e,t,r){let o=Zr[t];if(!o)return [];let n=[];for(let i=0;i<e.rows;i++)for(let p=0;p<e.cols;p++){let m=e.cells[i][p];m.hole||m.block||!m.piece||m.piece.color<0||m.piece.special||o.layer==="under"&&m.under||o.layer==="over"&&m.over||n.push({col:p,row:i});}let s=[],a=o.max===void 0?r:Math.max(0,o.max-sa(e,t));for(let i=0;i<Math.min(r,a)&&n.length>0;i++){let p=Math.floor(e.rnd()*n.length)%n.length,m=n.splice(p,1)[0],$=e.cells[m.row][m.col],k={id:t,hp:o.hp};o.layer==="under"?$.under=k:o.layer==="over"?$.over=k:($.block=k,$.piece=null),s.push(m);}return s}function la(e,t,r){let o=[];for(let s=0;s<e.rows;s++)for(let a=0;a<e.cols;a++){let i=e.cells[s][a].piece;i&&i.color>=0&&!i.special&&!e.cells[s][a].over&&o.push({col:a,row:s});}let n=[];for(let s=0;s<r&&o.length>0;s++){let a=o.splice(Math.floor(e.rnd()*o.length)%o.length,1)[0];e.cells[a.row][a.col].piece.special=e.rnd()<.5?"row":"col",n.push(a);}return n}function Ld(e,t){let r=Sd(oa(e));if(r.length===0)return null;let o=tl(),n=[];for(let i of r){let p=new Set(i.cells.map(([k,O])=>`${k},${O}`)),m=n.filter(k=>k.some(O=>O.cells.some(([C,z])=>p.has(`${C},${z}`)))),$=[i,...m.flat()];for(let k of m)n.splice(n.indexOf(k),1);n.push($);}let s=[],a=[];for(let i of n){let p=new Map;for(let O of i)for(let[C,z]of O.cells)p.set(`${C},${z}`,{col:C,row:z});let m=i.reduce((O,C)=>Math.max(O,C.cells.length),0),$=i.some(O=>O.dir==="h")&&i.some(O=>O.dir==="v"),k=Rn.filter(O=>O.make!==null).find(O=>O.make(m,$,i.find(C=>C.cells.length===m).dir));if(k){let O=t.find(z=>p.has(`${z.col},${z.row}`))??($?Vh(i):null)??Gh(i.find(z=>z.cells.length===m)),C=e.cells[O.row][O.col].piece?.color??0;a.push({at:O,special:k.id,color:C});}for(let O of p.values())s.push({...O,match:true});}cl(e,o,s);for(let i of a){let p=e.cells[i.at.row][i.at.col];p.piece||p.block||p.hole||(p.piece=ea(e,i.special==="rainbow"?rl:i.color,i.special),o.created.push({...i.at,piece:p.piece}));}return fl(e,o),o}function Vh(e){let t=new Set;for(let r of e)for(let[o,n]of r.cells){let s=`${o},${n}`;if(t.has(s))return {col:o,row:n};t.add(s);}return null}var Gh=e=>{let[t,r]=e.cells[Math.floor(e.cells.length/2)];return {col:t,row:r}};function cl(e,t,r){let o=new Set,n=new Set;for(;r.length>0;){let s=r.shift(),a=`${s.col},${s.row}`;if(!ta(e,s.col,s.row))continue;let i=e.cells[s.row][s.col];if(i.hole)continue;if(i.block){!s.match&&!n.has(a)&&(n.add(a),Js(t,i,"block",s));continue}if(o.has(a))continue;o.add(a);let p=i.piece;if(p){if(i.over){Js(t,i,"over",s);continue}if(p.color!==Qr){if(i.piece=null,t.cleared.push({...s,piece:p}),i.under&&(i.under.id==="slime"&&(t.slimeCleared=true),Js(t,i,"under",s)),s.match)for(let[m,$]of Ed){let k=mn(e,s.col+m,s.row+$),O=`${s.col+m},${s.row+$}`;k?.block&&!n.has(O)&&Zr[k.block.id]?.hitByNear&&(n.add(O),Js(t,k,"block",{col:s.col+m,row:s.row+$}));}p.special&&Kh(e,t,p.special,s,p.color,r);}}}}function Js(e,t,r,o){let n=t[r];n.hp-=1,e.hits.push({...o,id:n.id,hp:Math.max(0,n.hp)}),n.hp<=0&&(t[r]=null);}function Kh(e,t,r,o,n,s){t.fired.push({...o,kind:r});let i=Rn.find(p=>p.id===r)?.shape??r;for(let p of dl(e,i,o,n))s.push({...p,match:false});}var ca=(e,t,r)=>dl(e,t,r,-1);function dl(e,t,r,o){let n=[],s=i=>{for(let p=0;p<e.cols;p++)n.push({col:p,row:i});},a=i=>{for(let p=0;p<e.rows;p++)n.push({col:i,row:p});};if(t==="row")s(r.row);else if(t==="col")a(r.col);else if(t==="cross")s(r.row),a(r.col);else if(t.startsWith("cross:")){let i=Number(t.slice(6));for(let p=-i;p<=i;p++)s(r.row+p),a(r.col+p);}else if(t.startsWith("area:")){let i=Number(t.slice(5));for(let p=-i;p<=i;p++)for(let m=-i;m<=i;m++)n.push({col:r.col+m,row:r.row+p});}else if(t==="color"){let i=o>=0?o:_d(e);for(let p=0;p<e.rows;p++)for(let m=0;m<e.cols;m++)e.cells[p][m].piece?.color===i&&n.push({col:m,row:p});}else if(t==="all")for(let i=0;i<e.rows;i++)s(i);return n.filter(i=>ta(e,i.col,i.row))}function _d(e){let t=new Map;for(let n of e.cells)for(let s of n)Wh(s.piece)&&!s.block&&t.set(s.piece.color,(t.get(s.piece.color)??0)+1);let r=e.colors[0]??0,o=-1;for(let[n,s]of t)s>o&&(o=s,r=n);return r}function Fh(e,t,r,o,n,s){let a=[],i=o.special??"plain",p=s.special??"plain",m=yd.find(k=>k.a===i&&k.b===p||k.a===p&&k.b===i);e.cells[r.row][r.col].piece=null,e.cells[n.row][n.col].piece=null,t.cleared.push({...r,piece:o},{...n,piece:s}),t.fired.push({...n,kind:m?.effect??"combo"});let $=i==="rainbow"?s:o;if(m?.effect==="color"||m?.effect==="turn"){let k=$.color>=0?$.color:_d(e);for(let O=0;O<e.rows;O++)for(let C=0;C<e.cols;C++){let z=e.cells[O][C].piece;z?.color===k&&(m.effect==="turn"&&$.special&&$.special!=="rainbow"&&(z.special=$.special==="row"||$.special==="col"?e.rnd()<.5?"row":"col":$.special),a.push({col:C,row:O,match:false}));}}else for(let k of dl(e,m?.effect??"cross",n,$.color))a.push({...k,match:false});cl(e,t,a);}function fl(e,t){for(let r=0;r<4;r++){for(let n=0;n<e.cols;n++){let s=e.rows-1;for(;s>=0;){if(Ji(e.cells[s][n])){s--;continue}let a=s;for(;a-1>=0&&!Ji(e.cells[a-1][n]);)a--;let i=[];for(let $=s;$>=a;$--){let k=e.cells[$][n].piece;k&&i.push(k);}let p=s;for(let $ of i)e.cells[p--][n].piece=$;let m=-1;for(;p>=a;p--){let $=a===qh(e,n)&&e.dropsToSpawn>0&&Xh(e)<2&&e.rnd()<.35,k=$?ea(e,Qr):ea(e,ra(e,e.colors));$&&e.dropsToSpawn--,e.cells[p][n].piece=k,t.spawned.push({col:n,row:p,piece:k,from:a+m--});}s=a-1;}}let o=false;for(let n=0;n<e.cols;n++){let s=Uh(e,n);if(s<0)continue;let a=e.cells[s][n];a.piece?.color===Qr&&(a.piece=null,t.dropsCollected++,o=true);}if(!o)break}}var qh=(e,t)=>{for(let r=0;r<e.rows;r++)if(!Ji(e.cells[r][t]))return r;return -1},Uh=(e,t)=>{for(let r=e.rows-1;r>=0;r--)if(!e.cells[r][t].hole)return e.cells[r][t].block?-1:r;return -1},Xh=e=>{let t=0;for(let r of e.cells)for(let o of r)o.piece?.color===Qr&&t++;return t};var Zh="boss-spawned",Qh="boss-defeated",yn=ve("match3.gem"),Rd=ve("match3.overlay"),pl=ve("match3.layer"),Ad=ve("match3.backdrop"),Td=ve("match3.part"),Yr=(e,t)=>{let r=Number(e.vars[t]??0);return Number.isFinite(r)?r:0},da={id:"match3",version:2,engines:["phaser"],requires:["round"],params:{difficulty:{type:"number",default:.5,min:0,max:1},pieceScore:{type:"number",default:10,min:1,max:1e3,integer:true},coinEvery:{type:"number",default:8,min:1,max:100,integer:true},moveBonus:{type:"number",default:100,min:0,max:1e4,integer:true}},setup({world:e,params:t}){let r=w=>yr(t,w),o=e.rng.stream("match3"),n=ao(1,r("difficulty")),s=na(Zs.plain,[0,1,2,3,4],()=>o.next(),Gi),a=Gt(),i="idle",p=new Map,m=new Map,$=null,k=null,O=null,C=null,z=0,F=false,ne=0,X=0,ye=0,be=0,fe=0,we=false,de=false,Re={colors:new Map,drops:0},Ce=Us,Me=Us,ce=0,ue=0,Pe=false,Le=[],oe=null,Ee=0,tt=0,Ne=0,se=null,ke=[],_e=new Map,Te=()=>so.find(w=>w.id===e.vars["meta:hero"])??so[0],Be=()=>Xs(Te().skill),ee=()=>n.def.kind==="battle",Ie=()=>e.vars.reviving===true,nt=()=>gd*Math.pow(1.06,n.level-1)*(1+Yr(e,"meta:attack")),ht=()=>1+Yr(e,"meta:skill"),Ae=()=>Be().mana;function Gt(){return un(He(e),s.cols,s.rows,{top:.33,bottom:.96,widthShare:.94})}let Xe=()=>a.cell,rt=new Set,lt=(w,S,l,E,T=1)=>{rt.add(w);let c=_e.get(w);(c===void 0||!e.isAlive(c))&&(c=e.create(),e.set(c,Td,{id:w}),_e.set(w,c)),e.set(c,K,{x:S,y:l,scale:T}),e.set(c,ie,E);},ft=w=>{for(let[S,l]of [..._e])S.startsWith(w)&&(e.destroy(l),_e.delete(S));},yt=w=>{let S=Xe();if(w===rl)return {shape:"sprite",art:"m3_rainbow",w:S*.9,h:S*.9,depth:3};if(w===Qr)return {shape:"sprite",art:"m3_crate",w:S*.86,h:S*.86,depth:3};let l=ns(w);return {shape:"sprite",art:l?.art??"gem1",w:S*.88,h:S*.88,color:l?.color??"piece1",depth:3}},ut=(w,S,l,E,T)=>{let c=at(a,S,T),y=e.create();return e.set(y,yn,{id:w,col:S,row:l,kind:E}),e.set(y,K,{x:c.x,y:c.y}),e.set(y,ie,yt(E)),p.set(w,y),y},Et=()=>{let w=sl(s);for(let[S,l]of [...p])w.has(S)||(e.destroy(l),p.delete(S));for(let[S,l]of w){let E=p.get(S);E===void 0&&(E=ut(S,l.col,l.row,l.piece.color,l.row-s.rows));let T=e.need(E,yn);T.col=l.col,T.row=l.row,T.kind!==l.piece.color&&(T.kind=l.piece.color,e.set(E,ie,yt(l.piece.color)));let c=l.piece.special&&l.piece.special!=="rainbow"?Rn.find(R=>R.id===l.piece.special):void 0,y=m.get(S);c&&y===void 0&&(y=e.create(),e.set(y,Rd,{of:S}),e.set(y,K,{x:0,y:0}),m.set(S,y)),c&&y!==void 0&&e.set(y,ie,{shape:"sprite",art:c.art,w:Xe()*.95,h:Xe()*.95,depth:4}),!c&&y!==void 0&&(e.destroy(y),m.delete(S));}for(let[S,l]of [...m])w.has(S)||(e.destroy(l),m.delete(S));Ze();},Ze=()=>{dt(e,pl);let w=Xe();for(let S=0;S<s.rows;S++)for(let l=0;l<s.cols;l++){let E=s.cells[S][l],T=at(a,l,S),c=(y,R,L,M=1)=>{if(!R)return;let x=Zr[R.id],_=e.create();e.set(_,pl,{key:y}),e.set(_,K,{x:T.x,y:T.y}),e.set(_,ie,{shape:"sprite",art:R.hp>=2&&x?.id==="ice"?"m3_ice2":R.hp>=2&&x?.id==="stone"?"m3_stone2":x?.art??"m3_stone",w:w*M,h:w*M,depth:L});};c(`u${l},${S}`,E.under,1.5,.98),c(`o${l},${S}`,E.over,5,.98),c(`b${l},${S}`,E.block,3,.95);}},Ge=()=>{dt(e,Ad),zt(e,"board",a.top+a.cell*s.rows*.35);let w=Xe(),S=at(a,(s.cols-1)/2,(s.rows-1)/2),l=w*.25,E=(T,c,y)=>{let R=e.create();e.set(R,Ad,{i:0}),e.set(R,K,{x:T,y:c}),e.set(R,ie,y);};E(S.x,S.y,{shape:"sprite",art:"panel",w:w*s.cols+l*2,h:w*s.rows+l*2,color:"panel",alpha:.9,depth:-10});for(let T=0;T<s.rows;T++)for(let c=0;c<s.cols;c++){if(s.cells[T][c].hole)continue;let y=at(a,c,T);E(y.x,y.y,{shape:"sprite",art:"cell",w:w-2,h:w-2,color:(T+c)%2?"panel":"ground",alpha:.85,depth:-9});}},It=()=>{let w=He(e),S=w.h*.12,l=a.top-Xe()*.4,E=Math.max(40,(l-S)*.92);if((se===null||!e.isAlive(se))&&(se=e.create()),e.set(se,K,{x:w.w*.15,y:l-E/2}),e.set(se,ie,{shape:"actor",cast:Te().cast,h:E,pose:"idle",facing:1,depth:20}),oe&&e.isAlive(oe.entity)){let T=E*oe.def.size;e.set(oe.entity,K,{x:w.w*.82,y:l-T/2});let c=e.need(oe.entity,ie);c.shape==="actor"&&(c.h=T);}},Qe=()=>n.def.kind!=="goal"?[]:n.def.goals.map(w=>({goal:w,left:w.kind==="color"?Math.max(0,w.count-(Re.colors.get(w.color)??0)):w.kind==="clear"?sa(s,w.obstacle):w.kind==="drops"?Math.max(0,w.count-Re.drops):Math.max(0,w.value-Number(e.vars.score??0))})),Kt=()=>Qe().every(w=>w.left===0),Yt=w=>{let S=He(e).w*.07;if(w.kind==="color"){let l=ns(w.color);return {shape:"sprite",art:l?.art??"gem1",w:S,h:S,color:l?.color??"piece1",depth:70}}return w.kind==="clear"?{shape:"sprite",art:Zr[w.obstacle]?.art??"m3_stone",w:S,h:S,depth:70}:w.kind==="drops"?{shape:"sprite",art:"m3_crate",w:S,h:S,depth:70}:{shape:"sprite",art:"coin",w:S,h:S,depth:70}},Ft=(w,S,l,E,T,c)=>{let y=Math.max(8,E*.09);lt(`${w}:bg`,S,l,{shape:"rect",w:E,h:y,color:"#000000",alpha:.5,radius:y/2,depth:69});let R=Math.max(1,(E-4)*Math.max(0,Math.min(1,T)));lt(`${w}:fill`,S-(E-4)/2+R/2,l,{shape:"rect",w:R,h:y-4,color:c,radius:(y-4)/2,depth:69.1});},ur=()=>{let w=He(e),S=Math.min(w.w,w.h),l=(M,x,_,I,P="text",H=S*.045)=>lt(M,x,_,{shape:"text",text:I,size:Math.round(H),color:P,bold:true,depth:70}),E=a.top-Xe()*.4,T=w.h*.085;ke=[],rt.clear();let c=w.w*.36,y=(T+E)/2+S*.02,R=S*.07,L=ue>=Ae();if(ke.push({id:"skill",x:c,y,r:R*1.15}),L&<("h:skill:glow",c,y,{shape:"circle",r:R*1.25,color:Pe?"coin":"secondary",alpha:.5+.3*Math.sin(e.time*7),depth:68.9}),lt("h:skill:bg",c,y,{shape:"circle",r:R,color:"panel",alpha:.95,depth:69}),lt("h:skill:i",c,y,{shape:"sprite",art:Be().art,w:R*1.4,h:R*1.4,alpha:L?1:.45,depth:69.2}),Ft("h:mana",c,y+R*1.45,R*2.2,ue/Ae(),"secondary"),ee()){let M=w.w*.15;if(Ft("h:hp",M,T,w.w*.24,Ce/Me,"accent"),l("h:hp:t",M+w.w*.12+S*.05,T,`${Math.ceil(Ce)}`,"text",S*.034),ce>0&&(lt("h:sh:i",M+w.w*.12+S*.05,T+S*.055,{shape:"sprite",art:"m3_shield",w:S*.045,h:S*.045,color:"primary",depth:70}),l("h:sh:t",M+w.w*.12+S*.11,T+S*.055,`${Math.ceil(ce)}`,"primary",S*.03)),oe){let x=w.w*.78;Ft("h:foe",x,T,w.w*.26,oe.hp/oe.max,"danger"),l("h:foe:t",x-w.w*.13-S*.05,T,`${Math.ceil(oe.hp)}`,"text",S*.034);let _=rs[oe.def.element];lt("h:foe:el",x+w.w*.13+S*.03,T,{shape:"circle",r:S*.018,color:_.color,depth:70});let I=(T+E)/2;lt("h:foe:in:bg",w.w*.62,I,{shape:"circle",r:S*.045,color:oe.in<=1?"danger":"panel",alpha:.95,depth:69}),l("h:foe:in",w.w*.62,I,String(oe.in),"text",S*.045);let P=n.def.kind==="battle"?n.def.enemies.length:0;for(let H=0;H<P;H++)lt(`h:q:${H}`,w.w*.8+(H-(P-1)/2)*S*.04,E+S*.005,{shape:"circle",r:S*.012,color:H<Ee?"muted":H===Ee?"danger":"text",alpha:.9,depth:70});}}else {l("h:moves",w.w*.5,T+S*.01,String(X),X<=3?"danger":"text",S*.075);let M=Qe(),x=w.w*.64,_=w.w*.11,I=(T+E)/2+S*.02;M.forEach((P,H)=>{let re=x+H*_;lt(`h:g:${H}`,re,I,Yt(P.goal)),l(`h:g:${H}:t`,re,I+S*.06,P.left===0?"\u2713":String(P.left),P.left===0?"accent":"text",S*.038);});}e.vars.m3_phase=i,e.vars.m3_buttons=ke.map(M=>`${M.id}@${Math.round(M.x)},${Math.round(M.y)}`).join(";");for(let[M,x]of [..._e])!M.startsWith("h:")||rt.has(M)||(e.destroy(x),_e.delete(M));},bt=()=>{oe&&e.isAlive(oe.entity)&&it(e,oe.entity,"die");let w=Le.shift();if(w===void 0){oe=null;return}let S=os(w),l=e.create();e.set(l,K,{x:0,y:0}),e.set(l,ie,{shape:"actor",cast:S.cast,variant:S.variant??o.int(0,99),h:50,pose:"idle",facing:-1,depth:20});let E=S.hp*n.enemyHp;oe={def:S,hp:E,max:E,in:S.every,rage:1,entity:l},It(),S.boss&&(e.emit(Zh,{kind:w}),G(e,{kind:"shake",power:1})),D();},D=()=>{if(e.vars.moves=X,e.vars.hero_hp=Math.ceil(Ce),e.vars.mana=Math.floor(ue),e.vars.m3_goals=Qe().map(w=>`${w.goal.kind==="color"?`color${w.goal.color}`:w.goal.kind==="clear"?w.goal.obstacle:w.goal.kind}:${w.left}`).join(","),e.vars.m3_enemy=oe?`${oe.def.id}:${Math.ceil(oe.hp)}/${Math.ceil(oe.max)}:${oe.in}`:"",ee()){let w=n.def.kind==="battle"?n.def.enemies.length:1;e.vars.level_progress=Math.min(1,(Ee+(oe?1-oe.hp/oe.max:0))/w);}else {let w=n.def;if(w.kind==="goal"){let S=w.goals.map(E=>E.kind==="color"||E.kind==="drops"?E.count:E.kind==="score"?E.value:1),l=Qe();e.vars.level_progress=l.reduce((E,T,c)=>E+(T.goal.kind==="clear"?T.left===0?1:0:1-T.left/S[c]),0)/Math.max(1,l.length);}}},u=()=>{dt(e,yn),dt(e,Rd),dt(e,pl),dt(e,Td),p.clear(),m.clear(),_e.clear(),oe&&e.isAlive(oe.entity)&&e.destroy(oe.entity),oe=null,n=ao(Yr(e,"meta:chapter")||1,r("difficulty"));let w=n.def;s=na(Zs[w.board]??Zs.plain,n.colors,()=>o.next(),Gi,w.kind==="goal"?w.drops??0:0),a=Gt(),Ge(),i="idle",$=null,k=null,O=null,C=null,z=0,F=false,ne=0,Re.colors.clear(),Re.drops=0,X=w.kind==="goal"?w.moves+Yr(e,"meta:moves"):0,ye=X,be=0,fe=0,we=false,de=false,Me=Us*Math.pow(1.06,n.level-1)*(1+Yr(e,"meta:health")),Ce=Me,ce=0,ue=0,Pe=false,Ee=0,tt=0,Ne=0,Le=w.kind==="battle"?[...w.enemies]:[],e.vars.m3_level=n.level,e.vars.m3_world=n.world,e.vars.m3_kind=w.kind,e.vars.coins=0,e.vars.score=0,e.vars.stars=0,e.vars.reviving=false,Et(),It(),w.kind==="battle"&&bt(),D();},g=w=>{if(!w||!oe)return 1;let S=rs[w].beats.includes(oe.def.element),l=w===oe.def.element;return (S?1.5:l?.5:1)*(w===Te().element?1.25:1)},f=(w,S=0)=>{z++,F||=w.slimeCleared,Re.drops+=w.dropsCollected;let l=S,E=0,T=0,c=Xe();for(let M of w.cleared){let x=M.piece;x.color>=0&&Re.colors.set(x.color,(Re.colors.get(x.color)??0)+1);let _=ns(x.color),I=at(a,M.col,M.row);G(e,{kind:"burst",x:I.x,y:I.y,color:_?.color??"coin",n:6,size:c*.8}),ue=Math.min(Ae(),ue+kd*(1+Yr(e,"meta:mana"))),!(!ee()||!_)&&(_.role==="attack"?l+=nt()*g(_.element)*(1+.25*(z-1)):_.role==="heal"?E+=bd*Math.pow(1.06,n.level-1)*(1+Yr(e,"meta:health")):_.role==="shield"&&(T+=xd*Math.pow(1.06,n.level-1)*(1+Yr(e,"meta:defense"))));}for(let M of w.fired){let x=at(a,M.col,M.row);G(e,{kind:"ring",x:x.x,y:x.y,color:"coin",size:c*2.4});}w.fired.length>0&&G(e,{kind:"shake",power:.4+Math.min(1,w.fired.length*.2)});for(let M of w.created)e.emit("special-made",{kind:M.piece.special});let y=w.cleared.length*r("pieceScore")*z+w.fired.length*30;Je(e,"score",y),ne+=w.cleared.length;let L=Math.floor(ne/r("coinEvery"))-Math.floor((ne-w.cleared.length)/r("coinEvery"));L>0&&(Je(e,"coins",L),e.emit("coin-collected",{value:L})),e.emit("pieces-cleared",{count:w.cleared.length,cascade:z}),ee()&&(E>0&&(Ce=Math.min(Me,Ce+E),se!==null&&G(e,{kind:"pop",x:e.need(se,K).x,y:e.need(se,K).y-c,text:`+${Math.round(E)}`,color:"accent",size:Math.round(c*.45)})),T>0&&(ce+=T),l>0&&oe&&b(l)),Et(),D();},b=w=>{if(!oe)return;oe.hp-=w,se!==null&&Fe(e,se,"attack"),Fe(e,oe.entity,"hit");let S=e.need(oe.entity,K);G(e,{kind:"pop",x:S.x,y:S.y-Xe(),text:`-${Math.round(w)}`,color:"danger",size:Math.round(Xe()*.5)}),!(oe.hp>0)&&(Ee++,e.emit("enemy-defeated",{kind:oe.def.id}),d(),oe.def.boss&&(tt++,Je(e,"coins",10),e.emit(Qh,{kind:oe.def.id}),G(e,{kind:"flash",color:"coin"})),bt());},d=()=>{if(!oe)return;it(e,oe.entity,"die");let w=oe.entity;e.need(w,ie).alpha=.6,v(()=>{e.isAlive(w)&&e.destroy(w);});},h=[],v=w=>h.push({t:.9,f:w}),A=()=>{if(il(s,F),F=false,z=0,Et(),n.def.kind==="goal"){if(Kt())return Q();if(X<=0)return $e("out-of-moves")}else {if(!oe)return Q();if(oe.in--,oe.in<=0){i="enemy",fe=.45;return}}N();},N=()=>{i="idle",lo(s)===null&&(nl(s),Et(),e.emit("board-shuffled",{})),D();},B=()=>{if(!oe)return N();let w=oe.def,S=n.enemyAttack*w.attack*oe.rage;oe.rage=1,Fe(e,oe.entity,"attack");let l=Math.min(ce,S);if(ce-=l,S=(S-l)*(1-Math.min(.6,Yr(e,"meta:defense"))),S>0){if(Ce-=S,se!==null){Fe(e,se,"hit");let T=e.need(se,K);G(e,{kind:"pop",x:T.x,y:T.y-Xe(),text:`-${Math.round(S)}`,color:"danger",size:Math.round(Xe()*.5)});}G(e,{kind:"shake",power:.8}),e.emit("player-hit",{hp:Math.ceil(Ce)});}let E=w.skill;if(E?.kind==="sow"?ll(s,E.obstacle,E.count):E?.kind==="heal"?oe.hp=Math.min(oe.max,oe.hp+oe.max*E.share):E?.kind==="rage"&&(oe.rage=E.mult),oe.in=w.enrage&&oe.hp<oe.max*w.enrage?Math.max(1,w.every-1):w.every,Et(),Ce<=0)return Ce=0,$e("fell");N();},Q=()=>{if(n.def.kind==="goal"){Ne=Math.min(X,12),e.vars.stars=Math.min(we?1:3,Zi(X/Math.max(1,ye),false)),Je(e,"score",X*r("moveBonus")),i="finale",fe=.3;return}e.vars.stars=Math.min(we?1:3,Zi(Ce/Me,true)),J("cleared");},J=w=>{if(de)return;de=true,i="over";let S=w==="cleared";S&&e.vars["meta:first_clear"]===true&&Je(e,"coins",n.firstClearGold),S||(e.vars.stars=0),e.vars.reviving=false,D(),e.emit(Xt,{reason:w,stats:{chapter:n.level,seconds:Math.floor(be),cleared:S,stars:Number(e.vars.stars??0),coins:Number(e.vars.coins??0),bosses:tt,kills:Ee,battle:ee()}});},$e=w=>{if(e.vars.revive_ready===true&&!we){e.vars.reviving=true,e.vars.m3_revive_reason=w,i="idle",e.emit(tr,{});return}J(w);},Se=()=>{Ie()&&(we=true,e.vars.reviving=false,ee()?(Ce=Me*Md,oe&&(oe.in=oe.def.every)):X+=$d,G(e,{kind:"flash",color:"coin"}),N());},Ye=w=>{let S=s.cells[w.row]?.[w.col];if(!S||S.hole)return 0;let l=n.def.kind==="goal"?n.def.goals:[],E=0;for(let c of [S.under,S.over,S.block])c&&(E+=l.some(y=>y.kind==="clear"&&y.obstacle===c.id)?6:3);let T=S.piece;if(T&&!S.block){E+=1,T.special&&(E+=3),l.some(y=>y.kind==="color"&&y.color===T.color)&&(E+=2);let c=ns(T.color);ee()&&c?.role==="attack"&&(E+=g(c.element));}if(l.some(c=>c.kind==="drops"))for(let c=0;c<w.row;c++)s.cells[c][w.col].piece?.color===Qr&&(E+=2);return E},pt=w=>{let S={col:Math.floor(s.cols/2),row:Math.floor(s.rows/2)},l=-1;for(let E=0;E<s.rows;E++)for(let T=0;T<s.cols;T++){if(s.cells[E][T].hole)continue;let c=ca(s,w,{col:T,row:E}).reduce((y,R)=>y+Ye(R),0);c>l&&(l=c,S={col:T,row:E});}return S},ze=()=>{let w=Be();if(ue<w.mana||i!=="idle")return false;let S=ht(),l=[];if(w.kind==="shape"){let c=S>=(w.bigAt??99)&&w.bigShape?w.bigShape:w.shape??"area:1",y=pt(c);l=ca(s,c,y);let R=at(a,y.col,y.row);G(e,{kind:"ring",x:R.x,y:R.y,color:"coin",size:Xe()*4}),G(e,{kind:"flash",color:"coin"});}else l=la(s,"line",Math.round((w.count??3)*S));ue=0,Pe=false,z=0,se!==null&&Fe(e,se,"attack"),e.emit("skill-cast",{id:w.id}),Lt(e,"m3-skill");let E=ee()&&oe?w.damage*nt()*S*g(Te().element):0,T=ia(s,l,w.id);return f(T,E),i="falling",true},le=w=>{if(O){let S=s.cells[O.row]?.[O.col]?.piece?.id,l=S!==void 0?p.get(S):void 0;l!==void 0&&(e.need(l,K).scale=1);}if(O=w,w){let S=s.cells[w.row]?.[w.col]?.piece?.id,l=S!==void 0?p.get(S):void 0;l!==void 0&&(e.need(l,K).scale=1.15);}},V=0,te=(w,S)=>{if(V=0,Bt(e),i!=="idle"||Ie()||!ss(s,w,S))return;le(null);let l=s.cells[w.row][w.col].piece.id,E=s.cells[S.row][S.col].piece.id;$=new Map([[l,S],[E,w]]),k=[w,S],i="swapping",Lt(e,"match3-swap");};e.on(Nt,w=>{let S=w;if(!(!st(e)||hn(e)||de||Ie()))if(S.type==="tap"){if(ke.find(T=>Math.hypot(S.x-T.x,S.y-T.y)<=T.r)?.id==="skill"){if(ue<Ae())return;ze()||(Pe=true);return}let E=Ur(a,S.x,S.y);if(!E||i!=="idle")return;O&&Math.abs(O.col-E.col)+Math.abs(O.row-E.row)===1?te(O,E):le(O&&O.col===E.col&&O.row===E.row?null:E);}else if(S.type==="press"){let l=Ur(a,S.x,S.y);C=l?{x:S.x,y:S.y,...l}:null;}else if(S.type==="move"&&C){let l=S.x-C.x,E=S.y-C.y;if(Math.max(Math.abs(l),Math.abs(E))<a.cell*.45)return;let T={col:C.col,row:C.row},c=Math.abs(l)>Math.abs(E)?{col:T.col+Math.sign(l),row:T.row}:{col:T.col,row:T.row+Math.sign(E)};C=null,te(T,c);}else S.type==="release"&&(C=null);}),e.on(Ut,()=>{u(),e.vars.level=n.level;}),e.on(Qt,u),e.on(rr,Se),e.on(nr,()=>{Ie()&&(e.vars.reviving=false,J(ee()?"fell":"out-of-moves"));}),e.on(Zt,w=>{ft("h:"),ke=[],se!==null&&e.isAlive(se)&&it(e,se,w.reason==="cleared"?"dance":"die");}),e.on(qt,()=>{a=Gt(),Ge();for(let[w,S]of p){let l=e.need(S,yn);e.set(S,ie,yt(l.kind));}Et(),It();});let Y=w=>{let S=true,l=Math.min(1,w*14),E=Xe();for(let T of e.query(yn)){let c=e.need(T,yn),y=$?.get(c.id)??c,R=e.need(T,K),L=at(a,y.col,y.row),M=L.x-R.x,x=L.y-R.y,_=e.need(T,ie);Math.abs(M)<.5&&Math.abs(x)<.5?(R.x=L.x,R.y=L.y,_.alpha=1):(S=false,_.alpha=R.y<a.top-E*.3?0:1,R.x+=M*l,R.y+=Math.abs(x)>E*.3?Math.sign(x)*Math.min(Math.abs(x),E*12*w):x*l);}for(let[T,c]of m){let y=p.get(T);if(y===void 0)continue;let R=e.need(y,K);e.set(c,K,{x:R.x,y:R.y,scale:1+.06*Math.sin(e.time*6)}),e.need(c,ie).alpha=e.need(y,ie).alpha??1;}return S};e.addSystem({id:"match3",order:0,run(w,S){for(let l of [...h])l.t-=S,l.t<=0&&(h.splice(h.indexOf(l),1),l.f());if(!st(w)||de){Y(S);return}if(be+=S,ur(),!Ie()&&Y(S)){if(fe>0){fe-=S;return}if(i==="swapping"&&k){let[l,E]=k;k=null,$=null,z=0;let T=al(s,l,E);if(!T){let c=s.cells[l.row][l.col].piece.id,y=s.cells[E.row][E.col].piece.id;$=new Map([[c,E],[y,l]]),i="returning";return}n.def.kind==="goal"&&X--,f(T),i="falling";return}if(i==="returning"){if($){$=null;return}i="idle";return}if(i==="falling"){let l=aa(s);if(l){f(l);return}A();return}if(i==="enemy"){B();return}if(i==="finale"){if(Ne>0){Ne--,X=Math.max(0,X-1);let E=la(s,"line",1);E.length>0&&f(ia(s,E,"finale")),Et(),fe=.12;return}let l=aa(s);if(l){f(l);return}J("cleared");return}if(i==="idle"&&Pe){ze();return}if(i==="idle"){if(V+=S,(!vt(w,"match3-swap")||V>7)&&!_r(w)){let l=lo(s);l&&kt(w,"swipe",at(a,l[0].col,l[0].row),at(a,l[1].col,l[1].row),a.cell*1.1);}if(ue>=Ae()&&!vt(w,"m3-skill")&&!_r(w)){let l=ke.find(E=>E.id==="skill");l&&kt(w,"tap",l,void 0,a.cell*1.2);}}}}}),u();}};var as=[{id:"garden",prefix:"item",levels:8,color:"accent",gen:"mg_gen_garden"},{id:"bake",prefix:"mg_bake",levels:7,color:"coin",gen:"mg_gen_bake"},{id:"jewel",prefix:"mg_jewel",levels:7,color:"primary",gen:"mg_gen_jewel"},{id:"potion",prefix:"mg_potion",levels:7,color:"secondary",gen:"mg_gen_potion"}],Cr=e=>as.find(t=>t.id===e),hl=3,Dd=[0,.2,.35],Od=.06,gr={box:{id:"box",layer:"block",art:["mg_box","mg_box2"],neighbour:true,coins:1},fog:{id:"fog",layer:"cover",art:["mg_fog"],neighbour:true,hides:true},web:{id:"web",layer:"cover",art:["mg_web"],neighbour:true,mergeInto:true},bubble:{id:"bubble",layer:"cover",art:["mg_bubble"],neighbour:false,mergeInto:true,ttl:14}},ul=[{id:"joker",art:"mg_joker",effect:"joker"},{id:"scissors",art:"mg_scissors",effect:"split"},{id:"chest",art:"chest",effect:"chest",amount:3},{id:"battery",art:"mg_energy",effect:"energy",amount:6}],Jr=e=>ul.find(t=>t.id===e),ml=[[1,.5],[2,.35],[3,.15]],yl={"-":{kind:"free"},".":{kind:"hole"},A:{kind:"gen",chain:0},B:{kind:"gen",chain:1},C:{kind:"gen",chain:2},D:{kind:"gen",chain:3},a:{kind:"item",chain:0,level:1},b:{kind:"item",chain:1,level:1},c:{kind:"item",chain:2,level:1},d:{kind:"item",chain:3,level:1},x:{kind:"block",obstacle:"box",hp:1},X:{kind:"block",obstacle:"box",hp:2},f:{kind:"cover",obstacle:"fog",levels:[1,2,2,3]},w:{kind:"cover",obstacle:"web",levels:[2,2,3]},u:{kind:"cover",obstacle:"bubble",levels:[3,3,4]},J:{kind:"special",special:"joker"},S:{kind:"special",special:"scissors"},K:{kind:"special",special:"chest"},E:{kind:"special",special:"battery"}},Cd=7,Pd=8,An={start:["-------","-------","--a-a--","---A---","--a----","-------","-------","-------"],two:["-------","-------","-a---b-","--A-B--","-------","-------","-------","-------"],boxes:["-------","-------","--A-B--","-------","xxxxxxx","x--K--x","x-----x","xxxxxxx"],fog:["fffffff","fffffff","-------","--A-B--","-------","-------","xx-E-xx","xx---xx"],yard:["X-----X","-------","-A-J-B-","-------","xx---xx","fx---xf","ffx-xff","fffffff"],cellar:["XxxxxxX","x-----x","x-A-B-x","x-----x","x--K--x","xfffffx","xfffffx","XxxxxxX"],webs:["-------","-w---w-","--A-B--","---C---","-w---w-","-------","--www--","-------"],mine:["XX---XX","X--S--X","--A-C--","---B---","-------","ffXXXff","fff-fff","fffffff"],workshop:["w--E--w","-------","-A-B-C-","-------","xwxwxwx","-------","x--K--x","XXXXXXX"],vault:["XfffffX","fx---xf","f-A-B-f","f--J--f","f-C---f","fx---xf","XfffffX","XXXXXXX"],bubbles:["-------","-u---u-","--A-B--","---C---","-------","-u---u-","--uuu--","-------"],holes:["..---..",".-----.","--A-B--","---C---","---D---","--fff--",".-fff-.","..---.."],lab:["u-----u","-x-E-x-","--A-D--","-------","--B-C--","-w---w-","xxwuwxx","XXXXXXX"],terrace:["...-...","..---..",".-A-B-.","---J---","-C---D-","-u-x-u-","xxfffxx","XXfffXX"],four:["-------","-A---B-","-------","---J---","-------","-C---D-","xxxxxxx","XXXXXXX"],fortress:["ffXXXff","fx---xf","X-A-B-X","X--S--X","X-C-D-X","fx-K-xf","ffXXXff","fffffff"],maze:["-x-u-x-","-x---x-","-xA-Bx-","--w-w--","-xC-Dx-","-x---x-","-xfffx-","XXfffXX"],palace:["uXXXXXu","X--E--X","X-A-B-X","X--J--X","X-C-D-X","Xw---wX","XffKffX","XXXXXXX"]},gl=[{id:"upgrade",art:"mg_sk_merge",charge:10,effect:"upgrade",count:3},{id:"free",art:"mg_sk_free",charge:9,effect:"free",count:6},{id:"joker",art:"mg_sk_joker",charge:12,effect:"joker",count:2}],ha=e=>gl.find(t=>t.id===e),fo=[{id:"hero",cast:"hero",gems:0,skill:"upgrade"},{id:"hero2",cast:"hero2",gems:150,skill:"free"},{id:"hero3",cast:"hero3",gems:300,skill:"joker"}],We=(e,t,r,o,n=0,s=3,a)=>({board:e,chains:[...t].map(i=>({g:"garden",b:"bake",j:"jewel",p:"potion"})[i]??"garden"),orders:r,top:o,double:n,visible:s,...a?{slack:a}:{}}),fa=e=>({...e,vip:true}),sr=(e,t)=>({...e,extra:t}),ua=[We("start","g",3,3,0,1,1.6),We("start","g",4,3,0,2,1.5),We("two","gb",4,3,0,2,1.45),We("two","gb",5,4,0,2),We("boxes","gb",5,4,0,3),We("boxes","gb",6,4,.2,3),We("fog","gb",6,4,.2,3),We("yard","gb",6,5,.2,3),We("fog","gb",7,5,.3,3),sr(fa(We("cellar","gb",6,5,.3,3)),.92),sr(We("webs","gbj",5,4,.2,3),.92),sr(We("webs","gbj",6,4,.3,3),.92),sr(We("mine","gbj",6,5,.2,3),1.15),sr(We("workshop","gbj",6,5,.3,3),.9),sr(We("mine","gbj",7,5,.3,3),1.08),sr(We("yard","gj",6,5,.3,3),1.15),sr(We("workshop","gbj",7,5,.4,3),.92),We("vault","gbj",7,5,.3,3),sr(We("webs","jbg",7,6,.3,3),.92),fa(We("vault","gbj",7,6,.4,3)),sr(We("bubbles","gbp",6,5,.2,3),1.15),sr(We("bubbles","gbp",6,5,.3,3),1.12),sr(We("holes","gbpj",6,5,.3,3),.92),sr(We("lab","gbjp",7,5,.3,3),.92),We("holes","gbpj",7,5,.4,3),We("bubbles","pjg",7,6,.3,3),We("lab","gbjp",7,6,.4,3),We("terrace","gbjp",8,5,.4,3),We("holes","gbpj",8,6,.4,3),fa(We("terrace","gbjp",7,6,.4,3)),We("four","gbjp",7,5,.3,3),sr(We("fortress","gbjp",7,5,.4,3),1.06),We("maze","gbjp",7,6,.4,3),We("four","gbjp",8,6,.4,3),sr(We("fortress","gbjp",8,6,.5,3),1.06),We("palace","gbjp",8,6,.4,3),We("maze","gbjp",8,6,.5,3),We("lab","gbjp",9,6,.5,3),We("palace","gbjp",9,6,.5,3),sr(fa(We("fortress","gbjp",8,6,.5,3)),1.06)],co=10,Id=4,ma=ua.length,bl=[0,18,45,75];function Yh(e){let t=e>>>0;return ()=>{t=t+1831565813>>>0;let r=t;return r=Math.imul(r^r>>>15,r|1),r^=r+Math.imul(r^r>>>7,r|61),((r^r>>>14)>>>0)/4294967296}}var pa=e=>Math.pow(2,Math.max(0,e-1));function Jh(e,t){let r=Yh(t*7919+13),o=[],n=e.chains;for(let s=0;s<e.orders;s++){let a=e.orders<=1?1:s/(e.orders-1),i=e.vip===true&&s===e.orders-1,p=2+Math.round(a*(e.top-2)),m=Math.max(2,Math.min(e.top,p-(r()<.3?1:0))),$=n[(s+Math.floor(r()*n.length))%n.length],k=[{chain:$,level:i?Math.min(e.top+1,(Cr($)?.levels??7)-1):m}];if(i||s>0&&n.length>1&&r()<e.double){let O=n[(n.indexOf($)+1+Math.floor(r()*(n.length-1)))%n.length];k.push({chain:O,level:i?e.top:Math.max(2,m-1)});}o.push({wants:k,vip:i});}return o}function eu(e){let t=n=>n.reduce((s,a)=>s+pa(a),0)/Math.max(1,n.length),r=ml.reduce((n,[s,a])=>n+pa(s)*a,0),o=0;for(let n of e.join("")){let s=yl[n];if(s){if(s.kind==="item")o+=pa(s.level);else if(s.kind==="cover")o+=t(s.levels)*(gr[s.obstacle]?.mergeInto&&!gr[s.obstacle]?.ttl?.5:.2);else if(s.kind==="special"){let a=Jr(s.special);o+=a?.effect==="energy"?a.amount??0:a?.effect==="chest"?r*(a.amount??0):a?.effect==="joker"?3:2;}}}return o}function po(e,t=.5){let r=Math.max(1,Math.min(ma,Math.floor(e))),o=ua[r-1],n=Math.ceil(r/co),s=Jh(o,r),a=s.reduce((m,$)=>m+$.wants.reduce((k,O)=>k+pa(O.level),0),0),i=Math.max(a*.4,a-eu(An[o.board]??[])*.7),p=(o.slack??1.32-(n-1)*.08-(r-(n-1)*co)*.006)*(1.1-t*.2)*(o.extra??1);return {level:r,world:n,index:r-(n-1)*co,def:o,boss:o.vip===true,orders:s,energy:Math.ceil(i*p),firstClearGold:(o.vip?120:50)+(r-1)*10}}var xl=e=>bl[Math.ceil(Math.max(1,e)/co)-1]??0,ya=e=>e>=.2?3:e>=.08?2:1,ga=15,kl="kit-merge",vl=[{id:"Energy",var:"meta:energy",art:"mg_energy",color:"coin",perLevel:2,unit:"",maxLevel:15,price:40,growth:.12},{id:"GenLuck",var:"meta:luck",art:"mg_joker",color:"secondary",perLevel:2,unit:"%",maxLevel:15,price:45,growth:.12},{id:"Reward",var:"meta:reward",art:"coin",color:"coin",perLevel:5,unit:"%",maxLevel:20,price:40,growth:.12},{id:"SkillPower",var:"meta:skill",art:"mg_sk_merge",color:"secondary",perLevel:8,unit:"%",maxLevel:10,price:50,growth:.12},{id:"Charge",var:"meta:charge",art:"mg_sk_free",color:"primary",perLevel:5,unit:"%",maxLevel:10,price:50,growth:.12}],Nd={game:"merge",character:kl,stats:vl,heroes:fo,levels:ma,firstClearGold:e=>po(e).firstClearGold,stars:3,starsToEnter:xl};var ba=e=>({kind:"none",at:e,hits:[],coins:0}),en=e=>Cr(e)?.levels??8,$l=(e,t,r,o,n="")=>({id:e.nextId++,kind:t,chain:r,level:o,special:n}),is=(e,t,r)=>$l(e,"item",t,r),Bd=(e,t)=>$l(e,"special","",0,t);function Ml(e,t,r){let o=Math.max(...e.map(a=>a.length)),n={cols:o,rows:e.length,cells:[],chains:t,nextId:1,rand:r},s=a=>t[a]??null;for(let a=0;a<e.length;a++){let i=[];for(let p=0;p<o;p++){let m=yl[e[a][p]??"-"]??{kind:"free"},$={hole:m.kind==="hole",thing:null,cover:null,block:null};if(m.kind==="gen"){let k=s(m.chain);k&&($.thing=$l(n,"gen",k,1));}else if(m.kind==="item"){let k=s(m.chain);k&&($.thing=is(n,k,m.level));}else if(m.kind==="block")$.block={id:m.obstacle,hp:m.hp};else if(m.kind==="cover"){let k=t[Math.floor(r()*t.length)]??"garden",O=Math.min(en(k)-1,m.levels[Math.floor(r()*m.levels.length)]??1);$.thing=is(n,k,O);let C=gr[m.obstacle];$.cover={id:m.obstacle,hp:1,...C?.ttl?{ttl:C.ttl}:{}};}else m.kind==="special"&&($.thing=Bd(n,m.special));i.push($);}n.cells.push(i);}return n}var Tn=(e,t)=>e.cells[t.row]?.[t.col],Hd=(e,t)=>t.col>=0&&t.row>=0&&t.col<e.cols&&t.row<e.rows,Wd=e=>!!e&&!e.hole&&!e.thing&&!e.block,ho=(e,t)=>{let r=Tn(e,t);return !!r&&!!r.thing&&!r.cover&&!r.block};function Pr(e){let t=[];for(let r=0;r<e.rows;r++)for(let o=0;o<e.cols;o++){let n=e.cells[r][o];n.thing&&t.push({at:{col:o,row:r},thing:n.thing,cell:n});}return t}var tu=e=>e.cells.reduce((t,r)=>t+r.filter(Wd).length,0);function xa(e,t){let r=null,o=1/0;for(let n=0;n<e.rows;n++)for(let s=0;s<e.cols;s++){if(!Wd(e.cells[n][s]))continue;let a=Math.hypot(s-t.col,(n-t.row)*1.05);a<o-1e-9&&(o=a,r={col:s,row:n});}return r}function ka(e,t){let r=t?.thing;return !t||!r||t.block||r===e||e.kind!==r.kind||e.kind==="special"||t.cover&&!gr[t.cover.id]?.mergeInto||e.chain!==r.chain||e.level!==r.level?false:e.kind==="gen"?e.level<hl:e.level<en(e.chain)}function zd(e,t){let r=[],o=0;for(let[n,s]of [[1,0],[-1,0],[0,1],[0,-1]]){let a={col:t.col+n,row:t.row+s};if(!Hd(e,a))continue;let i=e.cells[a.row][a.col];for(let p of ["block","cover"]){let m=i[p];if(!m)continue;let $=gr[m.id];if(!$?.neighbour)continue;m.hp--;let k=m.hp<=0;k&&(i[p]=null,o+=$.coins??0),r.push({at:a,id:m.id,gone:k,revealed:k&&!!$.hides});}}return {hits:r,coins:o}}function jd(e,t,r){if(!ho(e,t)||!Hd(e,r)||t.col===r.col&&t.row===r.row)return ba(t);let o=Tn(e,t),n=Tn(e,r),s=o.thing;if(n.hole||n.block)return ba(t);if(ka(s,n)){let m=n.thing;o.thing=null,m.level++;let $=n.cover?.id;n.cover=null;let k=zd(e,r);return {kind:"merge",at:r,level:m.level,...$?{freed:$}:{},hits:k.hits,coins:k.coins}}let a=s.kind==="special"?Jr(s.special):void 0,i=n.thing,p=!n.cover||!!gr[n.cover.id]?.mergeInto;if(a?.effect==="joker"&&i?.kind==="item"&&p&&i.level<en(i.chain)){o.thing=null,i.level++;let m=n.cover?.id;n.cover=null;let $=zd(e,r);return {kind:"joker",at:r,level:i.level,...m?{freed:m}:{},hits:$.hits,coins:$.coins}}if(a?.effect==="split"&&i?.kind==="item"&&!n.cover&&i.level>=2){o.thing=null;let m=xa(e,r);return m?(i.level--,e.cells[m.row][m.col].thing=is(e,i.chain,i.level),{kind:"split",at:r,level:i.level,second:m,hits:[],coins:0}):(o.thing=s,ba(t))}return i?n.cover?ba(t):(o.thing=i,n.thing=s,{kind:"swap",at:r,hits:[],coins:0}):(o.thing=null,n.thing=s,{kind:"move",at:r,hits:[],coins:0})}function Vd(e,t,r=0){let o=Tn(e,t)?.thing;if(!o||o.kind!=="gen"||Tn(e,t).cover)return null;let n=xa(e,t);if(!n)return null;let s=e.rand(),a=Math.max(1,Math.min(hl,o.level)),i=a>=3&&s<Od?3:s<(Dd[a-1]??0)+r?2:1,p=is(e,o.chain,Math.min(i,en(o.chain)));return e.cells[n.row][n.col].thing=p,{at:n,thing:p,burst:ru(e)}}function ru(e){let t=[];for(let r=0;r<e.rows;r++)for(let o=0;o<e.cols;o++){let n=e.cells[r][o];n.cover?.ttl!==void 0&&(n.cover.ttl--,!(n.cover.ttl>0)&&(n.cover=null,n.thing=null,t.push({col:o,row:r})));}return t}var nu=e=>{let t=0;for(let[r,o]of ml)if(t+=o,e<t)return r;return 1};function Gd(e,t){let r=Tn(e,t),o=r?.thing;if(!r||!o||o.kind!=="special"||r.cover)return null;let n=Jr(o.special);if(n?.effect==="energy")return r.thing=null,{energy:n.amount??5,spawned:[]};if(n?.effect!=="chest")return null;r.thing=null;let s=[];for(let a=0;a<(n.amount??3);a++){let i=xa(e,t);if(!i)break;let p=e.chains[Math.floor(e.rand()*e.chains.length)]??as[0].id,m=is(e,p,Math.min(en(p),nu(e.rand())));e.cells[i.row][i.col].thing=m,s.push({at:i,thing:m});}return s.length===0?(r.thing=o,null):{energy:0,spawned:s}}function Kd(e,t={}){let r=Pr(e).filter(s=>ho(e,s.at)&&(s.thing.kind==="item"||t.gens!==false&&s.thing.kind==="gen")),o=null,n=1/0;for(let s of r)for(let a=0;a<e.rows;a++)for(let i=0;i<e.cols;i++){let p=e.cells[a][i];if(!ka(s.thing,p))continue;let m=(s.thing.kind==="gen"?100:0)+s.thing.level-(p.cover?.5:0);m<n&&(n=m,o=[s.at,{col:i,row:a}]);}return o}function Dn(e,t){let r=new Set,o=[],n=Pr(e);for(let s of t){let a=n.find(i=>i.thing.kind==="item"&&!i.cell.cover&&!r.has(i.thing.id)&&i.thing.chain===s.chain&&i.thing.level===s.level);if(!a)return null;r.add(a.thing.id),o.push(a.at);}return o}function wl(e,t){let r=Tn(e,t);if(!r?.thing)return null;let o=r.thing;return r.thing=null,o}function El(e,t,r){let o=xa(e,r),n=Bd(e,t);if(o)return e.cells[o.row][o.col].thing=n,{at:o,thing:n};let s=Pr(e).filter(a=>a.thing.kind==="item"&&!a.cell.cover).sort((a,i)=>a.thing.level-i.thing.level)[0];return s?(s.cell.thing=n,{at:s.at,thing:n}):null}function Fd(e){let t=Pr(e),r=tu(e)>0;for(let o of t){if(o.thing.kind!=="special"||o.cell.cover)continue;let n=Jr(o.thing.special);if(n?.effect==="energy"||n?.effect==="chest"&&r||n?.effect==="joker"&&t.some(s=>s.thing.kind==="item"&&(!s.cell.cover||gr[s.cell.cover.id]?.mergeInto)&&s.thing.level<en(s.thing.chain))||n?.effect==="split"&&r&&t.some(s=>s.thing.kind==="item"&&!s.cell.cover&&s.thing.level>=2))return true}return false}function qd(e,t,r){let o=[];for(let n=0;n<t;n++){let s=Pr(e).filter(p=>p.thing.kind==="item"&&!p.cell.cover&&p.thing.level<en(p.thing.chain)&&!o.some(m=>m.col===p.at.col&&m.row===p.at.row));if(s.length===0)break;let a=p=>r.some(m=>m.chain===p.thing.chain&&m.level===p.thing.level+1);s.sort((p,m)=>Number(a(m))-Number(a(p))||p.thing.level-m.thing.level);let i=s[0];i.thing.level++,o.push(i.at);}return o}var Sl=90,ls=ve("merge.item"),Zd=ve("merge.order"),Ll=ve("merge.layer"),Ud=ve("merge.backdrop"),Xd=ve("merge.part"),uo=ve("merge.customer"),mo=(e,t)=>{let r=Number(e.vars[t]??0);return Number.isFinite(r)?r:0},va={id:"merge",version:2,engines:["phaser"],requires:["round"],params:{difficulty:{type:"number",default:.5,min:0,max:1},orderReward:{type:"number",default:1,min:0,max:100},mergeScore:{type:"number",default:10,min:1,max:1e3,integer:true},energyBonus:{type:"number",default:20,min:0,max:1e4,integer:true}},setup({world:e,params:t}){let r=f=>yr(t,f),o=e.rng.stream("merge"),n=po(1,r("difficulty")),s=Ml(An.start,["garden"],()=>o.next()),a=oe(),i=new Map,p=new Map,m=null,$=[],k=[],O=0,C=0,z=0,F=0,ne=0,X=0,ye=0,be=0,fe=false,we=false,de=null,Re=[],Ce=()=>fo.find(f=>f.id===e.vars["meta:hero"])??fo[0],Me=()=>ha(Ce().skill),ce=()=>e.vars.reviving===true,ue=()=>Me().charge,Pe=()=>mo(e,"meta:luck"),Le=()=>$.flatMap(f=>f.order.wants);function oe(){return un(He(e),s.cols,s.rows,{top:.3,bottom:.86,widthShare:.94})}let Ee=()=>a.cell,tt=new Set,Ne=(f,b,d,h,v=1)=>{tt.add(f);let A=p.get(f);(A===void 0||!e.isAlive(A))&&(A=e.create(),e.set(A,Xd,{id:f}),p.set(f,A)),e.set(A,K,{x:b,y:d,scale:v}),e.set(A,ie,h);},se=()=>{for(let[f,b]of [...p])tt.has(f)||(e.destroy(b),p.delete(f));},ke=f=>{if(f.kind==="special")return Jr(f.special)?.art??"chest";let b=Cr(f.chain);return f.kind==="gen"?b?.gen??"chest":`${b?.prefix??"item"}${Math.min(f.level,b?.levels??8)}`},_e=f=>{let b=Ee(),d=f.kind==="gen"?.94:.92;return {shape:"sprite",art:ke(f),w:b*d,h:b*d,depth:3}},Te=()=>{let f=new Map(Pr(s).map(b=>[b.thing.id,b]));for(let[b,d]of [...i])f.has(b)||(e.destroy(d),i.delete(b));for(let[b,d]of f){let h=i.get(b);if(h===void 0){h=e.create();let N=at(a,d.at.col,d.at.row);e.set(h,K,{x:N.x,y:N.y,scale:.3}),i.set(b,h);}e.set(h,ls,{id:b,col:d.at.col,row:d.at.row});let v=_e(d.thing),A=d.cell.cover&&gr[d.cell.cover.id]?.hides;e.set(h,ie,{...v,alpha:A?0:1,depth:m?.id===b?30:3});}Be(),yt();},Be=()=>{dt(e,Ll);let f=Ee();for(let b=0;b<s.rows;b++)for(let d=0;d<s.cols;d++){let h=s.cells[b][d],v=at(a,d,b);for(let[A,N,B]of [["b",h.block,3],["c",h.cover,5]]){if(!N)continue;let Q=gr[N.id],J=Q?.art[Math.min(Q.art.length,Math.max(1,N.hp))-1]??"mg_box",$e=e.create();e.set($e,Ll,{key:`${A}${d},${b}`}),e.set($e,K,{x:v.x,y:v.y}),e.set($e,ie,{shape:"sprite",art:J,w:f*.98,h:f*.98,depth:B,alpha:N.id==="bubble"&&(N.ttl??99)<=3?.55+.4*Math.abs(Math.sin(e.time*6)):1});}}},ee=()=>{dt(e,Ud),zt(e,"board",a.top+a.cell*s.rows*.3);let f=Ee(),b=at(a,(s.cols-1)/2,(s.rows-1)/2),d=f*.22,h=(v,A,N)=>{let B=e.create();e.set(B,Ud,{i:0}),e.set(B,K,{x:v,y:A}),e.set(B,ie,N);};h(b.x,b.y,{shape:"sprite",art:"panel",w:f*s.cols+d*2,h:f*s.rows+d*2,color:"panel",alpha:.9,depth:-10});for(let v=0;v<s.rows;v++)for(let A=0;A<s.cols;A++){if(s.cells[v][A].hole)continue;let N=at(a,A,v);h(N.x,N.y,{shape:"sprite",art:"cell",w:f-3,h:f-3,color:(v+A)%2?"panel":"ground",alpha:.85,depth:-9});}},Ie=()=>Math.max(1,n.def.visible),nt=f=>{let b=He(e),d=Ie(),h=Math.min(b.w*.3,Ee()*2.6),v=b.w/2+(f-(d-1)/2)*(h+Ee()*.2),A=h*(d>2?.62:.72),N=b.h*.118+A/2,B=a.top-Ee()*.18;return {x:v,y:N,w:h,h:A,feet:B}},ht=(f,b,d)=>{let h=nt(f),v=Math.max(24,(h.feet-(h.y+h.h/2))*1.05),A=d?-v:h.x,N=e.create();return e.set(N,K,{x:A,y:h.feet-v/2}),e.set(N,ie,{shape:"actor",cast:b.vip?"boss":"helper",variant:b.vip?7:o.int(0,99),h:v,pose:d?"walk":"idle",facing:1,speed:Sl,depth:6}),e.set(N,uo,{slot:f,to:h.x,leaving:-1}),N},Ae=f=>{for(let b=0;b<Ie();b++){if($.some(h=>h.slot===b))continue;let d=k.shift();d&&$.push({order:d,slot:b,customer:ht(b,d,f)});}},Gt=(f,b)=>{for(let d of f.query(uo)){let h=f.need(d,uo),v=f.need(d,K),A=f.need(d,ie);if(A.shape!=="actor")continue;if(h.leaving>=0){h.leaving+=b,h.leaving>.7&&(A.pose="walk",A.facing=1,v.x+=Sl*1.4*b);continue}let N=h.to-v.x;Math.abs(N)>1?(v.x+=Math.sign(N)*Math.min(Math.abs(N),Sl*2*b),A.pose="walk",A.facing=N>0?1:-1):A.pose==="walk"&&(v.x=h.to,A.pose="idle");}},Xe=f=>Math.max(1,Math.round(f.wants.reduce((b,d)=>b+d.level,0)*r("orderReward")*(f.vip?3:1)*(1+mo(e,"meta:reward")))),rt=f=>{let b=Dn(s,f.order.wants);if(!b)return false;let d=nt(f.slot);for(let A of b){let N=at(a,A.col,A.row);G(e,{kind:"burst",x:N.x,y:N.y,color:"coin",n:8,size:Ee()*.8}),wl(s,A);}let h=Xe(f.order);Je(e,"coins",h),Je(e,"score",h*25),G(e,{kind:"burst",x:d.x,y:d.y,color:"coin",n:14,size:d.w*.8}),G(e,{kind:"pop",x:d.x,y:d.y-d.h*.5,text:`+${h}`,color:"coin",size:Math.round(d.h*.42)}),e.emit("coin-collected",{value:h}),e.emit("order-filled",{reward:h,vip:f.order.vip}),Lt(e,"merge-order"),ne++;let v=e.get(f.customer,uo);return v&&(v.leaving=0,Fe(e,f.customer,"cheer"),_n(e,f.customer,2.4)),$=$.filter(A=>A!==f),Ae(true),Te(),$.length===0&&k.length===0&&Et(),true},lt=(f,b,d,h,v,A)=>{let N=Math.max(8,h*.11);Ne(`${f}:bg`,b,d,{shape:"rect",w:h,h:N,color:"#000000",alpha:.5,radius:N/2,depth:69});let B=Math.max(1,(h-4)*Math.max(0,Math.min(1,v)));Ne(`${f}:fill`,b-(h-4)/2+B/2,d,{shape:"rect",w:B,h:N-4,color:A,radius:(N-4)/2,depth:69.1});},ft=()=>{let f=He(e),b=Math.min(f.w,f.h),d=Ee(),h=(V,te,Y,w,S="text",l=b*.045,E=70)=>Ne(V,te,Y,{shape:"text",text:w,size:Math.round(l),color:S,bold:true,depth:E});Re=[],tt.clear();let v=f.h*.085;Ne("h:en:i",f.w*.1,v,{shape:"sprite",art:"mg_energy",w:b*.07,h:b*.07,depth:70}),h("h:en",f.w*.1+b*.075,v,String(O),O<=3&&z===0?"danger":"text",b*.06),z>0&&h("h:free",f.w*.1+b*.17,v,`+${z}`,"secondary",b*.04);let A=$.length+k.length;Ne("h:ord:i",f.w*.8,v,{shape:"sprite",art:"ticket",w:b*.075,h:b*.05,color:"panel",depth:70}),h("h:ord",f.w*.8+b*.08,v,String(A),"text",b*.05);for(let V of $){let te=nt(V.slot);Dn(s,V.order.wants)!==null&&Ne(`h:t${V.slot}:glow`,te.x,te.y,{shape:"rect",w:te.w*1.08,h:te.h*1.14,color:"accent",alpha:.45+.3*Math.sin(e.time*6),radius:te.h*.2,depth:7.9}),Ne(`h:t${V.slot}`,te.x,te.y,{shape:"sprite",art:"ticket",w:te.w,h:te.h,color:V.order.vip?"coin":"panel",depth:8});let w=V.order.wants.length,S=Math.min(te.h*.58,te.w*.86/w);V.order.wants.forEach((l,E)=>{let T=te.x+(E-(w-1)/2)*S*1.05,c=te.y-te.h*.12,y=Cr(l.chain);Ne(`h:t${V.slot}:${E}`,T,c,{shape:"sprite",art:`${y?.prefix??"item"}${Math.min(l.level,y?.levels??8)}`,w:S,h:S,depth:8.1}),Dn(s,[l])?h(`h:t${V.slot}:${E}:ok`,T+S*.32,c+S*.32,"\u2713","accent",S*.42,8.2):h(`h:t${V.slot}:${E}:lv`,T+S*.34,c+S*.34,String(l.level),"coin",S*.3,8.2);}),Ne(`h:t${V.slot}:c`,te.x-te.w*.1,te.y+te.h*.3,{shape:"sprite",art:"coin",w:te.h*.19,h:te.h*.19,depth:8.1}),h(`h:t${V.slot}:cv`,te.x+te.w*.07,te.y+te.h*.3,String(Xe(V.order)),"coin",te.h*.2,8.1),Re.push({id:`order${V.slot}`,x:te.x,y:te.y,r:te.w*.5});}let N=Le();for(let V of Pr(s)){if(V.cell.cover&&gr[V.cell.cover.id]?.hides)continue;let te=i.get(V.thing.id);if(te===void 0)continue;let Y=e.need(te,K),w=m?.id===V.thing.id?31:6;if(V.thing.kind==="gen")for(let S=0;S<V.thing.level;S++)Ne(`h:i${V.thing.id}:s${S}`,Y.x+(S-(V.thing.level-1)/2)*d*.2,Y.y+d*.38,{shape:"circle",r:d*.075,color:"coin",depth:w});else V.thing.kind==="item"&&(N.some(S=>S.chain===V.thing.chain&&S.level===V.thing.level)&&(Ne(`h:i${V.thing.id}:ok`,Y.x+d*.3,Y.y-d*.3,{shape:"circle",r:d*.12,color:"accent",depth:w}),h(`h:i${V.thing.id}:okt`,Y.x+d*.3,Y.y-d*.3,"\u2713","#ffffff",d*.18,w+.1)),h(`h:i${V.thing.id}:lv`,Y.x+d*.3,Y.y+d*.3,String(V.thing.level),"coin",d*.22,w));}let B=a.top+d*s.rows+(f.h-(a.top+d*s.rows))*.5,Q=Math.min(b*.075,(f.h-(a.top+d*s.rows))*.38),J=f.w*.3,$e=F>=ue();Re.push({id:"skill",x:J,y:B,r:Q*1.2}),$e&&Ne("h:skill:glow",J,B,{shape:"circle",r:Q*1.28,color:"secondary",alpha:.5+.3*Math.sin(e.time*7),depth:68.9}),Ne("h:skill:bg",J,B,{shape:"circle",r:Q,color:"panel",alpha:.95,depth:69}),Ne("h:skill:i",J,B,{shape:"sprite",art:Me().art,w:Q*1.4,h:Q*1.4,alpha:$e?1:.45,depth:69.2}),lt("h:charge",J+Q*2.6,B,Q*2.4,F/ue(),"secondary");let Se=f.w*.88;Re.push({id:"bin",x:Se,y:B,r:Q*1.1});let Ye=m?i.get(m.id):void 0,pt=Ye!==void 0?e.need(Ye,K):null,ze=pt!==null&&Math.hypot(pt.x-Se,pt.y-B)<Q*1.3;Ne("h:bin:bg",Se,B,{shape:"circle",r:Q,color:ze?"danger":"panel",alpha:.95,depth:69}),Ne("h:bin",Se,B,{shape:"sprite",art:"mg_bin",w:Q*1.3,h:Q*1.3,alpha:m?1:.7,depth:69.2}),(de===null||!e.isAlive(de))&&(de=e.create(),e.set(de,ie,{shape:"actor",cast:Ce().cast,h:Q*2.6,pose:"idle",facing:1,depth:20})),e.set(de,K,{x:f.w*.11,y:B-Q*.1});let le=e.need(de,ie);le.shape==="actor"&&(le.h=Q*2.6),e.vars.mg_buttons=Re.map(V=>`${V.id}@${Math.round(V.x)},${Math.round(V.y)}`).join(";"),se();},yt=()=>{e.vars.energy=O,e.vars.mg_free=z,e.vars.mg_charge=Math.floor(F),e.vars.orders_left=$.length+k.length,e.vars.mg_orders=$.slice().sort((f,b)=>f.slot-b.slot).map(f=>f.order.wants.map(b=>`${b.chain}:${b.level}`).join("+")).join("|"),e.vars.level_progress=n.orders.length?ne/n.orders.length:0;},ut=()=>{dt(e,ls),dt(e,Ll),dt(e,Xd),dt(e,uo),i.clear(),p.clear(),de!==null&&e.isAlive(de)&&e.destroy(de),de=null,n=po(mo(e,"meta:chapter")||1,r("difficulty")),s=Ml(An[n.def.board]??An.start,n.def.chains,()=>o.next()),a=oe(),ee(),m=null,$=[],k=[...n.orders],O=Math.max(0,n.energy+Math.round(mo(e,"meta:energy"))),C=O,z=0,F=0,ne=0,X=0,ye=0,be=0,fe=false,we=false,e.vars.mg_level=n.level,e.vars.mg_world=n.world,e.vars.coins=0,e.vars.score=0,e.vars.stars=0,e.vars.reviving=false,Ae(false),Te();},Et=()=>{we||(e.vars.stars=Math.min(fe?1:3,ya(O/Math.max(1,C))),Je(e,"score",O*r("energyBonus")),G(e,{kind:"flash",color:"coin"}),Ze("cleared"));},Ze=f=>{if(we)return;we=true;let b=f==="cleared";b&&e.vars["meta:first_clear"]===true&&Je(e,"coins",n.firstClearGold),b||(e.vars.stars=0),e.vars.reviving=false,yt(),e.emit(Xt,{reason:f,stats:{chapter:n.level,seconds:Math.floor(ye),cleared:b,stars:Number(e.vars.stars??0),coins:Number(e.vars.coins??0),orders:ne,merges:X}});},Ge=()=>{if(e.vars.revive_ready===true&&!fe){e.vars.reviving=true,e.emit(tr,{});return}Ze("out-of-energy");},It=()=>{ce()&&(fe=true,e.vars.reviving=false,O+=ga,El(s,"joker",{col:Math.floor(s.cols/2),row:Math.floor(s.rows/2)}),G(e,{kind:"flash",color:"coin"}),Te());},Qe=()=>{if(O>0||z>0||F>=ue()||$.some(d=>Dn(s,d.order.wants))||Fd(s))return true;let f=[...Le(),...k.flatMap(d=>d.wants)],b=Pr(s);for(let d of b)if(!(!ho(s,d.at)||d.thing.kind!=="item")&&f.some(h=>h.chain===d.thing.chain&&h.level>d.thing.level)&&b.some(h=>ka(d.thing,h.cell)))return true;return false},Kt=f=>{let b=Ee(),d=at(a,f.at.col,f.at.row);if(f.kind==="merge"||f.kind==="joker"){let h=s.cells[f.at.row][f.at.col].thing,v=Cr(h.chain)?.color??"coin";G(e,{kind:"ring",x:d.x,y:d.y,color:v,size:b*1.4}),G(e,{kind:"burst",x:d.x,y:d.y,color:"coin",n:8,size:b*.8});let A=i.get(h.id);A!==void 0&&(e.need(A,K).scale=1.35),X++,F=Math.min(ue(),F+1+mo(e,"meta:charge")),Je(e,"score",Math.pow(2,h.level)*r("mergeScore")),e.emit("items-merged",{level:h.level,chain:h.chain}),Lt(e,"merge-merge"),h.kind==="item"&&h.level===en(h.chain)&&G(e,{kind:"flash",color:"coin"});for(let N of $)N.order.wants.some(B=>B.chain===h.chain&&B.level===h.level)&&Fe(e,N.customer,"wave");}f.kind==="split"&&G(e,{kind:"ring",x:d.x,y:d.y,color:"secondary",size:b*1.2}),f.freed&&e.emit("obstacle-cleared",{kind:f.freed});for(let h of f.hits){let v=at(a,h.at.col,h.at.row);G(e,{kind:"burst",x:v.x,y:v.y,color:h.id==="fog"?"#ffffff":"ground",n:h.gone?10:4,size:b*.9}),h.gone&&e.emit("obstacle-cleared",{kind:h.id});}f.coins>0&&(Je(e,"coins",f.coins),e.emit("coin-collected",{value:f.coins}),G(e,{kind:"pop",x:d.x,y:d.y-b*.5,text:`+${f.coins}`,color:"coin",size:Math.round(b*.4)})),f.hits.length&&G(e,{kind:"shake",power:.25});},Yt=f=>{if(O<=0&&z<=0){let A=at(a,f.col,f.row);G(e,{kind:"pop",x:A.x,y:A.y-Ee()*.5,text:"0",color:"danger",size:Math.round(Ee()*.4)});return}let b=Vd(s,f,Pe()),d=at(a,f.col,f.row);if(!b){G(e,{kind:"shake",power:.2}),G(e,{kind:"pop",x:d.x,y:d.y-Ee()*.5,text:"\u2715",color:"danger",size:Math.round(Ee()*.45)});return}z>0?z--:O--,Lt(e,"merge-generate");let h=i.get(s.cells[f.row][f.col].thing.id);h!==void 0&&(e.need(h,K).scale=1.2),G(e,{kind:"burst",x:d.x,y:d.y,color:Cr(b.thing.chain)?.color??"accent",n:6,size:Ee()*.7}),e.emit("item-spawned",{level:b.thing.level,chain:b.thing.chain}),Te();let v=i.get(b.thing.id);v!==void 0&&e.set(v,K,{x:d.x,y:d.y,scale:.4});for(let A of b.burst){let N=at(a,A.col,A.row);G(e,{kind:"burst",x:N.x,y:N.y,color:"#ffffff",n:10,size:Ee()});}},Ft=f=>{let b=Gd(s,f);if(!b)return;let d=at(a,f.col,f.row);G(e,{kind:"ring",x:d.x,y:d.y,color:"coin",size:Ee()*1.6}),b.energy>0&&(O+=b.energy,G(e,{kind:"pop",x:d.x,y:d.y-Ee()*.5,text:`+${b.energy}`,color:"coin",size:Math.round(Ee()*.45)})),Te();for(let h of b.spawned){let v=i.get(h.thing.id);v!==void 0&&e.set(v,K,{x:d.x,y:d.y,scale:.4});}},ur=()=>{let f=Me();if(F<f.charge)return false;let b=1+mo(e,"meta:skill"),d=Math.max(1,Math.round(f.count*b));if(F=0,de!==null&&Fe(e,de,"cheer"),G(e,{kind:"flash",color:"secondary"}),f.effect==="upgrade")for(let h of qd(s,d,[...Le(),...k.slice(0,2).flatMap(v=>v.wants)])){let v=at(a,h.col,h.row);G(e,{kind:"ring",x:v.x,y:v.y,color:"secondary",size:Ee()*1.4});}else if(f.effect==="free")z+=d;else for(let h=0;h<d;h++)El(s,"joker",{col:Math.floor(s.cols/2),row:Math.floor(s.rows/2)});return e.emit("skill-cast",{id:f.id}),Lt(e,"merge-skill"),Te(),true},bt=(f,b)=>Re.find(d=>Math.hypot(f-d.x,b-d.y)<=d.r);e.on(Nt,f=>{let b=f;if(!(!st(e)||hn(e)||we||ce())){if(b.type==="press"){Bt(e),be=0;let d=Ur(a,b.x,b.y);if(!d||!ho(s,d))return;let h=s.cells[d.row][d.col].thing.id,v=i.get(h);if(v===void 0)return;let A=e.need(v,K);m={id:h,from:d,dx:A.x-b.x,dy:A.y-b.y,x0:b.x,y0:b.y},e.need(v,ie).depth=30;}else if(b.type==="move"&&m){let d=i.get(m.id);if(d===void 0)return;let h=e.need(d,K);h.x=b.x+m.dx,h.y=b.y+m.dy,h.scale=1.12;}else if(b.type==="release"&&m){let d=m;m=null;let h=i.get(d.id);if(h!==void 0&&(e.need(h,ie).depth=3),Math.hypot(b.x-d.x0,b.y-d.y0)<Ee()*.3)return;let v=bt(b.x,b.y),A=s.cells[d.from.row][d.from.col].thing;if(v?.id==="bin"&&A&&A.kind!=="gen"){wl(s,d.from),Lt(e,"merge-bin"),Te();return}let N=v?.id.startsWith("order")?$.find(J=>`order${J.slot}`===v.id):void 0;if(N&&A?.kind==="item"&&N.order.wants.some(J=>J.chain===A.chain&&J.level===A.level)&&rt(N))return;let B=Ur(a,b.x,b.y);if(!B)return;let Q=jd(s,d.from,B);Q.kind!=="none"&&Kt(Q),Te();}else if(b.type==="tap"){be=0;let d=bt(b.x,b.y);if(d?.id==="skill"){ur();return}if(d?.id.startsWith("order")){let A=$.find(N=>`order${N.slot}`===d.id);A&&rt(A);return}let h=Ur(a,b.x,b.y),v=h?s.cells[h.row][h.col].thing:null;if(!h||!v||!ho(s,h))return;if(v.kind==="gen")Yt(h);else if(v.kind==="special")Ft(h);else {let A=$.find(N=>N.order.wants.some(B=>B.chain===v.chain&&B.level===v.level)&&Dn(s,N.order.wants));A&&rt(A);}}}}),e.on(Ut,()=>{ut(),e.vars.level=n.level;}),e.on(Qt,ut),e.on(rr,It),e.on(nr,()=>{ce()&&(e.vars.reviving=false,Ze("out-of-energy"));}),e.on(Zt,f=>{tt.clear(),se(),Re=[],de!==null&&e.isAlive(de)&&it(e,de,f.reason==="cleared"?"dance":"idle");}),e.on(qt,()=>{a=oe(),ee();for(let f of $){let b=nt(f.slot),d=e.get(f.customer,uo);d&&(d.to=b.x);let h=e.get(f.customer,K),v=Math.max(24,(b.feet-(b.y+b.h/2))*1.05);h&&e.set(f.customer,K,{x:b.x,y:b.feet-v/2});let A=e.get(f.customer,ie);A?.shape==="actor"&&(A.h=v);}Te();});let D=f=>{let b=Math.min(1,f*16);for(let[d,h]of i){if(m?.id===d)continue;let v=e.get(h,ls);if(!v)continue;let A=e.need(h,K),N=at(a,v.col,v.row);A.x+=(N.x-A.x)*b,A.y+=(N.y-A.y)*b;let B=A.scale??1;A.scale=B+(1-B)*Math.min(1,f*10);}},u=f=>{let b=$.find(h=>Dn(s,h.order.wants));if(b&&(!vt(f,"merge-order")||be>6)){let h=nt(b.slot);return kt(f,"tap",{x:h.x,y:h.y},void 0,Ee()*1.1)}let d=Kd(s,{gens:false});if(d&&(!vt(f,"merge-merge")||be>6))return kt(f,"swipe",at(a,d[0].col,d[0].row),at(a,d[1].col,d[1].row),Ee()*1.1);if(F>=ue()&&!vt(f,"merge-skill")){let h=Re.find(v=>v.id==="skill");if(h)return kt(f,"tap",h,void 0,Ee()*1.1)}if(!vt(f,"merge-generate")||be>6){let h=Pr(s).find(v=>v.thing.kind==="gen"&&!v.cell.cover);h&&(O>0||z>0)&&kt(f,"tap",at(a,h.at.col,h.at.row),void 0,Ee()*1.1);}},g=0;e.addSystem({id:"merge",order:0,run(f,b){Gt(f,b),D(b),!(!st(f)||we)&&(ye+=b,be+=b,ft(),++g%20===0&&s.cells.some(d=>d.some(h=>h.cover?.ttl!==void 0&&h.cover.ttl<=3))&&Be(),!(ce()||m)&&(_r(f)||u(f),Qe()||Ge()));}}),ut();}};var jt=10,Qd={id:"start",needs:[],rows:["..............","..............","..............","..............","..............","..............",".......o.o.o..",".P............","##############","##############"]},Yd={id:"checkpoint",needs:[],rows:["..........","..........","..........","..........","..........","..........","...o..o...","....C.....","##########","##########"]},Jd={id:"end",needs:[],rows:["..............","..............","..............","..............","..............","..............",".....o.o......","..........E...","##############","##############"]},ef={id:"boss",needs:[],rows:["..................","..................","..................","..................","...===......===...","..................","..................","..................","##################","##################"]},Ma=[{id:"walk",needs:["walker"],rows:["..............","..............","..............","..............",".....ooo......","....o...o.....","..............",".........W....","##############","##############"]},{id:"two-walkers",needs:["walker"],rows:["..............","..............","..............","......*.......",".....===......","..............","..o........o..","...W......W...","##############","##############"]},{id:"gaps",needs:["gaps"],rows:["..............","..............","..............","..............","..............","....o.....o...","...o.o...o.o..","..............","###...###...##","###...###...##"]},{id:"stairs",needs:["stairs"],rows:["..............","...........*..","..........===.","..............",".......###....",".......###.o..","....##########","....##########","##############","##############"]},{id:"spikes",needs:["spikes"],rows:["..............","..............","..............","..............","..............",".....ooo......","....=====.....","..............","###^^^^^^^####","##############"]},{id:"pits",needs:["pits"],rows:["..............","..............","..............","..............","......o.......",".....===...o..","..o.......===.",".===..........","##..........##","##..........##"]},{id:"spring",needs:["spring"],rows:["..............",".........*....","........####..","..............","..............","..............","..............","...T..........","##############","##############"]},{id:"hopper",needs:["hopper"],rows:["..............","..............","..............","..............",".....o...o....","..............","..............",".......J......","##############","##############"]},{id:"crumble",needs:["crumble"],rows:["..............","..............","..............","..............","..............","...o.o.o.o....","...______.....","..............","##........####","##........####"]},{id:"spiky",needs:["spiky"],rows:["..............","..............","..............","..............","..............","......ooo.....","..............",".......S......","##############","##############"]},{id:"moving",needs:["moving"],rows:["..............","..............","..............","..............",".....o..o.....","..............",".....M........","..............","##..........##","##..........##"]},{id:"flyer",needs:["flyer"],rows:["..............","..............","..............","......F.......","..............","..............","...o......o...","..............","##############","##############"]},{id:"key",needs:["key"],rows:["..............","..............","..K...........",".===..........","..............",".......===....","..............","...........B..","##############","##############"]},{id:"gunner",needs:["gunner"],rows:["..............","..............","..............","..............","..............",".....o.o......","....=====.....","...........G..","##############","##############"]},{id:"heart",needs:["walker","stairs"],rows:["..............","..............","..*...........","..............","......H.......",".....===......","..............","...W......W...","##############","##############"]},{id:"secret-high",needs:["spring","gaps"],rows:["..............","..*...........",".===..........","..............","..............","..............","........T.....","..............","#####...######","#####...######"]}],_l=4,On=5,wa=_l*On,$a={walker:1,gaps:1,spikes:2,stairs:2,pits:3,spring:3,hopper:4,crumble:4,spiky:6,moving:6,flyer:7,key:8,gunner:9},Rl=[0,9,24,39];function yo(e,t=.5){let r=Math.max(1,Math.min(wa,Math.floor(e))),o=Math.ceil(r/On),n=r-(o-1)*On,s=n===On,a=Object.keys($a).filter(p=>$a[p]<=r),i=Object.keys($a).find(p=>$a[p]===r)??null;return {level:r,world:o,index:n,boss:s,features:a,fresh:i,rooms:s?2:3+Math.min(5,Math.floor((r-1)/2)),pace:.85+t*.3+(r-1)*.02,bossHp:3+o,firstClearGold:(s?150:60)+(r-1)*20}}var Al=e=>Rl[Math.ceil(Math.max(1,e)/On)-1]??0,Tl=[{id:"double",stars:6},{id:"dash",stars:15},{id:"wall",stars:27}],Ea=e=>Tl.filter(t=>e>=t.stars).map(t=>t.id),go=[{id:"hero",cast:"hero",gems:0,perk:"none"},{id:"hero2",cast:"hero2",gems:150,perk:"heart"},{id:"hero3",cast:"hero3",gems:300,perk:"jump"}],Dl="kit-platformer",Ol=[{id:"Hearts",var:"meta:hearts",art:"heart",color:"danger",perLevel:1,unit:"",maxLevel:3,price:150,growth:1.2},{id:"JumpPower",var:"meta:jump",art:"boot",color:"accent",perLevel:2,unit:"%",maxLevel:10,price:40,growth:.15},{id:"Magnet",var:"meta:magnet",art:"magnet",color:"danger",perLevel:10,unit:"%",maxLevel:10,price:30,growth:.12},{id:"Grace",var:"meta:grace",art:"shield",color:"muted",perLevel:.2,unit:"s",maxLevel:10,price:35,growth:.12},{id:"Greed",var:"meta:greed",art:"coin",color:"coin",perLevel:2,unit:"%",maxLevel:25,price:40,growth:.1}],tf={game:"platformer",character:Dl,stats:Ol,heroes:go,levels:wa,firstClearGold:e=>yo(e).firstClearGold,stars:3,starsToEnter:Al};var ou="boss-spawned",su="boss-defeated",Cl="level-cleared",ar=ve("platformer.body"),mt=ve("platformer.thing"),cs=ve("platformer.strip"),wr=ve("platformer.hero"),rf=ve("platformer.hud"),gn=(e,t)=>{let r=Number(e.vars[t]??0);return Number.isFinite(r)?r:0},au=6,Cn=40,iu=3.3,lu=6.8,cu=.7,nf=1.3,Sa={id:"platformer",version:2,engines:["phaser"],requires:["round"],params:{difficulty:{type:"number",default:.5,min:0,max:1},lives:{type:"number",default:3,min:1,max:9,integer:true},coinScore:{type:"number",default:10,min:0,max:1e3,integer:true},starScore:{type:"number",default:300,min:0,max:1e4,integer:true},clearBonus:{type:"number",default:500,min:0,max:1e5,integer:true},graceTime:{type:"number",default:1.2,min:0,max:5},doubleJump:{type:"boolean",default:false}},setup({world:e,params:t}){let r=D=>yr(t,D),o=Jn(e),n=yo(1,r("difficulty")),s=[],a=0,i=null,p=0,m={x:2,y:8},$=3,k=3,O=0,C=false,z=false,F=0,ne=0,X=0,ye=false,be=false,fe=[],we=[false,false,false],de=new Map,Re=new Map,Ce=()=>go.find(D=>D.id===e.vars["meta:hero"])??go[0],Me=()=>e.vars.reviving===true,ce=()=>{let D=Number(e.vars.view_w??720),u=Number(e.vars.view_h??1280);return Math.min(D/8,u*.66/10)},ue=()=>Number(e.vars.view_h??1280)*.86-10*ce(),Pe=()=>Number(e.vars.view_w??720)/ce(),Le=(D,u)=>{if(u<0)return ".";if(D<0||D>=a)return "#";if(u>=10)return ".";let g=s[u]?.[D]??".";return g==="_"&&(de.get(`${D},${u}`)??0)>.5?".":g},oe=D=>D==="#",Ee=D=>D==="="||D==="_"||D==="^",tt=()=>{for(let N of e.query(mt))e.destroy(N);for(let N of e.query(cs))e.destroy(N);de.clear(),n=yo(gn(e,"meta:chapter")||1,r("difficulty"));let D=e.rng.stream(`platformer-level-${n.level}`),u=Ma.filter(N=>N.needs.every(B=>n.features.includes(B))),g=[],f=n.fresh!==null?u.find(N=>N.needs.includes(n.fresh)):void 0;for(f&&g.push(f);g.length<n.rooms;)g.push(D.pick(u));let b=Math.ceil(g.length/2),d=[Qd,...g.slice(0,b),Yd,...g.slice(b),n.boss?ef:Jd];s=Array.from({length:10},(N,B)=>d.map(Q=>Q.rows[B]??"").join("")),a=s[0].length;let h=[];for(let N=0;N<10;N++)for(let B=0;B<a;B++)s[N][B]==="*"&&h.push({c:B,r:N});let v=h.length<=3?h:[h[0],h[Math.floor(h.length/2)],h[h.length-1]];for(let N=v.length;N<3;N++)v.push({c:Math.floor(a*(N+1)/4),r:5});let A=0;for(let N=0;N<10;N++)for(let B=0;B<a;B++){let Q=s[N][B],J={x:B+.5,y:N+1};Q==="P"?m={...J}:Q==="o"?ke("coin",J.x,N+.85,.5,.5):Q==="H"&&A++<1?ke("heart",J.x,N+.9,.6,.6):Q==="K"?ke("key",J.x,N+.9,.6,.6):Q==="B"?ke("chest",J.x,J.y,1,.8):Q==="T"?ke("spring",J.x,J.y,1,.5):Q==="M"?ke("mover",J.x+.5,N+.4,2,.4).baseX=J.x+.5:Q==="C"?ke("checkpoint",J.x,J.y,.6,1.6):Q==="E"?ke("flag",J.x,J.y,.8,2.6):Q==="W"?ke("walker",J.x,J.y,.8,1):Q==="S"?ke("spiky",J.x,J.y,.8,1):Q==="J"?ke("hopper",J.x,J.y,.8,1):Q==="F"?ke("flyer",J.x,J.y,.9,.8):Q==="G"&&ke("gunner",J.x,J.y,.8,1.1),/[PoHKBTMCEWSJFG*]/.test(Q)&&(s[N]=Ne(s[N],B,"."));}if(v.forEach((N,B)=>ke("star",N.c+.5,N.r+.95,.85,.85).tag=String(B)),n.boss){let N=ke("boss",a-5,8,2.2,2.4);N.hp=n.bossHp,N.tag="walk",N.t=2;}_e();},Ne=(D,u,g)=>D.slice(0,u)+g+D.slice(u+1),se=(D,u,g,f)=>{switch(D){case "walker":return {shape:"actor",cast:"foe",h:g*f*1.35,pose:"walk",depth:8};case "spiky":return {shape:"actor",cast:"foe2",h:g*f*1.4,pose:"walk",depth:8};case "hopper":return {shape:"actor",cast:"foe3",h:g*f*1.35,pose:"idle",depth:8};case "flyer":return {shape:"actor",cast:"foe5",h:g*f*1.4,pose:"air",depth:8};case "gunner":return {shape:"actor",cast:"foe4",h:g*f*1.3,pose:"idle",depth:8};case "boss":return {shape:"actor",cast:"boss",h:g*f*1.2,pose:"walk",depth:8};case "bullet":return {shape:"sprite",art:"shot",color:"danger",w:u*f,h:g*f,depth:9};case "wave":return {shape:"sprite",art:"burst",color:"danger",w:u*f,h:g*f,depth:9};case "coin":return {shape:"sprite",art:"coin",w:u*f,h:g*f,depth:7};case "star":return {shape:"sprite",art:"bigstar",w:u*f,h:g*f,depth:7};case "heart":return {shape:"sprite",art:"heart",w:u*f,h:g*f,depth:7};case "key":return {shape:"sprite",art:"key",w:u*f,h:g*f,depth:7};case "chest":return {shape:"sprite",art:"chest",w:u*f,h:g*f*1.1,depth:6};case "spring":return {shape:"sprite",art:"spring",w:u*f,h:g*f*1.4,depth:6};case "mover":return {shape:"tile",art:"platform",w:u*f,h:g*f,unit:f,depth:5};case "checkpoint":return {shape:"sprite",art:"flag",color:"muted",w:u*f*1.6,h:g*f,depth:5};case "flag":return {shape:"sprite",art:"flag",w:u*f*1.4,h:g*f,depth:5}}};function ke(D,u,g,f,b){let d=e.create(),h={kind:D,vx:0,vy:0,dir:-1,t:0,baseX:u,baseY:g,hp:1,tag:"",safe:0};return e.set(d,mt,h),e.set(d,ar,{x:u,y:g,w:f,h:b}),e.set(d,K,{x:0,y:0}),e.set(d,ie,se(D,f,b,ce())),e.need(d,mt)}function _e(){for(let u of e.query(cs))e.destroy(u);let D=(Number(e.vars.view_h??1280)-(ue()+10*ce()))/ce()+.5;for(let u=0;u<10;u++){let g=0;for(;g<a;){let f=s[u][g];if(f==="."||f==="_"){f==="_"&&Te("_",g,u,1,.45),g++;continue}let b=f==="#"&&Le(g,u-1)!=="#",d=g;for(;d<a&&s[u][d]===f&&(f!=="#"||Le(d,u-1)!=="#"===b);)d++;if(f==="#"&&b){let h=0;for(;u+h<10&&s[u+h][g]==="#";)h++;Te("#",g,u,d-g,h+(u+h>=10?D:0));}else f!=="#"&&Te(f,g,u,d-g,f==="="?.45:.7);g=d;}}}function Te(D,u,g,f,b){let d=ce(),h=e.create();e.set(h,cs,{char:D}),e.set(h,ar,{x:u+f/2,y:D==="^"?g+1:g+b,w:f,h:b}),e.set(h,K,{x:0,y:0});let v=D==="^"?{shape:"tile",art:"spike",w:f*d,h:b*d,unit:d,depth:4}:D==="#"?{shape:"tile",art:"ground",w:f*d,h:b*d,unit:d*1.2,depth:3}:{shape:"tile",art:"platform",w:f*d,h:b*d,unit:d,depth:3,...D==="_"?{color:"muted",alpha:.85}:{}};e.set(h,ie,v),D==="_"&&e.set(h,mt,{kind:"mover",vx:0,vy:0,dir:0,t:0,baseX:u,baseY:g,hp:0,tag:"crumble",safe:0});}let Be=()=>{(i===null||!e.isAlive(i))&&(i=e.create(),e.set(i,wr,{vx:0,vy:0,grounded:true,facing:1,jumps:0,coyote:0,buffer:0,dash:0,dashCd:0,wall:0,swing:0,swingCd:0}),e.set(i,ar,{x:m.x,y:m.y,w:cu,h:nf}),e.set(i,K,{x:0,y:0})),e.set(i,ie,{shape:"actor",cast:Ce().cast,h:nf*ce()*1.25,pose:"idle",depth:10});},ee=()=>Math.sqrt(2*Cn*iu*(1+gn(e,"meta:jump"))*(Ce().perk==="jump"?1.15:1)),Ie=()=>{if(i===null)return;let D=e.need(i,ar),u=e.need(i,wr);D.x=m.x,D.y=m.y,u.vx=0,u.vy=0;for(let g of e.query(mt))(e.need(g,mt).kind==="bullet"||e.need(g,mt).kind==="wave")&&e.destroy(g);},nt=()=>{Yt(),tt(),k=r("lives")+gn(e,"meta:hearts")+(Ce().perk==="heart"?1:0),$=k,O=0,C=false,z=false,F=0,ne=0,X=0,ye=false,be=!n.boss,we.fill(false),fe=Ea(gn(e,"meta:stars_total")),r("doubleJump")&&!fe.includes("double")&&fe.push("double"),e.vars.abilities=fe.join(","),e.vars.platformer_level=n.level,e.vars.platformer_world=n.world,e.vars.lives=$,e.vars.coins=0,e.vars.score=0,e.vars.stars=0,e.vars.reviving=false,p=0,Be(),Ie(),i!==null&&(e.need(i,wr).facing=1,it(e,i,"idle")),n.boss&&e.emit(ou,{}),It(e);},ht=()=>{!st(e)||Me()||i===null||(e.need(i,wr).buffer=.13);},Ae=()=>{if(i===null)return;let D=e.need(i,wr);D.vy<0&&(D.vy*=.5);},Gt=()=>{if(!st(e)||Me()||i===null||!fe.includes("dash"))return;let D=e.need(i,wr);D.dashCd>0||(D.dash=.2,D.dashCd=.8,D.vy=0,Fe(e,i,"attack"));},Xe=()=>{if(!st(e)||Me()||i===null)return;let D=e.need(i,wr);D.swingCd>0||(D.swing=.16,D.swingCd=.32,Fe(e,i,"attack"));};e.on(Nt,D=>{let u=D;e.vars.started_tick!==e.tick&&(u.type==="key"&&(u.key==="up"||u.key==="action")?ht():u.type==="key-up"&&(u.key==="up"||u.key==="action")?Ae():u.type==="key"&&u.key==="down"?Gt():u.type==="tap"?Xe():u.type==="swipe"&&u.dir==="up"&&ht());});let rt=(D,u)=>{if(!st(D)||C)return;C=true;let g=u==="cleared",f=we.filter(Boolean).length;D.vars.stars=f,g&&D.vars["meta:first_clear"]===true&&Je(D,"coins",n.firstClearGold),D.vars.score=X*r("coinScore")+f*r("starScore")+(g?r("clearBonus"):0),D.vars.reviving=false,g&&D.emit(Cl,{level:n.level}),D.emit(Xt,{reason:u,stats:{chapter:n.level,seconds:Math.floor(F),cleared:g,stars:g?f:0,coins:X,bosses:n.boss&&be?1:0}});},lt=D=>{if(D.vars.revive_ready===true&&!z){D.vars.reviving=true,D.emit(tr,{});return}rt(D,"fell");},ft=D=>{Me()&&(z=true,D.vars.reviving=false,$=Math.max(2,Math.ceil(k/2)),D.vars.lives=$,O=2.5,Ie(),i!==null&&it(D,i,"idle"),G(D,{kind:"flash",color:"coin"}));},yt=(D,u)=>{if(i===null||O>0||C)return;let g=D.need(i,wr);g.dash>0||($--,D.vars.lives=$,D.emit("player-hit",{lives:$}),O=r("graceTime")+gn(D,"meta:grace"),g.vy=-ee()*.55,g.vx=(u===null?-g.facing:Math.sign(D.need(i,ar).x-u)||-g.facing)*5,Fe(D,i,"hit"),G(D,{kind:"shake",power:1.2}),G(D,{kind:"flash",color:"danger"}),$<=0&<(D));},ut=(D,u,g)=>{let f=D.need(u,mt),b=D.need(u,ar),d=ce();G(D,{kind:"burst",x:Ze(b.x),y:Ge(b.y-b.h/2),color:"danger",n:12,size:d*.9}),D.emit("enemy-defeated",{kind:f.kind,by:g}),Je(D,"score",50),D.destroy(u);},Et=(D,u)=>{let g=D.need(u,ar);ne+=1+gn(D,"meta:greed");let f=Math.floor(ne);ne-=f,f>0&&Je(D,"coins",f),X++,D.emit("coin-collected",{value:1}),G(D,{kind:"burst",x:Ze(g.x),y:Ge(g.y-g.h/2),color:"coin",n:6,size:ce()*.6}),D.destroy(u);},Ze=D=>D*ce()-p*ce(),Ge=D=>ue()+D*ce();function It(D){ce();for(let g of D.query(ar)){let f=D.need(g,ar),b=D.get(g,K);if(!b)continue;b.x=Ze(f.x),b.y=Ge(f.y-f.h/2);let d=D.get(g,ie);if(d&&d.shape==="actor"&&D.has(g,mt)){let h=D.need(g,mt);d.facing=h.dir>=0?1:-1,d.alpha=h.safe>0&&Math.floor(D.time*12)%2===0?.35:1,b.y=Ge(f.y)-d.h/2;}if(d&&d.shape==="actor"&&D.has(g,wr)&&(b.y=Ge(f.y)-d.h/2),d&&D.has(g,cs)&&D.need(g,cs).char==="_"){let h=de.get(`${Math.floor(f.x)},${Math.round(f.y-f.h)}`)??0;d.alpha=h>.5?0:h>0?.5+.5*Math.abs(Math.sin(D.time*30)):.85;}}}let Qe=(D,u,g,f)=>{let b=Re.get(D);(b===void 0||!e.isAlive(b))&&(b=e.create(),e.set(b,rf,{id:D}),Re.set(D,b)),e.set(b,K,{x:u,y:g}),e.set(b,ie,f);},Kt=D=>{let u=Re.get(D);u!==void 0&&e.destroy(u),Re.delete(D);};function Yt(){for(let D of Re.values())e.destroy(D);Re.clear(),dt(e,rf);}let Ft=D=>{let u=Number(D.vars.view_w??720),g=Number(D.vars.view_h??1280),f=Math.min(u,g),b=g*.085;Qe("lvl",u*.08,b,{shape:"text",text:`${n.world}-${n.index}`,size:Math.round(f*.042),color:"text",bold:true,depth:42});let d=f*.05;for(let N=0;N<k;N++)Qe(`h${N}`,u*.07+N*d*1.1,b+f*.065,{shape:"sprite",art:"heart",w:d,h:d,alpha:N<$?1:.25,depth:42});for(let N=k;N<12;N++)Kt(`h${N}`);let h=f*.06;for(let N=0;N<3;N++)Qe(`s${N}`,u/2+(N-1)*h*1.15,b,{shape:"sprite",art:"bigstar",w:h,h,alpha:we[N]?1:.25,depth:42});let v=f*.045,A=String(D.vars.coins??0);if(Qe("coin:i",u*.92-A.length*v*.6-v*.7,b,{shape:"sprite",art:"coin",w:v,h:v,depth:42}),Qe("coin",u*.92-A.length*v*.6/2,b,{shape:"text",text:A,size:Math.round(v),color:"text",bold:true,depth:42}),ye?Qe("key",u*.92-v*.3,b+f*.065,{shape:"sprite",art:"key",w:v,h:v,depth:42}):Kt("key"),n.boss){let N=D.query(mt).find(Se=>D.need(Se,mt).kind==="boss"),B=N!==void 0?D.need(N,mt).hp/n.bossHp:0,Q=u*.5,J=Math.max(10,f*.022);Qe("boss:bg",u/2,b+f*.075,{shape:"rect",w:Q,h:J,color:"#000000",alpha:.45,radius:J/2,depth:41});let $e=Math.max(0,(Q-4)*Math.round(B*100)/100);$e<1?Kt("boss:fill"):Qe("boss:fill",u/2-(Q-4)/2+$e/2,b+f*.075,{shape:"rect",w:$e,h:J-4,color:"danger",radius:(J-4)/2,depth:41.1});}};e.on(Ut,()=>{nt(),e.vars.level=n.level;}),e.on(Qt,nt),e.on(rr,()=>ft(e)),e.on(nr,()=>{Me()&&(e.vars.reviving=false,rt(e,"fell"));}),e.on(Zt,D=>{i!==null&&e.isAlive(i)&&it(e,i,D.reason==="cleared"?"dance":"die"),Yt();}),e.on(qt,()=>{zt(e,"side",ue()+8*ce()+2);let D=ce();for(let u of e.query(mt)){let g=e.need(u,mt);if(g.tag==="crumble")continue;let f=e.need(u,ar);e.set(u,ie,se(g.kind,f.w,f.h,D));}_e(),Be(),It(e);}),e.addSystem({id:"platformer",order:0,run(D,u){if(!st(D)||i===null||C||Me())return;F+=u,O>0&&(O=Math.max(0,O-u));let g=D.need(i,ar),f=D.need(i,wr),b=n.pace;for(let[Y,w]of [...de]){let S=w+u;S>3.5?de.delete(Y):de.set(Y,S);}let d=o.axis().x;if(d!==0&&(f.facing=d),f.dash>0)f.dash-=u,f.vx=f.facing*15,f.vy=0;else {let Y=d*au,w=f.grounded?60:32;f.vx+=Math.max(-w*u,Math.min(w*u,Y-f.vx)),f.vy+=Cn*u,f.vy>22&&(f.vy=22);}if(f.dashCd>0&&(f.dashCd-=u),f.swingCd>0&&(f.swingCd-=u),f.swing>0){f.swing-=u;let Y={l:f.facing>0?g.x:g.x-1.4,r:f.facing>0?g.x+1.4:g.x,t:g.y-g.h-.2,b:g.y};for(let w of D.query(mt)){if(!D.isAlive(w)||!D.has(w,mt))continue;let S=D.need(w,mt);if(!["walker","spiky","hopper","flyer","gunner","boss","bullet"].includes(S.kind))continue;let l=D.need(w,ar);l.x+l.w/2<Y.l||l.x-l.w/2>Y.r||l.y-l.h>Y.b||l.y<Y.t||(S.kind==="bullet"?(G(D,{kind:"burst",x:Ze(l.x),y:Ge(l.y-l.h/2),color:"text",n:6,size:ce()*.5}),D.destroy(w)):S.kind==="boss"?ur(D,w,"sword"):ut(D,w,"sword"));}}if(f.coyote=f.grounded?.1:Math.max(0,f.coyote-u),f.buffer>0){f.buffer-=u;let Y=fe.includes("double")&&f.jumps<2;f.coyote>0||f.grounded?(f.vy=-ee(),f.jumps=1,f.buffer=0,f.grounded=false,f.coyote=0):f.wall!==0&&fe.includes("wall")?(f.vy=-ee()*.95,f.vx=-f.wall*7,f.facing=-f.wall,f.jumps=1,f.buffer=0):Y&&f.jumps>=1&&(f.vy=-ee()*.9,f.jumps=2,f.buffer=0,G(D,{kind:"ring",x:Ze(g.x),y:Ge(g.y),color:"text",size:ce()*1.2})),f.buffer===0&&Fe(D,i,"jump");}let h=g.w/2,v=g.x+f.vx*u;f.wall=0;let A=Y=>{let w=[];for(let S=Math.floor(Y-g.h+.05);S<=Math.floor(Y-.05);S++)w.push(S);return w};if(f.vx>0){let Y=Math.floor(v+h);A(g.y).some(w=>oe(Le(Y,w)))&&(v=Y-h-.001,f.grounded||(f.wall=1),f.vx=0);}else if(f.vx<0){let Y=Math.floor(v-h);A(g.y).some(w=>oe(Le(Y,w)))&&(v=Y+1+h+.001,f.grounded||(f.wall=-1),f.vx=0);}f.wall===0&&!f.grounded&&d!==0&&A(g.y).some(Y=>oe(Le(Math.floor(v+d*(h+.05)),Y)))&&(f.wall=d),g.x=Math.max(h,Math.min(a-h,v));let N=g.y,B=g.y+f.vy*u,Q=f.grounded;f.grounded=false;let J=[Math.floor(g.x-h+.05),Math.floor(g.x+h-.05)];if(f.vy>=0){let Y=Math.floor(B);for(let w of J){let S=Le(w,Y),l=Y;if((oe(S)||Ee(S)&&N<=l+.05)&&B>=l){B=l,f.vy=0,f.grounded=true,f.jumps=0,S==="_"&&!de.has(`${w},${Y}`)&&de.set(`${w},${Y}`,.001),S==="^"&&(yt(D,null),f.vy=-ee()*.7,f.grounded=false);break}}}else {let Y=Math.floor(B-g.h);J.some(w=>oe(Le(w,Y)))&&(B=Y+1+g.h,f.vy=0);}g.y=B,!Q&&f.grounded&&Fe(D,i,"jump");for(let Y of D.query(mt)){let w=D.need(Y,mt);if(w.kind!=="mover"||w.tag==="crumble")continue;let S=D.need(Y,ar),l=S.x;w.t+=u,S.x=w.baseX+Math.sin(w.t*.9)*2.2;let E=S.y-S.h;f.vy>=0&&Math.abs(g.x-S.x)<S.w/2+h*.6&&N<=E+.1&&g.y>=E-.05&&(g.y=E,f.vy=0,f.grounded=true,f.jumps=0,g.x+=S.x-l);}if(g.y>12&&(yt(D,null),O=Math.max(O,1),!Me()&&!C&&Ie(),C||Me()))return;let $e={l:g.x-h,r:g.x+h,t:g.y-g.h,b:g.y},Se=Y=>$e.r>Y.x-Y.w/2&&$e.l<Y.x+Y.w/2&&$e.b>Y.y-Y.h&&$e.t<Y.y,Ye=1.2*(1+gn(D,"meta:magnet")),pt=g.x;for(let Y of D.query(mt)){if(!D.isAlive(Y)||!D.has(Y,mt))continue;let w=D.need(Y,mt),S=D.need(Y,ar);switch(w.safe>0&&(w.safe-=u),w.kind){case "walker":case "spiky":{w.vx=w.dir*1.6*b;let l=S.x+w.dir*(S.w/2+.05)+w.vx*u,E=oe(Le(Math.floor(l),Math.floor(S.y-.5))),T=Le(Math.floor(l),Math.floor(S.y));E||!(oe(T)||Ee(T))?w.dir=-w.dir:S.x+=w.vx*u;break}case "hopper":{w.t+=u,w.vy+=Cn*.6*u,S.y+=w.vy*u,S.y>=w.baseY&&(S.y=w.baseY,w.vy=0,w.t>1.5/b&&(w.t=0,w.vy=-Math.sqrt(2*Cn*.6*2.4))),w.dir=pt<S.x?-1:1;break}case "flyer":w.t+=u*b,S.x=w.baseX+Math.sin(w.t*.9)*3,S.y=w.baseY+Math.sin(w.t*1.8)*.9,w.dir=Math.cos(w.t*.9)>=0?1:-1;break;case "gunner":{if(w.dir=pt<S.x?-1:1,w.t+=u,w.t>2.2/b&&Math.abs(pt-S.x)<9){w.t=0;let l=ke("bullet",S.x+w.dir*.6,S.y-.45,.45,.3);l.vx=w.dir*6*b,l.dir=w.dir,Fe(D,Y,"attack");}break}case "bullet":case "wave":if(S.x+=w.vx*u,w.t+=u,w.t>(w.kind==="wave"?2.2:3.5)||oe(Le(Math.floor(S.x),Math.floor(S.y-.1)))){D.destroy(Y);continue}break;case "boss":bt(D,Y,w,S,pt,u);break;case "coin":Math.hypot(S.x-g.x,S.y-(g.y-g.h/2))<Ye&&Ye>1.21&&(S.x+=(g.x-S.x)*Math.min(1,u*10),S.y+=(g.y-g.h/2-S.y)*Math.min(1,u*10));break;}if(!(!D.isAlive(Y)||!Se(S))){switch(w.kind){case "coin":Et(D,Y);break;case "star":{let l=Number(w.tag);we[l]=true,D.vars.stars=we.filter(Boolean).length,D.emit("star-collected",{index:l}),G(D,{kind:"ring",x:Ze(S.x),y:Ge(S.y-S.h/2),color:"coin",size:ce()*2.4}),G(D,{kind:"flash",color:"coin"}),D.destroy(Y);break}case "heart":$=Math.min(k,$+1),D.vars.lives=$,G(D,{kind:"ring",x:Ze(S.x),y:Ge(S.y-S.h/2),color:"danger",size:ce()*1.6}),D.destroy(Y);break;case "key":ye=true,G(D,{kind:"ring",x:Ze(S.x),y:Ge(S.y-S.h/2),color:"coin",size:ce()*1.6}),D.destroy(Y);break;case "chest":if(ye&&w.tag!=="open"){w.tag="open",ye=false;for(let E=0;E<15;E++)ne+=1+gn(D,"meta:greed"),X++;let l=Math.floor(ne);ne-=l,Je(D,"coins",l),G(D,{kind:"burst",x:Ze(S.x),y:Ge(S.y-S.h/2),color:"coin",n:24,size:ce()*1.4}),G(D,{kind:"pop",x:Ze(S.x),y:Ge(S.y-S.h*1.4),text:"+15",color:"coin",size:Math.round(ce()*.5)});}break;case "spring":f.vy>0&&g.y-(S.y-S.h)<.5&&(f.vy=-Math.sqrt(2*Cn*lu),f.jumps=1,G(D,{kind:"ring",x:Ze(S.x),y:Ge(S.y-S.h),color:"accent",size:ce()*1.4}));break;case "checkpoint":if(w.tag!=="on"){w.tag="on",m={x:S.x,y:S.y};let l=D.need(Y,ie);l.shape==="sprite"&&(l.color="accent"),D.emit("checkpoint",{}),G(D,{kind:"ring",x:Ze(S.x),y:Ge(S.y-S.h/2),color:"accent",size:ce()*2});}break;case "flag":if(be){rt(D,"cleared");return}break;case "walker":case "hopper":case "flyer":case "gunner":case "spiky":case "boss":{let l=f.vy>0&&g.y-(S.y-S.h)<.55&&w.kind!=="spiky";f.dash>0&&w.kind!=="boss"?ut(D,Y,"dash"):l?(f.vy=-ee()*.65,f.jumps=1,w.kind==="boss"?ur(D,Y,"stomp"):ut(D,Y,"stomp")):yt(D,S.x);break}case "bullet":case "wave":yt(D,S.x),D.destroy(Y);break;}if(C||Me())return}}let ze=Pe(),le=Math.max(0,Math.min(Math.max(0,a-ze),g.x-ze*.4+f.facing*ze*.08)),V=p;p+=(le-p)*Math.min(1,u*6),Zo(D,(p-V)*ce()),D.vars.level_progress=Math.min(1,g.x/Math.max(1,a));let te=D.need(i,ie);te.shape==="actor"&&(te.facing=f.facing>=0?1:-1,te.pose=f.grounded?Math.abs(f.vx)>.5?"run":"idle":"air",te.speed=Math.abs(f.vx)*ce(),te.alpha=O>0&&Math.floor(D.time*12)%2===0?.35:1),It(D),Ft(D);}});function ur(D,u,g){let f=D.need(u,mt);f.safe>0||(f.hp--,f.safe=1,Fe(D,u,"hit"),G(D,{kind:"shake",power:1}),f.hp<=0&&(be=true,D.emit(su,{}),ut(D,u,g),ke("flag",a-2,8,.8,2.6)));}function bt(D,u,g,f,b,d){if(g.t-=d,g.vy+=Cn*d,f.y=Math.min(g.baseY,f.y+g.vy*d),f.y>=g.baseY){if(g.tag==="slam-air"){g.tag="walk",g.t=1.6,G(D,{kind:"shake",power:1.4});for(let h of [-1,1]){let v=ke("wave",f.x+h*1.2,g.baseY,.9,.6);v.vx=h*8*n.pace;}}g.vy=0;}if(g.tag==="walk"){if(g.dir=b<f.x?-1:1,f.x+=g.dir*1.4*n.pace*d,g.t<=0){let h=Math.floor(D.rng.next()*3);if(h===0)g.tag="charge",g.t=1.1,g.vx=g.dir*9*n.pace,it(D,u,"run");else if(h===1)g.tag="slam-air",g.vy=-Math.sqrt(2*Cn*4),Fe(D,u,"jump");else {g.tag="walk",g.t=2.4;for(let v of [a-15,a-3])ke("walker",v,g.baseY,.8,1).dir=v<f.x?1:-1;Fe(D,u,"cheer");}}}else g.tag==="charge"&&(f.x+=g.vx*d,(g.t<=0||oe(Le(Math.floor(f.x+Math.sign(g.vx)*1.2),Math.floor(g.baseY-1))))&&(g.tag="walk",g.t=1.8,it(D,u,"walk")));f.x=Math.max(a-17.5,Math.min(a-1.2,f.x));}zt(e,"side",ue()+8*ce()+2),nt();}};var pr=5,La=6,_a=6,Ir={blaster:{id:"blaster",art:"shot",color:"coin",damage:[10,13,15,18,24],cooldown:[.8,.7,.62,.55,.42],count:[1,1,2,2,3],pierce:[1,1,1,2,3]},blades:{id:"blades",art:"blade",color:"primary",damage:[8,10,12,14,19],cooldown:[.45,.42,.4,.38,.32],count:[2,2,3,3,5],reach:[.15,.16,.17,.18,.21]},aura:{id:"aura",art:"aura",color:"secondary",damage:[5,7,9,11,16],cooldown:[.5,.5,.45,.45,.4],count:[1,1,1,1,1],reach:[.11,.125,.14,.155,.19]},boomerang:{id:"boomerang",art:"boomerang",color:"accent",damage:[16,20,24,28,38],cooldown:[1.8,1.6,1.4,1.25,1],count:[1,1,2,2,3],reach:[.34,.36,.38,.4,.46]},lightning:{id:"lightning",art:"lightning",color:"primary",damage:[18,22,26,30,42],cooldown:[2,1.8,1.6,1.4,1.1],count:[2,3,4,5,7],reach:[.22,.23,.24,.25,.3]},drone:{id:"drone",art:"drone",color:"piece6",damage:[9,11,13,15,21],cooldown:[1,.9,.8,.7,.55],count:[1,1,2,2,3],reach:[.11,.11,.12,.12,.13]}},Pn=Object.keys(Ir),bo={might:{id:"might",art:"fist",color:"danger",step:.12},haste:{id:"haste",art:"hourglass",color:"primary",step:.07},area:{id:"area",art:"aura",color:"secondary",step:.1},swift:{id:"swift",art:"boot",color:"accent",step:.08},vigor:{id:"vigor",art:"heart",color:"danger",step:20},armor:{id:"armor",art:"shield",color:"muted",step:1.5},magnet:{id:"magnet",art:"magnet",color:"danger",step:.3},luck:{id:"luck",art:"clover",color:"accent",step:.2},growth:{id:"growth",art:"crystal",color:"accent",step:.1}},Ra=Object.keys(bo),tn={swarm:{kind:"swarm",cast:"foe5",hp:.6,speed:118,size:.045,damage:5,xp:1,from:0,weight:3},grunt:{kind:"grunt",cast:"foe",hp:1,speed:95,size:.055,damage:8,xp:1,from:0,weight:4},archer:{kind:"archer",cast:"foe3",hp:1.2,speed:88,size:.055,damage:7,xp:2,from:.8,weight:2},brute:{kind:"brute",cast:"foe2",hp:5,speed:62,size:.085,damage:14,xp:5,from:1.6,weight:1.2},charger:{kind:"charger",cast:"foe4",hp:2.5,speed:80,size:.065,damage:12,xp:3,from:2.4,weight:1.4},bomber:{kind:"bomber",cast:"foe5",hp:1.5,speed:120,size:.055,damage:16,xp:2,from:3.2,weight:1.4},miniboss:{kind:"miniboss",cast:"boss",hp:45,speed:75,size:.12,damage:18,xp:25,from:99,weight:0},boss:{kind:"boss",cast:"boss",hp:160,speed:70,size:.16,damage:24,xp:0,from:99,weight:0}},of=["swarm","grunt","archer","brute","charger","bomber"],Aa=10;function xo(e,t){let r=Math.max(1,Math.min(Aa,Math.floor(e)));return {chapter:r,duration:Math.min(600,t+(r-1)*30),hp:1+(r-1)*.45,damage:1+(r-1)*.12,headStart:(r-1)*.4,firstClearGold:100+(r-1)*60}}var ko=[{id:"hero",cast:"hero",weapon:"blaster",passive:null,gems:0},{id:"hero2",cast:"hero2",weapon:"blades",passive:"vigor",gems:150},{id:"hero3",cast:"hero3",weapon:"lightning",passive:"area",gems:300}],Pl=[{id:"Might",var:"meta:might",art:"fist",color:"danger",perLevel:4,unit:"%",maxLevel:50,price:30,growth:.09},{id:"Vitality",var:"meta:hp",art:"heart",color:"danger",perLevel:8,unit:"",maxLevel:50,price:25,growth:.09},{id:"Armor",var:"meta:armor",art:"shield",color:"muted",perLevel:.5,unit:"",maxLevel:30,price:40,growth:.1},{id:"Swiftness",var:"meta:speed",art:"boot",color:"accent",perLevel:2,unit:"%",maxLevel:25,price:35,growth:.1},{id:"Magnet",var:"meta:magnet",art:"magnet",color:"danger",perLevel:6,unit:"%",maxLevel:25,price:20,growth:.1},{id:"Luck",var:"meta:luck",art:"clover",color:"accent",perLevel:5,unit:"%",maxLevel:25,price:30,growth:.1},{id:"Growth",var:"meta:growth",art:"crystal",color:"accent",perLevel:3,unit:"%",maxLevel:30,price:30,growth:.1},{id:"Recovery",var:"meta:regen",art:"potion",color:"accent",perLevel:.1,unit:"",maxLevel:30,price:45,growth:.1}],Il="kit-survivors",sf=30,af=10,lf={game:"survivors",character:Il,stats:Pl,heroes:ko,levels:Aa,firstClearGold:e=>xo(e,300).firstClearGold,stars:0};var Da=ve("survivors.hero"),je=ve("survivors.foe"),zn=ve("survivors.shot"),nn=ve("survivors.bullet"),ir=ve("survivors.drop"),bn=ve("survivors.blade"),In=ve("survivors.aura"),Nn=ve("survivors.drone"),ds=ve("survivors.boomerang"),fs=ve("survivors.zap"),vo=ve("survivors.halo"),cf=ve("survivors.hud"),xn=ve("survivors.joystick"),Nl="level-up",zl="upgrade-picked",Bl="upgrade-pick",Hl="upgrade-reroll";var Oa="boss-spawned",Wl="boss-defeated",jl=e=>[...Object.entries(e.weapons).map(([t,r])=>`w:${t}:${r}`),...Object.entries(e.passives).map(([t,r])=>`p:${t}:${r}`)].join(","),df=e=>{let t={},r={};for(let o of String(e??"").split(",")){let[n,s,a]=o.split(":");n==="w"&&s&&s in Ir?t[s]=Number(a):n==="p"&&s&&s in bo&&(r[s]=Number(a));}return {weapons:t,passives:r}},Vl=e=>e.map(t=>`${t.kind}:${t.id}:${t.level}`).join(","),ff=e=>String(e??"").split(",").filter(Boolean).map(t=>{let[r,o,n]=t.split(":");return {kind:r,id:o??"",level:Number(n??1)}}),Ta=e=>e.vars.reviving===true,rn=(e,t)=>{let r=Number(e.vars[t]??0);return Number.isFinite(r)?r:0},Ca={id:"survivors",version:2,engines:["phaser"],requires:["round"],params:{duration:{type:"number",default:300,min:20,max:900},heroSpeed:{type:"number",default:260,min:80,max:800},hp:{type:"number",default:100,min:10,max:2e3},spawnRate:{type:"number",default:1.2,min:.1,max:10},spawnGrowth:{type:"number",default:.9,min:0,max:10},foeHp:{type:"number",default:10,min:1,max:1e3},foeHpGrowth:{type:"number",default:.45,min:0,max:5},foeDamage:{type:"number",default:1,min:.1,max:10},foeSpeed:{type:"number",default:1,min:.3,max:3},damage:{type:"number",default:1,min:.1,max:100},shotSpeed:{type:"number",default:640,min:100,max:2e3},xpFirst:{type:"number",default:4,min:1,max:100,integer:true},xpGrowth:{type:"number",default:1.25,min:1,max:2},coinRate:{type:"number",default:.25,min:0,max:1},killScore:{type:"number",default:10,min:0,max:1e3,integer:true},bossScore:{type:"number",default:500,min:0,max:1e5,integer:true},clearBonus:{type:"number",default:1e3,min:0,max:1e5,integer:true},graceTime:{type:"number",default:.6,min:0,max:5},maxFoes:{type:"number",default:46,min:5,max:160,integer:true},minibossEvery:{type:"number",default:120,min:0,max:900},eliteEvery:{type:"number",default:50,min:0,max:900}},setup({world:e,params:t,mode:r}){let o=e.rng.stream("survivors"),n=Jn(e),s=l=>yr(t,l),a=null,i=null,p=0,m={},$={},k={},O=0,C=0,z=0,F=1,ne=0,X=0,ye=[],be="level",fe=0,we=0,de=0,Re=false,Ce=0,Me=0,ce=300,ue=xo(1,300),Pe=false,Le=null,oe=0,Ee=0,tt=0,Ne=0,se=null,ke=0,_e=0,Te=false,Be=new Map,ee={maxHp:100,hp:100,regen:0,armor:0,speed:260,magnet:80,might:1,haste:1,area:1,luck:1,growth:1},Ie=()=>Math.min(He(e).w,He(e).h),nt=()=>Ie()/720,ht=()=>Ie()*.07,Ae=()=>{let l=He(e);return {x:l.w/2,y:l.h/2}},Gt=()=>{let l=T=>$[T]??0,E=ee.maxHp;ee.might=(1+rn(e,"meta:might")+.12*l("might"))*s("damage"),ee.haste=Math.max(.4,1-.07*l("haste")),ee.area=1+.1*l("area"),ee.speed=s("heroSpeed")*nt()*(1+rn(e,"meta:speed")+.08*l("swift")),ee.maxHp=s("hp")+rn(e,"meta:hp")+20*l("vigor"),ee.regen=rn(e,"meta:regen")+.3*l("vigor"),ee.armor=rn(e,"meta:armor")+1.5*l("armor"),ee.magnet=Ie()*.12*(1+rn(e,"meta:magnet")+.3*l("magnet")),ee.luck=1+rn(e,"meta:luck")+.2*l("luck"),ee.growth=1+rn(e,"meta:growth")+.1*l("growth"),ee.maxHp>E&&(ee.hp+=ee.maxHp-E),ee.hp=Math.min(ee.hp,ee.maxHp),e.vars.survivors_build=jl({weapons:m,passives:$});},Xe=l=>Math.ceil(s("xpFirst")*Math.pow(l,s("xpGrowth"))),rt=()=>ko.find(l=>l.id===e.vars["meta:hero"])??ko[0],lt=()=>{let l=Ae(),E=ht();(a===null||!e.isAlive(a))&&(a=e.create(),e.set(a,Da,{size:E})),e.need(a,Da).size=E,e.set(a,K,{x:l.x,y:l.y}),e.set(a,ie,{shape:"actor",cast:rt().cast,h:E*2.3,feet:E*.6,pose:"idle",depth:er(e,l.y)});},ft=(l,E,T,c)=>{let y=Be.get(l);(y===void 0||!e.isAlive(y))&&(y=e.create(),e.set(y,cf,{id:l}),Be.set(l,y)),e.set(y,K,{x:E,y:T}),e.set(y,ie,c);},yt=l=>{let E=Be.get(l);E!==void 0&&e.destroy(E),Be.delete(l);},ut=()=>{for(let l of Be.values())e.destroy(l);Be.clear(),dt(e,cf);},Et=(l,E,T,c,y,R,L,M=41)=>{let x=Math.max(0,Math.min(1,Math.round(R*100)/100));ft(`${l}:bg`,E,T,{shape:"rect",w:c,h:y,color:"#000000",alpha:.45,radius:y/2,depth:M});let _=Math.max(0,(c-4)*x);_<1?yt(`${l}:fill`):ft(`${l}:fill`,E-(c-4)/2+_/2,T,{shape:"rect",w:_,h:y-4,color:L,radius:(y-4)/2,depth:M+.01});},Ze=l=>{let E=He(l),T=Ie(),c=E.h*.085,y=E.w*.9,R=Math.max(10,T*.026);Et("xp",E.w/2,c,y,R,z/Xe(F),"accent"),ft("lv",E.w/2+y/2-T*.04,c+R*1.6,{shape:"text",text:`Lv ${F}`,size:Math.round(T*.032),color:"text",bold:true,depth:42});let L=c+T*.075;if(Le!==null&&l.isAlive(Le)&&l.has(Le,je)){let U=l.need(Le,je);Et("boss",E.w/2,L,E.w*.62,Math.max(14,T*.034),U.hp/U.maxHp,"danger"),ft("time",E.w/2,L-T*.05,{shape:"text",text:U.kind==="boss"?"BOSS":"MINI BOSS",size:Math.round(T*.036),color:"danger",bold:true,depth:42}),l.vars.boss_hp=U.hp/U.maxHp;}else yt("boss:bg"),yt("boss:fill"),ft("time",E.w/2,L,{shape:"text",text:Vs(Number(l.vars.time_left??0)),size:Math.round(T*.05),color:"text",bold:true,depth:42}),l.vars.boss_hp=0;let M=Math.round(T*.036);ft("kills:i",E.w*.06,L,{shape:"sprite",art:"skull",w:M*1.1,h:M*1.1,color:"text",depth:42}),ft("kills",E.w*.06+M*.75+String(we).length*M*.28,L,{shape:"text",text:String(we),size:M,color:"text",bold:true,depth:42});let x=T*.05,_=0,I=new Set,P=(U,me,he,xe,ge,Ke)=>{I.add(U),ft(`b:${U}`,ge,Ke,{shape:"sprite",art:me,w:x,h:x,color:he,alpha:.95,depth:41}),ft(`b:${U}:l`,ge+x*.38,Ke+x*.36,{shape:"text",text:xe>=5?"\u2605":String(xe),size:Math.round(x*.42),color:xe>=5?"coin":"text",bold:true,depth:42});};for(let[U,me]of Object.entries(m)){let he=Ir[U];P(U,he.art,he.color,me??1,E.w*.06+_*x*1.12,L+T*.075),_++;}_=0;for(let[U,me]of Object.entries($)){let he=bo[U];P(U,he.art,he.color,me??1,E.w*.06+_*x*.95,L+T*.075+x*1.1),_++;}for(let U of [...Be.keys()])if(U.startsWith("b:")){let me=U.slice(2).replace(/:l$/,"");I.has(me)||yt(U);}let H=ht(),re=Ae();Et("hp",re.x,re.y+H*1.05,H*1.7,Math.max(7,T*.013),ee.hp/ee.maxHp,ee.hp/ee.maxHp>.35?"accent":"danger",40);},Ge=(l=-1)=>{let E=He(e),T=Ie()*.08,c=l>=0?l:o.int(0,3);return {x:c===0?-T:c===1?E.w+T:o.range(-T,E.w+T),y:c===2?-T:c===3?E.h+T:o.range(-T,E.h+T)}},It=()=>s("foeHp")*ue.hp*(1+s("foeHpGrowth")*(Me/60)),Qe=(l,E,T=false)=>{let c=tn[l],y=l==="boss"||l==="miniboss",R=Ie()*c.size*(T?1.3:1),L=It()*c.hp*(T?8:1),M=Ct(e,E.x,E.y,{shape:"actor",cast:c.cast,variant:o.int(0,99),h:R*(y?1.9:l==="brute"?1.75:2.2),feet:R*.6,pose:l==="brute"||y?"walk":"run",depth:er(e,E.y)},{type:je,data:{kind:l,hp:L,maxHp:L,speed:c.speed*nt()*s("foeSpeed")*(1+Math.min(.5,Me/600)),size:R,damage:c.damage*ue.damage*s("foeDamage")*(T?1.4:1),xp:c.xp*(T?5:1),elite:T,t:o.range(0,1.5),phase:"walk",vx:0,vy:0,hurtAt:{},next:0}});return (T||y)&&Ct(e,E.x,E.y+R*.5,{shape:"sprite",art:"aura_field",w:R*2.2,h:R*1.1,color:y?"danger":"coin",alpha:.85,depth:2},{type:vo,data:{of:M}}),M},Kt=()=>{let l=Me/60+ue.headStart,E=Sr(r,"foes",of),T=E.filter(L=>tn[L].from<=l),c=T.length>0?T:[E.reduce((L,M)=>tn[L].from<=tn[M].from?L:M)],y=0;for(let L of c)y+=tn[L].weight;let R=o.range(0,y);for(let L of c)if(R-=tn[L].weight,R<=0)return L;return c[0]??"grunt"},Yt=()=>e.query(je).length,Ft=(l,E)=>{let T=Me/60+ue.headStart,c=s("spawnRate")*(1+s("spawnGrowth")*T);for(ke>0&&(ke-=E,c*=.25),Pe&&(c*=.45),se&&(se.left-=E,c*=2.6),Ce+=E*c;Ce>=1;)Ce-=1,!(Yt()>=s("maxFoes"))&&Qe(Kt(),Ge(se?se.side:-1));if(se&&se.left<=0&&(se=null),!Pe){if(Me>=tt){tt=Me+o.range(26,36);let y=Ne++%3;if(y===0){let R=Ae(),L=12+Math.min(12,Math.floor(T*2)),M=Ie()*.62;for(let x=0;x<L;x++){let _=x/L*Math.PI*2;Qe(T>3?"grunt":"swarm",{x:R.x+Math.cos(_)*M,y:R.y+Math.sin(_)*M*1.25});}G(l,{kind:"flash",color:"danger"});}else y===1?se={left:4,side:o.int(0,3)}:ke=5;}if(s("eliteEvery")>0&&Me>=Ee){Ee=Me+s("eliteEvery");let y=Kt();Qe(y==="swarm"?"grunt":y,Ge(),true);}s("minibossEvery")>0&&Me>=oe&&ce-Me>30&&(oe=Me+s("minibossEvery"),(Le===null||!l.isAlive(Le))&&(Le=Qe("miniboss",Ge()),l.emit(Oa,{kind:"miniboss"}),G(l,{kind:"shake",power:1.2})));}},ur=l=>{Pe=true,l.vars.time_left=0;let E=Ae();for(let T of l.query(je)){let c=l.get(T,je);if(!c||c.kind==="miniboss")continue;let y=l.need(T,K);Math.hypot(y.x-E.x,y.y-E.y)<Ie()*.3&&D(l,T,null,false);}Le=Qe("boss",{x:E.x,y:E.y-He(l).h*.42}),G(l,{kind:"shake",power:2}),G(l,{kind:"flash",color:"danger"}),l.emit(Oa,{kind:"boss"});},bt=(l,E,T,c=1)=>{let y=ht(),R=l==="xp"?{shape:"sprite",art:"crystal",w:y*(c>=25?.62:c>=5?.5:.38),h:y*(c>=25?.62:c>=5?.5:.38),color:c>=25?"secondary":c>=5?"primary":"accent",depth:3}:l==="coin"?{shape:"sprite",art:"coin",w:y*.4,h:y*.4,depth:3}:l==="food"?{shape:"sprite",art:"heart",w:y*.5,h:y*.5,depth:3}:l==="magnet"?{shape:"sprite",art:"magnet",w:y*.6,h:y*.6,depth:3}:l==="bomb"?{shape:"sprite",art:"bomb",w:y*.6,h:y*.6,depth:3}:{shape:"sprite",art:"chest",w:y*.9,h:y*.9,color:"coin",depth:3};Ct(e,E,T,R,{type:ir,data:{kind:l,value:c,pulled:false}});},D=(l,E,T,c=true)=>{let y=l.get(E,je);if(!y)return;let R=l.need(E,K),L=R.x,M=R.y;l.remove(E,je);for(let I of l.query(vo))l.need(I,vo).of===E&&l.destroy(I);it(l,E,"die");let x=l.need(E,ie);if(x.shape==="actor"&&(x.depth=er(l,M)-.2),_n(l,E,1.4),G(l,{kind:"burst",x:L,y:M,color:"danger",n:y.elite||y.kind==="boss"?22:8,size:y.size*1.4}),!c)return;we+=1,l.vars.kills=we,l.emit("enemy-defeated",{kind:y.kind,elite:y.elite,by:T});let _=ht();if(y.xp>0&&bt("xp",L,M+y.size*.4,y.xp),o.chance(Math.min(.95,s("coinRate")*ee.luck))&&bt("coin",L+_*.3,M+y.size*.4),o.chance(.012*ee.luck)&&bt("food",L-_*.3,M),o.chance(.004)&&!l.query(ir).some(I=>l.need(I,ir).kind==="magnet")&&bt("magnet",L,M-_*.3),o.chance(.004)&&bt("bomb",L,M-_*.3),y.elite||y.kind==="miniboss"){bt("chest",L,M);for(let I=0;I<3;I++)bt("coin",L+o.range(-_,_),M+o.range(-_,_));}if(y.kind==="bomber"){let I=Ie()*.11*ee.area;G(l,{kind:"ring",x:L,y:M,color:"piece6",size:I*2});for(let P of l.query(je)){let H=l.need(P,K);Math.hypot(H.x-L,H.y-M)<I&&u(l,P,It()*2.5,"blast");}}if((y.kind==="miniboss"||y.kind==="boss")&&(de+=1,l.vars.bosses=de,E===Le&&(Le=null),l.emit(Wl,{kind:y.kind}),G(l,{kind:"shake",power:2}),y.kind==="boss")){for(let I of l.query(je))D(l,I,null,false);h(l,"cleared");}},u=(l,E,T,c)=>{if(!l.has(E,je))return;let y=l.need(E,je);if(y.hp-=T,(y.elite||y.kind==="boss"||y.kind==="miniboss")&&_e>0){_e-=1;let R=l.need(E,K);G(l,{kind:"pop",x:R.x+o.range(-10,10),y:R.y-y.size,text:String(Math.round(T)),color:"text",size:Math.round(Ie()*.03)});}y.hp<=0?D(l,E,c):y.kind!=="boss"&&y.kind!=="miniboss"&&Fe(l,E,"hit");},g=(l,E,T,c,y)=>{let R=l.get(E,je);if(!R||R.kind==="boss"||R.kind==="miniboss"||R.phase==="dash")return;let L=l.need(E,K),M=L.x-T,x=L.y-c,_=Math.hypot(M,x)||1;L.x+=M/_*y,L.y+=x/_*y;},f=(l,E)=>{if(fe>0||a===null)return;let T=Math.max(1,E-ee.armor);ee.hp-=T,fe=s("graceTime"),l.vars.hp=Math.max(0,Math.ceil(ee.hp)),l.emit("player-hit",{hp:l.vars.hp}),Fe(l,a,"hit"),G(l,{kind:"flash",color:"danger"}),G(l,{kind:"shake",power:.8});let c=Ae();G(l,{kind:"pop",x:c.x,y:c.y-ht()*1.4,text:`-${Math.round(T)}`,color:"danger",size:Math.round(Ie()*.034)}),ee.hp<=0&&b(l);},b=l=>{if(l.vars.revive_ready===true&&!Re){l.vars.reviving=true,Bt(l),i=null,l.emit(tr,{});return}h(l,"died");},d=l=>{if(l.vars.reviving!==true)return;Re=true,l.vars.reviving=false,ee.hp=ee.maxHp,l.vars.hp=Math.ceil(ee.hp),fe=2.5;let E=Ae();for(let T of l.query(je)){let c=l.need(T,K);if(Math.hypot(c.x-E.x,c.y-E.y)<Ie()*.4){let y=l.get(T,je);if(!y)continue;y.kind==="boss"||y.kind==="miniboss"?g(l,T,E.x,E.y,Ie()*.2):D(l,T,"revive");}}for(let T of l.query(nn))l.destroy(T);G(l,{kind:"ring",x:E.x,y:E.y,color:"coin",size:Ie()*.8}),G(l,{kind:"flash",color:"coin"}),a!==null&&it(l,a,"idle");},h=(l,E)=>{if(!st(l)||Te)return;Te=true;let T=Math.floor(Me);E==="cleared"&&l.vars["meta:first_clear"]===true&&Je(l,"coins",ue.firstClearGold),l.vars.score=we*s("killScore")+T*5+de*s("bossScore")+(E==="cleared"?s("clearBonus")*ue.chapter:0),l.vars.choosing=false,l.vars.reviving=false,l.emit(Xt,{reason:E,stats:{kills:we,seconds:T,bosses:de,chapter:ue.chapter,level:F,cleared:E==="cleared"}});},v=Sr(r,"weapons",Pn),A=()=>{let l=[],E=Object.keys(m).length,T=Object.keys($).length;for(let y of Pn){let R=m[y];R!==void 0&&R<5?l.push({o:{kind:"weapon",id:y,level:R+1},weight:3}):R===void 0&&E<6&&v.includes(y)&&l.push({o:{kind:"weapon",id:y,level:1},weight:1.6});}for(let y of Ra){let R=$[y];R!==void 0&&R<5?l.push({o:{kind:"passive",id:y,level:R+1},weight:2}):R===void 0&&T<6&&l.push({o:{kind:"passive",id:y,level:1},weight:1.2});}let c=[];for(;c.length<3&&l.length>0;){let y=0;for(let M of l)y+=M.weight;let R=o.range(0,y),L=0;for(;L<l.length-1&&(R-=l[L].weight,!(R<=0));L++);c.push(l[L].o),l.splice(L,1);}return c.length<3&&c.push({kind:"heal",id:"heal",level:1}),c.length<3&&c.push({kind:"gold",id:"gold",level:1}),c},N=(l,E)=>{ye=A(),be=E,l.vars.choosing=true,l.vars.survivors_offer=Vl(ye),Bt(l),i=null,dt(l,xn);let T=Ae();G(l,{kind:"ring",x:T.x,y:T.y,color:E==="chest"?"coin":"accent",size:Ie()*.5}),l.emit(Nl,{level:F,source:E,options:ye,build:{weapons:{...m},passives:{...$}}});},B=l=>{l.vars.choosing===true||!st(l)||(ne>0?(ne-=1,N(l,"level")):X>0&&(X-=1,N(l,"chest")));},Q=(l,E)=>{E.kind==="weapon"?(m[E.id]=E.level,k[E.id]=0):E.kind==="passive"?$[E.id]=E.level:E.kind==="heal"?ee.hp=Math.min(ee.maxHp,ee.hp+ee.maxHp*.3):E.kind==="gold"&&Je(l,"coins",10),Gt(),l.vars.hp=Math.ceil(ee.hp),$e(l);},J=(l,E)=>{if(l.vars.choosing!==true)return;let T=ye[E];T&&(Q(l,T),ye=[],l.vars.choosing=false,l.vars.survivors_offer="",l.emit(zl,{kind:T.kind,id:T.id,level:T.level,source:be}),B(l));},$e=l=>{let E=Ae(),T=Ie(),c=m.blades,y=c?Ir.blades.count[c-1]:0,R=l.query(bn);for(let P of R)l.need(P,bn).index>=y&&l.destroy(P);for(let P=0;P<y;P++)R.some(H=>l.isAlive(H)&&l.need(H,bn).index===P)||Ct(l,E.x,E.y,{shape:"sprite",art:"blade",w:T*.075,h:T*.075,color:"primary",depth:31},{type:bn,data:{index:P}});for(let P of l.query(bn)){let H=l.need(P,ie);H.shape==="sprite"&&(H.w=H.h=T*(c===5?.095:.075)*Math.sqrt(ee.area));}let L=m.aura,M=l.query(In);if(L){let P=T*Ir.aura.reach[L-1]*ee.area;M.length===0&&Ct(l,E.x,E.y,{shape:"sprite",art:"aura_field",w:P*2,h:P*2,color:L===5?"coin":"secondary",alpha:.9,depth:1.5},{type:In,data:{r:P}});for(let H of l.query(In)){l.need(H,In).r=P;let re=l.need(H,ie);re.shape==="sprite"&&(re.w=re.h=P*2,re.color=L===5?"coin":"secondary");}}else for(let P of M)l.destroy(P);let x=m.drone,_=x?Ir.drone.count[x-1]:0,I=l.query(Nn);for(let P of I)l.need(P,Nn).index>=_&&l.destroy(P);for(let P=0;P<_;P++)I.some(H=>l.isAlive(H)&&l.need(H,Nn).index===P)||Ct(l,E.x,E.y,{shape:"sprite",art:"drone",w:T*.06,h:T*.06,color:"piece6",depth:33},{type:Nn,data:{index:P,cd:.3*P}});},Se=(l,E,T,c,y)=>{let R=null,L=c;for(let M of l.query(je)){if(y&&y.includes(M))continue;let x=l.need(M,K),_=Math.hypot(x.x-E,x.y-T);_<L&&(L=_,R=M);}return R},Ye=(l,E,T,c,y,R,L,M,x=1)=>{let _=ht()*x,I=s("shotSpeed")*nt(),P=Ct(l,E,T,{shape:"sprite",art:"shot",w:_*.95,h:_*.48,color:M,depth:30},{type:zn,data:{vx:Math.cos(c)*I,vy:Math.sin(c)*I,life:1.4,damage:y,pierce:R,hit:[],by:L}});l.need(P,K).rotation=c;},pt=(l,E,T)=>{if(a===null)return;let c=Ae(),y=Ie(),R=ht();for(let L of Pn){let M=m[L];if(M===void 0)continue;let x=Ir[L],_=M-1,I=x.damage[_]*ee.might;if(k[L]=(k[L]??0)-E,L==="blaster"&&k[L]<=0){let P=Se(l,c.x,c.y,y*.75);if(P===null){k[L]=0;continue}k[L]=x.cooldown[_]*ee.haste;let H=l.need(P,K),re=Math.atan2(H.y-(c.y-R*.3),H.x-c.x),U=x.count[_];for(let he=0;he<U;he++)Ye(l,c.x,c.y-R*.3,re+(he-(U-1)/2)*.16,I,x.pierce[_],"blaster",M===5?"piece6":"coin",M===5?1.25:1);Fe(l,a,"attack");let me=l.need(a,ie);me.shape==="actor"&&(me.actRate=1/Math.max(.2,x.cooldown[_]*ee.haste),T||(me.facing=H.x>=c.x?1:-1));}else if(L==="blades"){let P=y*x.reach[_]*ee.area,H=3+.35*M;O+=H*E;let re=l.query(bn),U=re.length||1;for(let me of re){let he=l.need(me,bn),xe=O+he.index/U*Math.PI*2,ge=l.need(me,K);ge.x=c.x+Math.cos(xe)*P,ge.y=c.y-R*.2+Math.sin(xe)*P,ge.rotation=O*2.2;let Ke=y*.04*Math.sqrt(ee.area);for(let ot of l.query(je)){let gt=l.get(ot,je);if(!gt)continue;let Ht=l.need(ot,K);Math.hypot(Ht.x-ge.x,Ht.y-ge.y)>Ke+gt.size*.55||l.time-(gt.hurtAt.blades??-9)<x.cooldown[_]||(gt.hurtAt.blades=l.time,u(l,ot,I,"blades"),g(l,ot,c.x,c.y,y*.012));}}}else if(L==="aura"){let P=l.query(In)[0];if(P===void 0)continue;let H=l.need(P,K);if(H.x=c.x,H.y=c.y+R*.3,l.need(P,K).rotation=l.time*.6,k[L]>0)continue;k[L]=x.cooldown[_];let re=l.need(P,In).r;for(let U of l.query(je)){let me=l.need(U,K),he=l.get(U,je);!he||Math.hypot(me.x-c.x,me.y-c.y)>re+he.size*.3||(u(l,U,I,"aura"),g(l,U,c.x,c.y,y*.008));}}else if(L==="boomerang"&&k[L]<=0){let P=Se(l,c.x,c.y,y*.8);if(P===null){k[L]=0;continue}k[L]=x.cooldown[_]*ee.haste;let H=l.need(P,K),re=Math.atan2(H.y-c.y,H.x-c.x),U=x.count[_];for(let me=0;me<U;me++){let he=re+me*Math.PI*2/U,xe=y*(M===5?.085:.065);Ct(l,c.x,c.y,{shape:"sprite",art:"boomerang",w:xe,h:xe,color:"accent",depth:32},{type:ds,data:{dx:Math.cos(he),dy:Math.sin(he),dist:0,range:y*x.reach[_]*ee.area,back:false,damage:I,hit:[]}});}}else if(L==="lightning"&&k[L]<=0){let P=Se(l,c.x,c.y,y*.55);if(P===null){k[L]=0;continue}k[L]=x.cooldown[_]*ee.haste;let H=[],re={x:c.x,y:c.y-R},U=P;for(let me=0;me<x.count[_]&&U!==null;me++){let he=l.get(U,je);if(!he)break;let xe=l.need(U,K),ge={x:xe.x,y:xe.y-he.size*.4};ze(l,re,ge,M===5?"coin":"primary"),H.push(U);let Ke=Se(l,xe.x,xe.y,y*x.reach[_]*ee.area,H);u(l,U,I,"lightning"),re=ge,U=Ke;}}else if(L==="drone"){C+=1.8*E;let P=l.query(Nn),H=P.length||1,re=y*x.reach[_];for(let U of P){let me=l.need(U,Nn),he=C+me.index/H*Math.PI*2,xe=l.need(U,K);if(xe.x=c.x+Math.cos(he)*re,xe.y=c.y-R*1.1+Math.sin(he)*re*.5,me.cd-=E,me.cd>0)continue;let ge=Se(l,xe.x,xe.y,y*.6);if(ge===null){me.cd=0;continue}me.cd=x.cooldown[_]*ee.haste;let Ke=l.need(ge,K);Ye(l,xe.x,xe.y,Math.atan2(Ke.y-xe.y,Ke.x-xe.x),I,M===5?2:1,"drone","piece6",.7);}}}},ze=(l,E,T,c)=>{let y=Math.hypot(T.x-E.x,T.y-E.y),R=Ct(l,(E.x+T.x)/2,(E.y+T.y)/2,{shape:"sprite",art:"zap",w:Math.max(8,y),h:Ie()*.035,color:c,depth:34},{type:fs,data:{life:.16}});l.need(R,K).rotation=Math.atan2(T.y-E.y,T.x-E.x);},le=(l,E)=>{let T=Ae(),c=ht(),y=Ie(),R=He(l),L=Math.hypot(R.w,R.h)*.75,M=l.query(je);for(let _ of M){let I=l.get(_,je);if(!I)continue;let P=l.need(_,K),H=T.x-P.x,re=T.y-P.y,U=Math.hypot(H,re)||1;H/=U,re/=U;let me=I.kind==="boss"||I.kind==="miniboss";if(U>(me?L*1.3:L)){let ot=Ge();P.x=ot.x,P.y=ot.y;continue}I.t-=E;let he=I.speed,xe=H,ge=re;if(I.kind==="archer"){let ot=y*.3;if(U<ot?he*=-0.6:U<ot*1.4&&(he=0),I.t<=0&&U<y*.6){I.t=2.4,Fe(l,_,"attack");let gt=260*nt();Ct(l,P.x,P.y-I.size*.6,{shape:"sprite",art:"orb",w:y*.03,h:y*.03,color:"danger",depth:29},{type:nn,data:{vx:H*gt,vy:re*gt,life:3,damage:I.damage}});}}else (I.kind==="charger"||I.kind==="miniboss"||I.kind==="boss")&&(I.phase==="walk"&&I.t<=0&&U<y*(me?.6:.38)?I.kind!=="boss"||I.next%3===0?(I.phase="wind",I.t=me?.7:.55,Fe(l,_,"surprised"),G(l,{kind:"ring",x:P.x,y:P.y,color:"danger",size:I.size*2.2})):V(l,_,I):I.phase==="wind"?(he=0,I.t<=0&&(I.phase="dash",I.t=me?.6:.45,I.vx=H,I.vy=re)):I.phase==="dash"&&(he=I.speed*(me?4:3.6),xe=I.vx,ge=I.vy,I.t<=0&&(I.phase="walk",I.t=me?I.hp<I.maxHp/2?1.6:2.4:2.8,I.kind==="boss"&&(I.next+=1))));P.x+=xe*he*E,P.y+=ge*he*E;let Ke=l.need(_,ie);if(Ke.shape==="actor"&&(Math.abs(T.x-P.x)>I.size*.4&&(Ke.facing=T.x>=P.x?1:-1),Ke.depth=er(l,P.y),Ke.speed=Math.abs(he),Ke.pose=he===0?"idle":I.kind==="brute"||me?"walk":"run"),U<(I.size+c)/2){if(I.kind==="bomber"){G(l,{kind:"ring",x:P.x,y:P.y,color:"piece6",size:y*.22}),f(l,I.damage),D(l,_,null,false);continue}if(fe<=0&&(Fe(l,_,"attack"),f(l,I.damage),Te||Ta(l)))return}}let x=l.query(je);for(let _=0;_<x.length;_++){let I=l.need(x[_],je),P=l.need(x[_],K);for(let H=_+1;H<x.length;H++){let re=l.need(x[H],je),U=l.need(x[H],K),me=(I.size+re.size)*.42,he=U.x-P.x,xe=U.y-P.y,ge=he*he+xe*xe;if(ge>=me*me||ge===0)continue;let Ke=Math.sqrt(ge),ot=(me-Ke)*.5,gt=he/Ke*ot,Ht=xe/Ke*ot,jr=I.kind==="boss"||I.kind==="miniboss",Dr=re.kind==="boss"||re.kind==="miniboss";jr||(P.x-=gt,P.y-=Ht),Dr||(U.x+=gt,U.y+=Ht);}}for(let _ of l.query(vo)){let I=l.need(_,vo).of;if(!l.isAlive(I)||!l.has(I,je)){l.destroy(_);continue}let P=l.need(I,K),H=l.need(_,K);H.x=P.x,H.y=P.y+l.need(I,je).size*.55;let re=l.need(_,ie);re.shape==="sprite"&&(re.alpha=.6+.3*Math.sin(l.time*6));}},V=(l,E,T)=>{let c=l.need(E,K),y=Ie(),R=T.next%3;if(T.next+=1,T.t=T.hp<T.maxHp/2?1.4:2.2,R===1){let L=T.hp<T.maxHp/2?18:12,M=220*nt();for(let x=0;x<L;x++){let _=x/L*Math.PI*2+l.time;Ct(l,c.x,c.y-T.size*.4,{shape:"sprite",art:"orb",w:y*.035,h:y*.035,color:"danger",depth:29},{type:nn,data:{vx:Math.cos(_)*M,vy:Math.sin(_)*M,life:3.5,damage:T.damage*.6}});}Fe(l,E,"attack"),G(l,{kind:"ring",x:c.x,y:c.y,color:"danger",size:T.size*3});}else {for(let L=0;L<6;L++){let M=L/6*Math.PI*2;Qe("swarm",{x:c.x+Math.cos(M)*T.size*1.6,y:c.y+Math.sin(M)*T.size*1.6});}Fe(l,E,"cheer");}},te=(l,E)=>{let T=He(l),c=Ae(),y=ht(),R=Ie()*.2;for(let M of l.query(zn)){let x=l.need(M,zn),_=l.need(M,K);if(_.x+=x.vx*E,_.y+=x.vy*E,x.life-=E,x.life<=0||_.x<-R||_.y<-R||_.x>T.w+R||_.y>T.h+R){l.destroy(M);continue}for(let I of l.query(je)){if(x.hit.includes(I))continue;let P=l.get(I,je);if(!P)continue;let H=l.need(I,K);if(!(Math.abs(H.x-_.x)>P.size/2+4||Math.abs(H.y-(_.y+P.size*.2))>P.size*.9+4)&&(x.hit.push(I),G(l,{kind:"burst",x:_.x,y:_.y,color:"coin",n:4,size:y*.5}),g(l,I,c.x,c.y,Ie()*.01),u(l,I,x.damage,x.by),x.hit.length>=x.pierce)){l.destroy(M);break}}}for(let M of l.query(nn)){let x=l.need(M,nn),_=l.need(M,K);if(_.x+=x.vx*E,_.y+=x.vy*E,x.life-=E,x.life<=0){l.destroy(M);continue}if(Math.hypot(_.x-c.x,_.y-(c.y-y*.3))<y*.55&&(l.destroy(M),f(l,x.damage),Te||Ta(l)))return}let L=Ie()*1.5;for(let M of l.query(ds)){let x=l.need(M,ds),_=l.need(M,K);if(_.rotation=(_.rotation??0)+E*14,x.back){let P=c.x-_.x,H=c.y-_.y,re=Math.hypot(P,H)||1;if(re<y*.5){l.destroy(M);continue}_.x+=P/re*L*E,_.y+=H/re*L*E;}else {let P=L*E*Math.max(.35,1-x.dist/x.range);_.x+=x.dx*P,_.y+=x.dy*P,x.dist+=P,x.dist>=x.range*.98&&(x.back=true,x.hit=[]);}let I=l.need(M,ie).w*.5;for(let P of l.query(je)){if(x.hit.includes(P))continue;let H=l.get(P,je);if(!H)continue;let re=l.need(P,K);Math.hypot(re.x-_.x,re.y-_.y)>I+H.size*.5||(x.hit.push(P),g(l,P,_.x,_.y,Ie()*.015),u(l,P,x.damage,"boomerang"));}}for(let M of l.query(fs)){let x=l.need(M,fs);x.life-=E;let _=l.need(M,ie);_.shape==="sprite"&&(_.alpha=Math.max(0,x.life/.16)),x.life<=0&&l.destroy(M);}},Y=(l,E)=>{let T=Ae(),c=ht(),R=l.query(ir).filter(L=>l.need(L,ir).kind==="xp");if(R.length>90){let L=R.map(P=>({e:P,d:Math.hypot(l.need(P,K).x-T.x,l.need(P,K).y-T.y)})).sort((P,H)=>H.d-P.d).slice(0,30),M=0,x=l.need(L[0].e,K),_=x.x,I=x.y;for(let P of L)M+=l.need(P.e,ir).value,l.destroy(P.e);bt("xp",_,I,Math.max(25,M));}for(let L of l.query(ir)){let M=l.need(L,ir),x=l.need(L,K),_=Math.hypot(T.x-x.x,T.y-x.y);if(_<ee.magnet||M.pulled){M.pulled=true;let I=Ie()*(M.kind==="xp"&&_>ee.magnet?2.4:1.4),P=Math.min(1,E*I/Math.max(1,_));x.x+=(T.x-x.x)*P,x.y+=(T.y-x.y)*P;}if(!(_>c*.6))if(l.destroy(L),M.kind==="coin")Je(l,"coins",M.value),l.emit("coin-collected",{value:M.value}),G(l,{kind:"pop",x:T.x,y:T.y-c*1.6,text:`+${M.value}`,size:Math.round(c*.45)});else if(M.kind==="xp"){for(z+=M.value*ee.growth;z>=Xe(F);)z-=Xe(F),F+=1,ne+=1;l.vars.xp_level=F;}else if(M.kind==="food")ee.hp=Math.min(ee.maxHp,ee.hp+ee.maxHp*.25),l.vars.hp=Math.ceil(ee.hp),G(l,{kind:"ring",x:T.x,y:T.y,color:"accent",size:c*3});else if(M.kind==="magnet"){for(let I of l.query(ir))(l.need(I,ir).kind==="xp"||l.need(I,ir).kind==="coin")&&(l.need(I,ir).pulled=true);G(l,{kind:"ring",x:T.x,y:T.y,color:"coin",size:Ie()*1.2});}else if(M.kind==="bomb"){let I=He(l);G(l,{kind:"flash",color:"#ffffff"}),G(l,{kind:"shake",power:2});for(let P of l.query(je)){let H=l.need(P,K);if(H.x<0||H.y<0||H.x>I.w||H.y>I.h)continue;let re=l.get(P,je);re&&u(l,P,re.kind==="boss"||re.kind==="miniboss"?re.maxHp*.1:re.hp+1,"bomb");}}else M.kind==="chest"&&(X+=1,G(l,{kind:"burst",x:T.x,y:T.y,color:"coin",n:20,size:c*2}));}B(l);},w=()=>{for(let E of [je,zn,nn,ir,bn,In,Nn,ds,fs,vo,xn])dt(e,E);dt(e,Qn),ut(),zt(e,"top",void 0,{pan:true}),e.vars.field_x=0,e.vars.field_y=0,i=null,p=0,ue=xo(rn(e,"meta:chapter")||1,s("duration")),ce=ue.duration;let l=rt();m={[l.weapon]:1},$=l.passive?{[l.passive]:1}:{};for(let E of Pn)k[E]=.4;z=0,F=1,ne=0,X=0,ye=[],fe=0,we=0,de=0,Re=false,Te=false,Ce=0,Me=0,Pe=false,Le=null,oe=s("minibossEvery")>0?s("minibossEvery"):1/0,Ee=s("eliteEvery")>0?s("eliteEvery")*.8:1/0,tt=22,Ne=0,se=null,ke=0,ee.maxHp=0,ee.hp=0,Gt(),ee.hp=ee.maxHp,e.vars.hp=Math.ceil(ee.hp),e.vars.hp_max=ee.maxHp,e.vars.time_left=ce,e.vars.xp_level=1,e.vars.kills=0,e.vars.bosses=0,e.vars.chapter=ue.chapter,e.vars.choosing=false,e.vars.reviving=false,e.vars.boss_hp=0,e.vars.survivors_offer="",lt(),$e(e);};e.on(Nt,l=>{let E=l,T=e.vars.choosing===true||e.vars.reviving===true;E.type==="press"&&st(e)&&!T?i={x:E.x,y:E.y}:E.type==="release"&&(i=null),E.type==="key"&&e.vars.choosing===true&&(E.key==="left"||E.key==="action"||E.key==="right")&&J(e,E.key==="left"?0:E.key==="action"?1:2);}),e.on(Bl,l=>J(e,Number(l.index??-1))),e.on(Hl,()=>{e.vars.choosing===true&&(e.vars.choosing=false,N(e,be));}),e.on(rr,()=>d(e)),e.on(nr,()=>{e.vars.reviving===true&&(e.vars.reviving=false,h(e,"died"));}),e.on(Ut,w),e.on(Qt,w),e.on(Zt,l=>{for(let E of e.query(je))it(e,E,"idle");a!==null&&e.isAlive(a)&&it(e,a,l.reason==="cleared"?"dance":"die"),ut(),dt(e,xn);}),e.on(qt,()=>{zt(e,"top",void 0,{pan:true}),lt(),st(e)&&$e(e);});let S=(l,E)=>{let T=i!==null&&n.pointer.down&&l.vars.choosing!==true,c=l.query(xn);if(!T||i===null){for(let x of c)l.destroy(x);return}c.length===0&&(Ct(l,i.x,i.y,{shape:"circle",r:E,color:"#ffffff",alpha:.16,depth:70},{type:xn,data:{part:0}}),Ct(l,i.x,i.y,{shape:"circle",r:E*.42,color:"#ffffff",alpha:.55,depth:71},{type:xn,data:{part:1}}));let y=n.pointer.x-i.x,R=n.pointer.y-i.y,L=Math.hypot(y,R)||1,M=Math.min(1,E/L);for(let x of l.query(xn)){let _=l.need(x,K);l.need(x,xn).part===0?(_.x=i.x,_.y=i.y):(_.x=i.x+y*M,_.y=i.y+R*M);}};e.addSystem({id:"survivors",order:0,run(l,E){if(!st(l)||a===null||Te)return;let T=l.vars.choosing===true||l.vars.reviving===true;for(let re of [a,...l.query(je)]){let U=l.get(re,ie);U?.shape==="actor"&&(U.paused=T);}if(T)return;_e=Math.min(12,_e+E*10);let c=He(l);if(Me+=E,!Pe){let re=Math.max(0,ce-Me);l.vars.time_left=re,re<=0&&ur(l);}fe>0&&(fe=Math.max(0,fe-E)),ee.regen>0&&ee.hp<ee.maxHp&&(ee.hp=Math.min(ee.maxHp,ee.hp+ee.regen*E),l.vars.hp=Math.ceil(ee.hp)),l.vars.hp_max=ee.maxHp;let y=Ae(),R=Ie()*.11,L=n.axis(),M=L.x,x=L.y,_=M!==0||x!==0?1:0;if(_===0&&i&&n.pointer.down){M=n.pointer.x-i.x,x=n.pointer.y-i.y;let re=Math.hypot(M,x);_=re<R*.18?0:Math.min(1,re/R);}S(l,R);let I=Math.hypot(M,x),P=I>0&&_>0;if(P){let re=M/I*ee.speed*_*E,U=x/I*ee.speed*_*E;for(let me of [...l.query(je),...l.query(zn),...l.query(nn),...l.query(ir),...l.query(Qn),...l.query(ds),...l.query(fs)]){let he=l.need(me,K);he.x-=re,he.y-=U;}pd(l,re,U),Je(l,"field_x",re),Je(l,"field_y",U),p+=E,p>.6&&Lt(l,"survivors-move");}!vt(l,"survivors-move")&&!_r(l)&&kt(l,"circle",{x:c.w/2,y:c.h*.8},{x:R*.6,y:0});let H=l.need(a,ie);H.alpha=fe>0&&Math.floor(l.time*12)%2===0?.4:1,H.shape==="actor"&&(H.pose=P?"run":"idle",H.speed=ee.speed*Math.max(.3,_),P&&Math.abs(M)>I*.15&&(H.facing=M>0?1:-1),H.depth=er(l,y.y)+5e-4),Ft(l,E),le(l,E),!(Te||Ta(l))&&(pt(l,E,P),te(l,E),!(Te||Ta(l))&&(Y(l,E),!Te&&(l.vars.score=we*s("killScore")+Math.floor(Me)*5+de*s("bossScore"),Ze(l))));}}),e.vars.survivors_base=s("duration"),w();}};var Pa=[{id:"archer",base:{damage:6,type:"physical",range:2.6,rate:1.2,air:true,ground:true,shot:"td_arrow",shotSpeed:13},tiers:[{cost:70,stats:{},art:"td_archer1"},{cost:100,stats:{damage:9,range:2.8,rate:1.35},art:"td_archer2"},{cost:150,stats:{damage:14,range:3,rate:1.5},art:"td_archer3"}],branches:[{id:"ranger",cost:240,stats:{damage:17,rate:2.5,multishot:2,range:3.1},art:"td_archer_ranger"},{id:"sniper",cost:260,stats:{damage:72,rate:.5,range:4.6,pierce:1,crit:.2,shotSpeed:22},art:"td_archer_sniper"}],unlockLevel:1,metaVar:"meta:tower:archer"},{id:"cannon",base:{damage:12,type:"physical",range:2.3,rate:.5,air:false,ground:true,shot:"bomb",shotSpeed:6,lob:true,splash:.9},tiers:[{cost:110,stats:{},art:"td_cannon1"},{cost:150,stats:{damage:22,splash:1},art:"td_cannon2"},{cost:210,stats:{damage:36,splash:1.1,range:2.5},art:"td_cannon3"}],branches:[{id:"bombard",cost:300,stats:{damage:72,splash:1.5,rate:.42,range:2.8,stun:.25,stunTime:.6},art:"td_cannon_bombard"},{id:"flamer",cost:280,stats:{damage:20,splash:1,rate:.9,burn:12,burnTime:3},art:"td_cannon_flamer"}],unlockLevel:1,metaVar:"meta:tower:cannon"},{id:"mage",base:{damage:14,type:"magic",range:2.4,rate:.7,air:true,ground:true,shot:"orb",shotSpeed:9},tiers:[{cost:100,stats:{},art:"td_mage1"},{cost:140,stats:{damage:26},art:"td_mage2"},{cost:200,stats:{damage:42,range:2.6},art:"td_mage3"}],branches:[{id:"arcane",cost:300,stats:{damage:110,type:"true",rate:.55,range:2.9},art:"td_mage_arcane"},{id:"storm",cost:280,stats:{damage:32,rate:.9,chain:4,beam:true,shot:"zap"},art:"td_mage_storm"}],unlockLevel:3,metaVar:"meta:tower:mage"},{id:"frost",base:{damage:3,type:"magic",range:2.2,rate:.8,air:true,ground:true,shot:"crystal",shotSpeed:10,splash:.5,slow:.35,slowTime:1.6},tiers:[{cost:90,stats:{},art:"td_frost1"},{cost:120,stats:{damage:5,slow:.45,slowTime:1.9},art:"td_frost2"},{cost:170,stats:{damage:8,slow:.5,slowTime:2.2,splash:.7,range:2.4},art:"td_frost3"}],branches:[{id:"glacier",cost:260,stats:{damage:14,slow:.6,slowTime:2.6,stun:.15,stunTime:1},art:"td_frost_glacier"},{id:"blizzard",cost:260,stats:{damage:10,splash:1.4,slow:.5,slowTime:2.4,range:2.7},art:"td_frost_blizzard"}],unlockLevel:5,metaVar:"meta:tower:frost"}],Gl=6,ps=.7,zr=e=>Pa.find(t=>t.id===e);function hs(e,t,r){let o=e.base;for(let s=1;s<Math.min(t,e.tiers.length);s++)o={...o,...e.tiers[s].stats};let n=r?e.branches.find(s=>s.id===r):void 0;return n?{...o,...n.stats}:o}function us(e,t,r){let o=0;for(let s=0;s<Math.min(t,e.tiers.length);s++)o+=e.tiers[s].cost;let n=r?e.branches.find(s=>s.id===r):void 0;return o+(n?.cost??0)}var Ia=(e,t,r)=>(r?e.branches.find(o=>o.id===r)?.art:void 0)??e.tiers[Math.min(t,e.tiers.length)-1].art,Bn=[{id:"grunt",cast:"foe",hp:1,speed:1,armor:0,resist:0,bounty:6,leak:1,size:.82,hit:.25,firstLevel:1,cost:1},{id:"runner",cast:"foe5",hp:.55,speed:1.8,armor:0,resist:0,bounty:4,leak:1,size:.72,hit:.15,firstLevel:2,cost:.7},{id:"brute",cast:"foe2",hp:2.6,speed:.7,armor:.6,resist:0,bounty:14,leak:2,size:1,hit:.5,firstLevel:3,cost:2.4,badge:"shield"},{id:"flyer",cast:"foe3",hp:.8,speed:1.2,armor:0,resist:0,flying:true,bounty:8,leak:1,size:.75,hit:0,firstLevel:4,cost:1.3,badge:"wing"},{id:"shaman",cast:"foe4",hp:1.6,speed:.9,armor:0,resist:.7,bounty:12,leak:1,size:.86,hit:.3,firstLevel:6,cost:2,badge:"orb"},{id:"healer",cast:"foe4",variant:7,hp:1.3,speed:.9,armor:.2,resist:.2,bounty:14,leak:1,size:.86,hit:.2,heals:{radius:1.6,share:.08,every:2},firstLevel:8,cost:2.2,badge:"potion"},{id:"splitter",cast:"foe2",variant:5,hp:2,speed:.85,armor:.2,resist:0,bounty:10,leak:2,size:.95,hit:.4,splits:{into:"spawnling",count:3},firstLevel:11,cost:2.6,badge:"skull"},{id:"spawnling",cast:"foe5",variant:3,hp:.35,speed:1.6,armor:0,resist:0,bounty:2,leak:1,size:.55,hit:.1,firstLevel:0,cost:.4},{id:"warlord",cast:"boss",hp:30,speed:.55,armor:.2,resist:0,bounty:120,leak:10,size:1.5,hit:2,summons:{id:"grunt",count:3,every:6},boss:1,firstLevel:0,cost:0},{id:"ironclad",cast:"boss",variant:4,hp:50,speed:.5,armor:.65,resist:0,bounty:160,leak:10,size:1.6,hit:2.5,enrage:{below:.5,speed:1.7},boss:2,firstLevel:0,cost:0,badge:"shield"},{id:"broodmother",cast:"boss",variant:9,hp:62,speed:.5,armor:.2,resist:.3,bounty:200,leak:10,size:1.6,hit:2.5,summons:{id:"spawnling",count:4,every:5},splits:{into:"spawnling",count:8},boss:3,firstLevel:0,cost:0,badge:"skull"},{id:"lich",cast:"boss",variant:13,hp:80,speed:.48,armor:.3,resist:.5,bounty:260,leak:15,size:1.7,hit:3,heals:{radius:2.2,share:.05,every:3},summons:{id:"shaman",count:2,every:7},boss:4,firstLevel:0,cost:0,badge:"orb"}],hr=e=>Bn.find(t=>t.id===e),$o=[{id:"meteor",icon:"td_meteor",kind:"strike",cooldown:35,unlockLevel:2,damage:2.2,count:3,radius:1.1,burn:.3},{id:"reinforce",icon:"shield",kind:"summon",cooldown:22,unlockLevel:4,count:2,cast:"helper",hp:4,dps:.6,time:14}],Br=9,Hr=13,Kl=[{id:"meadow-a",rows:["..S......",".o#o..t..","..#......","..#####o.",".o....#..","..t...#o.",".o#####..","..#..o..t","..#.*....","o.####o..","....o#...",".t...#.o.",".....X..."]},{id:"meadow-b",rows:["......S..",".t..o.#o.","......#..",".o#####..","..#..o...","..#.t..o.","..####...",".o..o#.t.","..*..#...","..####o..",".o#......","..#.o..t.","..X......"]},{id:"meadow-c",rows:[".S.......",".#.o..o..",".#.....#X",".#o.t.o#.",".#.....#.",".#o.o..#.",".#..r..#.",".#.o.o.#o",".#.....#.",".#o.*.o#.",".#######.","..o.o.o..","t.......t"]},{id:"meadow-boss",rows:["....S....","..o.#.o..","....#....",".####.o..",".#..o....",".#.o..t..",".#######.","..o.o..#.",".o.....#o","..######.","..#.o.o..",".o#......","..X......"]},{id:"river-a",rows:[".........","S####.o..",".o..#....","..o.#.~~.","....####.",".o.r...#.","...o...#o",".#######.",".#.o.o...",".#....r..",".####.o..","..o.#....","....X...."]},{id:"river-b",rows:[".S.....S.",".#.o.o.#.",".#..t..#.",".###.###.",".o.#o#.o.","...#.#...","..o###o..","....#....",".o..#.o..","...o#....","..r.#.o..",".o..#..t.","....X...."]},{id:"river-c",rows:["..~~.....","o...####S","..o.#..o.","....#.~~.",".####.~~.",".#..o....",".#.o..r..",".######o.","..o...#..",".~~.o.#..","X######o.","..o.o....","..~~...t."]},{id:"river-boss",rows:[".o.....o.","S##.o.##S","..#.r.#..",".o#####o.","....#....",".o..#.o..",".####..t.",".#..o..o.",".#.o.....",".#######.","..o.o..#.",".o.....#o",".......X."]},{id:"wood-a",rows:["..o...o..","S#######.",".o.....#.","...o.o.#o",".#####.#.",".#.o.#.#.",".#.X.#.#.",".#.###.#.",".#..o..#.",".#######.","..o.o.o..",".t..r..o.","........."]},{id:"wood-b",rows:["...S.....",".o.#..o..","...#.t...",".o.####o.","......#..",".o.o..#o.","......##X",".o.o..#o.","......#..",".o.####o.","...#.r...",".o.#..o..","...S....."]},{id:"wood-c",rows:[".o..o..o.",".#######S",".#.o..o..",".#######.","..o.o..#.",".#######.",".#..o..o.",".#######.","..o..o.#.",".#######.",".#.o..o..",".#..r..t.",".X......."]},{id:"wood-boss",rows:["....X....",".o..#..o.","..o.#....",".####.o..",".#..o..t.",".#.o..o..",".#######.","..o..o.#.",".o.....#.","..######.","..#.o..o.",".o#..r...","..S......"]},{id:"ash-a",rows:["....S....",".o..#..o.","S##.#.##S","..#.#.#..",".o#o#o#o.","..#####..",".o..#..o.","...o#o...",".t..#..t.",".o..#..o.","..r.#.r..",".o..#..o.","....X...."]},{id:"ash-b",rows:[".S.....S.",".#.o.o.#.",".#..o..#.",".###.###.","...#o#...",".o.#.#.o.","...#o#...",".###.###.",".#.o.o.#.",".#.....#.",".#######.","..o.#.o..","....X...."]},{id:"ash-c",rows:[".S.....X.",".#.###.#.",".#o#o#o#.",".#.#.#.#.",".#o#.#o#.",".#.#o#.#.","o#.#.#.#o",".#o#.#o#.",".#.#o#.#.",".#.#.#.#.",".#o#.#o#.",".###.###.","........."]},{id:"ash-boss",rows:[".o.....o.","S#.o.o.#S",".#.....#.",".#o.r.o#.",".#.....#.",".#o.X.o#.",".#..#..#.",".#o.#.o#.",".#..#..#.",".#.o#o.#.",".#######.","..o.o.o..",".t.....t."]}],Na=e=>Kl.find(t=>t.id===e);function Mo(e,t){return t==="x"?e.rows.map(r=>[...r].reverse().join("")):t==="y"?[...e.rows].reverse():e.rows}var du=e=>e==="#"||e==="S"||e==="X";function wo(e){let t=($,k)=>e[k]?.[$],r=null,o=[],n=[];for(let $=0;$<e.length;$++)for(let k=0;k<e[$].length;k++){let O=t(k,$);O==="X"?r={col:k,row:$}:O==="S"?o.push({col:k,row:$}):O==="o"&&n.push({col:k,row:$});}if(!r)throw new Error("tower-defense map: no gate (X)");if(o.length===0)throw new Error("tower-defense map: no entry (S)");let s=new Map,a=($,k)=>`${$},${k}`,i=[r];s.set(a(r.col,r.row),0);let p=[[0,1],[-1,0],[1,0],[0,-1]];for(;i.length>0;){let $=i.shift(),k=s.get(a($.col,$.row));for(let[O,C]of p){let z=$.col+O,F=$.row+C;!du(t(z,F))||s.has(a(z,F))||(s.set(a(z,F),k+1),i.push({col:z,row:F}));}}let m=o.map($=>{if(!s.has(a($.col,$.row)))throw new Error(`tower-defense map: the entry ${$.col},${$.row} has no road to the gate`);let k=[$],O=$;for(;O.col!==r.col||O.row!==r.row;){let C=s.get(a(O.col,O.row)),z=p.map(([F,ne])=>({col:O.col+F,row:O.row+ne})).find(F=>s.get(a(F.col,F.row))===C-1);k.push(z),O=z;}return k});return {rows:e,paths:m,gate:r,spots:n}}var Fl=4,Nr=5,ms=Fl*Nr,ql=[0,9,24,39],Ul=[{map:"meadow-a",mirror:"none"},{map:"meadow-b",mirror:"none"},{map:"meadow-c",mirror:"none"},{map:"meadow-a",mirror:"x"},{map:"meadow-boss",mirror:"none"},{map:"river-a",mirror:"none"},{map:"river-b",mirror:"none"},{map:"river-c",mirror:"none"},{map:"river-a",mirror:"x"},{map:"river-boss",mirror:"none"},{map:"wood-a",mirror:"none"},{map:"wood-b",mirror:"none"},{map:"wood-c",mirror:"none"},{map:"wood-b",mirror:"x"},{map:"wood-boss",mirror:"none"},{map:"ash-a",mirror:"none"},{map:"ash-b",mirror:"none"},{map:"ash-c",mirror:"none"},{map:"ash-a",mirror:"y"},{map:"ash-boss",mirror:"none"}];function fu(e){let t=e>>>0;return ()=>{t=t+1831565813>>>0;let r=t;return r=Math.imul(r^r>>>15,r|1),r^=r+Math.imul(r^r>>>7,r|61),((r^r>>>14)>>>0)/4294967296}}var pf=Bn.filter(e=>e.firstLevel>0).map(e=>e.id);function hf(e,t){let r=Bn.filter(n=>n.firstLevel>0&&n.firstLevel<=e);if(!t)return r;let o=r.filter(n=>t.includes(n.id));return o.length>0?o:r}function uf(e,t){let r=Bn.find(o=>o.firstLevel===e);return r&&(!t||t.includes(r.id))?r:void 0}function Xl(e,t,r){let o=Math.max(1,Math.min(ms,Math.floor(e))),n=fu(o*7919+13),s=hf(o,r),a=uf(o,r),i=Math.ceil(o/Nr),p=o%Nr===0?Bn.find(k=>k.boss===i):void 0,m=6+Math.floor((o-1)/2),$=[];for(let k=1;k<=m;k++){let O=5+k*1.6+o*.35,C=[],z=0,F=0,ne=[];if(k===1)ne.push(s[0]);else {a&&k===2&&ne.push(a);let ye=Math.min(4,1+Math.floor(k/3));for(;ne.length<ye;)ne.push(s[Math.floor(n()*s.length)]);}let X=O/ne.length;for(let ye of ne){let be=Math.max(1,Math.round(X/ye.cost)),fe=ye.speed>=1.5?.55:ye.hp>=2?1.3:.85;C.push({enemy:ye.id,count:be,gap:fe,delay:z,entry:F%Math.max(1,t)}),z+=be*fe*.55+1,F++;}p&&k===m&&C.push({enemy:p.id,count:1,gap:1,delay:z+2,entry:0}),$.push({groups:C});}return $}function Eo(e,t=.5,r){let o=Math.max(1,Math.min(ms,Math.floor(e))),n=Math.ceil(o/Nr),s=o-(n-1)*Nr,a=Ul[o-1],i=wo(Mo(Na(a.map),a.mirror)).paths.length;return {level:o,world:n,index:s,boss:s===Nr,map:a.map,mirror:a.mirror,hp:16*Math.pow(1.075,o-1)*(.8+t*.4),waves:Xl(o,i,r),gold:220+(o-1)*25,bounty:1+(o-1)*.03,towers:Pa.filter(p=>p.unlockLevel<=o).map(p=>p.id),spells:$o.filter(p=>p.unlockLevel<=o).map(p=>p.id),branches:o>=Gl,fresh:uf(o,r)?.id??null,enemies:hf(o,r).map(p=>p.id),firstClearGold:(s===Nr?150:60)+(o-1)*20}}var Zl=e=>ql[Math.ceil(Math.max(1,e)/Nr)-1]??0,za=(e,t)=>e>=t*.9?3:e>=t*.5?2:1,Ba=5,mf=20,So=[{id:"hero",cast:"hero",gems:0,perk:"none"},{id:"hero2",cast:"hero2",gems:150,perk:"gold"},{id:"hero3",cast:"hero3",gems:300,perk:"spells"}],Ql="kit-td",Yl=[{id:"StartGold",var:"meta:start_gold",art:"td_gold",color:"coin",perLevel:20,unit:"",maxLevel:10,price:40,growth:.12},{id:"Lives",var:"meta:lives",art:"heart",color:"danger",perLevel:1,unit:"",maxLevel:5,price:120,growth:.2},{id:"Archer",var:"meta:tower:archer",art:"td_archer1",color:"primary",perLevel:6,unit:"%",maxLevel:10,price:40,growth:.12},{id:"Cannon",var:"meta:tower:cannon",art:"td_cannon1",color:"primary",perLevel:6,unit:"%",maxLevel:10,price:40,growth:.12},{id:"Mage",var:"meta:tower:mage",art:"td_mage1",color:"primary",perLevel:6,unit:"%",maxLevel:10,price:45,growth:.12},{id:"Frost",var:"meta:tower:frost",art:"td_frost1",color:"primary",perLevel:6,unit:"%",maxLevel:10,price:45,growth:.12},{id:"Spells",var:"meta:spells",art:"td_meteor",color:"danger",perLevel:8,unit:"%",maxLevel:10,price:50,growth:.12}],yf={game:"tower-defense",character:Ql,stats:Yl,heroes:So,levels:ms,firstClearGold:e=>Eo(e).firstClearGold,stars:3,starsToEnter:Zl};var pu="boss-spawned",hu="boss-defeated",ec="wave-started",ja=ve("td.spot"),kr=ve("td.tower"),De=ve("td.raider"),Hn=ve("td.missile"),Ar=ve("td.soldier"),Ha=ve("td.meteor"),gf=ve("td.ground"),Jl=ve("td.part"),bf=ve("td.bar"),Wa=ve("td.zap"),ys=(e,t)=>{let r=Number(e.vars[t]??0);return Number.isFinite(r)?r:0},uu=.5,mu=.55,Va={id:"tower-defense",version:2,engines:["phaser"],requires:["round"],params:{difficulty:{type:"number",default:.5,min:0,max:1},lives:{type:"number",default:20,min:1,max:100,integer:true},gold:{type:"number",default:0,min:0,max:1e5,integer:true},wavePause:{type:"number",default:14,min:2,max:60},firstWait:{type:"number",default:25,min:1,max:600},earlyGold:{type:"number",default:2,min:0,max:100},coinRate:{type:"number",default:.15,min:0,max:1}},setup({world:e,params:t,mode:r}){let o=c=>yr(t,c),n=e.rng.stream("tower-defense"),s=Sr(r,"foes",pf),a=Eo(1,o("difficulty"),s),i=wo(Mo(Na(a.map),a.mirror)),p=[],m=Ne(),$=0,k=20,O=20,C=0,z=[],F=0,ne=null,X=0,ye=0,be=0,fe=false,we=false,de=1,Re=null,Ce=[],Me=null,ce=new Map,ue=[],Pe=null,Le=new Map,oe=new Map,Ee=()=>So.find(c=>c.id===e.vars["meta:hero"])??So[0],tt=()=>e.vars.reviving===true;function Ne(){return un(He(e),Br,Hr,{top:.15,bottom:.86,widthShare:.98})}let se=()=>m.cell,ke=c=>m.left+c*m.cell,_e=c=>m.top+c*m.cell,Te=c=>({x:ke(c.col+.5),y:_e(c.row+.5)}),Be=(c,y)=>({x:(c-m.left)/m.cell,y:(y-m.top)/m.cell}),ee=c=>c.row===0?{x:c.col+.5,y:-0.5}:c.row===Hr-1?{x:c.col+.5,y:Hr+.5}:c.col===0?{x:-0.5,y:c.row+.5}:c.col===Br-1?{x:Br+.5,y:c.row+.5}:null,Ie=()=>{p=i.paths.map(c=>{let y=c.map(L=>({x:L.col+.5,y:L.row+.5})),R=ee(c[0]);return R&&y.unshift(R),{pts:y,len:y.length-1}});},nt=(c,y)=>{if(y<=0)return c.pts[0];if(y>=c.len)return c.pts[c.len];let R=Math.floor(y),L=c.pts[R],M=c.pts[R+1],x=y-R;return {x:L.x+(M.x-L.x)*x,y:L.y+(M.y-L.y)*x}},ht=new Set,Ae=(c,y,R,L,M=1)=>{ht.add(c);let x=Le.get(c);(x===void 0||!e.isAlive(x))&&(x=e.create(),e.set(x,Jl,{id:c}),Le.set(c,x)),e.set(x,K,{x:y,y:R,scale:M}),e.set(x,ie,L);},Gt=c=>{for(let[y,R]of [...Le])ht.has(y)||!c.some(L=>y.startsWith(L))||(e.destroy(R),Le.delete(y));},Xe=c=>{for(let[y,R]of [...Le])y.startsWith(c)&&(e.destroy(R),Le.delete(y));},rt=(c,y,R,L)=>{let M=e.create();return e.set(M,gf,{kind:c}),e.set(M,K,{x:y,y:R}),e.set(M,ie,L),M},lt=()=>{dt(e,gf),dt(e,ja);let c=se();rt("grass",ke(Br/2),_e(Hr/2),{shape:"tile",art:"tile_grass",w:c*Br,h:c*Hr,unit:c,color:"ground",depth:-10}),i.rows.forEach((_,I)=>[..._].forEach((P,H)=>{let re=Te({col:H,row:I}),U=re.y+c*.45;P==="#"||P==="S"||P==="X"?rt("road",re.x,re.y,{shape:"sprite",art:"tile_road",w:c+1,h:c+1,color:"lane",depth:-9}):P==="~"?rt("water",re.x,re.y,{shape:"rect",w:c+1,h:c+1,color:"primary",alpha:.45,depth:-9}):P==="t"?rt("tree",re.x,U-c*.65,{shape:"sprite",art:"td_tree",w:c*1.05,h:c*1.3,depth:er(e,U,5)}):P==="r"?rt("rock",re.x,U-c*.3,{shape:"sprite",art:"rock",w:c*.8,h:c*.6,depth:er(e,U,5)}):P==="*"&&rt("bush",re.x,U-c*.3,{shape:"sprite",art:"td_bush",w:c*.85,h:c*.6,depth:er(e,U,5)});})),i.spots.forEach((_,I)=>{let P=Te(_),H=rt("spot",P.x,P.y+c*.18,{shape:"sprite",art:"td_spot",w:c*.95,h:c*.62,depth:-8});e.set(H,ja,{index:I,col:_.col,row:_.row});});let y=Te(i.gate),R=ee(i.gate),L=R&&R.y>=0?R:null,M=L?ke(i.gate.col+.5+(L.x-(i.gate.col+.5))*.35):y.x,x=L?_e(i.gate.row+.5+(L.y-(i.gate.row+.5))*.35):y.y;rt("gate",M,x-c*.2,{shape:"sprite",art:"td_gate",w:c*1.35,h:c*1.35,depth:er(e,x+c*.45,5)});for(let _ of i.paths){if(ee(_[0]))continue;let I=Te(_[0]);rt("portal",I.x,I.y-c*.1,{shape:"sprite",art:"td_portal",w:c*1.05,h:c*.95,depth:er(e,I.y,4)});}},ft=c=>e.query(kr).find(y=>e.need(y,kr).spot===c),yt=c=>{let y=e.need(c,kr),R=zr(y.kind),L=Te(i.spots[y.spot]),M=se(),x=M*1.45,_=L.y+M*.42;e.set(c,K,{x:L.x,y:_-x/2}),e.set(c,ie,{shape:"sprite",art:Ia(R,y.tier,y.branch||null),w:M*1.1,h:x,depth:er(e,_,5)});},ut=c=>{$=Math.max(0,Math.round(c)),e.vars.gold=$;},Et=(c,y)=>{let R=Te(i.spots[c]);G(e,{kind:"ring",x:R.x,y:R.y,color:y,size:se()*1.5}),G(e,{kind:"burst",x:R.x,y:R.y-se()*.4,color:y,n:10,size:se()});},Ze=(c,y)=>{let R=zr(y);if(!R||ft(c)!==void 0)return false;let L=R.tiers[0].cost;if($<L)return false;ut($-L);let M=e.create();return e.set(M,kr,{spot:c,kind:y,tier:1,branch:"",cooldown:.2}),yt(M),Et(c,"text"),e.emit("tower-built",{kind:y}),vt(e,"td-build")||(Lt(e,"td-build"),te()),true},Ge=(c,y)=>{let R=ft(c);if(R===void 0)return false;let L=e.need(R,kr),M=zr(L.kind),x;if(y){let _=M.branches.find(I=>I.id===y);if(!_||L.branch||L.tier<M.tiers.length||!a.branches)return false;x=_.cost;}else {if(L.tier>=M.tiers.length)return false;x=M.tiers[L.tier].cost;}return $<x?false:(ut($-x),y?L.branch=y:L.tier++,yt(R),Et(c,"coin"),e.emit("tower-upgraded",{kind:L.kind,tier:L.tier,branch:L.branch}),true)},It=c=>{let y=ft(c);if(y===void 0)return false;let R=e.need(y,kr),L=Math.floor(us(zr(R.kind),R.tier,R.branch||null)*ps);ut($+L);let M=Te(i.spots[c]);return G(e,{kind:"pop",x:M.x,y:M.y-se()*.8,text:`+${L}`,color:"coin",size:Math.round(se()*.3)}),G(e,{kind:"burst",x:M.x,y:M.y,color:"muted",n:12,size:se()}),e.destroy(y),e.emit("tower-sold",{kind:R.kind}),true},Qe=()=>{Re=null,Ce=[],Xe("m:"),e.vars.td_menu="";},Kt=c=>c.map(y=>`${y.action??y.id}@${Math.round(y.x)},${Math.round(y.y)}`).join(";"),Yt=c=>{Qe(),Re=c,Ft();},Ft=()=>{if(Re===null)return;let c=Re;Ce=[];let y=se(),R=He(e),L=Math.min(R.w,R.h),M=Math.max(y*.46,L*.062),x=Math.max(y*1.1,M*2.3),_=Te(i.spots[c]),I=Math.max(x+M,Math.min(R.w-x-M,_.x)),P=Math.max(R.h*.1+x+M,Math.min(R.h*.88-x-M,_.y-y*.2)),H=(ge,Ke,ot,gt,Ht,jr,Dr)=>{let $r=I+Ke*x,ln=P+ot*x;Ce.push({action:ge,x:$r,y:ln,r:M,ok:Dr}),e.vars.td_menu=Kt(Ce),Ae(`m:${ge}:bg`,$r,ln,{shape:"circle",r:M,color:"panel",alpha:.94,depth:60});let Vn=ge==="sell";Ae(`m:${ge}:rim`,$r,ln,{shape:"circle",r:M*1.08,color:Vn?"danger":Dr?"coin":"muted",alpha:Dr?.9:.5,depth:59.9}),Ae(`m:${ge}:art`,$r,ln-M*.12,{shape:"sprite",art:gt,w:Vn?M*1.25:M*1.15,h:Vn?M*1.25:M*1.3,alpha:Dr?1:.45,depth:60.1}),jr&&Ae(`m:${ge}:txt`,$r,ln+M*.78,{shape:"text",text:jr,size:Math.round(M*.52),color:Ht!==null&&!Dr?"danger":"coin",bold:true,depth:60.2});},re=ft(c);if(re===void 0){let ge=a.towers.map(ot=>zr(ot)).filter(Boolean),Ke=ge.length<=1?[[0,-1]]:ge.length===2?[[-0.8,-0.7],[.8,-0.7]]:ge.length===3?[[-0.85,-0.6],[.85,-0.6],[0,.9]]:[[-0.8,-0.75],[.8,-0.75],[-0.8,.75],[.8,.75]];ge.slice(0,4).forEach((ot,gt)=>{let Ht=ot.tiers[0].cost;H(`build:${ot.id}`,Ke[gt][0],Ke[gt][1],ot.tiers[0].art,Ht,String(Ht),$>=Ht);});return}let U=e.need(re,kr),me=zr(U.kind),he=hs(me,U.tier,U.branch||null);if(Ae("m:range",_.x,_.y,{shape:"sprite",art:"aura_field",w:he.range*y*2,h:he.range*y*2,color:"primary",alpha:.4,depth:1}),U.tier<me.tiers.length){let ge=me.tiers[U.tier];H("up",0,-1,ge.art,ge.cost,String(ge.cost),$>=ge.cost);}else !U.branch&&a.branches&&me.branches.slice(0,2).forEach((ge,Ke)=>H(`branch:${ge.id}`,Ke===0?-0.85:.85,-0.7,ge.art,ge.cost,String(ge.cost),$>=ge.cost));let xe=Math.floor(us(me,U.tier,U.branch||null)*ps);H("sell",0,1,"td_sell",null,`+${xe}`,true);},ur=c=>{if(Re===null)return;let y=Re,R=false;if(c.startsWith("build:")?R=Ze(y,c.slice(6)):c==="up"?R=Ge(y):c.startsWith("branch:")?R=Ge(y,c.slice(7)):c==="sell"&&(R=It(y)),!R){G(e,{kind:"shake",power:.3});return}Qe();},bt=(c,y)=>{let R=se(),L=-1,M=1/0;return i.spots.forEach((x,_)=>{let I=Te(x),P=ft(_)!==void 0?I.y-R*1.1:I.y-R*.5;if(Math.abs(c-I.x)>R*.55||y<P||y>I.y+R*.55)return;let H=Math.abs(c-I.x)+Math.abs(y-I.y);H<M&&(M=H,L=_);}),L},D=c=>1+.07*(c-1),u=(c,y,R,L)=>{let M=hr(c);if(!M||p.length===0)return null;let x=M.hp*a.hp*(M.boss?1:D(L)),_=e.create();return e.set(_,De,{kind:c,hp:x,maxHp:x,route:y%p.length,progress:R,x:0,y:0,slow:0,slowLeft:0,stun:0,burn:0,burnLeft:0,healCd:M.heals?.every??0,summonCd:M.summons?.every??0,heldBy:-1,enraged:false,wave:L}),e.set(_,K,{x:0,y:0}),e.set(_,ie,{shape:"actor",cast:M.cast,variant:M.variant??n.int(0,99),h:se()*M.size*1.15,pose:M.flying?"air":"walk",depth:6}),g(_),M.boss&&(e.emit(pu,{kind:c}),G(e,{kind:"shake",power:1})),_},g=c=>{let y=e.need(c,De),R=hr(y.kind),L=p[y.route],M=nt(L,y.progress),x=nt(L,y.progress+.05);y.x=M.x,y.y=M.y;let _=se(),I=e.need(c,K),P=e.need(c,ie),H=_e(M.y)+_*.2;if(I.x=ke(M.x),I.y=H-(R.flying?_*.55:0)-(P.shape==="actor"?P.h/2:0),P.shape==="actor"){Math.abs(x.x-M.x)>1e-4&&(P.facing=x.x>M.x?1:-1),P.depth=er(e,H,5),P.h=_*R.size*1.15;let re=y.heldBy<0&&y.stun<=0;P.pose=R.flying?"air":re?"walk":"idle",P.speed=R.speed*(1-y.slow)*_*de;}},f=c=>p[c.route].len-c.progress,b=c=>{let y=e.need(c,K);return {x:y.x,y:y.y}},d=(c,y,R,L,M=1,x="tower")=>{let _=e.get(c,De);if(!_)return;let I=hr(_.kind),P=y.damage*R*M*(L?2:1);if(y.type==="physical"?P*=1-I.armor*(1-(y.pierce??0)):y.type==="magic"&&(P*=1-I.resist),y.slow&&(_.slow=Math.max(_.slow,y.slow*(I.boss?.5:1)),_.slowLeft=Math.max(_.slowLeft,(y.slowTime??1)*R)),y.burn&&(_.burn=Math.max(_.burn,y.burn*R),_.burnLeft=Math.max(_.burnLeft,y.burnTime??2)),y.stun&&!I.boss&&n.chance(y.stun)&&(_.stun=Math.max(_.stun,y.stunTime??.5)),L){let H=b(c);G(e,{kind:"pop",x:H.x,y:H.y-se()*.5,text:String(Math.round(P)),color:"danger",size:Math.round(se()*.3)});}h(c,P,x);},h=(c,y,R)=>{let L=e.get(c,De);L&&(L.hp-=y,L.hp<=0&&v(c,R));},v=(c,y)=>{let R=e.need(c,De),L=hr(R.kind);e.remove(c,De),it(e,c,"die"),_n(e,c,1),ye++;let M=Math.round(L.bounty*a.bounty);ut($+M);let x=b(c);if(G(e,{kind:"pop",x:x.x,y:x.y-se()*.6,text:`+${M}`,color:"coin",size:Math.round(se()*.28)}),e.emit("enemy-defeated",{kind:R.kind,by:y}),L.boss?(be++,Je(e,"coins",10),e.emit(hu,{kind:R.kind}),G(e,{kind:"shake",power:1.4}),G(e,{kind:"flash",color:"coin"})):n.chance(o("coinRate"))&&(Je(e,"coins",1),e.emit("coin-collected",{value:1})),L.splits)for(let _=0;_<L.splits.count;_++)u(L.splits.into,R.route,Math.max(0,R.progress-.18*_),R.wave);},A=c=>{let y=e.need(c,De),R=hr(y.kind),L=Te(i.gate);G(e,{kind:"burst",x:L.x,y:L.y,color:"danger",n:12,size:se()}),e.destroy(c),k=Math.max(0,k-R.leak),e.vars.lives=k,e.emit("player-hit",{lives:k}),G(e,{kind:"flash",color:"danger"}),G(e,{kind:"shake",power:R.boss?1.6:.8}),k<=0&&J();},N=()=>{if(!(C>=a.waves.length)){C++,e.vars.wave=C,z=[];for(let c of a.waves[C-1].groups)for(let y=0;y<c.count;y++)z.push({at:c.delay+y*c.gap,enemy:c.enemy,entry:c.entry});z.sort((c,y)=>c.at-y.at),F=0,ne=null,e.emit(ec,{wave:C});}},B=()=>{if(!(ne===null||C>=a.waves.length)){if(C>0){let c=Math.ceil(ne*o("earlyGold")*a.bounty);if(c>0){ut($+c);let y=ue.find(R=>R.id.startsWith("call"));y&&G(e,{kind:"pop",x:y.x,y:y.y-se()*.6,text:`+${c}`,color:"coin",size:Math.round(se()*.32)});}}Lt(e,"td-call"),N();}},Q=c=>{if(fe||!st(e))return;fe=true;let y=c==="defended",R=y?Math.min(we?1:3,za(k,O)):0;e.vars.stars=R,y&&e.vars["meta:first_clear"]===true&&Je(e,"coins",a.firstClearGold),e.vars.score=Se()+(y?1e3+R*300:0),e.vars.reviving=false,Qe(),e.emit(Xt,{reason:c,stats:{chapter:a.level,seconds:Math.floor(X),cleared:y,stars:R,coins:Number(e.vars.coins??0),bosses:be,kills:ye,lives:k}});},J=()=>{if(e.vars.revive_ready===true&&!we){e.vars.reviving=true,Qe(),e.emit(tr,{});return}Q("overrun");},$e=()=>{if(tt()){we=true,e.vars.reviving=false,k=Ba,e.vars.lives=k;for(let c of e.query(De))e.need(c,De).stun=2;G(e,{kind:"flash",color:"coin"});}},Se=()=>ye*10+k*50+Math.max(0,C-1)*100,Ye=()=>1+ys(e,"meta:spells"),pt=(c,y,R)=>{let L=$o.find(_=>_.id===c);if(!L||(ce.get(c)??0)>0)return;let M=Be(y,R);if(M.x<-0.5||M.y<-0.5||M.x>Br+.5||M.y>Hr+.5)return;if(L.kind==="strike")for(let _=0;_<(L.count??1);_++){let I=e.create(),P=(L.radius??1)*.9;e.set(I,Ha,{x:M.x+(_===0?0:(n.next()-.5)*P*2),y:M.y+(_===0?0:(n.next()-.5)*P*2),t:0,delay:_*.2,damage:(L.damage??1)*a.hp*Ye(),radius:L.radius??1,burn:(L.burn??0)*a.hp*Ye()}),e.set(I,K,{x:-999,y:-999}),e.set(I,ie,{shape:"sprite",art:"td_meteor",w:se()*.9,h:se()*.9,alpha:0,depth:45});}else {let _={route:0,q:0,d:1/0};p.forEach((P,H)=>{for(let re=.5;re<=P.len-.5;re+=.25){let U=nt(P,re),me=Math.hypot(U.x-M.x,U.y-M.y);me<_.d&&(_={route:H,q:re,d:me});}});let I=L.count??1;for(let P=0;P<I;P++){let H=e.create(),re=(L.hp??3)*a.hp*Ye();e.set(H,Ar,{hp:re,maxHp:re,dps:(L.dps??.5)*a.hp*Ye(),left:L.time??12,route:_.route,progress:Math.max(.3,Math.min(p[_.route].len-.3,_.q+(P-(I-1)/2)*.45)),swing:0}),e.set(H,K,{x:0,y:0}),e.set(H,ie,{shape:"actor",cast:L.cast??"helper",variant:n.int(0,99),h:se()*.85,pose:"idle",depth:6}),ze(H);let U=e.need(H,K);G(e,{kind:"ring",x:U.x,y:U.y,color:"accent",size:se()*1.2});}}let x=L.cooldown*(Ee().perk==="spells"?.7:1);ce.set(c,x),Me=null,Pe!==null&&e.isAlive(Pe)&&Fe(e,Pe,"attack"),e.emit("spell-cast",{id:c});},ze=c=>{let y=e.need(c,Ar),R=p[y.route],L=nt(R,y.progress),M=nt(R,y.progress-.2),x=se(),_=e.need(c,K),I=e.need(c,ie),P=_e(L.y)+x*.2;_.x=ke(L.x),_.y=P-(I.shape==="actor"?I.h/2:0),I.shape==="actor"&&(Math.abs(M.x-L.x)>1e-4&&(I.facing=M.x>L.x?1:-1),I.depth=er(e,P,5),I.h=x*.85);},le=()=>{(Pe===null||!e.isAlive(Pe))&&(Pe=e.create());let c=se(),y=i.gate,R=[[1,0],[-1,0],[0,-1],[0,1]].map(([x,_])=>({col:y.col+x,row:y.row+_})).find(x=>x.col>=0&&x.row>=0&&x.col<Br&&x.row<Hr&&".tr*".includes(i.rows[x.row][x.col]))??y,L=Te(R),M=L.y+c*.35;e.set(Pe,K,{x:L.x,y:M-c*.6}),e.set(Pe,ie,{shape:"actor",cast:Ee().cast,h:c*1.2,pose:"idle",facing:R.col>y.col?-1:1,depth:er(e,M,5)});},V=()=>{if(vt(e,"td-build")||i.spots.length===0)return;let c=p[0],y=nt(c,c.len*.4),R=0,L=1/0;i.spots.forEach((M,x)=>{let _=Math.hypot(M.col+.5-y.x,M.row+.5-y.y);_<L&&(L=_,R=x);}),kt(e,"tap",Te(i.spots[R]),void 0,se()*1.2);},te=()=>{if(vt(e,"td-call")||C>0)return;let c=Te(i.paths[0][0]);kt(e,"tap",c,void 0,se()*1.2);},Y=()=>{let c=He(e),y=Math.min(c.w,c.h),R=se(),L=c.h*.085,M=y*.05,x=(U,me,he,xe,ge="text",Ke=y*.042)=>Ae(U,me,he,{shape:"text",text:xe,size:Math.round(Ke),color:ge,bold:true,depth:70});Ae("h:lives:i",c.w*.07,L,{shape:"sprite",art:"heart",w:M,h:M,depth:70}),x("h:lives",c.w*.15,L,String(k),k<=5?"danger":"text"),Ae("h:gold:i",c.w*.3,L,{shape:"sprite",art:"td_gold",w:M*1.15,h:M,depth:70}),x("h:gold",c.w*.4,L,String($),"coin"),Ae("h:wave:i",c.w*.56,L,{shape:"sprite",art:"td_call",w:M,h:M,depth:70}),x("h:wave",c.w*.66,L,`${C}/${a.waves.length}`),Ae("h:coin:i",c.w*.8,L,{shape:"sprite",art:"coin",w:M*.9,h:M*.9,depth:70}),x("h:coin",c.w*.89,L,String(e.vars.coins??0));let _=c.h*.125,I=e.query(De).find(U=>hr(e.need(U,De).kind)?.boss);if(I!==void 0){let U=e.need(I,De),me=c.w*.55,he=Math.max(10,y*.022);Ae("h:n:boss:bg",c.w/2,_,{shape:"rect",w:me,h:he,color:"#000000",alpha:.5,radius:he/2,depth:69});let xe=Math.max(1,(me-4)*Math.max(0,U.hp/U.maxHp));Ae("h:n:boss:fill",c.w/2-(me-4)/2+xe/2,_,{shape:"rect",w:xe,h:he-4,color:"danger",radius:(he-4)/2,depth:69.1}),Ae("h:n:boss:i",c.w/2-me/2-M*.7,_,{shape:"sprite",art:"skull",w:M,h:M,depth:70});}else if(ne!==null&&C<a.waves.length){let U=new Map;for(let ge of a.waves[C].groups)U.set(ge.enemy,(U.get(ge.enemy)??0)+ge.count);let me=[...U].slice(0,5),he=y*.15,xe=c.w/2-(me.length-1)*he/2;me.forEach(([ge,Ke],ot)=>{let gt=hr(ge),Ht=xe+ot*he;Ae(`h:n:${ge}:a`,Ht-M*.4,_+M*.1,{shape:"actor",cast:gt.cast,variant:gt.variant??1,h:M*1.5*Math.min(1.3,gt.size+.25),pose:gt.flying?"air":"idle",depth:70}),x(`h:n:${ge}:t`,Ht+M*.55,_+M*.1,`\xD7${Ke}`,gt.boss?"danger":"text",y*.034);});}if(ue=[],ne!==null&&C<a.waves.length){let U=C===0?1+.08*Math.sin(e.time*6):1;i.paths.forEach((me,he)=>{let xe=Te(me[0]),ge=R*.42;ue.push({id:`call:${he}`,x:xe.x,y:xe.y,r:ge*1.2}),Ae(`b:call:${he}:bg`,xe.x,xe.y,{shape:"circle",r:ge,color:"danger",alpha:.92,depth:65},U),Ae(`b:call:${he}:i`,xe.x,xe.y,{shape:"sprite",art:"td_call",w:ge*1.3,h:ge*1.3,depth:65.1},U),Ae(`b:call:${he}:t`,xe.x,xe.y+ge*1.25,{shape:"text",text:String(Math.ceil(ne??0)),size:Math.round(R*.26),color:"text",bold:true,depth:65.2});});}let P=c.h*.925,H=y*.065;$o.filter(U=>a.spells.includes(U.id)).forEach((U,me)=>{let he=c.w*.12+me*H*2.6,xe=ce.get(U.id)??0;ue.push({id:`spell:${U.id}`,x:he,y:P,r:H*1.15}),Me===U.id&&Ae(`b:s:${U.id}:rim`,he,P,{shape:"circle",r:H*1.18,color:"coin",alpha:.6+.4*Math.sin(e.time*8),depth:64.9}),Ae(`b:s:${U.id}:bg`,he,P,{shape:"circle",r:H,color:"panel",alpha:.92,depth:65}),Ae(`b:s:${U.id}:i`,he,P,{shape:"sprite",art:U.icon,w:H*1.25,h:H*1.25,alpha:xe>0?.4:1,depth:65.1}),xe>0&&Ae(`b:s:${U.id}:t`,he,P,{shape:"text",text:String(Math.ceil(xe)),size:Math.round(H*.8),color:"text",bold:true,depth:65.2});});let re=c.w*.88;ue.push({id:"speed",x:re,y:P,r:H*1.15}),Ae("b:speed:bg",re,P,{shape:"circle",r:H,color:de>1?"coin":"panel",alpha:.92,depth:65}),e.vars.td_buttons=Kt(ue),Ae("b:speed:t",re,P,{shape:"text",text:`x${de}`,size:Math.round(H*.75),color:de>1?"panel":"text",bold:true,depth:65.1});},w=()=>{let c=se(),y=new Set,R=(L,M,x,_,I)=>{y.add(L);let P=oe.get(L);if(!P){P=[e.create(),e.create(),e.create(),e.create(),e.create()];for(let[Ht,jr]of P.entries())e.set(jr,bf,{of:L,part:String(Ht)});oe.set(L,P);}let H=e.need(L,K),re=e.need(L,ie),U=re.shape==="actor"?re.h:c,me=H.y-U/2-c*.08,he=Math.min(He(e).w,He(e).h),xe=Math.max(c*.62,he*.065),ge=Math.max(5,xe*.13),Ke=M<.999;e.set(P[0],K,{x:H.x,y:me}),e.set(P[0],ie,{shape:"rect",w:xe,h:ge,color:"#000000",alpha:Ke?.55:0,radius:ge/2,depth:30});let ot=Math.max(1,(xe-2)*Math.max(0,M));e.set(P[1],K,{x:H.x-(xe-2)/2+ot/2,y:me}),e.set(P[1],ie,{shape:"rect",w:ot,h:ge-2,color:x,alpha:Ke?1:0,radius:(ge-2)/2,depth:30.1}),e.set(P[2],K,{x:H.x-xe/2-c*.12,y:me}),e.set(P[2],ie,{shape:"sprite",art:_??"shield",w:c*.24,h:c*.24,alpha:_?1:0,depth:30.2});let gt=H.y+U/2;e.set(P[3],K,{x:H.x,y:gt}),e.set(P[3],ie,{shape:"sprite",art:"aura_field",w:c*.75,h:c*.32,color:"primary",alpha:I?.slow?.75:0,depth:2}),e.set(P[4],K,{x:H.x,y:H.y}),e.set(P[4],ie,{shape:"sprite",art:"burst",w:c*.45,h:c*.45,color:"danger",alpha:I?.burn?.5+.4*Math.sin(e.time*20):0,depth:29});};for(let L of e.query(De)){let M=e.need(L,De);R(L,M.hp/M.maxHp,"danger",hr(M.kind)?.badge,{slow:M.slowLeft>0,burn:M.burnLeft>0});}for(let L of e.query(Ar)){let M=e.need(L,Ar);R(L,M.hp/M.maxHp,"accent",void 0,null);}for(let[L,M]of [...oe])if(!y.has(L)){for(let x of M)e.destroy(x);oe.delete(L);}},S=()=>{for(let c of [kr,De,Hn,Ar,Ha,Wa,bf,Jl])dt(e,c);Le.clear(),oe.clear();for(let c of e.query(ie))e.need(c,ie).shape==="actor"&&c!==Pe&&!e.has(c,Jl)&&e.destroy(c);},l=()=>{S(),a=Eo(ys(e,"meta:chapter")||1,o("difficulty"),s),i=wo(Mo(Na(a.map),a.mirror)),Ie(),zt(e,"top"),m=Ne(),lt(),$=0,ut((a.gold+o("gold")+ys(e,"meta:start_gold"))*(Ee().perk==="gold"?1.25:1)),O=o("lives")+ys(e,"meta:lives"),k=O,C=0,z=[],F=0,ne=o("firstWait"),X=0,ye=0,be=0,fe=false,we=false,de=1,Re=null,Ce=[],Me=null,ce.clear(),ue=[],e.vars.lives=k,e.vars.wave=0,e.vars.waves=a.waves.length,e.vars.td_level=a.level,e.vars.td_world=a.world,e.vars.coins=0,e.vars.score=0,e.vars.stars=0,e.vars.reviving=false,e.vars.td_speed=1,e.vars.level_progress=0,le();},E=c=>{if(c.startsWith("call"))B();else if(c==="speed")de=de>1?1:2,e.vars.td_speed=de;else if(c.startsWith("spell:")){let y=c.slice(6);Me===y?Me=null:(ce.get(y)??0)<=0&&(Me=y,Qe());}};e.on(Nt,c=>{let y=c;if(y.type!=="tap"||!st(e)||hn(e)||fe||tt())return;if(Re!==null){let M=Ce.find(x=>Math.hypot(y.x-x.x,y.y-x.y)<=x.r);if(M){ur(M.action);return}Qe();}let R=ue.find(M=>Math.hypot(y.x-M.x,y.y-M.y)<=M.r);if(R){E(R.id);return}if(Me!==null){pt(Me,y.x,y.y);return}let L=bt(y.x,y.y);L>=0&&(vt(e,"td-build")||Bt(e),Yt(L));}),e.on(Ut,()=>{l(),e.vars.level=a.level,V();}),e.on(Qt,l),e.on(rr,$e),e.on(nr,()=>{tt()&&(e.vars.reviving=false,Q("overrun"));}),e.on(Zt,c=>{Qe(),Xe("b:"),ue=[],Pe!==null&&e.isAlive(Pe)&&it(e,Pe,c.reason==="defended"?"dance":"die");for(let y of e.query(De))it(e,y,"idle");}),e.on(qt,()=>{zt(e,"top"),m=Ne(),lt();for(let c of e.query(kr))yt(c);dt(e,Hn),Re!==null&&Ft(),le();}),e.addSystem({id:"tower-defense",order:0,run(c,y){if(!st(c)||fe||tt())return;let R=y*de;X+=y;let L=se();for(let[M,x]of ce)x>0&&ce.set(M,Math.max(0,x-R));if(z.length>0){for(F+=R;z.length>0&&z[0].at<=F;){let M=z.shift();u(M.enemy,M.entry,0,C);}z.length===0&&C<a.waves.length&&(ne=o("wavePause"));}else ne!==null&&(ne-=R,ne<=0&&N());for(let M of c.query(Ar)){let x=c.need(M,Ar);if(x.left-=R,x.left<=0||x.hp<=0){c.remove(M,Ar),it(c,M,"die"),_n(c,M,.8);for(let P of c.query(De))c.need(P,De).heldBy===M&&(c.need(P,De).heldBy=-1);continue}let _=nt(p[x.route],x.progress),I=c.query(De).filter(P=>c.need(P,De).heldBy===M);if(I.length<2){let P=c.query(De).filter(H=>{let re=c.need(H,De),U=hr(re.kind);return re.heldBy<0&&!U.flying&&!U.boss&&Math.hypot(re.x-_.x,re.y-_.y)<=mu}).slice(0,2-I.length);for(let H of P)c.need(H,De).heldBy=M,I.push(H);}I.length>0&&(h(I[0],x.dps*R,"soldier"),x.swing-=R,x.swing<=0&&(Fe(c,M,"attack"),x.swing=.6)),ze(M);}for(let M of c.query(De)){let x=c.get(M,De);if(!x)continue;let _=hr(x.kind);if(!(x.burnLeft>0&&(x.burnLeft-=R,h(M,x.burn*R,"burn"),!c.has(M,De)))){if(x.slowLeft>0&&(x.slowLeft-=R,x.slowLeft<=0&&(x.slow=0)),x.stun>0&&(x.stun-=R),_.heals&&(x.healCd-=R,x.healCd<=0)){x.healCd=_.heals.every;for(let P of c.query(De)){let H=c.need(P,De);Math.hypot(H.x-x.x,H.y-x.y)>_.heals.radius||(H.hp=Math.min(H.maxHp,H.hp+H.maxHp*_.heals.share));}let I=b(M);G(c,{kind:"ring",x:I.x,y:I.y,color:"accent",size:_.heals.radius*L*2});}if(_.summons&&(x.summonCd-=R,x.summonCd<=0)){x.summonCd=_.summons.every;for(let I=0;I<_.summons.count;I++)u(_.summons.id,x.route,Math.max(0,x.progress-.45*(I+1)),x.wave);Fe(c,M,"cheer");}if(_.enrage&&!x.enraged&&x.hp<x.maxHp*_.enrage.below){x.enraged=true;let I=b(M);G(c,{kind:"ring",x:I.x,y:I.y,color:"danger",size:L*2});}if(x.heldBy>=0&&!c.has(x.heldBy,Ar)&&(x.heldBy=-1),x.heldBy<0&&x.stun<=0&&(x.progress+=_.speed*(1-x.slow)*(x.enraged&&_.enrage?_.enrage.speed:1)*R),x.progress>=p[x.route].len){if(A(M),fe||tt())return;continue}g(M);}}for(let M of c.query(kr)){let x=c.need(M,kr);if(x.cooldown-=R,x.cooldown>0)continue;let _=zr(x.kind),I=hs(_,x.tier,x.branch||null),P=1+ys(c,_.metaVar),H=i.spots[x.spot],re=H.col+.5,U=H.row+.5,me=c.query(De).filter(xe=>{let ge=c.need(xe,De);return (hr(ge.kind).flying?I.air:I.ground)&&ge.progress>0&&Math.hypot(ge.x-re,ge.y-U)<=I.range}).sort((xe,ge)=>f(c.need(xe,De))-f(c.need(ge,De))).slice(0,I.multishot??1);if(me.length===0){x.cooldown=0;continue}x.cooldown=1/I.rate;let he={x:ke(re),y:_e(U)-L*.75};for(let xe of me){let ge=I.crit!==void 0&&n.chance(I.crit);if(I.beam){let jr=[],Dr=he,$r=xe,ln=1;for(let Vn=0;Vn<=(I.chain??0)&&$r!==void 0;Vn++){let Tc=b($r);T(Dr,Tc,I.type==="magic"?"secondary":"primary"),jr.push($r);let Gn=c.need($r,De),sp=c.query(De).filter(Kn=>!jr.includes(Kn)&&Math.hypot(c.need(Kn,De).x-Gn.x,c.need(Kn,De).y-Gn.y)<=1.6).sort((Kn,Dc)=>Math.hypot(c.need(Kn,De).x-Gn.x,c.need(Kn,De).y-Gn.y)-Math.hypot(c.need(Dc,De).x-Gn.x,c.need(Dc,De).y-Gn.y))[0];d($r,I,P,ge,ln),Dr=Tc,$r=sp,ln*=.7;}continue}let Ke=b(xe),ot=c.create(),gt=Math.max(1,Math.hypot(Ke.x-he.x,Ke.y-he.y));c.set(ot,Hn,{target:xe,x:he.x,y:he.y,ax:Ke.x,ay:Ke.y,dist0:gt,went:0,stats:I,power:P,crit:ge}),c.set(ot,K,{x:he.x,y:he.y});let Ht=I.shot==="td_arrow"?{w:L*.55,h:L*.18}:I.lob?{w:L*.34,h:L*.34}:{w:L*.3,h:L*.3};c.set(ot,ie,{shape:"sprite",art:I.shot,...Ht,...I.burn?{color:"danger"}:I.slow?{color:"primary"}:I.type==="magic"?{color:"secondary"}:{},depth:40});}}for(let M of c.query(Hn)){let x=c.need(M,Hn);if(c.has(x.target,De)){let U=b(x.target);x.ax=U.x,x.ay=U.y;}let _=x.ax-x.x,I=x.ay-x.y,P=Math.hypot(_,I),H=x.stats.shotSpeed*L*R,re=c.need(M,K);if(P>H){x.x+=_/P*H,x.y+=I/P*H,x.went+=H;let U=Math.min(1,x.went/x.dist0);re.x=x.x,re.y=x.y-(x.stats.lob?Math.sin(Math.PI*U)*L*.9:0),re.rotation=x.stats.lob?(re.rotation??0)+R*8:Math.atan2(I,_);continue}if(c.destroy(M),x.stats.splash){let U=Be(x.ax,x.ay);G(c,{kind:"burst",x:x.ax,y:x.ay,color:x.stats.burn?"danger":x.stats.slow?"primary":"coin",n:12,size:x.stats.splash*L*1.6}),x.stats.lob&&G(c,{kind:"shake",power:.25});for(let me of c.query(De)){let he=c.need(me,De),xe=hr(he.kind);(xe.flying?x.stats.air:x.stats.ground)&&Math.hypot(he.x-U.x,he.y+(xe.flying?-0.55:0)-U.y)<=x.stats.splash&&d(me,x.stats,x.power,x.crit);}}else c.has(x.target,De)&&(G(c,{kind:"burst",x:x.ax,y:x.ay,color:x.stats.type==="magic"?"secondary":"coin",n:5,size:L*.5}),d(x.target,x.stats,x.power,x.crit));if(fe||tt())return}for(let M of c.query(Ha)){let x=c.need(M,Ha);x.t+=R;let _=(x.t-x.delay)/uu,I=c.need(M,K),P=c.need(M,ie);if(_<0)continue;if(_<1){let re=He(c).h;I.x=ke(x.x)+(1-_)*L*2,I.y=_e(x.y)-(1-_)*re*.5,I.rotation=-0.9,P.shape==="sprite"&&(P.alpha=1);continue}c.destroy(M),G(c,{kind:"burst",x:ke(x.x),y:_e(x.y),color:"danger",n:20,size:x.radius*L*2}),G(c,{kind:"ring",x:ke(x.x),y:_e(x.y),color:"coin",size:x.radius*L*2.2}),G(c,{kind:"shake",power:.8});let H={damage:x.damage,type:"true",...x.burn>0?{burn:x.burn,burnTime:2}:{}};for(let re of c.query(De)){let U=c.need(re,De);Math.hypot(U.x-x.x,U.y-x.y)<=x.radius&&d(re,H,1,false,1,"spell");}if(fe||tt())return}for(let M of c.query(Wa)){let x=c.need(M,Wa);x.life-=y,x.life<=0&&c.destroy(M);}if(C>=a.waves.length&&z.length===0&&c.query(De).length===0){Q("defended");return}c.vars.level_progress=a.waves.length>0?Math.min(1,(C-(z.length>0||c.query(De).length>0?.5:0))/a.waves.length):0,c.vars.score=Se(),ht.clear(),Re!==null&&Ft(),w(),Y(),Gt(["m:","h:","b:"]);}});let T=(c,y,R)=>{let L=Math.hypot(y.x-c.x,y.y-c.y),M=e.create();e.set(M,Wa,{life:.16}),e.set(M,K,{x:(c.x+y.x)/2,y:(c.y+y.y)/2,rotation:Math.atan2(y.y-c.y,y.x-c.x)}),e.set(M,ie,{shape:"sprite",art:"zap",w:Math.max(8,L),h:se()*.22,color:R,depth:41});};Ie(),l();}};var gs=[{id:"lemon",art:"biz1",color:"coin",cost:4,income:1,cycle:1,growth:1.07,manager:60},{id:"bakery",art:"biz2",color:"accent",cost:50,income:17,cycle:2,growth:1.1,manager:600},{id:"cafe",art:"biz3",color:"secondary",cost:600,income:225,cycle:3,growth:1.11,manager:7e3},{id:"workshop",art:"biz4",color:"primary",cost:7e3,income:2800,cycle:4,growth:1.11,manager:8e4},{id:"cinema",art:"ty_cinema",color:"danger",cost:8e4,income:4e4,cycle:6,growth:1.11,manager:1e6},{id:"hotel",art:"biz6",color:"secondary",cost:9e5,income:51e4,cycle:8,growth:1.11,manager:11e6},{id:"bank",art:"biz5",color:"coin",cost:1e7,income:62e5,cycle:10,growth:1.11,manager:12e7},{id:"port",art:"ty_port",color:"primary",cost:12e7,income:8e7,cycle:12,growth:1.11,manager:15e8}],Wn=e=>gs.find(t=>t.id===e),bs=[{at:10,speed:2},{at:25,speed:2},{at:50,speed:2},{at:75,income:3},{at:100,speed:2},{at:150,income:3}],Ka=.1,Fa=[{id:"double",scope:"one",art:"ty_up",mult:2,price:60,after:5},{id:"triple",scope:"one",art:"ty_up3",mult:3,price:2500,after:25},{id:"all",scope:"all",art:"ty_upall",mult:2,price:40,after:15}],_o=[{id:"rush",art:"ty_rush",effect:"rush",weight:3,ttl:7,mult:3,seconds:10},{id:"break",art:"ty_wrench",effect:"break",weight:2,ttl:99,taps:3},{id:"invest",art:"ty_investor",effect:"invest",weight:1,ttl:9,now:25,mult:2,seconds:30},{id:"courier",art:"chest",effect:"courier",weight:2,ttl:6,now:15,coins:2}],xf=e=>_o.find(t=>t.id===e),tc=[11,18],rc=[{id:"rush",art:"ty_sk_rush",charge:30,effect:"rush",mult:5,seconds:12},{id:"instant",art:"ty_sk_instant",charge:26,effect:"instant",cycles:8},{id:"sale",art:"ty_sk_sale",charge:28,effect:"sale",mult:.5,seconds:15}],qa=e=>rc.find(t=>t.id===e),kf=.4,vf=3,Ro=[{id:"hero",cast:"hero",gems:0,skill:"rush"},{id:"hero2",cast:"hero2",gems:150,skill:"instant"},{id:"hero3",cast:"hero3",gems:300,skill:"sale"}];var $f={l:"lemon",b:"bakery",c:"cafe",w:"workshop",n:"cinema",h:"hotel",k:"bank",p:"port"},yu={r:"rush",b:"break",i:"invest",c:"courier"},Ve=(e,t,r="",o)=>({businesses:[...e].map(n=>$f[n]??"lemon"),goals:t,events:[...r].map(n=>yu[n]??"rush"),...{}}),Ga=e=>({...e,vip:true}),Ue=e=>({kind:"cash",n:e}),At=(e,t)=>({kind:"level",biz:$f[e]??"lemon",n:t}),lr=e=>({kind:"managers",n:e}),jn=[Ve("lb",[Ue(5200)]),Ve("lb",[At("l",25),Ue(62e3)]),Ve("lbc",[Ue(17e3)],"r"),Ve("lbc",[lr(2),Ue(34e3)],"r"),Ve("lbc",[At("b",25),Ue(51e3)],"rc"),Ve("lbcw",[Ue(21e4)],"rc"),Ve("lbcw",[At("c",25),lr(2)],"rc"),Ve("lbcw",[lr(3),Ue(46e4)],"rc"),Ve("lbcw",[At("w",10),Ue(1e6)],"rc"),Ga(Ve("lbcw",[At("c",25),lr(4),Ue(5e6)],"rc")),Ve("bcw",[Ue(73e3)],"rb"),Ve("bcw",[At("c",25),Ue(17e4)],"rcb"),Ve("bcwn",[Ue(2e5)],"rcb"),Ve("bcwn",[lr(2),Ue(42e4)],"rcb"),Ve("bcwn",[At("n",5),Ue(97e4)],"rcb"),Ve("bcwn",[At("w",25),Ue(24e5)],"rcb"),Ve("bcwn",[lr(3),Ue(19e5)],"rcb"),Ve("bcwn",[At("c",50),Ue(32e5)],"rcb"),Ve("bcwn",[At("n",10),lr(3)],"rcb"),Ga(Ve("bcwn",[At("n",10),lr(4),Ue(64e6)],"rcb")),Ve("cwn",[Ue(12e5)],"rcbi"),Ve("cwn",[At("w",25),Ue(2e6)],"rcbi"),Ve("cwnh",[Ue(27e5)],"rcbi"),Ve("cwnh",[lr(2),Ue(32e5)],"rcbi"),Ve("cwnh",[At("h",5),Ue(16e6)],"rcbi"),Ve("cwnh",[At("n",25),Ue(26e6)],"rcbi"),Ve("cwnh",[lr(3),Ue(15e6)],"rcbi"),Ve("cwnh",[At("w",50),Ue(42e6)],"rcbi"),Ve("cwnh",[At("h",10),lr(3)],"rcbi"),Ga(Ve("cwnh",[At("h",10),lr(4),Ue(26e7)],"rcbi")),Ve("wnhk",[Ue(12e6)],"rcbi"),Ve("wnhk",[At("h",10),Ue(36e6)],"rcbi"),Ve("wnhk",[lr(3),Ue(21e7)],"rcbi"),Ve("nhkp",[Ue(21e7)],"rcbi"),Ve("nhkp",[At("k",10),Ue(38e7)],"rcbi"),Ve("nhkp",[lr(2),Ue(42e7)],"rcbi"),Ve("nhkp",[At("p",5),Ue(27e8)],"rcbi"),Ve("nhkp",[At("k",25),Ue(32e8)],"rcbi"),Ve("nhkp",[At("p",10),lr(3)],"rcbi"),Ga(Ve("nhkp",[At("p",10),lr(4),Ue(11e9)],"rcbi"))],Ao=10,Mf=4,Lo=jn.length,nc=[0,18,45,75],oc=e=>nc[Math.ceil(Math.max(1,e)/Ao)-1]??0,Ua=e=>e>=.3?3:e>=.12?2:1,Xa=30,wf=(e,t)=>Math.round((t?40:20)+(e-1)*2),sc=(e,t)=>(t?120:50)+(e-1)*10,ac="kit-tycoon",ic=[{id:"StartCash",var:"meta:cash",art:"coin",color:"coin",perLevel:20,unit:"%",maxLevel:15,price:40,growth:.12},{id:"CycleSpeed",var:"meta:speed",art:"hourglass",color:"secondary",perLevel:3,unit:"%",maxLevel:15,price:45,growth:.12},{id:"Income",var:"meta:income",art:"ty_up",color:"accent",perLevel:5,unit:"%",maxLevel:20,price:40,growth:.12},{id:"Discount",var:"meta:discount",art:"ty_sk_sale",color:"primary",perLevel:2,unit:"%",maxLevel:15,price:50,growth:.12},{id:"SkillPower",var:"meta:skill",art:"ty_sk_rush",color:"secondary",perLevel:8,unit:"%",maxLevel:10,price:50,growth:.12}],Ef={game:"tycoon",character:ac,stats:ic,heroes:Ro,levels:Lo,firstClearGold:e=>sc(e,jn[Math.max(1,Math.min(Lo,e))-1]?.vip===true),stars:3,starsToEnter:oc};var gu={income:0,speed:0,discount:0};function ks(e,t=gu,r){return {biz:e.businesses.map((n,s)=>({def:Wn(n)??gs[0],level:s===0?1:0,progress:0,ready:false,manager:false,mult:1,rush:0,rushMult:1,broken:0})),cash:r??Lf(e),earned:0,allMult:1,bought:new Set,timed:[],mods:t}}var Lf=e=>e.cash??(Wn(e.businesses[1]??e.businesses[0]??"lemon")?.cost??4)*2,bu=e=>e.timed.reduce((t,r)=>t*r.income,1),xu=e=>e.timed.reduce((t,r)=>t*r.price,1);function vs(e){let t=1,r=1,o=0;for(let n of bs)e>=n.at?(t*=n.speed??1,r*=n.income??1):o===0&&(o=n.at);return {speed:t,income:r,next:o}}function kn(e,t){let r=vs(t.level);return Math.max(Ka,t.def.cycle/r.speed/(1+e.mods.speed))}function Tr(e,t,r=t.level){if(r<=0)return 0;let o=vs(r),n=t.def.cycle/o.speed/(1+e.mods.speed),s=n<Ka?Ka/n:1;return t.def.income*r*o.income*s*t.mult*e.allMult*(1+e.mods.income)*(t.rush>0?t.rushMult:1)*bu(e)}var Za=(e,t)=>t.level<=0||t.broken>0?0:Tr(e,t)/kn(e,t),Qa=e=>e.biz.reduce((t,r)=>t+Za(e,r),0),xs=e=>Math.max(.1,1-Math.min(.9,e.mods.discount))*xu(e);function vn(e,t,r=1){let o=t.def.growth,n=t.def.cost*Math.pow(o,t.level),s=r<=1?n:n*(Math.pow(o,r)-1)/(o-1);return Math.ceil(s*xs(e))}function cc(e,t,r=1e3){let o=t.def.growth,n=t.def.cost*Math.pow(o,t.level)*xs(e);if(e.cash<n)return 0;let s=Math.floor(Math.log(e.cash*(o-1)/n+1)/Math.log(o)),a=Math.max(1,Math.min(r,s));for(;a>1&&vn(e,t,a)>e.cash;)a--;return vn(e,t,a)<=e.cash?a:0}var To=(e,t)=>Math.ceil(t.def.manager*xs(e));function Ya(e,t,r=1){let o=e.biz[t];if(!o||r<1)return {ok:false,milestones:[]};let n=vn(e,o,r);if(e.cash<n)return {ok:false,milestones:[]};e.cash-=n;let s=o.level;return o.level+=r,{ok:true,milestones:bs.filter(a=>s<a.at&&o.level>=a.at).map(a=>a.at)}}function Ja(e,t){let r=e.biz[t];if(!r||r.manager||r.level<=0)return false;let o=To(e,r);return e.cash<o?false:(e.cash-=o,r.manager=true,r.ready&&(r.ready=false,r.progress=0,$s(e,Tr(e,r))),true)}var $s=(e,t)=>{e.cash+=t,e.earned+=t;};function ei(e,t){let r=e.biz[t];if(!r||!r.ready)return 0;r.ready=false,r.progress=0;let o=Tr(e,r);return $s(e,o),o}function ti(e,t){let r=e.biz[t];return !r||r.broken<=0?false:(r.broken--,r.broken===0)}function dc(e,t){let r=0;for(let o of e.biz)o.level<=0||o.broken>0||(r+=Tr(e,o)*t);return $s(e,r),r}var fc=(e,t)=>$s(e,t);function ri(e,t){let r=e.timed.findIndex(o=>o.id===t.id);r>=0&&e.timed.splice(r,1),e.timed.push(t);}function ni(e,t){let r=[],o=[];e.biz.forEach((n,s)=>{if(n.rush>0&&(n.rush=Math.max(0,n.rush-t)),!(n.level<=0||n.ready||n.broken>0)&&(n.progress+=t/kn(e,n),!(n.progress<1)))if(n.manager){let a=Math.floor(n.progress);n.progress-=a;let i=Tr(e,n)*a;$s(e,i),o.push({index:s,amount:i});}else n.progress=1,n.ready=true,r.push(s);});for(let n=e.timed.length-1;n>=0;n--){let s=e.timed[n];s.left-=t,s.left<=0&&e.timed.splice(n,1);}return {ready:r,paid:o}}function pc(e){let t=[],r=e.biz.reduce((o,n)=>Math.max(o,n.def.cost),0);for(let o of Fa)o.scope==="all"?t.push({key:o.id,def:o,index:-1,price:Math.ceil(r*o.price*xs(e))}):e.biz.forEach((n,s)=>t.push({key:`${o.id}:${n.def.id}`,def:o,index:s,price:Math.ceil(n.def.cost*o.price*xs(e))}));return t}function oi(e,t=3){return pc(e).filter(r=>!e.bought.has(r.key)&&(r.index<0?(e.biz[0]?.level??0)>=r.def.after:(e.biz[r.index]?.level??0)>=r.def.after)).sort((r,o)=>r.price-o.price).slice(0,t)}function si(e,t){let r=pc(e).find(o=>o.key===t);return !r||e.bought.has(t)||e.cash<r.price?false:(e.cash-=r.price,e.bought.add(t),r.index<0?e.allMult*=r.def.mult:e.biz[r.index].mult*=r.def.mult,true)}var ai=e=>e.biz.filter(t=>t.manager).length;function on(e,t){if(t.kind==="cash")return Math.min(1,e.earned/Math.max(1,t.n));if(t.kind==="managers")return Math.min(1,ai(e)/Math.max(1,t.n));let r=e.biz.find(o=>o.def.id===t.biz);return Math.min(1,(r?.level??0)/Math.max(1,t.n))}var Ms=(e,t)=>t.every(r=>on(e,r)>=1),ii=(e,t)=>t.length?t.reduce((r,o)=>r+on(e,o),0)/t.length:1,lc=(e,t)=>t.manager?1:kn(e,t)/(kn(e,t)+1.2);function li(e,t){let r=e.biz.findIndex(k=>k.broken>0);if(r>=0)return {kind:"fix",index:r};let o=null,n=Qa(e),s=(k,O,C)=>{if(C>e.cash+n*8)return;let z=O/Math.max(1,C);(!o||z>o.value)&&(o={move:k,value:z,price:C});},a=k=>t.some(O=>O.kind==="level"&&O.biz===k&&on(e,O)<1),i=t.some(k=>k.kind==="managers"&&on(e,k)<1),p=t.some(k=>k.kind==="cash"&&on(e,k)<1);e.biz.forEach((k,O)=>{let C=Za(e,k)*lc(e,k),z={...k,level:k.level+1},ne=(Tr(e,z)/kn(e,z)*lc(e,z)-C)*(k.level===0?3:1)*(a(k.def.id)?3:1);s({kind:"buy",index:O},ne+(a(k.def.id)&&!p?n*.05:0),vn(e,k)),k.level>0&&!k.manager&&s({kind:"hire",index:O},Za(e,k)*(1-lc(e,k))*1.6*(i?3:1)+(i?n*.05:0),To(e,k));});for(let k of oi(e,6)){let O=k.index<0?n*(k.def.mult-1):Za(e,e.biz[k.index])*(k.def.mult-1);s({kind:"upgrade",key:k.key},O,k.price);}let m=e.biz.map((k,O)=>({b:k,i:O})).filter(k=>k.b.ready).sort((k,O)=>Tr(e,O.b)-Tr(e,k.b))[0],$=o;return $&&$.price<=e.cash?$.move:m?{kind:"collect",index:m.i}:null}function _f(e,t){return t?t.kind==="collect"?ei(e,t.index)>0:t.kind==="buy"?Ya(e,t.index).ok:t.kind==="hire"?Ja(e,t.index):t.kind==="fix"?ti(e,t.index)||true:si(e,t.key):false}function Rf(e,t={}){let r=ks(e,t.mods),o=.05,n=t.tapEvery??.4,s=t.max??900,a=0,i=0;for(;a<s;){if(Ms(r,e.goals))return a;if(ni(r,o),a+=o,a>=i){let p=li(r,e.goals);p&&(_f(r,p),i=a+n);}}return 1/0}var Sf=new Map;function ci(e){let t=Sf.get(e);return t===void 0&&(t=Rf(jn[e-1]),Sf.set(e,t)),t}function Do(e,t=.5){let r=Math.max(1,Math.min(Lo,Math.floor(e))),o=jn[r-1],n=Math.ceil(r/Ao),s=r-(n-1)*Ao,a=ci(r),i=(1.6-(n-1)*.08-s*.01)*(1.1-t*.2)*(o.extra??1),p=Math.max(45,Math.min(600,Math.ceil((Number.isFinite(a)?a:400)*i/5)*5));return {level:r,world:n,index:s,def:o,boss:o.vip===true,day:p,cash:Lf(o),coins:wf(r,o.vip===true),firstClearGold:sc(r,o.vip===true)}}var ku=ve("tycoon.part"),hc=ve("tycoon.manager"),Oo=(e,t)=>{let r=Number(e.vars[t]??0);return Number.isFinite(r)?r:0},vr=e=>{let t=Math.abs(e);for(let[r,o]of [[1e12,"T"],[1e9,"B"],[1e6,"M"],[1e3,"K"]])if(t>=r)return `${(e/r).toFixed(t>=r*100?0:1).replace(/\.0$/,"")}${o}`;return String(Math.floor(e))},Af=new WeakMap,Tf=e=>Af.get(e),ws=[1,10,0],di={id:"tycoon",version:2,engines:["phaser"],requires:["round"],params:{difficulty:{type:"number",default:.5,min:0,max:1},coinReward:{type:"number",default:1,min:0,max:10}},setup({world:e,params:t,mode:r}){let o=d=>yr(t,d),n=e.rng.stream("tycoon"),s=Sr(r,"events",_o.map(d=>d.id)),a=Do(1,o("difficulty")),i=ks(a.def),p=new Map,m=new Map,$=null,k=[],O=0,C=0,z=0,F=0,ne=0,X=false,ye=false,be=0,fe=null,we=null,de=null,Re=()=>Ro.find(d=>d.id===e.vars["meta:hero"])??Ro[0],Ce=()=>qa(Re().skill),Me=()=>e.vars.reviving===true,ce=()=>a.def.goals,ue=()=>{let d=He(e);return {...d,U:Math.min(d.w,d.h)}},Pe=d=>{let h=ue(),v=Math.max(1,i.biz.length),A=h.h*.25,N=h.h*.81,B=Math.max(6,h.h*.012),Q=Math.min((N-A-B*(v-1))/v,150,h.w*.26),J=Math.min(h.w*.96,660),$e=A+(N-A-(v*Q+(v-1)*B))/2;return {x:h.w/2,y:$e+d*(Q+B)+Q/2,w:J,h:Q}},Le=d=>{let h=Pe(d);return {x:h.x-h.w/2+h.h*.56,y:h.y,size:h.h*.9}},oe=()=>ue().h*.9,Ee=()=>{let d=ue();return Math.min(d.U*.075,d.h*.055)},tt=()=>{let d=ue(),h=we?1-we.left/we.def.ttl:0;return {x:-d.w*.05+h*d.w*1.1,y:d.h*.21,r:d.U*.06}},Ne=new Set,se=(d,h,v,A,N=1)=>{Ne.add(d);let B=p.get(d);(B===void 0||!e.isAlive(B))&&(B=e.create(),e.set(B,ku,{id:d}),p.set(d,B)),e.set(B,K,{x:h,y:v,scale:N}),e.set(B,ie,A);},ke=()=>{for(let[d,h]of [...p])Ne.has(d)||(e.destroy(h),p.delete(d));},_e=(d,h,v,A,N,B,Q=70)=>se(d,h,v,{shape:"text",text:A,size:Math.max(9,Math.round(B)),color:N,bold:true,depth:Q}),Te=(d,h,v,A,N,B,Q,J=2)=>{se(`${d}:bg`,h,v,{shape:"rect",w:A+4,h:N+4,color:"#000000",alpha:.4,radius:(N+4)/2,depth:J});let $e=Math.max(1,A*Math.max(0,Math.min(1,B)));se(`${d}:fill`,h-A/2+$e/2,v,{shape:"rect",w:$e,h:N,color:Q,radius:N/2,depth:J+.1});},Be=d=>k.push(d),ee=d=>{let h=i.biz[d],v=ws[ne]??1;return v===0?Math.max(1,cc(i,h)):v},Ie=()=>{i.biz.forEach((d,h)=>{let v=Pe(h),A=Le(h),N=d.level>0,B=d.def.color;se(`r${h}`,v.x,v.y,{shape:"sprite",art:"panel",w:v.w,h:v.h,color:"panel",depth:0}),d.rush>0&&se(`r${h}:rush`,A.x,A.y,{shape:"circle",r:A.size*.55,color:"coin",alpha:.35+.2*Math.sin(e.time*8),depth:.5});let Q=d.ready?1+.06*Math.abs(Math.sin(e.time*6)):1;se(`r${h}:b`,A.x,A.y,{shape:"sprite",art:d.def.art,w:A.size,h:A.size,color:B,alpha:N?d.broken>0?.55:1:.35,depth:1},Q),Be({id:`biz${h}`,x:A.x,y:A.y,w:A.size,h:A.size});let J=v.x-v.w*.12,$e=v.h*.2,Se=vs(d.level);if(_e(`r${h}:lv`,J,v.y-v.h*.26,N?`Lv ${d.level}${Se.next?`/${Se.next}`:""}`:"Lv 0","text",$e,2),N){_e(`r${h}:inc`,J,v.y+v.h*0,`+${vr(Tr(i,d))}`,"coin",$e*.95,2);let l=d.ready||kn(i,d)<=.15&&d.manager?1:d.progress;Te(`r${h}:bar`,J,v.y+v.h*.28,v.w*.3,Math.max(6,v.h*.12),l,d.broken>0?"danger":B),d.ready&&!d.manager&&_e(`r${h}:ok`,A.x+A.size*.36,A.y+A.size*.34,"$","coin",A.size*.3,3);}if(fe?.index===h){let l=1+.12*Math.sin(e.time*9);se(`r${h}:ev`,A.x+A.size*.32,A.y-A.size*.3,{shape:"sprite",art:fe.def.art,w:A.size*.5,h:A.size*.5,depth:4},l);}else d.broken>0&&(se(`r${h}:ev`,A.x+A.size*.3,A.y-A.size*.28,{shape:"sprite",art:"ty_wrench",w:A.size*.48,h:A.size*.48,depth:4},1+.08*Math.sin(e.time*10)),_e(`r${h}:evn`,A.x+A.size*.3,A.y+A.size*.05,String(d.broken),"danger",A.size*.26,4.1));let Ye=v.x+v.w*.13,pt=v.h*.27;if(N&&!d.manager){let l=To(i,d),E=i.cash>=l;se(`r${h}:m:bg`,Ye,v.y-v.h*.08,{shape:"circle",r:pt,color:E?"secondary":"panel",alpha:E?.95:.7,depth:1}),se(`r${h}:m`,Ye,v.y-v.h*.08,{shape:"sprite",art:"ty_manager",w:pt*1.7,h:pt*1.7,alpha:E?1:.5,depth:1.2}),_e(`r${h}:m:p`,Ye,v.y+v.h*.32,vr(l),E?"text":"muted",$e*.8,2),Be({id:`mgr${h}`,x:Ye,y:v.y,w:pt*2.2,h:v.h*.9});}let ze=v.x+v.w/2-v.w*.14,le=v.w*.25,V=v.h*.72,te=ee(h),Y=vn(i,d,te),w=i.cash>=Y;se(`r${h}:buy`,ze,v.y,{shape:"sprite",art:"button",w:le,h:V,color:w?"accent":"panel",alpha:w?1:.6,depth:1}),_e(`r${h}:buy:n`,ze,v.y-V*.2,N?`+${te}`:"OPEN","text",$e*.9,2),se(`r${h}:buy:c`,ze-le*.3,v.y+V*.2,{shape:"sprite",art:"coin",w:$e*.8,h:$e*.8,depth:2}),_e(`r${h}:buy:p`,ze+le*.08,v.y+V*.2,vr(Y),w?"coin":"muted",$e*.85,2),Be({id:`buy${h}`,x:ze,y:v.y,w:le,h:V});let S=m.get(h);if(d.manager&&(S===void 0||!e.isAlive(S))&&(S=e.create(),e.set(S,hc,{index:h}),e.set(S,ie,{shape:"actor",cast:"helper",variant:h*13+5,h:v.h*.78,pose:"idle",facing:1,depth:2}),m.set(h,S)),S!==void 0&&e.isAlive(S)){e.set(S,K,{x:Ye,y:v.y+v.h*.02});let l=e.need(S,ie);l.shape==="actor"&&(l.h=v.h*.78);}});},nt=d=>d.kind==="cash"?"coin":d.kind==="managers"?"ty_manager":Wn(d.biz??"")?.art??"biz1",ht=d=>d.kind==="cash"?i.earned:d.kind==="managers"?ai(i):i.biz.find(h=>h.def.id===d.biz)?.level??0,Ae=()=>{let d=ue(),h=d.U,v=d.h*.09;se("h:t:i",d.w*.09,v,{shape:"sprite",art:"hourglass",w:h*.06,h:h*.06,depth:70}),_e("h:t",d.w*.09+h*.09,v,Vs(O),O<=15?"danger":"text",h*.05),se("h:c:i",d.w*.42,v,{shape:"sprite",art:"coin",w:h*.07,h:h*.07,depth:70}),_e("h:c",d.w*.42+h*.13,v,vr(i.cash),"coin",h*.065);let A=h*.17;se("h:mode",d.w*.88,v,{shape:"sprite",art:"button",w:A,h:h*.08,color:"secondary",depth:70}),_e("h:mode:t",d.w*.88,v,ws[ne]===0?"MAX":`\xD7${ws[ne]}`,"text",h*.042,70.1),Be({id:"mode",x:d.w*.88,y:v,w:A,h:h*.09});let N=ce(),B=Math.min(d.w*.3,230),Q=Math.max(30,d.h*.05),J=d.h*.15;if(N.forEach((le,V)=>{let te=d.w/2+(V-(N.length-1)/2)*(B+h*.02),Y=on(i,le)>=1;se(`h:g${V}`,te,J,{shape:"sprite",art:"panel",w:B,h:Q,color:Y?"accent":"panel",depth:70}),se(`h:g${V}:i`,te-B*.36,J-Q*.06,{shape:"sprite",art:nt(le),w:Q*.75,h:Q*.75,depth:70.1});let w=ht(le),S=Y?"\u2713":le.kind==="cash"?`${vr(w)}/${vr(le.n)}`:le.kind==="level"?`Lv ${w}/${le.n}`:`${w}/${le.n}`;_e(`h:g${V}:t`,te+B*.1,J-Q*.08,S,"text",Q*.36,70.1),Te(`h:g${V}:bar`,te+B*.1,J+Q*.3,B*.62,Math.max(4,Q*.1),on(i,le),Y?"accent":"coin",70.1);}),i.timed.forEach((le,V)=>{let te=d.w*.9-V*h*.16,Y=le.id==="sale"?"ty_sk_sale":le.id==="invest"?"ty_investor":Ce().art;se(`h:tm${V}`,te-h*.04,d.h*.205,{shape:"sprite",art:Y,w:h*.06,h:h*.06,depth:70}),_e(`h:tm${V}:t`,te+h*.035,d.h*.205,`${Math.ceil(le.left)}`,"secondary",h*.04);}),we){let le=tt();se("h:courier",le.x,le.y+Math.sin(e.time*10)*le.r*.08,{shape:"sprite",art:we.def.art,w:le.r*2,h:le.r*2,depth:72}),Be({id:"courier",x:le.x,y:le.y,w:le.r*2.6,h:le.r*2.6});}let $e=oe(),Se=Ee(),Ye=d.w*.25,pt=F>=Ce().charge;pt&&se("h:sk:glow",Ye,$e,{shape:"circle",r:Se*1.28,color:"secondary",alpha:.5+.3*Math.sin(e.time*7),depth:68.9}),se("h:sk:bg",Ye,$e,{shape:"circle",r:Se,color:"panel",alpha:.95,depth:69}),se("h:sk",Ye,$e,{shape:"sprite",art:Ce().art,w:Se*1.4,h:Se*1.4,alpha:pt?1:.45,depth:69.2}),Te("h:charge",Ye,$e+Se*1.3,Se*2,Math.max(5,Se*.2),F/Ce().charge,"secondary",69),Be({id:"skill",x:Ye,y:$e,w:Se*2.4,h:Se*2.4}),oi(i,3).forEach((le,V)=>{let te=d.w*(.47+V*.18),Y=i.cash>=le.price;se(`h:u${V}:bg`,te,$e,{shape:"circle",r:Se,color:Y?"accent":"panel",alpha:Y?.95:.7,depth:69}),se(`h:u${V}`,te,$e-Se*.08,{shape:"sprite",art:le.def.art,w:Se*1.5,h:Se*1.5,alpha:Y?1:.55,depth:69.2});let w=le.index>=0?i.biz[le.index]:void 0;w&&se(`h:u${V}:b`,te+Se*.7,$e-Se*.6,{shape:"sprite",art:w.def.art,w:Se*.9,h:Se*.9,color:w.def.color,depth:69.3}),_e(`h:u${V}:p`,te,$e+Se*1.3,vr(le.price),Y?"coin":"muted",Se*.42,69.3),Be({id:`up:${le.key}`,x:te,y:$e,w:Se*2.3,h:Se*2.6});}),($===null||!e.isAlive($))&&($=e.create(),e.set($,ie,{shape:"actor",cast:Re().cast,h:Se*2.6,pose:"idle",facing:1,depth:20})),e.set($,K,{x:d.w*.09,y:$e-Se*.1});let ze=e.need($,ie);if(ze.shape==="actor"&&(ze.h=Se*2.6),de){let le=Math.min(d.w*.86,500),V=le*.42,te=d.w/2,Y=d.h*.5;se("h:inv:dim",te,Y,{shape:"rect",w:d.w,h:d.h,color:"#000000",alpha:.35,depth:79}),se("h:inv",te,Y,{shape:"sprite",art:"panel",w:le,h:V,color:"panel",depth:80}),se("h:inv:i",te-le*.34,Y,{shape:"sprite",art:de.def.art,w:V*.62,h:V*.62,depth:80.1});let w=le*.3,S=V*.5,l=Ze();se("h:inv:a",te+le*.02,Y-V*.04,{shape:"sprite",art:"button",w,h:S,color:"accent",depth:80.1}),se("h:inv:a:c",te+le*.02-w*.28,Y-V*.04,{shape:"sprite",art:"coin",w:S*.4,h:S*.4,depth:80.2}),_e("h:inv:a:t",te+le*.02+w*.1,Y-V*.04,vr(l),"coin",S*.3,80.2),se("h:inv:b",te+le*.33,Y-V*.04,{shape:"sprite",art:"button",w,h:S,color:"secondary",depth:80.1}),_e("h:inv:b:t",te+le*.33,Y-V*.04,`\xD7${de.def.mult??2} ${de.def.seconds??30}s`,"text",S*.28,80.2),Te("h:inv:bar",te+le*.17,Y+V*.32,le*.6,Math.max(4,V*.05),de.left/de.def.ttl,"coin",80.1),Be({id:"inv_now",x:te+le*.02,y:Y-V*.04,w,h:S}),Be({id:"inv_share",x:te+le*.33,y:Y-V*.04,w,h:S});}},Gt=()=>{k=[],Ne.clear(),Ie(),Ae(),ke(),e.vars.ty_buttons=k.map(d=>`${d.id}@${Math.round(d.x)},${Math.round(d.y)}`).join(";");},Xe=()=>{e.vars.cash=Math.floor(i.cash),e.vars.earned=Math.floor(i.earned),e.vars.time_left=O,e.vars.ty_charge=Math.floor(F),e.vars.ty_mode=ws[ne]??1,e.vars.level_progress=ii(i,ce()),e.vars.ty_goals=ce().map(d=>`${d.kind}:${Math.floor(ht(d))}/${d.n}`).join("|");},rt=()=>{for(let h of [...p.values(),...m.values()])e.isAlive(h)&&e.destroy(h);p.clear(),m.clear(),$!==null&&e.isAlive($)&&e.destroy($),$=null,a=Do(Oo(e,"meta:chapter")||1,o("difficulty"));let d={income:Oo(e,"meta:income"),speed:Oo(e,"meta:speed"),discount:Oo(e,"meta:discount")};i=ks(a.def,d,Math.round(a.cash*(1+Oo(e,"meta:cash")))),Af.set(e,{s:i,level:a}),zt(e,"board",He(e).h*.24),O=a.day,C=0,z=0,F=0,X=false,ye=false,be=8+n.range(0,4),fe=null,we=null,de=null,e.vars.ty_level=a.level,e.vars.ty_world=a.world,e.vars.coins=0,e.vars.score=0,e.vars.stars=0,e.vars.reviving=false,Xe();},lt=d=>{if(ye)return;ye=true;let h=d==="cleared",v=ii(i,ce()),A=h?Math.min(X?1:3,Ua(O/Math.max(1,a.day))):0,N=Math.round(a.coins*o("coinReward")*(h?[1,1,1.25,1.5][A]:v*.5));N>0&&(Je(e,"coins",N),e.emit("coin-collected",{value:N})),h&&e.vars["meta:first_clear"]===true&&Je(e,"coins",a.firstClearGold),e.vars.stars=A,e.vars.score=Math.round(v*1e3)+(h?A*500+Math.floor(O)*10:0),e.vars.reviving=false,fe=null,we=null,de=null,Xe(),e.emit(Xt,{reason:d,stats:{chapter:a.level,seconds:Math.floor(C),cleared:h,stars:A,coins:Number(e.vars.coins??0),earned:Math.floor(i.earned),managers:ai(i)}});},ft=()=>{ye||(G(e,{kind:"flash",color:"coin"}),lt("cleared"));},yt=()=>{if(e.vars.revive_ready===true&&!X){e.vars.reviving=true,e.emit(tr,{});return}lt("out-of-time");},ut=()=>{Me()&&(X=true,e.vars.reviving=false,O+=Xa,G(e,{kind:"flash",color:"coin"}),Xe());},Et=()=>Math.max(Qa(i),a.cash*.05),Ze=()=>Math.round(Et()*(de?.def.now??25)),Ge=d=>{F=Math.min(Ce().charge,F+vf),e.emit("event-handled",{id:d});},It=()=>{let d=i.biz.map((Q,J)=>({b:Q,i:J})).filter(Q=>Q.b.level>0&&Q.b.broken===0),h=Q=>Q.effect==="rush"?!fe&&d.some(J=>J.b.rush<=0):Q.effect==="break"?!i.biz.some(J=>J.broken>0)&&d.some(J=>J.b.level>=3):Q.effect==="invest"?!de:!we,v=a.def.events.filter(Q=>s.includes(Q)).map(Q=>_o.find(J=>J.id===Q)).filter(Q=>!!Q&&h(Q));if(!v.length)return;let A=v.reduce((Q,J)=>Q+J.weight,0),N=n.range(0,A),B=v.find(Q=>(N-=Q.weight)<0)??v[0];if(B.effect==="rush"){let Q=d.filter(J=>J.b.rush<=0);fe={index:Q[n.int(0,Q.length-1)].i,left:B.ttl,def:B};}else if(B.effect==="break"){let Q=d.filter($e=>$e.b.level>=3),J=Q[n.int(0,Q.length-1)];J.b.broken=B.taps??3,G(e,{kind:"shake",power:.3});}else B.effect==="invest"?de={left:B.ttl,def:B}:we={left:B.ttl,def:B};e.emit("event-started",{id:B.id});},Qe=d=>{fe&&(fe.left-=d)<=0&&(fe=null),we&&(we.left-=d)<=0&&(we=null),de&&(de.left-=d)<=0&&(de=null),a.def.events.length&&(be-=d,be<=0&&(It(),be=n.range(tc[0],tc[1])));},Kt=d=>{let h=i.biz[d];if(!h||h.level<=0)return;let v=Le(d);if(h.broken>0){G(e,{kind:"burst",x:v.x,y:v.y,color:"ground",n:6,size:v.size*.6}),ti(i,d)&&(G(e,{kind:"ring",x:v.x,y:v.y,color:"accent",size:v.size*1.2}),Ge("break"));return}fe?.index===d&&(h.rush=fe.def.seconds??10,h.rushMult=fe.def.mult??3,G(e,{kind:"ring",x:v.x,y:v.y,color:"coin",size:v.size*1.4}),G(e,{kind:"pop",x:v.x,y:v.y-v.size*.45,text:`\xD7${h.rushMult}`,color:"coin",size:Math.round(v.size*.3)}),fe=null,Ge("rush"));let A=ei(i,d);A<=0||(F=Math.min(Ce().charge,F+kf),Lt(e,"tycoon-collect"),G(e,{kind:"burst",x:v.x,y:v.y,color:"coin",n:8,size:v.size*.7}),G(e,{kind:"pop",x:v.x,y:v.y-v.size*.35,text:`+${vr(A)}`,color:"coin",size:Math.round(v.size*.24)}),e.emit("cycle-collected",{index:d,amount:A}));},Yt=d=>{let h=i.biz[d];if(!h)return;let v=Ya(i,d,ee(d)),A=Pe(d),N=A.x+A.w/2-A.w*.14;if(!v.ok){G(e,{kind:"shake",power:.1});return}Lt(e,"tycoon-buy");let B=Le(d);G(e,{kind:"ring",x:B.x,y:B.y,color:"coin",size:B.size*1.1}),G(e,{kind:"burst",x:N,y:A.y,color:"accent",n:5,size:A.h*.5}),e.emit("business-bought",{id:h.def.id,level:h.level});for(let Q of v.milestones)G(e,{kind:"flash",color:"coin"}),G(e,{kind:"pop",x:B.x,y:B.y-B.size*.5,text:`\u2605 ${Q}`,color:"coin",size:Math.round(B.size*.3)}),e.emit("milestone",{id:h.def.id,at:Q});},Ft=d=>{let h=i.biz[d];if(!h||!Ja(i,d))return;Lt(e,"tycoon-manager");let v=Le(d);G(e,{kind:"ring",x:v.x,y:v.y,color:"secondary",size:v.size*1.3}),G(e,{kind:"pop",x:v.x,y:v.y-v.size*.5,text:"\u2605",color:"secondary",size:Math.round(v.size*.35)}),e.emit("manager-hired",{id:h.def.id});},ur=(d,h,v)=>{si(i,d)&&(Lt(e,"tycoon-upgrade"),G(e,{kind:"ring",x:h,y:v,color:"accent",size:Ee()*2.6}),G(e,{kind:"flash",color:"accent"}),e.emit("upgrade-bought",{key:d}));},bt=()=>{let d=Ce();if(F<d.charge)return false;let h=1+Oo(e,"meta:skill");if(F=0,$!==null&&Fe(e,$,"cheer"),G(e,{kind:"flash",color:"secondary"}),d.effect==="rush")ri(i,{id:"skill",left:(d.seconds??12)*h,income:d.mult??5,price:1});else if(d.effect==="sale")ri(i,{id:"sale",left:(d.seconds??15)*h,income:1,price:d.mult??.5});else {let v=dc(i,Math.max(1,Math.round((d.cycles??8)*h))),A=ue();G(e,{kind:"pop",x:A.w/2,y:A.h*.16,text:`+${vr(v)}`,color:"coin",size:Math.round(A.U*.07)}),i.biz.forEach((N,B)=>{if(N.level<=0)return;let Q=Le(B);G(e,{kind:"burst",x:Q.x,y:Q.y,color:"coin",n:10,size:Q.size*.8});});}return e.emit("skill-cast",{id:d.id}),Lt(e,"tycoon-skill"),true},D=()=>{if(!we)return;let d=tt(),h=Math.round(Et()*(we.def.now??15));fc(i,h);let v=Math.round((we.def.coins??0)*o("coinReward"));v>0&&(Je(e,"coins",v),e.emit("coin-collected",{value:v})),G(e,{kind:"burst",x:d.x,y:d.y,color:"coin",n:14,size:d.r*2}),G(e,{kind:"pop",x:d.x,y:d.y+d.r*1.4,text:`+${vr(h)}`,color:"coin",size:Math.round(d.r*.7)}),we=null,Ge("courier");},u=d=>{if(!de)return;let h=de.def;d?ri(i,{id:"invest",left:h.seconds??30,income:h.mult??2,price:1}):fc(i,Ze()),de=null,G(e,{kind:"flash",color:"coin"}),Ge("invest");},g=(d,h,v)=>k.find(A=>(!v||A.id.startsWith(v))&&Math.abs(d-A.x)<=A.w/2&&Math.abs(h-A.y)<=A.h/2);e.on(Nt,d=>{let h=d;if(h.type!=="tap"||!st(e)||hn(e)||ye||Me())return;Bt(e),z=0;let v=de?g(h.x,h.y,"inv_")??g(h.x,h.y):g(h.x,h.y,"courier")??g(h.x,h.y);v&&(v.id==="inv_now"?u(false):v.id==="inv_share"?u(true):v.id==="courier"?D():v.id==="mode"?ne=(ne+1)%ws.length:v.id==="skill"?bt():v.id.startsWith("up:")?ur(v.id.slice(3),v.x,v.y):v.id.startsWith("biz")?Kt(Number(v.id.slice(3))):v.id.startsWith("buy")?Yt(Number(v.id.slice(3))):v.id.startsWith("mgr")&&Ft(Number(v.id.slice(3))),Xe(),Ms(i,ce())&&ft());}),e.on(Ut,()=>{rt(),e.vars.level=a.level;}),e.on(Qt,rt),e.on(rr,ut),e.on(nr,()=>{Me()&&(e.vars.reviving=false,lt("out-of-time"));}),e.on(Zt,d=>{Ne.clear(),ke(),k=[],e.vars.ty_buttons="",$!==null&&e.isAlive($)&&it(e,$,d.reason==="cleared"?"dance":"idle");}),e.on(qt,()=>zt(e,"board",He(e).h*.24));let f=d=>{if(!d)return;let h=d.kind==="collect"||d.kind==="fix"?`biz${d.index}`:d.kind==="buy"?`buy${d.index}`:d.kind==="hire"?`mgr${d.index}`:`up:${d.key}`;return k.find(v=>v.id===h)},b=d=>{let h=ue().U,v=i.biz.findIndex(A=>A.ready);if(!vt(d,"tycoon-collect")&&v>=0){let A=Le(v);return kt(d,"tap",A,void 0,A.size*.8)}if(!vt(d,"tycoon-buy")){let A=i.biz.findIndex(B=>i.cash>=vn(i,B,ee(i.biz.indexOf(B)))),N=k.find(B=>B.id===`buy${A}`);if(A>=0&&N)return kt(d,"tap",N,void 0,N.h)}if(!vt(d,"tycoon-manager")){let A=i.biz.findIndex(B=>B.level>0&&!B.manager&&i.cash>=To(i,B)),N=k.find(B=>B.id===`mgr${A}`);if(A>=0&&N)return kt(d,"tap",N,void 0,N.w)}if(F>=Ce().charge&&!vt(d,"tycoon-skill")){let A=k.find(N=>N.id==="skill");if(A)return kt(d,"tap",A,void 0,A.w)}if(z>6){let A=f(li(i,ce()));A&&kt(d,"tap",A,void 0,Math.min(A.w,h*.18));}};e.addSystem({id:"tycoon",order:0,run(d,h){if(!(!st(d)||ye)){if(!Me()){C+=h,z+=h,O=Math.max(0,O-h);for(let v of ni(i,h).paid)v.amount<=0||d.emit("cycle-collected",{index:v.index,amount:v.amount});F=Math.min(Ce().charge,F+h),Qe(h);}if(Gt(),Xe(),!Me()){if(Ms(i,ce()))return ft();_r(d)||b(d),O<=0&&yt();}}}}),rt();}};var sn=(e,t,r,o,n,s,a,i,p)=>({en:e,ru:t,kz:r,zh:o,ko:n,ja:s,hi:a,pt:i,de:p}),fi=sn("Score","\u041E\u0447\u043A\u0438","\u04B0\u043F\u0430\u0439","\u5206\u6570","\uC810\uC218","\u30B9\u30B3\u30A2","\u0938\u094D\u0915\u094B\u0930","Pontos","Punkte"),mc={id:"fantasy",version:1,setting:"fantasy",names:sn("Fantasy","\u0424\u044D\u043D\u0442\u0435\u0437\u0438","\u0424\u044D\u043D\u0442\u0435\u0437\u0438","\u5947\u5E7B","\uD310\uD0C0\uC9C0","\u30D5\u30A1\u30F3\u30BF\u30B8\u30FC","\u092B\u093C\u0948\u0902\u091F\u0947\u0938\u0940","Fantasia","Fantasy"),palette:{background:"#1f2a1d",ground:"#3b4a2e",lane:"#56683f",primary:"#4fa3e0",secondary:"#8e5bd1",danger:"#d0483b",coin:"#f2c14e",accent:"#6fbf4a",text:"#fff6e0",muted:"#b9b08f",piece1:"#e0443e",piece2:"#3f7fe0",piece3:"#43b05c",piece4:"#f2c14e",piece5:"#9b59d0",piece6:"#ef8a2f",panel:"#3a2f25"},texts:{"res.coins":sn("Gold","\u0417\u043E\u043B\u043E\u0442\u043E","\u0410\u043B\u0442\u044B\u043D","\u91D1\u5E01","\uACE8\uB4DC","\u30B4\u30FC\u30EB\u30C9","\u0938\u094B\u0928\u093E","Ouro","Gold"),"res.score":fi},races:["human","elf","dwarf","orc","undead"],cast:{hero:{preset:"knight",races:["human"]},foe:{preset:"berserker",parts:{Hat:null,Offhand:null,Weapon:"weapon/battle_axe"},races:["orc"]},foe2:{preset:"viking",parts:{Weapon:"weapon/double_axe"},races:["orc"]},boss:{preset:"dark_knight",races:["orc"]},helper:{preset:"hunter",parts:{Weapon:null,Hat:null},races:["elf","dwarf","human"]},foe3:{preset:"crossbowman",parts:{Weapon:"weapon/crossbow"},races:["undead"]},foe4:{preset:"lumberjack",parts:{Weapon:"weapon/spear",Back:null},races:["undead"]},foe5:{preset:"hunter",parts:{Hat:null,Back:null,Weapon:"weapon/dagger"},races:["undead"]},hero2:{preset:"crusader",races:["human","dwarf"]},hero3:{preset:"archmage",races:["elf"]}}},yc={id:"sci-fi",version:1,setting:"sci-fi",names:sn("Sci-fi","\u041D\u0430\u0443\u0447\u043D\u0430\u044F \u0444\u0430\u043D\u0442\u0430\u0441\u0442\u0438\u043A\u0430","\u0492\u044B\u043B\u044B\u043C\u0438 \u0444\u0430\u043D\u0442\u0430\u0441\u0442\u0438\u043A\u0430","\u79D1\u5E7B","SF","SF","\u0935\u093F\u091C\u094D\u091E\u093E\u0928 \u0915\u0925\u093E","Fic\xE7\xE3o cient\xEDfica","Science-Fiction"),palette:{background:"#0b1020",ground:"#151d33",lane:"#22305a",primary:"#36e3ff",secondary:"#b45cff",danger:"#ff3d6e",coin:"#ffe14d",accent:"#3dff9a",text:"#e8f6ff",muted:"#7d8fb3",piece1:"#ff3d6e",piece2:"#36a3ff",piece3:"#3dff9a",piece4:"#ffe14d",piece5:"#b45cff",piece6:"#ff8f3d",panel:"#18213d"},texts:{"res.coins":sn("Chips","\u0427\u0438\u043F\u044B","\u0427\u0438\u043F\u0442\u0435\u0440","\u82AF\u7247","\uCE69","\u30C1\u30C3\u30D7","\u091A\u093F\u092A\u094D\u0938","Chips","Chips"),"res.score":fi},races:["human"],cast:{hero:{preset:"soldier",races:["human"]},foe:{preset:"soldier",parts:{Hat:"hat/great_helm",Weapon:"weapon/pistol"},races:["undead"]},foe2:{preset:"gunslinger",parts:{Weapon:"weapon/rifle",Back:null},races:["orc"]},boss:{preset:"dark_knight",parts:{Weapon:"weapon/flame_sword"},races:["orc"]},helper:{preset:"gunslinger",parts:{Weapon:null,Back:null},races:["elf","human"]},foe3:{preset:"gunslinger",parts:{Weapon:"weapon/pistol",Back:null},races:["undead"]},foe4:{preset:"soldier",parts:{Hat:"hat/great_helm",Weapon:"weapon/spear"},races:["orc"]},foe5:{preset:"soldier",parts:{Hat:null,Back:null,Weapon:"weapon/dagger"},races:["undead"]},hero2:{preset:"musketeer",parts:{Weapon:"weapon/rifle"},races:["human"]},hero3:{preset:"archmage",parts:{Weapon:"weapon/wizard_staff"},races:["elf","human"]}}},gc={id:"cozy",version:1,setting:"cozy",names:sn("Cozy cartoon","\u0423\u044E\u0442\u043D\u044B\u0439 \u043C\u0443\u043B\u044C\u0442\u044F\u0448\u043D\u044B\u0439","\u0416\u0430\u0439\u043B\u044B \u043C\u0443\u043B\u044C\u0442\u0444\u0438\u043B\u044C\u043C","\u6E29\u99A8\u5361\u901A","\uC544\uB291\uD55C \uCE74\uD230","\u307B\u306E\u307C\u306E\u30AB\u30FC\u30C8\u30A5\u30FC\u30F3","\u0906\u0930\u093E\u092E\u0926\u093E\u092F\u0915 \u0915\u093E\u0930\u094D\u091F\u0942\u0928","Cartoon aconchegante","Gem\xFCtlicher Cartoon"),palette:{background:"#fdf1e4",ground:"#f3d9bf",lane:"#e9c6a3",primary:"#ff8fab",secondary:"#8fb8ff",danger:"#ff6b6b",coin:"#ffb627",accent:"#7ccf8a",text:"#3d2b25",muted:"#9c8478",piece1:"#ff8fab",piece2:"#7fb8ff",piece3:"#8cd98f",piece4:"#ffd166",piece5:"#c39bff",piece6:"#ffa96b",panel:"#fff8f0"},texts:{"res.coins":sn("Coins","\u041C\u043E\u043D\u0435\u0442\u043A\u0438","\u0422\u0438\u044B\u043D\u0434\u0430\u0440","\u786C\u5E01","\uCF54\uC778","\u30B3\u30A4\u30F3","\u0938\u093F\u0915\u094D\u0915\u0947","Moedas","M\xFCnzen"),"res.score":fi},races:["human","elf","dwarf"],cast:{hero:{preset:"camper",parts:{Glasses:null},races:["human"]},foe:{preset:"lumberjack",parts:{Weapon:"weapon/3",Back:null},races:["orc"]},foe2:{preset:"lumberjack",parts:{Weapon:null,Back:null},races:["dwarf"]},boss:{preset:"viking",races:["orc"]},helper:{preset:"camper",parts:{Weapon:null,Back:null,Glasses:null},races:["human","elf","dwarf"]},foe3:{preset:"hunter",parts:{Weapon:"weapon/hunting_bow"},races:["orc"]},foe4:{preset:"quarterback",races:["orc"]},foe5:{preset:"camper",parts:{Weapon:null,Back:null,Glasses:null},races:["orc"]},hero2:{preset:"quarterback",races:["human"]},hero3:{preset:"wizard",races:["elf"]}}},bc={id:"post-apocalypse",version:1,setting:"post-apocalypse",names:sn("Post-apocalypse","\u041F\u043E\u0441\u0442\u0430\u043F\u043E\u043A\u0430\u043B\u0438\u043F\u0441\u0438\u0441","\u041F\u043E\u0441\u0442\u0430\u043F\u043E\u043A\u0430\u043B\u0438\u043F\u0441\u0438\u0441","\u672B\u65E5\u5E9F\u571F","\uD3EC\uC2A4\uD2B8 \uC544\uD3EC\uCE7C\uB9BD\uC2A4","\u30DD\u30B9\u30C8\u30A2\u30DD\u30AB\u30EA\u30D7\u30B9","\u092A\u094D\u0930\u0932\u092F \u0915\u0947 \u092C\u093E\u0926","P\xF3s-apocalipse","Postapokalypse"),palette:{background:"#1d1a16",ground:"#3a3328",lane:"#4d4436",primary:"#d9a441",secondary:"#7a8f5b",danger:"#b8402d",coin:"#e0c060",accent:"#8fa35a",text:"#f0e6d2",muted:"#a39a86",piece1:"#b8402d",piece2:"#5a7f9a",piece3:"#7a8f5b",piece4:"#e0c060",piece5:"#8a6a4a",piece6:"#d9762f",panel:"#2c2620"},texts:{"res.coins":sn("Caps","\u041A\u0440\u044B\u0448\u043A\u0438","\u049A\u0430\u049B\u043F\u0430\u049B\u0442\u0430\u0440","\u74F6\u76D6","\uBCD1\uB69C\uAED1","\u30AD\u30E3\u30C3\u30D7","\u0922\u0915\u094D\u0915\u0928","Tampinhas","Kronkorken"),"res.score":fi},races:["human","undead","orc"],cast:{hero:{preset:"soldier",parts:{Hat:null,Gloves:"gloves/bracers"},races:["human"]},foe:{preset:"lumberjack",parts:{Weapon:null,Back:null,Gloves:null},races:["undead"]},foe2:{preset:"berserker",parts:{Hat:null,Offhand:null,Weapon:"weapon/mace"},races:["orc"]},boss:{preset:"berserker",parts:{Hat:"hat/great_helm",Weapon:"weapon/double_axe"},races:["orc"]},helper:{preset:"soldier",parts:{Hat:null,Weapon:null},races:["human"]},foe3:{preset:"musketeer",parts:{Weapon:"weapon/musket",Hat:null},races:["undead"]},foe4:{preset:"viking",parts:{Weapon:"weapon/mace"},races:["undead"]},foe5:{preset:"lumberjack",parts:{Weapon:"weapon/dagger",Back:null},races:["undead"]},hero2:{preset:"viking",parts:{Hat:null},races:["human"]},hero3:{preset:"ranger",races:["human"]}}},Co=[mc,yc,gc,bc],uc=(e,t)=>(e.flows??[]).some(r=>r.resource===t.resource&&r.by===t.by&&r.kind===t.kind)?e:{...e,flows:[...e.flows??[],t]},Df=e=>e.resources?.find(t=>t.kind==="currency")?.id??"coins",xc=e=>t=>uc(t,{resource:Df(t),by:`system:${e}`,kind:"sink"}),kc={id:"hero-upgrade",version:1,name:"link.hero-upgrade",core:["runner","platformer","survivors","tower-defense"],systems:["character"],apply:xc("character")},vc={id:"puzzle-city",version:1,name:"link.puzzle-city",core:["match3","merge"],systems:[],apply(e){if(e.modes.some(o=>o.id==="city"))return e;let t=Df(e),r={...e,modes:[...e.modes,{id:"city",preset:"tycoon",role:"meta"}]};return uc(uc(r,{resource:t,by:"city",kind:"source",amount:"vars.coins"}),{resource:t,by:"system:store",kind:"sink"})}},$c={id:"runner-collection",version:1,name:"link.runner-collection",core:["runner","platformer"],systems:["lootboxes","collections"],apply:xc("lootboxes")},Mc={id:"defense-boosts",version:1,name:"link.defense-boosts",core:["tower-defense","survivors"],systems:["boosts"],apply:xc("boosts")},pi=[kc,vc,$c,Mc];var Of=(e,t)=>`${e.character}-${t}`;var Cf={id:"runner",version:1,engine:"phaser",genre:"runner",name:"preset.runner",blocks:["round","lane-runner"],params:{difficulty:{type:"number",default:.5,min:0,max:1},generosity:{type:"number",default:.6,min:0,max:1},lanes:{type:"number",default:3,min:2,max:5,integer:true},lives:{type:"number",default:3,min:1,max:9,integer:true},length:{type:"number",default:1,min:.05,max:5}},blockParams:{"lane-runner":{lanes:"params.lanes",lives:"params.lives",difficulty:"params.difficulty",coinRate:"0.5 + params.generosity * 0.4",powerRate:"0.12 + params.generosity * 0.2",lengthScale:"params.length"}},produces:["soft","score"],placements:[{id:"reward_window",kind:"reward-window"},{id:"revive",kind:"revive",dailyLimit:5}]},Po={difficulty:{type:"number",default:.5,min:0,max:1},generosity:{type:"number",default:.6,min:0,max:1}},Io=[{id:"reward_window",kind:"reward-window"}],Pf={id:"platformer",version:1,engine:"phaser",genre:"platformer",name:"preset.platformer",blocks:["round","platformer"],params:{...Po,lives:{type:"number",default:3,min:1,max:9,integer:true},doubleJump:{type:"boolean",default:false}},blockParams:{platformer:{difficulty:"params.difficulty",lives:"params.lives",doubleJump:"params.doubleJump"}},produces:["soft","score"],placements:[...Io,{id:"revive",kind:"revive",dailyLimit:5}]},If={id:"survivors",version:1,engine:"phaser",genre:"survivors",name:"preset.survivors",blocks:["round","survivors"],params:{...Po,minutes:{type:"number",default:5,min:.5,max:15}},blockParams:{survivors:{duration:"params.minutes * 60",spawnRate:"0.9 + params.difficulty * 0.6",spawnGrowth:"0.6 + params.difficulty * 0.6",foeHpGrowth:"0.3 + params.difficulty * 0.3",foeDamage:"0.8 + params.difficulty * 0.4",coinRate:"0.15 + params.generosity * 0.3",hp:"120 - params.difficulty * 40"}},produces:["soft","score"],placements:[...Io,{id:"revive",kind:"revive",dailyLimit:5},{id:"reroll",kind:"retry",dailyLimit:10}]},Nf={id:"tower-defense",version:2,engine:"phaser",genre:"tower-defense",name:"preset.tower-defense",blocks:["round","tower-defense"],params:{...Po,lives:{type:"number",default:20,min:1,max:100,integer:true}},blockParams:{"tower-defense":{difficulty:"params.difficulty",lives:"params.lives",coinRate:"0.08 + params.generosity * 0.25",earlyGold:"1 + params.generosity * 2"}},produces:["soft","score"],placements:[...Io,{id:"revive",kind:"revive",dailyLimit:5}]},zf={id:"match3",version:2,engine:"phaser",genre:"match3",name:"preset.match3",blocks:["round","match3"],params:{...Po},blockParams:{match3:{difficulty:"params.difficulty",coinEvery:"12 - params.generosity * 7"}},produces:["soft","score","stars"],placements:[...Io,{id:"revive",kind:"revive",dailyLimit:5}]},Bf={id:"merge",version:2,engine:"phaser",genre:"merge",name:"preset.merge",blocks:["round","merge"],params:{...Po},blockParams:{merge:{difficulty:"params.difficulty",orderReward:"0.6 + params.generosity * 0.8"}},produces:["soft","score","stars"],placements:[...Io,{id:"revive",kind:"revive",dailyLimit:5}]},Hf={id:"tycoon",version:2,engine:"phaser",genre:"idle-tycoon",name:"preset.tycoon",blocks:["round","tycoon"],params:{...Po},blockParams:{tycoon:{difficulty:"params.difficulty",coinReward:"0.6 + params.generosity * 0.8"}},produces:["soft","score","stars"],placements:[...Io,{id:"revive",kind:"revive",dailyLimit:5}]},Wf=[Cf,Pf,If,Nf,zf,Bf,Hf],vu=[Gs,qs,Sa,Ca,Va,da,va,di];function $u(e){Ho(e);for(let t of vu)e.has(dn,t.id)||e.define(dn,t);for(let t of Co)e.has(Fn,t.id)||e.define(Fn,t);for(let t of pi)e.has(Wo,t.id)||e.define(Wo,t);for(let t of Wf)e.has(fn,t.id)||e.define(fn,t);}var Mu={v:1,engine:"phaser",seed:"demo-runner",modes:[{id:"run",preset:"runner",role:"core"}],resources:[{id:"coins",kind:"currency",ref:"CO",name:"res.coins"},{id:"score",kind:"score",name:"res.score"}],flows:[{resource:"coins",by:"run",kind:"source",amount:"vars.coins"},{resource:"coins",by:"system:store",kind:"sink"},{resource:"score",by:"run",kind:"source",amount:"vars.score"}],texts:{title:{en:"Lane Dash",ru:"\u0420\u044B\u0432\u043E\u043A \u043F\u043E \u043F\u043E\u043B\u043E\u0441\u0430\u043C"},hint:{en:"Swipe or tap a side to change lanes",ru:"\u0421\u0432\u0430\u0439\u043F \u0438\u043B\u0438 \u043D\u0430\u0436\u0430\u0442\u0438\u0435 \u0441\u0431\u043E\u043A\u0443 \u043C\u0435\u043D\u044F\u0435\u0442 \u043F\u043E\u043B\u043E\u0441\u0443"}}};function wu(e,t={}){let r=e==="runner"?"run":"main";return {v:1,engine:"phaser",seed:t.seed??e,modes:[{id:r,preset:e,role:"core",...t.params?{params:t.params}:{}}],resources:[{id:"coins",kind:"currency",ref:t.coinRef??"CO",name:"res.coins"},{id:"score",kind:"score",name:"res.score"}],flows:[{resource:"coins",by:r,kind:"source",amount:"vars.coins"},{resource:"coins",by:"system:store",kind:"sink"},{resource:"score",by:r,kind:"source",amount:"vars.score"}],...t.texts?{texts:t.texts}:{},...t.palette?{palette:t.palette}:{},...t.assets?{assets:t.assets}:{}}}var jf=255,Vf=10;var an=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),ui=e=>e===void 0?e:JSON.parse(JSON.stringify(e)),Gf=(e,t)=>JSON.stringify(e)===JSON.stringify(t),Eu=/^([A-Za-z0-9_-]+)(?:\[([A-Za-z0-9_-]+)=([^\]]*)\])?$/,Su=/^'([^']+)'$/;function Lu(e){let t=[],r="",o=false;for(let n of e)n==="'"&&(o=!o),n==="."&&!o?(t.push(r),r=""):r+=n;return t.push(r),t}function mi(e){if(!e)return [];let t=[];for(let r of Lu(e)){let o=Su.exec(r);if(o){t.push({key:o[1]});continue}let n=Eu.exec(r);if(!n)return null;t.push(n[2]!==void 0?{key:n[1],match:{field:n[2],value:n[3]??""}}:{key:n[1]});}return t}function Kf(e,t){let r=e.range;if(!r||t===void 0)return e.value;let o=Math.min(Math.max(Number.isFinite(t)?t:.5,0),1),n=r.min+o*(r.max-r.min);if(r.integer)return Math.round(n);let s=10**(r.digits??2);return Math.round(n*s)/s}function hi(e,t){if(!an(e)||!an(t))return ui(t);let r={...e};for(let[o,n]of Object.entries(t))r[o]=o in r?hi(r[o],n):ui(n);return r}function _u(e,t,r){let o=an(e)?ui(e):{},n=[];return t.forEach((s,a)=>{let i=mi(s.path);if(!i){n.push(a);return}let p=ui(Kf(s,r));if(i.length===0){s.op==="set"&&an(p)?o=p:s.op==="merge"&&an(p)?o=hi(o,p):n.push(a);return}let m=o;for(let k=0;k<i.length-1;k++){let O=Ru(m,i[k],s.ifExists!==true);if(O===void 0){n.push(a);return}m=O;}let $=i[i.length-1];if(!an(m)){n.push(a);return}if($.match){let k=m[$.key];if(!Array.isArray(k)){n.push(a);return}let O=k.findIndex(C=>an(C)&&String(C[$.match.field])===$.match.value);if(O<0){n.push(a);return}s.op==="set"?k[O]=p:s.op==="merge"?k[O]=hi(k[O],p):s.op==="unset"?k.splice(O,1):n.push(a);return}if(s.ifExists===true&&m[$.key]===void 0){n.push(a);return}switch(s.op){case "set":m[$.key]=p;break;case "merge":m[$.key]=m[$.key]===void 0?p:hi(m[$.key],p);break;case "unset":delete m[$.key];break;case "add":case "remove":{let k=Array.isArray(p)?p:[p],O=m[$.key];if(O!==void 0&&!Array.isArray(O)){n.push(a);return}let C=O?[...O]:[];if(s.op==="add")for(let z of k)C.some(F=>Gf(F,z))||C.push(z);else for(let z of k){let F=C.findIndex(ne=>Gf(ne,z));F>=0&&C.splice(F,1);}m[$.key]=C;break}}}),{value:o,skipped:n}}function Ru(e,t,r){if(an(e)){if(t.match){let o=e[t.key];return Array.isArray(o)?o.find(n=>an(n)&&String(n[t.match.field])===t.match.value):void 0}if(e[t.key]===void 0||e[t.key]===null){if(!r)return;e[t.key]={};}return e[t.key]}}function Au(e){return [...new Set(e.map(t=>`${t.section}:${t.path??""}`))]}var Tu=/^#([0-9a-f]{6})$/i;function Ff(e){let t=Tu.exec(e);if(!t)return [0,0,.5];let r=parseInt(t[1],16),o=(r>>16&255)/255,n=(r>>8&255)/255,s=(r&255)/255,a=Math.max(o,n,s),i=Math.min(o,n,s),p=(a+i)/2;if(a===i)return [0,0,p];let m=a-i,$=p>.5?m/(2-a-i):m/(a+i),k=a===o?(n-s)/m+(n<s?6:0):a===n?(s-o)/m+2:(o-n)/m+4;return k*=60,[k,$,p]}function qf(e,t,r){let o=(e%360+360)%360/360,n=Math.min(Math.max(t,0),1),s=Math.min(Math.max(r,0),1),a=p=>{let m=p;m<0&&(m+=1),m>1&&(m-=1);let $=s<.5?s*(1+n):s+n-s*n,k=2*s-$;return m<1/6?k+($-k)*6*m:m<1/2?$:m<2/3?k+($-k)*(2/3-m)*6:k},i=p=>Math.round(p*255).toString(16).padStart(2,"0");return n===0?`#${i(s)}${i(s)}${i(s)}`:`#${i(a(o+1/3))}${i(a(o))}${i(a(o-1/3))}`}function yi(e,t,r=1,o=0){let[n,s,a]=Ff(e);return qf(n+t,s*r,a+o)}function gi(e,t){let[r,o,n]=Ff(e);return qf(r,o,n*(1-t))}var Oe=(e,t)=>({en:e,ru:t}),Ec=(e,t)=>({section:"Look",op:"set",path:e,value:t}),wc=(e,t)=>({section:"GameSpec",op:"set",path:e,value:t}),Du=[{id:"casual-violet",title:Oe("Violet casual","\u0424\u0438\u043E\u043B\u0435\u0442\u043E\u0432\u044B\u0439 \u043A\u0430\u0437\u0443\u0430\u043B"),what:"Bright blue-violet screens, chunky glossy buttons: the classic mobile casual look.",examples:["any casual game","puzzle","arcade"],bgTop:"#5865f2",bgBottom:"#5a3fd6",panel:"#3d8ff5",nav:"#2c3794",ink:"#17193a"},{id:"candy-pink",title:Oe("Candy pink","\u0420\u043E\u0437\u043E\u0432\u0430\u044F \u043A\u043E\u043D\u0444\u0435\u0442\u0430"),what:"Sweet pink and raspberry, playful and girly, candy shop mood.",examples:["sweets","fashion","pets","kids"],bgTop:"#ff7ac6",bgBottom:"#d94a9c",panel:"#ff9ad5",nav:"#a8306f",ink:"#4a1235"},{id:"sunny-orange",title:Oe("Sunny orange","\u0421\u043E\u043B\u043D\u0435\u0447\u043D\u044B\u0439 \u043E\u0440\u0430\u043D\u0436\u0435\u0432\u044B\u0439"),what:"Warm orange and yellow, cheerful summer energy.",examples:["beach","fruit","summer","food"],bgTop:"#ffb347",bgBottom:"#ff7a2f",panel:"#ffc75f",nav:"#c4521b",ink:"#4a2410"},{id:"forest-green",title:Oe("Forest green","\u041B\u0435\u0441\u043D\u043E\u0439 \u0437\u0435\u043B\u0451\u043D\u044B\u0439"),what:"Deep greens of a forest, calm nature mood.",examples:["farm","nature","elves","camping"],bgTop:"#4caf50",bgBottom:"#2e7d32",panel:"#66bb6a",nav:"#1b5e20",ink:"#0f2e12"},{id:"ocean-blue",title:Oe("Ocean blue","\u041E\u043A\u0435\u0430\u043D\u0441\u043A\u0438\u0439 \u0441\u0438\u043D\u0438\u0439"),what:"Sea blue and aqua, fresh water mood.",examples:["ocean","fishing","pirates","islands"],bgTop:"#29b6f6",bgBottom:"#0277bd",panel:"#4fc3f7",nav:"#01579b",ink:"#062c47"},{id:"midnight-navy",title:Oe("Midnight navy","\u041F\u043E\u043B\u043D\u043E\u0447\u043D\u044B\u0439 \u0441\u0438\u043D\u0438\u0439"),what:"Dark navy night, calm and serious, stars at night.",examples:["space","night","strategy","sleep"],bgTop:"#283593",bgBottom:"#0d1442",panel:"#3949ab",nav:"#141a52",ink:"#070a22"},{id:"neon-cyber",title:Oe("Neon cyber","\u041D\u0435\u043E\u043D\u043E\u0432\u044B\u0439 \u043A\u0438\u0431\u0435\u0440"),what:"Black with neon cyan and magenta, cyberpunk and synthwave.",examples:["cyberpunk","hackers","racing at night","sci-fi"],bgTop:"#1a1033",bgBottom:"#07040f",panel:"#2b1a55",nav:"#120a26",ink:"#00e5ff",gold:"#ff3df5",green:"#00ffa3"},{id:"space-purple",title:Oe("Space purple","\u041A\u043E\u0441\u043C\u0438\u0447\u0435\u0441\u043A\u0438\u0439 \u043F\u0443\u0440\u043F\u0443\u0440"),what:"Deep purple space with nebula tones.",examples:["space","aliens","galaxy","magic"],bgTop:"#6a1b9a",bgBottom:"#2a0845",panel:"#8e24aa",nav:"#38006b",ink:"#16001f"},{id:"lava-red",title:Oe("Lava red","\u041B\u0430\u0432\u043E\u0432\u044B\u0439 \u043A\u0440\u0430\u0441\u043D\u044B\u0439"),what:"Hot red and black, danger, fire and action.",examples:["fire","volcano","action","boss fights"],bgTop:"#e53935",bgBottom:"#7f0000",panel:"#ef5350",nav:"#5c0000",ink:"#2a0000"},{id:"royal-gold",title:Oe("Royal gold","\u041A\u043E\u0440\u043E\u043B\u0435\u0432\u0441\u043A\u043E\u0435 \u0437\u043E\u043B\u043E\u0442\u043E"),what:"Gold and deep burgundy, rich, royal and luxurious.",examples:["kings","casino","treasure","empire"],bgTop:"#8e2b3a",bgBottom:"#4a0f1c",panel:"#b3424f",nav:"#3a0a15",ink:"#1f0509",gold:"#ffcf40"},{id:"ice-frost",title:Oe("Ice frost","\u041B\u0435\u0434\u044F\u043D\u043E\u0439"),what:"Pale icy blue and white, winter and snow.",examples:["winter","snow","christmas","north"],bgTop:"#e3f6ff",bgBottom:"#9fd7f5",panel:"#ffffff",nav:"#5aa6d6",ink:"#1d4a6b",light:true},{id:"paper-light",title:Oe("Paper light","\u0421\u0432\u0435\u0442\u043B\u0430\u044F \u0431\u0443\u043C\u0430\u0433\u0430"),what:"Clean light paper, minimal and calm, for word and brain games.",examples:["words","quiz","sudoku","education"],bgTop:"#fbf7ef",bgBottom:"#efe6d5",panel:"#ffffff",nav:"#cdbfa6",ink:"#3d3428",light:true},{id:"mint-fresh",title:Oe("Mint fresh","\u0421\u0432\u0435\u0436\u0430\u044F \u043C\u044F\u0442\u0430"),what:"Light mint and teal, fresh and soft.",examples:["cafe","health","relax","spa"],bgTop:"#b9f6e3",bgBottom:"#5fd4b0",panel:"#e6fff7",nav:"#2f9b80",ink:"#0e3d33",light:true},{id:"lemon-pop",title:Oe("Lemon pop","\u041B\u0438\u043C\u043E\u043D\u043D\u044B\u0439 \u043F\u043E\u043F"),what:"Bright lemon yellow, loud and happy pop art.",examples:["comics","party","kids","music"],bgTop:"#fff176",bgBottom:"#fbc02d",panel:"#fff9c4",nav:"#c49000",ink:"#3d2c00",light:true},{id:"peach-soft",title:Oe("Soft peach","\u041D\u0435\u0436\u043D\u044B\u0439 \u043F\u0435\u0440\u0441\u0438\u043A"),what:"Soft peach and coral pastel, cosy and gentle.",examples:["cooking","home decor","romance","pets"],bgTop:"#ffd3b6",bgBottom:"#ffaa85",panel:"#fff0e6",nav:"#d9775a",ink:"#4a2418",light:true},{id:"lavender-dream",title:Oe("Lavender dream","\u041B\u0430\u0432\u0430\u043D\u0434\u043E\u0432\u044B\u0439 \u0441\u043E\u043D"),what:"Pastel lavender, dreamy and magical.",examples:["fairies","unicorns","dreams","princess"],bgTop:"#e1d5ff",bgBottom:"#b39ddb",panel:"#f5f0ff",nav:"#7e57c2",ink:"#2e1a4d",light:true},{id:"toxic-lime",title:Oe("Toxic lime","\u042F\u0434\u043E\u0432\u0438\u0442\u044B\u0439 \u043B\u0430\u0439\u043C"),what:"Acid lime on dark, toxic, zombies and slime.",examples:["zombies","slime","chemistry","monsters"],bgTop:"#33402a",bgBottom:"#141a10",panel:"#4b5e35",nav:"#1c2414",ink:"#a6ff00",gold:"#d4ff3d",green:"#7dff2a"},{id:"desert-sand",title:Oe("Desert sand","\u041F\u0443\u0441\u0442\u044B\u043D\u043D\u044B\u0439 \u043F\u0435\u0441\u043E\u043A"),what:"Sand, ochre and terracotta, desert and ancient ruins.",examples:["egypt","western","desert","archaeology"],bgTop:"#e0b075",bgBottom:"#b5763f",panel:"#f0c995",nav:"#8a5126",ink:"#3b2210"},{id:"rust-wasteland",title:Oe("Rust wasteland","\u0420\u0436\u0430\u0432\u0430\u044F \u043F\u0443\u0441\u0442\u043E\u0448\u044C"),what:"Rusty brown and dusty orange, post-apocalypse scrap.",examples:["post-apocalypse","scrap","survival","mad roads"],bgTop:"#6d4c41",bgBottom:"#2e1f1a",panel:"#8d6e63",nav:"#3e2723",ink:"#140c09",gold:"#ff9e40"},{id:"steel-gray",title:Oe("Steel gray","\u0421\u0442\u0430\u043B\u044C\u043D\u043E\u0439 \u0441\u0435\u0440\u044B\u0439"),what:"Cool steel and graphite, military and industrial.",examples:["army","tanks","factory","robots"],bgTop:"#607d8b",bgBottom:"#263238",panel:"#78909c",nav:"#1c262b",ink:"#0b1013"},{id:"jungle-teal",title:Oe("Jungle teal","\u0422\u0440\u043E\u043F\u0438\u0447\u0435\u0441\u043A\u0438\u0439 \u0431\u0438\u0440\u044E\u0437\u043E\u0432\u044B\u0439"),what:"Teal and jungle green, tropical adventure.",examples:["jungle","tropics","dinosaurs","explorers"],bgTop:"#26a69a",bgBottom:"#00695c",panel:"#4db6ac",nav:"#004d40",ink:"#00211c"},{id:"berry-plum",title:Oe("Berry plum","\u042F\u0433\u043E\u0434\u043D\u0430\u044F \u0441\u043B\u0438\u0432\u0430"),what:"Plum and berry purple, juicy and rich.",examples:["berries","potions","fashion","music"],bgTop:"#ad1457",bgBottom:"#4a0072",panel:"#c2185b",nav:"#38004d",ink:"#1a0024"},{id:"sky-day",title:Oe("Clear sky","\u042F\u0441\u043D\u043E\u0435 \u043D\u0435\u0431\u043E"),what:"Light sky blue with white clouds, open and friendly.",examples:["flying","birds","kids","travel"],bgTop:"#bfe9ff",bgBottom:"#6ec6ff",panel:"#ffffff",nav:"#3a9ad9",ink:"#123a5a",light:true},{id:"chocolate",title:Oe("Chocolate","\u0428\u043E\u043A\u043E\u043B\u0430\u0434"),what:"Brown chocolate and caramel, sweet and warm.",examples:["bakery","coffee","sweets","autumn"],bgTop:"#8d5a3b",bgBottom:"#4e2c1a",panel:"#a6704b",nav:"#3b2012",ink:"#1a0d06",gold:"#ffc56b"},{id:"autumn-maple",title:Oe("Autumn maple","\u041E\u0441\u0435\u043D\u043D\u0438\u0439 \u043A\u043B\u0451\u043D"),what:"Orange and red autumn leaves, harvest mood.",examples:["autumn","halloween","harvest","forest"],bgTop:"#ef6c00",bgBottom:"#8c2f00",panel:"#f57c00",nav:"#6b2300",ink:"#2b0e00"},{id:"spooky-night",title:Oe("Spooky night","\u0416\u0443\u0442\u043A\u0430\u044F \u043D\u043E\u0447\u044C"),what:"Dark purple and pumpkin orange, ghosts and halloween.",examples:["halloween","ghosts","horror lite","witches"],bgTop:"#311b92",bgBottom:"#120838",panel:"#4527a0",nav:"#0d0629",ink:"#05020f",gold:"#ff8f00"},{id:"sakura",title:Oe("Sakura","\u0421\u0430\u043A\u0443\u0440\u0430"),what:"Cherry blossom pink with soft white, japanese spring.",examples:["japan","anime","spring","ninja lite"],bgTop:"#ffd6e7",bgBottom:"#f48fb1",panel:"#fff3f8",nav:"#c2185b",ink:"#4d0f2a",light:true},{id:"matrix-green",title:Oe("Terminal green","\u0422\u0435\u0440\u043C\u0438\u043D\u0430\u043B\u044C\u043D\u044B\u0439 \u0437\u0435\u043B\u0451\u043D\u044B\u0439"),what:"Black with bright terminal green, hacker console.",examples:["hacking","code","retro computers","spy"],bgTop:"#0b1f0f",bgBottom:"#000000",panel:"#123317",nav:"#06120a",ink:"#39ff6a",gold:"#c6ff00",green:"#39ff6a"},{id:"retro-arcade",title:Oe("Retro arcade","\u0420\u0435\u0442\u0440\u043E-\u0430\u0440\u043A\u0430\u0434\u0430"),what:"Eighties arcade: deep blue with hot pink and yellow.",examples:["retro","pixel","80s","arcade"],bgTop:"#1e2a78",bgBottom:"#0a0f3d",panel:"#ff2e88",nav:"#0a0f3d",ink:"#05071f",gold:"#ffe600"},{id:"stone-dungeon",title:Oe("Stone dungeon","\u041A\u0430\u043C\u0435\u043D\u043D\u043E\u0435 \u043F\u043E\u0434\u0437\u0435\u043C\u0435\u043B\u044C\u0435"),what:"Dark stone and torchlight, dungeons and castles.",examples:["dungeon","castle","knights","rpg"],bgTop:"#4e4a46",bgBottom:"#1f1c1a",panel:"#6b655e",nav:"#171513",ink:"#0a0908",gold:"#ffb300"},{id:"emerald-luxe",title:Oe("Emerald luxe","\u0418\u0437\u0443\u043C\u0440\u0443\u0434\u043D\u044B\u0439 \u043B\u044E\u043A\u0441"),what:"Emerald green with gold, wealth and luck.",examples:["casino","luck","money","irish"],bgTop:"#00695c",bgBottom:"#00251a",panel:"#00897b",nav:"#001a12",ink:"#000c08",gold:"#ffd54f"},{id:"bubblegum",title:Oe("Bubblegum","\u0416\u0432\u0430\u0447\u043A\u0430"),what:"Pastel cyan and pink together, fun and bouncy.",examples:["kids","toys","party","bubbles"],bgTop:"#a0f0ff",bgBottom:"#ff9fe0",panel:"#ffffff",nav:"#d66bb4",ink:"#3a1f4d",light:true},{id:"military-olive",title:Oe("Military olive","\u0410\u0440\u043C\u0435\u0439\u0441\u043A\u0430\u044F \u043E\u043B\u0438\u0432\u0430"),what:"Olive drab and khaki, army and survival.",examples:["army","war","survival","hunting"],bgTop:"#6b7a3a",bgBottom:"#33391b",panel:"#808f4a",nav:"#262b14",ink:"#101207",gold:"#e6c34d"},{id:"deep-sea",title:Oe("Deep sea","\u041C\u043E\u0440\u0441\u043A\u0430\u044F \u0431\u0435\u0437\u0434\u043D\u0430"),what:"Very dark teal-blue of the deep ocean with glowing tones.",examples:["submarine","deep sea","mermaids","monsters"],bgTop:"#004e64",bgBottom:"#001219",panel:"#00677f",nav:"#000c11",ink:"#000508",gold:"#94fbab",green:"#4dfff3"},{id:"sunset",title:Oe("Sunset","\u0417\u0430\u043A\u0430\u0442"),what:"Orange to purple sunset gradient, warm evening.",examples:["travel","music","romance","racing"],bgTop:"#ff8a65",bgBottom:"#6a1b9a",panel:"#ff7043",nav:"#4a148c",ink:"#1f0738"},{id:"arctic-night",title:Oe("Polar night","\u041F\u043E\u043B\u044F\u0440\u043D\u0430\u044F \u043D\u043E\u0447\u044C"),what:"Dark blue with aurora green and cyan.",examples:["aurora","north","winter night","magic"],bgTop:"#0d3b66",bgBottom:"#021526",panel:"#145374",nav:"#01101e",ink:"#000810",gold:"#7cf5c8",green:"#3ff2a0"},{id:"honey",title:Oe("Honey","\u041C\u0451\u0434"),what:"Golden honey amber, warm and sweet, bees and farms.",examples:["bees","farm","bakery","sunny"],bgTop:"#ffca28",bgBottom:"#ff8f00",panel:"#ffe082",nav:"#b26a00",ink:"#3d2400"},{id:"monochrome",title:Oe("Monochrome","\u041C\u043E\u043D\u043E\u0445\u0440\u043E\u043C"),what:"Black, white and gray only, strict and stylish.",examples:["noir","minimal","chess","detective"],bgTop:"#3a3a3a",bgBottom:"#111111",panel:"#555555",nav:"#0c0c0c",ink:"#000000",gold:"#ffffff",green:"#d9d9d9"},{id:"tropical-punch",title:Oe("Tropical punch","\u0422\u0440\u043E\u043F\u0438\u0447\u0435\u0441\u043A\u0438\u0439 \u043F\u0443\u043D\u0448"),what:"Hot coral, turquoise and yellow, tropical party.",examples:["tropics","summer party","cocktails","carnival"],bgTop:"#ff5e62",bgBottom:"#ff9966",panel:"#1de9b6",nav:"#c2364a",ink:"#3d0f16"},{id:"cloud-gray",title:Oe("Soft gray","\u041C\u044F\u0433\u043A\u0438\u0439 \u0441\u0435\u0440\u044B\u0439"),what:"Light neutral gray, calm and modern, apps and tools.",examples:["tools","productivity","calm puzzle","office"],bgTop:"#f2f4f7",bgBottom:"#d5dae1",panel:"#ffffff",nav:"#8a94a6",ink:"#2b313b",light:true}];function Ou(e){let t={bgTop:e.bgTop,bgBottom:e.bgBottom,panel:e.panel,panelDeep:gi(e.panel,.18),panelEdge:e.ink,ink:e.ink,nav:e.nav,text:e.light?e.ink:"#ffffff",textDim:e.light?yi(e.ink,0,.6,.25):yi(e.panel,0,.5,.35)};return e.gold&&(t.gold=e.gold,t.goldDeep=gi(e.gold,.2)),e.green&&(t.green=e.green,t.greenDeep=gi(e.green,.25)),{id:e.id,title:e.title,what:e.what,examples:e.examples,swatch:[e.bgTop,e.bgBottom,e.panel,e.gold??"#ffd43b"],patches:[Ec("Theme",t)]}}var Uf=Du.map(Ou),Cu=[{id:"classic",title:Oe("Classic","\u041A\u043B\u0430\u0441\u0441\u0438\u043A\u0430"),what:"The pack's own colours.",dh:0,sat:1,dl:0},{id:"dawn",title:Oe("Dawn","\u0420\u0430\u0441\u0441\u0432\u0435\u0442"),what:"Lighter and warmer, a morning mood.",dh:20,sat:1.05,dl:.08},{id:"night",title:Oe("Night","\u041D\u043E\u0447\u044C"),what:"Darker and bluer, a night mood.",dh:-35,sat:.9,dl:-0.07},{id:"ember",title:Oe("Ember","\u0423\u0433\u043B\u0438"),what:"Shifted to red and orange, hot and dangerous.",dh:-60,sat:1.15,dl:0},{id:"frost",title:Oe("Frost","\u0418\u043D\u0435\u0439"),what:"Shifted to cyan and pale blue, cold and icy.",dh:140,sat:.8,dl:.05},{id:"toxic",title:Oe("Toxic","\u042F\u0434"),what:"Shifted to acid green and yellow, toxic.",dh:70,sat:1.25,dl:0},{id:"royal",title:Oe("Royal","\u041A\u043E\u0440\u043E\u043B\u0435\u0432\u0441\u043A\u0438\u0439"),what:"Shifted to purple and violet, magical and noble.",dh:200,sat:1.1,dl:0},{id:"faded",title:Oe("Faded","\u0412\u044B\u0446\u0432\u0435\u0442\u0448\u0438\u0439"),what:"Muted, low saturation, old photo and dusty.",dh:0,sat:.45,dl:.03}],Pu=["background","ground","lane","primary","secondary","accent","muted","panel"],Xf=Co.flatMap(e=>Cu.map(t=>{let r={...e.palette};for(let o of Pu){let n=e.palette[o];n&&(r[o]=yi(n,t.dh,t.sat,t.dl));}return {id:`${e.id}-${t.id}`,title:{en:`${e.names.en??e.id}: ${t.title.en}`,ru:`${e.names.ru??e.id}: ${t.title.ru}`},what:`${e.names.en??e.id} world. ${t.what}`,swatch:[r.background,r.ground,r.primary,r.accent],patches:[wc("assets",e.id),wc("palette",r)]}})),Iu=[["knight","Knight","\u0420\u044B\u0446\u0430\u0440\u044C","An armoured knight with a sword and shield, brave and classic."],["dark_knight","Dark knight","\u0422\u0451\u043C\u043D\u044B\u0439 \u0440\u044B\u0446\u0430\u0440\u044C","A knight in black armour, grim and mighty."],["archmage","Archmage","\u0410\u0440\u0445\u0438\u043C\u0430\u0433","An old wizard in robes with a staff, magic and wisdom."],["berserker","Berserker","\u0411\u0435\u0440\u0441\u0435\u0440\u043A","A wild warrior with a big axe, rage and strength."],["hunter","Hunter","\u041E\u0445\u043E\u0442\u043D\u0438\u043A","A hunter with a bow and a hood, forests and tracking."],["crossbowman","Crossbowman","\u0410\u0440\u0431\u0430\u043B\u0435\u0442\u0447\u0438\u043A","A soldier with a crossbow, a careful shooter."],["gunslinger","Gunslinger","\u0421\u0442\u0440\u0435\u043B\u043E\u043A","A cowboy gunslinger, the wild west and duels."],["musketeer","Musketeer","\u041C\u0443\u0448\u043A\u0435\u0442\u0451\u0440","A musketeer with a hat and a musket, honour and adventure."],["soldier","Soldier","\u0421\u043E\u043B\u0434\u0430\u0442","A modern soldier with a rifle, war and missions."],["quarterback","Quarterback","\u041A\u0432\u043E\u0442\u0435\u0440\u0431\u0435\u043A","An american football player, sport and teams."],["lumberjack","Lumberjack","\u041B\u0435\u0441\u043E\u0440\u0443\u0431","A bearded lumberjack in a checked shirt with an axe, woods and work."],["viking","Viking","\u0412\u0438\u043A\u0438\u043D\u0433","A horned viking with a hammer, the north and raids."],["wizard","Wizard","\u0412\u043E\u043B\u0448\u0435\u0431\u043D\u0438\u043A","A young wizard with a pointy hat, spells and school of magic."],["ranger","Ranger","\u0421\u043B\u0435\u0434\u043E\u043F\u044B\u0442","A ranger of the wild, light armour and a long bow."],["king","King","\u041A\u043E\u0440\u043E\u043B\u044C","A king with a crown and a cape, kingdoms and rule."],["camper","Camper","\u0422\u0443\u0440\u0438\u0441\u0442","A casual hiker with a backpack, everyday modern life."],["crusader","Crusader","\u041A\u0440\u0435\u0441\u0442\u043E\u043D\u043E\u0441\u0435\u0446","A holy warrior in white and gold, light against darkness."]],Zf=Iu.map(([e,t,r,o])=>({id:e,title:Oe(t,r),what:o,patches:[wc("cast.hero.preset",e)]})),Qf=[["gear","Game gear","\u0418\u0433\u0440\u043E\u0432\u044B\u0435 \u043F\u0440\u0435\u0434\u043C\u0435\u0442\u044B","Faint swords, shields, potions, gems and crowns: the classic casual game look."],["plain","Plain gradient","\u0427\u0438\u0441\u0442\u044B\u0439 \u0433\u0440\u0430\u0434\u0438\u0435\u043D\u0442","No pattern, only the theme's gradient."],["dots","Polka dots","\u0413\u043E\u0440\u043E\u0448\u0435\u043A","Soft polka dots, playful."],["stripes","Diagonal stripes","\u0414\u0438\u0430\u0433\u043E\u043D\u0430\u043B\u044C\u043D\u044B\u0435 \u043F\u043E\u043B\u043E\u0441\u044B","Diagonal stripes, energetic and sporty."],["grid","Grid","\u0421\u0435\u0442\u043A\u0430","A thin grid like graph paper, tech or puzzle."],["hex","Honeycomb","\u0421\u043E\u0442\u044B","A honeycomb pattern, bees, sci-fi or strategy."],["stars","Stars","\u0417\u0432\u0451\u0437\u0434\u044B","Small scattered stars, night, space or magic."],["waves","Waves","\u0412\u043E\u043B\u043D\u044B","Soft waves, water and the sea."],["checker","Checkerboard","\u0428\u0430\u0445\u043C\u0430\u0442\u043A\u0430","A checkerboard, board games, racing flags."],["confetti","Confetti","\u041A\u043E\u043D\u0444\u0435\u0442\u0442\u0438","Colourful confetti bits, party and celebration."],["bubbles","Bubbles","\u041F\u0443\u0437\u044B\u0440\u0438","Round bubbles of different sizes, underwater or soda."],["zigzag","Zigzag","\u0417\u0438\u0433\u0437\u0430\u0433","A bold zigzag, retro and pop."],["diamonds","Diamonds","\u0420\u043E\u043C\u0431\u044B","A diamond pattern, cards, casino, royal."],["clouds","Clouds","\u041E\u0431\u043B\u0430\u043A\u0430","Puffy clouds, sky and dreams."],["leaves","Leaves","\u041B\u0438\u0441\u0442\u044C\u044F","Scattered leaves, nature, forest and autumn."],["circuit","Circuit","\u041C\u0438\u043A\u0440\u043E\u0441\u0445\u0435\u043C\u0430","Circuit board lines, robots, hackers and tech."],["sparkles","Sparkles","\u0418\u0441\u043A\u0440\u044B","Twinkling sparkles, magic, fairies and treasure."],["rays","Sun rays","\u041B\u0443\u0447\u0438","Rays from the centre, victory and big wins."],["bricks","Bricks","\u041A\u0438\u0440\u043F\u0438\u0447\u0438","A brick wall, city, castle or dungeon."],["paws","Paw prints","\u0421\u043B\u0435\u0434\u044B \u043B\u0430\u043F","Little paw prints, pets and animals."],["snow","Snowflakes","\u0421\u043D\u0435\u0436\u0438\u043D\u043A\u0438","Falling snowflakes, winter and holidays."]],Yf=Qf.map(([e,t,r,o])=>({id:e,title:Oe(t,r),what:o,patches:[Ec("Background",e)]})),Jf=[["classic","Classic","\u041A\u043B\u0430\u0441\u0441\u0438\u043A\u0430","The kit's default bright casual clicks and coins."],["soft","Soft","\u041C\u044F\u0433\u043A\u0438\u0435","Quiet, rounded, calm sounds for relaxing games."],["retro","Retro 8-bit","\u0420\u0435\u0442\u0440\u043E 8-\u0431\u0438\u0442","Square-wave chiptune bleeps of old consoles."],["magic","Magic","\u041C\u0430\u0433\u0438\u044F","Shimmering chimes and sparkles, fairy-tale."],["sci-fi","Sci-fi","\u0424\u0430\u043D\u0442\u0430\u0441\u0442\u0438\u043A\u0430","Electronic blips and sweeps, space and robots."],["wood","Wooden","\u0414\u0435\u0440\u0435\u0432\u044F\u043D\u043D\u044B\u0435","Short wooden knocks and marimba, cosy and natural."]],ep=Jf.map(([e,t,r,o])=>({id:e,title:Oe(t,r),what:o,patches:[Ec("SoundSet",e)]})),Nu={backgrounds:Qf.map(e=>e[0]),soundSets:Jf.map(e=>e[0])},Sc={"ui-themes":Uf,"kit-palettes":Xf,"hero-looks":Zf,backgrounds:Yf,"sound-sets":ep};var tp=1,j=(e,t)=>({en:e,ru:t}),Mt=(e,t)=>({section:"Look",op:"set",path:e,value:t}),$n=(e,t,r,o=false)=>({section:"GameSpec",op:"set",path:`modes[role=core].params.${e}`,range:{min:t,max:r,...o?{integer:true}:{}}}),Vt=(e,t)=>({section:"GameSpec",op:"add",path:`modes[role=core].content.${e}.without`,value:t}),wt=(e,t)=>({section:"GameSpec",op:"remove",path:`modes[role=core].content.${e}.without`,value:t}),Ss={modules:["kit-game"]},zu=[{id:"look.theme",group:"look",title:j("Interface colours","\u0426\u0432\u0435\u0442\u0430 \u0438\u043D\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430"),hint:j("Screens, panels and buttons of the whole app.","\u042D\u043A\u0440\u0430\u043D\u044B, \u043F\u0430\u043D\u0435\u043B\u0438 \u0438 \u043A\u043D\u043E\u043F\u043A\u0438 \u0432\u0441\u0435\u0433\u043E \u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u044F."),question:"Pick the colour theme of the app's interface (menus, panels, buttons) that fits this product best.",kind:"choice",list:"ui-themes"},{id:"look.background",group:"look",title:j("Screen pattern","\u0423\u0437\u043E\u0440 \u0444\u043E\u043D\u0430"),hint:j("A pattern over the screens' gradient.","\u0423\u0437\u043E\u0440 \u043F\u043E\u0432\u0435\u0440\u0445 \u0433\u0440\u0430\u0434\u0438\u0435\u043D\u0442\u0430 \u044D\u043A\u0440\u0430\u043D\u043E\u0432."),question:"Pick the background pattern of the app's screens that fits this product best.",kind:"choice",list:"backgrounds"},{id:"look.shape",group:"look",title:j("Shape of buttons","\u0424\u043E\u0440\u043C\u0430 \u043A\u043D\u043E\u043F\u043E\u043A"),question:"What shape should the buttons and panels of the interface have?",kind:"choice",options:[{id:"chunky",title:j("Chunky round","\u041F\u0443\u0445\u043B\u044B\u0435 \u043A\u0440\u0443\u0433\u043B\u044B\u0435"),what:"Big rounded corners and a thick outline: toy-like, casual, for kids.",patches:[Mt("Radius",18),Mt("ButtonRadius",16),Mt("Outline",3)]},{id:"classic",title:j("Classic","\u041A\u043B\u0430\u0441\u0441\u0438\u043A\u0430"),what:"Medium rounded corners and a normal outline: the default mobile casual look.",patches:[Mt("Radius",14),Mt("ButtonRadius",12),Mt("Outline",3)]},{id:"sharp",title:j("Sharp","\u0421\u0442\u0440\u043E\u0433\u0438\u0435"),what:"Small corners and a thin outline: serious, tactical, strategy or sci-fi.",patches:[Mt("Radius",4),Mt("ButtonRadius",4),Mt("Outline",2)]},{id:"pill",title:j("Pills","\u0422\u0430\u0431\u043B\u0435\u0442\u043A\u0438"),what:"Fully round pill buttons, no outline: soft, modern, minimal.",patches:[Mt("Radius",24),Mt("ButtonRadius",32),Mt("Outline",0)]}]},{id:"look.motion",group:"look",title:j("Animations","\u0410\u043D\u0438\u043C\u0430\u0446\u0438\u0438"),question:"How lively should the interface animations be?",kind:"choice",options:[{id:"calm",title:j("Calm","\u0421\u043F\u043E\u043A\u043E\u0439\u043D\u044B\u0435"),what:"Slow, soft, no bounce: relaxing, meditative, for brain games.",patches:[Mt("MotionSpeed",.7),Mt("MotionIntensity",.3),Mt("Particles",false)]},{id:"normal",title:j("Normal","\u041E\u0431\u044B\u0447\u043D\u044B\u0435"),what:"The default lively casual animations.",patches:[Mt("MotionSpeed",1),Mt("MotionIntensity",1),Mt("Particles",true)]},{id:"bouncy",title:j("Bouncy","\u041F\u0440\u0443\u0436\u0438\u043D\u0438\u0441\u0442\u044B\u0435"),what:"Strong bounces and overshoots: cartoonish, playful, for kids.",patches:[Mt("MotionSpeed",1.1),Mt("MotionIntensity",2),Mt("Particles",true)]},{id:"snappy",title:j("Snappy","\u0420\u0435\u0437\u043A\u0438\u0435"),what:"Very fast and short, little bounce: action, arcade, competitive.",patches:[Mt("MotionSpeed",1.8),Mt("MotionIntensity",.6),Mt("Particles",true)]}]},{id:"look.sound",group:"look",title:j("Interface sounds","\u0417\u0432\u0443\u043A\u0438 \u0438\u043D\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430"),question:"Pick the sound style of the interface (clicks, rewards, coins) that fits this product best.",kind:"choice",list:"sound-sets"}],Bu=[{id:"look.kit.palette",group:"look",title:j("World and colours of the game","\u041C\u0438\u0440 \u0438 \u0446\u0432\u0435\u0442\u0430 \u0438\u0433\u0440\u044B"),hint:j("The game's world (fantasy, sci-fi, cozy, post-apocalypse) and its colour mood.","\u041C\u0438\u0440 \u0438\u0433\u0440\u044B (\u0444\u044D\u043D\u0442\u0435\u0437\u0438, \u0444\u0430\u043D\u0442\u0430\u0441\u0442\u0438\u043A\u0430, \u0443\u044E\u0442, \u043F\u043E\u0441\u0442\u0430\u043F\u043E\u043A\u0430\u043B\u0438\u043F\u0441\u0438\u0441) \u0438 \u043D\u0430\u0441\u0442\u0440\u043E\u0435\u043D\u0438\u0435 \u0446\u0432\u0435\u0442\u0430."),for:Ss,question:"Pick the world and colour mood of the game scene that fits this idea best.",kind:"choice",list:"kit-palettes"},{id:"look.kit.hero",group:"look",title:j("The hero","\u0413\u0435\u0440\u043E\u0439"),for:Ss,question:"Pick the look of the game's main hero that fits this idea best.",kind:"choice",list:"hero-looks"},{id:"look.kit.race",group:"look",title:j("Hero's race","\u0420\u0430\u0441\u0430 \u0433\u0435\u0440\u043E\u044F"),for:Ss,question:"Which race should the main hero be?",kind:"choice",options:[["human","Human","\u0427\u0435\u043B\u043E\u0432\u0435\u043A","An ordinary human."],["elf","Elf","\u042D\u043B\u044C\u0444","A graceful elf with pointed ears: forests, magic, archery."],["dwarf","Dwarf","\u0413\u043D\u043E\u043C","A stout bearded dwarf: mines, forges, hammers."],["orc","Orc","\u041E\u0440\u043A","A green orc with tusks: brute strength, war, savage lands."],["undead","Undead","\u041D\u0435\u0436\u0438\u0442\u044C","A pale undead: skeletons, graveyards, dark magic, halloween."]].map(([e,t,r,o])=>({id:e,title:j(t,r),what:o,patches:[{section:"GameSpec",op:"set",path:"cast.hero.races",value:[e]}]}))}],Hu=[{id:"feel.difficulty",group:"feel",title:j("Difficulty","\u0421\u043B\u043E\u0436\u043D\u043E\u0441\u0442\u044C"),for:Ss,question:"How hard should this game be for its players?",kind:"score",levelTitles:[j("Very easy","\u041E\u0447\u0435\u043D\u044C \u043B\u0435\u0433\u043A\u043E"),j("Easy","\u041B\u0435\u0433\u043A\u043E"),j("Balanced","\u0421\u0431\u0430\u043B\u0430\u043D\u0441\u0438\u0440\u043E\u0432\u0430\u043D\u043D\u043E"),j("Hard","\u0421\u043B\u043E\u0436\u043D\u043E"),j("Very hard","\u041E\u0447\u0435\u043D\u044C \u0441\u043B\u043E\u0436\u043D\u043E")],levels:["Very easy and relaxing, for kids or a calm break.","Easy, casual.","Balanced: easy to start, harder later.","Hard, for players who like a challenge.","Very hard and punishing."],patches:[$n("difficulty",0,1)]},{id:"feel.generosity",group:"feel",title:j("Rewards in the game","\u041D\u0430\u0433\u0440\u0430\u0434\u044B \u0432 \u0438\u0433\u0440\u0435"),for:Ss,question:"How generous should the game's rewards be?",kind:"score",levelTitles:[j("Stingy","\u0421\u043A\u0443\u043F\u043E"),j("Modest","\u0421\u043A\u0440\u043E\u043C\u043D\u043E"),j("Normal","\u041E\u0431\u044B\u0447\u043D\u043E"),j("Generous","\u0429\u0435\u0434\u0440\u043E"),j("Very generous","\u041E\u0447\u0435\u043D\u044C \u0449\u0435\u0434\u0440\u043E")],levels:["Stingy: rewards are rare and earned slowly.","Modest rewards.","Normal rewards.","Generous rewards.","Very generous: rewards rain down."],patches:[$n("generosity",0,1)]},{id:"feel.runner.lanes",group:"feel",title:j("Lanes","\u041F\u043E\u043B\u043E\u0441\u044B"),for:{modules:["kit-game"],presets:["runner"]},question:"How wide should the running track be?",kind:"score",levelTitles:[j("2 lanes","2 \u043F\u043E\u043B\u043E\u0441\u044B"),j("3 lanes","3 \u043F\u043E\u043B\u043E\u0441\u044B"),j("4 lanes","4 \u043F\u043E\u043B\u043E\u0441\u044B"),j("5 lanes","5 \u043F\u043E\u043B\u043E\u0441")],levels:["Narrow: two lanes, simple and quick.","Normal: three lanes.","Wide: four lanes.","Very wide: five lanes, lots of dodging."],patches:[$n("lanes",2,5,true)]},{id:"feel.runner.lives",group:"feel",title:j("Lives in a run","\u0416\u0438\u0437\u043D\u0438 \u0432 \u0437\u0430\u0431\u0435\u0433\u0435"),for:{modules:["kit-game"],presets:["runner"]},question:"How many hits should the runner survive?",kind:"score",levelTitles:[j("One hit","\u041E\u0434\u0438\u043D \u0443\u0434\u0430\u0440"),j("A few","\u041D\u0435\u0441\u043A\u043E\u043B\u044C\u043A\u043E"),j("Many","\u041C\u043D\u043E\u0433\u043E")],levels:["One hit ends the run.","A few lives.","Many lives, forgiving."],patches:[$n("lives",1,6,true)]},{id:"feel.runner.length",group:"feel",title:j("Length of levels","\u0414\u043B\u0438\u043D\u0430 \u0443\u0440\u043E\u0432\u043D\u0435\u0439"),for:{modules:["kit-game"],presets:["runner"]},question:"How long should one level of the run be?",kind:"score",levelTitles:[j("Very short","\u041E\u0447\u0435\u043D\u044C \u043A\u043E\u0440\u043E\u0442\u043A\u0438\u0435"),j("Short","\u041A\u043E\u0440\u043E\u0442\u043A\u0438\u0435"),j("Normal","\u041E\u0431\u044B\u0447\u043D\u044B\u0435"),j("Long","\u0414\u043B\u0438\u043D\u043D\u044B\u0435")],levels:["Very short bursts for a quick break.","Short.","Normal.","Long runs."],patches:[$n("length",.5,2)]},{id:"feel.runner.powers",group:"feel",title:j("Power-ups","\u0423\u0441\u0438\u043B\u0435\u043D\u0438\u044F"),for:{modules:["kit-game"],presets:["runner"]},question:"Which power-ups fit this runner best?",kind:"choice",options:[{id:"all",title:j("All of them","\u0412\u0441\u0435"),what:"Magnet, shield, double coins, dash and flight: the full set.",patches:[wt("powers",["magnet","shield","double","dash","flight"])]},{id:"grounded",title:j("On the ground","\u0411\u0435\u0437 \u043F\u043E\u043B\u0451\u0442\u0430"),what:"No flight: magnet, shield, double coins and dash. Realistic, sports, city.",patches:[wt("powers",["magnet","shield","double","dash"]),Vt("powers",["flight"])]},{id:"coins",title:j("Coin hunter","\u041E\u0445\u043E\u0442\u0430 \u0437\u0430 \u043C\u043E\u043D\u0435\u0442\u0430\u043C\u0438"),what:"Only the coin ones: magnet and double coins. Collecting, greed, treasure.",patches:[wt("powers",["magnet","double"]),Vt("powers",["shield","dash","flight"])]},{id:"hardcore",title:j("Hardcore","\u0425\u0430\u0440\u0434\u043A\u043E\u0440"),what:"No shield and no flight: dodging is everything. Skill, challenge.",patches:[wt("powers",["magnet","double","dash"]),Vt("powers",["shield","flight"])]}]},{id:"feel.runner.obstacles",group:"feel",title:j("Obstacles","\u041F\u0440\u0435\u043F\u044F\u0442\u0441\u0442\u0432\u0438\u044F"),for:{modules:["kit-game"],presets:["runner"]},question:"Which obstacles fit this runner best?",kind:"choice",options:[{id:"all",title:j("Everything","\u0412\u0441\u0451 \u043F\u043E\u0434\u0440\u044F\u0434"),what:"Walls, barriers, pits, moving blocks, trains and rocks.",patches:[wt("obstacles",["wall","barrier","pit","mover","train","rock"])]},{id:"city",title:j("City streets","\u0413\u043E\u0440\u043E\u0434\u0441\u043A\u0438\u0435 \u0443\u043B\u0438\u0446\u044B"),what:"Walls, barriers, moving blocks and trains: a city, a subway, traffic.",patches:[wt("obstacles",["wall","barrier","mover","train"]),Vt("obstacles",["pit","rock"])]},{id:"wild",title:j("Wild lands","\u0414\u0438\u043A\u0438\u0435 \u0437\u0435\u043C\u043B\u0438"),what:"Walls, pits, rocks and barriers: forests, mountains, ruins, no trains.",patches:[wt("obstacles",["wall","barrier","pit","rock"]),Vt("obstacles",["mover","train"])]},{id:"simple",title:j("Simple","\u041F\u0440\u043E\u0441\u0442\u044B\u0435"),what:"Only walls, barriers and pits: easy to read, for kids.",patches:[wt("obstacles",["wall","barrier","pit"]),Vt("obstacles",["mover","train","rock"])]}]},{id:"feel.platformer.lives",group:"feel",title:j("Lives on a level","\u0416\u0438\u0437\u043D\u0438 \u043D\u0430 \u0443\u0440\u043E\u0432\u043D\u0435"),for:{modules:["kit-game"],presets:["platformer"]},question:"How many hits should the hero survive on a level?",kind:"score",levelTitles:[j("One hit","\u041E\u0434\u0438\u043D \u0443\u0434\u0430\u0440"),j("A few hearts","\u041D\u0435\u0441\u043A\u043E\u043B\u044C\u043A\u043E \u0441\u0435\u0440\u0434\u0435\u0446"),j("Many hearts","\u041C\u043D\u043E\u0433\u043E \u0441\u0435\u0440\u0434\u0435\u0446")],levels:["One hit and the level restarts.","A few hearts.","Many hearts, forgiving."],patches:[$n("lives",1,6,true)]},{id:"feel.platformer.double-jump",group:"feel",title:j("Double jump from the start","\u0414\u0432\u043E\u0439\u043D\u043E\u0439 \u043F\u0440\u044B\u0436\u043E\u043A \u0441\u0440\u0430\u0437\u0443"),for:{modules:["kit-game"],presets:["platformer"]},question:"Should the hero have a double jump from the very first level?",kind:"noul",yes:"Yes: the game is light and acrobatic, the hero flies around from the start.",no:"No: the double jump is earned later, the start is grounded and careful.",onYes:[{section:"GameSpec",op:"set",path:"modes[role=core].params.doubleJump",value:true}],onNo:[{section:"GameSpec",op:"set",path:"modes[role=core].params.doubleJump",value:false}]},{id:"feel.survivors.minutes",group:"feel",title:j("Length of a chapter","\u0414\u043B\u0438\u043D\u0430 \u0433\u043B\u0430\u0432\u044B"),for:{modules:["kit-game"],presets:["survivors"]},question:"How long should one chapter of survival last?",kind:"score",levelTitles:[j("2 minutes","2 \u043C\u0438\u043D\u0443\u0442\u044B"),j("5 minutes","5 \u043C\u0438\u043D\u0443\u0442"),j("10 minutes","10 \u043C\u0438\u043D\u0443\u0442"),j("15 minutes","15 \u043C\u0438\u043D\u0443\u0442")],levels:["Two minutes: quick bursts.","Five minutes.","Ten minutes.","Fifteen minutes: long sessions."],patches:[$n("minutes",2,15)]},{id:"feel.survivors.foes",group:"feel",title:j("Monsters","\u041C\u043E\u043D\u0441\u0442\u0440\u044B"),for:{modules:["kit-game"],presets:["survivors"]},question:"Which kinds of monsters fit this game best?",kind:"choice",options:[{id:"all",title:j("The whole horde","\u0412\u0441\u044F \u043E\u0440\u0434\u0430"),what:"Swarms, grunts, archers, brutes, chargers and bombers.",patches:[wt("foes",["swarm","grunt","archer","brute","charger","bomber"])]},{id:"melee",title:j("Close combat","\u0411\u043B\u0438\u0436\u043D\u0438\u0439 \u0431\u043E\u0439"),what:"No shooters: swarms, grunts, brutes and chargers. Zombies, beasts.",patches:[wt("foes",["swarm","grunt","brute","charger"]),Vt("foes",["archer","bomber"])]},{id:"army",title:j("An army","\u0410\u0440\u043C\u0438\u044F"),what:"Grunts, archers, brutes and chargers, no swarms: soldiers, knights, war.",patches:[wt("foes",["grunt","archer","brute","charger"]),Vt("foes",["swarm","bomber"])]},{id:"chaos",title:j("Chaos","\u0425\u0430\u043E\u0441"),what:"Swarms, bombers and chargers: fast, explosive, crazy.",patches:[wt("foes",["swarm","charger","bomber","grunt"]),Vt("foes",["archer","brute"])]}]},{id:"feel.td.lives",group:"feel",title:j("Lives of the base","\u0416\u0438\u0437\u043D\u0438 \u0431\u0430\u0437\u044B"),for:{modules:["kit-game"],presets:["tower-defense"]},question:"How many enemies may slip through before the level is lost?",kind:"score",levelTitles:[j("Very few","\u041E\u0447\u0435\u043D\u044C \u043C\u0430\u043B\u043E"),j("Some","\u0421\u0440\u0435\u0434\u043D\u0435"),j("Many","\u041C\u043D\u043E\u0433\u043E")],levels:["Very few: every leak hurts.","Some.","Many: forgiving."],patches:[$n("lives",5,40,true)]},{id:"feel.td.foes",group:"feel",title:j("Enemies in the waves","\u0412\u0440\u0430\u0433\u0438 \u0432 \u0432\u043E\u043B\u043D\u0430\u0445"),for:{modules:["kit-game"],presets:["tower-defense"]},question:"Which enemies should march in the waves of this tower defense?",kind:"choice",options:[{id:"all",title:j("The whole army","\u0412\u0441\u044F \u0430\u0440\u043C\u0438\u044F"),what:"Grunts, runners, brutes, flyers, shamans, healers and splitters: the full mix.",patches:[wt("foes",["grunt","runner","brute","flyer","shaman","healer","splitter"])]},{id:"ground",title:j("Only on foot","\u0422\u043E\u043B\u044C\u043A\u043E \u043F\u0435\u0448\u0438\u0435"),what:"No flyers: every enemy walks the road. Medieval, zombies, ground war.",patches:[wt("foes",["grunt","runner","brute","shaman","healer","splitter"]),Vt("foes",["flyer"])]},{id:"simple",title:j("Plain and clear","\u041F\u0440\u043E\u0441\u0442\u044B\u0435"),what:"No shamans, healers or splitters: easy to read, for kids and casual players.",patches:[wt("foes",["grunt","runner","brute","flyer"]),Vt("foes",["shaman","healer","splitter"])]},{id:"swarm",title:j("Fast hordes","\u0411\u044B\u0441\u0442\u0440\u044B\u0435 \u043E\u0440\u0434\u044B"),what:"No brutes or shamans: many fast weak foes, a frantic pace. Insects, rats, robots.",patches:[wt("foes",["grunt","runner","flyer","healer","splitter"]),Vt("foes",["brute","shaman"])]}]},{id:"feel.survivors.weapons",group:"feel",title:j("Weapons to find","\u041E\u0440\u0443\u0436\u0438\u0435 \u0432 \u0437\u0430\u0431\u0435\u0433\u0435"),hint:j("Which new weapons a level-up may offer.","\u041A\u0430\u043A\u043E\u0435 \u043D\u043E\u0432\u043E\u0435 \u043E\u0440\u0443\u0436\u0438\u0435 \u043F\u0440\u0435\u0434\u043B\u0430\u0433\u0430\u0435\u0442 \u043F\u043E\u0432\u044B\u0448\u0435\u043D\u0438\u0435 \u0443\u0440\u043E\u0432\u043D\u044F."),for:{modules:["kit-game"],presets:["survivors"]},question:"Which weapons fit the hero of this survival game best?",kind:"choice",options:[{id:"all",title:j("Everything","\u0412\u0441\u0451"),what:"Blaster, blades, aura, boomerang, lightning and drone: the full arsenal.",patches:[wt("weapons",["blaster","blades","aura","boomerang","lightning","drone"])]},{id:"tech",title:j("Technology","\u0422\u0435\u0445\u043D\u0438\u043A\u0430"),what:"Blaster, drone and lightning: guns and gadgets. Sci-fi, robots, the future.",patches:[wt("weapons",["blaster","drone","lightning"]),Vt("weapons",["blades","aura","boomerang"])]},{id:"magic",title:j("Magic and steel","\u041C\u0430\u0433\u0438\u044F \u0438 \u0441\u0442\u0430\u043B\u044C"),what:"Blades, aura, boomerang and lightning, no guns: fantasy, wizards, knights.",patches:[wt("weapons",["blades","aura","boomerang","lightning"]),Vt("weapons",["blaster","drone"])]},{id:"classic",title:j("Classic","\u041A\u043B\u0430\u0441\u0441\u0438\u043A\u0430"),what:"Blaster, blades and boomerang: simple weapons that are easy to read.",patches:[wt("weapons",["blaster","blades","boomerang"]),Vt("weapons",["aura","lightning","drone"])]}]},{id:"feel.tycoon.events",group:"feel",title:j("Events in the city","\u0421\u043E\u0431\u044B\u0442\u0438\u044F \u0432 \u0433\u043E\u0440\u043E\u0434\u0435"),for:{modules:["kit-game"],presets:["tycoon"]},question:"Which events should pop up while this tycoon city earns money?",kind:"choice",options:[{id:"all",title:j("Busy life","\u0411\u0443\u0440\u043D\u0430\u044F \u0436\u0438\u0437\u043D\u044C"),what:"Rushes, breakdowns, investors and couriers: always something to tap.",patches:[wt("events",["rush","break","invest","courier"])]},{id:"calm",title:j("No breakdowns","\u0411\u0435\u0437 \u043F\u043E\u043B\u043E\u043C\u043E\u043A"),what:"Rushes, investors and couriers, nothing ever breaks: a calm, cozy business.",patches:[wt("events",["rush","invest","courier"]),Vt("events",["break"])]},{id:"hands-on",title:j("Hands on","\u0421\u0432\u043E\u0438\u043C\u0438 \u0440\u0443\u043A\u0430\u043C\u0438"),what:"Rushes, breakdowns and couriers, no investors: the city grows by your own work.",patches:[wt("events",["rush","break","courier"]),Vt("events",["invest"])]},{id:"minimal",title:j("Only rushes","\u0422\u043E\u043B\u044C\u043A\u043E \u0430\u0436\u0438\u043E\u0442\u0430\u0436"),what:"Only rush hours: a quiet idle game with few interruptions.",patches:[wt("events",["rush"]),Vt("events",["break","invest","courier"])]}]}],Wu=(e,t)=>({Type:"VirtualCurrency",CurrencyID:e,Amount:t}),bi=(e,t,r,o,n)=>({id:e,title:j(t,r),what:o,patches:n.map((s,a)=>({section:"Reward",op:"set",path:`DailyCalendars.daily_login.Days[DayNumber=${a+1}].Rewards.Standard.Entries`,value:s.map(([i,p])=>Wu(i,p))}))}),Lc=(e,t)=>`StoreOffers.${e}.${t}`,ju=[{id:"economy.shop-ad-gems",group:"economy",title:j("Gems for an ad in the shop","\u041A\u0440\u0438\u0441\u0442\u0430\u043B\u043B\u044B \u0437\u0430 \u0440\u0435\u043A\u043B\u0430\u043C\u0443 \u0432 \u043C\u0430\u0433\u0430\u0437\u0438\u043D\u0435"),for:{sections:["Store"]},question:"How many gems should one rewarded ad in the shop give?",kind:"score",levelTitles:[j("A few","\u041C\u0430\u043B\u043E"),j("Some","\u0421\u0440\u0435\u0434\u043D\u0435"),j("A handful","\u041F\u0440\u0438\u043B\u0438\u0447\u043D\u043E"),j("Many","\u041C\u043D\u043E\u0433\u043E")],levels:["A few: gems are rare.","Some.","A good handful.","Many: gems flow freely."],patches:[{section:"Store",op:"set",path:Lc("kit_gems_ad","Reward.Grant.Standard.Entries[Type=VirtualCurrency].Amount"),range:{min:2,max:15,integer:true}}]},{id:"economy.shop-ad-cap",group:"economy",title:j("Ads in the shop a day","\u0420\u0435\u043A\u043B\u0430\u043C\u0430 \u0432 \u043C\u0430\u0433\u0430\u0437\u0438\u043D\u0435 \u0437\u0430 \u0434\u0435\u043D\u044C"),for:{sections:["Store"]},question:"How many times a day may a player watch an ad for gems in the shop?",kind:"score",levelTitles:[j("A few times","\u041D\u0435\u0441\u043A\u043E\u043B\u044C\u043A\u043E \u0440\u0430\u0437"),j("About ten","\u041E\u043A\u043E\u043B\u043E \u0434\u0435\u0441\u044F\u0442\u0438"),j("Many times","\u041C\u043D\u043E\u0433\u043E \u0440\u0430\u0437")],levels:["A few times.","About ten.","Many times."],patches:[{section:"Store",op:"set",path:Lc("kit_gems_ad","Availability.Limits.DailyCap"),range:{min:3,max:20,integer:true}}]},{id:"economy.shop-pack",group:"economy",title:j("Size of the gem pack","\u0420\u0430\u0437\u043C\u0435\u0440 \u043D\u0430\u0431\u043E\u0440\u0430 \u043A\u0440\u0438\u0441\u0442\u0430\u043B\u043B\u043E\u0432"),for:{sections:["Store"]},question:"How many gems should the paid gem pack hold?",kind:"score",levelTitles:[j("Small","\u041C\u0430\u043B\u0435\u043D\u044C\u043A\u0438\u0439"),j("Normal","\u041E\u0431\u044B\u0447\u043D\u044B\u0439"),j("Big","\u0411\u043E\u043B\u044C\u0448\u043E\u0439"),j("Huge","\u041E\u0433\u0440\u043E\u043C\u043D\u044B\u0439")],levels:["A small pack.","A normal pack.","A big pack.","A huge pack: the best deal."],patches:[{section:"Store",op:"set",path:Lc("kit_gems_pack","Reward.Grant.Standard.Entries[Type=VirtualCurrency].Amount"),range:{min:60,max:200,integer:true}}]},{id:"economy.start-coins",group:"economy",title:j("Coins at the start","\u041C\u043E\u043D\u0435\u0442\u044B \u043D\u0430 \u0441\u0442\u0430\u0440\u0442\u0435"),for:{sections:["Currency"]},question:"How many coins should a new player start with?",kind:"score",levelTitles:[j("A few","\u041C\u0430\u043B\u043E"),j("Some","\u0421\u0440\u0435\u0434\u043D\u0435"),j("Comfortable","\u041A\u043E\u043C\u0444\u043E\u0440\u0442\u043D\u043E"),j("Rich","\u0411\u043E\u0433\u0430\u0442\u043E")],levels:["A few: everything is earned.","Some.","A comfortable start.","A rich start: buy upgrades right away."],patches:[{section:"Currency",op:"set",path:"VirtualCurrencies.CO.Economy.InitialDeposit",range:{min:100,max:3e3,integer:true}}]},{id:"economy.ad-multiplier",group:"economy",title:j("Round reward for an ad","\u041D\u0430\u0433\u0440\u0430\u0434\u0430 \u0440\u0430\u0443\u043D\u0434\u0430 \u0437\u0430 \u0440\u0435\u043A\u043B\u0430\u043C\u0443"),hint:j("How many times the round's coins grow for a rewarded ad (in the app).","\u0412\u043E \u0441\u043A\u043E\u043B\u044C\u043A\u043E \u0440\u0430\u0437 \u0440\u0430\u0441\u0442\u0443\u0442 \u043C\u043E\u043D\u0435\u0442\u044B \u0440\u0430\u0443\u043D\u0434\u0430 \u0437\u0430 \u0440\u0435\u043A\u043B\u0430\u043C\u0443 (\u0432 \u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u0438)."),for:{modules:["kit-game"],sections:["Reward"]},question:"How big should the bonus for watching an ad after a round be?",kind:"score",levelTitles:[j("x2","x2"),j("x3","x3"),j("x4","x4"),j("x5","x5")],levels:["Double.","Triple.","Four times.","Five times."],patches:[{section:"Reward",op:"set",path:"Windows.round.AdMultiplier",range:{min:2,max:5,integer:true}}]},{id:"economy.vip-multiplier",group:"economy",title:j("Round reward for VIP","\u041D\u0430\u0433\u0440\u0430\u0434\u0430 \u0440\u0430\u0443\u043D\u0434\u0430 \u0434\u043B\u044F VIP"),for:{modules:["kit-game"],sections:["Reward"]},question:"How big should the round reward bonus of VIP players be?",kind:"score",levelTitles:[j("x3","x3"),j("x5","x5"),j("x8","x8")],levels:["Triple.","Five times.","Eight times."],patches:[{section:"Reward",op:"set",path:"Windows.round.VipMultiplier",range:{min:3,max:8,integer:true}}]},{id:"economy.vip-price",group:"economy",title:j("Price of VIP","\u0426\u0435\u043D\u0430 VIP"),for:{sections:["Premium"]},question:"How expensive should the VIP pass be, in gems?",kind:"score",levelTitles:[j("Cheap","\u0414\u0451\u0448\u0435\u0432\u043E"),j("Normal","\u041E\u0431\u044B\u0447\u043D\u043E"),j("Expensive","\u0414\u043E\u0440\u043E\u0433\u043E")],levels:["Cheap, an easy first purchase.","Normal.","Expensive, for the most devoted."],patches:[{section:"Premium",op:"set",path:"Definitions.vip.PriceOptions.default.Cost.Standard.Entries[Type=VirtualCurrency].Amount",range:{min:20,max:120,integer:true}}]},{id:"economy.daily-calendar",group:"economy",title:j("Daily login rewards","\u041D\u0430\u0433\u0440\u0430\u0434\u044B \u0437\u0430 \u0432\u0445\u043E\u0434"),for:{sections:["Reward"]},question:"Which daily login reward plan fits this game best?",kind:"choice",options:[bi("gentle","Gentle","\u0421\u043A\u0440\u043E\u043C\u043D\u044B\u0435","Small steady rewards every day: a calm game with a slow economy.",[[["CO",50]],[["CO",60]],[["CO",80]],[["GE",2]],[["CO",100]],[["CO",120]],[["GE",8],["CO",150]]]),bi("standard","Standard","\u041E\u0431\u044B\u0447\u043D\u044B\u0435","Growing coins with gems on day 4 and a big day 7.",[[["CO",100]],[["CO",150]],[["CO",200]],[["GE",5]],[["CO",300]],[["CO",400]],[["GE",20],["CO",500]]]),bi("generous","Generous","\u0429\u0435\u0434\u0440\u044B\u0435","Big rewards every day, gems often: a fast, rewarding economy.",[[["CO",300]],[["GE",5]],[["CO",500]],[["GE",10]],[["CO",800]],[["GE",15]],[["GE",40],["CO",1500]]]),bi("jackpot","Jackpot day 7","\u0414\u0436\u0435\u043A\u043F\u043E\u0442 \u043D\u0430 7-\u0439 \u0434\u0435\u043D\u044C","Small days and a huge jackpot on day 7: come back every day.",[[["CO",50]],[["CO",50]],[["CO",80]],[["CO",80]],[["CO",100]],[["CO",150]],[["GE",60],["CO",3e3]]])]}],No=(e,t,r)=>({section:"Quest",op:"set",path:`Quests.${e}.Reward.Grant.Standard.Entries[Type=VirtualCurrency].Amount`,range:{min:t,max:r,integer:true}}),Es=(e,t,r,o)=>({section:"Quest",op:"set",path:`Quests.${e}.Objectives.${t}.TargetValue`,range:{min:r,max:o,integer:true}}),rp="Definitions.star_festival",Mn=e=>{let[t,r]=e.name,[o,n]=e.token,s=`Collect ${o.toLowerCase()} by playing rounds, shopping and finishing quests. VIP gets a second prize on every milestone.`,a=`\u0421\u043E\u0431\u0438\u0440\u0430\u0439\u0442\u0435 ${n.toLowerCase()} \u0432 \u0440\u0430\u0443\u043D\u0434\u0430\u0445, \u043F\u043E\u043A\u0443\u043F\u043A\u0430\u0445 \u0438 \u0437\u0430\u0434\u0430\u043D\u0438\u044F\u0445. VIP \u043F\u043E\u043B\u0443\u0447\u0430\u0435\u0442 \u0432\u0442\u043E\u0440\u043E\u0439 \u043F\u0440\u0438\u0437 \u043D\u0430 \u043A\u0430\u0436\u0434\u043E\u0439 \u0432\u0435\u0445\u0435.`,i=[["stars_10",10],["stars_50",50],["stars_120",120],["stars_250",250]],p=(m,$)=>({section:"TimedEvent",op:"set",path:`${rp}.${m}`,value:$});return {id:e.id,title:j(t,r),what:e.what,patches:[p("DisplayName",t),p("Description",s),p("Content.DisplayName",t),p("Content.Description",s),p("Content.Token.DisplayName",o),...i.map(([m,$])=>p(`Content.Milestones.${m}.DisplayName`,`${$} ${e.unit[0]}`)),p("Content.Milestones.stars_400.DisplayName",e.crown[0])],translations:{ru:{[t]:r,[s]:a,[o]:n,[e.crown[0]]:e.crown[1],...Object.fromEntries(i.map(([,m])=>[`${m} ${e.unit[0]}`,`${m} ${e.unit[1]}`]))}}}},_c=(e,t,r,o,n,s,a)=>({id:e,title:j(t,r),what:a,patches:[{section:"TimedBoost",op:"set",path:"Definitions.double_rewards.Effect.Value",value:o},{section:"TimedBoost",op:"set",path:"Definitions.double_rewards.DisplayName",value:t},{section:"TimedBoost",op:"set",path:"Definitions.double_rewards.Description",value:n}],translations:{ru:{[t]:r,[n]:s}}}),Vu=[{id:"liveops.event-theme",group:"liveops",title:j("Theme of the weekly event","\u0422\u0435\u043C\u0430 \u043D\u0435\u0434\u0435\u043B\u044C\u043D\u043E\u0433\u043E \u0438\u0432\u0435\u043D\u0442\u0430"),hint:j("Name of the event, its tokens and prizes.","\u041D\u0430\u0437\u0432\u0430\u043D\u0438\u0435 \u0438\u0432\u0435\u043D\u0442\u0430, \u0435\u0433\u043E \u0436\u0435\u0442\u043E\u043D\u043E\u0432 \u0438 \u043F\u0440\u0438\u0437\u043E\u0432."),for:{sections:["TimedEvent"]},question:"Which weekly event theme fits this product best?",kind:"choice",options:[Mn({id:"star-festival",name:["Star festival","\u0417\u0432\u0451\u0437\u0434\u043D\u044B\u0439 \u0444\u0435\u0441\u0442\u0438\u0432\u0430\u043B\u044C"],token:["Festival stars","\u0417\u0432\u0451\u0437\u0434\u044B \u0444\u0435\u0441\u0442\u0438\u0432\u0430\u043B\u044F"],unit:["stars","\u0437\u0432\u0451\u0437\u0434"],crown:["Festival crown","\u041A\u043E\u0440\u043E\u043D\u0430 \u0444\u0435\u0441\u0442\u0438\u0432\u0430\u043B\u044F"],what:"A cheerful festival of stars: fits anything."}),Mn({id:"harvest",name:["Harvest fair","\u042F\u0440\u043C\u0430\u0440\u043A\u0430 \u0443\u0440\u043E\u0436\u0430\u044F"],token:["Golden apples","\u0417\u043E\u043B\u043E\u0442\u044B\u0435 \u044F\u0431\u043B\u043E\u043A\u0438"],unit:["apples","\u044F\u0431\u043B\u043E\u043A"],crown:["Golden basket","\u0417\u043E\u043B\u043E\u0442\u0430\u044F \u043A\u043E\u0440\u0437\u0438\u043D\u0430"],what:"Farm, nature, cozy village, autumn."}),Mn({id:"monster-hunt",name:["Monster hunt","\u041E\u0445\u043E\u0442\u0430 \u043D\u0430 \u043C\u043E\u043D\u0441\u0442\u0440\u043E\u0432"],token:["Trophies","\u0422\u0440\u043E\u0444\u0435\u0438"],unit:["trophies","\u0442\u0440\u043E\u0444\u0435\u0435\u0432"],crown:["Hunter's crown","\u041A\u043E\u0440\u043E\u043D\u0430 \u043E\u0445\u043E\u0442\u043D\u0438\u043A\u0430"],what:"Action, fantasy, battles, monsters."}),Mn({id:"space-week",name:["Space week","\u041A\u043E\u0441\u043C\u0438\u0447\u0435\u0441\u043A\u0430\u044F \u043D\u0435\u0434\u0435\u043B\u044F"],token:["Star shards","\u0417\u0432\u0451\u0437\u0434\u043D\u044B\u0435 \u043E\u0441\u043A\u043E\u043B\u043A\u0438"],unit:["shards","\u043E\u0441\u043A\u043E\u043B\u043A\u043E\u0432"],crown:["Galaxy medal","\u041C\u0435\u0434\u0430\u043B\u044C \u0433\u0430\u043B\u0430\u043A\u0442\u0438\u043A\u0438"],what:"Sci-fi, space, robots, the future."}),Mn({id:"winter",name:["Winter holidays","\u0417\u0438\u043C\u043D\u0438\u0435 \u043F\u0440\u0430\u0437\u0434\u043D\u0438\u043A\u0438"],token:["Snowflakes","\u0421\u043D\u0435\u0436\u0438\u043D\u043A\u0438"],unit:["snowflakes","\u0441\u043D\u0435\u0436\u0438\u043D\u043E\u043A"],crown:["Ice crown","\u041B\u0435\u0434\u044F\u043D\u0430\u044F \u043A\u043E\u0440\u043E\u043D\u0430"],what:"Winter, new year, cozy and festive."}),Mn({id:"beach",name:["Beach party","\u041F\u043B\u044F\u0436\u043D\u0430\u044F \u0432\u0435\u0447\u0435\u0440\u0438\u043D\u043A\u0430"],token:["Seashells","\u0420\u0430\u043A\u0443\u0448\u043A\u0438"],unit:["seashells","\u0440\u0430\u043A\u0443\u0448\u0435\u043A"],crown:["Golden surfboard","\u0417\u043E\u043B\u043E\u0442\u0430\u044F \u0434\u043E\u0441\u043A\u0430"],what:"Summer, the sea, islands, holidays."}),Mn({id:"treasure",name:["Treasure hunt","\u041E\u0445\u043E\u0442\u0430 \u0437\u0430 \u0441\u043E\u043A\u0440\u043E\u0432\u0438\u0449\u0430\u043C\u0438"],token:["Map pieces","\u041A\u0443\u0441\u043E\u0447\u043A\u0438 \u043A\u0430\u0440\u0442\u044B"],unit:["pieces","\u043A\u0443\u0441\u043E\u0447\u043A\u043E\u0432"],crown:["Pirate chest","\u041F\u0438\u0440\u0430\u0442\u0441\u043A\u0438\u0439 \u0441\u0443\u043D\u0434\u0443\u043A"],what:"Pirates, adventure, exploring, mysteries."}),Mn({id:"carnival",name:["Carnival","\u041A\u0430\u0440\u043D\u0430\u0432\u0430\u043B"],token:["Masks","\u041C\u0430\u0441\u043A\u0438"],unit:["masks","\u043C\u0430\u0441\u043E\u043A"],crown:["Carnival crown","\u041A\u043E\u0440\u043E\u043D\u0430 \u043A\u0430\u0440\u043D\u0430\u0432\u0430\u043B\u0430"],what:"Music, dance, a bright party, cartoon fun."})]},{id:"liveops.event-pace",group:"liveops",title:j("Pace of the weekly event","\u0422\u0435\u043C\u043F \u043D\u0435\u0434\u0435\u043B\u044C\u043D\u043E\u0433\u043E \u0438\u0432\u0435\u043D\u0442\u0430"),for:{sections:["TimedEvent"]},question:"How fast should players collect the weekly event tokens by playing rounds?",kind:"score",levelTitles:[j("Slow","\u041C\u0435\u0434\u043B\u0435\u043D\u043D\u043E"),j("Normal","\u041E\u0431\u044B\u0447\u043D\u043E"),j("Fast","\u0411\u044B\u0441\u0442\u0440\u043E"),j("Very fast","\u041E\u0447\u0435\u043D\u044C \u0431\u044B\u0441\u0442\u0440\u043E")],levels:["Slow: the top prize is for the most devoted.","Normal.","Fast.","Very fast: most players reach the top."],patches:[{section:"TimedEvent",op:"set",path:`${rp}.Content.TokenSources[SourceType=CustomAction].BaseWeight`,range:{min:2,max:10,integer:true}}]},{id:"liveops.boost-power",group:"liveops",title:j("Power of the reward boost","\u0421\u0438\u043B\u0430 \u0431\u0443\u0441\u0442\u0430 \u043D\u0430\u0433\u0440\u0430\u0434"),for:{sections:["TimedBoost"]},question:"How strong should the paid reward boost be?",kind:"choice",options:[_c("x1-5","Rewards x1.5","\u041D\u0430\u0433\u0440\u0430\u0434\u044B x1.5",1.5,"Every reward is 1.5 times bigger for an hour.","\u041A\u0430\u0436\u0434\u0430\u044F \u043D\u0430\u0433\u0440\u0430\u0434\u0430 \u0432 1.5 \u0440\u0430\u0437\u0430 \u0431\u043E\u043B\u044C\u0448\u0435 \u0432 \u0442\u0435\u0447\u0435\u043D\u0438\u0435 \u0447\u0430\u0441\u0430.","A gentle boost: a slow, balanced economy."),_c("x2","Double rewards","\u0414\u0432\u043E\u0439\u043D\u044B\u0435 \u043D\u0430\u0433\u0440\u0430\u0434\u044B",2,"Every reward is doubled for an hour.","\u041A\u0430\u0436\u0434\u0430\u044F \u043D\u0430\u0433\u0440\u0430\u0434\u0430 \u0443\u0434\u0432\u043E\u0435\u043D\u0430 \u043D\u0430 \u0447\u0430\u0441.","The classic double: fits most games."),_c("x3","Triple rewards","\u0422\u0440\u043E\u0439\u043D\u044B\u0435 \u043D\u0430\u0433\u0440\u0430\u0434\u044B",3,"Every reward is tripled for an hour.","\u041A\u0430\u0436\u0434\u0430\u044F \u043D\u0430\u0433\u0440\u0430\u0434\u0430 \u0443\u0442\u0440\u043E\u0435\u043D\u0430 \u043D\u0430 \u0447\u0430\u0441.","A big boost: a fast, generous economy.")]},{id:"liveops.quest-effort",group:"liveops",title:j("Effort of daily quests","\u0421\u043B\u043E\u0436\u043D\u043E\u0441\u0442\u044C \u0435\u0436\u0435\u0434\u043D\u0435\u0432\u043D\u044B\u0445 \u0437\u0430\u0434\u0430\u043D\u0438\u0439"),for:{sections:["Quest"]},question:"How much play should the daily quests ask for?",kind:"score",levelTitles:[j("A few minutes","\u041F\u0430\u0440\u0430 \u043C\u0438\u043D\u0443\u0442"),j("Short","\u041A\u043E\u0440\u043E\u0442\u043A\u043E"),j("Normal","\u041E\u0431\u044B\u0447\u043D\u043E"),j("Long","\u0414\u043E\u043B\u0433\u043E")],levels:["Very little: done in a few minutes.","A short session.","A normal session.","A long session: for devoted players."],patches:[Es("daily_play","play",1,8),Es("daily_earn","earn",50,500),Es("kit_daily_coins","coins",100,1500),Es("kit_daily_time","seconds",180,1800),Es("kit_daily_levels","levels",1,6)]},{id:"liveops.quest-rewards",group:"liveops",title:j("Rewards of daily quests","\u041D\u0430\u0433\u0440\u0430\u0434\u044B \u0437\u0430 \u0437\u0430\u0434\u0430\u043D\u0438\u044F"),for:{sections:["Quest"]},question:"How generous should the rewards of the daily quests be?",kind:"score",levelTitles:[j("Small","\u041C\u0430\u043B\u0435\u043D\u044C\u043A\u0438\u0435"),j("Normal","\u041E\u0431\u044B\u0447\u043D\u044B\u0435"),j("Big","\u0411\u043E\u043B\u044C\u0448\u0438\u0435"),j("Very big","\u041E\u0447\u0435\u043D\u044C \u0431\u043E\u043B\u044C\u0448\u0438\u0435")],levels:["Small.","Normal.","Big.","Very big."],patches:[No("daily_visit",10,100),No("daily_earn",30,300),No("daily_play",80,600),No("kit_daily_coins",50,500),No("kit_daily_time",50,500),No("kit_daily_levels",5,40)]},{id:"liveops.leaderboard",group:"liveops",title:j("Weekly leaderboard","\u041D\u0435\u0434\u0435\u043B\u044C\u043D\u044B\u0439 \u0440\u0435\u0439\u0442\u0438\u043D\u0433"),for:{sections:["Leaderboard"]},question:"Is competing on a weekly leaderboard a good fit for this product?",kind:"noul",yes:"Yes: players like to compete and compare their scores.",no:"No: it is a calm, personal or creative product without competition.",onYes:[{section:"Leaderboard",op:"set",path:"Definitions.weekly_score.IsEnabled",value:true}],onNo:[{section:"Leaderboard",op:"set",path:"Definitions.weekly_score.IsEnabled",value:false}]}],Wr=(e,t,r,o)=>({id:e,title:j(t,r),what:o,patches:[{section:"Currency",op:"set",path:"VirtualCurrencies.CO.DisplayName",value:t},{section:"GameSpec",op:"set",path:"texts.'res.coins'",value:{en:t,ru:r}}],translations:{ru:{[t]:r}}}),wn=(e,t,r,o)=>({id:e,title:j(t,r),what:o,patches:[{section:"Currency",op:"set",path:"VirtualCurrencies.GE.DisplayName",value:t}],translations:{ru:{[t]:r}}}),Gu=[{id:"texts.coin-name",group:"texts",title:j("Name of the coins","\u041D\u0430\u0437\u0432\u0430\u043D\u0438\u0435 \u043C\u043E\u043D\u0435\u0442"),for:{sections:["Currency"]},question:"What should the game's soft currency (earned in rounds) be called?",kind:"choice",options:[Wr("coins","Coins","\u041C\u043E\u043D\u0435\u0442\u044B","Plain coins: fits anything."),Wr("gold","Gold","\u0417\u043E\u043B\u043E\u0442\u043E","Gold: fantasy, medieval, pirates, treasure."),Wr("credits","Credits","\u041A\u0440\u0435\u0434\u0438\u0442\u044B","Credits: sci-fi, space, future, robots."),Wr("cash","Cash","\u041D\u0430\u043B\u0438\u0447\u043D\u044B\u0435","Cash: business, city, modern life, tycoon."),Wr("scrap","Scrap","\u0425\u043B\u0430\u043C","Scrap: post-apocalypse, survival, junk."),Wr("candies","Candies","\u041A\u043E\u043D\u0444\u0435\u0442\u044B","Candies: sweets, kids, cozy cartoon."),Wr("stars","Stars","\u0417\u0432\u0451\u0437\u0434\u044B","Stars: kids, space, dreams, music."),Wr("bones","Bones","\u041A\u043E\u0441\u0442\u0438","Bones: pets, dogs, dinosaurs, halloween."),Wr("shells","Shells","\u0420\u0430\u043A\u0443\u0448\u043A\u0438","Shells: the sea, islands, mermaids."),Wr("leaves","Leaves","\u041B\u0438\u0441\u0442\u044C\u044F","Leaves: nature, forest, farm, elves.")]},{id:"texts.gem-name",group:"texts",title:j("Name of the gems","\u041D\u0430\u0437\u0432\u0430\u043D\u0438\u0435 \u043A\u0440\u0438\u0441\u0442\u0430\u043B\u043B\u043E\u0432"),for:{sections:["Currency"]},question:"What should the game's premium currency be called?",kind:"choice",options:[wn("gems","Gems","\u041A\u0440\u0438\u0441\u0442\u0430\u043B\u043B\u044B","Gems: fits anything."),wn("diamonds","Diamonds","\u0410\u043B\u043C\u0430\u0437\u044B","Diamonds: luxury, mining, treasure."),wn("rubies","Rubies","\u0420\u0443\u0431\u0438\u043D\u044B","Rubies: fantasy, royal, magic."),wn("crystals","Energy cells","\u042D\u043D\u0435\u0440\u0433\u043E\u044F\u0447\u0435\u0439\u043A\u0438","Energy cells: sci-fi, robots, space."),wn("pearls","Pearls","\u0416\u0435\u043C\u0447\u0443\u0433","Pearls: the sea, mermaids, elegance."),wn("orbs","Orbs","\u0421\u0444\u0435\u0440\u044B","Magic orbs: wizards, spells, mystery."),wn("tokens","Tokens","\u0416\u0435\u0442\u043E\u043D\u044B","Tokens: arcade, casino, retro."),wn("hearts","Hearts","\u0421\u0435\u0440\u0434\u0435\u0447\u043A\u0438","Hearts: cute, love, pets, kids.")]}],Ku=new Set(["Look","GameSpec"]),xi=e=>e?.map(t=>Ku.has(t.section)?t:{...t,ifExists:true}),Fu=e=>{switch(e.kind){case "choice":return e.options?{...e,options:e.options.map(t=>({...t,patches:xi(t.patches)}))}:e;case "score":return {...e,patches:xi(e.patches)};case "noul":return {...e,onYes:xi(e.onYes),...e.onNo?{onNo:xi(e.onNo)}:{}}}},np=[...zu,...Bu,...Hu,...ju,...Vu,...Gu].map(Fu),qu={version:tp,knobs:np,lists:Sc};var Rc=/^[a-z0-9][a-z0-9_.-]{0,63}$/,Uu=new Set(["set","merge","unset","add","remove"]),Xu=/[\u2013\u2014]/;function ki(e,t,r,o=false){(!e||e.length===0)&&r.push(`${t}: no patches`);for(let[n,s]of (e??[]).entries())(!s.section||!/^[A-Z][A-Za-z0-9]*$/.test(s.section))&&r.push(`${t}.patches[${n}]: section "${s.section}"`),Uu.has(s.op)||r.push(`${t}.patches[${n}]: op "${s.op}"`),mi(s.path)===null&&r.push(`${t}.patches[${n}]: path "${s.path}"`),o&&s.op==="set"&&!s.range&&s.value===void 0&&r.push(`${t}.patches[${n}]: a score patch needs a range`),s.range&&!(Number.isFinite(s.range.min)&&Number.isFinite(s.range.max))&&r.push(`${t}.patches[${n}]: range`);}function op(e,t,r){e.length===0&&r.push(`${t}: no options`),e.length>255&&r.push(`${t}: ${e.length} options, the decision model takes ${255}`);let o=new Set;for(let n of e)Rc.test(n.id)||r.push(`${t}: option id "${n.id}"`),o.has(n.id)&&r.push(`${t}: option "${n.id}" twice`),o.add(n.id),n.title?.en||r.push(`${t}.${n.id}: no English title`),n.what||r.push(`${t}.${n.id}: no description for the decision model`),ki(n.patches,`${t}.${n.id}`,r);}function Ac(e,t){if(typeof e=="string")t.push(e);else if(Array.isArray(e))for(let r of e)Ac(r,t);else if(e&&typeof e=="object")for(let r of Object.values(e))Ac(r,t);}function Zu(e){let t=[];for(let[n,s]of Object.entries(e.lists))Rc.test(n)||t.push(`list "${n}": id`),op(s,`list ${n}`,t);let r=new Set;for(let n of e.knobs){let s=`knob ${n.id}`;Rc.test(n.id)||t.push(`${s}: id`),r.has(n.id)&&t.push(`${s}: twice`),r.add(n.id),n.title?.en||t.push(`${s}: no English title`),n.question||t.push(`${s}: no question`),n.kind==="choice"?(n.list&&n.options&&t.push(`${s}: options OR a list, not both`),n.list&&!e.lists[n.list]&&t.push(`${s}: no list "${n.list}"`),n.list||op(n.options??[],s,t)):n.kind==="score"?((n.levels.length<2||n.levels.length>10)&&t.push(`${s}: ${n.levels.length} levels, 2..${10}`),n.levelTitles?.length!==n.levels.length?t.push(`${s}: levelTitles must name every level`):n.levelTitles.forEach((a,i)=>{(!a.en||!a.ru)&&t.push(`${s}: level ${i} needs en and ru titles`);}),ki(n.patches,s,t,true)):n.kind==="noul"?((!n.yes||!n.no)&&t.push(`${s}: yes and no`),ki(n.onYes,s,t),n.onNo&&ki(n.onNo,`${s}.no`,t)):t.push(`${s}: kind`);}let o=[];Ac(e,o);for(let n of o)Xu.test(n)&&t.push(`a long dash in "${n.slice(0,60)}"`);return t}
|
|
3
|
-
exports.ABILITIES=Tl;exports.ART=Ws;exports.ASSET_PACKS=Fn;exports.BACKGROUND_OPTIONS=Yf;exports.BLOCKS=dn;exports.BOSS_DEFEATED=Wl;exports.BOSS_SPAWNED=Oa;exports.BRANCH_LEVEL=Gl;exports.Body=
|
|
1
|
+
'use strict';function Vr(e){if(!ap.test(e))throw new Error(`registry: bad kind name "${e}"`);return Object.freeze({name:e})}var Oc=/^[a-z0-9][a-z0-9-]*(?:\.[a-z0-9][a-z0-9-]*)*$/,ap=/^[a-z][a-z0-9-]*$/;function Ls(e){let t=new Map,r=n=>{let s=t.get(n);return s||(s=new Map,t.set(n,s)),s},o={define(n,s,a){if(!s||typeof s!="object")throw new Error(`registry: ${n.name} entry must be an object`);if(typeof s.id!="string"||!Oc.test(s.id))throw new Error(`registry: ${n.name} has a bad id "${String(s.id)}"`);if(!Number.isInteger(s.version)||s.version<1)throw new Error(`registry: ${n.name} "${s.id}" needs an integer version \u2265 1`);let i=r(n.name);if((i.has(s.id)||(e?.has(n,s.id)??false))&&!a?.override)throw new Error(`registry: ${n.name} "${s.id}" is already defined (pass { override: true } to replace it)`);let m=Object.freeze({...s});return i.set(s.id,m),m},get(n,s){let a=t.get(n.name)?.get(s);return a||e?.get(n,s)},require(n,s){let a=o.get(n,s);if(!a)throw new Error(`registry: no ${n.name} "${s}"`);return a},has(n,s){return o.get(n,s)!==void 0},list(n){let s=new Map;for(let a of e?.list(n)??[])s.set(a.id,a);for(let[a,i]of t.get(n.name)??[])s.set(a,i);return [...s.values()].sort((a,i)=>a.id<i.id?-1:a.id>i.id?1:0)},extend(){return Ls(o)}};return o}function ip(e){let t=1779033703^e.length;for(let r=0;r<e.length;r++)t=Math.imul(t^e.charCodeAt(r),3432918353),t=t<<13|t>>>19;return ()=>(t=Math.imul(t^t>>>16,2246822507),t=Math.imul(t^t>>>13,3266489909),t^=t>>>16,t>>>0)}function lp(e,t,r,o){return ()=>{e>>>=0,t>>>=0,r>>>=0,o>>>=0;let n=e+t|0;return e=t^t>>>9,t=r+(r<<3)|0,r=r<<21|r>>>11,o=o+1|0,n=n+o|0,r=r+n|0,(n>>>0)/4294967296}}function _s(e){let t=String(e),r=ip(t),o=lp(r(),r(),r(),r());for(let s=0;s<12;s++)o();return {seed:t,next:o,int(s,a){if(!Number.isFinite(s)||!Number.isFinite(a))throw new RangeError("int: bounds must be finite");let i=Math.ceil(Math.min(s,a)),h=Math.floor(Math.max(s,a));return i+Math.floor(o()*(h-i+1))},range(s,a){return s+o()*(a-s)},chance(s){return o()<s},pick(s){if(s.length===0)throw new RangeError("pick: empty list");return s[Math.floor(o()*s.length)]},weighted(s,a){let i=0;for(let m of s)i+=Math.max(0,a(m));if(i<=0)throw new RangeError("weighted: no positive weight");let h=o()*i;for(let m of s){let v=Math.max(0,a(m));if(!(v<=0)){if(h<v)return m;h-=v;}}for(let m=s.length-1;m>=0;m--){let v=s[m];if(a(v)>0)return v}throw new RangeError("weighted: no positive weight")},shuffle(s){let a=s.slice();for(let i=a.length-1;i>0;i--){let h=Math.floor(o()*(i+1)),m=a[i];a[i]=a[h],a[h]=m;}return a},stream(s){return _s(`${t}/${s}`)}}}var cr=class extends Error{constructor(r,o,n){super(`${r} at ${n} in "${o}"`);this.source=o;this.at=n;this.name="ExprError";}source;at},Cc=2e3,vi=64,lt=e=>{let t=typeof e=="number"?e:typeof e=="boolean"?e?1:0:Number(e);return Number.isFinite(t)?t:0},En=e=>typeof e=="string"?e.length>0:!!e,$i={min:(...e)=>e.length?Math.min(...e):0,max:(...e)=>e.length?Math.max(...e):0,abs:(e=0)=>Math.abs(e),floor:(e=0)=>Math.floor(e),ceil:(e=0)=>Math.ceil(e),round:(e=0)=>Math.round(e),sqrt:(e=0)=>Math.sqrt(Math.max(0,e)),pow:(e=0,t=1)=>Math.pow(e,t),log:(e=1)=>e>0?Math.log(e):0,clamp:(e=0,t=0,r=1)=>Math.min(Math.max(e,t),r),lerp:(e=0,t=0,r=0)=>e+(t-e)*r,sign:(e=0)=>Math.sign(e),step:(e=0,t=0)=>t<e?0:1},cp=["&&","||","==","!=","<=",">=","+","-","*","/","%","^","<",">","!","?",":","(",")",","];function dp(e){let t=[],r=0;for(;r<e.length;){let o=e[r];if(o===" "||o===" "||o===`
|
|
2
|
+
`||o==="\r"){r++;continue}if(o>="0"&&o<="9"||o==="."&&/[0-9]/.test(e[r+1]??"")){let s=/^(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/.exec(e.slice(r));if(!s)throw new cr("bad number",e,r);t.push({t:"num",v:Number(s[0]),at:r}),r+=s[0].length;continue}if(o==="'"||o==='"'){let s=e.indexOf(o,r+1);if(s<0)throw new cr("unclosed string",e,r);t.push({t:"str",v:e.slice(r+1,s),at:r}),r=s+1;continue}if(/[A-Za-z_$]/.test(o)){let s=/^[A-Za-z_$][A-Za-z0-9_$]*(?:\.[A-Za-z_$][A-Za-z0-9_$]*)*/.exec(e.slice(r));if(!s)throw new cr("bad name",e,r);t.push({t:"id",v:s[0],at:r}),r+=s[0].length;continue}let n=cp.find(s=>e.startsWith(s,r));if(!n)throw new cr(`unexpected "${o}"`,e,r);t.push({t:"op",v:n,at:r}),r+=n.length;}return t.push({t:"end",at:e.length}),t}var Pc={"||":1,"&&":2,"==":3,"!=":3,"<":4,"<=":4,">":4,">=":4,"+":5,"-":5,"*":6,"/":6,"%":6,"^":8};function fp(e){let t=dp(e),r=0,o=()=>t[r],n=()=>t[r++],s=O=>{let N=o();return N.t==="op"&&N.v===O},a=O=>{let N=n();if(N.t!=="op"||N.v!==O)throw new cr(`expected "${O}"`,e,N.at)},i=O=>{if(O>vi)throw new cr("formula is nested too deep",e,o().at);let N=h(0,O+1);if(!s("?"))return N;n();let q=i(O+1);a(":");let ne=i(O+1);return {k:"cond",c:N,a:q,b:ne}},h=(O,N)=>{if(N>vi)throw new cr("formula is nested too deep",e,o().at);let q=m(N+1);for(;;){let ne=o();if(ne.t!=="op")break;let Z=Pc[ne.v];if(Z===void 0||Z<O)break;n();let ye=ne.v==="^"?h(Z,N+1):h(Z+1,N+1);q={k:"bin",op:ne.v,a:q,b:ye};}return q},m=O=>{if(O>vi)throw new cr("formula is nested too deep",e,o().at);return s("-")||s("!")?{k:"un",op:n().v,a:h(Pc["^"],O+1)}:v(O+1)},v=O=>{let N=n();if(N.t==="num")return {k:"num",v:N.v};if(N.t==="str")return {k:"str",v:N.v};if(N.t==="op"&&N.v==="("){let q=i(O+1);return a(")"),q}if(N.t==="id"){if(N.v==="true")return {k:"bool",v:true};if(N.v==="false")return {k:"bool",v:false};if(s("(")){if(!Object.prototype.hasOwnProperty.call($i,N.v))throw new cr(`unknown function "${N.v}"`,e,N.at);n();let q=[];if(!s(")"))for(;;){if(q.push(i(O+1)),s(",")){n();continue}break}return a(")"),{k:"call",fn:N.v,args:q}}return {k:"var",path:N.v.split(".")}}throw new cr(N.t==="end"?"unexpected end":"unexpected token",e,N.at)},x=i(0),D=o();if(D.t!=="end")throw new cr("unexpected token",e,D.at);return x}function pp(e,t){let r=e;for(let o of t){if(r===null||typeof r!="object"||!Object.prototype.hasOwnProperty.call(r,o))return 0;r=r[o];}return typeof r=="number"||typeof r=="string"||typeof r=="boolean"?r:0}function lr(e,t){switch(e.k){case "num":case "str":case "bool":return e.v;case "var":return pp(t,e.path);case "un":return e.op==="-"?-lt(lr(e.a,t)):!En(lr(e.a,t));case "cond":return En(lr(e.c,t))?lr(e.a,t):lr(e.b,t);case "call":return lt($i[e.fn](...e.args.map(r=>lt(lr(r,t)))));case "bin":{if(e.op==="&&")return En(lr(e.a,t))&&En(lr(e.b,t));if(e.op==="||")return En(lr(e.a,t))||En(lr(e.b,t));let r=lr(e.a,t),o=lr(e.b,t);switch(e.op){case "==":return typeof r=="string"||typeof o=="string"?String(r)===String(o):lt(r)===lt(o);case "!=":return typeof r=="string"||typeof o=="string"?String(r)!==String(o):lt(r)!==lt(o);case "<":return lt(r)<lt(o);case "<=":return lt(r)<=lt(o);case ">":return lt(r)>lt(o);case ">=":return lt(r)>=lt(o);case "+":return typeof r=="string"||typeof o=="string"?`${r}${o}`:lt(r)+lt(o);case "-":return lt(r)-lt(o);case "*":return lt(r)*lt(o);case "/":{let n=lt(o);return n===0?0:lt(r)/n}case "%":{let n=lt(o);return n===0?0:lt(r)%n}case "^":return lt(Math.pow(lt(r),lt(o)))}return 0}}}function cn(e,t){switch(e.k){case "var":t.add(e.path.join("."));return;case "un":cn(e.a,t);return;case "bin":cn(e.a,t),cn(e.b,t);return;case "cond":cn(e.c,t),cn(e.a,t),cn(e.b,t);return;case "call":for(let r of e.args)cn(r,t);return;default:return}}var Rs=new Map;function Er(e){let t=Rs.get(e);if(t)return t;if(e.length>Cc)throw new cr("formula is too long",e,Cc);let r=fp(e),o=new Set;cn(r,o);let n={source:e,reads:[...o],eval:s=>lr(r,s),num:s=>lt(lr(r,s)),bool:s=>En(lr(r,s))};return Rs.size>5e3&&Rs.clear(),Rs.set(e,n),n}function Mi(e){try{return Er(e),null}catch(t){return t instanceof Error?t.message:String(t)}}function wi(e,t,r=0){return e===void 0?r:typeof e=="number"?Number.isFinite(e)?e:r:Er(e).num(t)}var hp=/^[a-z][a-z0-9-]*(?:\.[a-z0-9-]+)*$/;function ve(e){if(!hp.test(e))throw new Error(`world: bad component name "${e}"`);return Object.freeze({name:e})}var zo=class{rng;vars;tick=0;time=0;nextId=1;alive=new Set;stores=new Map;doomed=new Set;systems=[];systemSeq=0;handlers=new Map;queue=[];maxEventRounds;stepping=false;constructor(t={}){this.rng=_s(t.seed??"world"),this.vars={...t.vars??{}},this.maxEventRounds=t.maxEventRounds??16;}create(){let t=this.nextId++;return this.alive.add(t),t}destroy(t){this.alive.has(t)&&(this.stepping?this.doomed.add(t):this.purge(t));}isAlive(t){return this.alive.has(t)&&!this.doomed.has(t)}get entityCount(){return this.alive.size-this.doomed.size}set(t,r,o){if(!this.alive.has(t))throw new Error(`world: entity ${t} does not exist`);let n=this.stores.get(r.name);return n||(n=new Map,this.stores.set(r.name,n)),n.set(t,o),t}get(t,r){return this.stores.get(r.name)?.get(t)}need(t,r){let o=this.get(t,r);if(o===void 0)throw new Error(`world: entity ${t} has no ${r.name}`);return o}has(t,r){return this.stores.get(r.name)?.has(t)??false}remove(t,r){this.stores.get(r.name)?.delete(t);}query(...t){if(t.length===0)return [...this.alive].filter(a=>!this.doomed.has(a)).sort((a,i)=>a-i);let r=t.map(a=>this.stores.get(a.name));if(r.some(a=>!a||a.size===0))return [];let o=r,n=o.reduce((a,i)=>i.size<a.size?i:a),s=[];for(let a of n.keys())this.doomed.has(a)||o.every(i=>i.has(a))&&s.push(a);return s.sort((a,i)=>a-i)}addSystem(t){if(this.systems.some(r=>r.system.id===t.id))throw new Error(`world: system "${t.id}" is already added`);this.systems.push({system:t,seq:this.systemSeq++}),this.systems.sort((r,o)=>(r.system.order??0)-(o.system.order??0)||r.seq-o.seq);}removeSystem(t){this.systems=this.systems.filter(r=>r.system.id!==t);}get systemIds(){return this.systems.map(t=>t.system.id)}on(t,r){let o=this.handlers.get(t)??[];return o.push(r),this.handlers.set(t,o),()=>{let n=this.handlers.get(t);if(!n)return;let s=n.indexOf(r);s>=0&&n.splice(s,1);}}emit(t,r={}){this.queue.push({topic:t,payload:r});}flushEvents(){for(let t=0;t<this.maxEventRounds&&this.queue.length>0;t++){let r=this.queue;this.queue=[];for(let{topic:o,payload:n}of r){let s=this.handlers.get(o);if(!s)continue;for(let i of s.slice())i(n,this);let a=this.handlers.get("*");if(a)for(let i of a.slice())i({...n,topic:o},this);}}this.queue.length>0&&(this.queue=[],this.overflowed++);}overflowed=0;step(t){if(!(t>=0)||!Number.isFinite(t))throw new RangeError("world: dt must be a finite number \u2265 0");this.stepping=true;try{this.tick++,this.time+=t;for(let{system:r}of this.systems.slice())r.run(this,t);this.flushEvents();}finally{this.stepping=false;for(let r of this.doomed)this.purge(r);this.doomed.clear();}}purge(t){this.alive.delete(t);for(let r of this.stores.values())r.delete(t);}};function up(e,t={}){let r=t.step??.016666666666666666,o=t.maxSteps??5,n=0;return {step:r,advance(s){if(!(s>0)||!Number.isFinite(s))return 0;n+=s;let a=0;for(;n>=r&&a<o;)e.step(r),n-=r,a++;return a===o&&(n=0),a},get alpha(){return n/r}}}var Bo=Vr("effect"),mp=/^[a-z][a-z0-9_]*$/,Ic=e=>{let t=e.name;if(typeof t!="string"||!mp.test(t))throw new Error(`effect ${e.type}: bad var name`);return t},Nc=[{id:"set-var",version:1,required:["name","value"],formulas:["value"],run(e,t){let r=t.value,o=typeof r=="string"?Er(r).eval(e.scope):typeof r=="number"||typeof r=="boolean"?r:0;e.world.vars[Ic(t)]=o;}},{id:"add-var",version:1,required:["name","amount"],formulas:["amount","min","max"],run(e,t){let r=Ic(t),o=e.world.vars[r],n=(typeof o=="number"?o:0)+e.num(t.amount);t.min!==void 0&&(n=Math.max(n,e.num(t.min))),t.max!==void 0&&(n=Math.min(n,e.num(t.max))),e.world.vars[r]=n;}},{id:"emit",version:1,required:["topic"],run(e,t){let r=t.topic;if(typeof r!="string"||r.length===0)throw new Error("effect emit: topic required");let o=t.payload,n={};if(o&&typeof o=="object")for(let[s,a]of Object.entries(o))n[s]=typeof a=="string"?Er(a).eval(e.scope):a;e.world.emit(r,n);}}];function Ho(e){for(let t of Nc)e.has(Bo,t.id)||e.define(Bo,t);}function As(e,t,r,o){let n=new Set;e.forEach((s,a)=>{let i=`${r}.${a}`;if(!s||typeof s!="object"){o.push({level:"error",path:i,code:"RULE_SHAPE",message:"a rule must be an object"});return}if(typeof s.id!="string"||s.id.length===0?o.push({level:"error",path:`${i}.id`,code:"RULE_ID",message:"a rule needs an id"}):n.has(s.id)?o.push({level:"error",path:`${i}.id`,code:"RULE_DUPLICATE",message:`rule "${s.id}" is defined twice`}):n.add(s.id),(typeof s.on!="string"||s.on.length===0)&&o.push({level:"error",path:`${i}.on`,code:"RULE_TRIGGER",message:"a rule needs an event topic in `on`"}),s.when!==void 0)try{Er(String(s.when));}catch(h){o.push({level:"error",path:`${i}.when`,code:"RULE_FORMULA",message:h.message});}if(!Array.isArray(s.do)||s.do.length===0){o.push({level:"error",path:`${i}.do`,code:"RULE_EFFECTS",message:"a rule needs at least one effect"});return}s.do.forEach((h,m)=>{let v=`${i}.do.${m}`,x=typeof h?.type=="string"?t.get(Bo,h.type):void 0;if(!x){o.push({level:"error",path:`${v}.type`,code:"EFFECT_UNKNOWN",message:`unknown effect "${String(h?.type)}"`});return}for(let D of x.required??[])h[D]===void 0&&o.push({level:"error",path:`${v}.${D}`,code:"EFFECT_PARAM",message:`effect "${x.id}" needs "${D}"`});for(let D of x.formulas??[]){let O=h[D];if(typeof O=="string")try{Er(O);}catch(N){o.push({level:"error",path:`${v}.${D}`,code:"RULE_FORMULA",message:N.message});}}});});}function Ei(e,t,r,o={}){let n=t.map(i=>({def:i,...i.when!==void 0?{when:Er(i.when)}:{},effects:i.do.map(h=>({spec:h,def:r.require(Bo,h.type)})),hits:0,runs:0,lastRunAt:Number.NEGATIVE_INFINITY})),s=new Map;for(let i of n){let h=s.get(i.def.on)??[];h.push(i),s.set(i.def.on,h);}let a=[...s.entries()].map(([i,h])=>e.on(i,m=>{for(let v of h){if(v.def.once&&v.runs>0)continue;let x={event:m,vars:e.vars,tick:e.tick,time:e.time};if(v.when&&!v.when.bool(x)||(v.hits++,v.def.every!==void 0&&v.def.every>1&&v.hits%v.def.every!==0)||v.def.cooldown!==void 0&&e.time-v.lastRunAt<v.def.cooldown)continue;v.runs++,v.lastRunAt=e.time;let D={world:e,rule:v.def,event:m,scope:x,num:(O,N=0)=>typeof O=="number"||typeof O=="string"?wi(O,x,N):N};for(let O of v.effects)try{O.def.run(D,O.spec);}catch(N){o.onError?.(v.def,N);}}}));return ()=>a.forEach(i=>i())}var Si=e=>e.some(t=>t.level==="error");function Ts(e,t,r,o){let n={};for(let[s,a]of Object.entries(e))n[s]=a.default;if(!t)return n;for(let[s,a]of Object.entries(t)){let i=e[s],h=`${r}.${s}`;if(!i){o.push({level:"warning",path:h,code:"PARAM_UNKNOWN",message:`unknown parameter "${s}"`});continue}switch(i.type){case "number":{if(typeof a!="number"||!Number.isFinite(a)){o.push({level:"warning",path:h,code:"PARAM_TYPE",message:"expected a number, default used"});break}let m=i.integer?Math.round(a):a;i.min!==void 0&&m<i.min&&(m=i.min),i.max!==void 0&&m>i.max&&(m=i.max),m!==a&&o.push({level:"warning",path:h,code:"PARAM_CLAMPED",message:`${a} \u2192 ${m}`}),n[s]=m;break}case "enum":typeof a=="string"&&i.values.includes(a)?n[s]=a:o.push({level:"warning",path:h,code:"PARAM_ENUM",message:`not one of ${i.values.join(", ")}, default used`});break;case "boolean":typeof a=="boolean"?n[s]=a:o.push({level:"warning",path:h,code:"PARAM_TYPE",message:"expected true/false, default used"});break;case "string":if(typeof a=="string"){let m=i.maxLength??500;n[s]=a.length>m?a.slice(0,m):a,a.length>m&&o.push({level:"warning",path:h,code:"PARAM_CLAMPED",message:`cut to ${m} characters`});}else o.push({level:"warning",path:h,code:"PARAM_TYPE",message:"expected text, default used"});break}}return n}var Ds=["phaser","three","dom"],dn=Vr("block"),fn=Vr("preset");var zc=["store","premium","character","inventory","lootboxes","boosts","leaderboard","rewards","quests","collections","craft","marketplace","deals","events","coop-events","season","pvp","mailbox","reward-window","idle"],yp=/^system:([a-z][a-z0-9-]*)$/,gp=new Set(["currency","item"]);function Li(e,t,r,o){let n=new Set(e.map(h=>h.id)),s=new Set(t.map(h=>h.id)),a=new Map,i=new Map;r.forEach((h,m)=>{let v=`flows.${m}`;s.has(h.resource)||o.push({level:"error",path:`${v}.resource`,code:"FLOW_RESOURCE_UNKNOWN",message:`no resource "${h.resource}"`});let x=yp.exec(h.by);x?zc.includes(x[1])||o.push({level:"warning",path:`${v}.by`,code:"FLOW_SYSTEM_UNKNOWN",message:`"${h.by}" is not a platform system`}):n.has(h.by)||o.push({level:"error",path:`${v}.by`,code:"FLOW_BY_UNKNOWN",message:`"${h.by}" is neither a mode of the spec nor "system:<id>"`}),h.kind!=="source"&&h.kind!=="sink"&&o.push({level:"error",path:`${v}.kind`,code:"FLOW_KIND",message:'kind is "source" or "sink"'});let D=h.kind==="source"?a:i;D.set(h.resource,(D.get(h.resource)??0)+1);}),t.forEach((h,m)=>{let v=`resources.${m}`,x=a.get(h.id)??0,D=i.get(h.id)??0;x===0&&o.push({level:"error",path:v,code:"RESOURCE_NO_SOURCE",message:`nothing produces "${h.id}"`}),gp.has(h.kind)&&D===0&&o.push({level:"error",path:v,code:"RESOURCE_NO_SINK",message:`nothing spends "${h.id}"`});});}var F=ve("transform"),le=ve("visual"),Ri=Object.freeze({background:"#1b2133",ground:"#273047",lane:"#313b56",primary:"#4fc3f7",secondary:"#ba68c8",danger:"#ef5350",coin:"#ffd54f",accent:"#66bb6a",text:"#ffffff",muted:"#9aa3b8",piece1:"#ef5350",piece2:"#42a5f5",piece3:"#66bb6a",piece4:"#ffd54f",piece5:"#ab47bc",piece6:"#ff8a3d",panel:"#2b3550"}),_i=/^#[0-9a-fA-F]{6}(?:[0-9a-fA-F]{2})?$/;function Ai(e,t){let r=_i.test(e)?e:t[e]??Ri[e]??t.text??"#ffffff";return _i.test(r)?r.slice(0,7):"#ffffff"}function Ti(e){let t={...Ri};for(let[r,o]of Object.entries(e??{}))typeof o=="string"&&_i.test(o)&&(t[r]=o);return t}var zt="input",Ft="view-resized",Os=Object.freeze({hero:{preset:"knight",races:["human"]},foe:{preset:"berserker",parts:{Hat:null,Offhand:null,Weapon:"weapon/battle_axe"},races:["orc"]},foe2:{preset:"crossbowman",parts:{Weapon:"weapon/broadsword"},races:["undead"]},boss:{preset:"dark_knight",races:["orc"]},helper:{preset:"camper",parts:{Weapon:null,Back:null,Glasses:null},races:["human","elf","dwarf"]},foe3:{preset:"crossbowman",races:["undead"]},foe4:{preset:"viking",parts:{Weapon:"weapon/warhammer"},races:["orc"]},foe5:{preset:"hunter",parts:{Hat:null,Back:null,Weapon:"weapon/dagger"},races:["undead"]},hero2:{preset:"crusader",races:["human"]},hero3:{preset:"archmage",races:["elf"]}}),Di=Object.freeze({style:"default",cast:Os}),Oi="fx";var Fn=Vr("asset-pack"),Wo=Vr("link"),bp=(e,t="en")=>e.names[t]??e.names.en??e.id;function xp(e,t,r){let o=[],n=r.get(Wo,t);if(!n)return o.push({level:"error",path:"link",code:"LINK_UNKNOWN",message:`no link "${t}"`}),{spec:e,systems:[],issues:o};let s=e.modes.find(i=>i.role==="core")??e.modes[0],a=s?r.get(fn,s.preset)?.genre:void 0;return !a||!n.core.includes(a)?(o.push({level:"error",path:"link",code:"LINK_GENRE",message:`link "${t}" fits ${n.core.join(", ")}, not "${a??"?"}"`}),{spec:e,systems:[],issues:o}):{spec:n.apply(e),systems:n.systems,issues:o}}var Vo=1;function Sr(e,t,r){let o=e?.content[t];if(!o||o.length===0)return r;let n=r.filter(s=>!o.includes(s));return n.length>0?n:r}var Hc=Object.freeze({window:"round",adMultiplier:3,vipMultiplier:5}),kp={};function Wc(e,t){let r={...e},o=r.v===void 0?1:r.v;if(typeof o!="number"||!Number.isInteger(o)||o<1)return t.push({level:"error",path:"v",code:"SPEC_VERSION",message:"v must be an integer \u2265 1"}),null;if(o>Vo)return t.push({level:"error",path:"v",code:"SPEC_TOO_NEW",message:`spec v${o} is newer than this kit (v${Vo})`}),null;for(;o<Vo;){let n=kp[o];if(!n)return t.push({level:"error",path:"v",code:"SPEC_NO_MIGRATION",message:`no migration from v${o}`}),null;r=n(r),o++;}return r.v=Vo,r}var Ci=/^[a-z][a-z0-9_]*$/,vp=/^#[0-9a-fA-F]{6}(?:[0-9a-fA-F]{2})?$/,$p=/^[a-z]{2}(?:-[A-Z]{2})?$/,Mp=/^[a-z][a-z0-9_.-]*$/,Bc=["none","async","coop","pvp"],xt=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),jo=e=>Array.isArray(e)?e:[];function wp(e,t){let r=[];if(!xt(e))return r.push({level:"error",path:"",code:"SPEC_SHAPE",message:"a spec must be an object"}),{ok:false,issues:r};let o=Wc(e,r);if(!o)return {ok:false,issues:r};let n=o;Ds.includes(n.engine)||r.push({level:"error",path:"engine",code:"SPEC_ENGINE",message:`engine is one of ${Ds.join(", ")}`});let s=jo(n.modes);s.length===0&&r.push({level:"error",path:"modes",code:"SPEC_NO_MODES",message:"a game needs at least one mode"});let a=new Set,i=[];s.forEach((Z,ye)=>{let be=`modes.${ye}`;if(!xt(Z)){r.push({level:"error",path:be,code:"MODE_SHAPE",message:"a mode must be an object"});return}typeof Z.id!="string"||!Ci.test(Z.id)?r.push({level:"error",path:`${be}.id`,code:"MODE_ID",message:"mode id: snake_case, starts with a letter"}):a.has(Z.id)?r.push({level:"error",path:`${be}.id`,code:"MODE_DUPLICATE",message:`mode "${Z.id}" is defined twice`}):a.add(Z.id);let fe=typeof Z.preset=="string"?t.get(fn,Z.preset):void 0;if(!fe){r.push({level:"error",path:`${be}.preset`,code:"MODE_PRESET_UNKNOWN",message:`no preset "${String(Z.preset)}"`});return}fe.engine!==n.engine&&r.push({level:"error",path:`${be}.preset`,code:"MODE_ENGINE",message:`preset "${fe.id}" runs on ${fe.engine}, the spec on ${String(n.engine)}`}),Z.role!==void 0&&!["core","meta","embedded"].includes(Z.role)&&r.push({level:"error",path:`${be}.role`,code:"MODE_ROLE",message:"role is core, meta or embedded"});let Ee=Ts(fe.params??{},xt(Z.params)?Z.params:void 0,`${be}.params`,r),de={},Ae=new Set(fe.blocks);for(let ce of fe.blocks){let ke=t.get(dn,ce);if(!ke){r.push({level:"error",path:`${be}.preset`,code:"PRESET_BLOCK_UNKNOWN",message:`preset "${fe.id}" uses unknown block "${ce}"`});continue}ke.engines&&!ke.engines.includes(fe.engine)&&r.push({level:"error",path:`${be}.preset`,code:"BLOCK_ENGINE",message:`block "${ce}" is not drawn by ${fe.engine}`});for(let oe of ke.requires??[])Ae.has(oe)||r.push({level:"error",path:`${be}.preset`,code:"BLOCK_REQUIRES",message:`block "${ce}" needs "${oe}" in the same preset`});let Le={};for(let[oe,Te]of Object.entries(fe.blockParams?.[ce]??{})){let Ke=ke.params?.[oe];if(typeof Te=="string"&&(Ke?.type==="number"||Ke?.type==="boolean"))try{let Ne=Er(Te).eval({params:Ee});Le[oe]=Ke.type==="number"?Number(Ne):!!Ne;}catch(Ne){r.push({level:"error",path:`${be}.preset`,code:"PRESET_FORMULA",message:`preset "${fe.id}", ${ce}.${oe}: ${Ne.message}`});}else Le[oe]=Te;}let _e={...Le,...xt(Z.blockParams)&&xt(Z.blockParams[ce])?Z.blockParams[ce]:{}};de[ce]=Ts(ke.params??{},_e,`${be}.blockParams.${ce}`,r);}if(xt(Z.blockParams))for(let ce of Object.keys(Z.blockParams))Ae.has(ce)||r.push({level:"warning",path:`${be}.blockParams.${ce}`,code:"BLOCK_NOT_IN_PRESET",message:`preset "${fe.id}" has no block "${ce}"`});let Pe=[...fe.rules??[],...jo(Z.rules)];As(Pe,t,`${be}.rules`,r);let we={};if(Z.content!==void 0)if(!xt(Z.content))r.push({level:"warning",path:`${be}.content`,code:"CONTENT_SHAPE",message:"content is { kind: { without: [ids] } }; ignored"});else for(let[ce,ke]of Object.entries(Z.content)){let Le=xt(ke)?ke.without:void 0;Array.isArray(Le)&&Le.every(_e=>typeof _e=="string")?we[ce]=[...Le]:r.push({level:"warning",path:`${be}.content.${ce}`,code:"CONTENT_SHAPE",message:"expected { without: [ids] }; ignored"});}i.push({id:Z.id,role:Z.role??(ye===0?"core":"meta"),preset:fe,params:Ee,blockParams:de,rules:Pe,content:we});}),s.length>0&&!s.some((Z,ye)=>xt(Z)?(Z.role??(ye===0?"core":"meta"))==="core":false)&&r.push({level:"error",path:"modes",code:"SPEC_NO_CORE",message:"one mode must be the core (what the player plays)"});let h=jo(n.resources),m=new Set;h.forEach((Z,ye)=>{let be=`resources.${ye}`;if(!xt(Z)||typeof Z.id!="string"||!Ci.test(Z.id)){r.push({level:"error",path:be,code:"RESOURCE_ID",message:"resource id: snake_case, starts with a letter"});return}m.has(Z.id)&&r.push({level:"error",path:`${be}.id`,code:"RESOURCE_DUPLICATE",message:`resource "${Z.id}" is defined twice`}),m.add(Z.id),["currency","item","score","local"].includes(Z.kind)||r.push({level:"error",path:`${be}.kind`,code:"RESOURCE_KIND",message:"kind is currency, item, score or local"}),(Z.kind==="currency"||Z.kind==="item")&&Z.ref!==void 0&&(typeof Z.ref!="string"||Z.ref.length===0)&&r.push({level:"error",path:`${be}.ref`,code:"RESOURCE_REF",message:"ref is the engine currency or item id"});});let v=jo(n.flows);v.forEach((Z,ye)=>{if(typeof Z?.amount=="string"){let be=Mi(Z.amount);be&&r.push({level:"error",path:`flows.${ye}.amount`,code:"FLOW_FORMULA",message:be});}}),Li(s.filter(xt),h.filter(Z=>xt(Z)&&typeof Z.id=="string"),v.filter(xt),r);let x=jo(n.rules);As(x,t,"rules",r);let D={};if(n.vars!==void 0)if(!xt(n.vars))r.push({level:"error",path:"vars",code:"VARS_SHAPE",message:"vars must be an object"});else for(let[Z,ye]of Object.entries(n.vars))Ci.test(Z)?typeof ye=="number"||typeof ye=="string"||typeof ye=="boolean"?D[Z]=ye:r.push({level:"error",path:`vars.${Z}`,code:"VAR_TYPE",message:"a var is a number, text or true/false"}):r.push({level:"error",path:`vars.${Z}`,code:"VAR_NAME",message:"var name: snake_case"});let O=typeof n.assets=="string"&&n.assets?t.get(Fn,n.assets):void 0;if(n.assets!==void 0&&!O&&r.push({level:"warning",path:"assets",code:"ASSETS_UNKNOWN",message:`no asset pack "${String(n.assets)}"; the default look is used`}),n.palette!==void 0)if(!xt(n.palette))r.push({level:"error",path:"palette",code:"PALETTE_SHAPE",message:"palette must be an object"});else for(let[Z,ye]of Object.entries(n.palette))(typeof ye!="string"||!vp.test(ye))&&r.push({level:"warning",path:`palette.${Z}`,code:"PALETTE_COLOR",message:"a colour is #rrggbb or #rrggbbaa; ignored"});if(n.texts!==void 0)if(!xt(n.texts))r.push({level:"error",path:"texts",code:"TEXTS_SHAPE",message:"texts must be an object"});else for(let[Z,ye]of Object.entries(n.texts)){if(Mp.test(Z)||r.push({level:"error",path:`texts.${Z}`,code:"TEXT_KEY",message:"text key: lower case, digits, _ . -"}),!xt(ye)){r.push({level:"error",path:`texts.${Z}`,code:"TEXT_SHAPE",message:"a text is { lang: text }"});continue}for(let[be,fe]of Object.entries(ye))(!$p.test(be)||typeof fe!="string")&&r.push({level:"error",path:`texts.${Z}.${be}`,code:"TEXT_LANG",message:"language code like en or pt-BR, value text"});ye.en===void 0&&r.push({level:"warning",path:`texts.${Z}`,code:"TEXT_NO_EN",message:"no English text: other languages fall back to it"});}let N={...Hc};if(n.rewards!==void 0)if(!xt(n.rewards))r.push({level:"error",path:"rewards",code:"REWARDS_SHAPE",message:"rewards must be an object"});else {let Z=(be,fe,Ee)=>{let de=n.rewards[be];if(de===void 0)return;if(typeof de!="number"||!Number.isFinite(de)){r.push({level:"warning",path:`rewards.${be}`,code:"PARAM_TYPE",message:"expected a number, default used"});return}let Ae=Math.min(Math.max(de,fe),Ee);Ae!==de&&r.push({level:"warning",path:`rewards.${be}`,code:"PARAM_CLAMPED",message:`${de} \u2192 ${Ae}`}),N[be]=Ae;};Z("adMultiplier",1,10),Z("vipMultiplier",1,20);let ye=n.rewards.window;ye!==void 0&&(typeof ye=="string"&&/^[A-Za-z0-9_-]{1,64}$/.test(ye)?N.window=ye:r.push({level:"warning",path:"rewards.window",code:"PARAM_TYPE",message:"expected a window id, default used"}));}let q=n.multiplayer??"none";Bc.includes(q)||r.push({level:"error",path:"multiplayer",code:"SPEC_MULTIPLAYER",message:`multiplayer is one of ${Bc.join(", ")}`});let ne=!Si(r);return {ok:ne,issues:r,spec:n,...ne?{resolved:{spec:n,engine:n.engine,seed:typeof n.seed=="string"&&n.seed.length>0?n.seed:"game",modes:i,resources:h,flows:v,rules:x,vars:D,rewards:N,multiplayer:q,palette:Ti({...O?.palette,...xt(n.palette)?n.palette:{}}),texts:Sp(O?.texts,xt(n.texts)?n.texts:void 0),look:{style:O?O.style??O.id:Di.style,cast:Ep({...Os,...O?.cast},n.cast)}}}:{}}}function Ep(e,t){let r={...e};if(!xt(t))return r;for(let[o,n]of Object.entries(t)){if(!xt(n))continue;let s={...r[o]};typeof n.preset=="string"&&(s.preset=n.preset),Array.isArray(n.races)&&n.races.every(a=>typeof a=="string")&&n.races.length>0&&(s.races=n.races),xt(n.parts)&&(s.parts={...s.parts,...n.parts}),xt(n.colors)&&(s.colors={...s.colors,...n.colors}),r[o]=s;}return r}function Sp(e,t){let r={};for(let o of [e,t])for(let[n,s]of Object.entries(o??{}))if(s&&typeof s=="object")for(let[a,i]of Object.entries(s))typeof i=="string"&&((r[n]??={})[a]=i);return r}function Lp(){let e=Ls();return Ho(e),e}function _p(e,t,r,o={}){let n=e.modes.find(i=>i.id===t);if(!n)throw new Error(`game: no mode "${t}"`);let s=new zo({seed:`${e.seed}/${n.id}${o.salt!==void 0?`/${o.salt}`:""}`,vars:e.vars});for(let i of n.preset.blocks)r.require(dn,i).setup?.({world:s,spec:e,mode:n,params:n.blockParams[i]??{},registry:r});let a=Ei(s,[...n.rules,...e.rules],r,{...o.onRuleError?{onError:o.onRuleError}:{}});return s.emit("mode-started",{mode:n.id}),s.flushEvents(),{world:s,mode:n,stop:a}}var Rp=(e,t=0,r=255)=>Math.min(r,Math.max(t,e)),Pi=e=>{let t=/^#[0-9a-fA-F]{6}/.test(e)?e.slice(1,7):"ffffff";return [Number.parseInt(t.slice(0,2),16),Number.parseInt(t.slice(2,4),16),Number.parseInt(t.slice(4,6),16)]},Ap=(e,t,r)=>`#${[e,t,r].map(o=>Math.round(Rp(o)).toString(16).padStart(2,"0")).join("")}`;function qn(e,t,r){let o=Pi(e),n=Pi(t);return Ap(o[0]+(n[0]-o[0])*r,o[1]+(n[1]-o[1])*r,o[2]+(n[2]-o[2])*r)}var V=(e,t)=>qn(e,"#000000",t),Q=(e,t)=>qn(e,"#ffffff",t),Cs=e=>{let[t,r,o]=Pi(e);return (t*.299+r*.587+o*.114)/255},he=(e,t,r=false)=>`<linearGradient id="${e}" x1="0" y1="0" x2="${r?1:0}" y2="${r?0:1}">${t.map(([o,n,s])=>`<stop offset="${o}" stop-color="${n}"${s===void 0?"":` stop-opacity="${s}"`}/>`).join("")}</linearGradient>`,Fe=(e,t,r=.5,o=.5,n=.5)=>`<radialGradient id="${e}" cx="${r}" cy="${o}" r="${n}">${t.map(([s,a,i])=>`<stop offset="${s}" stop-color="${a}"${i===void 0?"":` stop-opacity="${i}"`}/>`).join("")}</radialGradient>`,ie=(...e)=>`<defs>${e.join("")}</defs>`,Sn=e=>(Math.round(e*10)/10).toString(),Je=(e,t,r,o,n=5,s=-Math.PI/2)=>{let a=[];for(let i=0;i<n*2;i++){let h=i%2===0?r:o,m=s+i*Math.PI/n;a.push(`${Sn(e+Math.cos(m)*h)},${Sn(t+Math.sin(m)*h)}`);}return a.join(" ")},Dt=(e,t,r,o,n=-Math.PI/2)=>{let s=[];for(let a=0;a<o;a++){let i=n+a*2*Math.PI/o;s.push(`${Sn(e+Math.cos(i)*r)},${Sn(t+Math.sin(i)*r)}`);}return s.join(" ")},Go=(e,t,r,o,n)=>{let s=[],a=o*4;for(let i=0;i<a;i++){let h=i/a*Math.PI*2,m=i%4<2?r:r-n;s.push(`${Sn(e+Math.cos(h)*m)},${Sn(t+Math.sin(h)*m)}`);}return `M${s.join("L")}Z`};function Mr(e){let t=e>>>0||1;return ()=>(t=t*1664525+1013904223>>>0,t/4294967296)}var jc=e=>e==="cozy"?"#5b3b33":e==="sci-fi"?"#05070f":e==="post-apocalypse"?"#1a120c":"#1c1622",U=Sn;var Ot=(e,t,r,o,n=.28)=>`<ellipse cx="${e}" cy="${t}" rx="${r}" ry="${o}" fill="#000" opacity="${n}"/>`,Gr=(e,t=4,r=.55)=>`<path d="${e}" fill="none" stroke="#fff" stroke-width="${t}" stroke-linecap="round" opacity="${r}"/>`,Tp={w:64,h:64,main:"coin",draw({main:e,ink:t,style:r}){let o=V(e,.25),n;return r==="sci-fi"?n=`<polygon points="${Dt(32,31,11,6)}" fill="none" stroke="${V(e,.45)}" stroke-width="3.5"/><circle cx="32" cy="31" r="3.5" fill="${V(e,.45)}"/>`:r==="cozy"?n=`<path d="M32 41 C22 34 19 29 22 25 C25 21 30 22 32 26 C34 22 39 21 42 25 C45 29 42 34 32 41Z" fill="${V(e,.35)}"/>`:r==="post-apocalypse"?n=`<path d="${Go(32,31,13,10,3)}" fill="${V(e,.4)}"/><circle cx="32" cy="31" r="5" fill="${e}"/>`:n=`<polygon points="${Je(32,31,12,5.5)}" fill="${V(e,.35)}"/>`,ie(he("g",[[0,Q(e,.45)],[.55,e],[1,V(e,.2)]]))+`<circle cx="32" cy="35" r="26" fill="${V(e,.5)}" stroke="${t}" stroke-width="3"/><circle cx="32" cy="31" r="26" fill="url(#g)" stroke="${t}" stroke-width="3"/><circle cx="32" cy="31" r="19" fill="none" stroke="${o}" stroke-width="2.5"/>`+n+Gr("M15 24 A19 19 0 0 1 28 12")}},Dp={w:64,h:64,main:"accent",draw({main:e,ink:t}){return Ot(32,59,14,3.5)+`<polygon points="32,4 52,22 44,57 20,57 12,22" fill="${e}" stroke="${t}" stroke-width="3" stroke-linejoin="round"/><polygon points="32,4 12,22 26,24" fill="${Q(e,.5)}"/><polygon points="32,4 26,24 38,24" fill="${Q(e,.3)}"/><polygon points="32,4 38,24 52,22" fill="${V(e,.1)}"/><polygon points="12,22 26,24 20,57" fill="${Q(e,.15)}"/><polygon points="52,22 38,24 44,57" fill="${V(e,.3)}"/><polygon points="26,24 38,24 44,57 20,57" fill="${e}"/>`+Gr("M22 18 L28 10",3,.8)}},Op={w:64,h:64,main:"danger",draw({main:e,ink:t}){return ie(he("g",[[0,Q(e,.3)],[1,V(e,.25)]]))+`<path d="M32 56 C12 42 5 32 8 21 C11 10 25 8 32 19 C39 8 53 10 56 21 C59 32 52 42 32 56Z" fill="url(#g)" stroke="${t}" stroke-width="3.5" stroke-linejoin="round"/>`+Gr("M16 22 C17 16 22 14 26 17",4,.7)}},Cp={w:100,h:100,draw({style:e,ink:t,c:r}){if(e==="sci-fi"){let n=r("primary");return ie(he("m",[[0,"#5d6f96"],[1,"#2a3452"]]),Fe("o",[[0,Q(n,.6)],[.5,n,.9],[1,n,0]]))+Ot(50,95,40,5)+`<rect x="12" y="18" width="76" height="74" rx="10" fill="url(#m)" stroke="${t}" stroke-width="4"/><rect x="20" y="26" width="60" height="10" rx="3" fill="#1a2238"/><rect x="22" y="28" width="56" height="6" rx="2" fill="${n}" opacity="0.85"/><circle cx="50" cy="62" r="20" fill="url(#o)"/><circle cx="50" cy="62" r="11" fill="${Q(n,.3)}" stroke="${t}" stroke-width="3"/><circle cx="22" cy="84" r="3" fill="#9fb2d8"/><circle cx="78" cy="84" r="3" fill="#9fb2d8"/>`}if(e==="cozy"){let n="#f2c862";return ie(he("h",[[0,Q(n,.25)],[1,V(n,.2)]]))+Ot(50,94,42,5)+`<rect x="8" y="26" width="84" height="66" rx="22" fill="url(#h)" stroke="${t}" stroke-width="4"/>`+[36,50,64,78].map(s=>`<path d="M18 ${s} Q50 ${s-5} 82 ${s}" stroke="${V(n,.25)}" stroke-width="2.5" fill="none"/>`).join("")+`<rect x="30" y="24" width="7" height="70" fill="#c0563d" stroke="${t}" stroke-width="2"/><rect x="63" y="24" width="7" height="70" fill="#c0563d" stroke="${t}" stroke-width="2"/>`+Gr("M20 38 Q30 32 44 33",4,.5)}if(e==="post-apocalypse"){let n="#9a4a26";return ie(he("r",[[0,"#6a2e18"],[.35,Q(n,.15)],[.7,n],[1,"#4a2010"]],true))+Ot(50,95,34,5)+`<rect x="18" y="10" width="64" height="84" rx="8" fill="url(#r)" stroke="${t}" stroke-width="4"/><rect x="16" y="28" width="68" height="6" fill="#5a2814" stroke="${t}" stroke-width="2"/><rect x="16" y="68" width="68" height="6" fill="#5a2814" stroke="${t}" stroke-width="2"/><polygon points="50,40 62,60 38,60" fill="#e8c23a" stroke="${t}" stroke-width="2.5" stroke-linejoin="round"/><rect x="48.5" y="45" width="3" height="8" fill="${t}"/><circle cx="50" cy="56.5" r="1.8" fill="${t}"/><path d="M24 82 q6 -6 10 2 q4 6 9 0" stroke="#3a1608" stroke-width="3" fill="none" opacity="0.6"/>`}if(e==="fantasy"){let n="#9a6234";return ie(he("w",[[0,"#5a3418"],[.3,Q(n,.15)],[.7,n],[1,"#4a2a12"]],true))+Ot(50,95,36,5)+`<path d="M24 10 Q14 52 24 94 L76 94 Q86 52 76 10Z" fill="url(#w)" stroke="${t}" stroke-width="4" stroke-linejoin="round"/>`+[38,50,62].map(s=>`<path d="M${s} 12 Q${s+(s-50)*.25} 52 ${s} 92" stroke="${V(n,.35)}" stroke-width="2" fill="none"/>`).join("")+[24,76].map(s=>`<path d="M19 ${s} Q50 ${s+4} 81 ${s}" stroke="#4d525c" stroke-width="7" fill="none"/><path d="M19 ${s-2} Q50 ${s+2} 81 ${s-2}" stroke="#8d939e" stroke-width="2" fill="none"/>`).join("")+Gr("M28 30 Q26 50 28 66",4,.35)}let o="#b07a44";return Ot(50,95,42,5)+`<rect x="10" y="14" width="80" height="80" rx="6" fill="${o}" stroke="${t}" stroke-width="4"/><rect x="18" y="22" width="64" height="64" fill="${V(o,.12)}" stroke="${V(o,.4)}" stroke-width="3"/><path d="M20 24 L80 84 M80 24 L20 84" stroke="${Q(o,.15)}" stroke-width="9"/><path d="M20 24 L80 84 M80 24 L20 84" stroke="${V(o,.4)}" stroke-width="2" fill="none" opacity="0.5"/>`+[18,82].flatMap(n=>[22,86].map(s=>`<circle cx="${n}" cy="${s}" r="3" fill="#6b6f78"/>`)).join("")}},Pp={w:100,h:60,draw({style:e,ink:t,c:r}){let o=[18,50,82];if(e==="sci-fi"){let s=r("danger");return ie(he("l",[[0,Q(s,.6),.95],[1,s,.2]]))+o.map(a=>`<polygon points="${a-9},52 ${a},6 ${a+9},52" fill="url(#l)"/>`).join("")+o.map(a=>`<line x1="${a}" y1="10" x2="${a}" y2="50" stroke="#fff" stroke-width="2" opacity="0.8"/>`).join("")+`<rect x="2" y="48" width="96" height="11" rx="3" fill="#2a3452" stroke="${t}" stroke-width="3"/>`+o.map(a=>`<circle cx="${a}" cy="53" r="3" fill="${s}"/>`).join("")}if(e==="cozy")return `<path d="M6 58 C2 40 14 26 26 30 C30 14 48 10 54 24 C64 12 86 18 84 34 C98 36 100 52 94 58Z" fill="#6cbf5c" stroke="${t}" stroke-width="3.5" stroke-linejoin="round"/>`+[[18,36],[36,24],[56,22],[74,30],[88,44],[28,48],[62,44]].map(([a,i])=>`<polygon points="${a-3},${i+2} ${a},${i-7} ${a+3},${i+2}" fill="#fff4e6" stroke="${t}" stroke-width="1.5"/>`).join("")+'<circle cx="44" cy="40" r="4" fill="#ff8fab"/><circle cx="72" cy="46" r="3.5" fill="#ff8fab"/>';let n=e==="post-apocalypse"?"#8a6a52":"#b9c1cd";return ie(he("s",[[0,Q(n,.4)],[.5,n],[1,V(n,.45)]],true))+o.map(s=>`<polygon points="${s-14},50 ${s},4 ${s+14},50" fill="url(#s)" stroke="${t}" stroke-width="3" stroke-linejoin="round"/>`).join("")+(e==="post-apocalypse"?'<path d="M2 40 q8 -10 16 0 q8 10 16 0 q8 -10 16 0 q8 10 16 0 q8 -10 16 0 q8 10 16 0" stroke="#5a4a3a" stroke-width="3" fill="none"/>':"")+`<rect x="2" y="47" width="96" height="12" rx="3" fill="${e==="post-apocalypse"?"#4a3a2a":"#5a4636"}" stroke="${t}" stroke-width="3"/>`}},Ip={w:60,h:180,main:"accent",draw({style:e,ink:t,main:r,c:o}){if(e==="sci-fi"){let a=o("primary");return ie(Fe("b",[[0,"#fff"],[.4,a],[1,a,0]]))+`<rect x="24" y="30" width="10" height="146" rx="3" fill="#4a5a80" stroke="${t}" stroke-width="3"/><circle cx="29" cy="24" r="22" fill="url(#b)"/><circle cx="29" cy="24" r="8" fill="#fff" stroke="${t}" stroke-width="2"/><rect x="34" y="50" width="24" height="34" rx="3" fill="${r}" opacity="0.75" stroke="${Q(r,.5)}" stroke-width="2"/><rect x="14" y="166" width="30" height="12" rx="3" fill="#2a3452" stroke="${t}" stroke-width="3"/>`}let n=e==="post-apocalypse"?"#7a6a5a":e==="cozy"?"#e8d8c8":"#c8a060",s=e==="post-apocalypse"?`<path d="M30 22 L58 28 L52 40 L58 52 L40 50 L44 60 L30 58Z" fill="${r}" stroke="${t}" stroke-width="3" stroke-linejoin="round"/>`:e==="cozy"?`<path d="M30 22 Q46 16 58 26 Q50 40 58 54 Q44 46 30 56Z" fill="${r}" stroke="${t}" stroke-width="3" stroke-linejoin="round"/><path d="M44 44 C38 40 37 37 39 35 C41 33 43 34 44 36 C45 34 47 33 49 35 C51 37 50 40 44 44Z" fill="#fff"/>`:`<path d="M30 22 L58 22 L58 62 L44 54 L30 62Z" fill="${r}" stroke="${t}" stroke-width="3" stroke-linejoin="round"/><polygon points="${Je(44,38,8,3.5)}" fill="${o("coin")}"/>`;return Ot(30,176,18,3.5)+`<rect x="25" y="14" width="8" height="162" rx="3" fill="${n}" stroke="${t}" stroke-width="3"/>`+s+`<circle cx="29" cy="12" r="7" fill="${o("coin")}" stroke="${t}" stroke-width="3"/>`}},Vc={w:64,h:32,main:"primary",draw({style:e,main:t,c:r}){return e==="sci-fi"?ie(he("t",[[0,t,0],[1,t,.9]],true))+`<rect x="2" y="11" width="44" height="10" rx="5" fill="url(#t)"/><rect x="22" y="9" width="40" height="14" rx="7" fill="${t}"/><rect x="28" y="13" width="30" height="6" rx="3" fill="#fff"/>`:e==="post-apocalypse"?ie(he("t",[[0,r("coin"),0],[1,r("coin"),.8]],true))+'<rect x="0" y="13" width="44" height="6" rx="3" fill="url(#t)"/><path d="M40 10 L54 10 Q62 16 54 22 L40 22Z" fill="#c9a24a" stroke="#3a2a12" stroke-width="2"/>':e==="cozy"?ie(he("t",[[0,t,0],[1,t,.7]],true))+`<rect x="0" y="12" width="40" height="8" rx="4" fill="url(#t)"/><polygon points="${Je(46,16,14,6)}" fill="${r("coin")}" stroke="#5b3b33" stroke-width="2" stroke-linejoin="round"/>`:ie(he("t",[[0,t,0],[1,t,.85]],true),Fe("o",[[0,"#fff"],[.45,Q(t,.4)],[1,t,0]]))+'<path d="M2 16 Q20 8 40 10 L40 22 Q20 24 2 16Z" fill="url(#t)"/><circle cx="46" cy="16" r="15" fill="url(#o)"/><circle cx="46" cy="16" r="6" fill="#fff"/>'}},Np=e=>({w:100,h:100,main:`piece${e}`,draw({main:t,ink:r}){let o=Q(t,.55),n=Q(t,.2),s=V(t,.32),a=ie(he("g",[[0,Q(t,.35)],[1,V(t,.25)]])),i=`stroke="${r}" stroke-width="4" stroke-linejoin="round"`,h;switch(e){case 1:h=`<circle cx="50" cy="52" r="40" fill="url(#g)" ${i}/><polygon points="${Dt(50,52,22,8,-Math.PI/8)}" fill="${n}"/><polygon points="${Dt(50,52,22,8,-Math.PI/8).split(" ").slice(5,8).join(" ")} 50,52" fill="${o}"/><polygon points="${Dt(50,52,22,8,-Math.PI/8).split(" ").slice(1,4).join(" ")} 50,52" fill="${s}"/>`;break;case 2:h=`<path d="M50 8 C66 30 84 46 84 64 C84 82 68 92 50 92 C32 92 16 82 16 64 C16 46 34 30 50 8Z" fill="url(#g)" ${i}/><path d="M50 24 C60 40 70 50 70 64 C70 76 60 82 50 82Z" fill="${s}" opacity="0.6"/><path d="M50 24 C40 40 30 50 30 64 C30 76 40 82 50 82Z" fill="${n}" opacity="0.7"/>`;break;case 3:h=`<polygon points="28,10 72,10 90,28 90,72 72,90 28,90 10,72 10,28" fill="url(#g)" ${i}/><polygon points="32,24 68,24 76,32 76,68 68,76 32,76 24,68 24,32" fill="${n}"/><polygon points="28,10 72,10 68,24 32,24" fill="${o}"/><polygon points="90,28 90,72 76,68 76,32" fill="${s}"/><polygon points="36,34 64,34 64,66 36,66" fill="${t}"/>`;break;case 4:h=`<polygon points="${Je(50,54,44,20)}" fill="url(#g)" ${i}/><polygon points="${Je(50,54,22,10)}" fill="${n}"/><polygon points="50,10 50,54 30,44" fill="${o}" opacity="0.7"/>`;break;case 5:h=`<polygon points="50,6 90,50 50,94 10,50" fill="url(#g)" ${i}/><polygon points="50,6 10,50 50,50" fill="${o}"/><polygon points="50,6 90,50 50,50" fill="${n}"/><polygon points="10,50 50,94 50,50" fill="${t}"/><polygon points="90,50 50,94 50,50" fill="${s}"/><polygon points="50,30 64,50 50,70 36,50" fill="${Q(t,.35)}"/>`;break;default:h=`<polygon points="${Dt(50,50,42,6)}" fill="url(#g)" ${i}/><polygon points="${Dt(50,50,24,6)}" fill="${n}"/><polygon points="${Dt(50,50,42,6).split(" ").slice(4,6).join(" ")} ${Dt(50,50,42,6).split(" ")[0]} 50,50" fill="${o}" opacity="0.6"/><polygon points="${Dt(50,50,42,6).split(" ").slice(1,4).join(" ")} 50,50" fill="${s}" opacity="0.55"/>`;}return a+Ot(50,94,30,4,.22)+h+Gr("M28 30 Q32 22 40 20",5,.75)}}),Ps=e=>`<path d="M24 86 Q50 72 76 86 Q76 94 50 94 Q24 94 24 86Z" fill="#7a5032" stroke="${e}" stroke-width="3"/>`,Un=(e,t,r,o,n,s)=>`<path transform="translate(${e} ${t}) rotate(${r}) scale(${o})" d="M0 0 C6 -10 18 -10 22 0 C18 8 6 8 0 0Z" fill="${n}" stroke="${s}" stroke-width="${U(2.4/o)}"/>`,Ko=(e,t,r,o,n)=>`<circle cx="${e-r*.55}" cy="${t+r*.2}" r="${r*.7}" fill="${V(o,.1)}" stroke="${n}" stroke-width="3"/><circle cx="${e+r*.55}" cy="${t+r*.2}" r="${r*.7}" fill="${V(o,.1)}" stroke="${n}" stroke-width="3"/><circle cx="${e}" cy="${t-r*.15}" r="${r*.85}" fill="${o}" stroke="${n}" stroke-width="3"/><circle cx="${e-r*.3}" cy="${t-r*.4}" r="${r*.3}" fill="${Q(o,.3)}"/>`,Ii=(e,t=50)=>`<path d="M45 92 L47 ${t} L53 ${t} L55 92Z" fill="#8a5a32" stroke="${e}" stroke-width="3" stroke-linejoin="round"/>`;function zp(e,t){let{ink:r}=t,o=t.style==="cozy"?"#7fd36e":"#58b04a",n=t.c("primary");switch(e){case 1:return Ot(50,84,18,4)+`<ellipse cx="50" cy="64" rx="15" ry="20" fill="#b07a44" stroke="${r}" stroke-width="3.5"/>`+Gr("M44 54 Q46 48 50 47",3.5,.6);case 2:return Ps(r)+`<path d="M50 84 Q48 66 50 56" stroke="${V(o,.2)}" stroke-width="5" fill="none" stroke-linecap="round"/>`+Un(50,60,-150,1,o,r)+Un(50,60,-30,1,o,r);case 3:return Ps(r)+`<path d="M50 84 Q47 60 50 38" stroke="${V(o,.2)}" stroke-width="5" fill="none" stroke-linecap="round"/>`+Un(50,66,-160,1.1,o,r)+Un(50,62,-20,1.1,o,r)+Un(50,44,-130,.9,Q(o,.15),r)+Un(50,42,-50,.9,Q(o,.15),r);case 4:return Ps(r)+Ko(50,62,26,o,r);case 5:return Ps(r)+Ko(50,62,28,o,r)+[[34,56],[56,44],[66,64],[46,70]].map(([s,a])=>`<polygon points="${Je(s,a,7,3.5,5)}" fill="${n}" stroke="${r}" stroke-width="1.5"/><circle cx="${s}" cy="${a}" r="2" fill="#fff6c0"/>`).join("");case 6:return Ot(50,93,26,4)+Ii(r,52)+Ko(50,40,32,o,r);case 7:return Ot(50,93,28,4)+Ii(r,54)+Ko(50,40,34,V(o,.05),r)+[[34,36],[58,26],[66,46],[44,52],[52,38]].map(([s,a])=>`<circle cx="${s}" cy="${a}" r="5.5" fill="${t.c("danger")}" stroke="${r}" stroke-width="2"/><circle cx="${s-1.5}" cy="${a-1.5}" r="1.6" fill="#fff" opacity="0.8"/>`).join("");default:{let s=t.c("coin");return Ot(50,93,30,4)+Ii(r,54)+Ko(50,38,36,s,r)+[[22,18],[80,22],[74,64],[24,60],[50,6]].map(([a,i])=>`<polygon points="${Je(a,i,6,2,4)}" fill="#fff"/>`).join("")}}}function Bp(e,t){let{ink:r}=t,o=t.style==="post-apocalypse"?"#9a8a72":"#a9b8d6",n=t.style==="post-apocalypse"?t.c("coin"):t.c("primary"),s=ie(he("m",[[0,Q(o,.35)],[1,V(o,.35)]]));switch(e){case 1:return s+Ot(50,88,16,4)+`<rect x="44" y="34" width="12" height="50" rx="2" fill="url(#m)" stroke="${r}" stroke-width="3"/>`+[44,54,64,74].map(a=>`<line x1="44" y1="${a}" x2="56" y2="${a-4}" stroke="${V(o,.45)}" stroke-width="2"/>`).join("")+`<rect x="32" y="22" width="36" height="14" rx="5" fill="url(#m)" stroke="${r}" stroke-width="3"/><line x1="42" y1="29" x2="58" y2="29" stroke="${r}" stroke-width="3"/>`;case 2:return s+Ot(50,86,26,4)+`<polygon points="${Dt(50,54,30,6)}" fill="url(#m)" stroke="${r}" stroke-width="3.5"/><circle cx="50" cy="54" r="12" fill="${V(o,.5)}" stroke="${r}" stroke-width="3"/>`+Gr("M30 42 L42 34",3.5,.6);case 3:return s+Ot(50,90,30,4)+`<path d="${Go(50,52,36,10,8)}" fill="url(#m)" stroke="${r}" stroke-width="3"/><circle cx="50" cy="52" r="12" fill="${V(o,.5)}" stroke="${r}" stroke-width="3"/>`;case 4:return s+Ot(50,90,34,4)+`<path d="${Go(36,60,26,9,6)}" fill="url(#m)" stroke="${r}" stroke-width="3"/><path d="${Go(66,38,22,8,6)}" fill="${Q(o,.1)}" stroke="${r}" stroke-width="3"/><circle cx="36" cy="60" r="8" fill="${n}" stroke="${r}" stroke-width="2.5"/><circle cx="66" cy="38" r="7" fill="${V(o,.5)}" stroke="${r}" stroke-width="2.5"/>`;case 5:return s+Ot(50,90,34,4)+[26,38,50,62,74].map(a=>`<rect x="${a-2}" y="12" width="4" height="12" fill="#c9a24a"/><rect x="${a-2}" y="76" width="4" height="12" fill="#c9a24a"/>`).join("")+`<rect x="18" y="22" width="64" height="56" rx="6" fill="#2a3040" stroke="${r}" stroke-width="3.5"/><rect x="32" y="36" width="36" height="28" rx="3" fill="${n}" opacity="0.85"/><path d="M36 50 H46 V42 H54 V58 H64" stroke="#fff" stroke-width="2.5" fill="none"/>`;case 6:return s+Ot(50,92,22,4)+`<rect x="28" y="20" width="44" height="70" rx="8" fill="url(#m)" stroke="${r}" stroke-width="3.5"/><rect x="40" y="10" width="20" height="12" rx="3" fill="${V(o,.3)}" stroke="${r}" stroke-width="3"/><rect x="34" y="30" width="32" height="52" rx="4" fill="#1d2230"/>`+[0,1,2].map(a=>`<rect x="38" y="${66-a*15}" width="24" height="11" rx="2" fill="${n}" opacity="${.95-a*.25}"/>`).join("");case 7:return s+Ot(50,94,32,4)+`<line x1="50" y1="6" x2="50" y2="20" stroke="${r}" stroke-width="3"/><circle cx="50" cy="6" r="5" fill="${t.c("danger")}" stroke="${r}" stroke-width="2"/><rect x="16" y="20" width="68" height="60" rx="16" fill="url(#m)" stroke="${r}" stroke-width="3.5"/><rect x="26" y="34" width="48" height="24" rx="10" fill="#1d2230"/><circle cx="40" cy="46" r="7" fill="${n}"/><circle cx="60" cy="46" r="7" fill="${n}"/><rect x="38" y="64" width="24" height="6" rx="3" fill="${V(o,.5)}"/><rect x="6" y="38" width="10" height="22" rx="4" fill="${V(o,.2)}" stroke="${r}" stroke-width="3"/><rect x="84" y="38" width="10" height="22" rx="4" fill="${V(o,.2)}" stroke="${r}" stroke-width="3"/>`;default:return s+ie(Fe("f",[[0,"#fff"],[.4,t.c("coin")],[1,t.c("danger"),0]]))+`<ellipse cx="50" cy="88" rx="16" ry="12" fill="url(#f)"/><path d="M50 4 C66 18 70 40 66 70 L34 70 C30 40 34 18 50 4Z" fill="url(#m)" stroke="${r}" stroke-width="3.5"/><circle cx="50" cy="34" r="9" fill="${n}" stroke="${r}" stroke-width="3"/><path d="M34 54 L20 76 L34 72Z M66 54 L80 76 L66 72Z" fill="${t.c("danger")}" stroke="${r}" stroke-width="3" stroke-linejoin="round"/>`}}var Hp=e=>({w:100,h:100,draw(t){return t.style==="sci-fi"||t.style==="post-apocalypse"?Bp(e,t):zp(e,t)}}),Wp={w:100,h:100,main:"accent",draw({style:e,ink:t,c:r}){let o=e==="sci-fi"?"#4a5a80":e==="post-apocalypse"?"#5e6a3a":e==="cozy"?"#e09a5a":"#9a5a2c",n=e==="sci-fi"?r("primary"):e==="post-apocalypse"?"#8a8a7a":r("coin");return ie(he("b",[[0,Q(o,.2)],[1,V(o,.3)]]),he("l",[[0,Q(o,.35)],[1,o]]))+Ot(50,92,40,5)+`<rect x="10" y="44" width="80" height="46" rx="6" fill="url(#b)" stroke="${t}" stroke-width="4"/><path d="M10 46 L10 34 Q50 4 90 34 L90 46Z" fill="url(#l)" stroke="${t}" stroke-width="4" stroke-linejoin="round"/><rect x="10" y="42" width="80" height="8" fill="${n}" stroke="${t}" stroke-width="3"/><rect x="20" y="18" width="8" height="72" fill="${n}" opacity="0.9"/><rect x="72" y="18" width="8" height="72" fill="${n}" opacity="0.9"/><rect x="40" y="44" width="20" height="22" rx="4" fill="${n}" stroke="${t}" stroke-width="3"/><circle cx="50" cy="54" r="3.5" fill="${t}"/>`+Gr("M18 32 Q34 18 48 16",4,.45)}},Gc={coin:Tp,crystal:Dp,heart:Op,obstacle:Cp,spike:Pp,flag:Ip,shot:Vc,bolt:Vc,chest:Wp,...Object.fromEntries([1,2,3,4,5,6].map(e=>[`gem${e}`,Np(e)])),...Object.fromEntries([1,2,3,4,5,6,7,8].map(e=>[`item${e}`,Hp(e)]))};var pn=(e,t,r)=>U(Math.min(e,t)*r),jp={w:0,h:0,exact:true,main:"panel",draw({w:e,h:t,main:r,ink:o}){let n=Math.max(2,Math.min(Math.min(e,t)*.035,7)),s=U(Math.min(Math.min(e,t)*.14,24)),a=Cs(r)>.6;return ie(he("p",[[0,Q(r,a?.3:.12)],[1,V(r,a?.06:.25)]]))+`<rect x="${U(n/2)}" y="${U(n*1.5)}" width="${U(e-n)}" height="${U(t-n*2)}" rx="${s}" fill="#000" opacity="0.25"/><rect x="${U(n/2)}" y="${U(n/2)}" width="${U(e-n)}" height="${U(t-n*2)}" rx="${s}" fill="url(#p)" stroke="${a?V(r,.3):o}" stroke-width="${U(n)}"/><rect x="${U(n*2)}" y="${U(n*2)}" width="${U(e-n*4)}" height="${U(Math.max(1,t*.12))}" rx="${pn(e,t,.06)}" fill="#fff" opacity="0.1"/>`}},Vp={w:0,h:0,exact:true,main:"panel",draw({w:e,h:t,main:r,ink:o,c:n}){let s=Math.max(3,e*.03),a=n("coin");return ie(he("p",[[0,Q(r,.18)],[1,V(r,.3)]]),he("g",[[0,Q(a,.35)],[1,V(a,.25)]]))+`<rect x="${U(s)}" y="${U(s*2)}" width="${U(e-s*2)}" height="${U(t-s*2.5)}" rx="${pn(e,t,.1)}" fill="#000" opacity="0.35"/><rect x="${U(s)}" y="${U(s)}" width="${U(e-s*2)}" height="${U(t-s*2.5)}" rx="${pn(e,t,.1)}" fill="url(#g)" stroke="${o}" stroke-width="${U(s*.8)}"/><rect x="${U(s*2.4)}" y="${U(s*2.4)}" width="${U(e-s*4.8)}" height="${U(t-s*5.3)}" rx="${pn(e,t,.07)}" fill="url(#p)"/><circle cx="${U(e/2)}" cy="${U(t*.3)}" r="${U(e*.2)}" fill="${a}" opacity="0.18"/>`}},Gp={w:0,h:0,exact:true,main:"accent",draw({w:e,h:t,main:r,ink:o}){let n=Math.max(2,Math.min(e,t)*.06),s=t*.12;return ie(he("b",[[0,Q(r,.3)],[1,V(r,.1)]]))+`<rect x="${U(n/2)}" y="${U(s)}" width="${U(e-n)}" height="${U(t-s-n/2)}" rx="${pn(e,t,.3)}" fill="${V(r,.45)}" stroke="${o}" stroke-width="${U(n)}"/><rect x="${U(n/2)}" y="${U(n/2)}" width="${U(e-n)}" height="${U(t-s-n/2)}" rx="${pn(e,t,.3)}" fill="url(#b)" stroke="${o}" stroke-width="${U(n)}"/><rect x="${U(e*.12)}" y="${U(t*.12)}" width="${U(e*.76)}" height="${U(t*.16)}" rx="${U(t*.08)}" fill="#fff" opacity="0.35"/>`}},Kp={w:0,h:0,exact:true,main:"ground",draw({w:e,h:t,main:r}){let o=Cs(r)>.55;return ie(he("c",[[0,V(r,o?.12:.3)],[1,Q(r,o?.1:.06)]]))+`<rect x="1.5" y="1.5" width="${U(e-3)}" height="${U(t-3)}" rx="${pn(e,t,.16)}" fill="url(#c)"/><rect x="1.5" y="1.5" width="${U(e-3)}" height="${U(t-3)}" rx="${pn(e,t,.16)}" fill="none" stroke="#000" stroke-opacity="0.18" stroke-width="2"/>`}},Fp={w:0,h:0,exact:true,main:"panel",draw({w:e,h:t,main:r,ink:o}){let n=t*.16,s=Math.max(2,Math.min(e,t)*.05),i=Cs(r)>.6?Q(r,.4):Q(r,.85);return `<path d="M${U(s)} ${U(s)} H${U(e-s)} V${U(t-n-s)} H${U(e*.58)} L${U(e*.5)} ${U(t-s)} L${U(e*.42)} ${U(t-n-s)} H${U(s)}Z" fill="${i}" stroke="${o}" stroke-width="${U(s)}" stroke-linejoin="round"/>`}},qp={w:100,h:100,draw(){let e="#1c1622",t="#ffffff",r="#d9dde8";return `<ellipse cx="60" cy="96" rx="26" ry="4" fill="#000" opacity="0.18"/><path d="M30 52 L30 14 Q30 5 39 5 Q48 5 48 14 L48 44 Q50 38 57 38 Q64 38 65 45 Q67 40 73 40 Q80 41 80 49 Q82 45 86 46 Q92 48 91 56 L89 76 Q86 92 70 94 L48 94 Q36 93 31 82 L17 64 Q13 58 18 54 Q23 50 28 55 Z" fill="${t}" stroke="${e}" stroke-width="4" stroke-linejoin="round"/><path d="M48 44 L48 58 M65 45 L65 58 M80 49 L80 60" stroke="${e}" stroke-width="3" stroke-linecap="round"/><path d="M34 86 Q44 92 58 91" stroke="${r}" stroke-width="5" fill="none" stroke-linecap="round"/><path d="M35 14 Q36 9 40 9" stroke="${r}" stroke-width="3" fill="none" stroke-linecap="round"/>`}},Up={w:100,h:100,main:"accent",draw({main:e,ink:t}){return ie(he("p",[[0,Q(e,.35)],[1,V(e,.15)]]))+`<circle cx="50" cy="54" r="44" fill="${V(e,.45)}"/><circle cx="50" cy="50" r="44" fill="url(#p)" stroke="${t}" stroke-width="4"/><circle cx="50" cy="50" r="36" fill="none" stroke="#fff" stroke-opacity="0.35" stroke-width="3"/><path d="M41 30 L72 50 L41 70 Z" fill="#fff" stroke="${t}" stroke-width="3.5" stroke-linejoin="round"/><path d="M22 38 Q28 22 44 16" stroke="#fff" stroke-width="5" fill="none" stroke-linecap="round" opacity="0.55"/>`}},Kc={panel:jp,card:Vp,button:Gp,cell:Kp,ticket:Fp,hand:qp,play:Up};var Lr=(e,t=4,r=.55)=>`<path d="${e}" fill="none" stroke="#fff" stroke-width="${t}" stroke-linecap="round" opacity="${r}"/>`,mr=(e,t)=>({w:64,h:64,main:e,draw:({main:r,ink:o})=>t(r,o)}),Xp=mr("primary",(e,t)=>ie(he("b",[[0,Q(e,.55)],[1,V(e,.15)]]))+`<path d="M32 4 C50 10 58 28 52 46 C48 34 40 26 30 24 C28 16 29 9 32 4Z" fill="url(#b)" stroke="${t}" stroke-width="3" stroke-linejoin="round"/><path d="M32 60 C14 54 6 36 12 18 C16 30 24 38 34 40 C36 48 35 55 32 60Z" fill="url(#b)" stroke="${t}" stroke-width="3" stroke-linejoin="round"/><circle cx="32" cy="32" r="8" fill="${V(e,.35)}" stroke="${t}" stroke-width="3"/><circle cx="32" cy="32" r="3" fill="${Q(e,.6)}"/>`+Lr("M36 9 C44 13 49 20 51 28",3,.7)),Zp=mr("secondary",(e,t)=>ie(Fe("a",[[0,Q(e,.7),.95],[.55,e,.55],[1,e,0]]))+`<circle cx="32" cy="32" r="29" fill="url(#a)"/><circle cx="32" cy="32" r="20" fill="none" stroke="${Q(e,.4)}" stroke-width="3" stroke-dasharray="7 5"/><circle cx="32" cy="32" r="10" fill="${Q(e,.5)}" stroke="${t}" stroke-width="2.5"/>`),Qp={w:100,h:100,main:"secondary",draw:({main:e})=>ie(Fe("a",[[0,e,.05],[.7,e,.18],[.94,Q(e,.3),.5],[1,Q(e,.4),0]]))+`<circle cx="50" cy="50" r="50" fill="url(#a)"/><circle cx="50" cy="50" r="46" fill="none" stroke="${Q(e,.5)}" stroke-width="1.5" stroke-dasharray="6 6" opacity="0.7"/>`},Yp=mr("accent",(e,t)=>ie(he("g",[[0,Q(e,.4)],[1,V(e,.25)]]))+`<path d="M8 14 C22 10 34 18 38 30 C46 32 54 42 56 54 C48 50 40 46 32 44 C28 32 20 24 8 14Z" fill="url(#g)" stroke="${t}" stroke-width="3.5" stroke-linejoin="round"/><path d="M14 16 C24 16 31 22 34 32" fill="none" stroke="${V(e,.35)}" stroke-width="2.5"/>`+Lr("M14 15 C22 14 28 18 31 24",3,.7)),Jp=mr("primary",(e,t)=>ie(he("l",[[0,Q(e,.7)],[1,e]]))+`<polygon points="36,3 12,36 28,36 22,61 52,24 35,24 44,3" fill="url(#l)" stroke="${t}" stroke-width="3.5" stroke-linejoin="round"/>`+Lr("M33 9 L20 30",3,.75)),e0={w:100,h:20,main:"primary",draw:({main:e})=>`<polyline points="0,10 14,4 26,15 40,5 54,14 66,4 80,15 92,6 100,10" fill="none" stroke="${Q(e,.4)}" stroke-width="7" stroke-linejoin="round" opacity="0.55"/><polyline points="0,10 14,4 26,15 40,5 54,14 66,4 80,15 92,6 100,10" fill="none" stroke="#fff" stroke-width="2.5" stroke-linejoin="round"/>`},t0=mr("piece6",(e,t)=>ie(he("d",[[0,Q(e,.45)],[1,V(e,.2)]]))+`<rect x="4" y="18" width="20" height="5" rx="2.5" fill="${V(e,.4)}" stroke="${t}" stroke-width="2"/><rect x="40" y="18" width="20" height="5" rx="2.5" fill="${V(e,.4)}" stroke="${t}" stroke-width="2"/><path d="M14 23 L22 32 M50 23 L42 32" stroke="${t}" stroke-width="3"/><ellipse cx="32" cy="38" rx="17" ry="13" fill="url(#d)" stroke="${t}" stroke-width="3"/><circle cx="32" cy="38" r="6" fill="#16223a" stroke="${t}" stroke-width="2"/><circle cx="33.5" cy="36.5" r="2" fill="#7fe7ff"/>`+Lr("M21 32 C24 28 28 27 31 27",3,.6)),r0=mr("danger",(e,t)=>ie(he("f",[[0,Q(e,.35)],[1,V(e,.2)]]))+`<path d="M14 26 C14 18 20 14 26 15 L46 15 C52 15 54 20 54 25 L54 40 C54 50 46 58 36 58 L28 58 C20 58 14 52 14 44Z" fill="url(#f)" stroke="${t}" stroke-width="3.5" stroke-linejoin="round"/>`+[24,34,44].map(r=>`<path d="M${r} 16 L${r} 30" stroke="${V(e,.4)}" stroke-width="2.5"/>`).join("")+`<path d="M14 34 C22 30 30 32 32 38" fill="none" stroke="${t}" stroke-width="3"/>`+Lr("M20 20 C22 18 26 18 30 18",3,.6)),n0=mr("primary",(e,t)=>`<rect x="12" y="5" width="40" height="7" rx="3" fill="${V(e,.3)}" stroke="${t}" stroke-width="3"/><rect x="12" y="52" width="40" height="7" rx="3" fill="${V(e,.3)}" stroke="${t}" stroke-width="3"/><path d="M17 12 C17 26 30 28 30 32 C30 36 17 38 17 52 L47 52 C47 38 34 36 34 32 C34 28 47 26 47 12Z" fill="${Q(e,.75)}" stroke="${t}" stroke-width="3" stroke-linejoin="round"/><path d="M22 49 C24 42 30 40 32 40 C34 40 40 42 42 49Z" fill="${e}"/><path d="M24 16 L40 16 C38 22 34 24 32 26 C30 24 26 22 24 16Z" fill="${e}"/>`),o0=mr("accent",(e,t)=>ie(he("b",[[0,Q(e,.35)],[1,V(e,.25)]]))+`<path d="M18 6 L38 6 L38 34 L54 40 C58 42 58 50 54 52 L14 52 C12 52 11 50 12 48 L18 34Z" fill="url(#b)" stroke="${t}" stroke-width="3.5" stroke-linejoin="round"/><rect x="12" y="52" width="46" height="6" rx="3" fill="${V(e,.45)}" stroke="${t}" stroke-width="3"/><path d="M6 22 L14 22 M3 30 L13 30 M7 38 L13 38" stroke="${Q(e,.5)}" stroke-width="3" stroke-linecap="round"/>`+Lr("M23 11 L23 30",3,.6)),s0=mr("muted",(e,t)=>ie(he("s",[[0,Q(e,.45)],[1,V(e,.3)]]))+`<path d="M32 4 L54 12 C54 34 46 50 32 60 C18 50 10 34 10 12Z" fill="url(#s)" stroke="${t}" stroke-width="3.5" stroke-linejoin="round"/><path d="M32 12 L46 17 C46 32 41 43 32 51Z" fill="${Q(e,.25)}" opacity="0.6"/>`+Lr("M17 16 C17 26 19 34 23 40",3,.55)),a0=mr("danger",(e,t)=>`<path d="M10 8 L24 8 L24 34 C24 40 28 44 32 44 C36 44 40 40 40 34 L40 8 L54 8 L54 34 C54 48 44 58 32 58 C20 58 10 48 10 34Z" fill="${e}" stroke="${t}" stroke-width="3.5" stroke-linejoin="round"/><rect x="10" y="8" width="14" height="10" fill="#e8edf5" stroke="${t}" stroke-width="3"/><rect x="40" y="8" width="14" height="10" fill="#e8edf5" stroke="${t}" stroke-width="3"/>`+Lr("M15 26 C15 38 20 46 26 50",3,.55)),i0=mr("accent",(e,t)=>[[32,18],[46,32],[32,46],[18,32]].map(([r,o])=>`<circle cx="${r}" cy="${o}" r="12" fill="${e}" stroke="${t}" stroke-width="3"/>`).join("")+`<circle cx="32" cy="32" r="7" fill="${Q(e,.3)}"/><path d="M36 40 C40 50 44 56 50 60" fill="none" stroke="${t}" stroke-width="3.5" stroke-linecap="round"/>`+Lr("M26 12 C28 9 32 8 35 9",3,.6)),l0=mr("accent",(e,t)=>ie(he("p",[[0,Q(e,.4)],[1,V(e,.2)]]))+`<rect x="25" y="4" width="14" height="8" rx="2" fill="#b07a44" stroke="${t}" stroke-width="3"/><path d="M26 12 L38 12 L38 22 C48 26 54 34 54 42 C54 52 44 60 32 60 C20 60 10 52 10 42 C10 34 16 26 26 22Z" fill="#e8f2ff" stroke="${t}" stroke-width="3.5" stroke-linejoin="round"/><path d="M13 40 C20 36 44 36 51 40 C51 50 43 57 32 57 C21 57 13 50 13 40Z" fill="url(#p)"/>`+Lr("M18 32 C20 28 24 26 27 25",3,.7)),c0=mr("muted",(e,t)=>ie(Fe("b",[[0,"#6a7080"],[1,"#1c1f28"]],.35,.35,.7))+`<circle cx="30" cy="38" r="22" fill="url(#b)" stroke="${t}" stroke-width="3.5"/><rect x="34" y="12" width="12" height="10" rx="2" transform="rotate(35 40 17)" fill="#4a4f5c" stroke="${t}" stroke-width="3"/><path d="M44 12 C48 6 54 6 56 10" fill="none" stroke="#b07a44" stroke-width="3"/><polygon points="${Je(57,9,7,3,6)}" fill="#ffd54f" stroke="${t}" stroke-width="1.5"/>`+Lr("M18 30 C20 25 24 22 28 21",4,.5)+`<circle cx="30" cy="38" r="22" fill="${e}" opacity="0.08"/>`),d0={w:40,h:40,main:"danger",draw:({main:e,ink:t})=>ie(Fe("o",[[0,"#fff"],[.45,Q(e,.3)],[1,e]]))+`<circle cx="20" cy="20" r="17" fill="${e}" opacity="0.35"/><circle cx="20" cy="20" r="11" fill="url(#o)" stroke="${t}" stroke-width="2.5"/>`},f0=mr("text",(e,t)=>`<path d="M32 6 C18 6 9 16 9 28 C9 36 13 41 18 44 L18 54 C18 57 20 58 22 58 L42 58 C44 58 46 57 46 54 L46 44 C51 41 55 36 55 28 C55 16 46 6 32 6Z" fill="${Q(e,.1)}" stroke="${t}" stroke-width="3.5" stroke-linejoin="round"/><circle cx="22" cy="30" r="7" fill="${t}"/><circle cx="42" cy="30" r="7" fill="${t}"/><path d="M32 38 L28 45 L36 45Z" fill="${t}"/>`+[26,32,38].map(r=>`<path d="M${r} 50 L${r} 58" stroke="${t}" stroke-width="2.5"/>`).join("")),p0={w:64,h:64,main:"coin",draw:({main:e,ink:t})=>`<polygon points="${Je(32,32,29,17,10)}" fill="${Q(e,.25)}" stroke="${t}" stroke-width="3" stroke-linejoin="round"/><polygon points="${Dt(32,32,12,6)}" fill="${e}"/>`},Fc={blade:Xp,aura:Zp,aura_field:Qp,boomerang:Yp,lightning:Jp,zap:e0,drone:t0,fist:r0,hourglass:n0,boot:o0,shield:s0,magnet:a0,clover:i0,potion:l0,bomb:c0,orb:d0,skull:f0,burst:p0};var Ni=(e,t=4,r=.5)=>`<path d="${e}" fill="none" stroke="#fff" stroke-width="${t}" stroke-linecap="round" opacity="${r}"/>`,Is=(e,t)=>e==="sci-fi"?{body:"#4f5f86",trim:t("primary"),dark:"#232c47"}:e==="cozy"?{body:"#d9935a",trim:"#f6d38a",dark:"#7a4a2e"}:e==="post-apocalypse"?{body:"#8a6a52",trim:"#c9a14a",dark:"#3d2f24"}:{body:"#9a6b43",trim:t("accent"),dark:"#4a3322"},h0={w:100,h:60,draw({style:e,ink:t,c:r}){let o=Is(e,r),n=r("danger");return ie(he("b",[[0,Q(o.trim,.4)],[1,V(o.trim,.15)]]))+`<ellipse cx="50" cy="57" rx="44" ry="3" fill="#000" opacity="0.25"/><rect x="10" y="14" width="9" height="44" rx="3" fill="${o.body}" stroke="${t}" stroke-width="3"/><rect x="81" y="14" width="9" height="44" rx="3" fill="${o.body}" stroke="${t}" stroke-width="3"/><rect x="4" y="10" width="92" height="17" rx="5" fill="url(#b)" stroke="${t}" stroke-width="3.5"/>`+[16,38,60,82].map(s=>`<path d="M${s} 11 L${s+10} 11 L${s+2} 26 L${s-8} 26Z" fill="${n}" opacity="0.9"/>`).join("")+`<rect x="4" y="10" width="92" height="17" rx="5" fill="none" stroke="${t}" stroke-width="3.5"/><rect x="14" y="32" width="72" height="8" rx="3" fill="${V(o.trim,.1)}" stroke="${t}" stroke-width="2.5"/>`+Ni("M12 15 L88 15",2.5,.55)}},u0={w:120,h:40,draw({style:e,ink:t,c:r}){let o=Is(e,r);return ie(Fe("p",[[0,"#000000",1],[.7,"#0b0d14",.95],[1,V(o.dark,.2),.9]]))+`<path d="M8 20 C10 6 32 3 60 4 C90 3 112 7 112 20 C112 33 90 37 60 36 C30 37 8 34 8 20Z" fill="${o.dark}" stroke="${t}" stroke-width="3"/><path d="M16 21 C18 11 36 9 60 9 C86 9 104 12 104 21 C104 30 86 32 60 32 C34 32 16 30 16 21Z" fill="url(#p)"/><path d="M20 12 L28 16 L34 10 L44 15 L52 9 L62 14 L72 9 L82 14 L92 10 L100 15" fill="none" stroke="${Q(o.dark,.25)}" stroke-width="2.5" stroke-linejoin="round"/>`}},m0={w:300,h:100,draw({style:e,ink:t,c:r}){let o=Is(e,r),n=r("secondary");return ie(he("w",[[0,Q(n,.35)],[1,V(n,.3)]]))+`<rect x="4" y="8" width="292" height="72" rx="10" fill="url(#w)" stroke="${t}" stroke-width="4"/><rect x="4" y="8" width="292" height="12" rx="6" fill="${Q(n,.45)}" stroke="${t}" stroke-width="3"/>`+[30,100,170,240].map(s=>`<rect x="${s}" y="30" width="40" height="24" rx="4" fill="${Q(o.trim,.55)}" stroke="${t}" stroke-width="3"/>`).join("")+`<rect x="4" y="64" width="292" height="10" fill="${V(n,.4)}"/>`+[40,90,210,260].map(s=>`<circle cx="${s}" cy="84" r="12" fill="${o.dark}" stroke="${t}" stroke-width="3.5"/><circle cx="${s}" cy="84" r="4" fill="${o.trim}"/>`).join("")+Ni("M14 26 L120 26",3,.4)}},y0={w:140,h:100,draw({style:e,ink:t,c:r}){let o=Is(e,r);return ie(he("r",[[0,Q(o.trim,.3)],[1,V(o.trim,.25)]]))+`<path d="M4 96 L136 8 L136 96Z" fill="${o.body}" stroke="${t}" stroke-width="4" stroke-linejoin="round"/><path d="M4 96 L136 8 L136 20 L22 96Z" fill="url(#r)" stroke="${t}" stroke-width="3" stroke-linejoin="round"/>`+[0,1,2].map(n=>{let s=60+n*22,a=70-n*15;return `<path d="M${s-8} ${a+6} L${s} ${a-4} L${s+8} ${a+6}" fill="none" stroke="#fff" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" opacity="0.8"/>`}).join("")}},g0={w:100,h:100,draw({style:e,ink:t,c:r}){let o=e==="sci-fi"?"#7c86a8":e==="cozy"?"#b8a99a":"#8f8a82",n=e==="cozy"?"#7ccf6a":e==="sci-fi"?r("primary"):"#6b8f4a";return ie(he("s",[[0,Q(o,.35)],[1,V(o,.35)]]))+`<ellipse cx="50" cy="95" rx="42" ry="5" fill="#000" opacity="0.28"/><path d="M10 92 C4 70 14 44 30 32 C40 14 66 10 80 26 C96 40 98 70 90 92Z" fill="url(#s)" stroke="${t}" stroke-width="4" stroke-linejoin="round"/><path d="M34 50 L46 62 M62 40 L70 54 M28 74 L40 70" stroke="${V(o,.45)}" stroke-width="3" stroke-linecap="round"/><path d="M30 34 C40 26 52 24 62 28" fill="none" stroke="${n}" stroke-width="6" stroke-linecap="round" opacity="0.85"/>`+Ni("M24 48 C28 38 36 32 44 30",4,.45)}},b0={w:100,h:30,draw:()=>ie(Fe("d",[[0,"#000000",.8],[.7,"#000000",.5],[1,"#000000",0]]))+'<ellipse cx="50" cy="15" rx="50" ry="15" fill="url(#d)"/>'},x0={w:60,h:300,draw({ink:e,c:t}){let r="#ffffff",o="#1b1d24",n=[];for(let s=0;s<14;s++)for(let a=0;a<2;a++)n.push(`<rect x="${16+a*14}" y="${18+s*18}" width="14" height="18" fill="${(s+a)%2===0?r:o}"/>`);return `<rect x="10" y="10" width="40" height="270" rx="4" fill="${o}" stroke="${e}" stroke-width="4"/>`+n.join("")+`<rect x="10" y="10" width="40" height="270" rx="4" fill="none" stroke="${e}" stroke-width="4"/><rect x="4" y="276" width="52" height="20" rx="5" fill="${t("accent")}" stroke="${e}" stroke-width="3.5"/><circle cx="30" cy="8" r="7" fill="${t("coin")}" stroke="${e}" stroke-width="3"/>`}},k0={w:64,h:64,main:"coin",draw:({main:e,ink:t})=>ie(Fe("c",[[0,Q(e,.5)],[.7,e],[1,V(e,.2)]]))+`<circle cx="24" cy="36" r="18" fill="url(#c)" stroke="${t}" stroke-width="3.5"/><circle cx="40" cy="26" r="18" fill="url(#c)" stroke="${t}" stroke-width="3.5"/><circle cx="40" cy="26" r="11" fill="none" stroke="${V(e,.25)}" stroke-width="2.5"/><rect x="30" y="40" width="30" height="20" rx="7" fill="${V(e,.55)}" stroke="${t}" stroke-width="3"/><path d="M36 45 L43 55 M43 45 L36 55" stroke="#fff" stroke-width="3.2" stroke-linecap="round"/><path d="M47 47 C48 43 55 43 55 47 C55 50 47 53 47 55 L55 55" fill="none" stroke="#fff" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/>`},v0={w:64,h:64,main:"secondary",draw:({main:e,ink:t})=>ie(he("g",[[0,Q(e,.6)],[1,V(e,.15)]]))+`<path d="M32 40 C22 22 10 14 4 14 C6 26 10 40 20 48 C10 48 8 52 6 56 C18 58 28 54 32 48Z" fill="url(#g)" stroke="${t}" stroke-width="3" stroke-linejoin="round"/><path d="M32 40 C42 22 54 14 60 14 C58 26 54 40 44 48 C54 48 56 52 58 56 C46 58 36 54 32 48Z" fill="url(#g)" stroke="${t}" stroke-width="3" stroke-linejoin="round"/><path d="M12 22 C16 30 20 36 26 40 M52 22 C48 30 44 36 38 40" fill="none" stroke="${Q(e,.7)}" stroke-width="2.5" stroke-linecap="round"/><circle cx="32" cy="44" r="5" fill="${Q(e,.4)}" stroke="${t}" stroke-width="2.5"/>`},qc={hurdle:h0,pit:u0,wagon:m0,ramp:y0,rock:g0,shadow:b0,finish:x0,coin2x:k0,wing:v0};var zi=(e,t=4,r=.55)=>`<path d="${e}" fill="none" stroke="#fff" stroke-width="${t}" stroke-linecap="round" opacity="${r}"/>`,$0={w:100,h:100,main:"coin",draw:({main:e,ink:t})=>ie(Fe("g",[[0,Q(e,.6),.75],[.6,e,.25],[1,e,0]]),he("s",[[0,Q(e,.55)],[1,V(e,.25)]]))+`<circle cx="50" cy="52" r="48" fill="url(#g)"/><polygon points="${Je(50,54,40,18)}" fill="url(#s)" stroke="${t}" stroke-width="4.5" stroke-linejoin="round"/><polygon points="${Je(50,54,22,10)}" fill="${Q(e,.45)}" opacity="0.7"/>`+zi("M38 32 L46 22",4,.75)},M0={w:64,h:64,main:"coin",draw:({main:e,ink:t})=>ie(he("k",[[0,Q(e,.45)],[1,V(e,.25)]]))+`<circle cx="20" cy="22" r="14" fill="url(#k)" stroke="${t}" stroke-width="3.5"/><circle cx="20" cy="22" r="5.5" fill="${V(e,.5)}"/><path d="M29 31 L54 56 M44 46 L50 40 M50 52 L56 46" stroke="${t}" stroke-width="9" stroke-linecap="round"/><path d="M29 31 L54 56 M44 46 L50 40 M50 52 L56 46" stroke="url(#k)" stroke-width="4.5" stroke-linecap="round"/>`+zi("M12 18 C13 13 16 11 20 10",3,.7)},w0={w:80,h:60,main:"accent",draw:({main:e,ink:t})=>ie(he("p",[[0,Q(e,.4)],[1,V(e,.2)]]))+`<rect x="14" y="50" width="52" height="8" rx="3" fill="#5a6070" stroke="${t}" stroke-width="3"/><path d="M24 50 L56 44 L24 38 L56 32 L24 26 L56 20" fill="none" stroke="${t}" stroke-width="7" stroke-linejoin="round"/><path d="M24 50 L56 44 L24 38 L56 32 L24 26 L56 20" fill="none" stroke="#c9d1dc" stroke-width="3.5" stroke-linejoin="round"/><rect x="6" y="6" width="68" height="14" rx="6" fill="url(#p)" stroke="${t}" stroke-width="3.5"/>`+zi("M14 10 L60 10",2.5,.6)},Uc={bigstar:$0,key:M0,spring:w0};var Ns=(e,t=4,r=.5)=>`<path d="${e}" fill="none" stroke="#fff" stroke-width="${t}" stroke-linecap="round" opacity="${r}"/>`,Kr=e=>e==="sci-fi"?{stone:"#5d6f96",wood:"#2f3a5c",metal:"#8fa3c8"}:e==="cozy"?{stone:"#f1e2cf",wood:"#c98b5a",metal:"#9aa3b0"}:e==="post-apocalypse"?{stone:"#8a7a62",wood:"#5e4a36",metal:"#7d7466"}:{stone:"#aeb0b8",wood:"#8a5a34",metal:"#6a7080"},Bi=e=>78-e*12,zs='<ellipse cx="50" cy="123" rx="38" ry="7" fill="#000" opacity="0.28"/>';function Xc(e,t,r,o,n){let s="";for(let a=r+10;a<116;a+=11){s+=`<line x1="${e+2}" y1="${a}" x2="${e+t-2}" y2="${a}" stroke="${V(o,.25)}" stroke-width="2"/>`;for(let i=1;i<3;i++){let h=e+t*i/3+((a-r)/11%2?6:0);s+=`<line x1="${h}" y1="${a}" x2="${h}" y2="${a+11}" stroke="${V(o,.25)}" stroke-width="2"/>`;}}return ie(he("s",[[0,Q(o,.25)],[1,V(o,.22)]],true))+`<rect x="${e}" y="${r}" width="${t}" height="${118-r}" fill="url(#s)" stroke="${n}" stroke-width="3.5"/>`+s+`<path d="M43 118 L43 105 A7 7 0 0 1 57 105 L57 118Z" fill="#3a2a1e" stroke="${n}" stroke-width="2.5"/>`}function E0(e,t,r){let{style:o,ink:n,c:s}=e,a=Kr(o),i=Bi(t)-(r?8:0),h=s(r==="sniper"?"danger":r==="ranger"?"coin":"accent"),m=Xc(28,44,i+18,a.stone,n),v=`<rect x="20" y="${i+8}" width="60" height="12" rx="2" fill="${a.wood}" stroke="${n}" stroke-width="3"/>`+[26,38,50,62,74].map(q=>`<rect x="${q-2}" y="${i-6}" width="4" height="15" fill="${Q(a.wood,.15)}" stroke="${n}" stroke-width="1.5"/>`).join("")+`<rect x="20" y="${i-8}" width="60" height="5" rx="2" fill="${Q(a.wood,.2)}" stroke="${n}" stroke-width="2.5"/>`,x=t>=2?`<polygon points="14,${i-8} 50,${i-36} 86,${i-8}" fill="${h}" stroke="${n}" stroke-width="3.5" stroke-linejoin="round"/><polygon points="14,${i-8} 50,${i-36} 38,${i-8}" fill="${Q(h,.25)}"/>`:"",D=t>=3?`<line x1="50" y1="${i-36}" x2="50" y2="${i-54}" stroke="${n}" stroke-width="3"/><path d="M50 ${i-54} L70 ${i-48} L50 ${i-42}Z" fill="${s("coin")}" stroke="${n}" stroke-width="2"/>`:"",O=(q,ne,Z=1)=>`<path d="M${q} ${ne-12*Z} Q${q+9*Z} ${ne} ${q} ${ne+12*Z}" fill="none" stroke="${a.wood}" stroke-width="${3.5*Z}" stroke-linecap="round"/><line x1="${q}" y1="${ne-12*Z}" x2="${q}" y2="${ne+12*Z}" stroke="#eee" stroke-width="1.5"/>`,N=O(66,i-2);return r==="ranger"&&(N=O(30,i-2)+O(68,i-2)),r==="sniper"&&(N=`<rect x="44" y="${i-6}" width="44" height="6" rx="2" fill="${a.metal}" stroke="${n}" stroke-width="2.5"/><rect x="56" y="${i-13}" width="14" height="6" rx="2" fill="${V(a.metal,.3)}" stroke="${n}" stroke-width="2"/>`),zs+m+v+N+x+D+Ns(`M24 ${i+11} L44 ${i+11}`,2.5,.45)}function S0(e,t,r){let{style:o,ink:n,c:s}=e,a=Kr(o),i=Bi(t)+14-(r?6:0),h=ie(he("b",[[0,Q(a.stone,.3)],[1,V(a.stone,.25)]],true),he("m",[[0,Q(a.metal,.35)],[1,V(a.metal,.35)]]))+`<path d="M20 118 L24 ${i} L76 ${i} L80 118Z" fill="url(#b)" stroke="${n}" stroke-width="3.5" stroke-linejoin="round"/>`+[0,1,2].map(ne=>`<rect x="${22+ne*20}" y="${i-9}" width="14" height="11" fill="${a.stone}" stroke="${n}" stroke-width="2.5"/>`).join("")+(t>=2?`<rect x="22" y="${i+14}" width="56" height="7" fill="${V(a.stone,.2)}" stroke="${n}" stroke-width="2"/>`:"")+(t>=3?`<rect x="22" y="${i+30}" width="56" height="7" fill="${s("coin")}" stroke="${n}" stroke-width="2"/>`:""),m=r==="bombard"?1.45:1+t*.08,v=34*m,x=13*m,D=`<g transform="rotate(-28 50 ${i-4})"><rect x="46" y="${i-4-x/2}" width="${v}" height="${x}" rx="${x/3}" fill="url(#m)" stroke="${n}" stroke-width="3"/><rect x="${46+v-7}" y="${i-4-x/2-2}" width="8" height="${x+4}" rx="2" fill="${V(a.metal,.3)}" stroke="${n}" stroke-width="2.5"/></g><circle cx="50" cy="${i-4}" r="${9*m}" fill="${V(a.metal,.2)}" stroke="${n}" stroke-width="3"/>`,O=44+v,N=r==="flamer"?`<g transform="rotate(-28 50 ${i-4})"><path d="M${O} ${i-16} C${O+14} ${i-22} ${O+30} ${i-10} ${O+22} ${i-4} C${O+30} ${i+2} ${O+14} ${i+14} ${O} ${i+8}Z" fill="#ff7a1a" stroke="${n}" stroke-width="2.5" stroke-linejoin="round"/><path d="M${O+2} ${i-9} C${O+12} ${i-12} ${O+18} ${i-6} ${O+13} ${i-3} C${O+18} ${i} ${O+10} ${i+6} ${O+2} ${i+2}Z" fill="#ffd34a"/></g>`:"",q=r==="bombard"?`<polygon points="${Je(50,i+24,8,3.5)}" fill="${s("danger")}" stroke="${n}" stroke-width="2"/>`:"";return zs+h+D+N+q+Ns(`M28 ${i+4} L28 ${i+40}`,3,.4)}function L0(e,t,r){let{style:o,ink:n,c:s}=e,a=Kr(o),i=64-t*6-(r?4:0),h=r==="storm"?s("coin"):r==="arcane"?Q(s("secondary"),.2):s("secondary"),m=Xc(32,36,i,a.stone,n)+`<rect x="44" y="${i+16}" width="12" height="16" rx="6" fill="${h}" stroke="${n}" stroke-width="2.5" opacity="0.9"/>`,v=i-28,x=`<polygon points="26,${i+2} 50,${v} 74,${i+2}" fill="${s("secondary")}" stroke="${n}" stroke-width="3.5" stroke-linejoin="round"/><polygon points="26,${i+2} 50,${v} 42,${i+2}" fill="${Q(s("secondary"),.25)}"/>`,D=7+t*1.3+(r==="arcane"?3:0),O=Math.max(D+6+(r==="arcane"?8:0),v-D*.5),N=ie(Fe("o",[[0,"#ffffff",1],[.45,h,.95],[1,h,.3]]))+`<circle cx="50" cy="${O}" r="${D+7}" fill="${h}" opacity="0.25"/><circle cx="50" cy="${O}" r="${D}" fill="url(#o)" stroke="${n}" stroke-width="2.5"/>`,q=r==="storm"?[-1,1].map(ne=>`<path d="M${50+ne*(D+3)} ${O-6} L${50+ne*(D+10)} ${O} L${50+ne*(D+5)} ${O+2} L${50+ne*(D+13)} ${O+10}" fill="none" stroke="${s("coin")}" stroke-width="3" stroke-linejoin="round"/>`).join(""):r==="arcane"?`<circle cx="50" cy="${O}" r="${D+11}" fill="none" stroke="${h}" stroke-width="2.5" stroke-dasharray="5 4"/>`:"";return zs+m+x+N+q}function _0(e,t,r){let{style:o,ink:n,c:s}=e,a=Kr(o),i=Bi(t)+10-(r?6:0),h=r==="glacier"?V(s("primary"),.15):Q(s("primary"),.35),m=ie(he("p",[[0,Q(a.stone,.25)],[1,V(a.stone,.25)]],true),he("i",[[0,"#ffffff"],[.5,h],[1,V(h,.25)]]))+`<path d="M24 118 L28 ${i+18} L72 ${i+18} L76 118Z" fill="url(#p)" stroke="${n}" stroke-width="3.5" stroke-linejoin="round"/>`,v=(O,N,q,ne)=>`<g transform="rotate(${ne} ${O} ${i+20})"><polygon points="${O-q},${i+20} ${O-q*.8},${i+20-N*.75} ${O},${i+20-N} ${O+q*.8},${i+20-N*.75} ${O+q},${i+20}" fill="url(#i)" stroke="${n}" stroke-width="2.5" stroke-linejoin="round"/><line x1="${O}" y1="${i+20-N}" x2="${O}" y2="${i+18}" stroke="#fff" stroke-width="1.5" opacity="0.6"/></g>`,x=v(50,38+t*6,10,0);t>=2&&(x=v(36,26+t*3,7,-14)+v(64,26+t*3,7,14)+x),t>=3&&(x=v(28,20,5,-26)+v(72,20,5,26)+x),r==="glacier"&&(x+=v(50,70,15,0));let D=r==="blizzard"?[0,1,2,3,4].map(O=>`<polygon points="${Je(22+O*14,i-30+O%2*12,5,2,6)}" fill="#fff" stroke="${n}" stroke-width="1.2"/>`).join(""):"";return zs+m+x+D}var R0={archer:E0,cannon:S0,mage:L0,frost:_0},Ct=(e,t,r="")=>({w:100,h:130,draw:o=>R0[e](o,t,r)}),A0={w:100,h:64,draw({style:e,ink:t,c:r}){let o=Kr(e),n=Array.from({length:10},(s,a)=>{let i=a/10*Math.PI*2;return `<ellipse cx="${(50+Math.cos(i)*38).toFixed(1)}" cy="${(34+Math.sin(i)*20).toFixed(1)}" rx="9" ry="6" fill="${a%2?o.stone:Q(o.stone,.15)}" stroke="${t}" stroke-width="2.5"/>`}).join("");return `<ellipse cx="50" cy="34" rx="40" ry="22" fill="${V(o.stone,.45)}" opacity="0.55"/>`+n+`<line x1="78" y1="30" x2="78" y2="6" stroke="${t}" stroke-width="2.5"/><path d="M78 6 L92 10 L78 15Z" fill="${r("coin")}" stroke="${t}" stroke-width="1.5"/>`}},T0={w:100,h:100,draw({style:e,ink:t,c:r}){let o=Kr(e),n=a=>`<rect x="${a}" y="22" width="22" height="72" fill="${o.stone}" stroke="${t}" stroke-width="3"/>`+[0,1].map(i=>`<rect x="${a+i*13}" y="13" width="9" height="11" fill="${o.stone}" stroke="${t}" stroke-width="2.5"/>`).join("")+`<polygon points="${a-3},22 ${a+11},2 ${a+25},22" fill="${r("danger")}" stroke="${t}" stroke-width="3" stroke-linejoin="round"/>`,s="";for(let a=38;a<=62;a+=6)s+=`<line x1="${a}" y1="52" x2="${a}" y2="94" stroke="${V(o.metal,.3)}" stroke-width="3"/>`;return `<ellipse cx="50" cy="95" rx="46" ry="5" fill="#000" opacity="0.28"/><rect x="22" y="36" width="56" height="58" fill="${Q(o.stone,.1)}" stroke="${t}" stroke-width="3.5"/><path d="M34 94 L34 60 A16 16 0 0 1 66 60 L66 94Z" fill="#241a14" stroke="${t}" stroke-width="3"/>`+s+n(8)+n(70)+`<rect x="44" y="40" width="12" height="9" fill="${r("coin")}" stroke="${t}" stroke-width="2"/>`}},D0={w:100,h:90,draw({style:e,ink:t}){let r=Kr(e);return `<path d="M6 86 C6 40 26 10 50 10 C74 10 94 40 94 86Z" fill="${V(r.stone,.15)}" stroke="${t}" stroke-width="4" stroke-linejoin="round"/><path d="M24 86 C24 52 36 30 50 30 C64 30 76 52 76 86Z" fill="#120c10" stroke="${t}" stroke-width="3"/><circle cx="42" cy="58" r="3" fill="#ff5a3a"/><circle cx="56" cy="58" r="3" fill="#ff5a3a"/>`}},O0={w:100,h:130,draw({style:e,ink:t,c:r}){let o=Kr(e),n=e==="post-apocalypse"?"#6b6a3a":e==="sci-fi"?r("secondary"):e==="cozy"?"#6fcf6a":"#3f8f3a";return e==="post-apocalypse"?`<ellipse cx="50" cy="124" rx="26" ry="5" fill="#000" opacity="0.28"/><path d="M46 124 L48 60 L30 40 M48 70 L68 46 M48 84 L32 74" fill="none" stroke="${o.wood}" stroke-width="8" stroke-linecap="round"/><path d="M46 124 L48 60" stroke="${t}" stroke-width="2" opacity="0.4"/>`:ie(Fe("l",[[0,Q(n,.35),1],[1,V(n,.2),1]],.4,.35,.65))+`<ellipse cx="50" cy="124" rx="30" ry="6" fill="#000" opacity="0.28"/><rect x="42" y="78" width="16" height="46" rx="4" fill="${o.wood}" stroke="${t}" stroke-width="3"/>`+(e==="sci-fi"?`<polygon points="${Dt(50,50,36,6)}" fill="url(#l)" stroke="${t}" stroke-width="3.5"/>`:`<circle cx="34" cy="62" r="24" fill="url(#l)" stroke="${t}" stroke-width="3.5"/><circle cx="66" cy="62" r="24" fill="url(#l)" stroke="${t}" stroke-width="3.5"/><circle cx="50" cy="38" r="28" fill="url(#l)" stroke="${t}" stroke-width="3.5"/>`)+Ns("M36 26 C42 20 50 18 56 20",4,.4)}},C0={w:100,h:70,draw({style:e,ink:t,c:r}){let o=e==="post-apocalypse"?"#7a6a3a":e==="sci-fi"?r("secondary"):e==="cozy"?"#7fd87a":"#4a9a3e";return `<ellipse cx="50" cy="64" rx="40" ry="5" fill="#000" opacity="0.25"/><circle cx="30" cy="44" r="20" fill="${o}" stroke="${t}" stroke-width="3"/><circle cx="70" cy="44" r="20" fill="${o}" stroke="${t}" stroke-width="3"/><circle cx="50" cy="32" r="24" fill="${Q(o,.12)}" stroke="${t}" stroke-width="3"/>`+[30,54,70].map((n,s)=>`<circle cx="${n}" cy="${36+s%2*10}" r="4" fill="${r(s===1?"coin":"danger")}"/>`).join("")}},P0={w:100,h:30,draw:({ink:e})=>`<line x1="10" y1="15" x2="80" y2="15" stroke="#8a5a34" stroke-width="5" stroke-linecap="round"/><polygon points="78,6 98,15 78,24" fill="#d8dde6" stroke="${e}" stroke-width="2.5" stroke-linejoin="round"/><path d="M4 7 L20 15 L4 23 M12 7 L26 15 L12 23" fill="none" stroke="#e8e0d0" stroke-width="3"/>`},I0={w:100,h:100,main:"danger",draw:({main:e,ink:t})=>ie(Fe("f",[[0,"#fff6c0",1],[.4,"#ffb23a",1],[1,e,.9]]))+`<path d="M62 10 C82 18 96 30 98 40 L70 62 Z" fill="#ff8a2a" opacity="0.75"/><path d="M50 16 C70 26 84 40 86 52 L60 66 Z" fill="#ffd34a" opacity="0.6"/><circle cx="40" cy="62" r="26" fill="url(#f)" stroke="${t}" stroke-width="3.5"/><circle cx="32" cy="56" r="5" fill="${V(e,.35)}"/><circle cx="48" cy="70" r="4" fill="${V(e,.35)}"/>`},N0={w:100,h:80,main:"coin",draw:({main:e,ink:t})=>{let r=(o,n)=>`<polygon points="${o},${n+18} ${o+6},${n} ${o+34},${n} ${o+40},${n+18}" fill="url(#g)" stroke="${t}" stroke-width="3" stroke-linejoin="round"/>`+Ns(`M${o+10} ${n+5} L${o+24} ${n+5}`,2.5,.7);return ie(he("g",[[0,Q(e,.5)],[1,V(e,.25)]]))+'<ellipse cx="50" cy="74" rx="44" ry="5" fill="#000" opacity="0.25"/>'+r(8,52)+r(52,52)+r(30,32)+r(30,12)}},z0={w:100,h:100,draw:({ink:e})=>`<path d="M14 86 L86 14 M14 14 L86 86" stroke="#d8dde6" stroke-width="9" stroke-linecap="round"/><path d="M14 86 L86 14 M14 14 L86 86" stroke="${e}" stroke-width="2.5" stroke-linecap="round" opacity="0.6"/><path d="M26 46 C26 24 38 14 50 14 C62 14 74 24 74 46 C74 58 68 62 64 64 L64 76 L36 76 L36 64 C32 62 26 58 26 46Z" fill="#f4efe4" stroke="${e}" stroke-width="4" stroke-linejoin="round"/><circle cx="40" cy="46" r="8" fill="#2a1e1e"/><circle cx="60" cy="46" r="8" fill="#2a1e1e"/><path d="M50 54 L46 62 L54 62Z" fill="#2a1e1e"/><path d="M42 76 L42 68 M50 76 L50 68 M58 76 L58 68" stroke="${e}" stroke-width="2.5"/>`},B0={w:100,h:100,draw({style:e,ink:t,c:r}){let o=Kr(e),n=r("danger");return `<rect x="30" y="30" width="34" height="56" fill="${o.stone}" stroke="${t}" stroke-width="3.5"/>`+[30,41,52].map(s=>`<rect x="${s+1}" y="20" width="8" height="11" fill="${o.stone}" stroke="${t}" stroke-width="2.5"/>`).join("")+`<path d="M41 86 L41 74 A6 6 0 0 1 53 74 L53 86Z" fill="#3a2a1e" stroke="${t}" stroke-width="2.5"/><circle cx="47" cy="52" r="38" fill="none" stroke="${t}" stroke-width="13"/><circle cx="47" cy="52" r="38" fill="none" stroke="${n}" stroke-width="8"/><line x1="20" y1="79" x2="74" y2="25" stroke="${t}" stroke-width="13" stroke-linecap="round"/><line x1="20" y1="79" x2="74" y2="25" stroke="${n}" stroke-width="8" stroke-linecap="round"/>`+ie(he("g",[[0,Q(r("coin"),.45)],[1,V(r("coin"),.2)]]))+`<circle cx="78" cy="80" r="17" fill="url(#g)" stroke="${t}" stroke-width="3.5"/><path d="M78 71 L78 89 M69 80 L87 80" stroke="${V(r("coin"),.45)}" stroke-width="4" stroke-linecap="round"/>`}},Zc={td_sell:B0,td_archer1:Ct("archer",1),td_archer2:Ct("archer",2),td_archer3:Ct("archer",3),td_archer_ranger:Ct("archer",3,"ranger"),td_archer_sniper:Ct("archer",3,"sniper"),td_cannon1:Ct("cannon",1),td_cannon2:Ct("cannon",2),td_cannon3:Ct("cannon",3),td_cannon_bombard:Ct("cannon",3,"bombard"),td_cannon_flamer:Ct("cannon",3,"flamer"),td_mage1:Ct("mage",1),td_mage2:Ct("mage",2),td_mage3:Ct("mage",3),td_mage_arcane:Ct("mage",3,"arcane"),td_mage_storm:Ct("mage",3,"storm"),td_frost1:Ct("frost",1),td_frost2:Ct("frost",2),td_frost3:Ct("frost",3),td_frost_glacier:Ct("frost",3,"glacier"),td_frost_blizzard:Ct("frost",3,"blizzard"),td_spot:A0,td_gate:T0,td_portal:D0,td_tree:O0,td_bush:C0,td_arrow:P0,td_meteor:I0,td_gold:N0,td_call:z0};var Fo=(e,t=4,r=.5)=>`<path d="${e}" fill="none" stroke="#fff" stroke-width="${t}" stroke-linecap="round" opacity="${r}"/>`,H0={w:100,h:100,draw:({ink:e})=>{let r=["#ff5a5a","#ffb03a","#ffe14a","#5ad35a","#4aa8ff","#a26bff"].map((o,n)=>{let s=n/6*Math.PI*2,a=(n+1)/6*Math.PI*2,i=h=>`${(50+Math.cos(h)*38).toFixed(1)} ${(50+Math.sin(h)*38).toFixed(1)}`;return `<path d="M50 50 L${i(s)} A38 38 0 0 1 ${i(a)}Z" fill="${o}"/>`});return ie(Fe("g",[[0,"#ffffff",.95],[.5,"#ffffff",.2],[1,"#ffffff",0]],.38,.35,.5))+'<circle cx="50" cy="50" r="46" fill="#ffffff" opacity="0.25"/>'+r.join("")+`<circle cx="50" cy="50" r="38" fill="url(#g)" stroke="${e}" stroke-width="4"/><polygon points="${Je(50,50,13,6)}" fill="#fff" opacity="0.9"/>`}},Qc=e=>({w:100,h:100,draw:({ink:t})=>{let r=`<path d="M8 50 L24 38 L24 45 L76 45 L76 38 L92 50 L76 62 L76 55 L24 55 L24 62Z" fill="#fff" stroke="${t}" stroke-width="3" stroke-linejoin="round"/>`;return `<g ${e?'transform="rotate(90 50 50)"':""} opacity="0.95">${r}</g>`}}),W0={w:100,h:100,draw:({ink:e})=>`<circle cx="50" cy="50" r="40" fill="none" stroke="#fff" stroke-width="7" opacity="0.9"/><circle cx="50" cy="50" r="40" fill="none" stroke="${e}" stroke-width="2" opacity="0.6"/><polygon points="${Je(78,20,13,5,8)}" fill="#ffd34a" stroke="${e}" stroke-width="2"/>`},Yc=e=>({w:100,h:100,draw:({ink:t})=>ie(he("i",[[0,"#e6f6ff",.75],[1,"#7cc4ff",e>1?.85:.6]]))+`<rect x="3" y="3" width="94" height="94" rx="12" fill="url(#i)" stroke="${t}" stroke-width="3" opacity="0.95"/>`+(e>1?'<rect x="12" y="12" width="76" height="76" rx="8" fill="none" stroke="#fff" stroke-width="4" opacity="0.8"/>':"")+Fo("M14 30 L30 14",5,.8)+Fo("M70 88 L86 72",4,.5)}),j0={w:100,h:100,draw:({ink:e})=>`<path d="M4 20 C4 8 14 4 24 6 C36 0 56 10 64 4 C78 0 96 8 96 22 L96 80 C96 94 84 98 72 94 C60 100 44 90 30 96 C16 100 4 92 4 80Z" fill="#8edc4a" opacity="0.6" stroke="${e}" stroke-width="3"/><circle cx="28" cy="70" r="6" fill="#c6f58a" opacity="0.9"/><circle cx="72" cy="30" r="5" fill="#c6f58a" opacity="0.9"/>`},V0={w:100,h:100,draw:({ink:e})=>{let t=(r,o,n)=>`<rect x="${r-14}" y="${o-8}" width="28" height="16" rx="8" fill="none" stroke="#9aa3b0" stroke-width="7" transform="rotate(${n} ${r} ${o})"/><rect x="${r-14}" y="${o-8}" width="28" height="16" rx="8" fill="none" stroke="${e}" stroke-width="1.5" transform="rotate(${n} ${r} ${o})"/>`;return [t(18,18,45),t(36,36,45),t(64,64,45),t(82,82,45),t(82,18,-45),t(64,36,-45),t(36,64,-45),t(18,82,-45)].join("")+`<circle cx="50" cy="50" r="12" fill="#c9a14a" stroke="${e}" stroke-width="3"/><rect x="46" y="48" width="8" height="10" fill="${e}"/>`}},Jc=e=>({w:100,h:100,draw:({style:t,ink:r})=>{let o=t==="sci-fi"?"#7c86a8":t==="cozy"?"#b8a99a":"#8f8a82";return ie(he("s",[[0,Q(o,.35)],[1,V(o,.35)]]))+`<path d="M10 30 L28 8 L72 6 L92 26 L94 72 L74 94 L26 94 L6 72Z" fill="url(#s)" stroke="${r}" stroke-width="4" stroke-linejoin="round"/>`+(e?"":`<path d="M30 30 L44 50 L36 70 M60 24 L66 44 L80 54" fill="none" stroke="${V(o,.5)}" stroke-width="3.5" stroke-linecap="round"/>`)+(e?`<path d="M30 40 L70 40 M30 60 L70 60" stroke="${V(o,.4)}" stroke-width="4"/>`:"")+Fo("M20 30 L34 14",4,.45)}}),G0={w:100,h:100,draw:({ink:e,c:t})=>{let r="";for(let o=18;o<=82;o+=16)r+=`<line x1="${o}" y1="18" x2="${o}" y2="88" stroke="#b07a3a" stroke-width="5"/>`;return `<circle cx="50" cy="58" r="22" fill="${t("coin")}" stroke="${e}" stroke-width="3"/><circle cx="42" cy="54" r="4" fill="${e}"/><circle cx="58" cy="54" r="4" fill="${e}"/><path d="M44 66 Q50 71 56 66" fill="none" stroke="${e}" stroke-width="3" stroke-linecap="round"/><path d="M34 40 L30 28 L42 36Z M66 40 L70 28 L58 36Z" fill="${t("coin")}" stroke="${e}" stroke-width="2.5"/>`+r+`<rect x="10" y="10" width="80" height="10" rx="4" fill="#8a5a2a" stroke="${e}" stroke-width="3"/><rect x="10" y="86" width="80" height="10" rx="4" fill="#8a5a2a" stroke="${e}" stroke-width="3"/>`}},K0={w:100,h:100,draw:({ink:e})=>ie(he("w",[[0,"#d9a066"],[1,"#9a6236"]]))+`<rect x="8" y="8" width="84" height="84" rx="6" fill="url(#w)" stroke="${e}" stroke-width="4"/><rect x="16" y="16" width="68" height="68" fill="none" stroke="#7a4a26" stroke-width="4"/><path d="M18 18 L82 82 M82 18 L18 82" stroke="#7a4a26" stroke-width="6"/><path d="M50 30 L50 64 M38 54 L50 66 L62 54" fill="none" stroke="#fff4d0" stroke-width="7" stroke-linecap="round" stroke-linejoin="round"/>`},F0={w:100,h:100,main:"danger",draw:({main:e,ink:t})=>ie(he("h",[[0,Q(e,.45)],[1,V(e,.2)]]))+`<path d="M50 88 C20 66 8 50 8 32 C8 18 20 8 32 8 C40 8 46 12 50 20 C54 12 60 8 68 8 C80 8 92 18 92 32 C92 50 80 66 50 88Z" fill="url(#h)" stroke="${t}" stroke-width="4.5" stroke-linejoin="round"/>`+Fo("M22 30 C22 22 28 18 34 18",5,.7)},q0={w:100,h:100,main:"primary",draw:({main:e,ink:t})=>ie(he("s",[[0,Q(e,.45)],[1,V(e,.25)]]))+`<path d="M50 6 L88 18 L86 52 C84 74 68 88 50 96 C32 88 16 74 14 52 L12 18Z" fill="url(#s)" stroke="${t}" stroke-width="4.5" stroke-linejoin="round"/><path d="M50 20 L74 28 L72 52 C70 66 60 76 50 82Z" fill="${Q(e,.3)}" opacity="0.7"/>`+Fo("M24 26 L36 22",4,.7)},U0={w:100,h:100,draw:({ink:e})=>ie(Fe("f",[[0,"#fff6c0",1],[.45,"#ffb23a",1],[1,"#e0442e",1]]))+`<polygon points="${Je(50,50,46,22,10)}" fill="url(#f)" stroke="${e}" stroke-width="4" stroke-linejoin="round"/><circle cx="50" cy="50" r="12" fill="#fff6c0"/>`},X0={w:100,h:100,draw:({ink:e,c:t})=>`<path d="M40 6 L60 6 L60 40 L94 40 L94 60 L60 60 L60 94 L40 94 L40 60 L6 60 L6 40 L40 40Z" fill="${t("coin")}" stroke="${e}" stroke-width="4" stroke-linejoin="round"/><circle cx="50" cy="50" r="13" fill="#fffbe0" stroke="${e}" stroke-width="3"/>`},Z0={w:100,h:100,draw:({ink:e,c:t})=>`<path d="M20 44 C10 44 6 34 12 26 C16 18 26 18 30 22 C34 10 52 8 60 18 C70 12 86 18 86 30 C96 32 96 46 84 48Z" fill="#d8e2f0" stroke="${e}" stroke-width="4" stroke-linejoin="round"/><path d="M48 48 L36 72 L50 72 L42 96 L68 62 L54 62 L62 48Z" fill="${t("coin")}" stroke="${e}" stroke-width="3.5" stroke-linejoin="round"/>`},ed={m3_rainbow:H0,m3_row:Qc(false),m3_col:Qc(true),m3_bomb:W0,m3_ice:Yc(1),m3_ice2:Yc(2),m3_slime:j0,m3_chain:V0,m3_stone:Jc(false),m3_stone2:Jc(true),m3_cage:G0,m3_crate:K0,m3_heart:F0,m3_shield:q0,m3_skill_blast:U0,m3_skill_cross:X0,m3_skill_storm:Z0};var St=(e,t,r,o,n=.28)=>`<ellipse cx="${e}" cy="${t}" rx="${r}" ry="${o}" fill="#000" opacity="${n}"/>`,br=(e,t=4,r=.55)=>`<path d="${e}" fill="none" stroke="#fff" stroke-width="${t}" stroke-linecap="round" opacity="${r}"/>`,Yt=e=>({w:100,h:100,draw:({ink:t})=>e(t)}),qo="#e8b84a",Ln="#c9803a",Q0=e=>Yt(t=>{switch(e){case 1:{let r=[0,1,2,3].map(o=>`<ellipse cx="${44-o%2*0}" cy="${30+o*11}" rx="7" ry="5" fill="${qo}" stroke="${t}" stroke-width="2.5" transform="rotate(-30 44 ${30+o*11})"/><ellipse cx="57" cy="${30+o*11}" rx="7" ry="5" fill="${Q(qo,.1)}" stroke="${t}" stroke-width="2.5" transform="rotate(30 57 ${30+o*11})"/>`);return St(50,90,14,3)+`<path d="M50 90 L50 22" stroke="${V(qo,.3)}" stroke-width="4" stroke-linecap="round"/>`+r.join("")+`<ellipse cx="50" cy="20" rx="5" ry="8" fill="${qo}" stroke="${t}" stroke-width="2.5"/>`}case 2:return ie(he("s",[[0,"#f6ecd6"],[1,"#d6c29a"]]))+St(50,90,28,5)+`<path d="M24 40 Q22 86 30 88 L70 88 Q78 86 76 40 Q50 30 24 40Z" fill="url(#s)" stroke="${t}" stroke-width="3.5"/><path d="M28 40 Q38 22 50 30 Q62 22 72 40" fill="#f6ecd6" stroke="${t}" stroke-width="3"/><path d="M36 38 L64 38" stroke="${Ln}" stroke-width="5"/><path d="M50 52 L56 62 L50 72 L44 62Z" fill="${qo}" stroke="${t}" stroke-width="2"/><circle cx="50" cy="20" r="6" fill="#fff" opacity="0.9"/><circle cx="58" cy="16" r="4" fill="#fff" opacity="0.8"/>`;case 3:return ie(Fe("d",[[0,"#fff6e6"],[1,"#e8cfa2"]],.4,.35))+St(50,86,30,5)+`<path d="M18 70 Q14 44 36 38 Q50 30 64 38 Q86 44 82 70 Q78 84 50 84 Q22 84 18 70Z" fill="url(#d)" stroke="${t}" stroke-width="3.5"/>`+br("M30 52 Q36 44 46 42",4,.7);case 4:return ie(he("b",[[0,"#f0b25a"],[1,Ln]]))+St(50,86,32,5)+`<path d="M16 72 Q14 40 50 34 Q86 40 84 72 Q80 84 50 84 Q20 84 16 72Z" fill="url(#b)" stroke="${t}" stroke-width="3.5"/>`+[[36,50],[50,46],[64,50],[44,60],[58,60]].map(([r,o])=>`<ellipse cx="${r}" cy="${o}" rx="3" ry="1.8" fill="#fff6d6" stroke="${t}" stroke-width="1"/>`).join("")+br("M26 56 Q30 46 40 42",4,.5);case 5:return ie(he("l",[[0,"#f2bb66"],[1,V(Ln,.1)]]))+St(50,84,40,5)+`<path d="M8 66 Q8 36 50 32 Q92 36 92 66 Q92 80 50 80 Q8 80 8 66Z" fill="url(#l)" stroke="${t}" stroke-width="3.5"/>`+[26,42,58,74].map(r=>`<path d="M${r-6} 52 Q${r} 42 ${r+6} 40" stroke="${V(Ln,.35)}" stroke-width="4" fill="none" stroke-linecap="round"/>`).join("")+br("M16 60 Q18 46 30 40",4,.45);case 6:return ie(he("p",[[0,"#f4c070"],[1,Ln]]))+St(50,86,42,5)+`<path d="M8 60 L14 80 L86 80 L92 60Z" fill="#b8b8c8" stroke="${t}" stroke-width="3.5"/><ellipse cx="50" cy="58" rx="42" ry="16" fill="url(#p)" stroke="${t}" stroke-width="3.5"/><ellipse cx="50" cy="56" rx="32" ry="10" fill="#c43a5a"/>`+[-20,-7,6,19].map(r=>`<line x1="${50+r}" y1="46" x2="${50+r+6}" y2="67" stroke="${Q(Ln,.2)}" stroke-width="4"/>`).join("")+[-20,0,20].map(r=>`<line x1="20" y1="${56+r*.3}" x2="80" y2="${56+r*.3}" stroke="${Q(Ln,.2)}" stroke-width="4" opacity="0.9"/>`).join("")+`<ellipse cx="50" cy="58" rx="42" ry="16" fill="none" stroke="${t}" stroke-width="3.5"/>`;default:return ie(he("c",[[0,"#fff4f6"],[1,"#f2c6d2"]]),he("t",[[0,"#ffd6e0"],[1,"#e89ab0"]]))+St(50,94,40,4)+`<rect x="12" y="62" width="76" height="28" rx="6" fill="url(#c)" stroke="${t}" stroke-width="3.5"/><rect x="24" y="38" width="52" height="26" rx="6" fill="url(#t)" stroke="${t}" stroke-width="3.5"/><path d="M12 70 Q20 78 28 70 Q36 78 44 70 Q52 78 60 70 Q68 78 76 70 Q84 78 88 70" fill="none" stroke="#fff" stroke-width="4"/><path d="M24 46 Q32 52 40 46 Q48 52 56 46 Q64 52 76 46" fill="none" stroke="#fff" stroke-width="4"/>`+[36,50,64].map(r=>`<rect x="${r-2.5}" y="22" width="5" height="16" rx="2" fill="#7cc4ff" stroke="${t}" stroke-width="1.5"/><path d="M${r} 12 Q${r+4} 18 ${r} 21 Q${r-4} 18 ${r} 12Z" fill="#ffc83a"/>`).join("")+`<circle cx="50" cy="40" r="5" fill="#d62a3a" stroke="${t}" stroke-width="2"/>`}}),Or="#4ac8ff",Uo="#ffc83a",Xn=(e,t,r,o,n,s)=>`<path d="M${e} ${t-r} L${e+o} ${t-r*.6} L${e+o*.8} ${t} L${e-o*.8} ${t} L${e-o} ${t-r*.6}Z" fill="${n}" stroke="${s}" stroke-width="3" stroke-linejoin="round"/><path d="M${e} ${t-r} L${e} ${t}" stroke="#fff" stroke-width="2" opacity="0.6"/>`,Y0=e=>Yt(t=>{switch(e){case 1:return ie(Fe("r",[[0,"#c8ccd6"],[1,"#7a8090"]],.4,.35))+St(50,84,28,5)+`<path d="M20 70 Q16 48 34 40 Q52 30 70 42 Q86 54 78 72 Q66 84 44 82 Q24 80 20 70Z" fill="url(#r)" stroke="${t}" stroke-width="3.5"/><path d="M58 52 L66 58 L60 64Z" fill="${Or}" stroke="${t}" stroke-width="1.5"/>`+br("M30 52 Q36 44 46 42",4,.5);case 2:return St(50,88,22,4)+Xn(50,86,66,18,Or,t)+br("M44 40 L46 30",3,.7);case 3:return St(50,90,34,5)+Xn(30,88,44,13,V(Or,.15),t)+Xn(70,88,48,13,"#a88aff",t)+Xn(50,88,70,16,Or,t);case 4:return ie(he("g",[[0,Q(Or,.4)],[1,V(Or,.3)]]))+St(50,90,30,5)+`<path d="M20 38 L34 20 L66 20 L80 38 L50 86Z" fill="url(#g)" stroke="${t}" stroke-width="3.5" stroke-linejoin="round"/><path d="M20 38 L80 38 M34 20 L42 38 L50 86 L58 38 L66 20 M42 38 L50 20 L58 38" fill="none" stroke="${t}" stroke-width="2" opacity="0.7"/><path d="M28 34 L36 24" stroke="#fff" stroke-width="4" stroke-linecap="round" opacity="0.8"/>`;case 5:return St(50,90,26,4)+`<circle cx="50" cy="62" r="24" fill="none" stroke="${t}" stroke-width="13"/><circle cx="50" cy="62" r="24" fill="none" stroke="${Uo}" stroke-width="8"/><path d="M50 62 m-16 -20" stroke="#fff" stroke-width="3" opacity="0.5"/><path d="M36 32 L42 22 L58 22 L64 32 L50 48Z" fill="#ff4a8a" stroke="${t}" stroke-width="3" stroke-linejoin="round"/>`+br("M30 70 Q30 54 40 46",3,.6);case 6:return St(50,92,24,4)+`<path d="M18 16 Q20 58 50 66 Q80 58 82 16" fill="none" stroke="${t}" stroke-width="7"/><path d="M18 16 Q20 58 50 66 Q80 58 82 16" fill="none" stroke="${Uo}" stroke-width="4" stroke-dasharray="5 3"/><path d="M50 62 L64 74 L50 92 L36 74Z" fill="${Or}" stroke="${t}" stroke-width="3" stroke-linejoin="round"/><circle cx="34" cy="52" r="4" fill="#ff4a8a" stroke="${t}" stroke-width="1.5"/><circle cx="66" cy="52" r="4" fill="#ff4a8a" stroke="${t}" stroke-width="1.5"/>`+br("M44 72 L50 66",3,.7);default:return ie(he("k",[[0,Q(Uo,.3)],[1,V(Uo,.25)]]))+St(50,90,38,5)+`<path d="M12 80 L8 30 L30 50 L50 18 L70 50 L92 30 L88 80Z" fill="url(#k)" stroke="${t}" stroke-width="3.5" stroke-linejoin="round"/><rect x="12" y="72" width="76" height="12" rx="3" fill="${V(Uo,.15)}" stroke="${t}" stroke-width="3"/><circle cx="50" cy="60" r="7" fill="#ff4a8a" stroke="${t}" stroke-width="2.5"/><circle cx="30" cy="64" r="5" fill="${Or}" stroke="${t}" stroke-width="2"/><circle cx="70" cy="64" r="5" fill="${Or}" stroke="${t}" stroke-width="2"/>`+[[8,30],[50,18],[92,30]].map(([r,o])=>`<circle cx="${r}" cy="${o}" r="5" fill="#fff6c0" stroke="${t}" stroke-width="2"/>`).join("")}}),Fr="#a26bff",td="#dff2ff",J0=e=>Yt(t=>{switch(e){case 1:return St(50,90,18,4)+'<path d="M50 90 Q46 60 52 30" stroke="#3f8a3a" stroke-width="4" fill="none" stroke-linecap="round"/>'+[[52,34,-40],[49,50,210],[51,64,-30],[48,76,200]].map(([r,o,n])=>`<ellipse cx="${r+12*Math.cos(n*Math.PI/180)}" cy="${o+12*Math.sin(n*Math.PI/180)}" rx="13" ry="6" fill="#5ad35a" stroke="${t}" stroke-width="2.5" transform="rotate(${n} ${r+12*Math.cos(n*Math.PI/180)} ${o+12*Math.sin(n*Math.PI/180)})"/>`).join("");case 2:return ie(Fe("d",[[0,Q(Fr,.5)],[1,V(Fr,.2)]],.4,.55))+St(50,90,18,4)+`<path d="M50 12 Q74 46 74 62 A24 24 0 0 1 26 62 Q26 46 50 12Z" fill="url(#d)" stroke="${t}" stroke-width="3.5"/>`+br("M38 58 Q38 48 44 40",4,.7);case 3:return St(50,92,14,3)+`<rect x="38" y="12" width="24" height="8" rx="2" fill="#a8774a" stroke="${t}" stroke-width="2.5"/><path d="M40 20 L40 78 A10 10 0 0 0 60 78 L60 20Z" fill="${td}" stroke="${t}" stroke-width="3" opacity="0.95"/><path d="M41 52 L41 78 A9 9 0 0 0 59 78 L59 52Z" fill="#4ad3a0"/>`+br("M45 26 L45 72",3,.7);case 4:return St(50,92,26,4)+`<rect x="42" y="10" width="16" height="10" rx="2" fill="#a8774a" stroke="${t}" stroke-width="2.5"/><path d="M44 20 L44 40 A26 26 0 1 0 56 40 L56 20Z" fill="${td}" stroke="${t}" stroke-width="3"/><path d="M27 62 A23 23 0 0 0 73 62Z" fill="#ff6a5a"/><circle cx="44" cy="70" r="3" fill="#fff" opacity="0.7"/><circle cx="56" cy="74" r="2" fill="#fff" opacity="0.7"/>`+br("M34 52 Q32 62 36 70",3.5,.7);case 5:return ie(he("b",[[0,Q(Fr,.3)],[1,V(Fr,.3)]]))+St(50,94,26,4)+`<rect x="40" y="6" width="20" height="12" rx="3" fill="#a8774a" stroke="${t}" stroke-width="2.5"/><path d="M42 18 L42 30 Q22 38 22 60 L22 82 Q22 90 30 90 L70 90 Q78 90 78 82 L78 60 Q78 38 58 30 L58 18Z" fill="url(#b)" stroke="${t}" stroke-width="3.5"/><rect x="30" y="56" width="40" height="22" rx="4" fill="#fff6e6" stroke="${t}" stroke-width="2"/><path d="M50 74 L40 64 A5 5 0 0 1 50 60 A5 5 0 0 1 60 64Z" fill="#e8384a"/>`+br("M30 44 Q28 52 28 60",4,.6);case 6:return ie(he("k",[[0,"#5a5a6a"],[1,"#22222c"]]))+St(50,94,36,4)+[[30,30,6],[46,20,8],[62,28,5]].map(([r,o,n])=>`<circle cx="${r}" cy="${o}" r="${n}" fill="${Q("#4ad3a0",.2)}" stroke="${t}" stroke-width="2"/>`).join("")+`<ellipse cx="50" cy="44" rx="38" ry="10" fill="#4ad3a0" stroke="${t}" stroke-width="3"/><path d="M12 44 Q12 86 50 86 Q88 86 88 44Z" fill="url(#k)" stroke="${t}" stroke-width="3.5"/><path d="M26 86 L22 94 M74 86 L78 94" stroke="${t}" stroke-width="5" stroke-linecap="round"/>`+br("M20 54 Q22 68 30 76",4,.35);default:return ie(Fe("o",[[0,"#ffffff"],[.35,Q(Fr,.4)],[1,V(Fr,.35)]],.4,.35))+St(50,94,26,4)+`<path d="M28 94 L34 76 L66 76 L72 94Z" fill="#a8774a" stroke="${t}" stroke-width="3"/><circle cx="50" cy="44" r="34" fill="${Fr}" opacity="0.25"/><circle cx="50" cy="46" r="28" fill="url(#o)" stroke="${t}" stroke-width="3.5"/><polygon points="${Je(50,46,12,5,4)}" fill="#fff" opacity="0.85"/>`+[[18,20],[84,26],[80,70],[16,66]].map(([r,o])=>`<polygon points="${Je(r,o,5,2,4)}" fill="#fff6c0"/>`).join("")}}),Bs=(e,t)=>ie(he("pad",[[0,Q(e,.25)],[1,V(e,.25)]]))+`<rect x="6" y="6" width="88" height="88" rx="20" fill="url(#pad)" stroke="${t}" stroke-width="4"/><rect x="12" y="12" width="76" height="40" rx="14" fill="#fff" opacity="0.18"/>`,eh=Yt(e=>Bs("#5ab04a",e)+`<path d="M26 44 Q24 84 32 84 L68 84 Q76 84 74 44 Q50 36 26 44Z" fill="#d8b884" stroke="${e}" stroke-width="3.5"/><path d="M30 46 Q40 32 50 40 Q60 32 70 46" fill="#e8cc9a" stroke="${e}" stroke-width="3"/><path d="M50 40 Q48 26 50 18" stroke="#3f8a3a" stroke-width="4" fill="none" stroke-linecap="round"/><ellipse cx="41" cy="22" rx="9" ry="5" fill="#7fd36e" stroke="${e}" stroke-width="2.5" transform="rotate(-25 41 22)"/><ellipse cx="59" cy="20" rx="9" ry="5" fill="#7fd36e" stroke="${e}" stroke-width="2.5" transform="rotate(25 59 20)"/>`+[[42,64],[52,70],[58,60]].map(([t,r])=>`<ellipse cx="${t}" cy="${r}" rx="3" ry="4" fill="#8a5a32"/>`).join("")),th=Yt(e=>Bs("#e09a3a",e)+`<path d="M16 84 L16 50 Q16 20 50 20 Q84 20 84 50 L84 84Z" fill="#c8634a" stroke="${e}" stroke-width="3.5"/>`+[30,44,58].map(t=>`<path d="M18 ${t} L82 ${t}" stroke="${V("#c8634a",.3)}" stroke-width="2"/>`).join("")+`<path d="M30 84 L30 60 Q30 46 50 46 Q70 46 70 84Z" fill="#2a1a14" stroke="${e}" stroke-width="3"/><path d="M38 84 Q36 70 44 64 Q44 72 50 70 Q50 60 58 58 Q66 70 62 84Z" fill="#ffb03a"/><path d="M44 84 Q44 76 50 74 Q56 76 56 84Z" fill="#ffe66a"/>`),rh=Yt(e=>Bs("#4a7ad3",e)+`<path d="M14 84 L22 46 L42 28 L66 32 L84 54 L86 84Z" fill="#8a8a9a" stroke="${e}" stroke-width="3.5" stroke-linejoin="round"/><path d="M22 46 L40 56 L42 28 M40 56 L66 32 M40 56 L60 84 M66 32 L68 60 L84 54 M68 60 L60 84" fill="none" stroke="${V("#8a8a9a",.3)}" stroke-width="2"/>`+Xn(36,76,18,6,Or,e)+Xn(70,78,14,5,"#ff4a8a",e)+`<path d="M58 14 L84 26" stroke="#8a5a32" stroke-width="5" stroke-linecap="round"/><path d="M76 12 Q86 20 90 34 L82 30 Q80 22 72 18Z" fill="#c8ccd6" stroke="${e}" stroke-width="2.5"/>`),nh=Yt(e=>Bs("#8a4ad3",e)+`<rect x="16" y="20" width="68" height="66" rx="6" fill="#8a5a32" stroke="${e}" stroke-width="3.5"/><path d="M16 52 L84 52" stroke="${e}" stroke-width="3"/>`+[[30,44,"#4ad3a0"],[50,44,"#ff6a5a"],[70,44,Fr],[30,78,Fr],[50,78,"#ffc83a"],[70,78,"#4ad3a0"]].map(([t,r,o])=>`<rect x="${Number(t)-4}" y="${Number(r)-20}" width="8" height="6" fill="#d8b884"/><path d="M${Number(t)-6} ${Number(r)-14} L${Number(t)+6} ${Number(r)-14} L${Number(t)+7} ${r} L${Number(t)-7} ${r}Z" fill="${o}" stroke="${e}" stroke-width="2"/>`).join("")),rd=e=>Yt(t=>{let r="#c08a4a";return ie(he("w",[[0,Q(r,.15)],[1,V(r,.2)]]))+`<rect x="6" y="6" width="88" height="88" rx="8" fill="url(#w)" stroke="${t}" stroke-width="4"/>`+[30,50,70].map(o=>`<line x1="8" y1="${o}" x2="92" y2="${o}" stroke="${V(r,.35)}" stroke-width="2"/>`).join("")+`<path d="M14 14 L86 86 M86 14 L14 86" stroke="${V(r,.3)}" stroke-width="7"/><rect x="6" y="6" width="88" height="88" rx="8" fill="none" stroke="${t}" stroke-width="4"/>`+(e?`<rect x="6" y="22" width="88" height="10" fill="#8a96aa" stroke="${t}" stroke-width="2.5"/><rect x="6" y="68" width="88" height="10" fill="#8a96aa" stroke="${t}" stroke-width="2.5"/>`+[16,50,84].map(o=>`<circle cx="${o}" cy="27" r="2.5" fill="${t}"/><circle cx="${o}" cy="73" r="2.5" fill="${t}"/>`).join(""):"")}),oh={w:100,h:100,draw:()=>ie(Fe("f",[[0,"#ffffff"],[1,"#c8d2e0"]],.45,.4,.6))+'<rect x="2" y="2" width="96" height="96" rx="14" fill="url(#f)" opacity="0.97"/>'+[[28,34,18],[62,30,20],[44,58,22],[76,64,16],[22,70,14]].map(([e,t,r])=>`<circle cx="${e}" cy="${t}" r="${r}" fill="#ffffff" opacity="0.75"/>`).join("")+'<text x="50" y="62" font-size="30" font-family="sans-serif" font-weight="900" text-anchor="middle" fill="#8a96aa" opacity="0.8">?</text>'},sh=Yt(e=>'<g stroke="#ffffff" stroke-width="2.5" fill="none" opacity="0.9">'+[0,45,90,135].map(t=>`<line x1="${50-46*Math.cos(t*Math.PI/180)}" y1="${50-46*Math.sin(t*Math.PI/180)}" x2="${50+46*Math.cos(t*Math.PI/180)}" y2="${50+46*Math.sin(t*Math.PI/180)}"/>`).join("")+[14,28,42].map(t=>`<polygon points="${Dt(50,50,t,8,0)}"/>`).join("")+`</g><g stroke="${e}" stroke-width="1" fill="none" opacity="0.35">`+[14,28,42].map(t=>`<polygon points="${Dt(50,50,t,8,0)}"/>`).join("")+"</g>"),ah={w:100,h:100,draw:()=>ie(Fe("u",[[0,"#ffffff",0],[.75,"#9ad8ff",.25],[1,"#4ab0ff",.7]]))+'<circle cx="50" cy="50" r="46" fill="url(#u)" stroke="#ffffff" stroke-width="3" opacity="0.95"/>'+br("M24 38 Q28 24 42 18",6,.85)+'<circle cx="72" cy="72" r="4" fill="#fff" opacity="0.7"/>'},ih=Yt(e=>ie(he("j",[[0,"#ff6a8a"],[.35,"#ffc83a"],[.7,"#5ad35a"],[1,"#4aa8ff"]]))+St(50,90,26,4)+`<circle cx="50" cy="50" r="40" fill="#fff" opacity="0.25"/><polygon points="${Je(50,50,40,18,5)}" fill="url(#j)" stroke="${e}" stroke-width="3.5" stroke-linejoin="round"/><circle cx="42" cy="46" r="4" fill="${e}"/><circle cx="58" cy="46" r="4" fill="${e}"/><path d="M42 58 Q50 64 58 58" stroke="${e}" stroke-width="3" fill="none" stroke-linecap="round"/>`),lh=Yt(e=>St(50,92,22,4)+`<path d="M50 54 L26 12 L34 10 L54 48Z" fill="#d8dee8" stroke="${e}" stroke-width="3" stroke-linejoin="round"/><path d="M50 54 L74 12 L66 10 L46 48Z" fill="#eef2f8" stroke="${e}" stroke-width="3" stroke-linejoin="round"/><circle cx="34" cy="74" r="14" fill="none" stroke="${e}" stroke-width="10"/><circle cx="34" cy="74" r="14" fill="none" stroke="#e8384a" stroke-width="6"/><circle cx="66" cy="74" r="14" fill="none" stroke="${e}" stroke-width="10"/><circle cx="66" cy="74" r="14" fill="none" stroke="#e8384a" stroke-width="6"/><circle cx="50" cy="54" r="5" fill="#ffc83a" stroke="${e}" stroke-width="2"/>`),ch=Yt(e=>ie(Fe("e",[[0,"#fff6a0"],[1,"#ffb000"]],.4,.35))+`<circle cx="50" cy="50" r="44" fill="url(#e)" stroke="${e}" stroke-width="4"/><path d="M56 12 L26 56 L46 56 L40 88 L74 40 L54 40Z" fill="#fff" stroke="${e}" stroke-width="3.5" stroke-linejoin="round"/>`),dh=Yt(e=>ie(he("t",[[0,"#9aa6ba"],[1,"#5a6478"]],true))+`<rect x="36" y="8" width="28" height="10" rx="4" fill="#5a6478" stroke="${e}" stroke-width="3"/><rect x="14" y="16" width="72" height="12" rx="4" fill="#7a869a" stroke="${e}" stroke-width="3.5"/><path d="M20 30 L26 90 L74 90 L80 30Z" fill="url(#t)" stroke="${e}" stroke-width="3.5" stroke-linejoin="round"/>`+[36,50,64].map(t=>`<line x1="${t}" y1="40" x2="${t}" y2="80" stroke="${e}" stroke-width="3" stroke-linecap="round" opacity="0.6"/>`).join("")),fh=Yt(e=>`<path d="M50 10 L80 44 L62 44 L62 84 L38 84 L38 44 L20 44Z" fill="#7cf0a0" stroke="${e}" stroke-width="4" stroke-linejoin="round"/>`+[[18,20],[84,66],[16,74]].map(([t,r])=>`<polygon points="${Je(t,r,9,3.5,4)}" fill="#fff6a0" stroke="${e}" stroke-width="1.5"/>`).join("")),ph=Yt(e=>`<path d="M40 8 L16 50 L32 50 L26 90 L56 40 L40 40Z" fill="#ffd34a" stroke="${e}" stroke-width="3.5" stroke-linejoin="round"/><path d="M70 18 L52 50 L64 50 L60 82 L84 44 L72 44Z" fill="#fff6a0" stroke="${e}" stroke-width="3" stroke-linejoin="round"/>`),hh=Yt(e=>`<path d="M22 84 L64 42" stroke="${e}" stroke-width="12" stroke-linecap="round"/><path d="M22 84 L64 42" stroke="#8a5a32" stroke-width="7" stroke-linecap="round"/><polygon points="${Je(70,34,24,10,5)}" fill="#ffc83a" stroke="${e}" stroke-width="3.5" stroke-linejoin="round"/>`+[[30,22],[88,70],[52,82]].map(([t,r])=>`<polygon points="${Je(t,r,7,2.5,4)}" fill="#fff"/>`).join("")),nd={...Object.fromEntries([1,2,3,4,5,6,7].map(e=>[`mg_bake${e}`,Q0(e)])),...Object.fromEntries([1,2,3,4,5,6,7].map(e=>[`mg_jewel${e}`,Y0(e)])),...Object.fromEntries([1,2,3,4,5,6,7].map(e=>[`mg_potion${e}`,J0(e)])),mg_gen_garden:eh,mg_gen_bake:th,mg_gen_jewel:rh,mg_gen_potion:nh,mg_box:rd(false),mg_box2:rd(true),mg_fog:oh,mg_web:sh,mg_bubble:ah,mg_joker:ih,mg_scissors:lh,mg_energy:ch,mg_bin:dh,mg_sk_merge:fh,mg_sk_free:ph,mg_sk_joker:hh};var od={fantasy:{skyTop:"#3f6aa8",skyBottom:"#f4c98e",far1:"#7b8fb8",far2:"#566f94",near:"#2c5638",crust:"#6dbb45",soil:"#7a5232",deep:"#4e331e",floor:"#5f9a3e",detail:"#7ab552",road:"#a57d4f",edge:"#7a5a36",wall:"#e8d9b8",roof:"#b8483a"},"sci-fi":{skyTop:"#050816",skyBottom:"#3b1f63",far1:"#232b5c",far2:"#161c40",near:"#0e1430",crust:"#36e3ff",soil:"#2a3452",deep:"#151b30",floor:"#1b2340",detail:"#2a3762",road:"#2b3868",edge:"#36e3ff",wall:"#3a4a72",roof:"#232c4a"},cozy:{skyTop:"#8fd3ff",skyBottom:"#fff3d6",far1:"#b6e2a2",far2:"#8fcc7e",near:"#5fae5a",crust:"#8ed46f",soil:"#c98b5a",deep:"#9e6a42",floor:"#a8dc8a",detail:"#c6ecab",road:"#efc89a",edge:"#d9a676",wall:"#fff1e0",roof:"#ff8f8f"},"post-apocalypse":{skyTop:"#3b2a26",skyBottom:"#d0803e",far1:"#7a5442",far2:"#4e3a2e",near:"#2a201a",crust:"#5a5248",soil:"#6b6358",deep:"#3e3832",floor:"#5e5648",detail:"#4a4438",road:"#46423c",edge:"#2e2a26",wall:"#8a7a62",roof:"#5a3a2a"},default:{skyTop:"#25365e",skyBottom:"#7d9fd6",far1:"#4f6494",far2:"#3a4b72",near:"#283958",crust:"#5fae5a",soil:"#6b4a2e",deep:"#45301c",floor:"#3e5a46",detail:"#4b6a52",road:"#5a5f78",edge:"#454a60",wall:"#e6dccb",roof:"#5a6fae"}},dr=e=>od[e]??od.default,uh={w:100,h:200,draw({style:e}){let t=dr(e),r="";if(e==="sci-fi"){let o=Mr(7);r=Array.from({length:60},()=>`<circle cx="${U(o()*100)}" cy="${U(o()*150)}" r="${U(.3+o()*.6)}" fill="#fff" opacity="${U(.3+o()*.7)}"/>`).join("");}return ie(he("s",[[0,t.skyTop],[.75,qn(t.skyTop,t.skyBottom,.7)],[1,t.skyBottom]]))+'<rect width="100" height="200" fill="url(#s)"/>'+r}},mh={w:100,h:100,draw({style:e}){if(e==="sci-fi")return ie(he("p",[[0,"#ff9ad5"],[1,"#6a3cc8"]]),Fe("h",[[0,"#ff9ad5",.5],[1,"#ff9ad5",0]]))+'<circle cx="50" cy="50" r="48" fill="url(#h)"/><circle cx="50" cy="50" r="26" fill="url(#p)"/><ellipse cx="50" cy="52" rx="44" ry="9" fill="none" stroke="#ffd0f0" stroke-width="3" opacity="0.8" transform="rotate(-14 50 52)"/>';let t=e==="post-apocalypse"?"#ff7a3a":e==="cozy"?"#fff2a8":"#fff0c0",r=e==="post-apocalypse"?"#ff5a2a":"#fff6d0";return ie(Fe("h",[[0,r,.85],[.45,r,.35],[1,r,0]]))+`<circle cx="50" cy="50" r="50" fill="url(#h)"/><circle cx="50" cy="50" r="20" fill="${t}"/>`}},Hs=(e,t,r,o,n,s)=>{let a=Mr(e),i=Array.from({length:s},()=>o-a()*n);i.push(i[0]);let h=i.map((m,v)=>`${U(v/s*t)},${U(m)}`);return `M0 ${r} L${h.join(" L")} L${t} ${r}Z`},yh={w:512,h:200,band:true,draw({style:e}){let t=dr(e),r=qn(t.far1,t.skyBottom,.35);if(e==="sci-fi"){let h=Mr(11),m=0,v="",x="";for(;m<500;){let D=26+Math.floor(h()*40),O=50+Math.floor(h()*130),N=Math.min(D,512-m);v+=`<rect x="${m}" y="${200-O}" width="${N}" height="${O}" fill="${h()<.5?t.far1:t.far2}"/>`,h()<.3&&(v+=`<rect x="${m+N/2-1}" y="${200-O-18}" width="2" height="18" fill="${t.far1}"/><circle cx="${m+N/2}" cy="${200-O-18}" r="2" fill="#ff3d6e"/>`);for(let q=200-O+8;q<196;q+=10)for(let ne=m+4;ne<m+N-4;ne+=7)h()<.35&&(x+=`<rect x="${ne}" y="${q}" width="3" height="4" fill="${h()<.5?"#36e3ff":"#ffd36e"}" opacity="0.8"/>`);m+=N+2;}return v+x}if(e==="post-apocalypse"){let h=Mr(13),m=6,v=`<path d="${Hs(3,512,200,170,22,8)}" fill="${r}"/>`;for(;m<490;){let x=30+Math.floor(h()*36),O=200-(60+Math.floor(h()*110)),N=h()*20;v+=`<path d="M${m} 200 L${m} ${O+N} L${m+x*.3} ${O} L${m+x*.55} ${O+14+N} L${m+x} ${O+6} L${m+x} 200Z" fill="${h()<.5?t.far1:t.far2}"/>`;for(let q=O+20;q<190;q+=14)for(let ne=m+5;ne<m+x-6;ne+=10)h()<.5&&(v+=`<rect x="${ne}" y="${q}" width="4" height="6" fill="${t.near}" opacity="0.7"/>`);m+=x+8+Math.floor(h()*20);}return v+'<ellipse cx="380" cy="60" rx="60" ry="14" fill="#2a1a14" opacity="0.25"/>'}if(e==="cozy"){let h=[80,230,400].map((m,v)=>`<rect x="${m}" y="${132-v*6}" width="22" height="18" fill="#fff4e8"/><polygon points="${m-3},${133-v*6} ${m+11},${120-v*6} ${m+25},${133-v*6}" fill="${["#ff8f8f","#8fb8ff","#ffb86b"][v]}"/><rect x="${m+8}" y="${140-v*6}" width="6" height="10" fill="#c98b5a"/>`).join("");return `<path d="${Hs(5,512,200,140,30,6)}" fill="${t.far1}"/>`+h+`<path d="${Hs(9,512,200,168,22,5)}" fill="${t.far2}"/>`+[40,170,300,460].map(m=>`<circle cx="${m}" cy="158" r="12" fill="${V(t.far2,.12)}"/>`).join("")}let o=Mr(17),n=[],s=[],a=(h,m)=>{n.push(`M${U(h-110)} 200 L${U(h)} ${U(m)} L${U(h+110)} 200Z`),s.push(`M${U(h-24)} ${U(m+26)} L${U(h)} ${U(m)} L${U(h+24)} ${U(m+26)} L${U(h+10)} ${U(m+20)} L${U(h)} ${U(m+28)} L${U(h-10)} ${U(m+20)}Z`);};for(let h=0;h<4;h++){let m=64+h*128+(o()-.5)*30,v=30+o()*40;a(m,v),m-110<0&&a(m+512,v),m+110>512&&a(m-512,v);}let i=e==="fantasy"?`<g fill="${V(t.far2,.15)}"><rect x="300" y="120" width="40" height="80"/><rect x="292" y="104" width="14" height="96"/><rect x="334" y="100" width="14" height="100"/><polygon points="290,104 299,84 308,104"/><polygon points="332,100 341,78 350,100"/>${[300,310,320,330].map(h=>`<rect x="${h}" y="114" width="6" height="8"/>`).join("")}</g><rect x="340" y="82" width="10" height="6" fill="#d0483b"/>`:"";return `<path d="${n.join(" ")}" fill="${r}"/><path d="${s.join(" ")}" fill="#f4f6ff" opacity="0.85"/><path d="${Hs(21,512,200,160,40,9)}" fill="${t.far2}"/>`+i}},gh={w:512,h:160,band:true,draw({style:e}){let t=dr(e),r=Mr(29),o=`<rect x="0" y="146" width="512" height="14" fill="${t.near}"/>`;if(e==="sci-fi"){let s=o;for(let a=30;a<500;a+=90+Math.floor(r()*40)){let i=60+r()*70;s+=`<rect x="${a}" y="${150-i}" width="8" height="${i}" fill="${t.near}"/><rect x="${a-14}" y="${150-i}" width="36" height="5" fill="${t.near}"/><circle cx="${a+4}" cy="${146-i}" r="3" fill="#36e3ff"/>`;}return s+=`<path d="M180 150 A40 40 0 0 1 260 150Z" fill="${t.near}"/><path d="M200 140 A22 22 0 0 1 240 140" stroke="#36e3ff" stroke-width="2" fill="none" opacity="0.7"/>`,s}if(e==="post-apocalypse"){let s=o,a=(i,h)=>`<path d="M${i} 150 L${i+3} ${150-h} M${i+2} ${150-h*.6} L${i-14} ${150-h*.85} M${i+2} ${150-h*.45} L${i+18} ${150-h*.7} M${i+3} ${150-h*.8} L${i+12} ${150-h}" stroke="${t.near}" stroke-width="5" stroke-linecap="round" fill="none"/>`;return s+=a(40,90)+a(300,110)+a(460,70),s+=`<rect x="150" y="18" width="5" height="132" fill="${t.near}"/><rect x="138" y="28" width="30" height="4" fill="${t.near}"/><path d="M0 34 Q75 54 152 30 Q260 58 360 34 Q440 50 512 34" stroke="${t.near}" stroke-width="1.5" fill="none"/>`,s+=`<path d="M180 150 L188 128 L232 124 L246 136 L262 138 L262 150Z" fill="${t.near}"/><circle cx="198" cy="150" r="8" fill="#1a120c"/><circle cx="246" cy="150" r="8" fill="#1a120c"/>`,s}if(e==="cozy"){let s=o;for(let a=20;a<500;a+=100+Math.floor(r()*30)){let i=50+r()*30;s+=`<rect x="${a+16}" y="${150-i*.5}" width="8" height="${i*.5}" fill="#9e6a42"/><circle cx="${a+20}" cy="${150-i*.6}" r="${i*.36}" fill="${t.near}"/><circle cx="${a+12}" cy="${150-i*.7}" r="${i*.12}" fill="${Q(t.near,.25)}"/>`;}for(let a=4;a<512;a+=16)s+=`<rect x="${a}" y="128" width="8" height="22" rx="3" fill="#fff8f0"/>`;return s+='<rect x="0" y="134" width="512" height="4" fill="#fff8f0"/>',s}let n=o;for(let s=14;s<500;s+=44+Math.floor(r()*50)){let a=70+r()*60,i=a*.36;n+=`<rect x="${s-3}" y="${150-a*.18}" width="6" height="${a*.18}" fill="${V(t.near,.3)}"/>`;for(let h=0;h<3;h++){let m=150-a*.15-h*a*.26,v=i*(1-h*.25);n+=`<polygon points="${U(s-v)},${U(m)} ${U(s)},${U(m-a*.42)} ${U(s+v)},${U(m)}" fill="${h===2?Q(t.near,.08):t.near}"/>`;}}return n}};function sd(e,t){let r=dr(e.style);if(e.style==="sci-fi")return `<rect x="0" y="0" width="${t}" height="16" fill="#3a4a72"/><rect x="0" y="0" width="${t}" height="4" fill="${e.c("primary")}"/><rect x="0" y="14" width="${t}" height="3" fill="#11172a"/>`+[16,48,80,112].filter(n=>n<t).map(n=>`<rect x="${n}" y="6" width="14" height="4" rx="2" fill="${e.c("primary")}" opacity="0.5"/>`).join("");if(e.style==="post-apocalypse")return `<path d="M0 0 L${t} 0 L${t} 14 L${t*.8} 18 L${t*.62} 12 L${t*.4} 20 L${t*.2} 13 L0 16Z" fill="#3a3530"/><path d="M${t*.15} 4 L${t*.3} 8 M${t*.6} 3 L${t*.75} 9" stroke="#24201c" stroke-width="2"/>`;if(e.style==="cozy"){let n="";for(let s=0;s<t;s+=32)n+=`<circle cx="${s+16}" cy="14" r="16" fill="${r.crust}"/>`;return `<rect x="0" y="0" width="${t}" height="14" fill="${r.crust}"/>${n}<circle cx="${t*.3}" cy="8" r="3" fill="#fff"/><circle cx="${t*.75}" cy="10" r="3" fill="#ff8fab"/>`}let o="";for(let n=2;n<t;n+=8)o+=`<polygon points="${n},12 ${n+3},${2+n*7%5} ${n+6},12" fill="${Q(r.crust,.15)}"/>`;return `<rect x="0" y="6" width="${t}" height="16" fill="${r.crust}"/>${o}<rect x="0" y="20" width="${t}" height="4" fill="${V(r.crust,.3)}"/>`}var bh={w:128,h:512,draw(e){let t=dr(e.style),r=Mr(41),o="";for(let n=0;n<14;n++)o+=`<ellipse cx="${U(8+r()*112)}" cy="${U(40+r()*460)}" rx="${U(4+r()*7)}" ry="${U(3+r()*4)}" fill="${V(t.soil,.2+r()*.15)}"/>`;return e.style==="sci-fi"&&(o=[80,180,280,380].map(n=>`<rect x="0" y="${n}" width="128" height="2" fill="#11172a"/>`).join("")+'<rect x="62" y="20" width="2" height="492" fill="#11172a"/>'+[100,300].map(n=>`<circle cx="20" cy="${n}" r="3" fill="#4a5a88"/><circle cx="108" cy="${n}" r="3" fill="#4a5a88"/>`).join("")),ie(he("d",[[0,t.soil],[1,t.deep]]))+'<rect width="128" height="512" fill="url(#d)"/>'+o+sd(e,128)}},xh={w:128,h:40,draw(e){let t=dr(e.style);return ie(he("d",[[0,t.soil],[1,t.deep]]))+'<path d="M0 10 L128 10 L128 26 Q96 40 64 36 Q32 40 0 26Z" fill="url(#d)"/>'+sd(e,128)+`<path d="M0 26 Q32 40 64 36 Q96 40 128 26" stroke="${e.ink}" stroke-width="2.5" fill="none" opacity="0.5"/>`}},kh={w:128,h:100,draw(e){let t=dr(e.style);if(e.style==="sci-fi")return `<rect width="128" height="100" fill="${t.road}"/><rect y="0" width="128" height="5" fill="${e.c("primary")}" opacity="0.8"/><rect y="95" width="128" height="5" fill="${e.c("primary")}" opacity="0.8"/><path d="M40 38 L58 50 L40 62 M74 38 L92 50 L74 62" stroke="${e.c("primary")}" stroke-width="5" fill="none" opacity="0.35"/>`;if(e.style==="cozy"){let s="";for(let a=0;a<5;a++)for(let i=a%2*-16;i<128;i+=32)s+=`<rect x="${i+1}" y="${a*20+1}" width="30" height="18" rx="4" fill="${a%2?t.road:Q(t.road,.08)}" stroke="${t.edge}" stroke-width="2"/>`;return `<rect width="128" height="100" fill="${t.edge}"/>${s}`}let r=Mr(53),o="";for(let s=0;s<12;s++)o+=`<ellipse cx="${U(r()*128)}" cy="${U(10+r()*80)}" rx="${U(2+r()*3)}" ry="${U(1.5+r()*2)}" fill="${V(t.road,.25)}"/>`;let n=e.style==="post-apocalypse"?'<rect x="20" y="47" width="40" height="6" fill="#c9a43a" opacity="0.75"/><path d="M80 20 L96 36 L90 52" stroke="#2a2622" stroke-width="2" fill="none"/>':"";return `<rect width="128" height="100" fill="${t.road}"/><rect width="128" height="6" fill="${t.edge}"/><rect y="94" width="128" height="6" fill="${t.edge}"/>${o}${n}`}},vh={w:128,h:128,draw({style:e}){let t=dr(e),r=Mr(61),o="";if(e==="sci-fi")o=`<rect x="2" y="2" width="60" height="60" rx="4" fill="${t.detail}"/><rect x="66" y="66" width="60" height="60" rx="4" fill="${t.detail}"/><rect x="66" y="2" width="60" height="60" rx="4" fill="${Q(t.floor,.05)}"/><rect x="2" y="66" width="60" height="60" rx="4" fill="${Q(t.floor,.05)}"/><rect x="62" y="0" width="4" height="128" fill="#36e3ff" opacity="0.18"/><rect x="0" y="62" width="128" height="4" fill="#36e3ff" opacity="0.18"/>`;else if(e==="post-apocalypse")o=`<path d="M10 20 L40 44 L36 70 L60 96 M80 10 L92 40 L120 52 M70 80 L100 110" stroke="${t.detail}" stroke-width="2.5" fill="none"/>`;else for(let n=0;n<18;n++){let s=6+r()*116,a=6+r()*116;o+=`<path d="M${U(s)} ${U(a)} l-3 -6 M${U(s)} ${U(a)} l0 -7 M${U(s)} ${U(a)} l3 -6" stroke="${t.detail}" stroke-width="2" stroke-linecap="round"/>`,e==="cozy"&&n%5===0&&(o+=`<circle cx="${U(s+6)}" cy="${U(a)}" r="2.5" fill="${["#fff","#ff8fab","#ffd166"][n%3]}"/>`);}return `<rect width="128" height="128" fill="${t.floor}"/>${o}`}},$h=e=>({w:64,h:64,draw({style:t,ink:r}){let o=dr(t),n='<ellipse cx="32" cy="50" rx="20" ry="6" fill="#000" opacity="0.22"/>';if(t==="sci-fi"){let i=[`<rect x="14" y="16" width="36" height="32" rx="4" fill="#4a5a80" stroke="${r}" stroke-width="3"/><rect x="20" y="24" width="24" height="5" fill="#36e3ff"/>`,`<circle cx="32" cy="32" r="16" fill="#2a3452" stroke="${r}" stroke-width="3"/>${[0,1,2,3].map(h=>`<rect x="22" y="${23+h*5}" width="20" height="2" fill="#11172a"/>`).join("")}`,`<rect x="6" y="28" width="52" height="10" rx="5" fill="#5d6f96" stroke="${r}" stroke-width="3"/><circle cx="18" cy="33" r="3" fill="#ff3d6e"/>`,'<circle cx="32" cy="32" r="8" fill="#b45cff"/><circle cx="32" cy="32" r="14" fill="none" stroke="#b45cff" stroke-width="2" opacity="0.5"/>'];return n+i[(e-1)%4]}if(t==="post-apocalypse"){let i=[`<circle cx="32" cy="32" r="18" fill="#1e1a16" stroke="${r}" stroke-width="3"/><circle cx="32" cy="32" r="8" fill="${o.floor}"/>`,`<circle cx="32" cy="32" r="16" fill="#8a3d24" stroke="${r}" stroke-width="3"/><circle cx="32" cy="32" r="10" fill="none" stroke="#5a2814" stroke-width="2"/>`,`<polygon points="10,40 22,22 38,30 52,18 54,44 30,48" fill="#6b6358" stroke="${r}" stroke-width="3" stroke-linejoin="round"/>`,'<path d="M20 44 L24 20 M32 46 L32 16 M42 44 L38 22" stroke="#7a6a3a" stroke-width="3" stroke-linecap="round"/>'];return n+i[(e-1)%4]}let s=t==="cozy"?"#6fc46a":"#3f7f3a",a=[`<circle cx="22" cy="34" r="12" fill="${s}" stroke="${r}" stroke-width="3"/><circle cx="42" cy="34" r="12" fill="${s}" stroke="${r}" stroke-width="3"/><circle cx="32" cy="24" r="13" fill="${Q(s,.1)}" stroke="${r}" stroke-width="3"/>`,`<path d="M12 44 Q14 22 32 20 Q50 22 52 44Z" fill="#9aa0a8" stroke="${r}" stroke-width="3"/><path d="M22 28 Q30 24 36 26" stroke="#fff" stroke-width="3" opacity="0.5" fill="none"/>`,[[22,28],[40,24],[32,40],[46,40]].map(([i,h],m)=>`<polygon points="${Je(i,h,7,3,5)}" fill="${["#ff8fab","#ffd166","#fff","#c39bff"][m]}" stroke="${r}" stroke-width="1.5"/>`).join(""),t==="cozy"?`<rect x="28" y="30" width="8" height="16" fill="#fff4e6" stroke="${r}" stroke-width="2.5"/><path d="M14 32 Q32 8 50 32Z" fill="#ff6b6b" stroke="${r}" stroke-width="3"/><circle cx="26" cy="24" r="3" fill="#fff"/><circle cx="38" cy="26" r="2.5" fill="#fff"/>`:`<ellipse cx="32" cy="38" rx="16" ry="9" fill="#8a5a32" stroke="${r}" stroke-width="3"/><ellipse cx="32" cy="34" rx="16" ry="9" fill="#c49a6a" stroke="${r}" stroke-width="3"/><ellipse cx="32" cy="34" rx="8" ry="4" fill="none" stroke="#8a5a32" stroke-width="2"/>`];return n+a[(e-1)%4]}}),Mh={w:0,h:0,exact:true,main:"ground",draw({style:e,w:t,h:r}){let o=dr(e),n=Mr(Math.round(t*13+r)),s="";for(let a=0;a<4;a++){let i=t*(.15+n()*.7),h=r*(.2+n()*.65);s+=e==="sci-fi"?`<circle cx="${U(i)}" cy="${U(h)}" r="${U(t*.02)}" fill="#4a5a88"/>`:`<path d="M${U(i)} ${U(h)} l${U(-t*.04)} ${U(-r*.08)} M${U(i)} ${U(h)} l0 ${U(-r*.1)} M${U(i)} ${U(h)} l${U(t*.04)} ${U(-r*.08)}" stroke="${o.detail}" stroke-width="${U(t*.025)}" stroke-linecap="round"/>`;}return `<rect width="${t}" height="${r}" fill="${o.floor}"/><rect x="0.5" y="0.5" width="${t-1}" height="${r-1}" fill="none" stroke="${V(o.floor,.25)}" stroke-opacity="0.35" stroke-width="1"/>${s}`}},wh={w:0,h:0,exact:true,main:"lane",draw({style:e,w:t,h:r,c:o}){let n=dr(e),s=Mr(Math.round(t*7+r*3)),a="";for(let h=0;h<5;h++)a+=`<ellipse cx="${U(t*(.15+s()*.7))}" cy="${U(r*(.15+s()*.7))}" rx="${U(t*(.04+s()*.05))}" ry="${U(r*.035)}" fill="${V(n.road,.18)}"/>`;let i=e==="sci-fi"?`<rect x="${U(t*.42)}" y="${U(r*.42)}" width="${U(t*.16)}" height="${U(r*.16)}" rx="2" fill="${o("primary")}" opacity="0.45"/>`:"";return `<rect width="${t}" height="${r}" fill="${n.road}"/>${a}${i}`}},Eh=e=>({w:100,h:130,main:"primary",draw({style:t,ink:r,main:o,c:n}){let s='<ellipse cx="50" cy="122" rx="38" ry="8" fill="#000" opacity="0.28"/>';if(t==="sci-fi"||t==="post-apocalypse"){let O=t==="sci-fi"?"#5d6f96":"#7a6a52",N=t==="sci-fi"?o:n("coin"),q=Array.from({length:e},(Z,ye)=>`<rect x="50" y="${52-(e-1)*5+ye*10}" width="${36+e*2}" height="8" rx="3" fill="${V(O,.25)}" stroke="${r}" stroke-width="2.5"/>`).join(""),ne=t==="post-apocalypse"?[0,1,2].map(Z=>`<ellipse cx="${26+Z*24}" cy="106" rx="14" ry="9" fill="#a89070" stroke="${r}" stroke-width="2.5"/>`).join("")+[0,1].map(Z=>`<ellipse cx="${38+Z*24}" cy="94" rx="14" ry="9" fill="#b8a080" stroke="${r}" stroke-width="2.5"/>`).join(""):`<polygon points="${Dt(50,100,34,6,0)}" fill="#2a3452" stroke="${r}" stroke-width="3.5"/><polygon points="${Dt(50,100,22,6,0)}" fill="${N}" opacity="0.4"/>`;return s+ne+`<rect x="38" y="64" width="24" height="30" fill="${O}" stroke="${r}" stroke-width="3"/>`+q+`<path d="M24 68 A26 26 0 0 1 76 68Z" fill="${Q(O,.15)}" stroke="${r}" stroke-width="3.5"/><circle cx="50" cy="56" r="${5+e}" fill="${N}" stroke="${r}" stroke-width="2.5"/>`}let a=t==="cozy"?"#f4e6d4":"#a7a9b2",i=t==="cozy"?n("primary"):o,h=70-e*14,m="";for(let O=h+10;O<112;O+=12)m+=`<line x1="26" y1="${O}" x2="74" y2="${O}" stroke="${V(a,.25)}" stroke-width="2"/>`+[0,1].map(N=>`<line x1="${36+N*16+O/12%2*8}" y1="${O}" x2="${36+N*16+O/12%2*8}" y2="${O+12}" stroke="${V(a,.25)}" stroke-width="2"/>`).join("");let v=[26,40,54,68].map(O=>`<rect x="${O}" y="${h-10}" width="8" height="12" fill="${a}" stroke="${r}" stroke-width="2.5"/>`).join(""),x=e>=2?`<polygon points="20,${h-2} 50,${h-44} 80,${h-2}" fill="${i}" stroke="${r}" stroke-width="3.5" stroke-linejoin="round"/><polygon points="20,${h-2} 50,${h-44} 40,${h-2}" fill="${Q(i,.2)}"/>`:v,D=e>=3?`<line x1="50" y1="${h-44}" x2="50" y2="${h-64}" stroke="${r}" stroke-width="3"/><path d="M50 ${h-64} L70 ${h-58} L50 ${h-52}Z" fill="${n("coin")}" stroke="${r}" stroke-width="2"/>`:"";return s+ie(he("s",[[0,Q(a,.2)],[1,V(a,.2)]],true))+`<rect x="24" y="${h}" width="52" height="${116-h}" fill="url(#s)" stroke="${r}" stroke-width="3.5"/>`+m+`<rect x="44" y="${h+16}" width="12" height="18" rx="6" fill="#2a2030" stroke="${r}" stroke-width="2.5"/><path d="M42 116 L42 100 A8 8 0 0 1 58 100 L58 116Z" fill="#6a4628" stroke="${r}" stroke-width="2.5"/>`+x+D}}),Sh=e=>({w:120,h:120,main:`piece${e}`,draw({style:t,ink:r,main:o,c:n}){let s=dr(t),a=t==="cozy"?Q(o,.6):s.wall,i=t==="sci-fi"?n("primary"):t==="post-apocalypse"?"#3a3530":"#9fd2f0",h=(x,D,O=12,N=14)=>`<rect x="${x}" y="${D}" width="${O}" height="${N}" rx="2" fill="${i}" stroke="${r}" stroke-width="2"/>`+(t==="post-apocalypse"?`<path d="M${x} ${D+3} L${x+O} ${D+N-3}" stroke="#8a6a3a" stroke-width="3"/>`:`<rect x="${x+2}" y="${D+2}" width="${O*.3}" height="${N*.4}" fill="#fff" opacity="0.5"/>`),m='<ellipse cx="60" cy="114" rx="50" ry="6" fill="#000" opacity="0.25"/>',v=(x,D,O)=>{let N="";for(let q=0;q<O;q+=12)N+=`<path d="M${x+q} ${D} h12 v10 q-6 6 -12 0Z" fill="${q/12%2?"#fff":o}" stroke="${r}" stroke-width="2"/>`;return N};switch(e){case 1:return m+`<rect x="22" y="64" width="76" height="46" fill="${a}" stroke="${r}" stroke-width="3"/><rect x="16" y="60" width="88" height="8" fill="${V(a,.2)}" stroke="${r}" stroke-width="3"/><rect x="28" y="30" width="4" height="34" fill="${r}"/><rect x="88" y="30" width="4" height="34" fill="${r}"/>`+v(22,24,76)+`<circle cx="44" cy="56" r="6" fill="${n("coin")}" stroke="${r}" stroke-width="2"/><circle cx="60" cy="54" r="7" fill="${o}" stroke="${r}" stroke-width="2"/><circle cx="76" cy="56" r="6" fill="${n("accent")}" stroke="${r}" stroke-width="2"/>`;case 2:return m+`<rect x="18" y="40" width="84" height="70" fill="${a}" stroke="${r}" stroke-width="3"/><polygon points="12,42 60,14 108,42" fill="${s.roof}" stroke="${r}" stroke-width="3" stroke-linejoin="round"/>`+v(22,54,76)+h(28,72,28,24)+`<rect x="68" y="72" width="22" height="38" fill="${V(o,.2)}" stroke="${r}" stroke-width="3"/>`;case 3:return m+`<rect x="20" y="26" width="80" height="84" fill="${a}" stroke="${r}" stroke-width="3"/><rect x="14" y="18" width="92" height="10" fill="${s.roof}" stroke="${r}" stroke-width="3"/>`+h(30,36)+h(54,36)+h(78,36)+v(20,62,80)+h(30,78,26,22)+`<rect x="66" y="78" width="22" height="32" fill="${V(o,.25)}" stroke="${r}" stroke-width="3"/><rect x="42" y="4" width="36" height="16" rx="4" fill="${o}" stroke="${r}" stroke-width="2.5"/><path d="M54 8 h10 v6 a4 4 0 0 1 -10 0Z" fill="#fff"/>`;case 4:return m+`<rect x="80" y="14" width="12" height="40" fill="${V(s.wall,.35)}" stroke="${r}" stroke-width="3"/><circle cx="90" cy="8" r="7" fill="#cfcfd8" opacity="0.75"/><circle cx="100" cy="2" r="5" fill="#cfcfd8" opacity="0.5"/><path d="M12 110 L12 50 L36 36 L36 50 L60 36 L60 50 L84 36 L84 50 L108 50 L108 110Z" fill="${V(a,.08)}" stroke="${r}" stroke-width="3" stroke-linejoin="round"/>`+h(22,62)+h(46,62)+h(70,62)+`<rect x="40" y="84" width="40" height="26" fill="${o}" stroke="${r}" stroke-width="3"/>`+[0,1,2].map(x=>`<line x1="40" y1="${90+x*7}" x2="80" y2="${90+x*7}" stroke="${V(o,.35)}" stroke-width="2"/>`).join("");case 5:return m+`<polygon points="8,42 60,12 112,42" fill="${Q(s.wall,.15)}" stroke="${r}" stroke-width="3" stroke-linejoin="round"/><circle cx="60" cy="32" r="8" fill="${n("coin")}" stroke="${r}" stroke-width="2.5"/><rect x="14" y="42" width="92" height="8" fill="${V(s.wall,.1)}" stroke="${r}" stroke-width="3"/>`+[20,40,72,92].map(x=>`<rect x="${x}" y="50" width="8" height="52" fill="${Q(s.wall,.2)}" stroke="${r}" stroke-width="2.5"/>`).join("")+`<rect x="50" y="62" width="20" height="40" fill="${o}" stroke="${r}" stroke-width="3"/><rect x="10" y="102" width="100" height="8" fill="${V(s.wall,.15)}" stroke="${r}" stroke-width="3"/>`;default:{let x="";for(let D=22;D<92;D+=18)x+=h(40,D,12,12)+h(62,D,12,12);return m+`<rect x="58" y="2" width="3" height="14" fill="${r}"/><circle cx="59.5" cy="2" r="3" fill="${n("danger")}"/><rect x="32" y="14" width="56" height="96" fill="${t==="cozy"?a:qn(s.wall,o,.25)}" stroke="${r}" stroke-width="3"/>`+x+`<rect x="50" y="94" width="20" height="16" fill="${V(o,.25)}" stroke="${r}" stroke-width="2.5"/>`}}}}),ad={sky:uh,sun:mh,far:yh,near:gh,ground:bh,platform:xh,road:kh,floor:vh,tile_grass:Mh,tile_road:wh,...Object.fromEntries([1,2,3,4].map(e=>[`decor${e}`,$h(e)])),...Object.fromEntries([1,2,3].map(e=>[`tower${e}`,Eh(e)])),...Object.fromEntries([1,2,3,4,5,6].map(e=>[`biz${e}`,Sh(e)]))};var Xo=(e,t,r,o,n=.28)=>`<ellipse cx="${e}" cy="${t}" rx="${r}" ry="${o}" fill="#000" opacity="${n}"/>`,Hi=(e,t=4,r=.55)=>`<path d="${e}" fill="none" stroke="#fff" stroke-width="${t}" stroke-linecap="round" opacity="${r}"/>`,qr=e=>({w:100,h:100,draw:({ink:t})=>e(t)}),Lh={w:120,h:120,main:"danger",draw({style:e,ink:t,main:r,c:o}){let n=dr(e),s=Array.from({length:9},(a,i)=>`<circle cx="${24+i*9}" cy="30" r="2.6" fill="${o("coin")}" stroke="${t}" stroke-width="1"/>`).join("");return Xo(60,114,50,6,.25)+`<rect x="14" y="40" width="92" height="70" fill="${n.wall}" stroke="${t}" stroke-width="3"/><rect x="10" y="18" width="100" height="24" rx="4" fill="${r}" stroke="${t}" stroke-width="3"/>`+s+`<rect x="34" y="46" width="52" height="22" rx="3" fill="${V(n.wall,.6)}" stroke="${t}" stroke-width="2.5"/><polygon points="54,51 54,63 66,57" fill="${o("coin")}"/><rect x="24" y="76" width="30" height="34" fill="${V(r,.25)}" stroke="${t}" stroke-width="3"/><rect x="66" y="76" width="30" height="34" fill="${V(r,.25)}" stroke="${t}" stroke-width="3"/><line x1="39" y1="76" x2="39" y2="110" stroke="${t}" stroke-width="2"/><line x1="81" y1="76" x2="81" y2="110" stroke="${t}" stroke-width="2"/><polygon points="${Je(60,9,8,3.5)}" fill="${o("coin")}" stroke="${t}" stroke-width="2"/>`}},_h={w:120,h:120,main:"primary",draw({style:e,ink:t,main:r,c:o}){let n=dr(e);return Xo(60,114,52,6,.25)+`<path d="M8 110 L8 84 Q60 62 112 84 L112 110Z" fill="${n.wall}" stroke="${t}" stroke-width="3" stroke-linejoin="round"/><rect x="16" y="90" width="14" height="10" rx="2" fill="#9fd2f0" stroke="${t}" stroke-width="2"/><rect x="90" y="90" width="14" height="10" rx="2" fill="#9fd2f0" stroke="${t}" stroke-width="2"/><rect x="78" y="22" width="6" height="66" fill="${V(n.wall,.35)}" stroke="${t}" stroke-width="2.5"/>`+[34,50,66].map(s=>`<line x1="84" y1="${s}" x2="70" y2="${s}" stroke="${t}" stroke-width="2.5"/>`).join("")+`<path d="M60 6 Q72 22 70 64 L50 64 Q48 22 60 6Z" fill="${Q(r,.75)}" stroke="${t}" stroke-width="3" stroke-linejoin="round"/><circle cx="60" cy="34" r="6" fill="#9fd2f0" stroke="${t}" stroke-width="2.5"/><path d="M50 52 L40 70 L50 66Z M70 52 L80 70 L70 66Z" fill="${r}" stroke="${t}" stroke-width="2.5" stroke-linejoin="round"/><path d="M54 64 L60 82 L66 64Z" fill="${o("coin")}" stroke="${t}" stroke-width="2"/><path d="M57 64 L60 74 L63 64Z" fill="#fff"/>`}},id=(e,t)=>qr(r=>`<circle cx="50" cy="50" r="44" fill="${Q(e,.7)}" stroke="${r}" stroke-width="4"/><path d="M50 12 L76 40 L60 40 L60 62 L40 62 L40 40 L24 40Z" fill="${e}" stroke="${r}" stroke-width="3.5" stroke-linejoin="round"/><text x="50" y="88" text-anchor="middle" font-family="Arial, sans-serif" font-weight="900" font-size="24" fill="${r}">${t}</text>`),Rh=qr(e=>`<circle cx="50" cy="50" r="44" fill="#ffe8a8" stroke="${e}" stroke-width="4"/>`+[30,50,70].map((t,r)=>`<path d="M${t} ${16+(r===1?0:8)} L${t+13} ${32+(r===1?0:8)} L${t+6} ${32+(r===1?0:8)} L${t+6} 56 L${t-6} 56 L${t-6} ${32+(r===1?0:8)} L${t-13} ${32+(r===1?0:8)}Z" fill="#ffb21a" stroke="${e}" stroke-width="2.5" stroke-linejoin="round"/>`).join("")+`<text x="50" y="88" text-anchor="middle" font-family="Arial, sans-serif" font-weight="900" font-size="24" fill="${e}">\xD72</text>`),Ah=qr(e=>ie(Fe("r",[[0,"#fff6a0"],[1,"#ff7a1a"]],.5,.6))+`<path d="M50 8 Q70 30 66 46 Q78 40 76 26 Q92 46 86 66 Q80 90 50 92 Q20 90 14 66 Q10 46 26 30 Q28 46 38 48 Q30 26 50 8Z" fill="url(#r)" stroke="${e}" stroke-width="3.5" stroke-linejoin="round"/><text x="50" y="76" text-anchor="middle" font-family="Arial, sans-serif" font-weight="900" font-size="30" fill="#fff" stroke="${e}" stroke-width="2">\xD73</text>`),Th=qr(e=>Xo(50,92,24,4)+`<path d="M30 80 L62 46" stroke="${e}" stroke-width="16" stroke-linecap="round"/><path d="M30 80 L62 46" stroke="#a8b2c2" stroke-width="10" stroke-linecap="round"/><path d="M58 24 A20 20 0 1 0 80 50 L70 50 L62 42 L62 30Z" fill="#c8d0dc" stroke="${e}" stroke-width="3.5" stroke-linejoin="round"/>`+Hi("M66 22 Q76 24 80 32",3,.7)+`<circle cx="26" cy="22" r="10" fill="#e8384a" stroke="${e}" stroke-width="3"/><path d="M26 15 L26 23 M26 27 L26 28" stroke="#fff" stroke-width="3.5" stroke-linecap="round"/>`),Dh=qr(e=>ie(he("c",[[0,"#8a5a32"],[1,"#5a381c"]]))+Xo(50,90,34,5)+`<path d="M38 26 L38 18 Q38 14 42 14 L58 14 Q62 14 62 18 L62 26" fill="none" stroke="${e}" stroke-width="5"/><rect x="12" y="26" width="76" height="56" rx="8" fill="url(#c)" stroke="${e}" stroke-width="4"/><line x1="12" y1="46" x2="88" y2="46" stroke="${e}" stroke-width="3"/><rect x="44" y="40" width="12" height="12" rx="2" fill="#ffc83a" stroke="${e}" stroke-width="2.5"/><text x="50" y="74" text-anchor="middle" font-family="Arial, sans-serif" font-weight="900" font-size="20" fill="#ffd34a">$</text>`+Hi("M20 32 L40 32",3,.5)),Oh=qr(e=>`<circle cx="50" cy="50" r="44" fill="#d8ecff" stroke="${e}" stroke-width="4"/><circle cx="50" cy="36" r="14" fill="#f4c9a0" stroke="${e}" stroke-width="3"/><path d="M36 30 Q50 14 64 30 Q60 22 50 22 Q40 22 36 30Z" fill="#5a381c" stroke="${e}" stroke-width="2"/><path d="M22 86 Q22 56 50 54 Q78 56 78 86Z" fill="#3a4a72" stroke="${e}" stroke-width="3" stroke-linejoin="round"/><path d="M46 56 L54 56 L56 76 L50 82 L44 76Z" fill="#e8384a" stroke="${e}" stroke-width="2" stroke-linejoin="round"/>`),Ch=qr(e=>`<circle cx="48" cy="54" r="34" fill="#fff" stroke="${e}" stroke-width="4"/><path d="M48 54 L48 32 M48 54 L64 62" stroke="${e}" stroke-width="5" stroke-linecap="round"/><path d="M74 10 Q86 22 82 34 Q92 30 90 20 Q100 34 92 46 Q84 56 72 50 Q62 42 68 30 Q72 36 76 34 Q70 22 74 10Z" fill="#ff7a1a" stroke="${e}" stroke-width="2.5" stroke-linejoin="round"/><rect x="40" y="12" width="16" height="8" rx="3" fill="#8a96aa" stroke="${e}" stroke-width="2.5"/>`),Ph=qr(e=>ie(Fe("i",[[0,"#fff6a0"],[1,"#ffb000"]],.45,.4))+`<circle cx="50" cy="50" r="42" fill="url(#i)" stroke="${e}" stroke-width="4"/><path d="M58 10 L28 54 L48 54 L40 90 L74 42 L54 42Z" fill="#fff" stroke="${e}" stroke-width="3.5" stroke-linejoin="round"/>`+[[18,24],[82,74],[20,78]].map(([t,r])=>`<polygon points="${Je(t,r,7,2.5,4)}" fill="#fff" stroke="${e}" stroke-width="1.5"/>`).join("")),Ih=qr(e=>Xo(50,92,24,4)+`<path d="M14 46 L46 12 L86 12 L86 52 L52 86Z" fill="#ff5a7a" stroke="${e}" stroke-width="4" stroke-linejoin="round"/><circle cx="72" cy="26" r="7" fill="#fff" stroke="${e}" stroke-width="3"/><text x="54" y="62" text-anchor="middle" font-family="Arial, sans-serif" font-weight="900" font-size="24" fill="#fff" stroke="${e}" stroke-width="1.5" transform="rotate(-45 54 54)">%</text>`+Hi("M48 18 L24 44",3,.6)),ld={ty_cinema:Lh,ty_port:_h,ty_up:id("#5ad35a","\xD72"),ty_up3:id("#4aa8ff","\xD73"),ty_upall:Rh,ty_rush:Ah,ty_wrench:Th,ty_investor:Dh,ty_manager:Oh,ty_sk_rush:Ch,ty_sk_instant:Ph,ty_sk_sale:Ih};var Ws=Object.freeze({...Gc,...Fc,...qc,...Uc,...Zc,...ed,...nd,...ld,...ad,...Kc}),Nh=e=>Object.prototype.hasOwnProperty.call(Ws,e);function zh(e,t){let r=Ws[e];return r?r.exact?t.w/Math.max(1,t.h):r.w/r.h:1}function Bh(e,t){let r=Ws[e];if(!r)return null;let{palette:o,style:n,box:s,px:a}=t,i=N=>Ai(N,o),h=r.exact?s.w:r.w,m=r.exact?s.h:r.h,v=r.draw({style:n,c:i,main:i(t.color??r.main??"primary"),ink:jc(n),w:h,h:m}),x=Math.max(1,Math.round(a.h)),D=Math.max(0,Math.round(t.padBottom??0)),O=D>0?m*(x+D)/x:m;return `<svg xmlns="http://www.w3.org/2000/svg" width="${Math.max(1,Math.round(a.w))}" height="${x+D}" viewBox="0 0 ${h} ${O}" preserveAspectRatio="none">${v}</svg>`}var Be=e=>({w:Number(e.vars.view_w??720),h:Number(e.vars.view_h??1280)}),ot=e=>e.vars.state==="playing",hn=e=>e.vars.started_tick===e.tick,Qe=(e,t,r)=>{let o=Number(e.vars[t]??0)+r;return e.vars[t]=o,o},yr=(e,t)=>Number(e[t]);function Pt(e,t,r,o,n){let s=e.create();return e.set(s,F,{x:t,y:r}),e.set(s,le,o),n&&e.set(s,n.type,n.data),s}var ct=(e,t)=>{for(let r of e.query(t))e.destroy(r);};function Jn(e){let t=new Set,r={down:false,x:0,y:0};return e.on(zt,o=>{let n=o;n.type==="key"?t.add(n.key):n.type==="key-up"?t.delete(n.key):n.type==="press"||n.type==="move"?(r.down=true,r.x=n.x,r.y=n.y):n.type==="release"&&(r.down=false);}),{keys:t,pointer:r,axis(){return {x:(t.has("right")?1:0)-(t.has("left")?1:0),y:(t.has("down")?1:0)-(t.has("up")?1:0)}}}}function un(e,t,r,o){let n=e.h*(o.bottom-o.top),s=Math.floor(Math.min(e.w*(o.widthShare??.94)/t,n/r)),a=(e.w-s*t)/2,i=e.h*o.top+(n-s*r)/2;return {cols:t,rows:r,cell:s,left:a,top:i}}var st=(e,t,r)=>({x:e.left+e.cell*(t+.5),y:e.top+e.cell*(r+.5)});function Ur(e,t,r){let o=Math.floor((t-e.left)/e.cell),n=Math.floor((r-e.top)/e.cell);return o>=0&&o<e.cols&&n>=0&&n<e.rows?{col:o,row:n}:null}var fd=["piece1","piece2","piece3","piece4","piece5","piece6"];ve("kit.status");var Vs=e=>{let t=Math.max(0,Math.ceil(e));return `${Math.floor(t/60)}:${String(t%60).padStart(2,"0")}`},K=(e,t)=>e.emit(Oi,t),Yn=ve("kit.backdrop");function Bt(e,t,r,o={}){for(let v of e.query(Yn))e.destroy(v);let n=Be(e),s=(v,x,D,O)=>Pt(e,x,D,O,{type:Yn,data:{speed:v}});if(t==="top"){let v=o.pan?1:0;s(v,n.w/2,n.h/2,{shape:"tile",art:"floor",w:n.w,h:n.h,unit:Math.min(n.w,n.h)*.24,depth:-100});let x=e.rng.stream("backdrop"),D=Math.round(n.w*n.h/52e3),O=Math.min(n.w,n.h);for(let N=0;N<D;N++){let q=O*x.range(.06,.1);s(v,x.range(0,n.w),x.range(0,n.h),{shape:"sprite",art:`decor${x.int(1,4)}`,w:q,h:q,depth:-95});}return}let a=r??n.h*.62;s(0,n.w/2,n.h/2,{shape:"sprite",art:"sky",w:n.w,h:n.h,depth:-100});let i=Math.min(n.w,n.h)*.34;s(.02,n.w*.74,a*.3,{shape:"sprite",art:"sun",w:i,h:i,depth:-99});let h=Math.min(n.h*.32,n.w*.55);s(.12,n.w/2,a-h/2,{shape:"tile",art:"far",w:n.w,h,depth:-90});let m=h*.62;s(.4,n.w/2,a-m/2+2,{shape:"tile",art:"near",w:n.w,h:m,depth:-80}),t==="board"?s(0,n.w/2,(n.h+a)/2,{shape:"tile",art:"ground",w:n.w,h:n.h-a+4,unit:h*.7,depth:-79}):s(0,n.w/2,(n.h+a)/2,{shape:"rect",w:n.w,h:n.h-a,color:"#140f0c",alpha:.92,depth:-79});}function Zo(e,t){for(let r of e.query(Yn)){let o=e.need(r,Yn).speed;if(o<=0)continue;let n=e.need(r,le);n.shape==="tile"&&(n.scrollX=(n.scrollX??0)+t*o);}}function pd(e,t,r){let o=Be(e),n=Math.min(o.w,o.h)*.1;for(let s of e.query(Yn)){if(e.need(s,Yn).speed<=0)continue;let a=e.need(s,le);if(a.shape==="tile"){a.scrollX=(a.scrollX??0)+t,a.scrollY=(a.scrollY??0)+r;continue}let i=e.need(s,F);i.x-=t,i.y-=r,i.x<-n?i.x+=o.w+2*n:i.x>o.w+n&&(i.x-=o.w+2*n),i.y<-n?i.y+=o.h+2*n:i.y>o.h+n&&(i.y-=o.h+2*n);}}function at(e,t,r){let o=e.get(t,le);o?.shape==="actor"&&(o.pose=r);}function Ge(e,t,r){let o=e.get(t,le);o?.shape==="actor"&&(o.act=r,o.actN=(o.actN??0)+1);}var Qn=ve("kit.fading"),cd=new WeakSet;function _n(e,t,r){e.set(t,Qn,{left:r,total:r}),!cd.has(e)&&(cd.add(e),e.addSystem({id:"kit.fading",order:90,run(o,n){for(let s of o.query(Qn)){let a=o.need(s,Qn);a.left-=n;let i=o.get(s,le);i&&(i.alpha=Math.max(0,Math.min(1,a.left/a.total*2))),a.left<=0&&o.destroy(s);}}}));}var Jt=(e,t,r=5)=>r+t/Math.max(1,Be(e).h),Zn=ve("kit.hint"),dd=new WeakSet,js=(e,t,r)=>({x:e+r*.11,y:t+r*.42});function kt(e,t,r,o=r,n){Ht(e);let s=n??Math.min(Be(e).w,Be(e).h)*.13,a={kind:t,ax:r.x,ay:r.y,bx:o.x,by:o.y,size:s,t:0},i=js(r.x,r.y,s);Pt(e,r.x,r.y,{shape:"circle",r:s*.22,color:"#ffffff",alpha:0,depth:89},{type:Zn,data:{...a,part:"ring"}}),Pt(e,i.x,i.y,{shape:"sprite",art:"hand",w:s,h:s,alpha:0,depth:90},{type:Zn,data:{...a,part:"hand"}}),!dd.has(e)&&(dd.add(e),e.addSystem({id:"kit.hints",order:95,run(h,m){for(let v of h.query(Zn)){let x=h.need(v,Zn);x.t+=m;let D=h.need(v,F),O=h.need(v,le);if(x.kind==="tap"){let N=x.t%1.2/1.2,q=N>.35&&N<.55;if(x.part==="hand"){let ne=js(x.ax,x.ay+(q?x.size*.06:0),x.size);D.x=ne.x,D.y=ne.y,D.scale=q?.9:1,O.alpha=Math.min(1,x.t*4);}else {let ne=N<.4?0:(N-.4)/.6;D.scale=1+ne*2.2,O.alpha=N<.4?0:.55*(1-ne);}}else if(x.kind==="swipe"){let N=x.t%1.6/1.6,q=N<.15?0:N>.75?1:(N-.15)/.6,ne=q*q*(3-2*q),Z=x.ax+(x.bx-x.ax)*ne,ye=x.ay+(x.by-x.ay)*ne;if(x.part==="hand"){let be=js(Z,ye,x.size);D.x=be.x,D.y=be.y,O.alpha=N<.1?N*10:N>.85?Math.max(0,(1-N)/.15):1;}else D.x=Z,D.y=ye,O.alpha=N>.15&&N<.8?.35:0;}else {let N=x.t*3,q=x.ax+Math.cos(N)*x.bx,ne=x.ay+Math.sin(N)*x.bx;if(x.part==="hand"){let Z=js(q,ne,x.size);D.x=Z.x,D.y=Z.y,O.alpha=Math.min(1,x.t*3);}else D.x=q,D.y=ne,O.alpha=.3;}}}}));}function Ht(e){for(let t of e.query(Zn))e.destroy(t);}var _r=e=>e.query(Zn).length>0,vt=(e,t)=>e.vars[`learned:${t}`]===true;function Lt(e,t){vt(e,t)||(e.vars[`learned:${t}`]=true,Ht(e));}var eo=ve("round.start"),qt="round-started",Ut="round-over",Xt="round-ended",Wi="start-round",Zt="show-start",er="revive-offer",tr="revive",rr="give-up",Gs={id:"round",version:1,setup({world:e}){e.vars.state="ready",e.vars.score=0,e.vars.coins=0,e.vars.best=typeof e.vars.best=="number"?e.vars.best:0,e.vars.round=0;let t=o=>{for(let i of o.query(eo))o.destroy(i);if(o.vars.state!=="ready")return;let n=Be(o),s=Math.min(n.w,n.h)*.26,a={x:n.w/2,y:n.h*.55};Pt(o,n.w/2,n.h/2,{shape:"rect",w:n.w,h:n.h,color:"#05040a",alpha:.4,depth:84},{type:eo,data:{t:-1}}),Pt(o,a.x,a.y,{shape:"sprite",art:"play",w:s,h:s,color:"accent",depth:85},{type:eo,data:{t:0}}),kt(o,"tap",{x:a.x+s*.12,y:a.y+s*.1});},r=()=>{for(let o of e.query(eo))e.destroy(o);Ht(e),e.vars.state="playing",e.vars.score=0,e.vars.coins=0,e.vars.round=Number(e.vars.round??0)+1,e.vars.started_tick=e.tick,e.emit(qt,{round:e.vars.round});};e.on(zt,o=>{let n=o;e.vars.state==="ready"&&(n.type==="tap"||n.type==="key"&&n.key==="action")&&r();}),e.on(Wi,()=>{e.vars.state!=="playing"&&r();}),e.on(Zt,()=>{e.vars.state==="ended"&&(e.vars.state="ready",t(e));}),e.on(Ft,()=>t(e)),e.addSystem({id:"round.start",order:96,run(o,n){for(let s of o.query(eo)){let a=o.need(s,eo);a.t<0||(a.t+=n,o.need(s,F).scale=1+.06*Math.sin(a.t*5));}}}),t(e),e.on(Ut,o=>{if(e.vars.state!=="playing")return;e.vars.state="ended",Ht(e);let n=Number(e.vars.score??0),s=Math.max(Number(e.vars.best??0),n);e.vars.best=s,e.emit(Xt,{score:n,coins:Number(e.vars.coins??0),best:s,reason:typeof o.reason=="string"?o.reason:"over",...o.stats&&typeof o.stats=="object"?{stats:o.stats}:{}});});}};var Ks=["wall","barrier","pit","mover","train","rock"];var Yo=["magnet","shield","double","dash","flight"],Rr={magnet:{art:"magnet",color:"danger",seconds:6,var:"meta:magnet_t",weight:3},shield:{art:"shield",color:"muted",seconds:8,var:"meta:shield_t",weight:2.5},double:{art:"coin2x",color:"coin",seconds:8,var:"meta:double_t",weight:2.5},dash:{art:"boot",color:"accent",seconds:2.5,var:"meta:dash_t",weight:1.5},flight:{art:"wing",color:"secondary",seconds:4,var:"meta:flight_t",weight:1}},Qo=20,hd={wall:1,barrier:2,pit:3,mover:4,train:5,rock:6};function to(e,t=.5){let r=Math.max(1,Math.min(Qo,Math.floor(e))),o=(r-1)/(Qo-1),n=Ks.filter(i=>hd[i]<=r),s=Ks.find(i=>hd[i]===r)??null,a=330+t*120+o*220;return {level:r,length:Math.round(16e3+(r-1)*3e3),speed:a,topSpeed:a*(1.25+o*.1),density:Math.min(.72,.3+t*.12+o*.3),kinds:n,fresh:s,coinStar:.6,firstClearGold:60+(r-1)*25}}var ro=e=>Math.floor(e/30),no=[{id:"hero",cast:"hero",gems:0,perk:"none"},{id:"hero2",cast:"hero2",gems:150,perk:"heart"},{id:"hero3",cast:"hero3",gems:300,perk:"power"}],ji="kit-runner",Vi=[{id:"MagnetTime",var:"meta:magnet_t",art:"magnet",color:"danger",perLevel:.6,unit:"s",maxLevel:15,price:20,growth:.12},{id:"ShieldTime",var:"meta:shield_t",art:"shield",color:"muted",perLevel:.8,unit:"s",maxLevel:15,price:25,growth:.12},{id:"DoubleTime",var:"meta:double_t",art:"coin2x",color:"coin",perLevel:.8,unit:"s",maxLevel:15,price:25,growth:.12},{id:"DashTime",var:"meta:dash_t",art:"boot",color:"accent",perLevel:.3,unit:"s",maxLevel:15,price:30,growth:.12},{id:"FlightTime",var:"meta:flight_t",art:"wing",color:"secondary",perLevel:.4,unit:"s",maxLevel:15,price:35,growth:.12},{id:"Luck",var:"meta:luck",art:"clover",color:"accent",perLevel:5,unit:"%",maxLevel:20,price:30,growth:.1},{id:"HeadStart",var:"meta:head_start",art:"lightning",color:"primary",perLevel:.4,unit:"s",maxLevel:10,price:50,growth:.15},{id:"Greed",var:"meta:greed",art:"coin",color:"coin",perLevel:2,unit:"%",maxLevel:25,price:40,growth:.1}],ud={game:"runner",character:ji,stats:Vi,heroes:no,levels:Qo,firstClearGold:e=>to(e).firstClearGold,stars:3};var _t=ve("runner.item"),Xr=ve("runner.player"),Fs=ve("runner.stripe"),md=ve("runner.hud"),Vt=(e,t)=>{let r=Number(e.vars.view_w??720),o=Number(e.vars.view_h??1280),n=Math.min(o*.11,r*.2,o*.5/t),s=o*.6-n*t/2;return {viewW:r,viewH:o,top:s,laneH:n,playerX:Math.min(r*.24,o*.3)}},oo=(e,t)=>e.top+e.laneH*(t+.72),Jo=(e,t)=>{let r=Number(e.vars[t]??0);return Number.isFinite(r)?r:0},It={wall:1.3,barrier:.5,mover:1,train:.95,rock:1.05,jump:1.25,flight:1.9},qs={id:"lane-runner",version:2,engines:["phaser"],requires:["round"],params:{lanes:{type:"number",default:3,min:2,max:5,integer:true},difficulty:{type:"number",default:.5,min:0,max:1},coinRate:{type:"number",default:.7,min:0,max:1},powerRate:{type:"number",default:.22,min:0,max:1},lives:{type:"number",default:3,min:1,max:9,integer:true},coinScore:{type:"number",default:10,min:0,max:1e3,integer:true},graceTime:{type:"number",default:1.2,min:0,max:5},jumpTime:{type:"number",default:.62,min:.3,max:1.5},lengthScale:{type:"number",default:1,min:.05,max:5}},setup({world:e,params:t,mode:r}){let o=u=>yr(t,u),n=o("lanes"),s=e.rng.stream("lane-runner"),a=null,i=u=>({...u,kinds:[...Sr(r,"obstacles",u.kinds)]}),h=Sr(r,"powers",Yo),m=i(to(1,o("difficulty"))),v=m.length,x=0,D=0,O=0,N=false,q=false,ne=false,Z=0,ye=0,be=0,fe=0,Ee=0,de=0,Ae=0,Pe=3,we=0,ce=false,ke=null,Le=new Map,_e=new Map,oe=()=>no.find(u=>u.id===e.vars["meta:hero"])??no[0],Te=u=>(Rr[u].seconds+Jo(e,Rr[u].var))*(oe().perk==="power"?1.25:1),Ke=()=>e.vars.reviving===true,Ne=()=>{for(let c of e.query(Fs))e.destroy(c);let u=Vt(e,n);Bt(e,"side",u.top+2);for(let c=0;c<n;c++){let p=e.create();e.set(p,Fs,{index:c}),e.set(p,F,{x:u.viewW/2,y:u.top+u.laneH*(c+.5)}),e.set(p,le,{shape:"tile",art:"road",w:u.viewW,h:u.laneH,unit:u.laneH*1.28,depth:-20+c*.1});}let f=u.viewH-(u.top+u.laneH*n),b=e.create();e.set(b,Fs,{index:-1}),e.set(b,F,{x:u.viewW/2,y:u.viewH-f/2+1}),e.set(b,le,{shape:"tile",art:"ground",w:u.viewW,h:f+2,unit:u.laneH*1.2,depth:-21});},se=(u,f,b)=>oo(u,f.lane)-f.alt-b/2,Ie=(u,f,b,c,p)=>{let k=u.laneH,_=9+b;switch(f){case "wall":return {v:{shape:"sprite",art:"obstacle",w:c,h:k*It.wall,depth:_},h:k*It.wall};case "barrier":return {v:{shape:"sprite",art:"hurdle",w:c,h:k*It.barrier,depth:_},h:k*It.barrier};case "pit":return {v:{shape:"sprite",art:"pit",w:c,h:k*.42,depth:-19+b*.1+.05},h:-k*.42};case "mover":return {v:{shape:"actor",cast:"foe",h:k*1.5,pose:"run",facing:-1,depth:_},h:k*1.5};case "train":return {v:{shape:"sprite",art:"wagon",w:c,h:k*It.train,depth:_},h:k*It.train};case "ramp":return {v:{shape:"sprite",art:"ramp",w:c,h:k*It.train,depth:_},h:k*It.train};case "rock":return {v:{shape:"sprite",art:"shadow",w:c,h:k*.3,alpha:.5,depth:-19+b*.1+.06},h:-k*.3};case "coin":return {v:{shape:"sprite",art:"coin",w:c,h:c,depth:_+.2},h:c};case "power":return {v:{shape:"sprite",art:Rr[p??"magnet"].art,color:Rr[p??"magnet"].color,w:c,h:c,depth:_+.2},h:c};case "finish":return {v:{shape:"sprite",art:"finish",w:k*.7,h:k*n+k*.9,depth:8},h:0}}},$e=(u,f,b,c={})=>{let p=Vt(e,n),k=c.size??(u==="coin"?p.laneH*.42:u==="power"?p.laneH*.62:p.laneH*.85),_=c.alt??(u==="coin"?p.laneH*.5:u==="power"?p.laneH*.6:0),C=e.create();e.set(C,_t,{lane:f,kind:u,size:k,alt:_,...c.power!==void 0?{power:c.power}:{}});let{v:z,h:B}=Ie(p,u,f,k,c.power),ae=p.viewW+p.laneH+k/2+b,pe=u==="finish"?p.top+p.laneH*n/2:B<0?oo(p,f)+B/2+p.laneH*.08:se(p,{lane:f,alt:_},B);return e.set(C,F,{x:ae,y:pe}),e.set(C,le,z),u==="coin"&&fe++,C},Se=(u,f,b,c)=>{let p=Vt(e,n);for(let k=0;k<b;k++)$e("coin",u,f+k*p.laneH*.75,c!==void 0?{alt:c}:{});},Ye=(u,f)=>{let b=1+Jo(e,"meta:luck");s.chance(Math.min(.9,o("powerRate")*b))&&$e("power",u,f,{power:s.weighted(h,c=>Rr[c].weight)});},ee=u=>m.kinds.includes(u),Re=()=>[...Array(n).keys()],rt=u=>{let f=["wall",...ee("barrier")?["barrier"]:[],...ee("pit")?["pit"]:[]],b=new Map;for(let k of Re())s.chance(m.density)&&b.set(k,s.pick(f));b.size>=n&&b.delete(s.int(0,n-1));let c=Vt(e,n);for(let[k,_]of b)$e(_,k,u,_==="pit"?{size:c.laneH*1.25}:{});let p=Re().filter(k=>!b.has(k));p.length>0&&s.chance(o("coinRate"))&&Se(s.pick(p),u-c.laneH,3);for(let[k,_]of b)(_==="barrier"||_==="pit")&&s.chance(.5)&&Se(k,u-c.laneH*.75,3,c.laneH*1.3);},ht=()=>{let f=Vt(e,n).laneH,b=p=>p+Math.round(m.density*3),c=[{id:"scatter",weight:3,make:p=>{let k=b(2);for(let _=0;_<k;_++)rt(_*p);return Ye(s.int(0,n-1),k*p-p/2),k*p}},{id:"rest",weight:1,make:p=>{let k=s.int(0,n-1);for(let _=0;_<4;_++)Se(k,_*p*.8,3),k=Math.max(0,Math.min(n-1,k+(s.chance(.5)?1:-1)));return Ye(k,4*p*.8),4*p*.8}}];return m.level>=3&&c.push({id:"corridor",weight:2,make:p=>{let k=b(3),_=s.int(0,n-1);for(let C=0;C<k;C++){for(let z of Re())z!==_&&$e("wall",z,C*p);Se(_,C*p-f*.4,2),C%2===1&&(_=Math.max(0,Math.min(n-1,_+(s.chance(.5)?1:-1))));}return k*p}}),(ee("barrier")||ee("pit"))&&c.push({id:"hurdles",weight:2,make:()=>{let p=Math.max(f*3.6,m.speed*o("jumpTime")*1.45),k=2+Math.round(m.density*2),_=[...ee("barrier")?["barrier"]:[],...ee("pit")?["pit"]:[]],C=s.int(0,n-1);for(let z=0;z<k;z++){for(let B of Re()){let ae=s.pick(_);$e(ae,B,z*p,ae==="pit"?{size:f*1.25}:{});}Se(C,z*p-f*.75,3,f*1.3);}return k*p}}),ee("train")&&c.push({id:"train",weight:2,make:p=>{let k=s.int(0,n-1),_=f*s.int(5,8),C=s.chance(.75),z=f*1.4;C&&$e("ramp",k,0,{size:z}),$e("train",k,(C?z:0)+_/2-f*.42,{size:_}),C&&Se(k,z+f*.4,Math.floor(_/(f*.75))-1,f*(It.train+.5));let B=Re().filter(pe=>pe!==k),ae=s.pick(B);if(s.chance(.5))$e("train",ae,p*.5+_/2,{size:_*.8});else for(let pe=0;pe<2;pe++)$e("wall",ae,p*(.5+pe*1.4));return (C?z:0)+_+p*.5}}),ee("mover")&&c.push({id:"movers",weight:1.5,make:p=>{let k=1+(s.chance(m.density)?1:0),_=new Set;for(let z=0;z<k;z++){let B=s.int(0,n-1);_.has(B)&&(B=(B+1)%n),_.add(B),$e("mover",B,z*p*1.6,{size:f*.6});}let C=Re().filter(z=>!_.has(z));return C.length>0&&Se(s.pick(C),0,4),k*p*1.6}}),ee("rock")&&c.push({id:"rocks",weight:1.5,make:p=>{let k=2+(s.chance(m.density)?1:0);for(let _=0;_<k;_++){let C=s.int(0,n-1);$e("rock",C,_*p*1.2,{size:f*.9});let z=Re().filter(B=>B!==C);Se(s.pick(z),_*p*1.2,2);}return k*p*1.2}}),c},De=u=>{let f=Vt(e,n),b=Math.floor(n/2),c=m.fresh;if(c===null||c==="wall")return 0;if(c==="barrier"||c==="pit"){for(let p=0;p<3;p++)$e(c,b,p*u*1.6,c==="pit"?{size:f.laneH*1.25}:{}),Se(b,p*u*1.6-f.laneH*.75,3,f.laneH*1.3);return 3*u*1.6}return c==="train"?($e("ramp",b,0,{size:f.laneH*1.4}),$e("train",b,f.laneH*1.4+f.laneH*3-f.laneH*.42,{size:f.laneH*6}),Se(b,f.laneH*1.8,7,f.laneH*(It.train+.5)),f.laneH*8+u):($e(c,b,0,{size:c==="mover"?f.laneH*.6:f.laneH*.9}),u*1.5)},Qt=()=>{let u=Math.max(Vt(e,n).laneH*2.1,300-m.density*110),f;if(!ce&&m.fresh!==null&&m.fresh!=="wall")ce=true,f=De(u);else {let b=ht();f=(O>0&&O%4===3?b.find(p=>p.id==="rest"):s.weighted(b,p=>p.weight)).make(u);}O++,D=Number(e.vars.distance??0)+f+u*1.2;},Xe=(u,f,b)=>{let c=u.laneH*1.05;return {x:u.playerX,y:oo(u,f)-b-c/2,h:c}},et=()=>{let u=Vt(e,n);(a===null||!e.isAlive(a))&&(a=e.create(),e.set(a,Xr,{lane:Math.floor(n/2),size:u.laneH*.5,alt:0,vy:0}),e.set(a,le,{shape:"actor",cast:oe().cast,h:0,pose:"idle",depth:10}));let f=e.need(a,Xr);f.size=u.laneH*.5;let b=Xe(u,f.lane,f.alt);e.set(a,F,{x:b.x,y:b.y});let c=e.need(a,le);c.shape==="actor"&&(c.cast=oe().cast,c.h=b.h,c.depth=10+f.lane);},it=()=>{for(let f of e.query(_t))e.destroy(f);Ze(),m=i(to(Jo(e,"meta:chapter")||1,o("difficulty"))),v=Math.round(m.length*o("lengthScale")),Pe=o("lives")+(oe().perk==="heart"?1:0),e.vars.distance=0,e.vars.meters=0,e.vars.level_length=v,e.vars.runner_length_scale=o("lengthScale"),e.vars.runner_level=m.level,e.vars.speed=m.speed,e.vars.lives=Pe,e.vars.coins=0,e.vars.score=0,e.vars.mult=1,e.vars.stars=0,e.vars.reviving=false,x=0,D=Vt(e,n).laneH*2,O=0,N=false,q=false,ne=false,Z=0,ye=0,be=0,fe=0,Ee=0,de=0,Ae=0,we=0,ce=false,ke=null,Le.clear();let u=Jo(e,"meta:head_start");if(u>0&&Le.set("dash",u),a!==null&&e.isAlive(a)){let f=e.need(a,Xr);f.lane=Math.floor(n/2),f.alt=0,f.vy=0;}et();},dt=u=>{if(!ot(e)||Ke()||a===null)return;let f=e.need(a,Xr),b=Math.min(n-1,Math.max(0,f.lane+u));b!==f.lane&&(Lt(e,"runner-lanes"),ke=f.lane),f.lane=b;},mt=()=>{let u=Vt(e,n),f=o("jumpTime");return 8*u.laneH*It.jump/(f*f)},yt=(u,f,b)=>{let c=Vt(u,n),p=c.playerX,k=c.laneH*.22,_=0;for(let C of u.query(_t)){let z=u.need(C,_t);if(z.lane!==f||z.kind!=="train"&&z.kind!=="ramp")continue;let B=u.need(C,F),ae=B.x-z.size/2,pe=B.x+z.size/2;if(p+k<ae||p-k>pe)continue;let Me=c.laneH*It.train;if(z.kind==="ramp")_=Math.max(_,Me*Math.max(0,Math.min(1,(p-ae)/z.size)));else if(b>=Me-c.laneH*.12)_=Math.max(_,Me);else return null}return _},gt=()=>{if(!ot(e)||Ke()||a===null||Le.has("flight"))return;let u=e.need(a,Xr),f=yt(e,u.lane,u.alt)??0;u.alt-f>2||(u.vy=mt()*o("jumpTime")/2,Ae++,Lt(e,"runner-jump"),Ht(e),e.emit("jumped",{}),Ge(e,a,"jump"));},ft=()=>{if(vt(e,"runner-lanes")||a===null)return;let u=Vt(e,n),f=u.playerX+u.laneH*1.6,b=oo(u,Math.floor(n/2))-u.laneH*.4;kt(e,"swipe",{x:f,y:b+u.laneH*.5},{x:f,y:b-u.laneH*.9},u.laneH);},ze=(u,f,b,c)=>{let p=_e.get(u);(p===void 0||!e.isAlive(p))&&(p=e.create(),e.set(p,md,{id:u}),_e.set(u,p)),e.set(p,F,{x:f,y:b}),e.set(p,le,c);},Et=u=>{let f=_e.get(u);f!==void 0&&e.destroy(f),_e.delete(u);};function Ze(){for(let u of _e.values())e.destroy(u);_e.clear(),ct(e,md);}let Wt=(u,f,b,c,p,k,_,C=41)=>{let z=Math.max(0,Math.min(1,Math.round(k*100)/100));ze(`${u}:bg`,f,b,{shape:"rect",w:c,h:p,color:"#000000",alpha:.45,radius:p/2,depth:C});let B=Math.max(0,(c-4)*z);B<1?Et(`${u}:fill`):ze(`${u}:fill`,f-(c-4)/2+B/2,b,{shape:"rect",w:B,h:p-4,color:_,radius:(p-4)/2,depth:C+.01});},hr=u=>{let f=Vt(u,n),b=Math.min(f.viewW,f.viewH),c=f.viewH*.085,p=f.viewW*.66,k=Math.max(10,b*.026),_=Number(u.vars.distance??0)/Math.max(1,v);Wt("way",f.viewW/2,c,p,k,_,"accent");let C=b*.055;ze("flag",f.viewW/2+p/2+C*.45,c-C*.25,{shape:"sprite",art:"flag",w:C,h:C,depth:42}),ze("lvl",f.viewW/2-p/2-b*.05,c,{shape:"text",text:`${m.level}`,size:Math.round(b*.04),color:"text",bold:true,depth:42});let z=c+b*.07,B=b*.05,ae=Number(u.vars.lives??0);for(let re=0;re<Pe;re++)ze(`h${re}`,f.viewW*.07+re*B*1.1,z,{shape:"sprite",art:"heart",w:B,h:B,alpha:re<ae?1:.25,depth:42});for(let re=Pe;re<10;re++)Et(`h${re}`);let pe=b*.045,Me=String(u.vars.coins??0);ze("coin:i",f.viewW*.93-Me.length*pe*.6-pe*.7,z,{shape:"sprite",art:"coin",w:pe,h:pe,depth:42}),ze("coin",f.viewW*.93-Me.length*pe*.6/2,z,{shape:"text",text:Me,size:Math.round(pe),color:"text",bold:true,depth:42});let qe=Number(u.vars.mult??1);qe>1?ze("mult",f.viewW*.9,z+pe*1.2,{shape:"text",text:`x${qe}`,size:Math.round(pe*1.05),color:"coin",bold:true,depth:42}):Et("mult");let tt=b*.055,pt=0;for(let re of Yo){let j=Le.get(re);if(j===void 0){Et(`p:${re}`),Et(`pb:${re}:bg`),Et(`pb:${re}:fill`);continue}let J=f.viewW*.07+pt*tt*1.25,Y=z+B*1.25;ze(`p:${re}`,J,Y,{shape:"sprite",art:Rr[re].art,color:Rr[re].color,w:tt,h:tt,depth:42}),Wt(`pb:${re}`,J,Y+tt*.7,tt,Math.max(6,b*.011),j/Math.max(.1,Te(re)),"coin",42),pt++;}},Nt=(u,f)=>{if(!ot(u)||q)return;q=true;let b=f==="cleared",c=b?1+(fe>0&&Ee>=fe*m.coinStar?1:0)+(de===0?1:0):0;u.vars.stars=c,b&&u.vars["meta:first_clear"]===true&&Qe(u,"coins",m.firstClearGold);let p=ro(Number(u.vars.distance??0));u.vars.score=we+p*2+(b?500*c:0),u.vars.reviving=false,u.emit(Ut,{reason:f,stats:{chapter:m.level,seconds:Math.floor(Z),cleared:b,stars:c,coins:Ee,meters:p,jumps:Ae,hits:de}});},ur=u=>{if(u.vars.revive_ready===true&&!ne){u.vars.reviving=true,Ht(u),u.emit(er,{});return}Nt(u,"crashed");},Tt=u=>{if(!Ke())return;ne=true,u.vars.reviving=false,u.vars.lives=Math.max(1,Math.ceil(Pe/2)),x=2.5,Le.set("shield",Math.max(Le.get("shield")??0,3));let f=Vt(u,n);for(let b of u.query(_t)){let c=u.need(b,_t);if(c.kind==="coin"||c.kind==="power"||c.kind==="finish")continue;let p=u.need(b,F);p.x-c.size/2<f.playerX+f.laneH*6&&(K(u,{kind:"burst",x:p.x,y:p.y,color:"coin",n:8,size:f.laneH*.6}),u.destroy(b));}if(a!==null){let b=u.need(a,Xr);b.alt=0,b.vy=0,at(u,a,"run");let c=u.need(a,F);K(u,{kind:"ring",x:c.x,y:c.y,color:"coin",size:f.laneH*4});}K(u,{kind:"flash",color:"coin"});},T=(u,f)=>{if(a===null)return;let b=u.need(f,F),c=Vt(u,n);if(Le.has("dash")){K(u,{kind:"burst",x:b.x,y:b.y,color:"accent",n:14,size:c.laneH*.8}),K(u,{kind:"shake",power:.6}),u.need(f,_t).kind!=="pit"&&u.destroy(f);return}if(x>0)return;if(Le.has("shield")){Le.delete("shield"),x=.8,K(u,{kind:"ring",x:c.playerX,y:u.need(a,F).y,color:"muted",size:c.laneH*2}),u.need(f,_t).kind!=="pit"&&u.destroy(f);return}de++,ye=0,u.vars.mult=1;let p=Number(u.vars.lives??1)-1;u.vars.lives=p,u.emit("player-hit",{lives:p}),K(u,{kind:"burst",x:b.x,y:b.y,color:"danger",n:14,size:c.laneH*.9}),K(u,{kind:"shake",power:1.5}),Ge(u,a,"hit"),u.need(f,_t).kind!=="pit"&&u.destroy(f),x=o("graceTime"),p<=0&&ur(u);},H=(u,f)=>{let b=u.need(f,_t),c=u.need(f,F),p=Vt(u,n);if(b.kind==="power"&&b.power!==void 0){Le.set(b.power,Te(b.power)),u.emit("power-up",{id:b.power}),K(u,{kind:"ring",x:c.x,y:c.y,color:Rr[b.power].color,size:p.laneH*1.6}),u.destroy(f);return}ye++;let k=Math.min(5,1+Math.floor(ye/12));k>Number(u.vars.mult??1)&&K(u,{kind:"pop",x:p.playerX,y:c.y-p.laneH,text:`x${k}`,color:"coin",size:Math.round(p.laneH*.42)}),u.vars.mult=k;let _=(Le.has("double")?2:1)*(1+Jo(u,"meta:greed"));be+=_;let C=Math.floor(be);be-=C,C>0&&Qe(u,"coins",C),Ee++,we+=Math.round(_*o("coinScore")*k),u.emit("coin-collected",{value:_}),K(u,{kind:"burst",x:c.x,y:c.y,color:"coin",n:6,size:b.size*1.3}),u.destroy(f);};e.on(zt,u=>{let f=u;e.vars.started_tick!==e.tick&&(f.type==="swipe"&&(f.dir==="up"||f.dir==="down")?dt(f.dir==="up"?-1:1):f.type==="swipe"&&f.dir==="right"?gt():f.type==="key"&&(f.key==="left"||f.key==="up")?dt(-1):f.type==="key"&&(f.key==="right"||f.key==="down")?dt(1):(f.type==="key"&&f.key==="action"||f.type==="tap")&>());}),e.on(qt,()=>{it(),a!==null&&at(e,a,"run"),ft();}),e.on(Zt,it),e.on(tr,()=>Tt(e)),e.on(rr,()=>{Ke()&&(e.vars.reviving=false,Nt(e,"crashed"));}),e.on(Xt,u=>{a!==null&&e.isAlive(a)&&at(e,a,u.reason==="cleared"?"dance":"die");for(let f of e.query(_t))e.need(f,_t).kind==="mover"&&at(e,f,"idle");Ze();}),e.on(Ft,()=>{Ne(),a!==null&&et();let u=Vt(e,n);for(let f of e.query(_t)){let b=e.need(f,_t),{v:c,h:p}=Ie(u,b.kind,b.lane,b.size,b.power);e.set(f,le,c),e.need(f,F).y=b.kind==="finish"?u.top+u.laneH*n/2:p<0?oo(u,b.lane)+p/2+u.laneH*.08:se(u,b,p);}}),e.addSystem({id:"lane-runner",order:0,run(u,f){if(!ot(u)||a===null||q||Ke())return;let b=Vt(u,n),c=b.laneH;Z+=f;let p=Number(u.vars.distance??0),_=(m.speed+(m.topSpeed-m.speed)*Math.min(1,p/Math.max(1,v)))*(Le.has("dash")?1.6:1);u.vars.speed=Math.round(_);let C=_*f;u.vars.distance=p+C,u.vars.meters=ro(p+C),x>0&&(x=Math.max(0,x-f));for(let[re,j]of [...Le])j-f<=0?(Le.delete(re),re==="flight"&&(x=Math.max(x,.8))):Le.set(re,j-f);Zo(u,C);for(let re of u.query(Fs)){let j=u.need(re,le);j.shape==="tile"&&(j.scrollX=(j.scrollX??0)+C);}let z=v-(p+C);if(!N&&z<=b.viewW-b.playerX+c){N=true;let re=$e("finish",0,0);u.need(re,F).x=b.playerX+z;}else !N&&p>=D&&z>b.viewW&&Qt();let B=u.need(a,Xr),ae=Le.has("flight");if(ae)B.alt+=(c*It.flight-B.alt)*Math.min(1,f*6),B.vy=0,Math.floor((p+C)/(c*.9))!==Math.floor(p/(c*.9))&&$e("coin",B.lane,0,{alt:c*(It.flight+.4)});else {B.vy-=mt()*f,B.alt+=B.vy*f;let re=yt(u,B.lane,B.alt);if(re===null){let j=u.query(_t).find(J=>{let Y=u.need(J,_t);return Y.lane===B.lane&&Y.kind==="train"&&Math.abs(u.need(J,F).x-b.playerX)<Y.size/2+c*.22});if(j!==void 0&&T(u,j),q||Ke())return;B.alt=Math.max(0,B.alt);}else B.alt<=re&&(B.alt=re,B.vy=0);}let pe=u.need(a,F),Me=Xe(b,B.lane,B.alt);pe.y+=(Me.y-pe.y)*Math.min(1,f*14),pe.x=Me.x,ke!==null&&Math.abs(Me.y-pe.y)<c*.15&&(ke=null);let qe=u.need(a,le);qe.shape==="actor"&&(qe.alpha=x>0&&Math.floor(u.time*12)%2===0?.35:1,qe.depth=10+B.lane+.5,qe.speed=_,qe.pose=B.alt>2&&B.vy!==0?"air":"run");let tt=c*.24,pt=Le.has("magnet");for(let re of u.query(_t)){if(!u.isAlive(re)||!u.has(re,_t))continue;let j=u.need(re,_t),J=u.need(re,F);if(J.x-=C,j.kind==="mover"){if(J.x-=_*.35*f,j.to===void 0&&J.x-b.playerX<c*6&&J.x-b.playerX>c*3){let E=[j.lane-1,j.lane+1].filter(l=>l>=0&&l<n);j.to=B.lane!==j.lane&&E.includes(B.lane)?B.lane:s.pick(E),j.warn=.45;}if(j.warn!==void 0&&j.warn>0){j.warn-=f;let E=u.need(re,le);E.alpha=Math.floor(u.time*14)%2===0?.4:1,j.warn<=0&&j.to!==void 0&&(j.lane=j.to,E.alpha=1,E.depth=9+j.lane);}J.y+=(se(b,j,c*1.5)-J.y)*Math.min(1,f*10);}if(j.kind==="rock"&&!j.landed&&J.x-b.playerX<c*2.6&&(j.landed=true,u.set(re,le,{shape:"sprite",art:"rock",w:j.size,h:c*It.rock,depth:9+j.lane}),J.y=oo(b,j.lane)-c*It.rock/2,K(u,{kind:"burst",x:J.x,y:J.y+c*.4,color:"muted",n:10,size:c*.7}),K(u,{kind:"shake",power:.5})),j.kind==="rock"&&!j.landed){let E=u.need(re,le);E.shape==="sprite"&&(E.alpha=.35+.3*Math.abs(Math.sin(u.time*6)));}if(j.kind==="power"&&(J.y=se(b,j,j.size)+Math.sin(u.time*4+J.x*.01)*c*.06),J.x+j.size/2<-c*2){u.destroy(re);continue}if(j.kind==="finish"){if(J.x<=b.playerX){K(u,{kind:"flash",color:"coin"}),Nt(u,"cleared");return}continue}if(j.kind==="coin"&&pt&&J.x>b.playerX-c*.5&&J.x<b.playerX+c*4&&(j.pulled=true),j.kind==="coin"&&j.pulled){J.x+=(b.playerX-J.x)*Math.min(1,f*10),J.y+=(pe.y-J.y)*Math.min(1,f*10),Math.hypot(J.x-b.playerX,J.y-pe.y)<c*.4&&H(u,re);continue}if(j.kind==="coin"||j.kind==="power"){if(j.lane!==B.lane&&j.lane!==ke)continue;let E=tt+j.size/2+c*.06;if(J.x-E>b.playerX||J.x+C+E<b.playerX)continue;let l=j.size/2+c*.08;(ae||J.y+l>pe.y-Me.h/2&&J.y-l<pe.y+Me.h/2)&&H(u,re);continue}let Y=j.kind==="barrier"?j.size*.3:j.size/2;if(Math.abs(J.x-b.playerX)>tt+Y||j.lane!==B.lane||ae||j.kind==="ramp"||j.kind==="train"||j.kind==="rock"&&!j.landed)continue;let M=j.kind==="wall"?It.wall:j.kind==="barrier"?It.barrier*.85:j.kind==="mover"?It.mover:j.kind==="rock"?It.rock:0;if(j.kind==="pit"?B.alt<2&&Math.abs(J.x-b.playerX)<j.size*.32&&T(u,re):B.alt<c*M&&T(u,re),q||Ke())return}vt(u,"runner-jump")||u.query(_t).find(j=>{let J=u.need(j,_t),Y=u.need(j,F).x-b.playerX;return (J.kind==="barrier"||J.kind==="pit")&&J.lane===B.lane&&Y>c*1.5&&Y<c*3.2})!==void 0&&!_r(u)&&kt(u,"tap",{x:b.playerX+c*1.2,y:pe.y}),u.vars.score=we+ro(p+C)*2,hr(u);}}),Ne(),it();}};var Rn=[{id:"rainbow",shape:"color",art:"m3_rainbow",make:e=>e>=5},{id:"bomb",shape:"area:1",art:"m3_bomb",make:(e,t)=>t},{id:"col",shape:"col",art:"m3_col",make:(e,t,r)=>e===4&&r==="h"},{id:"row",shape:"row",art:"m3_row",make:(e,t,r)=>e===4&&r==="v"}],yd=[{a:"row",b:"row",effect:"cross"},{a:"col",b:"col",effect:"cross"},{a:"row",b:"col",effect:"cross"},{a:"bomb",b:"row",effect:"cross:1"},{a:"bomb",b:"col",effect:"cross:1"},{a:"bomb",b:"bomb",effect:"area:2"},{a:"rainbow",b:"plain",effect:"color"},{a:"rainbow",b:"row",effect:"turn"},{a:"rainbow",b:"col",effect:"turn"},{a:"rainbow",b:"bomb",effect:"turn"},{a:"rainbow",b:"rainbow",effect:"all"}],Zr={ice:{id:"ice",layer:"under",hp:1,art:"m3_ice",max:20},slime:{id:"slime",layer:"under",hp:1,art:"m3_slime",spreads:true,max:16},chain:{id:"chain",layer:"over",hp:1,art:"m3_chain",max:10},stone:{id:"stone",layer:"block",hp:1,art:"m3_stone",hitByNear:true,max:10},cage:{id:"cage",layer:"block",hp:1,art:"m3_cage",hitByNear:true}},Gi={"-":{},".":{hole:true},i:{under:{id:"ice",hp:1}},I:{under:{id:"ice",hp:2}},m:{under:{id:"slime",hp:1}},c:{over:{id:"chain",hp:1}},s:{block:{id:"stone",hp:1}},S:{block:{id:"stone",hp:2}},g:{block:{id:"cage",hp:1}}},rs={fire:{beats:["nature"],color:"piece1"},water:{beats:["fire"],color:"piece2"},nature:{beats:["water"],color:"piece3"},light:{beats:["dark"],color:"piece4"},dark:{beats:["light"],color:"piece5"}},Ki=[{index:0,art:"gem1",color:"piece1",role:"attack",element:"fire"},{index:1,art:"gem2",color:"piece2",role:"attack",element:"water"},{index:2,art:"gem3",color:"piece3",role:"attack",element:"nature"},{index:3,art:"gem4",color:"piece4",role:"attack",element:"light"},{index:4,art:"gem5",color:"piece5",role:"attack",element:"dark"},{index:5,art:"m3_heart",color:"danger",role:"heal"},{index:6,art:"m3_shield",color:"primary",role:"shield"},{index:7,art:"gem6",color:"piece6",role:"attack"}],ns=e=>Ki.find(t=>t.index===e),Fi=[{id:"goblin",cast:"foe5",element:"nature",hp:1,attack:1,every:3,size:.8},{id:"wolf",cast:"foe",element:"nature",hp:.8,attack:.7,every:2,size:.85},{id:"orc",cast:"foe",variant:5,element:"fire",hp:1.4,attack:1.3,every:3,skill:{kind:"sow",obstacle:"stone",count:2},size:.95},{id:"frost-imp",cast:"foe3",element:"water",hp:1,attack:.9,every:3,skill:{kind:"sow",obstacle:"ice",count:3},size:.85},{id:"spider",cast:"foe4",element:"dark",hp:1.1,attack:1,every:3,skill:{kind:"sow",obstacle:"chain",count:3},size:.85},{id:"golem",cast:"foe2",element:"light",hp:2,attack:1.5,every:4,skill:{kind:"sow",obstacle:"stone",count:3},size:1.05},{id:"slime-beast",cast:"foe2",variant:9,element:"water",hp:1.3,attack:1.1,every:3,skill:{kind:"sow",obstacle:"slime",count:2},size:.95},{id:"shaman",cast:"foe4",variant:7,element:"dark",hp:1,attack:.9,every:3,skill:{kind:"heal",share:.15},size:.9},{id:"troll",cast:"boss",element:"nature",hp:3,attack:1.6,every:3,skill:{kind:"sow",obstacle:"stone",count:3},boss:true,enrage:.5,size:1.2},{id:"frost-queen",cast:"boss",variant:4,element:"water",hp:3.5,attack:1.5,every:3,skill:{kind:"sow",obstacle:"ice",count:5},boss:true,enrage:.5,size:1.2},{id:"spider-queen",cast:"boss",variant:9,element:"dark",hp:4,attack:1.7,every:3,skill:{kind:"sow",obstacle:"chain",count:4},boss:true,enrage:.5,size:1.2},{id:"lich",cast:"boss",variant:13,element:"dark",hp:4.5,attack:1.8,every:3,skill:{kind:"sow",obstacle:"slime",count:3},boss:true,enrage:.5,size:1.25}],os=e=>Fi.find(t=>t.id===e),Us=100,gd=4,bd=1.5,xd=2,kd=1,qi=[{id:"blast",art:"m3_skill_blast",mana:30,kind:"shape",shape:"area:1",bigShape:"area:2",bigAt:1.5,damage:6},{id:"cross",art:"m3_skill_cross",mana:28,kind:"shape",shape:"cross",bigShape:"cross:1",bigAt:1.5,damage:5},{id:"storm",art:"m3_skill_storm",mana:34,kind:"storm",count:4,damage:4}],Xs=e=>qi.find(t=>t.id===e),so=[{id:"hero",cast:"hero",gems:0,element:"fire",skill:"blast"},{id:"hero2",cast:"hero2",gems:150,element:"light",skill:"cross"},{id:"hero3",cast:"hero3",gems:300,element:"water",skill:"storm"}],Zs={plain:["--------","--------","--------","--------","--------","--------","--------","--------"],diamond:["..----..",".------.","--------","--------","--------","--------",".------.","..----.."],"ice-mid":["--------","--------","--iiii--","--iiii--","--iiii--","--iiii--","--------","--------"],"ice-low":["--------","--------","--------","--------","iiiiiiii","iiiiiiii","IIIIIIII","IIIIIIII"],stones:["--------","--------","--------","ss-ss-ss","--------","--------","--------","--------"],chains:["--------","-c----c-","--c--c--","---cc---","---cc---","--c--c--","-c----c-","--------"],cages:["--------","-g----g-","--------","---gg---","--------","--------","-g----g-","--------"],slime:["--------","--------","--------","--------","--------","--------","mm----mm","mmm--mmm"],hourglass:["--------","--------",".------.","..----..","..----..",".------.","--------","--------"],ring:["--------","--------","--------","---..---","---..---","--------","--------","--------"],"ice-stone":["--------","-S----S-","--IIII--","--IIII--","--IIII--","--IIII--","-S----S-","--------"],fortress:["s------s","-iiiiii-","-i-cc-i-","-ic--ci-","-ic--ci-","-i-cc-i-","-iiiiii-","s------s"],"slime-cages":["-g----g-","--------","--------","---mm---","---mm---","--------","--------","-g----g-"],"cross-holes":["---..---","--------","--------",".------.",".------.","--------","--------","---..---"]},$t=(e,t,r,o,n)=>({kind:"goal",board:e,moves:t,colors:r,goals:o,...n?{drops:n}:{}}),nr=(e,t,...r)=>({kind:"battle",board:e,elements:t,enemies:r}),xr=(e,t)=>({kind:"color",color:e,count:t}),Rt=e=>({kind:"clear",obstacle:e}),es=e=>({kind:"drops",count:e}),Qs=[$t("plain",20,5,[xr(0,12),xr(1,12)]),$t("diamond",20,5,[xr(2,15),xr(3,15)]),nr("plain",3,"goblin"),$t("ice-mid",22,5,[Rt("ice")]),$t("ring",20,5,[xr(0,20),xr(4,20)]),nr("plain",3,"goblin","wolf"),$t("stones",22,5,[Rt("stone"),xr(1,15)]),$t("ice-low",25,5,[Rt("ice")]),nr("diamond",3,"wolf","orc"),nr("plain",3,"troll"),$t("chains",24,5,[Rt("chain")]),$t("plain",25,5,[es(3)],3),nr("plain",4,"frost-imp","goblin"),$t("cages",22,5,[Rt("cage")]),$t("slime",25,5,[Rt("slime")]),nr("ice-mid",4,"orc","frost-imp"),$t("hourglass",24,5,[es(3),xr(2,20)],3),$t("ice-low",26,5,[Rt("ice")]),nr("plain",4,"spider","frost-imp","wolf"),nr("plain",4,"frost-queen"),$t("ice-stone",26,5,[Rt("ice"),Rt("stone")]),$t("cross-holes",26,6,[xr(0,20),xr(3,20)]),nr("chains",4,"spider","golem"),$t("fortress",28,5,[Rt("ice"),Rt("chain")]),$t("slime-cages",26,5,[Rt("cage"),Rt("slime")]),nr("plain",4,"slime-beast","golem"),$t("diamond",28,5,[es(3)],3),$t("ice-low",28,5,[Rt("ice"),xr(4,20)]),nr("ring",5,"shaman","golem","spider"),nr("plain",5,"spider-queen"),$t("fortress",28,6,[Rt("ice"),Rt("chain")]),$t("slime",28,5,[Rt("slime"),es(3)],3),nr("ice-stone",5,"golem","shaman"),$t("ice-stone",28,6,[Rt("ice"),Rt("stone")]),$t("slime-cages",28,6,[Rt("cage"),Rt("slime")]),nr("plain",5,"slime-beast","shaman","orc"),$t("cross-holes",30,5,[es(3),xr(1,18)],3),$t("fortress",32,5,[Rt("ice"),Rt("chain"),xr(2,15)]),nr("diamond",5,"golem","shaman","spider"),nr("plain",5,"lich")],ts=10,vd=4,Ys=Qs.length,Ui=[0,18,45,75];function Hh(e){return e.kind==="goal"?[0,1,2,3,4,7].slice(0,Math.max(3,Math.min(6,e.colors))):[...[0,1,2,3,4].slice(0,Math.max(2,Math.min(5,e.elements))),5,6]}function ao(e,t=.5){let r=Math.max(1,Math.min(Ys,Math.floor(e))),o=Qs[r-1],n=Math.ceil(r/ts),s=o.kind==="battle"&&o.enemies.some(a=>os(a)?.boss);return {level:r,world:n,index:r-(n-1)*ts,def:o,boss:s,colors:Hh(o),enemyHp:180*Math.pow(1.07,r-1)*(.8+t*.4),enemyAttack:14*Math.pow(1.06,r-1)*(.8+t*.4),firstClearGold:(s?120:50)+(r-1)*10}}var Xi=e=>Ui[Math.ceil(Math.max(1,e)/ts)-1]??0,Zi=(e,t)=>t?e>=.7?3:e>=.35?2:1:e>=.3?3:e>=.1?2:1,$d=5,Md=.5,Qi="kit-match3",Yi=[{id:"Attack",var:"meta:attack",art:"m3_skill_blast",color:"danger",perLevel:5,unit:"%",maxLevel:20,price:40,growth:.12},{id:"Health",var:"meta:health",art:"m3_heart",color:"danger",perLevel:6,unit:"%",maxLevel:20,price:40,growth:.12},{id:"Defense",var:"meta:defense",art:"m3_shield",color:"primary",perLevel:5,unit:"%",maxLevel:15,price:45,growth:.12},{id:"SkillPower",var:"meta:skill",art:"m3_skill_cross",color:"secondary",perLevel:8,unit:"%",maxLevel:10,price:50,growth:.12},{id:"ManaGain",var:"meta:mana",art:"m3_skill_storm",color:"secondary",perLevel:5,unit:"%",maxLevel:10,price:50,growth:.12},{id:"Moves",var:"meta:moves",art:"m3_bomb",color:"coin",perLevel:1,unit:"",maxLevel:5,price:120,growth:.2}],wd={game:"match3",character:Qi,stats:Yi,heroes:so,levels:Ys,firstClearGold:e=>ao(e).firstClearGold,stars:3,starsToEnter:Xi};var tl=()=>({cleared:[],created:[],fired:[],hits:[],spawned:[],dropsCollected:0,slimeCleared:false}),rl=-1,Qr=-2,ta=(e,t,r)=>t>=0&&r>=0&&t<e.cols&&r<e.rows,mn=(e,t,r)=>ta(e,t,r)?e.cells[r][t]:null,ra=(e,t)=>t[Math.floor(e.rnd()*t.length)%t.length],Ed=[[1,0],[-1,0],[0,1],[0,-1]],Ji=e=>e.hole||e.block!==null||e.over!==null,Wh=e=>e!==null&&e.color>=0;function na(e,t,r,o,n=0){let s={cols:e[0].length,rows:e.length,cells:e.map(a=>[...a].map(i=>{let h=o[i]??{};return {hole:h.hole===true,piece:null,under:h.under?{...h.under}:null,over:h.over?{...h.over}:null,block:h.block?{...h.block}:null}})),colors:t,nextId:1,dropsToSpawn:n,rnd:r};return el(s),s}var ea=(e,t,r=null)=>({id:e.nextId++,color:t,special:r});function el(e){for(let t=0;t<50;t++){for(let r=0;r<e.rows;r++)for(let o=0;o<e.cols;o++){let n=e.cells[r][o];if(n.hole||n.block||n.piece&&n.piece.color<0||n.piece?.special)continue;let s=new Set,a=mn(e,o-1,r)?.piece,i=mn(e,o-2,r)?.piece;a&&i&&a.color>=0&&a.color===i.color&&s.add(a.color);let h=mn(e,o,r-1)?.piece,m=mn(e,o,r-2)?.piece;h&&m&&h.color>=0&&h.color===m.color&&s.add(h.color);let v=e.colors.filter(D=>!s.has(D)),x=ra(e,v.length>0?v:e.colors);n.piece?n.piece.color=x:n.piece=ea(e,x);}if(io(oa(e)).size===0&&lo(e)!==null)return}}function nl(e){for(let t=0;t<e.rows;t++)for(let r=0;r<e.cols;r++){let o=e.cells[t][r].piece;o&&o.color>=0&&!o.special&&!e.cells[t][r].over&&(o.color=-100);}for(let t=0;t<e.rows;t++)for(let r=0;r<e.cols;r++)e.cells[t][r].piece?.color===-100&&(e.cells[t][r].piece.color=ra(e,e.colors));if(el(e),lo(e)===null){for(let t of e.cells)for(let r of t)r.over=null;el(e);}}var oa=e=>e.cells.map(t=>t.map(r=>r.piece&&r.piece.color>=0&&!r.block?r.piece.color:null));function io(e){let t=new Set;for(let r of Sd(e))for(let[o,n]of r.cells)t.add(`${o},${n}`);return t}function Sd(e){let t=[],r=e.length,o=e[0]?.length??0;for(let n=0;n<r;n++)for(let s=0;s<o;){let a=e[n][s],i=1;for(;a!=null&&s+i<o&&e[n][s+i]===a;)i++;a!=null&&i>=3&&t.push({cells:Array.from({length:i},(h,m)=>[s+m,n]),dir:"h"}),s+=i;}for(let n=0;n<o;n++)for(let s=0;s<r;){let a=e[s][n],i=1;for(;a!=null&&s+i<r&&e[s+i][n]===a;)i++;a!=null&&i>=3&&t.push({cells:Array.from({length:i},(h,m)=>[n,s+m]),dir:"v"}),s+=i;}return t}function ol(e){return jh(e)!==null}function jh(e){let t=e.length,r=e[0]?.length??0,o=(n,s)=>{let a=e[n[1]][n[0]];e[n[1]][n[0]]=e[s[1]][s[0]],e[s[1]][s[0]]=a;};for(let n=0;n<t;n++)for(let s=0;s<r;s++)for(let[a,i]of [[1,0],[0,1]]){if(s+a>=r||n+i>=t||e[n][s]===null||e[n+i][s+a]===null)continue;o([s,n],[s+a,n+i]);let h=io(e).size>0;if(o([s,n],[s+a,n+i]),h)return [[s,n],[s+a,n+i]]}return null}function ss(e,t,r){if(Math.abs(t.col-r.col)+Math.abs(t.row-r.row)!==1)return false;let o=mn(e,t.col,t.row),n=mn(e,r.col,r.row);if(!o||!n)return false;for(let s of [o,n])if(s.hole||s.block||s.over||!s.piece)return false;return true}function lo(e){let t=oa(e);for(let r=0;r<e.rows;r++)for(let o=0;o<e.cols;o++)for(let[n,s]of [[1,0],[0,1]]){let a={col:o,row:r},i={col:o+n,row:r+s};if(!ss(e,a,i))continue;let h=e.cells[r][o].piece,m=e.cells[i.row][i.col].piece;if(h.color===Qr&&m.color===Qr)continue;if(h.special==="rainbow"||m.special==="rainbow")return [a,i];if(h.special&&m.special)return [a,i];let v=t[r][o];t[r][o]=t[i.row][i.col],t[i.row][i.col]=v;let x=io(t).size>0;if(t[i.row][i.col]=t[r][o],t[r][o]=v,x)return [a,i]}return null}function sl(e){let t=new Map;for(let r=0;r<e.rows;r++)for(let o=0;o<e.cols;o++){let n=e.cells[r][o].piece;n&&t.set(n.id,{col:o,row:r,piece:n});}return t}function sa(e,t){let r=0;for(let o of e.cells)for(let n of o)for(let s of [n.under,n.over,n.block])s?.id===t&&r++;return r}function al(e,t,r){if(!ss(e,t,r))return null;let o=e.cells[t.row][t.col],n=e.cells[r.row][r.col],s=o.piece,a=n.piece;if(s.special==="rainbow"||a.special==="rainbow"||s.special&&a.special){o.piece=a,n.piece=s;let h=tl();return Fh(e,h,r,s,t,a),fl(e,h),h}o.piece=a,n.piece=s;let i=Ld(e,[t,r]);return i||(o.piece=s,n.piece=a,null)}function aa(e){return Ld(e,[])}function ia(e,t,r="skill"){let o=tl(),n=t.filter(s=>ta(e,s.col,s.row)).map(s=>({...s,match:false}));return t[0]&&o.fired.push({...t[0],kind:r}),cl(e,o,n),fl(e,o),o}function il(e,t){let r=[];if(t)return r;let o=Object.values(Zr).filter(n=>n.spreads);for(let n of o){let s=[];for(let h=0;h<e.rows;h++)for(let m=0;m<e.cols;m++)e.cells[h][m].under?.id===n.id&&s.push({col:m,row:h});if(s.length===0)continue;let a=[];for(let h of s)for(let[m,v]of Ed){let x=mn(e,h.col+m,h.row+v);x&&!x.hole&&!x.block&&!x.under&&a.push({col:h.col+m,row:h.row+v});}if(a.length===0)continue;let i=ra(e,a);e.cells[i.row][i.col].under={id:n.id,hp:1},r.push(i);}return r}function ll(e,t,r){let o=Zr[t];if(!o)return [];let n=[];for(let i=0;i<e.rows;i++)for(let h=0;h<e.cols;h++){let m=e.cells[i][h];m.hole||m.block||!m.piece||m.piece.color<0||m.piece.special||o.layer==="under"&&m.under||o.layer==="over"&&m.over||n.push({col:h,row:i});}let s=[],a=o.max===void 0?r:Math.max(0,o.max-sa(e,t));for(let i=0;i<Math.min(r,a)&&n.length>0;i++){let h=Math.floor(e.rnd()*n.length)%n.length,m=n.splice(h,1)[0],v=e.cells[m.row][m.col],x={id:t,hp:o.hp};o.layer==="under"?v.under=x:o.layer==="over"?v.over=x:(v.block=x,v.piece=null),s.push(m);}return s}function la(e,t,r){let o=[];for(let s=0;s<e.rows;s++)for(let a=0;a<e.cols;a++){let i=e.cells[s][a].piece;i&&i.color>=0&&!i.special&&!e.cells[s][a].over&&o.push({col:a,row:s});}let n=[];for(let s=0;s<r&&o.length>0;s++){let a=o.splice(Math.floor(e.rnd()*o.length)%o.length,1)[0];e.cells[a.row][a.col].piece.special=e.rnd()<.5?"row":"col",n.push(a);}return n}function Ld(e,t){let r=Sd(oa(e));if(r.length===0)return null;let o=tl(),n=[];for(let i of r){let h=new Set(i.cells.map(([x,D])=>`${x},${D}`)),m=n.filter(x=>x.some(D=>D.cells.some(([O,N])=>h.has(`${O},${N}`)))),v=[i,...m.flat()];for(let x of m)n.splice(n.indexOf(x),1);n.push(v);}let s=[],a=[];for(let i of n){let h=new Map;for(let D of i)for(let[O,N]of D.cells)h.set(`${O},${N}`,{col:O,row:N});let m=i.reduce((D,O)=>Math.max(D,O.cells.length),0),v=i.some(D=>D.dir==="h")&&i.some(D=>D.dir==="v"),x=Rn.filter(D=>D.make!==null).find(D=>D.make(m,v,i.find(O=>O.cells.length===m).dir));if(x){let D=t.find(N=>h.has(`${N.col},${N.row}`))??(v?Vh(i):null)??Gh(i.find(N=>N.cells.length===m)),O=e.cells[D.row][D.col].piece?.color??0;a.push({at:D,special:x.id,color:O});}for(let D of h.values())s.push({...D,match:true});}cl(e,o,s);for(let i of a){let h=e.cells[i.at.row][i.at.col];h.piece||h.block||h.hole||(h.piece=ea(e,i.special==="rainbow"?rl:i.color,i.special),o.created.push({...i.at,piece:h.piece}));}return fl(e,o),o}function Vh(e){let t=new Set;for(let r of e)for(let[o,n]of r.cells){let s=`${o},${n}`;if(t.has(s))return {col:o,row:n};t.add(s);}return null}var Gh=e=>{let[t,r]=e.cells[Math.floor(e.cells.length/2)];return {col:t,row:r}};function cl(e,t,r){let o=new Set,n=new Set;for(;r.length>0;){let s=r.shift(),a=`${s.col},${s.row}`;if(!ta(e,s.col,s.row))continue;let i=e.cells[s.row][s.col];if(i.hole)continue;if(i.block){!s.match&&!n.has(a)&&(n.add(a),Js(t,i,"block",s));continue}if(o.has(a))continue;o.add(a);let h=i.piece;if(h){if(i.over){Js(t,i,"over",s);continue}if(h.color!==Qr){if(i.piece=null,t.cleared.push({...s,piece:h}),i.under&&(i.under.id==="slime"&&(t.slimeCleared=true),Js(t,i,"under",s)),s.match)for(let[m,v]of Ed){let x=mn(e,s.col+m,s.row+v),D=`${s.col+m},${s.row+v}`;x?.block&&!n.has(D)&&Zr[x.block.id]?.hitByNear&&(n.add(D),Js(t,x,"block",{col:s.col+m,row:s.row+v}));}h.special&&Kh(e,t,h.special,s,h.color,r);}}}}function Js(e,t,r,o){let n=t[r];n.hp-=1,e.hits.push({...o,id:n.id,hp:Math.max(0,n.hp)}),n.hp<=0&&(t[r]=null);}function Kh(e,t,r,o,n,s){t.fired.push({...o,kind:r});let i=Rn.find(h=>h.id===r)?.shape??r;for(let h of dl(e,i,o,n))s.push({...h,match:false});}var ca=(e,t,r)=>dl(e,t,r,-1);function dl(e,t,r,o){let n=[],s=i=>{for(let h=0;h<e.cols;h++)n.push({col:h,row:i});},a=i=>{for(let h=0;h<e.rows;h++)n.push({col:i,row:h});};if(t==="row")s(r.row);else if(t==="col")a(r.col);else if(t==="cross")s(r.row),a(r.col);else if(t.startsWith("cross:")){let i=Number(t.slice(6));for(let h=-i;h<=i;h++)s(r.row+h),a(r.col+h);}else if(t.startsWith("area:")){let i=Number(t.slice(5));for(let h=-i;h<=i;h++)for(let m=-i;m<=i;m++)n.push({col:r.col+m,row:r.row+h});}else if(t==="color"){let i=o>=0?o:_d(e);for(let h=0;h<e.rows;h++)for(let m=0;m<e.cols;m++)e.cells[h][m].piece?.color===i&&n.push({col:m,row:h});}else if(t==="all")for(let i=0;i<e.rows;i++)s(i);return n.filter(i=>ta(e,i.col,i.row))}function _d(e){let t=new Map;for(let n of e.cells)for(let s of n)Wh(s.piece)&&!s.block&&t.set(s.piece.color,(t.get(s.piece.color)??0)+1);let r=e.colors[0]??0,o=-1;for(let[n,s]of t)s>o&&(o=s,r=n);return r}function Fh(e,t,r,o,n,s){let a=[],i=o.special??"plain",h=s.special??"plain",m=yd.find(x=>x.a===i&&x.b===h||x.a===h&&x.b===i);e.cells[r.row][r.col].piece=null,e.cells[n.row][n.col].piece=null,t.cleared.push({...r,piece:o},{...n,piece:s}),t.fired.push({...n,kind:m?.effect??"combo"});let v=i==="rainbow"?s:o;if(m?.effect==="color"||m?.effect==="turn"){let x=v.color>=0?v.color:_d(e);for(let D=0;D<e.rows;D++)for(let O=0;O<e.cols;O++){let N=e.cells[D][O].piece;N?.color===x&&(m.effect==="turn"&&v.special&&v.special!=="rainbow"&&(N.special=v.special==="row"||v.special==="col"?e.rnd()<.5?"row":"col":v.special),a.push({col:O,row:D,match:false}));}}else for(let x of dl(e,m?.effect??"cross",n,v.color))a.push({...x,match:false});cl(e,t,a);}function fl(e,t){for(let r=0;r<4;r++){for(let n=0;n<e.cols;n++){let s=e.rows-1;for(;s>=0;){if(Ji(e.cells[s][n])){s--;continue}let a=s;for(;a-1>=0&&!Ji(e.cells[a-1][n]);)a--;let i=[];for(let v=s;v>=a;v--){let x=e.cells[v][n].piece;x&&i.push(x);}let h=s;for(let v of i)e.cells[h--][n].piece=v;let m=-1;for(;h>=a;h--){let v=a===qh(e,n)&&e.dropsToSpawn>0&&Xh(e)<2&&e.rnd()<.35,x=v?ea(e,Qr):ea(e,ra(e,e.colors));v&&e.dropsToSpawn--,e.cells[h][n].piece=x,t.spawned.push({col:n,row:h,piece:x,from:a+m--});}s=a-1;}}let o=false;for(let n=0;n<e.cols;n++){let s=Uh(e,n);if(s<0)continue;let a=e.cells[s][n];a.piece?.color===Qr&&(a.piece=null,t.dropsCollected++,o=true);}if(!o)break}}var qh=(e,t)=>{for(let r=0;r<e.rows;r++)if(!Ji(e.cells[r][t]))return r;return -1},Uh=(e,t)=>{for(let r=e.rows-1;r>=0;r--)if(!e.cells[r][t].hole)return e.cells[r][t].block?-1:r;return -1},Xh=e=>{let t=0;for(let r of e.cells)for(let o of r)o.piece?.color===Qr&&t++;return t};var Zh="boss-spawned",Qh="boss-defeated",yn=ve("match3.gem"),Rd=ve("match3.overlay"),pl=ve("match3.layer"),Ad=ve("match3.backdrop"),Td=ve("match3.part"),Yr=(e,t)=>{let r=Number(e.vars[t]??0);return Number.isFinite(r)?r:0},da={id:"match3",version:2,engines:["phaser"],requires:["round"],params:{difficulty:{type:"number",default:.5,min:0,max:1},pieceScore:{type:"number",default:10,min:1,max:1e3,integer:true},coinEvery:{type:"number",default:8,min:1,max:100,integer:true},moveBonus:{type:"number",default:100,min:0,max:1e4,integer:true}},setup({world:e,params:t}){let r=M=>yr(t,M),o=e.rng.stream("match3"),n=ao(1,r("difficulty")),s=na(Zs.plain,[0,1,2,3,4],()=>o.next(),Gi),a=Qt(),i="idle",h=new Map,m=new Map,v=null,x=null,D=null,O=null,N=0,q=false,ne=0,Z=0,ye=0,be=0,fe=0,Ee=false,de=false,Ae={colors:new Map,drops:0},Pe=Us,we=Us,ce=0,ke=0,Le=false,_e=[],oe=null,Te=0,Ke=0,Ne=0,se=null,Ie=[],$e=new Map,Se=()=>so.find(M=>M.id===e.vars["meta:hero"])??so[0],Ye=()=>Xs(Se().skill),ee=()=>n.def.kind==="battle",Re=()=>e.vars.reviving===true,rt=()=>gd*Math.pow(1.06,n.level-1)*(1+Yr(e,"meta:attack")),ht=()=>1+Yr(e,"meta:skill"),De=()=>Ye().mana;function Qt(){return un(Be(e),s.cols,s.rows,{top:.33,bottom:.96,widthShare:.94})}let Xe=()=>a.cell,et=new Set,it=(M,E,l,w,A=1)=>{et.add(M);let d=$e.get(M);(d===void 0||!e.isAlive(d))&&(d=e.create(),e.set(d,Td,{id:M}),$e.set(M,d)),e.set(d,F,{x:E,y:l,scale:A}),e.set(d,le,w);},dt=M=>{for(let[E,l]of [...$e])E.startsWith(M)&&(e.destroy(l),$e.delete(E));},mt=M=>{let E=Xe();if(M===rl)return {shape:"sprite",art:"m3_rainbow",w:E*.9,h:E*.9,depth:3};if(M===Qr)return {shape:"sprite",art:"m3_crate",w:E*.86,h:E*.86,depth:3};let l=ns(M);return {shape:"sprite",art:l?.art??"gem1",w:E*.88,h:E*.88,color:l?.color??"piece1",depth:3}},yt=(M,E,l,w,A)=>{let d=st(a,E,A),y=e.create();return e.set(y,yn,{id:M,col:E,row:l,kind:w}),e.set(y,F,{x:d.x,y:d.y}),e.set(y,le,mt(w)),h.set(M,y),y},gt=()=>{let M=sl(s);for(let[E,l]of [...h])M.has(E)||(e.destroy(l),h.delete(E));for(let[E,l]of M){let w=h.get(E);w===void 0&&(w=yt(E,l.col,l.row,l.piece.color,l.row-s.rows));let A=e.need(w,yn);A.col=l.col,A.row=l.row,A.kind!==l.piece.color&&(A.kind=l.piece.color,e.set(w,le,mt(l.piece.color)));let d=l.piece.special&&l.piece.special!=="rainbow"?Rn.find(R=>R.id===l.piece.special):void 0,y=m.get(E);d&&y===void 0&&(y=e.create(),e.set(y,Rd,{of:E}),e.set(y,F,{x:0,y:0}),m.set(E,y)),d&&y!==void 0&&e.set(y,le,{shape:"sprite",art:d.art,w:Xe()*.95,h:Xe()*.95,depth:4}),!d&&y!==void 0&&(e.destroy(y),m.delete(E));}for(let[E,l]of [...m])M.has(E)||(e.destroy(l),m.delete(E));ft();},ft=()=>{ct(e,pl);let M=Xe();for(let E=0;E<s.rows;E++)for(let l=0;l<s.cols;l++){let w=s.cells[E][l],A=st(a,l,E),d=(y,R,S,$=1)=>{if(!R)return;let g=Zr[R.id],L=e.create();e.set(L,pl,{key:y}),e.set(L,F,{x:A.x,y:A.y}),e.set(L,le,{shape:"sprite",art:R.hp>=2&&g?.id==="ice"?"m3_ice2":R.hp>=2&&g?.id==="stone"?"m3_stone2":g?.art??"m3_stone",w:M*$,h:M*$,depth:S});};d(`u${l},${E}`,w.under,1.5,.98),d(`o${l},${E}`,w.over,5,.98),d(`b${l},${E}`,w.block,3,.95);}},ze=()=>{ct(e,Ad),Bt(e,"board",a.top+a.cell*s.rows*.35);let M=Xe(),E=st(a,(s.cols-1)/2,(s.rows-1)/2),l=M*.25,w=(A,d,y)=>{let R=e.create();e.set(R,Ad,{i:0}),e.set(R,F,{x:A,y:d}),e.set(R,le,y);};w(E.x,E.y,{shape:"sprite",art:"panel",w:M*s.cols+l*2,h:M*s.rows+l*2,color:"panel",alpha:.9,depth:-10});for(let A=0;A<s.rows;A++)for(let d=0;d<s.cols;d++){if(s.cells[A][d].hole)continue;let y=st(a,d,A);w(y.x,y.y,{shape:"sprite",art:"cell",w:M-2,h:M-2,color:(A+d)%2?"panel":"ground",alpha:.85,depth:-9});}},Et=()=>{let M=Be(e),E=M.h*.12,l=a.top-Xe()*.4,w=Math.max(40,(l-E)*.92);if((se===null||!e.isAlive(se))&&(se=e.create()),e.set(se,F,{x:M.w*.15,y:l-w/2}),e.set(se,le,{shape:"actor",cast:Se().cast,h:w,pose:"idle",facing:1,depth:20}),oe&&e.isAlive(oe.entity)){let A=w*oe.def.size;e.set(oe.entity,F,{x:M.w*.82,y:l-A/2});let d=e.need(oe.entity,le);d.shape==="actor"&&(d.h=A);}},Ze=()=>n.def.kind!=="goal"?[]:n.def.goals.map(M=>({goal:M,left:M.kind==="color"?Math.max(0,M.count-(Ae.colors.get(M.color)??0)):M.kind==="clear"?sa(s,M.obstacle):M.kind==="drops"?Math.max(0,M.count-Ae.drops):Math.max(0,M.value-Number(e.vars.score??0))})),Wt=()=>Ze().every(M=>M.left===0),hr=M=>{let E=Be(e).w*.07;if(M.kind==="color"){let l=ns(M.color);return {shape:"sprite",art:l?.art??"gem1",w:E,h:E,color:l?.color??"piece1",depth:70}}return M.kind==="clear"?{shape:"sprite",art:Zr[M.obstacle]?.art??"m3_stone",w:E,h:E,depth:70}:M.kind==="drops"?{shape:"sprite",art:"m3_crate",w:E,h:E,depth:70}:{shape:"sprite",art:"coin",w:E,h:E,depth:70}},Nt=(M,E,l,w,A,d)=>{let y=Math.max(8,w*.09);it(`${M}:bg`,E,l,{shape:"rect",w,h:y,color:"#000000",alpha:.5,radius:y/2,depth:69});let R=Math.max(1,(w-4)*Math.max(0,Math.min(1,A)));it(`${M}:fill`,E-(w-4)/2+R/2,l,{shape:"rect",w:R,h:y-4,color:d,radius:(y-4)/2,depth:69.1});},ur=()=>{let M=Be(e),E=Math.min(M.w,M.h),l=($,g,L,I,P="text",W=E*.045)=>it($,g,L,{shape:"text",text:I,size:Math.round(W),color:P,bold:true,depth:70}),w=a.top-Xe()*.4,A=M.h*.085;Ie=[],et.clear();let d=M.w*.36,y=(A+w)/2+E*.02,R=E*.07,S=ke>=De();if(Ie.push({id:"skill",x:d,y,r:R*1.15}),S&&it("h:skill:glow",d,y,{shape:"circle",r:R*1.25,color:Le?"coin":"secondary",alpha:.5+.3*Math.sin(e.time*7),depth:68.9}),it("h:skill:bg",d,y,{shape:"circle",r:R,color:"panel",alpha:.95,depth:69}),it("h:skill:i",d,y,{shape:"sprite",art:Ye().art,w:R*1.4,h:R*1.4,alpha:S?1:.45,depth:69.2}),Nt("h:mana",d,y+R*1.45,R*2.2,ke/De(),"secondary"),ee()){let $=M.w*.15;if(Nt("h:hp",$,A,M.w*.24,Pe/we,"accent"),l("h:hp:t",$+M.w*.12+E*.05,A,`${Math.ceil(Pe)}`,"text",E*.034),ce>0&&(it("h:sh:i",$+M.w*.12+E*.05,A+E*.055,{shape:"sprite",art:"m3_shield",w:E*.045,h:E*.045,color:"primary",depth:70}),l("h:sh:t",$+M.w*.12+E*.11,A+E*.055,`${Math.ceil(ce)}`,"primary",E*.03)),oe){let g=M.w*.78;Nt("h:foe",g,A,M.w*.26,oe.hp/oe.max,"danger"),l("h:foe:t",g-M.w*.13-E*.05,A,`${Math.ceil(oe.hp)}`,"text",E*.034);let L=rs[oe.def.element];it("h:foe:el",g+M.w*.13+E*.03,A,{shape:"circle",r:E*.018,color:L.color,depth:70});let I=(A+w)/2;it("h:foe:in:bg",M.w*.62,I,{shape:"circle",r:E*.045,color:oe.in<=1?"danger":"panel",alpha:.95,depth:69}),l("h:foe:in",M.w*.62,I,String(oe.in),"text",E*.045);let P=n.def.kind==="battle"?n.def.enemies.length:0;for(let W=0;W<P;W++)it(`h:q:${W}`,M.w*.8+(W-(P-1)/2)*E*.04,w+E*.005,{shape:"circle",r:E*.012,color:W<Te?"muted":W===Te?"danger":"text",alpha:.9,depth:70});}}else {l("h:moves",M.w*.5,A+E*.01,String(Z),Z<=3?"danger":"text",E*.075);let $=Ze(),g=M.w*.64,L=M.w*.11,I=(A+w)/2+E*.02;$.forEach((P,W)=>{let te=g+W*L;it(`h:g:${W}`,te,I,hr(P.goal)),l(`h:g:${W}:t`,te,I+E*.06,P.left===0?"\u2713":String(P.left),P.left===0?"accent":"text",E*.038);});}e.vars.m3_phase=i,e.vars.m3_buttons=Ie.map($=>`${$.id}@${Math.round($.x)},${Math.round($.y)}`).join(";");for(let[$,g]of [...$e])!$.startsWith("h:")||et.has($)||(e.destroy(g),$e.delete($));},Tt=()=>{oe&&e.isAlive(oe.entity)&&at(e,oe.entity,"die");let M=_e.shift();if(M===void 0){oe=null;return}let E=os(M),l=e.create();e.set(l,F,{x:0,y:0}),e.set(l,le,{shape:"actor",cast:E.cast,variant:E.variant??o.int(0,99),h:50,pose:"idle",facing:-1,depth:20});let w=E.hp*n.enemyHp;oe={def:E,hp:w,max:w,in:E.every,rage:1,entity:l},Et(),E.boss&&(e.emit(Zh,{kind:M}),K(e,{kind:"shake",power:1})),T();},T=()=>{if(e.vars.moves=Z,e.vars.hero_hp=Math.ceil(Pe),e.vars.mana=Math.floor(ke),e.vars.m3_goals=Ze().map(M=>`${M.goal.kind==="color"?`color${M.goal.color}`:M.goal.kind==="clear"?M.goal.obstacle:M.goal.kind}:${M.left}`).join(","),e.vars.m3_enemy=oe?`${oe.def.id}:${Math.ceil(oe.hp)}/${Math.ceil(oe.max)}:${oe.in}`:"",ee()){let M=n.def.kind==="battle"?n.def.enemies.length:1;e.vars.level_progress=Math.min(1,(Te+(oe?1-oe.hp/oe.max:0))/M);}else {let M=n.def;if(M.kind==="goal"){let E=M.goals.map(w=>w.kind==="color"||w.kind==="drops"?w.count:w.kind==="score"?w.value:1),l=Ze();e.vars.level_progress=l.reduce((w,A,d)=>w+(A.goal.kind==="clear"?A.left===0?1:0:1-A.left/E[d]),0)/Math.max(1,l.length);}}},H=()=>{ct(e,yn),ct(e,Rd),ct(e,pl),ct(e,Td),h.clear(),m.clear(),$e.clear(),oe&&e.isAlive(oe.entity)&&e.destroy(oe.entity),oe=null,n=ao(Yr(e,"meta:chapter")||1,r("difficulty"));let M=n.def;s=na(Zs[M.board]??Zs.plain,n.colors,()=>o.next(),Gi,M.kind==="goal"?M.drops??0:0),a=Qt(),ze(),i="idle",v=null,x=null,D=null,O=null,N=0,q=false,ne=0,Ae.colors.clear(),Ae.drops=0,Z=M.kind==="goal"?M.moves+Yr(e,"meta:moves"):0,ye=Z,be=0,fe=0,Ee=false,de=false,we=Us*Math.pow(1.06,n.level-1)*(1+Yr(e,"meta:health")),Pe=we,ce=0,ke=0,Le=false,Te=0,Ke=0,Ne=0,_e=M.kind==="battle"?[...M.enemies]:[],e.vars.m3_level=n.level,e.vars.m3_world=n.world,e.vars.m3_kind=M.kind,e.vars.coins=0,e.vars.score=0,e.vars.stars=0,e.vars.reviving=false,gt(),Et(),M.kind==="battle"&&Tt(),T();},u=M=>{if(!M||!oe)return 1;let E=rs[M].beats.includes(oe.def.element),l=M===oe.def.element;return (E?1.5:l?.5:1)*(M===Se().element?1.25:1)},f=(M,E=0)=>{N++,q||=M.slimeCleared,Ae.drops+=M.dropsCollected;let l=E,w=0,A=0,d=Xe();for(let $ of M.cleared){let g=$.piece;g.color>=0&&Ae.colors.set(g.color,(Ae.colors.get(g.color)??0)+1);let L=ns(g.color),I=st(a,$.col,$.row);K(e,{kind:"burst",x:I.x,y:I.y,color:L?.color??"coin",n:6,size:d*.8}),ke=Math.min(De(),ke+kd*(1+Yr(e,"meta:mana"))),!(!ee()||!L)&&(L.role==="attack"?l+=rt()*u(L.element)*(1+.25*(N-1)):L.role==="heal"?w+=bd*Math.pow(1.06,n.level-1)*(1+Yr(e,"meta:health")):L.role==="shield"&&(A+=xd*Math.pow(1.06,n.level-1)*(1+Yr(e,"meta:defense"))));}for(let $ of M.fired){let g=st(a,$.col,$.row);K(e,{kind:"ring",x:g.x,y:g.y,color:"coin",size:d*2.4});}M.fired.length>0&&K(e,{kind:"shake",power:.4+Math.min(1,M.fired.length*.2)});for(let $ of M.created)e.emit("special-made",{kind:$.piece.special});let y=M.cleared.length*r("pieceScore")*N+M.fired.length*30;Qe(e,"score",y),ne+=M.cleared.length;let S=Math.floor(ne/r("coinEvery"))-Math.floor((ne-M.cleared.length)/r("coinEvery"));S>0&&(Qe(e,"coins",S),e.emit("coin-collected",{value:S})),e.emit("pieces-cleared",{count:M.cleared.length,cascade:N}),ee()&&(w>0&&(Pe=Math.min(we,Pe+w),se!==null&&K(e,{kind:"pop",x:e.need(se,F).x,y:e.need(se,F).y-d,text:`+${Math.round(w)}`,color:"accent",size:Math.round(d*.45)})),A>0&&(ce+=A),l>0&&oe&&b(l)),gt(),T();},b=M=>{if(!oe)return;oe.hp-=M,se!==null&&Ge(e,se,"attack"),Ge(e,oe.entity,"hit");let E=e.need(oe.entity,F);K(e,{kind:"pop",x:E.x,y:E.y-Xe(),text:`-${Math.round(M)}`,color:"danger",size:Math.round(Xe()*.5)}),!(oe.hp>0)&&(Te++,e.emit("enemy-defeated",{kind:oe.def.id}),c(),oe.def.boss&&(Ke++,Qe(e,"coins",10),e.emit(Qh,{kind:oe.def.id}),K(e,{kind:"flash",color:"coin"})),Tt());},c=()=>{if(!oe)return;at(e,oe.entity,"die");let M=oe.entity;e.need(M,le).alpha=.6,k(()=>{e.isAlive(M)&&e.destroy(M);});},p=[],k=M=>p.push({t:.9,f:M}),_=()=>{if(il(s,q),q=false,N=0,gt(),n.def.kind==="goal"){if(Wt())return B();if(Z<=0)return pe("out-of-moves")}else {if(!oe)return B();if(oe.in--,oe.in<=0){i="enemy",fe=.45;return}}C();},C=()=>{i="idle",lo(s)===null&&(nl(s),gt(),e.emit("board-shuffled",{})),T();},z=()=>{if(!oe)return C();let M=oe.def,E=n.enemyAttack*M.attack*oe.rage;oe.rage=1,Ge(e,oe.entity,"attack");let l=Math.min(ce,E);if(ce-=l,E=(E-l)*(1-Math.min(.6,Yr(e,"meta:defense"))),E>0){if(Pe-=E,se!==null){Ge(e,se,"hit");let A=e.need(se,F);K(e,{kind:"pop",x:A.x,y:A.y-Xe(),text:`-${Math.round(E)}`,color:"danger",size:Math.round(Xe()*.5)});}K(e,{kind:"shake",power:.8}),e.emit("player-hit",{hp:Math.ceil(Pe)});}let w=M.skill;if(w?.kind==="sow"?ll(s,w.obstacle,w.count):w?.kind==="heal"?oe.hp=Math.min(oe.max,oe.hp+oe.max*w.share):w?.kind==="rage"&&(oe.rage=w.mult),oe.in=M.enrage&&oe.hp<oe.max*M.enrage?Math.max(1,M.every-1):M.every,gt(),Pe<=0)return Pe=0,pe("fell");C();},B=()=>{if(n.def.kind==="goal"){Ne=Math.min(Z,12),e.vars.stars=Math.min(Ee?1:3,Zi(Z/Math.max(1,ye),false)),Qe(e,"score",Z*r("moveBonus")),i="finale",fe=.3;return}e.vars.stars=Math.min(Ee?1:3,Zi(Pe/we,true)),ae("cleared");},ae=M=>{if(de)return;de=true,i="over";let E=M==="cleared";E&&e.vars["meta:first_clear"]===true&&Qe(e,"coins",n.firstClearGold),E||(e.vars.stars=0),e.vars.reviving=false,T(),e.emit(Ut,{reason:M,stats:{chapter:n.level,seconds:Math.floor(be),cleared:E,stars:Number(e.vars.stars??0),coins:Number(e.vars.coins??0),bosses:Ke,kills:Te,battle:ee()}});},pe=M=>{if(e.vars.revive_ready===true&&!Ee){e.vars.reviving=true,e.vars.m3_revive_reason=M,i="idle",e.emit(er,{});return}ae(M);},Me=()=>{Re()&&(Ee=true,e.vars.reviving=false,ee()?(Pe=we*Md,oe&&(oe.in=oe.def.every)):Z+=$d,K(e,{kind:"flash",color:"coin"}),C());},qe=M=>{let E=s.cells[M.row]?.[M.col];if(!E||E.hole)return 0;let l=n.def.kind==="goal"?n.def.goals:[],w=0;for(let d of [E.under,E.over,E.block])d&&(w+=l.some(y=>y.kind==="clear"&&y.obstacle===d.id)?6:3);let A=E.piece;if(A&&!E.block){w+=1,A.special&&(w+=3),l.some(y=>y.kind==="color"&&y.color===A.color)&&(w+=2);let d=ns(A.color);ee()&&d?.role==="attack"&&(w+=u(d.element));}if(l.some(d=>d.kind==="drops"))for(let d=0;d<M.row;d++)s.cells[d][M.col].piece?.color===Qr&&(w+=2);return w},tt=M=>{let E={col:Math.floor(s.cols/2),row:Math.floor(s.rows/2)},l=-1;for(let w=0;w<s.rows;w++)for(let A=0;A<s.cols;A++){if(s.cells[w][A].hole)continue;let d=ca(s,M,{col:A,row:w}).reduce((y,R)=>y+qe(R),0);d>l&&(l=d,E={col:A,row:w});}return E},pt=()=>{let M=Ye();if(ke<M.mana||i!=="idle")return false;let E=ht(),l=[];if(M.kind==="shape"){let d=E>=(M.bigAt??99)&&M.bigShape?M.bigShape:M.shape??"area:1",y=tt(d);l=ca(s,d,y);let R=st(a,y.col,y.row);K(e,{kind:"ring",x:R.x,y:R.y,color:"coin",size:Xe()*4}),K(e,{kind:"flash",color:"coin"});}else l=la(s,"line",Math.round((M.count??3)*E));ke=0,Le=false,N=0,se!==null&&Ge(e,se,"attack"),e.emit("skill-cast",{id:M.id}),Lt(e,"m3-skill");let w=ee()&&oe?M.damage*rt()*E*u(Se().element):0,A=ia(s,l,M.id);return f(A,w),i="falling",true},re=M=>{if(D){let E=s.cells[D.row]?.[D.col]?.piece?.id,l=E!==void 0?h.get(E):void 0;l!==void 0&&(e.need(l,F).scale=1);}if(D=M,M){let E=s.cells[M.row]?.[M.col]?.piece?.id,l=E!==void 0?h.get(E):void 0;l!==void 0&&(e.need(l,F).scale=1.15);}},j=0,J=(M,E)=>{if(j=0,Ht(e),i!=="idle"||Re()||!ss(s,M,E))return;re(null);let l=s.cells[M.row][M.col].piece.id,w=s.cells[E.row][E.col].piece.id;v=new Map([[l,E],[w,M]]),x=[M,E],i="swapping",Lt(e,"match3-swap");};e.on(zt,M=>{let E=M;if(!(!ot(e)||hn(e)||de||Re()))if(E.type==="tap"){if(Ie.find(A=>Math.hypot(E.x-A.x,E.y-A.y)<=A.r)?.id==="skill"){if(ke<De())return;pt()||(Le=true);return}let w=Ur(a,E.x,E.y);if(!w||i!=="idle")return;D&&Math.abs(D.col-w.col)+Math.abs(D.row-w.row)===1?J(D,w):re(D&&D.col===w.col&&D.row===w.row?null:w);}else if(E.type==="press"){let l=Ur(a,E.x,E.y);O=l?{x:E.x,y:E.y,...l}:null;}else if(E.type==="move"&&O){let l=E.x-O.x,w=E.y-O.y;if(Math.max(Math.abs(l),Math.abs(w))<a.cell*.45)return;let A={col:O.col,row:O.row},d=Math.abs(l)>Math.abs(w)?{col:A.col+Math.sign(l),row:A.row}:{col:A.col,row:A.row+Math.sign(w)};O=null,J(A,d);}else E.type==="release"&&(O=null);}),e.on(qt,()=>{H(),e.vars.level=n.level;}),e.on(Zt,H),e.on(tr,Me),e.on(rr,()=>{Re()&&(e.vars.reviving=false,ae(ee()?"fell":"out-of-moves"));}),e.on(Xt,M=>{dt("h:"),Ie=[],se!==null&&e.isAlive(se)&&at(e,se,M.reason==="cleared"?"dance":"die");}),e.on(Ft,()=>{a=Qt(),ze();for(let[M,E]of h){let l=e.need(E,yn);e.set(E,le,mt(l.kind));}gt(),Et();});let Y=M=>{let E=true,l=Math.min(1,M*14),w=Xe();for(let A of e.query(yn)){let d=e.need(A,yn),y=v?.get(d.id)??d,R=e.need(A,F),S=st(a,y.col,y.row),$=S.x-R.x,g=S.y-R.y,L=e.need(A,le);Math.abs($)<.5&&Math.abs(g)<.5?(R.x=S.x,R.y=S.y,L.alpha=1):(E=false,L.alpha=R.y<a.top-w*.3?0:1,R.x+=$*l,R.y+=Math.abs(g)>w*.3?Math.sign(g)*Math.min(Math.abs(g),w*12*M):g*l);}for(let[A,d]of m){let y=h.get(A);if(y===void 0)continue;let R=e.need(y,F);e.set(d,F,{x:R.x,y:R.y,scale:1+.06*Math.sin(e.time*6)}),e.need(d,le).alpha=e.need(y,le).alpha??1;}return E};e.addSystem({id:"match3",order:0,run(M,E){for(let l of [...p])l.t-=E,l.t<=0&&(p.splice(p.indexOf(l),1),l.f());if(!ot(M)||de){Y(E);return}if(be+=E,ur(),!Re()&&Y(E)){if(fe>0){fe-=E;return}if(i==="swapping"&&x){let[l,w]=x;x=null,v=null,N=0;let A=al(s,l,w);if(!A){let d=s.cells[l.row][l.col].piece.id,y=s.cells[w.row][w.col].piece.id;v=new Map([[d,w],[y,l]]),i="returning";return}n.def.kind==="goal"&&Z--,f(A),i="falling";return}if(i==="returning"){if(v){v=null;return}i="idle";return}if(i==="falling"){let l=aa(s);if(l){f(l);return}_();return}if(i==="enemy"){z();return}if(i==="finale"){if(Ne>0){Ne--,Z=Math.max(0,Z-1);let w=la(s,"line",1);w.length>0&&f(ia(s,w,"finale")),gt(),fe=.12;return}let l=aa(s);if(l){f(l);return}ae("cleared");return}if(i==="idle"&&Le){pt();return}if(i==="idle"){if(j+=E,(!vt(M,"match3-swap")||j>7)&&!_r(M)){let l=lo(s);l&&kt(M,"swipe",st(a,l[0].col,l[0].row),st(a,l[1].col,l[1].row),a.cell*1.1);}if(ke>=De()&&!vt(M,"m3-skill")&&!_r(M)){let l=Ie.find(w=>w.id==="skill");l&&kt(M,"tap",l,void 0,a.cell*1.2);}}}}}),H();}};var as=[{id:"garden",prefix:"item",levels:8,color:"accent",gen:"mg_gen_garden"},{id:"bake",prefix:"mg_bake",levels:7,color:"coin",gen:"mg_gen_bake"},{id:"jewel",prefix:"mg_jewel",levels:7,color:"primary",gen:"mg_gen_jewel"},{id:"potion",prefix:"mg_potion",levels:7,color:"secondary",gen:"mg_gen_potion"}],Cr=e=>as.find(t=>t.id===e),hl=3,Dd=[0,.2,.35],Od=.06,gr={box:{id:"box",layer:"block",art:["mg_box","mg_box2"],neighbour:true,coins:1},fog:{id:"fog",layer:"cover",art:["mg_fog"],neighbour:true,hides:true},web:{id:"web",layer:"cover",art:["mg_web"],neighbour:true,mergeInto:true},bubble:{id:"bubble",layer:"cover",art:["mg_bubble"],neighbour:false,mergeInto:true,ttl:14}},ul=[{id:"joker",art:"mg_joker",effect:"joker"},{id:"scissors",art:"mg_scissors",effect:"split"},{id:"chest",art:"chest",effect:"chest",amount:3},{id:"battery",art:"mg_energy",effect:"energy",amount:6}],Jr=e=>ul.find(t=>t.id===e),ml=[[1,.5],[2,.35],[3,.15]],yl={"-":{kind:"free"},".":{kind:"hole"},A:{kind:"gen",chain:0},B:{kind:"gen",chain:1},C:{kind:"gen",chain:2},D:{kind:"gen",chain:3},a:{kind:"item",chain:0,level:1},b:{kind:"item",chain:1,level:1},c:{kind:"item",chain:2,level:1},d:{kind:"item",chain:3,level:1},x:{kind:"block",obstacle:"box",hp:1},X:{kind:"block",obstacle:"box",hp:2},f:{kind:"cover",obstacle:"fog",levels:[1,2,2,3]},w:{kind:"cover",obstacle:"web",levels:[2,2,3]},u:{kind:"cover",obstacle:"bubble",levels:[3,3,4]},J:{kind:"special",special:"joker"},S:{kind:"special",special:"scissors"},K:{kind:"special",special:"chest"},E:{kind:"special",special:"battery"}},Cd=7,Pd=8,An={start:["-------","-------","--a-a--","---A---","--a----","-------","-------","-------"],two:["-------","-------","-a---b-","--A-B--","-------","-------","-------","-------"],boxes:["-------","-------","--A-B--","-------","xxxxxxx","x--K--x","x-----x","xxxxxxx"],fog:["fffffff","fffffff","-------","--A-B--","-------","-------","xx-E-xx","xx---xx"],yard:["X-----X","-------","-A-J-B-","-------","xx---xx","fx---xf","ffx-xff","fffffff"],cellar:["XxxxxxX","x-----x","x-A-B-x","x-----x","x--K--x","xfffffx","xfffffx","XxxxxxX"],webs:["-------","-w---w-","--A-B--","---C---","-w---w-","-------","--www--","-------"],mine:["XX---XX","X--S--X","--A-C--","---B---","-------","ffXXXff","fff-fff","fffffff"],workshop:["w--E--w","-------","-A-B-C-","-------","xwxwxwx","-------","x--K--x","XXXXXXX"],vault:["XfffffX","fx---xf","f-A-B-f","f--J--f","f-C---f","fx---xf","XfffffX","XXXXXXX"],bubbles:["-------","-u---u-","--A-B--","---C---","-------","-u---u-","--uuu--","-------"],holes:["..---..",".-----.","--A-B--","---C---","---D---","--fff--",".-fff-.","..---.."],lab:["u-----u","-x-E-x-","--A-D--","-------","--B-C--","-w---w-","xxwuwxx","XXXXXXX"],terrace:["...-...","..---..",".-A-B-.","---J---","-C---D-","-u-x-u-","xxfffxx","XXfffXX"],four:["-------","-A---B-","-------","---J---","-------","-C---D-","xxxxxxx","XXXXXXX"],fortress:["ffXXXff","fx---xf","X-A-B-X","X--S--X","X-C-D-X","fx-K-xf","ffXXXff","fffffff"],maze:["-x-u-x-","-x---x-","-xA-Bx-","--w-w--","-xC-Dx-","-x---x-","-xfffx-","XXfffXX"],palace:["uXXXXXu","X--E--X","X-A-B-X","X--J--X","X-C-D-X","Xw---wX","XffKffX","XXXXXXX"]},gl=[{id:"upgrade",art:"mg_sk_merge",charge:10,effect:"upgrade",count:3},{id:"free",art:"mg_sk_free",charge:9,effect:"free",count:6},{id:"joker",art:"mg_sk_joker",charge:12,effect:"joker",count:2}],ha=e=>gl.find(t=>t.id===e),fo=[{id:"hero",cast:"hero",gems:0,skill:"upgrade"},{id:"hero2",cast:"hero2",gems:150,skill:"free"},{id:"hero3",cast:"hero3",gems:300,skill:"joker"}],He=(e,t,r,o,n=0,s=3,a)=>({board:e,chains:[...t].map(i=>({g:"garden",b:"bake",j:"jewel",p:"potion"})[i]??"garden"),orders:r,top:o,double:n,visible:s,...a?{slack:a}:{}}),fa=e=>({...e,vip:true}),or=(e,t)=>({...e,extra:t}),ua=[He("start","g",3,3,0,1,1.6),He("start","g",4,3,0,2,1.5),He("two","gb",4,3,0,2,1.45),He("two","gb",5,4,0,2),He("boxes","gb",5,4,0,3),He("boxes","gb",6,4,.2,3),He("fog","gb",6,4,.2,3),He("yard","gb",6,5,.2,3),He("fog","gb",7,5,.3,3),or(fa(He("cellar","gb",6,5,.3,3)),.92),or(He("webs","gbj",5,4,.2,3),.92),or(He("webs","gbj",6,4,.3,3),.92),or(He("mine","gbj",6,5,.2,3),1.15),or(He("workshop","gbj",6,5,.3,3),.9),or(He("mine","gbj",7,5,.3,3),1.08),or(He("yard","gj",6,5,.3,3),1.15),or(He("workshop","gbj",7,5,.4,3),.92),He("vault","gbj",7,5,.3,3),or(He("webs","jbg",7,6,.3,3),.92),fa(He("vault","gbj",7,6,.4,3)),or(He("bubbles","gbp",6,5,.2,3),1.15),or(He("bubbles","gbp",6,5,.3,3),1.12),or(He("holes","gbpj",6,5,.3,3),.92),or(He("lab","gbjp",7,5,.3,3),.92),He("holes","gbpj",7,5,.4,3),He("bubbles","pjg",7,6,.3,3),He("lab","gbjp",7,6,.4,3),He("terrace","gbjp",8,5,.4,3),He("holes","gbpj",8,6,.4,3),fa(He("terrace","gbjp",7,6,.4,3)),He("four","gbjp",7,5,.3,3),or(He("fortress","gbjp",7,5,.4,3),1.06),He("maze","gbjp",7,6,.4,3),He("four","gbjp",8,6,.4,3),or(He("fortress","gbjp",8,6,.5,3),1.06),He("palace","gbjp",8,6,.4,3),He("maze","gbjp",8,6,.5,3),He("lab","gbjp",9,6,.5,3),He("palace","gbjp",9,6,.5,3),or(fa(He("fortress","gbjp",8,6,.5,3)),1.06)],co=10,Id=4,ma=ua.length,bl=[0,18,45,75];function Yh(e){let t=e>>>0;return ()=>{t=t+1831565813>>>0;let r=t;return r=Math.imul(r^r>>>15,r|1),r^=r+Math.imul(r^r>>>7,r|61),((r^r>>>14)>>>0)/4294967296}}var pa=e=>Math.pow(2,Math.max(0,e-1));function Jh(e,t){let r=Yh(t*7919+13),o=[],n=e.chains;for(let s=0;s<e.orders;s++){let a=e.orders<=1?1:s/(e.orders-1),i=e.vip===true&&s===e.orders-1,h=2+Math.round(a*(e.top-2)),m=Math.max(2,Math.min(e.top,h-(r()<.3?1:0))),v=n[(s+Math.floor(r()*n.length))%n.length],x=[{chain:v,level:i?Math.min(e.top+1,(Cr(v)?.levels??7)-1):m}];if(i||s>0&&n.length>1&&r()<e.double){let D=n[(n.indexOf(v)+1+Math.floor(r()*(n.length-1)))%n.length];x.push({chain:D,level:i?e.top:Math.max(2,m-1)});}o.push({wants:x,vip:i});}return o}function eu(e){let t=n=>n.reduce((s,a)=>s+pa(a),0)/Math.max(1,n.length),r=ml.reduce((n,[s,a])=>n+pa(s)*a,0),o=0;for(let n of e.join("")){let s=yl[n];if(s){if(s.kind==="item")o+=pa(s.level);else if(s.kind==="cover")o+=t(s.levels)*(gr[s.obstacle]?.mergeInto&&!gr[s.obstacle]?.ttl?.5:.2);else if(s.kind==="special"){let a=Jr(s.special);o+=a?.effect==="energy"?a.amount??0:a?.effect==="chest"?r*(a.amount??0):a?.effect==="joker"?3:2;}}}return o}function po(e,t=.5){let r=Math.max(1,Math.min(ma,Math.floor(e))),o=ua[r-1],n=Math.ceil(r/co),s=Jh(o,r),a=s.reduce((m,v)=>m+v.wants.reduce((x,D)=>x+pa(D.level),0),0),i=Math.max(a*.4,a-eu(An[o.board]??[])*.7),h=(o.slack??1.32-(n-1)*.08-(r-(n-1)*co)*.006)*(1.1-t*.2)*(o.extra??1);return {level:r,world:n,index:r-(n-1)*co,def:o,boss:o.vip===true,orders:s,energy:Math.ceil(i*h),firstClearGold:(o.vip?120:50)+(r-1)*10}}var xl=e=>bl[Math.ceil(Math.max(1,e)/co)-1]??0,ya=e=>e>=.2?3:e>=.08?2:1,ga=15,kl="kit-merge",vl=[{id:"Energy",var:"meta:energy",art:"mg_energy",color:"coin",perLevel:2,unit:"",maxLevel:15,price:40,growth:.12},{id:"GenLuck",var:"meta:luck",art:"mg_joker",color:"secondary",perLevel:2,unit:"%",maxLevel:15,price:45,growth:.12},{id:"Reward",var:"meta:reward",art:"coin",color:"coin",perLevel:5,unit:"%",maxLevel:20,price:40,growth:.12},{id:"SkillPower",var:"meta:skill",art:"mg_sk_merge",color:"secondary",perLevel:8,unit:"%",maxLevel:10,price:50,growth:.12},{id:"Charge",var:"meta:charge",art:"mg_sk_free",color:"primary",perLevel:5,unit:"%",maxLevel:10,price:50,growth:.12}],Nd={game:"merge",character:kl,stats:vl,heroes:fo,levels:ma,firstClearGold:e=>po(e).firstClearGold,stars:3,starsToEnter:xl};var ba=e=>({kind:"none",at:e,hits:[],coins:0}),en=e=>Cr(e)?.levels??8,$l=(e,t,r,o,n="")=>({id:e.nextId++,kind:t,chain:r,level:o,special:n}),is=(e,t,r)=>$l(e,"item",t,r),Bd=(e,t)=>$l(e,"special","",0,t);function Ml(e,t,r){let o=Math.max(...e.map(a=>a.length)),n={cols:o,rows:e.length,cells:[],chains:t,nextId:1,rand:r},s=a=>t[a]??null;for(let a=0;a<e.length;a++){let i=[];for(let h=0;h<o;h++){let m=yl[e[a][h]??"-"]??{kind:"free"},v={hole:m.kind==="hole",thing:null,cover:null,block:null};if(m.kind==="gen"){let x=s(m.chain);x&&(v.thing=$l(n,"gen",x,1));}else if(m.kind==="item"){let x=s(m.chain);x&&(v.thing=is(n,x,m.level));}else if(m.kind==="block")v.block={id:m.obstacle,hp:m.hp};else if(m.kind==="cover"){let x=t[Math.floor(r()*t.length)]??"garden",D=Math.min(en(x)-1,m.levels[Math.floor(r()*m.levels.length)]??1);v.thing=is(n,x,D);let O=gr[m.obstacle];v.cover={id:m.obstacle,hp:1,...O?.ttl?{ttl:O.ttl}:{}};}else m.kind==="special"&&(v.thing=Bd(n,m.special));i.push(v);}n.cells.push(i);}return n}var Tn=(e,t)=>e.cells[t.row]?.[t.col],Hd=(e,t)=>t.col>=0&&t.row>=0&&t.col<e.cols&&t.row<e.rows,Wd=e=>!!e&&!e.hole&&!e.thing&&!e.block,ho=(e,t)=>{let r=Tn(e,t);return !!r&&!!r.thing&&!r.cover&&!r.block};function Pr(e){let t=[];for(let r=0;r<e.rows;r++)for(let o=0;o<e.cols;o++){let n=e.cells[r][o];n.thing&&t.push({at:{col:o,row:r},thing:n.thing,cell:n});}return t}var tu=e=>e.cells.reduce((t,r)=>t+r.filter(Wd).length,0);function xa(e,t){let r=null,o=1/0;for(let n=0;n<e.rows;n++)for(let s=0;s<e.cols;s++){if(!Wd(e.cells[n][s]))continue;let a=Math.hypot(s-t.col,(n-t.row)*1.05);a<o-1e-9&&(o=a,r={col:s,row:n});}return r}function ka(e,t){let r=t?.thing;return !t||!r||t.block||r===e||e.kind!==r.kind||e.kind==="special"||t.cover&&!gr[t.cover.id]?.mergeInto||e.chain!==r.chain||e.level!==r.level?false:e.kind==="gen"?e.level<hl:e.level<en(e.chain)}function zd(e,t){let r=[],o=0;for(let[n,s]of [[1,0],[-1,0],[0,1],[0,-1]]){let a={col:t.col+n,row:t.row+s};if(!Hd(e,a))continue;let i=e.cells[a.row][a.col];for(let h of ["block","cover"]){let m=i[h];if(!m)continue;let v=gr[m.id];if(!v?.neighbour)continue;m.hp--;let x=m.hp<=0;x&&(i[h]=null,o+=v.coins??0),r.push({at:a,id:m.id,gone:x,revealed:x&&!!v.hides});}}return {hits:r,coins:o}}function jd(e,t,r){if(!ho(e,t)||!Hd(e,r)||t.col===r.col&&t.row===r.row)return ba(t);let o=Tn(e,t),n=Tn(e,r),s=o.thing;if(n.hole||n.block)return ba(t);if(ka(s,n)){let m=n.thing;o.thing=null,m.level++;let v=n.cover?.id;n.cover=null;let x=zd(e,r);return {kind:"merge",at:r,level:m.level,...v?{freed:v}:{},hits:x.hits,coins:x.coins}}let a=s.kind==="special"?Jr(s.special):void 0,i=n.thing,h=!n.cover||!!gr[n.cover.id]?.mergeInto;if(a?.effect==="joker"&&i?.kind==="item"&&h&&i.level<en(i.chain)){o.thing=null,i.level++;let m=n.cover?.id;n.cover=null;let v=zd(e,r);return {kind:"joker",at:r,level:i.level,...m?{freed:m}:{},hits:v.hits,coins:v.coins}}if(a?.effect==="split"&&i?.kind==="item"&&!n.cover&&i.level>=2){o.thing=null;let m=xa(e,r);return m?(i.level--,e.cells[m.row][m.col].thing=is(e,i.chain,i.level),{kind:"split",at:r,level:i.level,second:m,hits:[],coins:0}):(o.thing=s,ba(t))}return i?n.cover?ba(t):(o.thing=i,n.thing=s,{kind:"swap",at:r,hits:[],coins:0}):(o.thing=null,n.thing=s,{kind:"move",at:r,hits:[],coins:0})}function Vd(e,t,r=0){let o=Tn(e,t)?.thing;if(!o||o.kind!=="gen"||Tn(e,t).cover)return null;let n=xa(e,t);if(!n)return null;let s=e.rand(),a=Math.max(1,Math.min(hl,o.level)),i=a>=3&&s<Od?3:s<(Dd[a-1]??0)+r?2:1,h=is(e,o.chain,Math.min(i,en(o.chain)));return e.cells[n.row][n.col].thing=h,{at:n,thing:h,burst:ru(e)}}function ru(e){let t=[];for(let r=0;r<e.rows;r++)for(let o=0;o<e.cols;o++){let n=e.cells[r][o];n.cover?.ttl!==void 0&&(n.cover.ttl--,!(n.cover.ttl>0)&&(n.cover=null,n.thing=null,t.push({col:o,row:r})));}return t}var nu=e=>{let t=0;for(let[r,o]of ml)if(t+=o,e<t)return r;return 1};function Gd(e,t){let r=Tn(e,t),o=r?.thing;if(!r||!o||o.kind!=="special"||r.cover)return null;let n=Jr(o.special);if(n?.effect==="energy")return r.thing=null,{energy:n.amount??5,spawned:[]};if(n?.effect!=="chest")return null;r.thing=null;let s=[];for(let a=0;a<(n.amount??3);a++){let i=xa(e,t);if(!i)break;let h=e.chains[Math.floor(e.rand()*e.chains.length)]??as[0].id,m=is(e,h,Math.min(en(h),nu(e.rand())));e.cells[i.row][i.col].thing=m,s.push({at:i,thing:m});}return s.length===0?(r.thing=o,null):{energy:0,spawned:s}}function Kd(e,t={}){let r=Pr(e).filter(s=>ho(e,s.at)&&(s.thing.kind==="item"||t.gens!==false&&s.thing.kind==="gen")),o=null,n=1/0;for(let s of r)for(let a=0;a<e.rows;a++)for(let i=0;i<e.cols;i++){let h=e.cells[a][i];if(!ka(s.thing,h))continue;let m=(s.thing.kind==="gen"?100:0)+s.thing.level-(h.cover?.5:0);m<n&&(n=m,o=[s.at,{col:i,row:a}]);}return o}function Dn(e,t){let r=new Set,o=[],n=Pr(e);for(let s of t){let a=n.find(i=>i.thing.kind==="item"&&!i.cell.cover&&!r.has(i.thing.id)&&i.thing.chain===s.chain&&i.thing.level===s.level);if(!a)return null;r.add(a.thing.id),o.push(a.at);}return o}function wl(e,t){let r=Tn(e,t);if(!r?.thing)return null;let o=r.thing;return r.thing=null,o}function El(e,t,r){let o=xa(e,r),n=Bd(e,t);if(o)return e.cells[o.row][o.col].thing=n,{at:o,thing:n};let s=Pr(e).filter(a=>a.thing.kind==="item"&&!a.cell.cover).sort((a,i)=>a.thing.level-i.thing.level)[0];return s?(s.cell.thing=n,{at:s.at,thing:n}):null}function Fd(e){let t=Pr(e),r=tu(e)>0;for(let o of t){if(o.thing.kind!=="special"||o.cell.cover)continue;let n=Jr(o.thing.special);if(n?.effect==="energy"||n?.effect==="chest"&&r||n?.effect==="joker"&&t.some(s=>s.thing.kind==="item"&&(!s.cell.cover||gr[s.cell.cover.id]?.mergeInto)&&s.thing.level<en(s.thing.chain))||n?.effect==="split"&&r&&t.some(s=>s.thing.kind==="item"&&!s.cell.cover&&s.thing.level>=2))return true}return false}function qd(e,t,r){let o=[];for(let n=0;n<t;n++){let s=Pr(e).filter(h=>h.thing.kind==="item"&&!h.cell.cover&&h.thing.level<en(h.thing.chain)&&!o.some(m=>m.col===h.at.col&&m.row===h.at.row));if(s.length===0)break;let a=h=>r.some(m=>m.chain===h.thing.chain&&m.level===h.thing.level+1);s.sort((h,m)=>Number(a(m))-Number(a(h))||h.thing.level-m.thing.level);let i=s[0];i.thing.level++,o.push(i.at);}return o}var Sl=90,ls=ve("merge.item"),Zd=ve("merge.order"),Ll=ve("merge.layer"),Ud=ve("merge.backdrop"),Xd=ve("merge.part"),uo=ve("merge.customer"),mo=(e,t)=>{let r=Number(e.vars[t]??0);return Number.isFinite(r)?r:0},va={id:"merge",version:2,engines:["phaser"],requires:["round"],params:{difficulty:{type:"number",default:.5,min:0,max:1},orderReward:{type:"number",default:1,min:0,max:100},mergeScore:{type:"number",default:10,min:1,max:1e3,integer:true},energyBonus:{type:"number",default:20,min:0,max:1e4,integer:true}},setup({world:e,params:t}){let r=f=>yr(t,f),o=e.rng.stream("merge"),n=po(1,r("difficulty")),s=Ml(An.start,["garden"],()=>o.next()),a=oe(),i=new Map,h=new Map,m=null,v=[],x=[],D=0,O=0,N=0,q=0,ne=0,Z=0,ye=0,be=0,fe=false,Ee=false,de=null,Ae=[],Pe=()=>fo.find(f=>f.id===e.vars["meta:hero"])??fo[0],we=()=>ha(Pe().skill),ce=()=>e.vars.reviving===true,ke=()=>we().charge,Le=()=>mo(e,"meta:luck"),_e=()=>v.flatMap(f=>f.order.wants);function oe(){return un(Be(e),s.cols,s.rows,{top:.3,bottom:.86,widthShare:.94})}let Te=()=>a.cell,Ke=new Set,Ne=(f,b,c,p,k=1)=>{Ke.add(f);let _=h.get(f);(_===void 0||!e.isAlive(_))&&(_=e.create(),e.set(_,Xd,{id:f}),h.set(f,_)),e.set(_,F,{x:b,y:c,scale:k}),e.set(_,le,p);},se=()=>{for(let[f,b]of [...h])Ke.has(f)||(e.destroy(b),h.delete(f));},Ie=f=>{if(f.kind==="special")return Jr(f.special)?.art??"chest";let b=Cr(f.chain);return f.kind==="gen"?b?.gen??"chest":`${b?.prefix??"item"}${Math.min(f.level,b?.levels??8)}`},$e=f=>{let b=Te(),c=f.kind==="gen"?.94:.92;return {shape:"sprite",art:Ie(f),w:b*c,h:b*c,depth:3}},Se=()=>{let f=new Map(Pr(s).map(b=>[b.thing.id,b]));for(let[b,c]of [...i])f.has(b)||(e.destroy(c),i.delete(b));for(let[b,c]of f){let p=i.get(b);if(p===void 0){p=e.create();let C=st(a,c.at.col,c.at.row);e.set(p,F,{x:C.x,y:C.y,scale:.3}),i.set(b,p);}e.set(p,ls,{id:b,col:c.at.col,row:c.at.row});let k=$e(c.thing),_=c.cell.cover&&gr[c.cell.cover.id]?.hides;e.set(p,le,{...k,alpha:_?0:1,depth:m?.id===b?30:3});}Ye(),mt();},Ye=()=>{ct(e,Ll);let f=Te();for(let b=0;b<s.rows;b++)for(let c=0;c<s.cols;c++){let p=s.cells[b][c],k=st(a,c,b);for(let[_,C,z]of [["b",p.block,3],["c",p.cover,5]]){if(!C)continue;let B=gr[C.id],ae=B?.art[Math.min(B.art.length,Math.max(1,C.hp))-1]??"mg_box",pe=e.create();e.set(pe,Ll,{key:`${_}${c},${b}`}),e.set(pe,F,{x:k.x,y:k.y}),e.set(pe,le,{shape:"sprite",art:ae,w:f*.98,h:f*.98,depth:z,alpha:C.id==="bubble"&&(C.ttl??99)<=3?.55+.4*Math.abs(Math.sin(e.time*6)):1});}}},ee=()=>{ct(e,Ud),Bt(e,"board",a.top+a.cell*s.rows*.3);let f=Te(),b=st(a,(s.cols-1)/2,(s.rows-1)/2),c=f*.22,p=(k,_,C)=>{let z=e.create();e.set(z,Ud,{i:0}),e.set(z,F,{x:k,y:_}),e.set(z,le,C);};p(b.x,b.y,{shape:"sprite",art:"panel",w:f*s.cols+c*2,h:f*s.rows+c*2,color:"panel",alpha:.9,depth:-10});for(let k=0;k<s.rows;k++)for(let _=0;_<s.cols;_++){if(s.cells[k][_].hole)continue;let C=st(a,_,k);p(C.x,C.y,{shape:"sprite",art:"cell",w:f-3,h:f-3,color:(k+_)%2?"panel":"ground",alpha:.85,depth:-9});}},Re=()=>Math.max(1,n.def.visible),rt=f=>{let b=Be(e),c=Re(),p=Math.min(b.w*.3,Te()*2.6),k=b.w/2+(f-(c-1)/2)*(p+Te()*.2),_=p*(c>2?.62:.72),C=b.h*.118+_/2,z=a.top-Te()*.18;return {x:k,y:C,w:p,h:_,feet:z}},ht=(f,b,c)=>{let p=rt(f),k=Math.max(24,(p.feet-(p.y+p.h/2))*1.05),_=c?-k:p.x,C=e.create();return e.set(C,F,{x:_,y:p.feet-k/2}),e.set(C,le,{shape:"actor",cast:b.vip?"boss":"helper",variant:b.vip?7:o.int(0,99),h:k,pose:c?"walk":"idle",facing:1,speed:Sl,depth:6}),e.set(C,uo,{slot:f,to:p.x,leaving:-1}),C},De=f=>{for(let b=0;b<Re();b++){if(v.some(p=>p.slot===b))continue;let c=x.shift();c&&v.push({order:c,slot:b,customer:ht(b,c,f)});}},Qt=(f,b)=>{for(let c of f.query(uo)){let p=f.need(c,uo),k=f.need(c,F),_=f.need(c,le);if(_.shape!=="actor")continue;if(p.leaving>=0){p.leaving+=b,p.leaving>.7&&(_.pose="walk",_.facing=1,k.x+=Sl*1.4*b);continue}let C=p.to-k.x;Math.abs(C)>1?(k.x+=Math.sign(C)*Math.min(Math.abs(C),Sl*2*b),_.pose="walk",_.facing=C>0?1:-1):_.pose==="walk"&&(k.x=p.to,_.pose="idle");}},Xe=f=>Math.max(1,Math.round(f.wants.reduce((b,c)=>b+c.level,0)*r("orderReward")*(f.vip?3:1)*(1+mo(e,"meta:reward")))),et=f=>{let b=Dn(s,f.order.wants);if(!b)return false;let c=rt(f.slot);for(let _ of b){let C=st(a,_.col,_.row);K(e,{kind:"burst",x:C.x,y:C.y,color:"coin",n:8,size:Te()*.8}),wl(s,_);}let p=Xe(f.order);Qe(e,"coins",p),Qe(e,"score",p*25),K(e,{kind:"burst",x:c.x,y:c.y,color:"coin",n:14,size:c.w*.8}),K(e,{kind:"pop",x:c.x,y:c.y-c.h*.5,text:`+${p}`,color:"coin",size:Math.round(c.h*.42)}),e.emit("coin-collected",{value:p}),e.emit("order-filled",{reward:p,vip:f.order.vip}),Lt(e,"merge-order"),ne++;let k=e.get(f.customer,uo);return k&&(k.leaving=0,Ge(e,f.customer,"cheer"),_n(e,f.customer,2.4)),v=v.filter(_=>_!==f),De(true),Se(),v.length===0&&x.length===0&>(),true},it=(f,b,c,p,k,_)=>{let C=Math.max(8,p*.11);Ne(`${f}:bg`,b,c,{shape:"rect",w:p,h:C,color:"#000000",alpha:.5,radius:C/2,depth:69});let z=Math.max(1,(p-4)*Math.max(0,Math.min(1,k)));Ne(`${f}:fill`,b-(p-4)/2+z/2,c,{shape:"rect",w:z,h:C-4,color:_,radius:(C-4)/2,depth:69.1});},dt=()=>{let f=Be(e),b=Math.min(f.w,f.h),c=Te(),p=(j,J,Y,M,E="text",l=b*.045,w=70)=>Ne(j,J,Y,{shape:"text",text:M,size:Math.round(l),color:E,bold:true,depth:w});Ae=[],Ke.clear();let k=f.h*.085;Ne("h:en:i",f.w*.1,k,{shape:"sprite",art:"mg_energy",w:b*.07,h:b*.07,depth:70}),p("h:en",f.w*.1+b*.075,k,String(D),D<=3&&N===0?"danger":"text",b*.06),N>0&&p("h:free",f.w*.1+b*.17,k,`+${N}`,"secondary",b*.04);let _=v.length+x.length;Ne("h:ord:i",f.w*.8,k,{shape:"sprite",art:"ticket",w:b*.075,h:b*.05,color:"panel",depth:70}),p("h:ord",f.w*.8+b*.08,k,String(_),"text",b*.05);for(let j of v){let J=rt(j.slot);Dn(s,j.order.wants)!==null&&Ne(`h:t${j.slot}:glow`,J.x,J.y,{shape:"rect",w:J.w*1.08,h:J.h*1.14,color:"accent",alpha:.45+.3*Math.sin(e.time*6),radius:J.h*.2,depth:7.9}),Ne(`h:t${j.slot}`,J.x,J.y,{shape:"sprite",art:"ticket",w:J.w,h:J.h,color:j.order.vip?"coin":"panel",depth:8});let M=j.order.wants.length,E=Math.min(J.h*.58,J.w*.86/M);j.order.wants.forEach((l,w)=>{let A=J.x+(w-(M-1)/2)*E*1.05,d=J.y-J.h*.12,y=Cr(l.chain);Ne(`h:t${j.slot}:${w}`,A,d,{shape:"sprite",art:`${y?.prefix??"item"}${Math.min(l.level,y?.levels??8)}`,w:E,h:E,depth:8.1}),Dn(s,[l])?p(`h:t${j.slot}:${w}:ok`,A+E*.32,d+E*.32,"\u2713","accent",E*.42,8.2):p(`h:t${j.slot}:${w}:lv`,A+E*.34,d+E*.34,String(l.level),"coin",E*.3,8.2);}),Ne(`h:t${j.slot}:c`,J.x-J.w*.1,J.y+J.h*.3,{shape:"sprite",art:"coin",w:J.h*.19,h:J.h*.19,depth:8.1}),p(`h:t${j.slot}:cv`,J.x+J.w*.07,J.y+J.h*.3,String(Xe(j.order)),"coin",J.h*.2,8.1),Ae.push({id:`order${j.slot}`,x:J.x,y:J.y,r:J.w*.5});}let C=_e();for(let j of Pr(s)){if(j.cell.cover&&gr[j.cell.cover.id]?.hides)continue;let J=i.get(j.thing.id);if(J===void 0)continue;let Y=e.need(J,F),M=m?.id===j.thing.id?31:6;if(j.thing.kind==="gen")for(let E=0;E<j.thing.level;E++)Ne(`h:i${j.thing.id}:s${E}`,Y.x+(E-(j.thing.level-1)/2)*c*.2,Y.y+c*.38,{shape:"circle",r:c*.075,color:"coin",depth:M});else j.thing.kind==="item"&&(C.some(E=>E.chain===j.thing.chain&&E.level===j.thing.level)&&(Ne(`h:i${j.thing.id}:ok`,Y.x+c*.3,Y.y-c*.3,{shape:"circle",r:c*.12,color:"accent",depth:M}),p(`h:i${j.thing.id}:okt`,Y.x+c*.3,Y.y-c*.3,"\u2713","#ffffff",c*.18,M+.1)),p(`h:i${j.thing.id}:lv`,Y.x+c*.3,Y.y+c*.3,String(j.thing.level),"coin",c*.22,M));}let z=a.top+c*s.rows+(f.h-(a.top+c*s.rows))*.5,B=Math.min(b*.075,(f.h-(a.top+c*s.rows))*.38),ae=f.w*.3,pe=q>=ke();Ae.push({id:"skill",x:ae,y:z,r:B*1.2}),pe&&Ne("h:skill:glow",ae,z,{shape:"circle",r:B*1.28,color:"secondary",alpha:.5+.3*Math.sin(e.time*7),depth:68.9}),Ne("h:skill:bg",ae,z,{shape:"circle",r:B,color:"panel",alpha:.95,depth:69}),Ne("h:skill:i",ae,z,{shape:"sprite",art:we().art,w:B*1.4,h:B*1.4,alpha:pe?1:.45,depth:69.2}),it("h:charge",ae+B*2.6,z,B*2.4,q/ke(),"secondary");let Me=f.w*.88;Ae.push({id:"bin",x:Me,y:z,r:B*1.1});let qe=m?i.get(m.id):void 0,tt=qe!==void 0?e.need(qe,F):null,pt=tt!==null&&Math.hypot(tt.x-Me,tt.y-z)<B*1.3;Ne("h:bin:bg",Me,z,{shape:"circle",r:B,color:pt?"danger":"panel",alpha:.95,depth:69}),Ne("h:bin",Me,z,{shape:"sprite",art:"mg_bin",w:B*1.3,h:B*1.3,alpha:m?1:.7,depth:69.2}),(de===null||!e.isAlive(de))&&(de=e.create(),e.set(de,le,{shape:"actor",cast:Pe().cast,h:B*2.6,pose:"idle",facing:1,depth:20})),e.set(de,F,{x:f.w*.11,y:z-B*.1});let re=e.need(de,le);re.shape==="actor"&&(re.h=B*2.6),e.vars.mg_buttons=Ae.map(j=>`${j.id}@${Math.round(j.x)},${Math.round(j.y)}`).join(";"),se();},mt=()=>{e.vars.energy=D,e.vars.mg_free=N,e.vars.mg_charge=Math.floor(q),e.vars.orders_left=v.length+x.length,e.vars.mg_orders=v.slice().sort((f,b)=>f.slot-b.slot).map(f=>f.order.wants.map(b=>`${b.chain}:${b.level}`).join("+")).join("|"),e.vars.level_progress=n.orders.length?ne/n.orders.length:0;},yt=()=>{ct(e,ls),ct(e,Ll),ct(e,Xd),ct(e,uo),i.clear(),h.clear(),de!==null&&e.isAlive(de)&&e.destroy(de),de=null,n=po(mo(e,"meta:chapter")||1,r("difficulty")),s=Ml(An[n.def.board]??An.start,n.def.chains,()=>o.next()),a=oe(),ee(),m=null,v=[],x=[...n.orders],D=Math.max(0,n.energy+Math.round(mo(e,"meta:energy"))),O=D,N=0,q=0,ne=0,Z=0,ye=0,be=0,fe=false,Ee=false,e.vars.mg_level=n.level,e.vars.mg_world=n.world,e.vars.coins=0,e.vars.score=0,e.vars.stars=0,e.vars.reviving=false,De(false),Se();},gt=()=>{Ee||(e.vars.stars=Math.min(fe?1:3,ya(D/Math.max(1,O))),Qe(e,"score",D*r("energyBonus")),K(e,{kind:"flash",color:"coin"}),ft("cleared"));},ft=f=>{if(Ee)return;Ee=true;let b=f==="cleared";b&&e.vars["meta:first_clear"]===true&&Qe(e,"coins",n.firstClearGold),b||(e.vars.stars=0),e.vars.reviving=false,mt(),e.emit(Ut,{reason:f,stats:{chapter:n.level,seconds:Math.floor(ye),cleared:b,stars:Number(e.vars.stars??0),coins:Number(e.vars.coins??0),orders:ne,merges:Z}});},ze=()=>{if(e.vars.revive_ready===true&&!fe){e.vars.reviving=true,e.emit(er,{});return}ft("out-of-energy");},Et=()=>{ce()&&(fe=true,e.vars.reviving=false,D+=ga,El(s,"joker",{col:Math.floor(s.cols/2),row:Math.floor(s.rows/2)}),K(e,{kind:"flash",color:"coin"}),Se());},Ze=()=>{if(D>0||N>0||q>=ke()||v.some(c=>Dn(s,c.order.wants))||Fd(s))return true;let f=[..._e(),...x.flatMap(c=>c.wants)],b=Pr(s);for(let c of b)if(!(!ho(s,c.at)||c.thing.kind!=="item")&&f.some(p=>p.chain===c.thing.chain&&p.level>c.thing.level)&&b.some(p=>ka(c.thing,p.cell)))return true;return false},Wt=f=>{let b=Te(),c=st(a,f.at.col,f.at.row);if(f.kind==="merge"||f.kind==="joker"){let p=s.cells[f.at.row][f.at.col].thing,k=Cr(p.chain)?.color??"coin";K(e,{kind:"ring",x:c.x,y:c.y,color:k,size:b*1.4}),K(e,{kind:"burst",x:c.x,y:c.y,color:"coin",n:8,size:b*.8});let _=i.get(p.id);_!==void 0&&(e.need(_,F).scale=1.35),Z++,q=Math.min(ke(),q+1+mo(e,"meta:charge")),Qe(e,"score",Math.pow(2,p.level)*r("mergeScore")),e.emit("items-merged",{level:p.level,chain:p.chain}),Lt(e,"merge-merge"),p.kind==="item"&&p.level===en(p.chain)&&K(e,{kind:"flash",color:"coin"});for(let C of v)C.order.wants.some(z=>z.chain===p.chain&&z.level===p.level)&&Ge(e,C.customer,"wave");}f.kind==="split"&&K(e,{kind:"ring",x:c.x,y:c.y,color:"secondary",size:b*1.2}),f.freed&&e.emit("obstacle-cleared",{kind:f.freed});for(let p of f.hits){let k=st(a,p.at.col,p.at.row);K(e,{kind:"burst",x:k.x,y:k.y,color:p.id==="fog"?"#ffffff":"ground",n:p.gone?10:4,size:b*.9}),p.gone&&e.emit("obstacle-cleared",{kind:p.id});}f.coins>0&&(Qe(e,"coins",f.coins),e.emit("coin-collected",{value:f.coins}),K(e,{kind:"pop",x:c.x,y:c.y-b*.5,text:`+${f.coins}`,color:"coin",size:Math.round(b*.4)})),f.hits.length&&K(e,{kind:"shake",power:.25});},hr=f=>{if(D<=0&&N<=0){let _=st(a,f.col,f.row);K(e,{kind:"pop",x:_.x,y:_.y-Te()*.5,text:"0",color:"danger",size:Math.round(Te()*.4)});return}let b=Vd(s,f,Le()),c=st(a,f.col,f.row);if(!b){K(e,{kind:"shake",power:.2}),K(e,{kind:"pop",x:c.x,y:c.y-Te()*.5,text:"\u2715",color:"danger",size:Math.round(Te()*.45)});return}N>0?N--:D--,Lt(e,"merge-generate");let p=i.get(s.cells[f.row][f.col].thing.id);p!==void 0&&(e.need(p,F).scale=1.2),K(e,{kind:"burst",x:c.x,y:c.y,color:Cr(b.thing.chain)?.color??"accent",n:6,size:Te()*.7}),e.emit("item-spawned",{level:b.thing.level,chain:b.thing.chain}),Se();let k=i.get(b.thing.id);k!==void 0&&e.set(k,F,{x:c.x,y:c.y,scale:.4});for(let _ of b.burst){let C=st(a,_.col,_.row);K(e,{kind:"burst",x:C.x,y:C.y,color:"#ffffff",n:10,size:Te()});}},Nt=f=>{let b=Gd(s,f);if(!b)return;let c=st(a,f.col,f.row);K(e,{kind:"ring",x:c.x,y:c.y,color:"coin",size:Te()*1.6}),b.energy>0&&(D+=b.energy,K(e,{kind:"pop",x:c.x,y:c.y-Te()*.5,text:`+${b.energy}`,color:"coin",size:Math.round(Te()*.45)})),Se();for(let p of b.spawned){let k=i.get(p.thing.id);k!==void 0&&e.set(k,F,{x:c.x,y:c.y,scale:.4});}},ur=()=>{let f=we();if(q<f.charge)return false;let b=1+mo(e,"meta:skill"),c=Math.max(1,Math.round(f.count*b));if(q=0,de!==null&&Ge(e,de,"cheer"),K(e,{kind:"flash",color:"secondary"}),f.effect==="upgrade")for(let p of qd(s,c,[..._e(),...x.slice(0,2).flatMap(k=>k.wants)])){let k=st(a,p.col,p.row);K(e,{kind:"ring",x:k.x,y:k.y,color:"secondary",size:Te()*1.4});}else if(f.effect==="free")N+=c;else for(let p=0;p<c;p++)El(s,"joker",{col:Math.floor(s.cols/2),row:Math.floor(s.rows/2)});return e.emit("skill-cast",{id:f.id}),Lt(e,"merge-skill"),Se(),true},Tt=(f,b)=>Ae.find(c=>Math.hypot(f-c.x,b-c.y)<=c.r);e.on(zt,f=>{let b=f;if(!(!ot(e)||hn(e)||Ee||ce())){if(b.type==="press"){Ht(e),be=0;let c=Ur(a,b.x,b.y);if(!c||!ho(s,c))return;let p=s.cells[c.row][c.col].thing.id,k=i.get(p);if(k===void 0)return;let _=e.need(k,F);m={id:p,from:c,dx:_.x-b.x,dy:_.y-b.y,x0:b.x,y0:b.y},e.need(k,le).depth=30;}else if(b.type==="move"&&m){let c=i.get(m.id);if(c===void 0)return;let p=e.need(c,F);p.x=b.x+m.dx,p.y=b.y+m.dy,p.scale=1.12;}else if(b.type==="release"&&m){let c=m;m=null;let p=i.get(c.id);if(p!==void 0&&(e.need(p,le).depth=3),Math.hypot(b.x-c.x0,b.y-c.y0)<Te()*.3)return;let k=Tt(b.x,b.y),_=s.cells[c.from.row][c.from.col].thing;if(k?.id==="bin"&&_&&_.kind!=="gen"){wl(s,c.from),Lt(e,"merge-bin"),Se();return}let C=k?.id.startsWith("order")?v.find(ae=>`order${ae.slot}`===k.id):void 0;if(C&&_?.kind==="item"&&C.order.wants.some(ae=>ae.chain===_.chain&&ae.level===_.level)&&et(C))return;let z=Ur(a,b.x,b.y);if(!z)return;let B=jd(s,c.from,z);B.kind!=="none"&&Wt(B),Se();}else if(b.type==="tap"){be=0;let c=Tt(b.x,b.y);if(c?.id==="skill"){ur();return}if(c?.id.startsWith("order")){let _=v.find(C=>`order${C.slot}`===c.id);_&&et(_);return}let p=Ur(a,b.x,b.y),k=p?s.cells[p.row][p.col].thing:null;if(!p||!k||!ho(s,p))return;if(k.kind==="gen")hr(p);else if(k.kind==="special")Nt(p);else {let _=v.find(C=>C.order.wants.some(z=>z.chain===k.chain&&z.level===k.level)&&Dn(s,C.order.wants));_&&et(_);}}}}),e.on(qt,()=>{yt(),e.vars.level=n.level;}),e.on(Zt,yt),e.on(tr,Et),e.on(rr,()=>{ce()&&(e.vars.reviving=false,ft("out-of-energy"));}),e.on(Xt,f=>{Ke.clear(),se(),Ae=[],de!==null&&e.isAlive(de)&&at(e,de,f.reason==="cleared"?"dance":"idle");}),e.on(Ft,()=>{a=oe(),ee();for(let f of v){let b=rt(f.slot),c=e.get(f.customer,uo);c&&(c.to=b.x);let p=e.get(f.customer,F),k=Math.max(24,(b.feet-(b.y+b.h/2))*1.05);p&&e.set(f.customer,F,{x:b.x,y:b.feet-k/2});let _=e.get(f.customer,le);_?.shape==="actor"&&(_.h=k);}Se();});let T=f=>{let b=Math.min(1,f*16);for(let[c,p]of i){if(m?.id===c)continue;let k=e.get(p,ls);if(!k)continue;let _=e.need(p,F),C=st(a,k.col,k.row);_.x+=(C.x-_.x)*b,_.y+=(C.y-_.y)*b;let z=_.scale??1;_.scale=z+(1-z)*Math.min(1,f*10);}},H=f=>{let b=v.find(p=>Dn(s,p.order.wants));if(b&&(!vt(f,"merge-order")||be>6)){let p=rt(b.slot);return kt(f,"tap",{x:p.x,y:p.y},void 0,Te()*1.1)}let c=Kd(s,{gens:false});if(c&&(!vt(f,"merge-merge")||be>6))return kt(f,"swipe",st(a,c[0].col,c[0].row),st(a,c[1].col,c[1].row),Te()*1.1);if(q>=ke()&&!vt(f,"merge-skill")){let p=Ae.find(k=>k.id==="skill");if(p)return kt(f,"tap",p,void 0,Te()*1.1)}if(!vt(f,"merge-generate")||be>6){let p=Pr(s).find(k=>k.thing.kind==="gen"&&!k.cell.cover);p&&(D>0||N>0)&&kt(f,"tap",st(a,p.at.col,p.at.row),void 0,Te()*1.1);}},u=0;e.addSystem({id:"merge",order:0,run(f,b){Qt(f,b),T(b),!(!ot(f)||Ee)&&(ye+=b,be+=b,dt(),++u%20===0&&s.cells.some(c=>c.some(p=>p.cover?.ttl!==void 0&&p.cover.ttl<=3))&&Ye(),!(ce()||m)&&(_r(f)||H(f),Ze()||ze()));}}),yt();}};var Gt=10,Qd={id:"start",needs:[],rows:["..............","..............","..............","..............","..............","..............",".......o.o.o..",".P............","##############","##############"]},Yd={id:"checkpoint",needs:[],rows:["..........","..........","..........","..........","..........","..........","...o..o...","....C.....","##########","##########"]},Jd={id:"end",needs:[],rows:["..............","..............","..............","..............","..............","..............",".....o.o......","..........E...","##############","##############"]},ef={id:"boss",needs:[],rows:["..................","..................","..................","..................","...===......===...","..................","..................","..................","##################","##################"]},Ma=[{id:"walk",needs:["walker"],rows:["..............","..............","..............","..............",".....ooo......","....o...o.....","..............",".........W....","##############","##############"]},{id:"two-walkers",needs:["walker"],rows:["..............","..............","..............","......*.......",".....===......","..............","..o........o..","...W......W...","##############","##############"]},{id:"gaps",needs:["gaps"],rows:["..............","..............","..............","..............","..............","....o.....o...","...o.o...o.o..","..............","###...###...##","###...###...##"]},{id:"stairs",needs:["stairs"],rows:["..............","...........*..","..........===.","..............",".......###....",".......###.o..","....##########","....##########","##############","##############"]},{id:"spikes",needs:["spikes"],rows:["..............","..............","..............","..............","..............",".....ooo......","....=====.....","..............","###^^^^^^^####","##############"]},{id:"pits",needs:["pits"],rows:["..............","..............","..............","..............","......o.......",".....===...o..","..o.......===.",".===..........","##..........##","##..........##"]},{id:"spring",needs:["spring"],rows:["..............",".........*....","........####..","..............","..............","..............","..............","...T..........","##############","##############"]},{id:"hopper",needs:["hopper"],rows:["..............","..............","..............","..............",".....o...o....","..............","..............",".......J......","##############","##############"]},{id:"crumble",needs:["crumble"],rows:["..............","..............","..............","..............","..............","...o.o.o.o....","...______.....","..............","##........####","##........####"]},{id:"spiky",needs:["spiky"],rows:["..............","..............","..............","..............","..............","......ooo.....","..............",".......S......","##############","##############"]},{id:"moving",needs:["moving"],rows:["..............","..............","..............","..............",".....o..o.....","..............",".....M........","..............","##..........##","##..........##"]},{id:"flyer",needs:["flyer"],rows:["..............","..............","..............","......F.......","..............","..............","...o......o...","..............","##############","##############"]},{id:"key",needs:["key"],rows:["..............","..............","..K...........",".===..........","..............",".......===....","..............","...........B..","##############","##############"]},{id:"gunner",needs:["gunner"],rows:["..............","..............","..............","..............","..............",".....o.o......","....=====.....","...........G..","##############","##############"]},{id:"heart",needs:["walker","stairs"],rows:["..............","..............","..*...........","..............","......H.......",".....===......","..............","...W......W...","##############","##############"]},{id:"secret-high",needs:["spring","gaps"],rows:["..............","..*...........",".===..........","..............","..............","..............","........T.....","..............","#####...######","#####...######"]}],_l=4,On=5,wa=_l*On,$a={walker:1,gaps:1,spikes:2,stairs:2,pits:3,spring:3,hopper:4,crumble:4,spiky:6,moving:6,flyer:7,key:8,gunner:9},Rl=[0,9,24,39];function yo(e,t=.5){let r=Math.max(1,Math.min(wa,Math.floor(e))),o=Math.ceil(r/On),n=r-(o-1)*On,s=n===On,a=Object.keys($a).filter(h=>$a[h]<=r),i=Object.keys($a).find(h=>$a[h]===r)??null;return {level:r,world:o,index:n,boss:s,features:a,fresh:i,rooms:s?2:3+Math.min(5,Math.floor((r-1)/2)),pace:.85+t*.3+(r-1)*.02,bossHp:3+o,firstClearGold:(s?150:60)+(r-1)*20}}var Al=e=>Rl[Math.ceil(Math.max(1,e)/On)-1]??0,Tl=[{id:"double",stars:6},{id:"dash",stars:15},{id:"wall",stars:27}],Ea=e=>Tl.filter(t=>e>=t.stars).map(t=>t.id),go=[{id:"hero",cast:"hero",gems:0,perk:"none"},{id:"hero2",cast:"hero2",gems:150,perk:"heart"},{id:"hero3",cast:"hero3",gems:300,perk:"jump"}],Dl="kit-platformer",Ol=[{id:"Hearts",var:"meta:hearts",art:"heart",color:"danger",perLevel:1,unit:"",maxLevel:3,price:150,growth:1.2},{id:"JumpPower",var:"meta:jump",art:"boot",color:"accent",perLevel:2,unit:"%",maxLevel:10,price:40,growth:.15},{id:"Magnet",var:"meta:magnet",art:"magnet",color:"danger",perLevel:10,unit:"%",maxLevel:10,price:30,growth:.12},{id:"Grace",var:"meta:grace",art:"shield",color:"muted",perLevel:.2,unit:"s",maxLevel:10,price:35,growth:.12},{id:"Greed",var:"meta:greed",art:"coin",color:"coin",perLevel:2,unit:"%",maxLevel:25,price:40,growth:.1}],tf={game:"platformer",character:Dl,stats:Ol,heroes:go,levels:wa,firstClearGold:e=>yo(e).firstClearGold,stars:3,starsToEnter:Al};var ou="boss-spawned",su="boss-defeated",Cl="level-cleared",sr=ve("platformer.body"),ut=ve("platformer.thing"),cs=ve("platformer.strip"),wr=ve("platformer.hero"),rf=ve("platformer.hud"),gn=(e,t)=>{let r=Number(e.vars[t]??0);return Number.isFinite(r)?r:0},au=6,Cn=40,iu=3.3,lu=6.8,cu=.7,nf=1.3,Sa={id:"platformer",version:2,engines:["phaser"],requires:["round"],params:{difficulty:{type:"number",default:.5,min:0,max:1},lives:{type:"number",default:3,min:1,max:9,integer:true},coinScore:{type:"number",default:10,min:0,max:1e3,integer:true},starScore:{type:"number",default:300,min:0,max:1e4,integer:true},clearBonus:{type:"number",default:500,min:0,max:1e5,integer:true},graceTime:{type:"number",default:1.2,min:0,max:5},doubleJump:{type:"boolean",default:false}},setup({world:e,params:t}){let r=T=>yr(t,T),o=Jn(e),n=yo(1,r("difficulty")),s=[],a=0,i=null,h=0,m={x:2,y:8},v=3,x=3,D=0,O=false,N=false,q=0,ne=0,Z=0,ye=false,be=false,fe=[],Ee=[false,false,false],de=new Map,Ae=new Map,Pe=()=>go.find(T=>T.id===e.vars["meta:hero"])??go[0],we=()=>e.vars.reviving===true,ce=()=>{let T=Number(e.vars.view_w??720),H=Number(e.vars.view_h??1280);return Math.min(T/8,H*.66/10)},ke=()=>Number(e.vars.view_h??1280)*.86-10*ce(),Le=()=>Number(e.vars.view_w??720)/ce(),_e=(T,H)=>{if(H<0)return ".";if(T<0||T>=a)return "#";if(H>=10)return ".";let u=s[H]?.[T]??".";return u==="_"&&(de.get(`${T},${H}`)??0)>.5?".":u},oe=T=>T==="#",Te=T=>T==="="||T==="_"||T==="^",Ke=()=>{for(let C of e.query(ut))e.destroy(C);for(let C of e.query(cs))e.destroy(C);de.clear(),n=yo(gn(e,"meta:chapter")||1,r("difficulty"));let T=e.rng.stream(`platformer-level-${n.level}`),H=Ma.filter(C=>C.needs.every(z=>n.features.includes(z))),u=[],f=n.fresh!==null?H.find(C=>C.needs.includes(n.fresh)):void 0;for(f&&u.push(f);u.length<n.rooms;)u.push(T.pick(H));let b=Math.ceil(u.length/2),c=[Qd,...u.slice(0,b),Yd,...u.slice(b),n.boss?ef:Jd];s=Array.from({length:10},(C,z)=>c.map(B=>B.rows[z]??"").join("")),a=s[0].length;let p=[];for(let C=0;C<10;C++)for(let z=0;z<a;z++)s[C][z]==="*"&&p.push({c:z,r:C});let k=p.length<=3?p:[p[0],p[Math.floor(p.length/2)],p[p.length-1]];for(let C=k.length;C<3;C++)k.push({c:Math.floor(a*(C+1)/4),r:5});let _=0;for(let C=0;C<10;C++)for(let z=0;z<a;z++){let B=s[C][z],ae={x:z+.5,y:C+1};B==="P"?m={...ae}:B==="o"?Ie("coin",ae.x,C+.85,.5,.5):B==="H"&&_++<1?Ie("heart",ae.x,C+.9,.6,.6):B==="K"?Ie("key",ae.x,C+.9,.6,.6):B==="B"?Ie("chest",ae.x,ae.y,1,.8):B==="T"?Ie("spring",ae.x,ae.y,1,.5):B==="M"?Ie("mover",ae.x+.5,C+.4,2,.4).baseX=ae.x+.5:B==="C"?Ie("checkpoint",ae.x,ae.y,.6,1.6):B==="E"?Ie("flag",ae.x,ae.y,.8,2.6):B==="W"?Ie("walker",ae.x,ae.y,.8,1):B==="S"?Ie("spiky",ae.x,ae.y,.8,1):B==="J"?Ie("hopper",ae.x,ae.y,.8,1):B==="F"?Ie("flyer",ae.x,ae.y,.9,.8):B==="G"&&Ie("gunner",ae.x,ae.y,.8,1.1),/[PoHKBTMCEWSJFG*]/.test(B)&&(s[C]=Ne(s[C],z,"."));}if(k.forEach((C,z)=>Ie("star",C.c+.5,C.r+.95,.85,.85).tag=String(z)),n.boss){let C=Ie("boss",a-5,8,2.2,2.4);C.hp=n.bossHp,C.tag="walk",C.t=2;}$e();},Ne=(T,H,u)=>T.slice(0,H)+u+T.slice(H+1),se=(T,H,u,f)=>{switch(T){case "walker":return {shape:"actor",cast:"foe",h:u*f*1.35,pose:"walk",depth:8};case "spiky":return {shape:"actor",cast:"foe2",h:u*f*1.4,pose:"walk",depth:8};case "hopper":return {shape:"actor",cast:"foe3",h:u*f*1.35,pose:"idle",depth:8};case "flyer":return {shape:"actor",cast:"foe5",h:u*f*1.4,pose:"air",depth:8};case "gunner":return {shape:"actor",cast:"foe4",h:u*f*1.3,pose:"idle",depth:8};case "boss":return {shape:"actor",cast:"boss",h:u*f*1.2,pose:"walk",depth:8};case "bullet":return {shape:"sprite",art:"shot",color:"danger",w:H*f,h:u*f,depth:9};case "wave":return {shape:"sprite",art:"burst",color:"danger",w:H*f,h:u*f,depth:9};case "coin":return {shape:"sprite",art:"coin",w:H*f,h:u*f,depth:7};case "star":return {shape:"sprite",art:"bigstar",w:H*f,h:u*f,depth:7};case "heart":return {shape:"sprite",art:"heart",w:H*f,h:u*f,depth:7};case "key":return {shape:"sprite",art:"key",w:H*f,h:u*f,depth:7};case "chest":return {shape:"sprite",art:"chest",w:H*f,h:u*f*1.1,depth:6};case "spring":return {shape:"sprite",art:"spring",w:H*f,h:u*f*1.4,depth:6};case "mover":return {shape:"tile",art:"platform",w:H*f,h:u*f,unit:f,depth:5};case "checkpoint":return {shape:"sprite",art:"flag",color:"muted",w:H*f*1.6,h:u*f,depth:5};case "flag":return {shape:"sprite",art:"flag",w:H*f*1.4,h:u*f,depth:5}}};function Ie(T,H,u,f,b){let c=e.create(),p={kind:T,vx:0,vy:0,dir:-1,t:0,baseX:H,baseY:u,hp:1,tag:"",safe:0};return e.set(c,ut,p),e.set(c,sr,{x:H,y:u,w:f,h:b}),e.set(c,F,{x:0,y:0}),e.set(c,le,se(T,f,b,ce())),e.need(c,ut)}function $e(){for(let H of e.query(cs))e.destroy(H);let T=(Number(e.vars.view_h??1280)-(ke()+10*ce()))/ce()+.5;for(let H=0;H<10;H++){let u=0;for(;u<a;){let f=s[H][u];if(f==="."||f==="_"){f==="_"&&Se("_",u,H,1,.45),u++;continue}let b=f==="#"&&_e(u,H-1)!=="#",c=u;for(;c<a&&s[H][c]===f&&(f!=="#"||_e(c,H-1)!=="#"===b);)c++;if(f==="#"&&b){let p=0;for(;H+p<10&&s[H+p][u]==="#";)p++;Se("#",u,H,c-u,p+(H+p>=10?T:0));}else f!=="#"&&Se(f,u,H,c-u,f==="="?.45:.7);u=c;}}}function Se(T,H,u,f,b){let c=ce(),p=e.create();e.set(p,cs,{char:T}),e.set(p,sr,{x:H+f/2,y:T==="^"?u+1:u+b,w:f,h:b}),e.set(p,F,{x:0,y:0});let k=T==="^"?{shape:"tile",art:"spike",w:f*c,h:b*c,unit:c,depth:4}:T==="#"?{shape:"tile",art:"ground",w:f*c,h:b*c,unit:c*1.2,depth:3}:{shape:"tile",art:"platform",w:f*c,h:b*c,unit:c,depth:3,...T==="_"?{color:"muted",alpha:.85}:{}};e.set(p,le,k),T==="_"&&e.set(p,ut,{kind:"mover",vx:0,vy:0,dir:0,t:0,baseX:H,baseY:u,hp:0,tag:"crumble",safe:0});}let Ye=()=>{(i===null||!e.isAlive(i))&&(i=e.create(),e.set(i,wr,{vx:0,vy:0,grounded:true,facing:1,jumps:0,coyote:0,buffer:0,dash:0,dashCd:0,wall:0,swing:0,swingCd:0}),e.set(i,sr,{x:m.x,y:m.y,w:cu,h:nf}),e.set(i,F,{x:0,y:0})),e.set(i,le,{shape:"actor",cast:Pe().cast,h:nf*ce()*1.25,pose:"idle",depth:10});},ee=()=>Math.sqrt(2*Cn*iu*(1+gn(e,"meta:jump"))*(Pe().perk==="jump"?1.15:1)),Re=()=>{if(i===null)return;let T=e.need(i,sr),H=e.need(i,wr);T.x=m.x,T.y=m.y,H.vx=0,H.vy=0;for(let u of e.query(ut))(e.need(u,ut).kind==="bullet"||e.need(u,ut).kind==="wave")&&e.destroy(u);},rt=()=>{hr(),Ke(),x=r("lives")+gn(e,"meta:hearts")+(Pe().perk==="heart"?1:0),v=x,D=0,O=false,N=false,q=0,ne=0,Z=0,ye=false,be=!n.boss,Ee.fill(false),fe=Ea(gn(e,"meta:stars_total")),r("doubleJump")&&!fe.includes("double")&&fe.push("double"),e.vars.abilities=fe.join(","),e.vars.platformer_level=n.level,e.vars.platformer_world=n.world,e.vars.lives=v,e.vars.coins=0,e.vars.score=0,e.vars.stars=0,e.vars.reviving=false,h=0,Ye(),Re(),i!==null&&(e.need(i,wr).facing=1,at(e,i,"idle")),n.boss&&e.emit(ou,{}),Et(e);},ht=()=>{!ot(e)||we()||i===null||(e.need(i,wr).buffer=.13);},De=()=>{if(i===null)return;let T=e.need(i,wr);T.vy<0&&(T.vy*=.5);},Qt=()=>{if(!ot(e)||we()||i===null||!fe.includes("dash"))return;let T=e.need(i,wr);T.dashCd>0||(T.dash=.2,T.dashCd=.8,T.vy=0,Ge(e,i,"attack"));},Xe=()=>{if(!ot(e)||we()||i===null)return;let T=e.need(i,wr);T.swingCd>0||(T.swing=.16,T.swingCd=.32,Ge(e,i,"attack"));};e.on(zt,T=>{let H=T;e.vars.started_tick!==e.tick&&(H.type==="key"&&(H.key==="up"||H.key==="action")?ht():H.type==="key-up"&&(H.key==="up"||H.key==="action")?De():H.type==="key"&&H.key==="down"?Qt():H.type==="tap"?Xe():H.type==="swipe"&&H.dir==="up"&&ht());});let et=(T,H)=>{if(!ot(T)||O)return;O=true;let u=H==="cleared",f=Ee.filter(Boolean).length;T.vars.stars=f,u&&T.vars["meta:first_clear"]===true&&Qe(T,"coins",n.firstClearGold),T.vars.score=Z*r("coinScore")+f*r("starScore")+(u?r("clearBonus"):0),T.vars.reviving=false,u&&T.emit(Cl,{level:n.level}),T.emit(Ut,{reason:H,stats:{chapter:n.level,seconds:Math.floor(q),cleared:u,stars:u?f:0,coins:Z,bosses:n.boss&&be?1:0}});},it=T=>{if(T.vars.revive_ready===true&&!N){T.vars.reviving=true,T.emit(er,{});return}et(T,"fell");},dt=T=>{we()&&(N=true,T.vars.reviving=false,v=Math.max(2,Math.ceil(x/2)),T.vars.lives=v,D=2.5,Re(),i!==null&&at(T,i,"idle"),K(T,{kind:"flash",color:"coin"}));},mt=(T,H)=>{if(i===null||D>0||O)return;let u=T.need(i,wr);u.dash>0||(v--,T.vars.lives=v,T.emit("player-hit",{lives:v}),D=r("graceTime")+gn(T,"meta:grace"),u.vy=-ee()*.55,u.vx=(H===null?-u.facing:Math.sign(T.need(i,sr).x-H)||-u.facing)*5,Ge(T,i,"hit"),K(T,{kind:"shake",power:1.2}),K(T,{kind:"flash",color:"danger"}),v<=0&&it(T));},yt=(T,H,u)=>{let f=T.need(H,ut),b=T.need(H,sr),c=ce();K(T,{kind:"burst",x:ft(b.x),y:ze(b.y-b.h/2),color:"danger",n:12,size:c*.9}),T.emit("enemy-defeated",{kind:f.kind,by:u}),Qe(T,"score",50),T.destroy(H);},gt=(T,H)=>{let u=T.need(H,sr);ne+=1+gn(T,"meta:greed");let f=Math.floor(ne);ne-=f,f>0&&Qe(T,"coins",f),Z++,T.emit("coin-collected",{value:1}),K(T,{kind:"burst",x:ft(u.x),y:ze(u.y-u.h/2),color:"coin",n:6,size:ce()*.6}),T.destroy(H);},ft=T=>T*ce()-h*ce(),ze=T=>ke()+T*ce();function Et(T){ce();for(let u of T.query(sr)){let f=T.need(u,sr),b=T.get(u,F);if(!b)continue;b.x=ft(f.x),b.y=ze(f.y-f.h/2);let c=T.get(u,le);if(c&&c.shape==="actor"&&T.has(u,ut)){let p=T.need(u,ut);c.facing=p.dir>=0?1:-1,c.alpha=p.safe>0&&Math.floor(T.time*12)%2===0?.35:1,b.y=ze(f.y)-c.h/2;}if(c&&c.shape==="actor"&&T.has(u,wr)&&(b.y=ze(f.y)-c.h/2),c&&T.has(u,cs)&&T.need(u,cs).char==="_"){let p=de.get(`${Math.floor(f.x)},${Math.round(f.y-f.h)}`)??0;c.alpha=p>.5?0:p>0?.5+.5*Math.abs(Math.sin(T.time*30)):.85;}}}let Ze=(T,H,u,f)=>{let b=Ae.get(T);(b===void 0||!e.isAlive(b))&&(b=e.create(),e.set(b,rf,{id:T}),Ae.set(T,b)),e.set(b,F,{x:H,y:u}),e.set(b,le,f);},Wt=T=>{let H=Ae.get(T);H!==void 0&&e.destroy(H),Ae.delete(T);};function hr(){for(let T of Ae.values())e.destroy(T);Ae.clear(),ct(e,rf);}let Nt=T=>{let H=Number(T.vars.view_w??720),u=Number(T.vars.view_h??1280),f=Math.min(H,u),b=u*.085;Ze("lvl",H*.08,b,{shape:"text",text:`${n.world}-${n.index}`,size:Math.round(f*.042),color:"text",bold:true,depth:42});let c=f*.05;for(let C=0;C<x;C++)Ze(`h${C}`,H*.07+C*c*1.1,b+f*.065,{shape:"sprite",art:"heart",w:c,h:c,alpha:C<v?1:.25,depth:42});for(let C=x;C<12;C++)Wt(`h${C}`);let p=f*.06;for(let C=0;C<3;C++)Ze(`s${C}`,H/2+(C-1)*p*1.15,b,{shape:"sprite",art:"bigstar",w:p,h:p,alpha:Ee[C]?1:.25,depth:42});let k=f*.045,_=String(T.vars.coins??0);if(Ze("coin:i",H*.92-_.length*k*.6-k*.7,b,{shape:"sprite",art:"coin",w:k,h:k,depth:42}),Ze("coin",H*.92-_.length*k*.6/2,b,{shape:"text",text:_,size:Math.round(k),color:"text",bold:true,depth:42}),ye?Ze("key",H*.92-k*.3,b+f*.065,{shape:"sprite",art:"key",w:k,h:k,depth:42}):Wt("key"),n.boss){let C=T.query(ut).find(Me=>T.need(Me,ut).kind==="boss"),z=C!==void 0?T.need(C,ut).hp/n.bossHp:0,B=H*.5,ae=Math.max(10,f*.022);Ze("boss:bg",H/2,b+f*.075,{shape:"rect",w:B,h:ae,color:"#000000",alpha:.45,radius:ae/2,depth:41});let pe=Math.max(0,(B-4)*Math.round(z*100)/100);pe<1?Wt("boss:fill"):Ze("boss:fill",H/2-(B-4)/2+pe/2,b+f*.075,{shape:"rect",w:pe,h:ae-4,color:"danger",radius:(ae-4)/2,depth:41.1});}};e.on(qt,()=>{rt(),e.vars.level=n.level;}),e.on(Zt,rt),e.on(tr,()=>dt(e)),e.on(rr,()=>{we()&&(e.vars.reviving=false,et(e,"fell"));}),e.on(Xt,T=>{i!==null&&e.isAlive(i)&&at(e,i,T.reason==="cleared"?"dance":"die"),hr();}),e.on(Ft,()=>{Bt(e,"side",ke()+8*ce()+2);let T=ce();for(let H of e.query(ut)){let u=e.need(H,ut);if(u.tag==="crumble")continue;let f=e.need(H,sr);e.set(H,le,se(u.kind,f.w,f.h,T));}$e(),Ye(),Et(e);}),e.addSystem({id:"platformer",order:0,run(T,H){if(!ot(T)||i===null||O||we())return;q+=H,D>0&&(D=Math.max(0,D-H));let u=T.need(i,sr),f=T.need(i,wr),b=n.pace;for(let[Y,M]of [...de]){let E=M+H;E>3.5?de.delete(Y):de.set(Y,E);}let c=o.axis().x;if(c!==0&&(f.facing=c),f.dash>0)f.dash-=H,f.vx=f.facing*15,f.vy=0;else {let Y=c*au,M=f.grounded?60:32;f.vx+=Math.max(-M*H,Math.min(M*H,Y-f.vx)),f.vy+=Cn*H,f.vy>22&&(f.vy=22);}if(f.dashCd>0&&(f.dashCd-=H),f.swingCd>0&&(f.swingCd-=H),f.swing>0){f.swing-=H;let Y={l:f.facing>0?u.x:u.x-1.4,r:f.facing>0?u.x+1.4:u.x,t:u.y-u.h-.2,b:u.y};for(let M of T.query(ut)){if(!T.isAlive(M)||!T.has(M,ut))continue;let E=T.need(M,ut);if(!["walker","spiky","hopper","flyer","gunner","boss","bullet"].includes(E.kind))continue;let l=T.need(M,sr);l.x+l.w/2<Y.l||l.x-l.w/2>Y.r||l.y-l.h>Y.b||l.y<Y.t||(E.kind==="bullet"?(K(T,{kind:"burst",x:ft(l.x),y:ze(l.y-l.h/2),color:"text",n:6,size:ce()*.5}),T.destroy(M)):E.kind==="boss"?ur(T,M,"sword"):yt(T,M,"sword"));}}if(f.coyote=f.grounded?.1:Math.max(0,f.coyote-H),f.buffer>0){f.buffer-=H;let Y=fe.includes("double")&&f.jumps<2;f.coyote>0||f.grounded?(f.vy=-ee(),f.jumps=1,f.buffer=0,f.grounded=false,f.coyote=0):f.wall!==0&&fe.includes("wall")?(f.vy=-ee()*.95,f.vx=-f.wall*7,f.facing=-f.wall,f.jumps=1,f.buffer=0):Y&&f.jumps>=1&&(f.vy=-ee()*.9,f.jumps=2,f.buffer=0,K(T,{kind:"ring",x:ft(u.x),y:ze(u.y),color:"text",size:ce()*1.2})),f.buffer===0&&Ge(T,i,"jump");}let p=u.w/2,k=u.x+f.vx*H;f.wall=0;let _=Y=>{let M=[];for(let E=Math.floor(Y-u.h+.05);E<=Math.floor(Y-.05);E++)M.push(E);return M};if(f.vx>0){let Y=Math.floor(k+p);_(u.y).some(M=>oe(_e(Y,M)))&&(k=Y-p-.001,f.grounded||(f.wall=1),f.vx=0);}else if(f.vx<0){let Y=Math.floor(k-p);_(u.y).some(M=>oe(_e(Y,M)))&&(k=Y+1+p+.001,f.grounded||(f.wall=-1),f.vx=0);}f.wall===0&&!f.grounded&&c!==0&&_(u.y).some(Y=>oe(_e(Math.floor(k+c*(p+.05)),Y)))&&(f.wall=c),u.x=Math.max(p,Math.min(a-p,k));let C=u.y,z=u.y+f.vy*H,B=f.grounded;f.grounded=false;let ae=[Math.floor(u.x-p+.05),Math.floor(u.x+p-.05)];if(f.vy>=0){let Y=Math.floor(z);for(let M of ae){let E=_e(M,Y),l=Y;if((oe(E)||Te(E)&&C<=l+.05)&&z>=l){z=l,f.vy=0,f.grounded=true,f.jumps=0,E==="_"&&!de.has(`${M},${Y}`)&&de.set(`${M},${Y}`,.001),E==="^"&&(mt(T,null),f.vy=-ee()*.7,f.grounded=false);break}}}else {let Y=Math.floor(z-u.h);ae.some(M=>oe(_e(M,Y)))&&(z=Y+1+u.h,f.vy=0);}u.y=z,!B&&f.grounded&&Ge(T,i,"jump");for(let Y of T.query(ut)){let M=T.need(Y,ut);if(M.kind!=="mover"||M.tag==="crumble")continue;let E=T.need(Y,sr),l=E.x;M.t+=H,E.x=M.baseX+Math.sin(M.t*.9)*2.2;let w=E.y-E.h;f.vy>=0&&Math.abs(u.x-E.x)<E.w/2+p*.6&&C<=w+.1&&u.y>=w-.05&&(u.y=w,f.vy=0,f.grounded=true,f.jumps=0,u.x+=E.x-l);}if(u.y>12&&(mt(T,null),D=Math.max(D,1),!we()&&!O&&Re(),O||we()))return;let pe={l:u.x-p,r:u.x+p,t:u.y-u.h,b:u.y},Me=Y=>pe.r>Y.x-Y.w/2&&pe.l<Y.x+Y.w/2&&pe.b>Y.y-Y.h&&pe.t<Y.y,qe=1.2*(1+gn(T,"meta:magnet")),tt=u.x;for(let Y of T.query(ut)){if(!T.isAlive(Y)||!T.has(Y,ut))continue;let M=T.need(Y,ut),E=T.need(Y,sr);switch(M.safe>0&&(M.safe-=H),M.kind){case "walker":case "spiky":{M.vx=M.dir*1.6*b;let l=E.x+M.dir*(E.w/2+.05)+M.vx*H,w=oe(_e(Math.floor(l),Math.floor(E.y-.5))),A=_e(Math.floor(l),Math.floor(E.y));w||!(oe(A)||Te(A))?M.dir=-M.dir:E.x+=M.vx*H;break}case "hopper":{M.t+=H,M.vy+=Cn*.6*H,E.y+=M.vy*H,E.y>=M.baseY&&(E.y=M.baseY,M.vy=0,M.t>1.5/b&&(M.t=0,M.vy=-Math.sqrt(2*Cn*.6*2.4))),M.dir=tt<E.x?-1:1;break}case "flyer":M.t+=H*b,E.x=M.baseX+Math.sin(M.t*.9)*3,E.y=M.baseY+Math.sin(M.t*1.8)*.9,M.dir=Math.cos(M.t*.9)>=0?1:-1;break;case "gunner":{if(M.dir=tt<E.x?-1:1,M.t+=H,M.t>2.2/b&&Math.abs(tt-E.x)<9){M.t=0;let l=Ie("bullet",E.x+M.dir*.6,E.y-.45,.45,.3);l.vx=M.dir*6*b,l.dir=M.dir,Ge(T,Y,"attack");}break}case "bullet":case "wave":if(E.x+=M.vx*H,M.t+=H,M.t>(M.kind==="wave"?2.2:3.5)||oe(_e(Math.floor(E.x),Math.floor(E.y-.1)))){T.destroy(Y);continue}break;case "boss":Tt(T,Y,M,E,tt,H);break;case "coin":Math.hypot(E.x-u.x,E.y-(u.y-u.h/2))<qe&&qe>1.21&&(E.x+=(u.x-E.x)*Math.min(1,H*10),E.y+=(u.y-u.h/2-E.y)*Math.min(1,H*10));break;}if(!(!T.isAlive(Y)||!Me(E))){switch(M.kind){case "coin":gt(T,Y);break;case "star":{let l=Number(M.tag);Ee[l]=true,T.vars.stars=Ee.filter(Boolean).length,T.emit("star-collected",{index:l}),K(T,{kind:"ring",x:ft(E.x),y:ze(E.y-E.h/2),color:"coin",size:ce()*2.4}),K(T,{kind:"flash",color:"coin"}),T.destroy(Y);break}case "heart":v=Math.min(x,v+1),T.vars.lives=v,K(T,{kind:"ring",x:ft(E.x),y:ze(E.y-E.h/2),color:"danger",size:ce()*1.6}),T.destroy(Y);break;case "key":ye=true,K(T,{kind:"ring",x:ft(E.x),y:ze(E.y-E.h/2),color:"coin",size:ce()*1.6}),T.destroy(Y);break;case "chest":if(ye&&M.tag!=="open"){M.tag="open",ye=false;for(let w=0;w<15;w++)ne+=1+gn(T,"meta:greed"),Z++;let l=Math.floor(ne);ne-=l,Qe(T,"coins",l),K(T,{kind:"burst",x:ft(E.x),y:ze(E.y-E.h/2),color:"coin",n:24,size:ce()*1.4}),K(T,{kind:"pop",x:ft(E.x),y:ze(E.y-E.h*1.4),text:"+15",color:"coin",size:Math.round(ce()*.5)});}break;case "spring":f.vy>0&&u.y-(E.y-E.h)<.5&&(f.vy=-Math.sqrt(2*Cn*lu),f.jumps=1,K(T,{kind:"ring",x:ft(E.x),y:ze(E.y-E.h),color:"accent",size:ce()*1.4}));break;case "checkpoint":if(M.tag!=="on"){M.tag="on",m={x:E.x,y:E.y};let l=T.need(Y,le);l.shape==="sprite"&&(l.color="accent"),T.emit("checkpoint",{}),K(T,{kind:"ring",x:ft(E.x),y:ze(E.y-E.h/2),color:"accent",size:ce()*2});}break;case "flag":if(be){et(T,"cleared");return}break;case "walker":case "hopper":case "flyer":case "gunner":case "spiky":case "boss":{let l=f.vy>0&&u.y-(E.y-E.h)<.55&&M.kind!=="spiky";f.dash>0&&M.kind!=="boss"?yt(T,Y,"dash"):l?(f.vy=-ee()*.65,f.jumps=1,M.kind==="boss"?ur(T,Y,"stomp"):yt(T,Y,"stomp")):mt(T,E.x);break}case "bullet":case "wave":mt(T,E.x),T.destroy(Y);break;}if(O||we())return}}let pt=Le(),re=Math.max(0,Math.min(Math.max(0,a-pt),u.x-pt*.4+f.facing*pt*.08)),j=h;h+=(re-h)*Math.min(1,H*6),Zo(T,(h-j)*ce()),T.vars.level_progress=Math.min(1,u.x/Math.max(1,a));let J=T.need(i,le);J.shape==="actor"&&(J.facing=f.facing>=0?1:-1,J.pose=f.grounded?Math.abs(f.vx)>.5?"run":"idle":"air",J.speed=Math.abs(f.vx)*ce(),J.alpha=D>0&&Math.floor(T.time*12)%2===0?.35:1),Et(T),Nt(T);}});function ur(T,H,u){let f=T.need(H,ut);f.safe>0||(f.hp--,f.safe=1,Ge(T,H,"hit"),K(T,{kind:"shake",power:1}),f.hp<=0&&(be=true,T.emit(su,{}),yt(T,H,u),Ie("flag",a-2,8,.8,2.6)));}function Tt(T,H,u,f,b,c){if(u.t-=c,u.vy+=Cn*c,f.y=Math.min(u.baseY,f.y+u.vy*c),f.y>=u.baseY){if(u.tag==="slam-air"){u.tag="walk",u.t=1.6,K(T,{kind:"shake",power:1.4});for(let p of [-1,1]){let k=Ie("wave",f.x+p*1.2,u.baseY,.9,.6);k.vx=p*8*n.pace;}}u.vy=0;}if(u.tag==="walk"){if(u.dir=b<f.x?-1:1,f.x+=u.dir*1.4*n.pace*c,u.t<=0){let p=Math.floor(T.rng.next()*3);if(p===0)u.tag="charge",u.t=1.1,u.vx=u.dir*9*n.pace,at(T,H,"run");else if(p===1)u.tag="slam-air",u.vy=-Math.sqrt(2*Cn*4),Ge(T,H,"jump");else {u.tag="walk",u.t=2.4;for(let k of [a-15,a-3])Ie("walker",k,u.baseY,.8,1).dir=k<f.x?1:-1;Ge(T,H,"cheer");}}}else u.tag==="charge"&&(f.x+=u.vx*c,(u.t<=0||oe(_e(Math.floor(f.x+Math.sign(u.vx)*1.2),Math.floor(u.baseY-1))))&&(u.tag="walk",u.t=1.8,at(T,H,"walk")));f.x=Math.max(a-17.5,Math.min(a-1.2,f.x));}Bt(e,"side",ke()+8*ce()+2),rt();}};var fr=5,La=6,_a=6,Ir={blaster:{id:"blaster",art:"shot",color:"coin",damage:[10,13,15,18,24],cooldown:[.8,.7,.62,.55,.42],count:[1,1,2,2,3],pierce:[1,1,1,2,3]},blades:{id:"blades",art:"blade",color:"primary",damage:[8,10,12,14,19],cooldown:[.45,.42,.4,.38,.32],count:[2,2,3,3,5],reach:[.15,.16,.17,.18,.21]},aura:{id:"aura",art:"aura",color:"secondary",damage:[5,7,9,11,16],cooldown:[.5,.5,.45,.45,.4],count:[1,1,1,1,1],reach:[.11,.125,.14,.155,.19]},boomerang:{id:"boomerang",art:"boomerang",color:"accent",damage:[16,20,24,28,38],cooldown:[1.8,1.6,1.4,1.25,1],count:[1,1,2,2,3],reach:[.34,.36,.38,.4,.46]},lightning:{id:"lightning",art:"lightning",color:"primary",damage:[18,22,26,30,42],cooldown:[2,1.8,1.6,1.4,1.1],count:[2,3,4,5,7],reach:[.22,.23,.24,.25,.3]},drone:{id:"drone",art:"drone",color:"piece6",damage:[9,11,13,15,21],cooldown:[1,.9,.8,.7,.55],count:[1,1,2,2,3],reach:[.11,.11,.12,.12,.13]}},Pn=Object.keys(Ir),bo={might:{id:"might",art:"fist",color:"danger",step:.12},haste:{id:"haste",art:"hourglass",color:"primary",step:.07},area:{id:"area",art:"aura",color:"secondary",step:.1},swift:{id:"swift",art:"boot",color:"accent",step:.08},vigor:{id:"vigor",art:"heart",color:"danger",step:20},armor:{id:"armor",art:"shield",color:"muted",step:1.5},magnet:{id:"magnet",art:"magnet",color:"danger",step:.3},luck:{id:"luck",art:"clover",color:"accent",step:.2},growth:{id:"growth",art:"crystal",color:"accent",step:.1}},Ra=Object.keys(bo),tn={swarm:{kind:"swarm",cast:"foe5",hp:.6,speed:118,size:.045,damage:5,xp:1,from:0,weight:3},grunt:{kind:"grunt",cast:"foe",hp:1,speed:95,size:.055,damage:8,xp:1,from:0,weight:4},archer:{kind:"archer",cast:"foe3",hp:1.2,speed:88,size:.055,damage:7,xp:2,from:.8,weight:2},brute:{kind:"brute",cast:"foe2",hp:5,speed:62,size:.085,damage:14,xp:5,from:1.6,weight:1.2},charger:{kind:"charger",cast:"foe4",hp:2.5,speed:80,size:.065,damage:12,xp:3,from:2.4,weight:1.4},bomber:{kind:"bomber",cast:"foe5",hp:1.5,speed:120,size:.055,damage:16,xp:2,from:3.2,weight:1.4},miniboss:{kind:"miniboss",cast:"boss",hp:45,speed:75,size:.12,damage:18,xp:25,from:99,weight:0},boss:{kind:"boss",cast:"boss",hp:160,speed:70,size:.16,damage:24,xp:0,from:99,weight:0}},of=["swarm","grunt","archer","brute","charger","bomber"],Aa=10;function xo(e,t){let r=Math.max(1,Math.min(Aa,Math.floor(e)));return {chapter:r,duration:Math.min(600,t+(r-1)*30),hp:1+(r-1)*.45,damage:1+(r-1)*.12,headStart:(r-1)*.4,firstClearGold:100+(r-1)*60}}var ko=[{id:"hero",cast:"hero",weapon:"blaster",passive:null,gems:0},{id:"hero2",cast:"hero2",weapon:"blades",passive:"vigor",gems:150},{id:"hero3",cast:"hero3",weapon:"lightning",passive:"area",gems:300}],Pl=[{id:"Might",var:"meta:might",art:"fist",color:"danger",perLevel:4,unit:"%",maxLevel:50,price:30,growth:.09},{id:"Vitality",var:"meta:hp",art:"heart",color:"danger",perLevel:8,unit:"",maxLevel:50,price:25,growth:.09},{id:"Armor",var:"meta:armor",art:"shield",color:"muted",perLevel:.5,unit:"",maxLevel:30,price:40,growth:.1},{id:"Swiftness",var:"meta:speed",art:"boot",color:"accent",perLevel:2,unit:"%",maxLevel:25,price:35,growth:.1},{id:"Magnet",var:"meta:magnet",art:"magnet",color:"danger",perLevel:6,unit:"%",maxLevel:25,price:20,growth:.1},{id:"Luck",var:"meta:luck",art:"clover",color:"accent",perLevel:5,unit:"%",maxLevel:25,price:30,growth:.1},{id:"Growth",var:"meta:growth",art:"crystal",color:"accent",perLevel:3,unit:"%",maxLevel:30,price:30,growth:.1},{id:"Recovery",var:"meta:regen",art:"potion",color:"accent",perLevel:.1,unit:"",maxLevel:30,price:45,growth:.1}],Il="kit-survivors",sf=30,af=10,lf={game:"survivors",character:Il,stats:Pl,heroes:ko,levels:Aa,firstClearGold:e=>xo(e,300).firstClearGold,stars:0};var Da=ve("survivors.hero"),We=ve("survivors.foe"),zn=ve("survivors.shot"),nn=ve("survivors.bullet"),ar=ve("survivors.drop"),bn=ve("survivors.blade"),In=ve("survivors.aura"),Nn=ve("survivors.drone"),ds=ve("survivors.boomerang"),fs=ve("survivors.zap"),vo=ve("survivors.halo"),cf=ve("survivors.hud"),xn=ve("survivors.joystick"),Nl="level-up",zl="upgrade-picked",Bl="upgrade-pick",Hl="upgrade-reroll";var Oa="boss-spawned",Wl="boss-defeated",jl=e=>[...Object.entries(e.weapons).map(([t,r])=>`w:${t}:${r}`),...Object.entries(e.passives).map(([t,r])=>`p:${t}:${r}`)].join(","),df=e=>{let t={},r={};for(let o of String(e??"").split(",")){let[n,s,a]=o.split(":");n==="w"&&s&&s in Ir?t[s]=Number(a):n==="p"&&s&&s in bo&&(r[s]=Number(a));}return {weapons:t,passives:r}},Vl=e=>e.map(t=>`${t.kind}:${t.id}:${t.level}`).join(","),ff=e=>String(e??"").split(",").filter(Boolean).map(t=>{let[r,o,n]=t.split(":");return {kind:r,id:o??"",level:Number(n??1)}}),Ta=e=>e.vars.reviving===true,rn=(e,t)=>{let r=Number(e.vars[t]??0);return Number.isFinite(r)?r:0},Ca={id:"survivors",version:2,engines:["phaser"],requires:["round"],params:{duration:{type:"number",default:300,min:20,max:900},heroSpeed:{type:"number",default:260,min:80,max:800},hp:{type:"number",default:100,min:10,max:2e3},spawnRate:{type:"number",default:1.2,min:.1,max:10},spawnGrowth:{type:"number",default:.9,min:0,max:10},foeHp:{type:"number",default:10,min:1,max:1e3},foeHpGrowth:{type:"number",default:.45,min:0,max:5},foeDamage:{type:"number",default:1,min:.1,max:10},foeSpeed:{type:"number",default:1,min:.3,max:3},damage:{type:"number",default:1,min:.1,max:100},shotSpeed:{type:"number",default:640,min:100,max:2e3},xpFirst:{type:"number",default:4,min:1,max:100,integer:true},xpGrowth:{type:"number",default:1.25,min:1,max:2},coinRate:{type:"number",default:.25,min:0,max:1},killScore:{type:"number",default:10,min:0,max:1e3,integer:true},bossScore:{type:"number",default:500,min:0,max:1e5,integer:true},clearBonus:{type:"number",default:1e3,min:0,max:1e5,integer:true},graceTime:{type:"number",default:.6,min:0,max:5},maxFoes:{type:"number",default:46,min:5,max:160,integer:true},minibossEvery:{type:"number",default:120,min:0,max:900},eliteEvery:{type:"number",default:50,min:0,max:900}},setup({world:e,params:t,mode:r}){let o=e.rng.stream("survivors"),n=Jn(e),s=l=>yr(t,l),a=null,i=null,h=0,m={},v={},x={},D=0,O=0,N=0,q=1,ne=0,Z=0,ye=[],be="level",fe=0,Ee=0,de=0,Ae=false,Pe=0,we=0,ce=300,ke=xo(1,300),Le=false,_e=null,oe=0,Te=0,Ke=0,Ne=0,se=null,Ie=0,$e=0,Se=false,Ye=new Map,ee={maxHp:100,hp:100,regen:0,armor:0,speed:260,magnet:80,might:1,haste:1,area:1,luck:1,growth:1},Re=()=>Math.min(Be(e).w,Be(e).h),rt=()=>Re()/720,ht=()=>Re()*.07,De=()=>{let l=Be(e);return {x:l.w/2,y:l.h/2}},Qt=()=>{let l=A=>v[A]??0,w=ee.maxHp;ee.might=(1+rn(e,"meta:might")+.12*l("might"))*s("damage"),ee.haste=Math.max(.4,1-.07*l("haste")),ee.area=1+.1*l("area"),ee.speed=s("heroSpeed")*rt()*(1+rn(e,"meta:speed")+.08*l("swift")),ee.maxHp=s("hp")+rn(e,"meta:hp")+20*l("vigor"),ee.regen=rn(e,"meta:regen")+.3*l("vigor"),ee.armor=rn(e,"meta:armor")+1.5*l("armor"),ee.magnet=Re()*.12*(1+rn(e,"meta:magnet")+.3*l("magnet")),ee.luck=1+rn(e,"meta:luck")+.2*l("luck"),ee.growth=1+rn(e,"meta:growth")+.1*l("growth"),ee.maxHp>w&&(ee.hp+=ee.maxHp-w),ee.hp=Math.min(ee.hp,ee.maxHp),e.vars.survivors_build=jl({weapons:m,passives:v});},Xe=l=>Math.ceil(s("xpFirst")*Math.pow(l,s("xpGrowth"))),et=()=>ko.find(l=>l.id===e.vars["meta:hero"])??ko[0],it=()=>{let l=De(),w=ht();(a===null||!e.isAlive(a))&&(a=e.create(),e.set(a,Da,{size:w})),e.need(a,Da).size=w,e.set(a,F,{x:l.x,y:l.y}),e.set(a,le,{shape:"actor",cast:et().cast,h:w*2.3,feet:w*.6,pose:"idle",depth:Jt(e,l.y)});},dt=(l,w,A,d)=>{let y=Ye.get(l);(y===void 0||!e.isAlive(y))&&(y=e.create(),e.set(y,cf,{id:l}),Ye.set(l,y)),e.set(y,F,{x:w,y:A}),e.set(y,le,d);},mt=l=>{let w=Ye.get(l);w!==void 0&&e.destroy(w),Ye.delete(l);},yt=()=>{for(let l of Ye.values())e.destroy(l);Ye.clear(),ct(e,cf);},gt=(l,w,A,d,y,R,S,$=41)=>{let g=Math.max(0,Math.min(1,Math.round(R*100)/100));dt(`${l}:bg`,w,A,{shape:"rect",w:d,h:y,color:"#000000",alpha:.45,radius:y/2,depth:$});let L=Math.max(0,(d-4)*g);L<1?mt(`${l}:fill`):dt(`${l}:fill`,w-(d-4)/2+L/2,A,{shape:"rect",w:L,h:y-4,color:S,radius:(y-4)/2,depth:$+.01});},ft=l=>{let w=Be(l),A=Re(),d=w.h*.085,y=w.w*.9,R=Math.max(10,A*.026);gt("xp",w.w/2,d,y,R,N/Xe(q),"accent"),dt("lv",w.w/2+y/2-A*.04,d+R*1.6,{shape:"text",text:`Lv ${q}`,size:Math.round(A*.032),color:"text",bold:true,depth:42});let S=d+A*.075;if(_e!==null&&l.isAlive(_e)&&l.has(_e,We)){let X=l.need(_e,We);gt("boss",w.w/2,S,w.w*.62,Math.max(14,A*.034),X.hp/X.maxHp,"danger"),dt("time",w.w/2,S-A*.05,{shape:"text",text:X.kind==="boss"?"BOSS":"MINI BOSS",size:Math.round(A*.036),color:"danger",bold:true,depth:42}),l.vars.boss_hp=X.hp/X.maxHp;}else mt("boss:bg"),mt("boss:fill"),dt("time",w.w/2,S,{shape:"text",text:Vs(Number(l.vars.time_left??0)),size:Math.round(A*.05),color:"text",bold:true,depth:42}),l.vars.boss_hp=0;let $=Math.round(A*.036);dt("kills:i",w.w*.06,S,{shape:"sprite",art:"skull",w:$*1.1,h:$*1.1,color:"text",depth:42}),dt("kills",w.w*.06+$*.75+String(Ee).length*$*.28,S,{shape:"text",text:String(Ee),size:$,color:"text",bold:true,depth:42});let g=A*.05,L=0,I=new Set,P=(X,me,ue,xe,ge,Ve)=>{I.add(X),dt(`b:${X}`,ge,Ve,{shape:"sprite",art:me,w:g,h:g,color:ue,alpha:.95,depth:41}),dt(`b:${X}:l`,ge+g*.38,Ve+g*.36,{shape:"text",text:xe>=5?"\u2605":String(xe),size:Math.round(g*.42),color:xe>=5?"coin":"text",bold:true,depth:42});};for(let[X,me]of Object.entries(m)){let ue=Ir[X];P(X,ue.art,ue.color,me??1,w.w*.06+L*g*1.12,S+A*.075),L++;}L=0;for(let[X,me]of Object.entries(v)){let ue=bo[X];P(X,ue.art,ue.color,me??1,w.w*.06+L*g*.95,S+A*.075+g*1.1),L++;}for(let X of [...Ye.keys()])if(X.startsWith("b:")){let me=X.slice(2).replace(/:l$/,"");I.has(me)||mt(X);}let W=ht(),te=De();gt("hp",te.x,te.y+W*1.05,W*1.7,Math.max(7,A*.013),ee.hp/ee.maxHp,ee.hp/ee.maxHp>.35?"accent":"danger",40);},ze=(l=-1)=>{let w=Be(e),A=Re()*.08,d=l>=0?l:o.int(0,3);return {x:d===0?-A:d===1?w.w+A:o.range(-A,w.w+A),y:d===2?-A:d===3?w.h+A:o.range(-A,w.h+A)}},Et=()=>s("foeHp")*ke.hp*(1+s("foeHpGrowth")*(we/60)),Ze=(l,w,A=false)=>{let d=tn[l],y=l==="boss"||l==="miniboss",R=Re()*d.size*(A?1.3:1),S=Et()*d.hp*(A?8:1),$=Pt(e,w.x,w.y,{shape:"actor",cast:d.cast,variant:o.int(0,99),h:R*(y?1.9:l==="brute"?1.75:2.2),feet:R*.6,pose:l==="brute"||y?"walk":"run",depth:Jt(e,w.y)},{type:We,data:{kind:l,hp:S,maxHp:S,speed:d.speed*rt()*s("foeSpeed")*(1+Math.min(.5,we/600)),size:R,damage:d.damage*ke.damage*s("foeDamage")*(A?1.4:1),xp:d.xp*(A?5:1),elite:A,t:o.range(0,1.5),phase:"walk",vx:0,vy:0,hurtAt:{},next:0}});return (A||y)&&Pt(e,w.x,w.y+R*.5,{shape:"sprite",art:"aura_field",w:R*2.2,h:R*1.1,color:y?"danger":"coin",alpha:.85,depth:2},{type:vo,data:{of:$}}),$},Wt=()=>{let l=we/60+ke.headStart,w=Sr(r,"foes",of),A=w.filter(S=>tn[S].from<=l),d=A.length>0?A:[w.reduce((S,$)=>tn[S].from<=tn[$].from?S:$)],y=0;for(let S of d)y+=tn[S].weight;let R=o.range(0,y);for(let S of d)if(R-=tn[S].weight,R<=0)return S;return d[0]??"grunt"},hr=()=>e.query(We).length,Nt=(l,w)=>{let A=we/60+ke.headStart,d=s("spawnRate")*(1+s("spawnGrowth")*A);for(Ie>0&&(Ie-=w,d*=.25),Le&&(d*=.45),se&&(se.left-=w,d*=2.6),Pe+=w*d;Pe>=1;)Pe-=1,!(hr()>=s("maxFoes"))&&Ze(Wt(),ze(se?se.side:-1));if(se&&se.left<=0&&(se=null),!Le){if(we>=Ke){Ke=we+o.range(26,36);let y=Ne++%3;if(y===0){let R=De(),S=12+Math.min(12,Math.floor(A*2)),$=Re()*.62;for(let g=0;g<S;g++){let L=g/S*Math.PI*2;Ze(A>3?"grunt":"swarm",{x:R.x+Math.cos(L)*$,y:R.y+Math.sin(L)*$*1.25});}K(l,{kind:"flash",color:"danger"});}else y===1?se={left:4,side:o.int(0,3)}:Ie=5;}if(s("eliteEvery")>0&&we>=Te){Te=we+s("eliteEvery");let y=Wt();Ze(y==="swarm"?"grunt":y,ze(),true);}s("minibossEvery")>0&&we>=oe&&ce-we>30&&(oe=we+s("minibossEvery"),(_e===null||!l.isAlive(_e))&&(_e=Ze("miniboss",ze()),l.emit(Oa,{kind:"miniboss"}),K(l,{kind:"shake",power:1.2})));}},ur=l=>{Le=true,l.vars.time_left=0;let w=De();for(let A of l.query(We)){let d=l.get(A,We);if(!d||d.kind==="miniboss")continue;let y=l.need(A,F);Math.hypot(y.x-w.x,y.y-w.y)<Re()*.3&&T(l,A,null,false);}_e=Ze("boss",{x:w.x,y:w.y-Be(l).h*.42}),K(l,{kind:"shake",power:2}),K(l,{kind:"flash",color:"danger"}),l.emit(Oa,{kind:"boss"});},Tt=(l,w,A,d=1)=>{let y=ht(),R=l==="xp"?{shape:"sprite",art:"crystal",w:y*(d>=25?.62:d>=5?.5:.38),h:y*(d>=25?.62:d>=5?.5:.38),color:d>=25?"secondary":d>=5?"primary":"accent",depth:3}:l==="coin"?{shape:"sprite",art:"coin",w:y*.4,h:y*.4,depth:3}:l==="food"?{shape:"sprite",art:"heart",w:y*.5,h:y*.5,depth:3}:l==="magnet"?{shape:"sprite",art:"magnet",w:y*.6,h:y*.6,depth:3}:l==="bomb"?{shape:"sprite",art:"bomb",w:y*.6,h:y*.6,depth:3}:{shape:"sprite",art:"chest",w:y*.9,h:y*.9,color:"coin",depth:3};Pt(e,w,A,R,{type:ar,data:{kind:l,value:d,pulled:false}});},T=(l,w,A,d=true)=>{let y=l.get(w,We);if(!y)return;let R=l.need(w,F),S=R.x,$=R.y;l.remove(w,We);for(let I of l.query(vo))l.need(I,vo).of===w&&l.destroy(I);at(l,w,"die");let g=l.need(w,le);if(g.shape==="actor"&&(g.depth=Jt(l,$)-.2),_n(l,w,1.4),K(l,{kind:"burst",x:S,y:$,color:"danger",n:y.elite||y.kind==="boss"?22:8,size:y.size*1.4}),!d)return;Ee+=1,l.vars.kills=Ee,l.emit("enemy-defeated",{kind:y.kind,elite:y.elite,by:A});let L=ht();if(y.xp>0&&Tt("xp",S,$+y.size*.4,y.xp),o.chance(Math.min(.95,s("coinRate")*ee.luck))&&Tt("coin",S+L*.3,$+y.size*.4),o.chance(.012*ee.luck)&&Tt("food",S-L*.3,$),o.chance(.004)&&!l.query(ar).some(I=>l.need(I,ar).kind==="magnet")&&Tt("magnet",S,$-L*.3),o.chance(.004)&&Tt("bomb",S,$-L*.3),y.elite||y.kind==="miniboss"){Tt("chest",S,$);for(let I=0;I<3;I++)Tt("coin",S+o.range(-L,L),$+o.range(-L,L));}if(y.kind==="bomber"){let I=Re()*.11*ee.area;K(l,{kind:"ring",x:S,y:$,color:"piece6",size:I*2});for(let P of l.query(We)){let W=l.need(P,F);Math.hypot(W.x-S,W.y-$)<I&&H(l,P,Et()*2.5,"blast");}}if((y.kind==="miniboss"||y.kind==="boss")&&(de+=1,l.vars.bosses=de,w===_e&&(_e=null),l.emit(Wl,{kind:y.kind}),K(l,{kind:"shake",power:2}),y.kind==="boss")){for(let I of l.query(We))T(l,I,null,false);p(l,"cleared");}},H=(l,w,A,d)=>{if(!l.has(w,We))return;let y=l.need(w,We);if(y.hp-=A,(y.elite||y.kind==="boss"||y.kind==="miniboss")&&$e>0){$e-=1;let R=l.need(w,F);K(l,{kind:"pop",x:R.x+o.range(-10,10),y:R.y-y.size,text:String(Math.round(A)),color:"text",size:Math.round(Re()*.03)});}y.hp<=0?T(l,w,d):y.kind!=="boss"&&y.kind!=="miniboss"&&Ge(l,w,"hit");},u=(l,w,A,d,y)=>{let R=l.get(w,We);if(!R||R.kind==="boss"||R.kind==="miniboss"||R.phase==="dash")return;let S=l.need(w,F),$=S.x-A,g=S.y-d,L=Math.hypot($,g)||1;S.x+=$/L*y,S.y+=g/L*y;},f=(l,w)=>{if(fe>0||a===null)return;let A=Math.max(1,w-ee.armor);ee.hp-=A,fe=s("graceTime"),l.vars.hp=Math.max(0,Math.ceil(ee.hp)),l.emit("player-hit",{hp:l.vars.hp}),Ge(l,a,"hit"),K(l,{kind:"flash",color:"danger"}),K(l,{kind:"shake",power:.8});let d=De();K(l,{kind:"pop",x:d.x,y:d.y-ht()*1.4,text:`-${Math.round(A)}`,color:"danger",size:Math.round(Re()*.034)}),ee.hp<=0&&b(l);},b=l=>{if(l.vars.revive_ready===true&&!Ae){l.vars.reviving=true,Ht(l),i=null,l.emit(er,{});return}p(l,"died");},c=l=>{if(l.vars.reviving!==true)return;Ae=true,l.vars.reviving=false,ee.hp=ee.maxHp,l.vars.hp=Math.ceil(ee.hp),fe=2.5;let w=De();for(let A of l.query(We)){let d=l.need(A,F);if(Math.hypot(d.x-w.x,d.y-w.y)<Re()*.4){let y=l.get(A,We);if(!y)continue;y.kind==="boss"||y.kind==="miniboss"?u(l,A,w.x,w.y,Re()*.2):T(l,A,"revive");}}for(let A of l.query(nn))l.destroy(A);K(l,{kind:"ring",x:w.x,y:w.y,color:"coin",size:Re()*.8}),K(l,{kind:"flash",color:"coin"}),a!==null&&at(l,a,"idle");},p=(l,w)=>{if(!ot(l)||Se)return;Se=true;let A=Math.floor(we);w==="cleared"&&l.vars["meta:first_clear"]===true&&Qe(l,"coins",ke.firstClearGold),l.vars.score=Ee*s("killScore")+A*5+de*s("bossScore")+(w==="cleared"?s("clearBonus")*ke.chapter:0),l.vars.choosing=false,l.vars.reviving=false,l.emit(Ut,{reason:w,stats:{kills:Ee,seconds:A,bosses:de,chapter:ke.chapter,level:q,cleared:w==="cleared"}});},k=Sr(r,"weapons",Pn),_=()=>{let l=[],w=Object.keys(m).length,A=Object.keys(v).length;for(let y of Pn){let R=m[y];R!==void 0&&R<5?l.push({o:{kind:"weapon",id:y,level:R+1},weight:3}):R===void 0&&w<6&&k.includes(y)&&l.push({o:{kind:"weapon",id:y,level:1},weight:1.6});}for(let y of Ra){let R=v[y];R!==void 0&&R<5?l.push({o:{kind:"passive",id:y,level:R+1},weight:2}):R===void 0&&A<6&&l.push({o:{kind:"passive",id:y,level:1},weight:1.2});}let d=[];for(;d.length<3&&l.length>0;){let y=0;for(let $ of l)y+=$.weight;let R=o.range(0,y),S=0;for(;S<l.length-1&&(R-=l[S].weight,!(R<=0));S++);d.push(l[S].o),l.splice(S,1);}return d.length<3&&d.push({kind:"heal",id:"heal",level:1}),d.length<3&&d.push({kind:"gold",id:"gold",level:1}),d},C=(l,w)=>{ye=_(),be=w,l.vars.choosing=true,l.vars.survivors_offer=Vl(ye),Ht(l),i=null,ct(l,xn);let A=De();K(l,{kind:"ring",x:A.x,y:A.y,color:w==="chest"?"coin":"accent",size:Re()*.5}),l.emit(Nl,{level:q,source:w,options:ye,build:{weapons:{...m},passives:{...v}}});},z=l=>{l.vars.choosing===true||!ot(l)||(ne>0?(ne-=1,C(l,"level")):Z>0&&(Z-=1,C(l,"chest")));},B=(l,w)=>{w.kind==="weapon"?(m[w.id]=w.level,x[w.id]=0):w.kind==="passive"?v[w.id]=w.level:w.kind==="heal"?ee.hp=Math.min(ee.maxHp,ee.hp+ee.maxHp*.3):w.kind==="gold"&&Qe(l,"coins",10),Qt(),l.vars.hp=Math.ceil(ee.hp),pe(l);},ae=(l,w)=>{if(l.vars.choosing!==true)return;let A=ye[w];A&&(B(l,A),ye=[],l.vars.choosing=false,l.vars.survivors_offer="",l.emit(zl,{kind:A.kind,id:A.id,level:A.level,source:be}),z(l));},pe=l=>{let w=De(),A=Re(),d=m.blades,y=d?Ir.blades.count[d-1]:0,R=l.query(bn);for(let P of R)l.need(P,bn).index>=y&&l.destroy(P);for(let P=0;P<y;P++)R.some(W=>l.isAlive(W)&&l.need(W,bn).index===P)||Pt(l,w.x,w.y,{shape:"sprite",art:"blade",w:A*.075,h:A*.075,color:"primary",depth:31},{type:bn,data:{index:P}});for(let P of l.query(bn)){let W=l.need(P,le);W.shape==="sprite"&&(W.w=W.h=A*(d===5?.095:.075)*Math.sqrt(ee.area));}let S=m.aura,$=l.query(In);if(S){let P=A*Ir.aura.reach[S-1]*ee.area;$.length===0&&Pt(l,w.x,w.y,{shape:"sprite",art:"aura_field",w:P*2,h:P*2,color:S===5?"coin":"secondary",alpha:.9,depth:1.5},{type:In,data:{r:P}});for(let W of l.query(In)){l.need(W,In).r=P;let te=l.need(W,le);te.shape==="sprite"&&(te.w=te.h=P*2,te.color=S===5?"coin":"secondary");}}else for(let P of $)l.destroy(P);let g=m.drone,L=g?Ir.drone.count[g-1]:0,I=l.query(Nn);for(let P of I)l.need(P,Nn).index>=L&&l.destroy(P);for(let P=0;P<L;P++)I.some(W=>l.isAlive(W)&&l.need(W,Nn).index===P)||Pt(l,w.x,w.y,{shape:"sprite",art:"drone",w:A*.06,h:A*.06,color:"piece6",depth:33},{type:Nn,data:{index:P,cd:.3*P}});},Me=(l,w,A,d,y)=>{let R=null,S=d;for(let $ of l.query(We)){if(y&&y.includes($))continue;let g=l.need($,F),L=Math.hypot(g.x-w,g.y-A);L<S&&(S=L,R=$);}return R},qe=(l,w,A,d,y,R,S,$,g=1)=>{let L=ht()*g,I=s("shotSpeed")*rt(),P=Pt(l,w,A,{shape:"sprite",art:"shot",w:L*.95,h:L*.48,color:$,depth:30},{type:zn,data:{vx:Math.cos(d)*I,vy:Math.sin(d)*I,life:1.4,damage:y,pierce:R,hit:[],by:S}});l.need(P,F).rotation=d;},tt=(l,w,A)=>{if(a===null)return;let d=De(),y=Re(),R=ht();for(let S of Pn){let $=m[S];if($===void 0)continue;let g=Ir[S],L=$-1,I=g.damage[L]*ee.might;if(x[S]=(x[S]??0)-w,S==="blaster"&&x[S]<=0){let P=Me(l,d.x,d.y,y*.75);if(P===null){x[S]=0;continue}x[S]=g.cooldown[L]*ee.haste;let W=l.need(P,F),te=Math.atan2(W.y-(d.y-R*.3),W.x-d.x),X=g.count[L];for(let ue=0;ue<X;ue++)qe(l,d.x,d.y-R*.3,te+(ue-(X-1)/2)*.16,I,g.pierce[L],"blaster",$===5?"piece6":"coin",$===5?1.25:1);Ge(l,a,"attack");let me=l.need(a,le);me.shape==="actor"&&(me.actRate=1/Math.max(.2,g.cooldown[L]*ee.haste),A||(me.facing=W.x>=d.x?1:-1));}else if(S==="blades"){let P=y*g.reach[L]*ee.area,W=3+.35*$;D+=W*w;let te=l.query(bn),X=te.length||1;for(let me of te){let ue=l.need(me,bn),xe=D+ue.index/X*Math.PI*2,ge=l.need(me,F);ge.x=d.x+Math.cos(xe)*P,ge.y=d.y-R*.2+Math.sin(xe)*P,ge.rotation=D*2.2;let Ve=y*.04*Math.sqrt(ee.area);for(let nt of l.query(We)){let bt=l.get(nt,We);if(!bt)continue;let jt=l.need(nt,F);Math.hypot(jt.x-ge.x,jt.y-ge.y)>Ve+bt.size*.55||l.time-(bt.hurtAt.blades??-9)<g.cooldown[L]||(bt.hurtAt.blades=l.time,H(l,nt,I,"blades"),u(l,nt,d.x,d.y,y*.012));}}}else if(S==="aura"){let P=l.query(In)[0];if(P===void 0)continue;let W=l.need(P,F);if(W.x=d.x,W.y=d.y+R*.3,l.need(P,F).rotation=l.time*.6,x[S]>0)continue;x[S]=g.cooldown[L];let te=l.need(P,In).r;for(let X of l.query(We)){let me=l.need(X,F),ue=l.get(X,We);!ue||Math.hypot(me.x-d.x,me.y-d.y)>te+ue.size*.3||(H(l,X,I,"aura"),u(l,X,d.x,d.y,y*.008));}}else if(S==="boomerang"&&x[S]<=0){let P=Me(l,d.x,d.y,y*.8);if(P===null){x[S]=0;continue}x[S]=g.cooldown[L]*ee.haste;let W=l.need(P,F),te=Math.atan2(W.y-d.y,W.x-d.x),X=g.count[L];for(let me=0;me<X;me++){let ue=te+me*Math.PI*2/X,xe=y*($===5?.085:.065);Pt(l,d.x,d.y,{shape:"sprite",art:"boomerang",w:xe,h:xe,color:"accent",depth:32},{type:ds,data:{dx:Math.cos(ue),dy:Math.sin(ue),dist:0,range:y*g.reach[L]*ee.area,back:false,damage:I,hit:[]}});}}else if(S==="lightning"&&x[S]<=0){let P=Me(l,d.x,d.y,y*.55);if(P===null){x[S]=0;continue}x[S]=g.cooldown[L]*ee.haste;let W=[],te={x:d.x,y:d.y-R},X=P;for(let me=0;me<g.count[L]&&X!==null;me++){let ue=l.get(X,We);if(!ue)break;let xe=l.need(X,F),ge={x:xe.x,y:xe.y-ue.size*.4};pt(l,te,ge,$===5?"coin":"primary"),W.push(X);let Ve=Me(l,xe.x,xe.y,y*g.reach[L]*ee.area,W);H(l,X,I,"lightning"),te=ge,X=Ve;}}else if(S==="drone"){O+=1.8*w;let P=l.query(Nn),W=P.length||1,te=y*g.reach[L];for(let X of P){let me=l.need(X,Nn),ue=O+me.index/W*Math.PI*2,xe=l.need(X,F);if(xe.x=d.x+Math.cos(ue)*te,xe.y=d.y-R*1.1+Math.sin(ue)*te*.5,me.cd-=w,me.cd>0)continue;let ge=Me(l,xe.x,xe.y,y*.6);if(ge===null){me.cd=0;continue}me.cd=g.cooldown[L]*ee.haste;let Ve=l.need(ge,F);qe(l,xe.x,xe.y,Math.atan2(Ve.y-xe.y,Ve.x-xe.x),I,$===5?2:1,"drone","piece6",.7);}}}},pt=(l,w,A,d)=>{let y=Math.hypot(A.x-w.x,A.y-w.y),R=Pt(l,(w.x+A.x)/2,(w.y+A.y)/2,{shape:"sprite",art:"zap",w:Math.max(8,y),h:Re()*.035,color:d,depth:34},{type:fs,data:{life:.16}});l.need(R,F).rotation=Math.atan2(A.y-w.y,A.x-w.x);},re=(l,w)=>{let A=De(),d=ht(),y=Re(),R=Be(l),S=Math.hypot(R.w,R.h)*.75,$=l.query(We);for(let L of $){let I=l.get(L,We);if(!I)continue;let P=l.need(L,F),W=A.x-P.x,te=A.y-P.y,X=Math.hypot(W,te)||1;W/=X,te/=X;let me=I.kind==="boss"||I.kind==="miniboss";if(X>(me?S*1.3:S)){let nt=ze();P.x=nt.x,P.y=nt.y;continue}I.t-=w;let ue=I.speed,xe=W,ge=te;if(I.kind==="archer"){let nt=y*.3;if(X<nt?ue*=-0.6:X<nt*1.4&&(ue=0),I.t<=0&&X<y*.6){I.t=2.4,Ge(l,L,"attack");let bt=260*rt();Pt(l,P.x,P.y-I.size*.6,{shape:"sprite",art:"orb",w:y*.03,h:y*.03,color:"danger",depth:29},{type:nn,data:{vx:W*bt,vy:te*bt,life:3,damage:I.damage}});}}else (I.kind==="charger"||I.kind==="miniboss"||I.kind==="boss")&&(I.phase==="walk"&&I.t<=0&&X<y*(me?.6:.38)?I.kind!=="boss"||I.next%3===0?(I.phase="wind",I.t=me?.7:.55,Ge(l,L,"surprised"),K(l,{kind:"ring",x:P.x,y:P.y,color:"danger",size:I.size*2.2})):j(l,L,I):I.phase==="wind"?(ue=0,I.t<=0&&(I.phase="dash",I.t=me?.6:.45,I.vx=W,I.vy=te)):I.phase==="dash"&&(ue=I.speed*(me?4:3.6),xe=I.vx,ge=I.vy,I.t<=0&&(I.phase="walk",I.t=me?I.hp<I.maxHp/2?1.6:2.4:2.8,I.kind==="boss"&&(I.next+=1))));P.x+=xe*ue*w,P.y+=ge*ue*w;let Ve=l.need(L,le);if(Ve.shape==="actor"&&(Math.abs(A.x-P.x)>I.size*.4&&(Ve.facing=A.x>=P.x?1:-1),Ve.depth=Jt(l,P.y),Ve.speed=Math.abs(ue),Ve.pose=ue===0?"idle":I.kind==="brute"||me?"walk":"run"),X<(I.size+d)/2){if(I.kind==="bomber"){K(l,{kind:"ring",x:P.x,y:P.y,color:"piece6",size:y*.22}),f(l,I.damage),T(l,L,null,false);continue}if(fe<=0&&(Ge(l,L,"attack"),f(l,I.damage),Se||Ta(l)))return}}let g=l.query(We);for(let L=0;L<g.length;L++){let I=l.need(g[L],We),P=l.need(g[L],F);for(let W=L+1;W<g.length;W++){let te=l.need(g[W],We),X=l.need(g[W],F),me=(I.size+te.size)*.42,ue=X.x-P.x,xe=X.y-P.y,ge=ue*ue+xe*xe;if(ge>=me*me||ge===0)continue;let Ve=Math.sqrt(ge),nt=(me-Ve)*.5,bt=ue/Ve*nt,jt=xe/Ve*nt,jr=I.kind==="boss"||I.kind==="miniboss",Dr=te.kind==="boss"||te.kind==="miniboss";jr||(P.x-=bt,P.y-=jt),Dr||(X.x+=bt,X.y+=jt);}}for(let L of l.query(vo)){let I=l.need(L,vo).of;if(!l.isAlive(I)||!l.has(I,We)){l.destroy(L);continue}let P=l.need(I,F),W=l.need(L,F);W.x=P.x,W.y=P.y+l.need(I,We).size*.55;let te=l.need(L,le);te.shape==="sprite"&&(te.alpha=.6+.3*Math.sin(l.time*6));}},j=(l,w,A)=>{let d=l.need(w,F),y=Re(),R=A.next%3;if(A.next+=1,A.t=A.hp<A.maxHp/2?1.4:2.2,R===1){let S=A.hp<A.maxHp/2?18:12,$=220*rt();for(let g=0;g<S;g++){let L=g/S*Math.PI*2+l.time;Pt(l,d.x,d.y-A.size*.4,{shape:"sprite",art:"orb",w:y*.035,h:y*.035,color:"danger",depth:29},{type:nn,data:{vx:Math.cos(L)*$,vy:Math.sin(L)*$,life:3.5,damage:A.damage*.6}});}Ge(l,w,"attack"),K(l,{kind:"ring",x:d.x,y:d.y,color:"danger",size:A.size*3});}else {for(let S=0;S<6;S++){let $=S/6*Math.PI*2;Ze("swarm",{x:d.x+Math.cos($)*A.size*1.6,y:d.y+Math.sin($)*A.size*1.6});}Ge(l,w,"cheer");}},J=(l,w)=>{let A=Be(l),d=De(),y=ht(),R=Re()*.2;for(let $ of l.query(zn)){let g=l.need($,zn),L=l.need($,F);if(L.x+=g.vx*w,L.y+=g.vy*w,g.life-=w,g.life<=0||L.x<-R||L.y<-R||L.x>A.w+R||L.y>A.h+R){l.destroy($);continue}for(let I of l.query(We)){if(g.hit.includes(I))continue;let P=l.get(I,We);if(!P)continue;let W=l.need(I,F);if(!(Math.abs(W.x-L.x)>P.size/2+4||Math.abs(W.y-(L.y+P.size*.2))>P.size*.9+4)&&(g.hit.push(I),K(l,{kind:"burst",x:L.x,y:L.y,color:"coin",n:4,size:y*.5}),u(l,I,d.x,d.y,Re()*.01),H(l,I,g.damage,g.by),g.hit.length>=g.pierce)){l.destroy($);break}}}for(let $ of l.query(nn)){let g=l.need($,nn),L=l.need($,F);if(L.x+=g.vx*w,L.y+=g.vy*w,g.life-=w,g.life<=0){l.destroy($);continue}if(Math.hypot(L.x-d.x,L.y-(d.y-y*.3))<y*.55&&(l.destroy($),f(l,g.damage),Se||Ta(l)))return}let S=Re()*1.5;for(let $ of l.query(ds)){let g=l.need($,ds),L=l.need($,F);if(L.rotation=(L.rotation??0)+w*14,g.back){let P=d.x-L.x,W=d.y-L.y,te=Math.hypot(P,W)||1;if(te<y*.5){l.destroy($);continue}L.x+=P/te*S*w,L.y+=W/te*S*w;}else {let P=S*w*Math.max(.35,1-g.dist/g.range);L.x+=g.dx*P,L.y+=g.dy*P,g.dist+=P,g.dist>=g.range*.98&&(g.back=true,g.hit=[]);}let I=l.need($,le).w*.5;for(let P of l.query(We)){if(g.hit.includes(P))continue;let W=l.get(P,We);if(!W)continue;let te=l.need(P,F);Math.hypot(te.x-L.x,te.y-L.y)>I+W.size*.5||(g.hit.push(P),u(l,P,L.x,L.y,Re()*.015),H(l,P,g.damage,"boomerang"));}}for(let $ of l.query(fs)){let g=l.need($,fs);g.life-=w;let L=l.need($,le);L.shape==="sprite"&&(L.alpha=Math.max(0,g.life/.16)),g.life<=0&&l.destroy($);}},Y=(l,w)=>{let A=De(),d=ht(),R=l.query(ar).filter(S=>l.need(S,ar).kind==="xp");if(R.length>90){let S=R.map(P=>({e:P,d:Math.hypot(l.need(P,F).x-A.x,l.need(P,F).y-A.y)})).sort((P,W)=>W.d-P.d).slice(0,30),$=0,g=l.need(S[0].e,F),L=g.x,I=g.y;for(let P of S)$+=l.need(P.e,ar).value,l.destroy(P.e);Tt("xp",L,I,Math.max(25,$));}for(let S of l.query(ar)){let $=l.need(S,ar),g=l.need(S,F),L=Math.hypot(A.x-g.x,A.y-g.y);if(L<ee.magnet||$.pulled){$.pulled=true;let I=Re()*($.kind==="xp"&&L>ee.magnet?2.4:1.4),P=Math.min(1,w*I/Math.max(1,L));g.x+=(A.x-g.x)*P,g.y+=(A.y-g.y)*P;}if(!(L>d*.6))if(l.destroy(S),$.kind==="coin")Qe(l,"coins",$.value),l.emit("coin-collected",{value:$.value}),K(l,{kind:"pop",x:A.x,y:A.y-d*1.6,text:`+${$.value}`,size:Math.round(d*.45)});else if($.kind==="xp"){for(N+=$.value*ee.growth;N>=Xe(q);)N-=Xe(q),q+=1,ne+=1;l.vars.xp_level=q;}else if($.kind==="food")ee.hp=Math.min(ee.maxHp,ee.hp+ee.maxHp*.25),l.vars.hp=Math.ceil(ee.hp),K(l,{kind:"ring",x:A.x,y:A.y,color:"accent",size:d*3});else if($.kind==="magnet"){for(let I of l.query(ar))(l.need(I,ar).kind==="xp"||l.need(I,ar).kind==="coin")&&(l.need(I,ar).pulled=true);K(l,{kind:"ring",x:A.x,y:A.y,color:"coin",size:Re()*1.2});}else if($.kind==="bomb"){let I=Be(l);K(l,{kind:"flash",color:"#ffffff"}),K(l,{kind:"shake",power:2});for(let P of l.query(We)){let W=l.need(P,F);if(W.x<0||W.y<0||W.x>I.w||W.y>I.h)continue;let te=l.get(P,We);te&&H(l,P,te.kind==="boss"||te.kind==="miniboss"?te.maxHp*.1:te.hp+1,"bomb");}}else $.kind==="chest"&&(Z+=1,K(l,{kind:"burst",x:A.x,y:A.y,color:"coin",n:20,size:d*2}));}z(l);},M=()=>{for(let w of [We,zn,nn,ar,bn,In,Nn,ds,fs,vo,xn])ct(e,w);ct(e,Qn),yt(),Bt(e,"top",void 0,{pan:true}),e.vars.field_x=0,e.vars.field_y=0,i=null,h=0,ke=xo(rn(e,"meta:chapter")||1,s("duration")),ce=ke.duration;let l=et();m={[l.weapon]:1},v=l.passive?{[l.passive]:1}:{};for(let w of Pn)x[w]=.4;N=0,q=1,ne=0,Z=0,ye=[],fe=0,Ee=0,de=0,Ae=false,Se=false,Pe=0,we=0,Le=false,_e=null,oe=s("minibossEvery")>0?s("minibossEvery"):1/0,Te=s("eliteEvery")>0?s("eliteEvery")*.8:1/0,Ke=22,Ne=0,se=null,Ie=0,ee.maxHp=0,ee.hp=0,Qt(),ee.hp=ee.maxHp,e.vars.hp=Math.ceil(ee.hp),e.vars.hp_max=ee.maxHp,e.vars.time_left=ce,e.vars.xp_level=1,e.vars.kills=0,e.vars.bosses=0,e.vars.chapter=ke.chapter,e.vars.choosing=false,e.vars.reviving=false,e.vars.boss_hp=0,e.vars.survivors_offer="",it(),pe(e);};e.on(zt,l=>{let w=l,A=e.vars.choosing===true||e.vars.reviving===true;w.type==="press"&&ot(e)&&!A?i={x:w.x,y:w.y}:w.type==="release"&&(i=null),w.type==="key"&&e.vars.choosing===true&&(w.key==="left"||w.key==="action"||w.key==="right")&&ae(e,w.key==="left"?0:w.key==="action"?1:2);}),e.on(Bl,l=>ae(e,Number(l.index??-1))),e.on(Hl,()=>{e.vars.choosing===true&&(e.vars.choosing=false,C(e,be));}),e.on(tr,()=>c(e)),e.on(rr,()=>{e.vars.reviving===true&&(e.vars.reviving=false,p(e,"died"));}),e.on(qt,M),e.on(Zt,M),e.on(Xt,l=>{for(let w of e.query(We))at(e,w,"idle");a!==null&&e.isAlive(a)&&at(e,a,l.reason==="cleared"?"dance":"die"),yt(),ct(e,xn);}),e.on(Ft,()=>{Bt(e,"top",void 0,{pan:true}),it(),ot(e)&&pe(e);});let E=(l,w)=>{let A=i!==null&&n.pointer.down&&l.vars.choosing!==true,d=l.query(xn);if(!A||i===null){for(let g of d)l.destroy(g);return}d.length===0&&(Pt(l,i.x,i.y,{shape:"circle",r:w,color:"#ffffff",alpha:.16,depth:70},{type:xn,data:{part:0}}),Pt(l,i.x,i.y,{shape:"circle",r:w*.42,color:"#ffffff",alpha:.55,depth:71},{type:xn,data:{part:1}}));let y=n.pointer.x-i.x,R=n.pointer.y-i.y,S=Math.hypot(y,R)||1,$=Math.min(1,w/S);for(let g of l.query(xn)){let L=l.need(g,F);l.need(g,xn).part===0?(L.x=i.x,L.y=i.y):(L.x=i.x+y*$,L.y=i.y+R*$);}};e.addSystem({id:"survivors",order:0,run(l,w){if(!ot(l)||a===null||Se)return;let A=l.vars.choosing===true||l.vars.reviving===true;for(let te of [a,...l.query(We)]){let X=l.get(te,le);X?.shape==="actor"&&(X.paused=A);}if(A)return;$e=Math.min(12,$e+w*10);let d=Be(l);if(we+=w,!Le){let te=Math.max(0,ce-we);l.vars.time_left=te,te<=0&&ur(l);}fe>0&&(fe=Math.max(0,fe-w)),ee.regen>0&&ee.hp<ee.maxHp&&(ee.hp=Math.min(ee.maxHp,ee.hp+ee.regen*w),l.vars.hp=Math.ceil(ee.hp)),l.vars.hp_max=ee.maxHp;let y=De(),R=Re()*.11,S=n.axis(),$=S.x,g=S.y,L=$!==0||g!==0?1:0;if(L===0&&i&&n.pointer.down){$=n.pointer.x-i.x,g=n.pointer.y-i.y;let te=Math.hypot($,g);L=te<R*.18?0:Math.min(1,te/R);}E(l,R);let I=Math.hypot($,g),P=I>0&&L>0;if(P){let te=$/I*ee.speed*L*w,X=g/I*ee.speed*L*w;for(let me of [...l.query(We),...l.query(zn),...l.query(nn),...l.query(ar),...l.query(Qn),...l.query(ds),...l.query(fs)]){let ue=l.need(me,F);ue.x-=te,ue.y-=X;}pd(l,te,X),Qe(l,"field_x",te),Qe(l,"field_y",X),h+=w,h>.6&&Lt(l,"survivors-move");}!vt(l,"survivors-move")&&!_r(l)&&kt(l,"circle",{x:d.w/2,y:d.h*.8},{x:R*.6,y:0});let W=l.need(a,le);W.alpha=fe>0&&Math.floor(l.time*12)%2===0?.4:1,W.shape==="actor"&&(W.pose=P?"run":"idle",W.speed=ee.speed*Math.max(.3,L),P&&Math.abs($)>I*.15&&(W.facing=$>0?1:-1),W.depth=Jt(l,y.y)+5e-4),Nt(l,w),re(l,w),!(Se||Ta(l))&&(tt(l,w,P),J(l,w),!(Se||Ta(l))&&(Y(l,w),!Se&&(l.vars.score=Ee*s("killScore")+Math.floor(we)*5+de*s("bossScore"),ft(l))));}}),e.vars.survivors_base=s("duration"),M();}};var Pa=[{id:"archer",base:{damage:6,type:"physical",range:2.6,rate:1.2,air:true,ground:true,shot:"td_arrow",shotSpeed:13},tiers:[{cost:70,stats:{},art:"td_archer1"},{cost:100,stats:{damage:9,range:2.8,rate:1.35},art:"td_archer2"},{cost:150,stats:{damage:14,range:3,rate:1.5},art:"td_archer3"}],branches:[{id:"ranger",cost:240,stats:{damage:17,rate:2.5,multishot:2,range:3.1},art:"td_archer_ranger"},{id:"sniper",cost:260,stats:{damage:72,rate:.5,range:4.6,pierce:1,crit:.2,shotSpeed:22},art:"td_archer_sniper"}],unlockLevel:1,metaVar:"meta:tower:archer"},{id:"cannon",base:{damage:12,type:"physical",range:2.3,rate:.5,air:false,ground:true,shot:"bomb",shotSpeed:6,lob:true,splash:.9},tiers:[{cost:110,stats:{},art:"td_cannon1"},{cost:150,stats:{damage:22,splash:1},art:"td_cannon2"},{cost:210,stats:{damage:36,splash:1.1,range:2.5},art:"td_cannon3"}],branches:[{id:"bombard",cost:300,stats:{damage:72,splash:1.5,rate:.42,range:2.8,stun:.25,stunTime:.6},art:"td_cannon_bombard"},{id:"flamer",cost:280,stats:{damage:20,splash:1,rate:.9,burn:12,burnTime:3},art:"td_cannon_flamer"}],unlockLevel:1,metaVar:"meta:tower:cannon"},{id:"mage",base:{damage:14,type:"magic",range:2.4,rate:.7,air:true,ground:true,shot:"orb",shotSpeed:9},tiers:[{cost:100,stats:{},art:"td_mage1"},{cost:140,stats:{damage:26},art:"td_mage2"},{cost:200,stats:{damage:42,range:2.6},art:"td_mage3"}],branches:[{id:"arcane",cost:300,stats:{damage:110,type:"true",rate:.55,range:2.9},art:"td_mage_arcane"},{id:"storm",cost:280,stats:{damage:32,rate:.9,chain:4,beam:true,shot:"zap"},art:"td_mage_storm"}],unlockLevel:3,metaVar:"meta:tower:mage"},{id:"frost",base:{damage:3,type:"magic",range:2.2,rate:.8,air:true,ground:true,shot:"crystal",shotSpeed:10,splash:.5,slow:.35,slowTime:1.6},tiers:[{cost:90,stats:{},art:"td_frost1"},{cost:120,stats:{damage:5,slow:.45,slowTime:1.9},art:"td_frost2"},{cost:170,stats:{damage:8,slow:.5,slowTime:2.2,splash:.7,range:2.4},art:"td_frost3"}],branches:[{id:"glacier",cost:260,stats:{damage:14,slow:.6,slowTime:2.6,stun:.15,stunTime:1},art:"td_frost_glacier"},{id:"blizzard",cost:260,stats:{damage:10,splash:1.4,slow:.5,slowTime:2.4,range:2.7},art:"td_frost_blizzard"}],unlockLevel:5,metaVar:"meta:tower:frost"}],Gl=6,ps=.7,zr=e=>Pa.find(t=>t.id===e);function hs(e,t,r){let o=e.base;for(let s=1;s<Math.min(t,e.tiers.length);s++)o={...o,...e.tiers[s].stats};let n=r?e.branches.find(s=>s.id===r):void 0;return n?{...o,...n.stats}:o}function us(e,t,r){let o=0;for(let s=0;s<Math.min(t,e.tiers.length);s++)o+=e.tiers[s].cost;let n=r?e.branches.find(s=>s.id===r):void 0;return o+(n?.cost??0)}var Ia=(e,t,r)=>(r?e.branches.find(o=>o.id===r)?.art:void 0)??e.tiers[Math.min(t,e.tiers.length)-1].art,Bn=[{id:"grunt",cast:"foe",hp:1,speed:1,armor:0,resist:0,bounty:6,leak:1,size:.82,hit:.25,firstLevel:1,cost:1},{id:"runner",cast:"foe5",hp:.55,speed:1.8,armor:0,resist:0,bounty:4,leak:1,size:.72,hit:.15,firstLevel:2,cost:.7},{id:"brute",cast:"foe2",hp:2.6,speed:.7,armor:.6,resist:0,bounty:14,leak:2,size:1,hit:.5,firstLevel:3,cost:2.4,badge:"shield"},{id:"flyer",cast:"foe3",hp:.8,speed:1.2,armor:0,resist:0,flying:true,bounty:8,leak:1,size:.75,hit:0,firstLevel:4,cost:1.3,badge:"wing"},{id:"shaman",cast:"foe4",hp:1.6,speed:.9,armor:0,resist:.7,bounty:12,leak:1,size:.86,hit:.3,firstLevel:6,cost:2,badge:"orb"},{id:"healer",cast:"foe4",variant:7,hp:1.3,speed:.9,armor:.2,resist:.2,bounty:14,leak:1,size:.86,hit:.2,heals:{radius:1.6,share:.08,every:2},firstLevel:8,cost:2.2,badge:"potion"},{id:"splitter",cast:"foe2",variant:5,hp:2,speed:.85,armor:.2,resist:0,bounty:10,leak:2,size:.95,hit:.4,splits:{into:"spawnling",count:3},firstLevel:11,cost:2.6,badge:"skull"},{id:"spawnling",cast:"foe5",variant:3,hp:.35,speed:1.6,armor:0,resist:0,bounty:2,leak:1,size:.55,hit:.1,firstLevel:0,cost:.4},{id:"warlord",cast:"boss",hp:30,speed:.55,armor:.2,resist:0,bounty:120,leak:10,size:1.5,hit:2,summons:{id:"grunt",count:3,every:6},boss:1,firstLevel:0,cost:0},{id:"ironclad",cast:"boss",variant:4,hp:50,speed:.5,armor:.65,resist:0,bounty:160,leak:10,size:1.6,hit:2.5,enrage:{below:.5,speed:1.7},boss:2,firstLevel:0,cost:0,badge:"shield"},{id:"broodmother",cast:"boss",variant:9,hp:62,speed:.5,armor:.2,resist:.3,bounty:200,leak:10,size:1.6,hit:2.5,summons:{id:"spawnling",count:4,every:5},splits:{into:"spawnling",count:8},boss:3,firstLevel:0,cost:0,badge:"skull"},{id:"lich",cast:"boss",variant:13,hp:80,speed:.48,armor:.3,resist:.5,bounty:260,leak:15,size:1.7,hit:3,heals:{radius:2.2,share:.05,every:3},summons:{id:"shaman",count:2,every:7},boss:4,firstLevel:0,cost:0,badge:"orb"}],pr=e=>Bn.find(t=>t.id===e),$o=[{id:"meteor",icon:"td_meteor",kind:"strike",cooldown:35,unlockLevel:2,damage:2.2,count:3,radius:1.1,burn:.3},{id:"reinforce",icon:"shield",kind:"summon",cooldown:22,unlockLevel:4,count:2,cast:"helper",hp:4,dps:.6,time:14}],Br=9,Hr=13,Kl=[{id:"meadow-a",rows:["..S......",".o#o..t..","..#......","..#####o.",".o....#..","..t...#o.",".o#####..","..#..o..t","..#.*....","o.####o..","....o#...",".t...#.o.",".....X..."]},{id:"meadow-b",rows:["......S..",".t..o.#o.","......#..",".o#####..","..#..o...","..#.t..o.","..####...",".o..o#.t.","..*..#...","..####o..",".o#......","..#.o..t.","..X......"]},{id:"meadow-c",rows:[".S.......",".#.o..o..",".#.....#X",".#o.t.o#.",".#.....#.",".#o.o..#.",".#..r..#.",".#.o.o.#o",".#.....#.",".#o.*.o#.",".#######.","..o.o.o..","t.......t"]},{id:"meadow-boss",rows:["....S....","..o.#.o..","....#....",".####.o..",".#..o....",".#.o..t..",".#######.","..o.o..#.",".o.....#o","..######.","..#.o.o..",".o#......","..X......"]},{id:"river-a",rows:[".........","S####.o..",".o..#....","..o.#.~~.","....####.",".o.r...#.","...o...#o",".#######.",".#.o.o...",".#....r..",".####.o..","..o.#....","....X...."]},{id:"river-b",rows:[".S.....S.",".#.o.o.#.",".#..t..#.",".###.###.",".o.#o#.o.","...#.#...","..o###o..","....#....",".o..#.o..","...o#....","..r.#.o..",".o..#..t.","....X...."]},{id:"river-c",rows:["..~~.....","o...####S","..o.#..o.","....#.~~.",".####.~~.",".#..o....",".#.o..r..",".######o.","..o...#..",".~~.o.#..","X######o.","..o.o....","..~~...t."]},{id:"river-boss",rows:[".o.....o.","S##.o.##S","..#.r.#..",".o#####o.","....#....",".o..#.o..",".####..t.",".#..o..o.",".#.o.....",".#######.","..o.o..#.",".o.....#o",".......X."]},{id:"wood-a",rows:["..o...o..","S#######.",".o.....#.","...o.o.#o",".#####.#.",".#.o.#.#.",".#.X.#.#.",".#.###.#.",".#..o..#.",".#######.","..o.o.o..",".t..r..o.","........."]},{id:"wood-b",rows:["...S.....",".o.#..o..","...#.t...",".o.####o.","......#..",".o.o..#o.","......##X",".o.o..#o.","......#..",".o.####o.","...#.r...",".o.#..o..","...S....."]},{id:"wood-c",rows:[".o..o..o.",".#######S",".#.o..o..",".#######.","..o.o..#.",".#######.",".#..o..o.",".#######.","..o..o.#.",".#######.",".#.o..o..",".#..r..t.",".X......."]},{id:"wood-boss",rows:["....X....",".o..#..o.","..o.#....",".####.o..",".#..o..t.",".#.o..o..",".#######.","..o..o.#.",".o.....#.","..######.","..#.o..o.",".o#..r...","..S......"]},{id:"ash-a",rows:["....S....",".o..#..o.","S##.#.##S","..#.#.#..",".o#o#o#o.","..#####..",".o..#..o.","...o#o...",".t..#..t.",".o..#..o.","..r.#.r..",".o..#..o.","....X...."]},{id:"ash-b",rows:[".S.....S.",".#.o.o.#.",".#..o..#.",".###.###.","...#o#...",".o.#.#.o.","...#o#...",".###.###.",".#.o.o.#.",".#.....#.",".#######.","..o.#.o..","....X...."]},{id:"ash-c",rows:[".S.....X.",".#.###.#.",".#o#o#o#.",".#.#.#.#.",".#o#.#o#.",".#.#o#.#.","o#.#.#.#o",".#o#.#o#.",".#.#o#.#.",".#.#.#.#.",".#o#.#o#.",".###.###.","........."]},{id:"ash-boss",rows:[".o.....o.","S#.o.o.#S",".#.....#.",".#o.r.o#.",".#.....#.",".#o.X.o#.",".#..#..#.",".#o.#.o#.",".#..#..#.",".#.o#o.#.",".#######.","..o.o.o..",".t.....t."]}],Na=e=>Kl.find(t=>t.id===e);function Mo(e,t){return t==="x"?e.rows.map(r=>[...r].reverse().join("")):t==="y"?[...e.rows].reverse():e.rows}var du=e=>e==="#"||e==="S"||e==="X";function wo(e){let t=(v,x)=>e[x]?.[v],r=null,o=[],n=[];for(let v=0;v<e.length;v++)for(let x=0;x<e[v].length;x++){let D=t(x,v);D==="X"?r={col:x,row:v}:D==="S"?o.push({col:x,row:v}):D==="o"&&n.push({col:x,row:v});}if(!r)throw new Error("tower-defense map: no gate (X)");if(o.length===0)throw new Error("tower-defense map: no entry (S)");let s=new Map,a=(v,x)=>`${v},${x}`,i=[r];s.set(a(r.col,r.row),0);let h=[[0,1],[-1,0],[1,0],[0,-1]];for(;i.length>0;){let v=i.shift(),x=s.get(a(v.col,v.row));for(let[D,O]of h){let N=v.col+D,q=v.row+O;!du(t(N,q))||s.has(a(N,q))||(s.set(a(N,q),x+1),i.push({col:N,row:q}));}}let m=o.map(v=>{if(!s.has(a(v.col,v.row)))throw new Error(`tower-defense map: the entry ${v.col},${v.row} has no road to the gate`);let x=[v],D=v;for(;D.col!==r.col||D.row!==r.row;){let O=s.get(a(D.col,D.row)),N=h.map(([q,ne])=>({col:D.col+q,row:D.row+ne})).find(q=>s.get(a(q.col,q.row))===O-1);x.push(N),D=N;}return x});return {rows:e,paths:m,gate:r,spots:n}}var Fl=4,Nr=5,ms=Fl*Nr,ql=[0,9,24,39],Ul=[{map:"meadow-a",mirror:"none"},{map:"meadow-b",mirror:"none"},{map:"meadow-c",mirror:"none"},{map:"meadow-a",mirror:"x"},{map:"meadow-boss",mirror:"none"},{map:"river-a",mirror:"none"},{map:"river-b",mirror:"none"},{map:"river-c",mirror:"none"},{map:"river-a",mirror:"x"},{map:"river-boss",mirror:"none"},{map:"wood-a",mirror:"none"},{map:"wood-b",mirror:"none"},{map:"wood-c",mirror:"none"},{map:"wood-b",mirror:"x"},{map:"wood-boss",mirror:"none"},{map:"ash-a",mirror:"none"},{map:"ash-b",mirror:"none"},{map:"ash-c",mirror:"none"},{map:"ash-a",mirror:"y"},{map:"ash-boss",mirror:"none"}];function fu(e){let t=e>>>0;return ()=>{t=t+1831565813>>>0;let r=t;return r=Math.imul(r^r>>>15,r|1),r^=r+Math.imul(r^r>>>7,r|61),((r^r>>>14)>>>0)/4294967296}}var pf=Bn.filter(e=>e.firstLevel>0).map(e=>e.id);function hf(e,t){let r=Bn.filter(n=>n.firstLevel>0&&n.firstLevel<=e);if(!t)return r;let o=r.filter(n=>t.includes(n.id));return o.length>0?o:r}function uf(e,t){let r=Bn.find(o=>o.firstLevel===e);return r&&(!t||t.includes(r.id))?r:void 0}function Xl(e,t,r){let o=Math.max(1,Math.min(ms,Math.floor(e))),n=fu(o*7919+13),s=hf(o,r),a=uf(o,r),i=Math.ceil(o/Nr),h=o%Nr===0?Bn.find(x=>x.boss===i):void 0,m=6+Math.floor((o-1)/2),v=[];for(let x=1;x<=m;x++){let D=5+x*1.6+o*.35,O=[],N=0,q=0,ne=[];if(x===1)ne.push(s[0]);else {a&&x===2&&ne.push(a);let ye=Math.min(4,1+Math.floor(x/3));for(;ne.length<ye;)ne.push(s[Math.floor(n()*s.length)]);}let Z=D/ne.length;for(let ye of ne){let be=Math.max(1,Math.round(Z/ye.cost)),fe=ye.speed>=1.5?.55:ye.hp>=2?1.3:.85;O.push({enemy:ye.id,count:be,gap:fe,delay:N,entry:q%Math.max(1,t)}),N+=be*fe*.55+1,q++;}h&&x===m&&O.push({enemy:h.id,count:1,gap:1,delay:N+2,entry:0}),v.push({groups:O});}return v}function Eo(e,t=.5,r){let o=Math.max(1,Math.min(ms,Math.floor(e))),n=Math.ceil(o/Nr),s=o-(n-1)*Nr,a=Ul[o-1],i=wo(Mo(Na(a.map),a.mirror)).paths.length;return {level:o,world:n,index:s,boss:s===Nr,map:a.map,mirror:a.mirror,hp:16*Math.pow(1.075,o-1)*(.8+t*.4),waves:Xl(o,i,r),gold:220+(o-1)*25,bounty:1+(o-1)*.03,towers:Pa.filter(h=>h.unlockLevel<=o).map(h=>h.id),spells:$o.filter(h=>h.unlockLevel<=o).map(h=>h.id),branches:o>=Gl,fresh:uf(o,r)?.id??null,enemies:hf(o,r).map(h=>h.id),firstClearGold:(s===Nr?150:60)+(o-1)*20}}var Zl=e=>ql[Math.ceil(Math.max(1,e)/Nr)-1]??0,za=(e,t)=>e>=t*.9?3:e>=t*.5?2:1,Ba=5,mf=20,So=[{id:"hero",cast:"hero",gems:0,perk:"none"},{id:"hero2",cast:"hero2",gems:150,perk:"gold"},{id:"hero3",cast:"hero3",gems:300,perk:"spells"}],Ql="kit-td",Yl=[{id:"StartGold",var:"meta:start_gold",art:"td_gold",color:"coin",perLevel:20,unit:"",maxLevel:10,price:40,growth:.12},{id:"Lives",var:"meta:lives",art:"heart",color:"danger",perLevel:1,unit:"",maxLevel:5,price:120,growth:.2},{id:"Archer",var:"meta:tower:archer",art:"td_archer1",color:"primary",perLevel:6,unit:"%",maxLevel:10,price:40,growth:.12},{id:"Cannon",var:"meta:tower:cannon",art:"td_cannon1",color:"primary",perLevel:6,unit:"%",maxLevel:10,price:40,growth:.12},{id:"Mage",var:"meta:tower:mage",art:"td_mage1",color:"primary",perLevel:6,unit:"%",maxLevel:10,price:45,growth:.12},{id:"Frost",var:"meta:tower:frost",art:"td_frost1",color:"primary",perLevel:6,unit:"%",maxLevel:10,price:45,growth:.12},{id:"Spells",var:"meta:spells",art:"td_meteor",color:"danger",perLevel:8,unit:"%",maxLevel:10,price:50,growth:.12}],yf={game:"tower-defense",character:Ql,stats:Yl,heroes:So,levels:ms,firstClearGold:e=>Eo(e).firstClearGold,stars:3,starsToEnter:Zl};var pu="boss-spawned",hu="boss-defeated",ec="wave-started",ja=ve("td.spot"),kr=ve("td.tower"),Oe=ve("td.raider"),Hn=ve("td.missile"),Ar=ve("td.soldier"),Ha=ve("td.meteor"),gf=ve("td.ground"),Jl=ve("td.part"),bf=ve("td.bar"),Wa=ve("td.zap"),ys=(e,t)=>{let r=Number(e.vars[t]??0);return Number.isFinite(r)?r:0},uu=.5,mu=.55,Va={id:"tower-defense",version:2,engines:["phaser"],requires:["round"],params:{difficulty:{type:"number",default:.5,min:0,max:1},lives:{type:"number",default:20,min:1,max:100,integer:true},gold:{type:"number",default:0,min:0,max:1e5,integer:true},wavePause:{type:"number",default:14,min:2,max:60},firstWait:{type:"number",default:25,min:1,max:600},earlyGold:{type:"number",default:2,min:0,max:100},coinRate:{type:"number",default:.15,min:0,max:1}},setup({world:e,params:t,mode:r}){let o=d=>yr(t,d),n=e.rng.stream("tower-defense"),s=Sr(r,"foes",pf),a=Eo(1,o("difficulty"),s),i=wo(Mo(Na(a.map),a.mirror)),h=[],m=Ne(),v=0,x=20,D=20,O=0,N=[],q=0,ne=null,Z=0,ye=0,be=0,fe=false,Ee=false,de=1,Ae=null,Pe=[],we=null,ce=new Map,ke=[],Le=null,_e=new Map,oe=new Map,Te=()=>So.find(d=>d.id===e.vars["meta:hero"])??So[0],Ke=()=>e.vars.reviving===true;function Ne(){return un(Be(e),Br,Hr,{top:.15,bottom:.86,widthShare:.98})}let se=()=>m.cell,Ie=d=>m.left+d*m.cell,$e=d=>m.top+d*m.cell,Se=d=>({x:Ie(d.col+.5),y:$e(d.row+.5)}),Ye=(d,y)=>({x:(d-m.left)/m.cell,y:(y-m.top)/m.cell}),ee=d=>d.row===0?{x:d.col+.5,y:-0.5}:d.row===Hr-1?{x:d.col+.5,y:Hr+.5}:d.col===0?{x:-0.5,y:d.row+.5}:d.col===Br-1?{x:Br+.5,y:d.row+.5}:null,Re=()=>{h=i.paths.map(d=>{let y=d.map(S=>({x:S.col+.5,y:S.row+.5})),R=ee(d[0]);return R&&y.unshift(R),{pts:y,len:y.length-1}});},rt=(d,y)=>{if(y<=0)return d.pts[0];if(y>=d.len)return d.pts[d.len];let R=Math.floor(y),S=d.pts[R],$=d.pts[R+1],g=y-R;return {x:S.x+($.x-S.x)*g,y:S.y+($.y-S.y)*g}},ht=new Set,De=(d,y,R,S,$=1)=>{ht.add(d);let g=_e.get(d);(g===void 0||!e.isAlive(g))&&(g=e.create(),e.set(g,Jl,{id:d}),_e.set(d,g)),e.set(g,F,{x:y,y:R,scale:$}),e.set(g,le,S);},Qt=d=>{for(let[y,R]of [..._e])ht.has(y)||!d.some(S=>y.startsWith(S))||(e.destroy(R),_e.delete(y));},Xe=d=>{for(let[y,R]of [..._e])y.startsWith(d)&&(e.destroy(R),_e.delete(y));},et=(d,y,R,S)=>{let $=e.create();return e.set($,gf,{kind:d}),e.set($,F,{x:y,y:R}),e.set($,le,S),$},it=()=>{ct(e,gf),ct(e,ja);let d=se();et("grass",Ie(Br/2),$e(Hr/2),{shape:"tile",art:"tile_grass",w:d*Br,h:d*Hr,unit:d,color:"ground",depth:-10}),i.rows.forEach((L,I)=>[...L].forEach((P,W)=>{let te=Se({col:W,row:I}),X=te.y+d*.45;P==="#"||P==="S"||P==="X"?et("road",te.x,te.y,{shape:"sprite",art:"tile_road",w:d+1,h:d+1,color:"lane",depth:-9}):P==="~"?et("water",te.x,te.y,{shape:"rect",w:d+1,h:d+1,color:"primary",alpha:.45,depth:-9}):P==="t"?et("tree",te.x,X-d*.65,{shape:"sprite",art:"td_tree",w:d*1.05,h:d*1.3,depth:Jt(e,X,5)}):P==="r"?et("rock",te.x,X-d*.3,{shape:"sprite",art:"rock",w:d*.8,h:d*.6,depth:Jt(e,X,5)}):P==="*"&&et("bush",te.x,X-d*.3,{shape:"sprite",art:"td_bush",w:d*.85,h:d*.6,depth:Jt(e,X,5)});})),i.spots.forEach((L,I)=>{let P=Se(L),W=et("spot",P.x,P.y+d*.18,{shape:"sprite",art:"td_spot",w:d*.95,h:d*.62,depth:-8});e.set(W,ja,{index:I,col:L.col,row:L.row});});let y=Se(i.gate),R=ee(i.gate),S=R&&R.y>=0?R:null,$=S?Ie(i.gate.col+.5+(S.x-(i.gate.col+.5))*.35):y.x,g=S?$e(i.gate.row+.5+(S.y-(i.gate.row+.5))*.35):y.y;et("gate",$,g-d*.2,{shape:"sprite",art:"td_gate",w:d*1.35,h:d*1.35,depth:Jt(e,g+d*.45,5)});for(let L of i.paths){if(ee(L[0]))continue;let I=Se(L[0]);et("portal",I.x,I.y-d*.1,{shape:"sprite",art:"td_portal",w:d*1.05,h:d*.95,depth:Jt(e,I.y,4)});}},dt=d=>e.query(kr).find(y=>e.need(y,kr).spot===d),mt=d=>{let y=e.need(d,kr),R=zr(y.kind),S=Se(i.spots[y.spot]),$=se(),g=$*1.45,L=S.y+$*.42;e.set(d,F,{x:S.x,y:L-g/2}),e.set(d,le,{shape:"sprite",art:Ia(R,y.tier,y.branch||null),w:$*1.1,h:g,depth:Jt(e,L,5)});},yt=d=>{v=Math.max(0,Math.round(d)),e.vars.gold=v;},gt=(d,y)=>{let R=Se(i.spots[d]);K(e,{kind:"ring",x:R.x,y:R.y,color:y,size:se()*1.5}),K(e,{kind:"burst",x:R.x,y:R.y-se()*.4,color:y,n:10,size:se()});},ft=(d,y)=>{let R=zr(y);if(!R||dt(d)!==void 0)return false;let S=R.tiers[0].cost;if(v<S)return false;yt(v-S);let $=e.create();return e.set($,kr,{spot:d,kind:y,tier:1,branch:"",cooldown:.2}),mt($),gt(d,"text"),e.emit("tower-built",{kind:y}),vt(e,"td-build")||(Lt(e,"td-build"),J()),true},ze=(d,y)=>{let R=dt(d);if(R===void 0)return false;let S=e.need(R,kr),$=zr(S.kind),g;if(y){let L=$.branches.find(I=>I.id===y);if(!L||S.branch||S.tier<$.tiers.length||!a.branches)return false;g=L.cost;}else {if(S.tier>=$.tiers.length)return false;g=$.tiers[S.tier].cost;}return v<g?false:(yt(v-g),y?S.branch=y:S.tier++,mt(R),gt(d,"coin"),e.emit("tower-upgraded",{kind:S.kind,tier:S.tier,branch:S.branch}),true)},Et=d=>{let y=dt(d);if(y===void 0)return false;let R=e.need(y,kr),S=Math.floor(us(zr(R.kind),R.tier,R.branch||null)*ps);yt(v+S);let $=Se(i.spots[d]);return K(e,{kind:"pop",x:$.x,y:$.y-se()*.8,text:`+${S}`,color:"coin",size:Math.round(se()*.3)}),K(e,{kind:"burst",x:$.x,y:$.y,color:"muted",n:12,size:se()}),e.destroy(y),e.emit("tower-sold",{kind:R.kind}),true},Ze=()=>{Ae=null,Pe=[],Xe("m:"),e.vars.td_menu="";},Wt=d=>d.map(y=>`${y.action??y.id}@${Math.round(y.x)},${Math.round(y.y)}`).join(";"),hr=d=>{Ze(),Ae=d,Nt();},Nt=()=>{if(Ae===null)return;let d=Ae;Pe=[];let y=se(),R=Be(e),S=Math.min(R.w,R.h),$=Math.max(y*.46,S*.062),g=Math.max(y*1.1,$*2.3),L=Se(i.spots[d]),I=Math.max(g+$,Math.min(R.w-g-$,L.x)),P=Math.max(R.h*.1+g+$,Math.min(R.h*.88-g-$,L.y-y*.2)),W=(ge,Ve,nt,bt,jt,jr,Dr)=>{let $r=I+Ve*g,ln=P+nt*g;Pe.push({action:ge,x:$r,y:ln,r:$,ok:Dr}),e.vars.td_menu=Wt(Pe),De(`m:${ge}:bg`,$r,ln,{shape:"circle",r:$,color:"panel",alpha:.94,depth:60});let Vn=ge==="sell";De(`m:${ge}:rim`,$r,ln,{shape:"circle",r:$*1.08,color:Vn?"danger":Dr?"coin":"muted",alpha:Dr?.9:.5,depth:59.9}),De(`m:${ge}:art`,$r,ln-$*.12,{shape:"sprite",art:bt,w:Vn?$*1.25:$*1.15,h:Vn?$*1.25:$*1.3,alpha:Dr?1:.45,depth:60.1}),jr&&De(`m:${ge}:txt`,$r,ln+$*.78,{shape:"text",text:jr,size:Math.round($*.52),color:jt!==null&&!Dr?"danger":"coin",bold:true,depth:60.2});},te=dt(d);if(te===void 0){let ge=a.towers.map(nt=>zr(nt)).filter(Boolean),Ve=ge.length<=1?[[0,-1]]:ge.length===2?[[-0.8,-0.7],[.8,-0.7]]:ge.length===3?[[-0.85,-0.6],[.85,-0.6],[0,.9]]:[[-0.8,-0.75],[.8,-0.75],[-0.8,.75],[.8,.75]];ge.slice(0,4).forEach((nt,bt)=>{let jt=nt.tiers[0].cost;W(`build:${nt.id}`,Ve[bt][0],Ve[bt][1],nt.tiers[0].art,jt,String(jt),v>=jt);});return}let X=e.need(te,kr),me=zr(X.kind),ue=hs(me,X.tier,X.branch||null);if(De("m:range",L.x,L.y,{shape:"sprite",art:"aura_field",w:ue.range*y*2,h:ue.range*y*2,color:"primary",alpha:.4,depth:1}),X.tier<me.tiers.length){let ge=me.tiers[X.tier];W("up",0,-1,ge.art,ge.cost,String(ge.cost),v>=ge.cost);}else !X.branch&&a.branches&&me.branches.slice(0,2).forEach((ge,Ve)=>W(`branch:${ge.id}`,Ve===0?-0.85:.85,-0.7,ge.art,ge.cost,String(ge.cost),v>=ge.cost));let xe=Math.floor(us(me,X.tier,X.branch||null)*ps);W("sell",0,1,"td_sell",null,`+${xe}`,true);},ur=d=>{if(Ae===null)return;let y=Ae,R=false;if(d.startsWith("build:")?R=ft(y,d.slice(6)):d==="up"?R=ze(y):d.startsWith("branch:")?R=ze(y,d.slice(7)):d==="sell"&&(R=Et(y)),!R){K(e,{kind:"shake",power:.3});return}Ze();},Tt=(d,y)=>{let R=se(),S=-1,$=1/0;return i.spots.forEach((g,L)=>{let I=Se(g),P=dt(L)!==void 0?I.y-R*1.1:I.y-R*.5;if(Math.abs(d-I.x)>R*.55||y<P||y>I.y+R*.55)return;let W=Math.abs(d-I.x)+Math.abs(y-I.y);W<$&&($=W,S=L);}),S},T=d=>1+.07*(d-1),H=(d,y,R,S)=>{let $=pr(d);if(!$||h.length===0)return null;let g=$.hp*a.hp*($.boss?1:T(S)),L=e.create();return e.set(L,Oe,{kind:d,hp:g,maxHp:g,route:y%h.length,progress:R,x:0,y:0,slow:0,slowLeft:0,stun:0,burn:0,burnLeft:0,healCd:$.heals?.every??0,summonCd:$.summons?.every??0,heldBy:-1,enraged:false,wave:S}),e.set(L,F,{x:0,y:0}),e.set(L,le,{shape:"actor",cast:$.cast,variant:$.variant??n.int(0,99),h:se()*$.size*1.15,pose:$.flying?"air":"walk",depth:6}),u(L),$.boss&&(e.emit(pu,{kind:d}),K(e,{kind:"shake",power:1})),L},u=d=>{let y=e.need(d,Oe),R=pr(y.kind),S=h[y.route],$=rt(S,y.progress),g=rt(S,y.progress+.05);y.x=$.x,y.y=$.y;let L=se(),I=e.need(d,F),P=e.need(d,le),W=$e($.y)+L*.2;if(I.x=Ie($.x),I.y=W-(R.flying?L*.55:0)-(P.shape==="actor"?P.h/2:0),P.shape==="actor"){Math.abs(g.x-$.x)>1e-4&&(P.facing=g.x>$.x?1:-1),P.depth=Jt(e,W,5),P.h=L*R.size*1.15;let te=y.heldBy<0&&y.stun<=0;P.pose=R.flying?"air":te?"walk":"idle",P.speed=R.speed*(1-y.slow)*L*de;}},f=d=>h[d.route].len-d.progress,b=d=>{let y=e.need(d,F);return {x:y.x,y:y.y}},c=(d,y,R,S,$=1,g="tower")=>{let L=e.get(d,Oe);if(!L)return;let I=pr(L.kind),P=y.damage*R*$*(S?2:1);if(y.type==="physical"?P*=1-I.armor*(1-(y.pierce??0)):y.type==="magic"&&(P*=1-I.resist),y.slow&&(L.slow=Math.max(L.slow,y.slow*(I.boss?.5:1)),L.slowLeft=Math.max(L.slowLeft,(y.slowTime??1)*R)),y.burn&&(L.burn=Math.max(L.burn,y.burn*R),L.burnLeft=Math.max(L.burnLeft,y.burnTime??2)),y.stun&&!I.boss&&n.chance(y.stun)&&(L.stun=Math.max(L.stun,y.stunTime??.5)),S){let W=b(d);K(e,{kind:"pop",x:W.x,y:W.y-se()*.5,text:String(Math.round(P)),color:"danger",size:Math.round(se()*.3)});}p(d,P,g);},p=(d,y,R)=>{let S=e.get(d,Oe);S&&(S.hp-=y,S.hp<=0&&k(d,R));},k=(d,y)=>{let R=e.need(d,Oe),S=pr(R.kind);e.remove(d,Oe),at(e,d,"die"),_n(e,d,1),ye++;let $=Math.round(S.bounty*a.bounty);yt(v+$);let g=b(d);if(K(e,{kind:"pop",x:g.x,y:g.y-se()*.6,text:`+${$}`,color:"coin",size:Math.round(se()*.28)}),e.emit("enemy-defeated",{kind:R.kind,by:y}),S.boss?(be++,Qe(e,"coins",10),e.emit(hu,{kind:R.kind}),K(e,{kind:"shake",power:1.4}),K(e,{kind:"flash",color:"coin"})):n.chance(o("coinRate"))&&(Qe(e,"coins",1),e.emit("coin-collected",{value:1})),S.splits)for(let L=0;L<S.splits.count;L++)H(S.splits.into,R.route,Math.max(0,R.progress-.18*L),R.wave);},_=d=>{let y=e.need(d,Oe),R=pr(y.kind),S=Se(i.gate);K(e,{kind:"burst",x:S.x,y:S.y,color:"danger",n:12,size:se()}),e.destroy(d),x=Math.max(0,x-R.leak),e.vars.lives=x,e.emit("player-hit",{lives:x}),K(e,{kind:"flash",color:"danger"}),K(e,{kind:"shake",power:R.boss?1.6:.8}),x<=0&&ae();},C=()=>{if(!(O>=a.waves.length)){O++,e.vars.wave=O,N=[];for(let d of a.waves[O-1].groups)for(let y=0;y<d.count;y++)N.push({at:d.delay+y*d.gap,enemy:d.enemy,entry:d.entry});N.sort((d,y)=>d.at-y.at),q=0,ne=null,e.emit(ec,{wave:O});}},z=()=>{if(!(ne===null||O>=a.waves.length)){if(O>0){let d=Math.ceil(ne*o("earlyGold")*a.bounty);if(d>0){yt(v+d);let y=ke.find(R=>R.id.startsWith("call"));y&&K(e,{kind:"pop",x:y.x,y:y.y-se()*.6,text:`+${d}`,color:"coin",size:Math.round(se()*.32)});}}Lt(e,"td-call"),C();}},B=d=>{if(fe||!ot(e))return;fe=true;let y=d==="defended",R=y?Math.min(Ee?1:3,za(x,D)):0;e.vars.stars=R,y&&e.vars["meta:first_clear"]===true&&Qe(e,"coins",a.firstClearGold),e.vars.score=Me()+(y?1e3+R*300:0),e.vars.reviving=false,Ze(),e.emit(Ut,{reason:d,stats:{chapter:a.level,seconds:Math.floor(Z),cleared:y,stars:R,coins:Number(e.vars.coins??0),bosses:be,kills:ye,lives:x}});},ae=()=>{if(e.vars.revive_ready===true&&!Ee){e.vars.reviving=true,Ze(),e.emit(er,{});return}B("overrun");},pe=()=>{if(Ke()){Ee=true,e.vars.reviving=false,x=Ba,e.vars.lives=x;for(let d of e.query(Oe))e.need(d,Oe).stun=2;K(e,{kind:"flash",color:"coin"});}},Me=()=>ye*10+x*50+Math.max(0,O-1)*100,qe=()=>1+ys(e,"meta:spells"),tt=(d,y,R)=>{let S=$o.find(L=>L.id===d);if(!S||(ce.get(d)??0)>0)return;let $=Ye(y,R);if($.x<-0.5||$.y<-0.5||$.x>Br+.5||$.y>Hr+.5)return;if(S.kind==="strike")for(let L=0;L<(S.count??1);L++){let I=e.create(),P=(S.radius??1)*.9;e.set(I,Ha,{x:$.x+(L===0?0:(n.next()-.5)*P*2),y:$.y+(L===0?0:(n.next()-.5)*P*2),t:0,delay:L*.2,damage:(S.damage??1)*a.hp*qe(),radius:S.radius??1,burn:(S.burn??0)*a.hp*qe()}),e.set(I,F,{x:-999,y:-999}),e.set(I,le,{shape:"sprite",art:"td_meteor",w:se()*.9,h:se()*.9,alpha:0,depth:45});}else {let L={route:0,q:0,d:1/0};h.forEach((P,W)=>{for(let te=.5;te<=P.len-.5;te+=.25){let X=rt(P,te),me=Math.hypot(X.x-$.x,X.y-$.y);me<L.d&&(L={route:W,q:te,d:me});}});let I=S.count??1;for(let P=0;P<I;P++){let W=e.create(),te=(S.hp??3)*a.hp*qe();e.set(W,Ar,{hp:te,maxHp:te,dps:(S.dps??.5)*a.hp*qe(),left:S.time??12,route:L.route,progress:Math.max(.3,Math.min(h[L.route].len-.3,L.q+(P-(I-1)/2)*.45)),swing:0}),e.set(W,F,{x:0,y:0}),e.set(W,le,{shape:"actor",cast:S.cast??"helper",variant:n.int(0,99),h:se()*.85,pose:"idle",depth:6}),pt(W);let X=e.need(W,F);K(e,{kind:"ring",x:X.x,y:X.y,color:"accent",size:se()*1.2});}}let g=S.cooldown*(Te().perk==="spells"?.7:1);ce.set(d,g),we=null,Le!==null&&e.isAlive(Le)&&Ge(e,Le,"attack"),e.emit("spell-cast",{id:d});},pt=d=>{let y=e.need(d,Ar),R=h[y.route],S=rt(R,y.progress),$=rt(R,y.progress-.2),g=se(),L=e.need(d,F),I=e.need(d,le),P=$e(S.y)+g*.2;L.x=Ie(S.x),L.y=P-(I.shape==="actor"?I.h/2:0),I.shape==="actor"&&(Math.abs($.x-S.x)>1e-4&&(I.facing=$.x>S.x?1:-1),I.depth=Jt(e,P,5),I.h=g*.85);},re=()=>{(Le===null||!e.isAlive(Le))&&(Le=e.create());let d=se(),y=i.gate,R=[[1,0],[-1,0],[0,-1],[0,1]].map(([g,L])=>({col:y.col+g,row:y.row+L})).find(g=>g.col>=0&&g.row>=0&&g.col<Br&&g.row<Hr&&".tr*".includes(i.rows[g.row][g.col]))??y,S=Se(R),$=S.y+d*.35;e.set(Le,F,{x:S.x,y:$-d*.6}),e.set(Le,le,{shape:"actor",cast:Te().cast,h:d*1.2,pose:"idle",facing:R.col>y.col?-1:1,depth:Jt(e,$,5)});},j=()=>{if(vt(e,"td-build")||i.spots.length===0)return;let d=h[0],y=rt(d,d.len*.4),R=0,S=1/0;i.spots.forEach(($,g)=>{let L=Math.hypot($.col+.5-y.x,$.row+.5-y.y);L<S&&(S=L,R=g);}),kt(e,"tap",Se(i.spots[R]),void 0,se()*1.2);},J=()=>{if(vt(e,"td-call")||O>0)return;let d=Se(i.paths[0][0]);kt(e,"tap",d,void 0,se()*1.2);},Y=()=>{let d=Be(e),y=Math.min(d.w,d.h),R=se(),S=d.h*.085,$=y*.05,g=(X,me,ue,xe,ge="text",Ve=y*.042)=>De(X,me,ue,{shape:"text",text:xe,size:Math.round(Ve),color:ge,bold:true,depth:70});De("h:lives:i",d.w*.07,S,{shape:"sprite",art:"heart",w:$,h:$,depth:70}),g("h:lives",d.w*.15,S,String(x),x<=5?"danger":"text"),De("h:gold:i",d.w*.3,S,{shape:"sprite",art:"td_gold",w:$*1.15,h:$,depth:70}),g("h:gold",d.w*.4,S,String(v),"coin"),De("h:wave:i",d.w*.56,S,{shape:"sprite",art:"td_call",w:$,h:$,depth:70}),g("h:wave",d.w*.66,S,`${O}/${a.waves.length}`),De("h:coin:i",d.w*.8,S,{shape:"sprite",art:"coin",w:$*.9,h:$*.9,depth:70}),g("h:coin",d.w*.89,S,String(e.vars.coins??0));let L=d.h*.125,I=e.query(Oe).find(X=>pr(e.need(X,Oe).kind)?.boss);if(I!==void 0){let X=e.need(I,Oe),me=d.w*.55,ue=Math.max(10,y*.022);De("h:n:boss:bg",d.w/2,L,{shape:"rect",w:me,h:ue,color:"#000000",alpha:.5,radius:ue/2,depth:69});let xe=Math.max(1,(me-4)*Math.max(0,X.hp/X.maxHp));De("h:n:boss:fill",d.w/2-(me-4)/2+xe/2,L,{shape:"rect",w:xe,h:ue-4,color:"danger",radius:(ue-4)/2,depth:69.1}),De("h:n:boss:i",d.w/2-me/2-$*.7,L,{shape:"sprite",art:"skull",w:$,h:$,depth:70});}else if(ne!==null&&O<a.waves.length){let X=new Map;for(let ge of a.waves[O].groups)X.set(ge.enemy,(X.get(ge.enemy)??0)+ge.count);let me=[...X].slice(0,5),ue=y*.15,xe=d.w/2-(me.length-1)*ue/2;me.forEach(([ge,Ve],nt)=>{let bt=pr(ge),jt=xe+nt*ue;De(`h:n:${ge}:a`,jt-$*.4,L+$*.1,{shape:"actor",cast:bt.cast,variant:bt.variant??1,h:$*1.5*Math.min(1.3,bt.size+.25),pose:bt.flying?"air":"idle",depth:70}),g(`h:n:${ge}:t`,jt+$*.55,L+$*.1,`\xD7${Ve}`,bt.boss?"danger":"text",y*.034);});}if(ke=[],ne!==null&&O<a.waves.length){let X=O===0?1+.08*Math.sin(e.time*6):1;i.paths.forEach((me,ue)=>{let xe=Se(me[0]),ge=R*.42;ke.push({id:`call:${ue}`,x:xe.x,y:xe.y,r:ge*1.2}),De(`b:call:${ue}:bg`,xe.x,xe.y,{shape:"circle",r:ge,color:"danger",alpha:.92,depth:65},X),De(`b:call:${ue}:i`,xe.x,xe.y,{shape:"sprite",art:"td_call",w:ge*1.3,h:ge*1.3,depth:65.1},X),De(`b:call:${ue}:t`,xe.x,xe.y+ge*1.25,{shape:"text",text:String(Math.ceil(ne??0)),size:Math.round(R*.26),color:"text",bold:true,depth:65.2});});}let P=d.h*.925,W=y*.065;$o.filter(X=>a.spells.includes(X.id)).forEach((X,me)=>{let ue=d.w*.12+me*W*2.6,xe=ce.get(X.id)??0;ke.push({id:`spell:${X.id}`,x:ue,y:P,r:W*1.15}),we===X.id&&De(`b:s:${X.id}:rim`,ue,P,{shape:"circle",r:W*1.18,color:"coin",alpha:.6+.4*Math.sin(e.time*8),depth:64.9}),De(`b:s:${X.id}:bg`,ue,P,{shape:"circle",r:W,color:"panel",alpha:.92,depth:65}),De(`b:s:${X.id}:i`,ue,P,{shape:"sprite",art:X.icon,w:W*1.25,h:W*1.25,alpha:xe>0?.4:1,depth:65.1}),xe>0&&De(`b:s:${X.id}:t`,ue,P,{shape:"text",text:String(Math.ceil(xe)),size:Math.round(W*.8),color:"text",bold:true,depth:65.2});});let te=d.w*.88;ke.push({id:"speed",x:te,y:P,r:W*1.15}),De("b:speed:bg",te,P,{shape:"circle",r:W,color:de>1?"coin":"panel",alpha:.92,depth:65}),e.vars.td_buttons=Wt(ke),De("b:speed:t",te,P,{shape:"text",text:`x${de}`,size:Math.round(W*.75),color:de>1?"panel":"text",bold:true,depth:65.1});},M=()=>{let d=se(),y=new Set,R=(S,$,g,L,I)=>{y.add(S);let P=oe.get(S);if(!P){P=[e.create(),e.create(),e.create(),e.create(),e.create()];for(let[jt,jr]of P.entries())e.set(jr,bf,{of:S,part:String(jt)});oe.set(S,P);}let W=e.need(S,F),te=e.need(S,le),X=te.shape==="actor"?te.h:d,me=W.y-X/2-d*.08,ue=Math.min(Be(e).w,Be(e).h),xe=Math.max(d*.62,ue*.065),ge=Math.max(5,xe*.13),Ve=$<.999;e.set(P[0],F,{x:W.x,y:me}),e.set(P[0],le,{shape:"rect",w:xe,h:ge,color:"#000000",alpha:Ve?.55:0,radius:ge/2,depth:30});let nt=Math.max(1,(xe-2)*Math.max(0,$));e.set(P[1],F,{x:W.x-(xe-2)/2+nt/2,y:me}),e.set(P[1],le,{shape:"rect",w:nt,h:ge-2,color:g,alpha:Ve?1:0,radius:(ge-2)/2,depth:30.1}),e.set(P[2],F,{x:W.x-xe/2-d*.12,y:me}),e.set(P[2],le,{shape:"sprite",art:L??"shield",w:d*.24,h:d*.24,alpha:L?1:0,depth:30.2});let bt=W.y+X/2;e.set(P[3],F,{x:W.x,y:bt}),e.set(P[3],le,{shape:"sprite",art:"aura_field",w:d*.75,h:d*.32,color:"primary",alpha:I?.slow?.75:0,depth:2}),e.set(P[4],F,{x:W.x,y:W.y}),e.set(P[4],le,{shape:"sprite",art:"burst",w:d*.45,h:d*.45,color:"danger",alpha:I?.burn?.5+.4*Math.sin(e.time*20):0,depth:29});};for(let S of e.query(Oe)){let $=e.need(S,Oe);R(S,$.hp/$.maxHp,"danger",pr($.kind)?.badge,{slow:$.slowLeft>0,burn:$.burnLeft>0});}for(let S of e.query(Ar)){let $=e.need(S,Ar);R(S,$.hp/$.maxHp,"accent",void 0,null);}for(let[S,$]of [...oe])if(!y.has(S)){for(let g of $)e.destroy(g);oe.delete(S);}},E=()=>{for(let d of [kr,Oe,Hn,Ar,Ha,Wa,bf,Jl])ct(e,d);_e.clear(),oe.clear();for(let d of e.query(le))e.need(d,le).shape==="actor"&&d!==Le&&!e.has(d,Jl)&&e.destroy(d);},l=()=>{E(),a=Eo(ys(e,"meta:chapter")||1,o("difficulty"),s),i=wo(Mo(Na(a.map),a.mirror)),Re(),Bt(e,"top"),m=Ne(),it(),v=0,yt((a.gold+o("gold")+ys(e,"meta:start_gold"))*(Te().perk==="gold"?1.25:1)),D=o("lives")+ys(e,"meta:lives"),x=D,O=0,N=[],q=0,ne=o("firstWait"),Z=0,ye=0,be=0,fe=false,Ee=false,de=1,Ae=null,Pe=[],we=null,ce.clear(),ke=[],e.vars.lives=x,e.vars.wave=0,e.vars.waves=a.waves.length,e.vars.td_level=a.level,e.vars.td_world=a.world,e.vars.coins=0,e.vars.score=0,e.vars.stars=0,e.vars.reviving=false,e.vars.td_speed=1,e.vars.level_progress=0,re();},w=d=>{if(d.startsWith("call"))z();else if(d==="speed")de=de>1?1:2,e.vars.td_speed=de;else if(d.startsWith("spell:")){let y=d.slice(6);we===y?we=null:(ce.get(y)??0)<=0&&(we=y,Ze());}};e.on(zt,d=>{let y=d;if(y.type!=="tap"||!ot(e)||hn(e)||fe||Ke())return;if(Ae!==null){let $=Pe.find(g=>Math.hypot(y.x-g.x,y.y-g.y)<=g.r);if($){ur($.action);return}Ze();}let R=ke.find($=>Math.hypot(y.x-$.x,y.y-$.y)<=$.r);if(R){w(R.id);return}if(we!==null){tt(we,y.x,y.y);return}let S=Tt(y.x,y.y);S>=0&&(vt(e,"td-build")||Ht(e),hr(S));}),e.on(qt,()=>{l(),e.vars.level=a.level,j();}),e.on(Zt,l),e.on(tr,pe),e.on(rr,()=>{Ke()&&(e.vars.reviving=false,B("overrun"));}),e.on(Xt,d=>{Ze(),Xe("b:"),ke=[],Le!==null&&e.isAlive(Le)&&at(e,Le,d.reason==="defended"?"dance":"die");for(let y of e.query(Oe))at(e,y,"idle");}),e.on(Ft,()=>{Bt(e,"top"),m=Ne(),it();for(let d of e.query(kr))mt(d);ct(e,Hn),Ae!==null&&Nt(),re();}),e.addSystem({id:"tower-defense",order:0,run(d,y){if(!ot(d)||fe||Ke())return;let R=y*de;Z+=y;let S=se();for(let[$,g]of ce)g>0&&ce.set($,Math.max(0,g-R));if(N.length>0){for(q+=R;N.length>0&&N[0].at<=q;){let $=N.shift();H($.enemy,$.entry,0,O);}N.length===0&&O<a.waves.length&&(ne=o("wavePause"));}else ne!==null&&(ne-=R,ne<=0&&C());for(let $ of d.query(Ar)){let g=d.need($,Ar);if(g.left-=R,g.left<=0||g.hp<=0){d.remove($,Ar),at(d,$,"die"),_n(d,$,.8);for(let P of d.query(Oe))d.need(P,Oe).heldBy===$&&(d.need(P,Oe).heldBy=-1);continue}let L=rt(h[g.route],g.progress),I=d.query(Oe).filter(P=>d.need(P,Oe).heldBy===$);if(I.length<2){let P=d.query(Oe).filter(W=>{let te=d.need(W,Oe),X=pr(te.kind);return te.heldBy<0&&!X.flying&&!X.boss&&Math.hypot(te.x-L.x,te.y-L.y)<=mu}).slice(0,2-I.length);for(let W of P)d.need(W,Oe).heldBy=$,I.push(W);}I.length>0&&(p(I[0],g.dps*R,"soldier"),g.swing-=R,g.swing<=0&&(Ge(d,$,"attack"),g.swing=.6)),pt($);}for(let $ of d.query(Oe)){let g=d.get($,Oe);if(!g)continue;let L=pr(g.kind);if(!(g.burnLeft>0&&(g.burnLeft-=R,p($,g.burn*R,"burn"),!d.has($,Oe)))){if(g.slowLeft>0&&(g.slowLeft-=R,g.slowLeft<=0&&(g.slow=0)),g.stun>0&&(g.stun-=R),L.heals&&(g.healCd-=R,g.healCd<=0)){g.healCd=L.heals.every;for(let P of d.query(Oe)){let W=d.need(P,Oe);Math.hypot(W.x-g.x,W.y-g.y)>L.heals.radius||(W.hp=Math.min(W.maxHp,W.hp+W.maxHp*L.heals.share));}let I=b($);K(d,{kind:"ring",x:I.x,y:I.y,color:"accent",size:L.heals.radius*S*2});}if(L.summons&&(g.summonCd-=R,g.summonCd<=0)){g.summonCd=L.summons.every;for(let I=0;I<L.summons.count;I++)H(L.summons.id,g.route,Math.max(0,g.progress-.45*(I+1)),g.wave);Ge(d,$,"cheer");}if(L.enrage&&!g.enraged&&g.hp<g.maxHp*L.enrage.below){g.enraged=true;let I=b($);K(d,{kind:"ring",x:I.x,y:I.y,color:"danger",size:S*2});}if(g.heldBy>=0&&!d.has(g.heldBy,Ar)&&(g.heldBy=-1),g.heldBy<0&&g.stun<=0&&(g.progress+=L.speed*(1-g.slow)*(g.enraged&&L.enrage?L.enrage.speed:1)*R),g.progress>=h[g.route].len){if(_($),fe||Ke())return;continue}u($);}}for(let $ of d.query(kr)){let g=d.need($,kr);if(g.cooldown-=R,g.cooldown>0)continue;let L=zr(g.kind),I=hs(L,g.tier,g.branch||null),P=1+ys(d,L.metaVar),W=i.spots[g.spot],te=W.col+.5,X=W.row+.5,me=d.query(Oe).filter(xe=>{let ge=d.need(xe,Oe);return (pr(ge.kind).flying?I.air:I.ground)&&ge.progress>0&&Math.hypot(ge.x-te,ge.y-X)<=I.range}).sort((xe,ge)=>f(d.need(xe,Oe))-f(d.need(ge,Oe))).slice(0,I.multishot??1);if(me.length===0){g.cooldown=0;continue}g.cooldown=1/I.rate;let ue={x:Ie(te),y:$e(X)-S*.75};for(let xe of me){let ge=I.crit!==void 0&&n.chance(I.crit);if(I.beam){let jr=[],Dr=ue,$r=xe,ln=1;for(let Vn=0;Vn<=(I.chain??0)&&$r!==void 0;Vn++){let Tc=b($r);A(Dr,Tc,I.type==="magic"?"secondary":"primary"),jr.push($r);let Gn=d.need($r,Oe),sp=d.query(Oe).filter(Kn=>!jr.includes(Kn)&&Math.hypot(d.need(Kn,Oe).x-Gn.x,d.need(Kn,Oe).y-Gn.y)<=1.6).sort((Kn,Dc)=>Math.hypot(d.need(Kn,Oe).x-Gn.x,d.need(Kn,Oe).y-Gn.y)-Math.hypot(d.need(Dc,Oe).x-Gn.x,d.need(Dc,Oe).y-Gn.y))[0];c($r,I,P,ge,ln),Dr=Tc,$r=sp,ln*=.7;}continue}let Ve=b(xe),nt=d.create(),bt=Math.max(1,Math.hypot(Ve.x-ue.x,Ve.y-ue.y));d.set(nt,Hn,{target:xe,x:ue.x,y:ue.y,ax:Ve.x,ay:Ve.y,dist0:bt,went:0,stats:I,power:P,crit:ge}),d.set(nt,F,{x:ue.x,y:ue.y});let jt=I.shot==="td_arrow"?{w:S*.55,h:S*.18}:I.lob?{w:S*.34,h:S*.34}:{w:S*.3,h:S*.3};d.set(nt,le,{shape:"sprite",art:I.shot,...jt,...I.burn?{color:"danger"}:I.slow?{color:"primary"}:I.type==="magic"?{color:"secondary"}:{},depth:40});}}for(let $ of d.query(Hn)){let g=d.need($,Hn);if(d.has(g.target,Oe)){let X=b(g.target);g.ax=X.x,g.ay=X.y;}let L=g.ax-g.x,I=g.ay-g.y,P=Math.hypot(L,I),W=g.stats.shotSpeed*S*R,te=d.need($,F);if(P>W){g.x+=L/P*W,g.y+=I/P*W,g.went+=W;let X=Math.min(1,g.went/g.dist0);te.x=g.x,te.y=g.y-(g.stats.lob?Math.sin(Math.PI*X)*S*.9:0),te.rotation=g.stats.lob?(te.rotation??0)+R*8:Math.atan2(I,L);continue}if(d.destroy($),g.stats.splash){let X=Ye(g.ax,g.ay);K(d,{kind:"burst",x:g.ax,y:g.ay,color:g.stats.burn?"danger":g.stats.slow?"primary":"coin",n:12,size:g.stats.splash*S*1.6}),g.stats.lob&&K(d,{kind:"shake",power:.25});for(let me of d.query(Oe)){let ue=d.need(me,Oe),xe=pr(ue.kind);(xe.flying?g.stats.air:g.stats.ground)&&Math.hypot(ue.x-X.x,ue.y+(xe.flying?-0.55:0)-X.y)<=g.stats.splash&&c(me,g.stats,g.power,g.crit);}}else d.has(g.target,Oe)&&(K(d,{kind:"burst",x:g.ax,y:g.ay,color:g.stats.type==="magic"?"secondary":"coin",n:5,size:S*.5}),c(g.target,g.stats,g.power,g.crit));if(fe||Ke())return}for(let $ of d.query(Ha)){let g=d.need($,Ha);g.t+=R;let L=(g.t-g.delay)/uu,I=d.need($,F),P=d.need($,le);if(L<0)continue;if(L<1){let te=Be(d).h;I.x=Ie(g.x)+(1-L)*S*2,I.y=$e(g.y)-(1-L)*te*.5,I.rotation=-0.9,P.shape==="sprite"&&(P.alpha=1);continue}d.destroy($),K(d,{kind:"burst",x:Ie(g.x),y:$e(g.y),color:"danger",n:20,size:g.radius*S*2}),K(d,{kind:"ring",x:Ie(g.x),y:$e(g.y),color:"coin",size:g.radius*S*2.2}),K(d,{kind:"shake",power:.8});let W={damage:g.damage,type:"true",...g.burn>0?{burn:g.burn,burnTime:2}:{}};for(let te of d.query(Oe)){let X=d.need(te,Oe);Math.hypot(X.x-g.x,X.y-g.y)<=g.radius&&c(te,W,1,false,1,"spell");}if(fe||Ke())return}for(let $ of d.query(Wa)){let g=d.need($,Wa);g.life-=y,g.life<=0&&d.destroy($);}if(O>=a.waves.length&&N.length===0&&d.query(Oe).length===0){B("defended");return}d.vars.level_progress=a.waves.length>0?Math.min(1,(O-(N.length>0||d.query(Oe).length>0?.5:0))/a.waves.length):0,d.vars.score=Me(),ht.clear(),Ae!==null&&Nt(),M(),Y(),Qt(["m:","h:","b:"]);}});let A=(d,y,R)=>{let S=Math.hypot(y.x-d.x,y.y-d.y),$=e.create();e.set($,Wa,{life:.16}),e.set($,F,{x:(d.x+y.x)/2,y:(d.y+y.y)/2,rotation:Math.atan2(y.y-d.y,y.x-d.x)}),e.set($,le,{shape:"sprite",art:"zap",w:Math.max(8,S),h:se()*.22,color:R,depth:41});};Re(),l();}};var gs=[{id:"lemon",art:"biz1",color:"coin",cost:4,income:1,cycle:1,growth:1.07,manager:60},{id:"bakery",art:"biz2",color:"accent",cost:50,income:17,cycle:2,growth:1.1,manager:600},{id:"cafe",art:"biz3",color:"secondary",cost:600,income:225,cycle:3,growth:1.11,manager:7e3},{id:"workshop",art:"biz4",color:"primary",cost:7e3,income:2800,cycle:4,growth:1.11,manager:8e4},{id:"cinema",art:"ty_cinema",color:"danger",cost:8e4,income:4e4,cycle:6,growth:1.11,manager:1e6},{id:"hotel",art:"biz6",color:"secondary",cost:9e5,income:51e4,cycle:8,growth:1.11,manager:11e6},{id:"bank",art:"biz5",color:"coin",cost:1e7,income:62e5,cycle:10,growth:1.11,manager:12e7},{id:"port",art:"ty_port",color:"primary",cost:12e7,income:8e7,cycle:12,growth:1.11,manager:15e8}],Wn=e=>gs.find(t=>t.id===e),bs=[{at:10,speed:2},{at:25,speed:2},{at:50,speed:2},{at:75,income:3},{at:100,speed:2},{at:150,income:3}],Ka=.1,Fa=[{id:"double",scope:"one",art:"ty_up",mult:2,price:60,after:5},{id:"triple",scope:"one",art:"ty_up3",mult:3,price:2500,after:25},{id:"all",scope:"all",art:"ty_upall",mult:2,price:40,after:15}],_o=[{id:"rush",art:"ty_rush",effect:"rush",weight:3,ttl:7,mult:3,seconds:10},{id:"break",art:"ty_wrench",effect:"break",weight:2,ttl:99,taps:3},{id:"invest",art:"ty_investor",effect:"invest",weight:1,ttl:9,now:25,mult:2,seconds:30},{id:"courier",art:"chest",effect:"courier",weight:2,ttl:6,now:15,coins:2}],xf=e=>_o.find(t=>t.id===e),tc=[11,18],rc=[{id:"rush",art:"ty_sk_rush",charge:30,effect:"rush",mult:5,seconds:12},{id:"instant",art:"ty_sk_instant",charge:26,effect:"instant",cycles:8},{id:"sale",art:"ty_sk_sale",charge:28,effect:"sale",mult:.5,seconds:15}],qa=e=>rc.find(t=>t.id===e),kf=.4,vf=3,Ro=[{id:"hero",cast:"hero",gems:0,skill:"rush"},{id:"hero2",cast:"hero2",gems:150,skill:"instant"},{id:"hero3",cast:"hero3",gems:300,skill:"sale"}];var $f={l:"lemon",b:"bakery",c:"cafe",w:"workshop",n:"cinema",h:"hotel",k:"bank",p:"port"},yu={r:"rush",b:"break",i:"invest",c:"courier"},je=(e,t,r="",o)=>({businesses:[...e].map(n=>$f[n]??"lemon"),goals:t,events:[...r].map(n=>yu[n]??"rush"),...{}}),Ga=e=>({...e,vip:true}),Ue=e=>({kind:"cash",n:e}),At=(e,t)=>({kind:"level",biz:$f[e]??"lemon",n:t}),ir=e=>({kind:"managers",n:e}),jn=[je("lb",[Ue(5200)]),je("lb",[At("l",25),Ue(62e3)]),je("lbc",[Ue(17e3)],"r"),je("lbc",[ir(2),Ue(34e3)],"r"),je("lbc",[At("b",25),Ue(51e3)],"rc"),je("lbcw",[Ue(21e4)],"rc"),je("lbcw",[At("c",25),ir(2)],"rc"),je("lbcw",[ir(3),Ue(46e4)],"rc"),je("lbcw",[At("w",10),Ue(1e6)],"rc"),Ga(je("lbcw",[At("c",25),ir(4),Ue(5e6)],"rc")),je("bcw",[Ue(73e3)],"rb"),je("bcw",[At("c",25),Ue(17e4)],"rcb"),je("bcwn",[Ue(2e5)],"rcb"),je("bcwn",[ir(2),Ue(42e4)],"rcb"),je("bcwn",[At("n",5),Ue(97e4)],"rcb"),je("bcwn",[At("w",25),Ue(24e5)],"rcb"),je("bcwn",[ir(3),Ue(19e5)],"rcb"),je("bcwn",[At("c",50),Ue(32e5)],"rcb"),je("bcwn",[At("n",10),ir(3)],"rcb"),Ga(je("bcwn",[At("n",10),ir(4),Ue(64e6)],"rcb")),je("cwn",[Ue(12e5)],"rcbi"),je("cwn",[At("w",25),Ue(2e6)],"rcbi"),je("cwnh",[Ue(27e5)],"rcbi"),je("cwnh",[ir(2),Ue(32e5)],"rcbi"),je("cwnh",[At("h",5),Ue(16e6)],"rcbi"),je("cwnh",[At("n",25),Ue(26e6)],"rcbi"),je("cwnh",[ir(3),Ue(15e6)],"rcbi"),je("cwnh",[At("w",50),Ue(42e6)],"rcbi"),je("cwnh",[At("h",10),ir(3)],"rcbi"),Ga(je("cwnh",[At("h",10),ir(4),Ue(26e7)],"rcbi")),je("wnhk",[Ue(12e6)],"rcbi"),je("wnhk",[At("h",10),Ue(36e6)],"rcbi"),je("wnhk",[ir(3),Ue(21e7)],"rcbi"),je("nhkp",[Ue(21e7)],"rcbi"),je("nhkp",[At("k",10),Ue(38e7)],"rcbi"),je("nhkp",[ir(2),Ue(42e7)],"rcbi"),je("nhkp",[At("p",5),Ue(27e8)],"rcbi"),je("nhkp",[At("k",25),Ue(32e8)],"rcbi"),je("nhkp",[At("p",10),ir(3)],"rcbi"),Ga(je("nhkp",[At("p",10),ir(4),Ue(11e9)],"rcbi"))],Ao=10,Mf=4,Lo=jn.length,nc=[0,18,45,75],oc=e=>nc[Math.ceil(Math.max(1,e)/Ao)-1]??0,Ua=e=>e>=.3?3:e>=.12?2:1,Xa=30,wf=(e,t)=>Math.round((t?40:20)+(e-1)*2),sc=(e,t)=>(t?120:50)+(e-1)*10,ac="kit-tycoon",ic=[{id:"StartCash",var:"meta:cash",art:"coin",color:"coin",perLevel:20,unit:"%",maxLevel:15,price:40,growth:.12},{id:"CycleSpeed",var:"meta:speed",art:"hourglass",color:"secondary",perLevel:3,unit:"%",maxLevel:15,price:45,growth:.12},{id:"Income",var:"meta:income",art:"ty_up",color:"accent",perLevel:5,unit:"%",maxLevel:20,price:40,growth:.12},{id:"Discount",var:"meta:discount",art:"ty_sk_sale",color:"primary",perLevel:2,unit:"%",maxLevel:15,price:50,growth:.12},{id:"SkillPower",var:"meta:skill",art:"ty_sk_rush",color:"secondary",perLevel:8,unit:"%",maxLevel:10,price:50,growth:.12}],Ef={game:"tycoon",character:ac,stats:ic,heroes:Ro,levels:Lo,firstClearGold:e=>sc(e,jn[Math.max(1,Math.min(Lo,e))-1]?.vip===true),stars:3,starsToEnter:oc};var gu={income:0,speed:0,discount:0};function ks(e,t=gu,r){return {biz:e.businesses.map((n,s)=>({def:Wn(n)??gs[0],level:s===0?1:0,progress:0,ready:false,manager:false,mult:1,rush:0,rushMult:1,broken:0})),cash:r??Lf(e),earned:0,allMult:1,bought:new Set,timed:[],mods:t}}var Lf=e=>e.cash??(Wn(e.businesses[1]??e.businesses[0]??"lemon")?.cost??4)*2,bu=e=>e.timed.reduce((t,r)=>t*r.income,1),xu=e=>e.timed.reduce((t,r)=>t*r.price,1);function vs(e){let t=1,r=1,o=0;for(let n of bs)e>=n.at?(t*=n.speed??1,r*=n.income??1):o===0&&(o=n.at);return {speed:t,income:r,next:o}}function kn(e,t){let r=vs(t.level);return Math.max(Ka,t.def.cycle/r.speed/(1+e.mods.speed))}function Tr(e,t,r=t.level){if(r<=0)return 0;let o=vs(r),n=t.def.cycle/o.speed/(1+e.mods.speed),s=n<Ka?Ka/n:1;return t.def.income*r*o.income*s*t.mult*e.allMult*(1+e.mods.income)*(t.rush>0?t.rushMult:1)*bu(e)}var Za=(e,t)=>t.level<=0||t.broken>0?0:Tr(e,t)/kn(e,t),Qa=e=>e.biz.reduce((t,r)=>t+Za(e,r),0),xs=e=>Math.max(.1,1-Math.min(.9,e.mods.discount))*xu(e);function vn(e,t,r=1){let o=t.def.growth,n=t.def.cost*Math.pow(o,t.level),s=r<=1?n:n*(Math.pow(o,r)-1)/(o-1);return Math.ceil(s*xs(e))}function cc(e,t,r=1e3){let o=t.def.growth,n=t.def.cost*Math.pow(o,t.level)*xs(e);if(e.cash<n)return 0;let s=Math.floor(Math.log(e.cash*(o-1)/n+1)/Math.log(o)),a=Math.max(1,Math.min(r,s));for(;a>1&&vn(e,t,a)>e.cash;)a--;return vn(e,t,a)<=e.cash?a:0}var To=(e,t)=>Math.ceil(t.def.manager*xs(e));function Ya(e,t,r=1){let o=e.biz[t];if(!o||r<1)return {ok:false,milestones:[]};let n=vn(e,o,r);if(e.cash<n)return {ok:false,milestones:[]};e.cash-=n;let s=o.level;return o.level+=r,{ok:true,milestones:bs.filter(a=>s<a.at&&o.level>=a.at).map(a=>a.at)}}function Ja(e,t){let r=e.biz[t];if(!r||r.manager||r.level<=0)return false;let o=To(e,r);return e.cash<o?false:(e.cash-=o,r.manager=true,r.ready&&(r.ready=false,r.progress=0,$s(e,Tr(e,r))),true)}var $s=(e,t)=>{e.cash+=t,e.earned+=t;};function ei(e,t){let r=e.biz[t];if(!r||!r.ready)return 0;r.ready=false,r.progress=0;let o=Tr(e,r);return $s(e,o),o}function ti(e,t){let r=e.biz[t];return !r||r.broken<=0?false:(r.broken--,r.broken===0)}function dc(e,t){let r=0;for(let o of e.biz)o.level<=0||o.broken>0||(r+=Tr(e,o)*t);return $s(e,r),r}var fc=(e,t)=>$s(e,t);function ri(e,t){let r=e.timed.findIndex(o=>o.id===t.id);r>=0&&e.timed.splice(r,1),e.timed.push(t);}function ni(e,t){let r=[],o=[];e.biz.forEach((n,s)=>{if(n.rush>0&&(n.rush=Math.max(0,n.rush-t)),!(n.level<=0||n.ready||n.broken>0)&&(n.progress+=t/kn(e,n),!(n.progress<1)))if(n.manager){let a=Math.floor(n.progress);n.progress-=a;let i=Tr(e,n)*a;$s(e,i),o.push({index:s,amount:i});}else n.progress=1,n.ready=true,r.push(s);});for(let n=e.timed.length-1;n>=0;n--){let s=e.timed[n];s.left-=t,s.left<=0&&e.timed.splice(n,1);}return {ready:r,paid:o}}function pc(e){let t=[],r=e.biz.reduce((o,n)=>Math.max(o,n.def.cost),0);for(let o of Fa)o.scope==="all"?t.push({key:o.id,def:o,index:-1,price:Math.ceil(r*o.price*xs(e))}):e.biz.forEach((n,s)=>t.push({key:`${o.id}:${n.def.id}`,def:o,index:s,price:Math.ceil(n.def.cost*o.price*xs(e))}));return t}function oi(e,t=3){return pc(e).filter(r=>!e.bought.has(r.key)&&(r.index<0?(e.biz[0]?.level??0)>=r.def.after:(e.biz[r.index]?.level??0)>=r.def.after)).sort((r,o)=>r.price-o.price).slice(0,t)}function si(e,t){let r=pc(e).find(o=>o.key===t);return !r||e.bought.has(t)||e.cash<r.price?false:(e.cash-=r.price,e.bought.add(t),r.index<0?e.allMult*=r.def.mult:e.biz[r.index].mult*=r.def.mult,true)}var ai=e=>e.biz.filter(t=>t.manager).length;function on(e,t){if(t.kind==="cash")return Math.min(1,e.earned/Math.max(1,t.n));if(t.kind==="managers")return Math.min(1,ai(e)/Math.max(1,t.n));let r=e.biz.find(o=>o.def.id===t.biz);return Math.min(1,(r?.level??0)/Math.max(1,t.n))}var Ms=(e,t)=>t.every(r=>on(e,r)>=1),ii=(e,t)=>t.length?t.reduce((r,o)=>r+on(e,o),0)/t.length:1,lc=(e,t)=>t.manager?1:kn(e,t)/(kn(e,t)+1.2);function li(e,t){let r=e.biz.findIndex(x=>x.broken>0);if(r>=0)return {kind:"fix",index:r};let o=null,n=Qa(e),s=(x,D,O)=>{if(O>e.cash+n*8)return;let N=D/Math.max(1,O);(!o||N>o.value)&&(o={move:x,value:N,price:O});},a=x=>t.some(D=>D.kind==="level"&&D.biz===x&&on(e,D)<1),i=t.some(x=>x.kind==="managers"&&on(e,x)<1),h=t.some(x=>x.kind==="cash"&&on(e,x)<1);e.biz.forEach((x,D)=>{let O=Za(e,x)*lc(e,x),N={...x,level:x.level+1},ne=(Tr(e,N)/kn(e,N)*lc(e,N)-O)*(x.level===0?3:1)*(a(x.def.id)?3:1);s({kind:"buy",index:D},ne+(a(x.def.id)&&!h?n*.05:0),vn(e,x)),x.level>0&&!x.manager&&s({kind:"hire",index:D},Za(e,x)*(1-lc(e,x))*1.6*(i?3:1)+(i?n*.05:0),To(e,x));});for(let x of oi(e,6)){let D=x.index<0?n*(x.def.mult-1):Za(e,e.biz[x.index])*(x.def.mult-1);s({kind:"upgrade",key:x.key},D,x.price);}let m=e.biz.map((x,D)=>({b:x,i:D})).filter(x=>x.b.ready).sort((x,D)=>Tr(e,D.b)-Tr(e,x.b))[0],v=o;return v&&v.price<=e.cash?v.move:m?{kind:"collect",index:m.i}:null}function _f(e,t){return t?t.kind==="collect"?ei(e,t.index)>0:t.kind==="buy"?Ya(e,t.index).ok:t.kind==="hire"?Ja(e,t.index):t.kind==="fix"?ti(e,t.index)||true:si(e,t.key):false}function Rf(e,t={}){let r=ks(e,t.mods),o=.05,n=t.tapEvery??.4,s=t.max??900,a=0,i=0;for(;a<s;){if(Ms(r,e.goals))return a;if(ni(r,o),a+=o,a>=i){let h=li(r,e.goals);h&&(_f(r,h),i=a+n);}}return 1/0}var Sf=new Map;function ci(e){let t=Sf.get(e);return t===void 0&&(t=Rf(jn[e-1]),Sf.set(e,t)),t}function Do(e,t=.5){let r=Math.max(1,Math.min(Lo,Math.floor(e))),o=jn[r-1],n=Math.ceil(r/Ao),s=r-(n-1)*Ao,a=ci(r),i=(1.6-(n-1)*.08-s*.01)*(1.1-t*.2)*(o.extra??1),h=Math.max(45,Math.min(600,Math.ceil((Number.isFinite(a)?a:400)*i/5)*5));return {level:r,world:n,index:s,def:o,boss:o.vip===true,day:h,cash:Lf(o),coins:wf(r,o.vip===true),firstClearGold:sc(r,o.vip===true)}}var ku=ve("tycoon.part"),hc=ve("tycoon.manager"),Oo=(e,t)=>{let r=Number(e.vars[t]??0);return Number.isFinite(r)?r:0},vr=e=>{let t=Math.abs(e);for(let[r,o]of [[1e12,"T"],[1e9,"B"],[1e6,"M"],[1e3,"K"]])if(t>=r)return `${(e/r).toFixed(t>=r*100?0:1).replace(/\.0$/,"")}${o}`;return String(Math.floor(e))},Af=new WeakMap,Tf=e=>Af.get(e),ws=[1,10,0],di={id:"tycoon",version:2,engines:["phaser"],requires:["round"],params:{difficulty:{type:"number",default:.5,min:0,max:1},coinReward:{type:"number",default:1,min:0,max:10}},setup({world:e,params:t,mode:r}){let o=c=>yr(t,c),n=e.rng.stream("tycoon"),s=Sr(r,"events",_o.map(c=>c.id)),a=Do(1,o("difficulty")),i=ks(a.def),h=new Map,m=new Map,v=null,x=[],D=0,O=0,N=0,q=0,ne=0,Z=false,ye=false,be=0,fe=null,Ee=null,de=null,Ae=()=>Ro.find(c=>c.id===e.vars["meta:hero"])??Ro[0],Pe=()=>qa(Ae().skill),we=()=>e.vars.reviving===true,ce=()=>a.def.goals,ke=()=>{let c=Be(e);return {...c,U:Math.min(c.w,c.h)}},Le=c=>{let p=ke(),k=Math.max(1,i.biz.length),_=p.h*.25,C=p.h*.81,z=Math.max(6,p.h*.012),B=Math.min((C-_-z*(k-1))/k,150,p.w*.26),ae=Math.min(p.w*.96,660),pe=_+(C-_-(k*B+(k-1)*z))/2;return {x:p.w/2,y:pe+c*(B+z)+B/2,w:ae,h:B}},_e=c=>{let p=Le(c);return {x:p.x-p.w/2+p.h*.56,y:p.y,size:p.h*.9}},oe=()=>ke().h*.9,Te=()=>{let c=ke();return Math.min(c.U*.075,c.h*.055)},Ke=()=>{let c=ke(),p=Ee?1-Ee.left/Ee.def.ttl:0;return {x:-c.w*.05+p*c.w*1.1,y:c.h*.21,r:c.U*.06}},Ne=new Set,se=(c,p,k,_,C=1)=>{Ne.add(c);let z=h.get(c);(z===void 0||!e.isAlive(z))&&(z=e.create(),e.set(z,ku,{id:c}),h.set(c,z)),e.set(z,F,{x:p,y:k,scale:C}),e.set(z,le,_);},Ie=()=>{for(let[c,p]of [...h])Ne.has(c)||(e.destroy(p),h.delete(c));},$e=(c,p,k,_,C,z,B=70)=>se(c,p,k,{shape:"text",text:_,size:Math.max(9,Math.round(z)),color:C,bold:true,depth:B}),Se=(c,p,k,_,C,z,B,ae=2)=>{se(`${c}:bg`,p,k,{shape:"rect",w:_+4,h:C+4,color:"#000000",alpha:.4,radius:(C+4)/2,depth:ae});let pe=Math.max(1,_*Math.max(0,Math.min(1,z)));se(`${c}:fill`,p-_/2+pe/2,k,{shape:"rect",w:pe,h:C,color:B,radius:C/2,depth:ae+.1});},Ye=c=>x.push(c),ee=c=>{let p=i.biz[c],k=ws[ne]??1;return k===0?Math.max(1,cc(i,p)):k},Re=()=>{i.biz.forEach((c,p)=>{let k=Le(p),_=_e(p),C=c.level>0,z=c.def.color;se(`r${p}`,k.x,k.y,{shape:"sprite",art:"panel",w:k.w,h:k.h,color:"panel",depth:0}),c.rush>0&&se(`r${p}:rush`,_.x,_.y,{shape:"circle",r:_.size*.55,color:"coin",alpha:.35+.2*Math.sin(e.time*8),depth:.5});let B=c.ready?1+.06*Math.abs(Math.sin(e.time*6)):1;se(`r${p}:b`,_.x,_.y,{shape:"sprite",art:c.def.art,w:_.size,h:_.size,color:z,alpha:C?c.broken>0?.55:1:.35,depth:1},B),Ye({id:`biz${p}`,x:_.x,y:_.y,w:_.size,h:_.size});let ae=k.x-k.w*.12,pe=k.h*.2,Me=vs(c.level);if($e(`r${p}:lv`,ae,k.y-k.h*.26,C?`Lv ${c.level}${Me.next?`/${Me.next}`:""}`:"Lv 0","text",pe,2),C){$e(`r${p}:inc`,ae,k.y+k.h*0,`+${vr(Tr(i,c))}`,"coin",pe*.95,2);let l=c.ready||kn(i,c)<=.15&&c.manager?1:c.progress;Se(`r${p}:bar`,ae,k.y+k.h*.28,k.w*.3,Math.max(6,k.h*.12),l,c.broken>0?"danger":z),c.ready&&!c.manager&&$e(`r${p}:ok`,_.x+_.size*.36,_.y+_.size*.34,"$","coin",_.size*.3,3);}if(fe?.index===p){let l=1+.12*Math.sin(e.time*9);se(`r${p}:ev`,_.x+_.size*.32,_.y-_.size*.3,{shape:"sprite",art:fe.def.art,w:_.size*.5,h:_.size*.5,depth:4},l);}else c.broken>0&&(se(`r${p}:ev`,_.x+_.size*.3,_.y-_.size*.28,{shape:"sprite",art:"ty_wrench",w:_.size*.48,h:_.size*.48,depth:4},1+.08*Math.sin(e.time*10)),$e(`r${p}:evn`,_.x+_.size*.3,_.y+_.size*.05,String(c.broken),"danger",_.size*.26,4.1));let qe=k.x+k.w*.13,tt=k.h*.27;if(C&&!c.manager){let l=To(i,c),w=i.cash>=l;se(`r${p}:m:bg`,qe,k.y-k.h*.08,{shape:"circle",r:tt,color:w?"secondary":"panel",alpha:w?.95:.7,depth:1}),se(`r${p}:m`,qe,k.y-k.h*.08,{shape:"sprite",art:"ty_manager",w:tt*1.7,h:tt*1.7,alpha:w?1:.5,depth:1.2}),$e(`r${p}:m:p`,qe,k.y+k.h*.32,vr(l),w?"text":"muted",pe*.8,2),Ye({id:`mgr${p}`,x:qe,y:k.y,w:tt*2.2,h:k.h*.9});}let pt=k.x+k.w/2-k.w*.14,re=k.w*.25,j=k.h*.72,J=ee(p),Y=vn(i,c,J),M=i.cash>=Y;se(`r${p}:buy`,pt,k.y,{shape:"sprite",art:"button",w:re,h:j,color:M?"accent":"panel",alpha:M?1:.6,depth:1}),$e(`r${p}:buy:n`,pt,k.y-j*.2,C?`+${J}`:"OPEN","text",pe*.9,2),se(`r${p}:buy:c`,pt-re*.3,k.y+j*.2,{shape:"sprite",art:"coin",w:pe*.8,h:pe*.8,depth:2}),$e(`r${p}:buy:p`,pt+re*.08,k.y+j*.2,vr(Y),M?"coin":"muted",pe*.85,2),Ye({id:`buy${p}`,x:pt,y:k.y,w:re,h:j});let E=m.get(p);if(c.manager&&(E===void 0||!e.isAlive(E))&&(E=e.create(),e.set(E,hc,{index:p}),e.set(E,le,{shape:"actor",cast:"helper",variant:p*13+5,h:k.h*.78,pose:"idle",facing:1,depth:2}),m.set(p,E)),E!==void 0&&e.isAlive(E)){e.set(E,F,{x:qe,y:k.y+k.h*.02});let l=e.need(E,le);l.shape==="actor"&&(l.h=k.h*.78);}});},rt=c=>c.kind==="cash"?"coin":c.kind==="managers"?"ty_manager":Wn(c.biz??"")?.art??"biz1",ht=c=>c.kind==="cash"?i.earned:c.kind==="managers"?ai(i):i.biz.find(p=>p.def.id===c.biz)?.level??0,De=()=>{let c=ke(),p=c.U,k=c.h*.09;se("h:t:i",c.w*.09,k,{shape:"sprite",art:"hourglass",w:p*.06,h:p*.06,depth:70}),$e("h:t",c.w*.09+p*.09,k,Vs(D),D<=15?"danger":"text",p*.05),se("h:c:i",c.w*.42,k,{shape:"sprite",art:"coin",w:p*.07,h:p*.07,depth:70}),$e("h:c",c.w*.42+p*.13,k,vr(i.cash),"coin",p*.065);let _=p*.17;se("h:mode",c.w*.88,k,{shape:"sprite",art:"button",w:_,h:p*.08,color:"secondary",depth:70}),$e("h:mode:t",c.w*.88,k,ws[ne]===0?"MAX":`\xD7${ws[ne]}`,"text",p*.042,70.1),Ye({id:"mode",x:c.w*.88,y:k,w:_,h:p*.09});let C=ce(),z=Math.min(c.w*.3,230),B=Math.max(30,c.h*.05),ae=c.h*.15;if(C.forEach((re,j)=>{let J=c.w/2+(j-(C.length-1)/2)*(z+p*.02),Y=on(i,re)>=1;se(`h:g${j}`,J,ae,{shape:"sprite",art:"panel",w:z,h:B,color:Y?"accent":"panel",depth:70}),se(`h:g${j}:i`,J-z*.36,ae-B*.06,{shape:"sprite",art:rt(re),w:B*.75,h:B*.75,depth:70.1});let M=ht(re),E=Y?"\u2713":re.kind==="cash"?`${vr(M)}/${vr(re.n)}`:re.kind==="level"?`Lv ${M}/${re.n}`:`${M}/${re.n}`;$e(`h:g${j}:t`,J+z*.1,ae-B*.08,E,"text",B*.36,70.1),Se(`h:g${j}:bar`,J+z*.1,ae+B*.3,z*.62,Math.max(4,B*.1),on(i,re),Y?"accent":"coin",70.1);}),i.timed.forEach((re,j)=>{let J=c.w*.9-j*p*.16,Y=re.id==="sale"?"ty_sk_sale":re.id==="invest"?"ty_investor":Pe().art;se(`h:tm${j}`,J-p*.04,c.h*.205,{shape:"sprite",art:Y,w:p*.06,h:p*.06,depth:70}),$e(`h:tm${j}:t`,J+p*.035,c.h*.205,`${Math.ceil(re.left)}`,"secondary",p*.04);}),Ee){let re=Ke();se("h:courier",re.x,re.y+Math.sin(e.time*10)*re.r*.08,{shape:"sprite",art:Ee.def.art,w:re.r*2,h:re.r*2,depth:72}),Ye({id:"courier",x:re.x,y:re.y,w:re.r*2.6,h:re.r*2.6});}let pe=oe(),Me=Te(),qe=c.w*.25,tt=q>=Pe().charge;tt&&se("h:sk:glow",qe,pe,{shape:"circle",r:Me*1.28,color:"secondary",alpha:.5+.3*Math.sin(e.time*7),depth:68.9}),se("h:sk:bg",qe,pe,{shape:"circle",r:Me,color:"panel",alpha:.95,depth:69}),se("h:sk",qe,pe,{shape:"sprite",art:Pe().art,w:Me*1.4,h:Me*1.4,alpha:tt?1:.45,depth:69.2}),Se("h:charge",qe,pe+Me*1.3,Me*2,Math.max(5,Me*.2),q/Pe().charge,"secondary",69),Ye({id:"skill",x:qe,y:pe,w:Me*2.4,h:Me*2.4}),oi(i,3).forEach((re,j)=>{let J=c.w*(.47+j*.18),Y=i.cash>=re.price;se(`h:u${j}:bg`,J,pe,{shape:"circle",r:Me,color:Y?"accent":"panel",alpha:Y?.95:.7,depth:69}),se(`h:u${j}`,J,pe-Me*.08,{shape:"sprite",art:re.def.art,w:Me*1.5,h:Me*1.5,alpha:Y?1:.55,depth:69.2});let M=re.index>=0?i.biz[re.index]:void 0;M&&se(`h:u${j}:b`,J+Me*.7,pe-Me*.6,{shape:"sprite",art:M.def.art,w:Me*.9,h:Me*.9,color:M.def.color,depth:69.3}),$e(`h:u${j}:p`,J,pe+Me*1.3,vr(re.price),Y?"coin":"muted",Me*.42,69.3),Ye({id:`up:${re.key}`,x:J,y:pe,w:Me*2.3,h:Me*2.6});}),(v===null||!e.isAlive(v))&&(v=e.create(),e.set(v,le,{shape:"actor",cast:Ae().cast,h:Me*2.6,pose:"idle",facing:1,depth:20})),e.set(v,F,{x:c.w*.09,y:pe-Me*.1});let pt=e.need(v,le);if(pt.shape==="actor"&&(pt.h=Me*2.6),de){let re=Math.min(c.w*.86,500),j=re*.42,J=c.w/2,Y=c.h*.5;se("h:inv:dim",J,Y,{shape:"rect",w:c.w,h:c.h,color:"#000000",alpha:.35,depth:79}),se("h:inv",J,Y,{shape:"sprite",art:"panel",w:re,h:j,color:"panel",depth:80}),se("h:inv:i",J-re*.34,Y,{shape:"sprite",art:de.def.art,w:j*.62,h:j*.62,depth:80.1});let M=re*.3,E=j*.5,l=ft();se("h:inv:a",J+re*.02,Y-j*.04,{shape:"sprite",art:"button",w:M,h:E,color:"accent",depth:80.1}),se("h:inv:a:c",J+re*.02-M*.28,Y-j*.04,{shape:"sprite",art:"coin",w:E*.4,h:E*.4,depth:80.2}),$e("h:inv:a:t",J+re*.02+M*.1,Y-j*.04,vr(l),"coin",E*.3,80.2),se("h:inv:b",J+re*.33,Y-j*.04,{shape:"sprite",art:"button",w:M,h:E,color:"secondary",depth:80.1}),$e("h:inv:b:t",J+re*.33,Y-j*.04,`\xD7${de.def.mult??2} ${de.def.seconds??30}s`,"text",E*.28,80.2),Se("h:inv:bar",J+re*.17,Y+j*.32,re*.6,Math.max(4,j*.05),de.left/de.def.ttl,"coin",80.1),Ye({id:"inv_now",x:J+re*.02,y:Y-j*.04,w:M,h:E}),Ye({id:"inv_share",x:J+re*.33,y:Y-j*.04,w:M,h:E});}},Qt=()=>{x=[],Ne.clear(),Re(),De(),Ie(),e.vars.ty_buttons=x.map(c=>`${c.id}@${Math.round(c.x)},${Math.round(c.y)}`).join(";");},Xe=()=>{e.vars.cash=Math.floor(i.cash),e.vars.earned=Math.floor(i.earned),e.vars.time_left=D,e.vars.ty_charge=Math.floor(q),e.vars.ty_mode=ws[ne]??1,e.vars.level_progress=ii(i,ce()),e.vars.ty_goals=ce().map(c=>`${c.kind}:${Math.floor(ht(c))}/${c.n}`).join("|");},et=()=>{for(let p of [...h.values(),...m.values()])e.isAlive(p)&&e.destroy(p);h.clear(),m.clear(),v!==null&&e.isAlive(v)&&e.destroy(v),v=null,a=Do(Oo(e,"meta:chapter")||1,o("difficulty"));let c={income:Oo(e,"meta:income"),speed:Oo(e,"meta:speed"),discount:Oo(e,"meta:discount")};i=ks(a.def,c,Math.round(a.cash*(1+Oo(e,"meta:cash")))),Af.set(e,{s:i,level:a}),Bt(e,"board",Be(e).h*.24),D=a.day,O=0,N=0,q=0,Z=false,ye=false,be=8+n.range(0,4),fe=null,Ee=null,de=null,e.vars.ty_level=a.level,e.vars.ty_world=a.world,e.vars.coins=0,e.vars.score=0,e.vars.stars=0,e.vars.reviving=false,Xe();},it=c=>{if(ye)return;ye=true;let p=c==="cleared",k=ii(i,ce()),_=p?Math.min(Z?1:3,Ua(D/Math.max(1,a.day))):0,C=Math.round(a.coins*o("coinReward")*(p?[1,1,1.25,1.5][_]:k*.5));C>0&&(Qe(e,"coins",C),e.emit("coin-collected",{value:C})),p&&e.vars["meta:first_clear"]===true&&Qe(e,"coins",a.firstClearGold),e.vars.stars=_,e.vars.score=Math.round(k*1e3)+(p?_*500+Math.floor(D)*10:0),e.vars.reviving=false,fe=null,Ee=null,de=null,Xe(),e.emit(Ut,{reason:c,stats:{chapter:a.level,seconds:Math.floor(O),cleared:p,stars:_,coins:Number(e.vars.coins??0),earned:Math.floor(i.earned),managers:ai(i)}});},dt=()=>{ye||(K(e,{kind:"flash",color:"coin"}),it("cleared"));},mt=()=>{if(e.vars.revive_ready===true&&!Z){e.vars.reviving=true,e.emit(er,{});return}it("out-of-time");},yt=()=>{we()&&(Z=true,e.vars.reviving=false,D+=Xa,K(e,{kind:"flash",color:"coin"}),Xe());},gt=()=>Math.max(Qa(i),a.cash*.05),ft=()=>Math.round(gt()*(de?.def.now??25)),ze=c=>{q=Math.min(Pe().charge,q+vf),e.emit("event-handled",{id:c});},Et=()=>{let c=i.biz.map((B,ae)=>({b:B,i:ae})).filter(B=>B.b.level>0&&B.b.broken===0),p=B=>B.effect==="rush"?!fe&&c.some(ae=>ae.b.rush<=0):B.effect==="break"?!i.biz.some(ae=>ae.broken>0)&&c.some(ae=>ae.b.level>=3):B.effect==="invest"?!de:!Ee,k=a.def.events.filter(B=>s.includes(B)).map(B=>_o.find(ae=>ae.id===B)).filter(B=>!!B&&p(B));if(!k.length)return;let _=k.reduce((B,ae)=>B+ae.weight,0),C=n.range(0,_),z=k.find(B=>(C-=B.weight)<0)??k[0];if(z.effect==="rush"){let B=c.filter(ae=>ae.b.rush<=0);fe={index:B[n.int(0,B.length-1)].i,left:z.ttl,def:z};}else if(z.effect==="break"){let B=c.filter(pe=>pe.b.level>=3),ae=B[n.int(0,B.length-1)];ae.b.broken=z.taps??3,K(e,{kind:"shake",power:.3});}else z.effect==="invest"?de={left:z.ttl,def:z}:Ee={left:z.ttl,def:z};e.emit("event-started",{id:z.id});},Ze=c=>{fe&&(fe.left-=c)<=0&&(fe=null),Ee&&(Ee.left-=c)<=0&&(Ee=null),de&&(de.left-=c)<=0&&(de=null),a.def.events.length&&(be-=c,be<=0&&(Et(),be=n.range(tc[0],tc[1])));},Wt=c=>{let p=i.biz[c];if(!p||p.level<=0)return;let k=_e(c);if(p.broken>0){K(e,{kind:"burst",x:k.x,y:k.y,color:"ground",n:6,size:k.size*.6}),ti(i,c)&&(K(e,{kind:"ring",x:k.x,y:k.y,color:"accent",size:k.size*1.2}),ze("break"));return}fe?.index===c&&(p.rush=fe.def.seconds??10,p.rushMult=fe.def.mult??3,K(e,{kind:"ring",x:k.x,y:k.y,color:"coin",size:k.size*1.4}),K(e,{kind:"pop",x:k.x,y:k.y-k.size*.45,text:`\xD7${p.rushMult}`,color:"coin",size:Math.round(k.size*.3)}),fe=null,ze("rush"));let _=ei(i,c);_<=0||(q=Math.min(Pe().charge,q+kf),Lt(e,"tycoon-collect"),K(e,{kind:"burst",x:k.x,y:k.y,color:"coin",n:8,size:k.size*.7}),K(e,{kind:"pop",x:k.x,y:k.y-k.size*.35,text:`+${vr(_)}`,color:"coin",size:Math.round(k.size*.24)}),e.emit("cycle-collected",{index:c,amount:_}));},hr=c=>{let p=i.biz[c];if(!p)return;let k=Ya(i,c,ee(c)),_=Le(c),C=_.x+_.w/2-_.w*.14;if(!k.ok){K(e,{kind:"shake",power:.1});return}Lt(e,"tycoon-buy");let z=_e(c);K(e,{kind:"ring",x:z.x,y:z.y,color:"coin",size:z.size*1.1}),K(e,{kind:"burst",x:C,y:_.y,color:"accent",n:5,size:_.h*.5}),e.emit("business-bought",{id:p.def.id,level:p.level});for(let B of k.milestones)K(e,{kind:"flash",color:"coin"}),K(e,{kind:"pop",x:z.x,y:z.y-z.size*.5,text:`\u2605 ${B}`,color:"coin",size:Math.round(z.size*.3)}),e.emit("milestone",{id:p.def.id,at:B});},Nt=c=>{let p=i.biz[c];if(!p||!Ja(i,c))return;Lt(e,"tycoon-manager");let k=_e(c);K(e,{kind:"ring",x:k.x,y:k.y,color:"secondary",size:k.size*1.3}),K(e,{kind:"pop",x:k.x,y:k.y-k.size*.5,text:"\u2605",color:"secondary",size:Math.round(k.size*.35)}),e.emit("manager-hired",{id:p.def.id});},ur=(c,p,k)=>{si(i,c)&&(Lt(e,"tycoon-upgrade"),K(e,{kind:"ring",x:p,y:k,color:"accent",size:Te()*2.6}),K(e,{kind:"flash",color:"accent"}),e.emit("upgrade-bought",{key:c}));},Tt=()=>{let c=Pe();if(q<c.charge)return false;let p=1+Oo(e,"meta:skill");if(q=0,v!==null&&Ge(e,v,"cheer"),K(e,{kind:"flash",color:"secondary"}),c.effect==="rush")ri(i,{id:"skill",left:(c.seconds??12)*p,income:c.mult??5,price:1});else if(c.effect==="sale")ri(i,{id:"sale",left:(c.seconds??15)*p,income:1,price:c.mult??.5});else {let k=dc(i,Math.max(1,Math.round((c.cycles??8)*p))),_=ke();K(e,{kind:"pop",x:_.w/2,y:_.h*.16,text:`+${vr(k)}`,color:"coin",size:Math.round(_.U*.07)}),i.biz.forEach((C,z)=>{if(C.level<=0)return;let B=_e(z);K(e,{kind:"burst",x:B.x,y:B.y,color:"coin",n:10,size:B.size*.8});});}return e.emit("skill-cast",{id:c.id}),Lt(e,"tycoon-skill"),true},T=()=>{if(!Ee)return;let c=Ke(),p=Math.round(gt()*(Ee.def.now??15));fc(i,p);let k=Math.round((Ee.def.coins??0)*o("coinReward"));k>0&&(Qe(e,"coins",k),e.emit("coin-collected",{value:k})),K(e,{kind:"burst",x:c.x,y:c.y,color:"coin",n:14,size:c.r*2}),K(e,{kind:"pop",x:c.x,y:c.y+c.r*1.4,text:`+${vr(p)}`,color:"coin",size:Math.round(c.r*.7)}),Ee=null,ze("courier");},H=c=>{if(!de)return;let p=de.def;c?ri(i,{id:"invest",left:p.seconds??30,income:p.mult??2,price:1}):fc(i,ft()),de=null,K(e,{kind:"flash",color:"coin"}),ze("invest");},u=(c,p,k)=>x.find(_=>(!k||_.id.startsWith(k))&&Math.abs(c-_.x)<=_.w/2&&Math.abs(p-_.y)<=_.h/2);e.on(zt,c=>{let p=c;if(p.type!=="tap"||!ot(e)||hn(e)||ye||we())return;Ht(e),N=0;let k=de?u(p.x,p.y,"inv_")??u(p.x,p.y):u(p.x,p.y,"courier")??u(p.x,p.y);k&&(k.id==="inv_now"?H(false):k.id==="inv_share"?H(true):k.id==="courier"?T():k.id==="mode"?ne=(ne+1)%ws.length:k.id==="skill"?Tt():k.id.startsWith("up:")?ur(k.id.slice(3),k.x,k.y):k.id.startsWith("biz")?Wt(Number(k.id.slice(3))):k.id.startsWith("buy")?hr(Number(k.id.slice(3))):k.id.startsWith("mgr")&&Nt(Number(k.id.slice(3))),Xe(),Ms(i,ce())&&dt());}),e.on(qt,()=>{et(),e.vars.level=a.level;}),e.on(Zt,et),e.on(tr,yt),e.on(rr,()=>{we()&&(e.vars.reviving=false,it("out-of-time"));}),e.on(Xt,c=>{Ne.clear(),Ie(),x=[],e.vars.ty_buttons="",v!==null&&e.isAlive(v)&&at(e,v,c.reason==="cleared"?"dance":"idle");}),e.on(Ft,()=>Bt(e,"board",Be(e).h*.24));let f=c=>{if(!c)return;let p=c.kind==="collect"||c.kind==="fix"?`biz${c.index}`:c.kind==="buy"?`buy${c.index}`:c.kind==="hire"?`mgr${c.index}`:`up:${c.key}`;return x.find(k=>k.id===p)},b=c=>{let p=ke().U,k=i.biz.findIndex(_=>_.ready);if(!vt(c,"tycoon-collect")&&k>=0){let _=_e(k);return kt(c,"tap",_,void 0,_.size*.8)}if(!vt(c,"tycoon-buy")){let _=i.biz.findIndex(z=>i.cash>=vn(i,z,ee(i.biz.indexOf(z)))),C=x.find(z=>z.id===`buy${_}`);if(_>=0&&C)return kt(c,"tap",C,void 0,C.h)}if(!vt(c,"tycoon-manager")){let _=i.biz.findIndex(z=>z.level>0&&!z.manager&&i.cash>=To(i,z)),C=x.find(z=>z.id===`mgr${_}`);if(_>=0&&C)return kt(c,"tap",C,void 0,C.w)}if(q>=Pe().charge&&!vt(c,"tycoon-skill")){let _=x.find(C=>C.id==="skill");if(_)return kt(c,"tap",_,void 0,_.w)}if(N>6){let _=f(li(i,ce()));_&&kt(c,"tap",_,void 0,Math.min(_.w,p*.18));}};e.addSystem({id:"tycoon",order:0,run(c,p){if(!(!ot(c)||ye)){if(!we()){O+=p,N+=p,D=Math.max(0,D-p);for(let k of ni(i,p).paid)k.amount<=0||c.emit("cycle-collected",{index:k.index,amount:k.amount});q=Math.min(Pe().charge,q+p),Ze(p);}if(Qt(),Xe(),!we()){if(Ms(i,ce()))return dt();_r(c)||b(c),D<=0&&mt();}}}}),et();}};var sn=(e,t,r,o,n,s,a,i,h)=>({en:e,ru:t,kz:r,zh:o,ko:n,ja:s,hi:a,pt:i,de:h}),fi=sn("Score","\u041E\u0447\u043A\u0438","\u04B0\u043F\u0430\u0439","\u5206\u6570","\uC810\uC218","\u30B9\u30B3\u30A2","\u0938\u094D\u0915\u094B\u0930","Pontos","Punkte"),mc={id:"fantasy",version:1,setting:"fantasy",names:sn("Fantasy","\u0424\u044D\u043D\u0442\u0435\u0437\u0438","\u0424\u044D\u043D\u0442\u0435\u0437\u0438","\u5947\u5E7B","\uD310\uD0C0\uC9C0","\u30D5\u30A1\u30F3\u30BF\u30B8\u30FC","\u092B\u093C\u0948\u0902\u091F\u0947\u0938\u0940","Fantasia","Fantasy"),palette:{background:"#1f2a1d",ground:"#3b4a2e",lane:"#56683f",primary:"#4fa3e0",secondary:"#8e5bd1",danger:"#d0483b",coin:"#f2c14e",accent:"#6fbf4a",text:"#fff6e0",muted:"#b9b08f",piece1:"#e0443e",piece2:"#3f7fe0",piece3:"#43b05c",piece4:"#f2c14e",piece5:"#9b59d0",piece6:"#ef8a2f",panel:"#3a2f25"},texts:{"res.coins":sn("Gold","\u0417\u043E\u043B\u043E\u0442\u043E","\u0410\u043B\u0442\u044B\u043D","\u91D1\u5E01","\uACE8\uB4DC","\u30B4\u30FC\u30EB\u30C9","\u0938\u094B\u0928\u093E","Ouro","Gold"),"res.score":fi},races:["human","elf","dwarf","orc","undead"],cast:{hero:{preset:"knight",races:["human"]},foe:{preset:"berserker",parts:{Hat:null,Offhand:null,Weapon:"weapon/battle_axe"},races:["orc"]},foe2:{preset:"viking",parts:{Weapon:"weapon/double_axe"},races:["orc"]},boss:{preset:"dark_knight",races:["orc"]},helper:{preset:"hunter",parts:{Weapon:null,Hat:null},races:["elf","dwarf","human"]},foe3:{preset:"crossbowman",parts:{Weapon:"weapon/crossbow"},races:["undead"]},foe4:{preset:"lumberjack",parts:{Weapon:"weapon/spear",Back:null},races:["undead"]},foe5:{preset:"hunter",parts:{Hat:null,Back:null,Weapon:"weapon/dagger"},races:["undead"]},hero2:{preset:"crusader",races:["human","dwarf"]},hero3:{preset:"archmage",races:["elf"]}}},yc={id:"sci-fi",version:1,setting:"sci-fi",names:sn("Sci-fi","\u041D\u0430\u0443\u0447\u043D\u0430\u044F \u0444\u0430\u043D\u0442\u0430\u0441\u0442\u0438\u043A\u0430","\u0492\u044B\u043B\u044B\u043C\u0438 \u0444\u0430\u043D\u0442\u0430\u0441\u0442\u0438\u043A\u0430","\u79D1\u5E7B","SF","SF","\u0935\u093F\u091C\u094D\u091E\u093E\u0928 \u0915\u0925\u093E","Fic\xE7\xE3o cient\xEDfica","Science-Fiction"),palette:{background:"#0b1020",ground:"#151d33",lane:"#22305a",primary:"#36e3ff",secondary:"#b45cff",danger:"#ff3d6e",coin:"#ffe14d",accent:"#3dff9a",text:"#e8f6ff",muted:"#7d8fb3",piece1:"#ff3d6e",piece2:"#36a3ff",piece3:"#3dff9a",piece4:"#ffe14d",piece5:"#b45cff",piece6:"#ff8f3d",panel:"#18213d"},texts:{"res.coins":sn("Chips","\u0427\u0438\u043F\u044B","\u0427\u0438\u043F\u0442\u0435\u0440","\u82AF\u7247","\uCE69","\u30C1\u30C3\u30D7","\u091A\u093F\u092A\u094D\u0938","Chips","Chips"),"res.score":fi},races:["human"],cast:{hero:{preset:"soldier",races:["human"]},foe:{preset:"soldier",parts:{Hat:"hat/great_helm",Weapon:"weapon/pistol"},races:["undead"]},foe2:{preset:"gunslinger",parts:{Weapon:"weapon/rifle",Back:null},races:["orc"]},boss:{preset:"dark_knight",parts:{Weapon:"weapon/flame_sword"},races:["orc"]},helper:{preset:"gunslinger",parts:{Weapon:null,Back:null},races:["elf","human"]},foe3:{preset:"gunslinger",parts:{Weapon:"weapon/pistol",Back:null},races:["undead"]},foe4:{preset:"soldier",parts:{Hat:"hat/great_helm",Weapon:"weapon/spear"},races:["orc"]},foe5:{preset:"soldier",parts:{Hat:null,Back:null,Weapon:"weapon/dagger"},races:["undead"]},hero2:{preset:"musketeer",parts:{Weapon:"weapon/rifle"},races:["human"]},hero3:{preset:"archmage",parts:{Weapon:"weapon/wizard_staff"},races:["elf","human"]}}},gc={id:"cozy",version:1,setting:"cozy",names:sn("Cozy cartoon","\u0423\u044E\u0442\u043D\u044B\u0439 \u043C\u0443\u043B\u044C\u0442\u044F\u0448\u043D\u044B\u0439","\u0416\u0430\u0439\u043B\u044B \u043C\u0443\u043B\u044C\u0442\u0444\u0438\u043B\u044C\u043C","\u6E29\u99A8\u5361\u901A","\uC544\uB291\uD55C \uCE74\uD230","\u307B\u306E\u307C\u306E\u30AB\u30FC\u30C8\u30A5\u30FC\u30F3","\u0906\u0930\u093E\u092E\u0926\u093E\u092F\u0915 \u0915\u093E\u0930\u094D\u091F\u0942\u0928","Cartoon aconchegante","Gem\xFCtlicher Cartoon"),palette:{background:"#fdf1e4",ground:"#f3d9bf",lane:"#e9c6a3",primary:"#ff8fab",secondary:"#8fb8ff",danger:"#ff6b6b",coin:"#ffb627",accent:"#7ccf8a",text:"#3d2b25",muted:"#9c8478",piece1:"#ff8fab",piece2:"#7fb8ff",piece3:"#8cd98f",piece4:"#ffd166",piece5:"#c39bff",piece6:"#ffa96b",panel:"#fff8f0"},texts:{"res.coins":sn("Coins","\u041C\u043E\u043D\u0435\u0442\u043A\u0438","\u0422\u0438\u044B\u043D\u0434\u0430\u0440","\u786C\u5E01","\uCF54\uC778","\u30B3\u30A4\u30F3","\u0938\u093F\u0915\u094D\u0915\u0947","Moedas","M\xFCnzen"),"res.score":fi},races:["human","elf","dwarf"],cast:{hero:{preset:"camper",parts:{Glasses:null},races:["human"]},foe:{preset:"lumberjack",parts:{Weapon:"weapon/3",Back:null},races:["orc"]},foe2:{preset:"lumberjack",parts:{Weapon:null,Back:null},races:["dwarf"]},boss:{preset:"viking",races:["orc"]},helper:{preset:"camper",parts:{Weapon:null,Back:null,Glasses:null},races:["human","elf","dwarf"]},foe3:{preset:"hunter",parts:{Weapon:"weapon/hunting_bow"},races:["orc"]},foe4:{preset:"quarterback",races:["orc"]},foe5:{preset:"camper",parts:{Weapon:null,Back:null,Glasses:null},races:["orc"]},hero2:{preset:"quarterback",races:["human"]},hero3:{preset:"wizard",races:["elf"]}}},bc={id:"post-apocalypse",version:1,setting:"post-apocalypse",names:sn("Post-apocalypse","\u041F\u043E\u0441\u0442\u0430\u043F\u043E\u043A\u0430\u043B\u0438\u043F\u0441\u0438\u0441","\u041F\u043E\u0441\u0442\u0430\u043F\u043E\u043A\u0430\u043B\u0438\u043F\u0441\u0438\u0441","\u672B\u65E5\u5E9F\u571F","\uD3EC\uC2A4\uD2B8 \uC544\uD3EC\uCE7C\uB9BD\uC2A4","\u30DD\u30B9\u30C8\u30A2\u30DD\u30AB\u30EA\u30D7\u30B9","\u092A\u094D\u0930\u0932\u092F \u0915\u0947 \u092C\u093E\u0926","P\xF3s-apocalipse","Postapokalypse"),palette:{background:"#1d1a16",ground:"#3a3328",lane:"#4d4436",primary:"#d9a441",secondary:"#7a8f5b",danger:"#b8402d",coin:"#e0c060",accent:"#8fa35a",text:"#f0e6d2",muted:"#a39a86",piece1:"#b8402d",piece2:"#5a7f9a",piece3:"#7a8f5b",piece4:"#e0c060",piece5:"#8a6a4a",piece6:"#d9762f",panel:"#2c2620"},texts:{"res.coins":sn("Caps","\u041A\u0440\u044B\u0448\u043A\u0438","\u049A\u0430\u049B\u043F\u0430\u049B\u0442\u0430\u0440","\u74F6\u76D6","\uBCD1\uB69C\uAED1","\u30AD\u30E3\u30C3\u30D7","\u0922\u0915\u094D\u0915\u0928","Tampinhas","Kronkorken"),"res.score":fi},races:["human","undead","orc"],cast:{hero:{preset:"soldier",parts:{Hat:null,Gloves:"gloves/bracers"},races:["human"]},foe:{preset:"lumberjack",parts:{Weapon:null,Back:null,Gloves:null},races:["undead"]},foe2:{preset:"berserker",parts:{Hat:null,Offhand:null,Weapon:"weapon/mace"},races:["orc"]},boss:{preset:"berserker",parts:{Hat:"hat/great_helm",Weapon:"weapon/double_axe"},races:["orc"]},helper:{preset:"soldier",parts:{Hat:null,Weapon:null},races:["human"]},foe3:{preset:"musketeer",parts:{Weapon:"weapon/musket",Hat:null},races:["undead"]},foe4:{preset:"viking",parts:{Weapon:"weapon/mace"},races:["undead"]},foe5:{preset:"lumberjack",parts:{Weapon:"weapon/dagger",Back:null},races:["undead"]},hero2:{preset:"viking",parts:{Hat:null},races:["human"]},hero3:{preset:"ranger",races:["human"]}}},Co=[mc,yc,gc,bc],uc=(e,t)=>(e.flows??[]).some(r=>r.resource===t.resource&&r.by===t.by&&r.kind===t.kind)?e:{...e,flows:[...e.flows??[],t]},Df=e=>e.resources?.find(t=>t.kind==="currency")?.id??"coins",xc=e=>t=>uc(t,{resource:Df(t),by:`system:${e}`,kind:"sink"}),kc={id:"hero-upgrade",version:1,name:"link.hero-upgrade",core:["runner","platformer","survivors","tower-defense"],systems:["character"],apply:xc("character")},vc={id:"puzzle-city",version:1,name:"link.puzzle-city",core:["match3","merge"],systems:[],apply(e){if(e.modes.some(o=>o.id==="city"))return e;let t=Df(e),r={...e,modes:[...e.modes,{id:"city",preset:"tycoon",role:"meta"}]};return uc(uc(r,{resource:t,by:"city",kind:"source",amount:"vars.coins"}),{resource:t,by:"system:store",kind:"sink"})}},$c={id:"runner-collection",version:1,name:"link.runner-collection",core:["runner","platformer"],systems:["lootboxes","collections"],apply:xc("lootboxes")},Mc={id:"defense-boosts",version:1,name:"link.defense-boosts",core:["tower-defense","survivors"],systems:["boosts"],apply:xc("boosts")},pi=[kc,vc,$c,Mc];var Of=(e,t)=>`${e.character}-${t}`;var Cf={id:"runner",version:1,engine:"phaser",genre:"runner",name:"preset.runner",blocks:["round","lane-runner"],params:{difficulty:{type:"number",default:.5,min:0,max:1},generosity:{type:"number",default:.6,min:0,max:1},lanes:{type:"number",default:3,min:2,max:5,integer:true},lives:{type:"number",default:3,min:1,max:9,integer:true},length:{type:"number",default:1,min:.05,max:5}},blockParams:{"lane-runner":{lanes:"params.lanes",lives:"params.lives",difficulty:"params.difficulty",coinRate:"0.5 + params.generosity * 0.4",powerRate:"0.12 + params.generosity * 0.2",lengthScale:"params.length"}},produces:["soft","score"],placements:[{id:"reward_window",kind:"reward-window"},{id:"revive",kind:"revive",dailyLimit:5}]},Po={difficulty:{type:"number",default:.5,min:0,max:1},generosity:{type:"number",default:.6,min:0,max:1}},Io=[{id:"reward_window",kind:"reward-window"}],Pf={id:"platformer",version:1,engine:"phaser",genre:"platformer",name:"preset.platformer",blocks:["round","platformer"],params:{...Po,lives:{type:"number",default:3,min:1,max:9,integer:true},doubleJump:{type:"boolean",default:false}},blockParams:{platformer:{difficulty:"params.difficulty",lives:"params.lives",doubleJump:"params.doubleJump"}},produces:["soft","score"],placements:[...Io,{id:"revive",kind:"revive",dailyLimit:5}]},If={id:"survivors",version:1,engine:"phaser",genre:"survivors",name:"preset.survivors",blocks:["round","survivors"],params:{...Po,minutes:{type:"number",default:5,min:.5,max:15}},blockParams:{survivors:{duration:"params.minutes * 60",spawnRate:"0.9 + params.difficulty * 0.6",spawnGrowth:"0.6 + params.difficulty * 0.6",foeHpGrowth:"0.3 + params.difficulty * 0.3",foeDamage:"0.8 + params.difficulty * 0.4",coinRate:"0.15 + params.generosity * 0.3",hp:"120 - params.difficulty * 40"}},produces:["soft","score"],placements:[...Io,{id:"revive",kind:"revive",dailyLimit:5},{id:"reroll",kind:"retry",dailyLimit:10}]},Nf={id:"tower-defense",version:2,engine:"phaser",genre:"tower-defense",name:"preset.tower-defense",blocks:["round","tower-defense"],params:{...Po,lives:{type:"number",default:20,min:1,max:100,integer:true}},blockParams:{"tower-defense":{difficulty:"params.difficulty",lives:"params.lives",coinRate:"0.08 + params.generosity * 0.25",earlyGold:"1 + params.generosity * 2"}},produces:["soft","score"],placements:[...Io,{id:"revive",kind:"revive",dailyLimit:5}]},zf={id:"match3",version:2,engine:"phaser",genre:"match3",name:"preset.match3",blocks:["round","match3"],params:{...Po},blockParams:{match3:{difficulty:"params.difficulty",coinEvery:"12 - params.generosity * 7"}},produces:["soft","score","stars"],placements:[...Io,{id:"revive",kind:"revive",dailyLimit:5}]},Bf={id:"merge",version:2,engine:"phaser",genre:"merge",name:"preset.merge",blocks:["round","merge"],params:{...Po},blockParams:{merge:{difficulty:"params.difficulty",orderReward:"0.6 + params.generosity * 0.8"}},produces:["soft","score","stars"],placements:[...Io,{id:"revive",kind:"revive",dailyLimit:5}]},Hf={id:"tycoon",version:2,engine:"phaser",genre:"idle-tycoon",name:"preset.tycoon",blocks:["round","tycoon"],params:{...Po},blockParams:{tycoon:{difficulty:"params.difficulty",coinReward:"0.6 + params.generosity * 0.8"}},produces:["soft","score","stars"],placements:[...Io,{id:"revive",kind:"revive",dailyLimit:5}]},Wf=[Cf,Pf,If,Nf,zf,Bf,Hf],vu=[Gs,qs,Sa,Ca,Va,da,va,di];function $u(e){Ho(e);for(let t of vu)e.has(dn,t.id)||e.define(dn,t);for(let t of Co)e.has(Fn,t.id)||e.define(Fn,t);for(let t of pi)e.has(Wo,t.id)||e.define(Wo,t);for(let t of Wf)e.has(fn,t.id)||e.define(fn,t);}var Mu={v:1,engine:"phaser",seed:"demo-runner",modes:[{id:"run",preset:"runner",role:"core"}],resources:[{id:"coins",kind:"currency",ref:"CO",name:"res.coins"},{id:"score",kind:"score",name:"res.score"}],flows:[{resource:"coins",by:"run",kind:"source",amount:"vars.coins"},{resource:"coins",by:"system:store",kind:"sink"},{resource:"score",by:"run",kind:"source",amount:"vars.score"}],texts:{title:{en:"Lane Dash",ru:"\u0420\u044B\u0432\u043E\u043A \u043F\u043E \u043F\u043E\u043B\u043E\u0441\u0430\u043C"},hint:{en:"Swipe or tap a side to change lanes",ru:"\u0421\u0432\u0430\u0439\u043F \u0438\u043B\u0438 \u043D\u0430\u0436\u0430\u0442\u0438\u0435 \u0441\u0431\u043E\u043A\u0443 \u043C\u0435\u043D\u044F\u0435\u0442 \u043F\u043E\u043B\u043E\u0441\u0443"}}};function wu(e,t={}){let r=e==="runner"?"run":"main";return {v:1,engine:"phaser",seed:t.seed??e,modes:[{id:r,preset:e,role:"core",...t.params?{params:t.params}:{}}],resources:[{id:"coins",kind:"currency",ref:t.coinRef??"CO",name:"res.coins"},{id:"score",kind:"score",name:"res.score"}],flows:[{resource:"coins",by:r,kind:"source",amount:"vars.coins"},{resource:"coins",by:"system:store",kind:"sink"},{resource:"score",by:r,kind:"source",amount:"vars.score"}],...t.texts?{texts:t.texts}:{},...t.palette?{palette:t.palette}:{},...t.assets?{assets:t.assets}:{}}}var jf=255,Vf=10;var an=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),ui=e=>e===void 0?e:JSON.parse(JSON.stringify(e)),Gf=(e,t)=>JSON.stringify(e)===JSON.stringify(t),Eu=/^([A-Za-z0-9_-]+)(?:\[([A-Za-z0-9_-]+)=([^\]]*)\])?$/,Su=/^'([^']+)'$/;function Lu(e){let t=[],r="",o=false;for(let n of e)n==="'"&&(o=!o),n==="."&&!o?(t.push(r),r=""):r+=n;return t.push(r),t}function mi(e){if(!e)return [];let t=[];for(let r of Lu(e)){let o=Su.exec(r);if(o){t.push({key:o[1]});continue}let n=Eu.exec(r);if(!n)return null;t.push(n[2]!==void 0?{key:n[1],match:{field:n[2],value:n[3]??""}}:{key:n[1]});}return t}function Kf(e,t){let r=e.range;if(!r||t===void 0)return e.value;let o=Math.min(Math.max(Number.isFinite(t)?t:.5,0),1),n=r.min+o*(r.max-r.min);if(r.integer)return Math.round(n);let s=10**(r.digits??2);return Math.round(n*s)/s}function hi(e,t){if(!an(e)||!an(t))return ui(t);let r={...e};for(let[o,n]of Object.entries(t))r[o]=o in r?hi(r[o],n):ui(n);return r}function _u(e,t,r){let o=an(e)?ui(e):{},n=[];return t.forEach((s,a)=>{let i=mi(s.path);if(!i){n.push(a);return}let h=ui(Kf(s,r));if(i.length===0){s.op==="set"&&an(h)?o=h:s.op==="merge"&&an(h)?o=hi(o,h):n.push(a);return}let m=o;for(let x=0;x<i.length-1;x++){let D=Ru(m,i[x],s.ifExists!==true);if(D===void 0){n.push(a);return}m=D;}let v=i[i.length-1];if(!an(m)){n.push(a);return}if(v.match){let x=m[v.key];if(!Array.isArray(x)){n.push(a);return}let D=x.findIndex(O=>an(O)&&String(O[v.match.field])===v.match.value);if(D<0){n.push(a);return}s.op==="set"?x[D]=h:s.op==="merge"?x[D]=hi(x[D],h):s.op==="unset"?x.splice(D,1):n.push(a);return}if(s.ifExists===true&&m[v.key]===void 0){n.push(a);return}switch(s.op){case "set":m[v.key]=h;break;case "merge":m[v.key]=m[v.key]===void 0?h:hi(m[v.key],h);break;case "unset":delete m[v.key];break;case "add":case "remove":{let x=Array.isArray(h)?h:[h],D=m[v.key];if(D!==void 0&&!Array.isArray(D)){n.push(a);return}let O=D?[...D]:[];if(s.op==="add")for(let N of x)O.some(q=>Gf(q,N))||O.push(N);else for(let N of x){let q=O.findIndex(ne=>Gf(ne,N));q>=0&&O.splice(q,1);}m[v.key]=O;break}}}),{value:o,skipped:n}}function Ru(e,t,r){if(an(e)){if(t.match){let o=e[t.key];return Array.isArray(o)?o.find(n=>an(n)&&String(n[t.match.field])===t.match.value):void 0}if(e[t.key]===void 0||e[t.key]===null){if(!r)return;e[t.key]={};}return e[t.key]}}function Au(e){return [...new Set(e.map(t=>`${t.section}:${t.path??""}`))]}var Tu=/^#([0-9a-f]{6})$/i;function Ff(e){let t=Tu.exec(e);if(!t)return [0,0,.5];let r=parseInt(t[1],16),o=(r>>16&255)/255,n=(r>>8&255)/255,s=(r&255)/255,a=Math.max(o,n,s),i=Math.min(o,n,s),h=(a+i)/2;if(a===i)return [0,0,h];let m=a-i,v=h>.5?m/(2-a-i):m/(a+i),x=a===o?(n-s)/m+(n<s?6:0):a===n?(s-o)/m+2:(o-n)/m+4;return x*=60,[x,v,h]}function qf(e,t,r){let o=(e%360+360)%360/360,n=Math.min(Math.max(t,0),1),s=Math.min(Math.max(r,0),1),a=h=>{let m=h;m<0&&(m+=1),m>1&&(m-=1);let v=s<.5?s*(1+n):s+n-s*n,x=2*s-v;return m<1/6?x+(v-x)*6*m:m<1/2?v:m<2/3?x+(v-x)*(2/3-m)*6:x},i=h=>Math.round(h*255).toString(16).padStart(2,"0");return n===0?`#${i(s)}${i(s)}${i(s)}`:`#${i(a(o+1/3))}${i(a(o))}${i(a(o-1/3))}`}function yi(e,t,r=1,o=0){let[n,s,a]=Ff(e);return qf(n+t,s*r,a+o)}function gi(e,t){let[r,o,n]=Ff(e);return qf(r,o,n*(1-t))}var Ce=(e,t)=>({en:e,ru:t}),Ec=(e,t)=>({section:"Look",op:"set",path:e,value:t}),wc=(e,t)=>({section:"GameSpec",op:"set",path:e,value:t}),Du=[{id:"casual-violet",title:Ce("Violet casual","\u0424\u0438\u043E\u043B\u0435\u0442\u043E\u0432\u044B\u0439 \u043A\u0430\u0437\u0443\u0430\u043B"),what:"Bright blue-violet screens, chunky glossy buttons: the classic mobile casual look.",examples:["any casual game","puzzle","arcade"],bgTop:"#5865f2",bgBottom:"#5a3fd6",panel:"#3d8ff5",nav:"#2c3794",ink:"#17193a"},{id:"candy-pink",title:Ce("Candy pink","\u0420\u043E\u0437\u043E\u0432\u0430\u044F \u043A\u043E\u043D\u0444\u0435\u0442\u0430"),what:"Sweet pink and raspberry, playful and girly, candy shop mood.",examples:["sweets","fashion","pets","kids"],bgTop:"#ff7ac6",bgBottom:"#d94a9c",panel:"#ff9ad5",nav:"#a8306f",ink:"#4a1235"},{id:"sunny-orange",title:Ce("Sunny orange","\u0421\u043E\u043B\u043D\u0435\u0447\u043D\u044B\u0439 \u043E\u0440\u0430\u043D\u0436\u0435\u0432\u044B\u0439"),what:"Warm orange and yellow, cheerful summer energy.",examples:["beach","fruit","summer","food"],bgTop:"#ffb347",bgBottom:"#ff7a2f",panel:"#ffc75f",nav:"#c4521b",ink:"#4a2410"},{id:"forest-green",title:Ce("Forest green","\u041B\u0435\u0441\u043D\u043E\u0439 \u0437\u0435\u043B\u0451\u043D\u044B\u0439"),what:"Deep greens of a forest, calm nature mood.",examples:["farm","nature","elves","camping"],bgTop:"#4caf50",bgBottom:"#2e7d32",panel:"#66bb6a",nav:"#1b5e20",ink:"#0f2e12"},{id:"ocean-blue",title:Ce("Ocean blue","\u041E\u043A\u0435\u0430\u043D\u0441\u043A\u0438\u0439 \u0441\u0438\u043D\u0438\u0439"),what:"Sea blue and aqua, fresh water mood.",examples:["ocean","fishing","pirates","islands"],bgTop:"#29b6f6",bgBottom:"#0277bd",panel:"#4fc3f7",nav:"#01579b",ink:"#062c47"},{id:"midnight-navy",title:Ce("Midnight navy","\u041F\u043E\u043B\u043D\u043E\u0447\u043D\u044B\u0439 \u0441\u0438\u043D\u0438\u0439"),what:"Dark navy night, calm and serious, stars at night.",examples:["space","night","strategy","sleep"],bgTop:"#283593",bgBottom:"#0d1442",panel:"#3949ab",nav:"#141a52",ink:"#070a22"},{id:"neon-cyber",title:Ce("Neon cyber","\u041D\u0435\u043E\u043D\u043E\u0432\u044B\u0439 \u043A\u0438\u0431\u0435\u0440"),what:"Black with neon cyan and magenta, cyberpunk and synthwave.",examples:["cyberpunk","hackers","racing at night","sci-fi"],bgTop:"#1a1033",bgBottom:"#07040f",panel:"#2b1a55",nav:"#120a26",ink:"#00e5ff",gold:"#ff3df5",green:"#00ffa3"},{id:"space-purple",title:Ce("Space purple","\u041A\u043E\u0441\u043C\u0438\u0447\u0435\u0441\u043A\u0438\u0439 \u043F\u0443\u0440\u043F\u0443\u0440"),what:"Deep purple space with nebula tones.",examples:["space","aliens","galaxy","magic"],bgTop:"#6a1b9a",bgBottom:"#2a0845",panel:"#8e24aa",nav:"#38006b",ink:"#16001f"},{id:"lava-red",title:Ce("Lava red","\u041B\u0430\u0432\u043E\u0432\u044B\u0439 \u043A\u0440\u0430\u0441\u043D\u044B\u0439"),what:"Hot red and black, danger, fire and action.",examples:["fire","volcano","action","boss fights"],bgTop:"#e53935",bgBottom:"#7f0000",panel:"#ef5350",nav:"#5c0000",ink:"#2a0000"},{id:"royal-gold",title:Ce("Royal gold","\u041A\u043E\u0440\u043E\u043B\u0435\u0432\u0441\u043A\u043E\u0435 \u0437\u043E\u043B\u043E\u0442\u043E"),what:"Gold and deep burgundy, rich, royal and luxurious.",examples:["kings","casino","treasure","empire"],bgTop:"#8e2b3a",bgBottom:"#4a0f1c",panel:"#b3424f",nav:"#3a0a15",ink:"#1f0509",gold:"#ffcf40"},{id:"ice-frost",title:Ce("Ice frost","\u041B\u0435\u0434\u044F\u043D\u043E\u0439"),what:"Pale icy blue and white, winter and snow.",examples:["winter","snow","christmas","north"],bgTop:"#e3f6ff",bgBottom:"#9fd7f5",panel:"#ffffff",nav:"#5aa6d6",ink:"#1d4a6b",light:true},{id:"paper-light",title:Ce("Paper light","\u0421\u0432\u0435\u0442\u043B\u0430\u044F \u0431\u0443\u043C\u0430\u0433\u0430"),what:"Clean light paper, minimal and calm, for word and brain games.",examples:["words","quiz","sudoku","education"],bgTop:"#fbf7ef",bgBottom:"#efe6d5",panel:"#ffffff",nav:"#cdbfa6",ink:"#3d3428",light:true},{id:"mint-fresh",title:Ce("Mint fresh","\u0421\u0432\u0435\u0436\u0430\u044F \u043C\u044F\u0442\u0430"),what:"Light mint and teal, fresh and soft.",examples:["cafe","health","relax","spa"],bgTop:"#b9f6e3",bgBottom:"#5fd4b0",panel:"#e6fff7",nav:"#2f9b80",ink:"#0e3d33",light:true},{id:"lemon-pop",title:Ce("Lemon pop","\u041B\u0438\u043C\u043E\u043D\u043D\u044B\u0439 \u043F\u043E\u043F"),what:"Bright lemon yellow, loud and happy pop art.",examples:["comics","party","kids","music"],bgTop:"#fff176",bgBottom:"#fbc02d",panel:"#fff9c4",nav:"#c49000",ink:"#3d2c00",light:true},{id:"peach-soft",title:Ce("Soft peach","\u041D\u0435\u0436\u043D\u044B\u0439 \u043F\u0435\u0440\u0441\u0438\u043A"),what:"Soft peach and coral pastel, cosy and gentle.",examples:["cooking","home decor","romance","pets"],bgTop:"#ffd3b6",bgBottom:"#ffaa85",panel:"#fff0e6",nav:"#d9775a",ink:"#4a2418",light:true},{id:"lavender-dream",title:Ce("Lavender dream","\u041B\u0430\u0432\u0430\u043D\u0434\u043E\u0432\u044B\u0439 \u0441\u043E\u043D"),what:"Pastel lavender, dreamy and magical.",examples:["fairies","unicorns","dreams","princess"],bgTop:"#e1d5ff",bgBottom:"#b39ddb",panel:"#f5f0ff",nav:"#7e57c2",ink:"#2e1a4d",light:true},{id:"toxic-lime",title:Ce("Toxic lime","\u042F\u0434\u043E\u0432\u0438\u0442\u044B\u0439 \u043B\u0430\u0439\u043C"),what:"Acid lime on dark, toxic, zombies and slime.",examples:["zombies","slime","chemistry","monsters"],bgTop:"#33402a",bgBottom:"#141a10",panel:"#4b5e35",nav:"#1c2414",ink:"#a6ff00",gold:"#d4ff3d",green:"#7dff2a"},{id:"desert-sand",title:Ce("Desert sand","\u041F\u0443\u0441\u0442\u044B\u043D\u043D\u044B\u0439 \u043F\u0435\u0441\u043E\u043A"),what:"Sand, ochre and terracotta, desert and ancient ruins.",examples:["egypt","western","desert","archaeology"],bgTop:"#e0b075",bgBottom:"#b5763f",panel:"#f0c995",nav:"#8a5126",ink:"#3b2210"},{id:"rust-wasteland",title:Ce("Rust wasteland","\u0420\u0436\u0430\u0432\u0430\u044F \u043F\u0443\u0441\u0442\u043E\u0448\u044C"),what:"Rusty brown and dusty orange, post-apocalypse scrap.",examples:["post-apocalypse","scrap","survival","mad roads"],bgTop:"#6d4c41",bgBottom:"#2e1f1a",panel:"#8d6e63",nav:"#3e2723",ink:"#140c09",gold:"#ff9e40"},{id:"steel-gray",title:Ce("Steel gray","\u0421\u0442\u0430\u043B\u044C\u043D\u043E\u0439 \u0441\u0435\u0440\u044B\u0439"),what:"Cool steel and graphite, military and industrial.",examples:["army","tanks","factory","robots"],bgTop:"#607d8b",bgBottom:"#263238",panel:"#78909c",nav:"#1c262b",ink:"#0b1013"},{id:"jungle-teal",title:Ce("Jungle teal","\u0422\u0440\u043E\u043F\u0438\u0447\u0435\u0441\u043A\u0438\u0439 \u0431\u0438\u0440\u044E\u0437\u043E\u0432\u044B\u0439"),what:"Teal and jungle green, tropical adventure.",examples:["jungle","tropics","dinosaurs","explorers"],bgTop:"#26a69a",bgBottom:"#00695c",panel:"#4db6ac",nav:"#004d40",ink:"#00211c"},{id:"berry-plum",title:Ce("Berry plum","\u042F\u0433\u043E\u0434\u043D\u0430\u044F \u0441\u043B\u0438\u0432\u0430"),what:"Plum and berry purple, juicy and rich.",examples:["berries","potions","fashion","music"],bgTop:"#ad1457",bgBottom:"#4a0072",panel:"#c2185b",nav:"#38004d",ink:"#1a0024"},{id:"sky-day",title:Ce("Clear sky","\u042F\u0441\u043D\u043E\u0435 \u043D\u0435\u0431\u043E"),what:"Light sky blue with white clouds, open and friendly.",examples:["flying","birds","kids","travel"],bgTop:"#bfe9ff",bgBottom:"#6ec6ff",panel:"#ffffff",nav:"#3a9ad9",ink:"#123a5a",light:true},{id:"chocolate",title:Ce("Chocolate","\u0428\u043E\u043A\u043E\u043B\u0430\u0434"),what:"Brown chocolate and caramel, sweet and warm.",examples:["bakery","coffee","sweets","autumn"],bgTop:"#8d5a3b",bgBottom:"#4e2c1a",panel:"#a6704b",nav:"#3b2012",ink:"#1a0d06",gold:"#ffc56b"},{id:"autumn-maple",title:Ce("Autumn maple","\u041E\u0441\u0435\u043D\u043D\u0438\u0439 \u043A\u043B\u0451\u043D"),what:"Orange and red autumn leaves, harvest mood.",examples:["autumn","halloween","harvest","forest"],bgTop:"#ef6c00",bgBottom:"#8c2f00",panel:"#f57c00",nav:"#6b2300",ink:"#2b0e00"},{id:"spooky-night",title:Ce("Spooky night","\u0416\u0443\u0442\u043A\u0430\u044F \u043D\u043E\u0447\u044C"),what:"Dark purple and pumpkin orange, ghosts and halloween.",examples:["halloween","ghosts","horror lite","witches"],bgTop:"#311b92",bgBottom:"#120838",panel:"#4527a0",nav:"#0d0629",ink:"#05020f",gold:"#ff8f00"},{id:"sakura",title:Ce("Sakura","\u0421\u0430\u043A\u0443\u0440\u0430"),what:"Cherry blossom pink with soft white, japanese spring.",examples:["japan","anime","spring","ninja lite"],bgTop:"#ffd6e7",bgBottom:"#f48fb1",panel:"#fff3f8",nav:"#c2185b",ink:"#4d0f2a",light:true},{id:"matrix-green",title:Ce("Terminal green","\u0422\u0435\u0440\u043C\u0438\u043D\u0430\u043B\u044C\u043D\u044B\u0439 \u0437\u0435\u043B\u0451\u043D\u044B\u0439"),what:"Black with bright terminal green, hacker console.",examples:["hacking","code","retro computers","spy"],bgTop:"#0b1f0f",bgBottom:"#000000",panel:"#123317",nav:"#06120a",ink:"#39ff6a",gold:"#c6ff00",green:"#39ff6a"},{id:"retro-arcade",title:Ce("Retro arcade","\u0420\u0435\u0442\u0440\u043E-\u0430\u0440\u043A\u0430\u0434\u0430"),what:"Eighties arcade: deep blue with hot pink and yellow.",examples:["retro","pixel","80s","arcade"],bgTop:"#1e2a78",bgBottom:"#0a0f3d",panel:"#ff2e88",nav:"#0a0f3d",ink:"#05071f",gold:"#ffe600"},{id:"stone-dungeon",title:Ce("Stone dungeon","\u041A\u0430\u043C\u0435\u043D\u043D\u043E\u0435 \u043F\u043E\u0434\u0437\u0435\u043C\u0435\u043B\u044C\u0435"),what:"Dark stone and torchlight, dungeons and castles.",examples:["dungeon","castle","knights","rpg"],bgTop:"#4e4a46",bgBottom:"#1f1c1a",panel:"#6b655e",nav:"#171513",ink:"#0a0908",gold:"#ffb300"},{id:"emerald-luxe",title:Ce("Emerald luxe","\u0418\u0437\u0443\u043C\u0440\u0443\u0434\u043D\u044B\u0439 \u043B\u044E\u043A\u0441"),what:"Emerald green with gold, wealth and luck.",examples:["casino","luck","money","irish"],bgTop:"#00695c",bgBottom:"#00251a",panel:"#00897b",nav:"#001a12",ink:"#000c08",gold:"#ffd54f"},{id:"bubblegum",title:Ce("Bubblegum","\u0416\u0432\u0430\u0447\u043A\u0430"),what:"Pastel cyan and pink together, fun and bouncy.",examples:["kids","toys","party","bubbles"],bgTop:"#a0f0ff",bgBottom:"#ff9fe0",panel:"#ffffff",nav:"#d66bb4",ink:"#3a1f4d",light:true},{id:"military-olive",title:Ce("Military olive","\u0410\u0440\u043C\u0435\u0439\u0441\u043A\u0430\u044F \u043E\u043B\u0438\u0432\u0430"),what:"Olive drab and khaki, army and survival.",examples:["army","war","survival","hunting"],bgTop:"#6b7a3a",bgBottom:"#33391b",panel:"#808f4a",nav:"#262b14",ink:"#101207",gold:"#e6c34d"},{id:"deep-sea",title:Ce("Deep sea","\u041C\u043E\u0440\u0441\u043A\u0430\u044F \u0431\u0435\u0437\u0434\u043D\u0430"),what:"Very dark teal-blue of the deep ocean with glowing tones.",examples:["submarine","deep sea","mermaids","monsters"],bgTop:"#004e64",bgBottom:"#001219",panel:"#00677f",nav:"#000c11",ink:"#000508",gold:"#94fbab",green:"#4dfff3"},{id:"sunset",title:Ce("Sunset","\u0417\u0430\u043A\u0430\u0442"),what:"Orange to purple sunset gradient, warm evening.",examples:["travel","music","romance","racing"],bgTop:"#ff8a65",bgBottom:"#6a1b9a",panel:"#ff7043",nav:"#4a148c",ink:"#1f0738"},{id:"arctic-night",title:Ce("Polar night","\u041F\u043E\u043B\u044F\u0440\u043D\u0430\u044F \u043D\u043E\u0447\u044C"),what:"Dark blue with aurora green and cyan.",examples:["aurora","north","winter night","magic"],bgTop:"#0d3b66",bgBottom:"#021526",panel:"#145374",nav:"#01101e",ink:"#000810",gold:"#7cf5c8",green:"#3ff2a0"},{id:"honey",title:Ce("Honey","\u041C\u0451\u0434"),what:"Golden honey amber, warm and sweet, bees and farms.",examples:["bees","farm","bakery","sunny"],bgTop:"#ffca28",bgBottom:"#ff8f00",panel:"#ffe082",nav:"#b26a00",ink:"#3d2400"},{id:"monochrome",title:Ce("Monochrome","\u041C\u043E\u043D\u043E\u0445\u0440\u043E\u043C"),what:"Black, white and gray only, strict and stylish.",examples:["noir","minimal","chess","detective"],bgTop:"#3a3a3a",bgBottom:"#111111",panel:"#555555",nav:"#0c0c0c",ink:"#000000",gold:"#ffffff",green:"#d9d9d9"},{id:"tropical-punch",title:Ce("Tropical punch","\u0422\u0440\u043E\u043F\u0438\u0447\u0435\u0441\u043A\u0438\u0439 \u043F\u0443\u043D\u0448"),what:"Hot coral, turquoise and yellow, tropical party.",examples:["tropics","summer party","cocktails","carnival"],bgTop:"#ff5e62",bgBottom:"#ff9966",panel:"#1de9b6",nav:"#c2364a",ink:"#3d0f16"},{id:"cloud-gray",title:Ce("Soft gray","\u041C\u044F\u0433\u043A\u0438\u0439 \u0441\u0435\u0440\u044B\u0439"),what:"Light neutral gray, calm and modern, apps and tools.",examples:["tools","productivity","calm puzzle","office"],bgTop:"#f2f4f7",bgBottom:"#d5dae1",panel:"#ffffff",nav:"#8a94a6",ink:"#2b313b",light:true}];function Ou(e){let t={bgTop:e.bgTop,bgBottom:e.bgBottom,panel:e.panel,panelDeep:gi(e.panel,.18),panelEdge:e.ink,ink:e.ink,nav:e.nav,text:e.light?e.ink:"#ffffff",textDim:e.light?yi(e.ink,0,.6,.25):yi(e.panel,0,.5,.35)};return e.gold&&(t.gold=e.gold,t.goldDeep=gi(e.gold,.2)),e.green&&(t.green=e.green,t.greenDeep=gi(e.green,.25)),{id:e.id,title:e.title,what:e.what,examples:e.examples,swatch:[e.bgTop,e.bgBottom,e.panel,e.gold??"#ffd43b"],patches:[Ec("Theme",t)]}}var Uf=Du.map(Ou),Cu=[{id:"classic",title:Ce("Classic","\u041A\u043B\u0430\u0441\u0441\u0438\u043A\u0430"),what:"The pack's own colours.",dh:0,sat:1,dl:0},{id:"dawn",title:Ce("Dawn","\u0420\u0430\u0441\u0441\u0432\u0435\u0442"),what:"Lighter and warmer, a morning mood.",dh:20,sat:1.05,dl:.08},{id:"night",title:Ce("Night","\u041D\u043E\u0447\u044C"),what:"Darker and bluer, a night mood.",dh:-35,sat:.9,dl:-0.07},{id:"ember",title:Ce("Ember","\u0423\u0433\u043B\u0438"),what:"Shifted to red and orange, hot and dangerous.",dh:-60,sat:1.15,dl:0},{id:"frost",title:Ce("Frost","\u0418\u043D\u0435\u0439"),what:"Shifted to cyan and pale blue, cold and icy.",dh:140,sat:.8,dl:.05},{id:"toxic",title:Ce("Toxic","\u042F\u0434"),what:"Shifted to acid green and yellow, toxic.",dh:70,sat:1.25,dl:0},{id:"royal",title:Ce("Royal","\u041A\u043E\u0440\u043E\u043B\u0435\u0432\u0441\u043A\u0438\u0439"),what:"Shifted to purple and violet, magical and noble.",dh:200,sat:1.1,dl:0},{id:"faded",title:Ce("Faded","\u0412\u044B\u0446\u0432\u0435\u0442\u0448\u0438\u0439"),what:"Muted, low saturation, old photo and dusty.",dh:0,sat:.45,dl:.03}],Pu=["background","ground","lane","primary","secondary","accent","muted","panel"],Xf=Co.flatMap(e=>Cu.map(t=>{let r={...e.palette};for(let o of Pu){let n=e.palette[o];n&&(r[o]=yi(n,t.dh,t.sat,t.dl));}return {id:`${e.id}-${t.id}`,title:{en:`${e.names.en??e.id}: ${t.title.en}`,ru:`${e.names.ru??e.id}: ${t.title.ru}`},what:`${e.names.en??e.id} world. ${t.what}`,swatch:[r.background,r.ground,r.primary,r.accent],patches:[wc("assets",e.id),wc("palette",r)]}})),Iu=[["knight","Knight","\u0420\u044B\u0446\u0430\u0440\u044C","An armoured knight with a sword and shield, brave and classic."],["dark_knight","Dark knight","\u0422\u0451\u043C\u043D\u044B\u0439 \u0440\u044B\u0446\u0430\u0440\u044C","A knight in black armour, grim and mighty."],["archmage","Archmage","\u0410\u0440\u0445\u0438\u043C\u0430\u0433","An old wizard in robes with a staff, magic and wisdom."],["berserker","Berserker","\u0411\u0435\u0440\u0441\u0435\u0440\u043A","A wild warrior with a big axe, rage and strength."],["hunter","Hunter","\u041E\u0445\u043E\u0442\u043D\u0438\u043A","A hunter with a bow and a hood, forests and tracking."],["crossbowman","Crossbowman","\u0410\u0440\u0431\u0430\u043B\u0435\u0442\u0447\u0438\u043A","A soldier with a crossbow, a careful shooter."],["gunslinger","Gunslinger","\u0421\u0442\u0440\u0435\u043B\u043E\u043A","A cowboy gunslinger, the wild west and duels."],["musketeer","Musketeer","\u041C\u0443\u0448\u043A\u0435\u0442\u0451\u0440","A musketeer with a hat and a musket, honour and adventure."],["soldier","Soldier","\u0421\u043E\u043B\u0434\u0430\u0442","A modern soldier with a rifle, war and missions."],["quarterback","Quarterback","\u041A\u0432\u043E\u0442\u0435\u0440\u0431\u0435\u043A","An american football player, sport and teams."],["lumberjack","Lumberjack","\u041B\u0435\u0441\u043E\u0440\u0443\u0431","A bearded lumberjack in a checked shirt with an axe, woods and work."],["viking","Viking","\u0412\u0438\u043A\u0438\u043D\u0433","A horned viking with a hammer, the north and raids."],["wizard","Wizard","\u0412\u043E\u043B\u0448\u0435\u0431\u043D\u0438\u043A","A young wizard with a pointy hat, spells and school of magic."],["ranger","Ranger","\u0421\u043B\u0435\u0434\u043E\u043F\u044B\u0442","A ranger of the wild, light armour and a long bow."],["king","King","\u041A\u043E\u0440\u043E\u043B\u044C","A king with a crown and a cape, kingdoms and rule."],["camper","Camper","\u0422\u0443\u0440\u0438\u0441\u0442","A casual hiker with a backpack, everyday modern life."],["crusader","Crusader","\u041A\u0440\u0435\u0441\u0442\u043E\u043D\u043E\u0441\u0435\u0446","A holy warrior in white and gold, light against darkness."]],Zf=Iu.map(([e,t,r,o])=>({id:e,title:Ce(t,r),what:o,patches:[wc("cast.hero.preset",e)]})),Qf=[["gear","Game gear","\u0418\u0433\u0440\u043E\u0432\u044B\u0435 \u043F\u0440\u0435\u0434\u043C\u0435\u0442\u044B","Faint swords, shields, potions, gems and crowns: the classic casual game look."],["plain","Plain gradient","\u0427\u0438\u0441\u0442\u044B\u0439 \u0433\u0440\u0430\u0434\u0438\u0435\u043D\u0442","No pattern, only the theme's gradient."],["dots","Polka dots","\u0413\u043E\u0440\u043E\u0448\u0435\u043A","Soft polka dots, playful."],["stripes","Diagonal stripes","\u0414\u0438\u0430\u0433\u043E\u043D\u0430\u043B\u044C\u043D\u044B\u0435 \u043F\u043E\u043B\u043E\u0441\u044B","Diagonal stripes, energetic and sporty."],["grid","Grid","\u0421\u0435\u0442\u043A\u0430","A thin grid like graph paper, tech or puzzle."],["hex","Honeycomb","\u0421\u043E\u0442\u044B","A honeycomb pattern, bees, sci-fi or strategy."],["stars","Stars","\u0417\u0432\u0451\u0437\u0434\u044B","Small scattered stars, night, space or magic."],["waves","Waves","\u0412\u043E\u043B\u043D\u044B","Soft waves, water and the sea."],["checker","Checkerboard","\u0428\u0430\u0445\u043C\u0430\u0442\u043A\u0430","A checkerboard, board games, racing flags."],["confetti","Confetti","\u041A\u043E\u043D\u0444\u0435\u0442\u0442\u0438","Colourful confetti bits, party and celebration."],["bubbles","Bubbles","\u041F\u0443\u0437\u044B\u0440\u0438","Round bubbles of different sizes, underwater or soda."],["zigzag","Zigzag","\u0417\u0438\u0433\u0437\u0430\u0433","A bold zigzag, retro and pop."],["diamonds","Diamonds","\u0420\u043E\u043C\u0431\u044B","A diamond pattern, cards, casino, royal."],["clouds","Clouds","\u041E\u0431\u043B\u0430\u043A\u0430","Puffy clouds, sky and dreams."],["leaves","Leaves","\u041B\u0438\u0441\u0442\u044C\u044F","Scattered leaves, nature, forest and autumn."],["circuit","Circuit","\u041C\u0438\u043A\u0440\u043E\u0441\u0445\u0435\u043C\u0430","Circuit board lines, robots, hackers and tech."],["sparkles","Sparkles","\u0418\u0441\u043A\u0440\u044B","Twinkling sparkles, magic, fairies and treasure."],["rays","Sun rays","\u041B\u0443\u0447\u0438","Rays from the centre, victory and big wins."],["bricks","Bricks","\u041A\u0438\u0440\u043F\u0438\u0447\u0438","A brick wall, city, castle or dungeon."],["paws","Paw prints","\u0421\u043B\u0435\u0434\u044B \u043B\u0430\u043F","Little paw prints, pets and animals."],["snow","Snowflakes","\u0421\u043D\u0435\u0436\u0438\u043D\u043A\u0438","Falling snowflakes, winter and holidays."]],Yf=Qf.map(([e,t,r,o])=>({id:e,title:Ce(t,r),what:o,patches:[Ec("Background",e)]})),Jf=[["classic","Classic","\u041A\u043B\u0430\u0441\u0441\u0438\u043A\u0430","The kit's default bright casual clicks and coins."],["soft","Soft","\u041C\u044F\u0433\u043A\u0438\u0435","Quiet, rounded, calm sounds for relaxing games."],["retro","Retro 8-bit","\u0420\u0435\u0442\u0440\u043E 8-\u0431\u0438\u0442","Square-wave chiptune bleeps of old consoles."],["magic","Magic","\u041C\u0430\u0433\u0438\u044F","Shimmering chimes and sparkles, fairy-tale."],["sci-fi","Sci-fi","\u0424\u0430\u043D\u0442\u0430\u0441\u0442\u0438\u043A\u0430","Electronic blips and sweeps, space and robots."],["wood","Wooden","\u0414\u0435\u0440\u0435\u0432\u044F\u043D\u043D\u044B\u0435","Short wooden knocks and marimba, cosy and natural."]],ep=Jf.map(([e,t,r,o])=>({id:e,title:Ce(t,r),what:o,patches:[Ec("SoundSet",e)]})),Nu={backgrounds:Qf.map(e=>e[0]),soundSets:Jf.map(e=>e[0])},Sc={"ui-themes":Uf,"kit-palettes":Xf,"hero-looks":Zf,backgrounds:Yf,"sound-sets":ep};var tp=1,G=(e,t)=>({en:e,ru:t}),Mt=(e,t)=>({section:"Look",op:"set",path:e,value:t}),$n=(e,t,r,o=false)=>({section:"GameSpec",op:"set",path:`modes[role=core].params.${e}`,range:{min:t,max:r,...o?{integer:true}:{}}}),Kt=(e,t)=>({section:"GameSpec",op:"add",path:`modes[role=core].content.${e}.without`,value:t}),wt=(e,t)=>({section:"GameSpec",op:"remove",path:`modes[role=core].content.${e}.without`,value:t}),Ss={modules:["kit-game"]},zu=[{id:"look.theme",group:"look",title:G("Interface colours","\u0426\u0432\u0435\u0442\u0430 \u0438\u043D\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430"),hint:G("Screens, panels and buttons of the whole app.","\u042D\u043A\u0440\u0430\u043D\u044B, \u043F\u0430\u043D\u0435\u043B\u0438 \u0438 \u043A\u043D\u043E\u043F\u043A\u0438 \u0432\u0441\u0435\u0433\u043E \u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u044F."),question:"Pick the colour theme of the app's interface (menus, panels, buttons) that fits this product best.",kind:"choice",list:"ui-themes"},{id:"look.background",group:"look",title:G("Screen pattern","\u0423\u0437\u043E\u0440 \u0444\u043E\u043D\u0430"),hint:G("A pattern over the screens' gradient.","\u0423\u0437\u043E\u0440 \u043F\u043E\u0432\u0435\u0440\u0445 \u0433\u0440\u0430\u0434\u0438\u0435\u043D\u0442\u0430 \u044D\u043A\u0440\u0430\u043D\u043E\u0432."),question:"Pick the background pattern of the app's screens that fits this product best.",kind:"choice",list:"backgrounds"},{id:"look.shape",group:"look",title:G("Shape of buttons","\u0424\u043E\u0440\u043C\u0430 \u043A\u043D\u043E\u043F\u043E\u043A"),question:"What shape should the buttons and panels of the interface have?",kind:"choice",options:[{id:"chunky",title:G("Chunky round","\u041F\u0443\u0445\u043B\u044B\u0435 \u043A\u0440\u0443\u0433\u043B\u044B\u0435"),what:"Big rounded corners and a thick outline: toy-like, casual, for kids.",patches:[Mt("Radius",18),Mt("ButtonRadius",16),Mt("Outline",3)]},{id:"classic",title:G("Classic","\u041A\u043B\u0430\u0441\u0441\u0438\u043A\u0430"),what:"Medium rounded corners and a normal outline: the default mobile casual look.",patches:[Mt("Radius",14),Mt("ButtonRadius",12),Mt("Outline",3)]},{id:"sharp",title:G("Sharp","\u0421\u0442\u0440\u043E\u0433\u0438\u0435"),what:"Small corners and a thin outline: serious, tactical, strategy or sci-fi.",patches:[Mt("Radius",4),Mt("ButtonRadius",4),Mt("Outline",2)]},{id:"pill",title:G("Pills","\u0422\u0430\u0431\u043B\u0435\u0442\u043A\u0438"),what:"Fully round pill buttons, no outline: soft, modern, minimal.",patches:[Mt("Radius",24),Mt("ButtonRadius",32),Mt("Outline",0)]}]},{id:"look.motion",group:"look",title:G("Animations","\u0410\u043D\u0438\u043C\u0430\u0446\u0438\u0438"),question:"How lively should the interface animations be?",kind:"choice",options:[{id:"calm",title:G("Calm","\u0421\u043F\u043E\u043A\u043E\u0439\u043D\u044B\u0435"),what:"Slow, soft, no bounce: relaxing, meditative, for brain games.",patches:[Mt("MotionSpeed",.7),Mt("MotionIntensity",.3),Mt("Particles",false)]},{id:"normal",title:G("Normal","\u041E\u0431\u044B\u0447\u043D\u044B\u0435"),what:"The default lively casual animations.",patches:[Mt("MotionSpeed",1),Mt("MotionIntensity",1),Mt("Particles",true)]},{id:"bouncy",title:G("Bouncy","\u041F\u0440\u0443\u0436\u0438\u043D\u0438\u0441\u0442\u044B\u0435"),what:"Strong bounces and overshoots: cartoonish, playful, for kids.",patches:[Mt("MotionSpeed",1.1),Mt("MotionIntensity",2),Mt("Particles",true)]},{id:"snappy",title:G("Snappy","\u0420\u0435\u0437\u043A\u0438\u0435"),what:"Very fast and short, little bounce: action, arcade, competitive.",patches:[Mt("MotionSpeed",1.8),Mt("MotionIntensity",.6),Mt("Particles",true)]}]},{id:"look.sound",group:"look",title:G("Interface sounds","\u0417\u0432\u0443\u043A\u0438 \u0438\u043D\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430"),question:"Pick the sound style of the interface (clicks, rewards, coins) that fits this product best.",kind:"choice",list:"sound-sets"}],Bu=[{id:"look.kit.palette",group:"look",title:G("World and colours of the game","\u041C\u0438\u0440 \u0438 \u0446\u0432\u0435\u0442\u0430 \u0438\u0433\u0440\u044B"),hint:G("The game's world (fantasy, sci-fi, cozy, post-apocalypse) and its colour mood.","\u041C\u0438\u0440 \u0438\u0433\u0440\u044B (\u0444\u044D\u043D\u0442\u0435\u0437\u0438, \u0444\u0430\u043D\u0442\u0430\u0441\u0442\u0438\u043A\u0430, \u0443\u044E\u0442, \u043F\u043E\u0441\u0442\u0430\u043F\u043E\u043A\u0430\u043B\u0438\u043F\u0441\u0438\u0441) \u0438 \u043D\u0430\u0441\u0442\u0440\u043E\u0435\u043D\u0438\u0435 \u0446\u0432\u0435\u0442\u0430."),for:Ss,question:"Pick the world and colour mood of the game scene that fits this idea best.",kind:"choice",list:"kit-palettes"},{id:"look.kit.hero",group:"look",title:G("The hero","\u0413\u0435\u0440\u043E\u0439"),for:Ss,question:"Pick the look of the game's main hero that fits this idea best.",kind:"choice",list:"hero-looks"},{id:"look.kit.race",group:"look",title:G("Hero's race","\u0420\u0430\u0441\u0430 \u0433\u0435\u0440\u043E\u044F"),for:Ss,question:"Which race should the main hero be?",kind:"choice",options:[["human","Human","\u0427\u0435\u043B\u043E\u0432\u0435\u043A","An ordinary human."],["elf","Elf","\u042D\u043B\u044C\u0444","A graceful elf with pointed ears: forests, magic, archery."],["dwarf","Dwarf","\u0413\u043D\u043E\u043C","A stout bearded dwarf: mines, forges, hammers."],["orc","Orc","\u041E\u0440\u043A","A green orc with tusks: brute strength, war, savage lands."],["undead","Undead","\u041D\u0435\u0436\u0438\u0442\u044C","A pale undead: skeletons, graveyards, dark magic, halloween."]].map(([e,t,r,o])=>({id:e,title:G(t,r),what:o,patches:[{section:"GameSpec",op:"set",path:"cast.hero.races",value:[e]}]}))}],Hu=[{id:"feel.difficulty",group:"feel",title:G("Difficulty","\u0421\u043B\u043E\u0436\u043D\u043E\u0441\u0442\u044C"),for:Ss,question:"How hard should this game be for its players?",kind:"score",levelTitles:[G("Very easy","\u041E\u0447\u0435\u043D\u044C \u043B\u0435\u0433\u043A\u043E"),G("Easy","\u041B\u0435\u0433\u043A\u043E"),G("Balanced","\u0421\u0431\u0430\u043B\u0430\u043D\u0441\u0438\u0440\u043E\u0432\u0430\u043D\u043D\u043E"),G("Hard","\u0421\u043B\u043E\u0436\u043D\u043E"),G("Very hard","\u041E\u0447\u0435\u043D\u044C \u0441\u043B\u043E\u0436\u043D\u043E")],levels:["Very easy and relaxing, for kids or a calm break.","Easy, casual.","Balanced: easy to start, harder later.","Hard, for players who like a challenge.","Very hard and punishing."],patches:[$n("difficulty",0,1)]},{id:"feel.generosity",group:"feel",title:G("Rewards in the game","\u041D\u0430\u0433\u0440\u0430\u0434\u044B \u0432 \u0438\u0433\u0440\u0435"),for:Ss,question:"How generous should the game's rewards be?",kind:"score",levelTitles:[G("Stingy","\u0421\u043A\u0443\u043F\u043E"),G("Modest","\u0421\u043A\u0440\u043E\u043C\u043D\u043E"),G("Normal","\u041E\u0431\u044B\u0447\u043D\u043E"),G("Generous","\u0429\u0435\u0434\u0440\u043E"),G("Very generous","\u041E\u0447\u0435\u043D\u044C \u0449\u0435\u0434\u0440\u043E")],levels:["Stingy: rewards are rare and earned slowly.","Modest rewards.","Normal rewards.","Generous rewards.","Very generous: rewards rain down."],patches:[$n("generosity",0,1)]},{id:"feel.runner.lanes",group:"feel",title:G("Lanes","\u041F\u043E\u043B\u043E\u0441\u044B"),for:{modules:["kit-game"],presets:["runner"]},question:"How wide should the running track be?",kind:"score",levelTitles:[G("2 lanes","2 \u043F\u043E\u043B\u043E\u0441\u044B"),G("3 lanes","3 \u043F\u043E\u043B\u043E\u0441\u044B"),G("4 lanes","4 \u043F\u043E\u043B\u043E\u0441\u044B"),G("5 lanes","5 \u043F\u043E\u043B\u043E\u0441")],levels:["Narrow: two lanes, simple and quick.","Normal: three lanes.","Wide: four lanes.","Very wide: five lanes, lots of dodging."],patches:[$n("lanes",2,5,true)]},{id:"feel.runner.lives",group:"feel",title:G("Lives in a run","\u0416\u0438\u0437\u043D\u0438 \u0432 \u0437\u0430\u0431\u0435\u0433\u0435"),for:{modules:["kit-game"],presets:["runner"]},question:"How many hits should the runner survive?",kind:"score",levelTitles:[G("One hit","\u041E\u0434\u0438\u043D \u0443\u0434\u0430\u0440"),G("A few","\u041D\u0435\u0441\u043A\u043E\u043B\u044C\u043A\u043E"),G("Many","\u041C\u043D\u043E\u0433\u043E")],levels:["One hit ends the run.","A few lives.","Many lives, forgiving."],patches:[$n("lives",1,6,true)]},{id:"feel.runner.length",group:"feel",title:G("Length of levels","\u0414\u043B\u0438\u043D\u0430 \u0443\u0440\u043E\u0432\u043D\u0435\u0439"),for:{modules:["kit-game"],presets:["runner"]},question:"How long should one level of the run be?",kind:"score",levelTitles:[G("Very short","\u041E\u0447\u0435\u043D\u044C \u043A\u043E\u0440\u043E\u0442\u043A\u0438\u0435"),G("Short","\u041A\u043E\u0440\u043E\u0442\u043A\u0438\u0435"),G("Normal","\u041E\u0431\u044B\u0447\u043D\u044B\u0435"),G("Long","\u0414\u043B\u0438\u043D\u043D\u044B\u0435")],levels:["Very short bursts for a quick break.","Short.","Normal.","Long runs."],patches:[$n("length",.5,2)]},{id:"feel.runner.powers",group:"feel",title:G("Power-ups","\u0423\u0441\u0438\u043B\u0435\u043D\u0438\u044F"),for:{modules:["kit-game"],presets:["runner"]},question:"Which power-ups fit this runner best?",kind:"choice",options:[{id:"all",title:G("All of them","\u0412\u0441\u0435"),what:"Magnet, shield, double coins, dash and flight: the full set.",patches:[wt("powers",["magnet","shield","double","dash","flight"])]},{id:"grounded",title:G("On the ground","\u0411\u0435\u0437 \u043F\u043E\u043B\u0451\u0442\u0430"),what:"No flight: magnet, shield, double coins and dash. Realistic, sports, city.",patches:[wt("powers",["magnet","shield","double","dash"]),Kt("powers",["flight"])]},{id:"coins",title:G("Coin hunter","\u041E\u0445\u043E\u0442\u0430 \u0437\u0430 \u043C\u043E\u043D\u0435\u0442\u0430\u043C\u0438"),what:"Only the coin ones: magnet and double coins. Collecting, greed, treasure.",patches:[wt("powers",["magnet","double"]),Kt("powers",["shield","dash","flight"])]},{id:"hardcore",title:G("Hardcore","\u0425\u0430\u0440\u0434\u043A\u043E\u0440"),what:"No shield and no flight: dodging is everything. Skill, challenge.",patches:[wt("powers",["magnet","double","dash"]),Kt("powers",["shield","flight"])]}]},{id:"feel.runner.obstacles",group:"feel",title:G("Obstacles","\u041F\u0440\u0435\u043F\u044F\u0442\u0441\u0442\u0432\u0438\u044F"),for:{modules:["kit-game"],presets:["runner"]},question:"Which obstacles fit this runner best?",kind:"choice",options:[{id:"all",title:G("Everything","\u0412\u0441\u0451 \u043F\u043E\u0434\u0440\u044F\u0434"),what:"Walls, barriers, pits, moving blocks, trains and rocks.",patches:[wt("obstacles",["wall","barrier","pit","mover","train","rock"])]},{id:"city",title:G("City streets","\u0413\u043E\u0440\u043E\u0434\u0441\u043A\u0438\u0435 \u0443\u043B\u0438\u0446\u044B"),what:"Walls, barriers, moving blocks and trains: a city, a subway, traffic.",patches:[wt("obstacles",["wall","barrier","mover","train"]),Kt("obstacles",["pit","rock"])]},{id:"wild",title:G("Wild lands","\u0414\u0438\u043A\u0438\u0435 \u0437\u0435\u043C\u043B\u0438"),what:"Walls, pits, rocks and barriers: forests, mountains, ruins, no trains.",patches:[wt("obstacles",["wall","barrier","pit","rock"]),Kt("obstacles",["mover","train"])]},{id:"simple",title:G("Simple","\u041F\u0440\u043E\u0441\u0442\u044B\u0435"),what:"Only walls, barriers and pits: easy to read, for kids.",patches:[wt("obstacles",["wall","barrier","pit"]),Kt("obstacles",["mover","train","rock"])]}]},{id:"feel.platformer.lives",group:"feel",title:G("Lives on a level","\u0416\u0438\u0437\u043D\u0438 \u043D\u0430 \u0443\u0440\u043E\u0432\u043D\u0435"),for:{modules:["kit-game"],presets:["platformer"]},question:"How many hits should the hero survive on a level?",kind:"score",levelTitles:[G("One hit","\u041E\u0434\u0438\u043D \u0443\u0434\u0430\u0440"),G("A few hearts","\u041D\u0435\u0441\u043A\u043E\u043B\u044C\u043A\u043E \u0441\u0435\u0440\u0434\u0435\u0446"),G("Many hearts","\u041C\u043D\u043E\u0433\u043E \u0441\u0435\u0440\u0434\u0435\u0446")],levels:["One hit and the level restarts.","A few hearts.","Many hearts, forgiving."],patches:[$n("lives",1,6,true)]},{id:"feel.platformer.double-jump",group:"feel",title:G("Double jump from the start","\u0414\u0432\u043E\u0439\u043D\u043E\u0439 \u043F\u0440\u044B\u0436\u043E\u043A \u0441\u0440\u0430\u0437\u0443"),for:{modules:["kit-game"],presets:["platformer"]},question:"Should the hero have a double jump from the very first level?",kind:"noul",yes:"Yes: the game is light and acrobatic, the hero flies around from the start.",no:"No: the double jump is earned later, the start is grounded and careful.",onYes:[{section:"GameSpec",op:"set",path:"modes[role=core].params.doubleJump",value:true}],onNo:[{section:"GameSpec",op:"set",path:"modes[role=core].params.doubleJump",value:false}]},{id:"feel.survivors.minutes",group:"feel",title:G("Length of a chapter","\u0414\u043B\u0438\u043D\u0430 \u0433\u043B\u0430\u0432\u044B"),for:{modules:["kit-game"],presets:["survivors"]},question:"How long should one chapter of survival last?",kind:"score",levelTitles:[G("2 minutes","2 \u043C\u0438\u043D\u0443\u0442\u044B"),G("5 minutes","5 \u043C\u0438\u043D\u0443\u0442"),G("10 minutes","10 \u043C\u0438\u043D\u0443\u0442"),G("15 minutes","15 \u043C\u0438\u043D\u0443\u0442")],levels:["Two minutes: quick bursts.","Five minutes.","Ten minutes.","Fifteen minutes: long sessions."],patches:[$n("minutes",2,15)]},{id:"feel.survivors.foes",group:"feel",title:G("Monsters","\u041C\u043E\u043D\u0441\u0442\u0440\u044B"),for:{modules:["kit-game"],presets:["survivors"]},question:"Which kinds of monsters fit this game best?",kind:"choice",options:[{id:"all",title:G("The whole horde","\u0412\u0441\u044F \u043E\u0440\u0434\u0430"),what:"Swarms, grunts, archers, brutes, chargers and bombers.",patches:[wt("foes",["swarm","grunt","archer","brute","charger","bomber"])]},{id:"melee",title:G("Close combat","\u0411\u043B\u0438\u0436\u043D\u0438\u0439 \u0431\u043E\u0439"),what:"No shooters: swarms, grunts, brutes and chargers. Zombies, beasts.",patches:[wt("foes",["swarm","grunt","brute","charger"]),Kt("foes",["archer","bomber"])]},{id:"army",title:G("An army","\u0410\u0440\u043C\u0438\u044F"),what:"Grunts, archers, brutes and chargers, no swarms: soldiers, knights, war.",patches:[wt("foes",["grunt","archer","brute","charger"]),Kt("foes",["swarm","bomber"])]},{id:"chaos",title:G("Chaos","\u0425\u0430\u043E\u0441"),what:"Swarms, bombers and chargers: fast, explosive, crazy.",patches:[wt("foes",["swarm","charger","bomber","grunt"]),Kt("foes",["archer","brute"])]}]},{id:"feel.td.lives",group:"feel",title:G("Lives of the base","\u0416\u0438\u0437\u043D\u0438 \u0431\u0430\u0437\u044B"),for:{modules:["kit-game"],presets:["tower-defense"]},question:"How many enemies may slip through before the level is lost?",kind:"score",levelTitles:[G("Very few","\u041E\u0447\u0435\u043D\u044C \u043C\u0430\u043B\u043E"),G("Some","\u0421\u0440\u0435\u0434\u043D\u0435"),G("Many","\u041C\u043D\u043E\u0433\u043E")],levels:["Very few: every leak hurts.","Some.","Many: forgiving."],patches:[$n("lives",5,40,true)]},{id:"feel.td.foes",group:"feel",title:G("Enemies in the waves","\u0412\u0440\u0430\u0433\u0438 \u0432 \u0432\u043E\u043B\u043D\u0430\u0445"),for:{modules:["kit-game"],presets:["tower-defense"]},question:"Which enemies should march in the waves of this tower defense?",kind:"choice",options:[{id:"all",title:G("The whole army","\u0412\u0441\u044F \u0430\u0440\u043C\u0438\u044F"),what:"Grunts, runners, brutes, flyers, shamans, healers and splitters: the full mix.",patches:[wt("foes",["grunt","runner","brute","flyer","shaman","healer","splitter"])]},{id:"ground",title:G("Only on foot","\u0422\u043E\u043B\u044C\u043A\u043E \u043F\u0435\u0448\u0438\u0435"),what:"No flyers: every enemy walks the road. Medieval, zombies, ground war.",patches:[wt("foes",["grunt","runner","brute","shaman","healer","splitter"]),Kt("foes",["flyer"])]},{id:"simple",title:G("Plain and clear","\u041F\u0440\u043E\u0441\u0442\u044B\u0435"),what:"No shamans, healers or splitters: easy to read, for kids and casual players.",patches:[wt("foes",["grunt","runner","brute","flyer"]),Kt("foes",["shaman","healer","splitter"])]},{id:"swarm",title:G("Fast hordes","\u0411\u044B\u0441\u0442\u0440\u044B\u0435 \u043E\u0440\u0434\u044B"),what:"No brutes or shamans: many fast weak foes, a frantic pace. Insects, rats, robots.",patches:[wt("foes",["grunt","runner","flyer","healer","splitter"]),Kt("foes",["brute","shaman"])]}]},{id:"feel.survivors.weapons",group:"feel",title:G("Weapons to find","\u041E\u0440\u0443\u0436\u0438\u0435 \u0432 \u0437\u0430\u0431\u0435\u0433\u0435"),hint:G("Which new weapons a level-up may offer.","\u041A\u0430\u043A\u043E\u0435 \u043D\u043E\u0432\u043E\u0435 \u043E\u0440\u0443\u0436\u0438\u0435 \u043F\u0440\u0435\u0434\u043B\u0430\u0433\u0430\u0435\u0442 \u043F\u043E\u0432\u044B\u0448\u0435\u043D\u0438\u0435 \u0443\u0440\u043E\u0432\u043D\u044F."),for:{modules:["kit-game"],presets:["survivors"]},question:"Which weapons fit the hero of this survival game best?",kind:"choice",options:[{id:"all",title:G("Everything","\u0412\u0441\u0451"),what:"Blaster, blades, aura, boomerang, lightning and drone: the full arsenal.",patches:[wt("weapons",["blaster","blades","aura","boomerang","lightning","drone"])]},{id:"tech",title:G("Technology","\u0422\u0435\u0445\u043D\u0438\u043A\u0430"),what:"Blaster, drone and lightning: guns and gadgets. Sci-fi, robots, the future.",patches:[wt("weapons",["blaster","drone","lightning"]),Kt("weapons",["blades","aura","boomerang"])]},{id:"magic",title:G("Magic and steel","\u041C\u0430\u0433\u0438\u044F \u0438 \u0441\u0442\u0430\u043B\u044C"),what:"Blades, aura, boomerang and lightning, no guns: fantasy, wizards, knights.",patches:[wt("weapons",["blades","aura","boomerang","lightning"]),Kt("weapons",["blaster","drone"])]},{id:"classic",title:G("Classic","\u041A\u043B\u0430\u0441\u0441\u0438\u043A\u0430"),what:"Blaster, blades and boomerang: simple weapons that are easy to read.",patches:[wt("weapons",["blaster","blades","boomerang"]),Kt("weapons",["aura","lightning","drone"])]}]},{id:"feel.tycoon.events",group:"feel",title:G("Events in the city","\u0421\u043E\u0431\u044B\u0442\u0438\u044F \u0432 \u0433\u043E\u0440\u043E\u0434\u0435"),for:{modules:["kit-game"],presets:["tycoon"]},question:"Which events should pop up while this tycoon city earns money?",kind:"choice",options:[{id:"all",title:G("Busy life","\u0411\u0443\u0440\u043D\u0430\u044F \u0436\u0438\u0437\u043D\u044C"),what:"Rushes, breakdowns, investors and couriers: always something to tap.",patches:[wt("events",["rush","break","invest","courier"])]},{id:"calm",title:G("No breakdowns","\u0411\u0435\u0437 \u043F\u043E\u043B\u043E\u043C\u043E\u043A"),what:"Rushes, investors and couriers, nothing ever breaks: a calm, cozy business.",patches:[wt("events",["rush","invest","courier"]),Kt("events",["break"])]},{id:"hands-on",title:G("Hands on","\u0421\u0432\u043E\u0438\u043C\u0438 \u0440\u0443\u043A\u0430\u043C\u0438"),what:"Rushes, breakdowns and couriers, no investors: the city grows by your own work.",patches:[wt("events",["rush","break","courier"]),Kt("events",["invest"])]},{id:"minimal",title:G("Only rushes","\u0422\u043E\u043B\u044C\u043A\u043E \u0430\u0436\u0438\u043E\u0442\u0430\u0436"),what:"Only rush hours: a quiet idle game with few interruptions.",patches:[wt("events",["rush"]),Kt("events",["break","invest","courier"])]}]}],Wu=(e,t)=>({Type:"VirtualCurrency",CurrencyID:e,Amount:t}),bi=(e,t,r,o,n)=>({id:e,title:G(t,r),what:o,patches:n.map((s,a)=>({section:"Reward",op:"set",path:`DailyCalendars.daily_login.Days[DayNumber=${a+1}].Rewards.Standard.Entries`,value:s.map(([i,h])=>Wu(i,h))}))}),Lc=(e,t)=>`StoreOffers.${e}.${t}`,ju=[{id:"economy.shop-ad-gems",group:"economy",title:G("Gems for an ad in the shop","\u041A\u0440\u0438\u0441\u0442\u0430\u043B\u043B\u044B \u0437\u0430 \u0440\u0435\u043A\u043B\u0430\u043C\u0443 \u0432 \u043C\u0430\u0433\u0430\u0437\u0438\u043D\u0435"),for:{sections:["Store"]},question:"How many gems should one rewarded ad in the shop give?",kind:"score",levelTitles:[G("A few","\u041C\u0430\u043B\u043E"),G("Some","\u0421\u0440\u0435\u0434\u043D\u0435"),G("A handful","\u041F\u0440\u0438\u043B\u0438\u0447\u043D\u043E"),G("Many","\u041C\u043D\u043E\u0433\u043E")],levels:["A few: gems are rare.","Some.","A good handful.","Many: gems flow freely."],patches:[{section:"Store",op:"set",path:Lc("kit_gems_ad","Reward.Grant.Standard.Entries[Type=VirtualCurrency].Amount"),range:{min:2,max:15,integer:true}}]},{id:"economy.shop-ad-cap",group:"economy",title:G("Ads in the shop a day","\u0420\u0435\u043A\u043B\u0430\u043C\u0430 \u0432 \u043C\u0430\u0433\u0430\u0437\u0438\u043D\u0435 \u0437\u0430 \u0434\u0435\u043D\u044C"),for:{sections:["Store"]},question:"How many times a day may a player watch an ad for gems in the shop?",kind:"score",levelTitles:[G("A few times","\u041D\u0435\u0441\u043A\u043E\u043B\u044C\u043A\u043E \u0440\u0430\u0437"),G("About ten","\u041E\u043A\u043E\u043B\u043E \u0434\u0435\u0441\u044F\u0442\u0438"),G("Many times","\u041C\u043D\u043E\u0433\u043E \u0440\u0430\u0437")],levels:["A few times.","About ten.","Many times."],patches:[{section:"Store",op:"set",path:Lc("kit_gems_ad","Availability.Limits.DailyCap"),range:{min:3,max:20,integer:true}}]},{id:"economy.shop-pack",group:"economy",title:G("Size of the gem pack","\u0420\u0430\u0437\u043C\u0435\u0440 \u043D\u0430\u0431\u043E\u0440\u0430 \u043A\u0440\u0438\u0441\u0442\u0430\u043B\u043B\u043E\u0432"),for:{sections:["Store"]},question:"How many gems should the paid gem pack hold?",kind:"score",levelTitles:[G("Small","\u041C\u0430\u043B\u0435\u043D\u044C\u043A\u0438\u0439"),G("Normal","\u041E\u0431\u044B\u0447\u043D\u044B\u0439"),G("Big","\u0411\u043E\u043B\u044C\u0448\u043E\u0439"),G("Huge","\u041E\u0433\u0440\u043E\u043C\u043D\u044B\u0439")],levels:["A small pack.","A normal pack.","A big pack.","A huge pack: the best deal."],patches:[{section:"Store",op:"set",path:Lc("kit_gems_pack","Reward.Grant.Standard.Entries[Type=VirtualCurrency].Amount"),range:{min:60,max:200,integer:true}}]},{id:"economy.start-coins",group:"economy",title:G("Coins at the start","\u041C\u043E\u043D\u0435\u0442\u044B \u043D\u0430 \u0441\u0442\u0430\u0440\u0442\u0435"),for:{sections:["Currency"]},question:"How many coins should a new player start with?",kind:"score",levelTitles:[G("A few","\u041C\u0430\u043B\u043E"),G("Some","\u0421\u0440\u0435\u0434\u043D\u0435"),G("Comfortable","\u041A\u043E\u043C\u0444\u043E\u0440\u0442\u043D\u043E"),G("Rich","\u0411\u043E\u0433\u0430\u0442\u043E")],levels:["A few: everything is earned.","Some.","A comfortable start.","A rich start: buy upgrades right away."],patches:[{section:"Currency",op:"set",path:"VirtualCurrencies.CO.Economy.InitialDeposit",range:{min:100,max:3e3,integer:true}}]},{id:"economy.ad-multiplier",group:"economy",title:G("Round reward for an ad","\u041D\u0430\u0433\u0440\u0430\u0434\u0430 \u0440\u0430\u0443\u043D\u0434\u0430 \u0437\u0430 \u0440\u0435\u043A\u043B\u0430\u043C\u0443"),hint:G("How many times the round's coins grow for a rewarded ad (in the app).","\u0412\u043E \u0441\u043A\u043E\u043B\u044C\u043A\u043E \u0440\u0430\u0437 \u0440\u0430\u0441\u0442\u0443\u0442 \u043C\u043E\u043D\u0435\u0442\u044B \u0440\u0430\u0443\u043D\u0434\u0430 \u0437\u0430 \u0440\u0435\u043A\u043B\u0430\u043C\u0443 (\u0432 \u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u0438)."),for:{modules:["kit-game"],sections:["Reward"]},question:"How big should the bonus for watching an ad after a round be?",kind:"score",levelTitles:[G("x2","x2"),G("x3","x3"),G("x4","x4"),G("x5","x5")],levels:["Double.","Triple.","Four times.","Five times."],patches:[{section:"Reward",op:"set",path:"Windows.round.AdMultiplier",range:{min:2,max:5,integer:true}}]},{id:"economy.vip-multiplier",group:"economy",title:G("Round reward for VIP","\u041D\u0430\u0433\u0440\u0430\u0434\u0430 \u0440\u0430\u0443\u043D\u0434\u0430 \u0434\u043B\u044F VIP"),for:{modules:["kit-game"],sections:["Reward"]},question:"How big should the round reward bonus of VIP players be?",kind:"score",levelTitles:[G("x3","x3"),G("x5","x5"),G("x8","x8")],levels:["Triple.","Five times.","Eight times."],patches:[{section:"Reward",op:"set",path:"Windows.round.VipMultiplier",range:{min:3,max:8,integer:true}}]},{id:"economy.vip-price",group:"economy",title:G("Price of VIP","\u0426\u0435\u043D\u0430 VIP"),for:{sections:["Premium"]},question:"How expensive should the VIP pass be, in gems?",kind:"score",levelTitles:[G("Cheap","\u0414\u0451\u0448\u0435\u0432\u043E"),G("Normal","\u041E\u0431\u044B\u0447\u043D\u043E"),G("Expensive","\u0414\u043E\u0440\u043E\u0433\u043E")],levels:["Cheap, an easy first purchase.","Normal.","Expensive, for the most devoted."],patches:[{section:"Premium",op:"set",path:"Definitions.vip.PriceOptions.default.Cost.Standard.Entries[Type=VirtualCurrency].Amount",range:{min:20,max:120,integer:true}}]},{id:"economy.daily-calendar",group:"economy",title:G("Daily login rewards","\u041D\u0430\u0433\u0440\u0430\u0434\u044B \u0437\u0430 \u0432\u0445\u043E\u0434"),for:{sections:["Reward"]},question:"Which daily login reward plan fits this game best?",kind:"choice",options:[bi("gentle","Gentle","\u0421\u043A\u0440\u043E\u043C\u043D\u044B\u0435","Small steady rewards every day: a calm game with a slow economy.",[[["CO",50]],[["CO",60]],[["CO",80]],[["GE",2]],[["CO",100]],[["CO",120]],[["GE",8],["CO",150]]]),bi("standard","Standard","\u041E\u0431\u044B\u0447\u043D\u044B\u0435","Growing coins with gems on day 4 and a big day 7.",[[["CO",100]],[["CO",150]],[["CO",200]],[["GE",5]],[["CO",300]],[["CO",400]],[["GE",20],["CO",500]]]),bi("generous","Generous","\u0429\u0435\u0434\u0440\u044B\u0435","Big rewards every day, gems often: a fast, rewarding economy.",[[["CO",300]],[["GE",5]],[["CO",500]],[["GE",10]],[["CO",800]],[["GE",15]],[["GE",40],["CO",1500]]]),bi("jackpot","Jackpot day 7","\u0414\u0436\u0435\u043A\u043F\u043E\u0442 \u043D\u0430 7-\u0439 \u0434\u0435\u043D\u044C","Small days and a huge jackpot on day 7: come back every day.",[[["CO",50]],[["CO",50]],[["CO",80]],[["CO",80]],[["CO",100]],[["CO",150]],[["GE",60],["CO",3e3]]])]}],No=(e,t,r)=>({section:"Quest",op:"set",path:`Quests.${e}.Reward.Grant.Standard.Entries[Type=VirtualCurrency].Amount`,range:{min:t,max:r,integer:true}}),Es=(e,t,r,o)=>({section:"Quest",op:"set",path:`Quests.${e}.Objectives.${t}.TargetValue`,range:{min:r,max:o,integer:true}}),rp="Definitions.star_festival",Mn=e=>{let[t,r]=e.name,[o,n]=e.token,s=`Collect ${o.toLowerCase()} by playing rounds, shopping and finishing quests. VIP gets a second prize on every milestone.`,a=`\u0421\u043E\u0431\u0438\u0440\u0430\u0439\u0442\u0435 ${n.toLowerCase()} \u0432 \u0440\u0430\u0443\u043D\u0434\u0430\u0445, \u043F\u043E\u043A\u0443\u043F\u043A\u0430\u0445 \u0438 \u0437\u0430\u0434\u0430\u043D\u0438\u044F\u0445. VIP \u043F\u043E\u043B\u0443\u0447\u0430\u0435\u0442 \u0432\u0442\u043E\u0440\u043E\u0439 \u043F\u0440\u0438\u0437 \u043D\u0430 \u043A\u0430\u0436\u0434\u043E\u0439 \u0432\u0435\u0445\u0435.`,i=[["stars_10",10],["stars_50",50],["stars_120",120],["stars_250",250]],h=(m,v)=>({section:"TimedEvent",op:"set",path:`${rp}.${m}`,value:v});return {id:e.id,title:G(t,r),what:e.what,patches:[h("DisplayName",t),h("Description",s),h("Content.DisplayName",t),h("Content.Description",s),h("Content.Token.DisplayName",o),...i.map(([m,v])=>h(`Content.Milestones.${m}.DisplayName`,`${v} ${e.unit[0]}`)),h("Content.Milestones.stars_400.DisplayName",e.crown[0])],translations:{ru:{[t]:r,[s]:a,[o]:n,[e.crown[0]]:e.crown[1],...Object.fromEntries(i.map(([,m])=>[`${m} ${e.unit[0]}`,`${m} ${e.unit[1]}`]))}}}},_c=(e,t,r,o,n,s,a)=>({id:e,title:G(t,r),what:a,patches:[{section:"TimedBoost",op:"set",path:"Definitions.double_rewards.Effect.Value",value:o},{section:"TimedBoost",op:"set",path:"Definitions.double_rewards.DisplayName",value:t},{section:"TimedBoost",op:"set",path:"Definitions.double_rewards.Description",value:n}],translations:{ru:{[t]:r,[n]:s}}}),Vu=[{id:"liveops.event-theme",group:"liveops",title:G("Theme of the weekly event","\u0422\u0435\u043C\u0430 \u043D\u0435\u0434\u0435\u043B\u044C\u043D\u043E\u0433\u043E \u0438\u0432\u0435\u043D\u0442\u0430"),hint:G("Name of the event, its tokens and prizes.","\u041D\u0430\u0437\u0432\u0430\u043D\u0438\u0435 \u0438\u0432\u0435\u043D\u0442\u0430, \u0435\u0433\u043E \u0436\u0435\u0442\u043E\u043D\u043E\u0432 \u0438 \u043F\u0440\u0438\u0437\u043E\u0432."),for:{sections:["TimedEvent"]},question:"Which weekly event theme fits this product best?",kind:"choice",options:[Mn({id:"star-festival",name:["Star festival","\u0417\u0432\u0451\u0437\u0434\u043D\u044B\u0439 \u0444\u0435\u0441\u0442\u0438\u0432\u0430\u043B\u044C"],token:["Festival stars","\u0417\u0432\u0451\u0437\u0434\u044B \u0444\u0435\u0441\u0442\u0438\u0432\u0430\u043B\u044F"],unit:["stars","\u0437\u0432\u0451\u0437\u0434"],crown:["Festival crown","\u041A\u043E\u0440\u043E\u043D\u0430 \u0444\u0435\u0441\u0442\u0438\u0432\u0430\u043B\u044F"],what:"A cheerful festival of stars: fits anything."}),Mn({id:"harvest",name:["Harvest fair","\u042F\u0440\u043C\u0430\u0440\u043A\u0430 \u0443\u0440\u043E\u0436\u0430\u044F"],token:["Golden apples","\u0417\u043E\u043B\u043E\u0442\u044B\u0435 \u044F\u0431\u043B\u043E\u043A\u0438"],unit:["apples","\u044F\u0431\u043B\u043E\u043A"],crown:["Golden basket","\u0417\u043E\u043B\u043E\u0442\u0430\u044F \u043A\u043E\u0440\u0437\u0438\u043D\u0430"],what:"Farm, nature, cozy village, autumn."}),Mn({id:"monster-hunt",name:["Monster hunt","\u041E\u0445\u043E\u0442\u0430 \u043D\u0430 \u043C\u043E\u043D\u0441\u0442\u0440\u043E\u0432"],token:["Trophies","\u0422\u0440\u043E\u0444\u0435\u0438"],unit:["trophies","\u0442\u0440\u043E\u0444\u0435\u0435\u0432"],crown:["Hunter's crown","\u041A\u043E\u0440\u043E\u043D\u0430 \u043E\u0445\u043E\u0442\u043D\u0438\u043A\u0430"],what:"Action, fantasy, battles, monsters."}),Mn({id:"space-week",name:["Space week","\u041A\u043E\u0441\u043C\u0438\u0447\u0435\u0441\u043A\u0430\u044F \u043D\u0435\u0434\u0435\u043B\u044F"],token:["Star shards","\u0417\u0432\u0451\u0437\u0434\u043D\u044B\u0435 \u043E\u0441\u043A\u043E\u043B\u043A\u0438"],unit:["shards","\u043E\u0441\u043A\u043E\u043B\u043A\u043E\u0432"],crown:["Galaxy medal","\u041C\u0435\u0434\u0430\u043B\u044C \u0433\u0430\u043B\u0430\u043A\u0442\u0438\u043A\u0438"],what:"Sci-fi, space, robots, the future."}),Mn({id:"winter",name:["Winter holidays","\u0417\u0438\u043C\u043D\u0438\u0435 \u043F\u0440\u0430\u0437\u0434\u043D\u0438\u043A\u0438"],token:["Snowflakes","\u0421\u043D\u0435\u0436\u0438\u043D\u043A\u0438"],unit:["snowflakes","\u0441\u043D\u0435\u0436\u0438\u043D\u043E\u043A"],crown:["Ice crown","\u041B\u0435\u0434\u044F\u043D\u0430\u044F \u043A\u043E\u0440\u043E\u043D\u0430"],what:"Winter, new year, cozy and festive."}),Mn({id:"beach",name:["Beach party","\u041F\u043B\u044F\u0436\u043D\u0430\u044F \u0432\u0435\u0447\u0435\u0440\u0438\u043D\u043A\u0430"],token:["Seashells","\u0420\u0430\u043A\u0443\u0448\u043A\u0438"],unit:["seashells","\u0440\u0430\u043A\u0443\u0448\u0435\u043A"],crown:["Golden surfboard","\u0417\u043E\u043B\u043E\u0442\u0430\u044F \u0434\u043E\u0441\u043A\u0430"],what:"Summer, the sea, islands, holidays."}),Mn({id:"treasure",name:["Treasure hunt","\u041E\u0445\u043E\u0442\u0430 \u0437\u0430 \u0441\u043E\u043A\u0440\u043E\u0432\u0438\u0449\u0430\u043C\u0438"],token:["Map pieces","\u041A\u0443\u0441\u043E\u0447\u043A\u0438 \u043A\u0430\u0440\u0442\u044B"],unit:["pieces","\u043A\u0443\u0441\u043E\u0447\u043A\u043E\u0432"],crown:["Pirate chest","\u041F\u0438\u0440\u0430\u0442\u0441\u043A\u0438\u0439 \u0441\u0443\u043D\u0434\u0443\u043A"],what:"Pirates, adventure, exploring, mysteries."}),Mn({id:"carnival",name:["Carnival","\u041A\u0430\u0440\u043D\u0430\u0432\u0430\u043B"],token:["Masks","\u041C\u0430\u0441\u043A\u0438"],unit:["masks","\u043C\u0430\u0441\u043E\u043A"],crown:["Carnival crown","\u041A\u043E\u0440\u043E\u043D\u0430 \u043A\u0430\u0440\u043D\u0430\u0432\u0430\u043B\u0430"],what:"Music, dance, a bright party, cartoon fun."})]},{id:"liveops.event-pace",group:"liveops",title:G("Pace of the weekly event","\u0422\u0435\u043C\u043F \u043D\u0435\u0434\u0435\u043B\u044C\u043D\u043E\u0433\u043E \u0438\u0432\u0435\u043D\u0442\u0430"),for:{sections:["TimedEvent"]},question:"How fast should players collect the weekly event tokens by playing rounds?",kind:"score",levelTitles:[G("Slow","\u041C\u0435\u0434\u043B\u0435\u043D\u043D\u043E"),G("Normal","\u041E\u0431\u044B\u0447\u043D\u043E"),G("Fast","\u0411\u044B\u0441\u0442\u0440\u043E"),G("Very fast","\u041E\u0447\u0435\u043D\u044C \u0431\u044B\u0441\u0442\u0440\u043E")],levels:["Slow: the top prize is for the most devoted.","Normal.","Fast.","Very fast: most players reach the top."],patches:[{section:"TimedEvent",op:"set",path:`${rp}.Content.TokenSources[SourceType=CustomAction].BaseWeight`,range:{min:2,max:10,integer:true}}]},{id:"liveops.boost-power",group:"liveops",title:G("Power of the reward boost","\u0421\u0438\u043B\u0430 \u0431\u0443\u0441\u0442\u0430 \u043D\u0430\u0433\u0440\u0430\u0434"),for:{sections:["TimedBoost"]},question:"How strong should the paid reward boost be?",kind:"choice",options:[_c("x1-5","Rewards x1.5","\u041D\u0430\u0433\u0440\u0430\u0434\u044B x1.5",1.5,"Every reward is 1.5 times bigger for an hour.","\u041A\u0430\u0436\u0434\u0430\u044F \u043D\u0430\u0433\u0440\u0430\u0434\u0430 \u0432 1.5 \u0440\u0430\u0437\u0430 \u0431\u043E\u043B\u044C\u0448\u0435 \u0432 \u0442\u0435\u0447\u0435\u043D\u0438\u0435 \u0447\u0430\u0441\u0430.","A gentle boost: a slow, balanced economy."),_c("x2","Double rewards","\u0414\u0432\u043E\u0439\u043D\u044B\u0435 \u043D\u0430\u0433\u0440\u0430\u0434\u044B",2,"Every reward is doubled for an hour.","\u041A\u0430\u0436\u0434\u0430\u044F \u043D\u0430\u0433\u0440\u0430\u0434\u0430 \u0443\u0434\u0432\u043E\u0435\u043D\u0430 \u043D\u0430 \u0447\u0430\u0441.","The classic double: fits most games."),_c("x3","Triple rewards","\u0422\u0440\u043E\u0439\u043D\u044B\u0435 \u043D\u0430\u0433\u0440\u0430\u0434\u044B",3,"Every reward is tripled for an hour.","\u041A\u0430\u0436\u0434\u0430\u044F \u043D\u0430\u0433\u0440\u0430\u0434\u0430 \u0443\u0442\u0440\u043E\u0435\u043D\u0430 \u043D\u0430 \u0447\u0430\u0441.","A big boost: a fast, generous economy.")]},{id:"liveops.quest-effort",group:"liveops",title:G("Effort of daily quests","\u0421\u043B\u043E\u0436\u043D\u043E\u0441\u0442\u044C \u0435\u0436\u0435\u0434\u043D\u0435\u0432\u043D\u044B\u0445 \u0437\u0430\u0434\u0430\u043D\u0438\u0439"),for:{sections:["Quest"]},question:"How much play should the daily quests ask for?",kind:"score",levelTitles:[G("A few minutes","\u041F\u0430\u0440\u0430 \u043C\u0438\u043D\u0443\u0442"),G("Short","\u041A\u043E\u0440\u043E\u0442\u043A\u043E"),G("Normal","\u041E\u0431\u044B\u0447\u043D\u043E"),G("Long","\u0414\u043E\u043B\u0433\u043E")],levels:["Very little: done in a few minutes.","A short session.","A normal session.","A long session: for devoted players."],patches:[Es("daily_play","play",1,8),Es("daily_earn","earn",50,500),Es("kit_daily_coins","coins",100,1500),Es("kit_daily_time","seconds",180,1800),Es("kit_daily_levels","levels",1,6)]},{id:"liveops.quest-rewards",group:"liveops",title:G("Rewards of daily quests","\u041D\u0430\u0433\u0440\u0430\u0434\u044B \u0437\u0430 \u0437\u0430\u0434\u0430\u043D\u0438\u044F"),for:{sections:["Quest"]},question:"How generous should the rewards of the daily quests be?",kind:"score",levelTitles:[G("Small","\u041C\u0430\u043B\u0435\u043D\u044C\u043A\u0438\u0435"),G("Normal","\u041E\u0431\u044B\u0447\u043D\u044B\u0435"),G("Big","\u0411\u043E\u043B\u044C\u0448\u0438\u0435"),G("Very big","\u041E\u0447\u0435\u043D\u044C \u0431\u043E\u043B\u044C\u0448\u0438\u0435")],levels:["Small.","Normal.","Big.","Very big."],patches:[No("daily_visit",10,100),No("daily_earn",30,300),No("daily_play",80,600),No("kit_daily_coins",50,500),No("kit_daily_time",50,500),No("kit_daily_levels",5,40)]},{id:"liveops.leaderboard",group:"liveops",title:G("Weekly leaderboard","\u041D\u0435\u0434\u0435\u043B\u044C\u043D\u044B\u0439 \u0440\u0435\u0439\u0442\u0438\u043D\u0433"),for:{sections:["Leaderboard"]},question:"Is competing on a weekly leaderboard a good fit for this product?",kind:"noul",yes:"Yes: players like to compete and compare their scores.",no:"No: it is a calm, personal or creative product without competition.",onYes:[{section:"Leaderboard",op:"set",path:"Definitions.weekly_score.IsEnabled",value:true}],onNo:[{section:"Leaderboard",op:"set",path:"Definitions.weekly_score.IsEnabled",value:false}]}],Wr=(e,t,r,o)=>({id:e,title:G(t,r),what:o,patches:[{section:"Currency",op:"set",path:"VirtualCurrencies.CO.DisplayName",value:t},{section:"GameSpec",op:"set",path:"texts.'res.coins'",value:{en:t,ru:r}}],translations:{ru:{[t]:r}}}),wn=(e,t,r,o)=>({id:e,title:G(t,r),what:o,patches:[{section:"Currency",op:"set",path:"VirtualCurrencies.GE.DisplayName",value:t}],translations:{ru:{[t]:r}}}),Gu=[{id:"texts.coin-name",group:"texts",title:G("Name of the coins","\u041D\u0430\u0437\u0432\u0430\u043D\u0438\u0435 \u043C\u043E\u043D\u0435\u0442"),for:{sections:["Currency"]},question:"What should the game's soft currency (earned in rounds) be called?",kind:"choice",options:[Wr("coins","Coins","\u041C\u043E\u043D\u0435\u0442\u044B","Plain coins: fits anything."),Wr("gold","Gold","\u0417\u043E\u043B\u043E\u0442\u043E","Gold: fantasy, medieval, pirates, treasure."),Wr("credits","Credits","\u041A\u0440\u0435\u0434\u0438\u0442\u044B","Credits: sci-fi, space, future, robots."),Wr("cash","Cash","\u041D\u0430\u043B\u0438\u0447\u043D\u044B\u0435","Cash: business, city, modern life, tycoon."),Wr("scrap","Scrap","\u0425\u043B\u0430\u043C","Scrap: post-apocalypse, survival, junk."),Wr("candies","Candies","\u041A\u043E\u043D\u0444\u0435\u0442\u044B","Candies: sweets, kids, cozy cartoon."),Wr("stars","Stars","\u0417\u0432\u0451\u0437\u0434\u044B","Stars: kids, space, dreams, music."),Wr("bones","Bones","\u041A\u043E\u0441\u0442\u0438","Bones: pets, dogs, dinosaurs, halloween."),Wr("shells","Shells","\u0420\u0430\u043A\u0443\u0448\u043A\u0438","Shells: the sea, islands, mermaids."),Wr("leaves","Leaves","\u041B\u0438\u0441\u0442\u044C\u044F","Leaves: nature, forest, farm, elves.")]},{id:"texts.gem-name",group:"texts",title:G("Name of the gems","\u041D\u0430\u0437\u0432\u0430\u043D\u0438\u0435 \u043A\u0440\u0438\u0441\u0442\u0430\u043B\u043B\u043E\u0432"),for:{sections:["Currency"]},question:"What should the game's premium currency be called?",kind:"choice",options:[wn("gems","Gems","\u041A\u0440\u0438\u0441\u0442\u0430\u043B\u043B\u044B","Gems: fits anything."),wn("diamonds","Diamonds","\u0410\u043B\u043C\u0430\u0437\u044B","Diamonds: luxury, mining, treasure."),wn("rubies","Rubies","\u0420\u0443\u0431\u0438\u043D\u044B","Rubies: fantasy, royal, magic."),wn("crystals","Energy cells","\u042D\u043D\u0435\u0440\u0433\u043E\u044F\u0447\u0435\u0439\u043A\u0438","Energy cells: sci-fi, robots, space."),wn("pearls","Pearls","\u0416\u0435\u043C\u0447\u0443\u0433","Pearls: the sea, mermaids, elegance."),wn("orbs","Orbs","\u0421\u0444\u0435\u0440\u044B","Magic orbs: wizards, spells, mystery."),wn("tokens","Tokens","\u0416\u0435\u0442\u043E\u043D\u044B","Tokens: arcade, casino, retro."),wn("hearts","Hearts","\u0421\u0435\u0440\u0434\u0435\u0447\u043A\u0438","Hearts: cute, love, pets, kids.")]}],Ku=new Set(["Look","GameSpec"]),xi=e=>e?.map(t=>Ku.has(t.section)?t:{...t,ifExists:true}),Fu=e=>{switch(e.kind){case "choice":return e.options?{...e,options:e.options.map(t=>({...t,patches:xi(t.patches)}))}:e;case "score":return {...e,patches:xi(e.patches)};case "noul":return {...e,onYes:xi(e.onYes),...e.onNo?{onNo:xi(e.onNo)}:{}}}},np=[...zu,...Bu,...Hu,...ju,...Vu,...Gu].map(Fu),qu={version:tp,knobs:np,lists:Sc};var Rc=/^[a-z0-9][a-z0-9_.-]{0,63}$/,Uu=new Set(["set","merge","unset","add","remove"]),Xu=/[\u2013\u2014]/;function ki(e,t,r,o=false){(!e||e.length===0)&&r.push(`${t}: no patches`);for(let[n,s]of (e??[]).entries())(!s.section||!/^[A-Z][A-Za-z0-9]*$/.test(s.section))&&r.push(`${t}.patches[${n}]: section "${s.section}"`),Uu.has(s.op)||r.push(`${t}.patches[${n}]: op "${s.op}"`),mi(s.path)===null&&r.push(`${t}.patches[${n}]: path "${s.path}"`),o&&s.op==="set"&&!s.range&&s.value===void 0&&r.push(`${t}.patches[${n}]: a score patch needs a range`),s.range&&!(Number.isFinite(s.range.min)&&Number.isFinite(s.range.max))&&r.push(`${t}.patches[${n}]: range`);}function op(e,t,r){e.length===0&&r.push(`${t}: no options`),e.length>255&&r.push(`${t}: ${e.length} options, the decision model takes ${255}`);let o=new Set;for(let n of e)Rc.test(n.id)||r.push(`${t}: option id "${n.id}"`),o.has(n.id)&&r.push(`${t}: option "${n.id}" twice`),o.add(n.id),n.title?.en||r.push(`${t}.${n.id}: no English title`),n.what||r.push(`${t}.${n.id}: no description for the decision model`),ki(n.patches,`${t}.${n.id}`,r);}function Ac(e,t){if(typeof e=="string")t.push(e);else if(Array.isArray(e))for(let r of e)Ac(r,t);else if(e&&typeof e=="object")for(let r of Object.values(e))Ac(r,t);}function Zu(e){let t=[];for(let[n,s]of Object.entries(e.lists))Rc.test(n)||t.push(`list "${n}": id`),op(s,`list ${n}`,t);let r=new Set;for(let n of e.knobs){let s=`knob ${n.id}`;Rc.test(n.id)||t.push(`${s}: id`),r.has(n.id)&&t.push(`${s}: twice`),r.add(n.id),n.title?.en||t.push(`${s}: no English title`),n.question||t.push(`${s}: no question`),n.kind==="choice"?(n.list&&n.options&&t.push(`${s}: options OR a list, not both`),n.list&&!e.lists[n.list]&&t.push(`${s}: no list "${n.list}"`),n.list||op(n.options??[],s,t)):n.kind==="score"?((n.levels.length<2||n.levels.length>10)&&t.push(`${s}: ${n.levels.length} levels, 2..${10}`),n.levelTitles?.length!==n.levels.length?t.push(`${s}: levelTitles must name every level`):n.levelTitles.forEach((a,i)=>{(!a.en||!a.ru)&&t.push(`${s}: level ${i} needs en and ru titles`);}),ki(n.patches,s,t,true)):n.kind==="noul"?((!n.yes||!n.no)&&t.push(`${s}: yes and no`),ki(n.onYes,s,t),n.onNo&&ki(n.onNo,`${s}.no`,t)):t.push(`${s}: kind`);}let o=[];Ac(e,o);for(let n of o)Xu.test(n)&&t.push(`a long dash in "${n.slice(0,60)}"`);return t}
|
|
3
|
+
exports.ABILITIES=Tl;exports.ART=Ws;exports.ASSET_PACKS=Fn;exports.BACKGROUND_OPTIONS=Yf;exports.BLOCKS=dn;exports.BOSS_DEFEATED=Wl;exports.BOSS_SPAWNED=Oa;exports.BRANCH_LEVEL=Gl;exports.Body=sr;exports.Bullet=nn;exports.CHAPTERS=Aa;exports.CORE_EFFECTS=Nc;exports.DECISION_MAX_LEVELS=Vf;exports.DECISION_MAX_OPTIONS=jf;exports.DEFAULT_CAST=Os;exports.DEFAULT_LOOK=Di;exports.DEFAULT_PALETTE=Ri;exports.DEFAULT_REWARDS=Hc;exports.DEMO_SPEC=Mu;exports.Drop=ar;exports.EFFECTS=Bo;exports.ENEMIES=Bn;exports.ENGINES=Ds;exports.ENTRY_ID_RE=Oc;exports.ExprError=cr;exports.FOES=tn;exports.FUNCTIONS=$i;exports.FX_TOPIC=Oi;exports.Foe=We;exports.GIVE_UP=rr;exports.Gem=yn;exports.HEROES=ko;exports.HERO_LOOK_OPTIONS=Zf;exports.INPUT_TOPIC=zt;exports.Jumper=wr;exports.KIT_PALETTES=Xf;exports.KNOBS=np;exports.KNOB_CATALOG=qu;exports.KNOB_CATALOG_VERSION=tp;exports.KNOB_LISTS=Sc;exports.KNOWN_SYSTEMS=zc;exports.LEVELS_PER_WORLD=On;exports.LEVEL_CLEARED=Cl;exports.LEVEL_MAPS=Ul;exports.LEVEL_UP=Nl;exports.LINKS=Wo;exports.LOOK_RUNTIME_IDS=Nu;exports.M3_CHARACTER=Qi;exports.M3_ELEMENTS=rs;exports.M3_ENEMIES=Fi;exports.M3_HEROES=so;exports.M3_LEVELS=Ys;exports.M3_LEVELS_PER_WORLD=ts;exports.M3_LEVEL_DEFS=Qs;exports.M3_META=wd;exports.M3_META_STATS=Yi;exports.M3_OBSTACLES=Zr;exports.M3_PIECES=Ki;exports.M3_SKILLS=qi;exports.M3_SPECIALS=Rn;exports.M3_WORLDS=vd;exports.M3_WORLD_STARS=Ui;exports.MAPS=Kl;exports.MAP_COLS=Br;exports.MAP_ROWS=Hr;exports.MAX_LEVEL=fr;exports.MAX_PASSIVES=_a;exports.MAX_WEAPONS=La;exports.META_CHARACTER=Il;exports.META_STATS=Pl;exports.MG_BOARDS=An;exports.MG_CHAINS=as;exports.MG_CHARACTER=kl;exports.MG_COLS=Cd;exports.MG_HEROES=fo;exports.MG_LEVELS=ma;exports.MG_LEVELS_PER_WORLD=co;exports.MG_LEVEL_DEFS=ua;exports.MG_META=Nd;exports.MG_META_STATS=vl;exports.MG_OBSTACLES=gr;exports.MG_REVIVE_ENERGY=ga;exports.MG_ROWS=Pd;exports.MG_SKILLS=gl;exports.MG_SPECIAL_ITEMS=ul;exports.MG_WORLDS=Id;exports.MG_WORLD_STARS=bl;exports.MergeItem=ls;exports.Missile=Hn;exports.OBSTACLE_KINDS=Ks;exports.Order=Zd;exports.PASSIVES=bo;exports.PASSIVE_IDS=Ra;exports.PIECE_COLORS=fd;exports.PLATFORMER_CHARACTER=Dl;exports.PLATFORMER_HEROES=go;exports.PLATFORMER_LEVELS=wa;exports.PLATFORMER_META=tf;exports.PLATFORMER_META_STATS=Ol;exports.PLATFORM_LINKS=pi;exports.PLATFORM_PACKS=Co;exports.PLATFORM_PRESETS=Wf;exports.POWERS=Rr;exports.POWER_IDS=Yo;exports.PRESETS=fn;exports.REROLL_GEMS=af;exports.REVIVE=tr;exports.REVIVE_GEMS=sf;exports.REVIVE_OFFER=er;exports.ROOMS=Ma;exports.ROOM_ROWS=Gt;exports.ROUND_ENDED=Xt;exports.ROUND_OVER=Ut;exports.ROUND_STARTED=qt;exports.RUNNER_CHARACTER=ji;exports.RUNNER_HEROES=no;exports.RUNNER_LEVELS=Qo;exports.RUNNER_META=ud;exports.RUNNER_META_STATS=Vi;exports.Raider=Oe;exports.RoadItem=_t;exports.Runner=Xr;exports.SELL_SHARE=ps;exports.SHOW_START=Zt;exports.SOUND_SET_OPTIONS=ep;exports.SPEC_VERSION=Vo;exports.SPELLS=$o;exports.START_ROUND=Wi;exports.SURVIVORS_META=lf;exports.Shot=zn;exports.Soldier=Ar;exports.Spot=ja;exports.Survivor=Da;exports.TD_CHARACTER=Ql;exports.TD_HEROES=So;exports.TD_LEVELS=ms;exports.TD_LEVELS_PER_WORLD=Nr;exports.TD_LIVES=mf;exports.TD_META=yf;exports.TD_META_STATS=Yl;exports.TD_REVIVE_LIVES=Ba;exports.TD_WORLDS=Fl;exports.TD_WORLD_STARS=ql;exports.TOWERS=Pa;exports.TY_BUSINESSES=gs;exports.TY_CHARACTER=ac;exports.TY_EVENTS=_o;exports.TY_HEROES=Ro;exports.TY_LEVELS=Lo;exports.TY_LEVELS_PER_WORLD=Ao;exports.TY_LEVEL_DEFS=jn;exports.TY_META=Ef;exports.TY_META_STATS=ic;exports.TY_MILESTONES=bs;exports.TY_REVIVE_SECONDS=Xa;exports.TY_SKILLS=rc;exports.TY_UPGRADES=Fa;exports.TY_WORLDS=Mf;exports.TY_WORLD_STARS=nc;exports.Thing=ut;exports.Tower=kr;exports.Transform=F;exports.TyManager=hc;exports.UI_THEMES=Uf;exports.UPGRADE_PICK=Bl;exports.UPGRADE_PICKED=zl;exports.UPGRADE_REROLL=Hl;exports.VIEW_RESIZED_TOPIC=Ft;exports.Visual=le;exports.WAVE_STARTED=ec;exports.WEAPONS=Ir;exports.WEAPON_IDS=Pn;exports.WORLDS=_l;exports.WORLD_STARS=Rl;exports.World=zo;exports.abilitiesFor=Ea;exports.act=Ge;exports.applyLink=xp;exports.applyPatches=_u;exports.artAspect=zh;exports.artDocument=Bh;exports.attachRules=Ei;exports.boardOf=un;exports.buildFromVar=df;exports.buildToVar=jl;exports.cellAt=Ur;exports.cellCenter=st;exports.chapterOf=xo;exports.checkEconomy=Li;exports.checkExpr=Mi;exports.checkRules=As;exports.compileExpr=Er;exports.contentOf=Sr;exports.cozyPack=gc;exports.createFixedStepper=up;exports.createKitRegistry=Lp;exports.createRegistry=Ls;exports.createRng=_s;exports.defenseBoostsLink=Mc;exports.defineComponent=ve;exports.defineKind=Vr;exports.enemyOf=pr;exports.evalNumber=wi;exports.fantasyPack=mc;exports.findMatches=io;exports.fx=K;exports.hasArt=Nh;exports.hasErrors=Si;exports.hasMove=ol;exports.heroCharacterOf=Of;exports.heroUpgradeLink=kc;exports.laneRunnerBlock=qs;exports.levelOf=to;exports.m3EnemyOf=os;exports.m3LevelOf=ao;exports.m3SkillOf=Xs;exports.m3StarsToEnter=Xi;exports.match3Block=da;exports.match3Preset=zf;exports.mergeBlock=va;exports.mergePalette=Ti;exports.mergePreset=Bf;exports.metersOf=ro;exports.mgChainOf=Cr;exports.mgLevelOf=po;exports.mgSkillOf=ha;exports.mgSpecialOf=Jr;exports.mgStarsFor=ya;exports.mgStarsToEnter=xl;exports.migrateSpec=Wc;exports.mirrored=Mo;exports.offerFromVar=ff;exports.offerToVar=Vl;exports.packName=bp;exports.parseKnobPath=mi;exports.patchTargets=Au;exports.patchValue=Kf;exports.placeBackdrop=Bt;exports.platformerBlock=Sa;exports.platformerLevelOf=yo;exports.platformerPreset=Pf;exports.postApocalypsePack=bc;exports.puzzleCityLink=vc;exports.registerCoreEffects=Ho;exports.registerPlatformKit=$u;exports.resolveColor=Ai;exports.resolveParams=Ts;exports.roundBlock=Gs;exports.runnerCollectionLink=$c;exports.runnerPreset=Cf;exports.sciFiPack=yc;exports.scrollBackdrop=Zo;exports.setPose=at;exports.shortCash=vr;exports.specForPreset=wu;exports.starsToEnter=Al;exports.startMode=_p;exports.survivorsBlock=Ca;exports.survivorsPreset=If;exports.tdLevelOf=Eo;exports.tdStarsFor=za;exports.tdStarsToEnter=Zl;exports.tdWavesOf=Xl;exports.towerArt=Ia;exports.towerDefenseBlock=Va;exports.towerDefensePreset=Nf;exports.towerOf=zr;exports.towerSpent=us;exports.towerStats=hs;exports.traceMap=wo;exports.trackControls=Jn;exports.tyBotTimeOf=ci;exports.tyBusinessOf=Wn;exports.tyEventOf=xf;exports.tyLevelOf=Do;exports.tySkillOf=qa;exports.tyStarsFor=Ua;exports.tyStarsToEnter=oc;exports.tycoonBlock=di;exports.tycoonPreset=Hf;exports.tycoonStateOf=Tf;exports.validateKnobCatalog=Zu;exports.validateSpec=wp;exports.viewOf=Be;
|