// Generated by Construct 2, the HTML5 game and app creator :: http://www.scirra.com var cr = {}; cr.plugins_ = {}; cr.behaviors = {}; if (typeof Object.getPrototypeOf !== "function") { if (typeof "test".__proto__ === "object") { Object.getPrototypeOf = function(object) { return object.__proto__; }; } else { Object.getPrototypeOf = function(object) { return object.constructor.prototype; }; } } (function(){ cr.logexport = function (msg) { if (window.console && window.console.log) window.console.log(msg); }; cr.logerror = function (msg) { if (window.console && window.console.error) window.console.error(msg); }; cr.seal = function(x) { return x; }; cr.freeze = function(x) { return x; }; cr.is_undefined = function (x) { return typeof x === "undefined"; }; cr.is_number = function (x) { return typeof x === "number"; }; cr.is_string = function (x) { return typeof x === "string"; }; cr.isPOT = function (x) { return x > 0 && ((x - 1) & x) === 0; }; cr.nextHighestPowerOfTwo = function(x) { --x; for (var i = 1; i < 32; i <<= 1) { x = x | x >> i; } return x + 1; } cr.abs = function (x) { return (x < 0 ? -x : x); }; cr.max = function (a, b) { return (a > b ? a : b); }; cr.min = function (a, b) { return (a < b ? a : b); }; cr.PI = Math.PI; cr.round = function (x) { return (x + 0.5) | 0; }; cr.floor = function (x) { if (x >= 0) return x | 0; else return (x | 0) - 1; // correctly round down when negative }; cr.ceil = function (x) { var f = x | 0; return (f === x ? f : f + 1); }; function Vector2(x, y) { this.x = x; this.y = y; cr.seal(this); }; Vector2.prototype.offset = function (px, py) { this.x += px; this.y += py; return this; }; Vector2.prototype.mul = function (px, py) { this.x *= px; this.y *= py; return this; }; cr.vector2 = Vector2; cr.segments_intersect = function(a1x, a1y, a2x, a2y, b1x, b1y, b2x, b2y) { var max_ax, min_ax, max_ay, min_ay, max_bx, min_bx, max_by, min_by; if (a1x < a2x) { min_ax = a1x; max_ax = a2x; } else { min_ax = a2x; max_ax = a1x; } if (b1x < b2x) { min_bx = b1x; max_bx = b2x; } else { min_bx = b2x; max_bx = b1x; } if (max_ax < min_bx || min_ax > max_bx) return false; if (a1y < a2y) { min_ay = a1y; max_ay = a2y; } else { min_ay = a2y; max_ay = a1y; } if (b1y < b2y) { min_by = b1y; max_by = b2y; } else { min_by = b2y; max_by = b1y; } if (max_ay < min_by || min_ay > max_by) return false; var dpx = b1x - a1x + b2x - a2x; var dpy = b1y - a1y + b2y - a2y; var qax = a2x - a1x; var qay = a2y - a1y; var qbx = b2x - b1x; var qby = b2y - b1y; var d = cr.abs(qay * qbx - qby * qax); var la = qbx * dpy - qby * dpx; if (cr.abs(la) > d) return false; var lb = qax * dpy - qay * dpx; return cr.abs(lb) <= d; }; function Rect(left, top, right, bottom) { this.set(left, top, right, bottom); cr.seal(this); }; Rect.prototype.set = function (left, top, right, bottom) { this.left = left; this.top = top; this.right = right; this.bottom = bottom; }; Rect.prototype.copy = function (r) { this.left = r.left; this.top = r.top; this.right = r.right; this.bottom = r.bottom; }; Rect.prototype.width = function () { return this.right - this.left; }; Rect.prototype.height = function () { return this.bottom - this.top; }; Rect.prototype.offset = function (px, py) { this.left += px; this.top += py; this.right += px; this.bottom += py; return this; }; Rect.prototype.normalize = function () { var temp = 0; if (this.left > this.right) { temp = this.left; this.left = this.right; this.right = temp; } if (this.top > this.bottom) { temp = this.top; this.top = this.bottom; this.bottom = temp; } }; Rect.prototype.intersects_rect = function (rc) { return !(rc.right < this.left || rc.bottom < this.top || rc.left > this.right || rc.top > this.bottom); }; Rect.prototype.intersects_rect_off = function (rc, ox, oy) { return !(rc.right + ox < this.left || rc.bottom + oy < this.top || rc.left + ox > this.right || rc.top + oy > this.bottom); }; Rect.prototype.contains_pt = function (x, y) { return (x >= this.left && x <= this.right) && (y >= this.top && y <= this.bottom); }; Rect.prototype.equals = function (r) { return this.left === r.left && this.top === r.top && this.right === r.right && this.bottom === r.bottom; }; cr.rect = Rect; function Quad() { this.tlx = 0; this.tly = 0; this.trx = 0; this.try_ = 0; // is a keyword otherwise! this.brx = 0; this.bry = 0; this.blx = 0; this.bly = 0; cr.seal(this); }; Quad.prototype.set_from_rect = function (rc) { this.tlx = rc.left; this.tly = rc.top; this.trx = rc.right; this.try_ = rc.top; this.brx = rc.right; this.bry = rc.bottom; this.blx = rc.left; this.bly = rc.bottom; }; Quad.prototype.set_from_rotated_rect = function (rc, a) { if (a === 0) { this.set_from_rect(rc); } else { var sin_a = Math.sin(a); var cos_a = Math.cos(a); var left_sin_a = rc.left * sin_a; var top_sin_a = rc.top * sin_a; var right_sin_a = rc.right * sin_a; var bottom_sin_a = rc.bottom * sin_a; var left_cos_a = rc.left * cos_a; var top_cos_a = rc.top * cos_a; var right_cos_a = rc.right * cos_a; var bottom_cos_a = rc.bottom * cos_a; this.tlx = left_cos_a - top_sin_a; this.tly = top_cos_a + left_sin_a; this.trx = right_cos_a - top_sin_a; this.try_ = top_cos_a + right_sin_a; this.brx = right_cos_a - bottom_sin_a; this.bry = bottom_cos_a + right_sin_a; this.blx = left_cos_a - bottom_sin_a; this.bly = bottom_cos_a + left_sin_a; } }; Quad.prototype.offset = function (px, py) { this.tlx += px; this.tly += py; this.trx += px; this.try_ += py; this.brx += px; this.bry += py; this.blx += px; this.bly += py; return this; }; var minresult = 0; var maxresult = 0; function minmax4(a, b, c, d) { if (a < b) { if (c < d) { if (a < c) minresult = a; else minresult = c; if (b > d) maxresult = b; else maxresult = d; } else { if (a < d) minresult = a; else minresult = d; if (b > c) maxresult = b; else maxresult = c; } } else { if (c < d) { if (b < c) minresult = b; else minresult = c; if (a > d) maxresult = a; else maxresult = d; } else { if (b < d) minresult = b; else minresult = d; if (a > c) maxresult = a; else maxresult = c; } } }; Quad.prototype.bounding_box = function (rc) { minmax4(this.tlx, this.trx, this.brx, this.blx); rc.left = minresult; rc.right = maxresult; minmax4(this.tly, this.try_, this.bry, this.bly); rc.top = minresult; rc.bottom = maxresult; }; Quad.prototype.contains_pt = function (x, y) { var tlx = this.tlx; var tly = this.tly; var v0x = this.trx - tlx; var v0y = this.try_ - tly; var v1x = this.brx - tlx; var v1y = this.bry - tly; var v2x = x - tlx; var v2y = y - tly; var dot00 = v0x * v0x + v0y * v0y var dot01 = v0x * v1x + v0y * v1y var dot02 = v0x * v2x + v0y * v2y var dot11 = v1x * v1x + v1y * v1y var dot12 = v1x * v2x + v1y * v2y var invDenom = 1.0 / (dot00 * dot11 - dot01 * dot01); var u = (dot11 * dot02 - dot01 * dot12) * invDenom; var v = (dot00 * dot12 - dot01 * dot02) * invDenom; if ((u >= 0.0) && (v > 0.0) && (u + v < 1)) return true; v0x = this.blx - tlx; v0y = this.bly - tly; var dot00 = v0x * v0x + v0y * v0y var dot01 = v0x * v1x + v0y * v1y var dot02 = v0x * v2x + v0y * v2y invDenom = 1.0 / (dot00 * dot11 - dot01 * dot01); u = (dot11 * dot02 - dot01 * dot12) * invDenom; v = (dot00 * dot12 - dot01 * dot02) * invDenom; return (u >= 0.0) && (v > 0.0) && (u + v < 1); }; Quad.prototype.at = function (i, xory) { if (xory) { switch (i) { case 0: return this.tlx; case 1: return this.trx; case 2: return this.brx; case 3: return this.blx; case 4: return this.tlx; default: return this.tlx; } } else { switch (i) { case 0: return this.tly; case 1: return this.try_; case 2: return this.bry; case 3: return this.bly; case 4: return this.tly; default: return this.tly; } } }; Quad.prototype.midX = function () { return (this.tlx + this.trx + this.brx + this.blx) / 4; }; Quad.prototype.midY = function () { return (this.tly + this.try_ + this.bry + this.bly) / 4; }; Quad.prototype.intersects_segment = function (x1, y1, x2, y2) { if (this.contains_pt(x1, y1) || this.contains_pt(x2, y2)) return true; var a1x, a1y, a2x, a2y; var i; for (i = 0; i < 4; i++) { a1x = this.at(i, true); a1y = this.at(i, false); a2x = this.at(i + 1, true); a2y = this.at(i + 1, false); if (cr.segments_intersect(x1, y1, x2, y2, a1x, a1y, a2x, a2y)) return true; } return false; }; Quad.prototype.intersects_quad = function (rhs) { var midx = rhs.midX(); var midy = rhs.midY(); if (this.contains_pt(midx, midy)) return true; midx = this.midX(); midy = this.midY(); if (rhs.contains_pt(midx, midy)) return true; var a1x, a1y, a2x, a2y, b1x, b1y, b2x, b2y; var i, j; for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { a1x = this.at(i, true); a1y = this.at(i, false); a2x = this.at(i + 1, true); a2y = this.at(i + 1, false); b1x = rhs.at(j, true); b1y = rhs.at(j, false); b2x = rhs.at(j + 1, true); b2y = rhs.at(j + 1, false); if (cr.segments_intersect(a1x, a1y, a2x, a2y, b1x, b1y, b2x, b2y)) return true; } } return false; }; cr.quad = Quad; cr.RGB = function (red, green, blue) { return Math.max(Math.min(red, 255), 0) | (Math.max(Math.min(green, 255), 0) << 8) | (Math.max(Math.min(blue, 255), 0) << 16); }; cr.GetRValue = function (rgb) { return rgb & 0xFF; }; cr.GetGValue = function (rgb) { return (rgb & 0xFF00) >> 8; }; cr.GetBValue = function (rgb) { return (rgb & 0xFF0000) >> 16; }; cr.shallowCopy = function (a, b, allowOverwrite) { var attr; for (attr in b) { if (b.hasOwnProperty(attr)) { ; a[attr] = b[attr]; } } return a; }; cr.arrayRemove = function (arr, index) { var i, len; index = cr.floor(index); if (index < 0 || index >= arr.length) return; // index out of bounds for (i = index, len = arr.length - 1; i < len; i++) arr[i] = arr[i + 1]; cr.truncateArray(arr, len); }; cr.truncateArray = function (arr, index) { arr.length = index; }; cr.clearArray = function (arr) { cr.truncateArray(arr, 0); }; cr.shallowAssignArray = function (dest, src) { cr.clearArray(dest); var i, len; for (i = 0, len = src.length; i < len; ++i) dest[i] = src[i]; }; cr.appendArray = function (a, b) { a.push.apply(a, b); }; cr.fastIndexOf = function (arr, item) { var i, len; for (i = 0, len = arr.length; i < len; ++i) { if (arr[i] === item) return i; } return -1; }; cr.arrayFindRemove = function (arr, item) { var index = cr.fastIndexOf(arr, item); if (index !== -1) cr.arrayRemove(arr, index); }; cr.clamp = function(x, a, b) { if (x < a) return a; else if (x > b) return b; else return x; }; cr.to_radians = function(x) { return x / (180.0 / cr.PI); }; cr.to_degrees = function(x) { return x * (180.0 / cr.PI); }; cr.clamp_angle_degrees = function (a) { a %= 360; // now in (-360, 360) range if (a < 0) a += 360; // now in [0, 360) range return a; }; cr.clamp_angle = function (a) { a %= 2 * cr.PI; // now in (-2pi, 2pi) range if (a < 0) a += 2 * cr.PI; // now in [0, 2pi) range return a; }; cr.to_clamped_degrees = function (x) { return cr.clamp_angle_degrees(cr.to_degrees(x)); }; cr.to_clamped_radians = function (x) { return cr.clamp_angle(cr.to_radians(x)); }; cr.angleTo = function(x1, y1, x2, y2) { var dx = x2 - x1; var dy = y2 - y1; return Math.atan2(dy, dx); }; cr.angleDiff = function (a1, a2) { if (a1 === a2) return 0; var s1 = Math.sin(a1); var c1 = Math.cos(a1); var s2 = Math.sin(a2); var c2 = Math.cos(a2); var n = s1 * s2 + c1 * c2; if (n >= 1) return 0; if (n <= -1) return cr.PI; return Math.acos(n); }; cr.angleRotate = function (start, end, step) { var ss = Math.sin(start); var cs = Math.cos(start); var se = Math.sin(end); var ce = Math.cos(end); if (Math.acos(ss * se + cs * ce) > step) { if (cs * se - ss * ce > 0) return cr.clamp_angle(start + step); else return cr.clamp_angle(start - step); } else return cr.clamp_angle(end); }; cr.angleClockwise = function (a1, a2) { var s1 = Math.sin(a1); var c1 = Math.cos(a1); var s2 = Math.sin(a2); var c2 = Math.cos(a2); return c1 * s2 - s1 * c2 <= 0; }; cr.rotatePtAround = function (px, py, a, ox, oy, getx) { if (a === 0) return getx ? px : py; var sin_a = Math.sin(a); var cos_a = Math.cos(a); px -= ox; py -= oy; var left_sin_a = px * sin_a; var top_sin_a = py * sin_a; var left_cos_a = px * cos_a; var top_cos_a = py * cos_a; px = left_cos_a - top_sin_a; py = top_cos_a + left_sin_a; px += ox; py += oy; return getx ? px : py; } cr.distanceTo = function(x1, y1, x2, y2) { var dx = x2 - x1; var dy = y2 - y1; return Math.sqrt(dx*dx + dy*dy); }; cr.xor = function (x, y) { return !x !== !y; }; cr.lerp = function (a, b, x) { return a + (b - a) * x; }; cr.unlerp = function (a, b, c) { if (a === b) return 0; // avoid divide by 0 return (c - a) / (b - a); }; cr.anglelerp = function (a, b, x) { var diff = cr.angleDiff(a, b); if (cr.angleClockwise(b, a)) { return a + diff * x; } else { return a - diff * x; } }; cr.qarp = function (a, b, c, x) { return cr.lerp(cr.lerp(a, b, x), cr.lerp(b, c, x), x); }; cr.cubic = function (a, b, c, d, x) { return cr.lerp(cr.qarp(a, b, c, x), cr.qarp(b, c, d, x), x); }; cr.cosp = function (a, b, x) { return (a + b + (a - b) * Math.cos(x * Math.PI)) / 2; }; cr.hasAnyOwnProperty = function (o) { var p; for (p in o) { if (o.hasOwnProperty(p)) return true; } return false; }; cr.wipe = function (obj) { var p; for (p in obj) { if (obj.hasOwnProperty(p)) delete obj[p]; } }; var startup_time = +(new Date()); cr.performance_now = function() { if (typeof window["performance"] !== "undefined") { var winperf = window["performance"]; if (typeof winperf.now !== "undefined") return winperf.now(); else if (typeof winperf["webkitNow"] !== "undefined") return winperf["webkitNow"](); else if (typeof winperf["mozNow"] !== "undefined") return winperf["mozNow"](); else if (typeof winperf["msNow"] !== "undefined") return winperf["msNow"](); } return Date.now() - startup_time; }; var isChrome = false; var isSafari = false; var isiOS = false; var isEjecta = false; if (typeof window !== "undefined") // not c2 editor { isChrome = /chrome/i.test(navigator.userAgent) || /chromium/i.test(navigator.userAgent); isSafari = !isChrome && /safari/i.test(navigator.userAgent); isiOS = /(iphone|ipod|ipad)/i.test(navigator.userAgent); isEjecta = window["c2ejecta"]; } var supports_set = ((!isSafari && !isEjecta && !isiOS) && (typeof Set !== "undefined" && typeof Set.prototype["forEach"] !== "undefined")); function ObjectSet_() { this.s = null; this.items = null; // lazy allocated (hopefully results in better GC performance) this.item_count = 0; if (supports_set) { this.s = new Set(); } this.values_cache = []; this.cache_valid = true; cr.seal(this); }; ObjectSet_.prototype.contains = function (x) { if (this.isEmpty()) return false; if (supports_set) return this.s["has"](x); else return (this.items && this.items.hasOwnProperty(x)); }; ObjectSet_.prototype.add = function (x) { if (supports_set) { if (!this.s["has"](x)) { this.s["add"](x); this.cache_valid = false; } } else { var str = x.toString(); var items = this.items; if (!items) { this.items = {}; this.items[str] = x; this.item_count = 1; this.cache_valid = false; } else if (!items.hasOwnProperty(str)) { items[str] = x; this.item_count++; this.cache_valid = false; } } }; ObjectSet_.prototype.remove = function (x) { if (this.isEmpty()) return; if (supports_set) { if (this.s["has"](x)) { this.s["delete"](x); this.cache_valid = false; } } else if (this.items) { var str = x.toString(); var items = this.items; if (items.hasOwnProperty(str)) { delete items[str]; this.item_count--; this.cache_valid = false; } } }; ObjectSet_.prototype.clear = function (/*wipe_*/) { if (this.isEmpty()) return; if (supports_set) { this.s["clear"](); // best! } else { this.items = null; // creates garbage; will lazy allocate on next add() this.item_count = 0; } cr.clearArray(this.values_cache); this.cache_valid = true; }; ObjectSet_.prototype.isEmpty = function () { return this.count() === 0; }; ObjectSet_.prototype.count = function () { if (supports_set) return this.s["size"]; else return this.item_count; }; var current_arr = null; var current_index = 0; function set_append_to_arr(x) { current_arr[current_index++] = x; }; ObjectSet_.prototype.update_cache = function () { if (this.cache_valid) return; if (supports_set) { cr.clearArray(this.values_cache); current_arr = this.values_cache; current_index = 0; this.s["forEach"](set_append_to_arr); ; current_arr = null; current_index = 0; } else { var values_cache = this.values_cache; cr.clearArray(values_cache); var p, n = 0, items = this.items; if (items) { for (p in items) { if (items.hasOwnProperty(p)) values_cache[n++] = items[p]; } } ; } this.cache_valid = true; }; ObjectSet_.prototype.valuesRef = function () { this.update_cache(); return this.values_cache; }; cr.ObjectSet = ObjectSet_; var tmpSet = new cr.ObjectSet(); cr.removeArrayDuplicates = function (arr) { var i, len; for (i = 0, len = arr.length; i < len; ++i) { tmpSet.add(arr[i]); } cr.shallowAssignArray(arr, tmpSet.valuesRef()); tmpSet.clear(); }; cr.arrayRemoveAllFromObjectSet = function (arr, remset) { if (supports_set) cr.arrayRemoveAll_set(arr, remset.s); else cr.arrayRemoveAll_arr(arr, remset.valuesRef()); }; cr.arrayRemoveAll_set = function (arr, s) { var i, j, len, item; for (i = 0, j = 0, len = arr.length; i < len; ++i) { item = arr[i]; if (!s["has"](item)) // not an item to remove arr[j++] = item; // keep it } cr.truncateArray(arr, j); }; cr.arrayRemoveAll_arr = function (arr, rem) { var i, j, len, item; for (i = 0, j = 0, len = arr.length; i < len; ++i) { item = arr[i]; if (cr.fastIndexOf(rem, item) === -1) // not an item to remove arr[j++] = item; // keep it } cr.truncateArray(arr, j); }; function KahanAdder_() { this.c = 0; this.y = 0; this.t = 0; this.sum = 0; cr.seal(this); }; KahanAdder_.prototype.add = function (v) { this.y = v - this.c; this.t = this.sum + this.y; this.c = (this.t - this.sum) - this.y; this.sum = this.t; }; KahanAdder_.prototype.reset = function () { this.c = 0; this.y = 0; this.t = 0; this.sum = 0; }; cr.KahanAdder = KahanAdder_; cr.regexp_escape = function(text) { return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"); }; function CollisionPoly_(pts_array_) { this.pts_cache = []; this.bboxLeft = 0; this.bboxTop = 0; this.bboxRight = 0; this.bboxBottom = 0; this.convexpolys = null; // for physics behavior to cache separated polys this.set_pts(pts_array_); cr.seal(this); }; CollisionPoly_.prototype.set_pts = function(pts_array_) { this.pts_array = pts_array_; this.pts_count = pts_array_.length / 2; // x, y, x, y... in array this.pts_cache.length = pts_array_.length; this.cache_width = -1; this.cache_height = -1; this.cache_angle = 0; }; CollisionPoly_.prototype.is_empty = function() { return !this.pts_array.length; }; CollisionPoly_.prototype.update_bbox = function () { var myptscache = this.pts_cache; var bboxLeft_ = myptscache[0]; var bboxRight_ = bboxLeft_; var bboxTop_ = myptscache[1]; var bboxBottom_ = bboxTop_; var x, y, i = 1, i2, len = this.pts_count; for ( ; i < len; ++i) { i2 = i*2; x = myptscache[i2]; y = myptscache[i2+1]; if (x < bboxLeft_) bboxLeft_ = x; if (x > bboxRight_) bboxRight_ = x; if (y < bboxTop_) bboxTop_ = y; if (y > bboxBottom_) bboxBottom_ = y; } this.bboxLeft = bboxLeft_; this.bboxRight = bboxRight_; this.bboxTop = bboxTop_; this.bboxBottom = bboxBottom_; }; CollisionPoly_.prototype.set_from_rect = function(rc, offx, offy) { this.pts_cache.length = 8; this.pts_count = 4; var myptscache = this.pts_cache; myptscache[0] = rc.left - offx; myptscache[1] = rc.top - offy; myptscache[2] = rc.right - offx; myptscache[3] = rc.top - offy; myptscache[4] = rc.right - offx; myptscache[5] = rc.bottom - offy; myptscache[6] = rc.left - offx; myptscache[7] = rc.bottom - offy; this.cache_width = rc.right - rc.left; this.cache_height = rc.bottom - rc.top; this.update_bbox(); }; CollisionPoly_.prototype.set_from_quad = function(q, offx, offy, w, h) { this.pts_cache.length = 8; this.pts_count = 4; var myptscache = this.pts_cache; myptscache[0] = q.tlx - offx; myptscache[1] = q.tly - offy; myptscache[2] = q.trx - offx; myptscache[3] = q.try_ - offy; myptscache[4] = q.brx - offx; myptscache[5] = q.bry - offy; myptscache[6] = q.blx - offx; myptscache[7] = q.bly - offy; this.cache_width = w; this.cache_height = h; this.update_bbox(); }; CollisionPoly_.prototype.set_from_poly = function (r) { this.pts_count = r.pts_count; cr.shallowAssignArray(this.pts_cache, r.pts_cache); this.bboxLeft = r.bboxLeft; this.bboxTop - r.bboxTop; this.bboxRight = r.bboxRight; this.bboxBottom = r.bboxBottom; }; CollisionPoly_.prototype.cache_poly = function(w, h, a) { if (this.cache_width === w && this.cache_height === h && this.cache_angle === a) return; // cache up-to-date this.cache_width = w; this.cache_height = h; this.cache_angle = a; var i, i2, i21, len, x, y; var sina = 0; var cosa = 1; var myptsarray = this.pts_array; var myptscache = this.pts_cache; if (a !== 0) { sina = Math.sin(a); cosa = Math.cos(a); } for (i = 0, len = this.pts_count; i < len; i++) { i2 = i*2; i21 = i2+1; x = myptsarray[i2] * w; y = myptsarray[i21] * h; myptscache[i2] = (x * cosa) - (y * sina); myptscache[i21] = (y * cosa) + (x * sina); } this.update_bbox(); }; CollisionPoly_.prototype.contains_pt = function (a2x, a2y) { var myptscache = this.pts_cache; if (a2x === myptscache[0] && a2y === myptscache[1]) return true; var i, i2, imod, len = this.pts_count; var a1x = this.bboxLeft - 110; var a1y = this.bboxTop - 101; var a3x = this.bboxRight + 131 var a3y = this.bboxBottom + 120; var b1x, b1y, b2x, b2y; var count1 = 0, count2 = 0; for (i = 0; i < len; i++) { i2 = i*2; imod = ((i+1)%len)*2; b1x = myptscache[i2]; b1y = myptscache[i2+1]; b2x = myptscache[imod]; b2y = myptscache[imod+1]; if (cr.segments_intersect(a1x, a1y, a2x, a2y, b1x, b1y, b2x, b2y)) count1++; if (cr.segments_intersect(a3x, a3y, a2x, a2y, b1x, b1y, b2x, b2y)) count2++; } return (count1 % 2 === 1) || (count2 % 2 === 1); }; CollisionPoly_.prototype.intersects_poly = function (rhs, offx, offy) { var rhspts = rhs.pts_cache; var mypts = this.pts_cache; if (this.contains_pt(rhspts[0] + offx, rhspts[1] + offy)) return true; if (rhs.contains_pt(mypts[0] - offx, mypts[1] - offy)) return true; var i, i2, imod, leni, j, j2, jmod, lenj; var a1x, a1y, a2x, a2y, b1x, b1y, b2x, b2y; for (i = 0, leni = this.pts_count; i < leni; i++) { i2 = i*2; imod = ((i+1)%leni)*2; a1x = mypts[i2]; a1y = mypts[i2+1]; a2x = mypts[imod]; a2y = mypts[imod+1]; for (j = 0, lenj = rhs.pts_count; j < lenj; j++) { j2 = j*2; jmod = ((j+1)%lenj)*2; b1x = rhspts[j2] + offx; b1y = rhspts[j2+1] + offy; b2x = rhspts[jmod] + offx; b2y = rhspts[jmod+1] + offy; if (cr.segments_intersect(a1x, a1y, a2x, a2y, b1x, b1y, b2x, b2y)) return true; } } return false; }; CollisionPoly_.prototype.intersects_segment = function (offx, offy, x1, y1, x2, y2) { var mypts = this.pts_cache; if (this.contains_pt(x1 - offx, y1 - offy)) return true; var i, leni, i2, imod; var a1x, a1y, a2x, a2y; for (i = 0, leni = this.pts_count; i < leni; i++) { i2 = i*2; imod = ((i+1)%leni)*2; a1x = mypts[i2] + offx; a1y = mypts[i2+1] + offy; a2x = mypts[imod] + offx; a2y = mypts[imod+1] + offy; if (cr.segments_intersect(x1, y1, x2, y2, a1x, a1y, a2x, a2y)) return true; } return false; }; CollisionPoly_.prototype.mirror = function (px) { var i, leni, i2; for (i = 0, leni = this.pts_count; i < leni; ++i) { i2 = i*2; this.pts_cache[i2] = px * 2 - this.pts_cache[i2]; } }; CollisionPoly_.prototype.flip = function (py) { var i, leni, i21; for (i = 0, leni = this.pts_count; i < leni; ++i) { i21 = i*2+1; this.pts_cache[i21] = py * 2 - this.pts_cache[i21]; } }; CollisionPoly_.prototype.diag = function () { var i, leni, i2, i21, temp; for (i = 0, leni = this.pts_count; i < leni; ++i) { i2 = i*2; i21 = i2+1; temp = this.pts_cache[i2]; this.pts_cache[i2] = this.pts_cache[i21]; this.pts_cache[i21] = temp; } }; cr.CollisionPoly = CollisionPoly_; function SparseGrid_(cellwidth_, cellheight_) { this.cellwidth = cellwidth_; this.cellheight = cellheight_; this.cells = {}; }; SparseGrid_.prototype.totalCellCount = 0; SparseGrid_.prototype.getCell = function (x_, y_, create_if_missing) { var ret; var col = this.cells[x_]; if (!col) { if (create_if_missing) { ret = allocGridCell(this, x_, y_); this.cells[x_] = {}; this.cells[x_][y_] = ret; return ret; } else return null; } ret = col[y_]; if (ret) return ret; else if (create_if_missing) { ret = allocGridCell(this, x_, y_); this.cells[x_][y_] = ret; return ret; } else return null; }; SparseGrid_.prototype.XToCell = function (x_) { return cr.floor(x_ / this.cellwidth); }; SparseGrid_.prototype.YToCell = function (y_) { return cr.floor(y_ / this.cellheight); }; SparseGrid_.prototype.update = function (inst, oldrange, newrange) { var x, lenx, y, leny, cell; if (oldrange) { for (x = oldrange.left, lenx = oldrange.right; x <= lenx; ++x) { for (y = oldrange.top, leny = oldrange.bottom; y <= leny; ++y) { if (newrange && newrange.contains_pt(x, y)) continue; // is still in this cell cell = this.getCell(x, y, false); // don't create if missing if (!cell) continue; // cell does not exist yet cell.remove(inst); if (cell.isEmpty()) { freeGridCell(cell); this.cells[x][y] = null; } } } } if (newrange) { for (x = newrange.left, lenx = newrange.right; x <= lenx; ++x) { for (y = newrange.top, leny = newrange.bottom; y <= leny; ++y) { if (oldrange && oldrange.contains_pt(x, y)) continue; // is still in this cell this.getCell(x, y, true).insert(inst); } } } }; SparseGrid_.prototype.queryRange = function (rc, result) { var x, lenx, ystart, y, leny, cell; x = this.XToCell(rc.left); ystart = this.YToCell(rc.top); lenx = this.XToCell(rc.right); leny = this.YToCell(rc.bottom); for ( ; x <= lenx; ++x) { for (y = ystart; y <= leny; ++y) { cell = this.getCell(x, y, false); if (!cell) continue; cell.dump(result); } } }; cr.SparseGrid = SparseGrid_; function RenderGrid_(cellwidth_, cellheight_) { this.cellwidth = cellwidth_; this.cellheight = cellheight_; this.cells = {}; }; RenderGrid_.prototype.totalCellCount = 0; RenderGrid_.prototype.getCell = function (x_, y_, create_if_missing) { var ret; var col = this.cells[x_]; if (!col) { if (create_if_missing) { ret = allocRenderCell(this, x_, y_); this.cells[x_] = {}; this.cells[x_][y_] = ret; return ret; } else return null; } ret = col[y_]; if (ret) return ret; else if (create_if_missing) { ret = allocRenderCell(this, x_, y_); this.cells[x_][y_] = ret; return ret; } else return null; }; RenderGrid_.prototype.XToCell = function (x_) { return cr.floor(x_ / this.cellwidth); }; RenderGrid_.prototype.YToCell = function (y_) { return cr.floor(y_ / this.cellheight); }; RenderGrid_.prototype.update = function (inst, oldrange, newrange) { var x, lenx, y, leny, cell; if (oldrange) { for (x = oldrange.left, lenx = oldrange.right; x <= lenx; ++x) { for (y = oldrange.top, leny = oldrange.bottom; y <= leny; ++y) { if (newrange && newrange.contains_pt(x, y)) continue; // is still in this cell cell = this.getCell(x, y, false); // don't create if missing if (!cell) continue; // cell does not exist yet cell.remove(inst); if (cell.isEmpty()) { freeRenderCell(cell); this.cells[x][y] = null; } } } } if (newrange) { for (x = newrange.left, lenx = newrange.right; x <= lenx; ++x) { for (y = newrange.top, leny = newrange.bottom; y <= leny; ++y) { if (oldrange && oldrange.contains_pt(x, y)) continue; // is still in this cell this.getCell(x, y, true).insert(inst); } } } }; RenderGrid_.prototype.queryRange = function (left, top, right, bottom, result) { var x, lenx, ystart, y, leny, cell; x = this.XToCell(left); ystart = this.YToCell(top); lenx = this.XToCell(right); leny = this.YToCell(bottom); for ( ; x <= lenx; ++x) { for (y = ystart; y <= leny; ++y) { cell = this.getCell(x, y, false); if (!cell) continue; cell.dump(result); } } }; RenderGrid_.prototype.markRangeChanged = function (rc) { var x, lenx, ystart, y, leny, cell; x = rc.left; ystart = rc.top; lenx = rc.right; leny = rc.bottom; for ( ; x <= lenx; ++x) { for (y = ystart; y <= leny; ++y) { cell = this.getCell(x, y, false); if (!cell) continue; cell.is_sorted = false; } } }; cr.RenderGrid = RenderGrid_; var gridcellcache = []; function allocGridCell(grid_, x_, y_) { var ret; SparseGrid_.prototype.totalCellCount++; if (gridcellcache.length) { ret = gridcellcache.pop(); ret.grid = grid_; ret.x = x_; ret.y = y_; return ret; } else return new cr.GridCell(grid_, x_, y_); }; function freeGridCell(c) { SparseGrid_.prototype.totalCellCount--; c.objects.clear(); if (gridcellcache.length < 1000) gridcellcache.push(c); }; function GridCell_(grid_, x_, y_) { this.grid = grid_; this.x = x_; this.y = y_; this.objects = new cr.ObjectSet(); }; GridCell_.prototype.isEmpty = function () { return this.objects.isEmpty(); }; GridCell_.prototype.insert = function (inst) { this.objects.add(inst); }; GridCell_.prototype.remove = function (inst) { this.objects.remove(inst); }; GridCell_.prototype.dump = function (result) { cr.appendArray(result, this.objects.valuesRef()); }; cr.GridCell = GridCell_; var rendercellcache = []; function allocRenderCell(grid_, x_, y_) { var ret; RenderGrid_.prototype.totalCellCount++; if (rendercellcache.length) { ret = rendercellcache.pop(); ret.grid = grid_; ret.x = x_; ret.y = y_; return ret; } else return new cr.RenderCell(grid_, x_, y_); }; function freeRenderCell(c) { RenderGrid_.prototype.totalCellCount--; c.reset(); if (rendercellcache.length < 1000) rendercellcache.push(c); }; function RenderCell_(grid_, x_, y_) { this.grid = grid_; this.x = x_; this.y = y_; this.objects = []; // array which needs to be sorted by Z order this.is_sorted = true; // whether array is in correct sort order or not this.pending_removal = new cr.ObjectSet(); this.any_pending_removal = false; }; RenderCell_.prototype.isEmpty = function () { if (!this.objects.length) { ; ; return true; } if (this.objects.length > this.pending_removal.count()) return false; ; this.flush_pending(); // takes fast path and just resets state return true; }; RenderCell_.prototype.insert = function (inst) { if (this.pending_removal.contains(inst)) { this.pending_removal.remove(inst); if (this.pending_removal.isEmpty()) this.any_pending_removal = false; return; } if (this.objects.length) { var top = this.objects[this.objects.length - 1]; if (top.get_zindex() > inst.get_zindex()) this.is_sorted = false; // 'inst' should be somewhere beneath 'top' this.objects.push(inst); } else { this.objects.push(inst); this.is_sorted = true; } ; }; RenderCell_.prototype.remove = function (inst) { this.pending_removal.add(inst); this.any_pending_removal = true; if (this.pending_removal.count() >= 30) this.flush_pending(); }; RenderCell_.prototype.flush_pending = function () { ; if (!this.any_pending_removal) return; // not changed if (this.pending_removal.count() === this.objects.length) { this.reset(); return; } cr.arrayRemoveAllFromObjectSet(this.objects, this.pending_removal); this.pending_removal.clear(); this.any_pending_removal = false; }; function sortByInstanceZIndex(a, b) { return a.zindex - b.zindex; }; RenderCell_.prototype.ensure_sorted = function () { if (this.is_sorted) return; // already sorted this.objects.sort(sortByInstanceZIndex); this.is_sorted = true; }; RenderCell_.prototype.reset = function () { cr.clearArray(this.objects); this.is_sorted = true; this.pending_removal.clear(); this.any_pending_removal = false; }; RenderCell_.prototype.dump = function (result) { this.flush_pending(); this.ensure_sorted(); if (this.objects.length) result.push(this.objects); }; cr.RenderCell = RenderCell_; var fxNames = [ "lighter", "xor", "copy", "destination-over", "source-in", "destination-in", "source-out", "destination-out", "source-atop", "destination-atop"]; cr.effectToCompositeOp = function(effect) { if (effect <= 0 || effect >= 11) return "source-over"; return fxNames[effect - 1]; // not including "none" so offset by 1 }; cr.setGLBlend = function(this_, effect, gl) { if (!gl) return; this_.srcBlend = gl.ONE; this_.destBlend = gl.ONE_MINUS_SRC_ALPHA; switch (effect) { case 1: // lighter (additive) this_.srcBlend = gl.ONE; this_.destBlend = gl.ONE; break; case 2: // xor break; // todo case 3: // copy this_.srcBlend = gl.ONE; this_.destBlend = gl.ZERO; break; case 4: // destination-over this_.srcBlend = gl.ONE_MINUS_DST_ALPHA; this_.destBlend = gl.ONE; break; case 5: // source-in this_.srcBlend = gl.DST_ALPHA; this_.destBlend = gl.ZERO; break; case 6: // destination-in this_.srcBlend = gl.ZERO; this_.destBlend = gl.SRC_ALPHA; break; case 7: // source-out this_.srcBlend = gl.ONE_MINUS_DST_ALPHA; this_.destBlend = gl.ZERO; break; case 8: // destination-out this_.srcBlend = gl.ZERO; this_.destBlend = gl.ONE_MINUS_SRC_ALPHA; break; case 9: // source-atop this_.srcBlend = gl.DST_ALPHA; this_.destBlend = gl.ONE_MINUS_SRC_ALPHA; break; case 10: // destination-atop this_.srcBlend = gl.ONE_MINUS_DST_ALPHA; this_.destBlend = gl.SRC_ALPHA; break; } }; cr.round6dp = function (x) { return Math.round(x * 1000000) / 1000000; }; /* var localeCompare_options = { "usage": "search", "sensitivity": "accent" }; var has_localeCompare = !!"a".localeCompare; var localeCompare_works1 = (has_localeCompare && "a".localeCompare("A", undefined, localeCompare_options) === 0); var localeCompare_works2 = (has_localeCompare && "a".localeCompare("á", undefined, localeCompare_options) !== 0); var supports_localeCompare = (has_localeCompare && localeCompare_works1 && localeCompare_works2); */ cr.equals_nocase = function (a, b) { if (typeof a !== "string" || typeof b !== "string") return false; if (a.length !== b.length) return false; if (a === b) return true; /* if (supports_localeCompare) { return (a.localeCompare(b, undefined, localeCompare_options) === 0); } else { */ return a.toLowerCase() === b.toLowerCase(); }; cr.isCanvasInputEvent = function (e) { var target = e.target; if (!target) return true; if (target === document || target === window) return true; if (document && document.body && target === document.body) return true; if (cr.equals_nocase(target.tagName, "canvas")) return true; return false; }; }()); var MatrixArray=typeof Float32Array!=="undefined"?Float32Array:Array,glMatrixArrayType=MatrixArray,vec3={},mat3={},mat4={},quat4={};vec3.create=function(a){var b=new MatrixArray(3);a&&(b[0]=a[0],b[1]=a[1],b[2]=a[2]);return b};vec3.set=function(a,b){b[0]=a[0];b[1]=a[1];b[2]=a[2];return b};vec3.add=function(a,b,c){if(!c||a===c)return a[0]+=b[0],a[1]+=b[1],a[2]+=b[2],a;c[0]=a[0]+b[0];c[1]=a[1]+b[1];c[2]=a[2]+b[2];return c}; vec3.subtract=function(a,b,c){if(!c||a===c)return a[0]-=b[0],a[1]-=b[1],a[2]-=b[2],a;c[0]=a[0]-b[0];c[1]=a[1]-b[1];c[2]=a[2]-b[2];return c};vec3.negate=function(a,b){b||(b=a);b[0]=-a[0];b[1]=-a[1];b[2]=-a[2];return b};vec3.scale=function(a,b,c){if(!c||a===c)return a[0]*=b,a[1]*=b,a[2]*=b,a;c[0]=a[0]*b;c[1]=a[1]*b;c[2]=a[2]*b;return c}; vec3.normalize=function(a,b){b||(b=a);var c=a[0],d=a[1],e=a[2],g=Math.sqrt(c*c+d*d+e*e);if(g){if(g===1)return b[0]=c,b[1]=d,b[2]=e,b}else return b[0]=0,b[1]=0,b[2]=0,b;g=1/g;b[0]=c*g;b[1]=d*g;b[2]=e*g;return b};vec3.cross=function(a,b,c){c||(c=a);var d=a[0],e=a[1],a=a[2],g=b[0],f=b[1],b=b[2];c[0]=e*b-a*f;c[1]=a*g-d*b;c[2]=d*f-e*g;return c};vec3.length=function(a){var b=a[0],c=a[1],a=a[2];return Math.sqrt(b*b+c*c+a*a)};vec3.dot=function(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]}; vec3.direction=function(a,b,c){c||(c=a);var d=a[0]-b[0],e=a[1]-b[1],a=a[2]-b[2],b=Math.sqrt(d*d+e*e+a*a);if(!b)return c[0]=0,c[1]=0,c[2]=0,c;b=1/b;c[0]=d*b;c[1]=e*b;c[2]=a*b;return c};vec3.lerp=function(a,b,c,d){d||(d=a);d[0]=a[0]+c*(b[0]-a[0]);d[1]=a[1]+c*(b[1]-a[1]);d[2]=a[2]+c*(b[2]-a[2]);return d};vec3.str=function(a){return"["+a[0]+", "+a[1]+", "+a[2]+"]"}; mat3.create=function(a){var b=new MatrixArray(9);a&&(b[0]=a[0],b[1]=a[1],b[2]=a[2],b[3]=a[3],b[4]=a[4],b[5]=a[5],b[6]=a[6],b[7]=a[7],b[8]=a[8]);return b};mat3.set=function(a,b){b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[5]=a[5];b[6]=a[6];b[7]=a[7];b[8]=a[8];return b};mat3.identity=function(a){a[0]=1;a[1]=0;a[2]=0;a[3]=0;a[4]=1;a[5]=0;a[6]=0;a[7]=0;a[8]=1;return a}; mat3.transpose=function(a,b){if(!b||a===b){var c=a[1],d=a[2],e=a[5];a[1]=a[3];a[2]=a[6];a[3]=c;a[5]=a[7];a[6]=d;a[7]=e;return a}b[0]=a[0];b[1]=a[3];b[2]=a[6];b[3]=a[1];b[4]=a[4];b[5]=a[7];b[6]=a[2];b[7]=a[5];b[8]=a[8];return b};mat3.toMat4=function(a,b){b||(b=mat4.create());b[15]=1;b[14]=0;b[13]=0;b[12]=0;b[11]=0;b[10]=a[8];b[9]=a[7];b[8]=a[6];b[7]=0;b[6]=a[5];b[5]=a[4];b[4]=a[3];b[3]=0;b[2]=a[2];b[1]=a[1];b[0]=a[0];return b}; mat3.str=function(a){return"["+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+", "+a[4]+", "+a[5]+", "+a[6]+", "+a[7]+", "+a[8]+"]"};mat4.create=function(a){var b=new MatrixArray(16);a&&(b[0]=a[0],b[1]=a[1],b[2]=a[2],b[3]=a[3],b[4]=a[4],b[5]=a[5],b[6]=a[6],b[7]=a[7],b[8]=a[8],b[9]=a[9],b[10]=a[10],b[11]=a[11],b[12]=a[12],b[13]=a[13],b[14]=a[14],b[15]=a[15]);return b}; mat4.set=function(a,b){b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[5]=a[5];b[6]=a[6];b[7]=a[7];b[8]=a[8];b[9]=a[9];b[10]=a[10];b[11]=a[11];b[12]=a[12];b[13]=a[13];b[14]=a[14];b[15]=a[15];return b};mat4.identity=function(a){a[0]=1;a[1]=0;a[2]=0;a[3]=0;a[4]=0;a[5]=1;a[6]=0;a[7]=0;a[8]=0;a[9]=0;a[10]=1;a[11]=0;a[12]=0;a[13]=0;a[14]=0;a[15]=1;return a}; mat4.transpose=function(a,b){if(!b||a===b){var c=a[1],d=a[2],e=a[3],g=a[6],f=a[7],h=a[11];a[1]=a[4];a[2]=a[8];a[3]=a[12];a[4]=c;a[6]=a[9];a[7]=a[13];a[8]=d;a[9]=g;a[11]=a[14];a[12]=e;a[13]=f;a[14]=h;return a}b[0]=a[0];b[1]=a[4];b[2]=a[8];b[3]=a[12];b[4]=a[1];b[5]=a[5];b[6]=a[9];b[7]=a[13];b[8]=a[2];b[9]=a[6];b[10]=a[10];b[11]=a[14];b[12]=a[3];b[13]=a[7];b[14]=a[11];b[15]=a[15];return b}; mat4.determinant=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],g=a[4],f=a[5],h=a[6],i=a[7],j=a[8],k=a[9],l=a[10],n=a[11],o=a[12],m=a[13],p=a[14],a=a[15];return o*k*h*e-j*m*h*e-o*f*l*e+g*m*l*e+j*f*p*e-g*k*p*e-o*k*d*i+j*m*d*i+o*c*l*i-b*m*l*i-j*c*p*i+b*k*p*i+o*f*d*n-g*m*d*n-o*c*h*n+b*m*h*n+g*c*p*n-b*f*p*n-j*f*d*a+g*k*d*a+j*c*h*a-b*k*h*a-g*c*l*a+b*f*l*a}; mat4.inverse=function(a,b){b||(b=a);var c=a[0],d=a[1],e=a[2],g=a[3],f=a[4],h=a[5],i=a[6],j=a[7],k=a[8],l=a[9],n=a[10],o=a[11],m=a[12],p=a[13],r=a[14],s=a[15],A=c*h-d*f,B=c*i-e*f,t=c*j-g*f,u=d*i-e*h,v=d*j-g*h,w=e*j-g*i,x=k*p-l*m,y=k*r-n*m,z=k*s-o*m,C=l*r-n*p,D=l*s-o*p,E=n*s-o*r,q=1/(A*E-B*D+t*C+u*z-v*y+w*x);b[0]=(h*E-i*D+j*C)*q;b[1]=(-d*E+e*D-g*C)*q;b[2]=(p*w-r*v+s*u)*q;b[3]=(-l*w+n*v-o*u)*q;b[4]=(-f*E+i*z-j*y)*q;b[5]=(c*E-e*z+g*y)*q;b[6]=(-m*w+r*t-s*B)*q;b[7]=(k*w-n*t+o*B)*q;b[8]=(f*D-h*z+j*x)*q; b[9]=(-c*D+d*z-g*x)*q;b[10]=(m*v-p*t+s*A)*q;b[11]=(-k*v+l*t-o*A)*q;b[12]=(-f*C+h*y-i*x)*q;b[13]=(c*C-d*y+e*x)*q;b[14]=(-m*u+p*B-r*A)*q;b[15]=(k*u-l*B+n*A)*q;return b};mat4.toRotationMat=function(a,b){b||(b=mat4.create());b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[5]=a[5];b[6]=a[6];b[7]=a[7];b[8]=a[8];b[9]=a[9];b[10]=a[10];b[11]=a[11];b[12]=0;b[13]=0;b[14]=0;b[15]=1;return b}; mat4.toMat3=function(a,b){b||(b=mat3.create());b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[4];b[4]=a[5];b[5]=a[6];b[6]=a[8];b[7]=a[9];b[8]=a[10];return b};mat4.toInverseMat3=function(a,b){var c=a[0],d=a[1],e=a[2],g=a[4],f=a[5],h=a[6],i=a[8],j=a[9],k=a[10],l=k*f-h*j,n=-k*g+h*i,o=j*g-f*i,m=c*l+d*n+e*o;if(!m)return null;m=1/m;b||(b=mat3.create());b[0]=l*m;b[1]=(-k*d+e*j)*m;b[2]=(h*d-e*f)*m;b[3]=n*m;b[4]=(k*c-e*i)*m;b[5]=(-h*c+e*g)*m;b[6]=o*m;b[7]=(-j*c+d*i)*m;b[8]=(f*c-d*g)*m;return b}; mat4.multiply=function(a,b,c){c||(c=a);var d=a[0],e=a[1],g=a[2],f=a[3],h=a[4],i=a[5],j=a[6],k=a[7],l=a[8],n=a[9],o=a[10],m=a[11],p=a[12],r=a[13],s=a[14],a=a[15],A=b[0],B=b[1],t=b[2],u=b[3],v=b[4],w=b[5],x=b[6],y=b[7],z=b[8],C=b[9],D=b[10],E=b[11],q=b[12],F=b[13],G=b[14],b=b[15];c[0]=A*d+B*h+t*l+u*p;c[1]=A*e+B*i+t*n+u*r;c[2]=A*g+B*j+t*o+u*s;c[3]=A*f+B*k+t*m+u*a;c[4]=v*d+w*h+x*l+y*p;c[5]=v*e+w*i+x*n+y*r;c[6]=v*g+w*j+x*o+y*s;c[7]=v*f+w*k+x*m+y*a;c[8]=z*d+C*h+D*l+E*p;c[9]=z*e+C*i+D*n+E*r;c[10]=z*g+C* j+D*o+E*s;c[11]=z*f+C*k+D*m+E*a;c[12]=q*d+F*h+G*l+b*p;c[13]=q*e+F*i+G*n+b*r;c[14]=q*g+F*j+G*o+b*s;c[15]=q*f+F*k+G*m+b*a;return c};mat4.multiplyVec3=function(a,b,c){c||(c=b);var d=b[0],e=b[1],b=b[2];c[0]=a[0]*d+a[4]*e+a[8]*b+a[12];c[1]=a[1]*d+a[5]*e+a[9]*b+a[13];c[2]=a[2]*d+a[6]*e+a[10]*b+a[14];return c}; mat4.multiplyVec4=function(a,b,c){c||(c=b);var d=b[0],e=b[1],g=b[2],b=b[3];c[0]=a[0]*d+a[4]*e+a[8]*g+a[12]*b;c[1]=a[1]*d+a[5]*e+a[9]*g+a[13]*b;c[2]=a[2]*d+a[6]*e+a[10]*g+a[14]*b;c[3]=a[3]*d+a[7]*e+a[11]*g+a[15]*b;return c}; mat4.translate=function(a,b,c){var d=b[0],e=b[1],b=b[2],g,f,h,i,j,k,l,n,o,m,p,r;if(!c||a===c)return a[12]=a[0]*d+a[4]*e+a[8]*b+a[12],a[13]=a[1]*d+a[5]*e+a[9]*b+a[13],a[14]=a[2]*d+a[6]*e+a[10]*b+a[14],a[15]=a[3]*d+a[7]*e+a[11]*b+a[15],a;g=a[0];f=a[1];h=a[2];i=a[3];j=a[4];k=a[5];l=a[6];n=a[7];o=a[8];m=a[9];p=a[10];r=a[11];c[0]=g;c[1]=f;c[2]=h;c[3]=i;c[4]=j;c[5]=k;c[6]=l;c[7]=n;c[8]=o;c[9]=m;c[10]=p;c[11]=r;c[12]=g*d+j*e+o*b+a[12];c[13]=f*d+k*e+m*b+a[13];c[14]=h*d+l*e+p*b+a[14];c[15]=i*d+n*e+r*b+a[15]; return c};mat4.scale=function(a,b,c){var d=b[0],e=b[1],b=b[2];if(!c||a===c)return a[0]*=d,a[1]*=d,a[2]*=d,a[3]*=d,a[4]*=e,a[5]*=e,a[6]*=e,a[7]*=e,a[8]*=b,a[9]*=b,a[10]*=b,a[11]*=b,a;c[0]=a[0]*d;c[1]=a[1]*d;c[2]=a[2]*d;c[3]=a[3]*d;c[4]=a[4]*e;c[5]=a[5]*e;c[6]=a[6]*e;c[7]=a[7]*e;c[8]=a[8]*b;c[9]=a[9]*b;c[10]=a[10]*b;c[11]=a[11]*b;c[12]=a[12];c[13]=a[13];c[14]=a[14];c[15]=a[15];return c}; mat4.rotate=function(a,b,c,d){var e=c[0],g=c[1],c=c[2],f=Math.sqrt(e*e+g*g+c*c),h,i,j,k,l,n,o,m,p,r,s,A,B,t,u,v,w,x,y,z;if(!f)return null;f!==1&&(f=1/f,e*=f,g*=f,c*=f);h=Math.sin(b);i=Math.cos(b);j=1-i;b=a[0];f=a[1];k=a[2];l=a[3];n=a[4];o=a[5];m=a[6];p=a[7];r=a[8];s=a[9];A=a[10];B=a[11];t=e*e*j+i;u=g*e*j+c*h;v=c*e*j-g*h;w=e*g*j-c*h;x=g*g*j+i;y=c*g*j+e*h;z=e*c*j+g*h;e=g*c*j-e*h;g=c*c*j+i;d?a!==d&&(d[12]=a[12],d[13]=a[13],d[14]=a[14],d[15]=a[15]):d=a;d[0]=b*t+n*u+r*v;d[1]=f*t+o*u+s*v;d[2]=k*t+m*u+A* v;d[3]=l*t+p*u+B*v;d[4]=b*w+n*x+r*y;d[5]=f*w+o*x+s*y;d[6]=k*w+m*x+A*y;d[7]=l*w+p*x+B*y;d[8]=b*z+n*e+r*g;d[9]=f*z+o*e+s*g;d[10]=k*z+m*e+A*g;d[11]=l*z+p*e+B*g;return d};mat4.rotateX=function(a,b,c){var d=Math.sin(b),b=Math.cos(b),e=a[4],g=a[5],f=a[6],h=a[7],i=a[8],j=a[9],k=a[10],l=a[11];c?a!==c&&(c[0]=a[0],c[1]=a[1],c[2]=a[2],c[3]=a[3],c[12]=a[12],c[13]=a[13],c[14]=a[14],c[15]=a[15]):c=a;c[4]=e*b+i*d;c[5]=g*b+j*d;c[6]=f*b+k*d;c[7]=h*b+l*d;c[8]=e*-d+i*b;c[9]=g*-d+j*b;c[10]=f*-d+k*b;c[11]=h*-d+l*b;return c}; mat4.rotateY=function(a,b,c){var d=Math.sin(b),b=Math.cos(b),e=a[0],g=a[1],f=a[2],h=a[3],i=a[8],j=a[9],k=a[10],l=a[11];c?a!==c&&(c[4]=a[4],c[5]=a[5],c[6]=a[6],c[7]=a[7],c[12]=a[12],c[13]=a[13],c[14]=a[14],c[15]=a[15]):c=a;c[0]=e*b+i*-d;c[1]=g*b+j*-d;c[2]=f*b+k*-d;c[3]=h*b+l*-d;c[8]=e*d+i*b;c[9]=g*d+j*b;c[10]=f*d+k*b;c[11]=h*d+l*b;return c}; mat4.rotateZ=function(a,b,c){var d=Math.sin(b),b=Math.cos(b),e=a[0],g=a[1],f=a[2],h=a[3],i=a[4],j=a[5],k=a[6],l=a[7];c?a!==c&&(c[8]=a[8],c[9]=a[9],c[10]=a[10],c[11]=a[11],c[12]=a[12],c[13]=a[13],c[14]=a[14],c[15]=a[15]):c=a;c[0]=e*b+i*d;c[1]=g*b+j*d;c[2]=f*b+k*d;c[3]=h*b+l*d;c[4]=e*-d+i*b;c[5]=g*-d+j*b;c[6]=f*-d+k*b;c[7]=h*-d+l*b;return c}; mat4.frustum=function(a,b,c,d,e,g,f){f||(f=mat4.create());var h=b-a,i=d-c,j=g-e;f[0]=e*2/h;f[1]=0;f[2]=0;f[3]=0;f[4]=0;f[5]=e*2/i;f[6]=0;f[7]=0;f[8]=(b+a)/h;f[9]=(d+c)/i;f[10]=-(g+e)/j;f[11]=-1;f[12]=0;f[13]=0;f[14]=-(g*e*2)/j;f[15]=0;return f};mat4.perspective=function(a,b,c,d,e){a=c*Math.tan(a*Math.PI/360);b*=a;return mat4.frustum(-b,b,-a,a,c,d,e)}; mat4.ortho=function(a,b,c,d,e,g,f){f||(f=mat4.create());var h=b-a,i=d-c,j=g-e;f[0]=2/h;f[1]=0;f[2]=0;f[3]=0;f[4]=0;f[5]=2/i;f[6]=0;f[7]=0;f[8]=0;f[9]=0;f[10]=-2/j;f[11]=0;f[12]=-(a+b)/h;f[13]=-(d+c)/i;f[14]=-(g+e)/j;f[15]=1;return f}; mat4.lookAt=function(a,b,c,d){d||(d=mat4.create());var e,g,f,h,i,j,k,l,n=a[0],o=a[1],a=a[2];g=c[0];f=c[1];e=c[2];c=b[1];j=b[2];if(n===b[0]&&o===c&&a===j)return mat4.identity(d);c=n-b[0];j=o-b[1];k=a-b[2];l=1/Math.sqrt(c*c+j*j+k*k);c*=l;j*=l;k*=l;b=f*k-e*j;e=e*c-g*k;g=g*j-f*c;(l=Math.sqrt(b*b+e*e+g*g))?(l=1/l,b*=l,e*=l,g*=l):g=e=b=0;f=j*g-k*e;h=k*b-c*g;i=c*e-j*b;(l=Math.sqrt(f*f+h*h+i*i))?(l=1/l,f*=l,h*=l,i*=l):i=h=f=0;d[0]=b;d[1]=f;d[2]=c;d[3]=0;d[4]=e;d[5]=h;d[6]=j;d[7]=0;d[8]=g;d[9]=i;d[10]=k;d[11]= 0;d[12]=-(b*n+e*o+g*a);d[13]=-(f*n+h*o+i*a);d[14]=-(c*n+j*o+k*a);d[15]=1;return d};mat4.fromRotationTranslation=function(a,b,c){c||(c=mat4.create());var d=a[0],e=a[1],g=a[2],f=a[3],h=d+d,i=e+e,j=g+g,a=d*h,k=d*i;d*=j;var l=e*i;e*=j;g*=j;h*=f;i*=f;f*=j;c[0]=1-(l+g);c[1]=k+f;c[2]=d-i;c[3]=0;c[4]=k-f;c[5]=1-(a+g);c[6]=e+h;c[7]=0;c[8]=d+i;c[9]=e-h;c[10]=1-(a+l);c[11]=0;c[12]=b[0];c[13]=b[1];c[14]=b[2];c[15]=1;return c}; mat4.str=function(a){return"["+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+", "+a[4]+", "+a[5]+", "+a[6]+", "+a[7]+", "+a[8]+", "+a[9]+", "+a[10]+", "+a[11]+", "+a[12]+", "+a[13]+", "+a[14]+", "+a[15]+"]"};quat4.create=function(a){var b=new MatrixArray(4);a&&(b[0]=a[0],b[1]=a[1],b[2]=a[2],b[3]=a[3]);return b};quat4.set=function(a,b){b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];return b}; quat4.calculateW=function(a,b){var c=a[0],d=a[1],e=a[2];if(!b||a===b)return a[3]=-Math.sqrt(Math.abs(1-c*c-d*d-e*e)),a;b[0]=c;b[1]=d;b[2]=e;b[3]=-Math.sqrt(Math.abs(1-c*c-d*d-e*e));return b};quat4.inverse=function(a,b){if(!b||a===b)return a[0]*=-1,a[1]*=-1,a[2]*=-1,a;b[0]=-a[0];b[1]=-a[1];b[2]=-a[2];b[3]=a[3];return b};quat4.length=function(a){var b=a[0],c=a[1],d=a[2],a=a[3];return Math.sqrt(b*b+c*c+d*d+a*a)}; quat4.normalize=function(a,b){b||(b=a);var c=a[0],d=a[1],e=a[2],g=a[3],f=Math.sqrt(c*c+d*d+e*e+g*g);if(f===0)return b[0]=0,b[1]=0,b[2]=0,b[3]=0,b;f=1/f;b[0]=c*f;b[1]=d*f;b[2]=e*f;b[3]=g*f;return b};quat4.multiply=function(a,b,c){c||(c=a);var d=a[0],e=a[1],g=a[2],a=a[3],f=b[0],h=b[1],i=b[2],b=b[3];c[0]=d*b+a*f+e*i-g*h;c[1]=e*b+a*h+g*f-d*i;c[2]=g*b+a*i+d*h-e*f;c[3]=a*b-d*f-e*h-g*i;return c}; quat4.multiplyVec3=function(a,b,c){c||(c=b);var d=b[0],e=b[1],g=b[2],b=a[0],f=a[1],h=a[2],a=a[3],i=a*d+f*g-h*e,j=a*e+h*d-b*g,k=a*g+b*e-f*d,d=-b*d-f*e-h*g;c[0]=i*a+d*-b+j*-h-k*-f;c[1]=j*a+d*-f+k*-b-i*-h;c[2]=k*a+d*-h+i*-f-j*-b;return c};quat4.toMat3=function(a,b){b||(b=mat3.create());var c=a[0],d=a[1],e=a[2],g=a[3],f=c+c,h=d+d,i=e+e,j=c*f,k=c*h;c*=i;var l=d*h;d*=i;e*=i;f*=g;h*=g;g*=i;b[0]=1-(l+e);b[1]=k+g;b[2]=c-h;b[3]=k-g;b[4]=1-(j+e);b[5]=d+f;b[6]=c+h;b[7]=d-f;b[8]=1-(j+l);return b}; quat4.toMat4=function(a,b){b||(b=mat4.create());var c=a[0],d=a[1],e=a[2],g=a[3],f=c+c,h=d+d,i=e+e,j=c*f,k=c*h;c*=i;var l=d*h;d*=i;e*=i;f*=g;h*=g;g*=i;b[0]=1-(l+e);b[1]=k+g;b[2]=c-h;b[3]=0;b[4]=k-g;b[5]=1-(j+e);b[6]=d+f;b[7]=0;b[8]=c+h;b[9]=d-f;b[10]=1-(j+l);b[11]=0;b[12]=0;b[13]=0;b[14]=0;b[15]=1;return b}; quat4.slerp=function(a,b,c,d){d||(d=a);var e=a[0]*b[0]+a[1]*b[1]+a[2]*b[2]+a[3]*b[3],g,f;if(Math.abs(e)>=1)return d!==a&&(d[0]=a[0],d[1]=a[1],d[2]=a[2],d[3]=a[3]),d;g=Math.acos(e);f=Math.sqrt(1-e*e);if(Math.abs(f)<0.001)return d[0]=a[0]*0.5+b[0]*0.5,d[1]=a[1]*0.5+b[1]*0.5,d[2]=a[2]*0.5+b[2]*0.5,d[3]=a[3]*0.5+b[3]*0.5,d;e=Math.sin((1-c)*g)/f;c=Math.sin(c*g)/f;d[0]=a[0]*e+b[0]*c;d[1]=a[1]*e+b[1]*c;d[2]=a[2]*e+b[2]*c;d[3]=a[3]*e+b[3]*c;return d}; quat4.str=function(a){return"["+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+"]"}; (function() { var MAX_VERTICES = 8000; // equates to 2500 objects being drawn var MAX_INDICES = (MAX_VERTICES / 2) * 3; // 6 indices for every 4 vertices var MAX_POINTS = 8000; var MULTI_BUFFERS = 4; // cycle 4 buffers to try and avoid blocking var BATCH_NULL = 0; var BATCH_QUAD = 1; var BATCH_SETTEXTURE = 2; var BATCH_SETOPACITY = 3; var BATCH_SETBLEND = 4; var BATCH_UPDATEMODELVIEW = 5; var BATCH_RENDERTOTEXTURE = 6; var BATCH_CLEAR = 7; var BATCH_POINTS = 8; var BATCH_SETPROGRAM = 9; var BATCH_SETPROGRAMPARAMETERS = 10; var BATCH_SETTEXTURE1 = 11; var BATCH_SETCOLOR = 12; var BATCH_SETDEPTHTEST = 13; var BATCH_SETEARLYZMODE = 14; /* var lose_ext = null; window.lose_context = function () { if (!lose_ext) { console.log("WEBGL_lose_context not supported"); return; } lose_ext.loseContext(); }; window.restore_context = function () { if (!lose_ext) { console.log("WEBGL_lose_context not supported"); return; } lose_ext.restoreContext(); }; */ var tempMat4 = mat4.create(); function GLWrap_(gl, isMobile, enableFrontToBack) { this.isIE = /msie/i.test(navigator.userAgent) || /trident/i.test(navigator.userAgent); this.width = 0; // not yet known, wait for call to setSize() this.height = 0; this.enableFrontToBack = !!enableFrontToBack; this.isEarlyZPass = false; this.isBatchInEarlyZPass = false; this.currentZ = 0; this.zNear = 1; this.zFar = 1000; this.zIncrement = ((this.zFar - this.zNear) / 32768); this.zA = this.zFar / (this.zFar - this.zNear); this.zB = this.zFar * this.zNear / (this.zNear - this.zFar); this.kzA = 65536 * this.zA; this.kzB = 65536 * this.zB; this.cam = vec3.create([0, 0, 100]); // camera position this.look = vec3.create([0, 0, 0]); // lookat position this.up = vec3.create([0, 1, 0]); // up vector this.worldScale = vec3.create([1, 1, 1]); // world scaling factor this.enable_mipmaps = true; this.matP = mat4.create(); // perspective matrix this.matMV = mat4.create(); // model view matrix this.lastMV = mat4.create(); this.currentMV = mat4.create(); this.gl = gl; this.version = (this.gl.getParameter(this.gl.VERSION).indexOf("WebGL 2") === 0 ? 2 : 1); this.initState(); }; GLWrap_.prototype.initState = function () { var gl = this.gl; var i, len; this.lastOpacity = 1; this.lastTexture0 = null; // last bound to TEXTURE0 this.lastTexture1 = null; // last bound to TEXTURE1 this.currentOpacity = 1; gl.clearColor(0, 0, 0, 0); gl.clear(gl.COLOR_BUFFER_BIT); gl.enable(gl.BLEND); gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA); gl.disable(gl.CULL_FACE); gl.disable(gl.STENCIL_TEST); gl.disable(gl.DITHER); if (this.enableFrontToBack) { gl.enable(gl.DEPTH_TEST); gl.depthFunc(gl.LEQUAL); } else { gl.disable(gl.DEPTH_TEST); } this.maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE); this.lastSrcBlend = gl.ONE; this.lastDestBlend = gl.ONE_MINUS_SRC_ALPHA; this.vertexData = new Float32Array(MAX_VERTICES * (this.enableFrontToBack ? 3 : 2)); this.texcoordData = new Float32Array(MAX_VERTICES * 2); this.pointData = new Float32Array(MAX_POINTS * 4); this.pointBuffer = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, this.pointBuffer); gl.bufferData(gl.ARRAY_BUFFER, this.pointData.byteLength, gl.DYNAMIC_DRAW); this.vertexBuffers = new Array(MULTI_BUFFERS); this.texcoordBuffers = new Array(MULTI_BUFFERS); for (i = 0; i < MULTI_BUFFERS; i++) { this.vertexBuffers[i] = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffers[i]); gl.bufferData(gl.ARRAY_BUFFER, this.vertexData.byteLength, gl.DYNAMIC_DRAW); this.texcoordBuffers[i] = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, this.texcoordBuffers[i]); gl.bufferData(gl.ARRAY_BUFFER, this.texcoordData.byteLength, gl.DYNAMIC_DRAW); } this.curBuffer = 0; this.indexBuffer = gl.createBuffer(); gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer); var indexData = new Uint16Array(MAX_INDICES); i = 0, len = MAX_INDICES; var fv = 0; while (i < len) { indexData[i++] = fv; // top left indexData[i++] = fv + 1; // top right indexData[i++] = fv + 2; // bottom right (first tri) indexData[i++] = fv; // top left indexData[i++] = fv + 2; // bottom right indexData[i++] = fv + 3; // bottom left fv += 4; } gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indexData, gl.STATIC_DRAW); this.vertexPtr = 0; this.texPtr = 0; this.pointPtr = 0; var fsSource, vsSource; this.shaderPrograms = []; fsSource = [ "varying mediump vec2 vTex;", "uniform lowp float opacity;", "uniform lowp sampler2D samplerFront;", "void main(void) {", " gl_FragColor = texture2D(samplerFront, vTex);", " gl_FragColor *= opacity;", "}" ].join("\n"); if (this.enableFrontToBack) { vsSource = [ "attribute highp vec3 aPos;", "attribute mediump vec2 aTex;", "varying mediump vec2 vTex;", "uniform highp mat4 matP;", "uniform highp mat4 matMV;", "void main(void) {", " gl_Position = matP * matMV * vec4(aPos.x, aPos.y, aPos.z, 1.0);", " vTex = aTex;", "}" ].join("\n"); } else { vsSource = [ "attribute highp vec2 aPos;", "attribute mediump vec2 aTex;", "varying mediump vec2 vTex;", "uniform highp mat4 matP;", "uniform highp mat4 matMV;", "void main(void) {", " gl_Position = matP * matMV * vec4(aPos.x, aPos.y, 0.0, 1.0);", " vTex = aTex;", "}" ].join("\n"); } var shaderProg = this.createShaderProgram({src: fsSource}, vsSource, ""); ; this.shaderPrograms.push(shaderProg); // Default shader is always shader 0 fsSource = [ "uniform mediump sampler2D samplerFront;", "varying lowp float opacity;", "void main(void) {", " gl_FragColor = texture2D(samplerFront, gl_PointCoord);", " gl_FragColor *= opacity;", "}" ].join("\n"); var pointVsSource = [ "attribute vec4 aPos;", "varying float opacity;", "uniform mat4 matP;", "uniform mat4 matMV;", "void main(void) {", " gl_Position = matP * matMV * vec4(aPos.x, aPos.y, 0.0, 1.0);", " gl_PointSize = aPos.z;", " opacity = aPos.w;", "}" ].join("\n"); shaderProg = this.createShaderProgram({src: fsSource}, pointVsSource, ""); ; this.shaderPrograms.push(shaderProg); // Point shader is always shader 1 fsSource = [ "varying mediump vec2 vTex;", "uniform lowp sampler2D samplerFront;", "void main(void) {", " if (texture2D(samplerFront, vTex).a < 1.0)", " discard;", // discarding non-opaque fragments "}" ].join("\n"); var shaderProg = this.createShaderProgram({src: fsSource}, vsSource, ""); ; this.shaderPrograms.push(shaderProg); // Early-Z shader is always shader 2 fsSource = [ "uniform lowp vec4 colorFill;", "void main(void) {", " gl_FragColor = colorFill;", "}" ].join("\n"); var shaderProg = this.createShaderProgram({src: fsSource}, vsSource, ""); ; this.shaderPrograms.push(shaderProg); // Fill-color shader is always shader 3 for (var shader_name in cr.shaders) { if (cr.shaders.hasOwnProperty(shader_name)) this.shaderPrograms.push(this.createShaderProgram(cr.shaders[shader_name], vsSource, shader_name)); } gl.activeTexture(gl.TEXTURE0); gl.bindTexture(gl.TEXTURE_2D, null); this.batch = []; this.batchPtr = 0; this.hasQuadBatchTop = false; this.hasPointBatchTop = false; this.lastProgram = -1; // start -1 so first switchProgram can do work this.currentProgram = -1; // current program during batch execution this.currentShader = null; this.fbo = gl.createFramebuffer(); this.renderToTex = null; this.depthBuffer = null; this.attachedDepthBuffer = false; // wait until first size call to attach, otherwise it has no storage if (this.enableFrontToBack) { this.depthBuffer = gl.createRenderbuffer(); } this.tmpVec3 = vec3.create([0, 0, 0]); ; var pointsizes = gl.getParameter(gl.ALIASED_POINT_SIZE_RANGE); this.minPointSize = pointsizes[0]; this.maxPointSize = pointsizes[1]; if (this.maxPointSize > 2048) this.maxPointSize = 2048; ; this.switchProgram(0); cr.seal(this); }; function GLShaderProgram(gl, shaderProgram, name) { this.gl = gl; this.shaderProgram = shaderProgram; this.name = name; this.locAPos = gl.getAttribLocation(shaderProgram, "aPos"); this.locATex = gl.getAttribLocation(shaderProgram, "aTex"); this.locMatP = gl.getUniformLocation(shaderProgram, "matP"); this.locMatMV = gl.getUniformLocation(shaderProgram, "matMV"); this.locOpacity = gl.getUniformLocation(shaderProgram, "opacity"); this.locColorFill = gl.getUniformLocation(shaderProgram, "colorFill"); this.locSamplerFront = gl.getUniformLocation(shaderProgram, "samplerFront"); this.locSamplerBack = gl.getUniformLocation(shaderProgram, "samplerBack"); this.locDestStart = gl.getUniformLocation(shaderProgram, "destStart"); this.locDestEnd = gl.getUniformLocation(shaderProgram, "destEnd"); this.locSeconds = gl.getUniformLocation(shaderProgram, "seconds"); this.locPixelWidth = gl.getUniformLocation(shaderProgram, "pixelWidth"); this.locPixelHeight = gl.getUniformLocation(shaderProgram, "pixelHeight"); this.locLayerScale = gl.getUniformLocation(shaderProgram, "layerScale"); this.locLayerAngle = gl.getUniformLocation(shaderProgram, "layerAngle"); this.locViewOrigin = gl.getUniformLocation(shaderProgram, "viewOrigin"); this.locScrollPos = gl.getUniformLocation(shaderProgram, "scrollPos"); this.hasAnyOptionalUniforms = !!(this.locPixelWidth || this.locPixelHeight || this.locSeconds || this.locSamplerBack || this.locDestStart || this.locDestEnd || this.locLayerScale || this.locLayerAngle || this.locViewOrigin || this.locScrollPos); this.lpPixelWidth = -999; // set to something unlikely so never counts as cached on first set this.lpPixelHeight = -999; this.lpOpacity = 1; this.lpDestStartX = 0.0; this.lpDestStartY = 0.0; this.lpDestEndX = 1.0; this.lpDestEndY = 1.0; this.lpLayerScale = 1.0; this.lpLayerAngle = 0.0; this.lpViewOriginX = 0.0; this.lpViewOriginY = 0.0; this.lpScrollPosX = 0.0; this.lpScrollPosY = 0.0; this.lpSeconds = 0.0; this.lastCustomParams = []; this.lpMatMV = mat4.create(); if (this.locOpacity) gl.uniform1f(this.locOpacity, 1); if (this.locColorFill) gl.uniform4f(this.locColorFill, 1.0, 1.0, 1.0, 1.0); if (this.locSamplerFront) gl.uniform1i(this.locSamplerFront, 0); if (this.locSamplerBack) gl.uniform1i(this.locSamplerBack, 1); if (this.locDestStart) gl.uniform2f(this.locDestStart, 0.0, 0.0); if (this.locDestEnd) gl.uniform2f(this.locDestEnd, 1.0, 1.0); if (this.locLayerScale) gl.uniform1f(this.locLayerScale, 1.0); if (this.locLayerAngle) gl.uniform1f(this.locLayerAngle, 0.0); if (this.locViewOrigin) gl.uniform2f(this.locViewOrigin, 0.0, 0.0); if (this.locScrollPos) gl.uniform2f(this.locScrollPos, 0.0, 0.0); if (this.locSeconds) gl.uniform1f(this.locSeconds, 0.0); this.hasCurrentMatMV = false; // matMV needs updating }; function areMat4sEqual(a, b) { return a[0]===b[0]&&a[1]===b[1]&&a[2]===b[2]&&a[3]===b[3]&& a[4]===b[4]&&a[5]===b[5]&&a[6]===b[6]&&a[7]===b[7]&& a[8]===b[8]&&a[9]===b[9]&&a[10]===b[10]&&a[11]===b[11]&& a[12]===b[12]&&a[13]===b[13]&&a[14]===b[14]&&a[15]===b[15]; }; GLShaderProgram.prototype.updateMatMV = function (mv) { if (areMat4sEqual(this.lpMatMV, mv)) return; // no change, save the expensive GL call mat4.set(mv, this.lpMatMV); this.gl.uniformMatrix4fv(this.locMatMV, false, mv); }; GLWrap_.prototype.createShaderProgram = function(shaderEntry, vsSource, name) { var gl = this.gl; var fragmentShader = gl.createShader(gl.FRAGMENT_SHADER); gl.shaderSource(fragmentShader, shaderEntry.src); gl.compileShader(fragmentShader); if (!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS)) { var compilationlog = gl.getShaderInfoLog(fragmentShader); gl.deleteShader(fragmentShader); throw new Error("error compiling fragment shader: " + compilationlog); } var vertexShader = gl.createShader(gl.VERTEX_SHADER); gl.shaderSource(vertexShader, vsSource); gl.compileShader(vertexShader); if (!gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS)) { var compilationlog = gl.getShaderInfoLog(vertexShader); gl.deleteShader(fragmentShader); gl.deleteShader(vertexShader); throw new Error("error compiling vertex shader: " + compilationlog); } var shaderProgram = gl.createProgram(); gl.attachShader(shaderProgram, fragmentShader); gl.attachShader(shaderProgram, vertexShader); gl.linkProgram(shaderProgram); if (!gl.getProgramParameter(shaderProgram, gl.LINK_STATUS)) { var compilationlog = gl.getProgramInfoLog(shaderProgram); gl.deleteShader(fragmentShader); gl.deleteShader(vertexShader); gl.deleteProgram(shaderProgram); throw new Error("error linking shader program: " + compilationlog); } gl.useProgram(shaderProgram); gl.deleteShader(fragmentShader); gl.deleteShader(vertexShader); var ret = new GLShaderProgram(gl, shaderProgram, name); ret.extendBoxHorizontal = shaderEntry.extendBoxHorizontal || 0; ret.extendBoxVertical = shaderEntry.extendBoxVertical || 0; ret.crossSampling = !!shaderEntry.crossSampling; ret.preservesOpaqueness = !!shaderEntry.preservesOpaqueness; ret.animated = !!shaderEntry.animated; ret.parameters = shaderEntry.parameters || []; var i, len; for (i = 0, len = ret.parameters.length; i < len; i++) { ret.parameters[i][1] = gl.getUniformLocation(shaderProgram, ret.parameters[i][0]); ret.lastCustomParams.push(0); gl.uniform1f(ret.parameters[i][1], 0); } cr.seal(ret); return ret; }; GLWrap_.prototype.getShaderIndex = function(name_) { var i, len; for (i = 0, len = this.shaderPrograms.length; i < len; i++) { if (this.shaderPrograms[i].name === name_) return i; } return -1; }; GLWrap_.prototype.project = function (x, y, out) { var mv = this.matMV; var proj = this.matP; var fTempo = [0, 0, 0, 0, 0, 0, 0, 0]; fTempo[0] = mv[0]*x+mv[4]*y+mv[12]; fTempo[1] = mv[1]*x+mv[5]*y+mv[13]; fTempo[2] = mv[2]*x+mv[6]*y+mv[14]; fTempo[3] = mv[3]*x+mv[7]*y+mv[15]; fTempo[4] = proj[0]*fTempo[0]+proj[4]*fTempo[1]+proj[8]*fTempo[2]+proj[12]*fTempo[3]; fTempo[5] = proj[1]*fTempo[0]+proj[5]*fTempo[1]+proj[9]*fTempo[2]+proj[13]*fTempo[3]; fTempo[6] = proj[2]*fTempo[0]+proj[6]*fTempo[1]+proj[10]*fTempo[2]+proj[14]*fTempo[3]; fTempo[7] = -fTempo[2]; if(fTempo[7]===0.0) //The w value return; fTempo[7]=1.0/fTempo[7]; fTempo[4]*=fTempo[7]; fTempo[5]*=fTempo[7]; fTempo[6]*=fTempo[7]; out[0]=(fTempo[4]*0.5+0.5)*this.width; out[1]=(fTempo[5]*0.5+0.5)*this.height; }; GLWrap_.prototype.setSize = function(w, h, force) { if (this.width === w && this.height === h && !force) return; this.endBatch(); var gl = this.gl; this.width = w; this.height = h; gl.viewport(0, 0, w, h); mat4.lookAt(this.cam, this.look, this.up, this.matMV); if (this.enableFrontToBack) { mat4.ortho(-w/2, w/2, h/2, -h/2, this.zNear, this.zFar, this.matP); this.worldScale[0] = 1; this.worldScale[1] = 1; } else { mat4.perspective(45, w / h, this.zNear, this.zFar, this.matP); var tl = [0, 0]; var br = [0, 0]; this.project(0, 0, tl); this.project(1, 1, br); this.worldScale[0] = 1 / (br[0] - tl[0]); this.worldScale[1] = -1 / (br[1] - tl[1]); } var i, len, s; for (i = 0, len = this.shaderPrograms.length; i < len; i++) { s = this.shaderPrograms[i]; s.hasCurrentMatMV = false; if (s.locMatP) { gl.useProgram(s.shaderProgram); gl.uniformMatrix4fv(s.locMatP, false, this.matP); } } gl.useProgram(this.shaderPrograms[this.lastProgram].shaderProgram); gl.bindTexture(gl.TEXTURE_2D, null); gl.activeTexture(gl.TEXTURE1); gl.bindTexture(gl.TEXTURE_2D, null); gl.activeTexture(gl.TEXTURE0); this.lastTexture0 = null; this.lastTexture1 = null; if (this.depthBuffer) { gl.bindFramebuffer(gl.FRAMEBUFFER, this.fbo); gl.bindRenderbuffer(gl.RENDERBUFFER, this.depthBuffer); gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, this.width, this.height); if (!this.attachedDepthBuffer) { gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, this.depthBuffer); this.attachedDepthBuffer = true; } gl.bindRenderbuffer(gl.RENDERBUFFER, null); gl.bindFramebuffer(gl.FRAMEBUFFER, null); this.renderToTex = null; } }; GLWrap_.prototype.resetModelView = function () { mat4.lookAt(this.cam, this.look, this.up, this.matMV); mat4.scale(this.matMV, this.worldScale); }; GLWrap_.prototype.translate = function (x, y) { if (x === 0 && y === 0) return; this.tmpVec3[0] = x;// * this.worldScale[0]; this.tmpVec3[1] = y;// * this.worldScale[1]; this.tmpVec3[2] = 0; mat4.translate(this.matMV, this.tmpVec3); }; GLWrap_.prototype.scale = function (x, y) { if (x === 1 && y === 1) return; this.tmpVec3[0] = x; this.tmpVec3[1] = y; this.tmpVec3[2] = 1; mat4.scale(this.matMV, this.tmpVec3); }; GLWrap_.prototype.rotateZ = function (a) { if (a === 0) return; mat4.rotateZ(this.matMV, a); }; GLWrap_.prototype.updateModelView = function() { if (areMat4sEqual(this.lastMV, this.matMV)) return; var b = this.pushBatch(); b.type = BATCH_UPDATEMODELVIEW; if (b.mat4param) mat4.set(this.matMV, b.mat4param); else b.mat4param = mat4.create(this.matMV); mat4.set(this.matMV, this.lastMV); this.hasQuadBatchTop = false; this.hasPointBatchTop = false; }; /* var debugBatch = false; jQuery(document).mousedown( function(info) { if (info.which === 2) debugBatch = true; } ); */ GLWrap_.prototype.setEarlyZIndex = function (i) { if (!this.enableFrontToBack) return; if (i > 32760) i = 32760; this.currentZ = this.cam[2] - this.zNear - i * this.zIncrement; }; function GLBatchJob(type_, glwrap_) { this.type = type_; this.glwrap = glwrap_; this.gl = glwrap_.gl; this.opacityParam = 0; // for setOpacity() this.startIndex = 0; // for quad() this.indexCount = 0; // " this.texParam = null; // for setTexture() this.mat4param = null; // for updateModelView() this.shaderParams = []; // for user parameters cr.seal(this); }; GLBatchJob.prototype.doSetEarlyZPass = function () { var gl = this.gl; var glwrap = this.glwrap; if (this.startIndex !== 0) // enable { gl.depthMask(true); // enable depth writes gl.colorMask(false, false, false, false); // disable color writes gl.disable(gl.BLEND); // no color writes so disable blend gl.bindFramebuffer(gl.FRAMEBUFFER, glwrap.fbo); gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, null, 0); gl.clear(gl.DEPTH_BUFFER_BIT); // auto-clear depth buffer gl.bindFramebuffer(gl.FRAMEBUFFER, null); glwrap.isBatchInEarlyZPass = true; } else { gl.depthMask(false); // disable depth writes, only test existing depth values gl.colorMask(true, true, true, true); // enable color writes gl.enable(gl.BLEND); // turn blending back on glwrap.isBatchInEarlyZPass = false; } }; GLBatchJob.prototype.doSetTexture = function () { this.gl.bindTexture(this.gl.TEXTURE_2D, this.texParam); }; GLBatchJob.prototype.doSetTexture1 = function () { var gl = this.gl; gl.activeTexture(gl.TEXTURE1); gl.bindTexture(gl.TEXTURE_2D, this.texParam); gl.activeTexture(gl.TEXTURE0); }; GLBatchJob.prototype.doSetOpacity = function () { var o = this.opacityParam; var glwrap = this.glwrap; glwrap.currentOpacity = o; var curProg = glwrap.currentShader; if (curProg.locOpacity && curProg.lpOpacity !== o) { curProg.lpOpacity = o; this.gl.uniform1f(curProg.locOpacity, o); } }; GLBatchJob.prototype.doQuad = function () { this.gl.drawElements(this.gl.TRIANGLES, this.indexCount, this.gl.UNSIGNED_SHORT, this.startIndex); }; GLBatchJob.prototype.doSetBlend = function () { this.gl.blendFunc(this.startIndex, this.indexCount); }; GLBatchJob.prototype.doUpdateModelView = function () { var i, len, s, shaderPrograms = this.glwrap.shaderPrograms, currentProgram = this.glwrap.currentProgram; for (i = 0, len = shaderPrograms.length; i < len; i++) { s = shaderPrograms[i]; if (i === currentProgram && s.locMatMV) { s.updateMatMV(this.mat4param); s.hasCurrentMatMV = true; } else s.hasCurrentMatMV = false; } mat4.set(this.mat4param, this.glwrap.currentMV); }; GLBatchJob.prototype.doRenderToTexture = function () { var gl = this.gl; var glwrap = this.glwrap; if (this.texParam) { if (glwrap.lastTexture1 === this.texParam) { gl.activeTexture(gl.TEXTURE1); gl.bindTexture(gl.TEXTURE_2D, null); glwrap.lastTexture1 = null; gl.activeTexture(gl.TEXTURE0); } gl.bindFramebuffer(gl.FRAMEBUFFER, glwrap.fbo); if (!glwrap.isBatchInEarlyZPass) { gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.texParam, 0); } } else { if (!glwrap.enableFrontToBack) { gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, null, 0); } gl.bindFramebuffer(gl.FRAMEBUFFER, null); } }; GLBatchJob.prototype.doClear = function () { var gl = this.gl; var mode = this.startIndex; if (mode === 0) // clear whole surface { gl.clearColor(this.mat4param[0], this.mat4param[1], this.mat4param[2], this.mat4param[3]); gl.clear(gl.COLOR_BUFFER_BIT); } else if (mode === 1) // clear rectangle { gl.enable(gl.SCISSOR_TEST); gl.scissor(this.mat4param[0], this.mat4param[1], this.mat4param[2], this.mat4param[3]); gl.clearColor(0, 0, 0, 0); gl.clear(gl.COLOR_BUFFER_BIT); gl.disable(gl.SCISSOR_TEST); } else // clear depth { gl.clear(gl.DEPTH_BUFFER_BIT); } }; GLBatchJob.prototype.doSetDepthTestEnabled = function () { var gl = this.gl; var enable = this.startIndex; if (enable !== 0) { gl.enable(gl.DEPTH_TEST); } else { gl.disable(gl.DEPTH_TEST); } }; GLBatchJob.prototype.doPoints = function () { var gl = this.gl; var glwrap = this.glwrap; if (glwrap.enableFrontToBack) gl.disable(gl.DEPTH_TEST); var s = glwrap.shaderPrograms[1]; gl.useProgram(s.shaderProgram); if (!s.hasCurrentMatMV && s.locMatMV) { s.updateMatMV(glwrap.currentMV); s.hasCurrentMatMV = true; } gl.enableVertexAttribArray(s.locAPos); gl.bindBuffer(gl.ARRAY_BUFFER, glwrap.pointBuffer); gl.vertexAttribPointer(s.locAPos, 4, gl.FLOAT, false, 0, 0); gl.drawArrays(gl.POINTS, this.startIndex / 4, this.indexCount); s = glwrap.currentShader; gl.useProgram(s.shaderProgram); if (s.locAPos >= 0) { gl.enableVertexAttribArray(s.locAPos); gl.bindBuffer(gl.ARRAY_BUFFER, glwrap.vertexBuffers[glwrap.curBuffer]); gl.vertexAttribPointer(s.locAPos, glwrap.enableFrontToBack ? 3 : 2, gl.FLOAT, false, 0, 0); } if (s.locATex >= 0) { gl.enableVertexAttribArray(s.locATex); gl.bindBuffer(gl.ARRAY_BUFFER, glwrap.texcoordBuffers[glwrap.curBuffer]); gl.vertexAttribPointer(s.locATex, 2, gl.FLOAT, false, 0, 0); } if (glwrap.enableFrontToBack) gl.enable(gl.DEPTH_TEST); }; GLBatchJob.prototype.doSetProgram = function () { var gl = this.gl; var glwrap = this.glwrap; var s = glwrap.shaderPrograms[this.startIndex]; // recycled param to save memory glwrap.currentProgram = this.startIndex; // current batch program glwrap.currentShader = s; gl.useProgram(s.shaderProgram); // switch to if (!s.hasCurrentMatMV && s.locMatMV) { s.updateMatMV(glwrap.currentMV); s.hasCurrentMatMV = true; } if (s.locOpacity && s.lpOpacity !== glwrap.currentOpacity) { s.lpOpacity = glwrap.currentOpacity; gl.uniform1f(s.locOpacity, glwrap.currentOpacity); } if (s.locAPos >= 0) { gl.enableVertexAttribArray(s.locAPos); gl.bindBuffer(gl.ARRAY_BUFFER, glwrap.vertexBuffers[glwrap.curBuffer]); gl.vertexAttribPointer(s.locAPos, glwrap.enableFrontToBack ? 3 : 2, gl.FLOAT, false, 0, 0); } if (s.locATex >= 0) { gl.enableVertexAttribArray(s.locATex); gl.bindBuffer(gl.ARRAY_BUFFER, glwrap.texcoordBuffers[glwrap.curBuffer]); gl.vertexAttribPointer(s.locATex, 2, gl.FLOAT, false, 0, 0); } } GLBatchJob.prototype.doSetColor = function () { var s = this.glwrap.currentShader; var mat4param = this.mat4param; this.gl.uniform4f(s.locColorFill, mat4param[0], mat4param[1], mat4param[2], mat4param[3]); }; GLBatchJob.prototype.doSetProgramParameters = function () { var i, len, s = this.glwrap.currentShader; var gl = this.gl; var mat4param = this.mat4param; if (s.locSamplerBack && this.glwrap.lastTexture1 !== this.texParam) { gl.activeTexture(gl.TEXTURE1); gl.bindTexture(gl.TEXTURE_2D, this.texParam); this.glwrap.lastTexture1 = this.texParam; gl.activeTexture(gl.TEXTURE0); } var v = mat4param[0]; var v2; if (s.locPixelWidth && v !== s.lpPixelWidth) { s.lpPixelWidth = v; gl.uniform1f(s.locPixelWidth, v); } v = mat4param[1]; if (s.locPixelHeight && v !== s.lpPixelHeight) { s.lpPixelHeight = v; gl.uniform1f(s.locPixelHeight, v); } v = mat4param[2]; v2 = mat4param[3]; if (s.locDestStart && (v !== s.lpDestStartX || v2 !== s.lpDestStartY)) { s.lpDestStartX = v; s.lpDestStartY = v2; gl.uniform2f(s.locDestStart, v, v2); } v = mat4param[4]; v2 = mat4param[5]; if (s.locDestEnd && (v !== s.lpDestEndX || v2 !== s.lpDestEndY)) { s.lpDestEndX = v; s.lpDestEndY = v2; gl.uniform2f(s.locDestEnd, v, v2); } v = mat4param[6]; if (s.locLayerScale && v !== s.lpLayerScale) { s.lpLayerScale = v; gl.uniform1f(s.locLayerScale, v); } v = mat4param[7]; if (s.locLayerAngle && v !== s.lpLayerAngle) { s.lpLayerAngle = v; gl.uniform1f(s.locLayerAngle, v); } v = mat4param[8]; v2 = mat4param[9]; if (s.locViewOrigin && (v !== s.lpViewOriginX || v2 !== s.lpViewOriginY)) { s.lpViewOriginX = v; s.lpViewOriginY = v2; gl.uniform2f(s.locViewOrigin, v, v2); } v = mat4param[10]; v2 = mat4param[11]; if (s.locScrollPos && (v !== s.lpScrollPosX || v2 !== s.lpScrollPosY)) { s.lpScrollPosX = v; s.lpScrollPosY = v2; gl.uniform2f(s.locScrollPos, v, v2); } v = mat4param[12]; if (s.locSeconds && v !== s.lpSeconds) { s.lpSeconds = v; gl.uniform1f(s.locSeconds, v); } if (s.parameters.length) { for (i = 0, len = s.parameters.length; i < len; i++) { v = this.shaderParams[i]; if (v !== s.lastCustomParams[i]) { s.lastCustomParams[i] = v; gl.uniform1f(s.parameters[i][1], v); } } } }; GLWrap_.prototype.pushBatch = function () { if (this.batchPtr === this.batch.length) this.batch.push(new GLBatchJob(BATCH_NULL, this)); return this.batch[this.batchPtr++]; }; GLWrap_.prototype.endBatch = function () { if (this.batchPtr === 0) return; if (this.gl.isContextLost()) return; var gl = this.gl; if (this.pointPtr > 0) { gl.bindBuffer(gl.ARRAY_BUFFER, this.pointBuffer); gl.bufferSubData(gl.ARRAY_BUFFER, 0, this.pointData.subarray(0, this.pointPtr)); if (s && s.locAPos >= 0 && s.name === "") gl.vertexAttribPointer(s.locAPos, 4, gl.FLOAT, false, 0, 0); } if (this.vertexPtr > 0) { var s = this.currentShader; gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffers[this.curBuffer]); gl.bufferSubData(gl.ARRAY_BUFFER, 0, this.vertexData.subarray(0, this.vertexPtr)); if (s && s.locAPos >= 0 && s.name !== "") gl.vertexAttribPointer(s.locAPos, this.enableFrontToBack ? 3 : 2, gl.FLOAT, false, 0, 0); gl.bindBuffer(gl.ARRAY_BUFFER, this.texcoordBuffers[this.curBuffer]); gl.bufferSubData(gl.ARRAY_BUFFER, 0, this.texcoordData.subarray(0, this.texPtr)); if (s && s.locATex >= 0 && s.name !== "") gl.vertexAttribPointer(s.locATex, 2, gl.FLOAT, false, 0, 0); } var i, len, b; for (i = 0, len = this.batchPtr; i < len; i++) { b = this.batch[i]; switch (b.type) { case 1: b.doQuad(); break; case 2: b.doSetTexture(); break; case 3: b.doSetOpacity(); break; case 4: b.doSetBlend(); break; case 5: b.doUpdateModelView(); break; case 6: b.doRenderToTexture(); break; case 7: b.doClear(); break; case 8: b.doPoints(); break; case 9: b.doSetProgram(); break; case 10: b.doSetProgramParameters(); break; case 11: b.doSetTexture1(); break; case 12: b.doSetColor(); break; case 13: b.doSetDepthTestEnabled(); break; case 14: b.doSetEarlyZPass(); break; } } this.batchPtr = 0; this.vertexPtr = 0; this.texPtr = 0; this.pointPtr = 0; this.hasQuadBatchTop = false; this.hasPointBatchTop = false; this.isBatchInEarlyZPass = false; this.curBuffer++; if (this.curBuffer >= MULTI_BUFFERS) this.curBuffer = 0; }; GLWrap_.prototype.setOpacity = function (op) { if (op === this.lastOpacity) return; if (this.isEarlyZPass) return; // ignore var b = this.pushBatch(); b.type = BATCH_SETOPACITY; b.opacityParam = op; this.lastOpacity = op; this.hasQuadBatchTop = false; this.hasPointBatchTop = false; }; GLWrap_.prototype.setTexture = function (tex) { if (tex === this.lastTexture0) return; ; var b = this.pushBatch(); b.type = BATCH_SETTEXTURE; b.texParam = tex; this.lastTexture0 = tex; this.hasQuadBatchTop = false; this.hasPointBatchTop = false; }; GLWrap_.prototype.setBlend = function (s, d) { if (s === this.lastSrcBlend && d === this.lastDestBlend) return; if (this.isEarlyZPass) return; // ignore var b = this.pushBatch(); b.type = BATCH_SETBLEND; b.startIndex = s; // recycle params to save memory b.indexCount = d; this.lastSrcBlend = s; this.lastDestBlend = d; this.hasQuadBatchTop = false; this.hasPointBatchTop = false; }; GLWrap_.prototype.isPremultipliedAlphaBlend = function () { return (this.lastSrcBlend === this.gl.ONE && this.lastDestBlend === this.gl.ONE_MINUS_SRC_ALPHA); }; GLWrap_.prototype.setAlphaBlend = function () { this.setBlend(this.gl.ONE, this.gl.ONE_MINUS_SRC_ALPHA); }; GLWrap_.prototype.setNoPremultiplyAlphaBlend = function () { this.setBlend(this.gl.SRC_ALPHA, this.gl.ONE_MINUS_SRC_ALPHA); }; var LAST_VERTEX = MAX_VERTICES * 2 - 8; GLWrap_.prototype.quad = function(tlx, tly, trx, try_, brx, bry, blx, bly) { if (this.vertexPtr >= LAST_VERTEX) this.endBatch(); var v = this.vertexPtr; // vertex cursor var t = this.texPtr; var vd = this.vertexData; // vertex data array var td = this.texcoordData; // texture coord data array var currentZ = this.currentZ; if (this.hasQuadBatchTop) { this.batch[this.batchPtr - 1].indexCount += 6; } else { var b = this.pushBatch(); b.type = BATCH_QUAD; b.startIndex = this.enableFrontToBack ? v : (v / 2) * 3; b.indexCount = 6; this.hasQuadBatchTop = true; this.hasPointBatchTop = false; } if (this.enableFrontToBack) { vd[v++] = tlx; vd[v++] = tly; vd[v++] = currentZ; vd[v++] = trx; vd[v++] = try_; vd[v++] = currentZ; vd[v++] = brx; vd[v++] = bry; vd[v++] = currentZ; vd[v++] = blx; vd[v++] = bly; vd[v++] = currentZ; } else { vd[v++] = tlx; vd[v++] = tly; vd[v++] = trx; vd[v++] = try_; vd[v++] = brx; vd[v++] = bry; vd[v++] = blx; vd[v++] = bly; } td[t++] = 0; td[t++] = 0; td[t++] = 1; td[t++] = 0; td[t++] = 1; td[t++] = 1; td[t++] = 0; td[t++] = 1; this.vertexPtr = v; this.texPtr = t; }; GLWrap_.prototype.quadTex = function(tlx, tly, trx, try_, brx, bry, blx, bly, rcTex) { if (this.vertexPtr >= LAST_VERTEX) this.endBatch(); var v = this.vertexPtr; // vertex cursor var t = this.texPtr; var vd = this.vertexData; // vertex data array var td = this.texcoordData; // texture coord data array var currentZ = this.currentZ; if (this.hasQuadBatchTop) { this.batch[this.batchPtr - 1].indexCount += 6; } else { var b = this.pushBatch(); b.type = BATCH_QUAD; b.startIndex = this.enableFrontToBack ? v : (v / 2) * 3; b.indexCount = 6; this.hasQuadBatchTop = true; this.hasPointBatchTop = false; } var rc_left = rcTex.left; var rc_top = rcTex.top; var rc_right = rcTex.right; var rc_bottom = rcTex.bottom; if (this.enableFrontToBack) { vd[v++] = tlx; vd[v++] = tly; vd[v++] = currentZ; vd[v++] = trx; vd[v++] = try_; vd[v++] = currentZ; vd[v++] = brx; vd[v++] = bry; vd[v++] = currentZ; vd[v++] = blx; vd[v++] = bly; vd[v++] = currentZ; } else { vd[v++] = tlx; vd[v++] = tly; vd[v++] = trx; vd[v++] = try_; vd[v++] = brx; vd[v++] = bry; vd[v++] = blx; vd[v++] = bly; } td[t++] = rc_left; td[t++] = rc_top; td[t++] = rc_right; td[t++] = rc_top; td[t++] = rc_right; td[t++] = rc_bottom; td[t++] = rc_left; td[t++] = rc_bottom; this.vertexPtr = v; this.texPtr = t; }; GLWrap_.prototype.quadTexUV = function(tlx, tly, trx, try_, brx, bry, blx, bly, tlu, tlv, tru, trv, bru, brv, blu, blv) { if (this.vertexPtr >= LAST_VERTEX) this.endBatch(); var v = this.vertexPtr; // vertex cursor var t = this.texPtr; var vd = this.vertexData; // vertex data array var td = this.texcoordData; // texture coord data array var currentZ = this.currentZ; if (this.hasQuadBatchTop) { this.batch[this.batchPtr - 1].indexCount += 6; } else { var b = this.pushBatch(); b.type = BATCH_QUAD; b.startIndex = this.enableFrontToBack ? v : (v / 2) * 3; b.indexCount = 6; this.hasQuadBatchTop = true; this.hasPointBatchTop = false; } if (this.enableFrontToBack) { vd[v++] = tlx; vd[v++] = tly; vd[v++] = currentZ; vd[v++] = trx; vd[v++] = try_; vd[v++] = currentZ; vd[v++] = brx; vd[v++] = bry; vd[v++] = currentZ; vd[v++] = blx; vd[v++] = bly; vd[v++] = currentZ; } else { vd[v++] = tlx; vd[v++] = tly; vd[v++] = trx; vd[v++] = try_; vd[v++] = brx; vd[v++] = bry; vd[v++] = blx; vd[v++] = bly; } td[t++] = tlu; td[t++] = tlv; td[t++] = tru; td[t++] = trv; td[t++] = bru; td[t++] = brv; td[t++] = blu; td[t++] = blv; this.vertexPtr = v; this.texPtr = t; }; GLWrap_.prototype.convexPoly = function(pts) { var pts_count = pts.length / 2; ; var tris = pts_count - 2; // 3 points = 1 tri, 4 points = 2 tris, 5 points = 3 tris etc. var last_tri = tris - 1; var p0x = pts[0]; var p0y = pts[1]; var i, i2, p1x, p1y, p2x, p2y, p3x, p3y; for (i = 0; i < tris; i += 2) // draw 2 triangles at a time { i2 = i * 2; p1x = pts[i2 + 2]; p1y = pts[i2 + 3]; p2x = pts[i2 + 4]; p2y = pts[i2 + 5]; if (i === last_tri) { this.quad(p0x, p0y, p1x, p1y, p2x, p2y, p2x, p2y); } else { p3x = pts[i2 + 6]; p3y = pts[i2 + 7]; this.quad(p0x, p0y, p1x, p1y, p2x, p2y, p3x, p3y); } } }; var LAST_POINT = MAX_POINTS - 4; GLWrap_.prototype.point = function(x_, y_, size_, opacity_) { if (this.pointPtr >= LAST_POINT) this.endBatch(); var p = this.pointPtr; // point cursor var pd = this.pointData; // point data array if (this.hasPointBatchTop) { this.batch[this.batchPtr - 1].indexCount++; } else { var b = this.pushBatch(); b.type = BATCH_POINTS; b.startIndex = p; b.indexCount = 1; this.hasPointBatchTop = true; this.hasQuadBatchTop = false; } pd[p++] = x_; pd[p++] = y_; pd[p++] = size_; pd[p++] = opacity_; this.pointPtr = p; }; GLWrap_.prototype.switchProgram = function (progIndex) { if (this.lastProgram === progIndex) return; // no change var shaderProg = this.shaderPrograms[progIndex]; if (!shaderProg) { if (this.lastProgram === 0) return; // already on default shader progIndex = 0; shaderProg = this.shaderPrograms[0]; } var b = this.pushBatch(); b.type = BATCH_SETPROGRAM; b.startIndex = progIndex; this.lastProgram = progIndex; this.hasQuadBatchTop = false; this.hasPointBatchTop = false; }; GLWrap_.prototype.programUsesDest = function (progIndex) { var s = this.shaderPrograms[progIndex]; return !!(s.locDestStart || s.locDestEnd); }; GLWrap_.prototype.programUsesCrossSampling = function (progIndex) { var s = this.shaderPrograms[progIndex]; return !!(s.locDestStart || s.locDestEnd || s.crossSampling); }; GLWrap_.prototype.programPreservesOpaqueness = function (progIndex) { return this.shaderPrograms[progIndex].preservesOpaqueness; }; GLWrap_.prototype.programExtendsBox = function (progIndex) { var s = this.shaderPrograms[progIndex]; return s.extendBoxHorizontal !== 0 || s.extendBoxVertical !== 0; }; GLWrap_.prototype.getProgramBoxExtendHorizontal = function (progIndex) { return this.shaderPrograms[progIndex].extendBoxHorizontal; }; GLWrap_.prototype.getProgramBoxExtendVertical = function (progIndex) { return this.shaderPrograms[progIndex].extendBoxVertical; }; GLWrap_.prototype.getProgramParameterType = function (progIndex, paramIndex) { return this.shaderPrograms[progIndex].parameters[paramIndex][2]; }; GLWrap_.prototype.programIsAnimated = function (progIndex) { return this.shaderPrograms[progIndex].animated; }; GLWrap_.prototype.setProgramParameters = function (backTex, pixelWidth, pixelHeight, destStartX, destStartY, destEndX, destEndY, layerScale, layerAngle, viewOriginLeft, viewOriginTop, scrollPosX, scrollPosY, seconds, params) { var i, len; var s = this.shaderPrograms[this.lastProgram]; var b, mat4param, shaderParams; if (s.hasAnyOptionalUniforms || params.length) { b = this.pushBatch(); b.type = BATCH_SETPROGRAMPARAMETERS; if (b.mat4param) mat4.set(this.matMV, b.mat4param); else b.mat4param = mat4.create(); mat4param = b.mat4param; mat4param[0] = pixelWidth; mat4param[1] = pixelHeight; mat4param[2] = destStartX; mat4param[3] = destStartY; mat4param[4] = destEndX; mat4param[5] = destEndY; mat4param[6] = layerScale; mat4param[7] = layerAngle; mat4param[8] = viewOriginLeft; mat4param[9] = viewOriginTop; mat4param[10] = scrollPosX; mat4param[11] = scrollPosY; mat4param[12] = seconds; if (s.locSamplerBack) { ; b.texParam = backTex; } else b.texParam = null; if (params.length) { shaderParams = b.shaderParams; shaderParams.length = params.length; for (i = 0, len = params.length; i < len; i++) shaderParams[i] = params[i]; } this.hasQuadBatchTop = false; this.hasPointBatchTop = false; } }; GLWrap_.prototype.clear = function (r, g, b_, a) { var b = this.pushBatch(); b.type = BATCH_CLEAR; b.startIndex = 0; // clear all mode if (!b.mat4param) b.mat4param = mat4.create(); b.mat4param[0] = r; b.mat4param[1] = g; b.mat4param[2] = b_; b.mat4param[3] = a; this.hasQuadBatchTop = false; this.hasPointBatchTop = false; }; GLWrap_.prototype.clearRect = function (x, y, w, h) { if (w < 0 || h < 0) return; // invalid clear area var b = this.pushBatch(); b.type = BATCH_CLEAR; b.startIndex = 1; // clear rect mode if (!b.mat4param) b.mat4param = mat4.create(); b.mat4param[0] = x; b.mat4param[1] = y; b.mat4param[2] = w; b.mat4param[3] = h; this.hasQuadBatchTop = false; this.hasPointBatchTop = false; }; GLWrap_.prototype.clearDepth = function () { var b = this.pushBatch(); b.type = BATCH_CLEAR; b.startIndex = 2; // clear depth mode this.hasQuadBatchTop = false; this.hasPointBatchTop = false; }; GLWrap_.prototype.setEarlyZPass = function (e) { if (!this.enableFrontToBack) return; // no depth buffer in use e = !!e; if (this.isEarlyZPass === e) return; // no change var b = this.pushBatch(); b.type = BATCH_SETEARLYZMODE; b.startIndex = (e ? 1 : 0); this.hasQuadBatchTop = false; this.hasPointBatchTop = false; this.isEarlyZPass = e; this.renderToTex = null; if (this.isEarlyZPass) { this.switchProgram(2); // early Z program } else { this.switchProgram(0); // normal rendering } }; GLWrap_.prototype.setDepthTestEnabled = function (e) { if (!this.enableFrontToBack) return; // no depth buffer in use var b = this.pushBatch(); b.type = BATCH_SETDEPTHTEST; b.startIndex = (e ? 1 : 0); this.hasQuadBatchTop = false; this.hasPointBatchTop = false; }; GLWrap_.prototype.fullscreenQuad = function () { mat4.set(this.lastMV, tempMat4); this.resetModelView(); this.updateModelView(); var halfw = this.width / 2; var halfh = this.height / 2; this.quad(-halfw, halfh, halfw, halfh, halfw, -halfh, -halfw, -halfh); mat4.set(tempMat4, this.matMV); this.updateModelView(); }; GLWrap_.prototype.setColorFillMode = function (r_, g_, b_, a_) { this.switchProgram(3); var b = this.pushBatch(); b.type = BATCH_SETCOLOR; if (!b.mat4param) b.mat4param = mat4.create(); b.mat4param[0] = r_; b.mat4param[1] = g_; b.mat4param[2] = b_; b.mat4param[3] = a_; this.hasQuadBatchTop = false; this.hasPointBatchTop = false; }; GLWrap_.prototype.setTextureFillMode = function () { ; this.switchProgram(0); }; GLWrap_.prototype.restoreEarlyZMode = function () { ; this.switchProgram(2); }; GLWrap_.prototype.present = function () { this.endBatch(); this.gl.flush(); /* if (debugBatch) { ; debugBatch = false; } */ }; function nextHighestPowerOfTwo(x) { --x; for (var i = 1; i < 32; i <<= 1) { x = x | x >> i; } return x + 1; } var all_textures = []; var textures_by_src = {}; GLWrap_.prototype.contextLost = function () { cr.clearArray(all_textures); textures_by_src = {}; }; var BF_RGBA8 = 0; var BF_RGB8 = 1; var BF_RGBA4 = 2; var BF_RGB5_A1 = 3; var BF_RGB565 = 4; GLWrap_.prototype.loadTexture = function (img, tiling, linearsampling, pixelformat, tiletype, nomip) { tiling = !!tiling; linearsampling = !!linearsampling; var tex_key = img.src + "," + tiling + "," + linearsampling + (tiling ? ("," + tiletype) : ""); var webGL_texture = null; if (typeof img.src !== "undefined" && textures_by_src.hasOwnProperty(tex_key)) { webGL_texture = textures_by_src[tex_key]; webGL_texture.c2refcount++; return webGL_texture; } this.endBatch(); ; var gl = this.gl; var isPOT = (cr.isPOT(img.width) && cr.isPOT(img.height)); webGL_texture = gl.createTexture(); gl.bindTexture(gl.TEXTURE_2D, webGL_texture); gl.pixelStorei(gl["UNPACK_PREMULTIPLY_ALPHA_WEBGL"], true); var internalformat = gl.RGBA; var format = gl.RGBA; var type = gl.UNSIGNED_BYTE; if (pixelformat && !this.isIE) { switch (pixelformat) { case BF_RGB8: internalformat = gl.RGB; format = gl.RGB; break; case BF_RGBA4: type = gl.UNSIGNED_SHORT_4_4_4_4; break; case BF_RGB5_A1: type = gl.UNSIGNED_SHORT_5_5_5_1; break; case BF_RGB565: internalformat = gl.RGB; format = gl.RGB; type = gl.UNSIGNED_SHORT_5_6_5; break; } } if (this.version === 1 && !isPOT && tiling) { var canvas = document.createElement("canvas"); canvas.width = cr.nextHighestPowerOfTwo(img.width); canvas.height = cr.nextHighestPowerOfTwo(img.height); var ctx = canvas.getContext("2d"); if (typeof ctx["imageSmoothingEnabled"] !== "undefined") { ctx["imageSmoothingEnabled"] = linearsampling; } else { ctx["webkitImageSmoothingEnabled"] = linearsampling; ctx["mozImageSmoothingEnabled"] = linearsampling; ctx["msImageSmoothingEnabled"] = linearsampling; } ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, canvas.width, canvas.height); gl.texImage2D(gl.TEXTURE_2D, 0, internalformat, format, type, canvas); } else gl.texImage2D(gl.TEXTURE_2D, 0, internalformat, format, type, img); if (tiling) { if (tiletype === "repeat-x") { gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); } else if (tiletype === "repeat-y") { gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT); } else { gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT); } } else { gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); } if (linearsampling) { gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); if ((isPOT || this.version >= 2) && this.enable_mipmaps && !nomip) { gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR); gl.generateMipmap(gl.TEXTURE_2D); } else gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); } else { gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); } gl.bindTexture(gl.TEXTURE_2D, null); this.lastTexture0 = null; webGL_texture.c2width = img.width; webGL_texture.c2height = img.height; webGL_texture.c2refcount = 1; webGL_texture.c2texkey = tex_key; all_textures.push(webGL_texture); textures_by_src[tex_key] = webGL_texture; return webGL_texture; }; GLWrap_.prototype.createEmptyTexture = function (w, h, linearsampling, _16bit, tiling) { this.endBatch(); var gl = this.gl; if (this.isIE) _16bit = false; var webGL_texture = gl.createTexture(); gl.bindTexture(gl.TEXTURE_2D, webGL_texture); gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, w, h, 0, gl.RGBA, _16bit ? gl.UNSIGNED_SHORT_4_4_4_4 : gl.UNSIGNED_BYTE, null); if (tiling) { gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT); } else { gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); } gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, linearsampling ? gl.LINEAR : gl.NEAREST); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, linearsampling ? gl.LINEAR : gl.NEAREST); gl.bindTexture(gl.TEXTURE_2D, null); this.lastTexture0 = null; webGL_texture.c2width = w; webGL_texture.c2height = h; all_textures.push(webGL_texture); return webGL_texture; }; GLWrap_.prototype.videoToTexture = function (video_, texture_, _16bit) { this.endBatch(); var gl = this.gl; if (this.isIE) _16bit = false; gl.bindTexture(gl.TEXTURE_2D, texture_); gl.pixelStorei(gl["UNPACK_PREMULTIPLY_ALPHA_WEBGL"], true); try { gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, _16bit ? gl.UNSIGNED_SHORT_4_4_4_4 : gl.UNSIGNED_BYTE, video_); } catch (e) { if (console && console.error) console.error("Error updating WebGL texture: ", e); } gl.bindTexture(gl.TEXTURE_2D, null); this.lastTexture0 = null; }; GLWrap_.prototype.deleteTexture = function (tex) { if (!tex) return; if (typeof tex.c2refcount !== "undefined" && tex.c2refcount > 1) { tex.c2refcount--; return; } this.endBatch(); if (tex === this.lastTexture0) { this.gl.bindTexture(this.gl.TEXTURE_2D, null); this.lastTexture0 = null; } if (tex === this.lastTexture1) { this.gl.activeTexture(this.gl.TEXTURE1); this.gl.bindTexture(this.gl.TEXTURE_2D, null); this.gl.activeTexture(this.gl.TEXTURE0); this.lastTexture1 = null; } cr.arrayFindRemove(all_textures, tex); if (typeof tex.c2texkey !== "undefined") delete textures_by_src[tex.c2texkey]; this.gl.deleteTexture(tex); }; GLWrap_.prototype.estimateVRAM = function () { var total = this.width * this.height * 4 * 2; var i, len, t; for (i = 0, len = all_textures.length; i < len; i++) { t = all_textures[i]; total += (t.c2width * t.c2height * 4); } return total; }; GLWrap_.prototype.textureCount = function () { return all_textures.length; }; GLWrap_.prototype.setRenderingToTexture = function (tex) { if (tex === this.renderToTex) return; ; var b = this.pushBatch(); b.type = BATCH_RENDERTOTEXTURE; b.texParam = tex; this.renderToTex = tex; this.hasQuadBatchTop = false; this.hasPointBatchTop = false; }; cr.GLWrap = GLWrap_; }()); ; (function() { var raf = window["requestAnimationFrame"] || window["mozRequestAnimationFrame"] || window["webkitRequestAnimationFrame"] || window["msRequestAnimationFrame"] || window["oRequestAnimationFrame"]; function Runtime(canvas) { if (!canvas || (!canvas.getContext && !canvas["dc"])) return; if (canvas["c2runtime"]) return; else canvas["c2runtime"] = this; var self = this; this.isCrosswalk = /crosswalk/i.test(navigator.userAgent) || /xwalk/i.test(navigator.userAgent) || !!(typeof window["c2isCrosswalk"] !== "undefined" && window["c2isCrosswalk"]); this.isCordova = this.isCrosswalk || (typeof window["device"] !== "undefined" && (typeof window["device"]["cordova"] !== "undefined" || typeof window["device"]["phonegap"] !== "undefined")) || (typeof window["c2iscordova"] !== "undefined" && window["c2iscordova"]); this.isPhoneGap = this.isCordova; this.isDirectCanvas = !!canvas["dc"]; this.isAppMobi = (typeof window["AppMobi"] !== "undefined" || this.isDirectCanvas); this.isCocoonJs = !!window["c2cocoonjs"]; this.isEjecta = !!window["c2ejecta"]; if (this.isCocoonJs) { CocoonJS["App"]["onSuspended"].addEventListener(function() { self["setSuspended"](true); }); CocoonJS["App"]["onActivated"].addEventListener(function () { self["setSuspended"](false); }); } if (this.isEjecta) { document.addEventListener("pagehide", function() { self["setSuspended"](true); }); document.addEventListener("pageshow", function() { self["setSuspended"](false); }); document.addEventListener("resize", function () { self["setSize"](window.innerWidth, window.innerHeight); }); } this.isDomFree = (this.isDirectCanvas || this.isCocoonJs || this.isEjecta); this.isMicrosoftEdge = /edge\//i.test(navigator.userAgent); this.isIE = (/msie/i.test(navigator.userAgent) || /trident/i.test(navigator.userAgent) || /iemobile/i.test(navigator.userAgent)) && !this.isMicrosoftEdge; this.isTizen = /tizen/i.test(navigator.userAgent); this.isAndroid = /android/i.test(navigator.userAgent) && !this.isTizen && !this.isIE && !this.isMicrosoftEdge; // IE mobile and Tizen masquerade as Android this.isiPhone = (/iphone/i.test(navigator.userAgent) || /ipod/i.test(navigator.userAgent)) && !this.isIE && !this.isMicrosoftEdge; // treat ipod as an iphone; IE mobile masquerades as iPhone this.isiPad = /ipad/i.test(navigator.userAgent); this.isiOS = this.isiPhone || this.isiPad || this.isEjecta; this.isiPhoneiOS6 = (this.isiPhone && /os\s6/i.test(navigator.userAgent)); this.isChrome = (/chrome/i.test(navigator.userAgent) || /chromium/i.test(navigator.userAgent)) && !this.isIE && !this.isMicrosoftEdge; // note true on Chromium-based webview on Android 4.4+; IE 'Edge' mode also pretends to be Chrome this.isAmazonWebApp = /amazonwebappplatform/i.test(navigator.userAgent); this.isFirefox = /firefox/i.test(navigator.userAgent); this.isSafari = /safari/i.test(navigator.userAgent) && !this.isChrome && !this.isIE && !this.isMicrosoftEdge; // Chrome and IE Mobile masquerade as Safari this.isWindows = /windows/i.test(navigator.userAgent); this.isNWjs = (typeof window["c2nodewebkit"] !== "undefined" || typeof window["c2nwjs"] !== "undefined" || /nodewebkit/i.test(navigator.userAgent) || /nwjs/i.test(navigator.userAgent)); this.isNodeWebkit = this.isNWjs; // old name for backwards compat this.isArcade = (typeof window["is_scirra_arcade"] !== "undefined"); this.isWindows8App = !!(typeof window["c2isWindows8"] !== "undefined" && window["c2isWindows8"]); this.isWindows8Capable = !!(typeof window["c2isWindows8Capable"] !== "undefined" && window["c2isWindows8Capable"]); this.isWindowsPhone8 = !!(typeof window["c2isWindowsPhone8"] !== "undefined" && window["c2isWindowsPhone8"]); this.isWindowsPhone81 = !!(typeof window["c2isWindowsPhone81"] !== "undefined" && window["c2isWindowsPhone81"]); this.isWindows10 = !!window["cr_windows10"]; this.isWinJS = (this.isWindows8App || this.isWindows8Capable || this.isWindowsPhone81 || this.isWindows10); // note not WP8.0 this.isBlackberry10 = !!(typeof window["c2isBlackberry10"] !== "undefined" && window["c2isBlackberry10"]); this.isAndroidStockBrowser = (this.isAndroid && !this.isChrome && !this.isCrosswalk && !this.isFirefox && !this.isAmazonWebApp && !this.isDomFree); this.devicePixelRatio = 1; this.isMobile = (this.isCordova || this.isCrosswalk || this.isAppMobi || this.isCocoonJs || this.isAndroid || this.isiOS || this.isWindowsPhone8 || this.isWindowsPhone81 || this.isBlackberry10 || this.isTizen || this.isEjecta); if (!this.isMobile) { this.isMobile = /(blackberry|bb10|playbook|palm|symbian|nokia|windows\s+ce|phone|mobile|tablet|kindle|silk)/i.test(navigator.userAgent); } this.isWKWebView = !!(this.isiOS && this.isCordova && window["webkit"]); if (typeof cr_is_preview !== "undefined" && !this.isNWjs && (window.location.search === "?nw" || /nodewebkit/i.test(navigator.userAgent) || /nwjs/i.test(navigator.userAgent))) { this.isNWjs = true; } this.isDebug = (typeof cr_is_preview !== "undefined" && window.location.search.indexOf("debug") > -1); this.canvas = canvas; this.canvasdiv = document.getElementById("c2canvasdiv"); this.gl = null; this.glwrap = null; this.glUnmaskedRenderer = "(unavailable)"; this.enableFrontToBack = false; this.earlyz_index = 0; this.ctx = null; this.firstInFullscreen = false; this.oldWidth = 0; // for restoring non-fullscreen canvas after fullscreen this.oldHeight = 0; this.canvas.oncontextmenu = function (e) { if (e.preventDefault) e.preventDefault(); return false; }; this.canvas.onselectstart = function (e) { if (e.preventDefault) e.preventDefault(); return false; }; this.canvas.ontouchstart = function (e) { if(e.preventDefault) e.preventDefault(); return false; }; if (this.isDirectCanvas) window["c2runtime"] = this; if (this.isNWjs) { window["ondragover"] = function(e) { e.preventDefault(); return false; }; window["ondrop"] = function(e) { e.preventDefault(); return false; }; if (window["nwgui"] && window["nwgui"]["App"]["clearCache"]) window["nwgui"]["App"]["clearCache"](); } if (this.isAndroidStockBrowser && typeof jQuery !== "undefined") { jQuery("canvas").parents("*").css("overflow", "visible"); } this.width = canvas.width; this.height = canvas.height; this.draw_width = this.width; this.draw_height = this.height; this.cssWidth = this.width; this.cssHeight = this.height; this.lastWindowWidth = window.innerWidth; this.lastWindowHeight = window.innerHeight; this.forceCanvasAlpha = false; // note: now unused, left for backwards compat since plugins could modify it this.redraw = true; this.isSuspended = false; if (!Date.now) { Date.now = function now() { return +new Date(); }; } this.plugins = []; this.types = {}; this.types_by_index = []; this.behaviors = []; this.layouts = {}; this.layouts_by_index = []; this.eventsheets = {}; this.eventsheets_by_index = []; this.wait_for_textures = []; // for blocking until textures loaded this.triggers_to_postinit = []; this.all_global_vars = []; this.all_local_vars = []; this.solidBehavior = null; this.jumpthruBehavior = null; this.shadowcasterBehavior = null; this.deathRow = {}; this.hasPendingInstances = false; // true if anything exists in create row or death row this.isInClearDeathRow = false; this.isInOnDestroy = 0; // needs to support recursion so increments and decrements and is true if > 0 this.isRunningEvents = false; this.isEndingLayout = false; this.createRow = []; this.isLoadingState = false; this.saveToSlot = ""; this.loadFromSlot = ""; this.loadFromJson = null; // set to string when there is something to try to load this.lastSaveJson = ""; this.signalledContinuousPreview = false; this.suspendDrawing = false; // for hiding display until continuous preview loads this.fireOnCreateAfterLoad = []; // for delaying "On create" triggers until loading complete this.dt = 0; this.dt1 = 0; this.minimumFramerate = 30; this.logictime = 0; // used to calculate CPUUtilisation this.cpuutilisation = 0; this.timescale = 1.0; this.kahanTime = new cr.KahanAdder(); this.wallTime = new cr.KahanAdder(); this.last_tick_time = 0; this.fps = 0; this.last_fps_time = 0; this.tickcount = 0; this.tickcount_nosave = 0; // same as tickcount but never saved/loaded this.execcount = 0; this.framecount = 0; // for fps this.objectcount = 0; this.changelayout = null; this.destroycallbacks = []; this.event_stack = []; this.event_stack_index = -1; this.localvar_stack = [[]]; this.localvar_stack_index = 0; this.trigger_depth = 0; // recursion depth for triggers this.pushEventStack(null); this.loop_stack = []; this.loop_stack_index = -1; this.next_uid = 0; this.next_puid = 0; // permanent unique ids this.layout_first_tick = true; this.family_count = 0; this.suspend_events = []; this.raf_id = -1; this.timeout_id = -1; this.isloading = true; this.loadingprogress = 0; this.isNodeFullscreen = false; this.stackLocalCount = 0; // number of stack-based local vars for recursion this.audioInstance = null; this.had_a_click = false; this.isInUserInputEvent = false; this.objects_to_pretick = new cr.ObjectSet(); this.objects_to_tick = new cr.ObjectSet(); this.objects_to_tick2 = new cr.ObjectSet(); this.registered_collisions = []; this.temp_poly = new cr.CollisionPoly([]); this.temp_poly2 = new cr.CollisionPoly([]); this.allGroups = []; // array of all event groups this.groups_by_name = {}; this.cndsBySid = {}; this.actsBySid = {}; this.varsBySid = {}; this.blocksBySid = {}; this.running_layout = null; // currently running layout this.layer_canvas = null; // for layers "render-to-texture" this.layer_ctx = null; this.layer_tex = null; this.layout_tex = null; this.layout_canvas = null; this.layout_ctx = null; this.is_WebGL_context_lost = false; this.uses_background_blending = false; // if any shader uses background blending, so entire layout renders to texture this.fx_tex = [null, null]; this.fullscreen_scaling = 0; this.files_subfolder = ""; // path with project files this.objectsByUid = {}; // maps every in-use UID (as a string) to its instance this.loaderlogos = null; this.snapshotCanvas = null; this.snapshotData = ""; this.objectRefTable = []; this.requestProjectData(); }; Runtime.prototype.requestProjectData = function () { var self = this; if (this.isWKWebView) { this.fetchLocalFileViaCordovaAsText("data.json", function (str) { self.loadProject(JSON.parse(str)); }, function (err) { alert("Error fetching data.json"); }); return; } var xhr; if (this.isWindowsPhone8) xhr = new ActiveXObject("Microsoft.XMLHTTP"); else xhr = new XMLHttpRequest(); var datajs_filename = "data.json"; if (this.isWindows8App || this.isWindowsPhone8 || this.isWindowsPhone81 || this.isWindows10) datajs_filename = "data.json"; xhr.open("GET", datajs_filename, true); var supportsJsonResponse = false; if (!this.isDomFree && ("response" in xhr) && ("responseType" in xhr)) { try { xhr["responseType"] = "json"; supportsJsonResponse = (xhr["responseType"] === "json"); } catch (e) { supportsJsonResponse = false; } } if (!supportsJsonResponse && ("responseType" in xhr)) { try { xhr["responseType"] = "text"; } catch (e) {} } if ("overrideMimeType" in xhr) { try { xhr["overrideMimeType"]("application/json; charset=utf-8"); } catch (e) {} } if (this.isWindowsPhone8) { xhr.onreadystatechange = function () { if (xhr.readyState !== 4) return; self.loadProject(JSON.parse(xhr["responseText"])); }; } else { xhr.onload = function () { if (supportsJsonResponse) { self.loadProject(xhr["response"]); // already parsed by browser } else { if (self.isEjecta) { var str = xhr["responseText"]; str = str.substr(str.indexOf("{")); // trim any BOM self.loadProject(JSON.parse(str)); } else { self.loadProject(JSON.parse(xhr["responseText"])); // forced to sync parse JSON } } }; xhr.onerror = function (e) { cr.logerror("Error requesting " + datajs_filename + ":"); cr.logerror(e); }; } xhr.send(); }; Runtime.prototype.initRendererAndLoader = function () { var self = this; var i, len, j, lenj, k, lenk, t, s, l, y; this.isRetina = ((!this.isDomFree || this.isEjecta || this.isCordova) && this.useHighDpi && !this.isAndroidStockBrowser); if (this.fullscreen_mode === 0 && this.isiOS) this.isRetina = false; this.devicePixelRatio = (this.isRetina ? (window["devicePixelRatio"] || window["webkitDevicePixelRatio"] || window["mozDevicePixelRatio"] || window["msDevicePixelRatio"] || 1) : 1); this.ClearDeathRow(); var attribs; if (this.fullscreen_mode > 0) this["setSize"](window.innerWidth, window.innerHeight, true); this.canvas.addEventListener("webglcontextlost", function (ev) { ev.preventDefault(); self.onContextLost(); cr.logexport("[Construct 2] WebGL context lost"); window["cr_setSuspended"](true); // stop rendering }, false); this.canvas.addEventListener("webglcontextrestored", function (ev) { self.glwrap.initState(); self.glwrap.setSize(self.glwrap.width, self.glwrap.height, true); self.layer_tex = null; self.layout_tex = null; self.fx_tex[0] = null; self.fx_tex[1] = null; self.onContextRestored(); self.redraw = true; cr.logexport("[Construct 2] WebGL context restored"); window["cr_setSuspended"](false); // resume rendering }, false); try { if (this.enableWebGL && (this.isCocoonJs || this.isEjecta || !this.isDomFree)) { attribs = { "alpha": true, "depth": false, "antialias": false, "powerPreference": "high-performance", "failIfMajorPerformanceCaveat": true }; this.gl = (this.canvas.getContext("webgl2", attribs) || this.canvas.getContext("webgl", attribs) || this.canvas.getContext("experimental-webgl", attribs)); } } catch (e) { } if (this.gl) { var isWebGL2 = (this.gl.getParameter(this.gl.VERSION).indexOf("WebGL 2") === 0); var debug_ext = this.gl.getExtension("WEBGL_debug_renderer_info"); if (debug_ext) { var unmasked_vendor = this.gl.getParameter(debug_ext.UNMASKED_VENDOR_WEBGL); var unmasked_renderer = this.gl.getParameter(debug_ext.UNMASKED_RENDERER_WEBGL); this.glUnmaskedRenderer = unmasked_renderer + " [" + unmasked_vendor + "]"; } if (this.enableFrontToBack) this.glUnmaskedRenderer += " [front-to-back enabled]"; ; if (!this.isDomFree) { this.overlay_canvas = document.createElement("canvas"); jQuery(this.overlay_canvas).appendTo(this.canvas.parentNode); this.overlay_canvas.oncontextmenu = function (e) { return false; }; this.overlay_canvas.onselectstart = function (e) { return false; }; this.overlay_canvas.width = Math.round(this.cssWidth * this.devicePixelRatio); this.overlay_canvas.height = Math.round(this.cssHeight * this.devicePixelRatio); jQuery(this.overlay_canvas).css({"width": this.cssWidth + "px", "height": this.cssHeight + "px"}); this.positionOverlayCanvas(); this.overlay_ctx = this.overlay_canvas.getContext("2d"); } this.glwrap = new cr.GLWrap(this.gl, this.isMobile, this.enableFrontToBack); this.glwrap.setSize(this.canvas.width, this.canvas.height); this.glwrap.enable_mipmaps = (this.downscalingQuality !== 0); this.ctx = null; for (i = 0, len = this.types_by_index.length; i < len; i++) { t = this.types_by_index[i]; for (j = 0, lenj = t.effect_types.length; j < lenj; j++) { s = t.effect_types[j]; s.shaderindex = this.glwrap.getShaderIndex(s.id); s.preservesOpaqueness = this.glwrap.programPreservesOpaqueness(s.shaderindex); this.uses_background_blending = this.uses_background_blending || this.glwrap.programUsesDest(s.shaderindex); } } for (i = 0, len = this.layouts_by_index.length; i < len; i++) { l = this.layouts_by_index[i]; for (j = 0, lenj = l.effect_types.length; j < lenj; j++) { s = l.effect_types[j]; s.shaderindex = this.glwrap.getShaderIndex(s.id); s.preservesOpaqueness = this.glwrap.programPreservesOpaqueness(s.shaderindex); } l.updateActiveEffects(); // update preserves opaqueness flag for (j = 0, lenj = l.layers.length; j < lenj; j++) { y = l.layers[j]; for (k = 0, lenk = y.effect_types.length; k < lenk; k++) { s = y.effect_types[k]; s.shaderindex = this.glwrap.getShaderIndex(s.id); s.preservesOpaqueness = this.glwrap.programPreservesOpaqueness(s.shaderindex); this.uses_background_blending = this.uses_background_blending || this.glwrap.programUsesDest(s.shaderindex); } y.updateActiveEffects(); // update preserves opaqueness flag } } } else { if (this.fullscreen_mode > 0 && this.isDirectCanvas) { ; this.canvas = null; document.oncontextmenu = function (e) { return false; }; document.onselectstart = function (e) { return false; }; this.ctx = AppMobi["canvas"]["getContext"]("2d"); try { this.ctx["samplingMode"] = this.linearSampling ? "smooth" : "sharp"; this.ctx["globalScale"] = 1; this.ctx["HTML5CompatibilityMode"] = true; this.ctx["imageSmoothingEnabled"] = this.linearSampling; } catch(e){} if (this.width !== 0 && this.height !== 0) { this.ctx.width = this.width; this.ctx.height = this.height; } } if (!this.ctx) { ; if (this.isCocoonJs) { attribs = { "antialias": !!this.linearSampling, "alpha": true }; this.ctx = this.canvas.getContext("2d", attribs); } else { attribs = { "alpha": true }; this.ctx = this.canvas.getContext("2d", attribs); } this.setCtxImageSmoothingEnabled(this.ctx, this.linearSampling); } this.overlay_canvas = null; this.overlay_ctx = null; } this.tickFunc = function (timestamp) { self.tick(false, timestamp); }; if (window != window.top && !this.isDomFree && !this.isWinJS && !this.isWindowsPhone8) { document.addEventListener("mousedown", function () { window.focus(); }, true); document.addEventListener("touchstart", function () { window.focus(); }, true); } if (typeof cr_is_preview !== "undefined") { if (this.isCocoonJs) console.log("[Construct 2] In preview-over-wifi via CocoonJS mode"); if (window.location.search.indexOf("continuous") > -1) { cr.logexport("Reloading for continuous preview"); this.loadFromSlot = "__c2_continuouspreview"; this.suspendDrawing = true; } if (this.pauseOnBlur && !this.isMobile) { jQuery(window).focus(function () { self["setSuspended"](false); }); jQuery(window).blur(function () { var parent = window.parent; if (!parent || !parent.document.hasFocus()) self["setSuspended"](true); }); } } window.addEventListener("blur", function () { self.onWindowBlur(); }); if (!this.isDomFree) { var unfocusFormControlFunc = function (e) { if (cr.isCanvasInputEvent(e) && document["activeElement"] && document["activeElement"] !== document.getElementsByTagName("body")[0] && document["activeElement"].blur) { try { document["activeElement"].blur(); } catch (e) {} } } if (typeof PointerEvent !== "undefined") { document.addEventListener("pointerdown", unfocusFormControlFunc); } else if (window.navigator["msPointerEnabled"]) { document.addEventListener("MSPointerDown", unfocusFormControlFunc); } else { document.addEventListener("touchstart", unfocusFormControlFunc); } document.addEventListener("mousedown", unfocusFormControlFunc); } if (this.fullscreen_mode === 0 && this.isRetina && this.devicePixelRatio > 1) { this["setSize"](this.original_width, this.original_height, true); } this.tryLockOrientation(); this.getready(); // determine things to preload this.go(); // run loading screen this.extra = {}; cr.seal(this); }; var webkitRepaintFlag = false; Runtime.prototype["setSize"] = function (w, h, force) { var offx = 0, offy = 0; var neww = 0, newh = 0, intscale = 0; if (this.lastWindowWidth === w && this.lastWindowHeight === h && !force) return; this.lastWindowWidth = w; this.lastWindowHeight = h; var mode = this.fullscreen_mode; var orig_aspect, cur_aspect; var isfullscreen = (document["mozFullScreen"] || document["webkitIsFullScreen"] || !!document["msFullscreenElement"] || document["fullScreen"] || this.isNodeFullscreen) && !this.isCordova; if (!isfullscreen && this.fullscreen_mode === 0 && !force) return; // ignore size events when not fullscreen and not using a fullscreen-in-browser mode if (isfullscreen && this.fullscreen_scaling > 0) mode = this.fullscreen_scaling; var dpr = this.devicePixelRatio; if (mode >= 4) { orig_aspect = this.original_width / this.original_height; cur_aspect = w / h; if (cur_aspect > orig_aspect) { neww = h * orig_aspect; if (mode === 5) // integer scaling { intscale = (neww * dpr) / this.original_width; if (intscale > 1) intscale = Math.floor(intscale); else if (intscale < 1) intscale = 1 / Math.ceil(1 / intscale); neww = this.original_width * intscale / dpr; newh = this.original_height * intscale / dpr; offx = (w - neww) / 2; offy = (h - newh) / 2; w = neww; h = newh; } else { offx = (w - neww) / 2; w = neww; } } else { newh = w / orig_aspect; if (mode === 5) // integer scaling { intscale = (newh * dpr) / this.original_height; if (intscale > 1) intscale = Math.floor(intscale); else if (intscale < 1) intscale = 1 / Math.ceil(1 / intscale); neww = this.original_width * intscale / dpr; newh = this.original_height * intscale / dpr; offx = (w - neww) / 2; offy = (h - newh) / 2; w = neww; h = newh; } else { offy = (h - newh) / 2; h = newh; } } } else if (this.isNWjs && this.isNodeFullscreen && this.fullscreen_mode_set === 0) { offx = Math.floor((w - this.original_width) / 2); offy = Math.floor((h - this.original_height) / 2); w = this.original_width; h = this.original_height; } if (mode < 2) this.aspect_scale = dpr; this.cssWidth = Math.round(w); this.cssHeight = Math.round(h); this.width = Math.round(w * dpr); this.height = Math.round(h * dpr); this.redraw = true; if (this.wantFullscreenScalingQuality) { this.draw_width = this.width; this.draw_height = this.height; this.fullscreenScalingQuality = true; } else { if ((this.width < this.original_width && this.height < this.original_height) || mode === 1) { this.draw_width = this.width; this.draw_height = this.height; this.fullscreenScalingQuality = true; } else { this.draw_width = this.original_width; this.draw_height = this.original_height; this.fullscreenScalingQuality = false; /*var orig_aspect = this.original_width / this.original_height; var cur_aspect = this.width / this.height; if ((this.fullscreen_mode !== 2 && cur_aspect > orig_aspect) || (this.fullscreen_mode === 2 && cur_aspect < orig_aspect)) this.aspect_scale = this.height / this.original_height; else this.aspect_scale = this.width / this.original_width;*/ if (mode === 2) // scale inner { orig_aspect = this.original_width / this.original_height; cur_aspect = this.lastWindowWidth / this.lastWindowHeight; if (cur_aspect < orig_aspect) this.draw_width = this.draw_height * cur_aspect; else if (cur_aspect > orig_aspect) this.draw_height = this.draw_width / cur_aspect; } else if (mode === 3) { orig_aspect = this.original_width / this.original_height; cur_aspect = this.lastWindowWidth / this.lastWindowHeight; if (cur_aspect > orig_aspect) this.draw_width = this.draw_height * cur_aspect; else if (cur_aspect < orig_aspect) this.draw_height = this.draw_width / cur_aspect; } } } if (this.canvasdiv && !this.isDomFree) { jQuery(this.canvasdiv).css({"width": Math.round(w) + "px", "height": Math.round(h) + "px", "margin-left": Math.floor(offx) + "px", "margin-top": Math.floor(offy) + "px"}); if (typeof cr_is_preview !== "undefined") { jQuery("#borderwrap").css({"width": Math.round(w) + "px", "height": Math.round(h) + "px"}); } } if (this.canvas) { this.canvas.width = Math.round(w * dpr); this.canvas.height = Math.round(h * dpr); if (this.isEjecta) { this.canvas.style.left = Math.floor(offx) + "px"; this.canvas.style.top = Math.floor(offy) + "px"; this.canvas.style.width = Math.round(w) + "px"; this.canvas.style.height = Math.round(h) + "px"; } else if (this.isRetina && !this.isDomFree) { this.canvas.style.width = Math.round(w) + "px"; this.canvas.style.height = Math.round(h) + "px"; } } if (this.overlay_canvas) { this.overlay_canvas.width = Math.round(w * dpr); this.overlay_canvas.height = Math.round(h * dpr); this.overlay_canvas.style.width = this.cssWidth + "px"; this.overlay_canvas.style.height = this.cssHeight + "px"; } if (this.glwrap) { this.glwrap.setSize(Math.round(w * dpr), Math.round(h * dpr)); } if (this.isDirectCanvas && this.ctx) { this.ctx.width = Math.round(w); this.ctx.height = Math.round(h); } if (this.ctx) { this.setCtxImageSmoothingEnabled(this.ctx, this.linearSampling); } this.tryLockOrientation(); if (this.isiPhone && !this.isCordova) { window.scrollTo(0, 0); } }; Runtime.prototype.tryLockOrientation = function () { if (!this.autoLockOrientation || this.orientations === 0) return; var orientation = "portrait"; if (this.orientations === 2) orientation = "landscape"; try { if (screen["orientation"] && screen["orientation"]["lock"]) screen["orientation"]["lock"](orientation).catch(function(){}); else if (screen["lockOrientation"]) screen["lockOrientation"](orientation); else if (screen["webkitLockOrientation"]) screen["webkitLockOrientation"](orientation); else if (screen["mozLockOrientation"]) screen["mozLockOrientation"](orientation); else if (screen["msLockOrientation"]) screen["msLockOrientation"](orientation); } catch (e) { if (console && console.warn) console.warn("Failed to lock orientation: ", e); } }; Runtime.prototype.onContextLost = function () { this.glwrap.contextLost(); this.is_WebGL_context_lost = true; var i, len, t; for (i = 0, len = this.types_by_index.length; i < len; i++) { t = this.types_by_index[i]; if (t.onLostWebGLContext) t.onLostWebGLContext(); } }; Runtime.prototype.onContextRestored = function () { this.is_WebGL_context_lost = false; var i, len, t; for (i = 0, len = this.types_by_index.length; i < len; i++) { t = this.types_by_index[i]; if (t.onRestoreWebGLContext) t.onRestoreWebGLContext(); } }; Runtime.prototype.positionOverlayCanvas = function() { if (this.isDomFree) return; var isfullscreen = (document["mozFullScreen"] || document["webkitIsFullScreen"] || document["fullScreen"] || !!document["msFullscreenElement"] || this.isNodeFullscreen) && !this.isCordova; var overlay_position = isfullscreen ? jQuery(this.canvas).offset() : jQuery(this.canvas).position(); overlay_position.position = "absolute"; jQuery(this.overlay_canvas).css(overlay_position); }; var caf = window["cancelAnimationFrame"] || window["mozCancelAnimationFrame"] || window["webkitCancelAnimationFrame"] || window["msCancelAnimationFrame"] || window["oCancelAnimationFrame"]; Runtime.prototype["setSuspended"] = function (s) { var i, len; var self = this; if (s && !this.isSuspended) { cr.logexport("[Construct 2] Suspending"); this.isSuspended = true; // next tick will be last if (this.raf_id !== -1 && caf) // note: CocoonJS does not implement cancelAnimationFrame caf(this.raf_id); if (this.timeout_id !== -1) clearTimeout(this.timeout_id); for (i = 0, len = this.suspend_events.length; i < len; i++) this.suspend_events[i](true); } else if (!s && this.isSuspended) { cr.logexport("[Construct 2] Resuming"); this.isSuspended = false; this.last_tick_time = cr.performance_now(); // ensure first tick is a zero-dt one this.last_fps_time = cr.performance_now(); // reset FPS counter this.framecount = 0; this.logictime = 0; for (i = 0, len = this.suspend_events.length; i < len; i++) this.suspend_events[i](false); this.tick(false); // kick off runtime again } }; Runtime.prototype.addSuspendCallback = function (f) { this.suspend_events.push(f); }; Runtime.prototype.GetObjectReference = function (i) { ; return this.objectRefTable[i]; }; Runtime.prototype.loadProject = function (data_response) { ; if (!data_response || !data_response["project"]) cr.logerror("Project model unavailable"); var pm = data_response["project"]; this.name = pm[0]; this.first_layout = pm[1]; this.fullscreen_mode = pm[12]; // 0 = off, 1 = crop, 2 = scale inner, 3 = scale outer, 4 = letterbox scale, 5 = integer letterbox scale this.fullscreen_mode_set = pm[12]; this.original_width = pm[10]; this.original_height = pm[11]; this.parallax_x_origin = this.original_width / 2; this.parallax_y_origin = this.original_height / 2; if (this.isDomFree && !this.isEjecta && (pm[12] >= 4 || pm[12] === 0)) { cr.logexport("[Construct 2] Letterbox scale fullscreen modes are not supported on this platform - falling back to 'Scale outer'"); this.fullscreen_mode = 3; this.fullscreen_mode_set = 3; } this.uses_loader_layout = pm[18]; this.loaderstyle = pm[19]; if (this.loaderstyle === 0) { var loaderImage = new Image(); loaderImage.crossOrigin = "anonymous"; this.setImageSrc(loaderImage, "loading-logo.png"); this.loaderlogos = { logo: loaderImage }; } else if (this.loaderstyle === 4) // c2 splash { var loaderC2logo_1024 = new Image(); loaderC2logo_1024.src = ""; var loaderC2logo_512 = new Image(); loaderC2logo_512.src = ""; var loaderC2logo_256 = new Image(); loaderC2logo_256.src = ""; var loaderC2logo_128 = new Image(); loaderC2logo_128.src = ""; var loaderPowered_1024 = new Image(); loaderPowered_1024.src = ""; var loaderPowered_512 = new Image(); loaderPowered_512.src = ""; var loaderPowered_256 = new Image(); loaderPowered_256.src = ""; var loaderPowered_128 = new Image(); loaderPowered_128.src = ""; var loaderWebsite_1024 = new Image(); loaderWebsite_1024.src = ""; var loaderWebsite_512 = new Image(); loaderWebsite_512.src = ""; var loaderWebsite_256 = new Image(); loaderWebsite_256.src = ""; var loaderWebsite_128 = new Image(); loaderWebsite_128.src = ""; this.loaderlogos = { logo: [loaderC2logo_1024, loaderC2logo_512, loaderC2logo_256, loaderC2logo_128], powered: [loaderPowered_1024, loaderPowered_512, loaderPowered_256, loaderPowered_128], website: [loaderWebsite_1024, loaderWebsite_512, loaderWebsite_256, loaderWebsite_128] }; } this.next_uid = pm[21]; this.objectRefTable = cr.getObjectRefTable(); this.system = new cr.system_object(this); var i, len, j, lenj, k, lenk, idstr, m, b, t, f, p; var plugin, plugin_ctor; for (i = 0, len = pm[2].length; i < len; i++) { m = pm[2][i]; p = this.GetObjectReference(m[0]); ; cr.add_common_aces(m, p.prototype); plugin = new p(this); plugin.singleglobal = m[1]; plugin.is_world = m[2]; plugin.is_rotatable = m[5]; plugin.must_predraw = m[9]; if (plugin.onCreate) plugin.onCreate(); // opportunity to override default ACEs cr.seal(plugin); this.plugins.push(plugin); } this.objectRefTable = cr.getObjectRefTable(); for (i = 0, len = pm[3].length; i < len; i++) { m = pm[3][i]; plugin_ctor = this.GetObjectReference(m[1]); ; plugin = null; for (j = 0, lenj = this.plugins.length; j < lenj; j++) { if (this.plugins[j] instanceof plugin_ctor) { plugin = this.plugins[j]; break; } } ; ; var type_inst = new plugin.Type(plugin); ; type_inst.name = m[0]; type_inst.is_family = m[2]; type_inst.instvar_sids = m[3].slice(0); type_inst.vars_count = m[3].length; type_inst.behs_count = m[4]; type_inst.fx_count = m[5]; type_inst.sid = m[11]; if (type_inst.is_family) { type_inst.members = []; // types in this family type_inst.family_index = this.family_count++; type_inst.families = null; } else { type_inst.members = null; type_inst.family_index = -1; type_inst.families = []; // families this type belongs to } type_inst.family_var_map = null; type_inst.family_beh_map = null; type_inst.family_fx_map = null; type_inst.is_contained = false; type_inst.container = null; if (m[6]) { type_inst.texture_file = m[6][0]; type_inst.texture_filesize = m[6][1]; type_inst.texture_pixelformat = m[6][2]; } else { type_inst.texture_file = null; type_inst.texture_filesize = 0; type_inst.texture_pixelformat = 0; // rgba8 } if (m[7]) { type_inst.animations = m[7]; } else { type_inst.animations = null; } type_inst.index = i; // save index in to types array in type type_inst.instances = []; // all instances of this type type_inst.deadCache = []; // destroyed instances to recycle next create type_inst.solstack = [new cr.selection(type_inst)]; // initialise SOL stack with one empty SOL type_inst.cur_sol = 0; type_inst.default_instance = null; type_inst.default_layerindex = 0; type_inst.stale_iids = true; type_inst.updateIIDs = cr.type_updateIIDs; type_inst.getFirstPicked = cr.type_getFirstPicked; type_inst.getPairedInstance = cr.type_getPairedInstance; type_inst.getCurrentSol = cr.type_getCurrentSol; type_inst.pushCleanSol = cr.type_pushCleanSol; type_inst.pushCopySol = cr.type_pushCopySol; type_inst.popSol = cr.type_popSol; type_inst.getBehaviorByName = cr.type_getBehaviorByName; type_inst.getBehaviorIndexByName = cr.type_getBehaviorIndexByName; type_inst.getEffectIndexByName = cr.type_getEffectIndexByName; type_inst.applySolToContainer = cr.type_applySolToContainer; type_inst.getInstanceByIID = cr.type_getInstanceByIID; type_inst.collision_grid = new cr.SparseGrid(this.original_width, this.original_height); type_inst.any_cell_changed = true; type_inst.any_instance_parallaxed = false; type_inst.extra = {}; type_inst.toString = cr.type_toString; type_inst.behaviors = []; for (j = 0, lenj = m[8].length; j < lenj; j++) { b = m[8][j]; var behavior_ctor = this.GetObjectReference(b[1]); var behavior_plugin = null; for (k = 0, lenk = this.behaviors.length; k < lenk; k++) { if (this.behaviors[k] instanceof behavior_ctor) { behavior_plugin = this.behaviors[k]; break; } } if (!behavior_plugin) { behavior_plugin = new behavior_ctor(this); behavior_plugin.my_types = []; // types using this behavior behavior_plugin.my_instances = new cr.ObjectSet(); // instances of this behavior if (behavior_plugin.onCreate) behavior_plugin.onCreate(); cr.seal(behavior_plugin); this.behaviors.push(behavior_plugin); if (cr.behaviors.solid && behavior_plugin instanceof cr.behaviors.solid) this.solidBehavior = behavior_plugin; if (cr.behaviors.jumpthru && behavior_plugin instanceof cr.behaviors.jumpthru) this.jumpthruBehavior = behavior_plugin; if (cr.behaviors.shadowcaster && behavior_plugin instanceof cr.behaviors.shadowcaster) this.shadowcasterBehavior = behavior_plugin; } if (behavior_plugin.my_types.indexOf(type_inst) === -1) behavior_plugin.my_types.push(type_inst); var behavior_type = new behavior_plugin.Type(behavior_plugin, type_inst); behavior_type.name = b[0]; behavior_type.sid = b[2]; behavior_type.onCreate(); cr.seal(behavior_type); type_inst.behaviors.push(behavior_type); } type_inst.global = m[9]; type_inst.isOnLoaderLayout = m[10]; type_inst.effect_types = []; for (j = 0, lenj = m[12].length; j < lenj; j++) { type_inst.effect_types.push({ id: m[12][j][0], name: m[12][j][1], shaderindex: -1, preservesOpaqueness: false, active: true, index: j }); } type_inst.tile_poly_data = m[13]; if (!this.uses_loader_layout || type_inst.is_family || type_inst.isOnLoaderLayout || !plugin.is_world) { type_inst.onCreate(); cr.seal(type_inst); } if (type_inst.name) this.types[type_inst.name] = type_inst; this.types_by_index.push(type_inst); if (plugin.singleglobal) { var instance = new plugin.Instance(type_inst); instance.uid = this.next_uid++; instance.puid = this.next_puid++; instance.iid = 0; instance.get_iid = cr.inst_get_iid; instance.toString = cr.inst_toString; instance.properties = m[14]; instance.onCreate(); cr.seal(instance); type_inst.instances.push(instance); this.objectsByUid[instance.uid.toString()] = instance; } } for (i = 0, len = pm[4].length; i < len; i++) { var familydata = pm[4][i]; var familytype = this.types_by_index[familydata[0]]; var familymember; for (j = 1, lenj = familydata.length; j < lenj; j++) { familymember = this.types_by_index[familydata[j]]; familymember.families.push(familytype); familytype.members.push(familymember); } } for (i = 0, len = pm[28].length; i < len; i++) { var containerdata = pm[28][i]; var containertypes = []; for (j = 0, lenj = containerdata.length; j < lenj; j++) containertypes.push(this.types_by_index[containerdata[j]]); for (j = 0, lenj = containertypes.length; j < lenj; j++) { containertypes[j].is_contained = true; containertypes[j].container = containertypes; } } if (this.family_count > 0) { for (i = 0, len = this.types_by_index.length; i < len; i++) { t = this.types_by_index[i]; if (t.is_family || !t.families.length) continue; t.family_var_map = new Array(this.family_count); t.family_beh_map = new Array(this.family_count); t.family_fx_map = new Array(this.family_count); var all_fx = []; var varsum = 0; var behsum = 0; var fxsum = 0; for (j = 0, lenj = t.families.length; j < lenj; j++) { f = t.families[j]; t.family_var_map[f.family_index] = varsum; varsum += f.vars_count; t.family_beh_map[f.family_index] = behsum; behsum += f.behs_count; t.family_fx_map[f.family_index] = fxsum; fxsum += f.fx_count; for (k = 0, lenk = f.effect_types.length; k < lenk; k++) all_fx.push(cr.shallowCopy({}, f.effect_types[k])); } t.effect_types = all_fx.concat(t.effect_types); for (j = 0, lenj = t.effect_types.length; j < lenj; j++) t.effect_types[j].index = j; } } for (i = 0, len = pm[5].length; i < len; i++) { m = pm[5][i]; var layout = new cr.layout(this, m); cr.seal(layout); this.layouts[layout.name] = layout; this.layouts_by_index.push(layout); } for (i = 0, len = pm[6].length; i < len; i++) { m = pm[6][i]; var sheet = new cr.eventsheet(this, m); cr.seal(sheet); this.eventsheets[sheet.name] = sheet; this.eventsheets_by_index.push(sheet); } for (i = 0, len = this.eventsheets_by_index.length; i < len; i++) this.eventsheets_by_index[i].postInit(); for (i = 0, len = this.eventsheets_by_index.length; i < len; i++) this.eventsheets_by_index[i].updateDeepIncludes(); for (i = 0, len = this.triggers_to_postinit.length; i < len; i++) this.triggers_to_postinit[i].postInit(); cr.clearArray(this.triggers_to_postinit) this.audio_to_preload = pm[7]; this.files_subfolder = pm[8]; this.pixel_rounding = pm[9]; this.aspect_scale = 1.0; this.enableWebGL = pm[13]; this.linearSampling = pm[14]; this.clearBackground = pm[15]; this.versionstr = pm[16]; this.useHighDpi = pm[17]; this.orientations = pm[20]; // 0 = any, 1 = portrait, 2 = landscape this.autoLockOrientation = (this.orientations > 0); this.pauseOnBlur = pm[22]; this.wantFullscreenScalingQuality = pm[23]; // false = low quality, true = high quality this.fullscreenScalingQuality = this.wantFullscreenScalingQuality; this.downscalingQuality = pm[24]; // 0 = low (mips off), 1 = medium (mips on, dense spritesheet), 2 = high (mips on, sparse spritesheet) this.preloadSounds = pm[25]; // 0 = no, 1 = yes this.projectName = pm[26]; this.enableFrontToBack = pm[27] && !this.isIE; // front-to-back renderer disabled in IE (but not Edge) this.start_time = Date.now(); cr.clearArray(this.objectRefTable); this.initRendererAndLoader(); }; var anyImageHadError = false; var MAX_PARALLEL_IMAGE_LOADS = 100; var currentlyActiveImageLoads = 0; var imageLoadQueue = []; // array of [img, srcToSet] Runtime.prototype.queueImageLoad = function (img_, src_) { var self = this; var doneFunc = function () { currentlyActiveImageLoads--; self.maybeLoadNextImages(); }; img_.addEventListener("load", doneFunc); img_.addEventListener("error", doneFunc); imageLoadQueue.push([img_, src_]); this.maybeLoadNextImages(); }; Runtime.prototype.maybeLoadNextImages = function () { var next; while (imageLoadQueue.length && currentlyActiveImageLoads < MAX_PARALLEL_IMAGE_LOADS) { currentlyActiveImageLoads++; next = imageLoadQueue.shift(); this.setImageSrc(next[0], next[1]); } }; Runtime.prototype.waitForImageLoad = function (img_, src_) { img_["cocoonLazyLoad"] = true; img_.onerror = function (e) { img_.c2error = true; anyImageHadError = true; if (console && console.error) console.error("Error loading image '" + img_.src + "': ", e); }; if (this.isEjecta) { img_.src = src_; } else if (!img_.src) { if (typeof XAPKReader !== "undefined") { XAPKReader.get(src_, function (expanded_url) { img_.src = expanded_url; }, function (e) { img_.c2error = true; anyImageHadError = true; if (console && console.error) console.error("Error extracting image '" + src_ + "' from expansion file: ", e); }); } else { img_.crossOrigin = "anonymous"; // required for Arcade sandbox compatibility this.queueImageLoad(img_, src_); // use a queue to avoid requesting all images simultaneously } } this.wait_for_textures.push(img_); }; Runtime.prototype.findWaitingTexture = function (src_) { var i, len; for (i = 0, len = this.wait_for_textures.length; i < len; i++) { if (this.wait_for_textures[i].cr_src === src_) return this.wait_for_textures[i]; } return null; }; var audio_preload_totalsize = 0; var audio_preload_started = false; Runtime.prototype.getready = function () { if (!this.audioInstance) return; audio_preload_totalsize = this.audioInstance.setPreloadList(this.audio_to_preload); }; Runtime.prototype.areAllTexturesAndSoundsLoaded = function () { var totalsize = audio_preload_totalsize; var completedsize = 0; var audiocompletedsize = 0; var ret = true; var i, len, img; for (i = 0, len = this.wait_for_textures.length; i < len; i++) { img = this.wait_for_textures[i]; var filesize = img.cr_filesize; if (!filesize || filesize <= 0) filesize = 50000; totalsize += filesize; if (!!img.src && (img.complete || img["loaded"]) && !img.c2error) completedsize += filesize; else ret = false; // not all textures loaded } if (ret && this.preloadSounds && this.audioInstance) { if (!audio_preload_started) { this.audioInstance.startPreloads(); audio_preload_started = true; } audiocompletedsize = this.audioInstance.getPreloadedSize(); completedsize += audiocompletedsize; if (audiocompletedsize < audio_preload_totalsize) ret = false; // not done yet } if (totalsize == 0) this.progress = 1; // indicate to C2 splash loader that it can finish now else this.progress = (completedsize / totalsize); return ret; }; var isC2SplashDone = false; Runtime.prototype.go = function () { if (!this.ctx && !this.glwrap) return; var ctx = this.ctx || this.overlay_ctx; if (this.overlay_canvas) this.positionOverlayCanvas(); var curwidth = window.innerWidth; var curheight = window.innerHeight; if (this.lastWindowWidth !== curwidth || this.lastWindowHeight !== curheight) { this["setSize"](curwidth, curheight); } this.progress = 0; this.last_progress = -1; var self = this; if (this.areAllTexturesAndSoundsLoaded() && (this.loaderstyle !== 4 || isC2SplashDone)) { this.go_loading_finished(); } else { var ms_elapsed = Date.now() - this.start_time; if (ctx) { var overlay_width = this.width; var overlay_height = this.height; var dpr = this.devicePixelRatio; if (this.loaderstyle < 3 && (this.isCocoonJs || (ms_elapsed >= 500 && this.last_progress != this.progress))) { ctx.clearRect(0, 0, overlay_width, overlay_height); var mx = overlay_width / 2; var my = overlay_height / 2; var haslogo = (this.loaderstyle === 0 && this.loaderlogos.logo.complete); var hlw = 40 * dpr; var hlh = 0; var logowidth = 80 * dpr; var logoheight; if (haslogo) { var loaderLogoImage = this.loaderlogos.logo; logowidth = loaderLogoImage.width * dpr; logoheight = loaderLogoImage.height * dpr; hlw = logowidth / 2; hlh = logoheight / 2; ctx.drawImage(loaderLogoImage, cr.floor(mx - hlw), cr.floor(my - hlh), logowidth, logoheight); } if (this.loaderstyle <= 1) { my += hlh + (haslogo ? 12 * dpr : 0); mx -= hlw; mx = cr.floor(mx) + 0.5; my = cr.floor(my) + 0.5; ctx.fillStyle = anyImageHadError ? "red" : "DodgerBlue"; ctx.fillRect(mx, my, Math.floor(logowidth * this.progress), 6 * dpr); ctx.strokeStyle = "black"; ctx.strokeRect(mx, my, logowidth, 6 * dpr); ctx.strokeStyle = "white"; ctx.strokeRect(mx - 1 * dpr, my - 1 * dpr, logowidth + 2 * dpr, 8 * dpr); } else if (this.loaderstyle === 2) { ctx.font = (this.isEjecta ? "12pt ArialMT" : "12pt Arial"); ctx.fillStyle = anyImageHadError ? "#f00" : "#999"; ctx.textBaseLine = "middle"; var percent_text = Math.round(this.progress * 100) + "%"; var text_dim = ctx.measureText ? ctx.measureText(percent_text) : null; var text_width = text_dim ? text_dim.width : 0; ctx.fillText(percent_text, mx - (text_width / 2), my); } this.last_progress = this.progress; } else if (this.loaderstyle === 4) { this.draw_c2_splash_loader(ctx); if (raf) raf(function() { self.go(); }); else setTimeout(function() { self.go(); }, 16); return; } } setTimeout(function() { self.go(); }, (this.isCocoonJs ? 10 : 100)); } }; var splashStartTime = -1; var splashFadeInDuration = 300; var splashFadeOutDuration = 300; var splashAfterFadeOutWait = (typeof cr_is_preview === "undefined" ? 200 : 0); var splashIsFadeIn = true; var splashIsFadeOut = false; var splashFadeInFinish = 0; var splashFadeOutStart = 0; var splashMinDisplayTime = (typeof cr_is_preview === "undefined" ? 3000 : 0); var renderViaCanvas = null; var renderViaCtx = null; var splashFrameNumber = 0; function maybeCreateRenderViaCanvas(w, h) { if (!renderViaCanvas || renderViaCanvas.width !== w || renderViaCanvas.height !== h) { renderViaCanvas = document.createElement("canvas"); renderViaCanvas.width = w; renderViaCanvas.height = h; renderViaCtx = renderViaCanvas.getContext("2d"); } }; function mipImage(arr, size) { if (size <= 128) return arr[3]; else if (size <= 256) return arr[2]; else if (size <= 512) return arr[1]; else return arr[0]; }; Runtime.prototype.draw_c2_splash_loader = function(ctx) { if (isC2SplashDone) return; var w = Math.ceil(this.width); var h = Math.ceil(this.height); var dpr = this.devicePixelRatio; var logoimages = this.loaderlogos.logo; var poweredimages = this.loaderlogos.powered; var websiteimages = this.loaderlogos.website; for (var i = 0; i < 4; ++i) { if (!logoimages[i].complete || !poweredimages[i].complete || !websiteimages[i].complete) return; } if (splashFrameNumber === 0) splashStartTime = Date.now(); var nowTime = Date.now(); var isRenderingVia = false; var renderToCtx = ctx; var drawW, drawH; if (splashIsFadeIn || splashIsFadeOut) { ctx.clearRect(0, 0, w, h); maybeCreateRenderViaCanvas(w, h); renderToCtx = renderViaCtx; isRenderingVia = true; if (splashIsFadeIn && splashFrameNumber === 1) splashStartTime = Date.now(); } else { ctx.globalAlpha = 1; } renderToCtx.fillStyle = "#333333"; renderToCtx.fillRect(0, 0, w, h); if (this.cssHeight > 256) { drawW = cr.clamp(h * 0.22, 105, w * 0.6); drawH = drawW * 0.25; renderToCtx.drawImage(mipImage(poweredimages, drawW), w * 0.5 - drawW/2, h * 0.2 - drawH/2, drawW, drawH); drawW = Math.min(h * 0.395, w * 0.95); drawH = drawW; renderToCtx.drawImage(mipImage(logoimages, drawW), w * 0.5 - drawW/2, h * 0.485 - drawH/2, drawW, drawH); drawW = cr.clamp(h * 0.22, 105, w * 0.6); drawH = drawW * 0.25; renderToCtx.drawImage(mipImage(websiteimages, drawW), w * 0.5 - drawW/2, h * 0.868 - drawH/2, drawW, drawH); renderToCtx.fillStyle = "#3C3C3C"; drawW = w; drawH = Math.max(h * 0.005, 2); renderToCtx.fillRect(0, h * 0.8 - drawH/2, drawW, drawH); renderToCtx.fillStyle = anyImageHadError ? "red" : "#E0FF65"; drawW = w * this.progress; renderToCtx.fillRect(w * 0.5 - drawW/2, h * 0.8 - drawH/2, drawW, drawH); } else { drawW = h * 0.55; drawH = drawW; renderToCtx.drawImage(mipImage(logoimages, drawW), w * 0.5 - drawW/2, h * 0.45 - drawH/2, drawW, drawH); renderToCtx.fillStyle = "#3C3C3C"; drawW = w; drawH = Math.max(h * 0.005, 2); renderToCtx.fillRect(0, h * 0.85 - drawH/2, drawW, drawH); renderToCtx.fillStyle = anyImageHadError ? "red" : "#E0FF65"; drawW = w * this.progress; renderToCtx.fillRect(w * 0.5 - drawW/2, h * 0.85 - drawH/2, drawW, drawH); } if (isRenderingVia) { if (splashIsFadeIn) { if (splashFrameNumber === 0) ctx.globalAlpha = 0; else ctx.globalAlpha = Math.min((nowTime - splashStartTime) / splashFadeInDuration, 1); } else if (splashIsFadeOut) { ctx.globalAlpha = Math.max(1 - (nowTime - splashFadeOutStart) / splashFadeOutDuration, 0); } ctx.drawImage(renderViaCanvas, 0, 0, w, h); } if (splashIsFadeIn && nowTime - splashStartTime >= splashFadeInDuration && splashFrameNumber >= 2) { splashIsFadeIn = false; splashFadeInFinish = nowTime; } if (!splashIsFadeIn && nowTime - splashFadeInFinish >= splashMinDisplayTime && !splashIsFadeOut && this.progress >= 1) { splashIsFadeOut = true; splashFadeOutStart = nowTime; } if ((splashIsFadeOut && nowTime - splashFadeOutStart >= splashFadeOutDuration + splashAfterFadeOutWait) || (typeof cr_is_preview !== "undefined" && this.progress >= 1 && Date.now() - splashStartTime < 500)) { isC2SplashDone = true; splashIsFadeIn = false; splashIsFadeOut = false; renderViaCanvas = null; renderViaCtx = null; this.loaderlogos = null; } ++splashFrameNumber; }; Runtime.prototype.go_loading_finished = function () { if (this.overlay_canvas) { this.canvas.parentNode.removeChild(this.overlay_canvas); this.overlay_ctx = null; this.overlay_canvas = null; } this.start_time = Date.now(); this.last_fps_time = cr.performance_now(); // for counting framerate var i, len, t; if (this.uses_loader_layout) { for (i = 0, len = this.types_by_index.length; i < len; i++) { t = this.types_by_index[i]; if (!t.is_family && !t.isOnLoaderLayout && t.plugin.is_world) { t.onCreate(); cr.seal(t); } } } else this.isloading = false; for (i = 0, len = this.layouts_by_index.length; i < len; i++) { this.layouts_by_index[i].createGlobalNonWorlds(); } if (this.fullscreen_mode >= 2) { var orig_aspect = this.original_width / this.original_height; var cur_aspect = this.width / this.height; if ((this.fullscreen_mode !== 2 && cur_aspect > orig_aspect) || (this.fullscreen_mode === 2 && cur_aspect < orig_aspect)) this.aspect_scale = this.height / this.original_height; else this.aspect_scale = this.width / this.original_width; } if (this.first_layout) this.layouts[this.first_layout].startRunning(); else this.layouts_by_index[0].startRunning(); ; if (!this.uses_loader_layout) { this.loadingprogress = 1; this.trigger(cr.system_object.prototype.cnds.OnLoadFinished, null); if (window["C2_RegisterSW"]) // note not all platforms use SW window["C2_RegisterSW"](); } if (navigator["splashscreen"] && navigator["splashscreen"]["hide"]) navigator["splashscreen"]["hide"](); for (i = 0, len = this.types_by_index.length; i < len; i++) { t = this.types_by_index[i]; if (t.onAppBegin) t.onAppBegin(); } if (document["hidden"] || document["webkitHidden"] || document["mozHidden"] || document["msHidden"]) { window["cr_setSuspended"](true); // stop rendering } else { this.tick(false); } if (this.isDirectCanvas) AppMobi["webview"]["execute"]("onGameReady();"); }; Runtime.prototype.tick = function (background_wake, timestamp, debug_step) { if (!this.running_layout) return; var nowtime = cr.performance_now(); var logic_start = nowtime; if (!debug_step && this.isSuspended && !background_wake) return; if (!background_wake) { if (raf) this.raf_id = raf(this.tickFunc); else { this.timeout_id = setTimeout(this.tickFunc, this.isMobile ? 1 : 16); } } var raf_time = timestamp || nowtime; var fsmode = this.fullscreen_mode; var isfullscreen = (document["mozFullScreen"] || document["webkitIsFullScreen"] || document["fullScreen"] || !!document["msFullscreenElement"]) && !this.isCordova; if ((isfullscreen || this.isNodeFullscreen) && this.fullscreen_scaling > 0) fsmode = this.fullscreen_scaling; if (fsmode > 0) // r222: experimentally enabling this workaround for all platforms { var curwidth = window.innerWidth; var curheight = window.innerHeight; if (this.lastWindowWidth !== curwidth || this.lastWindowHeight !== curheight) { this["setSize"](curwidth, curheight); } } if (!this.isDomFree) { if (isfullscreen) { if (!this.firstInFullscreen) this.firstInFullscreen = true; } else { if (this.firstInFullscreen) { this.firstInFullscreen = false; if (this.fullscreen_mode === 0) { this["setSize"](Math.round(this.oldWidth / this.devicePixelRatio), Math.round(this.oldHeight / this.devicePixelRatio), true); } } else { this.oldWidth = this.width; this.oldHeight = this.height; } } } if (this.isloading) { var done = this.areAllTexturesAndSoundsLoaded(); // updates this.progress this.loadingprogress = this.progress; if (done) { this.isloading = false; this.progress = 1; this.trigger(cr.system_object.prototype.cnds.OnLoadFinished, null); if (window["C2_RegisterSW"]) window["C2_RegisterSW"](); } } this.logic(raf_time); if ((this.redraw || this.isCocoonJs) && !this.is_WebGL_context_lost && !this.suspendDrawing && !background_wake) { this.redraw = false; if (this.glwrap) this.drawGL(); else this.draw(); if (this.snapshotCanvas) { if (this.canvas && this.canvas.toDataURL) { this.snapshotData = this.canvas.toDataURL(this.snapshotCanvas[0], this.snapshotCanvas[1]); if (window["cr_onSnapshot"]) window["cr_onSnapshot"](this.snapshotData); this.trigger(cr.system_object.prototype.cnds.OnCanvasSnapshot, null); } this.snapshotCanvas = null; } } if (!this.hit_breakpoint) { this.tickcount++; this.tickcount_nosave++; this.execcount++; this.framecount++; } this.logictime += cr.performance_now() - logic_start; }; Runtime.prototype.logic = function (cur_time) { var i, leni, j, lenj, k, lenk, type, inst, binst; if (cur_time - this.last_fps_time >= 1000) // every 1 second { this.last_fps_time += 1000; if (cur_time - this.last_fps_time >= 1000) this.last_fps_time = cur_time; this.fps = this.framecount; this.framecount = 0; this.cpuutilisation = this.logictime; this.logictime = 0; } var wallDt = 0; if (this.last_tick_time !== 0) { var ms_diff = cur_time - this.last_tick_time; if (ms_diff < 0) ms_diff = 0; wallDt = ms_diff / 1000.0; // dt measured in seconds this.dt1 = wallDt; if (this.dt1 > 0.5) this.dt1 = 0; else if (this.dt1 > 1 / this.minimumFramerate) this.dt1 = 1 / this.minimumFramerate; } this.last_tick_time = cur_time; this.dt = this.dt1 * this.timescale; this.kahanTime.add(this.dt); this.wallTime.add(wallDt); // prevent min/max framerate affecting wall clock var isfullscreen = (document["mozFullScreen"] || document["webkitIsFullScreen"] || document["fullScreen"] || !!document["msFullscreenElement"] || this.isNodeFullscreen) && !this.isCordova; if (this.fullscreen_mode >= 2 /* scale */ || (isfullscreen && this.fullscreen_scaling > 0)) { var orig_aspect = this.original_width / this.original_height; var cur_aspect = this.width / this.height; var mode = this.fullscreen_mode; if (isfullscreen && this.fullscreen_scaling > 0) mode = this.fullscreen_scaling; if ((mode !== 2 && cur_aspect > orig_aspect) || (mode === 2 && cur_aspect < orig_aspect)) { this.aspect_scale = this.height / this.original_height; } else { this.aspect_scale = this.width / this.original_width; } if (this.running_layout) { this.running_layout.scrollToX(this.running_layout.scrollX); this.running_layout.scrollToY(this.running_layout.scrollY); } } else this.aspect_scale = (this.isRetina ? this.devicePixelRatio : 1); this.ClearDeathRow(); this.isInOnDestroy++; this.system.runWaits(); // prevent instance list changing this.isInOnDestroy--; this.ClearDeathRow(); // allow instance list changing this.isInOnDestroy++; var tickarr = this.objects_to_pretick.valuesRef(); for (i = 0, leni = tickarr.length; i < leni; i++) tickarr[i].pretick(); for (i = 0, leni = this.types_by_index.length; i < leni; i++) { type = this.types_by_index[i]; if (type.is_family || (!type.behaviors.length && !type.families.length)) continue; for (j = 0, lenj = type.instances.length; j < lenj; j++) { inst = type.instances[j]; for (k = 0, lenk = inst.behavior_insts.length; k < lenk; k++) { inst.behavior_insts[k].tick(); } } } for (i = 0, leni = this.types_by_index.length; i < leni; i++) { type = this.types_by_index[i]; if (type.is_family || (!type.behaviors.length && !type.families.length)) continue; // type doesn't have any behaviors for (j = 0, lenj = type.instances.length; j < lenj; j++) { inst = type.instances[j]; for (k = 0, lenk = inst.behavior_insts.length; k < lenk; k++) { binst = inst.behavior_insts[k]; if (binst.posttick) binst.posttick(); } } } tickarr = this.objects_to_tick.valuesRef(); for (i = 0, leni = tickarr.length; i < leni; i++) tickarr[i].tick(); this.isInOnDestroy--; // end preventing instance lists from being changed this.handleSaveLoad(); // save/load now if queued i = 0; while (this.changelayout && i++ < 10) { this.doChangeLayout(this.changelayout); } for (i = 0, leni = this.eventsheets_by_index.length; i < leni; i++) this.eventsheets_by_index[i].hasRun = false; if (this.running_layout.event_sheet) this.running_layout.event_sheet.run(); cr.clearArray(this.registered_collisions); this.layout_first_tick = false; this.isInOnDestroy++; // prevent instance lists from being changed for (i = 0, leni = this.types_by_index.length; i < leni; i++) { type = this.types_by_index[i]; if (type.is_family || (!type.behaviors.length && !type.families.length)) continue; // type doesn't have any behaviors for (j = 0, lenj = type.instances.length; j < lenj; j++) { var inst = type.instances[j]; for (k = 0, lenk = inst.behavior_insts.length; k < lenk; k++) { binst = inst.behavior_insts[k]; if (binst.tick2) binst.tick2(); } } } tickarr = this.objects_to_tick2.valuesRef(); for (i = 0, leni = tickarr.length; i < leni; i++) tickarr[i].tick2(); this.isInOnDestroy--; // end preventing instance lists from being changed }; Runtime.prototype.onWindowBlur = function () { var i, leni, j, lenj, k, lenk, type, inst, binst; for (i = 0, leni = this.types_by_index.length; i < leni; i++) { type = this.types_by_index[i]; if (type.is_family) continue; for (j = 0, lenj = type.instances.length; j < lenj; j++) { inst = type.instances[j]; if (inst.onWindowBlur) inst.onWindowBlur(); if (!inst.behavior_insts) continue; // single-globals don't have behavior_insts for (k = 0, lenk = inst.behavior_insts.length; k < lenk; k++) { binst = inst.behavior_insts[k]; if (binst.onWindowBlur) binst.onWindowBlur(); } } } }; Runtime.prototype.doChangeLayout = function (changeToLayout) { var prev_layout = this.running_layout; this.running_layout.stopRunning(); var i, len, j, lenj, k, lenk, type, inst, binst; if (this.glwrap) { for (i = 0, len = this.types_by_index.length; i < len; i++) { type = this.types_by_index[i]; if (type.is_family) continue; if (type.unloadTextures && (!type.global || type.instances.length === 0) && changeToLayout.initial_types.indexOf(type) === -1) { type.unloadTextures(); } } } if (prev_layout == changeToLayout) cr.clearArray(this.system.waits); cr.clearArray(this.registered_collisions); this.runLayoutChangeMethods(true); changeToLayout.startRunning(); this.runLayoutChangeMethods(false); this.redraw = true; this.layout_first_tick = true; this.ClearDeathRow(); }; Runtime.prototype.runLayoutChangeMethods = function (isBeforeChange) { var i, len, beh, type, j, lenj, inst, k, lenk, binst; for (i = 0, len = this.behaviors.length; i < len; i++) { beh = this.behaviors[i]; if (isBeforeChange) { if (beh.onBeforeLayoutChange) beh.onBeforeLayoutChange(); } else { if (beh.onLayoutChange) beh.onLayoutChange(); } } for (i = 0, len = this.types_by_index.length; i < len; i++) { type = this.types_by_index[i]; if (!type.global && !type.plugin.singleglobal) continue; for (j = 0, lenj = type.instances.length; j < lenj; j++) { inst = type.instances[j]; if (isBeforeChange) { if (inst.onBeforeLayoutChange) inst.onBeforeLayoutChange(); } else { if (inst.onLayoutChange) inst.onLayoutChange(); } if (inst.behavior_insts) { for (k = 0, lenk = inst.behavior_insts.length; k < lenk; k++) { binst = inst.behavior_insts[k]; if (isBeforeChange) { if (binst.onBeforeLayoutChange) binst.onBeforeLayoutChange(); } else { if (binst.onLayoutChange) binst.onLayoutChange(); } } } } } }; Runtime.prototype.pretickMe = function (inst) { this.objects_to_pretick.add(inst); }; Runtime.prototype.unpretickMe = function (inst) { this.objects_to_pretick.remove(inst); }; Runtime.prototype.tickMe = function (inst) { this.objects_to_tick.add(inst); }; Runtime.prototype.untickMe = function (inst) { this.objects_to_tick.remove(inst); }; Runtime.prototype.tick2Me = function (inst) { this.objects_to_tick2.add(inst); }; Runtime.prototype.untick2Me = function (inst) { this.objects_to_tick2.remove(inst); }; Runtime.prototype.getDt = function (inst) { if (!inst || inst.my_timescale === -1.0) return this.dt; return this.dt1 * inst.my_timescale; }; Runtime.prototype.draw = function () { this.running_layout.draw(this.ctx); if (this.isDirectCanvas) this.ctx["present"](); }; Runtime.prototype.drawGL = function () { if (this.enableFrontToBack) { this.earlyz_index = 1; // start from front, 1-based to avoid exactly equalling near plane Z value this.running_layout.drawGL_earlyZPass(this.glwrap); } this.running_layout.drawGL(this.glwrap); this.glwrap.present(); }; Runtime.prototype.addDestroyCallback = function (f) { if (f) this.destroycallbacks.push(f); }; Runtime.prototype.removeDestroyCallback = function (f) { cr.arrayFindRemove(this.destroycallbacks, f); }; Runtime.prototype.getObjectByUID = function (uid_) { ; var uidstr = uid_.toString(); if (this.objectsByUid.hasOwnProperty(uidstr)) return this.objectsByUid[uidstr]; else return null; }; var objectset_cache = []; function alloc_objectset() { if (objectset_cache.length) return objectset_cache.pop(); else return new cr.ObjectSet(); }; function free_objectset(s) { s.clear(); objectset_cache.push(s); }; Runtime.prototype.DestroyInstance = function (inst) { var i, len; var type = inst.type; var typename = type.name; var has_typename = this.deathRow.hasOwnProperty(typename); var obj_set = null; if (has_typename) { obj_set = this.deathRow[typename]; if (obj_set.contains(inst)) return; // already had DestroyInstance called } else { obj_set = alloc_objectset(); this.deathRow[typename] = obj_set; } obj_set.add(inst); this.hasPendingInstances = true; if (inst.is_contained) { for (i = 0, len = inst.siblings.length; i < len; i++) { this.DestroyInstance(inst.siblings[i]); } } if (this.isInClearDeathRow) obj_set.values_cache.push(inst); if (!this.isEndingLayout) { this.isInOnDestroy++; // support recursion this.trigger(Object.getPrototypeOf(inst.type.plugin).cnds.OnDestroyed, inst); this.isInOnDestroy--; } }; Runtime.prototype.ClearDeathRow = function () { if (!this.hasPendingInstances) return; var inst, type, instances; var i, j, leni, lenj, obj_set; this.isInClearDeathRow = true; for (i = 0, leni = this.createRow.length; i < leni; ++i) { inst = this.createRow[i]; type = inst.type; type.instances.push(inst); for (j = 0, lenj = type.families.length; j < lenj; ++j) { type.families[j].instances.push(inst); type.families[j].stale_iids = true; } } cr.clearArray(this.createRow); this.IterateDeathRow(); // moved to separate function so for-in performance doesn't hobble entire function cr.wipe(this.deathRow); // all objectsets have already been recycled this.isInClearDeathRow = false; this.hasPendingInstances = false; }; Runtime.prototype.IterateDeathRow = function () { for (var p in this.deathRow) { if (this.deathRow.hasOwnProperty(p)) { this.ClearDeathRowForType(this.deathRow[p]); } } }; Runtime.prototype.ClearDeathRowForType = function (obj_set) { var arr = obj_set.valuesRef(); // get array of items from set ; var type = arr[0].type; ; ; var i, len, j, lenj, w, f, layer_instances, inst; cr.arrayRemoveAllFromObjectSet(type.instances, obj_set); type.stale_iids = true; if (type.instances.length === 0) type.any_instance_parallaxed = false; for (i = 0, len = type.families.length; i < len; ++i) { f = type.families[i]; cr.arrayRemoveAllFromObjectSet(f.instances, obj_set); f.stale_iids = true; } for (i = 0, len = this.system.waits.length; i < len; ++i) { w = this.system.waits[i]; if (w.sols.hasOwnProperty(type.index)) cr.arrayRemoveAllFromObjectSet(w.sols[type.index].insts, obj_set); if (!type.is_family) { for (j = 0, lenj = type.families.length; j < lenj; ++j) { f = type.families[j]; if (w.sols.hasOwnProperty(f.index)) cr.arrayRemoveAllFromObjectSet(w.sols[f.index].insts, obj_set); } } } var first_layer = arr[0].layer; if (first_layer) { if (first_layer.useRenderCells) { layer_instances = first_layer.instances; for (i = 0, len = layer_instances.length; i < len; ++i) { inst = layer_instances[i]; if (!obj_set.contains(inst)) continue; // not destroying this instance inst.update_bbox(); first_layer.render_grid.update(inst, inst.rendercells, null); inst.rendercells.set(0, 0, -1, -1); } } cr.arrayRemoveAllFromObjectSet(first_layer.instances, obj_set); first_layer.setZIndicesStaleFrom(0); } for (i = 0; i < arr.length; ++i) // check array length every time in case it changes { this.ClearDeathRowForSingleInstance(arr[i], type); } free_objectset(obj_set); this.redraw = true; }; Runtime.prototype.ClearDeathRowForSingleInstance = function (inst, type) { var i, len, binst; for (i = 0, len = this.destroycallbacks.length; i < len; ++i) this.destroycallbacks[i](inst); if (inst.collcells) { type.collision_grid.update(inst, inst.collcells, null); } var layer = inst.layer; if (layer) { layer.removeFromInstanceList(inst, true); // remove from both instance list and render grid } if (inst.behavior_insts) { for (i = 0, len = inst.behavior_insts.length; i < len; ++i) { binst = inst.behavior_insts[i]; if (binst.onDestroy) binst.onDestroy(); binst.behavior.my_instances.remove(inst); } } this.objects_to_pretick.remove(inst); this.objects_to_tick.remove(inst); this.objects_to_tick2.remove(inst); if (inst.onDestroy) inst.onDestroy(); if (this.objectsByUid.hasOwnProperty(inst.uid.toString())) delete this.objectsByUid[inst.uid.toString()]; this.objectcount--; if (type.deadCache.length < 100) type.deadCache.push(inst); }; Runtime.prototype.createInstance = function (type, layer, sx, sy) { if (type.is_family) { var i = cr.floor(Math.random() * type.members.length); return this.createInstance(type.members[i], layer, sx, sy); } if (!type.default_instance) { return null; } return this.createInstanceFromInit(type.default_instance, layer, false, sx, sy, false); }; var all_behaviors = []; Runtime.prototype.createInstanceFromInit = function (initial_inst, layer, is_startup_instance, sx, sy, skip_siblings) { var i, len, j, lenj, p, effect_fallback, x, y; if (!initial_inst) return null; var type = this.types_by_index[initial_inst[1]]; ; ; var is_world = type.plugin.is_world; ; if (this.isloading && is_world && !type.isOnLoaderLayout) return null; if (is_world && !this.glwrap && initial_inst[0][11] === 11) return null; var original_layer = layer; if (!is_world) layer = null; var inst; if (type.deadCache.length) { inst = type.deadCache.pop(); inst.recycled = true; type.plugin.Instance.call(inst, type); } else { inst = new type.plugin.Instance(type); inst.recycled = false; } if (is_startup_instance && !skip_siblings && !this.objectsByUid.hasOwnProperty(initial_inst[2].toString())) inst.uid = initial_inst[2]; else inst.uid = this.next_uid++; this.objectsByUid[inst.uid.toString()] = inst; inst.puid = this.next_puid++; inst.iid = type.instances.length; for (i = 0, len = this.createRow.length; i < len; ++i) { if (this.createRow[i].type === type) inst.iid++; } inst.get_iid = cr.inst_get_iid; inst.toString = cr.inst_toString; var initial_vars = initial_inst[3]; if (inst.recycled) { cr.wipe(inst.extra); } else { inst.extra = {}; if (typeof cr_is_preview !== "undefined") { inst.instance_var_names = []; inst.instance_var_names.length = initial_vars.length; for (i = 0, len = initial_vars.length; i < len; i++) inst.instance_var_names[i] = initial_vars[i][1]; } inst.instance_vars = []; inst.instance_vars.length = initial_vars.length; } for (i = 0, len = initial_vars.length; i < len; i++) inst.instance_vars[i] = initial_vars[i][0]; if (is_world) { var wm = initial_inst[0]; ; inst.x = cr.is_undefined(sx) ? wm[0] : sx; inst.y = cr.is_undefined(sy) ? wm[1] : sy; inst.z = wm[2]; inst.width = wm[3]; inst.height = wm[4]; inst.depth = wm[5]; inst.angle = wm[6]; inst.opacity = wm[7]; inst.hotspotX = wm[8]; inst.hotspotY = wm[9]; inst.blend_mode = wm[10]; effect_fallback = wm[11]; if (!this.glwrap && type.effect_types.length) // no WebGL renderer and shaders used inst.blend_mode = effect_fallback; // use fallback blend mode - destroy mode was handled above inst.compositeOp = cr.effectToCompositeOp(inst.blend_mode); if (this.gl) cr.setGLBlend(inst, inst.blend_mode, this.gl); if (inst.recycled) { for (i = 0, len = wm[12].length; i < len; i++) { for (j = 0, lenj = wm[12][i].length; j < lenj; j++) inst.effect_params[i][j] = wm[12][i][j]; } inst.bbox.set(0, 0, 0, 0); inst.collcells.set(0, 0, -1, -1); inst.rendercells.set(0, 0, -1, -1); inst.bquad.set_from_rect(inst.bbox); cr.clearArray(inst.bbox_changed_callbacks); } else { inst.effect_params = wm[12].slice(0); for (i = 0, len = inst.effect_params.length; i < len; i++) inst.effect_params[i] = wm[12][i].slice(0); inst.active_effect_types = []; inst.active_effect_flags = []; inst.active_effect_flags.length = type.effect_types.length; inst.bbox = new cr.rect(0, 0, 0, 0); inst.collcells = new cr.rect(0, 0, -1, -1); inst.rendercells = new cr.rect(0, 0, -1, -1); inst.bquad = new cr.quad(); inst.bbox_changed_callbacks = []; inst.set_bbox_changed = cr.set_bbox_changed; inst.add_bbox_changed_callback = cr.add_bbox_changed_callback; inst.contains_pt = cr.inst_contains_pt; inst.update_bbox = cr.update_bbox; inst.update_render_cell = cr.update_render_cell; inst.update_collision_cell = cr.update_collision_cell; inst.get_zindex = cr.inst_get_zindex; } inst.tilemap_exists = false; inst.tilemap_width = 0; inst.tilemap_height = 0; inst.tilemap_data = null; if (wm.length === 14) { inst.tilemap_exists = true; inst.tilemap_width = wm[13][0]; inst.tilemap_height = wm[13][1]; inst.tilemap_data = wm[13][2]; } for (i = 0, len = type.effect_types.length; i < len; i++) inst.active_effect_flags[i] = true; inst.shaders_preserve_opaqueness = true; inst.updateActiveEffects = cr.inst_updateActiveEffects; inst.updateActiveEffects(); inst.uses_shaders = !!inst.active_effect_types.length; inst.bbox_changed = true; inst.cell_changed = true; type.any_cell_changed = true; inst.visible = true; inst.my_timescale = -1.0; inst.layer = layer; inst.zindex = layer.instances.length; // will be placed at top of current layer inst.earlyz_index = 0; if (typeof inst.collision_poly === "undefined") inst.collision_poly = null; inst.collisionsEnabled = true; this.redraw = true; } var initial_props, binst; cr.clearArray(all_behaviors); for (i = 0, len = type.families.length; i < len; i++) { all_behaviors.push.apply(all_behaviors, type.families[i].behaviors); } all_behaviors.push.apply(all_behaviors, type.behaviors); if (inst.recycled) { for (i = 0, len = all_behaviors.length; i < len; i++) { var btype = all_behaviors[i]; binst = inst.behavior_insts[i]; binst.recycled = true; btype.behavior.Instance.call(binst, btype, inst); initial_props = initial_inst[4][i]; for (j = 0, lenj = initial_props.length; j < lenj; j++) binst.properties[j] = initial_props[j]; binst.onCreate(); btype.behavior.my_instances.add(inst); } } else { inst.behavior_insts = []; for (i = 0, len = all_behaviors.length; i < len; i++) { var btype = all_behaviors[i]; var binst = new btype.behavior.Instance(btype, inst); binst.recycled = false; binst.properties = initial_inst[4][i].slice(0); binst.onCreate(); cr.seal(binst); inst.behavior_insts.push(binst); btype.behavior.my_instances.add(inst); } } initial_props = initial_inst[5]; if (inst.recycled) { for (i = 0, len = initial_props.length; i < len; i++) inst.properties[i] = initial_props[i]; } else inst.properties = initial_props.slice(0); this.createRow.push(inst); this.hasPendingInstances = true; if (layer) { ; layer.appendToInstanceList(inst, true); if (layer.parallaxX !== 1 || layer.parallaxY !== 1) type.any_instance_parallaxed = true; } this.objectcount++; if (type.is_contained) { inst.is_contained = true; if (inst.recycled) cr.clearArray(inst.siblings); else inst.siblings = []; // note: should not include self in siblings if (!is_startup_instance && !skip_siblings) // layout links initial instances { for (i = 0, len = type.container.length; i < len; i++) { if (type.container[i] === type) continue; if (!type.container[i].default_instance) { return null; } inst.siblings.push(this.createInstanceFromInit(type.container[i].default_instance, original_layer, false, is_world ? inst.x : sx, is_world ? inst.y : sy, true)); } for (i = 0, len = inst.siblings.length; i < len; i++) { inst.siblings[i].siblings.push(inst); for (j = 0; j < len; j++) { if (i !== j) inst.siblings[i].siblings.push(inst.siblings[j]); } } } } else { inst.is_contained = false; inst.siblings = null; } inst.onCreate(); if (!inst.recycled) cr.seal(inst); for (i = 0, len = inst.behavior_insts.length; i < len; i++) { if (inst.behavior_insts[i].postCreate) inst.behavior_insts[i].postCreate(); } return inst; }; Runtime.prototype.getLayerByName = function (layer_name) { var i, len; for (i = 0, len = this.running_layout.layers.length; i < len; i++) { var layer = this.running_layout.layers[i]; if (cr.equals_nocase(layer.name, layer_name)) return layer; } return null; }; Runtime.prototype.getLayerByNumber = function (index) { index = cr.floor(index); if (index < 0) index = 0; if (index >= this.running_layout.layers.length) index = this.running_layout.layers.length - 1; return this.running_layout.layers[index]; }; Runtime.prototype.getLayer = function (l) { if (cr.is_number(l)) return this.getLayerByNumber(l); else return this.getLayerByName(l.toString()); }; Runtime.prototype.clearSol = function (solModifiers) { var i, len; for (i = 0, len = solModifiers.length; i < len; i++) { solModifiers[i].getCurrentSol().select_all = true; } }; Runtime.prototype.pushCleanSol = function (solModifiers) { var i, len; for (i = 0, len = solModifiers.length; i < len; i++) { solModifiers[i].pushCleanSol(); } }; Runtime.prototype.pushCopySol = function (solModifiers) { var i, len; for (i = 0, len = solModifiers.length; i < len; i++) { solModifiers[i].pushCopySol(); } }; Runtime.prototype.popSol = function (solModifiers) { var i, len; for (i = 0, len = solModifiers.length; i < len; i++) { solModifiers[i].popSol(); } }; Runtime.prototype.updateAllCells = function (type) { if (!type.any_cell_changed) return; // all instances must already be up-to-date var i, len, instances = type.instances; for (i = 0, len = instances.length; i < len; ++i) { instances[i].update_collision_cell(); } var createRow = this.createRow; for (i = 0, len = createRow.length; i < len; ++i) { if (createRow[i].type === type) createRow[i].update_collision_cell(); } type.any_cell_changed = false; }; Runtime.prototype.getCollisionCandidates = function (layer, rtype, bbox, candidates) { var i, len, t; var is_parallaxed = (layer ? (layer.parallaxX !== 1 || layer.parallaxY !== 1) : false); if (rtype.is_family) { for (i = 0, len = rtype.members.length; i < len; ++i) { t = rtype.members[i]; if (is_parallaxed || t.any_instance_parallaxed) { cr.appendArray(candidates, t.instances); } else { this.updateAllCells(t); t.collision_grid.queryRange(bbox, candidates); } } } else { if (is_parallaxed || rtype.any_instance_parallaxed) { cr.appendArray(candidates, rtype.instances); } else { this.updateAllCells(rtype); rtype.collision_grid.queryRange(bbox, candidates); } } }; Runtime.prototype.getTypesCollisionCandidates = function (layer, types, bbox, candidates) { var i, len; for (i = 0, len = types.length; i < len; ++i) { this.getCollisionCandidates(layer, types[i], bbox, candidates); } }; Runtime.prototype.getSolidCollisionCandidates = function (layer, bbox, candidates) { var solid = this.getSolidBehavior(); if (!solid) return null; this.getTypesCollisionCandidates(layer, solid.my_types, bbox, candidates); }; Runtime.prototype.getJumpthruCollisionCandidates = function (layer, bbox, candidates) { var jumpthru = this.getJumpthruBehavior(); if (!jumpthru) return null; this.getTypesCollisionCandidates(layer, jumpthru.my_types, bbox, candidates); }; Runtime.prototype.testAndSelectCanvasPointOverlap = function (type, ptx, pty, inverted) { var sol = type.getCurrentSol(); var i, j, inst, len; var orblock = this.getCurrentEventStack().current_event.orblock; var lx, ly, arr; if (sol.select_all) { if (!inverted) { sol.select_all = false; cr.clearArray(sol.instances); // clear contents } for (i = 0, len = type.instances.length; i < len; i++) { inst = type.instances[i]; inst.update_bbox(); lx = inst.layer.canvasToLayer(ptx, pty, true); ly = inst.layer.canvasToLayer(ptx, pty, false); if (inst.contains_pt(lx, ly)) { if (inverted) return false; else sol.instances.push(inst); } else if (orblock) sol.else_instances.push(inst); } } else { j = 0; arr = (orblock ? sol.else_instances : sol.instances); for (i = 0, len = arr.length; i < len; i++) { inst = arr[i]; inst.update_bbox(); lx = inst.layer.canvasToLayer(ptx, pty, true); ly = inst.layer.canvasToLayer(ptx, pty, false); if (inst.contains_pt(lx, ly)) { if (inverted) return false; else if (orblock) sol.instances.push(inst); else { sol.instances[j] = sol.instances[i]; j++; } } } if (!inverted) arr.length = j; } type.applySolToContainer(); if (inverted) return true; // did not find anything overlapping else return sol.hasObjects(); }; Runtime.prototype.testOverlap = function (a, b) { if (!a || !b || a === b || !a.collisionsEnabled || !b.collisionsEnabled) return false; a.update_bbox(); b.update_bbox(); var layera = a.layer; var layerb = b.layer; var different_layers = (layera !== layerb && (layera.parallaxX !== layerb.parallaxX || layerb.parallaxY !== layerb.parallaxY || layera.scale !== layerb.scale || layera.angle !== layerb.angle || layera.zoomRate !== layerb.zoomRate)); var i, len, i2, i21, x, y, haspolya, haspolyb, polya, polyb; if (!different_layers) // same layers: easy check { if (!a.bbox.intersects_rect(b.bbox)) return false; if (!a.bquad.intersects_quad(b.bquad)) return false; if (a.tilemap_exists && b.tilemap_exists) return false; if (a.tilemap_exists) return this.testTilemapOverlap(a, b); if (b.tilemap_exists) return this.testTilemapOverlap(b, a); haspolya = (a.collision_poly && !a.collision_poly.is_empty()); haspolyb = (b.collision_poly && !b.collision_poly.is_empty()); if (!haspolya && !haspolyb) return true; if (haspolya) { a.collision_poly.cache_poly(a.width, a.height, a.angle); polya = a.collision_poly; } else { this.temp_poly.set_from_quad(a.bquad, a.x, a.y, a.width, a.height); polya = this.temp_poly; } if (haspolyb) { b.collision_poly.cache_poly(b.width, b.height, b.angle); polyb = b.collision_poly; } else { this.temp_poly.set_from_quad(b.bquad, b.x, b.y, b.width, b.height); polyb = this.temp_poly; } return polya.intersects_poly(polyb, b.x - a.x, b.y - a.y); } else // different layers: need to do full translated check { haspolya = (a.collision_poly && !a.collision_poly.is_empty()); haspolyb = (b.collision_poly && !b.collision_poly.is_empty()); if (haspolya) { a.collision_poly.cache_poly(a.width, a.height, a.angle); this.temp_poly.set_from_poly(a.collision_poly); } else { this.temp_poly.set_from_quad(a.bquad, a.x, a.y, a.width, a.height); } polya = this.temp_poly; if (haspolyb) { b.collision_poly.cache_poly(b.width, b.height, b.angle); this.temp_poly2.set_from_poly(b.collision_poly); } else { this.temp_poly2.set_from_quad(b.bquad, b.x, b.y, b.width, b.height); } polyb = this.temp_poly2; for (i = 0, len = polya.pts_count; i < len; i++) { i2 = i * 2; i21 = i2 + 1; x = polya.pts_cache[i2]; y = polya.pts_cache[i21]; polya.pts_cache[i2] = layera.layerToCanvas(x + a.x, y + a.y, true); polya.pts_cache[i21] = layera.layerToCanvas(x + a.x, y + a.y, false); } polya.update_bbox(); for (i = 0, len = polyb.pts_count; i < len; i++) { i2 = i * 2; i21 = i2 + 1; x = polyb.pts_cache[i2]; y = polyb.pts_cache[i21]; polyb.pts_cache[i2] = layerb.layerToCanvas(x + b.x, y + b.y, true); polyb.pts_cache[i21] = layerb.layerToCanvas(x + b.x, y + b.y, false); } polyb.update_bbox(); return polya.intersects_poly(polyb, 0, 0); } }; var tmpQuad = new cr.quad(); var tmpRect = new cr.rect(0, 0, 0, 0); var collrect_candidates = []; Runtime.prototype.testTilemapOverlap = function (tm, a) { var i, len, c, rc; var bbox = a.bbox; var tmx = tm.x; var tmy = tm.y; tm.getCollisionRectCandidates(bbox, collrect_candidates); var collrects = collrect_candidates; var haspolya = (a.collision_poly && !a.collision_poly.is_empty()); for (i = 0, len = collrects.length; i < len; ++i) { c = collrects[i]; rc = c.rc; if (bbox.intersects_rect_off(rc, tmx, tmy)) { tmpQuad.set_from_rect(rc); tmpQuad.offset(tmx, tmy); if (tmpQuad.intersects_quad(a.bquad)) { if (haspolya) { a.collision_poly.cache_poly(a.width, a.height, a.angle); if (c.poly) { if (c.poly.intersects_poly(a.collision_poly, a.x - (tmx + rc.left), a.y - (tmy + rc.top))) { cr.clearArray(collrect_candidates); return true; } } else { this.temp_poly.set_from_quad(tmpQuad, 0, 0, rc.right - rc.left, rc.bottom - rc.top); if (this.temp_poly.intersects_poly(a.collision_poly, a.x, a.y)) { cr.clearArray(collrect_candidates); return true; } } } else { if (c.poly) { this.temp_poly.set_from_quad(a.bquad, 0, 0, a.width, a.height); if (c.poly.intersects_poly(this.temp_poly, -(tmx + rc.left), -(tmy + rc.top))) { cr.clearArray(collrect_candidates); return true; } } else { cr.clearArray(collrect_candidates); return true; } } } } } cr.clearArray(collrect_candidates); return false; }; Runtime.prototype.testRectOverlap = function (r, b) { if (!b || !b.collisionsEnabled) return false; b.update_bbox(); var layerb = b.layer; var haspolyb, polyb; if (!b.bbox.intersects_rect(r)) return false; if (b.tilemap_exists) { b.getCollisionRectCandidates(r, collrect_candidates); var collrects = collrect_candidates; var i, len, c, tilerc; var tmx = b.x; var tmy = b.y; for (i = 0, len = collrects.length; i < len; ++i) { c = collrects[i]; tilerc = c.rc; if (r.intersects_rect_off(tilerc, tmx, tmy)) { if (c.poly) { this.temp_poly.set_from_rect(r, 0, 0); if (c.poly.intersects_poly(this.temp_poly, -(tmx + tilerc.left), -(tmy + tilerc.top))) { cr.clearArray(collrect_candidates); return true; } } else { cr.clearArray(collrect_candidates); return true; } } } cr.clearArray(collrect_candidates); return false; } else { tmpQuad.set_from_rect(r); if (!b.bquad.intersects_quad(tmpQuad)) return false; haspolyb = (b.collision_poly && !b.collision_poly.is_empty()); if (!haspolyb) return true; b.collision_poly.cache_poly(b.width, b.height, b.angle); tmpQuad.offset(-r.left, -r.top); this.temp_poly.set_from_quad(tmpQuad, 0, 0, 1, 1); return b.collision_poly.intersects_poly(this.temp_poly, r.left - b.x, r.top - b.y); } }; Runtime.prototype.testSegmentOverlap = function (x1, y1, x2, y2, b) { if (!b || !b.collisionsEnabled) return false; b.update_bbox(); var layerb = b.layer; var haspolyb, polyb; tmpRect.set(cr.min(x1, x2), cr.min(y1, y2), cr.max(x1, x2), cr.max(y1, y2)); if (!b.bbox.intersects_rect(tmpRect)) return false; if (b.tilemap_exists) { b.getCollisionRectCandidates(tmpRect, collrect_candidates); var collrects = collrect_candidates; var i, len, c, tilerc; var tmx = b.x; var tmy = b.y; for (i = 0, len = collrects.length; i < len; ++i) { c = collrects[i]; tilerc = c.rc; if (tmpRect.intersects_rect_off(tilerc, tmx, tmy)) { tmpQuad.set_from_rect(tilerc); tmpQuad.offset(tmx, tmy); if (tmpQuad.intersects_segment(x1, y1, x2, y2)) { if (c.poly) { if (c.poly.intersects_segment(tmx + tilerc.left, tmy + tilerc.top, x1, y1, x2, y2)) { cr.clearArray(collrect_candidates); return true; } } else { cr.clearArray(collrect_candidates); return true; } } } } cr.clearArray(collrect_candidates); return false; } else { if (!b.bquad.intersects_segment(x1, y1, x2, y2)) return false; haspolyb = (b.collision_poly && !b.collision_poly.is_empty()); if (!haspolyb) return true; b.collision_poly.cache_poly(b.width, b.height, b.angle); return b.collision_poly.intersects_segment(b.x, b.y, x1, y1, x2, y2); } }; Runtime.prototype.typeHasBehavior = function (t, b) { if (!b) return false; var i, len, j, lenj, f; for (i = 0, len = t.behaviors.length; i < len; i++) { if (t.behaviors[i].behavior instanceof b) return true; } if (!t.is_family) { for (i = 0, len = t.families.length; i < len; i++) { f = t.families[i]; for (j = 0, lenj = f.behaviors.length; j < lenj; j++) { if (f.behaviors[j].behavior instanceof b) return true; } } } return false; }; Runtime.prototype.typeHasNoSaveBehavior = function (t) { return this.typeHasBehavior(t, cr.behaviors.NoSave); }; Runtime.prototype.typeHasPersistBehavior = function (t) { return this.typeHasBehavior(t, cr.behaviors.Persist); }; Runtime.prototype.getSolidBehavior = function () { return this.solidBehavior; }; Runtime.prototype.getJumpthruBehavior = function () { return this.jumpthruBehavior; }; var candidates = []; Runtime.prototype.testOverlapSolid = function (inst) { var i, len, s; inst.update_bbox(); this.getSolidCollisionCandidates(inst.layer, inst.bbox, candidates); for (i = 0, len = candidates.length; i < len; ++i) { s = candidates[i]; if (!s.extra["solidEnabled"]) continue; if (this.testOverlap(inst, s)) { cr.clearArray(candidates); return s; } } cr.clearArray(candidates); return null; }; Runtime.prototype.testRectOverlapSolid = function (r) { var i, len, s; this.getSolidCollisionCandidates(null, r, candidates); for (i = 0, len = candidates.length; i < len; ++i) { s = candidates[i]; if (!s.extra["solidEnabled"]) continue; if (this.testRectOverlap(r, s)) { cr.clearArray(candidates); return s; } } cr.clearArray(candidates); return null; }; var jumpthru_array_ret = []; Runtime.prototype.testOverlapJumpThru = function (inst, all) { var ret = null; if (all) { ret = jumpthru_array_ret; cr.clearArray(ret); } inst.update_bbox(); this.getJumpthruCollisionCandidates(inst.layer, inst.bbox, candidates); var i, len, j; for (i = 0, len = candidates.length; i < len; ++i) { j = candidates[i]; if (!j.extra["jumpthruEnabled"]) continue; if (this.testOverlap(inst, j)) { if (all) ret.push(j); else { cr.clearArray(candidates); return j; } } } cr.clearArray(candidates); return ret; }; Runtime.prototype.pushOutSolid = function (inst, xdir, ydir, dist, include_jumpthrus, specific_jumpthru) { var push_dist = dist || 50; var oldx = inst.x var oldy = inst.y; var i; var last_overlapped = null, secondlast_overlapped = null; for (i = 0; i < push_dist; i++) { inst.x = (oldx + (xdir * i)); inst.y = (oldy + (ydir * i)); inst.set_bbox_changed(); if (!this.testOverlap(inst, last_overlapped)) { last_overlapped = this.testOverlapSolid(inst); if (last_overlapped) secondlast_overlapped = last_overlapped; if (!last_overlapped) { if (include_jumpthrus) { if (specific_jumpthru) last_overlapped = (this.testOverlap(inst, specific_jumpthru) ? specific_jumpthru : null); else last_overlapped = this.testOverlapJumpThru(inst); if (last_overlapped) secondlast_overlapped = last_overlapped; } if (!last_overlapped) { if (secondlast_overlapped) this.pushInFractional(inst, xdir, ydir, secondlast_overlapped, 16); return true; } } } } inst.x = oldx; inst.y = oldy; inst.set_bbox_changed(); return false; }; Runtime.prototype.pushOut = function (inst, xdir, ydir, dist, otherinst) { var push_dist = dist || 50; var oldx = inst.x var oldy = inst.y; var i; for (i = 0; i < push_dist; i++) { inst.x = (oldx + (xdir * i)); inst.y = (oldy + (ydir * i)); inst.set_bbox_changed(); if (!this.testOverlap(inst, otherinst)) return true; } inst.x = oldx; inst.y = oldy; inst.set_bbox_changed(); return false; }; Runtime.prototype.pushInFractional = function (inst, xdir, ydir, obj, limit) { var divisor = 2; var frac; var forward = false; var overlapping = false; var bestx = inst.x; var besty = inst.y; while (divisor <= limit) { frac = 1 / divisor; divisor *= 2; inst.x += xdir * frac * (forward ? 1 : -1); inst.y += ydir * frac * (forward ? 1 : -1); inst.set_bbox_changed(); if (this.testOverlap(inst, obj)) { forward = true; overlapping = true; } else { forward = false; overlapping = false; bestx = inst.x; besty = inst.y; } } if (overlapping) { inst.x = bestx; inst.y = besty; inst.set_bbox_changed(); } }; Runtime.prototype.pushOutSolidNearest = function (inst, max_dist_) { var max_dist = (cr.is_undefined(max_dist_) ? 100 : max_dist_); var dist = 0; var oldx = inst.x var oldy = inst.y; var dir = 0; var dx = 0, dy = 0; var last_overlapped = this.testOverlapSolid(inst); if (!last_overlapped) return true; // already clear of solids while (dist <= max_dist) { switch (dir) { case 0: dx = 0; dy = -1; dist++; break; case 1: dx = 1; dy = -1; break; case 2: dx = 1; dy = 0; break; case 3: dx = 1; dy = 1; break; case 4: dx = 0; dy = 1; break; case 5: dx = -1; dy = 1; break; case 6: dx = -1; dy = 0; break; case 7: dx = -1; dy = -1; break; } dir = (dir + 1) % 8; inst.x = cr.floor(oldx + (dx * dist)); inst.y = cr.floor(oldy + (dy * dist)); inst.set_bbox_changed(); if (!this.testOverlap(inst, last_overlapped)) { last_overlapped = this.testOverlapSolid(inst); if (!last_overlapped) return true; } } inst.x = oldx; inst.y = oldy; inst.set_bbox_changed(); return false; }; Runtime.prototype.registerCollision = function (a, b) { if (!a.collisionsEnabled || !b.collisionsEnabled) return; this.registered_collisions.push([a, b]); }; Runtime.prototype.addRegisteredCollisionCandidates = function (inst, otherType, arr) { var i, len, r, otherInst; for (i = 0, len = this.registered_collisions.length; i < len; ++i) { r = this.registered_collisions[i]; if (r[0] === inst) otherInst = r[1]; else if (r[1] === inst) otherInst = r[0]; else continue; if (otherType.is_family) { if (otherType.members.indexOf(otherType) === -1) continue; } else { if (otherInst.type !== otherType) continue; } if (arr.indexOf(otherInst) === -1) arr.push(otherInst); } }; Runtime.prototype.checkRegisteredCollision = function (a, b) { var i, len, x; for (i = 0, len = this.registered_collisions.length; i < len; i++) { x = this.registered_collisions[i]; if ((x[0] === a && x[1] === b) || (x[0] === b && x[1] === a)) return true; } return false; }; Runtime.prototype.calculateSolidBounceAngle = function(inst, startx, starty, obj) { var objx = inst.x; var objy = inst.y; var radius = cr.max(10, cr.distanceTo(startx, starty, objx, objy)); var startangle = cr.angleTo(startx, starty, objx, objy); var firstsolid = obj || this.testOverlapSolid(inst); if (!firstsolid) return cr.clamp_angle(startangle + cr.PI); var cursolid = firstsolid; var i, curangle, anticlockwise_free_angle, clockwise_free_angle; var increment = cr.to_radians(5); // 5 degree increments for (i = 1; i < 36; i++) { curangle = startangle - i * increment; inst.x = startx + Math.cos(curangle) * radius; inst.y = starty + Math.sin(curangle) * radius; inst.set_bbox_changed(); if (!this.testOverlap(inst, cursolid)) { cursolid = obj ? null : this.testOverlapSolid(inst); if (!cursolid) { anticlockwise_free_angle = curangle; break; } } } if (i === 36) anticlockwise_free_angle = cr.clamp_angle(startangle + cr.PI); var cursolid = firstsolid; for (i = 1; i < 36; i++) { curangle = startangle + i * increment; inst.x = startx + Math.cos(curangle) * radius; inst.y = starty + Math.sin(curangle) * radius; inst.set_bbox_changed(); if (!this.testOverlap(inst, cursolid)) { cursolid = obj ? null : this.testOverlapSolid(inst); if (!cursolid) { clockwise_free_angle = curangle; break; } } } if (i === 36) clockwise_free_angle = cr.clamp_angle(startangle + cr.PI); inst.x = objx; inst.y = objy; inst.set_bbox_changed(); if (clockwise_free_angle === anticlockwise_free_angle) return clockwise_free_angle; var half_diff = cr.angleDiff(clockwise_free_angle, anticlockwise_free_angle) / 2; var normal; if (cr.angleClockwise(clockwise_free_angle, anticlockwise_free_angle)) { normal = cr.clamp_angle(anticlockwise_free_angle + half_diff + cr.PI); } else { normal = cr.clamp_angle(clockwise_free_angle + half_diff); } ; var vx = Math.cos(startangle); var vy = Math.sin(startangle); var nx = Math.cos(normal); var ny = Math.sin(normal); var v_dot_n = vx * nx + vy * ny; var rx = vx - 2 * v_dot_n * nx; var ry = vy - 2 * v_dot_n * ny; return cr.angleTo(0, 0, rx, ry); }; var triggerSheetIndex = -1; Runtime.prototype.trigger = function (method, inst, value /* for fast triggers */) { ; if (!this.running_layout) return false; var sheet = this.running_layout.event_sheet; if (!sheet) return false; // no event sheet active; nothing to trigger var ret = false; var r, i, len; triggerSheetIndex++; var deep_includes = sheet.deep_includes; for (i = 0, len = deep_includes.length; i < len; ++i) { r = this.triggerOnSheet(method, inst, deep_includes[i], value); ret = ret || r; } r = this.triggerOnSheet(method, inst, sheet, value); ret = ret || r; triggerSheetIndex--; return ret; }; Runtime.prototype.triggerOnSheet = function (method, inst, sheet, value) { var ret = false; var i, leni, r, families; if (!inst) { r = this.triggerOnSheetForTypeName(method, inst, "system", sheet, value); ret = ret || r; } else { r = this.triggerOnSheetForTypeName(method, inst, inst.type.name, sheet, value); ret = ret || r; families = inst.type.families; for (i = 0, leni = families.length; i < leni; ++i) { r = this.triggerOnSheetForTypeName(method, inst, families[i].name, sheet, value); ret = ret || r; } } return ret; // true if anything got triggered }; Runtime.prototype.triggerOnSheetForTypeName = function (method, inst, type_name, sheet, value) { var i, leni; var ret = false, ret2 = false; var trig, index; var fasttrigger = (typeof value !== "undefined"); var triggers = (fasttrigger ? sheet.fasttriggers : sheet.triggers); var obj_entry = triggers[type_name]; if (!obj_entry) return ret; var triggers_list = null; for (i = 0, leni = obj_entry.length; i < leni; ++i) { if (obj_entry[i].method == method) { triggers_list = obj_entry[i].evs; break; } } if (!triggers_list) return ret; var triggers_to_fire; if (fasttrigger) { triggers_to_fire = triggers_list[value]; } else { triggers_to_fire = triggers_list; } if (!triggers_to_fire) return null; for (i = 0, leni = triggers_to_fire.length; i < leni; i++) { trig = triggers_to_fire[i][0]; index = triggers_to_fire[i][1]; ret2 = this.executeSingleTrigger(inst, type_name, trig, index); ret = ret || ret2; } return ret; }; Runtime.prototype.executeSingleTrigger = function (inst, type_name, trig, index) { var i, leni; var ret = false; this.trigger_depth++; var current_event = this.getCurrentEventStack().current_event; if (current_event) this.pushCleanSol(current_event.solModifiersIncludingParents); var isrecursive = (this.trigger_depth > 1); // calling trigger from inside another trigger this.pushCleanSol(trig.solModifiersIncludingParents); if (isrecursive) this.pushLocalVarStack(); var event_stack = this.pushEventStack(trig); event_stack.current_event = trig; if (inst) { var sol = this.types[type_name].getCurrentSol(); sol.select_all = false; cr.clearArray(sol.instances); sol.instances[0] = inst; this.types[type_name].applySolToContainer(); } var ok_to_run = true; if (trig.parent) { var temp_parents_arr = event_stack.temp_parents_arr; var cur_parent = trig.parent; while (cur_parent) { temp_parents_arr.push(cur_parent); cur_parent = cur_parent.parent; } temp_parents_arr.reverse(); for (i = 0, leni = temp_parents_arr.length; i < leni; i++) { if (!temp_parents_arr[i].run_pretrigger()) // parent event failed { ok_to_run = false; break; } } } if (ok_to_run) { this.execcount++; if (trig.orblock) trig.run_orblocktrigger(index); else trig.run(); ret = ret || event_stack.last_event_true; } this.popEventStack(); if (isrecursive) this.popLocalVarStack(); this.popSol(trig.solModifiersIncludingParents); if (current_event) this.popSol(current_event.solModifiersIncludingParents); if (this.hasPendingInstances && this.isInOnDestroy === 0 && triggerSheetIndex === 0 && !this.isRunningEvents) { this.ClearDeathRow(); } this.trigger_depth--; return ret; }; Runtime.prototype.getCurrentCondition = function () { var evinfo = this.getCurrentEventStack(); return evinfo.current_event.conditions[evinfo.cndindex]; }; Runtime.prototype.getCurrentConditionObjectType = function () { var cnd = this.getCurrentCondition(); return cnd.type; }; Runtime.prototype.isCurrentConditionFirst = function () { var evinfo = this.getCurrentEventStack(); return evinfo.cndindex === 0; }; Runtime.prototype.getCurrentAction = function () { var evinfo = this.getCurrentEventStack(); return evinfo.current_event.actions[evinfo.actindex]; }; Runtime.prototype.pushLocalVarStack = function () { this.localvar_stack_index++; if (this.localvar_stack_index >= this.localvar_stack.length) this.localvar_stack.push([]); }; Runtime.prototype.popLocalVarStack = function () { ; this.localvar_stack_index--; }; Runtime.prototype.getCurrentLocalVarStack = function () { return this.localvar_stack[this.localvar_stack_index]; }; Runtime.prototype.pushEventStack = function (cur_event) { this.event_stack_index++; if (this.event_stack_index >= this.event_stack.length) this.event_stack.push(new cr.eventStackFrame()); var ret = this.getCurrentEventStack(); ret.reset(cur_event); return ret; }; Runtime.prototype.popEventStack = function () { ; this.event_stack_index--; }; Runtime.prototype.getCurrentEventStack = function () { return this.event_stack[this.event_stack_index]; }; Runtime.prototype.pushLoopStack = function (name_) { this.loop_stack_index++; if (this.loop_stack_index >= this.loop_stack.length) { this.loop_stack.push(cr.seal({ name: name_, index: 0, stopped: false })); } var ret = this.getCurrentLoop(); ret.name = name_; ret.index = 0; ret.stopped = false; return ret; }; Runtime.prototype.popLoopStack = function () { ; this.loop_stack_index--; }; Runtime.prototype.getCurrentLoop = function () { return this.loop_stack[this.loop_stack_index]; }; Runtime.prototype.getEventVariableByName = function (name, scope) { var i, leni, j, lenj, sheet, e; while (scope) { for (i = 0, leni = scope.subevents.length; i < leni; i++) { e = scope.subevents[i]; if (e instanceof cr.eventvariable && cr.equals_nocase(name, e.name)) return e; } scope = scope.parent; } for (i = 0, leni = this.eventsheets_by_index.length; i < leni; i++) { sheet = this.eventsheets_by_index[i]; for (j = 0, lenj = sheet.events.length; j < lenj; j++) { e = sheet.events[j]; if (e instanceof cr.eventvariable && cr.equals_nocase(name, e.name)) return e; } } return null; }; Runtime.prototype.getLayoutBySid = function (sid_) { var i, len; for (i = 0, len = this.layouts_by_index.length; i < len; i++) { if (this.layouts_by_index[i].sid === sid_) return this.layouts_by_index[i]; } return null; }; Runtime.prototype.getObjectTypeBySid = function (sid_) { var i, len; for (i = 0, len = this.types_by_index.length; i < len; i++) { if (this.types_by_index[i].sid === sid_) return this.types_by_index[i]; } return null; }; Runtime.prototype.getGroupBySid = function (sid_) { var i, len; for (i = 0, len = this.allGroups.length; i < len; i++) { if (this.allGroups[i].sid === sid_) return this.allGroups[i]; } return null; }; Runtime.prototype.doCanvasSnapshot = function (format_, quality_) { this.snapshotCanvas = [format_, quality_]; this.redraw = true; // force redraw so snapshot is always taken }; function IsIndexedDBAvailable() { try { return !!window.indexedDB; } catch (e) { return false; } }; function makeSaveDb(e) { var db = e.target.result; db.createObjectStore("saves", { keyPath: "slot" }); }; function IndexedDB_WriteSlot(slot_, data_, oncomplete_, onerror_) { try { var request = indexedDB.open("_C2SaveStates"); request.onupgradeneeded = makeSaveDb; request.onerror = onerror_; request.onsuccess = function (e) { var db = e.target.result; db.onerror = onerror_; var transaction = db.transaction(["saves"], "readwrite"); var objectStore = transaction.objectStore("saves"); var putReq = objectStore.put({"slot": slot_, "data": data_ }); putReq.onsuccess = oncomplete_; }; } catch (err) { onerror_(err); } }; function IndexedDB_ReadSlot(slot_, oncomplete_, onerror_) { try { var request = indexedDB.open("_C2SaveStates"); request.onupgradeneeded = makeSaveDb; request.onerror = onerror_; request.onsuccess = function (e) { var db = e.target.result; db.onerror = onerror_; var transaction = db.transaction(["saves"]); var objectStore = transaction.objectStore("saves"); var readReq = objectStore.get(slot_); readReq.onsuccess = function (e) { if (readReq.result) oncomplete_(readReq.result["data"]); else oncomplete_(null); }; }; } catch (err) { onerror_(err); } }; Runtime.prototype.signalContinuousPreview = function () { this.signalledContinuousPreview = true; }; function doContinuousPreviewReload() { cr.logexport("Reloading for continuous preview"); if (!!window["c2cocoonjs"]) { CocoonJS["App"]["reload"](); } else { if (window.location.search.indexOf("continuous") > -1) window.location.reload(true); else window.location = window.location + "?continuous"; } }; Runtime.prototype.handleSaveLoad = function () { var self = this; var savingToSlot = this.saveToSlot; var savingJson = this.lastSaveJson; var loadingFromSlot = this.loadFromSlot; var continuous = false; if (this.signalledContinuousPreview) { continuous = true; savingToSlot = "__c2_continuouspreview"; this.signalledContinuousPreview = false; } if (savingToSlot.length) { this.ClearDeathRow(); savingJson = this.saveToJSONString(); if (IsIndexedDBAvailable() && !this.isCocoonJs) { IndexedDB_WriteSlot(savingToSlot, savingJson, function () { cr.logexport("Saved state to IndexedDB storage (" + savingJson.length + " bytes)"); self.lastSaveJson = savingJson; self.trigger(cr.system_object.prototype.cnds.OnSaveComplete, null); self.lastSaveJson = ""; if (continuous) doContinuousPreviewReload(); }, function (e) { try { localStorage.setItem("__c2save_" + savingToSlot, savingJson); cr.logexport("Saved state to WebStorage (" + savingJson.length + " bytes)"); self.lastSaveJson = savingJson; self.trigger(cr.system_object.prototype.cnds.OnSaveComplete, null); self.lastSaveJson = ""; if (continuous) doContinuousPreviewReload(); } catch (f) { cr.logexport("Failed to save game state: " + e + "; " + f); self.trigger(cr.system_object.prototype.cnds.OnSaveFailed, null); } }); } else { try { localStorage.setItem("__c2save_" + savingToSlot, savingJson); cr.logexport("Saved state to WebStorage (" + savingJson.length + " bytes)"); self.lastSaveJson = savingJson; this.trigger(cr.system_object.prototype.cnds.OnSaveComplete, null); self.lastSaveJson = ""; if (continuous) doContinuousPreviewReload(); } catch (e) { cr.logexport("Error saving to WebStorage: " + e); self.trigger(cr.system_object.prototype.cnds.OnSaveFailed, null); } } this.saveToSlot = ""; this.loadFromSlot = ""; this.loadFromJson = null; } if (loadingFromSlot.length) { if (IsIndexedDBAvailable() && !this.isCocoonJs) { IndexedDB_ReadSlot(loadingFromSlot, function (result_) { if (result_) { self.loadFromJson = result_; cr.logexport("Loaded state from IndexedDB storage (" + self.loadFromJson.length + " bytes)"); } else { self.loadFromJson = localStorage.getItem("__c2save_" + loadingFromSlot) || ""; cr.logexport("Loaded state from WebStorage (" + self.loadFromJson.length + " bytes)"); } self.suspendDrawing = false; if (!self.loadFromJson) { self.loadFromJson = null; self.trigger(cr.system_object.prototype.cnds.OnLoadFailed, null); } }, function (e) { self.loadFromJson = localStorage.getItem("__c2save_" + loadingFromSlot) || ""; cr.logexport("Loaded state from WebStorage (" + self.loadFromJson.length + " bytes)"); self.suspendDrawing = false; if (!self.loadFromJson) { self.loadFromJson = null; self.trigger(cr.system_object.prototype.cnds.OnLoadFailed, null); } }); } else { try { this.loadFromJson = localStorage.getItem("__c2save_" + loadingFromSlot) || ""; cr.logexport("Loaded state from WebStorage (" + this.loadFromJson.length + " bytes)"); } catch (e) { this.loadFromJson = null; } this.suspendDrawing = false; if (!self.loadFromJson) { self.loadFromJson = null; self.trigger(cr.system_object.prototype.cnds.OnLoadFailed, null); } } this.loadFromSlot = ""; this.saveToSlot = ""; } if (this.loadFromJson !== null) { this.ClearDeathRow(); var ok = this.loadFromJSONString(this.loadFromJson); if (ok) { this.lastSaveJson = this.loadFromJson; this.trigger(cr.system_object.prototype.cnds.OnLoadComplete, null); this.lastSaveJson = ""; } else { self.trigger(cr.system_object.prototype.cnds.OnLoadFailed, null); } this.loadFromJson = null; } }; function CopyExtraObject(extra) { var p, ret = {}; for (p in extra) { if (extra.hasOwnProperty(p)) { if (extra[p] instanceof cr.ObjectSet) continue; if (extra[p] && typeof extra[p].c2userdata !== "undefined") continue; if (p === "spriteCreatedDestroyCallback") continue; ret[p] = extra[p]; } } return ret; }; Runtime.prototype.saveToJSONString = function() { var i, len, j, lenj, type, layout, typeobj, g, c, a, v, p; var o = { "c2save": true, "version": 1, "rt": { "time": this.kahanTime.sum, "walltime": this.wallTime.sum, "timescale": this.timescale, "tickcount": this.tickcount, "execcount": this.execcount, "next_uid": this.next_uid, "running_layout": this.running_layout.sid, "start_time_offset": (Date.now() - this.start_time) }, "types": {}, "layouts": {}, "events": { "groups": {}, "cnds": {}, "acts": {}, "vars": {} } }; for (i = 0, len = this.types_by_index.length; i < len; i++) { type = this.types_by_index[i]; if (type.is_family || this.typeHasNoSaveBehavior(type)) continue; typeobj = { "instances": [] }; if (cr.hasAnyOwnProperty(type.extra)) typeobj["ex"] = CopyExtraObject(type.extra); for (j = 0, lenj = type.instances.length; j < lenj; j++) { typeobj["instances"].push(this.saveInstanceToJSON(type.instances[j])); } o["types"][type.sid.toString()] = typeobj; } for (i = 0, len = this.layouts_by_index.length; i < len; i++) { layout = this.layouts_by_index[i]; o["layouts"][layout.sid.toString()] = layout.saveToJSON(); } var ogroups = o["events"]["groups"]; for (i = 0, len = this.allGroups.length; i < len; i++) { g = this.allGroups[i]; ogroups[g.sid.toString()] = this.groups_by_name[g.group_name].group_active; } var ocnds = o["events"]["cnds"]; for (p in this.cndsBySid) { if (this.cndsBySid.hasOwnProperty(p)) { c = this.cndsBySid[p]; if (cr.hasAnyOwnProperty(c.extra)) ocnds[p] = { "ex": CopyExtraObject(c.extra) }; } } var oacts = o["events"]["acts"]; for (p in this.actsBySid) { if (this.actsBySid.hasOwnProperty(p)) { a = this.actsBySid[p]; if (cr.hasAnyOwnProperty(a.extra)) oacts[p] = { "ex": CopyExtraObject(a.extra) }; } } var ovars = o["events"]["vars"]; for (p in this.varsBySid) { if (this.varsBySid.hasOwnProperty(p)) { v = this.varsBySid[p]; if (!v.is_constant && (!v.parent || v.is_static)) ovars[p] = v.data; } } o["system"] = this.system.saveToJSON(); return JSON.stringify(o); }; Runtime.prototype.refreshUidMap = function () { var i, len, type, j, lenj, inst; this.objectsByUid = {}; for (i = 0, len = this.types_by_index.length; i < len; i++) { type = this.types_by_index[i]; if (type.is_family) continue; for (j = 0, lenj = type.instances.length; j < lenj; j++) { inst = type.instances[j]; this.objectsByUid[inst.uid.toString()] = inst; } } }; Runtime.prototype.loadFromJSONString = function (str) { var o; try { o = JSON.parse(str); } catch (e) { return false; } if (!o["c2save"]) return false; // probably not a c2 save state if (o["version"] > 1) return false; // from future version of c2; assume not compatible this.isLoadingState = true; var rt = o["rt"]; this.kahanTime.reset(); this.kahanTime.sum = rt["time"]; this.wallTime.reset(); this.wallTime.sum = rt["walltime"] || 0; this.timescale = rt["timescale"]; this.tickcount = rt["tickcount"]; this.execcount = rt["execcount"]; this.start_time = Date.now() - rt["start_time_offset"]; var layout_sid = rt["running_layout"]; if (layout_sid !== this.running_layout.sid) { var changeToLayout = this.getLayoutBySid(layout_sid); if (changeToLayout) this.doChangeLayout(changeToLayout); else return; // layout that was saved on has gone missing (deleted?) } var i, len, j, lenj, k, lenk, p, type, existing_insts, load_insts, inst, binst, layout, layer, g, iid, t; var otypes = o["types"]; for (p in otypes) { if (otypes.hasOwnProperty(p)) { type = this.getObjectTypeBySid(parseInt(p, 10)); if (!type || type.is_family || this.typeHasNoSaveBehavior(type)) continue; if (otypes[p]["ex"]) type.extra = otypes[p]["ex"]; else cr.wipe(type.extra); existing_insts = type.instances; load_insts = otypes[p]["instances"]; for (i = 0, len = cr.min(existing_insts.length, load_insts.length); i < len; i++) { this.loadInstanceFromJSON(existing_insts[i], load_insts[i]); } for (i = load_insts.length, len = existing_insts.length; i < len; i++) this.DestroyInstance(existing_insts[i]); for (i = existing_insts.length, len = load_insts.length; i < len; i++) { layer = null; if (type.plugin.is_world) { layer = this.running_layout.getLayerBySid(load_insts[i]["w"]["l"]); if (!layer) continue; } inst = this.createInstanceFromInit(type.default_instance, layer, false, 0, 0, true); this.loadInstanceFromJSON(inst, load_insts[i]); } type.stale_iids = true; } } this.ClearDeathRow(); this.refreshUidMap(); var olayouts = o["layouts"]; for (p in olayouts) { if (olayouts.hasOwnProperty(p)) { layout = this.getLayoutBySid(parseInt(p, 10)); if (!layout) continue; // must've gone missing layout.loadFromJSON(olayouts[p]); } } var ogroups = o["events"]["groups"]; for (p in ogroups) { if (ogroups.hasOwnProperty(p)) { g = this.getGroupBySid(parseInt(p, 10)); if (g && this.groups_by_name[g.group_name]) this.groups_by_name[g.group_name].setGroupActive(ogroups[p]); } } var ocnds = o["events"]["cnds"]; for (p in this.cndsBySid) { if (this.cndsBySid.hasOwnProperty(p)) { if (ocnds.hasOwnProperty(p)) { this.cndsBySid[p].extra = ocnds[p]["ex"]; } else { this.cndsBySid[p].extra = {}; } } } var oacts = o["events"]["acts"]; for (p in this.actsBySid) { if (this.actsBySid.hasOwnProperty(p)) { if (oacts.hasOwnProperty(p)) { this.actsBySid[p].extra = oacts[p]["ex"]; } else { this.actsBySid[p].extra = {}; } } } var ovars = o["events"]["vars"]; for (p in ovars) { if (ovars.hasOwnProperty(p) && this.varsBySid.hasOwnProperty(p)) { this.varsBySid[p].data = ovars[p]; } } this.next_uid = rt["next_uid"]; this.isLoadingState = false; for (i = 0, len = this.fireOnCreateAfterLoad.length; i < len; ++i) { inst = this.fireOnCreateAfterLoad[i]; this.trigger(Object.getPrototypeOf(inst.type.plugin).cnds.OnCreated, inst); } cr.clearArray(this.fireOnCreateAfterLoad); this.system.loadFromJSON(o["system"]); for (i = 0, len = this.types_by_index.length; i < len; i++) { type = this.types_by_index[i]; if (type.is_family || this.typeHasNoSaveBehavior(type)) continue; for (j = 0, lenj = type.instances.length; j < lenj; j++) { inst = type.instances[j]; if (type.is_contained) { iid = inst.get_iid(); cr.clearArray(inst.siblings); for (k = 0, lenk = type.container.length; k < lenk; k++) { t = type.container[k]; if (type === t) continue; ; inst.siblings.push(t.instances[iid]); } } if (inst.afterLoad) inst.afterLoad(); if (inst.behavior_insts) { for (k = 0, lenk = inst.behavior_insts.length; k < lenk; k++) { binst = inst.behavior_insts[k]; if (binst.afterLoad) binst.afterLoad(); } } } } this.redraw = true; return true; }; Runtime.prototype.saveInstanceToJSON = function(inst, state_only) { var i, len, world, behinst, et; var type = inst.type; var plugin = type.plugin; var o = {}; if (state_only) o["c2"] = true; // mark as known json data from Construct 2 else o["uid"] = inst.uid; if (cr.hasAnyOwnProperty(inst.extra)) o["ex"] = CopyExtraObject(inst.extra); if (inst.instance_vars && inst.instance_vars.length) { o["ivs"] = {}; for (i = 0, len = inst.instance_vars.length; i < len; i++) { o["ivs"][inst.type.instvar_sids[i].toString()] = inst.instance_vars[i]; } } if (plugin.is_world) { world = { "x": inst.x, "y": inst.y, "w": inst.width, "h": inst.height, "l": inst.layer.sid, "zi": inst.get_zindex() }; if (inst.angle !== 0) world["a"] = inst.angle; if (inst.opacity !== 1) world["o"] = inst.opacity; if (inst.hotspotX !== 0.5) world["hX"] = inst.hotspotX; if (inst.hotspotY !== 0.5) world["hY"] = inst.hotspotY; if (inst.blend_mode !== 0) world["bm"] = inst.blend_mode; if (!inst.visible) world["v"] = inst.visible; if (!inst.collisionsEnabled) world["ce"] = inst.collisionsEnabled; if (inst.my_timescale !== -1) world["mts"] = inst.my_timescale; if (type.effect_types.length) { world["fx"] = []; for (i = 0, len = type.effect_types.length; i < len; i++) { et = type.effect_types[i]; world["fx"].push({"name": et.name, "active": inst.active_effect_flags[et.index], "params": inst.effect_params[et.index] }); } } o["w"] = world; } if (inst.behavior_insts && inst.behavior_insts.length) { o["behs"] = {}; for (i = 0, len = inst.behavior_insts.length; i < len; i++) { behinst = inst.behavior_insts[i]; if (behinst.saveToJSON) o["behs"][behinst.type.sid.toString()] = behinst.saveToJSON(); } } if (inst.saveToJSON) o["data"] = inst.saveToJSON(); return o; }; Runtime.prototype.getInstanceVarIndexBySid = function (type, sid_) { var i, len; for (i = 0, len = type.instvar_sids.length; i < len; i++) { if (type.instvar_sids[i] === sid_) return i; } return -1; }; Runtime.prototype.getBehaviorIndexBySid = function (inst, sid_) { var i, len; for (i = 0, len = inst.behavior_insts.length; i < len; i++) { if (inst.behavior_insts[i].type.sid === sid_) return i; } return -1; }; Runtime.prototype.loadInstanceFromJSON = function(inst, o, state_only) { var p, i, len, iv, oivs, world, fxindex, obehs, behindex, value; var oldlayer; var type = inst.type; var plugin = type.plugin; if (state_only) { if (!o["c2"]) return; } else inst.uid = o["uid"]; if (o["ex"]) inst.extra = o["ex"]; else cr.wipe(inst.extra); oivs = o["ivs"]; if (oivs) { for (p in oivs) { if (oivs.hasOwnProperty(p)) { iv = this.getInstanceVarIndexBySid(type, parseInt(p, 10)); if (iv < 0 || iv >= inst.instance_vars.length) continue; // must've gone missing value = oivs[p]; if (value === null) value = NaN; inst.instance_vars[iv] = value; } } } if (plugin.is_world) { world = o["w"]; if (inst.layer.sid !== world["l"]) { oldlayer = inst.layer; inst.layer = this.running_layout.getLayerBySid(world["l"]); if (inst.layer) { oldlayer.removeFromInstanceList(inst, true); inst.layer.appendToInstanceList(inst, true); inst.set_bbox_changed(); inst.layer.setZIndicesStaleFrom(0); } else { inst.layer = oldlayer; if (!state_only) this.DestroyInstance(inst); } } inst.x = world["x"]; inst.y = world["y"]; inst.width = world["w"]; inst.height = world["h"]; inst.zindex = world["zi"]; inst.angle = world.hasOwnProperty("a") ? world["a"] : 0; inst.opacity = world.hasOwnProperty("o") ? world["o"] : 1; inst.hotspotX = world.hasOwnProperty("hX") ? world["hX"] : 0.5; inst.hotspotY = world.hasOwnProperty("hY") ? world["hY"] : 0.5; inst.visible = world.hasOwnProperty("v") ? world["v"] : true; inst.collisionsEnabled = world.hasOwnProperty("ce") ? world["ce"] : true; inst.my_timescale = world.hasOwnProperty("mts") ? world["mts"] : -1; inst.blend_mode = world.hasOwnProperty("bm") ? world["bm"] : 0;; inst.compositeOp = cr.effectToCompositeOp(inst.blend_mode); if (this.gl) cr.setGLBlend(inst, inst.blend_mode, this.gl); inst.set_bbox_changed(); if (world.hasOwnProperty("fx")) { for (i = 0, len = world["fx"].length; i < len; i++) { fxindex = type.getEffectIndexByName(world["fx"][i]["name"]); if (fxindex < 0) continue; // must've gone missing inst.active_effect_flags[fxindex] = world["fx"][i]["active"]; inst.effect_params[fxindex] = world["fx"][i]["params"]; } } inst.updateActiveEffects(); } obehs = o["behs"]; if (obehs) { for (p in obehs) { if (obehs.hasOwnProperty(p)) { behindex = this.getBehaviorIndexBySid(inst, parseInt(p, 10)); if (behindex < 0) continue; // must've gone missing inst.behavior_insts[behindex].loadFromJSON(obehs[p]); } } } if (o["data"]) inst.loadFromJSON(o["data"]); }; Runtime.prototype.fetchLocalFileViaCordova = function (filename, successCallback, errorCallback) { var path = cordova["file"]["applicationDirectory"] + "www/" + filename; window["resolveLocalFileSystemURL"](path, function (entry) { entry.file(successCallback, errorCallback); }, errorCallback); }; Runtime.prototype.fetchLocalFileViaCordovaAsText = function (filename, successCallback, errorCallback) { this.fetchLocalFileViaCordova(filename, function (file) { var reader = new FileReader(); reader.onload = function (e) { successCallback(e.target.result); }; reader.onerror = errorCallback; reader.readAsText(file); }, errorCallback); }; var queuedArrayBufferReads = []; var activeArrayBufferReads = 0; var MAX_ARRAYBUFFER_READS = 8; Runtime.prototype.maybeStartNextArrayBufferRead = function() { if (!queuedArrayBufferReads.length) return; // none left if (activeArrayBufferReads >= MAX_ARRAYBUFFER_READS) return; // already got maximum number in-flight activeArrayBufferReads++; var job = queuedArrayBufferReads.shift(); this.doFetchLocalFileViaCordovaAsArrayBuffer(job.filename, job.successCallback, job.errorCallback); }; Runtime.prototype.fetchLocalFileViaCordovaAsArrayBuffer = function (filename, successCallback_, errorCallback_) { var self = this; queuedArrayBufferReads.push({ filename: filename, successCallback: function (result) { activeArrayBufferReads--; self.maybeStartNextArrayBufferRead(); successCallback_(result); }, errorCallback: function (err) { activeArrayBufferReads--; self.maybeStartNextArrayBufferRead(); errorCallback_(err); } }); this.maybeStartNextArrayBufferRead(); }; Runtime.prototype.doFetchLocalFileViaCordovaAsArrayBuffer = function (filename, successCallback, errorCallback) { this.fetchLocalFileViaCordova(filename, function (file) { var reader = new FileReader(); reader.onload = function (e) { successCallback(e.target.result); }; reader.readAsArrayBuffer(file); }, errorCallback); }; Runtime.prototype.fetchLocalFileViaCordovaAsURL = function (filename, successCallback, errorCallback) { var blobType = ""; var lowername = filename.toLowerCase(); var ext3 = lowername.substr(lowername.length - 4); var ext4 = lowername.substr(lowername.length - 5); if (ext3 === ".mp4") blobType = "video/mp4"; else if (ext4 === ".webm") blobType = "video/webm"; // use video type but hopefully works with audio too else if (ext3 === ".m4a") blobType = "audio/mp4"; else if (ext3 === ".mp3") blobType = "audio/mpeg"; this.fetchLocalFileViaCordovaAsArrayBuffer(filename, function (arrayBuffer) { var blob = new Blob([arrayBuffer], { type: blobType }); var url = URL.createObjectURL(blob); successCallback(url); }, errorCallback); }; Runtime.prototype.isAbsoluteUrl = function (url) { return /^(?:[a-z]+:)?\/\//.test(url) || url.substr(0, 5) === "data:" || url.substr(0, 5) === "blob:"; }; Runtime.prototype.setImageSrc = function (img, src) { if (this.isWKWebView && !this.isAbsoluteUrl(src)) { this.fetchLocalFileViaCordovaAsURL(src, function (url) { img.src = url; }, function (err) { alert("Failed to load image: " + err); }); } else { img.src = src; } }; Runtime.prototype.setCtxImageSmoothingEnabled = function (ctx, e) { if (typeof ctx["imageSmoothingEnabled"] !== "undefined") { ctx["imageSmoothingEnabled"] = e; } else { ctx["webkitImageSmoothingEnabled"] = e; ctx["mozImageSmoothingEnabled"] = e; ctx["msImageSmoothingEnabled"] = e; } }; cr.runtime = Runtime; cr.createRuntime = function (canvasid) { return new Runtime(document.getElementById(canvasid)); }; cr.createDCRuntime = function (w, h) { return new Runtime({ "dc": true, "width": w, "height": h }); }; window["cr_createRuntime"] = cr.createRuntime; window["cr_createDCRuntime"] = cr.createDCRuntime; window["createCocoonJSRuntime"] = function () { window["c2cocoonjs"] = true; var canvas = document.createElement("screencanvas") || document.createElement("canvas"); canvas.screencanvas = true; document.body.appendChild(canvas); var rt = new Runtime(canvas); window["c2runtime"] = rt; window.addEventListener("orientationchange", function () { window["c2runtime"]["setSize"](window.innerWidth, window.innerHeight); }); window["c2runtime"]["setSize"](window.innerWidth, window.innerHeight); return rt; }; window["createEjectaRuntime"] = function () { var canvas = document.getElementById("canvas"); var rt = new Runtime(canvas); window["c2runtime"] = rt; window["c2runtime"]["setSize"](window.innerWidth, window.innerHeight); return rt; }; }()); window["cr_getC2Runtime"] = function() { var canvas = document.getElementById("c2canvas"); if (canvas) return canvas["c2runtime"]; else if (window["c2runtime"]) return window["c2runtime"]; else return null; } window["cr_getSnapshot"] = function (format_, quality_) { var runtime = window["cr_getC2Runtime"](); if (runtime) runtime.doCanvasSnapshot(format_, quality_); } window["cr_sizeCanvas"] = function(w, h) { if (w === 0 || h === 0) return; var runtime = window["cr_getC2Runtime"](); if (runtime) runtime["setSize"](w, h); } window["cr_setSuspended"] = function(s) { var runtime = window["cr_getC2Runtime"](); if (runtime) runtime["setSuspended"](s); } ; (function() { function Layout(runtime, m) { this.runtime = runtime; this.event_sheet = null; this.scrollX = (this.runtime.original_width / 2); this.scrollY = (this.runtime.original_height / 2); this.scale = 1.0; this.angle = 0; this.first_visit = true; this.name = m[0]; this.originalWidth = m[1]; this.originalHeight = m[2]; this.width = m[1]; this.height = m[2]; this.unbounded_scrolling = m[3]; this.sheetname = m[4]; this.sid = m[5]; var lm = m[6]; var i, len; this.layers = []; this.initial_types = []; for (i = 0, len = lm.length; i < len; i++) { var layer = new cr.layer(this, lm[i]); layer.number = i; cr.seal(layer); this.layers.push(layer); } var im = m[7]; this.initial_nonworld = []; for (i = 0, len = im.length; i < len; i++) { var inst = im[i]; var type = this.runtime.types_by_index[inst[1]]; ; if (!type.default_instance) type.default_instance = inst; this.initial_nonworld.push(inst); if (this.initial_types.indexOf(type) === -1) this.initial_types.push(type); } this.effect_types = []; this.active_effect_types = []; this.shaders_preserve_opaqueness = true; this.effect_params = []; for (i = 0, len = m[8].length; i < len; i++) { this.effect_types.push({ id: m[8][i][0], name: m[8][i][1], shaderindex: -1, preservesOpaqueness: false, active: true, index: i }); this.effect_params.push(m[8][i][2].slice(0)); } this.updateActiveEffects(); this.rcTex = new cr.rect(0, 0, 1, 1); this.rcTex2 = new cr.rect(0, 0, 1, 1); this.persist_data = {}; }; Layout.prototype.saveObjectToPersist = function (inst) { var sidStr = inst.type.sid.toString(); if (!this.persist_data.hasOwnProperty(sidStr)) this.persist_data[sidStr] = []; var type_persist = this.persist_data[sidStr]; type_persist.push(this.runtime.saveInstanceToJSON(inst)); }; Layout.prototype.hasOpaqueBottomLayer = function () { var layer = this.layers[0]; return !layer.transparent && layer.opacity === 1.0 && !layer.forceOwnTexture && layer.visible; }; Layout.prototype.updateActiveEffects = function () { cr.clearArray(this.active_effect_types); this.shaders_preserve_opaqueness = true; var i, len, et; for (i = 0, len = this.effect_types.length; i < len; i++) { et = this.effect_types[i]; if (et.active) { this.active_effect_types.push(et); if (!et.preservesOpaqueness) this.shaders_preserve_opaqueness = false; } } }; Layout.prototype.getEffectByName = function (name_) { var i, len, et; for (i = 0, len = this.effect_types.length; i < len; i++) { et = this.effect_types[i]; if (et.name === name_) return et; } return null; }; var created_instances = []; function sort_by_zindex(a, b) { return a.zindex - b.zindex; }; var first_layout = true; Layout.prototype.startRunning = function () { if (this.sheetname) { this.event_sheet = this.runtime.eventsheets[this.sheetname]; ; this.event_sheet.updateDeepIncludes(); } this.runtime.running_layout = this; this.width = this.originalWidth; this.height = this.originalHeight; this.scrollX = (this.runtime.original_width / 2); this.scrollY = (this.runtime.original_height / 2); var i, k, len, lenk, type, type_instances, initial_inst, inst, iid, t, s, p, q, type_data, layer; for (i = 0, len = this.runtime.types_by_index.length; i < len; i++) { type = this.runtime.types_by_index[i]; if (type.is_family) continue; // instances are only transferred for their real type type_instances = type.instances; for (k = 0, lenk = type_instances.length; k < lenk; k++) { inst = type_instances[k]; if (inst.layer) { var num = inst.layer.number; if (num >= this.layers.length) num = this.layers.length - 1; inst.layer = this.layers[num]; if (inst.layer.instances.indexOf(inst) === -1) inst.layer.instances.push(inst); inst.layer.zindices_stale = true; } } } if (!first_layout) { for (i = 0, len = this.layers.length; i < len; ++i) { this.layers[i].instances.sort(sort_by_zindex); } } var layer; cr.clearArray(created_instances); this.boundScrolling(); for (i = 0, len = this.layers.length; i < len; i++) { layer = this.layers[i]; layer.createInitialInstances(); // fills created_instances layer.updateViewport(null); } var uids_changed = false; if (!this.first_visit) { for (p in this.persist_data) { if (this.persist_data.hasOwnProperty(p)) { type = this.runtime.getObjectTypeBySid(parseInt(p, 10)); if (!type || type.is_family || !this.runtime.typeHasPersistBehavior(type)) continue; type_data = this.persist_data[p]; for (i = 0, len = type_data.length; i < len; i++) { layer = null; if (type.plugin.is_world) { layer = this.getLayerBySid(type_data[i]["w"]["l"]); if (!layer) continue; } inst = this.runtime.createInstanceFromInit(type.default_instance, layer, false, 0, 0, true); this.runtime.loadInstanceFromJSON(inst, type_data[i]); uids_changed = true; created_instances.push(inst); } cr.clearArray(type_data); } } for (i = 0, len = this.layers.length; i < len; i++) { this.layers[i].instances.sort(sort_by_zindex); this.layers[i].zindices_stale = true; // in case of duplicates/holes } } if (uids_changed) { this.runtime.ClearDeathRow(); this.runtime.refreshUidMap(); } for (i = 0; i < created_instances.length; i++) { inst = created_instances[i]; if (!inst.type.is_contained) continue; iid = inst.get_iid(); for (k = 0, lenk = inst.type.container.length; k < lenk; k++) { t = inst.type.container[k]; if (inst.type === t) continue; if (t.instances.length > iid) inst.siblings.push(t.instances[iid]); else { if (!t.default_instance) { } else { s = this.runtime.createInstanceFromInit(t.default_instance, inst.layer, true, inst.x, inst.y, true); this.runtime.ClearDeathRow(); t.updateIIDs(); inst.siblings.push(s); created_instances.push(s); // come back around and link up its own instances too } } } } for (i = 0, len = this.initial_nonworld.length; i < len; i++) { initial_inst = this.initial_nonworld[i]; type = this.runtime.types_by_index[initial_inst[1]]; if (!type.is_contained) { inst = this.runtime.createInstanceFromInit(this.initial_nonworld[i], null, true); } ; } this.runtime.changelayout = null; this.runtime.ClearDeathRow(); if (this.runtime.ctx && !this.runtime.isDomFree) { for (i = 0, len = this.runtime.types_by_index.length; i < len; i++) { t = this.runtime.types_by_index[i]; if (t.is_family || !t.instances.length || !t.preloadCanvas2D) continue; t.preloadCanvas2D(this.runtime.ctx); } } /* if (this.runtime.glwrap) { console.log("Estimated VRAM at layout start: " + this.runtime.glwrap.textureCount() + " textures, approx. " + Math.round(this.runtime.glwrap.estimateVRAM() / 1024) + " kb"); } */ if (this.runtime.isLoadingState) { cr.shallowAssignArray(this.runtime.fireOnCreateAfterLoad, created_instances); } else { for (i = 0, len = created_instances.length; i < len; i++) { inst = created_instances[i]; this.runtime.trigger(Object.getPrototypeOf(inst.type.plugin).cnds.OnCreated, inst); } } cr.clearArray(created_instances); if (!this.runtime.isLoadingState) { this.runtime.trigger(cr.system_object.prototype.cnds.OnLayoutStart, null); } this.first_visit = false; }; Layout.prototype.createGlobalNonWorlds = function () { var i, k, len, initial_inst, inst, type; for (i = 0, k = 0, len = this.initial_nonworld.length; i < len; i++) { initial_inst = this.initial_nonworld[i]; type = this.runtime.types_by_index[initial_inst[1]]; if (type.global) { if (!type.is_contained) { inst = this.runtime.createInstanceFromInit(initial_inst, null, true); } } else { this.initial_nonworld[k] = initial_inst; k++; } } cr.truncateArray(this.initial_nonworld, k); }; Layout.prototype.stopRunning = function () { ; /* if (this.runtime.glwrap) { console.log("Estimated VRAM at layout end: " + this.runtime.glwrap.textureCount() + " textures, approx. " + Math.round(this.runtime.glwrap.estimateVRAM() / 1024) + " kb"); } */ if (!this.runtime.isLoadingState) { this.runtime.trigger(cr.system_object.prototype.cnds.OnLayoutEnd, null); } this.runtime.isEndingLayout = true; cr.clearArray(this.runtime.system.waits); var i, leni, j, lenj; var layer_instances, inst, type; if (!this.first_visit) { for (i = 0, leni = this.layers.length; i < leni; i++) { this.layers[i].updateZIndices(); layer_instances = this.layers[i].instances; for (j = 0, lenj = layer_instances.length; j < lenj; j++) { inst = layer_instances[j]; if (!inst.type.global) { if (this.runtime.typeHasPersistBehavior(inst.type)) this.saveObjectToPersist(inst); } } } } for (i = 0, leni = this.layers.length; i < leni; i++) { layer_instances = this.layers[i].instances; for (j = 0, lenj = layer_instances.length; j < lenj; j++) { inst = layer_instances[j]; if (!inst.type.global) { this.runtime.DestroyInstance(inst); } } this.runtime.ClearDeathRow(); cr.clearArray(layer_instances); this.layers[i].zindices_stale = true; } for (i = 0, leni = this.runtime.types_by_index.length; i < leni; i++) { type = this.runtime.types_by_index[i]; if (type.global || type.plugin.is_world || type.plugin.singleglobal || type.is_family) continue; for (j = 0, lenj = type.instances.length; j < lenj; j++) this.runtime.DestroyInstance(type.instances[j]); this.runtime.ClearDeathRow(); } first_layout = false; this.runtime.isEndingLayout = false; }; var temp_rect = new cr.rect(0, 0, 0, 0); Layout.prototype.recreateInitialObjects = function (type, x1, y1, x2, y2) { temp_rect.set(x1, y1, x2, y2); var i, len; for (i = 0, len = this.layers.length; i < len; i++) { this.layers[i].recreateInitialObjects(type, temp_rect); } }; Layout.prototype.draw = function (ctx) { var layout_canvas; var layout_ctx = ctx; var ctx_changed = false; var render_offscreen = !this.runtime.fullscreenScalingQuality; if (render_offscreen) { if (!this.runtime.layout_canvas) { this.runtime.layout_canvas = document.createElement("canvas"); layout_canvas = this.runtime.layout_canvas; layout_canvas.width = this.runtime.draw_width; layout_canvas.height = this.runtime.draw_height; this.runtime.layout_ctx = layout_canvas.getContext("2d"); ctx_changed = true; } layout_canvas = this.runtime.layout_canvas; layout_ctx = this.runtime.layout_ctx; if (layout_canvas.width !== this.runtime.draw_width) { layout_canvas.width = this.runtime.draw_width; ctx_changed = true; } if (layout_canvas.height !== this.runtime.draw_height) { layout_canvas.height = this.runtime.draw_height; ctx_changed = true; } if (ctx_changed) { this.runtime.setCtxImageSmoothingEnabled(layout_ctx, this.runtime.linearSampling); } } layout_ctx.globalAlpha = 1; layout_ctx.globalCompositeOperation = "source-over"; if (this.runtime.clearBackground && !this.hasOpaqueBottomLayer()) layout_ctx.clearRect(0, 0, this.runtime.draw_width, this.runtime.draw_height); var i, len, l; for (i = 0, len = this.layers.length; i < len; i++) { l = this.layers[i]; if (l.visible && l.opacity > 0 && l.blend_mode !== 11 && (l.instances.length || !l.transparent)) l.draw(layout_ctx); else l.updateViewport(null); // even if not drawing, keep viewport up to date } if (render_offscreen) { ctx.drawImage(layout_canvas, 0, 0, this.runtime.width, this.runtime.height); } }; Layout.prototype.drawGL_earlyZPass = function (glw) { glw.setEarlyZPass(true); if (!this.runtime.layout_tex) { this.runtime.layout_tex = glw.createEmptyTexture(this.runtime.draw_width, this.runtime.draw_height, this.runtime.linearSampling); } if (this.runtime.layout_tex.c2width !== this.runtime.draw_width || this.runtime.layout_tex.c2height !== this.runtime.draw_height) { glw.deleteTexture(this.runtime.layout_tex); this.runtime.layout_tex = glw.createEmptyTexture(this.runtime.draw_width, this.runtime.draw_height, this.runtime.linearSampling); } glw.setRenderingToTexture(this.runtime.layout_tex); if (!this.runtime.fullscreenScalingQuality) { glw.setSize(this.runtime.draw_width, this.runtime.draw_height); } var i, l; for (i = this.layers.length - 1; i >= 0; --i) { l = this.layers[i]; if (l.visible && l.opacity === 1 && l.shaders_preserve_opaqueness && l.blend_mode === 0 && (l.instances.length || !l.transparent)) { l.drawGL_earlyZPass(glw); } else { l.updateViewport(null); // even if not drawing, keep viewport up to date } } glw.setEarlyZPass(false); }; Layout.prototype.drawGL = function (glw) { var render_to_texture = (this.active_effect_types.length > 0 || this.runtime.uses_background_blending || !this.runtime.fullscreenScalingQuality || this.runtime.enableFrontToBack); if (render_to_texture) { if (!this.runtime.layout_tex) { this.runtime.layout_tex = glw.createEmptyTexture(this.runtime.draw_width, this.runtime.draw_height, this.runtime.linearSampling); } if (this.runtime.layout_tex.c2width !== this.runtime.draw_width || this.runtime.layout_tex.c2height !== this.runtime.draw_height) { glw.deleteTexture(this.runtime.layout_tex); this.runtime.layout_tex = glw.createEmptyTexture(this.runtime.draw_width, this.runtime.draw_height, this.runtime.linearSampling); } glw.setRenderingToTexture(this.runtime.layout_tex); if (!this.runtime.fullscreenScalingQuality) { glw.setSize(this.runtime.draw_width, this.runtime.draw_height); } } else { if (this.runtime.layout_tex) { glw.setRenderingToTexture(null); glw.deleteTexture(this.runtime.layout_tex); this.runtime.layout_tex = null; } } if (this.runtime.clearBackground && !this.hasOpaqueBottomLayer()) glw.clear(0, 0, 0, 0); var i, len, l; for (i = 0, len = this.layers.length; i < len; i++) { l = this.layers[i]; if (l.visible && l.opacity > 0 && (l.instances.length || !l.transparent)) l.drawGL(glw); else l.updateViewport(null); // even if not drawing, keep viewport up to date } if (render_to_texture) { if (this.active_effect_types.length === 0 || (this.active_effect_types.length === 1 && this.runtime.fullscreenScalingQuality)) { if (this.active_effect_types.length === 1) { var etindex = this.active_effect_types[0].index; glw.switchProgram(this.active_effect_types[0].shaderindex); glw.setProgramParameters(null, // backTex 1.0 / this.runtime.draw_width, // pixelWidth 1.0 / this.runtime.draw_height, // pixelHeight 0.0, 0.0, // destStart 1.0, 1.0, // destEnd this.scale, // layerScale this.angle, // layerAngle 0.0, 0.0, // viewOrigin this.runtime.draw_width / 2, this.runtime.draw_height / 2, // scrollPos this.runtime.kahanTime.sum, // seconds this.effect_params[etindex]); // fx parameters if (glw.programIsAnimated(this.active_effect_types[0].shaderindex)) this.runtime.redraw = true; } else glw.switchProgram(0); if (!this.runtime.fullscreenScalingQuality) { glw.setSize(this.runtime.width, this.runtime.height); } glw.setRenderingToTexture(null); // to backbuffer glw.setDepthTestEnabled(false); // ignore depth buffer, copy full texture glw.setOpacity(1); glw.setTexture(this.runtime.layout_tex); glw.setAlphaBlend(); glw.resetModelView(); glw.updateModelView(); var halfw = this.runtime.width / 2; var halfh = this.runtime.height / 2; glw.quad(-halfw, halfh, halfw, halfh, halfw, -halfh, -halfw, -halfh); glw.setTexture(null); glw.setDepthTestEnabled(true); // turn depth test back on } else { this.renderEffectChain(glw, null, null, null); } } }; Layout.prototype.getRenderTarget = function() { if (this.active_effect_types.length > 0 || this.runtime.uses_background_blending || !this.runtime.fullscreenScalingQuality || this.runtime.enableFrontToBack) { return this.runtime.layout_tex; } else { return null; } }; Layout.prototype.getMinLayerScale = function () { var m = this.layers[0].getScale(); var i, len, l; for (i = 1, len = this.layers.length; i < len; i++) { l = this.layers[i]; if (l.parallaxX === 0 && l.parallaxY === 0) continue; if (l.getScale() < m) m = l.getScale(); } return m; }; Layout.prototype.scrollToX = function (x) { if (!this.unbounded_scrolling) { var widthBoundary = (this.runtime.draw_width * (1 / this.getMinLayerScale()) / 2); if (x > this.width - widthBoundary) x = this.width - widthBoundary; if (x < widthBoundary) x = widthBoundary; } if (this.scrollX !== x) { this.scrollX = x; this.runtime.redraw = true; } }; Layout.prototype.scrollToY = function (y) { if (!this.unbounded_scrolling) { var heightBoundary = (this.runtime.draw_height * (1 / this.getMinLayerScale()) / 2); if (y > this.height - heightBoundary) y = this.height - heightBoundary; if (y < heightBoundary) y = heightBoundary; } if (this.scrollY !== y) { this.scrollY = y; this.runtime.redraw = true; } }; Layout.prototype.boundScrolling = function () { this.scrollToX(this.scrollX); this.scrollToY(this.scrollY); }; Layout.prototype.renderEffectChain = function (glw, layer, inst, rendertarget) { var active_effect_types = inst ? inst.active_effect_types : layer ? layer.active_effect_types : this.active_effect_types; var layerScale = 1, layerAngle = 0, viewOriginLeft = 0, viewOriginTop = 0, viewOriginRight = this.runtime.draw_width, viewOriginBottom = this.runtime.draw_height; if (inst) { layerScale = inst.layer.getScale(); layerAngle = inst.layer.getAngle(); viewOriginLeft = inst.layer.viewLeft; viewOriginTop = inst.layer.viewTop; viewOriginRight = inst.layer.viewRight; viewOriginBottom = inst.layer.viewBottom; } else if (layer) { layerScale = layer.getScale(); layerAngle = layer.getAngle(); viewOriginLeft = layer.viewLeft; viewOriginTop = layer.viewTop; viewOriginRight = layer.viewRight; viewOriginBottom = layer.viewBottom; } var fx_tex = this.runtime.fx_tex; var i, len, last, temp, fx_index = 0, other_fx_index = 1; var y, h; var windowWidth = this.runtime.draw_width; var windowHeight = this.runtime.draw_height; var halfw = windowWidth / 2; var halfh = windowHeight / 2; var rcTex = layer ? layer.rcTex : this.rcTex; var rcTex2 = layer ? layer.rcTex2 : this.rcTex2; var screenleft = 0, clearleft = 0; var screentop = 0, cleartop = 0; var screenright = windowWidth, clearright = windowWidth; var screenbottom = windowHeight, clearbottom = windowHeight; var boxExtendHorizontal = 0; var boxExtendVertical = 0; var inst_layer_angle = inst ? inst.layer.getAngle() : 0; if (inst) { for (i = 0, len = active_effect_types.length; i < len; i++) { boxExtendHorizontal += glw.getProgramBoxExtendHorizontal(active_effect_types[i].shaderindex); boxExtendVertical += glw.getProgramBoxExtendVertical(active_effect_types[i].shaderindex); } var bbox = inst.bbox; screenleft = layer.layerToCanvas(bbox.left, bbox.top, true, true); screentop = layer.layerToCanvas(bbox.left, bbox.top, false, true); screenright = layer.layerToCanvas(bbox.right, bbox.bottom, true, true); screenbottom = layer.layerToCanvas(bbox.right, bbox.bottom, false, true); if (inst_layer_angle !== 0) { var screentrx = layer.layerToCanvas(bbox.right, bbox.top, true, true); var screentry = layer.layerToCanvas(bbox.right, bbox.top, false, true); var screenblx = layer.layerToCanvas(bbox.left, bbox.bottom, true, true); var screenbly = layer.layerToCanvas(bbox.left, bbox.bottom, false, true); temp = Math.min(screenleft, screenright, screentrx, screenblx); screenright = Math.max(screenleft, screenright, screentrx, screenblx); screenleft = temp; temp = Math.min(screentop, screenbottom, screentry, screenbly); screenbottom = Math.max(screentop, screenbottom, screentry, screenbly); screentop = temp; } screenleft -= boxExtendHorizontal; screentop -= boxExtendVertical; screenright += boxExtendHorizontal; screenbottom += boxExtendVertical; rcTex2.left = screenleft / windowWidth; rcTex2.top = 1 - screentop / windowHeight; rcTex2.right = screenright / windowWidth; rcTex2.bottom = 1 - screenbottom / windowHeight; clearleft = screenleft = cr.floor(screenleft); cleartop = screentop = cr.floor(screentop); clearright = screenright = cr.ceil(screenright); clearbottom = screenbottom = cr.ceil(screenbottom); clearleft -= boxExtendHorizontal; cleartop -= boxExtendVertical; clearright += boxExtendHorizontal; clearbottom += boxExtendVertical; if (screenleft < 0) screenleft = 0; if (screentop < 0) screentop = 0; if (screenright > windowWidth) screenright = windowWidth; if (screenbottom > windowHeight) screenbottom = windowHeight; if (clearleft < 0) clearleft = 0; if (cleartop < 0) cleartop = 0; if (clearright > windowWidth) clearright = windowWidth; if (clearbottom > windowHeight) clearbottom = windowHeight; rcTex.left = screenleft / windowWidth; rcTex.top = 1 - screentop / windowHeight; rcTex.right = screenright / windowWidth; rcTex.bottom = 1 - screenbottom / windowHeight; } else { rcTex.left = rcTex2.left = 0; rcTex.top = rcTex2.top = 0; rcTex.right = rcTex2.right = 1; rcTex.bottom = rcTex2.bottom = 1; } var pre_draw = (inst && (glw.programUsesDest(active_effect_types[0].shaderindex) || boxExtendHorizontal !== 0 || boxExtendVertical !== 0 || inst.opacity !== 1 || inst.type.plugin.must_predraw)) || (layer && !inst && layer.opacity !== 1); glw.setAlphaBlend(); if (pre_draw) { if (!fx_tex[fx_index]) { fx_tex[fx_index] = glw.createEmptyTexture(windowWidth, windowHeight, this.runtime.linearSampling); } if (fx_tex[fx_index].c2width !== windowWidth || fx_tex[fx_index].c2height !== windowHeight) { glw.deleteTexture(fx_tex[fx_index]); fx_tex[fx_index] = glw.createEmptyTexture(windowWidth, windowHeight, this.runtime.linearSampling); } glw.switchProgram(0); glw.setRenderingToTexture(fx_tex[fx_index]); h = clearbottom - cleartop; y = (windowHeight - cleartop) - h; glw.clearRect(clearleft, y, clearright - clearleft, h); if (inst) { inst.drawGL(glw); } else { glw.setTexture(this.runtime.layer_tex); glw.setOpacity(layer.opacity); glw.resetModelView(); glw.translate(-halfw, -halfh); glw.updateModelView(); glw.quadTex(screenleft, screenbottom, screenright, screenbottom, screenright, screentop, screenleft, screentop, rcTex); } rcTex2.left = rcTex2.top = 0; rcTex2.right = rcTex2.bottom = 1; if (inst) { temp = rcTex.top; rcTex.top = rcTex.bottom; rcTex.bottom = temp; } fx_index = 1; other_fx_index = 0; } glw.setOpacity(1); var last = active_effect_types.length - 1; var post_draw = glw.programUsesCrossSampling(active_effect_types[last].shaderindex) || (!layer && !inst && !this.runtime.fullscreenScalingQuality); var etindex = 0; for (i = 0, len = active_effect_types.length; i < len; i++) { if (!fx_tex[fx_index]) { fx_tex[fx_index] = glw.createEmptyTexture(windowWidth, windowHeight, this.runtime.linearSampling); } if (fx_tex[fx_index].c2width !== windowWidth || fx_tex[fx_index].c2height !== windowHeight) { glw.deleteTexture(fx_tex[fx_index]); fx_tex[fx_index] = glw.createEmptyTexture(windowWidth, windowHeight, this.runtime.linearSampling); } glw.switchProgram(active_effect_types[i].shaderindex); etindex = active_effect_types[i].index; if (glw.programIsAnimated(active_effect_types[i].shaderindex)) this.runtime.redraw = true; if (i == 0 && !pre_draw) { glw.setRenderingToTexture(fx_tex[fx_index]); h = clearbottom - cleartop; y = (windowHeight - cleartop) - h; glw.clearRect(clearleft, y, clearright - clearleft, h); if (inst) { var pixelWidth; var pixelHeight; if (inst.curFrame && inst.curFrame.texture_img) { var img = inst.curFrame.texture_img; pixelWidth = 1.0 / img.width; pixelHeight = 1.0 / img.height; } else { pixelWidth = 1.0 / inst.width; pixelHeight = 1.0 / inst.height; } glw.setProgramParameters(rendertarget, // backTex pixelWidth, pixelHeight, rcTex2.left, rcTex2.top, // destStart rcTex2.right, rcTex2.bottom, // destEnd layerScale, layerAngle, viewOriginLeft, viewOriginTop, (viewOriginLeft + viewOriginRight) / 2, (viewOriginTop + viewOriginBottom) / 2, this.runtime.kahanTime.sum, inst.effect_params[etindex]); // fx params inst.drawGL(glw); } else { glw.setProgramParameters(rendertarget, // backTex 1.0 / windowWidth, // pixelWidth 1.0 / windowHeight, // pixelHeight 0.0, 0.0, // destStart 1.0, 1.0, // destEnd layerScale, layerAngle, viewOriginLeft, viewOriginTop, (viewOriginLeft + viewOriginRight) / 2, (viewOriginTop + viewOriginBottom) / 2, this.runtime.kahanTime.sum, layer ? // fx params layer.effect_params[etindex] : this.effect_params[etindex]); glw.setTexture(layer ? this.runtime.layer_tex : this.runtime.layout_tex); glw.resetModelView(); glw.translate(-halfw, -halfh); glw.updateModelView(); glw.quadTex(screenleft, screenbottom, screenright, screenbottom, screenright, screentop, screenleft, screentop, rcTex); } rcTex2.left = rcTex2.top = 0; rcTex2.right = rcTex2.bottom = 1; if (inst && !post_draw) { temp = screenbottom; screenbottom = screentop; screentop = temp; } } else { glw.setProgramParameters(rendertarget, // backTex 1.0 / windowWidth, // pixelWidth 1.0 / windowHeight, // pixelHeight rcTex2.left, rcTex2.top, // destStart rcTex2.right, rcTex2.bottom, // destEnd layerScale, layerAngle, viewOriginLeft, viewOriginTop, (viewOriginLeft + viewOriginRight) / 2, (viewOriginTop + viewOriginBottom) / 2, this.runtime.kahanTime.sum, inst ? // fx params inst.effect_params[etindex] : layer ? layer.effect_params[etindex] : this.effect_params[etindex]); glw.setTexture(null); if (i === last && !post_draw) { if (inst) glw.setBlend(inst.srcBlend, inst.destBlend); else if (layer) glw.setBlend(layer.srcBlend, layer.destBlend); glw.setRenderingToTexture(rendertarget); } else { glw.setRenderingToTexture(fx_tex[fx_index]); h = clearbottom - cleartop; y = (windowHeight - cleartop) - h; glw.clearRect(clearleft, y, clearright - clearleft, h); } glw.setTexture(fx_tex[other_fx_index]); glw.resetModelView(); glw.translate(-halfw, -halfh); glw.updateModelView(); glw.quadTex(screenleft, screenbottom, screenright, screenbottom, screenright, screentop, screenleft, screentop, rcTex); if (i === last && !post_draw) glw.setTexture(null); } fx_index = (fx_index === 0 ? 1 : 0); other_fx_index = (fx_index === 0 ? 1 : 0); // will be opposite to fx_index since it was just assigned } if (post_draw) { glw.switchProgram(0); if (inst) glw.setBlend(inst.srcBlend, inst.destBlend); else if (layer) glw.setBlend(layer.srcBlend, layer.destBlend); else { if (!this.runtime.fullscreenScalingQuality) { glw.setSize(this.runtime.width, this.runtime.height); halfw = this.runtime.width / 2; halfh = this.runtime.height / 2; screenleft = 0; screentop = 0; screenright = this.runtime.width; screenbottom = this.runtime.height; } } glw.setRenderingToTexture(rendertarget); glw.setTexture(fx_tex[other_fx_index]); glw.resetModelView(); glw.translate(-halfw, -halfh); glw.updateModelView(); if (inst && active_effect_types.length === 1 && !pre_draw) glw.quadTex(screenleft, screentop, screenright, screentop, screenright, screenbottom, screenleft, screenbottom, rcTex); else glw.quadTex(screenleft, screenbottom, screenright, screenbottom, screenright, screentop, screenleft, screentop, rcTex); glw.setTexture(null); } }; Layout.prototype.getLayerBySid = function (sid_) { var i, len; for (i = 0, len = this.layers.length; i < len; i++) { if (this.layers[i].sid === sid_) return this.layers[i]; } return null; }; Layout.prototype.saveToJSON = function () { var i, len, layer, et; var o = { "sx": this.scrollX, "sy": this.scrollY, "s": this.scale, "a": this.angle, "w": this.width, "h": this.height, "fv": this.first_visit, // added r127 "persist": this.persist_data, "fx": [], "layers": {} }; for (i = 0, len = this.effect_types.length; i < len; i++) { et = this.effect_types[i]; o["fx"].push({"name": et.name, "active": et.active, "params": this.effect_params[et.index] }); } for (i = 0, len = this.layers.length; i < len; i++) { layer = this.layers[i]; o["layers"][layer.sid.toString()] = layer.saveToJSON(); } return o; }; Layout.prototype.loadFromJSON = function (o) { var i, j, len, fx, p, layer; this.scrollX = o["sx"]; this.scrollY = o["sy"]; this.scale = o["s"]; this.angle = o["a"]; this.width = o["w"]; this.height = o["h"]; this.persist_data = o["persist"]; if (typeof o["fv"] !== "undefined") this.first_visit = o["fv"]; var ofx = o["fx"]; for (i = 0, len = ofx.length; i < len; i++) { fx = this.getEffectByName(ofx[i]["name"]); if (!fx) continue; // must've gone missing fx.active = ofx[i]["active"]; this.effect_params[fx.index] = ofx[i]["params"]; } this.updateActiveEffects(); var olayers = o["layers"]; for (p in olayers) { if (olayers.hasOwnProperty(p)) { layer = this.getLayerBySid(parseInt(p, 10)); if (!layer) continue; // must've gone missing layer.loadFromJSON(olayers[p]); } } }; cr.layout = Layout; function Layer(layout, m) { this.layout = layout; this.runtime = layout.runtime; this.instances = []; // running instances this.scale = 1.0; this.angle = 0; this.disableAngle = false; this.tmprect = new cr.rect(0, 0, 0, 0); this.tmpquad = new cr.quad(); this.viewLeft = 0; this.viewRight = 0; this.viewTop = 0; this.viewBottom = 0; this.zindices_stale = false; this.zindices_stale_from = -1; // first index that has changed, or -1 if no bound this.clear_earlyz_index = 0; this.name = m[0]; this.index = m[1]; this.sid = m[2]; this.visible = m[3]; // initially visible this.background_color = m[4]; this.transparent = m[5]; this.parallaxX = m[6]; this.parallaxY = m[7]; this.opacity = m[8]; this.forceOwnTexture = m[9]; this.useRenderCells = m[10]; this.zoomRate = m[11]; this.blend_mode = m[12]; this.effect_fallback = m[13]; this.compositeOp = "source-over"; this.srcBlend = 0; this.destBlend = 0; this.render_grid = null; this.last_render_list = alloc_arr(); this.render_list_stale = true; this.last_render_cells = new cr.rect(0, 0, -1, -1); this.cur_render_cells = new cr.rect(0, 0, -1, -1); if (this.useRenderCells) { this.render_grid = new cr.RenderGrid(this.runtime.original_width, this.runtime.original_height); } this.render_offscreen = false; var im = m[14]; var i, len; this.startup_initial_instances = []; // for restoring initial_instances after load this.initial_instances = []; this.created_globals = []; // global object UIDs already created - for save/load to avoid recreating for (i = 0, len = im.length; i < len; i++) { var inst = im[i]; var type = this.runtime.types_by_index[inst[1]]; ; if (!type.default_instance) { type.default_instance = inst; type.default_layerindex = this.index; } this.initial_instances.push(inst); if (this.layout.initial_types.indexOf(type) === -1) this.layout.initial_types.push(type); } cr.shallowAssignArray(this.startup_initial_instances, this.initial_instances); this.effect_types = []; this.active_effect_types = []; this.shaders_preserve_opaqueness = true; this.effect_params = []; for (i = 0, len = m[15].length; i < len; i++) { this.effect_types.push({ id: m[15][i][0], name: m[15][i][1], shaderindex: -1, preservesOpaqueness: false, active: true, index: i }); this.effect_params.push(m[15][i][2].slice(0)); } this.updateActiveEffects(); this.rcTex = new cr.rect(0, 0, 1, 1); this.rcTex2 = new cr.rect(0, 0, 1, 1); }; Layer.prototype.updateActiveEffects = function () { cr.clearArray(this.active_effect_types); this.shaders_preserve_opaqueness = true; var i, len, et; for (i = 0, len = this.effect_types.length; i < len; i++) { et = this.effect_types[i]; if (et.active) { this.active_effect_types.push(et); if (!et.preservesOpaqueness) this.shaders_preserve_opaqueness = false; } } }; Layer.prototype.getEffectByName = function (name_) { var i, len, et; for (i = 0, len = this.effect_types.length; i < len; i++) { et = this.effect_types[i]; if (et.name === name_) return et; } return null; }; Layer.prototype.createInitialInstances = function () { var i, k, len, inst, initial_inst, type, keep, hasPersistBehavior; for (i = 0, k = 0, len = this.initial_instances.length; i < len; i++) { initial_inst = this.initial_instances[i]; type = this.runtime.types_by_index[initial_inst[1]]; ; hasPersistBehavior = this.runtime.typeHasPersistBehavior(type); keep = true; if (!hasPersistBehavior || this.layout.first_visit) { inst = this.runtime.createInstanceFromInit(initial_inst, this, true); if (!inst) continue; // may have skipped creation due to fallback effect "destroy" created_instances.push(inst); if (inst.type.global) { keep = false; this.created_globals.push(inst.uid); } } if (keep) { this.initial_instances[k] = this.initial_instances[i]; k++; } } this.initial_instances.length = k; this.runtime.ClearDeathRow(); // flushes creation row so IIDs will be correct if (!this.runtime.glwrap && this.effect_types.length) // no WebGL renderer and shaders used this.blend_mode = this.effect_fallback; // use fallback blend mode this.compositeOp = cr.effectToCompositeOp(this.blend_mode); if (this.runtime.gl) cr.setGLBlend(this, this.blend_mode, this.runtime.gl); this.render_list_stale = true; }; Layer.prototype.recreateInitialObjects = function (only_type, rc) { var i, len, initial_inst, type, wm, x, y, inst, j, lenj, s; var types_by_index = this.runtime.types_by_index; var only_type_is_family = only_type.is_family; var only_type_members = only_type.members; for (i = 0, len = this.initial_instances.length; i < len; ++i) { initial_inst = this.initial_instances[i]; wm = initial_inst[0]; x = wm[0]; y = wm[1]; if (!rc.contains_pt(x, y)) continue; // not in the given area type = types_by_index[initial_inst[1]]; if (type !== only_type) { if (only_type_is_family) { if (only_type_members.indexOf(type) < 0) continue; } else continue; // only_type is not a family, and the initial inst type does not match } inst = this.runtime.createInstanceFromInit(initial_inst, this, false); this.runtime.isInOnDestroy++; this.runtime.trigger(Object.getPrototypeOf(type.plugin).cnds.OnCreated, inst); if (inst.is_contained) { for (j = 0, lenj = inst.siblings.length; j < lenj; j++) { s = inst.siblings[i]; this.runtime.trigger(Object.getPrototypeOf(s.type.plugin).cnds.OnCreated, s); } } this.runtime.isInOnDestroy--; } }; Layer.prototype.removeFromInstanceList = function (inst, remove_from_grid) { var index = cr.fastIndexOf(this.instances, inst); if (index < 0) return; // not found if (remove_from_grid && this.useRenderCells && inst.rendercells && inst.rendercells.right >= inst.rendercells.left) { inst.update_bbox(); // make sure actually in its current rendercells this.render_grid.update(inst, inst.rendercells, null); // no new range provided - remove only inst.rendercells.set(0, 0, -1, -1); // set to invalid state to indicate not inserted } if (index === this.instances.length - 1) this.instances.pop(); else { cr.arrayRemove(this.instances, index); this.setZIndicesStaleFrom(index); } this.render_list_stale = true; }; Layer.prototype.appendToInstanceList = function (inst, add_to_grid) { ; inst.zindex = this.instances.length; this.instances.push(inst); if (add_to_grid && this.useRenderCells && inst.rendercells) { inst.set_bbox_changed(); // will cause immediate update and new insertion to grid } this.render_list_stale = true; }; Layer.prototype.prependToInstanceList = function (inst, add_to_grid) { ; this.instances.unshift(inst); this.setZIndicesStaleFrom(0); if (add_to_grid && this.useRenderCells && inst.rendercells) { inst.set_bbox_changed(); // will cause immediate update and new insertion to grid } }; Layer.prototype.moveInstanceAdjacent = function (inst, other, isafter) { ; var myZ = inst.get_zindex(); var insertZ = other.get_zindex(); cr.arrayRemove(this.instances, myZ); if (myZ < insertZ) insertZ--; if (isafter) insertZ++; if (insertZ === this.instances.length) this.instances.push(inst); else this.instances.splice(insertZ, 0, inst); this.setZIndicesStaleFrom(myZ < insertZ ? myZ : insertZ); }; Layer.prototype.setZIndicesStaleFrom = function (index) { if (this.zindices_stale_from === -1) // not yet set this.zindices_stale_from = index; else if (index < this.zindices_stale_from) // determine minimum z index affected this.zindices_stale_from = index; this.zindices_stale = true; this.render_list_stale = true; }; Layer.prototype.updateZIndices = function () { if (!this.zindices_stale) return; if (this.zindices_stale_from === -1) this.zindices_stale_from = 0; var i, len, inst; if (this.useRenderCells) { for (i = this.zindices_stale_from, len = this.instances.length; i < len; ++i) { inst = this.instances[i]; inst.zindex = i; this.render_grid.markRangeChanged(inst.rendercells); } } else { for (i = this.zindices_stale_from, len = this.instances.length; i < len; ++i) { this.instances[i].zindex = i; } } this.zindices_stale = false; this.zindices_stale_from = -1; }; Layer.prototype.getScale = function (include_aspect) { return this.getNormalScale() * (this.runtime.fullscreenScalingQuality || include_aspect ? this.runtime.aspect_scale : 1); }; Layer.prototype.getNormalScale = function () { return ((this.scale * this.layout.scale) - 1) * this.zoomRate + 1; }; Layer.prototype.getAngle = function () { if (this.disableAngle) return 0; return cr.clamp_angle(this.layout.angle + this.angle); }; var arr_cache = []; function alloc_arr() { if (arr_cache.length) return arr_cache.pop(); else return []; } function free_arr(a) { cr.clearArray(a); arr_cache.push(a); }; function mergeSortedZArrays(a, b, out) { var i = 0, j = 0, k = 0, lena = a.length, lenb = b.length, ai, bj; out.length = lena + lenb; for ( ; i < lena && j < lenb; ++k) { ai = a[i]; bj = b[j]; if (ai.zindex < bj.zindex) { out[k] = ai; ++i; } else { out[k] = bj; ++j; } } for ( ; i < lena; ++i, ++k) out[k] = a[i]; for ( ; j < lenb; ++j, ++k) out[k] = b[j]; }; var next_arr = []; function mergeAllSortedZArrays_pass(arr, first_pass) { var i, len, arr1, arr2, out; for (i = 0, len = arr.length; i < len - 1; i += 2) { arr1 = arr[i]; arr2 = arr[i+1]; out = alloc_arr(); mergeSortedZArrays(arr1, arr2, out); if (!first_pass) { free_arr(arr1); free_arr(arr2); } next_arr.push(out); } if (len % 2 === 1) { if (first_pass) { arr1 = alloc_arr(); cr.shallowAssignArray(arr1, arr[len - 1]); next_arr.push(arr1); } else { next_arr.push(arr[len - 1]); } } cr.shallowAssignArray(arr, next_arr); cr.clearArray(next_arr); }; function mergeAllSortedZArrays(arr) { var first_pass = true; while (arr.length > 1) { mergeAllSortedZArrays_pass(arr, first_pass); first_pass = false; } return arr[0]; }; var render_arr = []; Layer.prototype.getRenderCellInstancesToDraw = function () { ; this.updateZIndices(); this.render_grid.queryRange(this.viewLeft, this.viewTop, this.viewRight, this.viewBottom, render_arr); if (!render_arr.length) return alloc_arr(); if (render_arr.length === 1) { var a = alloc_arr(); cr.shallowAssignArray(a, render_arr[0]); cr.clearArray(render_arr); return a; } var draw_list = mergeAllSortedZArrays(render_arr); cr.clearArray(render_arr); return draw_list; }; Layer.prototype.draw = function (ctx) { this.render_offscreen = (this.forceOwnTexture || this.opacity !== 1.0 || this.blend_mode !== 0); var layer_canvas = this.runtime.canvas; var layer_ctx = ctx; var ctx_changed = false; if (this.render_offscreen) { if (!this.runtime.layer_canvas) { this.runtime.layer_canvas = document.createElement("canvas"); ; layer_canvas = this.runtime.layer_canvas; layer_canvas.width = this.runtime.draw_width; layer_canvas.height = this.runtime.draw_height; this.runtime.layer_ctx = layer_canvas.getContext("2d"); ; ctx_changed = true; } layer_canvas = this.runtime.layer_canvas; layer_ctx = this.runtime.layer_ctx; if (layer_canvas.width !== this.runtime.draw_width) { layer_canvas.width = this.runtime.draw_width; ctx_changed = true; } if (layer_canvas.height !== this.runtime.draw_height) { layer_canvas.height = this.runtime.draw_height; ctx_changed = true; } if (ctx_changed) { this.runtime.setCtxImageSmoothingEnabled(layer_ctx, this.runtime.linearSampling); } if (this.transparent) layer_ctx.clearRect(0, 0, this.runtime.draw_width, this.runtime.draw_height); } layer_ctx.globalAlpha = 1; layer_ctx.globalCompositeOperation = "source-over"; if (!this.transparent) { layer_ctx.fillStyle = "rgb(" + this.background_color[0] + "," + this.background_color[1] + "," + this.background_color[2] + ")"; layer_ctx.fillRect(0, 0, this.runtime.draw_width, this.runtime.draw_height); } layer_ctx.save(); this.disableAngle = true; var px = this.canvasToLayer(0, 0, true, true); var py = this.canvasToLayer(0, 0, false, true); this.disableAngle = false; if (this.runtime.pixel_rounding) { px = Math.round(px); py = Math.round(py); } this.rotateViewport(px, py, layer_ctx); var myscale = this.getScale(); layer_ctx.scale(myscale, myscale); layer_ctx.translate(-px, -py); var instances_to_draw; if (this.useRenderCells) { this.cur_render_cells.left = this.render_grid.XToCell(this.viewLeft); this.cur_render_cells.top = this.render_grid.YToCell(this.viewTop); this.cur_render_cells.right = this.render_grid.XToCell(this.viewRight); this.cur_render_cells.bottom = this.render_grid.YToCell(this.viewBottom); if (this.render_list_stale || !this.cur_render_cells.equals(this.last_render_cells)) { free_arr(this.last_render_list); instances_to_draw = this.getRenderCellInstancesToDraw(); this.render_list_stale = false; this.last_render_cells.copy(this.cur_render_cells); } else instances_to_draw = this.last_render_list; } else instances_to_draw = this.instances; var i, len, inst, last_inst = null; for (i = 0, len = instances_to_draw.length; i < len; ++i) { inst = instances_to_draw[i]; if (inst === last_inst) continue; this.drawInstance(inst, layer_ctx); last_inst = inst; } if (this.useRenderCells) this.last_render_list = instances_to_draw; layer_ctx.restore(); if (this.render_offscreen) { ctx.globalCompositeOperation = this.compositeOp; ctx.globalAlpha = this.opacity; ctx.drawImage(layer_canvas, 0, 0); } }; Layer.prototype.drawInstance = function(inst, layer_ctx) { if (!inst.visible || inst.width === 0 || inst.height === 0) return; inst.update_bbox(); var bbox = inst.bbox; if (bbox.right < this.viewLeft || bbox.bottom < this.viewTop || bbox.left > this.viewRight || bbox.top > this.viewBottom) return; layer_ctx.globalCompositeOperation = inst.compositeOp; inst.draw(layer_ctx); }; Layer.prototype.updateViewport = function (ctx) { this.disableAngle = true; var px = this.canvasToLayer(0, 0, true, true); var py = this.canvasToLayer(0, 0, false, true); this.disableAngle = false; if (this.runtime.pixel_rounding) { px = Math.round(px); py = Math.round(py); } this.rotateViewport(px, py, ctx); }; Layer.prototype.rotateViewport = function (px, py, ctx) { var myscale = this.getScale(); this.viewLeft = px; this.viewTop = py; this.viewRight = px + (this.runtime.draw_width * (1 / myscale)); this.viewBottom = py + (this.runtime.draw_height * (1 / myscale)); var temp; if (this.viewLeft > this.viewRight) { temp = this.viewLeft; this.viewLeft = this.viewRight; this.viewRight = temp; } if (this.viewTop > this.viewBottom) { temp = this.viewTop; this.viewTop = this.viewBottom; this.viewBottom = temp; } var myAngle = this.getAngle(); if (myAngle !== 0) { if (ctx) { ctx.translate(this.runtime.draw_width / 2, this.runtime.draw_height / 2); ctx.rotate(-myAngle); ctx.translate(this.runtime.draw_width / -2, this.runtime.draw_height / -2); } this.tmprect.set(this.viewLeft, this.viewTop, this.viewRight, this.viewBottom); this.tmprect.offset((this.viewLeft + this.viewRight) / -2, (this.viewTop + this.viewBottom) / -2); this.tmpquad.set_from_rotated_rect(this.tmprect, myAngle); this.tmpquad.bounding_box(this.tmprect); this.tmprect.offset((this.viewLeft + this.viewRight) / 2, (this.viewTop + this.viewBottom) / 2); this.viewLeft = this.tmprect.left; this.viewTop = this.tmprect.top; this.viewRight = this.tmprect.right; this.viewBottom = this.tmprect.bottom; } } Layer.prototype.drawGL_earlyZPass = function (glw) { var windowWidth = this.runtime.draw_width; var windowHeight = this.runtime.draw_height; var shaderindex = 0; var etindex = 0; this.render_offscreen = this.forceOwnTexture; if (this.render_offscreen) { if (!this.runtime.layer_tex) { this.runtime.layer_tex = glw.createEmptyTexture(this.runtime.draw_width, this.runtime.draw_height, this.runtime.linearSampling); } if (this.runtime.layer_tex.c2width !== this.runtime.draw_width || this.runtime.layer_tex.c2height !== this.runtime.draw_height) { glw.deleteTexture(this.runtime.layer_tex); this.runtime.layer_tex = glw.createEmptyTexture(this.runtime.draw_width, this.runtime.draw_height, this.runtime.linearSampling); } glw.setRenderingToTexture(this.runtime.layer_tex); } this.disableAngle = true; var px = this.canvasToLayer(0, 0, true, true); var py = this.canvasToLayer(0, 0, false, true); this.disableAngle = false; if (this.runtime.pixel_rounding) { px = Math.round(px); py = Math.round(py); } this.rotateViewport(px, py, null); var myscale = this.getScale(); glw.resetModelView(); glw.scale(myscale, myscale); glw.rotateZ(-this.getAngle()); glw.translate((this.viewLeft + this.viewRight) / -2, (this.viewTop + this.viewBottom) / -2); glw.updateModelView(); var instances_to_draw; if (this.useRenderCells) { this.cur_render_cells.left = this.render_grid.XToCell(this.viewLeft); this.cur_render_cells.top = this.render_grid.YToCell(this.viewTop); this.cur_render_cells.right = this.render_grid.XToCell(this.viewRight); this.cur_render_cells.bottom = this.render_grid.YToCell(this.viewBottom); if (this.render_list_stale || !this.cur_render_cells.equals(this.last_render_cells)) { free_arr(this.last_render_list); instances_to_draw = this.getRenderCellInstancesToDraw(); this.render_list_stale = false; this.last_render_cells.copy(this.cur_render_cells); } else instances_to_draw = this.last_render_list; } else instances_to_draw = this.instances; var i, inst, last_inst = null; for (i = instances_to_draw.length - 1; i >= 0; --i) { inst = instances_to_draw[i]; if (inst === last_inst) continue; this.drawInstanceGL_earlyZPass(instances_to_draw[i], glw); last_inst = inst; } if (this.useRenderCells) this.last_render_list = instances_to_draw; if (!this.transparent) { this.clear_earlyz_index = this.runtime.earlyz_index++; glw.setEarlyZIndex(this.clear_earlyz_index); glw.setColorFillMode(1, 1, 1, 1); glw.fullscreenQuad(); // fill remaining space in depth buffer with current Z value glw.restoreEarlyZMode(); } }; Layer.prototype.drawGL = function (glw) { var windowWidth = this.runtime.draw_width; var windowHeight = this.runtime.draw_height; var shaderindex = 0; var etindex = 0; this.render_offscreen = (this.forceOwnTexture || this.opacity !== 1.0 || this.active_effect_types.length > 0 || this.blend_mode !== 0); if (this.render_offscreen) { if (!this.runtime.layer_tex) { this.runtime.layer_tex = glw.createEmptyTexture(this.runtime.draw_width, this.runtime.draw_height, this.runtime.linearSampling); } if (this.runtime.layer_tex.c2width !== this.runtime.draw_width || this.runtime.layer_tex.c2height !== this.runtime.draw_height) { glw.deleteTexture(this.runtime.layer_tex); this.runtime.layer_tex = glw.createEmptyTexture(this.runtime.draw_width, this.runtime.draw_height, this.runtime.linearSampling); } glw.setRenderingToTexture(this.runtime.layer_tex); if (this.transparent) glw.clear(0, 0, 0, 0); } if (!this.transparent) { if (this.runtime.enableFrontToBack) { glw.setEarlyZIndex(this.clear_earlyz_index); glw.setColorFillMode(this.background_color[0] / 255, this.background_color[1] / 255, this.background_color[2] / 255, 1); glw.fullscreenQuad(); glw.setTextureFillMode(); } else { glw.clear(this.background_color[0] / 255, this.background_color[1] / 255, this.background_color[2] / 255, 1); } } this.disableAngle = true; var px = this.canvasToLayer(0, 0, true, true); var py = this.canvasToLayer(0, 0, false, true); this.disableAngle = false; if (this.runtime.pixel_rounding) { px = Math.round(px); py = Math.round(py); } this.rotateViewport(px, py, null); var myscale = this.getScale(); glw.resetModelView(); glw.scale(myscale, myscale); glw.rotateZ(-this.getAngle()); glw.translate((this.viewLeft + this.viewRight) / -2, (this.viewTop + this.viewBottom) / -2); glw.updateModelView(); var instances_to_draw; if (this.useRenderCells) { this.cur_render_cells.left = this.render_grid.XToCell(this.viewLeft); this.cur_render_cells.top = this.render_grid.YToCell(this.viewTop); this.cur_render_cells.right = this.render_grid.XToCell(this.viewRight); this.cur_render_cells.bottom = this.render_grid.YToCell(this.viewBottom); if (this.render_list_stale || !this.cur_render_cells.equals(this.last_render_cells)) { free_arr(this.last_render_list); instances_to_draw = this.getRenderCellInstancesToDraw(); this.render_list_stale = false; this.last_render_cells.copy(this.cur_render_cells); } else instances_to_draw = this.last_render_list; } else instances_to_draw = this.instances; var i, len, inst, last_inst = null; for (i = 0, len = instances_to_draw.length; i < len; ++i) { inst = instances_to_draw[i]; if (inst === last_inst) continue; this.drawInstanceGL(instances_to_draw[i], glw); last_inst = inst; } if (this.useRenderCells) this.last_render_list = instances_to_draw; if (this.render_offscreen) { shaderindex = this.active_effect_types.length ? this.active_effect_types[0].shaderindex : 0; etindex = this.active_effect_types.length ? this.active_effect_types[0].index : 0; if (this.active_effect_types.length === 0 || (this.active_effect_types.length === 1 && !glw.programUsesCrossSampling(shaderindex) && this.opacity === 1)) { if (this.active_effect_types.length === 1) { glw.switchProgram(shaderindex); glw.setProgramParameters(this.layout.getRenderTarget(), // backTex 1.0 / this.runtime.draw_width, // pixelWidth 1.0 / this.runtime.draw_height, // pixelHeight 0.0, 0.0, // destStart 1.0, 1.0, // destEnd myscale, // layerScale this.getAngle(), this.viewLeft, this.viewTop, (this.viewLeft + this.viewRight) / 2, (this.viewTop + this.viewBottom) / 2, this.runtime.kahanTime.sum, this.effect_params[etindex]); // fx parameters if (glw.programIsAnimated(shaderindex)) this.runtime.redraw = true; } else glw.switchProgram(0); glw.setRenderingToTexture(this.layout.getRenderTarget()); glw.setOpacity(this.opacity); glw.setTexture(this.runtime.layer_tex); glw.setBlend(this.srcBlend, this.destBlend); glw.resetModelView(); glw.updateModelView(); var halfw = this.runtime.draw_width / 2; var halfh = this.runtime.draw_height / 2; glw.quad(-halfw, halfh, halfw, halfh, halfw, -halfh, -halfw, -halfh); glw.setTexture(null); } else { this.layout.renderEffectChain(glw, this, null, this.layout.getRenderTarget()); } } }; Layer.prototype.drawInstanceGL = function (inst, glw) { ; if (!inst.visible || inst.width === 0 || inst.height === 0) return; inst.update_bbox(); var bbox = inst.bbox; if (bbox.right < this.viewLeft || bbox.bottom < this.viewTop || bbox.left > this.viewRight || bbox.top > this.viewBottom) return; glw.setEarlyZIndex(inst.earlyz_index); if (inst.uses_shaders) { this.drawInstanceWithShadersGL(inst, glw); } else { glw.switchProgram(0); // un-set any previously set shader glw.setBlend(inst.srcBlend, inst.destBlend); inst.drawGL(glw); } }; Layer.prototype.drawInstanceGL_earlyZPass = function (inst, glw) { ; if (!inst.visible || inst.width === 0 || inst.height === 0) return; inst.update_bbox(); var bbox = inst.bbox; if (bbox.right < this.viewLeft || bbox.bottom < this.viewTop || bbox.left > this.viewRight || bbox.top > this.viewBottom) return; inst.earlyz_index = this.runtime.earlyz_index++; if (inst.blend_mode !== 0 || inst.opacity !== 1 || !inst.shaders_preserve_opaqueness || !inst.drawGL_earlyZPass) return; glw.setEarlyZIndex(inst.earlyz_index); inst.drawGL_earlyZPass(glw); }; Layer.prototype.drawInstanceWithShadersGL = function (inst, glw) { var shaderindex = inst.active_effect_types[0].shaderindex; var etindex = inst.active_effect_types[0].index; var myscale = this.getScale(); if (inst.active_effect_types.length === 1 && !glw.programUsesCrossSampling(shaderindex) && !glw.programExtendsBox(shaderindex) && ((!inst.angle && !inst.layer.getAngle()) || !glw.programUsesDest(shaderindex)) && inst.opacity === 1 && !inst.type.plugin.must_predraw) { glw.switchProgram(shaderindex); glw.setBlend(inst.srcBlend, inst.destBlend); if (glw.programIsAnimated(shaderindex)) this.runtime.redraw = true; var destStartX = 0, destStartY = 0, destEndX = 0, destEndY = 0; if (glw.programUsesDest(shaderindex)) { var bbox = inst.bbox; var screenleft = this.layerToCanvas(bbox.left, bbox.top, true, true); var screentop = this.layerToCanvas(bbox.left, bbox.top, false, true); var screenright = this.layerToCanvas(bbox.right, bbox.bottom, true, true); var screenbottom = this.layerToCanvas(bbox.right, bbox.bottom, false, true); destStartX = screenleft / windowWidth; destStartY = 1 - screentop / windowHeight; destEndX = screenright / windowWidth; destEndY = 1 - screenbottom / windowHeight; } var pixelWidth; var pixelHeight; if (inst.curFrame && inst.curFrame.texture_img) { var img = inst.curFrame.texture_img; pixelWidth = 1.0 / img.width; pixelHeight = 1.0 / img.height; } else { pixelWidth = 1.0 / inst.width; pixelHeight = 1.0 / inst.height; } glw.setProgramParameters(this.render_offscreen ? this.runtime.layer_tex : this.layout.getRenderTarget(), // backTex pixelWidth, pixelHeight, destStartX, destStartY, destEndX, destEndY, myscale, this.getAngle(), this.viewLeft, this.viewTop, (this.viewLeft + this.viewRight) / 2, (this.viewTop + this.viewBottom) / 2, this.runtime.kahanTime.sum, inst.effect_params[etindex]); inst.drawGL(glw); } else { this.layout.renderEffectChain(glw, this, inst, this.render_offscreen ? this.runtime.layer_tex : this.layout.getRenderTarget()); glw.resetModelView(); glw.scale(myscale, myscale); glw.rotateZ(-this.getAngle()); glw.translate((this.viewLeft + this.viewRight) / -2, (this.viewTop + this.viewBottom) / -2); glw.updateModelView(); } }; Layer.prototype.canvasToLayer = function (ptx, pty, getx, using_draw_area) { var multiplier = this.runtime.devicePixelRatio; if (this.runtime.isRetina) { ptx *= multiplier; pty *= multiplier; } var ox = this.runtime.parallax_x_origin; var oy = this.runtime.parallax_y_origin; var par_x = ((this.layout.scrollX - ox) * this.parallaxX) + ox; var par_y = ((this.layout.scrollY - oy) * this.parallaxY) + oy; var x = par_x; var y = par_y; var invScale = 1 / this.getScale(!using_draw_area); if (using_draw_area) { x -= (this.runtime.draw_width * invScale) / 2; y -= (this.runtime.draw_height * invScale) / 2; } else { x -= (this.runtime.width * invScale) / 2; y -= (this.runtime.height * invScale) / 2; } x += ptx * invScale; y += pty * invScale; var a = this.getAngle(); if (a !== 0) { x -= par_x; y -= par_y; var cosa = Math.cos(a); var sina = Math.sin(a); var x_temp = (x * cosa) - (y * sina); y = (y * cosa) + (x * sina); x = x_temp; x += par_x; y += par_y; } return getx ? x : y; }; Layer.prototype.layerToCanvas = function (ptx, pty, getx, using_draw_area) { var ox = this.runtime.parallax_x_origin; var oy = this.runtime.parallax_y_origin; var par_x = ((this.layout.scrollX - ox) * this.parallaxX) + ox; var par_y = ((this.layout.scrollY - oy) * this.parallaxY) + oy; var x = par_x; var y = par_y; var a = this.getAngle(); if (a !== 0) { ptx -= par_x; pty -= par_y; var cosa = Math.cos(-a); var sina = Math.sin(-a); var x_temp = (ptx * cosa) - (pty * sina); pty = (pty * cosa) + (ptx * sina); ptx = x_temp; ptx += par_x; pty += par_y; } var invScale = 1 / this.getScale(!using_draw_area); if (using_draw_area) { x -= (this.runtime.draw_width * invScale) / 2; y -= (this.runtime.draw_height * invScale) / 2; } else { x -= (this.runtime.width * invScale) / 2; y -= (this.runtime.height * invScale) / 2; } x = (ptx - x) / invScale; y = (pty - y) / invScale; var multiplier = this.runtime.devicePixelRatio; if (this.runtime.isRetina && !using_draw_area) { x /= multiplier; y /= multiplier; } return getx ? x : y; }; Layer.prototype.rotatePt = function (x_, y_, getx) { if (this.getAngle() === 0) return getx ? x_ : y_; var nx = this.layerToCanvas(x_, y_, true); var ny = this.layerToCanvas(x_, y_, false); this.disableAngle = true; var px = this.canvasToLayer(nx, ny, true); var py = this.canvasToLayer(nx, ny, true); this.disableAngle = false; return getx ? px : py; }; Layer.prototype.saveToJSON = function () { var i, len, et; var o = { "s": this.scale, "a": this.angle, "vl": this.viewLeft, "vt": this.viewTop, "vr": this.viewRight, "vb": this.viewBottom, "v": this.visible, "bc": this.background_color, "t": this.transparent, "px": this.parallaxX, "py": this.parallaxY, "o": this.opacity, "zr": this.zoomRate, "fx": [], "cg": this.created_globals, // added r197; list of global UIDs already created "instances": [] }; for (i = 0, len = this.effect_types.length; i < len; i++) { et = this.effect_types[i]; o["fx"].push({"name": et.name, "active": et.active, "params": this.effect_params[et.index] }); } return o; }; Layer.prototype.loadFromJSON = function (o) { var i, j, len, p, inst, fx; this.scale = o["s"]; this.angle = o["a"]; this.viewLeft = o["vl"]; this.viewTop = o["vt"]; this.viewRight = o["vr"]; this.viewBottom = o["vb"]; this.visible = o["v"]; this.background_color = o["bc"]; this.transparent = o["t"]; this.parallaxX = o["px"]; this.parallaxY = o["py"]; this.opacity = o["o"]; this.zoomRate = o["zr"]; this.created_globals = o["cg"] || []; // added r197 cr.shallowAssignArray(this.initial_instances, this.startup_initial_instances); var temp_set = new cr.ObjectSet(); for (i = 0, len = this.created_globals.length; i < len; ++i) temp_set.add(this.created_globals[i]); for (i = 0, j = 0, len = this.initial_instances.length; i < len; ++i) { if (!temp_set.contains(this.initial_instances[i][2])) // UID in element 2 { this.initial_instances[j] = this.initial_instances[i]; ++j; } } cr.truncateArray(this.initial_instances, j); var ofx = o["fx"]; for (i = 0, len = ofx.length; i < len; i++) { fx = this.getEffectByName(ofx[i]["name"]); if (!fx) continue; // must've gone missing fx.active = ofx[i]["active"]; this.effect_params[fx.index] = ofx[i]["params"]; } this.updateActiveEffects(); this.instances.sort(sort_by_zindex); this.zindices_stale = true; }; cr.layer = Layer; }()); ; (function() { var allUniqueSolModifiers = []; function testSolsMatch(arr1, arr2) { var i, len = arr1.length; switch (len) { case 0: return true; case 1: return arr1[0] === arr2[0]; case 2: return arr1[0] === arr2[0] && arr1[1] === arr2[1]; default: for (i = 0; i < len; i++) { if (arr1[i] !== arr2[i]) return false; } return true; } }; function solArraySorter(t1, t2) { return t1.index - t2.index; }; function findMatchingSolModifier(arr) { var i, len, u, temp, subarr; if (arr.length === 2) { if (arr[0].index > arr[1].index) { temp = arr[0]; arr[0] = arr[1]; arr[1] = temp; } } else if (arr.length > 2) arr.sort(solArraySorter); // so testSolsMatch compares in same order if (arr.length >= allUniqueSolModifiers.length) allUniqueSolModifiers.length = arr.length + 1; if (!allUniqueSolModifiers[arr.length]) allUniqueSolModifiers[arr.length] = []; subarr = allUniqueSolModifiers[arr.length]; for (i = 0, len = subarr.length; i < len; i++) { u = subarr[i]; if (testSolsMatch(arr, u)) return u; } subarr.push(arr); return arr; }; function EventSheet(runtime, m) { this.runtime = runtime; this.triggers = {}; this.fasttriggers = {}; this.hasRun = false; this.includes = new cr.ObjectSet(); // all event sheets included by this sheet, at first-level indirection only this.deep_includes = []; // all includes from this sheet recursively, in trigger order this.already_included_sheets = []; // used while building deep_includes this.name = m[0]; var em = m[1]; // events model this.events = []; // triggers won't make it to this array var i, len; for (i = 0, len = em.length; i < len; i++) this.init_event(em[i], null, this.events); }; EventSheet.prototype.toString = function () { return this.name; }; EventSheet.prototype.init_event = function (m, parent, nontriggers) { switch (m[0]) { case 0: // event block { var block = new cr.eventblock(this, parent, m); cr.seal(block); if (block.orblock) { nontriggers.push(block); var i, len; for (i = 0, len = block.conditions.length; i < len; i++) { if (block.conditions[i].trigger) this.init_trigger(block, i); } } else { if (block.is_trigger()) this.init_trigger(block, 0); else nontriggers.push(block); } break; } case 1: // variable { var v = new cr.eventvariable(this, parent, m); cr.seal(v); nontriggers.push(v); break; } case 2: // include { var inc = new cr.eventinclude(this, parent, m); cr.seal(inc); nontriggers.push(inc); break; } default: ; } }; EventSheet.prototype.postInit = function () { var i, len; for (i = 0, len = this.events.length; i < len; i++) { this.events[i].postInit(i < len - 1 && this.events[i + 1].is_else_block); } }; EventSheet.prototype.updateDeepIncludes = function () { cr.clearArray(this.deep_includes); cr.clearArray(this.already_included_sheets); this.addDeepIncludes(this); cr.clearArray(this.already_included_sheets); }; EventSheet.prototype.addDeepIncludes = function (root_sheet) { var i, len, inc, sheet; var deep_includes = root_sheet.deep_includes; var already_included_sheets = root_sheet.already_included_sheets; var arr = this.includes.valuesRef(); for (i = 0, len = arr.length; i < len; ++i) { inc = arr[i]; sheet = inc.include_sheet; if (!inc.isActive() || root_sheet === sheet || already_included_sheets.indexOf(sheet) > -1) continue; already_included_sheets.push(sheet); sheet.addDeepIncludes(root_sheet); deep_includes.push(sheet); } }; EventSheet.prototype.run = function (from_include) { if (!this.runtime.resuming_breakpoint) { this.hasRun = true; if (!from_include) this.runtime.isRunningEvents = true; } var i, len; for (i = 0, len = this.events.length; i < len; i++) { var ev = this.events[i]; ev.run(); this.runtime.clearSol(ev.solModifiers); if (this.runtime.hasPendingInstances) this.runtime.ClearDeathRow(); } if (!from_include) this.runtime.isRunningEvents = false; }; function isPerformanceSensitiveTrigger(method) { if (cr.plugins_.Sprite && method === cr.plugins_.Sprite.prototype.cnds.OnFrameChanged) { return true; } return false; }; EventSheet.prototype.init_trigger = function (trig, index) { if (!trig.orblock) this.runtime.triggers_to_postinit.push(trig); // needs to be postInit'd later var i, len; var cnd = trig.conditions[index]; var type_name; if (cnd.type) type_name = cnd.type.name; else type_name = "system"; var fasttrigger = cnd.fasttrigger; var triggers = (fasttrigger ? this.fasttriggers : this.triggers); if (!triggers[type_name]) triggers[type_name] = []; var obj_entry = triggers[type_name]; var method = cnd.func; if (fasttrigger) { if (!cnd.parameters.length) // no parameters return; var firstparam = cnd.parameters[0]; if (firstparam.type !== 1 || // not a string param firstparam.expression.type !== 2) // not a string literal node { return; } var fastevs; var firstvalue = firstparam.expression.value.toLowerCase(); var i, len; for (i = 0, len = obj_entry.length; i < len; i++) { if (obj_entry[i].method == method) { fastevs = obj_entry[i].evs; if (!fastevs[firstvalue]) fastevs[firstvalue] = [[trig, index]]; else fastevs[firstvalue].push([trig, index]); return; } } fastevs = {}; fastevs[firstvalue] = [[trig, index]]; obj_entry.push({ method: method, evs: fastevs }); } else { for (i = 0, len = obj_entry.length; i < len; i++) { if (obj_entry[i].method == method) { obj_entry[i].evs.push([trig, index]); return; } } if (isPerformanceSensitiveTrigger(method)) obj_entry.unshift({ method: method, evs: [[trig, index]]}); else obj_entry.push({ method: method, evs: [[trig, index]]}); } }; cr.eventsheet = EventSheet; function Selection(type) { this.type = type; this.instances = []; // subset of picked instances this.else_instances = []; // subset of unpicked instances this.select_all = true; }; Selection.prototype.hasObjects = function () { if (this.select_all) return this.type.instances.length; else return this.instances.length; }; Selection.prototype.getObjects = function () { if (this.select_all) return this.type.instances; else return this.instances; }; /* Selection.prototype.ensure_picked = function (inst, skip_siblings) { var i, len; var orblock = inst.runtime.getCurrentEventStack().current_event.orblock; if (this.select_all) { this.select_all = false; if (orblock) { cr.shallowAssignArray(this.else_instances, inst.type.instances); cr.arrayFindRemove(this.else_instances, inst); } this.instances.length = 1; this.instances[0] = inst; } else { if (orblock) { i = this.else_instances.indexOf(inst); if (i !== -1) { this.instances.push(this.else_instances[i]); this.else_instances.splice(i, 1); } } else { if (this.instances.indexOf(inst) === -1) this.instances.push(inst); } } if (!skip_siblings) { } }; */ Selection.prototype.pick_one = function (inst) { if (!inst) return; if (inst.runtime.getCurrentEventStack().current_event.orblock) { if (this.select_all) { cr.clearArray(this.instances); cr.shallowAssignArray(this.else_instances, inst.type.instances); this.select_all = false; } var i = this.else_instances.indexOf(inst); if (i !== -1) { this.instances.push(this.else_instances[i]); this.else_instances.splice(i, 1); } } else { this.select_all = false; cr.clearArray(this.instances); this.instances[0] = inst; } }; cr.selection = Selection; function EventBlock(sheet, parent, m) { this.sheet = sheet; this.parent = parent; this.runtime = sheet.runtime; this.solModifiers = []; this.solModifiersIncludingParents = []; this.solWriterAfterCnds = false; // block does not change SOL after running its conditions this.group = false; // is group of events this.initially_activated = false; // if a group, is active on startup this.toplevelevent = false; // is an event block parented only by a top-level group this.toplevelgroup = false; // is parented only by other groups or is top-level (i.e. not in a subevent) this.has_else_block = false; // is followed by else ; this.conditions = []; this.actions = []; this.subevents = []; this.group_name = ""; this.group = false; this.initially_activated = false; this.group_active = false; this.contained_includes = null; if (m[1]) { this.group_name = m[1][1].toLowerCase(); this.group = true; this.initially_activated = !!m[1][0]; this.contained_includes = []; this.group_active = this.initially_activated; this.runtime.allGroups.push(this); this.runtime.groups_by_name[this.group_name] = this; } this.orblock = m[2]; this.sid = m[4]; if (!this.group) this.runtime.blocksBySid[this.sid.toString()] = this; var i, len; var cm = m[5]; for (i = 0, len = cm.length; i < len; i++) { var cnd = new cr.condition(this, cm[i]); cnd.index = i; cr.seal(cnd); this.conditions.push(cnd); /* if (cnd.is_logical()) this.is_logical = true; if (cnd.type && !cnd.type.plugin.singleglobal && this.cndReferences.indexOf(cnd.type) === -1) this.cndReferences.push(cnd.type); */ this.addSolModifier(cnd.type); } var am = m[6]; for (i = 0, len = am.length; i < len; i++) { var act = new cr.action(this, am[i]); act.index = i; cr.seal(act); this.actions.push(act); } if (m.length === 8) { var em = m[7]; for (i = 0, len = em.length; i < len; i++) this.sheet.init_event(em[i], this, this.subevents); } this.is_else_block = false; if (this.conditions.length) { this.is_else_block = (this.conditions[0].type == null && this.conditions[0].func == cr.system_object.prototype.cnds.Else); } }; window["_c2hh_"] = "A29F5CE22CCBBA4760C2FCDD4D910DC7BCBA3E33"; EventBlock.prototype.postInit = function (hasElse/*, prevBlock_*/) { var i, len; var p = this.parent; if (this.group) { this.toplevelgroup = true; while (p) { if (!p.group) { this.toplevelgroup = false; break; } p = p.parent; } } this.toplevelevent = !this.is_trigger() && (!this.parent || (this.parent.group && this.parent.toplevelgroup)); this.has_else_block = !!hasElse; this.solModifiersIncludingParents = this.solModifiers.slice(0); p = this.parent; while (p) { for (i = 0, len = p.solModifiers.length; i < len; i++) this.addParentSolModifier(p.solModifiers[i]); p = p.parent; } this.solModifiers = findMatchingSolModifier(this.solModifiers); this.solModifiersIncludingParents = findMatchingSolModifier(this.solModifiersIncludingParents); var i, len/*, s*/; for (i = 0, len = this.conditions.length; i < len; i++) this.conditions[i].postInit(); for (i = 0, len = this.actions.length; i < len; i++) this.actions[i].postInit(); for (i = 0, len = this.subevents.length; i < len; i++) { this.subevents[i].postInit(i < len - 1 && this.subevents[i + 1].is_else_block); } /* if (this.is_else_block && this.prev_block) { for (i = 0, len = this.prev_block.solModifiers.length; i < len; i++) { s = this.prev_block.solModifiers[i]; if (this.solModifiers.indexOf(s) === -1) this.solModifiers.push(s); } } */ }; EventBlock.prototype.setGroupActive = function (a) { if (this.group_active === !!a) return; // same state this.group_active = !!a; var i, len; for (i = 0, len = this.contained_includes.length; i < len; ++i) { this.contained_includes[i].updateActive(); } if (len > 0 && this.runtime.running_layout.event_sheet) this.runtime.running_layout.event_sheet.updateDeepIncludes(); }; function addSolModifierToList(type, arr) { var i, len, t; if (!type) return; if (arr.indexOf(type) === -1) arr.push(type); if (type.is_contained) { for (i = 0, len = type.container.length; i < len; i++) { t = type.container[i]; if (type === t) continue; // already handled if (arr.indexOf(t) === -1) arr.push(t); } } }; EventBlock.prototype.addSolModifier = function (type) { addSolModifierToList(type, this.solModifiers); }; EventBlock.prototype.addParentSolModifier = function (type) { addSolModifierToList(type, this.solModifiersIncludingParents); }; EventBlock.prototype.setSolWriterAfterCnds = function () { this.solWriterAfterCnds = true; if (this.parent) this.parent.setSolWriterAfterCnds(); }; EventBlock.prototype.is_trigger = function () { if (!this.conditions.length) // no conditions return false; else return this.conditions[0].trigger; }; EventBlock.prototype.run = function () { var i, len, c, any_true = false, cnd_result; var runtime = this.runtime; var evinfo = this.runtime.getCurrentEventStack(); evinfo.current_event = this; var conditions = this.conditions; if (!this.is_else_block) evinfo.else_branch_ran = false; if (this.orblock) { if (conditions.length === 0) any_true = true; // be sure to run if empty block evinfo.cndindex = 0 for (len = conditions.length; evinfo.cndindex < len; evinfo.cndindex++) { c = conditions[evinfo.cndindex]; if (c.trigger) // skip triggers when running OR block continue; cnd_result = c.run(); if (cnd_result) // make sure all conditions run and run if any were true any_true = true; } evinfo.last_event_true = any_true; if (any_true) this.run_actions_and_subevents(); } else { evinfo.cndindex = 0 for (len = conditions.length; evinfo.cndindex < len; evinfo.cndindex++) { cnd_result = conditions[evinfo.cndindex].run(); if (!cnd_result) // condition failed { evinfo.last_event_true = false; if (this.toplevelevent && runtime.hasPendingInstances) runtime.ClearDeathRow(); return; // bail out now } } evinfo.last_event_true = true; this.run_actions_and_subevents(); } this.end_run(evinfo); }; EventBlock.prototype.end_run = function (evinfo) { if (evinfo.last_event_true && this.has_else_block) evinfo.else_branch_ran = true; if (this.toplevelevent && this.runtime.hasPendingInstances) this.runtime.ClearDeathRow(); }; EventBlock.prototype.run_orblocktrigger = function (index) { var evinfo = this.runtime.getCurrentEventStack(); evinfo.current_event = this; if (this.conditions[index].run()) { this.run_actions_and_subevents(); this.runtime.getCurrentEventStack().last_event_true = true; } }; EventBlock.prototype.run_actions_and_subevents = function () { var evinfo = this.runtime.getCurrentEventStack(); var len; for (evinfo.actindex = 0, len = this.actions.length; evinfo.actindex < len; evinfo.actindex++) { if (this.actions[evinfo.actindex].run()) return; } this.run_subevents(); }; EventBlock.prototype.resume_actions_and_subevents = function () { var evinfo = this.runtime.getCurrentEventStack(); var len; for (len = this.actions.length; evinfo.actindex < len; evinfo.actindex++) { if (this.actions[evinfo.actindex].run()) return; } this.run_subevents(); }; EventBlock.prototype.run_subevents = function () { if (!this.subevents.length) return; var i, len, subev, pushpop/*, skipped_pop = false, pop_modifiers = null*/; var last = this.subevents.length - 1; this.runtime.pushEventStack(this); if (this.solWriterAfterCnds) { for (i = 0, len = this.subevents.length; i < len; i++) { subev = this.subevents[i]; pushpop = (!this.toplevelgroup || (!this.group && i < last)); if (pushpop) this.runtime.pushCopySol(subev.solModifiers); subev.run(); if (pushpop) this.runtime.popSol(subev.solModifiers); else this.runtime.clearSol(subev.solModifiers); } } else { for (i = 0, len = this.subevents.length; i < len; i++) { this.subevents[i].run(); } } this.runtime.popEventStack(); }; EventBlock.prototype.run_pretrigger = function () { var evinfo = this.runtime.getCurrentEventStack(); evinfo.current_event = this; var any_true = false; var i, len; for (evinfo.cndindex = 0, len = this.conditions.length; evinfo.cndindex < len; evinfo.cndindex++) { ; if (this.conditions[evinfo.cndindex].run()) any_true = true; else if (!this.orblock) // condition failed (let OR blocks run all conditions anyway) return false; // bail out } return this.orblock ? any_true : true; }; EventBlock.prototype.retrigger = function () { this.runtime.execcount++; var prevcndindex = this.runtime.getCurrentEventStack().cndindex; var len; var evinfo = this.runtime.pushEventStack(this); if (!this.orblock) { for (evinfo.cndindex = prevcndindex + 1, len = this.conditions.length; evinfo.cndindex < len; evinfo.cndindex++) { if (!this.conditions[evinfo.cndindex].run()) // condition failed { this.runtime.popEventStack(); // moving up level of recursion return false; // bail out } } } this.run_actions_and_subevents(); this.runtime.popEventStack(); return true; // ran an iteration }; EventBlock.prototype.isFirstConditionOfType = function (cnd) { var cndindex = cnd.index; if (cndindex === 0) return true; --cndindex; for ( ; cndindex >= 0; --cndindex) { if (this.conditions[cndindex].type === cnd.type) return false; } return true; }; cr.eventblock = EventBlock; function Condition(block, m) { this.block = block; this.sheet = block.sheet; this.runtime = block.runtime; this.parameters = []; this.results = []; this.extra = {}; // for plugins to stow away some custom info this.index = -1; this.anyParamVariesPerInstance = false; this.func = this.runtime.GetObjectReference(m[1]); ; this.trigger = (m[3] > 0); this.fasttrigger = (m[3] === 2); this.looping = m[4]; this.inverted = m[5]; this.isstatic = m[6]; this.sid = m[7]; this.runtime.cndsBySid[this.sid.toString()] = this; if (m[0] === -1) // system object { this.type = null; this.run = this.run_system; this.behaviortype = null; this.beh_index = -1; } else { this.type = this.runtime.types_by_index[m[0]]; ; if (this.isstatic) this.run = this.run_static; else this.run = this.run_object; if (m[2]) { this.behaviortype = this.type.getBehaviorByName(m[2]); ; this.beh_index = this.type.getBehaviorIndexByName(m[2]); ; } else { this.behaviortype = null; this.beh_index = -1; } if (this.block.parent) this.block.parent.setSolWriterAfterCnds(); } if (this.fasttrigger) this.run = this.run_true; if (m.length === 10) { var i, len; var em = m[9]; for (i = 0, len = em.length; i < len; i++) { var param = new cr.parameter(this, em[i]); cr.seal(param); this.parameters.push(param); } this.results.length = em.length; } }; Condition.prototype.postInit = function () { var i, len, p; for (i = 0, len = this.parameters.length; i < len; i++) { p = this.parameters[i]; p.postInit(); if (p.variesPerInstance) this.anyParamVariesPerInstance = true; } }; /* Condition.prototype.is_logical = function () { return !this.type || this.type.plugin.singleglobal; }; */ Condition.prototype.run_true = function () { return true; }; Condition.prototype.run_system = function () { var i, len; for (i = 0, len = this.parameters.length; i < len; i++) this.results[i] = this.parameters[i].get(); return cr.xor(this.func.apply(this.runtime.system, this.results), this.inverted); }; Condition.prototype.run_static = function () { var i, len; for (i = 0, len = this.parameters.length; i < len; i++) this.results[i] = this.parameters[i].get(); var ret = this.func.apply(this.behaviortype ? this.behaviortype : this.type, this.results); this.type.applySolToContainer(); return ret; }; Condition.prototype.run_object = function () { var i, j, k, leni, lenj, p, ret, met, inst, s, sol2; var type = this.type; var sol = type.getCurrentSol(); var is_orblock = this.block.orblock && !this.trigger; // triggers in OR blocks need to work normally var offset = 0; var is_contained = type.is_contained; var is_family = type.is_family; var family_index = type.family_index; var beh_index = this.beh_index; var is_beh = (beh_index > -1); var params_vary = this.anyParamVariesPerInstance; var parameters = this.parameters; var results = this.results; var inverted = this.inverted; var func = this.func; var arr, container; if (params_vary) { for (j = 0, lenj = parameters.length; j < lenj; ++j) { p = parameters[j]; if (!p.variesPerInstance) results[j] = p.get(0); } } else { for (j = 0, lenj = parameters.length; j < lenj; ++j) results[j] = parameters[j].get(0); } if (sol.select_all) { cr.clearArray(sol.instances); // clear contents cr.clearArray(sol.else_instances); arr = type.instances; for (i = 0, leni = arr.length; i < leni; ++i) { inst = arr[i]; ; if (params_vary) { for (j = 0, lenj = parameters.length; j < lenj; ++j) { p = parameters[j]; if (p.variesPerInstance) results[j] = p.get(i); // default SOL index is current object } } if (is_beh) { offset = 0; if (is_family) { offset = inst.type.family_beh_map[family_index]; } ret = func.apply(inst.behavior_insts[beh_index + offset], results); } else ret = func.apply(inst, results); met = cr.xor(ret, inverted); if (met) sol.instances.push(inst); else if (is_orblock) // in OR blocks, keep the instances not meeting the condition for subsequent testing sol.else_instances.push(inst); } if (type.finish) type.finish(true); sol.select_all = false; type.applySolToContainer(); return sol.hasObjects(); } else { k = 0; var using_else_instances = (is_orblock && !this.block.isFirstConditionOfType(this)); arr = (using_else_instances ? sol.else_instances : sol.instances); var any_true = false; for (i = 0, leni = arr.length; i < leni; ++i) { inst = arr[i]; ; if (params_vary) { for (j = 0, lenj = parameters.length; j < lenj; ++j) { p = parameters[j]; if (p.variesPerInstance) results[j] = p.get(i); // default SOL index is current object } } if (is_beh) { offset = 0; if (is_family) { offset = inst.type.family_beh_map[family_index]; } ret = func.apply(inst.behavior_insts[beh_index + offset], results); } else ret = func.apply(inst, results); if (cr.xor(ret, inverted)) { any_true = true; if (using_else_instances) { sol.instances.push(inst); if (is_contained) { for (j = 0, lenj = inst.siblings.length; j < lenj; j++) { s = inst.siblings[j]; s.type.getCurrentSol().instances.push(s); } } } else { arr[k] = inst; if (is_contained) { for (j = 0, lenj = inst.siblings.length; j < lenj; j++) { s = inst.siblings[j]; s.type.getCurrentSol().instances[k] = s; } } k++; } } else { if (using_else_instances) { arr[k] = inst; if (is_contained) { for (j = 0, lenj = inst.siblings.length; j < lenj; j++) { s = inst.siblings[j]; s.type.getCurrentSol().else_instances[k] = s; } } k++; } else if (is_orblock) { sol.else_instances.push(inst); if (is_contained) { for (j = 0, lenj = inst.siblings.length; j < lenj; j++) { s = inst.siblings[j]; s.type.getCurrentSol().else_instances.push(s); } } } } } cr.truncateArray(arr, k); if (is_contained) { container = type.container; for (i = 0, leni = container.length; i < leni; i++) { sol2 = container[i].getCurrentSol(); if (using_else_instances) cr.truncateArray(sol2.else_instances, k); else cr.truncateArray(sol2.instances, k); } } var pick_in_finish = any_true; // don't pick in finish() if we're only doing the logic test below if (using_else_instances && !any_true) { for (i = 0, leni = sol.instances.length; i < leni; i++) { inst = sol.instances[i]; if (params_vary) { for (j = 0, lenj = parameters.length; j < lenj; j++) { p = parameters[j]; if (p.variesPerInstance) results[j] = p.get(i); } } if (is_beh) ret = func.apply(inst.behavior_insts[beh_index], results); else ret = func.apply(inst, results); if (cr.xor(ret, inverted)) { any_true = true; break; // got our flag, don't need to test any more } } } if (type.finish) type.finish(pick_in_finish || is_orblock); return is_orblock ? any_true : sol.hasObjects(); } }; cr.condition = Condition; function Action(block, m) { this.block = block; this.sheet = block.sheet; this.runtime = block.runtime; this.parameters = []; this.results = []; this.extra = {}; // for plugins to stow away some custom info this.index = -1; this.anyParamVariesPerInstance = false; this.func = this.runtime.GetObjectReference(m[1]); ; if (m[0] === -1) // system { this.type = null; this.run = this.run_system; this.behaviortype = null; this.beh_index = -1; } else { this.type = this.runtime.types_by_index[m[0]]; ; this.run = this.run_object; if (m[2]) { this.behaviortype = this.type.getBehaviorByName(m[2]); ; this.beh_index = this.type.getBehaviorIndexByName(m[2]); ; } else { this.behaviortype = null; this.beh_index = -1; } } this.sid = m[3]; this.runtime.actsBySid[this.sid.toString()] = this; if (m.length === 6) { var i, len; var em = m[5]; for (i = 0, len = em.length; i < len; i++) { var param = new cr.parameter(this, em[i]); cr.seal(param); this.parameters.push(param); } this.results.length = em.length; } }; Action.prototype.postInit = function () { var i, len, p; for (i = 0, len = this.parameters.length; i < len; i++) { p = this.parameters[i]; p.postInit(); if (p.variesPerInstance) this.anyParamVariesPerInstance = true; } }; Action.prototype.run_system = function () { var runtime = this.runtime; var i, len; var parameters = this.parameters; var results = this.results; for (i = 0, len = parameters.length; i < len; ++i) results[i] = parameters[i].get(); return this.func.apply(runtime.system, results); }; Action.prototype.run_object = function () { var type = this.type; var beh_index = this.beh_index; var family_index = type.family_index; var params_vary = this.anyParamVariesPerInstance; var parameters = this.parameters; var results = this.results; var func = this.func; var instances = type.getCurrentSol().getObjects(); var is_family = type.is_family; var is_beh = (beh_index > -1); var i, j, leni, lenj, p, inst, offset; if (params_vary) { for (j = 0, lenj = parameters.length; j < lenj; ++j) { p = parameters[j]; if (!p.variesPerInstance) results[j] = p.get(0); } } else { for (j = 0, lenj = parameters.length; j < lenj; ++j) results[j] = parameters[j].get(0); } for (i = 0, leni = instances.length; i < leni; ++i) { inst = instances[i]; if (params_vary) { for (j = 0, lenj = parameters.length; j < lenj; ++j) { p = parameters[j]; if (p.variesPerInstance) results[j] = p.get(i); // pass i to use as default SOL index } } if (is_beh) { offset = 0; if (is_family) { offset = inst.type.family_beh_map[family_index]; } func.apply(inst.behavior_insts[beh_index + offset], results); } else func.apply(inst, results); } return false; }; cr.action = Action; var tempValues = []; var tempValuesPtr = -1; function pushTempValue() { tempValuesPtr++; if (tempValues.length === tempValuesPtr) tempValues.push(new cr.expvalue()); return tempValues[tempValuesPtr]; }; function popTempValue() { tempValuesPtr--; }; function Parameter(owner, m) { this.owner = owner; this.block = owner.block; this.sheet = owner.sheet; this.runtime = owner.runtime; this.type = m[0]; this.expression = null; this.solindex = 0; this.get = null; this.combosel = 0; this.layout = null; this.key = 0; this.object = null; this.index = 0; this.varname = null; this.eventvar = null; this.fileinfo = null; this.subparams = null; this.variadicret = null; this.subparams = null; this.variadicret = null; this.variesPerInstance = false; var i, len, param; switch (m[0]) { case 0: // number case 7: // any this.expression = new cr.expNode(this, m[1]); this.solindex = 0; this.get = this.get_exp; break; case 1: // string this.expression = new cr.expNode(this, m[1]); this.solindex = 0; this.get = this.get_exp_str; break; case 5: // layer this.expression = new cr.expNode(this, m[1]); this.solindex = 0; this.get = this.get_layer; break; case 3: // combo case 8: // cmp this.combosel = m[1]; this.get = this.get_combosel; break; case 6: // layout this.layout = this.runtime.layouts[m[1]]; ; this.get = this.get_layout; break; case 9: // keyb this.key = m[1]; this.get = this.get_key; break; case 4: // object this.object = this.runtime.types_by_index[m[1]]; ; this.get = this.get_object; this.block.addSolModifier(this.object); if (this.owner instanceof cr.action) this.block.setSolWriterAfterCnds(); else if (this.block.parent) this.block.parent.setSolWriterAfterCnds(); break; case 10: // instvar this.index = m[1]; if (owner.type && owner.type.is_family) { this.get = this.get_familyvar; this.variesPerInstance = true; } else this.get = this.get_instvar; break; case 11: // eventvar this.varname = m[1]; this.eventvar = null; this.get = this.get_eventvar; break; case 2: // audiofile ["name", ismusic] case 12: // fileinfo "name" this.fileinfo = m[1]; this.get = this.get_audiofile; break; case 13: // variadic this.get = this.get_variadic; this.subparams = []; this.variadicret = []; for (i = 1, len = m.length; i < len; i++) { param = new cr.parameter(this.owner, m[i]); cr.seal(param); this.subparams.push(param); this.variadicret.push(0); } break; default: ; } }; Parameter.prototype.postInit = function () { var i, len; if (this.type === 11) // eventvar { this.eventvar = this.runtime.getEventVariableByName(this.varname, this.block.parent); ; } else if (this.type === 13) // variadic, postInit all sub-params { for (i = 0, len = this.subparams.length; i < len; i++) this.subparams[i].postInit(); } if (this.expression) this.expression.postInit(); }; Parameter.prototype.maybeVaryForType = function (t) { if (this.variesPerInstance) return; // already varies per instance, no need to check again if (!t) return; // never vary for system type if (!t.plugin.singleglobal) { this.variesPerInstance = true; return; } }; Parameter.prototype.setVaries = function () { this.variesPerInstance = true; }; Parameter.prototype.get_exp = function (solindex) { this.solindex = solindex || 0; // default SOL index to use var temp = pushTempValue(); this.expression.get(temp); popTempValue(); return temp.data; // return actual JS value, not expvalue }; Parameter.prototype.get_exp_str = function (solindex) { this.solindex = solindex || 0; // default SOL index to use var temp = pushTempValue(); this.expression.get(temp); popTempValue(); if (cr.is_string(temp.data)) return temp.data; else return ""; }; Parameter.prototype.get_object = function () { return this.object; }; Parameter.prototype.get_combosel = function () { return this.combosel; }; Parameter.prototype.get_layer = function (solindex) { this.solindex = solindex || 0; // default SOL index to use var temp = pushTempValue(); this.expression.get(temp); popTempValue(); if (temp.is_number()) return this.runtime.getLayerByNumber(temp.data); else return this.runtime.getLayerByName(temp.data); } Parameter.prototype.get_layout = function () { return this.layout; }; Parameter.prototype.get_key = function () { return this.key; }; Parameter.prototype.get_instvar = function () { return this.index; }; Parameter.prototype.get_familyvar = function (solindex_) { var solindex = solindex_ || 0; var familytype = this.owner.type; var realtype = null; var sol = familytype.getCurrentSol(); var objs = sol.getObjects(); if (objs.length) realtype = objs[solindex % objs.length].type; else if (sol.else_instances.length) realtype = sol.else_instances[solindex % sol.else_instances.length].type; else if (familytype.instances.length) realtype = familytype.instances[solindex % familytype.instances.length].type; else return 0; return this.index + realtype.family_var_map[familytype.family_index]; }; Parameter.prototype.get_eventvar = function () { return this.eventvar; }; Parameter.prototype.get_audiofile = function () { return this.fileinfo; }; Parameter.prototype.get_variadic = function () { var i, len; for (i = 0, len = this.subparams.length; i < len; i++) { this.variadicret[i] = this.subparams[i].get(); } return this.variadicret; }; cr.parameter = Parameter; function EventVariable(sheet, parent, m) { this.sheet = sheet; this.parent = parent; this.runtime = sheet.runtime; this.solModifiers = []; this.name = m[1]; this.vartype = m[2]; this.initial = m[3]; this.is_static = !!m[4]; this.is_constant = !!m[5]; this.sid = m[6]; this.runtime.varsBySid[this.sid.toString()] = this; this.data = this.initial; // note: also stored in event stack frame for local nonstatic nonconst vars if (this.parent) // local var { if (this.is_static || this.is_constant) this.localIndex = -1; else this.localIndex = this.runtime.stackLocalCount++; this.runtime.all_local_vars.push(this); } else // global var { this.localIndex = -1; this.runtime.all_global_vars.push(this); } }; EventVariable.prototype.postInit = function () { this.solModifiers = findMatchingSolModifier(this.solModifiers); }; EventVariable.prototype.setValue = function (x) { ; var lvs = this.runtime.getCurrentLocalVarStack(); if (!this.parent || this.is_static || !lvs) this.data = x; else // local nonstatic variable: use event stack to keep value at this level of recursion { if (this.localIndex >= lvs.length) lvs.length = this.localIndex + 1; lvs[this.localIndex] = x; } }; EventVariable.prototype.getValue = function () { var lvs = this.runtime.getCurrentLocalVarStack(); if (!this.parent || this.is_static || !lvs || this.is_constant) return this.data; else // local nonstatic variable { if (this.localIndex >= lvs.length) { return this.initial; } if (typeof lvs[this.localIndex] === "undefined") { return this.initial; } return lvs[this.localIndex]; } }; EventVariable.prototype.run = function () { if (this.parent && !this.is_static && !this.is_constant) this.setValue(this.initial); }; cr.eventvariable = EventVariable; function EventInclude(sheet, parent, m) { this.sheet = sheet; this.parent = parent; this.runtime = sheet.runtime; this.solModifiers = []; this.include_sheet = null; // determined in postInit this.include_sheet_name = m[1]; this.active = true; }; EventInclude.prototype.toString = function () { return "include:" + this.include_sheet.toString(); }; EventInclude.prototype.postInit = function () { this.include_sheet = this.runtime.eventsheets[this.include_sheet_name]; ; ; this.sheet.includes.add(this); this.solModifiers = findMatchingSolModifier(this.solModifiers); var p = this.parent; while (p) { if (p.group) p.contained_includes.push(this); p = p.parent; } this.updateActive(); }; EventInclude.prototype.run = function () { if (this.parent) this.runtime.pushCleanSol(this.runtime.types_by_index); if (!this.include_sheet.hasRun) this.include_sheet.run(true); // from include if (this.parent) this.runtime.popSol(this.runtime.types_by_index); }; EventInclude.prototype.updateActive = function () { var p = this.parent; while (p) { if (p.group && !p.group_active) { this.active = false; return; } p = p.parent; } this.active = true; }; EventInclude.prototype.isActive = function () { return this.active; }; cr.eventinclude = EventInclude; function EventStackFrame() { this.temp_parents_arr = []; this.reset(null); cr.seal(this); }; EventStackFrame.prototype.reset = function (cur_event) { this.current_event = cur_event; this.cndindex = 0; this.actindex = 0; cr.clearArray(this.temp_parents_arr); this.last_event_true = false; this.else_branch_ran = false; this.any_true_state = false; }; EventStackFrame.prototype.isModifierAfterCnds = function () { if (this.current_event.solWriterAfterCnds) return true; if (this.cndindex < this.current_event.conditions.length - 1) return !!this.current_event.solModifiers.length; return false; }; cr.eventStackFrame = EventStackFrame; }()); (function() { function ExpNode(owner_, m) { this.owner = owner_; this.runtime = owner_.runtime; this.type = m[0]; ; this.get = [this.eval_int, this.eval_float, this.eval_string, this.eval_unaryminus, this.eval_add, this.eval_subtract, this.eval_multiply, this.eval_divide, this.eval_mod, this.eval_power, this.eval_and, this.eval_or, this.eval_equal, this.eval_notequal, this.eval_less, this.eval_lessequal, this.eval_greater, this.eval_greaterequal, this.eval_conditional, this.eval_system_exp, this.eval_object_exp, this.eval_instvar_exp, this.eval_behavior_exp, this.eval_eventvar_exp][this.type]; var paramsModel = null; this.value = null; this.first = null; this.second = null; this.third = null; this.func = null; this.results = null; this.parameters = null; this.object_type = null; this.beh_index = -1; this.instance_expr = null; this.varindex = -1; this.behavior_type = null; this.varname = null; this.eventvar = null; this.return_string = false; switch (this.type) { case 0: // int case 1: // float case 2: // string this.value = m[1]; break; case 3: // unaryminus this.first = new cr.expNode(owner_, m[1]); break; case 18: // conditional this.first = new cr.expNode(owner_, m[1]); this.second = new cr.expNode(owner_, m[2]); this.third = new cr.expNode(owner_, m[3]); break; case 19: // system_exp this.func = this.runtime.GetObjectReference(m[1]); ; if (this.func === cr.system_object.prototype.exps.random || this.func === cr.system_object.prototype.exps.choose) { this.owner.setVaries(); } this.results = []; this.parameters = []; if (m.length === 3) { paramsModel = m[2]; this.results.length = paramsModel.length + 1; // must also fit 'ret' } else this.results.length = 1; // to fit 'ret' break; case 20: // object_exp this.object_type = this.runtime.types_by_index[m[1]]; ; this.beh_index = -1; this.func = this.runtime.GetObjectReference(m[2]); this.return_string = m[3]; if (cr.plugins_.Function && this.func === cr.plugins_.Function.prototype.exps.Call) { this.owner.setVaries(); } if (m[4]) this.instance_expr = new cr.expNode(owner_, m[4]); else this.instance_expr = null; this.results = []; this.parameters = []; if (m.length === 6) { paramsModel = m[5]; this.results.length = paramsModel.length + 1; } else this.results.length = 1; // to fit 'ret' break; case 21: // instvar_exp this.object_type = this.runtime.types_by_index[m[1]]; ; this.return_string = m[2]; if (m[3]) this.instance_expr = new cr.expNode(owner_, m[3]); else this.instance_expr = null; this.varindex = m[4]; break; case 22: // behavior_exp this.object_type = this.runtime.types_by_index[m[1]]; ; this.behavior_type = this.object_type.getBehaviorByName(m[2]); ; this.beh_index = this.object_type.getBehaviorIndexByName(m[2]); this.func = this.runtime.GetObjectReference(m[3]); this.return_string = m[4]; if (m[5]) this.instance_expr = new cr.expNode(owner_, m[5]); else this.instance_expr = null; this.results = []; this.parameters = []; if (m.length === 7) { paramsModel = m[6]; this.results.length = paramsModel.length + 1; } else this.results.length = 1; // to fit 'ret' break; case 23: // eventvar_exp this.varname = m[1]; this.eventvar = null; // assigned in postInit break; } this.owner.maybeVaryForType(this.object_type); if (this.type >= 4 && this.type <= 17) { this.first = new cr.expNode(owner_, m[1]); this.second = new cr.expNode(owner_, m[2]); } if (paramsModel) { var i, len; for (i = 0, len = paramsModel.length; i < len; i++) this.parameters.push(new cr.expNode(owner_, paramsModel[i])); } cr.seal(this); }; ExpNode.prototype.postInit = function () { if (this.type === 23) // eventvar_exp { this.eventvar = this.owner.runtime.getEventVariableByName(this.varname, this.owner.block.parent); ; } if (this.first) this.first.postInit(); if (this.second) this.second.postInit(); if (this.third) this.third.postInit(); if (this.instance_expr) this.instance_expr.postInit(); if (this.parameters) { var i, len; for (i = 0, len = this.parameters.length; i < len; i++) this.parameters[i].postInit(); } }; var tempValues = []; var tempValuesPtr = -1; function pushTempValue() { ++tempValuesPtr; if (tempValues.length === tempValuesPtr) tempValues.push(new cr.expvalue()); return tempValues[tempValuesPtr]; }; function popTempValue() { --tempValuesPtr; }; function eval_params(parameters, results, temp) { var i, len; for (i = 0, len = parameters.length; i < len; ++i) { parameters[i].get(temp); results[i + 1] = temp.data; // passing actual javascript value as argument instead of expvalue } } ExpNode.prototype.eval_system_exp = function (ret) { var parameters = this.parameters; var results = this.results; results[0] = ret; var temp = pushTempValue(); eval_params(parameters, results, temp); popTempValue(); this.func.apply(this.runtime.system, results); }; ExpNode.prototype.eval_object_exp = function (ret) { var object_type = this.object_type; var results = this.results; var parameters = this.parameters; var instance_expr = this.instance_expr; var func = this.func; var index = this.owner.solindex; // default to parameter's intended SOL index var sol = object_type.getCurrentSol(); var instances = sol.getObjects(); if (!instances.length) { if (sol.else_instances.length) instances = sol.else_instances; else { if (this.return_string) ret.set_string(""); else ret.set_int(0); return; } } results[0] = ret; ret.object_class = object_type; // so expression can access family type if need be var temp = pushTempValue(); eval_params(parameters, results, temp); if (instance_expr) { instance_expr.get(temp); if (temp.is_number()) { index = temp.data; instances = object_type.instances; // pick from all instances, not SOL } } popTempValue(); var len = instances.length; if (index >= len || index <= -len) index %= len; // wraparound if (index < 0) index += len; var returned_val = func.apply(instances[index], results); ; }; ExpNode.prototype.eval_behavior_exp = function (ret) { var object_type = this.object_type; var results = this.results; var parameters = this.parameters; var instance_expr = this.instance_expr; var beh_index = this.beh_index; var func = this.func; var index = this.owner.solindex; // default to parameter's intended SOL index var sol = object_type.getCurrentSol(); var instances = sol.getObjects(); if (!instances.length) { if (sol.else_instances.length) instances = sol.else_instances; else { if (this.return_string) ret.set_string(""); else ret.set_int(0); return; } } results[0] = ret; ret.object_class = object_type; // so expression can access family type if need be var temp = pushTempValue(); eval_params(parameters, results, temp); if (instance_expr) { instance_expr.get(temp); if (temp.is_number()) { index = temp.data; instances = object_type.instances; // pick from all instances, not SOL } } popTempValue(); var len = instances.length; if (index >= len || index <= -len) index %= len; // wraparound if (index < 0) index += len; var inst = instances[index]; var offset = 0; if (object_type.is_family) { offset = inst.type.family_beh_map[object_type.family_index]; } var returned_val = func.apply(inst.behavior_insts[beh_index + offset], results); ; }; ExpNode.prototype.eval_instvar_exp = function (ret) { var instance_expr = this.instance_expr; var object_type = this.object_type; var varindex = this.varindex; var index = this.owner.solindex; // default to parameter's intended SOL index var sol = object_type.getCurrentSol(); var instances = sol.getObjects(); var inst; if (!instances.length) { if (sol.else_instances.length) instances = sol.else_instances; else { if (this.return_string) ret.set_string(""); else ret.set_int(0); return; } } if (instance_expr) { var temp = pushTempValue(); instance_expr.get(temp); if (temp.is_number()) { index = temp.data; var type_instances = object_type.instances; if (type_instances.length !== 0) // avoid NaN result with % { index %= type_instances.length; // wraparound if (index < 0) // offset index += type_instances.length; } inst = object_type.getInstanceByIID(index); var to_ret = inst.instance_vars[varindex]; if (cr.is_string(to_ret)) ret.set_string(to_ret); else ret.set_float(to_ret); popTempValue(); return; // done } popTempValue(); } var len = instances.length; if (index >= len || index <= -len) index %= len; // wraparound if (index < 0) index += len; inst = instances[index]; var offset = 0; if (object_type.is_family) { offset = inst.type.family_var_map[object_type.family_index]; } var to_ret = inst.instance_vars[varindex + offset]; if (cr.is_string(to_ret)) ret.set_string(to_ret); else ret.set_float(to_ret); }; ExpNode.prototype.eval_int = function (ret) { ret.type = cr.exptype.Integer; ret.data = this.value; }; ExpNode.prototype.eval_float = function (ret) { ret.type = cr.exptype.Float; ret.data = this.value; }; ExpNode.prototype.eval_string = function (ret) { ret.type = cr.exptype.String; ret.data = this.value; }; ExpNode.prototype.eval_unaryminus = function (ret) { this.first.get(ret); // retrieve operand if (ret.is_number()) ret.data = -ret.data; }; ExpNode.prototype.eval_add = function (ret) { this.first.get(ret); // left operand var temp = pushTempValue(); this.second.get(temp); // right operand if (ret.is_number() && temp.is_number()) { ret.data += temp.data; // both operands numbers: add if (temp.is_float()) ret.make_float(); } popTempValue(); }; ExpNode.prototype.eval_subtract = function (ret) { this.first.get(ret); // left operand var temp = pushTempValue(); this.second.get(temp); // right operand if (ret.is_number() && temp.is_number()) { ret.data -= temp.data; // both operands numbers: subtract if (temp.is_float()) ret.make_float(); } popTempValue(); }; ExpNode.prototype.eval_multiply = function (ret) { this.first.get(ret); // left operand var temp = pushTempValue(); this.second.get(temp); // right operand if (ret.is_number() && temp.is_number()) { ret.data *= temp.data; // both operands numbers: multiply if (temp.is_float()) ret.make_float(); } popTempValue(); }; ExpNode.prototype.eval_divide = function (ret) { this.first.get(ret); // left operand var temp = pushTempValue(); this.second.get(temp); // right operand if (ret.is_number() && temp.is_number()) { ret.data /= temp.data; // both operands numbers: divide ret.make_float(); } popTempValue(); }; ExpNode.prototype.eval_mod = function (ret) { this.first.get(ret); // left operand var temp = pushTempValue(); this.second.get(temp); // right operand if (ret.is_number() && temp.is_number()) { ret.data %= temp.data; // both operands numbers: modulo if (temp.is_float()) ret.make_float(); } popTempValue(); }; ExpNode.prototype.eval_power = function (ret) { this.first.get(ret); // left operand var temp = pushTempValue(); this.second.get(temp); // right operand if (ret.is_number() && temp.is_number()) { ret.data = Math.pow(ret.data, temp.data); // both operands numbers: raise to power if (temp.is_float()) ret.make_float(); } popTempValue(); }; ExpNode.prototype.eval_and = function (ret) { this.first.get(ret); // left operand var temp = pushTempValue(); this.second.get(temp); // right operand if (temp.is_string() || ret.is_string()) this.eval_and_stringconcat(ret, temp); else this.eval_and_logical(ret, temp); popTempValue(); }; ExpNode.prototype.eval_and_stringconcat = function (ret, temp) { if (ret.is_string() && temp.is_string()) this.eval_and_stringconcat_str_str(ret, temp); else this.eval_and_stringconcat_num(ret, temp); }; ExpNode.prototype.eval_and_stringconcat_str_str = function (ret, temp) { ret.data += temp.data; }; ExpNode.prototype.eval_and_stringconcat_num = function (ret, temp) { if (ret.is_string()) { ret.data += (Math.round(temp.data * 1e10) / 1e10).toString(); } else { ret.set_string(ret.data.toString() + temp.data); } }; ExpNode.prototype.eval_and_logical = function (ret, temp) { ret.set_int(ret.data && temp.data ? 1 : 0); }; ExpNode.prototype.eval_or = function (ret) { this.first.get(ret); // left operand var temp = pushTempValue(); this.second.get(temp); // right operand if (ret.is_number() && temp.is_number()) { if (ret.data || temp.data) ret.set_int(1); else ret.set_int(0); } popTempValue(); }; ExpNode.prototype.eval_conditional = function (ret) { this.first.get(ret); // condition operand if (ret.data) // is true this.second.get(ret); // evaluate second operand to ret else this.third.get(ret); // evaluate third operand to ret }; ExpNode.prototype.eval_equal = function (ret) { this.first.get(ret); // left operand var temp = pushTempValue(); this.second.get(temp); // right operand ret.set_int(ret.data === temp.data ? 1 : 0); popTempValue(); }; ExpNode.prototype.eval_notequal = function (ret) { this.first.get(ret); // left operand var temp = pushTempValue(); this.second.get(temp); // right operand ret.set_int(ret.data !== temp.data ? 1 : 0); popTempValue(); }; ExpNode.prototype.eval_less = function (ret) { this.first.get(ret); // left operand var temp = pushTempValue(); this.second.get(temp); // right operand ret.set_int(ret.data < temp.data ? 1 : 0); popTempValue(); }; ExpNode.prototype.eval_lessequal = function (ret) { this.first.get(ret); // left operand var temp = pushTempValue(); this.second.get(temp); // right operand ret.set_int(ret.data <= temp.data ? 1 : 0); popTempValue(); }; ExpNode.prototype.eval_greater = function (ret) { this.first.get(ret); // left operand var temp = pushTempValue(); this.second.get(temp); // right operand ret.set_int(ret.data > temp.data ? 1 : 0); popTempValue(); }; ExpNode.prototype.eval_greaterequal = function (ret) { this.first.get(ret); // left operand var temp = pushTempValue(); this.second.get(temp); // right operand ret.set_int(ret.data >= temp.data ? 1 : 0); popTempValue(); }; ExpNode.prototype.eval_eventvar_exp = function (ret) { var val = this.eventvar.getValue(); if (cr.is_number(val)) ret.set_float(val); else ret.set_string(val); }; cr.expNode = ExpNode; function ExpValue(type, data) { this.type = type || cr.exptype.Integer; this.data = data || 0; this.object_class = null; ; ; ; if (this.type == cr.exptype.Integer) this.data = Math.floor(this.data); cr.seal(this); }; ExpValue.prototype.is_int = function () { return this.type === cr.exptype.Integer; }; ExpValue.prototype.is_float = function () { return this.type === cr.exptype.Float; }; ExpValue.prototype.is_number = function () { return this.type === cr.exptype.Integer || this.type === cr.exptype.Float; }; ExpValue.prototype.is_string = function () { return this.type === cr.exptype.String; }; ExpValue.prototype.make_int = function () { if (!this.is_int()) { if (this.is_float()) this.data = Math.floor(this.data); // truncate float else if (this.is_string()) this.data = parseInt(this.data, 10); this.type = cr.exptype.Integer; } }; ExpValue.prototype.make_float = function () { if (!this.is_float()) { if (this.is_string()) this.data = parseFloat(this.data); this.type = cr.exptype.Float; } }; ExpValue.prototype.make_string = function () { if (!this.is_string()) { this.data = this.data.toString(); this.type = cr.exptype.String; } }; ExpValue.prototype.set_int = function (val) { ; this.type = cr.exptype.Integer; this.data = Math.floor(val); }; ExpValue.prototype.set_float = function (val) { ; this.type = cr.exptype.Float; this.data = val; }; ExpValue.prototype.set_string = function (val) { ; this.type = cr.exptype.String; this.data = val; }; ExpValue.prototype.set_any = function (val) { if (cr.is_number(val)) { this.type = cr.exptype.Float; this.data = val; } else if (cr.is_string(val)) { this.type = cr.exptype.String; this.data = val.toString(); } else { this.type = cr.exptype.Integer; this.data = 0; } }; cr.expvalue = ExpValue; cr.exptype = { Integer: 0, // emulated; no native integer support in javascript Float: 1, String: 2 }; }()); ; cr.system_object = function (runtime) { this.runtime = runtime; this.waits = []; }; cr.system_object.prototype.saveToJSON = function () { var o = {}; var i, len, j, lenj, p, w, t, sobj; o["waits"] = []; var owaits = o["waits"]; var waitobj; for (i = 0, len = this.waits.length; i < len; i++) { w = this.waits[i]; waitobj = { "t": w.time, "st": w.signaltag, "s": w.signalled, "ev": w.ev.sid, "sm": [], "sols": {} }; if (w.ev.actions[w.actindex]) waitobj["act"] = w.ev.actions[w.actindex].sid; for (j = 0, lenj = w.solModifiers.length; j < lenj; j++) waitobj["sm"].push(w.solModifiers[j].sid); for (p in w.sols) { if (w.sols.hasOwnProperty(p)) { t = this.runtime.types_by_index[parseInt(p, 10)]; ; sobj = { "sa": w.sols[p].sa, "insts": [] }; for (j = 0, lenj = w.sols[p].insts.length; j < lenj; j++) sobj["insts"].push(w.sols[p].insts[j].uid); waitobj["sols"][t.sid.toString()] = sobj; } } owaits.push(waitobj); } return o; }; cr.system_object.prototype.loadFromJSON = function (o) { var owaits = o["waits"]; var i, len, j, lenj, p, w, addWait, e, aindex, t, savedsol, nusol, inst; cr.clearArray(this.waits); for (i = 0, len = owaits.length; i < len; i++) { w = owaits[i]; e = this.runtime.blocksBySid[w["ev"].toString()]; if (!e) continue; // event must've gone missing aindex = -1; for (j = 0, lenj = e.actions.length; j < lenj; j++) { if (e.actions[j].sid === w["act"]) { aindex = j; break; } } if (aindex === -1) continue; // action must've gone missing addWait = {}; addWait.sols = {}; addWait.solModifiers = []; addWait.deleteme = false; addWait.time = w["t"]; addWait.signaltag = w["st"] || ""; addWait.signalled = !!w["s"]; addWait.ev = e; addWait.actindex = aindex; for (j = 0, lenj = w["sm"].length; j < lenj; j++) { t = this.runtime.getObjectTypeBySid(w["sm"][j]); if (t) addWait.solModifiers.push(t); } for (p in w["sols"]) { if (w["sols"].hasOwnProperty(p)) { t = this.runtime.getObjectTypeBySid(parseInt(p, 10)); if (!t) continue; // type must've been deleted savedsol = w["sols"][p]; nusol = { sa: savedsol["sa"], insts: [] }; for (j = 0, lenj = savedsol["insts"].length; j < lenj; j++) { inst = this.runtime.getObjectByUID(savedsol["insts"][j]); if (inst) nusol.insts.push(inst); } addWait.sols[t.index.toString()] = nusol; } } this.waits.push(addWait); } }; (function () { var sysProto = cr.system_object.prototype; function SysCnds() {}; SysCnds.prototype.EveryTick = function() { return true; }; SysCnds.prototype.OnLayoutStart = function() { return true; }; SysCnds.prototype.OnLayoutEnd = function() { return true; }; SysCnds.prototype.Compare = function(x, cmp, y) { return cr.do_cmp(x, cmp, y); }; SysCnds.prototype.CompareTime = function (cmp, t) { var elapsed = this.runtime.kahanTime.sum; if (cmp === 0) { var cnd = this.runtime.getCurrentCondition(); if (!cnd.extra["CompareTime_executed"]) { if (elapsed >= t) { cnd.extra["CompareTime_executed"] = true; return true; } } return false; } return cr.do_cmp(elapsed, cmp, t); }; SysCnds.prototype.LayerVisible = function (layer) { if (!layer) return false; else return layer.visible; }; SysCnds.prototype.LayerEmpty = function (layer) { if (!layer) return false; else return !layer.instances.length; }; SysCnds.prototype.LayerCmpOpacity = function (layer, cmp, opacity_) { if (!layer) return false; return cr.do_cmp(layer.opacity * 100, cmp, opacity_); }; SysCnds.prototype.Repeat = function (count) { var current_frame = this.runtime.getCurrentEventStack(); var current_event = current_frame.current_event; var solModifierAfterCnds = current_frame.isModifierAfterCnds(); var current_loop = this.runtime.pushLoopStack(); var i; if (solModifierAfterCnds) { for (i = 0; i < count && !current_loop.stopped; i++) { this.runtime.pushCopySol(current_event.solModifiers); current_loop.index = i; current_event.retrigger(); this.runtime.popSol(current_event.solModifiers); } } else { for (i = 0; i < count && !current_loop.stopped; i++) { current_loop.index = i; current_event.retrigger(); } } this.runtime.popLoopStack(); return false; }; SysCnds.prototype.While = function (count) { var current_frame = this.runtime.getCurrentEventStack(); var current_event = current_frame.current_event; var solModifierAfterCnds = current_frame.isModifierAfterCnds(); var current_loop = this.runtime.pushLoopStack(); var i; if (solModifierAfterCnds) { for (i = 0; !current_loop.stopped; i++) { this.runtime.pushCopySol(current_event.solModifiers); current_loop.index = i; if (!current_event.retrigger()) // one of the other conditions returned false current_loop.stopped = true; // break this.runtime.popSol(current_event.solModifiers); } } else { for (i = 0; !current_loop.stopped; i++) { current_loop.index = i; if (!current_event.retrigger()) current_loop.stopped = true; } } this.runtime.popLoopStack(); return false; }; SysCnds.prototype.For = function (name, start, end) { var current_frame = this.runtime.getCurrentEventStack(); var current_event = current_frame.current_event; var solModifierAfterCnds = current_frame.isModifierAfterCnds(); var current_loop = this.runtime.pushLoopStack(name); var i; if (end < start) { if (solModifierAfterCnds) { for (i = start; i >= end && !current_loop.stopped; --i) // inclusive to end { this.runtime.pushCopySol(current_event.solModifiers); current_loop.index = i; current_event.retrigger(); this.runtime.popSol(current_event.solModifiers); } } else { for (i = start; i >= end && !current_loop.stopped; --i) // inclusive to end { current_loop.index = i; current_event.retrigger(); } } } else { if (solModifierAfterCnds) { for (i = start; i <= end && !current_loop.stopped; ++i) // inclusive to end { this.runtime.pushCopySol(current_event.solModifiers); current_loop.index = i; current_event.retrigger(); this.runtime.popSol(current_event.solModifiers); } } else { for (i = start; i <= end && !current_loop.stopped; ++i) // inclusive to end { current_loop.index = i; current_event.retrigger(); } } } this.runtime.popLoopStack(); return false; }; var foreach_instancestack = []; var foreach_instanceptr = -1; SysCnds.prototype.ForEach = function (obj) { var sol = obj.getCurrentSol(); foreach_instanceptr++; if (foreach_instancestack.length === foreach_instanceptr) foreach_instancestack.push([]); var instances = foreach_instancestack[foreach_instanceptr]; cr.shallowAssignArray(instances, sol.getObjects()); var current_frame = this.runtime.getCurrentEventStack(); var current_event = current_frame.current_event; var solModifierAfterCnds = current_frame.isModifierAfterCnds(); var current_loop = this.runtime.pushLoopStack(); var i, len, j, lenj, inst, s, sol2; var is_contained = obj.is_contained; if (solModifierAfterCnds) { for (i = 0, len = instances.length; i < len && !current_loop.stopped; i++) { this.runtime.pushCopySol(current_event.solModifiers); inst = instances[i]; sol = obj.getCurrentSol(); sol.select_all = false; cr.clearArray(sol.instances); sol.instances[0] = inst; if (is_contained) { for (j = 0, lenj = inst.siblings.length; j < lenj; j++) { s = inst.siblings[j]; sol2 = s.type.getCurrentSol(); sol2.select_all = false; cr.clearArray(sol2.instances); sol2.instances[0] = s; } } current_loop.index = i; current_event.retrigger(); this.runtime.popSol(current_event.solModifiers); } } else { sol.select_all = false; cr.clearArray(sol.instances); for (i = 0, len = instances.length; i < len && !current_loop.stopped; i++) { inst = instances[i]; sol.instances[0] = inst; if (is_contained) { for (j = 0, lenj = inst.siblings.length; j < lenj; j++) { s = inst.siblings[j]; sol2 = s.type.getCurrentSol(); sol2.select_all = false; cr.clearArray(sol2.instances); sol2.instances[0] = s; } } current_loop.index = i; current_event.retrigger(); } } cr.clearArray(instances); this.runtime.popLoopStack(); foreach_instanceptr--; return false; }; function foreach_sortinstances(a, b) { var va = a.extra["c2_feo_val"]; var vb = b.extra["c2_feo_val"]; if (cr.is_number(va) && cr.is_number(vb)) return va - vb; else { va = "" + va; vb = "" + vb; if (va < vb) return -1; else if (va > vb) return 1; else return 0; } }; SysCnds.prototype.ForEachOrdered = function (obj, exp, order) { var sol = obj.getCurrentSol(); foreach_instanceptr++; if (foreach_instancestack.length === foreach_instanceptr) foreach_instancestack.push([]); var instances = foreach_instancestack[foreach_instanceptr]; cr.shallowAssignArray(instances, sol.getObjects()); var current_frame = this.runtime.getCurrentEventStack(); var current_event = current_frame.current_event; var current_condition = this.runtime.getCurrentCondition(); var solModifierAfterCnds = current_frame.isModifierAfterCnds(); var current_loop = this.runtime.pushLoopStack(); var i, len, j, lenj, inst, s, sol2; for (i = 0, len = instances.length; i < len; i++) { instances[i].extra["c2_feo_val"] = current_condition.parameters[1].get(i); } instances.sort(foreach_sortinstances); if (order === 1) instances.reverse(); var is_contained = obj.is_contained; if (solModifierAfterCnds) { for (i = 0, len = instances.length; i < len && !current_loop.stopped; i++) { this.runtime.pushCopySol(current_event.solModifiers); inst = instances[i]; sol = obj.getCurrentSol(); sol.select_all = false; cr.clearArray(sol.instances); sol.instances[0] = inst; if (is_contained) { for (j = 0, lenj = inst.siblings.length; j < lenj; j++) { s = inst.siblings[j]; sol2 = s.type.getCurrentSol(); sol2.select_all = false; cr.clearArray(sol2.instances); sol2.instances[0] = s; } } current_loop.index = i; current_event.retrigger(); this.runtime.popSol(current_event.solModifiers); } } else { sol.select_all = false; cr.clearArray(sol.instances); for (i = 0, len = instances.length; i < len && !current_loop.stopped; i++) { inst = instances[i]; sol.instances[0] = inst; if (is_contained) { for (j = 0, lenj = inst.siblings.length; j < lenj; j++) { s = inst.siblings[j]; sol2 = s.type.getCurrentSol(); sol2.select_all = false; cr.clearArray(sol2.instances); sol2.instances[0] = s; } } current_loop.index = i; current_event.retrigger(); } } cr.clearArray(instances); this.runtime.popLoopStack(); foreach_instanceptr--; return false; }; SysCnds.prototype.PickByComparison = function (obj_, exp_, cmp_, val_) { var i, len, k, inst; if (!obj_) return; foreach_instanceptr++; if (foreach_instancestack.length === foreach_instanceptr) foreach_instancestack.push([]); var tmp_instances = foreach_instancestack[foreach_instanceptr]; var sol = obj_.getCurrentSol(); cr.shallowAssignArray(tmp_instances, sol.getObjects()); if (sol.select_all) cr.clearArray(sol.else_instances); var current_condition = this.runtime.getCurrentCondition(); for (i = 0, k = 0, len = tmp_instances.length; i < len; i++) { inst = tmp_instances[i]; tmp_instances[k] = inst; exp_ = current_condition.parameters[1].get(i); val_ = current_condition.parameters[3].get(i); if (cr.do_cmp(exp_, cmp_, val_)) { k++; } else { sol.else_instances.push(inst); } } cr.truncateArray(tmp_instances, k); sol.select_all = false; cr.shallowAssignArray(sol.instances, tmp_instances); cr.clearArray(tmp_instances); foreach_instanceptr--; obj_.applySolToContainer(); return !!sol.instances.length; }; SysCnds.prototype.PickByEvaluate = function (obj_, exp_) { var i, len, k, inst; if (!obj_) return; foreach_instanceptr++; if (foreach_instancestack.length === foreach_instanceptr) foreach_instancestack.push([]); var tmp_instances = foreach_instancestack[foreach_instanceptr]; var sol = obj_.getCurrentSol(); cr.shallowAssignArray(tmp_instances, sol.getObjects()); if (sol.select_all) cr.clearArray(sol.else_instances); var current_condition = this.runtime.getCurrentCondition(); for (i = 0, k = 0, len = tmp_instances.length; i < len; i++) { inst = tmp_instances[i]; tmp_instances[k] = inst; exp_ = current_condition.parameters[1].get(i); if (exp_) { k++; } else { sol.else_instances.push(inst); } } cr.truncateArray(tmp_instances, k); sol.select_all = false; cr.shallowAssignArray(sol.instances, tmp_instances); cr.clearArray(tmp_instances); foreach_instanceptr--; obj_.applySolToContainer(); return !!sol.instances.length; }; SysCnds.prototype.TriggerOnce = function () { var cndextra = this.runtime.getCurrentCondition().extra; if (typeof cndextra["TriggerOnce_lastTick"] === "undefined") cndextra["TriggerOnce_lastTick"] = -1; var last_tick = cndextra["TriggerOnce_lastTick"]; var cur_tick = this.runtime.tickcount; cndextra["TriggerOnce_lastTick"] = cur_tick; return this.runtime.layout_first_tick || last_tick !== cur_tick - 1; }; SysCnds.prototype.Every = function (seconds) { var cnd = this.runtime.getCurrentCondition(); var last_time = cnd.extra["Every_lastTime"] || 0; var cur_time = this.runtime.kahanTime.sum; if (typeof cnd.extra["Every_seconds"] === "undefined") cnd.extra["Every_seconds"] = seconds; var this_seconds = cnd.extra["Every_seconds"]; if (cur_time >= last_time + this_seconds) { cnd.extra["Every_lastTime"] = last_time + this_seconds; if (cur_time >= cnd.extra["Every_lastTime"] + 0.04) { cnd.extra["Every_lastTime"] = cur_time; } cnd.extra["Every_seconds"] = seconds; return true; } else if (cur_time < last_time - 0.1) { cnd.extra["Every_lastTime"] = cur_time; } return false; }; SysCnds.prototype.PickNth = function (obj, index) { if (!obj) return false; var sol = obj.getCurrentSol(); var instances = sol.getObjects(); index = cr.floor(index); if (index < 0 || index >= instances.length) return false; var inst = instances[index]; sol.pick_one(inst); obj.applySolToContainer(); return true; }; SysCnds.prototype.PickRandom = function (obj) { if (!obj) return false; var sol = obj.getCurrentSol(); var instances = sol.getObjects(); var index = cr.floor(Math.random() * instances.length); if (index >= instances.length) return false; var inst = instances[index]; sol.pick_one(inst); obj.applySolToContainer(); return true; }; SysCnds.prototype.CompareVar = function (v, cmp, val) { return cr.do_cmp(v.getValue(), cmp, val); }; SysCnds.prototype.IsGroupActive = function (group) { var g = this.runtime.groups_by_name[group.toLowerCase()]; return g && g.group_active; }; SysCnds.prototype.IsPreview = function () { return typeof cr_is_preview !== "undefined"; }; SysCnds.prototype.PickAll = function (obj) { if (!obj) return false; if (!obj.instances.length) return false; var sol = obj.getCurrentSol(); sol.select_all = true; obj.applySolToContainer(); return true; }; SysCnds.prototype.IsMobile = function () { return this.runtime.isMobile; }; SysCnds.prototype.CompareBetween = function (x, a, b) { return x >= a && x <= b; }; SysCnds.prototype.Else = function () { var current_frame = this.runtime.getCurrentEventStack(); if (current_frame.else_branch_ran) return false; // another event in this else-if chain has run else return !current_frame.last_event_true; /* var current_frame = this.runtime.getCurrentEventStack(); var current_event = current_frame.current_event; var prev_event = current_event.prev_block; if (!prev_event) return false; if (prev_event.is_logical) return !this.runtime.last_event_true; var i, len, j, lenj, s, sol, temp, inst, any_picked = false; for (i = 0, len = prev_event.cndReferences.length; i < len; i++) { s = prev_event.cndReferences[i]; sol = s.getCurrentSol(); if (sol.select_all || sol.instances.length === s.instances.length) { sol.select_all = false; sol.instances.length = 0; } else { if (sol.instances.length === 1 && sol.else_instances.length === 0 && s.instances.length >= 2) { inst = sol.instances[0]; sol.instances.length = 0; for (j = 0, lenj = s.instances.length; j < lenj; j++) { if (s.instances[j] != inst) sol.instances.push(s.instances[j]); } any_picked = true; } else { temp = sol.instances; sol.instances = sol.else_instances; sol.else_instances = temp; any_picked = true; } } } return any_picked; */ }; SysCnds.prototype.OnLoadFinished = function () { return true; }; SysCnds.prototype.OnCanvasSnapshot = function () { return true; }; SysCnds.prototype.EffectsSupported = function () { return !!this.runtime.glwrap; }; SysCnds.prototype.OnSaveComplete = function () { return true; }; SysCnds.prototype.OnSaveFailed = function () { return true; }; SysCnds.prototype.OnLoadComplete = function () { return true; }; SysCnds.prototype.OnLoadFailed = function () { return true; }; SysCnds.prototype.ObjectUIDExists = function (u) { return !!this.runtime.getObjectByUID(u); }; SysCnds.prototype.IsOnPlatform = function (p) { var rt = this.runtime; switch (p) { case 0: // HTML5 website return !rt.isDomFree && !rt.isNodeWebkit && !rt.isCordova && !rt.isWinJS && !rt.isWindowsPhone8 && !rt.isBlackberry10 && !rt.isAmazonWebApp; case 1: // iOS return rt.isiOS; case 2: // Android return rt.isAndroid; case 3: // Windows 8 return rt.isWindows8App; case 4: // Windows Phone 8 return rt.isWindowsPhone8; case 5: // Blackberry 10 return rt.isBlackberry10; case 6: // Tizen return rt.isTizen; case 7: // CocoonJS return rt.isCocoonJs; case 8: // Cordova return rt.isCordova; case 9: // Scirra Arcade return rt.isArcade; case 10: // node-webkit return rt.isNodeWebkit; case 11: // crosswalk return rt.isCrosswalk; case 12: // amazon webapp return rt.isAmazonWebApp; case 13: // windows 10 app return rt.isWindows10; default: // should not be possible return false; } }; var cacheRegex = null; var lastRegex = ""; var lastFlags = ""; function getRegex(regex_, flags_) { if (!cacheRegex || regex_ !== lastRegex || flags_ !== lastFlags) { cacheRegex = new RegExp(regex_, flags_); lastRegex = regex_; lastFlags = flags_; } cacheRegex.lastIndex = 0; // reset return cacheRegex; }; SysCnds.prototype.RegexTest = function (str_, regex_, flags_) { var regex = getRegex(regex_, flags_); return regex.test(str_); }; var tmp_arr = []; SysCnds.prototype.PickOverlappingPoint = function (obj_, x_, y_) { if (!obj_) return false; var sol = obj_.getCurrentSol(); var instances = sol.getObjects(); var current_event = this.runtime.getCurrentEventStack().current_event; var orblock = current_event.orblock; var cnd = this.runtime.getCurrentCondition(); var i, len, inst, pick; if (sol.select_all) { cr.shallowAssignArray(tmp_arr, instances); cr.clearArray(sol.else_instances); sol.select_all = false; cr.clearArray(sol.instances); } else { if (orblock) { cr.shallowAssignArray(tmp_arr, sol.else_instances); cr.clearArray(sol.else_instances); } else { cr.shallowAssignArray(tmp_arr, instances); cr.clearArray(sol.instances); } } for (i = 0, len = tmp_arr.length; i < len; ++i) { inst = tmp_arr[i]; inst.update_bbox(); pick = cr.xor(inst.contains_pt(x_, y_), cnd.inverted); if (pick) sol.instances.push(inst); else sol.else_instances.push(inst); } obj_.applySolToContainer(); return cr.xor(!!sol.instances.length, cnd.inverted); }; SysCnds.prototype.IsNaN = function (n) { return !!isNaN(n); }; SysCnds.prototype.AngleWithin = function (a1, within, a2) { return cr.angleDiff(cr.to_radians(a1), cr.to_radians(a2)) <= cr.to_radians(within); }; SysCnds.prototype.IsClockwiseFrom = function (a1, a2) { return cr.angleClockwise(cr.to_radians(a1), cr.to_radians(a2)); }; SysCnds.prototype.IsBetweenAngles = function (a, la, ua) { var angle = cr.to_clamped_radians(a); var lower = cr.to_clamped_radians(la); var upper = cr.to_clamped_radians(ua); var obtuse = (!cr.angleClockwise(upper, lower)); if (obtuse) return !(!cr.angleClockwise(angle, lower) && cr.angleClockwise(angle, upper)); else return cr.angleClockwise(angle, lower) && !cr.angleClockwise(angle, upper); }; SysCnds.prototype.IsValueType = function (x, t) { if (typeof x === "number") return t === 0; else // string return t === 1; }; sysProto.cnds = new SysCnds(); function SysActs() {}; SysActs.prototype.GoToLayout = function (to) { if (this.runtime.isloading) return; // cannot change layout while loading on loader layout if (this.runtime.changelayout) return; // already changing to a different layout ; this.runtime.changelayout = to; }; SysActs.prototype.NextPrevLayout = function (prev) { if (this.runtime.isloading) return; // cannot change layout while loading on loader layout if (this.runtime.changelayout) return; // already changing to a different layout var index = this.runtime.layouts_by_index.indexOf(this.runtime.running_layout); if (prev && index === 0) return; // cannot go to previous layout from first layout if (!prev && index === this.runtime.layouts_by_index.length - 1) return; // cannot go to next layout from last layout var to = this.runtime.layouts_by_index[index + (prev ? -1 : 1)]; ; this.runtime.changelayout = to; }; SysActs.prototype.CreateObject = function (obj, layer, x, y) { if (!layer || !obj) return; var inst = this.runtime.createInstance(obj, layer, x, y); if (!inst) return; this.runtime.isInOnDestroy++; var i, len, s; this.runtime.trigger(Object.getPrototypeOf(obj.plugin).cnds.OnCreated, inst); if (inst.is_contained) { for (i = 0, len = inst.siblings.length; i < len; i++) { s = inst.siblings[i]; this.runtime.trigger(Object.getPrototypeOf(s.type.plugin).cnds.OnCreated, s); } } this.runtime.isInOnDestroy--; var sol = obj.getCurrentSol(); sol.select_all = false; cr.clearArray(sol.instances); sol.instances[0] = inst; if (inst.is_contained) { for (i = 0, len = inst.siblings.length; i < len; i++) { s = inst.siblings[i]; sol = s.type.getCurrentSol(); sol.select_all = false; cr.clearArray(sol.instances); sol.instances[0] = s; } } }; SysActs.prototype.SetLayerVisible = function (layer, visible_) { if (!layer) return; if (layer.visible !== visible_) { layer.visible = visible_; this.runtime.redraw = true; } }; SysActs.prototype.SetLayerOpacity = function (layer, opacity_) { if (!layer) return; opacity_ = cr.clamp(opacity_ / 100, 0, 1); if (layer.opacity !== opacity_) { layer.opacity = opacity_; this.runtime.redraw = true; } }; SysActs.prototype.SetLayerScaleRate = function (layer, sr) { if (!layer) return; if (layer.zoomRate !== sr) { layer.zoomRate = sr; this.runtime.redraw = true; } }; SysActs.prototype.SetLayerForceOwnTexture = function (layer, f) { if (!layer) return; f = !!f; if (layer.forceOwnTexture !== f) { layer.forceOwnTexture = f; this.runtime.redraw = true; } }; SysActs.prototype.SetLayoutScale = function (s) { if (!this.runtime.running_layout) return; if (this.runtime.running_layout.scale !== s) { this.runtime.running_layout.scale = s; this.runtime.running_layout.boundScrolling(); this.runtime.redraw = true; } }; SysActs.prototype.ScrollX = function(x) { this.runtime.running_layout.scrollToX(x); }; SysActs.prototype.ScrollY = function(y) { this.runtime.running_layout.scrollToY(y); }; SysActs.prototype.Scroll = function(x, y) { this.runtime.running_layout.scrollToX(x); this.runtime.running_layout.scrollToY(y); }; SysActs.prototype.ScrollToObject = function(obj) { var inst = obj.getFirstPicked(); if (inst) { this.runtime.running_layout.scrollToX(inst.x); this.runtime.running_layout.scrollToY(inst.y); } }; SysActs.prototype.SetVar = function(v, x) { ; if (v.vartype === 0) { if (cr.is_number(x)) v.setValue(x); else v.setValue(parseFloat(x)); } else if (v.vartype === 1) v.setValue(x.toString()); }; SysActs.prototype.AddVar = function(v, x) { ; if (v.vartype === 0) { if (cr.is_number(x)) v.setValue(v.getValue() + x); else v.setValue(v.getValue() + parseFloat(x)); } else if (v.vartype === 1) v.setValue(v.getValue() + x.toString()); }; SysActs.prototype.SubVar = function(v, x) { ; if (v.vartype === 0) { if (cr.is_number(x)) v.setValue(v.getValue() - x); else v.setValue(v.getValue() - parseFloat(x)); } }; SysActs.prototype.SetGroupActive = function (group, active) { var g = this.runtime.groups_by_name[group.toLowerCase()]; if (!g) return; switch (active) { case 0: g.setGroupActive(false); break; case 1: g.setGroupActive(true); break; case 2: g.setGroupActive(!g.group_active); break; } }; SysActs.prototype.SetTimescale = function (ts_) { var ts = ts_; if (ts < 0) ts = 0; this.runtime.timescale = ts; }; SysActs.prototype.SetObjectTimescale = function (obj, ts_) { var ts = ts_; if (ts < 0) ts = 0; if (!obj) return; var sol = obj.getCurrentSol(); var instances = sol.getObjects(); var i, len; for (i = 0, len = instances.length; i < len; i++) { instances[i].my_timescale = ts; } }; SysActs.prototype.RestoreObjectTimescale = function (obj) { if (!obj) return false; var sol = obj.getCurrentSol(); var instances = sol.getObjects(); var i, len; for (i = 0, len = instances.length; i < len; i++) { instances[i].my_timescale = -1.0; } }; var waitobjrecycle = []; function allocWaitObject() { var w; if (waitobjrecycle.length) w = waitobjrecycle.pop(); else { w = {}; w.sols = {}; w.solModifiers = []; } w.deleteme = false; return w; }; function freeWaitObject(w) { cr.wipe(w.sols); cr.clearArray(w.solModifiers); waitobjrecycle.push(w); }; var solstateobjects = []; function allocSolStateObject() { var s; if (solstateobjects.length) s = solstateobjects.pop(); else { s = {}; s.insts = []; } s.sa = false; return s; }; function freeSolStateObject(s) { cr.clearArray(s.insts); solstateobjects.push(s); }; SysActs.prototype.Wait = function (seconds) { if (seconds < 0) return; var i, len, s, t, ss; var evinfo = this.runtime.getCurrentEventStack(); var waitobj = allocWaitObject(); waitobj.time = this.runtime.kahanTime.sum + seconds; waitobj.signaltag = ""; waitobj.signalled = false; waitobj.ev = evinfo.current_event; waitobj.actindex = evinfo.actindex + 1; // pointing at next action for (i = 0, len = this.runtime.types_by_index.length; i < len; i++) { t = this.runtime.types_by_index[i]; s = t.getCurrentSol(); if (s.select_all && evinfo.current_event.solModifiers.indexOf(t) === -1) continue; waitobj.solModifiers.push(t); ss = allocSolStateObject(); ss.sa = s.select_all; cr.shallowAssignArray(ss.insts, s.instances); waitobj.sols[i.toString()] = ss; } this.waits.push(waitobj); return true; }; SysActs.prototype.WaitForSignal = function (tag) { var i, len, s, t, ss; var evinfo = this.runtime.getCurrentEventStack(); var waitobj = allocWaitObject(); waitobj.time = -1; waitobj.signaltag = tag.toLowerCase(); waitobj.signalled = false; waitobj.ev = evinfo.current_event; waitobj.actindex = evinfo.actindex + 1; // pointing at next action for (i = 0, len = this.runtime.types_by_index.length; i < len; i++) { t = this.runtime.types_by_index[i]; s = t.getCurrentSol(); if (s.select_all && evinfo.current_event.solModifiers.indexOf(t) === -1) continue; waitobj.solModifiers.push(t); ss = allocSolStateObject(); ss.sa = s.select_all; cr.shallowAssignArray(ss.insts, s.instances); waitobj.sols[i.toString()] = ss; } this.waits.push(waitobj); return true; }; SysActs.prototype.Signal = function (tag) { var lowertag = tag.toLowerCase(); var i, len, w; for (i = 0, len = this.waits.length; i < len; ++i) { w = this.waits[i]; if (w.time !== -1) continue; // timer wait, ignore if (w.signaltag === lowertag) // waiting for this signal w.signalled = true; // will run on next check } }; SysActs.prototype.SetLayerScale = function (layer, scale) { if (!layer) return; if (layer.scale === scale) return; layer.scale = scale; this.runtime.redraw = true; }; SysActs.prototype.ResetGlobals = function () { var i, len, g; for (i = 0, len = this.runtime.all_global_vars.length; i < len; i++) { g = this.runtime.all_global_vars[i]; g.data = g.initial; } }; SysActs.prototype.SetLayoutAngle = function (a) { a = cr.to_radians(a); a = cr.clamp_angle(a); if (this.runtime.running_layout) { if (this.runtime.running_layout.angle !== a) { this.runtime.running_layout.angle = a; this.runtime.redraw = true; } } }; SysActs.prototype.SetLayerAngle = function (layer, a) { if (!layer) return; a = cr.to_radians(a); a = cr.clamp_angle(a); if (layer.angle === a) return; layer.angle = a; this.runtime.redraw = true; }; SysActs.prototype.SetLayerParallax = function (layer, px, py) { if (!layer) return; if (layer.parallaxX === px / 100 && layer.parallaxY === py / 100) return; layer.parallaxX = px / 100; layer.parallaxY = py / 100; if (layer.parallaxX !== 1 || layer.parallaxY !== 1) { var i, len, instances = layer.instances; for (i = 0, len = instances.length; i < len; ++i) { instances[i].type.any_instance_parallaxed = true; } } this.runtime.redraw = true; }; SysActs.prototype.SetLayerBackground = function (layer, c) { if (!layer) return; var r = cr.GetRValue(c); var g = cr.GetGValue(c); var b = cr.GetBValue(c); if (layer.background_color[0] === r && layer.background_color[1] === g && layer.background_color[2] === b) return; layer.background_color[0] = r; layer.background_color[1] = g; layer.background_color[2] = b; this.runtime.redraw = true; }; SysActs.prototype.SetLayerTransparent = function (layer, t) { if (!layer) return; if (!!t === !!layer.transparent) return; layer.transparent = !!t; this.runtime.redraw = true; }; SysActs.prototype.SetLayerBlendMode = function (layer, bm) { if (!layer) return; if (layer.blend_mode === bm) return; layer.blend_mode = bm; layer.compositeOp = cr.effectToCompositeOp(layer.blend_mode); if (this.runtime.gl) cr.setGLBlend(layer, layer.blend_mode, this.runtime.gl); this.runtime.redraw = true; }; SysActs.prototype.StopLoop = function () { if (this.runtime.loop_stack_index < 0) return; // no loop currently running this.runtime.getCurrentLoop().stopped = true; }; SysActs.prototype.GoToLayoutByName = function (layoutname) { if (this.runtime.isloading) return; // cannot change layout while loading on loader layout if (this.runtime.changelayout) return; // already changing to different layout ; var l; for (l in this.runtime.layouts) { if (this.runtime.layouts.hasOwnProperty(l) && cr.equals_nocase(l, layoutname)) { this.runtime.changelayout = this.runtime.layouts[l]; return; } } }; SysActs.prototype.RestartLayout = function (layoutname) { if (this.runtime.isloading) return; // cannot restart loader layouts if (this.runtime.changelayout) return; // already changing to a different layout ; if (!this.runtime.running_layout) return; this.runtime.changelayout = this.runtime.running_layout; var i, len, g; for (i = 0, len = this.runtime.allGroups.length; i < len; i++) { g = this.runtime.allGroups[i]; g.setGroupActive(g.initially_activated); } }; SysActs.prototype.SnapshotCanvas = function (format_, quality_) { this.runtime.doCanvasSnapshot(format_ === 0 ? "image/png" : "image/jpeg", quality_ / 100); }; SysActs.prototype.SetCanvasSize = function (w, h) { if (w <= 0 || h <= 0) return; var mode = this.runtime.fullscreen_mode; var isfullscreen = (document["mozFullScreen"] || document["webkitIsFullScreen"] || !!document["msFullscreenElement"] || document["fullScreen"] || this.runtime.isNodeFullscreen); if (isfullscreen && this.runtime.fullscreen_scaling > 0) mode = this.runtime.fullscreen_scaling; if (mode === 0) { this.runtime["setSize"](w, h, true); } else { this.runtime.original_width = w; this.runtime.original_height = h; this.runtime["setSize"](this.runtime.lastWindowWidth, this.runtime.lastWindowHeight, true); } }; SysActs.prototype.SetLayoutEffectEnabled = function (enable_, effectname_) { if (!this.runtime.running_layout || !this.runtime.glwrap) return; var et = this.runtime.running_layout.getEffectByName(effectname_); if (!et) return; // effect name not found var enable = (enable_ === 1); if (et.active == enable) return; // no change et.active = enable; this.runtime.running_layout.updateActiveEffects(); this.runtime.redraw = true; }; SysActs.prototype.SetLayerEffectEnabled = function (layer, enable_, effectname_) { if (!layer || !this.runtime.glwrap) return; var et = layer.getEffectByName(effectname_); if (!et) return; // effect name not found var enable = (enable_ === 1); if (et.active == enable) return; // no change et.active = enable; layer.updateActiveEffects(); this.runtime.redraw = true; }; SysActs.prototype.SetLayoutEffectParam = function (effectname_, index_, value_) { if (!this.runtime.running_layout || !this.runtime.glwrap) return; var et = this.runtime.running_layout.getEffectByName(effectname_); if (!et) return; // effect name not found var params = this.runtime.running_layout.effect_params[et.index]; index_ = Math.floor(index_); if (index_ < 0 || index_ >= params.length) return; // effect index out of bounds if (this.runtime.glwrap.getProgramParameterType(et.shaderindex, index_) === 1) value_ /= 100.0; if (params[index_] === value_) return; // no change params[index_] = value_; if (et.active) this.runtime.redraw = true; }; SysActs.prototype.SetLayerEffectParam = function (layer, effectname_, index_, value_) { if (!layer || !this.runtime.glwrap) return; var et = layer.getEffectByName(effectname_); if (!et) return; // effect name not found var params = layer.effect_params[et.index]; index_ = Math.floor(index_); if (index_ < 0 || index_ >= params.length) return; // effect index out of bounds if (this.runtime.glwrap.getProgramParameterType(et.shaderindex, index_) === 1) value_ /= 100.0; if (params[index_] === value_) return; // no change params[index_] = value_; if (et.active) this.runtime.redraw = true; }; SysActs.prototype.SaveState = function (slot_) { this.runtime.saveToSlot = slot_; }; SysActs.prototype.LoadState = function (slot_) { this.runtime.loadFromSlot = slot_; }; SysActs.prototype.LoadStateJSON = function (jsonstr_) { this.runtime.loadFromJson = jsonstr_; }; SysActs.prototype.SetHalfFramerateMode = function (set_) { this.runtime.halfFramerateMode = (set_ !== 0); }; SysActs.prototype.SetFullscreenQuality = function (q) { var isfullscreen = (document["mozFullScreen"] || document["webkitIsFullScreen"] || !!document["msFullscreenElement"] || document["fullScreen"] || this.isNodeFullscreen); if (!isfullscreen && this.runtime.fullscreen_mode === 0) return; this.runtime.wantFullscreenScalingQuality = (q !== 0); this.runtime["setSize"](this.runtime.lastWindowWidth, this.runtime.lastWindowHeight, true); }; SysActs.prototype.ResetPersisted = function () { var i, len; for (i = 0, len = this.runtime.layouts_by_index.length; i < len; ++i) { this.runtime.layouts_by_index[i].persist_data = {}; this.runtime.layouts_by_index[i].first_visit = true; } }; SysActs.prototype.RecreateInitialObjects = function (obj, x1, y1, x2, y2) { if (!obj) return; this.runtime.running_layout.recreateInitialObjects(obj, x1, y1, x2, y2); }; SysActs.prototype.SetPixelRounding = function (m) { this.runtime.pixel_rounding = (m !== 0); this.runtime.redraw = true; }; SysActs.prototype.SetMinimumFramerate = function (f) { if (f < 1) f = 1; if (f > 120) f = 120; this.runtime.minimumFramerate = f; }; function SortZOrderList(a, b) { var layerA = a[0]; var layerB = b[0]; var diff = layerA - layerB; if (diff !== 0) return diff; var indexA = a[1]; var indexB = b[1]; return indexA - indexB; }; function SortInstancesByValue(a, b) { return a[1] - b[1]; }; SysActs.prototype.SortZOrderByInstVar = function (obj, iv) { if (!obj) return; var i, len, inst, value, r, layer, toZ; var sol = obj.getCurrentSol(); var pickedInstances = sol.getObjects(); var zOrderList = []; var instValues = []; var layout = this.runtime.running_layout; var isFamily = obj.is_family; var familyIndex = obj.family_index; for (i = 0, len = pickedInstances.length; i < len; ++i) { inst = pickedInstances[i]; if (!inst.layer) continue; // not a world instance if (isFamily) value = inst.instance_vars[iv + inst.type.family_var_map[familyIndex]]; else value = inst.instance_vars[iv]; zOrderList.push([ inst.layer.index, inst.get_zindex() ]); instValues.push([ inst, value ]); } if (!zOrderList.length) return; // no instances were world instances zOrderList.sort(SortZOrderList); instValues.sort(SortInstancesByValue); for (i = 0, len = zOrderList.length; i < len; ++i) { inst = instValues[i][0]; // instance in the order we want layer = layout.layers[zOrderList[i][0]]; // layer to put it on toZ = zOrderList[i][1]; // Z index on that layer to put it if (layer.instances[toZ] !== inst) // not already got this instance there { layer.instances[toZ] = inst; // update instance inst.layer = layer; // update instance's layer reference (could have changed) layer.setZIndicesStaleFrom(toZ); // mark Z indices stale from this point since they have changed } } }; sysProto.acts = new SysActs(); function SysExps() {}; SysExps.prototype["int"] = function(ret, x) { if (cr.is_string(x)) { ret.set_int(parseInt(x, 10)); if (isNaN(ret.data)) ret.data = 0; } else ret.set_int(x); }; SysExps.prototype["float"] = function(ret, x) { if (cr.is_string(x)) { ret.set_float(parseFloat(x)); if (isNaN(ret.data)) ret.data = 0; } else ret.set_float(x); }; SysExps.prototype.str = function(ret, x) { if (cr.is_string(x)) ret.set_string(x); else ret.set_string(x.toString()); }; SysExps.prototype.len = function(ret, x) { ret.set_int(x.length || 0); }; SysExps.prototype.random = function (ret, a, b) { if (b === undefined) { ret.set_float(Math.random() * a); } else { ret.set_float(Math.random() * (b - a) + a); } }; SysExps.prototype.sqrt = function(ret, x) { ret.set_float(Math.sqrt(x)); }; SysExps.prototype.abs = function(ret, x) { ret.set_float(Math.abs(x)); }; SysExps.prototype.round = function(ret, x) { ret.set_int(Math.round(x)); }; SysExps.prototype.floor = function(ret, x) { ret.set_int(Math.floor(x)); }; SysExps.prototype.ceil = function(ret, x) { ret.set_int(Math.ceil(x)); }; SysExps.prototype.sin = function(ret, x) { ret.set_float(Math.sin(cr.to_radians(x))); }; SysExps.prototype.cos = function(ret, x) { ret.set_float(Math.cos(cr.to_radians(x))); }; SysExps.prototype.tan = function(ret, x) { ret.set_float(Math.tan(cr.to_radians(x))); }; SysExps.prototype.asin = function(ret, x) { ret.set_float(cr.to_degrees(Math.asin(x))); }; SysExps.prototype.acos = function(ret, x) { ret.set_float(cr.to_degrees(Math.acos(x))); }; SysExps.prototype.atan = function(ret, x) { ret.set_float(cr.to_degrees(Math.atan(x))); }; SysExps.prototype.exp = function(ret, x) { ret.set_float(Math.exp(x)); }; SysExps.prototype.ln = function(ret, x) { ret.set_float(Math.log(x)); }; SysExps.prototype.log10 = function(ret, x) { ret.set_float(Math.log(x) / Math.LN10); }; SysExps.prototype.max = function(ret) { var max_ = arguments[1]; if (typeof max_ !== "number") max_ = 0; var i, len, a; for (i = 2, len = arguments.length; i < len; i++) { a = arguments[i]; if (typeof a !== "number") continue; // ignore non-numeric types if (max_ < a) max_ = a; } ret.set_float(max_); }; SysExps.prototype.min = function(ret) { var min_ = arguments[1]; if (typeof min_ !== "number") min_ = 0; var i, len, a; for (i = 2, len = arguments.length; i < len; i++) { a = arguments[i]; if (typeof a !== "number") continue; // ignore non-numeric types if (min_ > a) min_ = a; } ret.set_float(min_); }; SysExps.prototype.dt = function(ret) { ret.set_float(this.runtime.dt); }; SysExps.prototype.timescale = function(ret) { ret.set_float(this.runtime.timescale); }; SysExps.prototype.wallclocktime = function(ret) { ret.set_float((Date.now() - this.runtime.start_time) / 1000.0); }; SysExps.prototype.time = function(ret) { ret.set_float(this.runtime.kahanTime.sum); }; SysExps.prototype.tickcount = function(ret) { ret.set_int(this.runtime.tickcount); }; SysExps.prototype.objectcount = function(ret) { ret.set_int(this.runtime.objectcount); }; SysExps.prototype.fps = function(ret) { ret.set_int(this.runtime.fps); }; SysExps.prototype.loopindex = function(ret, name_) { var loop, i, len; if (!this.runtime.loop_stack.length) { ret.set_int(0); return; } if (name_) { for (i = this.runtime.loop_stack_index; i >= 0; --i) { loop = this.runtime.loop_stack[i]; if (loop.name === name_) { ret.set_int(loop.index); return; } } ret.set_int(0); } else { loop = this.runtime.getCurrentLoop(); ret.set_int(loop ? loop.index : -1); } }; SysExps.prototype.distance = function(ret, x1, y1, x2, y2) { ret.set_float(cr.distanceTo(x1, y1, x2, y2)); }; SysExps.prototype.angle = function(ret, x1, y1, x2, y2) { ret.set_float(cr.to_degrees(cr.angleTo(x1, y1, x2, y2))); }; SysExps.prototype.scrollx = function(ret) { ret.set_float(this.runtime.running_layout.scrollX); }; SysExps.prototype.scrolly = function(ret) { ret.set_float(this.runtime.running_layout.scrollY); }; SysExps.prototype.newline = function(ret) { ret.set_string("\n"); }; SysExps.prototype.lerp = function(ret, a, b, x) { ret.set_float(cr.lerp(a, b, x)); }; SysExps.prototype.qarp = function(ret, a, b, c, x) { ret.set_float(cr.qarp(a, b, c, x)); }; SysExps.prototype.cubic = function(ret, a, b, c, d, x) { ret.set_float(cr.cubic(a, b, c, d, x)); }; SysExps.prototype.cosp = function(ret, a, b, x) { ret.set_float(cr.cosp(a, b, x)); }; SysExps.prototype.windowwidth = function(ret) { ret.set_int(this.runtime.width); }; SysExps.prototype.windowheight = function(ret) { ret.set_int(this.runtime.height); }; SysExps.prototype.uppercase = function(ret, str) { ret.set_string(cr.is_string(str) ? str.toUpperCase() : ""); }; SysExps.prototype.lowercase = function(ret, str) { ret.set_string(cr.is_string(str) ? str.toLowerCase() : ""); }; SysExps.prototype.clamp = function(ret, x, l, u) { if (x < l) ret.set_float(l); else if (x > u) ret.set_float(u); else ret.set_float(x); }; SysExps.prototype.layerscale = function (ret, layerparam) { var layer = this.runtime.getLayer(layerparam); if (!layer) ret.set_float(0); else ret.set_float(layer.scale); }; SysExps.prototype.layeropacity = function (ret, layerparam) { var layer = this.runtime.getLayer(layerparam); if (!layer) ret.set_float(0); else ret.set_float(layer.opacity * 100); }; SysExps.prototype.layerscalerate = function (ret, layerparam) { var layer = this.runtime.getLayer(layerparam); if (!layer) ret.set_float(0); else ret.set_float(layer.zoomRate); }; SysExps.prototype.layerparallaxx = function (ret, layerparam) { var layer = this.runtime.getLayer(layerparam); if (!layer) ret.set_float(0); else ret.set_float(layer.parallaxX * 100); }; SysExps.prototype.layerparallaxy = function (ret, layerparam) { var layer = this.runtime.getLayer(layerparam); if (!layer) ret.set_float(0); else ret.set_float(layer.parallaxY * 100); }; SysExps.prototype.layerindex = function (ret, layerparam) { var layer = this.runtime.getLayer(layerparam); if (!layer) ret.set_int(-1); else ret.set_int(layer.index); }; SysExps.prototype.layoutscale = function (ret) { if (this.runtime.running_layout) ret.set_float(this.runtime.running_layout.scale); else ret.set_float(0); }; SysExps.prototype.layoutangle = function (ret) { ret.set_float(cr.to_degrees(this.runtime.running_layout.angle)); }; SysExps.prototype.layerangle = function (ret, layerparam) { var layer = this.runtime.getLayer(layerparam); if (!layer) ret.set_float(0); else ret.set_float(cr.to_degrees(layer.angle)); }; SysExps.prototype.layoutwidth = function (ret) { ret.set_int(this.runtime.running_layout.width); }; SysExps.prototype.layoutheight = function (ret) { ret.set_int(this.runtime.running_layout.height); }; SysExps.prototype.find = function (ret, text, searchstr) { if (cr.is_string(text) && cr.is_string(searchstr)) ret.set_int(text.search(new RegExp(cr.regexp_escape(searchstr), "i"))); else ret.set_int(-1); }; SysExps.prototype.findcase = function (ret, text, searchstr) { if (cr.is_string(text) && cr.is_string(searchstr)) ret.set_int(text.search(new RegExp(cr.regexp_escape(searchstr), ""))); else ret.set_int(-1); }; SysExps.prototype.left = function (ret, text, n) { ret.set_string(cr.is_string(text) ? text.substr(0, n) : ""); }; SysExps.prototype.right = function (ret, text, n) { ret.set_string(cr.is_string(text) ? text.substr(text.length - n) : ""); }; SysExps.prototype.mid = function (ret, text, index_, length_) { ret.set_string(cr.is_string(text) ? text.substr(index_, length_) : ""); }; SysExps.prototype.tokenat = function (ret, text, index_, sep) { if (cr.is_string(text) && cr.is_string(sep)) { var arr = text.split(sep); var i = cr.floor(index_); if (i < 0 || i >= arr.length) ret.set_string(""); else ret.set_string(arr[i]); } else ret.set_string(""); }; SysExps.prototype.tokencount = function (ret, text, sep) { if (cr.is_string(text) && text.length) ret.set_int(text.split(sep).length); else ret.set_int(0); }; SysExps.prototype.replace = function (ret, text, find_, replace_) { if (cr.is_string(text) && cr.is_string(find_) && cr.is_string(replace_)) ret.set_string(text.replace(new RegExp(cr.regexp_escape(find_), "gi"), replace_)); else ret.set_string(cr.is_string(text) ? text : ""); }; SysExps.prototype.trim = function (ret, text) { ret.set_string(cr.is_string(text) ? text.trim() : ""); }; SysExps.prototype.pi = function (ret) { ret.set_float(cr.PI); }; SysExps.prototype.layoutname = function (ret) { if (this.runtime.running_layout) ret.set_string(this.runtime.running_layout.name); else ret.set_string(""); }; SysExps.prototype.renderer = function (ret) { ret.set_string(this.runtime.gl ? "webgl" : "canvas2d"); }; SysExps.prototype.rendererdetail = function (ret) { ret.set_string(this.runtime.glUnmaskedRenderer); }; SysExps.prototype.anglediff = function (ret, a, b) { ret.set_float(cr.to_degrees(cr.angleDiff(cr.to_radians(a), cr.to_radians(b)))); }; SysExps.prototype.choose = function (ret) { var index = cr.floor(Math.random() * (arguments.length - 1)); ret.set_any(arguments[index + 1]); }; SysExps.prototype.rgb = function (ret, r, g, b) { ret.set_int(cr.RGB(r, g, b)); }; SysExps.prototype.projectversion = function (ret) { ret.set_string(this.runtime.versionstr); }; SysExps.prototype.projectname = function (ret) { ret.set_string(this.runtime.projectName); }; SysExps.prototype.anglelerp = function (ret, a, b, x) { a = cr.to_radians(a); b = cr.to_radians(b); var diff = cr.angleDiff(a, b); if (cr.angleClockwise(b, a)) { ret.set_float(cr.to_clamped_degrees(a + diff * x)); } else { ret.set_float(cr.to_clamped_degrees(a - diff * x)); } }; SysExps.prototype.anglerotate = function (ret, a, b, c) { a = cr.to_radians(a); b = cr.to_radians(b); c = cr.to_radians(c); ret.set_float(cr.to_clamped_degrees(cr.angleRotate(a, b, c))); }; SysExps.prototype.zeropad = function (ret, n, d) { var s = (n < 0 ? "-" : ""); if (n < 0) n = -n; var zeroes = d - n.toString().length; for (var i = 0; i < zeroes; i++) s += "0"; ret.set_string(s + n.toString()); }; SysExps.prototype.cpuutilisation = function (ret) { ret.set_float(this.runtime.cpuutilisation / 1000); }; SysExps.prototype.viewportleft = function (ret, layerparam) { var layer = this.runtime.getLayer(layerparam); ret.set_float(layer ? layer.viewLeft : 0); }; SysExps.prototype.viewporttop = function (ret, layerparam) { var layer = this.runtime.getLayer(layerparam); ret.set_float(layer ? layer.viewTop : 0); }; SysExps.prototype.viewportright = function (ret, layerparam) { var layer = this.runtime.getLayer(layerparam); ret.set_float(layer ? layer.viewRight : 0); }; SysExps.prototype.viewportbottom = function (ret, layerparam) { var layer = this.runtime.getLayer(layerparam); ret.set_float(layer ? layer.viewBottom : 0); }; SysExps.prototype.loadingprogress = function (ret) { ret.set_float(this.runtime.loadingprogress); }; SysExps.prototype.unlerp = function(ret, a, b, y) { ret.set_float(cr.unlerp(a, b, y)); }; SysExps.prototype.canvassnapshot = function (ret) { ret.set_string(this.runtime.snapshotData); }; SysExps.prototype.urlencode = function (ret, s) { ret.set_string(encodeURIComponent(s)); }; SysExps.prototype.urldecode = function (ret, s) { ret.set_string(decodeURIComponent(s)); }; SysExps.prototype.canvastolayerx = function (ret, layerparam, x, y) { var layer = this.runtime.getLayer(layerparam); ret.set_float(layer ? layer.canvasToLayer(x, y, true) : 0); }; SysExps.prototype.canvastolayery = function (ret, layerparam, x, y) { var layer = this.runtime.getLayer(layerparam); ret.set_float(layer ? layer.canvasToLayer(x, y, false) : 0); }; SysExps.prototype.layertocanvasx = function (ret, layerparam, x, y) { var layer = this.runtime.getLayer(layerparam); ret.set_float(layer ? layer.layerToCanvas(x, y, true) : 0); }; SysExps.prototype.layertocanvasy = function (ret, layerparam, x, y) { var layer = this.runtime.getLayer(layerparam); ret.set_float(layer ? layer.layerToCanvas(x, y, false) : 0); }; SysExps.prototype.savestatejson = function (ret) { ret.set_string(this.runtime.lastSaveJson); }; SysExps.prototype.imagememoryusage = function (ret) { if (this.runtime.glwrap) ret.set_float(Math.round(100 * this.runtime.glwrap.estimateVRAM() / (1024 * 1024)) / 100); else ret.set_float(0); }; SysExps.prototype.regexsearch = function (ret, str_, regex_, flags_) { var regex = getRegex(regex_, flags_); ret.set_int(str_ ? str_.search(regex) : -1); }; SysExps.prototype.regexreplace = function (ret, str_, regex_, flags_, replace_) { var regex = getRegex(regex_, flags_); ret.set_string(str_ ? str_.replace(regex, replace_) : ""); }; var regexMatches = []; var lastMatchesStr = ""; var lastMatchesRegex = ""; var lastMatchesFlags = ""; function updateRegexMatches(str_, regex_, flags_) { if (str_ === lastMatchesStr && regex_ === lastMatchesRegex && flags_ === lastMatchesFlags) return; var regex = getRegex(regex_, flags_); regexMatches = str_.match(regex); lastMatchesStr = str_; lastMatchesRegex = regex_; lastMatchesFlags = flags_; }; SysExps.prototype.regexmatchcount = function (ret, str_, regex_, flags_) { var regex = getRegex(regex_, flags_); updateRegexMatches(str_.toString(), regex_, flags_); ret.set_int(regexMatches ? regexMatches.length : 0); }; SysExps.prototype.regexmatchat = function (ret, str_, regex_, flags_, index_) { index_ = Math.floor(index_); var regex = getRegex(regex_, flags_); updateRegexMatches(str_.toString(), regex_, flags_); if (!regexMatches || index_ < 0 || index_ >= regexMatches.length) ret.set_string(""); else ret.set_string(regexMatches[index_]); }; SysExps.prototype.infinity = function (ret) { ret.set_float(Infinity); }; SysExps.prototype.setbit = function (ret, n, b, v) { n = n | 0; b = b | 0; v = (v !== 0 ? 1 : 0); ret.set_int((n & ~(1 << b)) | (v << b)); }; SysExps.prototype.togglebit = function (ret, n, b) { n = n | 0; b = b | 0; ret.set_int(n ^ (1 << b)); }; SysExps.prototype.getbit = function (ret, n, b) { n = n | 0; b = b | 0; ret.set_int((n & (1 << b)) ? 1 : 0); }; SysExps.prototype.originalwindowwidth = function (ret) { ret.set_int(this.runtime.original_width); }; SysExps.prototype.originalwindowheight = function (ret) { ret.set_int(this.runtime.original_height); }; sysProto.exps = new SysExps(); sysProto.runWaits = function () { var i, j, len, w, k, s, ss; var evinfo = this.runtime.getCurrentEventStack(); for (i = 0, len = this.waits.length; i < len; i++) { w = this.waits[i]; if (w.time === -1) // signalled wait { if (!w.signalled) continue; // not yet signalled } else // timer wait { if (w.time > this.runtime.kahanTime.sum) continue; // timer not yet expired } evinfo.current_event = w.ev; evinfo.actindex = w.actindex; evinfo.cndindex = 0; for (k in w.sols) { if (w.sols.hasOwnProperty(k)) { s = this.runtime.types_by_index[parseInt(k, 10)].getCurrentSol(); ss = w.sols[k]; s.select_all = ss.sa; cr.shallowAssignArray(s.instances, ss.insts); freeSolStateObject(ss); } } w.ev.resume_actions_and_subevents(); this.runtime.clearSol(w.solModifiers); w.deleteme = true; } for (i = 0, j = 0, len = this.waits.length; i < len; i++) { w = this.waits[i]; this.waits[j] = w; if (w.deleteme) freeWaitObject(w); else j++; } cr.truncateArray(this.waits, j); }; }()); ; (function () { cr.add_common_aces = function (m, pluginProto) { var singleglobal_ = m[1]; var position_aces = m[3]; var size_aces = m[4]; var angle_aces = m[5]; var appearance_aces = m[6]; var zorder_aces = m[7]; var effects_aces = m[8]; if (!pluginProto.cnds) pluginProto.cnds = {}; if (!pluginProto.acts) pluginProto.acts = {}; if (!pluginProto.exps) pluginProto.exps = {}; var cnds = pluginProto.cnds; var acts = pluginProto.acts; var exps = pluginProto.exps; if (position_aces) { cnds.CompareX = function (cmp, x) { return cr.do_cmp(this.x, cmp, x); }; cnds.CompareY = function (cmp, y) { return cr.do_cmp(this.y, cmp, y); }; cnds.IsOnScreen = function () { var layer = this.layer; this.update_bbox(); var bbox = this.bbox; return !(bbox.right < layer.viewLeft || bbox.bottom < layer.viewTop || bbox.left > layer.viewRight || bbox.top > layer.viewBottom); }; cnds.IsOutsideLayout = function () { this.update_bbox(); var bbox = this.bbox; var layout = this.runtime.running_layout; return (bbox.right < 0 || bbox.bottom < 0 || bbox.left > layout.width || bbox.top > layout.height); }; cnds.PickDistance = function (which, x, y) { var sol = this.getCurrentSol(); var instances = sol.getObjects(); if (!instances.length) return false; var inst = instances[0]; var pickme = inst; var dist = cr.distanceTo(inst.x, inst.y, x, y); var i, len, d; for (i = 1, len = instances.length; i < len; i++) { inst = instances[i]; d = cr.distanceTo(inst.x, inst.y, x, y); if ((which === 0 && d < dist) || (which === 1 && d > dist)) { dist = d; pickme = inst; } } sol.pick_one(pickme); return true; }; acts.SetX = function (x) { if (this.x !== x) { this.x = x; this.set_bbox_changed(); } }; acts.SetY = function (y) { if (this.y !== y) { this.y = y; this.set_bbox_changed(); } }; acts.SetPos = function (x, y) { if (this.x !== x || this.y !== y) { this.x = x; this.y = y; this.set_bbox_changed(); } }; acts.SetPosToObject = function (obj, imgpt) { var inst = obj.getPairedInstance(this); if (!inst) return; var newx, newy; if (inst.getImagePoint) { newx = inst.getImagePoint(imgpt, true); newy = inst.getImagePoint(imgpt, false); } else { newx = inst.x; newy = inst.y; } if (this.x !== newx || this.y !== newy) { this.x = newx; this.y = newy; this.set_bbox_changed(); } }; acts.MoveForward = function (dist) { if (dist !== 0) { this.x += Math.cos(this.angle) * dist; this.y += Math.sin(this.angle) * dist; this.set_bbox_changed(); } }; acts.MoveAtAngle = function (a, dist) { if (dist !== 0) { this.x += Math.cos(cr.to_radians(a)) * dist; this.y += Math.sin(cr.to_radians(a)) * dist; this.set_bbox_changed(); } }; exps.X = function (ret) { ret.set_float(this.x); }; exps.Y = function (ret) { ret.set_float(this.y); }; exps.dt = function (ret) { ret.set_float(this.runtime.getDt(this)); }; } if (size_aces) { cnds.CompareWidth = function (cmp, w) { return cr.do_cmp(this.width, cmp, w); }; cnds.CompareHeight = function (cmp, h) { return cr.do_cmp(this.height, cmp, h); }; acts.SetWidth = function (w) { if (this.width !== w) { this.width = w; this.set_bbox_changed(); } }; acts.SetHeight = function (h) { if (this.height !== h) { this.height = h; this.set_bbox_changed(); } }; acts.SetSize = function (w, h) { if (this.width !== w || this.height !== h) { this.width = w; this.height = h; this.set_bbox_changed(); } }; exps.Width = function (ret) { ret.set_float(this.width); }; exps.Height = function (ret) { ret.set_float(this.height); }; exps.BBoxLeft = function (ret) { this.update_bbox(); ret.set_float(this.bbox.left); }; exps.BBoxTop = function (ret) { this.update_bbox(); ret.set_float(this.bbox.top); }; exps.BBoxRight = function (ret) { this.update_bbox(); ret.set_float(this.bbox.right); }; exps.BBoxBottom = function (ret) { this.update_bbox(); ret.set_float(this.bbox.bottom); }; } if (angle_aces) { cnds.AngleWithin = function (within, a) { return cr.angleDiff(this.angle, cr.to_radians(a)) <= cr.to_radians(within); }; cnds.IsClockwiseFrom = function (a) { return cr.angleClockwise(this.angle, cr.to_radians(a)); }; cnds.IsBetweenAngles = function (a, b) { var lower = cr.to_clamped_radians(a); var upper = cr.to_clamped_radians(b); var angle = cr.clamp_angle(this.angle); var obtuse = (!cr.angleClockwise(upper, lower)); if (obtuse) return !(!cr.angleClockwise(angle, lower) && cr.angleClockwise(angle, upper)); else return cr.angleClockwise(angle, lower) && !cr.angleClockwise(angle, upper); }; acts.SetAngle = function (a) { var newangle = cr.to_radians(cr.clamp_angle_degrees(a)); if (isNaN(newangle)) return; if (this.angle !== newangle) { this.angle = newangle; this.set_bbox_changed(); } }; acts.RotateClockwise = function (a) { if (a !== 0 && !isNaN(a)) { this.angle += cr.to_radians(a); this.angle = cr.clamp_angle(this.angle); this.set_bbox_changed(); } }; acts.RotateCounterclockwise = function (a) { if (a !== 0 && !isNaN(a)) { this.angle -= cr.to_radians(a); this.angle = cr.clamp_angle(this.angle); this.set_bbox_changed(); } }; acts.RotateTowardAngle = function (amt, target) { var newangle = cr.angleRotate(this.angle, cr.to_radians(target), cr.to_radians(amt)); if (isNaN(newangle)) return; if (this.angle !== newangle) { this.angle = newangle; this.set_bbox_changed(); } }; acts.RotateTowardPosition = function (amt, x, y) { var dx = x - this.x; var dy = y - this.y; var target = Math.atan2(dy, dx); var newangle = cr.angleRotate(this.angle, target, cr.to_radians(amt)); if (isNaN(newangle)) return; if (this.angle !== newangle) { this.angle = newangle; this.set_bbox_changed(); } }; acts.SetTowardPosition = function (x, y) { var dx = x - this.x; var dy = y - this.y; var newangle = Math.atan2(dy, dx); if (isNaN(newangle)) return; if (this.angle !== newangle) { this.angle = newangle; this.set_bbox_changed(); } }; exps.Angle = function (ret) { ret.set_float(cr.to_clamped_degrees(this.angle)); }; } if (!singleglobal_) { cnds.CompareInstanceVar = function (iv, cmp, val) { return cr.do_cmp(this.instance_vars[iv], cmp, val); }; cnds.IsBoolInstanceVarSet = function (iv) { return this.instance_vars[iv]; }; cnds.PickInstVarHiLow = function (which, iv) { var sol = this.getCurrentSol(); var instances = sol.getObjects(); if (!instances.length) return false; var inst = instances[0]; var pickme = inst; var val = inst.instance_vars[iv]; var i, len, v; for (i = 1, len = instances.length; i < len; i++) { inst = instances[i]; v = inst.instance_vars[iv]; if ((which === 0 && v < val) || (which === 1 && v > val)) { val = v; pickme = inst; } } sol.pick_one(pickme); return true; }; cnds.PickByUID = function (u) { var i, len, j, inst, families, instances, sol; var cnd = this.runtime.getCurrentCondition(); if (cnd.inverted) { sol = this.getCurrentSol(); if (sol.select_all) { sol.select_all = false; cr.clearArray(sol.instances); cr.clearArray(sol.else_instances); instances = this.instances; for (i = 0, len = instances.length; i < len; i++) { inst = instances[i]; if (inst.uid === u) sol.else_instances.push(inst); else sol.instances.push(inst); } this.applySolToContainer(); return !!sol.instances.length; } else { for (i = 0, j = 0, len = sol.instances.length; i < len; i++) { inst = sol.instances[i]; sol.instances[j] = inst; if (inst.uid === u) { sol.else_instances.push(inst); } else j++; } cr.truncateArray(sol.instances, j); this.applySolToContainer(); return !!sol.instances.length; } } else { inst = this.runtime.getObjectByUID(u); if (!inst) return false; sol = this.getCurrentSol(); if (!sol.select_all && sol.instances.indexOf(inst) === -1) return false; // not picked if (this.is_family) { families = inst.type.families; for (i = 0, len = families.length; i < len; i++) { if (families[i] === this) { sol.pick_one(inst); this.applySolToContainer(); return true; } } } else if (inst.type === this) { sol.pick_one(inst); this.applySolToContainer(); return true; } return false; } }; cnds.OnCreated = function () { return true; }; cnds.OnDestroyed = function () { return true; }; acts.SetInstanceVar = function (iv, val) { var myinstvars = this.instance_vars; if (cr.is_number(myinstvars[iv])) { if (cr.is_number(val)) myinstvars[iv] = val; else myinstvars[iv] = parseFloat(val); } else if (cr.is_string(myinstvars[iv])) { if (cr.is_string(val)) myinstvars[iv] = val; else myinstvars[iv] = val.toString(); } else ; }; acts.AddInstanceVar = function (iv, val) { var myinstvars = this.instance_vars; if (cr.is_number(myinstvars[iv])) { if (cr.is_number(val)) myinstvars[iv] += val; else myinstvars[iv] += parseFloat(val); } else if (cr.is_string(myinstvars[iv])) { if (cr.is_string(val)) myinstvars[iv] += val; else myinstvars[iv] += val.toString(); } else ; }; acts.SubInstanceVar = function (iv, val) { var myinstvars = this.instance_vars; if (cr.is_number(myinstvars[iv])) { if (cr.is_number(val)) myinstvars[iv] -= val; else myinstvars[iv] -= parseFloat(val); } else ; }; acts.SetBoolInstanceVar = function (iv, val) { this.instance_vars[iv] = val ? 1 : 0; }; acts.ToggleBoolInstanceVar = function (iv) { this.instance_vars[iv] = 1 - this.instance_vars[iv]; }; acts.Destroy = function () { this.runtime.DestroyInstance(this); }; if (!acts.LoadFromJsonString) { acts.LoadFromJsonString = function (str_) { var o, i, len, binst; try { o = JSON.parse(str_); } catch (e) { return; } this.runtime.loadInstanceFromJSON(this, o, true); if (this.afterLoad) this.afterLoad(); if (this.behavior_insts) { for (i = 0, len = this.behavior_insts.length; i < len; ++i) { binst = this.behavior_insts[i]; if (binst.afterLoad) binst.afterLoad(); } } }; } exps.Count = function (ret) { var count = ret.object_class.instances.length; var i, len, inst; for (i = 0, len = this.runtime.createRow.length; i < len; i++) { inst = this.runtime.createRow[i]; if (ret.object_class.is_family) { if (inst.type.families.indexOf(ret.object_class) >= 0) count++; } else { if (inst.type === ret.object_class) count++; } } ret.set_int(count); }; exps.PickedCount = function (ret) { ret.set_int(ret.object_class.getCurrentSol().getObjects().length); }; exps.UID = function (ret) { ret.set_int(this.uid); }; exps.IID = function (ret) { ret.set_int(this.get_iid()); }; if (!exps.AsJSON) { exps.AsJSON = function (ret) { ret.set_string(JSON.stringify(this.runtime.saveInstanceToJSON(this, true))); }; } } if (appearance_aces) { cnds.IsVisible = function () { return this.visible; }; acts.SetVisible = function (v) { if (!v !== !this.visible) { this.visible = !!v; this.runtime.redraw = true; } }; cnds.CompareOpacity = function (cmp, x) { return cr.do_cmp(cr.round6dp(this.opacity * 100), cmp, x); }; acts.SetOpacity = function (x) { var new_opacity = x / 100.0; if (new_opacity < 0) new_opacity = 0; else if (new_opacity > 1) new_opacity = 1; if (new_opacity !== this.opacity) { this.opacity = new_opacity; this.runtime.redraw = true; } }; exps.Opacity = function (ret) { ret.set_float(cr.round6dp(this.opacity * 100.0)); }; } if (zorder_aces) { cnds.IsOnLayer = function (layer_) { if (!layer_) return false; return this.layer === layer_; }; cnds.PickTopBottom = function (which_) { var sol = this.getCurrentSol(); var instances = sol.getObjects(); if (!instances.length) return false; var inst = instances[0]; var pickme = inst; var i, len; for (i = 1, len = instances.length; i < len; i++) { inst = instances[i]; if (which_ === 0) { if (inst.layer.index > pickme.layer.index || (inst.layer.index === pickme.layer.index && inst.get_zindex() > pickme.get_zindex())) { pickme = inst; } } else { if (inst.layer.index < pickme.layer.index || (inst.layer.index === pickme.layer.index && inst.get_zindex() < pickme.get_zindex())) { pickme = inst; } } } sol.pick_one(pickme); return true; }; acts.MoveToTop = function () { var layer = this.layer; var layer_instances = layer.instances; if (layer_instances.length && layer_instances[layer_instances.length - 1] === this) return; // is already at top layer.removeFromInstanceList(this, false); layer.appendToInstanceList(this, false); this.runtime.redraw = true; }; acts.MoveToBottom = function () { var layer = this.layer; var layer_instances = layer.instances; if (layer_instances.length && layer_instances[0] === this) return; // is already at bottom layer.removeFromInstanceList(this, false); layer.prependToInstanceList(this, false); this.runtime.redraw = true; }; acts.MoveToLayer = function (layerMove) { if (!layerMove || layerMove == this.layer) return; this.layer.removeFromInstanceList(this, true); this.layer = layerMove; layerMove.appendToInstanceList(this, true); this.runtime.redraw = true; }; acts.ZMoveToObject = function (where_, obj_) { var isafter = (where_ === 0); if (!obj_) return; var other = obj_.getFirstPicked(this); if (!other || other.uid === this.uid) return; if (this.layer.index !== other.layer.index) { this.layer.removeFromInstanceList(this, true); this.layer = other.layer; other.layer.appendToInstanceList(this, true); } this.layer.moveInstanceAdjacent(this, other, isafter); this.runtime.redraw = true; }; exps.LayerNumber = function (ret) { ret.set_int(this.layer.number); }; exps.LayerName = function (ret) { ret.set_string(this.layer.name); }; exps.ZIndex = function (ret) { ret.set_int(this.get_zindex()); }; } if (effects_aces) { acts.SetEffectEnabled = function (enable_, effectname_) { if (!this.runtime.glwrap) return; var i = this.type.getEffectIndexByName(effectname_); if (i < 0) return; // effect name not found var enable = (enable_ === 1); if (this.active_effect_flags[i] === enable) return; // no change this.active_effect_flags[i] = enable; this.updateActiveEffects(); this.runtime.redraw = true; }; acts.SetEffectParam = function (effectname_, index_, value_) { if (!this.runtime.glwrap) return; var i = this.type.getEffectIndexByName(effectname_); if (i < 0) return; // effect name not found var et = this.type.effect_types[i]; var params = this.effect_params[i]; index_ = Math.floor(index_); if (index_ < 0 || index_ >= params.length) return; // effect index out of bounds if (this.runtime.glwrap.getProgramParameterType(et.shaderindex, index_) === 1) value_ /= 100.0; if (params[index_] === value_) return; // no change params[index_] = value_; if (et.active) this.runtime.redraw = true; }; } }; cr.set_bbox_changed = function () { this.bbox_changed = true; // will recreate next time box requested this.cell_changed = true; this.type.any_cell_changed = true; // avoid unnecessary updateAllBBox() calls this.runtime.redraw = true; // assume runtime needs to redraw var i, len, callbacks = this.bbox_changed_callbacks; for (i = 0, len = callbacks.length; i < len; ++i) { callbacks[i](this); } if (this.layer.useRenderCells) this.update_bbox(); }; cr.add_bbox_changed_callback = function (f) { if (f) { this.bbox_changed_callbacks.push(f); } }; cr.update_bbox = function () { if (!this.bbox_changed) return; // bounding box not changed var bbox = this.bbox; var bquad = this.bquad; bbox.set(this.x, this.y, this.x + this.width, this.y + this.height); bbox.offset(-this.hotspotX * this.width, -this.hotspotY * this.height); if (!this.angle) { bquad.set_from_rect(bbox); // make bounding quad from box } else { bbox.offset(-this.x, -this.y); // translate to origin bquad.set_from_rotated_rect(bbox, this.angle); // rotate around origin bquad.offset(this.x, this.y); // translate back to original position bquad.bounding_box(bbox); } bbox.normalize(); this.bbox_changed = false; // bounding box up to date this.update_render_cell(); }; var tmprc = new cr.rect(0, 0, 0, 0); cr.update_render_cell = function () { if (!this.layer.useRenderCells) return; var mygrid = this.layer.render_grid; var bbox = this.bbox; tmprc.set(mygrid.XToCell(bbox.left), mygrid.YToCell(bbox.top), mygrid.XToCell(bbox.right), mygrid.YToCell(bbox.bottom)); if (this.rendercells.equals(tmprc)) return; if (this.rendercells.right < this.rendercells.left) mygrid.update(this, null, tmprc); // first insertion with invalid rect: don't provide old range else mygrid.update(this, this.rendercells, tmprc); this.rendercells.copy(tmprc); this.layer.render_list_stale = true; }; cr.update_collision_cell = function () { if (!this.cell_changed || !this.collisionsEnabled) return; this.update_bbox(); var mygrid = this.type.collision_grid; var bbox = this.bbox; tmprc.set(mygrid.XToCell(bbox.left), mygrid.YToCell(bbox.top), mygrid.XToCell(bbox.right), mygrid.YToCell(bbox.bottom)); if (this.collcells.equals(tmprc)) return; if (this.collcells.right < this.collcells.left) mygrid.update(this, null, tmprc); // first insertion with invalid rect: don't provide old range else mygrid.update(this, this.collcells, tmprc); this.collcells.copy(tmprc); this.cell_changed = false; }; cr.inst_contains_pt = function (x, y) { if (!this.bbox.contains_pt(x, y)) return false; if (!this.bquad.contains_pt(x, y)) return false; if (this.tilemap_exists) return this.testPointOverlapTile(x, y); if (this.collision_poly && !this.collision_poly.is_empty()) { this.collision_poly.cache_poly(this.width, this.height, this.angle); return this.collision_poly.contains_pt(x - this.x, y - this.y); } else return true; }; cr.inst_get_iid = function () { this.type.updateIIDs(); return this.iid; }; cr.inst_get_zindex = function () { this.layer.updateZIndices(); return this.zindex; }; cr.inst_updateActiveEffects = function () { cr.clearArray(this.active_effect_types); var i, len, et; var preserves_opaqueness = true; for (i = 0, len = this.active_effect_flags.length; i < len; i++) { if (this.active_effect_flags[i]) { et = this.type.effect_types[i]; this.active_effect_types.push(et); if (!et.preservesOpaqueness) preserves_opaqueness = false; } } this.uses_shaders = !!this.active_effect_types.length; this.shaders_preserve_opaqueness = preserves_opaqueness; }; cr.inst_toString = function () { return "Inst" + this.puid; }; cr.type_getFirstPicked = function (frominst) { if (frominst && frominst.is_contained && frominst.type != this) { var i, len, s; for (i = 0, len = frominst.siblings.length; i < len; i++) { s = frominst.siblings[i]; if (s.type == this) return s; } } var instances = this.getCurrentSol().getObjects(); if (instances.length) return instances[0]; else return null; }; cr.type_getPairedInstance = function (inst) { var instances = this.getCurrentSol().getObjects(); if (instances.length) return instances[inst.get_iid() % instances.length]; else return null; }; cr.type_updateIIDs = function () { if (!this.stale_iids || this.is_family) return; // up to date or is family - don't want family to overwrite IIDs var i, len; for (i = 0, len = this.instances.length; i < len; i++) this.instances[i].iid = i; var next_iid = i; var createRow = this.runtime.createRow; for (i = 0, len = createRow.length; i < len; ++i) { if (createRow[i].type === this) createRow[i].iid = next_iid++; } this.stale_iids = false; }; cr.type_getInstanceByIID = function (i) { if (i < this.instances.length) return this.instances[i]; i -= this.instances.length; var createRow = this.runtime.createRow; var j, lenj; for (j = 0, lenj = createRow.length; j < lenj; ++j) { if (createRow[j].type === this) { if (i === 0) return createRow[j]; --i; } } ; return null; }; cr.type_getCurrentSol = function () { return this.solstack[this.cur_sol]; }; cr.type_pushCleanSol = function () { this.cur_sol++; if (this.cur_sol === this.solstack.length) { this.solstack.push(new cr.selection(this)); } else { this.solstack[this.cur_sol].select_all = true; // else clear next SOL cr.clearArray(this.solstack[this.cur_sol].else_instances); } }; cr.type_pushCopySol = function () { this.cur_sol++; if (this.cur_sol === this.solstack.length) this.solstack.push(new cr.selection(this)); var clonesol = this.solstack[this.cur_sol]; var prevsol = this.solstack[this.cur_sol - 1]; if (prevsol.select_all) { clonesol.select_all = true; cr.clearArray(clonesol.else_instances); } else { clonesol.select_all = false; cr.shallowAssignArray(clonesol.instances, prevsol.instances); cr.shallowAssignArray(clonesol.else_instances, prevsol.else_instances); } }; cr.type_popSol = function () { ; this.cur_sol--; }; cr.type_getBehaviorByName = function (behname) { var i, len, j, lenj, f, index = 0; if (!this.is_family) { for (i = 0, len = this.families.length; i < len; i++) { f = this.families[i]; for (j = 0, lenj = f.behaviors.length; j < lenj; j++) { if (behname === f.behaviors[j].name) { this.extra["lastBehIndex"] = index; return f.behaviors[j]; } index++; } } } for (i = 0, len = this.behaviors.length; i < len; i++) { if (behname === this.behaviors[i].name) { this.extra["lastBehIndex"] = index; return this.behaviors[i]; } index++; } return null; }; cr.type_getBehaviorIndexByName = function (behname) { var b = this.getBehaviorByName(behname); if (b) return this.extra["lastBehIndex"]; else return -1; }; cr.type_getEffectIndexByName = function (name_) { var i, len; for (i = 0, len = this.effect_types.length; i < len; i++) { if (this.effect_types[i].name === name_) return i; } return -1; }; cr.type_applySolToContainer = function () { if (!this.is_contained || this.is_family) return; var i, len, j, lenj, t, sol, sol2; this.updateIIDs(); sol = this.getCurrentSol(); var select_all = sol.select_all; var es = this.runtime.getCurrentEventStack(); var orblock = es && es.current_event && es.current_event.orblock; for (i = 0, len = this.container.length; i < len; i++) { t = this.container[i]; if (t === this) continue; t.updateIIDs(); sol2 = t.getCurrentSol(); sol2.select_all = select_all; if (!select_all) { cr.clearArray(sol2.instances); for (j = 0, lenj = sol.instances.length; j < lenj; ++j) sol2.instances[j] = t.getInstanceByIID(sol.instances[j].iid); if (orblock) { cr.clearArray(sol2.else_instances); for (j = 0, lenj = sol.else_instances.length; j < lenj; ++j) sol2.else_instances[j] = t.getInstanceByIID(sol.else_instances[j].iid); } } } }; cr.type_toString = function () { return "Type" + this.sid; }; cr.do_cmp = function (x, cmp, y) { if (typeof x === "undefined" || typeof y === "undefined") return false; switch (cmp) { case 0: // equal return x === y; case 1: // not equal return x !== y; case 2: // less return x < y; case 3: // less/equal return x <= y; case 4: // greater return x > y; case 5: // greater/equal return x >= y; default: ; return false; } }; })(); cr.shaders = {}; cr.shaders["blurhorizontal"] = {src: ["varying mediump vec2 vTex;", "uniform mediump sampler2D samplerFront;", "uniform mediump float pixelWidth;", "uniform mediump float intensity;", "void main(void)", "{", "mediump vec4 sum = vec4(0.0);", "mediump float halfPixelWidth = pixelWidth / 2.0;", "sum += texture2D(samplerFront, vTex - vec2(pixelWidth * 7.0 + halfPixelWidth, 0.0)) * 0.06;", "sum += texture2D(samplerFront, vTex - vec2(pixelWidth * 5.0 + halfPixelWidth, 0.0)) * 0.10;", "sum += texture2D(samplerFront, vTex - vec2(pixelWidth * 3.0 + halfPixelWidth, 0.0)) * 0.13;", "sum += texture2D(samplerFront, vTex - vec2(pixelWidth * 1.0 + halfPixelWidth, 0.0)) * 0.16;", "mediump vec4 front = texture2D(samplerFront, vTex);", "sum += front * 0.10;", "sum += texture2D(samplerFront, vTex + vec2(pixelWidth * 1.0 + halfPixelWidth, 0.0)) * 0.16;", "sum += texture2D(samplerFront, vTex + vec2(pixelWidth * 3.0 + halfPixelWidth, 0.0)) * 0.13;", "sum += texture2D(samplerFront, vTex + vec2(pixelWidth * 5.0 + halfPixelWidth, 0.0)) * 0.10;", "sum += texture2D(samplerFront, vTex + vec2(pixelWidth * 7.0 + halfPixelWidth, 0.0)) * 0.06;", "gl_FragColor = mix(front, sum, intensity);", "}" ].join("\n"), extendBoxHorizontal: 8, extendBoxVertical: 0, crossSampling: false, preservesOpaqueness: false, animated: false, parameters: [["intensity", 0, 1]] } cr.shaders["blurvertical"] = {src: ["varying mediump vec2 vTex;", "uniform mediump sampler2D samplerFront;", "uniform mediump float pixelHeight;", "uniform mediump float intensity;", "void main(void)", "{", "mediump vec4 sum = vec4(0.0);", "mediump float halfPixelHeight = pixelHeight / 2.0;", "sum += texture2D(samplerFront, vTex - vec2(0.0, pixelHeight * 7.0 + halfPixelHeight)) * 0.06;", "sum += texture2D(samplerFront, vTex - vec2(0.0, pixelHeight * 5.0 + halfPixelHeight)) * 0.10;", "sum += texture2D(samplerFront, vTex - vec2(0.0, pixelHeight * 3.0 + halfPixelHeight)) * 0.13;", "sum += texture2D(samplerFront, vTex - vec2(0.0, pixelHeight * 1.0 + halfPixelHeight)) * 0.16;", "mediump vec4 front = texture2D(samplerFront, vTex);", "sum += front * 0.10;", "sum += texture2D(samplerFront, vTex + vec2(0.0, pixelHeight * 1.0 + halfPixelHeight)) * 0.16;", "sum += texture2D(samplerFront, vTex + vec2(0.0, pixelHeight * 3.0 + halfPixelHeight)) * 0.13;", "sum += texture2D(samplerFront, vTex + vec2(0.0, pixelHeight * 5.0 + halfPixelHeight)) * 0.10;", "sum += texture2D(samplerFront, vTex + vec2(0.0, pixelHeight * 7.0 + halfPixelHeight)) * 0.06;", "gl_FragColor = mix(front, sum, intensity);", "}" ].join("\n"), extendBoxHorizontal: 0, extendBoxVertical: 8, crossSampling: false, preservesOpaqueness: false, animated: false, parameters: [["intensity", 0, 1]] } cr.shaders["darken"] = {src: ["varying mediump vec2 vTex;", "uniform lowp sampler2D samplerFront;", "uniform lowp sampler2D samplerBack;", "uniform mediump vec2 destStart;", "uniform mediump vec2 destEnd;", "void main(void)", "{", "lowp vec4 front = texture2D(samplerFront, vTex);", "front.rgb /= front.a;", "lowp vec4 back = texture2D(samplerBack, mix(destStart, destEnd, vTex));", "back.rgb /= back.a;", "front.rgb = min(front.rgb, back.rgb) * front.a;", "gl_FragColor = front * back.a;", "}" ].join("\n"), extendBoxHorizontal: 0, extendBoxVertical: 0, crossSampling: true, preservesOpaqueness: false, animated: false, parameters: [] } cr.shaders["glowvertical"] = {src: ["varying mediump vec2 vTex;", "uniform mediump sampler2D samplerFront;", "uniform mediump float pixelHeight;", "uniform mediump float intensity;", "void main(void)", "{", "mediump vec4 sum = vec4(0.0);", "mediump float halfPixelHeight = pixelHeight / 2.0;", "sum += texture2D(samplerFront, vTex - vec2(0.0, pixelHeight * 7.0 + halfPixelHeight)) * 0.06;", "sum += texture2D(samplerFront, vTex - vec2(0.0, pixelHeight * 5.0 + halfPixelHeight)) * 0.10;", "sum += texture2D(samplerFront, vTex - vec2(0.0, pixelHeight * 3.0 + halfPixelHeight)) * 0.13;", "sum += texture2D(samplerFront, vTex - vec2(0.0, pixelHeight * 1.0 + halfPixelHeight)) * 0.16;", "mediump vec4 front = texture2D(samplerFront, vTex);", "sum += front * 0.10;", "sum += texture2D(samplerFront, vTex + vec2(0.0, pixelHeight * 1.0 + halfPixelHeight)) * 0.16;", "sum += texture2D(samplerFront, vTex + vec2(0.0, pixelHeight * 3.0 + halfPixelHeight)) * 0.13;", "sum += texture2D(samplerFront, vTex + vec2(0.0, pixelHeight * 5.0 + halfPixelHeight)) * 0.10;", "sum += texture2D(samplerFront, vTex + vec2(0.0, pixelHeight * 7.0 + halfPixelHeight)) * 0.06;", "gl_FragColor = mix(front, max(front, sum), intensity);", "}" ].join("\n"), extendBoxHorizontal: 0, extendBoxVertical: 8, crossSampling: false, preservesOpaqueness: false, animated: false, parameters: [["intensity", 0, 1]] } cr.shaders["multiply"] = {src: ["varying mediump vec2 vTex;", "uniform lowp sampler2D samplerFront;", "uniform lowp sampler2D samplerBack;", "uniform mediump vec2 destStart;", "uniform mediump vec2 destEnd;", "void main(void)", "{", "lowp vec4 front = texture2D(samplerFront, vTex);", "lowp vec4 back = texture2D(samplerBack, mix(destStart, destEnd, vTex));", "front *= back;", "gl_FragColor = front;", "}" ].join("\n"), extendBoxHorizontal: 0, extendBoxVertical: 0, crossSampling: true, preservesOpaqueness: false, animated: false, parameters: [] } cr.shaders["pulse"] = {src: ["varying mediump vec2 vTex;", "uniform lowp sampler2D samplerFront;", "uniform lowp float intensity;", "uniform lowp float lighting;", "uniform mediump float frequency;", "uniform mediump float speed;", "uniform mediump float centerX;", "uniform mediump float centerY;", "uniform mediump float pixelWidth;", "uniform mediump float pixelHeight;", "uniform mediump float layerScale;", "uniform mediump float seconds;", "void main(void)", "{", "mediump vec2 res = vec2(1.0 / pixelWidth, 1.0 / pixelHeight);", "mediump vec2 halfres = res / 2.0;", "mediump vec2 cPos = (vTex - vec2(centerX, 1.0 - centerY)) * res;", "mediump float cLength = length(cPos);", "mediump vec2 uv = vTex+(cPos/cLength)*sin(cLength/frequency/layerScale-seconds*speed)/25.0;", "lowp vec4 front = texture2D(samplerFront, mix(vTex, uv, intensity));", "lowp vec3 col = mix(front.rgb, front.rgb*50.0/cLength, lighting * intensity);", "gl_FragColor = vec4(col,front.a);", "}" ].join("\n"), extendBoxHorizontal: 50, extendBoxVertical: 50, crossSampling: false, preservesOpaqueness: false, animated: true, parameters: [["intensity", 0, 1], ["lighting", 0, 1], ["speed", 0, 0], ["frequency", 0, 0], ["centerX", 0, 1], ["centerY", 0, 1]] } cr.shaders["scanlines"] = {src: ["varying mediump vec2 vTex;", "uniform lowp sampler2D samplerFront;", "uniform mediump float pixelHeight;", "uniform mediump float lineHeight;", "void main(void)", "{", "lowp vec4 front = texture2D(samplerFront, vTex);", "mediump float factor = 1.0 + (floor(mod(vTex.y, pixelHeight * lineHeight * 2.0) / (pixelHeight * lineHeight)) / 3.0);", "front.rgb /= factor;", "gl_FragColor = front;", "}" ].join("\n"), extendBoxHorizontal: 0, extendBoxVertical: 0, crossSampling: false, preservesOpaqueness: true, animated: false, parameters: [["lineHeight", 0, 0]] } cr.shaders["warp"] = {src: ["varying mediump vec2 vTex;", "uniform lowp sampler2D samplerFront;", "uniform mediump float seconds;", "uniform mediump float pixelWidth;", "uniform mediump float pixelHeight;", "uniform mediump float layerScale;", "uniform mediump float freqX;", "uniform mediump float freqY;", "uniform mediump float ampX;", "uniform mediump float ampY;", "uniform mediump float speedX;", "uniform mediump float speedY;", "void main(void)", "{", "mediump float boxLeft = 0.0;", "mediump float boxTop = 0.0;", "mediump float aspect = pixelHeight / pixelWidth;", "mediump vec2 p = vTex;", "p.x += (cos((vTex.y - boxTop) * freqX / layerScale / (pixelWidth * 750.0) + (seconds * speedX)) * ampX * pixelWidth * layerScale);", "p.y += (sin((vTex.x - boxLeft) * freqY * aspect / layerScale / (pixelHeight * 750.0) + (seconds * speedY)) * ampY * pixelHeight * layerScale);", "gl_FragColor = texture2D(samplerFront, p);", "}" ].join("\n"), extendBoxHorizontal: 25, extendBoxVertical: 25, crossSampling: false, preservesOpaqueness: false, animated: true, parameters: [["freqX", 0, 0], ["freqY", 0, 0], ["ampX", 0, 0], ["ampY", 0, 0], ["speedX", 0, 0], ["speedY", 0, 0]] } cr.shaders["water"] = {src: ["varying mediump vec2 vTex;", "uniform lowp sampler2D samplerFront;", "precision mediump float;", "uniform float seconds;", "uniform float pixelWidth;", "uniform float pixelHeight;", "const float PI = 3.1415926535897932;", "uniform float speed;", "uniform float speed_x;", "uniform float speed_y;", "uniform float intensity;", "const int steps = 8;", "uniform float frequency;", "uniform float angle; // better when a prime", "uniform float delta;", "uniform float intence;", "uniform float emboss;", "float col(vec2 coord)", "{", "float delta_theta = 2.0 * PI / angle;", "float col = 0.0;", "float theta = 0.0;", "for (int i = 0; i < steps; i++)", "{", "vec2 adjc = coord;", "theta = delta_theta*float(i);", "adjc.x += cos(theta)*seconds*speed + seconds * speed_x;", "adjc.y -= sin(theta)*seconds*speed - seconds * speed_y;", "col = col + cos( (adjc.x*cos(theta) - adjc.y*sin(theta))*frequency)*intensity;", "}", "return cos(col);", "}", "void main(void)", "{", "vec2 p = vTex, c1 = p, c2 = p;", "float cc1 = col(c1);", "c2.x += (1.0 / pixelWidth) / delta;", "float dx = emboss*(cc1-col(c2))/delta;", "c2.x = p.x;", "c2.y += (1.0 / pixelHeight) / delta;", "float dy = emboss*(cc1-col(c2))/delta;", "c1.x += dx;", "c1.y = -(c1.y+dy);", "float alpha = 1.+dot(dx,dy)*intence;", "c1.y = -c1.y;", "gl_FragColor = texture2D(samplerFront,c1)*(alpha);", "}" ].join("\n"), extendBoxHorizontal: 25, extendBoxVertical: 25, crossSampling: false, preservesOpaqueness: false, animated: true, parameters: [["speed", 0, 1], ["speed_x", 0, 1], ["speed_y", 0, 1], ["intensity", 0, 0], ["frequency", 0, 0], ["angle", 0, 0], ["delta", 0, 0], ["intence", 0, 0], ["emboss", 0, 1]] } ; ; cr.plugins_.Audio = function(runtime) { this.runtime = runtime; }; (function () { var pluginProto = cr.plugins_.Audio.prototype; pluginProto.Type = function(plugin) { this.plugin = plugin; this.runtime = plugin.runtime; }; var typeProto = pluginProto.Type.prototype; typeProto.onCreate = function() { }; var audRuntime = null; var audInst = null; var audTag = ""; var appPath = ""; // for Cordova only var API_HTML5 = 0; var API_WEBAUDIO = 1; var API_CORDOVA = 2; var API_APPMOBI = 3; var api = API_HTML5; var context = null; var audioBuffers = []; // cache of buffers var audioInstances = []; // cache of instances var lastAudio = null; var useOgg = false; // determined at create time var timescale_mode = 0; var silent = false; var masterVolume = 1; var listenerX = 0; var listenerY = 0; var isContextSuspended = false; var panningModel = 1; // HRTF var distanceModel = 1; // Inverse var refDistance = 10; var maxDistance = 10000; var rolloffFactor = 1; var micSource = null; var micTag = ""; var useNextTouchWorkaround = false; // heuristic in case play() does not return a promise and we have to guess if the play was blocked var playOnNextInput = []; // C2AudioInstances with HTMLAudioElements to play on next input event var playMusicAsSoundWorkaround = false; // play music tracks with Web Audio API var hasPlayedDummyBuffer = false; // dummy buffer played to unblock AudioContext on some platforms function addAudioToPlayOnNextInput(a) { var i = playOnNextInput.indexOf(a); if (i === -1) playOnNextInput.push(a); }; function tryPlayAudioElement(a) { var audioElem = a.instanceObject; var playRet; try { playRet = audioElem.play(); } catch (err) { addAudioToPlayOnNextInput(a); return; } if (playRet) // promise was returned { playRet.catch(function (err) { addAudioToPlayOnNextInput(a); }); } else if (useNextTouchWorkaround && !audRuntime.isInUserInputEvent) { addAudioToPlayOnNextInput(a); } }; function playQueuedAudio() { var i, len, m, playRet; if (!hasPlayedDummyBuffer && !isContextSuspended && context) { playDummyBuffer(); if (context["state"] === "running") hasPlayedDummyBuffer = true; } var tryPlay = playOnNextInput.slice(0); cr.clearArray(playOnNextInput); if (!silent) { for (i = 0, len = tryPlay.length; i < len; ++i) { m = tryPlay[i]; if (!m.stopped && !m.is_paused) { playRet = m.instanceObject.play(); if (playRet) { playRet.catch(function (err) { addAudioToPlayOnNextInput(m); }); } } } } }; function playDummyBuffer() { if (context["state"] === "suspended" && context["resume"]) context["resume"](); if (!context["createBuffer"]) return; var buffer = context["createBuffer"](1, 220, 22050); var source = context["createBufferSource"](); source["buffer"] = buffer; source["connect"](context["destination"]); startSource(source); }; document.addEventListener("touchend", playQueuedAudio, true); document.addEventListener("click", playQueuedAudio, true); document.addEventListener("keydown", playQueuedAudio, true); function dbToLinear(x) { var v = dbToLinear_nocap(x); if (!isFinite(v)) // accidentally passing a string can result in NaN; set volume to 0 if so v = 0; if (v < 0) v = 0; if (v > 1) v = 1; return v; }; function linearToDb(x) { if (x < 0) x = 0; if (x > 1) x = 1; return linearToDb_nocap(x); }; function dbToLinear_nocap(x) { return Math.pow(10, x / 20); }; function linearToDb_nocap(x) { return (Math.log(x) / Math.log(10)) * 20; }; var effects = {}; function getDestinationForTag(tag) { tag = tag.toLowerCase(); if (effects.hasOwnProperty(tag)) { if (effects[tag].length) return effects[tag][0].getInputNode(); } return context["destination"]; }; function createGain() { if (context["createGain"]) return context["createGain"](); else return context["createGainNode"](); }; function createDelay(d) { if (context["createDelay"]) return context["createDelay"](d); else return context["createDelayNode"](d); }; function startSource(s, scheduledTime) { if (s["start"]) s["start"](scheduledTime || 0); else s["noteOn"](scheduledTime || 0); }; function startSourceAt(s, x, d, scheduledTime) { if (s["start"]) s["start"](scheduledTime || 0, x); else s["noteGrainOn"](scheduledTime || 0, x, d - x); }; function stopSource(s) { try { if (s["stop"]) s["stop"](0); else s["noteOff"](0); } catch (e) {} }; function setAudioParam(ap, value, ramp, time) { if (!ap) return; // iOS is missing some parameters ap["cancelScheduledValues"](0); if (time === 0) { ap["value"] = value; return; } var curTime = context["currentTime"]; time += curTime; switch (ramp) { case 0: // step ap["setValueAtTime"](value, time); break; case 1: // linear ap["setValueAtTime"](ap["value"], curTime); // to set what to ramp from ap["linearRampToValueAtTime"](value, time); break; case 2: // exponential ap["setValueAtTime"](ap["value"], curTime); // to set what to ramp from ap["exponentialRampToValueAtTime"](value, time); break; } }; var filterTypes = ["lowpass", "highpass", "bandpass", "lowshelf", "highshelf", "peaking", "notch", "allpass"]; function FilterEffect(type, freq, detune, q, gain, mix) { this.type = "filter"; this.params = [type, freq, detune, q, gain, mix]; this.inputNode = createGain(); this.wetNode = createGain(); this.wetNode["gain"]["value"] = mix; this.dryNode = createGain(); this.dryNode["gain"]["value"] = 1 - mix; this.filterNode = context["createBiquadFilter"](); if (typeof this.filterNode["type"] === "number") this.filterNode["type"] = type; else this.filterNode["type"] = filterTypes[type]; this.filterNode["frequency"]["value"] = freq; if (this.filterNode["detune"]) // iOS 6 doesn't have detune yet this.filterNode["detune"]["value"] = detune; this.filterNode["Q"]["value"] = q; this.filterNode["gain"]["value"] = gain; this.inputNode["connect"](this.filterNode); this.inputNode["connect"](this.dryNode); this.filterNode["connect"](this.wetNode); }; FilterEffect.prototype.connectTo = function (node) { this.wetNode["disconnect"](); this.wetNode["connect"](node); this.dryNode["disconnect"](); this.dryNode["connect"](node); }; FilterEffect.prototype.remove = function () { this.inputNode["disconnect"](); this.filterNode["disconnect"](); this.wetNode["disconnect"](); this.dryNode["disconnect"](); }; FilterEffect.prototype.getInputNode = function () { return this.inputNode; }; FilterEffect.prototype.setParam = function(param, value, ramp, time) { switch (param) { case 0: // mix value = value / 100; if (value < 0) value = 0; if (value > 1) value = 1; this.params[5] = value; setAudioParam(this.wetNode["gain"], value, ramp, time); setAudioParam(this.dryNode["gain"], 1 - value, ramp, time); break; case 1: // filter frequency this.params[1] = value; setAudioParam(this.filterNode["frequency"], value, ramp, time); break; case 2: // filter detune this.params[2] = value; setAudioParam(this.filterNode["detune"], value, ramp, time); break; case 3: // filter Q this.params[3] = value; setAudioParam(this.filterNode["Q"], value, ramp, time); break; case 4: // filter/delay gain (note value is in dB here) this.params[4] = value; setAudioParam(this.filterNode["gain"], value, ramp, time); break; } }; function DelayEffect(delayTime, delayGain, mix) { this.type = "delay"; this.params = [delayTime, delayGain, mix]; this.inputNode = createGain(); this.wetNode = createGain(); this.wetNode["gain"]["value"] = mix; this.dryNode = createGain(); this.dryNode["gain"]["value"] = 1 - mix; this.mainNode = createGain(); this.delayNode = createDelay(delayTime); this.delayNode["delayTime"]["value"] = delayTime; this.delayGainNode = createGain(); this.delayGainNode["gain"]["value"] = delayGain; this.inputNode["connect"](this.mainNode); this.inputNode["connect"](this.dryNode); this.mainNode["connect"](this.wetNode); this.mainNode["connect"](this.delayNode); this.delayNode["connect"](this.delayGainNode); this.delayGainNode["connect"](this.mainNode); }; DelayEffect.prototype.connectTo = function (node) { this.wetNode["disconnect"](); this.wetNode["connect"](node); this.dryNode["disconnect"](); this.dryNode["connect"](node); }; DelayEffect.prototype.remove = function () { this.inputNode["disconnect"](); this.mainNode["disconnect"](); this.delayNode["disconnect"](); this.delayGainNode["disconnect"](); this.wetNode["disconnect"](); this.dryNode["disconnect"](); }; DelayEffect.prototype.getInputNode = function () { return this.inputNode; }; DelayEffect.prototype.setParam = function(param, value, ramp, time) { switch (param) { case 0: // mix value = value / 100; if (value < 0) value = 0; if (value > 1) value = 1; this.params[2] = value; setAudioParam(this.wetNode["gain"], value, ramp, time); setAudioParam(this.dryNode["gain"], 1 - value, ramp, time); break; case 4: // filter/delay gain (note value is passed in dB but needs to be linear here) this.params[1] = dbToLinear(value); setAudioParam(this.delayGainNode["gain"], dbToLinear(value), ramp, time); break; case 5: // delay time this.params[0] = value; setAudioParam(this.delayNode["delayTime"], value, ramp, time); break; } }; function ConvolveEffect(buffer, normalize, mix, src) { this.type = "convolve"; this.params = [normalize, mix, src]; this.inputNode = createGain(); this.wetNode = createGain(); this.wetNode["gain"]["value"] = mix; this.dryNode = createGain(); this.dryNode["gain"]["value"] = 1 - mix; this.convolveNode = context["createConvolver"](); if (buffer) { this.convolveNode["normalize"] = normalize; this.convolveNode["buffer"] = buffer; } this.inputNode["connect"](this.convolveNode); this.inputNode["connect"](this.dryNode); this.convolveNode["connect"](this.wetNode); }; ConvolveEffect.prototype.connectTo = function (node) { this.wetNode["disconnect"](); this.wetNode["connect"](node); this.dryNode["disconnect"](); this.dryNode["connect"](node); }; ConvolveEffect.prototype.remove = function () { this.inputNode["disconnect"](); this.convolveNode["disconnect"](); this.wetNode["disconnect"](); this.dryNode["disconnect"](); }; ConvolveEffect.prototype.getInputNode = function () { return this.inputNode; }; ConvolveEffect.prototype.setParam = function(param, value, ramp, time) { switch (param) { case 0: // mix value = value / 100; if (value < 0) value = 0; if (value > 1) value = 1; this.params[1] = value; setAudioParam(this.wetNode["gain"], value, ramp, time); setAudioParam(this.dryNode["gain"], 1 - value, ramp, time); break; } }; function FlangerEffect(delay, modulation, freq, feedback, mix) { this.type = "flanger"; this.params = [delay, modulation, freq, feedback, mix]; this.inputNode = createGain(); this.dryNode = createGain(); this.dryNode["gain"]["value"] = 1 - (mix / 2); this.wetNode = createGain(); this.wetNode["gain"]["value"] = mix / 2; this.feedbackNode = createGain(); this.feedbackNode["gain"]["value"] = feedback; this.delayNode = createDelay(delay + modulation); this.delayNode["delayTime"]["value"] = delay; this.oscNode = context["createOscillator"](); this.oscNode["frequency"]["value"] = freq; this.oscGainNode = createGain(); this.oscGainNode["gain"]["value"] = modulation; this.inputNode["connect"](this.delayNode); this.inputNode["connect"](this.dryNode); this.delayNode["connect"](this.wetNode); this.delayNode["connect"](this.feedbackNode); this.feedbackNode["connect"](this.delayNode); this.oscNode["connect"](this.oscGainNode); this.oscGainNode["connect"](this.delayNode["delayTime"]); startSource(this.oscNode); }; FlangerEffect.prototype.connectTo = function (node) { this.dryNode["disconnect"](); this.dryNode["connect"](node); this.wetNode["disconnect"](); this.wetNode["connect"](node); }; FlangerEffect.prototype.remove = function () { this.inputNode["disconnect"](); this.delayNode["disconnect"](); this.oscNode["disconnect"](); this.oscGainNode["disconnect"](); this.dryNode["disconnect"](); this.wetNode["disconnect"](); this.feedbackNode["disconnect"](); }; FlangerEffect.prototype.getInputNode = function () { return this.inputNode; }; FlangerEffect.prototype.setParam = function(param, value, ramp, time) { switch (param) { case 0: // mix value = value / 100; if (value < 0) value = 0; if (value > 1) value = 1; this.params[4] = value; setAudioParam(this.wetNode["gain"], value / 2, ramp, time); setAudioParam(this.dryNode["gain"], 1 - (value / 2), ramp, time); break; case 6: // modulation this.params[1] = value / 1000; setAudioParam(this.oscGainNode["gain"], value / 1000, ramp, time); break; case 7: // modulation frequency this.params[2] = value; setAudioParam(this.oscNode["frequency"], value, ramp, time); break; case 8: // feedback this.params[3] = value / 100; setAudioParam(this.feedbackNode["gain"], value / 100, ramp, time); break; } }; function PhaserEffect(freq, detune, q, modulation, modfreq, mix) { this.type = "phaser"; this.params = [freq, detune, q, modulation, modfreq, mix]; this.inputNode = createGain(); this.dryNode = createGain(); this.dryNode["gain"]["value"] = 1 - (mix / 2); this.wetNode = createGain(); this.wetNode["gain"]["value"] = mix / 2; this.filterNode = context["createBiquadFilter"](); if (typeof this.filterNode["type"] === "number") this.filterNode["type"] = 7; // all-pass else this.filterNode["type"] = "allpass"; this.filterNode["frequency"]["value"] = freq; if (this.filterNode["detune"]) // iOS 6 doesn't have detune yet this.filterNode["detune"]["value"] = detune; this.filterNode["Q"]["value"] = q; this.oscNode = context["createOscillator"](); this.oscNode["frequency"]["value"] = modfreq; this.oscGainNode = createGain(); this.oscGainNode["gain"]["value"] = modulation; this.inputNode["connect"](this.filterNode); this.inputNode["connect"](this.dryNode); this.filterNode["connect"](this.wetNode); this.oscNode["connect"](this.oscGainNode); this.oscGainNode["connect"](this.filterNode["frequency"]); startSource(this.oscNode); }; PhaserEffect.prototype.connectTo = function (node) { this.dryNode["disconnect"](); this.dryNode["connect"](node); this.wetNode["disconnect"](); this.wetNode["connect"](node); }; PhaserEffect.prototype.remove = function () { this.inputNode["disconnect"](); this.filterNode["disconnect"](); this.oscNode["disconnect"](); this.oscGainNode["disconnect"](); this.dryNode["disconnect"](); this.wetNode["disconnect"](); }; PhaserEffect.prototype.getInputNode = function () { return this.inputNode; }; PhaserEffect.prototype.setParam = function(param, value, ramp, time) { switch (param) { case 0: // mix value = value / 100; if (value < 0) value = 0; if (value > 1) value = 1; this.params[5] = value; setAudioParam(this.wetNode["gain"], value / 2, ramp, time); setAudioParam(this.dryNode["gain"], 1 - (value / 2), ramp, time); break; case 1: // filter frequency this.params[0] = value; setAudioParam(this.filterNode["frequency"], value, ramp, time); break; case 2: // filter detune this.params[1] = value; setAudioParam(this.filterNode["detune"], value, ramp, time); break; case 3: // filter Q this.params[2] = value; setAudioParam(this.filterNode["Q"], value, ramp, time); break; case 6: // modulation this.params[3] = value; setAudioParam(this.oscGainNode["gain"], value, ramp, time); break; case 7: // modulation frequency this.params[4] = value; setAudioParam(this.oscNode["frequency"], value, ramp, time); break; } }; function GainEffect(g) { this.type = "gain"; this.params = [g]; this.node = createGain(); this.node["gain"]["value"] = g; }; GainEffect.prototype.connectTo = function (node_) { this.node["disconnect"](); this.node["connect"](node_); }; GainEffect.prototype.remove = function () { this.node["disconnect"](); }; GainEffect.prototype.getInputNode = function () { return this.node; }; GainEffect.prototype.setParam = function(param, value, ramp, time) { switch (param) { case 4: // gain this.params[0] = dbToLinear(value); setAudioParam(this.node["gain"], dbToLinear(value), ramp, time); break; } }; function TremoloEffect(freq, mix) { this.type = "tremolo"; this.params = [freq, mix]; this.node = createGain(); this.node["gain"]["value"] = 1 - (mix / 2); this.oscNode = context["createOscillator"](); this.oscNode["frequency"]["value"] = freq; this.oscGainNode = createGain(); this.oscGainNode["gain"]["value"] = mix / 2; this.oscNode["connect"](this.oscGainNode); this.oscGainNode["connect"](this.node["gain"]); startSource(this.oscNode); }; TremoloEffect.prototype.connectTo = function (node_) { this.node["disconnect"](); this.node["connect"](node_); }; TremoloEffect.prototype.remove = function () { this.oscNode["disconnect"](); this.oscGainNode["disconnect"](); this.node["disconnect"](); }; TremoloEffect.prototype.getInputNode = function () { return this.node; }; TremoloEffect.prototype.setParam = function(param, value, ramp, time) { switch (param) { case 0: // mix value = value / 100; if (value < 0) value = 0; if (value > 1) value = 1; this.params[1] = value; setAudioParam(this.node["gain"]["value"], 1 - (value / 2), ramp, time); setAudioParam(this.oscGainNode["gain"]["value"], value / 2, ramp, time); break; case 7: // modulation frequency this.params[0] = value; setAudioParam(this.oscNode["frequency"], value, ramp, time); break; } }; function RingModulatorEffect(freq, mix) { this.type = "ringmod"; this.params = [freq, mix]; this.inputNode = createGain(); this.wetNode = createGain(); this.wetNode["gain"]["value"] = mix; this.dryNode = createGain(); this.dryNode["gain"]["value"] = 1 - mix; this.ringNode = createGain(); this.ringNode["gain"]["value"] = 0; this.oscNode = context["createOscillator"](); this.oscNode["frequency"]["value"] = freq; this.oscNode["connect"](this.ringNode["gain"]); startSource(this.oscNode); this.inputNode["connect"](this.ringNode); this.inputNode["connect"](this.dryNode); this.ringNode["connect"](this.wetNode); }; RingModulatorEffect.prototype.connectTo = function (node_) { this.wetNode["disconnect"](); this.wetNode["connect"](node_); this.dryNode["disconnect"](); this.dryNode["connect"](node_); }; RingModulatorEffect.prototype.remove = function () { this.oscNode["disconnect"](); this.ringNode["disconnect"](); this.inputNode["disconnect"](); this.wetNode["disconnect"](); this.dryNode["disconnect"](); }; RingModulatorEffect.prototype.getInputNode = function () { return this.inputNode; }; RingModulatorEffect.prototype.setParam = function(param, value, ramp, time) { switch (param) { case 0: // mix value = value / 100; if (value < 0) value = 0; if (value > 1) value = 1; this.params[1] = value; setAudioParam(this.wetNode["gain"], value, ramp, time); setAudioParam(this.dryNode["gain"], 1 - value, ramp, time); break; case 7: // modulation frequency this.params[0] = value; setAudioParam(this.oscNode["frequency"], value, ramp, time); break; } }; function DistortionEffect(threshold, headroom, drive, makeupgain, mix) { this.type = "distortion"; this.params = [threshold, headroom, drive, makeupgain, mix]; this.inputNode = createGain(); this.preGain = createGain(); this.postGain = createGain(); this.setDrive(drive, dbToLinear_nocap(makeupgain)); this.wetNode = createGain(); this.wetNode["gain"]["value"] = mix; this.dryNode = createGain(); this.dryNode["gain"]["value"] = 1 - mix; this.waveShaper = context["createWaveShaper"](); this.curve = new Float32Array(65536); this.generateColortouchCurve(threshold, headroom); this.waveShaper.curve = this.curve; this.inputNode["connect"](this.preGain); this.inputNode["connect"](this.dryNode); this.preGain["connect"](this.waveShaper); this.waveShaper["connect"](this.postGain); this.postGain["connect"](this.wetNode); }; DistortionEffect.prototype.setDrive = function (drive, makeupgain) { if (drive < 0.01) drive = 0.01; this.preGain["gain"]["value"] = drive; this.postGain["gain"]["value"] = Math.pow(1 / drive, 0.6) * makeupgain; }; function e4(x, k) { return 1.0 - Math.exp(-k * x); } DistortionEffect.prototype.shape = function (x, linearThreshold, linearHeadroom) { var maximum = 1.05 * linearHeadroom * linearThreshold; var kk = (maximum - linearThreshold); var sign = x < 0 ? -1 : +1; var absx = x < 0 ? -x : x; var shapedInput = absx < linearThreshold ? absx : linearThreshold + kk * e4(absx - linearThreshold, 1.0 / kk); shapedInput *= sign; return shapedInput; }; DistortionEffect.prototype.generateColortouchCurve = function (threshold, headroom) { var linearThreshold = dbToLinear_nocap(threshold); var linearHeadroom = dbToLinear_nocap(headroom); var n = 65536; var n2 = n / 2; var x = 0; for (var i = 0; i < n2; ++i) { x = i / n2; x = this.shape(x, linearThreshold, linearHeadroom); this.curve[n2 + i] = x; this.curve[n2 - i - 1] = -x; } }; DistortionEffect.prototype.connectTo = function (node) { this.wetNode["disconnect"](); this.wetNode["connect"](node); this.dryNode["disconnect"](); this.dryNode["connect"](node); }; DistortionEffect.prototype.remove = function () { this.inputNode["disconnect"](); this.preGain["disconnect"](); this.waveShaper["disconnect"](); this.postGain["disconnect"](); this.wetNode["disconnect"](); this.dryNode["disconnect"](); }; DistortionEffect.prototype.getInputNode = function () { return this.inputNode; }; DistortionEffect.prototype.setParam = function(param, value, ramp, time) { switch (param) { case 0: // mix value = value / 100; if (value < 0) value = 0; if (value > 1) value = 1; this.params[4] = value; setAudioParam(this.wetNode["gain"], value, ramp, time); setAudioParam(this.dryNode["gain"], 1 - value, ramp, time); break; } }; function CompressorEffect(threshold, knee, ratio, attack, release) { this.type = "compressor"; this.params = [threshold, knee, ratio, attack, release]; this.node = context["createDynamicsCompressor"](); try { this.node["threshold"]["value"] = threshold; this.node["knee"]["value"] = knee; this.node["ratio"]["value"] = ratio; this.node["attack"]["value"] = attack; this.node["release"]["value"] = release; } catch (e) {} }; CompressorEffect.prototype.connectTo = function (node_) { this.node["disconnect"](); this.node["connect"](node_); }; CompressorEffect.prototype.remove = function () { this.node["disconnect"](); }; CompressorEffect.prototype.getInputNode = function () { return this.node; }; CompressorEffect.prototype.setParam = function(param, value, ramp, time) { }; function AnalyserEffect(fftSize, smoothing) { this.type = "analyser"; this.params = [fftSize, smoothing]; this.node = context["createAnalyser"](); this.node["fftSize"] = fftSize; this.node["smoothingTimeConstant"] = smoothing; this.freqBins = new Float32Array(this.node["frequencyBinCount"]); this.signal = new Uint8Array(fftSize); this.peak = 0; this.rms = 0; }; AnalyserEffect.prototype.tick = function () { this.node["getFloatFrequencyData"](this.freqBins); this.node["getByteTimeDomainData"](this.signal); var fftSize = this.node["fftSize"]; var i = 0; this.peak = 0; var rmsSquaredSum = 0; var s = 0; for ( ; i < fftSize; i++) { s = (this.signal[i] - 128) / 128; if (s < 0) s = -s; if (this.peak < s) this.peak = s; rmsSquaredSum += s * s; } this.peak = linearToDb(this.peak); this.rms = linearToDb(Math.sqrt(rmsSquaredSum / fftSize)); }; AnalyserEffect.prototype.connectTo = function (node_) { this.node["disconnect"](); this.node["connect"](node_); }; AnalyserEffect.prototype.remove = function () { this.node["disconnect"](); }; AnalyserEffect.prototype.getInputNode = function () { return this.node; }; AnalyserEffect.prototype.setParam = function(param, value, ramp, time) { }; function ObjectTracker() { this.obj = null; this.loadUid = 0; }; ObjectTracker.prototype.setObject = function (obj_) { this.obj = obj_; }; ObjectTracker.prototype.hasObject = function () { return !!this.obj; }; ObjectTracker.prototype.tick = function (dt) { }; function C2AudioBuffer(src_, is_music) { this.src = src_; this.myapi = api; this.is_music = is_music; this.added_end_listener = false; var self = this; this.outNode = null; this.mediaSourceNode = null; this.panWhenReady = []; // for web audio API positioned sounds this.seekWhenReady = 0; this.pauseWhenReady = false; this.supportWebAudioAPI = false; this.failedToLoad = false; this.wasEverReady = false; // if a buffer is ever marked as ready, it's permanently considered ready after then. if (api === API_WEBAUDIO && is_music && !playMusicAsSoundWorkaround) { this.myapi = API_HTML5; this.outNode = createGain(); } this.bufferObject = null; // actual audio object this.audioData = null; // web audio api: ajax request result (compressed audio that needs decoding) var request; switch (this.myapi) { case API_HTML5: this.bufferObject = new Audio(); this.bufferObject.crossOrigin = "anonymous"; this.bufferObject.addEventListener("canplaythrough", function () { self.wasEverReady = true; // update loaded state so preload is considered complete }); if (api === API_WEBAUDIO && context["createMediaElementSource"] && !/wiiu/i.test(navigator.userAgent)) { this.supportWebAudioAPI = true; // can be routed through web audio api this.bufferObject.addEventListener("canplay", function () { if (!self.mediaSourceNode && self.bufferObject) { self.mediaSourceNode = context["createMediaElementSource"](self.bufferObject); self.mediaSourceNode["connect"](self.outNode); } }); } this.bufferObject.autoplay = false; // this is only a source buffer, not an instance this.bufferObject.preload = "auto"; this.bufferObject.src = src_; break; case API_WEBAUDIO: if (audRuntime.isWKWebView) { audRuntime.fetchLocalFileViaCordovaAsArrayBuffer(src_, function (arrayBuffer) { self.audioData = arrayBuffer; self.decodeAudioBuffer(); }, function (err) { self.failedToLoad = true; }); } else { request = new XMLHttpRequest(); request.open("GET", src_, true); request.responseType = "arraybuffer"; request.onload = function () { self.audioData = request.response; self.decodeAudioBuffer(); }; request.onerror = function () { self.failedToLoad = true; }; request.send(); } break; case API_CORDOVA: this.bufferObject = true; break; case API_APPMOBI: this.bufferObject = true; break; } }; C2AudioBuffer.prototype.release = function () { var i, len, j, a; for (i = 0, j = 0, len = audioInstances.length; i < len; ++i) { a = audioInstances[i]; audioInstances[j] = a; if (a.buffer === this) a.stop(); else ++j; // keep } audioInstances.length = j; if (this.mediaSourceNode) { this.mediaSourceNode["disconnect"](); this.mediaSourceNode = null; } if (this.outNode) { this.outNode["disconnect"](); this.outNode = null; } this.bufferObject = null; this.audioData = null; }; C2AudioBuffer.prototype.decodeAudioBuffer = function () { if (this.bufferObject || !this.audioData) return; // audio already decoded or AJAX request not yet complete var self = this; if (context["decodeAudioData"]) { context["decodeAudioData"](this.audioData, function (buffer) { self.bufferObject = buffer; self.audioData = null; // clear AJAX response to allow GC and save memory, only need the bufferObject now var p, i, len, a; if (!cr.is_undefined(self.playTagWhenReady) && !silent) { if (self.panWhenReady.length) { for (i = 0, len = self.panWhenReady.length; i < len; i++) { p = self.panWhenReady[i]; a = new C2AudioInstance(self, p.thistag); a.setPannerEnabled(true); if (typeof p.objUid !== "undefined") { p.obj = audRuntime.getObjectByUID(p.objUid); if (!p.obj) continue; } if (p.obj) { var px = cr.rotatePtAround(p.obj.x, p.obj.y, -p.obj.layer.getAngle(), listenerX, listenerY, true); var py = cr.rotatePtAround(p.obj.x, p.obj.y, -p.obj.layer.getAngle(), listenerX, listenerY, false); a.setPan(px, py, cr.to_degrees(p.obj.angle - p.obj.layer.getAngle()), p.ia, p.oa, p.og); a.setObject(p.obj); } else { a.setPan(p.x, p.y, p.a, p.ia, p.oa, p.og); } a.play(self.loopWhenReady, self.volumeWhenReady, self.seekWhenReady); if (self.pauseWhenReady) a.pause(); audioInstances.push(a); } cr.clearArray(self.panWhenReady); } else { a = new C2AudioInstance(self, self.playTagWhenReady || ""); // sometimes playTagWhenReady is not set - TODO: why? a.play(self.loopWhenReady, self.volumeWhenReady, self.seekWhenReady); if (self.pauseWhenReady) a.pause(); audioInstances.push(a); } } else if (!cr.is_undefined(self.convolveWhenReady)) { var convolveNode = self.convolveWhenReady.convolveNode; convolveNode["normalize"] = self.normalizeWhenReady; convolveNode["buffer"] = buffer; } }, function (e) { self.failedToLoad = true; }); } else { this.bufferObject = context["createBuffer"](this.audioData, false); this.audioData = null; // clear AJAX response to allow GC and save memory, only need the bufferObject now if (!cr.is_undefined(this.playTagWhenReady) && !silent) { var a = new C2AudioInstance(this, this.playTagWhenReady); a.play(this.loopWhenReady, this.volumeWhenReady, this.seekWhenReady); if (this.pauseWhenReady) a.pause(); audioInstances.push(a); } else if (!cr.is_undefined(this.convolveWhenReady)) { var convolveNode = this.convolveWhenReady.convolveNode; convolveNode["normalize"] = this.normalizeWhenReady; convolveNode["buffer"] = this.bufferObject; } } }; C2AudioBuffer.prototype.isLoaded = function () { switch (this.myapi) { case API_HTML5: var ret = this.bufferObject["readyState"] >= 4; // HAVE_ENOUGH_DATA if (ret) this.wasEverReady = true; return ret || this.wasEverReady; case API_WEBAUDIO: return !!this.audioData || !!this.bufferObject; case API_CORDOVA: return true; case API_APPMOBI: return true; } return false; }; C2AudioBuffer.prototype.isLoadedAndDecoded = function () { switch (this.myapi) { case API_HTML5: return this.isLoaded(); // no distinction between loaded and decoded in HTML5 audio, just rely on ready state case API_WEBAUDIO: return !!this.bufferObject; case API_CORDOVA: return true; case API_APPMOBI: return true; } return false; }; C2AudioBuffer.prototype.hasFailedToLoad = function () { switch (this.myapi) { case API_HTML5: return !!this.bufferObject["error"]; case API_WEBAUDIO: return this.failedToLoad; } return false; }; function C2AudioInstance(buffer_, tag_) { var self = this; this.tag = tag_; this.fresh = true; this.stopped = true; this.src = buffer_.src; this.buffer = buffer_; this.myapi = api; this.is_music = buffer_.is_music; this.playbackRate = 1; this.hasPlaybackEnded = true; // ended flag this.resume_me = false; // make sure resumes when leaving suspend this.is_paused = false; this.resume_position = 0; // for web audio api to resume from correct playback position this.looping = false; this.is_muted = false; this.is_silent = false; this.volume = 1; this.onended_handler = function (e) { if (self.is_paused || self.resume_me) return; var bufferThatEnded = this; if (!bufferThatEnded) bufferThatEnded = e.target; if (bufferThatEnded !== self.active_buffer) return; self.hasPlaybackEnded = true; self.stopped = true; audTag = self.tag; audRuntime.trigger(cr.plugins_.Audio.prototype.cnds.OnEnded, audInst); }; this.active_buffer = null; this.isTimescaled = ((timescale_mode === 1 && !this.is_music) || timescale_mode === 2); this.mutevol = 1; this.startTime = (this.isTimescaled ? audRuntime.kahanTime.sum : audRuntime.wallTime.sum); this.gainNode = null; this.pannerNode = null; this.pannerEnabled = false; this.objectTracker = null; this.panX = 0; this.panY = 0; this.panAngle = 0; this.panConeInner = 0; this.panConeOuter = 0; this.panConeOuterGain = 0; this.instanceObject = null; var add_end_listener = false; if (this.myapi === API_WEBAUDIO && this.buffer.myapi === API_HTML5 && !this.buffer.supportWebAudioAPI) this.myapi = API_HTML5; switch (this.myapi) { case API_HTML5: if (this.is_music) { this.instanceObject = buffer_.bufferObject; add_end_listener = !buffer_.added_end_listener; buffer_.added_end_listener = true; } else { this.instanceObject = new Audio(); this.instanceObject.crossOrigin = "anonymous"; this.instanceObject.autoplay = false; this.instanceObject.src = buffer_.bufferObject.src; add_end_listener = true; } if (add_end_listener) { this.instanceObject.addEventListener('ended', function () { audTag = self.tag; self.stopped = true; audRuntime.trigger(cr.plugins_.Audio.prototype.cnds.OnEnded, audInst); }); } break; case API_WEBAUDIO: this.gainNode = createGain(); this.gainNode["connect"](getDestinationForTag(tag_)); if (this.buffer.myapi === API_WEBAUDIO) { if (buffer_.bufferObject) { this.instanceObject = context["createBufferSource"](); this.instanceObject["buffer"] = buffer_.bufferObject; this.instanceObject["connect"](this.gainNode); } } else { this.instanceObject = this.buffer.bufferObject; // reference the audio element this.buffer.outNode["connect"](this.gainNode); if (!this.buffer.added_end_listener) { this.buffer.added_end_listener = true; this.buffer.bufferObject.addEventListener('ended', function () { audTag = self.tag; self.stopped = true; audRuntime.trigger(cr.plugins_.Audio.prototype.cnds.OnEnded, audInst); }); } } break; case API_CORDOVA: this.instanceObject = new window["Media"](appPath + this.src, null, null, function (status) { if (status === window["Media"]["MEDIA_STOPPED"]) { self.hasPlaybackEnded = true; self.stopped = true; audTag = self.tag; audRuntime.trigger(cr.plugins_.Audio.prototype.cnds.OnEnded, audInst); } }); break; case API_APPMOBI: this.instanceObject = true; break; } }; C2AudioInstance.prototype.hasEnded = function () { var time; switch (this.myapi) { case API_HTML5: return this.instanceObject.ended; case API_WEBAUDIO: if (this.buffer.myapi === API_WEBAUDIO) { if (!this.fresh && !this.stopped && this.instanceObject["loop"]) return false; if (this.is_paused) return false; return this.hasPlaybackEnded; } else return this.instanceObject.ended; case API_CORDOVA: return this.hasPlaybackEnded; case API_APPMOBI: true; // recycling an AppMobi sound does not matter because it will just do another throwaway playSound } return true; }; C2AudioInstance.prototype.canBeRecycled = function () { if (this.fresh || this.stopped) return true; // not yet used or is not playing return this.hasEnded(); }; C2AudioInstance.prototype.setPannerEnabled = function (enable_) { if (api !== API_WEBAUDIO) return; if (!this.pannerEnabled && enable_) { if (!this.gainNode) return; if (!this.pannerNode) { this.pannerNode = context["createPanner"](); if (typeof this.pannerNode["panningModel"] === "number") this.pannerNode["panningModel"] = panningModel; else this.pannerNode["panningModel"] = ["equalpower", "HRTF", "soundfield"][panningModel]; if (typeof this.pannerNode["distanceModel"] === "number") this.pannerNode["distanceModel"] = distanceModel; else this.pannerNode["distanceModel"] = ["linear", "inverse", "exponential"][distanceModel]; this.pannerNode["refDistance"] = refDistance; this.pannerNode["maxDistance"] = maxDistance; this.pannerNode["rolloffFactor"] = rolloffFactor; } this.gainNode["disconnect"](); this.gainNode["connect"](this.pannerNode); this.pannerNode["connect"](getDestinationForTag(this.tag)); this.pannerEnabled = true; } else if (this.pannerEnabled && !enable_) { if (!this.gainNode) return; this.pannerNode["disconnect"](); this.gainNode["disconnect"](); this.gainNode["connect"](getDestinationForTag(this.tag)); this.pannerEnabled = false; } }; C2AudioInstance.prototype.setPan = function (x, y, angle, innerangle, outerangle, outergain) { if (!this.pannerEnabled || api !== API_WEBAUDIO) return; this.pannerNode["setPosition"](x, y, 0); this.pannerNode["setOrientation"](Math.cos(cr.to_radians(angle)), Math.sin(cr.to_radians(angle)), 0); this.pannerNode["coneInnerAngle"] = innerangle; this.pannerNode["coneOuterAngle"] = outerangle; this.pannerNode["coneOuterGain"] = outergain; this.panX = x; this.panY = y; this.panAngle = angle; this.panConeInner = innerangle; this.panConeOuter = outerangle; this.panConeOuterGain = outergain; }; C2AudioInstance.prototype.setObject = function (o) { if (!this.pannerEnabled || api !== API_WEBAUDIO) return; if (!this.objectTracker) this.objectTracker = new ObjectTracker(); this.objectTracker.setObject(o); }; C2AudioInstance.prototype.tick = function (dt) { if (!this.pannerEnabled || api !== API_WEBAUDIO || !this.objectTracker || !this.objectTracker.hasObject() || !this.isPlaying()) { return; } this.objectTracker.tick(dt); var inst = this.objectTracker.obj; var px = cr.rotatePtAround(inst.x, inst.y, -inst.layer.getAngle(), listenerX, listenerY, true); var py = cr.rotatePtAround(inst.x, inst.y, -inst.layer.getAngle(), listenerX, listenerY, false); this.pannerNode["setPosition"](px, py, 0); var a = 0; if (typeof this.objectTracker.obj.angle !== "undefined") { a = inst.angle - inst.layer.getAngle(); this.pannerNode["setOrientation"](Math.cos(a), Math.sin(a), 0); } }; C2AudioInstance.prototype.play = function (looping, vol, fromPosition, scheduledTime) { var instobj = this.instanceObject; this.looping = looping; this.volume = vol; var seekPos = fromPosition || 0; scheduledTime = scheduledTime || 0; switch (this.myapi) { case API_HTML5: if (instobj.playbackRate !== 1.0) instobj.playbackRate = 1.0; if (instobj.volume !== vol * masterVolume) instobj.volume = vol * masterVolume; if (instobj.loop !== looping) instobj.loop = looping; if (instobj.muted) instobj.muted = false; if (instobj.currentTime !== seekPos) { try { instobj.currentTime = seekPos; } catch (err) { ; } } tryPlayAudioElement(this); break; case API_WEBAUDIO: this.muted = false; this.mutevol = 1; if (this.buffer.myapi === API_WEBAUDIO) { this.gainNode["gain"]["value"] = vol * masterVolume; if (!this.fresh) { this.instanceObject = context["createBufferSource"](); this.instanceObject["buffer"] = this.buffer.bufferObject; this.instanceObject["connect"](this.gainNode); } this.instanceObject["onended"] = this.onended_handler; this.active_buffer = this.instanceObject; this.instanceObject.loop = looping; this.hasPlaybackEnded = false; if (seekPos === 0) startSource(this.instanceObject, scheduledTime); else startSourceAt(this.instanceObject, seekPos, this.getDuration(), scheduledTime); } else { if (instobj.playbackRate !== 1.0) instobj.playbackRate = 1.0; if (instobj.loop !== looping) instobj.loop = looping; instobj.volume = vol * masterVolume; if (instobj.currentTime !== seekPos) { try { instobj.currentTime = seekPos; } catch (err) { ; } } tryPlayAudioElement(this); } break; case API_CORDOVA: if ((!this.fresh && this.stopped) || seekPos !== 0) instobj["seekTo"](seekPos); instobj["play"](); this.hasPlaybackEnded = false; break; case API_APPMOBI: if (audRuntime.isDirectCanvas) AppMobi["context"]["playSound"](this.src, looping); else AppMobi["player"]["playSound"](this.src, looping); break; } this.playbackRate = 1; this.startTime = (this.isTimescaled ? audRuntime.kahanTime.sum : audRuntime.wallTime.sum) - seekPos; this.fresh = false; this.stopped = false; this.is_paused = false; }; C2AudioInstance.prototype.stop = function () { switch (this.myapi) { case API_HTML5: if (!this.instanceObject.paused) this.instanceObject.pause(); break; case API_WEBAUDIO: if (this.buffer.myapi === API_WEBAUDIO) stopSource(this.instanceObject); else { if (!this.instanceObject.paused) this.instanceObject.pause(); } break; case API_CORDOVA: this.instanceObject["stop"](); break; case API_APPMOBI: if (audRuntime.isDirectCanvas) AppMobi["context"]["stopSound"](this.src); break; } this.stopped = true; this.is_paused = false; }; C2AudioInstance.prototype.pause = function () { if (this.fresh || this.stopped || this.hasEnded() || this.is_paused) return; switch (this.myapi) { case API_HTML5: if (!this.instanceObject.paused) this.instanceObject.pause(); break; case API_WEBAUDIO: if (this.buffer.myapi === API_WEBAUDIO) { this.resume_position = this.getPlaybackTime(true); if (this.looping) this.resume_position = this.resume_position % this.getDuration(); this.is_paused = true; stopSource(this.instanceObject); } else { if (!this.instanceObject.paused) this.instanceObject.pause(); } break; case API_CORDOVA: this.instanceObject["pause"](); break; case API_APPMOBI: if (audRuntime.isDirectCanvas) AppMobi["context"]["stopSound"](this.src); break; } this.is_paused = true; }; C2AudioInstance.prototype.resume = function () { if (this.fresh || this.stopped || this.hasEnded() || !this.is_paused) return; switch (this.myapi) { case API_HTML5: tryPlayAudioElement(this); break; case API_WEBAUDIO: if (this.buffer.myapi === API_WEBAUDIO) { this.instanceObject = context["createBufferSource"](); this.instanceObject["buffer"] = this.buffer.bufferObject; this.instanceObject["connect"](this.gainNode); this.instanceObject["onended"] = this.onended_handler; this.active_buffer = this.instanceObject; this.instanceObject.loop = this.looping; this.gainNode["gain"]["value"] = masterVolume * this.volume * this.mutevol; this.updatePlaybackRate(); this.startTime = (this.isTimescaled ? audRuntime.kahanTime.sum : audRuntime.wallTime.sum) - (this.resume_position / (this.playbackRate || 0.001)); startSourceAt(this.instanceObject, this.resume_position, this.getDuration()); } else { tryPlayAudioElement(this); } break; case API_CORDOVA: this.instanceObject["play"](); break; case API_APPMOBI: if (audRuntime.isDirectCanvas) AppMobi["context"]["resumeSound"](this.src); break; } this.is_paused = false; }; C2AudioInstance.prototype.seek = function (pos) { if (this.fresh || this.stopped || this.hasEnded()) return; switch (this.myapi) { case API_HTML5: try { this.instanceObject.currentTime = pos; } catch (e) {} break; case API_WEBAUDIO: if (this.buffer.myapi === API_WEBAUDIO) { if (this.is_paused) this.resume_position = pos; else { this.pause(); this.resume_position = pos; this.resume(); } } else { try { this.instanceObject.currentTime = pos; } catch (e) {} } break; case API_CORDOVA: break; case API_APPMOBI: if (audRuntime.isDirectCanvas) AppMobi["context"]["seekSound"](this.src, pos); break; } }; C2AudioInstance.prototype.reconnect = function (toNode) { if (this.myapi !== API_WEBAUDIO) return; if (this.pannerEnabled) { this.pannerNode["disconnect"](); this.pannerNode["connect"](toNode); } else { this.gainNode["disconnect"](); this.gainNode["connect"](toNode); } }; C2AudioInstance.prototype.getDuration = function (applyPlaybackRate) { var ret = 0; switch (this.myapi) { case API_HTML5: if (typeof this.instanceObject.duration !== "undefined") ret = this.instanceObject.duration; break; case API_WEBAUDIO: ret = this.buffer.bufferObject["duration"]; break; case API_CORDOVA: ret = this.instanceObject["getDuration"](); break; case API_APPMOBI: if (audRuntime.isDirectCanvas) ret = AppMobi["context"]["getDurationSound"](this.src); break; } if (applyPlaybackRate) ret /= (this.playbackRate || 0.001); // avoid divide-by-zero return ret; }; C2AudioInstance.prototype.getPlaybackTime = function (applyPlaybackRate) { var duration = this.getDuration(); var ret = 0; switch (this.myapi) { case API_HTML5: if (typeof this.instanceObject.currentTime !== "undefined") ret = this.instanceObject.currentTime; break; case API_WEBAUDIO: if (this.buffer.myapi === API_WEBAUDIO) { if (this.is_paused) return this.resume_position; else ret = (this.isTimescaled ? audRuntime.kahanTime.sum : audRuntime.wallTime.sum) - this.startTime; } else if (typeof this.instanceObject.currentTime !== "undefined") ret = this.instanceObject.currentTime; break; case API_CORDOVA: break; case API_APPMOBI: if (audRuntime.isDirectCanvas) ret = AppMobi["context"]["getPlaybackTimeSound"](this.src); break; } if (applyPlaybackRate) ret *= this.playbackRate; if (!this.looping && ret > duration) ret = duration; return ret; }; C2AudioInstance.prototype.isPlaying = function () { return !this.is_paused && !this.fresh && !this.stopped && !this.hasEnded(); }; C2AudioInstance.prototype.shouldSave = function () { return !this.fresh && !this.stopped && !this.hasEnded(); }; C2AudioInstance.prototype.setVolume = function (v) { this.volume = v; this.updateVolume(); }; C2AudioInstance.prototype.updateVolume = function () { var volToSet = this.volume * masterVolume; if (!isFinite(volToSet)) volToSet = 0; // HTMLMediaElement throws if setting non-finite volume switch (this.myapi) { case API_HTML5: if (typeof this.instanceObject.volume !== "undefined" && this.instanceObject.volume !== volToSet) this.instanceObject.volume = volToSet; break; case API_WEBAUDIO: if (this.buffer.myapi === API_WEBAUDIO) { this.gainNode["gain"]["value"] = volToSet * this.mutevol; } else { if (typeof this.instanceObject.volume !== "undefined" && this.instanceObject.volume !== volToSet) this.instanceObject.volume = volToSet; } break; case API_CORDOVA: break; case API_APPMOBI: break; } }; C2AudioInstance.prototype.getVolume = function () { return this.volume; }; C2AudioInstance.prototype.doSetMuted = function (m) { switch (this.myapi) { case API_HTML5: if (this.instanceObject.muted !== !!m) this.instanceObject.muted = !!m; break; case API_WEBAUDIO: if (this.buffer.myapi === API_WEBAUDIO) { this.mutevol = (m ? 0 : 1); this.gainNode["gain"]["value"] = masterVolume * this.volume * this.mutevol; } else { if (this.instanceObject.muted !== !!m) this.instanceObject.muted = !!m; } break; case API_CORDOVA: break; case API_APPMOBI: break; } }; C2AudioInstance.prototype.setMuted = function (m) { this.is_muted = !!m; this.doSetMuted(this.is_muted || this.is_silent); }; C2AudioInstance.prototype.setSilent = function (m) { this.is_silent = !!m; this.doSetMuted(this.is_muted || this.is_silent); }; C2AudioInstance.prototype.setLooping = function (l) { this.looping = l; switch (this.myapi) { case API_HTML5: if (this.instanceObject.loop !== !!l) this.instanceObject.loop = !!l; break; case API_WEBAUDIO: if (this.instanceObject.loop !== !!l) this.instanceObject.loop = !!l; break; case API_CORDOVA: break; case API_APPMOBI: if (audRuntime.isDirectCanvas) AppMobi["context"]["setLoopingSound"](this.src, l); break; } }; C2AudioInstance.prototype.setPlaybackRate = function (r) { this.playbackRate = r; this.updatePlaybackRate(); }; C2AudioInstance.prototype.updatePlaybackRate = function () { var r = this.playbackRate; if (this.isTimescaled) r *= audRuntime.timescale; switch (this.myapi) { case API_HTML5: if (this.instanceObject.playbackRate !== r) this.instanceObject.playbackRate = r; break; case API_WEBAUDIO: if (this.buffer.myapi === API_WEBAUDIO) { if (this.instanceObject["playbackRate"]["value"] !== r) this.instanceObject["playbackRate"]["value"] = r; } else { if (this.instanceObject.playbackRate !== r) this.instanceObject.playbackRate = r; } break; case API_CORDOVA: break; case API_APPMOBI: break; } }; C2AudioInstance.prototype.setSuspended = function (s) { switch (this.myapi) { case API_HTML5: if (s) { if (this.isPlaying()) { this.resume_me = true; this.instanceObject["pause"](); } else this.resume_me = false; } else { if (this.resume_me) { this.instanceObject["play"](); this.resume_me = false; } } break; case API_WEBAUDIO: if (s) { if (this.isPlaying()) { this.resume_me = true; if (this.buffer.myapi === API_WEBAUDIO) { this.resume_position = this.getPlaybackTime(true); if (this.looping) this.resume_position = this.resume_position % this.getDuration(); stopSource(this.instanceObject); } else this.instanceObject["pause"](); } else this.resume_me = false; } else { if (this.resume_me) { if (this.buffer.myapi === API_WEBAUDIO) { this.instanceObject = context["createBufferSource"](); this.instanceObject["buffer"] = this.buffer.bufferObject; this.instanceObject["connect"](this.gainNode); this.instanceObject["onended"] = this.onended_handler; this.active_buffer = this.instanceObject; this.instanceObject.loop = this.looping; this.gainNode["gain"]["value"] = masterVolume * this.volume * this.mutevol; this.updatePlaybackRate(); this.startTime = (this.isTimescaled ? audRuntime.kahanTime.sum : audRuntime.wallTime.sum) - (this.resume_position / (this.playbackRate || 0.001)); startSourceAt(this.instanceObject, this.resume_position, this.getDuration()); } else { this.instanceObject["play"](); } this.resume_me = false; } } break; case API_CORDOVA: if (s) { if (this.isPlaying()) { this.instanceObject["pause"](); this.resume_me = true; } else this.resume_me = false; } else { if (this.resume_me) { this.resume_me = false; this.instanceObject["play"](); } } break; case API_APPMOBI: break; } }; pluginProto.Instance = function(type) { this.type = type; this.runtime = type.runtime; audRuntime = this.runtime; audInst = this; this.listenerTracker = null; this.listenerZ = -600; if (this.runtime.isWKWebView) playMusicAsSoundWorkaround = true; if ((this.runtime.isiOS || (this.runtime.isAndroid && (this.runtime.isChrome || this.runtime.isAndroidStockBrowser))) && !this.runtime.isCrosswalk && !this.runtime.isDomFree && !this.runtime.isAmazonWebApp && !playMusicAsSoundWorkaround) { useNextTouchWorkaround = true; } context = null; if (typeof AudioContext !== "undefined") { api = API_WEBAUDIO; context = new AudioContext(); } else if (typeof webkitAudioContext !== "undefined") { api = API_WEBAUDIO; context = new webkitAudioContext(); } if (this.runtime.isiOS && context) { if (context.close) context.close(); if (typeof AudioContext !== "undefined") context = new AudioContext(); else if (typeof webkitAudioContext !== "undefined") context = new webkitAudioContext(); } if (api !== API_WEBAUDIO) { if (this.runtime.isCordova && typeof window["Media"] !== "undefined") api = API_CORDOVA; else if (this.runtime.isAppMobi) api = API_APPMOBI; } if (api === API_CORDOVA) { appPath = location.href; var i = appPath.lastIndexOf("/"); if (i > -1) appPath = appPath.substr(0, i + 1); appPath = appPath.replace("file://", ""); } if (this.runtime.isSafari && this.runtime.isWindows && typeof Audio === "undefined") { alert("It looks like you're using Safari for Windows without Quicktime. Audio cannot be played until Quicktime is installed."); this.runtime.DestroyInstance(this); } else { if (this.runtime.isDirectCanvas) useOgg = this.runtime.isAndroid; // AAC on iOS, OGG on Android else { try { useOgg = !!(new Audio().canPlayType('audio/ogg; codecs="vorbis"')); } catch (e) { useOgg = false; } } switch (api) { case API_HTML5: ; break; case API_WEBAUDIO: ; break; case API_CORDOVA: ; break; case API_APPMOBI: ; break; default: ; } this.runtime.tickMe(this); } }; var instanceProto = pluginProto.Instance.prototype; instanceProto.onCreate = function () { this.runtime.audioInstance = this; timescale_mode = this.properties[0]; // 0 = off, 1 = sounds only, 2 = all this.saveload = this.properties[1]; // 0 = all, 1 = sounds only, 2 = music only, 3 = none this.playinbackground = (this.properties[2] !== 0); this.nextPlayTime = 0; panningModel = this.properties[3]; // 0 = equalpower, 1 = hrtf, 3 = soundfield distanceModel = this.properties[4]; // 0 = linear, 1 = inverse, 2 = exponential this.listenerZ = -this.properties[5]; refDistance = this.properties[6]; maxDistance = this.properties[7]; rolloffFactor = this.properties[8]; this.listenerTracker = new ObjectTracker(); var draw_width = (this.runtime.draw_width || this.runtime.width); var draw_height = (this.runtime.draw_height || this.runtime.height); if (api === API_WEBAUDIO) { context["listener"]["setPosition"](draw_width / 2, draw_height / 2, this.listenerZ); context["listener"]["setOrientation"](0, 0, 1, 0, -1, 0); window["c2OnAudioMicStream"] = function (localMediaStream, tag) { if (micSource) micSource["disconnect"](); micTag = tag.toLowerCase(); micSource = context["createMediaStreamSource"](localMediaStream); micSource["connect"](getDestinationForTag(micTag)); }; } this.runtime.addSuspendCallback(function(s) { audInst.onSuspend(s); }); var self = this; this.runtime.addDestroyCallback(function (inst) { self.onInstanceDestroyed(inst); }); }; instanceProto.onInstanceDestroyed = function (inst) { var i, len, a; for (i = 0, len = audioInstances.length; i < len; i++) { a = audioInstances[i]; if (a.objectTracker) { if (a.objectTracker.obj === inst) { a.objectTracker.obj = null; if (a.pannerEnabled && a.isPlaying() && a.looping) a.stop(); } } } if (this.listenerTracker.obj === inst) this.listenerTracker.obj = null; }; instanceProto.saveToJSON = function () { var o = { "silent": silent, "masterVolume": masterVolume, "listenerZ": this.listenerZ, "listenerUid": this.listenerTracker.hasObject() ? this.listenerTracker.obj.uid : -1, "playing": [], "effects": {} }; var playingarr = o["playing"]; var i, len, a, d, p, panobj, playbackTime; for (i = 0, len = audioInstances.length; i < len; i++) { a = audioInstances[i]; if (!a.shouldSave()) continue; // no need to save stopped sounds if (this.saveload === 3) // not saving/loading any sounds/music continue; if (a.is_music && this.saveload === 1) // not saving/loading music continue; if (!a.is_music && this.saveload === 2) // not saving/loading sound continue; playbackTime = a.getPlaybackTime(); if (a.looping) playbackTime = playbackTime % a.getDuration(); d = { "tag": a.tag, "buffersrc": a.buffer.src, "is_music": a.is_music, "playbackTime": playbackTime, "volume": a.volume, "looping": a.looping, "muted": a.is_muted, "playbackRate": a.playbackRate, "paused": a.is_paused, "resume_position": a.resume_position }; if (a.pannerEnabled) { d["pan"] = {}; panobj = d["pan"]; if (a.objectTracker && a.objectTracker.hasObject()) { panobj["objUid"] = a.objectTracker.obj.uid; } else { panobj["x"] = a.panX; panobj["y"] = a.panY; panobj["a"] = a.panAngle; } panobj["ia"] = a.panConeInner; panobj["oa"] = a.panConeOuter; panobj["og"] = a.panConeOuterGain; } playingarr.push(d); } var fxobj = o["effects"]; var fxarr; for (p in effects) { if (effects.hasOwnProperty(p)) { fxarr = []; for (i = 0, len = effects[p].length; i < len; i++) { fxarr.push({ "type": effects[p][i].type, "params": effects[p][i].params }); } fxobj[p] = fxarr; } } return o; }; var objectTrackerUidsToLoad = []; instanceProto.loadFromJSON = function (o) { var setSilent = o["silent"]; masterVolume = o["masterVolume"]; this.listenerZ = o["listenerZ"]; this.listenerTracker.setObject(null); var listenerUid = o["listenerUid"]; if (listenerUid !== -1) { this.listenerTracker.loadUid = listenerUid; objectTrackerUidsToLoad.push(this.listenerTracker); } var playingarr = o["playing"]; var i, len, d, src, is_music, tag, playbackTime, looping, vol, b, a, p, pan, panObjUid; if (this.saveload !== 3) { for (i = 0, len = audioInstances.length; i < len; i++) { a = audioInstances[i]; if (a.is_music && this.saveload === 1) continue; // only saving/loading sound: leave music playing if (!a.is_music && this.saveload === 2) continue; // only saving/loading music: leave sound playing a.stop(); } } var fxarr, fxtype, fxparams, fx; for (p in effects) { if (effects.hasOwnProperty(p)) { for (i = 0, len = effects[p].length; i < len; i++) effects[p][i].remove(); } } cr.wipe(effects); for (p in o["effects"]) { if (o["effects"].hasOwnProperty(p)) { fxarr = o["effects"][p]; for (i = 0, len = fxarr.length; i < len; i++) { fxtype = fxarr[i]["type"]; fxparams = fxarr[i]["params"]; switch (fxtype) { case "filter": addEffectForTag(p, new FilterEffect(fxparams[0], fxparams[1], fxparams[2], fxparams[3], fxparams[4], fxparams[5])); break; case "delay": addEffectForTag(p, new DelayEffect(fxparams[0], fxparams[1], fxparams[2])); break; case "convolve": src = fxparams[2]; b = this.getAudioBuffer(src, false); if (b.bufferObject) { fx = new ConvolveEffect(b.bufferObject, fxparams[0], fxparams[1], src); } else { fx = new ConvolveEffect(null, fxparams[0], fxparams[1], src); b.normalizeWhenReady = fxparams[0]; b.convolveWhenReady = fx; } addEffectForTag(p, fx); break; case "flanger": addEffectForTag(p, new FlangerEffect(fxparams[0], fxparams[1], fxparams[2], fxparams[3], fxparams[4])); break; case "phaser": addEffectForTag(p, new PhaserEffect(fxparams[0], fxparams[1], fxparams[2], fxparams[3], fxparams[4], fxparams[5])); break; case "gain": addEffectForTag(p, new GainEffect(fxparams[0])); break; case "tremolo": addEffectForTag(p, new TremoloEffect(fxparams[0], fxparams[1])); break; case "ringmod": addEffectForTag(p, new RingModulatorEffect(fxparams[0], fxparams[1])); break; case "distortion": addEffectForTag(p, new DistortionEffect(fxparams[0], fxparams[1], fxparams[2], fxparams[3], fxparams[4])); break; case "compressor": addEffectForTag(p, new CompressorEffect(fxparams[0], fxparams[1], fxparams[2], fxparams[3], fxparams[4])); break; case "analyser": addEffectForTag(p, new AnalyserEffect(fxparams[0], fxparams[1])); break; } } } } for (i = 0, len = playingarr.length; i < len; i++) { if (this.saveload === 3) // not saving/loading any sounds/music continue; d = playingarr[i]; src = d["buffersrc"]; is_music = d["is_music"]; tag = d["tag"]; playbackTime = d["playbackTime"]; looping = d["looping"]; vol = d["volume"]; pan = d["pan"]; panObjUid = (pan && pan.hasOwnProperty("objUid")) ? pan["objUid"] : -1; if (is_music && this.saveload === 1) // not saving/loading music continue; if (!is_music && this.saveload === 2) // not saving/loading sound continue; a = this.getAudioInstance(src, tag, is_music, looping, vol); if (!a) { b = this.getAudioBuffer(src, is_music); b.seekWhenReady = playbackTime; b.pauseWhenReady = d["paused"]; if (pan) { if (panObjUid !== -1) { b.panWhenReady.push({ objUid: panObjUid, ia: pan["ia"], oa: pan["oa"], og: pan["og"], thistag: tag }); } else { b.panWhenReady.push({ x: pan["x"], y: pan["y"], a: pan["a"], ia: pan["ia"], oa: pan["oa"], og: pan["og"], thistag: tag }); } } continue; } a.resume_position = d["resume_position"]; a.setPannerEnabled(!!pan); a.play(looping, vol, playbackTime); a.updatePlaybackRate(); a.updateVolume(); a.doSetMuted(a.is_muted || a.is_silent); if (d["paused"]) a.pause(); if (d["muted"]) a.setMuted(true); a.doSetMuted(a.is_muted || a.is_silent); if (pan) { if (panObjUid !== -1) { a.objectTracker = a.objectTracker || new ObjectTracker(); a.objectTracker.loadUid = panObjUid; objectTrackerUidsToLoad.push(a.objectTracker); } else { a.setPan(pan["x"], pan["y"], pan["a"], pan["ia"], pan["oa"], pan["og"]); } } } if (setSilent && !silent) // setting silent { for (i = 0, len = audioInstances.length; i < len; i++) audioInstances[i].setSilent(true); silent = true; } else if (!setSilent && silent) // setting not silent { for (i = 0, len = audioInstances.length; i < len; i++) audioInstances[i].setSilent(false); silent = false; } }; instanceProto.afterLoad = function () { var i, len, ot, inst; for (i = 0, len = objectTrackerUidsToLoad.length; i < len; i++) { ot = objectTrackerUidsToLoad[i]; inst = this.runtime.getObjectByUID(ot.loadUid); ot.setObject(inst); ot.loadUid = -1; if (inst) { listenerX = inst.x; listenerY = inst.y; } } cr.clearArray(objectTrackerUidsToLoad); }; instanceProto.onSuspend = function (s) { if (this.playinbackground) return; if (!s && context && context["resume"]) { context["resume"](); isContextSuspended = false; } var i, len; for (i = 0, len = audioInstances.length; i < len; i++) audioInstances[i].setSuspended(s); if (s && context && context["suspend"]) { context["suspend"](); isContextSuspended = true; } }; instanceProto.tick = function () { var dt = this.runtime.dt; var i, len, a; for (i = 0, len = audioInstances.length; i < len; i++) { a = audioInstances[i]; a.tick(dt); if (timescale_mode !== 0) a.updatePlaybackRate(); } var p, arr, f; for (p in effects) { if (effects.hasOwnProperty(p)) { arr = effects[p]; for (i = 0, len = arr.length; i < len; i++) { f = arr[i]; if (f.tick) f.tick(); } } } if (api === API_WEBAUDIO && this.listenerTracker.hasObject()) { this.listenerTracker.tick(dt); listenerX = this.listenerTracker.obj.x; listenerY = this.listenerTracker.obj.y; context["listener"]["setPosition"](this.listenerTracker.obj.x, this.listenerTracker.obj.y, this.listenerZ); } }; var preload_list = []; instanceProto.setPreloadList = function (arr) { var i, len, p, filename, size, isOgg; var total_size = 0; for (i = 0, len = arr.length; i < len; ++i) { p = arr[i]; filename = p[0]; size = p[1] * 2; isOgg = (filename.length > 4 && filename.substr(filename.length - 4) === ".ogg"); if ((isOgg && useOgg) || (!isOgg && !useOgg)) { preload_list.push({ filename: filename, size: size, obj: null }); total_size += size; } } return total_size; }; instanceProto.startPreloads = function () { var i, len, p, src; for (i = 0, len = preload_list.length; i < len; ++i) { p = preload_list[i]; src = this.runtime.files_subfolder + p.filename; p.obj = this.getAudioBuffer(src, false); } }; instanceProto.getPreloadedSize = function () { var completed = 0; var i, len, p; for (i = 0, len = preload_list.length; i < len; ++i) { p = preload_list[i]; if (p.obj.isLoadedAndDecoded() || p.obj.hasFailedToLoad() || this.runtime.isDomFree || this.runtime.isAndroidStockBrowser) { completed += p.size; } else if (p.obj.isLoaded()) // downloaded but not decoded: only happens in Web Audio API, count as half-way progress { completed += Math.floor(p.size / 2); } }; return completed; }; instanceProto.releaseAllMusicBuffers = function () { var i, len, j, b; for (i = 0, j = 0, len = audioBuffers.length; i < len; ++i) { b = audioBuffers[i]; audioBuffers[j] = b; if (b.is_music) b.release(); else ++j; // keep } audioBuffers.length = j; }; instanceProto.getAudioBuffer = function (src_, is_music, dont_create) { var i, len, a, ret = null, j, k, lenj, ai; for (i = 0, len = audioBuffers.length; i < len; i++) { a = audioBuffers[i]; if (a.src === src_) { ret = a; break; } } if (!ret && !dont_create) { if (playMusicAsSoundWorkaround && is_music) this.releaseAllMusicBuffers(); ret = new C2AudioBuffer(src_, is_music); audioBuffers.push(ret); } return ret; }; instanceProto.getAudioInstance = function (src_, tag, is_music, looping, vol) { var i, len, a; for (i = 0, len = audioInstances.length; i < len; i++) { a = audioInstances[i]; if (a.src === src_ && (a.canBeRecycled() || is_music)) { a.tag = tag; return a; } } var b = this.getAudioBuffer(src_, is_music); if (!b.bufferObject) { if (tag !== "") { b.playTagWhenReady = tag; b.loopWhenReady = looping; b.volumeWhenReady = vol; } return null; } a = new C2AudioInstance(b, tag); audioInstances.push(a); return a; }; var taggedAudio = []; function SortByIsPlaying(a, b) { var an = a.isPlaying() ? 1 : 0; var bn = b.isPlaying() ? 1 : 0; if (an === bn) return 0; else if (an < bn) return 1; else return -1; }; function getAudioByTag(tag, sort_by_playing) { cr.clearArray(taggedAudio); if (!tag.length) { if (!lastAudio || lastAudio.hasEnded()) return; else { cr.clearArray(taggedAudio); taggedAudio[0] = lastAudio; return; } } var i, len, a; for (i = 0, len = audioInstances.length; i < len; i++) { a = audioInstances[i]; if (cr.equals_nocase(tag, a.tag)) taggedAudio.push(a); } if (sort_by_playing) taggedAudio.sort(SortByIsPlaying); }; function reconnectEffects(tag) { var i, len, arr, n, toNode = context["destination"]; if (effects.hasOwnProperty(tag)) { arr = effects[tag]; if (arr.length) { toNode = arr[0].getInputNode(); for (i = 0, len = arr.length; i < len; i++) { n = arr[i]; if (i + 1 === len) n.connectTo(context["destination"]); else n.connectTo(arr[i + 1].getInputNode()); } } } getAudioByTag(tag); for (i = 0, len = taggedAudio.length; i < len; i++) taggedAudio[i].reconnect(toNode); if (micSource && micTag === tag) { micSource["disconnect"](); micSource["connect"](toNode); } }; function addEffectForTag(tag, fx) { if (!effects.hasOwnProperty(tag)) effects[tag] = [fx]; else effects[tag].push(fx); reconnectEffects(tag); }; function Cnds() {}; Cnds.prototype.OnEnded = function (t) { return cr.equals_nocase(audTag, t); }; Cnds.prototype.PreloadsComplete = function () { var i, len; for (i = 0, len = audioBuffers.length; i < len; i++) { if (!audioBuffers[i].isLoadedAndDecoded() && !audioBuffers[i].hasFailedToLoad()) return false; } return true; }; Cnds.prototype.AdvancedAudioSupported = function () { return api === API_WEBAUDIO; }; Cnds.prototype.IsSilent = function () { return silent; }; Cnds.prototype.IsAnyPlaying = function () { var i, len; for (i = 0, len = audioInstances.length; i < len; i++) { if (audioInstances[i].isPlaying()) return true; } return false; }; Cnds.prototype.IsTagPlaying = function (tag) { getAudioByTag(tag); var i, len; for (i = 0, len = taggedAudio.length; i < len; i++) { if (taggedAudio[i].isPlaying()) return true; } return false; }; pluginProto.cnds = new Cnds(); function Acts() {}; Acts.prototype.Play = function (file, looping, vol, tag) { if (silent) return; var v = dbToLinear(vol); var is_music = file[1]; var src = this.runtime.files_subfolder + file[0] + (useOgg ? ".ogg" : ".m4a"); lastAudio = this.getAudioInstance(src, tag, is_music, looping!==0, v); if (!lastAudio) return; lastAudio.setPannerEnabled(false); lastAudio.play(looping!==0, v, 0, this.nextPlayTime); this.nextPlayTime = 0; }; Acts.prototype.PlayAtPosition = function (file, looping, vol, x_, y_, angle_, innerangle_, outerangle_, outergain_, tag) { if (silent) return; var v = dbToLinear(vol); var is_music = file[1]; var src = this.runtime.files_subfolder + file[0] + (useOgg ? ".ogg" : ".m4a"); lastAudio = this.getAudioInstance(src, tag, is_music, looping!==0, v); if (!lastAudio) { var b = this.getAudioBuffer(src, is_music); b.panWhenReady.push({ x: x_, y: y_, a: angle_, ia: innerangle_, oa: outerangle_, og: dbToLinear(outergain_), thistag: tag }); return; } lastAudio.setPannerEnabled(true); lastAudio.setPan(x_, y_, angle_, innerangle_, outerangle_, dbToLinear(outergain_)); lastAudio.play(looping!==0, v, 0, this.nextPlayTime); this.nextPlayTime = 0; }; Acts.prototype.PlayAtObject = function (file, looping, vol, obj, innerangle, outerangle, outergain, tag) { if (silent || !obj) return; var inst = obj.getFirstPicked(); if (!inst) return; var v = dbToLinear(vol); var is_music = file[1]; var src = this.runtime.files_subfolder + file[0] + (useOgg ? ".ogg" : ".m4a"); lastAudio = this.getAudioInstance(src, tag, is_music, looping!==0, v); if (!lastAudio) { var b = this.getAudioBuffer(src, is_music); b.panWhenReady.push({ obj: inst, ia: innerangle, oa: outerangle, og: dbToLinear(outergain), thistag: tag }); return; } lastAudio.setPannerEnabled(true); var px = cr.rotatePtAround(inst.x, inst.y, -inst.layer.getAngle(), listenerX, listenerY, true); var py = cr.rotatePtAround(inst.x, inst.y, -inst.layer.getAngle(), listenerX, listenerY, false); lastAudio.setPan(px, py, cr.to_degrees(inst.angle - inst.layer.getAngle()), innerangle, outerangle, dbToLinear(outergain)); lastAudio.setObject(inst); lastAudio.play(looping!==0, v, 0, this.nextPlayTime); this.nextPlayTime = 0; }; Acts.prototype.PlayByName = function (folder, filename, looping, vol, tag) { if (silent) return; var v = dbToLinear(vol); var is_music = (folder === 1); var src = this.runtime.files_subfolder + filename.toLowerCase() + (useOgg ? ".ogg" : ".m4a"); lastAudio = this.getAudioInstance(src, tag, is_music, looping!==0, v); if (!lastAudio) return; lastAudio.setPannerEnabled(false); lastAudio.play(looping!==0, v, 0, this.nextPlayTime); this.nextPlayTime = 0; }; Acts.prototype.PlayAtPositionByName = function (folder, filename, looping, vol, x_, y_, angle_, innerangle_, outerangle_, outergain_, tag) { if (silent) return; var v = dbToLinear(vol); var is_music = (folder === 1); var src = this.runtime.files_subfolder + filename.toLowerCase() + (useOgg ? ".ogg" : ".m4a"); lastAudio = this.getAudioInstance(src, tag, is_music, looping!==0, v); if (!lastAudio) { var b = this.getAudioBuffer(src, is_music); b.panWhenReady.push({ x: x_, y: y_, a: angle_, ia: innerangle_, oa: outerangle_, og: dbToLinear(outergain_), thistag: tag }); return; } lastAudio.setPannerEnabled(true); lastAudio.setPan(x_, y_, angle_, innerangle_, outerangle_, dbToLinear(outergain_)); lastAudio.play(looping!==0, v, 0, this.nextPlayTime); this.nextPlayTime = 0; }; Acts.prototype.PlayAtObjectByName = function (folder, filename, looping, vol, obj, innerangle, outerangle, outergain, tag) { if (silent || !obj) return; var inst = obj.getFirstPicked(); if (!inst) return; var v = dbToLinear(vol); var is_music = (folder === 1); var src = this.runtime.files_subfolder + filename.toLowerCase() + (useOgg ? ".ogg" : ".m4a"); lastAudio = this.getAudioInstance(src, tag, is_music, looping!==0, v); if (!lastAudio) { var b = this.getAudioBuffer(src, is_music); b.panWhenReady.push({ obj: inst, ia: innerangle, oa: outerangle, og: dbToLinear(outergain), thistag: tag }); return; } lastAudio.setPannerEnabled(true); var px = cr.rotatePtAround(inst.x, inst.y, -inst.layer.getAngle(), listenerX, listenerY, true); var py = cr.rotatePtAround(inst.x, inst.y, -inst.layer.getAngle(), listenerX, listenerY, false); lastAudio.setPan(px, py, cr.to_degrees(inst.angle - inst.layer.getAngle()), innerangle, outerangle, dbToLinear(outergain)); lastAudio.setObject(inst); lastAudio.play(looping!==0, v, 0, this.nextPlayTime); this.nextPlayTime = 0; }; Acts.prototype.SetLooping = function (tag, looping) { getAudioByTag(tag); var i, len; for (i = 0, len = taggedAudio.length; i < len; i++) taggedAudio[i].setLooping(looping === 0); }; Acts.prototype.SetMuted = function (tag, muted) { getAudioByTag(tag); var i, len; for (i = 0, len = taggedAudio.length; i < len; i++) taggedAudio[i].setMuted(muted === 0); }; Acts.prototype.SetVolume = function (tag, vol) { getAudioByTag(tag); var v = dbToLinear(vol); var i, len; for (i = 0, len = taggedAudio.length; i < len; i++) taggedAudio[i].setVolume(v); }; Acts.prototype.Preload = function (file) { if (silent) return; var is_music = file[1]; var src = this.runtime.files_subfolder + file[0] + (useOgg ? ".ogg" : ".m4a"); if (api === API_APPMOBI) { if (this.runtime.isDirectCanvas) AppMobi["context"]["loadSound"](src); else AppMobi["player"]["loadSound"](src); return; } else if (api === API_CORDOVA) { return; } this.getAudioInstance(src, "", is_music, false); }; Acts.prototype.PreloadByName = function (folder, filename) { if (silent) return; var is_music = (folder === 1); var src = this.runtime.files_subfolder + filename.toLowerCase() + (useOgg ? ".ogg" : ".m4a"); if (api === API_APPMOBI) { if (this.runtime.isDirectCanvas) AppMobi["context"]["loadSound"](src); else AppMobi["player"]["loadSound"](src); return; } else if (api === API_CORDOVA) { return; } this.getAudioInstance(src, "", is_music, false); }; Acts.prototype.SetPlaybackRate = function (tag, rate) { getAudioByTag(tag); if (rate < 0.0) rate = 0; var i, len; for (i = 0, len = taggedAudio.length; i < len; i++) taggedAudio[i].setPlaybackRate(rate); }; Acts.prototype.Stop = function (tag) { getAudioByTag(tag); var i, len; for (i = 0, len = taggedAudio.length; i < len; i++) taggedAudio[i].stop(); }; Acts.prototype.StopAll = function () { var i, len; for (i = 0, len = audioInstances.length; i < len; i++) audioInstances[i].stop(); }; Acts.prototype.SetPaused = function (tag, state) { getAudioByTag(tag); var i, len; for (i = 0, len = taggedAudio.length; i < len; i++) { if (state === 0) taggedAudio[i].pause(); else taggedAudio[i].resume(); } }; Acts.prototype.Seek = function (tag, pos) { getAudioByTag(tag); var i, len; for (i = 0, len = taggedAudio.length; i < len; i++) { taggedAudio[i].seek(pos); } }; Acts.prototype.SetSilent = function (s) { var i, len; if (s === 2) // toggling s = (silent ? 1 : 0); // choose opposite state if (s === 0 && !silent) // setting silent { for (i = 0, len = audioInstances.length; i < len; i++) audioInstances[i].setSilent(true); silent = true; } else if (s === 1 && silent) // setting not silent { for (i = 0, len = audioInstances.length; i < len; i++) audioInstances[i].setSilent(false); silent = false; } }; Acts.prototype.SetMasterVolume = function (vol) { masterVolume = dbToLinear(vol); var i, len; for (i = 0, len = audioInstances.length; i < len; i++) audioInstances[i].updateVolume(); }; Acts.prototype.AddFilterEffect = function (tag, type, freq, detune, q, gain, mix) { if (api !== API_WEBAUDIO || type < 0 || type >= filterTypes.length || !context["createBiquadFilter"]) return; tag = tag.toLowerCase(); mix = mix / 100; if (mix < 0) mix = 0; if (mix > 1) mix = 1; addEffectForTag(tag, new FilterEffect(type, freq, detune, q, gain, mix)); }; Acts.prototype.AddDelayEffect = function (tag, delay, gain, mix) { if (api !== API_WEBAUDIO) return; tag = tag.toLowerCase(); mix = mix / 100; if (mix < 0) mix = 0; if (mix > 1) mix = 1; addEffectForTag(tag, new DelayEffect(delay, dbToLinear(gain), mix)); }; Acts.prototype.AddFlangerEffect = function (tag, delay, modulation, freq, feedback, mix) { if (api !== API_WEBAUDIO || !context["createOscillator"]) return; tag = tag.toLowerCase(); mix = mix / 100; if (mix < 0) mix = 0; if (mix > 1) mix = 1; addEffectForTag(tag, new FlangerEffect(delay / 1000, modulation / 1000, freq, feedback / 100, mix)); }; Acts.prototype.AddPhaserEffect = function (tag, freq, detune, q, mod, modfreq, mix) { if (api !== API_WEBAUDIO || !context["createOscillator"]) return; tag = tag.toLowerCase(); mix = mix / 100; if (mix < 0) mix = 0; if (mix > 1) mix = 1; addEffectForTag(tag, new PhaserEffect(freq, detune, q, mod, modfreq, mix)); }; Acts.prototype.AddConvolutionEffect = function (tag, file, norm, mix) { if (api !== API_WEBAUDIO || !context["createConvolver"]) return; var doNormalize = (norm === 0); var src = this.runtime.files_subfolder + file[0] + (useOgg ? ".ogg" : ".m4a"); var b = this.getAudioBuffer(src, false); tag = tag.toLowerCase(); mix = mix / 100; if (mix < 0) mix = 0; if (mix > 1) mix = 1; var fx; if (b.bufferObject) { fx = new ConvolveEffect(b.bufferObject, doNormalize, mix, src); } else { fx = new ConvolveEffect(null, doNormalize, mix, src); b.normalizeWhenReady = doNormalize; b.convolveWhenReady = fx; } addEffectForTag(tag, fx); }; Acts.prototype.AddGainEffect = function (tag, g) { if (api !== API_WEBAUDIO) return; tag = tag.toLowerCase(); addEffectForTag(tag, new GainEffect(dbToLinear(g))); }; Acts.prototype.AddMuteEffect = function (tag) { if (api !== API_WEBAUDIO) return; tag = tag.toLowerCase(); addEffectForTag(tag, new GainEffect(0)); // re-use gain effect with 0 gain }; Acts.prototype.AddTremoloEffect = function (tag, freq, mix) { if (api !== API_WEBAUDIO || !context["createOscillator"]) return; tag = tag.toLowerCase(); mix = mix / 100; if (mix < 0) mix = 0; if (mix > 1) mix = 1; addEffectForTag(tag, new TremoloEffect(freq, mix)); }; Acts.prototype.AddRingModEffect = function (tag, freq, mix) { if (api !== API_WEBAUDIO || !context["createOscillator"]) return; tag = tag.toLowerCase(); mix = mix / 100; if (mix < 0) mix = 0; if (mix > 1) mix = 1; addEffectForTag(tag, new RingModulatorEffect(freq, mix)); }; Acts.prototype.AddDistortionEffect = function (tag, threshold, headroom, drive, makeupgain, mix) { if (api !== API_WEBAUDIO || !context["createWaveShaper"]) return; tag = tag.toLowerCase(); mix = mix / 100; if (mix < 0) mix = 0; if (mix > 1) mix = 1; addEffectForTag(tag, new DistortionEffect(threshold, headroom, drive, makeupgain, mix)); }; Acts.prototype.AddCompressorEffect = function (tag, threshold, knee, ratio, attack, release) { if (api !== API_WEBAUDIO || !context["createDynamicsCompressor"]) return; tag = tag.toLowerCase(); addEffectForTag(tag, new CompressorEffect(threshold, knee, ratio, attack / 1000, release / 1000)); }; Acts.prototype.AddAnalyserEffect = function (tag, fftSize, smoothing) { if (api !== API_WEBAUDIO) return; tag = tag.toLowerCase(); addEffectForTag(tag, new AnalyserEffect(fftSize, smoothing)); }; Acts.prototype.RemoveEffects = function (tag) { if (api !== API_WEBAUDIO) return; tag = tag.toLowerCase(); var i, len, arr; if (effects.hasOwnProperty(tag)) { arr = effects[tag]; if (arr.length) { for (i = 0, len = arr.length; i < len; i++) arr[i].remove(); cr.clearArray(arr); reconnectEffects(tag); } } }; Acts.prototype.SetEffectParameter = function (tag, index, param, value, ramp, time) { if (api !== API_WEBAUDIO) return; tag = tag.toLowerCase(); index = Math.floor(index); var arr; if (!effects.hasOwnProperty(tag)) return; arr = effects[tag]; if (index < 0 || index >= arr.length) return; arr[index].setParam(param, value, ramp, time); }; Acts.prototype.SetListenerObject = function (obj_) { if (!obj_ || api !== API_WEBAUDIO) return; var inst = obj_.getFirstPicked(); if (!inst) return; this.listenerTracker.setObject(inst); listenerX = inst.x; listenerY = inst.y; }; Acts.prototype.SetListenerZ = function (z) { this.listenerZ = z; }; Acts.prototype.ScheduleNextPlay = function (t) { if (!context) return; // needs Web Audio API this.nextPlayTime = t; }; Acts.prototype.UnloadAudio = function (file) { var is_music = file[1]; var src = this.runtime.files_subfolder + file[0] + (useOgg ? ".ogg" : ".m4a"); var b = this.getAudioBuffer(src, is_music, true /* don't create if missing */); if (!b) return; // not loaded b.release(); cr.arrayFindRemove(audioBuffers, b); }; Acts.prototype.UnloadAudioByName = function (folder, filename) { var is_music = (folder === 1); var src = this.runtime.files_subfolder + filename.toLowerCase() + (useOgg ? ".ogg" : ".m4a"); var b = this.getAudioBuffer(src, is_music, true /* don't create if missing */); if (!b) return; // not loaded b.release(); cr.arrayFindRemove(audioBuffers, b); }; Acts.prototype.UnloadAll = function () { var i, len; for (i = 0, len = audioBuffers.length; i < len; ++i) { audioBuffers[i].release(); }; cr.clearArray(audioBuffers); }; pluginProto.acts = new Acts(); function Exps() {}; Exps.prototype.Duration = function (ret, tag) { getAudioByTag(tag, true); if (taggedAudio.length) ret.set_float(taggedAudio[0].getDuration()); else ret.set_float(0); }; Exps.prototype.PlaybackTime = function (ret, tag) { getAudioByTag(tag, true); if (taggedAudio.length) ret.set_float(taggedAudio[0].getPlaybackTime(true)); else ret.set_float(0); }; Exps.prototype.Volume = function (ret, tag) { getAudioByTag(tag, true); if (taggedAudio.length) { var v = taggedAudio[0].getVolume(); ret.set_float(linearToDb(v)); } else ret.set_float(0); }; Exps.prototype.MasterVolume = function (ret) { ret.set_float(linearToDb(masterVolume)); }; Exps.prototype.EffectCount = function (ret, tag) { tag = tag.toLowerCase(); var arr = null; if (effects.hasOwnProperty(tag)) arr = effects[tag]; ret.set_int(arr ? arr.length : 0); }; function getAnalyser(tag, index) { var arr = null; if (effects.hasOwnProperty(tag)) arr = effects[tag]; if (arr && index >= 0 && index < arr.length && arr[index].freqBins) return arr[index]; else return null; }; Exps.prototype.AnalyserFreqBinCount = function (ret, tag, index) { tag = tag.toLowerCase(); index = Math.floor(index); var analyser = getAnalyser(tag, index); ret.set_int(analyser ? analyser.node["frequencyBinCount"] : 0); }; Exps.prototype.AnalyserFreqBinAt = function (ret, tag, index, bin) { tag = tag.toLowerCase(); index = Math.floor(index); bin = Math.floor(bin); var analyser = getAnalyser(tag, index); if (!analyser) ret.set_float(0); else if (bin < 0 || bin >= analyser.node["frequencyBinCount"]) ret.set_float(0); else ret.set_float(analyser.freqBins[bin]); }; Exps.prototype.AnalyserPeakLevel = function (ret, tag, index) { tag = tag.toLowerCase(); index = Math.floor(index); var analyser = getAnalyser(tag, index); if (analyser) ret.set_float(analyser.peak); else ret.set_float(0); }; Exps.prototype.AnalyserRMSLevel = function (ret, tag, index) { tag = tag.toLowerCase(); index = Math.floor(index); var analyser = getAnalyser(tag, index); if (analyser) ret.set_float(analyser.rms); else ret.set_float(0); }; Exps.prototype.SampleRate = function (ret) { ret.set_int(context ? context.sampleRate : 0); }; Exps.prototype.CurrentTime = function (ret) { ret.set_float(context ? context.currentTime : cr.performance_now()); }; pluginProto.exps = new Exps(); }()); ; ; cr.plugins_.Browser = function(runtime) { this.runtime = runtime; }; (function () { var pluginProto = cr.plugins_.Browser.prototype; pluginProto.Type = function(plugin) { this.plugin = plugin; this.runtime = plugin.runtime; }; var typeProto = pluginProto.Type.prototype; typeProto.onCreate = function() { }; var offlineScriptReady = false; var browserPluginReady = false; document.addEventListener("DOMContentLoaded", function () { if (window["C2_RegisterSW"] && navigator.serviceWorker) { var offlineClientScript = document.createElement("script"); offlineClientScript.onload = function () { offlineScriptReady = true; checkReady() }; offlineClientScript.src = "offlineClient.js"; document.head.appendChild(offlineClientScript); } }); var browserInstance = null; typeProto.onAppBegin = function () { browserPluginReady = true; checkReady(); }; function checkReady() { if (offlineScriptReady && browserPluginReady && window["OfflineClientInfo"]) { window["OfflineClientInfo"]["SetMessageCallback"](function (e) { browserInstance.onSWMessage(e); }); } }; pluginProto.Instance = function(type) { this.type = type; this.runtime = type.runtime; }; var instanceProto = pluginProto.Instance.prototype; instanceProto.onCreate = function() { var self = this; window.addEventListener("resize", function () { self.runtime.trigger(cr.plugins_.Browser.prototype.cnds.OnResize, self); }); browserInstance = this; if (typeof navigator.onLine !== "undefined") { window.addEventListener("online", function() { self.runtime.trigger(cr.plugins_.Browser.prototype.cnds.OnOnline, self); }); window.addEventListener("offline", function() { self.runtime.trigger(cr.plugins_.Browser.prototype.cnds.OnOffline, self); }); } if (typeof window.applicationCache !== "undefined") { window.applicationCache.addEventListener('updateready', function() { self.runtime.loadingprogress = 1; self.runtime.trigger(cr.plugins_.Browser.prototype.cnds.OnUpdateReady, self); }); window.applicationCache.addEventListener('progress', function(e) { self.runtime.loadingprogress = (e["loaded"] / e["total"]) || 0; }); } if (!this.runtime.isDirectCanvas) { document.addEventListener("appMobi.device.update.available", function() { self.runtime.trigger(cr.plugins_.Browser.prototype.cnds.OnUpdateReady, self); }); document.addEventListener("backbutton", function() { self.runtime.trigger(cr.plugins_.Browser.prototype.cnds.OnBackButton, self); }); document.addEventListener("menubutton", function() { self.runtime.trigger(cr.plugins_.Browser.prototype.cnds.OnMenuButton, self); }); document.addEventListener("searchbutton", function() { self.runtime.trigger(cr.plugins_.Browser.prototype.cnds.OnSearchButton, self); }); document.addEventListener("tizenhwkey", function (e) { var ret; switch (e["keyName"]) { case "back": ret = self.runtime.trigger(cr.plugins_.Browser.prototype.cnds.OnBackButton, self); if (!ret) { if (window["tizen"]) window["tizen"]["application"]["getCurrentApplication"]()["exit"](); } break; case "menu": ret = self.runtime.trigger(cr.plugins_.Browser.prototype.cnds.OnMenuButton, self); if (!ret) e.preventDefault(); break; } }); } if (this.runtime.isWindows10 && typeof Windows !== "undefined") { Windows["UI"]["Core"]["SystemNavigationManager"]["getForCurrentView"]().addEventListener("backrequested", function (e) { var ret = self.runtime.trigger(cr.plugins_.Browser.prototype.cnds.OnBackButton, self); if (ret) e["handled"] = true; }); } else if (this.runtime.isWinJS && WinJS["Application"]) { WinJS["Application"]["onbackclick"] = function (e) { return !!self.runtime.trigger(cr.plugins_.Browser.prototype.cnds.OnBackButton, self); }; } this.runtime.addSuspendCallback(function(s) { if (s) { self.runtime.trigger(cr.plugins_.Browser.prototype.cnds.OnPageHidden, self); } else { self.runtime.trigger(cr.plugins_.Browser.prototype.cnds.OnPageVisible, self); } }); this.is_arcade = (typeof window["is_scirra_arcade"] !== "undefined"); }; instanceProto.onSWMessage = function (e) { var messageType = e.data.type; if (messageType === "downloading-update") this.runtime.trigger(cr.plugins_.Browser.prototype.cnds.OnUpdateFound, this); else if (messageType === "update-ready" || messageType === "update-pending") this.runtime.trigger(cr.plugins_.Browser.prototype.cnds.OnUpdateReady, this); else if (messageType === "offline-ready") this.runtime.trigger(cr.plugins_.Browser.prototype.cnds.OnOfflineReady, this); }; var batteryManager = null; var loadedBatteryManager = false; function maybeLoadBatteryManager() { if (loadedBatteryManager) return; if (!navigator["getBattery"]) return; var promise = navigator["getBattery"](); loadedBatteryManager = true; if (promise) { promise.then(function (manager) { batteryManager = manager; }); } }; function Cnds() {}; Cnds.prototype.CookiesEnabled = function() { return navigator ? navigator.cookieEnabled : false; }; Cnds.prototype.IsOnline = function() { return navigator ? navigator.onLine : false; }; Cnds.prototype.HasJava = function() { return navigator ? navigator.javaEnabled() : false; }; Cnds.prototype.OnOnline = function() { return true; }; Cnds.prototype.OnOffline = function() { return true; }; Cnds.prototype.IsDownloadingUpdate = function () { if (typeof window["applicationCache"] === "undefined") return false; else return window["applicationCache"]["status"] === window["applicationCache"]["DOWNLOADING"]; }; Cnds.prototype.OnUpdateReady = function () { return true; }; Cnds.prototype.PageVisible = function () { return !this.runtime.isSuspended; }; Cnds.prototype.OnPageVisible = function () { return true; }; Cnds.prototype.OnPageHidden = function () { return true; }; Cnds.prototype.OnResize = function () { return true; }; Cnds.prototype.IsFullscreen = function () { return !!(document["mozFullScreen"] || document["webkitIsFullScreen"] || document["fullScreen"] || this.runtime.isNodeFullscreen); }; Cnds.prototype.OnBackButton = function () { return true; }; Cnds.prototype.OnMenuButton = function () { return true; }; Cnds.prototype.OnSearchButton = function () { return true; }; Cnds.prototype.IsMetered = function () { var connection = navigator["connection"] || navigator["mozConnection"] || navigator["webkitConnection"]; if (!connection) return false; return !!connection["metered"]; }; Cnds.prototype.IsCharging = function () { var battery = navigator["battery"] || navigator["mozBattery"] || navigator["webkitBattery"]; if (battery) { return !!battery["charging"] } else { maybeLoadBatteryManager(); if (batteryManager) { return !!batteryManager["charging"]; } else { return true; // if unknown, default to charging (powered) } } }; Cnds.prototype.IsPortraitLandscape = function (p) { var current = (window.innerWidth <= window.innerHeight ? 0 : 1); return current === p; }; Cnds.prototype.SupportsFullscreen = function () { if (this.runtime.isNodeWebkit) return true; var elem = this.runtime.canvasdiv || this.runtime.canvas; return !!(elem["requestFullscreen"] || elem["mozRequestFullScreen"] || elem["msRequestFullscreen"] || elem["webkitRequestFullScreen"]); }; Cnds.prototype.OnUpdateFound = function () { return true; }; Cnds.prototype.OnUpdateReady = function () { return true; }; Cnds.prototype.OnOfflineReady = function () { return true; }; pluginProto.cnds = new Cnds(); function Acts() {}; Acts.prototype.Alert = function (msg) { if (!this.runtime.isDomFree) alert(msg.toString()); }; Acts.prototype.Close = function () { if (this.runtime.isCocoonJs) CocoonJS["App"]["forceToFinish"](); else if (window["tizen"]) window["tizen"]["application"]["getCurrentApplication"]()["exit"](); else if (navigator["app"] && navigator["app"]["exitApp"]) navigator["app"]["exitApp"](); else if (navigator["device"] && navigator["device"]["exitApp"]) navigator["device"]["exitApp"](); else if (!this.is_arcade && !this.runtime.isDomFree) window.close(); }; Acts.prototype.Focus = function () { if (this.runtime.isNodeWebkit) { var win = window["nwgui"]["Window"]["get"](); win["focus"](); } else if (!this.is_arcade && !this.runtime.isDomFree) window.focus(); }; Acts.prototype.Blur = function () { if (this.runtime.isNodeWebkit) { var win = window["nwgui"]["Window"]["get"](); win["blur"](); } else if (!this.is_arcade && !this.runtime.isDomFree) window.blur(); }; Acts.prototype.GoBack = function () { if (navigator["app"] && navigator["app"]["backHistory"]) navigator["app"]["backHistory"](); else if (!this.is_arcade && !this.runtime.isDomFree && window.back) window.back(); }; Acts.prototype.GoForward = function () { if (!this.is_arcade && !this.runtime.isDomFree && window.forward) window.forward(); }; Acts.prototype.GoHome = function () { if (!this.is_arcade && !this.runtime.isDomFree && window.home) window.home(); }; Acts.prototype.GoToURL = function (url, target) { if (this.runtime.isCocoonJs) CocoonJS["App"]["openURL"](url); else if (this.runtime.isEjecta) ejecta["openURL"](url); else if (this.runtime.isWinJS) Windows["System"]["Launcher"]["launchUriAsync"](new Windows["Foundation"]["Uri"](url)); else if (navigator["app"] && navigator["app"]["loadUrl"]) navigator["app"]["loadUrl"](url, { "openExternal": true }); else if (this.runtime.isCordova) window.open(url, "_system"); else if (!this.is_arcade && !this.runtime.isDomFree) { if (target === 2 && !this.is_arcade) // top window.top.location = url; else if (target === 1 && !this.is_arcade) // parent window.parent.location = url; else // self window.location = url; } }; Acts.prototype.GoToURLWindow = function (url, tag) { if (this.runtime.isCocoonJs) CocoonJS["App"]["openURL"](url); else if (this.runtime.isEjecta) ejecta["openURL"](url); else if (this.runtime.isWinJS) Windows["System"]["Launcher"]["launchUriAsync"](new Windows["Foundation"]["Uri"](url)); else if (navigator["app"] && navigator["app"]["loadUrl"]) navigator["app"]["loadUrl"](url, { "openExternal": true }); else if (this.runtime.isCordova) window.open(url, "_system"); else if (!this.is_arcade && !this.runtime.isDomFree) window.open(url, tag); }; Acts.prototype.Reload = function () { if (!this.is_arcade && !this.runtime.isDomFree) window.location.reload(); }; var firstRequestFullscreen = true; var crruntime = null; function onFullscreenError(e) { if (console && console.warn) console.warn("Fullscreen request failed: ", e); crruntime["setSize"](window.innerWidth, window.innerHeight); }; Acts.prototype.RequestFullScreen = function (stretchmode) { if (this.runtime.isDomFree) { cr.logexport("[Construct 2] Requesting fullscreen is not supported on this platform - the request has been ignored"); return; } if (stretchmode >= 2) stretchmode += 1; if (stretchmode === 6) stretchmode = 2; if (this.runtime.isNodeWebkit) { if (this.runtime.isDebug) { debuggerFullscreen(true); } else if (!this.runtime.isNodeFullscreen && window["nwgui"]) { window["nwgui"]["Window"]["get"]()["enterFullscreen"](); this.runtime.isNodeFullscreen = true; this.runtime.fullscreen_scaling = (stretchmode >= 2 ? stretchmode : 0); } } else { if (document["mozFullScreen"] || document["webkitIsFullScreen"] || !!document["msFullscreenElement"] || document["fullScreen"] || document["fullScreenElement"]) { return; } this.runtime.fullscreen_scaling = (stretchmode >= 2 ? stretchmode : 0); var elem = document.documentElement; if (firstRequestFullscreen) { firstRequestFullscreen = false; crruntime = this.runtime; elem.addEventListener("mozfullscreenerror", onFullscreenError); elem.addEventListener("webkitfullscreenerror", onFullscreenError); elem.addEventListener("MSFullscreenError", onFullscreenError); elem.addEventListener("fullscreenerror", onFullscreenError); } if (elem["requestFullscreen"]) elem["requestFullscreen"](); else if (elem["mozRequestFullScreen"]) elem["mozRequestFullScreen"](); else if (elem["msRequestFullscreen"]) elem["msRequestFullscreen"](); else if (elem["webkitRequestFullScreen"]) { if (typeof Element !== "undefined" && typeof Element["ALLOW_KEYBOARD_INPUT"] !== "undefined") elem["webkitRequestFullScreen"](Element["ALLOW_KEYBOARD_INPUT"]); else elem["webkitRequestFullScreen"](); } } }; Acts.prototype.CancelFullScreen = function () { if (this.runtime.isDomFree) { cr.logexport("[Construct 2] Exiting fullscreen is not supported on this platform - the request has been ignored"); return; } if (this.runtime.isNodeWebkit) { if (this.runtime.isDebug) { debuggerFullscreen(false); } else if (this.runtime.isNodeFullscreen && window["nwgui"]) { window["nwgui"]["Window"]["get"]()["leaveFullscreen"](); this.runtime.isNodeFullscreen = false; } } else { if (document["exitFullscreen"]) document["exitFullscreen"](); else if (document["mozCancelFullScreen"]) document["mozCancelFullScreen"](); else if (document["msExitFullscreen"]) document["msExitFullscreen"](); else if (document["webkitCancelFullScreen"]) document["webkitCancelFullScreen"](); } }; Acts.prototype.Vibrate = function (pattern_) { try { var arr = pattern_.split(","); var i, len; for (i = 0, len = arr.length; i < len; i++) { arr[i] = parseInt(arr[i], 10); } if (navigator["vibrate"]) navigator["vibrate"](arr); else if (navigator["mozVibrate"]) navigator["mozVibrate"](arr); else if (navigator["webkitVibrate"]) navigator["webkitVibrate"](arr); else if (navigator["msVibrate"]) navigator["msVibrate"](arr); } catch (e) {} }; Acts.prototype.InvokeDownload = function (url_, filename_) { var a = document.createElement("a"); if (typeof a["download"] === "undefined") { window.open(url_); } else { var body = document.getElementsByTagName("body")[0]; a.textContent = filename_; a.href = url_; a["download"] = filename_; body.appendChild(a); var clickEvent = new MouseEvent("click"); a.dispatchEvent(clickEvent); body.removeChild(a); } }; Acts.prototype.InvokeDownloadString = function (str_, mimetype_, filename_) { var datauri = "data:" + mimetype_ + "," + encodeURIComponent(str_); var a = document.createElement("a"); if (typeof a["download"] === "undefined") { window.open(datauri); } else { var body = document.getElementsByTagName("body")[0]; a.textContent = filename_; a.href = datauri; a["download"] = filename_; body.appendChild(a); var clickEvent = new MouseEvent("click"); a.dispatchEvent(clickEvent); body.removeChild(a); } }; Acts.prototype.ConsoleLog = function (type_, msg_) { if (typeof console === "undefined") return; if (type_ === 0 && console.log) console.log(msg_.toString()); if (type_ === 1 && console.warn) console.warn(msg_.toString()); if (type_ === 2 && console.error) console.error(msg_.toString()); }; Acts.prototype.ConsoleGroup = function (name_) { if (console && console.group) console.group(name_); }; Acts.prototype.ConsoleGroupEnd = function () { if (console && console.groupEnd) console.groupEnd(); }; Acts.prototype.ExecJs = function (js_) { try { if (eval) eval(js_); } catch (e) { if (console && console.error) console.error("Error executing Javascript: ", e); } }; var orientations = [ "portrait", "landscape", "portrait-primary", "portrait-secondary", "landscape-primary", "landscape-secondary" ]; Acts.prototype.LockOrientation = function (o) { o = Math.floor(o); if (o < 0 || o >= orientations.length) return; this.runtime.autoLockOrientation = false; var orientation = orientations[o]; if (screen["orientation"] && screen["orientation"]["lock"]) screen["orientation"]["lock"](orientation); else if (screen["lockOrientation"]) screen["lockOrientation"](orientation); else if (screen["webkitLockOrientation"]) screen["webkitLockOrientation"](orientation); else if (screen["mozLockOrientation"]) screen["mozLockOrientation"](orientation); else if (screen["msLockOrientation"]) screen["msLockOrientation"](orientation); }; Acts.prototype.UnlockOrientation = function () { this.runtime.autoLockOrientation = false; if (screen["orientation"] && screen["orientation"]["unlock"]) screen["orientation"]["unlock"](); else if (screen["unlockOrientation"]) screen["unlockOrientation"](); else if (screen["webkitUnlockOrientation"]) screen["webkitUnlockOrientation"](); else if (screen["mozUnlockOrientation"]) screen["mozUnlockOrientation"](); else if (screen["msUnlockOrientation"]) screen["msUnlockOrientation"](); }; pluginProto.acts = new Acts(); function Exps() {}; Exps.prototype.URL = function (ret) { ret.set_string(this.runtime.isDomFree ? "" : window.location.toString()); }; Exps.prototype.Protocol = function (ret) { ret.set_string(this.runtime.isDomFree ? "" : window.location.protocol); }; Exps.prototype.Domain = function (ret) { ret.set_string(this.runtime.isDomFree ? "" : window.location.hostname); }; Exps.prototype.PathName = function (ret) { ret.set_string(this.runtime.isDomFree ? "" : window.location.pathname); }; Exps.prototype.Hash = function (ret) { ret.set_string(this.runtime.isDomFree ? "" : window.location.hash); }; Exps.prototype.Referrer = function (ret) { ret.set_string(this.runtime.isDomFree ? "" : document.referrer); }; Exps.prototype.Title = function (ret) { ret.set_string(this.runtime.isDomFree ? "" : document.title); }; Exps.prototype.Name = function (ret) { ret.set_string(this.runtime.isDomFree ? "" : navigator.appName); }; Exps.prototype.Version = function (ret) { ret.set_string(this.runtime.isDomFree ? "" : navigator.appVersion); }; Exps.prototype.Language = function (ret) { if (navigator && navigator.language) ret.set_string(navigator.language); else ret.set_string(""); }; Exps.prototype.Platform = function (ret) { ret.set_string(this.runtime.isDomFree ? "" : navigator.platform); }; Exps.prototype.Product = function (ret) { if (navigator && navigator.product) ret.set_string(navigator.product); else ret.set_string(""); }; Exps.prototype.Vendor = function (ret) { if (navigator && navigator.vendor) ret.set_string(navigator.vendor); else ret.set_string(""); }; Exps.prototype.UserAgent = function (ret) { ret.set_string(this.runtime.isDomFree ? "" : navigator.userAgent); }; Exps.prototype.QueryString = function (ret) { ret.set_string(this.runtime.isDomFree ? "" : window.location.search); }; Exps.prototype.QueryParam = function (ret, paramname) { if (this.runtime.isDomFree) { ret.set_string(""); return; } var match = RegExp('[?&]' + paramname + '=([^&]*)').exec(window.location.search); if (match) ret.set_string(decodeURIComponent(match[1].replace(/\+/g, ' '))); else ret.set_string(""); }; Exps.prototype.Bandwidth = function (ret) { var connection = navigator["connection"] || navigator["mozConnection"] || navigator["webkitConnection"]; if (!connection) ret.set_float(Number.POSITIVE_INFINITY); else { if (typeof connection["bandwidth"] !== "undefined") ret.set_float(connection["bandwidth"]); else if (typeof connection["downlinkMax"] !== "undefined") ret.set_float(connection["downlinkMax"]); else ret.set_float(Number.POSITIVE_INFINITY); } }; Exps.prototype.ConnectionType = function (ret) { var connection = navigator["connection"] || navigator["mozConnection"] || navigator["webkitConnection"]; if (!connection) ret.set_string("unknown"); else { ret.set_string(connection["type"] || "unknown"); } }; Exps.prototype.BatteryLevel = function (ret) { var battery = navigator["battery"] || navigator["mozBattery"] || navigator["webkitBattery"]; if (battery) { ret.set_float(battery["level"]); } else { maybeLoadBatteryManager(); if (batteryManager) { ret.set_float(batteryManager["level"]); } else { ret.set_float(1); // not supported/unknown: assume charged } } }; Exps.prototype.BatteryTimeLeft = function (ret) { var battery = navigator["battery"] || navigator["mozBattery"] || navigator["webkitBattery"]; if (battery) { ret.set_float(battery["dischargingTime"]); } else { maybeLoadBatteryManager(); if (batteryManager) { ret.set_float(batteryManager["dischargingTime"]); } else { ret.set_float(Number.POSITIVE_INFINITY); // not supported/unknown: assume infinite time left } } }; Exps.prototype.ExecJS = function (ret, js_) { if (!eval) { ret.set_any(0); return; } var result = 0; try { result = eval(js_); } catch (e) { if (console && console.error) console.error("Error executing Javascript: ", e); } if (typeof result === "number") ret.set_any(result); else if (typeof result === "string") ret.set_any(result); else if (typeof result === "boolean") ret.set_any(result ? 1 : 0); else ret.set_any(0); }; Exps.prototype.ScreenWidth = function (ret) { ret.set_int(screen.width); }; Exps.prototype.ScreenHeight = function (ret) { ret.set_int(screen.height); }; Exps.prototype.DevicePixelRatio = function (ret) { ret.set_float(this.runtime.devicePixelRatio); }; Exps.prototype.WindowInnerWidth = function (ret) { ret.set_int(window.innerWidth); }; Exps.prototype.WindowInnerHeight = function (ret) { ret.set_int(window.innerHeight); }; Exps.prototype.WindowOuterWidth = function (ret) { ret.set_int(window.outerWidth); }; Exps.prototype.WindowOuterHeight = function (ret) { ret.set_int(window.outerHeight); }; pluginProto.exps = new Exps(); }()); ; ; cr.plugins_.Function = function(runtime) { this.runtime = runtime; }; (function () { var pluginProto = cr.plugins_.Function.prototype; pluginProto.Type = function(plugin) { this.plugin = plugin; this.runtime = plugin.runtime; }; var typeProto = pluginProto.Type.prototype; typeProto.onCreate = function() { }; pluginProto.Instance = function(type) { this.type = type; this.runtime = type.runtime; }; var instanceProto = pluginProto.Instance.prototype; var funcStack = []; var funcStackPtr = -1; var isInPreview = false; // set in onCreate function FuncStackEntry() { this.name = ""; this.retVal = 0; this.params = []; }; function pushFuncStack() { funcStackPtr++; if (funcStackPtr === funcStack.length) funcStack.push(new FuncStackEntry()); return funcStack[funcStackPtr]; }; function getCurrentFuncStack() { if (funcStackPtr < 0) return null; return funcStack[funcStackPtr]; }; function getOneAboveFuncStack() { if (!funcStack.length) return null; var i = funcStackPtr + 1; if (i >= funcStack.length) i = funcStack.length - 1; return funcStack[i]; }; function popFuncStack() { ; funcStackPtr--; }; instanceProto.onCreate = function() { isInPreview = (typeof cr_is_preview !== "undefined"); var self = this; window["c2_callFunction"] = function (name_, params_) { var i, len, v; var fs = pushFuncStack(); fs.name = name_.toLowerCase(); fs.retVal = 0; if (params_) { fs.params.length = params_.length; for (i = 0, len = params_.length; i < len; ++i) { v = params_[i]; if (typeof v === "number" || typeof v === "string") fs.params[i] = v; else if (typeof v === "boolean") fs.params[i] = (v ? 1 : 0); else fs.params[i] = 0; } } else { cr.clearArray(fs.params); } self.runtime.trigger(cr.plugins_.Function.prototype.cnds.OnFunction, self, fs.name); popFuncStack(); return fs.retVal; }; }; function Cnds() {}; Cnds.prototype.OnFunction = function (name_) { var fs = getCurrentFuncStack(); if (!fs) return false; return cr.equals_nocase(name_, fs.name); }; Cnds.prototype.CompareParam = function (index_, cmp_, value_) { var fs = getCurrentFuncStack(); if (!fs) return false; index_ = cr.floor(index_); if (index_ < 0 || index_ >= fs.params.length) return false; return cr.do_cmp(fs.params[index_], cmp_, value_); }; pluginProto.cnds = new Cnds(); function Acts() {}; Acts.prototype.CallFunction = function (name_, params_) { var fs = pushFuncStack(); fs.name = name_.toLowerCase(); fs.retVal = 0; cr.shallowAssignArray(fs.params, params_); var ran = this.runtime.trigger(cr.plugins_.Function.prototype.cnds.OnFunction, this, fs.name); if (isInPreview && !ran) { ; } popFuncStack(); }; Acts.prototype.SetReturnValue = function (value_) { var fs = getCurrentFuncStack(); if (fs) fs.retVal = value_; else ; }; Acts.prototype.CallExpression = function (unused) { }; pluginProto.acts = new Acts(); function Exps() {}; Exps.prototype.ReturnValue = function (ret) { var fs = getOneAboveFuncStack(); if (fs) ret.set_any(fs.retVal); else ret.set_int(0); }; Exps.prototype.ParamCount = function (ret) { var fs = getCurrentFuncStack(); if (fs) ret.set_int(fs.params.length); else { ; ret.set_int(0); } }; Exps.prototype.Param = function (ret, index_) { index_ = cr.floor(index_); var fs = getCurrentFuncStack(); if (fs) { if (index_ >= 0 && index_ < fs.params.length) { ret.set_any(fs.params[index_]); } else { ; ret.set_int(0); } } else { ; ret.set_int(0); } }; Exps.prototype.Call = function (ret, name_) { var fs = pushFuncStack(); fs.name = name_.toLowerCase(); fs.retVal = 0; cr.clearArray(fs.params); var i, len; for (i = 2, len = arguments.length; i < len; i++) fs.params.push(arguments[i]); var ran = this.runtime.trigger(cr.plugins_.Function.prototype.cnds.OnFunction, this, fs.name); if (isInPreview && !ran) { ; } popFuncStack(); ret.set_any(fs.retVal); }; pluginProto.exps = new Exps(); }()); ; ; cr.plugins_.Keyboard = function(runtime) { this.runtime = runtime; }; (function () { var pluginProto = cr.plugins_.Keyboard.prototype; pluginProto.Type = function(plugin) { this.plugin = plugin; this.runtime = plugin.runtime; }; var typeProto = pluginProto.Type.prototype; typeProto.onCreate = function() { }; pluginProto.Instance = function(type) { this.type = type; this.runtime = type.runtime; this.keyMap = new Array(256); // stores key up/down state this.usedKeys = new Array(256); this.triggerKey = 0; }; var instanceProto = pluginProto.Instance.prototype; instanceProto.onCreate = function() { var self = this; if (!this.runtime.isDomFree) { jQuery(document).keydown( function(info) { self.onKeyDown(info); } ); jQuery(document).keyup( function(info) { self.onKeyUp(info); } ); } }; var keysToBlockWhenFramed = [32, 33, 34, 35, 36, 37, 38, 39, 40, 44]; instanceProto.onKeyDown = function (info) { var alreadyPreventedDefault = false; if (window != window.top && keysToBlockWhenFramed.indexOf(info.which) > -1) { info.preventDefault(); alreadyPreventedDefault = true; info.stopPropagation(); } if (this.keyMap[info.which]) { if (this.usedKeys[info.which] && !alreadyPreventedDefault) info.preventDefault(); return; } this.keyMap[info.which] = true; this.triggerKey = info.which; this.runtime.isInUserInputEvent = true; this.runtime.trigger(cr.plugins_.Keyboard.prototype.cnds.OnAnyKey, this); var eventRan = this.runtime.trigger(cr.plugins_.Keyboard.prototype.cnds.OnKey, this); var eventRan2 = this.runtime.trigger(cr.plugins_.Keyboard.prototype.cnds.OnKeyCode, this); this.runtime.isInUserInputEvent = false; if (eventRan || eventRan2) { this.usedKeys[info.which] = true; if (!alreadyPreventedDefault) info.preventDefault(); } }; instanceProto.onKeyUp = function (info) { this.keyMap[info.which] = false; this.triggerKey = info.which; this.runtime.isInUserInputEvent = true; this.runtime.trigger(cr.plugins_.Keyboard.prototype.cnds.OnAnyKeyReleased, this); var eventRan = this.runtime.trigger(cr.plugins_.Keyboard.prototype.cnds.OnKeyReleased, this); var eventRan2 = this.runtime.trigger(cr.plugins_.Keyboard.prototype.cnds.OnKeyCodeReleased, this); this.runtime.isInUserInputEvent = false; if (eventRan || eventRan2 || this.usedKeys[info.which]) { this.usedKeys[info.which] = true; info.preventDefault(); } }; instanceProto.onWindowBlur = function () { var i; for (i = 0; i < 256; ++i) { if (!this.keyMap[i]) continue; // key already up this.keyMap[i] = false; this.triggerKey = i; this.runtime.trigger(cr.plugins_.Keyboard.prototype.cnds.OnAnyKeyReleased, this); var eventRan = this.runtime.trigger(cr.plugins_.Keyboard.prototype.cnds.OnKeyReleased, this); var eventRan2 = this.runtime.trigger(cr.plugins_.Keyboard.prototype.cnds.OnKeyCodeReleased, this); if (eventRan || eventRan2) this.usedKeys[i] = true; } }; instanceProto.saveToJSON = function () { return { "triggerKey": this.triggerKey }; }; instanceProto.loadFromJSON = function (o) { this.triggerKey = o["triggerKey"]; }; function Cnds() {}; Cnds.prototype.IsKeyDown = function(key) { return this.keyMap[key]; }; Cnds.prototype.OnKey = function(key) { return (key === this.triggerKey); }; Cnds.prototype.OnAnyKey = function(key) { return true; }; Cnds.prototype.OnAnyKeyReleased = function(key) { return true; }; Cnds.prototype.OnKeyReleased = function(key) { return (key === this.triggerKey); }; Cnds.prototype.IsKeyCodeDown = function(key) { key = Math.floor(key); if (key < 0 || key >= this.keyMap.length) return false; return this.keyMap[key]; }; Cnds.prototype.OnKeyCode = function(key) { return (key === this.triggerKey); }; Cnds.prototype.OnKeyCodeReleased = function(key) { return (key === this.triggerKey); }; pluginProto.cnds = new Cnds(); function Acts() {}; pluginProto.acts = new Acts(); function Exps() {}; Exps.prototype.LastKeyCode = function (ret) { ret.set_int(this.triggerKey); }; function fixedStringFromCharCode(kc) { kc = Math.floor(kc); switch (kc) { case 8: return "backspace"; case 9: return "tab"; case 13: return "enter"; case 16: return "shift"; case 17: return "control"; case 18: return "alt"; case 19: return "pause"; case 20: return "capslock"; case 27: return "esc"; case 33: return "pageup"; case 34: return "pagedown"; case 35: return "end"; case 36: return "home"; case 37: return "←"; case 38: return "↑"; case 39: return "→"; case 40: return "↓"; case 45: return "insert"; case 46: return "del"; case 91: return "left window key"; case 92: return "right window key"; case 93: return "select"; case 96: return "numpad 0"; case 97: return "numpad 1"; case 98: return "numpad 2"; case 99: return "numpad 3"; case 100: return "numpad 4"; case 101: return "numpad 5"; case 102: return "numpad 6"; case 103: return "numpad 7"; case 104: return "numpad 8"; case 105: return "numpad 9"; case 106: return "numpad *"; case 107: return "numpad +"; case 109: return "numpad -"; case 110: return "numpad ."; case 111: return "numpad /"; case 112: return "F1"; case 113: return "F2"; case 114: return "F3"; case 115: return "F4"; case 116: return "F5"; case 117: return "F6"; case 118: return "F7"; case 119: return "F8"; case 120: return "F9"; case 121: return "F10"; case 122: return "F11"; case 123: return "F12"; case 144: return "numlock"; case 145: return "scroll lock"; case 186: return ";"; case 187: return "="; case 188: return ","; case 189: return "-"; case 190: return "."; case 191: return "/"; case 192: return "'"; case 219: return "["; case 220: return "\\"; case 221: return "]"; case 222: return "#"; case 223: return "`"; default: return String.fromCharCode(kc); } }; Exps.prototype.StringFromKeyCode = function (ret, kc) { ret.set_string(fixedStringFromCharCode(kc)); }; pluginProto.exps = new Exps(); }()); ; ; cr.plugins_.Kongregate = function(runtime) { this.runtime = runtime; }; (function () { var pluginProto = cr.plugins_.Kongregate.prototype; pluginProto.Type = function(plugin) { this.plugin = plugin; this.runtime = plugin.runtime; }; var typeProto = pluginProto.Type.prototype; typeProto.onCreate = function() { }; var kongregate = null; var kRuntime = null; var kInst = null; var kUserID = 0; var kUserName = "Guest"; function OnKongregateInPageLogin() { kUserID = kongregate["services"]["getUserId"](); kUserName = kongregate["services"]["getUsername"](); kRuntime.trigger(cr.plugins_.Kongregate.prototype.cnds.OnLogin, kInst); }; function KongregateLoadComplete() { kongregate = window["kongregateAPI"]["getAPI"](); kongregate["services"]["connect"](); kongregate["services"]["addEventListener"]("login", OnKongregateInPageLogin); kUserID = kongregate["services"]["getUserId"](); kUserName = kongregate["services"]["getUsername"](); if (kUserID > 0) kRuntime.trigger(cr.plugins_.Kongregate.prototype.cnds.OnLogin, kInst); }; pluginProto.Instance = function(type) { this.type = type; this.runtime = type.runtime; kRuntime = this.runtime; kInst = this; if (!this.runtime.isDomFree && typeof window["kongregateAPI"] !== "undefined") window["kongregateAPI"]["loadAPI"](KongregateLoadComplete); }; var instanceProto = pluginProto.Instance.prototype; instanceProto.onCreate = function() { }; instanceProto.onLayoutChange = function () { if (kUserID > 0) kRuntime.trigger(cr.plugins_.Kongregate.prototype.cnds.OnLogin, kInst); }; function Cnds() {}; Cnds.prototype.IsGuest = function () { if (!kongregate) return true; // preview mode return kongregate["services"]["isGuest"](); }; Cnds.prototype.OnLogin = function () { return true; }; pluginProto.cnds = new Cnds(); function Acts() {}; Acts.prototype.ShowRegBox = function () { if (kongregate && kUserID === 0) kongregate["services"]["showRegistrationBox"](); }; Acts.prototype.SubmitStat = function (name_, value_) { if (kongregate) kongregate["stats"]["submit"](name_, value_); }; Acts.prototype.ShowShoutBox = function (msg) { if (kUserID > 0) kongregate["services"]["showShoutBox"](msg); }; Acts.prototype.ShowSignInBox = function () { if (kongregate && kUserID === 0) kongregate["services"]["showSignInBox"](); }; pluginProto.acts = new Acts(); function Exps() {}; Exps.prototype.UserID = function (ret) { ret.set_int(kUserID); }; Exps.prototype.UserName = function (ret) { ret.set_string(kUserName); }; pluginProto.exps = new Exps(); }()); ; ; var localForageInitFailed = false; try { /*! localForage -- Offline Storage, Improved Version 1.4.0 https://mozilla.github.io/localForage (c) 2013-2015 Mozilla, Apache License 2.0 */ !function(){var a,b,c,d;!function(){var e={},f={};a=function(a,b,c){e[a]={deps:b,callback:c}},d=c=b=function(a){function c(b){if("."!==b.charAt(0))return b;for(var c=b.split("/"),d=a.split("/").slice(0,-1),e=0,f=c.length;f>e;e++){var g=c[e];if(".."===g)d.pop();else{if("."===g)continue;d.push(g)}}return d.join("/")}if(d._eak_seen=e,f[a])return f[a];if(f[a]={},!e[a])throw new Error("Could not find module "+a);for(var g,h=e[a],i=h.deps,j=h.callback,k=[],l=0,m=i.length;m>l;l++)"exports"===i[l]?k.push(g={}):k.push(b(c(i[l])));var n=j.apply(this,k);return f[a]=g||n}}(),a("promise/all",["./utils","exports"],function(a,b){"use strict";function c(a){var b=this;if(!d(a))throw new TypeError("You must pass an array to all.");return new b(function(b,c){function d(a){return function(b){f(a,b)}}function f(a,c){h[a]=c,0===--i&&b(h)}var g,h=[],i=a.length;0===i&&b([]);for(var j=0;jc;c++){var e=a[c];this.supports(e)&&b.push(e)}return b},a.prototype._wrapLibraryMethodsWithReady=function(){for(var a=0;ae;e++)d[e]=a.charCodeAt(e);return c}function d(a){return new Promise(function(b,c){var d=new XMLHttpRequest;d.open("GET",a),d.withCredentials=!0,d.responseType="arraybuffer",d.onreadystatechange=function(){return 4===d.readyState?200===d.status?b({response:d.response,type:d.getResponseHeader("Content-Type")}):void c({status:d.status,response:d.response}):void 0},d.send()})}function e(a){return new Promise(function(c,e){var f=b([""],{type:"image/png"}),g=a.transaction([D],"readwrite");g.objectStore(D).put(f,"key"),g.oncomplete=function(){var b=a.transaction([D],"readwrite"),f=b.objectStore(D).get("key");f.onerror=e,f.onsuccess=function(a){var b=a.target.result,e=URL.createObjectURL(b);d(e).then(function(a){c(!(!a||"image/png"!==a.type))},function(){c(!1)}).then(function(){URL.revokeObjectURL(e)})}},g.onerror=g.onabort=e})["catch"](function(){return!1})}function f(a){return"boolean"==typeof B?Promise.resolve(B):e(a).then(function(a){return B=a})}function g(a){return new Promise(function(b,c){var d=new FileReader;d.onerror=c,d.onloadend=function(c){var d=btoa(c.target.result||"");b({__local_forage_encoded_blob:!0,data:d,type:a.type})},d.readAsBinaryString(a)})}function h(a){var d=c(atob(a.data));return b([d],{type:a.type})}function i(a){return a&&a.__local_forage_encoded_blob}function j(a){var b=this,c=b._initReady().then(function(){var a=C[b._dbInfo.name];return a&&a.dbReady?a.dbReady:void 0});return c.then(a,a),c}function k(a){var b=C[a.name],c={};c.promise=new Promise(function(a){c.resolve=a}),b.deferredOperations.push(c),b.dbReady?b.dbReady=b.dbReady.then(function(){return c.promise}):b.dbReady=c.promise}function l(a){var b=C[a.name],c=b.deferredOperations.pop();c&&c.resolve()}function m(a){function b(){return Promise.resolve()}var c=this,d={db:null};if(a)for(var e in a)d[e]=a[e];C||(C={});var f=C[d.name];f||(f={forages:[],db:null,dbReady:null,deferredOperations:[]},C[d.name]=f),f.forages.push(c),c._initReady||(c._initReady=c.ready,c.ready=j);for(var g=[],h=0;hb.db.version;if(e&&(b.version!==c&&a.console.warn('The database "'+b.name+"\" can't be downgraded from version "+b.db.version+" to version "+b.version+"."),b.version=b.db.version),f||d){if(d){var g=b.db.version+1;g>b.version&&(b.version=g)}return!0}return!1}function r(b,c){var d=this;"string"!=typeof b&&(a.console.warn(b+" used as a key, but it is not a string."),b=String(b));var e=new Promise(function(a,c){d.ready().then(function(){var e=d._dbInfo,f=e.db.transaction(e.storeName,"readonly").objectStore(e.storeName),g=f.get(b);g.onsuccess=function(){var b=g.result;void 0===b&&(b=null),i(b)&&(b=h(b)),a(b)},g.onerror=function(){c(g.error)}})["catch"](c)});return z(e,c),e}function s(a,b){var c=this,d=new Promise(function(b,d){c.ready().then(function(){var e=c._dbInfo,f=e.db.transaction(e.storeName,"readonly").objectStore(e.storeName),g=f.openCursor(),j=1;g.onsuccess=function(){var c=g.result;if(c){var d=c.value;i(d)&&(d=h(d));var e=a(d,c.key,j++);void 0!==e?b(e):c["continue"]()}else b()},g.onerror=function(){d(g.error)}})["catch"](d)});return z(d,b),d}function t(b,c,d){var e=this;"string"!=typeof b&&(a.console.warn(b+" used as a key, but it is not a string."),b=String(b));var h=new Promise(function(a,d){var h;e.ready().then(function(){return h=e._dbInfo,c instanceof Blob?f(h.db).then(function(a){return a?c:g(c)}):c}).then(function(c){var e=h.db.transaction(h.storeName,"readwrite"),f=e.objectStore(h.storeName);null===c&&(c=void 0),e.oncomplete=function(){void 0===c&&(c=null),a(c)},e.onabort=e.onerror=function(){var a=g.error?g.error:g.transaction.error;d(a)};var g=f.put(c,b)})["catch"](d)});return z(h,d),h}function u(b,c){var d=this;"string"!=typeof b&&(a.console.warn(b+" used as a key, but it is not a string."),b=String(b));var e=new Promise(function(a,c){d.ready().then(function(){var e=d._dbInfo,f=e.db.transaction(e.storeName,"readwrite"),g=f.objectStore(e.storeName),h=g["delete"](b);f.oncomplete=function(){a()},f.onerror=function(){c(h.error)},f.onabort=function(){var a=h.error?h.error:h.transaction.error;c(a)}})["catch"](c)});return z(e,c),e}function v(a){var b=this,c=new Promise(function(a,c){b.ready().then(function(){var d=b._dbInfo,e=d.db.transaction(d.storeName,"readwrite"),f=e.objectStore(d.storeName),g=f.clear();e.oncomplete=function(){a()},e.onabort=e.onerror=function(){var a=g.error?g.error:g.transaction.error;c(a)}})["catch"](c)});return z(c,a),c}function w(a){var b=this,c=new Promise(function(a,c){b.ready().then(function(){var d=b._dbInfo,e=d.db.transaction(d.storeName,"readonly").objectStore(d.storeName),f=e.count();f.onsuccess=function(){a(f.result)},f.onerror=function(){c(f.error)}})["catch"](c)});return z(c,a),c}function x(a,b){var c=this,d=new Promise(function(b,d){return 0>a?void b(null):void c.ready().then(function(){var e=c._dbInfo,f=e.db.transaction(e.storeName,"readonly").objectStore(e.storeName),g=!1,h=f.openCursor();h.onsuccess=function(){var c=h.result;return c?void(0===a?b(c.key):g?b(c.key):(g=!0,c.advance(a))):void b(null)},h.onerror=function(){d(h.error)}})["catch"](d)});return z(d,b),d}function y(a){var b=this,c=new Promise(function(a,c){b.ready().then(function(){var d=b._dbInfo,e=d.db.transaction(d.storeName,"readonly").objectStore(d.storeName),f=e.openCursor(),g=[];f.onsuccess=function(){var b=f.result;return b?(g.push(b.key),void b["continue"]()):void a(g)},f.onerror=function(){c(f.error)}})["catch"](c)});return z(c,a),c}function z(a,b){b&&a.then(function(a){b(null,a)},function(a){b(a)})}var A=A||a.indexedDB||a.webkitIndexedDB||a.mozIndexedDB||a.OIndexedDB||a.msIndexedDB;if(A){var B,C,D="local-forage-detect-blob-support",E={_driver:"asyncStorage",_initStorage:m,iterate:s,getItem:r,setItem:t,removeItem:u,clear:v,length:w,key:x,keys:y};return E}}("undefined"!=typeof window?window:self);b["default"]=c,a.exports=b["default"]},function(a,b,c){"use strict";b.__esModule=!0;var d=function(a){function b(a){var b=this,d={};if(a)for(var e in a)d[e]=a[e];return d.keyPrefix=d.name+"/",d.storeName!==b._defaultConfig.storeName&&(d.keyPrefix+=d.storeName+"/"),b._dbInfo=d,new Promise(function(a,b){a(c(3))}).then(function(a){return d.serializer=a,Promise.resolve()})}function d(a){var b=this,c=b.ready().then(function(){for(var a=b._dbInfo.keyPrefix,c=m.length-1;c>=0;c--){var d=m.key(c);0===d.indexOf(a)&&m.removeItem(d)}});return l(c,a),c}function e(b,c){var d=this;"string"!=typeof b&&(a.console.warn(b+" used as a key, but it is not a string."),b=String(b));var e=d.ready().then(function(){var a=d._dbInfo,c=m.getItem(a.keyPrefix+b);return c&&(c=a.serializer.deserialize(c)),c});return l(e,c),e}function f(a,b){var c=this,d=c.ready().then(function(){for(var b=c._dbInfo,d=b.keyPrefix,e=d.length,f=m.length,g=1,h=0;f>h;h++){var i=m.key(h);if(0===i.indexOf(d)){var j=m.getItem(i);if(j&&(j=b.serializer.deserialize(j)),j=a(j,i.substring(e),g++),void 0!==j)return j}}});return l(d,b),d}function g(a,b){var c=this,d=c.ready().then(function(){var b,d=c._dbInfo;try{b=m.key(a)}catch(e){b=null}return b&&(b=b.substring(d.keyPrefix.length)),b});return l(d,b),d}function h(a){var b=this,c=b.ready().then(function(){for(var a=b._dbInfo,c=m.length,d=[],e=0;c>e;e++)0===m.key(e).indexOf(a.keyPrefix)&&d.push(m.key(e).substring(a.keyPrefix.length));return d});return l(c,a),c}function i(a){var b=this,c=b.keys().then(function(a){return a.length});return l(c,a),c}function j(b,c){var d=this;"string"!=typeof b&&(a.console.warn(b+" used as a key, but it is not a string."),b=String(b));var e=d.ready().then(function(){var a=d._dbInfo;m.removeItem(a.keyPrefix+b)});return l(e,c),e}function k(b,c,d){var e=this;"string"!=typeof b&&(a.console.warn(b+" used as a key, but it is not a string."),b=String(b));var f=e.ready().then(function(){void 0===c&&(c=null);var a=c;return new Promise(function(d,f){var g=e._dbInfo;g.serializer.serialize(c,function(c,e){if(e)f(e);else try{m.setItem(g.keyPrefix+b,c),d(a)}catch(h){("QuotaExceededError"===h.name||"NS_ERROR_DOM_QUOTA_REACHED"===h.name)&&f(h),f(h)}})})});return l(f,d),f}function l(a,b){b&&a.then(function(a){b(null,a)},function(a){b(a)})}var m=null;try{if(!(a.localStorage&&"setItem"in a.localStorage))return;m=a.localStorage}catch(n){return}var o={_driver:"localStorageWrapper",_initStorage:b,iterate:f,getItem:e,setItem:k,removeItem:j,clear:d,length:i,key:g,keys:h};return o}("undefined"!=typeof window?window:self);b["default"]=d,a.exports=b["default"]},function(a,b){"use strict";b.__esModule=!0;var c=function(a){function b(b,c){b=b||[],c=c||{};try{return new Blob(b,c)}catch(d){if("TypeError"!==d.name)throw d;for(var e=a.BlobBuilder||a.MSBlobBuilder||a.MozBlobBuilder||a.WebKitBlobBuilder,f=new e,g=0;gb;b+=4)c=g.indexOf(a[b]),d=g.indexOf(a[b+1]),e=g.indexOf(a[b+2]),f=g.indexOf(a[b+3]),l[j++]=c<<2|d>>4,l[j++]=(15&d)<<4|e>>2,l[j++]=(3&e)<<6|63&f;return k}function f(a){var b,c=new Uint8Array(a),d="";for(b=0;b>2],d+=g[(3&c[b])<<4|c[b+1]>>4],d+=g[(15&c[b+1])<<2|c[b+2]>>6],d+=g[63&c[b+2]];return c.length%3===2?d=d.substring(0,d.length-1)+"=":c.length%3===1&&(d=d.substring(0,d.length-2)+"=="),d}var g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",h="~~local_forage_type~",i=/^~~local_forage_type~([^~]+)~/,j="__lfsc__:",k=j.length,l="arbf",m="blob",n="si08",o="ui08",p="uic8",q="si16",r="si32",s="ur16",t="ui32",u="fl32",v="fl64",w=k+l.length,x={serialize:c,deserialize:d,stringToBuffer:e,bufferToString:f};return x}("undefined"!=typeof window?window:self);b["default"]=c,a.exports=b["default"]},function(a,b,c){"use strict";b.__esModule=!0;var d=function(a){function b(a){var b=this,d={db:null};if(a)for(var e in a)d[e]="string"!=typeof a[e]?a[e].toString():a[e];var f=new Promise(function(a,c){try{d.db=m(d.name,String(d.version),d.description,d.size)}catch(e){return c(e)}d.db.transaction(function(e){e.executeSql("CREATE TABLE IF NOT EXISTS "+d.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],function(){b._dbInfo=d,a()},function(a,b){c(b)})})});return new Promise(function(a,b){a(c(3))}).then(function(a){return d.serializer=a,f})}function d(b,c){var d=this;"string"!=typeof b&&(a.console.warn(b+" used as a key, but it is not a string."),b=String(b));var e=new Promise(function(a,c){d.ready().then(function(){var e=d._dbInfo;e.db.transaction(function(d){d.executeSql("SELECT * FROM "+e.storeName+" WHERE key = ? LIMIT 1",[b],function(b,c){var d=c.rows.length?c.rows.item(0).value:null;d&&(d=e.serializer.deserialize(d)),a(d)},function(a,b){c(b)})})})["catch"](c)});return l(e,c),e}function e(a,b){var c=this,d=new Promise(function(b,d){c.ready().then(function(){var e=c._dbInfo;e.db.transaction(function(c){c.executeSql("SELECT * FROM "+e.storeName,[],function(c,d){for(var f=d.rows,g=f.length,h=0;g>h;h++){var i=f.item(h),j=i.value;if(j&&(j=e.serializer.deserialize(j)),j=a(j,i.key,h+1),void 0!==j)return void b(j)}b()},function(a,b){d(b)})})})["catch"](d)});return l(d,b),d}function f(b,c,d){var e=this;"string"!=typeof b&&(a.console.warn(b+" used as a key, but it is not a string."),b=String(b));var f=new Promise(function(a,d){e.ready().then(function(){void 0===c&&(c=null);var f=c,g=e._dbInfo;g.serializer.serialize(c,function(c,e){e?d(e):g.db.transaction(function(e){e.executeSql("INSERT OR REPLACE INTO "+g.storeName+" (key, value) VALUES (?, ?)",[b,c],function(){a(f)},function(a,b){d(b)})},function(a){a.code===a.QUOTA_ERR&&d(a)})})})["catch"](d)});return l(f,d),f}function g(b,c){var d=this;"string"!=typeof b&&(a.console.warn(b+" used as a key, but it is not a string."),b=String(b));var e=new Promise(function(a,c){d.ready().then(function(){var e=d._dbInfo;e.db.transaction(function(d){d.executeSql("DELETE FROM "+e.storeName+" WHERE key = ?",[b],function(){a()},function(a,b){c(b)})})})["catch"](c)});return l(e,c),e}function h(a){var b=this,c=new Promise(function(a,c){b.ready().then(function(){var d=b._dbInfo;d.db.transaction(function(b){b.executeSql("DELETE FROM "+d.storeName,[],function(){a()},function(a,b){c(b)})})})["catch"](c)});return l(c,a),c}function i(a){var b=this,c=new Promise(function(a,c){b.ready().then(function(){var d=b._dbInfo;d.db.transaction(function(b){b.executeSql("SELECT COUNT(key) as c FROM "+d.storeName,[],function(b,c){var d=c.rows.item(0).c;a(d)},function(a,b){c(b)})})})["catch"](c)});return l(c,a),c}function j(a,b){var c=this,d=new Promise(function(b,d){c.ready().then(function(){var e=c._dbInfo;e.db.transaction(function(c){c.executeSql("SELECT key FROM "+e.storeName+" WHERE id = ? LIMIT 1",[a+1],function(a,c){var d=c.rows.length?c.rows.item(0).key:null;b(d)},function(a,b){d(b)})})})["catch"](d)});return l(d,b),d}function k(a){var b=this,c=new Promise(function(a,c){b.ready().then(function(){var d=b._dbInfo;d.db.transaction(function(b){b.executeSql("SELECT key FROM "+d.storeName,[],function(b,c){for(var d=[],e=0;e 0; }; Cnds.prototype.IsProcessingGets = function () { return this.pendingGets > 0; }; Cnds.prototype.OnAllSetsComplete = function () { return true; }; Cnds.prototype.OnAllGetsComplete = function () { return true; }; pluginProto.cnds = new Cnds(); function Acts() {}; Acts.prototype.SetItem = function (keyNoPrefix, value) { if (localForageInitFailed) { TriggerStorageError(this, "storage failed to initialise - may be disabled in browser settings"); return; } var keyPrefix = prefix + keyNoPrefix; this.pendingSets++; var self = this; localforage["setItem"](keyPrefix, value, function (err, valueSet) { debugDataChanged = true; self.pendingSets--; if (err) { errorMessage = getErrorString(err); self.runtime.trigger(cr.plugins_.LocalStorage.prototype.cnds.OnError, self); } else { currentKey = keyNoPrefix; lastValue = valueSet; self.runtime.trigger(cr.plugins_.LocalStorage.prototype.cnds.OnAnyItemSet, self); self.runtime.trigger(cr.plugins_.LocalStorage.prototype.cnds.OnItemSet, self); currentKey = ""; lastValue = ""; } if (self.pendingSets === 0) { self.runtime.trigger(cr.plugins_.LocalStorage.prototype.cnds.OnAllSetsComplete, self); } }); }; Acts.prototype.GetItem = function (keyNoPrefix) { if (localForageInitFailed) { TriggerStorageError(this, "storage failed to initialise - may be disabled in browser settings"); return; } var keyPrefix = prefix + keyNoPrefix; this.pendingGets++; var self = this; localforage["getItem"](keyPrefix, function (err, value) { self.pendingGets--; if (err) { errorMessage = getErrorString(err); self.runtime.trigger(cr.plugins_.LocalStorage.prototype.cnds.OnError, self); } else { currentKey = keyNoPrefix; lastValue = value; if (typeof lastValue === "undefined" || lastValue === null) lastValue = ""; self.runtime.trigger(cr.plugins_.LocalStorage.prototype.cnds.OnAnyItemGet, self); self.runtime.trigger(cr.plugins_.LocalStorage.prototype.cnds.OnItemGet, self); currentKey = ""; lastValue = ""; } if (self.pendingGets === 0) { self.runtime.trigger(cr.plugins_.LocalStorage.prototype.cnds.OnAllGetsComplete, self); } }); }; Acts.prototype.CheckItemExists = function (keyNoPrefix) { if (localForageInitFailed) { TriggerStorageError(this, "storage failed to initialise - may be disabled in browser settings"); return; } var keyPrefix = prefix + keyNoPrefix; var self = this; localforage["getItem"](keyPrefix, function (err, value) { if (err) { errorMessage = getErrorString(err); self.runtime.trigger(cr.plugins_.LocalStorage.prototype.cnds.OnError, self); } else { currentKey = keyNoPrefix; if (value === null) // null value indicates key missing { lastValue = ""; // prevent ItemValue meaning anything self.runtime.trigger(cr.plugins_.LocalStorage.prototype.cnds.OnItemMissing, self); } else { lastValue = value; // make available to ItemValue expression self.runtime.trigger(cr.plugins_.LocalStorage.prototype.cnds.OnItemExists, self); } currentKey = ""; lastValue = ""; } }); }; Acts.prototype.RemoveItem = function (keyNoPrefix) { if (localForageInitFailed) { TriggerStorageError(this, "storage failed to initialise - may be disabled in browser settings"); return; } var keyPrefix = prefix + keyNoPrefix; var self = this; localforage["removeItem"](keyPrefix, function (err) { debugDataChanged = true; if (err) { errorMessage = getErrorString(err); self.runtime.trigger(cr.plugins_.LocalStorage.prototype.cnds.OnError, self); } else { currentKey = keyNoPrefix; lastValue = ""; self.runtime.trigger(cr.plugins_.LocalStorage.prototype.cnds.OnAnyItemRemoved, self); self.runtime.trigger(cr.plugins_.LocalStorage.prototype.cnds.OnItemRemoved, self); currentKey = ""; } }); }; Acts.prototype.ClearStorage = function () { if (localForageInitFailed) { TriggerStorageError(this, "storage failed to initialise - may be disabled in browser settings"); return; } if (is_arcade) return; var self = this; localforage["clear"](function (err) { debugDataChanged = true; if (err) { errorMessage = getErrorString(err); self.runtime.trigger(cr.plugins_.LocalStorage.prototype.cnds.OnError, self); } else { currentKey = ""; lastValue = ""; cr.clearArray(keyNamesList); self.runtime.trigger(cr.plugins_.LocalStorage.prototype.cnds.OnCleared, self); } }); }; Acts.prototype.GetAllKeyNames = function () { if (localForageInitFailed) { TriggerStorageError(this, "storage failed to initialise - may be disabled in browser settings"); return; } var self = this; localforage["keys"](function (err, keyList) { var i, len, k; if (err) { errorMessage = getErrorString(err); self.runtime.trigger(cr.plugins_.LocalStorage.prototype.cnds.OnError, self); } else { cr.clearArray(keyNamesList); for (i = 0, len = keyList.length; i < len; ++i) { k = keyList[i]; if (!hasRequiredPrefix(k)) continue; keyNamesList.push(removePrefix(k)); } self.runtime.trigger(cr.plugins_.LocalStorage.prototype.cnds.OnAllKeyNamesLoaded, self); } }); }; pluginProto.acts = new Acts(); function Exps() {}; Exps.prototype.ItemValue = function (ret) { ret.set_any(lastValue); }; Exps.prototype.Key = function (ret) { ret.set_string(currentKey); }; Exps.prototype.KeyCount = function (ret) { ret.set_int(keyNamesList.length); }; Exps.prototype.KeyAt = function (ret, i) { i = Math.floor(i); if (i < 0 || i >= keyNamesList.length) { ret.set_string(""); return; } ret.set_string(keyNamesList[i]); }; Exps.prototype.ErrorMessage = function (ret) { ret.set_string(errorMessage); }; pluginProto.exps = new Exps(); }()); ; ; cr.plugins_.MagiCam = function(runtime) { this.runtime = runtime; }; (function () { var CMath = {}; CMath.lerp = function(a, b, x) { return a + (b - a) * x; }; CMath.cubic = function(a, b, c, d, x) { return this.lerp(this.lerp(this.lerp(a, b, x), this.lerp(b, c, x), x), this.lerp(this.lerp(b, c, x), this.lerp(c, d, x), x), x); } CMath.clamp = function(x, min, max) { if (x < min) { return min; } else if (x > max) { return max; } return x; }; function Transition(Type, Duration, Param1, Param2, Param3, Param4) { this.type = Type; this.duration = Duration; this.param1 = Param1; this.param2 = Param2; this.param3 = Param3; this.param4 = Param4; this.progress = 0; } function Camera(Name, X, Y, Scale, Global) { this.global = Global; this.name = Name; this.x = X; this.y = Y; this.scale = Scale; this.following = false; this.followedObjects = []; this.followedObjectUIDs = []; this.objectWeights = []; this.followedObjectIPs = []; this.followLag = 1; this.zoomToContain = false; this.zoomMarginH = 0; this.zoomMarginV = 0; this.zoomBoundU = -1; this.zoomBoundL = -1; this.transitions = []; this.moveTransFinished = false; this.zoomTransFinished = false; this.isShaking = false; this.shakeX = 0; this.shakeY = 0; this.shakeZoom = 0; this.shakeTimer = 0; this.shakeStrength = 0; this.shakeMaxDeviation = 0; this.shakeMaxZoomDeviation = 0; this.shakeLength = 0; this.shakeBuildTime = 0; this.shakeDropTime = 0; } Camera.prototype.GetName = function() { return this.name; }; Camera.prototype.GetX = function() { return this.x; }; Camera.prototype.SetX = function(value) { this.x = value; }; Camera.prototype.GetY = function() { return this.y; }; Camera.prototype.SetY = function(value) { this.y = value; }; Camera.prototype.GetShakeX = function() { return this.shakeX; }; Camera.prototype.GetShakeY = function() { return this.shakeY; }; Camera.prototype.SetFollowedObject = function(fObject) { this.followedObject = fObject; }; Camera.prototype.ShakeCamera = function(dt) { if (this.isShaking) { this.shakeTimer += dt; if (this.shakeTimer < this.shakeLength) { var shakeStrength = 0; if (this.shakeTimer < this.shakeBuildTime) { shakeStrength = CMath.lerp(0, this.shakeStrength, this.shakeTimer / this.shakeBuildTime); } else { shakeStrength = this.shakeStrength; } if (this.shakeTimer > this.shakeDropTime) { shakeStrength = CMath.lerp(this.shakeStrength, 0, (this.shakeTimer - this.shakeDropTime) / (this.shakeLength - this.shakeDropTime)); } var shakeAngle = Math.floor(Math.random() * 361) / 57.2958; var shakeX = CMath.lerp(0, Math.cos(shakeAngle) * this.shakeMaxDeviation, shakeStrength); var shakeY = CMath.lerp(0, Math.sin(shakeAngle) * this.shakeMaxDeviation, shakeStrength); var shakeZoom = CMath.lerp(0, (Math.floor(Math.random() * 201 - 100) / 100) * this.shakeMaxZoomDeviation, shakeStrength); this.shakeX = CMath.lerp(this.shakeX, shakeX, shakeStrength); this.shakeY = CMath.lerp(this.shakeY, shakeY, shakeStrength); this.shakeZoom = CMath.lerp(this.shakeZoom, shakeZoom, shakeStrength); } else { this.isShaking = false; this.shakeX = 0; this.shakeY = 0; this.shakeZoom = 0; } } } Camera.prototype.ProcessTransitions = function(dt) { this.moveTransFinished = false; this.zoomTransFinished = false; var transition; for (var i = 0; i < this.transitions.length; ) { transition = this.transitions[i]; transition.progress = CMath.clamp(transition.progress + (1.0 / transition.duration * dt), 0.0, 1.0); if (transition.type == "MOVE") { this.x = CMath.cubic(transition.param3, transition.param3, transition.param1, transition.param1, transition.progress); this.y = CMath.cubic(transition.param4, transition.param4, transition.param2, transition.param2, transition.progress); } else if (transition.type == "SCALE") { this.scale = CMath.cubic(transition.param2, transition.param2, transition.param1, transition.param1, transition.progress); } if (transition.progress == 1) { if (transition.type == "MOVE") { this.moveTransFinished = true; } else if (transition.type == "SCALE") { this.zoomTransFinished = true; } this.transitions.splice(i, 1); } else { i++; } } }; Camera.prototype.UpdateCameraTarget = function(dt, targetCamera) { for (var i = 0; i < this.transitions.length; i++) { var transition = this.transitions[i]; if (transition.type == "MOVE") { transition.param1 = targetCamera.GetX(); transition.param2 = targetCamera.GetY(); } else if (transition.type == "SCALE") { transition.param1 = targetCamera.scale; } } }; Camera.prototype.ProcessFollowing = function(dt, screenWidth, screenHeight, layout) { var followed = this.followedObjects; var followedObjectIPs = this.followedObjectIPs; if (this.following && followed.length > 0) { var tempX = 0, tempY = 0, tempScale = 0; if (!this.zoomToContain) { var sumX = 0, sumY = 0, sumW = 0; for (var i = 0; i < followed.length; i++) { sumX += followed[i].getImagePoint(followedObjectIPs[i], true) * this.objectWeights[i]; sumY += followed[i].getImagePoint(followedObjectIPs[i], false) * this.objectWeights[i]; sumW += this.objectWeights[i]; } tempX = sumX / sumW; tempY = sumY / sumW; } else { var minX = 0, maxX = 0, minY = 0, maxY = 0; var minXChanged = false, maxXChanged = false, minYChanged = false, maxYChanged = false; for (var i = 0; i < followed.length; i++) { var fObject = followed[i]; fObject.update_bbox(); if (minXChanged) { minX = Math.min(minX, fObject.bbox.left); } else { minX = fObject.bbox.left; minXChanged = true; } if (maxXChanged) { maxX = Math.max(maxX, fObject.bbox.right); } else { maxX = fObject.bbox.right; maxXChanged = true; } if (minYChanged) { minY = Math.min(minY, fObject.bbox.top); } else { minY = fObject.bbox.top; minYChanged = true; } if (maxYChanged) { maxY = Math.max(maxY, fObject.bbox.bottom); } else { maxY = fObject.bbox.bottom; maxYChanged = true; } } var tempXScale = (screenWidth - this.zoomMarginH * 2) / (maxX - minX); var tempYScale = (screenHeight - this.zoomMarginV * 2) / (maxY - minY); tempX = CMath.lerp(minX, maxX, 0.5); tempY = CMath.lerp(minY, maxY, 0.5); if (this.x < ((screenWidth / 2) / tempXScale)) { tempXScale = (screenWidth - this.zoomMarginH) / maxX; tempX = (screenWidth / tempXScale) / 2; } if (this.x > (layout.width - (screenWidth / 2) / tempXScale)) { tempXScale = (screenWidth - this.zoomMarginH) / (layout.width - minX); tempX = layout.width - (screenWidth / tempXScale) / 2; } if (this.y < ((screenHeight / 2) / tempYScale)) { tempYScale = (screenHeight - this.zoomMarginV) / maxY; tempY = (screenHeight / tempYScale) / 2; } if (this.y > (layout.height - (screenHeight / 2) / tempYScale)) { tempYScale = (screenHeight - this.zoomMarginV) / (layout.height - minY); tempY = layout.height - (screenHeight / tempYScale) / 2; } tempScale = Math.min(tempXScale, tempYScale); if (this.zoomBoundL != -1) { if (tempScale < this.zoomBoundL) { tempScale = this.zoomBoundL; } } if (this.zoomBoundU != -1) { if (tempScale > this.zoomBoundU) { tempScale = this.zoomBoundU; } } } if (this.followLag == 1) { this.x = tempX; this.y = tempY; if (this.zoomToContain) { this.scale = tempScale; } } else { var lag = (this.followLag * 4.0 * dt) * Math.sqrt(1.0 / dt); this.x = CMath.lerp(this.x, tempX, lag); this.y = CMath.lerp(this.y, tempY, lag); if (this.zoomToContain) { this.scale = CMath.lerp(this.scale, tempScale, lag); } } } }; var pluginProto = cr.plugins_.MagiCam.prototype; pluginProto.Type = function(plugin) { this.plugin = plugin; this.runtime = plugin.runtime; }; var typeProto = pluginProto.Type.prototype; typeProto.onCreate = function() { }; pluginProto.Instance = function(type) { this.type = type; this.runtime = type.runtime; this.localCameras = []; this.localCameraCount = 0; this.localCameraCountOld = 0; this.transCamera = null; this.transTarget = null; this.isSwitchingCameras = false; this.globalCameras = []; this.activeCamera = null; }; var instanceProto = pluginProto.Instance.prototype; instanceProto.onCreate = function() { this.runtime.tickMe(this); this.my_timescale = -1.0; }; instanceProto.saveToJSON = function () { if (null != this.transCamera) { this.localCameras.push(this.transCamera); } var o = { "lcc": this.localCameraCount, "olcc": this.localCameraCountOld, "alcc": this.localCameras.length, "agcc": this.globalCameras.length, "tcnn": (this.transCamera == null ? false : true) }; for (var i = 0; i < this.localCameras.length; i++) { o["lc" + i + "g"] = this.localCameras[i].global; o["lc" + i + "n"] = this.localCameras[i].name; o["lc" + i + "x"] = this.localCameras[i].x; o["lc" + i + "y"] = this.localCameras[i].y; o["lc" + i + "s"] = this.localCameras[i].scale; o["lc" + i + "f"] = this.localCameras[i].following; o["lc" + i + "foc"] = this.localCameras[i].followedObjects.length; for (var f = 0; f < this.localCameras[i].followedObjects.length; f++) { o["lc" + i + "fo" + f] = this.localCameras[i].followedObjects[f].uid; } for (var w = 0; w < this.localCameras[i].objectWeights.length; w++) { o["lc" + i + "fow" + w] = this.localCameras[i].objectWeights[w]; } for (var ip = 0; ip < this.localCameras[i].followedObjectIPs.length; ip++) { o["lc" + i + "foip" + ip] = this.localCameras[i].followedObjectIPs[ip]; } o["lc" + i + "fl"] = this.localCameras[i].followLag; o["lc" + i + "ztc"] = this.localCameras[i].zoomToContain; o["lc" + i + "zmh"] = this.localCameras[i].zoomMarginH; o["lc" + i + "zmv"] = this.localCameras[i].zoomMarginV; o["lc" + i + "zbu"] = this.localCameras[i].zoomBoundU; o["lc" + i + "zbl"] = this.localCameras[i].zoomBoundL; o["lc" + i + "tc"] = this.localCameras[i].transitions.length; for (var t = 0; t < this.localCameras[i].transitions.length; t++) { o["lc" + i + "t" + t + "tp"] = this.localCameras[i].transitions[t].type; o["lc" + i + "t" + t + "d"] = this.localCameras[i].transitions[t].duration; o["lc" + i + "t" + t + "p1"] = this.localCameras[i].transitions[t].param1; o["lc" + i + "t" + t + "p2"] = this.localCameras[i].transitions[t].param2; o["lc" + i + "t" + t + "p3"] = this.localCameras[i].transitions[t].param3; o["lc" + i + "t" + t + "p4"] = this.localCameras[i].transitions[t].param4; o["lc" + i + "t" + t + "pr"] = this.localCameras[i].transitions[t].progress; } o["lc" + i + "mtf"] = this.localCameras[i].moveTransFinished; o["lc" + i + "ztf"] = this.localCameras[i].zoomTransFinished; o["lc" + i + "csis"] = this.localCameras[i].isShaking; o["lc" + i + "cssx"] = this.localCameras[i].shakeX; o["lc" + i + "cssy"] = this.localCameras[i].shakeY; o["lc" + i + "cssz"] = this.localCameras[i].shakeZoom; o["lc" + i + "csst"] = this.localCameras[i].shakeTimer; o["lc" + i + "csss"] = this.localCameras[i].shakeStrength; o["lc" + i + "cssmd"] = this.localCameras[i].shakeMaxDeviation; o["lc" + i + "cssmzd"] = this.localCameras[i].shakeMaxZoomDeviation; o["lc" + i + "cssl"] = this.localCameras[i].shakeLength; o["lc" + i + "cssbt"] = this.localCameras[i].shakeBuildTime; o["lc" + i + "cssdt"] = this.localCameras[i].shakeDropTime; } for (var i = 0; i < this.globalCameras.length; i++) { o["gc" + i + "g"] = this.globalCameras[i].global; o["gc" + i + "n"] = this.globalCameras[i].name; o["gc" + i + "x"] = this.globalCameras[i].x; o["gc" + i + "y"] = this.globalCameras[i].y; o["gc" + i + "s"] = this.globalCameras[i].scale; o["gc" + i + "f"] = this.globalCameras[i].following; o["gc" + i + "foc"] = this.globalCameras[i].followedObjects.length; for (var f = 0; f < this.globalCameras[i].followedObjects.length; f++) { o["gc" + i + "fo" + f] = this.globalCameras[i].followedObjects[f].uid; } for (var w = 0; w < this.globalCameras[i].objectWeights.length; w++) { o["gc" + i + "fow" + w] = this.globalCameras[i].objectWeights[w]; } for (var ip = 0; ip < this.globalCameras[i].followedObjectIPs.length; ip++) { o["gc" + i + "foip" + ip] = this.globalCameras[i].followedObjectIPs[ip]; } o["gc" + i + "fl"] = this.globalCameras[i].followLag; o["gc" + i + "ztc"] = this.globalCameras[i].zoomToContain; o["gc" + i + "zmh"] = this.globalCameras[i].zoomMarginH; o["gc" + i + "zmv"] = this.globalCameras[i].zoomMarginV; o["gc" + i + "zbu"] = this.globalCameras[i].zoomBoundU; o["gc" + i + "zbl"] = this.globalCameras[i].zoomBoundL; o["gc" + i + "tc"] = this.globalCameras[i].transitions.length; for (var t = 0; t < this.globalCameras[i].transitions.length; t++) { o["gc" + i + "t" + t + "tp"] = this.globalCameras[i].transitions[t].type; o["gc" + i + "t" + t + "d"] = this.globalCameras[i].transitions[t].duration; o["gc" + i + "t" + t + "p1"] = this.globalCameras[i].transitions[t].param1; o["gc" + i + "t" + t + "p2"] = this.globalCameras[i].transitions[t].param2; o["gc" + i + "t" + t + "p3"] = this.globalCameras[i].transitions[t].param3; o["gc" + i + "t" + t + "p4"] = this.globalCameras[i].transitions[t].param4; } o["gc" + i + "mtf"] = this.globalCameras[i].moveTransFinished; o["gc" + i + "ztf"] = this.globalCameras[i].zoomTransFinished; o["gc" + i + "csis"] = this.globalCameras[i].isShaking; o["gc" + i + "cssx"] = this.globalCameras[i].shakeX; o["gc" + i + "cssy"] = this.globalCameras[i].shakeY; o["gc" + i + "cssz"] = this.globalCameras[i].shakeZoom; o["gc" + i + "csst"] = this.globalCameras[i].shakeTimer; o["gc" + i + "csss"] = this.globalCameras[i].shakeStrength; o["gc" + i + "cssmd"] = this.globalCameras[i].shakeMaxDeviation; o["gc" + i + "cssmzd"] = this.globalCameras[i].shakeMaxZoomDeviation; o["gc" + i + "cssl"] = this.globalCameras[i].shakeLength; o["gc" + i + "cssbt"] = this.globalCameras[i].shakeBuildTime; o["gc" + i + "cssdt"] = this.globalCameras[i].shakeDropTime; } if (null != this.activeCamera) { o["ac"] = this.activeCamera.name; } else { o["ac"] = "null"; } if (null != this.transTarget) { o["tt"] = this.transTarget.name; } return o; } instanceProto.loadFromJSON = function (o) { this.localCameras = []; this.globalCameras = []; this.localCameraCount = o["lcc"]; this.localCameraCountOld = o["olcc"]; var localCamCount = o["alcc"]; for (var i = 0; i < localCamCount; i++) { var tempCam = new Camera("", 0, 0, 0, false); tempCam.global = o["lc" + i + "g"]; tempCam.name = o["lc" + i + "n"]; tempCam.x = o["lc" + i + "x"]; tempCam.y = o["lc" + i + "y"]; tempCam.scale = o["lc" + i + "s"]; tempCam.following = o["lc" + i + "f"]; var foCount = o["lc" + i + "foc"]; for (var f = 0; f < foCount; f++) { tempCam.followedObjectUIDs.push(o["lc" + i + "fo" + f]); } for (var w = 0; w < foCount; w++) { tempCam.objectWeights.push(o["lc" + i + "fow" + w]); } for (var ip = 0; ip < foCount; ip++) { tempCam.followedObjectIPs.push(o["lc" + i + "foip" + ip]); } tempCam.followLag = o["lc" + i + "fl"]; tempCam.zoomToContain = o["lc" + i + "ztc"]; tempCam.zoomMarginH = o["lc" + i + "zmh"]; tempCam.zoomMarginV = o["lc" + i + "zmv"]; tempCam.zoomBoundU = o["lc" + i + "zbu"]; tempCam.zoomBoundL = o["lc" + i + "zbl"]; var transCount = o["lc" + i + "tc"]; for (var t = 0; t < transCount; t++) { var tempTrans = new Transition("", 0, 0, 0, 0); tempTrans.type = o["lc" + i + "t" + t + "tp"]; tempTrans.duration = o["lc" + i + "t" + t + "d"]; tempTrans.param1 = o["lc" + i + "t" + t + "p1"]; tempTrans.param2 = o["lc" + i + "t" + t + "p2"]; tempTrans.param3 = o["lc" + i + "t" + t + "p3"]; tempTrans.param4 = o["lc" + i + "t" + t + "p4"]; tempTrans.progress = o["lc" + i + "t" + t + "pr"]; tempCam.transitions.push(tempTrans); } tempCam.moveTransFinished = o["lc" + i + "mtf"]; tempCam.zoomTransFinished = o["lc" + i + "ztf"]; tempCam.isShaking = o["lc" + i + "csis"]; tempCam.shakeX = o["lc" + i + "cssx"]; tempCam.shakeY = o["lc" + i + "cssy"]; tempCam.shakeZoom = o["lc" + i + "cssz"]; tempCam.shakeTimer = o["lc" + i + "csst"]; tempCam.shakeStrength = o["lc" + i + "csss"]; tempCam.shakeMaxDeviation = o["lc" + i + "cssmd"]; tempCam.shakeMaxZoomDeviation = o["lc" + i + "cssmzd"]; tempCam.shakeLength = o["lc" + i + "cssl"]; tempCam.shakeBuildTime = o["lc" + i + "cssbt"]; tempCam.shakeDropTime = o["lc" + i + "cssdt"]; this.localCameras.push(tempCam); } var globalCamCount = o["agcc"]; for (var i = 0; i < globalCamCount; i++) { var tempCam = new Camera("", 0, 0, 0, false); tempCam.global = o["gc" + i + "g"]; tempCam.name = o["gc" + i + "n"]; tempCam.x = o["gc" + i + "x"]; tempCam.y = o["gc" + i + "y"]; tempCam.scale = o["gc" + i + "s"]; tempCam.following = o["gc" + i + "f"]; var foCount = o["gc" + i + "foc"]; for (var f = 0; f < foCount; f++) { tempCam.followedObjectUIDs.push(o["gc" + i + "fo" + f]); } for (var w = 0; w < foCount; w++) { tempCam.objectWeights.push(o["gc" + i + "fow" + w]); } for (var ip = 0; ip < foCount; ip++) { tempCam.followedObjectIPs.push(o["gc" + i + "foip" + ip]); } tempCam.followLag = o["gc" + i + "fl"]; tempCam.zoomToContain = o["gc" + i + "ztc"]; tempCam.zoomMarginH = o["gc" + i + "zmh"]; tempCam.zoomMarginV = o["gc" + i + "zmv"]; tempCam.zoomBoundU = o["gc" + i + "zbu"]; tempCam.zoomBoundL = o["gc" + i + "zbl"]; var transCount = o["gc" + i + "tc"]; for (var t = 0; t < transCount; t++) { var tempTrans = new Transition("", 0, 0, 0, 0); tempTrans.type = o["gc" + i + "t" + t + "tp"]; tempTrans.duration = o["gc" + i + "t" + t + "d"]; tempTrans.param1 = o["gc" + i + "t" + t + "p1"]; tempTrans.param2 = o["gc" + i + "t" + t + "p2"]; tempTrans.param3 = o["gc" + i + "t" + t + "p3"]; tempTrans.param4 = o["gc" + i + "t" + t + "p4"]; tempCam.transitions.push(tempTrans); } tempCam.moveTransFinished = o["gc" + i + "mtf"]; tempCam.zoomTransFinished = o["gc" + i + "ztf"]; tempCam.isShaking = o["gc" + i + "csis"]; tempCam.shakeX = o["gc" + i + "cssx"]; tempCam.shakeY = o["gc" + i + "cssy"]; tempCam.shakeZoom = o["gc" + i + "cssz"]; tempCam.shakeTimer = o["gc" + i + "csst"]; tempCam.shakeStrength = o["gc" + i + "csss"]; tempCam.shakeMaxDeviation = o["gc" + i + "cssmd"]; tempCam.shakeMaxZoomDeviation = o["gc" + i + "cssmzd"]; tempCam.shakeLength = o["gc" + i + "cssl"]; tempCam.shakeBuildTime = o["gc" + i + "cssbt"]; tempCam.shakeDropTime = o["gc" + i + "cssdt"]; this.globalCameras.push(tempCam); } var activeCam = o["ac"]; if (activeCam == "null") { this.activeCamera = null; } else { this.activeCamera = this.GetCamera(activeCam); } var hasTransCam = o["tcnn"]; if (hasTransCam) { this.transCamera = this.localCameras.pop(); this.transTarget = this.GetCamera(o["tt"]); } } instanceProto.afterLoad = function() { for (var i = 0; i < this.localCameras.length; i++) { for (var o = 0; o < this.localCameras[i].followedObjectUIDs.length; o++) { this.localCameras[i].followedObjects.push(this.runtime.getObjectByUID(this.localCameras[i].followedObjectUIDs[o])); } } for (var i = 0; i < this.globalCameras.length; i++) { for (var o = 0; o < this.globalCameras[i].followedObjectUIDs.length; o++) { this.globalCameras[i].followedObjects.push(this.runtime.getObjectByUID(this.globalCameras[i].followedObjectUIDs[o])); } } } instanceProto.onLayoutChange = function() { for (var i = 0; i < this.localCameraCountOld; i++) { this.localCameras.shift(); } this.localCameraCount -= this.localCameraCountOld; } instanceProto.tick = function() { this.localCameraCountOld = this.localCameraCount; var dt = this.runtime.getDt(this); if (dt == 0) { dt = 0.1; } for (var i = 0; i < this.globalCameras.length; i++) { this.globalCameras[i].ProcessTransitions(dt); this.globalCameras[i].ProcessFollowing(dt, this.runtime.original_width, this.runtime.original_height, this.runtime.running_layout); this.globalCameras[i].ShakeCamera(dt); } for (var i = 0; i < this.localCameras.length; i++) { this.localCameras[i].ProcessTransitions(dt); this.localCameras[i].ProcessFollowing(dt, this.runtime.original_width, this.runtime.original_height, this.runtime.running_layout); this.localCameras[i].ShakeCamera(dt); } if (null != this.transCamera) { this.transCamera.UpdateCameraTarget(dt, this.transTarget); this.transCamera.ProcessTransitions(dt); if (this.transCamera.moveTransFinished) { this.activeCamera = this.transTarget; this.transCamera = null; } } if (this.activeCamera != null) { this.runtime.running_layout.scrollToX(this.activeCamera.GetX() + this.activeCamera.GetShakeX()); this.runtime.running_layout.scrollToY(this.activeCamera.GetY() + this.activeCamera.GetShakeY()); this.runtime.running_layout.scale = this.activeCamera.scale + this.activeCamera.shakeZoom; this.runtime.redraw = true; } }; instanceProto.draw = function(ctx) { }; instanceProto.drawGL = function (glw) { }; instanceProto.GetCamera = function(Name) { if (Name == "") { return this.activeCamera; } for (var i = (this.globalCameras.length - 1) ; i >= 0; i--) { if (this.globalCameras[i].GetName() == Name) { return this.globalCameras[i]; } } for (var i = (this.localCameras.length - 1); i >= 0; i--) { if (this.localCameras[i].GetName() == Name) { return this.localCameras[i]; } } return null; }; function Cnds() {}; Cnds.prototype.TransitionFinished = function (CameraName, Transition) { var camera = this.GetCamera(CameraName); if (camera != null) { if (Transition == 0) { return camera.moveTransFinished; } else if (Transition == 1) { return camera.zoomTransFinished; } } return false; }; Cnds.prototype.TransitionIsInProgress = function (CameraName, Transition) { var camera = this.GetCamera(CameraName); if (camera != null) { for (var i = 0; i < camera.transitions.length; i++) { if (camera.transitions[i].type == "MOVE" && Transition == 0) { return true; } else if (camera.transitions[i].type == "SCALE" && Transition == 1) { return true; } } } return false; }; pluginProto.cnds = new Cnds(); function Acts() {}; Acts.prototype.FollowObject = function (CameraName, FollowedObject, ObjectWeight, ImagePoint) { if (!FollowedObject) { return; } var camera = this.GetCamera(CameraName); if (camera != null) { var followedObject = FollowedObject.getFirstPicked(); if (camera.global && !FollowedObject.global) { alert("MagiCam:\n\nObject not global - global cameras must follow global objects."); return; } camera.followedObjects.push(followedObject); camera.objectWeights.push(ObjectWeight); camera.followedObjectIPs.push(ImagePoint); } }; Acts.prototype.SetFollowLag = function (CameraName, FollowLag) { var camera = this.GetCamera(CameraName); if (camera != null) { camera.followLag = 1 - FollowLag / 100; } }; Acts.prototype.ZoomToContain = function (CameraName, Zoom, ZoomMarginH, ZoomMarginV, ZoomBoundU, ZoomBoundL) { var camera = this.GetCamera(CameraName); if (camera != null) { if (Zoom == 0) { camera.zoomToContain = true; camera.zoomMarginH = ZoomMarginH; camera.zoomMarginV = ZoomMarginV; camera.zoomBoundU = ZoomBoundU; camera.zoomBoundL = ZoomBoundL; } else { camera.zoomToContain = false; } } }; Acts.prototype.EnableFollowing = function (CameraName, Following) { var camera = this.GetCamera(CameraName); if (camera != null) { if (Following == 0) { camera.following = true; } else { camera.following = false; } } }; Acts.prototype.UnfollowObject = function (CameraName, FollowedObject) { if (!FollowedObject) { return; } var camera = this.GetCamera(CameraName); if (camera != null) { var followedObject = FollowedObject.getFirstPicked(); for (var i = 0; i < camera.followedObjects.length; i++) { if (camera.followedObjects[i] == followedObject) { camera.followedObjects.splice(i, 1); break; } } } }; Acts.prototype.CreateLocalCamera = function (cameraName, cameraX, cameraY, cameraScale, Active) { if (cameraName == "") { alert("Camera name must not be blank."); return; } this.localCameras.push(new Camera(cameraName, cameraX, cameraY, cameraScale, false)); this.localCameraCount++; if (Active == 1) { this.activeCamera = this.localCameras[this.localCameras.length - 1]; this.runtime.running_layout.scale = this.activeCamera.scale; } }; Acts.prototype.CreateGlobalCamera = function (cameraName, cameraX, cameraY, cameraScale, Active) { if (cameraName == "") { alert("Camera name must not be blank."); return; } else if (this.GetCamera(cameraName) != null) { return; } this.globalCameras.push(new Camera(cameraName, cameraX, cameraY, cameraScale, true)); if (Active == 1) { this.activeCamera = this.globalCameras[this.globalCameras.length - 1]; this.runtime.running_layout.scrollToX(this.activeCamera.GetX()); this.runtime.running_layout.scrollToY(this.activeCamera.GetY()); this.runtime.running_layout.scale = this.activeCamera.scale; } }; Acts.prototype.SetActiveCamera = function (CameraName) { var camera = this.GetCamera(CameraName); if (camera != null) { this.activeCamera = camera; this.runtime.running_layout.scrollToX(camera.GetX()); this.runtime.running_layout.scrollToY(camera.GetY()); this.runtime.running_layout.scale = camera.scale; } }; Acts.prototype.SetScrollSmoothing = function (CameraName) { }; Acts.prototype.SetXPosition = function (CameraName, X) { var camera = this.GetCamera(CameraName); if (camera != null) { camera.SetX(X); } }; Acts.prototype.SetYPosition = function (CameraName, Y) { var camera = this.GetCamera(CameraName); if (camera != null) { camera.SetY(Y); } }; Acts.prototype.SetPosition = function (CameraName, X, Y) { var camera = this.GetCamera(CameraName); if (camera != null) { camera.SetX(X); camera.SetY(Y); } }; Acts.prototype.SetZoom = function (CameraName, Zoom) { var camera = this.GetCamera(CameraName); if (camera != null) { camera.scale = Zoom; } }; Acts.prototype.TransitionToPoint = function (CameraName, X, Y, Duration) { var camera = this.GetCamera(CameraName); if (camera != null) { for (var i = 0; i < camera.transitions.length; i++) { if (camera.transitions[i].type == "MOVE") { camera.transitions.splice(i, 1); break; } } camera.transitions.push(new Transition("MOVE", Duration, X, Y, camera.GetX(), camera.GetY())); camera.following = false; camera.zoomToContain = false; } }; Acts.prototype.TransitionToZoom = function (CameraName, Zoom, Duration) { var camera = this.GetCamera(CameraName); if (camera != null) { for (var i = 0; i < camera.transitions.length; i++) { if (camera.transitions[i].type == "SCALE") { camera.transitions.splice(i, 1); break; } } camera.transitions.push(new Transition("SCALE", Duration, Zoom, camera.scale, null, null)); camera.zoomToContain = false; } }; Acts.prototype.TransitionToCamera = function (CameraName, Duration) { var camera = this.GetCamera(CameraName); if (camera != null) { this.transTarget = camera; this.transCamera = new Camera("transCamera", this.activeCamera.GetX(), this.activeCamera.GetY(), this.activeCamera.scale, false); this.transCamera.transitions.push(new Transition("MOVE", Duration, this.transTarget.GetX(), this.transTarget.GetY(), this.transCamera.GetX(), this.transCamera.GetY())); this.transCamera.transitions.push(new Transition("SCALE", Duration, this.transTarget.scale, this.transCamera.scale, null, null)); this.activeCamera = this.transCamera; this.isSwitchingCameras = true; } }; Acts.prototype.ShakeCamera = function (CameraName, Strength, MaxDeviation, MaxZoomDeviation, BuildLength, DropTime, Duration) { var camera = this.GetCamera(CameraName); if (camera != null) { camera.isShaking = true; camera.shakeStrength = Strength / 100; camera.shakeMaxDeviation = MaxDeviation; camera.shakeMaxZoomDeviation = MaxZoomDeviation; camera.shakeBuildTime = BuildLength; camera.shakeDropTime = DropTime; camera.shakeLength = Duration; camera.shakeTimer = 0; } }; pluginProto.acts = new Acts(); function Exps() {}; Exps.prototype.MovementTransitionProgress = function (ret, CameraName) { var camera = this.GetCamera(CameraName); if (null != camera) { for (var i = 0; i < camera.transitions.length; i++) { if (camera.transitions[i].type == "MOVE") { ret.set_float(camera.transitions[i].progress); return; } } } ret.set_float(0); }; Exps.prototype.ZoomTransitionProgress = function (ret, CameraName) { var camera = this.GetCamera(CameraName); if (null != camera) { for (var i = 0; i < camera.transitions.length; i++) { if (camera.transitions[i].type == "SCALE") { ret.set_float(camera.transitions[i].progress); return; } } } ret.set_float(0); }; Exps.prototype.GetX = function (ret, CameraName) { var camera = this.GetCamera(CameraName); if (null != camera) { ret.set_float(camera.x); return; } ret.set_float(0); }; Exps.prototype.GetY = function (ret, CameraName) { var camera = this.GetCamera(CameraName); if (null != camera) { ret.set_float(camera.y); return; } ret.set_float(0); }; Exps.prototype.GetZoom = function (ret, CameraName) { var camera = this.GetCamera(CameraName); if (null != camera) { ret.set_float(camera.scale); return; } ret.set_float(0); }; Exps.prototype.GetActiveCamera = function (ret) { if (null != this.activeCamera) { ret.set_string(this.activeCamera.name); return; } ret.set_string("null"); }; pluginProto.exps = new Exps(); }()); ; ; cr.plugins_.Mouse = function(runtime) { this.runtime = runtime; }; (function () { var pluginProto = cr.plugins_.Mouse.prototype; pluginProto.Type = function(plugin) { this.plugin = plugin; this.runtime = plugin.runtime; }; var typeProto = pluginProto.Type.prototype; typeProto.onCreate = function() { }; pluginProto.Instance = function(type) { this.type = type; this.runtime = type.runtime; this.buttonMap = new Array(4); // mouse down states this.mouseXcanvas = 0; // mouse position relative to canvas this.mouseYcanvas = 0; this.triggerButton = 0; this.triggerType = 0; this.triggerDir = 0; this.handled = false; }; var instanceProto = pluginProto.Instance.prototype; instanceProto.onCreate = function() { var self = this; if (!this.runtime.isDomFree) { jQuery(document).mousemove( function(info) { self.onMouseMove(info); } ); jQuery(document).mousedown( function(info) { self.onMouseDown(info); } ); jQuery(document).mouseup( function(info) { self.onMouseUp(info); } ); jQuery(document).dblclick( function(info) { self.onDoubleClick(info); } ); var wheelevent = function(info) { self.onWheel(info); }; document.addEventListener("mousewheel", wheelevent, false); document.addEventListener("DOMMouseScroll", wheelevent, false); } }; var dummyoffset = {left: 0, top: 0}; instanceProto.onMouseMove = function(info) { var offset = this.runtime.isDomFree ? dummyoffset : jQuery(this.runtime.canvas).offset(); this.mouseXcanvas = info.pageX - offset.left; this.mouseYcanvas = info.pageY - offset.top; }; instanceProto.mouseInGame = function () { if (this.runtime.fullscreen_mode > 0) return true; return this.mouseXcanvas >= 0 && this.mouseYcanvas >= 0 && this.mouseXcanvas < this.runtime.width && this.mouseYcanvas < this.runtime.height; }; instanceProto.onMouseDown = function(info) { if (!this.mouseInGame()) return; this.buttonMap[info.which] = true; this.runtime.isInUserInputEvent = true; this.runtime.trigger(cr.plugins_.Mouse.prototype.cnds.OnAnyClick, this); this.triggerButton = info.which - 1; // 1-based this.triggerType = 0; // single click this.runtime.trigger(cr.plugins_.Mouse.prototype.cnds.OnClick, this); this.runtime.trigger(cr.plugins_.Mouse.prototype.cnds.OnObjectClicked, this); this.runtime.isInUserInputEvent = false; }; instanceProto.onMouseUp = function(info) { if (!this.buttonMap[info.which]) return; if (this.runtime.had_a_click && !this.runtime.isMobile) info.preventDefault(); this.runtime.had_a_click = true; this.buttonMap[info.which] = false; this.runtime.isInUserInputEvent = true; this.triggerButton = info.which - 1; // 1-based this.runtime.trigger(cr.plugins_.Mouse.prototype.cnds.OnRelease, this); this.runtime.isInUserInputEvent = false; }; instanceProto.onDoubleClick = function(info) { if (!this.mouseInGame()) return; info.preventDefault(); this.runtime.isInUserInputEvent = true; this.triggerButton = info.which - 1; // 1-based this.triggerType = 1; // double click this.runtime.trigger(cr.plugins_.Mouse.prototype.cnds.OnClick, this); this.runtime.trigger(cr.plugins_.Mouse.prototype.cnds.OnObjectClicked, this); this.runtime.isInUserInputEvent = false; }; instanceProto.onWheel = function (info) { var delta = info.wheelDelta ? info.wheelDelta : info.detail ? -info.detail : 0; this.triggerDir = (delta < 0 ? 0 : 1); this.handled = false; this.runtime.isInUserInputEvent = true; this.runtime.trigger(cr.plugins_.Mouse.prototype.cnds.OnWheel, this); this.runtime.isInUserInputEvent = false; if (this.handled && cr.isCanvasInputEvent(info)) info.preventDefault(); }; instanceProto.onWindowBlur = function () { var i, len; for (i = 0, len = this.buttonMap.length; i < len; ++i) { if (!this.buttonMap[i]) continue; this.buttonMap[i] = false; this.triggerButton = i - 1; this.runtime.trigger(cr.plugins_.Mouse.prototype.cnds.OnRelease, this); } }; function Cnds() {}; Cnds.prototype.OnClick = function (button, type) { return button === this.triggerButton && type === this.triggerType; }; Cnds.prototype.OnAnyClick = function () { return true; }; Cnds.prototype.IsButtonDown = function (button) { return this.buttonMap[button + 1]; // jQuery uses 1-based buttons for some reason }; Cnds.prototype.OnRelease = function (button) { return button === this.triggerButton; }; Cnds.prototype.IsOverObject = function (obj) { var cnd = this.runtime.getCurrentCondition(); var mx = this.mouseXcanvas; var my = this.mouseYcanvas; return cr.xor(this.runtime.testAndSelectCanvasPointOverlap(obj, mx, my, cnd.inverted), cnd.inverted); }; Cnds.prototype.OnObjectClicked = function (button, type, obj) { if (button !== this.triggerButton || type !== this.triggerType) return false; // wrong click type return this.runtime.testAndSelectCanvasPointOverlap(obj, this.mouseXcanvas, this.mouseYcanvas, false); }; Cnds.prototype.OnWheel = function (dir) { this.handled = true; return dir === this.triggerDir; }; pluginProto.cnds = new Cnds(); function Acts() {}; var lastSetCursor = null; Acts.prototype.SetCursor = function (c) { if (this.runtime.isDomFree) return; var cursor_style = ["auto", "pointer", "text", "crosshair", "move", "help", "wait", "none"][c]; if (lastSetCursor === cursor_style) return; // redundant lastSetCursor = cursor_style; document.body.style.cursor = cursor_style; }; Acts.prototype.SetCursorSprite = function (obj) { if (this.runtime.isDomFree || this.runtime.isMobile || !obj) return; var inst = obj.getFirstPicked(); if (!inst || !inst.curFrame) return; var frame = inst.curFrame; if (lastSetCursor === frame) return; // already set this frame lastSetCursor = frame; var datauri = frame.getDataUri(); var cursor_style = "url(" + datauri + ") " + Math.round(frame.hotspotX * frame.width) + " " + Math.round(frame.hotspotY * frame.height) + ", auto"; document.body.style.cursor = ""; document.body.style.cursor = cursor_style; }; pluginProto.acts = new Acts(); function Exps() {}; Exps.prototype.X = function (ret, layerparam) { var layer, oldScale, oldZoomRate, oldParallaxX, oldAngle; if (cr.is_undefined(layerparam)) { layer = this.runtime.getLayerByNumber(0); oldScale = layer.scale; oldZoomRate = layer.zoomRate; oldParallaxX = layer.parallaxX; oldAngle = layer.angle; layer.scale = 1; layer.zoomRate = 1.0; layer.parallaxX = 1.0; layer.angle = 0; ret.set_float(layer.canvasToLayer(this.mouseXcanvas, this.mouseYcanvas, true)); layer.scale = oldScale; layer.zoomRate = oldZoomRate; layer.parallaxX = oldParallaxX; layer.angle = oldAngle; } else { if (cr.is_number(layerparam)) layer = this.runtime.getLayerByNumber(layerparam); else layer = this.runtime.getLayerByName(layerparam); if (layer) ret.set_float(layer.canvasToLayer(this.mouseXcanvas, this.mouseYcanvas, true)); else ret.set_float(0); } }; Exps.prototype.Y = function (ret, layerparam) { var layer, oldScale, oldZoomRate, oldParallaxY, oldAngle; if (cr.is_undefined(layerparam)) { layer = this.runtime.getLayerByNumber(0); oldScale = layer.scale; oldZoomRate = layer.zoomRate; oldParallaxY = layer.parallaxY; oldAngle = layer.angle; layer.scale = 1; layer.zoomRate = 1.0; layer.parallaxY = 1.0; layer.angle = 0; ret.set_float(layer.canvasToLayer(this.mouseXcanvas, this.mouseYcanvas, false)); layer.scale = oldScale; layer.zoomRate = oldZoomRate; layer.parallaxY = oldParallaxY; layer.angle = oldAngle; } else { if (cr.is_number(layerparam)) layer = this.runtime.getLayerByNumber(layerparam); else layer = this.runtime.getLayerByName(layerparam); if (layer) ret.set_float(layer.canvasToLayer(this.mouseXcanvas, this.mouseYcanvas, false)); else ret.set_float(0); } }; Exps.prototype.AbsoluteX = function (ret) { ret.set_float(this.mouseXcanvas); }; Exps.prototype.AbsoluteY = function (ret) { ret.set_float(this.mouseYcanvas); }; pluginProto.exps = new Exps(); }()); ; ; cr.plugins_.Particles = function(runtime) { this.runtime = runtime; }; (function () { var pluginProto = cr.plugins_.Particles.prototype; pluginProto.Type = function(plugin) { this.plugin = plugin; this.runtime = plugin.runtime; }; var typeProto = pluginProto.Type.prototype; typeProto.onCreate = function() { if (this.is_family) return; this.texture_img = new Image(); this.texture_img.cr_filesize = this.texture_filesize; this.webGL_texture = null; this.runtime.waitForImageLoad(this.texture_img, this.texture_file); }; typeProto.onLostWebGLContext = function () { if (this.is_family) return; this.webGL_texture = null; }; typeProto.onRestoreWebGLContext = function () { if (this.is_family || !this.instances.length) return; if (!this.webGL_texture) { this.webGL_texture = this.runtime.glwrap.loadTexture(this.texture_img, true, this.runtime.linearSampling, this.texture_pixelformat); } }; typeProto.loadTextures = function () { if (this.is_family || this.webGL_texture || !this.runtime.glwrap) return; this.webGL_texture = this.runtime.glwrap.loadTexture(this.texture_img, true, this.runtime.linearSampling, this.texture_pixelformat); }; typeProto.unloadTextures = function () { if (this.is_family || this.instances.length || !this.webGL_texture) return; this.runtime.glwrap.deleteTexture(this.webGL_texture); this.webGL_texture = null; }; typeProto.preloadCanvas2D = function (ctx) { ctx.drawImage(this.texture_img, 0, 0); }; function Particle(owner) { this.owner = owner; this.active = false; this.x = 0; this.y = 0; this.speed = 0; this.angle = 0; this.opacity = 1; this.grow = 0; this.size = 0; this.gs = 0; // gravity speed this.age = 0; cr.seal(this); }; Particle.prototype.init = function () { var owner = this.owner; this.x = owner.x - (owner.xrandom / 2) + (Math.random() * owner.xrandom); this.y = owner.y - (owner.yrandom / 2) + (Math.random() * owner.yrandom); this.speed = owner.initspeed - (owner.speedrandom / 2) + (Math.random() * owner.speedrandom); this.angle = owner.angle - (owner.spraycone / 2) + (Math.random() * owner.spraycone); this.opacity = owner.initopacity; this.size = owner.initsize - (owner.sizerandom / 2) + (Math.random() * owner.sizerandom); this.grow = owner.growrate - (owner.growrandom / 2) + (Math.random() * owner.growrandom); this.gs = 0; this.age = 0; }; Particle.prototype.tick = function (dt) { var owner = this.owner; this.x += Math.cos(this.angle) * this.speed * dt; this.y += Math.sin(this.angle) * this.speed * dt; this.y += this.gs * dt; this.speed += owner.acc * dt; this.size += this.grow * dt; this.gs += owner.g * dt; this.age += dt; if (this.size < 1) { this.active = false; return; } if (owner.lifeanglerandom !== 0) this.angle += (Math.random() * owner.lifeanglerandom * dt) - (owner.lifeanglerandom * dt / 2); if (owner.lifespeedrandom !== 0) this.speed += (Math.random() * owner.lifespeedrandom * dt) - (owner.lifespeedrandom * dt / 2); if (owner.lifeopacityrandom !== 0) { this.opacity += (Math.random() * owner.lifeopacityrandom * dt) - (owner.lifeopacityrandom * dt / 2); if (this.opacity < 0) this.opacity = 0; else if (this.opacity > 1) this.opacity = 1; } if (owner.destroymode <= 1 && this.age >= owner.timeout) { this.active = false; } if (owner.destroymode === 2 && this.speed <= 0) { this.active = false; } }; Particle.prototype.draw = function (ctx) { var curopacity = this.owner.opacity * this.opacity; if (curopacity === 0) return; if (this.owner.destroymode === 0) curopacity *= 1 - (this.age / this.owner.timeout); ctx.globalAlpha = curopacity; var drawx = this.x - this.size / 2; var drawy = this.y - this.size / 2; if (this.owner.runtime.pixel_rounding) { drawx = (drawx + 0.5) | 0; drawy = (drawy + 0.5) | 0; } ctx.drawImage(this.owner.type.texture_img, drawx, drawy, this.size, this.size); }; Particle.prototype.drawGL = function (glw) { var curopacity = this.owner.opacity * this.opacity; if (this.owner.destroymode === 0) curopacity *= 1 - (this.age / this.owner.timeout); var drawsize = this.size; var scaleddrawsize = drawsize * this.owner.particlescale; var drawx = this.x - drawsize / 2; var drawy = this.y - drawsize / 2; if (this.owner.runtime.pixel_rounding) { drawx = (drawx + 0.5) | 0; drawy = (drawy + 0.5) | 0; } if (scaleddrawsize < 1 || curopacity === 0) return; if (scaleddrawsize < glw.minPointSize || scaleddrawsize > glw.maxPointSize) { glw.setOpacity(curopacity); glw.quad(drawx, drawy, drawx + drawsize, drawy, drawx + drawsize, drawy + drawsize, drawx, drawy + drawsize); } else glw.point(this.x, this.y, scaleddrawsize, curopacity); }; Particle.prototype.left = function () { return this.x - this.size / 2; }; Particle.prototype.right = function () { return this.x + this.size / 2; }; Particle.prototype.top = function () { return this.y - this.size / 2; }; Particle.prototype.bottom = function () { return this.y + this.size / 2; }; pluginProto.Instance = function(type) { this.type = type; this.runtime = type.runtime; }; var instanceProto = pluginProto.Instance.prototype; var deadparticles = []; instanceProto.onCreate = function() { var props = this.properties; this.rate = props[0]; this.spraycone = cr.to_radians(props[1]); this.spraytype = props[2]; // 0 = continuous, 1 = one-shot this.spraying = true; // for continuous mode only this.initspeed = props[3]; this.initsize = props[4]; this.initopacity = props[5] / 100.0; this.growrate = props[6]; this.xrandom = props[7]; this.yrandom = props[8]; this.speedrandom = props[9]; this.sizerandom = props[10]; this.growrandom = props[11]; this.acc = props[12]; this.g = props[13]; this.lifeanglerandom = props[14]; this.lifespeedrandom = props[15]; this.lifeopacityrandom = props[16]; this.destroymode = props[17]; // 0 = fade, 1 = timeout, 2 = stopped this.timeout = props[18]; this.particleCreateCounter = 0; this.particlescale = 1; this.particleBoxLeft = this.x; this.particleBoxTop = this.y; this.particleBoxRight = this.x; this.particleBoxBottom = this.y; this.add_bbox_changed_callback(function (self) { self.bbox.set(self.particleBoxLeft, self.particleBoxTop, self.particleBoxRight, self.particleBoxBottom); self.bquad.set_from_rect(self.bbox); self.bbox_changed = false; self.update_collision_cell(); self.update_render_cell(); }); if (!this.recycled) this.particles = []; this.runtime.tickMe(this); this.type.loadTextures(); if (this.spraytype === 1) { for (var i = 0; i < this.rate; i++) this.allocateParticle().opacity = 0; } this.first_tick = true; // for re-init'ing one-shot particles on first tick so they assume any new angle/position }; instanceProto.saveToJSON = function () { var o = { "r": this.rate, "sc": this.spraycone, "st": this.spraytype, "s": this.spraying, "isp": this.initspeed, "isz": this.initsize, "io": this.initopacity, "gr": this.growrate, "xr": this.xrandom, "yr": this.yrandom, "spr": this.speedrandom, "szr": this.sizerandom, "grnd": this.growrandom, "acc": this.acc, "g": this.g, "lar": this.lifeanglerandom, "lsr": this.lifespeedrandom, "lor": this.lifeopacityrandom, "dm": this.destroymode, "to": this.timeout, "pcc": this.particleCreateCounter, "ft": this.first_tick, "p": [] }; var i, len, p; var arr = o["p"]; for (i = 0, len = this.particles.length; i < len; i++) { p = this.particles[i]; arr.push([p.x, p.y, p.speed, p.angle, p.opacity, p.grow, p.size, p.gs, p.age]); } return o; }; instanceProto.loadFromJSON = function (o) { this.rate = o["r"]; this.spraycone = o["sc"]; this.spraytype = o["st"]; this.spraying = o["s"]; this.initspeed = o["isp"]; this.initsize = o["isz"]; this.initopacity = o["io"]; this.growrate = o["gr"]; this.xrandom = o["xr"]; this.yrandom = o["yr"]; this.speedrandom = o["spr"]; this.sizerandom = o["szr"]; this.growrandom = o["grnd"]; this.acc = o["acc"]; this.g = o["g"]; this.lifeanglerandom = o["lar"]; this.lifespeedrandom = o["lsr"]; this.lifeopacityrandom = o["lor"]; this.destroymode = o["dm"]; this.timeout = o["to"]; this.particleCreateCounter = o["pcc"]; this.first_tick = o["ft"]; deadparticles.push.apply(deadparticles, this.particles); cr.clearArray(this.particles); var i, len, p, d; var arr = o["p"]; for (i = 0, len = arr.length; i < len; i++) { p = this.allocateParticle(); d = arr[i]; p.x = d[0]; p.y = d[1]; p.speed = d[2]; p.angle = d[3]; p.opacity = d[4]; p.grow = d[5]; p.size = d[6]; p.gs = d[7]; p.age = d[8]; } }; instanceProto.onDestroy = function () { deadparticles.push.apply(deadparticles, this.particles); cr.clearArray(this.particles); }; instanceProto.allocateParticle = function () { var p; if (deadparticles.length) { p = deadparticles.pop(); p.owner = this; } else p = new Particle(this); this.particles.push(p); p.active = true; return p; }; instanceProto.tick = function() { var dt = this.runtime.getDt(this); var i, len, p, n, j; if (this.spraytype === 0 && this.spraying) { this.particleCreateCounter += dt * this.rate; n = cr.floor(this.particleCreateCounter); this.particleCreateCounter -= n; for (i = 0; i < n; i++) { p = this.allocateParticle(); p.init(); } } this.particleBoxLeft = this.x; this.particleBoxTop = this.y; this.particleBoxRight = this.x; this.particleBoxBottom = this.y; for (i = 0, j = 0, len = this.particles.length; i < len; i++) { p = this.particles[i]; this.particles[j] = p; this.runtime.redraw = true; if (this.spraytype === 1 && this.first_tick) p.init(); p.tick(dt); if (!p.active) { deadparticles.push(p); continue; } if (p.left() < this.particleBoxLeft) this.particleBoxLeft = p.left(); if (p.right() > this.particleBoxRight) this.particleBoxRight = p.right(); if (p.top() < this.particleBoxTop) this.particleBoxTop = p.top(); if (p.bottom() > this.particleBoxBottom) this.particleBoxBottom = p.bottom(); j++; } cr.truncateArray(this.particles, j); this.set_bbox_changed(); this.first_tick = false; if (this.spraytype === 1 && this.particles.length === 0) this.runtime.DestroyInstance(this); }; instanceProto.draw = function (ctx) { var i, len, p, layer = this.layer; for (i = 0, len = this.particles.length; i < len; i++) { p = this.particles[i]; if (p.right() >= layer.viewLeft && p.bottom() >= layer.viewTop && p.left() <= layer.viewRight && p.top() <= layer.viewBottom) { p.draw(ctx); } } }; instanceProto.drawGL = function (glw) { this.particlescale = this.layer.getScale(); glw.setTexture(this.type.webGL_texture); var i, len, p, layer = this.layer; for (i = 0, len = this.particles.length; i < len; i++) { p = this.particles[i]; if (p.right() >= layer.viewLeft && p.bottom() >= layer.viewTop && p.left() <= layer.viewRight && p.top() <= layer.viewBottom) { p.drawGL(glw); } } }; function Cnds() {}; Cnds.prototype.IsSpraying = function () { return this.spraying; }; pluginProto.cnds = new Cnds(); function Acts() {}; Acts.prototype.SetSpraying = function (set_) { this.spraying = (set_ !== 0); }; Acts.prototype.SetEffect = function (effect) { this.blend_mode = effect; this.compositeOp = cr.effectToCompositeOp(effect); cr.setGLBlend(this, effect, this.runtime.gl); this.runtime.redraw = true; }; Acts.prototype.SetRate = function (x) { this.rate = x; var diff, i; if (this.spraytype === 1 && this.first_tick) { if (x < this.particles.length) { diff = this.particles.length - x; for (i = 0; i < diff; i++) deadparticles.push(this.particles.pop()); } else if (x > this.particles.length) { diff = x - this.particles.length; for (i = 0; i < diff; i++) this.allocateParticle().opacity = 0; } } }; Acts.prototype.SetSprayCone = function (x) { this.spraycone = cr.to_radians(x); }; Acts.prototype.SetInitSpeed = function (x) { this.initspeed = x; }; Acts.prototype.SetInitSize = function (x) { this.initsize = x; }; Acts.prototype.SetInitOpacity = function (x) { this.initopacity = x / 100; }; Acts.prototype.SetGrowRate = function (x) { this.growrate = x; }; Acts.prototype.SetXRandomiser = function (x) { this.xrandom = x; }; Acts.prototype.SetYRandomiser = function (x) { this.yrandom = x; }; Acts.prototype.SetSpeedRandomiser = function (x) { this.speedrandom = x; }; Acts.prototype.SetSizeRandomiser = function (x) { this.sizerandom = x; }; Acts.prototype.SetGrowRateRandomiser = function (x) { this.growrandom = x; }; Acts.prototype.SetParticleAcc = function (x) { this.acc = x; }; Acts.prototype.SetGravity = function (x) { this.g = x; }; Acts.prototype.SetAngleRandomiser = function (x) { this.lifeanglerandom = x; }; Acts.prototype.SetLifeSpeedRandomiser = function (x) { this.lifespeedrandom = x; }; Acts.prototype.SetOpacityRandomiser = function (x) { this.lifeopacityrandom = x; }; Acts.prototype.SetTimeout = function (x) { this.timeout = x; }; pluginProto.acts = new Acts(); function Exps() {}; Exps.prototype.ParticleCount = function (ret) { ret.set_int(this.particles.length); }; Exps.prototype.Rate = function (ret) { ret.set_float(this.rate); }; Exps.prototype.SprayCone = function (ret) { ret.set_float(cr.to_degrees(this.spraycone)); }; Exps.prototype.InitSpeed = function (ret) { ret.set_float(this.initspeed); }; Exps.prototype.InitSize = function (ret) { ret.set_float(this.initsize); }; Exps.prototype.InitOpacity = function (ret) { ret.set_float(this.initopacity * 100); }; Exps.prototype.InitGrowRate = function (ret) { ret.set_float(this.growrate); }; Exps.prototype.XRandom = function (ret) { ret.set_float(this.xrandom); }; Exps.prototype.YRandom = function (ret) { ret.set_float(this.yrandom); }; Exps.prototype.InitSpeedRandom = function (ret) { ret.set_float(this.speedrandom); }; Exps.prototype.InitSizeRandom = function (ret) { ret.set_float(this.sizerandom); }; Exps.prototype.InitGrowRandom = function (ret) { ret.set_float(this.growrandom); }; Exps.prototype.ParticleAcceleration = function (ret) { ret.set_float(this.acc); }; Exps.prototype.Gravity = function (ret) { ret.set_float(this.g); }; Exps.prototype.ParticleAngleRandom = function (ret) { ret.set_float(this.lifeanglerandom); }; Exps.prototype.ParticleSpeedRandom = function (ret) { ret.set_float(this.lifespeedrandom); }; Exps.prototype.ParticleOpacityRandom = function (ret) { ret.set_float(this.lifeopacityrandom); }; Exps.prototype.Timeout = function (ret) { ret.set_float(this.timeout); }; pluginProto.exps = new Exps(); }()); ; ; cr.plugins_.Sprite = function(runtime) { this.runtime = runtime; }; (function () { var pluginProto = cr.plugins_.Sprite.prototype; pluginProto.Type = function(plugin) { this.plugin = plugin; this.runtime = plugin.runtime; }; var typeProto = pluginProto.Type.prototype; function frame_getDataUri() { if (this.datauri.length === 0) { var tmpcanvas = document.createElement("canvas"); tmpcanvas.width = this.width; tmpcanvas.height = this.height; var tmpctx = tmpcanvas.getContext("2d"); if (this.spritesheeted) { tmpctx.drawImage(this.texture_img, this.offx, this.offy, this.width, this.height, 0, 0, this.width, this.height); } else { tmpctx.drawImage(this.texture_img, 0, 0, this.width, this.height); } this.datauri = tmpcanvas.toDataURL("image/png"); } return this.datauri; }; typeProto.onCreate = function() { if (this.is_family) return; var i, leni, j, lenj; var anim, frame, animobj, frameobj, wt, uv; this.all_frames = []; this.has_loaded_textures = false; for (i = 0, leni = this.animations.length; i < leni; i++) { anim = this.animations[i]; animobj = {}; animobj.name = anim[0]; animobj.speed = anim[1]; animobj.loop = anim[2]; animobj.repeatcount = anim[3]; animobj.repeatto = anim[4]; animobj.pingpong = anim[5]; animobj.sid = anim[6]; animobj.frames = []; for (j = 0, lenj = anim[7].length; j < lenj; j++) { frame = anim[7][j]; frameobj = {}; frameobj.texture_file = frame[0]; frameobj.texture_filesize = frame[1]; frameobj.offx = frame[2]; frameobj.offy = frame[3]; frameobj.width = frame[4]; frameobj.height = frame[5]; frameobj.duration = frame[6]; frameobj.hotspotX = frame[7]; frameobj.hotspotY = frame[8]; frameobj.image_points = frame[9]; frameobj.poly_pts = frame[10]; frameobj.pixelformat = frame[11]; frameobj.spritesheeted = (frameobj.width !== 0); frameobj.datauri = ""; // generated on demand and cached frameobj.getDataUri = frame_getDataUri; uv = {}; uv.left = 0; uv.top = 0; uv.right = 1; uv.bottom = 1; frameobj.sheetTex = uv; frameobj.webGL_texture = null; wt = this.runtime.findWaitingTexture(frame[0]); if (wt) { frameobj.texture_img = wt; } else { frameobj.texture_img = new Image(); frameobj.texture_img.cr_src = frame[0]; frameobj.texture_img.cr_filesize = frame[1]; frameobj.texture_img.c2webGL_texture = null; this.runtime.waitForImageLoad(frameobj.texture_img, frame[0]); } cr.seal(frameobj); animobj.frames.push(frameobj); this.all_frames.push(frameobj); } cr.seal(animobj); this.animations[i] = animobj; // swap array data for object } }; typeProto.updateAllCurrentTexture = function () { var i, len, inst; for (i = 0, len = this.instances.length; i < len; i++) { inst = this.instances[i]; inst.curWebGLTexture = inst.curFrame.webGL_texture; } }; typeProto.onLostWebGLContext = function () { if (this.is_family) return; var i, len, frame; for (i = 0, len = this.all_frames.length; i < len; ++i) { frame = this.all_frames[i]; frame.texture_img.c2webGL_texture = null; frame.webGL_texture = null; } this.has_loaded_textures = false; this.updateAllCurrentTexture(); }; typeProto.onRestoreWebGLContext = function () { if (this.is_family || !this.instances.length) return; var i, len, frame; for (i = 0, len = this.all_frames.length; i < len; ++i) { frame = this.all_frames[i]; frame.webGL_texture = this.runtime.glwrap.loadTexture(frame.texture_img, false, this.runtime.linearSampling, frame.pixelformat); } this.updateAllCurrentTexture(); }; typeProto.loadTextures = function () { if (this.is_family || this.has_loaded_textures || !this.runtime.glwrap) return; var i, len, frame; for (i = 0, len = this.all_frames.length; i < len; ++i) { frame = this.all_frames[i]; frame.webGL_texture = this.runtime.glwrap.loadTexture(frame.texture_img, false, this.runtime.linearSampling, frame.pixelformat); } this.has_loaded_textures = true; }; typeProto.unloadTextures = function () { if (this.is_family || this.instances.length || !this.has_loaded_textures) return; var i, len, frame; for (i = 0, len = this.all_frames.length; i < len; ++i) { frame = this.all_frames[i]; this.runtime.glwrap.deleteTexture(frame.webGL_texture); frame.webGL_texture = null; } this.has_loaded_textures = false; }; var already_drawn_images = []; typeProto.preloadCanvas2D = function (ctx) { var i, len, frameimg; cr.clearArray(already_drawn_images); for (i = 0, len = this.all_frames.length; i < len; ++i) { frameimg = this.all_frames[i].texture_img; if (already_drawn_images.indexOf(frameimg) !== -1) continue; ctx.drawImage(frameimg, 0, 0); already_drawn_images.push(frameimg); } }; pluginProto.Instance = function(type) { this.type = type; this.runtime = type.runtime; var poly_pts = this.type.animations[0].frames[0].poly_pts; if (this.recycled) this.collision_poly.set_pts(poly_pts); else this.collision_poly = new cr.CollisionPoly(poly_pts); }; var instanceProto = pluginProto.Instance.prototype; instanceProto.onCreate = function() { this.visible = (this.properties[0] === 0); // 0=visible, 1=invisible this.isTicking = false; this.inAnimTrigger = false; this.collisionsEnabled = (this.properties[3] !== 0); this.cur_animation = this.getAnimationByName(this.properties[1]) || this.type.animations[0]; this.cur_frame = this.properties[2]; if (this.cur_frame < 0) this.cur_frame = 0; if (this.cur_frame >= this.cur_animation.frames.length) this.cur_frame = this.cur_animation.frames.length - 1; var curanimframe = this.cur_animation.frames[this.cur_frame]; this.collision_poly.set_pts(curanimframe.poly_pts); this.hotspotX = curanimframe.hotspotX; this.hotspotY = curanimframe.hotspotY; this.cur_anim_speed = this.cur_animation.speed; this.cur_anim_repeatto = this.cur_animation.repeatto; if (!(this.type.animations.length === 1 && this.type.animations[0].frames.length === 1) && this.cur_anim_speed !== 0) { this.runtime.tickMe(this); this.isTicking = true; } if (this.recycled) this.animTimer.reset(); else this.animTimer = new cr.KahanAdder(); this.frameStart = this.getNowTime(); this.animPlaying = true; this.animRepeats = 0; this.animForwards = true; this.animTriggerName = ""; this.changeAnimName = ""; this.changeAnimFrom = 0; this.changeAnimFrame = -1; this.type.loadTextures(); var i, leni, j, lenj; var anim, frame, uv, maintex; for (i = 0, leni = this.type.animations.length; i < leni; i++) { anim = this.type.animations[i]; for (j = 0, lenj = anim.frames.length; j < lenj; j++) { frame = anim.frames[j]; if (frame.width === 0) { frame.width = frame.texture_img.width; frame.height = frame.texture_img.height; } if (frame.spritesheeted) { maintex = frame.texture_img; uv = frame.sheetTex; uv.left = frame.offx / maintex.width; uv.top = frame.offy / maintex.height; uv.right = (frame.offx + frame.width) / maintex.width; uv.bottom = (frame.offy + frame.height) / maintex.height; if (frame.offx === 0 && frame.offy === 0 && frame.width === maintex.width && frame.height === maintex.height) { frame.spritesheeted = false; } } } } this.curFrame = this.cur_animation.frames[this.cur_frame]; this.curWebGLTexture = this.curFrame.webGL_texture; }; instanceProto.saveToJSON = function () { var o = { "a": this.cur_animation.sid, "f": this.cur_frame, "cas": this.cur_anim_speed, "fs": this.frameStart, "ar": this.animRepeats, "at": this.animTimer.sum, "rt": this.cur_anim_repeatto }; if (!this.animPlaying) o["ap"] = this.animPlaying; if (!this.animForwards) o["af"] = this.animForwards; return o; }; instanceProto.loadFromJSON = function (o) { var anim = this.getAnimationBySid(o["a"]); if (anim) this.cur_animation = anim; this.cur_frame = o["f"]; if (this.cur_frame < 0) this.cur_frame = 0; if (this.cur_frame >= this.cur_animation.frames.length) this.cur_frame = this.cur_animation.frames.length - 1; this.cur_anim_speed = o["cas"]; this.frameStart = o["fs"]; this.animRepeats = o["ar"]; this.animTimer.reset(); this.animTimer.sum = o["at"]; this.animPlaying = o.hasOwnProperty("ap") ? o["ap"] : true; this.animForwards = o.hasOwnProperty("af") ? o["af"] : true; if (o.hasOwnProperty("rt")) this.cur_anim_repeatto = o["rt"]; else this.cur_anim_repeatto = this.cur_animation.repeatto; this.curFrame = this.cur_animation.frames[this.cur_frame]; this.curWebGLTexture = this.curFrame.webGL_texture; this.collision_poly.set_pts(this.curFrame.poly_pts); this.hotspotX = this.curFrame.hotspotX; this.hotspotY = this.curFrame.hotspotY; }; instanceProto.animationFinish = function (reverse) { this.cur_frame = reverse ? 0 : this.cur_animation.frames.length - 1; this.animPlaying = false; this.animTriggerName = this.cur_animation.name; this.inAnimTrigger = true; this.runtime.trigger(cr.plugins_.Sprite.prototype.cnds.OnAnyAnimFinished, this); this.runtime.trigger(cr.plugins_.Sprite.prototype.cnds.OnAnimFinished, this); this.inAnimTrigger = false; this.animRepeats = 0; }; instanceProto.getNowTime = function() { return this.animTimer.sum; }; instanceProto.tick = function() { this.animTimer.add(this.runtime.getDt(this)); if (this.changeAnimName.length) this.doChangeAnim(); if (this.changeAnimFrame >= 0) this.doChangeAnimFrame(); var now = this.getNowTime(); var cur_animation = this.cur_animation; var prev_frame = cur_animation.frames[this.cur_frame]; var next_frame; var cur_frame_time = prev_frame.duration / this.cur_anim_speed; if (this.animPlaying && now >= this.frameStart + cur_frame_time) { if (this.animForwards) { this.cur_frame++; } else { this.cur_frame--; } this.frameStart += cur_frame_time; if (this.cur_frame >= cur_animation.frames.length) { if (cur_animation.pingpong) { this.animForwards = false; this.cur_frame = cur_animation.frames.length - 2; } else if (cur_animation.loop) { this.cur_frame = this.cur_anim_repeatto; } else { this.animRepeats++; if (this.animRepeats >= cur_animation.repeatcount) { this.animationFinish(false); } else { this.cur_frame = this.cur_anim_repeatto; } } } if (this.cur_frame < 0) { if (cur_animation.pingpong) { this.cur_frame = 1; this.animForwards = true; if (!cur_animation.loop) { this.animRepeats++; if (this.animRepeats >= cur_animation.repeatcount) { this.animationFinish(true); } } } else { if (cur_animation.loop) { this.cur_frame = this.cur_anim_repeatto; } else { this.animRepeats++; if (this.animRepeats >= cur_animation.repeatcount) { this.animationFinish(true); } else { this.cur_frame = this.cur_anim_repeatto; } } } } if (this.cur_frame < 0) this.cur_frame = 0; else if (this.cur_frame >= cur_animation.frames.length) this.cur_frame = cur_animation.frames.length - 1; if (now > this.frameStart + (cur_animation.frames[this.cur_frame].duration / this.cur_anim_speed)) { this.frameStart = now; } next_frame = cur_animation.frames[this.cur_frame]; this.OnFrameChanged(prev_frame, next_frame); this.runtime.redraw = true; } }; instanceProto.getAnimationByName = function (name_) { var i, len, a; for (i = 0, len = this.type.animations.length; i < len; i++) { a = this.type.animations[i]; if (cr.equals_nocase(a.name, name_)) return a; } return null; }; instanceProto.getAnimationBySid = function (sid_) { var i, len, a; for (i = 0, len = this.type.animations.length; i < len; i++) { a = this.type.animations[i]; if (a.sid === sid_) return a; } return null; }; instanceProto.doChangeAnim = function () { var prev_frame = this.cur_animation.frames[this.cur_frame]; var anim = this.getAnimationByName(this.changeAnimName); this.changeAnimName = ""; if (!anim) return; if (cr.equals_nocase(anim.name, this.cur_animation.name) && this.animPlaying) return; this.cur_animation = anim; this.cur_anim_speed = anim.speed; this.cur_anim_repeatto = anim.repeatto; if (this.cur_frame < 0) this.cur_frame = 0; if (this.cur_frame >= this.cur_animation.frames.length) this.cur_frame = this.cur_animation.frames.length - 1; if (this.changeAnimFrom === 1) this.cur_frame = 0; this.animPlaying = true; this.frameStart = this.getNowTime(); this.animForwards = true; this.OnFrameChanged(prev_frame, this.cur_animation.frames[this.cur_frame]); this.runtime.redraw = true; }; instanceProto.doChangeAnimFrame = function () { var prev_frame = this.cur_animation.frames[this.cur_frame]; var prev_frame_number = this.cur_frame; this.cur_frame = cr.floor(this.changeAnimFrame); if (this.cur_frame < 0) this.cur_frame = 0; if (this.cur_frame >= this.cur_animation.frames.length) this.cur_frame = this.cur_animation.frames.length - 1; if (prev_frame_number !== this.cur_frame) { this.OnFrameChanged(prev_frame, this.cur_animation.frames[this.cur_frame]); this.frameStart = this.getNowTime(); this.runtime.redraw = true; } this.changeAnimFrame = -1; }; instanceProto.OnFrameChanged = function (prev_frame, next_frame) { var oldw = prev_frame.width; var oldh = prev_frame.height; var neww = next_frame.width; var newh = next_frame.height; if (oldw != neww) this.width *= (neww / oldw); if (oldh != newh) this.height *= (newh / oldh); this.hotspotX = next_frame.hotspotX; this.hotspotY = next_frame.hotspotY; this.collision_poly.set_pts(next_frame.poly_pts); this.set_bbox_changed(); this.curFrame = next_frame; this.curWebGLTexture = next_frame.webGL_texture; var i, len, b; for (i = 0, len = this.behavior_insts.length; i < len; i++) { b = this.behavior_insts[i]; if (b.onSpriteFrameChanged) b.onSpriteFrameChanged(prev_frame, next_frame); } this.runtime.trigger(cr.plugins_.Sprite.prototype.cnds.OnFrameChanged, this); }; instanceProto.draw = function(ctx) { ctx.globalAlpha = this.opacity; var cur_frame = this.curFrame; var spritesheeted = cur_frame.spritesheeted; var cur_image = cur_frame.texture_img; var myx = this.x; var myy = this.y; var w = this.width; var h = this.height; if (this.angle === 0 && w >= 0 && h >= 0) { myx -= this.hotspotX * w; myy -= this.hotspotY * h; if (this.runtime.pixel_rounding) { myx = Math.round(myx); myy = Math.round(myy); } if (spritesheeted) { ctx.drawImage(cur_image, cur_frame.offx, cur_frame.offy, cur_frame.width, cur_frame.height, myx, myy, w, h); } else { ctx.drawImage(cur_image, myx, myy, w, h); } } else { if (this.runtime.pixel_rounding) { myx = Math.round(myx); myy = Math.round(myy); } ctx.save(); var widthfactor = w > 0 ? 1 : -1; var heightfactor = h > 0 ? 1 : -1; ctx.translate(myx, myy); if (widthfactor !== 1 || heightfactor !== 1) ctx.scale(widthfactor, heightfactor); ctx.rotate(this.angle * widthfactor * heightfactor); var drawx = 0 - (this.hotspotX * cr.abs(w)) var drawy = 0 - (this.hotspotY * cr.abs(h)); if (spritesheeted) { ctx.drawImage(cur_image, cur_frame.offx, cur_frame.offy, cur_frame.width, cur_frame.height, drawx, drawy, cr.abs(w), cr.abs(h)); } else { ctx.drawImage(cur_image, drawx, drawy, cr.abs(w), cr.abs(h)); } ctx.restore(); } /* ctx.strokeStyle = "#f00"; ctx.lineWidth = 3; ctx.beginPath(); this.collision_poly.cache_poly(this.width, this.height, this.angle); var i, len, ax, ay, bx, by; for (i = 0, len = this.collision_poly.pts_count; i < len; i++) { ax = this.collision_poly.pts_cache[i*2] + this.x; ay = this.collision_poly.pts_cache[i*2+1] + this.y; bx = this.collision_poly.pts_cache[((i+1)%len)*2] + this.x; by = this.collision_poly.pts_cache[((i+1)%len)*2+1] + this.y; ctx.moveTo(ax, ay); ctx.lineTo(bx, by); } ctx.stroke(); ctx.closePath(); */ /* if (this.behavior_insts.length >= 1 && this.behavior_insts[0].draw) { this.behavior_insts[0].draw(ctx); } */ }; instanceProto.drawGL_earlyZPass = function(glw) { this.drawGL(glw); }; instanceProto.drawGL = function(glw) { glw.setTexture(this.curWebGLTexture); glw.setOpacity(this.opacity); var cur_frame = this.curFrame; var q = this.bquad; if (this.runtime.pixel_rounding) { var ox = Math.round(this.x) - this.x; var oy = Math.round(this.y) - this.y; if (cur_frame.spritesheeted) glw.quadTex(q.tlx + ox, q.tly + oy, q.trx + ox, q.try_ + oy, q.brx + ox, q.bry + oy, q.blx + ox, q.bly + oy, cur_frame.sheetTex); else glw.quad(q.tlx + ox, q.tly + oy, q.trx + ox, q.try_ + oy, q.brx + ox, q.bry + oy, q.blx + ox, q.bly + oy); } else { if (cur_frame.spritesheeted) glw.quadTex(q.tlx, q.tly, q.trx, q.try_, q.brx, q.bry, q.blx, q.bly, cur_frame.sheetTex); else glw.quad(q.tlx, q.tly, q.trx, q.try_, q.brx, q.bry, q.blx, q.bly); } }; instanceProto.getImagePointIndexByName = function(name_) { var cur_frame = this.curFrame; var i, len; for (i = 0, len = cur_frame.image_points.length; i < len; i++) { if (cr.equals_nocase(name_, cur_frame.image_points[i][0])) return i; } return -1; }; instanceProto.getImagePoint = function(imgpt, getX) { var cur_frame = this.curFrame; var image_points = cur_frame.image_points; var index; if (cr.is_string(imgpt)) index = this.getImagePointIndexByName(imgpt); else index = imgpt - 1; // 0 is origin index = cr.floor(index); if (index < 0 || index >= image_points.length) return getX ? this.x : this.y; // return origin var x = (image_points[index][1] - cur_frame.hotspotX) * this.width; var y = image_points[index][2]; y = (y - cur_frame.hotspotY) * this.height; var cosa = Math.cos(this.angle); var sina = Math.sin(this.angle); var x_temp = (x * cosa) - (y * sina); y = (y * cosa) + (x * sina); x = x_temp; x += this.x; y += this.y; return getX ? x : y; }; function Cnds() {}; var arrCache = []; function allocArr() { if (arrCache.length) return arrCache.pop(); else return [0, 0, 0]; }; function freeArr(a) { a[0] = 0; a[1] = 0; a[2] = 0; arrCache.push(a); }; function makeCollKey(a, b) { if (a < b) return "" + a + "," + b; else return "" + b + "," + a; }; function collmemory_add(collmemory, a, b, tickcount) { var a_uid = a.uid; var b_uid = b.uid; var key = makeCollKey(a_uid, b_uid); if (collmemory.hasOwnProperty(key)) { collmemory[key][2] = tickcount; return; } var arr = allocArr(); arr[0] = a_uid; arr[1] = b_uid; arr[2] = tickcount; collmemory[key] = arr; }; function collmemory_remove(collmemory, a, b) { var key = makeCollKey(a.uid, b.uid); if (collmemory.hasOwnProperty(key)) { freeArr(collmemory[key]); delete collmemory[key]; } }; function collmemory_removeInstance(collmemory, inst) { var uid = inst.uid; var p, entry; for (p in collmemory) { if (collmemory.hasOwnProperty(p)) { entry = collmemory[p]; if (entry[0] === uid || entry[1] === uid) { freeArr(collmemory[p]); delete collmemory[p]; } } } }; var last_coll_tickcount = -2; function collmemory_has(collmemory, a, b) { var key = makeCollKey(a.uid, b.uid); if (collmemory.hasOwnProperty(key)) { last_coll_tickcount = collmemory[key][2]; return true; } else { last_coll_tickcount = -2; return false; } }; var candidates1 = []; Cnds.prototype.OnCollision = function (rtype) { if (!rtype) return false; var runtime = this.runtime; var cnd = runtime.getCurrentCondition(); var ltype = cnd.type; var collmemory = null; if (cnd.extra["collmemory"]) { collmemory = cnd.extra["collmemory"]; } else { collmemory = {}; cnd.extra["collmemory"] = collmemory; } if (!cnd.extra["spriteCreatedDestroyCallback"]) { cnd.extra["spriteCreatedDestroyCallback"] = true; runtime.addDestroyCallback(function(inst) { collmemory_removeInstance(cnd.extra["collmemory"], inst); }); } var lsol = ltype.getCurrentSol(); var rsol = rtype.getCurrentSol(); var linstances = lsol.getObjects(); var rinstances; var registeredInstances; var l, linst, r, rinst; var curlsol, currsol; var tickcount = this.runtime.tickcount; var lasttickcount = tickcount - 1; var exists, run; var current_event = runtime.getCurrentEventStack().current_event; var orblock = current_event.orblock; for (l = 0; l < linstances.length; l++) { linst = linstances[l]; if (rsol.select_all) { linst.update_bbox(); this.runtime.getCollisionCandidates(linst.layer, rtype, linst.bbox, candidates1); rinstances = candidates1; this.runtime.addRegisteredCollisionCandidates(linst, rtype, rinstances); } else { rinstances = rsol.getObjects(); } for (r = 0; r < rinstances.length; r++) { rinst = rinstances[r]; if (runtime.testOverlap(linst, rinst) || runtime.checkRegisteredCollision(linst, rinst)) { exists = collmemory_has(collmemory, linst, rinst); run = (!exists || (last_coll_tickcount < lasttickcount)); collmemory_add(collmemory, linst, rinst, tickcount); if (run) { runtime.pushCopySol(current_event.solModifiers); curlsol = ltype.getCurrentSol(); currsol = rtype.getCurrentSol(); curlsol.select_all = false; currsol.select_all = false; if (ltype === rtype) { curlsol.instances.length = 2; // just use lsol, is same reference as rsol curlsol.instances[0] = linst; curlsol.instances[1] = rinst; ltype.applySolToContainer(); } else { curlsol.instances.length = 1; currsol.instances.length = 1; curlsol.instances[0] = linst; currsol.instances[0] = rinst; ltype.applySolToContainer(); rtype.applySolToContainer(); } current_event.retrigger(); runtime.popSol(current_event.solModifiers); } } else { collmemory_remove(collmemory, linst, rinst); } } cr.clearArray(candidates1); } return false; }; var rpicktype = null; var rtopick = new cr.ObjectSet(); var needscollisionfinish = false; var candidates2 = []; var temp_bbox = new cr.rect(0, 0, 0, 0); function DoOverlapCondition(rtype, offx, offy) { if (!rtype) return false; var do_offset = (offx !== 0 || offy !== 0); var oldx, oldy, ret = false, r, lenr, rinst; var cnd = this.runtime.getCurrentCondition(); var ltype = cnd.type; var inverted = cnd.inverted; var rsol = rtype.getCurrentSol(); var orblock = this.runtime.getCurrentEventStack().current_event.orblock; var rinstances; if (rsol.select_all) { this.update_bbox(); temp_bbox.copy(this.bbox); temp_bbox.offset(offx, offy); this.runtime.getCollisionCandidates(this.layer, rtype, temp_bbox, candidates2); rinstances = candidates2; } else if (orblock) { if (this.runtime.isCurrentConditionFirst() && !rsol.else_instances.length && rsol.instances.length) rinstances = rsol.instances; else rinstances = rsol.else_instances; } else { rinstances = rsol.instances; } rpicktype = rtype; needscollisionfinish = (ltype !== rtype && !inverted); if (do_offset) { oldx = this.x; oldy = this.y; this.x += offx; this.y += offy; this.set_bbox_changed(); } for (r = 0, lenr = rinstances.length; r < lenr; r++) { rinst = rinstances[r]; if (this.runtime.testOverlap(this, rinst)) { ret = true; if (inverted) break; if (ltype !== rtype) rtopick.add(rinst); } } if (do_offset) { this.x = oldx; this.y = oldy; this.set_bbox_changed(); } cr.clearArray(candidates2); return ret; }; typeProto.finish = function (do_pick) { if (!needscollisionfinish) return; if (do_pick) { var orblock = this.runtime.getCurrentEventStack().current_event.orblock; var sol = rpicktype.getCurrentSol(); var topick = rtopick.valuesRef(); var i, len, inst; if (sol.select_all) { sol.select_all = false; cr.clearArray(sol.instances); for (i = 0, len = topick.length; i < len; ++i) { sol.instances[i] = topick[i]; } if (orblock) { cr.clearArray(sol.else_instances); for (i = 0, len = rpicktype.instances.length; i < len; ++i) { inst = rpicktype.instances[i]; if (!rtopick.contains(inst)) sol.else_instances.push(inst); } } } else { if (orblock) { var initsize = sol.instances.length; for (i = 0, len = topick.length; i < len; ++i) { sol.instances[initsize + i] = topick[i]; cr.arrayFindRemove(sol.else_instances, topick[i]); } } else { cr.shallowAssignArray(sol.instances, topick); } } rpicktype.applySolToContainer(); } rtopick.clear(); needscollisionfinish = false; }; Cnds.prototype.IsOverlapping = function (rtype) { return DoOverlapCondition.call(this, rtype, 0, 0); }; Cnds.prototype.IsOverlappingOffset = function (rtype, offx, offy) { return DoOverlapCondition.call(this, rtype, offx, offy); }; Cnds.prototype.IsAnimPlaying = function (animname) { if (this.changeAnimName.length) return cr.equals_nocase(this.changeAnimName, animname); else return cr.equals_nocase(this.cur_animation.name, animname); }; Cnds.prototype.CompareFrame = function (cmp, framenum) { return cr.do_cmp(this.cur_frame, cmp, framenum); }; Cnds.prototype.CompareAnimSpeed = function (cmp, x) { var s = (this.animForwards ? this.cur_anim_speed : -this.cur_anim_speed); return cr.do_cmp(s, cmp, x); }; Cnds.prototype.OnAnimFinished = function (animname) { return cr.equals_nocase(this.animTriggerName, animname); }; Cnds.prototype.OnAnyAnimFinished = function () { return true; }; Cnds.prototype.OnFrameChanged = function () { return true; }; Cnds.prototype.IsMirrored = function () { return this.width < 0; }; Cnds.prototype.IsFlipped = function () { return this.height < 0; }; Cnds.prototype.OnURLLoaded = function () { return true; }; Cnds.prototype.IsCollisionEnabled = function () { return this.collisionsEnabled; }; pluginProto.cnds = new Cnds(); function Acts() {}; Acts.prototype.Spawn = function (obj, layer, imgpt) { if (!obj || !layer) return; var inst = this.runtime.createInstance(obj, layer, this.getImagePoint(imgpt, true), this.getImagePoint(imgpt, false)); if (!inst) return; if (typeof inst.angle !== "undefined") { inst.angle = this.angle; inst.set_bbox_changed(); } this.runtime.isInOnDestroy++; var i, len, s; this.runtime.trigger(Object.getPrototypeOf(obj.plugin).cnds.OnCreated, inst); if (inst.is_contained) { for (i = 0, len = inst.siblings.length; i < len; i++) { s = inst.siblings[i]; this.runtime.trigger(Object.getPrototypeOf(s.type.plugin).cnds.OnCreated, s); } } this.runtime.isInOnDestroy--; var cur_act = this.runtime.getCurrentAction(); var reset_sol = false; if (cr.is_undefined(cur_act.extra["Spawn_LastExec"]) || cur_act.extra["Spawn_LastExec"] < this.runtime.execcount) { reset_sol = true; cur_act.extra["Spawn_LastExec"] = this.runtime.execcount; } var sol; if (obj != this.type) { sol = obj.getCurrentSol(); sol.select_all = false; if (reset_sol) { cr.clearArray(sol.instances); sol.instances[0] = inst; } else sol.instances.push(inst); if (inst.is_contained) { for (i = 0, len = inst.siblings.length; i < len; i++) { s = inst.siblings[i]; sol = s.type.getCurrentSol(); sol.select_all = false; if (reset_sol) { cr.clearArray(sol.instances); sol.instances[0] = s; } else sol.instances.push(s); } } } }; Acts.prototype.SetEffect = function (effect) { this.blend_mode = effect; this.compositeOp = cr.effectToCompositeOp(effect); cr.setGLBlend(this, effect, this.runtime.gl); this.runtime.redraw = true; }; Acts.prototype.StopAnim = function () { this.animPlaying = false; }; Acts.prototype.StartAnim = function (from) { this.animPlaying = true; this.frameStart = this.getNowTime(); if (from === 1 && this.cur_frame !== 0) { this.changeAnimFrame = 0; if (!this.inAnimTrigger) this.doChangeAnimFrame(); } if (!this.isTicking) { this.runtime.tickMe(this); this.isTicking = true; } }; Acts.prototype.SetAnim = function (animname, from) { this.changeAnimName = animname; this.changeAnimFrom = from; if (!this.isTicking) { this.runtime.tickMe(this); this.isTicking = true; } if (!this.inAnimTrigger) this.doChangeAnim(); }; Acts.prototype.SetAnimFrame = function (framenumber) { this.changeAnimFrame = framenumber; if (!this.isTicking) { this.runtime.tickMe(this); this.isTicking = true; } if (!this.inAnimTrigger) this.doChangeAnimFrame(); }; Acts.prototype.SetAnimSpeed = function (s) { this.cur_anim_speed = cr.abs(s); this.animForwards = (s >= 0); if (!this.isTicking) { this.runtime.tickMe(this); this.isTicking = true; } }; Acts.prototype.SetAnimRepeatToFrame = function (s) { s = Math.floor(s); if (s < 0) s = 0; if (s >= this.cur_animation.frames.length) s = this.cur_animation.frames.length - 1; this.cur_anim_repeatto = s; }; Acts.prototype.SetMirrored = function (m) { var neww = cr.abs(this.width) * (m === 0 ? -1 : 1); if (this.width === neww) return; this.width = neww; this.set_bbox_changed(); }; Acts.prototype.SetFlipped = function (f) { var newh = cr.abs(this.height) * (f === 0 ? -1 : 1); if (this.height === newh) return; this.height = newh; this.set_bbox_changed(); }; Acts.prototype.SetScale = function (s) { var cur_frame = this.curFrame; var mirror_factor = (this.width < 0 ? -1 : 1); var flip_factor = (this.height < 0 ? -1 : 1); var new_width = cur_frame.width * s * mirror_factor; var new_height = cur_frame.height * s * flip_factor; if (this.width !== new_width || this.height !== new_height) { this.width = new_width; this.height = new_height; this.set_bbox_changed(); } }; Acts.prototype.LoadURL = function (url_, resize_, crossOrigin_) { var img = new Image(); var self = this; var curFrame_ = this.curFrame; img.onload = function () { if (curFrame_.texture_img.src === img.src) { if (self.runtime.glwrap && self.curFrame === curFrame_) self.curWebGLTexture = curFrame_.webGL_texture; if (resize_ === 0) // resize to image size { self.width = img.width; self.height = img.height; self.set_bbox_changed(); } self.runtime.redraw = true; self.runtime.trigger(cr.plugins_.Sprite.prototype.cnds.OnURLLoaded, self); return; } curFrame_.texture_img = img; curFrame_.offx = 0; curFrame_.offy = 0; curFrame_.width = img.width; curFrame_.height = img.height; curFrame_.spritesheeted = false; curFrame_.datauri = ""; curFrame_.pixelformat = 0; // reset to RGBA, since we don't know what type of image will have come in if (self.runtime.glwrap) { if (curFrame_.webGL_texture) self.runtime.glwrap.deleteTexture(curFrame_.webGL_texture); curFrame_.webGL_texture = self.runtime.glwrap.loadTexture(img, false, self.runtime.linearSampling); if (self.curFrame === curFrame_) self.curWebGLTexture = curFrame_.webGL_texture; self.type.updateAllCurrentTexture(); } if (resize_ === 0) // resize to image size { self.width = img.width; self.height = img.height; self.set_bbox_changed(); } self.runtime.redraw = true; self.runtime.trigger(cr.plugins_.Sprite.prototype.cnds.OnURLLoaded, self); }; if (url_.substr(0, 5) !== "data:" && crossOrigin_ === 0) img["crossOrigin"] = "anonymous"; this.runtime.setImageSrc(img, url_); }; Acts.prototype.SetCollisions = function (set_) { if (this.collisionsEnabled === (set_ !== 0)) return; // no change this.collisionsEnabled = (set_ !== 0); if (this.collisionsEnabled) this.set_bbox_changed(); // needs to be added back to cells else { if (this.collcells.right >= this.collcells.left) this.type.collision_grid.update(this, this.collcells, null); this.collcells.set(0, 0, -1, -1); } }; pluginProto.acts = new Acts(); function Exps() {}; Exps.prototype.AnimationFrame = function (ret) { ret.set_int(this.cur_frame); }; Exps.prototype.AnimationFrameCount = function (ret) { ret.set_int(this.cur_animation.frames.length); }; Exps.prototype.AnimationName = function (ret) { ret.set_string(this.cur_animation.name); }; Exps.prototype.AnimationSpeed = function (ret) { ret.set_float(this.animForwards ? this.cur_anim_speed : -this.cur_anim_speed); }; Exps.prototype.ImagePointX = function (ret, imgpt) { ret.set_float(this.getImagePoint(imgpt, true)); }; Exps.prototype.ImagePointY = function (ret, imgpt) { ret.set_float(this.getImagePoint(imgpt, false)); }; Exps.prototype.ImagePointCount = function (ret) { ret.set_int(this.curFrame.image_points.length); }; Exps.prototype.ImageWidth = function (ret) { ret.set_float(this.curFrame.width); }; Exps.prototype.ImageHeight = function (ret) { ret.set_float(this.curFrame.height); }; pluginProto.exps = new Exps(); }()); /* global cr,log,assert2 */ /* jshint globalstrict: true */ /* jshint strict: true */ ; ; cr.plugins_.Spritefont2 = function(runtime) { this.runtime = runtime; }; (function () { var pluginProto = cr.plugins_.Spritefont2.prototype; pluginProto.onCreate = function () { }; pluginProto.Type = function(plugin) { this.plugin = plugin; this.runtime = plugin.runtime; }; var typeProto = pluginProto.Type.prototype; typeProto.onCreate = function() { if (this.is_family) return; this.texture_img = new Image(); this.runtime.waitForImageLoad(this.texture_img, this.texture_file); this.webGL_texture = null; }; typeProto.onLostWebGLContext = function () { if (this.is_family) return; this.webGL_texture = null; }; typeProto.onRestoreWebGLContext = function () { if (this.is_family || !this.instances.length) return; if (!this.webGL_texture) { this.webGL_texture = this.runtime.glwrap.loadTexture(this.texture_img, false, this.runtime.linearSampling, this.texture_pixelformat); } var i, len; for (i = 0, len = this.instances.length; i < len; i++) this.instances[i].webGL_texture = this.webGL_texture; }; typeProto.unloadTextures = function () { if (this.is_family || this.instances.length || !this.webGL_texture) return; this.runtime.glwrap.deleteTexture(this.webGL_texture); this.webGL_texture = null; }; typeProto.preloadCanvas2D = function (ctx) { ctx.drawImage(this.texture_img, 0, 0); }; pluginProto.Instance = function(type) { this.type = type; this.runtime = type.runtime; }; var instanceProto = pluginProto.Instance.prototype; instanceProto.onDestroy = function() { freeAllLines (this.lines); freeAllClip (this.clipList); freeAllClipUV(this.clipUV); cr.wipe(this.characterWidthList); }; instanceProto.onCreate = function() { this.texture_img = this.type.texture_img; this.characterWidth = this.properties[0]; this.characterHeight = this.properties[1]; this.characterSet = this.properties[2]; this.text = this.properties[3]; this.characterScale = this.properties[4]; this.visible = (this.properties[5] === 0); // 0=visible, 1=invisible this.halign = this.properties[6]/2.0; // 0=left, 1=center, 2=right this.valign = this.properties[7]/2.0; // 0=top, 1=center, 2=bottom this.wrapbyword = (this.properties[9] === 0); // 0=word, 1=character this.characterSpacing = this.properties[10]; this.lineHeight = this.properties[11]; this.textWidth = 0; this.textHeight = 0; if (this.recycled) { cr.clearArray(this.lines); cr.wipe(this.clipList); cr.wipe(this.clipUV); cr.wipe(this.characterWidthList); } else { this.lines = []; this.clipList = {}; this.clipUV = {}; this.characterWidthList = {}; } this.text_changed = true; this.lastwrapwidth = this.width; if (this.runtime.glwrap) { if (!this.type.webGL_texture) { this.type.webGL_texture = this.runtime.glwrap.loadTexture(this.type.texture_img, false, this.runtime.linearSampling, this.type.texture_pixelformat); } this.webGL_texture = this.type.webGL_texture; } this.SplitSheet(); }; instanceProto.saveToJSON = function () { var save = { "t": this.text, "csc": this.characterScale, "csp": this.characterSpacing, "lh": this.lineHeight, "tw": this.textWidth, "th": this.textHeight, "lrt": this.last_render_tick, "ha": this.halign, "va": this.valign, "cw": {} }; for (var ch in this.characterWidthList) save["cw"][ch] = this.characterWidthList[ch]; return save; }; instanceProto.loadFromJSON = function (o) { this.text = o["t"]; this.characterScale = o["csc"]; this.characterSpacing = o["csp"]; this.lineHeight = o["lh"]; this.textWidth = o["tw"]; this.textHeight = o["th"]; this.last_render_tick = o["lrt"]; if (o.hasOwnProperty("ha")) this.halign = o["ha"]; if (o.hasOwnProperty("va")) this.valign = o["va"]; for(var ch in o["cw"]) this.characterWidthList[ch] = o["cw"][ch]; this.text_changed = true; this.lastwrapwidth = this.width; }; function trimRight(text) { return text.replace(/\s\s*$/, ''); } var MAX_CACHE_SIZE = 1000; function alloc(cache,Constructor) { if (cache.length) return cache.pop(); else return new Constructor(); } function free(cache,data) { if (cache.length < MAX_CACHE_SIZE) { cache.push(data); } } function freeAll(cache,dataList,isArray) { if (isArray) { var i, len; for (i = 0, len = dataList.length; i < len; i++) { free(cache,dataList[i]); } cr.clearArray(dataList); } else { var prop; for(prop in dataList) { if(Object.prototype.hasOwnProperty.call(dataList,prop)) { free(cache,dataList[prop]); delete dataList[prop]; } } } } function addLine(inst,lineIndex,cur_line) { var lines = inst.lines; var line; cur_line = trimRight(cur_line); if (lineIndex >= lines.length) lines.push(allocLine()); line = lines[lineIndex]; line.text = cur_line; line.width = inst.measureWidth(cur_line); inst.textWidth = cr.max(inst.textWidth,line.width); } var linesCache = []; function allocLine() { return alloc(linesCache,Object); } function freeLine(l) { free(linesCache,l); } function freeAllLines(arr) { freeAll(linesCache,arr,true); } function addClip(obj,property,x,y,w,h) { if (obj[property] === undefined) { obj[property] = alloc(clipCache,Object); } obj[property].x = x; obj[property].y = y; obj[property].w = w; obj[property].h = h; } var clipCache = []; function allocClip() { return alloc(clipCache,Object); } function freeAllClip(obj) { freeAll(clipCache,obj,false);} function addClipUV(obj,property,left,top,right,bottom) { if (obj[property] === undefined) { obj[property] = alloc(clipUVCache,cr.rect); } obj[property].left = left; obj[property].top = top; obj[property].right = right; obj[property].bottom = bottom; } var clipUVCache = []; function allocClipUV() { return alloc(clipUVCache,cr.rect);} function freeAllClipUV(obj) { freeAll(clipUVCache,obj,false);} instanceProto.SplitSheet = function() { var texture = this.texture_img; var texWidth = texture.width; var texHeight = texture.height; var charWidth = this.characterWidth; var charHeight = this.characterHeight; var charU = charWidth /texWidth; var charV = charHeight/texHeight; var charSet = this.characterSet ; var cols = Math.floor(texWidth/charWidth); var rows = Math.floor(texHeight/charHeight); for ( var c = 0; c < charSet.length; c++) { if (c >= cols * rows) break; var x = c%cols; var y = Math.floor(c/cols); var letter = charSet.charAt(c); if (this.runtime.glwrap) { addClipUV( this.clipUV, letter, x * charU , y * charV , (x+1) * charU , (y+1) * charV ); } else { addClip( this.clipList, letter, x * charWidth, y * charHeight, charWidth, charHeight ); } } }; /* * Word-Wrapping */ var wordsCache = []; pluginProto.TokeniseWords = function (text) { cr.clearArray(wordsCache); var cur_word = ""; var ch; var i = 0; while (i < text.length) { ch = text.charAt(i); if (ch === "\n") { if (cur_word.length) { wordsCache.push(cur_word); cur_word = ""; } wordsCache.push("\n"); ++i; } else if (ch === " " || ch === "\t" || ch === "-") { do { cur_word += text.charAt(i); i++; } while (i < text.length && (text.charAt(i) === " " || text.charAt(i) === "\t")); wordsCache.push(cur_word); cur_word = ""; } else if (i < text.length) { cur_word += ch; i++; } } if (cur_word.length) wordsCache.push(cur_word); }; pluginProto.WordWrap = function (inst) { var text = inst.text; var lines = inst.lines; if (!text || !text.length) { freeAllLines(lines); return; } var width = inst.width; if (width <= 2.0) { freeAllLines(lines); return; } var charWidth = inst.characterWidth; var charScale = inst.characterScale; var charSpacing = inst.characterSpacing; if ( (text.length * (charWidth * charScale + charSpacing) - charSpacing) <= width && text.indexOf("\n") === -1) { var all_width = inst.measureWidth(text); if (all_width <= width) { freeAllLines(lines); lines.push(allocLine()); lines[0].text = text; lines[0].width = all_width; inst.textWidth = all_width; inst.textHeight = inst.characterHeight * charScale + inst.lineHeight; return; } } var wrapbyword = inst.wrapbyword; this.WrapText(inst); inst.textHeight = lines.length * (inst.characterHeight * charScale + inst.lineHeight); }; pluginProto.WrapText = function (inst) { var wrapbyword = inst.wrapbyword; var text = inst.text; var lines = inst.lines; var width = inst.width; var wordArray; if (wrapbyword) { this.TokeniseWords(text); // writes to wordsCache wordArray = wordsCache; } else { wordArray = text; } var cur_line = ""; var prev_line; var line_width; var i; var lineIndex = 0; var line; var ignore_newline = false; for (i = 0; i < wordArray.length; i++) { if (wordArray[i] === "\n") { if (ignore_newline === true) { ignore_newline = false; } else { addLine(inst,lineIndex,cur_line); lineIndex++; } cur_line = ""; continue; } ignore_newline = false; prev_line = cur_line; cur_line += wordArray[i]; line_width = inst.measureWidth(trimRight(cur_line)); if (line_width > width) { if (prev_line === "") { addLine(inst,lineIndex,cur_line); cur_line = ""; ignore_newline = true; } else { addLine(inst,lineIndex,prev_line); cur_line = wordArray[i]; } lineIndex++; if (!wrapbyword && cur_line === " ") cur_line = ""; } } if (trimRight(cur_line).length) { addLine(inst,lineIndex,cur_line); lineIndex++; } for (i = lineIndex; i < lines.length; i++) freeLine(lines[i]); lines.length = lineIndex; }; instanceProto.measureWidth = function(text) { var spacing = this.characterSpacing; var len = text.length; var width = 0; for (var i = 0; i < len; i++) { width += this.getCharacterWidth(text.charAt(i)) * this.characterScale + spacing; } width -= (width > 0) ? spacing : 0; return width; }; /***/ instanceProto.getCharacterWidth = function(character) { var widthList = this.characterWidthList; if (widthList[character] !== undefined) { return widthList[character]; } else { return this.characterWidth; } }; instanceProto.rebuildText = function() { if (this.text_changed || this.width !== this.lastwrapwidth) { this.textWidth = 0; this.textHeight = 0; this.type.plugin.WordWrap(this); this.text_changed = false; this.lastwrapwidth = this.width; } }; var EPSILON = 0.00001; instanceProto.draw = function(ctx, glmode) { var texture = this.texture_img; if (this.text !== "" && texture != null) { this.rebuildText(); if (this.height < this.characterHeight*this.characterScale + this.lineHeight) { return; } ctx.globalAlpha = this.opacity; var myx = this.x; var myy = this.y; if (this.runtime.pixel_rounding) { myx = Math.round(myx); myy = Math.round(myy); } var viewLeft = this.layer.viewLeft; var viewTop = this.layer.viewTop; var viewRight = this.layer.viewRight; var viewBottom = this.layer.viewBottom; ctx.save(); ctx.translate(myx, myy); ctx.rotate(this.angle); var angle = this.angle; var ha = this.halign; var va = this.valign; var scale = this.characterScale; var charHeight = this.characterHeight * scale; var lineHeight = this.lineHeight; var charSpace = this.characterSpacing; var lines = this.lines; var textHeight = this.textHeight; var letterWidth; var halign; var valign = va * cr.max(0,(this.height - textHeight)); var offx = -(this.hotspotX * this.width); var offy = -(this.hotspotY * this.height); offy += valign; var drawX ; var drawY = offy; var roundX, roundY; for(var i = 0; i < lines.length; i++) { var line = lines[i].text; var len = lines[i].width; halign = ha * cr.max(0,this.width - len); drawX = offx + halign; drawY += lineHeight; if (angle === 0 && myy + drawY + charHeight < viewTop) { drawY += charHeight; continue; } for(var j = 0; j < line.length; j++) { var letter = line.charAt(j); letterWidth = this.getCharacterWidth(letter); var clip = this.clipList[letter]; if (angle === 0 && myx + drawX + letterWidth * scale + charSpace < viewLeft) { drawX += letterWidth * scale + charSpace; continue; } if ( drawX + letterWidth * scale > this.width + EPSILON ) { break; } if (clip !== undefined) { roundX = drawX; roundY = drawY; if (angle === 0 && scale === 1) { roundX = Math.round(roundX); roundY = Math.round(roundY); } ctx.drawImage( this.texture_img, clip.x, clip.y, clip.w, clip.h, roundX,roundY,clip.w*scale,clip.h*scale); } drawX += letterWidth * scale + charSpace; if (angle === 0 && myx + drawX > viewRight) break; } drawY += charHeight; if (angle === 0 && (drawY + charHeight + lineHeight > this.height || myy + drawY > viewBottom)) { break; } } ctx.restore(); } }; var dQuad = new cr.quad(); function rotateQuad(quad,cosa,sina) { var x_temp; x_temp = (quad.tlx * cosa) - (quad.tly * sina); quad.tly = (quad.tly * cosa) + (quad.tlx * sina); quad.tlx = x_temp; x_temp = (quad.trx * cosa) - (quad.try_ * sina); quad.try_ = (quad.try_ * cosa) + (quad.trx * sina); quad.trx = x_temp; x_temp = (quad.blx * cosa) - (quad.bly * sina); quad.bly = (quad.bly * cosa) + (quad.blx * sina); quad.blx = x_temp; x_temp = (quad.brx * cosa) - (quad.bry * sina); quad.bry = (quad.bry * cosa) + (quad.brx * sina); quad.brx = x_temp; } instanceProto.drawGL = function(glw) { glw.setTexture(this.webGL_texture); glw.setOpacity(this.opacity); if (!this.text) return; this.rebuildText(); if (this.height < this.characterHeight*this.characterScale + this.lineHeight) { return; } this.update_bbox(); var q = this.bquad; var ox = 0; var oy = 0; if (this.runtime.pixel_rounding) { ox = Math.round(this.x) - this.x; oy = Math.round(this.y) - this.y; } var viewLeft = this.layer.viewLeft; var viewTop = this.layer.viewTop; var viewRight = this.layer.viewRight; var viewBottom = this.layer.viewBottom; var angle = this.angle; var ha = this.halign; var va = this.valign; var scale = this.characterScale; var charHeight = this.characterHeight * scale; // to precalculate in onCreate or on change var lineHeight = this.lineHeight; var charSpace = this.characterSpacing; var lines = this.lines; var textHeight = this.textHeight; var letterWidth; var cosa,sina; if (angle !== 0) { cosa = Math.cos(angle); sina = Math.sin(angle); } var halign; var valign = va * cr.max(0,(this.height - textHeight)); var offx = q.tlx + ox; var offy = q.tly + oy; var drawX ; var drawY = valign; var roundX, roundY; for(var i = 0; i < lines.length; i++) { var line = lines[i].text; var lineWidth = lines[i].width; halign = ha * cr.max(0,this.width - lineWidth); drawX = halign; drawY += lineHeight; if (angle === 0 && offy + drawY + charHeight < viewTop) { drawY += charHeight; continue; } for(var j = 0; j < line.length; j++) { var letter = line.charAt(j); letterWidth = this.getCharacterWidth(letter); var clipUV = this.clipUV[letter]; if (angle === 0 && offx + drawX + letterWidth * scale + charSpace < viewLeft) { drawX += letterWidth * scale + charSpace; continue; } if (drawX + letterWidth * scale > this.width + EPSILON) { break; } if (clipUV !== undefined) { var clipWidth = this.characterWidth*scale; var clipHeight = this.characterHeight*scale; roundX = drawX; roundY = drawY; if (angle === 0 && scale === 1) { roundX = Math.round(roundX); roundY = Math.round(roundY); } dQuad.tlx = roundX; dQuad.tly = roundY; dQuad.trx = roundX + clipWidth; dQuad.try_ = roundY ; dQuad.blx = roundX; dQuad.bly = roundY + clipHeight; dQuad.brx = roundX + clipWidth; dQuad.bry = roundY + clipHeight; if(angle !== 0) { rotateQuad(dQuad,cosa,sina); } dQuad.offset(offx,offy); glw.quadTex( dQuad.tlx, dQuad.tly, dQuad.trx, dQuad.try_, dQuad.brx, dQuad.bry, dQuad.blx, dQuad.bly, clipUV ); } drawX += letterWidth * scale + charSpace; if (angle === 0 && offx + drawX > viewRight) break; } drawY += charHeight; if (angle === 0 && (drawY + charHeight + lineHeight > this.height || offy + drawY > viewBottom)) { break; } } }; function Cnds() {} Cnds.prototype.CompareText = function(text_to_compare, case_sensitive) { if (case_sensitive) return this.text == text_to_compare; else return cr.equals_nocase(this.text, text_to_compare); }; pluginProto.cnds = new Cnds(); function Acts() {} Acts.prototype.SetText = function(param) { if (cr.is_number(param) && param < 1e9) param = Math.round(param * 1e10) / 1e10; // round to nearest ten billionth - hides floating point errors var text_to_set = param.toString(); if (this.text !== text_to_set) { this.text = text_to_set; this.text_changed = true; this.runtime.redraw = true; } }; Acts.prototype.AppendText = function(param) { if (cr.is_number(param)) param = Math.round(param * 1e10) / 1e10; // round to nearest ten billionth - hides floating point errors var text_to_append = param.toString(); if (text_to_append) // not empty { this.text += text_to_append; this.text_changed = true; this.runtime.redraw = true; } }; Acts.prototype.SetScale = function(param) { if (param !== this.characterScale) { this.characterScale = param; this.text_changed = true; this.runtime.redraw = true; } }; Acts.prototype.SetCharacterSpacing = function(param) { if (param !== this.CharacterSpacing) { this.characterSpacing = param; this.text_changed = true; this.runtime.redraw = true; } }; Acts.prototype.SetLineHeight = function(param) { if (param !== this.lineHeight) { this.lineHeight = param; this.text_changed = true; this.runtime.redraw = true; } }; instanceProto.SetCharWidth = function(character,width) { var w = parseInt(width,10); if (this.characterWidthList[character] !== w) { this.characterWidthList[character] = w; this.text_changed = true; this.runtime.redraw = true; } }; Acts.prototype.SetCharacterWidth = function(characterSet,width) { if (characterSet !== "") { for(var c = 0; c < characterSet.length; c++) { this.SetCharWidth(characterSet.charAt(c),width); } } }; Acts.prototype.SetEffect = function (effect) { this.blend_mode = effect; this.compositeOp = cr.effectToCompositeOp(effect); cr.setGLBlend(this, effect, this.runtime.gl); this.runtime.redraw = true; }; Acts.prototype.SetHAlign = function (a) { this.halign = a / 2.0; this.text_changed = true; this.runtime.redraw = true; }; Acts.prototype.SetVAlign = function (a) { this.valign = a / 2.0; this.text_changed = true; this.runtime.redraw = true; }; pluginProto.acts = new Acts(); function Exps() {} Exps.prototype.CharacterWidth = function(ret,character) { ret.set_int(this.getCharacterWidth(character)); }; Exps.prototype.CharacterHeight = function(ret) { ret.set_int(this.characterHeight); }; Exps.prototype.CharacterScale = function(ret) { ret.set_float(this.characterScale); }; Exps.prototype.CharacterSpacing = function(ret) { ret.set_int(this.characterSpacing); }; Exps.prototype.LineHeight = function(ret) { ret.set_int(this.lineHeight); }; Exps.prototype.Text = function(ret) { ret.set_string(this.text); }; Exps.prototype.TextWidth = function (ret) { this.rebuildText(); ret.set_float(this.textWidth); }; Exps.prototype.TextHeight = function (ret) { this.rebuildText(); ret.set_float(this.textHeight); }; pluginProto.exps = new Exps(); }()); ; ; cr.plugins_.Spriter = function(runtime) { this.runtime = runtime; }; (function () { var pluginProto = cr.plugins_.Spriter.prototype; pluginProto.Type = function(plugin) { this.plugin = plugin; this.runtime = plugin.runtime; }; var typeProto = pluginProto.Type.prototype; function frame_getDataUri() { if (this.datauri.length === 0) { var tmpcanvas = document.createElement("canvas"); tmpcanvas.width = this.width; tmpcanvas.height = this.height; var tmpctx = tmpcanvas.getContext("2d"); if (this.spritesheeted) { tmpctx.drawImage(this.texture_img, this.offx, this.offy, this.width, this.height, 0, 0, this.width, this.height); } else { tmpctx.drawImage(this.texture_img, 0, 0, this.width, this.height); } this.datauri = tmpcanvas.toDataURL("image/png"); } return this.datauri; }; typeProto.onCreate = function() { this.doGetFromPreload=false; this.scmlFiles={}; this.scmlReserved={}; this.scmlInstsToNotify={}; this.objectArrays=[]; this.boneWidthArrays=[]; if (this.is_family) return; var i, leni, j, lenj; var anim, frame, animobj, frameobj, wt, uv; this.all_frames = []; this.has_loaded_textures = false; if(this.animations) { for (i = 0, leni = this.animations.length; i < leni; i++) { anim = this.animations[i]; animobj = {}; animobj.name = anim[0]; animobj.speed = anim[1]; animobj.loop = anim[2]; animobj.repeatcount = anim[3]; animobj.repeatto = anim[4]; animobj.pingpong = anim[5]; animobj.sid = anim[6]; animobj.frames = []; for (j = 0, lenj = anim[7].length; j < lenj; j++) { frame = anim[7][j]; frameobj = {}; frameobj.texture_file = frame[0]; frameobj.texture_filesize = frame[1]; frameobj.offx = frame[2]; frameobj.offy = frame[3]; frameobj.width = frame[4]; frameobj.height = frame[5]; frameobj.duration = frame[6]; frameobj.hotspotX = frame[7]; frameobj.hotspotY = frame[8]; frameobj.image_points = frame[9]; frameobj.poly_pts = frame[10]; frameobj.pixelformat = frame[11]; frameobj.spritesheeted = (frameobj.width !== 0); frameobj.datauri = ""; // generated on demand and cached frameobj.getDataUri = frame_getDataUri; uv = {}; uv.left = 0; uv.top = 0; uv.right = 1; uv.bottom = 1; frameobj.sheetTex = uv; frameobj.webGL_texture = null; wt = this.runtime.findWaitingTexture(frame[0]); if (wt) { frameobj.texture_img = wt; } else { frameobj.texture_img = new Image(); frameobj.texture_img.cr_src = frame[0]; frameobj.texture_img.cr_filesize = frame[1]; frameobj.texture_img.c2webGL_texture = null; this.runtime.waitForImageLoad(frameobj.texture_img, frame[0]); } cr.seal(frameobj); animobj.frames.push(frameobj); this.all_frames.push(frameobj); } cr.seal(animobj); this.animations[i] = animobj; // swap array data for object } } }; pluginProto.Instance = function(type) { this.type = type; this.runtime = type.runtime; this.lastData = ""; this.progress = 0; this.entity = 0; this.entities = []; this.currentSpriterTime = 0; this.currentAdjustedTime = 0; this.secondTime = 0; this.start_time = cr.performance_now(); this.lastKnownTime = this.getNowTime(); this.drawSelf=false; this.ignoreGlobalTimeScale=false; }; var instanceProto = pluginProto.Instance.prototype; instanceProto.setEntitiesToOtherEntities = function(otherEntities) { var NO_INDEX=-1; var entityTags = otherEntities; var att=0; for (var e = 0; e < entityTags.length; e++) { var entityTag=entityTags[e]; att=entityTag; var entity = new SpriterEntity(); att=entityTag; entity.name=att.name; var animationTags = entityTag.animations; for (var a = 0; a < animationTags.length; a++) { var animationTag = animationTags[a]; att=animationTag; var animation = new SpriterAnimation(); animation.name = att.name; animation.length = att.length; animation.looping = att.looping; animation.loopTo = att.loopTo; animation.l = att.l; animation.t = att.t; animation.r = att.r; animation.b = att.b; animation.meta=att.meta; var mainlineTag = animationTag.mainlineKeys; var mainline = new SpriterTimeline(); var keyTags = mainlineTag; for (var k = 0; k-1) { this.properties[0]=this.properties[0].replace(".scml",".scon"); } if((!this.getCharacterFromPreload())&&this.properties[0].length>0) { var self=this; var request = null; var doErrorFunc = function () { }; var errorFunc = function () { }; var progressFunc = function (e) { }; this.type.scmlReserved[this.properties[0]]=this; request = new XMLHttpRequest(); var isNodeWebkit=this.runtime.isNodeWebkit; request.onreadystatechange = function() { if (request.readyState === 4&&!self.isDestroyed) { if (request.status >= 400) { ; } else { request.responseText.replace(/\r\n/g, "\n");// fix windows style line endings self.doRequest(JSON.parse(request.responseText)); if(self.startingEntName) { self.setEntTo(self.startingEntName); } if(self.startingAnimName) { self.setAnimTo(self.startingAnimName); } if(self.startingLoopType&&self.currentAnimation) { self.currentAnimation.looping=self.startingLoopType; } } } }; request.onerror = errorFunc; request.ontimeout = errorFunc; request.onabort = errorFunc; request["onprogress"] = progressFunc; request.open("GET", this.properties[0]); request.send(); } this.force=false; this.inAnimTrigger=false; this.changeAnimTo=null; this.opacity=clamp(0.0,1.0,this.properties[3]/100.0); }; instanceProto.onDestroy = function () { this.isDestroyed=true; }; instanceProto.getVarDefsByName = function (objName) { for(var o=0;ohigh) { return high; } if(val=0) { return n; } else { return 0-n; } } function solveCurveX(ax,bx,cx,x,epsilon) { var t0; var t1; var t2; var x2; var d2; var i; for(t2=x, i=0; i<8; i++) { x2=sampleCurve(ax,bx,cx,t2)-x; if(fabs(x2)t1) { return t1; } while(t0x2) { t0=t2; } else { t1=t2; } t2=(t1-t0)*.5+t0; } return t2; // Failure. } function CubicBezierAtTime(t,p1x,p1y,p2x,p2y,duration) { var ax=0; var bx=0; var cx=0; var ay=0; var by=0; var cy=0; cx=3.0*p1x; bx=3.0*(p2x-p1x)-cx; ax=1.0-cx-bx; cy=3.0*p1y; by=3.0*(p2y-p1y)-cy; ay=1.0-cy-by; return solve(ax,bx,cx,ay,by,cy,t, solveEpsilon(duration)); } function getT(a,b,x) { if(a===b) { return 0; } return (x-a)/(b-a); } function qerp(a,b,c,t) { return cr.lerp(cr.lerp(a,b,t),cr.lerp(b,c,t),t); } function cerp(a,b,c,d,t) { return cr.lerp(qerp(a,b,c,t),qerp(b,c,d,t),t); } function quartic(a,b,c,d,e,t) { return cr.lerp(cerp(a,b,c,d,t),cerp(b,c,d,e,t),t); } function quintic(a,b,c,d,e,f,t) { return cr.lerp(quartic(a,b,c,d,e,t),quartic(b,c,d,e,f,t),t); } function trueT(key,t) { switch(key.curveType) { case "linear": return t; case "quadratic": return qerp(0,key.c1,1,t); case "cubic": return cerp(0,key.c1,key.c2,1,t); case "quartic": return quartic(0,key.c1,key.c2,key.c3,1,t); case "quintic": return quintic(key.c1,key.c2,key.c3,key.c4,t); case "bezier": return CubicBezierAtTime(t,key.c1,key.c2,key.c3,key.c4,1.0); case "instant": if(t>=1) { return 1; } else { return 0; } } return 0; } function TweenedSpriterObject(a,b,t,spin,wFactor,hFactor) { wFactor = typeof wFactor !== 'undefined' ? wFactor : 1; hFactor = typeof hFactor !== 'undefined' ? hFactor : 1; var newObj=new SpriterObject(); newObj.type = a.type; newObj.x = cr.lerp(a.x,b.x,t); newObj.y = cr.lerp(a.y,b.y,t); newObj.angle = anglelerp2(a.angle,b.angle,t,spin); newObj.a = cr.lerp(a.a,b.a,t); newObj.xScale = cr.lerp(a.xScale,b.xScale,t); newObj.yScale = cr.lerp(a.yScale,b.yScale,t); newObj.pivotX = a.pivotX;//cr.lerp(a.pivotX,b.pivotX,t); newObj.pivotY = a.pivotY;//cr.lerp(a.pivotY,b.pivotY,t); newObj.defaultPivot = a.defaultPivot; newObj.frame = a.frame; newObj.entity = a.entity; newObj.animation = a.animation; newObj.t = cr.lerp(a.t,b.t,t); newObj.storedFrame=a.storedFrame; return newObj; } function TweenedSpriterSound(a,b,t) { var newSound=new SpriterSound(); newSound.trigger = a.trigger; newSound.volume = cr.lerp(a.volume,b.volume,t); newSound.panning = cr.lerp(a.panning,b.panning,t); newSound.name =a.name; return newSound; } function SpriterObjectRef() { this.type = "reference"; this.timeline = 0; this.key = 0; this.parent = -1; } function SpriterFolder() { this.files = []; } function VarDef() { this.name = ""; this.type = ""; this.def = ""; } function TagLine() { this.keys=[]; this.lastTagIndex=0; this.currentTags=[]; } function MetaData() { this.varlines = []; this.tagline = new TagLine(); } function VarLine() { this.varDef = {}; this.defIndex = 0; this.keys = []; this.lastTagIndex=0; this.currentVal=0; } function EventLine() { this.name=""; this.keys=[]; this.meta = new MetaData(); } function SpriterFile() { this.fileName=""; this.pivotX=0; this.pivotY=0; this.w=1; this.h=1; this.atlasX=0; this.atlasY=0; this.atlasXOff=0; this.atlasYOff=0; this.atlasW=0; this.atlasH=0; this.atlasRotated=false; } function SetSpriteAnimFrame(sprite,framenumber,c2Object) { if(c2Object&&c2Object.appliedMap[framenumber]!==undefined) { if(c2Object.appliedMap[framenumber]===-1) { if(sprite) { sprite.visible=false; } framenumber=-1; } else { framenumber=c2Object.appliedMap[framenumber]; } } if(sprite) { sprite.changeAnimFrame = framenumber; if (!sprite.isTicking) { sprite.runtime.tickMe(sprite); sprite.isTicking = true; } if (!sprite.inAnimTrigger) { sprite.doChangeAnimFrame(); } } return framenumber; } function anglelerp(a, b, x) { var diff = cr.angleDiff(a, b); if (cr.angleClockwise(b, a)) { return (a + diff * x); } else { return (a - diff * x); } } function anglelerp2(a, b, x, spin) { if(spin===0) { return a; } var diff = cr.angleDiff(a, b); if (spin==-1) { return (a + diff * x); } else { return (a - diff * x); } } function findInArray(item,arr) { for(var i=0;ilayer.viewRight+this.rightBuffer) { return true; } if(this.ylayer.viewBottom+this.bottomBuffer) { return true; } } return false; } instanceProto.MoveToLayer = function (inst,layerMove) { if (!layerMove || layerMove == inst.layer) { return; } cr.arrayRemove(inst.layer.instances, inst.get_zindex()); inst.layer.setZIndicesStaleFrom(0); inst.layer = layerMove; inst.zindex = layerMove.instances.length; layerMove.instances.push(inst); inst.runtime.redraw = true; }; instanceProto.animationFinish = function (reverse) { this.animTriggerName = this.currentAnimation.name; var animTrigger=this.inAnimTrigger; if(this.inAnimTrigger===false) { this.inAnimTrigger = true; this.runtime.trigger(cr.plugins_.Spriter.prototype.cnds.OnAnyAnimFinished, this); this.runtime.trigger(cr.plugins_.Spriter.prototype.cnds.OnAnimFinished, this); this.inAnimTrigger = false; } }; instanceProto.clearAnimationState = function() { var anim=this.currentAnimation; if(anim) { for(var t=0;t0) { this.currentSpriterTime=0; } else { this.currentSpriterTime=this.currentAnimation.length; } this.lastKnownTime=this.getNowTime(); } else if (startFrom==2)//play from current time ratio { this.currentSpriterTime=this.currentAnimation.length*ratio; this.lastKnownTime=this.getNowTime(); } this.width = (this.currentAnimation.r-this.currentAnimation.l)*this.scaleRatio; this.height = (this.currentAnimation.b-this.currentAnimation.t)*this.scaleRatio; this.hotspotX = -(this.xFlip?(-this.currentAnimation.r):this.currentAnimation.l)/this.width*this.scaleRatio; this.hotspotY = -(this.yFlip?(-this.this.currentAnimation.b):this.currentAnimation.t)/this.height*this.scaleRatio; this.set_bbox_changed(); } }; instanceProto.endBlendAndSwap = function() { if(this.secondAnimation) { this.blendEndTime=0; this.blendStartTime=0; this.animBlend=0; this.blendPoseTime=0; if(this.changeToStartFrom===BLENDTOSTART) { this.currentSpriterTime=0; } this.currentSpriterTime=this.secondAnimation.localTime;//cr.lerp(0,this.secondAnimation.length,getT(0,this.currentAnimation.length,this.currentSpriterTime)); this.changeAnimTo=null; this.currentAnimation=this.secondAnimation; this.secondAnimation=null; this.changeToStartFrom=1;//play from current time } }; instanceProto.tickCurrentAnimationTime = function() { var lastKnownTime=this.lastKnownTime; var nowTime=this.getNowTime(); this.lastKnownTime=nowTime; var lastSpriterTime=this.currentSpriterTime; var cur_timescale=this.ignoreGlobalTimeScale?1:this.runtime.timescale; var animation=this.currentAnimation; if (this.my_timescale !== -1.0) { cur_timescale=this.my_timescale; } if(this.animPlaying) { this.currentSpriterTime+=(this.getNowTime()-lastKnownTime)*1000*this.speedRatio*cur_timescale; } var playTo=this.playTo; var animFinished=false; if(playTo>=0) { if(this.animPlaying) { if(((lastSpriterTime-playTo)*(this.currentSpriterTime-playTo))<0) { this.animPlaying=false; this.currentSpriterTime=this.playTo; this.playTo=-1; animFinished=true; } } } else { if(this.speedRatio>=0) { if(this.currentSpriterTime>=animation.length) { if(this.changeToStartFrom===BLENDTOSTART&&this.secondAnimation&&this.blendEndTime>0) { } else { if(animation.looping=="false") { this.currentSpriterTime=animation.length; this.animPlaying=false; } animFinished=true; } } } else { if(this.speedRatio<0) { if(this.currentSpriterTime<0) { if(this.changeToStartFrom===BLENDTOSTART&&this.secondAnimation&&this.blendEndTime>0) { } else { if(animation.looping=="false") { this.currentSpriterTime=0; this.animPlaying=false; } animFinished=true; } } } } } animation=this.currentAnimation; while(this.currentSpriterTime<0) { this.currentSpriterTime+=animation.length; } if(this.currentSpriterTime!==animation.length) { this.currentSpriterTime%=animation.length; } if(this.secondAnimation) { if(this.changeToStartFrom===BLENDTOSTART) { this.secondAnimation.localTime=0; } else { this.secondAnimation.localTime=cr.lerp(0,this.secondAnimation.length,getT(0,this.currentAnimation.length,this.currentSpriterTime)); } } var blendEndTime=this.blendEndTime; if(blendEndTime>0) { if(blendEndTime<=nowTime) { this.endBlendAndSwap(); } else { this.animBlend=getT(this.blendStartTime,blendEndTime,this.lastKnownTime); } } return animFinished; }; instanceProto.setMainlineKeyByTime = function(animation) { animation=(typeof animation!=='undefined')?animation:this.currentAnimation; if(animation) { var currentTime=0; if(animation===this.currentAnimation) { if(this.changeToStartFrom===BLENDTOSTART) { currentTime=this.blendPoseTime; } else { currentTime=this.currentSpriterTime; } } else { currentTime=animation.localTime; } var mainKeys=animation.mainlineKeys; animation.cur_frame=mainKeys.length; var secondTime=animation.length; for (var k=1;k= animation.mainlineKeys.length) { animation.cur_frame = animation.mainlineKeys.length - 1; } var mainKey=mainKeys[animation.cur_frame]; if(mainKey) { firstTime=mainKey.time; if(animation===this.currentAnimation) { var t=getT(firstTime,secondTime,this.currentSpriterTime); this.currentAdjustedTime=cr.lerp(firstTime,secondTime,trueT(mainKey,t)); } else { var t=getT(firstTime,secondTime,animation.localTime); if(this.changeToStartFrom===BLENDTOSTART) { animation.localTime=0; } else { animation.localTime=cr.lerp(firstTime,secondTime,trueT(mainKey,t)); } } } } }; instanceProto.doSecondAnimation = function() { return this.animBlend!==0&&this.secondAnimation; } function shortestSpin(a,b) { if(a===b) return 0; var pi=3.141592653589793; var rad=pi*2; while(b-a<-pi) { a-=rad; } while(b-a>pi) { b-=rad; } return b>a?-1:1; } instanceProto.tweenBone = function(bone, tweenedBones, animation, bones, currentIndex, currentTime, nextTime, key) { var nextBone = null; var nextFrame = null; var timelineIndex; var parent=bone.parent; if (bone.type == "reference") { var refTimeline = animation.timelines[bone.timeline]; var timelineName=refTimeline.name; timelineIndex=bone.timeline; var refKey = refTimeline.keys[bone.key]; var refKeyIndex = bone.key; lastTime = refKey.time; var nextFrame = null; var keysLength = refTimeline.keys.length; bone = refKey.bones[0]; if(keysLength>1) { if(refKeyIndex+1>=keysLength&&animation.looping=="true") { nextFrame=refTimeline.keys[0]; nextTime=nextFrame.time; if(currentTime>lastTime) { nextTime+=animation.length; } nextBone=nextFrame.bones[0]; } else if(refKeyIndex+1lastTime) { t=(currentTime-lastTime)/(nextTime-lastTime); } t=trueT(refKey,t); tweenedBones[currentIndex]=TweenedSpriterObject(bone,nextBone,t,refKey.spin); } else { tweenedBones[currentIndex]=CloneObject(bone); } refTimeline.currentMappedState=CloneObject(tweenedBones[currentIndex]); if(animation===this.currentAnimation) { if(this.animBlend!==0&&this.secondAnimation) { var secondTimeline=this.timelineFromName(refTimeline.name,this.secondAnimation); if(secondTimeline) { var secondBone=secondTimeline.currentObjectState; if(secondBone) { var firstBone=tweenedBones[currentIndex]; tweenedBones[currentIndex]=TweenedSpriterObject(firstBone,secondBone,this.animBlend,shortestSpin(firstBone.angle,secondBone.angle)); } } } } if(parent>-1) { if(animation===this.currentAnimation) { flipMe=tweenedBones[parent].xScale*tweenedBones[parent].yScale; } parentBone=tweenedBones[parent]; } else { if(animation===this.currentAnimation) { tweenedBones[currentIndex].x*=mirror_factor*this.scaleRatio; tweenedBones[currentIndex].y*=flip_factor*this.scaleRatio; tweenedBones[currentIndex].xScale*=mirror_factor*this.scaleRatio; tweenedBones[currentIndex].yScale*=flip_factor*this.scaleRatio; parentBone=this.objFromInst(this); parentBone.xScale*=this.subEntScaleX; parentBone.yScale*=this.subEntScaleY; flipMe=mirror_factor*flip_factor; } } if(animation===this.currentAnimation) { tweenedBones[currentIndex]=this.mapObjToObj(parentBone,tweenedBones[currentIndex],flipMe); } var overrideComponents=this.objectOverrides[timelineName]; if (typeof overrideComponents !== "undefined") { for(var component in overrideComponents) { switch(component) { case COMPONENTANGLE: tweenedBones[currentIndex].angle=cr.to_radians(overrideComponents[component]); this.force=true; break; case COMPONENTX: tweenedBones[currentIndex].x=overrideComponents[component]; this.force=true; break; case COMPONENTY: tweenedBones[currentIndex].y=overrideComponents[component]; this.force=true; break; case COMPONENTSCALEX: tweenedBones[currentIndex].xScale=overrideComponents[component]; this.force=true; break; case COMPONENTSCALEY: tweenedBones[currentIndex].yScale=overrideComponents[component]; this.force=true; break; default: break; } } } var ikOverride=this.boneIkOverrides[timelineName]; if (typeof ikOverride !== "undefined") { var tweenedChildBone={}; var childRefTimeline={}; var childTimelineName=""; for(var i = currentIndex+1; i < key.bones.length; i++) { var childBone = key.bones[i]; childRefTimeline = animation.timelines[childBone.timeline]; childTimelineName=childRefTimeline.name; if(childTimelineName===ikOverride.childBone) { this.tweenBone(childBone, tweenedBones, animation, bones, i, currentTime, nextTime, key); tweenedChildBone=tweenedBones[i]; this.force=true; break; } } childRefTimeline.currentObjectState=this.applyIk(ikOverride.targetX, ikOverride.targetY, ikOverride.additionalLength, tweenedBones[currentIndex], childRefTimeline.currentObjectState, childRefTimeline.currentMappedState, this.boneWidthArray[childTimelineName], currentTime, nextTime, key); tweenedBones[i]=childRefTimeline.currentObjectState; } refTimeline.currentObjectState=CloneObject(tweenedBones[currentIndex]); } } instanceProto.currentTweenedBones = function(animation) { var tweenedBones = []; animation = (typeof animation !== 'undefined') ? animation : this.currentAnimation; var key = animation.mainlineKeys[animation.cur_frame]; var nextTime = 0; var currentTime=0; this.clearAnimationState(); if(animation===this.currentAnimation) { if(this.changeToStartFrom===BLENDTOSTART) { currentTime=this.blendPoseTime; } else { currentTime=this.currentAdjustedTime; } } else { currentTime=animation.localTime; } for(var i = 0; i < key.bones.length; i++) { var bone = key.bones[i]; if(!tweenedBones[i]) { this.tweenBone(bone, tweenedBones, animation, key.bones, i, currentTime, nextTime, key); } } return tweenedBones; }; instanceProto.tick = function() { if(this.doGetFromPreload) { this.runtime.trigger(cr.plugins_.Spriter.prototype.cnds.readyForSetup, this); this.doGetFromPreload = false; } this.objectOverrides={}; this.boneIkOverrides={}; } instanceProto.tick2 = function(ticklessRefresh) { if(this.secondAnimation===this.currentAnimation) { this.blendStartTime=0; this.blendEndTime=0; this.blendPoseTime=0; this.secondAnimation=null; this.changeAnimTo=0; if(this.changeToStartFrom===BLENDTOSTART) { this.changeToStartFrom=0; } else if(this.changeToStartFrom===BLENDATCURRENTTIMERATIO) { this.changeToStartFrom=1; } } if(this.changeAnimTo&&!this.inAnimTrigger) { this.doAnimChange(); } var animation = this.currentAnimation; if (!animation||this.inAnimTrigger) { return; } var changed=null; if(!this.animPlaying) { if(!this.lastKnownInstDataAsObj||!this.instsEqual(this.lastKnownInstDataAsObj,this)) { changed=true; this.lastKnownInstDataAsObj=this.objFromInst(this); } else { var currZ=findInArray(this,this.layer.instances); if(currZ!==this.lastZ) { changed=true; this.lastZ=currZ; } } } if(!changed&&this.force) { changed=true; } this.force=false; var pauseAllButSound=false; var pauseAll=false; if(this.pauseWhenOutsideBuffer!=PAUSENEVER) { var outsideBuffer=this.isOutsideViewportBox(); if(outsideBuffer) { if(this.pauseWhenOutsideBuffer==PAUSEALLOUTSIDEBUFFER) { pauseAll=true; } else if(this.pauseWhenOutsideBuffer==PAUSEALLBUTSOUNDOUTSIDEBUFFER) { pauseAllButSound=true; } this.setAllInvisible(); } } if(this.animPlaying||changed||ticklessRefresh) { if(this.animPlaying&&!ticklessRefresh) { var animFinished=this.tickCurrentAnimationTime(); if(animFinished) { this.animationFinish(this.speedRatio<0); if(this.changeAnimTo&&!this.inAnimTrigger&&!this.animPlaying) { this.tick2(); return; } } } } else { return; } if(pauseAll) { return; } animation=this.currentAnimation; var c2ObjectArray=this.c2ObjectArray; this.setAllCollisionsAndVisibility(false); this.setMainlineKeyByTime(); this.runtime.redraw = true; if (!animation.mainlineKeys[animation.cur_frame]) { return; } if(!pauseAllButSound) { if(this.animBlend!==0&&this.secondAnimation) { if(this.changeToStartFrom===BLENDTOSTART) { this.secondAnimation.localTime=0; } else { this.secondAnimation.localTime=(this.currentSpriterTime/this.currentAnimation.length)*this.secondAnimation.length; } this.setMainlineKeyByTime(this.secondAnimation); var secondTweenedBones=this.currentTweenedBones(this.secondAnimation); this.animateCharacter(secondTweenedBones,this.secondAnimation,false); } var tweenedBones = this.currentTweenedBones(); this.animateCharacter(tweenedBones); } if(this.animPlaying) { this.animateSounds(); this.animateEvents(); this.animateMeta(animation.meta); } for(var i = 0; i < this.objectsToSet.length; i++) { var currentObjInstruction = this.objectsToSet[i]; var timeline=this.timelineFromName(currentObjInstruction.objectName); if(timeline && timeline.currentObjectState) { var setType = currentObjInstruction.setType; var objState = timeline.currentObjectState; var c2Obj=currentObjInstruction.c2Object.getFirstPicked(); if(c2Obj) { if(setType === 0 || setType === 1) { c2Obj.angle = objState.angle; } if(setType === 0 || setType === 2) { c2Obj.x = objState.x; c2Obj.y = objState.y; } c2Obj.set_bbox_changed(); } } } this.objectsToSet = []; }; instanceProto.animateCharacter = function(tweenedBones,animation,applyToInstances) { animation = (typeof animation !== 'undefined') ? animation : this.currentAnimation; if(!animation) { return; } var cur_frame = animation.cur_frame; var object; var objectRef; var nextObject = null; var lastTime = 0; var nextTime = 0; var myx = 0; var myy = 0; var w = 0; var h = 0; var layer=this.layer; var entity = this.entity; var zIndex=this.get_zindex(); applyToInstances = (typeof applyToInstances !== 'undefined') ? applyToInstances : true; var key = animation.mainlineKeys[animation.cur_frame]; var refKey; var instances=layer.instances; var currentTime=0; if(animation===this.currentAnimation) { if(this.changeToStartFrom===BLENDTOSTART) { currentTime=this.blendPoseTime; } else { currentTime=this.currentAdjustedTime; } } else { currentTime=animation.localTime; } if(applyToInstances&&!this.drawSelf) { var zOrder=[]; for(var i = 0; i < key.objects.length; i++) { object = key.objects[i]; if (object.type == "reference") { var refTimeline = animation.timelines[object.timeline]; var c2Obj=refTimeline.c2Object; if(c2Obj) { var inst=c2Obj.inst; if(inst) { var currZ=findInArray(inst,instances); if(currZ>=1&&currZ<=zIndex) { instances.splice(currZ,1); zIndex--; } } } } } var tempZ=findInArray(this,instances); if(zIndex!=tempZ) { instances.splice(tempZ,1); if(tempZ1) { if(refKeyIndex+1>=keysLength&&animation.looping=="true") { nextFrame=refTimeline.keys[0]; nextTime=nextFrame.time; if(currentTime>lastTime) { nextTime+=animation.length; } nextObject=nextFrame.objects[0]; } else if(refKeyIndex+10) { t=(currentTime-lastTime)/(nextTime-lastTime); } t=trueT(refKey,t); tweenedObj=TweenedSpriterObject(object,nextObject,t,refKey.spin); } else { tweenedObj=CloneObject(object); } if(applyToInstances&&c2Obj&&c2Obj.spriterType=="sprite") { tweenedObj.frame=SetSpriteAnimFrame(inst,object.frame,c2Obj); } if(inst) { var cur_frame = inst.curFrame; } var mirror_factor = (this.xFlip == 1 ? -1 : 1); var flip_factor = (this.yFlip == 1 ? -1 : 1); var parent=objectRef.parent; refTimeline.currentMappedState=CloneObject(tweenedObj); if(animation===this.currentAnimation) { if(this.animBlend!==0&&this.secondAnimation) { var secondTimeline=this.timelineFromName(refTimeline.name,this.secondAnimation); if(secondTimeline) { var secondBone=secondTimeline.currentObjectState; if(secondBone) { var firstBone=tweenedObj; tweenedObj=TweenedSpriterObject(firstBone,secondBone,this.animBlend,shortestSpin(firstBone.angle,secondBone.angle)); if(this.animBlend>0.5) { tweenedObj.frame=SetSpriteAnimFrame(inst,secondTimeline.currentObjectState.frame,c2Obj); } } } } } if(animation===this.currentAnimation) { var flip=false; if(parent>-1) { tweenedObj=this.mapObjToObj(tweenedBones[parent],tweenedObj,tweenedBones[parent].xScale*tweenedBones[parent].yScale); tweenedObj.xScale*=mirror_factor; tweenedObj.yScale*=flip_factor; flip=tweenedBones[parent].xScale<0; } else { tweenedObj.x*=mirror_factor*this.scaleRatio*this.subEntScaleX; tweenedObj.y*=flip_factor*this.scaleRatio*this.subEntScaleY; tweenedObj.xScale*=this.subEntScaleX; tweenedObj.yScale*=this.subEntScaleY; tweenedObj=this.mapObjToObj(this.objFromInst(this),tweenedObj,mirror_factor*flip_factor); flip=mirror_factor<0; } if(refTimeline.objectType==="point"&&flip) { tweenedObj.angle=tweenedObj.angle-cr.to_radians(180); } } var overrodeImage=false; if((inst||(this.drawSelf&&c2Obj))&&applyToInstances) { overrodeImage=this.applyObjToInst(tweenedObj,inst,parent>-1,c2Obj); } refTimeline.currentObjectState=tweenedObj; if(this.drawSelf&&parent==-1) { refTimeline.currentObjectState.xScale*=this.scaleRatio; refTimeline.currentObjectState.yScale*=this.scaleRatio; } if(!overrodeImage) { refTimeline.currentObjectState.frame=refTimeline.currentMappedState.frame; } if(this.drawSelf) { if(tweenedObj.defaultPivot) { var curPivot=c2Obj.obj.pivots[refTimeline.currentObjectState.frame]; if(!curPivot) { curPivot=c2Obj.obj.pivots[0]; } if(curPivot) { refTimeline.currentObjectState.pivotX=curPivot.x; refTimeline.currentObjectState.pivotY=curPivot.y; } } } this.animateMeta(refTimeline.meta); if(inst&&applyToInstances) { var instZOrder=zIndex+1+zCounter++; if(instances[instZOrder]!==inst) { var currInstanceZ=findInArray(inst,instances); if(currInstanceZ>=0) { instances.splice(currInstanceZ,1); } instances.splice(instZOrder,0,inst); inst.zorder=instZOrder; layer.setZIndicesStaleFrom(0); } } } } } }; instanceProto.animateSounds = function(anim) { anim = (typeof anim !== 'undefined') ? anim : this.currentAnimation; if(anim) { for(var s=0;s1) { if(curSoundFrame+1>=keysLength&&anim.looping=="true") { nextFrame=soundline.keys[0]; nextTime=nextFrame.time; if(this.currentSpriterTime>lastTime) { nextTime+=anim.length; } nextObject=nextFrame.objects[0]; } else if(curSoundFrame+10&&(time-lastTimetime+(anim.length-lastTime))) { if((time-lastTime>0)&&(time-lastTime0&&t<1) { this.playSound(soundline,soundToPlay.name); } } } } } } var tweenedSound; if(nextObject) { var t=0; var lastTime=curSoundKey.time; if(this.currentAdjustedTime1) { if(curEventFrame+1>=keysLength&&anim.looping=="true") { nextFrame=eventline.keys[0]; nextTime=nextFrame.time; if(this.currentSpriterTime>lastTime) { nextTime+=anim.length; } } else if(curEventFrame+10&&(time-lastTimetime+(anim.length-lastTime))) { if((time-lastTime>0)&&(time-lastTime0&&t<1) { this.playEvent(eventline,eventline.name); } } } } } } eventline.lastTimeEventCheck=this.currentAdjustedTime; } instanceProto.animateVar = function(varline,animLength,anim) { anim = (typeof anim !== 'undefined') ? anim : this.currentAnimation; var time=this.currentAdjustedTime; var varKeys=varline.keys; var firstVarFrame=-1; var secondVarFrame=-1; var firstTime=0; var secondTime=0; var firstVal=0; var secondVal=0; varline.lastTagIndex=0; varline.currentVal=varline.def.def; var type=varline.def.type; var firstKey; if(varKeys.length===0) { return; } if(varKeys.length>1) { for (var k=0;k0) { firstVarFrame=k-1; secondVarFrame=k; } else if(anim.looping==="true") { firstVarFrame=varKeys.length-1; secondVarFrame=0; } else { return; } if(firstVarFrame>-1) { firstKey=varKeys[firstVarFrame]; var secondKey=varKeys[secondVarFrame]; firstTime=firstKey.time; secondTime=secondKey.time; firstVal=firstKey.val; secondVal=secondKey.val; break; } } else if (k==varKeys.length-1) { if(anim.looping==="true") { firstVarFrame=k; secondVarFrame=0; firstKey=varKeys[firstVarFrame]; var secondKey=varKeys[secondVarFrame]; firstTime=firstKey.time; secondTime=secondKey.time; firstVal=firstKey.val; secondVal=secondKey.val; } else { varline.lastTagIndex=k; varline.currentVal=varKeys[k].val; return; } } } } else { varline.lastTagIndex=0; varline.currentVal=varKeys[0].val; return; } varline.lastTagIndex=firstVarFrame; if(type==="string") { varline.currentVal=firstVal; return; } if(firstTime>time) { firstTime-=anim.length; } if(secondTimethis.currentAdjustedTime&&anim.looping=="true") { curTagKey=tagKeys[tagKeys.length-1]; } var curTags=[]; for (var k=1;k 0 ? 1 : -1; var heightfactor = h > 0 ? 1 : -1; var mirror_factor = (this.xFlip == 1 ? -1 : 1); var flip_factor = (this.yFlip == 1 ? -1 : 1); var object = null; var animation = (typeof animation !== 'undefined') ? animation : this.currentAnimation; var cur_frame = animation.cur_frame; if(this.currentAnimation) { var key = this.currentAnimation.mainlineKeys[this.currentAnimation.cur_frame]; if(key) { for(var i = 0; i < key.objects.length; i++) { object = key.objects[i]; if (object.type == "reference") { var refTimeline = animation.timelines[object.timeline]; var objState = refTimeline.currentObjectState; if(objState&&typeof objState.frame !== 'undefined'&&objState.frame>-1) { var obj=refTimeline.object; if(obj) { var atlasInfo=obj.imageSizes[objState.frame]; var angle = objState.angle; var drawx = 0; var drawy = 0; ctx.save(); ctx.translate(objState.x,objState.y); if (widthfactor !== 1 || heightfactor !== 1) { ctx.scale(widthfactor, heightfactor); } if (mirror_factor !== 1 || flip_factor !== 1) { ctx.scale(mirror_factor, flip_factor); } var absPivotX=objState.pivotX*atlasInfo.w; drawx = atlasInfo.atlasXOff-absPivotX; if(atlasInfo.atlasRotated) { var reverseAbsPivotY=(1.0-objState.pivotY)*atlasInfo.h; var reverseXOff=atlasInfo.h-(atlasInfo.atlasYOff+atlasInfo.atlasH); angle-=cr.to_radians(90); drawy=reverseXOff-reverseAbsPivotY; } else { var absPivotY=objState.pivotY*atlasInfo.h; drawy = atlasInfo.atlasYOff-absPivotY; } drawx*=objState.xScale; drawy*=objState.yScale; if(mirror_factor*flip_factor==-1) { if(atlasInfo.atlasRotated) { angle-=cr.to_radians(180); } angle*=-1; } ctx.rotate(angle * widthfactor * heightfactor); if(atlasInfo.atlasRotated) { ctx.drawImage(cur_image, atlasInfo.atlasX, atlasInfo.atlasY, atlasInfo.atlasH, atlasInfo.atlasW, drawy,drawx, atlasInfo.atlasH*this.scaleRatio, atlasInfo.atlasW*this.scaleRatio); } else { ctx.drawImage(cur_image, atlasInfo.atlasX, atlasInfo.atlasY, atlasInfo.atlasW, atlasInfo.atlasH, drawx,drawy, atlasInfo.atlasW*this.scaleRatio, atlasInfo.atlasH*this.scaleRatio); } ctx.restore(); } } } } } } }; instanceProto.drawGL = function(glw) { if(!this.drawSelf) { return; } glw.setOpacity(this.opacity); var cur_frame = this.type.animations[0].frames[0]; var cur_image = cur_frame.texture_img; var webGL_texture = this.runtime.glwrap.loadTexture(cur_image, false, this.runtime.linearSampling, cur_frame.pixelformat); glw.setTexture(webGL_texture); var mirror_factor = (this.xFlip == 1 ? -1 : 1); var flip_factor = (this.yFlip == 1 ? -1 : 1); var object = null; var uv = {}; uv.left = 0; uv.top = 0; uv.right = 1; uv.bottom = 1; var animation=this.currentAnimation; if(animation) { var key = animation.mainlineKeys[animation.cur_frame]; if(key) { for(var i = 0; i < key.objects.length; i++) { object = key.objects[i]; if (object.type == "reference") { var refTimeline = animation.timelines[object.timeline]; var objState = refTimeline.currentObjectState; if(objState&&typeof objState.frame !== 'undefined'&&objState.frame>-1) { var obj=refTimeline.object; if(obj) { var atlasInfo=obj.imageSizes[objState.frame]; var angle = objState.angle; if(mirror_factor*flip_factor==-1) { angle-=cr.to_radians(180); if(!atlasInfo.atlasRotated) { angle*=-1; angle=cr.to_radians(180)-angle; } } uv.left = (atlasInfo.atlasX)/cur_image.width; uv.top = (atlasInfo.atlasY)/cur_image.height; var w=0; var h=0; if(atlasInfo.atlasRotated) { angle-=cr.to_radians(90); w+=atlasInfo.atlasH; h+=atlasInfo.atlasW; } else { w+=atlasInfo.atlasW; h+=atlasInfo.atlasH; } uv.right = ((atlasInfo.atlasX)+w)/cur_image.width; uv.bottom = ((atlasInfo.atlasY)+h)/cur_image.height; if(mirror_factor==-1) { var temp=uv.left; uv.left=uv.right; uv.right=temp; } if(flip_factor==-1) { var temp=uv.top; uv.top=uv.bottom; uv.bottom=temp; } var cur_frame = this.curFrame; var bbox = new cr.rect(0, 0, 0, 0); var bquad = new cr.quad(); var absPivotX=(objState.pivotX*atlasInfo.w)*objState.xScale; var xOff=objState.xScale*atlasInfo.atlasXOff; var absPivotY=(objState.pivotY*atlasInfo.h)*objState.yScale; var yOff=objState.yScale*atlasInfo.atlasYOff; var reverseAbsPivotX=((1.0-objState.pivotX)*atlasInfo.w)*objState.xScale; var reverseXOff=objState.xScale*(atlasInfo.w-(atlasInfo.atlasXOff+atlasInfo.atlasW)); var reverseAbsPivotY=((1.0-objState.pivotY)*atlasInfo.h)*objState.yScale; var reverseYOff=objState.yScale*(atlasInfo.h-(atlasInfo.atlasYOff+atlasInfo.atlasH)); var offsetX=0; var offsetY=0; if(atlasInfo.atlasRotated) { bbox.set(objState.x,objState.y,objState.x+(atlasInfo.atlasH*objState.yScale),objState.y+(atlasInfo.atlasW*objState.xScale)); if(mirror_factor==-1) { offsetX=yOff-absPivotY; } else { offsetX=reverseYOff-reverseAbsPivotY; } if(flip_factor==-1) { offsetY=reverseXOff-reverseAbsPivotX; } else { offsetY=xOff-absPivotX; } } else { bbox.set(objState.x,objState.y,objState.x+(atlasInfo.atlasW*objState.xScale),objState.y+(atlasInfo.atlasH*objState.yScale)); if(mirror_factor==-1) { offsetX=reverseXOff-reverseAbsPivotX; } else { offsetX=xOff-absPivotX; } if(flip_factor==-1) { offsetY=reverseYOff-reverseAbsPivotY; } else { offsetY=yOff-absPivotY; } } bbox.offset(offsetX,offsetY); bbox.offset(-objState.x, -objState.y); // translate to origin bquad.set_from_rotated_rect(bbox, angle); // rotate around origin bquad.offset(objState.x, objState.y); // translate back to original position bquad.bounding_box(bbox); bbox.normalize(); var q = bquad; glw.setOpacity(this.opacity*objState.a); glw.quadTex(q.tlx, q.tly, q.trx, q.try_, q.brx, q.bry, q.blx, q.bly, uv); } } } } } } }; instanceProto.playSound = function(soundLine,name) { this.soundToTrigger=name; this.soundLineToTrigger=soundLine; this.runtime.trigger(cr.plugins_.Spriter.prototype.cnds.OnSoundTriggered, this); } instanceProto.playEvent = function(eventLine,name) { this.eventToTrigger=name; this.eventLineToTrigger=eventLine; this.runtime.trigger(cr.plugins_.Spriter.prototype.cnds.OnEventTriggered, this); } instanceProto.changeVolume = function(soundLine,newVolume) { if(soundLine.currentObjectState.volume!=newVolume) { soundLine.currentObjectState.volume=newVolume; this.soundToTrigger=""; this.soundLineToTrigger=soundLine; this.runtime.trigger(cr.plugins_.Spriter.prototype.cnds.OnSoundVolumeChangeTriggered, this); } } instanceProto.changePanning = function(soundLine,newPanning) { if(soundLine.currentObjectState.panning!=newPanning) { soundLine.currentObjectState.panning=newPanning; this.soundToTrigger=""; this.soundLineToTrigger=soundLine; this.runtime.trigger(cr.plugins_.Spriter.prototype.cnds.OnSoundPanningChangeTriggered, this); } } function findObjectItemInArray(name, objectArray, entityName) { for (var o = 0; o < objectArray.length; o++) { var obj=objectArray[o]; if (obj&&(obj.name===name||(obj.entityName===entityName&&obj.originalName===name))) { return o; } } return -1; } function objectFromArray(name, objectArray, entityName) { for (var o = 0; o < objectArray.length; o++) { var obj=objectArray[o]; if (obj&&(obj.name===name||(obj.entityName===entityName&&obj.originalName===name))) { return obj; } } } function SpriterObjectArrayItem(spritername, name, entityName, originalName, varDefs) { this.name = name; this.fullTypeName = spritername + "_" + name; this.spriterType = "sprite"; this.frames = []; this.pivots = []; this.imageSizes = []; this.atlasInfos = []; this.charMaps = []; this.width = 0; this.height = 0; this.entityName = entityName; this.originalName = originalName; this.varDefs = varDefs; } instanceProto.timelineFromName = function(name,anim) { anim = typeof anim !== 'undefined' ? anim : this.currentAnimation; if(anim) { for(var t=0;t-1) { charMap.newFrame=-1; if(typeof mapTag["target_folder"]!=="undefined"&&typeof mapTag["target_file"]!=="undefined") { charMap.newFrame=lastObj.frames.indexOf(this.folders[mapTag["target_folder"]].files[mapTag["target_file"]].fileName ); } if(!lastObj.charMaps[charMapTag["name"]]) { lastObj.charMaps[charMapTag["name"]]=[]; } lastObj.charMaps[charMapTag["name"]].push(charMap); } } } } } } } } } } } } return objectArray; }; instanceProto.generateTestC2ObjectArray = function(objectArray) { var c2Objects=[]; var types=this.runtime.types; for(var o = 0,len = objectArray.length; o0.5) { object.angle-=1; } object.angle*=3.141592653589793*2; if(objectTag.hasOwnProperty("scale_x")) { object.xScale = (att["scale_x"]); } if(objectTag.hasOwnProperty("scale_y")) { object.yScale = (att["scale_y"]); } if(objectTag.hasOwnProperty("entity")) { object.entity = (att["entity"]); } if(objectTag.hasOwnProperty("animation")) { object.animation = (att["animation"]); } if(objectTag.hasOwnProperty("t")) { object.t = (att["t"]); } if(objectTag.hasOwnProperty("pivot_x")) { object.pivotX = (att["pivot_x"]); } else if(object_type==="sprite") { var folders=this.folders; var folder=folders[folderIndex]; object.defaultPivot=true; if(folder) { var file=folder.files[fileIndex]; if(file) { object.pivotX=file.pivotX; } } } if(objectTag.hasOwnProperty("pivot_y")) { object.pivotY = 1-(att["pivot_y"]); } else if(object_type==="sprite") { var folders=this.folders; var folder=folders[folderIndex]; object.defaultPivot=true; if(folder) { var file=folder.files[fileIndex]; if(file) { object.pivotY=file.pivotY; } } } return object; }; instanceProto.soundFromTag = function(soundTag) { var sound = new SpriterSound(); if(soundTag["folder"]!==undefined&&soundTag["file"]!==undefined) { var file=this.folders[soundTag["folder"]].files[soundTag["file"]]; if(file) { sound.name=file.fileName; sound.name=sound.name.substr(0,sound.name.lastIndexOf(".")); sound.name=sound.name.substr(sound.name.lastIndexOf("/")+1,sound.name.length); } } if(soundTag.hasOwnProperty("trigger")) { sound.trigger=soundTag["trigger"]; } if(soundTag.hasOwnProperty("panning")) { sound.panning = soundTag["panning"]; } if(soundTag.hasOwnProperty("volume")) { sound.volume = soundTag["volume"]; } return sound; }; instanceProto.initDOMtoPairedObjects = function() { var entities=this.entities; for(var e=0;e0) { for(var s=0;sanimIndex) { this.playTo=-1; this.changeAnimTo=this.entity.animations[animIndex]; this.changeToStartFrom=2; var anim=this.currentAnimation; if(anim) { this.animPlaying=true; } this.runtime.tick2Me(this); } } instanceProto.setAnim = function (animName,startFrom,blendDuration) { var ratio=0; if((startFrom==1||startFrom==2)&&this.currentAnimation&&animName==this.currentAnimation.name) { return; } if(startFrom>PLAYFROMCURRENTTIMERATIO&&blendDuration>0) { var secondAnim=this.getAnimFromEntity(animName); if(secondAnim===this.secondAnimation&&this.blendEndTime>0) { return; } if(secondAnim===this.currentAnimation) { if(!this.secondAnimation) { this.blendStartTime=0; this.blendEndTime=0; this.blendPoseTime=0; this.secondAnimation=null; this.animBlend=0; this.changeAnimTo=null; return; } else { this.currentAnimation=this.secondAnimation; this.animBlend=1.0-this.animBlend; } } else { this.animBlend=0; } this.secondAnimation=secondAnim; this.blendStartTime=this.getNowTime(); this.blendPoseTime=0; if(startFrom===BLENDTOSTART&&this.currentAnimation.looping==="false") { } this.blendEndTime=this.blendStartTime+((blendDuration/1000)/(this.ignoreGlobalTimeScale?1:this.runtime.timescale)); } else { if(blendDuration<=0) { if(startFrom===BLENDATCURRENTTIMERATIO) { startFrom=2; } else if(startFrom==BLENDTOSTART) { startFrom=0; } } this.blendStartTime=0; this.blendEndTime=0; this.blendPoseTime=0; this.secondAnimation=null; } this.changeToStartFrom=startFrom; if(startFrom===BLENDTOSTART&&this.secondAnimation) { this.blendPoseTime=this.currentSpriterTime; this.secondAnimation.localTime=0; this.setMainlineKeyByTime(this.secondAnimation); var secondTweenedBones=this.currentTweenedBones(this.secondAnimation); this.animateCharacter(secondTweenedBones,this.secondAnimation,false); } this.setAnimTo(animName,false); var animPlaying=this.animPlaying; this.animPlaying=false; this.tick2(true); this.animPlaying=animPlaying; }; instanceProto.doRequest = function (json,url_, method_) { var self = this; var request = null; var errorFunc = function () { }; try { var data = json; self.loadSCML(data); self.type.scmlFiles[self.properties[0]]=self.entities; self.runtime.trigger(cr.plugins_.Spriter.prototype.cnds.readyForSetup, self); self.setAnimTo(self.properties[2],true); if(!self.currentAnimation&&self.entity&&self.entity.animations.length) { self.setAnimTo(self.entity.animations[0].name,true); } for(var i=0;idistanceAB+distanceBTarget) { var newAngle=(cr.to_radians(270)-(Math.atan2(parentBone.x-targetX,parentBone.y-targetY))); if(parentBone.scaleX<0) { newAngle=newAngle-cr.to_radians(180); } if(this.xFlip) { newAngle-=cr.to_radians(180); } parentBone.angle=newAngle; } else { var xDiff=parentBone.x-targetX; var yDiff=parentBone.y-targetY; var newAngle=Math.acos((((distanceAB*distanceAB) +(distanceATarget*distanceATarget) -(distanceBTarget*distanceBTarget)) /(2*distanceAB*distanceATarget))); var angleOffset=cr.to_radians(270)-Math.atan2(xDiff,yDiff); var childAngleOffset=(cr.to_radians(270)-Math.atan2(parentBone.x-childBoneAbs.x,parentBone.y-childBoneAbs.y))-parentBone.angle; if(childBoneLocal.angle>0) { ikReversal=true; } newAngle=angleOffset+(newAngle*(ikReversal?-1:1)*(parentBoneFactor?-1:1)); if(parentBone.scaleX<0) { childAngleOffset=childAngleOffset-cr.to_radians(180); } newAngle-=childAngleOffset; if(newAngle!=newAngle) { newAngle=parentBone.angle; } else { if(parentBone.scaleX<0) { newAngle=newAngle-cr.to_radians(180); } } parentBone.angle=newAngle; } childBoneAbs=this.mapObjToObj(parentBone,childBoneLocal,parentBone.xScale*parentBone.yScale); var newAngle=cr.to_radians(270)-Math.atan2(childBoneAbs.x-targetX,childBoneAbs.y-targetY); if(childBoneAbs.scaleX<0) { newAngle-=cr.to_radians(180); } if(this.xFlip) { newAngle-=cr.to_radians(180); } if(parentBoneFactor) { newAngle=cr.to_radians(360)-newAngle; newAngle*=-1; } childBoneAbs.angle=newAngle; return childBoneAbs; } instanceProto.applyObjToInst = function(obj,inst,dontApplyGlobalScale,c2Object) { var overrodeImage=false; var overrideComponents=this.objectOverrides[c2Object.obj.originalName]; if (typeof overrideComponents !== "undefined") { for(var component in overrideComponents) { switch(component) { case COMPONENTANGLE: obj.angle=cr.to_radians(overrideComponents[component]); this.force=true; break; case COMPONENTX: obj.x=overrideComponents[component]; this.force=true; break; case COMPONENTY: obj.y=overrideComponents[component]; this.force=true; break; case COMPONENTSCALEX: obj.xScale=overrideComponents[component]; this.force=true; break; case COMPONENTSCALEY: obj.yScale=overrideComponents[component]; this.force=true; break; case COMPONENTIMAGE: obj.frame=SetSpriteAnimFrame(inst,overrideComponents[component],c2Object); overrodeImage=true; this.force=true; break; case COMPONENTPIVOTX: obj.pivotX=overrideComponents[component]; this.force=true; break; case COMPONENTPIVOTY: obj.pivotY=overrideComponents[component]; this.force=true; break; case COMPONENTENTITY: obj.entity=overrideComponents[component]; this.force=true; break; case COMPONENTANIMATION: obj.animation=overrideComponents[component]; this.force=true; break; case COMPONENTTIMERATIO: obj.t=overrideComponents[component]; this.force=true; break; default: break; } } } if(this.drawSelf&&!c2Object.inst) { return overrodeImage; } inst.angle=obj.angle; inst.opacity=obj.a; var cur_frame = inst.curFrame; inst.hotspotX=0; inst.hotspotY=0; inst.x=obj.x; inst.y=obj.y; var trueW=inst.width; var trueH=inst.height; if(c2Object.obj.spriterType==="entity") { inst.subEntScaleX=obj.xScale; inst.subEntScaleY=obj.yScale; inst.setEntToIndex(obj.entity); if(inst.entity) { inst.setAnimToIndex(obj.animation); inst.setAnimTime(1,obj.t); } } if(c2Object.obj.imageSizes&&c2Object.obj.imageSizes.length>inst.cur_frame) { trueW=c2Object.obj.imageSizes[inst.cur_frame].w; trueH=c2Object.obj.imageSizes[inst.cur_frame].h; } var mirror_factor = (this.xFlip == 1 ? -1 : 1); var flip_factor = (this.yFlip == 1 ? -1 : 1); var new_width = (dontApplyGlobalScale?1:this.scaleRatio) * trueW * obj.xScale * mirror_factor; var new_height = (dontApplyGlobalScale?1:this.scaleRatio) * trueH * obj.yScale * flip_factor; if (inst.width !== new_width || inst.height !== new_height) { inst.width = new_width; inst.height = new_height; } var pivX=obj.pivotX; var pivY=obj.pivotY; if(obj.defaultPivot) { var curPivot=c2Object.obj.pivots[inst.cur_frame]; if(!curPivot) { curPivot=c2Object.obj.pivots[0]; } if(curPivot) { pivX=curPivot.x; pivY=curPivot.y; } } this.applyPivotToInst(inst,pivX,pivY,new_width,new_height); inst.set_bbox_changed(); return overrodeImage; }; instanceProto.setEntTo = function(entName) { var entities=this.entities; for(var e = 0,len=entities.length;e0) { this.associateAllTypes(); inst=c2Object.inst; } } else { inst.collisionsEnabled = newState; inst.visible=newState; } } } }; instanceProto.setAllInvisible = function() { var c2ObjectArray=this.c2ObjectArray; if(c2ObjectArray) { for(var o=0;o0) { return true; } var anim=this.currentAnimation; if(anim&&anim.name===name) { return true; } else { return false; } }; Cnds.prototype.CompareEntity = function (name) { var ent=this.entity; if(ent&&ent.name===name) { return true; } else { return false; } }; Cnds.prototype.AnimationPaused = function () { return !this.animPlaying; }; Cnds.prototype.AnimationLooping = function () { var anim=this.currentAnimation; if(anim&&anim.looping==="true") { return true; } else { return false; } }; Cnds.prototype.isMirrored = function () { return this.xFlip; }; Cnds.prototype.isFlipped = function () { return this.yFlip; }; pluginProto.cnds = new Cnds(); function Acts() {} Acts.prototype.setPlaybackSpeedRatio = function (newSpeed) { this.speedRatio=newSpeed; }; Acts.prototype.setVisible = function (visible) { if(visible===1) { this.visible=true; } else { this.visible=false; } }; Acts.prototype.setOpacity = function (newOpacity) { this.opacity=clamp(0.0,1.0,newOpacity/100.0); }; Acts.prototype.setAutomaticPausing = function (newPauseSetting,leftBuffer,rightBuffer,topBuffer,bottomBuffer) { this.pauseWhenOutsideBuffer=newPauseSetting; this.leftBuffer=leftBuffer; this.rightBuffer=rightBuffer; this.topBuffer=topBuffer; this.bottomBuffer=bottomBuffer; } Acts.prototype.setObjectScaleRatio = function (newScale,xFlip,yFlip) { this.scaleRatio=newScale; this.xFlip=xFlip; this.yFlip=yFlip; this.force=true; }; Acts.prototype.setObjectXFlip = function (xFlip) { this.xFlip=xFlip; this.force=true; }; Acts.prototype.setIgnoreGlobalTimeScale = function (ignore) { this.ignoreGlobalTimeScale=(ignore==1); } Acts.prototype.findSpriterObject = function (c2Object) { if(this.currentAnimation) { var timelines=this.currentAnimation.timelines; for(var t=0;tthis.currentSpriterTime) { forwardDistance=this.playTo-this.currentSpriterTime; backwardDistance=(this.currentAnimation.length-this.playTo)+this.currentSpriterTime; } else { forwardDistance=this.playTo+(this.currentAnimation.length-this.currentSpriterTime); backwardDistance=this.currentSpriterTime-this.playTo; } if(backwardDistance0) { if(this.currentSpriterTime==anim.length) { this.currentSpriterTime=0; } } else if(this.currentSpriterTime===0) { this.currentSpriterTime=this.currentAnimation.length; } } }; Acts.prototype.removeAllCharMaps = function () { var c2Objs=this.c2ObjectArray; for(var c=0;c=0) { if(this.playTo>this.currentSpriterTime) { return ret.set_float(this.playTo-this.currentSpriterTime); } else { return ret.set_float(this.playTo+(this.currentAnimation.length-this.currentSpriterTime)); } } else { if(this.playTo>this.currentSpriterTime) { return ret.set_float((this.currentAnimation.length-this.playTo)+this.currentSpriterTime); } else { return ret.set_float(this.currentSpriterTime-this.playTo); } } } else { return ret.set_float(Math.abs(this.playTo-this.currentSpriterTime)); } }; Exps.prototype.triggeredSound = function (ret) { ret.set_string(this.soundToTrigger); }; Exps.prototype.triggeredSoundTag = function (ret) { if(this.soundLineToTrigger) { ret.set_string(this.soundLineToTrigger.name); return; } ret.set_string(""); }; Exps.prototype.soundVolume = function (ret,soundTag) { var soundline=this.soundlineFromName(soundTag); if(soundline) { if(soundline.currentObjectState) { ret.set_float(soundline.currentObjectState.volume); return; } } ret.set_float(0); }; Exps.prototype.soundPanning = function (ret,soundTag) { var soundline=this.soundlineFromName(soundTag); if(soundline) { if(soundline.currentObjectState) { ret.set_float(soundline.currentObjectState.panning); return; } } ret.set_float(0); }; Exps.prototype.blendRatio = function (ret) { ret.set_float(this.animBlend); }; Exps.prototype.Opacity = function(ret) { ret.set_float(this.opacity*100.0); } Exps.prototype.BBoxLeft = function (ret) { this.update_bbox(); ret.set_float(this.bbox.left); }; Exps.prototype.BBoxTop = function (ret) { this.update_bbox(); ret.set_float(this.bbox.top); }; Exps.prototype.BBoxRight = function (ret) { this.update_bbox(); ret.set_float(this.bbox.right); }; Exps.prototype.BBoxBottom = function (ret) { this.update_bbox(); ret.set_float(this.bbox.bottom); }; Exps.prototype.foundObject = function (ret) { ret.set_string(this.lastFoundObject); }; pluginProto.exps = new Exps(); }()); ; ; cr.plugins_.Text = function(runtime) { this.runtime = runtime; }; (function () { var pluginProto = cr.plugins_.Text.prototype; pluginProto.onCreate = function () { pluginProto.acts.SetWidth = function (w) { if (this.width !== w) { this.width = w; this.text_changed = true; // also recalculate text wrapping this.set_bbox_changed(); } }; }; pluginProto.Type = function(plugin) { this.plugin = plugin; this.runtime = plugin.runtime; }; var typeProto = pluginProto.Type.prototype; typeProto.onCreate = function() { }; typeProto.onLostWebGLContext = function () { if (this.is_family) return; var i, len, inst; for (i = 0, len = this.instances.length; i < len; i++) { inst = this.instances[i]; inst.mycanvas = null; inst.myctx = null; inst.mytex = null; } }; pluginProto.Instance = function(type) { this.type = type; this.runtime = type.runtime; if (this.recycled) cr.clearArray(this.lines); else this.lines = []; // for word wrapping this.text_changed = true; }; var instanceProto = pluginProto.Instance.prototype; var requestedWebFonts = {}; // already requested web fonts have an entry here instanceProto.onCreate = function() { this.text = this.properties[0]; this.visible = (this.properties[1] === 0); // 0=visible, 1=invisible this.font = this.properties[2]; this.color = this.properties[3]; this.halign = this.properties[4]; // 0=left, 1=center, 2=right this.valign = this.properties[5]; // 0=top, 1=center, 2=bottom this.wrapbyword = (this.properties[7] === 0); // 0=word, 1=character this.lastwidth = this.width; this.lastwrapwidth = this.width; this.lastheight = this.height; this.line_height_offset = this.properties[8]; this.facename = ""; this.fontstyle = ""; this.ptSize = 0; this.textWidth = 0; this.textHeight = 0; this.parseFont(); this.mycanvas = null; this.myctx = null; this.mytex = null; this.need_text_redraw = false; this.last_render_tick = this.runtime.tickcount; if (this.recycled) this.rcTex.set(0, 0, 1, 1); else this.rcTex = new cr.rect(0, 0, 1, 1); if (this.runtime.glwrap) this.runtime.tickMe(this); ; }; instanceProto.parseFont = function () { var arr = this.font.split(" "); var i; for (i = 0; i < arr.length; i++) { if (arr[i].substr(arr[i].length - 2, 2) === "pt") { this.ptSize = parseInt(arr[i].substr(0, arr[i].length - 2)); this.pxHeight = Math.ceil((this.ptSize / 72.0) * 96.0) + 4; // assume 96dpi... if (i > 0) this.fontstyle = arr[i - 1]; this.facename = arr[i + 1]; for (i = i + 2; i < arr.length; i++) this.facename += " " + arr[i]; break; } } }; instanceProto.saveToJSON = function () { return { "t": this.text, "f": this.font, "c": this.color, "ha": this.halign, "va": this.valign, "wr": this.wrapbyword, "lho": this.line_height_offset, "fn": this.facename, "fs": this.fontstyle, "ps": this.ptSize, "pxh": this.pxHeight, "tw": this.textWidth, "th": this.textHeight, "lrt": this.last_render_tick }; }; instanceProto.loadFromJSON = function (o) { this.text = o["t"]; this.font = o["f"]; this.color = o["c"]; this.halign = o["ha"]; this.valign = o["va"]; this.wrapbyword = o["wr"]; this.line_height_offset = o["lho"]; this.facename = o["fn"]; this.fontstyle = o["fs"]; this.ptSize = o["ps"]; this.pxHeight = o["pxh"]; this.textWidth = o["tw"]; this.textHeight = o["th"]; this.last_render_tick = o["lrt"]; this.text_changed = true; this.lastwidth = this.width; this.lastwrapwidth = this.width; this.lastheight = this.height; }; instanceProto.tick = function () { if (this.runtime.glwrap && this.mytex && (this.runtime.tickcount - this.last_render_tick >= 300)) { var layer = this.layer; this.update_bbox(); var bbox = this.bbox; if (bbox.right < layer.viewLeft || bbox.bottom < layer.viewTop || bbox.left > layer.viewRight || bbox.top > layer.viewBottom) { this.runtime.glwrap.deleteTexture(this.mytex); this.mytex = null; this.myctx = null; this.mycanvas = null; } } }; instanceProto.onDestroy = function () { this.myctx = null; this.mycanvas = null; if (this.runtime.glwrap && this.mytex) this.runtime.glwrap.deleteTexture(this.mytex); this.mytex = null; }; instanceProto.updateFont = function () { this.font = this.fontstyle + " " + this.ptSize.toString() + "pt " + this.facename; this.text_changed = true; this.runtime.redraw = true; }; instanceProto.draw = function(ctx, glmode) { ctx.font = this.font; ctx.textBaseline = "top"; ctx.fillStyle = this.color; ctx.globalAlpha = glmode ? 1 : this.opacity; var myscale = 1; if (glmode) { myscale = Math.abs(this.layer.getScale()); ctx.save(); ctx.scale(myscale, myscale); } if (this.text_changed || this.width !== this.lastwrapwidth) { this.type.plugin.WordWrap(this.text, this.lines, ctx, this.width, this.wrapbyword); this.text_changed = false; this.lastwrapwidth = this.width; } this.update_bbox(); var penX = glmode ? 0 : this.bquad.tlx; var penY = glmode ? 0 : this.bquad.tly; if (this.runtime.pixel_rounding) { penX = (penX + 0.5) | 0; penY = (penY + 0.5) | 0; } if (this.angle !== 0 && !glmode) { ctx.save(); ctx.translate(penX, penY); ctx.rotate(this.angle); penX = 0; penY = 0; } var endY = penY + this.height; var line_height = this.pxHeight; line_height += this.line_height_offset; var drawX; var i; if (this.valign === 1) // center penY += Math.max(this.height / 2 - (this.lines.length * line_height) / 2, 0); else if (this.valign === 2) // bottom penY += Math.max(this.height - (this.lines.length * line_height) - 2, 0); for (i = 0; i < this.lines.length; i++) { drawX = penX; if (this.halign === 1) // center drawX = penX + (this.width - this.lines[i].width) / 2; else if (this.halign === 2) // right drawX = penX + (this.width - this.lines[i].width); ctx.fillText(this.lines[i].text, drawX, penY); penY += line_height; if (penY >= endY - line_height) break; } if (this.angle !== 0 || glmode) ctx.restore(); this.last_render_tick = this.runtime.tickcount; }; instanceProto.drawGL = function(glw) { if (this.width < 1 || this.height < 1) return; var need_redraw = this.text_changed || this.need_text_redraw; this.need_text_redraw = false; var layer_scale = this.layer.getScale(); var layer_angle = this.layer.getAngle(); var rcTex = this.rcTex; var floatscaledwidth = layer_scale * this.width; var floatscaledheight = layer_scale * this.height; var scaledwidth = Math.ceil(floatscaledwidth); var scaledheight = Math.ceil(floatscaledheight); var absscaledwidth = Math.abs(scaledwidth); var absscaledheight = Math.abs(scaledheight); var halfw = this.runtime.draw_width / 2; var halfh = this.runtime.draw_height / 2; if (!this.myctx) { this.mycanvas = document.createElement("canvas"); this.mycanvas.width = absscaledwidth; this.mycanvas.height = absscaledheight; this.lastwidth = absscaledwidth; this.lastheight = absscaledheight; need_redraw = true; this.myctx = this.mycanvas.getContext("2d"); } if (absscaledwidth !== this.lastwidth || absscaledheight !== this.lastheight) { this.mycanvas.width = absscaledwidth; this.mycanvas.height = absscaledheight; if (this.mytex) { glw.deleteTexture(this.mytex); this.mytex = null; } need_redraw = true; } if (need_redraw) { this.myctx.clearRect(0, 0, absscaledwidth, absscaledheight); this.draw(this.myctx, true); if (!this.mytex) this.mytex = glw.createEmptyTexture(absscaledwidth, absscaledheight, this.runtime.linearSampling, this.runtime.isMobile); glw.videoToTexture(this.mycanvas, this.mytex, this.runtime.isMobile); } this.lastwidth = absscaledwidth; this.lastheight = absscaledheight; glw.setTexture(this.mytex); glw.setOpacity(this.opacity); glw.resetModelView(); glw.translate(-halfw, -halfh); glw.updateModelView(); var q = this.bquad; var tlx = this.layer.layerToCanvas(q.tlx, q.tly, true, true); var tly = this.layer.layerToCanvas(q.tlx, q.tly, false, true); var trx = this.layer.layerToCanvas(q.trx, q.try_, true, true); var try_ = this.layer.layerToCanvas(q.trx, q.try_, false, true); var brx = this.layer.layerToCanvas(q.brx, q.bry, true, true); var bry = this.layer.layerToCanvas(q.brx, q.bry, false, true); var blx = this.layer.layerToCanvas(q.blx, q.bly, true, true); var bly = this.layer.layerToCanvas(q.blx, q.bly, false, true); if (this.runtime.pixel_rounding || (this.angle === 0 && layer_angle === 0)) { var ox = ((tlx + 0.5) | 0) - tlx; var oy = ((tly + 0.5) | 0) - tly tlx += ox; tly += oy; trx += ox; try_ += oy; brx += ox; bry += oy; blx += ox; bly += oy; } if (this.angle === 0 && layer_angle === 0) { trx = tlx + scaledwidth; try_ = tly; brx = trx; bry = tly + scaledheight; blx = tlx; bly = bry; rcTex.right = 1; rcTex.bottom = 1; } else { rcTex.right = floatscaledwidth / scaledwidth; rcTex.bottom = floatscaledheight / scaledheight; } glw.quadTex(tlx, tly, trx, try_, brx, bry, blx, bly, rcTex); glw.resetModelView(); glw.scale(layer_scale, layer_scale); glw.rotateZ(-this.layer.getAngle()); glw.translate((this.layer.viewLeft + this.layer.viewRight) / -2, (this.layer.viewTop + this.layer.viewBottom) / -2); glw.updateModelView(); this.last_render_tick = this.runtime.tickcount; }; var wordsCache = []; pluginProto.TokeniseWords = function (text) { cr.clearArray(wordsCache); var cur_word = ""; var ch; var i = 0; while (i < text.length) { ch = text.charAt(i); if (ch === "\n") { if (cur_word.length) { wordsCache.push(cur_word); cur_word = ""; } wordsCache.push("\n"); ++i; } else if (ch === " " || ch === "\t" || ch === "-") { do { cur_word += text.charAt(i); i++; } while (i < text.length && (text.charAt(i) === " " || text.charAt(i) === "\t")); wordsCache.push(cur_word); cur_word = ""; } else if (i < text.length) { cur_word += ch; i++; } } if (cur_word.length) wordsCache.push(cur_word); }; var linesCache = []; function allocLine() { if (linesCache.length) return linesCache.pop(); else return {}; }; function freeLine(l) { linesCache.push(l); }; function freeAllLines(arr) { var i, len; for (i = 0, len = arr.length; i < len; i++) { freeLine(arr[i]); } cr.clearArray(arr); }; pluginProto.WordWrap = function (text, lines, ctx, width, wrapbyword) { if (!text || !text.length) { freeAllLines(lines); return; } if (width <= 2.0) { freeAllLines(lines); return; } if (text.length <= 100 && text.indexOf("\n") === -1) { var all_width = ctx.measureText(text).width; if (all_width <= width) { freeAllLines(lines); lines.push(allocLine()); lines[0].text = text; lines[0].width = all_width; return; } } this.WrapText(text, lines, ctx, width, wrapbyword); }; function trimSingleSpaceRight(str) { if (!str.length || str.charAt(str.length - 1) !== " ") return str; return str.substring(0, str.length - 1); }; pluginProto.WrapText = function (text, lines, ctx, width, wrapbyword) { var wordArray; if (wrapbyword) { this.TokeniseWords(text); // writes to wordsCache wordArray = wordsCache; } else wordArray = text; var cur_line = ""; var prev_line; var line_width; var i; var lineIndex = 0; var line; for (i = 0; i < wordArray.length; i++) { if (wordArray[i] === "\n") { if (lineIndex >= lines.length) lines.push(allocLine()); cur_line = trimSingleSpaceRight(cur_line); // for correct center/right alignment line = lines[lineIndex]; line.text = cur_line; line.width = ctx.measureText(cur_line).width; lineIndex++; cur_line = ""; continue; } prev_line = cur_line; cur_line += wordArray[i]; line_width = ctx.measureText(cur_line).width; if (line_width >= width) { if (lineIndex >= lines.length) lines.push(allocLine()); prev_line = trimSingleSpaceRight(prev_line); line = lines[lineIndex]; line.text = prev_line; line.width = ctx.measureText(prev_line).width; lineIndex++; cur_line = wordArray[i]; if (!wrapbyword && cur_line === " ") cur_line = ""; } } if (cur_line.length) { if (lineIndex >= lines.length) lines.push(allocLine()); cur_line = trimSingleSpaceRight(cur_line); line = lines[lineIndex]; line.text = cur_line; line.width = ctx.measureText(cur_line).width; lineIndex++; } for (i = lineIndex; i < lines.length; i++) freeLine(lines[i]); lines.length = lineIndex; }; function Cnds() {}; Cnds.prototype.CompareText = function(text_to_compare, case_sensitive) { if (case_sensitive) return this.text == text_to_compare; else return cr.equals_nocase(this.text, text_to_compare); }; pluginProto.cnds = new Cnds(); function Acts() {}; Acts.prototype.SetText = function(param) { if (cr.is_number(param) && param < 1e9) param = Math.round(param * 1e10) / 1e10; // round to nearest ten billionth - hides floating point errors var text_to_set = param.toString(); if (this.text !== text_to_set) { this.text = text_to_set; this.text_changed = true; this.runtime.redraw = true; } }; Acts.prototype.AppendText = function(param) { if (cr.is_number(param)) param = Math.round(param * 1e10) / 1e10; // round to nearest ten billionth - hides floating point errors var text_to_append = param.toString(); if (text_to_append) // not empty { this.text += text_to_append; this.text_changed = true; this.runtime.redraw = true; } }; Acts.prototype.SetFontFace = function (face_, style_) { var newstyle = ""; switch (style_) { case 1: newstyle = "bold"; break; case 2: newstyle = "italic"; break; case 3: newstyle = "bold italic"; break; } if (face_ === this.facename && newstyle === this.fontstyle) return; // no change this.facename = face_; this.fontstyle = newstyle; this.updateFont(); }; Acts.prototype.SetFontSize = function (size_) { if (this.ptSize === size_) return; this.ptSize = size_; this.pxHeight = Math.ceil((this.ptSize / 72.0) * 96.0) + 4; // assume 96dpi... this.updateFont(); }; Acts.prototype.SetFontColor = function (rgb) { var newcolor = "rgb(" + cr.GetRValue(rgb).toString() + "," + cr.GetGValue(rgb).toString() + "," + cr.GetBValue(rgb).toString() + ")"; if (newcolor === this.color) return; this.color = newcolor; this.need_text_redraw = true; this.runtime.redraw = true; }; Acts.prototype.SetWebFont = function (familyname_, cssurl_) { if (this.runtime.isDomFree) { cr.logexport("[Construct 2] Text plugin: 'Set web font' not supported on this platform - the action has been ignored"); return; // DC todo } var self = this; var refreshFunc = (function () { self.runtime.redraw = true; self.text_changed = true; }); if (requestedWebFonts.hasOwnProperty(cssurl_)) { var newfacename = "'" + familyname_ + "'"; if (this.facename === newfacename) return; // no change this.facename = newfacename; this.updateFont(); for (var i = 1; i < 10; i++) { setTimeout(refreshFunc, i * 100); setTimeout(refreshFunc, i * 1000); } return; } var wf = document.createElement("link"); wf.href = cssurl_; wf.rel = "stylesheet"; wf.type = "text/css"; wf.onload = refreshFunc; document.getElementsByTagName('head')[0].appendChild(wf); requestedWebFonts[cssurl_] = true; this.facename = "'" + familyname_ + "'"; this.updateFont(); for (var i = 1; i < 10; i++) { setTimeout(refreshFunc, i * 100); setTimeout(refreshFunc, i * 1000); } ; }; Acts.prototype.SetEffect = function (effect) { this.blend_mode = effect; this.compositeOp = cr.effectToCompositeOp(effect); cr.setGLBlend(this, effect, this.runtime.gl); this.runtime.redraw = true; }; pluginProto.acts = new Acts(); function Exps() {}; Exps.prototype.Text = function(ret) { ret.set_string(this.text); }; Exps.prototype.FaceName = function (ret) { ret.set_string(this.facename); }; Exps.prototype.FaceSize = function (ret) { ret.set_int(this.ptSize); }; Exps.prototype.TextWidth = function (ret) { var w = 0; var i, len, x; for (i = 0, len = this.lines.length; i < len; i++) { x = this.lines[i].width; if (w < x) w = x; } ret.set_int(w); }; Exps.prototype.TextHeight = function (ret) { ret.set_int(this.lines.length * (this.pxHeight + this.line_height_offset) - this.line_height_offset); }; pluginProto.exps = new Exps(); }()); ; ; cr.plugins_.TiledBg = function(runtime) { this.runtime = runtime; }; (function () { var pluginProto = cr.plugins_.TiledBg.prototype; pluginProto.Type = function(plugin) { this.plugin = plugin; this.runtime = plugin.runtime; }; var typeProto = pluginProto.Type.prototype; typeProto.onCreate = function() { if (this.is_family) return; this.texture_img = new Image(); this.texture_img.cr_filesize = this.texture_filesize; this.runtime.waitForImageLoad(this.texture_img, this.texture_file); this.pattern = null; this.webGL_texture = null; }; typeProto.onLostWebGLContext = function () { if (this.is_family) return; this.webGL_texture = null; }; typeProto.onRestoreWebGLContext = function () { if (this.is_family || !this.instances.length) return; if (!this.webGL_texture) { this.webGL_texture = this.runtime.glwrap.loadTexture(this.texture_img, true, this.runtime.linearSampling, this.texture_pixelformat); } var i, len; for (i = 0, len = this.instances.length; i < len; i++) this.instances[i].webGL_texture = this.webGL_texture; }; typeProto.loadTextures = function () { if (this.is_family || this.webGL_texture || !this.runtime.glwrap) return; this.webGL_texture = this.runtime.glwrap.loadTexture(this.texture_img, true, this.runtime.linearSampling, this.texture_pixelformat); }; typeProto.unloadTextures = function () { if (this.is_family || this.instances.length || !this.webGL_texture) return; this.runtime.glwrap.deleteTexture(this.webGL_texture); this.webGL_texture = null; }; typeProto.preloadCanvas2D = function (ctx) { ctx.drawImage(this.texture_img, 0, 0); }; pluginProto.Instance = function(type) { this.type = type; this.runtime = type.runtime; }; var instanceProto = pluginProto.Instance.prototype; instanceProto.onCreate = function() { this.visible = (this.properties[0] === 0); // 0=visible, 1=invisible this.rcTex = new cr.rect(0, 0, 0, 0); this.has_own_texture = false; // true if a texture loaded in from URL this.texture_img = this.type.texture_img; if (this.runtime.glwrap) { this.type.loadTextures(); this.webGL_texture = this.type.webGL_texture; } else { if (!this.type.pattern) this.type.pattern = this.runtime.ctx.createPattern(this.type.texture_img, "repeat"); this.pattern = this.type.pattern; } }; instanceProto.afterLoad = function () { this.has_own_texture = false; this.texture_img = this.type.texture_img; }; instanceProto.onDestroy = function () { if (this.runtime.glwrap && this.has_own_texture && this.webGL_texture) { this.runtime.glwrap.deleteTexture(this.webGL_texture); this.webGL_texture = null; } }; instanceProto.draw = function(ctx) { ctx.globalAlpha = this.opacity; ctx.save(); ctx.fillStyle = this.pattern; var myx = this.x; var myy = this.y; if (this.runtime.pixel_rounding) { myx = Math.round(myx); myy = Math.round(myy); } var drawX = -(this.hotspotX * this.width); var drawY = -(this.hotspotY * this.height); var offX = drawX % this.texture_img.width; var offY = drawY % this.texture_img.height; if (offX < 0) offX += this.texture_img.width; if (offY < 0) offY += this.texture_img.height; ctx.translate(myx, myy); ctx.rotate(this.angle); ctx.translate(offX, offY); ctx.fillRect(drawX - offX, drawY - offY, this.width, this.height); ctx.restore(); }; instanceProto.drawGL_earlyZPass = function(glw) { this.drawGL(glw); }; instanceProto.drawGL = function(glw) { glw.setTexture(this.webGL_texture); glw.setOpacity(this.opacity); var rcTex = this.rcTex; rcTex.right = this.width / this.texture_img.width; rcTex.bottom = this.height / this.texture_img.height; var q = this.bquad; if (this.runtime.pixel_rounding) { var ox = Math.round(this.x) - this.x; var oy = Math.round(this.y) - this.y; glw.quadTex(q.tlx + ox, q.tly + oy, q.trx + ox, q.try_ + oy, q.brx + ox, q.bry + oy, q.blx + ox, q.bly + oy, rcTex); } else glw.quadTex(q.tlx, q.tly, q.trx, q.try_, q.brx, q.bry, q.blx, q.bly, rcTex); }; function Cnds() {}; Cnds.prototype.OnURLLoaded = function () { return true; }; pluginProto.cnds = new Cnds(); function Acts() {}; Acts.prototype.SetEffect = function (effect) { this.blend_mode = effect; this.compositeOp = cr.effectToCompositeOp(effect); cr.setGLBlend(this, effect, this.runtime.gl); this.runtime.redraw = true; }; Acts.prototype.LoadURL = function (url_, crossOrigin_) { var img = new Image(); var self = this; img.onload = function () { self.texture_img = img; if (self.runtime.glwrap) { if (self.has_own_texture && self.webGL_texture) self.runtime.glwrap.deleteTexture(self.webGL_texture); self.webGL_texture = self.runtime.glwrap.loadTexture(img, true, self.runtime.linearSampling); } else { self.pattern = self.runtime.ctx.createPattern(img, "repeat"); } self.has_own_texture = true; self.runtime.redraw = true; self.runtime.trigger(cr.plugins_.TiledBg.prototype.cnds.OnURLLoaded, self); }; if (url_.substr(0, 5) !== "data:" && crossOrigin_ === 0) img.crossOrigin = "anonymous"; this.runtime.setImageSrc(img, url_); }; pluginProto.acts = new Acts(); function Exps() {}; Exps.prototype.ImageWidth = function (ret) { ret.set_float(this.texture_img.width); }; Exps.prototype.ImageHeight = function (ret) { ret.set_float(this.texture_img.height); }; pluginProto.exps = new Exps(); }()); ; ; cr.plugins_.Tilemap = function(runtime) { this.runtime = runtime; }; (function () { var pluginProto = cr.plugins_.Tilemap.prototype; pluginProto.Type = function(plugin) { this.plugin = plugin; this.runtime = plugin.runtime; }; var typeProto = pluginProto.Type.prototype; typeProto.onCreate = function() { var i, len, p; if (this.is_family) return; this.texture_img = new Image(); this.texture_img.cr_filesize = this.texture_filesize; this.runtime.waitForImageLoad(this.texture_img, this.texture_file); this.cut_tiles = []; this.cut_tiles_valid = false; this.tile_polys = []; this.tile_polys_cached = false; // first instance will cache polys with the tile width/height if (this.tile_poly_data && this.tile_poly_data.length) { for (i = 0, len = this.tile_poly_data.length; i < len; ++i) { p = this.tile_poly_data[i]; if (p) { this.tile_polys.push({ poly: p, flipmap: [[[null, null], [null, null]], [[null, null], [null, null]]] }); } else this.tile_polys.push(null); } } }; typeProto.cacheTilePoly = function (tileid, tilewidth, tileheight, fliph, flipv, flipd) { if (tileid < 0 || tileid >= this.tile_polys.length) return; if (!this.tile_polys[tileid]) return; // no poly for this tile var poly = this.tile_polys[tileid].poly; var flipmap = this.tile_polys[tileid].flipmap; var cached_poly = new cr.CollisionPoly(poly); cached_poly.cache_poly(tilewidth, tileheight, 0); if (flipd) cached_poly.diag(); if (fliph) cached_poly.mirror(tilewidth / 2); if (flipv) cached_poly.flip(tileheight / 2); flipmap[fliph?1:0][flipv?1:0][flipd?1:0] = cached_poly; }; typeProto.getTilePoly = function (id) { if (id === -1) return null; var tileid = (id & TILE_ID_MASK); if (tileid < 0 || tileid >= this.tile_polys.length) return null; // out of range if (!this.tile_polys[tileid]) return null; // no poly for this tile var fliph = (id & TILE_FLIPPED_HORIZONTAL) ? 1 : 0; var flipv = (id & TILE_FLIPPED_VERTICAL) ? 1 : 0; var flipd = (id & TILE_FLIPPED_DIAGONAL) ? 1 : 0; return this.tile_polys[tileid].flipmap[fliph][flipv][flipd]; }; typeProto.freeCutTiles = function () { var i, len; var glwrap = this.runtime.glwrap; if (glwrap) { for (i = 0, len = this.cut_tiles.length; i < len; ++i) glwrap.deleteTexture(this.cut_tiles[i]); } cr.clearArray(this.cut_tiles); this.cut_tiles_valid = false; } typeProto.maybeCutTiles = function (tw, th, offx, offy, sepx, sepy, seamless) { if (this.cut_tiles_valid) return; // no changed if (tw <= 0 || th <= 0) return; this.freeCutTiles(); var img_width = this.texture_img.width; var img_height = this.texture_img.height; var x, y; for (y = offy; y + th <= img_height; y += (th + sepy)) { for (x = offx; x + tw <= img_width; x += (tw + sepx)) { this.cut_tiles.push(this.CutTileImage(x, y, tw, th, seamless)); } } this.cut_tiles_valid = true; }; typeProto.CutTileImage = function(x, y, w, h, seamless) { if (this.runtime.glwrap) { return this.DoCutTileImage(x, y, w, h, false, false, false, seamless); } else { var flipmap = [[[null, null], [null, null]], [[null, null], [null, null]]]; flipmap[0][0][0] = this.DoCutTileImage(x, y, w, h, false, false, false, seamless); return { flipmap: flipmap, x: x, y: y, w: w, h: h }; } }; typeProto.GetFlippedTileImage = function (tileid, fliph, flipv, flipd, seamless) { if (tileid < 0 || tileid >= this.cut_tiles.length) return null; var tile = this.cut_tiles[tileid]; var flipmap = tile.flipmap; var hi = (fliph ? 1 : 0); var vi = (flipv ? 1 : 0); var di = (flipd ? 1 : 0); var ret = flipmap[hi][vi][di]; if (ret) { return ret; } else { ret = this.DoCutTileImage(tile.x, tile.y, tile.w, tile.h, hi!==0, vi!==0, di!==0, seamless); flipmap[hi][vi][di] = ret; return ret; } }; typeProto.DoCutTileImage = function(x, y, w, h, fliph, flipv, flipd, seamless) { var dw = w; var dh = h; if (this.runtime.glwrap && !seamless) { if (!cr.isPOT(dw)) dw = cr.nextHighestPowerOfTwo(dw); if (!cr.isPOT(dh)) dh = cr.nextHighestPowerOfTwo(dh); } var tmpcanvas = document.createElement("canvas"); tmpcanvas.width = dw; tmpcanvas.height = dh; var tmpctx = tmpcanvas.getContext("2d"); if (this.runtime.ctx) { if (fliph) { if (flipv) { if (flipd) { tmpctx.rotate(Math.PI / 2); tmpctx.scale(-1, 1); tmpctx.translate(-dw, -dh); } else { tmpctx.scale(-1, -1); tmpctx.translate(-dw, -dh); } } else { if (flipd) { tmpctx.rotate(Math.PI / 2); tmpctx.translate(0, -dh); } else { tmpctx.scale(-1, 1); tmpctx.translate(-dw, 0); } } } else { if (flipv) { if (flipd) { tmpctx.rotate(-Math.PI / 2); tmpctx.translate(-dw, 0); } else { tmpctx.scale(1, -1); tmpctx.translate(0, -dh); } } else { if (flipd) { tmpctx.scale(-1, 1); tmpctx.rotate(Math.PI / 2); } } } tmpctx.drawImage(this.texture_img, x, y, w, h, 0, 0, dw, dh); if (seamless) return tmpcanvas; else return this.runtime.ctx.createPattern(tmpcanvas, "repeat"); } else { ; tmpctx.drawImage(this.texture_img, x, y, w, h, 0, 0, dw, dh); var tex = this.runtime.glwrap.createEmptyTexture(dw, dh, this.runtime.linearSampling, false, !seamless); this.runtime.glwrap.videoToTexture(tmpcanvas, tex); return tex; } }; typeProto.onLostWebGLContext = function () { if (this.is_family) return; this.freeCutTiles(); }; typeProto.onRestoreWebGLContext = function () { }; typeProto.loadTextures = function () { }; typeProto.unloadTextures = function () { if (this.is_family || this.instances.length) return; this.freeCutTiles(); }; typeProto.preloadCanvas2D = function (ctx) { }; pluginProto.Instance = function(type) { this.type = type; this.runtime = type.runtime; }; var instanceProto = pluginProto.Instance.prototype; var TILE_FLIPPED_HORIZONTAL = -0x80000000 // note: pretend is a signed int, so negate var TILE_FLIPPED_VERTICAL = 0x40000000 var TILE_FLIPPED_DIAGONAL = 0x20000000 var TILE_FLAGS_MASK = 0xE0000000 var TILE_ID_MASK = 0x1FFFFFFF function TileQuad() { this.id = -1; this.tileid = -1; this.horiz_flip = false; this.vert_flip = false; this.diag_flip = false; this.any_flip = false; this.rc = new cr.rect(0, 0, 0, 0); }; var tilequad_cache = []; function allocTileQuad() { if (tilequad_cache.length) return tilequad_cache.pop(); else return new TileQuad(); }; function freeTileQuad(tq) { if (tilequad_cache.length < 10000) tilequad_cache.push(tq); }; function TileCollisionRect() { this.id = -1; this.rc = new cr.rect(0, 0, 0, 0); this.poly = null; } var collrect_cache = []; function allocCollRect() { if (collrect_cache.length) return collrect_cache.pop(); else return new TileCollisionRect(); }; function freeCollRect(r) { if (collrect_cache.length < 10000) collrect_cache.push(r); }; var tile_cell_cache = []; function allocTileCell(inst_, x_, y_) { var ret; if (tile_cell_cache.length) { ret = tile_cell_cache.pop(); ret.inst = inst_; ret.x = x_; ret.y = y_; ret.left = ret.x * ret.inst.cellwidth * ret.inst.tilewidth; ret.top = ret.y * ret.inst.cellheight * ret.inst.tileheight; ret.clear(); ret.quadmap_valid = false; return ret; } else return new TileCell(inst_, x_, y_); }; function freeTileCell(tc) { var i, len; for (i = 0, len = tc.quads.length; i < len; ++i) freeTileQuad(tc.quads[i]); cr.clearArray(tc.quads); for (i = 0, len = tc.collision_rects.length; i < len; ++i) freeCollRect(tc.collision_rects[i]); cr.clearArray(tc.collision_rects); if (tile_cell_cache.length < 1000) tile_cell_cache.push(tc); }; function TileCell(inst_, x_, y_) { this.inst = inst_; this.x = x_; this.y = y_; this.left = this.x * this.inst.cellwidth * this.inst.tilewidth; this.top = this.y * this.inst.cellheight * this.inst.tileheight; this.tiles = []; this.quads = []; this.collision_rects = []; this.quadmap_valid = false; var i, len, j, lenj, arr; for (i = 0, len = this.inst.cellheight; i < len; ++i) { arr = []; for (j = 0, lenj = this.inst.cellwidth; j < lenj; ++j) arr.push(-1); this.tiles.push(arr); } }; TileCell.prototype.clear = function () { var i, len, j, lenj, arr; this.tiles.length = this.inst.cellheight; for (i = 0, len = this.tiles.length; i < len; ++i) { arr = this.tiles[i]; if (!arr) { arr = []; this.tiles[i] = arr; } arr.length = this.inst.cellwidth; for (j = 0, lenj = arr.length; j < lenj; ++j) arr[j] = -1; } }; TileCell.prototype.maybeBuildQuadMap = function () { if (this.quadmap_valid) return; // not changed var tilewidth = this.inst.tilewidth; var tileheight = this.inst.tileheight; if (tilewidth <= 0 || tileheight <= 0) return; var i, j, len, y, leny, x, lenx, arr, t, p, q; for (i = 0, len = this.quads.length; i < len; ++i) freeTileQuad(this.quads[i]); for (i = 0, len = this.collision_rects.length; i < len; ++i) freeCollRect(this.collision_rects[i]); cr.clearArray(this.quads); cr.clearArray(this.collision_rects); var extentwidth = Math.min(this.inst.mapwidth, Math.floor(this.inst.width / tilewidth)); var extentheight = Math.min(this.inst.mapheight, Math.floor(this.inst.height / tileheight)); extentwidth -= this.left / tilewidth; extentheight -= this.top / tileheight; if (extentwidth > this.inst.cellwidth) extentwidth = this.inst.cellwidth; if (extentheight > this.inst.cellheight) extentheight = this.inst.cellheight; var seamless = this.inst.seamless; var cur_quad = null; for (y = 0, leny = extentheight; y < leny; ++y) { arr = this.tiles[y]; for (x = 0, lenx = extentwidth; x < lenx; ++x) { t = arr[x]; if (t === -1) { if (cur_quad) { this.quads.push(cur_quad); cur_quad = null; } continue; } if (seamless || !cur_quad || t !== cur_quad.id) { if (cur_quad) this.quads.push(cur_quad); cur_quad = allocTileQuad(); cur_quad.id = t; cur_quad.tileid = (t & TILE_ID_MASK); cur_quad.horiz_flip = (t & TILE_FLIPPED_HORIZONTAL) !== 0; cur_quad.vert_flip = (t & TILE_FLIPPED_VERTICAL) !== 0; cur_quad.diag_flip = (t & TILE_FLIPPED_DIAGONAL) !== 0; cur_quad.any_flip = (cur_quad.horiz_flip || cur_quad.vert_flip || cur_quad.diag_flip); cur_quad.rc.left = x * tilewidth + this.left; cur_quad.rc.top = y * tileheight + this.top; cur_quad.rc.right = cur_quad.rc.left + tilewidth; cur_quad.rc.bottom = cur_quad.rc.top + tileheight; } else { cur_quad.rc.right += tilewidth; } } if (cur_quad) { this.quads.push(cur_quad); cur_quad = null; } } var cur_rect = null; var tileid, tilepoly; var cur_has_poly = false; var rc; for (y = 0, leny = extentheight; y < leny; ++y) { arr = this.tiles[y]; for (x = 0, lenx = extentwidth; x < lenx; ++x) { t = arr[x]; if (t === -1) { if (cur_rect) { this.collision_rects.push(cur_rect); cur_rect = null; cur_has_poly = false; } continue; } tileid = (t & TILE_ID_MASK); tilepoly = this.inst.type.getTilePoly(t); if (!cur_rect || tilepoly || cur_has_poly) { if (cur_rect) { this.collision_rects.push(cur_rect); cur_rect = null; } ; cur_rect = allocCollRect(); cur_rect.id = t; cur_rect.poly = tilepoly ? tilepoly : null; rc = cur_rect.rc; rc.left = x * tilewidth + this.left; rc.top = y * tileheight + this.top; rc.right = rc.left + tilewidth; rc.bottom = rc.top + tileheight; cur_has_poly = !!tilepoly; } else { cur_rect.rc.right += tilewidth; } } if (cur_rect) { this.collision_rects.push(cur_rect); cur_rect = null; cur_has_poly = false; } } if (!seamless) { len = this.quads.length; for (i = 0; i < len; ++i) { q = this.quads[i]; for (j = i + 1; j < len; ++j) { p = this.quads[j]; if (p.rc.top < q.rc.bottom) continue; if (p.rc.top > q.rc.bottom) break; if (p.rc.right > q.rc.right || p.rc.left > q.rc.left) break; if (p.id === q.id && p.rc.left === q.rc.left && p.rc.right === q.rc.right) { freeTileQuad(this.quads[j]); this.quads.splice(j, 1); --len; q.rc.bottom += tileheight; --j; // look at same j index again } } } } len = this.collision_rects.length; var prc, qrc; for (i = 0; i < len; ++i) { q = this.collision_rects[i]; if (q.poly) continue; qrc = q.rc; for (j = i + 1; j < len; ++j) { p = this.collision_rects[j]; prc = p.rc; if (prc.top < qrc.bottom) continue; if (prc.top > qrc.bottom) break; if (prc.right > qrc.right || prc.left > qrc.left) break; if (p.poly) continue; if (prc.left === qrc.left && prc.right === qrc.right) { freeCollRect(this.collision_rects[j]); this.collision_rects.splice(j, 1); --len; qrc.bottom += tileheight; --j; // look at same j index again } } } this.quadmap_valid = true; }; TileCell.prototype.setTileAt = function (x_, y_, t_) { if (this.tiles[y_][x_] !== t_) { this.tiles[y_][x_] = t_; this.quadmap_valid = false; this.inst.any_quadmap_changed = true; this.inst.physics_changed = true; this.inst.runtime.redraw = true; } }; instanceProto.onCreate = function() { ; var i, len, p; this.visible = (this.properties[0] === 0); this.tilewidth = this.properties[1]; this.tileheight = this.properties[2]; this.tilexoffset = this.properties[3]; this.tileyoffset = this.properties[4]; this.tilexspacing = this.properties[5]; this.tileyspacing = this.properties[6]; this.seamless = (this.properties[7] !== 0); this.mapwidth = this.tilemap_width; this.mapheight = this.tilemap_height; this.lastwidth = this.width; this.lastheight = this.height; var tw = this.tilewidth; var th = this.tileheight; if (tw === 0) tw = 1; if (th === 0) th = 1; this.cellwidth = Math.ceil(this.runtime.original_width / tw); this.cellheight = Math.ceil(this.runtime.original_height / th); if (!this.type.tile_polys_cached) { this.type.tile_polys_cached = true; for (i = 0, len = this.type.tile_polys.length; i < len; ++i) { p = this.type.tile_polys[i]; if (!p) continue; this.type.cacheTilePoly(i, tw, th, false, false, false); this.type.cacheTilePoly(i, tw, th, false, false, true); this.type.cacheTilePoly(i, tw, th, false, true, false); this.type.cacheTilePoly(i, tw, th, false, true, true); this.type.cacheTilePoly(i, tw, th, true, false, false); this.type.cacheTilePoly(i, tw, th, true, false, true); this.type.cacheTilePoly(i, tw, th, true, true, false); this.type.cacheTilePoly(i, tw, th, true, true, true); } } if (!this.recycled) this.tilecells = []; this.maybeResizeTilemap(true); this.setTilesFromRLECSV(this.tilemap_data); this.type.maybeCutTiles(this.tilewidth, this.tileheight, this.tilexoffset, this.tileyoffset, this.tilexspacing, this.tileyspacing, this.seamless); this.physics_changed = false; // to indicate to physics behavior to recreate body this.any_quadmap_changed = true; this.maybeBuildAllQuadMap(); }; instanceProto.maybeBuildAllQuadMap = function () { if (!this.any_quadmap_changed) return; // no change var i, len, j, lenj, arr; for (i = 0, len = this.tilecells.length; i < len; ++i) { arr = this.tilecells[i]; for (j = 0, lenj = arr.length; j < lenj; ++j) { arr[j].maybeBuildQuadMap(); } } this.any_quadmap_changed = false; }; instanceProto.setAllQuadMapChanged = function () { var i, len, j, lenj, arr; for (i = 0, len = this.tilecells.length; i < len; ++i) { arr = this.tilecells[i]; for (j = 0, lenj = arr.length; j < lenj; ++j) { arr[j].quadmap_valid = false; } } this.any_quadmap_changed = true; }; function RunLengthDecode(str) { var ret = []; var parts = str.split(","); var i, len, p, x, n, t, part; for (i = 0, len = parts.length; i < len; ++i) { p = parts[i]; x = p.indexOf("x"); if (x > -1) { n = parseInt(p.substring(0, x), 10); part = p.substring(x + 1); t = parseInt(part, 10); if (part.indexOf("h") > -1) t = t | TILE_FLIPPED_HORIZONTAL; if (part.indexOf("v") > -1) t = t | TILE_FLIPPED_VERTICAL; if (part.indexOf("d") > -1) t = t | TILE_FLIPPED_DIAGONAL; for ( ; n > 0; --n) ret.push(t); } else { t = parseInt(p, 10); if (p.indexOf("h") > -1) t = t | TILE_FLIPPED_HORIZONTAL; if (p.indexOf("v") > -1) t = t | TILE_FLIPPED_VERTICAL; if (p.indexOf("d") > -1) t = t | TILE_FLIPPED_DIAGONAL; ret.push(t); } } return ret; }; instanceProto.maybeResizeTilemap = function (force) { var curwidth = cr.floor(this.width / this.tilewidth); var curheight = cr.floor(this.height / this.tileheight); if (curwidth <= this.mapwidth && curheight <= this.mapheight && !force) return; var vcells, hcells; if (force) { vcells = Math.ceil(this.mapheight / this.cellheight); hcells = Math.ceil(this.mapwidth / this.cellwidth); } else { vcells = this.tilecells.length; hcells = Math.ceil(this.mapwidth / this.cellwidth); if (curheight > this.mapheight) { this.mapheight = curheight; vcells = Math.ceil(this.mapheight / this.cellheight); } if (curwidth > this.mapwidth) { this.mapwidth = curwidth; hcells = Math.ceil(this.mapwidth / this.cellwidth); } this.setAllQuadMapChanged(); this.physics_changed = true; this.runtime.redraw = true; } var y, x, arr; for (y = 0; y < vcells; ++y) { arr = this.tilecells[y]; if (!arr) { arr = []; for (x = 0; x < hcells; ++x) arr.push(allocTileCell(this, x, y)); this.tilecells[y] = arr; } else { for (x = arr.length; x < hcells; ++x) arr.push(allocTileCell(this, x, y)); } } }; instanceProto.cellAt = function (tx, ty) { if (tx < 0 || ty < 0) return null; var cy = cr.floor(ty / this.cellheight); if (cy >= this.tilecells.length) return null; var row = this.tilecells[cy]; var cx = cr.floor(tx / this.cellwidth); if (cx >= row.length) return null; return row[cx]; }; instanceProto.cellAtIndex = function (cx, cy) { if (cx < 0 || cy < 0 || cy >= this.tilecells.length) return null; var row = this.tilecells[cy]; if (cx >= row.length) return null; return row[cx]; }; instanceProto.setTilesFromRLECSV = function (str) { var tilestream = RunLengthDecode(str); var next = 0; var y, x, arr, tile, cell; for (y = 0; y < this.mapheight; ++y) { for (x = 0; x < this.mapwidth; ++x) { tile = tilestream[next++]; cell = this.cellAt(x, y); if (cell) cell.setTileAt(x % this.cellwidth, y % this.cellheight, tile); } } }; instanceProto.getTilesAsRLECSV = function () { var ret = ""; if (this.mapwidth <= 0 || this.mapheight <= 0) return ret; var run_count = 1; var run_number = this.getTileAt(0, 0); var y, leny, x, lenx, t; var tileid, horiz_flip, vert_flip, diag_flip; lenx = cr.floor(this.width / this.tilewidth); leny = cr.floor(this.height / this.tileheight); for (y = 0; y < leny; ++y) { for (x = (y === 0 ? 1 : 0) ; x < lenx; ++x) { t = this.getTileAt(x, y); if (t === run_number) ++run_count; else { if (run_number === -1) { tileid = -1; horiz_flip = false; vert_flip = false; diag_flip = false; } else { tileid = (run_number & TILE_ID_MASK); horiz_flip = (run_number & TILE_FLIPPED_HORIZONTAL) !== 0; vert_flip = (run_number & TILE_FLIPPED_VERTICAL) !== 0; diag_flip = (run_number & TILE_FLIPPED_DIAGONAL) !== 0; } if (run_count === 1) ret += "" + tileid; else ret += "" + run_count + "x" + tileid; if (horiz_flip) ret += "h"; if (vert_flip) ret += "v"; if (diag_flip) ret += "d"; ret += ","; run_count = 1; run_number = t; } } } if (run_number === -1) { tileid = -1; horiz_flip = false; vert_flip = false; diag_flip = false; } else { tileid = (run_number & TILE_ID_MASK); horiz_flip = (run_number & TILE_FLIPPED_HORIZONTAL) !== 0; vert_flip = (run_number & TILE_FLIPPED_VERTICAL) !== 0; diag_flip = (run_number & TILE_FLIPPED_DIAGONAL) !== 0; } if (run_count === 1) ret += "" + tileid; else ret += "" + run_count + "x" + tileid; if (horiz_flip) ret += "h"; if (vert_flip) ret += "v"; if (diag_flip) ret += "d"; return ret; }; instanceProto.getTileAt = function (x_, y_) { x_ = Math.floor(x_); y_ = Math.floor(y_); if (x_ < 0 || y_ < 0 || x_ >= this.mapwidth || y_ >= this.mapheight) return -1; var cell = this.cellAt(x_, y_); if (!cell) return -1; return cell.tiles[y_ % this.cellheight][x_ % this.cellwidth]; }; instanceProto.setTileAt = function (x_, y_, t_) { x_ = Math.floor(x_); y_ = Math.floor(y_); if (x_ < 0 || y_ < 0 || x_ >= this.mapwidth || y_ >= this.mapheight) return -1; var cell = this.cellAt(x_, y_); if (!cell) return -1; cell.setTileAt(x_ % this.cellwidth, y_ % this.cellheight, t_); }; instanceProto.worldToCellX = function (x) { return Math.floor((x - this.x) / (this.cellwidth * this.tilewidth)); }; instanceProto.worldToCellY = function (y) { return Math.floor((y - this.y) / (this.cellheight * this.tileheight)); }; instanceProto.worldToTileX = function (x) { return Math.floor((x - this.x) / this.tilewidth) }; instanceProto.worldToTileY = function (y) { return Math.floor((y - this.y) / this.tileheight); }; instanceProto.getCollisionRectCandidates = function (bbox, candidates) { var firstCellX = this.worldToCellX(bbox.left); var firstCellY = this.worldToCellY(bbox.top); var lastCellX = this.worldToCellX(bbox.right); var lastCellY = this.worldToCellY(bbox.bottom); var cx, cy, cell; for (cx = firstCellX; cx <= lastCellX; ++cx) { for (cy = firstCellY; cy <= lastCellY; ++cy) { cell = this.cellAtIndex(cx, cy); if (!cell) continue; cell.maybeBuildQuadMap(); cr.appendArray(candidates, cell.collision_rects); } } }; instanceProto.testPointOverlapTile = function (x, y) { var tx = this.worldToTileX(x); var ty = this.worldToTileY(y); var tile = this.getTileAt(tx, ty); if (tile === -1) return false; // empty tile here var poly = this.type.getTilePoly(tile); if (!poly) return true; // no poly; whole tile registers overlap var tileStartX = (Math.floor((x - this.x) / this.tilewidth) * this.tilewidth) + this.x; var tileStartY = (Math.floor((y - this.y) / this.tileheight) * this.tileheight) + this.y; x -= tileStartX; y -= tileStartY; return poly.contains_pt(x, y); }; instanceProto.getAllCollisionRects = function (candidates) { var i, len, j, lenj, row, cell; for (i = 0, len = this.tilecells.length; i < len; ++i) { row = this.tilecells[i]; for (j = 0, lenj = row.length; j < lenj; ++j) { cell = row[j]; cell.maybeBuildQuadMap(); cr.appendArray(candidates, cell.collision_rects); } } }; instanceProto.onDestroy = function () { var i, len, j, lenj, arr; for (i = 0, len = this.tilecells.length; i < len; ++i) { arr = this.tilecells[i]; for (j = 0, lenj = arr.length; j < lenj; ++j) { freeTileCell(arr[j]); } cr.clearArray(arr); } cr.clearArray(this.tilecells); }; instanceProto.saveToJSON = function () { this.maybeResizeTilemap(); var curwidth = cr.floor(this.width / this.tilewidth); var curheight = cr.floor(this.height / this.tileheight); return { "w": curwidth, "h": curheight, "d": this.getTilesAsRLECSV() }; }; instanceProto.loadFromJSON = function (o) { this.mapwidth = o["w"]; this.mapheight = o["h"]; this.maybeResizeTilemap(true); this.setTilesFromRLECSV(o["d"]); this.physics_changed = true; this.setAllQuadMapChanged(); }; instanceProto.draw = function(ctx) { if (this.tilewidth <= 0 || this.tileheight <= 0) return; this.type.maybeCutTiles(this.tilewidth, this.tileheight, this.tilexoffset, this.tileyoffset, this.tilexspacing, this.tileyspacing, this.seamless); if (this.width !== this.lastwidth || this.height !== this.lastheight) { this.physics_changed = true; this.setAllQuadMapChanged(); this.maybeBuildAllQuadMap(); this.lastwidth = this.width; this.lastheight = this.height; } ctx.globalAlpha = this.opacity; var layer = this.layer; var viewLeft = layer.viewLeft; var viewTop = layer.viewTop; var viewRight = layer.viewRight; var viewBottom = layer.viewBottom; var myx = this.x; var myy = this.y; var seamless = this.seamless; var qrc; if (this.runtime.pixel_rounding) { myx = Math.round(myx); myy = Math.round(myy); } var cellWidthPx = this.cellwidth * this.tilewidth; var cellHeightPx = this.cellheight * this.tileheight; var firstCellX = Math.floor((viewLeft - myx) / cellWidthPx); var lastCellX = Math.floor((viewRight - myx) / cellWidthPx); var firstCellY = Math.floor((viewTop - myy) / cellHeightPx); var lastCellY = Math.floor((viewBottom - myy) / cellHeightPx); var offx = myx % this.tilewidth; var offy = myy % this.tileheight; if (this.seamless) { offx = 0; offy = 0; } if (offx !== 0 || offy !== 0) { ctx.save(); ctx.translate(offx, offy); myx -= offx; myy -= offy; viewLeft -= offx; viewTop -= offy; viewRight -= offx; viewBottom -= offy; } var cx, cy, cell, i, len, q, qleft, qtop, qright, qbottom, img; for (cx = firstCellX; cx <= lastCellX; ++cx) { for (cy = firstCellY; cy <= lastCellY; ++cy) { cell = this.cellAtIndex(cx, cy); if (!cell) continue; cell.maybeBuildQuadMap(); for (i = 0, len = cell.quads.length; i < len; ++i) { q = cell.quads[i]; if (q.id === -1) continue; qrc = q.rc; qleft = qrc.left + myx; qtop = qrc.top + myy; qright = qrc.right + myx; qbottom = qrc.bottom + myy; if (qleft > viewRight || qright < viewLeft || qtop > viewBottom || qbottom < viewTop) continue; img = this.type.GetFlippedTileImage(q.tileid, q.horiz_flip, q.vert_flip, q.diag_flip, this.seamless); if (seamless) { ctx.drawImage(img, qleft, qtop); } else { ctx.fillStyle = this.type.GetFlippedTileImage(q.tileid, q.horiz_flip, q.vert_flip, q.diag_flip, this.seamless); ctx.fillRect(qleft, qtop, qright - qleft, qbottom - qtop); } } /* for (i = 0, len = cell.collision_rects.length; i < len; ++i) { qrc = cell.collision_rects[i].rc; qleft = qrc.left + myx; qtop = qrc.top + myy; qright = qrc.right + myx; qbottom = qrc.bottom + myy; ctx.strokeRect(qleft, qtop, qright - qleft, qbottom - qtop); } */ } } if (offx !== 0 || offy !== 0) ctx.restore(); }; var tmp_rect = new cr.rect(0, 0, 1, 1); instanceProto.drawGL_earlyZPass = function(glw) { this.drawGL(glw); }; instanceProto.drawGL = function (glw) { if (this.tilewidth <= 0 || this.tileheight <= 0) return; this.type.maybeCutTiles(this.tilewidth, this.tileheight, this.tilexoffset, this.tileyoffset, this.tilexspacing, this.tileyspacing, this.seamless); if (this.width !== this.lastwidth || this.height !== this.lastheight) { this.physics_changed = true; this.setAllQuadMapChanged(); this.maybeBuildAllQuadMap(); this.lastwidth = this.width; this.lastheight = this.height; } glw.setOpacity(this.opacity); var cut_tiles = this.type.cut_tiles; var layer = this.layer; var viewLeft = layer.viewLeft; var viewTop = layer.viewTop; var viewRight = layer.viewRight; var viewBottom = layer.viewBottom; var myx = this.x; var myy = this.y; var qrc; if (this.runtime.pixel_rounding) { myx = Math.round(myx); myy = Math.round(myy); } var cellWidthPx = this.cellwidth * this.tilewidth; var cellHeightPx = this.cellheight * this.tileheight; var firstCellX = Math.floor((viewLeft - myx) / cellWidthPx); var lastCellX = Math.floor((viewRight - myx) / cellWidthPx); var firstCellY = Math.floor((viewTop - myy) / cellHeightPx); var lastCellY = Math.floor((viewBottom - myy) / cellHeightPx); var i, len, q, qleft, qtop, qright, qbottom; var qtlx, qtly, qtrx, qtry, qbrx, qbry, qblx, qbly, temp; var cx, cy, cell; for (cx = firstCellX; cx <= lastCellX; ++cx) { for (cy = firstCellY; cy <= lastCellY; ++cy) { cell = this.cellAtIndex(cx, cy); if (!cell) continue; cell.maybeBuildQuadMap(); for (i = 0, len = cell.quads.length; i < len; ++i) { q = cell.quads[i]; if (q.id === -1) continue; qrc = q.rc; qleft = qrc.left + myx; qtop = qrc.top + myy; qright = qrc.right + myx; qbottom = qrc.bottom + myy; if (qleft > viewRight || qright < viewLeft || qtop > viewBottom || qbottom < viewTop) continue; glw.setTexture(cut_tiles[q.tileid]); tmp_rect.right = (qright - qleft) / this.tilewidth; tmp_rect.bottom = (qbottom - qtop) / this.tileheight; if (q.any_flip) { if (q.diag_flip) { temp = tmp_rect.right; tmp_rect.right = tmp_rect.bottom; tmp_rect.bottom = temp; } qtlx = 0; qtly = 0; qtrx = tmp_rect.right; qtry = 0; qbrx = tmp_rect.right; qbry = tmp_rect.bottom; qblx = 0; qbly = tmp_rect.bottom; if (q.diag_flip) { temp = qblx; qblx = qtrx; qtrx = temp; temp = qbly; qbly = qtry; qtry = temp; } if (q.horiz_flip) { temp = qtlx; qtlx = qtrx; qtrx = temp; temp = qtly; qtly = qtry; qtry = temp; temp = qblx; qblx = qbrx; qbrx = temp; temp = qbly; qbly = qbry; qbry = temp; } if (q.vert_flip) { temp = qtlx; qtlx = qblx; qblx = temp; temp = qtly; qtly = qbly; qbly = temp; temp = qtrx; qtrx = qbrx; qbrx = temp; temp = qtry; qtry = qbry; qbry = temp; } glw.quadTexUV(qleft, qtop, qright, qtop, qright, qbottom, qleft, qbottom, qtlx, qtly, qtrx, qtry, qbrx, qbry, qblx, qbly); } else { glw.quadTex(qleft, qtop, qright, qtop, qright, qbottom, qleft, qbottom, tmp_rect); } } } } }; function Cnds() {}; Cnds.prototype.CompareTileAt = function (tx, ty, cmp, t) { var tile = this.getTileAt(tx, ty); if (tile !== -1) tile = (tile & TILE_ID_MASK); return cr.do_cmp(tile, cmp, t); }; function StateComboToFlags(state) { switch (state) { case 0: // normal return 0; case 1: // flipped horizontal return TILE_FLIPPED_HORIZONTAL; case 2: // flipped vertical return TILE_FLIPPED_VERTICAL; case 3: // rotated 90 return TILE_FLIPPED_HORIZONTAL | TILE_FLIPPED_DIAGONAL; case 4: // rotated 180 return TILE_FLIPPED_HORIZONTAL | TILE_FLIPPED_VERTICAL; case 5: // rotated 270 return TILE_FLIPPED_VERTICAL | TILE_FLIPPED_DIAGONAL; case 6: // rotated 90, flipped vertical return TILE_FLIPPED_HORIZONTAL | TILE_FLIPPED_VERTICAL | TILE_FLIPPED_DIAGONAL; case 7: // rotated 270, flipped vertical return TILE_FLIPPED_DIAGONAL; default: return 0; } }; Cnds.prototype.CompareTileStateAt = function (tx, ty, state) { var tile = this.getTileAt(tx, ty); var flags = 0; if (tile !== -1) flags = (tile & TILE_FLAGS_MASK); return flags === StateComboToFlags(state); }; Cnds.prototype.OnURLLoaded = function () { return true; }; pluginProto.cnds = new Cnds(); function Acts() {}; Acts.prototype.EraseTile = function (tx, ty) { this.maybeResizeTilemap(); this.setTileAt(tx, ty, -1); }; Acts.prototype.SetTile = function (tx, ty, t, state) { this.maybeResizeTilemap(); this.setTileAt(tx, ty, (t & TILE_ID_MASK) | StateComboToFlags(state)); }; Acts.prototype.SetTileState = function (tx, ty, state) { var t = this.getTileAt(tx, ty); if (t !== -1) { this.maybeResizeTilemap(); this.setTileAt(tx, ty, (t & TILE_ID_MASK) | StateComboToFlags(state)); } }; Acts.prototype.EraseTileRange = function (tx, ty, tw, th) { var fromx = Math.floor(cr.max(tx, 0)); var fromy = Math.floor(cr.max(ty, 0)); var tox = Math.floor(cr.min(tx + tw, this.mapwidth)); var toy = Math.floor(cr.min(ty + th, this.mapheight)); var x, y; for (y = fromy; y < toy; ++y) { for (x = fromx; x < tox; ++x) { this.setTileAt(x, y, -1); } } }; Acts.prototype.SetTileRange = function (tx, ty, tw, th, t, state) { this.maybeResizeTilemap(); var fromx = Math.floor(cr.max(tx, 0)); var fromy = Math.floor(cr.max(ty, 0)); var tox = Math.floor(cr.min(tx + tw, this.mapwidth)); var toy = Math.floor(cr.min(ty + th, this.mapheight)); var settile = (t & TILE_ID_MASK) | StateComboToFlags(state); var x, y; for (y = fromy; y < toy; ++y) { for (x = fromx; x < tox; ++x) { this.setTileAt(x, y, settile); } } }; Acts.prototype.SetTileStateRange = function (tx, ty, tw, th, state) { this.maybeResizeTilemap(); var fromx = Math.floor(cr.max(tx, 0)); var fromy = Math.floor(cr.max(ty, 0)); var tox = Math.floor(cr.min(tx + tw, this.mapwidth)); var toy = Math.floor(cr.min(ty + th, this.mapheight)); var setstate = StateComboToFlags(state); var x, y, t; for (y = fromy; y < toy; ++y) { for (x = fromx; x < tox; ++x) { t = this.getTileAt(x, y); if (t !== -1) this.setTileAt(x, y, (t & TILE_ID_MASK) | setstate); } } }; Acts.prototype.LoadFromJSON = function (str) { var o; try { o = JSON.parse(str); } catch (e) { return; } if (!o["c2tilemap"]) return; // not a known tilemap data format this.mapwidth = o["width"]; this.mapheight = o["height"]; this.maybeResizeTilemap(true); this.setTilesFromRLECSV(o["data"]); this.setAllQuadMapChanged(); this.physics_changed = true; }; Acts.prototype.JSONDownload = function (filename) { var a = document.createElement("a"); var o = { "c2tilemap": true, "width": this.mapwidth, "height": this.mapheight, "data": this.getTilesAsRLECSV() }; if (typeof a.download === "undefined") { var str = 'data:text/html,' + encodeURIComponent("

Download link

"); window.open(str); } else { var body = document.getElementsByTagName("body")[0]; a.textContent = filename; a.href = "data:application/json," + encodeURIComponent(JSON.stringify(o)); a.download = filename; body.appendChild(a); var clickEvent = document.createEvent("MouseEvent"); clickEvent.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); a.dispatchEvent(clickEvent); body.removeChild(a); } }; Acts.prototype.LoadURL = function (url_, crossOrigin_) { var img = new Image(); var self = this; img.onload = function () { var type = self.type; type.freeCutTiles(); type.texture_img = img; self.runtime.redraw = true; self.runtime.trigger(cr.plugins_.Tilemap.prototype.cnds.OnURLLoaded, self); }; if (url_.substr(0, 5) !== "data:" && crossOrigin_ === 0) img.crossOrigin = "anonymous"; this.runtime.setImageSrc(img, url_); }; pluginProto.acts = new Acts(); function Exps() {}; Exps.prototype.TileAt = function (ret, tx, ty) { var tile = this.getTileAt(tx, ty); ret.set_int(tile === -1 ? -1 : (tile & TILE_ID_MASK)); }; Exps.prototype.PositionToTileX = function (ret, x_) { ret.set_float(this.worldToTileX(x_)); }; Exps.prototype.PositionToTileY = function (ret, y_) { ret.set_float(this.worldToTileY(y_)); }; Exps.prototype.TileToPositionX = function (ret, x_) { ret.set_float((x_ * this.tilewidth) + this.x + (this.tilewidth / 2)); }; Exps.prototype.TileToPositionY = function (ret, y_) { ret.set_float((y_ * this.tileheight) + this.y + (this.tileheight / 2)); }; Exps.prototype.SnapX = function (ret, x_) { ret.set_float((Math.floor((x_ - this.x) / this.tilewidth) * this.tilewidth) + this.x + (this.tilewidth / 2)); }; Exps.prototype.SnapY = function (ret, y_) { ret.set_float((Math.floor((y_ - this.y) / this.tileheight) * this.tileheight) + this.y + (this.tileheight / 2)); }; Exps.prototype.TilesJSON = function (ret) { this.maybeResizeTilemap(); var curwidth = cr.floor(this.width / this.tilewidth); var curheight = cr.floor(this.height / this.tileheight); ret.set_string(JSON.stringify({ "c2tilemap": true, "width": curwidth, "height": curheight, "data": this.getTilesAsRLECSV() })); }; pluginProto.exps = new Exps(); }()); ; ; cr.plugins_.gamepad = function(runtime) { this.runtime = runtime; }; (function () { var pluginProto = cr.plugins_.gamepad.prototype; var isSupported = false; pluginProto.Type = function(plugin) { this.plugin = plugin; this.runtime = plugin.runtime; isSupported = !!(navigator["getGamepads"] || navigator["webkitGetGamepads"] || navigator["mozGetGamepads"] || navigator["gamepads"] || navigator["webkitGamepads"] || navigator["MozGamepads"] || window["cr_getGamepads"]); }; var typeProto = pluginProto.Type.prototype; typeProto.onCreate = function() { }; var gamepadRuntime = null; var gamepadInstance = null; var controllers = new Array(16); var padStates = new Array(16); var padOldStates = new Array(16); var osToken = ""; var browserToken = ""; function getPadState(i) { var j; if (!padStates[i]) { padStates[i] = new Array(20); for (j = 0; j < 20; ++j) padStates[i][j] = 0; } return padStates[i]; }; function getPadOldState(i) { var j; if (!padOldStates[i]) { padOldStates[i] = new Array(20); for (j = 0; j < 20; ++j) padOldStates[i][j] = 0; } return padOldStates[i]; }; function updatePadOldState(i) { var cur = getPadState(i); var old = getPadOldState(i); var j; for (j = 0; j < 20; ++j) old[j] = cur[j]; }; function clearPadState(i) { padStates[i] = null; padOldStates[i] = null; }; var axisOffset = 16; var curCtrlMap = null; var ctrlmap = {}; ctrlmap["windows"] = {}; ctrlmap["windows"]["firefox"] = {}; function doControllerMapping(index, isAxis, buttonmap, axismap) { if (isAxis) { if (index >= axismap.length) return -1; // unknown axis if (cr.is_number(axismap[index])) return axismap[index] + axisOffset; else { return axismap[index]; // returning array } } else { if (index >= buttonmap.length) return -1; // unknown button return buttonmap[index]; } }; var win_ff_xbox360_buttons = [0, 1, 2, 3, 4, 5, 8, 9, 10, 11]; var win_ff_xbox360_axes = [0, 1, [7, 6], 2, 3, [14, 15], [12, 13]]; ctrlmap["windows"]["firefox"]["xbox360"] = function (index, isAxis) { return doControllerMapping(index, isAxis, win_ff_xbox360_buttons, win_ff_xbox360_axes); }; var win_ff_lda_buttons = [2, 0, 1, 3, 4, 6, 5, 7, 8, 9]; var win_ff_lda_axes = [0, 1, 2, 3, [14, 15], [12, 13]]; ctrlmap["windows"]["firefox"]["logitechdualaction"] = function (index, isAxis) { return doControllerMapping(index, isAxis, win_ff_lda_buttons, win_ff_lda_axes); }; function defaultMap(index, isAxis) { if (isAxis) { if (index >= 4) return -1; // unknown axis return index + axisOffset; } else { if (index >= 16) return -1; // unknown button return index; } }; function getMapper(id_) { if (!curCtrlMap) return defaultMap; var controllertoken = ""; var id = id_.toLowerCase(); if (id.indexOf("xbox 360") > -1) controllertoken = "xbox360"; else if (id.indexOf("logitech dual action") > -1) controllertoken = "logitechdualaction"; var curmap = curCtrlMap[controllertoken]; return curmap || defaultMap; }; function onConnected(e) { controllers[e["gamepad"]["index"]] = e["gamepad"]; gamepadRuntime.trigger(cr.plugins_.gamepad.prototype.cnds.OnGamepadConnected, gamepadInstance); }; function onDisconnected(e) { gamepadRuntime.trigger(cr.plugins_.gamepad.prototype.cnds.OnGamepadDisconnected, gamepadInstance); controllers[e["gamepad"]["index"]] = null; }; pluginProto.Instance = function(type) { this.type = type; this.runtime = type.runtime; gamepadRuntime = this.runtime; gamepadInstance = this; }; var instanceProto = pluginProto.Instance.prototype; instanceProto.onCreate = function() { this.deadzone = this.properties[0]; this.lastButton = 0; var userAgent = navigator.userAgent; osToken = "windows"; if (/mac/i.test(userAgent)) osToken = "mac"; curCtrlMap = ctrlmap[osToken]; browserToken = "chrome"; if (/firefox/i.test(userAgent)) browserToken = "firefox"; if (curCtrlMap) curCtrlMap = curCtrlMap[browserToken]; window.addEventListener("webkitgamepadconnected", onConnected, false); window.addEventListener("webkitgamepaddisconnected", onDisconnected, false); window.addEventListener("MozGamepadConnected", onConnected, false); window.addEventListener("MozGamepadDisconnected", onDisconnected, false); window.addEventListener("gamepadconnected", onConnected, false); window.addEventListener("gamepaddisconnected", onDisconnected, false); this.runtime.tickMe(this); this.activeControllers = []; }; instanceProto.tick = function () { this.activeControllers.length = 0; var gamepads = null; var synthetic = false; if (navigator["getGamepads"]) gamepads = navigator["getGamepads"](); else if (navigator["webkitGetGamepads"]) gamepads = navigator["webkitGetGamepads"](); else if (navigator["mozGetGamepads"]) gamepads = navigator["mozGetGamepads"](); else if (navigator["msGetGamepads"]) gamepads = navigator["msGetGamepads"](); else if (this.runtime.isWindows8Capable && window["cr_getGamepads"]) { gamepads = window["cr_getGamepads"](); synthetic = true; } else gamepads = navigator["gamepads"] || navigator["webkitGamepads"] || navigator["MozGamepads"] || controllers; if (!gamepads) return; var i, len, j, lenj, mapfunc, index, value; for (i = 0, len = gamepads.length; i < len; i++) { var pad = gamepads[i]; if (!pad) { clearPadState(i); continue; } var state = getPadState(i); var oldstate = getPadOldState(i); updatePadOldState(i); mapfunc = (synthetic ? defaultMap : getMapper(pad.id)); for (j = 0, lenj = pad["buttons"].length; j < lenj; j++) { if (typeof pad["buttons"][j]["value"] !== "undefined") value = pad["buttons"][j]["value"]; else value = pad["buttons"][j]; index = mapfunc(j, false, value); if (index >= 0 && index < 20) { state[index] = value * 100; if (state[index] >= 50 && oldstate[index] < 50) this.lastButton = index; } } for (j = 0, lenj = pad["axes"].length; j < lenj; j++) { value = pad["axes"][j]; index = mapfunc(j, true, value); if (cr.is_number(index)) { if (index >= 0 && index < 20) state[index] = value * 100; } else { state[index[0]] = 0; state[index[1]] = 0; if (value <= 0) state[index[0]] = Math.abs(value * 100); else state[index[1]] = Math.abs(value * 100); } } this.activeControllers.push(pad); } for ( ; i < 20; ++i) clearPadState(i); }; instanceProto.saveToJSON = function () { return { "lastButton": this.lastButton }; }; instanceProto.loadFromJSON = function (o) { this.lastButton = o["lastButton"]; }; function Cnds() {}; Cnds.prototype.SupportsGamepad = function () { return isSupported; }; Cnds.prototype.OnGamepadConnected = function () { return true; }; Cnds.prototype.OnGamepadDisconnected = function () { return true; }; Cnds.prototype.IsButtonDown = function (gamepad, button) { gamepad = Math.floor(gamepad); if (gamepad < 0 || gamepad >= this.activeControllers.length) return false; var state = getPadState(gamepad); if (!state) return false; var ret = state[button] >= 50; if (ret) this.lastButton = button; return ret; }; Cnds.prototype.OnButtonDown = function (gamepad, button) { gamepad = Math.floor(gamepad); if (gamepad < 0 || gamepad >= this.activeControllers.length) return false; var state = getPadState(gamepad); var oldstate = getPadOldState(gamepad); if (!state || !oldstate) return false; var ret = state[button] >= 50 && oldstate[button] < 50; if (ret) this.lastButton = button; return ret; }; Cnds.prototype.OnButtonUp = function (gamepad, button) { gamepad = Math.floor(gamepad); if (gamepad < 0 || gamepad >= this.activeControllers.length) return false; var state = getPadState(gamepad); var oldstate = getPadOldState(gamepad); if (!state || !oldstate) return false; var ret = state[button] < 50 && oldstate[button] >= 50; if (ret) this.lastButton = button; return ret; }; Cnds.prototype.HasGamepads = function () { return this.activeControllers.length > 0; }; Cnds.prototype.CompareAxis = function (gamepad, axis, comparison, value) { gamepad = Math.floor(gamepad); axis = Math.floor(axis); if (gamepad < 0 || gamepad >= this.activeControllers.length) return false; var state = getPadState(gamepad); if (!state) return; var axisvalue = state[axis + axisOffset]; var othervalue = 0; if (axis % 2 === 0) // is X axis othervalue = state[axis + axisOffset + 1]; // get next axis (Y) else othervalue = state[axis + axisOffset - 1]; // get previous axis (X) if (Math.sqrt(axisvalue * axisvalue + othervalue * othervalue) <= this.deadzone) axisvalue = 0; return cr.do_cmp(axisvalue, comparison, value); }; Cnds.prototype.OnAnyButtonDown = function (gamepad) { gamepad = Math.floor(gamepad); if (gamepad < 0 || gamepad >= this.activeControllers.length) return false; var state = getPadState(gamepad); var oldstate = getPadOldState(gamepad); if (!state || !oldstate) return false; var i, len; for (i = 0, len = state.length; i < len; i++) { if (state[i] >= 50 && oldstate[i] < 50) { this.lastButton = i; return true; } } return false; }; Cnds.prototype.OnAnyButtonUp = function (gamepad) { gamepad = Math.floor(gamepad); if (gamepad < 0 || gamepad >= this.activeControllers.length) return false; var state = getPadState(gamepad); var oldstate = getPadOldState(gamepad); if (!state || !oldstate) return false; var i, len; for (i = 0, len = state.length; i < len; i++) { if (state[i] < 50 && oldstate[i] >= 50) { this.lastButton = i; return true; } } return false; }; Cnds.prototype.IsButtonIndexDown = function (gamepad, button) { gamepad = Math.floor(gamepad); if (gamepad < 0 || gamepad >= this.activeControllers.length) return false; var state = getPadState(gamepad); if (!state) return false; button = Math.floor(button); if (button < 0 || button >= state.length) return false; var ret = state[button] >= 50; if (ret) this.lastButton = button; return ret; }; Cnds.prototype.OnButtonIndexDown = function (gamepad, button) { gamepad = Math.floor(gamepad); if (gamepad < 0 || gamepad >= this.activeControllers.length) return false; var state = getPadState(gamepad); var oldstate = getPadOldState(gamepad); if (!state || !oldstate) return false; button = Math.floor(button); if (button < 0 || button >= state.length) return false; var ret = state[button] >= 50 && oldstate[button] < 50; if (ret) this.lastButton = button; return ret; }; Cnds.prototype.OnButtonIndexUp = function (gamepad, button) { gamepad = Math.floor(gamepad); if (gamepad < 0 || gamepad >= this.activeControllers.length) return false; var state = getPadState(gamepad); var oldstate = getPadOldState(gamepad); if (!state || !oldstate) return false; button = Math.floor(button); if (button < 0 || button >= state.length) return false; var ret = state[button] < 50 && oldstate[button] >= 50; if (ret) this.lastButton = button; return ret; }; pluginProto.cnds = new Cnds(); function Acts() {}; pluginProto.acts = new Acts(); function Exps() {}; Exps.prototype.GamepadCount = function (ret) { ret.set_int(this.activeControllers.length); }; Exps.prototype.GamepadID = function (ret, index) { if (index < 0 || index >= this.activeControllers.length) { ret.set_string(""); return; } ret.set_string(this.activeControllers[index].id); }; Exps.prototype.GamepadAxes = function (ret, index) { if (index < 0 || index >= this.activeControllers.length) { ret.set_string(""); return; } var axes = this.activeControllers[index]["axes"]; var str = ""; var i, len; for (i = 0, len = axes.length; i < len; i++) { str += "Axis " + i + ": " + Math.round(axes[i] * 100) + "\n"; } ret.set_string(str); }; Exps.prototype.GamepadButtons = function (ret, index) { if (index < 0 || index >= this.activeControllers.length) { ret.set_string(""); return; } var buttons = this.activeControllers[index]["buttons"]; var str = ""; var i, len, value; for (i = 0, len = buttons.length; i < len; i++) { if (typeof buttons[i]["value"] !== "undefined") value = buttons[i]["value"]; else value = buttons[i]; str += "Button " + i + ": " + Math.round(value * 100) + "\n"; } ret.set_string(str); }; Exps.prototype.RawButton = function (ret, gamepad, index) { gamepad = Math.floor(gamepad); index = Math.floor(index); if (gamepad < 0 || gamepad >= this.activeControllers.length) { ret.set_float(0); return; } var state = this.activeControllers[gamepad]["buttons"]; if (!state || index < 0 || index >= state.length) { ret.set_float(0); return; } if (typeof state[index]["value"] !== "undefined") ret.set_float(state[index]["value"]); else ret.set_float(state[index]); }; Exps.prototype.RawAxis = function (ret, gamepad, index) { gamepad = Math.floor(gamepad); index = Math.floor(index); if (gamepad < 0 || gamepad >= this.activeControllers.length) { ret.set_float(0); return; } var state = this.activeControllers[gamepad]["axes"]; if (!state || index < 0 || index >= state.length) { ret.set_float(0); return; } ret.set_float(state[index]); }; Exps.prototype.RawButtonCount = function (ret, gamepad) { gamepad = Math.floor(gamepad); if (gamepad < 0 || gamepad >= this.activeControllers.length) { ret.set_int(0); return; } ret.set_int(this.activeControllers[gamepad]["buttons"].length); }; Exps.prototype.RawAxisCount = function (ret, gamepad) { gamepad = Math.floor(gamepad); if (gamepad < 0 || gamepad >= this.activeControllers.length) { ret.set_int(0); return; } ret.set_int(this.activeControllers[gamepad]["axes"].length); }; Exps.prototype.Button = function (ret, gamepad, index) { gamepad = Math.floor(gamepad); index = Math.floor(index); if (gamepad < 0 || gamepad >= this.activeControllers.length) { ret.set_float(0); return; } var state = getPadState(gamepad); if (!state || index < 0 || index >= axisOffset) { ret.set_float(0); return; } ret.set_float(state[index]); }; Exps.prototype.Axis = function (ret, gamepad, index) { gamepad = Math.floor(gamepad); index = Math.floor(index); if (gamepad < 0 || gamepad >= this.activeControllers.length) { ret.set_float(0); return; } var state = getPadState(gamepad); if (!state || index < 0 || index >= 4) { ret.set_float(0); return; } var value = state[index + axisOffset]; var othervalue = 0; if (index % 2 === 0) // is X axis othervalue = state[index + axisOffset + 1]; // get next axis (Y) else othervalue = state[index + axisOffset - 1]; // get previous axis (X) if (Math.sqrt(value * value + othervalue * othervalue) <= this.deadzone) value = 0; ret.set_float(value); }; Exps.prototype.LastButton = function (ret) { ret.set_int(this.lastButton); }; pluginProto.exps = new Exps(); }()); ; ; cr.plugins_.video = function(runtime) { this.runtime = runtime; }; (function () { var pluginProto = cr.plugins_.video.prototype; pluginProto.Type = function(plugin) { this.plugin = plugin; this.runtime = plugin.runtime; }; var typeProto = pluginProto.Type.prototype; typeProto.onCreate = function() { }; typeProto.onLostWebGLContext = function () { if (this.is_family) return; var i, len, inst; for (i = 0, len = this.instances.length; i < len; ++i) { inst = this.instances[i]; inst.webGL_texture = null; // will lazy create again on next draw } }; var tmpVideo = document.createElement("video"); var can_play_webm = !!tmpVideo.canPlayType("video/webm"); var can_play_ogv = !!tmpVideo.canPlayType("video/ogg"); var can_play_mp4 = !!tmpVideo.canPlayType("video/mp4"); tmpVideo = null; function isVideoPlaying(v) { return v && !v.paused && !v.ended && v.currentTime > 0; }; pluginProto.Instance = function(type) { this.type = type; this.runtime = type.runtime; }; var instanceProto = pluginProto.Instance.prototype; var playOnNextInput = []; function playQueued() { var tryPlay = playOnNextInput.slice(0); cr.clearArray(playOnNextInput); var i, len, playRet, v; for (i = 0, len = tryPlay.length; i < len; ++i) { v = tryPlay[i]; playRet = v.play(); if (playRet) { playRet.catch(function (err) { addVideoToPlayOnNextInput(v); }); } } }; document.addEventListener("touchend", playQueued, true); document.addEventListener("click", playQueued, true); document.addEventListener("keydown", playQueued, true); function addVideoToPlayOnNextInput(v) { var i = playOnNextInput.indexOf(v); if (i === -1) playOnNextInput.push(v); }; instanceProto.queueVideoPlay = function (add) { if (!this.video) return; var i; var self = this; if (!add) { i = playOnNextInput.indexOf(this.video); if (i >= 0) playOnNextInput.splice(i, 1); return; } if (this.isSettingSource > 0) { addVideoToPlayOnNextInput(this.video); return; } var playRet; try { playRet = this.video.play(); } catch (err) { addVideoToPlayOnNextInput(this.video); return; } if (playRet) // Promise was returned { playRet.catch(function (err) { if (self.video) addVideoToPlayOnNextInput(self.video); }); } else if (this.useNextTouchWorkaround && !this.runtime.isInUserInputEvent) { addVideoToPlayOnNextInput(this.video); } }; instanceProto.onCreate = function() { this.webm_src = this.properties[0]; this.ogv_src = this.properties[1]; this.mp4_src = this.properties[2]; this.autoplay = this.properties[3]; // 0 = no, 1 = preload, 2 = yes this.playInBackground = (this.properties[4] !== 0); // 0 = no, 1 = yes this.videoWasPlayingOnSuspend = false; this.video = document.createElement("video"); this.video.crossOrigin = "anonymous"; this.video["playsInline"] = true; // ensure inline playback on iOS this.webGL_texture = null; this.currentTrigger = -1; this.viaCanvas = null; this.viaCtx = null; this.useViaCanvasWorkaround = this.runtime.isIE || this.runtime.isMicrosoftEdge; this.isSettingSource = 0; var self = this; this.video.addEventListener("canplay", function () { self.currentTrigger = 0; self.runtime.trigger(cr.plugins_.video.prototype.cnds.OnPlaybackEvent, self); }); this.video.addEventListener("canplaythrough", function () { self.currentTrigger = 1; self.runtime.trigger(cr.plugins_.video.prototype.cnds.OnPlaybackEvent, self); }); this.video.addEventListener("ended", function () { self.currentTrigger = 2; self.runtime.trigger(cr.plugins_.video.prototype.cnds.OnPlaybackEvent, self); }); this.video.addEventListener("error", function () { self.currentTrigger = 3; self.runtime.trigger(cr.plugins_.video.prototype.cnds.OnPlaybackEvent, self); }); this.video.addEventListener("loadstart", function () { self.currentTrigger = 4; self.runtime.trigger(cr.plugins_.video.prototype.cnds.OnPlaybackEvent, self); }); this.video.addEventListener("playing", function () { self.currentTrigger = 5; self.runtime.trigger(cr.plugins_.video.prototype.cnds.OnPlaybackEvent, self); }); this.video.addEventListener("pause", function () { self.currentTrigger = 6; self.runtime.trigger(cr.plugins_.video.prototype.cnds.OnPlaybackEvent, self); }); this.video.addEventListener("stalled", function () { self.currentTrigger = 7; self.runtime.trigger(cr.plugins_.video.prototype.cnds.OnPlaybackEvent, self); }); this.useNextTouchWorkaround = ((this.runtime.isiOS || (this.runtime.isAndroid && (this.runtime.isChrome || this.runtime.isAndroidStockBrowser))) && !this.runtime.isCrosswalk && !this.runtime.isDomFree); if (this.autoplay === 0) { this.video.autoplay = false; this.video.preload = "none"; } else if (this.autoplay === 1) { this.video.autoplay = false; this.video.preload = "auto"; } else if (this.autoplay === 2) { this.video.autoplay = true; } this.setSource(this.webm_src, this.ogv_src, this.mp4_src); if (this.autoplay === 2) this.queueVideoPlay(true); this.visible = (this.properties[5] !== 0); this.runtime.tickMe(this); if (!this.recycled) { var self = this; this.runtime.addSuspendCallback(function(s) { self.onSuspend(s); }); } }; instanceProto.onSuspend = function (s) { if (this.playInBackground || !this.video) return; if (s) { if (isVideoPlaying(this.video)) { this.queueVideoPlay(false); this.video.pause(); this.videoWasPlayingOnSuspend = true; } } else { if (this.videoWasPlayingOnSuspend) { this.queueVideoPlay(true); this.videoWasPlayingOnSuspend = false; } } }; instanceProto.setSource = function (webm_src, ogv_src, mp4_src) { var self = this; var useSrc = ""; if (can_play_webm && webm_src) useSrc = webm_src.toLowerCase(); else if (can_play_ogv && ogv_src) useSrc = ogv_src.toLowerCase(); else if (can_play_mp4 && mp4_src) useSrc = mp4_src.toLowerCase(); if (useSrc) { if (this.runtime.isWKWebView && !this.runtime.isAbsoluteUrl(useSrc)) { this.isSettingSource++; this.runtime.fetchLocalFileViaCordovaAsURL(useSrc, function (url) { self.isSettingSource--; self.video.src = url; // load video from blob URL playQueued(); // may have queued a play while setting source; try play now src is set }, function (err) { console.error("[Video] Failed to load video '" + useSrc + "': ", err); self.isSettingSource--; self.video.src = useSrc; // error loading local video; try to load the original source anyway }); } else { this.video.src = useSrc; } } if (this.runtime.glwrap && this.webGL_texture) { this.runtime.glwrap.deleteTexture(this.webGL_texture); this.webGL_texture = null; } this.viaCanvas = null; this.viaCtx = null; }; instanceProto.onDestroy = function () { this.queueVideoPlay(false); if (isVideoPlaying(this.video)) this.video.pause(); // stop playback if (this.runtime.glwrap && this.webGL_texture) { this.runtime.glwrap.deleteTexture(this.webGL_texture); this.webGL_texture = null; } this.viaCanvas = null; this.viaCtx = null; this.video.src = ""; // memory is not always cleaned up unless we drop the src! this.video = null; }; instanceProto.tick = function () { if (isVideoPlaying(this.video)) this.runtime.redraw = true; }; instanceProto.saveToJSON = function () { return { "s": (this.video.src || ""), "p": !!isVideoPlaying(this.video), "t": (this.video.currentTime || 0) }; }; instanceProto.loadFromJSON = function (o) { if (!o || typeof o["s"] === "undefined") return; var src = o["s"]; this.setSource(src, src, src); try { this.video.currentTime = o["t"]; } catch (e) {}; // ignore if throws if (o["p"]) // is playing { this.queueVideoPlay(true); } else { this.queueVideoPlay(false); this.video.pause(); } }; instanceProto.draw = function (ctx) { if (!this.video) return; // no video to draw var videoWidth = this.video.videoWidth; var videoHeight = this.video.videoHeight; if (videoWidth <= 0 || videoHeight <= 0) return; // not yet loaded metadata var videoAspect = videoWidth / videoHeight; var dispWidth = this.width; var dispHeight = this.height; var dispAspect = dispWidth / dispHeight; var offx = 0; var offy = 0; var drawWidth = 0; var drawHeight = 0; if (dispAspect > videoAspect) { drawWidth = dispHeight * videoAspect; drawHeight = dispHeight; offx = Math.floor((dispWidth - drawWidth) / 2); if (offx < 0) offx = 0; } else { drawWidth = dispWidth; drawHeight = dispWidth / videoAspect; offy = Math.floor((dispHeight - drawHeight) / 2); if (offy < 0) offy = 0; } ctx.globalAlpha = this.opacity; ctx.drawImage(this.video, this.x + offx, this.y + offy, drawWidth, drawHeight); }; var tmpRect = new cr.rect(0, 0, 0, 0); var tmpQuad = new cr.quad(); instanceProto.drawGL = function (glw) { if (!this.video) return; // no video to draw var videoWidth = this.video.videoWidth; var videoHeight = this.video.videoHeight; if (videoWidth <= 0 || videoHeight <= 0) return; // not yet loaded metadata var videoAspect = videoWidth / videoHeight; var dispWidth = this.width; var dispHeight = this.height; var dispAspect = dispWidth / dispHeight; var offx = 0; var offy = 0; var drawWidth = 0; var drawHeight = 0; if (dispAspect > videoAspect) { drawWidth = dispHeight * videoAspect; drawHeight = dispHeight; offx = Math.floor((dispWidth - drawWidth) / 2); if (offx < 0) offx = 0; } else { drawWidth = dispWidth; drawHeight = dispWidth / videoAspect; offy = Math.floor((dispHeight - drawHeight) / 2); if (offy < 0) offy = 0; } if (!this.webGL_texture) { this.webGL_texture = glw.createEmptyTexture(videoWidth, videoHeight, this.runtime.linearSampling, false, false); } if (this.useViaCanvasWorkaround) { if (!this.viaCtx) { this.viaCanvas = document.createElement("canvas"); this.viaCanvas.width = videoWidth; this.viaCanvas.height = videoHeight; this.viaCtx = this.viaCanvas.getContext("2d"); } this.viaCtx.drawImage(this.video, 0, 0); glw.videoToTexture(this.viaCanvas, this.webGL_texture); } else { glw.videoToTexture(this.video, this.webGL_texture); } glw.setBlend(this.srcBlend, this.destBlend); glw.setOpacity(this.opacity); glw.setTexture(this.webGL_texture); tmpRect.set(this.x + offx, this.y + offy, this.x + offx + drawWidth, this.y + offy + drawHeight); tmpQuad.set_from_rect(tmpRect); glw.quad(tmpQuad.tlx, tmpQuad.tly, tmpQuad.trx, tmpQuad.try_, tmpQuad.brx, tmpQuad.bry, tmpQuad.blx, tmpQuad.bly); }; function dbToLinear_nocap(x) { return Math.pow(10, x / 20); }; function linearToDb_nocap(x) { return (Math.log(x) / Math.log(10)) * 20; }; function dbToLinear(x) { var v = dbToLinear_nocap(x); if (v < 0) v = 0; if (v > 1) v = 1; return v; }; function linearToDb(x) { if (x < 0) x = 0; if (x > 1) x = 1; return linearToDb_nocap(x); }; function Cnds() {}; Cnds.prototype.IsPlaying = function () { return isVideoPlaying(this.video); }; Cnds.prototype.IsPaused = function () { return this.video.paused; }; Cnds.prototype.HasEnded = function () { return this.video.ended; }; Cnds.prototype.IsMuted = function () { return this.video.muted; }; Cnds.prototype.OnPlaybackEvent = function (trig) { return this.currentTrigger === trig; }; pluginProto.cnds = new Cnds(); function Acts() {}; Acts.prototype.SetSource = function (webm_src, ogv_src, mp4_src) { this.setSource(webm_src, ogv_src, mp4_src); this.video.load(); }; Acts.prototype.SetPlaybackTime = function (s) { try { this.video.currentTime = s; } catch (e) { if (console && console.error) console.error("Exception setting video playback time: ", e); } }; Acts.prototype.SetLooping = function (l) { this.video.loop = (l !== 0); }; Acts.prototype.SetMuted = function (m) { this.video.muted = (m !== 0); }; Acts.prototype.SetVolume = function (v) { this.video.volume = dbToLinear(v); }; Acts.prototype.Pause = function () { this.queueVideoPlay(false); // remove any play-on-next-touch queue, since we don't want it to be playing any more this.video.pause(); }; Acts.prototype.Play = function () { this.queueVideoPlay(true); }; pluginProto.acts = new Acts(); function Exps() {}; Exps.prototype.PlaybackTime = function (ret) { ret.set_float(this.video.currentTime || 0); }; Exps.prototype.Duration = function (ret) { ret.set_float(this.video.duration || 0); }; Exps.prototype.Volume = function (ret) { ret.set_float(linearToDb(this.video.volume || 0)); }; pluginProto.exps = new Exps(); }()); ; ; cr.behaviors.Bullet = function(runtime) { this.runtime = runtime; }; (function () { var behaviorProto = cr.behaviors.Bullet.prototype; behaviorProto.Type = function(behavior, objtype) { this.behavior = behavior; this.objtype = objtype; this.runtime = behavior.runtime; }; var behtypeProto = behaviorProto.Type.prototype; behtypeProto.onCreate = function() { }; behaviorProto.Instance = function(type, inst) { this.type = type; this.behavior = type.behavior; this.inst = inst; // associated object instance to modify this.runtime = type.runtime; }; var behinstProto = behaviorProto.Instance.prototype; behinstProto.onCreate = function() { var speed = this.properties[0]; this.acc = this.properties[1]; this.g = this.properties[2]; this.bounceOffSolid = (this.properties[3] !== 0); this.setAngle = (this.properties[4] !== 0); this.dx = Math.cos(this.inst.angle) * speed; this.dy = Math.sin(this.inst.angle) * speed; this.lastx = this.inst.x; this.lasty = this.inst.y; this.lastKnownAngle = this.inst.angle; this.travelled = 0; this.enabled = (this.properties[5] !== 0); }; behinstProto.saveToJSON = function () { return { "acc": this.acc, "g": this.g, "dx": this.dx, "dy": this.dy, "lx": this.lastx, "ly": this.lasty, "lka": this.lastKnownAngle, "t": this.travelled, "e": this.enabled }; }; behinstProto.loadFromJSON = function (o) { this.acc = o["acc"]; this.g = o["g"]; this.dx = o["dx"]; this.dy = o["dy"]; this.lastx = o["lx"]; this.lasty = o["ly"]; this.lastKnownAngle = o["lka"]; this.travelled = o["t"]; this.enabled = o["e"]; }; behinstProto.tick = function () { if (!this.enabled) return; var dt = this.runtime.getDt(this.inst); var s, a; var bounceSolid, bounceAngle; if (this.inst.angle !== this.lastKnownAngle) { if (this.setAngle) { s = cr.distanceTo(0, 0, this.dx, this.dy); this.dx = Math.cos(this.inst.angle) * s; this.dy = Math.sin(this.inst.angle) * s; } this.lastKnownAngle = this.inst.angle; } if (this.acc !== 0) { s = cr.distanceTo(0, 0, this.dx, this.dy); if (this.dx === 0 && this.dy === 0) a = this.inst.angle; else a = cr.angleTo(0, 0, this.dx, this.dy); s += this.acc * dt; if (s < 0) s = 0; this.dx = Math.cos(a) * s; this.dy = Math.sin(a) * s; } if (this.g !== 0) this.dy += this.g * dt; this.lastx = this.inst.x; this.lasty = this.inst.y; if (this.dx !== 0 || this.dy !== 0) { this.inst.x += this.dx * dt; this.inst.y += this.dy * dt; this.travelled += cr.distanceTo(0, 0, this.dx * dt, this.dy * dt) if (this.setAngle) { this.inst.angle = cr.angleTo(0, 0, this.dx, this.dy); this.inst.set_bbox_changed(); this.lastKnownAngle = this.inst.angle; } this.inst.set_bbox_changed(); if (this.bounceOffSolid) { bounceSolid = this.runtime.testOverlapSolid(this.inst); if (bounceSolid) { this.runtime.registerCollision(this.inst, bounceSolid); s = cr.distanceTo(0, 0, this.dx, this.dy); bounceAngle = this.runtime.calculateSolidBounceAngle(this.inst, this.lastx, this.lasty); this.dx = Math.cos(bounceAngle) * s; this.dy = Math.sin(bounceAngle) * s; this.inst.x += this.dx * dt; // move out for one tick since the object can't have spent a tick in the solid this.inst.y += this.dy * dt; this.inst.set_bbox_changed(); if (this.setAngle) { this.inst.angle = bounceAngle; this.lastKnownAngle = bounceAngle; this.inst.set_bbox_changed(); } if (!this.runtime.pushOutSolid(this.inst, this.dx / s, this.dy / s, Math.max(s * 2.5 * dt, 30))) this.runtime.pushOutSolidNearest(this.inst, 100); } } } }; function Cnds() {}; Cnds.prototype.CompareSpeed = function (cmp, s) { return cr.do_cmp(cr.distanceTo(0, 0, this.dx, this.dy), cmp, s); }; Cnds.prototype.CompareTravelled = function (cmp, d) { return cr.do_cmp(this.travelled, cmp, d); }; behaviorProto.cnds = new Cnds(); function Acts() {}; Acts.prototype.SetSpeed = function (s) { var a = cr.angleTo(0, 0, this.dx, this.dy); this.dx = Math.cos(a) * s; this.dy = Math.sin(a) * s; }; Acts.prototype.SetAcceleration = function (a) { this.acc = a; }; Acts.prototype.SetGravity = function (g) { this.g = g; }; Acts.prototype.SetAngleOfMotion = function (a) { a = cr.to_radians(a); var s = cr.distanceTo(0, 0, this.dx, this.dy) this.dx = Math.cos(a) * s; this.dy = Math.sin(a) * s; }; Acts.prototype.Bounce = function (objtype) { if (!objtype) return; var otherinst = objtype.getFirstPicked(this.inst); if (!otherinst) return; var dt = this.runtime.getDt(this.inst); var s = cr.distanceTo(0, 0, this.dx, this.dy); var bounceAngle = this.runtime.calculateSolidBounceAngle(this.inst, this.lastx, this.lasty, otherinst); this.dx = Math.cos(bounceAngle) * s; this.dy = Math.sin(bounceAngle) * s; this.inst.x += this.dx * dt; // move out for one tick since the object can't have spent a tick in the solid this.inst.y += this.dy * dt; this.inst.set_bbox_changed(); if (this.setAngle) { this.inst.angle = bounceAngle; this.lastKnownAngle = bounceAngle; this.inst.set_bbox_changed(); } if (s !== 0) // prevent divide-by-zero { if (this.bounceOffSolid) { if (!this.runtime.pushOutSolid(this.inst, this.dx / s, this.dy / s, Math.max(s * 2.5 * dt, 30))) this.runtime.pushOutSolidNearest(this.inst, 100); } else { this.runtime.pushOut(this.inst, this.dx / s, this.dy / s, Math.max(s * 2.5 * dt, 30), otherinst) } } }; Acts.prototype.SetDistanceTravelled = function (d) { this.travelled = d; }; Acts.prototype.SetEnabled = function (en) { this.enabled = (en === 1); }; behaviorProto.acts = new Acts(); function Exps() {}; Exps.prototype.Speed = function (ret) { var s = cr.distanceTo(0, 0, this.dx, this.dy); s = cr.round6dp(s); ret.set_float(s); }; Exps.prototype.Acceleration = function (ret) { ret.set_float(this.acc); }; Exps.prototype.AngleOfMotion = function (ret) { ret.set_float(cr.to_degrees(cr.angleTo(0, 0, this.dx, this.dy))); }; Exps.prototype.DistanceTravelled = function (ret) { ret.set_float(this.travelled); }; Exps.prototype.Gravity = function (ret) { ret.set_float(this.g); }; behaviorProto.exps = new Exps(); }()); ; ; cr.behaviors.EightDir = function(runtime) { this.runtime = runtime; }; (function () { var behaviorProto = cr.behaviors.EightDir.prototype; behaviorProto.Type = function(behavior, objtype) { this.behavior = behavior; this.objtype = objtype; this.runtime = behavior.runtime; }; var behtypeProto = behaviorProto.Type.prototype; behtypeProto.onCreate = function() { }; behaviorProto.Instance = function(type, inst) { this.type = type; this.behavior = type.behavior; this.inst = inst; // associated object instance to modify this.runtime = type.runtime; this.upkey = false; this.downkey = false; this.leftkey = false; this.rightkey = false; this.ignoreInput = false; this.simup = false; this.simdown = false; this.simleft = false; this.simright = false; this.lastuptick = -1; this.lastdowntick = -1; this.lastlefttick = -1; this.lastrighttick = -1; this.dx = 0; this.dy = 0; }; var behinstProto = behaviorProto.Instance.prototype; behinstProto.onCreate = function() { this.maxspeed = this.properties[0]; this.acc = this.properties[1]; this.dec = this.properties[2]; this.directions = this.properties[3]; // 0=Up & down, 1=Left & right, 2=4 directions, 3=8 directions" this.angleMode = this.properties[4]; // 0=No,1=90-degree intervals, 2=45-degree intervals, 3=360 degree (smooth) this.defaultControls = (this.properties[5] === 1); // 0=no, 1=yes this.enabled = (this.properties[6] !== 0); if (this.defaultControls && !this.runtime.isDomFree) { jQuery(document).keydown( (function (self) { return function(info) { self.onKeyDown(info); }; })(this) ); jQuery(document).keyup( (function (self) { return function(info) { self.onKeyUp(info); }; })(this) ); } }; behinstProto.saveToJSON = function () { return { "dx": this.dx, "dy": this.dy, "enabled": this.enabled, "maxspeed": this.maxspeed, "acc": this.acc, "dec": this.dec, "ignoreInput": this.ignoreInput }; }; behinstProto.loadFromJSON = function (o) { this.dx = o["dx"]; this.dy = o["dy"]; this.enabled = o["enabled"]; this.maxspeed = o["maxspeed"]; this.acc = o["acc"]; this.dec = o["dec"]; this.ignoreInput = o["ignoreInput"]; this.upkey = false; this.downkey = false; this.leftkey = false; this.rightkey = false; this.simup = false; this.simdown = false; this.simleft = false; this.simright = false; this.lastuptick = -1; this.lastdowntick = -1; this.lastlefttick = -1; this.lastrighttick = -1; }; behinstProto.onKeyDown = function (info) { var tickcount = this.runtime.tickcount; switch (info.which) { case 37: // left info.preventDefault(); if (this.lastlefttick < tickcount) this.leftkey = true; break; case 38: // up info.preventDefault(); if (this.lastuptick < tickcount) this.upkey = true; break; case 39: // right info.preventDefault(); if (this.lastrighttick < tickcount) this.rightkey = true; break; case 40: // down info.preventDefault(); if (this.lastdowntick < tickcount) this.downkey = true; break; } }; behinstProto.onKeyUp = function (info) { var tickcount = this.runtime.tickcount; switch (info.which) { case 37: // left info.preventDefault(); this.leftkey = false; this.lastlefttick = tickcount; break; case 38: // up info.preventDefault(); this.upkey = false; this.lastuptick = tickcount; break; case 39: // right info.preventDefault(); this.rightkey = false; this.lastrighttick = tickcount; break; case 40: // down info.preventDefault(); this.downkey = false; this.lastdowntick = tickcount; break; } }; behinstProto.onWindowBlur = function () { this.upkey = false; this.downkey = false; this.leftkey = false; this.rightkey = false; }; behinstProto.tick = function () { var dt = this.runtime.getDt(this.inst); var left = this.leftkey || this.simleft; var right = this.rightkey || this.simright; var up = this.upkey || this.simup; var down = this.downkey || this.simdown; this.simleft = false; this.simright = false; this.simup = false; this.simdown = false; if (!this.enabled) return; var collobj = this.runtime.testOverlapSolid(this.inst); if (collobj) { this.runtime.registerCollision(this.inst, collobj); if (!this.runtime.pushOutSolidNearest(this.inst)) return; // must be stuck in solid } if (this.ignoreInput) { left = false; right = false; up = false; down = false; } if (this.directions === 0) { left = false; right = false; } else if (this.directions === 1) { up = false; down = false; } if (this.directions === 2 && (up || down)) { left = false; right = false; } if (left == right) // both up or both down { if (this.dx < 0) { this.dx += this.dec * dt; if (this.dx > 0) this.dx = 0; } else if (this.dx > 0) { this.dx -= this.dec * dt; if (this.dx < 0) this.dx = 0; } } if (up == down) { if (this.dy < 0) { this.dy += this.dec * dt; if (this.dy > 0) this.dy = 0; } else if (this.dy > 0) { this.dy -= this.dec * dt; if (this.dy < 0) this.dy = 0; } } if (left && !right) { if (this.dx > 0) this.dx -= (this.acc + this.dec) * dt; else this.dx -= this.acc * dt; } if (right && !left) { if (this.dx < 0) this.dx += (this.acc + this.dec) * dt; else this.dx += this.acc * dt; } if (up && !down) { if (this.dy > 0) this.dy -= (this.acc + this.dec) * dt; else this.dy -= this.acc * dt; } if (down && !up) { if (this.dy < 0) this.dy += (this.acc + this.dec) * dt; else this.dy += this.acc * dt; } var ax, ay; if (this.dx !== 0 || this.dy !== 0) { var speed = Math.sqrt(this.dx * this.dx + this.dy * this.dy); if (speed > this.maxspeed) { var a = Math.atan2(this.dy, this.dx); this.dx = this.maxspeed * Math.cos(a); this.dy = this.maxspeed * Math.sin(a); } var oldx = this.inst.x; var oldy = this.inst.y; var oldangle = this.inst.angle; this.inst.x += this.dx * dt; this.inst.set_bbox_changed(); collobj = this.runtime.testOverlapSolid(this.inst); if (collobj) { if (!this.runtime.pushOutSolid(this.inst, (this.dx < 0 ? 1 : -1), 0, Math.abs(Math.floor(this.dx * dt)))) { this.inst.x = oldx; } this.dx = 0; this.inst.set_bbox_changed(); this.runtime.registerCollision(this.inst, collobj); } this.inst.y += this.dy * dt; this.inst.set_bbox_changed(); collobj = this.runtime.testOverlapSolid(this.inst); if (collobj) { if (!this.runtime.pushOutSolid(this.inst, 0, (this.dy < 0 ? 1 : -1), Math.abs(Math.floor(this.dy * dt)))) { this.inst.y = oldy; } this.dy = 0; this.inst.set_bbox_changed(); this.runtime.registerCollision(this.inst, collobj); } ax = cr.round6dp(this.dx); ay = cr.round6dp(this.dy); if ((ax !== 0 || ay !== 0) && this.inst.type.plugin.is_rotatable) { if (this.angleMode === 1) // 90 degree intervals this.inst.angle = cr.to_clamped_radians(Math.round(cr.to_degrees(Math.atan2(ay, ax)) / 90.0) * 90.0); else if (this.angleMode === 2) // 45 degree intervals this.inst.angle = cr.to_clamped_radians(Math.round(cr.to_degrees(Math.atan2(ay, ax)) / 45.0) * 45.0); else if (this.angleMode === 3) // 360 degree this.inst.angle = Math.atan2(ay, ax); } this.inst.set_bbox_changed(); if (this.inst.angle != oldangle) { collobj = this.runtime.testOverlapSolid(this.inst); if (collobj) { this.inst.angle = oldangle; this.inst.set_bbox_changed(); this.runtime.registerCollision(this.inst, collobj); } } } }; function Cnds() {}; Cnds.prototype.IsMoving = function () { var speed = Math.sqrt(this.dx * this.dx + this.dy * this.dy); return speed > 1e-10; }; Cnds.prototype.CompareSpeed = function (cmp, s) { var speed = Math.sqrt(this.dx * this.dx + this.dy * this.dy); return cr.do_cmp(speed, cmp, s); }; behaviorProto.cnds = new Cnds(); function Acts() {}; Acts.prototype.Stop = function () { this.dx = 0; this.dy = 0; }; Acts.prototype.Reverse = function () { this.dx *= -1; this.dy *= -1; }; Acts.prototype.SetIgnoreInput = function (ignoring) { this.ignoreInput = ignoring; }; Acts.prototype.SetSpeed = function (speed) { if (speed < 0) speed = 0; if (speed > this.maxspeed) speed = this.maxspeed; var a = Math.atan2(this.dy, this.dx); this.dx = speed * Math.cos(a); this.dy = speed * Math.sin(a); }; Acts.prototype.SetMaxSpeed = function (maxspeed) { this.maxspeed = maxspeed; if (this.maxspeed < 0) this.maxspeed = 0; }; Acts.prototype.SetAcceleration = function (acc) { this.acc = acc; if (this.acc < 0) this.acc = 0; }; Acts.prototype.SetDeceleration = function (dec) { this.dec = dec; if (this.dec < 0) this.dec = 0; }; Acts.prototype.SimulateControl = function (ctrl) { switch (ctrl) { case 0: this.simleft = true; break; case 1: this.simright = true; break; case 2: this.simup = true; break; case 3: this.simdown = true; break; } }; Acts.prototype.SetEnabled = function (en) { this.enabled = (en === 1); }; Acts.prototype.SetVectorX = function (x_) { this.dx = x_; }; Acts.prototype.SetVectorY = function (y_) { this.dy = y_; }; behaviorProto.acts = new Acts(); function Exps() {}; Exps.prototype.Speed = function (ret) { ret.set_float(Math.sqrt(this.dx * this.dx + this.dy * this.dy)); }; Exps.prototype.MaxSpeed = function (ret) { ret.set_float(this.maxspeed); }; Exps.prototype.Acceleration = function (ret) { ret.set_float(this.acc); }; Exps.prototype.Deceleration = function (ret) { ret.set_float(this.dec); }; Exps.prototype.MovingAngle = function (ret) { ret.set_float(cr.to_degrees(Math.atan2(this.dy, this.dx))); }; Exps.prototype.VectorX = function (ret) { ret.set_float(this.dx); }; Exps.prototype.VectorY = function (ret) { ret.set_float(this.dy); }; behaviorProto.exps = new Exps(); }()); ; ; cr.behaviors.Fade = function(runtime) { this.runtime = runtime; }; (function () { var behaviorProto = cr.behaviors.Fade.prototype; behaviorProto.Type = function(behavior, objtype) { this.behavior = behavior; this.objtype = objtype; this.runtime = behavior.runtime; }; var behtypeProto = behaviorProto.Type.prototype; behtypeProto.onCreate = function() { }; behaviorProto.Instance = function(type, inst) { this.type = type; this.behavior = type.behavior; this.inst = inst; // associated object instance to modify this.runtime = type.runtime; }; var behinstProto = behaviorProto.Instance.prototype; behinstProto.onCreate = function() { this.activeAtStart = this.properties[0] === 1; this.setMaxOpacity = false; // used to retrieve maxOpacity once in first 'Start fade' action if initially inactive this.fadeInTime = this.properties[1]; this.waitTime = this.properties[2]; this.fadeOutTime = this.properties[3]; this.destroy = this.properties[4]; // 0 = no, 1 = after fade out this.stage = this.activeAtStart ? 0 : 3; // 0 = fade in, 1 = wait, 2 = fade out, 3 = done if (this.recycled) this.stageTime.reset(); else this.stageTime = new cr.KahanAdder(); this.maxOpacity = (this.inst.opacity ? this.inst.opacity : 1.0); if (this.activeAtStart) { if (this.fadeInTime === 0) { this.stage = 1; if (this.waitTime === 0) this.stage = 2; } else { this.inst.opacity = 0; this.runtime.redraw = true; } } }; behinstProto.saveToJSON = function () { return { "fit": this.fadeInTime, "wt": this.waitTime, "fot": this.fadeOutTime, "s": this.stage, "st": this.stageTime.sum, "mo": this.maxOpacity, }; }; behinstProto.loadFromJSON = function (o) { this.fadeInTime = o["fit"]; this.waitTime = o["wt"]; this.fadeOutTime = o["fot"]; this.stage = o["s"]; this.stageTime.reset(); this.stageTime.sum = o["st"]; this.maxOpacity = o["mo"]; }; behinstProto.tick = function () { this.stageTime.add(this.runtime.getDt(this.inst)); if (this.stage === 0) { this.inst.opacity = (this.stageTime.sum / this.fadeInTime) * this.maxOpacity; this.runtime.redraw = true; if (this.inst.opacity >= this.maxOpacity) { this.inst.opacity = this.maxOpacity; this.stage = 1; // wait stage this.stageTime.reset(); this.runtime.trigger(cr.behaviors.Fade.prototype.cnds.OnFadeInEnd, this.inst); } } if (this.stage === 1) { if (this.stageTime.sum >= this.waitTime) { this.stage = 2; // fade out stage this.stageTime.reset(); this.runtime.trigger(cr.behaviors.Fade.prototype.cnds.OnWaitEnd, this.inst); } } if (this.stage === 2) { if (this.fadeOutTime !== 0) { this.inst.opacity = this.maxOpacity - ((this.stageTime.sum / this.fadeOutTime) * this.maxOpacity); this.runtime.redraw = true; if (this.inst.opacity < 0) { this.inst.opacity = 0; this.stage = 3; // done this.stageTime.reset(); this.runtime.trigger(cr.behaviors.Fade.prototype.cnds.OnFadeOutEnd, this.inst); if (this.destroy === 1) this.runtime.DestroyInstance(this.inst); } } } }; behinstProto.doStart = function () { this.stage = 0; this.stageTime.reset(); if (this.fadeInTime === 0) { this.stage = 1; if (this.waitTime === 0) this.stage = 2; } else { this.inst.opacity = 0; this.runtime.redraw = true; } }; function Cnds() {}; Cnds.prototype.OnFadeOutEnd = function () { return true; }; Cnds.prototype.OnFadeInEnd = function () { return true; }; Cnds.prototype.OnWaitEnd = function () { return true; }; behaviorProto.cnds = new Cnds(); function Acts() {}; Acts.prototype.StartFade = function () { if (!this.activeAtStart && !this.setMaxOpacity) { this.maxOpacity = (this.inst.opacity ? this.inst.opacity : 1.0); this.setMaxOpacity = true; } if (this.stage === 3) this.doStart(); }; Acts.prototype.RestartFade = function () { this.doStart(); }; Acts.prototype.SetFadeInTime = function (t) { if (t < 0) t = 0; this.fadeInTime = t; }; Acts.prototype.SetWaitTime = function (t) { if (t < 0) t = 0; this.waitTime = t; }; Acts.prototype.SetFadeOutTime = function (t) { if (t < 0) t = 0; this.fadeOutTime = t; }; behaviorProto.acts = new Acts(); function Exps() {}; Exps.prototype.FadeInTime = function (ret) { ret.set_float(this.fadeInTime); }; Exps.prototype.WaitTime = function (ret) { ret.set_float(this.waitTime); }; Exps.prototype.FadeOutTime = function (ret) { ret.set_float(this.fadeOutTime); }; behaviorProto.exps = new Exps(); }()); ; ; cr.behaviors.Flash = function(runtime) { this.runtime = runtime; }; (function () { var behaviorProto = cr.behaviors.Flash.prototype; behaviorProto.Type = function(behavior, objtype) { this.behavior = behavior; this.objtype = objtype; this.runtime = behavior.runtime; }; var behtypeProto = behaviorProto.Type.prototype; behtypeProto.onCreate = function() { }; behaviorProto.Instance = function(type, inst) { this.type = type; this.behavior = type.behavior; this.inst = inst; // associated object instance to modify this.runtime = type.runtime; }; var behinstProto = behaviorProto.Instance.prototype; behinstProto.onCreate = function() { this.ontime = 0; this.offtime = 0; this.stage = 0; // 0 = on, 1 = off this.stagetimeleft = 0; this.timeleft = 0; }; behinstProto.saveToJSON = function () { return { "ontime": this.ontime, "offtime": this.offtime, "stage": this.stage, "stagetimeleft": this.stagetimeleft, "timeleft": this.timeleft }; }; behinstProto.loadFromJSON = function (o) { this.ontime = o["ontime"]; this.offtime = o["offtime"]; this.stage = o["stage"]; this.stagetimeleft = o["stagetimeleft"]; this.timeleft = o["timeleft"]; if (this.timeleft === null) this.timeleft = Infinity; }; behinstProto.tick = function () { if (this.timeleft <= 0) return; // not flashing var dt = this.runtime.getDt(this.inst); this.timeleft -= dt; if (this.timeleft <= 0) { this.timeleft = 0; this.inst.visible = true; this.runtime.redraw = true; this.runtime.trigger(cr.behaviors.Flash.prototype.cnds.OnFlashEnded, this.inst); return; } this.stagetimeleft -= dt; if (this.stagetimeleft <= 0) { if (this.stage === 0) { this.inst.visible = false; this.stage = 1; this.stagetimeleft += this.offtime; } else { this.inst.visible = true; this.stage = 0; this.stagetimeleft += this.ontime; } this.runtime.redraw = true; } }; function Cnds() {}; Cnds.prototype.IsFlashing = function () { return this.timeleft > 0; }; Cnds.prototype.OnFlashEnded = function () { return true; }; behaviorProto.cnds = new Cnds(); function Acts() {}; Acts.prototype.Flash = function (on_, off_, dur_) { this.ontime = on_; this.offtime = off_; this.stage = 1; // always start off this.stagetimeleft = off_; this.timeleft = dur_; this.inst.visible = false; this.runtime.redraw = true; }; Acts.prototype.StopFlashing = function () { this.timeleft = 0; this.inst.visible = true; this.runtime.redraw = true; return; }; behaviorProto.acts = new Acts(); function Exps() {}; behaviorProto.exps = new Exps(); }()); ; ; cr.behaviors.LOS = function(runtime) { this.runtime = runtime; }; (function () { var behaviorProto = cr.behaviors.LOS.prototype; behaviorProto.Type = function(behavior, objtype) { this.behavior = behavior; this.objtype = objtype; this.runtime = behavior.runtime; }; var behtypeProto = behaviorProto.Type.prototype; behtypeProto.onCreate = function() { this.obstacleTypes = []; // object types to check for as obstructions }; behtypeProto.findLosBehavior = function (inst) { var i, len, b; for (i = 0, len = inst.behavior_insts.length; i < len; ++i) { b = inst.behavior_insts[i]; if (b instanceof cr.behaviors.LOS.prototype.Instance && b.type === this) return b; } return null; }; behaviorProto.Instance = function(type, inst) { this.type = type; this.behavior = type.behavior; this.inst = inst; // associated object instance to modify this.runtime = type.runtime; }; var behinstProto = behaviorProto.Instance.prototype; behinstProto.onCreate = function() { this.obstacleMode = this.properties[0]; // 0 = solids, 1 = custom this.range = this.properties[1]; this.cone = cr.to_radians(this.properties[2]); this.useCollisionCells = (this.properties[3] !== 0); }; behinstProto.onDestroy = function () { }; behinstProto.saveToJSON = function () { var o = { "r": this.range, "c": this.cone, "t": [] }; var i, len; for (i = 0, len = this.type.obstacleTypes.length; i < len; i++) { o["t"].push(this.type.obstacleTypes[i].sid); } return o; }; behinstProto.loadFromJSON = function (o) { this.range = o["r"]; this.cone = o["c"]; cr.clearArray(this.type.obstacleTypes); var i, len, t; for (i = 0, len = o["t"].length; i < len; i++) { t = this.runtime.getObjectTypeBySid(o["t"][i]); if (t) this.type.obstacleTypes.push(t); } }; behinstProto.tick = function () { }; var candidates = []; var tmpRect = new cr.rect(0, 0, 0, 0); behinstProto.hasLOSto = function (x_, y_) { var startx = this.inst.x; var starty = this.inst.y; var myangle = this.inst.angle; if (this.inst.width < 0) myangle += Math.PI; if (cr.distanceTo(startx, starty, x_, y_) > this.range) return false; // too far away var a = cr.angleTo(startx, starty, x_, y_); if (cr.angleDiff(myangle, a) > this.cone / 2) return false; // outside cone of view var i, leni, rinst, solid; tmpRect.set(startx, starty, x_, y_); tmpRect.normalize(); if (this.obstacleMode === 0) { if (this.useCollisionCells) { this.runtime.getSolidCollisionCandidates(this.inst.layer, tmpRect, candidates); } else { solid = this.runtime.getSolidBehavior(); if (solid) cr.appendArray(candidates, solid.my_instances.valuesRef()); } for (i = 0, leni = candidates.length; i < leni; ++i) { rinst = candidates[i]; if (!rinst.extra["solidEnabled"] || rinst === this.inst) continue; if (this.runtime.testSegmentOverlap(startx, starty, x_, y_, rinst)) { cr.clearArray(candidates); return false; } } } else { if (this.useCollisionCells) { this.runtime.getTypesCollisionCandidates(this.inst.layer, this.type.obstacleTypes, tmpRect, candidates); } else { for (i = 0, leni = this.type.obstacleTypes.length; i < leni; ++i) { cr.appendArray(candidates, this.type.obstacleTypes[i].instances); } } for (i = 0, leni = candidates.length; i < leni; ++i) { rinst = candidates[i]; if (rinst === this.inst) continue; if (this.runtime.testSegmentOverlap(startx, starty, x_, y_, rinst)) { cr.clearArray(candidates); return false; } } } cr.clearArray(candidates); return true; }; function Cnds() {}; var ltopick = new cr.ObjectSet(); var rtopick = new cr.ObjectSet(); Cnds.prototype.HasLOSToObject = function (obj_) { if (!obj_) return false; var i, j, leni, lenj, linst, losbeh, rinst, pick; var lsol = this.runtime.getCurrentConditionObjectType().getCurrentSol(); var rsol = obj_.getCurrentSol(); var linstances = lsol.getObjects(); var rinstances = rsol.getObjects(); if (lsol.select_all) cr.clearArray(lsol.else_instances); if (rsol.select_all) cr.clearArray(rsol.else_instances); var inverted = this.runtime.getCurrentCondition().inverted; for (i = 0, leni = linstances.length; i < leni; ++i) { linst = linstances[i]; pick = false; losbeh = this.findLosBehavior(linst); ; for (j = 0, lenj = rinstances.length; j < lenj; ++j) { rinst = rinstances[j]; if (linst !== rinst && cr.xor(losbeh.hasLOSto(rinst.x, rinst.y), inverted)) { pick = true; rtopick.add(rinst); } } if (pick) ltopick.add(linst); } var lpicks = ltopick.valuesRef(); var rpicks = rtopick.valuesRef(); lsol.select_all = false; rsol.select_all = false; cr.shallowAssignArray(lsol.instances, lpicks); cr.shallowAssignArray(rsol.instances, rpicks); ltopick.clear(); rtopick.clear(); return lsol.hasObjects(); }; Cnds.prototype.HasLOSToPosition = function (x_, y_) { return this.hasLOSto(x_, y_); }; behaviorProto.cnds = new Cnds(); function Acts() {}; Acts.prototype.SetRange = function (r) { this.range = r; }; Acts.prototype.SetCone = function (c) { this.cone = cr.to_radians(c); }; Acts.prototype.AddObstacle = function (obj_) { var obstacleTypes = this.type.obstacleTypes; if (obstacleTypes.indexOf(obj_) !== -1) return; var i, len, t; for (i = 0, len = obstacleTypes.length; i < len; i++) { t = obstacleTypes[i]; if (t.is_family && t.members.indexOf(obj_) !== -1) return; } obstacleTypes.push(obj_); }; Acts.prototype.ClearObstacles = function () { cr.clearArray(this.type.obstacleTypes); }; behaviorProto.acts = new Acts(); function Exps() {}; Exps.prototype.Range = function (ret) { ret.set_float(this.range); }; Exps.prototype.ConeOfView = function (ret) { ret.set_float(cr.to_degrees(this.cone)); }; behaviorProto.exps = new Exps(); }()); ; ; cr.behaviors.Persist = function(runtime) { this.runtime = runtime; }; (function () { var behaviorProto = cr.behaviors.Persist.prototype; behaviorProto.Type = function(behavior, objtype) { this.behavior = behavior; this.objtype = objtype; this.runtime = behavior.runtime; }; var behtypeProto = behaviorProto.Type.prototype; behtypeProto.onCreate = function() { }; behaviorProto.Instance = function(type, inst) { this.type = type; this.behavior = type.behavior; this.inst = inst; // associated object instance to modify this.runtime = type.runtime; }; var behinstProto = behaviorProto.Instance.prototype; behinstProto.onCreate = function() { this.myProperty = this.properties[0]; }; behinstProto.onDestroy = function () { }; behinstProto.tick = function () { var dt = this.runtime.getDt(this.inst); }; function Cnds() {}; behaviorProto.cnds = new Cnds(); function Acts() {}; behaviorProto.acts = new Acts(); function Exps() {}; behaviorProto.exps = new Exps(); }()); var Box2D = (function () { function c(a){throw a;}var d=void 0,aa=!0,ba=null,ca=!1,e;e||(e=eval("(function() { try { return Module || {} } catch(e) { return {} } })()"));var da={},ea;for(ea in e)e.hasOwnProperty(ea)&&(da[ea]=e[ea]);var fa="object"===typeof process&&"function"===typeof require,ga="object"===typeof window,ia="function"===typeof importScripts,ja=!ga&&!fa&&!ia; if(fa){e.print||(e.print=function(a){process.stdout.write(a+"\n")});e.printErr||(e.printErr=function(a){process.stderr.write(a+"\n")});var ka=require("fs"),la=require("path");e.read=function(a,b){var a=la.normalize(a),f=ka.readFileSync(a);!f&&a!=la.resolve(a)&&(a=path.join(__dirname,"..","src",a),f=ka.readFileSync(a));f&&!b&&(f=f.toString());return f};e.readBinary=function(a){return e.read(a,aa)};e.load=function(a){ma(read(a))};e.thisProgram=1 0) var gc = undefined")):ga||ia?(e.read=function(a){var b=new XMLHttpRequest;b.open("GET",a,ca);b.send(ba);return b.responseText},"undefined"!=typeof arguments&&(e.arguments=arguments),"undefined"!==typeof console?(e.print||(e.print=function(a){console.log(a)}),e.printErr||(e.printErr=function(a){console.log(a)})):e.print||(e.print= function(){}),ga?window.Module=e:e.load=importScripts):c("Unknown runtime environment. Where are we?");function ma(a){eval.call(ba,a)}!e.load&&e.read&&(e.load=function(a){ma(e.read(a))});e.print||(e.print=function(){});e.printErr||(e.printErr=e.print);e.arguments||(e.arguments=[]);e.thisProgram||(e.thisProgram="./this.program");e.print=e.print;e.n=e.printErr;e.preRun=[];e.postRun=[];for(ea in da)da.hasOwnProperty(ea)&&(e[ea]=da[ea]); var h={ga:function(a){qa=a},aa:function(){return qa},A:function(){return ra},J:function(a){ra=a},Q:function(a){switch(a){case "i1":case "i8":return 1;case "i16":return 2;case "i32":return 4;case "i64":return 8;case "float":return 4;case "double":return 8;default:return"*"===a[a.length-1]?h.B:"i"===a[0]?(a=parseInt(a.substr(1)),oa(0===a%8),a/8):0}},P:function(a){return Math.max(h.Q(a),h.B)},ha:16,ua:function(a,b,f){return!f&&("i64"==a||"double"==a)?8:!a?Math.min(b,8):Math.min(b||(a?h.P(a):0),h.B)}, r:function(a,b,f){return f&&f.length?(f.splice||(f=Array.prototype.slice.call(f)),f.splice(0,0,b),e["dynCall_"+a].apply(ba,f)):e["dynCall_"+a].call(ba,b)},p:[ba,ba,ba,ba,ba,ba,ba,ba,ba,ba,ba,ba,ba,ba,ba,ba,ba,ba,ba,ba],V:function(a){for(var b=0;b=ya&&ua("Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value "+ya+", (2) compile with ALLOW_MEMORY_GROWTH which adjusts the size at runtime but prevents some optimizations, or (3) set Module.TOTAL_MEMORY before the program runs.");return b},C:function(a,b){return Math.ceil(a/(b?b:16))*(b?b:16)},ca:function(a,b,f){return f?+(a>>>0)+4294967296*+(b>>>0):+(a>>> 0)+4294967296*+(b|0)},L:8,B:4,ia:0};e.Runtime=h;h.addFunction=h.V;h.removeFunction=h.fa;var za=ca,Ba,Da,qa;function oa(a,b){a||ua("Assertion failed: "+b)}function Ea(a){var b=e["_"+a];if(!b)try{b=eval("_"+a)}catch(f){}oa(b,"Cannot call unknown function "+a+" (perhaps LLVM optimizations or closure removed it?)");return b}var Fa,Ga; (function(){function a(a){a=a.toString().match(k).slice(1);return{arguments:a[0],body:a[1],returnValue:a[2]}}var b=0,f={stackSave:function(){b=h.A()},stackRestore:function(){h.J(b)},arrayToC:function(a){var b=h.u(a.length);Ha(a,b);return b},stringToC:function(a){var b=0;a!==ba&&(a!==d&&0!==a)&&(b=h.u((a.length<<2)+1),Ia(a,b));return b}},g={string:f.stringToC,array:f.arrayToC};Ga=function(a,k,m,n){var a=Ea(a),ta=[];if(n)for(var Aa=0;Aa>0]=b;break;case "i8":Ka[a>>0]=b;break;case "i16":La[a>>1]=b;break;case "i32":Ma[a>>2]=b;break;case "i64":Da=[b>>>0,(Ba=b,1<=+Oa(Ba)?0>>0:~~+Ra((Ba-+(~~Ba>>>0))/4294967296)>>>0:0)];Ma[a>>2]=Da[0];Ma[a+4>>2]=Da[1];break;case "float":Sa[a>>2]=b;break;case "double":Ta[a>>3]=b;break;default:ua("invalid type for setValue: "+f)}}e.setValue=Ja; function Ua(a,b){b=b||"i8";"*"===b.charAt(b.length-1)&&(b="i32");switch(b){case "i1":return Ka[a>>0];case "i8":return Ka[a>>0];case "i16":return La[a>>1];case "i32":return Ma[a>>2];case "i64":return Ma[a>>2];case "float":return Sa[a>>2];case "double":return Ta[a>>3];default:ua("invalid type for setValue: "+b)}return ba}e.getValue=Ua;var Wa=1,Xa=2,Za=4;e.ALLOC_NORMAL=0;e.ALLOC_STACK=Wa;e.ALLOC_STATIC=Xa;e.ALLOC_DYNAMIC=3;e.ALLOC_NONE=Za; function $a(a,b,f,g){var k,n;"number"===typeof a?(k=aa,n=a):(k=ca,n=a.length);var m="string"===typeof b?b:ba,f=f==Za?g:[ab,h.u,h.U,h.o][f===d?Xa:f](Math.max(n,m?1:b.length));if(k){g=f;oa(0==(f&3));for(a=f+(n&-4);g>2]=0;for(a=f+n;g>0]=0;return f}if("i8"===m)return a.subarray||a.slice?bb.set(a,f):bb.set(new Uint8Array(a),f),f;for(var g=0,l,ha;g>0];if(128<=g)f=aa;else if(0==g&&!b)break;k++;if(b&&k==b)break}b||(b=k);var n="";if(!f){for(;0>0],n+=f.da(g);return n}e.Pointer_stringify=sa;e.UTF16ToString=function(a){for(var b=0,f="";;){var g=La[a+2*b>>1];if(0==g)return f;++b;f+=String.fromCharCode(g)}}; e.stringToUTF16=function(a,b){for(var f=0;f>1]=a.charCodeAt(f);La[b+2*a.length>>1]=0};e.UTF32ToString=function(a){for(var b=0,f="";;){var g=Ma[a+4*b>>2];if(0==g)return f;++b;65536<=g?(g-=65536,f+=String.fromCharCode(55296|g>>10,56320|g&1023)):f+=String.fromCharCode(g)}};e.stringToUTF32=function(a,b){for(var f=0,g=0;g=k)var n=a.charCodeAt(++g),k=65536+((k&1023)<<10)|n&1023;Ma[b+4*f>>2]=k;++f}Ma[b+4*f>>2]=0}; function cb(a){function b(f,g,k){var g=g||Infinity,m="",n=[],V;if("N"===a[l]){l++;"K"===a[l]&&l++;for(V=[];"E"!==a[l];)if("S"===a[l]){l++;var pa=a.indexOf("_",l);V.push(Na[a.substring(l,pa)||0]||"?");l=pa+1}else if("C"===a[l])V.push(V[V.length-1]),l+=2;else{var pa=parseInt(a.substr(l)),x=pa.toString().length;if(!pa||!x){l--;break}var ta=a.substr(l+x,pa);V.push(ta);Na.push(ta);l+=x+pa}l++;V=V.join("::");g--;if(0===g)return f?[V]:V}else if(("K"===a[l]||Ya&&"L"===a[l])&&l++,pa=parseInt(a.substr(l)))x= pa.toString().length,V=a.substr(l+x,pa),l+=x+pa;Ya=ca;"I"===a[l]?(l++,pa=b(aa),x=b(aa,1,aa),m+=x[0]+" "+V+"<"+pa.join(", ")+">"):m=V;a:for(;lob?2*ob:ob+16777216; ob!==ya&&(e.n("increasing TOTAL_MEMORY to "+ob+" to be compliant with the asm.js spec"),ya=ob);oa("undefined"!==typeof Int32Array&&"undefined"!==typeof Float64Array&&!!(new Int32Array(1)).subarray&&!!(new Int32Array(1)).set,"JS engine does not provide full typed array support");var pb=new ArrayBuffer(ya);Ka=new Int8Array(pb);La=new Int16Array(pb);Ma=new Int32Array(pb);bb=new Uint8Array(pb);gb=new Uint16Array(pb);hb=new Uint32Array(pb);Sa=new Float32Array(pb);Ta=new Float64Array(pb);Ma[0]=255; oa(255===bb[0]&&0===bb[3],"Typed arrays 2 must be run on a little-endian system");e.HEAP=d;e.buffer=pb;e.HEAP8=Ka;e.HEAP16=La;e.HEAP32=Ma;e.HEAPU8=bb;e.HEAPU16=gb;e.HEAPU32=hb;e.HEAPF32=Sa;e.HEAPF64=Ta;function qb(a){for(;0>0]=a[f],f+=1}e.writeStringToMemory=Ia; function Ha(a,b){for(var f=0;f>0]=a[f]}e.writeArrayToMemory=Ha;e.writeAsciiToMemory=function(a,b,f){for(var g=0;g>0]=a.charCodeAt(g);f||(Ka[b+a.length>>0]=0)};function Cb(a,b){return 0<=a?a:32>=b?2*Math.abs(1<=a)return a;var f=32>=b?Math.abs(1<=f&&(32>=b||a>f))a=-2*f+a;return a} if(!Math.imul||-5!==Math.imul(4294967295,5))Math.imul=function(a,b){var f=a&65535,g=b&65535;return f*g+((a>>>16)*g+f*(b>>>16)<<16)|0};Math.za=Math.imul;var Oa=Math.abs,Eb=Math.cos,Fb=Math.sin,Gb=Math.atan2,Hb=Math.sqrt,Ra=Math.ceil,Qa=Math.floor,Pa=Math.min,Ib=0,Jb=ba,Kb=ba;function Lb(){Ib++;e.monitorRunDependencies&&e.monitorRunDependencies(Ib)}e.addRunDependency=Lb; function Mb(){Ib--;e.monitorRunDependencies&&e.monitorRunDependencies(Ib);if(0==Ib&&(Jb!==ba&&(clearInterval(Jb),Jb=ba),Kb)){var a=Kb;Kb=ba;a()}}e.removeRunDependency=Mb;e.preloadedImages={};e.preloadedAudios={};var Nb=ba,jb=8,wa=jb+19344;sb.push(); $a([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,200,3,0,0,42,0,0,0,43,0,0,0,42,0,0,0,43,0,0,0,42,0,0,0,42,0,0,0,44,0,0,0,42,0,0,0,54,74,83,68,114,97,119,0,54,98,50,68,114,97,119,0,184,72,0,0,184,3,0,0,224,72,0,0,176,3,0,0,192,3,0,0,0,0,0,0,123,32,118, 97,114,32,115,101,108,102,32,61,32,77,111,100,117,108,101,91,39,103,101,116,67,97,99,104,101,39,93,40,77,111,100,117,108,101,91,39,74,83,68,114,97,119,39,93,41,91,36,48,93,59,32,105,102,32,40,33,115,101,108,102,46,104,97,115,79,119,110,80,114,111,112,101,114,116,121,40,39,68,114,97,119,84,114,97,110,115,102,111,114,109,39,41,41,32,116,104,114,111,119,32,39,97,32,74,83,73,109,112,108,101,109,101,110,116,97,116,105,111,110,32,109,117,115,116,32,105,109,112,108,101,109,101,110,116,32,97,108,108,32,102, 117,110,99,116,105,111,110,115,44,32,121,111,117,32,102,111,114,103,111,116,32,74,83,68,114,97,119,58,58,68,114,97,119,84,114,97,110,115,102,111,114,109,46,39,59,32,115,101,108,102,46,68,114,97,119,84,114,97,110,115,102,111,114,109,40,36,49,41,59,32,125,0,123,32,118,97,114,32,115,101,108,102,32,61,32,77,111,100,117,108,101,91,39,103,101,116,67,97,99,104,101,39,93,40,77,111,100,117,108,101,91,39,74,83,68,114,97,119,39,93,41,91,36,48,93,59,32,105,102,32,40,33,115,101,108,102,46,104,97,115,79,119,110, 80,114,111,112,101,114,116,121,40,39,68,114,97,119,83,101,103,109,101,110,116,39,41,41,32,116,104,114,111,119,32,39,97,32,74,83,73,109,112,108,101,109,101,110,116,97,116,105,111,110,32,109,117,115,116,32,105,109,112,108,101,109,101,110,116,32,97,108,108,32,102,117,110,99,116,105,111,110,115,44,32,121,111,117,32,102,111,114,103,111,116,32,74,83,68,114,97,119,58,58,68,114,97,119,83,101,103,109,101,110,116,46,39,59,32,115,101,108,102,46,68,114,97,119,83,101,103,109,101,110,116,40,36,49,44,36,50,44,36, 51,41,59,32,125,0,123,32,118,97,114,32,115,101,108,102,32,61,32,77,111,100,117,108,101,91,39,103,101,116,67,97,99,104,101,39,93,40,77,111,100,117,108,101,91,39,74,83,68,114,97,119,39,93,41,91,36,48,93,59,32,105,102,32,40,33,115,101,108,102,46,104,97,115,79,119,110,80,114,111,112,101,114,116,121,40,39,68,114,97,119,83,111,108,105,100,67,105,114,99,108,101,39,41,41,32,116,104,114,111,119,32,39,97,32,74,83,73,109,112,108,101,109,101,110,116,97,116,105,111,110,32,109,117,115,116,32,105,109,112,108,101, 109,101,110,116,32,97,108,108,32,102,117,110,99,116,105,111,110,115,44,32,121,111,117,32,102,111,114,103,111,116,32,74,83,68,114,97,119,58,58,68,114,97,119,83,111,108,105,100,67,105,114,99,108,101,46,39,59,32,115,101,108,102,46,68,114,97,119,83,111,108,105,100,67,105,114,99,108,101,40,36,49,44,36,50,44,36,51,44,36,52,41,59,32,125,0,0,123,32,118,97,114,32,115,101,108,102,32,61,32,77,111,100,117,108,101,91,39,103,101,116,67,97,99,104,101,39,93,40,77,111,100,117,108,101,91,39,74,83,68,114,97,119,39, 93,41,91,36,48,93,59,32,105,102,32,40,33,115,101,108,102,46,104,97,115,79,119,110,80,114,111,112,101,114,116,121,40,39,68,114,97,119,67,105,114,99,108,101,39,41,41,32,116,104,114,111,119,32,39,97,32,74,83,73,109,112,108,101,109,101,110,116,97,116,105,111,110,32,109,117,115,116,32,105,109,112,108,101,109,101,110,116,32,97,108,108,32,102,117,110,99,116,105,111,110,115,44,32,121,111,117,32,102,111,114,103,111,116,32,74,83,68,114,97,119,58,58,68,114,97,119,67,105,114,99,108,101,46,39,59,32,115,101,108, 102,46,68,114,97,119,67,105,114,99,108,101,40,36,49,44,36,50,44,36,51,41,59,32,125,0,0,0,0,123,32,118,97,114,32,115,101,108,102,32,61,32,77,111,100,117,108,101,91,39,103,101,116,67,97,99,104,101,39,93,40,77,111,100,117,108,101,91,39,74,83,68,114,97,119,39,93,41,91,36,48,93,59,32,105,102,32,40,33,115,101,108,102,46,104,97,115,79,119,110,80,114,111,112,101,114,116,121,40,39,68,114,97,119,83,111,108,105,100,80,111,108,121,103,111,110,39,41,41,32,116,104,114,111,119,32,39,97,32,74,83,73,109,112,108,101, 109,101,110,116,97,116,105,111,110,32,109,117,115,116,32,105,109,112,108,101,109,101,110,116,32,97,108,108,32,102,117,110,99,116,105,111,110,115,44,32,121,111,117,32,102,111,114,103,111,116,32,74,83,68,114,97,119,58,58,68,114,97,119,83,111,108,105,100,80,111,108,121,103,111,110,46,39,59,32,115,101,108,102,46,68,114,97,119,83,111,108,105,100,80,111,108,121,103,111,110,40,36,49,44,36,50,44,36,51,41,59,32,125,0,0,123,32,118,97,114,32,115,101,108,102,32,61,32,77,111,100,117,108,101,91,39,103,101,116, 67,97,99,104,101,39,93,40,77,111,100,117,108,101,91,39,74,83,68,114,97,119,39,93,41,91,36,48,93,59,32,105,102,32,40,33,115,101,108,102,46,104,97,115,79,119,110,80,114,111,112,101,114,116,121,40,39,68,114,97,119,80,111,108,121,103,111,110,39,41,41,32,116,104,114,111,119,32,39,97,32,74,83,73,109,112,108,101,109,101,110,116,97,116,105,111,110,32,109,117,115,116,32,105,109,112,108,101,109,101,110,116,32,97,108,108,32,102,117,110,99,116,105,111,110,115,44,32,121,111,117,32,102,111,114,103,111,116,32,74, 83,68,114,97,119,58,58,68,114,97,119,80,111,108,121,103,111,110,46,39,59,32,115,101,108,102,46,68,114,97,119,80,111,108,121,103,111,110,40,36,49,44,36,50,44,36,51,41,59,32,125,0,0,0,0,0,56,9,0,0,44,0,0,0,45,0,0,0,42,0,0,0,0,0,0,0,49,53,74,83,67,111,110,116,97,99,116,70,105,108,116,101,114,0,0,0,0,0,0,0,224,72,0,0,32,9,0,0,88,47,0,0,0,0,0,0,123,32,118,97,114,32,115,101,108,102,32,61,32,77,111,100,117,108,101,91,39,103,101,116,67,97,99,104,101,39,93,40,77,111,100,117,108,101,91,39,74,83,67,111,110, 116,97,99,116,70,105,108,116,101,114,39,93,41,91,36,48,93,59,32,105,102,32,40,33,115,101,108,102,46,104,97,115,79,119,110,80,114,111,112,101,114,116,121,40,39,83,104,111,117,108,100,67,111,108,108,105,100,101,39,41,41,32,116,104,114,111,119,32,39,97,32,74,83,73,109,112,108,101,109,101,110,116,97,116,105,111,110,32,109,117,115,116,32,105,109,112,108,101,109,101,110,116,32,97,108,108,32,102,117,110,99,116,105,111,110,115,44,32,121,111,117,32,102,111,114,103,111,116,32,74,83,67,111,110,116,97,99,116, 70,105,108,116,101,114,58,58,83,104,111,117,108,100,67,111,108,108,105,100,101,46,39,59,32,114,101,116,117,114,110,32,115,101,108,102,46,83,104,111,117,108,100,67,111,108,108,105,100,101,40,36,49,44,36,50,41,59,32,125,0,0,0,0,0,66,111,120,50,68,95,118,50,46,51,46,49,47,66,111,120,50,68,47,67,111,108,108,105,115,105,111,110,47,83,104,97,112,101,115,47,98,50,80,111,108,121,103,111,110,83,104,97,112,101,46,104,0,0,0,0,0,0,0,0,208,10,0,0,46,0,0,0,47,0,0,0,43,0,0,0,44,0,0,0,42,0,0,0,43,0,0,0,49,55,74, 83,67,111,110,116,97,99,116,76,105,115,116,101,110,101,114,0,0,0,0,0,49,55,98,50,67,111,110,116,97,99,116,76,105,115,116,101,110,101,114,0,0,0,0,0,184,72,0,0,176,10,0,0,224,72,0,0,152,10,0,0,200,10,0,0,0,0,0,0,123,32,118,97,114,32,115,101,108,102,32,61,32,77,111,100,117,108,101,91,39,103,101,116,67,97,99,104,101,39,93,40,77,111,100,117,108,101,91,39,74,83,67,111,110,116,97,99,116,76,105,115,116,101,110,101,114,39,93,41,91,36,48,93,59,32,105,102,32,40,33,115,101,108,102,46,104,97,115,79,119,110,80, 114,111,112,101,114,116,121,40,39,69,110,100,67,111,110,116,97,99,116,39,41,41,32,116,104,114,111,119,32,39,97,32,74,83,73,109,112,108,101,109,101,110,116,97,116,105,111,110,32,109,117,115,116,32,105,109,112,108,101,109,101,110,116,32,97,108,108,32,102,117,110,99,116,105,111,110,115,44,32,121,111,117,32,102,111,114,103,111,116,32,74,83,67,111,110,116,97,99,116,76,105,115,116,101,110,101,114,58,58,69,110,100,67,111,110,116,97,99,116,46,39,59,32,115,101,108,102,46,69,110,100,67,111,110,116,97,99,116, 40,36,49,41,59,32,125,0,0,0,0,123,32,118,97,114,32,115,101,108,102,32,61,32,77,111,100,117,108,101,91,39,103,101,116,67,97,99,104,101,39,93,40,77,111,100,117,108,101,91,39,74,83,67,111,110,116,97,99,116,76,105,115,116,101,110,101,114,39,93,41,91,36,48,93,59,32,105,102,32,40,33,115,101,108,102,46,104,97,115,79,119,110,80,114,111,112,101,114,116,121,40,39,66,101,103,105,110,67,111,110,116,97,99,116,39,41,41,32,116,104,114,111,119,32,39,97,32,74,83,73,109,112,108,101,109,101,110,116,97,116,105,111,110, 32,109,117,115,116,32,105,109,112,108,101,109,101,110,116,32,97,108,108,32,102,117,110,99,116,105,111,110,115,44,32,121,111,117,32,102,111,114,103,111,116,32,74,83,67,111,110,116,97,99,116,76,105,115,116,101,110,101,114,58,58,66,101,103,105,110,67,111,110,116,97,99,116,46,39,59,32,115,101,108,102,46,66,101,103,105,110,67,111,110,116,97,99,116,40,36,49,41,59,32,125,0,0,0,0,0,0,0,0,0,0,8,13,0,0,48,0,0,0,49,0,0,0,42,0,0,0,0,0,0,0,49,55,74,83,82,97,121,67,97,115,116,67,97,108,108,98,97,99,107,0,0,0,0, 0,49,55,98,50,82,97,121,67,97,115,116,67,97,108,108,98,97,99,107,0,0,0,0,0,184,72,0,0,232,12,0,0,224,72,0,0,208,12,0,0,0,13,0,0,0,0,0,0,123,32,118,97,114,32,115,101,108,102,32,61,32,77,111,100,117,108,101,91,39,103,101,116,67,97,99,104,101,39,93,40,77,111,100,117,108,101,91,39,74,83,82,97,121,67,97,115,116,67,97,108,108,98,97,99,107,39,93,41,91,36,48,93,59,32,105,102,32,40,33,115,101,108,102,46,104,97,115,79,119,110,80,114,111,112,101,114,116,121,40,39,82,101,112,111,114,116,70,105,120,116,117,114, 101,39,41,41,32,116,104,114,111,119,32,39,97,32,74,83,73,109,112,108,101,109,101,110,116,97,116,105,111,110,32,109,117,115,116,32,105,109,112,108,101,109,101,110,116,32,97,108,108,32,102,117,110,99,116,105,111,110,115,44,32,121,111,117,32,102,111,114,103,111,116,32,74,83,82,97,121,67,97,115,116,67,97,108,108,98,97,99,107,58,58,82,101,112,111,114,116,70,105,120,116,117,114,101,46,39,59,32,114,101,116,117,114,110,32,115,101,108,102,46,82,101,112,111,114,116,70,105,120,116,117,114,101,40,36,49,44,36, 50,44,36,51,44,36,52,41,59,32,125,0,0,0,0,0,0,0,104,14,0,0,50,0,0,0,51,0,0,0,42,0,0,0,0,0,0,0,49,53,74,83,81,117,101,114,121,67,97,108,108,98,97,99,107,0,0,0,0,0,0,0,49,53,98,50,81,117,101,114,121,67,97,108,108,98,97,99,107,0,0,0,0,0,0,0,184,72,0,0,72,14,0,0,224,72,0,0,48,14,0,0,96,14,0,0,0,0,0,0,123,32,118,97,114,32,115,101,108,102,32,61,32,77,111,100,117,108,101,91,39,103,101,116,67,97,99,104,101,39,93,40,77,111,100,117,108,101,91,39,74,83,81,117,101,114,121,67,97,108,108,98,97,99,107,39,93,41, 91,36,48,93,59,32,105,102,32,40,33,115,101,108,102,46,104,97,115,79,119,110,80,114,111,112,101,114,116,121,40,39,82,101,112,111,114,116,70,105,120,116,117,114,101,39,41,41,32,116,104,114,111,119,32,39,97,32,74,83,73,109,112,108,101,109,101,110,116,97,116,105,111,110,32,109,117,115,116,32,105,109,112,108,101,109,101,110,116,32,97,108,108,32,102,117,110,99,116,105,111,110,115,44,32,121,111,117,32,102,111,114,103,111,116,32,74,83,81,117,101,114,121,67,97,108,108,98,97,99,107,58,58,82,101,112,111,114, 116,70,105,120,116,117,114,101,46,39,59,32,114,101,116,117,114,110,32,115,101,108,102,46,82,101,112,111,114,116,70,105,120,116,117,114,101,40,36,49,41,59,32,125,0,0,0,0,0,0,0,0,48,32,60,61,32,99,104,105,108,100,73,110,100,101,120,32,38,38,32,99,104,105,108,100,73,110,100,101,120,32,60,32,109,95,112,114,111,120,121,67,111,117,110,116,0,0,0,0,66,111,120,50,68,95,118,50,46,51,46,49,47,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,98,50,70,105,120,116,117,114,101,46,104,0,71,101,116,65,65,66,66, 0,98,50,73,115,86,97,108,105,100,40,100,101,110,115,105,116,121,41,32,38,38,32,100,101,110,115,105,116,121,32,62,61,32,48,46,48,102,0,0,0,83,101,116,68,101,110,115,105,116,121,0,0,0,0,0,0,0,0,0,0,152,16,0,0,52,0,0,0,53,0,0,0,45,0,0,0,46,0,0,0,47,0,0,0,48,0,0,0,50,49,74,83,68,101,115,116,114,117,99,116,105,111,110,76,105,115,116,101,110,101,114,0,50,56,98,50,68,101,115,116,114,117,99,116,105,111,110,76,105,115,116,101,110,101,114,87,114,97,112,112,101,114,0,0,50,49,98,50,68,101,115,116,114,117,99, 116,105,111,110,76,105,115,116,101,110,101,114,0,184,72,0,0,96,16,0,0,64,73,0,0,64,16,0,0,0,0,0,0,1,0,0,0,120,16,0,0,0,0,0,0,224,72,0,0,40,16,0,0,128,16,0,0,0,0,0,0,123,32,118,97,114,32,115,101,108,102,32,61,32,77,111,100,117,108,101,91,39,103,101,116,67,97,99,104,101,39,93,40,77,111,100,117,108,101,91,39,74,83,68,101,115,116,114,117,99,116,105,111,110,76,105,115,116,101,110,101,114,39,93,41,91,36,48,93,59,32,105,102,32,40,33,115,101,108,102,46,104,97,115,79,119,110,80,114,111,112,101,114,116,121, 40,39,83,97,121,71,111,111,100,98,121,101,70,105,120,116,117,114,101,39,41,41,32,116,104,114,111,119,32,39,97,32,74,83,73,109,112,108,101,109,101,110,116,97,116,105,111,110,32,109,117,115,116,32,105,109,112,108,101,109,101,110,116,32,97,108,108,32,102,117,110,99,116,105,111,110,115,44,32,121,111,117,32,102,111,114,103,111,116,32,74,83,68,101,115,116,114,117,99,116,105,111,110,76,105,115,116,101,110,101,114,58,58,83,97,121,71,111,111,100,98,121,101,70,105,120,116,117,114,101,46,39,59,32,115,101,108, 102,46,83,97,121,71,111,111,100,98,121,101,70,105,120,116,117,114,101,40,36,49,41,59,32,125,0,0,0,0,0,0,0,123,32,118,97,114,32,115,101,108,102,32,61,32,77,111,100,117,108,101,91,39,103,101,116,67,97,99,104,101,39,93,40,77,111,100,117,108,101,91,39,74,83,68,101,115,116,114,117,99,116,105,111,110,76,105,115,116,101,110,101,114,39,93,41,91,36,48,93,59,32,105,102,32,40,33,115,101,108,102,46,104,97,115,79,119,110,80,114,111,112,101,114,116,121,40,39,83,97,121,71,111,111,100,98,121,101,74,111,105,110,116, 39,41,41,32,116,104,114,111,119,32,39,97,32,74,83,73,109,112,108,101,109,101,110,116,97,116,105,111,110,32,109,117,115,116,32,105,109,112,108,101,109,101,110,116,32,97,108,108,32,102,117,110,99,116,105,111,110,115,44,32,121,111,117,32,102,111,114,103,111,116,32,74,83,68,101,115,116,114,117,99,116,105,111,110,76,105,115,116,101,110,101,114,58,58,83,97,121,71,111,111,100,98,121,101,74,111,105,110,116,46,39,59,32,115,101,108,102,46,83,97,121,71,111,111,100,98,121,101,74,111,105,110,116,40,36,49,41,59, 32,125,0,0,0,0,0,0,0,0,0,40,20,0,0,49,0,0,0,50,0,0,0,42,0,0,0,42,0,0,0,54,0,0,0,51,0,0,0,55,0,0,0,56,0,0,0,52,0,0,0,53,0,0,0,43,0,0,0,0,0,0,0,66,111,120,50,68,95,118,50,46,51,46,49,47,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,74,111,105,110,116,115,47,98,50,77,111,116,111,114,74,111,105,110,116,46,99,112,112,0,0,0,0,0,98,50,73,115,86,97,108,105,100,40,102,97,99,116,111,114,41,32,38,38,32,48,46,48,102,32,60,61,32,102,97,99,116,111,114,32,38,38,32,102,97,99,116,111,114,32,60,61,32,49,46,48, 102,0,0,0,83,101,116,67,111,114,114,101,99,116,105,111,110,70,97,99,116,111,114,0,0,0,0,0,32,32,98,50,77,111,116,111,114,74,111,105,110,116,68,101,102,32,106,100,59,10,0,0,32,32,106,100,46,108,105,110,101,97,114,79,102,102,115,101,116,46,83,101,116,40,37,46,49,53,108,101,102,44,32,37,46,49,53,108,101,102,41,59,10,0,0,0,0,0,0,0,32,32,106,100,46,97,110,103,117,108,97,114,79,102,102,115,101,116,32,61,32,37,46,49,53,108,101,102,59,10,0,0,32,32,106,100,46,99,111,114,114,101,99,116,105,111,110,70,97,99, 116,111,114,32,61,32,37,46,49,53,108,101,102,59,10,0,0,0,0,0,0,0,49,50,98,50,77,111,116,111,114,74,111,105,110,116,0,0,55,98,50,74,111,105,110,116,0,0,0,0,0,0,0,0,184,72,0,0,16,20,0,0,224,72,0,0,0,20,0,0,32,20,0,0,0,0,0,0,100,101,110,32,62,32,48,46,48,102,0,0,0,0,0,0,66,111,120,50,68,95,118,50,46,51,46,49,47,66,111,120,50,68,47,67,111,108,108,105,115,105,111,110,47,98,50,67,111,108,108,105,100,101,69,100,103,101,46,99,112,112,0,0,98,50,67,111,108,108,105,100,101,69,100,103,101,65,110,100,67,105,114, 99,108,101,0,0,48,32,60,61,32,101,100,103,101,49,32,38,38,32,101,100,103,101,49,32,60,32,112,111,108,121,49,45,62,109,95,99,111,117,110,116,0,0,0,0,66,111,120,50,68,95,118,50,46,51,46,49,47,66,111,120,50,68,47,67,111,108,108,105,115,105,111,110,47,98,50,67,111,108,108,105,100,101,80,111,108,121,103,111,110,46,99,112,112,0,0,0,0,0,0,0,98,50,70,105,110,100,73,110,99,105,100,101,110,116,69,100,103,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,48,32,60,61,32,105,110,100,101,120,32,38, 38,32,105,110,100,101,120,32,60,32,99,104,97,105,110,45,62,109,95,99,111,117,110,116,0,0,0,0,66,111,120,50,68,95,118,50,46,51,46,49,47,66,111,120,50,68,47,67,111,108,108,105,115,105,111,110,47,98,50,68,105,115,116,97,110,99,101,46,99,112,112,0,0,0,0,0,98,50,68,105,115,116,97,110,99,101,0,0,0,0,0,0,71,101,116,77,101,116,114,105,99,0,0,0,0,0,0,0,71,101,116,87,105,116,110,101,115,115,80,111,105,110,116,115,0,0,0,0,0,0,0,0,99,97,99,104,101,45,62,99,111,117,110,116,32,60,61,32,51,0,0,0,0,0,0,0,82,101, 97,100,67,97,99,104,101,0,0,0,0,0,0,0,109,95,110,111,100,101,67,111,117,110,116,32,61,61,32,109,95,110,111,100,101,67,97,112,97,99,105,116,121,0,0,0,66,111,120,50,68,95,118,50,46,51,46,49,47,66,111,120,50,68,47,67,111,108,108,105,115,105,111,110,47,98,50,68,121,110,97,109,105,99,84,114,101,101,46,99,112,112,0,0,65,108,108,111,99,97,116,101,78,111,100,101,0,0,0,0,48,32,60,61,32,110,111,100,101,73,100,32,38,38,32,110,111,100,101,73,100,32,60,32,109,95,110,111,100,101,67,97,112,97,99,105,116,121,0,0, 70,114,101,101,78,111,100,101,0,0,0,0,0,0,0,0,48,32,60,32,109,95,110,111,100,101,67,111,117,110,116,0,68,101,115,116,114,111,121,80,114,111,120,121,0,0,0,0,109,95,110,111,100,101,115,91,112,114,111,120,121,73,100,93,46,73,115,76,101,97,102,40,41,0,0,0,0,0,0,0,77,111,118,101,80,114,111,120,121,0,0,0,0,0,0,0,99,104,105,108,100,49,32,33,61,32,40,45,49,41,0,0,73,110,115,101,114,116,76,101,97,102,0,0,0,0,0,0,99,104,105,108,100,50,32,33,61,32,40,45,49,41,0,0,105,65,32,33,61,32,40,45,49,41,0,0,0,0,0,0,66, 97,108,97,110,99,101,0,48,32,60,61,32,105,66,32,38,38,32,105,66,32,60,32,109,95,110,111,100,101,67,97,112,97,99,105,116,121,0,0,48,32,60,61,32,105,67,32,38,38,32,105,67,32,60,32,109,95,110,111,100,101,67,97,112,97,99,105,116,121,0,0,48,32,60,61,32,105,70,32,38,38,32,105,70,32,60,32,109,95,110,111,100,101,67,97,112,97,99,105,116,121,0,0,48,32,60,61,32,105,71,32,38,38,32,105,71,32,60,32,109,95,110,111,100,101,67,97,112,97,99,105,116,121,0,0,109,95,110,111,100,101,115,91,67,45,62,112,97,114,101,110, 116,93,46,99,104,105,108,100,50,32,61,61,32,105,65,0,48,32,60,61,32,105,68,32,38,38,32,105,68,32,60,32,109,95,110,111,100,101,67,97,112,97,99,105,116,121,0,0,48,32,60,61,32,105,69,32,38,38,32,105,69,32,60,32,109,95,110,111,100,101,67,97,112,97,99,105,116,121,0,0,109,95,110,111,100,101,115,91,66,45,62,112,97,114,101,110,116,93,46,99,104,105,108,100,50,32,61,61,32,105,65,0,110,111,100,101,45,62,73,115,76,101,97,102,40,41,32,61,61,32,102,97,108,115,101,0,71,101,116,77,97,120,66,97,108,97,110,99,101, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,116,97,114,103,101,116,32,62,32,116,111,108,101,114,97,110,99,101,0,0,0,0,0,0,66,111,120,50,68,95,118,50,46,51,46,49,47,66,111,120,50,68,47,67,111,108,108,105,115,105,111,110,47,98,50,84,105,109,101,79,102,73,109,112,97,99,116,46,99,112,112,0,98,50,84,105,109,101,79,102,73,109,112,97,99,116,0,0,69,118,97,108,117,97,116,101,0,0,0,0,0,0,0,0,48,32,60,61,32,105,110,100,101,120,32,38,38,32,105,110,100,101,120,32,60,32, 109,95,99,111,117,110,116,0,0,0,66,111,120,50,68,95,118,50,46,51,46,49,47,66,111,120,50,68,47,67,111,108,108,105,115,105,111,110,47,98,50,68,105,115,116,97,110,99,101,46,104,0,0,0,0,0,0,0,71,101,116,86,101,114,116,101,120,0,0,0,0,0,0,0,70,105,110,100,77,105,110,83,101,112,97,114,97,116,105,111,110,0,0,0,0,0,0,0,48,32,60,32,99,111,117,110,116,32,38,38,32,99,111,117,110,116,32,60,32,51,0,0,0,0,0,0,0,27,0,0,57,0,0,0,58,0,0,0,44,0,0,0,42,0,0,0,43,0,0,0,42,0,0,0,45,0,0,0,43,0,0,0,109,95,118,101,114,116, 105,99,101,115,32,61,61,32,48,76,32,38,38,32,109,95,99,111,117,110,116,32,61,61,32,48,0,0,0,0,0,0,0,0,66,111,120,50,68,95,118,50,46,51,46,49,47,66,111,120,50,68,47,67,111,108,108,105,115,105,111,110,47,83,104,97,112,101,115,47,98,50,67,104,97,105,110,83,104,97,112,101,46,99,112,112,0,0,0,0,67,114,101,97,116,101,76,111,111,112,0,0,0,0,0,0,98,50,68,105,115,116,97,110,99,101,83,113,117,97,114,101,100,40,118,49,44,32,118,50,41,32,62,32,48,46,48,48,53,102,32,42,32,48,46,48,48,53,102,0,0,0,0,0,67,114,101, 97,116,101,67,104,97,105,110,0,0,0,0,0,99,111,117,110,116,32,62,61,32,50,0,0,0,0,0,0,98,50,68,105,115,116,97,110,99,101,83,113,117,97,114,101,100,40,118,101,114,116,105,99,101,115,91,105,45,49,93,44,32,118,101,114,116,105,99,101,115,91,105,93,41,32,62,32,48,46,48,48,53,102,32,42,32,48,46,48,48,53,102,0,48,32,60,61,32,105,110,100,101,120,32,38,38,32,105,110,100,101,120,32,60,32,109,95,99,111,117,110,116,32,45,32,49,0,0,0,0,0,0,0,71,101,116,67,104,105,108,100,69,100,103,101,0,0,0,0,99,104,105,108,100, 73,110,100,101,120,32,60,32,109,95,99,111,117,110,116,0,0,0,0,67,111,109,112,117,116,101,65,65,66,66,0,0,0,0,0,49,50,98,50,67,104,97,105,110,83,104,97,112,101,0,0,55,98,50,83,104,97,112,101,0,0,0,0,0,0,0,0,184,72,0,0,232,26,0,0,224,72,0,0,216,26,0,0,248,26,0,0,0,0,0,0,0,0,0,0,72,27,0,0,59,0,0,0,60,0,0,0,45,0,0,0,43,0,0,0,44,0,0,0,43,0,0,0,46,0,0,0,44,0,0,0,49,51,98,50,67,105,114,99,108,101,83,104,97,112,101,0,224,72,0,0,56,27,0,0,248,26,0,0,0,0,0,0,0,0,0,0,144,27,0,0,61,0,0,0,62,0,0,0,46,0,0,0,44, 0,0,0,45,0,0,0,44,0,0,0,47,0,0,0,45,0,0,0,49,49,98,50,69,100,103,101,83,104,97,112,101,0,0,0,224,72,0,0,128,27,0,0,248,26,0,0,0,0,0,0,51,32,60,61,32,99,111,117,110,116,32,38,38,32,99,111,117,110,116,32,60,61,32,49,54,0,0,0,0,0,0,0,66,111,120,50,68,95,118,50,46,51,46,49,47,66,111,120,50,68,47,67,111,108,108,105,115,105,111,110,47,83,104,97,112,101,115,47,98,50,80,111,108,121,103,111,110,83,104,97,112,101,46,99,112,112,0,0,83,101,116,0,0,0,0,0,101,100,103,101,46,76,101,110,103,116,104,83,113,117,97, 114,101,100,40,41,32,62,32,49,46,49,57,50,48,57,50,56,57,53,53,48,55,56,49,50,53,101,45,48,55,70,32,42,32,49,46,49,57,50,48,57,50,56,57,53,53,48,55,56,49,50,53,101,45,48,55,70,0,0,0,0,0,0,0,0,48,46,48,102,32,60,61,32,108,111,119,101,114,32,38,38,32,108,111,119,101,114,32,60,61,32,105,110,112,117,116,46,109,97,120,70,114,97,99,116,105,111,110,0,0,0,0,0,109,95,99,111,117,110,116,32,62,61,32,51,0,0,0,0,67,111,109,112,117,116,101,77,97,115,115,0,0,0,0,0,97,114,101,97,32,62,32,49,46,49,57,50,48,57,50, 56,57,53,53,48,55,56,49,50,53,101,45,48,55,70,0,0,0,0,0,0,0,29,0,0,63,0,0,0,64,0,0,0,47,0,0,0,45,0,0,0,46,0,0,0,45,0,0,0,48,0,0,0,46,0,0,0,49,52,98,50,80,111,108,121,103,111,110,83,104,97,112,101,0,0,0,0,0,0,0,0,224,72,0,0,232,28,0,0,248,26,0,0,0,0,0,0,99,111,117,110,116,32,62,61,32,51,0,0,0,0,0,0,67,111,109,112,117,116,101,67,101,110,116,114,111,105,100,0,16,0,0,0,32,0,0,0,64,0,0,0,96,0,0,0,128,0,0,0,160,0,0,0,192,0,0,0,224,0,0,0,0,1,0,0,64,1,0,0,128,1,0,0,192,1,0,0,0,2,0,0,128,2,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,106,32,60,32,98,50,95,98,108,111,99,107,83,105,122,101,115,0,0,0,0,0,0,0,66,111,120,50,68,95,118,50,46,51,46,49,47,66,111,120,50,68,47,67,111,109,109,111,110,47,98,50,66,108,111,99,107,65,108,108,111,99,97, 116,111,114,46,99,112,112,0,0,98,50,66,108,111,99,107,65,108,108,111,99,97,116,111,114,0,0,0,0,0,0,0,0,48,32,60,32,115,105,122,101,0,0,0,0,0,0,0,0,48,32,60,61,32,105,110,100,101,120,32,38,38,32,105,110,100,101,120,32,60,32,98,50,95,98,108,111,99,107,83,105,122,101,115,0,0,0,0,0,98,108,111,99,107,67,111,117,110,116,32,42,32,98,108,111,99,107,83,105,122,101,32,60,61,32,98,50,95,99,104,117,110,107,83,105,122,101,0,0,109,95,105,110,100,101,120,32,61,61,32,48,0,0,0,0,66,111,120,50,68,95,118,50,46,51,46, 49,47,66,111,120,50,68,47,67,111,109,109,111,110,47,98,50,83,116,97,99,107,65,108,108,111,99,97,116,111,114,46,99,112,112,0,0,126,98,50,83,116,97,99,107,65,108,108,111,99,97,116,111,114,0,0,0,0,0,0,0,109,95,101,110,116,114,121,67,111,117,110,116,32,61,61,32,48,0,0,0,0,0,0,0,109,95,101,110,116,114,121,67,111,117,110,116,32,60,32,98,50,95,109,97,120,83,116,97,99,107,69,110,116,114,105,101,115,0,0,0,0,0,0,0,65,108,108,111,99,97,116,101,0,0,0,0,0,0,0,0,109,95,101,110,116,114,121,67,111,117,110,116,32, 62,32,48,0,0,0,0,0,0,0,0,70,114,101,101,0,0,0,0,112,32,61,61,32,101,110,116,114,121,45,62,100,97,116,97,0,0,0,0,0,0,0,0,98,100,45,62,112,111,115,105,116,105,111,110,46,73,115,86,97,108,105,100,40,41,0,0,66,111,120,50,68,95,118,50,46,51,46,49,47,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,98,50,66,111,100,121,46,99,112,112,0,0,98,50,66,111,100,121,0,0,98,100,45,62,108,105,110,101,97,114,86,101,108,111,99,105,116,121,46,73,115,86,97,108,105,100,40,41,0,0,0,0,98,50,73,115,86,97,108,105,100,40, 98,100,45,62,97,110,103,108,101,41,0,0,0,0,98,50,73,115,86,97,108,105,100,40,98,100,45,62,97,110,103,117,108,97,114,86,101,108,111,99,105,116,121,41,0,0,98,50,73,115,86,97,108,105,100,40,98,100,45,62,97,110,103,117,108,97,114,68,97,109,112,105,110,103,41,32,38,38,32,98,100,45,62,97,110,103,117,108,97,114,68,97,109,112,105,110,103,32,62,61,32,48,46,48,102,0,0,0,0,0,98,50,73,115,86,97,108,105,100,40,98,100,45,62,108,105,110,101,97,114,68,97,109,112,105,110,103,41,32,38,38,32,98,100,45,62,108,105,110, 101,97,114,68,97,109,112,105,110,103,32,62,61,32,48,46,48,102,0,0,0,0,0,0,0,109,95,119,111,114,108,100,45,62,73,115,76,111,99,107,101,100,40,41,32,61,61,32,102,97,108,115,101,0,0,0,0,83,101,116,84,121,112,101,0,67,114,101,97,116,101,70,105,120,116,117,114,101,0,0,0,68,101,115,116,114,111,121,70,105,120,116,117,114,101,0,0,102,105,120,116,117,114,101,45,62,109,95,98,111,100,121,32,61,61,32,116,104,105,115,0,109,95,102,105,120,116,117,114,101,67,111,117,110,116,32,62,32,48,0,0,0,0,0,0,102,111,117,110, 100,0,0,0,109,95,116,121,112,101,32,61,61,32,98,50,95,100,121,110,97,109,105,99,66,111,100,121,0,0,0,0,0,0,0,0,82,101,115,101,116,77,97,115,115,68,97,116,97,0,0,0,109,95,73,32,62,32,48,46,48,102,0,0,0,0,0,0,83,101,116,77,97,115,115,68,97,116,97,0,0,0,0,0,83,101,116,84,114,97,110,115,102,111,114,109,0,0,0,0,83,101,116,65,99,116,105,118,101,0,0,0,0,0,0,0,32,32,98,50,66,111,100,121,68,101,102,32,98,100,59,10,0,0,0,0,0,0,0,0,32,32,98,100,46,116,121,112,101,32,61,32,98,50,66,111,100,121,84,121,112,101, 40,37,100,41,59,10,0,0,0,0,32,32,98,100,46,112,111,115,105,116,105,111,110,46,83,101,116,40,37,46,49,53,108,101,102,44,32,37,46,49,53,108,101,102,41,59,10,0,0,0,32,32,98,100,46,97,110,103,108,101,32,61,32,37,46,49,53,108,101,102,59,10,0,0,32,32,98,100,46,108,105,110,101,97,114,86,101,108,111,99,105,116,121,46,83,101,116,40,37,46,49,53,108,101,102,44,32,37,46,49,53,108,101,102,41,59,10,0,0,0,0,0,32,32,98,100,46,97,110,103,117,108,97,114,86,101,108,111,99,105,116,121,32,61,32,37,46,49,53,108,101,102, 59,10,0,0,0,0,0,0,0,0,32,32,98,100,46,108,105,110,101,97,114,68,97,109,112,105,110,103,32,61,32,37,46,49,53,108,101,102,59,10,0,0,32,32,98,100,46,97,110,103,117,108,97,114,68,97,109,112,105,110,103,32,61,32,37,46,49,53,108,101,102,59,10,0,32,32,98,100,46,97,108,108,111,119,83,108,101,101,112,32,61,32,98,111,111,108,40,37,100,41,59,10,0,0,0,0,32,32,98,100,46,97,119,97,107,101,32,61,32,98,111,111,108,40,37,100,41,59,10,0,32,32,98,100,46,102,105,120,101,100,82,111,116,97,116,105,111,110,32,61,32,98, 111,111,108,40,37,100,41,59,10,0,32,32,98,100,46,98,117,108,108,101,116,32,61,32,98,111,111,108,40,37,100,41,59,10,0,0,0,0,0,0,0,0,32,32,98,100,46,97,99,116,105,118,101,32,61,32,98,111,111,108,40,37,100,41,59,10,0,0,0,0,0,0,0,0,32,32,98,100,46,103,114,97,118,105,116,121,83,99,97,108,101,32,61,32,37,46,49,53,108,101,102,59,10,0,0,0,32,32,98,111,100,105,101,115,91,37,100,93,32,61,32,109,95,119,111,114,108,100,45,62,67,114,101,97,116,101,66,111,100,121,40,38,98,100,41,59,10,0,0,0,0,0,0,0,32,32,123,10, 0,0,0,0,32,32,125,10,0,0,0,0,48,47,0,0,0,0,0,0,16,38,0,0,0,0,0,0,109,95,99,111,117,110,116,32,62,32,48,0,0,0,0,0,66,111,120,50,68,95,118,50,46,51,46,49,47,66,111,120,50,68,47,67,111,109,109,111,110,47,98,50,71,114,111,119,97,98,108,101,83,116,97,99,107,46,104,0,0,0,0,0,80,111,112,0,0,0,0,0,0,0,0,0,200,10,0,0,65,0,0,0,66,0,0,0,54,0,0,0,55,0,0,0,42,0,0,0,43,0,0,0,109,95,112,114,111,120,121,67,111,117,110,116,32,61,61,32,48,0,0,0,0,0,0,0,66,111,120,50,68,95,118,50,46,51,46,49,47,66,111,120,50,68,47, 68,121,110,97,109,105,99,115,47,98,50,70,105,120,116,117,114,101,46,99,112,112,0,0,0,0,0,0,0,67,114,101,97,116,101,80,114,111,120,105,101,115,0,0,0,32,32,32,32,98,50,70,105,120,116,117,114,101,68,101,102,32,102,100,59,10,0,0,0,32,32,32,32,102,100,46,102,114,105,99,116,105,111,110,32,61,32,37,46,49,53,108,101,102,59,10,0,0,0,0,0,32,32,32,32,102,100,46,114,101,115,116,105,116,117,116,105,111,110,32,61,32,37,46,49,53,108,101,102,59,10,0,0,32,32,32,32,102,100,46,100,101,110,115,105,116,121,32,61,32,37, 46,49,53,108,101,102,59,10,0,0,0,0,0,0,32,32,32,32,102,100,46,105,115,83,101,110,115,111,114,32,61,32,98,111,111,108,40,37,100,41,59,10,0,0,0,0,32,32,32,32,102,100,46,102,105,108,116,101,114,46,99,97,116,101,103,111,114,121,66,105,116,115,32,61,32,117,105,110,116,49,54,40,37,100,41,59,10,0,0,0,0,0,0,0,32,32,32,32,102,100,46,102,105,108,116,101,114,46,109,97,115,107,66,105,116,115,32,61,32,117,105,110,116,49,54,40,37,100,41,59,10,0,0,0,32,32,32,32,102,100,46,102,105,108,116,101,114,46,103,114,111, 117,112,73,110,100,101,120,32,61,32,105,110,116,49,54,40,37,100,41,59,10,0,0,32,32,32,32,98,50,67,105,114,99,108,101,83,104,97,112,101,32,115,104,97,112,101,59,10,0,0,0,0,0,0,0,32,32,32,32,115,104,97,112,101,46,109,95,114,97,100,105,117,115,32,61,32,37,46,49,53,108,101,102,59,10,0,0,32,32,32,32,115,104,97,112,101,46,109,95,112,46,83,101,116,40,37,46,49,53,108,101,102,44,32,37,46,49,53,108,101,102,41,59,10,0,0,0,32,32,32,32,98,50,69,100],"i8",Za,h.L); $a([103,101,83,104,97,112,101,32,115,104,97,112,101,59,10,0,32,32,32,32,115,104,97,112,101,46,109,95,118,101,114,116,101,120,48,46,83,101,116,40,37,46,49,53,108,101,102,44,32,37,46,49,53,108,101,102,41,59,10,0,0,0,0,0,32,32,32,32,115,104,97,112,101,46,109,95,118,101,114,116,101,120,49,46,83,101,116,40,37,46,49,53,108,101,102,44,32,37,46,49,53,108,101,102,41,59,10,0,0,0,0,0,32,32,32,32,115,104,97,112,101,46,109,95,118,101,114,116,101,120,50,46,83,101,116,40,37,46,49,53,108,101,102,44,32,37,46,49,53, 108,101,102,41,59,10,0,0,0,0,0,32,32,32,32,115,104,97,112,101,46,109,95,118,101,114,116,101,120,51,46,83,101,116,40,37,46,49,53,108,101,102,44,32,37,46,49,53,108,101,102,41,59,10,0,0,0,0,0,32,32,32,32,115,104,97,112,101,46,109,95,104,97,115,86,101,114,116,101,120,48,32,61,32,98,111,111,108,40,37,100,41,59,10,0,0,0,0,0,32,32,32,32,115,104,97,112,101,46,109,95,104,97,115,86,101,114,116,101,120,51,32,61,32,98,111,111,108,40,37,100,41,59,10,0,0,0,0,0,32,32,32,32,98,50,80,111,108,121,103,111,110,83,104, 97,112,101,32,115,104,97,112,101,59,10,0,0,0,0,0,0,32,32,32,32,98,50,86,101,99,50,32,118,115,91,37,100,93,59,10,0,0,0,0,0,32,32,32,32,118,115,91,37,100,93,46,83,101,116,40,37,46,49,53,108,101,102,44,32,37,46,49,53,108,101,102,41,59,10,0,0,0,0,0,0,32,32,32,32,115,104,97,112,101,46,83,101,116,40,118,115,44,32,37,100,41,59,10,0,32,32,32,32,98,50,67,104,97,105,110,83,104,97,112,101,32,115,104,97,112,101,59,10,0,0,0,0,0,0,0,0,32,32,32,32,115,104,97,112,101,46,67,114,101,97,116,101,67,104,97,105,110,40, 118,115,44,32,37,100,41,59,10,0,32,32,32,32,115,104,97,112,101,46,109,95,112,114,101,118,86,101,114,116,101,120,46,83,101,116,40,37,46,49,53,108,101,102,44,32,37,46,49,53,108,101,102,41,59,10,0,0,32,32,32,32,115,104,97,112,101,46,109,95,110,101,120,116,86,101,114,116,101,120,46,83,101,116,40,37,46,49,53,108,101,102,44,32,37,46,49,53,108,101,102,41,59,10,0,0,32,32,32,32,115,104,97,112,101,46,109,95,104,97,115,80,114,101,118,86,101,114,116,101,120,32,61,32,98,111,111,108,40,37,100,41,59,10,0,0,32,32, 32,32,115,104,97,112,101,46,109,95,104,97,115,78,101,120,116,86,101,114,116,101,120,32,61,32,98,111,111,108,40,37,100,41,59,10,0,0,10,0,0,0,0,0,0,0,32,32,32,32,102,100,46,115,104,97,112,101,32,61,32,38,115,104,97,112,101,59,10,0,32,32,32,32,98,111,100,105,101,115,91,37,100,93,45,62,67,114,101,97,116,101,70,105,120,116,117,114,101,40,38,102,100,41,59,10,0,0,0,0,116,111,105,73,110,100,101,120,65,32,60,32,109,95,98,111,100,121,67,111,117,110,116,0,66,111,120,50,68,95,118,50,46,51,46,49,47,66,111,120, 50,68,47,68,121,110,97,109,105,99,115,47,98,50,73,115,108,97,110,100,46,99,112,112,0,0,0,0,0,0,0,0,116,111,105,73,110,100,101,120,66,32,60,32,109,95,98,111,100,121,67,111,117,110,116,0,73,115,76,111,99,107,101,100,40,41,32,61,61,32,102,97,108,115,101,0,0,0,0,0,66,111,120,50,68,95,118,50,46,51,46,49,47,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,98,50,87,111,114,108,100,46,99,112,112,0,67,114,101,97,116,101,66,111,100,121,0,0,0,0,0,0,109,95,98,111,100,121,67,111,117,110,116,32,62,32,48,0,68, 101,115,116,114,111,121,66,111,100,121,0,0,0,0,0,67,114,101,97,116,101,74,111,105,110,116,0,0,0,0,0,68,101,115,116,114,111,121,74,111,105,110,116,0,0,0,0,109,95,106,111,105,110,116,67,111,117,110,116,32,62,32,48,0,0,0,0,0,0,0,0,98,45,62,73,115,65,99,116,105,118,101,40,41,32,61,61,32,116,114,117,101,0,0,0,83,111,108,118,101,0,0,0,115,116,97,99,107,67,111,117,110,116,32,60,32,115,116,97,99,107,83,105,122,101,0,0,116,121,112,101,65,32,61,61,32,98,50,95,100,121,110,97,109,105,99,66,111,100,121,32,124, 124,32,116,121,112,101,66,32,61,61,32,98,50,95,100,121,110,97,109,105,99,66,111,100,121,0,0,0,0,0,0,83,111,108,118,101,84,79,73,0,0,0,0,0,0,0,0,97,108,112,104,97,48,32,60,32,49,46,48,102,0,0,0,118,101,114,116,101,120,67,111,117,110,116,32,60,61,32,49,54,0,0,0,0,0,0,0,68,114,97,119,83,104,97,112,101,0,0,0,0,0,0,0,98,50,86,101,99,50,32,103,40,37,46,49,53,108,101,102,44,32,37,46,49,53,108,101,102,41,59,10,0,0,0,0,109,95,119,111,114,108,100,45,62,83,101,116,71,114,97,118,105,116,121,40,103,41,59,10,0, 0,0,0,0,0,0,0,98,50,66,111,100,121,42,42,32,98,111,100,105,101,115,32,61,32,40,98,50,66,111,100,121,42,42,41,98,50,65,108,108,111,99,40,37,100,32,42,32,115,105,122,101,111,102,40,98,50,66,111,100,121,42,41,41,59,10,0,0,0,0,0,98,50,74,111,105,110,116,42,42,32,106,111,105,110,116,115,32,61,32,40,98,50,74,111,105,110,116,42,42,41,98,50,65,108,108,111,99,40,37,100,32,42,32,115,105,122,101,111,102,40,98,50,74,111,105,110,116,42,41,41,59,10,0,0,123,10,0,0,0,0,0,0,125,10,0,0,0,0,0,0,98,50,70,114,101,101, 40,106,111,105,110,116,115,41,59,10,0,0,0,0,0,0,0,0,98,50,70,114,101,101,40,98,111,100,105,101,115,41,59,10,0,0,0,0,0,0,0,0,106,111,105,110,116,115,32,61,32,78,85,76,76,59,10,0,98,111,100,105,101,115,32,61,32,78,85,76,76,59,10,0,114,46,76,101,110,103,116,104,83,113,117,97,114,101,100,40,41,32,62,32,48,46,48,102,0,0,0,0,0,0,0,0,66,111,120,50,68,95,118,50,46,51,46,49,47,66,111,120,50,68,47,67,111,108,108,105,115,105,111,110,47,98,50,68,121,110,97,109,105,99,84,114,101,101,46,104,0,0,0,0,82,97,121,67, 97,115,116,0,48,32,60,61,32,112,114,111,120,121,73,100,32,38,38,32,112,114,111,120,121,73,100,32,60,32,109,95,110,111,100,101,67,97,112,97,99,105,116,121,0,0,0,0,0,0,0,0,71,101,116,85,115,101,114,68,97,116,97,0,0,0,0,0,71,101,116,70,97,116,65,65,66,66,0,0,0,0,0,0,66,111,120,50,68,95,118,50,46,51,46,49,47,66,111,120,50,68,47,67,111,109,109,111,110,47,98,50,77,97,116,104,46,104,0,0,0,0,0,0,65,100,118,97,110,99,101,0,109,95,106,111,105,110,116,67,111,117,110,116,32,60,32,109,95,106,111,105,110,116,67, 97,112,97,99,105,116,121,0,0,66,111,120,50,68,95,118,50,46,51,46,49,47,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,98,50,73,115,108,97,110,100,46,104,0,0,65,100,100,0,0,0,0,0,109,95,99,111,110,116,97,99,116,67,111,117,110,116,32,60,32,109,95,99,111,110,116,97,99,116,67,97,112,97,99,105,116,121,0,0,0,0,0,0,109,95,98,111,100,121,67,111,117,110,116,32,60,32,109,95,98,111,100,121,67,97,112,97,99,105,116,121,0,0,0,0,0,0,0,0,88,47,0,0,67,0,0,0,68,0,0,0,47,0,0,0,0,0,0,0,49,53,98,50,67,111,110,116, 97,99,116,70,105,108,116,101,114,0,0,0,0,0,0,0,184,72,0,0,64,47,0,0,0,0,0,0,16,48,0,0,49,0,0,0,69,0,0,0,70,0,0,0,0,0,0,0,66,111,120,50,68,95,118,50,46,51,46,49,47,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,67,111,110,116,97,99,116,115,47,98,50,67,104,97,105,110,65,110,100,67,105,114,99,108,101,67,111,110,116,97,99,116,46,99,112,112,0,0,0,0,0,0,0,0,98,50,67,104,97,105,110,65,110,100,67,105,114,99,108,101,67,111,110,116,97,99,116,0,50,51,98,50,67,104,97,105,110,65,110,100,67,105,114,99,108, 101,67,111,110,116,97,99,116,0,0,0,0,0,0,0,57,98,50,67,111,110,116,97,99,116,0,0,0,0,0,0,184,72,0,0,248,47,0,0,224,72,0,0,216,47,0,0,8,48,0,0,0,0,0,0,0,0,0,0,240,48,0,0,50,0,0,0,71,0,0,0,72,0,0,0,0,0,0,0,109,95,102,105,120,116,117,114,101,65,45,62,71,101,116,84,121,112,101,40,41,32,61,61,32,98,50,83,104,97,112,101,58,58,101,95,99,104,97,105,110,0,0,0,0,0,0,0,66,111,120,50,68,95,118,50,46,51,46,49,47,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,67,111,110,116,97,99,116,115,47,98,50,67,104,97, 105,110,65,110,100,80,111,108,121,103,111,110,67,111,110,116,97,99,116,46,99,112,112,0,0,0,0,0,0,0,98,50,67,104,97,105,110,65,110,100,80,111,108,121,103,111,110,67,111,110,116,97,99,116,0,0,0,0,0,0,0,0,50,52,98,50,67,104,97,105,110,65,110,100,80,111,108,121,103,111,110,67,111,110,116,97,99,116,0,0,0,0,0,0,224,72,0,0,208,48,0,0,8,48,0,0,0,0,0,0,0,0,0,0,176,49,0,0,51,0,0,0,73,0,0,0,74,0,0,0,0,0,0,0,109,95,102,105,120,116,117,114,101,65,45,62,71,101,116,84,121,112,101,40,41,32,61,61,32,98,50,83,104, 97,112,101,58,58,101,95,99,105,114,99,108,101,0,0,0,0,0,0,66,111,120,50,68,95,118,50,46,51,46,49,47,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,67,111,110,116,97,99,116,115,47,98,50,67,105,114,99,108,101,67,111,110,116,97,99,116,46,99,112,112,0,0,0,0,0,0,0,0,98,50,67,105,114,99,108,101,67,111,110,116,97,99,116,0,49,53,98,50,67,105,114,99,108,101,67,111,110,116,97,99,116,0,0,0,0,0,0,0,224,72,0,0,152,49,0,0,8,48,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,48,32,60,61,32,116,121,112,101,49,32,38,38,32,116,121,112,101,49,32,60,32,98,50,83,104,97,112,101,58,58,101,95,116,121,112,101,67,111,117,110,116,0,0,0,0,0,0,66,111,120, 50,68,95,118,50,46,51,46,49,47,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,67,111,110,116,97,99,116,115,47,98,50,67,111,110,116,97,99,116,46,99,112,112,0,0,0,0,0,0,48,32,60,61,32,116,121,112,101,50,32,38,38,32,116,121,112,101,50,32,60,32,98,50,83,104,97,112,101,58,58,101,95,116,121,112,101,67,111,117,110,116,0,0,0,0,0,0,115,95,105,110,105,116,105,97,108,105,122,101,100,32,61,61,32,116,114,117,101,0,0,0,48,32,60,61,32,116,121,112,101,65,32,38,38,32,116,121,112,101,66,32,60,32,98,50,83,104, 97,112,101,58,58,101,95,116,121,112,101,67,111,117,110,116,0,0,0,0,0,0,112,111,105,110,116,67,111,117,110,116,32,62,32,48,0,0,66,111,120,50,68,95,118,50,46,51,46,49,47,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,67,111,110,116,97,99,116,115,47,98,50,67,111,110,116,97,99,116,83,111,108,118,101,114,46,99,112,112,0,0,0,0,0,0,0,0,98,50,67,111,110,116,97,99,116,83,111,108,118,101,114,0,109,97,110,105,102,111,108,100,45,62,112,111,105,110,116,67,111,117,110,116,32,62,32,48,0,0,0,0,0,0,0,0,73,110, 105,116,105,97,108,105,122,101,86,101,108,111,99,105,116,121,67,111,110,115,116,114,97,105,110,116,115,0,0,0,112,111,105,110,116,67,111,117,110,116,32,61,61,32,49,32,124,124,32,112,111,105,110,116,67,111,117,110,116,32,61,61,32,50,0,0,0,0,0,0,83,111,108,118,101,86,101,108,111,99,105,116,121,67,111,110,115,116,114,97,105,110,116,115,0,0,0,0,0,0,0,0,97,46,120,32,62,61,32,48,46,48,102,32,38,38,32,97,46,121,32,62,61,32,48,46,48,102,0,0,0,0,0,0,112,99,45,62,112,111,105,110,116,67,111,117,110,116,32,62, 32,48,0,0,0,0,0,0,0,0,0,0,24,53,0,0,52,0,0,0,75,0,0,0,76,0,0,0,0,0,0,0,66,111,120,50,68,95,118,50,46,51,46,49,47,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,67,111,110,116,97,99,116,115,47,98,50,69,100,103,101,65,110,100,67,105,114,99,108,101,67,111,110,116,97,99,116,46,99,112,112,0,98,50,69,100,103,101,65,110,100,67,105,114,99,108,101,67,111,110,116,97,99,116,0,0,50,50,98,50,69,100,103,101,65,110,100,67,105,114,99,108,101,67,111,110,116,97,99,116,0,0,0,0,0,0,0,0,224,72,0,0,248,52,0,0,8,48, 0,0,0,0,0,0,0,0,0,0,240,53,0,0,53,0,0,0,77,0,0,0,78,0,0,0,0,0,0,0,109,95,102,105,120,116,117,114,101,65,45,62,71,101,116,84,121,112,101,40,41,32,61,61,32,98,50,83,104,97,112,101,58,58,101,95,101,100,103,101,0,0,0,0,0,0,0,0,66,111,120,50,68,95,118,50,46,51,46,49,47,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,67,111,110,116,97,99,116,115,47,98,50,69,100,103,101,65,110,100,80,111,108,121,103,111,110,67,111,110,116,97,99,116,46,99,112,112,0,0,0,0,0,0,0,0,98,50,69,100,103,101,65,110,100,80,111, 108,121,103,111,110,67,111,110,116,97,99,116,0,50,51,98,50,69,100,103,101,65,110,100,80,111,108,121,103,111,110,67,111,110,116,97,99,116,0,0,0,0,0,0,0,224,72,0,0,208,53,0,0,8,48,0,0,0,0,0,0,0,0,0,0,208,54,0,0,54,0,0,0,79,0,0,0,80,0,0,0,0,0,0,0,66,111,120,50,68,95,118,50,46,51,46,49,47,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,67,111,110,116,97,99,116,115,47,98,50,80,111,108,121,103,111,110,65,110,100,67,105,114,99,108,101,67,111,110,116,97,99,116,46,99,112,112,0,0,0,0,0,0,98,50,80,111,108, 121,103,111,110,65,110,100,67,105,114,99,108,101,67,111,110,116,97,99,116,0,0,0,0,0,0,0,109,95,102,105,120,116,117,114,101,66,45,62,71,101,116,84,121,112,101,40,41,32,61,61,32,98,50,83,104,97,112,101,58,58,101,95,99,105,114,99,108,101,0,0,0,0,0,0,50,53,98,50,80,111,108,121,103,111,110,65,110,100,67,105,114,99,108,101,67,111,110,116,97,99,116,0,0,0,0,0,224,72,0,0,176,54,0,0,8,48,0,0,0,0,0,0,0,0,0,0,200,55,0,0,55,0,0,0,81,0,0,0,82,0,0,0,0,0,0,0,109,95,102,105,120,116,117,114,101,65,45,62,71,101,116, 84,121,112,101,40,41,32,61,61,32,98,50,83,104,97,112,101,58,58,101,95,112,111,108,121,103,111,110,0,0,0,0,0,66,111,120,50,68,95,118,50,46,51,46,49,47,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,67,111,110,116,97,99,116,115,47,98,50,80,111,108,121,103,111,110,67,111,110,116,97,99,116,46,99,112,112,0,0,0,0,0,0,0,98,50,80,111,108,121,103,111,110,67,111,110,116,97,99,116,0,0,0,0,0,0,0,0,109,95,102,105,120,116,117,114,101,66,45,62,71,101,116,84,121,112,101,40,41,32,61,61,32,98,50,83,104,97,112, 101,58,58,101,95,112,111,108,121,103,111,110,0,0,0,0,0,49,54,98,50,80,111,108,121,103,111,110,67,111,110,116,97,99,116,0,0,0,0,0,0,224,72,0,0,176,55,0,0,8,48,0,0,0,0,0,0,0,0,0,0,96,56,0,0,56,0,0,0,57,0,0,0,47,0,0,0,43,0,0,0,83,0,0,0,51,0,0,0,84,0,0,0,85,0,0,0,58,0,0,0,59,0,0,0,48,0,0,0,0,0,0,0,32,32,98,50,68,105,115,116,97,110,99,101,74,111,105,110,116,68,101,102,32,106,100,59,10,0,0,0,0,0,0,0,32,32,106,100,46,108,101,110,103,116,104,32,61,32,37,46,49,53,108,101,102,59,10,0,49,53,98,50,68,105,115, 116,97,110,99,101,74,111,105,110,116,0,0,0,0,0,0,0,224,72,0,0,72,56,0,0,32,20,0,0,0,0,0,0,0,0,0,0,200,57,0,0,60,0,0,0,61,0,0,0,48,0,0,0,44,0,0,0,86,0,0,0,51,0,0,0,87,0,0,0,88,0,0,0,62,0,0,0,63,0,0,0,49,0,0,0,0,0,0,0,98,50,73,115,86,97,108,105,100,40,102,111,114,99,101,41,32,38,38,32,102,111,114,99,101,32,62,61,32,48,46,48,102,0,0,0,0,0,0,0,66,111,120,50,68,95,118,50,46,51,46,49,47,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,74,111,105,110,116,115,47,98,50,70,114,105,99,116,105,111,110,74, 111,105,110,116,46,99,112,112,0,0,83,101,116,77,97,120,70,111,114,99,101,0,0,0,0,0,98,50,73,115,86,97,108,105,100,40,116,111,114,113,117,101,41,32,38,38,32,116,111,114,113,117,101,32,62,61,32,48,46,48,102,0,0,0,0,0,83,101,116,77,97,120,84,111,114,113,117,101,0,0,0,0,32,32,98,50,70,114,105,99,116,105,111,110,74,111,105,110,116,68,101,102,32,106,100,59,10,0,0,0,0,0,0,0,32,32,106,100,46,109,97,120,70,111,114,99,101,32,61,32,37,46,49,53,108,101,102,59,10,0,0,0,0,0,0,0,32,32,106,100,46,109,97,120,84,111, 114,113,117,101,32,61,32,37,46,49,53,108,101,102,59,10,0,0,0,0,0,0,49,53,98,50,70,114,105,99,116,105,111,110,74,111,105,110,116,0,0,0,0,0,0,0,224,72,0,0,176,57,0,0,32,20,0,0,0,0,0,0,0,0,0,0,104,59,0,0,64,0,0,0,65,0,0,0,49,0,0,0,45,0,0,0,89,0,0,0,51,0,0,0,90,0,0,0,91,0,0,0,66,0,0,0,67,0,0,0,50,0,0,0,0,0,0,0,109,95,116,121,112,101,65,32,61,61,32,101,95,114,101,118,111,108,117,116,101,74,111,105,110,116,32,124,124,32,109,95,116,121,112,101,65,32,61,61,32,101,95,112,114,105,115,109,97,116,105,99,74,111, 105,110,116,0,0,0,0,0,0,0,66,111,120,50,68,95,118,50,46,51,46,49,47,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,74,111,105,110,116,115,47,98,50,71,101,97,114,74,111,105,110,116,46,99,112,112,0,0,0,0,0,0,98,50,71,101,97,114,74,111,105,110,116,0,0,0,0,0,109,95,116,121,112,101,66,32,61,61,32,101,95,114,101,118,111,108,117,116,101,74,111,105,110,116,32,124,124,32,109,95,116,121,112,101,66,32,61,61,32,101,95,112,114,105,115,109,97,116,105,99,74,111,105,110,116,0,0,0,0,0,0,0,98,50,73,115,86,97, 108,105,100,40,114,97,116,105,111,41,0,0,0,0,0,0,0,0,83,101,116,82,97,116,105,111,0,0,0,0,0,0,0,0,32,32,98,50,71,101,97,114,74,111,105,110,116,68,101,102,32,106,100,59,10,0,0,0,32,32,106,100,46,106,111,105,110,116,49,32,61,32,106,111,105,110,116,115,91,37,100,93,59,10,0,0,0,0,0,0,32,32,106,100,46,106,111,105,110,116,50,32,61,32,106,111,105,110,116,115,91,37,100,93,59,10,0,0,0,0,0,0,49,49,98,50,71,101,97,114,74,111,105,110,116,0,0,0,224,72,0,0,88,59,0,0,32,20,0,0,0,0,0,0,102,97,108,115,101,0,0,0,66, 111,120,50,68,95,118,50,46,51,46,49,47,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,74,111,105,110,116,115,47,98,50,74,111,105,110,116,46,99,112,112,0,0,67,114,101,97,116,101,0,0,68,101,115,116,114,111,121,0,0,0,0,0,32,20,0,0,42,0,0,0,42,0,0,0,42,0,0,0,42,0,0,0,92,0,0,0,51,0,0,0,93,0,0,0,94,0,0,0,42,0,0,0,42,0,0,0,42,0,0,0,0,0,0,0,100,101,102,45,62,98,111,100,121,65,32,33,61,32,100,101,102,45,62,98,111,100,121,66,0,0,0,0,0,0,0,0,98,50,74,111,105,110,116,0,47,47,32,68,117,109,112,32,105,115, 32,110,111,116,32,115,117,112,112,111,114,116,101,100,32,102,111,114,32,116,104,105,115,32,106,111,105,110,116,32,116,121,112,101,46,10,0,0,0,0,0,0,232,61,0,0,68,0,0,0,69,0,0,0,50,0,0,0,46,0,0,0,95,0,0,0,70,0,0,0,96,0,0,0,97,0,0,0,71,0,0,0,72,0,0,0,51,0,0,0,0,0,0,0,100,101,102,45,62,116,97,114,103,101,116,46,73,115,86,97,108,105,100,40,41,0,0,0,66,111,120,50,68,95,118,50,46,51,46,49,47,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,74,111,105,110,116,115,47,98,50,77,111,117,115,101,74,111,105, 110,116,46,99,112,112,0,0,0,0,0,98,50,77,111,117,115,101,74,111,105,110,116,0,0,0,0,98,50,73,115,86,97,108,105,100,40,100,101,102,45,62,109,97,120,70,111,114,99,101,41,32,38,38,32,100,101,102,45,62,109,97,120,70,111,114,99,101,32,62,61,32,48,46,48,102,0,0,0,0,0,0,0,98,50,73,115,86,97,108,105,100,40,100,101,102,45,62,102,114,101,113,117,101,110,99,121,72,122,41,32,38,38,32,100,101,102,45,62,102,114,101,113,117,101,110,99,121,72,122,32,62,61,32,48,46,48,102,0,98,50,73,115,86,97,108,105,100,40,100,101, 102,45,62,100,97,109,112,105,110,103,82,97,116,105,111,41,32,38,38,32,100,101,102,45,62,100,97,109,112,105,110,103,82,97,116,105,111,32,62,61,32,48,46,48,102,0,0,0,0,0,0,0,100,32,43,32,104,32,42,32,107,32,62,32,49,46,49,57,50,48,57,50,56,57,53,53,48,55,56,49,50,53,101,45,48,55,70,0,0,0,0,0,73,110,105,116,86,101,108,111,99,105,116,121,67,111,110,115,116,114,97,105,110,116,115,0,49,50,98,50,77,111,117,115,101,74,111,105,110,116,0,0,224,72,0,0,216,61,0,0,32,20,0,0,0,0,0,0,77,111,117,115,101,32,106,111, 105,110,116,32,100,117,109,112,105,110,103,32,105,115,32,110,111,116,32,115,117,112,112,111,114,116,101,100,46,10,0,0,0,0,0,0,56,63,0,0,73,0,0,0,74,0,0,0,51,0,0,0,47,0,0,0,98,0,0,0,51,0,0,0,99,0,0,0,100,0,0,0,75,0,0,0,76,0,0,0,52,0,0,0,0,0,0,0,66,111,120,50,68,95,118,50,46,51,46,49,47,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,74,111,105,110,116,115,47,98,50,80,114,105,115,109,97,116,105,99,74,111,105,110,116,46,99,112,112,0,32,32,98,50,80,114,105,115,109,97,116,105,99,74,111,105,110,116, 68,101,102,32,106,100,59,10,0,0,0,0,0,0,32,32,106,100,46,108,111,119,101,114,84,114,97,110,115,108,97,116,105,111,110,32,61,32,37,46,49,53,108,101,102,59,10,0,0,0,0,0,0,0,32,32,106,100,46,117,112,112,101,114,84,114,97,110,115,108,97,116,105,111,110,32,61,32,37,46,49,53,108,101,102,59,10,0,0,0,0,0,0,0,32,32,106,100,46,109,97,120,77,111,116,111,114,70,111,114,99,101,32,61,32,37,46,49,53,108,101,102,59,10,0,0,49,54,98,50,80,114,105,115,109,97,116,105,99,74,111,105,110,116,0,0,0,0,0,0,224,72,0,0,32,63, 0,0,32,20,0,0,0,0,0,0,114,97,116,105,111,32,62,32,49,46,49,57,50,48,57,50,56,57,53,53,48,55,56,49,50,53,101,45,48,55,70,0,66,111,120,50,68,95,118,50,46,51,46,49,47,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,74,111,105,110,116,115,47,98,50,80,117,108,108,101,121,74,111,105,110,116,46,99,112,112,0,0,0,0,73,110,105,116,105,97,108,105,122,101,0,0,0,0,0,0,0,0,0,0,240,64,0,0,77,0,0,0,78,0,0,0,52,0,0,0,48,0,0,0,101,0,0,0,79,0,0,0,102,0,0,0,103,0,0,0,80,0,0,0,81,0,0,0,53,0,0,0,0,0,0,0,100,101,102, 45,62,114,97,116,105,111,32,33,61,32,48,46,48,102,0,0,0,0,0,0,98,50,80,117,108,108,101,121,74,111,105,110,116,0,0,0,32,32,98,50,80,117,108,108,101,121,74,111,105,110,116,68,101,102,32,106,100,59,10,0,32,32,106,100,46,103,114,111,117,110,100,65,110,99,104,111,114,65,46,83,101,116,40,37,46,49,53,108,101,102,44,32,37,46,49,53,108,101,102,41,59,10,0,0,0,0,0,0,32,32,106,100,46,103,114,111,117,110,100,65,110,99,104,111,114,66,46,83,101,116,40,37,46,49,53,108,101,102,44,32,37,46,49,53,108,101,102,41,59, 10,0,0,0,0,0,0,32,32,106,100,46,108,101,110,103,116,104,65,32,61,32,37,46,49,53,108,101,102,59,10,0,0,0,0,0,0,0,0,32,32,106,100,46,108,101,110,103,116,104,66,32,61,32,37,46,49,53,108,101,102,59,10,0,0,0,0,0,0,0,0,32,32,106,100,46,114,97,116,105,111,32,61,32,37,46,49,53,108,101,102,59,10,0,0,49,51,98,50,80,117,108,108,101,121,74,111,105,110,116,0,224,72,0,0,224,64,0,0,32,20,0,0,0,0,0,0,0,0,0,0,40,66,0,0,82,0,0,0,83,0,0,0,53,0,0,0,49,0,0,0,104,0,0,0,51,0,0,0,105,0,0,0,106,0,0,0,84,0,0,0,85,0,0,0,54, 0,0,0,0,0,0,0,108,111,119,101,114,32,60,61,32,117,112,112,101,114,0,0,66,111,120,50,68,95,118,50,46,51,46,49,47,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,74,111,105,110,116,115,47,98,50,82,101,118,111,108,117,116,101,74,111,105,110,116,46,99,112,112,0,0,83,101,116,76,105,109,105,116,115,0,0,0,0,0,0,0,32,32,98,50,82,101,118,111,108,117,116,101,74,111,105,110,116,68,101,102,32,106,100,59,10,0,0,0,0,0,0,0,32,32,106,100,46,101,110,97,98,108,101,76,105,109,105,116,32,61,32,98,111,111,108,40, 37,100,41,59,10,0,0,0,32,32,106,100,46,108,111,119,101,114,65,110,103,108,101,32,61,32,37,46,49,53,108,101,102,59,10,0,0,0,0,0,32,32,106,100,46,117,112,112,101,114,65,110,103,108,101,32,61,32,37,46,49,53,108,101,102,59,10,0,0,0,0,0,49,53,98,50,82,101,118,111,108,117,116,101,74,111,105,110,116,0,0,0,0,0,0,0,224,72,0,0,16,66,0,0,32,20,0,0,0,0,0,0,0,0,0,0,184,66,0,0,86,0,0,0,87,0,0,0,54,0,0,0,50,0,0,0,107,0,0,0,51,0,0,0,108,0,0,0,109,0,0,0,88,0,0,0,89,0,0,0,55,0,0,0,0,0,0,0,32,32,98,50,82,111,112,101, 74,111,105,110,116,68,101,102,32,106,100,59,10,0,0,0,32,32,106,100,46,109,97,120,76,101,110,103,116,104,32,61,32,37,46,49,53,108,101,102,59,10,0,0,0,0,0,0,49,49,98,50,82,111,112,101,74,111,105,110,116,0,0,0,224,72,0,0,168,66,0,0,32,20,0,0,0,0,0,0,0,0,0,0,72,67,0,0,90,0,0,0,91,0,0,0,55,0,0,0,51,0,0,0,110,0,0,0,51,0,0,0,111,0,0,0,112,0,0,0,92,0,0,0,93,0,0,0,56,0,0,0,0,0,0,0,32,32,98,50,87,101,108,100,74,111,105,110,116,68,101,102,32,106,100,59,10,0,0,0,32,32,106,100,46,114,101,102,101,114,101,110,99, 101,65,110,103,108,101,32,61,32,37,46,49,53,108,101,102,59,10,0,49,49,98,50,87,101,108,100,74,111,105,110,116,0,0,0,224,72,0,0,56,67,0,0,32,20,0,0,0,0,0,0,0,0,0,0,120,69,0,0,94,0,0,0,95,0,0,0,56,0,0,0,52,0,0,0,113,0,0,0,51,0,0,0,114,0,0,0,115,0,0,0,96,0,0,0,97,0,0,0,57,0,0,0,0,0,0,0,32,32,98,50,87,104,101,101,108,74,111,105,110,116,68,101,102,32,106,100,59,10,0,0,32,32,106,100,46,98,111,100,121,65,32,61,32,98,111,100,105,101,115,91,37,100,93,59,10,0,0,0,0,0,0,0,32,32,106,100,46,98,111,100,121,66, 32,61,32,98,111,100,105,101,115,91,37,100,93,59,10,0,0,0,0,0,0,0,32,32,106,100,46,99,111,108,108,105,100,101,67,111,110,110,101,99,116,101,100,32,61,32,98,111,111,108,40,37,100,41,59,10,0,0,0,0,0,0,32,32,106,100,46,108,111,99,97,108,65,110,99,104,111,114,65,46,83,101,116,40,37,46,49,53,108,101,102,44,32,37,46,49,53,108,101,102,41,59,10,0,0,0,0,0,0,0,32,32,106,100,46,108,111,99,97,108,65,110,99,104,111,114,66,46,83,101,116,40,37,46,49,53,108,101,102,44,32,37,46,49,53,108,101,102,41,59,10,0,0,0,0,0, 0,0,32,32,106,100,46,108,111,99,97,108,65,120,105,115,65,46,83,101,116,40,37,46,49,53,108,101,102,44,32,37,46,49,53,108,101,102,41,59,10,0,32,32,106,100,46,101,110,97,98,108,101,77,111,116,111,114,32,61,32,98,111,111,108,40,37,100,41,59,10,0,0,0,32,32,106,100,46,109,111,116,111,114,83,112,101,101,100,32,61,32,37,46,49,53,108,101,102,59,10,0,0,0,0,0,32,32,106,100,46,109,97,120,77,111,116,111,114,84,111,114,113,117,101,32,61,32,37,46,49,53,108,101,102,59,10,0,32,32,106,100,46,102,114,101,113,117,101, 110,99,121,72,122,32,61,32,37,46,49,53,108,101,102,59,10,0,0,0,0,32,32,106,100,46,100,97,109,112,105,110,103,82,97,116,105,111,32,61,32,37,46,49,53,108,101,102,59,10,0,0,0,32,32,106,111,105,110,116,115,91,37,100,93,32,61,32,109,95,119,111,114,108,100,45,62,67,114,101,97,116,101,74,111,105,110,116,40,38,106,100,41,59,10,0,0,0,0,0,0,49,50,98,50,87,104,101,101,108,74,111,105,110,116,0,0,224,72,0,0,104,69,0,0,32,20,0,0,0,0,0,0,43,0,0,0,0,0,0,0,117,110,99,97,117,103,104,116,0,0,0,0,0,0,0,0,116,101,114, 109,105,110,97,116,105,110,103,32,119,105,116,104,32,37,115,32,101,120,99,101,112,116,105,111,110,32,111,102,32,116,121,112,101,32,37,115,58,32,37,115,0,0,0,0,116,101,114,109,105,110,97,116,105,110,103,32,119,105,116,104,32,37,115,32,101,120,99,101,112,116,105,111,110,32,111,102,32,116,121,112,101,32,37,115,0,0,0,0,0,0,0,0,116,101,114,109,105,110,97,116,105,110,103,32,119,105,116,104,32,37,115,32,102,111,114,101,105,103,110,32,101,120,99,101,112,116,105,111,110,0,0,0,116,101,114,109,105,110,97,116, 105,110,103,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,112,116,104,114,101,97,100,95,111,110,99,101,32,102,97,105,108,117,114,101,32,105,110,32,95,95,99,120,97,95,103,101,116,95,103,108,111,98,97,108,115,95,102,97,115,116,40,41,0,0,0,0,0,0,0,0,99,97,110,110,111,116,32,99,114,101,97,116,101,32,112,116,104,114,101,97,100,32,107,101,121,32,102,111,114,32,95,95,99,120,97,95,103,101,116,95,103,108,111,98,97,108,115,40,41,0,0,0,0,0,0,0,99,97,110,110,111,116,32,122,101,114,111,32,111,117,116,32,116,104,114, 101,97,100,32,118,97,108,117,101,32,102,111,114,32,95,95,99,120,97,95,103,101,116,95,103,108,111,98,97,108,115,40,41,0,0,0,0,0,0,0,0,40,71,0,0,116,0,0,0,117,0,0,0,46,0,0,0,0,0,0,0,115,116,100,58,58,98,97,100,95,97,108,108,111,99,0,0,83,116,57,98,97,100,95,97,108,108,111,99,0,0,0,0,224,72,0,0,24,71,0,0,176,71,0,0,0,0,0,0,116,101,114,109,105,110,97,116,101,95,104,97,110,100,108,101,114,32,117,110,101,120,112,101,99,116,101,100,108,121,32,114,101,116,117,114,110,101,100,0,116,101,114,109,105,110,97, 116,101,95,104,97,110,100,108,101,114,32,117,110,101,120,112,101,99,116,101,100,108,121,32,116,104,114,101,119,32,97,110,32,101,120,99,101,112,116,105,111,110,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,83,116,57,101,120,99,101,112,116,105,111,110,0,0,0,0,184,72,0,0,160,71,0,0,83,116,57,116,121,112,101,95,105,110,102,111,0,0,0,0,184,72,0,0,184,71,0,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,54,95,95,115,104,105,109,95,116,121,112,101,95,105,110,102,111,69,0,0,0,0,0,0,0,0,224,72,0,0,208,71,0,0,200,71,0,0,0, 0,0,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,55,95,95,99,108,97,115,115,95,116,121,112,101,95,105,110,102,111,69,0,0,0,0,0,0,0,224,72,0,0,8,72,0,0,248,71,0,0,0,0,0,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,57,95,95,112,111,105,110,116,101,114,95,116,121,112,101,95,105,110,102,111,69,0,0,0,0,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,55,95,95,112,98,97,115,101,95,116,121,112,101,95,105,110,102,111,69,0,0,0,0,0,0,0,224,72,0,0,104,72,0,0,248,71,0,0,0,0,0,0,224,72,0,0,64,72,0,0,144, 72,0,0,0,0,0,0,0,0,0,0,48,72,0,0,118,0,0,0,119,0,0,0,120,0,0,0,121,0,0,0,48,0,0,0,42,0,0,0,42,0,0,0,56,0,0,0,0,0,0,0,40,73,0,0,118,0,0,0,122,0,0,0,120,0,0,0,121,0,0,0,48,0,0,0,43,0,0,0,43,0,0,0,57,0,0,0,78,49,48,95,95,99,120,120,97,98,105,118,49,50,48,95,95,115,105,95,99,108,97,115,115,95,116,121,112,101,95,105,110,102,111,69,0,0,0,0,224,72,0,0,0,73,0,0,48,72,0,0,0,0,0,0,0,0,0,0,136,73,0,0,118,0,0,0,123,0,0,0,120,0,0,0,121,0,0,0,48,0,0,0,44,0,0,0,44,0,0,0,58,0,0,0,78,49,48,95,95,99,120,120,97,98, 105,118,49,50,49,95,95,118,109,105,95,99,108,97,115,115,95,116,121,112,101,95,105,110,102,111,69,0,0,0,224,72,0,0,96,73,0,0,48,72,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"i8",Za,h.L+10240);var Ob=h.C($a(12,"i8",Xa),8);oa(0==Ob%8);var Pb=Qa;function Qb(){return!!Qb.K}var Rb=0,Sb=[],Tb={};function Ub(a){if(!a||Tb[a])return a;for(var b in Tb)if(Tb[b].N===a)return b;return a} function Vb(){var a=Rb;if(!a)return(i.setTempRet0(0),0)|0;var b=Tb[a],f=b.type;if(!f)return(i.setTempRet0(0),a)|0;var g=Array.prototype.slice.call(arguments);e.___cxa_is_pointer_type(f);Vb.buffer||(Vb.buffer=ab(4));Ma[Vb.buffer>>2]=a;for(var a=Vb.buffer,k=0;k>2],b.N=a,(i.setTempRet0(g[k]),a)|0;a=Ma[a>>2];return(i.setTempRet0(f),a)|0}e._memset=Wb;function Xb(a,b){Xb.H||(Xb.H={});a in Xb.H||(h.r("v",b),Xb.H[a]=1)}e._strlen=Yb; var va=d,Zb=0;function $b(a){return Ma[Zb>>2]=a}var ac=9;function bc(a,b,f){a=va.$(a);if(!a)return $b(ac),-1;try{return va.write(a,Ka,b,f)}catch(g){return va.ba(g),-1}}function cc(a){a=va.R(a);return!a?-1:a.sa}function dc(a,b){var f=Cb(a&255);Ka[dc.T>>0]=f;var g=cc(b);if(-1==bc(g,dc.T,1)){if(f=va.R(b))f.error=aa;return-1}return f}var ec={},fc=1;function gc(a,b,f,g){f*=b;if(0==f)return 0;var k=cc(g),a=bc(k,a,f);if(-1==a){if(b=va.R(g))b.error=aa;return 0}return a/b|0} function hc(a){return 0>a||0===a&&-Infinity===1/a} function ic(a,b){function f(a){var f;"double"===a?f=(Ma[Ob>>2]=Ma[b+k>>2],Ma[Ob+4>>2]=Ma[b+(k+4)>>2],+Ta[Ob>>3]):"i64"==a?f=[Ma[b+k>>2],Ma[b+(k+4)>>2]]:(a="i32",f=Ma[b+k>>2]);k+=h.P(a);return f}for(var g=a,k=0,n=[],m,l;;){var ha=g;m=Ka[g>>0];if(0===m)break;l=Ka[g+1>>0];if(37==m){var Na=ca,Ya=ca,ta=ca,Aa=ca,ib=ca;a:for(;;){switch(l){case 43:Na=aa;break;case 45:Ya=aa;break;case 35:ta=aa;break;case 48:if(Aa)break a;else{Aa=aa;break}case 32:ib=aa;break;default:break a}g++;l=Ka[g+1>>0]}var Va=0;if(42== l)Va=f("i32"),g++,l=Ka[g+1>>0];else for(;48<=l&&57>=l;)Va=10*Va+(l-48),g++,l=Ka[g+1>>0];var db=ca,Ca=-1;if(46==l){Ca=0;db=aa;g++;l=Ka[g+1>>0];if(42==l)Ca=f("i32"),g++;else for(;;){l=Ka[g+1>>0];if(48>l||57>0]}0>Ca&&(Ca=6,db=ca);var V;switch(String.fromCharCode(l)){case "h":l=Ka[g+2>>0];104==l?(g++,V=1):V=2;break;case "l":l=Ka[g+2>>0];108==l?(g++,V=8):V=4;break;case "L":case "q":case "j":V=8;break;case "z":case "t":case "I":V=4;break;default:V=ba}V&&g++;l=Ka[g+ 1>>0];switch(String.fromCharCode(l)){case "d":case "i":case "u":case "o":case "x":case "X":case "p":ha=100==l||105==l;V=V||4;var pa=m=f("i"+8*V),x;8==V&&(m=h.ca(m[0],m[1],117==l));4>=V&&(m=(ha?Db:Cb)(m&Math.pow(256,V)-1,8*V));var xb=Math.abs(m),ha="";if(100==l||105==l)x=8==V&&jc?jc.stringify(pa[0],pa[1],ba):Db(m,8*V).toString(10);else if(117==l)x=8==V&&jc?jc.stringify(pa[0],pa[1],aa):Cb(m,8*V).toString(10),m=Math.abs(m);else if(111==l)x=(ta?"0":"")+xb.toString(8);else if(120==l||88==l){ha=ta&&0!= m?"0x":"";if(8==V&&jc)if(pa[1]){x=(pa[1]>>>0).toString(16);for(ta=(pa[0]>>>0).toString(16);8>ta.length;)ta="0"+ta;x+=ta}else x=(pa[0]>>>0).toString(16);else if(0>m){m=-m;x=(xb-1).toString(16);pa=[];for(ta=0;taV&&-4<=V?(l=(103==l?"f":"F").charCodeAt(0),Ca-=V+1):(l=(103==l?"e":"E").charCodeAt(0),Ca--),V=Math.min(Ca, 20);if(101==l||69==l)x=m.toExponential(V),/[eE][-+]\d$/.test(x)&&(x=x.slice(0,-1)+"0"+x.slice(-1));else if(102==l||70==l)x=m.toFixed(V),0===m&&hc(m)&&(x="-"+x);ha=x.split("e");if(db&&!ta)for(;1V++;)ha[0]+="0";x=ha[0]+(1m?"-":"")+"inf",Aa=ca;for(;x.length< Va;)x=Ya?x+" ":Aa&&("-"==x[0]||"+"==x[0])?x[0]+"0"+x.slice(1):(Aa?"0":" ")+x;97>l&&(x=x.toUpperCase());x.split("").forEach(function(a){n.push(a.charCodeAt(0))});break;case "s":Aa=(Na=f("i8*"))?Yb(Na):6;db&&(Aa=Math.min(Aa,Ca));if(!Ya)for(;Aa>0]);else n=n.concat(Ab("(null)".substr(0,Aa),aa));if(Ya)for(;Aa>2]=n.length; break;case "%":n.push(m);break;default:for(ta=ha;ta>0])}g+=2}else n.push(m),g+=1}return n}function kc(a,b,f){f=ic(b,f);b=h.A();a=gc($a(f,"i8",Wa),1,f.length,a);h.J(b);return a}function lc(a,b){var f=ic(a,b),g=Bb(f);"\n"===g[g.length-1]&&(g=g.substr(0,g.length-1));e.print(g);return f.length}e._memcpy=mc;function nc(a){nc.Z||(xa=xa+4095&-4096,nc.Z=aa,oa(h.o),nc.W=h.o,h.o=function(){ua("cannot dynamically allocate, sbrk now has control")});var b=xa;0!=a&&nc.W(a);return b} function ab(a){return h.o(a+8)+8&4294967288}e._malloc=ab;var oc=$a(1,"i32*",Xa);dc.T=$a([0],"i8",Xa);Zb=h.U(4);Ma[Zb>>2]=0;kb=ra=h.C(wa);lb=kb+nb;mb=xa=h.C(lb);oa(mb>2]=fc;ec[fc]=0;fc++;return 0},___cxa_guard_acquire:function(a){return!Ka[a>>0]?Ka[a>>0]=1:0},___setErrNo:$b,_vfprintf:function(a,b,f){return kc(a,b,Ma[f>>2])},_emscripten_asm_const_int:function(a){var b= Array.prototype.slice.call(arguments,1);return h.O(a,b.length).apply(ba,b)|0},___assert_fail:function(a,b,f,g){za=aa;c("Assertion failed: "+sa(a)+", at: "+[b?sa(b):"unknown filename",f,g?sa(g):"unknown function"]+" at "+fb())},_atan2f:Gb,__ZSt18uncaught_exceptionv:Qb,___cxa_guard_release:function(){},_pwrite:function(a,b,f,g){a=va.$(a);if(!a)return $b(ac),-1;try{return va.write(a,Ka,b,f,g)}catch(k){return va.ba(k),-1}},_emscripten_asm_const_double:function(a){var b=Array.prototype.slice.call(arguments, 1);return+h.O(a,b.length).apply(ba,b)},_fprintf:kc,__reallyNegative:hc,_sbrk:nc,___cxa_begin_catch:function(a){Qb.K--;Sb.push(a);var b=Ub(a);b&&Tb[b].S++;return a},_sinf:Fb,_fileno:cc,___resumeException:function(a){Rb||(Rb=a);var b=Ub(a);b&&(Tb[b].S=0);c(a+" - Exception catching is disabled, this exception cannot be caught. Compile with -s DISABLE_EXCEPTION_CATCHING=0 or DISABLE_EXCEPTION_CATCHING=2 to catch.")},___cxa_find_matching_catch:Vb,_sysconf:function(a){switch(a){case 30:return 4096;case 132:case 133:case 12:case 137:case 138:case 15:case 235:case 16:case 17:case 18:case 19:case 20:case 149:case 13:case 10:case 236:case 153:case 9:case 21:case 22:case 159:case 154:case 14:case 77:case 78:case 139:case 80:case 81:case 79:case 82:case 68:case 67:case 164:case 11:case 29:case 47:case 48:case 95:case 52:case 51:case 46:return 200809; case 27:case 246:case 127:case 128:case 23:case 24:case 160:case 161:case 181:case 182:case 242:case 183:case 184:case 243:case 244:case 245:case 165:case 178:case 179:case 49:case 50:case 168:case 169:case 175:case 170:case 171:case 172:case 97:case 76:case 32:case 173:case 35:return-1;case 176:case 177:case 7:case 155:case 8:case 157:case 125:case 126:case 92:case 93:case 129:case 130:case 131:case 94:case 91:return 1;case 74:case 60:case 69:case 70:case 4:return 1024;case 31:case 42:case 72:return 32; case 87:case 26:case 33:return 2147483647;case 34:case 1:return 47839;case 38:case 36:return 99;case 43:case 37:return 2048;case 0:return 2097152;case 3:return 65536;case 28:return 32768;case 44:return 32767;case 75:return 16384;case 39:return 1E3;case 89:return 700;case 71:return 256;case 40:return 255;case 2:return 100;case 180:return 64;case 25:return 20;case 5:return 16;case 6:return 6;case 73:return 4;case 84:return"object"===typeof navigator?navigator.hardwareConcurrency||1:1}$b(22);return-1}, _pthread_getspecific:function(a){return ec[a]||0},_vprintf:function(a,b){return lc(a,Ma[b>>2])},_emscripten_memcpy_big:function(a,b,f){bb.set(bb.subarray(b,b+f),a);return a},_pthread_once:Xb,_printf:lc,_floorf:Pb,_sqrtf:Hb,_write:bc,___errno_location:function(){return Zb},_pthread_setspecific:function(a,b){if(!(a in ec))return 22;ec[a]=b;return 0},_fputc:dc,___cxa_throw:function(a,b,f){Tb[a]={e:a,N:a,type:b,qa:f,S:0};Rb=a;"uncaught_exception"in Qb?Qb.K++:Qb.K=1;c(a+" - Exception catching is disabled, this exception cannot be caught. Compile with -s DISABLE_EXCEPTION_CATCHING=0 or DISABLE_EXCEPTION_CATCHING=2 to catch.")}, _abort:function(){e.abort()},_fwrite:gc,_time:function(a){var b=Date.now()/1E3|0;a&&(Ma[a>>2]=b);return b},___cxa_allocate_exception:function(a){return ab(a)},__formatString:ic,___cxa_pure_virtual:function(){za=aa;c("Pure virtual function called!")},STACKTOP:ra,STACK_MAX:lb,tempDoublePtr:Ob,ABORT:za,NaN:NaN,Infinity:Infinity,_stderr:oc};// EMSCRIPTEN_START_ASM var i=(function(global,env,buffer) { "use asm";var a=new global.Int8Array(buffer);var b=new global.Int16Array(buffer);var c=new global.Int32Array(buffer);var d=new global.Uint8Array(buffer);var e=new global.Uint16Array(buffer);var f=new global.Uint32Array(buffer);var g=new global.Float32Array(buffer);var h=new global.Float64Array(buffer);var i=env.STACKTOP|0;var j=env.STACK_MAX|0;var k=env.tempDoublePtr|0;var l=env.ABORT|0;var m=env._stderr|0;var n=0;var o=0;var p=0;var q=0;var r=+env.NaN,s=+env.Infinity;var t=0,u=0,v=0,w=0,x=0.0,y=0,z=0,A=0,B=0.0;var C=0;var D=0;var E=0;var F=0;var G=0;var H=0;var I=0;var J=0;var K=0;var L=0;var M=global.Math.floor;var N=global.Math.abs;var O=global.Math.sqrt;var P=global.Math.pow;var Q=global.Math.cos;var R=global.Math.sin;var S=global.Math.tan;var T=global.Math.acos;var U=global.Math.asin;var V=global.Math.atan;var W=global.Math.atan2;var X=global.Math.exp;var Y=global.Math.log;var Z=global.Math.ceil;var _=global.Math.imul;var $=env.abort;var aa=env.assert;var ba=env.min;var ca=env.jsCall;var da=env.invoke_iiii;var ea=env.invoke_viiiii;var fa=env.invoke_did;var ga=env.invoke_vi;var ha=env.invoke_diiiid;var ia=env.invoke_vii;var ja=env.invoke_viidii;var ka=env.invoke_ii;var la=env.invoke_viidi;var ma=env.invoke_viii;var na=env.invoke_v;var oa=env.invoke_viid;var pa=env.invoke_viiiiii;var qa=env.invoke_iii;var ra=env.invoke_iiiiii;var sa=env.invoke_viiii;var ta=env._cosf;var ua=env._send;var va=env._pthread_key_create;var wa=env.___cxa_guard_acquire;var xa=env.___setErrNo;var ya=env._vfprintf;var za=env._emscripten_asm_const_int;var Aa=env.___assert_fail;var Ba=env._atan2f;var Ca=env.__ZSt18uncaught_exceptionv;var Da=env.___cxa_guard_release;var Ea=env._pwrite;var Fa=env._emscripten_asm_const_double;var Ga=env._fprintf;var Ha=env.__reallyNegative;var Ia=env._sbrk;var Ja=env.___cxa_begin_catch;var Ka=env._sinf;var La=env._fileno;var Ma=env.___resumeException;var Na=env.___cxa_find_matching_catch;var Oa=env._sysconf;var Pa=env._pthread_getspecific;var Qa=env._vprintf;var Ra=env._emscripten_memcpy_big;var Sa=env._pthread_once;var Ta=env._printf;var Ua=env._floorf;var Va=env._sqrtf;var Wa=env._write;var Xa=env.___errno_location;var Ya=env._pthread_setspecific;var Za=env._fputc;var _a=env.___cxa_throw;var $a=env._abort;var ab=env._fwrite;var bb=env._time;var cb=env.___cxa_allocate_exception;var db=env.__formatString;var eb=env.___cxa_pure_virtual;var fb=0.0; function wb(a){a=a|0;var b=0;b=i;i=i+a|0;i=i+15&-16;return b|0}function xb(){return i|0}function yb(a){a=a|0;i=a}function zb(a,b){a=a|0;b=b|0;if(!n){n=a;o=b}}function Ab(b){b=b|0;a[k>>0]=a[b>>0];a[k+1>>0]=a[b+1>>0];a[k+2>>0]=a[b+2>>0];a[k+3>>0]=a[b+3>>0]}function Bb(b){b=b|0;a[k>>0]=a[b>>0];a[k+1>>0]=a[b+1>>0];a[k+2>>0]=a[b+2>>0];a[k+3>>0]=a[b+3>>0];a[k+4>>0]=a[b+4>>0];a[k+5>>0]=a[b+5>>0];a[k+6>>0]=a[b+6>>0];a[k+7>>0]=a[b+7>>0]}function Cb(a){a=a|0;C=a}function Db(){return C|0}function Eb(){var a=0,b=0,d=0;a=i;b=NB(4)|0;if(b){d=b;c[d>>2]=4112;i=a;return d|0}while(1){b=c[4582]|0;c[4582]=b+0;if(!b){b=4;break}qb[b&63]();d=NB(4)|0;if(d){b=5;break}}if((b|0)==4){d=cb(4)|0;c[d>>2]=18168;_a(d|0,18216,116)}else if((b|0)==5){c[d>>2]=4112;i=a;return d|0}return 0}function Fb(a,b){a=a|0;b=b|0;var d=0;d=i;lb[c[(c[a>>2]|0)+16>>2]&127](a,b);i=d;return}function Gb(a,b){a=a|0;b=b|0;var d=0;d=i;lb[c[(c[a>>2]|0)+20>>2]&127](a,b);i=d;return}function Hb(a){a=a|0;var b=0;b=i;if(!a){i=b;return}jb[c[(c[a>>2]|0)+4>>2]&127](a);i=b;return}function Ib(a){a=a|0;return c[a+16>>2]|0}function Jb(a,b){a=a|0;b=b|0;c[a+16>>2]=b;return}function Kb(a){a=a|0;var b=0;b=i;if(a)OB(a);i=b;return}function Lb(a){a=a|0;return a+80|0}function Mb(a){a=a|0;return a+88|0}function Nb(a,b){a=a|0;b=+b;g[a+104>>2]=b;return}function Ob(a){a=a|0;return+(+g[a+104>>2])}function Pb(a,b){a=a|0;b=+b;g[a+68>>2]=b;return}function Qb(a){a=a|0;return+(+g[a+68>>2])}function Rb(a,b){a=a|0;b=+b;g[a+72>>2]=b;return}function Sb(a){a=a|0;return+(+g[a+72>>2])}function Tb(a){a=a|0;return c[a+4>>2]|0}function Ub(a){a=a|0;return c[a+48>>2]|0}function Vb(a){a=a|0;return c[a+52>>2]|0}function Wb(b){b=b|0;var d=0,e=0,f=0;e=i;i=i+16|0;d=e;if((a[16]|0)==0?(wa(16)|0)!=0:0)Da(16);lb[c[c[b>>2]>>2]&127](d,b);f=d;b=c[f+4>>2]|0;d=8;c[d>>2]=c[f>>2];c[d+4>>2]=b;i=e;return 8}function Xb(b){b=b|0;var d=0,e=0,f=0;e=i;i=i+16|0;d=e;if((a[32]|0)==0?(wa(32)|0)!=0:0)Da(32);lb[c[(c[b>>2]|0)+4>>2]&127](d,b);f=d;b=c[f+4>>2]|0;d=24;c[d>>2]=c[f>>2];c[d+4>>2]=b;i=e;return 24}function Yb(b,d){b=b|0;d=+d;var e=0,f=0,g=0;f=i;i=i+16|0;e=f;if((a[48]|0)==0?(wa(48)|0)!=0:0)Da(48);rb[c[(c[b>>2]|0)+8>>2]&63](e,b,d);g=e;b=c[g+4>>2]|0;e=40;c[e>>2]=c[g>>2];c[e+4>>2]=b;i=f;return 40}function Zb(a,b){a=a|0;b=+b;var d=0;d=i;b=+ib[c[(c[a>>2]|0)+12>>2]&63](a,b);i=d;return+b}function _b(a){a=a|0;return c[a+12>>2]|0}function $b(a){a=a|0;return c[a+64>>2]|0}function ac(a,b){a=a|0;b=b|0;c[a+64>>2]=b;return}function bc(a){a=a|0;var d=0;d=i;if(!(b[(c[a+48>>2]|0)+4>>1]&32)){a=0;i=d;return a|0}a=(b[(c[a+52>>2]|0)+4>>1]&32)!=0;i=d;return a|0}function cc(b){b=b|0;return(a[b+61>>0]|0)!=0|0}function dc(a){a=a|0;var b=0;b=i;if(!a){i=b;return}jb[c[(c[a>>2]|0)+28>>2]&127](a);i=b;return}function ec(){var a=0,b=0,d=0;a=i;b=NB(36)|0;if(b){d=b;i=a;return d|0}while(1){b=c[4582]|0;c[4582]=b+0;if(!b){b=4;break}qb[b&63]();d=NB(36)|0;if(d){b=5;break}}if((b|0)==4){d=cb(4)|0;c[d>>2]=18168;_a(d|0,18216,116)}else if((b|0)==5){i=a;return d|0}return 0}function fc(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0;e=i;f=NB(36)|0;a:do if(!f){while(1){f=c[4582]|0;c[4582]=f+0;if(!f)break;qb[f&63]();f=NB(36)|0;if(f)break a}f=cb(4)|0;c[f>>2]=18168;_a(f|0,18216,116)}while(0);h=f+12|0;g=f+24|0;c[f+0>>2]=c[a+0>>2];c[f+4>>2]=c[a+4>>2];c[f+8>>2]=c[a+8>>2];c[h+0>>2]=c[b+0>>2];c[h+4>>2]=c[b+4>>2];c[h+8>>2]=c[b+8>>2];c[g+0>>2]=c[d+0>>2];c[g+4>>2]=c[d+4>>2];c[g+8>>2]=c[d+8>>2];i=e;return f|0}function gc(a){a=a|0;var b=0,d=0;b=i;d=a+0|0;a=d+36|0;do{c[d>>2]=0;d=d+4|0}while((d|0)<(a|0));i=b;return}function hc(b,d){b=b|0;d=d|0;var e=0,f=0;f=i;i=i+16|0;e=f;if((a[72]|0)==0?(wa(72)|0)!=0:0)Da(72);Jx(e,b,d);c[14]=c[e+0>>2];c[15]=c[e+4>>2];c[16]=c[e+8>>2];i=f;return 56}function ic(b,c){b=b|0;c=c|0;var d=0,e=0.0,f=0.0,h=0.0,j=0.0,k=0.0,l=0.0,m=0.0;d=i;if((a[88]|0)==0?(wa(88)|0)!=0:0)Da(88);f=+g[b>>2];h=+g[b+12>>2];e=+g[b+4>>2];j=+g[b+16>>2];k=f*j-h*e;if(k!=0.0)k=1.0/k;l=+g[c>>2];m=+g[c+4>>2];j=+(k*(j*l-h*m));k=+(k*(f*m-e*l));b=80;g[b>>2]=j;g[b+4>>2]=k;i=d;return 80}function jc(a,b){a=a|0;b=b|0;var d=0,e=0.0,f=0.0,h=0.0,j=0.0,k=0.0;d=i;e=+g[a>>2];h=+g[a+12>>2];f=+g[a+4>>2];j=+g[a+16>>2];k=e*j-h*f;if(k!=0.0)k=1.0/k;g[b>>2]=j*k;j=-k;g[b+12>>2]=h*j;g[b+8>>2]=0.0;g[b+4>>2]=f*j;g[b+16>>2]=e*k;a=b+20|0;c[a+0>>2]=0;c[a+4>>2]=0;c[a+8>>2]=0;c[a+12>>2]=0;i=d;return}function kc(a,b){a=a|0;b=b|0;var c=0;c=i;Mx(a,b);i=c;return}function lc(a){a=a|0;return a|0}function mc(a,b){a=a|0;b=b|0;var d=0;d=i;c[a+0>>2]=c[b+0>>2];c[a+4>>2]=c[b+4>>2];c[a+8>>2]=c[b+8>>2];i=d;return}function nc(a){a=a|0;return a+12|0}function oc(a,b){a=a|0;b=b|0;var d=0;d=i;a=a+12|0;c[a+0>>2]=c[b+0>>2];c[a+4>>2]=c[b+4>>2];c[a+8>>2]=c[b+8>>2];i=d;return}function pc(a){a=a|0;return a+24|0}function qc(a,b){a=a|0;b=b|0;var d=0;d=i;a=a+24|0;c[a+0>>2]=c[b+0>>2];c[a+4>>2]=c[b+4>>2];c[a+8>>2]=c[b+8>>2];i=d;return}function rc(a){a=a|0;var b=0;b=i;if(a)OB(a);i=b;return}function sc(a){a=a|0;return c[(c[a+12>>2]|0)+4>>2]|0}function tc(a){a=a|0;return c[a+12>>2]|0}function uc(f,h){f=f|0;h=h|0;var j=0,k=0,l=0,m=0;j=i;k=f+38|0;if((h&1|0)==(d[k>>0]|0|0)){i=j;return}f=c[f+8>>2]|0;l=f+4|0;m=e[l>>1]|0;if(!(m&2)){b[l>>1]=m|2;g[f+144>>2]=0.0}a[k>>0]=h&1;i=j;return}function vc(b){b=b|0;return(a[b+38>>0]|0)!=0|0}function wc(a,d){a=a|0;d=d|0;var e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0;e=i;l=a+32|0;b[l+0>>1]=b[d+0>>1]|0;b[l+2>>1]=b[d+2>>1]|0;b[l+4>>1]=b[d+4>>1]|0;d=c[a+8>>2]|0;if(!d){i=e;return}g=c[d+112>>2]|0;if(g)do{f=c[g+4>>2]|0;if((c[f+48>>2]|0)==(a|0)?1:(c[f+52>>2]|0)==(a|0)){l=f+4|0;c[l>>2]=c[l>>2]|8}g=c[g+12>>2]|0}while((g|0)!=0);h=c[d+88>>2]|0;if(!h){i=e;return}d=a+28|0;if((c[d>>2]|0)<=0){i=e;return}a=a+24|0;g=h+102912|0;f=h+102908|0;k=h+102904|0;l=c[g>>2]|0;j=0;do{h=c[(c[a>>2]|0)+(j*28|0)+24>>2]|0;if((l|0)==(c[f>>2]|0)){m=c[k>>2]|0;c[f>>2]=l<<1;l=NB(l<<3)|0;c[k>>2]=l;SB(l|0,m|0,c[g>>2]<<2|0)|0;OB(m);l=c[g>>2]|0}c[(c[k>>2]|0)+(l<<2)>>2]=h;l=(c[g>>2]|0)+1|0;c[g>>2]=l;j=j+1|0}while((j|0)<(c[d>>2]|0));i=e;return}function xc(a){a=a|0;return a+32|0}function yc(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,j=0,k=0,l=0;b=i;d=c[a+8>>2]|0;if(!d){i=b;return}f=c[d+112>>2]|0;if(f)do{e=c[f+4>>2]|0;if((c[e+48>>2]|0)==(a|0)?1:(c[e+52>>2]|0)==(a|0)){k=e+4|0;c[k>>2]=c[k>>2]|8}f=c[f+12>>2]|0}while((f|0)!=0);g=c[d+88>>2]|0;if(!g){i=b;return}d=a+28|0;if((c[d>>2]|0)<=0){i=b;return}a=a+24|0;f=g+102912|0;e=g+102908|0;g=g+102904|0;k=c[f>>2]|0;j=0;do{h=c[(c[a>>2]|0)+(j*28|0)+24>>2]|0;if((k|0)==(c[e>>2]|0)){l=c[g>>2]|0;c[e>>2]=k<<1;k=NB(k<<3)|0;c[g>>2]=k;SB(k|0,l|0,c[f>>2]<<2|0)|0;OB(l);k=c[f>>2]|0}c[(c[g>>2]|0)+(k<<2)>>2]=h;k=(c[f>>2]|0)+1|0;c[f>>2]=k;j=j+1|0}while((j|0)<(c[d>>2]|0));i=b;return}function zc(a){a=a|0;return c[a+8>>2]|0}function Ac(a){a=a|0;return c[a+4>>2]|0}function Bc(a){a=a|0;return c[a+40>>2]|0}function Cc(a,b){a=a|0;b=b|0;c[a+40>>2]=b;return}function Dc(a,b){a=a|0;b=b|0;var d=0,e=0;d=i;e=c[a+12>>2]|0;a=gb[c[(c[e>>2]|0)+16>>2]&63](e,(c[a+8>>2]|0)+12|0,b)|0;i=d;return a|0}function Ec(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0;f=i;g=c[a+12>>2]|0;b=ub[c[(c[g>>2]|0)+20>>2]&63](g,b,d,(c[a+8>>2]|0)+12|0,e)|0;i=f;return b|0}function Fc(a,b){a=a|0;b=b|0;var d=0,e=0;d=i;e=c[a+12>>2]|0;rb[c[(c[e>>2]|0)+28>>2]&63](e,b,+g[a>>2]);i=d;return}function Gc(a,b){a=a|0;b=+b;var d=0;d=i;if(((g[k>>2]=b,c[k>>2]|0)&2139095040|0)!=2139095040&b>=0.0){g[a>>2]=b;i=d;return}else Aa(4048,4e3,295,4088)}function Hc(a){a=a|0;return+(+g[a>>2])}function Ic(a){a=a|0;return+(+g[a+16>>2])}function Jc(a,b){a=a|0;b=+b;g[a+16>>2]=b;return}function Kc(a){a=a|0;return+(+g[a+20>>2])}function Lc(a,b){a=a|0;b=+b;g[a+20>>2]=b;return}function Mc(a,b){a=a|0;b=b|0;var d=0;d=i;if((b|0)>-1?(c[a+28>>2]|0)>(b|0):0){i=d;return(c[a+24>>2]|0)+(b*28|0)|0}Aa(3952,4e3,341,4040);return 0}function Nc(a,b){a=a|0;b=b|0;var c=0;c=i;ny(a,b);i=c;return}function Oc(a){a=a|0;var b=0;b=i;if(a)OB(a);i=b;return}function Pc(){var a=0,d=0;a=i;d=NB(6)|0;a:do if(!d){while(1){d=c[4582]|0;c[4582]=d+0;if(!d)break;qb[d&63]();d=NB(6)|0;if(d)break a}d=cb(4)|0;c[d>>2]=18168;_a(d|0,18216,116)}while(0);b[d>>1]=1;b[d+2>>1]=-1;b[d+4>>1]=0;i=a;return d|0}function Qc(a){a=a|0;return b[a>>1]|0}function Rc(a,c){a=a|0;c=c|0;b[a>>1]=c;return}function Sc(a){a=a|0;return b[a+2>>1]|0}function Tc(a,c){a=a|0;c=c|0;b[a+2>>1]=c;return}function Uc(a){a=a|0;return b[a+4>>1]|0}function Vc(a,c){a=a|0;c=c|0;b[a+4>>1]=c;return}function Wc(a){a=a|0;var b=0;b=i;if(a)OB(a);i=b;return}function Xc(){var a=0,b=0,d=0;a=i;b=NB(4)|0;if(b){d=b;c[d>>2]=3616;i=a;return d|0}while(1){b=c[4582]|0;c[4582]=b+0;if(!b){b=4;break}qb[b&63]();d=NB(4)|0;if(d){b=5;break}}if((b|0)==4){d=cb(4)|0;c[d>>2]=18168;_a(d|0,18216,116)}else if((b|0)==5){c[d>>2]=3616;i=a;return d|0}return 0}function Yc(a,b){a=a|0;b=b|0;var d=0;d=i;a=tb[c[(c[a>>2]|0)+8>>2]&63](a,b)|0;i=d;return a|0}function Zc(a){a=a|0;var b=0;b=i;if(!a){i=b;return}jb[c[(c[a>>2]|0)+4>>2]&127](a);i=b;return}function _c(a,d){a=a|0;d=d|0;var e=0,f=0,h=0,j=0,k=0;e=i;h=c[a+52>>2]|0;f=h+4|0;j=b[f>>1]|0;if((j&2)==0?(k=j&65535,(k&2|0)==0):0){b[f>>1]=k|2;g[h+144>>2]=0.0}h=d;j=c[h+4>>2]|0;k=a+76|0;c[k>>2]=c[h>>2];c[k+4>>2]=j;i=e;return}function $c(a){a=a|0;return a+76|0}function ad(a,b){a=a|0;b=+b;g[a+104>>2]=b;return}function bd(a){a=a|0;return+(+g[a+104>>2])}function cd(a,b){a=a|0;b=+b;g[a+84>>2]=b;return}function dd(a){a=a|0;return+(+g[a+84>>2])}function ed(a,b){a=a|0;b=+b;g[a+88>>2]=b;return}function fd(a){a=a|0;return+(+g[a+88>>2])}function gd(a){a=a|0;return c[a+4>>2]|0}function hd(a){a=a|0;return c[a+48>>2]|0}function id(a){a=a|0;return c[a+52>>2]|0}function jd(b){b=b|0;var d=0,e=0,f=0;e=i;i=i+16|0;d=e;if((a[104]|0)==0?(wa(104)|0)!=0:0)Da(104);lb[c[c[b>>2]>>2]&127](d,b);f=d;b=c[f+4>>2]|0;d=96;c[d>>2]=c[f>>2];c[d+4>>2]=b;i=e;return 96}function kd(b){b=b|0;var d=0,e=0,f=0;e=i;i=i+16|0;d=e;if((a[120]|0)==0?(wa(120)|0)!=0:0)Da(120);lb[c[(c[b>>2]|0)+4>>2]&127](d,b);f=d;b=c[f+4>>2]|0;d=112;c[d>>2]=c[f>>2];c[d+4>>2]=b;i=e;return 112}function ld(b,d){b=b|0;d=+d;var e=0,f=0,g=0;f=i;i=i+16|0;e=f;if((a[136]|0)==0?(wa(136)|0)!=0:0)Da(136);rb[c[(c[b>>2]|0)+8>>2]&63](e,b,d);g=e;b=c[g+4>>2]|0;e=128;c[e>>2]=c[g>>2];c[e+4>>2]=b;i=f;return 128}function md(a,b){a=a|0;b=+b;var d=0;d=i;b=+ib[c[(c[a>>2]|0)+12>>2]&63](a,b);i=d;return+b}function nd(a){a=a|0;return c[a+12>>2]|0}function od(a){a=a|0;return c[a+64>>2]|0}function pd(a,b){a=a|0;b=b|0;c[a+64>>2]=b;return}function qd(a){a=a|0;var d=0;d=i;if(!(b[(c[a+48>>2]|0)+4>>1]&32)){a=0;i=d;return a|0}a=(b[(c[a+52>>2]|0)+4>>1]&32)!=0;i=d;return a|0}function rd(b){b=b|0;return(a[b+61>>0]|0)!=0|0}function sd(a){a=a|0;var b=0;b=i;if(!a){i=b;return}jb[c[(c[a>>2]|0)+28>>2]&127](a);i=b;return}function td(){var a=0,b=0,d=0;a=i;b=NB(8)|0;if(b){d=b;i=a;return d|0}while(1){b=c[4582]|0;c[4582]=b+0;if(!b){b=4;break}qb[b&63]();d=NB(8)|0;if(d){b=5;break}}if((b|0)==4){d=cb(4)|0;c[d>>2]=18168;_a(d|0,18216,116)}else if((b|0)==5){i=a;return d|0}return 0}function ud(a){a=+a;var b=0,d=0;b=i;d=NB(8)|0;a:do if(!d){while(1){d=c[4582]|0;c[4582]=d+0;if(!d)break;qb[d&63]();d=NB(8)|0;if(d)break a}d=cb(4)|0;c[d>>2]=18168;_a(d|0,18216,116)}while(0);g[d>>2]=+R(+a);g[d+4>>2]=+Q(+a);i=b;return d|0}function vd(a,b){a=a|0;b=+b;g[a>>2]=+R(+b);g[a+4>>2]=+Q(+b);return}function wd(a){a=a|0;g[a>>2]=0.0;g[a+4>>2]=1.0;return}function xd(a){a=a|0;var b=0.0;b=+W(+(+g[a>>2]),+(+g[a+4>>2]));return+b}function yd(b){b=b|0;var c=0,d=0.0,e=0.0;c=i;if((a[152]|0)==0?(wa(152)|0)!=0:0)Da(152);e=+(+g[b+4>>2]);d=+(+g[b>>2]);b=144;g[b>>2]=e;g[b+4>>2]=d;i=c;return 144}function zd(b){b=b|0;var c=0,d=0.0,e=0.0;c=i;if((a[168]|0)==0?(wa(168)|0)!=0:0)Da(168);e=+-+g[b>>2];d=+(+g[b+4>>2]);b=160;g[b>>2]=e;g[b+4>>2]=d;i=c;return 160}function Ad(a){a=a|0;return+(+g[a>>2])}function Bd(a,b){a=a|0;b=+b;g[a>>2]=b;return}function Cd(a){a=a|0;return+(+g[a+4>>2])}function Dd(a,b){a=a|0;b=+b;g[a+4>>2]=b;return}function Ed(a){a=a|0;var b=0;b=i;if(a)OB(a);i=b;return}function Fd(a,d){a=a|0;d=d|0;var f=0,h=0,j=0,k=0,l=0;f=i;h=a+68|0;if(!(+g[d>>2]!=+g[h>>2])?!(+g[d+4>>2]!=+g[a+72>>2]):0){i=f;return}j=c[a+48>>2]|0;k=j+4|0;l=e[k>>1]|0;if(!(l&2)){b[k>>1]=l|2;g[j+144>>2]=0.0}a=c[a+52>>2]|0;j=a+4|0;k=e[j>>1]|0;if(!(k&2)){b[j>>1]=k|2;g[a+144>>2]=0.0}j=d;k=c[j+4>>2]|0;l=h;c[l>>2]=c[j>>2];c[l+4>>2]=k;i=f;return}function Gd(a){a=a|0;return a+68|0}function Hd(a,d){a=a|0;d=+d;var f=0,h=0,j=0,k=0,l=0;f=i;h=a+76|0;if(!(+g[h>>2]!=d)){i=f;return}j=c[a+48>>2]|0;k=j+4|0;l=e[k>>1]|0;if(!(l&2)){b[k>>1]=l|2;g[j+144>>2]=0.0}a=c[a+52>>2]|0;j=a+4|0;k=e[j>>1]|0;if(!(k&2)){b[j>>1]=k|2;g[a+144>>2]=0.0}g[h>>2]=d;i=f;return}function Id(a){a=a|0;return+(+g[a+76>>2])}function Jd(a,b){a=a|0;b=+b;var d=0;d=i;if(((g[k>>2]=b,c[k>>2]|0)&2139095040|0)!=2139095040&b>=0.0){g[a+92>>2]=b;i=d;return}else Aa(14504,4840,228,14600)}function Kd(a){a=a|0;return+(+g[a+92>>2])}function Ld(a,b){a=a|0;b=+b;var d=0;d=i;if(((g[k>>2]=b,c[k>>2]|0)&2139095040|0)!=2139095040&b>=0.0){g[a+96>>2]=b;i=d;return}else Aa(14616,4840,239,14656)}function Md(a){a=a|0;return+(+g[a+96>>2])}function Nd(a,b){a=a|0;b=+b;var d=0;d=i;if(((g[k>>2]=b,c[k>>2]|0)&2139095040|0)!=2139095040&b>=0.0&b<=1.0){g[a+100>>2]=b;i=d;return}else Aa(4896,4840,250,4952)}function Od(a){a=a|0;return+(+g[a+100>>2])}function Pd(a){a=a|0;return c[a+4>>2]|0}function Qd(a){a=a|0;return c[a+48>>2]|0}function Rd(a){a=a|0;return c[a+52>>2]|0}function Sd(b){b=b|0;var d=0,e=0,f=0;e=i;i=i+16|0;d=e;if((a[184]|0)==0?(wa(184)|0)!=0:0)Da(184);lb[c[c[b>>2]>>2]&127](d,b);f=d;b=c[f+4>>2]|0;d=176;c[d>>2]=c[f>>2];c[d+4>>2]=b;i=e;return 176}function Td(b){b=b|0;var d=0,e=0,f=0;e=i;i=i+16|0;d=e;if((a[200]|0)==0?(wa(200)|0)!=0:0)Da(200);lb[c[(c[b>>2]|0)+4>>2]&127](d,b);f=d;b=c[f+4>>2]|0;d=192;c[d>>2]=c[f>>2];c[d+4>>2]=b;i=e;return 192}function Ud(b,d){b=b|0;d=+d;var e=0,f=0,g=0;f=i;i=i+16|0;e=f;if((a[216]|0)==0?(wa(216)|0)!=0:0)Da(216);rb[c[(c[b>>2]|0)+8>>2]&63](e,b,d);g=e;b=c[g+4>>2]|0;e=208;c[e>>2]=c[g>>2];c[e+4>>2]=b;i=f;return 208}function Vd(a,b){a=a|0;b=+b;var d=0;d=i;b=+ib[c[(c[a>>2]|0)+12>>2]&63](a,b);i=d;return+b}function Wd(a){a=a|0;return c[a+12>>2]|0}function Xd(a){a=a|0;return c[a+64>>2]|0}function Yd(a,b){a=a|0;b=b|0;c[a+64>>2]=b;return}function Zd(a){a=a|0;var d=0;d=i;if(!(b[(c[a+48>>2]|0)+4>>1]&32)){a=0;i=d;return a|0}a=(b[(c[a+52>>2]|0)+4>>1]&32)!=0;i=d;return a|0}function _d(b){b=b|0;return(a[b+61>>0]|0)!=0|0}function $d(a){a=a|0;var b=0;b=i;if(!a){i=b;return}jb[c[(c[a>>2]|0)+28>>2]&127](a);i=b;return}function ae(a){a=a|0;return+(+g[a>>2])}function be(a,b){a=a|0;b=+b;g[a>>2]=b;return}function ce(a){a=a|0;return+(+g[a+4>>2])}function de(a,b){a=a|0;b=+b;g[a+4>>2]=b;return}function ee(a){a=a|0;return+(+g[a+8>>2])}function fe(a,b){a=a|0;b=+b;g[a+8>>2]=b;return}function ge(a){a=a|0;return+(+g[a+12>>2])}function he(a,b){a=a|0;b=+b;g[a+12>>2]=b;return}function ie(a){a=a|0;return+(+g[a+16>>2])}function je(a,b){a=a|0;b=+b;g[a+16>>2]=b;return}function ke(a){a=a|0;return+(+g[a+20>>2])}function le(a,b){a=a|0;b=+b;g[a+20>>2]=b;return}function me(a){a=a|0;return+(+g[a+24>>2])}function ne(a,b){a=a|0;b=+b;g[a+24>>2]=b;return}function oe(a){a=a|0;return+(+g[a+28>>2])}function pe(a,b){a=a|0;b=+b;g[a+28>>2]=b;return}function qe(a){a=a|0;var b=0;b=i;if(a)OB(a);i=b;return}function re(a){a=a|0;var b=0;b=i;if(a)OB(a);i=b;return}function se(){var b=0,d=0,e=0,f=0;b=i;d=NB(52)|0;a:do if(!d){while(1){d=c[4582]|0;c[4582]=d+0;if(!d)break;qb[d&63]();d=NB(52)|0;if(d)break a}d=cb(4)|0;c[d>>2]=18168;_a(d|0,18216,116)}while(0);c[d+44>>2]=0;f=d+4|0;e=d+36|0;c[f+0>>2]=0;c[f+4>>2]=0;c[f+8>>2]=0;c[f+12>>2]=0;c[f+16>>2]=0;c[f+20>>2]=0;c[f+24>>2]=0;c[f+28>>2]=0;a[e>>0]=1;a[d+37>>0]=1;a[d+38>>0]=0;a[d+39>>0]=0;c[d>>2]=0;a[d+40>>0]=1;g[d+48>>2]=1.0;i=b;return d|0}function te(a){a=a|0;return c[a>>2]|0}function ue(a,b){a=a|0;b=b|0;c[a>>2]=b;return}function ve(a){a=a|0;return a+4|0}function we(a,b){a=a|0;b=b|0;var d=0,e=0;e=b;d=c[e+4>>2]|0;b=a+4|0;c[b>>2]=c[e>>2];c[b+4>>2]=d;return}function xe(a){a=a|0;return+(+g[a+12>>2])}function ye(a,b){a=a|0;b=+b;g[a+12>>2]=b;return}function ze(a){a=a|0;return a+16|0}function Ae(a,b){a=a|0;b=b|0;var d=0,e=0;e=b;d=c[e+4>>2]|0;b=a+16|0;c[b>>2]=c[e>>2];c[b+4>>2]=d;return}function Be(a){a=a|0;return+(+g[a+24>>2])}function Ce(a,b){a=a|0;b=+b;g[a+24>>2]=b;return}function De(a){a=a|0;return+(+g[a+28>>2])}function Ee(a,b){a=a|0;b=+b;g[a+28>>2]=b;return}function Fe(a){a=a|0;return+(+g[a+32>>2])}function Ge(a,b){a=a|0;b=+b;g[a+32>>2]=b;return}function He(b){b=b|0;return(a[b+36>>0]|0)!=0|0}function Ie(b,c){b=b|0;c=c|0;a[b+36>>0]=c&1;return}function Je(b){b=b|0;return(a[b+37>>0]|0)!=0|0}function Ke(b,c){b=b|0;c=c|0;a[b+37>>0]=c&1;return}function Le(b){b=b|0;return(a[b+38>>0]|0)!=0|0}function Me(b,c){b=b|0;c=c|0;a[b+38>>0]=c&1;return}function Ne(b){b=b|0;return(a[b+39>>0]|0)!=0|0}function Oe(b,c){b=b|0;c=c|0;a[b+39>>0]=c&1;return}function Pe(b){b=b|0;return(a[b+40>>0]|0)!=0|0}function Qe(b,c){b=b|0;c=c|0;a[b+40>>0]=c&1;return}function Re(a){a=a|0;return c[a+44>>2]|0}function Se(a,b){a=a|0;b=b|0;c[a+44>>2]=b;return}function Te(a){a=a|0;return+(+g[a+48>>2])}function Ue(a,b){a=a|0;b=+b;g[a+48>>2]=b;return}function Ve(a){a=a|0;var b=0;b=i;if(a)OB(a);i=b;return}function We(){var a=0,b=0,d=0;a=i;b=NB(4)|0;if(b){d=b;c[d>>2]=3264;i=a;return d|0}while(1){b=c[4582]|0;c[4582]=b+0;if(!b){b=4;break}qb[b&63]();d=NB(4)|0;if(d){b=5;break}}if((b|0)==4){d=cb(4)|0;c[d>>2]=18168;_a(d|0,18216,116)}else if((b|0)==5){c[d>>2]=3264;i=a;return d|0}return 0}function Xe(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=+f;var g=0;g=i;f=+kb[c[(c[a>>2]|0)+8>>2]&63](a,b,d,e,f);i=g;return+f}function Ye(a){a=a|0;var b=0;b=i;if(!a){i=b;return}jb[c[(c[a>>2]|0)+4>>2]&127](a);i=b;return}function Ze(b){b=b|0;return a[b>>0]|0}function _e(b,c){b=b|0;c=c|0;a[b>>0]=c;return}function $e(b){b=b|0;return a[b+1>>0]|0}function af(b,c){b=b|0;c=c|0;a[b+1>>0]=c;return}function bf(b){b=b|0;return a[b+2>>0]|0}function cf(b,c){b=b|0;c=c|0;a[b+2>>0]=c;return}function df(b){b=b|0;return a[b+3>>0]|0}function ef(b,c){b=b|0;c=c|0;a[b+3>>0]=c;return}function ff(a){a=a|0;var b=0;b=i;if(a)OB(a);i=b;return}function gf(){var a=0,b=0,d=0;a=i;b=NB(8)|0;if(b){d=b;i=a;return d|0}while(1){b=c[4582]|0;c[4582]=b+0;if(!b){b=4;break}qb[b&63]();d=NB(8)|0;if(d){b=5;break}}if((b|0)==4){d=cb(4)|0;c[d>>2]=18168;_a(d|0,18216,116)}else if((b|0)==5){i=a;return d|0}return 0}function hf(a,b){a=+a;b=+b;var d=0,e=0;d=i;e=NB(8)|0;a:do if(!e){while(1){e=c[4582]|0;c[4582]=e+0;if(!e)break;qb[e&63]();e=NB(8)|0;if(e)break a}e=cb(4)|0;c[e>>2]=18168;_a(e|0,18216,116)}while(0);g[e>>2]=a;g[e+4>>2]=b;i=d;return e|0}function jf(a){a=a|0;g[a>>2]=0.0;g[a+4>>2]=0.0;return}function kf(a,b,c){a=a|0;b=+b;c=+c;g[a>>2]=b;g[a+4>>2]=c;return}function lf(a,b){a=a|0;b=b|0;g[a>>2]=+g[b>>2]+ +g[a>>2];a=a+4|0;g[a>>2]=+g[b+4>>2]+ +g[a>>2];return}function mf(a,b){a=a|0;b=b|0;g[a>>2]=+g[a>>2]- +g[b>>2];a=a+4|0;g[a>>2]=+g[a>>2]- +g[b+4>>2];return}function nf(a,b){a=a|0;b=+b;g[a>>2]=+g[a>>2]*b;a=a+4|0;g[a>>2]=+g[a>>2]*b;return}function of(a){a=a|0;var b=0.0,c=0.0;c=+g[a>>2];b=+g[a+4>>2];b=+O(+(c*c+b*b));return+b}function pf(a){a=a|0;var b=0.0,c=0.0;c=+g[a>>2];b=+g[a+4>>2];return+(c*c+b*b)}function qf(a){a=a|0;var b=0,c=0.0,d=0.0,e=0.0,f=0,h=0.0;b=i;d=+g[a>>2];f=a+4|0;e=+g[f>>2];c=+O(+(d*d+e*e));if(c<1.1920928955078125e-7){e=0.0;i=b;return+e}h=1.0/c;g[a>>2]=d*h;g[f>>2]=e*h;e=c;i=b;return+e}function rf(a){a=a|0;var b=0;b=i;if(((g[k>>2]=+g[a>>2],c[k>>2]|0)&2139095040|0)==2139095040){a=0;i=b;return a|0}a=((g[k>>2]=+g[a+4>>2],c[k>>2]|0)&2139095040|0)!=2139095040;i=b;return a|0}function sf(b){b=b|0;var c=0,d=0.0,e=0.0;c=i;if((a[232]|0)==0?(wa(232)|0)!=0:0)Da(232);e=+-+g[b+4>>2];d=+(+g[b>>2]);b=224;g[b>>2]=e;g[b+4>>2]=d;i=c;return 224}function tf(a){a=a|0;return+(+g[a>>2])}function uf(a,b){a=a|0;b=+b;g[a>>2]=b;return}function vf(a){a=a|0;return+(+g[a+4>>2])}function wf(a,b){a=a|0;b=+b;g[a+4>>2]=b;return}function xf(a){a=a|0;var b=0;b=i;if(a)OB(a);i=b;return}function yf(){var a=0,b=0,d=0;a=i;b=NB(12)|0;if(b){d=b;i=a;return d|0}while(1){b=c[4582]|0;c[4582]=b+0;if(!b){b=4;break}qb[b&63]();d=NB(12)|0;if(d){b=5;break}}if((b|0)==4){d=cb(4)|0;c[d>>2]=18168;_a(d|0,18216,116)}else if((b|0)==5){i=a;return d|0}return 0}function zf(a,b,d){a=+a;b=+b;d=+d;var e=0,f=0;e=i;f=NB(12)|0;a:do if(!f){while(1){f=c[4582]|0;c[4582]=f+0;if(!f)break;qb[f&63]();f=NB(12)|0;if(f)break a}f=cb(4)|0;c[f>>2]=18168;_a(f|0,18216,116)}while(0);g[f>>2]=a;g[f+4>>2]=b;g[f+8>>2]=d;i=e;return f|0}function Af(a){a=a|0;g[a>>2]=0.0;g[a+4>>2]=0.0;g[a+8>>2]=0.0;return}function Bf(a,b,c,d){a=a|0;b=+b;c=+c;d=+d;g[a>>2]=b;g[a+4>>2]=c;g[a+8>>2]=d;return}function Cf(a,b){a=a|0;b=b|0;var c=0;g[a>>2]=+g[b>>2]+ +g[a>>2];c=a+4|0;g[c>>2]=+g[b+4>>2]+ +g[c>>2];a=a+8|0;g[a>>2]=+g[b+8>>2]+ +g[a>>2];return}function Df(a,b){a=a|0;b=b|0;var c=0;g[a>>2]=+g[a>>2]- +g[b>>2];c=a+4|0;g[c>>2]=+g[c>>2]- +g[b+4>>2];a=a+8|0;g[a>>2]=+g[a>>2]- +g[b+8>>2];return}function Ef(a,b){a=a|0;b=+b;var c=0;g[a>>2]=+g[a>>2]*b;c=a+4|0;g[c>>2]=+g[c>>2]*b;a=a+8|0;g[a>>2]=+g[a>>2]*b;return}function Ff(a){a=a|0;return+(+g[a>>2])}function Gf(a,b){a=a|0;b=+b;g[a>>2]=b;return}function Hf(a){a=a|0;return+(+g[a+4>>2])}function If(a,b){a=a|0;b=+b;g[a+4>>2]=b;return}function Jf(a){a=a|0;return+(+g[a+8>>2])}function Kf(a,b){a=a|0;b=+b;g[a+8>>2]=b;return}function Lf(a){a=a|0;var b=0;b=i;if(a)OB(a);i=b;return}function Mf(){var a=0,b=0;a=i;b=NB(16)|0;a:do if(!b){while(1){b=c[4582]|0;c[4582]=b+0;if(!b)break;qb[b&63]();b=NB(16)|0;if(b)break a}b=cb(4)|0;c[b>>2]=18168;_a(b|0,18216,116)}while(0);c[b+0>>2]=0;c[b+4>>2]=0;c[b+8>>2]=0;c[b+12>>2]=0;i=a;return b|0}function Nf(a){a=a|0;var b=0,d=0.0,e=0.0,f=0.0,h=0.0;b=i;e=+g[a+8>>2];f=+g[a>>2];d=+g[a+12>>2];h=+g[a+4>>2];if(!(e-f>=0.0&d-h>=0.0)){a=0;i=b;return a|0}if(((g[k>>2]=f,c[k>>2]|0)&2139095040|0)==2139095040){a=0;i=b;return a|0}if(((g[k>>2]=h,c[k>>2]|0)&2139095040|0)==2139095040){a=0;i=b;return a|0}if(((g[k>>2]=e,c[k>>2]|0)&2139095040|0)==2139095040){a=0;i=b;return a|0}a=((g[k>>2]=d,c[k>>2]|0)&2139095040|0)!=2139095040;i=b;return a|0}function Of(b){b=b|0;var c=0,d=0.0,e=0.0;c=i;if((a[248]|0)==0?(wa(248)|0)!=0:0)Da(248);e=+((+g[b>>2]+ +g[b+8>>2])*.5);d=+((+g[b+4>>2]+ +g[b+12>>2])*.5);b=240;g[b>>2]=e;g[b+4>>2]=d;i=c;return 240}function Pf(b){b=b|0;var c=0,d=0.0,e=0.0;c=i;if((a[264]|0)==0?(wa(264)|0)!=0:0)Da(264);e=+((+g[b+8>>2]- +g[b>>2])*.5);d=+((+g[b+12>>2]- +g[b+4>>2])*.5);b=256;g[b>>2]=e;g[b+4>>2]=d;i=c;return 256}function Qf(a){a=a|0;return+((+g[a+8>>2]- +g[a>>2]+(+g[a+12>>2]- +g[a+4>>2]))*2.0)}function Rf(a,b){a=a|0;b=b|0;var c=0,d=0.0,e=0.0,f=0,h=0.0,j=0.0;c=i;d=+g[a>>2];e=+g[b>>2];h=+g[a+4>>2];j=+g[b+4>>2];e=+(d>2]=e;g[f+4>>2]=j;f=a+8|0;j=+g[f>>2];e=+g[b+8>>2];h=+g[a+12>>2];d=+g[b+12>>2];e=+(j>e?j:e);d=+(h>d?h:d);a=f;g[a>>2]=e;g[a+4>>2]=d;i=c;return}function Sf(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0.0,f=0.0,h=0.0,j=0.0,k=0;d=i;e=+g[b>>2];f=+g[c>>2];h=+g[b+4>>2];j=+g[c+4>>2];f=+(e>2]=f;g[k+4>>2]=j;j=+g[b+8>>2];f=+g[c+8>>2];h=+g[b+12>>2];e=+g[c+12>>2];f=+(j>f?j:f);e=+(h>e?h:e);b=a+8|0;g[b>>2]=f;g[b+4>>2]=e;i=d;return}function Tf(a,b){a=a|0;b=b|0;var c=0;c=i;if((+g[a>>2]<=+g[b>>2]?+g[a+4>>2]<=+g[b+4>>2]:0)?+g[b+8>>2]<=+g[a+8>>2]:0)b=+g[b+12>>2]<=+g[a+12>>2];else b=0;i=c;return b|0}function Uf(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,h=0,j=0,l=0,m=0,n=0,o=0,p=0.0,q=0.0,r=0.0,s=0.0,t=0,u=0.0;e=i;i=i+32|0;l=e+8|0;h=e+24|0;j=e+16|0;f=e;n=d;t=c[n>>2]|0;n=c[n+4>>2]|0;o=l;c[o>>2]=t;c[o+4>>2]=n;r=+g[d+8>>2]-(c[k>>2]=t,+g[k>>2]);p=+g[d+12>>2]- +g[d+4>>2];g[h>>2]=r;g[h+4>>2]=p;if(!(r>0.0))r=-r;if(!(p>0.0))p=-p;g[j>>2]=r;g[j+4>>2]=p;n=a+8|0;m=f+4|0;o=0;p=3.4028234663852886e+38;q=-3.4028234663852886e+38;while(1){if(r<1.1920928955078125e-7){r=+g[l+(o<<2)>>2];if(r<+g[a+(o<<2)>>2]){f=0;a=17;break}if(+g[n+(o<<2)>>2]>2];r=+g[l+(o<<2)>>2];u=s*(+g[a+(o<<2)>>2]-r);r=s*(+g[n+(o<<2)>>2]-r);t=u>r;s=t?r:u;r=t?u:r;if(s>q){g[f>>2]=0.0;g[m>>2]=0.0;g[f+(o<<2)>>2]=t?1.0:-1.0;q=s}p=pp){f=0;a=17;break}}o=o+1|0;if((o|0)>=2){a=14;break}r=+g[j+(o<<2)>>2]}if((a|0)==14){if(q<0.0){t=0;i=e;return t|0}if(+g[d+16>>2]>2]=q;n=f;o=c[n+4>>2]|0;t=b;c[t>>2]=c[n>>2];c[t+4>>2]=o;t=1;i=e;return t|0}else if((a|0)==17){i=e;return f|0}return 0}function Vf(a){a=a|0;return a|0}function Wf(a,b){a=a|0;b=b|0;var d=0,e=0;e=b;d=c[e+4>>2]|0;b=a;c[b>>2]=c[e>>2];c[b+4>>2]=d;return}function Xf(a){a=a|0;return a+8|0}function Yf(a,b){a=a|0;b=b|0;var d=0,e=0;e=b;d=c[e+4>>2]|0;b=a+8|0;c[b>>2]=c[e>>2];c[b+4>>2]=d;return}function Zf(a){a=a|0;var b=0;b=i;if(a)OB(a);i=b;return}function _f(){var d=0,e=0;d=i;e=NB(28)|0;a:do if(!e){while(1){e=c[4582]|0;c[4582]=e+0;if(!e)break;qb[e&63]();e=NB(28)|0;if(e)break a}e=cb(4)|0;c[e>>2]=18168;_a(e|0,18216,116)}while(0);b[e+22>>1]=1;b[e+24>>1]=-1;b[e+26>>1]=0;c[e>>2]=0;c[e+4>>2]=0;g[e+8>>2]=.20000000298023224;g[e+12>>2]=0.0;g[e+16>>2]=0.0;a[e+20>>0]=0;i=d;return e|0}function $f(a){a=a|0;return c[a>>2]|0}function ag(a,b){a=a|0;b=b|0;c[a>>2]=b;return}function bg(a){a=a|0;return c[a+4>>2]|0}function cg(a,b){a=a|0;b=b|0;c[a+4>>2]=b;return}function dg(a){a=a|0;return+(+g[a+8>>2])}function eg(a,b){a=a|0;b=+b;g[a+8>>2]=b;return}function fg(a){a=a|0;return+(+g[a+12>>2])}function gg(a,b){a=a|0;b=+b;g[a+12>>2]=b;return}function hg(a){a=a|0;return+(+g[a+16>>2])}function ig(a,b){a=a|0;b=+b;g[a+16>>2]=b;return}function jg(b){b=b|0;return(a[b+20>>0]|0)!=0|0}function kg(b,c){b=b|0;c=c|0;a[b+20>>0]=c&1;return}function lg(a){a=a|0;return a+22|0}function mg(a,c){a=a|0;c=c|0;var d=0;d=i;a=a+22|0;b[a+0>>1]=b[c+0>>1]|0;b[a+2>>1]=b[c+2>>1]|0;b[a+4>>1]=b[c+4>>1]|0;i=d;return}function ng(a){a=a|0;var b=0;b=i;if(a)OB(a);i=b;return}function og(){var b=0,d=0,e=0;b=i;d=NB(44)|0;a:do if(!d){while(1){d=c[4582]|0;c[4582]=d+0;if(!d)break;qb[d&63]();d=NB(44)|0;if(d)break a}d=cb(4)|0;c[d>>2]=18168;_a(d|0,18216,116)}while(0);c[d+0>>2]=0;c[d+4>>2]=0;c[d+8>>2]=0;c[d+12>>2]=0;a[d+16>>0]=0;c[d>>2]=9;e=d+20|0;c[e+0>>2]=0;c[e+4>>2]=0;c[e+8>>2]=0;c[e+12>>2]=0;c[e+16>>2]=0;c[e+20>>2]=0;i=b;return d|0}function pg(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,h=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0;f=i;c[a+8>>2]=b;c[a+12>>2]=d;m=+g[e>>2]- +g[b+12>>2];n=e+4|0;h=+g[n>>2]- +g[b+16>>2];j=+g[b+24>>2];k=+g[b+20>>2];l=+(m*j+h*k);k=+(j*h-m*k);b=a+20|0;g[b>>2]=l;g[b+4>>2]=k;k=+g[e>>2]- +g[d+12>>2];l=+g[n>>2]- +g[d+16>>2];m=+g[d+24>>2];h=+g[d+20>>2];j=+(k*m+l*h);h=+(m*l-k*h);b=a+28|0;g[b>>2]=j;g[b+4>>2]=h;i=f;return}function qg(a){a=a|0;return a+20|0}function rg(a,b){a=a|0;b=b|0;var d=0,e=0;e=b;d=c[e+4>>2]|0;b=a+20|0;c[b>>2]=c[e>>2];c[b+4>>2]=d;return}function sg(a){a=a|0;return a+28|0}function tg(a,b){a=a|0;b=b|0;var d=0,e=0;e=b;d=c[e+4>>2]|0;b=a+28|0;c[b>>2]=c[e>>2];c[b+4>>2]=d;return}function ug(a){a=a|0;return+(+g[a+36>>2])}function vg(a,b){a=a|0;b=+b;g[a+36>>2]=b;return}function wg(a){a=a|0;return+(+g[a+40>>2])}function xg(a,b){a=a|0;b=+b;g[a+40>>2]=b;return}function yg(a){a=a|0;return c[a>>2]|0}function zg(a,b){a=a|0;b=b|0;c[a>>2]=b;return}function Ag(a){a=a|0;return c[a+4>>2]|0}function Bg(a,b){a=a|0;b=b|0;c[a+4>>2]=b;return}function Cg(a){a=a|0;return c[a+8>>2]|0}function Dg(a,b){a=a|0;b=b|0;c[a+8>>2]=b;return}function Eg(a){a=a|0;return c[a+12>>2]|0}function Fg(a,b){a=a|0;b=b|0;c[a+12>>2]=b;return}function Gg(b){b=b|0;return(a[b+16>>0]|0)!=0|0}function Hg(b,c){b=b|0;c=c|0;a[b+16>>0]=c&1;return}function Ig(a){a=a|0;var b=0;b=i;if(a)OB(a);i=b;return}function Jg(){var a=0,b=0,d=0,e=0;a=i;e=NB(64)|0;a:do if(!e){while(1){b=c[4582]|0;c[4582]=b+0;if(!b)break;qb[b&63]();e=NB(64)|0;if(e)break a}e=cb(4)|0;c[e>>2]=18168;_a(e|0,18216,116)}while(0);d=e+0|0;b=d+64|0;do{c[d>>2]=0;d=d+4|0}while((d|0)<(b|0));i=a;return e|0}function Kg(a){a=a|0;return a+40|0}function Lg(a,b){a=a|0;b=b|0;var d=0,e=0;e=b;d=c[e+4>>2]|0;b=a+40|0;c[b>>2]=c[e>>2];c[b+4>>2]=d;return}function Mg(a){a=a|0;return a+48|0}function Ng(a,b){a=a|0;b=b|0;var d=0,e=0;e=b;d=c[e+4>>2]|0;b=a+48|0;c[b>>2]=c[e>>2];c[b+4>>2]=d;return}function Og(a){a=a|0;return c[a+56>>2]|0}function Pg(a,b){a=a|0;b=b|0;c[a+56>>2]=b;return}function Qg(a){a=a|0;return c[a+60>>2]|0}function Rg(a,b){a=a|0;b=b|0;c[a+60>>2]=b;return}function Sg(a){a=a|0;var b=0;b=i;if(a)OB(a);i=b;return}function Tg(){var b=0,d=0,e=0,f=0;b=i;d=NB(72)|0;a:do if(!d){while(1){d=c[4582]|0;c[4582]=d+0;if(!d)break;qb[d&63]();d=NB(72)|0;if(d)break a}d=cb(4)|0;c[d>>2]=18168;_a(d|0,18216,116)}while(0);c[d+0>>2]=0;c[d+4>>2]=0;c[d+8>>2]=0;c[d+12>>2]=0;a[d+16>>0]=0;c[d>>2]=2;f=d+20|0;e=d+36|0;c[f+0>>2]=0;c[f+4>>2]=0;c[f+8>>2]=0;c[f+12>>2]=0;g[e>>2]=1.0;g[d+40>>2]=0.0;g[d+44>>2]=0.0;a[d+48>>0]=0;g[d+52>>2]=0.0;g[d+56>>2]=0.0;a[d+60>>0]=0;g[d+64>>2]=0.0;g[d+68>>2]=0.0;i=b;return d|0}function Ug(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var h=0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0,p=0,q=0,r=0;h=i;c[a+8>>2]=b;c[a+12>>2]=d;k=+g[e>>2]- +g[b+12>>2];q=e+4|0;n=+g[q>>2]- +g[b+16>>2];p=b+24|0;l=+g[p>>2];o=b+20|0;j=+g[o>>2];m=+(k*l+n*j);j=+(l*n-k*j);r=a+20|0;g[r>>2]=m;g[r+4>>2]=j;j=+g[e>>2]- +g[d+12>>2];m=+g[q>>2]- +g[d+16>>2];k=+g[d+24>>2];n=+g[d+20>>2];l=+(j*k+m*n);n=+(k*m-j*n);e=a+28|0;g[e>>2]=l;g[e+4>>2]=n;n=+g[p>>2];l=+g[f>>2];j=+g[o>>2];m=+g[f+4>>2];k=+(n*l+j*m);j=+(n*m-l*j);e=a+36|0;g[e>>2]=k;g[e+4>>2]=j;g[a+44>>2]=+g[d+56>>2]- +g[b+56>>2];i=h;return}function Vg(a){a=a|0;return a+20|0}function Wg(a,b){a=a|0;b=b|0;var d=0,e=0;e=b;d=c[e+4>>2]|0;b=a+20|0;c[b>>2]=c[e>>2];c[b+4>>2]=d;return}function Xg(a){a=a|0;return a+28|0}function Yg(a,b){a=a|0;b=b|0;var d=0,e=0;e=b;d=c[e+4>>2]|0;b=a+28|0;c[b>>2]=c[e>>2];c[b+4>>2]=d;return}function Zg(a){a=a|0;return a+36|0}function _g(a,b){a=a|0;b=b|0;var d=0,e=0;e=b;d=c[e+4>>2]|0;b=a+36|0;c[b>>2]=c[e>>2];c[b+4>>2]=d;return}function $g(a){a=a|0;return+(+g[a+44>>2])}function ah(a,b){a=a|0;b=+b;g[a+44>>2]=b;return}function bh(b){b=b|0;return(a[b+48>>0]|0)!=0|0}function ch(b,c){b=b|0;c=c|0;a[b+48>>0]=c&1;return}function dh(a){a=a|0;return+(+g[a+52>>2])}function eh(a,b){a=a|0;b=+b;g[a+52>>2]=b;return}function fh(a){a=a|0;return+(+g[a+56>>2])}function gh(a,b){a=a|0;b=+b;g[a+56>>2]=b;return}function hh(b){b=b|0;return(a[b+60>>0]|0)!=0|0}function ih(b,c){b=b|0;c=c|0;a[b+60>>0]=c&1;return}function jh(a){a=a|0;return+(+g[a+64>>2])}function kh(a,b){a=a|0;b=+b;g[a+64>>2]=b;return}function lh(a){a=a|0;return+(+g[a+68>>2])}function mh(a,b){a=a|0;b=+b;g[a+68>>2]=b;return}function nh(a){a=a|0;return c[a>>2]|0}function oh(a,b){a=a|0;b=b|0;c[a>>2]=b;return}function ph(a){a=a|0;return c[a+4>>2]|0}function qh(a,b){a=a|0;b=b|0;c[a+4>>2]=b;return}function rh(a){a=a|0;return c[a+8>>2]|0}function sh(a,b){a=a|0;b=b|0;c[a+8>>2]=b;return}function th(a){a=a|0;return c[a+12>>2]|0}function uh(a,b){a=a|0;b=b|0;c[a+12>>2]=b;return}function vh(b){b=b|0;return(a[b+16>>0]|0)!=0|0}function wh(b,c){b=b|0;c=c|0;a[b+16>>0]=c&1;return}function xh(a){a=a|0;var b=0;b=i;if(a)OB(a);i=b;return}function yh(b){b=b|0;var d=0,e=0,f=0,h=0,j=0,k=0;d=i;e=NB(103028)|0;a:do if(!e){while(1){e=c[4582]|0;c[4582]=e+0;if(!e)break;qb[e&63]();e=NB(103028)|0;if(e)break a}k=cb(4)|0;c[k>>2]=18168;_a(k|0,18216,116)}while(0);h=e+8|0;c[h>>2]=128;c[e+4>>2]=0;f=NB(1024)|0;c[e>>2]=f;QB(f|0,0,c[h>>2]<<3|0)|0;h=e+12|0;f=h+56|0;do{c[h>>2]=0;h=h+4|0}while((h|0)<(f|0));do if(!(a[8176]|0)){f=1;h=0;while(1){if((h|0)>=14){f=7;break}if((f|0)>(c[7472+(h<<2)>>2]|0)){h=h+1|0;a[7528+f>>0]=h}else a[7528+f>>0]=h;f=f+1|0;if((f|0)>=641){f=12;break}}if((f|0)==7)Aa(8184,8208,71,8256);else if((f|0)==12){a[8176]=1;break}}while(0);c[e+102468>>2]=0;c[e+102472>>2]=0;c[e+102476>>2]=0;c[e+102864>>2]=0;c[e+102872>>2]=-1;f=e+102884|0;c[f>>2]=16;c[e+102880>>2]=0;j=NB(576)|0;h=e+102876|0;c[h>>2]=j;QB(j|0,0,(c[f>>2]|0)*36|0)|0;j=(c[f>>2]|0)+ -1|0;h=c[h>>2]|0;if((j|0)>0){k=0;do{j=k;k=k+1|0;c[h+(j*36|0)+20>>2]=k;c[h+(j*36|0)+32>>2]=-1;j=(c[f>>2]|0)+ -1|0}while((k|0)<(j|0))}c[h+(j*36|0)+20>>2]=-1;c[h+(((c[f>>2]|0)+ -1|0)*36|0)+32>>2]=-1;j=e+102888|0;k=e+102920|0;c[j+0>>2]=0;c[j+4>>2]=0;c[j+8>>2]=0;c[j+12>>2]=0;c[k>>2]=16;c[e+102924>>2]=0;c[e+102916>>2]=NB(128)|0;c[e+102908>>2]=16;c[e+102912>>2]=0;c[e+102904>>2]=NB(64)|0;c[e+102932>>2]=0;c[e+102936>>2]=0;c[e+102940>>2]=9648;c[e+102944>>2]=9656;k=e+102948|0;j=e+102968|0;c[e+102980>>2]=0;c[e+102984>>2]=0;f=e+102992|0;c[k+0>>2]=0;c[k+4>>2]=0;c[k+8>>2]=0;c[k+12>>2]=0;c[k+16>>2]=0;a[f>>0]=1;a[e+102993>>0]=1;a[e+102994>>0]=0;a[e+102995>>0]=1;a[e+102976>>0]=1;f=b;h=c[f+4>>2]|0;c[j>>2]=c[f>>2];c[j+4>>2]=h;c[e+102868>>2]=4;g[e+102988>>2]=0.0;c[k>>2]=e;k=e+102996|0;c[k+0>>2]=0;c[k+4>>2]=0;c[k+8>>2]=0;c[k+12>>2]=0;c[k+16>>2]=0;c[k+20>>2]=0;c[k+24>>2]=0;c[k+28>>2]=0;i=d;return e|0}function zh(a,b){a=a|0;b=b|0;c[a+102980>>2]=b;return}function Ah(a,b){a=a|0;b=b|0;c[a+102940>>2]=b;return}function Bh(a,b){a=a|0;b=b|0;c[a+102944>>2]=b;return}function Ch(a,b){a=a|0;b=b|0;c[a+102984>>2]=b;return}function Dh(d,e){d=d|0;e=e|0;var f=0,h=0,j=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0.0;f=i;if(c[d+102868>>2]&2)Aa(11064,11088,109,11128);h=Hx(d,152)|0;if(!h)h=0;else{l=e+4|0;if(((g[k>>2]=+g[l>>2],c[k>>2]|0)&2139095040|0)==2139095040)Aa(8600,8624,27,8664);if(((g[k>>2]=+g[e+8>>2],c[k>>2]|0)&2139095040|0)==2139095040)Aa(8600,8624,27,8664);o=e+16|0;if(((g[k>>2]=+g[o>>2],c[k>>2]|0)&2139095040|0)==2139095040)Aa(8672,8624,28,8664);if(((g[k>>2]=+g[e+20>>2],c[k>>2]|0)&2139095040|0)==2139095040)Aa(8672,8624,28,8664);p=e+12|0;if(((g[k>>2]=+g[p>>2],c[k>>2]|0)&2139095040|0)==2139095040)Aa(8704,8624,29,8664);q=e+24|0;if(((g[k>>2]=+g[q>>2],c[k>>2]|0)&2139095040|0)==2139095040)Aa(8728,8624,30,8664);n=e+32|0;s=+g[n>>2];if(((g[k>>2]=s,c[k>>2]|0)&2139095040|0)==2139095040|!(s>=0.0))Aa(8760,8624,31,8664);m=e+28|0;s=+g[m>>2];if(((g[k>>2]=s,c[k>>2]|0)&2139095040|0)==2139095040|!(s>=0.0))Aa(8824,8624,32,8664);j=h+4|0;r=(a[e+39>>0]|0)==0?0:8;b[j>>1]=r;if(a[e+38>>0]|0){r=(r&65535|16)&65535;b[j>>1]=r}if(a[e+36>>0]|0){r=(r&65535|4)&65535;b[j>>1]=r}if(a[e+37>>0]|0){r=(r&65535|2)&65535;b[j>>1]=r}if(a[e+40>>0]|0)b[j>>1]=r&65535|32;c[h+88>>2]=d;r=l;l=c[r>>2]|0;r=c[r+4>>2]|0;j=h+12|0;c[j>>2]=l;c[j+4>>2]=r;s=+g[p>>2];g[h+20>>2]=+R(+s);g[h+24>>2]=+Q(+s);g[h+28>>2]=0.0;g[h+32>>2]=0.0;j=h+36|0;c[j>>2]=l;c[j+4>>2]=r;j=h+44|0;c[j>>2]=l;c[j+4>>2]=r;g[h+52>>2]=+g[p>>2];g[h+56>>2]=+g[p>>2];g[h+60>>2]=0.0;c[h+108>>2]=0;c[h+112>>2]=0;c[h+92>>2]=0;c[h+96>>2]=0;p=o;j=c[p+4>>2]|0;r=h+64|0;c[r>>2]=c[p>>2];c[r+4>>2]=j;g[h+72>>2]=+g[q>>2];g[h+132>>2]=+g[m>>2];g[h+136>>2]=+g[n>>2];g[h+140>>2]=+g[e+48>>2];g[h+76>>2]=0.0;g[h+80>>2]=0.0;g[h+84>>2]=0.0;g[h+144>>2]=0.0;r=c[e>>2]|0;c[h>>2]=r;j=h+116|0;if((r|0)==2){g[j>>2]=1.0;g[h+120>>2]=1.0}else{g[j>>2]=0.0;g[h+120>>2]=0.0}g[h+124>>2]=0.0;g[h+128>>2]=0.0;c[h+148>>2]=c[e+44>>2];c[h+100>>2]=0;c[h+104>>2]=0}c[h+92>>2]=0;j=d+102952|0;c[h+96>>2]=c[j>>2];e=c[j>>2]|0;if(!e){c[j>>2]=h;r=d+102960|0;q=c[r>>2]|0;q=q+1|0;c[r>>2]=q;i=f;return h|0}c[e+92>>2]=h;c[j>>2]=h;r=d+102960|0;q=c[r>>2]|0;q=q+1|0;c[r>>2]=q;i=f;return h|0}function Eh(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0;e=i;f=b+102960|0;if((c[f>>2]|0)<=0)Aa(11144,11088,133,11160);if(c[b+102868>>2]&2)Aa(11064,11088,134,11160);j=d+108|0;k=c[j>>2]|0;if(k){h=b+102980|0;do{m=k;k=c[k+12>>2]|0;l=c[h>>2]|0;if(!l)l=m+4|0;else{o=m+4|0;lb[c[(c[l>>2]|0)+8>>2]&127](l,c[o>>2]|0);l=o}ry(b,c[l>>2]|0);c[j>>2]=k}while((k|0)!=0)}c[j>>2]=0;h=d+112|0;k=c[h>>2]|0;if(k){j=b+102872|0;do{o=k;k=c[k+12>>2]|0;Xx(j,c[o+4>>2]|0)}while((k|0)!=0)}c[h>>2]=0;h=d+100|0;m=c[h>>2]|0;a:do if(!m)g=d+104|0;else{l=b+102980|0;j=b+102872|0;k=d+104|0;while(1){n=m;m=c[m+4>>2]|0;o=c[l>>2]|0;if(o)lb[c[(c[o>>2]|0)+12>>2]&127](o,n);ly(n,j);jy(n,b);o=a[7572]|0;if((o&255)>=14)break;o=b+((o&255)<<2)+12|0;c[n>>2]=c[o>>2];c[o>>2]=n;c[h>>2]=m;c[k>>2]=(c[k>>2]|0)+ -1;if(!m){g=k;break a}}Aa(8296,8208,171,8568)}while(0);c[h>>2]=0;c[g>>2]=0;h=d+92|0;j=c[h>>2]|0;g=d+96|0;if(j)c[j+96>>2]=c[g>>2];j=c[g>>2]|0;if(j)c[j+92>>2]=c[h>>2];h=b+102952|0;if((c[h>>2]|0)==(d|0))c[h>>2]=c[g>>2];c[f>>2]=(c[f>>2]|0)+ -1;f=a[7680]|0;if((f&255)<14){o=b+((f&255)<<2)+12|0;c[d>>2]=c[o>>2];c[o>>2]=d;i=e;return}else Aa(8296,8208,171,8568)}function Fh(b,d){b=b|0;d=d|0;var e=0,f=0,h=0,j=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0.0,y=0.0,z=0.0,A=0.0,B=0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0,K=0,L=0.0;e=i;if(c[b+102868>>2]&2)Aa(11064,11088,214,11176);do switch(c[d>>2]|0){case 7:{h=Hx(b,224)|0;do if(h){c[h>>2]=15304;f=d+8|0;j=d+12|0;if((c[f>>2]|0)==(c[j>>2]|0))Aa(15352,15232,185,15384);else{c[h+4>>2]=c[d>>2];c[h+8>>2]=0;c[h+12>>2]=0;c[h+48>>2]=c[f>>2];c[h+52>>2]=c[j>>2];c[h+56>>2]=0;a[h+61>>0]=a[d+16>>0]|0;a[h+60>>0]=0;c[h+64>>2]=c[d+4>>2];w=h+16|0;c[w+0>>2]=0;c[w+4>>2]=0;c[w+8>>2]=0;c[w+12>>2]=0;c[w+16>>2]=0;c[w+20>>2]=0;c[w+24>>2]=0;c[w+28>>2]=0;c[h>>2]=17248;w=d+20|0;B=c[w+4>>2]|0;q=h+76|0;c[q>>2]=c[w>>2];c[q+4>>2]=B;q=d+28|0;B=c[q+4>>2]|0;w=h+84|0;c[w>>2]=c[q>>2];c[w+4>>2]=B;w=d+36|0;B=c[w>>2]|0;w=c[w+4>>2]|0;q=h+92|0;c[q>>2]=B;c[q+4>>2]=w;q=h+100|0;g[q>>2]=-(c[k>>2]=w,+g[k>>2]);c[q+4>>2]=B;g[h+204>>2]=0.0;g[h+108>>2]=0.0;g[h+208>>2]=0.0;g[h+112>>2]=0.0;g[h+212>>2]=0.0;g[h+116>>2]=0.0;g[h+120>>2]=+g[d+48>>2];g[h+124>>2]=+g[d+52>>2];a[h+128>>0]=a[d+44>>0]|0;g[h+68>>2]=+g[d+56>>2];g[h+72>>2]=+g[d+60>>2];g[h+216>>2]=0.0;g[h+220>>2]=0.0;q=h+172|0;c[q+0>>2]=0;c[q+4>>2]=0;c[q+8>>2]=0;c[q+12>>2]=0;q=h;break}}else q=0;while(0);f=q;break};case 2:{f=Hx(b,256)|0;if(!f)f=0;else{c[f>>2]=15304;h=d+8|0;j=d+12|0;if((c[h>>2]|0)==(c[j>>2]|0))Aa(15352,15232,185,15384);c[f+4>>2]=c[d>>2];c[f+8>>2]=0;c[f+12>>2]=0;c[f+48>>2]=c[h>>2];c[f+52>>2]=c[j>>2];c[f+56>>2]=0;a[f+61>>0]=a[d+16>>0]|0;a[f+60>>0]=0;c[f+64>>2]=c[d+4>>2];h=f+16|0;c[h+0>>2]=0;c[h+4>>2]=0;c[h+8>>2]=0;c[h+12>>2]=0;c[h+16>>2]=0;c[h+20>>2]=0;c[h+24>>2]=0;c[h+28>>2]=0;c[f>>2]=15912;h=f+84|0;B=d+20|0;w=c[B+4>>2]|0;v=f+68|0;c[v>>2]=c[B>>2];c[v+4>>2]=w;v=d+28|0;w=c[v+4>>2]|0;B=f+76|0;c[B>>2]=c[v>>2];c[B+4>>2]=w;B=d+36|0;w=c[B>>2]|0;B=c[B+4>>2]|0;v=h;c[v>>2]=w;c[v+4>>2]=B;x=(c[k>>2]=w,+g[k>>2]);y=(c[k>>2]=B,+g[k>>2]);z=+O(+(x*x+y*y));if(!(z<1.1920928955078125e-7)){C=1.0/z;x=x*C;g[h>>2]=x;y=y*C;g[f+88>>2]=y}A=+-y;C=+x;w=f+92|0;g[w>>2]=A;g[w+4>>2]=C;g[f+100>>2]=+g[d+44>>2];w=f+104|0;g[f+252>>2]=0.0;B=d+52|0;c[w+0>>2]=0;c[w+4>>2]=0;c[w+8>>2]=0;c[w+12>>2]=0;g[f+120>>2]=+g[B>>2];g[f+124>>2]=+g[d+56>>2];g[f+128>>2]=+g[d+64>>2];g[f+132>>2]=+g[d+68>>2];a[f+136>>0]=a[d+48>>0]|0;a[f+137>>0]=a[d+60>>0]|0;c[f+140>>2]=0;B=f+184|0;c[B+0>>2]=0;c[B+4>>2]=0;c[B+8>>2]=0;c[B+12>>2]=0}break};case 9:{f=Hx(b,180)|0;do if(f){c[f>>2]=15304;j=d+8|0;h=d+12|0;if((c[j>>2]|0)==(c[h>>2]|0))Aa(15352,15232,185,15384);else{c[f+4>>2]=c[d>>2];c[f+8>>2]=0;c[f+12>>2]=0;c[f+48>>2]=c[j>>2];c[f+52>>2]=c[h>>2];c[f+56>>2]=0;a[f+61>>0]=a[d+16>>0]|0;a[f+60>>0]=0;c[f+64>>2]=c[d+4>>2];p=f+16|0;c[p+0>>2]=0;c[p+4>>2]=0;c[p+8>>2]=0;c[p+12>>2]=0;c[p+16>>2]=0;c[p+20>>2]=0;c[p+24>>2]=0;c[p+28>>2]=0;c[f>>2]=14456;p=d+20|0;B=c[p+4>>2]|0;w=f+68|0;c[w>>2]=c[p>>2];c[w+4>>2]=B;w=d+28|0;B=c[w+4>>2]|0;p=f+76|0;c[p>>2]=c[w>>2];c[p+4>>2]=B;g[f+84>>2]=0.0;g[f+88>>2]=0.0;g[f+92>>2]=0.0;g[f+96>>2]=+g[d+36>>2];g[f+100>>2]=+g[d+40>>2];p=f;break}}else p=0;while(0);f=p;break};case 8:{j=Hx(b,208)|0;do if(j){c[j>>2]=15304;h=d+8|0;f=d+12|0;if((c[h>>2]|0)==(c[f>>2]|0))Aa(15352,15232,185,15384);else{c[j+4>>2]=c[d>>2];c[j+8>>2]=0;c[j+12>>2]=0;c[j+48>>2]=c[h>>2];c[j+52>>2]=c[f>>2];c[j+56>>2]=0;a[j+61>>0]=a[d+16>>0]|0;a[j+60>>0]=0;c[j+64>>2]=c[d+4>>2];l=j+16|0;c[l+0>>2]=0;c[l+4>>2]=0;c[l+8>>2]=0;c[l+12>>2]=0;c[l+16>>2]=0;c[l+20>>2]=0;c[l+24>>2]=0;c[l+28>>2]=0;c[j>>2]=17104;l=d+20|0;B=c[l+4>>2]|0;w=j+80|0;c[w>>2]=c[l>>2];c[w+4>>2]=B;w=d+28|0;B=c[w+4>>2]|0;l=j+88|0;c[l>>2]=c[w>>2];c[l+4>>2]=B;g[j+96>>2]=+g[d+36>>2];g[j+68>>2]=+g[d+40>>2];g[j+72>>2]=+g[d+44>>2];g[j+104>>2]=0.0;g[j+108>>2]=0.0;g[j+112>>2]=0.0;l=j;break}}else l=0;while(0);f=l;break};case 1:{f=Hx(b,228)|0;do if(f){c[f>>2]=15304;j=d+8|0;h=d+12|0;if((c[j>>2]|0)==(c[h>>2]|0))Aa(15352,15232,185,15384);else{c[f+4>>2]=c[d>>2];c[f+8>>2]=0;c[f+12>>2]=0;c[f+48>>2]=c[j>>2];c[f+52>>2]=c[h>>2];c[f+56>>2]=0;a[f+61>>0]=a[d+16>>0]|0;a[f+60>>0]=0;c[f+64>>2]=c[d+4>>2];B=f+16|0;c[B+0>>2]=0;c[B+4>>2]=0;c[B+8>>2]=0;c[B+12>>2]=0;c[B+16>>2]=0;c[B+20>>2]=0;c[B+24>>2]=0;c[B+28>>2]=0;c[f>>2]=16648;B=d+20|0;m=c[B+4>>2]|0;w=f+68|0;c[w>>2]=c[B>>2];c[w+4>>2]=m;w=d+28|0;m=c[w+4>>2]|0;B=f+76|0;c[B>>2]=c[w>>2];c[B+4>>2]=m;g[f+116>>2]=+g[d+36>>2];B=f+84|0;m=d+44|0;c[B+0>>2]=0;c[B+4>>2]=0;c[B+8>>2]=0;c[B+12>>2]=0;g[f+120>>2]=+g[m>>2];g[f+124>>2]=+g[d+48>>2];g[f+104>>2]=+g[d+60>>2];g[f+108>>2]=+g[d+56>>2];a[f+112>>0]=a[d+40>>0]|0;a[f+100>>0]=a[d+52>>0]|0;c[f+224>>2]=0;m=f;break}}else m=0;while(0);f=m;break};case 6:{f=Hx(b,276)|0;if(!f)f=0;else{c[f>>2]=15304;j=d+8|0;h=d+12|0;if((c[j>>2]|0)==(c[h>>2]|0))Aa(15352,15232,185,15384);c[f+4>>2]=c[d>>2];c[f+8>>2]=0;c[f+12>>2]=0;B=f+48|0;c[B>>2]=c[j>>2];o=f+52|0;c[o>>2]=c[h>>2];c[f+56>>2]=0;a[f+61>>0]=a[d+16>>0]|0;a[f+60>>0]=0;c[f+64>>2]=c[d+4>>2];u=f+16|0;c[u+0>>2]=0;c[u+4>>2]=0;c[u+8>>2]=0;c[u+12>>2]=0;c[u+16>>2]=0;c[u+20>>2]=0;c[u+24>>2]=0;c[u+28>>2]=0;c[f>>2]=14816;u=f+92|0;l=f+100|0;r=f+108|0;m=f+116|0;t=f+124|0;j=f+132|0;w=d+20|0;v=c[w>>2]|0;c[f+68>>2]=v;n=d+24|0;p=c[n>>2]|0;c[f+72>>2]=p;s=c[v+4>>2]|0;c[f+76>>2]=s;h=c[p+4>>2]|0;c[f+80>>2]=h;if((s+ -1|0)>>>0>=2)Aa(14864,14928,53,14984);if((h+ -1|0)>>>0>=2)Aa(15e3,14928,54,14984);q=c[v+48>>2]|0;c[f+84>>2]=q;v=c[v+52>>2]|0;c[B>>2]=v;x=+g[v+20>>2];y=+g[v+24>>2];A=+g[q+20>>2];z=+g[q+24>>2];w=c[w>>2]|0;if((s|0)==1){A=+g[v+56>>2];C=+g[q+56>>2];B=w+68|0;v=c[B+4>>2]|0;s=r;c[s>>2]=c[B>>2];c[s+4>>2]=v;s=w+76|0;v=c[s+4>>2]|0;B=u;c[B>>2]=c[s>>2];c[B+4>>2]=v;x=+g[w+116>>2];g[f+140>>2]=x;g[t>>2]=0.0;g[f+128>>2]=0.0;x=A-C-x}else{H=+g[q+16>>2];D=+g[q+12>>2];I=+g[v+16>>2];J=+g[v+12>>2];q=w+68|0;K=c[q>>2]|0;q=c[q+4>>2]|0;v=r;c[v>>2]=K;c[v+4>>2]=q;v=w+76|0;s=c[v>>2]|0;v=c[v+4>>2]|0;B=u;c[B>>2]=s;c[B+4>>2]=v;g[f+140>>2]=+g[w+100>>2];B=w+84|0;w=c[B>>2]|0;B=c[B+4>>2]|0;u=t;c[u>>2]=w;c[u+4>>2]=B;E=(c[k>>2]=K,+g[k>>2]);C=(c[k>>2]=q,+g[k>>2]);G=(c[k>>2]=s,+g[k>>2]);F=(c[k>>2]=v,+g[k>>2]);D=J-D+(y*G-x*F);x=I-H+(x*G+y*F);y=(c[k>>2]=w,+g[k>>2])*(z*D+A*x-E);x=y+(c[k>>2]=B,+g[k>>2])*(z*x-A*D-C)}q=c[p+48>>2]|0;c[f+88>>2]=q;p=c[p+52>>2]|0;c[o>>2]=p;A=+g[p+20>>2];y=+g[p+24>>2];C=+g[q+20>>2];z=+g[q+24>>2];n=c[n>>2]|0;if((h|0)==1){I=+g[p+56>>2];J=+g[q+56>>2];K=n+68|0;B=c[K+4>>2]|0;w=m;c[w>>2]=c[K>>2];c[w+4>>2]=B;w=n+76|0;B=c[w+4>>2]|0;K=l;c[K>>2]=c[w>>2];c[K+4>>2]=B;y=+g[n+116>>2];g[f+144>>2]=y;g[j>>2]=0.0;g[f+136>>2]=0.0;y=I-J-y}else{E=+g[q+16>>2];I=+g[q+12>>2];D=+g[p+16>>2];L=+g[p+12>>2];u=n+68|0;t=c[u>>2]|0;u=c[u+4>>2]|0;w=m;c[w>>2]=t;c[w+4>>2]=u;w=n+76|0;v=c[w>>2]|0;w=c[w+4>>2]|0;K=l;c[K>>2]=v;c[K+4>>2]=w;g[f+144>>2]=+g[n+100>>2];K=n+84|0;B=c[K>>2]|0;K=c[K+4>>2]|0;s=j;c[s>>2]=B;c[s+4>>2]=K;H=(c[k>>2]=t,+g[k>>2]);J=(c[k>>2]=u,+g[k>>2]);F=(c[k>>2]=v,+g[k>>2]);G=(c[k>>2]=w,+g[k>>2]);I=L-I+(y*F-A*G);y=D-E+(A*F+y*G);H=(c[k>>2]=B,+g[k>>2])*(z*I+C*y-H);y=H+(c[k>>2]=K,+g[k>>2])*(z*y-C*I-J)}L=+g[d+28>>2];g[f+152>>2]=L;g[f+148>>2]=x+y*L;g[f+156>>2]=0.0}break};case 4:{f=Hx(b,196)|0;do if(f){c[f>>2]=15304;h=d+8|0;l=d+12|0;if((c[h>>2]|0)==(c[l>>2]|0))Aa(15352,15232,185,15384);c[f+4>>2]=c[d>>2];c[f+8>>2]=0;c[f+12>>2]=0;c[f+48>>2]=c[h>>2];c[f+52>>2]=c[l>>2];c[f+56>>2]=0;a[f+61>>0]=a[d+16>>0]|0;a[f+60>>0]=0;c[f+64>>2]=c[d+4>>2];l=f+16|0;c[l+0>>2]=0;c[l+4>>2]=0;c[l+8>>2]=0;c[l+12>>2]=0;c[l+16>>2]=0;c[l+20>>2]=0;c[l+24>>2]=0;c[l+28>>2]=0;c[f>>2]=16312;l=d+20|0;h=c[l+4>>2]|0;K=f+68|0;c[K>>2]=c[l>>2];c[K+4>>2]=h;K=d+28|0;h=c[K+4>>2]|0;l=f+76|0;c[l>>2]=c[K>>2];c[l+4>>2]=h;l=d+36|0;h=c[l+4>>2]|0;K=f+92|0;c[K>>2]=c[l>>2];c[K+4>>2]=h;K=d+44|0;h=c[K+4>>2]|0;l=f+100|0;c[l>>2]=c[K>>2];c[l+4>>2]=h;l=d+52|0;g[f+84>>2]=+g[l>>2];h=d+56|0;g[f+88>>2]=+g[h>>2];x=+g[d+60>>2];if(x!=0.0){g[f+112>>2]=x;g[f+108>>2]=+g[l>>2]+x*+g[h>>2];g[f+116>>2]=0.0;j=f;break}else Aa(16360,16232,65,16384)}else j=0;while(0);f=j;break};case 3:{f=Hx(b,176)|0;do if(f){c[f>>2]=15304;j=d+8|0;h=d+12|0;if((c[j>>2]|0)==(c[h>>2]|0))Aa(15352,15232,185,15384);else{c[f+4>>2]=c[d>>2];c[f+8>>2]=0;c[f+12>>2]=0;c[f+48>>2]=c[j>>2];c[f+52>>2]=c[h>>2];c[f+56>>2]=0;a[f+61>>0]=a[d+16>>0]|0;a[f+60>>0]=0;c[f+64>>2]=c[d+4>>2];n=f+16|0;c[n+0>>2]=0;c[n+4>>2]=0;c[n+8>>2]=0;c[n+12>>2]=0;c[n+16>>2]=0;c[n+20>>2]=0;c[n+24>>2]=0;c[n+28>>2]=0;c[f>>2]=14304;n=d+20|0;K=c[n+4>>2]|0;B=f+80|0;c[B>>2]=c[n>>2];c[B+4>>2]=K;B=d+28|0;K=c[B+4>>2]|0;n=f+88|0;c[n>>2]=c[B>>2];c[n+4>>2]=K;g[f+104>>2]=+g[d+36>>2];g[f+68>>2]=+g[d+40>>2];g[f+72>>2]=+g[d+44>>2];g[f+100>>2]=0.0;g[f+96>>2]=0.0;g[f+76>>2]=0.0;n=f;break}}else n=0;while(0);f=n;break};case 5:{f=Hx(b,168)|0;do if(f){c[f>>2]=15304;j=d+8|0;l=d+12|0;if((c[j>>2]|0)==(c[l>>2]|0))Aa(15352,15232,185,15384);c[f+4>>2]=c[d>>2];c[f+8>>2]=0;c[f+12>>2]=0;c[f+48>>2]=c[j>>2];n=c[l>>2]|0;c[f+52>>2]=n;c[f+56>>2]=0;a[f+61>>0]=a[d+16>>0]|0;a[f+60>>0]=0;c[f+64>>2]=c[d+4>>2];o=f+16|0;c[o+0>>2]=0;c[o+4>>2]=0;c[o+8>>2]=0;c[o+12>>2]=0;c[o+16>>2]=0;c[o+20>>2]=0;c[o+24>>2]=0;c[o+28>>2]=0;c[f>>2]=15448;o=d+20|0;if(((g[k>>2]=+g[o>>2],c[k>>2]|0)&2139095040|0)==2139095040)Aa(15496,15520,34,15576);if(((g[k>>2]=+g[d+24>>2],c[k>>2]|0)&2139095040|0)==2139095040)Aa(15496,15520,34,15576);m=d+28|0;L=+g[m>>2];if(((g[k>>2]=L,c[k>>2]|0)&2139095040|0)==2139095040|!(L>=0.0))Aa(15592,15520,35,15576);l=d+32|0;L=+g[l>>2];if(((g[k>>2]=L,c[k>>2]|0)&2139095040|0)==2139095040|!(L>=0.0))Aa(15648,15520,36,15576);j=d+36|0;L=+g[j>>2];if(((g[k>>2]=L,c[k>>2]|0)&2139095040|0)==2139095040|!(L>=0.0))Aa(15704,15520,37,15576);else{h=o;K=c[h>>2]|0;h=c[h+4>>2]|0;B=f+76|0;c[B>>2]=K;c[B+4>>2]=h;I=(c[k>>2]=K,+g[k>>2])- +g[n+12>>2];H=(c[k>>2]=h,+g[k>>2])- +g[n+16>>2];G=+g[n+24>>2];L=+g[n+20>>2];J=+(I*G+H*L);L=+(G*H-I*L);h=f+68|0;g[h>>2]=J;g[h+4>>2]=L;g[f+104>>2]=+g[m>>2];g[f+96>>2]=0.0;g[f+100>>2]=0.0;g[f+84>>2]=+g[l>>2];g[f+88>>2]=+g[j>>2];g[f+92>>2]=0.0;g[f+108>>2]=0.0;h=f;break}}else h=0;while(0);f=h;break};case 10:{f=Hx(b,168)|0;do if(f){c[f>>2]=15304;j=d+8|0;h=d+12|0;if((c[j>>2]|0)==(c[h>>2]|0))Aa(15352,15232,185,15384);else{c[f+4>>2]=c[d>>2];c[f+8>>2]=0;c[f+12>>2]=0;c[f+48>>2]=c[j>>2];c[f+52>>2]=c[h>>2];c[f+56>>2]=0;a[f+61>>0]=a[d+16>>0]|0;a[f+60>>0]=0;c[f+64>>2]=c[d+4>>2];r=f+16|0;c[r+0>>2]=0;c[r+4>>2]=0;c[r+8>>2]=0;c[r+12>>2]=0;c[r+16>>2]=0;c[r+20>>2]=0;c[r+24>>2]=0;c[r+28>>2]=0;c[f>>2]=16960;r=d+20|0;K=c[r+4>>2]|0;B=f+68|0;c[B>>2]=c[r>>2];c[B+4>>2]=K;B=d+28|0;K=c[B+4>>2]|0;r=f+76|0;c[r>>2]=c[B>>2];c[r+4>>2]=K;g[f+84>>2]=+g[d+36>>2];g[f+160>>2]=0.0;g[f+92>>2]=0.0;c[f+164>>2]=0;g[f+88>>2]=0.0;r=f;break}}else r=0;while(0);f=r;break};case 11:{f=Hx(b,192)|0;do if(f){c[f>>2]=15304;j=d+8|0;h=d+12|0;if((c[j>>2]|0)==(c[h>>2]|0))Aa(15352,15232,185,15384);else{c[f+4>>2]=c[d>>2];c[f+8>>2]=0;c[f+12>>2]=0;c[f+48>>2]=c[j>>2];c[f+52>>2]=c[h>>2];c[f+56>>2]=0;a[f+61>>0]=a[d+16>>0]|0;a[f+60>>0]=0;c[f+64>>2]=c[d+4>>2];B=f+16|0;c[B+0>>2]=0;c[B+4>>2]=0;c[B+8>>2]=0;c[B+12>>2]=0;c[B+16>>2]=0;c[B+20>>2]=0;c[B+24>>2]=0;c[B+28>>2]=0;c[f>>2]=4792;B=d+20|0;K=c[B+4>>2]|0;o=f+68|0;c[o>>2]=c[B>>2];c[o+4>>2]=K;g[f+76>>2]=+g[d+28>>2];g[f+80>>2]=0.0;g[f+84>>2]=0.0;g[f+88>>2]=0.0;g[f+92>>2]=+g[d+32>>2];g[f+96>>2]=+g[d+36>>2];g[f+100>>2]=+g[d+40>>2];o=f;break}}else o=0;while(0);f=o;break};default:Aa(15224,15232,121,15280)}while(0);c[f+8>>2]=0;j=b+102956|0;c[f+12>>2]=c[j>>2];h=c[j>>2]|0;if(h)c[h+8>>2]=f;c[j>>2]=f;j=b+102964|0;c[j>>2]=(c[j>>2]|0)+1;j=f+16|0;c[f+20>>2]=f;b=f+52|0;c[j>>2]=c[b>>2];c[f+24>>2]=0;h=f+48|0;m=c[h>>2]|0;l=m+108|0;c[f+28>>2]=c[l>>2];l=c[l>>2]|0;if(l){c[l+8>>2]=j;m=c[h>>2]|0}c[m+108>>2]=j;j=f+32|0;c[f+36>>2]=f;c[j>>2]=c[h>>2];c[f+40>>2]=0;l=c[b>>2]|0;h=l+108|0;c[f+44>>2]=c[h>>2];h=c[h>>2]|0;if(h){c[h+8>>2]=j;l=c[b>>2]|0}c[l+108>>2]=j;b=c[d+8>>2]|0;if(a[d+16>>0]|0){i=e;return f|0}d=c[(c[d+12>>2]|0)+112>>2]|0;if(!d){i=e;return f|0}do{if((c[d>>2]|0)==(b|0)){K=(c[d+4>>2]|0)+4|0;c[K>>2]=c[K>>2]|8}d=c[d+12>>2]|0}while((d|0)!=0);i=e;return f|0}function Gh(a,b){a=a|0;b=b|0;var c=0;c=i;ry(a,b);i=c;return}function Hh(a,b,c,d){a=a|0;b=+b;c=c|0;d=d|0;var e=0;e=i;uy(a,b,c,d);i=e;return}function Ih(a){a=a|0;var b=0;b=i;a=c[a+102952>>2]|0;if(!a){i=b;return}do{g[a+76>>2]=0.0;g[a+80>>2]=0.0;g[a+84>>2]=0.0;a=c[a+96>>2]|0}while((a|0)!=0);i=b;return}function Jh(a){a=a|0;var d=0,e=0,f=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0.0,W=0.0,X=0.0,Y=0.0;d=i;i=i+208|0;o=d+40|0;n=d+24|0;r=d+80|0;t=d+104|0;q=d+48|0;p=d+32|0;s=d;x=d+160|0;w=d+64|0;v=d+176|0;y=d+192|0;z=d+88|0;h=d+144|0;l=d+112|0;f=d+8|0;e=a+102984|0;j=c[e>>2]|0;if(!j){i=d;return}j=c[j+4>>2]|0;if((j&1|0)!=0?(P=c[a+102952>>2]|0,(P|0)!=0):0){O=x+4|0;A=x+8|0;B=x+12|0;F=y+4|0;G=y+8|0;H=y+12|0;I=z+4|0;J=z+8|0;K=z+12|0;L=w+4|0;M=w+8|0;N=w+12|0;C=v+4|0;D=v+8|0;E=v+12|0;do{Q=P+12|0;S=c[P+100>>2]|0;if(S){R=P+4|0;do{T=b[R>>1]|0;do if(T&32){U=c[P>>2]|0;if((U|0)==1){g[v>>2]=.5;g[C>>2]=.5;g[D>>2]=.8999999761581421;g[E>>2]=1.0;vy(a,c[S+12>>2]|0,Q,v);break}else if(U)if(!(T&2)){g[y>>2]=.6000000238418579;g[F>>2]=.6000000238418579;g[G>>2]=.6000000238418579;g[H>>2]=1.0;vy(a,c[S+12>>2]|0,Q,y);break}else{g[z>>2]=.8999999761581421;g[I>>2]=.699999988079071;g[J>>2]=.699999988079071;g[K>>2]=1.0;vy(a,c[S+12>>2]|0,Q,z);break}else{g[w>>2]=.5;g[L>>2]=.8999999761581421;g[M>>2]=.5;g[N>>2]=1.0;vy(a,c[S+12>>2]|0,Q,w);break}}else{g[x>>2]=.5;g[O>>2]=.5;g[A>>2]=.30000001192092896;g[B>>2]=1.0;vy(a,c[S+12>>2]|0,Q,x)}while(0);S=c[S+4>>2]|0}while((S|0)!=0)}P=c[P+96>>2]|0}while((P|0)!=0)}if((j&2|0)!=0?(u=c[a+102956>>2]|0,(u|0)!=0):0){v=q+4|0;w=q+8|0;x=q+12|0;do{T=(c[u+52>>2]|0)+12|0;S=(c[u+48>>2]|0)+12|0;y=c[S+4>>2]|0;U=o;c[U>>2]=c[S>>2];c[U+4>>2]=y;U=c[T+4>>2]|0;y=n;c[y>>2]=c[T>>2];c[y+4>>2]=U;lb[c[c[u>>2]>>2]&127](r,u);lb[c[(c[u>>2]|0)+4>>2]&127](t,u);g[q>>2]=.5;g[v>>2]=.800000011920929;g[w>>2]=.800000011920929;g[x>>2]=1.0;y=c[u+4>>2]|0;if((y|0)==3){U=c[e>>2]|0;vb[c[(c[U>>2]|0)+24>>2]&63](U,r,t,q)}else if((y|0)==4){U=u+68|0;T=c[U+4>>2]|0;S=p;c[S>>2]=c[U>>2];c[S+4>>2]=T;S=u+76|0;T=c[S+4>>2]|0;U=s;c[U>>2]=c[S>>2];c[U+4>>2]=T;U=c[e>>2]|0;vb[c[(c[U>>2]|0)+24>>2]&63](U,p,r,q);U=c[e>>2]|0;vb[c[(c[U>>2]|0)+24>>2]&63](U,s,t,q);U=c[e>>2]|0;vb[c[(c[U>>2]|0)+24>>2]&63](U,p,s,q)}else if((y|0)!=5){U=c[e>>2]|0;vb[c[(c[U>>2]|0)+24>>2]&63](U,o,r,q);U=c[e>>2]|0;vb[c[(c[U>>2]|0)+24>>2]&63](U,r,t,q);U=c[e>>2]|0;vb[c[(c[U>>2]|0)+24>>2]&63](U,n,t,q)}u=c[u+12>>2]|0}while((u|0)!=0)}if(j&8){n=a+102932|0;while(1){n=c[n>>2]|0;if(!n)break;else n=n+12|0}}a:do if((j&4|0)!=0?(g[h>>2]=.8999999761581421,g[h+4>>2]=.30000001192092896,g[h+8>>2]=.8999999761581421,g[h+12>>2]=1.0,m=c[a+102952>>2]|0,(m|0)!=0):0){o=a+102884|0;v=a+102876|0;n=l+4|0;u=l+8|0;t=l+12|0;s=l+16|0;r=l+20|0;q=l+24|0;p=l+28|0;b:while(1){if((b[m+4>>1]&32)!=0?(k=c[m+100>>2]|0,(k|0)!=0):0){A=k;do{z=A+28|0;if((c[z>>2]|0)>0){y=A+24|0;x=0;do{w=c[(c[y>>2]|0)+(x*28|0)+24>>2]|0;if((w|0)<=-1){h=37;break b}if((c[o>>2]|0)<=(w|0)){h=37;break b}U=c[v>>2]|0;W=+g[U+(w*36|0)>>2];Y=+g[U+(w*36|0)+4>>2];X=+g[U+(w*36|0)+8>>2];V=+g[U+(w*36|0)+12>>2];g[l>>2]=W;g[n>>2]=Y;g[u>>2]=X;g[t>>2]=Y;g[s>>2]=X;g[r>>2]=V;g[q>>2]=W;g[p>>2]=V;U=c[e>>2]|0;vb[c[(c[U>>2]|0)+8>>2]&63](U,l,4,h);x=x+1|0}while((x|0)<(c[z>>2]|0))}A=c[A+4>>2]|0}while((A|0)!=0)}m=c[m+96>>2]|0;if(!m)break a}if((h|0)==37)Aa(11792,11736,164,11856)}while(0);if(!(j&16)){i=d;return}a=c[a+102952>>2]|0;if(!a){i=d;return}do{S=a+12|0;c[f+0>>2]=c[S+0>>2];c[f+4>>2]=c[S+4>>2];c[f+8>>2]=c[S+8>>2];c[f+12>>2]=c[S+12>>2];S=a+44|0;T=c[S+4>>2]|0;U=f;c[U>>2]=c[S>>2];c[U+4>>2]=T;U=c[e>>2]|0;lb[c[(c[U>>2]|0)+28>>2]&127](U,f);a=c[a+96>>2]|0}while((a|0)!=0);i=d;return}function Kh(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0;j=i;i=i+1040|0;f=j;h=f+4|0;c[f>>2]=h;k=f+1028|0;c[k>>2]=0;l=f+1032|0;c[l>>2]=256;n=c[f>>2]|0;c[n+(c[k>>2]<<2)>>2]=c[a+102872>>2];u=c[k>>2]|0;s=u+1|0;c[k>>2]=s;do if((u|0)>-1){q=a+102876|0;p=d+4|0;o=d+8|0;n=d+12|0;a=a+102884|0;a:while(1){if((s|0)<=0){k=4;break}s=s+ -1|0;c[k>>2]=s;u=c[f>>2]|0;r=c[u+(s<<2)>>2]|0;do if((r|0)!=-1?(m=c[q>>2]|0,!((+g[d>>2]- +g[m+(r*36|0)+8>>2]>0.0?1:+g[p>>2]- +g[m+(r*36|0)+12>>2]>0.0)|+g[m+(r*36|0)>>2]- +g[o>>2]>0.0|+g[m+(r*36|0)+4>>2]- +g[n>>2]>0.0)):0){t=m+(r*36|0)+24|0;if((c[t>>2]|0)==-1){if((r|0)<=-1){k=11;break a}if((c[a>>2]|0)<=(r|0)){k=11;break a}if(!(tb[c[(c[b>>2]|0)+8>>2]&63](b,c[(c[m+(r*36|0)+16>>2]|0)+16>>2]|0)|0)){k=21;break a}s=c[k>>2]|0;break}if((s|0)==(c[l>>2]|0)?(c[l>>2]=s<<1,s=NB(s<<3)|0,c[f>>2]=s,SB(s|0,u|0,c[k>>2]<<2|0)|0,(u|0)!=(h|0)):0)OB(u);s=c[f>>2]|0;c[s+(c[k>>2]<<2)>>2]=c[t>>2];t=(c[k>>2]|0)+1|0;c[k>>2]=t;r=m+(r*36|0)+28|0;if((t|0)==(c[l>>2]|0)?(c[l>>2]=t<<1,u=NB(t<<3)|0,c[f>>2]=u,SB(u|0,s|0,c[k>>2]<<2|0)|0,(s|0)!=(h|0)):0)OB(s);c[(c[f>>2]|0)+(c[k>>2]<<2)>>2]=c[r>>2];s=(c[k>>2]|0)+1|0;c[k>>2]=s}while(0);if((s|0)<=0){k=21;break}}if((k|0)==4)Aa(9664,9680,67,9728);else if((k|0)==11)Aa(11792,11736,158,11840);else if((k|0)==21){e=c[f>>2]|0;break}}else e=n;while(0);if((e|0)==(h|0)){i=j;return}OB(e);c[f>>2]=0;i=j;return}function Lh(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,h=0,j=0,l=0,m=0.0,n=0.0,o=0,p=0,q=0.0,r=0.0,s=0,t=0.0,u=0.0,v=0.0,w=0.0,x=0,y=0,z=0.0,A=0.0,B=0.0,C=0,D=0,E=0,F=0,G=0.0,H=0,I=0,J=0,K=0,L=0.0,M=0,N=0,P=0.0,Q=0.0,R=0.0,S=0.0,T=0,U=0,V=0,W=0,X=0.0,Y=0.0,Z=0.0;f=i;i=i+1088|0;l=f+1064|0;j=f+1056|0;h=f+20|0;o=f;s=c[d>>2]|0;d=c[d+4>>2]|0;x=e;e=c[x>>2]|0;x=c[x+4>>2]|0;w=(c[k>>2]=s,+g[k>>2]);t=(c[k>>2]=d,+g[k>>2]);u=(c[k>>2]=e,+g[k>>2]);u=u-w;v=(c[k>>2]=x,+g[k>>2])-t;z=u*u+v*v;if(!(z>0.0))Aa(11704,11736,209,11784);z=+O(+z);if(z<1.1920928955078125e-7){B=v;A=u}else{A=1.0/z;B=v*A;A=u*A}z=-B;G=B<-0.0?z:B;if(A>0.0)B=A;else B=-A;Q=w+u;R=t+v;y=h+4|0;c[h>>2]=y;D=h+1028|0;c[D>>2]=0;C=h+1032|0;c[C>>2]=256;c[(c[h>>2]|0)+(c[D>>2]<<2)>>2]=c[a+102872>>2];W=c[D>>2]|0;V=W+1|0;c[D>>2]=V;a:do if((W|0)>-1){E=a+102876|0;F=o+8|0;H=o+16|0;I=a+102884|0;J=l+8|0;K=o+4|0;M=o+8|0;a=o+12|0;N=j+4|0;L=wR?t:R;Q=w>Q?w:Q;R=t>2]=V;U=c[h>>2]|0;T=c[U+(V<<2)>>2]|0;do if((T|0)!=-1?(p=c[E>>2]|0,q=+g[p+(T*36|0)+8>>2],m=+g[p+(T*36|0)+12>>2],n=+g[p+(T*36|0)>>2],r=+g[p+(T*36|0)+4>>2],!(L-q>0.0|R-m>0.0|n-Q>0.0|r-P>0.0)):0){X=(w-(q+n)*.5)*z+A*(t-(m+r)*.5);if(!(X>0.0))X=-X;if(!(X-(G*(q-n)*.5+B*(m-r)*.5)>0.0)){W=p+(T*36|0)+24|0;if((c[W>>2]|0)!=-1){if((V|0)==(c[C>>2]|0)?(c[C>>2]=V<<1,V=NB(V<<3)|0,c[h>>2]=V,SB(V|0,U|0,c[D>>2]<<2|0)|0,(U|0)!=(y|0)):0)OB(U);U=c[h>>2]|0;c[U+(c[D>>2]<<2)>>2]=c[W>>2];V=(c[D>>2]|0)+1|0;c[D>>2]=V;T=p+(T*36|0)+28|0;if((V|0)==(c[C>>2]|0)?(c[C>>2]=V<<1,W=NB(V<<3)|0,c[h>>2]=W,SB(W|0,U|0,c[D>>2]<<2|0)|0,(U|0)!=(y|0)):0)OB(U);c[(c[h>>2]|0)+(c[D>>2]<<2)>>2]=c[T>>2];V=(c[D>>2]|0)+1|0;c[D>>2]=V;break}W=o;c[W>>2]=s;c[W+4>>2]=d;W=F;c[W>>2]=e;c[W+4>>2]=x;g[H>>2]=S;if((T|0)<=-1){j=21;break b}if((c[I>>2]|0)<=(T|0)){j=21;break b}W=c[p+(T*36|0)+16>>2]|0;T=c[W+16>>2]|0;V=c[T+12>>2]|0;if(ub[c[(c[V>>2]|0)+20>>2]&63](V,l,o,(c[T+8>>2]|0)+12|0,c[W+20>>2]|0)|0){X=+g[J>>2];Z=1.0-X;Y=Z*+g[K>>2]+X*+g[a>>2];g[j>>2]=+g[o>>2]*Z+X*+g[M>>2];g[N>>2]=Y;X=+kb[c[(c[b>>2]|0)+8>>2]&63](b,T,j,l,X)}else X=+g[H>>2];if(X==0.0)break a;if(X>0.0)break c;V=c[D>>2]|0}}while(0);if((V|0)<=0)break a}Q=w+u*X;R=t+v*X;V=c[D>>2]|0;if((V|0)<=0)break a;else{L=wR?t:R;Q=w>Q?w:Q;R=t>2]|0;if((j|0)==(y|0)){i=f;return}OB(j);c[h>>2]=0;i=f;return}function Mh(a){a=a|0;return c[a+102952>>2]|0}function Nh(a){a=a|0;return c[a+102956>>2]|0}function Oh(a){a=a|0;return c[a+102932>>2]|0}function Ph(f,h){f=f|0;h=h|0;var j=0,k=0;j=i;k=f+102976|0;if((h&1|0)==(d[k>>0]|0|0)){i=j;return}a[k>>0]=h&1;if(h){i=j;return}f=c[f+102952>>2]|0;if(!f){i=j;return}do{k=f+4|0;h=e[k>>1]|0;if(!(h&2)){b[k>>1]=h|2;g[f+144>>2]=0.0}f=c[f+96>>2]|0}while((f|0)!=0);i=j;return}function Qh(b){b=b|0;return(a[b+102976>>0]|0)!=0|0}function Rh(b,c){b=b|0;c=c|0;a[b+102992>>0]=c&1;return}function Sh(b){b=b|0;return(a[b+102992>>0]|0)!=0|0}function Th(b,c){b=b|0;c=c|0;a[b+102993>>0]=c&1;return}function Uh(b){b=b|0;return(a[b+102993>>0]|0)!=0|0}function Vh(b,c){b=b|0;c=c|0;a[b+102994>>0]=c&1;return}function Wh(b){b=b|0;return(a[b+102994>>0]|0)!=0|0}function Xh(a){a=a|0;return c[a+102900>>2]|0}function Yh(a){a=a|0;return c[a+102960>>2]|0}function Zh(a){a=a|0;return c[a+102964>>2]|0}function _h(a){a=a|0;return c[a+102936>>2]|0}function $h(a){a=a|0;var b=0,d=0;b=i;d=c[a+102872>>2]|0;if((d|0)==-1){d=0;i=b;return d|0}d=c[(c[a+102876>>2]|0)+(d*36|0)+32>>2]|0;i=b;return d|0}function ai(a){a=a|0;var b=0,d=0,e=0,f=0,g=0;b=i;d=c[a+102884>>2]|0;if((d|0)<=0){g=0;i=b;return g|0}a=c[a+102876>>2]|0;e=0;f=0;while(1){if((c[a+(e*36|0)+32>>2]|0)>=2){g=c[a+(e*36|0)+24>>2]|0;if((g|0)==-1){d=5;break}g=(c[a+((c[a+(e*36|0)+28>>2]|0)*36|0)+32>>2]|0)-(c[a+(g*36|0)+32>>2]|0)|0;g=(g|0)>0?g:0-g|0;f=(f|0)>(g|0)?f:g}e=e+1|0;if((e|0)>=(d|0)){d=8;break}}if((d|0)==5)Aa(6152,5624,683,6176);else if((d|0)==8){i=b;return f|0}return 0}function bi(a){a=a|0;var b=0,d=0.0,e=0,f=0,h=0.0;b=i;f=c[a+102872>>2]|0;if((f|0)==-1){h=0.0;i=b;return+h}e=c[a+102876>>2]|0;d=(+g[e+(f*36|0)+8>>2]- +g[e+(f*36|0)>>2]+(+g[e+(f*36|0)+12>>2]- +g[e+(f*36|0)+4>>2]))*2.0;a=c[a+102884>>2]|0;if((a|0)>0){f=0;h=0.0;do{if((c[e+(f*36|0)+32>>2]|0)>=0)h=h+(+g[e+(f*36|0)+8>>2]- +g[e+(f*36|0)>>2]+(+g[e+(f*36|0)+12>>2]- +g[e+(f*36|0)+4>>2]))*2.0;f=f+1|0}while((f|0)<(a|0))}else h=0.0;h=h/d;i=b;return+h}function ci(a,b){a=a|0;b=b|0;var d=0,e=0;e=b;d=c[e+4>>2]|0;b=a+102968|0;c[b>>2]=c[e>>2];c[b+4>>2]=d;return}function di(b){b=b|0;var d=0,e=0,f=0;d=i;if((a[280]|0)==0?(wa(280)|0)!=0:0)Da(280);f=b+102968|0;e=c[f+4>>2]|0;b=272;c[b>>2]=c[f>>2];c[b+4>>2]=e;i=d;return 272}function ei(a){a=a|0;return(c[a+102868>>2]&2|0)!=0|0}function fi(a,b){a=a|0;b=b|0;var d=0;a=a+102868|0;d=c[a>>2]|0;c[a>>2]=b?d|4:d&-5;return}function gi(a){a=a|0;return(c[a+102868>>2]&4|0)!=0|0}function hi(a){a=a|0;return a+102996|0}function ii(a){a=a|0;var b=0,d=0,e=0,f=0,j=0.0;d=i;i=i+16|0;b=d;if(c[a+102868>>2]&2){i=d;return}j=+g[a+102972>>2];h[k>>3]=+g[a+102968>>2];c[b>>2]=c[k>>2];c[b+4>>2]=c[k+4>>2];e=b+8|0;h[k>>3]=j;c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];Nx(11416,b);Nx(11448,b);c[b>>2]=c[a+102960>>2];Nx(11480,b);c[b>>2]=c[a+102964>>2];Nx(11544,b);e=c[a+102952>>2]|0;if(e){f=0;while(1){c[e+8>>2]=f;Ux(e);e=c[e+96>>2]|0;if(!e)break;else f=f+1|0}}a=a+102956|0;f=c[a>>2]|0;if(f){e=0;while(1){c[f+56>>2]=e;f=c[f+12>>2]|0;if(!f)break;else e=e+1|0}e=c[a>>2]|0;if(e){do{if((c[e+4>>2]|0)!=6){Nx(11608,b);jb[c[(c[e>>2]|0)+16>>2]&127](e);Nx(11616,b)}e=c[e+12>>2]|0}while((e|0)!=0);a=c[a>>2]|0;if(a)do{if((c[a+4>>2]|0)==6){Nx(11608,b);jb[c[(c[a>>2]|0)+16>>2]&127](a);Nx(11616,b)}a=c[a+12>>2]|0}while((a|0)!=0)}}Nx(11624,b);Nx(11648,b);Nx(11672,b);Nx(11688,b);i=d;return}function ji(a){a=a|0;var b=0,d=0,e=0,f=0;b=i;if(!a){i=b;return}d=c[a+102952>>2]|0;if(d)do{e=d;d=c[d+96>>2]|0;e=c[e+100>>2]|0;while(1){if(!e)break;f=c[e+4>>2]|0;c[e+28>>2]=0;jy(e,a);e=f}}while((d|0)!=0);OB(c[a+102904>>2]|0);OB(c[a+102916>>2]|0);OB(c[a+102876>>2]|0);if(c[a+102468>>2]|0)Aa(8376,8392,32,8440);if(c[a+102864>>2]|0)Aa(8464,8392,33,8440);d=a+4|0;f=c[a>>2]|0;if((c[d>>2]|0)>0){e=0;do{OB(c[f+(e<<3)+4>>2]|0);e=e+1|0;f=c[a>>2]|0}while((e|0)<(c[d>>2]|0))}OB(f);OB(a);i=b;return}function ki(a){a=a|0;return a+68|0}function li(a){a=a|0;return a+76|0}function mi(a){a=a|0;return a+84|0}function ni(a){a=a|0;return+(+g[a+100>>2])}function oi(a){a=a|0;var b=0.0,d=0.0,e=0.0,f=0.0,h=0,i=0.0,j=0.0,k=0,l=0.0,m=0.0,n=0.0,o=0.0;h=c[a+48>>2]|0;d=+g[h+24>>2];j=+g[a+68>>2];f=+g[h+20>>2];i=+g[a+72>>2];k=c[a+52>>2]|0;m=+g[k+24>>2];o=+g[a+76>>2];n=+g[k+20>>2];l=+g[a+80>>2];e=+g[a+84>>2];b=+g[a+88>>2];return+((+g[k+12>>2]+(m*o-n*l)-(+g[h+12>>2]+(d*j-f*i)))*(d*e-f*b)+(o*n+m*l+ +g[k+16>>2]-(j*f+d*i+ +g[h+16>>2]))*(f*e+d*b))}function pi(a){a=a|0;var b=0.0,d=0,e=0.0,f=0.0,h=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0,r=0;d=i;q=c[a+48>>2]|0;r=c[a+52>>2]|0;o=+g[a+68>>2]- +g[q+28>>2];f=+g[a+72>>2]- +g[q+32>>2];l=+g[q+24>>2];n=+g[q+20>>2];e=o*l-f*n;o=l*f+o*n;f=+g[a+76>>2]- +g[r+28>>2];k=+g[a+80>>2]- +g[r+32>>2];p=+g[r+24>>2];m=+g[r+20>>2];j=f*p-k*m;m=p*k+f*m;f=+g[a+84>>2];k=+g[a+88>>2];p=l*f-n*k;k=n*f+l*k;a=q+64|0;l=+g[a>>2];f=+g[a+4>>2];a=r+64|0;n=+g[a>>2];b=+g[q+72>>2];h=+g[r+72>>2];b=(m+ +g[r+48>>2]-(o+ +g[q+48>>2]))*p*b-(j+ +g[r+44>>2]-(e+ +g[q+44>>2]))*k*b+(p*(o*b+(n-m*h-l))+k*(+g[a+4>>2]+j*h-f-e*b));i=d;return+b}function qi(b){b=b|0;return(a[b+136>>0]|0)!=0|0}function ri(f,h){f=f|0;h=h|0;var j=0,k=0,l=0,m=0,n=0;j=i;k=f+136|0;if((h&1|0)==(d[k>>0]|0|0)){i=j;return}l=c[f+48>>2]|0;m=l+4|0;n=e[m>>1]|0;if(!(n&2)){b[m>>1]=n|2;g[l+144>>2]=0.0}l=c[f+52>>2]|0;m=l+4|0;n=e[m>>1]|0;if(!(n&2)){b[m>>1]=n|2;g[l+144>>2]=0.0}a[k>>0]=h&1;g[f+112>>2]=0.0;i=j;return}function si(a){a=a|0;return+(+g[a+120>>2])}function ti(a){a=a|0;return+(+g[a+124>>2])}function ui(a,d,f){a=a|0;d=+d;f=+f;var h=0,j=0,k=0,l=0,m=0;j=i;if(!(d<=f))Aa(16696,15960,567,16768);h=a+120|0;if(!(+g[h>>2]!=d)?!(+g[a+124>>2]!=f):0){i=j;return}m=c[a+48>>2]|0;k=m+4|0;l=e[k>>1]|0;if(!(l&2)){b[k>>1]=l|2;g[m+144>>2]=0.0}l=c[a+52>>2]|0;m=l+4|0;k=e[m>>1]|0;if(!(k&2)){b[m>>1]=k|2;g[l+144>>2]=0.0}g[h>>2]=d;g[a+124>>2]=f;g[a+112>>2]=0.0;i=j;return}function vi(b){b=b|0;return(a[b+137>>0]|0)!=0|0}function wi(d,f){d=d|0;f=f|0;var h=0,j=0,k=0,l=0;h=i;j=c[d+48>>2]|0;k=j+4|0;l=e[k>>1]|0;if(!(l&2)){b[k>>1]=l|2;g[j+144>>2]=0.0}l=c[d+52>>2]|0;k=l+4|0;j=e[k>>1]|0;if(j&2){l=d+137|0;k=f&1;a[l>>0]=k;i=h;return}b[k>>1]=j|2;g[l+144>>2]=0.0;l=d+137|0;k=f&1;a[l>>0]=k;i=h;return}function xi(a,d){a=a|0;d=+d;var f=0,h=0,j=0,k=0;f=i;h=c[a+48>>2]|0;j=h+4|0;k=e[j>>1]|0;if(!(k&2)){b[j>>1]=k|2;g[h+144>>2]=0.0}k=c[a+52>>2]|0;j=k+4|0;h=e[j>>1]|0;if(h&2){k=a+132|0;g[k>>2]=d;i=f;return}b[j>>1]=h|2;g[k+144>>2]=0.0;k=a+132|0;g[k>>2]=d;i=f;return}function yi(a){a=a|0;return+(+g[a+132>>2])}function zi(a,d){a=a|0;d=+d;var f=0,h=0,j=0,k=0;f=i;h=c[a+48>>2]|0;j=h+4|0;k=e[j>>1]|0;if(!(k&2)){b[j>>1]=k|2;g[h+144>>2]=0.0}k=c[a+52>>2]|0;j=k+4|0;h=e[j>>1]|0;if(h&2){k=a+128|0;g[k>>2]=d;i=f;return}b[j>>1]=h|2;g[k+144>>2]=0.0;k=a+128|0;g[k>>2]=d;i=f;return}function Ai(a){a=a|0;return+(+g[a+128>>2])}function Bi(a,b){a=a|0;b=+b;return+(+g[a+116>>2]*b)}function Ci(a){a=a|0;return c[a+4>>2]|0}function Di(a){a=a|0;return c[a+48>>2]|0}function Ei(a){a=a|0;return c[a+52>>2]|0}function Fi(b){b=b|0;var d=0,e=0,f=0;e=i;i=i+16|0;d=e;if((a[296]|0)==0?(wa(296)|0)!=0:0)Da(296);lb[c[c[b>>2]>>2]&127](d,b);f=d;b=c[f+4>>2]|0;d=288;c[d>>2]=c[f>>2];c[d+4>>2]=b;i=e;return 288}function Gi(b){b=b|0;var d=0,e=0,f=0;e=i;i=i+16|0;d=e;if((a[312]|0)==0?(wa(312)|0)!=0:0)Da(312);lb[c[(c[b>>2]|0)+4>>2]&127](d,b);f=d;b=c[f+4>>2]|0;d=304;c[d>>2]=c[f>>2];c[d+4>>2]=b;i=e;return 304}function Hi(b,d){b=b|0;d=+d;var e=0,f=0,g=0;f=i;i=i+16|0;e=f;if((a[328]|0)==0?(wa(328)|0)!=0:0)Da(328);rb[c[(c[b>>2]|0)+8>>2]&63](e,b,d);g=e;b=c[g+4>>2]|0;e=320;c[e>>2]=c[g>>2];c[e+4>>2]=b;i=f;return 320}function Ii(a,b){a=a|0;b=+b;var d=0;d=i;b=+ib[c[(c[a>>2]|0)+12>>2]&63](a,b);i=d;return+b}function Ji(a){a=a|0;return c[a+12>>2]|0}function Ki(a){a=a|0;return c[a+64>>2]|0}function Li(a,b){a=a|0;b=b|0;c[a+64>>2]=b;return}function Mi(a){a=a|0;var d=0;d=i;if(!(b[(c[a+48>>2]|0)+4>>1]&32)){a=0;i=d;return a|0}a=(b[(c[a+52>>2]|0)+4>>1]&32)!=0;i=d;return a|0}function Ni(b){b=b|0;return(a[b+61>>0]|0)!=0|0}function Oi(a){a=a|0;var b=0;b=i;if(!a){i=b;return}jb[c[(c[a>>2]|0)+28>>2]&127](a);i=b;return}function Pi(a){a=a|0;return a|0}function Qi(a,b){a=a|0;b=b|0;var d=0,e=0;e=b;d=c[e+4>>2]|0;b=a;c[b>>2]=c[e>>2];c[b+4>>2]=d;return}function Ri(a){a=a|0;return+(+g[a+8>>2])}function Si(a,b){a=a|0;b=+b;g[a+8>>2]=b;return}function Ti(a){a=a|0;var b=0;b=i;if(a)OB(a);i=b;return}function Ui(a){a=a|0;return a|0}function Vi(b,c){b=b|0;c=c|0;c=d[c>>0]|d[c+1>>0]<<8|d[c+2>>0]<<16|d[c+3>>0]<<24;a[b>>0]=c;a[b+1>>0]=c>>8;a[b+2>>0]=c>>16;a[b+3>>0]=c>>24;return}function Wi(a){a=a|0;return c[a>>2]|0}function Xi(a,b){a=a|0;b=b|0;c[a>>2]=b;return}function Yi(a){a=a|0;var b=0;b=i;if(a)OB(a);i=b;return}function Zi(a){a=a|0;var b=0;b=i;if(!a){i=b;return}jb[c[(c[a>>2]|0)+4>>2]&127](a);i=b;return}function _i(){var a=0,b=0,d=0;a=i;b=NB(4)|0;if(b){d=b;c[d>>2]=2688;i=a;return d|0}while(1){b=c[4582]|0;c[4582]=b+0;if(!b){b=4;break}qb[b&63]();d=NB(4)|0;if(d){b=5;break}}if((b|0)==4){d=cb(4)|0;c[d>>2]=18168;_a(d|0,18216,116)}else if((b|0)==5){c[d>>2]=2688;i=a;return d|0}return 0}function $i(a,b){a=a|0;b=b|0;var d=0;d=i;lb[c[(c[a>>2]|0)+8>>2]&127](a,b);i=d;return}function aj(a,b){a=a|0;b=b|0;var d=0;d=i;lb[c[(c[a>>2]|0)+12>>2]&127](a,b);i=d;return}function bj(a){a=a|0;var b=0;b=i;if(!a){i=b;return}jb[c[(c[a>>2]|0)+4>>2]&127](a);i=b;return}function cj(){var a=0,b=0,d=0;a=i;b=NB(16)|0;if(b){d=b;i=a;return d|0}while(1){b=c[4582]|0;c[4582]=b+0;if(!b){b=4;break}qb[b&63]();d=NB(16)|0;if(d){b=5;break}}if((b|0)==4){d=cb(4)|0;c[d>>2]=18168;_a(d|0,18216,116)}else if((b|0)==5){i=a;return d|0}return 0}function dj(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0;d=i;e=NB(16)|0;a:do if(!e){while(1){e=c[4582]|0;c[4582]=e+0;if(!e)break;qb[e&63]();e=NB(16)|0;if(e)break a}e=cb(4)|0;c[e>>2]=18168;_a(e|0,18216,116)}while(0);g=a;a=c[g+4>>2]|0;f=e;c[f>>2]=c[g>>2];c[f+4>>2]=a;f=b;a=c[f+4>>2]|0;b=e+8|0;c[b>>2]=c[f>>2];c[b+4>>2]=a;i=d;return e|0}function ej(a,b,d,e){a=+a;b=+b;d=+d;e=+e;var f=0,h=0;f=i;h=NB(16)|0;a:do if(!h){while(1){h=c[4582]|0;c[4582]=h+0;if(!h)break;qb[h&63]();h=NB(16)|0;if(h)break a}h=cb(4)|0;c[h>>2]=18168;_a(h|0,18216,116)}while(0);g[h>>2]=a;g[h+4>>2]=d;g[h+8>>2]=b;g[h+12>>2]=e;i=f;return h|0}function fj(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0;f=b;b=c[f+4>>2]|0;e=a;c[e>>2]=c[f>>2];c[e+4>>2]=b;e=d;d=c[e+4>>2]|0;b=a+8|0;c[b>>2]=c[e>>2];c[b+4>>2]=d;return}function gj(a){a=a|0;g[a>>2]=1.0;g[a+8>>2]=0.0;g[a+4>>2]=0.0;g[a+12>>2]=1.0;return}function hj(a){a=a|0;var b=0;b=i;c[a+0>>2]=0;c[a+4>>2]=0;c[a+8>>2]=0;c[a+12>>2]=0;i=b;return}function ij(b){b=b|0;var c=0,d=0.0,e=0.0,f=0.0,h=0.0,j=0.0,k=0.0;c=i;if((a[352]|0)==0?(wa(352)|0)!=0:0)Da(352);d=+g[b>>2];e=+g[b+8>>2];f=+g[b+4>>2];h=+g[b+12>>2];j=d*h-e*f;if(j!=0.0)j=1.0/j;k=-j;g[84]=h*j;g[85]=f*k;g[86]=e*k;g[87]=d*j;i=c;return 336}function jj(b,c){b=b|0;c=c|0;var d=0,e=0.0,f=0.0,h=0.0,j=0.0,k=0.0,l=0.0,m=0.0;d=i;if((a[368]|0)==0?(wa(368)|0)!=0:0)Da(368);f=+g[b>>2];h=+g[b+8>>2];e=+g[b+4>>2];j=+g[b+12>>2];k=f*j-h*e;if(k!=0.0)k=1.0/k;l=+g[c>>2];m=+g[c+4>>2];j=+(k*(j*l-h*m));k=+(k*(f*m-e*l));b=360;g[b>>2]=j;g[b+4>>2]=k;i=d;return 360}function kj(a){a=a|0;return a|0}function lj(a,b){a=a|0;b=b|0;var d=0,e=0;e=b;d=c[e+4>>2]|0;b=a;c[b>>2]=c[e>>2];c[b+4>>2]=d;return}function mj(a){a=a|0;return a+8|0}function nj(a,b){a=a|0;b=b|0;var d=0,e=0;e=b;d=c[e+4>>2]|0;b=a+8|0;c[b>>2]=c[e>>2];c[b+4>>2]=d;return}function oj(a){a=a|0;var b=0;b=i;if(a)OB(a);i=b;return}function pj(){var b=0,d=0,e=0,f=0;b=i;d=NB(64)|0;a:do if(!d){while(1){d=c[4582]|0;c[4582]=d+0;if(!d)break;qb[d&63]();d=NB(64)|0;if(d)break a}d=cb(4)|0;c[d>>2]=18168;_a(d|0,18216,116)}while(0);c[d+0>>2]=0;c[d+4>>2]=0;c[d+8>>2]=0;c[d+12>>2]=0;a[d+16>>0]=0;c[d>>2]=7;f=d+20|0;e=d+36|0;c[f+0>>2]=0;c[f+4>>2]=0;c[f+8>>2]=0;c[f+12>>2]=0;g[e>>2]=1.0;g[d+40>>2]=0.0;a[d+44>>0]=0;g[d+48>>2]=0.0;g[d+52>>2]=0.0;g[d+56>>2]=2.0;g[d+60>>2]=.699999988079071;i=b;return d|0}function qj(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var h=0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0,p=0,q=0;h=i;c[a+8>>2]=b;c[a+12>>2]=d;k=+g[e>>2]- +g[b+12>>2];p=e+4|0;n=+g[p>>2]- +g[b+16>>2];o=b+24|0;l=+g[o>>2];b=b+20|0;j=+g[b>>2];m=+(k*l+n*j);j=+(l*n-k*j);q=a+20|0;g[q>>2]=m;g[q+4>>2]=j;j=+g[e>>2]- +g[d+12>>2];m=+g[p>>2]- +g[d+16>>2];k=+g[d+24>>2];n=+g[d+20>>2];l=+(j*k+m*n);n=+(k*m-j*n);e=a+28|0;g[e>>2]=l;g[e+4>>2]=n;n=+g[o>>2];l=+g[f>>2];j=+g[b>>2];m=+g[f+4>>2];k=+(n*l+j*m);j=+(n*m-l*j);b=a+36|0;g[b>>2]=k;g[b+4>>2]=j;i=h;return}function rj(a){a=a|0;return a+20|0}function sj(a,b){a=a|0;b=b|0;var d=0,e=0;e=b;d=c[e+4>>2]|0;b=a+20|0;c[b>>2]=c[e>>2];c[b+4>>2]=d;return}function tj(a){a=a|0;return a+28|0}function uj(a,b){a=a|0;b=b|0;var d=0,e=0;e=b;d=c[e+4>>2]|0;b=a+28|0;c[b>>2]=c[e>>2];c[b+4>>2]=d;return}function vj(a){a=a|0;return a+36|0}function wj(a,b){a=a|0;b=b|0;var d=0,e=0;e=b;d=c[e+4>>2]|0;b=a+36|0;c[b>>2]=c[e>>2];c[b+4>>2]=d;return}function xj(b){b=b|0;return(a[b+44>>0]|0)!=0|0}function yj(b,c){b=b|0;c=c|0;a[b+44>>0]=c&1;return}function zj(a){a=a|0;return+(+g[a+48>>2])}function Aj(a,b){a=a|0;b=+b;g[a+48>>2]=b;return}function Bj(a){a=a|0;return+(+g[a+52>>2])}function Cj(a,b){a=a|0;b=+b;g[a+52>>2]=b;return}function Dj(a){a=a|0;return+(+g[a+56>>2])}function Ej(a,b){a=a|0;b=+b;g[a+56>>2]=b;return}function Fj(a){a=a|0;return+(+g[a+60>>2])}function Gj(a,b){a=a|0;b=+b;g[a+60>>2]=b;return}function Hj(a){a=a|0;return c[a>>2]|0}function Ij(a,b){a=a|0;b=b|0;c[a>>2]=b;return}function Jj(a){a=a|0;return c[a+4>>2]|0}function Kj(a,b){a=a|0;b=b|0;c[a+4>>2]=b;return}function Lj(a){a=a|0;return c[a+8>>2]|0}function Mj(a,b){a=a|0;b=b|0;c[a+8>>2]=b;return}function Nj(a){a=a|0;return c[a+12>>2]|0}function Oj(a,b){a=a|0;b=b|0;c[a+12>>2]=b;return}function Pj(b){b=b|0;return(a[b+16>>0]|0)!=0|0}function Qj(b,c){b=b|0;c=c|0;a[b+16>>0]=c&1;return}function Rj(a){a=a|0;var b=0;b=i;if(a)OB(a);i=b;return}function Sj(){var a=0,b=0,d=0;a=i;b=NB(20)|0;a:do if(!b){while(1){b=c[4582]|0;c[4582]=b+0;if(!b)break;qb[b&63]();b=NB(20)|0;if(b)break a}b=cb(4)|0;c[b>>2]=18168;_a(b|0,18216,116)}while(0);c[b>>2]=6936;d=b+4|0;c[d+0>>2]=0;c[d+4>>2]=0;c[d+8>>2]=0;c[d+12>>2]=0;i=a;return b|0}function Tj(a){a=a|0;return c[a+4>>2]|0}function Uj(a){a=a|0;var b=0;b=i;a=nb[c[(c[a>>2]|0)+12>>2]&63](a)|0;i=b;return a|0}function Vj(a,b,d){a=a|0;b=b|0;d=d|0;var e=0;e=i;a=gb[c[(c[a>>2]|0)+16>>2]&63](a,b,d)|0;i=e;return a|0}function Wj(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0;g=i;a=ub[c[(c[a>>2]|0)+20>>2]&63](a,b,d,e,f)|0;i=g;return a|0}function Xj(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0;f=i;vb[c[(c[a>>2]|0)+24>>2]&63](a,b,d,e);i=f;return}function Yj(a,b,d){a=a|0;b=b|0;d=+d;var e=0;e=i;rb[c[(c[a>>2]|0)+28>>2]&63](a,b,d);i=e;return}function Zj(a){a=a|0;return a+12|0}function _j(a,b){a=a|0;b=b|0;var d=0,e=0;e=b;d=c[e+4>>2]|0;b=a+12|0;c[b>>2]=c[e>>2];c[b+4>>2]=d;return}function $j(a){a=a|0;return c[a+4>>2]|0}function ak(a,b){a=a|0;b=b|0;c[a+4>>2]=b;return}function bk(a){a=a|0;return+(+g[a+8>>2])}function ck(a,b){a=a|0;b=+b;g[a+8>>2]=b;return}function dk(a){a=a|0;var b=0;b=i;if(!a){i=b;return}jb[c[(c[a>>2]|0)+4>>2]&127](a);i=b;return}function ek(){var b=0,d=0,e=0;b=i;d=NB(48)|0;a:do if(!d){while(1){d=c[4582]|0;c[4582]=d+0;if(!d)break;qb[d&63]();d=NB(48)|0;if(d)break a}d=cb(4)|0;c[d>>2]=18168;_a(d|0,18216,116)}while(0);c[d+0>>2]=0;c[d+4>>2]=0;c[d+8>>2]=0;c[d+12>>2]=0;a[d+16>>0]=0;c[d>>2]=8;e=d+20|0;c[e+0>>2]=0;c[e+4>>2]=0;c[e+8>>2]=0;c[e+12>>2]=0;c[e+16>>2]=0;c[e+20>>2]=0;c[e+24>>2]=0;i=b;return d|0}function fk(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,h=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0,o=0;f=i;c[a+8>>2]=b;c[a+12>>2]=d;m=+g[e>>2]- +g[b+12>>2];n=e+4|0;h=+g[n>>2]- +g[b+16>>2];j=+g[b+24>>2];k=+g[b+20>>2];l=+(m*j+h*k);k=+(j*h-m*k);o=a+20|0;g[o>>2]=l;g[o+4>>2]=k;k=+g[e>>2]- +g[d+12>>2];l=+g[n>>2]- +g[d+16>>2];m=+g[d+24>>2];h=+g[d+20>>2];j=+(k*m+l*h);h=+(m*l-k*h);e=a+28|0;g[e>>2]=j;g[e+4>>2]=h;g[a+36>>2]=+g[d+56>>2]- +g[b+56>>2];i=f;return}function gk(a){a=a|0;return a+20|0}function hk(a,b){a=a|0;b=b|0;var d=0,e=0;e=b;d=c[e+4>>2]|0;b=a+20|0;c[b>>2]=c[e>>2];c[b+4>>2]=d;return}function ik(a){a=a|0;return a+28|0}function jk(a,b){a=a|0;b=b|0;var d=0,e=0;e=b;d=c[e+4>>2]|0;b=a+28|0;c[b>>2]=c[e>>2];c[b+4>>2]=d;return}function kk(a){a=a|0;return+(+g[a+36>>2])}function lk(a,b){a=a|0;b=+b;g[a+36>>2]=b;return}function mk(a){a=a|0;return+(+g[a+40>>2])}function nk(a,b){a=a|0;b=+b;g[a+40>>2]=b;return}function ok(a){a=a|0;return+(+g[a+44>>2])}function pk(a,b){a=a|0;b=+b;g[a+44>>2]=b;return}function qk(a){a=a|0;return c[a>>2]|0}function rk(a,b){a=a|0;b=b|0;c[a>>2]=b;return}function sk(a){a=a|0;return c[a+4>>2]|0}function tk(a,b){a=a|0;b=b|0;c[a+4>>2]=b;return}function uk(a){a=a|0;return c[a+8>>2]|0}function vk(a,b){a=a|0;b=b|0;c[a+8>>2]=b;return}function wk(a){a=a|0;return c[a+12>>2]|0}function xk(a,b){a=a|0;b=b|0;c[a+12>>2]=b;return}function yk(b){b=b|0;return(a[b+16>>0]|0)!=0|0}function zk(b,c){b=b|0;c=c|0;a[b+16>>0]=c&1;return}function Ak(a){a=a|0;var b=0;b=i;if(a)OB(a);i=b;return}function Bk(a,b){a=a|0;b=b|0;c[a+4>>2]=b;return}function Ck(a){a=a|0;return c[a+4>>2]|0}function Dk(a,b){a=a|0;b=b|0;a=a+4|0;c[a>>2]=c[a>>2]|b;return}function Ek(a,b){a=a|0;b=b|0;a=a+4|0;c[a>>2]=c[a>>2]&~b;return}function Fk(a){a=a|0;var b=0;b=i;if(!a){i=b;return}jb[c[(c[a>>2]|0)+4>>2]&127](a);i=b;return}function Gk(){var a=0,b=0;a=i;b=NB(16)|0;a:do if(!b){while(1){b=c[4582]|0;c[4582]=b+0;if(!b)break;qb[b&63]();b=NB(16)|0;if(b)break a}b=cb(4)|0;c[b>>2]=18168;_a(b|0,18216,116)}while(0);c[b+0>>2]=0;c[b+4>>2]=0;c[b+8>>2]=0;c[b+12>>2]=0;i=a;return b|0}function Hk(a){a=a|0;return+(+g[a>>2])}function Ik(a,b){a=a|0;b=+b;g[a>>2]=b;return}function Jk(a){a=a|0;return a+4|0}function Kk(a,b){a=a|0;b=b|0;var d=0,e=0;e=b;d=c[e+4>>2]|0;b=a+4|0;c[b>>2]=c[e>>2];c[b+4>>2]=d;return}function Lk(a){a=a|0;return+(+g[a+12>>2])}function Mk(a,b){a=a|0;b=+b;g[a+12>>2]=b;return}function Nk(a){a=a|0;var b=0;b=i;if(a)OB(a);i=b;return}function Ok(a){a=a|0;return c[a+4>>2]|0}function Pk(a){a=a|0;return c[a+48>>2]|0}function Qk(a){a=a|0;return c[a+52>>2]|0}function Rk(b){b=b|0;var d=0,e=0,f=0;e=i;i=i+16|0;d=e;if((a[384]|0)==0?(wa(384)|0)!=0:0)Da(384);lb[c[c[b>>2]>>2]&127](d,b);f=d;b=c[f+4>>2]|0;d=376;c[d>>2]=c[f>>2];c[d+4>>2]=b;i=e;return 376}function Sk(b){b=b|0;var d=0,e=0,f=0;e=i;i=i+16|0;d=e;if((a[400]|0)==0?(wa(400)|0)!=0:0)Da(400);lb[c[(c[b>>2]|0)+4>>2]&127](d,b);f=d;b=c[f+4>>2]|0;d=392;c[d>>2]=c[f>>2];c[d+4>>2]=b;i=e;return 392}function Tk(b,d){b=b|0;d=+d;var e=0,f=0,g=0;f=i;i=i+16|0;e=f;if((a[416]|0)==0?(wa(416)|0)!=0:0)Da(416);rb[c[(c[b>>2]|0)+8>>2]&63](e,b,d);g=e;b=c[g+4>>2]|0;e=408;c[e>>2]=c[g>>2];c[e+4>>2]=b;i=f;return 408}function Uk(a,b){a=a|0;b=+b;var d=0;d=i;b=+ib[c[(c[a>>2]|0)+12>>2]&63](a,b);i=d;return+b}function Vk(a){a=a|0;return c[a+12>>2]|0}function Wk(a){a=a|0;return c[a+64>>2]|0}function Xk(a,b){a=a|0;b=b|0;c[a+64>>2]=b;return}function Yk(a){a=a|0;var d=0;d=i;if(!(b[(c[a+48>>2]|0)+4>>1]&32)){a=0;i=d;return a|0}a=(b[(c[a+52>>2]|0)+4>>1]&32)!=0;i=d;return a|0}function Zk(b){b=b|0;return(a[b+61>>0]|0)!=0|0}function _k(a){a=a|0;var b=0;b=i;jb[c[(c[a>>2]|0)+16>>2]&127](a);i=b;return}function $k(a){a=a|0;return c[a+68>>2]|0}function al(a){a=a|0;return c[a+72>>2]|0}function bl(a,b){a=a|0;b=+b;var d=0;d=i;if(((g[k>>2]=b,c[k>>2]|0)&2139095040|0)==2139095040)Aa(15064,14928,394,15088);else{g[a+152>>2]=b;i=d;return}}function cl(a){a=a|0;return+(+g[a+152>>2])}function dl(a){a=a|0;return c[a+4>>2]|0}function el(a){a=a|0;return c[a+48>>2]|0}function fl(a){a=a|0;return c[a+52>>2]|0}function gl(b){b=b|0;var d=0,e=0,f=0;e=i;i=i+16|0;d=e;if((a[432]|0)==0?(wa(432)|0)!=0:0)Da(432);lb[c[c[b>>2]>>2]&127](d,b);f=d;b=c[f+4>>2]|0;d=424;c[d>>2]=c[f>>2];c[d+4>>2]=b;i=e;return 424}function hl(b){b=b|0;var d=0,e=0,f=0;e=i;i=i+16|0;d=e;if((a[448]|0)==0?(wa(448)|0)!=0:0)Da(448);lb[c[(c[b>>2]|0)+4>>2]&127](d,b);f=d;b=c[f+4>>2]|0;d=440;c[d>>2]=c[f>>2];c[d+4>>2]=b;i=e;return 440}function il(b,d){b=b|0;d=+d;var e=0,f=0,g=0;f=i;i=i+16|0;e=f;if((a[464]|0)==0?(wa(464)|0)!=0:0)Da(464);rb[c[(c[b>>2]|0)+8>>2]&63](e,b,d);g=e;b=c[g+4>>2]|0;e=456;c[e>>2]=c[g>>2];c[e+4>>2]=b;i=f;return 456}function jl(a,b){a=a|0;b=+b;var d=0;d=i;b=+ib[c[(c[a>>2]|0)+12>>2]&63](a,b);i=d;return+b}function kl(a){a=a|0;return c[a+12>>2]|0}function ll(a){a=a|0;return c[a+64>>2]|0}function ml(a,b){a=a|0;b=b|0;c[a+64>>2]=b;return}function nl(a){a=a|0;var d=0;d=i;if(!(b[(c[a+48>>2]|0)+4>>1]&32)){a=0;i=d;return a|0}a=(b[(c[a+52>>2]|0)+4>>1]&32)!=0;i=d;return a|0}function ol(b){b=b|0;return(a[b+61>>0]|0)!=0|0}function pl(a){a=a|0;var b=0;b=i;if(!a){i=b;return}jb[c[(c[a>>2]|0)+28>>2]&127](a);i=b;return}function ql(a){a=a|0;var b=0;b=i;if(!a){i=b;return}jb[c[(c[a>>2]|0)+4>>2]&127](a);i=b;return}function rl(a){a=a|0;return a+80|0}function sl(a){a=a|0;return a+88|0}function tl(a,b){a=a|0;b=+b;g[a+68>>2]=b;return}function ul(a){a=a|0;return+(+g[a+68>>2])}function vl(a,b){a=a|0;b=+b;g[a+72>>2]=b;return}function wl(a){a=a|0;return+(+g[a+72>>2])}function xl(a){a=a|0;var b=0;b=i;jb[c[(c[a>>2]|0)+16>>2]&127](a);i=b;return}function yl(a){a=a|0;return c[a+4>>2]|0}function zl(a){a=a|0;return c[a+48>>2]|0}function Al(a){a=a|0;return c[a+52>>2]|0}function Bl(b){b=b|0;var d=0,e=0,f=0;e=i;i=i+16|0;d=e;if((a[480]|0)==0?(wa(480)|0)!=0:0)Da(480);lb[c[c[b>>2]>>2]&127](d,b);f=d;b=c[f+4>>2]|0;d=472;c[d>>2]=c[f>>2];c[d+4>>2]=b;i=e;return 472}function Cl(b){b=b|0;var d=0,e=0,f=0;e=i;i=i+16|0;d=e;if((a[496]|0)==0?(wa(496)|0)!=0:0)Da(496);lb[c[(c[b>>2]|0)+4>>2]&127](d,b);f=d;b=c[f+4>>2]|0;d=488;c[d>>2]=c[f>>2];c[d+4>>2]=b;i=e;return 488}function Dl(b,d){b=b|0;d=+d;var e=0,f=0,g=0;f=i;i=i+16|0;e=f;if((a[512]|0)==0?(wa(512)|0)!=0:0)Da(512);rb[c[(c[b>>2]|0)+8>>2]&63](e,b,d);g=e;b=c[g+4>>2]|0;e=504;c[e>>2]=c[g>>2];c[e+4>>2]=b;i=f;return 504}function El(a,b){a=a|0;b=+b;var d=0;d=i;b=+ib[c[(c[a>>2]|0)+12>>2]&63](a,b);i=d;return+b}function Fl(a){a=a|0;return c[a+12>>2]|0}function Gl(a){a=a|0;return c[a+64>>2]|0}function Hl(a,b){a=a|0;b=b|0;c[a+64>>2]=b;return}function Il(a){a=a|0;var d=0;d=i;if(!(b[(c[a+48>>2]|0)+4>>1]&32)){a=0;i=d;return a|0}a=(b[(c[a+52>>2]|0)+4>>1]&32)!=0;i=d;return a|0}function Jl(b){b=b|0;return(a[b+61>>0]|0)!=0|0}function Kl(a){a=a|0;var b=0;b=i;if(!a){i=b;return}jb[c[(c[a>>2]|0)+28>>2]&127](a);i=b;return}function Ll(){var a=0,b=0;a=i;b=NB(16)|0;a:do if(!b){while(1){b=c[4582]|0;c[4582]=b+0;if(!b)break;qb[b&63]();b=NB(16)|0;if(b)break a}b=cb(4)|0;c[b>>2]=18168;_a(b|0,18216,116)}while(0);c[b+0>>2]=0;c[b+4>>2]=0;c[b+8>>2]=0;c[b+12>>2]=0;i=a;return b|0}function Ml(a){a=a|0;return c[a>>2]|0}function Nl(a,b){a=a|0;b=b|0;c[a>>2]=b;return}function Ol(a){a=a|0;return c[a+4>>2]|0}function Pl(a,b){a=a|0;b=b|0;c[a+4>>2]=b;return}function Ql(a){a=a|0;return c[a+8>>2]|0}function Rl(a,b){a=a|0;b=b|0;c[a+8>>2]=b;return}function Sl(a){a=a|0;return c[a+12>>2]|0}function Tl(a,b){a=a|0;b=b|0;c[a+12>>2]=b;return}function Ul(a){a=a|0;var b=0;b=i;if(a)OB(a);i=b;return}function Vl(){var b=0,d=0;b=i;d=NB(64)|0;a:do if(!d){while(1){d=c[4582]|0;c[4582]=d+0;if(!d)break;qb[d&63]();d=NB(64)|0;if(d)break a}d=cb(4)|0;c[d>>2]=18168;_a(d|0,18216,116)}while(0);c[d+0>>2]=0;c[d+4>>2]=0;c[d+8>>2]=0;c[d+12>>2]=0;c[d>>2]=4;g[d+20>>2]=-1.0;g[d+24>>2]=1.0;g[d+28>>2]=1.0;g[d+32>>2]=1.0;g[d+36>>2]=-1.0;g[d+40>>2]=0.0;g[d+44>>2]=1.0;g[d+48>>2]=0.0;g[d+52>>2]=0.0;g[d+56>>2]=0.0;g[d+60>>2]=1.0;a[d+16>>0]=1;i=b;return d|0}function Wl(a,b,d,e,f,h,j,k){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;j=j|0;k=+k;var l=0,m=0.0,n=0.0,o=0,p=0.0,q=0.0,r=0.0,s=0,t=0;l=i;c[a+8>>2]=b;c[a+12>>2]=d;o=e;s=c[o+4>>2]|0;t=a+20|0;c[t>>2]=c[o>>2];c[t+4>>2]=s;t=f;s=c[t+4>>2]|0;o=a+28|0;c[o>>2]=c[t>>2];c[o+4>>2]=s;r=+g[h>>2]- +g[b+12>>2];o=h+4|0;m=+g[o>>2]- +g[b+16>>2];n=+g[b+24>>2];p=+g[b+20>>2];q=+(r*n+m*p);p=+(n*m-r*p);b=a+36|0;g[b>>2]=q;g[b+4>>2]=p;p=+g[j>>2]- +g[d+12>>2];b=j+4|0;q=+g[b>>2]- +g[d+16>>2];r=+g[d+24>>2];m=+g[d+20>>2];n=+(p*r+q*m);m=+(r*q-p*m);d=a+44|0;g[d>>2]=n;g[d+4>>2]=m;m=+g[h>>2]- +g[e>>2];n=+g[o>>2]- +g[e+4>>2];g[a+52>>2]=+O(+(m*m+n*n));n=+g[j>>2]- +g[f>>2];m=+g[b>>2]- +g[f+4>>2];g[a+56>>2]=+O(+(n*n+m*m));g[a+60>>2]=k;if(k>1.1920928955078125e-7){i=l;return}else Aa(16200,16232,51,16288)}function Xl(a){a=a|0;return a+20|0}function Yl(a,b){a=a|0;b=b|0;var d=0,e=0;e=b;d=c[e+4>>2]|0;b=a+20|0;c[b>>2]=c[e>>2];c[b+4>>2]=d;return}function Zl(a){a=a|0;return a+28|0}function _l(a,b){a=a|0;b=b|0;var d=0,e=0;e=b;d=c[e+4>>2]|0;b=a+28|0;c[b>>2]=c[e>>2];c[b+4>>2]=d;return}function $l(a){a=a|0;return a+36|0}function am(a,b){a=a|0;b=b|0;var d=0,e=0;e=b;d=c[e+4>>2]|0;b=a+36|0;c[b>>2]=c[e>>2];c[b+4>>2]=d;return}function bm(a){a=a|0;return a+44|0}function cm(a,b){a=a|0;b=b|0;var d=0,e=0;e=b;d=c[e+4>>2]|0;b=a+44|0;c[b>>2]=c[e>>2];c[b+4>>2]=d;return}function dm(a){a=a|0;return+(+g[a+52>>2])}function em(a,b){a=a|0;b=+b;g[a+52>>2]=b;return}function fm(a){a=a|0;return+(+g[a+56>>2])}function gm(a,b){a=a|0;b=+b;g[a+56>>2]=b;return}function hm(a){a=a|0;return+(+g[a+60>>2])}function im(a,b){a=a|0;b=+b;g[a+60>>2]=b;return}function jm(a){a=a|0;return c[a>>2]|0}function km(a,b){a=a|0;b=b|0;c[a>>2]=b;return}function lm(a){a=a|0;return c[a+4>>2]|0}function mm(a,b){a=a|0;b=b|0;c[a+4>>2]=b;return}function nm(a){a=a|0;return c[a+8>>2]|0}function om(a,b){a=a|0;b=b|0;c[a+8>>2]=b;return}function pm(a){a=a|0;return c[a+12>>2]|0}function qm(a,b){a=a|0;b=b|0;c[a+12>>2]=b;return}function rm(b){b=b|0;return(a[b+16>>0]|0)!=0|0}function sm(b,c){b=b|0;c=c|0;a[b+16>>0]=c&1;return}function tm(a){a=a|0;var b=0;b=i;if(a)OB(a);i=b;return}function um(a){a=a|0;var b=0;b=i;if(!a){i=b;return}jb[c[(c[a>>2]|0)+4>>2]&127](a);i=b;return}function vm(){var a=0,b=0;a=i;b=NB(20)|0;a:do if(!b){while(1){b=c[4582]|0;c[4582]=b+0;if(!b)break;qb[b&63]();b=NB(20)|0;if(b)break a}b=cb(4)|0;c[b>>2]=18168;_a(b|0,18216,116)}while(0);c[b+0>>2]=0;c[b+4>>2]=0;c[b+8>>2]=0;c[b+12>>2]=0;c[b+16>>2]=0;i=a;return b|0}function wm(a){a=a|0;return a|0}function xm(a,b){a=a|0;b=b|0;var d=0,e=0;e=b;d=c[e+4>>2]|0;b=a;c[b>>2]=c[e>>2];c[b+4>>2]=d;return}function ym(a){a=a|0;return+(+g[a+8>>2])}function zm(a,b){a=a|0;b=+b;g[a+8>>2]=b;return}function Am(a){a=a|0;return+(+g[a+12>>2])}function Bm(a,b){a=a|0;b=+b;g[a+12>>2]=b;return}function Cm(a){a=a|0;return a+16|0}function Dm(a,b){a=a|0;b=b|0;c[a+16>>2]=c[b>>2];return}function Em(a){a=a|0;var b=0;b=i;if(a)OB(a);i=b;return}function Fm(a){a=a|0;var b=0;b=i;if(!a){i=b;return}jb[c[(c[a>>2]|0)+4>>2]&127](a);i=b;return}function Gm(){var b=0,d=0;b=i;d=NB(20)|0;a:do if(!d){while(1){d=c[4582]|0;c[4582]=d+0;if(!d)break;qb[d&63]();d=NB(20)|0;if(d)break a}d=cb(4)|0;c[d>>2]=18168;_a(d|0,18216,116)}while(0);c[d+0>>2]=0;c[d+4>>2]=0;c[d+8>>2]=0;c[d+12>>2]=0;a[d+16>>0]=0;i=b;return d|0}function Hm(a){a=a|0;return c[a>>2]|0}function Im(a,b){a=a|0;b=b|0;c[a>>2]=b;return}function Jm(a){a=a|0;return c[a+4>>2]|0}function Km(a,b){a=a|0;b=b|0;c[a+4>>2]=b;return}function Lm(a){a=a|0;return c[a+8>>2]|0}function Mm(a,b){a=a|0;b=b|0;c[a+8>>2]=b;return}function Nm(a){a=a|0;return c[a+12>>2]|0}function Om(a,b){a=a|0;b=b|0;c[a+12>>2]=b;return}function Pm(b){b=b|0;return(a[b+16>>0]|0)!=0|0}function Qm(b,c){b=b|0;c=c|0;a[b+16>>0]=c&1;return}function Rm(a){a=a|0;var b=0;b=i;if(a)OB(a);i=b;return}function Sm(){var a=0,b=0,d=0;a=i;b=NB(16)|0;if(b){d=b;i=a;return d|0}while(1){b=c[4582]|0;c[4582]=b+0;if(!b){b=4;break}qb[b&63]();d=NB(16)|0;if(d){b=5;break}}if((b|0)==4){d=cb(4)|0;c[d>>2]=18168;_a(d|0,18216,116)}else if((b|0)==5){i=a;return d|0}return 0}function Tm(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0;d=i;e=NB(16)|0;a:do if(!e){while(1){e=c[4582]|0;c[4582]=e+0;if(!e)break;qb[e&63]();e=NB(16)|0;if(e)break a}e=cb(4)|0;c[e>>2]=18168;_a(e|0,18216,116)}while(0);g=a;a=c[g+4>>2]|0;f=e;c[f>>2]=c[g>>2];c[f+4>>2]=a;f=b;a=c[f+4>>2]|0;b=e+8|0;c[b>>2]=c[f>>2];c[b+4>>2]=a;i=d;return e|0}function Um(a){a=a|0;g[a>>2]=0.0;g[a+4>>2]=0.0;g[a+8>>2]=0.0;g[a+12>>2]=1.0;return}function Vm(a,b,d){a=a|0;b=b|0;d=+d;var e=0,f=0;f=b;e=c[f+4>>2]|0;b=a;c[b>>2]=c[f>>2];c[b+4>>2]=e;g[a+8>>2]=+R(+d);g[a+12>>2]=+Q(+d);return}function Wm(a){a=a|0;return a|0}function Xm(a,b){a=a|0;b=b|0;var d=0,e=0;e=b;d=c[e+4>>2]|0;b=a;c[b>>2]=c[e>>2];c[b+4>>2]=d;return}function Ym(a){a=a|0;return a+8|0}function Zm(a,b){a=a|0;b=b|0;var d=0,e=0;e=b;d=c[e+4>>2]|0;b=a+8|0;c[b>>2]=c[e>>2];c[b+4>>2]=d;return}function _m(a){a=a|0;var b=0;b=i;if(a)OB(a);i=b;return}function $m(){var b=0,d=0;b=i;d=NB(40)|0;a:do if(!d){while(1){d=c[4582]|0;c[4582]=d+0;if(!d)break;qb[d&63]();d=NB(40)|0;if(d)break a}d=cb(4)|0;c[d>>2]=18168;_a(d|0,18216,116)}while(0);c[d>>2]=6488;c[d+4>>2]=3;g[d+8>>2]=.009999999776482582;c[d+12>>2]=0;c[d+16>>2]=0;a[d+36>>0]=0;a[d+37>>0]=0;i=b;return d|0}function an(a){a=a|0;var b=0,d=0;b=i;d=a+12|0;OB(c[d>>2]|0);c[d>>2]=0;c[a+16>>2]=0;i=b;return}function bn(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,h=0,j=0,l=0,m=0,n=0,o=0.0,p=0.0,q=0.0,r=0;h=i;f=b+12|0;if(c[f>>2]|0)Aa(6520,6560,38,6616);j=b+16|0;if(c[j>>2]|0)Aa(6520,6560,38,6616);if((e|0)<=2)Aa(7440,6560,39,6616);m=d;n=c[m>>2]|0;m=c[m+4>>2]|0;l=1;while(1){q=(c[k>>2]=n,+g[k>>2]);o=(c[k>>2]=m,+g[k>>2]);r=d+(l<<3)|0;n=c[r>>2]|0;m=c[r+4>>2]|0;p=(c[k>>2]=n,+g[k>>2]);p=q-p;o=o-(c[k>>2]=m,+g[k>>2]);l=l+1|0;if(!(p*p+o*o>2499999936844688.0e-20)){l=9;break}if((l|0)>=(e|0)){l=10;break}}if((l|0)==9)Aa(6632,6560,45,6616);else if((l|0)==10){m=e+1|0;c[j>>2]=m;m=NB(m<<3)|0;c[f>>2]=m;SB(m|0,d|0,e<<3|0)|0;m=c[f>>2]|0;r=m;l=c[r+4>>2]|0;m=m+(e<<3)|0;c[m>>2]=c[r>>2];c[m+4>>2]=l;m=c[f>>2]|0;l=m+((c[j>>2]|0)+ -2<<3)|0;r=c[l+4>>2]|0;n=b+20|0;c[n>>2]=c[l>>2];c[n+4>>2]=r;m=m+8|0;n=c[m+4>>2]|0;r=b+28|0;c[r>>2]=c[m>>2];c[r+4>>2]=n;a[b+36>>0]=1;a[b+37>>0]=1;i=h;return}}function cn(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=i;hx(a,b,c);i=d;return}function dn(b,d){b=b|0;d=d|0;var e=0,f=0;f=d;e=c[f+4>>2]|0;d=b+20|0;c[d>>2]=c[f>>2];c[d+4>>2]=e;a[b+36>>0]=1;return}function en(b,d){b=b|0;d=d|0;var e=0,f=0;f=d;e=c[f+4>>2]|0;d=b+28|0;c[d>>2]=c[f>>2];c[d+4>>2]=e;a[b+37>>0]=1;return}function fn(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=i;kx(a,b,c);i=d;return}function gn(a){a=a|0;return c[a+4>>2]|0}function hn(a){a=a|0;var b=0;b=i;a=nb[c[(c[a>>2]|0)+12>>2]&63](a)|0;i=b;return a|0}function jn(a,b,d){a=a|0;b=b|0;d=d|0;var e=0;e=i;a=gb[c[(c[a>>2]|0)+16>>2]&63](a,b,d)|0;i=e;return a|0}function kn(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0;g=i;a=ub[c[(c[a>>2]|0)+20>>2]&63](a,b,d,e,f)|0;i=g;return a|0}function ln(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0;f=i;vb[c[(c[a>>2]|0)+24>>2]&63](a,b,d,e);i=f;return}function mn(a,b,d){a=a|0;b=b|0;d=+d;var e=0;e=i;rb[c[(c[a>>2]|0)+28>>2]&63](a,b,d);i=e;return}function nn(a){a=a|0;return c[a+12>>2]|0}function on(a,b){a=a|0;b=b|0;c[a+12>>2]=b;return}function pn(a){a=a|0;return c[a+16>>2]|0}function qn(a,b){a=a|0;b=b|0;c[a+16>>2]=b;return}function rn(a){a=a|0;return a+20|0}function sn(a,b){a=a|0;b=b|0;var d=0,e=0;e=b;d=c[e+4>>2]|0;b=a+20|0;c[b>>2]=c[e>>2];c[b+4>>2]=d;return}function tn(a){a=a|0;return a+28|0}function un(a,b){a=a|0;b=b|0;var d=0,e=0;e=b;d=c[e+4>>2]|0;b=a+28|0;c[b>>2]=c[e>>2];c[b+4>>2]=d;return}function vn(b){b=b|0;return(a[b+36>>0]|0)!=0|0}function wn(b,c){b=b|0;c=c|0;a[b+36>>0]=c&1;return}function xn(b){b=b|0;return(a[b+37>>0]|0)!=0|0}function yn(b,c){b=b|0;c=c|0;a[b+37>>0]=c&1;return}function zn(a){a=a|0;return c[a+4>>2]|0}function An(a,b){a=a|0;b=b|0;c[a+4>>2]=b;return}function Bn(a){a=a|0;return+(+g[a+8>>2])}function Cn(a,b){a=a|0;b=+b;g[a+8>>2]=b;return}function Dn(a){a=a|0;var b=0;b=i;if(!a){i=b;return}jb[c[(c[a>>2]|0)+4>>2]&127](a);i=b;return}function En(){var a=0,b=0,d=0;a=i;b=NB(16)|0;if(b){d=b;i=a;return d|0}while(1){b=c[4582]|0;c[4582]=b+0;if(!b){b=4;break}qb[b&63]();d=NB(16)|0;if(d){b=5;break}}if((b|0)==4){d=cb(4)|0;c[d>>2]=18168;_a(d|0,18216,116)}else if((b|0)==5){i=a;return d|0}return 0}function Fn(a,b,d){a=+a;b=+b;d=+d;var e=0,f=0;e=i;f=NB(16)|0;a:do if(!f){while(1){f=c[4582]|0;c[4582]=f+0;if(!f)break;qb[f&63]();f=NB(16)|0;if(f)break a}f=cb(4)|0;c[f>>2]=18168;_a(f|0,18216,116)}while(0);g[f>>2]=a;g[f+4>>2]=b;g[f+8>>2]=d;g[f+12>>2]=1.0;i=e;return f|0}function Gn(a,b,c,d){a=a|0;b=+b;c=+c;d=+d;g[a>>2]=b;g[a+4>>2]=c;g[a+8>>2]=d;g[a+12>>2]=1.0;return}function Hn(a){a=a|0;return+(+g[a>>2])}function In(a,b){a=a|0;b=+b;g[a>>2]=b;return}function Jn(a){a=a|0;return+(+g[a+4>>2])}function Kn(a,b){a=a|0;b=+b;g[a+4>>2]=b;return}function Ln(a){a=a|0;return+(+g[a+8>>2])}function Mn(a,b){a=a|0;b=+b;g[a+8>>2]=b;return}function Nn(a){a=a|0;var b=0;b=i;if(a)OB(a);i=b;return}function On(a){a=a|0;return a+68|0}function Pn(a){a=a|0;return a+76|0}function Qn(a,b){a=a|0;b=+b;g[a+84>>2]=b;return}function Rn(a){a=a|0;return+(+g[a+84>>2])}function Sn(a){a=a|0;return c[a+164>>2]|0}function Tn(a){a=a|0;return c[a+4>>2]|0}function Un(a){a=a|0;return c[a+48>>2]|0}function Vn(a){a=a|0;return c[a+52>>2]|0}function Wn(b){b=b|0;var d=0,e=0,f=0;e=i;i=i+16|0;d=e;if((a[528]|0)==0?(wa(528)|0)!=0:0)Da(528);lb[c[c[b>>2]>>2]&127](d,b);f=d;b=c[f+4>>2]|0;d=520;c[d>>2]=c[f>>2];c[d+4>>2]=b;i=e;return 520}function Xn(b){b=b|0;var d=0,e=0,f=0;e=i;i=i+16|0;d=e;if((a[544]|0)==0?(wa(544)|0)!=0:0)Da(544);lb[c[(c[b>>2]|0)+4>>2]&127](d,b);f=d;b=c[f+4>>2]|0;d=536;c[d>>2]=c[f>>2];c[d+4>>2]=b;i=e;return 536}function Yn(b,d){b=b|0;d=+d;var e=0,f=0,g=0;f=i;i=i+16|0;e=f;if((a[560]|0)==0?(wa(560)|0)!=0:0)Da(560);rb[c[(c[b>>2]|0)+8>>2]&63](e,b,d);g=e;b=c[g+4>>2]|0;e=552;c[e>>2]=c[g>>2];c[e+4>>2]=b;i=f;return 552}function Zn(a,b){a=a|0;b=+b;var d=0;d=i;b=+ib[c[(c[a>>2]|0)+12>>2]&63](a,b);i=d;return+b}function _n(a){a=a|0;return c[a+12>>2]|0}function $n(a){a=a|0;return c[a+64>>2]|0}function ao(a,b){a=a|0;b=b|0;c[a+64>>2]=b;return}function bo(a){a=a|0;var d=0;d=i;if(!(b[(c[a+48>>2]|0)+4>>1]&32)){a=0;i=d;return a|0}a=(b[(c[a+52>>2]|0)+4>>1]&32)!=0;i=d;return a|0}function co(b){b=b|0;return(a[b+61>>0]|0)!=0|0}function eo(a){a=a|0;var b=0;b=i;if(!a){i=b;return}jb[c[(c[a>>2]|0)+28>>2]&127](a);i=b;return}function fo(a){a=a|0;return a|0}function go(a,b){a=a|0;b=b|0;var d=0,e=0;e=b;d=c[e+4>>2]|0;b=a;c[b>>2]=c[e>>2];c[b+4>>2]=d;return}function ho(a){a=a|0;return a+8|0}function io(a,b){a=a|0;b=b|0;var d=0,e=0;e=b;d=c[e+4>>2]|0;b=a+8|0;c[b>>2]=c[e>>2];c[b+4>>2]=d;return}function jo(a){a=a|0;return+(+g[a+16>>2])}function ko(a,b){a=a|0;b=+b;g[a+16>>2]=b;return}function lo(a){a=a|0;var b=0;b=i;if(a)OB(a);i=b;return}function mo(){var a=0,b=0;a=i;b=NB(280)|0;a:do if(!b){while(1){b=c[4582]|0;c[4582]=b+0;if(!b)break;qb[b&63]();b=NB(280)|0;if(b)break a}b=cb(4)|0;c[b>>2]=18168;_a(b|0,18216,116)}while(0);c[b>>2]=7368;c[b+4>>2]=2;g[b+8>>2]=.009999999776482582;c[b+276>>2]=0;g[b+12>>2]=0.0;g[b+16>>2]=0.0;i=a;return b|0}function no(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0.0,h=0.0,j=0.0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0;e=i;i=i+192|0;o=e+64|0;n=e;if((d+ -3|0)>>>0>=14)Aa(7072,7104,122,7160);v=~d;v=(v|0)>-17?v:-17;p=~v;SB(o|0,b|0,-8-(v<<3)|0)|0;if((v|0)>-4)Aa(15224,7104,159,7160);q=0;b=1;w=+g[o>>2];do{x=+g[o+(b<<3)>>2];if(!(x>w)){if(x==w?+g[o+(b<<3)+4>>2]<+g[o+(q<<3)+4>>2]:0)l=9}else l=9;if((l|0)==9){l=0;q=b;w=x}b=b+1|0}while((b|0)!=(p|0));r=q;s=1;b=0;while(1){c[n+(b<<2)>>2]=r;u=o+(r<<3)|0;d=o+(r<<3)+4|0;v=0;t=1;do{if((v|0)!=(r|0)){z=+g[u>>2];x=+g[o+(v<<3)>>2]-z;w=+g[d>>2];y=+g[o+(v<<3)+4>>2]-w;z=+g[o+(t<<3)>>2]-z;w=+g[o+(t<<3)+4>>2]-w;A=x*w-y*z;v=A<0.0?t:v;if(A==0.0?z*z+w*w>x*x+y*y:0)v=t}else v=t;t=t+1|0}while((t|0)!=(p|0));d=b+1|0;if((v|0)==(q|0))break;else{r=v;s=s+1|0;b=d}}if((d|0)<3)Aa(15224,7104,224,7160);c[a+276>>2]=d;if((b|0)>-1)m=0;else Aa(7440,7104,76,7456);do{t=o+(c[n+(m<<2)>>2]<<3)|0;u=c[t+4>>2]|0;v=a+(m<<3)+20|0;c[v>>2]=c[t>>2];c[v+4>>2]=u;m=m+1|0}while((m|0)!=(s|0));o=0;do{p=o;o=o+1|0;n=(o|0)<(d|0);v=n?o:0;y=+g[a+(v<<3)+20>>2]- +g[a+(p<<3)+20>>2];w=+g[a+(v<<3)+24>>2]- +g[a+(p<<3)+24>>2];x=w*w;if(!(y*y+x>1.4210854715202004e-14)){l=24;break}m=a+(p<<3)+148|0;A=+w;y=+-y;v=m;g[v>>2]=A;g[v+4>>2]=y;p=a+(p<<3)+152|0;y=+g[p>>2];x=+O(+(x+y*y));if(!(x<1.1920928955078125e-7)){A=1.0/x;g[m>>2]=w*A;g[p>>2]=y*A}}while(n);if((l|0)==24)Aa(7168,7104,243,7160);l=a+12|0;m=a+20|0;if((b|0)>1){h=0.0;j=0.0;f=0.0;k=0}else Aa(7440,7104,76,7456);do{v=a+(k<<3)+20|0;w=+g[v>>2];x=+g[v+4>>2];k=k+1|0;if((k|0)<(d|0))b=a+(k<<3)+20|0;else b=m;v=b;y=+g[v>>2];z=+g[v+4>>2];A=(w*z-x*y)*.5;f=f+A;A=A*.3333333432674408;h=h+(w+0.0+y)*A;j=j+(x+0.0+z)*A}while((k|0)!=(d|0));if(f>1.1920928955078125e-7){A=1.0/f;z=+(h*A);A=+(j*A);v=l;g[v>>2]=z;g[v+4>>2]=A;i=e;return}else Aa(7328,7104,115,7456)}function oo(a,b,d){a=a|0;b=+b;d=+d;var e=0.0,f=0.0;c[a+276>>2]=4;e=-b;f=-d;g[a+20>>2]=e;g[a+24>>2]=f;g[a+28>>2]=b;g[a+32>>2]=f;g[a+36>>2]=b;g[a+40>>2]=d;g[a+44>>2]=e;g[a+48>>2]=d;g[a+148>>2]=0.0;g[a+152>>2]=-1.0;g[a+156>>2]=1.0;g[a+160>>2]=0.0;g[a+164>>2]=0.0;g[a+168>>2]=1.0;g[a+172>>2]=-1.0;g[a+176>>2]=0.0;g[a+12>>2]=0.0;g[a+16>>2]=0.0;return}function po(a,b,d,e,f){a=a|0;b=+b;d=+d;e=e|0;f=+f;var h=0,j=0,k=0.0,l=0.0,m=0.0,n=0,o=0,p=0,q=0.0,r=0.0;j=i;h=a+276|0;c[h>>2]=4;k=-b;m=-d;g[a+20>>2]=k;g[a+24>>2]=m;g[a+28>>2]=b;g[a+32>>2]=m;g[a+36>>2]=b;g[a+40>>2]=d;g[a+44>>2]=k;g[a+48>>2]=d;g[a+148>>2]=0.0;g[a+152>>2]=-1.0;g[a+156>>2]=1.0;g[a+160>>2]=0.0;g[a+164>>2]=0.0;g[a+168>>2]=1.0;g[a+172>>2]=-1.0;g[a+176>>2]=0.0;p=e;o=c[p+4>>2]|0;n=a+12|0;c[n>>2]=c[p>>2];c[n+4>>2]=o;d=+g[e>>2];k=+g[e+4>>2];b=+R(+f);f=+Q(+f);l=-1.0;e=0;while(1){p=a+(e<<3)+20|0;r=+g[p>>2];q=+(d+(f*r-b*m));m=+(k+(b*r+f*m));g[p>>2]=q;g[p+4>>2]=m;p=a+(e<<3)+148|0;m=+g[p>>2];q=+(f*m-b*l);m=+(b*m+f*l);g[p>>2]=q;g[p+4>>2]=m;e=e+1|0;if((e|0)>=(c[h>>2]|0))break;m=+g[a+(e<<3)+24>>2];l=+g[a+(e<<3)+152>>2]}i=j;return}function qo(a){a=a|0;return c[a+276>>2]|0}function ro(a,b){a=a|0;b=b|0;var d=0;d=i;if((b|0)>-1?(c[a+276>>2]|0)>(b|0):0){i=d;return a+(b<<3)+20|0}Aa(6336,2624,97,6416);return 0}function so(a){a=a|0;return c[a+4>>2]|0}function to(a){a=a|0;var b=0;b=i;a=nb[c[(c[a>>2]|0)+12>>2]&63](a)|0;i=b;return a|0}function uo(a,b,d){a=a|0;b=b|0;d=d|0;var e=0;e=i;a=gb[c[(c[a>>2]|0)+16>>2]&63](a,b,d)|0;i=e;return a|0}function vo(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0;g=i;a=ub[c[(c[a>>2]|0)+20>>2]&63](a,b,d,e,f)|0;i=g;return a|0}function wo(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0;f=i;vb[c[(c[a>>2]|0)+24>>2]&63](a,b,d,e);i=f;return}function xo(a,b,d){a=a|0;b=b|0;d=+d;var e=0;e=i;rb[c[(c[a>>2]|0)+28>>2]&63](a,b,d);i=e;return}function yo(a){a=a|0;return a+12|0}function zo(a,b){a=a|0;b=b|0;var d=0,e=0;e=b;d=c[e+4>>2]|0;b=a+12|0;c[b>>2]=c[e>>2];c[b+4>>2]=d;return}function Ao(a){a=a|0;return c[a+276>>2]|0}function Bo(a,b){a=a|0;b=b|0;c[a+276>>2]=b;return}function Co(a){a=a|0;return c[a+4>>2]|0}function Do(a,b){a=a|0;b=b|0;c[a+4>>2]=b;return}function Eo(a){a=a|0;return+(+g[a+8>>2])}function Fo(a,b){a=a|0;b=+b;g[a+8>>2]=b;return}function Go(a){a=a|0;var b=0;b=i;if(!a){i=b;return}jb[c[(c[a>>2]|0)+4>>2]&127](a);i=b;return}function Ho(){var a=0,d=0,e=0;a=i;d=NB(48)|0;a:do if(!d){while(1){d=c[4582]|0;c[4582]=d+0;if(!d)break;qb[d&63]();d=NB(48)|0;if(d)break a}d=cb(4)|0;c[d>>2]=18168;_a(d|0,18216,116)}while(0);c[d>>2]=7008;c[d+4>>2]=1;g[d+8>>2]=.009999999776482582;e=d+28|0;c[e+0>>2]=0;c[e+4>>2]=0;c[e+8>>2]=0;c[e+12>>2]=0;b[e+16>>1]=0;i=a;return d|0}function Io(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0;g=d;d=c[g+4>>2]|0;f=b+12|0;c[f>>2]=c[g>>2];c[f+4>>2]=d;f=e;e=c[f+4>>2]|0;d=b+20|0;c[d>>2]=c[f>>2];c[d+4>>2]=e;a[b+44>>0]=0;a[b+45>>0]=0;return}function Jo(a){a=a|0;return c[a+4>>2]|0}function Ko(a){a=a|0;var b=0;b=i;a=nb[c[(c[a>>2]|0)+12>>2]&63](a)|0;i=b;return a|0}function Lo(a,b,d){a=a|0;b=b|0;d=d|0;var e=0;e=i;a=gb[c[(c[a>>2]|0)+16>>2]&63](a,b,d)|0;i=e;return a|0}function Mo(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0;g=i;a=ub[c[(c[a>>2]|0)+20>>2]&63](a,b,d,e,f)|0;i=g;return a|0}function No(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0;f=i;vb[c[(c[a>>2]|0)+24>>2]&63](a,b,d,e);i=f;return}function Oo(a,b,d){a=a|0;b=b|0;d=+d;var e=0;e=i;rb[c[(c[a>>2]|0)+28>>2]&63](a,b,d);i=e;return}function Po(a){a=a|0;return a+12|0}function Qo(a,b){a=a|0;b=b|0;var d=0,e=0;e=b;d=c[e+4>>2]|0;b=a+12|0;c[b>>2]=c[e>>2];c[b+4>>2]=d;return}function Ro(a){a=a|0;return a+20|0}function So(a,b){a=a|0;b=b|0;var d=0,e=0;e=b;d=c[e+4>>2]|0;b=a+20|0;c[b>>2]=c[e>>2];c[b+4>>2]=d;return}function To(a){a=a|0;return a+28|0}function Uo(a,b){a=a|0;b=b|0;var d=0,e=0;e=b;d=c[e+4>>2]|0;b=a+28|0;c[b>>2]=c[e>>2];c[b+4>>2]=d;return}function Vo(a){a=a|0;return a+36|0}function Wo(a,b){a=a|0;b=b|0;var d=0,e=0;e=b;d=c[e+4>>2]|0;b=a+36|0;c[b>>2]=c[e>>2];c[b+4>>2]=d;return}function Xo(b){b=b|0;return(a[b+44>>0]|0)!=0|0}function Yo(b,c){b=b|0;c=c|0;a[b+44>>0]=c&1;return}function Zo(b){b=b|0;return(a[b+45>>0]|0)!=0|0}function _o(b,c){b=b|0;c=c|0;a[b+45>>0]=c&1;return}function $o(a){a=a|0;return c[a+4>>2]|0}function ap(a,b){a=a|0;b=b|0;c[a+4>>2]=b;return}function bp(a){a=a|0;return+(+g[a+8>>2])}function cp(a,b){a=a|0;b=+b;g[a+8>>2]=b;return}function dp(a){a=a|0;var b=0;b=i;if(!a){i=b;return}jb[c[(c[a>>2]|0)+4>>2]&127](a);i=b;return}function ep(){var a=0,b=0,d=0;a=i;b=NB(4)|0;if(b){d=b;c[d>>2]=2320;i=a;return d|0}while(1){b=c[4582]|0;c[4582]=b+0;if(!b){b=4;break}qb[b&63]();d=NB(4)|0;if(d){b=5;break}}if((b|0)==4){d=cb(4)|0;c[d>>2]=18168;_a(d|0,18216,116)}else if((b|0)==5){c[d>>2]=2320;i=a;return d|0}return 0}function fp(a,b,d){a=a|0;b=b|0;d=d|0;var e=0;e=i;a=gb[c[(c[a>>2]|0)+8>>2]&63](a,b,d)|0;i=e;return a|0}function gp(a){a=a|0;var b=0;b=i;if(!a){i=b;return}jb[c[(c[a>>2]|0)+4>>2]&127](a);i=b;return}function hp(){var b=0,d=0,e=0;b=i;d=NB(64)|0;a:do if(!d){while(1){d=c[4582]|0;c[4582]=d+0;if(!d)break;qb[d&63]();d=NB(64)|0;if(d)break a}d=cb(4)|0;c[d>>2]=18168;_a(d|0,18216,116)}while(0);c[d+0>>2]=0;c[d+4>>2]=0;c[d+8>>2]=0;c[d+12>>2]=0;a[d+16>>0]=0;c[d>>2]=1;e=d+20|0;g[d+44>>2]=0.0;g[d+48>>2]=0.0;g[d+60>>2]=0.0;g[d+56>>2]=0.0;a[d+52>>0]=0;c[e+0>>2]=0;c[e+4>>2]=0;c[e+8>>2]=0;c[e+12>>2]=0;c[e+16>>2]=0;a[e+20>>0]=0;i=b;return d|0}function ip(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,h=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0,o=0;f=i;c[a+8>>2]=b;c[a+12>>2]=d;m=+g[e>>2]- +g[b+12>>2];n=e+4|0;h=+g[n>>2]- +g[b+16>>2];j=+g[b+24>>2];k=+g[b+20>>2];l=+(m*j+h*k);k=+(j*h-m*k);o=a+20|0;g[o>>2]=l;g[o+4>>2]=k;k=+g[e>>2]- +g[d+12>>2];l=+g[n>>2]- +g[d+16>>2];m=+g[d+24>>2];h=+g[d+20>>2];j=+(k*m+l*h);h=+(m*l-k*h);e=a+28|0;g[e>>2]=j;g[e+4>>2]=h;g[a+36>>2]=+g[d+56>>2]- +g[b+56>>2];i=f;return}function jp(a){a=a|0;return a+20|0}function kp(a,b){a=a|0;b=b|0;var d=0,e=0;e=b;d=c[e+4>>2]|0;b=a+20|0;c[b>>2]=c[e>>2];c[b+4>>2]=d;return}function lp(a){a=a|0;return a+28|0}function mp(a,b){a=a|0;b=b|0;var d=0,e=0;e=b;d=c[e+4>>2]|0;b=a+28|0;c[b>>2]=c[e>>2];c[b+4>>2]=d;return}function np(a){a=a|0;return+(+g[a+36>>2])}function op(a,b){a=a|0;b=+b;g[a+36>>2]=b;return}function pp(b){b=b|0;return(a[b+40>>0]|0)!=0|0}function qp(b,c){b=b|0;c=c|0;a[b+40>>0]=c&1;return}function rp(a){a=a|0;return+(+g[a+44>>2])}function sp(a,b){a=a|0;b=+b;g[a+44>>2]=b;return}function tp(a){a=a|0;return+(+g[a+48>>2])}function up(a,b){a=a|0;b=+b;g[a+48>>2]=b;return}function vp(b){b=b|0;return(a[b+52>>0]|0)!=0|0}function wp(b,c){b=b|0;c=c|0;a[b+52>>0]=c&1;return}function xp(a){a=a|0;return+(+g[a+56>>2])}function yp(a,b){a=a|0;b=+b;g[a+56>>2]=b;return}function zp(a){a=a|0;return+(+g[a+60>>2])}function Ap(a,b){a=a|0;b=+b;g[a+60>>2]=b;return}function Bp(a){a=a|0;return c[a>>2]|0}function Cp(a,b){a=a|0;b=b|0;c[a>>2]=b;return}function Dp(a){a=a|0;return c[a+4>>2]|0}function Ep(a,b){a=a|0;b=b|0;c[a+4>>2]=b;return}function Fp(a){a=a|0;return c[a+8>>2]|0}function Gp(a,b){a=a|0;b=b|0;c[a+8>>2]=b;return}function Hp(a){a=a|0;return c[a+12>>2]|0}function Ip(a,b){a=a|0;b=b|0;c[a+12>>2]=b;return}function Jp(b){b=b|0;return(a[b+16>>0]|0)!=0|0}function Kp(b,c){b=b|0;c=c|0;a[b+16>>0]=c&1;return}function Lp(a){a=a|0;var b=0;b=i;if(a)OB(a);i=b;return}function Mp(){var a=0,b=0,d=0;a=i;b=NB(8)|0;a:do if(!b){while(1){b=c[4582]|0;c[4582]=b+0;if(!b)break;qb[b&63]();b=NB(8)|0;if(b)break a}b=cb(4)|0;c[b>>2]=18168;_a(b|0,18216,116)}while(0);d=b;c[d>>2]=0;c[d+4>>2]=0;c[b+4>>2]=0;c[b>>2]=912;i=a;return b|0}function Np(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0;f=i;vb[c[(c[a>>2]|0)+8>>2]&63](a,b,d,e);i=f;return}function Op(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0;f=i;vb[c[(c[a>>2]|0)+12>>2]&63](a,b,d,e);i=f;return}function Pp(a,b,d,e){a=a|0;b=b|0;d=+d;e=e|0;var f=0;f=i;ob[c[(c[a>>2]|0)+16>>2]&63](a,b,d,e);i=f;return}function Qp(a,b,d,e,f){a=a|0;b=b|0;d=+d;e=e|0;f=f|0;var g=0;g=i;mb[c[(c[a>>2]|0)+20>>2]&63](a,b,d,e,f);i=g;return}function Rp(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0;f=i;vb[c[(c[a>>2]|0)+24>>2]&63](a,b,d,e);i=f;return}function Sp(a,b){a=a|0;b=b|0;var d=0;d=i;lb[c[(c[a>>2]|0)+28>>2]&127](a,b);i=d;return}function Tp(a){a=a|0;var b=0;b=i;if(!a){i=b;return}jb[c[(c[a>>2]|0)+4>>2]&127](a);i=b;return}function Up(a){a=a|0;return a+76|0}function Vp(a){a=a|0;return a+84|0}function Wp(a){a=a|0;return a+92|0}function Xp(a){a=a|0;var b=0.0,d=0.0,e=0.0,f=0.0,h=0,i=0.0,j=0.0,k=0,l=0.0,m=0.0,n=0.0,o=0.0;h=c[a+48>>2]|0;k=c[a+52>>2]|0;d=+g[h+24>>2];j=+g[a+76>>2];f=+g[h+20>>2];i=+g[a+80>>2];m=+g[k+24>>2];o=+g[a+84>>2];n=+g[k+20>>2];l=+g[a+88>>2];e=+g[a+92>>2];b=+g[a+96>>2];return+((+g[k+12>>2]+(m*o-n*l)-(+g[h+12>>2]+(d*j-f*i)))*(d*e-f*b)+(o*n+m*l+ +g[k+16>>2]-(j*f+d*i+ +g[h+16>>2]))*(f*e+d*b))}function Yp(a){a=a|0;return+(+g[(c[a+52>>2]|0)+72>>2]- +g[(c[a+48>>2]|0)+72>>2])}function Zp(b){b=b|0;return(a[b+128>>0]|0)!=0|0}function _p(d,f){d=d|0;f=f|0;var h=0,j=0,k=0,l=0;h=i;j=c[d+48>>2]|0;k=j+4|0;l=e[k>>1]|0;if(!(l&2)){b[k>>1]=l|2;g[j+144>>2]=0.0}l=c[d+52>>2]|0;k=l+4|0;j=e[k>>1]|0;if(j&2){l=d+128|0;k=f&1;a[l>>0]=k;i=h;return}b[k>>1]=j|2;g[l+144>>2]=0.0;l=d+128|0;k=f&1;a[l>>0]=k;i=h;return}function $p(a,d){a=a|0;d=+d;var f=0,h=0,j=0,k=0;f=i;h=c[a+48>>2]|0;j=h+4|0;k=e[j>>1]|0;if(!(k&2)){b[j>>1]=k|2;g[h+144>>2]=0.0}k=c[a+52>>2]|0;j=k+4|0;h=e[j>>1]|0;if(h&2){k=a+124|0;g[k>>2]=d;i=f;return}b[j>>1]=h|2;g[k+144>>2]=0.0;k=a+124|0;g[k>>2]=d;i=f;return}function aq(a){a=a|0;return+(+g[a+124>>2])}function bq(a,d){a=a|0;d=+d;var f=0,h=0,j=0,k=0;f=i;h=c[a+48>>2]|0;j=h+4|0;k=e[j>>1]|0;if(!(k&2)){b[j>>1]=k|2;g[h+144>>2]=0.0}k=c[a+52>>2]|0;j=k+4|0;h=e[j>>1]|0;if(h&2){k=a+120|0;g[k>>2]=d;i=f;return}b[j>>1]=h|2;g[k+144>>2]=0.0;k=a+120|0;g[k>>2]=d;i=f;return}function cq(a){a=a|0;return+(+g[a+120>>2])}function dq(a,b){a=a|0;b=+b;return+(+g[a+112>>2]*b)}function eq(a,b){a=a|0;b=+b;g[a+68>>2]=b;return}function fq(a){a=a|0;return+(+g[a+68>>2])}function gq(a,b){a=a|0;b=+b;g[a+72>>2]=b;return}function hq(a){a=a|0;return+(+g[a+72>>2])}function iq(a){a=a|0;return c[a+4>>2]|0}function jq(a){a=a|0;return c[a+48>>2]|0}function kq(a){a=a|0;return c[a+52>>2]|0}function lq(b){b=b|0;var d=0,e=0,f=0;e=i;i=i+16|0;d=e;if((a[576]|0)==0?(wa(576)|0)!=0:0)Da(576);lb[c[c[b>>2]>>2]&127](d,b);f=d;b=c[f+4>>2]|0;d=568;c[d>>2]=c[f>>2];c[d+4>>2]=b;i=e;return 568}function mq(b){b=b|0;var d=0,e=0,f=0;e=i;i=i+16|0;d=e;if((a[592]|0)==0?(wa(592)|0)!=0:0)Da(592);lb[c[(c[b>>2]|0)+4>>2]&127](d,b);f=d;b=c[f+4>>2]|0;d=584;c[d>>2]=c[f>>2];c[d+4>>2]=b;i=e;return 584}function nq(b,d){b=b|0;d=+d;var e=0,f=0,g=0;f=i;i=i+16|0;e=f;if((a[608]|0)==0?(wa(608)|0)!=0:0)Da(608);rb[c[(c[b>>2]|0)+8>>2]&63](e,b,d);g=e;b=c[g+4>>2]|0;e=600;c[e>>2]=c[g>>2];c[e+4>>2]=b;i=f;return 600}function oq(a,b){a=a|0;b=+b;var d=0;d=i;b=+ib[c[(c[a>>2]|0)+12>>2]&63](a,b);i=d;return+b}function pq(a){a=a|0;return c[a+12>>2]|0}function qq(a){a=a|0;return c[a+64>>2]|0}function rq(a,b){a=a|0;b=b|0;c[a+64>>2]=b;return}function sq(a){a=a|0;var d=0;d=i;if(!(b[(c[a+48>>2]|0)+4>>1]&32)){a=0;i=d;return a|0}a=(b[(c[a+52>>2]|0)+4>>1]&32)!=0;i=d;return a|0}function tq(b){b=b|0;return(a[b+61>>0]|0)!=0|0}function uq(a){a=a|0;var b=0;b=i;if(!a){i=b;return}jb[c[(c[a>>2]|0)+28>>2]&127](a);i=b;return}function vq(b){b=b|0;var d=0,e=0,f=0;d=i;if((a[624]|0)==0?(wa(624)|0)!=0:0)Da(624);f=b+68|0;e=c[f+4>>2]|0;b=616;c[b>>2]=c[f>>2];c[b+4>>2]=e;i=d;return 616}function wq(b){b=b|0;var d=0,e=0,f=0;d=i;if((a[640]|0)==0?(wa(640)|0)!=0:0)Da(640);f=b+76|0;e=c[f+4>>2]|0;b=632;c[b>>2]=c[f>>2];c[b+4>>2]=e;i=d;return 632}function xq(a){a=a|0;return+(+g[a+84>>2])}function yq(a){a=a|0;return+(+g[a+88>>2])}function zq(a){a=a|0;return+(+g[a+112>>2])}function Aq(a){a=a|0;var b=0.0,d=0,e=0.0,f=0,h=0.0,j=0.0,k=0.0;d=i;f=c[a+48>>2]|0;h=+g[f+24>>2];k=+g[a+92>>2];j=+g[f+20>>2];b=+g[a+96>>2];a=a+68|0;e=+g[a>>2];e=+g[f+12>>2]+(h*k-j*b)-e;b=k*j+h*b+ +g[f+16>>2]- +g[a+4>>2];b=+O(+(e*e+b*b));i=d;return+b}function Bq(a){a=a|0;var b=0.0,d=0,e=0.0,f=0,h=0.0,j=0.0,k=0.0;d=i;f=c[a+52>>2]|0;h=+g[f+24>>2];k=+g[a+100>>2];j=+g[f+20>>2];b=+g[a+104>>2];a=a+76|0;e=+g[a>>2];e=+g[f+12>>2]+(h*k-j*b)-e;b=k*j+h*b+ +g[f+16>>2]- +g[a+4>>2];b=+O(+(e*e+b*b));i=d;return+b}function Cq(a){a=a|0;return c[a+4>>2]|0}function Dq(a){a=a|0;return c[a+48>>2]|0}function Eq(a){a=a|0;return c[a+52>>2]|0}function Fq(b){b=b|0;var d=0,e=0,f=0;e=i;i=i+16|0;d=e;if((a[656]|0)==0?(wa(656)|0)!=0:0)Da(656);lb[c[c[b>>2]>>2]&127](d,b);f=d;b=c[f+4>>2]|0;d=648;c[d>>2]=c[f>>2];c[d+4>>2]=b;i=e;return 648}function Gq(b){b=b|0;var d=0,e=0,f=0;e=i;i=i+16|0;d=e;if((a[672]|0)==0?(wa(672)|0)!=0:0)Da(672);lb[c[(c[b>>2]|0)+4>>2]&127](d,b);f=d;b=c[f+4>>2]|0;d=664;c[d>>2]=c[f>>2];c[d+4>>2]=b;i=e;return 664}function Hq(b,d){b=b|0;d=+d;var e=0,f=0,g=0;f=i;i=i+16|0;e=f;if((a[688]|0)==0?(wa(688)|0)!=0:0)Da(688);rb[c[(c[b>>2]|0)+8>>2]&63](e,b,d);g=e;b=c[g+4>>2]|0;e=680;c[e>>2]=c[g>>2];c[e+4>>2]=b;i=f;return 680}function Iq(a,b){a=a|0;b=+b;var d=0;d=i;b=+ib[c[(c[a>>2]|0)+12>>2]&63](a,b);i=d;return+b}function Jq(a){a=a|0;return c[a+12>>2]|0}function Kq(a){a=a|0;return c[a+64>>2]|0}function Lq(a,b){a=a|0;b=b|0;c[a+64>>2]=b;return}function Mq(a){a=a|0;var d=0;d=i;if(!(b[(c[a+48>>2]|0)+4>>1]&32)){a=0;i=d;return a|0}a=(b[(c[a+52>>2]|0)+4>>1]&32)!=0;i=d;return a|0}function Nq(b){b=b|0;return(a[b+61>>0]|0)!=0|0}function Oq(a){a=a|0;var b=0;b=i;if(!a){i=b;return}jb[c[(c[a>>2]|0)+28>>2]&127](a);i=b;return}function Pq(){var b=0,d=0;b=i;d=NB(40)|0;a:do if(!d){while(1){d=c[4582]|0;c[4582]=d+0;if(!d)break;qb[d&63]();d=NB(40)|0;if(d)break a}d=cb(4)|0;c[d>>2]=18168;_a(d|0,18216,116)}while(0);c[d+0>>2]=0;c[d+4>>2]=0;c[d+8>>2]=0;c[d+12>>2]=0;a[d+16>>0]=0;c[d>>2]=5;g[d+20>>2]=0.0;g[d+24>>2]=0.0;g[d+28>>2]=0.0;g[d+32>>2]=5.0;g[d+36>>2]=.699999988079071;i=b;return d|0}function Qq(a){a=a|0;return a+20|0}function Rq(a,b){a=a|0;b=b|0;var d=0,e=0;e=b;d=c[e+4>>2]|0;b=a+20|0;c[b>>2]=c[e>>2];c[b+4>>2]=d;return}function Sq(a){a=a|0;return+(+g[a+28>>2])}function Tq(a,b){a=a|0;b=+b;g[a+28>>2]=b;return}function Uq(a){a=a|0;return+(+g[a+32>>2])}function Vq(a,b){a=a|0;b=+b;g[a+32>>2]=b;return}function Wq(a){a=a|0;return+(+g[a+36>>2])}function Xq(a,b){a=a|0;b=+b;g[a+36>>2]=b;return}function Yq(a){a=a|0;return c[a>>2]|0}function Zq(a,b){a=a|0;b=b|0;c[a>>2]=b;return}function _q(a){a=a|0;return c[a+4>>2]|0}function $q(a,b){a=a|0;b=b|0;c[a+4>>2]=b;return}function ar(a){a=a|0;return c[a+8>>2]|0}function br(a,b){a=a|0;b=b|0;c[a+8>>2]=b;return}function cr(a){a=a|0;return c[a+12>>2]|0}function dr(a,b){a=a|0;b=b|0;c[a+12>>2]=b;return}function er(b){b=b|0;return(a[b+16>>0]|0)!=0|0}function fr(b,c){b=b|0;c=c|0;a[b+16>>0]=c&1;return}function gr(a){a=a|0;var b=0;b=i;if(a)OB(a);i=b;return}function hr(a){a=a|0;return a+64|0}function ir(a){a=a|0;return(c[a+4>>2]&2|0)!=0|0}function jr(a,b){a=a|0;b=b|0;var d=0;a=a+4|0;d=c[a>>2]|0;c[a>>2]=b?d|4:d&-5;return}function kr(a){a=a|0;return(c[a+4>>2]&4|0)!=0|0}function lr(a){a=a|0;return c[a+12>>2]|0}function mr(a){a=a|0;return c[a+48>>2]|0}function nr(a){a=a|0;return c[a+56>>2]|0}function or(a){a=a|0;return c[a+52>>2]|0}function pr(a){a=a|0;return c[a+60>>2]|0}function qr(a,b){a=a|0;b=+b;g[a+136>>2]=b;return}function rr(a){a=a|0;return+(+g[a+136>>2])}function sr(a){a=a|0;g[a+136>>2]=+O(+(+g[(c[a+48>>2]|0)+16>>2]*+g[(c[a+52>>2]|0)+16>>2]));return}function tr(a,b){a=a|0;b=+b;g[a+140>>2]=b;return}function ur(a){a=a|0;return+(+g[a+140>>2])}function vr(a){a=a|0;var b=0.0,d=0.0;d=+g[(c[a+48>>2]|0)+20>>2];b=+g[(c[a+52>>2]|0)+20>>2];g[a+140>>2]=d>b?d:b;return}function wr(a,b){a=a|0;b=+b;g[a+144>>2]=b;return}function xr(a){a=a|0;return+(+g[a+144>>2])}function yr(a){a=a|0;return c[a+4>>2]|0}function zr(a){a=a|0;var b=0;b=i;a=nb[c[(c[a>>2]|0)+12>>2]&63](a)|0;i=b;return a|0}function Ar(a,b,d){a=a|0;b=b|0;d=d|0;var e=0;e=i;a=gb[c[(c[a>>2]|0)+16>>2]&63](a,b,d)|0;i=e;return a|0}function Br(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0;g=i;a=ub[c[(c[a>>2]|0)+20>>2]&63](a,b,d,e,f)|0;i=g;return a|0}function Cr(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0;f=i;vb[c[(c[a>>2]|0)+24>>2]&63](a,b,d,e);i=f;return}function Dr(a,b,d){a=a|0;b=b|0;d=+d;var e=0;e=i;rb[c[(c[a>>2]|0)+28>>2]&63](a,b,d);i=e;return}function Er(a){a=a|0;return c[a+4>>2]|0}function Fr(a,b){a=a|0;b=b|0;c[a+4>>2]=b;return}function Gr(a){a=a|0;return+(+g[a+8>>2])}function Hr(a,b){a=a|0;b=+b;g[a+8>>2]=b;return}function Ir(a){a=a|0;var b=0;b=i;if(!a){i=b;return}jb[c[(c[a>>2]|0)+4>>2]&127](a);i=b;return}function Jr(){var b=0,d=0,e=0,f=0;b=i;d=NB(48)|0;a:do if(!d){while(1){d=c[4582]|0;c[4582]=d+0;if(!d)break;qb[d&63]();d=NB(48)|0;if(d)break a}d=cb(4)|0;c[d>>2]=18168;_a(d|0,18216,116)}while(0);c[d+0>>2]=0;c[d+4>>2]=0;c[d+8>>2]=0;c[d+12>>2]=0;a[d+16>>0]=0;c[d>>2]=3;f=d+20|0;e=d+36|0;c[f+0>>2]=0;c[f+4>>2]=0;c[f+8>>2]=0;c[f+12>>2]=0;g[e>>2]=1.0;g[d+40>>2]=0.0;g[d+44>>2]=0.0;i=b;return d|0}function Kr(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var h=0,j=0.0,k=0.0,l=0,m=0.0,n=0.0,o=0.0;h=i;c[a+8>>2]=b;c[a+12>>2]=d;o=+g[e>>2]- +g[b+12>>2];l=e+4|0;k=+g[l>>2]- +g[b+16>>2];j=+g[b+24>>2];m=+g[b+20>>2];n=+(o*j+k*m);m=+(j*k-o*m);b=a+20|0;g[b>>2]=n;g[b+4>>2]=m;m=+g[f>>2]- +g[d+12>>2];b=f+4|0;n=+g[b>>2]- +g[d+16>>2];o=+g[d+24>>2];k=+g[d+20>>2];j=+(m*o+n*k);k=+(o*n-m*k);d=a+28|0;g[d>>2]=j;g[d+4>>2]=k;k=+g[f>>2]- +g[e>>2];j=+g[b>>2]- +g[l>>2];g[a+36>>2]=+O(+(k*k+j*j));i=h;return}function Lr(a){a=a|0;return a+20|0}function Mr(a,b){a=a|0;b=b|0;var d=0,e=0;e=b;d=c[e+4>>2]|0;b=a+20|0;c[b>>2]=c[e>>2];c[b+4>>2]=d;return}function Nr(a){a=a|0;return a+28|0}function Or(a,b){a=a|0;b=b|0;var d=0,e=0;e=b;d=c[e+4>>2]|0;b=a+28|0;c[b>>2]=c[e>>2];c[b+4>>2]=d;return}function Pr(a){a=a|0;return+(+g[a+36>>2])}function Qr(a,b){a=a|0;b=+b;g[a+36>>2]=b;return}function Rr(a){a=a|0;return+(+g[a+40>>2])}function Sr(a,b){a=a|0;b=+b;g[a+40>>2]=b;return}function Tr(a){a=a|0;return+(+g[a+44>>2])}function Ur(a,b){a=a|0;b=+b;g[a+44>>2]=b;return}function Vr(a){a=a|0;return c[a>>2]|0}function Wr(a,b){a=a|0;b=b|0;c[a>>2]=b;return}function Xr(a){a=a|0;return c[a+4>>2]|0}function Yr(a,b){a=a|0;b=b|0;c[a+4>>2]=b;return}function Zr(a){a=a|0;return c[a+8>>2]|0}function _r(a,b){a=a|0;b=b|0;c[a+8>>2]=b;return}function $r(a){a=a|0;return c[a+12>>2]|0}function as(a,b){a=a|0;b=b|0;c[a+12>>2]=b;return}function bs(b){b=b|0;return(a[b+16>>0]|0)!=0|0}function cs(b,c){b=b|0;c=c|0;a[b+16>>0]=c&1;return}function ds(a){a=a|0;var b=0;b=i;if(a)OB(a);i=b;return}function es(a,b){a=a|0;b=b|0;var c=0;c=i;a=Sx(a,b)|0;i=c;return a|0}function fs(d,e,f){d=d|0;e=e|0;f=+f;var h=0,j=0;h=i;i=i+32|0;j=h;b[j+22>>1]=1;b[j+24>>1]=-1;b[j+26>>1]=0;c[j+4>>2]=0;g[j+8>>2]=.20000000298023224;g[j+12>>2]=0.0;a[j+20>>0]=0;c[j>>2]=e;g[j+16>>2]=f;e=Sx(d,j)|0;i=h;return e|0}function gs(d,e){d=d|0;e=e|0;var f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0;f=i;j=d+88|0;if(c[(c[j>>2]|0)+102868>>2]&2)Aa(8888,8624,216,8944);h=e+8|0;if((c[h>>2]|0)!=(d|0))Aa(8960,8624,222,8944);g=d+104|0;if((c[g>>2]|0)<=0)Aa(8984,8624,225,8944);o=d+100|0;n=c[o>>2]|0;if(!n)Aa(9008,8624,241,8944);else{m=n;k=o}while(1){n=m+4|0;if((m|0)==(e|0))break;m=c[n>>2]|0;if(!m){l=11;break}else k=n}if((l|0)==11)Aa(9008,8624,241,8944);l=e+4|0;c[k>>2]=c[l>>2];k=c[d+112>>2]|0;if(k)do{m=c[k+4>>2]|0;k=c[k+12>>2]|0;if((c[m+48>>2]|0)==(e|0)?1:(c[m+52>>2]|0)==(e|0))Xx((c[j>>2]|0)+102872|0,m)}while((k|0)!=0);j=c[j>>2]|0;if(b[d+4>>1]&32)ly(e,j+102872|0);jy(e,j);c[h>>2]=0;c[l>>2]=0;h=a[7572]|0;if((h&255)<14){o=j+((h&255)<<2)+12|0;c[e>>2]=c[o>>2];c[o>>2]=e;c[g>>2]=(c[g>>2]|0)+ -1;Qx(d);i=f;return}else Aa(8296,8208,171,8568)}function hs(a,b,d){a=a|0;b=b|0;d=+d;var e=0,f=0,h=0,j=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0,q=0;e=i;h=c[a+88>>2]|0;if(c[h+102868>>2]&2)Aa(8888,8624,419,9096);f=a+12|0;n=+R(+d);g[a+20>>2]=n;m=+Q(+d);g[a+24>>2]=m;p=c[b>>2]|0;b=c[b+4>>2]|0;q=f;c[q>>2]=p;c[q+4>>2]=b;o=+g[a+28>>2];j=+g[a+32>>2];l=(c[k>>2]=p,+g[k>>2])+(m*o-n*j);j=o*n+m*j+(c[k>>2]=b,+g[k>>2]);l=+l;j=+j;b=a+44|0;g[b>>2]=l;g[b+4>>2]=j;g[a+56>>2]=d;b=a+36|0;g[b>>2]=l;g[b+4>>2]=j;g[a+52>>2]=d;h=h+102872|0;a=c[a+100>>2]|0;if(!a){i=e;return}do{my(a,h,f,f);a=c[a+4>>2]|0}while((a|0)!=0);i=e;return}function is(a){a=a|0;return a+12|0}function js(a){a=a|0;return a+12|0}function ks(a){a=a|0;return+(+g[a+56>>2])}function ls(a){a=a|0;return a+44|0}function ms(a){a=a|0;return a+28|0}function ns(a,d){a=a|0;d=d|0;var f=0,h=0,j=0,k=0.0,l=0.0;f=i;if(!(c[a>>2]|0)){i=f;return}l=+g[d>>2];k=+g[d+4>>2];if(l*l+k*k>0.0?(j=a+4|0,h=e[j>>1]|0,(h&2|0)==0):0){b[j>>1]=h|2;g[a+144>>2]=0.0}h=d;j=c[h+4>>2]|0;d=a+64|0;c[d>>2]=c[h>>2];c[d+4>>2]=j;i=f;return}function os(b){b=b|0;var d=0,e=0,f=0;d=i;if((a[704]|0)==0?(wa(704)|0)!=0:0)Da(704);f=b+64|0;e=c[f+4>>2]|0;b=696;c[b>>2]=c[f>>2];c[b+4>>2]=e;i=d;return 696}function ps(a,d){a=a|0;d=+d;var f=0,h=0,j=0;f=i;if(!(c[a>>2]|0)){i=f;return}if(d*d>0.0?(j=a+4|0,h=e[j>>1]|0,(h&2|0)==0):0){b[j>>1]=h|2;g[a+144>>2]=0.0}g[a+72>>2]=d;i=f;return}function qs(a){a=a|0;return+(+g[a+72>>2])}function rs(a,d,e,f){a=a|0;d=d|0;e=e|0;f=f|0;var h=0,j=0,k=0,l=0;h=i;if((c[a>>2]|0)!=2){i=h;return}k=a+4|0;l=b[k>>1]|0;if((f?(l&2)==0:0)?(j=l&65535,(j&2|0)==0):0){l=(j|2)&65535;b[k>>1]=l;g[a+144>>2]=0.0}if(!(l&2)){i=h;return}k=a+76|0;g[k>>2]=+g[d>>2]+ +g[k>>2];k=d+4|0;l=a+80|0;g[l>>2]=+g[k>>2]+ +g[l>>2];l=a+84|0;g[l>>2]=+g[l>>2]+((+g[e>>2]- +g[a+44>>2])*+g[k>>2]-(+g[e+4>>2]- +g[a+48>>2])*+g[d>>2]);i=h;return}function ss(a,d,e){a=a|0;d=d|0;e=e|0;var f=0,h=0,j=0,k=0;f=i;if((c[a>>2]|0)!=2){i=f;return}j=a+4|0;k=b[j>>1]|0;if((e?(k&2)==0:0)?(h=k&65535,(h&2|0)==0):0){k=(h|2)&65535;b[j>>1]=k;g[a+144>>2]=0.0}if(!(k&2)){i=f;return}k=a+76|0;g[k>>2]=+g[d>>2]+ +g[k>>2];k=a+80|0;g[k>>2]=+g[d+4>>2]+ +g[k>>2];i=f;return}function ts(a,d,e){a=a|0;d=+d;e=e|0;var f=0,h=0,j=0,k=0;f=i;if((c[a>>2]|0)!=2){i=f;return}j=a+4|0;k=b[j>>1]|0;if((e?(k&2)==0:0)?(h=k&65535,(h&2|0)==0):0){k=(h|2)&65535;b[j>>1]=k;g[a+144>>2]=0.0}if(!(k&2)){i=f;return}k=a+84|0;g[k>>2]=+g[k>>2]+d;i=f;return}function us(a,d,e,f){a=a|0;d=d|0;e=e|0;f=f|0;var h=0,j=0,k=0,l=0,m=0.0,n=0.0;h=i;if((c[a>>2]|0)!=2){i=h;return}k=a+4|0;l=b[k>>1]|0;if((f?(l&2)==0:0)?(j=l&65535,(j&2|0)==0):0){l=(j|2)&65535;b[k>>1]=l;g[a+144>>2]=0.0}if(!(l&2)){i=h;return}n=+g[a+120>>2];k=d+4|0;m=n*+g[k>>2];l=a+64|0;g[l>>2]=n*+g[d>>2]+ +g[l>>2];l=a+68|0;g[l>>2]=m+ +g[l>>2];l=a+72|0;g[l>>2]=+g[l>>2]+ +g[a+128>>2]*((+g[e>>2]- +g[a+44>>2])*+g[k>>2]-(+g[e+4>>2]- +g[a+48>>2])*+g[d>>2]);i=h;return}function vs(a,d,e){a=a|0;d=+d;e=e|0;var f=0,h=0,j=0,k=0;f=i;if((c[a>>2]|0)!=2){i=f;return}j=a+4|0;k=b[j>>1]|0;if((e?(k&2)==0:0)?(h=k&65535,(h&2|0)==0):0){k=(h|2)&65535;b[j>>1]=k;g[a+144>>2]=0.0}if(!(k&2)){i=f;return}k=a+72|0;g[k>>2]=+g[k>>2]+ +g[a+128>>2]*d;i=f;return}function ws(a){a=a|0;return+(+g[a+116>>2])}function xs(a){a=a|0;var b=0.0,c=0.0;c=+g[a+28>>2];b=+g[a+32>>2];return+(+g[a+124>>2]+ +g[a+116>>2]*(c*c+b*b))}function ys(a,b){a=a|0;b=b|0;var d=0,e=0,f=0.0,h=0.0;d=a+116|0;g[b>>2]=+g[d>>2];e=a+28|0;h=+g[e>>2];f=+g[a+32>>2];g[b+12>>2]=+g[a+124>>2]+ +g[d>>2]*(h*h+f*f);d=c[e+4>>2]|0;a=b+4|0;c[a>>2]=c[e>>2];c[a+4>>2]=d;return}function zs(a,d){a=a|0;d=d|0;var e=0,f=0,h=0,j=0.0,l=0.0,m=0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0;e=i;if(c[(c[a+88>>2]|0)+102868>>2]&2)Aa(8888,8624,355,9080);if((c[a>>2]|0)!=2){i=e;return}m=a+120|0;g[m>>2]=0.0;h=a+124|0;g[h>>2]=0.0;f=a+128|0;g[f>>2]=0.0;j=+g[d>>2];j=!(j<=0.0)?j:1.0;g[a+116>>2]=j;g[m>>2]=1.0/j;l=+g[d+12>>2];do if(l>0.0?(b[a+4>>1]&16)==0:0){o=+g[d+4>>2];n=+g[d+8>>2];j=l-j*(o*o+n*n);g[h>>2]=j;if(j>0.0){g[f>>2]=1.0/j;break}else Aa(9064,8624,381,9080)}while(0);m=a+44|0;h=m;o=+g[h>>2];j=+g[h+4>>2];h=d+4|0;f=c[h>>2]|0;h=c[h+4>>2]|0;d=a+28|0;c[d>>2]=f;c[d+4>>2]=h;q=+g[a+24>>2];r=(c[k>>2]=f,+g[k>>2]);l=+g[a+20>>2];p=(c[k>>2]=h,+g[k>>2]);n=+g[a+12>>2]+(q*r-l*p);p=r*l+q*p+ +g[a+16>>2];q=+n;l=+p;g[m>>2]=q;g[m+4>>2]=l;m=a+36|0;g[m>>2]=q;g[m+4>>2]=l;l=+g[a+72>>2];m=a+64|0;g[m>>2]=+g[m>>2]-l*(p-j);m=a+68|0;g[m>>2]=l*(n-o)+ +g[m>>2];i=e;return}function As(a){a=a|0;var b=0;b=i;Qx(a);i=b;return}function Bs(b,c){b=b|0;c=c|0;var d=0,e=0.0,f=0.0,h=0.0,j=0.0,k=0.0;d=i;if((a[720]|0)==0?(wa(720)|0)!=0:0)Da(720);h=+g[b+24>>2];k=+g[c>>2];j=+g[b+20>>2];e=+g[c+4>>2];f=+(+g[b+12>>2]+(h*k-j*e));e=+(k*j+h*e+ +g[b+16>>2]);c=712;g[c>>2]=f;g[c+4>>2]=e;i=d;return 712}function Cs(b,c){b=b|0;c=c|0;var d=0,e=0.0,f=0.0,h=0.0,j=0.0,k=0.0;d=i;if((a[736]|0)==0?(wa(736)|0)!=0:0)Da(736);h=+g[b+24>>2];k=+g[c>>2];j=+g[b+20>>2];e=+g[c+4>>2];f=+(h*k-j*e);e=+(k*j+h*e);c=728;g[c>>2]=f;g[c+4>>2]=e;i=d;return 728}function Ds(b,c){b=b|0;c=c|0;var d=0,e=0.0,f=0.0,h=0.0,j=0.0,k=0.0;d=i;if((a[752]|0)==0?(wa(752)|0)!=0:0)Da(752);h=+g[c>>2]- +g[b+12>>2];j=+g[c+4>>2]- +g[b+16>>2];k=+g[b+24>>2];e=+g[b+20>>2];f=+(h*k+j*e);e=+(k*j-h*e);b=744;g[b>>2]=f;g[b+4>>2]=e;i=d;return 744}function Es(b,c){b=b|0;c=c|0;var d=0,e=0.0,f=0.0,h=0.0,j=0.0,k=0.0;d=i;if((a[768]|0)==0?(wa(768)|0)!=0:0)Da(768);k=+g[b+24>>2];h=+g[c>>2];e=+g[b+20>>2];j=+g[c+4>>2];f=+(k*h+e*j);e=+(k*j-h*e);c=760;g[c>>2]=f;g[c+4>>2]=e;i=d;return 760}function Fs(b,c){b=b|0;c=c|0;var d=0,e=0.0,f=0.0;d=i;if((a[784]|0)==0?(wa(784)|0)!=0:0)Da(784);e=+g[b+72>>2];f=+(+g[b+64>>2]-e*(+g[c+4>>2]- +g[b+48>>2]));e=+(e*(+g[c>>2]- +g[b+44>>2])+ +g[b+68>>2]);c=776;g[c>>2]=f;g[c+4>>2]=e;i=d;return 776}function Gs(b,c){b=b|0;c=c|0;var d=0,e=0.0,f=0.0,h=0.0,j=0.0,k=0.0,l=0.0;d=i;if((a[800]|0)==0?(wa(800)|0)!=0:0)Da(800);k=+g[b+24>>2];j=+g[c>>2];h=+g[b+20>>2];e=+g[c+4>>2];l=+g[b+72>>2];f=+(+g[b+64>>2]-l*(j*h+k*e+ +g[b+16>>2]- +g[b+48>>2]));e=+(l*(+g[b+12>>2]+(k*j-h*e)- +g[b+44>>2])+ +g[b+68>>2]);c=792;g[c>>2]=f;g[c+4>>2]=e;i=d;return 792}function Hs(a){a=a|0;return+(+g[a+132>>2])}function Is(a,b){a=a|0;b=+b;g[a+132>>2]=b;return}function Js(a){a=a|0;return+(+g[a+136>>2])}function Ks(a,b){a=a|0;b=+b;g[a+136>>2]=b;return}function Ls(a){a=a|0;return+(+g[a+140>>2])}function Ms(a,b){a=a|0;b=+b;g[a+140>>2]=b;return}function Ns(a,d){a=a|0;d=d|0;var f=0,h=0,j=0,l=0,m=0,n=0,o=0,p=0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0;f=i;i=i+16|0;l=f;h=a+88|0;if(c[(c[h>>2]|0)+102868>>2]&2)Aa(8888,8624,115,8920);if((c[a>>2]|0)==(d|0)){i=f;return}c[a>>2]=d;Qx(a);if((c[a>>2]|0)==0?(g[a+64>>2]=0.0,g[a+68>>2]=0.0,g[a+72>>2]=0.0,s=+g[a+56>>2],g[a+52>>2]=s,j=a+44|0,m=c[j>>2]|0,j=c[j+4>>2]|0,p=a+36|0,c[p>>2]=m,c[p+4>>2]=j,t=+R(+s),g[l+8>>2]=t,s=+Q(+s),g[l+12>>2]=s,u=+g[a+28>>2],q=+g[a+32>>2],r=(c[k>>2]=m,+g[k>>2])-(s*u-t*q),q=(c[k>>2]=j,+g[k>>2])-(u*t+s*q),r=+r,q=+q,j=l,g[j>>2]=r,g[j+4>>2]=q,j=(c[h>>2]|0)+102872|0,m=c[a+100>>2]|0,(m|0)!=0):0){d=a+12|0;do{my(m,j,l,d);m=c[m+4>>2]|0}while((m|0)!=0)}l=a+4|0;j=e[l>>1]|0;if(!(j&2)){b[l>>1]=j|2;g[a+144>>2]=0.0}g[a+76>>2]=0.0;g[a+80>>2]=0.0;g[a+84>>2]=0.0;j=a+112|0;l=c[j>>2]|0;if(l)do{p=l;l=c[l+12>>2]|0;Xx((c[h>>2]|0)+102872|0,c[p+4>>2]|0)}while((l|0)!=0);c[j>>2]=0;j=c[h>>2]|0;n=c[a+100>>2]|0;if(!n){i=f;return}h=j+102912|0;a=j+102908|0;j=j+102904|0;do{o=c[n+28>>2]|0;if((o|0)>0){d=n+24|0;p=c[h>>2]|0;l=0;do{m=c[(c[d>>2]|0)+(l*28|0)+24>>2]|0;if((p|0)==(c[a>>2]|0)){v=c[j>>2]|0;c[a>>2]=p<<1;p=NB(p<<3)|0;c[j>>2]=p;SB(p|0,v|0,c[h>>2]<<2|0)|0;OB(v);p=c[h>>2]|0}c[(c[j>>2]|0)+(p<<2)>>2]=m;p=(c[h>>2]|0)+1|0;c[h>>2]=p;l=l+1|0}while((l|0)!=(o|0))}n=c[n+4>>2]|0}while((n|0)!=0);i=f;return}function Os(a){a=a|0;return c[a>>2]|0}function Ps(a,c){a=a|0;c=c|0;var d=0;a=a+4|0;d=e[a>>1]|0;b[a>>1]=c?d|8:d&65527;return}function Qs(a){a=a|0;return(b[a+4>>1]&8)!=0|0}function Rs(a,c){a=a|0;c=c|0;var d=0,f=0,h=0;d=i;f=a+4|0;h=e[f>>1]|0;if(c){b[f>>1]=h|4;i=d;return}c=h&65531;b[f>>1]=c;if(h&2){i=d;return}b[f>>1]=c|2;g[a+144>>2]=0.0;i=d;return}function Ss(a){a=a|0;return(b[a+4>>1]&4)!=0|0}function Ts(a,d){a=a|0;d=d|0;var f=0,h=0,j=0;f=i;h=a+4|0;j=e[h>>1]|0;if(!d){b[h>>1]=j&65533;g[a+144>>2]=0.0;d=a+64|0;c[d+0>>2]=0;c[d+4>>2]=0;c[d+8>>2]=0;c[d+12>>2]=0;c[d+16>>2]=0;c[d+20>>2]=0;i=f;return}if(j&2){i=f;return}b[h>>1]=j|2;g[a+144>>2]=0.0;i=f;return}function Us(a){a=a|0;return(b[a+4>>1]&2)!=0|0} function uy(f,h,j,l){f=f|0;h=+h;j=j|0;l=l|0;var m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0.0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,N=0,P=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0,oa=0,pa=0,qa=0,ra=0,sa=0,ta=0,ua=0,va=0,wa=0,xa=0,ya=0,za=0,Ba=0,Ca=0,Da=0,Ea=0,Fa=0,Ga=0,Ha=0,Ia=0,Ja=0,Ka=0,La=0,Ma=0,Na=0,Oa=0,Pa=0,Qa=0,Ra=0,Sa=0,Ta=0,Ua=0,Va=0,Wa=0,Xa=0,Ya=0,Za=0,_a=0,$a=0,ab=0,bb=0,cb=0,db=0,eb=0,fb=0,hb=0,ib=0,jb=0,kb=0,mb=0,nb=0,ob=0,pb=0,qb=0,rb=0,sb=0,ub=0,vb=0,wb=0,xb=0,yb=0,zb=0,Ab=0,Bb=0,Cb=0,Db=0,Eb=0,Fb=0,Gb=0,Hb=0,Ib=0,Jb=0,Kb=0.0,Lb=0,Mb=0.0,Nb=0.0,Ob=0,Pb=0.0,Qb=0.0,Rb=0.0,Sb=0.0,Tb=0.0,Ub=0.0,Vb=0.0,Wb=0.0,Xb=0.0,Yb=0.0,Zb=0.0,_b=0.0,$b=0.0,ac=0.0,bc=0.0,cc=0.0,dc=0.0,ec=0.0,fc=0.0,gc=0.0,hc=0.0,ic=0,jc=0.0,kc=0.0,lc=0.0,mc=0.0,nc=0.0,oc=0.0,pc=0.0,qc=0.0,rc=0.0,sc=0,tc=0,uc=0,vc=0,wc=0,xc=0,yc=0,zc=0,Ac=0,Bc=0,Cc=0.0,Dc=0.0,Ec=0.0,Fc=0.0,Gc=0,Hc=0,Ic=0.0,Jc=0.0,Kc=0,Lc=0.0,Mc=0.0,Nc=0,Oc=0,Pc=0,Qc=0,Rc=0,Sc=0,Tc=0.0;m=i;i=i+608|0;p=m;q=m+16|0;r=m+112|0;x=m+236|0;y=m+404|0;o=m+136|0;z=m+536|0;t=m+456|0;u=m+492|0;s=m+528|0;v=m+368|0;w=m+591|0;J=m+588|0;n=f+102868|0;C=c[n>>2]|0;if(C&1){Yx(f+102872|0);C=c[n>>2]&-2;c[n>>2]=C}c[n>>2]=C|2;C=h>0.0;if(C)D=1.0/h;else D=0.0;G=f+102988|0;Kb=+g[G>>2]*h;K=a[f+102992>>0]|0;E=f+102872|0;F=f+102932|0;S=c[F>>2]|0;a:do if(S){H=f+102884|0;L=f+102876|0;P=f+102944|0;N=f+102940|0;b:while(1){W=c[S+48>>2]|0;U=c[S+52>>2]|0;V=c[S+56>>2]|0;T=c[S+60>>2]|0;Z=c[W+8>>2]|0;X=c[U+8>>2]|0;Y=S+4|0;$=c[Y>>2]|0;c:do if(!($&8))B=16;else{if(!(Tx(X,Z)|0)){Sc=c[S+12>>2]|0;Xx(E,S);S=Sc;break}_=c[N>>2]|0;do if(_)if(gb[c[(c[_>>2]|0)+8>>2]&63](_,W,U)|0){$=c[Y>>2]|0;break}else{Sc=c[S+12>>2]|0;Xx(E,S);S=Sc;break c}while(0);c[Y>>2]=$&-9;B=16}while(0);do if((B|0)==16){B=0;if(!(b[Z+4>>1]&2))Y=0;else Y=(c[Z>>2]|0)!=0;if(!(b[X+4>>1]&2))X=0;else X=(c[X>>2]|0)!=0;if(!(Y|X)){S=c[S+12>>2]|0;break}V=c[(c[W+24>>2]|0)+(V*28|0)+24>>2]|0;U=c[(c[U+24>>2]|0)+(T*28|0)+24>>2]|0;if((V|0)<=-1){B=24;break b}W=c[H>>2]|0;if((W|0)<=(V|0)){B=24;break b}T=c[L>>2]|0;if(!((U|0)>-1&(W|0)>(U|0))){B=26;break b}if((+g[T+(U*36|0)>>2]- +g[T+(V*36|0)+8>>2]>0.0?1:+g[T+(U*36|0)+4>>2]- +g[T+(V*36|0)+12>>2]>0.0)|+g[T+(V*36|0)>>2]- +g[T+(U*36|0)+8>>2]>0.0|+g[T+(V*36|0)+4>>2]- +g[T+(U*36|0)+12>>2]>0.0){Sc=c[S+12>>2]|0;Xx(E,S);S=Sc;break}else{My(S,c[P>>2]|0);S=c[S+12>>2]|0;break}}while(0);if(!S)break a}if((B|0)==24)Aa(11792,11736,164,11856);else if((B|0)==26)Aa(11792,11736,164,11856)}while(0);g[f+103e3>>2]=0.0;H=f+102995|0;if(!((a[H>>0]|0)==0|C^1)){L=f+103008|0;g[L>>2]=0.0;N=f+103012|0;g[N>>2]=0.0;P=f+103016|0;g[P>>2]=0.0;U=f+102960|0;S=f+68|0;oy(z,c[U>>2]|0,c[f+102936>>2]|0,c[f+102964>>2]|0,S,c[f+102944>>2]|0);T=f+102952|0;V=c[T>>2]|0;if(V)do{Sc=V+4|0;b[Sc>>1]=e[Sc>>1]&65534;V=c[V+96>>2]|0}while((V|0)!=0);V=c[F>>2]|0;if(V)do{Sc=V+4|0;c[Sc>>2]=c[Sc>>2]&-2;V=c[V+12>>2]|0}while((V|0)!=0);V=c[f+102956>>2]|0;if(V)do{a[V+60>>0]=0;V=c[V+12>>2]|0}while((V|0)!=0);Oa=c[U>>2]|0;Na=Ox(S,Oa<<2)|0;Qa=c[T>>2]|0;d:do if(Qa){Ka=z+28|0;Y=z+36|0;Ja=z+32|0;La=f+102976|0;Ga=z+8|0;Ha=z+48|0;Ia=z+16|0;ca=f+102968|0;da=f+102972|0;wa=z+20|0;Fa=z+24|0;ta=x+4|0;qa=x+8|0;na=x+12|0;ma=x+16|0;la=x+20|0;ka=x+21|0;ja=x+24|0;ea=x+28|0;ua=y+4|0;ga=y+8|0;Da=y+12|0;Ea=y+16|0;Ma=y+20|0;V=y+21|0;W=z+12|0;X=y+24|0;Z=y+28|0;_=y+32|0;$=y+36|0;aa=y+40|0;ba=K<<24>>24==0;ia=(j|0)>0;Pa=o+48|0;ha=o+40|0;oa=o+44|0;pa=(l|0)>0;sa=o+36|0;ra=o+24|0;U=p+8|0;va=p+12|0;xa=q+8|0;ya=q+12|0;za=r+8|0;Ba=r+16|0;Ca=o+32|0;fa=o+28|0;e:while(1){Ra=Qa+4|0;Sa=b[Ra>>1]|0;do if((Sa&35)==34?(c[Qa>>2]|0)!=0:0){c[Ka>>2]=0;c[Y>>2]=0;c[Ja>>2]=0;c[Na>>2]=Qa;b[Ra>>1]=Sa&65535|1;Ta=1;do{Ta=Ta+ -1|0;Ra=c[Na+(Ta<<2)>>2]|0;Ua=Ra+4|0;if(!(b[Ua>>1]&32)){B=43;break e}sy(z,Ra);Sa=e[Ua>>1]|0;if(!(Sa&2)){b[Ua>>1]=Sa|2;g[Ra+144>>2]=0.0}do if(c[Ra>>2]|0){Sa=c[Ra+112>>2]|0;if(Sa)do{Ua=c[Sa+4>>2]|0;Va=Ua+4|0;do if((c[Va>>2]&7|0)==6){if(a[(c[Ua+48>>2]|0)+38>>0]|0)break;if(a[(c[Ua+52>>2]|0)+38>>0]|0)break;ty(z,Ua);c[Va>>2]=c[Va>>2]|1;Ua=c[Sa>>2]|0;Va=Ua+4|0;Wa=b[Va>>1]|0;if(Wa&1)break;if((Ta|0)>=(Oa|0)){B=54;break e}c[Na+(Ta<<2)>>2]=Ua;b[Va>>1]=Wa&65535|1;Ta=Ta+1|0}while(0);Sa=c[Sa+12>>2]|0}while((Sa|0)!=0);Ra=c[Ra+108>>2]|0;if(!Ra)break;do{Va=Ra+4|0;Sa=c[Va>>2]|0;do if(!(a[Sa+60>>0]|0)){Wa=c[Ra>>2]|0;Ya=Wa+4|0;Xa=b[Ya>>1]|0;if(!(Xa&32))break;Ua=c[Ja>>2]|0;if((Ua|0)>=(c[Ha>>2]|0)){B=61;break e}c[Ja>>2]=Ua+1;c[(c[Ia>>2]|0)+(Ua<<2)>>2]=Sa;a[(c[Va>>2]|0)+60>>0]=1;if(Xa&1)break;if((Ta|0)>=(Oa|0)){B=64;break e}c[Na+(Ta<<2)>>2]=Wa;b[Ya>>1]=Xa&65535|1;Ta=Ta+1|0}while(0);Ra=c[Ra+12>>2]|0}while((Ra|0)!=0)}while(0)}while((Ta|0)>0);Ra=(a[La>>0]|0)==0;Sa=c[Ka>>2]|0;Va=(Sa|0)>0;if(Va){Wa=c[Ga>>2]|0;Xa=0;do{Ta=c[Wa+(Xa<<2)>>2]|0;Ua=Ta+44|0;Ya=c[Ua>>2]|0;Ua=c[Ua+4>>2]|0;Nb=+g[Ta+56>>2];Sc=Ta+64|0;Mb=+g[Sc>>2];Pb=+g[Sc+4>>2];Qb=+g[Ta+72>>2];Sc=Ta+36|0;c[Sc>>2]=Ya;c[Sc+4>>2]=Ua;g[Ta+52>>2]=Nb;if((c[Ta>>2]|0)==2){Jc=+g[Ta+140>>2];Lc=+g[Ta+120>>2];Mc=1.0/(+g[Ta+132>>2]*h+1.0);Mb=(Mb+(Jc*+g[ca>>2]+Lc*+g[Ta+76>>2])*h)*Mc;Pb=(Pb+(Jc*+g[da>>2]+Lc*+g[Ta+80>>2])*h)*Mc;Qb=(Qb+ +g[Ta+128>>2]*h*+g[Ta+84>>2])*(1.0/(+g[Ta+136>>2]*h+1.0))}Ta=c[wa>>2]|0;Sc=Ta+(Xa*12|0)|0;c[Sc>>2]=Ya;c[Sc+4>>2]=Ua;g[Ta+(Xa*12|0)+8>>2]=Nb;Ua=c[Fa>>2]|0;Lc=+Mb;Mc=+Pb;Sc=Ua+(Xa*12|0)|0;g[Sc>>2]=Lc;g[Sc+4>>2]=Mc;g[Ua+(Xa*12|0)+8>>2]=Qb;Xa=Xa+1|0}while((Xa|0)<(Sa|0))}else{Ua=c[Fa>>2]|0;Ta=c[wa>>2]|0}g[x>>2]=h;g[ta>>2]=D;g[qa>>2]=Kb;c[na>>2]=j;c[ma>>2]=l;a[la>>0]=K;a[ka+0>>0]=a[J+0>>0]|0;a[ka+1>>0]=a[J+1>>0]|0;a[ka+2>>0]=a[J+2>>0]|0;c[ja>>2]=Ta;c[ea>>2]=Ua;g[y>>2]=h;g[ua>>2]=D;g[ga>>2]=Kb;c[Da>>2]=j;c[Ea>>2]=l;a[Ma>>0]=K;a[V+0>>0]=a[J+0>>0]|0;a[V+1>>0]=a[J+1>>0]|0;a[V+2>>0]=a[J+2>>0]|0;c[X>>2]=c[W>>2];c[Z>>2]=c[Y>>2];c[_>>2]=Ta;c[$>>2]=Ua;c[aa>>2]=c[z>>2];Ny(o,y);Oy(o);if(!ba?(I=c[Pa>>2]|0,(I|0)>0):0){$a=c[fa>>2]|0;ab=c[ha>>2]|0;Wa=0;do{Ya=c[ab+(Wa*156|0)+112>>2]|0;_a=c[ab+(Wa*156|0)+116>>2]|0;Mb=+g[ab+(Wa*156|0)+120>>2];Sb=+g[ab+(Wa*156|0)+128>>2];Rb=+g[ab+(Wa*156|0)+124>>2];Qb=+g[ab+(Wa*156|0)+132>>2];bb=c[ab+(Wa*156|0)+148>>2]|0;Za=$a+(Ya*12|0)|0;Xa=Za;Ub=+g[Xa>>2];Wb=+g[Xa+4>>2];Ya=$a+(Ya*12|0)+8|0;Vb=+g[Ya>>2];Xa=$a+(_a*12|0)|0;Sc=Xa;Xb=+g[Sc>>2];Yb=+g[Sc+4>>2];_a=$a+(_a*12|0)+8|0;Tb=+g[_a>>2];Sc=ab+(Wa*156|0)+72|0;Pb=+g[Sc>>2];Nb=+g[Sc+4>>2];if((bb|0)>0){cb=0;do{Jc=+g[ab+(Wa*156|0)+(cb*36|0)+16>>2];Mc=+g[ab+(Wa*156|0)+(cb*36|0)+20>>2];Lc=Pb*Jc+Nb*Mc;Mc=Nb*Jc-Pb*Mc;Vb=Vb-Sb*(+g[ab+(Wa*156|0)+(cb*36|0)>>2]*Mc- +g[ab+(Wa*156|0)+(cb*36|0)+4>>2]*Lc);Ub=Ub-Mb*Lc;Wb=Wb-Mb*Mc;Tb=Tb+Qb*(Mc*+g[ab+(Wa*156|0)+(cb*36|0)+8>>2]-Lc*+g[ab+(Wa*156|0)+(cb*36|0)+12>>2]);Xb=Xb+Rb*Lc;Yb=Yb+Rb*Mc;cb=cb+1|0}while((cb|0)!=(bb|0))}Mc=+Ub;Lc=+Wb;Sc=Za;g[Sc>>2]=Mc;g[Sc+4>>2]=Lc;g[Ya>>2]=Vb;Lc=+Xb;Mc=+Yb;Sc=Xa;g[Sc>>2]=Lc;g[Sc+4>>2]=Mc;g[_a>>2]=Tb;Wa=Wa+1|0}while((Wa|0)<(I|0))}Wa=c[Ja>>2]|0;Xa=(Wa|0)>0;if(Xa){Za=c[Ia>>2]|0;Ya=0;do{Sc=c[Za+(Ya<<2)>>2]|0;lb[c[(c[Sc>>2]|0)+32>>2]&127](Sc,x);Ya=Ya+1|0}while((Ya|0)<(Wa|0))}if(ia){_a=0;do{if(Xa){Ya=c[Ia>>2]|0;Za=0;do{Sc=c[Ya+(Za<<2)>>2]|0;lb[c[(c[Sc>>2]|0)+36>>2]&127](Sc,x);Za=Za+1|0}while((Za|0)<(Wa|0))}Py(o);_a=_a+1|0}while((_a|0)<(j|0))}$a=c[Pa>>2]|0;if(($a|0)>0){_a=c[ha>>2]|0;Za=c[oa>>2]|0;Ya=0;do{ab=c[Za+(c[_a+(Ya*156|0)+152>>2]<<2)>>2]|0;Xa=c[_a+(Ya*156|0)+148>>2]|0;if((Xa|0)>0){Wa=0;do{g[ab+(Wa*20|0)+72>>2]=+g[_a+(Ya*156|0)+(Wa*36|0)+16>>2];g[ab+(Wa*20|0)+76>>2]=+g[_a+(Ya*156|0)+(Wa*36|0)+20>>2];Wa=Wa+1|0}while((Wa|0)<(Xa|0))}Ya=Ya+1|0}while((Ya|0)<($a|0))}if(Va){Va=0;do{Sa=Ta+(Va*12|0)|0;Sc=Sa;Mb=+g[Sc>>2];Nb=+g[Sc+4>>2];Pb=+g[Ta+(Va*12|0)+8>>2];Sc=Ua+(Va*12|0)|0;Qb=+g[Sc>>2];Sb=+g[Sc+4>>2];Rb=+g[Ua+(Va*12|0)+8>>2];Mc=Qb*h;Tb=Sb*h;Tb=Mc*Mc+Tb*Tb;if(Tb>4.0){Mc=2.0/+O(+Tb);Qb=Qb*Mc;Sb=Sb*Mc}Tb=Rb*h;if(Tb*Tb>2.4674012660980225){if(!(Tb>0.0))Tb=-Tb;Rb=Rb*(1.5707963705062866/Tb)}Mc=+(Mb+Qb*h);Lc=+(Nb+Sb*h);Ta=Sa;g[Ta>>2]=Mc;g[Ta+4>>2]=Lc;Ta=c[wa>>2]|0;g[Ta+(Va*12|0)+8>>2]=Pb+Rb*h;Ua=c[Fa>>2]|0;Lc=+Qb;Mc=+Sb;Sa=Ua+(Va*12|0)|0;g[Sa>>2]=Lc;g[Sa+4>>2]=Mc;g[Ua+(Va*12|0)+8>>2]=Rb;Va=Va+1|0;Sa=c[Ka>>2]|0}while((Va|0)<(Sa|0))}f:do if(pa){Wa=c[Pa>>2]|0;Va=0;while(1){if((Wa|0)>0){Xa=c[ra>>2]|0;_a=c[sa>>2]|0;Za=0;Wb=0.0;do{db=_a+(Za*88|0)|0;bb=c[_a+(Za*88|0)+32>>2]|0;$a=c[_a+(Za*88|0)+36>>2]|0;cb=_a+(Za*88|0)+48|0;Sb=+g[cb>>2];Tb=+g[cb+4>>2];Rb=+g[_a+(Za*88|0)+40>>2];Mb=+g[_a+(Za*88|0)+64>>2];cb=_a+(Za*88|0)+56|0;Ub=+g[cb>>2];Vb=+g[cb+4>>2];Pb=+g[_a+(Za*88|0)+44>>2];Qb=+g[_a+(Za*88|0)+68>>2];cb=c[_a+(Za*88|0)+84>>2]|0;Ya=Xa+(bb*12|0)|0;ab=Ya;Xb=+g[ab>>2];Yb=+g[ab+4>>2];bb=Xa+(bb*12|0)+8|0;ac=+g[bb>>2];ab=Xa+($a*12|0)|0;Sc=ab;Zb=+g[Sc>>2];_b=+g[Sc+4>>2];$a=Xa+($a*12|0)+8|0;$b=+g[$a>>2];if((cb|0)>0){Nb=Rb+Pb;eb=0;do{gc=+R(+ac);g[U>>2]=gc;hc=+Q(+ac);g[va>>2]=hc;fc=+R(+$b);g[xa>>2]=fc;cc=+Q(+$b);g[ya>>2]=cc;bc=+(Xb-(Sb*hc-Tb*gc));gc=+(Yb-(Tb*hc+Sb*gc));Sc=p;g[Sc>>2]=bc;g[Sc+4>>2]=gc;gc=+(Zb-(Ub*cc-Vb*fc));fc=+(_b-(Vb*cc+Ub*fc));Sc=q;g[Sc>>2]=gc;g[Sc+4>>2]=fc;Qy(r,db,p,q,eb);Sc=r;fc=+g[Sc>>2];gc=+g[Sc+4>>2];Sc=za;cc=+g[Sc>>2];bc=+g[Sc+4>>2];hc=+g[Ba>>2];ec=cc-Xb;dc=bc-Yb;cc=cc-Zb;bc=bc-_b;Wb=Wb0.0)hc=-(hc<-.20000000298023224?-.20000000298023224:hc)/jc;else hc=0.0;Mc=fc*hc;Lc=gc*hc;Xb=Xb-Rb*Mc;Yb=Yb-Rb*Lc;ac=ac-Mb*(ec*Lc-dc*Mc);Zb=Zb+Pb*Mc;_b=_b+Pb*Lc;$b=$b+Qb*(cc*Lc-bc*Mc);eb=eb+1|0}while((eb|0)!=(cb|0))}Mc=+Xb;Lc=+Yb;Sc=Ya;g[Sc>>2]=Mc;g[Sc+4>>2]=Lc;g[bb>>2]=ac;Lc=+Zb;Mc=+_b;Sc=ab;g[Sc>>2]=Lc;g[Sc+4>>2]=Mc;g[$a>>2]=$b;Za=Za+1|0}while((Za|0)<(Wa|0))}else Wb=0.0;Xa=Wb>=-.014999999664723873;Za=c[Ja>>2]|0;if((Za|0)>0){_a=c[Ia>>2]|0;Ya=0;$a=1;do{Sc=c[_a+(Ya<<2)>>2]|0;$a=$a&(tb[c[(c[Sc>>2]|0)+40>>2]&63](Sc,x)|0);Ya=Ya+1|0}while((Ya|0)<(Za|0))}else $a=1;Va=Va+1|0;if(Xa&$a){Va=0;break f}if((Va|0)>=(l|0)){Va=1;break}}}else Va=1;while(0);if((Sa|0)>0){Xa=c[Ga>>2]|0;Wa=0;do{Sc=c[Xa+(Wa<<2)>>2]|0;Rc=Ta+(Wa*12|0)|0;Qc=c[Rc>>2]|0;Rc=c[Rc+4>>2]|0;Nc=Sc+44|0;c[Nc>>2]=Qc;c[Nc+4>>2]=Rc;Jc=+g[Ta+(Wa*12|0)+8>>2];g[Sc+56>>2]=Jc;Nc=Ua+(Wa*12|0)|0;Oc=c[Nc+4>>2]|0;Pc=Sc+64|0;c[Pc>>2]=c[Nc>>2];c[Pc+4>>2]=Oc;g[Sc+72>>2]=+g[Ua+(Wa*12|0)+8>>2];Fc=+R(+Jc);g[Sc+20>>2]=Fc;Jc=+Q(+Jc);g[Sc+24>>2]=Jc;Ic=+g[Sc+28>>2];Mc=+g[Sc+32>>2];Lc=(c[k>>2]=Qc,+g[k>>2])-(Jc*Ic-Fc*Mc);Mc=(c[k>>2]=Rc,+g[k>>2])-(Fc*Ic+Jc*Mc);Lc=+Lc;Mc=+Mc;Sc=Sc+12|0;g[Sc>>2]=Lc;g[Sc+4>>2]=Mc;Wa=Wa+1|0}while((Wa|0)<(Sa|0))}Sa=c[ha>>2]|0;qy(z,Sa);do if(!Ra){Ra=c[Ka>>2]|0;if((Ra|0)<=0)break;Ta=c[Ga>>2]|0;Ua=0;Mb=3.4028234663852886e+38;do{Wa=c[Ta+(Ua<<2)>>2]|0;g:do if(c[Wa>>2]|0){do if(b[Wa+4>>1]&4){Mc=+g[Wa+72>>2];if(Mc*Mc>.001218469929881394)break;Lc=+g[Wa+64>>2];Mc=+g[Wa+68>>2];if(Lc*Lc+Mc*Mc>9999999747378752.0e-20)break;Sc=Wa+144|0;Mc=+g[Sc>>2]+h;g[Sc>>2]=Mc;Mb=Mb>2]=0.0;Mb=0.0}while(0);Ua=Ua+1|0}while((Ua|0)<(Ra|0));if(!(Mb>=.5)|Va)break;else Ua=0;do{Sc=c[Ta+(Ua<<2)>>2]|0;Rc=Sc+4|0;b[Rc>>1]=e[Rc>>1]&65533;g[Sc+144>>2]=0.0;Sc=Sc+64|0;c[Sc+0>>2]=0;c[Sc+4>>2]=0;c[Sc+8>>2]=0;c[Sc+12>>2]=0;c[Sc+16>>2]=0;c[Sc+20>>2]=0;Ua=Ua+1|0}while((Ua|0)<(Ra|0))}while(0);Ra=c[Ca>>2]|0;Px(Ra,Sa);Px(Ra,c[sa>>2]|0);g[L>>2]=+g[L>>2]+0.0;g[N>>2]=+g[N>>2]+0.0;g[P>>2]=+g[P>>2]+0.0;Ra=c[Ka>>2]|0;if((Ra|0)<=0)break;Sa=c[Ga>>2]|0;Ta=0;do{Ua=c[Sa+(Ta<<2)>>2]|0;if(!(c[Ua>>2]|0)){Sc=Ua+4|0;b[Sc>>1]=e[Sc>>1]&65534}Ta=Ta+1|0}while((Ta|0)<(Ra|0))}while(0);Qa=c[Qa+96>>2]|0;if(!Qa)break d}if((B|0)==43)Aa(11232,11088,445,11256);else if((B|0)==54)Aa(11264,11088,495,11256);else if((B|0)==61)Aa(11920,11952,68,11992);else if((B|0)==64)Aa(11264,11088,524,11256)}while(0);Px(S,Na);I=c[T>>2]|0;if(I)do{if((b[I+4>>1]&1)!=0?(c[I>>2]|0)!=0:0)Rx(I);I=c[I+96>>2]|0}while((I|0)!=0);Yx(E);g[f+103020>>2]=0.0;py(z);g[f+103004>>2]=0.0}if(a[f+102993>>0]|0){if(C){I=f+102944|0;oy(z,64,32,0,f+68|0,c[I>>2]|0);if(a[H>>0]|0){J=c[f+102952>>2]|0;if(J)do{Sc=J+4|0;b[Sc>>1]=e[Sc>>1]&65534;g[J+60>>2]=0.0;J=c[J+96>>2]|0}while((J|0)!=0);J=c[F>>2]|0;if(J)do{Sc=J+4|0;c[Sc>>2]=c[Sc>>2]&-34;c[J+128>>2]=0;g[J+132>>2]=1.0;J=c[J+12>>2]|0}while((J|0)!=0)}qa=z+28|0;pa=z+36|0;oa=z+32|0;na=s+4|0;ma=z+40|0;la=z+44|0;K=f+102994|0;ka=z+8|0;va=x+16|0;Ea=x+20|0;kb=x+24|0;Ba=x+44|0;Ca=x+48|0;jb=x+52|0;hb=x+28|0;ra=x+56|0;Gb=x+92|0;Fb=x+128|0;Eb=x+56|0;Db=x+60|0;Cb=x+64|0;Bb=x+68|0;Ab=x+72|0;zb=x+76|0;yb=x+80|0;nb=x+84|0;xb=x+88|0;wb=x+92|0;vb=x+96|0;ub=x+100|0;sb=x+104|0;rb=x+108|0;qb=x+112|0;pb=x+116|0;mb=x+120|0;ob=x+124|0;ib=p+4|0;fb=q+28|0;eb=q+88|0;db=q+56|0;cb=q+64|0;bb=q+68|0;ab=q+72|0;$a=q+80|0;_a=q+84|0;Za=r+16|0;Ya=o+4|0;Xa=o+8|0;Wa=o+12|0;Va=o+16|0;Ua=o+20|0;Ta=o+24|0;Sa=o+28|0;Ra=o+32|0;Qa=o+36|0;Pa=o+40|0;Oa=o+44|0;Na=o+48|0;Ma=o+52|0;La=o+56|0;Ka=o+60|0;Ja=o+64|0;Ia=o+68|0;Ha=o+72|0;Ga=o+76|0;Fa=o+80|0;Da=p+9|0;ya=o+92|0;xa=o+96|0;za=p+10|0;wa=o+84|0;ua=o+92|0;N=o+84|0;sa=o+88|0;ja=z+20|0;ia=z+24|0;ha=z+12|0;ga=x+24|0;fa=x+28|0;ea=x+40|0;da=x+4|0;ca=x+8|0;ba=x+12|0;aa=x+16|0;$=x+20|0;_=x+21|0;Z=x+32|0;Y=x+36|0;Hb=(j|0)>0;ta=y+40|0;L=y+32|0;W=y+36|0;X=y+48|0;V=y+24|0;U=p+8|0;T=p+12|0;P=q+8|0;l=q+12|0;J=r+8|0;S=r+16|0;h:while(1){Ib=c[F>>2]|0;if(!Ib){B=255;break}else{Kb=1.0;Jb=0}do{Lb=Ib+4|0;Ob=c[Lb>>2]|0;do if((Ob&4|0)!=0?(c[Ib+128>>2]|0)<=8:0){if(!(Ob&32)){ic=c[Ib+48>>2]|0;Ob=c[Ib+52>>2]|0;if(a[ic+38>>0]|0)break;if(a[Ob+38>>0]|0)break;sc=c[ic+8>>2]|0;uc=c[Ob+8>>2]|0;vc=c[sc>>2]|0;wc=c[uc>>2]|0;if(!((vc|0)==2|(wc|0)==2)){B=158;break h}tc=b[sc+4>>1]|0;xc=b[uc+4>>1]|0;if(!((tc&2)!=0&(vc|0)!=0|(xc&2)!=0&(wc|0)!=0))break;if(!((tc&8)!=0|(vc|0)!=2|((xc&8)!=0|(wc|0)!=2)))break;vc=sc+28|0;xc=sc+60|0;Nb=+g[xc>>2];tc=uc+28|0;wc=uc+60|0;Mb=+g[wc>>2];do if(Nb>2];Sc=sc+40|0;Jc=+g[Sc>>2];Mc=Lc*(+g[sc+48>>2]-Jc);g[Rc>>2]=Ic+Lc*(+g[sc+44>>2]-Ic);g[Sc>>2]=Jc+Mc;Sc=sc+52|0;Mc=+g[Sc>>2];g[Sc>>2]=Mc+Lc*(+g[sc+56>>2]-Mc);g[xc>>2]=Mb}else{if(!(Mb>2];Sc=uc+40|0;Lc=+g[Sc>>2];Mb=Mc*(+g[uc+48>>2]-Lc);g[Rc>>2]=Jc+Mc*(+g[uc+44>>2]-Jc);g[Sc>>2]=Lc+Mb;Sc=uc+52|0;Mb=+g[Sc>>2];g[Sc>>2]=Mb+Mc*(+g[uc+56>>2]-Mb);g[wc>>2]=Nb;Mb=Nb}while(0);if(!(Mb<1.0)){B=170;break h}Sc=c[Ib+56>>2]|0;sc=c[Ib+60>>2]|0;c[va>>2]=0;c[Ea>>2]=0;g[kb>>2]=0.0;c[Ba>>2]=0;c[Ca>>2]=0;g[jb>>2]=0.0;Xw(x,c[ic+12>>2]|0,Sc);Xw(hb,c[Ob+12>>2]|0,sc);Ob=ra+0|0;ic=vc+0|0;sc=Ob+36|0;do{c[Ob>>2]=c[ic>>2];Ob=Ob+4|0;ic=ic+4|0}while((Ob|0)<(sc|0));Ob=Gb+0|0;ic=tc+0|0;sc=Ob+36|0;do{c[Ob>>2]=c[ic>>2];Ob=Ob+4|0;ic=ic+4|0}while((Ob|0)<(sc|0));g[Fb>>2]=1.0;c[1548]=(c[1548]|0)+1;Sb=+g[Eb>>2];Rb=+g[Db>>2];Zb=+g[Cb>>2];_b=+g[Bb>>2];hc=+g[Ab>>2];gc=+g[zb>>2];ec=+g[yb>>2];ac=+g[xb>>2];Yb=+g[wb>>2];$b=+g[vb>>2];Qb=+g[ub>>2];dc=+g[sb>>2];fc=+g[rb>>2];Tb=+g[qb>>2];Ub=+g[pb>>2];Pb=+g[ob>>2];bc=+M(+(ec/6.2831854820251465))*6.2831854820251465;ec=ec-bc;bc=+g[nb>>2]-bc;Xb=+M(+(Ub/6.2831854820251465))*6.2831854820251465;Ub=Ub-Xb;Xb=+g[mb>>2]-Xb;cc=+g[kb>>2]+ +g[jb>>2]+-.014999999664723873;cc=cc<.004999999888241291?.004999999888241291:cc;if(!(cc>.0012499999720603228)){B=172;break h}b[ib>>1]=0;c[q+0>>2]=c[x+0>>2];c[q+4>>2]=c[x+4>>2];c[q+8>>2]=c[x+8>>2];c[q+12>>2]=c[x+12>>2];c[q+16>>2]=c[x+16>>2];c[q+20>>2]=c[x+20>>2];c[q+24>>2]=c[x+24>>2];c[fb+0>>2]=c[hb+0>>2];c[fb+4>>2]=c[hb+4>>2];c[fb+8>>2]=c[hb+8>>2];c[fb+12>>2]=c[hb+12>>2];c[fb+16>>2]=c[hb+16>>2];c[fb+20>>2]=c[hb+20>>2];c[fb+24>>2]=c[hb+24>>2];a[eb>>0]=0;Vb=cc+.0012499999720603228;Wb=cc+-.0012499999720603228;Ob=0;Nb=0.0;i:while(1){mc=1.0-Nb;kc=mc*ec+Nb*bc;jc=+R(+kc);kc=+Q(+kc);pc=mc*Zb+Nb*hc-(kc*Sb-jc*Rb);lc=mc*_b+Nb*gc-(jc*Sb+kc*Rb);oc=mc*Ub+Nb*Xb;nc=+R(+oc);oc=+Q(+oc);qc=mc*Qb+Nb*fc-(oc*Yb-nc*$b);mc=mc*dc+Nb*Tb-(nc*Yb+oc*$b);rc=+pc;Mc=+lc;Sc=db;g[Sc>>2]=rc;g[Sc+4>>2]=Mc;g[cb>>2]=jc;g[bb>>2]=kc;Mc=+qc;rc=+mc;Sc=ab;g[Sc>>2]=Mc;g[Sc+4>>2]=rc;g[$a>>2]=nc;g[_a>>2]=oc;Yw(r,p,q);rc=+g[Za>>2];if(rc<=0.0){ic=2;Nb=0.0;break}if(rc>2]=x;c[Ya>>2]=hb;sc=c[ib>>2]|0;uc=sc&65535;ic=sc>>>16;vc=ic&255;sc=sc>>>24;tc=sc&255;if(!(uc<<16>>16!=0&(uc&65535)<3)){B=177;break h}g[Xa>>2]=Sb;g[Wa>>2]=Rb;g[Va>>2]=Zb;g[Ua>>2]=_b;g[Ta>>2]=hc;g[Sa>>2]=gc;g[Ra>>2]=ec;g[Qa>>2]=bc;g[Pa>>2]=ac;g[Oa>>2]=Yb;g[Na>>2]=$b;g[Ma>>2]=Qb;g[La>>2]=dc;g[Ka>>2]=fc;g[Ja>>2]=Tb;g[Ia>>2]=Ub;g[Ha>>2]=Xb;g[Ga>>2]=Pb;do if(uc<<16>>16!=1)if(vc<<24>>24==tc<<24>>24){c[Fa>>2]=2;uc=d[Da>>0]|0;sc=c[Ca>>2]|0;if((sc|0)<=(uc|0)){B=187;break h}tc=c[Ba>>2]|0;uc=tc+(uc<<3)|0;Cc=+g[uc>>2];rc=+g[uc+4>>2];uc=d[za>>0]|0;if((sc|0)<=(uc|0)){B=189;break h}Sc=tc+(uc<<3)|0;Fc=+g[Sc>>2];Dc=+g[Sc+4>>2];Jc=Fc-Cc;Ic=Dc-rc;Ec=-Jc;Lc=+Ic;Mc=+Ec;Sc=ya;g[Sc>>2]=Lc;g[Sc+4>>2]=Mc;Jc=+O(+(Ic*Ic+Jc*Jc));if(!(Jc<1.1920928955078125e-7)){Mc=1.0/Jc;Ic=Ic*Mc;g[ya>>2]=Ic;Ec=Mc*Ec;g[xa>>2]=Ec}Cc=(Cc+Fc)*.5;rc=(rc+Dc)*.5;Lc=+Cc;Mc=+rc;Sc=wa;g[Sc>>2]=Lc;g[Sc+4>>2]=Mc;ic=ic&255;if((c[Ea>>2]|0)<=(ic|0)){B=193;break h}Sc=(c[va>>2]|0)+(ic<<3)|0;Lc=+g[Sc>>2];Mc=+g[Sc+4>>2];if(!((oc*Ic-nc*Ec)*(pc+(kc*Lc-jc*Mc)-(qc+(oc*Cc-nc*rc)))+(nc*Ic+oc*Ec)*(lc+(jc*Lc+kc*Mc)-(mc+(nc*Cc+oc*rc)))<0.0)){Mc=Zb;nc=_b;mc=hc;Lc=gc;lc=ec;kc=bc;Jc=Sb;Ic=Rb;Fc=Qb;Dc=dc;qc=fc;Ec=Tb;oc=Ub;pc=Xb;Cc=Yb;rc=$b;sc=2;ic=1;jc=1.0;break}nc=+-Ic;Mc=+-Ec;sc=ya;g[sc>>2]=nc;g[sc+4>>2]=Mc;Mc=Zb;nc=_b;mc=hc;Lc=gc;lc=ec;kc=bc;Jc=Sb;Ic=Rb;Fc=Qb;Dc=dc;qc=fc;Ec=Tb;oc=Ub;pc=Xb;Cc=Yb;rc=$b;sc=2;ic=1;jc=1.0;break}else{c[Fa>>2]=1;uc=ic&255;ic=c[Ea>>2]|0;if((ic|0)<=(uc|0)){B=197;break h}tc=c[va>>2]|0;Sc=tc+(uc<<3)|0;Cc=+g[Sc>>2];rc=+g[Sc+4>>2];if((ic|0)<=(sc|0)){B=199;break h}Sc=tc+(sc<<3)|0;Ic=+g[Sc>>2];Dc=+g[Sc+4>>2];Jc=Ic-Cc;Fc=Dc-rc;Ec=-Jc;Lc=+Fc;Mc=+Ec;Sc=ya;g[Sc>>2]=Lc;g[Sc+4>>2]=Mc;Jc=+O(+(Fc*Fc+Jc*Jc));if(!(Jc<1.1920928955078125e-7)){Mc=1.0/Jc;Fc=Fc*Mc;g[ya>>2]=Fc;Ec=Mc*Ec;g[xa>>2]=Ec}Cc=(Cc+Ic)*.5;rc=(rc+Dc)*.5;Lc=+Cc;Mc=+rc;ic=wa;g[ic>>2]=Lc;g[ic+4>>2]=Mc;ic=d[Da>>0]|0;if((c[Ca>>2]|0)<=(ic|0)){B=203;break h}Sc=(c[Ba>>2]|0)+(ic<<3)|0;Lc=+g[Sc>>2];Mc=+g[Sc+4>>2];if(!((kc*Fc-jc*Ec)*(qc+(oc*Lc-nc*Mc)-(pc+(kc*Cc-jc*rc)))+(jc*Fc+kc*Ec)*(mc+(nc*Lc+oc*Mc)-(lc+(jc*Cc+kc*rc)))<0.0)){Mc=Zb;nc=_b;mc=hc;Lc=gc;lc=ec;kc=bc;Jc=Sb;Ic=Rb;Fc=Qb;Dc=dc;qc=fc;Ec=Tb;oc=Ub;pc=Xb;Cc=Yb;rc=$b;sc=1;ic=1;jc=1.0;break}nc=+-Fc;Mc=+-Ec;sc=ya;g[sc>>2]=nc;g[sc+4>>2]=Mc;Mc=Zb;nc=_b;mc=hc;Lc=gc;lc=ec;kc=bc;Jc=Sb;Ic=Rb;Fc=Qb;Dc=dc;qc=fc;Ec=Tb;oc=Ub;pc=Xb;Cc=Yb;rc=$b;sc=1;ic=1;jc=1.0;break}else{c[Fa>>2]=0;ic=ic&255;if((c[Ea>>2]|0)<=(ic|0)){B=180;break h}ic=(c[va>>2]|0)+(ic<<3)|0;Cc=+g[ic>>2];rc=+g[ic+4>>2];ic=d[Da>>0]|0;if((c[Ca>>2]|0)<=(ic|0)){B=182;break h}Sc=(c[Ba>>2]|0)+(ic<<3)|0;Lc=+g[Sc>>2];Mc=+g[Sc+4>>2];pc=qc+(oc*Lc-nc*Mc)-(pc+(kc*Cc-jc*rc));jc=mc+(nc*Lc+oc*Mc)-(lc+(jc*Cc+kc*rc));Mc=+pc;kc=+jc;Sc=ya;g[Sc>>2]=Mc;g[Sc+4>>2]=kc;kc=+O(+(pc*pc+jc*jc));if(kc<1.1920928955078125e-7){Mc=Zb;nc=_b;mc=hc;Lc=gc;lc=ec;kc=bc;Jc=Sb;Ic=Rb;Fc=Qb;Dc=dc;qc=fc;Ec=Tb;oc=Ub;pc=Xb;Cc=Yb;rc=$b;sc=0;ic=1;jc=1.0;break}Mc=1.0/kc;g[ya>>2]=pc*Mc;g[xa>>2]=jc*Mc;Mc=Zb;nc=_b;mc=hc;Lc=gc;lc=ec;kc=bc;Jc=Sb;Ic=Rb;Fc=Qb;Dc=dc;qc=fc;Ec=Tb;oc=Ub;pc=Xb;Cc=Yb;rc=$b;sc=0;ic=1;jc=1.0}while(0);while(1){Tc=1.0-jc;kc=Tc*lc+kc*jc;lc=+R(+kc);kc=+Q(+kc);mc=Tc*Mc+mc*jc-(kc*Jc-lc*Ic);nc=Tc*nc+Lc*jc-(lc*Jc+kc*Ic);oc=Tc*oc+pc*jc;pc=+R(+oc);oc=+Q(+oc);qc=Tc*Fc+qc*jc-(oc*Cc-pc*rc);rc=Tc*Dc+Ec*jc-(pc*Cc+oc*rc);if(!sc){Cc=+g[ua>>2];Dc=+g[xa>>2];Jc=kc*Cc+lc*Dc;Ic=kc*Dc-lc*Cc;Fc=-Cc;Tc=-Dc;Ec=oc*Fc+pc*Tc;Fc=oc*Tc-pc*Fc;sc=c[o>>2]|0;tc=c[sc+16>>2]|0;sc=c[sc+20>>2]|0;if((sc|0)>1){uc=0;Lc=Ic*+g[tc+4>>2]+Jc*+g[tc>>2];wc=1;while(1){Mc=Jc*+g[tc+(wc<<3)>>2]+Ic*+g[tc+(wc<<3)+4>>2];vc=Mc>Lc;uc=vc?wc:uc;wc=wc+1|0;if((wc|0)==(sc|0))break;else Lc=vc?Mc:Lc}}else uc=0;vc=c[Ya>>2]|0;wc=c[vc+16>>2]|0;vc=c[vc+20>>2]|0;if((vc|0)>1){zc=0;Jc=Fc*+g[wc+4>>2]+Ec*+g[wc>>2];xc=1;while(1){Ic=Ec*+g[wc+(xc<<3)>>2]+Fc*+g[wc+(xc<<3)+4>>2];yc=Ic>Jc;zc=yc?xc:zc;xc=xc+1|0;if((xc|0)==(vc|0))break;else Jc=yc?Ic:Jc}}else zc=0;if(!((uc|0)>-1&(sc|0)>(uc|0))){B=214;break h}Sc=tc+(uc<<3)|0;Ec=+g[Sc>>2];Fc=+g[Sc+4>>2];if(!((zc|0)>-1&(vc|0)>(zc|0))){B=216;break h}Sc=wc+(zc<<3)|0;Mc=+g[Sc>>2];Tc=+g[Sc+4>>2];pc=Cc*(qc+(oc*Mc-pc*Tc)-(mc+(kc*Ec-lc*Fc)))+Dc*(rc+(pc*Mc+oc*Tc)-(nc+(lc*Ec+kc*Fc)))}else if((sc|0)==1){Tc=+g[ua>>2];Dc=+g[xa>>2];Cc=kc*Tc-lc*Dc;Dc=lc*Tc+kc*Dc;Tc=+g[N>>2];Fc=+g[sa>>2];mc=mc+(kc*Tc-lc*Fc);kc=nc+(lc*Tc+kc*Fc);Fc=-Cc;Tc=-Dc;Ec=oc*Fc+pc*Tc;Fc=oc*Tc-pc*Fc;sc=c[Ya>>2]|0;tc=c[sc+16>>2]|0;sc=c[sc+20>>2]|0;if((sc|0)>1){zc=0;lc=Fc*+g[tc+4>>2]+Ec*+g[tc>>2];uc=1;while(1){nc=Ec*+g[tc+(uc<<3)>>2]+Fc*+g[tc+(uc<<3)+4>>2];vc=nc>lc;zc=vc?uc:zc;uc=uc+1|0;if((uc|0)==(sc|0))break;else lc=vc?nc:lc}if((zc|0)<=-1){B=223;break h}}else zc=0;if((sc|0)<=(zc|0)){B=223;break h}uc=tc+(zc<<3)|0;Mc=+g[uc>>2];Tc=+g[uc+4>>2];pc=Cc*(qc+(oc*Mc-pc*Tc)-mc)+Dc*(rc+(pc*Mc+oc*Tc)-kc);uc=-1}else if((sc|0)==2){Mc=+g[ua>>2];Dc=+g[xa>>2];Cc=oc*Mc-pc*Dc;Dc=pc*Mc+oc*Dc;Mc=+g[N>>2];Tc=+g[sa>>2];qc=qc+(oc*Mc-pc*Tc);oc=rc+(pc*Mc+oc*Tc);rc=-Cc;Tc=-Dc;pc=kc*rc+lc*Tc;rc=kc*Tc-lc*rc;sc=c[o>>2]|0;tc=c[sc+16>>2]|0;sc=c[sc+20>>2]|0;if((sc|0)>1){uc=0;Ec=rc*+g[tc+4>>2]+pc*+g[tc>>2];vc=1;while(1){Fc=pc*+g[tc+(vc<<3)>>2]+rc*+g[tc+(vc<<3)+4>>2];wc=Fc>Ec;uc=wc?vc:uc;vc=vc+1|0;if((vc|0)==(sc|0))break;else Ec=wc?Fc:Ec}if((uc|0)<=-1){B=230;break h}}else uc=0;if((sc|0)<=(uc|0)){B=230;break h}zc=tc+(uc<<3)|0;Tc=+g[zc>>2];pc=+g[zc+4>>2];pc=Cc*(mc+(kc*Tc-lc*pc)-qc)+Dc*(nc+(lc*Tc+kc*pc)-oc);zc=-1}else{B=232;break h}if(pc>Vb){ic=4;Nb=1.0;B=246;break i}if(pc>Wb){Nb=jc;break}mc=+ex(o,uc,zc,Nb);if(mc0.0))qc=-qc;if(qc<.0012499999720603228){jc=oc;break}tc=nc>cc;if((sc|0)==50)break;else{kc=tc?oc:kc;lc=tc?lc:oc;mc=tc?nc:mc;pc=tc?pc:nc}}Sc=c[1556]|0;c[1556]=(Sc|0)>(sc|0)?Sc:sc;if((ic|0)==16)break;Mc=+g[Va>>2];nc=+g[Ua>>2];mc=+g[Ta>>2];Lc=+g[Sa>>2];lc=+g[Ra>>2];kc=+g[Qa>>2];Jc=+g[Xa>>2];Ic=+g[Wa>>2];Fc=+g[Ma>>2];Dc=+g[La>>2];qc=+g[Ka>>2];Ec=+g[Ja>>2];oc=+g[Ia>>2];pc=+g[Ha>>2];Cc=+g[Oa>>2];rc=+g[Na>>2];sc=c[Fa>>2]|0;ic=ic+1|0}Ob=Ob+1|0;c[1550]=(c[1550]|0)+1;if((Ob|0)==20){Ob=20;ic=1;break}}if((B|0)==246){B=0;c[1550]=(c[1550]|0)+1;Ob=Ob+1|0}Sc=c[1552]|0;c[1552]=(Sc|0)>(Ob|0)?Sc:Ob;if((ic|0)==3){Mb=Mb+(1.0-Mb)*Nb;Mb=Mb<1.0?Mb:1.0}else Mb=1.0;g[Ib+132>>2]=Mb;c[Lb>>2]=c[Lb>>2]|32}else Mb=+g[Ib+132>>2];if(Mb>2]|0}while((Ib|0)!=0);if((Jb|0)==0|Kb>.9999988079071045){B=255;break}Lb=c[(c[Jb+48>>2]|0)+8>>2]|0;Ib=c[(c[Jb+52>>2]|0)+8>>2]|0;uc=Lb+28|0;Ob=t+0|0;ic=uc+0|0;sc=Ob+36|0;do{c[Ob>>2]=c[ic>>2];Ob=Ob+4|0;ic=ic+4|0}while((Ob|0)<(sc|0));tc=Ib+28|0;Ob=u+0|0;ic=tc+0|0;sc=Ob+36|0;do{c[Ob>>2]=c[ic>>2];Ob=Ob+4|0;ic=ic+4|0}while((Ob|0)<(sc|0));Ob=Lb+60|0;Mb=+g[Ob>>2];if(!(Mb<1.0)){B=257;break}Jc=(Kb-Mb)/(1.0-Mb);wc=Lb+44|0;Sc=Lb+36|0;Mb=+g[Sc>>2];xc=Lb+48|0;vc=Lb+40|0;Lc=+g[vc>>2];Mc=Jc*(+g[xc>>2]-Lc);g[Sc>>2]=Mb+Jc*(+g[wc>>2]-Mb);g[vc>>2]=Lc+Mc;vc=Lb+56|0;Sc=Lb+52|0;Mc=+g[Sc>>2];Mc=Mc+Jc*(+g[vc>>2]-Mc);g[Sc>>2]=Mc;g[Ob>>2]=Kb;Ob=Lb+36|0;Sc=c[Ob>>2]|0;Ob=c[Ob+4>>2]|0;yc=Lb+44|0;c[yc>>2]=Sc;c[yc+4>>2]=Ob;g[vc>>2]=Mc;Jc=+R(+Mc);yc=Lb+20|0;g[yc>>2]=Jc;Mc=+Q(+Mc);Ac=Lb+24|0;g[Ac>>2]=Mc;Gc=Lb+12|0;Bc=Lb+28|0;Lc=+g[Bc>>2];zc=Lb+32|0;Mb=+g[zc>>2];Tc=(c[k>>2]=Sc,+g[k>>2])-(Mc*Lc-Jc*Mb);Mb=(c[k>>2]=Ob,+g[k>>2])-(Jc*Lc+Mc*Mb);Tc=+Tc;Mb=+Mb;Ob=Gc;g[Ob>>2]=Tc;g[Ob+4>>2]=Mb;Ob=Ib+60|0;Mb=+g[Ob>>2];if(!(Mb<1.0)){B=259;break}Ic=(Kb-Mb)/(1.0-Mb);Kc=Ib+44|0;ic=Ib+36|0;Tc=+g[ic>>2];Hc=Ib+48|0;Nc=Ib+40|0;Jc=+g[Nc>>2];Lc=Ic*(+g[Hc>>2]-Jc);g[ic>>2]=Tc+Ic*(+g[Kc>>2]-Tc);g[Nc>>2]=Jc+Lc;Nc=Ib+56|0;ic=Ib+52|0;Lc=+g[ic>>2];Lc=Lc+Ic*(+g[Nc>>2]-Lc);g[ic>>2]=Lc;g[Ob>>2]=Kb;Ob=Ib+36|0;ic=c[Ob>>2]|0;Ob=c[Ob+4>>2]|0;Oc=Ib+44|0;c[Oc>>2]=ic;c[Oc+4>>2]=Ob;g[Nc>>2]=Lc;Ic=+R(+Lc);Oc=Ib+20|0;g[Oc>>2]=Ic;Lc=+Q(+Lc);Pc=Ib+24|0;g[Pc>>2]=Lc;Sc=Ib+12|0;Qc=Ib+28|0;Jc=+g[Qc>>2];Rc=Ib+32|0;Tc=+g[Rc>>2];Mc=(c[k>>2]=ic,+g[k>>2])-(Lc*Jc-Ic*Tc);Tc=(c[k>>2]=Ob,+g[k>>2])-(Ic*Jc+Lc*Tc);Mc=+Mc;Tc=+Tc;Ob=Sc;g[Ob>>2]=Mc;g[Ob+4>>2]=Tc;My(Jb,c[I>>2]|0);Ob=Jb+4|0;ic=c[Ob>>2]|0;c[Ob>>2]=ic&-33;sc=Jb+128|0;c[sc>>2]=(c[sc>>2]|0)+1;if((ic&6|0)!=6){c[Ob>>2]=ic&-37;Ob=uc+0|0;ic=t+0|0;sc=Ob+36|0;do{c[Ob>>2]=c[ic>>2];Ob=Ob+4|0;ic=ic+4|0}while((Ob|0)<(sc|0));Ob=tc+0|0;ic=u+0|0;sc=Ob+36|0;do{c[Ob>>2]=c[ic>>2];Ob=Ob+4|0;ic=ic+4|0}while((Ob|0)<(sc|0));Jc=+g[vc>>2];Mc=+R(+Jc);g[yc>>2]=Mc;Jc=+Q(+Jc);g[Ac>>2]=Jc;Tc=+g[Bc>>2];Lc=+g[zc>>2];Ic=+(+g[wc>>2]-(Jc*Tc-Mc*Lc));Lc=+(+g[xc>>2]-(Mc*Tc+Jc*Lc));g[Gc>>2]=Ic;g[Gc+4>>2]=Lc;Lc=+g[Nc>>2];Ic=+R(+Lc);g[Oc>>2]=Ic;Lc=+Q(+Lc);g[Pc>>2]=Lc;Jc=+g[Qc>>2];Tc=+g[Rc>>2];Mc=+(+g[Kc>>2]-(Lc*Jc-Ic*Tc));Tc=+(+g[Hc>>2]-(Ic*Jc+Lc*Tc));g[Sc>>2]=Mc;g[Sc+4>>2]=Tc;continue}ic=Lb+4|0;sc=e[ic>>1]|0;if(!(sc&2)){b[ic>>1]=sc|2;g[Lb+144>>2]=0.0}tc=Ib+4|0;sc=e[tc>>1]|0;if(!(sc&2)){b[tc>>1]=sc|2;g[Ib+144>>2]=0.0}c[qa>>2]=0;c[pa>>2]=0;c[oa>>2]=0;sy(z,Lb);sy(z,Ib);ty(z,Jb);b[ic>>1]=e[ic>>1]|1;b[tc>>1]=e[tc>>1]|1;c[Ob>>2]=c[Ob>>2]|1;c[s>>2]=Lb;c[na>>2]=Ib;Ob=Lb;Jb=1;while(1){j:do if((c[Ob>>2]|0)==2?(A=c[Ob+112>>2]|0,(A|0)!=0):0){vc=Ob+4|0;uc=A;do{if((c[qa>>2]|0)==(c[ma>>2]|0))break j;if((c[pa>>2]|0)==(c[la>>2]|0))break j;yc=c[uc+4>>2]|0;xc=yc+4|0;k:do if(!(c[xc>>2]&1)){tc=c[uc>>2]|0;do if((c[tc>>2]|0)==2){if(b[vc>>1]&8)break;if(!(b[tc+4>>1]&8))break k}while(0);if(a[(c[yc+48>>2]|0)+38>>0]|0)break;if(a[(c[yc+52>>2]|0)+38>>0]|0)break;wc=tc+28|0;Ob=v+0|0;ic=wc+0|0;sc=Ob+36|0;do{c[Ob>>2]=c[ic>>2];Ob=Ob+4|0;ic=ic+4|0}while((Ob|0)<(sc|0));Ob=tc+4|0;if(!(b[Ob>>1]&1)){ic=tc+60|0;Mb=+g[ic>>2];if(!(Mb<1.0)){B=280;break h}Ic=(Kb-Mb)/(1.0-Mb);Sc=tc+36|0;Tc=+g[Sc>>2];Qc=tc+40|0;Jc=+g[Qc>>2];Lc=Ic*(+g[tc+48>>2]-Jc);g[Sc>>2]=Tc+Ic*(+g[tc+44>>2]-Tc);g[Qc>>2]=Jc+Lc;Qc=tc+56|0;Sc=tc+52|0;Lc=+g[Sc>>2];Lc=Lc+Ic*(+g[Qc>>2]-Lc);g[Sc>>2]=Lc;g[ic>>2]=Kb;Sc=tc+36|0;Rc=c[Sc>>2]|0;Sc=c[Sc+4>>2]|0;Pc=tc+44|0;c[Pc>>2]=Rc;c[Pc+4>>2]=Sc;g[Qc>>2]=Lc;Ic=+R(+Lc);g[tc+20>>2]=Ic;Lc=+Q(+Lc);g[tc+24>>2]=Lc;Jc=+g[tc+28>>2];Tc=+g[tc+32>>2];Mc=(c[k>>2]=Rc,+g[k>>2])-(Lc*Jc-Ic*Tc);Tc=(c[k>>2]=Sc,+g[k>>2])-(Ic*Jc+Lc*Tc);Mc=+Mc;Tc=+Tc;Sc=tc+12|0;g[Sc>>2]=Mc;g[Sc+4>>2]=Tc}My(yc,c[I>>2]|0);ic=c[xc>>2]|0;if(!(ic&4)){Ob=wc+0|0;ic=v+0|0;sc=Ob+36|0;do{c[Ob>>2]=c[ic>>2];Ob=Ob+4|0;ic=ic+4|0}while((Ob|0)<(sc|0));Lc=+g[tc+56>>2];Ic=+R(+Lc);g[tc+20>>2]=Ic;Lc=+Q(+Lc);g[tc+24>>2]=Lc;Jc=+g[tc+28>>2];Tc=+g[tc+32>>2];Mc=+(+g[tc+44>>2]-(Lc*Jc-Ic*Tc));Tc=+(+g[tc+48>>2]-(Ic*Jc+Lc*Tc));Sc=tc+12|0;g[Sc>>2]=Mc;g[Sc+4>>2]=Tc;break}if(!(ic&2)){Ob=wc+0|0;ic=v+0|0;sc=Ob+36|0;do{c[Ob>>2]=c[ic>>2];Ob=Ob+4|0;ic=ic+4|0}while((Ob|0)<(sc|0));Lc=+g[tc+56>>2];Ic=+R(+Lc);g[tc+20>>2]=Ic;Lc=+Q(+Lc);g[tc+24>>2]=Lc;Jc=+g[tc+28>>2];Tc=+g[tc+32>>2];Mc=+(+g[tc+44>>2]-(Lc*Jc-Ic*Tc));Tc=+(+g[tc+48>>2]-(Ic*Jc+Lc*Tc));Sc=tc+12|0;g[Sc>>2]=Mc;g[Sc+4>>2]=Tc;break}c[xc>>2]=ic|1;ty(z,yc);ic=e[Ob>>1]|0;if(ic&1)break;b[Ob>>1]=ic|1;do if(c[tc>>2]|0){if(ic&2)break;b[Ob>>1]=ic|3;g[tc+144>>2]=0.0}while(0);sy(z,tc)}while(0);uc=c[uc+12>>2]|0}while((uc|0)!=0)}while(0);if((Jb|0)>=2)break;Ob=c[s+(Jb<<2)>>2]|0;Jb=Jb+1|0}Kb=(1.0-Kb)*h;Mb=1.0/Kb;Jb=c[Lb+8>>2]|0;Lb=c[Ib+8>>2]|0;uc=c[qa>>2]|0;if((uc|0)<=(Jb|0)){B=295;break}if((uc|0)<=(Lb|0)){B=300;break}Ib=(uc|0)>0;if(Ib){sc=c[ka>>2]|0;ic=c[ja>>2]|0;Ob=c[ia>>2]|0;tc=0;do{Sc=c[sc+(tc<<2)>>2]|0;Rc=Sc+44|0;Qc=c[Rc+4>>2]|0;Pc=ic+(tc*12|0)|0;c[Pc>>2]=c[Rc>>2];c[Pc+4>>2]=Qc;g[ic+(tc*12|0)+8>>2]=+g[Sc+56>>2];Pc=Sc+64|0;Qc=c[Pc+4>>2]|0;Rc=Ob+(tc*12|0)|0;c[Rc>>2]=c[Pc>>2];c[Rc+4>>2]=Qc;g[Ob+(tc*12|0)+8>>2]=+g[Sc+72>>2];tc=tc+1|0}while((tc|0)<(uc|0))}else{ic=c[ja>>2]|0;Ob=c[ia>>2]|0}c[ga>>2]=c[ha>>2];c[fa>>2]=c[pa>>2];c[ea>>2]=c[z>>2];g[x>>2]=Kb;g[da>>2]=Mb;g[ca>>2]=1.0;c[ba>>2]=j;c[aa>>2]=20;a[$>>0]=0;a[_+0>>0]=a[w+0>>0]|0;a[_+1>>0]=a[w+1>>0]|0;a[_+2>>0]=a[w+2>>0]|0;c[Z>>2]=ic;c[Y>>2]=Ob;Ny(y,x);uc=c[X>>2]|0;tc=(uc|0)>0;vc=c[W>>2]|0;wc=c[V>>2]|0;sc=0;do{if(tc){xc=0;Wb=0.0;do{Hc=vc+(xc*88|0)|0;zc=c[vc+(xc*88|0)+32>>2]|0;Bc=c[vc+(xc*88|0)+36>>2]|0;Gc=vc+(xc*88|0)+48|0;Qb=+g[Gc>>2];Ub=+g[Gc+4>>2];Gc=vc+(xc*88|0)+56|0;Tb=+g[Gc>>2];Sb=+g[Gc+4>>2];Gc=c[vc+(xc*88|0)+84>>2]|0;if((zc|0)==(Jb|0)|(zc|0)==(Lb|0)){Mb=+g[vc+(xc*88|0)+64>>2];Rb=+g[vc+(xc*88|0)+40>>2]}else{Mb=0.0;Rb=0.0}if((Bc|0)==(Jb|0)|(Bc|0)==(Lb|0)){Nb=+g[vc+(xc*88|0)+68>>2];Pb=+g[vc+(xc*88|0)+44>>2]}else{Nb=0.0;Pb=0.0}yc=wc+(zc*12|0)|0;Ac=yc;Xb=+g[Ac>>2];Yb=+g[Ac+4>>2];Ac=wc+(zc*12|0)+8|0;cc=+g[Ac>>2];zc=wc+(Bc*12|0)|0;Sc=zc;Zb=+g[Sc>>2];_b=+g[Sc+4>>2];Bc=wc+(Bc*12|0)+8|0;$b=+g[Bc>>2];if((Gc|0)>0){Vb=Rb+Pb;Kc=0;do{fc=+R(+cc);g[U>>2]=fc;hc=+Q(+cc);g[T>>2]=hc;gc=+R(+$b);g[P>>2]=gc;bc=+Q(+$b);g[l>>2]=bc;ac=+(Xb-(Qb*hc-Ub*fc));fc=+(Yb-(Ub*hc+Qb*fc));Sc=p;g[Sc>>2]=ac;g[Sc+4>>2]=fc;fc=+(Zb-(Tb*bc-Sb*gc));gc=+(_b-(Sb*bc+Tb*gc));Sc=q;g[Sc>>2]=fc;g[Sc+4>>2]=gc;Qy(r,Hc,p,q,Kc);Sc=r;gc=+g[Sc>>2];fc=+g[Sc+4>>2];Sc=J;bc=+g[Sc>>2];ac=+g[Sc+4>>2];hc=+g[S>>2];dc=bc-Xb;ec=ac-Yb;bc=bc-Zb;ac=ac-_b;Wb=Wb0.0)hc=-(hc<-.20000000298023224?-.20000000298023224:hc)/jc;else hc=0.0;Tc=gc*hc;Mc=fc*hc;Xb=Xb-Rb*Tc;Yb=Yb-Rb*Mc;cc=cc-Mb*(dc*Mc-ec*Tc);Zb=Zb+Pb*Tc;_b=_b+Pb*Mc;$b=$b+Nb*(bc*Mc-ac*Tc);Kc=Kc+1|0}while((Kc|0)!=(Gc|0))}Tc=+Xb;Mc=+Yb;Sc=yc;g[Sc>>2]=Tc;g[Sc+4>>2]=Mc;g[Ac>>2]=cc;Mc=+Zb;Tc=+_b;Sc=zc;g[Sc>>2]=Mc;g[Sc+4>>2]=Tc;g[Bc>>2]=$b;xc=xc+1|0}while((xc|0)<(uc|0))}else Wb=0.0;sc=sc+1|0}while(!(Wb>=-.007499999832361937)&(sc|0)<20);Sc=c[ka>>2]|0;Pc=Sc+(Jb<<2)|0;Oc=ic+(Jb*12|0)|0;Rc=c[Oc+4>>2]|0;Qc=(c[Pc>>2]|0)+36|0;c[Qc>>2]=c[Oc>>2];c[Qc+4>>2]=Rc;g[(c[Pc>>2]|0)+52>>2]=+g[ic+(Jb*12|0)+8>>2];Sc=Sc+(Lb<<2)|0;Pc=ic+(Lb*12|0)|0;Qc=c[Pc+4>>2]|0;Rc=(c[Sc>>2]|0)+36|0;c[Rc>>2]=c[Pc>>2];c[Rc+4>>2]=Qc;g[(c[Sc>>2]|0)+52>>2]=+g[ic+(Lb*12|0)+8>>2];Oy(y);if(Hb){Jb=0;do{Py(y);Jb=Jb+1|0}while((Jb|0)<(j|0))}if(Ib){Jb=0;do{Ib=ic+(Jb*12|0)|0;Sc=Ib;Nb=+g[Sc>>2];Mb=+g[Sc+4>>2];Pb=+g[ic+(Jb*12|0)+8>>2];Sc=Ob+(Jb*12|0)|0;Qb=+g[Sc>>2];Rb=+g[Sc+4>>2];Sb=+g[Ob+(Jb*12|0)+8>>2];Tc=Kb*Qb;Tb=Kb*Rb;Tb=Tc*Tc+Tb*Tb;if(Tb>4.0){Tc=2.0/+O(+Tb);Qb=Qb*Tc;Rb=Rb*Tc}Tb=Kb*Sb;if(Tb*Tb>2.4674012660980225){if(!(Tb>0.0))Tb=-Tb;Sb=Sb*(1.5707963705062866/Tb)}Mc=Nb+Kb*Qb;Fc=Mb+Kb*Rb;Lc=Pb+Kb*Sb;Ec=+Mc;Tc=+Fc;ic=Ib;g[ic>>2]=Ec;g[ic+4>>2]=Tc;ic=c[ja>>2]|0;g[ic+(Jb*12|0)+8>>2]=Lc;Ob=c[ia>>2]|0;Jc=+Qb;Ic=+Rb;Sc=Ob+(Jb*12|0)|0;g[Sc>>2]=Jc;g[Sc+4>>2]=Ic;g[Ob+(Jb*12|0)+8>>2]=Sb;Sc=c[(c[ka>>2]|0)+(Jb<<2)>>2]|0;Rc=Sc+44|0;g[Rc>>2]=Ec;g[Rc+4>>2]=Tc;g[Sc+56>>2]=Lc;Rc=Sc+64|0;g[Rc>>2]=Jc;g[Rc+4>>2]=Ic;g[Sc+72>>2]=Sb;Ic=+R(+Lc);g[Sc+20>>2]=Ic;Lc=+Q(+Lc);g[Sc+24>>2]=Lc;Jc=+g[Sc+28>>2];Tc=+g[Sc+32>>2];Mc=+(Mc-(Lc*Jc-Ic*Tc));Tc=+(Fc-(Ic*Jc+Lc*Tc));Sc=Sc+12|0;g[Sc>>2]=Mc;g[Sc+4>>2]=Tc;Jb=Jb+1|0}while((Jb|0)<(c[qa>>2]|0))}Sc=c[ta>>2]|0;qy(z,Sc);Lb=c[L>>2]|0;Px(Lb,Sc);Px(Lb,c[W>>2]|0);Lb=c[qa>>2]|0;if((Lb|0)>0){Ib=c[ka>>2]|0;Jb=0;do{Ob=c[Ib+(Jb<<2)>>2]|0;Sc=Ob+4|0;b[Sc>>1]=e[Sc>>1]&65534;do if((c[Ob>>2]|0)==2){Rx(Ob);Ob=c[Ob+112>>2]|0;if(!Ob)break;do{Sc=(c[Ob+4>>2]|0)+4|0;c[Sc>>2]=c[Sc>>2]&-34;Ob=c[Ob+12>>2]|0}while((Ob|0)!=0)}while(0);Jb=Jb+1|0}while((Jb|0)<(Lb|0))}Yx(E);if(a[K>>0]|0){B=332;break}}switch(B|0){case 158:{Aa(11288,11088,641,11344);break};case 163:{Aa(11360,11872,704,11912);break};case 167:{Aa(11360,11872,704,11912);break};case 170:{Aa(11360,11088,676,11344);break};case 172:{Aa(6232,6256,279,6304);break};case 177:{Aa(6456,6256,52,16288);break};case 180:{Aa(6336,6368,103,6416);break};case 182:{Aa(6336,6368,103,6416);break};case 187:{Aa(6336,6368,103,6416);break};case 189:{Aa(6336,6368,103,6416);break};case 193:{Aa(6336,6368,103,6416);break};case 197:{Aa(6336,6368,103,6416);break};case 199:{Aa(6336,6368,103,6416);break};case 203:{Aa(6336,6368,103,6416);break};case 214:{Aa(6336,6368,103,6416);break};case 216:{Aa(6336,6368,103,6416);break};case 223:{Aa(6336,6368,103,6416);break};case 230:{Aa(6336,6368,103,6416);break};case 232:{Aa(15224,6256,186,6432);break};case 255:{a[H>>0]=1;break};case 257:{Aa(11360,11872,704,11912);break};case 259:{Aa(11360,11872,704,11912);break};case 280:{Aa(11360,11872,704,11912);break};case 295:{Aa(10968,10992,386,11344);break};case 300:{Aa(11040,10992,387,11344);break};case 332:{a[H>>0]=0;break}}py(z);g[f+103024>>2]=0.0;B=334}}else B=334;if((B|0)==334?C:0)g[G>>2]=D;o=c[n>>2]|0;if(!(o&4)){Sc=o&-3;c[n>>2]=Sc;Sc=f+102996|0;g[Sc>>2]=0.0;i=m;return}p=c[f+102952>>2]|0;if(!p){Sc=o&-3;c[n>>2]=Sc;Sc=f+102996|0;g[Sc>>2]=0.0;i=m;return}do{g[p+76>>2]=0.0;g[p+80>>2]=0.0;g[p+84>>2]=0.0;p=c[p+96>>2]|0}while((p|0)!=0);Sc=o&-3;c[n>>2]=Sc;Sc=f+102996|0;g[Sc>>2]=0.0;i=m;return}function vy(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0.0,q=0.0,r=0.0,s=0.0,t=0,u=0.0,v=0.0,w=0,x=0,y=0,z=0.0;f=i;i=i+176|0;m=f+16|0;l=f+152|0;o=f+160|0;n=f+168|0;h=f+8|0;j=f;k=f+24|0;t=c[b+4>>2]|0;if((t|0)==3){k=c[b+16>>2]|0;m=c[b+12>>2]|0;b=d+12|0;p=+g[b>>2];v=+g[m>>2];o=d+8|0;q=+g[o>>2];u=+g[m+4>>2];s=+g[d>>2];n=d+4|0;r=+g[n>>2];g[h>>2]=s+(p*v-q*u);g[h+4>>2]=v*q+p*u+r;if((k|0)<=1){i=f;return}l=j+4|0;a=a+102984|0;t=1;while(1){u=+g[m+(t<<3)>>2];v=+g[m+(t<<3)+4>>2];g[j>>2]=s+(p*u-q*v);g[l>>2]=u*q+p*v+r;y=c[a>>2]|0;vb[c[(c[y>>2]|0)+24>>2]&63](y,h,j,e);y=c[a>>2]|0;ob[c[(c[y>>2]|0)+16>>2]&63](y,h,.05000000074505806,e);y=j;x=c[y+4>>2]|0;w=h;c[w>>2]=c[y>>2];c[w+4>>2]=x;t=t+1|0;if((t|0)==(k|0))break;p=+g[b>>2];q=+g[o>>2];s=+g[d>>2];r=+g[n>>2]}i=f;return}else if((t|0)==2){h=c[b+276>>2]|0;if((h|0)>=17)Aa(11376,11088,1077,11400);if((h|0)>0){j=b+20|0;q=+g[d+12>>2];r=+g[d+8>>2];p=+g[d>>2];s=+g[d+4>>2];d=0;do{z=+g[j+(d<<3)>>2];v=+g[j+(d<<3)+4>>2];u=+(p+(q*z-r*v));v=+(z*r+q*v+s);y=k+(d<<3)|0;g[y>>2]=u;g[y+4>>2]=v;d=d+1|0}while((d|0)!=(h|0))}y=c[a+102984>>2]|0;vb[c[(c[y>>2]|0)+12>>2]&63](y,k,h,e);i=f;return}else if((t|0)==1){u=+g[d+12>>2];v=+g[b+12>>2];s=+g[d+8>>2];r=+g[b+16>>2];q=+g[d>>2];z=+g[d+4>>2];g[o>>2]=q+(u*v-s*r);g[o+4>>2]=v*s+u*r+z;y=b+20|0;r=+g[y>>2];v=+g[y+4>>2];g[n>>2]=q+(u*r-s*v);g[n+4>>2]=r*s+u*v+z;y=c[a+102984>>2]|0;vb[c[(c[y>>2]|0)+24>>2]&63](y,o,n,e);i=f;return}else if(!t){v=+g[d+12>>2];r=+g[b+12>>2];u=+g[d+8>>2];s=+g[b+16>>2];z=r*u+v*s+ +g[d+4>>2];g[m>>2]=+g[d>>2]+(v*r-u*s);g[m+4>>2]=z;z=+g[b+8>>2];g[l>>2]=v-u*0.0;g[l+4>>2]=u+v*0.0;y=c[a+102984>>2]|0;mb[c[(c[y>>2]|0)+20>>2]&63](y,m,z,l,e);i=f;return}else{i=f;return}}function wy(a,c,d){a=a|0;c=c|0;d=d|0;var e=0;a=i;e=b[c+36>>1]|0;if(!(e<<16>>16==0?1:e<<16>>16!=(b[d+36>>1]|0))){e=e<<16>>16>0;i=a;return e|0}if(!((b[d+32>>1]&b[c+34>>1])<<16>>16)){e=0;i=a;return e|0}e=(b[d+34>>1]&b[c+32>>1])<<16>>16!=0;i=a;return e|0}function xy(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var h=0,j=0,k=0.0,l=0.0;h=i;f=Hx(f,148)|0;if(!f){j=0;i=h;return j|0}c[f+4>>2]=4;c[f+48>>2]=a;c[f+52>>2]=d;c[f+56>>2]=b;c[f+60>>2]=e;c[f+124>>2]=0;c[f+128>>2]=0;e=a+16|0;j=f+8|0;b=j+40|0;do{c[j>>2]=0;j=j+4|0}while((j|0)<(b|0));g[f+136>>2]=+O(+(+g[e>>2]*+g[d+16>>2]));l=+g[a+20>>2];k=+g[d+20>>2];g[f+140>>2]=l>k?l:k;g[f+144>>2]=0.0;c[f>>2]=12136;if((c[(c[a+12>>2]|0)+4>>2]|0)!=3)Aa(12344,12152,42,12224);if(!(c[(c[d+12>>2]|0)+4>>2]|0)){j=f;i=h;return j|0}else Aa(13952,12152,43,12224);return 0}function yy(a,b){a=a|0;b=b|0;var d=0;d=i;jb[c[(c[a>>2]|0)+4>>2]&127](a);Ix(b,a,148);i=d;return}function zy(a,d,e,f){a=a|0;d=d|0;e=e|0;f=f|0;var h=0,j=0,k=0,l=0;h=i;i=i+48|0;j=h;k=c[(c[a+48>>2]|0)+12>>2]|0;c[j>>2]=7008;c[j+4>>2]=1;g[j+8>>2]=.009999999776482582;l=j+28|0;c[l+0>>2]=0;c[l+4>>2]=0;c[l+8>>2]=0;c[l+12>>2]=0;b[l+16>>1]=0;kx(k,j,c[a+56>>2]|0);Tw(d,j,e,c[(c[a+52>>2]|0)+12>>2]|0,f);i=h;return}function Ay(a){a=a|0;return}function By(a){a=a|0;var b=0;b=i;OB(a);i=b;return}function Cy(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var h=0,j=0,k=0.0,l=0.0;h=i;f=Hx(f,148)|0;if(!f){j=0;i=h;return j|0}c[f+4>>2]=4;c[f+48>>2]=a;c[f+52>>2]=d;c[f+56>>2]=b;c[f+60>>2]=e;c[f+124>>2]=0;c[f+128>>2]=0;e=a+16|0;j=f+8|0;b=j+40|0;do{c[j>>2]=0;j=j+4|0}while((j|0)<(b|0));g[f+136>>2]=+O(+(+g[e>>2]*+g[d+16>>2]));l=+g[a+20>>2];k=+g[d+20>>2];g[f+140>>2]=l>k?l:k;g[f+144>>2]=0.0;c[f>>2]=12328;if((c[(c[a+12>>2]|0)+4>>2]|0)!=3)Aa(12344,12392,42,12464);if((c[(c[d+12>>2]|0)+4>>2]|0)==2){j=f;i=h;return j|0}else Aa(14208,12392,43,12464);return 0}function Dy(a,b){a=a|0;b=b|0;var d=0;d=i;jb[c[(c[a>>2]|0)+4>>2]&127](a);Ix(b,a,148);i=d;return}function Ey(a,d,e,f){a=a|0;d=d|0;e=e|0;f=f|0;var h=0,j=0,k=0,l=0;h=i;i=i+48|0;j=h;k=c[(c[a+48>>2]|0)+12>>2]|0;c[j>>2]=7008;c[j+4>>2]=1;g[j+8>>2]=.009999999776482582;l=j+28|0;c[l+0>>2]=0;c[l+4>>2]=0;c[l+8>>2]=0;c[l+12>>2]=0;b[l+16>>1]=0;kx(k,j,c[a+56>>2]|0);Uw(d,j,e,c[(c[a+52>>2]|0)+12>>2]|0,f);i=h;return}function Fy(a){a=a|0;return}function Gy(a){a=a|0;var b=0;b=i;OB(a);i=b;return}function Hy(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var h=0,j=0,k=0.0,l=0.0;b=i;f=Hx(f,148)|0;if(!f){j=0;i=b;return j|0}c[f+4>>2]=4;c[f+48>>2]=a;c[f+52>>2]=d;c[f+56>>2]=0;c[f+60>>2]=0;c[f+124>>2]=0;c[f+128>>2]=0;h=a+16|0;j=f+8|0;e=j+40|0;do{c[j>>2]=0;j=j+4|0}while((j|0)<(e|0));g[f+136>>2]=+O(+(+g[h>>2]*+g[d+16>>2]));l=+g[a+20>>2];k=+g[d+20>>2];g[f+140>>2]=l>k?l:k;g[f+144>>2]=0.0;c[f>>2]=12552;if(c[(c[a+12>>2]|0)+4>>2]|0)Aa(12568,12616,43,12680);if(!(c[(c[d+12>>2]|0)+4>>2]|0)){j=f;i=b;return j|0}else Aa(13952,12616,44,12680);return 0}function Iy(a,b){a=a|0;b=b|0;var d=0;d=i;jb[c[(c[a>>2]|0)+4>>2]&127](a);Ix(b,a,148);i=d;return}function Jy(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,h=0,j=0,k=0.0,l=0.0,m=0.0,n=0,o=0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0;f=i;o=c[(c[a+48>>2]|0)+12>>2]|0;n=c[(c[a+52>>2]|0)+12>>2]|0;h=b+60|0;c[h>>2]=0;a=o+12|0;k=+g[d+12>>2];q=+g[a>>2];p=+g[d+8>>2];l=+g[o+16>>2];j=n+12|0;s=+g[e+12>>2];u=+g[j>>2];t=+g[e+8>>2];r=+g[n+16>>2];m=+g[e>>2]+(s*u-t*r)-(+g[d>>2]+(k*q-p*l));l=u*t+s*r+ +g[e+4>>2]-(q*p+k*l+ +g[d+4>>2]);k=+g[o+8>>2]+ +g[n+8>>2];if(m*m+l*l>k*k){i=f;return}c[b+56>>2]=0;o=c[a+4>>2]|0;n=b+48|0;c[n>>2]=c[a>>2];c[n+4>>2]=o;g[b+40>>2]=0.0;g[b+44>>2]=0.0;c[h>>2]=1;n=c[j+4>>2]|0;o=b;c[o>>2]=c[j>>2];c[o+4>>2]=n;c[b+16>>2]=0;i=f;return}function Ky(a){a=a|0;return}function Ly(a){a=a|0;var b=0;b=i;OB(a);i=b;return}function My(d,f){d=d|0;f=f|0;var h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0;j=i;i=i+192|0;q=j+100|0;s=j+88|0;p=j+64|0;h=j;r=d+64|0;k=h+0|0;m=r+0|0;l=k+64|0;do{c[k>>2]=c[m>>2];k=k+4|0;m=m+4|0}while((k|0)<(l|0));l=d+4|0;o=c[l>>2]|0;c[l>>2]=o|4;o=o>>>1;t=c[d+48>>2]|0;u=c[d+52>>2]|0;k=(a[u+38>>0]|a[t+38>>0])<<24>>24!=0;n=c[t+8>>2]|0;m=c[u+8>>2]|0;v=n+12|0;w=m+12|0;if(!k){vb[c[c[d>>2]>>2]&63](d,r,v,w);u=d+124|0;p=(c[u>>2]|0)>0;if(p){w=c[h+60>>2]|0;x=(w|0)>0;t=0;do{s=d+(t*20|0)+72|0;g[s>>2]=0.0;r=d+(t*20|0)+76|0;g[r>>2]=0.0;q=c[d+(t*20|0)+80>>2]|0;a:do if(x){y=0;while(1){v=y+1|0;if((c[h+(y*20|0)+16>>2]|0)==(q|0))break;if((v|0)<(w|0))y=v;else break a}g[s>>2]=+g[h+(y*20|0)+8>>2];g[r>>2]=+g[h+(y*20|0)+12>>2]}while(0);t=t+1|0}while((t|0)<(c[u>>2]|0))}o=o&1;if(p^(o|0)!=0){r=n+4|0;q=e[r>>1]|0;if(!(q&2)){b[r>>1]=q|2;g[n+144>>2]=0.0}q=m+4|0;n=e[q>>1]|0;if(!(n&2)){b[q>>1]=n|2;g[m+144>>2]=0.0}}}else{t=c[t+12>>2]|0;x=c[u+12>>2]|0;u=c[d+56>>2]|0;y=c[d+60>>2]|0;c[q+16>>2]=0;c[q+20>>2]=0;g[q+24>>2]=0.0;c[q+44>>2]=0;c[q+48>>2]=0;g[q+52>>2]=0.0;Xw(q,t,u);Xw(q+28|0,x,y);y=q+56|0;c[y+0>>2]=c[v+0>>2];c[y+4>>2]=c[v+4>>2];c[y+8>>2]=c[v+8>>2];c[y+12>>2]=c[v+12>>2];y=q+72|0;c[y+0>>2]=c[w+0>>2];c[y+4>>2]=c[w+4>>2];c[y+8>>2]=c[w+8>>2];c[y+12>>2]=c[w+12>>2];a[q+88>>0]=1;b[s+4>>1]=0;Yw(p,s,q);p=+g[p+16>>2]<11920928955078125.0e-22;c[d+124>>2]=0;o=o&1}m=c[l>>2]|0;c[l>>2]=p?m|2:m&-3;l=(o|0)==0;m=p^1;n=(f|0)==0;if(!(l^1|m|n))lb[c[(c[f>>2]|0)+8>>2]&127](f,d);if(!(l|p|n))lb[c[(c[f>>2]|0)+12>>2]&127](f,d);if(k|m|n){i=j;return}pb[c[(c[f>>2]|0)+16>>2]&63](f,d,h);i=j;return}function Ny(b,d){b=b|0;d=d|0;var e=0,f=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0.0,t=0.0,u=0,v=0,w=0,x=0,y=0,z=0;e=i;c[b+0>>2]=c[d+0>>2];c[b+4>>2]=c[d+4>>2];c[b+8>>2]=c[d+8>>2];c[b+12>>2]=c[d+12>>2];c[b+16>>2]=c[d+16>>2];c[b+20>>2]=c[d+20>>2];r=c[d+40>>2]|0;m=b+32|0;c[m>>2]=r;f=c[d+28>>2]|0;j=b+48|0;c[j>>2]=f;h=b+36|0;c[h>>2]=Ox(r,f*88|0)|0;f=b+40|0;c[f>>2]=Ox(c[m>>2]|0,(c[j>>2]|0)*156|0)|0;c[b+24>>2]=c[d+32>>2];c[b+28>>2]=c[d+36>>2];m=c[d+24>>2]|0;d=b+44|0;c[d>>2]=m;if((c[j>>2]|0)<=0){i=e;return}k=b+20|0;b=b+8|0;l=0;while(1){n=c[m+(l<<2)>>2]|0;o=c[n+48>>2]|0;p=c[n+52>>2]|0;r=c[o+8>>2]|0;q=c[p+8>>2]|0;m=c[n+124>>2]|0;if((m|0)<=0){f=4;break}s=+g[(c[p+12>>2]|0)+8>>2];t=+g[(c[o+12>>2]|0)+8>>2];p=c[f>>2]|0;g[p+(l*156|0)+136>>2]=+g[n+136>>2];g[p+(l*156|0)+140>>2]=+g[n+140>>2];g[p+(l*156|0)+144>>2]=+g[n+144>>2];z=r+8|0;c[p+(l*156|0)+112>>2]=c[z>>2];y=q+8|0;c[p+(l*156|0)+116>>2]=c[y>>2];w=r+120|0;g[p+(l*156|0)+120>>2]=+g[w>>2];x=q+120|0;g[p+(l*156|0)+124>>2]=+g[x>>2];v=r+128|0;g[p+(l*156|0)+128>>2]=+g[v>>2];u=q+128|0;g[p+(l*156|0)+132>>2]=+g[u>>2];c[p+(l*156|0)+152>>2]=l;c[p+(l*156|0)+148>>2]=m;o=p+(l*156|0)+80|0;c[o+0>>2]=0;c[o+4>>2]=0;c[o+8>>2]=0;c[o+12>>2]=0;c[o+16>>2]=0;c[o+20>>2]=0;c[o+24>>2]=0;c[o+28>>2]=0;o=c[h>>2]|0;c[o+(l*88|0)+32>>2]=c[z>>2];c[o+(l*88|0)+36>>2]=c[y>>2];g[o+(l*88|0)+40>>2]=+g[w>>2];g[o+(l*88|0)+44>>2]=+g[x>>2];x=r+28|0;r=c[x+4>>2]|0;w=o+(l*88|0)+48|0;c[w>>2]=c[x>>2];c[w+4>>2]=r;w=q+28|0;r=c[w+4>>2]|0;q=o+(l*88|0)+56|0;c[q>>2]=c[w>>2];c[q+4>>2]=r;g[o+(l*88|0)+64>>2]=+g[v>>2];g[o+(l*88|0)+68>>2]=+g[u>>2];q=n+104|0;r=c[q+4>>2]|0;u=o+(l*88|0)+16|0;c[u>>2]=c[q>>2];c[u+4>>2]=r;u=n+112|0;r=c[u+4>>2]|0;q=o+(l*88|0)+24|0;c[q>>2]=c[u>>2];c[q+4>>2]=r;c[o+(l*88|0)+84>>2]=m;g[o+(l*88|0)+76>>2]=t;g[o+(l*88|0)+80>>2]=s;c[o+(l*88|0)+72>>2]=c[n+120>>2];q=0;do{r=n+(q*20|0)+64|0;if(!(a[k>>0]|0)){g[p+(l*156|0)+(q*36|0)+16>>2]=0.0;g[p+(l*156|0)+(q*36|0)+20>>2]=0.0}else{g[p+(l*156|0)+(q*36|0)+16>>2]=+g[b>>2]*+g[n+(q*20|0)+72>>2];g[p+(l*156|0)+(q*36|0)+20>>2]=+g[b>>2]*+g[n+(q*20|0)+76>>2]}x=p+(l*156|0)+(q*36|0)|0;g[p+(l*156|0)+(q*36|0)+24>>2]=0.0;g[p+(l*156|0)+(q*36|0)+28>>2]=0.0;g[p+(l*156|0)+(q*36|0)+32>>2]=0.0;z=o+(l*88|0)+(q<<3)|0;c[x+0>>2]=0;c[x+4>>2]=0;c[x+8>>2]=0;c[x+12>>2]=0;x=r;y=c[x+4>>2]|0;c[z>>2]=c[x>>2];c[z+4>>2]=y;q=q+1|0}while((q|0)!=(m|0));l=l+1|0;if((l|0)>=(c[j>>2]|0)){f=12;break}m=c[d>>2]|0}if((f|0)==4)Aa(13160,13176,73,13240);else if((f|0)==12){i=e;return}}function Oy(a){a=a|0;var b=0,d=0,e=0,f=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0,H=0,I=0.0,J=0.0,K=0.0,L=0.0,M=0.0,N=0.0,P=0.0,S=0.0,T=0.0,U=0,V=0,W=0,X=0,Y=0,Z=0.0,_=0.0,$=0.0,aa=0.0,ba=0.0;b=i;i=i+32|0;e=b;d=a+48|0;if((c[d>>2]|0)<=0){i=b;return}j=a+40|0;h=a+36|0;k=a+44|0;f=a+24|0;n=a+28|0;p=e+4|0;m=e+8|0;a=e+24|0;l=0;while(1){o=c[j>>2]|0;U=c[h>>2]|0;G=c[(c[k>>2]|0)+(c[o+(l*156|0)+152>>2]<<2)>>2]|0;W=c[o+(l*156|0)+112>>2]|0;H=c[o+(l*156|0)+116>>2]|0;D=+g[o+(l*156|0)+120>>2];C=+g[o+(l*156|0)+124>>2];q=+g[o+(l*156|0)+128>>2];r=+g[o+(l*156|0)+132>>2];X=U+(l*88|0)+48|0;N=+g[X>>2];P=+g[X+4>>2];X=U+(l*88|0)+56|0;M=+g[X>>2];T=+g[X+4>>2];X=c[f>>2]|0;Y=X+(W*12|0)|0;x=+g[Y>>2];y=+g[Y+4>>2];I=+g[X+(W*12|0)+8>>2];Y=c[n>>2]|0;V=Y+(W*12|0)|0;t=+g[V>>2];w=+g[V+4>>2];u=+g[Y+(W*12|0)+8>>2];W=X+(H*12|0)|0;z=+g[W>>2];A=+g[W+4>>2];J=+g[X+(H*12|0)+8>>2];X=Y+(H*12|0)|0;B=+g[X>>2];v=+g[X+4>>2];s=+g[Y+(H*12|0)+8>>2];H=c[G+124>>2]|0;if((H|0)<=0){d=4;break}E=+g[U+(l*88|0)+80>>2];F=+g[U+(l*88|0)+76>>2];K=+R(+I);L=+Q(+I);I=+R(+J);J=+Q(+J);S=x-(N*L-P*K);P=y-(P*L+N*K);N=z-(M*J-T*I);M=A-(T*J+M*I);U=c[G+120>>2]|0;a:do if((U|0)==2){_=+g[G+104>>2];T=+g[G+108>>2];Z=J*_-I*T;T=_*I+J*T;_=+Z;$=+T;U=e;g[U>>2]=_;g[U+4>>2]=$;$=+g[G+112>>2];_=+g[G+116>>2];N=N+(J*$-I*_);J=$*I+J*_+M;M=Z;I=T;U=0;do{$=+g[G+(U*20|0)+64>>2];_=+g[G+(U*20|0)+68>>2];T=S+(L*$-K*_);_=$*K+L*_+P;$=E-(M*(T-N)+(_-J)*I);Z=T+M*$;$=_+I*$;T=T-M*F;_=_-I*F;ba=+((T+Z)*.5);aa=+((_+$)*.5);Y=e+(U<<3)+8|0;g[Y>>2]=ba;g[Y+4>>2]=aa;g[e+(U<<2)+24>>2]=+g[e>>2]*(T-Z)+ +g[p>>2]*(_-$);U=U+1|0;M=+g[e>>2];I=+g[p>>2]}while((U|0)<(H|0));aa=+-M;ba=+-I;Y=e;g[Y>>2]=aa;g[Y+4>>2]=ba}else if(!U){g[e>>2]=1.0;g[p>>2]=0.0;aa=+g[G+112>>2];ba=+g[G+116>>2];S=S+(L*aa-K*ba);K=aa*K+L*ba+P;ba=+g[G+64>>2];aa=+g[G+68>>2];L=N+(J*ba-I*aa);I=ba*I+J*aa+M;aa=S-L;ba=K-I;if(aa*aa+ba*ba>1.4210854715202004e-14){M=L-S;J=I-K;ba=+M;N=+J;Y=e;g[Y>>2]=ba;g[Y+4>>2]=N;N=+O(+(M*M+J*J));if(!(N<1.1920928955078125e-7)){ba=1.0/N;M=M*ba;g[e>>2]=M;J=J*ba;g[p>>2]=J}}else{M=1.0;J=0.0}$=S+M*F;ba=K+J*F;_=L-M*E;aa=I-J*E;T=+(($+_)*.5);Z=+((ba+aa)*.5);Y=m;g[Y>>2]=T;g[Y+4>>2]=Z;g[a>>2]=M*(_-$)+J*(aa-ba)}else if((U|0)==1){$=+g[G+104>>2];ba=+g[G+108>>2];aa=L*$-K*ba;ba=$*K+L*ba;$=+aa;_=+ba;U=e;g[U>>2]=$;g[U+4>>2]=_;_=+g[G+112>>2];$=+g[G+116>>2];S=S+(L*_-K*$);K=_*K+L*$+P;L=aa;P=ba;U=0;while(1){ba=+g[G+(U*20|0)+64>>2];aa=+g[G+(U*20|0)+68>>2];_=N+(J*ba-I*aa);aa=ba*I+J*aa+M;ba=F-(L*(_-S)+(aa-K)*P);$=_+L*ba;ba=aa+P*ba;_=_-L*E;aa=aa-P*E;T=+((_+$)*.5);Z=+((aa+ba)*.5);Y=e+(U<<3)+8|0;g[Y>>2]=T;g[Y+4>>2]=Z;g[e+(U<<2)+24>>2]=+g[e>>2]*(_-$)+ +g[p>>2]*(aa-ba);U=U+1|0;if((U|0)>=(H|0))break a;L=+g[e>>2];P=+g[p>>2]}}while(0);V=o+(l*156|0)+72|0;Y=e;H=c[Y+4>>2]|0;G=V;c[G>>2]=c[Y>>2];c[G+4>>2]=H;G=o+(l*156|0)+148|0;H=c[G>>2]|0;do if((H|0)>0){U=o+(l*156|0)+76|0;C=D+C;W=o+(l*156|0)+140|0;X=0;do{F=+g[e+(X<<3)+8>>2];D=F-x;aa=+g[e+(X<<3)+12>>2];J=+D;I=+(aa-y);Y=o+(l*156|0)+(X*36|0)|0;g[Y>>2]=J;g[Y+4>>2]=I;F=F-z;I=+F;aa=+(aa-A);Y=o+(l*156|0)+(X*36|0)+8|0;g[Y>>2]=I;g[Y+4>>2]=aa;aa=+g[U>>2];I=+g[o+(l*156|0)+(X*36|0)+4>>2];J=+g[V>>2];ba=D*aa-I*J;E=+g[o+(l*156|0)+(X*36|0)+12>>2];J=aa*F-J*E;J=C+ba*q*ba+J*r*J;if(J>0.0)J=1.0/J;else J=0.0;g[o+(l*156|0)+(X*36|0)+24>>2]=J;J=+g[U>>2];aa=-+g[V>>2];ba=D*aa-J*I;J=F*aa-J*E;J=C+ba*q*ba+J*r*J;if(J>0.0)J=1.0/J;else J=0.0;g[o+(l*156|0)+(X*36|0)+28>>2]=J;Y=o+(l*156|0)+(X*36|0)+32|0;g[Y>>2]=0.0;D=+g[V>>2]*(B-s*E-t+u*I)+ +g[U>>2]*(v+s*F-w-u*D);if(D<-1.0)g[Y>>2]=-(D*+g[W>>2]);X=X+1|0}while((X|0)!=(H|0));if((c[G>>2]|0)==2){$=+g[U>>2];t=+g[V>>2];_=+g[o+(l*156|0)>>2]*$- +g[o+(l*156|0)+4>>2]*t;s=$*+g[o+(l*156|0)+8>>2]-t*+g[o+(l*156|0)+12>>2];aa=$*+g[o+(l*156|0)+36>>2]-t*+g[o+(l*156|0)+40>>2];t=$*+g[o+(l*156|0)+44>>2]-t*+g[o+(l*156|0)+48>>2];$=q*_;ba=r*s;s=C+_*$+s*ba;q=C+aa*q*aa+t*r*t;r=C+$*aa+ba*t;t=s*q-r*r;if(!(s*s>2]=1;break}g[o+(l*156|0)+96>>2]=s;g[o+(l*156|0)+100>>2]=r;g[o+(l*156|0)+104>>2]=r;g[o+(l*156|0)+108>>2]=q;if(t!=0.0)t=1.0/t;ba=-(t*r);g[o+(l*156|0)+80>>2]=q*t;g[o+(l*156|0)+84>>2]=ba;g[o+(l*156|0)+88>>2]=ba;g[o+(l*156|0)+92>>2]=s*t}}while(0);l=l+1|0;if((l|0)>=(c[d>>2]|0)){d=32;break}}if((d|0)==4)Aa(13256,13176,171,13288);else if((d|0)==32){i=b;return}}function Py(a){a=a|0;var b=0,d=0,e=0,f=0,h=0,j=0,k=0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0,I=0.0,J=0.0,K=0,L=0.0,M=0.0,N=0.0,O=0.0,P=0.0,Q=0,R=0,S=0,T=0.0,U=0.0;b=i;e=a+48|0;if((c[e>>2]|0)<=0){i=b;return}d=a+40|0;h=a+28|0;H=c[h>>2]|0;j=0;a:while(1){r=c[d>>2]|0;a=c[r+(j*156|0)+112>>2]|0;f=c[r+(j*156|0)+116>>2]|0;o=+g[r+(j*156|0)+120>>2];m=+g[r+(j*156|0)+128>>2];n=+g[r+(j*156|0)+124>>2];l=+g[r+(j*156|0)+132>>2];K=c[r+(j*156|0)+148>>2]|0;k=H+(a*12|0)|0;S=k;R=H+(f*12|0)|0;Q=r+(j*156|0)+72|0;q=+g[Q>>2];p=+g[Q+4>>2];y=-q;z=+g[r+(j*156|0)+136>>2];Q=(K|0)==1;if((K+ -1|0)>>>0>=2){d=5;break}u=+g[R+4>>2];w=+g[R>>2];v=+g[S+4>>2];R=r+(j*156|0)+144|0;x=+g[S>>2];S=0;t=+g[H+(a*12|0)+8>>2];s=+g[H+(f*12|0)+8>>2];do{O=+g[r+(j*156|0)+(S*36|0)+12>>2];M=+g[r+(j*156|0)+(S*36|0)+8>>2];L=+g[r+(j*156|0)+(S*36|0)+4>>2];J=+g[r+(j*156|0)+(S*36|0)>>2];P=z*+g[r+(j*156|0)+(S*36|0)+16>>2];H=r+(j*156|0)+(S*36|0)+20|0;N=+g[H>>2];G=N- +g[r+(j*156|0)+(S*36|0)+28>>2]*(p*(w-s*O-x+t*L)+(u+s*M-v-t*J)*y- +g[R>>2]);I=-P;P=G>2]=P;P=p*N;N=N*y;x=x-o*P;v=v-o*N;t=t-m*(J*N-L*P);w=w+n*P;u=u+n*N;s=s+l*(M*N-O*P);S=S+1|0}while((S|0)!=(K|0));do if(!Q){K=r+(j*156|0)+16|0;M=+g[K>>2];H=r+(j*156|0)+52|0;L=+g[H>>2];if(!(M>=0.0)|!(L>=0.0)){d=10;break a}A=+g[r+(j*156|0)+12>>2];z=+g[r+(j*156|0)+8>>2];C=+g[r+(j*156|0)+4>>2];F=+g[r+(j*156|0)>>2];y=+g[r+(j*156|0)+48>>2];B=+g[r+(j*156|0)+44>>2];E=+g[r+(j*156|0)+40>>2];D=+g[r+(j*156|0)+36>>2];J=+g[r+(j*156|0)+104>>2];N=+g[r+(j*156|0)+100>>2];G=q*(w-s*A-x+t*C)+p*(u+s*z-v-t*F)- +g[r+(j*156|0)+32>>2]-(M*+g[r+(j*156|0)+96>>2]+L*J);I=q*(w-s*y-x+t*E)+p*(u+s*B-v-t*D)- +g[r+(j*156|0)+68>>2]-(M*N+L*+g[r+(j*156|0)+108>>2]);U=+g[r+(j*156|0)+80>>2]*G+ +g[r+(j*156|0)+88>>2]*I;T=G*+g[r+(j*156|0)+84>>2]+I*+g[r+(j*156|0)+92>>2];O=-U;P=-T;if(!(!(U<=-0.0)|!(T<=-0.0))){M=O-M;T=P-L;N=q*M;M=p*M;U=q*T;T=p*T;J=N+U;L=M+T;g[K>>2]=O;g[H>>2]=P;x=x-o*J;v=v-o*L;w=w+n*J;u=u+n*L;t=t-m*(F*M-C*N+(D*T-E*U));s=s+l*(z*M-A*N+(B*T-y*U));break}U=G*+g[r+(j*156|0)+24>>2];O=-U;if(U<=-0.0?I+N*O>=0.0:0){N=O-M;T=0.0-L;P=q*N;N=p*N;U=q*T;T=p*T;L=U+P;M=T+N;g[K>>2]=O;g[H>>2]=0.0;x=x-o*L;v=v-o*M;w=w+n*L;u=u+n*M;t=t-m*(N*F-P*C+(T*D-U*E));s=s+l*(N*z-P*A+(T*B-U*y));break}U=I*+g[r+(j*156|0)+60>>2];N=-U;if(U<=-0.0?G+J*N>=0.0:0){O=0.0-M;T=N-L;P=q*O;O=p*O;U=q*T;T=p*T;L=P+U;M=O+T;g[K>>2]=0.0;g[H>>2]=N;x=x-o*L;v=v-o*M;w=w+n*L;u=u+n*M;t=t-m*(O*F-P*C+(T*D-U*E));s=s+l*(O*z-P*A+(T*B-U*y));break}if(!(!(G>=0.0)|!(I>=0.0))){O=0.0-M;T=0.0-L;P=q*O;O=p*O;U=q*T;T=p*T;M=P+U;N=O+T;g[K>>2]=0.0;g[H>>2]=0.0;x=x-o*M;v=v-o*N;w=w+n*M;u=u+n*N;t=t-m*(O*F-P*C+(T*D-U*E));s=s+l*(O*z-P*A+(T*B-U*y))}}else{H=0;while(1){T=+g[r+(j*156|0)+(H*36|0)+12>>2];O=+g[r+(j*156|0)+(H*36|0)+8>>2];N=+g[r+(j*156|0)+(H*36|0)+4>>2];M=+g[r+(j*156|0)+(H*36|0)>>2];S=r+(j*156|0)+(H*36|0)+16|0;P=+g[S>>2];U=P- +g[r+(j*156|0)+(H*36|0)+24>>2]*(q*(w-s*T-x+t*N)+p*(u+s*O-v-t*M)- +g[r+(j*156|0)+(H*36|0)+32>>2]);U=U>0.0?U:0.0;P=U-P;g[S>>2]=U;U=q*P;P=p*P;x=x-o*U;v=v-o*P;t=t-m*(M*P-N*U);w=w+n*U;u=u+n*P;s=s+l*(O*P-T*U);if(!H)break;else H=H+1|0}}while(0);U=+x;T=+v;H=k;g[H>>2]=U;g[H+4>>2]=T;H=c[h>>2]|0;g[H+(a*12|0)+8>>2]=t;T=+w;U=+u;H=H+(f*12|0)|0;g[H>>2]=T;g[H+4>>2]=U;H=c[h>>2]|0;g[H+(f*12|0)+8>>2]=s;j=j+1|0;if((j|0)>=(c[e>>2]|0)){d=22;break}}if((d|0)==5)Aa(13320,13176,314,13360);else if((d|0)==10)Aa(13392,13176,412,13360);else if((d|0)==22){i=b;return}}function Qy(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var h=0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0,s=0.0,t=0.0,u=0.0,v=0,w=0;h=i;if((c[b+84>>2]|0)<=0)Aa(13424,13176,623,16288);r=c[b+72>>2]|0;if((r|0)==2){v=e+12|0;j=+g[v>>2];k=+g[b+16>>2];r=e+8|0;l=+g[r>>2];q=+g[b+20>>2];p=j*k-l*q;q=k*l+j*q;j=+p;l=+q;w=a;g[w>>2]=j;g[w+4>>2]=l;l=+g[v>>2];j=+g[b+24>>2];k=+g[r>>2];m=+g[b+28>>2];s=+g[d+12>>2];u=+g[b+(f<<3)>>2];t=+g[d+8>>2];o=+g[b+(f<<3)+4>>2];n=+g[d>>2]+(s*u-t*o);o=u*t+s*o+ +g[d+4>>2];g[a+16>>2]=p*(n-(+g[e>>2]+(l*j-k*m)))+(o-(j*k+l*m+ +g[e+4>>2]))*q- +g[b+76>>2]- +g[b+80>>2];n=+n;o=+o;f=a+8|0;g[f>>2]=n;g[f+4>>2]=o;p=+-p;q=+-q;f=a;g[f>>2]=p;g[f+4>>2]=q;i=h;return}else if(!r){m=+g[d+12>>2];n=+g[b+24>>2];u=+g[d+8>>2];l=+g[b+28>>2];j=+g[d>>2]+(m*n-u*l);l=n*u+m*l+ +g[d+4>>2];m=+g[e+12>>2];u=+g[b>>2];n=+g[e+8>>2];o=+g[b+4>>2];k=+g[e>>2]+(m*u-n*o);o=u*n+m*o+ +g[e+4>>2];m=k-j;n=o-l;u=+m;p=+n;w=a;g[w>>2]=u;g[w+4>>2]=p;p=+O(+(m*m+n*n));if(p<1.1920928955078125e-7){p=m;q=n}else{q=1.0/p;p=m*q;g[a>>2]=p;q=n*q;g[a+4>>2]=q}t=+((j+k)*.5);u=+((l+o)*.5);w=a+8|0;g[w>>2]=t;g[w+4>>2]=u;g[a+16>>2]=m*p+n*q- +g[b+76>>2]- +g[b+80>>2];i=h;return}else if((r|0)==1){v=d+12|0;n=+g[v>>2];o=+g[b+16>>2];w=d+8|0;p=+g[w>>2];s=+g[b+20>>2];m=n*o-p*s;s=o*p+n*s;n=+m;p=+s;r=a;g[r>>2]=n;g[r+4>>2]=p;p=+g[v>>2];n=+g[b+24>>2];o=+g[w>>2];q=+g[b+28>>2];l=+g[e+12>>2];j=+g[b+(f<<3)>>2];k=+g[e+8>>2];u=+g[b+(f<<3)+4>>2];t=+g[e>>2]+(l*j-k*u);u=j*k+l*u+ +g[e+4>>2];g[a+16>>2]=m*(t-(+g[d>>2]+(p*n-o*q)))+(u-(n*o+p*q+ +g[d+4>>2]))*s- +g[b+76>>2]- +g[b+80>>2];t=+t;u=+u;w=a+8|0;g[w>>2]=t;g[w+4>>2]=u;i=h;return}else{i=h;return}}function Ry(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var h=0,j=0,k=0.0,l=0.0;b=i;f=Hx(f,148)|0;if(!f){j=0;i=b;return j|0}c[f+4>>2]=4;c[f+48>>2]=a;c[f+52>>2]=d;c[f+56>>2]=0;c[f+60>>2]=0;c[f+124>>2]=0;c[f+128>>2]=0;h=a+16|0;j=f+8|0;e=j+40|0;do{c[j>>2]=0;j=j+4|0}while((j|0)<(e|0));g[f+136>>2]=+O(+(+g[h>>2]*+g[d+16>>2]));l=+g[a+20>>2];k=+g[d+20>>2];g[f+140>>2]=l>k?l:k;g[f+144>>2]=0.0;c[f>>2]=13456;if((c[(c[a+12>>2]|0)+4>>2]|0)!=1)Aa(13632,13472,40,13536);if(!(c[(c[d+12>>2]|0)+4>>2]|0)){j=f;i=b;return j|0}else Aa(13952,13472,41,13536);return 0}function Sy(a,b){a=a|0;b=b|0;var d=0;d=i;jb[c[(c[a>>2]|0)+4>>2]&127](a);Ix(b,a,148);i=d;return}function Ty(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0;f=i;Tw(b,c[(c[a+48>>2]|0)+12>>2]|0,d,c[(c[a+52>>2]|0)+12>>2]|0,e);i=f;return}function Uy(a){a=a|0;return}function Vy(a){a=a|0;var b=0;b=i;OB(a);i=b;return}function Wy(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var h=0,j=0,k=0.0,l=0.0;b=i;f=Hx(f,148)|0;if(!f){j=0;i=b;return j|0}c[f+4>>2]=4;c[f+48>>2]=a;c[f+52>>2]=d;c[f+56>>2]=0;c[f+60>>2]=0;c[f+124>>2]=0;c[f+128>>2]=0;h=a+16|0;j=f+8|0;e=j+40|0;do{c[j>>2]=0;j=j+4|0}while((j|0)<(e|0));g[f+136>>2]=+O(+(+g[h>>2]*+g[d+16>>2]));l=+g[a+20>>2];k=+g[d+20>>2];g[f+140>>2]=l>k?l:k;g[f+144>>2]=0.0;c[f>>2]=13616;if((c[(c[a+12>>2]|0)+4>>2]|0)!=1)Aa(13632,13680,40,13752);if((c[(c[d+12>>2]|0)+4>>2]|0)==2){j=f;i=b;return j|0}else Aa(14208,13680,41,13752);return 0}function Xy(a,b){a=a|0;b=b|0;var d=0;d=i;jb[c[(c[a>>2]|0)+4>>2]&127](a);Ix(b,a,148);i=d;return}function Yy(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0;f=i;Uw(b,c[(c[a+48>>2]|0)+12>>2]|0,d,c[(c[a+52>>2]|0)+12>>2]|0,e);i=f;return}function Zy(a){a=a|0;return}function _y(a){a=a|0;var b=0;b=i;OB(a);i=b;return}function $y(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var h=0,j=0,k=0.0,l=0.0;b=i;f=Hx(f,148)|0;if(!f){j=0;i=b;return j|0}c[f+4>>2]=4;c[f+48>>2]=a;c[f+52>>2]=d;c[f+56>>2]=0;c[f+60>>2]=0;c[f+124>>2]=0;c[f+128>>2]=0;h=a+16|0;j=f+8|0;e=j+40|0;do{c[j>>2]=0;j=j+4|0}while((j|0)<(e|0));g[f+136>>2]=+O(+(+g[h>>2]*+g[d+16>>2]));l=+g[a+20>>2];k=+g[d+20>>2];g[f+140>>2]=l>k?l:k;g[f+144>>2]=0.0;c[f>>2]=13832;if((c[(c[a+12>>2]|0)+4>>2]|0)!=2)Aa(14072,13848,40,13920);if(!(c[(c[d+12>>2]|0)+4>>2]|0)){j=f;i=b;return j|0}else Aa(13952,13848,41,13920);return 0}function az(a,b){a=a|0;b=b|0;var d=0;d=i;jb[c[(c[a>>2]|0)+4>>2]&127](a);Ix(b,a,148);i=d;return}function bz(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,h=0,j=0,l=0.0,m=0.0,n=0.0,o=0,p=0,q=0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0;f=i;j=c[(c[a+48>>2]|0)+12>>2]|0;p=c[(c[a+52>>2]|0)+12>>2]|0;h=b+60|0;c[h>>2]=0;a=p+12|0;x=+g[e+12>>2];m=+g[a>>2];n=+g[e+8>>2];y=+g[p+16>>2];l=+g[e>>2]+(x*m-n*y)- +g[d>>2];y=m*n+x*y+ +g[e+4>>2]- +g[d+4>>2];x=+g[d+12>>2];n=+g[d+8>>2];m=l*x+y*n;n=x*y-l*n;l=+g[j+8>>2]+ +g[p+8>>2];p=c[j+276>>2]|0;do if((p|0)>0){d=0;e=0;r=-3.4028234663852886e+38;while(1){s=(m- +g[j+(d<<3)+20>>2])*+g[j+(d<<3)+148>>2]+(n- +g[j+(d<<3)+24>>2])*+g[j+(d<<3)+152>>2];if(s>l){d=19;break}z=s>r;r=z?s:r;e=z?d:e;d=d+1|0;if((d|0)>=(p|0)){d=4;break}}if((d|0)==4){z=r<1.1920928955078125e-7;break}else if((d|0)==19){i=f;return}}else{e=0;z=1}while(0);q=e+1|0;o=j+(e<<3)+20|0;d=c[o>>2]|0;o=c[o+4>>2]|0;x=(c[k>>2]=d,+g[k>>2]);t=(c[k>>2]=o,+g[k>>2]);q=j+(((q|0)<(p|0)?q:0)<<3)+20|0;p=c[q>>2]|0;q=c[q+4>>2]|0;y=(c[k>>2]=p,+g[k>>2]);w=(c[k>>2]=q,+g[k>>2]);if(z){c[h>>2]=1;c[b+56>>2]=1;z=j+(e<<3)+148|0;q=c[z+4>>2]|0;p=b+40|0;c[p>>2]=c[z>>2];c[p+4>>2]=q;x=+((x+y)*.5);y=+((t+w)*.5);p=b+48|0;g[p>>2]=x;g[p+4>>2]=y;p=a;q=c[p+4>>2]|0;z=b;c[z>>2]=c[p>>2];c[z+4>>2]=q;c[b+16>>2]=0;i=f;return}s=m-x;u=n-t;r=m-y;v=n-w;if(s*(y-x)+u*(w-t)<=0.0){m=s*s+u*u;if(m>l*l){i=f;return}c[h>>2]=1;c[b+56>>2]=1;h=b+40|0;y=+s;l=+u;z=h;g[z>>2]=y;g[z+4>>2]=l;l=+O(+m);if(!(l<1.1920928955078125e-7)){y=1.0/l;g[h>>2]=s*y;g[b+44>>2]=u*y}p=b+48|0;c[p>>2]=d;c[p+4>>2]=o;p=a;q=c[p+4>>2]|0;z=b;c[z>>2]=c[p>>2];c[z+4>>2]=q;c[b+16>>2]=0;i=f;return}if(!(r*(x-y)+v*(t-w)<=0.0)){r=(x+y)*.5;s=(t+w)*.5;d=j+(e<<3)+148|0;if((m-r)*+g[d>>2]+(n-s)*+g[j+(e<<3)+152>>2]>l){i=f;return}c[h>>2]=1;c[b+56>>2]=1;z=d;q=c[z+4>>2]|0;p=b+40|0;c[p>>2]=c[z>>2];c[p+4>>2]=q;x=+r;y=+s;p=b+48|0;g[p>>2]=x;g[p+4>>2]=y;p=a;q=c[p+4>>2]|0;z=b;c[z>>2]=c[p>>2];c[z+4>>2]=q;c[b+16>>2]=0;i=f;return}m=r*r+v*v;if(m>l*l){i=f;return}c[h>>2]=1;c[b+56>>2]=1;h=b+40|0;y=+r;l=+v;z=h;g[z>>2]=y;g[z+4>>2]=l;l=+O(+m);if(!(l<1.1920928955078125e-7)){y=1.0/l;g[h>>2]=r*y;g[b+44>>2]=v*y}z=b+48|0;c[z>>2]=p;c[z+4>>2]=q;p=a;q=c[p+4>>2]|0;z=b;c[z>>2]=c[p>>2];c[z+4>>2]=q;c[b+16>>2]=0;i=f;return}function cz(a){a=a|0;return}function dz(a){a=a|0;var b=0;b=i;OB(a);i=b;return}function ez(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var h=0,j=0,k=0.0,l=0.0;b=i;f=Hx(f,148)|0;if(!f){j=0;i=b;return j|0}c[f+4>>2]=4;c[f+48>>2]=a;c[f+52>>2]=d;c[f+56>>2]=0;c[f+60>>2]=0;c[f+124>>2]=0;c[f+128>>2]=0;h=a+16|0;j=f+8|0;e=j+40|0;do{c[j>>2]=0;j=j+4|0}while((j|0)<(e|0));g[f+136>>2]=+O(+(+g[h>>2]*+g[d+16>>2]));l=+g[a+20>>2];k=+g[d+20>>2];g[f+140>>2]=l>k?l:k;g[f+144>>2]=0.0;c[f>>2]=14056;if((c[(c[a+12>>2]|0)+4>>2]|0)!=2)Aa(14072,14120,43,14184);if((c[(c[d+12>>2]|0)+4>>2]|0)==2){j=f;i=b;return j|0}else Aa(14208,14120,44,14184);return 0}function fz(a,b){a=a|0;b=b|0;var d=0;d=i;jb[c[(c[a>>2]|0)+4>>2]&127](a);Ix(b,a,148);i=d;return}function gz(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var h=0,j=0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0,q=0,r=0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0,B=0.0,C=0.0,D=0.0,E=0,F=0,G=0.0,H=0,I=0,J=0.0,K=0,L=0.0,M=0.0,N=0.0;h=i;i=i+80|0;F=h+76|0;r=h+72|0;p=h;q=h+48|0;j=h+24|0;A=c[(c[b+48>>2]|0)+12>>2]|0;E=c[(c[b+52>>2]|0)+12>>2]|0;b=d+60|0;c[b>>2]=0;k=+g[A+8>>2]+ +g[E+8>>2];c[F>>2]=0;l=+Vw(F,A,e,E,f);if(l>k){i=h;return}c[r>>2]=0;m=+Vw(r,E,f,A,e);if(m>k){i=h;return}if(m>l+.0005000000237487257){s=+g[f>>2];v=+g[f+4>>2];u=+g[f+8>>2];t=+g[f+12>>2];o=+g[e>>2];l=+g[e+4>>2];m=+g[e+8>>2];n=+g[e+12>>2];r=c[r>>2]|0;c[d+56>>2]=2;f=1;e=E}else{s=+g[e>>2];v=+g[e+4>>2];u=+g[e+8>>2];t=+g[e+12>>2];o=+g[f>>2];l=+g[f+4>>2];m=+g[f+8>>2];n=+g[f+12>>2];r=c[F>>2]|0;c[d+56>>2]=1;f=0;e=A;A=E}E=c[A+276>>2]|0;if((r|0)<=-1)Aa(5264,5304,74,5360);F=c[e+276>>2]|0;if((F|0)<=(r|0))Aa(5264,5304,74,5360);w=+g[e+(r<<3)+148>>2];L=+g[e+(r<<3)+152>>2];x=t*w-u*L;L=u*w+t*L;w=n*x+m*L;x=n*L-m*x;if((E|0)>0){H=0;K=0;y=3.4028234663852886e+38;while(1){z=w*+g[A+(H<<3)+148>>2]+x*+g[A+(H<<3)+152>>2];I=z>2];D=+g[A+(K<<3)+24>>2];B=+(o+(n*z-m*D));D=+(l+(m*z+n*D));H=p;g[H>>2]=B;g[H+4>>2]=D;H=r&255;E=p+8|0;a[E>>0]=H;a[E+1>>0]=K;a[E+2>>0]=1;a[E+3>>0]=0;D=+g[A+(I<<3)+20>>2];B=+g[A+(I<<3)+24>>2];z=+(o+(n*D-m*B));B=+(l+(m*D+n*B));A=p+12|0;g[A>>2]=z;g[A+4>>2]=B;A=p+20|0;a[A>>0]=H;a[A+1>>0]=I;a[A+2>>0]=1;a[A+3>>0]=0;A=r+1|0;A=(A|0)<(F|0)?A:0;K=e+(r<<3)+20|0;B=+g[K>>2];z=+g[K+4>>2];K=e+(A<<3)+20|0;D=+g[K>>2];C=+g[K+4>>2];G=D-B;L=C-z;w=+O(+(G*G+L*L));if(!(w<1.1920928955078125e-7)){J=1.0/w;G=G*J;L=L*J}J=t*G-u*L;x=t*L+u*G;y=-J;N=s+(t*B-u*z);M=v+(u*B+t*z);w=N*x+M*y;if((Ww(q,p,y,-x,k-(N*J+M*x),r)|0)<2){i=h;return}if((Ww(j,q,J,x,k+((s+(t*D-u*C))*J+(v+(u*D+t*C))*x),A)|0)<2){i=h;return}N=+L;M=+-G;p=d+40|0;g[p>>2]=N;g[p+4>>2]=M;M=+((B+D)*.5);N=+((z+C)*.5);p=d+48|0;g[p>>2]=M;g[p+4>>2]=N;p=f<<24>>24==0;q=0;r=0;do{s=+g[j+(q*12|0)>>2];t=+g[j+(q*12|0)+4>>2];if(x*s+t*y-w<=k){N=s-o;L=t-l;M=+(n*N+m*L);N=+(n*L-m*N);e=d+(r*20|0)|0;g[e>>2]=M;g[e+4>>2]=N;e=d+(r*20|0)+16|0;f=c[j+(q*12|0)+8>>2]|0;c[e>>2]=f;if(!p){a[e>>0]=f>>>8;a[e+1>>0]=f;a[e+2>>0]=f>>>24;a[e+3>>0]=f>>>16}r=r+1|0}q=q+1|0}while((q|0)!=2);c[b>>2]=r;i=h;return}function hz(a){a=a|0;return}function iz(a){a=a|0;var b=0;b=i;OB(a);i=b;return}function jz(b,d){b=b|0;d=d|0;var e=0.0,f=0.0,h=0.0,j=0.0,l=0,m=0,n=0,o=0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,P=0,S=0,T=0,U=0,V=0.0;o=i;A=c[b+48>>2]|0;T=c[A+8>>2]|0;l=b+108|0;c[l>>2]=T;S=c[b+52>>2]|0;N=c[S+8>>2]|0;n=b+112|0;c[n>>2]=N;L=A+28|0;M=c[L>>2]|0;L=c[L+4>>2]|0;H=b+140|0;c[H>>2]=M;c[H+4>>2]=L;H=S+28|0;K=c[H>>2]|0;H=c[H+4>>2]|0;J=b+148|0;c[J>>2]=K;c[J+4>>2]=H;J=b+156|0;g[J>>2]=+g[A+120>>2];H=b+160|0;g[H>>2]=+g[S+120>>2];I=b+164|0;g[I>>2]=+g[A+128>>2];A=b+168|0;g[A>>2]=+g[S+128>>2];S=c[d+24>>2]|0;m=S+(T*12|0)|0;v=+g[m>>2];w=+g[m+4>>2];e=+g[S+(T*12|0)+8>>2];m=d+28|0;P=c[m>>2]|0;U=P+(T*12|0)|0;u=+g[U>>2];t=+g[U+4>>2];h=+g[P+(T*12|0)+8>>2];T=S+(N*12|0)|0;C=+g[T>>2];G=+g[T+4>>2];E=+g[S+(N*12|0)+8>>2];S=P+(N*12|0)|0;s=+g[S>>2];f=+g[S+4>>2];j=+g[P+(N*12|0)+8>>2];r=+R(+e);e=+Q(+e);D=+R(+E);E=+Q(+E);F=+g[b+80>>2]-(c[k>>2]=M,+g[k>>2]);q=+g[b+84>>2]-(c[k>>2]=L,+g[k>>2]);p=e*F-r*q;q=r*F+e*q;e=+p;F=+q;L=b+124|0;g[L>>2]=e;g[L+4>>2]=F;F=+g[b+88>>2]-(c[k>>2]=K,+g[k>>2]);e=+g[b+92>>2]- +g[b+152>>2];r=E*F-D*e;e=D*F+E*e;E=+r;F=+e;K=b+132|0;g[K>>2]=E;g[K+4>>2]=F;K=b+116|0;v=C+r-v-p;w=G+e-w-q;G=+v;C=+w;L=K;g[L>>2]=G;g[L+4>>2]=C;C=+O(+(v*v+w*w));if(C>.004999999888241291){G=1.0/C;v=v*G;g[K>>2]=v;w=G*w}else{g[K>>2]=0.0;w=0.0;v=0.0}g[b+120>>2]=w;G=w*p-q*v;D=w*r-v*e;x=+g[J>>2];y=+g[I>>2];z=+g[H>>2];B=+g[A>>2];D=z+(x+G*G*y)+D*D*B;if(D!=0.0)G=1.0/D;else G=0.0;A=b+172|0;g[A>>2]=G;E=+g[b+68>>2];if(E>0.0){C=C- +g[b+104>>2];V=E*6.2831854820251465;F=V*G*V;E=+g[d>>2];G=E*(V*G*2.0*+g[b+72>>2]+F*E);H=b+96|0;g[H>>2]=G;if(G!=0.0)G=1.0/G;else G=0.0;g[H>>2]=G;g[b+76>>2]=F*C*E*G;C=D+G;if(C!=0.0)C=1.0/C;else C=0.0;g[A>>2]=C}else{g[b+96>>2]=0.0;g[b+76>>2]=0.0}if(!(a[d+20>>0]|0)){g[b+100>>2]=0.0;C=u;D=t;F=s;G=f;E=h;V=j;U=c[l>>2]|0;T=c[m>>2]|0;U=T+(U*12|0)|0;C=+C;D=+D;T=U;g[T>>2]=C;U=U+4|0;g[U>>2]=D;U=c[l>>2]|0;T=c[m>>2]|0;U=T+(U*12|0)+8|0;g[U>>2]=E;U=c[n>>2]|0;U=T+(U*12|0)|0;F=+F;G=+G;T=U;g[T>>2]=F;U=U+4|0;g[U>>2]=G;U=c[n>>2]|0;T=c[m>>2]|0;U=T+(U*12|0)+8|0;g[U>>2]=V;i=o;return}else{U=b+100|0;C=+g[d+8>>2]*+g[U>>2];g[U>>2]=C;V=v*C;w=C*w;C=u-V*x;D=t-w*x;F=s+V*z;G=f+w*z;E=h-y*(w*p-V*q);V=j+B*(w*r-V*e);U=c[l>>2]|0;T=c[m>>2]|0;U=T+(U*12|0)|0;C=+C;D=+D;T=U;g[T>>2]=C;U=U+4|0;g[U>>2]=D;U=c[l>>2]|0;T=c[m>>2]|0;U=T+(U*12|0)+8|0;g[U>>2]=E;U=c[n>>2]|0;U=T+(U*12|0)|0;F=+F;G=+G;T=U;g[T>>2]=F;U=U+4|0;g[U>>2]=G;U=c[n>>2]|0;T=c[m>>2]|0;U=T+(U*12|0)+8|0;g[U>>2]=V;i=o;return}}function kz(a,b){a=a|0;b=b|0;var d=0,e=0,f=0.0,h=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0,o=0.0,p=0.0,q=0.0,r=0,s=0.0,t=0.0,u=0.0,v=0.0,w=0,x=0.0,y=0.0,z=0,A=0;d=i;n=a+108|0;w=c[n>>2]|0;e=b+28|0;z=c[e>>2]|0;r=z+(w*12|0)|0;b=r;q=+g[b>>2];s=+g[b+4>>2];v=+g[z+(w*12|0)+8>>2];b=a+112|0;w=c[b>>2]|0;A=z+(w*12|0)|0;m=+g[A>>2];l=+g[A+4>>2];u=+g[z+(w*12|0)+8>>2];o=+g[a+128>>2];h=+g[a+124>>2];f=+g[a+136>>2];t=+g[a+132>>2];j=+g[a+116>>2];p=+g[a+120>>2];w=a+100|0;y=+g[w>>2];x=+g[a+172>>2]*(+g[a+76>>2]+(j*(m-u*f-(q-v*o))+p*(l+u*t-(s+v*h)))+ +g[a+96>>2]*y);k=-x;g[w>>2]=y-x;j=j*k;k=p*k;p=+g[a+156>>2];o=v- +g[a+164>>2]*(h*k-j*o);h=+g[a+160>>2];f=u+ +g[a+168>>2]*(k*t-j*f);q=+(q-p*j);p=+(s-p*k);a=r;g[a>>2]=q;g[a+4>>2]=p;a=c[e>>2]|0;g[a+((c[n>>2]|0)*12|0)+8>>2]=o;j=+(m+j*h);h=+(l+k*h);a=a+((c[b>>2]|0)*12|0)|0;g[a>>2]=j;g[a+4>>2]=h;g[(c[e>>2]|0)+((c[b>>2]|0)*12|0)+8>>2]=f;i=d;return}function lz(a,b){a=a|0;b=b|0;var d=0,e=0,f=0.0,h=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0,q=0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0,x=0,y=0,z=0.0,A=0.0,B=0.0;d=i;if(+g[a+68>>2]>0.0){q=1;i=d;return q|0}e=a+108|0;q=c[e>>2]|0;p=b+24|0;x=c[p>>2]|0;b=x+(q*12|0)|0;w=b;n=+g[w>>2];o=+g[w+4>>2];f=+g[x+(q*12|0)+8>>2];q=a+112|0;w=c[q>>2]|0;y=x+(w*12|0)|0;r=+g[y>>2];s=+g[y+4>>2];k=+g[x+(w*12|0)+8>>2];l=+R(+f);t=+Q(+f);v=+R(+k);u=+Q(+k);m=+g[a+80>>2]- +g[a+140>>2];j=+g[a+84>>2]- +g[a+144>>2];h=t*m-l*j;j=l*m+t*j;t=+g[a+88>>2]- +g[a+148>>2];m=+g[a+92>>2]- +g[a+152>>2];l=u*t-v*m;m=v*t+u*m;u=r+l-n-h;t=s+m-o-j;v=+O(+(u*u+t*t));if(v<1.1920928955078125e-7)v=0.0;else{z=1.0/v;u=u*z;t=t*z}v=v- +g[a+104>>2];v=v<.20000000298023224?v:.20000000298023224;v=v<-.20000000298023224?-.20000000298023224:v;B=-(+g[a+172>>2]*v);A=u*B;u=t*B;B=+g[a+156>>2];t=f- +g[a+164>>2]*(h*u-j*A);j=+g[a+160>>2];z=k+ +g[a+168>>2]*(l*u-m*A);n=+(n-B*A);o=+(o-B*u);y=b;g[y>>2]=n;g[y+4>>2]=o;y=c[p>>2]|0;g[y+((c[e>>2]|0)*12|0)+8>>2]=t;t=+(r+j*A);u=+(s+j*u);y=y+((c[q>>2]|0)*12|0)|0;g[y>>2]=t;g[y+4>>2]=u;g[(c[p>>2]|0)+((c[q>>2]|0)*12|0)+8>>2]=z;if(!(v>0.0))v=-v;y=v<.004999999888241291;i=d;return y|0}function mz(a,b){a=a|0;b=b|0;var d=0.0,e=0.0,f=0.0,h=0.0,i=0.0,j=0;j=c[b+48>>2]|0;i=+g[j+24>>2];h=+g[b+80>>2];f=+g[j+20>>2];e=+g[b+84>>2];d=h*f+i*e+ +g[j+16>>2];g[a>>2]=+g[j+12>>2]+(i*h-f*e);g[a+4>>2]=d;return}function nz(a,b){a=a|0;b=b|0;var d=0.0,e=0.0,f=0.0,h=0.0,i=0.0,j=0;j=c[b+52>>2]|0;i=+g[j+24>>2];h=+g[b+88>>2];f=+g[j+20>>2];e=+g[b+92>>2];d=h*f+i*e+ +g[j+16>>2];g[a>>2]=+g[j+12>>2]+(i*h-f*e);g[a+4>>2]=d;return}function oz(a,b,c){a=a|0;b=b|0;c=+c;var d=0.0;d=+g[b+100>>2]*c;c=d*+g[b+120>>2];g[a>>2]=+g[b+116>>2]*d;g[a+4>>2]=c;return}function pz(a,b){a=a|0;b=+b;return 0.0}function qz(a){a=a|0;var b=0,e=0,f=0,j=0.0,l=0;b=i;i=i+16|0;e=b;l=c[(c[a+48>>2]|0)+8>>2]|0;f=c[(c[a+52>>2]|0)+8>>2]|0;Nx(14352,e);c[e>>2]=l;Nx(17320,e);c[e>>2]=f;Nx(17352,e);c[e>>2]=d[a+61>>0];Nx(17384,e);j=+g[a+84>>2];h[k>>3]=+g[a+80>>2];c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];f=e+8|0;h[k>>3]=j;c[f>>2]=c[k>>2];c[f+4>>2]=c[k+4>>2];Nx(17424,e);j=+g[a+92>>2];h[k>>3]=+g[a+88>>2];c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];f=e+8|0;h[k>>3]=j;c[f>>2]=c[k>>2];c[f+4>>2]=c[k+4>>2];Nx(17472,e);h[k>>3]=+g[a+104>>2];c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];Nx(14384,e);h[k>>3]=+g[a+68>>2];c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];Nx(17656,e);h[k>>3]=+g[a+72>>2];c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];Nx(17688,e);c[e>>2]=c[a+56>>2];Nx(17720,e);i=b;return}function rz(a){a=a|0;return}function sz(a){a=a|0;var b=0;b=i;OB(a);i=b;return}function tz(b,d){b=b|0;d=d|0;var e=0.0,f=0.0,h=0.0,j=0.0,l=0.0,m=0.0,n=0,o=0,p=0,q=0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0,E=0.0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0.0,O=0.0;q=i;o=c[b+48>>2]|0;L=c[o+8>>2]|0;n=b+104|0;c[n>>2]=L;K=c[b+52>>2]|0;I=c[K+8>>2]|0;p=b+108|0;c[p>>2]=I;G=o+28|0;H=c[G>>2]|0;G=c[G+4>>2]|0;D=b+128|0;c[D>>2]=H;c[D+4>>2]=G;D=K+28|0;F=c[D>>2]|0;D=c[D+4>>2]|0;J=b+136|0;c[J>>2]=F;c[J+4>>2]=D;r=+g[o+120>>2];g[b+144>>2]=r;s=+g[K+120>>2];g[b+148>>2]=s;t=+g[o+128>>2];g[b+152>>2]=t;w=+g[K+128>>2];g[b+156>>2]=w;K=c[d+24>>2]|0;y=+g[K+(L*12|0)+8>>2];o=d+28|0;J=c[o>>2]|0;M=J+(L*12|0)|0;u=+g[M>>2];f=+g[M+4>>2];l=+g[J+(L*12|0)+8>>2];A=+g[K+(I*12|0)+8>>2];K=J+(I*12|0)|0;h=+g[K>>2];j=+g[K+4>>2];m=+g[J+(I*12|0)+8>>2];x=+R(+y);y=+Q(+y);C=+R(+A);A=+Q(+A);E=+g[b+68>>2]-(c[k>>2]=H,+g[k>>2]);v=+g[b+72>>2]-(c[k>>2]=G,+g[k>>2]);e=y*E-x*v;v=x*E+y*v;y=+e;E=+v;G=b+112|0;g[G>>2]=y;g[G+4>>2]=E;E=+g[b+76>>2]-(c[k>>2]=F,+g[k>>2]);y=+g[b+80>>2]-(c[k>>2]=D,+g[k>>2]);x=A*E-C*y;y=C*E+A*y;A=+x;E=+y;D=b+120|0;g[D>>2]=A;g[D+4>>2]=E;E=r+s;A=E+v*t*v+y*w*y;C=t*e;z=w*x;B=-(v*C)-y*z;z=E+e*C+x*z;C=A*z-B*B;if(C!=0.0)C=1.0/C;E=-(B*C);g[b+160>>2]=z*C;g[b+164>>2]=E;g[b+168>>2]=E;g[b+172>>2]=A*C;z=t+w;if(z>0.0)z=1.0/z;g[b+176>>2]=z;D=b+84|0;if(!(a[d+20>>0]|0)){g[D>>2]=0.0;g[b+88>>2]=0.0;g[b+92>>2]=0.0;y=u;z=f;B=h;C=j;A=l;E=m;M=c[n>>2]|0;L=c[o>>2]|0;M=L+(M*12|0)|0;y=+y;z=+z;L=M;g[L>>2]=y;M=M+4|0;g[M>>2]=z;M=c[n>>2]|0;L=c[o>>2]|0;M=L+(M*12|0)+8|0;g[M>>2]=A;M=c[p>>2]|0;M=L+(M*12|0)|0;B=+B;C=+C;L=M;g[L>>2]=B;M=M+4|0;g[M>>2]=C;M=c[p>>2]|0;L=c[o>>2]|0;M=L+(M*12|0)+8|0;g[M>>2]=E;i=q;return}else{L=d+8|0;N=+g[L>>2];E=N*+g[D>>2];g[D>>2]=E;M=b+88|0;N=N*+g[M>>2];g[M>>2]=N;M=b+92|0;O=+g[L>>2]*+g[M>>2];g[M>>2]=O;u=u-r*E;z=f-r*N;B=h+s*E;C=j+s*N;A=l-t*(O+(N*e-E*v));E=m+w*(O+(N*x-E*y));M=c[n>>2]|0;L=c[o>>2]|0;M=L+(M*12|0)|0;y=+u;z=+z;L=M;g[L>>2]=y;M=M+4|0;g[M>>2]=z;M=c[n>>2]|0;L=c[o>>2]|0;M=L+(M*12|0)+8|0;g[M>>2]=A;M=c[p>>2]|0;M=L+(M*12|0)|0;B=+B;C=+C;L=M;g[L>>2]=B;M=M+4|0;g[M>>2]=C;M=c[p>>2]|0;L=c[o>>2]|0;M=L+(M*12|0)+8|0;g[M>>2]=E;i=q;return}}function uz(a,b){a=a|0;b=b|0;var d=0.0,e=0.0,f=0.0,h=0.0,j=0,k=0,l=0.0,m=0.0,n=0.0,o=0,p=0.0,q=0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0,A=0.0,B=0.0,C=0.0,D=0.0,E=0,F=0;q=i;k=a+104|0;o=c[k>>2]|0;j=b+28|0;E=c[j>>2]|0;z=E+(o*12|0)|0;l=+g[z>>2];h=+g[z+4>>2];y=+g[E+(o*12|0)+8>>2];o=a+108|0;z=c[o>>2]|0;F=E+(z*12|0)|0;m=+g[F>>2];n=+g[F+4>>2];x=+g[E+(z*12|0)+8>>2];f=+g[a+144>>2];e=+g[a+148>>2];d=+g[a+152>>2];p=+g[a+156>>2];B=+g[b>>2];b=a+92|0;s=+g[b>>2];w=B*+g[a+100>>2];t=s-(x-y)*+g[a+176>>2];v=-w;w=t>2]=w;s=w-s;y=y-d*s;s=x+p*s;x=+g[a+124>>2];w=+g[a+120>>2];v=+g[a+116>>2];t=+g[a+112>>2];D=v*y+(m-x*s-l);C=n+w*s-h-t*y;A=+g[a+164>>2]*D+ +g[a+172>>2]*C;b=a+84|0;z=b;u=+g[z>>2];r=+g[z+4>>2];C=u-(+g[a+160>>2]*D+ +g[a+168>>2]*C);g[b>>2]=C;z=a+88|0;A=+g[z>>2]-A;g[z>>2]=A;B=B*+g[a+96>>2];D=C*C+A*A;if(D>B*B){D=+O(+D);if(!(D<1.1920928955078125e-7)){D=1.0/D;C=C*D;g[b>>2]=C;A=A*D;g[z>>2]=A}C=B*C;g[b>>2]=C;A=B*A;g[z>>2]=A}D=C-u;C=A-r;B=+(l-f*D);A=+(h-f*C);F=(c[j>>2]|0)+((c[k>>2]|0)*12|0)|0;g[F>>2]=B;g[F+4>>2]=A;F=c[j>>2]|0;g[F+((c[k>>2]|0)*12|0)+8>>2]=y-d*(t*C-D*v);A=+(m+e*D);B=+(n+e*C);F=F+((c[o>>2]|0)*12|0)|0;g[F>>2]=A;g[F+4>>2]=B;g[(c[j>>2]|0)+((c[o>>2]|0)*12|0)+8>>2]=s+p*(C*w-D*x);i=q;return}function vz(a,b){a=a|0;b=b|0;return 1}function wz(a,b){a=a|0;b=b|0;var d=0.0,e=0.0,f=0.0,h=0.0,i=0.0,j=0;j=c[b+48>>2]|0;i=+g[j+24>>2];h=+g[b+68>>2];f=+g[j+20>>2];e=+g[b+72>>2];d=h*f+i*e+ +g[j+16>>2];g[a>>2]=+g[j+12>>2]+(i*h-f*e);g[a+4>>2]=d;return}function xz(a,b){a=a|0;b=b|0;var d=0.0,e=0.0,f=0.0,h=0.0,i=0.0,j=0;j=c[b+52>>2]|0;i=+g[j+24>>2];h=+g[b+76>>2];f=+g[j+20>>2];e=+g[b+80>>2];d=h*f+i*e+ +g[j+16>>2];g[a>>2]=+g[j+12>>2]+(i*h-f*e);g[a+4>>2]=d;return}function yz(a,b,c){a=a|0;b=b|0;c=+c;var d=0.0;d=+g[b+88>>2]*c;g[a>>2]=+g[b+84>>2]*c;g[a+4>>2]=d;return}function zz(a,b){a=a|0;b=+b;return+(+g[a+92>>2]*b)}function Az(a){a=a|0;var b=0,e=0,f=0,j=0.0,l=0;b=i;i=i+16|0;e=b;l=c[(c[a+48>>2]|0)+8>>2]|0;f=c[(c[a+52>>2]|0)+8>>2]|0;Nx(14672,e);c[e>>2]=l;Nx(17320,e);c[e>>2]=f;Nx(17352,e);c[e>>2]=d[a+61>>0];Nx(17384,e);j=+g[a+72>>2];h[k>>3]=+g[a+68>>2];c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];f=e+8|0;h[k>>3]=j;c[f>>2]=c[k>>2];c[f+4>>2]=c[k+4>>2];Nx(17424,e);j=+g[a+80>>2];h[k>>3]=+g[a+76>>2];c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];f=e+8|0;h[k>>3]=j;c[f>>2]=c[k>>2];c[f+4>>2]=c[k+4>>2];Nx(17472,e);h[k>>3]=+g[a+96>>2];c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];Nx(14704,e);h[k>>3]=+g[a+100>>2];c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];Nx(14736,e);c[e>>2]=c[a+56>>2];Nx(17720,e);i=b;return}function Bz(a){a=a|0;return}function Cz(a){a=a|0;var b=0;b=i;OB(a);i=b;return}function Dz(b,d){b=b|0;d=d|0;var e=0,f=0.0,h=0.0,j=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0,t=0,u=0.0,v=0,w=0,x=0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0,I=0.0,J=0.0,K=0.0,L=0.0,M=0.0,N=0.0,O=0,P=0.0,S=0.0,T=0.0,U=0.0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0.0,fa=0.0,ga=0.0,ha=0.0,ia=0.0,ja=0.0,ka=0.0,la=0.0,ma=0.0,na=0.0;x=i;ba=c[b+48>>2]|0;aa=c[ba+8>>2]|0;s=b+160|0;c[s>>2]=aa;Y=c[b+52>>2]|0;$=c[Y+8>>2]|0;e=b+164|0;c[e>>2]=$;t=c[b+84>>2]|0;_=c[t+8>>2]|0;v=b+168|0;c[v>>2]=_;Z=c[b+88>>2]|0;H=c[Z+8>>2]|0;w=b+172|0;c[w>>2]=H;W=b+176|0;ca=ba+28|0;X=c[ca+4>>2]|0;O=W;c[O>>2]=c[ca>>2];c[O+4>>2]=X;O=b+184|0;X=Y+28|0;ca=c[X+4>>2]|0;V=O;c[V>>2]=c[X>>2];c[V+4>>2]=ca;V=b+192|0;ca=t+28|0;X=c[ca+4>>2]|0;da=V;c[da>>2]=c[ca>>2];c[da+4>>2]=X;da=Z+28|0;X=c[da>>2]|0;da=c[da+4>>2]|0;ca=b+200|0;c[ca>>2]=X;c[ca+4>>2]=da;y=+g[ba+120>>2];g[b+208>>2]=y;z=+g[Y+120>>2];g[b+212>>2]=z;A=+g[t+120>>2];g[b+216>>2]=A;B=+g[Z+120>>2];g[b+220>>2]=B;C=+g[ba+128>>2];g[b+224>>2]=C;D=+g[Y+128>>2];g[b+228>>2]=D;E=+g[t+128>>2];g[b+232>>2]=E;F=+g[Z+128>>2];g[b+236>>2]=F;Z=c[d+24>>2]|0;I=+g[Z+(aa*12|0)+8>>2];t=d+28|0;Y=c[t>>2]|0;ba=Y+(aa*12|0)|0;G=+g[ba>>2];u=+g[ba+4>>2];o=+g[Y+(aa*12|0)+8>>2];S=+g[Z+($*12|0)+8>>2];aa=Y+($*12|0)|0;f=+g[aa>>2];h=+g[aa+4>>2];p=+g[Y+($*12|0)+8>>2];K=+g[Z+(_*12|0)+8>>2];$=Y+(_*12|0)|0;j=+g[$>>2];l=+g[$+4>>2];q=+g[Y+(_*12|0)+8>>2];T=+g[Z+(H*12|0)+8>>2];Z=Y+(H*12|0)|0;m=+g[Z>>2];n=+g[Z+4>>2];r=+g[Y+(H*12|0)+8>>2];L=+R(+I);I=+Q(+I);M=+R(+S);S=+Q(+S);J=+R(+K);K=+Q(+K);N=+R(+T);T=+Q(+T);H=b+272|0;g[H>>2]=0.0;P=(c[k>>2]=X,+g[k>>2]);if((c[b+76>>2]|0)==1){g[b+240>>2]=0.0;g[b+244>>2]=0.0;g[b+256>>2]=1.0;g[b+264>>2]=1.0;U=C+E;L=0.0;I=0.0;K=1.0;J=1.0}else{ia=+g[b+124>>2];ea=+g[b+128>>2];fa=K*ia-J*ea;ea=J*ia+K*ea;ia=+g[b+108>>2]- +g[V>>2];ha=+g[b+112>>2]- +g[b+196>>2];ga=+g[b+92>>2]- +g[W>>2];U=+g[b+96>>2]- +g[b+180>>2];ka=+fa;ja=+ea;da=b+240|0;g[da>>2]=ka;g[da+4>>2]=ja;J=ea*(K*ia-J*ha)-fa*(J*ia+K*ha);g[b+264>>2]=J;K=ea*(I*ga-L*U)-fa*(L*ga+I*U);g[b+256>>2]=K;U=A+y+J*E*J+K*C*K;L=fa;I=ea}U=U+0.0;g[H>>2]=U;if((c[b+80>>2]|0)==1){g[b+248>>2]=0.0;g[b+252>>2]=0.0;N=+g[b+152>>2];g[b+260>>2]=N;g[b+268>>2]=N;T=N*N*(D+F);M=0.0;P=0.0;S=N}else{la=+g[b+132>>2];fa=+g[b+136>>2];ga=T*la-N*fa;fa=N*la+T*fa;la=+g[b+116>>2]-P;ea=+g[b+120>>2]- +g[b+204>>2];ha=+g[b+100>>2]- +g[O>>2];ia=+g[b+104>>2]- +g[b+188>>2];ja=+g[b+152>>2];ka=ga*ja;P=fa*ja;na=+ka;ma=+P;da=b+248|0;g[da>>2]=na;g[da+4>>2]=ma;N=(fa*(T*la-N*ea)-ga*(N*la+T*ea))*ja;g[b+268>>2]=N;S=ja*(fa*(S*ha-M*ia)-ga*(M*ha+S*ia));g[b+260>>2]=S;T=ja*ja*(B+z)+N*F*N+S*S*D;M=ka}T=U+T;g[H>>2]=T;if(T>0.0)T=1.0/T;else T=0.0;g[H>>2]=T;H=b+156|0;if(!(a[d+20>>0]|0)){g[H>>2]=0.0;T=G;U=u;fa=f;ga=h;ia=j;ja=l;la=m;ma=n;ea=o;ha=p;ka=q;na=r;da=c[s>>2]|0;ca=c[t>>2]|0;da=ca+(da*12|0)|0;T=+T;U=+U;ca=da;g[ca>>2]=T;da=da+4|0;g[da>>2]=U;da=c[s>>2]|0;ca=c[t>>2]|0;da=ca+(da*12|0)+8|0;g[da>>2]=ea;da=c[e>>2]|0;da=ca+(da*12|0)|0;fa=+fa;ga=+ga;ca=da;g[ca>>2]=fa;da=da+4|0;g[da>>2]=ga;da=c[e>>2]|0;ca=c[t>>2]|0;da=ca+(da*12|0)+8|0;g[da>>2]=ha;da=c[v>>2]|0;da=ca+(da*12|0)|0;ia=+ia;ja=+ja;ca=da;g[ca>>2]=ia;da=da+4|0;g[da>>2]=ja;da=c[v>>2]|0;ca=c[t>>2]|0;da=ca+(da*12|0)+8|0;g[da>>2]=ka;da=c[w>>2]|0;da=ca+(da*12|0)|0;la=+la;ma=+ma;ca=da;g[ca>>2]=la;da=da+4|0;g[da>>2]=ma;da=c[w>>2]|0;ca=c[t>>2]|0;da=ca+(da*12|0)+8|0;g[da>>2]=na;i=x;return}else{na=+g[H>>2];U=y*na;ga=na*z;ja=na*A;ma=na*B;T=G+L*U;U=u+U*I;fa=f+M*ga;ga=h+ga*P;ia=j-L*ja;ja=l-I*ja;la=m-M*ma;ma=n-P*ma;ea=o+na*C*K;ha=p+na*D*S;ka=q-na*E*J;na=r-na*F*N;da=c[s>>2]|0;ca=c[t>>2]|0;da=ca+(da*12|0)|0;T=+T;U=+U;ca=da;g[ca>>2]=T;da=da+4|0;g[da>>2]=U;da=c[s>>2]|0;ca=c[t>>2]|0;da=ca+(da*12|0)+8|0;g[da>>2]=ea;da=c[e>>2]|0;da=ca+(da*12|0)|0;fa=+fa;ga=+ga;ca=da;g[ca>>2]=fa;da=da+4|0;g[da>>2]=ga;da=c[e>>2]|0;ca=c[t>>2]|0;da=ca+(da*12|0)+8|0;g[da>>2]=ha;da=c[v>>2]|0;da=ca+(da*12|0)|0;ia=+ia;ja=+ja;ca=da;g[ca>>2]=ia;da=da+4|0;g[da>>2]=ja;da=c[v>>2]|0;ca=c[t>>2]|0;da=ca+(da*12|0)+8|0;g[da>>2]=ka;da=c[w>>2]|0;da=ca+(da*12|0)|0;la=+la;ma=+ma;ca=da;g[ca>>2]=la;da=da+4|0;g[da>>2]=ma;da=c[w>>2]|0;ca=c[t>>2]|0;da=ca+(da*12|0)+8|0;g[da>>2]=na;i=x;return}}function Ez(a,b){a=a|0;b=b|0;var d=0,e=0,f=0.0,h=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0,v=0.0,w=0.0,x=0.0,y=0.0,z=0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0,H=0,I=0;d=i;z=a+160|0;u=c[z>>2]|0;e=b+28|0;H=c[e>>2]|0;n=H+(u*12|0)|0;C=+g[n>>2];D=+g[n+4>>2];w=+g[H+(u*12|0)+8>>2];u=a+164|0;n=c[u>>2]|0;b=H+(n*12|0)|0;x=+g[b>>2];y=+g[b+4>>2];p=+g[H+(n*12|0)+8>>2];n=a+168|0;b=c[n>>2]|0;G=H+(b*12|0)|0;t=+g[G>>2];s=+g[G+4>>2];h=+g[H+(b*12|0)+8>>2];b=a+172|0;G=c[b>>2]|0;I=H+(G*12|0)|0;m=+g[I>>2];l=+g[I+4>>2];F=+g[H+(G*12|0)+8>>2];q=+g[a+240>>2];r=+g[a+244>>2];j=+g[a+248>>2];k=+g[a+252>>2];A=+g[a+256>>2];o=+g[a+264>>2];v=+g[a+260>>2];f=+g[a+268>>2];B=+g[a+272>>2]*((C-t)*q+(D-s)*r+((x-m)*j+(y-l)*k)+(w*A-h*o+(p*v-F*f)));E=-B;G=a+156|0;g[G>>2]=+g[G>>2]-B;B=+g[a+208>>2]*E;A=w+ +g[a+224>>2]*E*A;w=+g[a+212>>2]*E;v=p+ +g[a+228>>2]*E*v;p=+g[a+216>>2]*E;o=h- +g[a+232>>2]*E*o;h=+g[a+220>>2]*E;f=F- +g[a+236>>2]*E*f;C=+(C+q*B);B=+(D+r*B);a=(c[e>>2]|0)+((c[z>>2]|0)*12|0)|0;g[a>>2]=C;g[a+4>>2]=B;a=c[e>>2]|0;g[a+((c[z>>2]|0)*12|0)+8>>2]=A;x=+(x+j*w);w=+(y+w*k);a=a+((c[u>>2]|0)*12|0)|0;g[a>>2]=x;g[a+4>>2]=w;a=c[e>>2]|0;g[a+((c[u>>2]|0)*12|0)+8>>2]=v;q=+(t-q*p);p=+(s-r*p);a=a+((c[n>>2]|0)*12|0)|0;g[a>>2]=q;g[a+4>>2]=p;a=c[e>>2]|0;g[a+((c[n>>2]|0)*12|0)+8>>2]=o;j=+(m-j*h);h=+(l-k*h);a=a+((c[b>>2]|0)*12|0)|0;g[a>>2]=j;g[a+4>>2]=h;g[(c[e>>2]|0)+((c[b>>2]|0)*12|0)+8>>2]=f;i=d;return}function Fz(a,b){a=a|0;b=b|0;var d=0,e=0,f=0.0,h=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0,o=0.0,p=0.0,q=0,r=0,s=0.0,t=0.0,u=0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0,K=0.0,L=0.0,M=0.0,N=0.0,O=0.0,P=0,S=0,T=0,U=0.0,V=0.0,W=0.0,X=0.0,Y=0.0,Z=0.0,_=0.0;e=i;d=a+160|0;n=c[d>>2]|0;q=b+24|0;S=c[q>>2]|0;u=S+(n*12|0)|0;b=u;w=+g[b>>2];v=+g[b+4>>2];t=+g[S+(n*12|0)+8>>2];b=a+164|0;n=c[b>>2]|0;r=S+(n*12|0)|0;h=+g[r>>2];j=+g[r+4>>2];k=+g[S+(n*12|0)+8>>2];n=a+168|0;r=c[n>>2]|0;P=S+(r*12|0)|0;l=+g[P>>2];m=+g[P+4>>2];o=+g[S+(r*12|0)+8>>2];r=a+172|0;P=c[r>>2]|0;T=S+(P*12|0)|0;p=+g[T>>2];f=+g[T+4>>2];s=+g[S+(P*12|0)+8>>2];x=+R(+t);y=+Q(+t);G=+R(+k);H=+Q(+k);F=+R(+o);I=+Q(+o);E=+R(+s);D=+Q(+s);if((c[a+76>>2]|0)==1){O=+g[a+224>>2];I=+g[a+232>>2];B=0.0;C=0.0;z=O;x=I;A=1.0;y=1.0;F=t-o- +g[a+140>>2];I=O+I}else{X=+g[a+124>>2];V=+g[a+128>>2];B=I*X-F*V;C=F*X+I*V;W=+g[a+108>>2]- +g[a+192>>2];K=+g[a+112>>2]- +g[a+196>>2];L=+g[a+92>>2]- +g[a+176>>2];U=+g[a+96>>2]- +g[a+180>>2];J=y*L-x*U;U=x*L+y*U;L=C*(I*W-F*K)-B*(F*W+I*K);O=C*J-B*U;M=+g[a+232>>2];N=+g[a+224>>2];J=w-l+J;U=v-m+U;z=N;x=M;A=O;y=L;F=X*(I*J+F*U-W)+V*(I*U-F*J-K);I=+g[a+216>>2]+ +g[a+208>>2]+L*L*M+O*N*O}if((c[a+80>>2]|0)==1){G=+g[a+152>>2];M=+g[a+228>>2];H=+g[a+236>>2];O=G*G*(M+H);N=G;J=0.0;K=0.0;L=G;D=k-s- +g[a+144>>2]}else{Z=+g[a+132>>2];U=+g[a+136>>2];J=D*Z-E*U;_=E*Z+D*U;Y=+g[a+116>>2]- +g[a+200>>2];X=+g[a+120>>2]- +g[a+204>>2];K=+g[a+100>>2]- +g[a+184>>2];V=+g[a+104>>2]- +g[a+188>>2];W=H*K-G*V;V=G*K+H*V;K=+g[a+152>>2];G=K*(_*(D*Y-E*X)-J*(E*Y+D*X));L=K*(_*W-J*V);H=+g[a+236>>2];M=+g[a+228>>2];W=h-p+W;V=j-f+V;O=K*K*(+g[a+220>>2]+ +g[a+212>>2])+G*G*H+L*M*L;N=K;J=J*K;K=_*K;D=Z*(D*W+E*V-Y)+U*(D*V-E*W-X)}E=I+0.0+O;if(E>0.0)D=-(F+D*N- +g[a+148>>2])/E;else D=0.0;X=D*+g[a+208>>2];Y=D*+g[a+212>>2];Z=D*+g[a+216>>2];_=D*+g[a+220>>2];W=+(w+B*X);X=+(v+C*X);T=u;g[T>>2]=W;g[T+4>>2]=X;T=c[q>>2]|0;g[T+((c[d>>2]|0)*12|0)+8>>2]=t+A*D*z;X=+(h+J*Y);Y=+(j+K*Y);T=T+((c[b>>2]|0)*12|0)|0;g[T>>2]=X;g[T+4>>2]=Y;T=c[q>>2]|0;g[T+((c[b>>2]|0)*12|0)+8>>2]=k+L*D*M;Y=+(l-B*Z);Z=+(m-C*Z);T=T+((c[n>>2]|0)*12|0)|0;g[T>>2]=Y;g[T+4>>2]=Z;T=c[q>>2]|0;g[T+((c[n>>2]|0)*12|0)+8>>2]=o-y*D*x;Z=+(p-J*_);_=+(f-K*_);T=T+((c[r>>2]|0)*12|0)|0;g[T>>2]=Z;g[T+4>>2]=_;g[(c[q>>2]|0)+((c[r>>2]|0)*12|0)+8>>2]=s-G*D*H;i=e;return 1}function Gz(a,b){a=a|0;b=b|0;var d=0.0,e=0.0,f=0.0,h=0.0,i=0.0,j=0;j=c[b+48>>2]|0;i=+g[j+24>>2];h=+g[b+92>>2];f=+g[j+20>>2];e=+g[b+96>>2];d=h*f+i*e+ +g[j+16>>2];g[a>>2]=+g[j+12>>2]+(i*h-f*e);g[a+4>>2]=d;return}function Hz(a,b){a=a|0;b=b|0;var d=0.0,e=0.0,f=0.0,h=0.0,i=0.0,j=0;j=c[b+52>>2]|0;i=+g[j+24>>2];h=+g[b+100>>2];f=+g[j+20>>2];e=+g[b+104>>2];d=h*f+i*e+ +g[j+16>>2];g[a>>2]=+g[j+12>>2]+(i*h-f*e);g[a+4>>2]=d;return}function Iz(a,b,c){a=a|0;b=b|0;c=+c;var d=0.0,e=0.0;e=+g[b+156>>2];d=e*+g[b+244>>2]*c;g[a>>2]=e*+g[b+240>>2]*c;g[a+4>>2]=d;return}function Jz(a,b){a=a|0;b=+b;return+(+g[a+156>>2]*+g[a+256>>2]*b)}function Kz(a){a=a|0;var b=0,e=0,f=0,j=0,l=0,m=0;b=i;i=i+16|0;e=b;m=c[(c[a+48>>2]|0)+8>>2]|0;l=c[(c[a+52>>2]|0)+8>>2]|0;j=c[(c[a+68>>2]|0)+56>>2]|0;f=c[(c[a+72>>2]|0)+56>>2]|0;Nx(15104,e);c[e>>2]=m;Nx(17320,e);c[e>>2]=l;Nx(17352,e);c[e>>2]=d[a+61>>0];Nx(17384,e);c[e>>2]=j;Nx(15128,e);c[e>>2]=f;Nx(15160,e);h[k>>3]=+g[a+152>>2];c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];Nx(16584,e);c[e>>2]=c[a+56>>2];Nx(17720,e);i=b;return}function Lz(a){a=a|0;return}function Mz(a){a=a|0;var b=0;b=i;OB(a);i=b;return}function Nz(a){a=a|0;a=i;i=i+16|0;Nx(15392,a);i=a;return}function Oz(a){a=a|0;return}function Pz(a){a=a|0;var b=0;b=i;OB(a);i=b;return}function Qz(b,d){b=b|0;d=d|0;var e=0.0,f=0,h=0,j=0,l=0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0,A=0,B=0,C=0,D=0;l=i;B=c[b+52>>2]|0;h=c[B+8>>2]|0;j=b+116|0;c[j>>2]=h;z=B+28|0;A=c[z>>2]|0;z=c[z+4>>2]|0;f=b+128|0;c[f>>2]=A;c[f+4>>2]=z;m=+g[B+120>>2];g[b+136>>2]=m;e=+g[B+128>>2];g[b+140>>2]=e;f=c[d+24>>2]|0;C=f+(h*12|0)|0;r=+g[C>>2];p=+g[C+4>>2];u=+g[f+(h*12|0)+8>>2];f=d+28|0;C=c[f>>2]|0;D=C+(h*12|0)|0;o=+g[D>>2];n=+g[D+4>>2];q=+g[C+(h*12|0)+8>>2];w=+R(+u);u=+Q(+u);y=+g[B+116>>2];x=+g[b+84>>2]*6.2831854820251465;v=+g[d>>2];s=v*y*x*x;y=x*y*2.0*+g[b+88>>2]+s;x=(c[k>>2]=A,+g[k>>2]);t=(c[k>>2]=z,+g[k>>2]);if(!(y>1.1920928955078125e-7))Aa(15768,15520,125,15808);v=v*y;if(v!=0.0)v=1.0/v;g[b+108>>2]=v;s=s*v;g[b+92>>2]=s;x=+g[b+68>>2]-x;y=+g[b+72>>2]-t;t=u*x-w*y;u=w*x+u*y;y=+t;x=+u;D=b+120|0;g[D>>2]=y;g[D+4>>2]=x;x=v+(m+u*e*u);y=e*t;w=u*y;v=v+(m+t*y);y=x*v-w*w;if(y!=0.0)y=1.0/y;w=w*y;g[b+144>>2]=v*y;g[b+148>>2]=w;g[b+152>>2]=w;g[b+156>>2]=x*y;z=b+160|0;y=r+t- +g[b+76>>2];p=p+u- +g[b+80>>2];w=+y;x=+p;D=z;g[D>>2]=w;g[D+4>>2]=x;g[z>>2]=s*y;g[b+164>>2]=s*p;p=q*.9800000190734863;z=b+96|0;if(!(a[d+20>>0]|0)){g[z>>2]=0.0;g[b+100>>2]=0.0;w=o;x=n;y=p;D=c[f>>2]|0;D=D+(h*12|0)|0;w=+w;x=+x;C=D;g[C>>2]=w;D=D+4|0;g[D>>2]=x;D=c[j>>2]|0;C=c[f>>2]|0;D=C+(D*12|0)+8|0;g[D>>2]=y;i=l;return}else{v=+g[d+8>>2];y=v*+g[z>>2];g[z>>2]=y;D=b+100|0;v=v*+g[D>>2];g[D>>2]=v;w=o+m*y;x=n+v*m;y=p+e*(v*t-y*u);D=c[f>>2]|0;D=D+(h*12|0)|0;w=+w;x=+x;C=D;g[C>>2]=w;D=D+4|0;g[D>>2]=x;D=c[j>>2]|0;C=c[f>>2]|0;D=C+(D*12|0)+8|0;g[D>>2]=y;i=l;return}}function Rz(a,b){a=a|0;b=b|0;var d=0.0,e=0,f=0,h=0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0,p=0.0,q=0.0,r=0,s=0,t=0.0,u=0.0,v=0.0,w=0.0,x=0;o=i;e=a+116|0;s=c[e>>2]|0;f=b+28|0;r=c[f>>2]|0;h=r+(s*12|0)|0;x=h;k=+g[x>>2];j=+g[x+4>>2];n=+g[r+(s*12|0)+8>>2];l=+g[a+124>>2];m=+g[a+120>>2];t=+g[a+108>>2];s=a+96|0;w=+g[s>>2];r=a+100|0;q=+g[r>>2];u=-(k-n*l+ +g[a+160>>2]+t*w);t=-(j+n*m+ +g[a+164>>2]+t*q);v=+g[a+148>>2]*u+ +g[a+156>>2]*t;x=s;p=+g[x>>2];d=+g[x+4>>2];t=w+(+g[a+144>>2]*u+ +g[a+152>>2]*t);g[s>>2]=t;q=v+q;g[r>>2]=q;v=+g[b>>2]*+g[a+104>>2];u=q*q+t*t;if(u>v*v){w=v/+O(+u);t=t*w;g[s>>2]=t;q=w*q;g[r>>2]=q}u=t-p;t=q-d;v=+g[a+136>>2];w=n+ +g[a+140>>2]*(t*m-u*l);u=+(k+u*v);v=+(j+t*v);x=h;g[x>>2]=u;g[x+4>>2]=v;g[(c[f>>2]|0)+((c[e>>2]|0)*12|0)+8>>2]=w;i=o;return}function Sz(a,b){a=a|0;b=b|0;return 1}function Tz(a,b){a=a|0;b=b|0;var d=0,e=0;e=b+76|0;d=c[e+4>>2]|0;b=a;c[b>>2]=c[e>>2];c[b+4>>2]=d;return}function Uz(a,b){a=a|0;b=b|0;var d=0.0,e=0.0,f=0.0,h=0.0,i=0.0,j=0;j=c[b+52>>2]|0;i=+g[j+24>>2];h=+g[b+68>>2];f=+g[j+20>>2];e=+g[b+72>>2];d=h*f+i*e+ +g[j+16>>2];g[a>>2]=+g[j+12>>2]+(i*h-f*e);g[a+4>>2]=d;return}function Vz(a,b,c){a=a|0;b=b|0;c=+c;var d=0.0;d=+g[b+100>>2]*c;g[a>>2]=+g[b+96>>2]*c;g[a+4>>2]=d;return}function Wz(a,b){a=a|0;b=+b;return+(b*0.0)}function Xz(a,b){a=a|0;b=b|0;var c=0;c=a+76|0;g[c>>2]=+g[c>>2]- +g[b>>2];a=a+80|0;g[a>>2]=+g[a>>2]- +g[b+4>>2];return}function Yz(a){a=a|0;a=i;i=i+16|0;Nx(15864,a);i=a;return}function Zz(a){a=a|0;return}function _z(a){a=a|0;var b=0;b=i;OB(a);i=b;return}function $z(b,d){b=b|0;d=d|0;var e=0.0,f=0.0,h=0.0,j=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0,q=0,r=0,s=0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0,K=0.0,L=0.0,M=0,N=0,O=0,P=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0.0,Z=0.0,_=0.0;s=i;q=c[b+48>>2]|0;W=c[q+8>>2]|0;p=b+144|0;c[p>>2]=W;V=c[b+52>>2]|0;T=c[V+8>>2]|0;r=b+148|0;c[r>>2]=T;P=q+28|0;S=c[P>>2]|0;P=c[P+4>>2]|0;N=b+152|0;c[N>>2]=S;c[N+4>>2]=P;N=V+28|0;O=c[N>>2]|0;N=c[N+4>>2]|0;M=b+160|0;c[M>>2]=O;c[M+4>>2]=N;M=b+168|0;g[M>>2]=+g[q+120>>2];u=+g[V+120>>2];g[b+172>>2]=u;v=+g[q+128>>2];g[b+176>>2]=v;x=+g[V+128>>2];g[b+180>>2]=x;V=c[d+24>>2]|0;q=V+(W*12|0)|0;D=+g[q>>2];G=+g[q+4>>2];L=+g[V+(W*12|0)+8>>2];q=d+28|0;U=c[q>>2]|0;X=U+(W*12|0)|0;h=+g[X>>2];j=+g[X+4>>2];n=+g[U+(W*12|0)+8>>2];W=V+(T*12|0)|0;y=+g[W>>2];t=+g[W+4>>2];f=+g[V+(T*12|0)+8>>2];V=U+(T*12|0)|0;l=+g[V>>2];m=+g[V+4>>2];o=+g[U+(T*12|0)+8>>2];A=+R(+L);L=+Q(+L);e=+R(+f);f=+Q(+f);w=+g[b+68>>2]-(c[k>>2]=S,+g[k>>2]);K=+g[b+72>>2]-(c[k>>2]=P,+g[k>>2]);B=L*w-A*K;K=A*w+L*K;w=+g[b+76>>2]-(c[k>>2]=O,+g[k>>2]);C=+g[b+80>>2]-(c[k>>2]=N,+g[k>>2]);J=f*w-e*C;C=e*w+f*C;D=y-D+J-B;G=t-G+C-K;t=+g[M>>2];y=+g[b+84>>2];f=+g[b+88>>2];w=L*y-A*f;f=A*y+L*f;y=+w;e=+f;M=b+184|0;g[M>>2]=y;g[M+4>>2]=e;B=B+D;K=K+G;e=B*f-K*w;g[b+208>>2]=e;y=J*f-C*w;g[b+212>>2]=y;I=t+u;E=v*e;F=x*y;H=I+e*E+y*F;if(H>0.0)z=1.0/H;else z=H;g[b+252>>2]=z;_=+g[b+92>>2];Z=+g[b+96>>2];z=L*_-A*Z;A=A*_+L*Z;Z=+z;_=+A;X=b+192|0;g[X>>2]=Z;g[X+4>>2]=_;B=B*A-K*z;g[b+200>>2]=B;C=J*A-C*z;g[b+204>>2]=C;_=v*B;Z=x*C;Y=_+Z;K=_*e+Z*y;J=x+v;L=E+F;g[b+216>>2]=I+B*_+C*Z;g[b+220>>2]=Y;g[b+224>>2]=K;g[b+228>>2]=Y;g[b+232>>2]=J==0.0?1.0:J;g[b+236>>2]=L;g[b+240>>2]=K;g[b+244>>2]=L;g[b+248>>2]=H;do if(a[b+136>>0]|0){D=D*w+G*f;E=+g[b+124>>2];F=+g[b+120>>2];G=E-F;if(!(G>0.0))G=-G;if(G<.009999999776482582){c[b+140>>2]=3;break}if(D<=F){M=b+140|0;if((c[M>>2]|0)==1)break;c[M>>2]=1;g[b+112>>2]=0.0;break}M=b+140|0;if(!(D>=E)){c[M>>2]=0;g[b+112>>2]=0.0;break}if((c[M>>2]|0)!=2){c[M>>2]=2;g[b+112>>2]=0.0}}else{c[b+140>>2]=0;g[b+112>>2]=0.0}while(0);if(!(a[b+137>>0]|0))g[b+116>>2]=0.0;M=b+104|0;if(!(a[d+20>>0]|0)){c[M+0>>2]=0;c[M+4>>2]=0;c[M+8>>2]=0;c[M+12>>2]=0;J=h;K=j;Y=l;Z=m;L=n;_=o;X=c[p>>2]|0;W=c[q>>2]|0;X=W+(X*12|0)|0;J=+J;K=+K;W=X;g[W>>2]=J;X=X+4|0;g[X>>2]=K;X=c[p>>2]|0;W=c[q>>2]|0;X=W+(X*12|0)+8|0;g[X>>2]=L;X=c[r>>2]|0;X=W+(X*12|0)|0;Y=+Y;Z=+Z;W=X;g[W>>2]=Y;X=X+4|0;g[X>>2]=Z;X=c[r>>2]|0;W=c[q>>2]|0;X=W+(X*12|0)+8|0;g[X>>2]=_;i=s;return}else{W=d+8|0;_=+g[W>>2];I=_*+g[M>>2];g[M>>2]=I;X=b+108|0;H=_*+g[X>>2];g[X>>2]=H;X=b+112|0;_=_*+g[X>>2];g[X>>2]=_;X=b+116|0;Y=+g[W>>2]*+g[X>>2];g[X>>2]=Y;_=Y+_;Y=I*z+w*_;Z=I*A+_*f;J=h-t*Y;K=j-t*Z;Y=l+u*Y;Z=m+u*Z;L=n-v*(I*B+H+_*e);_=o+x*(H+I*C+_*y);X=c[p>>2]|0;W=c[q>>2]|0;X=W+(X*12|0)|0;J=+J;K=+K;W=X;g[W>>2]=J;X=X+4|0;g[X>>2]=K;X=c[p>>2]|0;W=c[q>>2]|0;X=W+(X*12|0)+8|0;g[X>>2]=L;X=c[r>>2]|0;X=W+(X*12|0)|0;Y=+Y;Z=+Z;W=X;g[W>>2]=Y;X=X+4|0;g[X>>2]=Z;X=c[r>>2]|0;W=c[q>>2]|0;X=W+(X*12|0)+8|0;g[X>>2]=_;i=s;return}}function aA(b,d){b=b|0;d=d|0;var e=0,f=0.0,h=0.0,j=0.0,k=0.0,l=0,m=0,n=0,o=0,p=0,q=0.0,r=0,s=0.0,t=0.0,u=0,v=0.0,w=0.0,x=0,y=0,z=0.0,A=0,B=0,C=0.0,D=0.0,E=0,F=0,G=0.0,H=0,I=0,J=0,K=0,L=0,M=0.0,N=0.0,O=0.0,P=0.0,Q=0,R=0.0;e=i;i=i+48|0;o=e+28|0;u=e+16|0;p=e+8|0;B=e;l=b+144|0;n=c[l>>2]|0;m=d+28|0;L=c[m>>2]|0;Q=L+(n*12|0)|0;v=+g[Q>>2];s=+g[Q+4>>2];w=+g[L+(n*12|0)+8>>2];n=b+148|0;Q=c[n>>2]|0;K=L+(Q*12|0)|0;t=+g[K>>2];q=+g[K+4>>2];z=+g[L+(Q*12|0)+8>>2];f=+g[b+168>>2];h=+g[b+172>>2];j=+g[b+176>>2];k=+g[b+180>>2];if((a[b+137>>0]|0)!=0?(c[b+140>>2]|0)!=3:0){M=+g[b+184>>2];G=+g[b+188>>2];O=+g[b+212>>2];N=+g[b+208>>2];Q=b+116|0;P=+g[Q>>2];D=+g[d>>2]*+g[b+128>>2];R=P+ +g[b+252>>2]*(+g[b+132>>2]-((t-v)*M+(q-s)*G+z*O-w*N));C=-D;D=R>2]=D;P=D-P;M=M*P;G=G*P;q=q+h*G;s=s-f*G;t=t+h*M;v=v-f*M;w=w-j*N*P;z=z+k*O*P}O=t-v;P=q-s;x=b+192|0;A=b+196|0;y=b+204|0;d=b+200|0;M=O*+g[x>>2]+P*+g[A>>2]+z*+g[y>>2]-w*+g[d>>2];N=z-w;if((a[b+136>>0]|0)!=0?(r=b+140|0,(c[r>>2]|0)!=0):0){J=b+184|0;L=b+188|0;B=b+212|0;K=b+208|0;H=b+104|0;C=+g[H>>2];I=b+108|0;D=+g[I>>2];F=b+112|0;G=+g[F>>2];E=b+216|0;M=-M;N=-N;O=-(O*+g[J>>2]+P*+g[L>>2]+z*+g[B>>2]-w*+g[K>>2]);g[u>>2]=M;g[u+4>>2]=N;g[u+8>>2]=O;Jx(o,E,u);g[H>>2]=+g[o>>2]+ +g[H>>2];Q=o+4|0;g[I>>2]=+g[Q>>2]+ +g[I>>2];u=o+8|0;O=+g[u>>2]+ +g[F>>2];g[F>>2]=O;r=c[r>>2]|0;if((r|0)==2){O=O<0.0?O:0.0;g[F>>2]=O}else if((r|0)==1){O=O>0.0?O:0.0;g[F>>2]=O}P=O-G;Kx(p,E,M- +g[b+240>>2]*P,N-P*+g[b+244>>2]);M=C+ +g[p>>2];N=D+ +g[p+4>>2];g[H>>2]=M;g[I>>2]=N;M=M-C;N=N-D;P=+g[F>>2]-G;g[o>>2]=M;g[Q>>2]=N;g[u>>2]=P;R=N+M*+g[y>>2]+P*+g[B>>2];O=M*+g[x>>2]+P*+g[J>>2];N=M*+g[d>>2]+N+P*+g[K>>2];P=M*+g[A>>2]+P*+g[L>>2];M=f*P;G=f*O;G=v-G;M=s-M;O=h*O;P=h*P;O=t+O;P=q+P;N=j*N;R=k*R;N=w-N;R=z+R;Q=c[l>>2]|0;L=c[m>>2]|0;Q=L+(Q*12|0)|0;G=+G;M=+M;L=Q;g[L>>2]=G;Q=Q+4|0;g[Q>>2]=M;Q=c[l>>2]|0;L=c[m>>2]|0;Q=L+(Q*12|0)+8|0;g[Q>>2]=N;Q=c[n>>2]|0;Q=L+(Q*12|0)|0;O=+O;P=+P;L=Q;g[L>>2]=O;Q=Q+4|0;g[Q>>2]=P;Q=c[n>>2]|0;L=c[m>>2]|0;Q=L+(Q*12|0)+8|0;g[Q>>2]=R;i=e;return}Kx(B,b+216|0,-M,-N);P=+g[B>>2];Q=b+104|0;g[Q>>2]=P+ +g[Q>>2];N=+g[B+4>>2];Q=b+108|0;g[Q>>2]=N+ +g[Q>>2];R=N+P*+g[y>>2];O=P*+g[x>>2];N=P*+g[d>>2]+N;P=P*+g[A>>2];M=f*P;G=f*O;G=v-G;M=s-M;O=h*O;P=h*P;O=t+O;P=q+P;N=j*N;R=k*R;N=w-N;R=z+R;Q=c[l>>2]|0;L=c[m>>2]|0;Q=L+(Q*12|0)|0;G=+G;M=+M;L=Q;g[L>>2]=G;Q=Q+4|0;g[Q>>2]=M;Q=c[l>>2]|0;L=c[m>>2]|0;Q=L+(Q*12|0)+8|0;g[Q>>2]=N;Q=c[n>>2]|0;Q=L+(Q*12|0)|0;O=+O;P=+P;L=Q;g[L>>2]=O;Q=Q+4|0;g[Q>>2]=P;Q=c[n>>2]|0;L=c[m>>2]|0;Q=L+(Q*12|0)+8|0;g[Q>>2]=R;i=e;return}function bA(b,d){b=b|0;d=d|0;var e=0,f=0,h=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0,y=0.0,z=0.0,A=0.0,B=0.0,C=0,D=0.0,E=0,F=0.0,G=0,H=0.0,I=0.0,J=0.0,K=0.0,L=0.0,M=0.0,N=0.0,O=0,P=0,S=0,T=0.0,U=0.0,V=0.0;f=i;i=i+64|0;G=f+24|0;C=f+12|0;E=f;e=b+144|0;O=c[e>>2]|0;x=d+24|0;P=c[x>>2]|0;d=P+(O*12|0)|0;v=+g[d>>2];w=+g[d+4>>2];z=+g[P+(O*12|0)+8>>2];d=b+148|0;O=c[d>>2]|0;S=P+(O*12|0)|0;A=+g[S>>2];B=+g[S+4>>2];l=+g[P+(O*12|0)+8>>2];L=+R(+z);N=+Q(+z);m=+R(+l);I=+Q(+l);n=+g[b+168>>2];o=+g[b+172>>2];y=+g[b+176>>2];h=+g[b+180>>2];J=+g[b+68>>2]- +g[b+152>>2];p=+g[b+72>>2]- +g[b+156>>2];D=N*J-L*p;p=L*J+N*p;J=+g[b+76>>2]- +g[b+160>>2];q=+g[b+80>>2]- +g[b+164>>2];F=I*J-m*q;q=m*J+I*q;I=A+F-v-D;J=B+q-w-p;m=+g[b+84>>2];t=+g[b+88>>2];r=N*m-L*t;t=L*m+N*t;D=D+I;p=p+J;m=t*D-r*p;k=F*t-q*r;M=+g[b+92>>2];u=+g[b+96>>2];s=N*M-L*u;u=L*M+N*u;p=u*D-s*p;q=F*u-q*s;F=s*I+u*J;D=l-z- +g[b+100>>2];if(F>0.0)H=F;else H=-F;if(D>0.0)j=D;else j=-D;do if(a[b+136>>0]|0){I=r*I+t*J;J=+g[b+124>>2];K=+g[b+120>>2];L=J-K;if(!(L>0.0))L=-L;if(L<.009999999776482582){J=I<.20000000298023224?I:.20000000298023224;if(!(I>0.0))I=-I;K=J<-.20000000298023224?-.20000000298023224:J;b=1;H=H>I?H:I;break}if(I<=K){M=I-K+.004999999888241291;M=M<0.0?M:0.0;N=K-I;K=M<-.20000000298023224?-.20000000298023224:M;b=1;H=H>N?H:N;break}if(I>=J){N=I-J;K=N+-.004999999888241291;K=K<.20000000298023224?K:.20000000298023224;K=K<0.0?0.0:K;b=1;H=H>N?H:N}else{K=0.0;b=0}}else{K=0.0;b=0}while(0);L=n+o;M=y*p;N=h*q;I=q*N+(L+p*M);J=N+M;if(b){U=k*N+m*M;V=y+h;N=y*m;M=h*k;T=M+N;g[G>>2]=I;g[G+4>>2]=J;g[G+8>>2]=U;g[G+12>>2]=J;g[G+16>>2]=V==0.0?1.0:V;g[G+20>>2]=T;g[G+24>>2]=U;g[G+28>>2]=T;g[G+32>>2]=k*M+(L+m*N);g[E>>2]=-F;g[E+4>>2]=-D;g[E+8>>2]=-K;Jx(C,G,E);D=+g[C>>2];K=+g[C+8>>2];F=+g[C+4>>2]}else{K=y+h;K=K==0.0?1.0:K;F=-F;L=-D;M=K*I-J*J;if(M!=0.0)M=1.0/M;D=(K*F-J*L)*M;K=0.0;F=(I*L-J*F)*M}U=r*K+s*D;V=t*K+u*D;N=+(v-n*U);T=+(w-n*V);S=(c[x>>2]|0)+((c[e>>2]|0)*12|0)|0;g[S>>2]=N;g[S+4>>2]=T;S=c[x>>2]|0;g[S+((c[e>>2]|0)*12|0)+8>>2]=z-y*(m*K+(F+p*D));U=+(A+o*U);V=+(B+o*V);S=S+((c[d>>2]|0)*12|0)|0;g[S>>2]=U;g[S+4>>2]=V;g[(c[x>>2]|0)+((c[d>>2]|0)*12|0)+8>>2]=l+h*(k*K+(F+q*D));if(!(H<=.004999999888241291)){S=0;i=f;return S|0}S=j<=.03490658849477768;i=f;return S|0}function cA(a,b){a=a|0;b=b|0;var d=0.0,e=0.0,f=0.0,h=0.0,i=0.0,j=0;j=c[b+48>>2]|0;i=+g[j+24>>2];h=+g[b+68>>2];f=+g[j+20>>2];e=+g[b+72>>2];d=h*f+i*e+ +g[j+16>>2];g[a>>2]=+g[j+12>>2]+(i*h-f*e);g[a+4>>2]=d;return}function dA(a,b){a=a|0;b=b|0;var d=0.0,e=0.0,f=0.0,h=0.0,i=0.0,j=0;j=c[b+52>>2]|0;i=+g[j+24>>2];h=+g[b+76>>2];f=+g[j+20>>2];e=+g[b+80>>2];d=h*f+i*e+ +g[j+16>>2];g[a>>2]=+g[j+12>>2]+(i*h-f*e);g[a+4>>2]=d;return}function eA(a,b,c){a=a|0;b=b|0;c=+c;var d=0.0,e=0.0,f=0.0;f=+g[b+104>>2];e=+g[b+116>>2]+ +g[b+112>>2];d=(f*+g[b+196>>2]+e*+g[b+188>>2])*c;g[a>>2]=(f*+g[b+192>>2]+ +g[b+184>>2]*e)*c;g[a+4>>2]=d;return}function fA(a,b){a=a|0;b=+b;return+(+g[a+108>>2]*b)}function gA(a){a=a|0;var b=0,e=0,f=0,j=0.0,l=0;b=i;i=i+16|0;e=b;l=c[(c[a+48>>2]|0)+8>>2]|0;f=c[(c[a+52>>2]|0)+8>>2]|0;Nx(16016,e);c[e>>2]=l;Nx(17320,e);c[e>>2]=f;Nx(17352,e);c[e>>2]=d[a+61>>0];Nx(17384,e);j=+g[a+72>>2];h[k>>3]=+g[a+68>>2];c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];f=e+8|0;h[k>>3]=j;c[f>>2]=c[k>>2];c[f+4>>2]=c[k+4>>2];Nx(17424,e);j=+g[a+80>>2];h[k>>3]=+g[a+76>>2];c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];f=e+8|0;h[k>>3]=j;c[f>>2]=c[k>>2];c[f+4>>2]=c[k+4>>2];Nx(17472,e);j=+g[a+88>>2];h[k>>3]=+g[a+84>>2];c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];f=e+8|0;h[k>>3]=j;c[f>>2]=c[k>>2];c[f+4>>2]=c[k+4>>2];Nx(17520,e);h[k>>3]=+g[a+100>>2];c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];Nx(17176,e);c[e>>2]=d[a+136>>0];Nx(16816,e);h[k>>3]=+g[a+120>>2];c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];Nx(16048,e);h[k>>3]=+g[a+124>>2];c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];Nx(16088,e);c[e>>2]=d[a+137>>0];Nx(17560,e);h[k>>3]=+g[a+132>>2];c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];Nx(17592,e);h[k>>3]=+g[a+128>>2];c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];Nx(16128,e);c[e>>2]=c[a+56>>2];Nx(17720,e);i=b;return}function hA(a){a=a|0;return}function iA(a){a=a|0;var b=0;b=i;OB(a);i=b;return}function jA(b,d){b=b|0;d=d|0;var e=0.0,f=0.0,h=0.0,j=0.0,l=0.0,m=0,n=0,o=0,p=0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0,w=0.0,x=0.0,y=0,z=0,A=0,B=0.0,C=0.0,D=0,E=0.0,F=0.0,G=0,H=0.0,I=0.0,J=0.0,K=0.0,L=0,M=0,N=0,P=0,S=0,T=0,U=0.0;p=i;v=c[b+48>>2]|0;S=c[v+8>>2]|0;m=b+120|0;c[m>>2]=S;P=c[b+52>>2]|0;M=c[P+8>>2]|0;o=b+124|0;c[o>>2]=M;D=v+28|0;L=c[D>>2]|0;D=c[D+4>>2]|0;y=b+160|0;c[y>>2]=L;c[y+4>>2]=D;y=P+28|0;G=c[y>>2]|0;y=c[y+4>>2]|0;A=b+168|0;c[A>>2]=G;c[A+4>>2]=y;A=b+176|0;g[A>>2]=+g[v+120>>2];y=b+180|0;g[y>>2]=+g[P+120>>2];z=b+184|0;g[z>>2]=+g[v+128>>2];v=b+188|0;g[v>>2]=+g[P+128>>2];P=c[d+24>>2]|0;n=P+(S*12|0)|0;x=+g[n>>2];F=+g[n+4>>2];t=+g[P+(S*12|0)+8>>2];n=d+28|0;N=c[n>>2]|0;T=N+(S*12|0)|0;u=+g[T>>2];s=+g[T+4>>2];j=+g[N+(S*12|0)+8>>2];S=P+(M*12|0)|0;C=+g[S>>2];E=+g[S+4>>2];B=+g[P+(M*12|0)+8>>2];P=N+(M*12|0)|0;f=+g[P>>2];h=+g[P+4>>2];l=+g[N+(M*12|0)+8>>2];e=+R(+t);t=+Q(+t);K=+R(+B);B=+Q(+B);w=+g[b+92>>2]-(c[k>>2]=L,+g[k>>2]);r=+g[b+96>>2]-(c[k>>2]=D,+g[k>>2]);q=t*w-e*r;r=e*w+t*r;t=+q;w=+r;D=b+144|0;g[D>>2]=t;g[D+4>>2]=w;w=+g[b+100>>2]-(c[k>>2]=G,+g[k>>2]);t=+g[b+104>>2]- +g[b+172>>2];e=B*w-K*t;t=K*w+B*t;B=+e;w=+t;G=b+152|0;g[G>>2]=B;g[G+4>>2]=w;G=b+128|0;x=x+q- +g[b+68>>2];F=F+r- +g[b+72>>2];w=+x;B=+F;D=G;g[D>>2]=w;g[D+4>>2]=B;D=b+136|0;C=C+e- +g[b+76>>2];E=E+t- +g[b+80>>2];B=+C;w=+E;L=D;g[L>>2]=B;g[L+4>>2]=w;w=+O(+(x*x+F*F));B=+O(+(C*C+E*E));if(w>.04999999701976776){w=1.0/w;x=x*w;g[G>>2]=x;w=w*F}else{g[G>>2]=0.0;w=0.0;x=0.0}g[b+132>>2]=w;if(B>.04999999701976776){B=1.0/B;C=B*C;g[D>>2]=C;B=B*E}else{g[D>>2]=0.0;B=0.0;C=0.0}g[b+140>>2]=B;U=q*w-r*x;K=e*B-t*C;E=+g[A>>2];F=+g[z>>2];H=+g[y>>2];J=+g[v>>2];I=+g[b+112>>2];K=E+U*U*F+I*I*(H+K*K*J);if(K>0.0)K=1.0/K;g[b+192>>2]=K;if(!(a[d+20>>0]|0)){g[b+116>>2]=0.0;F=u;H=s;J=f;K=h;I=j;U=l;T=c[m>>2]|0;S=c[n>>2]|0;T=S+(T*12|0)|0;F=+F;H=+H;S=T;g[S>>2]=F;T=T+4|0;g[T>>2]=H;T=c[m>>2]|0;S=c[n>>2]|0;T=S+(T*12|0)+8|0;g[T>>2]=I;T=c[o>>2]|0;T=S+(T*12|0)|0;J=+J;K=+K;S=T;g[S>>2]=J;T=T+4|0;g[T>>2]=K;T=c[o>>2]|0;S=c[n>>2]|0;T=S+(T*12|0)+8|0;g[T>>2]=U;i=p;return}else{T=b+116|0;U=+g[d+8>>2]*+g[T>>2];g[T>>2]=U;K=-U;x=x*K;w=w*K;I=-(U*I);U=C*I;B=B*I;C=u+x*E;E=s+w*E;I=f+U*H;K=h+B*H;H=j+F*(w*q-x*r);U=l+J*(B*e-U*t);T=c[m>>2]|0;S=c[n>>2]|0;T=S+(T*12|0)|0;F=+C;J=+E;S=T;g[S>>2]=F;T=T+4|0;g[T>>2]=J;T=c[m>>2]|0;S=c[n>>2]|0;T=S+(T*12|0)+8|0;g[T>>2]=H;T=c[o>>2]|0;T=S+(T*12|0)|0;J=+I;K=+K;S=T;g[S>>2]=J;T=T+4|0;g[T>>2]=K;T=c[o>>2]|0;S=c[n>>2]|0;T=S+(T*12|0)+8|0;g[T>>2]=U;i=p;return}}function kA(a,b){a=a|0;b=b|0;var d=0,e=0,f=0.0,h=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0,o=0.0,p=0.0,q=0.0,r=0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0,A=0,B=0;d=i;n=a+120|0;z=c[n>>2]|0;e=b+28|0;A=c[e>>2]|0;r=A+(z*12|0)|0;b=r;u=+g[b>>2];t=+g[b+4>>2];x=+g[A+(z*12|0)+8>>2];b=a+124|0;z=c[b>>2]|0;B=A+(z*12|0)|0;m=+g[B>>2];l=+g[B+4>>2];w=+g[A+(z*12|0)+8>>2];o=+g[a+148>>2];h=+g[a+144>>2];f=+g[a+156>>2];v=+g[a+152>>2];q=+g[a+128>>2];s=+g[a+132>>2];y=+g[a+112>>2];j=+g[a+136>>2];k=+g[a+140>>2];p=+g[a+192>>2]*(-((u-x*o)*q+(t+x*h)*s)-y*((m-w*f)*j+(l+w*v)*k));z=a+116|0;g[z>>2]=+g[z>>2]-p;q=q*p;s=s*p;p=y*p;j=j*p;k=p*k;p=+g[a+176>>2];o=x+ +g[a+184>>2]*(s*h-q*o);h=+g[a+180>>2];f=w+ +g[a+188>>2]*(k*v-j*f);q=+(u+q*p);p=+(t+s*p);a=r;g[a>>2]=q;g[a+4>>2]=p;a=c[e>>2]|0;g[a+((c[n>>2]|0)*12|0)+8>>2]=o;j=+(m+j*h);h=+(l+k*h);a=a+((c[b>>2]|0)*12|0)|0;g[a>>2]=j;g[a+4>>2]=h;g[(c[e>>2]|0)+((c[b>>2]|0)*12|0)+8>>2]=f;i=d;return}function lA(a,b){a=a|0;b=b|0;var d=0,e=0,f=0.0,h=0.0,j=0.0,k=0.0,l=0,m=0.0,n=0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0,G=0,H=0,I=0.0;d=i;e=a+120|0;n=c[e>>2]|0;b=b+24|0;G=c[b>>2]|0;l=G+(n*12|0)|0;F=l;k=+g[F>>2];r=+g[F+4>>2];f=+g[G+(n*12|0)+8>>2];n=a+124|0;F=c[n>>2]|0;H=G+(F*12|0)|0;s=+g[H>>2];m=+g[H+4>>2];o=+g[G+(F*12|0)+8>>2];p=+R(+f);t=+Q(+f);y=+R(+o);v=+Q(+o);q=+g[a+92>>2]- +g[a+160>>2];j=+g[a+96>>2]- +g[a+164>>2];h=t*q-p*j;j=p*q+t*j;t=+g[a+100>>2]- +g[a+168>>2];q=+g[a+104>>2]- +g[a+172>>2];p=v*t-y*q;q=y*t+v*q;v=k+h- +g[a+68>>2];t=r+j- +g[a+72>>2];y=s+p- +g[a+76>>2];x=m+q- +g[a+80>>2];w=+O(+(v*v+t*t));u=+O(+(y*y+x*x));if(w>.04999999701976776){E=1.0/w;t=t*E;v=v*E}else{t=0.0;v=0.0}if(u>.04999999701976776){D=1.0/u;x=x*D;D=y*D}else{x=0.0;D=0.0}I=h*t-j*v;E=p*x-q*D;A=+g[a+176>>2];z=+g[a+184>>2];y=+g[a+180>>2];B=+g[a+188>>2];C=+g[a+112>>2];E=A+I*I*z+C*C*(y+E*E*B);if(E>0.0)E=1.0/E;u=+g[a+108>>2]-w-u*C;if(u>0.0)w=u;else w=-u;E=E*u;v=v*E;u=t*E;E=E*C;I=D*E;E=x*E;D=+(k+v*A);C=+(r+u*A);H=l;g[H>>2]=D;g[H+4>>2]=C;H=c[b>>2]|0;g[H+((c[e>>2]|0)*12|0)+8>>2]=f+(h*u-j*v)*z;C=+(s+I*y);D=+(m+E*y);H=H+((c[n>>2]|0)*12|0)|0;g[H>>2]=C;g[H+4>>2]=D;g[(c[b>>2]|0)+((c[n>>2]|0)*12|0)+8>>2]=o+B*(p*E-q*I);i=d;return w<.004999999888241291|0}function mA(a,b){a=a|0;b=b|0;var d=0.0,e=0.0,f=0.0,h=0.0,i=0.0,j=0;j=c[b+48>>2]|0;i=+g[j+24>>2];h=+g[b+92>>2];f=+g[j+20>>2];e=+g[b+96>>2];d=h*f+i*e+ +g[j+16>>2];g[a>>2]=+g[j+12>>2]+(i*h-f*e);g[a+4>>2]=d;return}function nA(a,b){a=a|0;b=b|0;var d=0.0,e=0.0,f=0.0,h=0.0,i=0.0,j=0;j=c[b+52>>2]|0;i=+g[j+24>>2];h=+g[b+100>>2];f=+g[j+20>>2];e=+g[b+104>>2];d=h*f+i*e+ +g[j+16>>2];g[a>>2]=+g[j+12>>2]+(i*h-f*e);g[a+4>>2]=d;return}function oA(a,b,c){a=a|0;b=b|0;c=+c;var d=0.0,e=0.0;e=+g[b+116>>2];d=e*+g[b+140>>2]*c;g[a>>2]=e*+g[b+136>>2]*c;g[a+4>>2]=d;return}function pA(a,b){a=a|0;b=+b;return 0.0}function qA(a){a=a|0;var b=0,e=0,f=0,j=0.0,l=0;b=i;i=i+16|0;e=b;l=c[(c[a+48>>2]|0)+8>>2]|0;f=c[(c[a+52>>2]|0)+8>>2]|0;Nx(16400,e);c[e>>2]=l;Nx(17320,e);c[e>>2]=f;Nx(17352,e);c[e>>2]=d[a+61>>0];Nx(17384,e);j=+g[a+72>>2];h[k>>3]=+g[a+68>>2];c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];f=e+8|0;h[k>>3]=j;c[f>>2]=c[k>>2];c[f+4>>2]=c[k+4>>2];Nx(16424,e);j=+g[a+80>>2];h[k>>3]=+g[a+76>>2];c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];f=e+8|0;h[k>>3]=j;c[f>>2]=c[k>>2];c[f+4>>2]=c[k+4>>2];Nx(16472,e);j=+g[a+96>>2];h[k>>3]=+g[a+92>>2];c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];f=e+8|0;h[k>>3]=j;c[f>>2]=c[k>>2];c[f+4>>2]=c[k+4>>2];Nx(17424,e);j=+g[a+104>>2];h[k>>3]=+g[a+100>>2];c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];f=e+8|0;h[k>>3]=j;c[f>>2]=c[k>>2];c[f+4>>2]=c[k+4>>2];Nx(17472,e);h[k>>3]=+g[a+84>>2];c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];Nx(16520,e);h[k>>3]=+g[a+88>>2];c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];Nx(16552,e);h[k>>3]=+g[a+112>>2];c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];Nx(16584,e);c[e>>2]=c[a+56>>2];Nx(17720,e);i=b;return}function rA(a,b){a=a|0;b=b|0;var c=0,d=0;c=a+68|0;g[c>>2]=+g[c>>2]- +g[b>>2];c=b+4|0;d=a+72|0;g[d>>2]=+g[d>>2]- +g[c>>2];d=a+76|0;g[d>>2]=+g[d>>2]- +g[b>>2];b=a+80|0;g[b>>2]=+g[b>>2]- +g[c>>2];return}function sA(a){a=a|0;return}function tA(a){a=a|0;var b=0;b=i;OB(a);i=b;return}function uA(b,d){b=b|0;d=d|0;var e=0.0,f=0.0,h=0.0,j=0.0,l=0.0,m=0.0,n=0,o=0,p=0,q=0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0,D=0.0,E=0.0,F=0.0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0.0,P=0.0,S=0.0;q=i;o=c[b+48>>2]|0;M=c[o+8>>2]|0;n=b+128|0;c[n>>2]=M;L=c[b+52>>2]|0;J=c[L+8>>2]|0;p=b+132|0;c[p>>2]=J;H=o+28|0;I=c[H>>2]|0;H=c[H+4>>2]|0;C=b+152|0;c[C>>2]=I;c[C+4>>2]=H;C=L+28|0;G=c[C>>2]|0;C=c[C+4>>2]|0;K=b+160|0;c[K>>2]=G;c[K+4>>2]=C;r=+g[o+120>>2];g[b+168>>2]=r;s=+g[L+120>>2];g[b+172>>2]=s;t=+g[o+128>>2];g[b+176>>2]=t;e=+g[L+128>>2];g[b+180>>2]=e;L=c[d+24>>2]|0;A=+g[L+(M*12|0)+8>>2];o=d+28|0;K=c[o>>2]|0;N=K+(M*12|0)|0;w=+g[N>>2];f=+g[N+4>>2];l=+g[K+(M*12|0)+8>>2];z=+g[L+(J*12|0)+8>>2];L=K+(J*12|0)|0;h=+g[L>>2];j=+g[L+4>>2];m=+g[K+(J*12|0)+8>>2];x=+R(+A);y=+Q(+A);F=+R(+z);D=+Q(+z);B=+g[b+68>>2]-(c[k>>2]=I,+g[k>>2]);v=+g[b+72>>2]-(c[k>>2]=H,+g[k>>2]);u=y*B-x*v;v=x*B+y*v;y=+u;B=+v;H=b+136|0;g[H>>2]=y;g[H+4>>2]=B;B=+g[b+76>>2]-(c[k>>2]=G,+g[k>>2]);y=+g[b+80>>2]-(c[k>>2]=C,+g[k>>2]);x=D*B-F*y;y=F*B+D*y;D=+x;B=+y;C=b+144|0;g[C>>2]=D;g[C+4>>2]=B;B=t+e;C=B==0.0;D=r+s;g[b+184>>2]=D+t*v*v+e*y*y;F=-(t*v*u)-e*y*x;g[b+196>>2]=F;E=-(t*v)-e*y;g[b+208>>2]=E;g[b+188>>2]=F;g[b+200>>2]=D+t*u*u+e*x*x;D=t*u+e*x;g[b+212>>2]=D;g[b+192>>2]=E;g[b+204>>2]=D;g[b+216>>2]=B;if(B>0.0)B=1.0/B;g[b+220>>2]=B;if((a[b+100>>0]|0)==0|C)g[b+96>>2]=0.0;do if((a[b+112>>0]|0)==0|C)c[b+224>>2]=0;else{z=z-A- +g[b+116>>2];A=+g[b+124>>2];B=+g[b+120>>2];D=A-B;if(!(D>0.0))D=-D;if(D<.06981317698955536){c[b+224>>2]=3;break}if(z<=B){C=b+224|0;if((c[C>>2]|0)!=1)g[b+92>>2]=0.0;c[C>>2]=1;break}C=b+224|0;if(!(z>=A)){c[C>>2]=0;g[b+92>>2]=0.0;break}if((c[C>>2]|0)!=2)g[b+92>>2]=0.0;c[C>>2]=2}while(0);C=b+84|0;if(!(a[d+20>>0]|0)){c[C+0>>2]=0;c[C+4>>2]=0;c[C+8>>2]=0;c[C+12>>2]=0;z=w;A=f;D=h;E=j;B=l;F=m;N=c[n>>2]|0;M=c[o>>2]|0;N=M+(N*12|0)|0;z=+z;A=+A;M=N;g[M>>2]=z;N=N+4|0;g[N>>2]=A;N=c[n>>2]|0;M=c[o>>2]|0;N=M+(N*12|0)+8|0;g[N>>2]=B;N=c[p>>2]|0;N=M+(N*12|0)|0;D=+D;E=+E;M=N;g[M>>2]=D;N=N+4|0;g[N>>2]=E;N=c[p>>2]|0;M=c[o>>2]|0;N=M+(N*12|0)+8|0;g[N>>2]=F;i=q;return}else{M=d+8|0;S=+g[M>>2];F=S*+g[C>>2];g[C>>2]=F;N=b+88|0;O=S*+g[N>>2];g[N>>2]=O;N=b+92|0;S=S*+g[N>>2];g[N>>2]=S;N=b+96|0;P=+g[M>>2]*+g[N>>2];g[N>>2]=P;z=w-r*F;A=f-r*O;D=h+s*F;E=j+s*O;B=l-t*(S+(P+(O*u-F*v)));F=m+e*(S+(P+(O*x-F*y)));N=c[n>>2]|0;M=c[o>>2]|0;N=M+(N*12|0)|0;z=+z;A=+A;M=N;g[M>>2]=z;N=N+4|0;g[N>>2]=A;N=c[n>>2]|0;M=c[o>>2]|0;N=M+(N*12|0)+8|0;g[N>>2]=B;N=c[p>>2]|0;N=M+(N*12|0)|0;D=+D;E=+E;M=N;g[M>>2]=D;N=N+4|0;g[N>>2]=E;N=c[p>>2]|0;M=c[o>>2]|0;N=M+(N*12|0)+8|0;g[N>>2]=F;i=q;return}} function Vs(a,d){a=a|0;d=d|0;var e=0,f=0,g=0,h=0,j=0;e=i;f=a+88|0;g=c[f>>2]|0;if(c[g+102868>>2]&2)Aa(8888,8624,456,9112);h=a+4|0;j=b[h>>1]|0;if(!((j&32)!=0^d)){i=e;return}j=j&65535;if(d){b[h>>1]=j|32;f=g+102872|0;g=c[a+100>>2]|0;if(!g){i=e;return}a=a+12|0;do{ky(g,f,a);g=c[g+4>>2]|0}while((g|0)!=0);i=e;return}b[h>>1]=j&65503;g=g+102872|0;d=c[a+100>>2]|0;if(d)do{ly(d,g);d=c[d+4>>2]|0}while((d|0)!=0);a=a+112|0;g=c[a>>2]|0;if(g)do{j=g;g=c[g+12>>2]|0;Xx((c[f>>2]|0)+102872|0,c[j+4>>2]|0)}while((g|0)!=0);c[a>>2]=0;i=e;return}function Ws(a){a=a|0;return(b[a+4>>1]&32)!=0|0}function Xs(a,c){a=a|0;c=c|0;var d=0,f=0,h=0;d=i;h=a+4|0;f=e[h>>1]|0;if(!((f&16|0)!=0^c)){i=d;return}b[h>>1]=c?f|16:f&65519;g[a+72>>2]=0.0;Qx(a);i=d;return}function Ys(a){a=a|0;return(b[a+4>>1]&16)!=0|0}function Zs(a){a=a|0;return c[a+100>>2]|0}function _s(a){a=a|0;return c[a+108>>2]|0}function $s(a){a=a|0;return c[a+112>>2]|0}function at(a){a=a|0;return c[a+96>>2]|0}function bt(a){a=a|0;return c[a+148>>2]|0}function ct(a,b){a=a|0;b=b|0;c[a+148>>2]=b;return}function dt(a){a=a|0;return c[a+88>>2]|0}function et(a){a=a|0;var b=0;b=i;Ux(a);i=b;return}function ft(a){a=a|0;return a+68|0}function gt(a){a=a|0;return a+76|0}function ht(a,b){a=a|0;b=+b;var d=0;d=i;if(((g[k>>2]=b,c[k>>2]|0)&2139095040|0)!=2139095040&b>=0.0){g[a+96>>2]=b;i=d;return}else Aa(14504,14544,217,14600)}function it(a){a=a|0;return+(+g[a+96>>2])}function jt(a,b){a=a|0;b=+b;var d=0;d=i;if(((g[k>>2]=b,c[k>>2]|0)&2139095040|0)!=2139095040&b>=0.0){g[a+100>>2]=b;i=d;return}else Aa(14616,14544,228,14656)}function kt(a){a=a|0;return+(+g[a+100>>2])}function lt(a){a=a|0;return c[a+4>>2]|0}function mt(a){a=a|0;return c[a+48>>2]|0}function nt(a){a=a|0;return c[a+52>>2]|0}function ot(b){b=b|0;var d=0,e=0,f=0;e=i;i=i+16|0;d=e;if((a[816]|0)==0?(wa(816)|0)!=0:0)Da(816);lb[c[c[b>>2]>>2]&127](d,b);f=d;b=c[f+4>>2]|0;d=808;c[d>>2]=c[f>>2];c[d+4>>2]=b;i=e;return 808}function pt(b){b=b|0;var d=0,e=0,f=0;e=i;i=i+16|0;d=e;if((a[832]|0)==0?(wa(832)|0)!=0:0)Da(832);lb[c[(c[b>>2]|0)+4>>2]&127](d,b);f=d;b=c[f+4>>2]|0;d=824;c[d>>2]=c[f>>2];c[d+4>>2]=b;i=e;return 824}function qt(b,d){b=b|0;d=+d;var e=0,f=0,g=0;f=i;i=i+16|0;e=f;if((a[848]|0)==0?(wa(848)|0)!=0:0)Da(848);rb[c[(c[b>>2]|0)+8>>2]&63](e,b,d);g=e;b=c[g+4>>2]|0;e=840;c[e>>2]=c[g>>2];c[e+4>>2]=b;i=f;return 840}function rt(a,b){a=a|0;b=+b;var d=0;d=i;b=+ib[c[(c[a>>2]|0)+12>>2]&63](a,b);i=d;return+b}function st(a){a=a|0;return c[a+12>>2]|0}function tt(a){a=a|0;return c[a+64>>2]|0}function ut(a,b){a=a|0;b=b|0;c[a+64>>2]=b;return}function vt(a){a=a|0;var d=0;d=i;if(!(b[(c[a+48>>2]|0)+4>>1]&32)){a=0;i=d;return a|0}a=(b[(c[a+52>>2]|0)+4>>1]&32)!=0;i=d;return a|0}function wt(b){b=b|0;return(a[b+61>>0]|0)!=0|0}function xt(a){a=a|0;var b=0;b=i;if(!a){i=b;return}jb[c[(c[a>>2]|0)+28>>2]&127](a);i=b;return}function yt(a){a=a|0;var b=0;b=i;if(!a){i=b;return}jb[c[(c[a>>2]|0)+4>>2]&127](a);i=b;return}function zt(){var b=0,d=0;b=i;d=NB(32)|0;a:do if(!d){while(1){d=c[4582]|0;c[4582]=d+0;if(!d)break;qb[d&63]();d=NB(32)|0;if(d)break a}d=cb(4)|0;c[d>>2]=18168;_a(d|0,18216,116)}while(0);c[d+0>>2]=0;c[d+4>>2]=0;c[d+8>>2]=0;c[d+12>>2]=0;a[d+16>>0]=0;c[d>>2]=6;c[d+20>>2]=0;c[d+24>>2]=0;g[d+28>>2]=1.0;i=b;return d|0}function At(a){a=a|0;return c[a+20>>2]|0}function Bt(a,b){a=a|0;b=b|0;c[a+20>>2]=b;return}function Ct(a){a=a|0;return c[a+24>>2]|0}function Dt(a,b){a=a|0;b=b|0;c[a+24>>2]=b;return}function Et(a){a=a|0;return+(+g[a+28>>2])}function Ft(a,b){a=a|0;b=+b;g[a+28>>2]=b;return}function Gt(a){a=a|0;return c[a>>2]|0}function Ht(a,b){a=a|0;b=b|0;c[a>>2]=b;return}function It(a){a=a|0;return c[a+4>>2]|0}function Jt(a,b){a=a|0;b=b|0;c[a+4>>2]=b;return}function Kt(a){a=a|0;return c[a+8>>2]|0}function Lt(a,b){a=a|0;b=b|0;c[a+8>>2]=b;return}function Mt(a){a=a|0;return c[a+12>>2]|0}function Nt(a,b){a=a|0;b=b|0;c[a+12>>2]=b;return}function Ot(b){b=b|0;return(a[b+16>>0]|0)!=0|0}function Pt(b,c){b=b|0;c=c|0;a[b+16>>0]=c&1;return}function Qt(a){a=a|0;var b=0;b=i;if(a)OB(a);i=b;return}function Rt(a){a=a|0;return a+68|0}function St(a){a=a|0;return a+76|0}function Tt(a){a=a|0;return+(+g[a+116>>2])}function Ut(a){a=a|0;return+(+g[(c[a+52>>2]|0)+56>>2]- +g[(c[a+48>>2]|0)+56>>2]- +g[a+116>>2])}function Vt(a){a=a|0;return+(+g[(c[a+52>>2]|0)+72>>2]- +g[(c[a+48>>2]|0)+72>>2])}function Wt(b){b=b|0;return(a[b+112>>0]|0)!=0|0}function Xt(f,h){f=f|0;h=h|0;var j=0,k=0,l=0,m=0,n=0;j=i;k=f+112|0;if((h&1|0)==(d[k>>0]|0|0)){i=j;return}l=c[f+48>>2]|0;m=l+4|0;n=e[m>>1]|0;if(!(n&2)){b[m>>1]=n|2;g[l+144>>2]=0.0}l=c[f+52>>2]|0;m=l+4|0;n=e[m>>1]|0;if(!(n&2)){b[m>>1]=n|2;g[l+144>>2]=0.0}a[k>>0]=h&1;g[f+92>>2]=0.0;i=j;return}function Yt(a){a=a|0;return+(+g[a+120>>2])}function Zt(a){a=a|0;return+(+g[a+124>>2])}function _t(a,d,f){a=a|0;d=+d;f=+f;var h=0,j=0,k=0,l=0,m=0;j=i;if(!(d<=f))Aa(16696,16712,471,16768);h=a+120|0;if(!(+g[h>>2]!=d)?!(+g[a+124>>2]!=f):0){i=j;return}m=c[a+48>>2]|0;k=m+4|0;l=e[k>>1]|0;if(!(l&2)){b[k>>1]=l|2;g[m+144>>2]=0.0}l=c[a+52>>2]|0;m=l+4|0;k=e[m>>1]|0;if(!(k&2)){b[m>>1]=k|2;g[l+144>>2]=0.0}g[a+92>>2]=0.0;g[h>>2]=d;g[a+124>>2]=f;i=j;return}function $t(b){b=b|0;return(a[b+100>>0]|0)!=0|0}function au(d,f){d=d|0;f=f|0;var h=0,j=0,k=0,l=0;h=i;j=c[d+48>>2]|0;k=j+4|0;l=e[k>>1]|0;if(!(l&2)){b[k>>1]=l|2;g[j+144>>2]=0.0}l=c[d+52>>2]|0;k=l+4|0;j=e[k>>1]|0;if(j&2){l=d+100|0;k=f&1;a[l>>0]=k;i=h;return}b[k>>1]=j|2;g[l+144>>2]=0.0;l=d+100|0;k=f&1;a[l>>0]=k;i=h;return}function bu(a,d){a=a|0;d=+d;var f=0,h=0,j=0,k=0;f=i;h=c[a+48>>2]|0;j=h+4|0;k=e[j>>1]|0;if(!(k&2)){b[j>>1]=k|2;g[h+144>>2]=0.0}k=c[a+52>>2]|0;j=k+4|0;h=e[j>>1]|0;if(h&2){k=a+108|0;g[k>>2]=d;i=f;return}b[j>>1]=h|2;g[k+144>>2]=0.0;k=a+108|0;g[k>>2]=d;i=f;return}function cu(a){a=a|0;return+(+g[a+108>>2])}function du(a,d){a=a|0;d=+d;var f=0,h=0,j=0,k=0;f=i;h=c[a+48>>2]|0;j=h+4|0;k=e[j>>1]|0;if(!(k&2)){b[j>>1]=k|2;g[h+144>>2]=0.0}k=c[a+52>>2]|0;j=k+4|0;h=e[j>>1]|0;if(h&2){k=a+104|0;g[k>>2]=d;i=f;return}b[j>>1]=h|2;g[k+144>>2]=0.0;k=a+104|0;g[k>>2]=d;i=f;return}function eu(a){a=a|0;return+(+g[a+104>>2])}function fu(a,b){a=a|0;b=+b;return+(+g[a+96>>2]*b)}function gu(a){a=a|0;return c[a+4>>2]|0}function hu(a){a=a|0;return c[a+48>>2]|0}function iu(a){a=a|0;return c[a+52>>2]|0}function ju(b){b=b|0;var d=0,e=0,f=0;e=i;i=i+16|0;d=e;if((a[864]|0)==0?(wa(864)|0)!=0:0)Da(864);lb[c[c[b>>2]>>2]&127](d,b);f=d;b=c[f+4>>2]|0;d=856;c[d>>2]=c[f>>2];c[d+4>>2]=b;i=e;return 856}function ku(b){b=b|0;var d=0,e=0,f=0;e=i;i=i+16|0;d=e;if((a[880]|0)==0?(wa(880)|0)!=0:0)Da(880);lb[c[(c[b>>2]|0)+4>>2]&127](d,b);f=d;b=c[f+4>>2]|0;d=872;c[d>>2]=c[f>>2];c[d+4>>2]=b;i=e;return 872}function lu(b,d){b=b|0;d=+d;var e=0,f=0,g=0;f=i;i=i+16|0;e=f;if((a[896]|0)==0?(wa(896)|0)!=0:0)Da(896);rb[c[(c[b>>2]|0)+8>>2]&63](e,b,d);g=e;b=c[g+4>>2]|0;e=888;c[e>>2]=c[g>>2];c[e+4>>2]=b;i=f;return 888}function mu(a,b){a=a|0;b=+b;var d=0;d=i;b=+ib[c[(c[a>>2]|0)+12>>2]&63](a,b);i=d;return+b}function nu(a){a=a|0;return c[a+12>>2]|0}function ou(a){a=a|0;return c[a+64>>2]|0}function pu(a,b){a=a|0;b=b|0;c[a+64>>2]=b;return}function qu(a){a=a|0;var d=0;d=i;if(!(b[(c[a+48>>2]|0)+4>>1]&32)){a=0;i=d;return a|0}a=(b[(c[a+52>>2]|0)+4>>1]&32)!=0;i=d;return a|0}function ru(b){b=b|0;return(a[b+61>>0]|0)!=0|0}function su(a){a=a|0;var b=0;b=i;if(!a){i=b;return}jb[c[(c[a>>2]|0)+28>>2]&127](a);i=b;return}function tu(a){a=a|0;var b=0;b=i;if(!a){i=b;return}jb[c[(c[a>>2]|0)+4>>2]&127](a);i=b;return}function uu(){var a=0,b=0;a=i;b=NB(16)|0;a:do if(!b){while(1){b=c[4582]|0;c[4582]=b+0;if(!b)break;qb[b&63]();b=NB(16)|0;if(b)break a}b=cb(4)|0;c[b>>2]=18168;_a(b|0,18216,116)}while(0);c[b+0>>2]=0;c[b+4>>2]=0;c[b+8>>2]=0;c[b+12>>2]=0;i=a;return b|0}function vu(a){a=a|0;return c[a>>2]|0}function wu(a,b){a=a|0;b=b|0;c[a>>2]=b;return}function xu(a){a=a|0;return c[a+4>>2]|0}function yu(a,b){a=a|0;b=b|0;c[a+4>>2]=b;return}function zu(a){a=a|0;return c[a+8>>2]|0}function Au(a,b){a=a|0;b=b|0;c[a+8>>2]=b;return}function Bu(a){a=a|0;return c[a+12>>2]|0}function Cu(a,b){a=a|0;b=b|0;c[a+12>>2]=b;return}function Du(a){a=a|0;var b=0;b=i;if(a)OB(a);i=b;return}function Eu(){var b=0,d=0;b=i;d=NB(40)|0;a:do if(!d){while(1){d=c[4582]|0;c[4582]=d+0;if(!d)break;qb[d&63]();d=NB(40)|0;if(d)break a}d=cb(4)|0;c[d>>2]=18168;_a(d|0,18216,116)}while(0);c[d+0>>2]=0;c[d+4>>2]=0;c[d+8>>2]=0;c[d+12>>2]=0;a[d+16>>0]=0;c[d>>2]=10;g[d+20>>2]=-1.0;g[d+24>>2]=0.0;g[d+28>>2]=1.0;g[d+32>>2]=0.0;g[d+36>>2]=0.0;i=b;return d|0}function Fu(a){a=a|0;return a+20|0}function Gu(a,b){a=a|0;b=b|0;var d=0,e=0;e=b;d=c[e+4>>2]|0;b=a+20|0;c[b>>2]=c[e>>2];c[b+4>>2]=d;return}function Hu(a){a=a|0;return a+28|0}function Iu(a,b){a=a|0;b=b|0;var d=0,e=0;e=b;d=c[e+4>>2]|0;b=a+28|0;c[b>>2]=c[e>>2];c[b+4>>2]=d;return}function Ju(a){a=a|0;return+(+g[a+36>>2])}function Ku(a,b){a=a|0;b=+b;g[a+36>>2]=b;return}function Lu(a){a=a|0;return c[a>>2]|0}function Mu(a,b){a=a|0;b=b|0;c[a>>2]=b;return}function Nu(a){a=a|0;return c[a+4>>2]|0}function Ou(a,b){a=a|0;b=b|0;c[a+4>>2]=b;return}function Pu(a){a=a|0;return c[a+8>>2]|0}function Qu(a,b){a=a|0;b=b|0;c[a+8>>2]=b;return}function Ru(a){a=a|0;return c[a+12>>2]|0}function Su(a,b){a=a|0;b=b|0;c[a+12>>2]=b;return}function Tu(b){b=b|0;return(a[b+16>>0]|0)!=0|0}function Uu(b,c){b=b|0;c=c|0;a[b+16>>0]=c&1;return}function Vu(a){a=a|0;var b=0;b=i;if(a)OB(a);i=b;return}function Wu(){var b=0,d=0;b=i;d=NB(44)|0;a:do if(!d){while(1){d=c[4582]|0;c[4582]=d+0;if(!d)break;qb[d&63]();d=NB(44)|0;if(d)break a}d=cb(4)|0;c[d>>2]=18168;_a(d|0,18216,116)}while(0);c[d+0>>2]=0;c[d+4>>2]=0;c[d+8>>2]=0;c[d+12>>2]=0;a[d+16>>0]=0;c[d>>2]=11;g[d+20>>2]=0.0;g[d+24>>2]=0.0;g[d+28>>2]=0.0;g[d+32>>2]=1.0;g[d+36>>2]=1.0;g[d+40>>2]=.30000001192092896;i=b;return d|0}function Xu(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,h=0.0,j=0.0,k=0.0,l=0.0,m=0.0;e=i;c[a+8>>2]=b;c[a+12>>2]=d;f=d+12|0;k=+g[f>>2];k=k- +g[b+12>>2];l=+g[f+4>>2]- +g[b+16>>2];m=+g[b+24>>2];h=+g[b+20>>2];j=+(k*m+l*h);h=+(m*l-k*h);f=a+20|0;g[f>>2]=j;g[f+4>>2]=h;g[a+28>>2]=+g[d+56>>2]- +g[b+56>>2];i=e;return}function Yu(a){a=a|0;return a+20|0}function Zu(a,b){a=a|0;b=b|0;var d=0,e=0;e=b;d=c[e+4>>2]|0;b=a+20|0;c[b>>2]=c[e>>2];c[b+4>>2]=d;return}function _u(a){a=a|0;return+(+g[a+28>>2])}function $u(a,b){a=a|0;b=+b;g[a+28>>2]=b;return}function av(a){a=a|0;return+(+g[a+32>>2])}function bv(a,b){a=a|0;b=+b;g[a+32>>2]=b;return}function cv(a){a=a|0;return+(+g[a+36>>2])}function dv(a,b){a=a|0;b=+b;g[a+36>>2]=b;return}function ev(a){a=a|0;return+(+g[a+40>>2])}function fv(a,b){a=a|0;b=+b;g[a+40>>2]=b;return}function gv(a){a=a|0;return c[a>>2]|0}function hv(a,b){a=a|0;b=b|0;c[a>>2]=b;return}function iv(a){a=a|0;return c[a+4>>2]|0}function jv(a,b){a=a|0;b=b|0;c[a+4>>2]=b;return}function kv(a){a=a|0;return c[a+8>>2]|0}function lv(a,b){a=a|0;b=b|0;c[a+8>>2]=b;return}function mv(a){a=a|0;return c[a+12>>2]|0}function nv(a,b){a=a|0;b=b|0;c[a+12>>2]=b;return}function ov(b){b=b|0;return(a[b+16>>0]|0)!=0|0}function pv(b,c){b=b|0;c=c|0;a[b+16>>0]=c&1;return}function qv(a){a=a|0;var b=0;b=i;if(a)OB(a);i=b;return}function rv(){return 0}function sv(){return 1}function tv(){return 2}function uv(){return 3}function vv(){return 4}function wv(){return 0}function xv(){return 1}function yv(){return 2}function zv(){return 3}function Av(){return 4}function Bv(){return 5}function Cv(){return 6}function Dv(){return 7}function Ev(){return 8}function Fv(){return 9}function Gv(){return 10}function Hv(){return 11}function Iv(){return 0}function Jv(){return 1}function Kv(){return 2}function Lv(){return 3}function Mv(){return 0}function Nv(){return 1}function Ov(){return 2}function Pv(){return 0}function Qv(){return 1}function Rv(){return 2}function Sv(){return 1}function Tv(){return 2}function Uv(){return 4}function Vv(){return 8}function Wv(){return 16}function Xv(){return 0}function Yv(){return 1}function Zv(a){a=a|0;return}function _v(a){a=a|0;var b=0;b=i;OB(a);i=b;return}function $v(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;e=i;za(2096,a|0,b|0,c|0,d|0)|0;i=e;return}function aw(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;e=i;za(1864,a|0,b|0,c|0,d|0)|0;i=e;return}function bw(a,b,c,d){a=a|0;b=b|0;c=+c;d=d|0;var e=0;e=i;za(1648,a|0,b|0,+c,d|0)|0;i=e;return}function cw(a,b,c,d,e){a=a|0;b=b|0;c=+c;d=d|0;e=e|0;var f=0;f=i;za(1416,a|0,b|0,+c,d|0,e|0)|0;i=f;return}function dw(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;e=i;za(1200,a|0,b|0,c|0,d|0)|0;i=e;return}function ew(a,b){a=a|0;b=b|0;var c=0;c=i;za(984,a|0,b|0)|0;i=c;return}function fw(a){a=a|0;return}function gw(a){a=a|0;var b=0;b=i;OB(a);i=b;return}function hw(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=i;a=(za(2376,a|0,b|0,c|0)|0)!=0;i=d;return a|0}function iw(a){a=a|0;return}function jw(a){a=a|0;var b=0;b=i;OB(a);i=b;return}function kw(a){a=a|0;return}function lw(a){a=a|0;var b=0;b=i;OB(a);i=b;return}function mw(a){a=a|0;return}function nw(a){a=a|0;var b=0;b=i;OB(a);i=b;return}function ow(a){a=a|0;return}function pw(a){a=a|0;var b=0;b=i;OB(a);i=b;return}function qw(a,b){a=a|0;b=b|0;var c=0;c=i;za(3016,a|0,b|0)|0;i=c;return}function rw(a,b){a=a|0;b=b|0;var c=0;c=i;za(2784,a|0,b|0)|0;i=c;return}function sw(a,b,c){a=a|0;b=b|0;c=c|0;return}function tw(a,b,c){a=a|0;b=b|0;c=c|0;return}function uw(a){a=a|0;return}function vw(a){a=a|0;var b=0;b=i;OB(a);i=b;return}function ww(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;var f=0;f=i;e=+Fa(3352,a|0,b|0,c|0,d|0,+e);i=f;return+e}function xw(a){a=a|0;return}function yw(a){a=a|0;var b=0;b=i;OB(a);i=b;return}function zw(a,b){a=a|0;b=b|0;var c=0;c=i;a=(za(3704,a|0,b|0)|0)!=0;i=c;return a|0}function Aw(a){a=a|0;return}function Bw(a){a=a|0;var b=0;b=i;OB(a);i=b;return}function Cw(a,b){a=a|0;b=b|0;var d=0;d=i;lb[c[(c[a>>2]|0)+16>>2]&127](a,b);i=d;return}function Dw(a,b){a=a|0;b=b|0;var d=0;d=i;lb[c[(c[a>>2]|0)+20>>2]&127](a,b);i=d;return}function Ew(a,b){a=a|0;b=b|0;var c=0;c=i;za(4528,a|0,b|0)|0;i=c;return}function Fw(a,b){a=a|0;b=b|0;var c=0;c=i;za(4264,a|0,b|0)|0;i=c;return}function Gw(b,d){b=b|0;d=d|0;var e=0.0,f=0.0,h=0.0,j=0.0,l=0.0,m=0.0,n=0,o=0,p=0,q=0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0,K=0.0,L=0,M=0.0,N=0,O=0,P=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0;q=i;o=c[b+48>>2]|0;X=c[o+8>>2]|0;n=b+104|0;c[n>>2]=X;W=c[b+52>>2]|0;U=c[W+8>>2]|0;p=b+108|0;c[p>>2]=U;S=o+28|0;T=c[S>>2]|0;S=c[S+4>>2]|0;O=b+128|0;c[O>>2]=T;c[O+4>>2]=S;O=W+28|0;P=c[O>>2]|0;O=c[O+4>>2]|0;N=b+136|0;c[N>>2]=P;c[N+4>>2]=O;N=b+156|0;g[N>>2]=+g[o+120>>2];L=b+160|0;g[L>>2]=+g[W+120>>2];t=+g[o+128>>2];g[b+164>>2]=t;w=+g[W+128>>2];g[b+168>>2]=w;W=c[d+24>>2]|0;o=W+(X*12|0)|0;z=+g[o>>2];C=+g[o+4>>2];E=+g[W+(X*12|0)+8>>2];o=d+28|0;V=c[o>>2]|0;Y=V+(X*12|0)|0;y=+g[Y>>2];f=+g[Y+4>>2];l=+g[V+(X*12|0)+8>>2];X=W+(U*12|0)|0;G=+g[X>>2];B=+g[X+4>>2];D=+g[W+(U*12|0)+8>>2];W=V+(U*12|0)|0;h=+g[W>>2];j=+g[W+4>>2];m=+g[V+(U*12|0)+8>>2];A=+R(+E);F=+Q(+E);M=+R(+D);s=+Q(+D);e=-(c[k>>2]=T,+g[k>>2]);v=-(c[k>>2]=S,+g[k>>2]);u=F*e-A*v;v=A*e+F*v;e=+u;r=+v;S=b+112|0;g[S>>2]=e;g[S+4>>2]=r;r=-(c[k>>2]=P,+g[k>>2]);e=-(c[k>>2]=O,+g[k>>2]);x=s*r-M*e;e=M*r+s*e;s=+x;r=+e;O=b+120|0;g[O>>2]=s;g[O+4>>2]=r;r=+g[N>>2];s=+g[L>>2];M=r+s;I=M+v*t*v+e*w*e;K=t*u;H=w*x;J=-(v*K)-e*H;H=M+u*K+x*H;K=I*H-J*J;if(K!=0.0)K=1.0/K;M=-(J*K);g[b+172>>2]=H*K;g[b+176>>2]=M;g[b+180>>2]=M;g[b+184>>2]=I*K;H=t+w;if(H>0.0)H=1.0/H;g[b+188>>2]=H;J=+g[b+68>>2];M=+g[b+72>>2];K=+(G+x-z-u-(F*J-A*M));M=+(B+e-C-v-(A*J+F*M));L=b+144|0;g[L>>2]=K;g[L+4>>2]=M;g[b+152>>2]=D-E- +g[b+76>>2];L=b+80|0;if(!(a[d+20>>0]|0)){g[L>>2]=0.0;g[b+84>>2]=0.0;g[b+88>>2]=0.0;G=y;H=f;J=h;K=j;I=l;M=m;Y=c[n>>2]|0;X=c[o>>2]|0;Y=X+(Y*12|0)|0;G=+G;H=+H;X=Y;g[X>>2]=G;Y=Y+4|0;g[Y>>2]=H;Y=c[n>>2]|0;X=c[o>>2]|0;Y=X+(Y*12|0)+8|0;g[Y>>2]=I;Y=c[p>>2]|0;Y=X+(Y*12|0)|0;J=+J;K=+K;X=Y;g[X>>2]=J;Y=Y+4|0;g[Y>>2]=K;Y=c[p>>2]|0;X=c[o>>2]|0;Y=X+(Y*12|0)+8|0;g[Y>>2]=M;i=q;return}else{X=d+8|0;F=+g[X>>2];M=F*+g[L>>2];g[L>>2]=M;Y=b+84|0;F=F*+g[Y>>2];g[Y>>2]=F;Y=b+88|0;E=+g[X>>2]*+g[Y>>2];g[Y>>2]=E;G=y-r*M;H=f-r*F;J=h+s*M;K=j+s*F;I=l-t*(E+(F*u-M*v));M=m+w*(E+(F*x-M*e));Y=c[n>>2]|0;X=c[o>>2]|0;Y=X+(Y*12|0)|0;G=+G;H=+H;X=Y;g[X>>2]=G;Y=Y+4|0;g[Y>>2]=H;Y=c[n>>2]|0;X=c[o>>2]|0;Y=X+(Y*12|0)+8|0;g[Y>>2]=I;Y=c[p>>2]|0;Y=X+(Y*12|0)|0;J=+J;K=+K;X=Y;g[X>>2]=J;Y=Y+4|0;g[Y>>2]=K;Y=c[p>>2]|0;X=c[o>>2]|0;Y=X+(Y*12|0)+8|0;g[Y>>2]=M;i=q;return}}function Hw(a,b){a=a|0;b=b|0;var d=0.0,e=0.0,f=0.0,h=0.0,j=0,k=0,l=0.0,m=0.0,n=0.0,o=0,p=0.0,q=0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0,A=0.0,B=0.0,C=0.0,D=0.0,E=0,F=0;q=i;k=a+104|0;o=c[k>>2]|0;j=b+28|0;E=c[j>>2]|0;z=E+(o*12|0)|0;l=+g[z>>2];h=+g[z+4>>2];y=+g[E+(o*12|0)+8>>2];o=a+108|0;z=c[o>>2]|0;F=E+(z*12|0)|0;m=+g[F>>2];n=+g[F+4>>2];x=+g[E+(z*12|0)+8>>2];f=+g[a+156>>2];e=+g[a+160>>2];d=+g[a+164>>2];p=+g[a+168>>2];B=+g[b>>2];C=+g[b+4>>2]*+g[a+100>>2];b=a+88|0;s=+g[b>>2];w=B*+g[a+96>>2];t=s- +g[a+188>>2]*(x-y+C*+g[a+152>>2]);v=-w;w=t>2]=w;s=w-s;y=y-d*s;s=x+p*s;x=+g[a+124>>2];w=+g[a+120>>2];v=+g[a+116>>2];t=+g[a+112>>2];D=+g[a+144>>2]*C+(v*y+(m-x*s-l));C=C*+g[a+148>>2]+(n+w*s-h-t*y);A=+g[a+176>>2]*D+ +g[a+184>>2]*C;b=a+80|0;z=b;u=+g[z>>2];r=+g[z+4>>2];C=u-(+g[a+172>>2]*D+ +g[a+180>>2]*C);g[b>>2]=C;z=a+84|0;A=+g[z>>2]-A;g[z>>2]=A;B=B*+g[a+92>>2];D=C*C+A*A;if(D>B*B){D=+O(+D);if(!(D<1.1920928955078125e-7)){D=1.0/D;C=C*D;g[b>>2]=C;A=A*D;g[z>>2]=A}C=B*C;g[b>>2]=C;A=B*A;g[z>>2]=A}D=C-u;C=A-r;B=+(l-f*D);A=+(h-f*C);F=(c[j>>2]|0)+((c[k>>2]|0)*12|0)|0;g[F>>2]=B;g[F+4>>2]=A;F=c[j>>2]|0;g[F+((c[k>>2]|0)*12|0)+8>>2]=y-d*(t*C-D*v);A=+(m+e*D);B=+(n+e*C);F=F+((c[o>>2]|0)*12|0)|0;g[F>>2]=A;g[F+4>>2]=B;g[(c[j>>2]|0)+((c[o>>2]|0)*12|0)+8>>2]=s+p*(C*w-D*x);i=q;return}function Iw(a,b){a=a|0;b=b|0;return 1}function Jw(a,b){a=a|0;b=b|0;var d=0,e=0;e=(c[b+48>>2]|0)+12|0;d=c[e+4>>2]|0;b=a;c[b>>2]=c[e>>2];c[b+4>>2]=d;return}function Kw(a,b){a=a|0;b=b|0;var d=0,e=0;e=(c[b+52>>2]|0)+12|0;d=c[e+4>>2]|0;b=a;c[b>>2]=c[e>>2];c[b+4>>2]=d;return}function Lw(a,b,c){a=a|0;b=b|0;c=+c;var d=0.0;d=+g[b+84>>2]*c;g[a>>2]=+g[b+80>>2]*c;g[a+4>>2]=d;return}function Mw(a,b){a=a|0;b=+b;return+(+g[a+88>>2]*b)}function Nw(a){a=a|0;var b=0,e=0,f=0,j=0.0,l=0;b=i;i=i+16|0;e=b;l=c[(c[a+48>>2]|0)+8>>2]|0;f=c[(c[a+52>>2]|0)+8>>2]|0;Nx(4976,e);c[e>>2]=l;Nx(17320,e);c[e>>2]=f;Nx(17352,e);c[e>>2]=d[a+61>>0];Nx(17384,e);j=+g[a+72>>2];h[k>>3]=+g[a+68>>2];c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];f=e+8|0;h[k>>3]=j;c[f>>2]=c[k>>2];c[f+4>>2]=c[k+4>>2];Nx(5e3,e);h[k>>3]=+g[a+76>>2];c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];Nx(5048,e);h[k>>3]=+g[a+92>>2];c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];Nx(14704,e);h[k>>3]=+g[a+96>>2];c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];Nx(14736,e);h[k>>3]=+g[a+100>>2];c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];Nx(5080,e);c[e>>2]=c[a+56>>2];Nx(17720,e);i=b;return}function Ow(a,b){a=a|0;b=b|0;return}function Pw(a){a=a|0;return}function Qw(a){a=a|0;var b=0;b=i;OB(a);i=b;return}function Rw(a){a=a|0;Ja(a|0)|0;oB()}function Sw(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0;d=i;e=a+40|0;f=c[e>>2]|0;g=a+36|0;a=a+32|0;if((f|0)==(c[g>>2]|0)){h=c[a>>2]|0;c[g>>2]=f<<1;f=NB(f<<3)|0;c[a>>2]=f;SB(f|0,h|0,c[e>>2]<<2|0)|0;OB(h);f=c[e>>2]|0}c[(c[a>>2]|0)+(f<<2)>>2]=b;c[e>>2]=(c[e>>2]|0)+1;i=d;return}function Tw(b,d,e,f,h){b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;var j=0,l=0,m=0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0,u=0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0;m=i;j=b+60|0;c[j>>2]=0;l=f+12|0;o=+g[h+12>>2];B=+g[l>>2];w=+g[h+8>>2];x=+g[f+16>>2];A=+g[h>>2]+(o*B-w*x)- +g[e>>2];x=B*w+o*x+ +g[h+4>>2]- +g[e+4>>2];o=+g[e+12>>2];w=+g[e+8>>2];B=A*o+x*w;w=o*x-A*w;e=d+12|0;h=c[e>>2]|0;e=c[e+4>>2]|0;A=(c[k>>2]=h,+g[k>>2]);x=(c[k>>2]=e,+g[k>>2]);u=d+20|0;t=c[u>>2]|0;u=c[u+4>>2]|0;o=(c[k>>2]=t,+g[k>>2]);p=(c[k>>2]=u,+g[k>>2]);n=o-A;v=p-x;y=n*(o-B)+v*(p-w);s=B-A;r=w-x;z=s*n+r*v;q=+g[d+8>>2]+ +g[f+8>>2];if(z<=0.0){if(s*s+r*r>q*q){i=m;return}if((a[d+44>>0]|0)!=0?(f=d+28|0,C=+g[f>>2],(A-B)*(A-C)+(x-w)*(x- +g[f+4>>2])>0.0):0){i=m;return}c[j>>2]=1;c[b+56>>2]=0;g[b+40>>2]=0.0;g[b+44>>2]=0.0;t=b+48|0;c[t>>2]=h;c[t+4>>2]=e;t=b+16|0;c[t>>2]=0;a[t>>0]=0;a[t+1>>0]=0;a[t+2>>0]=0;a[t+3>>0]=0;t=l;u=c[t+4>>2]|0;f=b;c[f>>2]=c[t>>2];c[f+4>>2]=u;i=m;return}if(y<=0.0){n=B-o;r=w-p;if(n*n+r*r>q*q){i=m;return}if((a[d+45>>0]|0)!=0?(f=d+36|0,C=+g[f>>2],n*(C-o)+r*(+g[f+4>>2]-p)>0.0):0){i=m;return}c[j>>2]=1;c[b+56>>2]=0;g[b+40>>2]=0.0;g[b+44>>2]=0.0;f=b+48|0;c[f>>2]=t;c[f+4>>2]=u;t=b+16|0;c[t>>2]=0;a[t>>0]=1;a[t+1>>0]=0;a[t+2>>0]=0;a[t+3>>0]=0;t=l;u=c[t+4>>2]|0;f=b;c[f>>2]=c[t>>2];c[f+4>>2]=u;i=m;return}C=n*n+v*v;if(!(C>0.0))Aa(5176,5192,127,5240);C=1.0/C;B=B-(A*y+o*z)*C;C=w-(x*y+p*z)*C;if(B*B+C*C>q*q){i=m;return}o=-v;if(n*r+s*o<0.0)n=-n;else v=o;o=+O(+(n*n+v*v));if(!(o<1.1920928955078125e-7)){C=1.0/o;v=v*C;n=n*C}c[j>>2]=1;c[b+56>>2]=1;B=+v;C=+n;t=b+40|0;g[t>>2]=B;g[t+4>>2]=C;t=b+48|0;c[t>>2]=h;c[t+4>>2]=e;t=b+16|0;c[t>>2]=0;a[t>>0]=0;a[t+1>>0]=0;a[t+2>>0]=1;a[t+3>>0]=0;t=l;u=c[t+4>>2]|0;f=b;c[f>>2]=c[t>>2];c[f+4>>2]=u;i=m;return}function Uw(b,d,e,f,h){b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;var j=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0,H=0.0,I=0.0,J=0.0,K=0.0,L=0.0,M=0,N=0.0,P=0,Q=0.0,R=0.0,S=0.0,T=0.0,U=0,V=0,W=0.0,X=0.0;j=i;i=i+464|0;q=j;o=j+432|0;l=j+408|0;r=j+24|0;m=r+260|0;F=+g[e+12>>2];N=+g[h+8>>2];A=+g[e+8>>2];E=+g[h+12>>2];z=F*N-A*E;E=N*A+F*E;N=+z;D=+E;C=+g[h>>2]- +g[e>>2];L=+g[h+4>>2]- +g[e+4>>2];B=F*C+A*L;C=F*L-A*C;A=+B;L=+C;e=m;g[e>>2]=A;g[e+4>>2]=L;e=r+268|0;g[e>>2]=N;g[e+4>>2]=D;e=r+272|0;D=+g[f+12>>2];h=r+268|0;N=+g[f+16>>2];B=B+(E*D-z*N);n=r+264|0;C=D*z+E*N+C;N=+B;E=+C;M=r+276|0;g[M>>2]=N;g[M+4>>2]=E;M=d+28|0;G=c[M>>2]|0;M=c[M+4>>2]|0;s=r+284|0;c[s>>2]=G;c[s+4>>2]=M;s=r+292|0;y=d+12|0;u=c[y>>2]|0;y=c[y+4>>2]|0;t=s;c[t>>2]=u;c[t+4>>2]=y;t=r+300|0;w=d+20|0;V=c[w>>2]|0;w=c[w+4>>2]|0;U=t;c[U>>2]=V;c[U+4>>2]=w;U=d+36|0;P=c[U>>2]|0;U=c[U+4>>2]|0;v=r+308|0;c[v>>2]=P;c[v+4>>2]=U;v=(a[d+44>>0]|0)!=0;x=(a[d+45>>0]|0)==0;E=(c[k>>2]=V,+g[k>>2]);N=(c[k>>2]=u,+g[k>>2]);z=E-N;D=(c[k>>2]=w,+g[k>>2]);L=(c[k>>2]=y,+g[k>>2]);A=D-L;F=+O(+(z*z+A*A));J=(c[k>>2]=G,+g[k>>2]);K=(c[k>>2]=M,+g[k>>2]);I=(c[k>>2]=P,+g[k>>2]);H=(c[k>>2]=U,+g[k>>2]);if(!(F<1.1920928955078125e-7)){T=1.0/F;z=z*T;A=A*T}u=r+324|0;F=-z;g[u>>2]=A;d=r+328|0;g[d>>2]=F;F=(B-N)*A+(C-L)*F;if(v){N=N-J;L=L-K;Q=+O(+(N*N+L*L));if(!(Q<1.1920928955078125e-7)){T=1.0/Q;N=N*T;L=L*T}T=-N;g[r+316>>2]=L;g[r+320>>2]=T;w=A*N-z*L>=0.0;J=(B-J)*L+(C-K)*T}else{w=0;J=0.0}a:do if(x){if(!v){V=F>=0.0;a[r+376>>0]=V&1;v=r+340|0;if(V){P=u;V=c[P>>2]|0;P=c[P+4>>2]|0;U=v;c[U>>2]=V;c[U+4>>2]=P;S=+-(c[k>>2]=V,+g[k>>2]);T=+z;V=r+356|0;g[V>>2]=S;g[V+4>>2]=T;V=r+364|0;g[V>>2]=S;g[V+4>>2]=T;break}else{S=+-A;T=+z;U=v;g[U>>2]=S;g[U+4>>2]=T;U=u;P=c[U>>2]|0;U=c[U+4>>2]|0;V=r+356|0;c[V>>2]=P;c[V+4>>2]=U;V=r+364|0;c[V>>2]=P;c[V+4>>2]=U;break}}v=J>=0.0;if(w){if(!v){V=F>=0.0;a[r+376>>0]=V&1;v=r+340|0;if(!V){S=+-A;T=+z;P=v;g[P>>2]=S;g[P+4>>2]=T;P=u;U=c[P>>2]|0;P=c[P+4>>2]|0;V=r+356|0;c[V>>2]=U;c[V+4>>2]=P;V=r+364|0;g[V>>2]=-(c[k>>2]=U,+g[k>>2]);g[V+4>>2]=T;break}}else{a[r+376>>0]=1;v=r+340|0}V=u;U=c[V+4>>2]|0;P=v;c[P>>2]=c[V>>2];c[P+4>>2]=U;P=r+316|0;U=c[P+4>>2]|0;V=r+356|0;c[V>>2]=c[P>>2];c[V+4>>2]=U;S=+-+g[u>>2];T=+-+g[d>>2];V=r+364|0;g[V>>2]=S;g[V+4>>2]=T;break}else{if(v){V=F>=0.0;a[r+376>>0]=V&1;v=r+340|0;if(V){P=u;V=c[P>>2]|0;P=c[P+4>>2]|0;U=v;c[U>>2]=V;c[U+4>>2]=P;U=r+356|0;c[U>>2]=V;c[U+4>>2]=P;S=+-(c[k>>2]=V,+g[k>>2]);T=+z;V=r+364|0;g[V>>2]=S;g[V+4>>2]=T;break}}else{a[r+376>>0]=0;v=r+340|0}T=+-A;S=+z;P=v;g[P>>2]=T;g[P+4>>2]=S;P=u;U=c[P+4>>2]|0;V=r+356|0;c[V>>2]=c[P>>2];c[V+4>>2]=U;S=+-+g[r+316>>2];T=+-+g[r+320>>2];V=r+364|0;g[V>>2]=S;g[V+4>>2]=T;break}}else{I=I-E;H=H-D;K=+O(+(I*I+H*H));if(!(K<1.1920928955078125e-7)){T=1.0/K;I=I*T;H=H*T}T=-I;x=r+332|0;g[x>>2]=H;y=r+336|0;g[y>>2]=T;G=z*H-A*I>0.0;B=(B-E)*H+(C-D)*T;if(!v){v=F>=0.0;if(G){if(!v){V=B>=0.0;a[r+376>>0]=V&1;v=r+340|0;if(!V){S=+-A;T=+z;P=v;g[P>>2]=S;g[P+4>>2]=T;P=r+356|0;g[P>>2]=S;g[P+4>>2]=T;P=u;U=c[P+4>>2]|0;V=r+364|0;c[V>>2]=c[P>>2];c[V+4>>2]=U;break}}else{a[r+376>>0]=1;v=r+340|0}V=u;U=c[V+4>>2]|0;P=v;c[P>>2]=c[V>>2];c[P+4>>2]=U;S=+-+g[u>>2];T=+-+g[d>>2];P=r+356|0;g[P>>2]=S;g[P+4>>2]=T;P=r+332|0;U=c[P+4>>2]|0;V=r+364|0;c[V>>2]=c[P>>2];c[V+4>>2]=U;break}else{if(v){V=B>=0.0;a[r+376>>0]=V&1;v=r+340|0;if(V){U=u;P=c[U>>2]|0;U=c[U+4>>2]|0;V=v;c[V>>2]=P;c[V+4>>2]=U;S=+-(c[k>>2]=P,+g[k>>2]);T=+z;V=r+356|0;g[V>>2]=S;g[V+4>>2]=T;V=r+364|0;c[V>>2]=P;c[V+4>>2]=U;break}}else{a[r+376>>0]=0;v=r+340|0}T=+-A;S=+z;P=v;g[P>>2]=T;g[P+4>>2]=S;S=+-+g[x>>2];T=+-+g[y>>2];P=r+356|0;g[P>>2]=S;g[P+4>>2]=T;P=u;U=c[P+4>>2]|0;V=r+364|0;c[V>>2]=c[P>>2];c[V+4>>2]=U;break}}if(w&G){if(!(J>=0.0)&!(F>=0.0)){V=B>=0.0;a[r+376>>0]=V&1;v=r+340|0;if(!V){S=+-A;T=+z;V=v;g[V>>2]=S;g[V+4>>2]=T;V=r+356|0;g[V>>2]=S;g[V+4>>2]=T;V=r+364|0;g[V>>2]=S;g[V+4>>2]=T;break}}else{a[r+376>>0]=1;v=r+340|0}P=u;U=c[P+4>>2]|0;V=v;c[V>>2]=c[P>>2];c[V+4>>2]=U;V=r+316|0;U=c[V+4>>2]|0;P=r+356|0;c[P>>2]=c[V>>2];c[P+4>>2]=U;P=r+332|0;U=c[P+4>>2]|0;V=r+364|0;c[V>>2]=c[P>>2];c[V+4>>2]=U;break}if(w){do if(!(J>=0.0)){if(F>=0.0){V=B>=0.0;a[r+376>>0]=V&1;v=r+340|0;if(V)break}else{a[r+376>>0]=0;v=r+340|0}S=+-A;T=+z;V=v;g[V>>2]=S;g[V+4>>2]=T;T=+-+g[x>>2];S=+-+g[y>>2];V=r+356|0;g[V>>2]=T;g[V+4>>2]=S;S=+-+g[u>>2];T=+-+g[d>>2];V=r+364|0;g[V>>2]=S;g[V+4>>2]=T;break a}else{a[r+376>>0]=1;v=r+340|0}while(0);P=u;U=c[P+4>>2]|0;V=v;c[V>>2]=c[P>>2];c[V+4>>2]=U;V=r+316|0;U=c[V+4>>2]|0;P=r+356|0;c[P>>2]=c[V>>2];c[P+4>>2]=U;P=u;U=c[P+4>>2]|0;V=r+364|0;c[V>>2]=c[P>>2];c[V+4>>2]=U;break}if(!G){if(!(!(J>=0.0)|!(F>=0.0))){V=B>=0.0;a[r+376>>0]=V&1;v=r+340|0;if(V){U=u;P=c[U>>2]|0;U=c[U+4>>2]|0;V=v;c[V>>2]=P;c[V+4>>2]=U;V=r+356|0;c[V>>2]=P;c[V+4>>2]=U;V=r+364|0;c[V>>2]=P;c[V+4>>2]=U;break}}else{a[r+376>>0]=0;v=r+340|0}S=+-A;T=+z;V=v;g[V>>2]=S;g[V+4>>2]=T;T=+-+g[x>>2];S=+-+g[y>>2];V=r+356|0;g[V>>2]=T;g[V+4>>2]=S;S=+-+g[r+316>>2];T=+-+g[r+320>>2];V=r+364|0;g[V>>2]=S;g[V+4>>2]=T;break}do if(!(B>=0.0)){if(J>=0.0){V=F>=0.0;a[r+376>>0]=V&1;v=r+340|0;if(V)break}else{a[r+376>>0]=0;v=r+340|0}S=+-A;T=+z;V=v;g[V>>2]=S;g[V+4>>2]=T;T=+-+g[u>>2];S=+-+g[d>>2];V=r+356|0;g[V>>2]=T;g[V+4>>2]=S;S=+-+g[r+316>>2];T=+-+g[r+320>>2];V=r+364|0;g[V>>2]=S;g[V+4>>2]=T;break a}else{a[r+376>>0]=1;v=r+340|0}while(0);P=u;U=c[P+4>>2]|0;V=v;c[V>>2]=c[P>>2];c[V+4>>2]=U;V=u;U=c[V+4>>2]|0;P=r+356|0;c[P>>2]=c[V>>2];c[P+4>>2]=U;P=r+332|0;U=c[P+4>>2]|0;V=r+364|0;c[V>>2]=c[P>>2];c[V+4>>2]=U}while(0);y=c[f+276>>2]|0;v=r+256|0;c[v>>2]=y;if((y|0)>0){w=0;do{Q=+g[e>>2];S=+g[f+(w<<3)+20>>2];T=+g[h>>2];R=+g[f+(w<<3)+24>>2];N=+(+g[m>>2]+(Q*S-T*R));R=+(S*T+Q*R+ +g[n>>2]);V=r+(w<<3)|0;g[V>>2]=N;g[V+4>>2]=R;R=+g[e>>2];N=+g[f+(w<<3)+148>>2];Q=+g[h>>2];T=+g[f+(w<<3)+152>>2];S=+(R*N-Q*T);T=+(N*Q+R*T);V=r+(w<<3)+128|0;g[V>>2]=S;g[V+4>>2]=T;w=w+1|0}while((w|0)<(y|0));y=c[v>>2]|0}w=r+372|0;g[w>>2]=.019999999552965164;v=b+60|0;c[v>>2]=0;x=a[r+376>>0]|0;G=(y|0)>0;if(!G){i=j;return}z=+g[r+292>>2];D=+g[r+296>>2];C=+g[r+340>>2];E=+g[r+344>>2];F=3.4028234663852886e+38;B=3.4028234663852886e+38;P=0;while(1){A=(+g[r+(P<<3)>>2]-z)*C+(+g[r+(P<<3)+4>>2]-D)*E;M=A=(y|0))break;else F=M?A:F}if(B>.019999999552965164){i=j;return}z=+g[r+344>>2];A=+g[r+340>>2];do if(G){H=+g[r+292>>2];J=+g[r+296>>2];K=+g[r+300>>2];L=+g[r+304>>2];I=+g[r+356>>2];F=+g[r+360>>2];E=+g[r+364>>2];D=+g[r+368>>2];N=-3.4028234663852886e+38;G=0;P=0;M=-1;Q=-3.4028234663852886e+38;while(1){R=+g[r+(G<<3)+128>>2];T=-R;S=-+g[r+(G<<3)+132>>2];X=+g[r+(G<<3)>>2];C=+g[r+(G<<3)+4>>2];W=(X-H)*T+(C-J)*S;C=(X-K)*T+(C-L)*S;C=W.019999999552965164){P=2;break}if(!(z*R+A*S>=0.0))if(C>N?!((T-I)*A+(S-F)*z<-.03490658849477768):0)p=77;else C=Q;else if(C>N?!((T-E)*A+(S-D)*z<-.03490658849477768):0)p=77;else C=Q;if((p|0)==77){p=0;N=C;P=2;M=G}G=G+1|0;if((G|0)>=(y|0)){G=M;p=79;break}else Q=C}if((p|0)==79)if(!P){p=82;break}if(C>.019999999552965164){i=j;return}if(C>B*.9800000190734863+.0010000000474974513){M=(P|0)==1;P=b+56|0;if(M){G=M;M=q;p=84}else{c[P>>2]=2;x=s;d=c[x+4>>2]|0;s=q;c[s>>2]=c[x>>2];c[s+4>>2]=d;s=q+8|0;a[s>>0]=0;d=G&255;a[s+1>>0]=d;a[s+2>>0]=0;a[s+3>>0]=1;s=t;t=c[s+4>>2]|0;x=q+12|0;c[x>>2]=c[s>>2];c[x+4>>2]=t;x=q+20|0;a[x>>0]=0;a[x+1>>0]=d;a[x+2>>0]=0;a[x+3>>0]=1;x=G+1|0;x=(x|0)<(y|0)?x:0;y=r+(G<<3)|0;t=r+(x<<3)|0;d=r+(G<<3)+128|0;s=c[t+4>>2]|0;t=c[t>>2]|0;r=M;M=x;x=c[y>>2]|0;y=c[y+4>>2]|0;u=c[d>>2]|0;d=c[d+4>>2]|0}}else p=82}else p=82;while(0);if((p|0)==82){G=1;M=q;P=b+56|0;p=84}do if((p|0)==84){c[P>>2]=1;if((y|0)>1){U=0;B=A*+g[r+128>>2]+z*+g[r+132>>2];p=1;while(1){C=A*+g[r+(p<<3)+128>>2]+z*+g[r+(p<<3)+132>>2];P=C=(y|0))break;else B=P?C:B}}else U=0;P=U+1|0;P=(P|0)<(y|0)?P:0;p=r+(U<<3)|0;V=c[p+4>>2]|0;y=q;c[y>>2]=c[p>>2];c[y+4>>2]=V;y=q+8|0;a[y>>0]=0;a[y+1>>0]=U;a[y+2>>0]=1;a[y+3>>0]=0;y=r+(P<<3)|0;U=c[y+4>>2]|0;V=q+12|0;c[V>>2]=c[y>>2];c[V+4>>2]=U;V=q+20|0;a[V>>0]=0;a[V+1>>0]=P;a[V+2>>0]=1;a[V+3>>0]=0;if(!(x<<24>>24)){y=t;t=s;u=(g[k>>2]=-+g[u>>2],c[k>>2]|0);s=c[t+4>>2]|0;t=c[t>>2]|0;q=M;r=G;G=1;M=0;x=c[y>>2]|0;y=c[y+4>>2]|0;d=(g[k>>2]=-+g[d>>2],c[k>>2]|0);break}else{y=s;d=u;s=c[t+4>>2]|0;t=c[t>>2]|0;q=M;r=G;G=0;M=1;x=c[y>>2]|0;y=c[y+4>>2]|0;u=c[d>>2]|0;d=c[d+4>>2]|0;break}}while(0);A=(c[k>>2]=y,+g[k>>2]);z=(c[k>>2]=d,+g[k>>2]);T=(c[k>>2]=d,+g[k>>2]);C=(c[k>>2]=u,+g[k>>2]);W=(c[k>>2]=x,+g[k>>2]);X=-C;B=-T;if((Ww(o,q,T,X,T*W+(c[k>>2]=y,+g[k>>2])*X,G)|0)<2){i=j;return}X=(c[k>>2]=s,+g[k>>2]);X=(c[k>>2]=t,+g[k>>2])*B+C*X;if((Ww(l,o,B,(c[k>>2]=u,+g[k>>2]),X,M)|0)<2){i=j;return}o=b+40|0;if(r){V=o;c[V>>2]=u;c[V+4>>2]=d;V=b+48|0;c[V>>2]=x;c[V+4>>2]=y}else{V=f+(G<<3)+148|0;U=c[V+4>>2]|0;P=o;c[P>>2]=c[V>>2];c[P+4>>2]=U;P=f+(G<<3)+20|0;U=c[P+4>>2]|0;V=b+48|0;c[V>>2]=c[P>>2];c[V+4>>2]=U}B=(c[k>>2]=x,+g[k>>2]);C=(c[k>>2]=u,+g[k>>2]);D=+g[w>>2];E=+g[m>>2];F=+g[n>>2];H=+g[e>>2];I=+g[h>>2];h=0;e=0;do{n=l+(h*12|0)|0;J=+g[n>>2];K=+g[l+(h*12|0)+4>>2];if((J-B)*C+(K-A)*z<=D){m=b+(e*20|0)|0;if(r){X=J-E;T=K-F;W=+(X*H+T*I);X=+(H*T-X*I);V=m;g[V>>2]=W;g[V+4>>2]=X;c[b+(e*20|0)+16>>2]=c[l+(h*12|0)+8>>2]}else{P=n;V=c[P+4>>2]|0;U=m;c[U>>2]=c[P>>2];c[U+4>>2]=V;U=l+(h*12|0)+8|0;V=b+(e*20|0)+16|0;a[V+2>>0]=a[U+3>>0]|0;a[V+3>>0]=a[U+2>>0]|0;a[V>>0]=a[U+1>>0]|0;a[V+1>>0]=a[U>>0]|0}e=e+1|0}h=h+1|0}while((h|0)!=2);c[v>>2]=e;i=j;return}function Vw(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var h=0,j=0,k=0,l=0.0,m=0.0,n=0.0,o=0.0,p=0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0,w=0.0,x=0.0;h=i;j=c[b+276>>2]|0;k=c[e+276>>2]|0;t=+g[f+12>>2];o=+g[d+8>>2];w=+g[f+8>>2];l=+g[d+12>>2];m=t*o-w*l;l=o*w+t*l;o=+g[d>>2]- +g[f>>2];u=+g[d+4>>2]- +g[f+4>>2];n=t*o+w*u;o=t*u-w*o;if((j|0)<=0){v=0;w=-3.4028234663852886e+38;c[a>>2]=v;i=h;return+w}d=(k|0)>0;p=0;f=0;q=-3.4028234663852886e+38;do{w=+g[b+(f<<3)+148>>2];t=+g[b+(f<<3)+152>>2];r=l*w-m*t;t=m*w+l*t;w=+g[b+(f<<3)+20>>2];u=+g[b+(f<<3)+24>>2];s=n+(l*w-m*u);u=o+(m*w+l*u);if(d){v=0;w=3.4028234663852886e+38;do{x=r*(+g[e+(v<<3)+20>>2]-s)+t*(+g[e+(v<<3)+24>>2]-u);w=xq;q=v?w:q;p=v?f:p;f=f+1|0}while((f|0)!=(j|0));c[a>>2]=p;i=h;return+q}function Ww(b,d,e,f,h,j){b=b|0;d=d|0;e=+e;f=+f;h=+h;j=j|0;var k=0.0,l=0,m=0,n=0,o=0,p=0,q=0;o=i;l=d+4|0;k=+g[d>>2]*e+ +g[l>>2]*f-h;m=d+12|0;n=d+16|0;h=+g[m>>2]*e+ +g[n>>2]*f-h;if(!(k<=0.0))p=0;else{c[b+0>>2]=c[d+0>>2];c[b+4>>2]=c[d+4>>2];c[b+8>>2]=c[d+8>>2];p=1}if(h<=0.0){q=p+1|0;p=b+(p*12|0)|0;c[p+0>>2]=c[m+0>>2];c[p+4>>2]=c[m+4>>2];c[p+8>>2]=c[m+8>>2];p=q}if(!(k*h<0.0)){q=p;i=o;return q|0}h=k/(k-h);f=+g[d>>2];e=+g[l>>2];f=+(f+h*(+g[m>>2]-f));e=+(e+h*(+g[n>>2]-e));q=b+(p*12|0)|0;g[q>>2]=f;g[q+4>>2]=e;q=b+(p*12|0)+8|0;a[q>>0]=j;a[q+1>>0]=a[d+9>>0]|0;a[q+2>>0]=0;a[q+3>>0]=1;q=p+1|0;i=o;return q|0}function Xw(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,h=0,j=0,k=0,l=0;e=i;f=c[b+4>>2]|0;if((f|0)==3){if((d|0)<=-1)Aa(5408,5448,53,7160);f=b+16|0;if((c[f>>2]|0)<=(d|0))Aa(5408,5448,53,7160);j=b+12|0;l=(c[j>>2]|0)+(d<<3)|0;k=c[l+4>>2]|0;h=a;c[h>>2]=c[l>>2];c[h+4>>2]=k;h=d+1|0;d=a+8|0;j=c[j>>2]|0;if((h|0)<(c[f>>2]|0)){j=j+(h<<3)|0;k=c[j+4>>2]|0;l=d;c[l>>2]=c[j>>2];c[l+4>>2]=k}else{k=c[j+4>>2]|0;l=d;c[l>>2]=c[j>>2];c[l+4>>2]=k}c[a+16>>2]=a;c[a+20>>2]=2;g[a+24>>2]=+g[b+8>>2];i=e;return}else if((f|0)==1){c[a+16>>2]=b+12;c[a+20>>2]=2;g[a+24>>2]=+g[b+8>>2];i=e;return}else if(!f){c[a+16>>2]=b+12;c[a+20>>2]=1;g[a+24>>2]=+g[b+8>>2];i=e;return}else if((f|0)==2){c[a+16>>2]=b+20;c[a+20>>2]=c[b+276>>2];g[a+24>>2]=+g[b+8>>2];i=e;return}else Aa(15224,5448,81,7160)}function Yw(e,f,h){e=e|0;f=f|0;h=h|0;var j=0,l=0,m=0,n=0,o=0,p=0.0,q=0.0,r=0,s=0,t=0.0,u=0.0,v=0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0,C=0,D=0.0,E=0,F=0.0,G=0,H=0,I=0,J=0.0,K=0,L=0,M=0,N=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0.0,_=0,$=0.0,aa=0.0,ba=0,ca=0,da=0,ea=0,fa=0.0,ga=0.0,ha=0.0,ia=0,ja=0.0,ka=0.0,la=0.0,ma=0.0,na=0.0,oa=0.0,pa=0.0,qa=0.0,ra=0.0,sa=0.0,ta=0.0;j=i;i=i+144|0;m=j;B=j+124|0;E=j+112|0;c[1346]=(c[1346]|0)+1;z=+g[h+56>>2];y=+g[h+60>>2];A=+g[h+64>>2];D=+g[h+68>>2];x=+g[h+72>>2];F=+g[h+76>>2];J=+g[h+80>>2];w=+g[h+84>>2];n=f+4|0;M=b[n>>1]|0;if((M&65535)>=4)Aa(5552,5448,102,5576);L=M&65535;o=m+108|0;c[o>>2]=L;a:do if(M<<16>>16){M=h+16|0;N=h+48|0;L=h+44|0;P=c[h+20>>2]|0;Q=0;while(1){S=d[f+Q+6>>0]|0;c[m+(Q*36|0)+28>>2]=S;R=d[f+Q+9>>0]|0;c[m+(Q*36|0)+32>>2]=R;if((P|0)<=(S|0)){Y=6;break}ia=(c[M>>2]|0)+(S<<3)|0;$=+g[ia>>2];Z=+g[ia+4>>2];if((c[N>>2]|0)<=(R|0)){Y=8;break}R=(c[L>>2]|0)+(R<<3)|0;ja=+g[R>>2];ga=+g[R+4>>2];ka=z+($*D-Z*A);ha=+ka;la=+(Z*D+$*A+y);R=m+(Q*36|0)|0;g[R>>2]=ha;g[R+4>>2]=la;la=x+(ja*w-ga*J);ha=+la;ja=+(ga*w+ja*J+F);R=m+(Q*36|0)+8|0;g[R>>2]=ha;g[R+4>>2]=ja;ka=+(la-ka);la=+(+g[m+(Q*36|0)+12>>2]- +g[m+(Q*36|0)+4>>2]);R=m+(Q*36|0)+16|0;g[R>>2]=ka;g[R+4>>2]=la;g[m+(Q*36|0)+24>>2]=0.0;Q=Q+1|0;R=c[o>>2]|0;if((Q|0)>=(R|0)){K=R;break a}}if((Y|0)==6)Aa(6336,6368,103,6416);else if((Y|0)==8)Aa(6336,6368,103,6416)}else K=L;while(0);do if((K|0)>1){ka=+g[f>>2];la=+Zw(m);if(!(la>2]|0;Y=15;break}c[o>>2]=0;Y=17}else Y=15;while(0);if((Y|0)==15)if(!K)Y=17;else{V=K;v=h+20|0;G=h+44|0;H=h+48|0;C=m+16|0;s=m+24|0;I=h+16|0}do if((Y|0)==17){c[m+28>>2]=0;c[m+32>>2]=0;K=h+20|0;if((c[K>>2]|0)<=0)Aa(6336,6368,103,6416);L=h+16|0;M=c[L>>2]|0;Z=+g[M>>2];$=+g[M+4>>2];M=h+48|0;if((c[M>>2]|0)>0){G=h+44|0;C=c[G>>2]|0;ja=+g[C>>2];fa=+g[C+4>>2];ka=z+(Z*D-$*A);la=$*D+Z*A+y;ga=+ka;ha=+la;C=m;g[C>>2]=ga;g[C+4>>2]=ha;ha=x+(ja*w-fa*J);ja=fa*w+ja*J+F;fa=+ha;ga=+ja;C=m+8|0;g[C>>2]=fa;g[C+4>>2]=ga;C=m+16|0;ka=+(ha-ka);la=+(ja-la);s=C;g[s>>2]=ka;g[s+4>>2]=la;s=m+24|0;g[s>>2]=1.0;c[o>>2]=1;V=1;v=K;H=M;I=L;break}else Aa(6336,6368,103,6416)}while(0);S=m+16|0;R=m+20|0;Q=m+52|0;P=m+56|0;M=m+36|0;N=m+52|0;K=m+60|0;U=m+72|0;T=m+88|0;L=m+96|0;W=0;b:while(1){X=(V|0)>0;if(X){Y=0;do{c[B+(Y<<2)>>2]=c[m+(Y*36|0)+28>>2];c[E+(Y<<2)>>2]=c[m+(Y*36|0)+32>>2];Y=Y+1|0}while((Y|0)!=(V|0))}do if((V|0)==2){ia=C;la=+g[ia>>2];Z=+g[ia+4>>2];ia=N;aa=+g[ia>>2];ga=+g[ia+4>>2];$=aa-la;fa=ga-Z;Z=la*$+Z*fa;if(Z>=-0.0){g[s>>2]=1.0;c[o>>2]=1;Y=45;break}$=aa*$+ga*fa;if(!($<=0.0)){la=1.0/($-Z);g[s>>2]=$*la;g[K>>2]=-(Z*la);c[o>>2]=2;Y=46;break}else{g[K>>2]=1.0;c[o>>2]=1;Y=m+0|0;_=M+0|0;ba=Y+36|0;do{c[Y>>2]=c[_>>2];Y=Y+4|0;_=_+4|0}while((Y|0)<(ba|0));Y=45;break}}else if((V|0)==1)Y=45;else if((V|0)==3){ia=C;pa=+g[ia>>2];na=+g[ia+4>>2];ia=N;ma=+g[ia>>2];oa=+g[ia+4>>2];ia=T;qa=+g[ia>>2];Z=+g[ia+4>>2];sa=ma-pa;aa=oa-na;ga=pa*sa+na*aa;ha=ma*sa+oa*aa;$=qa-pa;ra=Z-na;fa=pa*$+na*ra;la=qa*$+Z*ra;ta=qa-ma;ja=Z-oa;ka=ma*ta+oa*ja;ja=qa*ta+Z*ja;$=sa*ra-aa*$;aa=(ma*Z-oa*qa)*$;Z=(na*qa-pa*Z)*$;$=(pa*oa-na*ma)*$;if(!(!(ga>=-0.0)|!(fa>=-0.0))){g[s>>2]=1.0;c[o>>2]=1;Y=45;break}if(!(!(ga<-0.0)|!(ha>0.0)|!($<=0.0))){ta=1.0/(ha-ga);g[s>>2]=ha*ta;g[K>>2]=-(ga*ta);c[o>>2]=2;Y=46;break}if(!(!(fa<-0.0)|!(la>0.0)|!(Z<=0.0))){ta=1.0/(la-fa);g[s>>2]=la*ta;g[L>>2]=-(fa*ta);c[o>>2]=2;Y=M+0|0;_=U+0|0;ba=Y+36|0;do{c[Y>>2]=c[_>>2];Y=Y+4|0;_=_+4|0}while((Y|0)<(ba|0));Y=46;break}if(!(!(ha<=0.0)|!(ka>=-0.0))){g[K>>2]=1.0;c[o>>2]=1;Y=m+0|0;_=M+0|0;ba=Y+36|0;do{c[Y>>2]=c[_>>2];Y=Y+4|0;_=_+4|0}while((Y|0)<(ba|0));Y=45;break}if(!(!(la<=0.0)|!(ja<=0.0))){g[L>>2]=1.0;c[o>>2]=1;Y=m+0|0;_=U+0|0;ba=Y+36|0;do{c[Y>>2]=c[_>>2];Y=Y+4|0;_=_+4|0}while((Y|0)<(ba|0));Y=45;break}if(!(ka<-0.0)|!(ja>0.0)|!(aa<=0.0)){Y=43;break b}ta=1.0/(ja-ka);g[K>>2]=ja*ta;g[L>>2]=-(ka*ta);c[o>>2]=2;Y=m+0|0;_=U+0|0;ba=Y+36|0;do{c[Y>>2]=c[_>>2];Y=Y+4|0;_=_+4|0}while((Y|0)<(ba|0));Y=46}else{Y=44;break b}while(0);do if((Y|0)==45){_=1;Z=-+g[S>>2];$=-+g[R>>2]}else if((Y|0)==46){sa=+g[S>>2];$=+g[Q>>2]-sa;ta=+g[R>>2];Z=+g[P>>2]-ta;if(sa*Z-$*ta>0.0){_=2;Z=-Z;break}else{_=2;$=-$;break}}while(0);if(Z*Z+$*$<1.4210854715202004e-14){V=_;Y=71;break}ba=m+(_*36|0)|0;ha=-Z;ta=-$;ga=D*ha+A*ta;ha=D*ta-A*ha;ca=c[I>>2]|0;da=c[v>>2]|0;if((da|0)>1){ea=0;aa=ha*+g[ca+4>>2]+ga*+g[ca>>2];ia=1;while(1){fa=ga*+g[ca+(ia<<3)>>2]+ha*+g[ca+(ia<<3)+4>>2];Y=fa>aa;ea=Y?ia:ea;ia=ia+1|0;if((ia|0)==(da|0))break;else aa=Y?fa:aa}Y=m+(_*36|0)+28|0;c[Y>>2]=ea;if((ea|0)<=-1){Y=56;break}}else{Y=m+(_*36|0)+28|0;c[Y>>2]=0;ea=0}if((da|0)<=(ea|0)){Y=56;break}sa=+g[ca+(ea<<3)>>2];fa=+g[ca+(ea<<3)+4>>2];aa=z+(D*sa-A*fa);ta=+aa;fa=+(sa*A+D*fa+y);ca=ba;g[ca>>2]=ta;g[ca+4>>2]=fa;fa=w*Z+J*$;Z=w*$-Z*J;ca=c[G>>2]|0;ba=c[H>>2]|0;if((ba|0)>1){da=0;ga=Z*+g[ca+4>>2]+fa*+g[ca>>2];ea=1;while(1){$=fa*+g[ca+(ea<<3)>>2]+Z*+g[ca+(ea<<3)+4>>2];ia=$>ga;da=ia?ea:da;ea=ea+1|0;if((ea|0)==(ba|0))break;else ga=ia?$:ga}ea=m+(_*36|0)+32|0;c[ea>>2]=da;if((da|0)<=-1){Y=63;break}}else{ea=m+(_*36|0)+32|0;c[ea>>2]=0;da=0}if((ba|0)<=(da|0)){Y=63;break}qa=+g[ca+(da<<3)>>2];ta=+g[ca+(da<<3)+4>>2];sa=x+(w*qa-J*ta);ra=+sa;ta=+(qa*J+w*ta+F);ia=m+(_*36|0)+8|0;g[ia>>2]=ra;g[ia+4>>2]=ta;sa=+(sa-aa);ta=+(+g[m+(_*36|0)+12>>2]- +g[m+(_*36|0)+4>>2]);ia=m+(_*36|0)+16|0;g[ia>>2]=sa;g[ia+4>>2]=ta;W=W+1|0;c[1348]=(c[1348]|0)+1;if(X){Y=c[Y>>2]|0;X=0;do{if((Y|0)==(c[B+(X<<2)>>2]|0)?(c[ea>>2]|0)==(c[E+(X<<2)>>2]|0):0){Y=70;break b}X=X+1|0}while((X|0)<(V|0))}V=(c[o>>2]|0)+1|0;c[o>>2]=V;if((W|0)>=20){Y=71;break}}if((Y|0)==43){ta=1.0/($+(aa+Z));g[s>>2]=aa*ta;g[K>>2]=Z*ta;g[L>>2]=$*ta;c[o>>2]=3;l=c[1350]|0;c[1350]=(l|0)>(W|0)?l:W;l=e+8|0;r=W;Y=75}else if((Y|0)==44)Aa(15224,5448,498,5496);else if((Y|0)==56)Aa(6336,6368,103,6416);else if((Y|0)==63)Aa(6336,6368,103,6416);else if((Y|0)==70){V=c[o>>2]|0;Y=71}do if((Y|0)==71){v=c[1350]|0;c[1350]=(v|0)>(W|0)?v:W;v=e+8|0;if((V|0)==3){l=v;r=W;Y=75;break}else if(!V)Aa(15224,5448,218,5528);else if((V|0)==1){r=m;ea=c[r>>2]|0;r=c[r+4>>2]|0;l=e;c[l>>2]=ea;c[l+4>>2]=r;l=m+8|0;ia=c[l>>2]|0;l=c[l+4>>2]|0;da=v;c[da>>2]=ia;c[da+4>>2]=l;t=(c[k>>2]=ea,+g[k>>2]);u=(c[k>>2]=ia,+g[k>>2]);q=(c[k>>2]=r,+g[k>>2]);p=(c[k>>2]=l,+g[k>>2]);l=v;r=W;break}else if((V|0)==2){sa=+g[s>>2];p=+g[K>>2];t=sa*+g[m>>2]+p*+g[m+36>>2];q=sa*+g[m+4>>2]+p*+g[m+40>>2];ta=+t;u=+q;l=e;g[l>>2]=ta;g[l+4>>2]=u;u=sa*+g[m+8>>2]+p*+g[m+44>>2];p=sa*+g[m+12>>2]+p*+g[m+48>>2];sa=+u;ta=+p;l=v;g[l>>2]=sa;g[l+4>>2]=ta;l=v;r=W;break}else Aa(15224,5448,237,5528)}while(0);if((Y|0)==75){t=+g[s>>2];q=+g[K>>2];p=+g[L>>2];u=t*+g[m>>2]+q*+g[m+36>>2]+p*+g[m+72>>2];p=t*+g[m+4>>2]+q*+g[m+40>>2]+p*+g[m+76>>2];q=+u;t=+p;ia=e;g[ia>>2]=q;g[ia+4>>2]=t;ia=l;g[ia>>2]=q;g[ia+4>>2]=t;t=u;q=p}sa=t-u;s=e+4|0;v=e+12|0;ta=q-p;B=e+16|0;g[B>>2]=+O(+(sa*sa+ta*ta));c[e+20>>2]=r;g[f>>2]=+Zw(m);o=c[o>>2]|0;b[n>>1]=o;if((o|0)>0){n=0;do{a[f+n+6>>0]=c[m+(n*36|0)+28>>2];a[f+n+9>>0]=c[m+(n*36|0)+32>>2];n=n+1|0}while((n|0)<(o|0))}if(!(a[h+88>>0]|0)){i=j;return}p=+g[h+24>>2];q=+g[h+52>>2];t=+g[B>>2];u=p+q;if(!(t>u&t>1.1920928955078125e-7)){sa=+((+g[e>>2]+ +g[l>>2])*.5);ta=+((+g[s>>2]+ +g[v>>2])*.5);ia=e;g[ia>>2]=sa;g[ia+4>>2]=ta;ia=l;g[ia>>2]=sa;g[ia+4>>2]=ta;g[B>>2]=0.0;i=j;return}g[B>>2]=t-u;w=+g[l>>2];t=+g[e>>2];z=w-t;u=+g[v>>2];x=+g[s>>2];y=u-x;A=+O(+(z*z+y*y));if(!(A<1.1920928955078125e-7)){ta=1.0/A;z=z*ta;y=y*ta}g[e>>2]=p*z+t;g[s>>2]=p*y+x;g[l>>2]=w-q*z;g[v>>2]=u-q*y;i=j;return}function Zw(a){a=a|0;var b=0,d=0,e=0.0,f=0.0;b=i;d=c[a+108>>2]|0;if((d|0)==3){e=+g[a+16>>2];f=+g[a+20>>2];e=(+g[a+52>>2]-e)*(+g[a+92>>2]-f)-(+g[a+56>>2]-f)*(+g[a+88>>2]-e);i=b;return+e}else if(!d)Aa(15224,5448,247,5512);else if((d|0)==2){e=+g[a+16>>2]- +g[a+52>>2];f=+g[a+20>>2]- +g[a+56>>2];f=+O(+(e*e+f*f));i=b;return+f}else if((d|0)==1){f=0.0;i=b;return+f}else Aa(15224,5448,260,5512);return 0.0}function _w(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0;b=i;d=a+16|0;e=c[d>>2]|0;if((e|0)==-1){f=a+8|0;g=c[f>>2]|0;e=a+12|0;if((g|0)!=(c[e>>2]|0))Aa(5592,5624,58,5672);a=a+4|0;h=c[a>>2]|0;c[e>>2]=g<<1;g=NB(g*72|0)|0;c[a>>2]=g;SB(g|0,h|0,(c[f>>2]|0)*36|0)|0;OB(h);g=c[f>>2]|0;h=(c[e>>2]|0)+ -1|0;a=c[a>>2]|0;if((g|0)<(h|0))do{h=g;g=g+1|0;c[a+(h*36|0)+20>>2]=g;c[a+(h*36|0)+32>>2]=-1;h=(c[e>>2]|0)+ -1|0}while((g|0)<(h|0));c[a+(h*36|0)+20>>2]=-1;c[a+(((c[e>>2]|0)+ -1|0)*36|0)+32>>2]=-1;e=c[f>>2]|0;c[d>>2]=e}else{f=a+8|0;a=c[a+4>>2]|0}h=a+(e*36|0)+20|0;c[d>>2]=c[h>>2];c[h>>2]=-1;c[a+(e*36|0)+24>>2]=-1;c[a+(e*36|0)+28>>2]=-1;c[a+(e*36|0)+32>>2]=0;c[a+(e*36|0)+16>>2]=0;c[f>>2]=(c[f>>2]|0)+1;i=b;return e|0}function $w(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;d=i;if((b|0)<=-1)Aa(5688,5624,94,5728);if((c[a+12>>2]|0)<=(b|0))Aa(5688,5624,94,5728);e=a+8|0;if((c[e>>2]|0)>0){f=a+16|0;a=c[a+4>>2]|0;c[a+(b*36|0)+20>>2]=c[f>>2];c[a+(b*36|0)+32>>2]=-1;c[f>>2]=b;c[e>>2]=(c[e>>2]|0)+ -1;i=d;return}else Aa(5744,5624,95,5728)}function ax(a,b){a=a|0;b=b|0;var d=0,e=0,f=0.0,h=0.0,j=0.0,k=0.0,l=0,m=0,n=0,o=0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0;d=i;n=a+24|0;c[n>>2]=(c[n>>2]|0)+1;n=c[a>>2]|0;if((n|0)==-1){c[a>>2]=b;c[(c[a+4>>2]|0)+(b*36|0)+20>>2]=-1;i=d;return}e=a+4|0;l=c[e>>2]|0;f=+g[l+(b*36|0)>>2];h=+g[l+(b*36|0)+4>>2];j=+g[l+(b*36|0)+8>>2];k=+g[l+(b*36|0)+12>>2];m=c[l+(n*36|0)+24>>2]|0;a:do if((m|0)!=-1)do{o=c[l+(n*36|0)+28>>2]|0;s=+g[l+(n*36|0)+8>>2];y=+g[l+(n*36|0)>>2];u=+g[l+(n*36|0)+12>>2];q=+g[l+(n*36|0)+4>>2];w=((s>j?s:j)-(yk?u:k)-(q>2];y=f>2];w=h>2];r=j>v?j:v;t=+g[l+(m*36|0)+12>>2];x=k>t?k:t;if((c[l+(m*36|0)+24>>2]|0)==-1)r=(r-y+(x-w))*2.0;else r=(r-y+(x-w))*2.0-(v-u+(t-s))*2.0;r=q+r;s=+g[l+(o*36|0)>>2];w=f>2];y=h>2];v=j>u?j:u;t=+g[l+(o*36|0)+12>>2];x=k>t?k:t;if((c[l+(o*36|0)+24>>2]|0)==-1)s=(v-w+(x-y))*2.0;else s=(v-w+(x-y))*2.0-(u-s+(t-z))*2.0;q=q+s;if(p>2]|0}while((m|0)!=-1);while(0);l=c[l+(n*36|0)+20>>2]|0;m=_w(a)|0;o=c[e>>2]|0;c[o+(m*36|0)+20>>2]=l;c[o+(m*36|0)+16>>2]=0;o=c[e>>2]|0;z=+g[o+(n*36|0)>>2];y=+g[o+(n*36|0)+4>>2];z=+(f>2]=z;g[A+4>>2]=y;y=+g[o+(n*36|0)+8>>2];z=+g[o+(n*36|0)+12>>2];y=+(j>y?j:y);z=+(k>z?k:z);o=o+(m*36|0)+8|0;g[o>>2]=y;g[o+4>>2]=z;o=c[e>>2]|0;c[o+(m*36|0)+32>>2]=(c[o+(n*36|0)+32>>2]|0)+1;if((l|0)==-1){c[o+(m*36|0)+24>>2]=n;c[o+(m*36|0)+28>>2]=b;c[o+(n*36|0)+20>>2]=m;A=o+(b*36|0)+20|0;c[A>>2]=m;c[a>>2]=m;m=c[A>>2]|0}else{A=o+(l*36|0)+24|0;if((c[A>>2]|0)==(n|0))c[A>>2]=m;else c[o+(l*36|0)+28>>2]=m;c[o+(m*36|0)+24>>2]=n;c[o+(m*36|0)+28>>2]=b;c[o+(n*36|0)+20>>2]=m;c[o+(b*36|0)+20>>2]=m}if((m|0)==-1){i=d;return}while(1){n=dx(a,m)|0;b=c[e>>2]|0;l=c[b+(n*36|0)+24>>2]|0;m=c[b+(n*36|0)+28>>2]|0;if((l|0)==-1){e=20;break}if((m|0)==-1){e=22;break}o=c[b+(l*36|0)+32>>2]|0;A=c[b+(m*36|0)+32>>2]|0;c[b+(n*36|0)+32>>2]=((o|0)>(A|0)?o:A)+1;cx(b+(n*36|0)|0,b+(l*36|0)|0,b+(m*36|0)|0);m=c[(c[e>>2]|0)+(n*36|0)+20>>2]|0;if((m|0)==-1){e=24;break}}if((e|0)==20)Aa(5824,5624,304,5840);else if((e|0)==22)Aa(5856,5624,305,5840);else if((e|0)==24){i=d;return}}function bx(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,j=0;e=i;if((c[a>>2]|0)==(b|0)){c[a>>2]=-1;i=e;return}d=a+4|0;f=c[d>>2]|0;g=c[f+(b*36|0)+20>>2]|0;h=c[f+(g*36|0)+20>>2]|0;j=c[f+(g*36|0)+24>>2]|0;if((j|0)==(b|0))j=c[f+(g*36|0)+28>>2]|0;if((h|0)==-1){c[a>>2]=j;c[f+(j*36|0)+20>>2]=-1;$w(a,g);i=e;return}b=f+(h*36|0)+24|0;if((c[b>>2]|0)==(g|0))c[b>>2]=j;else c[f+(h*36|0)+28>>2]=j;c[f+(j*36|0)+20>>2]=h;$w(a,g);do{j=dx(a,h)|0;b=c[d>>2]|0;f=c[b+(j*36|0)+24>>2]|0;g=c[b+(j*36|0)+28>>2]|0;cx(b+(j*36|0)|0,b+(f*36|0)|0,b+(g*36|0)|0);b=c[d>>2]|0;f=c[b+(f*36|0)+32>>2]|0;g=c[b+(g*36|0)+32>>2]|0;c[b+(j*36|0)+32>>2]=((f|0)>(g|0)?f:g)+1;h=c[b+(j*36|0)+20>>2]|0}while((h|0)!=-1);i=e;return}function cx(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0.0,f=0.0,h=0.0,j=0.0,k=0;d=i;e=+g[b>>2];f=+g[c>>2];h=+g[b+4>>2];j=+g[c+4>>2];f=+(e>2]=f;g[k+4>>2]=j;j=+g[b+8>>2];f=+g[c+8>>2];h=+g[b+12>>2];e=+g[c+12>>2];f=+(j>f?j:f);e=+(h>e?h:e);b=a+8|0;g[b>>2]=f;g[b+4>>2]=e;i=d;return}function dx(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0;d=i;if((b|0)==-1)Aa(5872,5624,379,5888);h=c[a+4>>2]|0;g=h+(b*36|0)|0;p=h+(b*36|0)+24|0;o=c[p>>2]|0;if((o|0)==-1){u=b;i=d;return u|0}j=h+(b*36|0)+32|0;if((c[j>>2]|0)<2){u=b;i=d;return u|0}q=h+(b*36|0)+28|0;n=c[q>>2]|0;if((o|0)<=-1)Aa(5896,5624,389,5888);m=c[a+12>>2]|0;if((o|0)>=(m|0))Aa(5896,5624,389,5888);if(!((n|0)>-1&(n|0)<(m|0)))Aa(5928,5624,390,5888);l=h+(o*36|0)|0;k=h+(n*36|0)|0;e=h+(n*36|0)+32|0;f=h+(o*36|0)+32|0;r=(c[e>>2]|0)-(c[f>>2]|0)|0;if((r|0)>1){u=h+(n*36|0)+24|0;o=c[u>>2]|0;p=h+(n*36|0)+28|0;r=c[p>>2]|0;t=h+(o*36|0)|0;s=h+(r*36|0)|0;if(!((o|0)>-1&(o|0)<(m|0)))Aa(5960,5624,404,5888);if(!((r|0)>-1&(r|0)<(m|0)))Aa(5992,5624,405,5888);c[u>>2]=b;u=h+(b*36|0)+20|0;m=h+(n*36|0)+20|0;c[m>>2]=c[u>>2];c[u>>2]=n;m=c[m>>2]|0;do if((m|0)!=-1){a=h+(m*36|0)+24|0;if((c[a>>2]|0)==(b|0)){c[a>>2]=n;break}a=h+(m*36|0)+28|0;if((c[a>>2]|0)==(b|0)){c[a>>2]=n;break}else Aa(6024,5624,421,5888)}else c[a>>2]=n;while(0);m=h+(o*36|0)+32|0;a=h+(r*36|0)+32|0;if((c[m>>2]|0)>(c[a>>2]|0)){c[p>>2]=o;c[q>>2]=r;c[h+(r*36|0)+20>>2]=b;cx(g,l,s);cx(k,g,t);f=c[f>>2]|0;u=c[a>>2]|0;u=((f|0)>(u|0)?f:u)+1|0;c[j>>2]=u;f=c[m>>2]|0;f=(u|0)>(f|0)?u:f}else{c[p>>2]=r;c[q>>2]=o;c[h+(o*36|0)+20>>2]=b;cx(g,l,t);cx(k,g,s);f=c[f>>2]|0;u=c[m>>2]|0;u=((f|0)>(u|0)?f:u)+1|0;c[j>>2]=u;f=c[a>>2]|0;f=(u|0)>(f|0)?u:f}c[e>>2]=f+1;u=n;i=d;return u|0}if((r|0)>=-1){u=b;i=d;return u|0}u=h+(o*36|0)+24|0;t=c[u>>2]|0;s=h+(o*36|0)+28|0;r=c[s>>2]|0;n=h+(t*36|0)|0;q=h+(r*36|0)|0;if(!((t|0)>-1&(t|0)<(m|0)))Aa(6056,5624,464,5888);if(!((r|0)>-1&(r|0)<(m|0)))Aa(6088,5624,465,5888);c[u>>2]=b;u=h+(b*36|0)+20|0;m=h+(o*36|0)+20|0;c[m>>2]=c[u>>2];c[u>>2]=o;m=c[m>>2]|0;do if((m|0)!=-1){a=h+(m*36|0)+24|0;if((c[a>>2]|0)==(b|0)){c[a>>2]=o;break}a=h+(m*36|0)+28|0;if((c[a>>2]|0)==(b|0)){c[a>>2]=o;break}else Aa(6120,5624,481,5888)}else c[a>>2]=o;while(0);m=h+(t*36|0)+32|0;a=h+(r*36|0)+32|0;if((c[m>>2]|0)>(c[a>>2]|0)){c[s>>2]=t;c[p>>2]=r;c[h+(r*36|0)+20>>2]=b;cx(g,k,q);cx(l,g,n);e=c[e>>2]|0;u=c[a>>2]|0;u=((e|0)>(u|0)?e:u)+1|0;c[j>>2]=u;e=c[m>>2]|0;e=(u|0)>(e|0)?u:e}else{c[s>>2]=r;c[p>>2]=t;c[h+(t*36|0)+20>>2]=b;cx(g,k,n);cx(l,g,q);e=c[e>>2]|0;u=c[m>>2]|0;u=((e|0)>(u|0)?e:u)+1|0;c[j>>2]=u;e=c[a>>2]|0;e=(u|0)>(e|0)?u:e}c[f>>2]=e+1;u=o;i=d;return u|0}function ex(a,b,d,e){a=a|0;b=b|0;d=d|0;e=+e;var f=0.0,h=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0,p=0.0,q=0.0,r=0.0,s=0.0,t=0,u=0.0,v=0.0;o=i;q=1.0-e;f=q*+g[a+32>>2]+ +g[a+36>>2]*e;m=+R(+f);f=+Q(+f);j=+g[a+8>>2];n=+g[a+12>>2];l=q*+g[a+16>>2]+ +g[a+24>>2]*e-(f*j-m*n);n=q*+g[a+20>>2]+ +g[a+28>>2]*e-(m*j+f*n);j=q*+g[a+68>>2]+ +g[a+72>>2]*e;k=+R(+j);j=+Q(+j);r=+g[a+44>>2];s=+g[a+48>>2];h=q*+g[a+52>>2]+ +g[a+60>>2]*e-(j*r-k*s);e=q*+g[a+56>>2]+ +g[a+64>>2]*e-(k*r+j*s);t=c[a+80>>2]|0;if((t|0)==1){p=+g[a+92>>2];q=+g[a+96>>2];r=+g[a+84>>2];s=+g[a+88>>2];a=c[a+4>>2]|0;if((d|0)<=-1)Aa(6336,6368,103,6416);if((c[a+20>>2]|0)<=(d|0))Aa(6336,6368,103,6416);t=(c[a+16>>2]|0)+(d<<3)|0;v=+g[t>>2];u=+g[t+4>>2];s=(f*p-m*q)*(h+(j*v-k*u)-(l+(f*r-m*s)))+(m*p+f*q)*(e+(k*v+j*u)-(n+(m*r+f*s)));i=o;return+s}else if(!t){t=c[a>>2]|0;if((b|0)<=-1)Aa(6336,6368,103,6416);if((c[t+20>>2]|0)<=(b|0))Aa(6336,6368,103,6416);b=(c[t+16>>2]|0)+(b<<3)|0;p=+g[b>>2];q=+g[b+4>>2];b=c[a+4>>2]|0;if((d|0)<=-1)Aa(6336,6368,103,6416);if((c[b+20>>2]|0)<=(d|0))Aa(6336,6368,103,6416);t=(c[b+16>>2]|0)+(d<<3)|0;u=+g[t>>2];v=+g[t+4>>2];v=+g[a+92>>2]*(h+(j*u-k*v)-(l+(f*p-m*q)))+ +g[a+96>>2]*(e+(k*u+j*v)-(n+(m*p+f*q)));i=o;return+v}else if((t|0)==2){s=+g[a+92>>2];q=+g[a+96>>2];p=+g[a+84>>2];r=+g[a+88>>2];a=c[a>>2]|0;if((b|0)<=-1)Aa(6336,6368,103,6416);if((c[a+20>>2]|0)<=(b|0))Aa(6336,6368,103,6416);t=(c[a+16>>2]|0)+(b<<3)|0;u=+g[t>>2];v=+g[t+4>>2];v=(j*s-k*q)*(l+(f*u-m*v)-(h+(j*p-k*r)))+(k*s+j*q)*(n+(m*u+f*v)-(e+(k*p+j*r)));i=o;return+v}else Aa(15224,6256,239,6320);return 0.0}function fx(a){a=a|0;var b=0;b=i;c[a>>2]=6488;OB(c[a+12>>2]|0);OB(a);i=b;return}function gx(a){a=a|0;var b=0,d=0;b=i;c[a>>2]=6488;d=a+12|0;OB(c[d>>2]|0);c[d>>2]=0;c[a+16>>2]=0;i=b;return}function hx(a,d,e){a=a|0;d=d|0;e=e|0;var f=0,h=0,j=0,k=0,l=0.0,m=0.0,n=0.0,o=0.0;h=i;f=a+12|0;if(c[f>>2]|0)Aa(6520,6560,60,6680);j=a+16|0;if(c[j>>2]|0)Aa(6520,6560,60,6680);if((e|0)<=1)Aa(6696,6560,61,6680);m=+g[d>>2];l=+g[d+4>>2];k=1;while(1){o=m;m=+g[d+(k<<3)>>2];o=o-m;n=l;l=+g[d+(k<<3)+4>>2];n=n-l;k=k+1|0;if(!(o*o+n*n>2499999936844688.0e-20)){k=9;break}if((k|0)>=(e|0)){k=10;break}}if((k|0)==9)Aa(6712,6560,66,6680);else if((k|0)==10){c[j>>2]=e;k=NB(e<<3)|0;c[f>>2]=k;SB(k|0,d|0,c[j>>2]<<3|0)|0;k=a+20|0;c[k+0>>2]=0;c[k+4>>2]=0;c[k+8>>2]=0;c[k+12>>2]=0;b[k+16>>1]=0;i=h;return}}function ix(b,d){b=b|0;d=d|0;var e=0,f=0,h=0,j=0;e=i;d=Hx(d,40)|0;if(!d)d=0;else{c[d>>2]=6488;c[d+4>>2]=3;g[d+8>>2]=.009999999776482582;c[d+12>>2]=0;c[d+16>>2]=0;a[d+36>>0]=0;a[d+37>>0]=0}hx(d,c[b+12>>2]|0,c[b+16>>2]|0);f=b+20|0;h=c[f+4>>2]|0;j=d+20|0;c[j>>2]=c[f>>2];c[j+4>>2]=h;j=b+28|0;h=c[j+4>>2]|0;f=d+28|0;c[f>>2]=c[j>>2];c[f+4>>2]=h;a[d+36>>0]=a[b+36>>0]|0;a[d+37>>0]=a[b+37>>0]|0;i=e;return d|0}function jx(a){a=a|0;return(c[a+16>>2]|0)+ -1|0}function kx(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,h=0,j=0,k=0,l=0,m=0,n=0;f=i;if((e|0)<=-1)Aa(6776,6560,112,6816);h=b+16|0;if(((c[h>>2]|0)+ -1|0)<=(e|0))Aa(6776,6560,112,6816);c[d+4>>2]=1;g[d+8>>2]=+g[b+8>>2];j=b+12|0;k=(c[j>>2]|0)+(e<<3)|0;l=c[k+4>>2]|0;m=d+12|0;c[m>>2]=c[k>>2];c[m+4>>2]=l;m=(c[j>>2]|0)+(e+1<<3)|0;l=c[m+4>>2]|0;k=d+20|0;c[k>>2]=c[m>>2];c[k+4>>2]=l;k=d+28|0;if((e|0)>0){n=(c[j>>2]|0)+(e+ -1<<3)|0;l=c[n+4>>2]|0;m=k;c[m>>2]=c[n>>2];c[m+4>>2]=l;a[d+44>>0]=1}else{l=b+20|0;m=c[l+4>>2]|0;n=k;c[n>>2]=c[l>>2];c[n+4>>2]=m;a[d+44>>0]=a[b+36>>0]|0}k=d+36|0;if(((c[h>>2]|0)+ -2|0)>(e|0)){l=(c[j>>2]|0)+(e+2<<3)|0;m=c[l+4>>2]|0;n=k;c[n>>2]=c[l>>2];c[n+4>>2]=m;a[d+45>>0]=1;i=f;return}else{l=b+28|0;m=c[l+4>>2]|0;n=k;c[n>>2]=c[l>>2];c[n+4>>2]=m;a[d+45>>0]=a[b+37>>0]|0;i=f;return}}function lx(a,b,c){a=a|0;b=b|0;c=c|0;return 0}function mx(a,d,e,f,h){a=a|0;d=d|0;e=e|0;f=f|0;h=h|0;var j=0,k=0,l=0,m=0,n=0,o=0;j=i;i=i+48|0;k=j;l=c[a+16>>2]|0;if((l|0)>(h|0)){c[k>>2]=7008;c[k+4>>2]=1;g[k+8>>2]=.009999999776482582;m=k+28|0;c[m+0>>2]=0;c[m+4>>2]=0;c[m+8>>2]=0;c[m+12>>2]=0;b[m+16>>1]=0;m=h+1|0;a=c[a+12>>2]|0;o=a+(h<<3)|0;n=c[o+4>>2]|0;h=k+12|0;c[h>>2]=c[o>>2];c[h+4>>2]=n;l=a+(((m|0)==(l|0)?0:m)<<3)|0;h=c[l+4>>2]|0;a=k+20|0;c[a>>2]=c[l>>2];c[a+4>>2]=h;a=yx(k,d,e,f,0)|0;i=j;return a|0}else Aa(6832,6560,152,11784);return 0}function nx(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,h=0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0;f=i;h=c[a+16>>2]|0;if((h|0)>(e|0)){r=e+1|0;h=(r|0)==(h|0)?0:r;a=c[a+12>>2]|0;o=+g[d+12>>2];n=+g[a+(e<<3)>>2];p=+g[d+8>>2];l=+g[a+(e<<3)+4>>2];k=+g[d>>2];m=k+(o*n-p*l);q=+g[d+4>>2];l=n*p+o*l+q;n=+g[a+(h<<3)>>2];j=+g[a+(h<<3)+4>>2];k=k+(o*n-p*j);j=q+(p*n+o*j);o=+(m>2]=o;g[a+4>>2]=n;k=+(m>k?m:k);j=+(l>j?l:j);a=b+8|0;g[a>>2]=k;g[a+4>>2]=j;i=f;return}else Aa(6832,6560,171,6856)}function ox(a,b,d){a=a|0;b=b|0;d=+d;a=i;c[b+0>>2]=0;c[b+4>>2]=0;c[b+8>>2]=0;c[b+12>>2]=0;i=a;return}function px(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0;d=i;b=Hx(b,20)|0;if(!b)b=0;else{c[b>>2]=6936;e=b+4|0;c[e+0>>2]=0;c[e+4>>2]=0;c[e+8>>2]=0;c[e+12>>2]=0}g=a+4|0;e=c[g+4>>2]|0;f=b+4|0;c[f>>2]=c[g>>2];c[f+4>>2]=e;f=a+12|0;a=c[f+4>>2]|0;e=b+12|0;c[e>>2]=c[f>>2];c[e+4>>2]=a;i=d;return b|0}function qx(a){a=a|0;return 1}function rx(a,b,c){a=a|0;b=b|0;c=c|0;var d=0.0,e=0.0,f=0.0,h=0.0,i=0.0;d=+g[b+12>>2];i=+g[a+12>>2];h=+g[b+8>>2];e=+g[a+16>>2];f=+g[c>>2]-(+g[b>>2]+(d*i-h*e));e=+g[c+4>>2]-(+g[b+4>>2]+(i*h+d*e));d=+g[a+8>>2];return f*f+e*e<=d*d|0}function sx(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0.0,h=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0;e=i;m=+g[d+12>>2];k=+g[a+12>>2];n=+g[d+8>>2];h=+g[a+16>>2];l=+g[c>>2];f=l-(+g[d>>2]+(m*k-n*h));j=+g[c+4>>2];h=j-(+g[d+4>>2]+(k*n+m*h));m=+g[a+8>>2];l=+g[c+8>>2]-l;j=+g[c+12>>2]-j;n=f*l+h*j;k=l*l+j*j;m=n*n-(f*f+h*h-m*m)*k;if(m<0.0|k<1.1920928955078125e-7){d=0;i=e;return d|0}n=n+ +O(+m);m=-n;if(!(n<=-0.0)){d=0;i=e;return d|0}if(!(k*+g[c+16>>2]>=m)){d=0;i=e;return d|0}n=m/k;g[b+8>>2]=n;f=f+l*n;j=h+j*n;n=+f;h=+j;d=b;g[d>>2]=n;g[d+4>>2]=h;h=+O(+(f*f+j*j));if(h<1.1920928955078125e-7){d=1;i=e;return d|0}n=1.0/h;g[b>>2]=f*n;g[b+4>>2]=j*n;d=1;i=e;return d|0}function tx(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0.0,f=0.0,h=0.0,i=0.0,j=0.0;e=+g[c+12>>2];j=+g[a+12>>2];i=+g[c+8>>2];f=+g[a+16>>2];h=+g[c>>2]+(e*j-i*f);f=+g[c+4>>2]+(j*i+e*f);d=a+8|0;e=+g[d>>2];g[b>>2]=h-e;g[b+4>>2]=f-e;e=+g[d>>2];g[b+8>>2]=h+e;g[b+12>>2]=f+e;return}function ux(a,b,d){a=a|0;b=b|0;d=+d;var e=0.0,f=0.0,h=0.0,i=0,j=0,k=0,l=0,m=0;j=a+8|0;h=+g[j>>2];h=h*d*3.1415927410125732*h;g[b>>2]=h;i=a+12|0;m=i;l=c[m+4>>2]|0;k=b+4|0;c[k>>2]=c[m>>2];c[k+4>>2]=l;f=+g[j>>2];e=+g[i>>2];d=+g[a+16>>2];g[b+12>>2]=h*(f*f*.5+(e*e+d*d));return}function vx(a,d){a=a|0;d=d|0;var e=0,f=0,h=0,j=0;e=i;d=Hx(d,48)|0;if(!d)d=0;else{c[d>>2]=7008;c[d+4>>2]=1;g[d+8>>2]=.009999999776482582;f=d+28|0;c[f+0>>2]=0;c[f+4>>2]=0;c[f+8>>2]=0;c[f+12>>2]=0;b[f+16>>1]=0}j=a+4|0;h=c[j+4>>2]|0;f=d+4|0;c[f>>2]=c[j>>2];c[f+4>>2]=h;f=d+12|0;a=a+12|0;c[f+0>>2]=c[a+0>>2];c[f+4>>2]=c[a+4>>2];c[f+8>>2]=c[a+8>>2];c[f+12>>2]=c[a+12>>2];c[f+16>>2]=c[a+16>>2];c[f+20>>2]=c[a+20>>2];c[f+24>>2]=c[a+24>>2];c[f+28>>2]=c[a+28>>2];b[f+32>>1]=b[a+32>>1]|0;i=e;return d|0}function wx(a){a=a|0;return 1}function xx(a,b,c){a=a|0;b=b|0;c=c|0;return 0}function yx(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,h=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0;e=i;m=+g[d>>2];l=+g[c>>2]-m;n=+g[d+4>>2];j=+g[c+4>>2]-n;f=d+12|0;q=+g[f>>2];d=d+8|0;k=+g[d>>2];h=l*q+j*k;l=q*j-l*k;m=+g[c+8>>2]-m;n=+g[c+12>>2]-n;j=q*m+k*n-h;m=q*n-k*m-l;v=a+12|0;k=+g[v>>2];n=+g[v+4>>2];a=a+20|0;q=+g[a>>2];q=q-k;p=+g[a+4>>2]-n;t=-q;o=q*q+p*p;r=+O(+o);if(r<1.1920928955078125e-7)s=p;else{u=1.0/r;s=p*u;t=u*t}r=(n-l)*t+(k-h)*s;u=m*t+j*s;if(u==0.0){v=0;i=e;return v|0}u=r/u;if(u<0.0){v=0;i=e;return v|0}if(o==0.0?1:+g[c+16>>2]1.0){v=0;i=e;return v|0}g[b+8>>2]=u;u=+g[f>>2];j=+g[d>>2];h=s*u-t*j;j=t*u+s*j;if(r>0.0){t=+-h;u=+-j;v=b;g[v>>2]=t;g[v+4>>2]=u;v=1;i=e;return v|0}else{t=+h;u=+j;v=b;g[v>>2]=t;g[v+4>>2]=u;v=1;i=e;return v|0}return 0}function zx(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0.0,f=0.0,h=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0;d=i;j=+g[c+12>>2];m=+g[a+12>>2];l=+g[c+8>>2];h=+g[a+16>>2];f=+g[c>>2];k=f+(j*m-l*h);n=+g[c+4>>2];h=m*l+j*h+n;m=+g[a+20>>2];e=+g[a+24>>2];f=f+(j*m-l*e);e=n+(l*m+j*e);j=+g[a+8>>2];m=+((k>2]=m;g[c+4>>2]=l;f=+(j+(k>f?k:f));e=+(j+(h>e?h:e));c=b+8|0;g[c>>2]=f;g[c+4>>2]=e;i=d;return}function Ax(a,b,c){a=a|0;b=b|0;c=+c;var d=0,e=0.0;d=i;g[b>>2]=0.0;e=+((+g[a+12>>2]+ +g[a+20>>2])*.5);c=+((+g[a+16>>2]+ +g[a+24>>2])*.5);a=b+4|0;g[a>>2]=e;g[a+4>>2]=c;g[b+12>>2]=0.0;i=d;return}function Bx(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,h=0;d=i;b=Hx(b,280)|0;if(!b)b=0;else{c[b>>2]=7368;c[b+4>>2]=2;g[b+8>>2]=.009999999776482582;c[b+276>>2]=0;g[b+12>>2]=0.0;g[b+16>>2]=0.0}h=a+4|0;f=c[h+4>>2]|0;e=b+4|0;c[e>>2]=c[h>>2];c[e+4>>2]=f;SB(b+12|0,a+12|0,268)|0;i=d;return b|0}function Cx(a){a=a|0;return 1}function Dx(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0.0,h=0.0,j=0.0,k=0.0,l=0.0;e=i;j=+g[d>>2]- +g[b>>2];k=+g[d+4>>2]- +g[b+4>>2];l=+g[b+12>>2];h=+g[b+8>>2];f=j*l+k*h;h=l*k-j*h;b=c[a+276>>2]|0;if((b|0)>0)d=0;else{d=1;i=e;return d|0}while(1){if((f- +g[a+(d<<3)+20>>2])*+g[a+(d<<3)+148>>2]+(h- +g[a+(d<<3)+24>>2])*+g[a+(d<<3)+152>>2]>0.0){b=0;a=4;break}d=d+1|0;if((d|0)>=(b|0)){b=1;a=4;break}}if((a|0)==4){i=e;return b|0}return 0}function Ex(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var h=0,j=0.0,k=0.0,l=0,m=0.0,n=0.0,o=0.0,p=0,q=0.0,r=0.0,s=0.0,t=0,u=0.0,v=0.0,w=0.0,x=0.0;f=i;n=+g[e>>2];m=+g[d>>2]-n;w=+g[e+4>>2];r=+g[d+4>>2]-w;l=e+12|0;v=+g[l>>2];e=e+8|0;q=+g[e>>2];o=m*v+r*q;m=v*r-m*q;n=+g[d+8>>2]-n;w=+g[d+12>>2]-w;r=v*n+q*w-o;n=v*w-q*n-m;p=c[a+276>>2]|0;q=+g[d+16>>2];do if((p|0)>0){t=0;d=-1;s=0.0;u=q;a:while(1){x=+g[a+(t<<3)+148>>2];w=+g[a+(t<<3)+152>>2];v=(+g[a+(t<<3)+20>>2]-o)*x+(+g[a+(t<<3)+24>>2]-m)*w;w=r*x+n*w;do if(w==0.0){if(v<0.0){h=0;p=17;break a}}else{if(w<0.0?v0.0?v=(p|0)){p=12;break}}if((p|0)==12){if(s>=0.0){j=q;h=d;k=s;break}Aa(7248,7104,328,11784)}else if((p|0)==17){i=f;return h|0}}else{j=q;h=-1;k=0.0}while(0);if(!(k<=j))Aa(7248,7104,328,11784);if((h|0)<=-1){t=0;i=f;return t|0}g[b+8>>2]=k;v=+g[l>>2];s=+g[a+(h<<3)+148>>2];u=+g[e>>2];x=+g[a+(h<<3)+152>>2];w=+(v*s-u*x);x=+(s*u+v*x);t=b;g[t>>2]=w;g[t+4>>2]=x;t=1;i=f;return t|0}function Fx(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0.0,h=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0,q=0.0,r=0.0,s=0.0;e=i;f=+g[d+12>>2];n=+g[a+20>>2];h=+g[d+8>>2];o=+g[a+24>>2];j=+g[d>>2];l=j+(f*n-h*o);k=+g[d+4>>2];o=n*h+f*o+k;d=c[a+276>>2]|0;if((d|0)>1){m=l;n=o;p=1;do{s=+g[a+(p<<3)+20>>2];q=+g[a+(p<<3)+24>>2];r=j+(f*s-h*q);q=s*h+f*q+k;m=mr?l:r;o=o>q?o:q;p=p+1|0}while((p|0)<(d|0))}else{n=o;m=l}s=+g[a+8>>2];q=+(m-s);r=+(n-s);p=b;g[p>>2]=q;g[p+4>>2]=r;r=+(l+s);s=+(o+s);p=b+8|0;g[p>>2]=r;g[p+4>>2]=s;i=e;return}function Gx(a,b,d){a=a|0;b=b|0;d=+d;var e=0,f=0,h=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0,p=0.0,q=0,r=0,s=0,t=0,u=0.0,v=0,w=0.0,x=0.0,y=0.0,z=0.0;e=i;f=c[a+276>>2]|0;if((f|0)>2){j=0.0;h=0.0;o=0}else Aa(7296,7104,385,7312);do{h=h+ +g[a+(o<<3)+20>>2];j=j+ +g[a+(o<<3)+24>>2];o=o+1|0}while((o|0)<(f|0));n=1.0/+(f|0);h=h*n;n=j*n;s=a+20|0;v=a+24|0;l=0.0;m=0.0;j=0.0;k=0.0;t=0;do{u=+g[a+(t<<3)+20>>2]-h;p=+g[a+(t<<3)+24>>2]-n;t=t+1|0;o=(t|0)<(f|0);if(o){q=a+(t<<3)+20|0;r=a+(t<<3)+24|0}else{q=s;r=v}x=+g[q>>2]-h;w=+g[r>>2]-n;y=u*w-p*x;z=y*.5;k=k+z;z=z*.3333333432674408;l=l+(u+x)*z;m=m+(p+w)*z;j=j+y*.0833333358168602*(x*x+(u*u+u*x)+(w*w+(p*p+p*w)))}while(o);p=k*d;g[b>>2]=p;if(k>1.1920928955078125e-7){z=1.0/k;y=l*z;z=m*z;w=h+y;x=n+z;n=+w;u=+x;v=b+4|0;g[v>>2]=n;g[v+4>>2]=u;g[b+12>>2]=j*d+p*(w*w+x*x-(y*y+z*z));i=e;return}else Aa(7328,7104,431,7312)}function Hx(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,j=0,k=0,l=0;e=i;if(!d){k=0;i=e;return k|0}if((d|0)<=0)Aa(8280,8208,102,8528);if((d|0)>640){k=NB(d)|0;i=e;return k|0}k=a[7528+d>>0]|0;g=k&255;if((k&255)>=14)Aa(8296,8208,110,8528);d=b+(g<<2)+12|0;f=c[d>>2]|0;if(f){c[d>>2]=c[f>>2];k=f;i=e;return k|0}f=b+4|0;h=c[f>>2]|0;j=b+8|0;if((h|0)==(c[j>>2]|0)){k=c[b>>2]|0;h=h+128|0;c[j>>2]=h;h=NB(h<<3)|0;c[b>>2]=h;SB(h|0,k|0,c[f>>2]<<3|0)|0;QB((c[b>>2]|0)+(c[f>>2]<<3)|0,0,1024)|0;OB(k);h=c[f>>2]|0}k=c[b>>2]|0;j=NB(16384)|0;b=k+(h<<3)+4|0;c[b>>2]=j;g=c[7472+(g<<2)>>2]|0;c[k+(h<<3)>>2]=g;h=16384/(g|0)|0;if((_(h,g)|0)>=16385)Aa(8336,8208,138,8528);h=h+ -1|0;if((h|0)>0){k=0;do{l=k;k=k+1|0;c[j+(_(l,g)|0)>>2]=j+(_(k,g)|0);j=c[b>>2]|0}while((k|0)!=(h|0))}c[j+(_(h,g)|0)>>2]=0;c[d>>2]=c[c[b>>2]>>2];c[f>>2]=(c[f>>2]|0)+1;l=c[b>>2]|0;i=e;return l|0}function Ix(b,d,e){b=b|0;d=d|0;e=e|0;var f=0;f=i;if(!e){i=f;return}if((e|0)<=0)Aa(8280,8208,162,8568);if((e|0)>640){OB(d);i=f;return}e=a[7528+e>>0]|0;if((e&255)>=14)Aa(8296,8208,171,8568);e=b+((e&255)<<2)+12|0;c[d>>2]=c[e>>2];c[e>>2]=d;i=f;return}function Jx(a,b,c){a=a|0;b=b|0;c=c|0;var d=0.0,e=0.0,f=0.0,h=0.0,i=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0;e=+g[b+16>>2];l=+g[b+32>>2];h=+g[b+20>>2];d=+g[b+28>>2];o=e*l-h*d;k=+g[b+24>>2];f=+g[b+12>>2];n=h*k-l*f;m=d*f-e*k;j=+g[b>>2];i=+g[b+4>>2];p=+g[b+8>>2];q=o*j+i*n+m*p;if(q!=0.0)q=1.0/q;r=+g[c>>2];s=+g[c+4>>2];t=+g[c+8>>2];g[a>>2]=q*(o*r+s*n+m*t);g[a+4>>2]=q*((s*l-t*d)*j+i*(t*k-l*r)+(d*r-s*k)*p);g[a+8>>2]=q*((e*t-h*s)*j+i*(h*r-t*f)+(s*f-e*r)*p);return}function Kx(a,b,c,d){a=a|0;b=b|0;c=+c;d=+d;var e=0.0,f=0.0,h=0.0,i=0.0,j=0.0;f=+g[b>>2];h=+g[b+12>>2];e=+g[b+4>>2];i=+g[b+16>>2];j=f*i-h*e;if(j!=0.0)j=1.0/j;g[a>>2]=j*(i*c-h*d);g[a+4>>2]=j*(f*d-e*c);return}function Lx(a,b){a=a|0;b=b|0;var d=0,e=0.0,f=0.0,h=0.0,j=0.0,k=0.0;d=i;e=+g[a>>2];h=+g[a+12>>2];f=+g[a+4>>2];j=+g[a+16>>2];k=e*j-h*f;if(k!=0.0)k=1.0/k;g[b>>2]=j*k;j=-k;g[b+12>>2]=h*j;g[b+8>>2]=0.0;g[b+4>>2]=f*j;g[b+16>>2]=e*k;a=b+20|0;c[a+0>>2]=0;c[a+4>>2]=0;c[a+8>>2]=0;c[a+12>>2]=0;i=d;return}function Mx(a,b){a=a|0;b=b|0;var c=0.0,d=0.0,e=0.0,f=0.0,h=0.0,i=0.0,j=0.0,k=0.0,l=0.0,m=0.0;d=+g[a+16>>2];c=+g[a+32>>2];l=d*c;m=+g[a+20>>2];f=+g[a+28>>2];h=+g[a+24>>2];i=+g[a+12>>2];k=c*i;j=f*i-d*h;e=+g[a>>2];m=(l-m*f)*e+ +g[a+4>>2]*(m*h-k)+j*+g[a+8>>2];if(m!=0.0)m=1.0/m;g[b>>2]=m*(l-f*f);l=m*(h*f-k);g[b+4>>2]=l;k=m*j;g[b+8>>2]=k;g[b+12>>2]=l;g[b+16>>2]=m*(e*c-h*h);l=m*(i*h-e*f);g[b+20>>2]=l;g[b+24>>2]=k;g[b+28>>2]=l;g[b+32>>2]=m*(e*d-i*i);return}function Nx(a,b){a=a|0;b=b|0;var d=0,e=0;d=i;i=i+16|0;e=d;c[e>>2]=b;Qa(a|0,e|0)|0;i=d;return}function Ox(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,j=0,k=0;f=i;e=b+102796|0;g=c[e>>2]|0;if((g|0)>=32)Aa(8488,8392,38,8528);h=b+(g*12|0)+102412|0;c[b+(g*12|0)+102416>>2]=d;j=b+102400|0;k=c[j>>2]|0;if((k+d|0)>102400){c[h>>2]=NB(d)|0;a[b+(g*12|0)+102420>>0]=1}else{c[h>>2]=b+k;a[b+(g*12|0)+102420>>0]=0;c[j>>2]=(c[j>>2]|0)+d}k=b+102404|0;j=(c[k>>2]|0)+d|0;c[k>>2]=j;k=b+102408|0;d=c[k>>2]|0;c[k>>2]=(d|0)>(j|0)?d:j;c[e>>2]=(c[e>>2]|0)+1;i=f;return c[h>>2]|0}function Px(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0;f=i;e=b+102796|0;g=c[e>>2]|0;if((g|0)<=0)Aa(8544,8392,63,8568);h=g+ -1|0;if((c[b+(h*12|0)+102412>>2]|0)!=(d|0))Aa(8576,8392,65,8568);if(!(a[b+(h*12|0)+102420>>0]|0)){d=b+(h*12|0)+102416|0;h=b+102400|0;c[h>>2]=(c[h>>2]|0)-(c[d>>2]|0)}else{OB(d);d=b+(h*12|0)+102416|0;g=c[e>>2]|0}h=b+102404|0;c[h>>2]=(c[h>>2]|0)-(c[d>>2]|0);c[e>>2]=g+ -1;i=f;return}function Qx(a){a=a|0;var d=0,e=0,f=0,h=0,j=0.0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0.0,s=0.0,t=0,u=0.0,v=0.0,w=0.0,x=0,y=0.0;h=i;i=i+16|0;n=h;l=a+116|0;m=a+120|0;f=a+124|0;k=a+128|0;e=a+28|0;g[e>>2]=0.0;g[a+32>>2]=0.0;c[l+0>>2]=0;c[l+4>>2]=0;c[l+8>>2]=0;c[l+12>>2]=0;o=c[a>>2]|0;if((o|0)==1|(o|0)==0){q=a+12|0;p=c[q>>2]|0;q=c[q+4>>2]|0;t=a+36|0;c[t>>2]=p;c[t+4>>2]=q;t=a+44|0;c[t>>2]=p;c[t+4>>2]=q;g[a+52>>2]=+g[a+56>>2];i=h;return}else if((o|0)==2){t=c[a+100>>2]|0;if(t){o=n+4|0;p=n+8|0;q=n+12|0;u=0.0;r=0.0;s=0.0;v=0.0;do{w=+g[t>>2];if(!(w==0.0)){x=c[t+12>>2]|0;rb[c[(c[x>>2]|0)+28>>2]&63](x,n,w);u=+g[n>>2];r=u+ +g[l>>2];g[l>>2]=r;s=s+u*+g[o>>2];v=v+u*+g[p>>2];u=+g[q>>2]+ +g[f>>2];g[f>>2]=u}t=c[t+4>>2]|0}while((t|0)!=0);if(r>0.0){w=1.0/r;g[m>>2]=w;s=s*w;v=v*w}else d=11}else{v=0.0;s=0.0;u=0.0;d=11}if((d|0)==11){g[l>>2]=1.0;g[m>>2]=1.0;r=1.0}do if(u>0.0?(b[a+4>>1]&16)==0:0){r=u-(v*v+s*s)*r;g[f>>2]=r;if(r>0.0){j=1.0/r;break}else Aa(9064,8624,334,9048)}else d=17;while(0);if((d|0)==17){g[f>>2]=0.0;j=0.0}g[k>>2]=j;x=a+44|0;t=x;w=+g[t>>2];r=+g[t+4>>2];y=+s;j=+v;t=e;g[t>>2]=y;g[t+4>>2]=j;j=+g[a+24>>2];y=+g[a+20>>2];u=+g[a+12>>2]+(j*s-y*v);s=s*y+j*v+ +g[a+16>>2];j=+u;v=+s;g[x>>2]=j;g[x+4>>2]=v;x=a+36|0;g[x>>2]=j;g[x+4>>2]=v;v=+g[a+72>>2];x=a+64|0;g[x>>2]=+g[x>>2]-v*(s-r);x=a+68|0;g[x>>2]=v*(u-w)+ +g[x>>2];i=h;return}else Aa(9016,8624,299,9048)}function Rx(a){a=a|0;var b=0,d=0,e=0,f=0,h=0.0,j=0.0,k=0.0,l=0.0,m=0.0;b=i;i=i+16|0;e=b;k=+g[a+52>>2];l=+R(+k);g[e+8>>2]=l;k=+Q(+k);g[e+12>>2]=k;m=+g[a+28>>2];h=+g[a+32>>2];j=+(+g[a+36>>2]-(k*m-l*h));h=+(+g[a+40>>2]-(m*l+k*h));d=e;g[d>>2]=j;g[d+4>>2]=h;d=(c[a+88>>2]|0)+102872|0;f=c[a+100>>2]|0;if(!f){i=b;return}a=a+12|0;do{my(f,d,e,a);f=c[f+4>>2]|0}while((f|0)!=0);i=b;return}function Sx(d,e){d=d|0;e=e|0;var f=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0.0;f=i;h=d+88|0;n=c[h>>2]|0;if(c[n+102868>>2]&2)Aa(8888,8624,168,8928);l=Hx(n,44)|0;if(!l)l=0;else{b[l+32>>1]=1;b[l+34>>1]=-1;b[l+36>>1]=0;c[l+40>>2]=0;c[l+24>>2]=0;c[l+28>>2]=0;c[l+0>>2]=0;c[l+4>>2]=0;c[l+8>>2]=0;c[l+12>>2]=0}c[l+40>>2]=c[e+4>>2];g[l+16>>2]=+g[e+8>>2];g[l+20>>2]=+g[e+12>>2];j=l+8|0;c[j>>2]=d;k=l+4|0;c[k>>2]=0;m=l+32|0;p=e+22|0;b[m+0>>1]=b[p+0>>1]|0;b[m+2>>1]=b[p+2>>1]|0;b[m+4>>1]=b[p+4>>1]|0;a[l+38>>0]=a[e+20>>0]|0;m=c[e>>2]|0;m=tb[c[(c[m>>2]|0)+8>>2]&63](m,n)|0;c[l+12>>2]=m;m=nb[c[(c[m>>2]|0)+12>>2]&63](m)|0;p=Hx(n,m*28|0)|0;n=l+24|0;c[n>>2]=p;if((m|0)>0){o=0;do{c[p+(o*28|0)+16>>2]=0;p=c[n>>2]|0;c[p+(o*28|0)+24>>2]=-1;o=o+1|0}while((o|0)!=(m|0))}c[l+28>>2]=0;q=+g[e+16>>2];g[l>>2]=q;if(b[d+4>>1]&32){ky(l,(c[h>>2]|0)+102872|0,d+12|0);q=+g[l>>2]}p=d+100|0;c[k>>2]=c[p>>2];c[p>>2]=l;p=d+104|0;c[p>>2]=(c[p>>2]|0)+1;c[j>>2]=d;if(!(q>0.0)){p=c[h>>2]|0;p=p+102868|0;o=c[p>>2]|0;o=o|1;c[p>>2]=o;i=f;return l|0}Qx(d);p=c[h>>2]|0;p=p+102868|0;o=c[p>>2]|0;o=o|1;c[p>>2]=o;i=f;return l|0}function Tx(b,d){b=b|0;d=d|0;var e=0,f=0;e=i;if((c[b>>2]|0)!=2?(c[d>>2]|0)!=2:0)d=0;else f=3;a:do if((f|0)==3){f=c[b+108>>2]|0;if(!f)d=1;else while(1){if((c[f>>2]|0)==(d|0)?(a[(c[f+4>>2]|0)+61>>0]|0)==0:0){d=0;break a}f=c[f+12>>2]|0;if(!f){d=1;break}}}while(0);i=e;return d|0}function Ux(a){a=a|0;var b=0,d=0,f=0,j=0,l=0,m=0.0;b=i;i=i+16|0;d=b;j=a+8|0;f=c[j>>2]|0;Nx(11608,d);Nx(9128,d);c[d>>2]=c[a>>2];Nx(9152,d);m=+g[a+16>>2];h[k>>3]=+g[a+12>>2];c[d>>2]=c[k>>2];c[d+4>>2]=c[k+4>>2];l=d+8|0;h[k>>3]=m;c[l>>2]=c[k>>2];c[l+4>>2]=c[k+4>>2];Nx(9184,d);h[k>>3]=+g[a+56>>2];c[d>>2]=c[k>>2];c[d+4>>2]=c[k+4>>2];Nx(9224,d);m=+g[a+68>>2];h[k>>3]=+g[a+64>>2];c[d>>2]=c[k>>2];c[d+4>>2]=c[k+4>>2];l=d+8|0;h[k>>3]=m;c[l>>2]=c[k>>2];c[l+4>>2]=c[k+4>>2];Nx(9248,d);h[k>>3]=+g[a+72>>2];c[d>>2]=c[k>>2];c[d+4>>2]=c[k+4>>2];Nx(9296,d);h[k>>3]=+g[a+132>>2];c[d>>2]=c[k>>2];c[d+4>>2]=c[k+4>>2];Nx(9336,d);h[k>>3]=+g[a+136>>2];c[d>>2]=c[k>>2];c[d+4>>2]=c[k+4>>2];Nx(9368,d);l=a+4|0;c[d>>2]=(e[l>>1]|0)&4;Nx(9400,d);c[d>>2]=(e[l>>1]|0)&2;Nx(9432,d);c[d>>2]=(e[l>>1]|0)&16;Nx(9456,d);c[d>>2]=(e[l>>1]|0)&8;Nx(9488,d);c[d>>2]=(e[l>>1]|0)&32;Nx(9520,d);h[k>>3]=+g[a+140>>2];c[d>>2]=c[k>>2];c[d+4>>2]=c[k+4>>2];Nx(9552,d);c[d>>2]=c[j>>2];Nx(9584,d);Nx(10896,d);a=c[a+100>>2]|0;if(!a){Nx(11616,d);i=b;return}do{Nx(9632,d);ny(a,f);Nx(9640,d);a=c[a+4>>2]|0}while((a|0)!=0);Nx(11616,d);i=b;return}function Vx(a){a=a|0;return}function Wx(a){a=a|0;return}function Xx(d,f){d=d|0;f=f|0;var h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;h=i;k=f+48|0;j=f+52|0;m=c[(c[k>>2]|0)+8>>2]|0;l=c[(c[j>>2]|0)+8>>2]|0;n=c[d+72>>2]|0;if((n|0)!=0?(c[f+4>>2]&2|0)!=0:0)lb[c[(c[n>>2]|0)+12>>2]&127](n,f);o=f+8|0;p=c[o>>2]|0;n=f+12|0;if(p)c[p+12>>2]=c[n>>2];p=c[n>>2]|0;if(p)c[p+8>>2]=c[o>>2];o=d+60|0;if((c[o>>2]|0)==(f|0))c[o>>2]=c[n>>2];o=f+24|0;p=c[o>>2]|0;n=f+28|0;if(p)c[p+12>>2]=c[n>>2];p=c[n>>2]|0;if(p)c[p+8>>2]=c[o>>2];m=m+112|0;if((f+16|0)==(c[m>>2]|0))c[m>>2]=c[n>>2];n=f+40|0;o=c[n>>2]|0;m=f+44|0;if(o)c[o+12>>2]=c[m>>2];o=c[m>>2]|0;if(o)c[o+8>>2]=c[n>>2];l=l+112|0;if((f+32|0)==(c[l>>2]|0))c[l>>2]=c[m>>2];l=c[d+76>>2]|0;if(!(a[12928]|0))Aa(13088,12984,103,15288);k=c[k>>2]|0;j=c[j>>2]|0;if(((c[f+124>>2]|0)>0?(a[k+38>>0]|0)==0:0)?(a[j+38>>0]|0)==0:0){m=c[k+8>>2]|0;n=m+4|0;o=e[n>>1]|0;if(!(o&2)){b[n>>1]=o|2;g[m+144>>2]=0.0}m=c[j+8>>2]|0;o=m+4|0;n=e[o>>1]|0;if(!(n&2)){b[o>>1]=n|2;g[m+144>>2]=0.0}}k=c[(c[k+12>>2]|0)+4>>2]|0;j=c[(c[j+12>>2]|0)+4>>2]|0;if((k|0)>-1&(j|0)<4){lb[c[12736+(k*48|0)+(j*12|0)+4>>2]&127](f,l);p=d+64|0;c[p>>2]=(c[p>>2]|0)+ -1;i=h;return}else Aa(13112,12984,119,15288)}function Yx(d){d=d|0;var f=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0;f=i;i=i+1040|0;k=f;j=d+52|0;c[j>>2]=0;l=d+40|0;y=c[l>>2]|0;do if((y|0)>0){w=d+32|0;r=d+56|0;v=d+12|0;t=d+4|0;s=k+4|0;o=k+1028|0;u=k+1032|0;q=d+48|0;m=d+44|0;x=0;while(1){B=c[(c[w>>2]|0)+(x<<2)>>2]|0;c[r>>2]=B;if((B|0)!=-1){if((B|0)<=-1){o=7;break}if((c[v>>2]|0)<=(B|0)){o=7;break}C=c[t>>2]|0;c[k>>2]=s;c[o>>2]=0;c[u>>2]=256;dy(k,d);if((c[o>>2]|0)>0){A=C+(B*36|0)|0;y=C+(B*36|0)+4|0;z=C+(B*36|0)+8|0;B=C+(B*36|0)+12|0;do{C=ey(k)|0;do if((C|0)!=-1?(p=c[t>>2]|0,!((+g[A>>2]- +g[p+(C*36|0)+8>>2]>0.0?1:+g[y>>2]- +g[p+(C*36|0)+12>>2]>0.0)|+g[p+(C*36|0)>>2]- +g[z>>2]>0.0|+g[p+(C*36|0)+4>>2]- +g[B>>2]>0.0)):0){D=p+(C*36|0)+24|0;if((c[D>>2]|0)!=-1){dy(k,D);dy(k,p+(C*36|0)+28|0);break}D=c[r>>2]|0;if((D|0)!=(C|0)){E=c[j>>2]|0;if((E|0)==(c[q>>2]|0)){D=c[m>>2]|0;c[q>>2]=E<<1;E=NB(E<<4)|0;c[m>>2]=E;SB(E|0,D|0,c[j>>2]<<3|0)|0;OB(D);D=c[r>>2]|0;E=c[j>>2]|0}F=c[m>>2]|0;c[F+(E<<3)>>2]=(D|0)>(C|0)?C:D;E=c[r>>2]|0;c[F+(c[j>>2]<<3)+4>>2]=(E|0)<(C|0)?C:E;c[j>>2]=(c[j>>2]|0)+1}}while(0)}while((c[o>>2]|0)>0)}y=c[k>>2]|0;if((y|0)!=(s|0)){OB(y);c[k>>2]=0}y=c[l>>2]|0}x=x+1|0;if((x|0)>=(y|0)){o=23;break}}if((o|0)==7)Aa(11792,11736,164,11856);else if((o|0)==23){h=m;n=c[j>>2]|0;break}}else{h=d+44|0;n=0}while(0);c[l>>2]=0;F=c[h>>2]|0;c[k>>2]=58;_x(F,F+(n<<3)|0,k);if((c[j>>2]|0)<=0){i=f;return}o=d+12|0;n=d+4|0;m=d+68|0;l=d+76|0;k=d+60|0;d=d+64|0;s=c[h>>2]|0;q=s;s=c[s>>2]|0;r=0;a:while(1){p=q+(r<<3)|0;if((s|0)<=-1){o=28;break}u=c[o>>2]|0;if((u|0)<=(s|0)){o=28;break}t=c[n>>2]|0;q=q+(r<<3)+4|0;v=c[q>>2]|0;if(!((v|0)>-1&(u|0)>(v|0))){o=30;break}x=c[t+(s*36|0)+16>>2]|0;v=c[t+(v*36|0)+16>>2]|0;u=c[x+16>>2]|0;s=c[v+16>>2]|0;t=c[x+20>>2]|0;v=c[v+20>>2]|0;x=c[u+8>>2]|0;w=c[s+8>>2]|0;b:do if((x|0)!=(w|0)){C=c[w+112>>2]|0;if(C)do{if((c[C>>2]|0)==(x|0)){B=c[C+4>>2]|0;y=c[B+48>>2]|0;z=c[B+52>>2]|0;A=c[B+56>>2]|0;B=c[B+60>>2]|0;if((y|0)==(u|0)&(z|0)==(s|0)&(A|0)==(t|0)&(B|0)==(v|0))break b;if((y|0)==(s|0)&(z|0)==(u|0)&(A|0)==(v|0)&(B|0)==(t|0))break b}C=c[C+12>>2]|0}while((C|0)!=0);if(Tx(w,x)|0){w=c[m>>2]|0;if((w|0)!=0?!(gb[c[(c[w>>2]|0)+8>>2]&63](w,u,s)|0):0)break;w=c[l>>2]|0;if(!(a[12928]|0)){c[3184]=46;c[3185]=98;a[12744]=1;c[3208]=47;c[3209]=99;a[12840]=1;c[3190]=47;c[3191]=99;a[12768]=0;c[3214]=48;c[3215]=100;a[12864]=1;c[3196]=49;c[3197]=101;a[12792]=1;c[3187]=49;c[3188]=101;a[12756]=0;c[3202]=50;c[3203]=102;a[12816]=1;c[3211]=50;c[3212]=102;a[12852]=0;c[3220]=51;c[3221]=103;a[12888]=1;c[3193]=51;c[3194]=103;a[12780]=0;c[3226]=52;c[3227]=104;a[12912]=1;c[3217]=52;c[3218]=104;a[12876]=0;a[12928]=1}x=c[(c[u+12>>2]|0)+4>>2]|0;y=c[(c[s+12>>2]|0)+4>>2]|0;if(x>>>0>=4){o=43;break a}if(y>>>0>=4){o=45;break a}z=c[12736+(x*48|0)+(y*12|0)>>2]|0;if(z){if(!(a[12736+(x*48|0)+(y*12|0)+8>>0]|0))w=ub[z&63](s,v,u,t,w)|0;else w=ub[z&63](u,t,s,v,w)|0;if(w){v=c[w+48>>2]|0;u=c[w+52>>2]|0;t=c[v+8>>2]|0;s=c[u+8>>2]|0;c[w+8>>2]=0;c[w+12>>2]=c[k>>2];x=c[k>>2]|0;if(x)c[x+8>>2]=w;c[k>>2]=w;z=w+16|0;c[w+20>>2]=w;c[z>>2]=s;c[w+24>>2]=0;x=t+112|0;c[w+28>>2]=c[x>>2];y=c[x>>2]|0;if(y)c[y+8>>2]=z;c[x>>2]=z;x=w+32|0;c[w+36>>2]=w;c[x>>2]=t;c[w+40>>2]=0;y=s+112|0;c[w+44>>2]=c[y>>2];w=c[y>>2]|0;if(w)c[w+8>>2]=x;c[y>>2]=x;do if(!(a[v+38>>0]|0)){if(a[u+38>>0]|0)break;u=t+4|0;v=e[u>>1]|0;if(!(v&2)){b[u>>1]=v|2;g[t+144>>2]=0.0}u=s+4|0;t=e[u>>1]|0;if(t&2)break;b[u>>1]=t|2;g[s+144>>2]=0.0}while(0);c[d>>2]=(c[d>>2]|0)+1}}}}while(0);t=c[j>>2]|0;while(1){r=r+1|0;if((r|0)>=(t|0)){o=68;break a}u=c[h>>2]|0;s=c[u+(r<<3)>>2]|0;if((s|0)!=(c[p>>2]|0)){q=u;continue a}if((c[u+(r<<3)+4>>2]|0)!=(c[q>>2]|0)){q=u;continue a}}}if((o|0)==28)Aa(11792,11736,158,11840);else if((o|0)==30)Aa(11792,11736,158,11840);else if((o|0)==43)Aa(12936,12984,80,15280);else if((o|0)==45)Aa(13040,12984,81,15280);else if((o|0)==68){i=f;return}}function Zx(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;d=i;f=c[a>>2]|0;e=c[b>>2]|0;if((f|0)>=(e|0))if((f|0)==(e|0))a=(c[a+4>>2]|0)<(c[b+4>>2]|0);else a=0;else a=1;i=d;return a|0}function _x(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0;e=i;i=i+16|0;f=e;a:while(1){j=b;h=b+ -8|0;b:while(1){k=a;n=j-k|0;o=n>>3;switch(o|0){case 4:{g=7;break a};case 3:{g=6;break a};case 5:{g=8;break a};case 2:{g=4;break a};case 1:case 0:{g=51;break a};default:{}}if((n|0)<248){g=10;break a}m=(o|0)/2|0;l=a+(m<<3)|0;if((n|0)>7992){n=(o|0)/4|0;n=by(a,a+(n<<3)|0,l,a+(n+m<<3)|0,h,d)|0}else n=$x(a,l,h,d)|0;do if(tb[c[d>>2]&63](a,l)|0)o=h;else{o=h;while(1){o=o+ -8|0;if((a|0)==(o|0))break;if(tb[c[d>>2]&63](o,l)|0){g=34;break}}if((g|0)==34){g=0;p=a;m=c[p>>2]|0;p=c[p+4>>2]|0;s=o;r=c[s+4>>2]|0;q=a;c[q>>2]=c[s>>2];c[q+4>>2]=r;q=o;c[q>>2]=m;c[q+4>>2]=p;n=n+1|0;break}k=a+8|0;if(!(tb[c[d>>2]&63](a,h)|0)){if((k|0)==(h|0)){g=51;break a}while(1){l=k+8|0;if(tb[c[d>>2]&63](a,k)|0)break;if((l|0)==(h|0)){g=51;break a}else k=l}s=k;r=c[s>>2]|0;s=c[s+4>>2]|0;p=h;q=c[p+4>>2]|0;c[k>>2]=c[p>>2];c[k+4>>2]=q;k=h;c[k>>2]=r;c[k+4>>2]=s;k=l}if((k|0)==(h|0)){g=51;break a}else m=h;while(1){while(1){l=k+8|0;if(tb[c[d>>2]&63](a,k)|0)break;else k=l}do m=m+ -8|0;while(tb[c[d>>2]&63](a,m)|0);if(k>>>0>=m>>>0){a=k;continue b}s=k;r=c[s>>2]|0;s=c[s+4>>2]|0;p=m;q=c[p+4>>2]|0;c[k>>2]=c[p>>2];c[k+4>>2]=q;k=m;c[k>>2]=r;c[k+4>>2]=s;k=l}}while(0);m=a+8|0;c:do if(m>>>0>>0)while(1){q=m;while(1){m=q+8|0;if(tb[c[d>>2]&63](q,l)|0)q=m;else{p=o;break}}do p=p+ -8|0;while(!(tb[c[d>>2]&63](p,l)|0));if(q>>>0>p>>>0){m=q;break c}s=q;r=c[s>>2]|0;s=c[s+4>>2]|0;u=p;t=c[u+4>>2]|0;o=q;c[o>>2]=c[u>>2];c[o+4>>2]=t;o=p;c[o>>2]=r;c[o+4>>2]=s;o=p;l=(l|0)==(q|0)?p:l;n=n+1|0}while(0);if((m|0)!=(l|0)?tb[c[d>>2]&63](l,m)|0:0){t=m;s=c[t>>2]|0;t=c[t+4>>2]|0;q=l;r=c[q+4>>2]|0;u=m;c[u>>2]=c[q>>2];c[u+4>>2]=r;u=l;c[u>>2]=s;c[u+4>>2]=t;n=n+1|0}if(!n){n=cy(a,m,d)|0;l=m+8|0;if(cy(l,b,d)|0){g=46;break}if(n){a=l;continue}}u=m;if((u-k|0)>=(j-u|0)){g=50;break}_x(a,m,d);a=m+8|0}if((g|0)==46){g=0;if(n){g=51;break}else{b=m;continue}}else if((g|0)==50){g=0;_x(m+8|0,b,d);b=m;continue}}if((g|0)==4){if(!(tb[c[d>>2]&63](h,a)|0)){i=e;return}t=a;s=c[t>>2]|0;t=c[t+4>>2]|0;q=h;r=c[q+4>>2]|0;u=a;c[u>>2]=c[q>>2];c[u+4>>2]=r;u=h;c[u>>2]=s;c[u+4>>2]=t;i=e;return}else if((g|0)==6){$x(a,a+8|0,h,d)|0;i=e;return}else if((g|0)==7){ay(a,a+8|0,a+16|0,h,d)|0;i=e;return}else if((g|0)==8){by(a,a+8|0,a+16|0,a+24|0,h,d)|0;i=e;return}else if((g|0)==10){j=a+16|0;$x(a,a+8|0,j,d)|0;g=a+24|0;if((g|0)==(b|0)){i=e;return}while(1){if(tb[c[d>>2]&63](g,j)|0){t=g;u=c[t+4>>2]|0;h=f;c[h>>2]=c[t>>2];c[h+4>>2]=u;h=g;while(1){s=j;t=c[s+4>>2]|0;u=h;c[u>>2]=c[s>>2];c[u+4>>2]=t;if((j|0)==(a|0))break;h=j+ -8|0;if(tb[c[d>>2]&63](f,h)|0){u=j;j=h;h=u}else break}s=f;t=c[s+4>>2]|0;u=j;c[u>>2]=c[s>>2];c[u+4>>2]=t}h=g+8|0;if((h|0)==(b|0))break;else{j=g;g=h}}i=e;return}else if((g|0)==51){i=e;return}}function $x(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,j=0,k=0,l=0;f=i;j=tb[c[e>>2]&63](b,a)|0;g=tb[c[e>>2]&63](d,b)|0;if(!j){if(!g){j=0;i=f;return j|0}h=b;g=c[h>>2]|0;h=c[h+4>>2]|0;l=d;k=c[l+4>>2]|0;j=b;c[j>>2]=c[l>>2];c[j+4>>2]=k;j=d;c[j>>2]=g;c[j+4>>2]=h;if(!(tb[c[e>>2]&63](b,a)|0)){l=1;i=f;return l|0}k=a;j=c[k>>2]|0;k=c[k+4>>2]|0;e=b;h=c[e+4>>2]|0;l=a;c[l>>2]=c[e>>2];c[l+4>>2]=h;l=b;c[l>>2]=j;c[l+4>>2]=k;l=2;i=f;return l|0}h=a;j=c[h>>2]|0;h=c[h+4>>2]|0;if(g){e=d;k=c[e+4>>2]|0;l=a;c[l>>2]=c[e>>2];c[l+4>>2]=k;l=d;c[l>>2]=j;c[l+4>>2]=h;l=1;i=f;return l|0}g=b;k=c[g+4>>2]|0;l=a;c[l>>2]=c[g>>2];c[l+4>>2]=k;l=b;c[l>>2]=j;c[l+4>>2]=h;if(!(tb[c[e>>2]&63](d,b)|0)){l=1;i=f;return l|0}k=b;j=c[k>>2]|0;k=c[k+4>>2]|0;a=d;h=c[a+4>>2]|0;l=b;c[l>>2]=c[a>>2];c[l+4>>2]=h;l=d;c[l>>2]=j;c[l+4>>2]=k;l=2;i=f;return l|0}function ay(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,j=0,k=0,l=0,m=0,n=0;g=i;h=$x(a,b,d,f)|0;if(!(tb[c[f>>2]&63](e,d)|0)){e=h;i=g;return e|0}j=d;k=c[j>>2]|0;j=c[j+4>>2]|0;n=e;m=c[n+4>>2]|0;l=d;c[l>>2]=c[n>>2];c[l+4>>2]=m;c[e>>2]=k;c[e+4>>2]=j;if(!(tb[c[f>>2]&63](d,b)|0)){n=h+1|0;i=g;return n|0}m=b;l=c[m>>2]|0;m=c[m+4>>2]|0;j=d;k=c[j+4>>2]|0;n=b;c[n>>2]=c[j>>2];c[n+4>>2]=k;n=d;c[n>>2]=l;c[n+4>>2]=m;if(!(tb[c[f>>2]&63](b,a)|0)){n=h+2|0;i=g;return n|0}m=a;l=c[m>>2]|0;m=c[m+4>>2]|0;j=b;k=c[j+4>>2]|0;n=a;c[n>>2]=c[j>>2];c[n+4>>2]=k;n=b;c[n>>2]=l;c[n+4>>2]=m;n=h+3|0;i=g;return n|0}function by(a,b,d,e,f,g){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,j=0,k=0,l=0,m=0,n=0,o=0;h=i;j=ay(a,b,d,e,g)|0;if(!(tb[c[g>>2]&63](f,e)|0)){f=j;i=h;return f|0}k=e;l=c[k>>2]|0;k=c[k+4>>2]|0;o=f;n=c[o+4>>2]|0;m=e;c[m>>2]=c[o>>2];c[m+4>>2]=n;c[f>>2]=l;c[f+4>>2]=k;if(!(tb[c[g>>2]&63](e,d)|0)){o=j+1|0;i=h;return o|0}n=d;m=c[n>>2]|0;n=c[n+4>>2]|0;k=e;l=c[k+4>>2]|0;o=d;c[o>>2]=c[k>>2];c[o+4>>2]=l;o=e;c[o>>2]=m;c[o+4>>2]=n;if(!(tb[c[g>>2]&63](d,b)|0)){o=j+2|0;i=h;return o|0}n=b;m=c[n>>2]|0;n=c[n+4>>2]|0;k=d;l=c[k+4>>2]|0;o=b;c[o>>2]=c[k>>2];c[o+4>>2]=l;o=d;c[o>>2]=m;c[o+4>>2]=n;if(!(tb[c[g>>2]&63](b,a)|0)){o=j+3|0;i=h;return o|0}n=a;m=c[n>>2]|0;n=c[n+4>>2]|0;k=b;l=c[k+4>>2]|0;o=a;c[o>>2]=c[k>>2];c[o+4>>2]=l;o=b;c[o>>2]=m;c[o+4>>2]=n;o=j+4|0;i=h;return o|0}function cy(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0;e=i;i=i+16|0;g=e;switch(b-a>>3|0){case 2:{f=b+ -8|0;if(!(tb[c[d>>2]&63](f,a)|0)){l=1;i=e;return l|0}k=a;j=c[k>>2]|0;k=c[k+4>>2]|0;b=f;h=c[b+4>>2]|0;l=a;c[l>>2]=c[b>>2];c[l+4>>2]=h;l=f;c[l>>2]=j;c[l+4>>2]=k;l=1;i=e;return l|0};case 1:case 0:{l=1;i=e;return l|0};case 5:{by(a,a+8|0,a+16|0,a+24|0,b+ -8|0,d)|0;l=1;i=e;return l|0};case 3:{$x(a,a+8|0,b+ -8|0,d)|0;l=1;i=e;return l|0};case 4:{ay(a,a+8|0,a+16|0,b+ -8|0,d)|0;l=1;i=e;return l|0};default:{l=a+16|0;$x(a,a+8|0,l,d)|0;h=a+24|0;if((h|0)==(b|0)){l=1;i=e;return l|0}else j=0;while(1){if(tb[c[d>>2]&63](h,l)|0){n=h;m=c[n+4>>2]|0;k=g;c[k>>2]=c[n>>2];c[k+4>>2]=m;k=h;while(1){o=l;m=c[o+4>>2]|0;n=k;c[n>>2]=c[o>>2];c[n+4>>2]=m;if((l|0)==(a|0))break;k=l+ -8|0;if(tb[c[d>>2]&63](g,k)|0){o=l;l=k;k=o}else break}m=g;n=c[m+4>>2]|0;o=l;c[o>>2]=c[m>>2];c[o+4>>2]=n;j=j+1|0;if((j|0)==8)break}k=h+8|0;if((k|0)==(b|0)){a=1;f=15;break}else{l=h;h=k}}if((f|0)==15){i=e;return a|0}o=(h+8|0)==(b|0);i=e;return o|0}}return 0}function dy(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0;e=i;d=a+1028|0;f=c[d>>2]|0;g=a+1032|0;if((f|0)==(c[g>>2]|0)?(h=c[a>>2]|0,c[g>>2]=f<<1,g=NB(f<<3)|0,c[a>>2]=g,SB(g|0,h|0,c[d>>2]<<2|0)|0,(h|0)!=(a+4|0)):0)OB(h);c[(c[a>>2]|0)+(c[d>>2]<<2)>>2]=c[b>>2];c[d>>2]=(c[d>>2]|0)+1;i=e;return}function ey(a){a=a|0;var b=0,d=0;b=a+1028|0;d=c[b>>2]|0;if((d|0)>0){d=d+ -1|0;c[b>>2]=d;return c[(c[a>>2]|0)+(d<<2)>>2]|0}else Aa(9664,9680,67,9728);return 0}function fy(a){a=a|0;var b=0;b=i;OB(a);i=b;return}function gy(a,b){a=a|0;b=b|0;return}function hy(a,b){a=a|0;b=b|0;return}function iy(a){a=a|0;var b=0;b=i;OB(a);i=b;return}function jy(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;d=i;if(c[a+28>>2]|0)Aa(9768,9792,72,15288);e=a+12|0;f=c[e>>2]|0;f=nb[c[(c[f>>2]|0)+12>>2]&63](f)|0;a=a+24|0;Ix(b,c[a>>2]|0,f*28|0);c[a>>2]=0;a=c[e>>2]|0;f=c[a+4>>2]|0;if(!f){jb[c[c[a>>2]>>2]&127](a);Ix(b,a,20);c[e>>2]=0;i=d;return}else if((f|0)==2){jb[c[c[a>>2]>>2]&127](a);Ix(b,a,280);c[e>>2]=0;i=d;return}else if((f|0)==1){jb[c[c[a>>2]>>2]&127](a);Ix(b,a,48);c[e>>2]=0;i=d;return}else if((f|0)==3){jb[c[c[a>>2]>>2]&127](a);Ix(b,a,40);c[e>>2]=0;i=d;return}else Aa(15224,9792,115,15288)}function ky(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0.0,s=0.0;e=i;f=a+28|0;if(c[f>>2]|0)Aa(9768,9792,124,9840);h=a+12|0;m=c[h>>2]|0;m=nb[c[(c[m>>2]|0)+12>>2]&63](m)|0;c[f>>2]=m;if((m|0)<=0){i=e;return}j=a+24|0;k=b+4|0;l=b+28|0;m=0;do{n=c[j>>2]|0;p=n+(m*28|0)|0;o=c[h>>2]|0;vb[c[(c[o>>2]|0)+24>>2]&63](o,p,d,m);o=_w(b)|0;r=+(+g[p>>2]+-.10000000149011612);s=+(+g[n+(m*28|0)+4>>2]+-.10000000149011612);q=(c[k>>2]|0)+(o*36|0)|0;g[q>>2]=r;g[q+4>>2]=s;s=+(+g[n+(m*28|0)+8>>2]+.10000000149011612);r=+(+g[n+(m*28|0)+12>>2]+.10000000149011612);q=(c[k>>2]|0)+(o*36|0)+8|0;g[q>>2]=s;g[q+4>>2]=r;c[(c[k>>2]|0)+(o*36|0)+16>>2]=p;c[(c[k>>2]|0)+(o*36|0)+32>>2]=0;ax(b,o);c[l>>2]=(c[l>>2]|0)+1;Sw(b,o);c[n+(m*28|0)+24>>2]=o;c[n+(m*28|0)+16>>2]=a;c[n+(m*28|0)+20>>2]=m;m=m+1|0}while((m|0)<(c[f>>2]|0));i=e;return}function ly(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;e=i;d=a+28|0;if((c[d>>2]|0)<=0){c[d>>2]=0;i=e;return}a=a+24|0;h=b+40|0;j=b+32|0;g=b+28|0;f=b+12|0;l=b+4|0;k=0;while(1){n=(c[a>>2]|0)+(k*28|0)+24|0;m=c[n>>2]|0;q=c[h>>2]|0;if((q|0)>0){o=c[j>>2]|0;p=0;do{r=o+(p<<2)|0;if((c[r>>2]|0)==(m|0)){c[r>>2]=-1;q=c[h>>2]|0}p=p+1|0}while((p|0)<(q|0))}c[g>>2]=(c[g>>2]|0)+ -1;if((m|0)<=-1){b=10;break}if((c[f>>2]|0)<=(m|0)){b=10;break}if((c[(c[l>>2]|0)+(m*36|0)+24>>2]|0)!=-1){b=12;break}bx(b,m);$w(b,m);c[n>>2]=-1;k=k+1|0;if((k|0)>=(c[d>>2]|0)){b=14;break}}if((b|0)==10)Aa(11792,5624,123,5760);else if((b|0)==12)Aa(5776,5624,124,5760);else if((b|0)==14){c[d>>2]=0;i=e;return}}function my(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0,E=0,F=0,G=0.0,H=0.0,I=0;f=i;i=i+32|0;j=f+16|0;k=f;h=a+28|0;if((c[h>>2]|0)<=0){i=f;return}l=a+24|0;o=a+12|0;p=j+4|0;q=k+4|0;r=j+8|0;s=k+8|0;t=j+12|0;u=k+12|0;v=e+4|0;w=d+4|0;m=b+12|0;a=b+4|0;n=0;while(1){F=c[l>>2]|0;D=c[o>>2]|0;E=F+(n*28|0)+20|0;vb[c[(c[D>>2]|0)+24>>2]&63](D,j,d,c[E>>2]|0);D=c[o>>2]|0;vb[c[(c[D>>2]|0)+24>>2]&63](D,k,e,c[E>>2]|0);E=F+(n*28|0)|0;z=+g[j>>2];B=+g[k>>2];B=z>2];H=+g[q>>2];A=+B;H=+(z>2]=A;g[D+4>>2]=H;D=F+(n*28|0)+8|0;H=+g[r>>2];A=+g[s>>2];A=H>A?H:A;H=+g[t>>2];z=+g[u>>2];y=+A;z=+(H>z?H:z);x=D;g[x>>2]=y;g[x+4>>2]=z;z=+g[e>>2]- +g[d>>2];y=+g[v>>2]- +g[w>>2];x=c[F+(n*28|0)+24>>2]|0;if((x|0)<=-1){b=5;break}if((c[m>>2]|0)<=(x|0)){b=5;break}I=c[a>>2]|0;if((c[I+(x*36|0)+24>>2]|0)!=-1){b=7;break}if(!(((+g[I+(x*36|0)>>2]<=B?+g[I+(x*36|0)+4>>2]<=+g[F+(n*28|0)+4>>2]:0)?A<=+g[I+(x*36|0)+8>>2]:0)?+g[F+(n*28|0)+12>>2]<=+g[I+(x*36|0)+12>>2]:0)){bx(b,x);I=E;H=+g[I>>2];B=+g[I+4>>2];I=D;C=+g[I>>2];H=H+-.10000000149011612;B=B+-.10000000149011612;C=C+.10000000149011612;A=+g[I+4>>2]+.10000000149011612;G=z*2.0;z=y*2.0;if(G<0.0)y=H+G;else{y=H;C=G+C}if(z<0.0)B=B+z;else A=z+A;I=c[a>>2]|0;H=+y;G=+B;F=I+(x*36|0)|0;g[F>>2]=H;g[F+4>>2]=G;G=+C;H=+A;I=I+(x*36|0)+8|0;g[I>>2]=G;g[I+4>>2]=H;ax(b,x);Sw(b,x)}n=n+1|0;if((n|0)>=(c[h>>2]|0)){b=20;break}}if((b|0)==5)Aa(11792,5624,132,5808);else if((b|0)==7)Aa(5776,5624,134,5808);else if((b|0)==20){i=f;return}}function ny(a,f){a=a|0;f=f|0;var j=0,l=0,m=0,n=0,o=0,p=0,q=0.0,r=0.0;j=i;i=i+32|0;l=j;Nx(9856,l);h[k>>3]=+g[a+16>>2];c[l>>2]=c[k>>2];c[l+4>>2]=c[k+4>>2];Nx(9880,l);h[k>>3]=+g[a+20>>2];c[l>>2]=c[k>>2];c[l+4>>2]=c[k+4>>2];Nx(9912,l);h[k>>3]=+g[a>>2];c[l>>2]=c[k>>2];c[l+4>>2]=c[k+4>>2];Nx(9944,l);c[l>>2]=d[a+38>>0];Nx(9976,l);c[l>>2]=e[a+32>>1];Nx(10008,l);c[l>>2]=e[a+34>>1];Nx(10056,l);c[l>>2]=b[a+36>>1];Nx(10096,l);a=c[a+12>>2]|0;m=c[a+4>>2]|0;if((m|0)==3){Nx(10656,l);m=a+16|0;c[l>>2]=c[m>>2];Nx(10568,l);o=c[m>>2]|0;if((o|0)>0){p=a+12|0;n=0;do{o=c[p>>2]|0;r=+g[o+(n<<3)>>2];q=+g[o+(n<<3)+4>>2];c[l>>2]=n;o=l+4|0;h[k>>3]=r;c[o>>2]=c[k>>2];c[o+4>>2]=c[k+4>>2];o=l+12|0;h[k>>3]=q;c[o>>2]=c[k>>2];c[o+4>>2]=c[k+4>>2];Nx(10592,l);n=n+1|0;o=c[m>>2]|0}while((n|0)<(o|0))}c[l>>2]=o;Nx(10688,l);p=a+20|0;r=+g[p+4>>2];h[k>>3]=+g[p>>2];c[l>>2]=c[k>>2];c[l+4>>2]=c[k+4>>2];p=l+8|0;h[k>>3]=r;c[p>>2]=c[k>>2];c[p+4>>2]=c[k+4>>2];Nx(10720,l);p=a+28|0;r=+g[p+4>>2];h[k>>3]=+g[p>>2];c[l>>2]=c[k>>2];c[l+4>>2]=c[k+4>>2];p=l+8|0;h[k>>3]=r;c[p>>2]=c[k>>2];c[p+4>>2]=c[k+4>>2];Nx(10768,l);c[l>>2]=d[a+36>>0];Nx(10816,l);c[l>>2]=d[a+37>>0];Nx(10856,l)}else if(!m){Nx(10136,l);h[k>>3]=+g[a+8>>2];c[l>>2]=c[k>>2];c[l+4>>2]=c[k+4>>2];Nx(10168,l);r=+g[a+16>>2];h[k>>3]=+g[a+12>>2];c[l>>2]=c[k>>2];c[l+4>>2]=c[k+4>>2];p=l+8|0;h[k>>3]=r;c[p>>2]=c[k>>2];c[p+4>>2]=c[k+4>>2];Nx(10200,l)}else if((m|0)==2){Nx(10536,l);c[l>>2]=16;Nx(10568,l);m=a+276|0;o=c[m>>2]|0;if((o|0)>0){a=a+20|0;n=0;do{q=+g[a+(n<<3)>>2];r=+g[a+(n<<3)+4>>2];c[l>>2]=n;o=l+4|0;h[k>>3]=q;c[o>>2]=c[k>>2];c[o+4>>2]=c[k+4>>2];o=l+12|0;h[k>>3]=r;c[o>>2]=c[k>>2];c[o+4>>2]=c[k+4>>2];Nx(10592,l);n=n+1|0;o=c[m>>2]|0}while((n|0)<(o|0))}c[l>>2]=o;Nx(10632,l)}else if((m|0)==1){Nx(10240,l);h[k>>3]=+g[a+8>>2];c[l>>2]=c[k>>2];c[l+4>>2]=c[k+4>>2];Nx(10168,l);p=a+28|0;r=+g[p+4>>2];h[k>>3]=+g[p>>2];c[l>>2]=c[k>>2];c[l+4>>2]=c[k+4>>2];p=l+8|0;h[k>>3]=r;c[p>>2]=c[k>>2];c[p+4>>2]=c[k+4>>2];Nx(10264,l);r=+g[a+16>>2];h[k>>3]=+g[a+12>>2];c[l>>2]=c[k>>2];c[l+4>>2]=c[k+4>>2];p=l+8|0;h[k>>3]=r;c[p>>2]=c[k>>2];c[p+4>>2]=c[k+4>>2];Nx(10312,l);p=a+20|0;r=+g[p+4>>2];h[k>>3]=+g[p>>2];c[l>>2]=c[k>>2];c[l+4>>2]=c[k+4>>2];p=l+8|0;h[k>>3]=r;c[p>>2]=c[k>>2];c[p+4>>2]=c[k+4>>2];Nx(10360,l);r=+g[a+40>>2];h[k>>3]=+g[a+36>>2];c[l>>2]=c[k>>2];c[l+4>>2]=c[k+4>>2];p=l+8|0;h[k>>3]=r;c[p>>2]=c[k>>2];c[p+4>>2]=c[k+4>>2];Nx(10408,l);c[l>>2]=d[a+44>>0];Nx(10456,l);c[l>>2]=d[a+45>>0];Nx(10496,l)}else{i=j;return}Nx(10896,l);Nx(10904,l);Nx(10896,l);c[l>>2]=f;Nx(10928,l);i=j;return}function oy(a,b,d,e,f,g){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,j=0;h=i;j=a+40|0;c[j>>2]=b;c[a+44>>2]=d;c[a+48>>2]=e;c[a+28>>2]=0;c[a+36>>2]=0;c[a+32>>2]=0;c[a>>2]=f;c[a+4>>2]=g;c[a+8>>2]=Ox(f,b<<2)|0;c[a+12>>2]=Ox(c[a>>2]|0,d<<2)|0;c[a+16>>2]=Ox(c[a>>2]|0,e<<2)|0;c[a+24>>2]=Ox(c[a>>2]|0,(c[j>>2]|0)*12|0)|0;c[a+20>>2]=Ox(c[a>>2]|0,(c[j>>2]|0)*12|0)|0;i=h;return}function py(a){a=a|0;var b=0;b=i;Px(c[a>>2]|0,c[a+20>>2]|0);Px(c[a>>2]|0,c[a+24>>2]|0);Px(c[a>>2]|0,c[a+16>>2]|0);Px(c[a>>2]|0,c[a+12>>2]|0);Px(c[a>>2]|0,c[a+8>>2]|0);i=b;return}function qy(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,h=0,j=0,k=0,l=0,m=0,n=0;h=i;i=i+32|0;e=h;d=a+4|0;if(!(c[d>>2]|0)){i=h;return}f=a+36|0;if((c[f>>2]|0)<=0){i=h;return}n=a+12|0;k=e+16|0;l=0;do{m=c[(c[n>>2]|0)+(l<<2)>>2]|0;j=c[b+(l*156|0)+148>>2]|0;c[k>>2]=j;if((j|0)>0){a=0;do{g[e+(a<<2)>>2]=+g[b+(l*156|0)+(a*36|0)+16>>2];g[e+(a<<2)+8>>2]=+g[b+(l*156|0)+(a*36|0)+20>>2];a=a+1|0}while((a|0)<(j|0))}j=c[d>>2]|0;pb[c[(c[j>>2]|0)+20>>2]&63](j,m,e);l=l+1|0}while((l|0)<(c[f>>2]|0));i=h;return}function ry(d,f){d=d|0;f=f|0;var h=0,j=0,k=0,l=0,m=0,n=0,o=0;h=i;if(c[d+102868>>2]&2)Aa(11064,11088,274,11192);j=a[f+61>>0]|0;l=f+8|0;m=c[l>>2]|0;k=f+12|0;if(m)c[m+12>>2]=c[k>>2];m=c[k>>2]|0;if(m)c[m+8>>2]=c[l>>2];l=d+102956|0;if((c[l>>2]|0)==(f|0))c[l>>2]=c[k>>2];k=c[f+48>>2]|0;l=c[f+52>>2]|0;n=k+4|0;m=e[n>>1]|0;if(!(m&2)){b[n>>1]=m|2;g[k+144>>2]=0.0}m=l+4|0;n=e[m>>1]|0;if(!(n&2)){b[m>>1]=n|2;g[l+144>>2]=0.0}n=f+24|0;o=c[n>>2]|0;m=f+28|0;if(o)c[o+12>>2]=c[m>>2];o=c[m>>2]|0;if(o)c[o+8>>2]=c[n>>2];o=k+108|0;if((f+16|0)==(c[o>>2]|0))c[o>>2]=c[m>>2];c[n>>2]=0;c[m>>2]=0;n=f+40|0;o=c[n>>2]|0;m=f+44|0;if(o)c[o+12>>2]=c[m>>2];o=c[m>>2]|0;if(o)c[o+8>>2]=c[n>>2];o=l+108|0;if((f+32|0)==(c[o>>2]|0))c[o>>2]=c[m>>2];c[n>>2]=0;c[m>>2]=0;jb[c[(c[f>>2]|0)+24>>2]&127](f);do switch(c[f+4>>2]|0){case 6:{Ix(d,f,276);break};case 11:{Ix(d,f,192);break};case 3:{Ix(d,f,176);break};case 5:{Ix(d,f,168);break};case 8:{Ix(d,f,208);break};case 10:{Ix(d,f,168);break};case 7:{Ix(d,f,224);break};case 4:{Ix(d,f,196);break};case 9:{Ix(d,f,180);break};case 1:{Ix(d,f,228);break};case 2:{Ix(d,f,256);break};default:Aa(15224,15232,178,15288)}while(0);f=d+102964|0;d=c[f>>2]|0;if((d|0)<=0)Aa(11208,11088,346,11192);c[f>>2]=d+ -1;if(j<<24>>24){i=h;return}j=c[l+112>>2]|0;if(!j){i=h;return}do{if((c[j>>2]|0)==(k|0)){o=(c[j+4>>2]|0)+4|0;c[o>>2]=c[o>>2]|8}j=c[j+12>>2]|0}while((j|0)!=0);i=h;return}function sy(a,b){a=a|0;b=b|0;var d=0,e=0;d=a+28|0;e=c[d>>2]|0;if((e|0)<(c[a+40>>2]|0)){c[b+8>>2]=e;e=c[d>>2]|0;c[(c[a+8>>2]|0)+(e<<2)>>2]=b;c[d>>2]=e+1;return}else Aa(12040,11952,54,11992)}function ty(a,b){a=a|0;b=b|0;var d=0,e=0;e=a+36|0;d=c[e>>2]|0;if((d|0)<(c[a+44>>2]|0)){c[e>>2]=d+1;c[(c[a+12>>2]|0)+(d<<2)>>2]=b;return}else Aa(12e3,11952,62,11992)} function vA(b,d){b=b|0;d=d|0;var e=0.0,f=0.0,h=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0,o=0,p=0,q=0,r=0.0,s=0.0,t=0.0,u=0,v=0,w=0,x=0,y=0,z=0.0,A=0.0,B=0.0,C=0.0,D=0,E=0.0,F=0.0,G=0.0,H=0,I=0.0,J=0,K=0.0,L=0;q=i;i=i+48|0;L=q+36|0;J=q+24|0;y=q+16|0;x=q+8|0;u=q;n=b+128|0;p=c[n>>2]|0;o=d+28|0;D=c[o>>2]|0;v=D+(p*12|0)|0;j=+g[v>>2];k=+g[v+4>>2];s=+g[D+(p*12|0)+8>>2];p=b+132|0;v=c[p>>2]|0;w=D+(v*12|0)|0;m=+g[w>>2];h=+g[w+4>>2];t=+g[D+(v*12|0)+8>>2];e=+g[b+168>>2];r=+g[b+172>>2];l=+g[b+176>>2];f=+g[b+180>>2];v=l+f==0.0;if((a[b+100>>0]|0)!=0?!((c[b+224>>2]|0)==3|v):0){D=b+96|0;K=+g[D>>2];I=+g[d>>2]*+g[b+104>>2];F=K- +g[b+220>>2]*(t-s- +g[b+108>>2]);G=-I;I=F>2]=I;K=I-K;s=s-l*K;t=t+f*K}if((a[b+112>>0]|0)!=0?(H=b+224|0,!((c[H>>2]|0)==0|v)):0){w=b+148|0;d=b+144|0;v=b+140|0;u=b+136|0;z=m-t*+g[w>>2]-j+s*+g[v>>2];C=h+t*+g[d>>2]-k-s*+g[u>>2];g[L>>2]=z;g[L+4>>2]=C;g[L+8>>2]=t-s;D=b+184|0;Jx(J,D,L);F=+g[J>>2];A=-F;G=+g[J+4>>2];E=-G;I=+g[J+8>>2];B=-I;H=c[H>>2]|0;do if((H|0)==1){x=b+84|0;H=b+92|0;K=+g[H>>2];I=K-I;if(I<0.0){Kx(y,D,K*+g[b+208>>2]-z,K*+g[b+212>>2]-C);A=+g[y>>2];E=+g[y+4>>2];B=-+g[H>>2];g[x>>2]=A+ +g[x>>2];L=b+88|0;g[L>>2]=E+ +g[L>>2];g[H>>2]=0.0;break}else{g[x>>2]=+g[x>>2]-F;L=b+88|0;g[L>>2]=+g[L>>2]-G;g[H>>2]=I;break}}else if((H|0)==3){L=b+84|0;g[L>>2]=+g[L>>2]-F;L=b+88|0;g[L>>2]=+g[L>>2]-G;L=b+92|0;g[L>>2]=+g[L>>2]-I}else if((H|0)==2){H=b+84|0;y=b+92|0;K=+g[y>>2];I=K-I;if(I>0.0){Kx(x,D,K*+g[b+208>>2]-z,K*+g[b+212>>2]-C);A=+g[x>>2];E=+g[x+4>>2];B=-+g[y>>2];g[H>>2]=A+ +g[H>>2];L=b+88|0;g[L>>2]=E+ +g[L>>2];g[y>>2]=0.0;break}else{g[H>>2]=+g[H>>2]-F;L=b+88|0;g[L>>2]=+g[L>>2]-G;g[y>>2]=I;break}}while(0);K=B+(E*+g[d>>2]-A*+g[w>>2]);F=B+(E*+g[u>>2]-A*+g[v>>2]);C=A;G=r*C;I=r*E;C=e*C;E=e*E;G=m+G;I=h+I;C=j-C;E=k-E;F=l*F;K=f*K;F=s-F;K=t+K;L=c[n>>2]|0;J=c[o>>2]|0;L=J+(L*12|0)|0;C=+C;E=+E;J=L;g[J>>2]=C;L=L+4|0;g[L>>2]=E;L=c[n>>2]|0;J=c[o>>2]|0;L=J+(L*12|0)+8|0;g[L>>2]=F;L=c[p>>2]|0;L=J+(L*12|0)|0;G=+G;I=+I;J=L;g[J>>2]=G;L=L+4|0;g[L>>2]=I;L=c[p>>2]|0;J=c[o>>2]|0;L=J+(L*12|0)+8|0;g[L>>2]=K;i=q;return}H=b+148|0;D=b+144|0;L=b+140|0;J=b+136|0;Kx(u,b+184|0,-(m-t*+g[H>>2]-j+s*+g[L>>2]),-(h+t*+g[D>>2]-k-s*+g[J>>2]));C=+g[u>>2];y=b+84|0;g[y>>2]=C+ +g[y>>2];E=+g[u+4>>2];y=b+88|0;g[y>>2]=E+ +g[y>>2];K=E*+g[D>>2]-C*+g[H>>2];F=E*+g[J>>2]-C*+g[L>>2];G=r*C;I=r*E;C=e*C;E=e*E;G=m+G;I=h+I;C=j-C;E=k-E;F=l*F;K=f*K;F=s-F;K=t+K;L=c[n>>2]|0;J=c[o>>2]|0;L=J+(L*12|0)|0;C=+C;E=+E;J=L;g[J>>2]=C;L=L+4|0;g[L>>2]=E;L=c[n>>2]|0;J=c[o>>2]|0;L=J+(L*12|0)+8|0;g[L>>2]=F;L=c[p>>2]|0;L=J+(L*12|0)|0;G=+G;I=+I;J=L;g[J>>2]=G;L=L+4|0;g[L>>2]=I;L=c[p>>2]|0;J=c[o>>2]|0;L=J+(L*12|0)+8|0;g[L>>2]=K;i=q;return}function wA(b,d){b=b|0;d=d|0;var e=0,f=0,h=0.0,j=0.0,k=0,l=0.0,m=0.0,n=0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0,H=0,I=0,J=0.0;f=i;e=b+128|0;n=c[e>>2]|0;k=d+24|0;G=c[k>>2]|0;d=G+(n*12|0)|0;H=d;l=+g[H>>2];j=+g[H+4>>2];q=+g[G+(n*12|0)+8>>2];n=b+132|0;H=c[n>>2]|0;I=G+(H*12|0)|0;h=+g[I>>2];m=+g[I+4>>2];r=+g[G+(H*12|0)+8>>2];H=b+176|0;G=b+180|0;if(a[b+112>>0]|0){s=+g[G>>2];t=+g[H>>2];G=c[b+224>>2]|0;if((G|0)==0|s+t==0.0){o=t;p=s;u=0.0}else{o=r-q- +g[b+116>>2];if((G|0)==2){u=o- +g[b+124>>2];v=u+-.03490658849477768;v=v<.13962635397911072?v:.13962635397911072;v=-(+g[b+220>>2]*(v<0.0?0.0:v))}else if((G|0)==3){u=o- +g[b+120>>2];u=u<.13962635397911072?u:.13962635397911072;u=u<-.13962635397911072?-.13962635397911072:u;v=-(+g[b+220>>2]*u);if(!(u>0.0))u=-u}else if((G|0)==1){u=o- +g[b+120>>2];v=u+.03490658849477768;v=v<0.0?v:0.0;u=-u;v=-(+g[b+220>>2]*(v<-.13962635397911072?-.13962635397911072:v))}else{u=0.0;v=0.0}o=t;p=s;q=q-v*t;r=r+v*s}}else{o=+g[H>>2];p=+g[G>>2];u=0.0}w=+R(+q);x=+Q(+q);y=+R(+r);z=+Q(+r);v=+g[b+68>>2]- +g[b+152>>2];s=+g[b+72>>2]- +g[b+156>>2];A=x*v-w*s;s=w*v+x*s;x=+g[b+76>>2]- +g[b+160>>2];v=+g[b+80>>2]- +g[b+164>>2];w=z*x-y*v;v=y*x+z*v;z=h+w-l-A;x=m+v-j-s;y=+O(+(z*z+x*x));t=+g[b+168>>2];C=+g[b+172>>2];J=t+C;E=J+s*s*o+v*v*p;F=A*o;B=w*p;D=-(s*F)-v*B;B=J+A*F+w*B;F=E*B-D*D;if(F!=0.0)F=1.0/F;J=-((z*B-x*D)*F);F=-((x*E-z*D)*F);E=+(l-t*J);D=+(j-t*F);I=d;g[I>>2]=E;g[I+4>>2]=D;I=c[k>>2]|0;g[I+((c[e>>2]|0)*12|0)+8>>2]=q-o*(A*F-s*J);D=+(h+C*J);E=+(m+C*F);I=I+((c[n>>2]|0)*12|0)|0;g[I>>2]=D;g[I+4>>2]=E;g[(c[k>>2]|0)+((c[n>>2]|0)*12|0)+8>>2]=r+p*(w*F-v*J);if(!(y<=.004999999888241291)){I=0;i=f;return I|0}I=u<=.03490658849477768;i=f;return I|0}function xA(a,b){a=a|0;b=b|0;var d=0.0,e=0.0,f=0.0,h=0.0,i=0.0,j=0;j=c[b+48>>2]|0;i=+g[j+24>>2];h=+g[b+68>>2];f=+g[j+20>>2];e=+g[b+72>>2];d=h*f+i*e+ +g[j+16>>2];g[a>>2]=+g[j+12>>2]+(i*h-f*e);g[a+4>>2]=d;return}function yA(a,b){a=a|0;b=b|0;var d=0.0,e=0.0,f=0.0,h=0.0,i=0.0,j=0;j=c[b+52>>2]|0;i=+g[j+24>>2];h=+g[b+76>>2];f=+g[j+20>>2];e=+g[b+80>>2];d=h*f+i*e+ +g[j+16>>2];g[a>>2]=+g[j+12>>2]+(i*h-f*e);g[a+4>>2]=d;return}function zA(a,b,c){a=a|0;b=b|0;c=+c;var d=0.0;d=+g[b+88>>2]*c;g[a>>2]=+g[b+84>>2]*c;g[a+4>>2]=d;return}function AA(a,b){a=a|0;b=+b;return+(+g[a+92>>2]*b)}function BA(a){a=a|0;var b=0,e=0,f=0,j=0.0,l=0;b=i;i=i+16|0;e=b;l=c[(c[a+48>>2]|0)+8>>2]|0;f=c[(c[a+52>>2]|0)+8>>2]|0;Nx(16784,e);c[e>>2]=l;Nx(17320,e);c[e>>2]=f;Nx(17352,e);c[e>>2]=d[a+61>>0];Nx(17384,e);j=+g[a+72>>2];h[k>>3]=+g[a+68>>2];c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];f=e+8|0;h[k>>3]=j;c[f>>2]=c[k>>2];c[f+4>>2]=c[k+4>>2];Nx(17424,e);j=+g[a+80>>2];h[k>>3]=+g[a+76>>2];c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];f=e+8|0;h[k>>3]=j;c[f>>2]=c[k>>2];c[f+4>>2]=c[k+4>>2];Nx(17472,e);h[k>>3]=+g[a+116>>2];c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];Nx(17176,e);c[e>>2]=d[a+112>>0];Nx(16816,e);h[k>>3]=+g[a+120>>2];c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];Nx(16848,e);h[k>>3]=+g[a+124>>2];c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];Nx(16880,e);c[e>>2]=d[a+100>>0];Nx(17560,e);h[k>>3]=+g[a+108>>2];c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];Nx(17592,e);h[k>>3]=+g[a+104>>2];c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];Nx(17624,e);c[e>>2]=c[a+56>>2];Nx(17720,e);i=b;return}function CA(a){a=a|0;return}function DA(a){a=a|0;var b=0;b=i;OB(a);i=b;return}function EA(b,d){b=b|0;d=d|0;var e=0,f=0,h=0,j=0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0,x=0.0,y=0,z=0.0,A=0.0,B=0,C=0.0,D=0.0,E=0,F=0,G=0,H=0.0,I=0,J=0,K=0,L=0,M=0,N=0,P=0.0;e=i;w=c[b+48>>2]|0;M=c[w+8>>2]|0;f=b+96|0;c[f>>2]=M;L=c[b+52>>2]|0;J=c[L+8>>2]|0;h=b+100|0;c[h>>2]=J;E=w+28|0;I=c[E>>2]|0;E=c[E+4>>2]|0;y=b+128|0;c[y>>2]=I;c[y+4>>2]=E;y=L+28|0;G=c[y>>2]|0;y=c[y+4>>2]|0;F=b+136|0;c[F>>2]=G;c[F+4>>2]=y;F=b+144|0;g[F>>2]=+g[w+120>>2];y=b+148|0;g[y>>2]=+g[L+120>>2];B=b+152|0;g[B>>2]=+g[w+128>>2];w=b+156|0;g[w>>2]=+g[L+128>>2];L=c[d+24>>2]|0;j=L+(M*12|0)|0;v=+g[j>>2];x=+g[j+4>>2];l=+g[L+(M*12|0)+8>>2];j=d+28|0;K=c[j>>2]|0;N=K+(M*12|0)|0;u=+g[N>>2];t=+g[N+4>>2];o=+g[K+(M*12|0)+8>>2];M=L+(J*12|0)|0;z=+g[M>>2];H=+g[M+4>>2];C=+g[L+(J*12|0)+8>>2];L=K+(J*12|0)|0;s=+g[L>>2];r=+g[L+4>>2];m=+g[K+(J*12|0)+8>>2];n=+R(+l);l=+Q(+l);A=+R(+C);C=+Q(+C);D=+g[b+68>>2]-(c[k>>2]=I,+g[k>>2]);q=+g[b+72>>2]-(c[k>>2]=E,+g[k>>2]);p=l*D-n*q;q=n*D+l*q;l=+p;D=+q;E=b+112|0;g[E>>2]=l;g[E+4>>2]=D;D=+g[b+76>>2]-(c[k>>2]=G,+g[k>>2]);l=+g[b+80>>2]- +g[b+140>>2];n=C*D-A*l;l=A*D+C*l;C=+n;D=+l;G=b+120|0;g[G>>2]=C;g[G+4>>2]=D;G=b+104|0;v=z+n-v-p;x=H+l-x-q;H=+v;z=+x;E=G;g[E>>2]=H;g[E+4>>2]=z;E=b+108|0;z=+O(+(v*v+x*x));g[b+88>>2]=z;c[b+164>>2]=z- +g[b+84>>2]>0.0?2:0;if(!(z>.004999999888241291)){g[G>>2]=0.0;g[E>>2]=0.0;g[b+160>>2]=0.0;g[b+92>>2]=0.0;i=e;return}A=1.0/z;v=A*v;g[G>>2]=v;A=A*x;g[E>>2]=A;P=p*A-q*v;H=A*n-v*l;C=+g[F>>2];x=+g[B>>2];D=+g[y>>2];z=+g[w>>2];H=D+(C+P*P*x)+H*H*z;if(H!=0.0)H=1.0/H;else H=0.0;g[b+160>>2]=H;if(!(a[d+20>>0]|0))g[b+92>>2]=0.0;else{N=b+92|0;H=+g[d+8>>2]*+g[N>>2];g[N>>2]=H;P=v*H;H=H*A;u=u-P*C;t=t-H*C;s=s+P*D;r=r+H*D;o=o-x*(H*p-P*q);m=m+z*(H*n-P*l)}P=+u;H=+t;N=(c[j>>2]|0)+((c[f>>2]|0)*12|0)|0;g[N>>2]=P;g[N+4>>2]=H;N=c[j>>2]|0;g[N+((c[f>>2]|0)*12|0)+8>>2]=o;H=+s;P=+r;N=N+((c[h>>2]|0)*12|0)|0;g[N>>2]=H;g[N+4>>2]=P;g[(c[j>>2]|0)+((c[h>>2]|0)*12|0)+8>>2]=m;i=e;return}function FA(a,b){a=a|0;b=b|0;var d=0.0,e=0,f=0,h=0.0,j=0.0,k=0,l=0,m=0.0,n=0.0,o=0.0,p=0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0,z=0,A=0,B=0.0;p=i;k=a+96|0;e=c[k>>2]|0;f=b+28|0;z=c[f>>2]|0;l=z+(e*12|0)|0;y=l;n=+g[y>>2];m=+g[y+4>>2];t=+g[z+(e*12|0)+8>>2];e=a+100|0;y=c[e>>2]|0;A=z+(y*12|0)|0;j=+g[A>>2];h=+g[A+4>>2];q=+g[z+(y*12|0)+8>>2];r=+g[a+116>>2];s=+g[a+112>>2];o=+g[a+124>>2];d=+g[a+120>>2];w=+g[a+88>>2]- +g[a+84>>2];v=+g[a+104>>2];u=+g[a+108>>2];x=(j-q*o-(n-t*r))*v+(h+q*d-(m+t*s))*u;if(w<0.0)x=x+w*+g[b+4>>2];A=a+92|0;B=+g[A>>2];w=B-x*+g[a+160>>2];w=w>0.0?0.0:w;g[A>>2]=w;B=w-B;v=v*B;u=u*B;B=+g[a+144>>2];t=t- +g[a+152>>2]*(s*u-v*r);w=+g[a+148>>2];x=q+ +g[a+156>>2]*(u*d-v*o);r=+(n-B*v);s=+(m-B*u);A=l;g[A>>2]=r;g[A+4>>2]=s;A=c[f>>2]|0;g[A+((c[k>>2]|0)*12|0)+8>>2]=t;v=+(j+v*w);w=+(h+u*w);A=A+((c[e>>2]|0)*12|0)|0;g[A>>2]=v;g[A+4>>2]=w;g[(c[f>>2]|0)+((c[e>>2]|0)*12|0)+8>>2]=x;i=p;return}function GA(a,b){a=a|0;b=b|0;var d=0,e=0,f=0.0,h=0.0,j=0.0,k=0,l=0.0,m=0.0,n=0.0,o=0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0,x=0,y=0,z=0.0,A=0.0,B=0.0;e=i;d=a+96|0;o=c[d>>2]|0;b=b+24|0;x=c[b>>2]|0;k=x+(o*12|0)|0;w=k;m=+g[w>>2];l=+g[w+4>>2];s=+g[x+(o*12|0)+8>>2];o=a+100|0;w=c[o>>2]|0;y=x+(w*12|0)|0;h=+g[y>>2];f=+g[y+4>>2];p=+g[x+(w*12|0)+8>>2];j=+R(+s);t=+Q(+s);u=+R(+p);v=+Q(+p);n=+g[a+68>>2]- +g[a+128>>2];q=+g[a+72>>2]- +g[a+132>>2];r=t*n-j*q;q=j*n+t*q;t=+g[a+76>>2]- +g[a+136>>2];n=+g[a+80>>2]- +g[a+140>>2];j=v*t-u*n;n=u*t+v*n;v=h+j-m-r;t=f+n-l-q;u=+O(+(v*v+t*t));if(u<1.1920928955078125e-7)u=0.0;else{z=1.0/u;v=v*z;t=t*z}y=a+84|0;B=u- +g[y>>2];B=B<.20000000298023224?B:.20000000298023224;B=-(+g[a+160>>2]*(B<0.0?0.0:B));A=v*B;v=t*B;B=+g[a+144>>2];t=s- +g[a+152>>2]*(r*v-q*A);s=+g[a+148>>2];z=p+ +g[a+156>>2]*(j*v-n*A);q=+(m-B*A);r=+(l-B*v);x=k;g[x>>2]=q;g[x+4>>2]=r;x=c[b>>2]|0;g[x+((c[d>>2]|0)*12|0)+8>>2]=t;t=+(h+s*A);v=+(f+s*v);x=x+((c[o>>2]|0)*12|0)|0;g[x>>2]=t;g[x+4>>2]=v;g[(c[b>>2]|0)+((c[o>>2]|0)*12|0)+8>>2]=z;i=e;return u- +g[y>>2]<.004999999888241291|0}function HA(a,b){a=a|0;b=b|0;var d=0.0,e=0.0,f=0.0,h=0.0,i=0.0,j=0;j=c[b+48>>2]|0;i=+g[j+24>>2];h=+g[b+68>>2];f=+g[j+20>>2];e=+g[b+72>>2];d=h*f+i*e+ +g[j+16>>2];g[a>>2]=+g[j+12>>2]+(i*h-f*e);g[a+4>>2]=d;return}function IA(a,b){a=a|0;b=b|0;var d=0.0,e=0.0,f=0.0,h=0.0,i=0.0,j=0;j=c[b+52>>2]|0;i=+g[j+24>>2];h=+g[b+76>>2];f=+g[j+20>>2];e=+g[b+80>>2];d=h*f+i*e+ +g[j+16>>2];g[a>>2]=+g[j+12>>2]+(i*h-f*e);g[a+4>>2]=d;return}function JA(a,b,c){a=a|0;b=b|0;c=+c;var d=0.0;d=+g[b+92>>2]*c;c=d*+g[b+108>>2];g[a>>2]=+g[b+104>>2]*d;g[a+4>>2]=c;return}function KA(a,b){a=a|0;b=+b;return 0.0}function LA(a){a=a|0;var b=0,e=0,f=0,j=0.0,l=0;b=i;i=i+16|0;e=b;l=c[(c[a+48>>2]|0)+8>>2]|0;f=c[(c[a+52>>2]|0)+8>>2]|0;Nx(17008,e);c[e>>2]=l;Nx(17320,e);c[e>>2]=f;Nx(17352,e);c[e>>2]=d[a+61>>0];Nx(17384,e);j=+g[a+72>>2];h[k>>3]=+g[a+68>>2];c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];f=e+8|0;h[k>>3]=j;c[f>>2]=c[k>>2];c[f+4>>2]=c[k+4>>2];Nx(17424,e);j=+g[a+80>>2];h[k>>3]=+g[a+76>>2];c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];f=e+8|0;h[k>>3]=j;c[f>>2]=c[k>>2];c[f+4>>2]=c[k+4>>2];Nx(17472,e);h[k>>3]=+g[a+84>>2];c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];Nx(17032,e);c[e>>2]=c[a+56>>2];Nx(17720,e);i=b;return}function MA(a){a=a|0;return}function NA(a){a=a|0;var b=0;b=i;OB(a);i=b;return}function OA(b,d){b=b|0;d=d|0;var e=0,f=0.0,h=0.0,j=0.0,l=0.0,m=0.0,n=0,o=0,p=0,q=0,r=0.0,s=0.0,t=0.0,u=0,v=0,w=0.0,x=0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0,F=0,G=0.0,H=0.0,I=0.0,J=0.0,K=0,L=0,M=0,N=0;q=i;i=i+48|0;F=q;o=c[b+48>>2]|0;M=c[o+8>>2]|0;n=b+116|0;c[n>>2]=M;L=c[b+52>>2]|0;u=c[L+8>>2]|0;p=b+120|0;c[p>>2]=u;x=o+28|0;E=c[x>>2]|0;x=c[x+4>>2]|0;v=b+140|0;c[v>>2]=E;c[v+4>>2]=x;v=L+28|0;e=c[v>>2]|0;v=c[v+4>>2]|0;K=b+148|0;c[K>>2]=e;c[K+4>>2]=v;r=+g[o+120>>2];g[b+156>>2]=r;s=+g[L+120>>2];g[b+160>>2]=s;t=+g[o+128>>2];g[b+164>>2]=t;w=+g[L+128>>2];g[b+168>>2]=w;L=c[d+24>>2]|0;B=+g[L+(M*12|0)+8>>2];o=d+28|0;K=c[o>>2]|0;N=K+(M*12|0)|0;y=+g[N>>2];f=+g[N+4>>2];l=+g[K+(M*12|0)+8>>2];A=+g[L+(u*12|0)+8>>2];L=K+(u*12|0)|0;h=+g[L>>2];j=+g[L+4>>2];m=+g[K+(u*12|0)+8>>2];z=+R(+B);D=+Q(+B);J=+R(+A);H=+Q(+A);u=b+124|0;G=+g[b+80>>2]-(c[k>>2]=E,+g[k>>2]);I=+g[b+84>>2]-(c[k>>2]=x,+g[k>>2]);C=D*G-z*I;I=z*G+D*I;D=+C;G=+I;x=u;g[x>>2]=D;g[x+4>>2]=G;x=b+132|0;G=+g[b+88>>2]-(c[k>>2]=e,+g[k>>2]);D=+g[b+92>>2]-(c[k>>2]=v,+g[k>>2]);z=H*G-J*D;D=J*G+H*D;H=+z;G=+D;v=x;g[v>>2]=H;g[v+4>>2]=G;G=r+s;v=b+128|0;e=b+136|0;g[F>>2]=G+t*I*I+w*D*D;H=-(t*I*C)-w*D*z;g[F+12>>2]=H;D=-(t*I)-w*D;g[F+24>>2]=D;g[F+4>>2]=H;g[F+16>>2]=G+t*C*C+w*z*z;z=t*C+w*z;g[F+28>>2]=z;g[F+8>>2]=D;g[F+20>>2]=z;z=t+w;g[F+32>>2]=z;E=b+68|0;do if(!(+g[E>>2]>0.0)){E=b+172|0;if(z==0.0){Lx(F,E);g[b+100>>2]=0.0;g[b+76>>2]=0.0;break}else{Mx(F,E);g[b+100>>2]=0.0;g[b+76>>2]=0.0;break}}else{Lx(F,b+172|0);if(z>0.0)D=1.0/z;else D=0.0;A=A-B- +g[b+96>>2];J=+g[E>>2]*6.2831854820251465;B=J*D*J;C=+g[d>>2];D=C*(J*D*2.0*+g[b+72>>2]+C*B);E=b+100|0;g[E>>2]=D;if(D!=0.0)D=1.0/D;else D=0.0;g[E>>2]=D;g[b+76>>2]=A*C*B*D;z=z+D;if(z!=0.0)z=1.0/z;else z=0.0;g[b+204>>2]=z}while(0);E=b+104|0;if(!(a[d+20>>0]|0)){g[E>>2]=0.0;g[b+108>>2]=0.0;g[b+112>>2]=0.0;C=y;D=f;H=h;I=j;G=l;J=m;N=c[n>>2]|0;M=c[o>>2]|0;N=M+(N*12|0)|0;C=+C;D=+D;M=N;g[M>>2]=C;N=N+4|0;g[N>>2]=D;N=c[n>>2]|0;M=c[o>>2]|0;N=M+(N*12|0)+8|0;g[N>>2]=G;N=c[p>>2]|0;N=M+(N*12|0)|0;H=+H;I=+I;M=N;g[M>>2]=H;N=N+4|0;g[N>>2]=I;N=c[p>>2]|0;M=c[o>>2]|0;N=M+(N*12|0)+8|0;g[N>>2]=J;i=q;return}else{A=+g[d+8>>2];J=A*+g[E>>2];g[E>>2]=J;N=b+108|0;B=A*+g[N>>2];g[N>>2]=B;N=b+112|0;A=A*+g[N>>2];g[N>>2]=A;C=y-r*J;D=f-r*B;H=h+s*J;I=j+s*B;G=l-t*(A+(B*+g[u>>2]-J*+g[v>>2]));J=m+w*(A+(B*+g[x>>2]-J*+g[e>>2]));N=c[n>>2]|0;M=c[o>>2]|0;N=M+(N*12|0)|0;C=+C;D=+D;M=N;g[M>>2]=C;N=N+4|0;g[N>>2]=D;N=c[n>>2]|0;M=c[o>>2]|0;N=M+(N*12|0)+8|0;g[N>>2]=G;N=c[p>>2]|0;N=M+(N*12|0)|0;H=+H;I=+I;M=N;g[M>>2]=H;N=N+4|0;g[N>>2]=I;N=c[p>>2]|0;M=c[o>>2]|0;N=M+(N*12|0)+8|0;g[N>>2]=J;i=q;return}}function PA(a,b){a=a|0;b=b|0;var d=0,e=0,f=0.0,h=0,j=0.0,k=0.0,l=0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0,u=0,v=0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0;e=i;d=a+116|0;t=c[d>>2]|0;l=b+28|0;u=c[l>>2]|0;h=u+(t*12|0)|0;b=h;k=+g[b>>2];j=+g[b+4>>2];s=+g[u+(t*12|0)+8>>2];b=a+120|0;t=c[b>>2]|0;v=u+(t*12|0)|0;m=+g[v>>2];f=+g[v+4>>2];r=+g[u+(t*12|0)+8>>2];n=+g[a+156>>2];o=+g[a+160>>2];q=+g[a+164>>2];p=+g[a+168>>2];if(+g[a+68>>2]>0.0){v=a+112|0;A=+g[v>>2];D=+g[a+204>>2]*(r-s+ +g[a+76>>2]+ +g[a+100>>2]*A);B=-D;g[v>>2]=A-D;D=s-q*B;B=r+p*B;r=+g[a+136>>2];A=+g[a+132>>2];w=+g[a+128>>2];C=+g[a+124>>2];s=w*D+(m-r*B-k);x=f+A*B-j-C*D;y=+g[a+172>>2]*s+ +g[a+184>>2]*x;x=+g[a+176>>2]*s+ +g[a+188>>2]*x;s=-y;z=-x;v=a+104|0;g[v>>2]=+g[v>>2]-y;v=a+108|0;g[v>>2]=+g[v>>2]-x;x=z;y=s;w=D-q*(C*z-w*s);s=B+p*(A*z-r*s);q=o*y;r=o*x;o=n*y;p=n*x;q=m+q;r=f+r;o=k-o;p=j-p;o=+o;p=+p;v=h;u=v;g[u>>2]=o;v=v+4|0;g[v>>2]=p;v=c[d>>2]|0;u=c[l>>2]|0;v=u+(v*12|0)+8|0;g[v>>2]=w;v=c[b>>2]|0;v=u+(v*12|0)|0;q=+q;r=+r;u=v;g[u>>2]=q;v=v+4|0;g[v>>2]=r;v=c[b>>2]|0;u=c[l>>2]|0;v=u+(v*12|0)+8|0;g[v>>2]=s;i=e;return}else{C=+g[a+136>>2];w=+g[a+132>>2];A=+g[a+128>>2];E=+g[a+124>>2];x=m-r*C-k+s*A;B=f+r*w-j-s*E;D=r-s;y=x*+g[a+172>>2]+B*+g[a+184>>2]+D*+g[a+196>>2];z=x*+g[a+176>>2]+B*+g[a+188>>2]+D*+g[a+200>>2];D=x*+g[a+180>>2]+B*+g[a+192>>2]+D*+g[a+204>>2];B=-y;x=-z;v=a+104|0;g[v>>2]=+g[v>>2]-y;v=a+108|0;g[v>>2]=+g[v>>2]-z;v=a+112|0;g[v>>2]=+g[v>>2]-D;z=x;y=B;A=s-q*(E*x-A*B-D);D=r+p*(w*x-C*B-D);B=o*y;C=o*z;y=n*y;z=n*z;B=m+B;C=f+C;y=k-y;z=j-z;y=+y;z=+z;v=h;u=v;g[u>>2]=y;v=v+4|0;g[v>>2]=z;v=c[d>>2]|0;u=c[l>>2]|0;v=u+(v*12|0)+8|0;g[v>>2]=A;v=c[b>>2]|0;v=u+(v*12|0)|0;B=+B;C=+C;u=v;g[u>>2]=B;v=v+4|0;g[v>>2]=C;v=c[b>>2]|0;u=c[l>>2]|0;v=u+(v*12|0)+8|0;g[v>>2]=D;i=e;return}}function QA(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,h=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0,E=0,F=0,G=0.0,H=0.0,I=0,J=0,K=0;d=i;i=i+64|0;E=d+24|0;F=d+12|0;D=d;e=a+116|0;f=c[e>>2]|0;b=b+24|0;J=c[b>>2]|0;I=J+(f*12|0)|0;q=+g[I>>2];l=+g[I+4>>2];h=+g[J+(f*12|0)+8>>2];f=a+120|0;I=c[f>>2]|0;K=J+(I*12|0)|0;k=+g[K>>2];m=+g[K+4>>2];o=+g[J+(I*12|0)+8>>2];v=+R(+h);C=+Q(+h);B=+R(+o);z=+Q(+o);n=+g[a+156>>2];r=+g[a+160>>2];j=+g[a+164>>2];p=+g[a+168>>2];w=+g[a+80>>2]- +g[a+140>>2];t=+g[a+84>>2]- +g[a+144>>2];s=C*w-v*t;t=v*w+C*t;C=+g[a+88>>2]- +g[a+148>>2];w=+g[a+92>>2]- +g[a+152>>2];v=z*C-B*w;w=B*C+z*w;z=n+r;C=z+j*t*t+p*w*w;g[E>>2]=C;B=-(j*t*s)-p*w*v;g[E+12>>2]=B;A=-(j*t)-p*w;g[E+24>>2]=A;g[E+4>>2]=B;z=z+j*s*s+p*v*v;g[E+16>>2]=z;G=j*s+p*v;g[E+28>>2]=G;g[E+8>>2]=A;g[E+20>>2]=G;G=j+p;g[E+32>>2]=G;A=k+v-q-s;y=m+w-l-t;if(+g[a+68>>2]>0.0){u=+O(+(y*y+A*A));x=C*z-B*B;if(x!=0.0)x=1.0/x;H=-(x*(z*A-B*y));x=-(x*(C*y-B*A));v=v*x-w*H;w=x;y=H;s=s*x-t*H;x=0.0}else{H=o-h- +g[a+96>>2];u=+O(+(y*y+A*A));if(H>0.0)x=H;else x=-H;g[F>>2]=A;g[F+4>>2]=y;g[F+8>>2]=H;if(G>0.0){Jx(D,E,F);C=+g[D+4>>2];y=+g[D>>2];z=-+g[D+8>>2]}else{G=C*z-B*B;if(G!=0.0)G=1.0/G;C=G*(C*y-B*A);y=G*(z*A-B*y);z=0.0}H=-y;G=-C;v=z+(v*G-w*H);w=G;y=H;s=z+(s*G-t*H)}H=+(q-n*y);G=+(l-n*w);K=(c[b>>2]|0)+((c[e>>2]|0)*12|0)|0;g[K>>2]=H;g[K+4>>2]=G;K=c[b>>2]|0;g[K+((c[e>>2]|0)*12|0)+8>>2]=h-j*s;G=+(k+r*y);H=+(m+r*w);K=K+((c[f>>2]|0)*12|0)|0;g[K>>2]=G;g[K+4>>2]=H;g[(c[b>>2]|0)+((c[f>>2]|0)*12|0)+8>>2]=o+p*v;if(!(u<=.004999999888241291)){K=0;i=d;return K|0}K=x<=.03490658849477768;i=d;return K|0}function RA(a,b){a=a|0;b=b|0;var d=0.0,e=0.0,f=0.0,h=0.0,i=0.0,j=0;j=c[b+48>>2]|0;i=+g[j+24>>2];h=+g[b+80>>2];f=+g[j+20>>2];e=+g[b+84>>2];d=h*f+i*e+ +g[j+16>>2];g[a>>2]=+g[j+12>>2]+(i*h-f*e);g[a+4>>2]=d;return}function SA(a,b){a=a|0;b=b|0;var d=0.0,e=0.0,f=0.0,h=0.0,i=0.0,j=0;j=c[b+52>>2]|0;i=+g[j+24>>2];h=+g[b+88>>2];f=+g[j+20>>2];e=+g[b+92>>2];d=h*f+i*e+ +g[j+16>>2];g[a>>2]=+g[j+12>>2]+(i*h-f*e);g[a+4>>2]=d;return}function TA(a,b,c){a=a|0;b=b|0;c=+c;var d=0.0;d=+g[b+108>>2]*c;g[a>>2]=+g[b+104>>2]*c;g[a+4>>2]=d;return}function UA(a,b){a=a|0;b=+b;return+(+g[a+112>>2]*b)}function VA(a){a=a|0;var b=0,e=0,f=0,j=0.0,l=0;b=i;i=i+16|0;e=b;l=c[(c[a+48>>2]|0)+8>>2]|0;f=c[(c[a+52>>2]|0)+8>>2]|0;Nx(17152,e);c[e>>2]=l;Nx(17320,e);c[e>>2]=f;Nx(17352,e);c[e>>2]=d[a+61>>0];Nx(17384,e);j=+g[a+84>>2];h[k>>3]=+g[a+80>>2];c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];f=e+8|0;h[k>>3]=j;c[f>>2]=c[k>>2];c[f+4>>2]=c[k+4>>2];Nx(17424,e);j=+g[a+92>>2];h[k>>3]=+g[a+88>>2];c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];f=e+8|0;h[k>>3]=j;c[f>>2]=c[k>>2];c[f+4>>2]=c[k+4>>2];Nx(17472,e);h[k>>3]=+g[a+96>>2];c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];Nx(17176,e);h[k>>3]=+g[a+68>>2];c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];Nx(17656,e);h[k>>3]=+g[a+72>>2];c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];Nx(17688,e);c[e>>2]=c[a+56>>2];Nx(17720,e);i=b;return}function WA(a){a=a|0;return}function XA(a){a=a|0;var b=0;b=i;OB(a);i=b;return}function YA(b,d){b=b|0;d=d|0;var e=0.0,f=0,h=0.0,j=0,l=0.0,m=0,n=0,o=0.0,p=0,q=0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0,y=0,z=0.0,A=0.0,B=0.0,C=0.0,D=0,E=0.0,F=0,G=0,H=0.0,I=0.0,J=0.0,K=0.0,L=0.0,M=0.0,N=0.0,O=0.0,P=0,S=0,T=0,U=0,V=0,W=0,X=0.0,Y=0.0;p=i;j=c[b+48>>2]|0;V=c[j+8>>2]|0;x=b+132|0;c[x>>2]=V;f=c[b+52>>2]|0;S=c[f+8>>2]|0;q=b+136|0;c[q>>2]=S;D=j+28|0;P=c[D>>2]|0;D=c[D+4>>2]|0;G=b+140|0;c[G>>2]=P;c[G+4>>2]=D;G=f+28|0;F=c[G>>2]|0;G=c[G+4>>2]|0;n=b+148|0;c[n>>2]=F;c[n+4>>2]=G;E=+g[j+120>>2];n=b+156|0;g[n>>2]=E;K=+g[f+120>>2];m=b+160|0;g[m>>2]=K;A=+g[j+128>>2];j=b+164|0;g[j>>2]=A;z=+g[f+128>>2];f=b+168|0;g[f>>2]=z;U=c[d+24>>2]|0;y=U+(V*12|0)|0;C=+g[y>>2];B=+g[y+4>>2];H=+g[U+(V*12|0)+8>>2];y=d+28|0;T=c[y>>2]|0;W=T+(V*12|0)|0;r=+g[W>>2];s=+g[W+4>>2];v=+g[T+(V*12|0)+8>>2];V=U+(S*12|0)|0;e=+g[V>>2];h=+g[V+4>>2];o=+g[U+(S*12|0)+8>>2];U=T+(S*12|0)|0;t=+g[U>>2];u=+g[U+4>>2];w=+g[T+(S*12|0)+8>>2];O=+R(+H);H=+Q(+H);N=+R(+o);o=+Q(+o);l=+g[b+76>>2]-(c[k>>2]=P,+g[k>>2]);L=+g[b+80>>2]-(c[k>>2]=D,+g[k>>2]);I=H*l-O*L;L=O*l+H*L;l=+g[b+84>>2]-(c[k>>2]=F,+g[k>>2]);M=+g[b+88>>2]-(c[k>>2]=G,+g[k>>2]);J=o*l-N*M;M=N*l+o*M;C=e+J-C-I;B=h+M-B-L;h=+g[b+100>>2];e=+g[b+104>>2];o=H*h-O*e;e=O*h+H*e;h=+o;l=+e;G=b+180|0;g[G>>2]=h;g[G+4>>2]=l;I=I+C;L=L+B;l=e*I-o*L;g[b+196>>2]=l;h=J*e-M*o;g[b+200>>2]=h;K=E+K;E=K+l*A*l+h*z*h;if(E>0.0)E=1.0/E;g[b+204>>2]=E;D=b+212|0;g[D>>2]=0.0;F=b+216|0;g[F>>2]=0.0;G=b+220|0;g[G>>2]=0.0;N=+g[b+68>>2];if(N>0.0){Y=+g[b+92>>2];X=+g[b+96>>2];E=H*Y-O*X;H=O*Y+H*X;X=+E;O=+H;W=b+172|0;g[W>>2]=X;g[W+4>>2]=O;O=I*H-L*E;g[b+188>>2]=O;I=J*H-M*E;g[b+192>>2]=I;I=K+O*A*O+I*z*I;if(I>0.0){L=1.0/I;g[D>>2]=L;Y=N*6.2831854820251465;K=Y*L*Y;J=+g[d>>2];L=J*(Y*L*2.0*+g[b+72>>2]+J*K);if(L>0.0)L=1.0/L;g[G>>2]=L;g[F>>2]=(C*E+B*H)*J*K*L;B=I+L;g[D>>2]=B;if(B>0.0)g[D>>2]=1.0/B}}else g[b+116>>2]=0.0;if(a[b+128>>0]|0){z=z+A;D=b+208|0;g[D>>2]=z;if(z>0.0)g[D>>2]=1.0/z}else{g[b+208>>2]=0.0;g[b+112>>2]=0.0}if(!(a[d+20>>0]|0)){g[b+108>>2]=0.0;g[b+116>>2]=0.0;g[b+112>>2]=0.0;L=r;M=s;O=t;X=u;N=v;Y=w;W=c[x>>2]|0;V=c[y>>2]|0;W=V+(W*12|0)|0;L=+L;M=+M;V=W;g[V>>2]=L;W=W+4|0;g[W>>2]=M;W=c[x>>2]|0;V=c[y>>2]|0;W=V+(W*12|0)+8|0;g[W>>2]=N;W=c[q>>2]|0;W=V+(W*12|0)|0;O=+O;X=+X;V=W;g[V>>2]=O;W=W+4|0;g[W>>2]=X;W=c[q>>2]|0;V=c[y>>2]|0;W=V+(W*12|0)+8|0;g[W>>2]=Y;i=p;return}else{V=d+8|0;W=b+108|0;K=+g[V>>2]*+g[W>>2];g[W>>2]=K;W=b+116|0;Y=+g[V>>2]*+g[W>>2];g[W>>2]=Y;W=b+112|0;J=+g[V>>2]*+g[W>>2];g[W>>2]=J;O=K*o+Y*+g[b+172>>2];N=K*e+Y*+g[b+176>>2];M=+g[n>>2];X=+g[m>>2];L=r-O*M;M=s-N*M;O=t+O*X;X=u+N*X;N=v-(J+(K*l+Y*+g[b+188>>2]))*+g[j>>2];Y=w+(J+(K*h+Y*+g[b+192>>2]))*+g[f>>2];W=c[x>>2]|0;V=c[y>>2]|0;W=V+(W*12|0)|0;L=+L;M=+M;V=W;g[V>>2]=L;W=W+4|0;g[W>>2]=M;W=c[x>>2]|0;V=c[y>>2]|0;W=V+(W*12|0)+8|0;g[W>>2]=N;W=c[q>>2]|0;W=V+(W*12|0)|0;O=+O;X=+X;V=W;g[V>>2]=O;W=W+4|0;g[W>>2]=X;W=c[q>>2]|0;V=c[y>>2]|0;W=V+(W*12|0)+8|0;g[W>>2]=Y;i=p;return}}function ZA(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,h=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0,A=0.0,B=0,C=0;d=i;v=+g[a+156>>2];o=+g[a+160>>2];t=+g[a+164>>2];k=+g[a+168>>2];r=a+132|0;e=c[r>>2]|0;f=b+28|0;B=c[f>>2]|0;z=B+(e*12|0)|0;w=+g[z>>2];x=+g[z+4>>2];y=+g[B+(e*12|0)+8>>2];e=a+136|0;z=c[e>>2]|0;C=B+(z*12|0)|0;j=+g[C>>2];s=+g[C+4>>2];m=+g[B+(z*12|0)+8>>2];q=+g[a+172>>2];p=+g[a+176>>2];l=+g[a+192>>2];u=+g[a+188>>2];z=a+116|0;A=+g[z>>2];h=+g[a+212>>2]*(+g[a+216>>2]+(m*l+(q*(j-w)+p*(s-x))-y*u)+ +g[a+220>>2]*A);n=-h;g[z>>2]=A-h;q=q*n;p=p*n;w=w-v*q;x=x-v*p;u=y-t*u*n;q=j+o*q;p=s+o*p;n=m+k*l*n;z=a+112|0;l=+g[z>>2];m=+g[b>>2]*+g[a+120>>2];s=l- +g[a+208>>2]*(n-u- +g[a+124>>2]);j=-m;m=s>2]=m;l=m-l;u=u-t*l;l=n+k*l;n=+g[a+180>>2];m=+g[a+184>>2];j=+g[a+200>>2];s=+g[a+196>>2];y=+g[a+204>>2]*((q-w)*n+(p-x)*m+j*l-s*u);h=-y;b=a+108|0;g[b>>2]=+g[b>>2]-y;n=n*h;m=m*h;w=+(w-v*n);v=+(x-v*m);b=(c[f>>2]|0)+((c[r>>2]|0)*12|0)|0;g[b>>2]=w;g[b+4>>2]=v;b=c[f>>2]|0;g[b+((c[r>>2]|0)*12|0)+8>>2]=u-t*s*h;n=+(q+o*n);m=+(p+o*m);b=b+((c[e>>2]|0)*12|0)|0;g[b>>2]=n;g[b+4>>2]=m;g[(c[f>>2]|0)+((c[e>>2]|0)*12|0)+8>>2]=l+k*j*h;i=d;return}function _A(a,b){a=a|0;b=b|0;var d=0,e=0,f=0.0,h=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0,E=0,F=0,G=0.0;e=i;d=a+132|0;w=c[d>>2]|0;b=b+24|0;E=c[b>>2]|0;D=E+(w*12|0)|0;j=+g[D>>2];l=+g[D+4>>2];n=+g[E+(w*12|0)+8>>2];w=a+136|0;D=c[w>>2]|0;F=E+(D*12|0)|0;t=+g[F>>2];v=+g[F+4>>2];x=+g[E+(D*12|0)+8>>2];u=+R(+n);q=+Q(+n);k=+R(+x);f=+Q(+x);r=+g[a+76>>2]- +g[a+140>>2];m=+g[a+80>>2]- +g[a+144>>2];o=q*r-u*m;m=u*r+q*m;r=+g[a+84>>2]- +g[a+148>>2];z=+g[a+88>>2]- +g[a+152>>2];y=f*r-k*z;z=k*r+f*z;f=t-j+y-o;r=v-l+z-m;k=+g[a+100>>2];h=+g[a+104>>2];p=q*k-u*h;h=u*k+q*h;q=p*f+h*r;k=+g[a+156>>2];u=+g[a+160>>2];s=+g[a+164>>2];C=+g[a+196>>2];A=+g[a+168>>2];B=+g[a+200>>2];B=k+u+C*s*C+B*A*B;if(B!=0.0)B=-q/B;else B=0.0;G=p*B;C=h*B;j=+(j-G*k);l=+(l-C*k);F=(c[b>>2]|0)+((c[d>>2]|0)*12|0)|0;g[F>>2]=j;g[F+4>>2]=l;F=c[b>>2]|0;g[F+((c[d>>2]|0)*12|0)+8>>2]=n-(h*(o+f)-p*(m+r))*B*s;t=+(t+G*u);C=+(v+C*u);F=F+((c[w>>2]|0)*12|0)|0;g[F>>2]=t;g[F+4>>2]=C;g[(c[b>>2]|0)+((c[w>>2]|0)*12|0)+8>>2]=x+(y*h-z*p)*B*A;if(q>0.0){G=q;F=G<=.004999999888241291;i=e;return F|0}G=-q;F=G<=.004999999888241291;i=e;return F|0}function $A(a,b){a=a|0;b=b|0;var d=0.0,e=0.0,f=0.0,h=0.0,i=0.0,j=0;j=c[b+48>>2]|0;i=+g[j+24>>2];h=+g[b+76>>2];f=+g[j+20>>2];e=+g[b+80>>2];d=h*f+i*e+ +g[j+16>>2];g[a>>2]=+g[j+12>>2]+(i*h-f*e);g[a+4>>2]=d;return}function aB(a,b){a=a|0;b=b|0;var d=0.0,e=0.0,f=0.0,h=0.0,i=0.0,j=0;j=c[b+52>>2]|0;i=+g[j+24>>2];h=+g[b+84>>2];f=+g[j+20>>2];e=+g[b+88>>2];d=h*f+i*e+ +g[j+16>>2];g[a>>2]=+g[j+12>>2]+(i*h-f*e);g[a+4>>2]=d;return}function bB(a,b,c){a=a|0;b=b|0;c=+c;var d=0.0,e=0.0,f=0.0;f=+g[b+108>>2];e=+g[b+116>>2];d=(f*+g[b+184>>2]+e*+g[b+176>>2])*c;g[a>>2]=(f*+g[b+180>>2]+e*+g[b+172>>2])*c;g[a+4>>2]=d;return}function cB(a,b){a=a|0;b=+b;return+(+g[a+112>>2]*b)}function dB(a){a=a|0;var b=0,e=0,f=0,j=0.0,l=0;b=i;i=i+16|0;e=b;l=c[(c[a+48>>2]|0)+8>>2]|0;f=c[(c[a+52>>2]|0)+8>>2]|0;Nx(17296,e);c[e>>2]=l;Nx(17320,e);c[e>>2]=f;Nx(17352,e);c[e>>2]=d[a+61>>0];Nx(17384,e);j=+g[a+80>>2];h[k>>3]=+g[a+76>>2];c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];f=e+8|0;h[k>>3]=j;c[f>>2]=c[k>>2];c[f+4>>2]=c[k+4>>2];Nx(17424,e);j=+g[a+88>>2];h[k>>3]=+g[a+84>>2];c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];f=e+8|0;h[k>>3]=j;c[f>>2]=c[k>>2];c[f+4>>2]=c[k+4>>2];Nx(17472,e);j=+g[a+96>>2];h[k>>3]=+g[a+92>>2];c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];f=e+8|0;h[k>>3]=j;c[f>>2]=c[k>>2];c[f+4>>2]=c[k+4>>2];Nx(17520,e);c[e>>2]=d[a+128>>0];Nx(17560,e);h[k>>3]=+g[a+124>>2];c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];Nx(17592,e);h[k>>3]=+g[a+120>>2];c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];Nx(17624,e);h[k>>3]=+g[a+68>>2];c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];Nx(17656,e);h[k>>3]=+g[a+72>>2];c[e>>2]=c[k>>2];c[e+4>>2]=c[k+4>>2];Nx(17688,e);c[e>>2]=c[a+56>>2];Nx(17720,e);i=b;return}function eB(a){a=a|0;return}function fB(a){a=a|0;var b=0;b=i;OB(a);i=b;return}function gB(a,b){a=a|0;b=b|0;var d=0;d=i;i=i+16|0;c[d>>2]=b;b=c[m>>2]|0;ya(b|0,a|0,d|0)|0;Za(10,b|0)|0;$a()}function hB(){var a=0,b=0,d=0,e=0,f=0;a=i;i=i+16|0;b=a;a=a+12|0;if(Sa(17984,44)|0)gB(17992,b);d=Pa(c[4494]|0)|0;if(!d)gB(17960,b);d=c[d>>2]|0;if(!d)gB(17960,b);f=d+48|0;e=c[f>>2]|0;f=c[f+4>>2]|0;if(!((e&-256|0)==1126902528&(f|0)==1129074247)){c[b>>2]=17808;gB(17920,b)}if((e|0)==1126902529&(f|0)==1129074247)e=c[d+44>>2]|0;else e=d+80|0;c[a>>2]=e;f=c[d>>2]|0;d=c[f+4>>2]|0;if(vB(18352,f,a)|0){f=c[a>>2]|0;f=nb[c[(c[f>>2]|0)+8>>2]&63](f)|0;c[b>>2]=17808;c[b+4>>2]=d;c[b+8>>2]=f;gB(17824,b)}else{c[b>>2]=17808;c[b+4>>2]=d;gB(17872,b)}}function iB(){var a=0;a=i;i=i+16|0;if(!(va(17976,124)|0)){i=a;return}else gB(18048,a)}function jB(a){a=a|0;var b=0;b=i;i=i+16|0;OB(a);if(!(Ya(c[4494]|0,0)|0)){i=b;return}else gB(18104,b)}function kB(a){a=a|0;var b=0;b=i;OB(a);i=b;return}function lB(a){a=a|0;return}function mB(a){a=a|0;return 18184}function nB(a){a=a|0;var b=0;b=i;i=i+16|0;qb[a&63]();gB(18232,b)}function oB(){var a=0,b=0;b=i;i=i+16|0;if(Sa(17984,44)|0)gB(17992,b);b=Pa(c[4494]|0)|0;if(((b|0)!=0?(a=c[b>>2]|0,(a|0)!=0):0)?(b=a+48|0,(c[b>>2]&-256|0)==1126902528?(c[b+4>>2]|0)==1129074247:0):0)nB(c[a+12>>2]|0);b=c[4450]|0;c[4450]=b+0;nB(b)}function pB(a){a=a|0;return}function qB(a){a=a|0;return}function rB(a){a=a|0;return}function sB(a){a=a|0;var b=0;b=i;OB(a);i=b;return}function tB(a){a=a|0;var b=0;b=i;OB(a);i=b;return}function uB(a){a=a|0;var b=0;b=i;OB(a);i=b;return}function vB(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0;e=i;i=i+64|0;f=e;if((a|0)==(b|0)){h=1;i=e;return h|0}if(!b){h=0;i=e;return h|0}b=BB(b,18480)|0;if(!b){h=0;i=e;return h|0}h=f+0|0;g=h+56|0;do{c[h>>2]=0;h=h+4|0}while((h|0)<(g|0));c[f>>2]=b;c[f+8>>2]=a;c[f+12>>2]=-1;c[f+48>>2]=1;vb[c[(c[b>>2]|0)+28>>2]&63](b,f,c[d>>2]|0,1);if((c[f+24>>2]|0)!=1){h=0;i=e;return h|0}c[d>>2]=c[f+16>>2];h=1;i=e;return h|0}function wB(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0;f=i;g=b+16|0;h=c[g>>2]|0;if(!h){c[g>>2]=d;c[b+24>>2]=e;c[b+36>>2]=1;i=f;return}if((h|0)!=(d|0)){h=b+36|0;c[h>>2]=(c[h>>2]|0)+1;c[b+24>>2]=2;a[b+54>>0]=1;i=f;return}d=b+24|0;if((c[d>>2]|0)!=2){i=f;return}c[d>>2]=e;i=f;return}function xB(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0;f=i;if((c[b+8>>2]|0)!=(a|0)){i=f;return}wB(b,d,e);i=f;return}function yB(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0;f=i;if((a|0)==(c[b+8>>2]|0)){wB(b,d,e);i=f;return}else{a=c[a+8>>2]|0;vb[c[(c[a>>2]|0)+28>>2]&63](a,b,d,e);i=f;return}}function zB(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0;f=i;g=c[a+4>>2]|0;h=g>>8;if(g&1)h=c[(c[d>>2]|0)+h>>2]|0;a=c[a>>2]|0;vb[c[(c[a>>2]|0)+28>>2]&63](a,b,d+h|0,(g&2|0)!=0?e:2);i=f;return}function AB(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,j=0;g=i;if((b|0)==(c[d+8>>2]|0)){wB(d,e,f);i=g;return}j=c[b+12>>2]|0;h=b+(j<<3)+16|0;zB(b+16|0,d,e,f);if((j|0)<=1){i=g;return}j=d+54|0;b=b+24|0;while(1){zB(b,d,e,f);if(a[j>>0]|0){f=7;break}b=b+8|0;if(b>>>0>=h>>>0){f=7;break}}if((f|0)==7){i=g;return}}function BB(d,e){d=d|0;e=e|0;var f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;f=i;i=i+64|0;m=f;g=c[d>>2]|0;h=d+(c[g+ -8>>2]|0)|0;g=c[g+ -4>>2]|0;c[m>>2]=e;c[m+4>>2]=d;c[m+8>>2]=18424;p=m+12|0;n=m+16|0;o=m+20|0;j=m+24|0;d=m+28|0;k=m+32|0;l=m+40|0;r=(g|0)==(e|0);e=p+0|0;q=e+40|0;do{c[e>>2]=0;e=e+4|0}while((e|0)<(q|0));b[p+40>>1]=0;a[p+42>>0]=0;do if(r){c[m+48>>2]=1;sb[c[(c[g>>2]|0)+20>>2]&63](g,m,h,h,1,0);d=(c[j>>2]|0)==1?h:0}else{hb[c[(c[g>>2]|0)+24>>2]&63](g,m,h,1,0);g=c[m+36>>2]|0;if(!g){if((c[l>>2]|0)!=1){d=0;break}if((c[d>>2]|0)!=1){d=0;break}d=(c[k>>2]|0)==1?c[o>>2]|0:0;break}else if((g|0)!=1){d=0;break}if((c[j>>2]|0)!=1){if(c[l>>2]|0){d=0;break}if((c[d>>2]|0)!=1){d=0;break}if((c[k>>2]|0)!=1){d=0;break}}d=c[n>>2]|0}while(0);i=f;return d|0}function CB(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0;g=i;a[b+53>>0]=1;if((c[b+4>>2]|0)!=(e|0)){i=g;return}a[b+52>>0]=1;e=b+16|0;h=c[e>>2]|0;if(!h){c[e>>2]=d;c[b+24>>2]=f;c[b+36>>2]=1;if(!((f|0)==1?(c[b+48>>2]|0)==1:0)){i=g;return}a[b+54>>0]=1;i=g;return}if((h|0)!=(d|0)){h=b+36|0;c[h>>2]=(c[h>>2]|0)+1;a[b+54>>0]=1;i=g;return}d=b+24|0;e=c[d>>2]|0;if((e|0)==2)c[d>>2]=f;else f=e;if(!((f|0)==1?(c[b+48>>2]|0)==1:0)){i=g;return}a[b+54>>0]=1;i=g;return}function DB(b,d,e,f,g){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0;h=i;if((b|0)==(c[d+8>>2]|0)){if((c[d+4>>2]|0)!=(e|0)){i=h;return}e=d+28|0;if((c[e>>2]|0)==1){i=h;return}c[e>>2]=f;i=h;return}if((b|0)!=(c[d>>2]|0)){u=c[b+12>>2]|0;m=b+(u<<3)+16|0;FB(b+16|0,d,e,f,g);n=b+24|0;if((u|0)<=1){i=h;return}p=c[b+8>>2]|0;if((p&2|0)==0?(o=d+36|0,(c[o>>2]|0)!=1):0){if(!(p&1)){q=d+54|0;p=n;while(1){if(a[q>>0]|0){p=43;break}if((c[o>>2]|0)==1){p=43;break}FB(p,d,e,f,g);p=p+8|0;if(p>>>0>=m>>>0){p=43;break}}if((p|0)==43){i=h;return}}p=d+24|0;q=d+54|0;r=n;while(1){if(a[q>>0]|0){p=43;break}if((c[o>>2]|0)==1?(c[p>>2]|0)==1:0){p=43;break}FB(r,d,e,f,g);r=r+8|0;if(r>>>0>=m>>>0){p=43;break}}if((p|0)==43){i=h;return}}o=d+54|0;while(1){if(a[o>>0]|0){p=43;break}FB(n,d,e,f,g);n=n+8|0;if(n>>>0>=m>>>0){p=43;break}}if((p|0)==43){i=h;return}}if((c[d+16>>2]|0)!=(e|0)?(j=d+20|0,(c[j>>2]|0)!=(e|0)):0){c[d+32>>2]=f;m=d+44|0;if((c[m>>2]|0)==4){i=h;return}u=c[b+12>>2]|0;t=b+(u<<3)+16|0;a:do if((u|0)>0){o=d+52|0;n=d+53|0;r=d+54|0;q=b+8|0;p=d+24|0;u=0;s=0;b=b+16|0;b:do{a[o>>0]=0;a[n>>0]=0;EB(b,d,e,e,1,g);if(a[r>>0]|0)break;do if(a[n>>0]|0){if(!(a[o>>0]|0))if(!(c[q>>2]&1)){s=1;break b}else{s=1;break}if((c[p>>2]|0)==1){p=25;break a}if(!(c[q>>2]&2)){p=25;break a}else{u=1;s=1}}while(0);b=b+8|0}while(b>>>0>>0);if(u){l=s;p=24}else{k=s;p=21}}else{k=0;p=21}while(0);if((p|0)==21){c[j>>2]=e;u=d+40|0;c[u>>2]=(c[u>>2]|0)+1;if((c[d+36>>2]|0)==1?(c[d+24>>2]|0)==2:0){a[d+54>>0]=1;if(k)p=25;else p=26}else{l=k;p=24}}if((p|0)==24)if(l)p=25;else p=26;if((p|0)==25){c[m>>2]=3;i=h;return}else if((p|0)==26){c[m>>2]=4;i=h;return}}if((f|0)!=1){i=h;return}c[d+32>>2]=1;i=h;return}function EB(a,b,d,e,f,g){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,j=0,k=0;h=i;j=c[a+4>>2]|0;k=j>>8;if(j&1)k=c[(c[e>>2]|0)+k>>2]|0;a=c[a>>2]|0;sb[c[(c[a>>2]|0)+20>>2]&63](a,b,d,e+k|0,(j&2|0)!=0?f:2,g);i=h;return}function FB(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,j=0;g=i;h=c[a+4>>2]|0;j=h>>8;if(h&1)j=c[(c[d>>2]|0)+j>>2]|0;a=c[a>>2]|0;hb[c[(c[a>>2]|0)+24>>2]&63](a,b,d+j|0,(h&2|0)!=0?e:2,f);i=g;return}function GB(b,d,e,f,g){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,j=0,k=0,l=0,m=0;h=i;if((b|0)==(c[d+8>>2]|0)){if((c[d+4>>2]|0)!=(e|0)){i=h;return}j=d+28|0;if((c[j>>2]|0)==1){i=h;return}c[j>>2]=f;i=h;return}if((b|0)!=(c[d>>2]|0)){l=c[b+8>>2]|0;hb[c[(c[l>>2]|0)+24>>2]&63](l,d,e,f,g);i=h;return}if((c[d+16>>2]|0)!=(e|0)?(k=d+20|0,(c[k>>2]|0)!=(e|0)):0){c[d+32>>2]=f;f=d+44|0;if((c[f>>2]|0)==4){i=h;return}l=d+52|0;a[l>>0]=0;m=d+53|0;a[m>>0]=0;b=c[b+8>>2]|0;sb[c[(c[b>>2]|0)+20>>2]&63](b,d,e,e,1,g);if(a[m>>0]|0){if(!(a[l>>0]|0)){b=1;j=13}}else{b=0;j=13}do if((j|0)==13){c[k>>2]=e;m=d+40|0;c[m>>2]=(c[m>>2]|0)+1;if((c[d+36>>2]|0)==1?(c[d+24>>2]|0)==2:0){a[d+54>>0]=1;if(b)break}else j=16;if((j|0)==16?b:0)break;c[f>>2]=4;i=h;return}while(0);c[f>>2]=3;i=h;return}if((f|0)!=1){i=h;return}c[d+32>>2]=1;i=h;return}function HB(b,d,e,f,g){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0;g=i;if((c[d+8>>2]|0)==(b|0)){if((c[d+4>>2]|0)!=(e|0)){i=g;return}d=d+28|0;if((c[d>>2]|0)==1){i=g;return}c[d>>2]=f;i=g;return}if((c[d>>2]|0)!=(b|0)){i=g;return}if((c[d+16>>2]|0)!=(e|0)?(h=d+20|0,(c[h>>2]|0)!=(e|0)):0){c[d+32>>2]=f;c[h>>2]=e;b=d+40|0;c[b>>2]=(c[b>>2]|0)+1;if((c[d+36>>2]|0)==1?(c[d+24>>2]|0)==2:0)a[d+54>>0]=1;c[d+44>>2]=4;i=g;return}if((f|0)!=1){i=g;return}c[d+32>>2]=1;i=g;return}function IB(b,d,e,f,g,h){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;var j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;m=i;if((b|0)==(c[d+8>>2]|0)){CB(d,e,f,g);i=m;return}j=d+52|0;l=a[j>>0]|0;o=d+53|0;n=a[o>>0]|0;r=c[b+12>>2]|0;p=b+(r<<3)+16|0;a[j>>0]=0;a[o>>0]=0;EB(b+16|0,d,e,f,g,h);a:do if((r|0)>1){k=d+24|0;q=b+8|0;r=d+54|0;b=b+24|0;do{if(a[r>>0]|0)break a;if(!(a[j>>0]|0)){if((a[o>>0]|0)!=0?(c[q>>2]&1|0)==0:0)break a}else{if((c[k>>2]|0)==1)break a;if(!(c[q>>2]&2))break a}a[j>>0]=0;a[o>>0]=0;EB(b,d,e,f,g,h);b=b+8|0}while(b>>>0

>>0)}while(0);a[j>>0]=l;a[o>>0]=n;i=m;return}function JB(a,b,d,e,f,g){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0;h=i;if((a|0)==(c[b+8>>2]|0)){CB(b,d,e,f);i=h;return}else{a=c[a+8>>2]|0;sb[c[(c[a>>2]|0)+20>>2]&63](a,b,d,e,f,g);i=h;return}}function KB(a,b,d,e,f,g){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;g=i;if((c[b+8>>2]|0)!=(a|0)){i=g;return}CB(b,d,e,f);i=g;return}function LB(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0;e=i;i=i+16|0;f=e;c[f>>2]=c[d>>2];a=gb[c[(c[a>>2]|0)+16>>2]&63](a,b,f)|0;b=a&1;if(!a){i=e;return b|0}c[d>>2]=c[f>>2];i=e;return b|0}function MB(a){a=a|0;var b=0;b=i;if(!a)a=0;else a=(BB(a,18592)|0)!=0;i=b;return a&1|0}function NB(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0;b=i;do if(a>>>0<245){if(a>>>0<11)a=16;else a=a+11&-8;v=a>>>3;p=c[4710]|0;w=p>>>v;if(w&3){h=(w&1^1)+v|0;g=h<<1;e=18880+(g<<2)|0;g=18880+(g+2<<2)|0;j=c[g>>2]|0;d=j+8|0;f=c[d>>2]|0;do if((e|0)!=(f|0)){if(f>>>0<(c[4714]|0)>>>0)$a();k=f+12|0;if((c[k>>2]|0)==(j|0)){c[k>>2]=e;c[g>>2]=f;break}else $a()}else c[4710]=p&~(1<>2]=H|3;H=j+(H|4)|0;c[H>>2]=c[H>>2]|1;H=d;i=b;return H|0}if(a>>>0>(c[4712]|0)>>>0){if(w){h=2<>>12&16;h=h>>>d;f=h>>>5&8;h=h>>>f;g=h>>>2&4;h=h>>>g;e=h>>>1&2;h=h>>>e;j=h>>>1&1;j=(f|d|g|e|j)+(h>>>j)|0;h=j<<1;e=18880+(h<<2)|0;h=18880+(h+2<<2)|0;g=c[h>>2]|0;d=g+8|0;f=c[d>>2]|0;do if((e|0)!=(f|0)){if(f>>>0<(c[4714]|0)>>>0)$a();k=f+12|0;if((c[k>>2]|0)==(g|0)){c[k>>2]=e;c[h>>2]=f;break}else $a()}else c[4710]=p&~(1<>2]=a|3;e=g+a|0;c[g+(a|4)>>2]=f|1;c[g+h>>2]=f;h=c[4712]|0;if(h){g=c[4715]|0;k=h>>>3;j=k<<1;h=18880+(j<<2)|0;l=c[4710]|0;k=1<>2]|0;if(k>>>0<(c[4714]|0)>>>0)$a();else{D=j;C=k}}else{c[4710]=l|k;D=18880+(j+2<<2)|0;C=h}c[D>>2]=g;c[C+12>>2]=g;c[g+8>>2]=C;c[g+12>>2]=h}c[4712]=f;c[4715]=e;H=d;i=b;return H|0}p=c[4711]|0;if(p){e=(p&0-p)+ -1|0;G=e>>>12&16;e=e>>>G;F=e>>>5&8;e=e>>>F;H=e>>>2&4;e=e>>>H;f=e>>>1&2;e=e>>>f;d=e>>>1&1;d=c[19144+((F|G|H|f|d)+(e>>>d)<<2)>>2]|0;e=(c[d+4>>2]&-8)-a|0;f=d;while(1){g=c[f+16>>2]|0;if(!g){g=c[f+20>>2]|0;if(!g)break}f=(c[g+4>>2]&-8)-a|0;H=f>>>0>>0;e=H?f:e;f=g;d=H?g:d}h=c[4714]|0;if(d>>>0>>0)$a();f=d+a|0;if(d>>>0>=f>>>0)$a();g=c[d+24>>2]|0;k=c[d+12>>2]|0;do if((k|0)==(d|0)){k=d+20|0;j=c[k>>2]|0;if(!j){k=d+16|0;j=c[k>>2]|0;if(!j){B=0;break}}while(1){l=j+20|0;m=c[l>>2]|0;if(m){j=m;k=l;continue}m=j+16|0;l=c[m>>2]|0;if(!l)break;else{j=l;k=m}}if(k>>>0>>0)$a();else{c[k>>2]=0;B=j;break}}else{j=c[d+8>>2]|0;if(j>>>0>>0)$a();h=j+12|0;if((c[h>>2]|0)!=(d|0))$a();l=k+8|0;if((c[l>>2]|0)==(d|0)){c[h>>2]=k;c[l>>2]=j;B=k;break}else $a()}while(0);do if(g){h=c[d+28>>2]|0;j=19144+(h<<2)|0;if((d|0)==(c[j>>2]|0)){c[j>>2]=B;if(!B){c[4711]=c[4711]&~(1<>>0<(c[4714]|0)>>>0)$a();h=g+16|0;if((c[h>>2]|0)==(d|0))c[h>>2]=B;else c[g+20>>2]=B;if(!B)break}if(B>>>0<(c[4714]|0)>>>0)$a();c[B+24>>2]=g;g=c[d+16>>2]|0;do if(g)if(g>>>0<(c[4714]|0)>>>0)$a();else{c[B+16>>2]=g;c[g+24>>2]=B;break}while(0);g=c[d+20>>2]|0;if(g)if(g>>>0<(c[4714]|0)>>>0)$a();else{c[B+20>>2]=g;c[g+24>>2]=B;break}}while(0);if(e>>>0<16){H=e+a|0;c[d+4>>2]=H|3;H=d+(H+4)|0;c[H>>2]=c[H>>2]|1}else{c[d+4>>2]=a|3;c[d+(a|4)>>2]=e|1;c[d+(e+a)>>2]=e;h=c[4712]|0;if(h){g=c[4715]|0;l=h>>>3;j=l<<1;h=18880+(j<<2)|0;k=c[4710]|0;l=1<>2]|0;if(k>>>0<(c[4714]|0)>>>0)$a();else{A=j;z=k}}else{c[4710]=k|l;A=18880+(j+2<<2)|0;z=h}c[A>>2]=g;c[z+12>>2]=g;c[g+8>>2]=z;c[g+12>>2]=h}c[4712]=e;c[4715]=f}H=d+8|0;i=b;return H|0}}}else if(a>>>0<=4294967231){z=a+11|0;a=z&-8;B=c[4711]|0;if(B){A=0-a|0;z=z>>>8;if(z)if(a>>>0>16777215)C=31;else{G=(z+1048320|0)>>>16&8;H=z<>>16&4;H=H<>>16&2;C=14-(F|G|C)+(H<>>15)|0;C=a>>>(C+7|0)&1|C<<1}else C=0;D=c[19144+(C<<2)>>2]|0;a:do if(!D){F=0;z=0}else{if((C|0)==31)z=0;else z=25-(C>>>1)|0;F=0;E=a<>2]&-8;G=H-a|0;if(G>>>0>>0)if((H|0)==(a|0)){A=G;F=D;z=D;break a}else{A=G;z=D}H=c[D+20>>2]|0;D=c[D+(E>>>31<<2)+16>>2]|0;F=(H|0)==0|(H|0)==(D|0)?F:H;if(!D)break;else E=E<<1}}while(0);if((F|0)==0&(z|0)==0){H=2<>>12&16;H=H>>>D;C=H>>>5&8;H=H>>>C;E=H>>>2&4;H=H>>>E;G=H>>>1&2;H=H>>>G;F=H>>>1&1;F=c[19144+((C|D|E|G|F)+(H>>>F)<<2)>>2]|0}if(F)while(1){H=(c[F+4>>2]&-8)-a|0;B=H>>>0>>0;A=B?H:A;z=B?F:z;B=c[F+16>>2]|0;if(B){F=B;continue}F=c[F+20>>2]|0;if(!F)break}if((z|0)!=0?A>>>0<((c[4712]|0)-a|0)>>>0:0){f=c[4714]|0;if(z>>>0>>0)$a();d=z+a|0;if(z>>>0>=d>>>0)$a();e=c[z+24>>2]|0;h=c[z+12>>2]|0;do if((h|0)==(z|0)){h=z+20|0;g=c[h>>2]|0;if(!g){h=z+16|0;g=c[h>>2]|0;if(!g){x=0;break}}while(1){j=g+20|0;k=c[j>>2]|0;if(k){g=k;h=j;continue}j=g+16|0;k=c[j>>2]|0;if(!k)break;else{g=k;h=j}}if(h>>>0>>0)$a();else{c[h>>2]=0;x=g;break}}else{g=c[z+8>>2]|0;if(g>>>0>>0)$a();f=g+12|0;if((c[f>>2]|0)!=(z|0))$a();j=h+8|0;if((c[j>>2]|0)==(z|0)){c[f>>2]=h;c[j>>2]=g;x=h;break}else $a()}while(0);do if(e){g=c[z+28>>2]|0;f=19144+(g<<2)|0;if((z|0)==(c[f>>2]|0)){c[f>>2]=x;if(!x){c[4711]=c[4711]&~(1<>>0<(c[4714]|0)>>>0)$a();f=e+16|0;if((c[f>>2]|0)==(z|0))c[f>>2]=x;else c[e+20>>2]=x;if(!x)break}if(x>>>0<(c[4714]|0)>>>0)$a();c[x+24>>2]=e;e=c[z+16>>2]|0;do if(e)if(e>>>0<(c[4714]|0)>>>0)$a();else{c[x+16>>2]=e;c[e+24>>2]=x;break}while(0);e=c[z+20>>2]|0;if(e)if(e>>>0<(c[4714]|0)>>>0)$a();else{c[x+20>>2]=e;c[e+24>>2]=x;break}}while(0);b:do if(A>>>0>=16){c[z+4>>2]=a|3;c[z+(a|4)>>2]=A|1;c[z+(A+a)>>2]=A;f=A>>>3;if(A>>>0<256){h=f<<1;e=18880+(h<<2)|0;g=c[4710]|0;f=1<>2]|0;if(g>>>0>=(c[4714]|0)>>>0){w=f;v=g;break}$a()}while(0);c[w>>2]=d;c[v+12>>2]=d;c[z+(a+8)>>2]=v;c[z+(a+12)>>2]=e;break}e=A>>>8;if(e)if(A>>>0>16777215)e=31;else{G=(e+1048320|0)>>>16&8;H=e<>>16&4;H=H<>>16&2;e=14-(F|G|e)+(H<>>15)|0;e=A>>>(e+7|0)&1|e<<1}else e=0;f=19144+(e<<2)|0;c[z+(a+28)>>2]=e;c[z+(a+20)>>2]=0;c[z+(a+16)>>2]=0;h=c[4711]|0;g=1<>2]=d;c[z+(a+24)>>2]=f;c[z+(a+12)>>2]=d;c[z+(a+8)>>2]=d;break}f=c[f>>2]|0;if((e|0)==31)e=0;else e=25-(e>>>1)|0;c:do if((c[f+4>>2]&-8|0)!=(A|0)){e=A<>>31<<2)+16|0;h=c[g>>2]|0;if(!h)break;if((c[h+4>>2]&-8|0)==(A|0)){p=h;break c}else{e=e<<1;f=h}}if(g>>>0<(c[4714]|0)>>>0)$a();else{c[g>>2]=d;c[z+(a+24)>>2]=f;c[z+(a+12)>>2]=d;c[z+(a+8)>>2]=d;break b}}else p=f;while(0);f=p+8|0;e=c[f>>2]|0;g=c[4714]|0;if(p>>>0>>0)$a();if(e>>>0>>0)$a();else{c[e+12>>2]=d;c[f>>2]=d;c[z+(a+8)>>2]=e;c[z+(a+12)>>2]=p;c[z+(a+24)>>2]=0;break}}else{H=A+a|0;c[z+4>>2]=H|3;H=z+(H+4)|0;c[H>>2]=c[H>>2]|1}while(0);H=z+8|0;i=b;return H|0}}}else a=-1;while(0);p=c[4712]|0;if(a>>>0<=p>>>0){e=p-a|0;d=c[4715]|0;if(e>>>0>15){c[4715]=d+a;c[4712]=e;c[d+(a+4)>>2]=e|1;c[d+p>>2]=e;c[d+4>>2]=a|3}else{c[4712]=0;c[4715]=0;c[d+4>>2]=p|3;H=d+(p+4)|0;c[H>>2]=c[H>>2]|1}H=d+8|0;i=b;return H|0}p=c[4713]|0;if(a>>>0

>>0){G=p-a|0;c[4713]=G;H=c[4716]|0;c[4716]=H+a;c[H+(a+4)>>2]=G|1;c[H+4>>2]=a|3;H=H+8|0;i=b;return H|0}do if(!(c[4828]|0)){p=Oa(30)|0;if(!(p+ -1&p)){c[4830]=p;c[4829]=p;c[4831]=-1;c[4832]=-1;c[4833]=0;c[4821]=0;c[4828]=(bb(0)|0)&-16^1431655768;break}else $a()}while(0);w=a+48|0;p=c[4830]|0;x=a+47|0;z=p+x|0;p=0-p|0;v=z&p;if(v>>>0<=a>>>0){H=0;i=b;return H|0}A=c[4820]|0;if((A|0)!=0?(G=c[4818]|0,H=G+v|0,H>>>0<=G>>>0|H>>>0>A>>>0):0){H=0;i=b;return H|0}d:do if(!(c[4821]&4)){B=c[4716]|0;e:do if(B){A=19288|0;while(1){C=c[A>>2]|0;if(C>>>0<=B>>>0?(y=A+4|0,(C+(c[y>>2]|0)|0)>>>0>B>>>0):0)break;A=c[A+8>>2]|0;if(!A){o=182;break e}}if(A){B=z-(c[4713]|0)&p;if(B>>>0<2147483647){p=Ia(B|0)|0;A=(p|0)==((c[A>>2]|0)+(c[y>>2]|0)|0);y=p;z=B;p=A?p:-1;A=A?B:0;o=191}else A=0}else o=182}else o=182;while(0);do if((o|0)==182){p=Ia(0)|0;if((p|0)!=(-1|0)){z=p;A=c[4829]|0;y=A+ -1|0;if(!(y&z))A=v;else A=v-z+(y+z&0-A)|0;y=c[4818]|0;z=y+A|0;if(A>>>0>a>>>0&A>>>0<2147483647){H=c[4820]|0;if((H|0)!=0?z>>>0<=y>>>0|z>>>0>H>>>0:0){A=0;break}y=Ia(A|0)|0;o=(y|0)==(p|0);z=A;p=o?p:-1;A=o?A:0;o=191}else A=0}else A=0}while(0);f:do if((o|0)==191){o=0-z|0;if((p|0)!=(-1|0)){q=A;o=202;break d}do if((y|0)!=(-1|0)&z>>>0<2147483647&z>>>0>>0?(u=c[4830]|0,u=x-z+u&0-u,u>>>0<2147483647):0)if((Ia(u|0)|0)==(-1|0)){Ia(o|0)|0;break f}else{z=u+z|0;break}while(0);if((y|0)!=(-1|0)){p=y;q=z;o=202;break d}}while(0);c[4821]=c[4821]|4;o=199}else{A=0;o=199}while(0);if((((o|0)==199?v>>>0<2147483647:0)?(t=Ia(v|0)|0,s=Ia(0)|0,(s|0)!=(-1|0)&(t|0)!=(-1|0)&t>>>0>>0):0)?(r=s-t|0,q=r>>>0>(a+40|0)>>>0,q):0){p=t;q=q?r:A;o=202}if((o|0)==202){r=(c[4818]|0)+q|0;c[4818]=r;if(r>>>0>(c[4819]|0)>>>0)c[4819]=r;r=c[4716]|0;g:do if(r){v=19288|0;while(1){t=c[v>>2]|0;u=v+4|0;s=c[u>>2]|0;if((p|0)==(t+s|0)){o=214;break}w=c[v+8>>2]|0;if(!w)break;else v=w}if(((o|0)==214?(c[v+12>>2]&8|0)==0:0)?r>>>0>=t>>>0&r>>>0

>>0:0){c[u>>2]=s+q;d=(c[4713]|0)+q|0;e=r+8|0;if(!(e&7))e=0;else e=0-e&7;H=d-e|0;c[4716]=r+e;c[4713]=H;c[r+(e+4)>>2]=H|1;c[r+(d+4)>>2]=40;c[4717]=c[4832];break}if(p>>>0<(c[4714]|0)>>>0)c[4714]=p;t=p+q|0;s=19288|0;while(1){if((c[s>>2]|0)==(t|0)){o=224;break}u=c[s+8>>2]|0;if(!u)break;else s=u}if((o|0)==224?(c[s+12>>2]&8|0)==0:0){c[s>>2]=p;h=s+4|0;c[h>>2]=(c[h>>2]|0)+q;h=p+8|0;if(!(h&7))h=0;else h=0-h&7;j=p+(q+8)|0;if(!(j&7))n=0;else n=0-j&7;o=p+(n+q)|0;j=h+a|0;k=p+j|0;m=o-(p+h)-a|0;c[p+(h+4)>>2]=a|3;h:do if((o|0)!=(c[4716]|0)){if((o|0)==(c[4715]|0)){H=(c[4712]|0)+m|0;c[4712]=H;c[4715]=k;c[p+(j+4)>>2]=H|1;c[p+(H+j)>>2]=H;break}r=q+4|0;t=c[p+(r+n)>>2]|0;if((t&3|0)==1){a=t&-8;s=t>>>3;i:do if(t>>>0>=256){l=c[p+((n|24)+q)>>2]|0;u=c[p+(q+12+n)>>2]|0;do if((u|0)==(o|0)){u=n|16;t=p+(r+u)|0;s=c[t>>2]|0;if(!s){t=p+(u+q)|0;s=c[t>>2]|0;if(!s){g=0;break}}while(1){u=s+20|0;v=c[u>>2]|0;if(v){s=v;t=u;continue}u=s+16|0;v=c[u>>2]|0;if(!v)break;else{s=v;t=u}}if(t>>>0<(c[4714]|0)>>>0)$a();else{c[t>>2]=0;g=s;break}}else{t=c[p+((n|8)+q)>>2]|0;if(t>>>0<(c[4714]|0)>>>0)$a();v=t+12|0;if((c[v>>2]|0)!=(o|0))$a();s=u+8|0;if((c[s>>2]|0)==(o|0)){c[v>>2]=u;c[s>>2]=t;g=u;break}else $a()}while(0);if(!l)break;t=c[p+(q+28+n)>>2]|0;s=19144+(t<<2)|0;do if((o|0)!=(c[s>>2]|0)){if(l>>>0<(c[4714]|0)>>>0)$a();s=l+16|0;if((c[s>>2]|0)==(o|0))c[s>>2]=g;else c[l+20>>2]=g;if(!g)break i}else{c[s>>2]=g;if(g)break;c[4711]=c[4711]&~(1<>>0<(c[4714]|0)>>>0)$a();c[g+24>>2]=l;l=n|16;o=c[p+(l+q)>>2]|0;do if(o)if(o>>>0<(c[4714]|0)>>>0)$a();else{c[g+16>>2]=o;c[o+24>>2]=g;break}while(0);l=c[p+(r+l)>>2]|0;if(!l)break;if(l>>>0<(c[4714]|0)>>>0)$a();else{c[g+20>>2]=l;c[l+24>>2]=g;break}}else{r=c[p+((n|8)+q)>>2]|0;g=c[p+(q+12+n)>>2]|0;t=18880+(s<<1<<2)|0;do if((r|0)!=(t|0)){if(r>>>0<(c[4714]|0)>>>0)$a();if((c[r+12>>2]|0)==(o|0))break;$a()}while(0);if((g|0)==(r|0)){c[4710]=c[4710]&~(1<>>0<(c[4714]|0)>>>0)$a();s=g+8|0;if((c[s>>2]|0)==(o|0)){l=s;break}$a()}while(0);c[r+12>>2]=g;c[l>>2]=r}while(0);o=p+((a|n)+q)|0;m=a+m|0}g=o+4|0;c[g>>2]=c[g>>2]&-2;c[p+(j+4)>>2]=m|1;c[p+(m+j)>>2]=m;g=m>>>3;if(m>>>0<256){m=g<<1;d=18880+(m<<2)|0;l=c[4710]|0;g=1<>2]|0;if(g>>>0>=(c[4714]|0)>>>0){f=l;e=g;break}$a()}while(0);c[f>>2]=k;c[e+12>>2]=k;c[p+(j+8)>>2]=e;c[p+(j+12)>>2]=d;break}e=m>>>8;do if(!e)e=0;else{if(m>>>0>16777215){e=31;break}G=(e+1048320|0)>>>16&8;H=e<>>16&4;H=H<>>16&2;e=14-(F|G|e)+(H<>>15)|0;e=m>>>(e+7|0)&1|e<<1}while(0);l=19144+(e<<2)|0;c[p+(j+28)>>2]=e;c[p+(j+20)>>2]=0;c[p+(j+16)>>2]=0;f=c[4711]|0;g=1<>2]=k;c[p+(j+24)>>2]=l;c[p+(j+12)>>2]=k;c[p+(j+8)>>2]=k;break}l=c[l>>2]|0;if((e|0)==31)e=0;else e=25-(e>>>1)|0;j:do if((c[l+4>>2]&-8|0)!=(m|0)){e=m<>>31<<2)+16|0;f=c[g>>2]|0;if(!f)break;if((c[f+4>>2]&-8|0)==(m|0)){d=f;break j}else{e=e<<1;l=f}}if(g>>>0<(c[4714]|0)>>>0)$a();else{c[g>>2]=k;c[p+(j+24)>>2]=l;c[p+(j+12)>>2]=k;c[p+(j+8)>>2]=k;break h}}else d=l;while(0);f=d+8|0;e=c[f>>2]|0;g=c[4714]|0;if(d>>>0>>0)$a();if(e>>>0>>0)$a();else{c[e+12>>2]=k;c[f>>2]=k;c[p+(j+8)>>2]=e;c[p+(j+12)>>2]=d;c[p+(j+24)>>2]=0;break}}else{H=(c[4713]|0)+m|0;c[4713]=H;c[4716]=k;c[p+(j+4)>>2]=H|1}while(0);H=p+(h|8)|0;i=b;return H|0}e=19288|0;while(1){d=c[e>>2]|0;if(d>>>0<=r>>>0?(n=c[e+4>>2]|0,m=d+n|0,m>>>0>r>>>0):0)break;e=c[e+8>>2]|0}e=d+(n+ -39)|0;if(!(e&7))e=0;else e=0-e&7;d=d+(n+ -47+e)|0;d=d>>>0<(r+16|0)>>>0?r:d;e=d+8|0;f=p+8|0;if(!(f&7))f=0;else f=0-f&7;H=q+ -40-f|0;c[4716]=p+f;c[4713]=H;c[p+(f+4)>>2]=H|1;c[p+(q+ -36)>>2]=40;c[4717]=c[4832];c[d+4>>2]=27;c[e+0>>2]=c[4822];c[e+4>>2]=c[4823];c[e+8>>2]=c[4824];c[e+12>>2]=c[4825];c[4822]=p;c[4823]=q;c[4825]=0;c[4824]=e;e=d+28|0;c[e>>2]=7;if((d+32|0)>>>0>>0)do{H=e;e=e+4|0;c[e>>2]=7}while((H+8|0)>>>0>>0);if((d|0)!=(r|0)){d=d-r|0;e=r+(d+4)|0;c[e>>2]=c[e>>2]&-2;c[r+4>>2]=d|1;c[r+d>>2]=d;e=d>>>3;if(d>>>0<256){g=e<<1;d=18880+(g<<2)|0;f=c[4710]|0;e=1<>2]|0;if(e>>>0>=(c[4714]|0)>>>0){k=f;j=e;break}$a()}while(0);c[k>>2]=r;c[j+12>>2]=r;c[r+8>>2]=j;c[r+12>>2]=d;break}e=d>>>8;if(e)if(d>>>0>16777215)e=31;else{G=(e+1048320|0)>>>16&8;H=e<>>16&4;H=H<>>16&2;e=14-(F|G|e)+(H<>>15)|0;e=d>>>(e+7|0)&1|e<<1}else e=0;j=19144+(e<<2)|0;c[r+28>>2]=e;c[r+20>>2]=0;c[r+16>>2]=0;f=c[4711]|0;g=1<>2]=r;c[r+24>>2]=j;c[r+12>>2]=r;c[r+8>>2]=r;break}f=c[j>>2]|0;if((e|0)==31)e=0;else e=25-(e>>>1)|0;k:do if((c[f+4>>2]&-8|0)!=(d|0)){e=d<>>31<<2)+16|0;g=c[j>>2]|0;if(!g)break;if((c[g+4>>2]&-8|0)==(d|0)){h=g;break k}else{e=e<<1;f=g}}if(j>>>0<(c[4714]|0)>>>0)$a();else{c[j>>2]=r;c[r+24>>2]=f;c[r+12>>2]=r;c[r+8>>2]=r;break g}}else h=f;while(0);f=h+8|0;e=c[f>>2]|0;d=c[4714]|0;if(h>>>0>>0)$a();if(e>>>0>>0)$a();else{c[e+12>>2]=r;c[f>>2]=r;c[r+8>>2]=e;c[r+12>>2]=h;c[r+24>>2]=0;break}}}else{H=c[4714]|0;if((H|0)==0|p>>>0>>0)c[4714]=p;c[4822]=p;c[4823]=q;c[4825]=0;c[4719]=c[4828];c[4718]=-1;d=0;do{H=d<<1;G=18880+(H<<2)|0;c[18880+(H+3<<2)>>2]=G;c[18880+(H+2<<2)>>2]=G;d=d+1|0}while((d|0)!=32);d=p+8|0;if(!(d&7))d=0;else d=0-d&7;H=q+ -40-d|0;c[4716]=p+d;c[4713]=H;c[p+(d+4)>>2]=H|1;c[p+(q+ -36)>>2]=40;c[4717]=c[4832]}while(0);d=c[4713]|0;if(d>>>0>a>>>0){G=d-a|0;c[4713]=G;H=c[4716]|0;c[4716]=H+a;c[H+(a+4)>>2]=G|1;c[H+4>>2]=a|3;H=H+8|0;i=b;return H|0}}c[(Xa()|0)>>2]=12;H=0;i=b;return H|0}function OB(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0;b=i;if(!a){i=b;return}q=a+ -8|0;r=c[4714]|0;if(q>>>0>>0)$a();o=c[a+ -4>>2]|0;n=o&3;if((n|0)==1)$a();j=o&-8;h=a+(j+ -8)|0;do if(!(o&1)){u=c[q>>2]|0;if(!n){i=b;return}q=-8-u|0;o=a+q|0;n=u+j|0;if(o>>>0>>0)$a();if((o|0)==(c[4715]|0)){d=a+(j+ -4)|0;if((c[d>>2]&3|0)!=3){d=o;m=n;break}c[4712]=n;c[d>>2]=c[d>>2]&-2;c[a+(q+4)>>2]=n|1;c[h>>2]=n;i=b;return}t=u>>>3;if(u>>>0<256){d=c[a+(q+8)>>2]|0;m=c[a+(q+12)>>2]|0;p=18880+(t<<1<<2)|0;if((d|0)!=(p|0)){if(d>>>0>>0)$a();if((c[d+12>>2]|0)!=(o|0))$a()}if((m|0)==(d|0)){c[4710]=c[4710]&~(1<>>0>>0)$a();p=m+8|0;if((c[p>>2]|0)==(o|0))s=p;else $a()}else s=m+8|0;c[d+12>>2]=m;c[s>>2]=d;d=o;m=n;break}s=c[a+(q+24)>>2]|0;t=c[a+(q+12)>>2]|0;do if((t|0)==(o|0)){u=a+(q+20)|0;t=c[u>>2]|0;if(!t){u=a+(q+16)|0;t=c[u>>2]|0;if(!t){p=0;break}}while(1){w=t+20|0;v=c[w>>2]|0;if(v){t=v;u=w;continue}v=t+16|0;w=c[v>>2]|0;if(!w)break;else{t=w;u=v}}if(u>>>0>>0)$a();else{c[u>>2]=0;p=t;break}}else{u=c[a+(q+8)>>2]|0;if(u>>>0>>0)$a();r=u+12|0;if((c[r>>2]|0)!=(o|0))$a();v=t+8|0;if((c[v>>2]|0)==(o|0)){c[r>>2]=t;c[v>>2]=u;p=t;break}else $a()}while(0);if(s){t=c[a+(q+28)>>2]|0;r=19144+(t<<2)|0;if((o|0)==(c[r>>2]|0)){c[r>>2]=p;if(!p){c[4711]=c[4711]&~(1<>>0<(c[4714]|0)>>>0)$a();r=s+16|0;if((c[r>>2]|0)==(o|0))c[r>>2]=p;else c[s+20>>2]=p;if(!p){d=o;m=n;break}}if(p>>>0<(c[4714]|0)>>>0)$a();c[p+24>>2]=s;r=c[a+(q+16)>>2]|0;do if(r)if(r>>>0<(c[4714]|0)>>>0)$a();else{c[p+16>>2]=r;c[r+24>>2]=p;break}while(0);q=c[a+(q+20)>>2]|0;if(q)if(q>>>0<(c[4714]|0)>>>0)$a();else{c[p+20>>2]=q;c[q+24>>2]=p;d=o;m=n;break}else{d=o;m=n}}else{d=o;m=n}}else{d=q;m=j}while(0);if(d>>>0>=h>>>0)$a();n=a+(j+ -4)|0;o=c[n>>2]|0;if(!(o&1))$a();if(!(o&2)){if((h|0)==(c[4716]|0)){w=(c[4713]|0)+m|0;c[4713]=w;c[4716]=d;c[d+4>>2]=w|1;if((d|0)!=(c[4715]|0)){i=b;return}c[4715]=0;c[4712]=0;i=b;return}if((h|0)==(c[4715]|0)){w=(c[4712]|0)+m|0;c[4712]=w;c[4715]=d;c[d+4>>2]=w|1;c[d+w>>2]=w;i=b;return}m=(o&-8)+m|0;n=o>>>3;do if(o>>>0>=256){l=c[a+(j+16)>>2]|0;q=c[a+(j|4)>>2]|0;do if((q|0)==(h|0)){o=a+(j+12)|0;n=c[o>>2]|0;if(!n){o=a+(j+8)|0;n=c[o>>2]|0;if(!n){k=0;break}}while(1){p=n+20|0;q=c[p>>2]|0;if(q){n=q;o=p;continue}p=n+16|0;q=c[p>>2]|0;if(!q)break;else{n=q;o=p}}if(o>>>0<(c[4714]|0)>>>0)$a();else{c[o>>2]=0;k=n;break}}else{o=c[a+j>>2]|0;if(o>>>0<(c[4714]|0)>>>0)$a();p=o+12|0;if((c[p>>2]|0)!=(h|0))$a();n=q+8|0;if((c[n>>2]|0)==(h|0)){c[p>>2]=q;c[n>>2]=o;k=q;break}else $a()}while(0);if(l){n=c[a+(j+20)>>2]|0;o=19144+(n<<2)|0;if((h|0)==(c[o>>2]|0)){c[o>>2]=k;if(!k){c[4711]=c[4711]&~(1<>>0<(c[4714]|0)>>>0)$a();n=l+16|0;if((c[n>>2]|0)==(h|0))c[n>>2]=k;else c[l+20>>2]=k;if(!k)break}if(k>>>0<(c[4714]|0)>>>0)$a();c[k+24>>2]=l;h=c[a+(j+8)>>2]|0;do if(h)if(h>>>0<(c[4714]|0)>>>0)$a();else{c[k+16>>2]=h;c[h+24>>2]=k;break}while(0);h=c[a+(j+12)>>2]|0;if(h)if(h>>>0<(c[4714]|0)>>>0)$a();else{c[k+20>>2]=h;c[h+24>>2]=k;break}}}else{k=c[a+j>>2]|0;a=c[a+(j|4)>>2]|0;j=18880+(n<<1<<2)|0;if((k|0)!=(j|0)){if(k>>>0<(c[4714]|0)>>>0)$a();if((c[k+12>>2]|0)!=(h|0))$a()}if((a|0)==(k|0)){c[4710]=c[4710]&~(1<>>0<(c[4714]|0)>>>0)$a();j=a+8|0;if((c[j>>2]|0)==(h|0))l=j;else $a()}else l=a+8|0;c[k+12>>2]=a;c[l>>2]=k}while(0);c[d+4>>2]=m|1;c[d+m>>2]=m;if((d|0)==(c[4715]|0)){c[4712]=m;i=b;return}}else{c[n>>2]=o&-2;c[d+4>>2]=m|1;c[d+m>>2]=m}h=m>>>3;if(m>>>0<256){a=h<<1;e=18880+(a<<2)|0;j=c[4710]|0;h=1<>2]|0;if(a>>>0<(c[4714]|0)>>>0)$a();else{f=h;g=a}}else{c[4710]=j|h;f=18880+(a+2<<2)|0;g=e}c[f>>2]=d;c[g+12>>2]=d;c[d+8>>2]=g;c[d+12>>2]=e;i=b;return}f=m>>>8;if(f)if(m>>>0>16777215)f=31;else{v=(f+1048320|0)>>>16&8;w=f<>>16&4;w=w<>>16&2;f=14-(u|v|f)+(w<>>15)|0;f=m>>>(f+7|0)&1|f<<1}else f=0;g=19144+(f<<2)|0;c[d+28>>2]=f;c[d+20>>2]=0;c[d+16>>2]=0;a=c[4711]|0;h=1<>2]|0;if((f|0)==31)f=0;else f=25-(f>>>1)|0;b:do if((c[g+4>>2]&-8|0)!=(m|0)){f=m<>>31<<2)+16|0;g=c[h>>2]|0;if(!g)break;if((c[g+4>>2]&-8|0)==(m|0)){e=g;break b}else{f=f<<1;a=g}}if(h>>>0<(c[4714]|0)>>>0)$a();else{c[h>>2]=d;c[d+24>>2]=a;c[d+12>>2]=d;c[d+8>>2]=d;break a}}else e=g;while(0);g=e+8|0;f=c[g>>2]|0;h=c[4714]|0;if(e>>>0>>0)$a();if(f>>>0>>0)$a();else{c[f+12>>2]=d;c[g>>2]=d;c[d+8>>2]=f;c[d+12>>2]=e;c[d+24>>2]=0;break}}else{c[4711]=a|h;c[g>>2]=d;c[d+24>>2]=g;c[d+12>>2]=d;c[d+8>>2]=d}while(0);w=(c[4718]|0)+ -1|0;c[4718]=w;if(!w)d=19296|0;else{i=b;return}while(1){d=c[d>>2]|0;if(!d)break;else d=d+8|0}c[4718]=-1;i=b;return}function PB(){}function QB(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0;f=b+e|0;if((e|0)>=20){d=d&255;i=b&3;h=d|d<<8|d<<16|d<<24;g=f&~3;if(i){i=b+4-i|0;while((b|0)<(i|0)){a[b>>0]=d;b=b+1|0}}while((b|0)<(g|0)){c[b>>2]=h;b=b+4|0}}while((b|0)<(f|0)){a[b>>0]=d;b=b+1|0}return b-e|0}function RB(b){b=b|0;var c=0;c=b;while(a[c>>0]|0)c=c+1|0;return c-b|0}function SB(b,d,e){b=b|0;d=d|0;e=e|0;var f=0;if((e|0)>=4096)return Ra(b|0,d|0,e|0)|0;f=b|0;if((b&3)==(d&3)){while(b&3){if(!e)return f|0;a[b>>0]=a[d>>0]|0;b=b+1|0;d=d+1|0;e=e-1|0}while((e|0)>=4){c[b>>2]=c[d>>2];b=b+4|0;d=d+4|0;e=e-4|0}}while((e|0)>0){a[b>>0]=a[d>>0]|0;b=b+1|0;d=d+1|0;e=e-1|0}return f|0}function TB(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return gb[a&63](b|0,c|0,d|0)|0}function UB(a,b,c){a=a|0;b=b|0;c=c|0;return ca(0,a|0,b|0,c|0)|0}function VB(a,b,c){a=a|0;b=b|0;c=c|0;return ca(1,a|0,b|0,c|0)|0}function WB(a,b,c){a=a|0;b=b|0;c=c|0;return ca(2,a|0,b|0,c|0)|0}function XB(a,b,c){a=a|0;b=b|0;c=c|0;return ca(3,a|0,b|0,c|0)|0}function YB(a,b,c){a=a|0;b=b|0;c=c|0;return ca(4,a|0,b|0,c|0)|0}function ZB(a,b,c){a=a|0;b=b|0;c=c|0;return ca(5,a|0,b|0,c|0)|0}function _B(a,b,c){a=a|0;b=b|0;c=c|0;return ca(6,a|0,b|0,c|0)|0}function $B(a,b,c){a=a|0;b=b|0;c=c|0;return ca(7,a|0,b|0,c|0)|0}function aC(a,b,c){a=a|0;b=b|0;c=c|0;return ca(8,a|0,b|0,c|0)|0}function bC(a,b,c){a=a|0;b=b|0;c=c|0;return ca(9,a|0,b|0,c|0)|0}function cC(a,b,c){a=a|0;b=b|0;c=c|0;return ca(10,a|0,b|0,c|0)|0}function dC(a,b,c){a=a|0;b=b|0;c=c|0;return ca(11,a|0,b|0,c|0)|0}function eC(a,b,c){a=a|0;b=b|0;c=c|0;return ca(12,a|0,b|0,c|0)|0}function fC(a,b,c){a=a|0;b=b|0;c=c|0;return ca(13,a|0,b|0,c|0)|0}function gC(a,b,c){a=a|0;b=b|0;c=c|0;return ca(14,a|0,b|0,c|0)|0}function hC(a,b,c){a=a|0;b=b|0;c=c|0;return ca(15,a|0,b|0,c|0)|0}function iC(a,b,c){a=a|0;b=b|0;c=c|0;return ca(16,a|0,b|0,c|0)|0}function jC(a,b,c){a=a|0;b=b|0;c=c|0;return ca(17,a|0,b|0,c|0)|0}function kC(a,b,c){a=a|0;b=b|0;c=c|0;return ca(18,a|0,b|0,c|0)|0}function lC(a,b,c){a=a|0;b=b|0;c=c|0;return ca(19,a|0,b|0,c|0)|0}function mC(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;hb[a&63](b|0,c|0,d|0,e|0,f|0)}function nC(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;ca(0,a|0,b|0,c|0,d|0,e|0)}function oC(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;ca(1,a|0,b|0,c|0,d|0,e|0)}function pC(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;ca(2,a|0,b|0,c|0,d|0,e|0)}function qC(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;ca(3,a|0,b|0,c|0,d|0,e|0)}function rC(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;ca(4,a|0,b|0,c|0,d|0,e|0)}function sC(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;ca(5,a|0,b|0,c|0,d|0,e|0)}function tC(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;ca(6,a|0,b|0,c|0,d|0,e|0)}function uC(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;ca(7,a|0,b|0,c|0,d|0,e|0)}function vC(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;ca(8,a|0,b|0,c|0,d|0,e|0)}function wC(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;ca(9,a|0,b|0,c|0,d|0,e|0)}function xC(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;ca(10,a|0,b|0,c|0,d|0,e|0)}function yC(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;ca(11,a|0,b|0,c|0,d|0,e|0)}function zC(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;ca(12,a|0,b|0,c|0,d|0,e|0)}function AC(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;ca(13,a|0,b|0,c|0,d|0,e|0)}function BC(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;ca(14,a|0,b|0,c|0,d|0,e|0)}function CC(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;ca(15,a|0,b|0,c|0,d|0,e|0)}function DC(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;ca(16,a|0,b|0,c|0,d|0,e|0)}function EC(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;ca(17,a|0,b|0,c|0,d|0,e|0)}function FC(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;ca(18,a|0,b|0,c|0,d|0,e|0)}function GC(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;ca(19,a|0,b|0,c|0,d|0,e|0)}function HC(a,b,c){a=a|0;b=b|0;c=+c;return+ib[a&63](b|0,+c)}function IC(a,b){a=a|0;b=+b;return+ca(0,a|0,+b)}function JC(a,b){a=a|0;b=+b;return+ca(1,a|0,+b)}function KC(a,b){a=a|0;b=+b;return+ca(2,a|0,+b)}function LC(a,b){a=a|0;b=+b;return+ca(3,a|0,+b)}function MC(a,b){a=a|0;b=+b;return+ca(4,a|0,+b)}function NC(a,b){a=a|0;b=+b;return+ca(5,a|0,+b)}function OC(a,b){a=a|0;b=+b;return+ca(6,a|0,+b)}function PC(a,b){a=a|0;b=+b;return+ca(7,a|0,+b)}function QC(a,b){a=a|0;b=+b;return+ca(8,a|0,+b)}function RC(a,b){a=a|0;b=+b;return+ca(9,a|0,+b)}function SC(a,b){a=a|0;b=+b;return+ca(10,a|0,+b)}function TC(a,b){a=a|0;b=+b;return+ca(11,a|0,+b)}function UC(a,b){a=a|0;b=+b;return+ca(12,a|0,+b)}function VC(a,b){a=a|0;b=+b;return+ca(13,a|0,+b)}function WC(a,b){a=a|0;b=+b;return+ca(14,a|0,+b)}function XC(a,b){a=a|0;b=+b;return+ca(15,a|0,+b)}function YC(a,b){a=a|0;b=+b;return+ca(16,a|0,+b)}function ZC(a,b){a=a|0;b=+b;return+ca(17,a|0,+b)}function _C(a,b){a=a|0;b=+b;return+ca(18,a|0,+b)}function $C(a,b){a=a|0;b=+b;return+ca(19,a|0,+b)}function aD(a,b){a=a|0;b=b|0;jb[a&127](b|0)}function bD(a){a=a|0;ca(0,a|0)}function cD(a){a=a|0;ca(1,a|0)}function dD(a){a=a|0;ca(2,a|0)}function eD(a){a=a|0;ca(3,a|0)}function fD(a){a=a|0;ca(4,a|0)}function gD(a){a=a|0;ca(5,a|0)}function hD(a){a=a|0;ca(6,a|0)}function iD(a){a=a|0;ca(7,a|0)}function jD(a){a=a|0;ca(8,a|0)}function kD(a){a=a|0;ca(9,a|0)}function lD(a){a=a|0;ca(10,a|0)}function mD(a){a=a|0;ca(11,a|0)}function nD(a){a=a|0;ca(12,a|0)}function oD(a){a=a|0;ca(13,a|0)}function pD(a){a=a|0;ca(14,a|0)}function qD(a){a=a|0;ca(15,a|0)}function rD(a){a=a|0;ca(16,a|0)}function sD(a){a=a|0;ca(17,a|0)}function tD(a){a=a|0;ca(18,a|0)}function uD(a){a=a|0;ca(19,a|0)}function vD(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=+f;return+kb[a&63](b|0,c|0,d|0,e|0,+f)}function wD(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;return+ca(0,a|0,b|0,c|0,d|0,+e)}function xD(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;return+ca(1,a|0,b|0,c|0,d|0,+e)}function yD(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;return+ca(2,a|0,b|0,c|0,d|0,+e)}function zD(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;return+ca(3,a|0,b|0,c|0,d|0,+e)}function AD(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;return+ca(4,a|0,b|0,c|0,d|0,+e)}function BD(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;return+ca(5,a|0,b|0,c|0,d|0,+e)}function CD(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;return+ca(6,a|0,b|0,c|0,d|0,+e)}function DD(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;return+ca(7,a|0,b|0,c|0,d|0,+e)}function ED(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;return+ca(8,a|0,b|0,c|0,d|0,+e)}function FD(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;return+ca(9,a|0,b|0,c|0,d|0,+e)}function GD(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;return+ca(10,a|0,b|0,c|0,d|0,+e)}function HD(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;return+ca(11,a|0,b|0,c|0,d|0,+e)}function ID(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;return+ca(12,a|0,b|0,c|0,d|0,+e)}function JD(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;return+ca(13,a|0,b|0,c|0,d|0,+e)}function KD(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;return+ca(14,a|0,b|0,c|0,d|0,+e)}function LD(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;return+ca(15,a|0,b|0,c|0,d|0,+e)}function MD(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;return+ca(16,a|0,b|0,c|0,d|0,+e)}function ND(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;return+ca(17,a|0,b|0,c|0,d|0,+e)}function OD(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;return+ca(18,a|0,b|0,c|0,d|0,+e)}function PD(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;return+ca(19,a|0,b|0,c|0,d|0,+e)}function QD(a,b,c){a=a|0;b=b|0;c=c|0;lb[a&127](b|0,c|0)}function RD(a,b){a=a|0;b=b|0;ca(0,a|0,b|0)}function SD(a,b){a=a|0;b=b|0;ca(1,a|0,b|0)}function TD(a,b){a=a|0;b=b|0;ca(2,a|0,b|0)}function UD(a,b){a=a|0;b=b|0;ca(3,a|0,b|0)}function VD(a,b){a=a|0;b=b|0;ca(4,a|0,b|0)}function WD(a,b){a=a|0;b=b|0;ca(5,a|0,b|0)}function XD(a,b){a=a|0;b=b|0;ca(6,a|0,b|0)}function YD(a,b){a=a|0;b=b|0;ca(7,a|0,b|0)}function ZD(a,b){a=a|0;b=b|0;ca(8,a|0,b|0)}function _D(a,b){a=a|0;b=b|0;ca(9,a|0,b|0)}function $D(a,b){a=a|0;b=b|0;ca(10,a|0,b|0)}function aE(a,b){a=a|0;b=b|0;ca(11,a|0,b|0)}function bE(a,b){a=a|0;b=b|0;ca(12,a|0,b|0)}function cE(a,b){a=a|0;b=b|0;ca(13,a|0,b|0)}function dE(a,b){a=a|0;b=b|0;ca(14,a|0,b|0)}function eE(a,b){a=a|0;b=b|0;ca(15,a|0,b|0)}function fE(a,b){a=a|0;b=b|0;ca(16,a|0,b|0)}function gE(a,b){a=a|0;b=b|0;ca(17,a|0,b|0)}function hE(a,b){a=a|0;b=b|0;ca(18,a|0,b|0)}function iE(a,b){a=a|0;b=b|0;ca(19,a|0,b|0)}function jE(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=+d;e=e|0;f=f|0;mb[a&63](b|0,c|0,+d,e|0,f|0)}function kE(a,b,c,d,e){a=a|0;b=b|0;c=+c;d=d|0;e=e|0;ca(0,a|0,b|0,+c,d|0,e|0)}function lE(a,b,c,d,e){a=a|0;b=b|0;c=+c;d=d|0;e=e|0;ca(1,a|0,b|0,+c,d|0,e|0)}function mE(a,b,c,d,e){a=a|0;b=b|0;c=+c;d=d|0;e=e|0;ca(2,a|0,b|0,+c,d|0,e|0)}function nE(a,b,c,d,e){a=a|0;b=b|0;c=+c;d=d|0;e=e|0;ca(3,a|0,b|0,+c,d|0,e|0)}function oE(a,b,c,d,e){a=a|0;b=b|0;c=+c;d=d|0;e=e|0;ca(4,a|0,b|0,+c,d|0,e|0)}function pE(a,b,c,d,e){a=a|0;b=b|0;c=+c;d=d|0;e=e|0;ca(5,a|0,b|0,+c,d|0,e|0)}function qE(a,b,c,d,e){a=a|0;b=b|0;c=+c;d=d|0;e=e|0;ca(6,a|0,b|0,+c,d|0,e|0)}function rE(a,b,c,d,e){a=a|0;b=b|0;c=+c;d=d|0;e=e|0;ca(7,a|0,b|0,+c,d|0,e|0)}function sE(a,b,c,d,e){a=a|0;b=b|0;c=+c;d=d|0;e=e|0;ca(8,a|0,b|0,+c,d|0,e|0)}function tE(a,b,c,d,e){a=a|0;b=b|0;c=+c;d=d|0;e=e|0;ca(9,a|0,b|0,+c,d|0,e|0)}function uE(a,b,c,d,e){a=a|0;b=b|0;c=+c;d=d|0;e=e|0;ca(10,a|0,b|0,+c,d|0,e|0)}function vE(a,b,c,d,e){a=a|0;b=b|0;c=+c;d=d|0;e=e|0;ca(11,a|0,b|0,+c,d|0,e|0)}function wE(a,b,c,d,e){a=a|0;b=b|0;c=+c;d=d|0;e=e|0;ca(12,a|0,b|0,+c,d|0,e|0)}function xE(a,b,c,d,e){a=a|0;b=b|0;c=+c;d=d|0;e=e|0;ca(13,a|0,b|0,+c,d|0,e|0)}function yE(a,b,c,d,e){a=a|0;b=b|0;c=+c;d=d|0;e=e|0;ca(14,a|0,b|0,+c,d|0,e|0)}function zE(a,b,c,d,e){a=a|0;b=b|0;c=+c;d=d|0;e=e|0;ca(15,a|0,b|0,+c,d|0,e|0)}function AE(a,b,c,d,e){a=a|0;b=b|0;c=+c;d=d|0;e=e|0;ca(16,a|0,b|0,+c,d|0,e|0)}function BE(a,b,c,d,e){a=a|0;b=b|0;c=+c;d=d|0;e=e|0;ca(17,a|0,b|0,+c,d|0,e|0)}function CE(a,b,c,d,e){a=a|0;b=b|0;c=+c;d=d|0;e=e|0;ca(18,a|0,b|0,+c,d|0,e|0)}function DE(a,b,c,d,e){a=a|0;b=b|0;c=+c;d=d|0;e=e|0;ca(19,a|0,b|0,+c,d|0,e|0)}function EE(a,b){a=a|0;b=b|0;return nb[a&63](b|0)|0}function FE(a){a=a|0;return ca(0,a|0)|0}function GE(a){a=a|0;return ca(1,a|0)|0}function HE(a){a=a|0;return ca(2,a|0)|0}function IE(a){a=a|0;return ca(3,a|0)|0}function JE(a){a=a|0;return ca(4,a|0)|0}function KE(a){a=a|0;return ca(5,a|0)|0}function LE(a){a=a|0;return ca(6,a|0)|0}function ME(a){a=a|0;return ca(7,a|0)|0}function NE(a){a=a|0;return ca(8,a|0)|0}function OE(a){a=a|0;return ca(9,a|0)|0}function PE(a){a=a|0;return ca(10,a|0)|0}function QE(a){a=a|0;return ca(11,a|0)|0}function RE(a){a=a|0;return ca(12,a|0)|0}function SE(a){a=a|0;return ca(13,a|0)|0}function TE(a){a=a|0;return ca(14,a|0)|0}function UE(a){a=a|0;return ca(15,a|0)|0}function VE(a){a=a|0;return ca(16,a|0)|0}function WE(a){a=a|0;return ca(17,a|0)|0}function XE(a){a=a|0;return ca(18,a|0)|0}function YE(a){a=a|0;return ca(19,a|0)|0}function ZE(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=+d;e=e|0;ob[a&63](b|0,c|0,+d,e|0)}function _E(a,b,c,d){a=a|0;b=b|0;c=+c;d=d|0;ca(0,a|0,b|0,+c,d|0)}function $E(a,b,c,d){a=a|0;b=b|0;c=+c;d=d|0;ca(1,a|0,b|0,+c,d|0)}function aF(a,b,c,d){a=a|0;b=b|0;c=+c;d=d|0;ca(2,a|0,b|0,+c,d|0)}function bF(a,b,c,d){a=a|0;b=b|0;c=+c;d=d|0;ca(3,a|0,b|0,+c,d|0)}function cF(a,b,c,d){a=a|0;b=b|0;c=+c;d=d|0;ca(4,a|0,b|0,+c,d|0)}function dF(a,b,c,d){a=a|0;b=b|0;c=+c;d=d|0;ca(5,a|0,b|0,+c,d|0)}function eF(a,b,c,d){a=a|0;b=b|0;c=+c;d=d|0;ca(6,a|0,b|0,+c,d|0)}function fF(a,b,c,d){a=a|0;b=b|0;c=+c;d=d|0;ca(7,a|0,b|0,+c,d|0)}function gF(a,b,c,d){a=a|0;b=b|0;c=+c;d=d|0;ca(8,a|0,b|0,+c,d|0)}function hF(a,b,c,d){a=a|0;b=b|0;c=+c;d=d|0;ca(9,a|0,b|0,+c,d|0)}function iF(a,b,c,d){a=a|0;b=b|0;c=+c;d=d|0;ca(10,a|0,b|0,+c,d|0)}function jF(a,b,c,d){a=a|0;b=b|0;c=+c;d=d|0;ca(11,a|0,b|0,+c,d|0)}function kF(a,b,c,d){a=a|0;b=b|0;c=+c;d=d|0;ca(12,a|0,b|0,+c,d|0)}function lF(a,b,c,d){a=a|0;b=b|0;c=+c;d=d|0;ca(13,a|0,b|0,+c,d|0)}function mF(a,b,c,d){a=a|0;b=b|0;c=+c;d=d|0;ca(14,a|0,b|0,+c,d|0)}function nF(a,b,c,d){a=a|0;b=b|0;c=+c;d=d|0;ca(15,a|0,b|0,+c,d|0)}function oF(a,b,c,d){a=a|0;b=b|0;c=+c;d=d|0;ca(16,a|0,b|0,+c,d|0)}function pF(a,b,c,d){a=a|0;b=b|0;c=+c;d=d|0;ca(17,a|0,b|0,+c,d|0)}function qF(a,b,c,d){a=a|0;b=b|0;c=+c;d=d|0;ca(18,a|0,b|0,+c,d|0)}function rF(a,b,c,d){a=a|0;b=b|0;c=+c;d=d|0;ca(19,a|0,b|0,+c,d|0)}function sF(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;pb[a&63](b|0,c|0,d|0)}function tF(a,b,c){a=a|0;b=b|0;c=c|0;ca(0,a|0,b|0,c|0)}function uF(a,b,c){a=a|0;b=b|0;c=c|0;ca(1,a|0,b|0,c|0)}function vF(a,b,c){a=a|0;b=b|0;c=c|0;ca(2,a|0,b|0,c|0)}function wF(a,b,c){a=a|0;b=b|0;c=c|0;ca(3,a|0,b|0,c|0)}function xF(a,b,c){a=a|0;b=b|0;c=c|0;ca(4,a|0,b|0,c|0)}function yF(a,b,c){a=a|0;b=b|0;c=c|0;ca(5,a|0,b|0,c|0)}function zF(a,b,c){a=a|0;b=b|0;c=c|0;ca(6,a|0,b|0,c|0)}function AF(a,b,c){a=a|0;b=b|0;c=c|0;ca(7,a|0,b|0,c|0)}function BF(a,b,c){a=a|0;b=b|0;c=c|0;ca(8,a|0,b|0,c|0)}function CF(a,b,c){a=a|0;b=b|0;c=c|0;ca(9,a|0,b|0,c|0)}function DF(a,b,c){a=a|0;b=b|0;c=c|0;ca(10,a|0,b|0,c|0)}function EF(a,b,c){a=a|0;b=b|0;c=c|0;ca(11,a|0,b|0,c|0)}function FF(a,b,c){a=a|0;b=b|0;c=c|0;ca(12,a|0,b|0,c|0)}function GF(a,b,c){a=a|0;b=b|0;c=c|0;ca(13,a|0,b|0,c|0)}function HF(a,b,c){a=a|0;b=b|0;c=c|0;ca(14,a|0,b|0,c|0)}function IF(a,b,c){a=a|0;b=b|0;c=c|0;ca(15,a|0,b|0,c|0)}function JF(a,b,c){a=a|0;b=b|0;c=c|0;ca(16,a|0,b|0,c|0)}function KF(a,b,c){a=a|0;b=b|0;c=c|0;ca(17,a|0,b|0,c|0)}function LF(a,b,c){a=a|0;b=b|0;c=c|0;ca(18,a|0,b|0,c|0)}function MF(a,b,c){a=a|0;b=b|0;c=c|0;ca(19,a|0,b|0,c|0)}function NF(a){a=a|0;qb[a&63]()}function OF(){ca(0)}function PF(){ca(1)}function QF(){ca(2)}function RF(){ca(3)}function SF(){ca(4)}function TF(){ca(5)}function UF(){ca(6)}function VF(){ca(7)}function WF(){ca(8)}function XF(){ca(9)}function YF(){ca(10)}function ZF(){ca(11)}function _F(){ca(12)}function $F(){ca(13)}function aG(){ca(14)}function bG(){ca(15)}function cG(){ca(16)}function dG(){ca(17)}function eG(){ca(18)}function fG(){ca(19)}function gG(a,b,c,d){a=a|0;b=b|0;c=c|0;d=+d;rb[a&63](b|0,c|0,+d)}function hG(a,b,c){a=a|0;b=b|0;c=+c;ca(0,a|0,b|0,+c)}function iG(a,b,c){a=a|0;b=b|0;c=+c;ca(1,a|0,b|0,+c)}function jG(a,b,c){a=a|0;b=b|0;c=+c;ca(2,a|0,b|0,+c)}function kG(a,b,c){a=a|0;b=b|0;c=+c;ca(3,a|0,b|0,+c)}function lG(a,b,c){a=a|0;b=b|0;c=+c;ca(4,a|0,b|0,+c)}function mG(a,b,c){a=a|0;b=b|0;c=+c;ca(5,a|0,b|0,+c)}function nG(a,b,c){a=a|0;b=b|0;c=+c;ca(6,a|0,b|0,+c)}function oG(a,b,c){a=a|0;b=b|0;c=+c;ca(7,a|0,b|0,+c)}function pG(a,b,c){a=a|0;b=b|0;c=+c;ca(8,a|0,b|0,+c)}function qG(a,b,c){a=a|0;b=b|0;c=+c;ca(9,a|0,b|0,+c)}function rG(a,b,c){a=a|0;b=b|0;c=+c;ca(10,a|0,b|0,+c)}function sG(a,b,c){a=a|0;b=b|0;c=+c;ca(11,a|0,b|0,+c)}function tG(a,b,c){a=a|0;b=b|0;c=+c;ca(12,a|0,b|0,+c)}function uG(a,b,c){a=a|0;b=b|0;c=+c;ca(13,a|0,b|0,+c)}function vG(a,b,c){a=a|0;b=b|0;c=+c;ca(14,a|0,b|0,+c)}function wG(a,b,c){a=a|0;b=b|0;c=+c;ca(15,a|0,b|0,+c)}function xG(a,b,c){a=a|0;b=b|0;c=+c;ca(16,a|0,b|0,+c)}function yG(a,b,c){a=a|0;b=b|0;c=+c;ca(17,a|0,b|0,+c)}function zG(a,b,c){a=a|0;b=b|0;c=+c;ca(18,a|0,b|0,+c)}function AG(a,b,c){a=a|0;b=b|0;c=+c;ca(19,a|0,b|0,+c)}function BG(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;sb[a&63](b|0,c|0,d|0,e|0,f|0,g|0)}function CG(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;ca(0,a|0,b|0,c|0,d|0,e|0,f|0)}function DG(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;ca(1,a|0,b|0,c|0,d|0,e|0,f|0)}function EG(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;ca(2,a|0,b|0,c|0,d|0,e|0,f|0)}function FG(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;ca(3,a|0,b|0,c|0,d|0,e|0,f|0)}function GG(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;ca(4,a|0,b|0,c|0,d|0,e|0,f|0)}function HG(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;ca(5,a|0,b|0,c|0,d|0,e|0,f|0)}function IG(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;ca(6,a|0,b|0,c|0,d|0,e|0,f|0)}function JG(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;ca(7,a|0,b|0,c|0,d|0,e|0,f|0)}function KG(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;ca(8,a|0,b|0,c|0,d|0,e|0,f|0)}function LG(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;ca(9,a|0,b|0,c|0,d|0,e|0,f|0)}function MG(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;ca(10,a|0,b|0,c|0,d|0,e|0,f|0)}function NG(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;ca(11,a|0,b|0,c|0,d|0,e|0,f|0)}function OG(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;ca(12,a|0,b|0,c|0,d|0,e|0,f|0)}function PG(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;ca(13,a|0,b|0,c|0,d|0,e|0,f|0)}function QG(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;ca(14,a|0,b|0,c|0,d|0,e|0,f|0)}function RG(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;ca(15,a|0,b|0,c|0,d|0,e|0,f|0)}function SG(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;ca(16,a|0,b|0,c|0,d|0,e|0,f|0)}function TG(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;ca(17,a|0,b|0,c|0,d|0,e|0,f|0)}function UG(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;ca(18,a|0,b|0,c|0,d|0,e|0,f|0)}function VG(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;ca(19,a|0,b|0,c|0,d|0,e|0,f|0)}function WG(a,b,c){a=a|0;b=b|0;c=c|0;return tb[a&63](b|0,c|0)|0}function XG(a,b){a=a|0;b=b|0;return ca(0,a|0,b|0)|0}function YG(a,b){a=a|0;b=b|0;return ca(1,a|0,b|0)|0}function ZG(a,b){a=a|0;b=b|0;return ca(2,a|0,b|0)|0}function _G(a,b){a=a|0;b=b|0;return ca(3,a|0,b|0)|0}function $G(a,b){a=a|0;b=b|0;return ca(4,a|0,b|0)|0}function aH(a,b){a=a|0;b=b|0;return ca(5,a|0,b|0)|0}function bH(a,b){a=a|0;b=b|0;return ca(6,a|0,b|0)|0}function cH(a,b){a=a|0;b=b|0;return ca(7,a|0,b|0)|0}function dH(a,b){a=a|0;b=b|0;return ca(8,a|0,b|0)|0}function eH(a,b){a=a|0;b=b|0;return ca(9,a|0,b|0)|0}function fH(a,b){a=a|0;b=b|0;return ca(10,a|0,b|0)|0}function gH(a,b){a=a|0;b=b|0;return ca(11,a|0,b|0)|0}function hH(a,b){a=a|0;b=b|0;return ca(12,a|0,b|0)|0}function iH(a,b){a=a|0;b=b|0;return ca(13,a|0,b|0)|0}function jH(a,b){a=a|0;b=b|0;return ca(14,a|0,b|0)|0}function kH(a,b){a=a|0;b=b|0;return ca(15,a|0,b|0)|0}function lH(a,b){a=a|0;b=b|0;return ca(16,a|0,b|0)|0}function mH(a,b){a=a|0;b=b|0;return ca(17,a|0,b|0)|0}function nH(a,b){a=a|0;b=b|0;return ca(18,a|0,b|0)|0}function oH(a,b){a=a|0;b=b|0;return ca(19,a|0,b|0)|0}function pH(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return ub[a&63](b|0,c|0,d|0,e|0,f|0)|0}function qH(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return ca(0,a|0,b|0,c|0,d|0,e|0)|0}function rH(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return ca(1,a|0,b|0,c|0,d|0,e|0)|0}function sH(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return ca(2,a|0,b|0,c|0,d|0,e|0)|0}function tH(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return ca(3,a|0,b|0,c|0,d|0,e|0)|0}function uH(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return ca(4,a|0,b|0,c|0,d|0,e|0)|0}function vH(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return ca(5,a|0,b|0,c|0,d|0,e|0)|0}function wH(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return ca(6,a|0,b|0,c|0,d|0,e|0)|0}function xH(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return ca(7,a|0,b|0,c|0,d|0,e|0)|0}function yH(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return ca(8,a|0,b|0,c|0,d|0,e|0)|0}function zH(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return ca(9,a|0,b|0,c|0,d|0,e|0)|0}function AH(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return ca(10,a|0,b|0,c|0,d|0,e|0)|0}function BH(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return ca(11,a|0,b|0,c|0,d|0,e|0)|0}function CH(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return ca(12,a|0,b|0,c|0,d|0,e|0)|0}function DH(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return ca(13,a|0,b|0,c|0,d|0,e|0)|0}function EH(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return ca(14,a|0,b|0,c|0,d|0,e|0)|0}function FH(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return ca(15,a|0,b|0,c|0,d|0,e|0)|0}function GH(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return ca(16,a|0,b|0,c|0,d|0,e|0)|0}function HH(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return ca(17,a|0,b|0,c|0,d|0,e|0)|0}function IH(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return ca(18,a|0,b|0,c|0,d|0,e|0)|0}function JH(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return ca(19,a|0,b|0,c|0,d|0,e|0)|0}function KH(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;vb[a&63](b|0,c|0,d|0,e|0)}function LH(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;ca(0,a|0,b|0,c|0,d|0)}function MH(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;ca(1,a|0,b|0,c|0,d|0)}function NH(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;ca(2,a|0,b|0,c|0,d|0)}function OH(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;ca(3,a|0,b|0,c|0,d|0)}function PH(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;ca(4,a|0,b|0,c|0,d|0)}function QH(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;ca(5,a|0,b|0,c|0,d|0)}function RH(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;ca(6,a|0,b|0,c|0,d|0)}function SH(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;ca(7,a|0,b|0,c|0,d|0)}function TH(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;ca(8,a|0,b|0,c|0,d|0)}function UH(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;ca(9,a|0,b|0,c|0,d|0)}function VH(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;ca(10,a|0,b|0,c|0,d|0)}function WH(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;ca(11,a|0,b|0,c|0,d|0)}function XH(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;ca(12,a|0,b|0,c|0,d|0)}function YH(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;ca(13,a|0,b|0,c|0,d|0)}function ZH(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;ca(14,a|0,b|0,c|0,d|0)}function _H(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;ca(15,a|0,b|0,c|0,d|0)}function $H(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;ca(16,a|0,b|0,c|0,d|0)}function aI(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;ca(17,a|0,b|0,c|0,d|0)}function bI(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;ca(18,a|0,b|0,c|0,d|0)}function cI(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;ca(19,a|0,b|0,c|0,d|0)}function dI(a,b,c){a=a|0;b=b|0;c=c|0;$(0);return 0}function eI(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;$(1)}function fI(a,b){a=a|0;b=+b;$(2);return 0.0}function gI(a){a=a|0;$(3)}function hI(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;$(4);return 0.0}function iI(a,b){a=a|0;b=b|0;$(5)}function jI(a,b,c,d,e){a=a|0;b=b|0;c=+c;d=d|0;e=e|0;$(6)}function kI(a){a=a|0;$(7);return 0}function lI(a,b,c,d){a=a|0;b=b|0;c=+c;d=d|0;$(8)}function mI(a,b,c){a=a|0;b=b|0;c=c|0;$(9)}function nI(){$(10)}function oI(){eb()}function pI(a,b,c){a=a|0;b=b|0;c=+c;$(11)}function qI(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;$(12)}function rI(a,b){a=a|0;b=b|0;$(13);return 0}function sI(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;$(14);return 0}function tI(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;$(15)} var gb=[dI,dI,UB,dI,VB,dI,WB,dI,XB,dI,YB,dI,ZB,dI,_B,dI,$B,dI,aC,dI,bC,dI,cC,dI,dC,dI,eC,dI,fC,dI,gC,dI,hC,dI,iC,dI,jC,dI,kC,dI,lC,dI,hw,lx,rx,xx,Dx,wy,vB,dI,dI,dI,dI,dI,dI,dI,dI,dI,dI,dI,dI,dI,dI,dI];var hb=[eI,eI,nC,eI,oC,eI,pC,eI,qC,eI,rC,eI,sC,eI,tC,eI,uC,eI,vC,eI,wC,eI,xC,eI,yC,eI,zC,eI,AC,eI,BC,eI,CC,eI,DC,eI,EC,eI,FC,eI,GC,eI,HB,GB,DB,eI,eI,eI,eI,eI,eI,eI,eI,eI,eI,eI,eI,eI,eI,eI,eI,eI,eI,eI];var ib=[fI,fI,IC,fI,JC,fI,KC,fI,LC,fI,MC,fI,NC,fI,OC,fI,PC,fI,QC,fI,RC,fI,SC,fI,TC,fI,UC,fI,VC,fI,WC,fI,XC,fI,YC,fI,ZC,fI,_C,fI,$C,fI,Mw,pz,zz,Jz,Wz,fA,pA,AA,KA,UA,cB,fI,fI,fI,fI,fI,fI,fI,fI,fI,fI,fI];var jb=[gI,gI,bD,gI,cD,gI,dD,gI,eD,gI,fD,gI,gD,gI,hD,gI,iD,gI,jD,gI,kD,gI,lD,gI,mD,gI,nD,gI,oD,gI,pD,gI,qD,gI,rD,gI,sD,gI,tD,gI,uD,gI,Zv,_v,fw,gw,ow,pw,uw,vw,xw,yw,Aw,Bw,Nw,Pw,Qw,gx,fx,mw,nw,iw,jw,kw,lw,Wx,fy,Vx,iy,Ay,By,Fy,Gy,Ky,Ly,Uy,Vy,Zy,_y,cz,dz,hz,iz,qz,rz,sz,Az,Bz,Cz,Kz,Lz,Mz,Nz,Oz,Pz,Yz,Zz,_z,gA,hA,iA,qA,sA,tA,BA,CA,DA,LA,MA,NA,VA,WA,XA,dB,eB,fB,lB,kB,pB,sB,qB,rB,tB,uB,jB,gI,gI,gI];var kb=[hI,hI,wD,hI,xD,hI,yD,hI,zD,hI,AD,hI,BD,hI,CD,hI,DD,hI,ED,hI,FD,hI,GD,hI,HD,hI,ID,hI,JD,hI,KD,hI,LD,hI,MD,hI,ND,hI,OD,hI,PD,hI,ww,hI,hI,hI,hI,hI,hI,hI,hI,hI,hI,hI,hI,hI,hI,hI,hI,hI,hI,hI,hI,hI];var lb=[iI,iI,RD,iI,SD,iI,TD,iI,UD,iI,VD,iI,WD,iI,XD,iI,YD,iI,ZD,iI,_D,iI,$D,iI,aE,iI,bE,iI,cE,iI,dE,iI,eE,iI,fE,iI,gE,iI,hE,iI,iE,iI,ew,qw,rw,Cw,Dw,Ew,Fw,Jw,Kw,Ow,Gw,Hw,gy,hy,mz,nz,jz,kz,wz,xz,tz,uz,Gz,Hz,Dz,Ez,Tz,Uz,Xz,Qz,Rz,cA,dA,$z,aA,mA,nA,rA,jA,kA,xA,yA,uA,vA,HA,IA,EA,FA,RA,SA,OA,PA,$A,aB,YA,ZA,Iy,az,fz,Sy,Xy,yy,Dy,iI,iI,iI,iI,iI,iI,iI,iI,iI,iI,iI,iI,iI,iI,iI,iI,iI,iI,iI,iI,iI,iI,iI];var mb=[jI,jI,kE,jI,lE,jI,mE,jI,nE,jI,oE,jI,pE,jI,qE,jI,rE,jI,sE,jI,tE,jI,uE,jI,vE,jI,wE,jI,xE,jI,yE,jI,zE,jI,AE,jI,BE,jI,CE,jI,DE,jI,cw,jI,jI,jI,jI,jI,jI,jI,jI,jI,jI,jI,jI,jI,jI,jI,jI,jI,jI,jI,jI,jI];var nb=[kI,kI,FE,kI,GE,kI,HE,kI,IE,kI,JE,kI,KE,kI,LE,kI,ME,kI,NE,kI,OE,kI,PE,kI,QE,kI,RE,kI,SE,kI,TE,kI,UE,kI,VE,kI,WE,kI,XE,kI,YE,kI,jx,qx,wx,Cx,mB,kI,kI,kI,kI,kI,kI,kI,kI,kI,kI,kI,kI,kI,kI,kI,kI,kI];var ob=[lI,lI,_E,lI,$E,lI,aF,lI,bF,lI,cF,lI,dF,lI,eF,lI,fF,lI,gF,lI,hF,lI,iF,lI,jF,lI,kF,lI,lF,lI,mF,lI,nF,lI,oF,lI,pF,lI,qF,lI,rF,lI,bw,lI,lI,lI,lI,lI,lI,lI,lI,lI,lI,lI,lI,lI,lI,lI,lI,lI,lI,lI,lI,lI];var pb=[mI,mI,tF,mI,uF,mI,vF,mI,wF,mI,xF,mI,yF,mI,zF,mI,AF,mI,BF,mI,CF,mI,DF,mI,EF,mI,FF,mI,GF,mI,HF,mI,IF,mI,JF,mI,KF,mI,LF,mI,MF,mI,sw,tw,mI,mI,mI,mI,mI,mI,mI,mI,mI,mI,mI,mI,mI,mI,mI,mI,mI,mI,mI,mI];var qb=[nI,nI,OF,nI,PF,nI,QF,nI,RF,nI,SF,nI,TF,nI,UF,nI,VF,nI,WF,nI,XF,nI,YF,nI,ZF,nI,_F,nI,$F,nI,aG,nI,bG,nI,cG,nI,dG,nI,eG,nI,fG,nI,oI,hB,iB,nI,nI,nI,nI,nI,nI,nI,nI,nI,nI,nI,nI,nI,nI,nI,nI,nI,nI,nI];var rb=[pI,pI,hG,pI,iG,pI,jG,pI,kG,pI,lG,pI,mG,pI,nG,pI,oG,pI,pG,pI,qG,pI,rG,pI,sG,pI,tG,pI,uG,pI,vG,pI,wG,pI,xG,pI,yG,pI,zG,pI,AG,pI,Lw,ox,ux,Ax,Gx,oz,yz,Iz,Vz,eA,oA,zA,JA,TA,bB,pI,pI,pI,pI,pI,pI,pI];var sb=[qI,qI,CG,qI,DG,qI,EG,qI,FG,qI,GG,qI,HG,qI,IG,qI,JG,qI,KG,qI,LG,qI,MG,qI,NG,qI,OG,qI,PG,qI,QG,qI,RG,qI,SG,qI,TG,qI,UG,qI,VG,qI,KB,JB,IB,qI,qI,qI,qI,qI,qI,qI,qI,qI,qI,qI,qI,qI,qI,qI,qI,qI,qI,qI];var tb=[rI,rI,XG,rI,YG,rI,ZG,rI,_G,rI,$G,rI,aH,rI,bH,rI,cH,rI,dH,rI,eH,rI,fH,rI,gH,rI,hH,rI,iH,rI,jH,rI,kH,rI,lH,rI,mH,rI,nH,rI,oH,rI,zw,Iw,ix,px,vx,Bx,lz,vz,Fz,Sz,bA,lA,wA,GA,QA,_A,Zx,rI,rI,rI,rI,rI];var ub=[sI,sI,qH,sI,rH,sI,sH,sI,tH,sI,uH,sI,vH,sI,wH,sI,xH,sI,yH,sI,zH,sI,AH,sI,BH,sI,CH,sI,DH,sI,EH,sI,FH,sI,GH,sI,HH,sI,IH,sI,JH,sI,mx,sx,yx,Ex,Hy,$y,ez,Ry,Wy,xy,Cy,sI,sI,sI,sI,sI,sI,sI,sI,sI,sI,sI];var vb=[tI,tI,LH,tI,MH,tI,NH,tI,OH,tI,PH,tI,QH,tI,RH,tI,SH,tI,TH,tI,UH,tI,VH,tI,WH,tI,XH,tI,YH,tI,ZH,tI,_H,tI,$H,tI,aI,tI,bI,tI,cI,tI,$v,aw,dw,nx,tx,zx,Fx,zy,Ey,Jy,Ty,Yy,bz,gz,xB,yB,AB,tI,tI,tI,tI,tI];return{_emscripten_bind_b2WheelJoint_GetSpringDampingRatio_0:hq,_emscripten_bind_b2ContactEdge_set_next_1:Cu,_emscripten_bind_b2ChainShape_get_m_count_0:pn,_emscripten_bind_b2Fixture_SetFriction_1:Jc,_emscripten_bind_b2Shape_ComputeAABB_3:Cr,_emscripten_bind_b2FrictionJointDef_set_userData_1:Bg,_emscripten_bind_b2Vec3_get_z_0:Jf,_emscripten_bind_b2World_IsLocked_0:ei,_emscripten_bind_b2Draw_GetFlags_0:Ck,_emscripten_bind_b2FrictionJoint_IsActive_0:vt,_emscripten_bind_b2Color_set_g_1:Kn,_emscripten_bind_b2WheelJointDef_get_frequencyHz_0:Dj,_emscripten_bind_b2RopeJointDef_set_localAnchorA_1:Gu,_emscripten_bind_b2PolygonShape_RayCast_4:vo,_emscripten_bind_b2World_GetTreeBalance_0:ai,_emscripten_bind_b2PrismaticJointDef_get_upperTranslation_0:fh,_emscripten_bind_JSDraw_DrawSolidCircle_4:Qp,_emscripten_bind_b2RevoluteJoint_GetLocalAnchorA_0:Rt,_emscripten_bind_b2FixtureDef_get_filter_0:lg,_emscripten_bind_b2FrictionJointDef_get_type_0:yg,_emscripten_bind_b2RevoluteJoint_GetMotorTorque_1:fu,_emscripten_bind_b2MotorJointDef_set_type_1:hv,_emscripten_bind_b2RayCastInput_get_p1_0:fo,_emscripten_bind_b2EdgeShape_set_m_hasVertex3_1:_o,_emscripten_bind_b2JointEdge_set_joint_1:Pl,_emscripten_enum_b2ShapeType_e_polygon:tv,_emscripten_bind_b2Fixture___destroy___0:Oc,_emscripten_bind_b2PulleyJoint_SetUserData_1:Lq,_emscripten_bind_b2World_SetWarmStarting_1:Rh,_emscripten_bind_JSDraw_DrawCircle_3:Pp,_emscripten_bind_b2WeldJoint_IsActive_0:Il,_emscripten_bind_b2DestructionListener___destroy___0:yt,_emscripten_bind_b2BodyDef_set_type_1:ue,_emscripten_bind_b2ChainShape_ComputeAABB_3:ln,_emscripten_bind_b2MouseJointDef_set_type_1:Zq,_emscripten_bind_b2JointEdge_get_prev_0:Ql,_emscripten_bind_b2WeldJoint_GetReactionTorque_1:El,_emscripten_bind_b2MotorJointDef_get_maxForce_0:av,_emscripten_bind_b2DistanceJointDef_get_userData_0:Xr,_emscripten_bind_b2BodyDef_get_position_0:ve,_emscripten_bind_b2RopeJointDef_get_localAnchorB_0:Hu,_emscripten_bind_b2RevoluteJointDef_set_userData_1:Ep,_emscripten_bind_b2RevoluteJointDef_get_localAnchorA_0:jp,_emscripten_bind_b2World_SetContactFilter_1:Ah,_emscripten_bind_b2WheelJointDef_get_collideConnected_0:Pj,_emscripten_bind_b2MouseJointDef_set_userData_1:$q,_emscripten_bind_JSDraw_DrawSegment_3:Rp,_emscripten_bind_b2FixtureDef_set_restitution_1:gg,_emscripten_bind_b2MotorJointDef_Initialize_2:Xu,_emscripten_bind_b2EdgeShape_GetChildCount_0:Ko,_emscripten_bind_b2Mat33_get_ey_0:nc,_emscripten_bind_b2MouseJoint_IsActive_0:qd,_emscripten_bind_b2World_GetGravity_0:di,_emscripten_bind_b2World_DrawDebugData_0:Jh,_emscripten_bind_b2Profile_get_broadphase_0:me,_emscripten_bind_b2PulleyJointDef_get_bodyA_0:nm,_emscripten_bind_b2PrismaticJoint_SetLimits_2:ui,_emscripten_bind_b2PulleyJointDef_get_localAnchorA_0:$l,_emscripten_bind_b2DistanceJoint_GetAnchorA_0:Wb,_emscripten_bind_b2ManifoldPoint_set_tangentImpulse_1:Bm,_emscripten_bind_b2PolygonShape_get_m_count_0:Ao,_emscripten_bind_b2RopeJointDef_set_collideConnected_1:Uu,_emscripten_bind_b2CircleShape_set_m_p_1:_j,_emscripten_bind_JSContactListener_EndContact_1:aj,_emscripten_bind_b2MassData_set_mass_1:Ik,_emscripten_bind_b2Vec3_get_x_0:Ff,_emscripten_bind_b2ChainShape_CreateChain_2:cn,_emscripten_bind_b2Color_get_r_0:Hn,_emscripten_bind_b2World_DestroyBody_1:Eh,_emscripten_bind_b2Profile_get_solvePosition_0:ke,_emscripten_bind_b2Shape_RayCast_4:Br,_emscripten_bind_b2PulleyJoint_GetGroundAnchorA_0:vq,_emscripten_bind_b2Mat33___destroy___0:rc,_emscripten_bind_b2GearJoint_GetReactionTorque_1:jl,_emscripten_bind_b2WeldJointDef_set_collideConnected_1:zk,_emscripten_bind_b2Manifold_get_type_0:Og,_emscripten_bind_b2RevoluteJoint___destroy___0:su,_emscripten_bind_b2PulleyJointDef_b2PulleyJointDef_0:Vl,_emscripten_bind_b2World_SetAutoClearForces_1:fi,_emscripten_bind_b2PrismaticJointDef_set_lowerTranslation_1:eh,_emscripten_bind_b2BodyDef_set_position_1:we,_emscripten_bind_b2Transform_get_q_0:Ym,_emscripten_bind_b2FrictionJoint_GetMaxForce_0:it,_emscripten_bind_b2PolygonShape_set_m_count_1:Bo,_emscripten_bind_b2Contact_GetNext_0:lr,_emscripten_bind_b2MotorJointDef_set_userData_1:jv,_emscripten_bind_b2EdgeShape_get_m_type_0:$o,_emscripten_bind_b2GearJoint_GetJoint1_0:$k,_emscripten_bind_b2WheelJoint_GetMaxMotorTorque_0:cq,_emscripten_bind_b2MotorJoint_SetMaxTorque_1:Ld,_emscripten_bind_b2GearJoint_GetAnchorA_0:gl,_emscripten_enum_b2JointType_e_mouseJoint:Bv,_emscripten_bind_b2MouseJointDef_set_bodyA_1:br,_emscripten_enum_b2JointType_e_revoluteJoint:xv,_emscripten_bind_b2World_SetContactListener_1:Bh,_emscripten_bind_b2Body_IsAwake_0:Us,_emscripten_bind_b2JointEdge_set_other_1:Nl,_emscripten_bind_b2RevoluteJoint_IsMotorEnabled_0:$t,_emscripten_bind_b2MouseJointDef_set_target_1:Rq,_emscripten_bind_b2MotorJoint_SetCorrectionFactor_1:Nd,_emscripten_bind_b2FixtureDef_get_density_0:hg,_emscripten_bind_b2ChainShape_set_m_vertices_1:on,_emscripten_bind_b2ChainShape_get_m_vertices_0:nn,_emscripten_bind_b2Rot_set_s_1:Bd,_emscripten_bind_b2MotorJointDef_get_collideConnected_0:ov,_emscripten_bind_b2RevoluteJoint_GetUpperLimit_0:Zt,_emscripten_bind_b2WheelJointDef_set_bodyB_1:Oj,_emscripten_bind_b2WheelJointDef_set_enableMotor_1:yj,_emscripten_bind_b2FixtureDef_get_userData_0:bg,_emscripten_bind_b2FrictionJointDef_set_collideConnected_1:Hg,_emscripten_bind_b2PrismaticJointDef_get_lowerTranslation_0:dh,_emscripten_bind_b2GearJoint_GetCollideConnected_0:ol,_emscripten_bind_b2RevoluteJointDef_get_upperAngle_0:tp,_emscripten_bind_b2Body_ApplyAngularImpulse_2:vs,_emscripten_enum_b2JointType_e_frictionJoint:Fv,_emscripten_bind_b2RayCastOutput_set_fraction_1:Si,_emscripten_bind_b2Color_set_r_1:In,_emscripten_bind_b2DistanceJointDef_get_length_0:Pr,_emscripten_bind_b2PulleyJoint_GetBodyB_0:Eq,_emscripten_bind_b2WheelJointDef_set_type_1:Ij,_emscripten_bind_b2World_GetTreeQuality_0:bi,_emscripten_bind_b2BodyDef_set_gravityScale_1:Ue,_emscripten_bind_b2RopeJointDef_set_bodyB_1:Su,_emscripten_bind_b2PrismaticJoint_GetLowerLimit_0:si,_emscripten_bind_b2AABB_get_lowerBound_0:Vf,_emscripten_bind_b2WheelJoint_SetMotorSpeed_1:$p,_emscripten_bind_b2PrismaticJointDef_get_referenceAngle_0:$g,_emscripten_bind_b2Body_SetMassData_1:zs,_emscripten_bind_b2BodyDef_get_angularVelocity_0:Be,_emscripten_bind_b2WeldJoint_SetDampingRatio_1:vl,_emscripten_bind_b2PrismaticJointDef___destroy___0:xh,_emscripten_bind_b2Contact_IsTouching_0:ir,_emscripten_bind_b2Draw_SetFlags_1:Bk,_emscripten_bind_b2AABB_Contains_1:Tf,_emscripten_bind_b2DistanceJoint_GetNext_0:_b,_emscripten_bind_b2GearJoint_GetReactionForce_1:il,_emscripten_bind_b2PrismaticJoint_GetNext_0:Ji,_emscripten_bind_b2Filter_get_groupIndex_0:Uc,_emscripten_bind_b2PrismaticJoint_GetType_0:Ci,_emscripten_bind_b2Fixture_GetRestitution_0:Kc,_emscripten_bind_b2Transform_set_q_1:Zm,_emscripten_bind_b2PolygonShape___destroy___0:Go,_emscripten_bind_b2AABB_get_upperBound_0:Xf,_emscripten_bind_b2Transform___destroy___0:_m,_emscripten_bind_b2WeldJointDef_set_localAnchorB_1:jk,_emscripten_bind_b2CircleShape_set_m_radius_1:ck,_emscripten_bind_b2EdgeShape_set_m_hasVertex0_1:Yo,_emscripten_bind_b2RopeJoint_GetMaxLength_0:Rn,_emscripten_bind_b2GearJoint_GetUserData_0:ll,_emscripten_bind_b2MotorJoint_GetCollideConnected_0:_d,_emscripten_bind_b2GearJointDef_set_type_1:Ht,_emscripten_bind_b2DistanceJoint_SetDampingRatio_1:Rb,_emscripten_bind_b2Contact_GetFixtureA_0:mr,_emscripten_bind_b2QueryCallback___destroy___0:Fm,_emscripten_bind_b2PulleyJointDef_get_ratio_0:hm,_emscripten_bind_b2PrismaticJointDef_get_localAnchorB_0:Xg,_emscripten_bind_b2CircleShape_set_m_type_1:ak,_emscripten_enum_b2ShapeType_e_typeCount:vv,_emscripten_bind_b2Body_SetTransform_2:hs,_emscripten_bind_b2RopeJoint_GetAnchorB_0:Xn,_emscripten_bind_b2AABB_set_upperBound_1:Yf,_emscripten_bind_b2MouseJointDef_get_collideConnected_0:er,_emscripten_bind_b2ContactImpulse___destroy___0:Kb,_emscripten_bind_b2PrismaticJointDef_b2PrismaticJointDef_0:Tg,_emscripten_bind_b2Vec2_set_x_1:uf,_emscripten_bind_b2RayCastInput___destroy___0:lo,_emscripten_bind_b2Body_ApplyForceToCenter_2:ss,_emscripten_bind_JSDestructionListener_JSDestructionListener_0:Eb,_emscripten_bind_b2WheelJointDef_set_localAnchorA_1:sj,_emscripten_bind_b2FrictionJoint_GetBodyB_0:nt,_emscripten_bind_b2DistanceJointDef_get_bodyA_0:Zr,_emscripten_bind_b2WeldJointDef_set_bodyA_1:vk,_emscripten_bind_b2World_SetDestructionListener_1:zh,_emscripten_bind_b2RevoluteJoint_GetJointSpeed_0:Vt,_emscripten_bind_b2WheelJoint_GetLocalAnchorB_0:Vp,_emscripten_bind_b2JointDef___destroy___0:Rm,_emscripten_bind_b2PrismaticJointDef_Initialize_4:Ug,_emscripten_bind_b2FrictionJointDef_get_localAnchorA_0:qg,_emscripten_bind_b2CircleShape_GetChildCount_0:Uj,_emscripten_bind_b2BodyDef_get_bullet_0:Ne,_emscripten_bind_b2ManifoldPoint_get_localPoint_0:wm,_emscripten_bind_b2PrismaticJointDef_get_type_0:nh,_emscripten_bind_b2MassData_get_center_0:Jk,_emscripten_bind_b2World_b2World_1:yh,_emscripten_bind_b2WheelJoint_GetReactionForce_1:nq,_emscripten_bind_b2World_SetSubStepping_1:Vh,_emscripten_bind_b2Vec2_op_add_1:lf,_emscripten_bind_b2Joint_GetBodyA_0:Pk,_emscripten_bind_b2Joint_GetCollideConnected_0:Zk,_emscripten_bind_b2MotorJoint_GetReactionTorque_1:Vd,_emscripten_bind_b2WheelJoint_IsMotorEnabled_0:Zp,_emscripten_bind_b2WheelJointDef___destroy___0:Rj,_emscripten_bind_b2Vec3_SetZero_0:Af,_emscripten_enum_b2JointType_e_pulleyJoint:Av,_emscripten_bind_b2ChainShape_get_m_nextVertex_0:tn,_emscripten_bind_b2Contact_SetEnabled_1:jr,_emscripten_bind_b2Shape_set_m_radius_1:Hr,_emscripten_bind_b2GearJointDef_get_joint2_0:Ct,_emscripten_bind_b2World_SetDebugDraw_1:Ch,_emscripten_bind_b2ContactID_set_key_1:Xi,_emscripten_bind_b2RevoluteJointDef_set_collideConnected_1:Kp,_malloc:NB,_emscripten_bind_b2World_GetProxyCount_0:Xh,_emscripten_bind_b2Vec2_Normalize_0:qf,_emscripten_bind_b2WheelJoint_GetJointSpeed_0:Yp,_emscripten_bind_b2FrictionJointDef_set_localAnchorA_1:rg,_emscripten_bind_b2GearJoint_GetRatio_0:cl,_emscripten_bind_JSRayCastCallback_JSRayCastCallback_0:We,_emscripten_bind_b2RayCastInput_set_p2_1:io,_emscripten_bind_b2RevoluteJointDef_get_motorSpeed_0:xp,_emscripten_bind_b2RayCastOutput_get_normal_0:Pi,_emscripten_bind_b2WeldJoint_GetBodyA_0:zl,_emscripten_bind_b2MotorJointDef_set_maxForce_1:bv,_emscripten_enum_b2DrawFlag_e_jointBit:Tv,_emscripten_bind_b2FixtureDef_get_isSensor_0:jg,_emscripten_bind_b2PulleyJointDef_set_bodyB_1:qm,_emscripten_bind_b2WheelJoint_EnableMotor_1:_p,_emscripten_bind_b2WheelJoint_GetLocalAnchorA_0:Up,_emscripten_bind_JSDraw_DrawSolidPolygon_3:Op,_emscripten_bind_b2Rot_Set_1:vd,_emscripten_bind_b2ContactFeature_set_typeB_1:ef,_emscripten_bind_JSDraw___destroy___0:Tp,_emscripten_bind_b2MouseJointDef___destroy___0:gr,_emscripten_bind_b2Mat33_Solve22_1:ic,_emscripten_bind_b2Profile_set_solvePosition_1:le,_emscripten_bind_b2ContactFilter___destroy___0:tu,_emscripten_bind_b2PulleyJointDef_get_localAnchorB_0:bm,_emscripten_bind_b2ChainShape_set_m_hasPrevVertex_1:wn,_emscripten_bind_b2PrismaticJoint___destroy___0:Oi,_emscripten_bind_b2World_CreateJoint_1:Fh,_emscripten_bind_b2Profile_get_solveTOI_0:oe,_emscripten_bind_b2ManifoldPoint_get_id_0:Cm,_emscripten_bind_b2Manifold_set_pointCount_1:Rg,_emscripten_bind_b2PrismaticJoint_GetMotorSpeed_0:yi,_emscripten_bind_b2Body_SetSleepingAllowed_1:Rs,_emscripten_bind_b2Rot_SetIdentity_0:wd,_emscripten_bind_b2PulleyJoint_GetGroundAnchorB_0:wq,_emscripten_bind_b2Vec3_op_add_1:Cf,_emscripten_bind_b2FrictionJoint_GetType_0:lt,_emscripten_bind_b2DistanceJointDef_set_dampingRatio_1:Ur,_emscripten_bind_b2MotorJoint_GetBodyA_0:Qd,_emscripten_bind_b2MouseJointDef_get_dampingRatio_0:Wq,_emscripten_bind_b2RevoluteJoint_GetMotorSpeed_0:cu,_emscripten_bind_b2ChainShape_set_m_type_1:An,_emscripten_bind_b2RevoluteJointDef_set_bodyB_1:Ip,_emscripten_bind_b2Body_GetGravityScale_0:Ls,_emscripten_bind_b2GearJointDef_get_bodyB_0:Mt,_emscripten_bind_b2Mat33_b2Mat33_0:ec,_emscripten_bind_b2MouseJointDef_get_bodyB_0:cr,_emscripten_bind_b2Shape_TestPoint_2:Ar,_emscripten_bind_b2Body_GetWorldVector_1:Cs,_emscripten_bind_b2WeldJointDef_get_frequencyHz_0:mk,_emscripten_bind_b2PolygonShape_Set_2:no,_emscripten_bind_b2Manifold___destroy___0:Sg,_emscripten_bind_b2PulleyJointDef_set_lengthA_1:em,_emscripten_bind_b2RevoluteJointDef_set_localAnchorA_1:kp,_emscripten_bind_b2GearJoint___destroy___0:pl,_emscripten_bind_b2RevoluteJoint_GetJointAngle_0:Ut,_emscripten_bind_b2PulleyJointDef_set_ratio_1:im,_emscripten_bind_b2JointEdge_set_prev_1:Rl,_emscripten_bind_b2PrismaticJoint_GetReactionTorque_1:Ii,_emscripten_bind_b2Body_GetLocalPoint_1:Ds,_emscripten_bind_b2PrismaticJoint_GetCollideConnected_0:Ni,_emscripten_bind_b2RopeJointDef_get_userData_0:Nu,_emscripten_bind_b2DistanceJoint_IsActive_0:bc,_emscripten_bind_b2MotorJointDef_set_angularOffset_1:$u,_emscripten_bind_b2Vec2_b2Vec2_2:hf,_emscripten_bind_b2PrismaticJoint_GetJointTranslation_0:oi,_emscripten_bind_b2Vec2_b2Vec2_0:gf,_emscripten_bind_b2DistanceJoint_GetAnchorB_0:Xb,_emscripten_bind_b2WheelJointDef_get_maxMotorTorque_0:zj,_emscripten_bind_b2Vec2_op_sub_1:mf,_emscripten_bind_b2CircleShape_get_m_p_0:Zj,_emscripten_bind_b2ContactFeature_get_indexA_0:Ze,_emscripten_bind_b2MotorJointDef_b2MotorJointDef_0:Wu,_emscripten_bind_b2ChainShape_set_m_nextVertex_1:un,_emscripten_bind_b2PulleyJoint_GetCollideConnected_0:Nq,_emscripten_bind_b2PulleyJoint_GetAnchorB_0:Gq,_emscripten_bind_b2Mat33_get_ex_0:lc,_emscripten_bind_b2Body_GetPosition_0:js,_emscripten_bind_b2Profile___destroy___0:qe,_emscripten_bind_b2ContactEdge_get_prev_0:zu,_emscripten_bind_b2DistanceJoint_SetFrequency_1:Pb,_emscripten_enum_b2ShapeType_e_chain:uv,_emscripten_enum_b2ContactFeatureType_e_vertex:Xv,_emscripten_bind_b2Fixture_GetBody_0:zc,_emscripten_bind_b2ContactImpulse_set_count_1:Jb,_emscripten_bind_b2PulleyJointDef_get_bodyB_0:pm,_emscripten_bind_b2Rot_set_c_1:Dd,_emscripten_bind_b2RevoluteJoint_GetReactionTorque_1:mu,_emscripten_bind_b2Fixture_SetDensity_1:Gc,_emscripten_bind_b2ChainShape_get_m_prevVertex_0:rn,_emscripten_bind_b2World_ClearForces_0:Ih,_emscripten_bind_b2Vec3___destroy___0:Lf,_emscripten_bind_b2WheelJointDef_set_userData_1:Kj,_emscripten_bind_b2WeldJoint_SetFrequency_1:tl,_emscripten_bind_b2WheelJoint_SetSpringFrequencyHz_1:eq,_emscripten_bind_b2Body_SetFixedRotation_1:Xs,_emscripten_bind_b2RayCastOutput_set_normal_1:Qi,_emscripten_bind_b2DistanceJoint_GetDampingRatio_0:Sb,_emscripten_bind_b2WeldJointDef_set_userData_1:tk,_emscripten_bind_b2Body_GetMassData_1:ys,_emscripten_bind_b2MouseJointDef_set_bodyB_1:dr,_emscripten_bind_b2CircleShape_GetType_0:Tj,_emscripten_bind_b2PolygonShape_GetType_0:so,_emscripten_bind_b2PrismaticJointDef_set_referenceAngle_1:ah,_emscripten_bind_b2RopeJointDef_get_collideConnected_0:Tu,_emscripten_bind_b2FixtureDef_set_filter_1:mg,_emscripten_bind_b2PulleyJointDef_get_groundAnchorA_0:Xl,_emscripten_bind_b2Fixture_SetFilterData_1:wc,_emscripten_bind_b2FrictionJointDef_get_userData_0:Ag,_emscripten_bind_b2RayCastCallback___destroy___0:ql,_emscripten_bind_b2PulleyJointDef_set_localAnchorA_1:am,_emscripten_bind_b2MotorJoint_SetUserData_1:Yd,_emscripten_bind_b2PrismaticJoint_GetLocalAxisA_0:mi,_emscripten_bind_b2MotorJoint_GetBodyB_0:Rd,_emscripten_bind_b2Transform_Set_2:Vm,_emscripten_bind_b2MouseJoint_SetTarget_1:_c,_emscripten_bind_b2RopeJointDef_get_localAnchorA_0:Fu,_emscripten_bind_b2ContactEdge_set_contact_1:yu,_emscripten_bind_b2RevoluteJointDef_get_enableLimit_0:pp,_emscripten_bind_b2CircleShape_get_m_radius_0:bk,_emscripten_bind_b2RevoluteJoint_GetUserData_0:ou,_emscripten_bind_b2Profile_set_solveTOI_1:pe,_emscripten_bind_b2PrismaticJointDef_set_type_1:oh,_emscripten_bind_b2GearJointDef_get_userData_0:It,_emscripten_bind_b2RevoluteJoint_GetAnchorB_0:ku,_emscripten_bind_b2FrictionJointDef___destroy___0:Ig,_emscripten_bind_b2PrismaticJoint_GetReactionForce_1:Hi,_emscripten_bind_b2Transform_b2Transform_0:Sm,_emscripten_bind_b2MouseJoint_GetCollideConnected_0:rd,_emscripten_enum_b2LimitState_e_equalLimits:Lv,_emscripten_bind_b2ManifoldPoint_set_normalImpulse_1:zm,_emscripten_bind_b2Body_GetContactList_0:$s,_emscripten_bind_b2Body_IsFixedRotation_0:Ys,_emscripten_enum_b2DrawFlag_e_shapeBit:Sv,_emscripten_bind_b2Contact_GetFriction_0:rr,_emscripten_bind_b2WheelJoint_GetAnchorB_0:mq,_emscripten_bind_b2DistanceJointDef_set_length_1:Qr,_emscripten_bind_b2DistanceJoint_GetLocalAnchorB_0:Mb,_emscripten_bind_b2FrictionJoint_GetLocalAnchorB_0:gt,_emscripten_bind_b2Mat33_set_ey_1:oc,_emscripten_bind_b2DistanceJointDef_get_type_0:Vr,_emscripten_bind_b2Draw_ClearFlags_1:Ek,_emscripten_bind_b2Body_IsActive_0:Ws,_emscripten_bind_b2Contact_ResetRestitution_0:vr,_emscripten_bind_b2World_GetAllowSleeping_0:Qh,_emscripten_bind_b2ManifoldPoint_b2ManifoldPoint_0:vm,_emscripten_bind_b2PrismaticJointDef_set_maxMotorForce_1:kh,_emscripten_bind_b2GearJointDef_set_bodyA_1:Lt,_emscripten_bind_b2RevoluteJointDef_set_enableMotor_1:wp,_emscripten_bind_b2PulleyJoint_IsActive_0:Mq,_emscripten_bind_b2MouseJoint_GetNext_0:nd,_emscripten_bind_b2Transform_set_p_1:Xm,_emscripten_bind_b2EdgeShape_set_m_vertex0_1:Uo,_emscripten_bind_b2PulleyJointDef_get_lengthB_0:fm,_emscripten_bind_b2WeldJoint_SetUserData_1:Hl,_emscripten_bind_b2Fixture_SetSensor_1:uc,_emscripten_bind_b2GearJointDef_get_joint1_0:At,_emscripten_bind_b2PrismaticJoint_GetMotorForce_1:Bi,_emscripten_bind_b2DistanceJoint_GetBodyA_0:Ub,_emscripten_bind_b2GearJoint_IsActive_0:nl,_emscripten_bind_b2EdgeShape_get_m_vertex0_0:To,_emscripten_bind_b2World_GetBodyCount_0:Yh,_emscripten_bind_b2Fixture_GetMassData_1:Fc,_emscripten_bind_b2WeldJointDef_get_collideConnected_0:yk,_emscripten_bind_b2FrictionJoint_GetMaxTorque_0:kt,_emscripten_bind_b2EdgeShape_RayCast_4:Mo,_emscripten_bind_b2BodyDef_set_allowSleep_1:Ie,_emscripten_bind_b2PulleyJoint_GetType_0:Cq,_emscripten_bind_b2WeldJointDef_set_localAnchorA_1:hk,_emscripten_bind_b2Profile_set_step_1:be,_emscripten_bind_b2ContactEdge_set_other_1:wu,_emscripten_bind_b2PulleyJoint_GetCurrentLengthB_0:Bq,_emscripten_bind_b2Vec2_op_mul_1:nf,_emscripten_bind_b2PrismaticJointDef_get_localAnchorA_0:Vg,_emscripten_bind_b2EdgeShape___destroy___0:dp,_emscripten_bind_b2RopeJoint_GetAnchorA_0:Wn,_emscripten_bind_b2World_GetContactCount_0:_h,_emscripten_bind_b2MotorJointDef_set_correctionFactor_1:fv,_emscripten_bind_b2DistanceJointDef_set_userData_1:Yr,_emscripten_bind_b2ContactEdge_get_other_0:vu,_emscripten_bind_b2RopeJoint_GetLocalAnchorB_0:Pn,_emscripten_bind_b2PulleyJointDef___destroy___0:tm,_emscripten_bind_b2MouseJoint_GetBodyB_0:id,_emscripten_bind_b2PolygonShape_TestPoint_2:uo,_emscripten_bind_b2EdgeShape_set_m_vertex3_1:Wo,_emscripten_bind_b2PolygonShape_b2PolygonShape_0:mo,_emscripten_bind_b2GearJointDef_set_ratio_1:Ft,_emscripten_bind_b2WheelJoint_SetMaxMotorTorque_1:bq,_emscripten_bind_b2WheelJointDef_get_localAxisA_0:vj,_emscripten_bind_b2DistanceJointDef_get_localAnchorA_0:Lr,_emscripten_bind_b2MassData_set_center_1:Kk,_emscripten_bind_b2Contact_SetTangentSpeed_1:wr,_emscripten_bind_b2FrictionJointDef_get_localAnchorB_0:sg,_emscripten_bind_b2BodyDef_get_active_0:Pe,_emscripten_bind_b2Body_GetAngularVelocity_0:qs,_emscripten_bind_b2WeldJoint_GetBodyB_0:Al,_emscripten_bind_b2Draw___destroy___0:Fk,_emscripten_bind_b2WheelJointDef_Initialize_4:qj,_emscripten_bind_b2WeldJointDef_set_dampingRatio_1:pk,_emscripten_bind_b2Contact_IsEnabled_0:kr,_emscripten_bind_b2Joint_GetAnchorB_0:Sk,_emscripten_bind_b2PrismaticJointDef_get_userData_0:ph,_emscripten_bind_b2MotorJoint_GetMaxForce_0:Kd,_emscripten_bind_b2RevoluteJoint_GetBodyA_0:hu,_emscripten_bind_b2ContactID_set_cf_1:Vi,_emscripten_bind_b2Rot_GetXAxis_0:yd,_emscripten_bind_b2ContactEdge_set_prev_1:Au,_emscripten_bind_b2Vec3_Set_3:Bf,_emscripten_bind_b2Fixture_GetNext_0:Ac,_emscripten_bind_b2FrictionJointDef_set_localAnchorB_1:tg,_emscripten_bind_b2PulleyJoint_GetNext_0:Jq,_emscripten_bind_b2ChainShape_get_m_type_0:zn,_emscripten_bind_b2GearJointDef_get_bodyA_0:Kt,_emscripten_bind_b2DistanceJointDef_set_frequencyHz_1:Sr,_emscripten_bind_b2RevoluteJointDef_get_localAnchorB_0:lp,_emscripten_bind_b2RevoluteJointDef_get_referenceAngle_0:np,_emscripten_bind_JSContactFilter___destroy___0:gp,_memset:QB,_emscripten_bind_b2PolygonShape_get_m_radius_0:Eo,_emscripten_bind_b2RopeJoint_GetUserData_0:$n,_emscripten_bind_b2RopeJointDef_get_bodyA_0:Pu,_emscripten_bind_b2DistanceJointDef_get_dampingRatio_0:Tr,_emscripten_enum_b2ManifoldType_e_faceA:Nv,_emscripten_enum_b2ManifoldType_e_faceB:Ov,_emscripten_bind_b2RevoluteJointDef_get_bodyB_0:Hp,_emscripten_bind_b2FixtureDef_b2FixtureDef_0:_f,_emscripten_bind_b2PrismaticJoint_SetUserData_1:Li,_emscripten_bind_b2EdgeShape_get_m_hasVertex3_0:Zo,_emscripten_enum_b2ShapeType_e_edge:sv,_emscripten_bind_b2RevoluteJoint_GetMaxMotorTorque_0:eu,_emscripten_bind_b2BodyDef_set_active_1:Qe,_emscripten_bind_b2DistanceJointDef_set_localAnchorB_1:Or,_emscripten_bind_b2Body_GetWorldPoint_1:Bs,_emscripten_bind_b2ManifoldPoint_get_normalImpulse_0:ym,_emscripten_bind_JSContactFilter_ShouldCollide_2:fp,_emscripten_bind_b2Joint_GetReactionTorque_1:Uk,_emscripten_bind_b2RevoluteJointDef_set_type_1:Cp,_emscripten_bind_b2RopeJointDef_b2RopeJointDef_0:Eu,_emscripten_bind_b2BodyDef_get_linearDamping_0:De,_emscripten_bind_b2MotorJointDef_get_bodyB_0:mv,_emscripten_bind_b2World_Step_3:Hh,_emscripten_bind_b2CircleShape_RayCast_4:Wj,_emscripten_bind_b2Profile_get_step_0:ae,_emscripten_bind_b2Vec3_b2Vec3_0:yf,_emscripten_bind_b2Vec3_b2Vec3_3:zf,_emscripten_bind_b2PulleyJoint_GetLengthB_0:yq,_emscripten_bind_b2Filter_set_categoryBits_1:Rc,_emscripten_bind_b2MotorJoint_GetUserData_0:Xd,_emscripten_bind_b2PrismaticJoint_GetLocalAnchorA_0:ki,_emscripten_bind_b2Shape_get_m_type_0:Er,_emscripten_bind_b2MouseJoint_SetDampingRatio_1:ed,_emscripten_bind_b2World_GetAutoClearForces_0:gi,_emscripten_enum_b2ShapeType_e_circle:rv,_emscripten_bind_b2BodyDef_set_fixedRotation_1:Me,_emscripten_bind_b2RopeJoint_GetLimitState_0:Sn,_emscripten_bind_b2JointDef_get_collideConnected_0:Pm,_emscripten_bind_b2Body_Dump_0:et,_emscripten_bind_b2RevoluteJoint_GetLowerLimit_0:Yt,_emscripten_bind_b2Body_GetWorldCenter_0:ls,_emscripten_bind_JSContactListener___destroy___0:bj,_emscripten_bind_b2BodyDef_set_linearVelocity_1:Ae,_emscripten_bind_b2JointDef_set_collideConnected_1:Qm,_emscripten_bind_b2MotorJoint___destroy___0:$d,_emscripten_bind_b2Body_GetUserData_0:bt,_emscripten_bind_b2World_GetContinuousPhysics_0:Uh,_emscripten_bind_b2Fixture_RayCast_3:Ec,_emscripten_bind_b2JointDef_set_bodyA_1:Mm,_emscripten_bind_b2GearJointDef_get_collideConnected_0:Ot,_emscripten_bind_b2RopeJointDef_get_maxLength_0:Ju,_emscripten_bind_b2MouseJointDef_get_bodyA_0:ar,_emscripten_bind_b2Body_SetBullet_1:Ps,_emscripten_bind_b2DistanceJoint_GetType_0:Tb,_emscripten_bind_b2FixtureDef_get_restitution_0:fg,_emscripten_bind_b2Fixture_GetType_0:sc,_emscripten_bind_b2PulleyJointDef_set_localAnchorB_1:cm,_emscripten_bind_b2RevoluteJoint_GetBodyB_0:iu,_emscripten_bind_b2Profile_set_solveInit_1:he,_emscripten_bind_b2RopeJointDef_set_type_1:Mu,_emscripten_bind_b2PrismaticJointDef_get_bodyB_0:th,_emscripten_bind_b2Body_SetLinearVelocity_1:ns,_emscripten_bind_b2RevoluteJoint_GetReferenceAngle_0:Tt,_emscripten_bind_b2PulleyJointDef_get_userData_0:lm,_emscripten_bind_b2PrismaticJointDef_set_bodyB_1:uh,_emscripten_bind_b2FrictionJointDef_b2FrictionJointDef_0:og,_free:OB,_emscripten_bind_b2PulleyJoint_GetCurrentLengthA_0:Aq,_emscripten_bind_b2Manifold_get_localNormal_0:Kg,_emscripten_bind_b2AABB_RayCast_2:Uf,_emscripten_bind_b2FixtureDef_set_isSensor_1:kg,_emscripten_bind_b2RopeJoint_GetBodyB_0:Vn,_emscripten_bind_b2PrismaticJoint_GetAnchorA_0:Fi,_emscripten_bind_b2ChainShape_set_m_count_1:qn,_emscripten_bind_b2PrismaticJoint_IsMotorEnabled_0:vi,_emscripten_bind_b2WeldJoint_GetFrequency_0:ul,_emscripten_bind_b2Joint_GetUserData_0:Wk,_emscripten_bind_b2RevoluteJointDef_get_lowerAngle_0:rp,_emscripten_bind_b2Manifold_set_type_1:Pg,_emscripten_bind_b2DistanceJoint_GetLength_0:Ob,_emscripten_bind_b2RopeJointDef_set_maxLength_1:Ku,_emscripten_bind_b2ChainShape_TestPoint_2:jn,_emscripten_bind_b2PrismaticJoint_GetReferenceAngle_0:ni,_emscripten_bind_b2RayCastInput_get_p2_0:ho,_emscripten_bind_b2RevoluteJoint_EnableLimit_1:Xt,_emscripten_bind_b2BodyDef_set_angle_1:ye,_emscripten_bind_b2WeldJoint_GetUserData_0:Gl,_emscripten_bind_b2WheelJointDef_get_localAnchorA_0:rj,_emscripten_bind_b2PulleyJointDef_set_type_1:km,_emscripten_bind_b2Body_IsBullet_0:Qs,_emscripten_bind_b2MotorJointDef_set_bodyA_1:lv,_emscripten_bind_b2Mat33_GetSymInverse33_1:kc,_emscripten_bind_b2Body_ApplyLinearImpulse_3:us,_emscripten_bind_b2PolygonShape_ComputeMass_2:xo,_emscripten_bind_b2WeldJoint_GetLocalAnchorA_0:rl,_emscripten_bind_b2MouseJoint_SetFrequency_1:cd,_emscripten_bind_b2EdgeShape_get_m_vertex1_0:Po,_emscripten_bind_b2BodyDef_set_awake_1:Ke,_emscripten_bind_b2Vec2_get_y_0:vf,_emscripten_bind_b2Body_CreateFixture_1:es,_emscripten_bind_b2Body_CreateFixture_2:fs,_emscripten_bind_b2PulleyJoint_GetUserData_0:Kq,_emscripten_bind_b2Body_SetActive_1:Vs,_emscripten_bind_b2Fixture_GetUserData_0:Bc,_emscripten_bind_b2PolygonShape_ComputeAABB_3:wo,_emscripten_bind_b2ContactFeature_get_typeA_0:bf,_emscripten_bind_b2MouseJoint_GetReactionForce_1:ld,_emscripten_bind_b2FrictionJoint_GetReactionTorque_1:rt,_emscripten_bind_b2EdgeShape_TestPoint_2:Lo,_memcpy:SB,_emscripten_bind_b2PolygonShape_get_m_centroid_0:yo,_emscripten_bind_b2ChainShape___destroy___0:Dn,_emscripten_bind_b2GearJoint_SetUserData_1:ml,_emscripten_bind_b2Vec3_set_z_1:Kf,_emscripten_bind_b2PrismaticJointDef_set_enableLimit_1:ch,_emscripten_bind_b2DistanceJoint_GetFrequency_0:Qb,_emscripten_bind_b2Body_SetGravityScale_1:Ms,_emscripten_enum_b2ContactFeatureType_e_face:Yv,_emscripten_bind_b2AABB_GetPerimeter_0:Qf,_emscripten_bind_b2PulleyJointDef_get_lengthA_0:dm,_emscripten_bind_b2Vec3_set_x_1:Gf,_emscripten_bind_b2PulleyJointDef_get_type_0:jm,_emscripten_bind_JSDestructionListener_SayGoodbyeJoint_1:Fb,_emscripten_bind_b2Shape___destroy___0:Ir,_strlen:RB,_emscripten_bind_b2Color_set_b_1:Mn,_emscripten_bind_b2Joint_GetReactionForce_1:Tk,_emscripten_bind_b2FixtureDef_set_friction_1:eg,_emscripten_bind_b2ContactID___destroy___0:Yi,_emscripten_bind_b2EdgeShape_get_m_hasVertex0_0:Xo,_emscripten_bind_JSRayCastCallback_ReportFixture_4:Xe,_emscripten_bind_b2MotorJointDef_get_linearOffset_0:Yu,_emscripten_bind_b2Profile_set_solveVelocity_1:je,_emscripten_bind_b2PrismaticJoint_GetAnchorB_0:Gi,_emscripten_bind_b2WeldJointDef_b2WeldJointDef_0:ek,_emscripten_enum_b2BodyType_b2_staticBody:Pv,_emscripten_bind_b2RevoluteJointDef_set_upperAngle_1:up,_emscripten_bind_b2RevoluteJointDef_get_type_0:Bp,_emscripten_bind_b2GearJointDef_get_type_0:Gt,_emscripten_bind_b2ChainShape_GetType_0:gn,_emscripten_bind_b2RayCastInput_get_maxFraction_0:jo,_emscripten_bind_b2GearJoint_GetBodyA_0:el,_emscripten_bind_b2Body_GetLocalVector_1:Es,_emscripten_bind_b2PrismaticJoint_EnableLimit_1:ri,_emscripten_bind_b2FrictionJointDef_get_maxForce_0:ug,_emscripten_bind_b2BodyDef_set_angularVelocity_1:Ce,_emscripten_bind_b2Body_SetLinearDamping_1:Is,_emscripten_bind_b2WheelJoint_GetBodyB_0:kq,_emscripten_bind_b2Color___destroy___0:Nn,_emscripten_bind_b2PrismaticJoint_IsActive_0:Mi,_emscripten_bind_b2Filter_get_categoryBits_0:Qc,_emscripten_enum_b2JointType_e_weldJoint:Ev,_emscripten_bind_b2World_SetContinuousPhysics_1:Th,_emscripten_bind_b2MouseJointDef_get_target_0:Qq,_emscripten_bind_b2Manifold_b2Manifold_0:Jg,_emscripten_bind_b2PulleyJointDef_set_userData_1:mm,_emscripten_bind_b2FrictionJointDef_set_maxForce_1:vg,_emscripten_bind_b2DistanceJointDef_b2DistanceJointDef_0:Jr,_emscripten_bind_b2PolygonShape_set_m_centroid_1:zo,_emscripten_bind_b2Mat33_GetInverse22_1:jc,_emscripten_bind_b2PolygonShape_SetAsBox_4:po,_emscripten_bind_b2EdgeShape_get_m_vertex2_0:Ro,_emscripten_bind_b2WheelJoint_GetReactionTorque_1:oq,_emscripten_bind_b2RevoluteJointDef_b2RevoluteJointDef_0:hp,_emscripten_bind_b2ContactFeature_set_typeA_1:cf,_emscripten_bind_b2Fixture_Dump_1:Nc,_emscripten_bind_b2World_GetJointList_0:Nh,_emscripten_bind_b2Manifold_set_localPoint_1:Ng,_emscripten_bind_b2DistanceJoint_SetUserData_1:ac,_emscripten_bind_b2BodyDef_set_bullet_1:Oe,_emscripten_bind_b2RayCastOutput___destroy___0:Ti,___cxa_can_catch:LB,_emscripten_bind_b2WheelJoint_GetNext_0:pq,_emscripten_bind_b2AABB_GetCenter_0:Of,_emscripten_bind_b2Filter_set_groupIndex_1:Vc,_emscripten_bind_b2JointDef_b2JointDef_0:Gm,_emscripten_bind_b2CircleShape_b2CircleShape_0:Sj,_emscripten_bind_b2GearJointDef_b2GearJointDef_0:zt,_emscripten_bind_b2JointDef_get_bodyB_0:Nm,_emscripten_bind_b2DistanceJoint_GetReactionForce_1:Yb,_emscripten_bind_b2PrismaticJoint_GetJointSpeed_0:pi,_emscripten_bind_b2PulleyJointDef_get_groundAnchorB_0:Zl,_emscripten_bind_b2Joint_GetAnchorA_0:Rk,_emscripten_bind_b2Contact_GetRestitution_0:ur,_emscripten_bind_b2ContactEdge_get_contact_0:xu,_emscripten_bind_b2RevoluteJointDef_get_userData_0:Dp,_emscripten_bind_b2Body_ApplyTorque_2:ts,_emscripten_bind_b2Fixture_GetAABB_1:Mc,_emscripten_bind_b2DistanceJointDef_Initialize_4:Kr,_emscripten_bind_b2PrismaticJointDef_set_collideConnected_1:wh,_emscripten_bind_b2PrismaticJointDef_set_localAxisA_1:_g,_emscripten_bind_b2Contact_GetTangentSpeed_0:xr,_emscripten_enum_b2LimitState_e_atLowerLimit:Jv,_emscripten_bind_b2ManifoldPoint_set_id_1:Dm,_emscripten_bind_b2WheelJointDef_get_bodyB_0:Nj,_emscripten_bind_b2WeldJoint_GetLocalAnchorB_0:sl,_emscripten_bind_b2RevoluteJointDef_set_localAnchorB_1:mp,_emscripten_bind_b2RevoluteJoint_GetType_0:gu,_emscripten_bind_b2Body_DestroyFixture_1:gs,_emscripten_bind_b2Profile_set_broadphase_1:ne,_emscripten_bind_b2WheelJointDef_get_localAnchorB_0:tj,_emscripten_bind_b2ContactImpulse_get_count_0:Ib,_emscripten_bind_b2World_GetJointCount_0:Zh,_emscripten_bind_b2WheelJoint_GetMotorSpeed_0:aq,_emscripten_bind_b2Body_GetAngularDamping_0:Js,_emscripten_bind_b2WheelJointDef_get_dampingRatio_0:Fj,_emscripten_bind_b2RayCastOutput_get_fraction_0:Ri,_emscripten_enum_b2ManifoldType_e_circles:Mv,_emscripten_bind_b2GearJoint_SetRatio_1:bl,_emscripten_bind_JSDraw_DrawPolygon_3:Np,_emscripten_bind_b2Filter___destroy___0:Wc,_emscripten_bind_b2JointEdge_set_next_1:Tl,___cxa_is_pointer_type:MB,_emscripten_bind_b2BodyDef_get_fixedRotation_0:Le,_emscripten_bind_b2PrismaticJointDef_set_motorSpeed_1:mh,_emscripten_bind_b2ChainShape_SetPrevVertex_1:dn,_emscripten_bind_b2MotorJoint_IsActive_0:Zd,_emscripten_bind_b2MouseJoint_GetReactionTorque_1:md,_emscripten_bind_b2MouseJoint_GetUserData_0:od,_emscripten_bind_b2WheelJoint_GetUserData_0:qq,_emscripten_bind_b2Vec3_op_sub_1:Df,_emscripten_bind_b2BodyDef_get_gravityScale_0:Te,_emscripten_bind_b2Shape_GetType_0:yr,_emscripten_bind_b2AABB_IsValid_0:Nf,_emscripten_bind_b2WheelJoint_GetBodyA_0:jq,_emscripten_bind_JSDraw_DrawTransform_1:Sp,_emscripten_bind_b2PulleyJoint_GetLengthA_0:xq,_emscripten_bind_b2DistanceJointDef_get_frequencyHz_0:Rr,_emscripten_bind_b2RevoluteJoint_SetMotorSpeed_1:bu,_emscripten_bind_b2World___destroy___0:ji,_emscripten_bind_b2ChainShape_get_m_hasNextVertex_0:xn,_emscripten_bind_b2ChainShape_SetNextVertex_1:en,_emscripten_bind_b2Body_SetType_1:Ns,_emscripten_bind_b2Body_GetMass_0:ws,_emscripten_bind_b2Rot_b2Rot_0:td,_emscripten_bind_b2Rot_b2Rot_1:ud,_emscripten_enum_b2JointType_e_distanceJoint:zv,_emscripten_bind_b2PulleyJoint___destroy___0:Oq,_emscripten_bind_b2PrismaticJoint_GetLocalAnchorB_0:li,_emscripten_bind_b2MouseJoint_GetType_0:gd,_emscripten_bind_JSQueryCallback___destroy___0:Zc,_emscripten_bind_b2RevoluteJointDef_set_lowerAngle_1:sp,_emscripten_bind_b2JointEdge___destroy___0:Ul,_emscripten_bind_b2PulleyJoint_GetRatio_0:zq,_emscripten_bind_JSContactListener_BeginContact_1:$i,_emscripten_bind_b2MotorJointDef_set_linearOffset_1:Zu,_emscripten_enum_b2JointType_e_motorJoint:Hv,_emscripten_bind_b2JointEdge_get_next_0:Sl,_emscripten_bind_b2RayCastInput_set_maxFraction_1:ko,_emscripten_bind_b2MouseJoint_GetBodyA_0:hd,_emscripten_bind_b2Profile_set_collide_1:de,_emscripten_bind_b2AABB_b2AABB_0:Mf,_emscripten_bind_b2Fixture_Refilter_0:yc,_emscripten_bind_b2World_CreateBody_1:Dh,_emscripten_bind_b2RopeJointDef_set_userData_1:Ou,_emscripten_bind_b2Fixture_IsSensor_0:vc,_emscripten_bind_b2WeldJoint_GetType_0:yl,_emscripten_bind_b2PrismaticJointDef_get_motorSpeed_0:lh,_emscripten_bind_b2Rot___destroy___0:Ed,_emscripten_bind_b2Filter_get_maskBits_0:Sc,_emscripten_bind_b2Mat22_get_ex_0:kj,_emscripten_bind_b2Body_GetFixtureList_0:Zs,_emscripten_bind_b2RevoluteJointDef_get_enableMotor_0:vp,_emscripten_bind_b2MouseJointDef_set_dampingRatio_1:Xq,_emscripten_bind_JSRayCastCallback___destroy___0:Ye,_emscripten_bind_b2ContactListener___destroy___0:um,_emscripten_bind_b2PrismaticJointDef_set_localAnchorB_1:Yg,_emscripten_enum_b2DrawFlag_e_pairBit:Vv,_emscripten_bind_b2FrictionJoint___destroy___0:xt,_emscripten_bind_b2WeldJoint_Dump_0:xl,_emscripten_bind_b2MotorJoint_SetMaxForce_1:Jd,_emscripten_bind_b2FrictionJointDef_get_maxTorque_0:wg,_emscripten_bind_b2FrictionJoint_GetLocalAnchorA_0:ft,_emscripten_bind_b2WeldJointDef_get_localAnchorB_0:ik,_emscripten_bind_b2PrismaticJointDef_get_bodyA_0:rh,_emscripten_bind_b2Vec2_IsValid_0:rf,_emscripten_bind_b2PrismaticJointDef_set_bodyA_1:sh,_emscripten_bind_b2World_GetWarmStarting_0:Sh,_emscripten_bind_b2RevoluteJointDef_set_enableLimit_1:qp,_emscripten_bind_b2WeldJointDef___destroy___0:Ak,_emscripten_bind_b2Mat22_Solve_1:jj,_emscripten_bind_b2Color_get_g_0:Jn,_emscripten_bind_VoidPtr___destroy___0:re,_emscripten_bind_b2RopeJoint_GetNext_0:_n,_emscripten_bind_b2Filter_b2Filter_0:Pc,_emscripten_bind_b2PolygonShape_GetChildCount_0:to,_emscripten_bind_b2GearJointDef_get_ratio_0:Et,_emscripten_bind_b2Mat33_Solve33_1:hc,_emscripten_bind_b2PulleyJoint_GetReactionForce_1:Hq,_emscripten_bind_b2WheelJoint_GetCollideConnected_0:tq,_emscripten_bind_b2WheelJoint_SetSpringDampingRatio_1:gq,_emscripten_bind_b2RevoluteJointDef___destroy___0:Lp,_emscripten_bind_b2MouseJointDef_get_maxForce_0:Sq,_emscripten_bind_b2RevoluteJoint_EnableMotor_1:au,_emscripten_bind_b2ContactFeature_get_typeB_0:df,_emscripten_bind_b2MotorJoint_SetLinearOffset_1:Fd,_emscripten_bind_b2MotorJoint_GetReactionForce_1:Ud,_emscripten_bind_b2Rot_GetAngle_0:xd,_emscripten_bind_b2World_SetAllowSleeping_1:Ph,_emscripten_bind_b2MotorJoint_SetAngularOffset_1:Hd,_emscripten_bind_b2MotorJoint_GetLinearOffset_0:Gd,_emscripten_bind_b2FrictionJoint_GetCollideConnected_0:wt,_emscripten_bind_b2WheelJointDef_set_motorSpeed_1:Cj,_emscripten_bind_b2MotorJoint_GetAnchorA_0:Sd,_emscripten_bind_b2Fixture_GetDensity_0:Hc,_emscripten_bind_b2PolygonShape_get_m_type_0:Co,_emscripten_bind_b2Vec2_Set_2:kf,_emscripten_bind_b2WeldJointDef_get_type_0:qk,_emscripten_bind_b2MouseJointDef_b2MouseJointDef_0:Pq,_emscripten_bind_b2Rot_get_s_0:Ad,_emscripten_bind_b2FrictionJoint_SetMaxTorque_1:jt,_emscripten_bind_b2MouseJointDef_get_frequencyHz_0:Uq,_emscripten_bind_b2FrictionJoint_SetUserData_1:ut,_emscripten_bind_b2FixtureDef_set_userData_1:cg,_emscripten_bind_b2JointDef_get_userData_0:Jm,_emscripten_bind_b2DistanceJointDef_get_collideConnected_0:bs,_emscripten_bind_b2RevoluteJointDef_set_referenceAngle_1:op,_emscripten_bind_b2ContactFeature___destroy___0:ff,_emscripten_bind_b2DistanceJointDef_set_bodyB_1:as,_emscripten_bind_JSQueryCallback_JSQueryCallback_0:Xc,_emscripten_bind_b2ChainShape_GetChildCount_0:hn,_emscripten_bind_b2MassData_b2MassData_0:Gk,_emscripten_bind_b2Vec3_set_y_1:If,_emscripten_bind_b2AABB_Combine_1:Rf,_emscripten_bind_b2AABB_Combine_2:Sf,_emscripten_bind_b2PrismaticJoint_GetBodyA_0:Di,_emscripten_bind_b2PrismaticJoint_GetMaxMotorForce_0:Ai,_emscripten_bind_b2AABB___destroy___0:Zf,_emscripten_bind_b2Body_IsSleepingAllowed_0:Ss,_emscripten_bind_b2MouseJointDef_set_maxForce_1:Tq,_emscripten_bind_b2MotorJoint_GetCorrectionFactor_0:Od,_emscripten_bind_b2Profile_get_solve_0:ee,_emscripten_bind_JSDestructionListener_SayGoodbyeFixture_1:Gb,_emscripten_bind_b2PolygonShape_GetVertexCount_0:qo,_emscripten_bind_b2Rot_get_c_0:Cd,_emscripten_bind_b2AABB_set_lowerBound_1:Wf,_emscripten_bind_b2ChainShape_get_m_hasPrevVertex_0:vn,_emscripten_bind_b2MouseJoint_SetMaxForce_1:ad,_emscripten_bind_b2FrictionJointDef_get_bodyB_0:Eg,_emscripten_bind_b2JointDef_set_userData_1:Km,_emscripten_bind_b2ManifoldPoint_get_tangentImpulse_0:Am,_emscripten_bind_b2RevoluteJointDef_get_maxMotorTorque_0:zp,_emscripten_bind_b2WeldJointDef_get_dampingRatio_0:ok,_emscripten_bind_b2MouseJoint___destroy___0:sd,_emscripten_bind_b2EdgeShape_b2EdgeShape_0:Ho,_emscripten_bind_b2FrictionJoint_GetReactionForce_1:qt,_emscripten_bind_b2DistanceJointDef_set_type_1:Wr,_emscripten_bind_b2WeldJoint___destroy___0:Kl,_emscripten_bind_b2PulleyJoint_GetBodyA_0:Dq,_emscripten_bind_b2RopeJointDef_get_type_0:Lu,_emscripten_bind_b2CircleShape_ComputeMass_2:Yj,_emscripten_bind_b2DistanceJointDef_get_localAnchorB_0:Nr,_emscripten_bind_b2GearJointDef___destroy___0:Qt,_emscripten_bind_b2RevoluteJointDef_set_bodyA_1:Gp,_emscripten_enum_b2BodyType_b2_dynamicBody:Rv,_emscripten_bind_b2CircleShape_TestPoint_2:Vj,_emscripten_bind_b2MotorJointDef_get_maxTorque_0:cv,_emscripten_bind_b2Body_GetLinearVelocityFromLocalPoint_1:Gs,_emscripten_bind_b2Mat22_b2Mat22_0:cj,_emscripten_bind_b2MouseJoint_GetAnchorB_0:kd,_emscripten_enum_b2BodyType_b2_kinematicBody:Qv,_emscripten_bind_b2Manifold_get_localPoint_0:Mg,_emscripten_bind_b2GearJoint_GetBodyB_0:fl,_emscripten_bind_b2ChainShape_Clear_0:an,_emscripten_bind_b2CircleShape___destroy___0:dk,_emscripten_bind_b2MotorJoint_GetType_0:Pd,_emscripten_bind_b2BodyDef_get_awake_0:Je,_emscripten_bind_b2Contact_SetRestitution_1:tr,_emscripten_bind_b2BodyDef_get_angularDamping_0:Fe,_emscripten_bind_b2EdgeShape_get_m_vertex3_0:Vo,_emscripten_bind_b2Fixture_SetUserData_1:Cc,_emscripten_bind_b2Transform_SetIdentity_0:Um,_emscripten_bind_b2GearJointDef_set_joint1_1:Bt,_emscripten_bind_b2EdgeShape_set_m_vertex2_1:So,_emscripten_bind_b2ContactEdge_get_next_0:Bu,_emscripten_bind_b2ContactFeature_set_indexB_1:af,_emscripten_bind_b2Body_GetLinearVelocityFromWorldPoint_1:Fs,_emscripten_bind_b2WeldJoint_GetCollideConnected_0:Jl,_emscripten_bind_b2Mat22_set_ey_1:nj,_emscripten_bind_b2WheelJointDef_set_frequencyHz_1:Ej,_emscripten_bind_b2World_GetSubStepping_0:Wh,_emscripten_bind_b2Rot_GetYAxis_0:zd,_emscripten_bind_b2Contact_GetChildIndexB_0:pr,_emscripten_bind_b2DistanceJoint___destroy___0:dc,_emscripten_bind_b2EdgeShape_GetType_0:Jo,_emscripten_bind_b2WheelJointDef_set_dampingRatio_1:Gj,_emscripten_bind_b2ManifoldPoint___destroy___0:Em,_emscripten_enum_b2JointType_e_prismaticJoint:yv,_emscripten_bind_b2MotorJoint_GetNext_0:Wd,_emscripten_bind_b2Vec2_Length_0:of,_emscripten_bind_b2Vec2_SetZero_0:jf,_emscripten_bind_b2RopeJoint___destroy___0:eo,_emscripten_bind_b2World_DestroyJoint_1:Gh,_emscripten_bind_b2JointDef_set_bodyB_1:Om,_emscripten_bind_b2Mat22_Set_2:fj,_emscripten_bind_b2Body_GetType_0:Os,_emscripten_bind_b2WeldJoint_GetAnchorB_0:Cl,_emscripten_bind_b2WeldJoint_GetNext_0:Fl,_emscripten_bind_b2Shape_get_m_radius_0:Gr,_emscripten_bind_b2EdgeShape_ComputeAABB_3:No,_emscripten_bind_b2BodyDef_get_type_0:te,_emscripten_bind_b2WheelJointDef_set_collideConnected_1:Qj,_emscripten_bind_JSDestructionListener___destroy___0:Hb,_emscripten_bind_b2MotorJointDef_get_type_0:gv,_emscripten_bind_b2RopeJoint_GetLocalAnchorA_0:On,_emscripten_bind_b2BodyDef_set_linearDamping_1:Ee,_emscripten_bind_b2FrictionJoint_GetUserData_0:tt,_emscripten_bind_b2Contact_SetFriction_1:qr,_emscripten_bind_b2Manifold_set_localNormal_1:Lg,_emscripten_bind_b2JointDef_get_bodyA_0:Lm,_emscripten_bind_b2Body_GetLinearDamping_0:Hs,_emscripten_bind_b2WeldJointDef_set_frequencyHz_1:nk,_emscripten_bind_b2Body_ResetMassData_0:As,_emscripten_bind_b2PrismaticJointDef_set_enableMotor_1:ih,_emscripten_enum_b2JointType_e_wheelJoint:Dv,_emscripten_bind_b2Vec2_Skew_0:sf,_emscripten_bind_b2MouseJoint_GetDampingRatio_0:fd,_emscripten_bind_b2RevoluteJoint_GetAnchorA_0:ju,_emscripten_bind_b2ChainShape_set_m_prevVertex_1:sn,_emscripten_bind_b2WheelJoint_GetAnchorA_0:lq,_emscripten_bind_b2MotorJoint_GetMaxTorque_0:Md,_emscripten_bind_b2FrictionJoint_GetNext_0:st,_emscripten_bind_b2PrismaticJointDef_set_userData_1:qh,_emscripten_bind_b2FrictionJointDef_set_type_1:zg,_emscripten_bind_b2PrismaticJoint_GetUserData_0:Ki,_emscripten_bind_b2FrictionJointDef_get_collideConnected_0:Gg,_emscripten_bind_b2Body_GetInertia_0:xs,_emscripten_bind_b2WeldJointDef_set_referenceAngle_1:lk,_emscripten_bind_b2FrictionJoint_GetAnchorA_0:ot,_emscripten_bind_b2RopeJoint_GetType_0:Tn,_emscripten_bind_b2MassData_get_I_0:Lk,_emscripten_bind_b2WheelJointDef_get_motorSpeed_0:Bj,_emscripten_bind_b2WeldJointDef_get_referenceAngle_0:kk,_emscripten_enum_b2JointType_e_ropeJoint:Gv,_emscripten_bind_b2Filter_set_maskBits_1:Tc,_emscripten_bind_b2EdgeShape_set_m_radius_1:cp,_emscripten_bind_b2MotorJointDef_set_collideConnected_1:pv,_emscripten_bind_b2Mat22_b2Mat22_2:dj,_emscripten_bind_b2WheelJointDef_set_maxMotorTorque_1:Aj,_emscripten_bind_b2FrictionJointDef_set_bodyB_1:Fg,_emscripten_bind_b2Mat22_b2Mat22_4:ej,_emscripten_bind_b2ChainShape_set_m_hasNextVertex_1:yn,_emscripten_bind_b2Mat22_GetInverse_0:ij,_emscripten_bind_b2PrismaticJoint_EnableMotor_1:wi,_emscripten_bind_b2CircleShape_get_m_type_0:$j,_emscripten_bind_b2DistanceJoint_GetLocalAnchorA_0:Lb,_emscripten_bind_b2ContactEdge_b2ContactEdge_0:uu,_emscripten_bind_b2BodyDef___destroy___0:Ve,_emscripten_bind_b2FrictionJointDef_set_maxTorque_1:xg,_emscripten_bind_b2PolygonShape_GetVertex_1:ro,_emscripten_bind_b2PulleyJointDef_set_groundAnchorB_1:_l,_emscripten_bind_b2RevoluteJointDef_get_collideConnected_0:Jp,_emscripten_bind_b2DistanceJointDef_set_bodyA_1:_r,_emscripten_bind_b2RevoluteJoint_SetLimits_2:_t,_emscripten_bind_b2WeldJointDef_set_type_1:rk,_emscripten_bind_b2MotorJointDef___destroy___0:qv,_emscripten_bind_b2FixtureDef_set_density_1:ig,_emscripten_bind_b2Shape_set_m_type_1:Fr,_emscripten_bind_b2WheelJoint_GetJointTranslation_0:Xp,_emscripten_bind_b2WheelJoint_GetMotorTorque_1:dq,_emscripten_bind_b2RopeJoint_SetUserData_1:ao,_emscripten_bind_b2RopeJointDef___destroy___0:Vu,_emscripten_bind_b2WheelJoint_IsActive_0:sq,_emscripten_bind_b2PrismaticJointDef_get_enableMotor_0:hh,_emscripten_bind_b2MotorJointDef_set_bodyB_1:nv,_emscripten_bind_b2Transform_b2Transform_2:Tm,_emscripten_bind_b2WeldJoint_GetReactionForce_1:Dl,_emscripten_bind_b2ChainShape_RayCast_4:kn,_emscripten_bind_b2PrismaticJoint_GetUpperLimit_0:ti,_emscripten_bind_b2ContactID_get_cf_0:Ui,_emscripten_bind_b2MouseJointDef_set_frequencyHz_1:Vq,_emscripten_bind_b2ChainShape_get_m_radius_0:Bn,_emscripten_bind_b2Body_GetLinearVelocity_0:os,_emscripten_bind_b2ChainShape_set_m_radius_1:Cn,_emscripten_bind_b2DistanceJoint_GetReactionTorque_1:Zb,_emscripten_bind_b2World_Dump_0:ii,_emscripten_bind_b2RevoluteJoint_GetLocalAnchorB_0:St,_emscripten_bind_JSContactFilter_JSContactFilter_0:ep,_emscripten_bind_b2Profile_set_solve_1:fe,_emscripten_bind_b2WeldJoint_GetDampingRatio_0:wl,_emscripten_bind_b2Color_get_b_0:Ln,_emscripten_bind_b2MouseJointDef_get_userData_0:_q,_emscripten_bind_b2CircleShape_ComputeAABB_3:Xj,_emscripten_bind_b2RopeJoint_GetReactionForce_1:Yn,_emscripten_bind_b2PrismaticJointDef_get_enableLimit_0:bh,_emscripten_bind_b2ManifoldPoint_set_localPoint_1:xm,_emscripten_bind_b2Fixture_GetFilterData_0:xc,_emscripten_bind_b2World_GetBodyList_0:Mh,_emscripten_bind_b2Shape_ComputeMass_2:Dr,_emscripten_bind_b2Joint_GetNext_0:Vk,_emscripten_bind_b2PrismaticJointDef_get_collideConnected_0:vh,_emscripten_bind_b2World_RayCast_3:Lh,_emscripten_bind_b2MassData_set_I_1:Mk,_emscripten_bind_b2MassData___destroy___0:Nk,_emscripten_bind_b2Profile_get_collide_0:ce,_emscripten_bind_b2Color_b2Color_3:Fn,_emscripten_bind_b2Color_b2Color_0:En,_emscripten_bind_b2MouseJoint_GetFrequency_0:dd,_emscripten_bind_b2WeldJointDef_Initialize_3:fk,_emscripten_bind_b2Shape_GetChildCount_0:zr,_emscripten_enum_b2JointType_e_gearJoint:Cv,_emscripten_bind_b2FixtureDef_get_friction_0:dg,_emscripten_bind_b2PrismaticJointDef_set_localAnchorA_1:Wg,_emscripten_bind_b2Contact_GetManifold_0:hr,_emscripten_bind_b2MouseJoint_GetTarget_0:$c,_emscripten_bind_b2WeldJointDef_get_localAnchorA_0:gk,_emscripten_bind_b2MouseJoint_SetUserData_1:pd,_emscripten_bind_b2JointEdge_get_other_0:Ml,_emscripten_bind_b2ChainShape_GetChildEdge_2:fn,_emscripten_bind_b2GearJointDef_set_collideConnected_1:Pt,_emscripten_bind_b2MotorJointDef_get_angularOffset_0:_u,_emscripten_bind_b2WheelJoint_SetUserData_1:rq,_emscripten_bind_b2Body_ApplyForce_3:rs,_emscripten_bind_b2PrismaticJoint_SetMotorSpeed_1:xi,_emscripten_bind_b2DistanceJoint_GetCollideConnected_0:cc,_emscripten_bind_b2MouseJoint_GetMaxForce_0:bd,_emscripten_bind_b2World_SetGravity_1:ci,_emscripten_bind_b2Mat22_SetZero_0:hj,_emscripten_bind_b2Contact_GetChildIndexA_0:nr,_emscripten_bind_b2Fixture_SetRestitution_1:Lc,_emscripten_bind_b2Body_GetTransform_0:is,_emscripten_bind_b2ContactEdge___destroy___0:Du,_emscripten_bind_b2Mat33_set_ex_1:mc,_emscripten_bind_b2AABB_GetExtents_0:Pf,_emscripten_bind_b2RevoluteJointDef_get_bodyA_0:Fp,_emscripten_bind_b2PrismaticJoint_GetBodyB_0:Ei,_emscripten_bind_b2WheelJointDef_set_bodyA_1:Mj,_emscripten_bind_b2DistanceJointDef_set_collideConnected_1:cs,_emscripten_bind_b2BodyDef_get_angle_0:xe,_emscripten_bind_b2PulleyJoint_GetReactionTorque_1:Iq,_emscripten_bind_b2FixtureDef_get_shape_0:$f,_emscripten_bind_b2WeldJointDef_get_userData_0:sk,_emscripten_bind_b2FrictionJoint_SetMaxForce_1:ht,_emscripten_bind_b2Mat33_b2Mat33_3:fc,_emscripten_bind_b2Vec3_get_y_0:Hf,_emscripten_bind_b2JointDef_get_type_0:Hm,_emscripten_bind_JSQueryCallback_ReportFixture_1:Yc,_emscripten_bind_b2Fixture_TestPoint_1:Dc,_emscripten_bind_b2RevoluteJoint_GetCollideConnected_0:ru,_emscripten_bind_JSDraw_JSDraw_0:Mp,_emscripten_bind_b2MouseJoint_GetAnchorA_0:jd,_emscripten_bind_b2Transform_get_p_0:Wm,_emscripten_bind_b2EdgeShape_ComputeMass_2:Oo,_emscripten_bind_b2World_GetProfile_0:hi,_emscripten_bind_b2DistanceJointDef___destroy___0:ds,_emscripten_bind_b2RopeJointDef_set_bodyA_1:Qu,_emscripten_bind_b2JointDef_set_type_1:Im,_emscripten_bind_b2Draw_AppendFlags_1:Dk,_emscripten_bind_b2MotorJointDef_get_userData_0:iv,_emscripten_bind_b2World_GetContactList_0:Oh,_emscripten_bind_b2Mat33_set_ez_1:qc,_emscripten_bind_b2JointEdge_b2JointEdge_0:Ll,_emscripten_bind_b2FrictionJointDef_get_bodyA_0:Cg,_emscripten_bind_b2WheelJointDef_get_type_0:Hj,_emscripten_bind_b2RevoluteJoint_GetReactionForce_1:lu,_emscripten_bind_b2PulleyJointDef_set_collideConnected_1:sm,_emscripten_bind_b2RopeJoint_GetCollideConnected_0:co,_emscripten_bind_b2GearJointDef_set_joint2_1:Dt,_emscripten_bind_b2BodyDef_set_userData_1:Se,_emscripten_bind_b2GearJoint_GetAnchorB_0:hl,_emscripten_bind_b2RopeJoint_IsActive_0:bo,_emscripten_bind_b2Fixture_GetFriction_0:Ic,_emscripten_enum_b2DrawFlag_e_aabbBit:Uv,_emscripten_bind_b2RevoluteJointDef_Initialize_3:ip,_emscripten_bind_b2Body_GetAngle_0:ks,_emscripten_bind_b2EdgeShape_Set_2:Io,_emscripten_bind_b2Mat33_SetZero_0:gc,_emscripten_bind_b2MotorJointDef_set_maxTorque_1:dv,_emscripten_bind_b2PrismaticJointDef_get_localAxisA_0:Zg,_emscripten_bind_b2Mat22_get_ey_0:mj,_emscripten_bind_b2Mat22_SetIdentity_0:gj,_emscripten_bind_b2Joint_IsActive_0:Yk,_emscripten_bind_b2BodyDef_get_allowSleep_0:He,_emscripten_bind_b2World_GetTreeHeight_0:$h,_emscripten_bind_b2GearJoint_GetJoint2_0:al,_emscripten_bind_b2EdgeShape_set_m_vertex1_1:Qo,_emscripten_bind_b2Body_GetWorld_0:dt,_emscripten_enum_b2LimitState_e_inactiveLimit:Iv,_emscripten_bind_b2PulleyJointDef_set_lengthB_1:gm,_emscripten_bind_b2Body_SetAwake_1:Ts,_emscripten_bind_b2PrismaticJointDef_set_upperTranslation_1:gh,_emscripten_bind_b2Vec2___destroy___0:xf,_emscripten_bind_b2RayCastInput_set_p1_1:go,_emscripten_bind_b2Contact_ResetFriction_0:sr,_emscripten_bind_b2PulleyJoint_GetAnchorA_0:Fq,_emscripten_bind_b2BodyDef_get_linearVelocity_0:ze,_emscripten_bind_b2DistanceJointDef_get_bodyB_0:$r,_emscripten_bind_b2Mat22___destroy___0:oj,_emscripten_bind_b2RevoluteJoint_GetNext_0:nu,_emscripten_bind_b2WeldJointDef_get_bodyA_0:uk,_emscripten_bind_b2MotorJoint_GetAnchorB_0:Td,_emscripten_bind_b2Fixture_GetShape_0:tc,_emscripten_bind_b2PolygonShape_SetAsBox_2:oo,_emscripten_bind_b2Vec3_op_mul_1:Ef,_emscripten_bind_b2PolygonShape_set_m_type_1:Do,_emscripten_bind_b2WheelJoint_GetType_0:iq,_emscripten_bind_b2MotorJoint_GetAngularOffset_0:Id,_emscripten_bind_b2RevoluteJoint_IsActive_0:qu,_emscripten_bind_b2GearJoint_GetNext_0:kl,_emscripten_bind_b2MotorJointDef_get_correctionFactor_0:ev,_emscripten_bind_b2Color_Set_3:Gn,_emscripten_bind_b2EdgeShape_set_m_type_1:ap,_emscripten_bind_b2WheelJoint_GetLocalAxisA_0:Wp,_emscripten_bind_b2Body_GetNext_0:at,_emscripten_bind_b2RopeJoint_GetBodyA_0:Un,_emscripten_enum_b2JointType_e_unknownJoint:wv,_emscripten_bind_b2ContactFeature_set_indexA_1:_e,_emscripten_bind_b2Profile_get_solveInit_0:ge,_emscripten_bind_b2BodyDef_set_angularDamping_1:Ge,_emscripten_bind_b2FrictionJoint_GetAnchorB_0:pt,_emscripten_bind_b2World_QueryAABB_2:Kh,_emscripten_bind_b2BodyDef_get_userData_0:Re,_emscripten_bind_b2ContactID_get_key_0:Wi,_emscripten_bind_b2Body_SetAngularVelocity_1:ps,_emscripten_bind_b2WheelJointDef_get_userData_0:Jj,_emscripten_bind_b2RevoluteJoint_IsLimitEnabled_0:Wt,_emscripten_bind_b2DistanceJoint_GetBodyB_0:Vb,_emscripten_bind_b2RevoluteJointDef_set_maxMotorTorque_1:Ap,_emscripten_bind_b2WeldJointDef_set_bodyB_1:xk,_emscripten_bind_b2RevoluteJoint_SetUserData_1:pu,_emscripten_bind_b2DistanceJoint_SetLength_1:Nb,_emscripten_bind_b2JointEdge_get_joint_0:Ol,_emscripten_bind_b2Body_GetLocalCenter_0:ms,_emscripten_bind_b2FixtureDef___destroy___0:ng,_emscripten_bind_b2FixtureDef_set_shape_1:ag,_emscripten_bind_b2WeldJoint_GetAnchorA_0:Bl,_emscripten_bind_b2Profile_get_solveVelocity_0:ie,_emscripten_bind_b2WeldJointDef_get_bodyB_0:wk,_emscripten_bind_b2Body_SetAngularDamping_1:Ks,_emscripten_bind_b2PulleyJointDef_Initialize_7:Wl,_emscripten_bind_b2GearJointDef_set_bodyB_1:Nt,_emscripten_bind_b2RopeJoint_GetReactionTorque_1:Zn,_emscripten_bind_b2Mat22_set_ex_1:lj,_emscripten_bind_b2GearJoint_GetType_0:dl,_emscripten_enum_b2DrawFlag_e_centerOfMassBit:Wv,_emscripten_bind_b2ChainShape_b2ChainShape_0:$m,_emscripten_bind_b2RevoluteJoint_SetMaxMotorTorque_1:du,_emscripten_bind_b2RopeJointDef_set_localAnchorB_1:Iu,_emscripten_bind_b2FrictionJointDef_Initialize_3:pg,_emscripten_bind_b2GearJointDef_set_userData_1:Jt,_emscripten_bind_b2ChainShape_CreateLoop_2:bn,_emscripten_bind_b2EdgeShape_get_m_radius_0:bp,_emscripten_bind_b2Contact_GetFixtureB_0:or,_emscripten_bind_b2ChainShape_ComputeMass_2:mn,_emscripten_bind_b2Vec2_set_y_1:wf,_emscripten_bind_b2PrismaticJoint_IsLimitEnabled_0:qi,_emscripten_bind_b2RopeJointDef_get_bodyB_0:Ru,_emscripten_bind_b2BodyDef_b2BodyDef_0:se,_emscripten_bind_b2MassData_get_mass_0:Hk,_emscripten_bind_b2WheelJoint___destroy___0:uq,_emscripten_bind_b2Joint_GetBodyB_0:Qk,_emscripten_bind_b2MouseJointDef_set_collideConnected_1:fr,_emscripten_bind_b2WheelJointDef_set_localAxisA_1:wj,_emscripten_bind_b2Joint_Dump_0:_k,_emscripten_bind_b2WheelJointDef_b2WheelJointDef_0:pj,_emscripten_bind_b2RevoluteJointDef_set_motorSpeed_1:yp,_emscripten_bind_b2MotorJointDef_get_bodyA_0:kv,_emscripten_bind_b2WheelJointDef_get_enableMotor_0:xj,_emscripten_bind_b2Vec2_LengthSquared_0:pf,_emscripten_bind_b2FrictionJointDef_set_bodyA_1:Dg,_emscripten_bind_b2WheelJoint_GetSpringFrequencyHz_0:fq,_emscripten_bind_b2ContactFeature_get_indexB_0:$e,_emscripten_bind_b2Body_GetJointList_0:_s,_emscripten_bind_b2FrictionJoint_GetBodyA_0:mt,_emscripten_bind_b2WheelJointDef_set_localAnchorB_1:uj,_emscripten_bind_b2DistanceJointDef_set_localAnchorA_1:Mr,_emscripten_bind_b2PrismaticJointDef_get_maxMotorForce_0:jh,_emscripten_bind_b2Body_SetUserData_1:ct,_emscripten_bind_b2DistanceJoint_GetUserData_0:$b,_emscripten_bind_b2PulleyJointDef_set_bodyA_1:om,_emscripten_bind_b2Joint_GetType_0:Ok,_emscripten_bind_b2Manifold_get_pointCount_0:Qg,_emscripten_bind_b2Mat33_get_ez_0:pc,_emscripten_bind_b2DestructionListenerWrapper___destroy___0:Zi,_emscripten_bind_b2WheelJointDef_get_bodyA_0:Lj,_emscripten_enum_b2LimitState_e_atUpperLimit:Kv,_emscripten_bind_b2PulleyJointDef_set_groundAnchorA_1:Yl,_emscripten_bind_b2MouseJointDef_get_type_0:Yq,_emscripten_bind_b2PrismaticJoint_SetMaxMotorForce_1:zi,_emscripten_bind_b2PulleyJointDef_get_collideConnected_0:rm,_emscripten_bind_b2RopeJoint_SetMaxLength_1:Qn,_emscripten_bind_b2Joint_SetUserData_1:Xk,_emscripten_bind_b2PolygonShape_set_m_radius_1:Fo,_emscripten_bind_b2Vec2_get_x_0:tf,_emscripten_bind_JSContactListener_JSContactListener_0:_i,runPostSets:PB,stackAlloc:wb,stackSave:xb,stackRestore:yb,setThrew:zb,setTempRet0:Cb,getTempRet0:Db,dynCall_iiii:TB,dynCall_viiiii:mC,dynCall_did:HC,dynCall_vi:aD,dynCall_diiiid:vD,dynCall_vii:QD,dynCall_viidii:jE,dynCall_ii:EE,dynCall_viidi:ZE,dynCall_viii:sF,dynCall_v:NF,dynCall_viid:gG,dynCall_viiiiii:BG,dynCall_iii:WG,dynCall_iiiiii:pH,dynCall_viiii:KH}}) (e.X,e.Y,pb),pc=e._emscripten_bind_b2WheelJoint_GetSpringDampingRatio_0=i._emscripten_bind_b2WheelJoint_GetSpringDampingRatio_0,qc=e._emscripten_bind_b2ContactEdge_set_next_1=i._emscripten_bind_b2ContactEdge_set_next_1,rc=e._emscripten_bind_b2ChainShape_get_m_count_0=i._emscripten_bind_b2ChainShape_get_m_count_0,sc=e._emscripten_bind_b2Fixture_SetFriction_1=i._emscripten_bind_b2Fixture_SetFriction_1,tc=e._emscripten_bind_b2Shape_ComputeAABB_3=i._emscripten_bind_b2Shape_ComputeAABB_3, uc=e._emscripten_bind_b2FrictionJointDef_set_userData_1=i._emscripten_bind_b2FrictionJointDef_set_userData_1,vc=e._emscripten_bind_b2Vec3_get_z_0=i._emscripten_bind_b2Vec3_get_z_0,wc=e._emscripten_bind_b2World_IsLocked_0=i._emscripten_bind_b2World_IsLocked_0,xc=e._emscripten_bind_b2Draw_GetFlags_0=i._emscripten_bind_b2Draw_GetFlags_0,yc=e._emscripten_bind_b2FrictionJoint_IsActive_0=i._emscripten_bind_b2FrictionJoint_IsActive_0,zc=e._emscripten_bind_b2Color_set_g_1=i._emscripten_bind_b2Color_set_g_1, Ac=e._emscripten_bind_b2WheelJointDef_get_frequencyHz_0=i._emscripten_bind_b2WheelJointDef_get_frequencyHz_0,Bc=e._emscripten_bind_b2RopeJointDef_set_localAnchorA_1=i._emscripten_bind_b2RopeJointDef_set_localAnchorA_1,Cc=e._emscripten_bind_b2PolygonShape_RayCast_4=i._emscripten_bind_b2PolygonShape_RayCast_4,Dc=e._emscripten_bind_b2World_GetTreeBalance_0=i._emscripten_bind_b2World_GetTreeBalance_0,Ec=e._emscripten_bind_b2PrismaticJointDef_get_upperTranslation_0=i._emscripten_bind_b2PrismaticJointDef_get_upperTranslation_0, Fc=e._emscripten_bind_JSDraw_DrawSolidCircle_4=i._emscripten_bind_JSDraw_DrawSolidCircle_4,Gc=e._emscripten_bind_b2RevoluteJoint_GetLocalAnchorA_0=i._emscripten_bind_b2RevoluteJoint_GetLocalAnchorA_0,Hc=e._emscripten_bind_b2FixtureDef_get_filter_0=i._emscripten_bind_b2FixtureDef_get_filter_0,Ic=e._emscripten_bind_b2FrictionJointDef_get_type_0=i._emscripten_bind_b2FrictionJointDef_get_type_0,Jc=e._emscripten_bind_b2RevoluteJoint_GetMotorTorque_1=i._emscripten_bind_b2RevoluteJoint_GetMotorTorque_1, Kc=e._emscripten_bind_b2MotorJointDef_set_type_1=i._emscripten_bind_b2MotorJointDef_set_type_1,Lc=e._emscripten_bind_b2RayCastInput_get_p1_0=i._emscripten_bind_b2RayCastInput_get_p1_0,Mc=e._emscripten_bind_b2EdgeShape_set_m_hasVertex3_1=i._emscripten_bind_b2EdgeShape_set_m_hasVertex3_1,Nc=e._emscripten_bind_b2JointEdge_set_joint_1=i._emscripten_bind_b2JointEdge_set_joint_1,Oc=e._emscripten_enum_b2ShapeType_e_polygon=i._emscripten_enum_b2ShapeType_e_polygon,Pc=e._emscripten_bind_b2Fixture___destroy___0= i._emscripten_bind_b2Fixture___destroy___0,Qc=e._emscripten_bind_b2PulleyJoint_SetUserData_1=i._emscripten_bind_b2PulleyJoint_SetUserData_1,Rc=e._emscripten_bind_b2World_SetWarmStarting_1=i._emscripten_bind_b2World_SetWarmStarting_1,Sc=e._emscripten_bind_JSDraw_DrawCircle_3=i._emscripten_bind_JSDraw_DrawCircle_3,Tc=e._emscripten_bind_b2WeldJoint_IsActive_0=i._emscripten_bind_b2WeldJoint_IsActive_0,Uc=e._emscripten_bind_b2DestructionListener___destroy___0=i._emscripten_bind_b2DestructionListener___destroy___0, Vc=e._emscripten_bind_b2BodyDef_set_type_1=i._emscripten_bind_b2BodyDef_set_type_1,Wc=e._emscripten_bind_b2ChainShape_ComputeAABB_3=i._emscripten_bind_b2ChainShape_ComputeAABB_3,Xc=e._emscripten_bind_b2MouseJointDef_set_type_1=i._emscripten_bind_b2MouseJointDef_set_type_1,Yc=e._emscripten_bind_b2JointEdge_get_prev_0=i._emscripten_bind_b2JointEdge_get_prev_0,Zc=e._emscripten_bind_b2WeldJoint_GetReactionTorque_1=i._emscripten_bind_b2WeldJoint_GetReactionTorque_1,$c=e._emscripten_bind_b2MotorJointDef_get_maxForce_0= i._emscripten_bind_b2MotorJointDef_get_maxForce_0,ad=e._emscripten_bind_b2DistanceJointDef_get_userData_0=i._emscripten_bind_b2DistanceJointDef_get_userData_0,bd=e._emscripten_bind_b2BodyDef_get_position_0=i._emscripten_bind_b2BodyDef_get_position_0,cd=e._emscripten_bind_b2RopeJointDef_get_localAnchorB_0=i._emscripten_bind_b2RopeJointDef_get_localAnchorB_0,dd=e._emscripten_bind_b2RevoluteJointDef_set_userData_1=i._emscripten_bind_b2RevoluteJointDef_set_userData_1,ed=e._emscripten_bind_b2RevoluteJointDef_get_localAnchorA_0= i._emscripten_bind_b2RevoluteJointDef_get_localAnchorA_0,fd=e._emscripten_bind_b2World_SetContactFilter_1=i._emscripten_bind_b2World_SetContactFilter_1,gd=e._emscripten_bind_b2WheelJointDef_get_collideConnected_0=i._emscripten_bind_b2WheelJointDef_get_collideConnected_0,hd=e._emscripten_bind_b2MouseJointDef_set_userData_1=i._emscripten_bind_b2MouseJointDef_set_userData_1,id=e._emscripten_bind_JSDraw_DrawSegment_3=i._emscripten_bind_JSDraw_DrawSegment_3,jd=e._emscripten_bind_b2FixtureDef_set_restitution_1= i._emscripten_bind_b2FixtureDef_set_restitution_1,kd=e._emscripten_bind_b2MotorJointDef_Initialize_2=i._emscripten_bind_b2MotorJointDef_Initialize_2,ld=e._emscripten_bind_b2EdgeShape_GetChildCount_0=i._emscripten_bind_b2EdgeShape_GetChildCount_0,md=e._emscripten_bind_b2Mat33_get_ey_0=i._emscripten_bind_b2Mat33_get_ey_0,nd=e._emscripten_bind_b2MouseJoint_IsActive_0=i._emscripten_bind_b2MouseJoint_IsActive_0,od=e._emscripten_bind_b2World_GetGravity_0=i._emscripten_bind_b2World_GetGravity_0,pd=e._emscripten_bind_b2World_DrawDebugData_0= i._emscripten_bind_b2World_DrawDebugData_0,qd=e._emscripten_bind_b2Profile_get_broadphase_0=i._emscripten_bind_b2Profile_get_broadphase_0,rd=e._emscripten_bind_b2PulleyJointDef_get_bodyA_0=i._emscripten_bind_b2PulleyJointDef_get_bodyA_0,sd=e._emscripten_bind_b2PrismaticJoint_SetLimits_2=i._emscripten_bind_b2PrismaticJoint_SetLimits_2,td=e._emscripten_bind_b2PulleyJointDef_get_localAnchorA_0=i._emscripten_bind_b2PulleyJointDef_get_localAnchorA_0,ud=e._emscripten_bind_b2DistanceJoint_GetAnchorA_0=i._emscripten_bind_b2DistanceJoint_GetAnchorA_0, vd=e._emscripten_bind_b2ManifoldPoint_set_tangentImpulse_1=i._emscripten_bind_b2ManifoldPoint_set_tangentImpulse_1,wd=e._emscripten_bind_b2PolygonShape_get_m_count_0=i._emscripten_bind_b2PolygonShape_get_m_count_0,xd=e._emscripten_bind_b2RopeJointDef_set_collideConnected_1=i._emscripten_bind_b2RopeJointDef_set_collideConnected_1,yd=e._emscripten_bind_b2CircleShape_set_m_p_1=i._emscripten_bind_b2CircleShape_set_m_p_1,zd=e._emscripten_bind_JSContactListener_EndContact_1=i._emscripten_bind_JSContactListener_EndContact_1, Ad=e._emscripten_bind_b2MassData_set_mass_1=i._emscripten_bind_b2MassData_set_mass_1,Bd=e._emscripten_bind_b2Vec3_get_x_0=i._emscripten_bind_b2Vec3_get_x_0,Cd=e._emscripten_bind_b2ChainShape_CreateChain_2=i._emscripten_bind_b2ChainShape_CreateChain_2,Dd=e._emscripten_bind_b2Color_get_r_0=i._emscripten_bind_b2Color_get_r_0,Ed=e._emscripten_bind_b2World_DestroyBody_1=i._emscripten_bind_b2World_DestroyBody_1,Fd=e._emscripten_bind_b2Profile_get_solvePosition_0=i._emscripten_bind_b2Profile_get_solvePosition_0, Gd=e._emscripten_bind_b2Shape_RayCast_4=i._emscripten_bind_b2Shape_RayCast_4,Hd=e._emscripten_bind_b2PulleyJoint_GetGroundAnchorA_0=i._emscripten_bind_b2PulleyJoint_GetGroundAnchorA_0,Id=e._emscripten_bind_b2Mat33___destroy___0=i._emscripten_bind_b2Mat33___destroy___0,Jd=e._emscripten_bind_b2GearJoint_GetReactionTorque_1=i._emscripten_bind_b2GearJoint_GetReactionTorque_1,Kd=e._emscripten_bind_b2WeldJointDef_set_collideConnected_1=i._emscripten_bind_b2WeldJointDef_set_collideConnected_1,Ld=e._emscripten_bind_b2Manifold_get_type_0= i._emscripten_bind_b2Manifold_get_type_0,Md=e._emscripten_bind_b2RevoluteJoint___destroy___0=i._emscripten_bind_b2RevoluteJoint___destroy___0,Nd=e._emscripten_bind_b2PulleyJointDef_b2PulleyJointDef_0=i._emscripten_bind_b2PulleyJointDef_b2PulleyJointDef_0,Od=e._emscripten_bind_b2World_SetAutoClearForces_1=i._emscripten_bind_b2World_SetAutoClearForces_1,Pd=e._emscripten_bind_b2PrismaticJointDef_set_lowerTranslation_1=i._emscripten_bind_b2PrismaticJointDef_set_lowerTranslation_1,Qd=e._emscripten_bind_b2BodyDef_set_position_1= i._emscripten_bind_b2BodyDef_set_position_1,Rd=e._emscripten_bind_b2Transform_get_q_0=i._emscripten_bind_b2Transform_get_q_0,Sd=e._emscripten_bind_b2FrictionJoint_GetMaxForce_0=i._emscripten_bind_b2FrictionJoint_GetMaxForce_0,Td=e._emscripten_bind_b2PolygonShape_set_m_count_1=i._emscripten_bind_b2PolygonShape_set_m_count_1,Ud=e._emscripten_bind_b2Contact_GetNext_0=i._emscripten_bind_b2Contact_GetNext_0,Vd=e._emscripten_bind_b2MotorJointDef_set_userData_1=i._emscripten_bind_b2MotorJointDef_set_userData_1, Wd=e._emscripten_bind_b2EdgeShape_get_m_type_0=i._emscripten_bind_b2EdgeShape_get_m_type_0,Xd=e._emscripten_bind_b2GearJoint_GetJoint1_0=i._emscripten_bind_b2GearJoint_GetJoint1_0,Yd=e._emscripten_bind_b2WheelJoint_GetMaxMotorTorque_0=i._emscripten_bind_b2WheelJoint_GetMaxMotorTorque_0,Zd=e._emscripten_bind_b2MotorJoint_SetMaxTorque_1=i._emscripten_bind_b2MotorJoint_SetMaxTorque_1,$d=e._emscripten_bind_b2GearJoint_GetAnchorA_0=i._emscripten_bind_b2GearJoint_GetAnchorA_0,ae=e._emscripten_enum_b2JointType_e_mouseJoint= i._emscripten_enum_b2JointType_e_mouseJoint,be=e._emscripten_bind_b2MouseJointDef_set_bodyA_1=i._emscripten_bind_b2MouseJointDef_set_bodyA_1,ce=e._emscripten_enum_b2JointType_e_revoluteJoint=i._emscripten_enum_b2JointType_e_revoluteJoint,de=e._emscripten_bind_b2World_SetContactListener_1=i._emscripten_bind_b2World_SetContactListener_1,ee=e._emscripten_bind_b2Body_IsAwake_0=i._emscripten_bind_b2Body_IsAwake_0,fe=e._emscripten_bind_b2JointEdge_set_other_1=i._emscripten_bind_b2JointEdge_set_other_1, ge=e._emscripten_bind_b2RevoluteJoint_IsMotorEnabled_0=i._emscripten_bind_b2RevoluteJoint_IsMotorEnabled_0,he=e._emscripten_bind_b2MouseJointDef_set_target_1=i._emscripten_bind_b2MouseJointDef_set_target_1,ie=e._emscripten_bind_b2MotorJoint_SetCorrectionFactor_1=i._emscripten_bind_b2MotorJoint_SetCorrectionFactor_1,je=e._emscripten_bind_b2FixtureDef_get_density_0=i._emscripten_bind_b2FixtureDef_get_density_0,ke=e._emscripten_bind_b2ChainShape_set_m_vertices_1=i._emscripten_bind_b2ChainShape_set_m_vertices_1, le=e._emscripten_bind_b2ChainShape_get_m_vertices_0=i._emscripten_bind_b2ChainShape_get_m_vertices_0,me=e._emscripten_bind_b2Rot_set_s_1=i._emscripten_bind_b2Rot_set_s_1,ne=e._emscripten_bind_b2MotorJointDef_get_collideConnected_0=i._emscripten_bind_b2MotorJointDef_get_collideConnected_0,oe=e._emscripten_bind_b2RevoluteJoint_GetUpperLimit_0=i._emscripten_bind_b2RevoluteJoint_GetUpperLimit_0,pe=e._emscripten_bind_b2WheelJointDef_set_bodyB_1=i._emscripten_bind_b2WheelJointDef_set_bodyB_1,qe=e._emscripten_bind_b2WheelJointDef_set_enableMotor_1= i._emscripten_bind_b2WheelJointDef_set_enableMotor_1,re=e._emscripten_bind_b2FixtureDef_get_userData_0=i._emscripten_bind_b2FixtureDef_get_userData_0,se=e._emscripten_bind_b2FrictionJointDef_set_collideConnected_1=i._emscripten_bind_b2FrictionJointDef_set_collideConnected_1,te=e._emscripten_bind_b2PrismaticJointDef_get_lowerTranslation_0=i._emscripten_bind_b2PrismaticJointDef_get_lowerTranslation_0,ue=e._emscripten_bind_b2GearJoint_GetCollideConnected_0=i._emscripten_bind_b2GearJoint_GetCollideConnected_0, ve=e._emscripten_bind_b2RevoluteJointDef_get_upperAngle_0=i._emscripten_bind_b2RevoluteJointDef_get_upperAngle_0,we=e._emscripten_bind_b2Body_ApplyAngularImpulse_2=i._emscripten_bind_b2Body_ApplyAngularImpulse_2,xe=e._emscripten_enum_b2JointType_e_frictionJoint=i._emscripten_enum_b2JointType_e_frictionJoint,ye=e._emscripten_bind_b2RayCastOutput_set_fraction_1=i._emscripten_bind_b2RayCastOutput_set_fraction_1,ze=e._emscripten_bind_b2Color_set_r_1=i._emscripten_bind_b2Color_set_r_1,Ae=e._emscripten_bind_b2DistanceJointDef_get_length_0= i._emscripten_bind_b2DistanceJointDef_get_length_0,Be=e._emscripten_bind_b2PulleyJoint_GetBodyB_0=i._emscripten_bind_b2PulleyJoint_GetBodyB_0,Ce=e._emscripten_bind_b2WheelJointDef_set_type_1=i._emscripten_bind_b2WheelJointDef_set_type_1,De=e._emscripten_bind_b2World_GetTreeQuality_0=i._emscripten_bind_b2World_GetTreeQuality_0,Ee=e._emscripten_bind_b2BodyDef_set_gravityScale_1=i._emscripten_bind_b2BodyDef_set_gravityScale_1,Fe=e._emscripten_bind_b2RopeJointDef_set_bodyB_1=i._emscripten_bind_b2RopeJointDef_set_bodyB_1, Ge=e._emscripten_bind_b2PrismaticJoint_GetLowerLimit_0=i._emscripten_bind_b2PrismaticJoint_GetLowerLimit_0,He=e._emscripten_bind_b2AABB_get_lowerBound_0=i._emscripten_bind_b2AABB_get_lowerBound_0,Ie=e._emscripten_bind_b2WheelJoint_SetMotorSpeed_1=i._emscripten_bind_b2WheelJoint_SetMotorSpeed_1,Je=e._emscripten_bind_b2PrismaticJointDef_get_referenceAngle_0=i._emscripten_bind_b2PrismaticJointDef_get_referenceAngle_0,Ke=e._emscripten_bind_b2Body_SetMassData_1=i._emscripten_bind_b2Body_SetMassData_1, Le=e._emscripten_bind_b2BodyDef_get_angularVelocity_0=i._emscripten_bind_b2BodyDef_get_angularVelocity_0,Me=e._emscripten_bind_b2WeldJoint_SetDampingRatio_1=i._emscripten_bind_b2WeldJoint_SetDampingRatio_1,Ne=e._emscripten_bind_b2PrismaticJointDef___destroy___0=i._emscripten_bind_b2PrismaticJointDef___destroy___0,Oe=e._emscripten_bind_b2Contact_IsTouching_0=i._emscripten_bind_b2Contact_IsTouching_0,Pe=e._emscripten_bind_b2Draw_SetFlags_1=i._emscripten_bind_b2Draw_SetFlags_1,Qe=e._emscripten_bind_b2AABB_Contains_1= i._emscripten_bind_b2AABB_Contains_1,Re=e._emscripten_bind_b2DistanceJoint_GetNext_0=i._emscripten_bind_b2DistanceJoint_GetNext_0,Se=e._emscripten_bind_b2GearJoint_GetReactionForce_1=i._emscripten_bind_b2GearJoint_GetReactionForce_1,Te=e._emscripten_bind_b2PrismaticJoint_GetNext_0=i._emscripten_bind_b2PrismaticJoint_GetNext_0,Ue=e._emscripten_bind_b2Filter_get_groupIndex_0=i._emscripten_bind_b2Filter_get_groupIndex_0,Ve=e._emscripten_bind_b2PrismaticJoint_GetType_0=i._emscripten_bind_b2PrismaticJoint_GetType_0, We=e._emscripten_bind_b2Fixture_GetRestitution_0=i._emscripten_bind_b2Fixture_GetRestitution_0,Xe=e._emscripten_bind_b2Transform_set_q_1=i._emscripten_bind_b2Transform_set_q_1,Ye=e._emscripten_bind_b2PolygonShape___destroy___0=i._emscripten_bind_b2PolygonShape___destroy___0,Ze=e._emscripten_bind_b2AABB_get_upperBound_0=i._emscripten_bind_b2AABB_get_upperBound_0,$e=e._emscripten_bind_b2Transform___destroy___0=i._emscripten_bind_b2Transform___destroy___0,af=e._emscripten_bind_b2WeldJointDef_set_localAnchorB_1= i._emscripten_bind_b2WeldJointDef_set_localAnchorB_1,bf=e._emscripten_bind_b2CircleShape_set_m_radius_1=i._emscripten_bind_b2CircleShape_set_m_radius_1,cf=e._emscripten_bind_b2EdgeShape_set_m_hasVertex0_1=i._emscripten_bind_b2EdgeShape_set_m_hasVertex0_1,df=e._emscripten_bind_b2RopeJoint_GetMaxLength_0=i._emscripten_bind_b2RopeJoint_GetMaxLength_0,ef=e._emscripten_bind_b2GearJoint_GetUserData_0=i._emscripten_bind_b2GearJoint_GetUserData_0,ff=e._emscripten_bind_b2MotorJoint_GetCollideConnected_0=i._emscripten_bind_b2MotorJoint_GetCollideConnected_0, gf=e._emscripten_bind_b2GearJointDef_set_type_1=i._emscripten_bind_b2GearJointDef_set_type_1,hf=e._emscripten_bind_b2DistanceJoint_SetDampingRatio_1=i._emscripten_bind_b2DistanceJoint_SetDampingRatio_1,jf=e._emscripten_bind_b2Contact_GetFixtureA_0=i._emscripten_bind_b2Contact_GetFixtureA_0,kf=e._emscripten_bind_b2QueryCallback___destroy___0=i._emscripten_bind_b2QueryCallback___destroy___0,lf=e._emscripten_bind_b2PulleyJointDef_get_ratio_0=i._emscripten_bind_b2PulleyJointDef_get_ratio_0,mf=e._emscripten_bind_b2PrismaticJointDef_get_localAnchorB_0= i._emscripten_bind_b2PrismaticJointDef_get_localAnchorB_0,nf=e._emscripten_bind_b2CircleShape_set_m_type_1=i._emscripten_bind_b2CircleShape_set_m_type_1,of=e._emscripten_enum_b2ShapeType_e_typeCount=i._emscripten_enum_b2ShapeType_e_typeCount,pf=e._emscripten_bind_b2Body_SetTransform_2=i._emscripten_bind_b2Body_SetTransform_2,qf=e._emscripten_bind_b2RopeJoint_GetAnchorB_0=i._emscripten_bind_b2RopeJoint_GetAnchorB_0,rf=e._emscripten_bind_b2AABB_set_upperBound_1=i._emscripten_bind_b2AABB_set_upperBound_1, sf=e._emscripten_bind_b2MouseJointDef_get_collideConnected_0=i._emscripten_bind_b2MouseJointDef_get_collideConnected_0,tf=e._emscripten_bind_b2ContactImpulse___destroy___0=i._emscripten_bind_b2ContactImpulse___destroy___0,uf=e._emscripten_bind_b2PrismaticJointDef_b2PrismaticJointDef_0=i._emscripten_bind_b2PrismaticJointDef_b2PrismaticJointDef_0,vf=e._emscripten_bind_b2Vec2_set_x_1=i._emscripten_bind_b2Vec2_set_x_1,wf=e._emscripten_bind_b2RayCastInput___destroy___0=i._emscripten_bind_b2RayCastInput___destroy___0, xf=e._emscripten_bind_b2Body_ApplyForceToCenter_2=i._emscripten_bind_b2Body_ApplyForceToCenter_2,yf=e._emscripten_bind_JSDestructionListener_JSDestructionListener_0=i._emscripten_bind_JSDestructionListener_JSDestructionListener_0,zf=e._emscripten_bind_b2WheelJointDef_set_localAnchorA_1=i._emscripten_bind_b2WheelJointDef_set_localAnchorA_1,Af=e._emscripten_bind_b2FrictionJoint_GetBodyB_0=i._emscripten_bind_b2FrictionJoint_GetBodyB_0,Bf=e._emscripten_bind_b2DistanceJointDef_get_bodyA_0=i._emscripten_bind_b2DistanceJointDef_get_bodyA_0, Cf=e._emscripten_bind_b2WeldJointDef_set_bodyA_1=i._emscripten_bind_b2WeldJointDef_set_bodyA_1,Df=e._emscripten_bind_b2World_SetDestructionListener_1=i._emscripten_bind_b2World_SetDestructionListener_1,Ef=e._emscripten_bind_b2RevoluteJoint_GetJointSpeed_0=i._emscripten_bind_b2RevoluteJoint_GetJointSpeed_0,Ff=e._emscripten_bind_b2WheelJoint_GetLocalAnchorB_0=i._emscripten_bind_b2WheelJoint_GetLocalAnchorB_0,Gf=e._emscripten_bind_b2JointDef___destroy___0=i._emscripten_bind_b2JointDef___destroy___0, Hf=e._emscripten_bind_b2PrismaticJointDef_Initialize_4=i._emscripten_bind_b2PrismaticJointDef_Initialize_4,If=e._emscripten_bind_b2FrictionJointDef_get_localAnchorA_0=i._emscripten_bind_b2FrictionJointDef_get_localAnchorA_0,Jf=e._emscripten_bind_b2CircleShape_GetChildCount_0=i._emscripten_bind_b2CircleShape_GetChildCount_0,Kf=e._emscripten_bind_b2BodyDef_get_bullet_0=i._emscripten_bind_b2BodyDef_get_bullet_0,Lf=e._emscripten_bind_b2ManifoldPoint_get_localPoint_0=i._emscripten_bind_b2ManifoldPoint_get_localPoint_0, Mf=e._emscripten_bind_b2PrismaticJointDef_get_type_0=i._emscripten_bind_b2PrismaticJointDef_get_type_0,Nf=e._emscripten_bind_b2MassData_get_center_0=i._emscripten_bind_b2MassData_get_center_0,Of=e._emscripten_bind_b2World_b2World_1=i._emscripten_bind_b2World_b2World_1,Pf=e._emscripten_bind_b2WheelJoint_GetReactionForce_1=i._emscripten_bind_b2WheelJoint_GetReactionForce_1,Qf=e._emscripten_bind_b2World_SetSubStepping_1=i._emscripten_bind_b2World_SetSubStepping_1,Rf=e._emscripten_bind_b2Vec2_op_add_1= i._emscripten_bind_b2Vec2_op_add_1,Sf=e._emscripten_bind_b2Joint_GetBodyA_0=i._emscripten_bind_b2Joint_GetBodyA_0,Tf=e._emscripten_bind_b2Joint_GetCollideConnected_0=i._emscripten_bind_b2Joint_GetCollideConnected_0,Uf=e._emscripten_bind_b2MotorJoint_GetReactionTorque_1=i._emscripten_bind_b2MotorJoint_GetReactionTorque_1,Vf=e._emscripten_bind_b2WheelJoint_IsMotorEnabled_0=i._emscripten_bind_b2WheelJoint_IsMotorEnabled_0,Wf=e._emscripten_bind_b2WheelJointDef___destroy___0=i._emscripten_bind_b2WheelJointDef___destroy___0, Xf=e._emscripten_bind_b2Vec3_SetZero_0=i._emscripten_bind_b2Vec3_SetZero_0,Yf=e._emscripten_enum_b2JointType_e_pulleyJoint=i._emscripten_enum_b2JointType_e_pulleyJoint,Zf=e._emscripten_bind_b2ChainShape_get_m_nextVertex_0=i._emscripten_bind_b2ChainShape_get_m_nextVertex_0,$f=e._emscripten_bind_b2Contact_SetEnabled_1=i._emscripten_bind_b2Contact_SetEnabled_1,ag=e._emscripten_bind_b2Shape_set_m_radius_1=i._emscripten_bind_b2Shape_set_m_radius_1,bg=e._emscripten_bind_b2GearJointDef_get_joint2_0=i._emscripten_bind_b2GearJointDef_get_joint2_0, cg=e._emscripten_bind_b2World_SetDebugDraw_1=i._emscripten_bind_b2World_SetDebugDraw_1,dg=e._emscripten_bind_b2ContactID_set_key_1=i._emscripten_bind_b2ContactID_set_key_1,eg=e._emscripten_bind_b2RevoluteJointDef_set_collideConnected_1=i._emscripten_bind_b2RevoluteJointDef_set_collideConnected_1,ab=e._malloc=i._malloc,fg=e._emscripten_bind_b2World_GetProxyCount_0=i._emscripten_bind_b2World_GetProxyCount_0,gg=e._emscripten_bind_b2Vec2_Normalize_0=i._emscripten_bind_b2Vec2_Normalize_0,hg=e._emscripten_bind_b2WheelJoint_GetJointSpeed_0= i._emscripten_bind_b2WheelJoint_GetJointSpeed_0,ig=e._emscripten_bind_b2FrictionJointDef_set_localAnchorA_1=i._emscripten_bind_b2FrictionJointDef_set_localAnchorA_1,jg=e._emscripten_bind_b2GearJoint_GetRatio_0=i._emscripten_bind_b2GearJoint_GetRatio_0,kg=e._emscripten_bind_JSRayCastCallback_JSRayCastCallback_0=i._emscripten_bind_JSRayCastCallback_JSRayCastCallback_0,lg=e._emscripten_bind_b2RayCastInput_set_p2_1=i._emscripten_bind_b2RayCastInput_set_p2_1,mg=e._emscripten_bind_b2RevoluteJointDef_get_motorSpeed_0= i._emscripten_bind_b2RevoluteJointDef_get_motorSpeed_0,ng=e._emscripten_bind_b2RayCastOutput_get_normal_0=i._emscripten_bind_b2RayCastOutput_get_normal_0,og=e._emscripten_bind_b2WeldJoint_GetBodyA_0=i._emscripten_bind_b2WeldJoint_GetBodyA_0,pg=e._emscripten_bind_b2MotorJointDef_set_maxForce_1=i._emscripten_bind_b2MotorJointDef_set_maxForce_1,qg=e._emscripten_enum_b2DrawFlag_e_jointBit=i._emscripten_enum_b2DrawFlag_e_jointBit,rg=e._emscripten_bind_b2FixtureDef_get_isSensor_0=i._emscripten_bind_b2FixtureDef_get_isSensor_0, sg=e._emscripten_bind_b2PulleyJointDef_set_bodyB_1=i._emscripten_bind_b2PulleyJointDef_set_bodyB_1,tg=e._emscripten_bind_b2WheelJoint_EnableMotor_1=i._emscripten_bind_b2WheelJoint_EnableMotor_1,ug=e._emscripten_bind_b2WheelJoint_GetLocalAnchorA_0=i._emscripten_bind_b2WheelJoint_GetLocalAnchorA_0,vg=e._emscripten_bind_JSDraw_DrawSolidPolygon_3=i._emscripten_bind_JSDraw_DrawSolidPolygon_3,wg=e._emscripten_bind_b2Rot_Set_1=i._emscripten_bind_b2Rot_Set_1,xg=e._emscripten_bind_b2ContactFeature_set_typeB_1= i._emscripten_bind_b2ContactFeature_set_typeB_1,yg=e._emscripten_bind_JSDraw___destroy___0=i._emscripten_bind_JSDraw___destroy___0,zg=e._emscripten_bind_b2MouseJointDef___destroy___0=i._emscripten_bind_b2MouseJointDef___destroy___0,Ag=e._emscripten_bind_b2Mat33_Solve22_1=i._emscripten_bind_b2Mat33_Solve22_1,Bg=e._emscripten_bind_b2Profile_set_solvePosition_1=i._emscripten_bind_b2Profile_set_solvePosition_1,Cg=e._emscripten_bind_b2ContactFilter___destroy___0=i._emscripten_bind_b2ContactFilter___destroy___0, Dg=e._emscripten_bind_b2PulleyJointDef_get_localAnchorB_0=i._emscripten_bind_b2PulleyJointDef_get_localAnchorB_0,Eg=e._emscripten_bind_b2ChainShape_set_m_hasPrevVertex_1=i._emscripten_bind_b2ChainShape_set_m_hasPrevVertex_1,Fg=e._emscripten_bind_b2PrismaticJoint___destroy___0=i._emscripten_bind_b2PrismaticJoint___destroy___0,Gg=e._emscripten_bind_b2World_CreateJoint_1=i._emscripten_bind_b2World_CreateJoint_1,Hg=e._emscripten_bind_b2Profile_get_solveTOI_0=i._emscripten_bind_b2Profile_get_solveTOI_0, Ig=e._emscripten_bind_b2ManifoldPoint_get_id_0=i._emscripten_bind_b2ManifoldPoint_get_id_0,Jg=e._emscripten_bind_b2Manifold_set_pointCount_1=i._emscripten_bind_b2Manifold_set_pointCount_1,Kg=e._emscripten_bind_b2PrismaticJoint_GetMotorSpeed_0=i._emscripten_bind_b2PrismaticJoint_GetMotorSpeed_0,Lg=e._emscripten_bind_b2Body_SetSleepingAllowed_1=i._emscripten_bind_b2Body_SetSleepingAllowed_1,Mg=e._emscripten_bind_b2Rot_SetIdentity_0=i._emscripten_bind_b2Rot_SetIdentity_0,Ng=e._emscripten_bind_b2PulleyJoint_GetGroundAnchorB_0= i._emscripten_bind_b2PulleyJoint_GetGroundAnchorB_0,Og=e._emscripten_bind_b2Vec3_op_add_1=i._emscripten_bind_b2Vec3_op_add_1,Pg=e._emscripten_bind_b2FrictionJoint_GetType_0=i._emscripten_bind_b2FrictionJoint_GetType_0,Qg=e._emscripten_bind_b2DistanceJointDef_set_dampingRatio_1=i._emscripten_bind_b2DistanceJointDef_set_dampingRatio_1,Rg=e._emscripten_bind_b2MotorJoint_GetBodyA_0=i._emscripten_bind_b2MotorJoint_GetBodyA_0,Sg=e._emscripten_bind_b2MouseJointDef_get_dampingRatio_0=i._emscripten_bind_b2MouseJointDef_get_dampingRatio_0, Tg=e._emscripten_bind_b2RevoluteJoint_GetMotorSpeed_0=i._emscripten_bind_b2RevoluteJoint_GetMotorSpeed_0,Ug=e._emscripten_bind_b2ChainShape_set_m_type_1=i._emscripten_bind_b2ChainShape_set_m_type_1,Vg=e._emscripten_bind_b2RevoluteJointDef_set_bodyB_1=i._emscripten_bind_b2RevoluteJointDef_set_bodyB_1,Wg=e._emscripten_bind_b2Body_GetGravityScale_0=i._emscripten_bind_b2Body_GetGravityScale_0,Xg=e._emscripten_bind_b2GearJointDef_get_bodyB_0=i._emscripten_bind_b2GearJointDef_get_bodyB_0,Yg=e._emscripten_bind_b2Mat33_b2Mat33_0= i._emscripten_bind_b2Mat33_b2Mat33_0,Zg=e._emscripten_bind_b2MouseJointDef_get_bodyB_0=i._emscripten_bind_b2MouseJointDef_get_bodyB_0,$g=e._emscripten_bind_b2Shape_TestPoint_2=i._emscripten_bind_b2Shape_TestPoint_2,ah=e._emscripten_bind_b2Body_GetWorldVector_1=i._emscripten_bind_b2Body_GetWorldVector_1,bh=e._emscripten_bind_b2WeldJointDef_get_frequencyHz_0=i._emscripten_bind_b2WeldJointDef_get_frequencyHz_0,ch=e._emscripten_bind_b2PolygonShape_Set_2=i._emscripten_bind_b2PolygonShape_Set_2,dh=e._emscripten_bind_b2Manifold___destroy___0= i._emscripten_bind_b2Manifold___destroy___0,eh=e._emscripten_bind_b2PulleyJointDef_set_lengthA_1=i._emscripten_bind_b2PulleyJointDef_set_lengthA_1,fh=e._emscripten_bind_b2RevoluteJointDef_set_localAnchorA_1=i._emscripten_bind_b2RevoluteJointDef_set_localAnchorA_1,gh=e._emscripten_bind_b2GearJoint___destroy___0=i._emscripten_bind_b2GearJoint___destroy___0,hh=e._emscripten_bind_b2RevoluteJoint_GetJointAngle_0=i._emscripten_bind_b2RevoluteJoint_GetJointAngle_0,ih=e._emscripten_bind_b2PulleyJointDef_set_ratio_1= i._emscripten_bind_b2PulleyJointDef_set_ratio_1,jh=e._emscripten_bind_b2JointEdge_set_prev_1=i._emscripten_bind_b2JointEdge_set_prev_1,kh=e._emscripten_bind_b2PrismaticJoint_GetReactionTorque_1=i._emscripten_bind_b2PrismaticJoint_GetReactionTorque_1,lh=e._emscripten_bind_b2Body_GetLocalPoint_1=i._emscripten_bind_b2Body_GetLocalPoint_1,mh=e._emscripten_bind_b2PrismaticJoint_GetCollideConnected_0=i._emscripten_bind_b2PrismaticJoint_GetCollideConnected_0,nh=e._emscripten_bind_b2RopeJointDef_get_userData_0= i._emscripten_bind_b2RopeJointDef_get_userData_0,oh=e._emscripten_bind_b2DistanceJoint_IsActive_0=i._emscripten_bind_b2DistanceJoint_IsActive_0,ph=e._emscripten_bind_b2MotorJointDef_set_angularOffset_1=i._emscripten_bind_b2MotorJointDef_set_angularOffset_1,qh=e._emscripten_bind_b2Vec2_b2Vec2_2=i._emscripten_bind_b2Vec2_b2Vec2_2,rh=e._emscripten_bind_b2PrismaticJoint_GetJointTranslation_0=i._emscripten_bind_b2PrismaticJoint_GetJointTranslation_0,sh=e._emscripten_bind_b2Vec2_b2Vec2_0=i._emscripten_bind_b2Vec2_b2Vec2_0, th=e._emscripten_bind_b2DistanceJoint_GetAnchorB_0=i._emscripten_bind_b2DistanceJoint_GetAnchorB_0,uh=e._emscripten_bind_b2WheelJointDef_get_maxMotorTorque_0=i._emscripten_bind_b2WheelJointDef_get_maxMotorTorque_0,vh=e._emscripten_bind_b2Vec2_op_sub_1=i._emscripten_bind_b2Vec2_op_sub_1,wh=e._emscripten_bind_b2CircleShape_get_m_p_0=i._emscripten_bind_b2CircleShape_get_m_p_0,xh=e._emscripten_bind_b2ContactFeature_get_indexA_0=i._emscripten_bind_b2ContactFeature_get_indexA_0,yh=e._emscripten_bind_b2MotorJointDef_b2MotorJointDef_0= i._emscripten_bind_b2MotorJointDef_b2MotorJointDef_0,zh=e._emscripten_bind_b2ChainShape_set_m_nextVertex_1=i._emscripten_bind_b2ChainShape_set_m_nextVertex_1,Ah=e._emscripten_bind_b2PulleyJoint_GetCollideConnected_0=i._emscripten_bind_b2PulleyJoint_GetCollideConnected_0,Bh=e._emscripten_bind_b2PulleyJoint_GetAnchorB_0=i._emscripten_bind_b2PulleyJoint_GetAnchorB_0,Ch=e._emscripten_bind_b2Mat33_get_ex_0=i._emscripten_bind_b2Mat33_get_ex_0,Dh=e._emscripten_bind_b2Body_GetPosition_0=i._emscripten_bind_b2Body_GetPosition_0, Eh=e._emscripten_bind_b2Profile___destroy___0=i._emscripten_bind_b2Profile___destroy___0,Fh=e._emscripten_bind_b2ContactEdge_get_prev_0=i._emscripten_bind_b2ContactEdge_get_prev_0,Gh=e._emscripten_bind_b2DistanceJoint_SetFrequency_1=i._emscripten_bind_b2DistanceJoint_SetFrequency_1,Hh=e._emscripten_enum_b2ShapeType_e_chain=i._emscripten_enum_b2ShapeType_e_chain,Ih=e._emscripten_enum_b2ContactFeatureType_e_vertex=i._emscripten_enum_b2ContactFeatureType_e_vertex,Jh=e._emscripten_bind_b2Fixture_GetBody_0= i._emscripten_bind_b2Fixture_GetBody_0,Kh=e._emscripten_bind_b2ContactImpulse_set_count_1=i._emscripten_bind_b2ContactImpulse_set_count_1,Lh=e._emscripten_bind_b2PulleyJointDef_get_bodyB_0=i._emscripten_bind_b2PulleyJointDef_get_bodyB_0,Mh=e._emscripten_bind_b2Rot_set_c_1=i._emscripten_bind_b2Rot_set_c_1,Nh=e._emscripten_bind_b2RevoluteJoint_GetReactionTorque_1=i._emscripten_bind_b2RevoluteJoint_GetReactionTorque_1,Oh=e._emscripten_bind_b2Fixture_SetDensity_1=i._emscripten_bind_b2Fixture_SetDensity_1, Ph=e._emscripten_bind_b2ChainShape_get_m_prevVertex_0=i._emscripten_bind_b2ChainShape_get_m_prevVertex_0,Qh=e._emscripten_bind_b2World_ClearForces_0=i._emscripten_bind_b2World_ClearForces_0,Rh=e._emscripten_bind_b2Vec3___destroy___0=i._emscripten_bind_b2Vec3___destroy___0,Sh=e._emscripten_bind_b2WheelJointDef_set_userData_1=i._emscripten_bind_b2WheelJointDef_set_userData_1,Th=e._emscripten_bind_b2WeldJoint_SetFrequency_1=i._emscripten_bind_b2WeldJoint_SetFrequency_1,Uh=e._emscripten_bind_b2WheelJoint_SetSpringFrequencyHz_1= i._emscripten_bind_b2WheelJoint_SetSpringFrequencyHz_1,Vh=e._emscripten_bind_b2Body_SetFixedRotation_1=i._emscripten_bind_b2Body_SetFixedRotation_1,Wh=e._emscripten_bind_b2RayCastOutput_set_normal_1=i._emscripten_bind_b2RayCastOutput_set_normal_1,Xh=e._emscripten_bind_b2DistanceJoint_GetDampingRatio_0=i._emscripten_bind_b2DistanceJoint_GetDampingRatio_0,Yh=e._emscripten_bind_b2WeldJointDef_set_userData_1=i._emscripten_bind_b2WeldJointDef_set_userData_1,Zh=e._emscripten_bind_b2Body_GetMassData_1=i._emscripten_bind_b2Body_GetMassData_1, $h=e._emscripten_bind_b2MouseJointDef_set_bodyB_1=i._emscripten_bind_b2MouseJointDef_set_bodyB_1,ai=e._emscripten_bind_b2CircleShape_GetType_0=i._emscripten_bind_b2CircleShape_GetType_0,bi=e._emscripten_bind_b2PolygonShape_GetType_0=i._emscripten_bind_b2PolygonShape_GetType_0,ci=e._emscripten_bind_b2PrismaticJointDef_set_referenceAngle_1=i._emscripten_bind_b2PrismaticJointDef_set_referenceAngle_1,di=e._emscripten_bind_b2RopeJointDef_get_collideConnected_0=i._emscripten_bind_b2RopeJointDef_get_collideConnected_0, ei=e._emscripten_bind_b2FixtureDef_set_filter_1=i._emscripten_bind_b2FixtureDef_set_filter_1,fi=e._emscripten_bind_b2PulleyJointDef_get_groundAnchorA_0=i._emscripten_bind_b2PulleyJointDef_get_groundAnchorA_0,gi=e._emscripten_bind_b2Fixture_SetFilterData_1=i._emscripten_bind_b2Fixture_SetFilterData_1,hi=e._emscripten_bind_b2FrictionJointDef_get_userData_0=i._emscripten_bind_b2FrictionJointDef_get_userData_0,ii=e._emscripten_bind_b2RayCastCallback___destroy___0=i._emscripten_bind_b2RayCastCallback___destroy___0, ji=e._emscripten_bind_b2PulleyJointDef_set_localAnchorA_1=i._emscripten_bind_b2PulleyJointDef_set_localAnchorA_1,ki=e._emscripten_bind_b2MotorJoint_SetUserData_1=i._emscripten_bind_b2MotorJoint_SetUserData_1,li=e._emscripten_bind_b2PrismaticJoint_GetLocalAxisA_0=i._emscripten_bind_b2PrismaticJoint_GetLocalAxisA_0,mi=e._emscripten_bind_b2MotorJoint_GetBodyB_0=i._emscripten_bind_b2MotorJoint_GetBodyB_0,ni=e._emscripten_bind_b2Transform_Set_2=i._emscripten_bind_b2Transform_Set_2,oi=e._emscripten_bind_b2MouseJoint_SetTarget_1= i._emscripten_bind_b2MouseJoint_SetTarget_1,pi=e._emscripten_bind_b2RopeJointDef_get_localAnchorA_0=i._emscripten_bind_b2RopeJointDef_get_localAnchorA_0,qi=e._emscripten_bind_b2ContactEdge_set_contact_1=i._emscripten_bind_b2ContactEdge_set_contact_1,ri=e._emscripten_bind_b2RevoluteJointDef_get_enableLimit_0=i._emscripten_bind_b2RevoluteJointDef_get_enableLimit_0,si=e._emscripten_bind_b2CircleShape_get_m_radius_0=i._emscripten_bind_b2CircleShape_get_m_radius_0,ti=e._emscripten_bind_b2RevoluteJoint_GetUserData_0= i._emscripten_bind_b2RevoluteJoint_GetUserData_0,ui=e._emscripten_bind_b2Profile_set_solveTOI_1=i._emscripten_bind_b2Profile_set_solveTOI_1,vi=e._emscripten_bind_b2PrismaticJointDef_set_type_1=i._emscripten_bind_b2PrismaticJointDef_set_type_1,wi=e._emscripten_bind_b2GearJointDef_get_userData_0=i._emscripten_bind_b2GearJointDef_get_userData_0,xi=e._emscripten_bind_b2RevoluteJoint_GetAnchorB_0=i._emscripten_bind_b2RevoluteJoint_GetAnchorB_0,yi=e._emscripten_bind_b2FrictionJointDef___destroy___0=i._emscripten_bind_b2FrictionJointDef___destroy___0, zi=e._emscripten_bind_b2PrismaticJoint_GetReactionForce_1=i._emscripten_bind_b2PrismaticJoint_GetReactionForce_1,Ai=e._emscripten_bind_b2Transform_b2Transform_0=i._emscripten_bind_b2Transform_b2Transform_0,Bi=e._emscripten_bind_b2MouseJoint_GetCollideConnected_0=i._emscripten_bind_b2MouseJoint_GetCollideConnected_0,Ci=e._emscripten_enum_b2LimitState_e_equalLimits=i._emscripten_enum_b2LimitState_e_equalLimits,Di=e._emscripten_bind_b2ManifoldPoint_set_normalImpulse_1=i._emscripten_bind_b2ManifoldPoint_set_normalImpulse_1, Ei=e._emscripten_bind_b2Body_GetContactList_0=i._emscripten_bind_b2Body_GetContactList_0,Fi=e._emscripten_bind_b2Body_IsFixedRotation_0=i._emscripten_bind_b2Body_IsFixedRotation_0,Gi=e._emscripten_enum_b2DrawFlag_e_shapeBit=i._emscripten_enum_b2DrawFlag_e_shapeBit,Hi=e._emscripten_bind_b2Contact_GetFriction_0=i._emscripten_bind_b2Contact_GetFriction_0,Ii=e._emscripten_bind_b2WheelJoint_GetAnchorB_0=i._emscripten_bind_b2WheelJoint_GetAnchorB_0,Ji=e._emscripten_bind_b2DistanceJointDef_set_length_1= i._emscripten_bind_b2DistanceJointDef_set_length_1,Ki=e._emscripten_bind_b2DistanceJoint_GetLocalAnchorB_0=i._emscripten_bind_b2DistanceJoint_GetLocalAnchorB_0,Li=e._emscripten_bind_b2FrictionJoint_GetLocalAnchorB_0=i._emscripten_bind_b2FrictionJoint_GetLocalAnchorB_0,Mi=e._emscripten_bind_b2Mat33_set_ey_1=i._emscripten_bind_b2Mat33_set_ey_1,Ni=e._emscripten_bind_b2DistanceJointDef_get_type_0=i._emscripten_bind_b2DistanceJointDef_get_type_0,Oi=e._emscripten_bind_b2Draw_ClearFlags_1=i._emscripten_bind_b2Draw_ClearFlags_1, Pi=e._emscripten_bind_b2Body_IsActive_0=i._emscripten_bind_b2Body_IsActive_0,Qi=e._emscripten_bind_b2Contact_ResetRestitution_0=i._emscripten_bind_b2Contact_ResetRestitution_0,Ri=e._emscripten_bind_b2World_GetAllowSleeping_0=i._emscripten_bind_b2World_GetAllowSleeping_0,Si=e._emscripten_bind_b2ManifoldPoint_b2ManifoldPoint_0=i._emscripten_bind_b2ManifoldPoint_b2ManifoldPoint_0,Ti=e._emscripten_bind_b2PrismaticJointDef_set_maxMotorForce_1=i._emscripten_bind_b2PrismaticJointDef_set_maxMotorForce_1, Ui=e._emscripten_bind_b2GearJointDef_set_bodyA_1=i._emscripten_bind_b2GearJointDef_set_bodyA_1,Vi=e._emscripten_bind_b2RevoluteJointDef_set_enableMotor_1=i._emscripten_bind_b2RevoluteJointDef_set_enableMotor_1,Wi=e._emscripten_bind_b2PulleyJoint_IsActive_0=i._emscripten_bind_b2PulleyJoint_IsActive_0,Xi=e._emscripten_bind_b2MouseJoint_GetNext_0=i._emscripten_bind_b2MouseJoint_GetNext_0,Yi=e._emscripten_bind_b2Transform_set_p_1=i._emscripten_bind_b2Transform_set_p_1,Zi=e._emscripten_bind_b2EdgeShape_set_m_vertex0_1= i._emscripten_bind_b2EdgeShape_set_m_vertex0_1,$i=e._emscripten_bind_b2PulleyJointDef_get_lengthB_0=i._emscripten_bind_b2PulleyJointDef_get_lengthB_0,aj=e._emscripten_bind_b2WeldJoint_SetUserData_1=i._emscripten_bind_b2WeldJoint_SetUserData_1,bj=e._emscripten_bind_b2Fixture_SetSensor_1=i._emscripten_bind_b2Fixture_SetSensor_1,cj=e._emscripten_bind_b2GearJointDef_get_joint1_0=i._emscripten_bind_b2GearJointDef_get_joint1_0,dj=e._emscripten_bind_b2PrismaticJoint_GetMotorForce_1=i._emscripten_bind_b2PrismaticJoint_GetMotorForce_1, ej=e._emscripten_bind_b2DistanceJoint_GetBodyA_0=i._emscripten_bind_b2DistanceJoint_GetBodyA_0,fj=e._emscripten_bind_b2GearJoint_IsActive_0=i._emscripten_bind_b2GearJoint_IsActive_0,gj=e._emscripten_bind_b2EdgeShape_get_m_vertex0_0=i._emscripten_bind_b2EdgeShape_get_m_vertex0_0,hj=e._emscripten_bind_b2World_GetBodyCount_0=i._emscripten_bind_b2World_GetBodyCount_0,ij=e._emscripten_bind_b2Fixture_GetMassData_1=i._emscripten_bind_b2Fixture_GetMassData_1,jj=e._emscripten_bind_b2WeldJointDef_get_collideConnected_0= i._emscripten_bind_b2WeldJointDef_get_collideConnected_0,kj=e._emscripten_bind_b2FrictionJoint_GetMaxTorque_0=i._emscripten_bind_b2FrictionJoint_GetMaxTorque_0,lj=e._emscripten_bind_b2EdgeShape_RayCast_4=i._emscripten_bind_b2EdgeShape_RayCast_4,mj=e._emscripten_bind_b2BodyDef_set_allowSleep_1=i._emscripten_bind_b2BodyDef_set_allowSleep_1,nj=e._emscripten_bind_b2PulleyJoint_GetType_0=i._emscripten_bind_b2PulleyJoint_GetType_0,oj=e._emscripten_bind_b2WeldJointDef_set_localAnchorA_1=i._emscripten_bind_b2WeldJointDef_set_localAnchorA_1, pj=e._emscripten_bind_b2Profile_set_step_1=i._emscripten_bind_b2Profile_set_step_1,qj=e._emscripten_bind_b2ContactEdge_set_other_1=i._emscripten_bind_b2ContactEdge_set_other_1,rj=e._emscripten_bind_b2PulleyJoint_GetCurrentLengthB_0=i._emscripten_bind_b2PulleyJoint_GetCurrentLengthB_0,sj=e._emscripten_bind_b2Vec2_op_mul_1=i._emscripten_bind_b2Vec2_op_mul_1,tj=e._emscripten_bind_b2PrismaticJointDef_get_localAnchorA_0=i._emscripten_bind_b2PrismaticJointDef_get_localAnchorA_0,uj=e._emscripten_bind_b2EdgeShape___destroy___0= i._emscripten_bind_b2EdgeShape___destroy___0,vj=e._emscripten_bind_b2RopeJoint_GetAnchorA_0=i._emscripten_bind_b2RopeJoint_GetAnchorA_0,wj=e._emscripten_bind_b2World_GetContactCount_0=i._emscripten_bind_b2World_GetContactCount_0,xj=e._emscripten_bind_b2MotorJointDef_set_correctionFactor_1=i._emscripten_bind_b2MotorJointDef_set_correctionFactor_1,yj=e._emscripten_bind_b2DistanceJointDef_set_userData_1=i._emscripten_bind_b2DistanceJointDef_set_userData_1,zj=e._emscripten_bind_b2ContactEdge_get_other_0= i._emscripten_bind_b2ContactEdge_get_other_0,Aj=e._emscripten_bind_b2RopeJoint_GetLocalAnchorB_0=i._emscripten_bind_b2RopeJoint_GetLocalAnchorB_0,Bj=e._emscripten_bind_b2PulleyJointDef___destroy___0=i._emscripten_bind_b2PulleyJointDef___destroy___0,Cj=e._emscripten_bind_b2MouseJoint_GetBodyB_0=i._emscripten_bind_b2MouseJoint_GetBodyB_0,Dj=e._emscripten_bind_b2PolygonShape_TestPoint_2=i._emscripten_bind_b2PolygonShape_TestPoint_2,Ej=e._emscripten_bind_b2EdgeShape_set_m_vertex3_1=i._emscripten_bind_b2EdgeShape_set_m_vertex3_1, Fj=e._emscripten_bind_b2PolygonShape_b2PolygonShape_0=i._emscripten_bind_b2PolygonShape_b2PolygonShape_0,Gj=e._emscripten_bind_b2GearJointDef_set_ratio_1=i._emscripten_bind_b2GearJointDef_set_ratio_1,Hj=e._emscripten_bind_b2WheelJoint_SetMaxMotorTorque_1=i._emscripten_bind_b2WheelJoint_SetMaxMotorTorque_1,Ij=e._emscripten_bind_b2WheelJointDef_get_localAxisA_0=i._emscripten_bind_b2WheelJointDef_get_localAxisA_0,Jj=e._emscripten_bind_b2DistanceJointDef_get_localAnchorA_0=i._emscripten_bind_b2DistanceJointDef_get_localAnchorA_0, Kj=e._emscripten_bind_b2MassData_set_center_1=i._emscripten_bind_b2MassData_set_center_1,Lj=e._emscripten_bind_b2Contact_SetTangentSpeed_1=i._emscripten_bind_b2Contact_SetTangentSpeed_1,Mj=e._emscripten_bind_b2FrictionJointDef_get_localAnchorB_0=i._emscripten_bind_b2FrictionJointDef_get_localAnchorB_0,Nj=e._emscripten_bind_b2BodyDef_get_active_0=i._emscripten_bind_b2BodyDef_get_active_0,Oj=e._emscripten_bind_b2Body_GetAngularVelocity_0=i._emscripten_bind_b2Body_GetAngularVelocity_0,Pj=e._emscripten_bind_b2WeldJoint_GetBodyB_0= i._emscripten_bind_b2WeldJoint_GetBodyB_0,Qj=e._emscripten_bind_b2Draw___destroy___0=i._emscripten_bind_b2Draw___destroy___0,Rj=e._emscripten_bind_b2WheelJointDef_Initialize_4=i._emscripten_bind_b2WheelJointDef_Initialize_4,Sj=e._emscripten_bind_b2WeldJointDef_set_dampingRatio_1=i._emscripten_bind_b2WeldJointDef_set_dampingRatio_1,Tj=e._emscripten_bind_b2Contact_IsEnabled_0=i._emscripten_bind_b2Contact_IsEnabled_0,Uj=e._emscripten_bind_b2Joint_GetAnchorB_0=i._emscripten_bind_b2Joint_GetAnchorB_0, Vj=e._emscripten_bind_b2PrismaticJointDef_get_userData_0=i._emscripten_bind_b2PrismaticJointDef_get_userData_0,Wj=e._emscripten_bind_b2MotorJoint_GetMaxForce_0=i._emscripten_bind_b2MotorJoint_GetMaxForce_0,Xj=e._emscripten_bind_b2RevoluteJoint_GetBodyA_0=i._emscripten_bind_b2RevoluteJoint_GetBodyA_0,Yj=e._emscripten_bind_b2ContactID_set_cf_1=i._emscripten_bind_b2ContactID_set_cf_1,Zj=e._emscripten_bind_b2Rot_GetXAxis_0=i._emscripten_bind_b2Rot_GetXAxis_0,$j=e._emscripten_bind_b2ContactEdge_set_prev_1= i._emscripten_bind_b2ContactEdge_set_prev_1,ak=e._emscripten_bind_b2Vec3_Set_3=i._emscripten_bind_b2Vec3_Set_3,bk=e._emscripten_bind_b2Fixture_GetNext_0=i._emscripten_bind_b2Fixture_GetNext_0,ck=e._emscripten_bind_b2FrictionJointDef_set_localAnchorB_1=i._emscripten_bind_b2FrictionJointDef_set_localAnchorB_1,dk=e._emscripten_bind_b2PulleyJoint_GetNext_0=i._emscripten_bind_b2PulleyJoint_GetNext_0,ek=e._emscripten_bind_b2ChainShape_get_m_type_0=i._emscripten_bind_b2ChainShape_get_m_type_0,fk=e._emscripten_bind_b2GearJointDef_get_bodyA_0= i._emscripten_bind_b2GearJointDef_get_bodyA_0,gk=e._emscripten_bind_b2DistanceJointDef_set_frequencyHz_1=i._emscripten_bind_b2DistanceJointDef_set_frequencyHz_1,hk=e._emscripten_bind_b2RevoluteJointDef_get_localAnchorB_0=i._emscripten_bind_b2RevoluteJointDef_get_localAnchorB_0,ik=e._emscripten_bind_b2RevoluteJointDef_get_referenceAngle_0=i._emscripten_bind_b2RevoluteJointDef_get_referenceAngle_0,jk=e._emscripten_bind_JSContactFilter___destroy___0=i._emscripten_bind_JSContactFilter___destroy___0,Wb= e._memset=i._memset,kk=e._emscripten_bind_b2PolygonShape_get_m_radius_0=i._emscripten_bind_b2PolygonShape_get_m_radius_0,lk=e._emscripten_bind_b2RopeJoint_GetUserData_0=i._emscripten_bind_b2RopeJoint_GetUserData_0,mk=e._emscripten_bind_b2RopeJointDef_get_bodyA_0=i._emscripten_bind_b2RopeJointDef_get_bodyA_0,nk=e._emscripten_bind_b2DistanceJointDef_get_dampingRatio_0=i._emscripten_bind_b2DistanceJointDef_get_dampingRatio_0,ok=e._emscripten_enum_b2ManifoldType_e_faceA=i._emscripten_enum_b2ManifoldType_e_faceA, pk=e._emscripten_enum_b2ManifoldType_e_faceB=i._emscripten_enum_b2ManifoldType_e_faceB,qk=e._emscripten_bind_b2RevoluteJointDef_get_bodyB_0=i._emscripten_bind_b2RevoluteJointDef_get_bodyB_0,rk=e._emscripten_bind_b2FixtureDef_b2FixtureDef_0=i._emscripten_bind_b2FixtureDef_b2FixtureDef_0,sk=e._emscripten_bind_b2PrismaticJoint_SetUserData_1=i._emscripten_bind_b2PrismaticJoint_SetUserData_1,tk=e._emscripten_bind_b2EdgeShape_get_m_hasVertex3_0=i._emscripten_bind_b2EdgeShape_get_m_hasVertex3_0,uk=e._emscripten_enum_b2ShapeType_e_edge= i._emscripten_enum_b2ShapeType_e_edge,vk=e._emscripten_bind_b2RevoluteJoint_GetMaxMotorTorque_0=i._emscripten_bind_b2RevoluteJoint_GetMaxMotorTorque_0,wk=e._emscripten_bind_b2BodyDef_set_active_1=i._emscripten_bind_b2BodyDef_set_active_1,xk=e._emscripten_bind_b2DistanceJointDef_set_localAnchorB_1=i._emscripten_bind_b2DistanceJointDef_set_localAnchorB_1,yk=e._emscripten_bind_b2Body_GetWorldPoint_1=i._emscripten_bind_b2Body_GetWorldPoint_1,zk=e._emscripten_bind_b2ManifoldPoint_get_normalImpulse_0=i._emscripten_bind_b2ManifoldPoint_get_normalImpulse_0, Ak=e._emscripten_bind_JSContactFilter_ShouldCollide_2=i._emscripten_bind_JSContactFilter_ShouldCollide_2,Bk=e._emscripten_bind_b2Joint_GetReactionTorque_1=i._emscripten_bind_b2Joint_GetReactionTorque_1,Ck=e._emscripten_bind_b2RevoluteJointDef_set_type_1=i._emscripten_bind_b2RevoluteJointDef_set_type_1,Dk=e._emscripten_bind_b2RopeJointDef_b2RopeJointDef_0=i._emscripten_bind_b2RopeJointDef_b2RopeJointDef_0,Ek=e._emscripten_bind_b2BodyDef_get_linearDamping_0=i._emscripten_bind_b2BodyDef_get_linearDamping_0, Fk=e._emscripten_bind_b2MotorJointDef_get_bodyB_0=i._emscripten_bind_b2MotorJointDef_get_bodyB_0,Gk=e._emscripten_bind_b2World_Step_3=i._emscripten_bind_b2World_Step_3,Hk=e._emscripten_bind_b2CircleShape_RayCast_4=i._emscripten_bind_b2CircleShape_RayCast_4,Ik=e._emscripten_bind_b2Profile_get_step_0=i._emscripten_bind_b2Profile_get_step_0,Jk=e._emscripten_bind_b2Vec3_b2Vec3_0=i._emscripten_bind_b2Vec3_b2Vec3_0,Kk=e._emscripten_bind_b2Vec3_b2Vec3_3=i._emscripten_bind_b2Vec3_b2Vec3_3,Lk=e._emscripten_bind_b2PulleyJoint_GetLengthB_0= i._emscripten_bind_b2PulleyJoint_GetLengthB_0,Mk=e._emscripten_bind_b2Filter_set_categoryBits_1=i._emscripten_bind_b2Filter_set_categoryBits_1,Nk=e._emscripten_bind_b2MotorJoint_GetUserData_0=i._emscripten_bind_b2MotorJoint_GetUserData_0,Ok=e._emscripten_bind_b2PrismaticJoint_GetLocalAnchorA_0=i._emscripten_bind_b2PrismaticJoint_GetLocalAnchorA_0,Pk=e._emscripten_bind_b2Shape_get_m_type_0=i._emscripten_bind_b2Shape_get_m_type_0,Qk=e._emscripten_bind_b2MouseJoint_SetDampingRatio_1=i._emscripten_bind_b2MouseJoint_SetDampingRatio_1, Rk=e._emscripten_bind_b2World_GetAutoClearForces_0=i._emscripten_bind_b2World_GetAutoClearForces_0,Sk=e._emscripten_enum_b2ShapeType_e_circle=i._emscripten_enum_b2ShapeType_e_circle,Tk=e._emscripten_bind_b2BodyDef_set_fixedRotation_1=i._emscripten_bind_b2BodyDef_set_fixedRotation_1,Uk=e._emscripten_bind_b2RopeJoint_GetLimitState_0=i._emscripten_bind_b2RopeJoint_GetLimitState_0,Vk=e._emscripten_bind_b2JointDef_get_collideConnected_0=i._emscripten_bind_b2JointDef_get_collideConnected_0,Wk=e._emscripten_bind_b2Body_Dump_0= i._emscripten_bind_b2Body_Dump_0,Xk=e._emscripten_bind_b2RevoluteJoint_GetLowerLimit_0=i._emscripten_bind_b2RevoluteJoint_GetLowerLimit_0,Yk=e._emscripten_bind_b2Body_GetWorldCenter_0=i._emscripten_bind_b2Body_GetWorldCenter_0,Zk=e._emscripten_bind_JSContactListener___destroy___0=i._emscripten_bind_JSContactListener___destroy___0,$k=e._emscripten_bind_b2BodyDef_set_linearVelocity_1=i._emscripten_bind_b2BodyDef_set_linearVelocity_1,al=e._emscripten_bind_b2JointDef_set_collideConnected_1=i._emscripten_bind_b2JointDef_set_collideConnected_1, bl=e._emscripten_bind_b2MotorJoint___destroy___0=i._emscripten_bind_b2MotorJoint___destroy___0,cl=e._emscripten_bind_b2Body_GetUserData_0=i._emscripten_bind_b2Body_GetUserData_0,dl=e._emscripten_bind_b2World_GetContinuousPhysics_0=i._emscripten_bind_b2World_GetContinuousPhysics_0,el=e._emscripten_bind_b2Fixture_RayCast_3=i._emscripten_bind_b2Fixture_RayCast_3,fl=e._emscripten_bind_b2JointDef_set_bodyA_1=i._emscripten_bind_b2JointDef_set_bodyA_1,gl=e._emscripten_bind_b2GearJointDef_get_collideConnected_0= i._emscripten_bind_b2GearJointDef_get_collideConnected_0,hl=e._emscripten_bind_b2RopeJointDef_get_maxLength_0=i._emscripten_bind_b2RopeJointDef_get_maxLength_0,il=e._emscripten_bind_b2MouseJointDef_get_bodyA_0=i._emscripten_bind_b2MouseJointDef_get_bodyA_0,jl=e._emscripten_bind_b2Body_SetBullet_1=i._emscripten_bind_b2Body_SetBullet_1,kl=e._emscripten_bind_b2DistanceJoint_GetType_0=i._emscripten_bind_b2DistanceJoint_GetType_0,ll=e._emscripten_bind_b2FixtureDef_get_restitution_0=i._emscripten_bind_b2FixtureDef_get_restitution_0, ml=e._emscripten_bind_b2Fixture_GetType_0=i._emscripten_bind_b2Fixture_GetType_0,nl=e._emscripten_bind_b2PulleyJointDef_set_localAnchorB_1=i._emscripten_bind_b2PulleyJointDef_set_localAnchorB_1,ol=e._emscripten_bind_b2RevoluteJoint_GetBodyB_0=i._emscripten_bind_b2RevoluteJoint_GetBodyB_0,pl=e._emscripten_bind_b2Profile_set_solveInit_1=i._emscripten_bind_b2Profile_set_solveInit_1,ql=e._emscripten_bind_b2RopeJointDef_set_type_1=i._emscripten_bind_b2RopeJointDef_set_type_1,rl=e._emscripten_bind_b2PrismaticJointDef_get_bodyB_0= i._emscripten_bind_b2PrismaticJointDef_get_bodyB_0,sl=e._emscripten_bind_b2Body_SetLinearVelocity_1=i._emscripten_bind_b2Body_SetLinearVelocity_1,tl=e._emscripten_bind_b2RevoluteJoint_GetReferenceAngle_0=i._emscripten_bind_b2RevoluteJoint_GetReferenceAngle_0,ul=e._emscripten_bind_b2PulleyJointDef_get_userData_0=i._emscripten_bind_b2PulleyJointDef_get_userData_0,vl=e._emscripten_bind_b2PrismaticJointDef_set_bodyB_1=i._emscripten_bind_b2PrismaticJointDef_set_bodyB_1,wl=e._emscripten_bind_b2FrictionJointDef_b2FrictionJointDef_0= i._emscripten_bind_b2FrictionJointDef_b2FrictionJointDef_0,eb=e._free=i._free,xl=e._emscripten_bind_b2PulleyJoint_GetCurrentLengthA_0=i._emscripten_bind_b2PulleyJoint_GetCurrentLengthA_0,yl=e._emscripten_bind_b2Manifold_get_localNormal_0=i._emscripten_bind_b2Manifold_get_localNormal_0,zl=e._emscripten_bind_b2AABB_RayCast_2=i._emscripten_bind_b2AABB_RayCast_2,Al=e._emscripten_bind_b2FixtureDef_set_isSensor_1=i._emscripten_bind_b2FixtureDef_set_isSensor_1,Bl=e._emscripten_bind_b2RopeJoint_GetBodyB_0= i._emscripten_bind_b2RopeJoint_GetBodyB_0,Cl=e._emscripten_bind_b2PrismaticJoint_GetAnchorA_0=i._emscripten_bind_b2PrismaticJoint_GetAnchorA_0,Dl=e._emscripten_bind_b2ChainShape_set_m_count_1=i._emscripten_bind_b2ChainShape_set_m_count_1,El=e._emscripten_bind_b2PrismaticJoint_IsMotorEnabled_0=i._emscripten_bind_b2PrismaticJoint_IsMotorEnabled_0,Fl=e._emscripten_bind_b2WeldJoint_GetFrequency_0=i._emscripten_bind_b2WeldJoint_GetFrequency_0,Gl=e._emscripten_bind_b2Joint_GetUserData_0=i._emscripten_bind_b2Joint_GetUserData_0, Hl=e._emscripten_bind_b2RevoluteJointDef_get_lowerAngle_0=i._emscripten_bind_b2RevoluteJointDef_get_lowerAngle_0,Il=e._emscripten_bind_b2Manifold_set_type_1=i._emscripten_bind_b2Manifold_set_type_1,Jl=e._emscripten_bind_b2DistanceJoint_GetLength_0=i._emscripten_bind_b2DistanceJoint_GetLength_0,Kl=e._emscripten_bind_b2RopeJointDef_set_maxLength_1=i._emscripten_bind_b2RopeJointDef_set_maxLength_1,Ll=e._emscripten_bind_b2ChainShape_TestPoint_2=i._emscripten_bind_b2ChainShape_TestPoint_2,Ml=e._emscripten_bind_b2PrismaticJoint_GetReferenceAngle_0= i._emscripten_bind_b2PrismaticJoint_GetReferenceAngle_0,Nl=e._emscripten_bind_b2RayCastInput_get_p2_0=i._emscripten_bind_b2RayCastInput_get_p2_0,Ol=e._emscripten_bind_b2RevoluteJoint_EnableLimit_1=i._emscripten_bind_b2RevoluteJoint_EnableLimit_1,Pl=e._emscripten_bind_b2BodyDef_set_angle_1=i._emscripten_bind_b2BodyDef_set_angle_1,Ql=e._emscripten_bind_b2WeldJoint_GetUserData_0=i._emscripten_bind_b2WeldJoint_GetUserData_0,Rl=e._emscripten_bind_b2WheelJointDef_get_localAnchorA_0=i._emscripten_bind_b2WheelJointDef_get_localAnchorA_0, Sl=e._emscripten_bind_b2PulleyJointDef_set_type_1=i._emscripten_bind_b2PulleyJointDef_set_type_1,Tl=e._emscripten_bind_b2Body_IsBullet_0=i._emscripten_bind_b2Body_IsBullet_0,Ul=e._emscripten_bind_b2MotorJointDef_set_bodyA_1=i._emscripten_bind_b2MotorJointDef_set_bodyA_1,Vl=e._emscripten_bind_b2Mat33_GetSymInverse33_1=i._emscripten_bind_b2Mat33_GetSymInverse33_1,Wl=e._emscripten_bind_b2Body_ApplyLinearImpulse_3=i._emscripten_bind_b2Body_ApplyLinearImpulse_3,Xl=e._emscripten_bind_b2PolygonShape_ComputeMass_2= i._emscripten_bind_b2PolygonShape_ComputeMass_2,Yl=e._emscripten_bind_b2WeldJoint_GetLocalAnchorA_0=i._emscripten_bind_b2WeldJoint_GetLocalAnchorA_0,Zl=e._emscripten_bind_b2MouseJoint_SetFrequency_1=i._emscripten_bind_b2MouseJoint_SetFrequency_1,$l=e._emscripten_bind_b2EdgeShape_get_m_vertex1_0=i._emscripten_bind_b2EdgeShape_get_m_vertex1_0,am=e._emscripten_bind_b2BodyDef_set_awake_1=i._emscripten_bind_b2BodyDef_set_awake_1,bm=e._emscripten_bind_b2Vec2_get_y_0=i._emscripten_bind_b2Vec2_get_y_0,cm= e._emscripten_bind_b2Body_CreateFixture_1=i._emscripten_bind_b2Body_CreateFixture_1,dm=e._emscripten_bind_b2Body_CreateFixture_2=i._emscripten_bind_b2Body_CreateFixture_2,em=e._emscripten_bind_b2PulleyJoint_GetUserData_0=i._emscripten_bind_b2PulleyJoint_GetUserData_0,fm=e._emscripten_bind_b2Body_SetActive_1=i._emscripten_bind_b2Body_SetActive_1,gm=e._emscripten_bind_b2Fixture_GetUserData_0=i._emscripten_bind_b2Fixture_GetUserData_0,hm=e._emscripten_bind_b2PolygonShape_ComputeAABB_3=i._emscripten_bind_b2PolygonShape_ComputeAABB_3, im=e._emscripten_bind_b2ContactFeature_get_typeA_0=i._emscripten_bind_b2ContactFeature_get_typeA_0,jm=e._emscripten_bind_b2MouseJoint_GetReactionForce_1=i._emscripten_bind_b2MouseJoint_GetReactionForce_1,km=e._emscripten_bind_b2FrictionJoint_GetReactionTorque_1=i._emscripten_bind_b2FrictionJoint_GetReactionTorque_1,lm=e._emscripten_bind_b2EdgeShape_TestPoint_2=i._emscripten_bind_b2EdgeShape_TestPoint_2,mc=e._memcpy=i._memcpy,mm=e._emscripten_bind_b2PolygonShape_get_m_centroid_0=i._emscripten_bind_b2PolygonShape_get_m_centroid_0, nm=e._emscripten_bind_b2ChainShape___destroy___0=i._emscripten_bind_b2ChainShape___destroy___0,om=e._emscripten_bind_b2GearJoint_SetUserData_1=i._emscripten_bind_b2GearJoint_SetUserData_1,pm=e._emscripten_bind_b2Vec3_set_z_1=i._emscripten_bind_b2Vec3_set_z_1,qm=e._emscripten_bind_b2PrismaticJointDef_set_enableLimit_1=i._emscripten_bind_b2PrismaticJointDef_set_enableLimit_1,rm=e._emscripten_bind_b2DistanceJoint_GetFrequency_0=i._emscripten_bind_b2DistanceJoint_GetFrequency_0,sm=e._emscripten_bind_b2Body_SetGravityScale_1= i._emscripten_bind_b2Body_SetGravityScale_1,tm=e._emscripten_enum_b2ContactFeatureType_e_face=i._emscripten_enum_b2ContactFeatureType_e_face,um=e._emscripten_bind_b2AABB_GetPerimeter_0=i._emscripten_bind_b2AABB_GetPerimeter_0,vm=e._emscripten_bind_b2PulleyJointDef_get_lengthA_0=i._emscripten_bind_b2PulleyJointDef_get_lengthA_0,wm=e._emscripten_bind_b2Vec3_set_x_1=i._emscripten_bind_b2Vec3_set_x_1,xm=e._emscripten_bind_b2PulleyJointDef_get_type_0=i._emscripten_bind_b2PulleyJointDef_get_type_0,ym=e._emscripten_bind_JSDestructionListener_SayGoodbyeJoint_1= i._emscripten_bind_JSDestructionListener_SayGoodbyeJoint_1,zm=e._emscripten_bind_b2Shape___destroy___0=i._emscripten_bind_b2Shape___destroy___0,Yb=e._strlen=i._strlen,Am=e._emscripten_bind_b2Color_set_b_1=i._emscripten_bind_b2Color_set_b_1,Bm=e._emscripten_bind_b2Joint_GetReactionForce_1=i._emscripten_bind_b2Joint_GetReactionForce_1,Cm=e._emscripten_bind_b2FixtureDef_set_friction_1=i._emscripten_bind_b2FixtureDef_set_friction_1,Dm=e._emscripten_bind_b2ContactID___destroy___0=i._emscripten_bind_b2ContactID___destroy___0, Em=e._emscripten_bind_b2EdgeShape_get_m_hasVertex0_0=i._emscripten_bind_b2EdgeShape_get_m_hasVertex0_0,Fm=e._emscripten_bind_JSRayCastCallback_ReportFixture_4=i._emscripten_bind_JSRayCastCallback_ReportFixture_4,Gm=e._emscripten_bind_b2MotorJointDef_get_linearOffset_0=i._emscripten_bind_b2MotorJointDef_get_linearOffset_0,Hm=e._emscripten_bind_b2Profile_set_solveVelocity_1=i._emscripten_bind_b2Profile_set_solveVelocity_1,Im=e._emscripten_bind_b2PrismaticJoint_GetAnchorB_0=i._emscripten_bind_b2PrismaticJoint_GetAnchorB_0, Jm=e._emscripten_bind_b2WeldJointDef_b2WeldJointDef_0=i._emscripten_bind_b2WeldJointDef_b2WeldJointDef_0,Km=e._emscripten_enum_b2BodyType_b2_staticBody=i._emscripten_enum_b2BodyType_b2_staticBody,Lm=e._emscripten_bind_b2RevoluteJointDef_set_upperAngle_1=i._emscripten_bind_b2RevoluteJointDef_set_upperAngle_1,Mm=e._emscripten_bind_b2RevoluteJointDef_get_type_0=i._emscripten_bind_b2RevoluteJointDef_get_type_0,Nm=e._emscripten_bind_b2GearJointDef_get_type_0=i._emscripten_bind_b2GearJointDef_get_type_0, Om=e._emscripten_bind_b2ChainShape_GetType_0=i._emscripten_bind_b2ChainShape_GetType_0,Pm=e._emscripten_bind_b2RayCastInput_get_maxFraction_0=i._emscripten_bind_b2RayCastInput_get_maxFraction_0,Qm=e._emscripten_bind_b2GearJoint_GetBodyA_0=i._emscripten_bind_b2GearJoint_GetBodyA_0,Rm=e._emscripten_bind_b2Body_GetLocalVector_1=i._emscripten_bind_b2Body_GetLocalVector_1,Sm=e._emscripten_bind_b2PrismaticJoint_EnableLimit_1=i._emscripten_bind_b2PrismaticJoint_EnableLimit_1,Tm=e._emscripten_bind_b2FrictionJointDef_get_maxForce_0= i._emscripten_bind_b2FrictionJointDef_get_maxForce_0,Um=e._emscripten_bind_b2BodyDef_set_angularVelocity_1=i._emscripten_bind_b2BodyDef_set_angularVelocity_1,Vm=e._emscripten_bind_b2Body_SetLinearDamping_1=i._emscripten_bind_b2Body_SetLinearDamping_1,Wm=e._emscripten_bind_b2WheelJoint_GetBodyB_0=i._emscripten_bind_b2WheelJoint_GetBodyB_0,Xm=e._emscripten_bind_b2Color___destroy___0=i._emscripten_bind_b2Color___destroy___0,Ym=e._emscripten_bind_b2PrismaticJoint_IsActive_0=i._emscripten_bind_b2PrismaticJoint_IsActive_0, Zm=e._emscripten_bind_b2Filter_get_categoryBits_0=i._emscripten_bind_b2Filter_get_categoryBits_0,$m=e._emscripten_enum_b2JointType_e_weldJoint=i._emscripten_enum_b2JointType_e_weldJoint,an=e._emscripten_bind_b2World_SetContinuousPhysics_1=i._emscripten_bind_b2World_SetContinuousPhysics_1,bn=e._emscripten_bind_b2MouseJointDef_get_target_0=i._emscripten_bind_b2MouseJointDef_get_target_0,cn=e._emscripten_bind_b2Manifold_b2Manifold_0=i._emscripten_bind_b2Manifold_b2Manifold_0,dn=e._emscripten_bind_b2PulleyJointDef_set_userData_1= i._emscripten_bind_b2PulleyJointDef_set_userData_1,en=e._emscripten_bind_b2FrictionJointDef_set_maxForce_1=i._emscripten_bind_b2FrictionJointDef_set_maxForce_1,fn=e._emscripten_bind_b2DistanceJointDef_b2DistanceJointDef_0=i._emscripten_bind_b2DistanceJointDef_b2DistanceJointDef_0,gn=e._emscripten_bind_b2PolygonShape_set_m_centroid_1=i._emscripten_bind_b2PolygonShape_set_m_centroid_1,hn=e._emscripten_bind_b2Mat33_GetInverse22_1=i._emscripten_bind_b2Mat33_GetInverse22_1,jn=e._emscripten_bind_b2PolygonShape_SetAsBox_4= i._emscripten_bind_b2PolygonShape_SetAsBox_4,kn=e._emscripten_bind_b2EdgeShape_get_m_vertex2_0=i._emscripten_bind_b2EdgeShape_get_m_vertex2_0,ln=e._emscripten_bind_b2WheelJoint_GetReactionTorque_1=i._emscripten_bind_b2WheelJoint_GetReactionTorque_1,mn=e._emscripten_bind_b2RevoluteJointDef_b2RevoluteJointDef_0=i._emscripten_bind_b2RevoluteJointDef_b2RevoluteJointDef_0,nn=e._emscripten_bind_b2ContactFeature_set_typeA_1=i._emscripten_bind_b2ContactFeature_set_typeA_1,on=e._emscripten_bind_b2Fixture_Dump_1= i._emscripten_bind_b2Fixture_Dump_1,pn=e._emscripten_bind_b2World_GetJointList_0=i._emscripten_bind_b2World_GetJointList_0,qn=e._emscripten_bind_b2Manifold_set_localPoint_1=i._emscripten_bind_b2Manifold_set_localPoint_1,rn=e._emscripten_bind_b2DistanceJoint_SetUserData_1=i._emscripten_bind_b2DistanceJoint_SetUserData_1,sn=e._emscripten_bind_b2BodyDef_set_bullet_1=i._emscripten_bind_b2BodyDef_set_bullet_1,tn=e._emscripten_bind_b2RayCastOutput___destroy___0=i._emscripten_bind_b2RayCastOutput___destroy___0; e.___cxa_can_catch=i.___cxa_can_catch; var un=e._emscripten_bind_b2WheelJoint_GetNext_0=i._emscripten_bind_b2WheelJoint_GetNext_0,vn=e._emscripten_bind_b2AABB_GetCenter_0=i._emscripten_bind_b2AABB_GetCenter_0,wn=e._emscripten_bind_b2Filter_set_groupIndex_1=i._emscripten_bind_b2Filter_set_groupIndex_1,xn=e._emscripten_bind_b2JointDef_b2JointDef_0=i._emscripten_bind_b2JointDef_b2JointDef_0,yn=e._emscripten_bind_b2CircleShape_b2CircleShape_0=i._emscripten_bind_b2CircleShape_b2CircleShape_0,zn=e._emscripten_bind_b2GearJointDef_b2GearJointDef_0=i._emscripten_bind_b2GearJointDef_b2GearJointDef_0, An=e._emscripten_bind_b2JointDef_get_bodyB_0=i._emscripten_bind_b2JointDef_get_bodyB_0,Bn=e._emscripten_bind_b2DistanceJoint_GetReactionForce_1=i._emscripten_bind_b2DistanceJoint_GetReactionForce_1,Cn=e._emscripten_bind_b2PrismaticJoint_GetJointSpeed_0=i._emscripten_bind_b2PrismaticJoint_GetJointSpeed_0,Dn=e._emscripten_bind_b2PulleyJointDef_get_groundAnchorB_0=i._emscripten_bind_b2PulleyJointDef_get_groundAnchorB_0,En=e._emscripten_bind_b2Joint_GetAnchorA_0=i._emscripten_bind_b2Joint_GetAnchorA_0, Fn=e._emscripten_bind_b2Contact_GetRestitution_0=i._emscripten_bind_b2Contact_GetRestitution_0,Gn=e._emscripten_bind_b2ContactEdge_get_contact_0=i._emscripten_bind_b2ContactEdge_get_contact_0,Hn=e._emscripten_bind_b2RevoluteJointDef_get_userData_0=i._emscripten_bind_b2RevoluteJointDef_get_userData_0,In=e._emscripten_bind_b2Body_ApplyTorque_2=i._emscripten_bind_b2Body_ApplyTorque_2,Jn=e._emscripten_bind_b2Fixture_GetAABB_1=i._emscripten_bind_b2Fixture_GetAABB_1,Kn=e._emscripten_bind_b2DistanceJointDef_Initialize_4= i._emscripten_bind_b2DistanceJointDef_Initialize_4,Ln=e._emscripten_bind_b2PrismaticJointDef_set_collideConnected_1=i._emscripten_bind_b2PrismaticJointDef_set_collideConnected_1,Mn=e._emscripten_bind_b2PrismaticJointDef_set_localAxisA_1=i._emscripten_bind_b2PrismaticJointDef_set_localAxisA_1,Nn=e._emscripten_bind_b2Contact_GetTangentSpeed_0=i._emscripten_bind_b2Contact_GetTangentSpeed_0,On=e._emscripten_enum_b2LimitState_e_atLowerLimit=i._emscripten_enum_b2LimitState_e_atLowerLimit,Pn=e._emscripten_bind_b2ManifoldPoint_set_id_1= i._emscripten_bind_b2ManifoldPoint_set_id_1,Qn=e._emscripten_bind_b2WheelJointDef_get_bodyB_0=i._emscripten_bind_b2WheelJointDef_get_bodyB_0,Rn=e._emscripten_bind_b2WeldJoint_GetLocalAnchorB_0=i._emscripten_bind_b2WeldJoint_GetLocalAnchorB_0,Sn=e._emscripten_bind_b2RevoluteJointDef_set_localAnchorB_1=i._emscripten_bind_b2RevoluteJointDef_set_localAnchorB_1,Tn=e._emscripten_bind_b2RevoluteJoint_GetType_0=i._emscripten_bind_b2RevoluteJoint_GetType_0,Un=e._emscripten_bind_b2Body_DestroyFixture_1=i._emscripten_bind_b2Body_DestroyFixture_1, Vn=e._emscripten_bind_b2Profile_set_broadphase_1=i._emscripten_bind_b2Profile_set_broadphase_1,Wn=e._emscripten_bind_b2WheelJointDef_get_localAnchorB_0=i._emscripten_bind_b2WheelJointDef_get_localAnchorB_0,Xn=e._emscripten_bind_b2ContactImpulse_get_count_0=i._emscripten_bind_b2ContactImpulse_get_count_0,Yn=e._emscripten_bind_b2World_GetJointCount_0=i._emscripten_bind_b2World_GetJointCount_0,Zn=e._emscripten_bind_b2WheelJoint_GetMotorSpeed_0=i._emscripten_bind_b2WheelJoint_GetMotorSpeed_0,$n=e._emscripten_bind_b2Body_GetAngularDamping_0= i._emscripten_bind_b2Body_GetAngularDamping_0,ao=e._emscripten_bind_b2WheelJointDef_get_dampingRatio_0=i._emscripten_bind_b2WheelJointDef_get_dampingRatio_0,bo=e._emscripten_bind_b2RayCastOutput_get_fraction_0=i._emscripten_bind_b2RayCastOutput_get_fraction_0,co=e._emscripten_enum_b2ManifoldType_e_circles=i._emscripten_enum_b2ManifoldType_e_circles,eo=e._emscripten_bind_b2GearJoint_SetRatio_1=i._emscripten_bind_b2GearJoint_SetRatio_1,fo=e._emscripten_bind_JSDraw_DrawPolygon_3=i._emscripten_bind_JSDraw_DrawPolygon_3, go=e._emscripten_bind_b2Filter___destroy___0=i._emscripten_bind_b2Filter___destroy___0,ho=e._emscripten_bind_b2JointEdge_set_next_1=i._emscripten_bind_b2JointEdge_set_next_1;e.___cxa_is_pointer_type=i.___cxa_is_pointer_type; var io=e._emscripten_bind_b2BodyDef_get_fixedRotation_0=i._emscripten_bind_b2BodyDef_get_fixedRotation_0,jo=e._emscripten_bind_b2PrismaticJointDef_set_motorSpeed_1=i._emscripten_bind_b2PrismaticJointDef_set_motorSpeed_1,ko=e._emscripten_bind_b2ChainShape_SetPrevVertex_1=i._emscripten_bind_b2ChainShape_SetPrevVertex_1,lo=e._emscripten_bind_b2MotorJoint_IsActive_0=i._emscripten_bind_b2MotorJoint_IsActive_0,mo=e._emscripten_bind_b2MouseJoint_GetReactionTorque_1=i._emscripten_bind_b2MouseJoint_GetReactionTorque_1, no=e._emscripten_bind_b2MouseJoint_GetUserData_0=i._emscripten_bind_b2MouseJoint_GetUserData_0,oo=e._emscripten_bind_b2WheelJoint_GetUserData_0=i._emscripten_bind_b2WheelJoint_GetUserData_0,po=e._emscripten_bind_b2Vec3_op_sub_1=i._emscripten_bind_b2Vec3_op_sub_1,qo=e._emscripten_bind_b2BodyDef_get_gravityScale_0=i._emscripten_bind_b2BodyDef_get_gravityScale_0,ro=e._emscripten_bind_b2Shape_GetType_0=i._emscripten_bind_b2Shape_GetType_0,so=e._emscripten_bind_b2AABB_IsValid_0=i._emscripten_bind_b2AABB_IsValid_0, to=e._emscripten_bind_b2WheelJoint_GetBodyA_0=i._emscripten_bind_b2WheelJoint_GetBodyA_0,uo=e._emscripten_bind_JSDraw_DrawTransform_1=i._emscripten_bind_JSDraw_DrawTransform_1,vo=e._emscripten_bind_b2PulleyJoint_GetLengthA_0=i._emscripten_bind_b2PulleyJoint_GetLengthA_0,wo=e._emscripten_bind_b2DistanceJointDef_get_frequencyHz_0=i._emscripten_bind_b2DistanceJointDef_get_frequencyHz_0,xo=e._emscripten_bind_b2RevoluteJoint_SetMotorSpeed_1=i._emscripten_bind_b2RevoluteJoint_SetMotorSpeed_1,yo=e._emscripten_bind_b2World___destroy___0= i._emscripten_bind_b2World___destroy___0,zo=e._emscripten_bind_b2ChainShape_get_m_hasNextVertex_0=i._emscripten_bind_b2ChainShape_get_m_hasNextVertex_0,Ao=e._emscripten_bind_b2ChainShape_SetNextVertex_1=i._emscripten_bind_b2ChainShape_SetNextVertex_1,Bo=e._emscripten_bind_b2Body_SetType_1=i._emscripten_bind_b2Body_SetType_1,Co=e._emscripten_bind_b2Body_GetMass_0=i._emscripten_bind_b2Body_GetMass_0,Do=e._emscripten_bind_b2Rot_b2Rot_0=i._emscripten_bind_b2Rot_b2Rot_0,Eo=e._emscripten_bind_b2Rot_b2Rot_1= i._emscripten_bind_b2Rot_b2Rot_1,Fo=e._emscripten_enum_b2JointType_e_distanceJoint=i._emscripten_enum_b2JointType_e_distanceJoint,Go=e._emscripten_bind_b2PulleyJoint___destroy___0=i._emscripten_bind_b2PulleyJoint___destroy___0,Ho=e._emscripten_bind_b2PrismaticJoint_GetLocalAnchorB_0=i._emscripten_bind_b2PrismaticJoint_GetLocalAnchorB_0,Io=e._emscripten_bind_b2MouseJoint_GetType_0=i._emscripten_bind_b2MouseJoint_GetType_0,Jo=e._emscripten_bind_JSQueryCallback___destroy___0=i._emscripten_bind_JSQueryCallback___destroy___0, Ko=e._emscripten_bind_b2RevoluteJointDef_set_lowerAngle_1=i._emscripten_bind_b2RevoluteJointDef_set_lowerAngle_1,Lo=e._emscripten_bind_b2JointEdge___destroy___0=i._emscripten_bind_b2JointEdge___destroy___0,Mo=e._emscripten_bind_b2PulleyJoint_GetRatio_0=i._emscripten_bind_b2PulleyJoint_GetRatio_0,No=e._emscripten_bind_JSContactListener_BeginContact_1=i._emscripten_bind_JSContactListener_BeginContact_1,Oo=e._emscripten_bind_b2MotorJointDef_set_linearOffset_1=i._emscripten_bind_b2MotorJointDef_set_linearOffset_1, Po=e._emscripten_enum_b2JointType_e_motorJoint=i._emscripten_enum_b2JointType_e_motorJoint,Qo=e._emscripten_bind_b2JointEdge_get_next_0=i._emscripten_bind_b2JointEdge_get_next_0,Ro=e._emscripten_bind_b2RayCastInput_set_maxFraction_1=i._emscripten_bind_b2RayCastInput_set_maxFraction_1,So=e._emscripten_bind_b2MouseJoint_GetBodyA_0=i._emscripten_bind_b2MouseJoint_GetBodyA_0,To=e._emscripten_bind_b2Profile_set_collide_1=i._emscripten_bind_b2Profile_set_collide_1,Uo=e._emscripten_bind_b2AABB_b2AABB_0= i._emscripten_bind_b2AABB_b2AABB_0,Vo=e._emscripten_bind_b2Fixture_Refilter_0=i._emscripten_bind_b2Fixture_Refilter_0,Wo=e._emscripten_bind_b2World_CreateBody_1=i._emscripten_bind_b2World_CreateBody_1,Xo=e._emscripten_bind_b2RopeJointDef_set_userData_1=i._emscripten_bind_b2RopeJointDef_set_userData_1,Yo=e._emscripten_bind_b2Fixture_IsSensor_0=i._emscripten_bind_b2Fixture_IsSensor_0,Zo=e._emscripten_bind_b2WeldJoint_GetType_0=i._emscripten_bind_b2WeldJoint_GetType_0,$o=e._emscripten_bind_b2PrismaticJointDef_get_motorSpeed_0= i._emscripten_bind_b2PrismaticJointDef_get_motorSpeed_0,ap=e._emscripten_bind_b2Rot___destroy___0=i._emscripten_bind_b2Rot___destroy___0,bp=e._emscripten_bind_b2Filter_get_maskBits_0=i._emscripten_bind_b2Filter_get_maskBits_0,cp=e._emscripten_bind_b2Mat22_get_ex_0=i._emscripten_bind_b2Mat22_get_ex_0,dp=e._emscripten_bind_b2Body_GetFixtureList_0=i._emscripten_bind_b2Body_GetFixtureList_0,ep=e._emscripten_bind_b2RevoluteJointDef_get_enableMotor_0=i._emscripten_bind_b2RevoluteJointDef_get_enableMotor_0, fp=e._emscripten_bind_b2MouseJointDef_set_dampingRatio_1=i._emscripten_bind_b2MouseJointDef_set_dampingRatio_1,gp=e._emscripten_bind_JSRayCastCallback___destroy___0=i._emscripten_bind_JSRayCastCallback___destroy___0,hp=e._emscripten_bind_b2ContactListener___destroy___0=i._emscripten_bind_b2ContactListener___destroy___0,ip=e._emscripten_bind_b2PrismaticJointDef_set_localAnchorB_1=i._emscripten_bind_b2PrismaticJointDef_set_localAnchorB_1,jp=e._emscripten_enum_b2DrawFlag_e_pairBit=i._emscripten_enum_b2DrawFlag_e_pairBit, kp=e._emscripten_bind_b2FrictionJoint___destroy___0=i._emscripten_bind_b2FrictionJoint___destroy___0,lp=e._emscripten_bind_b2WeldJoint_Dump_0=i._emscripten_bind_b2WeldJoint_Dump_0,mp=e._emscripten_bind_b2MotorJoint_SetMaxForce_1=i._emscripten_bind_b2MotorJoint_SetMaxForce_1,np=e._emscripten_bind_b2FrictionJointDef_get_maxTorque_0=i._emscripten_bind_b2FrictionJointDef_get_maxTorque_0,op=e._emscripten_bind_b2FrictionJoint_GetLocalAnchorA_0=i._emscripten_bind_b2FrictionJoint_GetLocalAnchorA_0,pp=e._emscripten_bind_b2WeldJointDef_get_localAnchorB_0= i._emscripten_bind_b2WeldJointDef_get_localAnchorB_0,qp=e._emscripten_bind_b2PrismaticJointDef_get_bodyA_0=i._emscripten_bind_b2PrismaticJointDef_get_bodyA_0,rp=e._emscripten_bind_b2Vec2_IsValid_0=i._emscripten_bind_b2Vec2_IsValid_0,sp=e._emscripten_bind_b2PrismaticJointDef_set_bodyA_1=i._emscripten_bind_b2PrismaticJointDef_set_bodyA_1,tp=e._emscripten_bind_b2World_GetWarmStarting_0=i._emscripten_bind_b2World_GetWarmStarting_0,up=e._emscripten_bind_b2RevoluteJointDef_set_enableLimit_1=i._emscripten_bind_b2RevoluteJointDef_set_enableLimit_1, vp=e._emscripten_bind_b2WeldJointDef___destroy___0=i._emscripten_bind_b2WeldJointDef___destroy___0,wp=e._emscripten_bind_b2Mat22_Solve_1=i._emscripten_bind_b2Mat22_Solve_1,xp=e._emscripten_bind_b2Color_get_g_0=i._emscripten_bind_b2Color_get_g_0,yp=e._emscripten_bind_VoidPtr___destroy___0=i._emscripten_bind_VoidPtr___destroy___0,zp=e._emscripten_bind_b2RopeJoint_GetNext_0=i._emscripten_bind_b2RopeJoint_GetNext_0,Ap=e._emscripten_bind_b2Filter_b2Filter_0=i._emscripten_bind_b2Filter_b2Filter_0,Bp=e._emscripten_bind_b2PolygonShape_GetChildCount_0= i._emscripten_bind_b2PolygonShape_GetChildCount_0,Cp=e._emscripten_bind_b2GearJointDef_get_ratio_0=i._emscripten_bind_b2GearJointDef_get_ratio_0,Dp=e._emscripten_bind_b2Mat33_Solve33_1=i._emscripten_bind_b2Mat33_Solve33_1,Ep=e._emscripten_bind_b2PulleyJoint_GetReactionForce_1=i._emscripten_bind_b2PulleyJoint_GetReactionForce_1,Fp=e._emscripten_bind_b2WheelJoint_GetCollideConnected_0=i._emscripten_bind_b2WheelJoint_GetCollideConnected_0,Gp=e._emscripten_bind_b2WheelJoint_SetSpringDampingRatio_1=i._emscripten_bind_b2WheelJoint_SetSpringDampingRatio_1, Hp=e._emscripten_bind_b2RevoluteJointDef___destroy___0=i._emscripten_bind_b2RevoluteJointDef___destroy___0,Ip=e._emscripten_bind_b2MouseJointDef_get_maxForce_0=i._emscripten_bind_b2MouseJointDef_get_maxForce_0,Jp=e._emscripten_bind_b2RevoluteJoint_EnableMotor_1=i._emscripten_bind_b2RevoluteJoint_EnableMotor_1,Kp=e._emscripten_bind_b2ContactFeature_get_typeB_0=i._emscripten_bind_b2ContactFeature_get_typeB_0,Lp=e._emscripten_bind_b2MotorJoint_SetLinearOffset_1=i._emscripten_bind_b2MotorJoint_SetLinearOffset_1, Mp=e._emscripten_bind_b2MotorJoint_GetReactionForce_1=i._emscripten_bind_b2MotorJoint_GetReactionForce_1,Np=e._emscripten_bind_b2Rot_GetAngle_0=i._emscripten_bind_b2Rot_GetAngle_0,Op=e._emscripten_bind_b2World_SetAllowSleeping_1=i._emscripten_bind_b2World_SetAllowSleeping_1,Pp=e._emscripten_bind_b2MotorJoint_SetAngularOffset_1=i._emscripten_bind_b2MotorJoint_SetAngularOffset_1,Qp=e._emscripten_bind_b2MotorJoint_GetLinearOffset_0=i._emscripten_bind_b2MotorJoint_GetLinearOffset_0,Rp=e._emscripten_bind_b2FrictionJoint_GetCollideConnected_0= i._emscripten_bind_b2FrictionJoint_GetCollideConnected_0,Sp=e._emscripten_bind_b2WheelJointDef_set_motorSpeed_1=i._emscripten_bind_b2WheelJointDef_set_motorSpeed_1,Tp=e._emscripten_bind_b2MotorJoint_GetAnchorA_0=i._emscripten_bind_b2MotorJoint_GetAnchorA_0,Up=e._emscripten_bind_b2Fixture_GetDensity_0=i._emscripten_bind_b2Fixture_GetDensity_0,Vp=e._emscripten_bind_b2PolygonShape_get_m_type_0=i._emscripten_bind_b2PolygonShape_get_m_type_0,Wp=e._emscripten_bind_b2Vec2_Set_2=i._emscripten_bind_b2Vec2_Set_2, Xp=e._emscripten_bind_b2WeldJointDef_get_type_0=i._emscripten_bind_b2WeldJointDef_get_type_0,Yp=e._emscripten_bind_b2MouseJointDef_b2MouseJointDef_0=i._emscripten_bind_b2MouseJointDef_b2MouseJointDef_0,Zp=e._emscripten_bind_b2Rot_get_s_0=i._emscripten_bind_b2Rot_get_s_0,$p=e._emscripten_bind_b2FrictionJoint_SetMaxTorque_1=i._emscripten_bind_b2FrictionJoint_SetMaxTorque_1,aq=e._emscripten_bind_b2MouseJointDef_get_frequencyHz_0=i._emscripten_bind_b2MouseJointDef_get_frequencyHz_0,bq=e._emscripten_bind_b2FrictionJoint_SetUserData_1= i._emscripten_bind_b2FrictionJoint_SetUserData_1,cq=e._emscripten_bind_b2FixtureDef_set_userData_1=i._emscripten_bind_b2FixtureDef_set_userData_1,dq=e._emscripten_bind_b2JointDef_get_userData_0=i._emscripten_bind_b2JointDef_get_userData_0,eq=e._emscripten_bind_b2DistanceJointDef_get_collideConnected_0=i._emscripten_bind_b2DistanceJointDef_get_collideConnected_0,fq=e._emscripten_bind_b2RevoluteJointDef_set_referenceAngle_1=i._emscripten_bind_b2RevoluteJointDef_set_referenceAngle_1,gq=e._emscripten_bind_b2ContactFeature___destroy___0= i._emscripten_bind_b2ContactFeature___destroy___0,hq=e._emscripten_bind_b2DistanceJointDef_set_bodyB_1=i._emscripten_bind_b2DistanceJointDef_set_bodyB_1,iq=e._emscripten_bind_JSQueryCallback_JSQueryCallback_0=i._emscripten_bind_JSQueryCallback_JSQueryCallback_0,jq=e._emscripten_bind_b2ChainShape_GetChildCount_0=i._emscripten_bind_b2ChainShape_GetChildCount_0,kq=e._emscripten_bind_b2MassData_b2MassData_0=i._emscripten_bind_b2MassData_b2MassData_0,lq=e._emscripten_bind_b2Vec3_set_y_1=i._emscripten_bind_b2Vec3_set_y_1, mq=e._emscripten_bind_b2AABB_Combine_1=i._emscripten_bind_b2AABB_Combine_1,nq=e._emscripten_bind_b2AABB_Combine_2=i._emscripten_bind_b2AABB_Combine_2,oq=e._emscripten_bind_b2PrismaticJoint_GetBodyA_0=i._emscripten_bind_b2PrismaticJoint_GetBodyA_0,pq=e._emscripten_bind_b2PrismaticJoint_GetMaxMotorForce_0=i._emscripten_bind_b2PrismaticJoint_GetMaxMotorForce_0,qq=e._emscripten_bind_b2AABB___destroy___0=i._emscripten_bind_b2AABB___destroy___0,rq=e._emscripten_bind_b2Body_IsSleepingAllowed_0=i._emscripten_bind_b2Body_IsSleepingAllowed_0, sq=e._emscripten_bind_b2MouseJointDef_set_maxForce_1=i._emscripten_bind_b2MouseJointDef_set_maxForce_1,tq=e._emscripten_bind_b2MotorJoint_GetCorrectionFactor_0=i._emscripten_bind_b2MotorJoint_GetCorrectionFactor_0,uq=e._emscripten_bind_b2Profile_get_solve_0=i._emscripten_bind_b2Profile_get_solve_0,vq=e._emscripten_bind_JSDestructionListener_SayGoodbyeFixture_1=i._emscripten_bind_JSDestructionListener_SayGoodbyeFixture_1,wq=e._emscripten_bind_b2PolygonShape_GetVertexCount_0=i._emscripten_bind_b2PolygonShape_GetVertexCount_0, xq=e._emscripten_bind_b2Rot_get_c_0=i._emscripten_bind_b2Rot_get_c_0,yq=e._emscripten_bind_b2AABB_set_lowerBound_1=i._emscripten_bind_b2AABB_set_lowerBound_1,zq=e._emscripten_bind_b2ChainShape_get_m_hasPrevVertex_0=i._emscripten_bind_b2ChainShape_get_m_hasPrevVertex_0,Aq=e._emscripten_bind_b2MouseJoint_SetMaxForce_1=i._emscripten_bind_b2MouseJoint_SetMaxForce_1,Bq=e._emscripten_bind_b2FrictionJointDef_get_bodyB_0=i._emscripten_bind_b2FrictionJointDef_get_bodyB_0,Cq=e._emscripten_bind_b2JointDef_set_userData_1= i._emscripten_bind_b2JointDef_set_userData_1,Dq=e._emscripten_bind_b2ManifoldPoint_get_tangentImpulse_0=i._emscripten_bind_b2ManifoldPoint_get_tangentImpulse_0,Eq=e._emscripten_bind_b2RevoluteJointDef_get_maxMotorTorque_0=i._emscripten_bind_b2RevoluteJointDef_get_maxMotorTorque_0,Fq=e._emscripten_bind_b2WeldJointDef_get_dampingRatio_0=i._emscripten_bind_b2WeldJointDef_get_dampingRatio_0,Gq=e._emscripten_bind_b2MouseJoint___destroy___0=i._emscripten_bind_b2MouseJoint___destroy___0,Hq=e._emscripten_bind_b2EdgeShape_b2EdgeShape_0= i._emscripten_bind_b2EdgeShape_b2EdgeShape_0,Iq=e._emscripten_bind_b2FrictionJoint_GetReactionForce_1=i._emscripten_bind_b2FrictionJoint_GetReactionForce_1,Jq=e._emscripten_bind_b2DistanceJointDef_set_type_1=i._emscripten_bind_b2DistanceJointDef_set_type_1,Kq=e._emscripten_bind_b2WeldJoint___destroy___0=i._emscripten_bind_b2WeldJoint___destroy___0,Lq=e._emscripten_bind_b2PulleyJoint_GetBodyA_0=i._emscripten_bind_b2PulleyJoint_GetBodyA_0,Mq=e._emscripten_bind_b2RopeJointDef_get_type_0=i._emscripten_bind_b2RopeJointDef_get_type_0, Nq=e._emscripten_bind_b2CircleShape_ComputeMass_2=i._emscripten_bind_b2CircleShape_ComputeMass_2,Oq=e._emscripten_bind_b2DistanceJointDef_get_localAnchorB_0=i._emscripten_bind_b2DistanceJointDef_get_localAnchorB_0,Pq=e._emscripten_bind_b2GearJointDef___destroy___0=i._emscripten_bind_b2GearJointDef___destroy___0,Qq=e._emscripten_bind_b2RevoluteJointDef_set_bodyA_1=i._emscripten_bind_b2RevoluteJointDef_set_bodyA_1,Rq=e._emscripten_enum_b2BodyType_b2_dynamicBody=i._emscripten_enum_b2BodyType_b2_dynamicBody, Sq=e._emscripten_bind_b2CircleShape_TestPoint_2=i._emscripten_bind_b2CircleShape_TestPoint_2,Tq=e._emscripten_bind_b2MotorJointDef_get_maxTorque_0=i._emscripten_bind_b2MotorJointDef_get_maxTorque_0,Uq=e._emscripten_bind_b2Body_GetLinearVelocityFromLocalPoint_1=i._emscripten_bind_b2Body_GetLinearVelocityFromLocalPoint_1,Vq=e._emscripten_bind_b2Mat22_b2Mat22_0=i._emscripten_bind_b2Mat22_b2Mat22_0,Wq=e._emscripten_bind_b2MouseJoint_GetAnchorB_0=i._emscripten_bind_b2MouseJoint_GetAnchorB_0,Xq=e._emscripten_enum_b2BodyType_b2_kinematicBody= i._emscripten_enum_b2BodyType_b2_kinematicBody,Yq=e._emscripten_bind_b2Manifold_get_localPoint_0=i._emscripten_bind_b2Manifold_get_localPoint_0,Zq=e._emscripten_bind_b2GearJoint_GetBodyB_0=i._emscripten_bind_b2GearJoint_GetBodyB_0,$q=e._emscripten_bind_b2ChainShape_Clear_0=i._emscripten_bind_b2ChainShape_Clear_0,ar=e._emscripten_bind_b2CircleShape___destroy___0=i._emscripten_bind_b2CircleShape___destroy___0,br=e._emscripten_bind_b2MotorJoint_GetType_0=i._emscripten_bind_b2MotorJoint_GetType_0,cr= e._emscripten_bind_b2BodyDef_get_awake_0=i._emscripten_bind_b2BodyDef_get_awake_0,dr=e._emscripten_bind_b2Contact_SetRestitution_1=i._emscripten_bind_b2Contact_SetRestitution_1,er=e._emscripten_bind_b2BodyDef_get_angularDamping_0=i._emscripten_bind_b2BodyDef_get_angularDamping_0,fr=e._emscripten_bind_b2EdgeShape_get_m_vertex3_0=i._emscripten_bind_b2EdgeShape_get_m_vertex3_0,gr=e._emscripten_bind_b2Fixture_SetUserData_1=i._emscripten_bind_b2Fixture_SetUserData_1,hr=e._emscripten_bind_b2Transform_SetIdentity_0= i._emscripten_bind_b2Transform_SetIdentity_0,ir=e._emscripten_bind_b2GearJointDef_set_joint1_1=i._emscripten_bind_b2GearJointDef_set_joint1_1,jr=e._emscripten_bind_b2EdgeShape_set_m_vertex2_1=i._emscripten_bind_b2EdgeShape_set_m_vertex2_1,kr=e._emscripten_bind_b2ContactEdge_get_next_0=i._emscripten_bind_b2ContactEdge_get_next_0,lr=e._emscripten_bind_b2ContactFeature_set_indexB_1=i._emscripten_bind_b2ContactFeature_set_indexB_1,mr=e._emscripten_bind_b2Body_GetLinearVelocityFromWorldPoint_1=i._emscripten_bind_b2Body_GetLinearVelocityFromWorldPoint_1, nr=e._emscripten_bind_b2WeldJoint_GetCollideConnected_0=i._emscripten_bind_b2WeldJoint_GetCollideConnected_0,or=e._emscripten_bind_b2Mat22_set_ey_1=i._emscripten_bind_b2Mat22_set_ey_1,pr=e._emscripten_bind_b2WheelJointDef_set_frequencyHz_1=i._emscripten_bind_b2WheelJointDef_set_frequencyHz_1,qr=e._emscripten_bind_b2World_GetSubStepping_0=i._emscripten_bind_b2World_GetSubStepping_0,rr=e._emscripten_bind_b2Rot_GetYAxis_0=i._emscripten_bind_b2Rot_GetYAxis_0,sr=e._emscripten_bind_b2Contact_GetChildIndexB_0= i._emscripten_bind_b2Contact_GetChildIndexB_0,tr=e._emscripten_bind_b2DistanceJoint___destroy___0=i._emscripten_bind_b2DistanceJoint___destroy___0,ur=e._emscripten_bind_b2EdgeShape_GetType_0=i._emscripten_bind_b2EdgeShape_GetType_0,vr=e._emscripten_bind_b2WheelJointDef_set_dampingRatio_1=i._emscripten_bind_b2WheelJointDef_set_dampingRatio_1,wr=e._emscripten_bind_b2ManifoldPoint___destroy___0=i._emscripten_bind_b2ManifoldPoint___destroy___0,xr=e._emscripten_enum_b2JointType_e_prismaticJoint=i._emscripten_enum_b2JointType_e_prismaticJoint, yr=e._emscripten_bind_b2MotorJoint_GetNext_0=i._emscripten_bind_b2MotorJoint_GetNext_0,zr=e._emscripten_bind_b2Vec2_Length_0=i._emscripten_bind_b2Vec2_Length_0,Ar=e._emscripten_bind_b2Vec2_SetZero_0=i._emscripten_bind_b2Vec2_SetZero_0,Br=e._emscripten_bind_b2RopeJoint___destroy___0=i._emscripten_bind_b2RopeJoint___destroy___0,Cr=e._emscripten_bind_b2World_DestroyJoint_1=i._emscripten_bind_b2World_DestroyJoint_1,Dr=e._emscripten_bind_b2JointDef_set_bodyB_1=i._emscripten_bind_b2JointDef_set_bodyB_1, Er=e._emscripten_bind_b2Mat22_Set_2=i._emscripten_bind_b2Mat22_Set_2,Fr=e._emscripten_bind_b2Body_GetType_0=i._emscripten_bind_b2Body_GetType_0,Gr=e._emscripten_bind_b2WeldJoint_GetAnchorB_0=i._emscripten_bind_b2WeldJoint_GetAnchorB_0,Hr=e._emscripten_bind_b2WeldJoint_GetNext_0=i._emscripten_bind_b2WeldJoint_GetNext_0,Ir=e._emscripten_bind_b2Shape_get_m_radius_0=i._emscripten_bind_b2Shape_get_m_radius_0,Jr=e._emscripten_bind_b2EdgeShape_ComputeAABB_3=i._emscripten_bind_b2EdgeShape_ComputeAABB_3,Kr= e._emscripten_bind_b2BodyDef_get_type_0=i._emscripten_bind_b2BodyDef_get_type_0,Lr=e._emscripten_bind_b2WheelJointDef_set_collideConnected_1=i._emscripten_bind_b2WheelJointDef_set_collideConnected_1,Mr=e._emscripten_bind_JSDestructionListener___destroy___0=i._emscripten_bind_JSDestructionListener___destroy___0,Nr=e._emscripten_bind_b2MotorJointDef_get_type_0=i._emscripten_bind_b2MotorJointDef_get_type_0,Or=e._emscripten_bind_b2RopeJoint_GetLocalAnchorA_0=i._emscripten_bind_b2RopeJoint_GetLocalAnchorA_0, Pr=e._emscripten_bind_b2BodyDef_set_linearDamping_1=i._emscripten_bind_b2BodyDef_set_linearDamping_1,Qr=e._emscripten_bind_b2FrictionJoint_GetUserData_0=i._emscripten_bind_b2FrictionJoint_GetUserData_0,Rr=e._emscripten_bind_b2Contact_SetFriction_1=i._emscripten_bind_b2Contact_SetFriction_1,Sr=e._emscripten_bind_b2Manifold_set_localNormal_1=i._emscripten_bind_b2Manifold_set_localNormal_1,Tr=e._emscripten_bind_b2JointDef_get_bodyA_0=i._emscripten_bind_b2JointDef_get_bodyA_0,Ur=e._emscripten_bind_b2Body_GetLinearDamping_0= i._emscripten_bind_b2Body_GetLinearDamping_0,Vr=e._emscripten_bind_b2WeldJointDef_set_frequencyHz_1=i._emscripten_bind_b2WeldJointDef_set_frequencyHz_1,Wr=e._emscripten_bind_b2Body_ResetMassData_0=i._emscripten_bind_b2Body_ResetMassData_0,Xr=e._emscripten_bind_b2PrismaticJointDef_set_enableMotor_1=i._emscripten_bind_b2PrismaticJointDef_set_enableMotor_1,Yr=e._emscripten_enum_b2JointType_e_wheelJoint=i._emscripten_enum_b2JointType_e_wheelJoint,Zr=e._emscripten_bind_b2Vec2_Skew_0=i._emscripten_bind_b2Vec2_Skew_0, $r=e._emscripten_bind_b2MouseJoint_GetDampingRatio_0=i._emscripten_bind_b2MouseJoint_GetDampingRatio_0,as=e._emscripten_bind_b2RevoluteJoint_GetAnchorA_0=i._emscripten_bind_b2RevoluteJoint_GetAnchorA_0,bs=e._emscripten_bind_b2ChainShape_set_m_prevVertex_1=i._emscripten_bind_b2ChainShape_set_m_prevVertex_1,cs=e._emscripten_bind_b2WheelJoint_GetAnchorA_0=i._emscripten_bind_b2WheelJoint_GetAnchorA_0,ds=e._emscripten_bind_b2MotorJoint_GetMaxTorque_0=i._emscripten_bind_b2MotorJoint_GetMaxTorque_0,es=e._emscripten_bind_b2FrictionJoint_GetNext_0= i._emscripten_bind_b2FrictionJoint_GetNext_0,fs=e._emscripten_bind_b2PrismaticJointDef_set_userData_1=i._emscripten_bind_b2PrismaticJointDef_set_userData_1,gs=e._emscripten_bind_b2FrictionJointDef_set_type_1=i._emscripten_bind_b2FrictionJointDef_set_type_1,hs=e._emscripten_bind_b2PrismaticJoint_GetUserData_0=i._emscripten_bind_b2PrismaticJoint_GetUserData_0,is=e._emscripten_bind_b2FrictionJointDef_get_collideConnected_0=i._emscripten_bind_b2FrictionJointDef_get_collideConnected_0,js=e._emscripten_bind_b2Body_GetInertia_0= i._emscripten_bind_b2Body_GetInertia_0,ks=e._emscripten_bind_b2WeldJointDef_set_referenceAngle_1=i._emscripten_bind_b2WeldJointDef_set_referenceAngle_1,ls=e._emscripten_bind_b2FrictionJoint_GetAnchorA_0=i._emscripten_bind_b2FrictionJoint_GetAnchorA_0,ms=e._emscripten_bind_b2RopeJoint_GetType_0=i._emscripten_bind_b2RopeJoint_GetType_0,ns=e._emscripten_bind_b2MassData_get_I_0=i._emscripten_bind_b2MassData_get_I_0,os=e._emscripten_bind_b2WheelJointDef_get_motorSpeed_0=i._emscripten_bind_b2WheelJointDef_get_motorSpeed_0, ps=e._emscripten_bind_b2WeldJointDef_get_referenceAngle_0=i._emscripten_bind_b2WeldJointDef_get_referenceAngle_0,qs=e._emscripten_enum_b2JointType_e_ropeJoint=i._emscripten_enum_b2JointType_e_ropeJoint,rs=e._emscripten_bind_b2Filter_set_maskBits_1=i._emscripten_bind_b2Filter_set_maskBits_1,ss=e._emscripten_bind_b2EdgeShape_set_m_radius_1=i._emscripten_bind_b2EdgeShape_set_m_radius_1,ts=e._emscripten_bind_b2MotorJointDef_set_collideConnected_1=i._emscripten_bind_b2MotorJointDef_set_collideConnected_1, us=e._emscripten_bind_b2Mat22_b2Mat22_2=i._emscripten_bind_b2Mat22_b2Mat22_2,vs=e._emscripten_bind_b2WheelJointDef_set_maxMotorTorque_1=i._emscripten_bind_b2WheelJointDef_set_maxMotorTorque_1,xs=e._emscripten_bind_b2FrictionJointDef_set_bodyB_1=i._emscripten_bind_b2FrictionJointDef_set_bodyB_1,ys=e._emscripten_bind_b2Mat22_b2Mat22_4=i._emscripten_bind_b2Mat22_b2Mat22_4,zs=e._emscripten_bind_b2ChainShape_set_m_hasNextVertex_1=i._emscripten_bind_b2ChainShape_set_m_hasNextVertex_1,As=e._emscripten_bind_b2Mat22_GetInverse_0= i._emscripten_bind_b2Mat22_GetInverse_0,Bs=e._emscripten_bind_b2PrismaticJoint_EnableMotor_1=i._emscripten_bind_b2PrismaticJoint_EnableMotor_1,Cs=e._emscripten_bind_b2CircleShape_get_m_type_0=i._emscripten_bind_b2CircleShape_get_m_type_0,Ds=e._emscripten_bind_b2DistanceJoint_GetLocalAnchorA_0=i._emscripten_bind_b2DistanceJoint_GetLocalAnchorA_0,Es=e._emscripten_bind_b2ContactEdge_b2ContactEdge_0=i._emscripten_bind_b2ContactEdge_b2ContactEdge_0,Fs=e._emscripten_bind_b2BodyDef___destroy___0=i._emscripten_bind_b2BodyDef___destroy___0, Gs=e._emscripten_bind_b2FrictionJointDef_set_maxTorque_1=i._emscripten_bind_b2FrictionJointDef_set_maxTorque_1,Hs=e._emscripten_bind_b2PolygonShape_GetVertex_1=i._emscripten_bind_b2PolygonShape_GetVertex_1,Is=e._emscripten_bind_b2PulleyJointDef_set_groundAnchorB_1=i._emscripten_bind_b2PulleyJointDef_set_groundAnchorB_1,Js=e._emscripten_bind_b2RevoluteJointDef_get_collideConnected_0=i._emscripten_bind_b2RevoluteJointDef_get_collideConnected_0,Ks=e._emscripten_bind_b2DistanceJointDef_set_bodyA_1=i._emscripten_bind_b2DistanceJointDef_set_bodyA_1, Ls=e._emscripten_bind_b2RevoluteJoint_SetLimits_2=i._emscripten_bind_b2RevoluteJoint_SetLimits_2,Ms=e._emscripten_bind_b2WeldJointDef_set_type_1=i._emscripten_bind_b2WeldJointDef_set_type_1,Ns=e._emscripten_bind_b2MotorJointDef___destroy___0=i._emscripten_bind_b2MotorJointDef___destroy___0,Os=e._emscripten_bind_b2FixtureDef_set_density_1=i._emscripten_bind_b2FixtureDef_set_density_1,Ps=e._emscripten_bind_b2Shape_set_m_type_1=i._emscripten_bind_b2Shape_set_m_type_1,Qs=e._emscripten_bind_b2WheelJoint_GetJointTranslation_0= i._emscripten_bind_b2WheelJoint_GetJointTranslation_0,Rs=e._emscripten_bind_b2WheelJoint_GetMotorTorque_1=i._emscripten_bind_b2WheelJoint_GetMotorTorque_1,Ss=e._emscripten_bind_b2RopeJoint_SetUserData_1=i._emscripten_bind_b2RopeJoint_SetUserData_1,Ts=e._emscripten_bind_b2RopeJointDef___destroy___0=i._emscripten_bind_b2RopeJointDef___destroy___0,Us=e._emscripten_bind_b2WheelJoint_IsActive_0=i._emscripten_bind_b2WheelJoint_IsActive_0,Vs=e._emscripten_bind_b2PrismaticJointDef_get_enableMotor_0=i._emscripten_bind_b2PrismaticJointDef_get_enableMotor_0, Ws=e._emscripten_bind_b2MotorJointDef_set_bodyB_1=i._emscripten_bind_b2MotorJointDef_set_bodyB_1,Xs=e._emscripten_bind_b2Transform_b2Transform_2=i._emscripten_bind_b2Transform_b2Transform_2,Ys=e._emscripten_bind_b2WeldJoint_GetReactionForce_1=i._emscripten_bind_b2WeldJoint_GetReactionForce_1,Zs=e._emscripten_bind_b2ChainShape_RayCast_4=i._emscripten_bind_b2ChainShape_RayCast_4,$s=e._emscripten_bind_b2PrismaticJoint_GetUpperLimit_0=i._emscripten_bind_b2PrismaticJoint_GetUpperLimit_0,at=e._emscripten_bind_b2ContactID_get_cf_0= i._emscripten_bind_b2ContactID_get_cf_0,bt=e._emscripten_bind_b2MouseJointDef_set_frequencyHz_1=i._emscripten_bind_b2MouseJointDef_set_frequencyHz_1,ct=e._emscripten_bind_b2ChainShape_get_m_radius_0=i._emscripten_bind_b2ChainShape_get_m_radius_0,dt=e._emscripten_bind_b2Body_GetLinearVelocity_0=i._emscripten_bind_b2Body_GetLinearVelocity_0,et=e._emscripten_bind_b2ChainShape_set_m_radius_1=i._emscripten_bind_b2ChainShape_set_m_radius_1,ft=e._emscripten_bind_b2DistanceJoint_GetReactionTorque_1=i._emscripten_bind_b2DistanceJoint_GetReactionTorque_1, gt=e._emscripten_bind_b2World_Dump_0=i._emscripten_bind_b2World_Dump_0,ht=e._emscripten_bind_b2RevoluteJoint_GetLocalAnchorB_0=i._emscripten_bind_b2RevoluteJoint_GetLocalAnchorB_0,it=e._emscripten_bind_JSContactFilter_JSContactFilter_0=i._emscripten_bind_JSContactFilter_JSContactFilter_0,jt=e._emscripten_bind_b2Profile_set_solve_1=i._emscripten_bind_b2Profile_set_solve_1,kt=e._emscripten_bind_b2WeldJoint_GetDampingRatio_0=i._emscripten_bind_b2WeldJoint_GetDampingRatio_0,lt=e._emscripten_bind_b2Color_get_b_0= i._emscripten_bind_b2Color_get_b_0,mt=e._emscripten_bind_b2MouseJointDef_get_userData_0=i._emscripten_bind_b2MouseJointDef_get_userData_0,nt=e._emscripten_bind_b2CircleShape_ComputeAABB_3=i._emscripten_bind_b2CircleShape_ComputeAABB_3,ot=e._emscripten_bind_b2RopeJoint_GetReactionForce_1=i._emscripten_bind_b2RopeJoint_GetReactionForce_1,pt=e._emscripten_bind_b2PrismaticJointDef_get_enableLimit_0=i._emscripten_bind_b2PrismaticJointDef_get_enableLimit_0,qt=e._emscripten_bind_b2ManifoldPoint_set_localPoint_1= i._emscripten_bind_b2ManifoldPoint_set_localPoint_1,rt=e._emscripten_bind_b2Fixture_GetFilterData_0=i._emscripten_bind_b2Fixture_GetFilterData_0,st=e._emscripten_bind_b2World_GetBodyList_0=i._emscripten_bind_b2World_GetBodyList_0,tt=e._emscripten_bind_b2Shape_ComputeMass_2=i._emscripten_bind_b2Shape_ComputeMass_2,ut=e._emscripten_bind_b2Joint_GetNext_0=i._emscripten_bind_b2Joint_GetNext_0,vt=e._emscripten_bind_b2PrismaticJointDef_get_collideConnected_0=i._emscripten_bind_b2PrismaticJointDef_get_collideConnected_0, wt=e._emscripten_bind_b2World_RayCast_3=i._emscripten_bind_b2World_RayCast_3,xt=e._emscripten_bind_b2MassData_set_I_1=i._emscripten_bind_b2MassData_set_I_1,yt=e._emscripten_bind_b2MassData___destroy___0=i._emscripten_bind_b2MassData___destroy___0,zt=e._emscripten_bind_b2Profile_get_collide_0=i._emscripten_bind_b2Profile_get_collide_0,At=e._emscripten_bind_b2Color_b2Color_3=i._emscripten_bind_b2Color_b2Color_3,Bt=e._emscripten_bind_b2Color_b2Color_0=i._emscripten_bind_b2Color_b2Color_0,Ct=e._emscripten_bind_b2MouseJoint_GetFrequency_0= i._emscripten_bind_b2MouseJoint_GetFrequency_0,Dt=e._emscripten_bind_b2WeldJointDef_Initialize_3=i._emscripten_bind_b2WeldJointDef_Initialize_3,Et=e._emscripten_bind_b2Shape_GetChildCount_0=i._emscripten_bind_b2Shape_GetChildCount_0,Ft=e._emscripten_enum_b2JointType_e_gearJoint=i._emscripten_enum_b2JointType_e_gearJoint,Gt=e._emscripten_bind_b2FixtureDef_get_friction_0=i._emscripten_bind_b2FixtureDef_get_friction_0,Ht=e._emscripten_bind_b2PrismaticJointDef_set_localAnchorA_1=i._emscripten_bind_b2PrismaticJointDef_set_localAnchorA_1, It=e._emscripten_bind_b2Contact_GetManifold_0=i._emscripten_bind_b2Contact_GetManifold_0,Jt=e._emscripten_bind_b2MouseJoint_GetTarget_0=i._emscripten_bind_b2MouseJoint_GetTarget_0,Kt=e._emscripten_bind_b2WeldJointDef_get_localAnchorA_0=i._emscripten_bind_b2WeldJointDef_get_localAnchorA_0,Lt=e._emscripten_bind_b2MouseJoint_SetUserData_1=i._emscripten_bind_b2MouseJoint_SetUserData_1,Mt=e._emscripten_bind_b2JointEdge_get_other_0=i._emscripten_bind_b2JointEdge_get_other_0,Nt=e._emscripten_bind_b2ChainShape_GetChildEdge_2= i._emscripten_bind_b2ChainShape_GetChildEdge_2,Ot=e._emscripten_bind_b2GearJointDef_set_collideConnected_1=i._emscripten_bind_b2GearJointDef_set_collideConnected_1,Pt=e._emscripten_bind_b2MotorJointDef_get_angularOffset_0=i._emscripten_bind_b2MotorJointDef_get_angularOffset_0,Qt=e._emscripten_bind_b2WheelJoint_SetUserData_1=i._emscripten_bind_b2WheelJoint_SetUserData_1,Rt=e._emscripten_bind_b2Body_ApplyForce_3=i._emscripten_bind_b2Body_ApplyForce_3,St=e._emscripten_bind_b2PrismaticJoint_SetMotorSpeed_1= i._emscripten_bind_b2PrismaticJoint_SetMotorSpeed_1,Tt=e._emscripten_bind_b2DistanceJoint_GetCollideConnected_0=i._emscripten_bind_b2DistanceJoint_GetCollideConnected_0,Ut=e._emscripten_bind_b2MouseJoint_GetMaxForce_0=i._emscripten_bind_b2MouseJoint_GetMaxForce_0,Vt=e._emscripten_bind_b2World_SetGravity_1=i._emscripten_bind_b2World_SetGravity_1,Wt=e._emscripten_bind_b2Mat22_SetZero_0=i._emscripten_bind_b2Mat22_SetZero_0,Xt=e._emscripten_bind_b2Contact_GetChildIndexA_0=i._emscripten_bind_b2Contact_GetChildIndexA_0, Yt=e._emscripten_bind_b2Fixture_SetRestitution_1=i._emscripten_bind_b2Fixture_SetRestitution_1,Zt=e._emscripten_bind_b2Body_GetTransform_0=i._emscripten_bind_b2Body_GetTransform_0,$t=e._emscripten_bind_b2ContactEdge___destroy___0=i._emscripten_bind_b2ContactEdge___destroy___0,au=e._emscripten_bind_b2Mat33_set_ex_1=i._emscripten_bind_b2Mat33_set_ex_1,bu=e._emscripten_bind_b2AABB_GetExtents_0=i._emscripten_bind_b2AABB_GetExtents_0,cu=e._emscripten_bind_b2RevoluteJointDef_get_bodyA_0=i._emscripten_bind_b2RevoluteJointDef_get_bodyA_0, du=e._emscripten_bind_b2PrismaticJoint_GetBodyB_0=i._emscripten_bind_b2PrismaticJoint_GetBodyB_0,eu=e._emscripten_bind_b2WheelJointDef_set_bodyA_1=i._emscripten_bind_b2WheelJointDef_set_bodyA_1,fu=e._emscripten_bind_b2DistanceJointDef_set_collideConnected_1=i._emscripten_bind_b2DistanceJointDef_set_collideConnected_1,gu=e._emscripten_bind_b2BodyDef_get_angle_0=i._emscripten_bind_b2BodyDef_get_angle_0,hu=e._emscripten_bind_b2PulleyJoint_GetReactionTorque_1=i._emscripten_bind_b2PulleyJoint_GetReactionTorque_1, iu=e._emscripten_bind_b2FixtureDef_get_shape_0=i._emscripten_bind_b2FixtureDef_get_shape_0,ju=e._emscripten_bind_b2WeldJointDef_get_userData_0=i._emscripten_bind_b2WeldJointDef_get_userData_0,ku=e._emscripten_bind_b2FrictionJoint_SetMaxForce_1=i._emscripten_bind_b2FrictionJoint_SetMaxForce_1,lu=e._emscripten_bind_b2Mat33_b2Mat33_3=i._emscripten_bind_b2Mat33_b2Mat33_3,mu=e._emscripten_bind_b2Vec3_get_y_0=i._emscripten_bind_b2Vec3_get_y_0,nu=e._emscripten_bind_b2JointDef_get_type_0=i._emscripten_bind_b2JointDef_get_type_0, ou=e._emscripten_bind_JSQueryCallback_ReportFixture_1=i._emscripten_bind_JSQueryCallback_ReportFixture_1,pu=e._emscripten_bind_b2Fixture_TestPoint_1=i._emscripten_bind_b2Fixture_TestPoint_1,qu=e._emscripten_bind_b2RevoluteJoint_GetCollideConnected_0=i._emscripten_bind_b2RevoluteJoint_GetCollideConnected_0,ru=e._emscripten_bind_JSDraw_JSDraw_0=i._emscripten_bind_JSDraw_JSDraw_0,su=e._emscripten_bind_b2MouseJoint_GetAnchorA_0=i._emscripten_bind_b2MouseJoint_GetAnchorA_0,tu=e._emscripten_bind_b2Transform_get_p_0= i._emscripten_bind_b2Transform_get_p_0,uu=e._emscripten_bind_b2EdgeShape_ComputeMass_2=i._emscripten_bind_b2EdgeShape_ComputeMass_2,vu=e._emscripten_bind_b2World_GetProfile_0=i._emscripten_bind_b2World_GetProfile_0,wu=e._emscripten_bind_b2DistanceJointDef___destroy___0=i._emscripten_bind_b2DistanceJointDef___destroy___0,xu=e._emscripten_bind_b2RopeJointDef_set_bodyA_1=i._emscripten_bind_b2RopeJointDef_set_bodyA_1,yu=e._emscripten_bind_b2JointDef_set_type_1=i._emscripten_bind_b2JointDef_set_type_1, zu=e._emscripten_bind_b2Draw_AppendFlags_1=i._emscripten_bind_b2Draw_AppendFlags_1,Au=e._emscripten_bind_b2MotorJointDef_get_userData_0=i._emscripten_bind_b2MotorJointDef_get_userData_0,Bu=e._emscripten_bind_b2World_GetContactList_0=i._emscripten_bind_b2World_GetContactList_0,Cu=e._emscripten_bind_b2Mat33_set_ez_1=i._emscripten_bind_b2Mat33_set_ez_1,Du=e._emscripten_bind_b2JointEdge_b2JointEdge_0=i._emscripten_bind_b2JointEdge_b2JointEdge_0,Eu=e._emscripten_bind_b2FrictionJointDef_get_bodyA_0=i._emscripten_bind_b2FrictionJointDef_get_bodyA_0, Fu=e._emscripten_bind_b2WheelJointDef_get_type_0=i._emscripten_bind_b2WheelJointDef_get_type_0,Gu=e._emscripten_bind_b2RevoluteJoint_GetReactionForce_1=i._emscripten_bind_b2RevoluteJoint_GetReactionForce_1,Hu=e._emscripten_bind_b2PulleyJointDef_set_collideConnected_1=i._emscripten_bind_b2PulleyJointDef_set_collideConnected_1,Iu=e._emscripten_bind_b2RopeJoint_GetCollideConnected_0=i._emscripten_bind_b2RopeJoint_GetCollideConnected_0,Ju=e._emscripten_bind_b2GearJointDef_set_joint2_1=i._emscripten_bind_b2GearJointDef_set_joint2_1, Ku=e._emscripten_bind_b2BodyDef_set_userData_1=i._emscripten_bind_b2BodyDef_set_userData_1,Lu=e._emscripten_bind_b2GearJoint_GetAnchorB_0=i._emscripten_bind_b2GearJoint_GetAnchorB_0,Mu=e._emscripten_bind_b2RopeJoint_IsActive_0=i._emscripten_bind_b2RopeJoint_IsActive_0,Nu=e._emscripten_bind_b2Fixture_GetFriction_0=i._emscripten_bind_b2Fixture_GetFriction_0,Ou=e._emscripten_enum_b2DrawFlag_e_aabbBit=i._emscripten_enum_b2DrawFlag_e_aabbBit,Pu=e._emscripten_bind_b2RevoluteJointDef_Initialize_3=i._emscripten_bind_b2RevoluteJointDef_Initialize_3, Qu=e._emscripten_bind_b2Body_GetAngle_0=i._emscripten_bind_b2Body_GetAngle_0,Ru=e._emscripten_bind_b2EdgeShape_Set_2=i._emscripten_bind_b2EdgeShape_Set_2,Su=e._emscripten_bind_b2Mat33_SetZero_0=i._emscripten_bind_b2Mat33_SetZero_0,Tu=e._emscripten_bind_b2MotorJointDef_set_maxTorque_1=i._emscripten_bind_b2MotorJointDef_set_maxTorque_1,Uu=e._emscripten_bind_b2PrismaticJointDef_get_localAxisA_0=i._emscripten_bind_b2PrismaticJointDef_get_localAxisA_0,Vu=e._emscripten_bind_b2Mat22_get_ey_0=i._emscripten_bind_b2Mat22_get_ey_0, Wu=e._emscripten_bind_b2Mat22_SetIdentity_0=i._emscripten_bind_b2Mat22_SetIdentity_0,Xu=e._emscripten_bind_b2Joint_IsActive_0=i._emscripten_bind_b2Joint_IsActive_0,Yu=e._emscripten_bind_b2BodyDef_get_allowSleep_0=i._emscripten_bind_b2BodyDef_get_allowSleep_0,Zu=e._emscripten_bind_b2World_GetTreeHeight_0=i._emscripten_bind_b2World_GetTreeHeight_0,$u=e._emscripten_bind_b2GearJoint_GetJoint2_0=i._emscripten_bind_b2GearJoint_GetJoint2_0,av=e._emscripten_bind_b2EdgeShape_set_m_vertex1_1=i._emscripten_bind_b2EdgeShape_set_m_vertex1_1, bv=e._emscripten_bind_b2Body_GetWorld_0=i._emscripten_bind_b2Body_GetWorld_0,cv=e._emscripten_enum_b2LimitState_e_inactiveLimit=i._emscripten_enum_b2LimitState_e_inactiveLimit,dv=e._emscripten_bind_b2PulleyJointDef_set_lengthB_1=i._emscripten_bind_b2PulleyJointDef_set_lengthB_1,ev=e._emscripten_bind_b2Body_SetAwake_1=i._emscripten_bind_b2Body_SetAwake_1,fv=e._emscripten_bind_b2PrismaticJointDef_set_upperTranslation_1=i._emscripten_bind_b2PrismaticJointDef_set_upperTranslation_1,gv=e._emscripten_bind_b2Vec2___destroy___0= i._emscripten_bind_b2Vec2___destroy___0,hv=e._emscripten_bind_b2RayCastInput_set_p1_1=i._emscripten_bind_b2RayCastInput_set_p1_1,iv=e._emscripten_bind_b2Contact_ResetFriction_0=i._emscripten_bind_b2Contact_ResetFriction_0,jv=e._emscripten_bind_b2PulleyJoint_GetAnchorA_0=i._emscripten_bind_b2PulleyJoint_GetAnchorA_0,kv=e._emscripten_bind_b2BodyDef_get_linearVelocity_0=i._emscripten_bind_b2BodyDef_get_linearVelocity_0,lv=e._emscripten_bind_b2DistanceJointDef_get_bodyB_0=i._emscripten_bind_b2DistanceJointDef_get_bodyB_0, mv=e._emscripten_bind_b2Mat22___destroy___0=i._emscripten_bind_b2Mat22___destroy___0,nv=e._emscripten_bind_b2RevoluteJoint_GetNext_0=i._emscripten_bind_b2RevoluteJoint_GetNext_0,ov=e._emscripten_bind_b2WeldJointDef_get_bodyA_0=i._emscripten_bind_b2WeldJointDef_get_bodyA_0,pv=e._emscripten_bind_b2MotorJoint_GetAnchorB_0=i._emscripten_bind_b2MotorJoint_GetAnchorB_0,qv=e._emscripten_bind_b2Fixture_GetShape_0=i._emscripten_bind_b2Fixture_GetShape_0,rv=e._emscripten_bind_b2PolygonShape_SetAsBox_2=i._emscripten_bind_b2PolygonShape_SetAsBox_2, sv=e._emscripten_bind_b2Vec3_op_mul_1=i._emscripten_bind_b2Vec3_op_mul_1,tv=e._emscripten_bind_b2PolygonShape_set_m_type_1=i._emscripten_bind_b2PolygonShape_set_m_type_1,uv=e._emscripten_bind_b2WheelJoint_GetType_0=i._emscripten_bind_b2WheelJoint_GetType_0,vv=e._emscripten_bind_b2MotorJoint_GetAngularOffset_0=i._emscripten_bind_b2MotorJoint_GetAngularOffset_0,wv=e._emscripten_bind_b2RevoluteJoint_IsActive_0=i._emscripten_bind_b2RevoluteJoint_IsActive_0,xv=e._emscripten_bind_b2GearJoint_GetNext_0= i._emscripten_bind_b2GearJoint_GetNext_0,yv=e._emscripten_bind_b2MotorJointDef_get_correctionFactor_0=i._emscripten_bind_b2MotorJointDef_get_correctionFactor_0,zv=e._emscripten_bind_b2Color_Set_3=i._emscripten_bind_b2Color_Set_3,Av=e._emscripten_bind_b2EdgeShape_set_m_type_1=i._emscripten_bind_b2EdgeShape_set_m_type_1,Bv=e._emscripten_bind_b2WheelJoint_GetLocalAxisA_0=i._emscripten_bind_b2WheelJoint_GetLocalAxisA_0,Cv=e._emscripten_bind_b2Body_GetNext_0=i._emscripten_bind_b2Body_GetNext_0,Dv=e._emscripten_bind_b2RopeJoint_GetBodyA_0= i._emscripten_bind_b2RopeJoint_GetBodyA_0,Ev=e._emscripten_enum_b2JointType_e_unknownJoint=i._emscripten_enum_b2JointType_e_unknownJoint,Fv=e._emscripten_bind_b2ContactFeature_set_indexA_1=i._emscripten_bind_b2ContactFeature_set_indexA_1,Gv=e._emscripten_bind_b2Profile_get_solveInit_0=i._emscripten_bind_b2Profile_get_solveInit_0,Hv=e._emscripten_bind_b2BodyDef_set_angularDamping_1=i._emscripten_bind_b2BodyDef_set_angularDamping_1,Iv=e._emscripten_bind_b2FrictionJoint_GetAnchorB_0=i._emscripten_bind_b2FrictionJoint_GetAnchorB_0, Jv=e._emscripten_bind_b2World_QueryAABB_2=i._emscripten_bind_b2World_QueryAABB_2,Kv=e._emscripten_bind_b2BodyDef_get_userData_0=i._emscripten_bind_b2BodyDef_get_userData_0,Lv=e._emscripten_bind_b2ContactID_get_key_0=i._emscripten_bind_b2ContactID_get_key_0,Mv=e._emscripten_bind_b2Body_SetAngularVelocity_1=i._emscripten_bind_b2Body_SetAngularVelocity_1,Nv=e._emscripten_bind_b2WheelJointDef_get_userData_0=i._emscripten_bind_b2WheelJointDef_get_userData_0,Ov=e._emscripten_bind_b2RevoluteJoint_IsLimitEnabled_0= i._emscripten_bind_b2RevoluteJoint_IsLimitEnabled_0,Pv=e._emscripten_bind_b2DistanceJoint_GetBodyB_0=i._emscripten_bind_b2DistanceJoint_GetBodyB_0,Qv=e._emscripten_bind_b2RevoluteJointDef_set_maxMotorTorque_1=i._emscripten_bind_b2RevoluteJointDef_set_maxMotorTorque_1,Rv=e._emscripten_bind_b2WeldJointDef_set_bodyB_1=i._emscripten_bind_b2WeldJointDef_set_bodyB_1,Sv=e._emscripten_bind_b2RevoluteJoint_SetUserData_1=i._emscripten_bind_b2RevoluteJoint_SetUserData_1,Tv=e._emscripten_bind_b2DistanceJoint_SetLength_1= i._emscripten_bind_b2DistanceJoint_SetLength_1,Uv=e._emscripten_bind_b2JointEdge_get_joint_0=i._emscripten_bind_b2JointEdge_get_joint_0,Vv=e._emscripten_bind_b2Body_GetLocalCenter_0=i._emscripten_bind_b2Body_GetLocalCenter_0,Wv=e._emscripten_bind_b2FixtureDef___destroy___0=i._emscripten_bind_b2FixtureDef___destroy___0,Xv=e._emscripten_bind_b2FixtureDef_set_shape_1=i._emscripten_bind_b2FixtureDef_set_shape_1,Yv=e._emscripten_bind_b2WeldJoint_GetAnchorA_0=i._emscripten_bind_b2WeldJoint_GetAnchorA_0, Zv=e._emscripten_bind_b2Profile_get_solveVelocity_0=i._emscripten_bind_b2Profile_get_solveVelocity_0,$v=e._emscripten_bind_b2WeldJointDef_get_bodyB_0=i._emscripten_bind_b2WeldJointDef_get_bodyB_0,aw=e._emscripten_bind_b2Body_SetAngularDamping_1=i._emscripten_bind_b2Body_SetAngularDamping_1,bw=e._emscripten_bind_b2PulleyJointDef_Initialize_7=i._emscripten_bind_b2PulleyJointDef_Initialize_7,cw=e._emscripten_bind_b2GearJointDef_set_bodyB_1=i._emscripten_bind_b2GearJointDef_set_bodyB_1,dw=e._emscripten_bind_b2RopeJoint_GetReactionTorque_1= i._emscripten_bind_b2RopeJoint_GetReactionTorque_1,ew=e._emscripten_bind_b2Mat22_set_ex_1=i._emscripten_bind_b2Mat22_set_ex_1,fw=e._emscripten_bind_b2GearJoint_GetType_0=i._emscripten_bind_b2GearJoint_GetType_0,gw=e._emscripten_enum_b2DrawFlag_e_centerOfMassBit=i._emscripten_enum_b2DrawFlag_e_centerOfMassBit,hw=e._emscripten_bind_b2ChainShape_b2ChainShape_0=i._emscripten_bind_b2ChainShape_b2ChainShape_0,iw=e._emscripten_bind_b2RevoluteJoint_SetMaxMotorTorque_1=i._emscripten_bind_b2RevoluteJoint_SetMaxMotorTorque_1, jw=e._emscripten_bind_b2RopeJointDef_set_localAnchorB_1=i._emscripten_bind_b2RopeJointDef_set_localAnchorB_1,kw=e._emscripten_bind_b2FrictionJointDef_Initialize_3=i._emscripten_bind_b2FrictionJointDef_Initialize_3,lw=e._emscripten_bind_b2GearJointDef_set_userData_1=i._emscripten_bind_b2GearJointDef_set_userData_1,mw=e._emscripten_bind_b2ChainShape_CreateLoop_2=i._emscripten_bind_b2ChainShape_CreateLoop_2,nw=e._emscripten_bind_b2EdgeShape_get_m_radius_0=i._emscripten_bind_b2EdgeShape_get_m_radius_0, ow=e._emscripten_bind_b2Contact_GetFixtureB_0=i._emscripten_bind_b2Contact_GetFixtureB_0,pw=e._emscripten_bind_b2ChainShape_ComputeMass_2=i._emscripten_bind_b2ChainShape_ComputeMass_2,qw=e._emscripten_bind_b2Vec2_set_y_1=i._emscripten_bind_b2Vec2_set_y_1,rw=e._emscripten_bind_b2PrismaticJoint_IsLimitEnabled_0=i._emscripten_bind_b2PrismaticJoint_IsLimitEnabled_0,sw=e._emscripten_bind_b2RopeJointDef_get_bodyB_0=i._emscripten_bind_b2RopeJointDef_get_bodyB_0,tw=e._emscripten_bind_b2BodyDef_b2BodyDef_0= i._emscripten_bind_b2BodyDef_b2BodyDef_0,uw=e._emscripten_bind_b2MassData_get_mass_0=i._emscripten_bind_b2MassData_get_mass_0,vw=e._emscripten_bind_b2WheelJoint___destroy___0=i._emscripten_bind_b2WheelJoint___destroy___0,ww=e._emscripten_bind_b2Joint_GetBodyB_0=i._emscripten_bind_b2Joint_GetBodyB_0,xw=e._emscripten_bind_b2MouseJointDef_set_collideConnected_1=i._emscripten_bind_b2MouseJointDef_set_collideConnected_1,yw=e._emscripten_bind_b2WheelJointDef_set_localAxisA_1=i._emscripten_bind_b2WheelJointDef_set_localAxisA_1, zw=e._emscripten_bind_b2Joint_Dump_0=i._emscripten_bind_b2Joint_Dump_0,Aw=e._emscripten_bind_b2WheelJointDef_b2WheelJointDef_0=i._emscripten_bind_b2WheelJointDef_b2WheelJointDef_0,Bw=e._emscripten_bind_b2RevoluteJointDef_set_motorSpeed_1=i._emscripten_bind_b2RevoluteJointDef_set_motorSpeed_1,Cw=e._emscripten_bind_b2MotorJointDef_get_bodyA_0=i._emscripten_bind_b2MotorJointDef_get_bodyA_0,Dw=e._emscripten_bind_b2WheelJointDef_get_enableMotor_0=i._emscripten_bind_b2WheelJointDef_get_enableMotor_0,Ew= e._emscripten_bind_b2Vec2_LengthSquared_0=i._emscripten_bind_b2Vec2_LengthSquared_0,Fw=e._emscripten_bind_b2FrictionJointDef_set_bodyA_1=i._emscripten_bind_b2FrictionJointDef_set_bodyA_1,Gw=e._emscripten_bind_b2WheelJoint_GetSpringFrequencyHz_0=i._emscripten_bind_b2WheelJoint_GetSpringFrequencyHz_0,Hw=e._emscripten_bind_b2ContactFeature_get_indexB_0=i._emscripten_bind_b2ContactFeature_get_indexB_0,Iw=e._emscripten_bind_b2Body_GetJointList_0=i._emscripten_bind_b2Body_GetJointList_0,Jw=e._emscripten_bind_b2FrictionJoint_GetBodyA_0= i._emscripten_bind_b2FrictionJoint_GetBodyA_0,Kw=e._emscripten_bind_b2WheelJointDef_set_localAnchorB_1=i._emscripten_bind_b2WheelJointDef_set_localAnchorB_1,Lw=e._emscripten_bind_b2DistanceJointDef_set_localAnchorA_1=i._emscripten_bind_b2DistanceJointDef_set_localAnchorA_1,Mw=e._emscripten_bind_b2PrismaticJointDef_get_maxMotorForce_0=i._emscripten_bind_b2PrismaticJointDef_get_maxMotorForce_0,Nw=e._emscripten_bind_b2Body_SetUserData_1=i._emscripten_bind_b2Body_SetUserData_1,Ow=e._emscripten_bind_b2DistanceJoint_GetUserData_0= i._emscripten_bind_b2DistanceJoint_GetUserData_0,Pw=e._emscripten_bind_b2PulleyJointDef_set_bodyA_1=i._emscripten_bind_b2PulleyJointDef_set_bodyA_1,Qw=e._emscripten_bind_b2Joint_GetType_0=i._emscripten_bind_b2Joint_GetType_0,Rw=e._emscripten_bind_b2Manifold_get_pointCount_0=i._emscripten_bind_b2Manifold_get_pointCount_0,Sw=e._emscripten_bind_b2Mat33_get_ez_0=i._emscripten_bind_b2Mat33_get_ez_0,Tw=e._emscripten_bind_b2DestructionListenerWrapper___destroy___0=i._emscripten_bind_b2DestructionListenerWrapper___destroy___0, Uw=e._emscripten_bind_b2WheelJointDef_get_bodyA_0=i._emscripten_bind_b2WheelJointDef_get_bodyA_0,Vw=e._emscripten_enum_b2LimitState_e_atUpperLimit=i._emscripten_enum_b2LimitState_e_atUpperLimit,Ww=e._emscripten_bind_b2PulleyJointDef_set_groundAnchorA_1=i._emscripten_bind_b2PulleyJointDef_set_groundAnchorA_1,Xw=e._emscripten_bind_b2MouseJointDef_get_type_0=i._emscripten_bind_b2MouseJointDef_get_type_0,Yw=e._emscripten_bind_b2PrismaticJoint_SetMaxMotorForce_1=i._emscripten_bind_b2PrismaticJoint_SetMaxMotorForce_1, Zw=e._emscripten_bind_b2PulleyJointDef_get_collideConnected_0=i._emscripten_bind_b2PulleyJointDef_get_collideConnected_0,$w=e._emscripten_bind_b2RopeJoint_SetMaxLength_1=i._emscripten_bind_b2RopeJoint_SetMaxLength_1,ax=e._emscripten_bind_b2Joint_SetUserData_1=i._emscripten_bind_b2Joint_SetUserData_1,bx=e._emscripten_bind_b2PolygonShape_set_m_radius_1=i._emscripten_bind_b2PolygonShape_set_m_radius_1,cx=e._emscripten_bind_b2Vec2_get_x_0=i._emscripten_bind_b2Vec2_get_x_0,dx=e._emscripten_bind_JSContactListener_JSContactListener_0= i._emscripten_bind_JSContactListener_JSContactListener_0;e.runPostSets=i.runPostSets;e.dynCall_iiii=i.dynCall_iiii;e.dynCall_viiiii=i.dynCall_viiiii;e.dynCall_did=i.dynCall_did;e.dynCall_vi=i.dynCall_vi;e.dynCall_diiiid=i.dynCall_diiiid;e.dynCall_vii=i.dynCall_vii;e.dynCall_viidii=i.dynCall_viidii;e.dynCall_ii=i.dynCall_ii;e.dynCall_viidi=i.dynCall_viidi;e.dynCall_viii=i.dynCall_viii;e.dynCall_v=i.dynCall_v;e.dynCall_viid=i.dynCall_viid;e.dynCall_viiiiii=i.dynCall_viiiiii;e.dynCall_iii=i.dynCall_iii; e.dynCall_iiiiii=i.dynCall_iiiiii;e.dynCall_viiii=i.dynCall_viiii;h.u=i.stackAlloc;h.A=i.stackSave;h.J=i.stackRestore;h.ga=i.setTempRet0;h.aa=i.getTempRet0;var jc=ba;if(Nb)if("function"===typeof e.locateFile?Nb=e.locateFile(Nb):e.memoryInitializerPrefixURL&&(Nb=e.memoryInitializerPrefixURL+Nb),fa||ja){var ex=e.readBinary(Nb);bb.set(ex,jb)}else Lb(),Browser.oa(Nb,function(a){bb.set(a,jb);Mb()},function(){c("could not load memory initializer "+Nb)}); function na(a){this.name="ExitStatus";this.message="Program terminated with exit("+a+")";this.status=a}na.prototype=Error();var fx,gx=ba,Kb=function hx(){!e.calledRun&&ix&&jx();e.calledRun||(Kb=hx)}; e.callMain=e.pa=function(a){function b(){for(var a=0;3>a;a++)g.push(0)}oa(0==Ib,"cannot call main when async dependencies remain! (listen on __ATMAIN__)");oa(0==rb.length,"cannot call main when preRun functions remain to be called");a=a||[];wb||(wb=aa,qb(sb));var f=a.length+1,g=[$a(Ab(e.thisProgram),"i8",0)];b();for(var k=0;k= px && px >= x2-0.1) || (x1-0.1 <= px && px <= x2+0.1); var b2 = (y1+0.1 >= py && py >= y2-0.1) || (y1-0.1 <= py && py <= y2+0.1); return (b1 && b2) && cr.b2Separator.isOnLine(px, py, x1, y1, x2, y2); }; cr.b2Separator.isOnLine = function(px, py, x1, y1, x2, y2) { if (Math.abs(x2-x1) > 0.1) { var a = (y2-y1) / (x2-x1); var possibleY = a * (px-x1)+y1; var diff = Math.abs(possibleY-py); return diff < 0.1; } return Math.abs(px-x1) < 0.1; }; cr.b2Separator.pointsMatch = function(x1, y1, x2, y2) { return Math.abs(x2-x1) < 0.1 && Math.abs(y2-y1) < 0.1; }; cr.b2Separator.Separate = function(verticesVec /*array of b2Vec2*/, objarea) { var calced = cr.b2Separator.calcShapes(verticesVec); var ret = []; var poly, a, b, c; var i, len, j, lenj; var areasum; for (i = 0, len = calced.length; i < len; i++) { a = calced[i]; poly = []; poly.length = a.length; areasum = 0; for (j = 0, lenj = a.length; j < lenj; j++) { b = a[j]; c = a[(j + 1) % lenj]; areasum += (b.get_x() * c.get_y() - b.get_y() * c.get_x()); poly[j] = b2Vec2.Get(b.get_x(), b.get_y()); } areasum = Math.abs(areasum / 2); if (areasum >= objarea * 0.001) ret.push(poly); else { for (j = 0, lenj = poly.length; j < lenj; j++) b2Vec2.Free(poly[j]); } } ; return ret; }; cr.b2Separator.calcShapes = function(verticesVec /*array of b2Vec2*/) { var vec = []; // array of b2Vec2 var i = 0, n = 0, j = 0; // ints var d = 0, t = 0, dx = 0, dy = 0, minLen = 0; // numbers var i1 = 0, i2 = 0, i3 = 0; // ints var p1, p2, p3, v1, v2, v, hitV; // b2Vec2s var j1 = 0, j2 = 0, k = 0, h = 0; // ints var vec1 = [], vec2 = []; // array of b2Vec2 var isConvex = false; // boolean var figsVec = [], queue = []; // Arrays var pushed = false; queue.push(verticesVec); while (queue.length) { vec = queue[0]; n = vec.length; isConvex = true; for (i = 0; i < n; i++) { i1 = i; i2 = (i < n-1) ? i+1 : i+1-n; i3 = (i < n-2) ? i+2 : i+2-n; p1 = vec[i1]; p2 = vec[i2]; p3 = vec[i3]; d = cr.b2Separator.det(p1.get_x(), p1.get_y(), p2.get_x(), p2.get_y(), p3.get_x(), p3.get_y()); if (d < 0) { isConvex = false; minLen = 1e9; for (j = 0; j < n; j++) { if ((j !== i1) && (j !== i2)) { j1 = j; j2 = (j= n) return []; if (!cr.b2Separator.isOnSegment(v2.get_x(), v2.get_y(), vec[h].get_x(), vec[h].get_y(), p1.get_x(), p1.get_y())) vec1.push(vec[k]); break; } h = k; if (k-1 < 0) k = n-1; else k--; } vec1.reverse(); h = -1; k = i2; while (true) { if (k !== j1) vec2.push(vec[k]); else { if (h < 0 || h >= n) return []; if (k === j1 && !cr.b2Separator.isOnSegment(v1.get_x(), v1.get_y(), vec[h].get_x(), vec[h].get_y(), p2.get_x(), p2.get_y())) vec2.push(vec[k]); break; } h = k; if (k+1 > n-1) k = 0; else k++; } queue.push(vec1, vec2); queue.shift(); break; } } if (isConvex) figsVec.push(queue.shift()); } return figsVec; }; ; ; cr.behaviors.Physics = function(runtime) { this.runtime = runtime; this.world = new Box2D.b2World(getTempVec2a(0, 10), // gravity true); // allow sleep this.worldG = 10; this.lastUpdateTick = -1; var listener = new Box2D.JSContactListener(); listener.BeginContact = function (contactPtr) { var contact = Box2D.wrapPointer(contactPtr, Box2D.b2Contact); var behA = contact.GetFixtureA().GetBody().c2userdata; var behB = contact.GetFixtureB().GetBody().c2userdata; runtime.registerCollision(behA.inst, behB.inst); }; listener.EndContact = function () {}; // unused this.world.SetContactListener(listener); var filter = new Box2D.JSContactFilter(); var self = this; filter.ShouldCollide = function (fixAPtr, fixBPtr) { if (self.allCollisionsEnabled) return true; var fixtureA = Box2D.wrapPointer(fixAPtr, Box2D.b2Fixture); var fixtureB = Box2D.wrapPointer(fixBPtr, Box2D.b2Fixture); var typeA = fixtureA.GetBody().c2userdata.inst.type; var typeB = fixtureB.GetBody().c2userdata.inst.type; var s = typeA.extra["Physics_DisabledCollisions"]; if (s && s.contains(typeB)) return false; s = typeB.extra["Physics_DisabledCollisions"]; if (s && s.contains(typeA)) return false; return true; }; this.world.SetContactFilter(filter); this.steppingMode = 0; // fixed this.velocityIterations = 8; this.positionIterations = 3; this.allCollisionsEnabled = true; }; (function () { var b2BodyDef = Box2D.b2BodyDef, b2Body = Box2D.b2Body, b2FixtureDef = Box2D.b2FixtureDef, b2Fixture = Box2D.b2Fixture, b2World = Box2D.b2World, b2PolygonShape = Box2D.b2PolygonShape, b2CircleShape = Box2D.b2CircleShape, b2DistanceJointDef = Box2D.b2DistanceJointDef, b2RevoluteJointDef = Box2D.b2RevoluteJointDef; var TILE_FLIPPED_HORIZONTAL = -0x80000000 // note: pretend is a signed int, so negate var TILE_FLIPPED_VERTICAL = 0x40000000 var TILE_FLIPPED_DIAGONAL = 0x20000000 var TILE_FLAGS_MASK = 0xE0000000 var worldScale = 0.02; var behaviorProto = cr.behaviors.Physics.prototype; behaviorProto.Type = function(behavior, objtype) { this.behavior = behavior; this.objtype = objtype; this.runtime = behavior.runtime; }; var behtypeProto = behaviorProto.Type.prototype; behtypeProto.onCreate = function() { }; behaviorProto.Instance = function(type, inst) { this.type = type; this.behavior = type.behavior; this.inst = inst; // associated object instance to modify this.runtime = type.runtime; this.world = this.behavior.world; }; var behinstProto = behaviorProto.Instance.prototype; behinstProto.onCreate = function() { this.immovable = (this.properties[0] !== 0); this.collisionmask = this.properties[1]; this.preventRotation = (this.properties[2] !== 0); this.density = this.properties[3]; this.friction = this.properties[4]; this.restitution = this.properties[5]; this.linearDamping = this.properties[6]; this.angularDamping = this.properties[7]; this.bullet = (this.properties[8] !== 0); this.enabled = (this.properties[9] !== 0); this.body = null; this.fixture = null; this.inst.update_bbox(); this.lastKnownX = this.inst.x; this.lastKnownY = this.inst.y; this.lastKnownAngle = this.inst.angle; this.lastWidth = 0; this.lastHeight = 0; this.lastTickOverride = false; this.recreateBody = false; this.lastAnimation = null; // for sprites only - will be undefined for other objects this.lastAnimationFrame = -1; // for sprites only - will be undefined for other objects if (this.myJoints) { cr.clearArray(this.myJoints); cr.clearArray(this.myCreatedJoints); this.joiningMe.clear(); } else { this.myJoints = []; // Created Box2D joints this.myCreatedJoints = []; // List of actions called to create joints this.joiningMe = new cr.ObjectSet(); // Instances with joints to me } var self = this; if (!this.recycled) { this.myDestroyCallback = (function(inst) { self.onInstanceDestroyed(inst); }); } this.runtime.addDestroyCallback(this.myDestroyCallback); }; behinstProto.postCreate = function () { this.inst.update_bbox(); this.createBody(); this.lastAnimation = this.inst.cur_animation; this.lastAnimationFrame = this.inst.cur_frame; }; behinstProto.onDestroy = function() { this.destroyBody(); cr.clearArray(this.myCreatedJoints); this.joiningMe.clear(); this.runtime.removeDestroyCallback(this.myDestroyCallback); }; behinstProto.saveToJSON = function () { var o = { "e": this.enabled, "im": this.immovable, "pr": this.preventRotation, "d": this.density, "fr": this.friction, "re": this.restitution, "ld": this.linearDamping, "ad": this.angularDamping, "b": this.bullet, "mcj": this.myCreatedJoints }; if (this.enabled) { var temp = this.body.GetLinearVelocity(); o["vx"] = temp.get_x(); o["vy"] = temp.get_y(); o["om"] = this.body.GetAngularVelocity(); } return o; }; behinstProto.loadFromJSON = function (o) { this.destroyBody(); cr.clearArray(this.myCreatedJoints); this.joiningMe.clear(); this.enabled = o["e"]; this.immovable = o["im"]; this.preventRotation = o["pr"]; this.density = o["d"]; this.friction = o["fr"]; this.restitution = o["re"]; this.linearDamping = o["ld"]; this.angularDamping = o["ad"]; this.bullet = o["b"]; this.lastKnownX = this.inst.x; this.lastKnownY = this.inst.y; this.lastKnownAngle = this.inst.angle; this.lastWidth = this.inst.width; this.lastHeight = this.inst.height; if (this.enabled) { this.createBody(); this.body.SetLinearVelocity(getTempVec2a(o["vx"], o["vy"])); this.body.SetAngularVelocity(o["om"]); if (o["vx"] !== 0 || o["vy"] !== 0 || o["om"] !== 0) this.body.SetAwake(true); this.myCreatedJoints = o["mcj"]; } }; behinstProto.afterLoad = function () { if (this.enabled) this.recreateMyJoints(); }; behinstProto.onInstanceDestroyed = function (inst) { var i, len, j, instuid = inst.uid; for (i = 0, j = 0, len = this.myCreatedJoints.length; i < len; i++) { this.myCreatedJoints[j] = this.myCreatedJoints[i]; if (j < this.myJoints.length) this.myJoints[j] = this.myJoints[i]; if (this.myCreatedJoints[i].params[1] == instuid) // attached instance is always 2nd param { if (i < this.myJoints.length) // myJoints can already be empty in some cases this.world.DestroyJoint(this.myJoints[i]); } else j++; } this.myCreatedJoints.length = j; if (j < this.myJoints.length) this.myJoints.length = j; this.joiningMe.remove(inst); }; behinstProto.destroyMyJoints = function() { var i, len; for (i = 0, len = this.myJoints.length; i < len; i++) this.world.DestroyJoint(this.myJoints[i]); cr.clearArray(this.myJoints); }; behinstProto.recreateMyJoints = function() { var i, len, j; for (i = 0, len = this.myCreatedJoints.length; i < len; i++) { j = this.myCreatedJoints[i]; switch (j.type) { case 0: // distance joint this.doCreateDistanceJoint(j.params[0], j.params[1], j.params[2], j.params[3], j.params[4]); break; case 1: // revolute joint this.doCreateRevoluteJoint(j.params[0], j.params[1]); break; case 2: // limited revolute joint this.doCreateLimitedRevoluteJoint(j.params[0], j.params[1], j.params[2], j.params[3]); break; default: ; } } }; behinstProto.destroyBody = function() { if (!this.body) return; this.destroyMyJoints(); if (this.fixture) { this.body.DestroyFixture(this.fixture); this.fixture = null; } this.world.DestroyBody(this.body); this.body = null; this.inst.extra.box2dbody = null; }; var collrects = []; behinstProto.createBody = function() { if (!this.enabled) return; var inst = this.inst; inst.update_bbox(); var i, len, j, lenj, k, lenk, vec, arr, b, tv, c, rc, pts_cache, pts_count, convexpolys, cp, offx, offy, oldAngle; if (!this.body) { var bodyDef = new b2BodyDef(); bodyDef.set_type(this.immovable ? 0 : 2); // 0 = b2_staticBody, 2 = b2_dynamicBody bodyDef.set_position(getTempVec2b(inst.bquad.midX() * worldScale, inst.bquad.midY() * worldScale)); bodyDef.set_angle(inst.angle); bodyDef.set_fixedRotation(this.preventRotation); bodyDef.set_linearDamping(this.linearDamping); bodyDef.set_angularDamping(this.angularDamping); bodyDef.set_bullet(this.bullet); this.body = this.world.CreateBody(bodyDef); this.body.c2userdata = this; inst.extra.box2dbody = this.body; Box2D.destroy(bodyDef); } if (this.fixture) { this.body.DestroyFixture(this.fixture); this.fixture = null; } var fixDef = new b2FixtureDef(); fixDef.set_density(this.density); fixDef.set_friction(this.friction); fixDef.set_restitution(this.restitution); var hasPoly = this.inst.collision_poly && !this.inst.collision_poly.is_empty(); var usecollisionmask = this.collisionmask; if (!hasPoly && !this.inst.tilemap_exists && this.collisionmask === 0) usecollisionmask = 1; var instw = Math.max(Math.abs(inst.width), 1); var insth = Math.max(Math.abs(inst.height), 1); var ismirrored = inst.width < 0; var isflipped = inst.height < 0; var shape; if (usecollisionmask === 0) { if (inst.tilemap_exists) { offx = inst.bquad.midX() - inst.x; offy = inst.bquad.midY() - inst.y; inst.getAllCollisionRects(collrects); arr = []; for (i = 0, len = collrects.length; i < len; ++i) { c = collrects[i]; rc = c.rc; if (c.poly) { if (!c.poly.convexpolys) { pts_cache = c.poly.pts_cache; pts_count = c.poly.pts_count; for (j = 0; j < pts_count; ++j) { arr.push(b2Vec2.Get(pts_cache[j*2], pts_cache[j*2+1])); } var flags = (c.id & TILE_FLAGS_MASK); if (flags === TILE_FLIPPED_HORIZONTAL || flags === TILE_FLIPPED_VERTICAL || flags === TILE_FLIPPED_DIAGONAL || ((flags & TILE_FLIPPED_HORIZONTAL) && (flags & TILE_FLIPPED_VERTICAL) && (flags & TILE_FLIPPED_DIAGONAL))) { arr.reverse(); } c.poly.convexpolys = cr.b2Separator.Separate(arr, (rc.right - rc.left) * (rc.bottom - rc.top)); for (j = 0, lenj = arr.length; j < lenj; ++j) b2Vec2.Free(arr[j]); cr.clearArray(arr); } for (j = 0, lenj = c.poly.convexpolys.length; j < lenj; ++j) { cp = c.poly.convexpolys[j]; ; for (k = 0, lenk = cp.length; k < lenk; ++k) { arr.push(b2Vec2.Get((rc.left + cp[k].get_x() - offx) * worldScale, (rc.top + cp[k].get_y() - offy) * worldScale)); } shape = createPolygonShape(arr); fixDef.set_shape(shape); this.fixture = this.body.CreateFixture(fixDef); Box2D.destroy(shape); for (k = 0, lenk = arr.length; k < lenk; ++k) b2Vec2.Free(arr[k]); cr.clearArray(arr); } } else { arr.push(b2Vec2.Get((rc.left - offx) * worldScale, (rc.top - offy) * worldScale)); arr.push(b2Vec2.Get((rc.right - offx) * worldScale, (rc.top - offy) * worldScale)); arr.push(b2Vec2.Get((rc.right - offx) * worldScale, (rc.bottom - offy) * worldScale)); arr.push(b2Vec2.Get((rc.left - offx) * worldScale, (rc.bottom - offy) * worldScale)); shape = createPolygonShape(arr); fixDef.set_shape(shape); this.fixture = this.body.CreateFixture(fixDef); Box2D.destroy(shape); } for (j = 0, lenj = arr.length; j < lenj; ++j) b2Vec2.Free(arr[j]); cr.clearArray(arr); } } else { oldAngle = inst.angle; inst.angle = 0; inst.set_bbox_changed(); inst.update_bbox(); offx = inst.bquad.midX() - inst.x; offy = inst.bquad.midY() - inst.y; inst.angle = oldAngle; inst.set_bbox_changed(); inst.collision_poly.cache_poly(ismirrored ? -instw : instw, isflipped ? -insth : insth, 0); pts_cache = inst.collision_poly.pts_cache; pts_count = inst.collision_poly.pts_count; arr = []; arr.length = pts_count; for (i = 0; i < pts_count; i++) { arr[i] = b2Vec2.Get(pts_cache[i*2] - offx, pts_cache[i*2+1] - offy); } if (ismirrored !== isflipped) arr.reverse(); // wrong clockwise order when flipped convexpolys = cr.b2Separator.Separate(arr, instw * insth); for (i = 0; i < pts_count; i++) b2Vec2.Free(arr[i]); if (convexpolys.length) { for (i = 0, len = convexpolys.length; i < len; i++) { arr = convexpolys[i]; ; for (j = 0, lenj = arr.length; j < lenj; j++) { vec = arr[j]; vec.set_x(vec.get_x() * worldScale); vec.set_y(vec.get_y() * worldScale); } shape = createPolygonShape(arr); fixDef.set_shape(shape); this.fixture = this.body.CreateFixture(fixDef); Box2D.destroy(shape); for (j = 0, lenj = arr.length; j < lenj; j++) b2Vec2.Free(arr[j]); } } else { shape = new b2PolygonShape(); shape.SetAsBox(instw * worldScale * 0.5, insth * worldScale * 0.5); fixDef.set_shape(shape); this.fixture = this.body.CreateFixture(fixDef); Box2D.destroy(shape); } } } else if (usecollisionmask === 1) { shape = new b2PolygonShape(); shape.SetAsBox(instw * worldScale * 0.5, insth * worldScale * 0.5); fixDef.set_shape(shape); this.fixture = this.body.CreateFixture(fixDef); Box2D.destroy(shape); } else { shape = new b2CircleShape(); shape.set_m_radius(Math.min(instw, insth) * worldScale * 0.5); fixDef.set_shape(shape); this.fixture = this.body.CreateFixture(fixDef); Box2D.destroy(shape); } this.lastWidth = inst.width; this.lastHeight = inst.height; Box2D.destroy(fixDef); cr.clearArray(collrects); }; /* behinstProto.draw = function (ctx) { if (!this.myconvexpolys) return; this.inst.update_bbox(); var midx = this.inst.bquad.midX(); var midy = this.inst.bquad.midY(); var i, len, j, lenj; var sina = 0; var cosa = 1; if (this.inst.angle !== 0) { sina = Math.sin(this.inst.angle); cosa = Math.cos(this.inst.angle); } var strokeStyles = ["#f00", "#0f0", "#00f", "#ff0", "#0ff", "#f0f"]; ctx.lineWidth = 2; var i, len, j, lenj, ax, ay, bx, by, poly, va, vb; for (i = 0, len = this.myconvexpolys.length; i < len; i++) { poly = this.myconvexpolys[i]; ctx.strokeStyle = strokeStyles[i]; for (j = 0, lenj = poly.length; j < lenj; j++) { va = poly[j]; vb = poly[(j + 1) % lenj]; ax = va.x / worldScale; ay = va.y / worldScale; bx = vb.x / worldScale; by = vb.y / worldScale; ctx.beginPath(); ctx.moveTo(((ax * cosa) - (ay * sina)) + midx, ((ay * cosa) + (ax * sina)) + midy); ctx.lineTo(((bx * cosa) - (by * sina)) + midx, ((by * cosa) + (bx * sina)) + midy); ctx.stroke(); ctx.closePath(); } } }; */ behinstProto.tick = function () { if (!this.enabled) return; var inst = this.inst; var dt; if (this.behavior.steppingMode === 0) // fixed { dt = this.runtime.timescale / 60; } else { dt = this.runtime.getDt(this.inst); if (dt > 1 / 30) dt = 1 / 30; } if (this.runtime.tickcount_nosave > this.behavior.lastUpdateTick && this.runtime.timescale > 0) { if (dt !== 0) { this.world.Step(dt, this.behavior.velocityIterations, this.behavior.positionIterations); // still apply timescale } this.world.ClearForces(); this.behavior.lastUpdateTick = this.runtime.tickcount_nosave; } if (this.recreateBody || inst.width !== this.lastWidth || inst.height !== this.lastHeight || inst.cur_animation !== this.lastAnimation || inst.cur_frame !== this.lastAnimationFrame || (inst.tilemap_exists && inst.physics_changed)) { this.createBody(); this.recreateBody = false; this.lastAnimation = inst.cur_animation; this.lastAnimationFrame = inst.cur_frame; if (inst.tilemap_exists && inst.physics_changed) inst.physics_changed = false; } var pos_changed = (inst.x !== this.lastKnownX || inst.y !== this.lastKnownY); var angle_changed = (inst.angle !== this.lastKnownAngle); if (pos_changed) { inst.update_bbox(); var newmidx = inst.bquad.midX(); var newmidy = inst.bquad.midY(); var diffx = newmidx - this.lastKnownX; var diffy = newmidy - this.lastKnownY; if (angle_changed) this.body.SetTransform(getTempVec2a(newmidx * worldScale, newmidy * worldScale), inst.angle); else this.body.SetTransform(getTempVec2a(newmidx * worldScale, newmidy * worldScale), this.body.GetAngle()); this.body.SetLinearVelocity(getTempVec2a(diffx, diffy)); this.lastTickOverride = true; this.body.SetAwake(true); } else if (this.lastTickOverride) { this.lastTickOverride = false; this.body.SetLinearVelocity(getTempVec2a(0, 0)); this.body.SetTransform(getTempVec2a(inst.bquad.midX() * worldScale, inst.bquad.midY() * worldScale), this.body.GetAngle()); } if (!pos_changed && angle_changed) { this.body.SetTransform(this.body.GetPosition(), inst.angle); this.body.SetAwake(true); } var pos = this.body.GetPosition(); var newx = pos.get_x() / worldScale; var newy = pos.get_y() / worldScale; var newangle = this.body.GetAngle(); if (newx !== inst.x || newy !== inst.y || newangle !== inst.angle) { inst.x = newx; inst.y = newy; inst.angle = newangle; inst.set_bbox_changed(); inst.update_bbox(); var dx = inst.bquad.midX() - inst.x; var dy = inst.bquad.midY() - inst.y; if (dx !== 0 || dy !== 0) { inst.x -= dx; inst.y -= dy; inst.set_bbox_changed(); } } this.lastKnownX = inst.x; this.lastKnownY = inst.y; this.lastKnownAngle = inst.angle; }; behinstProto.getInstImgPointX = function(imgpt) { if (imgpt === -1 || !this.inst.getImagePoint) return this.inst.x; if (imgpt === 0 && this.body) return (this.body.GetPosition().get_x() + this.body.GetLocalCenter().get_x()) / worldScale; return this.inst.getImagePoint(imgpt, true); }; behinstProto.getInstImgPointY = function(imgpt) { if (imgpt === -1 || !this.inst.getImagePoint) return this.inst.y; if (imgpt === 0 && this.body) return (this.body.GetPosition().get_y() + this.body.GetLocalCenter().get_y()) / worldScale; return this.inst.getImagePoint(imgpt, false); }; function Cnds() {}; Cnds.prototype.IsSleeping = function () { if (!this.enabled) return false; return !this.body.IsAwake(); }; Cnds.prototype.CompareVelocity = function (which_, cmp_, x_) { if (!this.enabled) return false; var velocity_vec = this.body.GetLinearVelocity(); var v, vx, vy; if (which_ === 0) // X velocity v = velocity_vec.get_x() / worldScale; else if (which_ === 1) // Y velocity v = velocity_vec.get_y() / worldScale; else // Overall velocity { vx = velocity_vec.get_x() / worldScale; vy = velocity_vec.get_y() / worldScale; v = cr.distanceTo(0, 0, vx, vy); } return cr.do_cmp(v, cmp_, x_); }; Cnds.prototype.CompareAngularVelocity = function (cmp_, x_) { if (!this.enabled) return false; var av = cr.to_degrees(this.body.GetAngularVelocity()); return cr.do_cmp(av, cmp_, x_); }; Cnds.prototype.CompareMass = function (cmp_, x_) { if (!this.enabled) return false; var mass = this.body.GetMass() / worldScale; return cr.do_cmp(mass, cmp_, x_); }; Cnds.prototype.IsEnabled = function () { return this.enabled; }; behaviorProto.cnds = new Cnds(); function Acts() {}; Acts.prototype.ApplyForce = function (fx, fy, imgpt) { if (!this.enabled) return; var x = this.getInstImgPointX(imgpt); var y = this.getInstImgPointY(imgpt); this.body.ApplyForce(getTempVec2a(fx, fy), getTempVec2b(x * worldScale, y * worldScale), true); }; Acts.prototype.ApplyForceToward = function (f, px, py, imgpt) { if (!this.enabled) return; var x = this.getInstImgPointX(imgpt); var y = this.getInstImgPointY(imgpt); var a = cr.angleTo(x, y, px, py); this.body.ApplyForce(getTempVec2a(Math.cos(a) * f, Math.sin(a) * f), getTempVec2b(x * worldScale, y * worldScale), true); }; Acts.prototype.ApplyForceAtAngle = function (f, a, imgpt) { if (!this.enabled) return; a = cr.to_radians(a); var x = this.getInstImgPointX(imgpt); var y = this.getInstImgPointY(imgpt); this.body.ApplyForce(getTempVec2a(Math.cos(a) * f, Math.sin(a) * f), getTempVec2b(x * worldScale, y * worldScale), true); }; Acts.prototype.ApplyImpulse = function (fx, fy, imgpt) { if (!this.enabled) return; var x = this.getInstImgPointX(imgpt); var y = this.getInstImgPointY(imgpt); this.body.ApplyLinearImpulse(getTempVec2a(fx, fy), getTempVec2b(x * worldScale, y * worldScale), true); this.lastTickOverride = false; this.lastKnownX = this.inst.x; this.lastKnownY = this.inst.y; }; Acts.prototype.ApplyImpulseToward = function (f, px, py, imgpt) { if (!this.enabled) return; var x = this.getInstImgPointX(imgpt); var y = this.getInstImgPointY(imgpt); var a = cr.angleTo(x, y, px, py); this.body.ApplyLinearImpulse(getTempVec2a(Math.cos(a) * f, Math.sin(a) * f), getTempVec2b(x * worldScale, y * worldScale), true); this.lastTickOverride = false; this.lastKnownX = this.inst.x; this.lastKnownY = this.inst.y; }; Acts.prototype.ApplyImpulseAtAngle = function (f, a, imgpt) { if (!this.enabled) return; a = cr.to_radians(a); var x = this.getInstImgPointX(imgpt); var y = this.getInstImgPointY(imgpt); this.body.ApplyLinearImpulse(getTempVec2a(Math.cos(a) * f, Math.sin(a) * f), getTempVec2b(x * worldScale, y * worldScale), true); this.lastTickOverride = false; this.lastKnownX = this.inst.x; this.lastKnownY = this.inst.y; }; Acts.prototype.ApplyTorque = function (m) { if (!this.enabled) return; this.body.ApplyTorque(cr.to_radians(m), true); }; Acts.prototype.ApplyTorqueToAngle = function (m, a) { if (!this.enabled) return; m = cr.to_radians(m); a = cr.to_radians(a); if (cr.angleClockwise(this.inst.angle, a)) this.body.ApplyTorque(-m, true); else this.body.ApplyTorque(m, true); }; Acts.prototype.ApplyTorqueToPosition = function (m, x, y) { if (!this.enabled) return; m = cr.to_radians(m); var a = cr.angleTo(this.inst.x, this.inst.y, x, y); if (cr.angleClockwise(this.inst.angle, a)) this.body.ApplyTorque(-m, true); else this.body.ApplyTorque(m, true); }; Acts.prototype.SetAngularVelocity = function (v) { if (!this.enabled) return; this.body.SetAngularVelocity(cr.to_radians(v)); this.body.SetAwake(true); }; Acts.prototype.CreateDistanceJoint = function (imgpt, obj, objimgpt, damping, freq) { if (!obj || !this.enabled) return; var otherinst = obj.getFirstPicked(this.inst); if (!otherinst || otherinst == this.inst) return; if (!otherinst.extra.box2dbody) return; // no physics behavior on other object this.myCreatedJoints.push({type: 0, params: [imgpt, otherinst.uid, objimgpt, damping, freq]}); this.doCreateDistanceJoint(imgpt, otherinst.uid, objimgpt, damping, freq); }; behinstProto.doCreateDistanceJoint = function (imgpt, otherinstuid, objimgpt, damping, freq) { if (!this.enabled) return; var otherinst = this.runtime.getObjectByUID(otherinstuid); if (!otherinst || otherinst == this.inst || !otherinst.extra.box2dbody) return; otherinst.extra.box2dbody.c2userdata.joiningMe.add(this.inst); var myx = this.getInstImgPointX(imgpt); var myy = this.getInstImgPointY(imgpt); var theirx, theiry; if (otherinst.getImagePoint) { theirx = otherinst.getImagePoint(objimgpt, true); theiry = otherinst.getImagePoint(objimgpt, false); } else { theirx = otherinst.x; theiry = otherinst.y; } var dx = myx - theirx; var dy = myy - theiry; var jointDef = new b2DistanceJointDef(); jointDef.Initialize(this.body, otherinst.extra.box2dbody, getTempVec2a(myx * worldScale, myy * worldScale), getTempVec2b(theirx * worldScale, theiry * worldScale)); jointDef.set_length(Math.sqrt(dx*dx + dy*dy) * worldScale); jointDef.set_dampingRatio(damping); jointDef.set_frequencyHz(freq); this.myJoints.push(this.world.CreateJoint(jointDef)); Box2D.destroy(jointDef); }; Acts.prototype.CreateRevoluteJoint = function (imgpt, obj) { if (!obj || !this.enabled) return; var otherinst = obj.getFirstPicked(this.inst); if (!otherinst || otherinst == this.inst) return; if (!otherinst.extra.box2dbody) return; // no physics behavior on other object this.myCreatedJoints.push({type: 1, params: [imgpt, otherinst.uid]}); this.doCreateRevoluteJoint(imgpt, otherinst.uid); }; behinstProto.doCreateRevoluteJoint = function (imgpt, otherinstuid) { if (!this.enabled) return; var otherinst = this.runtime.getObjectByUID(otherinstuid); if (!otherinst || otherinst == this.inst || !otherinst.extra.box2dbody) return; otherinst.extra.box2dbody.c2userdata.joiningMe.add(this.inst); var myx = this.getInstImgPointX(imgpt); var myy = this.getInstImgPointY(imgpt); var jointDef = new b2RevoluteJointDef(); jointDef.Initialize(this.body, otherinst.extra.box2dbody, getTempVec2a(myx * worldScale, myy * worldScale)); this.myJoints.push(this.world.CreateJoint(jointDef)); Box2D.destroy(jointDef); }; Acts.prototype.CreateLimitedRevoluteJoint = function (imgpt, obj, lower, upper) { if (!obj || !this.enabled) return; var otherinst = obj.getFirstPicked(this.inst); if (!otherinst || otherinst == this.inst) return; if (!otherinst.extra.box2dbody) return; // no physics behavior on other object this.myCreatedJoints.push({type: 2, params: [imgpt, otherinst.uid, lower, upper]}); this.doCreateLimitedRevoluteJoint(imgpt, otherinst.uid, lower, upper); }; behinstProto.doCreateLimitedRevoluteJoint = function (imgpt, otherinstuid, lower, upper) { if (!this.enabled) return; var otherinst = this.runtime.getObjectByUID(otherinstuid); if (!otherinst || otherinst == this.inst || !otherinst.extra.box2dbody) return; otherinst.extra.box2dbody.c2userdata.joiningMe.add(this.inst); var myx = this.getInstImgPointX(imgpt); var myy = this.getInstImgPointY(imgpt); var jointDef = new b2RevoluteJointDef(); jointDef.Initialize(this.body, otherinst.extra.box2dbody, getTempVec2a(myx * worldScale, myy * worldScale)); jointDef.set_enableLimit(true); jointDef.set_lowerAngle(cr.to_radians(lower)); jointDef.set_upperAngle(cr.to_radians(upper)); this.myJoints.push(this.world.CreateJoint(jointDef)); Box2D.destroy(jointDef); }; Acts.prototype.SetWorldGravity = function (g) { if (g === this.behavior.worldG) return; this.world.SetGravity(getTempVec2a(0, g)); this.behavior.worldG = g; var i, len, arr = this.behavior.my_instances.valuesRef(); for (i = 0, len = arr.length; i < len; i++) { if (arr[i].extra.box2dbody) arr[i].extra.box2dbody.SetAwake(true); } }; Acts.prototype.SetSteppingMode = function (mode) { this.behavior.steppingMode = mode; }; Acts.prototype.SetIterations = function (vel, pos) { if (vel < 1) vel = 1; if (pos < 1) pos = 1; this.behavior.velocityIterations = vel; this.behavior.positionIterations = pos; }; Acts.prototype.SetVelocity = function (vx, vy) { if (!this.enabled) return; this.body.SetLinearVelocity(getTempVec2a(vx * worldScale, vy * worldScale)); this.body.SetAwake(true); this.lastTickOverride = false; this.lastKnownX = this.inst.x; this.lastKnownY = this.inst.y; }; Acts.prototype.SetDensity = function (d) { if (!this.enabled) return; if (this.density === d) return; this.density = d; this.fixture.SetDensity(d); this.body.ResetMassData(); }; Acts.prototype.SetFriction = function (f) { if (!this.enabled) return; if (this.friction === f) return; this.friction = f; this.fixture.SetFriction(f); var contactEdge, contact; for (contactEdge = this.body.GetContactList(); Box2D.getPointer(contactEdge); contactEdge = contactEdge.get_next()) { var contact = contactEdge.get_contact(); if (contact) contact.ResetFriction(); } }; Acts.prototype.SetElasticity = function (e) { if (!this.enabled) return; if (this.restitution === e) return; this.restitution = e; this.fixture.SetRestitution(e); }; Acts.prototype.SetLinearDamping = function (ld) { if (!this.enabled) return; if (this.linearDamping === ld) return; this.linearDamping = ld; this.body.SetLinearDamping(ld); }; Acts.prototype.SetAngularDamping = function (ad) { if (!this.enabled) return; if (this.angularDamping === ad) return; this.angularDamping = ad; this.body.SetAngularDamping(ad); }; Acts.prototype.SetImmovable = function (i) { if (!this.enabled) return; if (this.immovable === (i !== 0)) return; this.immovable = (i !== 0); this.body.SetType(this.immovable ? 0 /*b2BodyDef.b2_staticBody*/ : 2 /*b2BodyDef.b2_dynamicBody*/); this.body.SetAwake(true); }; function SetCollisionsEnabled(typeA, typeB, state) { var s; if (state) { s = typeA.extra["Physics_DisabledCollisions"]; if (s) s.remove(typeB); s = typeB.extra["Physics_DisabledCollisions"]; if (s) s.remove(typeA); } else { if (!typeA.extra["Physics_DisabledCollisions"]) typeA.extra["Physics_DisabledCollisions"] = new cr.ObjectSet(); typeA.extra["Physics_DisabledCollisions"].add(typeB); if (!typeB.extra["Physics_DisabledCollisions"]) typeB.extra["Physics_DisabledCollisions"] = new cr.ObjectSet(); typeB.extra["Physics_DisabledCollisions"].add(typeA); } }; Acts.prototype.EnableCollisions = function (obj, state) { if (!obj || !this.enabled) return; var i, len; if (obj.is_family) { for (i = 0, len = obj.members.length; i < len; i++) { SetCollisionsEnabled(this.inst.type, obj.members[i], state !== 0); } } else { SetCollisionsEnabled(this.inst.type, obj, state !== 0); } this.behavior.allCollisionsEnabled = false; }; Acts.prototype.SetPreventRotate = function (i) { if (!this.enabled) return; if (this.preventRotation === (i !== 0)) return; this.preventRotation = (i !== 0); this.body.SetFixedRotation(this.preventRotation); this.body.SetAngularVelocity(0); this.body.SetAwake(true); }; Acts.prototype.SetBullet = function (i) { if (!this.enabled) return; if (this.bullet === (i !== 0)) return; this.bullet = (i !== 0); this.body.SetBullet(this.bullet); this.body.SetAwake(true); }; Acts.prototype.RemoveJoints = function () { if (!this.enabled) return; this.destroyMyJoints(); cr.clearArray(this.myCreatedJoints); this.joiningMe.clear(); }; Acts.prototype.SetEnabled = function (e) { if (this.enabled && e === 0) { this.destroyBody(); this.enabled = false; } else if (!this.enabled && e === 1) { this.enabled = true; this.createBody(); } }; behaviorProto.acts = new Acts(); function Exps() {}; Exps.prototype.VelocityX = function (ret) { ret.set_float(this.enabled ? this.body.GetLinearVelocity().get_x() / worldScale : 0); }; Exps.prototype.VelocityY = function (ret) { ret.set_float(this.enabled ? this.body.GetLinearVelocity().get_y() / worldScale : 0); }; Exps.prototype.AngularVelocity = function (ret) { ret.set_float(this.enabled ? cr.to_degrees(this.body.GetAngularVelocity()) : 0); }; Exps.prototype.Mass = function (ret) { ret.set_float(this.enabled ? this.body.GetMass() / worldScale : 0); }; Exps.prototype.CenterOfMassX = function (ret) { ret.set_float(this.enabled ? (this.body.GetPosition().get_x() + this.body.GetLocalCenter().get_x()) / worldScale : 0); }; Exps.prototype.CenterOfMassY = function (ret) { ret.set_float(this.enabled ? (this.body.GetPosition().get_y() + this.body.GetLocalCenter().get_y()) / worldScale : 0); }; Exps.prototype.Density = function (ret) { ret.set_float(this.enabled ? this.density : 0); }; Exps.prototype.Friction = function (ret) { ret.set_float(this.enabled ? this.friction : 0); }; Exps.prototype.Elasticity = function (ret) { ret.set_float(this.enabled ? this.restitution : 0); }; Exps.prototype.LinearDamping = function (ret) { ret.set_float(this.enabled ? this.linearDamping : 0); }; Exps.prototype.AngularDamping = function (ret) { ret.set_float(this.enabled ? this.angularDamping : 0); }; behaviorProto.exps = new Exps(); }()); ; ; cr.behaviors.Pin = function(runtime) { this.runtime = runtime; }; (function () { var behaviorProto = cr.behaviors.Pin.prototype; behaviorProto.Type = function(behavior, objtype) { this.behavior = behavior; this.objtype = objtype; this.runtime = behavior.runtime; }; var behtypeProto = behaviorProto.Type.prototype; behtypeProto.onCreate = function() { }; behaviorProto.Instance = function(type, inst) { this.type = type; this.behavior = type.behavior; this.inst = inst; // associated object instance to modify this.runtime = type.runtime; }; var behinstProto = behaviorProto.Instance.prototype; behinstProto.onCreate = function() { this.pinObject = null; this.pinObjectUid = -1; // for loading this.pinAngle = 0; this.pinDist = 0; this.myStartAngle = 0; this.theirStartAngle = 0; this.lastKnownAngle = 0; this.mode = 0; // 0 = position & angle; 1 = position; 2 = angle; 3 = rope; 4 = bar var self = this; if (!this.recycled) { this.myDestroyCallback = (function(inst) { self.onInstanceDestroyed(inst); }); } this.runtime.addDestroyCallback(this.myDestroyCallback); }; behinstProto.saveToJSON = function () { return { "uid": this.pinObject ? this.pinObject.uid : -1, "pa": this.pinAngle, "pd": this.pinDist, "msa": this.myStartAngle, "tsa": this.theirStartAngle, "lka": this.lastKnownAngle, "m": this.mode }; }; behinstProto.loadFromJSON = function (o) { this.pinObjectUid = o["uid"]; // wait until afterLoad to look up this.pinAngle = o["pa"]; this.pinDist = o["pd"]; this.myStartAngle = o["msa"]; this.theirStartAngle = o["tsa"]; this.lastKnownAngle = o["lka"]; this.mode = o["m"]; }; behinstProto.afterLoad = function () { if (this.pinObjectUid === -1) this.pinObject = null; else { this.pinObject = this.runtime.getObjectByUID(this.pinObjectUid); ; } this.pinObjectUid = -1; }; behinstProto.onInstanceDestroyed = function (inst) { if (this.pinObject == inst) this.pinObject = null; }; behinstProto.onDestroy = function() { this.pinObject = null; this.runtime.removeDestroyCallback(this.myDestroyCallback); }; behinstProto.tick = function () { }; behinstProto.tick2 = function () { if (!this.pinObject) return; if (this.lastKnownAngle !== this.inst.angle) this.myStartAngle = cr.clamp_angle(this.myStartAngle + (this.inst.angle - this.lastKnownAngle)); var newx = this.inst.x; var newy = this.inst.y; if (this.mode === 3 || this.mode === 4) // rope mode or bar mode { var dist = cr.distanceTo(this.inst.x, this.inst.y, this.pinObject.x, this.pinObject.y); if ((dist > this.pinDist) || (this.mode === 4 && dist < this.pinDist)) { var a = cr.angleTo(this.pinObject.x, this.pinObject.y, this.inst.x, this.inst.y); newx = this.pinObject.x + Math.cos(a) * this.pinDist; newy = this.pinObject.y + Math.sin(a) * this.pinDist; } } else { newx = this.pinObject.x + Math.cos(this.pinObject.angle + this.pinAngle) * this.pinDist; newy = this.pinObject.y + Math.sin(this.pinObject.angle + this.pinAngle) * this.pinDist; } var newangle = cr.clamp_angle(this.myStartAngle + (this.pinObject.angle - this.theirStartAngle)); this.lastKnownAngle = newangle; if ((this.mode === 0 || this.mode === 1 || this.mode === 3 || this.mode === 4) && (this.inst.x !== newx || this.inst.y !== newy)) { this.inst.x = newx; this.inst.y = newy; this.inst.set_bbox_changed(); } if ((this.mode === 0 || this.mode === 2) && (this.inst.angle !== newangle)) { this.inst.angle = newangle; this.inst.set_bbox_changed(); } }; function Cnds() {}; Cnds.prototype.IsPinned = function () { return !!this.pinObject; }; behaviorProto.cnds = new Cnds(); function Acts() {}; Acts.prototype.Pin = function (obj, mode_) { if (!obj) return; var otherinst = obj.getFirstPicked(this.inst); if (!otherinst) return; this.pinObject = otherinst; this.pinAngle = cr.angleTo(otherinst.x, otherinst.y, this.inst.x, this.inst.y) - otherinst.angle; this.pinDist = cr.distanceTo(otherinst.x, otherinst.y, this.inst.x, this.inst.y); this.myStartAngle = this.inst.angle; this.lastKnownAngle = this.inst.angle; this.theirStartAngle = otherinst.angle; this.mode = mode_; }; Acts.prototype.Unpin = function () { this.pinObject = null; }; behaviorProto.acts = new Acts(); function Exps() {}; Exps.prototype.PinnedUID = function (ret) { ret.set_int(this.pinObject ? this.pinObject.uid : -1); }; behaviorProto.exps = new Exps(); }()); ; ; cr.behaviors.Platform = function(runtime) { this.runtime = runtime; }; (function () { var behaviorProto = cr.behaviors.Platform.prototype; behaviorProto.Type = function(behavior, objtype) { this.behavior = behavior; this.objtype = objtype; this.runtime = behavior.runtime; }; var behtypeProto = behaviorProto.Type.prototype; behtypeProto.onCreate = function() { }; var ANIMMODE_STOPPED = 0; var ANIMMODE_MOVING = 1; var ANIMMODE_JUMPING = 2; var ANIMMODE_FALLING = 3; behaviorProto.Instance = function(type, inst) { this.type = type; this.behavior = type.behavior; this.inst = inst; // associated object instance to modify this.runtime = type.runtime; this.leftkey = false; this.rightkey = false; this.jumpkey = false; this.jumped = false; // prevent bunnyhopping this.doubleJumped = false; this.canDoubleJump = false; this.ignoreInput = false; this.simleft = false; this.simright = false; this.simjump = false; this.lastFloorObject = null; this.loadFloorObject = -1; this.lastFloorX = 0; this.lastFloorY = 0; this.floorIsJumpthru = false; this.animMode = ANIMMODE_STOPPED; this.fallthrough = 0; // fall through jump-thru. >0 to disable, lasts a few ticks this.firstTick = true; this.dx = 0; this.dy = 0; }; var behinstProto = behaviorProto.Instance.prototype; behinstProto.updateGravity = function() { this.downx = Math.cos(this.ga); this.downy = Math.sin(this.ga); this.rightx = Math.cos(this.ga - Math.PI / 2); this.righty = Math.sin(this.ga - Math.PI / 2); this.downx = cr.round6dp(this.downx); this.downy = cr.round6dp(this.downy); this.rightx = cr.round6dp(this.rightx); this.righty = cr.round6dp(this.righty); this.g1 = this.g; if (this.g < 0) { this.downx *= -1; this.downy *= -1; this.g = Math.abs(this.g); } }; behinstProto.onCreate = function() { this.maxspeed = this.properties[0]; this.acc = this.properties[1]; this.dec = this.properties[2]; this.jumpStrength = this.properties[3]; this.g = this.properties[4]; this.g1 = this.g; this.maxFall = this.properties[5]; this.enableDoubleJump = (this.properties[6] !== 0); // 0=disabled, 1=enabled this.jumpSustain = (this.properties[7] / 1000); // convert ms to s this.defaultControls = (this.properties[8] === 1); // 0=no, 1=yes this.enabled = (this.properties[9] !== 0); this.wasOnFloor = false; this.wasOverJumpthru = this.runtime.testOverlapJumpThru(this.inst); this.loadOverJumpthru = -1; this.sustainTime = 0; // time of jump sustain remaining this.ga = cr.to_radians(90); this.updateGravity(); var self = this; if (this.defaultControls && !this.runtime.isDomFree) { jQuery(document).keydown(function(info) { self.onKeyDown(info); }); jQuery(document).keyup(function(info) { self.onKeyUp(info); }); } if (!this.recycled) { this.myDestroyCallback = function(inst) { self.onInstanceDestroyed(inst); }; } this.runtime.addDestroyCallback(this.myDestroyCallback); this.inst.extra["isPlatformBehavior"] = true; }; behinstProto.saveToJSON = function () { return { "ii": this.ignoreInput, "lfx": this.lastFloorX, "lfy": this.lastFloorY, "lfo": (this.lastFloorObject ? this.lastFloorObject.uid : -1), "am": this.animMode, "en": this.enabled, "fall": this.fallthrough, "ft": this.firstTick, "dx": this.dx, "dy": this.dy, "ms": this.maxspeed, "acc": this.acc, "dec": this.dec, "js": this.jumpStrength, "g": this.g, "g1": this.g1, "mf": this.maxFall, "wof": this.wasOnFloor, "woj": (this.wasOverJumpthru ? this.wasOverJumpthru.uid : -1), "ga": this.ga, "edj": this.enableDoubleJump, "cdj": this.canDoubleJump, "dj": this.doubleJumped, "sus": this.jumpSustain }; }; behinstProto.loadFromJSON = function (o) { this.ignoreInput = o["ii"]; this.lastFloorX = o["lfx"]; this.lastFloorY = o["lfy"]; this.loadFloorObject = o["lfo"]; this.animMode = o["am"]; this.enabled = o["en"]; this.fallthrough = o["fall"]; this.firstTick = o["ft"]; this.dx = o["dx"]; this.dy = o["dy"]; this.maxspeed = o["ms"]; this.acc = o["acc"]; this.dec = o["dec"]; this.jumpStrength = o["js"]; this.g = o["g"]; this.g1 = o["g1"]; this.maxFall = o["mf"]; this.wasOnFloor = o["wof"]; this.loadOverJumpthru = o["woj"]; this.ga = o["ga"]; this.enableDoubleJump = o["edj"]; this.canDoubleJump = o["cdj"]; this.doubleJumped = o["dj"]; this.jumpSustain = o["sus"]; this.leftkey = false; this.rightkey = false; this.jumpkey = false; this.jumped = false; this.simleft = false; this.simright = false; this.simjump = false; this.sustainTime = 0; this.updateGravity(); }; behinstProto.afterLoad = function () { if (this.loadFloorObject === -1) this.lastFloorObject = null; else this.lastFloorObject = this.runtime.getObjectByUID(this.loadFloorObject); if (this.loadOverJumpthru === -1) this.wasOverJumpthru = null; else this.wasOverJumpthru = this.runtime.getObjectByUID(this.loadOverJumpthru); }; behinstProto.onInstanceDestroyed = function (inst) { if (this.lastFloorObject == inst) this.lastFloorObject = null; }; behinstProto.onDestroy = function () { this.lastFloorObject = null; this.runtime.removeDestroyCallback(this.myDestroyCallback); }; behinstProto.onKeyDown = function (info) { switch (info.which) { case 38: // up info.preventDefault(); this.jumpkey = true; break; case 37: // left info.preventDefault(); this.leftkey = true; break; case 39: // right info.preventDefault(); this.rightkey = true; break; } }; behinstProto.onKeyUp = function (info) { switch (info.which) { case 38: // up info.preventDefault(); this.jumpkey = false; this.jumped = false; break; case 37: // left info.preventDefault(); this.leftkey = false; break; case 39: // right info.preventDefault(); this.rightkey = false; break; } }; behinstProto.onWindowBlur = function () { this.leftkey = false; this.rightkey = false; this.jumpkey = false; }; behinstProto.getGDir = function () { if (this.g < 0) return -1; else return 1; }; behinstProto.isOnFloor = function () { var ret = null; var ret2 = null; var i, len, j; var oldx = this.inst.x; var oldy = this.inst.y; this.inst.x += this.downx; this.inst.y += this.downy; this.inst.set_bbox_changed(); if (this.lastFloorObject && this.runtime.testOverlap(this.inst, this.lastFloorObject) && (!this.runtime.typeHasBehavior(this.lastFloorObject.type, cr.behaviors.solid) || this.lastFloorObject.extra["solidEnabled"])) { this.inst.x = oldx; this.inst.y = oldy; this.inst.set_bbox_changed(); return this.lastFloorObject; } else { ret = this.runtime.testOverlapSolid(this.inst); if (!ret && this.fallthrough === 0) ret2 = this.runtime.testOverlapJumpThru(this.inst, true); this.inst.x = oldx; this.inst.y = oldy; this.inst.set_bbox_changed(); if (ret) // was overlapping solid { if (this.runtime.testOverlap(this.inst, ret)) return null; else { this.floorIsJumpthru = false; return ret; } } if (ret2 && ret2.length) { for (i = 0, j = 0, len = ret2.length; i < len; i++) { ret2[j] = ret2[i]; if (!this.runtime.testOverlap(this.inst, ret2[i])) j++; } if (j >= 1) { this.floorIsJumpthru = true; return ret2[0]; } } return null; } }; behinstProto.tick = function () { }; behinstProto.posttick = function () { var dt = this.runtime.getDt(this.inst); var mx, my, obstacle, mag, allover, i, len, j, oldx, oldy; if (!this.jumpkey && !this.simjump) this.jumped = false; var left = this.leftkey || this.simleft; var right = this.rightkey || this.simright; var jumpkey = (this.jumpkey || this.simjump); var jump = jumpkey && !this.jumped; this.simleft = false; this.simright = false; this.simjump = false; if (!this.enabled) return; if (this.ignoreInput) { left = false; right = false; jumpkey = false; jump = false; } if (!jumpkey) this.sustainTime = 0; var lastFloor = this.lastFloorObject; var floor_moved = false; if (this.firstTick) { if (this.runtime.testOverlapSolid(this.inst) || this.runtime.testOverlapJumpThru(this.inst)) { this.runtime.pushOutSolid(this.inst, -this.downx, -this.downy, 4, true); } this.firstTick = false; } if (lastFloor && this.dy === 0 && (lastFloor.y !== this.lastFloorY || lastFloor.x !== this.lastFloorX)) { mx = (lastFloor.x - this.lastFloorX); my = (lastFloor.y - this.lastFloorY); this.inst.x += mx; this.inst.y += my; this.inst.set_bbox_changed(); this.lastFloorX = lastFloor.x; this.lastFloorY = lastFloor.y; floor_moved = true; if (this.runtime.testOverlapSolid(this.inst)) { this.runtime.pushOutSolid(this.inst, -mx, -my, Math.sqrt(mx * mx + my * my) * 2.5); } } var floor_ = this.isOnFloor(); var collobj = this.runtime.testOverlapSolid(this.inst); if (collobj) { if (this.inst.extra["inputPredicted"]) { this.runtime.pushOutSolid(this.inst, -this.downx, -this.downy, 10, false); } else if (this.runtime.pushOutSolidNearest(this.inst, Math.max(this.inst.width, this.inst.height) / 2)) { this.runtime.registerCollision(this.inst, collobj); } else return; } if (floor_) { this.doubleJumped = false; // reset double jump flags for next jump this.canDoubleJump = false; if (this.dy > 0) { if (!this.wasOnFloor) { this.runtime.pushInFractional(this.inst, -this.downx, -this.downy, floor_, 16); this.wasOnFloor = true; } this.dy = 0; } if (lastFloor != floor_) { this.lastFloorObject = floor_; this.lastFloorX = floor_.x; this.lastFloorY = floor_.y; this.runtime.registerCollision(this.inst, floor_); } else if (floor_moved) { collobj = this.runtime.testOverlapSolid(this.inst); if (collobj) { this.runtime.registerCollision(this.inst, collobj); if (mx !== 0) { if (mx > 0) this.runtime.pushOutSolid(this.inst, -this.rightx, -this.righty); else this.runtime.pushOutSolid(this.inst, this.rightx, this.righty); } this.runtime.pushOutSolid(this.inst, -this.downx, -this.downy); } } } else { if (!jumpkey) this.canDoubleJump = true; } if ((floor_ && jump) || (!floor_ && this.enableDoubleJump && jumpkey && this.canDoubleJump && !this.doubleJumped)) { oldx = this.inst.x; oldy = this.inst.y; this.inst.x -= this.downx; this.inst.y -= this.downy; this.inst.set_bbox_changed(); if (!this.runtime.testOverlapSolid(this.inst)) { this.sustainTime = this.jumpSustain; this.runtime.trigger(cr.behaviors.Platform.prototype.cnds.OnJump, this.inst); this.animMode = ANIMMODE_JUMPING; this.dy = -this.jumpStrength; jump = true; // set in case is double jump if (floor_) this.jumped = true; else this.doubleJumped = true; } else jump = false; this.inst.x = oldx; this.inst.y = oldy; this.inst.set_bbox_changed(); } if (!floor_) { if (jumpkey && this.sustainTime > 0) { this.dy = -this.jumpStrength; this.sustainTime -= dt; } else { this.lastFloorObject = null; this.dy += this.g * dt; if (this.dy > this.maxFall) this.dy = this.maxFall; } if (jump) this.jumped = true; } this.wasOnFloor = !!floor_; if (left == right) // both up or both down { if (this.dx < 0) { this.dx += this.dec * dt; if (this.dx > 0) this.dx = 0; } else if (this.dx > 0) { this.dx -= this.dec * dt; if (this.dx < 0) this.dx = 0; } } if (left && !right) { if (this.dx > 0) this.dx -= (this.acc + this.dec) * dt; else this.dx -= this.acc * dt; } if (right && !left) { if (this.dx < 0) this.dx += (this.acc + this.dec) * dt; else this.dx += this.acc * dt; } if (this.dx > this.maxspeed) this.dx = this.maxspeed; else if (this.dx < -this.maxspeed) this.dx = -this.maxspeed; var landed = false; if (this.dx !== 0) { oldx = this.inst.x; oldy = this.inst.y; mx = this.dx * dt * this.rightx; my = this.dx * dt * this.righty; this.inst.x += this.rightx * (this.dx > 1 ? 1 : -1) - this.downx; this.inst.y += this.righty * (this.dx > 1 ? 1 : -1) - this.downy; this.inst.set_bbox_changed(); var is_jumpthru = false; var slope_too_steep = this.runtime.testOverlapSolid(this.inst); /* if (!slope_too_steep && floor_) { slope_too_steep = this.runtime.testOverlapJumpThru(this.inst); is_jumpthru = true; if (slope_too_steep) { this.inst.x = oldx; this.inst.y = oldy; this.inst.set_bbox_changed(); if (this.runtime.testOverlap(this.inst, slope_too_steep)) { slope_too_steep = null; is_jumpthru = false; } } } */ this.inst.x = oldx + mx; this.inst.y = oldy + my; this.inst.set_bbox_changed(); obstacle = this.runtime.testOverlapSolid(this.inst); if (!obstacle && floor_) { obstacle = this.runtime.testOverlapJumpThru(this.inst); if (obstacle) { this.inst.x = oldx; this.inst.y = oldy; this.inst.set_bbox_changed(); if (this.runtime.testOverlap(this.inst, obstacle)) { obstacle = null; is_jumpthru = false; } else is_jumpthru = true; this.inst.x = oldx + mx; this.inst.y = oldy + my; this.inst.set_bbox_changed(); } } if (obstacle) { var push_dist = Math.abs(this.dx * dt) + 2; if (slope_too_steep || !this.runtime.pushOutSolid(this.inst, -this.downx, -this.downy, push_dist, is_jumpthru, obstacle)) { this.runtime.registerCollision(this.inst, obstacle); push_dist = Math.max(Math.abs(this.dx * dt * 2.5), 30); if (!this.runtime.pushOutSolid(this.inst, this.rightx * (this.dx < 0 ? 1 : -1), this.righty * (this.dx < 0 ? 1 : -1), push_dist, false)) { this.inst.x = oldx; this.inst.y = oldy; this.inst.set_bbox_changed(); } else if (floor_ && !is_jumpthru && !this.floorIsJumpthru) { oldx = this.inst.x; oldy = this.inst.y; this.inst.x += this.downx; this.inst.y += this.downy; if (this.runtime.testOverlapSolid(this.inst)) { if (!this.runtime.pushOutSolid(this.inst, -this.downx, -this.downy, 3, false)) { this.inst.x = oldx; this.inst.y = oldy; this.inst.set_bbox_changed(); } } else { this.inst.x = oldx; this.inst.y = oldy; this.inst.set_bbox_changed(); } } if (!is_jumpthru) this.dx = 0; // stop } else if (!slope_too_steep && !jump && (Math.abs(this.dy) < Math.abs(this.jumpStrength / 4))) { this.dy = 0; if (!floor_) landed = true; } } else { var newfloor = this.isOnFloor(); if (floor_ && !newfloor) { mag = Math.ceil(Math.abs(this.dx * dt)) + 2; oldx = this.inst.x; oldy = this.inst.y; this.inst.x += this.downx * mag; this.inst.y += this.downy * mag; this.inst.set_bbox_changed(); if (this.runtime.testOverlapSolid(this.inst) || this.runtime.testOverlapJumpThru(this.inst)) this.runtime.pushOutSolid(this.inst, -this.downx, -this.downy, mag + 2, true); else { this.inst.x = oldx; this.inst.y = oldy; this.inst.set_bbox_changed(); } } else if (newfloor && this.dy === 0) { this.runtime.pushInFractional(this.inst, -this.downx, -this.downy, newfloor, 16); } } } if (this.dy !== 0) { oldx = this.inst.x; oldy = this.inst.y; this.inst.x += this.dy * dt * this.downx; this.inst.y += this.dy * dt * this.downy; var newx = this.inst.x; var newy = this.inst.y; this.inst.set_bbox_changed(); collobj = this.runtime.testOverlapSolid(this.inst); var fell_on_jumpthru = false; if (!collobj && (this.dy > 0) && !floor_) { allover = this.fallthrough > 0 ? null : this.runtime.testOverlapJumpThru(this.inst, true); if (allover && allover.length) { if (this.wasOverJumpthru) { this.inst.x = oldx; this.inst.y = oldy; this.inst.set_bbox_changed(); for (i = 0, j = 0, len = allover.length; i < len; i++) { allover[j] = allover[i]; if (!this.runtime.testOverlap(this.inst, allover[i])) j++; } allover.length = j; this.inst.x = newx; this.inst.y = newy; this.inst.set_bbox_changed(); } if (allover.length >= 1) collobj = allover[0]; } fell_on_jumpthru = !!collobj; } if (collobj) { this.runtime.registerCollision(this.inst, collobj); this.sustainTime = 0; var push_dist = (fell_on_jumpthru ? Math.abs(this.dy * dt * 2.5 + 10) : Math.max(Math.abs(this.dy * dt * 2.5 + 10), 30)); if (!this.runtime.pushOutSolid(this.inst, this.downx * (this.dy < 0 ? 1 : -1), this.downy * (this.dy < 0 ? 1 : -1), push_dist, fell_on_jumpthru, collobj)) { this.inst.x = oldx; this.inst.y = oldy; this.inst.set_bbox_changed(); this.wasOnFloor = true; // prevent adjustment for unexpected floor landings if (!fell_on_jumpthru) this.dy = 0; // stop } else { this.lastFloorObject = collobj; this.lastFloorX = collobj.x; this.lastFloorY = collobj.y; this.floorIsJumpthru = fell_on_jumpthru; if (fell_on_jumpthru) landed = true; this.dy = 0; // stop } } } if (this.animMode !== ANIMMODE_FALLING && this.dy > 0 && !floor_) { this.runtime.trigger(cr.behaviors.Platform.prototype.cnds.OnFall, this.inst); this.animMode = ANIMMODE_FALLING; } if (floor_ || landed) { if (this.animMode === ANIMMODE_FALLING || landed || (jump && this.dy === 0)) { this.runtime.trigger(cr.behaviors.Platform.prototype.cnds.OnLand, this.inst); if (this.dx === 0 && this.dy === 0) this.animMode = ANIMMODE_STOPPED; else this.animMode = ANIMMODE_MOVING; } else { if (this.animMode !== ANIMMODE_STOPPED && this.dx === 0 && this.dy === 0) { this.runtime.trigger(cr.behaviors.Platform.prototype.cnds.OnStop, this.inst); this.animMode = ANIMMODE_STOPPED; } if (this.animMode !== ANIMMODE_MOVING && (this.dx !== 0 || this.dy !== 0) && !jump) { this.runtime.trigger(cr.behaviors.Platform.prototype.cnds.OnMove, this.inst); this.animMode = ANIMMODE_MOVING; } } } if (this.fallthrough > 0) this.fallthrough--; this.wasOverJumpthru = this.runtime.testOverlapJumpThru(this.inst); }; function Cnds() {}; Cnds.prototype.IsMoving = function () { return this.dx !== 0 || this.dy !== 0; }; Cnds.prototype.CompareSpeed = function (cmp, s) { var speed = Math.sqrt(this.dx * this.dx + this.dy * this.dy); return cr.do_cmp(speed, cmp, s); }; Cnds.prototype.IsOnFloor = function () { if (this.dy !== 0) return false; var ret = null; var ret2 = null; var i, len, j; var oldx = this.inst.x; var oldy = this.inst.y; this.inst.x += this.downx; this.inst.y += this.downy; this.inst.set_bbox_changed(); ret = this.runtime.testOverlapSolid(this.inst); if (!ret && this.fallthrough === 0) ret2 = this.runtime.testOverlapJumpThru(this.inst, true); this.inst.x = oldx; this.inst.y = oldy; this.inst.set_bbox_changed(); if (ret) // was overlapping solid { return !this.runtime.testOverlap(this.inst, ret); } if (ret2 && ret2.length) { for (i = 0, j = 0, len = ret2.length; i < len; i++) { ret2[j] = ret2[i]; if (!this.runtime.testOverlap(this.inst, ret2[i])) j++; } if (j >= 1) return true; } return false; }; Cnds.prototype.IsByWall = function (side) { var ret = false; var oldx = this.inst.x; var oldy = this.inst.y; if (side === 0) // left { this.inst.x -= this.rightx * 2; this.inst.y -= this.righty * 2; } else { this.inst.x += this.rightx * 2; this.inst.y += this.righty * 2; } this.inst.set_bbox_changed(); if (!this.runtime.testOverlapSolid(this.inst)) { this.inst.x = oldx; this.inst.y = oldy; this.inst.set_bbox_changed(); return false; } this.inst.x -= this.downx * 3; this.inst.y -= this.downy * 3; this.inst.set_bbox_changed(); ret = this.runtime.testOverlapSolid(this.inst); this.inst.x = oldx; this.inst.y = oldy; this.inst.set_bbox_changed(); return ret; }; Cnds.prototype.IsJumping = function () { return this.dy < 0; }; Cnds.prototype.IsFalling = function () { return this.dy > 0; }; Cnds.prototype.OnJump = function () { return true; }; Cnds.prototype.OnFall = function () { return true; }; Cnds.prototype.OnStop = function () { return true; }; Cnds.prototype.OnMove = function () { return true; }; Cnds.prototype.OnLand = function () { return true; }; Cnds.prototype.IsDoubleJumpEnabled = function () { return this.enableDoubleJump; }; behaviorProto.cnds = new Cnds(); function Acts() {}; Acts.prototype.SetIgnoreInput = function (ignoring) { this.ignoreInput = ignoring; }; Acts.prototype.SetMaxSpeed = function (maxspeed) { this.maxspeed = maxspeed; if (this.maxspeed < 0) this.maxspeed = 0; }; Acts.prototype.SetAcceleration = function (acc) { this.acc = acc; if (this.acc < 0) this.acc = 0; }; Acts.prototype.SetDeceleration = function (dec) { this.dec = dec; if (this.dec < 0) this.dec = 0; }; Acts.prototype.SetJumpStrength = function (js) { this.jumpStrength = js; if (this.jumpStrength < 0) this.jumpStrength = 0; }; Acts.prototype.SetGravity = function (grav) { if (this.g1 === grav) return; // no change this.g = grav; this.updateGravity(); if (this.runtime.testOverlapSolid(this.inst)) { this.runtime.pushOutSolid(this.inst, this.downx, this.downy, 10); this.inst.x += this.downx * 2; this.inst.y += this.downy * 2; this.inst.set_bbox_changed(); } this.lastFloorObject = null; }; Acts.prototype.SetMaxFallSpeed = function (mfs) { this.maxFall = mfs; if (this.maxFall < 0) this.maxFall = 0; }; Acts.prototype.SimulateControl = function (ctrl) { switch (ctrl) { case 0: this.simleft = true; break; case 1: this.simright = true; break; case 2: this.simjump = true; break; } }; Acts.prototype.SetVectorX = function (vx) { this.dx = vx; }; Acts.prototype.SetVectorY = function (vy) { this.dy = vy; }; Acts.prototype.SetGravityAngle = function (a) { a = cr.to_radians(a); a = cr.clamp_angle(a); if (this.ga === a) return; // no change this.ga = a; this.updateGravity(); this.lastFloorObject = null; }; Acts.prototype.SetEnabled = function (en) { if (this.enabled !== (en === 1)) { this.enabled = (en === 1); if (!this.enabled) this.lastFloorObject = null; } }; Acts.prototype.FallThrough = function () { var oldx = this.inst.x; var oldy = this.inst.y; this.inst.x += this.downx; this.inst.y += this.downy; this.inst.set_bbox_changed(); var overlaps = this.runtime.testOverlapJumpThru(this.inst, false); this.inst.x = oldx; this.inst.y = oldy; this.inst.set_bbox_changed(); if (!overlaps) return; this.fallthrough = 3; // disable jumpthrus for 3 ticks (1 doesn't do it, 2 does, 3 to be on safe side) this.lastFloorObject = null; }; Acts.prototype.SetDoubleJumpEnabled = function (e) { this.enableDoubleJump = (e !== 0); }; Acts.prototype.SetJumpSustain = function (s) { this.jumpSustain = s / 1000; // convert to ms }; behaviorProto.acts = new Acts(); function Exps() {}; Exps.prototype.Speed = function (ret) { ret.set_float(Math.sqrt(this.dx * this.dx + this.dy * this.dy)); }; Exps.prototype.MaxSpeed = function (ret) { ret.set_float(this.maxspeed); }; Exps.prototype.Acceleration = function (ret) { ret.set_float(this.acc); }; Exps.prototype.Deceleration = function (ret) { ret.set_float(this.dec); }; Exps.prototype.JumpStrength = function (ret) { ret.set_float(this.jumpStrength); }; Exps.prototype.Gravity = function (ret) { ret.set_float(this.g); }; Exps.prototype.GravityAngle = function (ret) { ret.set_float(cr.to_degrees(this.ga)); }; Exps.prototype.MaxFallSpeed = function (ret) { ret.set_float(this.maxFall); }; Exps.prototype.MovingAngle = function (ret) { ret.set_float(cr.to_degrees(Math.atan2(this.dy, this.dx))); }; Exps.prototype.VectorX = function (ret) { ret.set_float(this.dx); }; Exps.prototype.VectorY = function (ret) { ret.set_float(this.dy); }; Exps.prototype.JumpSustain = function (ret) { ret.set_float(this.jumpSustain * 1000); // convert back to ms }; behaviorProto.exps = new Exps(); }()); ; ; cr.behaviors.Rotate = function(runtime) { this.runtime = runtime; }; (function () { var behaviorProto = cr.behaviors.Rotate.prototype; behaviorProto.Type = function(behavior, objtype) { this.behavior = behavior; this.objtype = objtype; this.runtime = behavior.runtime; }; var behtypeProto = behaviorProto.Type.prototype; behtypeProto.onCreate = function() { }; behaviorProto.Instance = function(type, inst) { this.type = type; this.behavior = type.behavior; this.inst = inst; // associated object instance to modify this.runtime = type.runtime; }; var behinstProto = behaviorProto.Instance.prototype; behinstProto.onCreate = function() { this.speed = cr.to_radians(this.properties[0]); this.acc = cr.to_radians(this.properties[1]); }; behinstProto.saveToJSON = function () { return { "speed": this.speed, "acc": this.acc }; }; behinstProto.loadFromJSON = function (o) { this.speed = o["speed"]; this.acc = o["acc"]; }; behinstProto.tick = function () { var dt = this.runtime.getDt(this.inst); if (dt === 0) return; if (this.acc !== 0) this.speed += this.acc * dt; if (this.speed !== 0) { this.inst.angle = cr.clamp_angle(this.inst.angle + this.speed * dt); this.inst.set_bbox_changed(); } }; function Cnds() {}; behaviorProto.cnds = new Cnds(); function Acts() {}; Acts.prototype.SetSpeed = function (s) { this.speed = cr.to_radians(s); }; Acts.prototype.SetAcceleration = function (a) { this.acc = cr.to_radians(a); }; behaviorProto.acts = new Acts(); function Exps() {}; Exps.prototype.Speed = function (ret) { ret.set_float(cr.to_degrees(this.speed)); }; Exps.prototype.Acceleration = function (ret) { ret.set_float(cr.to_degrees(this.acc)); }; behaviorProto.exps = new Exps(); }()); ; ; cr.behaviors.Sin = function(runtime) { this.runtime = runtime; }; (function () { var behaviorProto = cr.behaviors.Sin.prototype; behaviorProto.Type = function(behavior, objtype) { this.behavior = behavior; this.objtype = objtype; this.runtime = behavior.runtime; }; var behtypeProto = behaviorProto.Type.prototype; behtypeProto.onCreate = function() { }; behaviorProto.Instance = function(type, inst) { this.type = type; this.behavior = type.behavior; this.inst = inst; // associated object instance to modify this.runtime = type.runtime; this.i = 0; // period offset (radians) }; var behinstProto = behaviorProto.Instance.prototype; var _2pi = 2 * Math.PI; var _pi_2 = Math.PI / 2; var _3pi_2 = (3 * Math.PI) / 2; behinstProto.onCreate = function() { this.active = (this.properties[0] === 1); this.movement = this.properties[1]; // 0=Horizontal|1=Vertical|2=Size|3=Width|4=Height|5=Angle|6=Opacity|7=Value only this.wave = this.properties[2]; // 0=Sine|1=Triangle|2=Sawtooth|3=Reverse sawtooth|4=Square this.period = this.properties[3]; this.period += Math.random() * this.properties[4]; // period random if (this.period === 0) this.i = 0; else { this.i = (this.properties[5] / this.period) * _2pi; // period offset this.i += ((Math.random() * this.properties[6]) / this.period) * _2pi; // period offset random } this.mag = this.properties[7]; // magnitude this.mag += Math.random() * this.properties[8]; // magnitude random this.initialValue = 0; this.initialValue2 = 0; this.ratio = 0; if (this.movement === 5) // angle this.mag = cr.to_radians(this.mag); this.init(); }; behinstProto.saveToJSON = function () { return { "i": this.i, "a": this.active, "mv": this.movement, "w": this.wave, "p": this.period, "mag": this.mag, "iv": this.initialValue, "iv2": this.initialValue2, "r": this.ratio, "lkv": this.lastKnownValue, "lkv2": this.lastKnownValue2 }; }; behinstProto.loadFromJSON = function (o) { this.i = o["i"]; this.active = o["a"]; this.movement = o["mv"]; this.wave = o["w"]; this.period = o["p"]; this.mag = o["mag"]; this.initialValue = o["iv"]; this.initialValue2 = o["iv2"] || 0; this.ratio = o["r"]; this.lastKnownValue = o["lkv"]; this.lastKnownValue2 = o["lkv2"] || 0; }; behinstProto.init = function () { switch (this.movement) { case 0: // horizontal this.initialValue = this.inst.x; break; case 1: // vertical this.initialValue = this.inst.y; break; case 2: // size this.initialValue = this.inst.width; this.ratio = this.inst.height / this.inst.width; break; case 3: // width this.initialValue = this.inst.width; break; case 4: // height this.initialValue = this.inst.height; break; case 5: // angle this.initialValue = this.inst.angle; break; case 6: // opacity this.initialValue = this.inst.opacity; break; case 7: this.initialValue = 0; break; case 8: // forwards/backwards this.initialValue = this.inst.x; this.initialValue2 = this.inst.y; break; default: ; } this.lastKnownValue = this.initialValue; this.lastKnownValue2 = this.initialValue2; }; behinstProto.waveFunc = function (x) { x = x % _2pi; switch (this.wave) { case 0: // sine return Math.sin(x); case 1: // triangle if (x <= _pi_2) return x / _pi_2; else if (x <= _3pi_2) return 1 - (2 * (x - _pi_2) / Math.PI); else return (x - _3pi_2) / _pi_2 - 1; case 2: // sawtooth return 2 * x / _2pi - 1; case 3: // reverse sawtooth return -2 * x / _2pi + 1; case 4: // square return x < Math.PI ? -1 : 1; }; return 0; }; behinstProto.tick = function () { var dt = this.runtime.getDt(this.inst); if (!this.active || dt === 0) return; if (this.period === 0) this.i = 0; else { this.i += (dt / this.period) * _2pi; this.i = this.i % _2pi; } this.updateFromPhase(); }; behinstProto.updateFromPhase = function () { switch (this.movement) { case 0: // horizontal if (this.inst.x !== this.lastKnownValue) this.initialValue += this.inst.x - this.lastKnownValue; this.inst.x = this.initialValue + this.waveFunc(this.i) * this.mag; this.lastKnownValue = this.inst.x; break; case 1: // vertical if (this.inst.y !== this.lastKnownValue) this.initialValue += this.inst.y - this.lastKnownValue; this.inst.y = this.initialValue + this.waveFunc(this.i) * this.mag; this.lastKnownValue = this.inst.y; break; case 2: // size this.inst.width = this.initialValue + this.waveFunc(this.i) * this.mag; this.inst.height = this.inst.width * this.ratio; break; case 3: // width this.inst.width = this.initialValue + this.waveFunc(this.i) * this.mag; break; case 4: // height this.inst.height = this.initialValue + this.waveFunc(this.i) * this.mag; break; case 5: // angle if (this.inst.angle !== this.lastKnownValue) this.initialValue = cr.clamp_angle(this.initialValue + (this.inst.angle - this.lastKnownValue)); this.inst.angle = cr.clamp_angle(this.initialValue + this.waveFunc(this.i) * this.mag); this.lastKnownValue = this.inst.angle; break; case 6: // opacity this.inst.opacity = this.initialValue + (this.waveFunc(this.i) * this.mag) / 100; if (this.inst.opacity < 0) this.inst.opacity = 0; else if (this.inst.opacity > 1) this.inst.opacity = 1; break; case 8: // forwards/backwards if (this.inst.x !== this.lastKnownValue) this.initialValue += this.inst.x - this.lastKnownValue; if (this.inst.y !== this.lastKnownValue2) this.initialValue2 += this.inst.y - this.lastKnownValue2; this.inst.x = this.initialValue + Math.cos(this.inst.angle) * this.waveFunc(this.i) * this.mag; this.inst.y = this.initialValue2 + Math.sin(this.inst.angle) * this.waveFunc(this.i) * this.mag; this.lastKnownValue = this.inst.x; this.lastKnownValue2 = this.inst.y; break; } this.inst.set_bbox_changed(); }; behinstProto.onSpriteFrameChanged = function (prev_frame, next_frame) { switch (this.movement) { case 2: // size this.initialValue *= (next_frame.width / prev_frame.width); this.ratio = next_frame.height / next_frame.width; break; case 3: // width this.initialValue *= (next_frame.width / prev_frame.width); break; case 4: // height this.initialValue *= (next_frame.height / prev_frame.height); break; } }; function Cnds() {}; Cnds.prototype.IsActive = function () { return this.active; }; Cnds.prototype.CompareMovement = function (m) { return this.movement === m; }; Cnds.prototype.ComparePeriod = function (cmp, v) { return cr.do_cmp(this.period, cmp, v); }; Cnds.prototype.CompareMagnitude = function (cmp, v) { if (this.movement === 5) return cr.do_cmp(this.mag, cmp, cr.to_radians(v)); else return cr.do_cmp(this.mag, cmp, v); }; Cnds.prototype.CompareWave = function (w) { return this.wave === w; }; behaviorProto.cnds = new Cnds(); function Acts() {}; Acts.prototype.SetActive = function (a) { this.active = (a === 1); }; Acts.prototype.SetPeriod = function (x) { this.period = x; }; Acts.prototype.SetMagnitude = function (x) { this.mag = x; if (this.movement === 5) // angle this.mag = cr.to_radians(this.mag); }; Acts.prototype.SetMovement = function (m) { if (this.movement === 5 && m !== 5) this.mag = cr.to_degrees(this.mag); this.movement = m; this.init(); }; Acts.prototype.SetWave = function (w) { this.wave = w; }; Acts.prototype.SetPhase = function (x) { this.i = (x * _2pi) % _2pi; this.updateFromPhase(); }; Acts.prototype.UpdateInitialState = function () { this.init(); }; behaviorProto.acts = new Acts(); function Exps() {}; Exps.prototype.CyclePosition = function (ret) { ret.set_float(this.i / _2pi); }; Exps.prototype.Period = function (ret) { ret.set_float(this.period); }; Exps.prototype.Magnitude = function (ret) { if (this.movement === 5) // angle ret.set_float(cr.to_degrees(this.mag)); else ret.set_float(this.mag); }; Exps.prototype.Value = function (ret) { ret.set_float(this.waveFunc(this.i) * this.mag); }; behaviorProto.exps = new Exps(); }()); ; ; cr.behaviors.Timer = function(runtime) { this.runtime = runtime; }; (function () { var behaviorProto = cr.behaviors.Timer.prototype; behaviorProto.Type = function(behavior, objtype) { this.behavior = behavior; this.objtype = objtype; this.runtime = behavior.runtime; }; var behtypeProto = behaviorProto.Type.prototype; behtypeProto.onCreate = function() { }; behaviorProto.Instance = function(type, inst) { this.type = type; this.behavior = type.behavior; this.inst = inst; // associated object instance to modify this.runtime = type.runtime; }; var behinstProto = behaviorProto.Instance.prototype; behinstProto.onCreate = function() { this.timers = {}; }; behinstProto.onDestroy = function () { cr.wipe(this.timers); }; behinstProto.saveToJSON = function () { var o = {}; var p, t; for (p in this.timers) { if (this.timers.hasOwnProperty(p)) { t = this.timers[p]; o[p] = { "c": t.current.sum, "t": t.total.sum, "d": t.duration, "r": t.regular }; } } return o; }; behinstProto.loadFromJSON = function (o) { this.timers = {}; var p; for (p in o) { if (o.hasOwnProperty(p)) { this.timers[p] = { current: new cr.KahanAdder(), total: new cr.KahanAdder(), duration: o[p]["d"], regular: o[p]["r"] }; this.timers[p].current.sum = o[p]["c"]; this.timers[p].total.sum = o[p]["t"]; } } }; behinstProto.tick = function () { var dt = this.runtime.getDt(this.inst); var p, t; for (p in this.timers) { if (this.timers.hasOwnProperty(p)) { t = this.timers[p]; t.current.add(dt); t.total.add(dt); } } }; behinstProto.tick2 = function () { var p, t; for (p in this.timers) { if (this.timers.hasOwnProperty(p)) { t = this.timers[p]; if (t.current.sum >= t.duration) { if (t.regular) t.current.sum -= t.duration; else delete this.timers[p]; } } } }; function Cnds() {}; Cnds.prototype.OnTimer = function (tag_) { tag_ = tag_.toLowerCase(); var t = this.timers[tag_]; if (!t) return false; return t.current.sum >= t.duration; }; behaviorProto.cnds = new Cnds(); function Acts() {}; Acts.prototype.StartTimer = function (duration_, type_, tag_) { this.timers[tag_.toLowerCase()] = { current: new cr.KahanAdder(), total: new cr.KahanAdder(), duration: duration_, regular: (type_ === 1) }; }; Acts.prototype.StopTimer = function (tag_) { tag_ = tag_.toLowerCase(); if (this.timers.hasOwnProperty(tag_)) delete this.timers[tag_]; }; behaviorProto.acts = new Acts(); function Exps() {}; Exps.prototype.CurrentTime = function (ret, tag_) { var t = this.timers[tag_.toLowerCase()]; ret.set_float(t ? t.current.sum : 0); }; Exps.prototype.TotalTime = function (ret, tag_) { var t = this.timers[tag_.toLowerCase()]; ret.set_float(t ? t.total.sum : 0); }; Exps.prototype.Duration = function (ret, tag_) { var t = this.timers[tag_.toLowerCase()]; ret.set_float(t ? t.duration : 0); }; behaviorProto.exps = new Exps(); }()); ; ; cr.behaviors.Turret = function(runtime) { this.runtime = runtime; }; (function () { var behaviorProto = cr.behaviors.Turret.prototype; behaviorProto.Type = function(behavior, objtype) { this.behavior = behavior; this.objtype = objtype; this.runtime = behavior.runtime; }; var behtypeProto = behaviorProto.Type.prototype; behtypeProto.onCreate = function() { this.targetTypes = []; // object types to check for as targets }; behaviorProto.Instance = function(type, inst) { this.type = type; this.behavior = type.behavior; this.inst = inst; // associated object instance to modify this.runtime = type.runtime; }; var behinstProto = behaviorProto.Instance.prototype; behinstProto.onCreate = function() { this.range = this.properties[0]; this.rateOfFire = this.properties[1]; this.rotateEnabled = (this.properties[2] !== 0); this.rotateSpeed = cr.to_radians(this.properties[3]); this.targetMode = this.properties[4]; // 0 = first, 1 = nearest this.predictiveAim = (this.properties[5] !== 0); this.projectileSpeed = this.properties[6]; this.enabled = (this.properties[7] !== 0); this.useCollisionCells = (this.properties[8] !== 0); this.lastCheckTime = 0; // last time checked for targets in range this.fireTimeCount = this.rateOfFire; // counts up to rate of fire before shooting. starts in fully reloaded state this.currentTarget = null; // current target object this.loadTargetUid = -1; this.oldTargetX = 0; this.oldTargetY = 0; this.lastSpeeds = [0, 0, 0, 0]; this.speedsCount = 0; this.firstTickWithTarget = true; var self = this; if (!this.recycled) { this.myDestroyCallback = function(inst) { self.onInstanceDestroyed(inst); }; } this.runtime.addDestroyCallback(this.myDestroyCallback); }; behinstProto.saveToJSON = function () { var o = { "r": this.range, "rof": this.rateOfFire, "re": this.rotateEnabled, "rs": this.rotateSpeed, "tm": this.targetMode, "pa": this.predictiveAim, "ps": this.projectileSpeed, "en": this.enabled, "lct": this.lastCheckTime, "ftc": this.fireTimeCount, "target": (this.currentTarget ? this.currentTarget.uid : -1), "ox": this.oldTargetX, "oy": this.oldTargetY, "ls": this.lastSpeeds, "sc": this.speedsCount, "targs": [] }; var i, len; for (i = 0, len = this.type.targetTypes.length; i < len; i++) { o["targs"].push(this.type.targetTypes[i].sid); } return o; }; behinstProto.loadFromJSON = function (o) { this.range = o["r"]; this.rateOfFire = o["rof"]; this.rotateEnabled = o["re"]; this.rotateSpeed = o["rs"]; this.targetMode = o["tm"]; this.predictiveAim = o["pa"]; this.projectileSpeed = o["ps"]; this.enabled = o["en"]; this.lastCheckTime = o["lct"]; this.fireTimeCount = o["ftc"] || 0; // not in = this.lastCheckTime + 0.1) { this.lastCheckTime = nowtime; if (this.targetMode === 0 && !this.currentTarget) { this.lookForFirstTarget(); if (this.currentTarget) { this.speedsCount = 0; this.firstTickWithTarget = true; this.oldTargetX = this.currentTarget.x; this.oldTargetY = this.currentTarget.y; this.runtime.trigger(cr.behaviors.Turret.prototype.cnds.OnTargetAcquired, this.inst); } } else if (this.targetMode === 1) { var oldTarget = this.currentTarget; this.lookForNearestTarget(); if (this.currentTarget && this.currentTarget !== oldTarget) { this.speedsCount = 0; this.firstTickWithTarget = true; this.oldTargetX = this.currentTarget.x; this.oldTargetY = this.currentTarget.y; this.runtime.trigger(cr.behaviors.Turret.prototype.cnds.OnTargetAcquired, this.inst); } } } this.fireTimeCount += dt; if (this.currentTarget) { var targetAngle = cr.angleTo(inst.x, inst.y, this.currentTarget.x, this.currentTarget.y); if (this.predictiveAim) { var Gx = inst.x; var Gy = inst.y; var Px = this.currentTarget.x; var Py = this.currentTarget.y; var h = cr.angleTo(Px, Py, this.oldTargetX, this.oldTargetY); if (!this.firstTickWithTarget) this.addSpeed(cr.distanceTo(Px, Py, this.oldTargetX, this.oldTargetY) / dt); var s = this.getSpeed(); var q = Py - Gy; var r = Px - Gx; var w = (s * Math.sin(h) * (Gx - Px) - s * Math.cos(h) * (Gy - Py)) / this.projectileSpeed; var a = (Math.asin(w / Math.sqrt(q * q + r * r)) - Math.atan2(q, -r)) + Math.PI; if (!isNaN(a)) targetAngle = a; } if (this.rotateEnabled) { inst.angle = cr.angleRotate(inst.angle, targetAngle, this.rotateSpeed * dt); inst.set_bbox_changed(); } if ((this.fireTimeCount >= this.rateOfFire) && (!this.rotateEnabled || cr.to_degrees(cr.angleDiff(inst.angle, targetAngle)) <= 0.1) && (!this.predictiveAim || this.speedsCount >= 4)) { this.fireTimeCount -= this.rateOfFire; if (this.fireTimeCount >= this.rateOfFire) this.fireTimeCount = 0; this.runtime.trigger(cr.behaviors.Turret.prototype.cnds.OnShoot, this.inst); } if (this.currentTarget) { this.oldTargetX = this.currentTarget.x; this.oldTargetY = this.currentTarget.y; } this.firstTickWithTarget = false; } if (this.fireTimeCount > this.rateOfFire) this.fireTimeCount = this.rateOfFire; }; function Cnds() {}; Cnds.prototype.HasTarget = function () { return !!this.currentTarget; }; Cnds.prototype.OnShoot = function () { return true; }; Cnds.prototype.OnTargetAcquired = function () { return true; }; behaviorProto.cnds = new Cnds(); function Acts() {}; Acts.prototype.AcquireTarget = function (obj_) { if (!obj_) return; var instances = obj_.getCurrentSol().getObjects(); var i, len, inst; for (i = 0, len = instances.length; i < len; ++i) { inst = instances[i]; if (this.currentTarget !== inst && this.isInRange(inst)) { this.currentTarget = inst; this.speedsCount = 0; this.firstTickWithTarget = true; this.oldTargetX = this.currentTarget.x; this.oldTargetY = this.currentTarget.y; this.runtime.trigger(cr.behaviors.Turret.prototype.cnds.OnTargetAcquired, this.inst); break; } } }; Acts.prototype.AddTarget = function (obj_) { var targetTypes = this.type.targetTypes; if (targetTypes.indexOf(obj_) !== -1) return; var i, len, t; for (i = 0, len = targetTypes.length; i < len; i++) { t = targetTypes[i]; if (t.is_family && t.members.indexOf(obj_) !== -1) return; } targetTypes.push(obj_); }; Acts.prototype.ClearTargets = function () { cr.clearArray(this.type.targetTypes); }; Acts.prototype.UnacquireTarget = function () { this.currentTarget = null; this.speedsCount = 0; this.firstTickWithTarget = true; }; Acts.prototype.SetEnabled = function (e) { this.enabled = (e !== 0); }; Acts.prototype.SetRange = function (r) { this.range = r; }; Acts.prototype.SetRateOfFire = function (r) { this.rateOfFire = r; }; Acts.prototype.SetRotate = function (r) { this.rotateEnabled = (r !== 0); }; Acts.prototype.SetRotateSpeed = function (r) { this.rotateSpeed = cr.to_radians(r); }; Acts.prototype.SetTargetMode = function (s) { this.targetMode = s; }; Acts.prototype.SetPredictiveAim = function (s) { this.predictiveAim = (s !== 0); }; Acts.prototype.SetProjectileSpeed = function (s) { this.projectileSpeed = s; }; behaviorProto.acts = new Acts(); function Exps() {}; Exps.prototype.TargetUID = function (ret) { ret.set_int(this.currentTarget ? this.currentTarget.uid : 0); }; Exps.prototype.Range = function (ret) { ret.set_float(this.range); }; Exps.prototype.RateOfFire = function (ret) { ret.set_float(this.rateOfFire); }; Exps.prototype.RotateSpeed = function (ret) { ret.set_float(cr.to_degrees(this.rotateSpeed)); }; behaviorProto.exps = new Exps(); }()); ; ; cr.behaviors.jumpthru = function(runtime) { this.runtime = runtime; }; (function () { var behaviorProto = cr.behaviors.jumpthru.prototype; behaviorProto.Type = function(behavior, objtype) { this.behavior = behavior; this.objtype = objtype; this.runtime = behavior.runtime; }; var behtypeProto = behaviorProto.Type.prototype; behtypeProto.onCreate = function() { }; behaviorProto.Instance = function(type, inst) { this.type = type; this.behavior = type.behavior; this.inst = inst; // associated object instance to modify this.runtime = type.runtime; }; var behinstProto = behaviorProto.Instance.prototype; behinstProto.onCreate = function() { this.inst.extra["jumpthruEnabled"] = (this.properties[0] !== 0); }; behinstProto.tick = function () { }; function Cnds() {}; Cnds.prototype.IsEnabled = function () { return this.inst.extra["jumpthruEnabled"]; }; behaviorProto.cnds = new Cnds(); function Acts() {}; Acts.prototype.SetEnabled = function (e) { this.inst.extra["jumpthruEnabled"] = !!e; }; behaviorProto.acts = new Acts(); }()); var easeOutBounceArray = []; var easeInElasticArray = []; var easeOutElasticArray = []; var easeInOutElasticArray = []; var easeInCircle = []; var easeOutCircle = []; var easeInOutCircle = []; var easeInBack = []; var easeOutBack = []; var easeInOutBack = []; var litetween_precision = 10000; var updateLimit = 0; //0.0165; function easeOutBouncefunc(t) { var b=0.0; var c=1.0; var d=1.0; if ((t/=d) < (1/2.75)) { result = c*(7.5625*t*t) + b; } else if (t < (2/2.75)) { result = c*(7.5625*(t-=(1.5/2.75))*t + .75) + b; } else if (t < (2.5/2.75)) { result = c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b; } else { result = c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b; } return result; } function integerize(t, d) { return Math.round(t/d*litetween_precision); } function easeFunc(easing, t, b, c, d, flip, param) { var ret_ease = 0; switch (easing) { case 0: // linear ret_ease = c*t/d + b; break; case 1: // easeInQuad ret_ease = c*(t/=d)*t + b; break; case 2: // easeOutQuad ret_ease = -c *(t/=d)*(t-2) + b; break; case 3: // easeInOutQuad if ((t/=d/2) < 1) ret_ease = c/2*t*t + b else ret_ease = -c/2 * ((--t)*(t-2) - 1) + b; break; case 4: // easeInCubic ret_ease = c*(t/=d)*t*t + b; break; case 5: // easeOutCubic ret_ease = c*((t=t/d-1)*t*t + 1) + b; break; case 6: // easeInOutCubic if ((t/=d/2) < 1) ret_ease = c/2*t*t*t + b else ret_ease = c/2*((t-=2)*t*t + 2) + b; break; case 7: // easeInQuart ret_ease = c*(t/=d)*t*t*t + b; break; case 8: // easeOutQuart ret_ease = -c * ((t=t/d-1)*t*t*t - 1) + b; break; case 9: // easeInOutQuart if ((t/=d/2) < 1) ret_ease = c/2*t*t*t*t + b else ret_ease = -c/2 * ((t-=2)*t*t*t - 2) + b; break; case 10: // easeInQuint ret_ease = c*(t/=d)*t*t*t*t + b; break; case 11: // easeOutQuint ret_ease = c*((t=t/d-1)*t*t*t*t + 1) + b; break; case 12: // easeInOutQuint if ((t/=d/2) < 1) ret_ease = c/2*t*t*t*t*t + b else ret_ease = c/2*((t-=2)*t*t*t*t + 2) + b; break; case 13: // easeInCircle if (param.optimized) { ret_ease = easeInCircle[integerize(t,d)]; } else { ret_ease = -(Math.sqrt(1-t*t) - 1); } break; case 14: // easeOutCircle if (param.optimized) { ret_ease = easeOutCircle[integerize(t,d)]; } else { ret_ease = Math.sqrt(1 - ((t-1)*(t-1))); } break; case 15: // easeInOutCircle if (param.optimized) { ret_ease = easeInOutCircle[integerize(t,d)]; } else { if ((t/=d/2) < 1) ret_ease = -c/2 * (Math.sqrt(1 - t*t) - 1) + b else ret_ease = c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b; } break; case 16: // easeInBack if (param.optimized) { ret_ease = easeInBack[integerize(t,d)]; } else { var s = param.s; ret_ease = c*(t/=d)*t*((s+1)*t - s) + b; } break; case 17: // easeOutBack if (param.optimized) { ret_ease = easeOutBack[integerize(t,d)]; } else { var s = param.s; ret_ease = c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b; } break; case 18: // easeInOutBack if (param.optimized) { ret_ease = easeInOutBack[integerize(t,d)]; } else { var s = param.s if ((t/=d/2) < 1) ret_ease = c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b else ret_ease = c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b; } break; case 19: //easeInElastic if (param.optimized) { ret_ease = easeInElasticArray[integerize(t, d)]; } else { var a = param.a; var p = param.p; var s = 0; if (t==0) ret_ease = b; if ((t/=d)==1) ret_ease = b+c; if (p==0) p=d*.3; if (a==0 || a < Math.abs(c)) { a=c; s=p/4; } else var s = p/(2*Math.PI) * Math.asin (c/a); ret_ease = -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b; } break; case 20: //easeOutElastic if (param.optimized) { ret_ease = easeOutElasticArray[integerize(t,d)]; } else { var a = param.a; var p = param.p; var s = 0; if (t==0) ret_ease= b; if ((t/=d)==1) ret_ease= b+c; if (p == 0) p=d*.3; if (a==0 || a < Math.abs(c)) { a=c; var s=p/4; } else var s = p/(2*Math.PI) * Math.asin (c/a); ret_ease= (a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b); } break; case 21: //easeInOutElastic if (param.optimized) { ret_ease = easeInOutElasticArray[integerize(t,d)]; } else { var a = param.a; var p = param.p; var s = 0; if (t==0) ret_ease = b; if ((t/=d/2)==2) ret_ease = b+c; if (p==0) p=d*(.3*1.5); if (a==0 || a < Math.abs(c)) { a=c; var s=p/4; } else var s = p/(2*Math.PI) * Math.asin (c/a); if (t < 1) ret_ease = -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b else ret_ease = a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b; } break; case 22: //easeInBounce if (param.optimized) { ret_ease = c - easeOutBounceArray[integerize(d-t, d)] + b; } else { ret_ease = c - easeOutBouncefunc(d-t/d) + b; } break; case 23: //easeOutBounce if (param.optimized) { ret_ease = easeOutBounceArray[integerize(t, d)]; } else { ret_ease = easeOutBouncefunc(t/d); } break; case 24: //easeInOutBounce if (param.optimized) { if (t < d/2) ret_ease = (c - easeOutBounceArray[integerize(d-(t*2), d)] + b) * 0.5 +b; else ret_ease = easeOutBounceArray[integerize(t*2-d, d)] * .5 + c*.5 + b; } else { if (t < d/2) ret_ease = (c - easeOutBouncefunc(d-(t*2)) + b) * 0.5 +b; else ret_ease = easeOutBouncefunc((t*2-d)/d) * .5 + c *.5 + b; } break; case 25: //easeInSmoothstep var mt = (t/d) / 2; ret_ease = (2*(mt * mt * (3 - 2*mt))); break; case 26: //easeOutSmoothstep var mt = ((t/d) + 1) / 2; ret_ease = ((2*(mt * mt * (3 - 2*mt))) - 1); break; case 27: //easeInOutSmoothstep var mt = (t / d); ret_ease = (mt * mt * (3 - 2*mt)); break; }; if (flip) return (c - b) - ret_ease else return ret_ease; }; (function preCalculateArray() { var d = 1.0; var b = 0.0; var c = 1.0; var result = 0.0; var a = 0.0; var p = 0.0; var t = 0.0; var s = 0.0; for (var ti = 0; ti <= litetween_precision; ti++) { t = ti/litetween_precision; if ((t/=d) < (1/2.75)) { result = c*(7.5625*t*t) + b; } else if (t < (2/2.75)) { result = c*(7.5625*(t-=(1.5/2.75))*t + .75) + b; } else if (t < (2.5/2.75)) { result = c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b; } else { result = c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b; } easeOutBounceArray[ti] = result; t = ti/litetween_precision; a = 0; p = 0; if (t==0) result = b; if ((t/=d)==1) result = b+c; if (p==0) p=d*.3; if (a==0 || a < Math.abs(c)) { a=c; var s=p/4; } else var s = p/(2*Math.PI) * Math.asin (c/a); result = -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b; easeInElasticArray[ti] = result; t = ti/litetween_precision; a = 0; p = 0; if (t==0) result= b; if ((t/=d)==1) result= b+c; if (p == 0) p=d*.3; if (a==0 || a < Math.abs(c)) { a=c; var s=p/4; } else var s = p/(2*Math.PI) * Math.asin (c/a); result= (a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b); easeOutElasticArray[ti] = result; t = ti/litetween_precision; a = 0; p = 0; if (t==0) result = b; if ((t/=d/2)==2) result = b+c; if (p==0) p=d*(.3*1.5); if (a==0 || a < Math.abs(c)) { a=c; var s=p/4; } else var s = p/(2*Math.PI) * Math.asin (c/a); if (t < 1) result = -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b else result = a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b; easeInOutElasticArray[ti] = result; t = ti/litetween_precision; easeInCircle[ti] = -(Math.sqrt(1-t*t) - 1); t = ti/litetween_precision; easeOutCircle[ti] = Math.sqrt(1 - ((t-1)*(t-1))); t = ti/litetween_precision; if ((t/=d/2) < 1) result = -c/2 * (Math.sqrt(1 - t*t) - 1) + b else result = c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b; easeInOutCircle[ti] = result; t = ti/litetween_precision; s = 0; if (s==0) s = 1.70158; result = c*(t/=d)*t*((s+1)*t - s) + b; easeInBack[ti] = result; t = ti/litetween_precision; s = 0; if (s==0) s = 1.70158; result = c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b; easeOutBack[ti] = result; t = ti/litetween_precision; s = 0; if (s==0) s = 1.70158; if ((t/=d/2) < 1) result = c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b else result = c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b; easeInOutBack[ti] = result; } }()); var TweenObject = function() { var constructor = function (tname, tweened, easefunc, initial, target, duration, enforce) { this.name = tname; this.value = 0; this.setInitial(initial); this.setTarget(target); this.easefunc = easefunc; this.tweened = tweened; this.duration = duration; this.progress = 0; this.state = 0; this.onStart = false; this.onEnd = false; this.onReverseStart = false; this.onReverseEnd = false; this.lastKnownValue = 0; this.lastKnownValue2 = 0; this.enforce = enforce; this.pingpong = 1.0; this.flipEase = false; this.easingparam = []; for (var i=0; i<28; i++) { this.easingparam[i] = {}; this.easingparam[i].a = 0.0; this.easingparam[i].p = 0.0; this.easingparam[i].t = 0.0; this.easingparam[i].s = 0.0; this.easingparam[i].optimized = true; } } return constructor; }(); (function () { TweenObject.prototype = { }; TweenObject.prototype.flipTarget = function () { var x1 = this.initialparam1; var x2 = this.initialparam2; this.initialparam1 = this.targetparam1; this.initialparam2 = this.targetparam2; this.targetparam1 = x1; this.targetparam2 = x2; this.lastKnownValue = 0; this.lastKnownValue2 = 0; } TweenObject.prototype.setInitial = function (initial) { this.initialparam1 = parseFloat(initial.split(",")[0]); this.initialparam2 = parseFloat(initial.split(",")[1]); this.lastKnownValue = 0; this.lastKnownValue2 = 0; } TweenObject.prototype.setTarget = function (target) { this.targetparam1 = parseFloat(target.split(",")[0]); this.targetparam2 = parseFloat(target.split(",")[1]); if (isNaN(this.targetparam2)) this.targetparam2 = this.targetparam1; } TweenObject.prototype.OnTick = function(dt) { if (this.state === 0) return -1.0; if (this.state === 1) this.progress += dt; if (this.state === 2) this.progress -= dt; if (this.state === 3) { this.state = 0; } if ((this.state === 4) || (this.state === 6)) { this.progress += dt * this.pingpong; } if (this.state === 5) { this.progress += dt * this.pingpong; } if (this.progress < 0) { this.progress = 0; if (this.state === 4) { this.pingpong = 1; } else if (this.state === 6) { this.pingpong = 1; this.flipEase = false; } else { this.state = 0; } this.onReverseEnd = true; return 0.0; } else if (this.progress > this.duration) { this.progress = this.duration; if (this.state === 4) { this.pingpong = -1; } else if (this.state === 6) { this.pingpong = -1; this.flipEase = true; } else if (this.state === 5) { this.progress = 0.0; } else { this.state = 0; } this.onEnd = true; return 1.0; } else { if (this.flipEase) { var factor = easeFunc(this.easefunc, this.duration - this.progress, 0, 1, this.duration, this.flipEase, this.easingparam[this.easefunc]); } else { var factor = easeFunc(this.easefunc, this.progress, 0, 1, this.duration, this.flipEase, this.easingparam[this.easefunc]); } return factor; } }; }()); ; ; function trim (str) { return str.replace(/^\s\s*/, '').replace(/\s\s*$/, ''); } cr.behaviors.lunarray_LiteTween = function(runtime) { this.runtime = runtime; }; (function () { var behaviorProto = cr.behaviors.lunarray_LiteTween.prototype; behaviorProto.Type = function(behavior, objtype) { this.behavior = behavior; this.objtype = objtype; this.runtime = behavior.runtime; }; var behtypeProto = behaviorProto.Type.prototype; behtypeProto.onCreate = function() { }; behaviorProto.Instance = function(type, inst) { this.type = type; this.behavior = type.behavior; this.inst = inst; // associated object instance to modify this.runtime = type.runtime; this.i = 0; // progress }; var behinstProto = behaviorProto.Instance.prototype; behinstProto.onCreate = function() { this.playmode = this.properties[0]; this.active = (this.playmode == 1) || (this.playmode == 2) || (this.playmode == 3) || (this.playmode == 4); this.tweened = this.properties[1]; // 0=Position|1=Size|2=Width|3=Height|4=Angle|5=Opacity|6=Value only|7=Horizontal|8=Vertical|9=Scale this.easing = this.properties[2]; this.target = this.properties[3]; this.targetmode = this.properties[4]; this.useCurrent = false; if (this.targetmode === 1) this.target = "relative("+this.target+")"; this.duration = this.properties[5]; this.enforce = (this.properties[6] === 1); this.value = 0; this.tween_list = {}; this.addToTweenList("default", this.tweened, this.easing, "current", this.target, this.duration, this.enforce); if (this.properties[0] === 1) this.startTween(0) if (this.properties[0] === 2) this.startTween(2) if (this.properties[0] === 3) this.startTween(3) if (this.properties[0] === 4) this.startTween(4) }; behinstProto.parseCurrent = function(tweened, parseText) { if (parseText === undefined) parseText = "current"; var parsed = trim(parseText); parseText = trim(parseText); var value = this.value; if (parseText === "current") { switch (tweened) { case 0: parsed = this.inst.x + "," + this.inst.y; break; case 1: parsed = this.inst.width + "," + this.inst.height; break; case 2: parsed = this.inst.width + "," + this.inst.height; break; case 3: parsed = this.inst.width + "," + this.inst.height; break; case 4: parsed = cr.to_degrees(this.inst.angle) + "," + cr.to_degrees(this.inst.angle); break; case 5: parsed = (this.inst.opacity*100) + "," + (this.inst.opacity*100); break; case 6: parsed = value + "," + value; break; case 7: parsed = this.inst.x + "," + this.inst.y; break; case 8: parsed = this.inst.x + "," + this.inst.y; break; case 9: if (this.inst.curFrame !== undefined) parsed = (this.inst.width/this.inst.curFrame.width) + "," +(this.inst.height/this.inst.curFrame.height) else parsed = "1,1"; break; default: break; } } if (parseText.substring(0,8) === "relative") { var param1 = parseText.match(/\((.*?)\)/); if (param1) { var relativex = parseFloat(param1[1].split(",")[0]); var relativey = parseFloat(param1[1].split(",")[1]); } if (isNaN(relativex)) relativex = 0; if (isNaN(relativey)) relativey = 0; switch (tweened) { case 0: parsed = (this.inst.x+relativex) + "," + (this.inst.y+relativey); break; case 1: parsed = (this.inst.width+relativex) + "," + (this.inst.height+relativey); break; case 2: parsed = (this.inst.width+relativex) + "," + (this.inst.height+relativey); break; case 3: parsed = (this.inst.width+relativex) + "," + (this.inst.height+relativey); break; case 4: parsed = (cr.to_degrees(this.inst.angle)+relativex) + "," + (cr.to_degrees(this.inst.angle)+relativey); break; case 5: parsed = (this.inst.opacity*100+relativex) + "," + (this.inst.opacity*100+relativey); break; case 6: parsed = value+relativex + "," + value+relativex; break; case 7: parsed = (this.inst.x+relativex) + "," + (this.inst.y); break; case 8: parsed = (this.inst.x) + "," + (this.inst.y+relativex); break; case 9: parsed = (relativex) + "," + (relativey); break; default: break; } } return parsed; }; behinstProto.addToTweenList = function(tname, tweened, easing, init, targ, duration, enforce) { init = this.parseCurrent(tweened, init); targ = this.parseCurrent(tweened, targ); if (this.tween_list[tname] !== undefined) { delete this.tween_list[tname] } this.tween_list[tname] = new TweenObject(tname, tweened, easing, init, targ, duration, enforce); this.tween_list[tname].dt = 0; }; behinstProto.saveToJSON = function () { var v = JSON.stringify(this.tween_list["default"]); return { "playmode": this.playmode, "active": this.active, "tweened": this.tweened, "easing": this.easing, "target": this.target, "targetmode": this.targetmode, "useCurrent": this.useCurrent, "duration": this.duration, "enforce": this.enforce, "value": this.value, "tweenlist": JSON.stringify(this.tween_list["default"]) }; }; TweenObject.Load = function(rawObj, tname, tweened, easing, init, targ, duration, enforce) { var obj = new TweenObject(tname, tweened, easing, init, targ, duration, enforce); for(var i in rawObj) obj[i] = rawObj[i]; return obj; }; behinstProto.loadFromJSON = function (o) { var x = JSON.parse(o["tweenlist"]); var tempObj = TweenObject.Load(x, x.name, x.tweened, x.easefunc, x.initialparam1+","+x.initialparam2, x.targetparam1+","+x.targetparam2, x.duration, x.enforce); console.log(tempObj); this.tween_list["default"] = tempObj; this.playmode = o["playmode"]; this.active = o["active"]; this.movement = o["tweened"]; this.easing = o["easing"]; this.target = o["target"]; this.targetmode = o["targetmode"]; this.useCurrent = o["useCurrent"]; this.duration = o["duration"]; this.enforce = o["enforce"]; this.value = o["value"]; }; behinstProto.setProgressTo = function (mark) { if (mark > 1.0) mark = 1.0; if (mark < 0.0) mark = 0.0; for (var i in this.tween_list) { var inst = this.tween_list[i]; inst.lastKnownValue = 0; inst.lastKnownValue2 = 0; inst.state = 3; inst.progress = mark * inst.duration; var factor = inst.OnTick(0); this.updateTween(inst, factor); } } behinstProto.startTween = function (startMode) { for (var i in this.tween_list) { var inst = this.tween_list[i]; if (this.useCurrent) { var init = this.parseCurrent(inst.tweened, "current"); var target = this.parseCurrent(inst.tweened, this.target); inst.setInitial(init); inst.setTarget(target); } if (startMode === 0) { inst.progress = 0.000001; inst.lastKnownValue = 0; inst.lastKnownValue2 = 0; inst.onStart = true; inst.state = 1; } if (startMode === 1) { inst.state = 1; } if ((startMode === 2) || (startMode === 4)) { inst.progress = 0.000001; inst.lastKnownValue = 0; inst.lastKnownValue2 = 0; inst.onStart = true; if (startMode == 2) inst.state = 4; //state ping pong if (startMode == 4) inst.state = 6; //state flip flop } if (startMode === 3) { inst.progress = 0.000001; inst.lastKnownValue = 0; inst.lastKnownValue2 = 0; inst.onStart = true; inst.state = 5; } } } behinstProto.stopTween = function (stopMode) { for (var i in this.tween_list) { var inst = this.tween_list[i]; if (stopMode === 1) inst.progress = 0.0; if (stopMode === 2) inst.progress = inst.duration; inst.state = 3; var factor = inst.OnTick(0); this.updateTween(inst, factor); } } behinstProto.reverseTween = function(reverseMode) { for (var i in this.tween_list) { var inst = this.tween_list[i]; if (reverseMode === 1) { inst.progress = inst.duration; inst.lastKnownValue = 0; inst.lastKnownValue2 = 0; inst.onReverseStart = true; } inst.state = 2; } } behinstProto.updateTween = function (inst, factor) { var isMirrored = 1; var isFlipped = 1; if (this.inst.width < 0) isMirrored = -1; if (this.inst.height < 0) isFlipped = -1; if (inst.tweened === 0) { if (inst.enforce) { this.inst.x = inst.initialparam1 + (inst.targetparam1 - inst.initialparam1) * factor; this.inst.y = inst.initialparam2 + (inst.targetparam2 - inst.initialparam2) * factor; } else { this.inst.x += ((inst.targetparam1 - inst.initialparam1) * factor) - inst.lastKnownValue; this.inst.y += ((inst.targetparam2 - inst.initialparam2) * factor) - inst.lastKnownValue2; inst.lastKnownValue = ((inst.targetparam1 - inst.initialparam1) * factor); inst.lastKnownValue2 = ((inst.targetparam2 - inst.initialparam2) * factor); } } else if (inst.tweened === 1) { if (inst.enforce) { this.inst.width = (isMirrored * inst.initialparam1 + ((inst.targetparam1 - inst.initialparam1) * (factor * isMirrored))); this.inst.height = (isFlipped * inst.initialparam2 + ((inst.targetparam2 - inst.initialparam2) * (factor * isFlipped))); } else { this.inst.width += (isMirrored *(inst.targetparam1 - inst.initialparam1) * factor) - inst.lastKnownValue; this.inst.height += (isFlipped *(inst.targetparam2 - inst.initialparam2) * factor) - inst.lastKnownValue2; inst.lastKnownValue = (isMirrored *(inst.targetparam1 - inst.initialparam1) * factor); inst.lastKnownValue2 = (isFlipped *(inst.targetparam2 - inst.initialparam2) * factor); } } else if (inst.tweened === 2) { if (inst.enforce) { this.inst.width = (isMirrored * inst.initialparam1 + ((inst.targetparam1 - inst.initialparam1) * (factor * isMirrored))); } else { this.inst.width += (isMirrored *(inst.targetparam1 - inst.initialparam1) * factor) - inst.lastKnownValue; inst.lastKnownValue = (isMirrored *(inst.targetparam1 - inst.initialparam1) * factor); } } else if (inst.tweened === 3) { if (inst.enforce) { this.inst.height = (isFlipped * inst.initialparam2 + ((inst.targetparam2 - inst.initialparam2) * (factor * isFlipped))); } else { this.inst.height += (isFlipped * (inst.targetparam2 - inst.initialparam2) * factor) - inst.lastKnownValue2; inst.lastKnownValue2 = (isFlipped * (inst.targetparam2 - inst.initialparam2) * factor); } } else if (inst.tweened === 4) { if (inst.enforce) { var tangle = inst.initialparam1 + (inst.targetparam1 - inst.initialparam1) * factor; this.inst.angle = cr.clamp_angle(cr.to_radians(tangle)); } else { var tangle = ((inst.targetparam1 - inst.initialparam1) * factor) - inst.lastKnownValue; this.inst.angle = cr.clamp_angle(this.inst.angle + cr.to_radians(tangle)); inst.lastKnownValue = (inst.targetparam1 - inst.initialparam1) * factor; } } else if (inst.tweened === 5) { if (inst.enforce) { this.inst.opacity = (inst.initialparam1 + (inst.targetparam1 - inst.initialparam1) * factor) / 100; } else { this.inst.opacity += (((inst.targetparam1 - inst.initialparam1) * factor) - inst.lastKnownValue) / 100; inst.lastKnownValue = ((inst.targetparam1 - inst.initialparam1) * factor); } } else if (inst.tweened === 6) { if (inst.enforce) { this.value = (inst.initialparam1 + (inst.targetparam1 - inst.initialparam1) * factor); } else { this.value += (((inst.targetparam1 - inst.initialparam1) * factor) - inst.lastKnownValue); inst.lastKnownValue = ((inst.targetparam1 - inst.initialparam1) * factor); } } else if (inst.tweened === 7) { if (inst.enforce) { this.inst.x = inst.initialparam1 + (inst.targetparam1 - inst.initialparam1) * factor; } else { this.inst.x += ((inst.targetparam1 - inst.initialparam1) * factor) - inst.lastKnownValue; inst.lastKnownValue = ((inst.targetparam1 - inst.initialparam1) * factor); } } else if (inst.tweened === 8) { if (inst.enforce) { this.inst.y = inst.initialparam2 + (inst.targetparam2 - inst.initialparam2) * factor; } else { this.inst.y += ((inst.targetparam2 - inst.initialparam2) * factor) - inst.lastKnownValue2; inst.lastKnownValue2 = ((inst.targetparam2 - inst.initialparam2) * factor); } } else if (inst.tweened === 9) { var scalex = inst.initialparam1 + (inst.targetparam1 - inst.initialparam1) * factor; var scaley = inst.initialparam2 + (inst.targetparam2 - inst.initialparam2) * factor; if (this.inst.width < 0) scalex = inst.initialparam1 + (inst.targetparam1 + inst.initialparam1) * -factor; if (this.inst.height < 0) scaley = inst.initialparam2 + (inst.targetparam2 + inst.initialparam2) * -factor; if (inst.enforce) { this.inst.width = this.inst.curFrame.width * scalex; this.inst.height = this.inst.curFrame.height * scaley; } else { if (this.inst.width < 0) { this.inst.width = scalex * (this.inst.width / (-1+inst.lastKnownValue)); inst.lastKnownValue = scalex + 1 } else { this.inst.width = scalex * (this.inst.width / (1+inst.lastKnownValue)); inst.lastKnownValue = scalex - 1; } if (this.inst.height < 0) { this.inst.height = scaley * (this.inst.height / (-1+inst.lastKnownValue2)); inst.lastKnownValue2 = scaley + 1 } else { this.inst.height = scaley * (this.inst.height / (1+inst.lastKnownValue2)); inst.lastKnownValue2 = scaley - 1; } } } this.inst.set_bbox_changed(); } behinstProto.tick = function () { var dt = this.runtime.getDt(this.inst); var inst = this.tween_list["default"]; if (inst.state !== 0) { if (inst.onStart) { this.runtime.trigger(cr.behaviors.lunarray_LiteTween.prototype.cnds.OnStart, this.inst); inst.onStart = false; } if (inst.onReverseStart) { this.runtime.trigger(cr.behaviors.lunarray_LiteTween.prototype.cnds.OnReverseStart, this.inst); inst.onReverseStart = false; } this.active = (inst.state == 1) || (inst.state == 2) || (inst.state == 4) || (inst.state == 5) || (inst.state == 6); var factor = inst.OnTick(dt); this.updateTween(inst, factor); if (inst.onEnd) { this.runtime.trigger(cr.behaviors.lunarray_LiteTween.prototype.cnds.OnEnd, this.inst); inst.onEnd = false; } if (inst.onReverseEnd) { this.runtime.trigger(cr.behaviors.lunarray_LiteTween.prototype.cnds.OnReverseEnd, this.inst); inst.onReverseEnd = false; } } }; behaviorProto.cnds = {}; var cnds = behaviorProto.cnds; cnds.IsActive = function () { return (this.tween_list["default"].state !== 0); }; cnds.IsReversing = function () { return (this.tween_list["default"].state == 2); }; cnds.CompareProgress = function (cmp, v) { var inst = this.tween_list["default"]; return cr.do_cmp((inst.progress / inst.duration), cmp, v); }; cnds.OnThreshold = function (cmp, v) { var inst = this.tween_list["default"]; this.threshold = (cr.do_cmp((inst.progress / inst.duration), cmp, v)); var ret = (this.oldthreshold != this.threshold) && (this.threshold); if (ret) { this.oldthreshold = this.threshold; } return ret; }; cnds.OnStart = function () { if (this.tween_list["default"] === undefined) return false; return this.tween_list["default"].onStart; }; cnds.OnReverseStart = function () { if (this.tween_list["default"] === undefined) return false; return this.tween_list["default"].onReverseStart; }; cnds.OnEnd = function () { if (this.tween_list["default"] === undefined) return false; return this.tween_list["default"].onEnd; }; cnds.OnReverseEnd = function () { if (this.tween_list["default"] === undefined) return false; return this.tween_list["default"].onReverseEnd; }; behaviorProto.acts = {}; var acts = behaviorProto.acts; acts.Start = function (startmode, current) { this.threshold = false; this.oldthreshold = false; this.useCurrent = (current == 1); this.startTween(startmode); }; acts.Stop = function (stopmode) { this.stopTween(stopmode); }; acts.Reverse = function (revMode) { this.threshold = false; this.oldthreshold = false; this.reverseTween(revMode); }; acts.ProgressTo = function (progress) { this.setProgressTo(progress); }; acts.SetDuration = function (x) { if (isNaN(x)) return; if (x < 0) return; if (this.tween_list["default"] === undefined) return; this.tween_list["default"].duration = x; }; acts.SetEnforce = function (x) { if (this.tween_list["default"] === undefined) return; this.tween_list["default"].enforce = (x===1); }; acts.SetInitial = function (x) { if (this.tween_list["default"] === undefined) return; var init = this.parseCurrent(this.tween_list["default"].tweened, x); this.tween_list["default"].setInitial(init); }; acts.SetTarget = function (targettype, absrel, x) { if (this.tween_list["default"] === undefined) return; if (isNaN(x)) return; var inst = this.tween_list["default"]; var parsed = x + ""; this.targetmode = absrel; var x1 = ""; var x2 = ""; if (absrel === 1) { this.target = "relative(" + parsed + ")"; switch (targettype) { case 0: x1 = (this.inst.x + x); x2 = inst.targetparam2; break; case 1: x1 = inst.targetparam1; x2 = (this.inst.y + x); break; case 2: x1 = "" + cr.to_degrees(this.inst.angle + cr.to_radians(x)); x2 = x1; break; //angle case 3: x1 = "" + (this.inst.opacity*100) + x; x2 = x1; break; //opacity case 4: x1 = (this.inst.width + x); x2 = inst.targetparam2; break; //width case 5: x1 = inst.targetparam1; x2 = (this.inst.height + x); break; //height case 6: x1 = x; x2 = x; break; //value default: break; } parsed = x1 + "," + x2; } else { switch (targettype) { case 0: x1 = x; x2 = inst.targetparam2; break; case 1: x1 = inst.targetparam1; x2 = x; break; case 2: x1 = x; x2 = x; break; //angle case 3: x1 = x; x2 = x; break; //opacity case 4: x1 = x; x2 = inst.targetparam2; break; //width case 5: x1 = inst.targetparam1; x2 = x; break; //height case 6: x1 = x; x2 = x; break; //value default: break; } parsed = x1 + "," + x2; this.target = parsed; } var init = this.parseCurrent(this.tween_list["default"].tweened, "current"); var targ = this.parseCurrent(this.tween_list["default"].tweened, parsed); inst.setInitial(init); inst.setTarget(targ); }; acts.SetTweenedProperty = function (x) { if (this.tween_list["default"] === undefined) return; this.tween_list["default"].tweened = x; }; acts.SetEasing = function (x) { if (this.tween_list["default"] === undefined) return; this.tween_list["default"].easefunc = x; }; acts.SetEasingParam = function (x, a, p, t, s) { if (this.tween_list["default"] === undefined) return; this.tween_list["default"].easingparam[x].optimized = false; this.tween_list["default"].easingparam[x].a = a; this.tween_list["default"].easingparam[x].p = p; this.tween_list["default"].easingparam[x].t = t; this.tween_list["default"].easingparam[x].s = s; }; acts.ResetEasingParam = function () { if (this.tween_list["default"] === undefined) return; this.tween_list["default"].optimized = true; }; acts.SetValue = function (x) { var inst = this.tween_list["default"]; this.value = x; if (inst.tweened === 6) inst.setInitial( this.parseCurrent(inst.tweened, "current") ); }; acts.SetParameter = function (tweened, easefunction, target, duration, enforce) { if (this.tween_list["default"] === undefined) { this.addToTweenList("default", tweened, easefunction, initial, target, duration, enforce, 0); } else { var inst = this.tween_list["default"]; inst.tweened = tweened; inst.easefunc = easefunction; inst.setInitial( this.parseCurrent(tweened, "current") ); inst.setTarget( this.parseCurrent(tweened, target) ); inst.duration = duration; inst.enforce = (enforce === 1); } }; behaviorProto.exps = {}; var exps = behaviorProto.exps; exps.State = function (ret) { var parsed = "N/A"; switch (this.tween_list["default"].state) { case 0: parsed = "paused"; break; case 1: parsed = "playing"; break; case 2: parsed = "reversing"; break; case 3: parsed = "seeking"; break; default: break; } ret.set_string(parsed); }; exps.Progress = function (ret) { var progress = this.tween_list["default"].progress/this.tween_list["default"].duration; ret.set_float(progress); }; exps.Duration = function (ret) { ret.set_float(this.tween_list["default"].duration); }; exps.Target = function (ret) { var inst = this.tween_list["default"]; var parsed = "N/A"; switch (inst.tweened) { case 0: parsed = inst.targetparam1; break; case 1: parsed = inst.targetparam2; break; case 2: parsed = inst.targetparam1; break; case 3: parsed = inst.targetparam1; break; case 4: parsed = inst.targetparam1; break; case 5: parsed = inst.targetparam2; break; case 6: parsed = inst.targetparam1; break; default: break; } ret.set_float(parsed); }; exps.Value = function (ret) { var tval = this.value; ret.set_float(tval); }; exps.Tween = function (ret, a_, b_, x_, easefunc_) { var currX = (x_>1.0?1.0:x_); var factor = easeFunc(easefunc_, currX<0.0?0.0:currX, 0.0, 1.0, 1.0, false, false); ret.set_float(a_ + factor * (b_-a_)); }; }()); ; ; cr.behaviors.solid = function(runtime) { this.runtime = runtime; }; (function () { var behaviorProto = cr.behaviors.solid.prototype; behaviorProto.Type = function(behavior, objtype) { this.behavior = behavior; this.objtype = objtype; this.runtime = behavior.runtime; }; var behtypeProto = behaviorProto.Type.prototype; behtypeProto.onCreate = function() { }; behaviorProto.Instance = function(type, inst) { this.type = type; this.behavior = type.behavior; this.inst = inst; // associated object instance to modify this.runtime = type.runtime; }; var behinstProto = behaviorProto.Instance.prototype; behinstProto.onCreate = function() { this.inst.extra["solidEnabled"] = (this.properties[0] !== 0); }; behinstProto.tick = function () { }; function Cnds() {}; Cnds.prototype.IsEnabled = function () { return this.inst.extra["solidEnabled"]; }; behaviorProto.cnds = new Cnds(); function Acts() {}; Acts.prototype.SetEnabled = function (e) { this.inst.extra["solidEnabled"] = !!e; }; behaviorProto.acts = new Acts(); }()); ; ; cr.behaviors.wrap = function(runtime) { this.runtime = runtime; }; (function () { var behaviorProto = cr.behaviors.wrap.prototype; behaviorProto.Type = function(behavior, objtype) { this.behavior = behavior; this.objtype = objtype; this.runtime = behavior.runtime; }; var behtypeProto = behaviorProto.Type.prototype; behtypeProto.onCreate = function() { }; behaviorProto.Instance = function(type, inst) { this.type = type; this.behavior = type.behavior; this.inst = inst; // associated object instance to modify this.runtime = type.runtime; }; var behinstProto = behaviorProto.Instance.prototype; behinstProto.onCreate = function() { this.mode = this.properties[0]; // 0 = wrap to layout, 1 = wrap to viewport }; behinstProto.tick = function () { var inst = this.inst; inst.update_bbox(); var bbox = inst.bbox; var layer = inst.layer; var layout = layer.layout; var lbound = 0, rbound = 0, tbound = 0, bbound = 0; if (this.mode === 0) { rbound = layout.width; bbound = layout.height; } else { lbound = layer.viewLeft; rbound = layer.viewRight; tbound = layer.viewTop; bbound = layer.viewBottom; } if (bbox.right < lbound) { inst.x = (rbound - 1) + (inst.x - bbox.left); inst.set_bbox_changed(); } else if (bbox.left > rbound) { inst.x = (lbound + 1) - (bbox.right - inst.x); inst.set_bbox_changed(); } else if (bbox.bottom < tbound) { inst.y = (bbound - 1) + (inst.y - bbox.top); inst.set_bbox_changed(); } else if (bbox.top > bbound) { inst.y = (tbound + 1) - (bbox.bottom - inst.y); inst.set_bbox_changed(); } }; }()); cr.getObjectRefTable = function () { return [ cr.plugins_.Audio, cr.plugins_.Browser, cr.plugins_.Function, cr.plugins_.Particles, cr.plugins_.gamepad, cr.plugins_.Keyboard, cr.plugins_.Kongregate, cr.plugins_.LocalStorage, cr.plugins_.Mouse, cr.plugins_.TiledBg, cr.plugins_.Text, cr.plugins_.Spriter, cr.plugins_.video, cr.plugins_.Sprite, cr.plugins_.Spritefont2, cr.plugins_.Tilemap, cr.plugins_.MagiCam, cr.behaviors.solid, cr.behaviors.Platform, cr.behaviors.lunarray_LiteTween, cr.behaviors.Timer, cr.behaviors.Flash, cr.behaviors.Physics, cr.behaviors.Sin, cr.behaviors.jumpthru, cr.behaviors.EightDir, cr.behaviors.Persist, cr.behaviors.Pin, cr.behaviors.Rotate, cr.behaviors.Bullet, cr.behaviors.Turret, cr.behaviors.LOS, cr.behaviors.Fade, cr.behaviors.wrap, cr.system_object.prototype.cnds.OnLayoutStart, cr.plugins_.MagiCam.prototype.acts.CreateLocalCamera, cr.plugins_.Sprite.prototype.acts.SetEffectEnabled, cr.behaviors.Platform.prototype.acts.SetIgnoreInput, cr.system_object.prototype.cnds.For, cr.system_object.prototype.exps["int"], cr.plugins_.Tilemap.prototype.exps.Width, cr.plugins_.Tilemap.prototype.exps.Height, cr.plugins_.Tilemap.prototype.cnds.CompareTileAt, cr.system_object.prototype.exps.loopindex, cr.system_object.prototype.acts.CreateObject, cr.plugins_.Tilemap.prototype.exps.TileToPositionX, cr.plugins_.Tilemap.prototype.exps.TileToPositionY, cr.system_object.prototype.cnds.CompareVar, cr.plugins_.Audio.prototype.acts.SetSilent, cr.plugins_.Text.prototype.cnds.CompareInstanceVar, cr.system_object.prototype.acts.Wait, cr.plugins_.Text.prototype.acts.SetVisible, cr.system_object.prototype.acts.WaitForSignal, cr.system_object.prototype.cnds.CompareTime, cr.system_object.prototype.acts.SetVar, cr.system_object.prototype.cnds.TriggerOnce, cr.plugins_.Sprite.prototype.acts.SetPos, cr.plugins_.Keyboard.prototype.cnds.IsKeyDown, cr.plugins_.gamepad.prototype.cnds.IsButtonDown, cr.plugins_.Text.prototype.acts.Destroy, cr.behaviors.Fade.prototype.acts.StartFade, cr.plugins_.Sprite.prototype.acts.Destroy, cr.plugins_.Sprite.prototype.cnds.IsOnLayer, cr.system_object.prototype.cnds.IsGroupActive, cr.plugins_.Keyboard.prototype.cnds.OnKey, cr.plugins_.gamepad.prototype.cnds.OnButtonDown, cr.plugins_.Sprite.prototype.cnds.IsOverlapping, cr.plugins_.MagiCam.prototype.cnds.TransitionIsInProgress, cr.system_object.prototype.cnds.RegexTest, cr.plugins_.MagiCam.prototype.acts.TransitionToPoint, cr.plugins_.TiledBg.prototype.exps.X, cr.plugins_.TiledBg.prototype.exps.Y, cr.system_object.prototype.acts.SetObjectTimescale, cr.plugins_.Sprite.prototype.acts.SetVisible, cr.plugins_.Spritefont2.prototype.acts.SetVisible, cr.system_object.prototype.acts.AddVar, cr.plugins_.Audio.prototype.acts.Stop, cr.plugins_.Audio.prototype.acts.Play, cr.behaviors.lunarray_LiteTween.prototype.acts.SetTarget, cr.behaviors.lunarray_LiteTween.prototype.acts.Start, cr.system_object.prototype.cnds.Else, cr.plugins_.Text.prototype.acts.SetText, cr.plugins_.Sprite.prototype.exps.X, cr.plugins_.Sprite.prototype.exps.Y, cr.system_object.prototype.acts.Signal, cr.system_object.prototype.acts.SetLayerEffectParam, cr.system_object.prototype.acts.SetLayerEffectEnabled, cr.plugins_.MagiCam.prototype.acts.TransitionToZoom, cr.plugins_.LocalStorage.prototype.acts.SetItem, cr.plugins_.LocalStorage.prototype.cnds.IsProcessingSets, cr.behaviors.Platform.prototype.acts.SetEnabled, cr.behaviors.Platform.prototype.acts.SetGravity, cr.behaviors.Platform.prototype.acts.SetMaxFallSpeed, cr.behaviors.Platform.prototype.acts.SimulateControl, cr.behaviors.Platform.prototype.cnds.OnJump, cr.behaviors.Platform.prototype.cnds.IsOnFloor, cr.behaviors.Timer.prototype.acts.StartTimer, cr.plugins_.Sprite.prototype.acts.SetBoolInstanceVar, cr.behaviors.Platform.prototype.acts.SetDeceleration, cr.behaviors.Platform.prototype.cnds.IsFalling, cr.plugins_.Sprite.prototype.cnds.IsBoolInstanceVarSet, cr.system_object.prototype.cnds.Compare, cr.behaviors.Timer.prototype.exps.CurrentTime, cr.behaviors.Platform.prototype.acts.SetVectorY, cr.behaviors.Platform.prototype.cnds.IsByWall, cr.plugins_.gamepad.prototype.cnds.CompareAxis, cr.behaviors.Platform.prototype.acts.SetVectorX, cr.behaviors.Platform.prototype.cnds.IsJumping, cr.behaviors.Timer.prototype.acts.StopTimer, cr.behaviors.Platform.prototype.exps.VectorY, cr.plugins_.Sprite.prototype.cnds.OnCollision, cr.behaviors.Platform.prototype.cnds.OnFall, cr.behaviors.lunarray_LiteTween.prototype.acts.Reverse, cr.plugins_.Sprite.prototype.exps.UID, cr.system_object.prototype.cnds.PickByComparison, cr.plugins_.Sprite.prototype.acts.SetOpacity, cr.behaviors.Flash.prototype.acts.Flash, cr.plugins_.Sprite.prototype.cnds.IsOverlappingOffset, cr.plugins_.Sprite.prototype.cnds.CompareInstanceVar, cr.plugins_.Spritefont2.prototype.acts.SetText, cr.behaviors.Sin.prototype.acts.SetActive, cr.plugins_.Spritefont2.prototype.acts.SetPos, cr.plugins_.Sprite.prototype.cnds.IsVisible, cr.plugins_.Sprite.prototype.cnds.CompareY, cr.plugins_.Sprite.prototype.exps.ImagePointY, cr.plugins_.Sprite.prototype.acts.Spawn, cr.plugins_.Spriter.prototype.cnds.readyForSetup, cr.plugins_.Spriter.prototype.acts.associateTypeWithName, cr.plugins_.Audio.prototype.cnds.OnEnded, cr.plugins_.Audio.prototype.cnds.IsSilent, cr.plugins_.Mouse.prototype.cnds.OnObjectClicked, cr.plugins_.Browser.prototype.acts.GoToURLWindow, cr.behaviors.Turret.prototype.acts.AddTarget, cr.behaviors.lunarray_LiteTween.prototype.cnds.OnEnd, cr.plugins_.Sprite.prototype.acts.AddInstanceVar, cr.plugins_.Sprite.prototype.exps.Opacity, cr.plugins_.Sprite.prototype.acts.SetAnim, cr.plugins_.Sprite.prototype.cnds.PickDistance, cr.plugins_.MagiCam.prototype.acts.ShakeCamera, cr.plugins_.Particles.prototype.acts.SetPosToObject, cr.behaviors.Pin.prototype.acts.Pin, cr.behaviors.Platform.prototype.cnds.CompareSpeed, cr.plugins_.Particles.prototype.acts.SetSpraying, cr.plugins_.Particles.prototype.cnds.OnCreated, cr.plugins_.Particles.prototype.acts.SetAngle, cr.plugins_.Sprite.prototype.exps.Angle, cr.plugins_.Sprite.prototype.acts.SetPosToObject, cr.behaviors.Platform.prototype.exps.VectorX, cr.behaviors.LOS.prototype.acts.AddObstacle, cr.behaviors.LOS.prototype.cnds.HasLOSToObject, cr.behaviors.Turret.prototype.cnds.OnShoot, cr.behaviors.Turret.prototype.cnds.HasTarget, cr.behaviors.Turret.prototype.cnds.OnTargetAcquired, cr.plugins_.Sprite.prototype.cnds.OnCreated, cr.plugins_.Sprite.prototype.cnds.CompareOpacity, cr.plugins_.Sprite.prototype.cnds.IsOnScreen, cr.behaviors.Rotate.prototype.acts.SetSpeed, cr.system_object.prototype.cnds.OnLoadFinished, cr.plugins_.Particles.prototype.cnds.IsOnScreen, cr.plugins_.Spritefont2.prototype.acts.SetOpacity, cr.plugins_.Sprite.prototype.acts.ToggleBoolInstanceVar, cr.plugins_.Tilemap.prototype.acts.EraseTile, cr.plugins_.Tilemap.prototype.exps.PositionToTileX, cr.plugins_.Tilemap.prototype.exps.PositionToTileY, cr.plugins_.Sprite.prototype.acts.StopAnim, cr.plugins_.Spriter.prototype.acts.setAnimation, cr.plugins_.Tilemap.prototype.acts.SetTile, cr.plugins_.Tilemap.prototype.acts.SetTileRange, cr.plugins_.MagiCam.prototype.acts.CreateGlobalCamera, cr.plugins_.MagiCam.prototype.acts.TransitionToCamera, cr.plugins_.MagiCam.prototype.cnds.TransitionFinished, cr.plugins_.Spriter.prototype.acts.SetPos, cr.plugins_.Spriter.prototype.exps.X, cr.plugins_.Spriter.prototype.exps.Y, cr.plugins_.Text.prototype.acts.AppendText, cr.system_object.prototype.exps.zeropad, cr.plugins_.Spritefont2.prototype.acts.SetInstanceVar, cr.system_object.prototype.exps.random, cr.plugins_.Spritefont2.prototype.cnds.CompareInstanceVar, cr.plugins_.LocalStorage.prototype.acts.CheckItemExists, cr.plugins_.LocalStorage.prototype.cnds.IsProcessingGets, cr.plugins_.LocalStorage.prototype.cnds.OnAllSetsComplete, cr.system_object.prototype.acts.GoToLayout, cr.plugins_.Browser.prototype.acts.Reload, cr.plugins_.LocalStorage.prototype.acts.ClearStorage, cr.plugins_.LocalStorage.prototype.cnds.OnCleared, cr.system_object.prototype.cnds.Every, cr.plugins_.LocalStorage.prototype.cnds.OnItemExists, cr.plugins_.LocalStorage.prototype.acts.GetItem, cr.plugins_.LocalStorage.prototype.cnds.OnItemGet, cr.plugins_.LocalStorage.prototype.exps.ItemValue, cr.plugins_.LocalStorage.prototype.cnds.OnItemMissing, cr.plugins_.Sprite.prototype.acts.SetInstanceVar, cr.plugins_.Browser.prototype.exps.Domain ];};