// limit main image height to make sure we have space for the progress meter & copyright

! function() {
    define("skbJet/component/resourceLoader/resourceLib", [], function() {
        return {}
    }), define("skbJet/component/resourceLoader/Util", [], function() {
        var e = {};
        return e.httpGetJson = function(t, o, n) {
            e.httpGetText(t, function(e) {
                o(JSON.parse(e))
            }, n)
        }, e.httpGetText = function(e, t, o) {
            var n = new XMLHttpRequest;
            n.withCredentials = !0, n.addEventListener("load", function(e) {
                e.target.status >= 200 && e.target.status < 300 ? t(e.target.responseText) : o()
            }), n.addEventListener("error", o), n.addEventListener("timeout", o), n.open("GET", e), n.send()
        }, e.removeQueryStr = function(e) {
            var t = e.match(/(.*)\?/);
            return t ? t[1] : e
        }, e.getFileNameFromPath = function(e) {
            var t = e.match(/\/?([^\/]+)$/);
            return t ? t[1] : e
        }, e.getFileExt = function(t, o) {
            t = e.removeQueryStr(t), t = e.getFileNameFromPath(t);
            var n = t.match(/\.(\w+)$/);
            return n && n[1] ? o ? n[1].toLowerCase() : n[1] : null
        }, e.getFileNameWithoutExt = function(t) {
            t = e.removeQueryStr(t), t = e.getFileNameFromPath(t);
            var o = t.match(/(.*)(\.\w+)+$/);
            return o ? o[1] : t
        }, e.getParentFolder = function(t) {
            t = e.removeQueryStr(t);
            var o = e.getFileNameFromPath(t);
            return t.substring(0, t.length - o.length)
        }, e
    }), define("skbJet/component/resourceLoader/LoaderContext", [], function() {
        function e(e, t, o) {
            this.assetPackUrl = e, this.languageCode = t, this.skinCode = o, this.totalResAmount = 0, this.currentLoaded = 0, this.gameFolder = null, this.i18nParent = null, this.queryStr = "", window._cacheFlag && window._cacheFlag.queryStr && (this.queryStr = window._cacheFlag.queryStr), this.fileListMap = {
                i18n: null
            }, this.subLoaderMap = {}, this.onFileLoaded = function() {}, this.onLoadFailed = function() {}
        }
        return e
    }), define("skbJet/component/resourceLoader/LoaderChainHandler", [], function() {
        function e() {}
        return e.prototype.next = null, e.prototype.handle = null, e
    }), define("skbJet/component/resourceLoader/handlers/languageListHandler", ["skbJet/component/resourceLoader/Util", "skbJet/component/resourceLoader/LoaderChainHandler"], function(e, t) {
        function o(e, t) {
            for (var o = {}, n = 0; n < e.length; n++) o[e[n]] = [e[n].toLowerCase()], e[n].indexOf("_") > -1 ? o[e[n]].push(e[n].replace("_", "-").toLowerCase()) : e[n].indexOf("-") > -1 && o[e[n]].push(e[n].replace("-", "_").toLowerCase());
            var r;
            for (var a in o)
                if (o[a].indexOf("i18n/" + t.languageCode.toLowerCase() + ".json") >= 0) {
                    r = a.substring(a.lastIndexOf("/") + 1, a.lastIndexOf("."));
                    break
                }
            if (!r)
                for (var a in o)
                    if (o[a].indexOf("i18n/default.json") >= 0) {
                        r = a.substring(a.lastIndexOf("/") + 1, a.lastIndexOf("."));
                        break
                    }
            if (!r)
                for (var a in o)
                    if (o[a].indexOf("i18n/en.json") >= 0) {
                        r = a.substring(a.lastIndexOf("/") + 1, a.lastIndexOf("."));
                        break
                    }
            return !!r && (t.languageCode = r, !0)
        }

        function n(e) {
            var t = e.gameFolder,
                o = !1;
            if (window.location.search.match(/&?custom=true&?/) && (o = !0), window.gtk && window.gtk.jLottery && window.gtk.jLottery.embeddedParams && window.gtk.jLottery.embeddedParams.custom && (o = !0), o) {
                var n = e.gameFolder.match(/\/([^\/]+\/)$/)[1];
                t = "/custom_lang/" + e.skinCode + "/" + n
            }
            return t
        }
        var r = new t;
        return r.handle = function(t) {
            t.languageCode = t.languageCode || "default", t.languageCode = t.languageCode.toLowerCase();
            var a = t.assetPackUrl.substring(0, t.assetPackUrl.lastIndexOf("/"));
            t.gameFolder = a.substring(0, a.lastIndexOf("/") + 1), t.i18nParent = n(t), e.httpGetJson(t.i18nParent + "i18n.json" + t.queryStr, function(e) {
                o(e.i18n, t) ? r.next.handle(t) : t.onLoadFailed()
            }, t.onLoadFailed)
        }, r
    }), define("skbJet/component/resourceLoader/handlers/skinListHandler", ["skbJet/component/resourceLoader/Util", "skbJet/component/resourceLoader/LoaderChainHandler"], function(e, t) {
        function o(e, t) {
            for (var o = 0; o < e.length; o++) {
                var n = e[o];
                if (n = n.substring(n.lastIndexOf("/") + 1, n.lastIndexOf(".")), t.skinCode.toLowerCase() === n.toLowerCase()) return
            }
            t.skinCode = "default"
        }
        var n = new t;
        return n.handle = function(t) {
            t.skinCode = t.skinCode || "default";
            var r = t.i18nParent + "i18n/" + t.languageCode + ".json" + t.queryStr;
            e.httpGetJson(r, function(e) {
                o(e[t.languageCode], t), n.next.handle(t)
            }, t.onLoadFailed)
        }, n
    }), define("skbJet/component/resourceLoader/handlers/fileListHandler", ["skbJet/component/resourceLoader/Util", "skbJet/component/resourceLoader/LoaderChainHandler"], function(e, t) {
        function o(e, t, o, n) {
            n.fileListMap[e] || (n.fileListMap[e] = {});
            for (var r = 0; r < t.length; r++) n.fileListMap[e][t[r]] = o
        }

        function n(t, n) {
            var a = t.assetPackUrl + ".json" + t.queryStr;
            e.httpGetJson(a, function(e) {
                for (var a in e) o(a, e[a], t.gameFolder + "assetPacks/", t);
                var s = t.assetPackUrl.substring(t.assetPackUrl.lastIndexOf("assetPacks"));
                n && n.indexOf(t.skinCode + "/" + s + ".json") > -1 ? r(t, s) : i.next.handle(t)
            }, t.onLoadFailed)
        }

        function r(t, n) {
            var r = t.i18nParent + "i18n/" + t.languageCode + "/" + t.skinCode + "/",
                a = r + n + ".json" + t.queryStr;
            e.httpGetJson(a, function(e) {
                for (var n in e) o(n, e[n], r + "assetPacks/", t);
                i.next.handle(t)
            }, t.onLoadFailed)
        }

        function a(t) {
            var r = t.i18nParent + "i18n/",
                a = r + t.languageCode + "/",
                i = a + t.skinCode + ".json" + t.queryStr;
            e.httpGetJson(i, function(e) {
                o("i18n", e[t.skinCode], a, t), n(t, e.assetPacks)
            }, t.onLoadFailed)
        }
        var i = new t;
        return i.handle = a, i
    }), define("skbJet/component/resourceLoader/handlers/fileLoadHandler", ["skbJet/component/resourceLoader/LoaderChainHandler"], function(e) {
        function t(e, t, o) {
            setTimeout(function() {
                e.load(t, o)
            }, 1)
        }
        var o = new e;
        return o.handle = function(e) {
            for (var o in e.fileListMap) e.subLoaderMap[o] && t(e.subLoaderMap[o], e.fileListMap[o], {
                onFileLoaded: e.onFileLoaded,
                onLoadFailed: e.onLoadFailed,
                queryStr: e.queryStr
            })
        }, o.addSubLoader = function(e, t, o) {
            e.subLoaderMap[t] = o
        }, o.summary = function(e) {
            var t = 0,
                o = 0,
                n = !0;
            for (var r in e.fileListMap) e.subLoaderMap[r] && (t += e.subLoaderMap[r].getTotal(), o += e.subLoaderMap[r].getCurrent(), n = n && e.subLoaderMap[r].isComplete());
            return {
                total: t,
                current: o,
                complete: n
            }
        }, o
    }), define("skbJet/component/resourceLoader/ResourceLoader", ["skbJet/component/resourceLoader/Util", "skbJet/component/resourceLoader/LoaderContext", "skbJet/component/resourceLoader/handlers/languageListHandler", "skbJet/component/resourceLoader/handlers/skinListHandler", "skbJet/component/resourceLoader/handlers/fileListHandler", "skbJet/component/resourceLoader/handlers/fileLoadHandler"], function(e, t, o, n, r, a) {
        function i(e, i, s) {
            this.context = new t(e, i, s), this.loadChain = [o, n, r, a]
        }
        var s;
        return i.prototype.load = function(e, t) {
            for (var o = 0; o < this.loadChain.length - 1; o++) this.loadChain[o].next = this.loadChain[o + 1];
            this.context.onFileLoaded = e, this.context.onLoadFailed = t, this.loadChain[0].handle(this.context)
        }, i.prototype.addSubLoader = function(e, t) {
            a.addSubLoader(this.context, e, t)
        }, i.prototype.currentProgress = function() {
            return a.summary(this.context)
        }, i.initDefault = function(e, t, o) {
            if (s) throw "Default loader already inited.";
            s = new i(e, t, o)
        }, i.getDefault = function() {
            return s
        }, i
    }), define("skbJet/component/resourceLoader/AbstractSubLoader", ["skbJet/component/resourceLoader/Util", "skbJet/component/resourceLoader/resourceLib"], function(e, t) {
        function o() {}

        function n() {}
        return n.prototype._initOptions = function(e, o) {
            this._count = {
                total: 0,
                current: 0,
                complete: !1
            }, this.options = o || {}, this.options.type = this.options.type || e, t[this.options.type] || (t[this.options.type] = {})
        }, n.prototype.getTotal = function() {
            return this._count.total
        }, n.prototype.getCurrent = function() {
            return this._count.current
        }, n.prototype.isComplete = function() {
            return this._count.complete
        }, n.prototype._prepareLoad = function(e) {
            e = e || {}, this._count.total = 0, this._count.current = 0, e.queryStr = e.queryStr ? e.queryStr : "", e.onFileLoaded = e.onFileLoaded ? e.onFileLoaded : o, e.onLoadFailed = e.onLoadFailed ? e.onLoadFailed : o;
            for (var t in e) this.options[t] = e[t]
        }, n.prototype.load = function(o, n) {
            this._prepareLoad(n);
            var r = [];
            for (var a in o)
                if (o[a]) {
                    if (this.options.fileExtFilterList) {
                        var i = e.getFileExt(a, !0);
                        if (this.options.fileExtFilterList.indexOf(i) < 0) continue
                    }
                    this._count.total++, r.push(a)
                }
            if (0 === this._count.total) return this._count.complete = !0, void this.options.onFileLoaded();
            for (var s = this, d = 0; d < r.length; d++) {
                var a = r[d];
                this._doLoadFile(o[a] + a + this.options.queryStr, function(e) {
                    return function(o) {
                        s._count.current++, s._count.current === s._count.total && (s._count.complete = !0), t[s.options.type] = t[s.options.type] || {}, t[s.options.type][e] = o, s.options.onFileLoaded()
                    }
                }(e.getFileNameWithoutExt(a)), this.options.onLoadFailed)
            }
        }, n.prototype._doLoadFile = function(e, t, o) {
            throw "Not implemented yet. Params: url:" + e + "   success:" + t + "   fail:" + o
        }, n
    }), define("skbJet/component/resourceLoader/subLoaders/HtmlTagSubLoader", ["skbJet/component/resourceLoader/Util", "skbJet/component/resourceLoader/AbstractSubLoader"], function(e, t) {
        function o(e) {
            this._initOptions("_html_tags", e)
        }
        return o.prototype = new t, o.prototype._doLoadFile = function(e, t, o) {
            var n = document.createElement(this.options.tagName);
            if (n.onload = function() {
                    t(n)
                }, n.onerror = o, this.options.parentTag && this.options.parentTag.appendChild(n), this.options.tagAttributes)
                for (var r in this.options.tagAttributes) n.setAttribute(r, this.options.tagAttributes[r]);
            n.src = e
        }, o
    }), define("skbJet/component/resourceLoader/subLoaders/TextFilesSubLoader", ["skbJet/component/resourceLoader/Util", "skbJet/component/resourceLoader/AbstractSubLoader"], function(e, t) {
        function o(e) {
            this._initOptions("_text_files", e)
        }
        return o.prototype = new t, o.prototype._doLoadFile = function(t, o, n) {
            "json" === e.getFileExt(t, !0) && this.options.parseJson ? e.httpGetJson(t, o, n) : e.httpGetText(t, o, n)
        }, o
    }), define("splash/splashLoadController", ["skbJet/component/resourceLoader/ResourceLoader", "skbJet/component/resourceLoader/subLoaders/HtmlTagSubLoader", "skbJet/component/resourceLoader/subLoaders/TextFilesSubLoader"], function(e, t, o) {
        function n(n) {
            var r = window.location.search.match(/&?assetPack=(\w+)&?/)[1],
                a = window.location.search.match(/&?language=([^&]+)&?/)[1],
                i = window.location.search.match(/&?skincode=(\w+)&?/)[1];
            e.initDefault("assetPacks/" + r, a, i);
            var s = e.getDefault(),
                d = new o({
                    type: "i18n",
                    parseJson: !0
                });
            d.origLoad = d.load, d.load = function(e, t) {
                for (var o in e) o.match(/splash\.json$/) || delete e[o];
                this.origLoad(e, t)
            }, s.addSubLoader("i18n", d), s.addSubLoader("splashSprites", new o({
                type: "splash",
                parseJson: !0,
                fileExtFilterList: ["json"]
            })), s.addSubLoader("splash", new t({
                type: "splash",
                tagName: "img",
                fileExtFilterList: ["jpg", "png"]
            })), s.load(function() {
                s.currentProgress().total === s.currentProgress().current && n && n()
            }, function() {})
        }
        return {
            load: n
        }
    }), define("splash", ["skbJet/component/resourceLoader/resourceLib", "splash/splashLoadController"], function(e, t) {
        function o() {
            u.clearRect(0, 0, d.width, d.height);
            var t = e.splash.loading,
                o = s[Math.floor(L) % s.length],
                n = Math.min(t.width, d.width),
                r = n / (t.width / t.height);
            r = Math.min(r, d.height - o.sourceSize.h - 65), n = r / (t.height / t.width);
            var a = Math.max(0, d.height / 3 - r / 2),
                i = a + r + (d.height - (a + r)) / 2;
            i = Math.min(i, d.height - 25 - o.sourceSize.h / 2);
            var p = i - 65;
            u.save(), u.translate(.5 * d.width, 0), u.drawImage(t, n / -2, a, n, r), u.restore(), u.save(), u.fillStyle = "#ffffff", u.textAlign = "center", u.save(), u.translate(.5 * d.width, i), u.font = "bold 20px Oswald, sans-serif", u.textBaseline = "middle", u.fillText(f + "%", 0, 0);
            var m = e.splash.activityAnimBackground;
            u.drawImage(m, m.width / -2, m.height / -2);
            var g = e.splash.loaderSprite.meta.scale;
            u.scale(1 / g, 1 / g), u.drawImage(e.splash.loaderAnim, o.frame.x, o.frame.y, o.frame.w, o.frame.h, o.spriteSourceSize.x - o.sourceSize.w * o.pivot.x, o.spriteSourceSize.y - o.sourceSize.h * o.pivot.y, o.spriteSourceSize.w, o.spriteSourceSize.h), u.restore(), u.save(), u.translate(.5 * d.width, d.height - 10), u.font = "bold 16px Oswald, sans-serif", u.fillText(l, 0, 0), u.restore(), u.save(), u.textAlign = "left", u.font = "bold 16px Oswald, sans-serif", u.textBaseline = "middle";
            var w = u.measureText(c).width,
                b = u.measureText(h).width,
                v = Math.round(w + b);
            d.width - 20 < v && (u.font = "bold 12px Oswald, sans-serif", w = u.measureText(c).width, b = u.measureText(h).width, v = Math.round(w + b)), u.translate(.5 * d.width - v / 2, p), u.fillStyle = "#00e4ff", u.fillText(c, 0, 0), u.fillStyle = "#fce759", u.fillText(h, w, 0), u.restore(), u.restore()
        }

        function n(e) {
            e.data && e.data.loaded && (f = e.data.loaded)
        }

        function r() {
            d.width = window.innerWidth, d.height = window.innerHeight
        }

        function a() {
            var e = Date.now(),
                t = Math.min(50, e - p);
            (f < 100 || window.frameElement && "block" === window.frameElement.style.display) && (p = e, requestAnimationFrame(a)), L += t / (1e3 / 30), o()
        }

        function i() {
            l = e.i18n.splash.splashScreen.footer.shortVersion, c = e.i18n.splash.splashScreen.featureText, h = e.i18n.splash.splashScreen.featureTextTwo, s = e.splash.loaderSprite.frames, r(), a(), window.addEventListener("resize", r), window.addEventListener("message", n, !1)
        }
        var s, d = document.getElementById("loadingCanvas"),
            u = d.getContext("2d"),
            l = "",
            c = "",
            h = "",
            f = 0,
            p = Date.now(),
            L = 0;
        return function() {
            t.load(i)
        }(), {}
    })
}();