Skip to content

Instantly share code, notes, and snippets.

@joahg
Created January 3, 2014 20:37
Show Gist options
  • Save joahg/8246112 to your computer and use it in GitHub Desktop.
Save joahg/8246112 to your computer and use it in GitHub Desktop.
This file has been truncated, but you can view the full file.
define("models/composer/file", ["require", "exports", "module", "backbone"], function (e, t, n) {
var r = e("backbone");
n.exports = r.Model.extend({})
}), define("collections/composer/files", ["require", "exports", "module", "collections/api/base", "models/composer/file"], function (e, t, n) {
var r = e("collections/api/base"),
i = e("models/composer/file");
n.exports = r.extend({
model: i,
namesepace: "files"
})
}), define("models/composer/submission", ["require", "exports", "module", "backbone", "underscore"], function (e, t, n) {
var r = e("backbone"),
i = e("underscore");
n.exports = r.Model.extend({
initialize: function () {
this.resetTimer()
},
resetTimer: function () {
this.submissionTimer = Date.now()
},
url: function () {
return "/composer/" + this.get("project_id") + "/checkpoint/" + this.get("checkpoint_id") + "/submit"
},
save: function (e) {
i.extend(e, {
created_at: Math.floor(Date.now() / 1e3),
elapsed_time: Date.now() - this.submissionTimer
}), this.resetTimer(), r.Model.prototype.save.apply(this, arguments)
}
})
}), define("models/composer/checkpoint", ["require", "exports", "module", "models/api/base", "backbone", "collections/composer/files", "models/composer/submission", "underscore"], function (e, t, n) {
var r = e("models/api/base"),
i = e("backbone"),
s = e("collections/composer/files"),
o = e("models/composer/submission"),
u = e("underscore");
n.exports = r.extend({
initialize: function (e, t) {
t = t || {}, this.project = t.project || new i.Model, this.isValid() || this.unset("latest_files"), this._initializeFileAttribute("latest_files"), this._initializeFileAttribute("default_files"), this.get("latest_files") && this._bindFileChangeListeners(this.get("latest_files"))
},
validate: function () {
if (this.get("latest_files")) {
var e = this.get("latest_files").length === 0 || !u.isEqual(u.pluck(this.get("latest_files"), "filename"), u.pluck(this.get("default_files"), "filename"));
if (e) return "Invalid latest_files"
}
},
url: function () {
return "/composer/" + this.project.get("id") + "/checkpoint/" + this.id
},
total: function () {
var e = this.project.get("checkpoints").length;
return e < 10 ? "0" + e : e
},
_initializeFileAttribute: function (e) {
this.get(e) && this.set(e, this._cleanFiles(this.get(e)), {
silent: !0
})
},
_cleanFiles: function (e) {
return e instanceof s ? e : new s(e)
},
_cloneFiles: function (e) {
return e = e || [], new s(e.map(function (e) {
return e.clone()
}))
},
clonedFiles: function () {
return this._cloneFiles(this.files())
},
_bindFilePersistenceListeners: function (e) {
e.once("add remove reset sort destroy change", function () {
this.set("latest_files", e, {
silent: !0
})
}, this)
},
_bindFileChangeListeners: function (e) {
e.on("change:content", this.trigger.bind(this, "file:changed"))
},
files: function () {
var e = this.get("latest_files"),
t = this.get("default_files"),
n = this.get("index"),
r = !this.get("code_reset"),
i = this.collection && this.collection.length >= n ? this.collection.at(n - 1) : null,
s, o;
if (n === 0 && this.collection && this.collection.length >= n && this.project.get("index") !== 0) {
var u = this.project.course.get("projects").at(this.project.get("index") - 1);
i = u.get("checkpoints").at(u.get("checkpoints_count") - 1)
}
return e ? (o = !0, s = e) : r && i && i.get("latest_files") ? (o = !1, s = i.clonedFiles()) : (o = !1, s = this._cloneFiles(t)), o || (this._bindFilePersistenceListeners(s), this._bindFileChangeListeners(s)), s
},
fileByName: function (e) {
return this.files().find(function (t) {
return t.get("filename") === e
})
},
default_files: function () {
var e = this.get("default_files");
return e ? e.toJSON() : []
},
resetFiles: function () {
return this.unset("latest_files"), this.files()
},
author: function () {
return this.project.get("author")
},
project_name: function () {
return this.project.get("name")
},
is_current_checkpoint: function () {
return this.project.is_current_project() && this.project.get("cp_index") === this.get("index")
},
toJSON: function () {
return r.prototype.toJSON.call(this, {
methods: ["total", "files", "default_files", "author", "project_name", "is_current_checkpoint"]
})
},
setAnswer: function () {
this.set("latest_files", new s(this.get("answer")))
},
newSubmission: function () {
return this.submission = new o({
checkpoint_id: this.id,
curriculum_id: this.project.getCurriculumId(),
project_id: this.project.get("id")
}), this.submission
},
saveSubmission: function (e, t) {
t = t || {};
var n = t.success;
return t.success = function () {
n && n.apply(this, arguments)
}, e.latest_files = this.files().toJSON(), e.correct && this.set("completed", !0), this.submission.save(e, t)
}
})
}), define("collections/composer/checkpoints", ["require", "exports", "module", "collections/api/base", "models/composer/checkpoint"], function (e, t, n) {
var r = e("collections/api/base"),
i = e("models/composer/checkpoint");
n.exports = r.extend({
model: i,
namesepace: "checkpoints"
})
}), define("models/composer/project", ["require", "exports", "module", "backbone", "models/api/base", "collections/composer/checkpoints"], function (e, t, n) {
var r = e("backbone"),
i = e("models/api/base"),
s = e("collections/composer/checkpoints");
n.exports = i.extend({
defaults: {
cp_index: 0
},
initialize: function (e, t) {
t = t || {}, this.course = t.course || new r.Model, this.set("checkpoints", new s(e.checkpoints, {
project: this
}))
},
gotoNextCheckpoint: function () {
if (this.has_next()) {
var e = this.get("cp_index") + 1;
return this.set("cp_index", e), !0
}
return !1
},
gotoPrevCheckpoint: function () {
if (this.has_prev()) {
var e = this.get("cp_index") - 1;
return this.set("cp_index", e), !0
}
return !1
},
getCurrentCheckpoint: function () {
return this.get("checkpoints").at(this.get("cp_index"))
},
getCurriculumId: function () {
return this.course.get("curriculum_id")
},
is_web: function () {
return this.course.get("mode") === "web"
},
is_server: function () {
return this.course.get("mode") === "server"
},
has_next: function () {
return this.get("cp_index") < this.get("checkpoints").length - 1
},
prompt_signup: function () {
return CCDATA.current_user === undefined
},
has_prev: function () {
return this.get("cp_index") >= 1
},
return_to: function () {
return CCDATA.composer.goal_return_to ? {
goal_url: CCDATA.composer.goal_return_to
} : this.course.get("return_to")
},
is_admin: function () {
try {
return CCDATA.current_user.roles.indexOf("admin") !== -1
} catch (e) {
return !1
}
},
is_non_codex_web_course: function () {
return this.course.get("language") === "Web" && !this.course.get("is_php")
},
has_successor: function () {
return this.course.has_next()
},
is_current_project: function () {
return this.course.get("project_index") === this.get("index")
},
completed_checkpoints_count: function () {
return this.get("checkpoints").filter(function (e) {
return e.get("completed")
}).length
},
toJSON: function () {
var e = i.prototype.toJSON.call(this, {
methods: ["is_web", "is_server", "has_next", "is_admin", "prompt_signup", "has_successor", "is_current_project", "completed_checkpoints_count", "return_to"]
});
return e.checkpoints = this.get("checkpoints").toJSON(), e
}
})
}), define("collections/composer/projects", ["require", "exports", "module", "collections/api/base", "models/composer/project"], function (e, t, n) {
var r = e("collections/api/base"),
i = e("models/composer/project");
n.exports = r.extend({
model: i,
namesepace: "projects"
})
}), define("models/composer/mediator", ["require", "exports", "module", "backbone"], function (e, t, n) {
var r = e("backbone"),
i = r.Model.extend({
init: function (e) {
this.course = e, this.setCurrentProject(e.getCurrentProject()), this.listenTo(this.course, "change:project_index", function () {
this.setCurrentProject(this.course.getCurrentProject());
var e = [].slice.call(arguments);
e.unshift("change:project_index"), this.trigger.apply(this, e)
})
},
setCurrentProject: function (e) {
this.project && this.stopListening(this.project), this.project = e, this.listenTo(this.project, "change:cp_index", this.trigger.bind(this, "change:cp_index"))
},
getCurrentCheckpoint: function () {
return this.project.get("checkpoints").at(this.project.get("cp_index"))
},
getMode: function () {
return this.course.get("mode")
},
setEvaluator: function (e) {
if (this.evaluator) throw new Error("Cannot reset evaluator");
this.evaluator = e, this.listenTo(this.evaluator, "all", function (e) {
var t = [].slice.call(arguments, 1);
t.unshift("evaluator:" + e), this.trigger.apply(this, t)
}), this.on("evaluator:run", function (e) {
this.evaluator.run(e)
})
},
isCodex: function () {
return this.course.get("is_php") || ["python", "ruby"].indexOf(this.course.get("language").toLowerCase()) > -1
},
navigate: function (e, t) {
this.course.get("project_index") !== e ? (this.course.get("projects").at(e).set("cp_index", t), this.course.set("project_index", e)) : this.project.set("cp_index", t)
}
});
n.exports = new i
}), define("models/composer/course", ["require", "exports", "module", "models/api/base", "collections/composer/projects", "models/composer/mediator"], function (e, t, n) {
var r = e("models/api/base"),
i = e("collections/composer/projects"),
s = e("models/composer/mediator");
n.exports = r.extend({
defaults: {
project_index: 0
},
initialize: function (e) {
this.set("projects", new i(e.projects, {
course: this
}))
},
gotoNextProject: function () {
if (this.has_next()) {
var e = this.get("project_index") + 1;
return this.set("project_index", e), !0
}
return !1
},
gotoPrevProject: function () {
if (this.has_prev()) {
var e = this.get("project_index") - 1;
return this.set("project_index", e), !0
}
return !1
},
getCurrentProject: function () {
return this.get("projects").at(this.get("project_index"))
},
is_web: function () {
return this.get("mode") === "web"
},
is_server: function () {
return this.get("mode") === "server"
},
has_next: function () {
return this.get("project_index") < this.get("projects").length - 1
},
has_prev: function () {
return this.get("project_index") >= 1
},
prompt_signup: function () {
return CCDATA.current_user === undefined
},
is_admin: function () {
try {
return CCDATA.current_user.roles.indexOf("admin") !== -1
} catch (e) {
return !1
}
},
getProgressExercises: function () {
var e = this.get("projects"),
t = 0,
n = 0,
r = s.project.get("index"),
i = s.project.get("cp_index");
return e.forEach(function (e) {
r > 0 ? t += e.get("checkpoints_count") : r === 0 && (t += i + 1), r--, n += e.get("checkpoints_count")
}), {
index: t,
total: n
}
}
})
}), define("views/composer/base_view", ["require", "exports", "module", "libs/utils", "jquery", "underscore"], function (e, t, n) {
var r = e("libs/utils"),
i = e("jquery"),
s = e("underscore");
n.exports = {
template: function () {
var e = this.options.templateName || s.result(this, "templateName");
return r.template(e).apply(this, s.toArray(arguments))
},
destroy: function () {
this._destroy && this._destroy(), this.$el.off(), i.cleanData(this.$el), this.$el.empty(), this.stopListening(), this.destroySubviews(), this.undelegateEvents()
},
getSubview: function (e) {
if (this._subviews) return this._subviews[e]
},
setSubview: function (e, t) {
return this._subviews = this._subviews || {}, this._subviews[e] = this[e] = t, this._subviews
},
initSubview: function (e, t) {
t = t || {};
var n = this.getSubviewClass(e),
r = new n(t);
return this.setSubview(e, r), r
},
renderSubviews: function (e) {
s.each(e, function (e, t) {
this.renderSubview(t, e)
}, this)
},
renderSubview: function (e, t) {
this.ensureSubviewDestroyed(e);
var n = this.initSubview(e, t);
n.render()
},
ensureSubviewDestroyed: function (e) {
this.getSubview(e) && this.destroySubview(e)
},
destroySubview: function (e) {
var t = this.getSubview(e);
this.setSubview(e, null), t.destroy(), this.stopListening(t)
},
destroySubviews: function () {
this.destroyAllSubviews()
},
destroyAllSubviews: function () {
s(this._subviews).each(function (e, t) {
this.destroySubview(t)
}, this), this._subviews = {}
},
defineSubviews: function (e) {
s.each(e, function (e, t) {
this.setSubviewClass(t, e)
}, this)
},
setSubviewClass: function (e, t) {
this._viewKlasses = this._viewKlasses || {}, this._viewKlasses[e] = t
},
getSubviewClass: function (e) {
if (this._viewKlasses) return this._viewKlasses[e]
}
}
}), ! function (e) {
e(function () {
"use strict";
e.support.transition = function () {
var t = document.body || document.documentElement,
n = t.style,
r = n.transition !== undefined || n.WebkitTransition !== undefined || n.MozTransition !== undefined || n.MsTransition !== undefined || n.OTransition !== undefined;
return r && {
end: function () {
var t = "TransitionEnd";
return e.browser.webkit ? t = "webkitTransitionEnd" : e.browser.mozilla ? t = "transitionend" : e.browser.opera && (t = "oTransitionEnd"), t
}()
}
}()
})
}(window.jQuery), define("plugins/bootstrap-transition", function () {}), ! function (e) {
var t = function (t, n) {
this.$element = e(t), this.options = e.extend({}, e.fn.collapse.defaults, n), this.options.parent && (this.$parent = e(this.options.parent)), this.options.toggle && this.toggle()
};
t.prototype = {
constructor: t,
dimension: function () {
var e = this.$element.hasClass("width");
return e ? "width" : "height"
},
show: function () {
var t, n, r, i;
if (this.transitioning || this.$element.hasClass("in")) return;
t = this.dimension(), n = e.camelCase(["scroll", t].join("-")), r = this.$parent && this.$parent.find("> .accordion-group > .in");
if (r && r.length) {
i = r.data("collapse");
if (i && i.transitioning) return;
r.collapse("hide"), i || r.data("collapse", null)
}
this.$element[t](0), this.transition("addClass", e.Event("show"), "shown"), e.support.transition && this.$element[t](this.$element[0][n])
},
hide: function () {
var t;
if (this.transitioning || !this.$element.hasClass("in")) return;
t = this.dimension(), this.reset(this.$element[t]()), this.transition("removeClass", e.Event("hide"), "hidden"), this.$element[t](0)
},
reset: function (e) {
var t = this.dimension();
return this.$element.removeClass("collapse")[t](e || "auto")[0].offsetWidth, this.$element[e !== null ? "addClass" : "removeClass"]("collapse"), this
},
transition: function (t, n, r) {
var i = this,
s = function () {
n.type == "show" && i.reset(), i.transitioning = 0, i.$element.trigger(r)
};
this.$element.trigger(n);
if (n.isDefaultPrevented()) return;
this.transitioning = 1, this.$element[t]("in"), e.support.transition && this.$element.hasClass("collapse") ? this.$element.one(e.support.transition.end, s) : s()
},
toggle: function () {
this[this.$element.hasClass("in") ? "hide" : "show"]()
}
};
var n = e.fn.collapse;
e.fn.collapse = function (n) {
return this.each(function () {
var r = e(this),
i = r.data("collapse"),
s = e.extend({}, e.fn.collapse.defaults, r.data(), typeof n == "object" && n);
i || r.data("collapse", i = new t(this, s)), typeof n == "string" && i[n]()
})
}, e.fn.collapse.defaults = {
toggle: !0
}, e.fn.collapse.Constructor = t, e.fn.collapse.noConflict = function () {
return e.fn.collapse = n, this
}, e(document).on("click.collapse.data-api", "[data-toggle=collapse]", function (t) {
var n = e(this),
r, i = n.attr("data-target") || t.preventDefault() || (r = n.attr("href")) && r.replace(/.*(?=#[^\s]+$)/, ""),
s = e(i).data("collapse") ? "toggle" : n.data();
n[e(i).hasClass("in") ? "addClass" : "removeClass"]("collapsed"), e(i).collapse(s)
})
}(window.jQuery), define("plugins/bootstrap-collapse", function () {}),
function (e, t, n) {
var r, i, s, o, u, a, f, l, c, h, p, d, v, m, g, y, b, w, E, S, x;
S = {
paneClass: "pane",
sliderClass: "slider",
contentClass: "content",
iOSNativeScrolling: !1,
preventPageScrolling: !1,
disableResize: !1,
alwaysVisible: !1,
flashDelay: 1500,
sliderMinHeight: 20,
sliderMaxHeight: null,
documentContext: null,
windowContext: null
}, y = "scrollbar", g = "scroll", l = "mousedown", c = "mousemove", p = "mousewheel", h = "mouseup", m = "resize", u = "drag", w = "up", v = "panedown", s = "DOMMouseScroll", o = "down", E = "wheel", a = "keydown", f = "keyup", b = "touchmove", r = t.navigator.appName === "Microsoft Internet Explorer" && /msie 7./i.test(t.navigator.appVersion) && t.ActiveXObject, i = null, x = function () {
var e, t, r;
return e = n.createElement("div"), t = e.style, t.position = "absolute", t.width = "100px", t.height = "100px", t.overflow = g, t.top = "-9999px", n.body.appendChild(e), r = e.offsetWidth - e.clientWidth, n.body.removeChild(e), r
}, d = function () {
function a(r, s) {
this.el = r, this.options = s, i || (i = x()), this.$el = e(this.el), this.doc = e(this.options.documentContext || n), this.win = e(this.options.windowContext || t), this.$content = this.$el.children("." + s.contentClass), this.$content.attr("tabindex", 0), this.content = this.$content[0], this.options.iOSNativeScrolling && this.el.style.WebkitOverflowScrolling != null ? this.nativeScrolling() : this.generate(), this.createEvents(), this.addEvents(), this.reset()
}
return a.prototype.preventScrolling = function (e, t) {
if (!this.isActive) return;
if (e.type === s)(t === o && e.originalEvent.detail > 0 || t === w && e.originalEvent.detail < 0) && e.preventDefault();
else if (e.type === p) {
if (!e.originalEvent || !e.originalEvent.wheelDelta) return;
(t === o && e.originalEvent.wheelDelta < 0 || t === w && e.originalEvent.wheelDelta > 0) && e.preventDefault()
}
}, a.prototype.nativeScrolling = function () {
this.$content.css({
WebkitOverflowScrolling: "touch"
}), this.iOSNativeScrolling = !0, this.isActive = !0
}, a.prototype.updateScrollValues = function () {
var e;
e = this.content, this.maxScrollTop = e.scrollHeight - e.clientHeight, this.prevScrollTop = this.contentScrollTop || 0, this.contentScrollTop = e.scrollTop, this.iOSNativeScrolling || (this.maxSliderTop = this.paneHeight - this.sliderHeight, this.sliderTop = this.contentScrollTop * this.maxSliderTop / this.maxScrollTop)
}, a.prototype.createEvents = function () {
var e = this;
this.events = {
down: function (t) {
return e.isBeingDragged = !0, e.offsetY = t.pageY - e.slider.offset().top, e.pane.addClass("active"), e.doc.bind(c, e.events[u]).bind(h, e.events[w]), !1
},
drag: function (t) {
return e.sliderY = t.pageY - e.$el.offset().top - e.offsetY, e.scroll(), e.updateScrollValues(), e.contentScrollTop >= e.maxScrollTop && e.prevScrollTop !== e.maxScrollTop ? e.$el.trigger("scrollend") : e.contentScrollTop === 0 && e.prevScrollTop !== 0 && e.$el.trigger("scrolltop"), !1
},
up: function (t) {
return e.isBeingDragged = !1, e.pane.removeClass("active"), e.doc.unbind(c, e.events[u]).unbind(h, e.events[w]), !1
},
resize: function (t) {
e.reset()
},
panedown: function (t) {
return e.sliderY = (t.offsetY || t.originalEvent.layerY) - e.sliderHeight * .5, e.scroll(), e.events.down(t), !1
},
scroll: function (t) {
if (e.isBeingDragged) return;
e.updateScrollValues(), e.iOSNativeScrolling || (e.sliderY = e.sliderTop, e.slider.css({
top: e.sliderTop
}));
if (t == null) return;
e.contentScrollTop >= e.maxScrollTop ? (e.options.preventPageScrolling && e.preventScrolling(t, o), e.prevScrollTop !== e.maxScrollTop && e.$el.trigger("scrollend")) : e.contentScrollTop === 0 && (e.options.preventPageScrolling && e.preventScrolling(t, w), e.prevScrollTop !== 0 && e.$el.trigger("scrolltop"))
},
wheel: function (t) {
var n;
if (t == null) return;
return n = t.delta || t.wheelDelta || t.originalEvent && t.originalEvent.wheelDelta || -t.detail || t.originalEvent && -t.originalEvent.detail, n && (e.sliderY += -n / 3), e.scroll(), !1
}
}
}, a.prototype.addEvents = function () {
var e;
this.removeEvents(), e = this.events, this.options.disableResize || this.win.bind(m, e[m]), this.iOSNativeScrolling || (this.slider.bind(l, e[o]), this.pane.bind(l, e[v]).bind("" + p + " " + s, e[E])), this.$content.bind("" + g + " " + p + " " + s + " " + b, e[g])
}, a.prototype.removeEvents = function () {
var e;
e = this.events, this.win.unbind(m, e[m]), this.iOSNativeScrolling || (this.slider.unbind(), this.pane.unbind()), this.$content.unbind("" + g + " " + p + " " + s + " " + b, e[g])
}, a.prototype.generate = function () {
var e, t, n, r, s;
return n = this.options, r = n.paneClass, s = n.sliderClass, e = n.contentClass, !this.$el.find("" + r).length && !this.$el.find("" + s).length && this.$el.append('<div class="' + r + '"><div class="' + s + '" /></div>'), this.pane = this.$el.children("." + r), this.slider = this.pane.find("." + s), i && (t = {
right: -i
}, this.$el.addClass("has-scrollbar")), t != null && this.$content.css(t), this
}, a.prototype.restore = function () {
this.stopped = !1, this.pane.show(), this.addEvents()
}, a.prototype.reset = function () {
var e, t, n, s, o, u, a, f, l, c;
if (this.iOSNativeScrolling) {
this.contentHeight = this.content.scrollHeight;
return
}
return this.$el.find("." + this.options.paneClass).length || this.generate().stop(), this.stopped && this.restore(), e = this.content, n = e.style, s = n.overflowY, r && this.$content.css({
height: this.$content.height()
}), t = e.scrollHeight + i, l = parseInt(this.$el.css("max-height"), 10), l > 0 && (this.$el.height(""), this.$el.height(e.scrollHeight > l ? l : e.scrollHeight)), u = this.pane.outerHeight(), f = parseInt(this.pane.css("top"), 10), o = parseInt(this.pane.css("bottom"), 10), a = u + f + o, c = Math.round(a / t * a), c < this.options.sliderMinHeight ? c = this.options.sliderMinHeight : this.options.sliderMaxHeight != null && c > this.options.sliderMaxHeight && (c = this.options.sliderMaxHeight), s === g && n.overflowX !== g && (c += i), this.maxSliderTop = a - c, this.contentHeight = t, this.paneHeight = u, this.paneOuterHeight = a, this.sliderHeight = c, this.slider.height(c), this.events.scroll(), this.pane.show(), this.isActive = !0, e.scrollHeight === e.clientHeight || this.pane.outerHeight(!0) >= e.scrollHeight && s !== g ? (this.pane.hide(), this.isActive = !1) : this.el.clientHeight === e.scrollHeight && s === g ? this.slider.hide() : this.slider.show(), this.pane.css({
opacity: this.options.alwaysVisible ? 1 : "",
visibility: this.options.alwaysVisible ? "visible" : ""
}), this
}, a.prototype.scroll = function () {
if (!this.isActive) return;
return this.sliderY = Math.max(0, this.sliderY), this.sliderY = Math.min(this.maxSliderTop, this.sliderY), this.$content.scrollTop((this.paneHeight - this.contentHeight + i) * this.sliderY / this.maxSliderTop * -1), this.iOSNativeScrolling || this.slider.css({
top: this.sliderY
}), this
}, a.prototype.scrollBottom = function (e) {
if (!this.isActive) return;
return this.reset(), this.$content.scrollTop(this.contentHeight - this.$content.height() - e).trigger(p), this
}, a.prototype.scrollTop = function (e) {
if (!this.isActive) return;
return this.reset(), this.$content.scrollTop(+e).trigger(p), this
}, a.prototype.scrollTo = function (t) {
if (!this.isActive) return;
return this.reset(), this.scrollTop(e(t).get(0).offsetTop), this
}, a.prototype.stop = function () {
return this.stopped = !0, this.removeEvents(), this.pane.hide(), this
}, a.prototype.destroy = function () {
return this.stopped || this.stop(), this.pane.length && this.pane.remove(), r && this.$content.height(""), this.$content.removeAttr("tabindex"), this.$el.hasClass("has-scrollbar") && (this.$el.removeClass("has-scrollbar"), this.$content.css({
right: ""
})), this
}, a.prototype.flash = function () {
var e = this;
if (!this.isActive) return;
return this.reset(), this.pane.addClass("flashed"), setTimeout(function () {
e.pane.removeClass("flashed")
}, this.options.flashDelay), this
}, a
}(), e.fn.nanoScroller = function (t) {
return this.each(function () {
var n, r;
(r = this.nanoscroller) || (n = e.extend({}, S, t), this.nanoscroller = r = new d(this, n));
if (t && typeof t == "object") {
e.extend(r.options, t);
if (t.scrollBottom) return r.scrollBottom(t.scrollBottom);
if (t.scrollTop) return r.scrollTop(t.scrollTop);
if (t.scrollTo) return r.scrollTo(t.scrollTo);
if (t.scroll === "bottom") return r.scrollBottom(0);
if (t.scroll === "top") return r.scrollTop(0);
if (t.scroll && t.scroll instanceof e) return r.scrollTo(t.scroll);
if (t.stop) return r.stop();
if (t.destroy) return r.destroy();
if (t.flash) return r.flash()
}
return r.reset()
})
}
}(jQuery, window, document), define("plugins/jquery.nanoscroller", function () {}), ! function (e) {
var t = function (e, t) {
this.init("tooltip", e, t)
};
t.prototype = {
constructor: t,
init: function (t, n, r) {
var i, s;
this.type = t, this.$element = e(n), this.options = this.getOptions(r), this.enabled = !0, this.options.trigger != "manual" && (i = this.options.trigger == "hover" ? "mouseenter" : "focus", s = this.options.trigger == "hover" ? "mouseleave" : "blur", this.$element.on(i, this.options.selector, e.proxy(this.enter, this)), this.$element.on(s, this.options.selector, e.proxy(this.leave, this))), this.options.selector ? this._options = e.extend({}, this.options, {
trigger: "manual",
selector: ""
}) : this.fixTitle()
},
getOptions: function (t) {
return t = e.extend({}, e.fn[this.type].defaults, t, this.$element.data()), t.delay && typeof t.delay == "number" && (t.delay = {
show: t.delay,
hide: t.delay
}), t
},
enter: function (t) {
var n = e(t.currentTarget)[this.type](this._options).data(this.type);
if (!n.options.delay || !n.options.delay.show) return n.show();
clearTimeout(this.timeout), n.hoverState = "in", this.timeout = setTimeout(function () {
n.hoverState == "in" && n.show()
}, n.options.delay.show)
},
leave: function (t) {
var n = e(t.currentTarget)[this.type](this._options).data(this.type);
if (!n.options.delay || !n.options.delay.hide) return n.hide();
clearTimeout(this.timeout), n.hoverState = "out", this.timeout = setTimeout(function () {
n.hoverState == "out" && n.hide()
}, n.options.delay.hide)
},
show: function () {
var e, t, n, r, i, s, o;
if (this.hasContent() && this.enabled) {
e = this.tip(), this.setContent(), this.options.animation && e.addClass("fade"), s = typeof this.options.placement == "function" ? this.options.placement.call(this, e[0], this.$element[0]) : this.options.placement, t = /in/.test(s), e.remove().css({
top: 0,
left: 0,
display: "block"
}).appendTo(t ? this.$element : document.body), n = this.getPosition(t), r = e[0].offsetWidth, i = e[0].offsetHeight;
switch (t ? s.split(" ")[1] : s) {
case "bottom":
o = {
top: n.top + n.height,
left: n.left + n.width / 2 - r / 2
};
break;
case "top":
o = {
top: n.top - i,
left: n.left + n.width / 2 - r / 2
};
break;
case "left":
o = {
top: n.top + n.height / 2 - i / 2,
left: n.left - r
};
break;
case "right":
o = {
top: n.top + n.height / 2 - i / 2,
left: n.left + n.width
}
}
e.css(o).addClass(s).addClass("in")
}
},
isHTML: function (e) {
return typeof e != "string" || e.charAt(0) === "<" && e.charAt(e.length - 1) === ">" && e.length >= 3 || /^(?:[^<]*<[\w\W]+>[^>]*$)/.exec(e)
},
setContent: function () {
var e = this.tip(),
t = this.getTitle();
e.find(".tooltip-inner")[this.isHTML(t) ? "html" : "text"](t), e.removeClass("fade in top bottom left right")
},
hide: function () {
function r() {
var t = setTimeout(function () {
n.off(e.support.transition.end).remove()
}, 500);
n.one(e.support.transition.end, function () {
clearTimeout(t), n.remove()
})
}
var t = this,
n = this.tip();
n.removeClass("in"), e.support.transition && this.$tip.hasClass("fade") ? r() : n.remove()
},
fixTitle: function () {
var e = this.$element;
(e.attr("title") || typeof e.attr("data-original-title") != "string") && e.attr("data-original-title", e.attr("title") || "").removeAttr("title")
},
hasContent: function () {
return this.getTitle()
},
getPosition: function (t) {
return e.extend({}, t ? {
top: 0,
left: 0
} : this.$element.offset(), {
width: this.$element[0].offsetWidth,
height: this.$element[0].offsetHeight
})
},
getTitle: function () {
var e, t = this.$element,
n = this.options;
return e = t.attr("data-original-title") || (typeof n.title == "function" ? n.title.call(t[0]) : n.title), e
},
tip: function () {
return this.$tip = this.$tip || e(this.options.template)
},
validate: function () {
this.$element[0].parentNode || (this.hide(), this.$element = null, this.options = null)
},
enable: function () {
this.enabled = !0
},
disable: function () {
this.enabled = !1
},
toggleEnabled: function () {
this.enabled = !this.enabled
},
toggle: function () {
this[this.tip().hasClass("in") ? "hide" : "show"]()
}
}, e.fn.tooltip = function (n) {
return this.each(function () {
var r = e(this),
i = r.data("tooltip"),
s = typeof n == "object" && n;
i || r.data("tooltip", i = new t(this, s)), typeof n == "string" && i[n]()
})
}, e.fn.tooltip.Constructor = t, e.fn.tooltip.defaults = {
animation: !0,
placement: "top",
selector: !1,
template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',
trigger: "hover",
title: "",
delay: 0
}
}(window.jQuery), define("plugins/bootstrap-tooltip", function () {}), define("libs/statsd", ["require", "exports", "module", "jquery"], function (e, t, n) {
var r = e("jquery"),
i = "/stats/v1/batch",
s = function (e) {
e = e || {}, this.FLUSH_INTERVAL = (e.flushInterval || 10) * 1e3, this.QUEUE_LIMIT = e.queueLimit || 10, this.flushUrl = e.flushUrl, this._statsdQueue = [], this._flushTimeout = null, e.stopped || this._startIntervalFlush(), this._registerBeforeUnload()
};
(function () {
this._preparedData = function () {
return {
data: this._statsdQueue
}
}, this._flush = function () {
r.ajax({
type: "POST",
url: this.flushUrl,
data: JSON.stringify(this._preparedData()),
contentType: "application/json"
}), this._statsdQueue = []
}, this._flushIfNecessary = function () {
this._statsdQueue.length > 0 && this._flush()
}, this._record = function (e, t, n, r) {
var i = {
name: e,
payload: {
measurement: t,
action: n
}
};
r != null && (i.payload.value = r), this._statsdQueue.push(i), setTimeout(this._flushIfOverflow.bind(this), 0)
}, this._flushIfOverflow = function () {
if (this._statsdQueue.length >= this.QUEUE_LIMIT) {
var e = !1;
this._flushTimeout !== null && (this._stopIntervalFlush(), e = !0), this._flush(), e && this._startIntervalFlush()
}
}, this._stopIntervalFlush = function () {
clearTimeout(this._flushTimeout), this._flushTimeout = null
}, this._startIntervalFlush = function () {
this._flushIfNecessary(), this._flushTimeout = setTimeout(this._startIntervalFlush.bind(this), this.FLUSH_INTERVAL)
}, this._registerBeforeUnload = function () {
r(window).on("beforeunload", this._flushIfNecessary.bind(this))
}, this.increment = function (e, t) {
this._record(e, t, "increment", null)
}, this.decrement = function (e, t) {
this._record(e, t, "decrement", null)
}, this.gauge = function (e, t, n) {
this._record(e, t, "gauge", n)
}, this.timing = function (e, t, n) {
this._record(e, t, "timing", n)
}, this.set = function (e, t, n) {
this._record(e, t, "set", n)
}
}).call(s.prototype), n.exports = new s({
flushUrl: i
})
}), define("presenters/composer/educational", ["require", "exports", "module"], function (e, t, n) {
n.exports = function (e) {
var t = e.checkpoint.toJSON();
return t.projects = e.course.get("projects").toJSON(), t.course_name = e.course.get("name"), t.course_exercises_index = e.course.getProgressExercises().index, t.course_exercises_total = e.course.getProgressExercises().total, t
}
}), define("views/composer/educational", ["require", "exports", "module", "plugins/bootstrap-transition", "plugins/bootstrap-collapse", "plugins/jquery.nanoscroller", "plugins/bootstrap-tooltip", "backbone", "views/composer/base_view", "underscore", "models/composer/mediator", "highlightjs", "jquery", "libs/statsd", "libs/utils", "presenters/composer/educational"], function (e, t, n) {
e("plugins/bootstrap-transition"), e("plugins/bootstrap-collapse"), e("plugins/jquery.nanoscroller"), e("plugins/bootstrap-tooltip");
var r = e("backbone"),
i = e("views/composer/base_view"),
s = e("underscore"),
o = e("models/composer/mediator"),
u = e("highlightjs"),
a = e("jquery"),
f = e("libs/statsd"),
l = e("libs/utils"),
c = e("presenters/composer/educational");
n.exports = r.View.extend({
templateName: "composer/_educational",
el: ".js-lesson-left-bar",
events: {
"click .ui-accordian__trigger": "toggleHint",
"click .js-show-checkpoints": "showCheckpoints",
"click .js-switch-checkpoint": "checkpointNav",
"click .js-toggle-left-bar": "toggleShow",
"click .js-section": "toggleSection"
},
initialize: function () {
a(document).on("click", ":not(.checkpoints-container)", this.hideCheckpoints.bind(this)), this.listenTo(o, "change:project_index", this.changeForumUrl)
},
changeForumUrl: function (e, t) {
var n = t.toString(),
r = a(".lesson-links__link").eq(0),
i = r.attr("href").split("/").slice(0, 3);
r.attr("href", i.concat(n).join("/"))
},
_initScroll: function () {
l.isMobile() ? (this.$(".nano__content").removeClass("content"), this.$(".lesson-checkpoint").css({
overflow: "auto",
"-webkit-overflow-scrolling": "touch"
})) : this.$(".nano").nanoScroller()
},
render: function () {
var e = this;
if (this.$el.is(":empty")) {
var t = c({
checkpoint: this.model,
course: o.course
});
this.$el.html(this.template(t))
}
return this._initScroll(), this.$(".lesson-completed-ribbon").tooltip({
placement: "left"
}), this.$(".ui-accordian").on("transitionEnd webkitTransitionEnd transitionend oTransitionEnd msTransitionEnd", function (t) {
if (t.originalEvent.propertyName === "max-height") {
var n = e.$(t.currentTarget);
n.hasClass("is-expanded") && n.css("max-height", 9999)
}
}), this.highlightCode(), this.initDropDown(), this
},
TRANSITION_SPEED: 260,
toggleHint: function (e) {
var t = this.$(".nano__content"),
n = this.$(e.currentTarget),
r = n.closest(".ui-accordian"),
i = n.outerHeight(),
s = r.children(".ui-accordian__inner").outerHeight(!0),
o = 250;
r.toggleClass("is-expanded"), r.hasClass("is-expanded") ? (f.increment("composer", "hint-open"), r.addClass("transition--max-height").css({
"max-height": i + s
}), t.animate({
scrollTop: t.scrollTop() + r.offset().top - t.offset().top
}, {
duration: o,
easing: "swing"
})) : (r.removeClass("transition--max-height").css({
"max-height": i + s
}), setTimeout(function () {
r.addClass("transition--max-height").css({
"max-height": i
})
}, 10)), setTimeout(this._initScroll.bind(this, null), this.TRANSITION_SPEED)
},
checkpointNav: function (e) {
var t = parseInt(a(e.currentTarget).data("index"), 10),
n = parseInt(a(e.currentTarget).closest(".js-section__content").data("index"), 10);
o.navigate(n, t)
},
_toggleCheckpoints: function (e) {
this.$el.toggleClass("js-showing-checkpoints", e), this.$(".js-checkpoints").toggleClass("is-shown", e), this.$(".js-checkpoints-overlay").toggleClass("is-shown", e), this.$(".js-show-checkpoints").toggleClass("is-active", e), this.$(".js-course-name").toggleClass("is-active", e)
},
showCheckpoints: function (e) {
e.stopPropagation();
if (this.$el.hasClass("js-showing-checkpoints")) return this.hideCheckpoints();
this._toggleCheckpoints(!0)
},
hideCheckpoints: function () {
this._toggleCheckpoints(!1)
},
highlightCode: function () {
this.$("code").each(function (e, t) {
u.highlightBlock(t)
})
},
toggleShow: function () {
this.$el.parent().toggleClass("is-collapsed"), a("body").toggleClass("is-left-bar__collapsed")
},
initDropDown: function () {
this.$(".js-section").not(".is-active").next(".js-section__content").collapse("hide"), this.$(".js-section").filter(".is-active").next(".js-section__content").collapse("show")
},
toggleSection: function (e) {
e.stopPropagation();
var t = a(e.currentTarget);
if (t.hasClass("is-active")) return !1;
this.$(".js-section.is-active").removeClass("is-active").next(".js-section__content").collapse("hide"), t.addClass("is-active").next(".js-section__content").collapse("show")
}
}), s.extend(n.exports.prototype, i)
}),
function (e) {
function r(r, s, o) {
function l() {
a.handshake(), f || (o(a), f = !0)
}
typeof s == "function" && (o = s, s = null), o || (o = n), s || (s = document.querySelector("body"));
var u = document.createElement("iframe"),
a = new i(u);
e.addEventListener("message", a.messageHandler.bind(a), !1), t.push(u), u.setAttribute("scrolling", "no"), u.setAttribute("src", r), a.on("size", function (e) {
e === undefined ? e = a._size : a._size = e;
var t = $(a.iframe.parentNode).width(),
n = t / (e.width + 20);
n > 1 && (n = 1);
var r = {
height: 1 / n * 100 + "%",
width: 1 / n * 100 + "%"
};
r[Modernizr.prefixed("transform")] = "scale(" + n + ")", $(a.iframe).css(r)
});
var f = !1;
u.addEventListener("load", l, !1), s.appendChild(u)
}
function i(e) {
this.iframe = e, this.callbacks = {}, this.eventQ = {
load: [],
evaljs: [],
html: []
}, this.secret = Math.ceil(Math.random() * 999999999) + 1
}
var t = [],
n = function () {};
r.clear = function () {
t.forEach(function (e) {
var t = e.parentElement;
t && t.removeChild(e)
}), t = []
}, i.prototype.handle = function (e, t) {
var n = this,
r;
if (e === "custom") {
var i = t;
r = this.callbacks[i.type] || [], r.forEach(function (e) {
typeof e == "function" && e.call(e.thisArg || n, i.data)
})
} else {
r = this.eventQ[e];
if (!r) return;
var s = r.shift();
typeof s == "function" && s.call(s.thisArg || n, t)
}
}, i.prototype.messageHandler = function (e) {
var t;
try {
t = JSON.parse(e.data)
} catch (n) {
return
}
if (t.secret !== this.secret) return;
var r = t.data,
i = t.type;
this.handle(i, r)
}, i.prototype.post = function (e, t) {
this.iframe.contentWindow.postMessage(JSON.stringify({
type: e,
data: t,
secret: this.secret
}), "*")
}, i.prototype.evaljs = function (t, r, i) {
var s = function (t) {
var i = t.error,
s = i,
o;
i && (o = e[i.__errorType__]) && (s = new o(i.message), s.stack = i.stack, s.type = i.type, s.arguments = i.arguments), (r || n).call(this, s, t.result)
};
s.thisArg = i, this.eventQ.evaljs.push(s), this.post("evaljs", t)
}, i.prototype.load = function (e, t, r) {
t = t || n, t.thisArg = r, this.eventQ.load.push(t), this.post("load", e)
}, i.prototype.html = function (e, t) {
e = e || n, e.thisArg = t, this.eventQ.html.push(e), this.post("html", null)
}, i.prototype.handshake = function () {
this.post("handshake", this.secret)
}, i.prototype.on = function (e, t, r) {
t = t || n, t.thisArg = r, this.callbacks[e] ? this.callbacks[e].push(t) : this.callbacks[e] = [t]
}, i.prototype.trigger = i.prototype.handle, i.prototype.off = function (e, t) {
var n = this.callbacks[e];
if (n) {
var r = n.indexOf(t);
r !== -1 && n.splice(r, 1)
} else this.callbacks[e] = []
}, r.Context = i, e.stuff = r
}(this), define("vendor/stuff", function (e) {
return function () {
return e.stuff
}
}(this)), define("libs/composer/stuff", ["require", "exports", "module", "vendor/stuff"], function (e, t, n) {
var r = e("vendor/stuff"),
i = CCDATA.env !== "production" ? "//" + window.location.host + "/assets/secure/index.dev.html" : "http://external.codecademy.com/assets/secure/index.html?v2";
n.exports = function () {
var e = [].slice.call(arguments);
e.unshift(i), r.apply(null, e)
}
}), define("views/composer/mini_preview", ["require", "exports", "module", "backbone", "views/composer/base_view", "libs/composer/stuff", "models/composer/mediator", "libs/utils", "jquery", "underscore"], function (e, t, n) {
var r = e("backbone"),
i = e("views/composer/base_view"),
s = e("libs/composer/stuff"),
o = e("models/composer/mediator"),
u = e("libs/utils"),
a = e("jquery"),
f = e("underscore");
n.exports = r.View.extend({
templateName: "composer/_mini_preview",
tInitMiniWeb: u.template("composer/init_mini_web.js"),
el: ".mini-preview",
initialize: function () {
this.listenTo(o, "web:reloadCode", this.load, this);
var e = this;
a(window).on("resize." + this.cid, function () {
e.context.trigger("size")
})
},
render: function () {
return this.$el.is(":empty") && this.$el.html(this.template()), this.initContext(), this
},
initContext: function () {
var e = this;
s(e.$(".frame-wrap").get(0), function (t) {
e.context = t, t.trigger("size"), o.trigger("miniPreview:ready")
})
},
reset: function () {
var e = {
height: "",
width: ""
};
e[Modernizr.prefixed("transform")] = "", this.$("iframe").css(e)
},
load: function (e) {
if (this.context === undefined) return;
var t = this;
this.context.load(e, function () {
this.context.evaljs("document.title;", function (e, t) {
this.setTitle(t)
}, this)
}, this), this.context.evaljs(t.tInitMiniWeb({
width: a(window).width()
}))
},
setTitle: function (e) {
var t = document.title,
n = t.split("|").slice(-2);
e && n.unshift(e), document.title = n.map(function (e) {
return " " + e.trim() + " "
}).join("|").trim()
},
destroy: function () {
a(window).off("resize." + this.cid), i.destroy.call(this)
}
}), f.extend(n.exports.prototype, i)
}),
function (e) {
e.fn.insideOf = function (t) {
var n = this[0];
return n.parentNode ? n == t ? !0 : e(n.parentNode).insideOf(t) : !1
}
}(jQuery), define("plugins/jquery.insideof", function () {}), define("widgets/actions_dropdown", ["require", "exports", "module", "backbone", "jquery", "underscore", "plugins/jquery.insideof"], function (e, t, n) {
var r = e("backbone"),
i = e("jquery"),
s = e("underscore");
e("plugins/jquery.insideof"), n.exports = r.View.extend({
events: {
"click .js-open-dropdown": "_toggle",
"click .js-close": "close"
},
initialize: function (e) {
this.setElement(e.$el), this.$opener = this.$(".actions-dropdown__opener"), this.$content = this.$(".actions-dropdown__content"), this.$arrow = this.$(".actions-dropdown__arrow-container")
},
_maxWidth: function (e) {
return Math.max.apply(Math, e.map(function () {
return i(this).outerWidth(!0)
}))
},
close: function () {
this.$el.removeClass("is-open"), setTimeout(function () {
this.$el.removeClass("is-visible")
}.bind(this), 200)
},
open: function () {
this.$el.addClass("is-visible");
var e = this._maxWidth(this.$(".actions-list .actions-list__text")),
t = (20 + e) * 1.4;
this.$content.css("width", t + "px");
var n = this.$opener.outerWidth(),
r = this.$arrow.outerWidth(),
i = this.$content.outerWidth();
this.$content.css("right", n / 2 - i / 2), this.$arrow.css("right", i / 2 - r / 2), s.defer(function () {
this.$el.addClass("is-open")
}.bind(this))
},
_isOpen: function () {
return this.$el.hasClass("is-visible")
},
_toggle: function () {
this._isOpen() ? this.close() : this.open(), this.$content.is(":visible") && i(document).one("mouseup", function (e) {
i(e.target).insideOf(this.$el[0]) || this.close()
}.bind(this))
}
})
}),
function () {
var e, t, n, r, i, s, o, u, a, f, l, c, h, p, d, v, m, g, y, b, w, E, S, x, T, N, C, k, L, A, O, M, _, D, P, H, B, j = function (e, t) {
return function () {
return e.apply(t, arguments)
}
}, F = [].slice;
e = jQuery, D = 0, P = 1, H = 2, T = 13, O = 9, E = 46, w = 8, C = 37, A = 39, M = 38, S = 40, N = 36, x = 35, L = 33, k = 34, a = "jqconsole-", i = "" + a + "cursor", s = "" + a + "header", f = "" + a + "prompt", u = "" + a + "old-prompt", o = "" + a + "input", r = "" + a + "blurred", y = "keypress", v = "<span/>", p = "<div/>", d = ":empty", _ = "\n", h = ">>> ", c = "... ", l = 2, n = "" + a + "ansi-", m = "", g = /\[(\d*)(?:;(\d*))*m/, t = function () {
function e() {
this.stylize = j(this.stylize, this), this._closeSpan = j(this._closeSpan, this), this._openSpan = j(this._openSpan, this), this.getClasses = j(this.getClasses, this), this._style = j(this._style, this), this._color = j(this._color, this), this._remove = j(this._remove, this), this._append = j(this._append, this), this.klasses = []
}
return e.prototype.COLORS = ["black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"], e.prototype._append = function (e) {
e = "" + n + e;
if (this.klasses.indexOf(e) === -1) return this.klasses.push(e)
}, e.prototype._remove = function () {
var e, t, r, i, s, o;
r = 1 <= arguments.length ? F.call(arguments, 0) : [], o = [];
for (i = 0, s = r.length; i < s; i++) t = r[i], t === "fonts" || t === "color" || t === "background-color" ? o.push(this.klasses = function () {
var r, i, s, o;
s = this.klasses, o = [];
for (r = 0, i = s.length; r < i; r++) e = s[r], e.indexOf(t) !== n.length && o.push(e);
return o
}.call(this)) : (t = "" + n + t, o.push(this.klasses = function () {
var n, r, i, s;
i = this.klasses, s = [];
for (n = 0, r = i.length; n < r; n++) e = i[n], e !== t && s.push(e);
return s
}.call(this)));
return o
}, e.prototype._color = function (e) {
return this.COLORS[e]
}, e.prototype._style = function (e) {
e === "" && (e = 0), e = parseInt(e);
if (isNaN(e)) return;
switch (e) {
case 0:
return this.klasses = [];
case 1:
return this._append("bold");
case 2:
return this._append("lighter");
case 3:
return this._append("italic");
case 4:
return this._append("underline");
case 5:
return this._append("blink");
case 6:
return this._append("blink-rapid");
case 8:
return this._append("hidden");
case 9:
return this._append("line-through");
case 10:
return this._remove("fonts");
case 11:
case 12:
case 13:
case 14:
case 15:
case 16:
case 17:
case 18:
case 19:
return this._remove("fonts"), this._append("fonts-" + (e - 10));
case 20:
return this._append("fraktur");
case 21:
return this._remove("bold", "lighter");
case 22:
return this._remove("bold", "lighter");
case 23:
return this._remove("italic", "fraktur");
case 24:
return this._remove("underline");
case 25:
return this._remove("blink", "blink-rapid");
case 28:
return this._remove("hidden");
case 29:
return this._remove("line-through");
case 30:
case 31:
case 32:
case 33:
case 34:
case 35:
case 36:
case 37:
return this._remove("color"), this._append("color-" + this._color(e - 30));
case 39:
return this._remove("color");
case 40:
case 41:
case 42:
case 43:
case 44:
case 45:
case 46:
case 47:
return this._remove("background-color"), this._append("background-color-" + this._color(e - 40));
case 49:
return this._remove("background-color");
case 51:
return this._append("framed");
case 53:
return this._append("overline");
case 54:
return this._remove("framed");
case 55:
return this._remove("overline")
}
}, e.prototype.getClasses = function () {
return this.klasses.join(" ")
}, e.prototype._openSpan = function (e) {
return '<span class="' + this.getClasses() + '">' + e
}, e.prototype._closeSpan = function (e) {
return "" + e + "</span>"
}, e.prototype.stylize = function (e) {
var t, n, r, i, s, o;
e = this._openSpan(e), r = 0;
while ((r = e.indexOf(m, r)) && r !== -1)
if (n = e.slice(r).match(g)) {
o = n.slice(1);
for (i = 0, s = o.length; i < s; i++) t = o[i], this._style(t);
e = this._closeSpan(e.slice(0, r)) + this._openSpan(e.slice(r + 1 + n[0].length))
} else r++;
return this._closeSpan(e)
}, e
}(), B = function (e, t) {
return '<span class="' + e + '">' + (t || "") + "</span>"
}, b = function () {
function n(n, r, i, o) {
this.container = n, this._HideComposition = j(this._HideComposition, this), this._ShowComposition = j(this._ShowComposition, this), this._UpdateComposition = j(this._UpdateComposition, this), this._EndComposition = j(this._EndComposition, this), this._StartComposition = j(this._StartComposition, this), this._CheckComposition = j(this._CheckComposition, this), this._ProcessMatch = j(this._ProcessMatch, this), this._HandleKey = j(this._HandleKey, this), this._HandleChar = j(this._HandleChar, this), this.isMobile = !! navigator.userAgent.match(/iPhone|iPad|iPod|Android/i), this.isIos = !! navigator.userAgent.match(/iPhone|iPad|iPod/i), this.isAndroid = !! navigator.userAgent.match(/Android/i), this.$window = e(window), this.header = r || "", this.prompt_label_main = typeof i == "string" ? i : h, this.prompt_label_continue = o || c, this.indent_width = l, this.state = P, this.input_queue = [], this.input_callback = null, this.multiline_callback = null, this.history = [], this.history_index = 0, this.history_new = "", this.history_active = !1, this.shortcuts = {}, this.$console = e('<pre class="jqconsole"/>').appendTo(this.container), this.$console.css({
position: "absolute",
top: 0,
bottom: 0,
right: 0,
left: 0,
margin: 0,
overflow: "auto"
}), this.$console_focused = !0, this.$input_container = e(p).appendTo(this.container), this.$input_container.css({
position: "relative",
width: 1,
height: 0,
top: -999999,
overflow: "hidden"
}), this.$input_source = e("<textarea/>"), this.$input_source.attr({
wrap: "off",
autocapitalize: "off",
autocorrect: "off",
spellcheck: "false",
autocomplete: "off"
}), this.$input_source.css({
position: "absolute",
width: 2
}), this.$input_source.appendTo(this.$input_container), this.$composition = e(p), this.$composition.addClass("" + a + "composition"), this.$composition.css({
display: "inline",
position: "relative"
}), this.matchings = {
openings: {},
closings: {},
clss: []
}, this.ansi = new t, this._InitPrompt(), this._SetupEvents(), this.Write(this.header, s), e(this.container).data("jqconsole", this)
}
return n.prototype.ResetHistory = function () {
return this.SetHistory([])
}, n.prototype.ResetShortcuts = function () {
return this.shortcuts = {}
}, n.prototype.ResetMatchings = function () {
return this.matchings = {
openings: {},
closings: {},
clss: []
}
}, n.prototype.Reset = function () {
return this.state !== P && this.ClearPromptText(!0), this.state = P, this.input_queue = [], this.input_callback = null, this.multiline_callback = null, this.ResetHistory(), this.ResetShortcuts(), this.ResetMatchings(), this.$prompt.detach(), this.$input_container.detach(), this.$console.html(""), this.$prompt.appendTo(this.$console), this.$input_container.appendTo(this.container), this.Write(this.header, s), void 0
}, n.prototype.GetHistory = function () {
return this.history
}, n.prototype.SetHistory = function (e) {
return this.history = e.slice(), this.history_index = this.history.length
}, n.prototype._CheckKeyCode = function (e) {
isNaN(e) ? e = e.charCodeAt(0) : e = parseInt(e, 10);
if (0 < e && e < 256 && !isNaN(e)) return e;
throw new Error("Key code must be a number between 0 and 256 exclusive.")
}, n.prototype._LetterCaseHelper = function (e, t) {
t(e), 65 <= e && e <= 90 && t(e + 32);
if (97 <= e && e <= 122) return t(e - 32)
}, n.prototype.RegisterShortcut = function (e, t) {
var n, r = this;
e = this._CheckKeyCode(e);
if (typeof t != "function") throw new Error("Callback must be a function, not " + t + ".");
return n = function (e) {
return e in r.shortcuts || (r.shortcuts[e] = []), r.shortcuts[e].push(t)
}, this._LetterCaseHelper(e, n), void 0
}, n.prototype.UnRegisterShortcut = function (e, t) {
var n, r = this;
return e = this._CheckKeyCode(e), n = function (e) {
if (e in r.shortcuts) return t ? r.shortcuts[e].splice(r.shortcuts[e].indexOf(t), 1) : delete r.shortcuts[e]
}, this._LetterCaseHelper(e, n), void 0
}, n.prototype.GetColumn = function () {
var e;
return this.$prompt_cursor.text(""), e = this.$console.text().split(_), this.$prompt_cursor.html("&nbsp;"), e[e.length - 1].length
}, n.prototype.GetLine = function () {
return this.$console.text().split(_).length - 1
}, n.prototype.ClearPromptText = function (e) {
if (this.state === P) throw new Error("ClearPromptText() is not allowed in output state.");
return this.$prompt_before.html(""), this.$prompt_after.html(""), this.$prompt_label.text(e ? "" : this._SelectPromptLabel(!1)), this.$prompt_left.text(""), this.$prompt_right.text(""), void 0
}, n.prototype.GetPromptText = function (t) {
var n, r, i, s, o;
if (this.state === P) throw new Error("GetPromptText() is not allowed in output state.");
return t ? (this.$prompt_cursor.text(""), o = this.$prompt.text(), this.$prompt_cursor.html("&nbsp;"), o) : (s = function (t) {
var n;
return n = [], t.children().each(function () {
return n.push(e(this).children().last().text())
}), n.join(_)
}, r = s(this.$prompt_before), r && (r += _), i = this.$prompt_left.text() + this.$prompt_right.text(), n = s(this.$prompt_after), n && (n = _ + n), r + i + n)
}, n.prototype.SetPromptText = function (e) {
if (this.state === P) throw new Error("SetPromptText() is not allowed in output state.");
return this.ClearPromptText(!1), this._AppendPromptText(e), this._ScrollToEnd(), void 0
}, n.prototype.SetPromptLabel = function (e, t) {
return this.prompt_label_main = e, t != null && (this.prompt_label_continue = t), void 0
}, n.prototype.Write = function (t, n, r) {
var i;
return r == null && (r = !0), r && (t = this.ansi.stylize(e(v).text(t).html())), i = e(v).html(t), n != null && i.addClass(n), this.Append(i)
}, n.prototype.Append = function (t) {
var n;
return n = e(t).insertBefore(this.$prompt), this._ScrollToEnd(), this.$prompt_cursor.detach().insertAfter(this.$prompt_left), n
}, n.prototype.Input = function (e) {
var t, n, r, i, s = this;
if (this.state === H) r = this.input_callback, i = this.multiline_callback, n = this.history_active, t = this.async_multiline, this.AbortPrompt(), this.input_queue.unshift(function () {
return s.Prompt(n, r, i, t)
});
else if (this.state !== P) {
this.input_queue.push(function () {
return s.Input(e)
});
return
}
return this.history_active = !1, this.input_callback = e, this.multiline_callback = null, this.state = D, this.$prompt.attr("class", o), this.$prompt_label.text(this._SelectPromptLabel(!1)), this.Focus(), this._ScrollToEnd(), void 0
}, n.prototype.Prompt = function (e, t, n, r) {
var i = this;
if (this.state !== P) {
this.input_queue.push(function () {
return i.Prompt(e, t, n, r)
});
return
}
return this.history_active = e, this.input_callback = t, this.multiline_callback = n, this.async_multiline = r, this.state = H, this.$prompt.attr("class", f + " " + this.ansi.getClasses()), this.$prompt_label.text(this._SelectPromptLabel(!1)), this.Focus(), this._ScrollToEnd(), void 0
}, n.prototype.AbortPrompt = function () {
if (this.state !== H) throw new Error("Cannot abort prompt when not in prompt state.");
return this.Write(this.GetPromptText(!0) + _, u), this.ClearPromptText(!0), this.state = P, this.input_callback = this.multiline_callback = null, this._CheckInputQueue(), void 0
}, n.prototype.Focus = function () {
return this.IsDisabled() || this.$input_source.focus(), void 0
}, n.prototype.SetIndentWidth = function (e) {
return this.indent_width = e
}, n.prototype.GetIndentWidth = function () {
return this.indent_width
}, n.prototype.RegisterMatching = function (e, t, n) {
var r;
return r = {
opening_char: e,
closing_char: t,
cls: n
}, this.matchings.clss.push(n), this.matchings.openings[e] = r, this.matchings.closings[t] = r
}, n.prototype.UnRegisterMatching = function (e, t) {
var n;
return n = this.matchings.openings[e].cls, delete this.matchings.openings[e], delete this.matchings.closings[t], this.matchings.clss.splice(this.matchings.clss.indexOf(n), 1)
}, n.prototype.Dump = function () {
var t, n;
return t = this.$console.find("." + s).nextUntil("." + f),
function () {
var r, i, s;
s = [];
for (r = 0, i = t.length; r < i; r++) n = t[r], e(n).is("." + u) ? s.push(e(n).text().replace(/^\s+/, ">>> ")) : s.push(e(n).text());
return s
}().join(" ")
}, n.prototype.GetState = function () {
return this.state === D ? "input" : this.state === P ? "output" : "prompt"
}, n.prototype.Disable = function () {
return this.$input_source.attr("disabled", !0), this.$input_source.blur()
}, n.prototype.Enable = function () {
return this.$input_source.attr("disabled", !1)
}, n.prototype.IsDisabled = function () {
return Boolean(this.$input_source.attr("disabled"))
}, n.prototype.MoveToStart = function (e) {
return this._MoveTo(e, !0), void 0
}, n.prototype.MoveToEnd = function (e) {
return this._MoveTo(e, !1), void 0
}, n.prototype._CheckInputQueue = function () {
if (this.input_queue.length) return this.input_queue.shift()()
}, n.prototype._InitPrompt = function () {
this.$prompt = e(B(o)).appendTo(this.$console), this.$prompt_before = e(v).appendTo(this.$prompt), this.$prompt_current = e(v).appendTo(this.$prompt), this.$prompt_after = e(v).appendTo(this.$prompt), this.$prompt_label = e(v).appendTo(this.$prompt_current), this.$prompt_left = e(v).appendTo(this.$prompt_current), this.$prompt_right = e(v).appendTo(this.$prompt_current), this.$prompt_right.css({
position: "relative"
}), this.$prompt_cursor = e(B(i, "&nbsp;")), this.$prompt_cursor.insertBefore(this.$prompt_right), this.$prompt_cursor.css({
color: "transparent",
display: "inline",
zIndex: 0
});
if (!this.isMobile) return this.$prompt_cursor.css("position", "absolute")
}, n.prototype._SetupEvents = function () {
var t, n, i = this;
this.isMobile ? this.$console.click(function (e) {
return e.preventDefault(), i.Focus()
}) : this.$console.mouseup(function (e) {
var t;
return e.which === 2 ? i.Focus() : (t = function () {
if (!window.getSelection().toString()) return e.preventDefault(), i.Focus()
}, setTimeout(t, 0))
}), this.$input_source.focus(function () {
var e, t;
return i._ScrollToEnd(), i.$console_focused = !0, i.$console.removeClass(r), t = function () {
if (i.$console_focused) return i.$console.removeClass(r)
}, setTimeout(t, 100), e = function () {
if (i.isIos && i.$console_focused) return i.$input_source.hide()
}, setTimeout(e, 500)
}), this.$input_source.blur(function () {
var e;
return i.$console_focused = !1, i.isIos && i.$input_source.show(), e = function () {
if (!i.$console_focused) return i.$console.addClass(r)
}, setTimeout(e, 100)
}), n = e.browser.opera ? "input" : "paste", this.$input_source.bind(n, function () {
var e;
return e = function () {
if (i.in_composition) return;
return i._AppendPromptText(i.$input_source.val()), i.$input_source.val(""), i.Focus()
}, setTimeout(e, 0)
}), this.$input_source.keypress(this._HandleChar), this.$input_source.keydown(this._HandleKey), this.$input_source.keydown(this._CheckComposition), e.browser.mozilla != null && (this.$input_source.bind("compositionstart", this._StartComposition), this.$input_source.bind("compositionend", this._EndCommposition), this.$input_source.bind("text", this._UpdateComposition));
if (e.browser.opera != null) return t = function () {
if (i.in_composition) return;
if (i.$input_source.val().length) return i._StartComposition()
}, setInterval(t, 200)
}, n.prototype._HandleChar = function (e) {
var t, n;
return this.state === P || e.metaKey || e.ctrlKey ? !0 : (t = e.which, t === 8 || t === 9 || t === 13 ? !1 : (n = String.fromCharCode(t), n.length === 0 ? !0 : (this.$prompt_left.text(this.$prompt_left.text() + n), this._ScrollToEnd(), !1)))
}, n.prototype._HandleKey = function (t) {
var n;
if (this.state === P) return !0;
n = t.keyCode || t.which, setTimeout(e.proxy(this._CheckMatchings, this), 0);
if (t.altKey) return !0;
if (t.ctrlKey || t.metaKey) return this._HandleCtrlShortcut(n);
if (t.shiftKey) {
switch (n) {
case T:
this._HandleEnter(!0);
break;
case O:
this._Unindent();
break;
case M:
this._MoveUp();
break;
case S:
this._MoveDown();
break;
case L:
this._ScrollUp();
break;
case k:
this._ScrollDown();
break;
default:
return !0
}
return !1
}
switch (n) {
case T:
this._HandleEnter(!1);
break;
case O:
this._Indent();
break;
case E:
this._Delete(!1);
break;
case w:
this._Backspace(!1);
break;
case C:
this._MoveLeft(!1);
break;
case A:
this._MoveRight(!1);
break;
case M:
this._HistoryPrevious();
break;
case S:
this._HistoryNext();
break;
case N:
this.MoveToStart(!1);
break;
case x:
this.MoveToEnd(!1);
break;
case L:
this._ScrollUp();
break;
case k:
this._ScrollDown();
break;
default:
return !0
}
return !1
}, n.prototype._HandleCtrlShortcut = function (e) {
var t, n, r, i;
switch (e) {
case E:
this._Delete(!0);
break;
case w:
this._Backspace(!0);
break;
case C:
this._MoveLeft(!0);
break;
case A:
this._MoveRight(!0);
break;
case M:
this._MoveUp();
break;
case S:
this._MoveDown();
break;
case x:
this.MoveToEnd(!0);
break;
case N:
this.MoveToStart(!0);
break;
default:
if (e in this.shortcuts) {
i = this.shortcuts[e];
for (n = 0, r = i.length; n < r; n++) t = i[n], t.call(this);
return !1
}
return !0
}
return !1
}, n.prototype._HandleEnter = function (e) {
var t, n, r = this;
return e ? this._InsertNewLine(!0) : (n = this.GetPromptText(), t = function (e) {
var t, i, s, o, u, f;
if (e !== !1) {
r.MoveToEnd(!0), r._InsertNewLine(!0), f = [];
for (s = o = 0, u = Math.abs(e); 0 <= u ? o < u : o > u; s = 0 <= u ? ++o : --o) e > 0 ? f.push(r._Indent()) : f.push(r._Unindent());
return f
}
return i = r.state === D ? "input" : "prompt", r.Write(r.GetPromptText(!0) + _, "" + a + "old-" + i), r.ClearPromptText(!0), r.history_active && ((!r.history.length || r.history[r.history.length - 1] !== n) && r.history.push(n), r.history_index = r.history.length), r.state = P, t = r.input_callback, r.input_callback = null, t && t(n), r._CheckInputQueue()
}, this.multiline_callback ? this.async_multiline ? this.multiline_callback(n, t) : t(this.multiline_callback(n)) : t(!1))
}, n.prototype._GetDirectionals = function (t) {
var n, r, i, s, o, u, a, f;
return s = t ? this.$prompt_left : this.$prompt_right, n = t ? this.$prompt_right : this.$prompt_left, i = t ? this.$prompt_before : this.$prompt_after, r = t ? this.$prompt_after : this.$prompt_before, u = t ? e.proxy(this.MoveToStart, this) : e.proxy(this.MoveToEnd, this), o = t ? e.proxy(this._MoveLeft, this) : e.proxy(this._MoveRight, this), f = t ? "last" : "first", a = t ? "prependTo" : "appendTo", {
$prompt_which: s,
$prompt_opposite: n,
$prompt_relative: i,
$prompt_rel_opposite: r,
MoveToLimit: u,
MoveDirection: o,
which_end: f,
where_append: a
}
}, n.prototype._VerticalMove = function (e) {
var t, n, r, i, s, o, u, a;
a = this._GetDirectionals(e), r = a.$prompt_which, t = a.$prompt_opposite, n = a.$prompt_relative, s = a.MoveToLimit, i = a.MoveDirection;
if (n.is(d)) return;
return o = this.$prompt_left.text().length, s(), i(), u = r.text(), t.text(e ? u.slice(o) : u.slice(0, o)), r.text(e ? u.slice(0, o) : u.slice(o))
}, n.prototype._MoveUp = function () {
return this._VerticalMove(!0)
}, n.prototype._MoveDown = function () {
return this._VerticalMove()
}, n.prototype._HorizontalMove = function (t, n) {
var r, i, s, o, u, a, f, l, c, h, p, m, g, y;
y = this._GetDirectionals(n), u = y.$prompt_which, i = y.$prompt_opposite, o = y.$prompt_relative, s = y.$prompt_rel_opposite, m = y.which_end, p = y.where_append, l = n ? /\w*\W*$/ : /^\w*\W*/, c = u.text();
if (c) {
if (t) {
g = c.match(l);
if (!g) return;
return g = g[0], h = i.text(), i.text(n ? g + h : h + g), f = g.length, u.text(n ? c.slice(0, -f) : c.slice(f))
}
return h = i.text(), i.text(n ? c.slice(-1) + h : h + c[0]), u.text(n ? c.slice(0, -1) : c.slice(1))
}
if (!o.is(d)) return a = e(v)[p](s), a.append(e(v).text(this.$prompt_label.text())), a.append(e(v).text(i.text())), r = o.children()[m]().detach(), this.$prompt_label.text(r.children().first().text()), u.text(r.children().last().text()), i.text("")
}, n.prototype._MoveLeft = function (e) {
return this._HorizontalMove(e, !0)
}, n.prototype._MoveRight = function (e) {
return this._HorizontalMove(e)
}, n.prototype._MoveTo = function (e, t) {
var n, r, i, s, o, u, a;
u = this._GetDirectionals(t), i = u.$prompt_which, n = u.$prompt_opposite, r = u.$prompt_relative, o = u.MoveToLimit, s = u.MoveDirection;
if (e) {
a = [];
while (!r.is(d) || i.text() !== "") o(!1), a.push(s(!1));
return a
}
return n.text(this.$prompt_left.text() + this.$prompt_right.text()), i.text("")
}, n.prototype._Delete = function (e) {
var t, n, r;
n = this.$prompt_right.text();
if (n) {
if (e) {
r = n.match(/^\w*\W*/);
if (!r) return;
return r = r[0], this.$prompt_right.text(n.slice(r.length))
}
return this.$prompt_right.text(n.slice(1))
}
if (!this.$prompt_after.is(d)) return t = this.$prompt_after.children().first().detach(), this.$prompt_right.text(t.children().last().text())
}, n.prototype._Backspace = function (t) {
var n, r, i;
setTimeout(e.proxy(this._ScrollToEnd, this), 0), r = this.$prompt_left.text();
if (r) {
if (t) {
i = r.match(/\w*\W*$/);
if (!i) return;
return i = i[0], this.$prompt_left.text(r.slice(0, -i.length))
}
return this.$prompt_left.text(r.slice(0, -1))
}
if (!this.$prompt_before.is(d)) return n = this.$prompt_before.children().last().detach(), this.$prompt_label.text(n.children().first().text()), this.$prompt_left.text(n.children().last().text())
}, n.prototype._Indent = function () {
var e;
return this.$prompt_left.prepend(function () {
var t, n, r;
r = [];
for (e = t = 1, n = this.indent_width; 1 <= n ? t <= n : t >= n; e = 1 <= n ? ++t : --t) r.push(" ");
return r
}.call(this).join(""))
}, n.prototype._Unindent = function () {
var e, t, n, r, i;
e = this.$prompt_left.text() + this.$prompt_right.text(), i = [];
for (t = n = 1, r = this.indent_width; 1 <= r ? n <= r : n >= r; t = 1 <= r ? ++n : --n) {
if (!/^ /.test(e)) break;
this.$prompt_left.text() ? this.$prompt_left.text(this.$prompt_left.text().slice(1)) : this.$prompt_right.text(this.$prompt_right.text().slice(1)), i.push(e = e.slice(1))
}
return i
}, n.prototype._InsertNewLine = function (t) {
var n, r, i;
return t == null && (t = !1), i = this._SelectPromptLabel(!this.$prompt_before.is(d)), n = e(v).appendTo(this.$prompt_before), n.append(e(v).text(i)), n.append(e(v).text(this.$prompt_left.text())), this.$prompt_label.text(this._SelectPromptLabel(!0)), t && (r = this.$prompt_left.text().match(/^\s+/)) ? this.$prompt_left.text(r[0]) : this.$prompt_left.text(""), this._ScrollToEnd()
}, n.prototype._AppendPromptText = function (e) {
var t, n, r, i, s, o;
n = e.split(_), this.$prompt_left.text(this.$prompt_left.text() + n[0]), s = n.slice(1), o = [];
for (r = 0, i = s.length; r < i; r++) t = s[r], this._InsertNewLine(), o.push(this.$prompt_left.text(t));
return o
}, n.prototype._ScrollUp = function () {
var e;
return e = this.$console[0].scrollTop - this.$console.height(), this.$console.stop().animate({
scrollTop: e
}, "fast")
}, n.prototype._ScrollDown = function () {
var e;
return e = this.$console[0].scrollTop + this.$console.height(), this.$console.stop().animate({
scrollTop: e
}, "fast")
}, n.prototype._ScrollToEnd = function () {
var e, t = this;
return this.$console.scrollTop(this.$console[0].scrollHeight), e = function () {
var e, n, r, i, s, o, u;
n = t.$prompt_cursor.height(), u = t.$window.scrollTop(), o = t.$window.scrollLeft(), e = document.documentElement.clientHeight, i = t.$prompt_cursor.offset(), s = t.$prompt_cursor.position(), t.$input_container.css({
left: s.left,
top: s.top - 999999
}), r = i.top - 2 * n;
if (t.isMobile && typeof orientation != "undefined" && orientation !== null) {
if (u < i.top || u > i.top) return t.$window.scrollTop(r)
} else {
if (u + e < i.top) return t.$window.scrollTop(i.top - e + n);
if (u > r) return t.$window.scrollTop(i.top)
}
}, setTimeout(e, 0)
}, n.prototype._SelectPromptLabel = function (e) {
return this.state === H ? e ? " \n" + this.prompt_label_continue : this.prompt_label_main : e ? "\n " : " "
}, n.prototype._outerHTML = function (t) {
return document.body.outerHTML ? t.get(0).outerHTML : e(p).append(t.eq(0).clone()).html()
}, n.prototype._Wrap = function (e, t, n) {
var r, i;
return i = e.html(), r = i.slice(0, t) + B(n, i[t]) + i.slice(t + 1), e.html(r)
}, n.prototype._WalkCharacters = function (e, t, n, r, i) {
var s, o, u;
o = i ? e.length : 0, e = e.split(""), u = function () {
var t, n, r, s;
return i ? (r = e, e = 2 <= r.length ? F.call(r, 0, n = r.length - 1) : (n = 0, []), t = r[n++]) : (s = e, t = s[0], e = 2 <= s.length ? F.call(s, 1) : []), t && (o += i ? -1 : 1), t
};
while (s = u()) {
s === t ? r++ : s === n && r--;
if (r === 0) return {
index: o,
current_count: r
}
}
return {
index: -1,
current_count: r
}
}, n.prototype._ProcessMatch = function (t, n, r) {
var i, s, o, u, a, f, l, c, h, p, d, v, m = this;
return p = n ? [t.closing_char, t.opening_char] : [t.opening_char, t.closing_char], u = p[0], c = p[1], d = this._GetDirectionals(n), o = d.$prompt_which, s = d.$prompt_relative, a = 1, f = !1, h = o.html(), n || (h = h.slice(1)), r && n && (h = h.slice(0, -1)), v = this._WalkCharacters(h, u, c, a, n), l = v.index, a = v.current_count, l > -1 ? (this._Wrap(o, l, t.cls), f = !0) : (i = s.children(), i = n ? Array.prototype.reverse.call(i) : i, i.each(function (r, i) {
var s, o;
s = e(i).children().last(), h = s.html(), o = m._WalkCharacters(h, u, c, a, n), l = o.index, a = o.current_count;
if (l > -1) return n || l--, m._Wrap(s, l, t.cls), f = !0, !1
})), f
}, n.prototype._CheckMatchings = function (t) {
var n, r, i, s, o, u, a;
i = t ? this.$prompt_left.text().slice(this.$prompt_left.text().length - 1) : this.$prompt_right.text()[0], a = this.matchings.clss;
for (o = 0, u = a.length; o < u; o++) n = a[o], e("." + n, this.$console).contents().unwrap();
(r = this.matchings.closings[i]) ? s = this._ProcessMatch(r, !0, t) : (r = this.matchings.openings[i]) ? s = this._ProcessMatch(r, !1, t) : t || this._CheckMatchings(!0);
if (t) {
if (s) return this._Wrap(this.$prompt_left, this.$prompt_left.html().length - 1, r.cls)
} else if (s) return this._Wrap(this.$prompt_right, 0, r.cls)
}, n.prototype._HistoryPrevious = function () {
if (!this.history_active) return;
if (this.history_index <= 0) return;
return this.history_index === this.history.length && (this.history_new = this.GetPromptText()), this.SetPromptText(this.history[--this.history_index])
}, n.prototype._HistoryNext = function () {
if (!this.history_active) return;
if (this.history_index >= this.history.length) return;
return this.history_index === this.history.length - 1 ? (this.history_index++, this.SetPromptText(this.history_new)) : this.SetPromptText(this.history[++this.history_index])
}, n.prototype._CheckComposition = function (t) {
var n;
n = t.keyCode || t.which, e.browser.opera != null && this.in_composition && this._UpdateComposition();
if (n === 229) return this.in_composition ? this._UpdateComposition() : this._StartComposition()
}, n.prototype._StartComposition = function () {
return this.$input_source.bind(y, this._EndComposition), this.in_composition = !0, this._ShowComposition(), setTimeout(this._UpdateComposition, 0)
}, n.prototype._EndComposition = function () {
return this.$input_source.unbind(y, this._EndComposition), this.in_composition = !1, this._HideComposition(), this.$input_source.val("")
}, n.prototype._UpdateComposition = function (e) {
var t, n = this;
return t = function () {
if (!n.in_composition) return;
return n.$composition.text(n.$input_source.val())
}, setTimeout(t, 0)
}, n.prototype._ShowComposition = function () {
return this.$composition.css("height", this.$prompt_cursor.height()), this.$composition.empty(), this.$composition.appendTo(this.$prompt_left)
}, n.prototype._HideComposition = function () {
return this.$composition.detach()
}, n
}(), e.fn.jqconsole = function (e, t, n) {
return new b(this, e, t, n)
}, e.fn.jqconsole.JQConsole = b, e.fn.jqconsole.Ansi = t
}.call(this), define("vendor/jqconsole", function () {}), define("widgets/widget", ["require", "exports", "module", "underscore", "jquery"], function (e, t) {
var n = e("underscore"),
r = e("jquery"),
i = function (e, t) {
this._$styler = e || r(), this._$container = t || r(), n.bindAll(this)
};
(function () {
this.setStyler = function (e) {
return this._$styler = e || r(), this
}, this.setContainer = function (e) {
return this._$container = e || r(), this
}, this.css = function () {
return this._$styler.css.apply(this._$styler, arguments)
}, this.width = function (e) {
return this._$styler.width(e)
}, this.height = function (e) {
return this._$styler.height(e)
}, this.show = function () {
return this._$container.show(), this
}, this.hide = function () {
return this._$container.hide(), this
}, this.isHidden = function () {
return this._$container.is(":not(:visible)")
}
}).call(i.prototype), t.Widget = i
}), define("widgets/console", ["require", "exports", "module", "vendor/jqconsole", "libs/utils", "widgets/widget", "underscore", "jquery"], function (e, t) {
e("vendor/jqconsole");
var n = e("libs/utils"),
r = e("widgets/widget").Widget,
i = e("underscore"),
s = e("jquery"),
o = "> ",
u = "",
a = ".. ",
f = "reset",
l = "246px",
c = "144px",
h = {}, p = {
"{}": "brace",
"[]": "bracket",
"()": "paren"
}, d = function (e, t) {
t(!1)
}, v = {
shortcuts: h,
matchings: p,
continueLabel: a,
promptLabel: o,
header: u,
multilineCallback: d,
evaluator: s.noop
}, m = function (e, t) {
this.settings = i.extend({}, v, t), typeof e == "string" ? this.$console = s("#" + e) : this.$console = e, this.jqconsole = this.$console.jqconsole(this.settings.header, this.settings.promptLabel, this.settings.continueLabel), this.input = i.bind(this.input, this), this.output = i.bind(this.output, this), m.super_.constructor.apply(this, [this.$console, this.$console])
};
n.inherits(m, r),
function () {
this.reset = function (e) {
i.extend(this.settings, e);
var t = this.jqconsole;
return t.shortcuts = {}, t.matchings = {
openings: {},
closings: {},
clss: []
}, i.each(this.settings.shortcuts, function (e, n) {
t.RegisterShortcut(n, e)
}), i.each(this.settings.matchings, function (e, n) {
t.RegisterMatching(n.charAt(0), n.charAt(1), e)
}), this.startPrompt(), this
}, this._handler = function (e) {
return s.trim(e) === f ? this.startPrompt() : this.settings.evaluator(e), this
}, this.startPrompt = function () {
return this.jqconsole.GetState() !== "prompt" && this.jqconsole.Prompt(!0, i.bind(this._handler, this), this.settings.multilineCallback, !0), this
}, this.disable = function () {
return this.jqconsole.Disable(), this
}, this.enable = function () {
return this.jqconsole.Enable(), this
}, this.log = function (e, t) {
return this.jqconsole.Write(e, "log", Boolean(t)), this
};
var e = function (e) {
return e.replace(/\n/g, "<br>").replace(/\t/g, "&nbsp;&nbsp;&nbsp;&nbsp;").replace(/\s/g, "&nbsp")
};
this.error = function (t) {
var n = "";
return typeof t == "object" ? (n += t.name || "", n.length && (n += ": "), n += t.message) : n = String(t), n = n.slice(-1) !== "\n" ? n + "\n" : n, this.jqconsole.Write(e(i.escape(n)), "error", !1), this
}, this.result = function (e) {
return e != null && this.jqconsole.Write("==> " + e, "output"), this
}, this.output = function (e) {
return this.jqconsole.Write(e, "print"), this
}, this.input = function (e) {
return this.jqconsole.Input(e), this
}, this.set = function (e, t) {
return this.settings[e] = t, this
}, this.expand = function () {
return this.$console.height(l), this
}, this.collapse = function () {
return this.$console.height(c), this
}, this.focus = function () {
return this.jqconsole.Focus(), this
}, this.clear = function () {
return this.$console.find(".jqconsole-input").prevAll().remove(), this
}
}.call(m.prototype), t.Console = m
}), define("views/composer/terminal", ["require", "exports", "module", "backbone", "views/composer/base_view", "widgets/console", "models/composer/mediator", "jquery", "underscore"], function (e, t, n) {
var r = e("backbone"),
i = e("views/composer/base_view"),
s = e("widgets/console").Console,
o = e("models/composer/mediator"),
u = e("jquery"),
a = e("underscore");
n.exports = r.View.extend({
templateName: "composer/_terminal",
el: ".terminal",
initialize: function () {
this.listenTo(o, {
"change:cp_index": this.clear,
"evaluator:run:before": this.clear,
"evaluator:run:result": this.onRun,
"evaluator:input": this.onInput,
"evaluator:output": this.onOutput
})
},
render: function () {
return this.$el.is(":empty") && this.$el.html(this.template()), this.console = new s(this.$(".console")), this
},
onRun: function (e, t, n) {
var r = this.console;
this._finishInput(!0), t ? r.error(t) : r.log(n)
},
onInput: function (e) {
u("body").addClass("term-input-wait"), this._removingInput && clearTimeout(this._removingInput);
var t = this;
this.console.input(function () {
t._finishInput(), e.apply(null, arguments)
})
},
_finishInput: function (e) {
var t = function () {
u("body").removeClass("term-input-wait")
};
if (e) t();
else {
var n = 500;
this._removingInput = setTimeout(t, n)
}
},
onOutput: function (e) {
this.console.output(e)
},
close: function () {
this.$el.closest(".js-lesson-sidebar").removeClass("show")
},
clear: function () {
this.console.clear()
}
}), a.extend(n.exports.prototype, i)
}), define("libs/experiment", ["require", "exports", "module", "jquery"], function (e, t, n) {
var r = e("jquery"),
i = "/participants",
s = function (e) {
e = e || {}, this.url = e.url
};
(function () {
this.recordTakeUp = function (e) {
r.ajax({
type: "POST",
url: this.url + "/take_up",
data: JSON.stringify({
experiment_slug: e
}),
contentType: "application/json"
})
}, this.recordExposed = function (e) {
if (CCDATA.current_user !== undefined && CCDATA.current_user.roles.indexOf("admin") > -1) return;
r.ajax({
type: "POST",
url: this.url + "/exposed",
data: JSON.stringify({
experiment_slug: e
}),
contentType: "application/json"
})
}
}).call(s.prototype), n.exports = new s({
url: i
})
}), define("views/composer/flash_card", ["require", "exports", "module", "jquery", "underscore", "backbone", "views/composer/base_view", "libs/experiment", "libs/statsd", "models/composer/mediator", "highlightjs"], function (e, t, n) {
var r = e("jquery"),
i = e("underscore"),
s = e("backbone"),
o = e("views/composer/base_view"),
u = e("libs/experiment"),
a = e("libs/statsd"),
f = e("models/composer/mediator"),
l = e("highlightjs");
n.exports = s.View.extend({
el: "#js-glossary-flash-card",
events: {
"click .js-close-flash-card": "_userHide",
"click .js-flash-card-takeup": "_recordTakeup"
},
templateName: "composer/_flash_card_content",
initialize: function () {
this.listenTo(f, "evaluator:run:err:repl", this.reactToError)
},
onFail: function (e, t) {
var n = this._matchingExamples(t),
r = CCDATA.composer.experiments.flash_cards;
a.increment("flashCard", "lookup"), this._logError(e, t), n.length && (a.increment("flashCard", "match"), u.recordExposed("flash_cards"), r.treatment === "treatment" && this._displayExample(n[0]))
},
reactToError: function (e, t) {
var n = CCDATA.composer.experiments.flash_cards;
if (t && t.line) {
var r = e.split("\n")[t.line - 1];
this.onFail(t, r), n.treatment === "treatment" && (f.trigger("highlightErrorLine", {
lineno: t.line
}), a.increment("flashCard", "lineHighlighted"))
}
},
_displayExample: function (e) {
var t = l.highlightAuto(e.example).value;
this.$el.html(this.template({
example: t,
language: e.language,
category: e.category,
hyphenated_category: e.category.replace(/[^\w]/gi, "-")
})), this._show(), a.increment("flashCard", "display")
},
_show: function () {
this.$el.addClass("is-shown")
},
_hide: function () {
this.$el.removeClass("is-shown")
},
_userHide: function () {
a.increment("flashCard", "userClose"), this._hide()
},
_recordTakeup: function () {
u.recordTakeUp("flash_cards"), a.increment("flashCard", "takeup")
},
_logError: function (e, t) {
r.ajax({
type: "POST",
url: "/composer/submission_errors",
data: {
type: e.name,
message: e.message,
code: t,
eid: this.options.e_id,
sid: this.options.s_id
}
})
},
_matchingExamples: function (e) {
return CCDATA.composer.syntax_examples.filter(function (t) {
return (new RegExp(t.listener, "gi")).test(e)
})
}
}), i.extend(n.exports.prototype, o)
}), define("views/composer/sidebar", ["require", "exports", "module", "backbone", "views/composer/base_view", "views/composer/mini_preview", "widgets/actions_dropdown", "models/composer/mediator", "views/composer/terminal", "views/composer/flash_card", "libs/statsd", "underscore"], function (e, t, n) {
var r = e("backbone"),
i = e("views/composer/base_view"),
s = e("views/composer/mini_preview"),
o = e("widgets/actions_dropdown"),
u = e("models/composer/mediator"),
a = e("views/composer/terminal"),
f = e("views/composer/flash_card"),
l = e("libs/statsd"),
c = e("underscore");
n.exports = r.View.extend({
templateName: "composer/_sidebar",
el: ".js-lesson-sidebar",
events: {
"click .js-full-screen": "fullPreview",
"click .js-fork-codebit": "createCodebit"
},
initialize: function () {
this.defineSubviews({
miniPreview: s,
terminal: a,
flashCard: f
}), this.$(".actions-dropdown").each(function () {
new o({
$el: this
})
}), CCDATA.composer.experiments.flash_cards.in_experiment && this.listenTo(u, "change:cp_index", this.renderFlashCard), this.listenTo(u, "change:cp_index", this.closeTerminal), this.listenTo(u, "change:cp_index", this.closeMiniPreview)
},
renderMiniPreview: function () {
return this.renderSubview("miniPreview"), this
},
renderFlashCard: function () {
this.renderSubview("flashCard", {
e_id: u.getCurrentCheckpoint().id,
s_id: u.getCurrentCheckpoint().project.get("id")
})
},
render: function () {
return this.$el.is(":empty") && this.$el.html(this.template(this.model.toJSON())), u.getMode() === "web" ? this.renderMiniPreview() : (this.renderSubview("terminal"), CCDATA.composer.experiments.flash_cards.in_experiment && this.renderFlashCard()), this
},
showTermBack: function () {
this.$el.addClass("term-show")
},
closeMiniPreview: function () {
u.trigger("resultView:backToEditor")
},
closeTerminal: function () {
this.terminal && this.terminal.close()
},
fullPreview: function (e) {
e.preventDefault(), l.increment("composer", "trigger-full-screen"), u.trigger("miniPreview:viewfull")
},
createCodebit: function (e) {
e.preventDefault(), l.increment("codebits", "create-from-composer"), u.trigger("codebit-cta")
}
}), c.extend(n.exports.prototype, i)
}), define("views/composer/base_result_view", ["require", "exports", "module", "libs/utils", "backbone", "models/composer/mediator"], function (e, t, n) {
var r = e("libs/utils"),
i = e("backbone"),
s = e("models/composer/mediator");
n.exports = i.View.extend({
successTemplate: r.template("composer/_success"),
failTemplate: r.template("composer/_fail"),
initialize: function () {
this.listenTo(s, {
"checkpoint:pass": this.pass,
"checkpoint:fail": this.fail,
"change:cp_index": this.removeResult,
"change:project_index": this.removeResult,
"resultView:backToEditor": this.removeResult
})
},
showBackToEditor: function (e) {
this.$(".js-state--back").toggleClass("may-be-shown", e)
},
pass: function () {
var e = this.$(".js-state--passed");
e.html(this.successTemplate(s.project.toJSON())).addClass("is-shown")
},
fail: function (e, t) {
this.$(".js-state--failed").html(this.failTemplate({
hint: t
})).addClass("is-shown"), this.showBackToEditor(!0)
},
removeResult: function () {
this.$(".js-state--failed, .js-state--passed").removeClass("is-shown"), this.showBackToEditor(!1)
},
backToEditor: function () {
return s.trigger("resultView:backToEditor"), this
}
})
}), define("views/composer/bottombar", ["require", "exports", "module", "views/composer/base_view", "models/composer/mediator", "views/composer/base_result_view", "libs/statsd", "underscore"], function (e, t, n) {
var r = e("views/composer/base_view"),
i = e("models/composer/mediator"),
s = e("views/composer/base_result_view"),
o = e("libs/statsd"),
u = e("underscore");
n.exports = s.extend({
templateName: "composer/_bottom_bar",
el: ".js-lesson-action-bar",
events: {
"click .js-submit-code": "submit",
"click .js-reset-code.reset": "reset",
"click .js-reset-code.undo": "undoReset",
"click .js-goto-next-checkpoint": "nextCheckpoint",
"click .js-view-server": "showServer",
"click .back-editor": "backToEditor",
"click .js-show-answer": "showAnswer",
"click .close-icon": "close",
"click .js-next-section": "nextProject"
},
initialize: function () {
s.prototype.initialize.call(this), this.listenTo(i, "change:submitting", this.toggleSubmitting)
},
render: function () {
return this.$el.is(":empty") && this.$el.html(this.template(this.model.toJSON())), this
},
nextCheckpoint: function () {
this.close(), i.project.gotoNextCheckpoint()
},
prevCheckpoint: function () {
this.close(), i.project.gotoPrevCheckpoint()
},
pass: function () {
this.constructor.__super__.pass.call(this), this.$("input#user_redirect").attr("value", this.$("a.js-anon-signup-continue").attr("href"))
},
submit: function () {
i.get("submitting") || (this.removeResult(), this.trigger("submit"))
},
reset: function () {
this.removeResult(), this.trigger("reset"), o.increment("composer-reset", "reset")
},
undoReset: function () {
this.trigger("undoReset"), o.increment("composer-reset", "undo")
},
fullPreview: function () {
i.trigger("miniPreview:viewfull")
},
showServer: function () {
this.trigger("showServer")
},
showAnswer: function () {
this.trigger("showAnswer")
},
close: function () {
this.backToEditor(), this.removeResult()
},
toggleSubmitting: function (e, t) {
this.$(".js-submit-code.ui-loading").toggleClass("is-loading", t)
},
toggleResetButton: function (e) {
var t = this.$(".js-reset-code");
t.hasClass("undo") && e !== !1 ? (t.text("Reset Code"), t.toggleClass("reset undo"), t.toggleClass("ui-button--transparent--on-dark ui-button--gray--on-dark")) : e !== !0 && (t.html('<div class="cc-icon icon-undo"></div>Undo'), t.toggleClass("reset undo"), t.toggleClass("ui-button--transparent--on-dark ui-button--gray--on-dark"))
},
nextProject: function () {
this.backToEditor(), i.course.gotoNextProject()
}
}), u.extend(n.exports.prototype, r)
}), define("widgets/tabs", ["require", "exports", "module", "backbone", "jquery"], function (e, t, n) {
var r = e("backbone"),
i = e("jquery");
n.exports = r.View.extend({
events: function () {
return {
"click .tab": "onTabClick"
}
},
initialize: function (e) {
this.state = new r.Model({
currentTab: e.currentTab
}), this.state.on("change:currentTab", this.onTabChange, this)
},
onTabChange: function (e, t) {
this.$(".active").removeClass("active"), this.$('[data-type="' + t + '"]').addClass("active"), this.trigger("tabChange", this, t)
},
currentTab: function () {
return this.state.get("currentTab")
},
currentTabPath: function () {
return this.$(".active")[0].pathname
},
setTab: function (e, t) {
this.state.set({
currentTab: e
}, t)
},
onTabClick: function (e) {
e.preventDefault(), this.setTab(i(e.currentTarget).data("type"))
}
})
}), define("views/composer/file_tabs", ["require", "exports", "module", "widgets/tabs", "views/composer/base_view", "widgets/actions_dropdown", "models/composer/mediator", "libs/statsd", "underscore"], function (e, t, n) {
var r = e("widgets/tabs"),
i = e("views/composer/base_view"),
s = e("widgets/actions_dropdown"),
o = e("models/composer/mediator"),
u = e("libs/statsd"),
a = e("underscore");
n.exports = r.extend({
templateName: "composer/_tabs",
el: ".js-lesson-file-tabs",
render: function () {
return this.$el.empty().append(this.template(this.model.toJSON())), this.$el.find(".js-file-tab").first().addClass("active"), this.$el.find(".js-view-project").click(this._viewProject), this.$el.find(".js-fork-codebit").click(this.createCodebit), this.$(".actions-dropdown").each(function () {
new s({
$el: this
})
}), this
},
_viewProject: function () {
o.trigger("miniPreview:viewfull")
},
createCodebit: function (e) {
e.preventDefault(), u.increment("codebits", "create-from-composer"), o.trigger("codebit-cta")
}
}), a.extend(n.exports.prototype, i)
}), define("widgets/editor/multi_editor/base", ["require", "exports", "module", "underscore", "backbone"], function (e, t, n) {
function s() {}
function o() {
throw new Error("Not implemented.")
}
var r = e("underscore"),
i = e("backbone").Events;
r.extend(s.prototype, i), s.prototype.addNewFile = o, s.prototype.getFile = o, s.prototype.renameFile = o, s.prototype.deleteFile = o, s.prototype.showFile = o, s.prototype.getCurrentFile = o, s.prototype.setFileContent = o, s.prototype.focus = o, s.prototype.addCommand = o, s.prototype.setTheme = o, s.prototype.setReadOnly = o, s.prototype.destroy = o, n.exports = s
}),
function () {
var e, t, n;
(function (r) {
function d(e, t) {
return h.call(e, t)
}
function v(e, t) {
var n, r, i, s, o, u, a, f, c, h, p = t && t.split("/"),
d = l.map,
v = d && d["*"] || {};
if (e && e.charAt(0) === ".")
if (t) {
p = p.slice(0, p.length - 1), e = p.concat(e.split("/"));
for (f = 0; f < e.length; f += 1) {
h = e[f];
if (h === ".") e.splice(f, 1), f -= 1;
else if (h === "..") {
if (f === 1 && (e[2] === ".." || e[0] === "..")) break;
f > 0 && (e.splice(f - 1, 2), f -= 2)
}
}
e = e.join("/")
} else e.indexOf("./") === 0 && (e = e.substring(2));
if ((p || v) && d) {
n = e.split("/");
for (f = n.length; f > 0; f -= 1) {
r = n.slice(0, f).join("/");
if (p)
for (c = p.length; c > 0; c -= 1) {
i = d[p.slice(0, c).join("/")];
if (i) {
i = i[r];
if (i) {
s = i, o = f;
break
}
}
}
if (s) break;
!u && v && v[r] && (u = v[r], a = f)
}!s && u && (s = u, o = a), s && (n.splice(0, o, s), e = n.join("/"))
}
return e
}
function m(e, t) {
return function () {
return s.apply(r, p.call(arguments, 0).concat([e, t]))
}
}
function g(e) {
return function (t) {
return v(t, e)
}
}
function y(e) {
return function (t) {
a[e] = t
}
}
function b(e) {
if (d(f, e)) {
var t = f[e];
delete f[e], c[e] = !0, i.apply(r, t)
}
if (!d(a, e) && !d(c, e)) throw new Error("No " + e);
return a[e]
}
function w(e) {
var t, n = e ? e.indexOf("!") : -1;
return n > -1 && (t = e.substring(0, n), e = e.substring(n + 1, e.length)), [t, e]
}
function E(e) {
return function () {
return l && l.config && l.config[e] || {}
}
}
var i, s, o, u, a = {}, f = {}, l = {}, c = {}, h = Object.prototype.hasOwnProperty,
p = [].slice;
o = function (e, t) {
var n, r = w(e),
i = r[0];
return e = r[1], i && (i = v(i, t), n = b(i)), i ? n && n.normalize ? e = n.normalize(e, g(t)) : e = v(e, t) : (e = v(e, t), r = w(e), i = r[0], e = r[1], i && (n = b(i))), {
f: i ? i + "!" + e : e,
n: e,
pr: i,
p: n
}
}, u = {
require: function (e) {
return m(e)
},
exports: function (e) {
var t = a[e];
return typeof t != "undefined" ? t : a[e] = {}
},
module: function (e) {
return {
id: e,
uri: "",
exports: a[e],
config: E(e)
}
}
}, i = function (e, t, n, i) {
var s, l, h, p, v, g = [],
w;
i = i || e;
if (typeof n == "function") {
t = !t.length && n.length ? ["require", "exports", "module"] : t;
for (v = 0; v < t.length; v += 1) {
p = o(t[v], i), l = p.f;
if (l === "require") g[v] = u.require(e);
else if (l === "exports") g[v] = u.exports(e), w = !0;
else if (l === "module") s = g[v] = u.module(e);
else if (d(a, l) || d(f, l) || d(c, l)) g[v] = b(l);
else {
if (!p.p) throw new Error(e + " missing " + l);
p.p.load(p.n, m(i, !0), y(l), {}), g[v] = a[l]
}
}
h = n.apply(a[e], g);
if (e)
if (s && s.exports !== r && s.exports !== a[e]) a[e] = s.exports;
else if (h !== r || !w) a[e] = h
} else e && (a[e] = n)
}, e = t = s = function (e, t, n, a, f) {
return typeof e == "string" ? u[e] ? u[e](t) : b(o(e, t).f) : (e.splice || (l = e, t.splice ? (e = t, t = n, n = null) : e = r), t = t || function () {}, typeof n == "function" && (n = a, a = f), a ? i(r, e, t, n) : setTimeout(function () {
i(r, e, t, n)
}, 4), s)
}, s.config = function (e) {
return l = e, s
}, n = function (e, t, n) {
t.splice || (n = t, t = []), !d(a, e) && !d(f, e) && (f[e] = [e, t, n])
}, n.amd = {
jQuery: !0
}
})(), n("almond", [], function () {}), n("orion/editor/util", [], function () {
function v(e) {
var t = arguments;
return e.replace(/\$\{([^\}]+)\}/g, function (e, n) {
return t[(n << 0) + 1]
})
}
function g(e, t) {
return e.createElementNS ? e.createElementNS(m, t) : e.createElement(t)
}
var e = navigator.userAgent,
t = parseFloat(e.split("MSIE")[1]) || undefined,
n = parseFloat(e.split("Firefox/")[1] || e.split("Minefield/")[1]) || undefined,
r = e.indexOf("Opera") !== -1,
i = parseFloat(e.split("Chrome/")[1]) || undefined,
s = e.indexOf("Safari") !== -1 && !i,
o = parseFloat(e.split("WebKit/")[1]) || undefined,
u = e.indexOf("Android") !== -1,
a = e.indexOf("iPad") !== -1,
f = e.indexOf("iPhone") !== -1,
l = a || f,
c = navigator.platform.indexOf("Mac") !== -1,
h = navigator.platform.indexOf("Win") !== -1,
p = navigator.platform.indexOf("Linux") !== -1,
d = h ? "\r\n" : "\n",
m = "http://www.w3.org/1999/xhtml";
return {
formatMessage: v,
createElement: g,
isIE: t,
isFirefox: n,
isOpera: r,
isChrome: i,
isSafari: s,
isWebkit: o,
isAndroid: u,
isIPad: a,
isIPhone: f,
isIOS: l,
isMac: c,
isWindows: h,
isLinux: p,
platformDelimiter: d
}
}), n("orion/editor/eventTarget", [], function () {
function e() {}
return e.addMixin = function (t) {
var n = e.prototype;
for (var r in n) n.hasOwnProperty(r) && (t[r] = n[r])
}, e.prototype = {
addEventListener: function (e, t, n) {
this._eventTypes || (this._eventTypes = {});
var r = this._eventTypes[e];
r || (r = this._eventTypes[e] = {
level: 0,
listeners: []
});
var i = r.listeners;
i.push({
listener: t,
useCapture: n
})
},
dispatchEvent: function (e) {
var t = e.type;
this._dispatchEvent("pre" + t, e), this._dispatchEvent(t, e), this._dispatchEvent("post" + t, e)
},
_dispatchEvent: function (e, t) {
var n = this._eventTypes ? this._eventTypes[e] : null;
if (n) {
var r = n.listeners;
try {
n.level++;
if (r)
for (var i = 0, s = r.length; i < s; i++)
if (r[i]) {
var o = r[i].listener;
typeof o == "function" ? o.call(this, t) : o.handleEvent && typeof o.handleEvent == "function" && o.handleEvent(t)
}
} finally {
n.level--;
if (n.compact && n.level === 0) {
for (var u = r.length - 1; u >= 0; u--) r[u] || r.splice(u, 1);
r.length === 0 && delete this._eventTypes[e], n.compact = !1
}
}
}
},
isListening: function (e) {
return this._eventTypes ? this._eventTypes[e] !== undefined : !1
},
removeEventListener: function (e, t, n) {
if (!this._eventTypes) return;
var r = this._eventTypes[e];
if (r) {
var i = r.listeners;
for (var s = 0, o = i.length; s < o; s++) {
var u = i[s];
if (u && u.listener === t && u.useCapture === n) {
r.level !== 0 ? (i[s] = null, r.compact = !0) : i.splice(s, 1);
break
}
}
i.length === 0 && delete this._eventTypes[e]
}
}
}, {
EventTarget: e
}
}), n("orion/editor/textModel", ["orion/editor/eventTarget", "orion/editor/util"], function (e, t) {
function n(e, t) {
this._lastLineIndex = -1, this._text = [""], this._lineOffsets = [0], this.setText(e), this.setLineDelimiter(t)
}
return n.prototype = {
find: function (e) {
this._text.length > 1 && (this._text = [this._text.join("")]);
var t = e.string,
n = e.regex,
r = t;
!n && t && (r = t.replace(/([\\$\^*\/+?\.\(\)|{}\[\]])/g, "\\$&"));
var i = null,
s;
if (r) {
var o = e.reverse,
u = e.wrap,
a = e.wholeWord,
f = e.caseInsensitive,
l = e.start || 0,
c = e.end,
h = e.end !== undefined,
p = "";
p.indexOf("g") === -1 && (p += "g"), f && p.indexOf("i") === -1 && (p += "i"), a && (r = "\\b" + r + "\\b");
var d = this._text[0],
v, m, g = 0;
h && (d = d.substring(l, c), g = l);
var y = new RegExp(r, p);
o ? s = function () {
var e = null;
y.lastIndex = 0;
for (;;) {
m = y.lastIndex, v = y.exec(d);
if (m === y.lastIndex) return null;
if (!v) break;
if (v.index < l) e = {
start: v.index + g,
end: y.lastIndex + g
};
else {
if (!u || e) break;
l = d.length, e = {
start: v.index + g,
end: y.lastIndex + g
}
}
}
return e && (l = e.start), e
} : (h || (y.lastIndex = l), s = function () {
for (;;) {
m = y.lastIndex, v = y.exec(d);
if (m === y.lastIndex) return null;
if (v) return {
start: v.index + g,
end: y.lastIndex + g
};
if (m !== 0 && u) continue;
break
}
return null
}), i = s()
}
return {
next: function () {
var e = i;
return e && (i = s()), e
},
hasNext: function () {
return i !== null
}
}
},
getCharCount: function () {
var e = 0;
for (var t = 0; t < this._text.length; t++) e += this._text[t].length;
return e
},
getLine: function (e, t) {
var n = this.getLineCount();
if (0 <= e && e < n) {
var r = this._lineOffsets[e];
if (e + 1 < n) {
var i = this.getText(r, this._lineOffsets[e + 1]);
if (t) return i;
var s = i.length,
o;
while ((o = i.charCodeAt(s - 1)) === 10 || o === 13) s--;
return i.substring(0, s)
}
return this.getText(r)
}
return null
},
getLineAtOffset: function (e) {
var t = this.getCharCount();
if (0 <= e && e <= t) {
var n = this.getLineCount();
if (e === t) return n - 1;
var r, i, s = this._lastLineIndex;
if (0 <= s && s < n) {
r = this._lineOffsets[s], i = s + 1 < n ? this._lineOffsets[s + 1] : t;
if (r <= e && e < i) return s
}
var o = n,
u = -1;
while (o - u > 1) {
s = Math.floor((o + u) / 2), r = this._lineOffsets[s], i = s + 1 < n ? this._lineOffsets[s + 1] : t;
if (e <= r) o = s;
else {
if (e < i) {
o = s;
break
}
u = s
}
}
return this._lastLineIndex = o, o
}
return -1
},
getLineCount: function () {
return this._lineOffsets.length
},
getLineDelimiter: function () {
return this._lineDelimiter
},
getLineEnd: function (e, t) {
var n = this.getLineCount();
if (0 <= e && e < n) {
if (e + 1 < n) {
var r = this._lineOffsets[e + 1];
if (t) return r;
var i = this.getText(Math.max(this._lineOffsets[e], r - 2), r),
s = i.length,
o;
while ((o = i.charCodeAt(s - 1)) === 10 || o === 13) s--;
return r - (i.length - s)
}
return this.getCharCount()
}
return -1
},
getLineStart: function (e) {
return 0 <= e && e < this.getLineCount() ? this._lineOffsets[e] : -1
},
getText: function (e, t) {
e === undefined && (e = 0), t === undefined && (t = this.getCharCount());
if (e === t) return "";
var n = 0,
r = 0,
i;
while (r < this._text.length) {
i = this._text[r].length;
if (e <= n + i) break;
n += i, r++
}
var s = n,
o = r;
while (r < this._text.length) {
i = this._text[r].length;
if (t <= n + i) break;
n += i, r++
}
var u = n,
a = r;
if (o === a) return this._text[o].substring(e - s, t - u);
var f = this._text[o].substring(e - s),
l = this._text[a].substring(0, t - u);
return f + this._text.slice(o + 1, a).join("") + l
},
onChanging: function (e) {
return this.dispatchEvent(e)
},
onChanged: function (e) {
return this.dispatchEvent(e)
},
setLineDelimiter: function (e, n) {
e === "auto" && (e = undefined, this.getLineCount() > 1 && (e = this.getText(this.getLineEnd(0), this.getLineEnd(0, !0)))), this._lineDelimiter = e ? e : t.platformDelimiter;
if (n) {
var r = this.getLineCount();
if (r > 1) {
var i = new Array(r);
for (var s = 0; s < r; s++) i[s] = this.getLine(s);
this.setText(i.join(this._lineDelimiter))
}
}
},
setText: function (e, t, n) {
e === undefined && (e = ""), t === undefined && (t = 0), n === undefined && (n = this.getCharCount());
if (t === n && e === "") return;
var r = this.getLineAtOffset(t),
i = this.getLineAtOffset(n),
s = t,
o = n - t,
u = i - r,
a = e.length,
f = 0,
l = this.getLineCount(),
c = 0,
h = 0,
p = 0,
d = [];
for (;;) {
c !== -1 && c <= p && (c = e.indexOf("\r", p)), h !== -1 && h <= p && (h = e.indexOf("\n", p));
if (h === -1 && c === -1) break;
c !== -1 && h !== -1 ? c + 1 === h ? p = h + 1 : p = (c < h ? c : h) + 1 : c !== -1 ? p = c + 1 : p = h + 1, d.push(t + p), f++
}
var v = {
type: "Changing",
text: e,
start: s,
removedCharCount: o,
addedCharCount: a,
removedLineCount: u,
addedLineCount: f
};
this.onChanging(v);
if (d.length === 0) {
var m = this.getLineStart(r),
g;
i + 1 < l ? g = this.getLineStart(i + 1) : g = this.getCharCount(), t !== m && (e = this.getText(m, t) + e, t = m), n !== g && (e += this.getText(n, g), n = g)
}
var y = a - o;
for (var b = r + u + 1; b < l; b++) this._lineOffsets[b] += y;
var w = [r + 1, u].concat(d);
Array.prototype.splice.apply(this._lineOffsets, w);
var E = 0,
S = 0,
x;
while (S < this._text.length) {
x = this._text[S].length;
if (t <= E + x) break;
E += x, S++
}
var T = E,
N = S;
while (S < this._text.length) {
x = this._text[S].length;
if (n <= E + x) break;
E += x, S++
}
var C = E,
k = S,
L = this._text[N],
A = this._text[k],
O = L.substring(0, t - T),
M = A.substring(n - C),
_ = [N, k - N + 1];
O && _.push(O), e && _.push(e), M && _.push(M), Array.prototype.splice.apply(this._text, _), this._text.length === 0 && (this._text = [""]);
var D = {
type: "Changed",
start: s,
removedCharCount: o,
addedCharCount: a,
removedLineCount: u,
addedLineCount: f
};
this.onChanged(D)
}
}, e.EventTarget.addMixin(n.prototype), {
TextModel: n
}
}), n("orion/editor/projectionTextModel", ["orion/editor/textModel", "orion/editor/eventTarget"], function (e, t) {
function n(e) {
this._model = e, this._projections = []
}
return n.prototype = {
addProjection: function (t) {
if (!t) return;
var n = this._model,
r = this._projections;
t._lineIndex = n.getLineAtOffset(t.start), t._lineCount = n.getLineAtOffset(t.end) - t._lineIndex;
var i = t.text;
i || (i = ""), typeof i == "string" ? t._model = new e.TextModel(i, n.getLineDelimiter()) : t._model = i;
var s = this.mapOffset(t.start, !0),
o = t.end - t.start,
u = t._lineCount,
a = t._model.getCharCount(),
f = t._model.getLineCount() - 1,
l = {
type: "Changing",
text: t._model.getText(),
start: s,
removedCharCount: o,
addedCharCount: a,
removedLineCount: u,
addedLineCount: f
};
this.onChanging(l);
var c = this._binarySearch(r, t.start);
r.splice(c, 0, t);
var h = {
type: "Changed",
start: s,
removedCharCount: o,
addedCharCount: a,
removedLineCount: u,
addedLineCount: f
};
this.onChanged(h)
},
getProjections: function () {
return this._projections.slice(0)
},
getBaseModel: function () {
return this._model
},
mapOffset: function (e, t) {
var n = this._projections,
r = 0,
i, s;
if (t) {
for (i = 0; i < n.length; i++) {
s = n[i];
if (s.start > e) break;
if (s.end > e) return -1;
r += s._model.getCharCount() - (s.end - s.start)
}
return e + r
}
for (i = 0; i < n.length; i++) {
s = n[i];
if (s.start > e - r) break;
var o = s._model.getCharCount();
if (s.start + o > e - r) return -1;
r += o - (s.end - s.start)
}
return e - r
},
removeProjection: function (e) {
var t, n = 0;
for (t = 0; t < this._projections.length; t++) {
var r = this._projections[t];
if (r === e) {
e = r;
break
}
n += r._model.getCharCount() - (r.end - r.start)
}
if (t < this._projections.length) {
var i = this._model,
s = e.start + n,
o = e.end - e.start,
u = e._lineCount,
a = e._model.getCharCount(),
f = e._model.getLineCount() - 1,
l = {
type: "Changing",
text: i.getText(e.start, e.end),
start: s,
removedCharCount: a,
addedCharCount: o,
removedLineCount: f,
addedLineCount: u
};
this.onChanging(l), this._projections.splice(t, 1);
var c = {
type: "Changed",
start: s,
removedCharCount: a,
addedCharCount: o,
removedLineCount: f,
addedLineCount: u
};
this.onChanged(c)
}
},
_binarySearch: function (e, t) {
var n = e.length,
r = -1,
i;
while (n - r > 1) i = Math.floor((n + r) / 2), t <= e[i].start ? n = i : r = i;
return n
},
getCharCount: function () {
var e = this._model.getCharCount(),
t = this._projections;
for (var n = 0; n < t.length; n++) {
var r = t[n];
e += r._model.getCharCount() - (r.end - r.start)
}
return e
},
getLine: function (e, t) {
if (e < 0) return null;
var n = this._model,
r = this._projections,
i = 0,
s = [],
o = 0,
u, a, f;
for (u = 0; u < r.length; u++) {
f = r[u];
if (f._lineIndex >= e - i) break;
a = f._model.getLineCount() - 1;
if (f._lineIndex + a >= e - i) {
var l = e - (f._lineIndex + i);
if (l < a) return f._model.getLine(l, t);
s.push(f._model.getLine(a))
}
o = f.end, i += a - f._lineCount
}
o = Math.max(o, n.getLineStart(e - i));
for (; u < r.length; u++) {
f = r[u];
if (f._lineIndex > e - i) break;
s.push(n.getText(o, f.start)), a = f._model.getLineCount() - 1;
if (f._lineIndex + a > e - i) return s.push(f._model.getLine(0, t)), s.join("");
s.push(f._model.getText()), o = f.end, i += a - f._lineCount
}
var c = n.getLineEnd(e - i, t);
return o < c && s.push(n.getText(o, c)), s.join("")
},
getLineAtOffset: function (e) {
var t = this._model,
n = this._projections,
r = 0,
i = 0;
for (var s = 0; s < n.length; s++) {
var o = n[s];
if (o.start > e - r) break;
var u = o._model.getCharCount();
if (o.start + u > e - r) {
var a = e - (o.start + r);
i += o._model.getLineAtOffset(a), r += a;
break
}
i += o._model.getLineCount() - 1 - o._lineCount, r += u - (o.end - o.start)
}
return t.getLineAtOffset(e - r) + i
},
getLineCount: function () {
var e = this._model,
t = this._projections,
n = e.getLineCount();
for (var r = 0; r < t.length; r++) {
var i = t[r];
n += i._model.getLineCount() - 1 - i._lineCount
}
return n
},
getLineDelimiter: function () {
return this._model.getLineDelimiter()
},
getLineEnd: function (e, t) {
if (e < 0) return -1;
var n = this._model,
r = this._projections,
i = 0,
s = 0;
for (var o = 0; o < r.length; o++) {
var u = r[o];
if (u._lineIndex > e - i) break;
var a = u._model.getLineCount() - 1;
if (u._lineIndex + a > e - i) {
var f = e - (u._lineIndex + i);
return u._model.getLineEnd(f, t) + u.start + s
}
s += u._model.getCharCount() - (u.end - u.start), i += a - u._lineCount
}
return n.getLineEnd(e - i, t) + s
},
getLineStart: function (e) {
if (e < 0) return -1;
var t = this._model,
n = this._projections,
r = 0,
i = 0;
for (var s = 0; s < n.length; s++) {
var o = n[s];
if (o._lineIndex >= e - r) break;
var u = o._model.getLineCount() - 1;
if (o._lineIndex + u >= e - r) {
var a = e - (o._lineIndex + r);
return o._model.getLineStart(a) + o.start + i
}
i += o._model.getCharCount() - (o.end - o.start), r += u - o._lineCount
}
return t.getLineStart(e - r) + i
},
getText: function (e, t) {
e === undefined && (e = 0);
var n = this._model,
r = this._projections,
i = 0,
s = [],
o, u, a;
for (o = 0; o < r.length; o++) {
u = r[o];
if (u.start > e - i) break;
a = u._model.getCharCount();
if (u.start + a > e - i) {
if (t !== undefined && u.start + a > t - i) return u._model.getText(e - (u.start + i), t - (u.start + i));
s.push(u._model.getText(e - (u.start + i))), e = u.end + i + a - (u.end - u.start)
}
i += a - (u.end - u.start)
}
var f = e - i;
if (t !== undefined) {
for (; o < r.length; o++) {
u = r[o];
if (u.start > t - i) break;
s.push(n.getText(f, u.start)), a = u._model.getCharCount();
if (u.start + a > t - i) return s.push(u._model.getText(0, t - (u.start + i))), s.join("");
s.push(u._model.getText()), f = u.end, i += a - (u.end - u.start)
}
s.push(n.getText(f, t - i))
} else {
for (; o < r.length; o++) u = r[o], s.push(n.getText(f, u.start)), s.push(u._model.getText()), f = u.end;
s.push(n.getText(f))
}
return s.join("")
},
_onChanging: function (e, t, n, r, i, s) {
var o = this._model,
u = this._projections,
a, f, l = 0,
c, h = t + n;
for (; a < u.length; a++) {
f = u[a];
if (f.start > t) break;
l += f._model.getCharCount() - (f.end - f.start)
}
var p = t + l,
d = a;
for (; a < u.length; a++) {
f = u[a];
if (f.start > h) break;
l += f._model.getCharCount() - (f.end - f.start), c += f._model.getLineCount() - 1 - f._lineCount
}
var v = h + l,
m = a;
this.onChanging(p, v - p, r, i + c, s), u.splice(u, m - d);
var g = e.length - (v - p);
for (; a < u.length; a++) f = u[a], f.start += g, f.end += g, f._lineIndex = o.getLineAtOffset(f.start)
},
onChanging: function (e) {
return this.dispatchEvent(e)
},
onChanged: function (e) {
return this.dispatchEvent(e)
},
setLineDelimiter: function (e) {
this._model.setLineDelimiter(e)
},
setText: function (e, t, n) {
e === undefined && (e = ""), t === undefined && (t = 0);
var r = t,
i = n,
s = this._model,
o = this._projections,
u = 0,
a = 0,
f, l, c, h, p, d = 0;
for (f = 0; f < o.length; f++) {
l = o[f];
if (l.start > t - u) break;
c = l._model.getCharCount();
if (l.start + c > t - u) {
if (n !== undefined && l.start + c > n - u) {
l._model.setText(e, t - (l.start + u), n - (l.start + u));
return
}
d = l._model.getLineCount() - 1 - l._model.getLineAtOffset(t - (l.start + u)), h = {
projection: l,
start: t - (l.start + u)
}, t = l.end + u + c - (l.end - l.start)
}
a += l._model.getLineCount() - 1 - l._lineCount, u += c - (l.end - l.start)
}
var v = t - u,
m = f,
g = s.getLineAtOffset(v) + a - d;
if (n !== undefined)
for (; f < o.length; f++) {
l = o[f];
if (l.start > n - u) break;
c = l._model.getCharCount();
if (l.start + c > n - u) {
a += l._model.getLineAtOffset(n - (l.start + u)), c = n - (l.start + u), n = l.end + u, p = {
projection: l,
end: c
};
break
}
a += l._model.getLineCount() - 1 - l._lineCount, u += c - (l.end - l.start)
} else {
for (; f < o.length; f++) l = o[f], a += l._model.getLineCount() - 1 - l._lineCount, u += l._model.getCharCount() - (l.end - l.start);
n = i = s.getCharCount() + u
}
var y = n - u,
b = f,
w = s.getLineAtOffset(y) + a,
E = i - r,
S = w - g,
x = e.length,
T = 0,
N = 0,
C = 0,
k = 0;
for (;;) {
N !== -1 && N <= k && (N = e.indexOf("\r", k)), C !== -1 && C <= k && (C = e.indexOf("\n", k));
if (C === -1 && N === -1) break;
N !== -1 && C !== -1 ? N + 1 === C ? k = C + 1 : k = (N < C ? N : C) + 1 : N !== -1 ? k = N + 1 : k = C + 1, T++
}
var L = {
type: "Changing",
text: e,
start: r,
removedCharCount: E,
addedCharCount: x,
removedLineCount: S,
addedLineCount: T
};
this.onChanging(L), s.setText(e, v, y), h && (l = h.projection, l._model.setText("", h.start)), p && (l = p.projection, l._model.setText("", 0, p.end), l.start = l.end, l._lineCount = 0), o.splice(m, b - m);
var A = e.length - (y - v);
for (f = b; f < o.length; f++) l = o[f], l.start += A, l.end += A, l._lineIndex = s.getLineAtOffset(l.start);
var O = {
type: "Changed",
start: r,
removedCharCount: E,
addedCharCount: x,
removedLineCount: S,
addedLineCount: T
};
this.onChanged(O)
}
}, t.EventTarget.addMixin(n.prototype), {
ProjectionTextModel: n
}
}), n("orion/editor/keyBinding", ["orion/editor/util"], function (e) {
function t(e, t, n, r, i) {
typeof e == "string" ? this.keyCode = e.toUpperCase().charCodeAt(0) : this.keyCode = e, this.mod1 = t !== undefined && t !== null ? t : !1, this.mod2 = n !== undefined && n !== null ? n : !1, this.mod3 = r !== undefined && r !== null ? r : !1, this.mod4 = i !== undefined && i !== null ? i : !1
}
return t.prototype = {
match: function (t) {
if (this.keyCode === t.keyCode) {
var n = e.isMac ? t.metaKey : t.ctrlKey;
return this.mod1 !== n ? !1 : this.mod2 !== t.shiftKey ? !1 : this.mod3 !== t.altKey ? !1 : e.isMac && this.mod4 !== t.ctrlKey ? !1 : !0
}
return !1
},
equals: function (e) {
return e ? this.keyCode !== e.keyCode ? !1 : this.mod1 !== e.mod1 ? !1 : this.mod2 !== e.mod2 ? !1 : this.mod3 !== e.mod3 ? !1 : this.mod4 !== e.mod4 ? !1 : !0 : !1
}
}, {
KeyBinding: t
}
}), n("orion/editor/textView", ["orion/editor/textModel", "orion/editor/keyBinding", "orion/editor/eventTarget", "orion/editor/util"], function (e, t, n, r) {
function i(e) {
return e.defaultView || e.parentWindow
}
function s(e, t, n, r) {
typeof e.addEventListener == "function" ? e.addEventListener(t, n, r === !0) : e.attachEvent("on" + t, n)
}
function o(e, t, n, r) {
typeof e.removeEventListener == "function" ? e.removeEventListener(t, n, r === !0) : e.detachEvent("on" + t, n)
}
function u(e, t, n) {
if (n) {
t.className = "";
var i = t.attributes;
for (var s = i.length; s-- > 0;)(!r.isIE || r.isIE >= 9 || r.isIE < 9 && i[s].specified) && t.removeAttribute(i[s].name)
}
if (!e) return;
e.styleClass && (t.className = e.styleClass);
var o = e.style;
if (o)
for (var u in o) o.hasOwnProperty(u) && (t.style[u] = o[u]);
var a = e.attributes;
if (a)
for (var f in a) a.hasOwnProperty(f) && t.setAttribute(f, a[f])
}
function a(e) {
return e instanceof Array ? e.slice(0) : e
}
function f(e, t) {
if (e === t) return !0;
if (e && !t || !e && t) return !1;
if (e && e.constructor === String || t && t.constructor === String) return !1;
if (e instanceof Array || t instanceof Array) {
if (e instanceof Array && t instanceof Array) {
if (e.length !== t.length) return !1;
for (var n = 0; n < e.length; n++)
if (!f(e[n], t[n])) return !1;
return !0
}
return !1
}
if (e instanceof Object && t instanceof Object) {
var r;
for (r in e)
if (e.hasOwnProperty(r)) {
if (!t.hasOwnProperty(r)) return !1;
if (!f(e[r], t[r])) return !1
}
for (r in t)
if (!e.hasOwnProperty(r)) return !1;
return !0
}
return !1
}
function l(e, t, n) {
var r = 0,
i = 0,
s = 0,
o = e.length;
while (s < o) {
r !== -1 && r <= s && (r = e.indexOf("\r", s)), i !== -1 && i <= s && (i = e.indexOf("\n", s));
var u = s,
a;
if (i === -1 && r === -1) {
t(e.substring(s));
break
}
r !== -1 && i !== -1 ? r + 1 === i ? (a = r, s = i + 1) : (a = r < i ? r : i, s = (r < i ? r : i) + 1) : r !== -1 ? (a = r, s = r + 1) : (a = i, s = i + 1), t(e.substring(u, a)), n()
}
}
function c(e) {
var t, n, r, s, o = i(e.ownerDocument);
if (o.getComputedStyle) {
var u = o.getComputedStyle(e, null);
t = u.getPropertyValue("border-left-width"), n = u.getPropertyValue("border-top-width"), r = u.getPropertyValue("border-right-width"), s = u.getPropertyValue("border-bottom-width")
} else e.currentStyle && (t = e.currentStyle.borderLeftWidth, n = e.currentStyle.borderTopWidth, r = e.currentStyle.borderRightWidth, s = e.currentStyle.borderBottomWidth);
return {
left: parseInt(t, 10) || 0,
top: parseInt(n, 10) || 0,
right: parseInt(r, 10) || 0,
bottom: parseInt(s, 10) || 0
}
}
function h(e) {
var t, n, r, s, o = i(e.ownerDocument);
if (o.getComputedStyle) {
var u = o.getComputedStyle(e, null);
t = u.getPropertyValue("padding-left"), n = u.getPropertyValue("padding-top"), r = u.getPropertyValue("padding-right"), s = u.getPropertyValue("padding-bottom")
} else e.currentStyle && (t = e.currentStyle.paddingLeft, n = e.currentStyle.paddingTop, r = e.currentStyle.paddingRight, s = e.currentStyle.paddingBottom);
return {
left: parseInt(t, 10) || 0,
top: parseInt(n, 10) || 0,
right: parseInt(r, 10) || 0,
bottom: parseInt(s, 10) || 0
}
}
function p(e) {
var t = e._trim;
if (!t) {
t = h(e);
var n = c(e);
t.left += n.left, t.top += n.top, t.right += n.right, t.bottom += n.bottom, e._trim = t
}
return t
}
function d(e, t, n) {
this.start = e, this.end = t, this.caret = n
}
function v(e) {
this.left = e.left, this.top = e.top, this.right = e.right, this.bottom = e.bottom
}
function m(e, t, n) {
this.view = e, this.lineIndex = t, this._lineDiv = n
}
function y(e) {
this._init(e)
}
d.prototype = {
clone: function () {
return new d(this.start, this.end, this.caret)
},
collapse: function () {
this.caret ? this.end = this.start : this.start = this.end
},
extend: function (e) {
this.caret ? this.start = e : this.end = e;
if (this.start > this.end) {
var t = this.start;
this.start = this.end, this.end = t, this.caret = !this.caret
}
},
setCaret: function (e) {
this.start = e, this.end = e, this.caret = !1
},
getCaret: function () {
return this.caret ? this.start : this.end
},
toString: function () {
return "start=" + this.start + " end=" + this.end + (this.caret ? " caret is at start" : " caret is at end")
},
isEmpty: function () {
return this.start === this.end
},
equals: function (e) {
return this.caret === e.caret && this.start === e.start && this.end === e.end
}
}, v.prototype = {
toString: function () {
return "{l=" + this.left + ", t=" + this.top + ", r=" + this.right + ", b=" + this.bottom + "}"
}
}, m.prototype = {
create: function (e, t) {
if (this._lineDiv) return;
var n = this._lineDiv = this._createLine(e, t, this.lineIndex);
return n._line = this, n
},
_createLine: function (e, t, n) {
var i = this.view,
s = i._model,
o = s.getLine(n),
a = s.getLineStart(n),
l = {
type: "LineStyle",
textView: i,
lineIndex: n,
lineText: o,
lineStart: a
};
o.length < 2e3 && i.onLineStyle(l);
var c = t || r.createElement(e.ownerDocument, "div");
if (!t || !f(t.viewStyle, l.style)) u(l.style, c, t), t && (t._trim = null), c.viewStyle = l.style, c.setAttribute("role", "presentation");
c.lineIndex = n;
var h = [],
p = {
tabOffset: 0,
ranges: h
};
this._createRanges(l.ranges, o, 0, o.length, a, p);
var d = " ";
!i._fullSelection && r.isIE < 9 && (d = ""), r.isWebkit && (d = "‌"), h.push({
text: d,
style: i._metrics.largestFontStyle,
ignoreChars: 1
});
var v, m, g, y, b, w, E, S = 0,
x = 0,
T, N, C;
if (t) {
var k = t.modelChangedEvent;
k && (k.removedLineCount === 0 && k.addedLineCount === 0 ? (C = k.start - a, N = k.addedCharCount - k.removedCharCount) : C = -1, t.modelChangedEvent = undefined), y = t.firstChild
}
for (var L = 0; L < h.length; L++) {
v = h[L], w = v.text, S += w.length, g = v.style;
if (y) {
E = y.firstChild.data, b = y.viewStyle;
if (E === w && f(g, b)) {
x += E.length, y._rectsCache = undefined, m = y = y.nextSibling;
continue
}
while (y) {
if (C !== -1) {
var A = S;
A >= C && (A -= N);
var O = y.firstChild.data,
M = O ? O.length : 0;
if (x + M > A) break;
x += M
}
T = y.nextSibling, c.removeChild(y), y = T
}
}
m = this._createSpan(c, w, g, v.ignoreChars), y ? c.insertBefore(m, y) : c.appendChild(m), t && (t.lineWidth = undefined)
}
if (t) {
var _ = m ? m.nextSibling : null;
while (_) T = _.nextSibling, t.removeChild(_), _ = T
} else e.appendChild(c);
return c
},
_createRanges: function (e, t, n, r, i, s) {
if (n >= r) return;
if (e)
for (var o = 0; o < e.length; o++) {
var u = e[o];
if (u.end <= i + n) continue;
var a = Math.max(i + n, u.start) - i;
if (a >= r) break;
var l = Math.min(i + r, u.end) - i;
if (a < l) {
a = Math.max(n, a), l = Math.min(r, l), n < a && this._createRange(t, n, a, null, s);
while (o + 1 < e.length && e[o + 1].start - i === l && f(u.style, e[o + 1].style)) u = e[o + 1], l = Math.min(i + r, u.end) - i, o++;
this._createRange(t, a, l, u.style, s), n = l
}
}
n < r && this._createRange(t, n, r, null, s)
},
_createRange: function (e, t, n, r, i) {
if (t >= n) return;
var s = this.view._customTabSize,
o;
if (s && s !== 8) {
var u = e.indexOf(" ", t);
while (u !== -1 && u < n) {
t < u && (o = {
text: e.substring(t, u),
style: r
}, i.ranges.push(o), i.tabOffset += o.text.length);
var a = s - i.tabOffset % s;
if (a > 0) {
var f = "Â ";
for (var l = 1; l < a; l++) f += " ";
o = {
text: f,
style: r,
ignoreChars: a - 1
}, i.ranges.push(o), i.tabOffset += o.text.length
}
t = u + 1, u = e.indexOf(" ", t)
}
}
t < n && (o = {
text: e.substring(t, n),
style: r
}, i.ranges.push(o), i.tabOffset += o.text.length)
},
_createSpan: function (e, t, n, i) {
var o = n && n.tagName === "A";
o && (e.hasLink = !0);
var a = o && this.view._linksVisible ? "a" : "span",
f = e.ownerDocument,
l = r.createElement(e.ownerDocument, a);
l.appendChild(f.createTextNode(t)), u(n, l);
if (a === "A") {
var c = this.view,
h = this._getWindow();
s(l, "click", function (e) {
return c._handleLinkClick(e ? e : h.event)
}, !1)
}
return l.viewStyle = n, i && (l.ignoreChars = i), l
},
_ensureCreated: function () {
return this._lineDiv ? this._lineDiv : this._createdDiv = this.create(this.view._clientDiv, null)
},
getBoundingClientRect: function (e, t) {
var n = this._ensureCreated(),
s = this.view;
if (e === undefined) return this._getLineBoundingClientRect(n, !0);
var o = s._model,
u = n.ownerDocument,
a = this.lineIndex,
f = null;
if (e < o.getLineEnd(a)) {
var l = o.getLineStart(a),
c = n.firstChild;
while (c) {
var h = c.firstChild,
p = h.length;
c.ignoreChars && (p -= c.ignoreChars);
if (l + p > e) {
var d = e - l,
m;
if (s._isRangeRects) m = u.createRange(), m.setStart(h, d), m.setEnd(h, d + 1), f = new v(m.getBoundingClientRect());
else if (r.isIE) m = u.body.createTextRange(), m.moveToElementText(c), m.collapse(), m.moveEnd("character", d + 1), m.moveStart("character", d), f = new v(m.getBoundingClientRect());
else {
var g = h.data;
c.removeChild(h), c.appendChild(u.createTextNode(g.substring(0, d)));
var y = r.createElement(u, "span");
y.appendChild(u.createTextNode(g.substring(d, d + 1))), c.appendChild(y), c.appendChild(u.createTextNode(g.substring(d + 1))), f = new v(y.getBoundingClientRect()), c.innerHTML = "", c.appendChild(h);
if (!this._createdDiv) {
var b = s._getSelection();
(l <= b.start && b.start < l + p || l <= b.end && b.end < l + p) && s._updateDOMSelection()
}
} if (r.isIE) {
var w = i(n.ownerDocument),
E = w.screen.logicalXDPI / w.screen.deviceXDPI,
S = w.screen.logicalYDPI / w.screen.deviceYDPI;
f.left = f.left * E, f.right = f.right * E, f.top = f.top * S, f.bottom = f.bottom * S
}
break
}
l += p, c = c.nextSibling
}
}
var x = this.getBoundingClientRect();
if (!f)
if (s._wrapMode) {
var T = this.getClientRects();
f = T[T.length - 1], f.left = f.right, f.left += x.left, f.top += x.top, f.right += x.left, f.bottom += x.top
} else f = new v(x), f.left = f.right;
if (t || t === undefined) f.left -= x.left, f.top -= x.top, f.right -= x.left, f.bottom -= x.top;
return f
},
_getClientRects: function (e, t) {
var n, r, i, s;
if (!e._rectsCache) {
n = e.getClientRects(), r = new Array(n.length);
for (s = 0; s < n.length; s++) i = r[s] = new v(n[s]), i.left -= t.left, i.top -= t.top, i.right -= t.left, i.bottom -= t.top;
e._rectsCache = r
}
n = e._rectsCache, r = [n.length];
for (s = 0; s < n.length; s++) r[s] = new v(n[s]);
return r
},
getClientRects: function (e) {
if (!this.view._wrapMode) return [this.getBoundingClientRect()];
var t = this._ensureCreated(),
n = [],
r = t.firstChild,
i, s, o = t.getBoundingClientRect();
while (r) {
var u = this._getClientRects(r, o);
for (i = 0; i < u.length; i++) {
var a = u[i],
f;
if (a.top === a.bottom) continue;
var l = a.top + (a.bottom - a.top) / 2;
for (f = 0; f < n.length; f++) {
s = n[f];
if (s.top <= l && l < s.bottom) break
}
f === n.length ? n.push(a) : (a.left < s.left && (s.left = a.left), a.top < s.top && (s.top = a.top), a.right > s.right && (s.right = a.right), a.bottom > s.bottom && (s.bottom = a.bottom))
}
r = r.nextSibling
}
return e !== undefined ? n[e] : n
},
_getLineBoundingClientRect: function (e, t) {
var n = new v(e.getBoundingClientRect());
if (!this.view._wrapMode) {
n.right = n.left;
var r = e.lastChild;
while (r && r.ignoreChars === r.firstChild.length) r = r.previousSibling;
if (r) {
var i = r.getBoundingClientRect();
n.right = i.right + p(e).right
}
}
if (t) {
var s = p(e);
n.left = n.left + s.left, n.right = n.right - s.right
}
return n
},
getLineCount: function () {
return this.view._wrapMode ? this.getClientRects().length : 1
},
getLineIndex: function (e) {
if (!this.view._wrapMode) return 0;
var t = this.getClientRects(),
n = this.getBoundingClientRect(e),
r = n.top + (n.bottom - n.top) / 2;
for (var i = 0; i < t.length; i++)
if (t[i].top <= r && r < t[i].bottom) return i;
return t.length - 1
},
getLineStart: function (e) {
if (!this.view._wrapMode || e === 0) return this.view._model.getLineStart(e);
var t = this.getClientRects();
return this.getOffset(t[e].left + 1, t[e].top + 1)
},
getOffset: function (e, t) {
var n = this.view,
s = n._model,
o = this.lineIndex,
u = s.getLineStart(o),
a = s.getLineEnd(o);
if (u === a) return u;
var f = this._ensureCreated(),
l = this.getBoundingClientRect(),
c, h;
if (n._wrapMode) {
c = this.getClientRects(), t < c[0].top && (t = c[0].top);
for (var p = 0; p < c.length; p++) {
h = c[p];
if (h.top <= t && t < h.bottom) break
}
e < h.left && (e = h.left), e > h.right && (e = h.right - 1)
} else e < 0 && (e = 0), e > l.right - l.left && (e = l.right - l.left);
var d = f.ownerDocument,
v = i(d),
m = r.isIE ? v.screen.logicalXDPI / v.screen.deviceXDPI : 1,
g = r.isIE ? v.screen.logicalYDPI / v.screen.deviceYDPI : 1,
y = u,
b = f.firstChild;
e: while (b) {
var w = b.firstChild,
E = w.length;
b.ignoreChars && (E -= b.ignoreChars);
var S, x, T, N;
c = this._getClientRects(b, l);
for (var C = 0; C < c.length; C++) {
h = c[C];
if (h.left <= e && e < h.right && (!n._wrapMode || h.top <= t && t < h.bottom)) {
var k, L, A;
if (r.isIE || n._isRangeRects) {
k = n._isRangeRects ? d.createRange() : d.body.createTextRange();
var O = E,
M = -1;
while (O - M > 1) {
var _ = Math.floor((O + M) / 2);
L = M + 1, A = _ === E - 1 && b.ignoreChars ? w.length : _ + 1, n._isRangeRects ? (k.setStart(w, L), k.setEnd(w, A)) : (k.moveToElementText(b), k.move("character", L), k.moveEnd("character", A - L)), c = k.getClientRects();
var D = !1;
for (var P = 0; P < c.length; P++) {
h = c[P], S = h.left * m - l.left, T = h.right * m - l.left, x = h.top * g - l.top, N = h.bottom * g - l.top;
if (S <= e && e < T && (!n._wrapMode || x <= t && t < N)) {
D = !0;
break
}
}
D ? O = _ : M = _
}
y += O, L = O, A = O === E - 1 && b.ignoreChars ? w.length : Math.min(O + 1, w.length), n._isRangeRects ? (k.setStart(w, L), k.setEnd(w, A)) : (k.moveToElementText(b), k.move("character", L), k.moveEnd("character", A - L)), h = k.getClientRects()[0], S = h.left * m - l.left, T = h.right * m - l.left, e > S + (T - S) / 2 && y++
} else {
var H = [];
for (var B = 0; B < E; B++) H.push("<span>"), B === E - 1 ? H.push(w.data.substring(B)) : H.push(w.data.substring(B, B + 1)), H.push("</span>");
b.innerHTML = H.join("");
var j = b.firstChild;
while (j) {
h = j.getBoundingClientRect(), S = h.left - l.left, T = h.right - l.left;
if (S <= e && e < T) {
e > S + (T - S) / 2 && y++;
break
}
y++, j = j.nextSibling
}
if (!this._createdDiv) {
b.innerHTML = "", b.appendChild(w);
var F = n._getSelection();
(y <= F.start && F.start < y + E || y <= F.end && F.end < y + E) && n._updateDOMSelection()
}
}
break e
}
}
y += E, b = b.nextSibling
}
return Math.min(a, Math.max(u, y))
},
getNextOffset: function (e, t, n) {
if (t === "line") {
var i = this.view,
s = i._model,
o = s.getLineAtOffset(e);
return n > 0 ? s.getLineEnd(o) : s.getLineStart(o)
}
return t === "wordend" ? this._getNextOffset_W3C(e, t, n) : r.isIE ? this._getNextOffset_IE(e, t, n) : this._getNextOffset_W3C(e, t, n)
},
_getNextOffset_W3C: function (e, t, n) {
function r(e) {
return 33 <= e && e <= 47 || 58 <= e && e <= 64 || 91 <= e && e <= 94 || e === 96 || 123 <= e && e <= 126
}
function i(e) {
return e === 32 || e === 9
}
if (t === "word" || t === "wordend") {
var s = this.view,
o = s._model,
u = o.getLineAtOffset(e),
a = o.getLine(u),
f = o.getLineStart(u),
l = o.getLineEnd(u),
c = a.length,
h = e - f,
p, d, v, m, g;
if (n > 0) {
if (h === c) return l;
p = a.charCodeAt(h), d = r(p), v = !d && !i(p), h++;
while (h < c) {
p = a.charCodeAt(h), m = r(p);
if (t === "wordend") {
if (!m && d) break
} else if (m && !d) break;
g = !m && !i(p);
if (t === "wordend") {
if (!g && v) break
} else if (g && !v) break;
v = g, d = m, h++
}
} else {
if (h === 0) return f;
h--, p = a.charCodeAt(h), d = r(p), v = !d && !i(p);
while (0 < h) {
p = a.charCodeAt(h - 1), m = r(p);
if (t === "wordend") {
if (m && !d) break
} else if (!m && d) break;
g = !m && !i(p);
if (t === "wordend") {
if (g && !v) break
} else if (!g && v) break;
v = g, d = m, h--
}
}
return f + h
}
return e + n
},
_getNextOffset_IE: function (e, t, n) {
var r = this._ensureCreated(),
i = this.view,
s = i._model,
o = this.lineIndex,
u = 0,
a, f, l = s.getLineStart(o),
c = r.ownerDocument;
if (e === s.getLineEnd(o)) a = c.body.createTextRange(), a.moveToElementText(r.lastChild), f = a.text.length, a.moveEnd(t, n), u = e + a.text.length - f;
else if (e === l && n < 0) u = l;
else {
var h = r.firstChild;
while (h) {
var p = h.firstChild,
d = p.length;
h.ignoreChars && (d -= h.ignoreChars);
if (l + d > e) {
a = c.body.createTextRange(), e === l && n < 0 ? a.moveToElementText(h.previousSibling) : (a.moveToElementText(h), a.collapse(), a.moveEnd("character", e - l)), f = a.text.length, a.moveEnd(t, n), u = e + a.text.length - f;
break
}
l = d + l, h = h.nextSibling
}
}
return u
},
destroy: function () {
var e = this._createdDiv;
e && (e.parentNode.removeChild(e), this._createdDiv = null)
}
};
var g = 15;
return y.prototype = {
addRuler: function (e, t) {
e.setView(this);
var n = this._rulers;
if (t !== undefined) {
var r, i;
for (r = 0, i = 0; r < n.length && i < t; r++) e.getLocation() === n[r].getLocation() && i++;
n.splice(i, 0, e), t = i
} else n.push(e);
this._createRuler(e, t), this._update()
},
computeSize: function () {
var e = 0,
t = 0,
n = this._model,
i = this._clientDiv;
if (!i) return {
width: e,
height: t
};
var s = i.style.width;
r.isWebkit && (i.style.width = "0x7fffffffpx");
var o = n.getLineCount();
for (var u = 0; u < o; u++) {
var a = this._getLine(u),
f = a.getBoundingClientRect();
e = Math.max(e, f.right - f.left), t += f.bottom - f.top, a.destroy()
}
r.isWebkit && (i.style.width = s);
var l = this._getViewPadding();
return e += l.right + l.left, t += l.bottom + l.top, {
width: e,
height: t
}
},
convert: function (e, t, n) {
if (!this._clientDiv) return;
var r = this._getScroll(),
i = this._getViewPadding(),
s = this._viewDiv.getBoundingClientRect();
return t === "document" && (e.x !== undefined && (e.x += -r.x + s.left + i.left), e.y !== undefined && (e.y += -r.y + s.top + i.top)), n === "document" && (e.x !== undefined && (e.x += r.x - s.left - i.left), e.y !== undefined && (e.y += r.y - s.top - i.top)), e
},
destroy: function () {
for (var e = 0; e < this._rulers.length; e++) this._rulers[e].setView(null);
this.rulers = null, this._destroyView();
var t = {
type: "Destroy"
};
this.onDestroy(t), this._parent = null, this._model = null, this._selection = null, this._doubleClickSelection = null, this._keyBindings = null, this._actions = null
},
focus: function () {
if (!this._clientDiv) return;
this._updateDOMSelection(), r.isOpera && this._clientDiv.blur(), this._clientDiv.focus(), this._updateDOMSelection()
},
hasFocus: function () {
return this._hasFocus
},
getActionDescription: function (e) {
var t = this._actions[e];
return t ? t.actionDescription : undefined
},
getActions: function (e) {
var t = [],
n = this._actions;
for (var r in n)
if (n.hasOwnProperty(r)) {
if (!e && n[r].defaultHandler) continue;
t.push(r)
}
return t
},
getBottomIndex: function (e) {
return this._clientDiv ? this._getBottomIndex(e) : 0
},
getBottomPixel: function () {
return this._clientDiv ? this._getScroll().y + this._getClientHeight() : 0
},
getCaretOffset: function () {
var e = this._getSelection();
return e.getCaret()
},
getClientArea: function () {
if (!this._clientDiv) return {
x: 0,
y: 0,
width: 0,
height: 0
};
var e = this._getScroll();
return {
x: e.x,
y: e.y,
width: this._getClientWidth(),
height: this._getClientHeight()
}
},
getHorizontalPixel: function () {
return this._clientDiv ? this._getScroll().x : 0
},
getKeyBindings: function (e) {
var t = [],
n = this._keyBindings;
for (var r = 0; r < n.length; r++) n[r].actionID === e && t.push(n[r].keyBinding);
return t
},
getLineHeight: function (e) {
return this._clientDiv ? this._getLineHeight(e) : 0
},
getLineIndex: function (e) {
return this._clientDiv ? this._getLineIndex(e) : 0
},
getLinePixel: function (e) {
return this._clientDiv ? this._getLinePixel(e) : 0
},
getLocationAtOffset: function (e) {
if (!this._clientDiv) return {
x: 0,
y: 0
};
var t = this._model;
e = Math.min(Math.max(0, e), t.getCharCount());
var n = t.getLineAtOffset(e),
r = this._getLine(n),
i = r.getBoundingClientRect(e);
r.destroy();
var s = i.left,
o = this._getLinePixel(n) + i.top;
return {
x: s,
y: o
}
},
getOptions: function () {
var e;
if (arguments.length === 0) e = this._defaultOptions();
else if (arguments.length === 1) {
var t = arguments[0];
if (typeof t == "string") return a(this["_" + t]);
e = t
} else {
e = {};
for (var n in arguments) arguments.hasOwnProperty(n) && (e[arguments[n]] = undefined)
}
for (var r in e) e.hasOwnProperty(r) && (e[r] = a(this["_" + r]));
return e
},
getModel: function () {
return this._model
},
getOffsetAtLocation: function (e, t) {
if (!this._clientDiv) return 0;
var n = this._getLineIndex(t),
r = this._getLine(n),
i = r.getOffset(e, t - this._getLinePixel(n));
return r.destroy(), i
},
getRulers: function () {
return this._rulers.slice(0)
},
getSelection: function () {
var e = this._getSelection();
return {
start: e.start,
end: e.end
}
},
getText: function (e, t) {
var n = this._model;
return n.getText(e, t)
},
getTopIndex: function (e) {
return this._clientDiv ? this._getTopIndex(e) : 0
},
getTopPixel: function () {
return this._clientDiv ? this._getScroll().y : 0
},
invokeAction: function (e, t) {
if (!this._clientDiv) return;
var n = this._actions[e];
if (n) {
if (!t && n.handler && n.handler()) return;
if (n.defaultHandler) return n.defaultHandler()
}
return !1
},
isDestroyed: function () {
return !this._clientDiv
},
onContextMenu: function (e) {
return this.dispatchEvent(e)
},
onDragStart: function (e) {
return this.dispatchEvent(e)
},
onDrag: function (e) {
return this.dispatchEvent(e)
},
onDragEnd: function (e) {
return this.dispatchEvent(e)
},
onDragEnter: function (e) {
return this.dispatchEvent(e)
},
onDragOver: function (e) {
return this.dispatchEvent(e)
},
onDragLeave: function (e) {
return this.dispatchEvent(e)
},
onDrop: function (e) {
return this.dispatchEvent(e)
},
onDestroy: function (e) {
return this.dispatchEvent(e)
},
onLineStyle: function (e) {
return this.dispatchEvent(e)
},
onModelChanged: function (e) {
return this.dispatchEvent(e)
},
onModelChanging: function (e) {
return this.dispatchEvent(e)
},
onModify: function (e) {
return this.dispatchEvent(e)
},
onMouseDown: function (e) {
return this.dispatchEvent(e)
},
onMouseUp: function (e) {
return this.dispatchEvent(e)
},
onMouseMove: function (e) {
return this.dispatchEvent(e)
},
onMouseOver: function (e) {
return this.dispatchEvent(e)
},
onMouseOut: function (e) {
return this.dispatchEvent(e)
},
onSelection: function (e) {
return this.dispatchEvent(e)
},
onScroll: function (e) {
return this.dispatchEvent(e)
},
onVerify: function (e) {
return this.dispatchEvent(e)
},
onFocus: function (e) {
return this.dispatchEvent(e)
},
onBlur: function (e) {
return this.dispatchEvent(e)
},
redraw: function () {
if (this._redrawCount > 0) return;
var e = this._model.getLineCount();
this.redrawRulers(0, e), this.redrawLines(0, e)
},
redrawRulers: function (e, t) {
if (this._redrawCount > 0) return;
var n = this.getRulers();
for (var r = 0; r < n.length; r++) this.redrawLines(e, t, n[r])
},
redrawLines: function (e, t, n) {
if (this._redrawCount > 0) return;
e === undefined && (e = 0), t === undefined && (t = this._model.getLineCount());
if (e === t) return;
var r = this._clientDiv;
if (!r) return;
if (n) {
var i = n.getLocation(),
s = i === "left" ? this._leftDiv : this._rightDiv,
o = s.firstChild.rows[0].cells;
for (var u = 0; u < o.length; u++)
if (o[u].firstChild._ruler === n) {
r = o[u].firstChild;
break
}
}
n ? r.rulerChanged = !0 : this._lineHeight && this._resetLineHeight(e, t);
if (!n || n.getOverview() === "page") {
var a = r.firstChild;
while (a) {
var f = a.lineIndex;
e <= f && f < t && (a.lineChanged = !0), a = a.nextSibling
}
}
n || this._wrapMode || e <= this._maxLineIndex && this._maxLineIndex < t && (this._checkMaxLineIndex = this._maxLineIndex, this._maxLineIndex = -1, this._maxLineWidth = 0), this._queueUpdate()
},
redrawRange: function (e, t) {
if (this._redrawCount > 0) return;
var n = this._model;
e === undefined && (e = 0), t === undefined && (t = n.getCharCount());
var r = n.getLineAtOffset(e),
i = n.getLineAtOffset(Math.max(e, t - 1)) + 1;
this.redrawLines(r, i)
},
removeRuler: function (e) {
var t = this._rulers;
for (var n = 0; n < t.length; n++)
if (t[n] === e) {
t.splice(n, 1), e.setView(null), this._destroyRuler(e), this._update();
break
}
},
resize: function () {
if (!this._clientDiv) return;
this._handleResize(null)
},
setAction: function (e, t, n) {
if (!e) return;
var r = this._actions,
i = r[e];
i || (i = r[e] = {}), i.handler = t, i.actionDescription = n
},
setKeyBinding: function (e, t) {
var n = this._keyBindings;
for (var r = 0; r < n.length; r++) {
var i = n[r];
if (i.keyBinding.equals(e)) {
t ? i.actionID = t : i.predefined ? i.actionID = null : n.splice(r, 1);
return
}
}
t && n.push({
keyBinding: e,
actionID: t
})
},
setCaretOffset: function (e, t) {
var n = this._model.getCharCount();
e = Math.max(0, Math.min(e, n));
var r = new d(e, e, !1);
this._setSelection(r, t === undefined || t)
},
setHorizontalPixel: function (e) {
if (!this._clientDiv) return;
e = Math.max(0, e), this._scrollView(e - this._getScroll().x, 0)
},
setRedraw: function (e) {
e ? --this._redrawCount === 0 && this.redraw() : this._redrawCount++
},
setModel: function (e) {
if (!e) return;
if (e === this._model) return;
this._model.removeEventListener("preChanging", this._modelListener.onChanging), this._model.removeEventListener("postChanged", this._modelListener.onChanged);
var t = this._model.getLineCount(),
n = this._model.getCharCount(),
r = e.getLineCount(),
i = e.getCharCount(),
s = e.getText(),
o = {
type: "ModelChanging",
text: s,
start: 0,
removedCharCount: n,
addedCharCount: i,
removedLineCount: t,
addedLineCount: r
};
this.onModelChanging(o), this._model = e, o = {
type: "ModelChanged",
start: 0,
removedCharCount: n,
addedCharCount: i,
removedLineCount: t,
addedLineCount: r
}, this.onModelChanged(o), this._model.addEventListener("preChanging", this._modelListener.onChanging), this._model.addEventListener("postChanged", this._modelListener.onChanged), this._reset(), this._update()
},
setOptions: function (e) {
var t = this._defaultOptions();
for (var n in e)
if (e.hasOwnProperty(n)) {
var r = e[n],
i = this["_" + n];
if (f(i, r)) continue;
var s = t[n] ? t[n].update : null;
if (s) {
s.call(this, r);
continue
}
this["_" + n] = a(r)
}
},
setSelection: function (e, t, n) {
var r = e > t;
if (r) {
var i = e;
e = t, t = i
}
var s = this._model.getCharCount();
e = Math.max(0, Math.min(e, s)), t = Math.max(0, Math.min(t, s));
var o = new d(e, t, r);
this._setSelection(o, n === undefined || n)
},
setText: function (e, t, n) {
var i = t === undefined && n === undefined;
t === undefined && (t = 0), n === undefined && (n = this._model.getCharCount()), this._modifyContent({
text: e,
start: t,
end: n,
_code: !0
}, !i), i && (this._columnX = -1, this._setSelection(new d(0, 0, !1), !0), r.isFirefox && this._fixCaret())
},
setTopIndex: function (e) {
if (!this._clientDiv) return;
this._scrollView(0, this._getLinePixel(Math.max(0, e)) - this._getScroll().y)
},
setTopPixel: function (e) {
if (!this._clientDiv) return;
this._scrollView(0, Math.max(0, e) - this._getScroll().y)
},
showSelection: function () {
return this._showCaret(!0)
},
update: function (e, t) {
if (!this._clientDiv) return;
e && this._updateStyle(), t === undefined || t ? this._update() : this._queueUpdate()
},
_handleRootMouseDown: function (e) {
r.isFirefox && e.which === 1 && (this._clientDiv.contentEditable = !1, (this._overlayDiv || this._clientDiv).draggable = !0, this._ignoreBlur = !0);
var t = this._overlayDiv || this._clientDiv;
r.isIE < 9 && (t = this._viewDiv);
var n = e.target ? e.target : e.srcElement;
while (n) {
if (t === n) return;
n = n.parentNode
}
e.preventDefault && e.preventDefault(), e.stopPropagation && e.stopPropagation();
if (!this._isW3CEvents) {
var i = this,
s = this._getWindow();
s.setTimeout(function () {
i._clientDiv.focus()
}, 0)
}
},
_handleRootMouseUp: function (e) {
r.isFirefox && e.which === 1 && (this._clientDiv.contentEditable = !0, (this._overlayDiv || this._clientDiv).draggable = !1, this._fixCaret(), this._ignoreBlur = !1)
},
_handleBlur: function (e) {
if (this._ignoreBlur) return;
this._hasFocus = !1;
if (r.isIE < 9 && !this._getSelection().isEmpty()) {
var t = this._rootDiv,
n = r.createElement(t.ownerDocument, "div");
t.appendChild(n), t.removeChild(n)
}
if (this._selDiv1) {
var i = "lightgray";
this._selDiv1.style.background = i, this._selDiv2.style.background = i, this._selDiv3.style.background = i;
var s, o = this._getWindow(),
u = this._selDiv1.ownerDocument;
if (o.getSelection) {
var a = o.getSelection();
s = a.anchorNode;
while (s) {
if (s === this._clientDiv) {
a.rangeCount > 0 && a.removeAllRanges();
break
}
s = s.parentNode
}
} else if (u.selection) {
this._ignoreSelect = !1, s = u.selection.createRange().parentElement();
while (s) {
if (s === this._clientDiv) {
u.selection.empty();
break
}
s = s.parentNode
}
this._ignoreSelect = !0
}
}
this._ignoreFocus || this.onBlur({
type: "Blur"
})
},
_handleContextMenu: function (e) {
r.isIE && this._lastMouseButton === 3 && this._updateDOMSelection();
var t = !1;
if (this.isListening("ContextMenu")) {
var n = this._createMouseEvent("ContextMenu", e);
n.screenX = e.screenX, n.screenY = e.screenY, this.onContextMenu(n), t = n.defaultPrevented
}
if (t) return e.preventDefault && e.preventDefault(), !1
},
_handleCopy: function (e) {
if (this._ignoreCopy) return;
if (this._doCopy(e)) return e.preventDefault && e.preventDefault(), !1
},
_handleCut: function (e) {
if (this._doCut(e)) return e.preventDefault && e.preventDefault(), !1
},
_handleDataModified: function (e) {
this._startIME()
},
_handleDblclick: function (e) {
var t = e.timeStamp ? e.timeStamp : (new Date).getTime();
this._lastMouseTime = t, this._clickCount !== 2 && (this._clickCount = 2, this._handleMouse(e))
},
_handleDragStart: function (e) {
if (r.isFirefox) {
var t = this,
n = this._getWindow();
n.setTimeout(function () {
t._clientDiv.contentEditable = !0, t._clientDiv.draggable = !1, t._ignoreBlur = !1
}, 0)
}
if (!this.isListening("DragStart") || this._dragOffset === -1) return e.preventDefault && e.preventDefault(), !1;
this._isMouseDown = !1, this.onDragStart(this._createMouseEvent("DragStart", e)), this._dragOffset = -1
},
_handleDrag: function (e) {
this.isListening("Drag") && this.onDrag(this._createMouseEvent("Drag", e))
},
_handleDragEnd: function (e) {
this._dropTarget = !1, this._dragOffset = -1, this.isListening("DragEnd") && this.onDragEnd(this._createMouseEvent("DragEnd", e)), r.isFirefox && (this._fixCaret(), e.dataTransfer.dropEffect === "none" && !e.dataTransfer.mozUserCancelled && this._fixCaret())
},
_handleDragEnter: function (e) {
var t = !0;
this._dropTarget = !0, this.isListening("DragEnter") && (t = !1, this.onDragEnter(this._createMouseEvent("DragEnter", e)));
if (r.isWebkit || t) return e.preventDefault && e.preventDefault(), !1
},
_handleDragOver: function (e) {
var t = !0;
this.isListening("DragOver") && (t = !1, this.onDragOver(this._createMouseEvent("DragOver", e)));
if (r.isWebkit || t) return t && (e.dataTransfer.dropEffect = "none"), e.preventDefault && e.preventDefault(), !1
},
_handleDragLeave: function (e) {
this._dropTarget = !1, this.isListening("DragLeave") && this.onDragLeave(this._createMouseEvent("DragLeave", e))
},
_handleDrop: function (e) {
return this._dropTarget = !1, this.isListening("Drop") && this.onDrop(this._createMouseEvent("Drop", e)), e.preventDefault && e.preventDefault(), !1
},
_handleFocus: function (e) {
this._hasFocus = !0, r.isIOS && this._lastTouchOffset !== undefined ? (this.setCaretOffset(this._lastTouchOffset, !0), this._lastTouchOffset = undefined) : this._updateDOMSelection();
if (this._selDiv1) {
var t = this._highlightRGB;
this._selDiv1.style.background = t, this._selDiv2.style.background = t, this._selDiv3.style.background = t
}
this._ignoreFocus || this.onFocus({
type: "Focus"
})
},
_handleKeyDown: function (e) {
var t = !1;
switch (e.keyCode) {
case 16:
case 17:
case 18:
case 91:
t = !0;
break;
default:
this._setLinksVisible(!1)
}
if (e.keyCode === 229) {
if (this._readonly) return e.preventDefault && e.preventDefault(), !1;
var n = !0;
r.isSafari && r.isMac && e.ctrlKey && (n = !1), n && this._startIME()
} else t || this._commitIME(); if ((r.isMac || r.isLinux) && r.isFirefox < 4 || r.isOpera) return this._keyDownEvent = e, !0;
if (this._doAction(e)) return e.preventDefault ? (e.preventDefault(), e.stopPropagation()) : (e.cancelBubble = !0, e.returnValue = !1, e.keyCode = 0), !1
},
_handleKeyPress: function (e) {
if (r.isMac && r.isWebkit)
if (63232 <= e.keyCode && e.keyCode <= 63487 || e.keyCode === 13 || e.keyCode === 8) return e.preventDefault && e.preventDefault(), !1;
if ((r.isMac || r.isLinux) && r.isFirefox < 4 || r.isOpera)
if (this._doAction(this._keyDownEvent)) return e.preventDefault && e.preventDefault(), !1;
var t = r.isMac ? e.metaKey : e.ctrlKey;
if (e.charCode !== undefined && t) switch (e.charCode) {
case 99:
case 118:
case 120:
return !0
}
var n = !1;
if (r.isMac) {
if (e.ctrlKey || e.metaKey) n = !0
} else if (r.isFirefox) {
if (e.ctrlKey || e.altKey) n = !0
} else e.ctrlKey ^ e.altKey && (n = !0); if (!n) {
var i = r.isOpera ? e.which : e.charCode !== undefined ? e.charCode : e.keyCode;
if (i > 31) return this._doContent(String.fromCharCode(i)), e.preventDefault && e.preventDefault(), !1
}
},
_handleKeyUp: function (e) {
var t = r.isMac ? e.metaKey : e.ctrlKey;
t || this._setLinksVisible(!1), e.keyCode === 13 && this._commitIME()
},
_handleLinkClick: function (e) {
var t = r.isMac ? e.metaKey : e.ctrlKey;
if (!t) return e.preventDefault && e.preventDefault(), !1
},
_handleMouse: function (e) {
var t = this._getWindow(),
n = !0,
i = t;
if (r.isIE || r.isFirefox && !this._overlayDiv) i = this._clientDiv;
if (this._overlayDiv) {
this._hasFocus && (this._ignoreFocus = !0);
var s = this;
t.setTimeout(function () {
s.focus(), s._ignoreFocus = !1
}, 0)
}
return this._clickCount === 1 ? (n = this._setSelectionTo(e.clientX, e.clientY, e.shiftKey, !r.isOpera && this._hasFocus && this.isListening("DragStart")), n && this._setGrab(i)) : (this._isW3CEvents && this._setGrab(i), this._doubleClickSelection = null, this._setSelectionTo(e.clientX, e.clientY, e.shiftKey), this._doubleClickSelection = this._getSelection()), n
},
_handleMouseDown: function (e) {
if (this._linksVisible) {
var t = e.target || e.srcElement;
if (t.tagName === "A") return;
this._setLinksVisible(!1)
}
this._commitIME();
var n = e.which;
n || (e.button === 4 && (n = 2), e.button === 2 && (n = 3), e.button === 1 && (n = 1));
var i = n !== 2 && e.timeStamp ? e.timeStamp : (new Date).getTime(),
s = i - this._lastMouseTime,
o = Math.abs(this._lastMouseX - e.clientX),
u = Math.abs(this._lastMouseY - e.clientY),
a = this._lastMouseButton === n;
this._lastMouseX = e.clientX, this._lastMouseY = e.clientY, this._lastMouseTime = i, this._lastMouseButton = n, n === 1 && (this._isMouseDown = !0, a && s <= this._clickTime && o <= this._clickDist && u <= this._clickDist ? this._clickCount++ : this._clickCount = 1);
if (this.isListening("MouseDown")) {
var f = this._createMouseEvent("MouseDown", e);
this.onMouseDown(f);
if (f.defaultPrevented) {
e.preventDefault();
return
}
}
n === 1 && this._handleMouse(e) && (r.isIE >= 9 || r.isOpera || r.isChrome || r.isSafari || r.isFirefox && !this._overlayDiv) && (this._hasFocus || this.focus(), e.preventDefault()), r.isFirefox && this._lastMouseButton === 3 && this._updateDOMSelection()
},
_handleMouseOver: function (e) {
this.isListening("MouseOver") && this.onMouseOver(this._createMouseEvent("MouseOver", e))
},
_handleMouseOut: function (e) {
this.isListening("MouseOut") && this.onMouseOut(this._createMouseEvent("MouseOut", e))
},
_handleMouseMove: function (e) {
var t = this._isClientDiv(e);
this.isListening("MouseMove") && t && this.onMouseMove(this._createMouseEvent("MouseMove", e));
if (this._dropTarget) return;
var n = this._linksVisible || this._lastMouseMoveX !== e.clientX || this._lastMouseMoveY !== e.clientY;
this._lastMouseMoveX = e.clientX, this._lastMouseMoveY = e.clientY, this._setLinksVisible(n && !this._isMouseDown && (r.isMac ? e.metaKey : e.ctrlKey));
if (!this._isW3CEvents) {
if (e.button === 0) return this._setGrab(null), !0;
if (!this._isMouseDown && e.button === 1 && (this._clickCount & 1) !== 0 && t) return this._clickCount = 2, this._handleMouse(e, this._clickCount)
}
if (!this._isMouseDown || this._dragOffset !== -1) return;
var i = e.clientX,
s = e.clientY,
o = this._getViewPadding(),
u = this._viewDiv.getBoundingClientRect(),
a = this._getClientWidth(),
f = this._getClientHeight(),
l = u.left + o.left,
c = u.top + o.top,
h = u.left + o.left + a,
p = u.top + o.top + f,
d = this._model,
v = d.getLineAtOffset(this._getSelection().getCaret());
s < c && v !== 0 ? this._doAutoScroll("up", i, s - c) : s > p && v !== d.getLineCount() - 1 ? this._doAutoScroll("down", i, s - p) : i < l && !this._wrapMode ? this._doAutoScroll("left", i - l, s) : i > h && !this._wrapMode ? this._doAutoScroll("right", i - h, s) : (this._endAutoScroll(), this._setSelectionTo(i, s, !0))
},
_isClientDiv: function (e) {
var t = this._overlayDiv || this._clientDiv,
n = e.target ? e.target : e.srcElement;
while (n) {
if (t === n) return !0;
n = n.parentNode
}
return !1
},
_createMouseEvent: function (e, t) {
var n = this.convert({
x: t.clientX,
y: t.clientY
}, "page", "document");
return {
type: e,
event: t,
clickCount: this._clickCount,
x: n.x,
y: n.y,
preventDefault: function () {
this.defaultPrevented = !0
}
}
},
_handleMouseUp: function (e) {
var t = e.which ? e.button === 0 : e.button === 1;
this.isListening("MouseUp") && (this._isClientDiv(e) || t && this._isMouseDown) && this.onMouseUp(this._createMouseEvent("MouseUp", e));
if (this._linksVisible) return;
if (t && this._isMouseDown) {
if (this._dragOffset !== -1) {
var n = this._getSelection();
n.extend(this._dragOffset), n.collapse(), this._setSelection(n, !0, !0), this._dragOffset = -1
}
this._isMouseDown = !1, this._endAutoScroll(), this._isW3CEvents && this._setGrab(null), r.isFirefox && e.preventDefault()
}
},
_handleMouseWheel: function (e) {
var t = this._getLineHeight(),
n = 0,
i = 0;
if (r.isIE || r.isOpera) i = -e.wheelDelta / 40 * t;
else if (r.isFirefox) {
var s;
if (r.isMac) s = e.detail * 3;
else {
var o = 256;
s = Math.max(-o, Math.min(o, e.detail)) * t
}
e.axis === e.HORIZONTAL_AXIS ? n = s : i = s
} else if (r.isMac) {
var u = 40,
a = 40;
e.wheelDeltaX % 120 !== 0 && (u = 1), e.wheelDeltaY % 120 !== 0 && (a = 1), n = -e.wheelDeltaX / u, -1 < n && n < 0 && (n = -1), 0 < n && n < 1 && (n = 1), i = -e.wheelDeltaY / a, -1 < i && i < 0 && (i = -1), 0 < i && i < 1 && (i = 1)
} else {
n = -e.wheelDeltaX;
var f = 8;
i = -e.wheelDeltaY / 120 * f * t
} if (r.isSafari) {
var l = e.target;
while (l && l.lineIndex === undefined) l = l.parentNode;
this._mouseWheelLine = l
}
var c = this._getScroll();
this._scrollView(n, i);
var h = this._getScroll();
if (c.x !== h.x || c.y !== h.y) return e.preventDefault && e.preventDefault(), !1
},
_handlePaste: function (e) {
if (this._ignorePaste) return;
if (this._doPaste(e)) {
if (r.isIE) {
var t = this;
this._ignoreFocus = !0;
var n = this._getWindow();
n.setTimeout(function () {
t._updateDOMSelection(), t._ignoreFocus = !1
}, 0)
}
return e.preventDefault && e.preventDefault(), !1
}
},
_handleResize: function (e) {
var t = this._parent.clientWidth,
n = this._parent.clientHeight;
if (this._parentWidth !== t || this._parentHeight !== n) this._parentWidth !== t && this._resetLineHeight(), this._parentWidth = t, this._parentHeight = n, r.isIE < 9 ? this._queueUpdate() : this._update()
},
_handleRulerEvent: function (e) {
var t = e.target ? e.target : e.srcElement,
n = t.lineIndex,
r = t;
while (r && !r._ruler) n === undefined && r.lineIndex !== undefined && (n = r.lineIndex), r = r.parentNode;
var i = r ? r._ruler : null;
if (n === undefined && i && i.getOverview() === "document") {
var s = this._getClientHeight(),
o = this._model.getLineCount(),
u = this._getViewPadding(),
a = this._viewDiv.getBoundingClientRect(),
f = s + u.top + u.bottom - 2 * this._metrics.scrollWidth;
n = Math.floor((e.clientY - a.top - this._metrics.scrollWidth) * o / f), 0 <= n && n < o || (n = undefined)
}
if (i) switch (e.type) {
case "click":
i.onClick && i.onClick(n, e);
break;
case "dblclick":
i.onDblClick && i.onDblClick(n, e);
break;
case "mousemove":
i.onMouseMove && i.onMouseMove(n, e);
break;
case "mouseover":
i.onMouseOver && i.onMouseOver(n, e);
break;
case "mouseout":
i.onMouseOut && i.onMouseOut(n, e)
}
},
_handleScroll: function () {
var e = this._getScroll(),
t = this._hScroll,
n = this._vScroll;
if (t !== e.x || n !== e.y) {
this._checkOverlayScroll(), this._hScroll = e.x, this._vScroll = e.y, this._commitIME(), this._update(n === e.y);
var r = {
type: "Scroll",
oldValue: {
x: t,
y: n
},
newValue: e
};
this.onScroll(r)
}
},
_handleSelectStart: function (e) {
if (this._ignoreSelect) return e && e.preventDefault && e.preventDefault(), !1
},
_getModelOffset: function (e, t) {
if (!e) return;
var n;
e.tagName === "DIV" ? n = e : n = e.parentNode.parentNode;
var r = 0,
i = n.lineIndex;
if (e.tagName !== "DIV") {
var s = n.firstChild;
while (s) {
var o = s.firstChild;
if (o === e) {
s.ignoreChars && (r -= s.ignoreChars), r += t;
break
}
s.ignoreChars && (r -= s.ignoreChars), r += o.data.length, s = s.nextSibling
}
}
return Math.max(0, r) + this._model.getLineStart(i)
},
_updateSelectionFromDOM: function () {
var e = this._getWindow(),
t = e.getSelection(),
n = this._getModelOffset(t.anchorNode, t.anchorOffset),
r = this._getModelOffset(t.focusNode, t.focusOffset);
if (n === undefined || r === undefined) return;
this._setSelection(new d(n, r), !1, !1)
},
_handleSelectionChange: function (e) {
if (this._imeOffset !== -1) return;
if (r.isAndroid) {
var t = this._getWindow();
this._selTimer && t.clearTimeout(this._selTimer);
var n = this;
this._selTimer = t.setTimeout(function () {
if (!n._clientDiv) return;
n._selTimer = null, n._updateSelectionFromDOM()
}, 250)
} else this._updateSelectionFromDOM()
},
_handleTextInput: function (e) {
this._imeOffset = -1;
if (r.isAndroid) {
var t = this._getWindow().getSelection(),
n = t.anchorNode;
while (n) {
if (n.lineIndex !== undefined) break;
n = n.parentNode
}
if (n) {
var i = this._model,
s = n.lineIndex,
o = i.getLine(s),
u = o,
a = 0,
f = i.getLineStart(s);
if (t.rangeCount > 0) {
t.getRangeAt(0).deleteContents();
var l = n.ownerDocument.createTextNode(e.data);
t.getRangeAt(0).insertNode(l);
var c = this._getDOMText(n, l);
u = c.text, a = c.offset, l.parentNode.removeChild(l)
}
n.lineRemoved = !0;
var h = 0;
while (o.charCodeAt(h) === u.charCodeAt(h) && h < a) h++;
var p = o.length - 1,
d = u.length - o.length;
while (o.charCodeAt(p) === u.charCodeAt(p + d) && p + d >= a + e.data.length) p--;
p++;
var v = u.substring(h, p + d);
h += f, p += f, this._modifyContent({
text: v,
start: h,
end: p,
_ignoreDOMSelection: !0
}, !0)
}
} else this._doContent(e.data);
e.preventDefault()
},
_handleTouchStart: function (e) {
this._commitIME();
var t = this._getWindow();
this._touchScrollTimer && (this._vScrollDiv.style.display = "none", this._hScrollDiv.style.display = "none", t.clearInterval(this._touchScrollTimer), this._touchScrollTimer = null);
var n = e.touches;
if (n.length === 1) {
var i = n[0],
s = i.clientX,
o = i.clientY;
this._touchStartX = s, this._touchStartY = o, r.isAndroid && (o < i.pageY - t.pageYOffset || s < i.pageX - t.pageXOffset) && (s = i.pageX - t.pageXOffset, o = i.pageY - t.pageYOffset);
var u = this.convert({
x: s,
y: o
}, "page", "document");
this._lastTouchOffset = this.getOffsetAtLocation(u.x, u.y), this._touchStartTime = e.timeStamp, this._touching = !0
}
},
_handleTouchMove: function (e) {
var t = e.touches;
if (t.length === 1) {
var n = t[0];
this._touchCurrentX = n.clientX, this._touchCurrentY = n.clientY;
var r = 10;
if (!this._touchScrollTimer && e.timeStamp - this._touchStartTime < r * 20) {
this._vScrollDiv.style.display = "block", this._wrapMode || (this._hScrollDiv.style.display = "block");
var i = this,
s = this._getWindow();
this._touchScrollTimer = s.setInterval(function () {
var e = 0,
t = 0;
if (i._touching) e = i._touchStartX - i._touchCurrentX, t = i._touchStartY - i._touchCurrentY, i._touchSpeedX = e / r, i._touchSpeedY = t / r, i._touchStartX = i._touchCurrentX, i._touchStartY = i._touchCurrentY;
else {
if (Math.abs(i._touchSpeedX) < .1 && Math.abs(i._touchSpeedY) < .1) {
i._vScrollDiv.style.display = "none", i._hScrollDiv.style.display = "none", s.clearInterval(i._touchScrollTimer), i._touchScrollTimer = null;
return
}
e = i._touchSpeedX * r, t = i._touchSpeedY * r, i._touchSpeedX *= .95, i._touchSpeedY *= .95
}
i._scrollView(e, t)
}, r)
}
this._touchScrollTimer && e.preventDefault()
}
},
_handleTouchEnd: function (e) {
var t = e.touches;
t.length === 0 && (this._touching = !1)
},
_doAction: function (e) {
var t = this._keyBindings;
for (var n = 0; n < t.length; n++) {
var r = t[n];
if (r.keyBinding.match(e)) {
if (r.actionID) {
var i = this._actions,
s = i[r.actionID];
if (s)
if (s.handler) {
if (!s.handler()) return s.defaultHandler ? typeof s.defaultHandler() == "boolean" : !1
} else if (s.defaultHandler) return typeof s.defaultHandler() == "boolean"
}
return !0
}
}
return !1
},
_doBackspace: function (e) {
var t = this._getSelection();
if (t.isEmpty()) {
var n = this._model,
r = t.getCaret(),
i = n.getLineAtOffset(r),
s = n.getLineStart(i);
if (r === s) i > 0 && t.extend(n.getLineEnd(i - 1));
else {
var o = !1;
if (this._expandTab && e.unit === "character" && (r - s) % this._tabSize === 0) {
var u = n.getText(s, r);
o = !/[^ ]/.test(u)
}
if (o) t.extend(r - this._tabSize);
else {
var a = this._getLine(i);
t.extend(a.getNextOffset(r, e.unit, -1)), a.destroy()
}
}
}
return this._modifyContent({
text: "",
start: t.start,
end: t.end
}, !0), !0
},
_doContent: function (e) {
var t = this._getSelection();
this._modifyContent({
text: e,
start: t.start,
end: t.end,
_ignoreDOMSelection: !0
}, !0)
},
_doCopy: function (e) {
var t = this._getSelection();
if (!t.isEmpty()) {
var n = this._getBaseText(t.start, t.end);
return this._setClipboardText(n, e)
}
return !0
},
_doCursorNext: function (e) {
if (!e.select && this._clearSelection("next")) return !0;
var t = this._model,
n = this._getSelection(),
r = n.getCaret(),
i = t.getLineAtOffset(r);
if (r === t.getLineEnd(i)) i + 1 < t.getLineCount() && n.extend(t.getLineStart(i + 1));
else {
var s = this._getLine(i);
n.extend(s.getNextOffset(r, e.unit, 1)), s.destroy()
}
return e.select || n.collapse(), this._setSelection(n, !0), !0
},
_doCursorPrevious: function (e) {
if (!e.select && this._clearSelection("previous")) return !0;
var t = this._model,
n = this._getSelection(),
r = n.getCaret(),
i = t.getLineAtOffset(r);
if (r === t.getLineStart(i)) i > 0 && n.extend(t.getLineEnd(i - 1));
else {
var s = this._getLine(i);
n.extend(s.getNextOffset(r, e.unit, -1)), s.destroy()
}
return e.select || n.collapse(), this._setSelection(n, !0), !0
},
_doCut: function (e) {
var t = this._getSelection();
if (!t.isEmpty()) {
var n = this._getBaseText(t.start, t.end);
return this._doContent(""), this._setClipboardText(n, e)
}
return !0
},
_doDelete: function (e) {
var t = this._getSelection();
if (t.isEmpty()) {
var n = this._model,
r = t.getCaret(),
i = n.getLineAtOffset(r);
if (r === n.getLineEnd(i)) i + 1 < n.getLineCount() && t.extend(n.getLineStart(i + 1));
else {
var s = this._getLine(i);
t.extend(s.getNextOffset(r, e.unit, 1)), s.destroy()
}
}
return this._modifyContent({
text: "",
start: t.start,
end: t.end
}, !0), !0
},
_doEnd: function (e) {
var t = this._getSelection(),
n = this._model;
if (e.ctrl) t.extend(n.getCharCount());
else {
var r = t.getCaret(),
i = n.getLineAtOffset(r);
if (this._wrapMode) {
var s = this._getLine(i),
o = s.getLineIndex(r);
o === s.getLineCount() - 1 ? r = n.getLineEnd(i) : r = s.getLineStart(o + 1) - 1, s.destroy()
} else r = n.getLineEnd(i);
t.extend(r)
}
return e.select || t.collapse(), this._setSelection(t, !0), !0
},
_doEnter: function (e) {
var t = this._model,
n = this._getSelection();
return this._doContent(t.getLineDelimiter()), e && e.noCursor && (n.end = n.start, this._setSelection(n)), !0
},
_doHome: function (e) {
var t = this._getSelection(),
n = this._model;
if (e.ctrl) t.extend(0);
else {
var r = t.getCaret(),
i = n.getLineAtOffset(r);
if (this._wrapMode) {
var s = this._getLine(i),
o = s.getLineIndex(r);
r = s.getLineStart(o), s.destroy()
} else r = n.getLineStart(i);
t.extend(r)
}
return e.select || t.collapse(), this._setSelection(t, !0), !0
},
_doLineDown: function (e) {
var t = this._model,
n = this._getSelection(),
i = n.getCaret(),
s = t.getLineAtOffset(i),
o, u = this._getLine(s),
a = this._columnX,
f = 1,
l = !1;
if (a === -1 || e.wholeLine || e.select && r.isIE) {
var c = e.wholeLine ? t.getLineEnd(s + 1) : i;
a = u.getBoundingClientRect(c).left
}
return (o = u.getLineIndex(i)) < u.getLineCount() - 1 ? f = u.getClientRects(o + 1).top + 1 : (l = s === t.getLineCount() - 1, s++), l ? e.select && (n.extend(t.getCharCount()), this._setSelection(n, !0, !0)) : (u.lineIndex !== s && (u.destroy(), u = this._getLine(s)), n.extend(u.getOffset(a, f)), e.select || n.collapse(), this._setSelection(n, !0, !0)), this._columnX = a, u.destroy(), !0
},
_doLineUp: function (e) {
var t = this._model,
n = this._getSelection(),
i = n.getCaret(),
s = t.getLineAtOffset(i),
o, u = this._getLine(s),
a = this._columnX,
f = !1,
l;
if (a === -1 || e.wholeLine || e.select && r.isIE) {
var c = e.wholeLine ? t.getLineStart(s - 1) : i;
a = u.getBoundingClientRect(c).left
}
return (o = u.getLineIndex(i)) > 0 ? l = u.getClientRects(o - 1).top + 1 : (f = s === 0, f || (s--, l = this._getLineHeight(s) - 1)), f ? e.select && (n.extend(0), this._setSelection(n, !0, !0)) : (u.lineIndex !== s && (u.destroy(), u = this._getLine(s)), n.extend(u.getOffset(a, l)), e.select || n.collapse(), this._setSelection(n, !0, !0)), this._columnX = a, u.destroy(), !0
},
_doPageDown: function (e) {
var t = this._model,
n = this._getSelection(),
i = n.getCaret(),
s = t.getLineAtOffset(i),
o = t.getLineCount(),
u = this._getScroll(),
a = this._getClientHeight(),
f, l;
if (this._lineHeight) {
f = this._columnX;
var c = this._getBoundsAtOffset(i);
if (f === -1 || e.select && r.isIE) f = c.left;
var h = this._getLineIndex(c.top + a);
l = this._getLine(h);
var p = this._getLinePixel(h),
d = c.top + a - p;
i = l.getOffset(f, d);
var v = l.getBoundingClientRect(i);
return l.destroy(), n.extend(i), e.select || n.collapse(), this._setSelection(n, !0, !0, v.top + p - c.top), this._columnX = f, !0
}
if (s < o - 1) {
var m = this._getLineHeight(),
g = Math.floor(a / m),
y = Math.min(o - s - 1, g);
y = Math.max(1, y), f = this._columnX;
if (f === -1 || e.select && r.isIE) l = this._getLine(s), f = l.getBoundingClientRect(i).left, l.destroy();
l = this._getLine(s + y), n.extend(l.getOffset(f, 0)), l.destroy(), e.select || n.collapse();
var b = o * m,
w = u.y + y * m;
w + a > b && (w = b - a), this._setSelection(n, !0, !0, w - u.y), this._columnX = f
}
return !0
},
_doPageUp: function (e) {
var t = this._model,
n = this._getSelection(),
i = n.getCaret(),
s = t.getLineAtOffset(i),
o = this._getScroll(),
u = this._getClientHeight(),
a, f;
if (this._lineHeight) {
a = this._columnX;
var l = this._getBoundsAtOffset(i);
if (a === -1 || e.select && r.isIE) a = l.left;
var c = this._getLineIndex(l.bottom - u);
f = this._getLine(c);
var h = this._getLinePixel(c),
p = l.bottom - u - h;
i = f.getOffset(a, p);
var d = f.getBoundingClientRect(i);
return f.destroy(), n.extend(i), e.select || n.collapse(), this._setSelection(n, !0, !0, d.top + h - l.top), this._columnX = a, !0
}
if (s > 0) {
var v = this._getLineHeight(),
m = Math.floor(u / v),
g = Math.max(1, Math.min(s, m));
a = this._columnX;
if (a === -1 || e.select && r.isIE) f = this._getLine(s), a = f.getBoundingClientRect(i).left, f.destroy();
f = this._getLine(s - g), n.extend(f.getOffset(a, this._getLineHeight(s - g) - 1)), f.destroy(), e.select || n.collapse();
var y = Math.max(0, o.y - g * v);
this._setSelection(n, !0, !0, y - o.y), this._columnX = a
}
return !0
},
_doPaste: function (e) {
var t = this,
n = this._getClipboardText(e, function (e) {
if (e) {
if (r.isLinux && t._lastMouseButton === 2) {
var n = (new Date).getTime() - t._lastMouseTime;
n <= t._clickTime && t._setSelectionTo(t._lastMouseX, t._lastMouseY)
}
t._doContent(e)
}
});
return n !== null
},
_doScroll: function (e) {
var t = e.type,
n = this._model,
r = n.getLineCount(),
i = this._getClientHeight(),
s = this._getLineHeight(),
o = r * s,
u = this._getScroll().y,
a;
switch (t) {
case "textStart":
a = 0;
break;
case "textEnd":
a = o - i;
break;
case "pageDown":
a = u + i;
break;
case "pageUp":
a = u - i;
break;
case "centerLine":
var f = this._getSelection(),
l = n.getLineAtOffset(f.start),
c = n.getLineAtOffset(f.end),
h = (c - l + 1) * s;
a = l * s - i / 2 + h / 2
}
return a !== undefined && (a = Math.min(Math.max(0, a), o - i), this._scrollView(0, a - u)), !0
},
_doSelectAll: function (e) {
var t = this._model,
n = this._getSelection();
return n.setCaret(0), n.extend(t.getCharCount()), this._setSelection(n, !1), !0
},
_doTab: function (e) {
if (!this._tabMode || this._readonly) return;
var t = " ";
if (this._expandTab) {
var n = this._model,
r = this._getSelection().getCaret(),
i = n.getLineAtOffset(r),
s = n.getLineStart(i),
o = this._tabSize - (r - s) % this._tabSize;
t = (new Array(o + 1)).join(" ")
}
return this._doContent(t), !0
},
_doShiftTab: function (e) {
if (!this._tabMode || this._readonly) return;
return !0
},
_doTabMode: function (e) {
return this._tabMode = !this._tabMode, !0
},
_doWrapMode: function (e) {
return this.setOptions({
wrapMode: !this.getOptions("wrapMode")
}), !0
},
_autoScroll: function () {
var e = this._getSelection(),
t = this.convert({
x: this._autoScrollX,
y: this._autoScrollY
}, "page", "document"),
n = e.getCaret(),
r = this._model.getLineAtOffset(n),
i, s;
if (this._autoScrollDir === "up" || this._autoScrollDir === "down") {
var o = this._autoScrollY / this._getLineHeight();
o = o < 0 ? Math.floor(o) : Math.ceil(o), i = r, i = Math.max(0, Math.min(this._model.getLineCount() - 1, i + o))
} else if (this._autoScrollDir === "left" || this._autoScrollDir === "right") i = this._getLineIndex(t.y), s = this._getLine(r), t.x += s.getBoundingClientRect(n, !1).left, s.destroy();
s = this._getLine(i), e.extend(s.getOffset(t.x, t.y - this._getLinePixel(i))), s.destroy(), this._setSelection(e, !0)
},
_autoScrollTimer: function () {
this._autoScroll();
var e = this,
t = this._getWindow();
this._autoScrollTimerID = t.setTimeout(function () {
e._autoScrollTimer()
}, this._AUTO_SCROLL_RATE)
},
_calculateLineHeightTimer: function (e) {
if (!this._lineHeight) return;
if (this._calculateLHTimer) return;
var t = this._model.getLineCount(),
n = 0;
if (e) {
var r = 0,
i = 100,
s = (new Date).getTime(),
o = 0;
while (n < t) {
this._lineHeight[n] || (r++, o || (o = n), this._lineHeight[n] = this._calculateLineHeight(n)), n++;
if ((new Date).getTime() - s > i) break
}
this.redrawRulers(0, t), this._queueUpdate()
}
var u = this._getWindow();
if (n !== t) {
var a = this;
this._calculateLHTimer = u.setTimeout(function () {
a._calculateLHTimer = null, a._calculateLineHeightTimer(!0)
}, 0);
return
}
this._calculateLHTimer && (u.clearTimeout(this._calculateLHTimer), this._calculateLHTimer = undefined)
},
_calculateLineHeight: function (e) {
var t = this._getLine(e),
n = t.getBoundingClientRect();
return t.destroy(), Math.max(1, Math.ceil(n.bottom - n.top))
},
_calculateMetrics: function () {
var e = this._clientDiv,
t = e.ownerDocument,
n = " ",
i = r.createElement(t, "div");
i.style.lineHeight = "normal";
var s = this._model,
o = s.getLine(0),
a = {
type: "LineStyle",
textView: this,
0: 0,
lineText: o,
lineStart: 0
};
this.onLineStyle(a), u(a.style, i), i.style.position = "fixed", i.style.left = "-1000px";
var f = r.createElement(t, "span");
f.appendChild(t.createTextNode(n)), i.appendChild(f);
var l = r.createElement(t, "span");
l.style.fontStyle = "italic", l.appendChild(t.createTextNode(n)), i.appendChild(l);
var c = r.createElement(t, "span");
c.style.fontWeight = "bold", c.appendChild(t.createTextNode(n)), i.appendChild(c);
var d = r.createElement(t, "span");
d.style.fontWeight = "bold", d.style.fontStyle = "italic", d.appendChild(t.createTextNode(n)), i.appendChild(d), e.appendChild(i);
var v = i.getBoundingClientRect(),
m = f.getBoundingClientRect(),
g = l.getBoundingClientRect(),
y = c.getBoundingClientRect(),
b = d.getBoundingClientRect(),
w = m.bottom - m.top,
E = g.bottom - g.top,
S = y.bottom - y.top,
x = b.bottom - b.top,
T = 0,
N = v.bottom - v.top <= 0,
C = Math.max(1, v.bottom - v.top);
E > w && (T = 1), S > E && (T = 2), x > S && (T = 3);
var k;
T !== 0 && (k = {
style: {}
}, (T & 1) !== 0 && (k.style.fontStyle = "italic"), (T & 2) !== 0 && (k.style.fontWeight = "bold"));
var L = p(i);
e.removeChild(i);
var A = h(this._viewDiv),
O = r.createElement(t, "div");
O.style.position = "fixed", O.style.left = "-1000px", O.style.paddingLeft = A.left + "px", O.style.paddingTop = A.top + "px", O.style.paddingRight = A.right + "px", O.style.paddingBottom = A.bottom + "px", O.style.width = "100px", O.style.height = "100px";
var M = r.createElement(t, "div");
M.style.width = "100%", M.style.height = "100%", O.appendChild(M), e.appendChild(O);
var _ = O.getBoundingClientRect(),
D = M.getBoundingClientRect();
O.style.overflow = "hidden", M.style.height = "200px";
var P = O.clientWidth;
O.style.overflow = "scroll";
var H = O.clientWidth;
e.removeChild(O);
var B = P - H;
return A = {
left: D.left - _.left,
top: D.top - _.top,
right: _.right - D.right,
bottom: _.bottom - D.bottom
}, {
lineHeight: C,
largestFontStyle: k,
lineTrim: L,
viewPadding: A,
scrollWidth: B,
invalid: N
}
},
_checkOverlayScroll: function () {
if (!r.isMac) return;
var e = this,
t = this._getWindow();
this._overlayScrollTimer && t.clearTimeout(this._overlayScrollTimer);
var n = function () {
var r = e._isOverOverlayScroll();
r.vertical || r.horizontal ? e._overlayScrollTimer = t.setTimeout(n, 200) : (e._overlayScrollTimer = undefined, e._update())
};
this._overlayScrollTimer = t.setTimeout(n, 200)
},
_clearSelection: function (e) {
var t = this._getSelection();
return t.isEmpty() ? !1 : (e === "next" ? t.start = t.end : t.end = t.start, this._setSelection(t, !0), !0)
},
_commitIME: function () {
if (this._imeOffset === -1) return;
this._scrollDiv.focus(), this._clientDiv.focus();
var e = this._model,
t = e.getLineAtOffset(this._imeOffset),
n = e.getLineStart(t),
r = this._getDOMText(this._getLineNode(t)).text,
i = e.getLine(t),
s = this._imeOffset - n,
o = s + r.length - i.length;
if (s !== o) {
var u = r.substring(s, o);
this._doContent(u)
}
this._imeOffset = -1
},
_createActions: function () {
var e = t.KeyBinding,
n = this._keyBindings = [];
n.push({
actionID: "lineUp",
keyBinding: new e(38),
predefined: !0
}), n.push({
actionID: "lineDown",
keyBinding: new e(40),
predefined: !0
}), n.push({
actionID: "charPrevious",
keyBinding: new e(37),
predefined: !0
}), n.push({
actionID: "charNext",
keyBinding: new e(39),
predefined: !0
}), r.isMac ? (n.push({
actionID: "scrollPageUp",
keyBinding: new e(33),
predefined: !0
}), n.push({
actionID: "scrollPageDown",
keyBinding: new e(34),
predefined: !0
}), n.push({
actionID: "pageUp",
keyBinding: new e(33, null, null, !0),
predefined: !0
}), n.push({
actionID: "pageDown",
keyBinding: new e(34, null, null, !0),
predefined: !0
}), n.push({
actionID: "lineStart",
keyBinding: new e(37, !0),
predefined: !0
}), n.push({
actionID: "lineEnd",
keyBinding: new e(39, !0),
predefined: !0
}), n.push({
actionID: "wordPrevious",
keyBinding: new e(37, null, null, !0),
predefined: !0
}), n.push({
actionID: "wordNext",
keyBinding: new e(39, null, null, !0),
predefined: !0
}), n.push({
actionID: "scrollTextStart",
keyBinding: new e(36),
predefined: !0
}), n.push({
actionID: "scrollTextEnd",
keyBinding: new e(35),
predefined: !0
}), n.push({
actionID: "textStart",
keyBinding: new e(38, !0),
predefined: !0
}), n.push({
actionID: "textEnd",
keyBinding: new e(40, !0),
predefined: !0
}), n.push({
actionID: "scrollPageUp",
keyBinding: new e(38, null, null, null, !0),
predefined: !0
}), n.push({
actionID: "scrollPageDown",
keyBinding: new e(40, null, null, null, !0),
predefined: !0
}), n.push({
actionID: "lineStart",
keyBinding: new e(37, null, null, null, !0),
predefined: !0
}), n.push({
actionID: "lineEnd",
keyBinding: new e(39, null, null, null, !0),
predefined: !0
}), n.push({
actionID: "lineStart",
keyBinding: new e(38, null, null, !0),
predefined: !0
}), n.push({
actionID: "lineEnd",
keyBinding: new e(40, null, null, !0),
predefined: !0
})) : (n.push({
actionID: "pageUp",
keyBinding: new e(33),
predefined: !0
}), n.push({
actionID: "pageDown",
keyBinding: new e(34),
predefined: !0
}), n.push({
actionID: "lineStart",
keyBinding: new e(36),
predefined: !0
}), n.push({
actionID: "lineEnd",
keyBinding: new e(35),
predefined: !0
}), n.push({
actionID: "wordPrevious",
keyBinding: new e(37, !0),
predefined: !0
}), n.push({
actionID: "wordNext",
keyBinding: new e(39, !0),
predefined: !0
}), n.push({
actionID: "textStart",
keyBinding: new e(36, !0),
predefined: !0
}), n.push({
actionID: "textEnd",
keyBinding: new e(35, !0),
predefined: !0
})), r.isFirefox && r.isLinux && (n.push({
actionID: "lineUp",
keyBinding: new e(38, !0),
predefined: !0
}), n.push({
actionID: "lineDown",
keyBinding: new e(40, !0),
predefined: !0
})), n.push({
actionID: "selectLineUp",
keyBinding: new e(38, null, !0),
predefined: !0
}), n.push({
actionID: "selectLineDown",
keyBinding: new e(40, null, !0),
predefined: !0
}), n.push({
actionID: "selectCharPrevious",
keyBinding: new e(37, null, !0),
predefined: !0
}), n.push({
actionID: "selectCharNext",
keyBinding: new e(39, null, !0),
predefined: !0
}), n.push({
actionID: "selectPageUp",
keyBinding: new e(33, null, !0),
predefined: !0
}), n.push({
actionID: "selectPageDown",
keyBinding: new e(34, null, !0),
predefined: !0
}), r.isMac ? (n.push({
actionID: "selectLineStart",
keyBinding: new e(37, !0, !0),
predefined: !0
}), n.push({
actionID: "selectLineEnd",
keyBinding: new e(39, !0, !0),
predefined: !0
}), n.push({
actionID: "selectWordPrevious",
keyBinding: new e(37, null, !0, !0),
predefined: !0
}), n.push({
actionID: "selectWordNext",
keyBinding: new e(39, null, !0, !0),
predefined: !0
}), n.push({
actionID: "selectTextStart",
keyBinding: new e(36, null, !0),
predefined: !0
}), n.push({
actionID: "selectTextEnd",
keyBinding: new e(35, null, !0),
predefined: !0
}), n.push({
actionID: "selectTextStart",
keyBinding: new e(38, !0, !0),
predefined: !0
}), n.push({
actionID: "selectTextEnd",
keyBinding: new e(40, !0, !0),
predefined: !0
}), n.push({
actionID: "selectLineStart",
keyBinding: new e(37, null, !0, null, !0),
predefined: !0
}), n.push({
actionID: "selectLineEnd",
keyBinding: new e(39, null, !0, null, !0),
predefined: !0
}), n.push({
actionID: "selectLineStart",
keyBinding: new e(38, null, !0, !0),
predefined: !0
}), n.push({
actionID: "selectLineEnd",
keyBinding: new e(40, null, !0, !0),
predefined: !0
})) : (r.isLinux && (n.push({
actionID: "selectWholeLineUp",
keyBinding: new e(38, !0, !0),
predefined: !0
}), n.push({
actionID: "selectWholeLineDown",
keyBinding: new e(40, !0, !0),
predefined: !0
})), n.push({
actionID: "selectLineStart",
keyBinding: new e(36, null, !0),
predefined: !0
}), n.push({
actionID: "selectLineEnd",
keyBinding: new e(35, null, !0),
predefined: !0
}), n.push({
actionID: "selectWordPrevious",
keyBinding: new e(37, !0, !0),
predefined: !0
}), n.push({
actionID: "selectWordNext",
keyBinding: new e(39, !0, !0),
predefined: !0
}), n.push({
actionID: "selectTextStart",
keyBinding: new e(36, !0, !0),
predefined: !0
}), n.push({
actionID: "selectTextEnd",
keyBinding: new e(35, !0, !0),
predefined: !0
})), n.push({
actionID: "undo",
keyBinding: new t.KeyBinding("z", !0),
predefined: !0
}), r.isMac ? n.push({
actionID: "redo",
keyBinding: new t.KeyBinding("z", !0, !0),
predefined: !0
}) : n.push({
actionID: "redo",
keyBinding: new t.KeyBinding("y", !0),
predefined: !0
}), n.push({
actionID: "deletePrevious",
keyBinding: new e(8),
predefined: !0
}), n.push({
actionID: "deletePrevious",
keyBinding: new e(8, null, !0),
predefined: !0
}), n.push({
actionID: "deleteNext",
keyBinding: new e(46),
predefined: !0
}), n.push({
actionID: "deleteWordPrevious",
keyBinding: new e(8, !0),
predefined: !0
}), n.push({
actionID: "deleteWordPrevious",
keyBinding: new e(8, !0, !0),
predefined: !0
}), n.push({
actionID: "deleteWordNext",
keyBinding: new e(46, !0),
predefined: !0
}), n.push({
actionID: "tab",
keyBinding: new e(9),
predefined: !0
}), n.push({
actionID: "shiftTab",
keyBinding: new e(9, null, !0),
predefined: !0
}), n.push({
actionID: "enter",
keyBinding: new e(13),
predefined: !0
}), n.push({
actionID: "enter",
keyBinding: new e(13, null, !0),
predefined: !0
}), n.push({
actionID: "selectAll",
keyBinding: new e("a", !0),
predefined: !0
}), n.push({
actionID: "toggleTabMode",
keyBinding: new e("m", !0),
predefined: !0
}), r.isMac && (n.push({
actionID: "deleteNext",
keyBinding: new e(46, null, !0),
predefined: !0
}), n.push({
actionID: "deleteWordPrevious",
keyBinding: new e(8, null, null, !0),
predefined: !0
}), n.push({
actionID: "deleteWordNext",
keyBinding: new e(46, null, null, !0),
predefined: !0
}));
if (!r.isFirefox) {
var i = r.isMac && r.isChrome;
n.push({
actionID: null,
keyBinding: new e("u", !i, !1, !1, i),
predefined: !0
}), n.push({
actionID: null,
keyBinding: new e("i", !i, !1, !1, i),
predefined: !0
}), n.push({
actionID: null,
keyBinding: new e("b", !i, !1, !1, i),
predefined: !0
})
}
r.isFirefox && (n.push({
actionID: "copy",
keyBinding: new e(45, !0),
predefined: !0
}), n.push({
actionID: "paste",
keyBinding: new e(45, null, !0),
predefined: !0
}), n.push({
actionID: "cut",
keyBinding: new e(46, null, !0),
predefined: !0
})), r.isMac && (n.push({
actionID: "lineStart",
keyBinding: new e("a", !1, !1, !1, !0),
predefined: !0
}), n.push({
actionID: "lineEnd",
keyBinding: new e("e", !1, !1, !1, !0),
predefined: !0
}), n.push({
actionID: "lineUp",
keyBinding: new e("p", !1, !1, !1, !0),
predefined: !0
}), n.push({
actionID: "lineDown",
keyBinding: new e("n", !1, !1, !1, !0),
predefined: !0
}), n.push({
actionID: "charPrevious",
keyBinding: new e("b", !1, !1, !1, !0),
predefined: !0
}), n.push({
actionID: "charNext",
keyBinding: new e("f", !1, !1, !1, !0),
predefined: !0
}), n.push({
actionID: "deletePrevious",
keyBinding: new e("h", !1, !1, !1, !0),
predefined: !0
}), n.push({
actionID: "deleteNext",
keyBinding: new e("d", !1, !1, !1, !0),
predefined: !0
}), n.push({
actionID: "deleteLineEnd",
keyBinding: new e("k", !1, !1, !1, !0),
predefined: !0
}), r.isFirefox ? (n.push({
actionID: "scrollPageDown",
keyBinding: new e("v", !1, !1, !1, !0),
predefined: !0
}), n.push({
actionID: "deleteLineStart",
keyBinding: new e("u", !1, !1, !1, !0),
predefined: !0
}), n.push({
actionID: "deleteWordPrevious",
keyBinding: new e("w", !1, !1, !1, !0),
predefined: !0
})) : (n.push({
actionID: "pageDown",
keyBinding: new e("v", !1, !1, !1, !0),
predefined: !0
}), n.push({
actionID: "centerLine",
keyBinding: new e("l", !1, !1, !1, !0),
predefined: !0
}), n.push({
actionID: "enterNoCursor",
keyBinding: new e("o", !1, !1, !1, !0),
predefined: !0
})));
var s = this;
this._actions = {
lineUp: {
defaultHandler: function () {
return s._doLineUp({
select: !1
})
}
},
lineDown: {
defaultHandler: function () {
return s._doLineDown({
select: !1
})
}
},
lineStart: {
defaultHandler: function () {
return s._doHome({
select: !1,
ctrl: !1
})
}
},
lineEnd: {
defaultHandler: function () {
return s._doEnd({
select: !1,
ctrl: !1
})
}
},
charPrevious: {
defaultHandler: function () {
return s._doCursorPrevious({
select: !1,
unit: "character"
})
}
},
charNext: {
defaultHandler: function () {
return s._doCursorNext({
select: !1,
unit: "character"
})
}
},
pageUp: {
defaultHandler: function () {
return s._doPageUp({
select: !1
})
}
},
pageDown: {
defaultHandler: function () {
return s._doPageDown({
select: !1
})
}
},
scrollPageUp: {
defaultHandler: function () {
return s._doScroll({
type: "pageUp"
})
}
},
scrollPageDown: {
defaultHandler: function () {
return s._doScroll({
type: "pageDown"
})
}
},
wordPrevious: {
defaultHandler: function () {
return s._doCursorPrevious({
select: !1,
unit: "word"
})
}
},
wordNext: {
defaultHandler: function () {
return s._doCursorNext({
select: !1,
unit: "word"
})
}
},
textStart: {
defaultHandler: function () {
return s._doHome({
select: !1,
ctrl: !0
})
}
},
textEnd: {
defaultHandler: function () {
return s._doEnd({
select: !1,
ctrl: !0
})
}
},
scrollTextStart: {
defaultHandler: function () {
return s._doScroll({
type: "textStart"
})
}
},
scrollTextEnd: {
defaultHandler: function () {
return s._doScroll({
type: "textEnd"
})
}
},
centerLine: {
defaultHandler: function () {
return s._doScroll({
type: "centerLine"
})
}
},
selectLineUp: {
defaultHandler: function () {
return s._doLineUp({
select: !0
})
}
},
selectLineDown: {
defaultHandler: function () {
return s._doLineDown({
select: !0
})
}
},
selectWholeLineUp: {
defaultHandler: function () {
return s._doLineUp({
select: !0,
wholeLine: !0
})
}
},
selectWholeLineDown: {
defaultHandler: function () {
return s._doLineDown({
select: !0,
wholeLine: !0
})
}
},
selectLineStart: {
defaultHandler: function () {
return s._doHome({
select: !0,
ctrl: !1
})
}
},
selectLineEnd: {
defaultHandler: function () {
return s._doEnd({
select: !0,
ctrl: !1
})
}
},
selectCharPrevious: {
defaultHandler: function () {
return s._doCursorPrevious({
select: !0,
unit: "character"
})
}
},
selectCharNext: {
defaultHandler: function () {
return s._doCursorNext({
select: !0,
unit: "character"
})
}
},
selectPageUp: {
defaultHandler: function () {
return s._doPageUp({
select: !0
})
}
},
selectPageDown: {
defaultHandler: function () {
return s._doPageDown({
select: !0
})
}
},
selectWordPrevious: {
defaultHandler: function () {
return s._doCursorPrevious({
select: !0,
unit: "word"
})
}
},
selectWordNext: {
defaultHandler: function () {
return s._doCursorNext({
select: !0,
unit: "word"
})
}
},
selectTextStart: {
defaultHandler: function () {
return s._doHome({
select: !0,
ctrl: !0
})
}
},
selectTextEnd: {
defaultHandler: function () {
return s._doEnd({
select: !0,
ctrl: !0
})
}
},
deletePrevious: {
defaultHandler: function () {
return s._doBackspace({
unit: "character"
})
}
},
deleteNext: {
defaultHandler: function () {
return s._doDelete({
unit: "character"
})
}
},
deleteWordPrevious: {
defaultHandler: function () {
return s._doBackspace({
unit: "word"
})
}
},
deleteWordNext: {
defaultHandler: function () {
return s._doDelete({
unit: "word"
})
}
},
deleteLineStart: {
defaultHandler: function () {
return s._doBackspace({
unit: "line"
})
}
},
deleteLineEnd: {
defaultHandler: function () {
return s._doDelete({
unit: "line"
})
}
},
tab: {
defaultHandler: function () {
return s._doTab()
}
},
shiftTab: {
defaultHandler: function () {
return s._doShiftTab()
}
},
enter: {
defaultHandler: function () {
return s._doEnter()
}
},
enterNoCursor: {
defaultHandler: function () {
return s._doEnter({
noCursor: !0
})
}
},
selectAll: {
defaultHandler: function () {
return s._doSelectAll()
}
},
copy: {
defaultHandler: function () {
return s._doCopy()
}
},
cut: {
defaultHandler: function () {
return s._doCut()
}
},
paste: {
defaultHandler: function () {
return s._doPaste()
}
},
toggleWrapMode: {
defaultHandler: function () {
return s._doWrapMode()
}
},
toggleTabMode: {
defaultHandler: function () {
return s._doTabMode()
}
}
}
},
_createRuler: function (e, t) {
if (!this._clientDiv) return;
var n = e.getLocation(),
i = n === "left" ? this._leftDiv : this._rightDiv;
i.style.display = "block";
var s = r.createElement(i.ownerDocument, "div");
s._ruler = e, s.rulerChanged = !0, s.style.position = "relative";
var o = i.firstChild.rows[0],
u = o.cells.length;
t = t === undefined || t < 0 || t > u ? u : t;
var a = o.insertCell(t);
a.vAlign = "top", a.style.verticalAlign = "top", a.style.borderWidth = "0px", a.style.margin = "0px", a.style.padding = "0px", a.style.outline = "none", a.appendChild(s)
},
_createView: function () {
if (this._clientDiv) return;
var e = this._parent;
while (e.hasChildNodes()) e.removeChild(e.lastChild);
var t = e.ownerDocument,
n = r.createElement(t, "div");
this._rootDiv = n, n.tabIndex = -1, n.style.position = "relative", n.style.overflow = "hidden", n.style.width = "100%", n.style.height = "100%", e.style.overflow = "hidden", n.setAttribute("role", "application"), e.appendChild(n);
var i = r.createElement(t, "div");
i.className = "textviewLeftRuler", this._leftDiv = i, i.tabIndex = -1, i.style.overflow = "hidden", i.style.MozUserSelect = "none", i.style.WebkitUserSelect = "none", i.style.position = "absolute", i.style.cursor = "default", i.style.display = "none", i.setAttribute("aria-hidden", "true");
var s = r.createElement(t, "table");
i.appendChild(s), s.cellPadding = "0px", s.cellSpacing = "0px", s.border = "0px", s.style.borderWidth = "0px", s.style.margin = "0px", s.style.padding = "0px", s.style.outline = "none", s.style.lineHeight = "normal";
var o = s.insertRow(0);
o.style.borderWidth = "0px", o.style.margin = "0px", o.style.padding = "0px", o.style.outline = "none", o.style.lineHeight = "normal", n.appendChild(i);
var u = r.createElement(t, "div");
u.className = "textview", this._viewDiv = u, u.tabIndex = -1, u.style.overflow = "auto", u.style.position = "absolute", u.style.top = "0px", u.style.bottom = "0px", u.style.borderWidth = "0px", u.style.margin = "0px", u.style.outline = "none", n.appendChild(u);
var a = r.createElement(t, "div");
a.className = "textviewRightRuler", this._rightDiv = a, a.tabIndex = -1, a.style.display = "none", a.style.overflow = "hidden", a.style.MozUserSelect = "none", a.style.WebkitUserSelect = "none", a.style.position = "absolute", a.style.cursor = "default", a.style.right = "0px", a.setAttribute("aria-hidden", "true"), s = r.createElement(t, "table"), a.appendChild(s), s.cellPadding = "0px", s.cellSpacing = "0px", s.border = "0px", s.style.borderWidth = "0px", s.style.margin = "0px", s.style.padding = "0px", s.style.outline = "none", s.style.lineHeight = "normal", o = s.insertRow(0), o.style.borderWidth = "0px", o.style.margin = "0px", o.style.padding = "0px", o.style.outline = "none", o.style.lineHeight = "normal", n.appendChild(a);
var f = r.createElement(t, "div");
this._scrollDiv = f, f.style.margin = "0px", f.style.borderWidth = "0px", f.style.padding = "0px", u.appendChild(f);
if (r.isFirefox) {
var l = r.createElement(t, "div");
this._clipboardDiv = l, l.style.position = "fixed", l.style.whiteSpace = "pre", l.style.left = "-1000px", n.appendChild(l)
}
if (!r.isIE && !r.isIOS) {
var c = r.createElement(t, "div");
this._clipDiv = c, c.style.position = "absolute", c.style.overflow = "hidden", c.style.margin = "0px", c.style.borderWidth = "0px", c.style.padding = "0px", n.appendChild(c);
var h = r.createElement(t, "div");
this._clipScrollDiv = h, h.style.position = "absolute", h.style.height = "1px", h.style.top = "-1000px", c.appendChild(h)
}
this._setFullSelection(this._fullSelection, !0);
var p = r.createElement(t, "div");
p.className = "textviewContent", this._clientDiv = p, p.style.position = "absolute", p.style.borderWidth = "0px", p.style.margin = "0px", p.style.padding = "0px", p.style.outline = "none", p.style.zIndex = "1", p.style.WebkitUserSelect = "text", p.setAttribute("spellcheck", "false");
if (r.isIOS || r.isAndroid) p.style.WebkitTapHighlightColor = "transparent";
(this._clipDiv || n).appendChild(p);
if (r.isIOS || r.isAndroid) {
var d = r.createElement(t, "div");
this._vScrollDiv = d, d.style.position = "absolute", d.style.borderWidth = "1px", d.style.borderColor = "white", d.style.borderStyle = "solid", d.style.borderRadius = "4px", d.style.backgroundColor = "black", d.style.opacity = "0.5", d.style.margin = "0px", d.style.padding = "0px", d.style.outline = "none", d.style.zIndex = "3", d.style.width = "8px", d.style.display = "none", n.appendChild(d);
var v = r.createElement(t, "div");
this._hScrollDiv = v, v.style.position = "absolute", v.style.borderWidth = "1px", v.style.borderColor = "white", v.style.borderStyle = "solid", v.style.borderRadius = "4px", v.style.backgroundColor = "black", v.style.opacity = "0.5", v.style.margin = "0px", v.style.padding = "0px", v.style.outline = "none", v.style.zIndex = "3", v.style.height = "8px", v.style.display = "none", n.appendChild(v)
}
if (r.isFirefox && !p.setCapture) {
var m = r.createElement(t, "div");
this._overlayDiv = m, m.style.position = p.style.position, m.style.borderWidth = p.style.borderWidth, m.style.margin = p.style.margin, m.style.padding = p.style.padding, m.style.cursor = "text", m.style.zIndex = "2", (this._clipDiv || n).appendChild(m)
}
p.contentEditable = "true", p.setAttribute("role", "textbox"), p.setAttribute("aria-multiline", "true"), this._setWrapMode(this._wrapMode, !0), this._setReadOnly(this._readonly), this._setThemeClass(this._themeClass, !0), this._setTabSize(this._tabSize, !0);
if (!t.getElementById("_textviewStyle")) {
var g = "";
r.isWebkit && this._metrics.scrollWidth > 0 && (g += "\n.textviewContainer ::-webkit-scrollbar-corner {background: #eeeeee;}"), r.isFirefox && r.isMac && this._highlightRGB && this._highlightRGB !== "Highlight" && (g += "\n.textviewContainer ::-moz-selection {background: " + this._highlightRGB + ";}");
if (g) {
var y = r.createElement(t, "style");
y.id = "_textviewStyle";
var b = t.getElementsByTagName("head")[0] || t.documentElement;
y.appendChild(t.createTextNode(g)), b.insertBefore(y, b.firstChild)
}
}
this._hookEvents();
var w = this._rulers;
for (var E = 0; E < w.length; E++) this._createRuler(w[E]);
this._update()
},
_defaultOptions: function () {
return {
parent: {
value: undefined,
update: null
},
model: {
value: undefined,
update: this.setModel
},
readonly: {
value: !1,
update: this._setReadOnly
},
fullSelection: {
value: !0,
update: this._setFullSelection
},
tabMode: {
value: !0,
update: null
},
tabSize: {
value: 8,
update: this._setTabSize
},
expandTab: {
value: !1,
update: null
},
wrapMode: {
value: !1,
update: this._setWrapMode
},
themeClass: {
value: undefined,
update: this._setThemeClass
}
}
},
_destroyRuler: function (e) {
var t = e.getLocation(),
n = t === "left" ? this._leftDiv : this._rightDiv;
if (n) {
var r = n.firstChild.rows[0],
i = r.cells;
for (var s = 0; s < i.length; s++) {
var o = i[s];
if (o.firstChild._ruler === e) break
}
if (s === i.length) return;
r.cells[s]._ruler = undefined, r.deleteCell(s), i.length === 0 && (n.style.display = "none")
}
},
_destroyView: function () {
var e = this._clientDiv;
if (!e) return;
this._setGrab(null), this._unhookEvents();
var t = this._getWindow();
this._autoScrollTimerID && (t.clearTimeout(this._autoScrollTimerID), this._autoScrollTimerID = null), this._updateTimer && (t.clearTimeout(this._updateTimer), this._updateTimer = null);
var n = this._rootDiv;
n.parentNode.removeChild(n), this._selDiv1 = null, this._selDiv2 = null, this._selDiv3 = null, this._clipboardDiv = null, this._rootDiv = null, this._scrollDiv = null, this._viewDiv = null, this._clipDiv = null, this._clipScrollDiv = null, this._clientDiv = null, this._overlayDiv = null, this._leftDiv = null, this._rightDiv = null, this._vScrollDiv = null, this._hScrollDiv = null
},
_doAutoScroll: function (e, t, n) {
this._autoScrollDir = e, this._autoScrollX = t, this._autoScrollY = n, this._autoScrollTimerID || this._autoScrollTimer()
},
_endAutoScroll: function () {
if (this._autoScrollTimerID) {
var e = this._getWindow();
e.clearTimeout(this._autoScrollTimerID)
}
this._autoScrollDir = undefined, this._autoScrollTimerID = undefined
},
_fixCaret: function () {
var e = this._clientDiv;
if (e) {
var t = this._hasFocus;
this._ignoreFocus = !0, t && e.blur(), e.contentEditable = !1, e.contentEditable = !0, t && e.focus(), this._ignoreFocus = !1
}
},
_getBaseText: function (e, t) {
var n = this._model;
return n.getBaseModel && (e = n.mapOffset(e), t = n.mapOffset(t), n = n.getBaseModel()), n.getText(e, t)
},
_getBottomIndex: function (e) {
var t = this._bottomChild;
if (e && this._getClientHeight() > this._getLineHeight()) {
var n = t.getBoundingClientRect(),
r = this._clientDiv.getBoundingClientRect();
n.bottom > r.bottom && (t = this._getLinePrevious(t) || t)
}
return t.lineIndex
},
_getBoundsAtOffset: function (e) {
var t = this._model,
n = this._getLine(t.getLineAtOffset(e)),
r = n.getBoundingClientRect(e),
i = this._getLinePixel(n.lineIndex);
return r.top += i, r.bottom += i, n.destroy(), r
},
_getClientHeight: function () {
var e = this._getViewPadding();
return Math.max(0, this._viewDiv.clientHeight - e.top - e.bottom)
},
_getClientWidth: function () {
var e = this._getViewPadding();
return Math.max(0, this._viewDiv.clientWidth - e.left - e.right)
},
_getClipboardText: function (e, t) {
var n = this._model.getLineDelimiter(),
i, s, o = this._getWindow();
if (o.clipboardData) return i = [], s = o.clipboardData.getData("Text"), l(s, function (e) {
i.push(e)
}, function () {
i.push(n)
}), s = i.join(""), t && t(s), s;
if (r.isFirefox) {
this._ignoreFocus = !0;
var u = this._clipboardDiv;
u.innerHTML = "<pre contenteditable=''></pre>", u.firstChild.focus();
var a = this,
f = function () {
var e = a._getTextFromElement(u);
return u.innerHTML = "", i = [], l(e, function (e) {
i.push(e)
}, function () {
i.push(n)
}), i.join("")
}, c = !1;
this._ignorePaste = !0;
if (!r.isLinux || this._lastMouseButton !== 2) try {
var h = u.ownerDocument;
c = h.execCommand("paste", !1, null)
} catch (p) {
c = u.childNodes.length > 1 || u.firstChild && u.firstChild.childNodes.length > 0
}
return this._ignorePaste = !1, c ? (this.focus(), this._ignoreFocus = !1, s = f(), s && t && t(s), s) : e ? (o.setTimeout(function () {
a.focus(), s = f(), s && t && t(s), a._ignoreFocus = !1
}, 0), null) : (this.focus(), this._ignoreFocus = !1, "")
}
return e && e.clipboardData ? (i = [], s = e.clipboardData.getData("text/plain"), l(s, function (e) {
i.push(e)
}, function () {
i.push(n)
}), s = i.join(""), s && t && t(s), s) : ""
},
_getDOMText: function (e, t) {
var n = e.firstChild,
r = "",
i = 0;
while (n) {
var s;
if (n.ignoreChars) {
s = n.lastChild;
var o = 0,
u = [],
a = -1;
while (s) {
var f = s.data;
for (var l = f.length - 1; l >= 0; l--) {
var c = f.substring(l, l + 1);
o < n.ignoreChars && (c === " " || c === "‌" || c === "") ? o++ : u.push(c === " " ? " " : c)
}
t === s && (a = u.length), s = s.previousSibling
}
u = u.reverse().join(""), a !== -1 && (i = r.length + u.length - a), r += u
} else {
s = n.firstChild;
while (s) t === s && (i = r.length), r += s.data, s = s.nextSibling
}
n = n.nextSibling
}
return {
text: r,
offset: i
}
},
_getTextFromElement: function (e) {
var t = e.ownerDocument,
n = t.defaultView;
if (!n.getSelection) return e.innerText || e.textContent;
var r = t.createRange();
r.selectNode(e);
var i = n.getSelection(),
s = [],
o;
for (o = 0; o < i.rangeCount; o++) s.push(i.getRangeAt(o));
this._ignoreSelect = !0, i.removeAllRanges(), i.addRange(r);
var u = i.toString();
i.removeAllRanges();
for (o = 0; o < s.length; o++) i.addRange(s[o]);
return this._ignoreSelect = !1, u
},
_getViewPadding: function () {
return this._metrics.viewPadding
},
_getLine: function (e) {
var t = this._getLineNode(e);
return t && !t.lineChanged && !t.lineRemoved ? t._line : new m(this, e)
},
_getLineHeight: function (e, t) {
if (e !== undefined && this._lineHeight) {
var n = this._lineHeight[e];
if (n) return n;
if (t || t === undefined) {
var r = this._lineHeight[e] = this._calculateLineHeight(e);
return r
}
}
return this._metrics.lineHeight
},
_getLineNode: function (e) {
var t = this._clientDiv,
n = t.firstChild;
while (n) {
if (e === n.lineIndex) return n;
n = n.nextSibling
}
return undefined
},
_getLineNext: function (e) {
var t = e ? e.nextSibling : this._clientDiv.firstChild;
while (t && t.lineIndex === -1) t = t.nextSibling;
return t
},
_getLinePrevious: function (e) {
var t = e ? e.previousSibling : this._clientDiv.lastChild;
while (t && t.lineIndex === -1) t = t.previousSibling;
return t
},
_getLinePixel: function (e) {
e = Math.min(Math.max(0, e), this._model.getLineCount());
if (this._lineHeight) {
var t = this._getTopIndex(),
n = -this._topIndexY + this._getScroll().y,
r;
if (e > t)
for (r = t; r < e; r++) n += this._getLineHeight(r);
else
for (r = t - 1; r >= e; r--) n -= this._getLineHeight(r);
return n
}
var i = this._getLineHeight();
return i * e
},
_getLineIndex: function (e) {
var t, n = 0,
r = this._model.getLineCount();
if (this._lineHeight) {
n = this._getTopIndex();
var i = -this._topIndexY + this._getScroll().y;
if (e !== i)
if (e < i)
while (e < i && n > 0) e += this._getLineHeight(--n);
else {
t = this._getLineHeight(n);
while (e - t >= i && n < r - 1) e -= t, t = this._getLineHeight(++n)
}
} else t = this._getLineHeight(), n = Math.floor(e / t);
return Math.max(0, Math.min(r - 1, n))
},
_getScroll: function () {
var e = this._viewDiv;
return {
x: e.scrollLeft,
y: e.scrollTop
}
},
_getSelection: function () {
return this._selection.clone()
},
_getTopIndex: function (e) {
var t = this._topChild;
if (e && this._getClientHeight() > this._getLineHeight()) {
var n = t.getBoundingClientRect(),
r = this._getViewPadding(),
i = this._viewDiv.getBoundingClientRect();
n.top < i.top + r.top && (t = this._getLineNext(t) || t)
}
return t.lineIndex
},
_hookEvents: function () {
var e = this;
this._modelListener = {
onChanging: function (t) {
e._onModelChanging(t)
},
onChanged: function (t) {
e._onModelChanged(t)
}
}, this._model.addEventListener("preChanging", this._modelListener.onChanging), this._model.addEventListener("postChanged", this._modelListener.onChanged);
var t = this._handlers = [],
n = this._clientDiv,
i = this._viewDiv,
o = this._rootDiv,
u = this._overlayDiv || n,
a = n.ownerDocument,
f = this._getWindow(),
l = r.isIE ? a : f;
t.push({
target: f,
type: "resize",
handler: function (t) {
return e._handleResize(t ? t : f.event)
}
}), t.push({
target: n,
type: "blur",
handler: function (t) {
return e._handleBlur(t ? t : f.event)
}
}), t.push({
target: n,
type: "focus",
handler: function (t) {
return e._handleFocus(t ? t : f.event)
}
}), t.push({
target: i,
type: "focus",
handler: function (e) {
n.focus()
}
}), t.push({
target: i,
type: "scroll",
handler: function (t) {
return e._handleScroll(t ? t : f.event)
}
}), t.push({
target: n,
type: "textInput",
handler: function (t) {
return e._handleTextInput(t ? t : f.event)
}
}), t.push({
target: n,
type: "keydown",
handler: function (t) {
return e._handleKeyDown(t ? t : f.event)
}
}), t.push({
target: n,
type: "keypress",
handler: function (t) {
return e._handleKeyPress(t ? t : f.event)
}
}), t.push({
target: n,
type: "keyup",
handler: function (t) {
return e._handleKeyUp(t ? t : f.event)
}
}), t.push({
target: n,
type: "contextmenu",
handler: function (t) {
return e._handleContextMenu(t ? t : f.event)
}
}), t.push({
target: n,
type: "copy",
handler: function (t) {
return e._handleCopy(t ? t : f.event)
}
}), t.push({
target: n,
type: "cut",
handler: function (t) {
return e._handleCut(t ? t : f.event)
}
}), t.push({
target: n,
type: "paste",
handler: function (t) {
return e._handlePaste(t ? t : f.event)
}
});
if (r.isIOS || r.isAndroid) t.push({
target: a,
type: "selectionchange",
handler: function (t) {
return e._handleSelectionChange(t ? t : f.event)
}
}), t.push({
target: n,
type: "touchstart",
handler: function (t) {
return e._handleTouchStart(t ? t : f.event)
}
}), t.push({
target: n,
type: "touchmove",
handler: function (t) {
return e._handleTouchMove(t ? t : f.event)
}
}), t.push({
target: n,
type: "touchend",
handler: function (t) {
return e._handleTouchEnd(t ? t : f.event)
}
});
else {
t.push({
target: n,
type: "selectstart",
handler: function (t) {
return e._handleSelectStart(t ? t : f.event)
}
}), t.push({
target: n,
type: "mousedown",
handler: function (t) {
return e._handleMouseDown(t ? t : f.event)
}
}), t.push({
target: n,
type: "mouseover",
handler: function (t) {
return e._handleMouseOver(t ? t : f.event)
}
}), t.push({
target: n,
type: "mouseout",
handler: function (t) {
return e._handleMouseOut(t ? t : f.event)
}
}), t.push({
target: l,
type: "mouseup",
handler: function (t) {
return e._handleMouseUp(t ? t : f.event)
}
}), t.push({
target: l,
type: "mousemove",
handler: function (t) {
return e._handleMouseMove(t ? t : f.event)
}
}), t.push({
target: o,
type: "mousedown",
handler: function (t) {
return e._handleRootMouseDown(t ? t : f.event)
}
}), t.push({
target: o,
type: "mouseup",
handler: function (t) {
return e._handleRootMouseUp(t ? t : f.event)
}
}), t.push({
target: u,
type: "dragstart",
handler: function (t) {
return e._handleDragStart(t ? t : f.event)
}
}), t.push({
target: u,
type: "drag",
handler: function (t) {
return e._handleDrag(t ? t : f.event)
}
}), t.push({
target: u,
type: "dragend",
handler: function (t) {
return e._handleDragEnd(t ? t : f.event)
}
}), t.push({
target: u,
type: "dragenter",
handler: function (t) {
return e._handleDragEnter(t ? t : f.event)
}
}), t.push({
target: u,
type: "dragover",
handler: function (t) {
return e._handleDragOver(t ? t : f.event)
}
}), t.push({
target: u,
type: "dragleave",
handler: function (t) {
return e._handleDragLeave(t ? t : f.event)
}
}), t.push({
target: u,
type: "drop",
handler: function (t) {
return e._handleDrop(t ? t : f.event)
}
}), t.push({
target: this._clientDiv,
type: r.isFirefox ? "DOMMouseScroll" : "mousewheel",
handler: function (t) {
return e._handleMouseWheel(t ? t : f.event)
}
});
if (r.isFirefox && (!r.isWindows || r.isFirefox >= 15)) {
var c = f.MutationObserver || f.MozMutationObserver;
c ? (this._mutationObserver = new c(function (t) {
e._handleDataModified(t)
}), this._mutationObserver.observe(n, {
subtree: !0,
characterData: !0
})) : t.push({
target: this._clientDiv,
type: "DOMCharacterDataModified",
handler: function (t) {
return e._handleDataModified(t ? t : f.event)
}
})
}
this._overlayDiv && (t.push({
target: this._overlayDiv,
type: "mousedown",
handler: function (t) {
return e._handleMouseDown(t ? t : f.event)
}
}), t.push({
target: this._overlayDiv,
type: "mouseover",
handler: function (t) {
return e._handleMouseOver(t ? t : f.event)
}
}), t.push({
target: this._overlayDiv,
type: "mouseout",
handler: function (t) {
return e._handleMouseOut(t ? t : f.event)
}
}), t.push({
target: this._overlayDiv,
type: "contextmenu",
handler: function (t) {
return e._handleContextMenu(t ? t : f.event)
}
})), this._isW3CEvents || t.push({
target: this._clientDiv,
type: "dblclick",
handler: function (t) {
return e._handleDblclick(t ? t : f.event)
}
})
}
var h = this._leftDiv,
p = this._rightDiv;
r.isIE && t.push({
target: h,
type: "selectstart",
handler: function () {
return !1
}
}), t.push({
target: h,
type: r.isFirefox ? "DOMMouseScroll" : "mousewheel",
handler: function (t) {
return e._handleMouseWheel(t ? t : f.event)
}
}), t.push({
target: h,
type: "click",
handler: function (t) {
e._handleRulerEvent(t ? t : f.event)
}
}), t.push({
target: h,
type: "dblclick",
handler: function (t) {
e._handleRulerEvent(t ? t : f.event)
}
}), t.push({
target: h,
type: "mousemove",
handler: function (t) {
e._handleRulerEvent(t ? t : f.event)
}
}), t.push({
target: h,
type: "mouseover",
handler: function (t) {
e._handleRulerEvent(t ? t : f.event)
}
}), t.push({
target: h,
type: "mouseout",
handler: function (t) {
e._handleRulerEvent(t ? t : f.event)
}
}), r.isIE && t.push({
target: p,
type: "selectstart",
handler: function () {
return !1
}
}), t.push({
target: p,
type: r.isFirefox ? "DOMMouseScroll" : "mousewheel",
handler: function (t) {
return e._handleMouseWheel(t ? t : f.event)
}
}), t.push({
target: p,
type: "click",
handler: function (t) {
e._handleRulerEvent(t ? t : f.event)
}
}), t.push({
target: p,
type: "dblclick",
handler: function (t) {
e._handleRulerEvent(t ? t : f.event)
}
}), t.push({
target: p,
type: "mousemove",
handler: function (t) {
e._handleRulerEvent(t ? t : f.event)
}
}), t.push({
target: p,
type: "mouseover",
handler: function (t) {
e._handleRulerEvent(t ? t : f.event)
}
}), t.push({
target: p,
type: "mouseout",
handler: function (t) {
e._handleRulerEvent(t ? t : f.event)
}
});
for (var d = 0; d < t.length; d++) {
var v = t[d];
s(v.target, v.type, v.handler, v.capture)
}
},
_getWindow: function () {
return i(this._parent.ownerDocument)
},
_init: function (t) {
var n = t.parent;
typeof n == "string" && (n = (t.document || document).getElementById(n));
if (!n) throw "no parent";
t.parent = n, t.model = t.model || new e.TextModel;
var i = this._defaultOptions();
for (var s in i)
if (i.hasOwnProperty(s)) {
var o;
t[s] !== undefined ? o = t[s] : o = i[s].value, this["_" + s] = o
}
this._rulers = [], this._selection = new d(0, 0, !1), this._linksVisible = !1, this._redrawCount = 0, this._maxLineWidth = 0, this._maxLineIndex = -1, this._ignoreSelect = !0, this._ignoreFocus = !1, this._hasFocus = !1, this._columnX = -1, this._dragOffset = -1, this._isRangeRects = (!r.isIE || r.isIE >= 9) && typeof n.ownerDocument.createRange().getBoundingClientRect == "function", this._isW3CEvents = n.addEventListener, this._autoScrollX = null, this._autoScrollY = null, this._autoScrollTimerID = null, this._AUTO_SCROLL_RATE = 50, this._grabControl = null, this._moseMoveClosure = null, this._mouseUpClosure = null, this._lastMouseX = 0, this._lastMouseY = 0, this._lastMouseTime = 0, this._clickCount = 0, this._clickTime = 250, this._clickDist = 5, this._isMouseDown = !1, this._doubleClickSelection = null, this._hScroll = 0, this._vScroll = 0, this._imeOffset = -1, this._createActions(), this._createView()
},
_isOverOverlayScroll: function () {
if (!r.isMac) return {};
var e = this._viewDiv.getBoundingClientRect(),
t = this._lastMouseMoveX,
n = this._lastMouseMoveY;
return {
vertical: e.top <= n && n < e.bottom && e.right - g <= t && t < e.right,
horizontal: e.bottom - g <= n && n < e.bottom && e.left <= t && t < e.right
}
},
_modifyContent: function (e, t) {
if (this._readonly && !e._code) return;
e.type = "Verify", this.onVerify(e);
if (e.text === null || e.text === undefined) return;
var n = this._model;
try {
e._ignoreDOMSelection && (this._ignoreDOMSelection = !0), n.setText(e.text, e.start, e.end)
} finally {
e._ignoreDOMSelection && (this._ignoreDOMSelection = !1)
}
if (t) {
var r = this._getSelection();
r.setCaret(e.start + e.text.length), this._setSelection(r, !0)
}
this.onModify({
type: "Modify"
})
},
_onModelChanged: function (e) {
e.type = "ModelChanged", this.onModelChanged(e), e.type = "Changed";
var t = e.start,
n = e.addedCharCount,
r = e.removedCharCount,
i = e.addedLineCount,
s = e.removedLineCount,
o = this._getSelection();
o.end > t && (o.end > t && o.start < t + r ? o.setCaret(t + n) : (o.start += n - r, o.end += n - r), this._setSelection(o, !1, !1));
var u = this._model,
a = u.getLineAtOffset(t),
f = this._getLineNext();
while (f) {
var l = f.lineIndex;
a <= l && l <= a + s && (a === l && !f.modelChangedEvent && !f.lineRemoved ? (f.modelChangedEvent = e, f.lineChanged = !0) : (f.lineRemoved = !0, f.lineChanged = !1, f.modelChangedEvent = null)), l > a + s && (f.lineIndex = l + i - s, f._line.lineIndex = f.lineIndex), f = this._getLineNext(f)
}
this._wrapMode || a <= this._maxLineIndex && this._maxLineIndex <= a + s && (this._checkMaxLineIndex = this._maxLineIndex, this._maxLineIndex = -1, this._maxLineWidth = 0), this._update()
},
_onModelChanging: function (e) {
e.type = "ModelChanging", this.onModelChanging(e), e.type = "Changing"
},
_queueUpdate: function () {
if (this._updateTimer || this._ignoreQueueUpdate) return;
var e = this,
t = this._getWindow();
this._updateTimer = t.setTimeout(function () {
e._updateTimer = null, e._update()
}, 0)
},
_resetLineHeight: function (e, t) {
if (this._wrapMode) {
if (e !== undefined && t !== undefined)
for (var n = e; n < t; n++) this._lineHeight[n] = undefined;
else this._lineHeight = new Array(this._model.getLineCount());
this._calculateLineHeightTimer()
} else this._lineHeight = null
},
_resetLineWidth: function () {
var e = this._clientDiv;
if (e) {
var t = e.firstChild;
while (t) t.lineWidth = undefined, t = t.nextSibling
}
},
_reset: function () {
this._maxLineIndex = -1, this._maxLineWidth = 0, this._columnX = -1, this._topChild = null, this._bottomChild = null, this._topIndexY = 0, this._resetLineHeight(), this._setSelection(new d(0, 0, !1), !1, !1), this._viewDiv && (this._viewDiv.scrollLeft = 0, this._viewDiv.scrollTop = 0);
var e = this._clientDiv;
if (e) {
var t = e.firstChild;
while (t) t.lineRemoved = !0, t = t.nextSibling;
if (r.isFirefox) {
this._ignoreFocus = !1;
var n = this._hasFocus;
n && e.blur(), e.contentEditable = !1, e.contentEditable = !0, n && e.focus(), this._ignoreFocus = !1
}
}
},
_scrollView: function (e, t) {
this._ensureCaretVisible = !1;
var n = this._viewDiv;
e && (n.scrollLeft += e), t && (n.scrollTop += t)
},
_setClipboardText: function (e, t) {
var n, i = this._parent.ownerDocument,
s = this._getWindow();
if (s.clipboardData) return n = [], l(e, function (e) {
n.push(e)
}, function () {
n.push(r.platformDelimiter)
}), s.clipboardData.setData("Text", n.join(""));
if (t && t.clipboardData) {
n = [], l(e, function (e) {
n.push(e)
}, function () {
n.push(r.platformDelimiter)
});
if (t.clipboardData.setData("text/plain", n.join(""))) return !0
}
var o = r.createElement(i, "pre");
o.style.position = "fixed", o.style.left = "-1000px", l(e, function (e) {
o.appendChild(i.createTextNode(e))
}, function () {
o.appendChild(r.createElement(i, "br"))
}), o.appendChild(i.createTextNode(" ")), this._clientDiv.appendChild(o);
var u = i.createRange();
u.setStart(o.firstChild, 0), u.setEndBefore(o.lastChild);
var a = s.getSelection();
a.rangeCount > 0 && a.removeAllRanges(), a.addRange(u);
var f = this,
c = function () {
o && o.parentNode === f._clientDiv && f._clientDiv.removeChild(o), f._updateDOMSelection()
}, h = !1;
this._ignoreCopy = !0;
try {
h = i.execCommand("copy", !1, null)
} catch (p) {}
return this._ignoreCopy = !1, !h && t ? (s.setTimeout(c, 0), !1) : (c(), !0)
},
_setDOMSelection: function (e, t, n, i) {
var s, o, u, a, f = 0,
l = e.firstChild,
c, h, p = this._model,
d = p.getLine(e.lineIndex).length;
while (l) {
c = l.firstChild, h = c.length, l.ignoreChars && (h -= l.ignoreChars);
if (f + h > t || f + h >= d) {
s = c, o = t - f, l.ignoreChars && h > 0 && o === h && (o += l.ignoreChars);
break
}
f += h, l = l.nextSibling
}
f = 0, l = n.firstChild;
var v = this._model.getLine(n.lineIndex).length;
while (l) {
c = l.firstChild, h = c.length, l.ignoreChars && (h -= l.ignoreChars);
if (h + f > i || f + h >= v) {
u = c, a = i - f, l.ignoreChars && h > 0 && a === h && (a += l.ignoreChars);
break
}
f += h, l = l.nextSibling
}
this._setDOMFullSelection(e, t, d, n, i, v);
if (!this._hasFocus) return;
var m, g = this._getWindow(),
y = this._parent.ownerDocument;
if (g.getSelection) {
var b = g.getSelection();
if (b.anchorNode === s && b.anchorOffset === o && b.focusNode === u && b.focusOffset === a || b.anchorNode === u && b.anchorOffset === a && b.focusNode === s && b.focusOffset === o) return;
m = y.createRange(), m.setStart(s, o), m.setEnd(u, a), this._ignoreSelect = !1, b.rangeCount > 0 && b.removeAllRanges(), b.addRange(m), this._ignoreSelect = !0
} else if (y.selection) {
var w = y.body,
E = r.createElement(y, "div");
w.appendChild(E), w.removeChild(E), m = w.createTextRange(), m.moveToElementText(s.parentNode), m.moveStart("character", o);
var S = w.createTextRange();
S.moveToElementText(u.parentNode), S.moveStart("character", a), m.setEndPoint("EndToStart", S), this._ignoreSelect = !1, m.select(), this._ignoreSelect = !0
}
},
_setDOMFullSelection: function (e, t, n, r, i, s) {
if (!this._selDiv1) return;
var o = this._selDiv1;
o.style.width = "0px", o.style.height = "0px", o = this._selDiv2, o.style.width = "0px", o.style.height = "0px", o = this._selDiv3, o.style.width = "0px", o.style.height = "0px";
if (e === r && t === i) return;
var u = this._model,
a = this._getViewPadding(),
f = this._clientDiv.getBoundingClientRect(),
l = this._viewDiv.getBoundingClientRect(),
c = l.left + a.left,
h = f.right,
p = l.top + a.top,
d = f.bottom,
v = 0,
g = 0;
if (this._clipDiv) {
var y = this._clipDiv.getBoundingClientRect();
v = y.left - this._clipDiv.scrollLeft, g = y.top
} else {
var b = this._rootDiv.getBoundingClientRect();
v = b.left, g = b.top
}
this._ignoreDOMSelection = !0;
var w = new m(this, e.lineIndex, e),
E = w.getBoundingClientRect(u.getLineStart(e.lineIndex) + t, !1),
S = E.left,
x = new m(this, r.lineIndex, r),
T = x.getBoundingClientRect(u.getLineStart(r.lineIndex) + i, !1),
N = T.left;
this._ignoreDOMSelection = !1;
var C = this._selDiv1,
k = Math.min(h, Math.max(c, S)),
L = Math.min(d, Math.max(p, E.top)),
A = h,
O = Math.min(d, Math.max(p, E.bottom));
C.style.left = k - v + "px", C.style.top = L - g + "px", C.style.width = Math.max(0, A - k) + "px", C.style.height = Math.max(0, O - L) + "px";
if (E.top === T.top) A = Math.min(N, h), C.style.width = Math.max(0, A - k) + "px";
else {
var M = c,
_ = Math.min(d, Math.max(p, T.top)),
D = Math.min(h, Math.max(c, N)),
P = Math.min(d, Math.max(p, T.bottom)),
H = this._selDiv3;
H.style.left = M - v + "px", H.style.top = _ - g + "px", H.style.width = Math.max(0, D - M) + "px", H.style.height = Math.max(0, P - _) + "px";
if (_ - O > 0) {
var B = this._selDiv2;
B.style.left = c - v + "px", B.style.top = O - g + "px", B.style.width = Math.max(0, h - c) + "px", B.style.height = Math.max(0, _ - O) + "px"
}
}
},
_setGrab: function (e) {
if (e === this._grabControl) return;
e ? (e.setCapture && e.setCapture(), this._grabControl = e) : (this._grabControl.releaseCapture && this._grabControl.releaseCapture(), this._grabControl = null)
},
_setLinksVisible: function (e) {
if (this._linksVisible === e) return;
this._linksVisible = e, r.isIE && e && (this._hadFocus = this._hasFocus);
var t = this._clientDiv;
t.contentEditable = !e, this._hadFocus && !e && t.focus(), this._overlayDiv && (this._overlayDiv.style.zIndex = e ? "-1" : "1");
var n = this._getLineNext();
while (n) {
if (n.hasLink) {
var i = n.firstChild;
while (i) {
var s = i.nextSibling,
o = i.viewStyle;
o && o.tagName === "A" && n.replaceChild(n._line._createSpan(n, i.firstChild.data, o), i), i = s
}
}
n = this._getLineNext(n)
}
},
_setSelection: function (e, t, n, r) {
if (e) {
this._columnX = -1, n === undefined && (n = !0);
var i = this._selection;
this._selection = e, t && this._showCaret(!1, r), n && this._updateDOMSelection();
if (!i.equals(e)) {
var s = {
type: "Selection",
oldValue: {
start: i.start,
end: i.end
},
newValue: {
start: e.start,
end: e.end
}
};
this.onSelection(s)
}
}
},
_setSelectionTo: function (e, t, n, r) {
var i = this._model,
s, o = this._getSelection(),
u = this.convert({
x: e,
y: t
}, "page", "document"),
a = this._getLineIndex(u.y),
f;
if (this._clickCount === 1) {
f = this._getLine(a), s = f.getOffset(u.x, u.y - this._getLinePixel(a)), f.destroy();
if (r && !n && o.start <= s && s < o.end) return this._dragOffset = s, !1;
o.extend(s), n || o.collapse()
} else {
var l = (this._clickCount & 1) === 0,
c, h;
if (l) f = this._getLine(a), s = f.getOffset(u.x, u.y - this._getLinePixel(a)), this._doubleClickSelection ? s >= this._doubleClickSelection.start ? (c = this._doubleClickSelection.start, h = f.getNextOffset(s, "wordend", 1)) : (c = f.getNextOffset(s, "word", -1), h = this._doubleClickSelection.end) : (c = f.getNextOffset(s, "word", -1), h = f.getNextOffset(c, "wordend", 1)), f.destroy();
else if (this._doubleClickSelection) {
var p = i.getLineAtOffset(this._doubleClickSelection.start);
a >= p ? (c = i.getLineStart(p), h = i.getLineEnd(a)) : (c = i.getLineStart(a), h = i.getLineEnd(p))
} else c = i.getLineStart(a), h = i.getLineEnd(a);
o.setCaret(c), o.extend(h)
}
return this._setSelection(o, !0, !0), !0
},
_setFullSelection: function (e, t) {
this._fullSelection = e, r.isWebkit && (this._fullSelection = !0);
var n = this._clipDiv || this._rootDiv;
if (!n) return;
if (!this._fullSelection) {
this._selDiv1 && (n.removeChild(this._selDiv1), this._selDiv1 = null), this._selDiv2 && (n.removeChild(this._selDiv2), this._selDiv2 = null), this._selDiv3 && (n.removeChild(this._selDiv3), this._selDiv3 = null);
return
}
if (!this._selDiv1 && this._fullSelection && !r.isIOS) {
var i = n.ownerDocument;
this._highlightRGB = r.isWebkit ? "transparent" : "Highlight";
var s = r.createElement(i, "div");
this._selDiv1 = s, s.style.position = "absolute", s.style.borderWidth = "0px", s.style.margin = "0px", s.style.padding = "0px", s.style.outline = "none", s.style.background = this._highlightRGB, s.style.width = "0px", s.style.height = "0px", s.style.zIndex = "0", n.appendChild(s);
var o = r.createElement(i, "div");
this._selDiv2 = o, o.style.position = "absolute", o.style.borderWidth = "0px", o.style.margin = "0px", o.style.padding = "0px", o.style.outline = "none", o.style.background = this._highlightRGB, o.style.width = "0px", o.style.height = "0px", o.style.zIndex = "0", n.appendChild(o);
var u = r.createElement(i, "div");
this._selDiv3 = u, u.style.position = "absolute", u.style.borderWidth = "0px", u.style.margin = "0px", u.style.padding = "0px", u.style.outline = "none", u.style.background = this._highlightRGB, u.style.width = "0px", u.style.height = "0px", u.style.zIndex = "0", n.appendChild(u);
if (r.isFirefox && r.isMac) {
var a = this._getWindow(),
f = a.getComputedStyle(u, null),
l = f.getPropertyValue("background-color");
switch (l) {
case "rgb(119, 141, 168)":
l = "rgb(199, 208, 218)";
break;
case "rgb(127, 127, 127)":
l = "rgb(198, 198, 198)";
break;
case "rgb(255, 193, 31)":
l = "rgb(250, 236, 115)";
break;
case "rgb(243, 70, 72)":
l = "rgb(255, 176, 139)";
break;
case "rgb(255, 138, 34)":
l = "rgb(255, 209, 129)";
break;
case "rgb(102, 197, 71)":
l = "rgb(194, 249, 144)";
break;
case "rgb(140, 78, 184)":
l = "rgb(232, 184, 255)";
break;
default:
l = "rgb(180, 213, 255)"
}
this._highlightRGB = l, s.style.background = l, o.style.background = l, u.style.background = l
}
t || this._updateDOMSelection()
}
},
_setReadOnly: function (e) {
this._readonly = e, this._clientDiv.setAttribute("aria-readonly", e ? "true" : "false")
},
_setTabSize: function (e, t) {
this._tabSize = e, this._customTabSize = undefined;
var n = this._clientDiv;
r.isOpera ? n && (n.style.OTabSize = this._tabSize + "") : r.isWebkit >= 537.1 ? n && (n.style.tabSize = this._tabSize + "") : r.isFirefox >= 4 ? n && (n.style.MozTabSize = this._tabSize + "") : this._tabSize !== 8 && (this._customTabSize = this._tabSize), t || (this.redrawLines(), this._resetLineWidth())
},
_setThemeClass: function (e, t) {
this._themeClass = e;
var n = "textviewContainer";
this._themeClass && (n += " " + this._themeClass), this._rootDiv.className = n, this._updateStyle(t)
},
_setWrapMode: function (e, t) {
this._wrapMode = e;
var n = this._clientDiv,
r = this._viewDiv;
e ? (n.style.whiteSpace = "pre-wrap", n.style.wordWrap = "break-word", r.style.overflowX = "hidden", r.style.overflowY = "scroll") : (n.style.whiteSpace = "pre", n.style.wordWrap = "normal", r.style.overflowX = "auto", r.style.overflowY = "auto"), t || (this.redraw(), this._resetLineWidth()), this._resetLineHeight()
},
_showCaret: function (e, t) {
if (!this._clientDiv) return;
var n = this._model,
r = this._getSelection(),
i = this._getScroll(),
s = r.getCaret(),
o = r.start,
u = r.end,
a = n.getLineAtOffset(u),
f = Math.max(Math.max(o, n.getLineStart(a)), u - 1),
l = this._getClientWidth(),
c = this._getClientHeight(),
h = l / 4,
p = this._getBoundsAtOffset(s === o ? o : f),
d = p.left,
v = p.right,
m = p.top,
g = p.bottom;
e && !r.isEmpty() && (p = this._getBoundsAtOffset(s === u ? o : f), p.top === m ? s === o ? v = d + Math.min(p.right - d, l) : d = v - Math.min(v - p.left, l) : s === o ? g = m + Math.min(p.bottom - m, c) : m = g - Math.min(g - p.top, c));
var y = 0;
d < i.x && (y = Math.min(d - i.x, -h)), v > i.x + l && (y = Math.max(v - i.x - l, h));
var b = 0;
return m < i.y ? b = m - i.y : g > i.y + c && (b = g - i.y - c), t && (t > 0 ? b > 0 && (b = Math.max(b, t)) : b < 0 && (b = Math.min(b, t))), y !== 0 || b !== 0 ? (this._scrollView(y, b), c !== this._getClientHeight() || l !== this._getClientWidth() ? this._showCaret() : this._ensureCaretVisible = !0, !0) : !1
},
_startIME: function () {
if (this._imeOffset !== -1) return;
var e = this._getSelection();
e.isEmpty() || this._modifyContent({
text: "",
start: e.start,
end: e.end
}, !0), this._imeOffset = e.start
},
_unhookEvents: function () {
this._model.removeEventListener("preChanging", this._modelListener.onChanging), this._model.removeEventListener("postChanged", this._modelListener.onChanged), this._modelListener = null;
for (var e = 0; e < this._handlers.length; e++) {
var t = this._handlers[e];
o(t.target, t.type, t.handler)
}
this._handlers = null, this._mutationObserver && (this._mutationObserver.disconnect(), this._mutationObserver = null)
},
_updateDOMSelection: function () {
if (this._ignoreDOMSelection) return;
if (!this._clientDiv) return;
var e = this._getSelection(),
t = this._model,
n = t.getLineAtOffset(e.start),
r = t.getLineAtOffset(e.end),
i = this._getLineNext();
if (!i) return;
var s = this._getLinePrevious(),
o, u, a, f;
n < i.lineIndex ? (o = i, a = 0) : n > s.lineIndex ? (o = s, a = 0) : (o = this._getLineNode(n), a = e.start - t.getLineStart(n)), r < i.lineIndex ? (u = i, f = 0) : r > s.lineIndex ? (u = s, f = 0) : (u = this._getLineNode(r), f = e.end - t.getLineStart(r)), this._setDOMSelection(o, a, u, f)
},
_update: function (e) {
if (this._redrawCount > 0) return;
if (this._updateTimer) {
var t = this._getWindow();
t.clearTimeout(this._updateTimer), this._updateTimer = null, e = !1
}
var n = this._clientDiv;
if (!n) return;
this._metrics.invalid && (this._ignoreQueueUpdate = !0, this._updateStyle(), this._ignoreQueueUpdate = !1);
var i = this._model,
s = this._getScroll(),
o = this._getViewPadding(),
u = i.getLineCount(),
a = this._getLineHeight(),
f = this._getClientWidth();
this._wrapMode && (n.style.width = f + "px");
var l, c, h, p, d, v, y, b, w, E = 0,
S = 0,
x;
if (this._lineHeight) {
while (S < u) {
x = this._getLineHeight(S);
if (E + x > s.y) break;
E += x, S++
}
l = S, c = Math.max(0, l - 1), p = h = s.y - E, l > 0 && (h += this._getLineHeight(l - 1))
} else {
var T = Math.max(0, s.y) / a;
l = Math.floor(T), c = Math.max(0, l - 1), h = Math.round((T - c) * a), p = Math.round((T - l) * a), w = u * a
}
this._topIndexY = p;
var N = this._parent,
C = N.clientWidth,
k = N.clientHeight;
y = this._getClientHeight();
if (e) {
d = 0, this._leftDiv && (v = this._leftDiv.getBoundingClientRect(), d = v.right - v.left), b = f, this._wrapMode || (b = Math.max(this._maxLineWidth, b));
while (S < u) x = this._getLineHeight(S, !1), E += x, S++;
w = E
} else {
var L = this._viewDiv,
A = Math.floor((y + p) / a),
O = Math.min(l + A, u - 1),
M = Math.min(O + 1, u - 1),
_, D, P = n.firstChild;
while (P) {
_ = P.lineIndex;
var H = P.nextSibling;
if (!(c <= _ && _ <= M) || P.lineRemoved || P.lineIndex === -1) this._mouseWheelLine === P ? (P.style.display = "none", P.lineIndex = -1) : n.removeChild(P);
P = H
}
P = this._getLineNext();
var B = L.ownerDocument,
j = B.createDocumentFragment();
for (_ = c; _ <= M; _++)!P || P.lineIndex > _ ? (new m(this, _)).create(j, null) : (j.firstChild && (n.insertBefore(j, P), j = B.createDocumentFragment()), P && P.lineChanged && (P = (new m(this, _)).create(j, P), P.lineChanged = !1), P = this._getLineNext(P));
j.firstChild && n.insertBefore(j, P), r.isWebkit && !this._wrapMode && (n.style.width = "0x7fffffffpx");
var F;
P = this._getLineNext();
var I = y + h,
q = !1;
while (P) D = P.lineWidth, D === undefined && (F = P._line.getBoundingClientRect(), D = P.lineWidth = Math.ceil(F.right - F.left), this._lineHeight && (this._lineHeight[P.lineIndex] = Math.ceil(F.bottom - F.top))), this._lineHeight && !q && (I -= this._lineHeight[P.lineIndex], I < 0 && (O = P.lineIndex, q = !0)), this._wrapMode || (D >= this._maxLineWidth && (this._maxLineWidth = D, this._maxLineIndex = P.lineIndex), this._checkMaxLineIndex === P.lineIndex && (this._checkMaxLineIndex = -1)), P.lineIndex === l && (this._topChild = P), P.lineIndex === O && (this._bottomChild = P), P = this._getLineNext(P);
if (this._checkMaxLineIndex !== -1) {
_ = this._checkMaxLineIndex, this._checkMaxLineIndex = -1;
if (0 <= _ && _ < u) {
var R = new m(this, _);
F = R.getBoundingClientRect(), D = F.right - F.left, D >= this._maxLineWidth && (this._maxLineWidth = D, this._maxLineIndex = _), R.destroy()
}
}
while (S < u) x = this._getLineHeight(S, S <= O), E += x, S++;
w = E, this._updateRuler(this._leftDiv, l, O), this._updateRuler(this._rightDiv, l, O), d = 0, this._leftDiv && (v = this._leftDiv.getBoundingClientRect(), d = v.right - v.left);
var U = 0;
if (this._rightDiv) {
var z = this._rightDiv.getBoundingClientRect();
U = z.right - z.left
}
L.style.left = d + "px", L.style.right = U + "px";
var W = this._scrollDiv;
W.style.height = w + "px", f = this._getClientWidth();
var X = f;
this._wrapMode || (X = Math.max(this._maxLineWidth, X)), b = X, (!r.isIE || r.isIE >= 9) && this._maxLineWidth > f && (X += o.right + o.left), W.style.width = X + "px", this._clipScrollDiv && (this._clipScrollDiv.style.width = X + "px"), s = this._getScroll();
var V = y + o.top + o.bottom;
this._updateRulerSize(this._leftDiv, V), this._updateRulerSize(this._rightDiv, V)
} if (this._vScrollDiv) {
var $ = y - 8,
J = Math.max(15, Math.ceil(Math.min(1, $ / (w + o.top + o.bottom)) * $));
this._vScrollDiv.style.left = d + f - 8 + "px", this._vScrollDiv.style.top = Math.floor(Math.max(0, s.y * $ / w)) + "px", this._vScrollDiv.style.height = J + "px"
}
if (!this._wrapMode && this._hScrollDiv) {
var K = f - 8,
Q = Math.max(15, Math.ceil(Math.min(1, K / (this._maxLineWidth + o.left + o.right)) * K));
this._hScrollDiv.style.left = d + Math.floor(Math.max(0, Math.floor(s.x * K / this._maxLineWidth))) + "px", this._hScrollDiv.style.top = y - 9 + "px", this._hScrollDiv.style.width = Q + "px"
}
var G = s.x,
Y = this._clipDiv,
Z = this._overlayDiv,
et, tt;
if (Y) {
Y.scrollLeft = G, et = d + o.left, tt = o.top;
var nt = f,
rt = y,
it = 0,
st = -h;
s.x === 0 && (et -= o.left, nt += o.left, it = o.left), s.x + f === b && (nt += o.right), s.y === 0 && (tt -= o.top, rt += o.top, st += o.top), s.y + y === w && (rt += o.bottom), Y.style.left = et + "px", Y.style.top = tt + "px";
var ot = this._isOverOverlayScroll();
Y.style.right = C - nt - et + (this._overlayScrollTimer && ot.vertical ? g : 0) + "px", Y.style.bottom = k - rt - tt + (this._overlayScrollTimer && ot.horizontal ? g : 0) + "px", n.style.left = it + "px", n.style.top = st + "px", n.style.width = b + "px", n.style.height = y + h + "px", Z && (Z.style.left = n.style.left, Z.style.top = n.style.top, Z.style.width = n.style.width, Z.style.height = n.style.height)
} else {
et = G, tt = h;
var ut = G + f,
at = h + y;
et === 0 && (et -= o.left), tt === 0 && (tt -= o.top), ut === b && (ut += o.right), s.y + y === w && (at += o.bottom), n.style.clip = "rect(" + tt + "px," + ut + "px," + at + "px," + et + "px)", n.style.left = -G + d + o.left + "px", n.style.width = (r.isWebkit ? b : f + G) + "px", e || (n.style.top = -h + o.top + "px", n.style.height = y + h + "px"), Z && (Z.style.clip = n.style.clip, Z.style.left = n.style.left, Z.style.width = n.style.width, e || (Z.style.top = n.style.top, Z.style.height = n.style.height))
}
this._updateDOMSelection();
var ft = this._ensureCaretVisible;
this._ensureCaretVisible = !1, y !== this._getClientHeight() && (this._update(), ft && this._showCaret())
},
_updateRulerSize: function (e, t) {
if (!e) return;
var n = this._topIndexY,
r = this._getLineHeight(),
i = e.firstChild.rows[0].cells;
for (var s = 0; s < i.length; s++) {
var o = i[s].firstChild,
u = r;
o._ruler.getOverview() === "page" && (u += n), o.style.top = -u + "px", o.style.height = t + u + "px", o = o.nextSibling
}
e.style.height = t + "px"
},
_updateRuler: function (e, t, n) {
if (!e) return;
var i = e.firstChild.rows[0].cells,
s = this._parent.ownerDocument,
o = this._getLineHeight(),
a = this._getViewPadding();
for (var f = 0; f < i.length; f++) {
var l = i[f].firstChild,
c = l._ruler;
l.rulerChanged && u(c.getRulerStyle(), l);
var h, p = l.firstChild;
p ? (h = p, p = p.nextSibling) : (h = r.createElement(s, "div"), h.style.visibility = "hidden", l.appendChild(h));
var d, v;
l.rulerChanged && h && (d = -1, v = c.getWidestAnnotation(), v && (u(v.style, h), v.html && (h.innerHTML = v.html)), h.lineIndex = d, h.style.height = o + a.top + "px");
var m = c.getOverview(),
g, y, b;
if (m === "page") {
b = c.getAnnotations(t, n + 1);
while (p) {
d = p.lineIndex;
var w = p.nextSibling;
(!(t <= d && d <= n) || p.lineChanged) && l.removeChild(p), p = w
}
p = l.firstChild.nextSibling, y = s.createDocumentFragment();
for (d = t; d <= n; d++)!p || p.lineIndex > d ? (g = r.createElement(s, "div"), v = b[d], v && (u(v.style, g), v.html && (g.innerHTML = v.html), g.annotation = v), g.lineIndex = d, g.style.height = this._getLineHeight(d) + "px", y.appendChild(g)) : (y.firstChild && (l.insertBefore(y, p), y = s.createDocumentFragment()), p && (p = p.nextSibling));
y.firstChild && l.insertBefore(y, p)
} else {
var E = this._getClientHeight(),
S = this._model.getLineCount(),
x = o * S,
T = E + a.top + a.bottom - 2 * this._metrics.scrollWidth,
N;
x < T ? N = o : N = T / S;
if (l.rulerChanged) {
var C = l.childNodes.length;
while (C > 1) l.removeChild(l.lastChild), C--;
b = c.getAnnotations(0, S), y = s.createDocumentFragment();
for (var k in b) {
d = k >>> 0;
if (d < 0) continue;
g = r.createElement(s, "div"), v = b[k], u(v.style, g), g.style.position = "absolute", g.style.top = this._metrics.scrollWidth + o + Math.floor(d * N) + "px", v.html && (g.innerHTML = v.html), g.annotation = v, g.lineIndex = d, y.appendChild(g)
}
l.appendChild(y)
} else if (l._oldTrackHeight !== T) {
g = l.firstChild ? l.firstChild.nextSibling : null;
while (g) g.style.top = this._metrics.scrollWidth + o + Math.floor(g.lineIndex * N) + "px", g = g.nextSibling
}
l._oldTrackHeight = T
}
l.rulerChanged = !1, l = l.nextSibling
}
},
_updateStyle: function (e) {
!e && r.isIE && (this._rootDiv.style.lineHeight = "normal");
var t = this._metrics = this._calculateMetrics();
r.isIE ? this._rootDiv.style.lineHeight = t.lineHeight - (t.lineTrim.top + t.lineTrim.bottom) + "px" : this._rootDiv.style.lineHeight = "normal", e || (this.redraw(), this._resetLineWidth())
}
}, n.EventTarget.addMixin(y.prototype), {
TextView: y
}
}),
function () {
function i(e, t, n, r, i, s) {
t[e] && (n.push(e), (t[e] === !0 || t[e] === 1) && r.push(i + e + "/" + s))
}
function s(e, n, r, i, s) {
var o = i + n + "/" + s;
t._fileExists(e.toUrl(o)) && r.push(o)
}
function o(e, t, n) {
for (var i in t)!(i in r) && (!(i in e) || n) && (e[i] = t[i])
}
var e = /(^.*(^|\/)nls(\/|$))([^\/]*)\/?([^\/]*)/,
r = {};
n("i18n", {
version: "1.0.0",
load: function (t, n, r, u) {
u = u || {};
var a, f = e.exec(t),
l = f[1],
c = f[4],
h = f[5],
p = c.split("-"),
d = [],
v = {}, m, g, y = "";
f[5] ? (l = f[1], a = l + h) : (a = t, h = f[4], c = u.locale || (u.locale = typeof navigator == "undefined" ? "root" : (navigator.language || navigator.userLanguage || "root").toLowerCase()), p = c.split("-"));
if (u.isBuild) {
d.push(a), s(n, "root", d, l, h);
for (m = 0; g = p[m]; m++) y += (y ? "-" : "") + g, s(n, y, d, l, h);
n(d, function () {
r()
})
} else n([a], function (e) {
var t = [];
i("root", e, t, d, l, h);
for (m = 0; g = p[m]; m++) y += (y ? "-" : "") + g, i(y, e, t, d, l, h);
n(d, function () {
var i, s;
for (i = t.length - 1; i > -1 && (g = t[i]); i--) {
s = e[g];
if (s === !0 || s === 1) s = n(l + g + "/" + h);
o(v, s)
}
r(v)
})
})
}
})
}(), n("orion/editor/i18n", {
load: function (e, t, n, r) {
t.specified && t.specified("orion/bootstrap") ? t(["orion/i18n!" + e], function (e) {
n(e)
}) : n({})
}
}), n("orion/editor/nls/root/messages", {
multipleAnnotations: "Multiple annotations:",
line: "Line: ${0}",
breakpoint: "Breakpoint",
bookmark: "Bookmark",
task: "Task",
error: "Error",
warning: "Warning",
matchingSearch: "Matching Search",
currentSearch: "Current Search",
currentLine: "Current Line",
matchingBracket: "Matching Bracket",
currentBracket: "Current Bracket",
Comment: "Comment",
"Flat outline": "Flat outline",
incrementalFind: "Incremental find: ${0}",
incrementalFindNotFound: "Incremental find: ${0} (not found)",
find: "Find...",
undo: "Undo",
redo: "Redo",
cancelMode: "Cancel Current Mode",
findNext: "Find Next Occurrence",
findPrevious: "Find Previous Occurrence",
incrementalFindKey: "Incremental Find",
indentLines: "Indent Lines",
unindentLines: "Unindent Lines",
moveLinesUp: "Move Lines Up",
moveLinesDown: "Move Lines Down",
copyLinesUp: "Copy Lines Up",
copyLinesDown: "Copy Lines Down",
deleteLines: "Delete Lines",
gotoLine: "Goto Line...",
gotoLinePrompty: "Goto Line:",
nextAnnotation: "Next Annotation",
prevAnnotation: "Previous Annotation",
expand: "Expand",
collapse: "Collapse",
expandAll: "Expand All",
collapseAll: "Collapse All",
lastEdit: "Last Edit Location",
toggleLineComment: "Toggle Line Comment",
addBlockComment: "Add Block Comment",
removeBlockComment: "Remove Block Comment",
linkedModeEntered: "Linked Mode entered",
linkedModeExited: "Linked Mode exited",
syntaxError: "Syntax Error",
contentAssist: "Content Assist",
lineColumn: "Line ${0} : Col ${1}"
}), n("orion/editor/nls/messages", ["orion/editor/i18n!orion/editor/nls/messages", "orion/editor/nls/root/messages"], function (e, t) {
var n = {
root: t
};
for (var r in e) e.hasOwnProperty(r) && typeof n[r] == "undefined" && (n[r] = e[r]);
return n
}), n("orion/editor/annotations", ["i18n!orion/editor/nls/messages", "orion/editor/eventTarget"], function (e, t) {
function n(e, t, n) {
this.start = e, this.end = t, this._projectionModel = n, this.html = this._expandedHTML, this.style = this._expandedStyle, this.expanded = !0
}
function r() {}
function s(t, n) {
var i = t.lastIndexOf("."),
s = t.substring(i + 1),
o = {
title: e[s],
style: {
styleClass: "annotation " + s
},
html: "<div class='annotationHTML " + s + "'></div>",
overviewStyle: {
styleClass: "annotationOverview " + s
}
};
n ? o.lineStyle = {
styleClass: "annotationLine " + s
} : o.rangeStyle = {
styleClass: "annotationRange " + s
}, r.registerType(t, o)
}
function o() {}
function u(e) {
this._annotations = [];
var t = this;
this._listener = {
onChanged: function (e) {
t._onChanged(e)
}
}, this.setTextModel(e)
}
function a(e, t) {
this._view = e, this._annotationModel = t;
var n = this;
this._listener = {
onDestroy: function (e) {
n._onDestroy(e)
},
onLineStyle: function (e) {
n._onLineStyle(e)
},
onChanged: function (e) {
n._onAnnotationModelChanged(e)
}
}, e.addEventListener("Destroy", this._listener.onDestroy), e.addEventListener("postLineStyle", this._listener.onLineStyle), t.addEventListener("Changed", this._listener.onChanged)
}
n.prototype = {
_expandedHTML: "<div class='annotationHTML expanded'></div>",
_expandedStyle: {
styleClass: "annotation expanded"
},
_collapsedHTML: "<div class='annotationHTML collapsed'></div>",
_collapsedStyle: {
styleClass: "annotation collapsed"
},
collapse: function () {
if (!this.expanded) return;
this.expanded = !1, this.html = this._collapsedHTML, this.style = this._collapsedStyle;
var e = this._projectionModel,
t = e.getBaseModel();
this._projection = {
start: t.getLineStart(t.getLineAtOffset(this.start) + 1),
end: t.getLineEnd(t.getLineAtOffset(this.end), !0)
}, e.addProjection(this._projection)
},
expand: function () {
if (this.expanded) return;
this.expanded = !0, this.html = this._expandedHTML, this.style = this._expandedStyle, this._projectionModel.removeProjection(this._projection)
}
}, r.ANNOTATION_ERROR = "orion.annotation.error", r.ANNOTATION_WARNING = "orion.annotation.warning", r.ANNOTATION_TASK = "orion.annotation.task", r.ANNOTATION_BREAKPOINT = "orion.annotation.breakpoint", r.ANNOTATION_BOOKMARK = "orion.annotation.bookmark", r.ANNOTATION_FOLDING = "orion.annotation.folding", r.ANNOTATION_CURRENT_BRACKET = "orion.annotation.currentBracket", r.ANNOTATION_MATCHING_BRACKET = "orion.annotation.matchingBracket", r.ANNOTATION_CURRENT_LINE = "orion.annotation.currentLine", r.ANNOTATION_CURRENT_SEARCH = "orion.annotation.currentSearch", r.ANNOTATION_MATCHING_SEARCH = "orion.annotation.matchingSearch", r.ANNOTATION_READ_OCCURRENCE = "orion.annotation.readOccurrence", r.ANNOTATION_WRITE_OCCURRENCE = "orion.annotation.writeOccurrence";
var i = {};
return r.registerType = function (e, t) {
var n = t;
return typeof n != "function" && (n = function (e, t, n) {
this.start = e, this.end = t, n && (this.title = n)
}, n.prototype = t), n.prototype.type = e, i[e] = n, e
}, r.createAnnotation = function (e, t, n, r) {
return new(this.getType(e))(t, n, r)
}, r.getType = function (e) {
return i[e]
}, s(r.ANNOTATION_ERROR), s(r.ANNOTATION_WARNING), s(r.ANNOTATION_TASK), s(r.ANNOTATION_BREAKPOINT), s(r.ANNOTATION_BOOKMARK), s(r.ANNOTATION_CURRENT_BRACKET), s(r.ANNOTATION_MATCHING_BRACKET), s(r.ANNOTATION_CURRENT_SEARCH), s(r.ANNOTATION_MATCHING_SEARCH), s(r.ANNOTATION_READ_OCCURRENCE), s(r.ANNOTATION_WRITE_OCCURRENCE), s(r.ANNOTATION_CURRENT_LINE, !0), r.registerType(r.ANNOTATION_FOLDING, n), o.addMixin = function (e) {
var t = o.prototype;
for (var n in t) t.hasOwnProperty(n) && (e[n] = t[n])
}, o.prototype = {
addAnnotationType: function (e) {
this._annotationTypes || (this._annotationTypes = []), this._annotationTypes.push(e)
},
getAnnotationTypePriority: function (e) {
if (this._annotationTypes)
for (var t = 0; t < this._annotationTypes.length; t++)
if (this._annotationTypes[t] === e) return t + 1;
return 0
},
getAnnotationsByType: function (e, t, n) {
var r = e.getAnnotations(t, n),
i, s = [];
while (r.hasNext()) {
i = r.next();
var o = this.getAnnotationTypePriority(i.type);
if (o === 0) continue;
s.push(i)
}
var u = this;
return s.sort(function (e, t) {
return u.getAnnotationTypePriority(e.type) - u.getAnnotationTypePriority(t.type)
}), s
},
isAnnotationTypeVisible: function (e) {
return this.getAnnotationTypePriority(e) !== 0
},
removeAnnotationType: function (e) {
if (!this._annotationTypes) return;
for (var t = 0; t < this._annotationTypes.length; t++)
if (this._annotationTypes[t] === e) {
this._annotationTypes.splice(t, 1);
break
}
}
}, u.prototype = {
addAnnotation: function (e) {
if (!e) return;
var t = this._annotations,
n = this._binarySearch(t, e.start);
t.splice(n, 0, e);
var r = {
type: "Changed",
added: [e],
removed: [],
changed: []
};
this.onChanged(r)
},
getTextModel: function () {
return this._model
},
getAnnotations: function (e, t) {
var n = this._annotations,
r, i = 0,
s = function () {
while (i < n.length) {
var r = n[i++];
if (e === r.start || (e > r.start ? e < r.end : r.start < t)) return r;
if (r.start >= t) break
}
return null
};
return r = s(), {
next: function () {
var e = r;
return e && (r = s()), e
},
hasNext: function () {
return r !== null
}
}
},
modifyAnnotation: function (e) {
if (!e) return;
var t = this._getAnnotationIndex(e);
if (t < 0) return;
var n = {
type: "Changed",
added: [],
removed: [],
changed: [e]
};
this.onChanged(n)
},
onChanged: function (e) {
return this.dispatchEvent(e)
},
removeAnnotations: function (e) {
var t = this._annotations,
n, r;
if (e) {
n = [];
for (r = t.length - 1; r >= 0; r--) {
var i = t[r];
i.type === e && t.splice(r, 1), n.splice(0, 0, i)
}
} else n = t, t = [];
var s = {
type: "Changed",
removed: n,
added: [],
changed: []
};
this.onChanged(s)
},
removeAnnotation: function (e) {
if (!e) return;
var t = this._getAnnotationIndex(e);
if (t < 0) return;
var n = {
type: "Changed",
removed: this._annotations.splice(t, 1),
added: [],
changed: []
};
this.onChanged(n)
},
replaceAnnotations: function (e, t) {
var n = this._annotations,
r, i, s, o = [];
if (e)
for (r = e.length - 1; r >= 0; r--) {
s = e[r], i = this._getAnnotationIndex(s);
if (i < 0) continue;
n.splice(i, 1), o.splice(0, 0, s)
}
t || (t = []);
for (r = 0; r < t.length; r++) s = t[r], i = this._binarySearch(n, s.start), n.splice(i, 0, s);
var u = {
type: "Changed",
removed: o,
added: t,
changed: []
};
this.onChanged(u)
},
setTextModel: function (e) {
this._model && this._model.removeEventListener("Changed", this._listener.onChanged), this._model = e, this._model && this._model.addEventListener("Changed", this._listener.onChanged)
},
_binarySearch: function (e, t) {
var n = e.length,
r = -1,
i;
while (n - r > 1) i = Math.floor((n + r) / 2), t <= e[i].start ? n = i : r = i;
return n
},
_getAnnotationIndex: function (e) {
var t = this._annotations,
n = this._binarySearch(t, e.start);
while (n < t.length && t[n].start === e.start) {
if (t[n] === e) return n;
n++
}
return -1
},
_onChanged: function (e) {
var t = e.start,
n = e.addedCharCount,
r = e.removedCharCount,
i = this._annotations,
s = t + r,
o = 0;
if (!(0 <= o && o < i.length)) return;
var u = {
type: "Changed",
added: [],
removed: [],
changed: [],
textModelChangedEvent: e
}, a = n - r,
f;
for (f = o; f < i.length; f++) {
var l = i[f];
l.start >= s ? (l.start += a, l.end += a, u.changed.push(l)) : l.end <= t || (l.start < t && s < l.end ? (l.end += a, u.changed.push(l)) : (i.splice(f, 1), u.removed.push(l), f--))
}(u.added.length > 0 || u.removed.length > 0 || u.changed.length > 0) && this.onChanged(u)
}
}, t.EventTarget.addMixin(u.prototype), a.prototype = {
destroy: function () {
var e = this._view;
e && (e.removeEventListener("Destroy", this._listener.onDestroy), e.removeEventListener("LineStyle", this._listener.onLineStyle), this.view = null);
var t = this._annotationModel;
t && (t.removeEventListener("Changed", this._listener.onChanged), t = null)
},
_mergeStyle: function (e, t) {
if (t) {
e || (e = {}), e.styleClass && t.styleClass && e.styleClass !== t.styleClass ? e.styleClass += " " + t.styleClass : e.styleClass = t.styleClass;
var n;
if (t.style) {
e.style || (e.style = {});
for (n in t.style) e.style[n] || (e.style[n] = t.style[n])
}
if (t.attributes) {
e.attributes || (e.attributes = {});
for (n in t.attributes) e.attributes[n] || (e.attributes[n] = t.attributes[n])
}
}
return e
},
_mergeStyleRanges: function (e, t) {
e || (e = []);
var n, r;
for (r = 0; r < e.length && t; r++) {
var i = e[r];
if (t.end <= i.start) break;
if (t.start >= i.end) continue;
n = this._mergeStyle({}, i.style), n = this._mergeStyle(n, t.style);
var s = [];
s.push(r, 1), t.start < i.start && s.push({
start: t.start,
end: i.start,
style: t.style
}), t.start > i.start && s.push({
start: i.start,
end: t.start,
style: i.style
}), s.push({
start: Math.max(i.start, t.start),
end: Math.min(i.end, t.end),
style: n
}), t.end < i.end && s.push({
start: t.end,
end: i.end,
style: i.style
}), t.end > i.end ? t = {
start: i.end,
end: t.end,
style: t.style
} : t = null, Array.prototype.splice.apply(e, s)
}
return t && (n = this._mergeStyle({}, t.style), e.splice(r, 0, {
start: t.start,
end: t.end,
style: n
})), e
},
_onAnnotationModelChanged: function (e) {
function i(e) {
for (var i = 0; i < e.length; i++) {
if (!n.isAnnotationTypeVisible(e[i].type)) continue;
var s = e[i].start,
o = e[i].end;
r.getBaseModel && (s = r.mapOffset(s, !0), o = r.mapOffset(o, !0)), s !== -1 && o !== -1 && t.redrawRange(s, o)
}
}
if (e.textModelChangedEvent) return;
var t = this._view;
if (!t) return;
var n = this,
r = t.getModel();
i(e.added), i(e.removed), i(e.changed)
},
_onDestroy: function (e) {
this.destroy()
},
_onLineStyle: function (e) {
var t = this._annotationModel,
n = e.textView.getModel(),
r = t.getTextModel(),
i = e.lineStart,
s = e.lineStart + e.lineText.length;
r !== n && (i = n.mapOffset(i), s = n.mapOffset(s));
var o = t.getAnnotations(i, s);
while (o.hasNext()) {
var u = o.next();
if (!this.isAnnotationTypeVisible(u.type)) continue;
if (u.rangeStyle) {
var a = u.start,
f = u.end;
r !== n && (a = n.mapOffset(a, !0), f = n.mapOffset(f, !0)), e.ranges = this._mergeStyleRanges(e.ranges, {
start: a,
end: f,
style: u.rangeStyle
})
}
u.lineStyle && (e.style = this._mergeStyle({}, e.style), e.style = this._mergeStyle(e.style, u.lineStyle))
}
}
}, o.addMixin(a.prototype), {
FoldingAnnotation: n,
AnnotationType: r,
AnnotationTypeList: o,
AnnotationModel: u,
AnnotationStyler: a
}
}), n("orion/editor/tooltip", ["i18n!orion/editor/nls/messages", "orion/editor/textView", "orion/editor/textModel", "orion/editor/projectionTextModel", "orion/editor/util"], function (e, t, n, r, i) {
function s(e) {
this._view = e, this._create(e.getOptions("parent").ownerDocument), e.addEventListener("Destroy", this, this.destroy)
}
return s.getTooltip = function (e) {
return e._tooltip || (e._tooltip = new s(e)), e._tooltip
}, s.prototype = {
_create: function (e) {
if (this._tooltipDiv) return;
var t = this._tooltipDiv = i.createElement(e, "div");
t.className = "textviewTooltip", t.setAttribute("aria-live", "assertive"), t.setAttribute("aria-atomic", "true");
var n = this._tooltipContents = i.createElement(e, "div");
t.appendChild(n), e.body.appendChild(t), this.hide()
},
_getWindow: function () {
var e = this._tooltipDiv.ownerDocument;
return e.defaultView || e.parentWindow
},
destroy: function () {
if (!this._tooltipDiv) return;
this.hide();
var e = this._tooltipDiv.parentNode;
e && e.removeChild(this._tooltipDiv), this._tooltipDiv = null
},
hide: function () {
this._contentsView && (this._contentsView.destroy(), this._contentsView = null), this._tooltipContents && (this._tooltipContents.innerHTML = ""), this._tooltipDiv && (this._tooltipDiv.style.visibility = "hidden");
var e = this._getWindow();
this._showTimeout && (e.clearTimeout(this._showTimeout), this._showTimeout = null), this._hideTimeout && (e.clearTimeout(this._hideTimeout), this._hideTimeout = null), this._fadeTimeout && (e.clearInterval(this._fadeTimeout), this._fadeTimeout = null)
},
isVisible: function () {
return this._tooltipDiv && this._tooltipDiv.style.visibility === "visible"
},
setTarget: function (e, t) {
if (this.target === e) return;
this._target = e, this.hide();
if (e) {
var n = this;
if (t === 0) n.show(!0);
else {
var r = this._getWindow();
n._showTimeout = r.setTimeout(function () {
n.show(!0)
}, t ? t : 500)
}
}
},
show: function (e) {
if (!this._target) return;
var n = this._target.getTooltipInfo();
if (!n) return;
var i = this._tooltipDiv,
s = this._tooltipContents;
i.style.left = i.style.right = i.style.width = i.style.height = s.style.width = s.style.height = "auto";
var o = n.contents;
o instanceof Array && (o = this._getAnnotationContents(o));
if (typeof o == "string") s.innerHTML = o;
else if (this._isNode(o)) s.appendChild(o);
else {
if (!(o instanceof r.ProjectionTextModel)) return;
var u = this._view,
a = u.getOptions();
a.wrapMode = !1, a.parent = s;
var f = "tooltip",
l = a.themeClass;
l ? (l = l.replace(f, ""), l && (l = " " + l), l = f + l) : l = f, a.themeClass = l;
var c = this._contentsView = new t.TextView(a);
c._clientDiv.contentEditable = !1;
var h = {
onLineStyle: function (e) {
u.onLineStyle(e)
}
};
c.addEventListener("LineStyle", h.onLineStyle), c.setModel(o);
var p = c.computeSize();
s.style.width = p.width + 20 + "px", s.style.height = p.height + "px", c.resize()
}
var d = i.ownerDocument.documentElement;
if (n.anchor === "right") {
var v = d.clientWidth - n.x;
i.style.right = v + "px", i.style.maxWidth = d.clientWidth - v - 10 + "px"
} else {
var m = parseInt(this._getNodeStyle(i, "padding-left", "0"), 10);
m += parseInt(this._getNodeStyle(i, "border-left-width", "0"), 10), m = n.x - m, i.style.left = m + "px", i.style.maxWidth = d.clientWidth - m - 10 + "px"
}
var g = parseInt(this._getNodeStyle(i, "padding-top", "0"), 10);
g += parseInt(this._getNodeStyle(i, "border-top-width", "0"), 10), g = n.y - g, i.style.top = g + "px", i.style.maxHeight = d.clientHeight - g - 10 + "px", i.style.opacity = "1", i.style.visibility = "visible";
if (e) {
var y = this,
b = this._getWindow();
y._hideTimeout = b.setTimeout(function () {
var e = parseFloat(y._getNodeStyle(i, "opacity", "1"));
y._fadeTimeout = b.setInterval(function () {
if (i.style.visibility === "visible" && e > 0) {
e -= .1, i.style.opacity = e;
return
}
y.hide()
}, 50)
}, 5e3)
}
},
_getAnnotationContents: function (t) {
function o(e, t) {
var n = s.getLineStart(s.getLineAtOffset(e)),
r = s.getLineEnd(s.getLineAtOffset(t), !0);
return s.getText(n, r)
}
function u(e) {
var t = e.title;
if (t === "") return null;
var n = "<div>";
return e.html && (n += e.html + "&nbsp;"), t || (t = o(e.start, e.end)), t = t.replace(/</g, "&lt;").replace(/>/g, "&gt;"), n += "<span style='vertical-align:middle;'>" + t + "</span><div>", n
}
if (t.length === 0) return null;
var n = this._view.getModel(),
i, s = n.getBaseModel ? n.getBaseModel() : n;
if (t.length === 1) {
i = t[0];
if (i.title !== undefined) return u(i);
var a = new r.ProjectionTextModel(s),
f = s.getLineStart(s.getLineAtOffset(i.start)),
l = s.getCharCount();
return i.end !== l && a.addProjection({
start: i.end,
end: l
}), f > 0 && a.addProjection({
start: 0,
end: f
}), a
}
var c = "<div><em>" + e.multipleAnnotations + "</em></div>";
for (var h = 0; h < t.length; h++) {
i = t[h];
var p = u(i);
p && (c += p)
}
return c
},
_getNodeStyle: function (e, t, n) {
var r;
if (e) {
r = e.style[t];
if (!r)
if (e.currentStyle) {
var i = 0,
s = t;
while ((i = s.indexOf("-", i)) !== -1) s = s.substring(0, i) + s.substring(i + 1, i + 2).toUpperCase() + s.substring(i + 2);
r = e.currentStyle[s]
} else {
var o = e.ownerDocument.defaultView.getComputedStyle(e, null);
r = o ? o.getPropertyValue(t) : null
}
}
return r || n
},
_isNode: function (e) {
return typeof Node == "object" ? e instanceof Node : e && typeof e == "object" && typeof e.nodeType == "number" && typeof e.nodeName == "string"
}
}, {
Tooltip: s
}
}), n("orion/editor/rulers", ["i18n!orion/editor/nls/messages", "orion/editor/annotations", "orion/editor/tooltip", "orion/editor/util"], function (e, t, n, r) {
function i(e, t, n, r) {
this._location = t || "left", this._overview = n || "page", this._rulerStyle = r, this._view = null;
var i = this;
this._listener = {
onTextModelChanged: function (e) {
i._onTextModelChanged(e)
},
onAnnotationModelChanged: function (e) {
i._onAnnotationModelChanged(e)
}
}, this.setAnnotationModel(e)
}
function s(e, t, n, r, s) {
i.call(this, e, t, "page", n), this._oddStyle = r || {
style: {
backgroundColor: "white"
}
}, this._evenStyle = s || {
style: {
backgroundColor: "white"
}
}, this._numOfDigits = 0
}
function o(e, t, n) {
i.call(this, e, t, "page", n)
}
function u(e, t, n) {
i.call(this, e, t, "document", n)
}
function a(e, t, n) {
o.call(this, e, t, n)
}
return i.prototype = {
getAnnotations: function (e, t) {
var n = this._annotationModel;
if (!n) return [];
var r = this._view.getModel(),
i = r.getLineStart(e),
s = r.getLineEnd(t - 1),
o = r;
r.getBaseModel && (o = r.getBaseModel(), i = r.mapOffset(i), s = r.mapOffset(s));
var u = [],
a = this.getAnnotationsByType(n, i, s);
for (var f = 0; f < a.length; f++) {
var l = a[f],
c = o.getLineAtOffset(l.start),
h = o.getLineAtOffset(Math.max(l.start, l.end - 1));
for (var p = c; p <= h; p++) {
var d = p;
if (r !== o) {
var v = o.getLineStart(p);
v = r.mapOffset(v, !0);
if (v === -1) continue;
d = r.getLineAtOffset(v)
}
if (!(e <= d && d < t)) continue;
var m = this._mergeAnnotation(u[d], l, p - c, h - c + 1);
m && (u[d] = m)
}
}
if (!this._multiAnnotation && this._multiAnnotationOverlay)
for (var g in u) u[g]._multiple && (u[g].html = u[g].html + this._multiAnnotationOverlay.html);
return u
},
getAnnotationModel: function () {
return this._annotationModel
},
getLocation: function () {
return this._location
},
getOverview: function () {
return this._overview
},
getRulerStyle: function () {
return this._rulerStyle
},
getView: function () {
return this._view
},
getWidestAnnotation: function () {
return null
},
setAnnotationModel: function (e) {
this._annotationModel && this._annotationModel.removEventListener("Changed", this._listener.onAnnotationModelChanged), this._annotationModel = e, this._annotationModel && this._annotationModel.addEventListener("Changed", this._listener.onAnnotationModelChanged)
},
setMultiAnnotation: function (e) {
this._multiAnnotation = e
},
setMultiAnnotationOverlay: function (e) {
this._multiAnnotationOverlay = e
},
setView: function (e) {
this._onTextModelChanged && this._view && this._view.removeEventListener("ModelChanged", this._listener.onTextModelChanged), this._view = e, this._onTextModelChanged && this._view && this._view.addEventListener("ModelChanged", this._listener.onTextModelChanged)
},
onClick: function (e, t) {},
onDblClick: function (e, t) {},
onMouseMove: function (e, t) {
var r = n.Tooltip.getTooltip(this._view);
if (!r) return;
if (r.isVisible() && this._tooltipLineIndex === e) return;
this._tooltipLineIndex = e;
var i = this;
r.setTarget({
y: t.clientY,
getTooltipInfo: function () {
return i._getTooltipInfo(i._tooltipLineIndex, this.y)
}
})
},
onMouseOver: function (e, t) {
this.onMouseMove(e, t)
},
onMouseOut: function (e, t) {
var r = n.Tooltip.getTooltip(this._view);
if (!r) return;
r.setTarget(null)
},
_getTooltipInfo: function (e, t) {
if (e === undefined) return;
var n = this._view,
r = n.getModel(),
i = this._annotationModel,
s = [];
if (i) {
var o = r.getLineStart(e),
u = r.getLineEnd(e);
r.getBaseModel && (o = r.mapOffset(o), u = r.mapOffset(u)), s = this.getAnnotationsByType(i, o, u)
}
var a = this._getTooltipContents(e, s);
if (!a) return null;
var f = {
contents: a,
anchor: this.getLocation()
}, l = n.getClientArea();
return this.getOverview() === "document" ? l.y = n.convert({
y: t
}, "view", "document").y : l.y = n.getLocationAtOffset(r.getLineStart(e)).y, n.convert(l, "document", "page"), f.x = l.x, f.y = l.y, f.anchor === "right" && (f.x += l.width), f
},
_getTooltipContents: function (e, t) {
return t
},
_onAnnotationModelChanged: function (e) {
function u(e) {
for (var i = 0; i < e.length; i++) {
if (!r.isAnnotationTypeVisible(e[i].type)) continue;
var s = e[i].start,
o = e[i].end;
n.getBaseModel && (s = n.mapOffset(s, !0), o = n.mapOffset(o, !0)), s !== -1 && o !== -1 && t.redrawLines(n.getLineAtOffset(s), n.getLineAtOffset(Math.max(s, o - 1)) + 1, r)
}
}
var t = this._view;
if (!t) return;
var n = t.getModel(),
r = this,
i = n.getLineCount();
if (e.textModelChangedEvent) {
var s = e.textModelChangedEvent.start;
n.getBaseModel && (s = n.mapOffset(s, !0));
var o = n.getLineAtOffset(s);
t.redrawLines(o, i, r);
return
}
u(e.added), u(e.removed), u(e.changed)
},
_mergeAnnotation: function (e, t, n, r) {
return e || (e = {}), n === 0 && (e.html && t.html ? (t.html !== e.html && !e._multiple && this._multiAnnotation && (e.html = this._multiAnnotation.html), e._multiple = !0) : e.html = t.html), e.style = this._mergeStyle(e.style, t.style), e
},
_mergeStyle: function (e, t) {
if (t) {
e || (e = {}), e.styleClass && t.styleClass && e.styleClass !== t.styleClass ? e.styleClass += " " + t.styleClass : e.styleClass = t.styleClass;
var n;
if (t.style) {
e.style || (e.style = {});
for (n in t.style) e.style[n] || (e.style[n] = t.style[n])
}
if (t.attributes) {
e.attributes || (e.attributes = {});
for (n in t.attributes) e.attributes[n] || (e.attributes[n] = t.attributes[n])
}
}
return e
}
}, t.AnnotationTypeList.addMixin(i.prototype), s.prototype = new i, s.prototype.getAnnotations = function (e, t) {
var n = i.prototype.getAnnotations.call(this, e, t),
r = this._view.getModel();
for (var s = e; s < t; s++) {
var o = s & 1 ? this._oddStyle : this._evenStyle,
u = s;
if (r.getBaseModel) {
var a = r.getLineStart(u);
u = r.getBaseModel().getLineAtOffset(r.mapOffset(a))
}
n[s] || (n[s] = {}), n[s].html = u + 1 + "", n[s].style || (n[s].style = o)
}
return n
}, s.prototype.getWidestAnnotation = function () {
var e = this._view.getModel().getLineCount();
return this.getAnnotations(e - 1, e)[e - 1]
}, s.prototype._onTextModelChanged = function (e) {
var t = e.start,
n = this._view.getModel(),
r = n.getBaseModel ? n.getBaseModel().getLineCount() : n.getLineCount(),
i = (r + "").length;
if (this._numOfDigits !== i) {
this._numOfDigits = i;
var s = n.getLineAtOffset(t);
this._view.redrawLines(s, n.getLineCount(), this)
}
}, o.prototype = new i, u.prototype = new i, u.prototype.getRulerStyle = function () {
var e = {
style: {
lineHeight: "1px",
fontSize: "1px"
}
};
return e = this._mergeStyle(e, this._rulerStyle), e
}, u.prototype.onClick = function (e, t) {
if (e === undefined) return;
this._view.setTopIndex(e)
}, u.prototype._getTooltipContents = function (t, n) {
if (n.length === 0) {
var s = this._view.getModel(),
o = t;
if (s.getBaseModel) {
var u = s.getLineStart(o);
o = s.getBaseModel().getLineAtOffset(s.mapOffset(u))
}
return r.formatMessage(e.line, o + 1)
}
return i.prototype._getTooltipContents.call(this, t, n)
}, u.prototype._mergeAnnotation = function (e, t, n, r) {
if (n !== 0) return undefined;
var i = e;
if (!i) {
var s = 3 * r;
i = {
html: "&nbsp;",
style: {
style: {
height: s + "px"
}
}
}, i.style = this._mergeStyle(i.style, t.overviewStyle)
}
return i
}, a.prototype = new o, a.prototype.onClick = function (e, t) {
if (e === undefined) return;
var r = this._annotationModel;
if (!r) return;
var i = this._view,
s = i.getModel(),
o = s.getLineStart(e),
u = s.getLineEnd(e, !0);
s.getBaseModel && (o = s.mapOffset(o), u = s.mapOffset(u), s = s.getBaseModel());
var a, f = r.getAnnotations(o, u);
while (!a && f.hasNext()) {
var l = f.next();
if (!this.isAnnotationTypeVisible(l.type)) continue;
a = l
}
if (a && s.getLineAtOffset(a.start) === s.getLineAtOffset(o)) {
var c = n.Tooltip.getTooltip(this._view);
c && c.setTarget(null), a.expanded ? a.collapse() : a.expand(), this._annotationModel.modifyAnnotation(a)
}
}, a.prototype._getTooltipContents = function (e, t) {
return t.length === 1 && t[0].expanded ? null : o.prototype._getTooltipContents.call(this, e, t)
}, a.prototype._onAnnotationModelChanged = function (e) {
function a(e) {
for (i = 0; i < e.length; i++) {
if (!r.isAnnotationTypeVisible(e[i].type)) continue;
var t = e[i].start;
n.getBaseModel && (t = n.mapOffset(t, !0)), t !== -1 && (u = Math.min(u, n.getLineAtOffset(t)))
}
}
if (e.textModelChangedEvent) {
o.prototype._onAnnotationModelChanged.call(this, e);
return
}
var t = this._view;
if (!t) return;
var n = t.getModel(),
r = this,
i, s = n.getLineCount(),
u = s;
a(e.added), a(e.removed), a(e.changed);
var f = t.getRulers();
for (i = 0; i < f.length; i++) t.redrawLines(u, s, f[i])
}, {
Ruler: i,
AnnotationRuler: o,
LineNumberRuler: s,
OverviewRuler: u,
FoldingRuler: a
}
}), n("orion/editor/undoStack", [], function () {
function e(e, t, n) {
this.offset = e, this.text = t, this.previousText = n
}
function t() {
this.changes = []
}
function n(e, t) {
this.view = e, this.size = t !== undefined ? t : 100, this.reset();
var n = e.getModel();
n.getBaseModel && (n = n.getBaseModel()), this.model = n;
var r = this;
this._listener = {
onChanging: function (e) {
r._onChanging(e)
},
onDestroy: function (e) {
r._onDestroy(e)
}
}, n.addEventListener("Changing", this._listener.onChanging), e.addEventListener("Destroy", this._listener.onDestroy)
}
return e.prototype = {
undo: function (e, t) {
this._doUndoRedo(this.offset, this.previousText, this.text, e, t)
},
redo: function (e, t) {
this._doUndoRedo(this.offset, this.text, this.previousText, e, t)
},
_doUndoRedo: function (e, t, n, r, i) {
var s = r.getModel();
if (s.mapOffset && r.annotationModel) {
var o = s.mapOffset(e, !0);
if (o < 0) {
var u = r.annotationModel,
a = u.getAnnotations(e, e + 1);
while (a.hasNext()) {
var f = a.next();
if (f.type === "orion.annotation.folding") {
f.expand(), o = s.mapOffset(e, !0);
break
}
}
}
if (o < 0) return;
e = o
}
r.setText(t, e, e + n.length), i && r.setSelection(e, e + t.length)
}
}, t.prototype = {
add: function (e) {
this.changes.push(e)
},
end: function (e) {
this.endSelection = e.getSelection(), this.endCaret = e.getCaretOffset()
},
undo: function (e, t) {
for (var n = this.changes.length - 1; n >= 0; n--) this.changes[n].undo(e, !1);
if (t) {
var r = this.startSelection.start,
i = this.startSelection.end;
e.setSelection(this.startCaret ? r : i, this.startCaret ? i : r)
}
},
redo: function (e, t) {
for (var n = 0; n < this.changes.length; n++) this.changes[n].redo(e, !1);
if (t) {
var r = this.endSelection.start,
i = this.endSelection.end;
e.setSelection(this.endCaret ? r : i, this.endCaret ? i : r)
}
},
start: function (e) {
this.startSelection = e.getSelection(), this.startCaret = e.getCaretOffset()
}
}, n.prototype = {
add: function (e) {
if (this.compoundChange) this.compoundChange.add(e);
else {
var t = this.stack.length;
this.stack.splice(this.index, t - this.index, e), this.index++, this.stack.length > this.size && (this.stack.shift(), this.index--, this.cleanIndex--)
}
},
markClean: function () {
this.endCompoundChange(), this._commitUndo(), this.cleanIndex = this.index
},
isClean: function () {
return this.cleanIndex === this.getSize().undo
},
canUndo: function () {
return this.getSize().undo > 0
},
canRedo: function () {
return this.getSize().redo > 0
},
endCompoundChange: function () {
this.compoundChange && this.compoundChange.end(this.view), this.compoundChange = undefined
},
getSize: function () {
var e = this.index,
t = this.stack.length;
return this._undoStart !== undefined && e++, {
undo: e,
redo: t - e
}
},
undo: function () {
this._commitUndo();
if (this.index <= 0) return !1;
var e = this.stack[--this.index];
return this._ignoreUndo = !0, e.undo(this.view, !0), this._ignoreUndo = !1, !0
},
redo: function () {
this._commitUndo();
if (this.index >= this.stack.length) return !1;
var e = this.stack[this.index++];
return this._ignoreUndo = !0, e.redo(this.view, !0), this._ignoreUndo = !1, !0
},
reset: function () {
this.index = this.cleanIndex = 0, this.stack = [], this._undoStart = undefined, this._undoText = "", this._undoType = 0, this._ignoreUndo = !1, this._compoundChange = undefined
},
startCompoundChange: function () {
this._commitUndo();
var e = new t;
this.add(e), this.compoundChange = e, this.compoundChange.start(this.view)
},
_commitUndo: function () {
this._undoStart !== undefined && (this._undoType === -1 ? this.add(new e(this._undoStart, "", this._undoText)) : this.add(new e(this._undoStart, this._undoText, "")), this._undoStart = undefined, this._undoText = "", this._undoType = 0)
},
_onDestroy: function (e) {
this.model.removeEventListener("Changing", this._listener.onChanging), this.view.removeEventListener("Destroy", this._listener.onDestroy)
},
_onChanging: function (t) {
var n = t.text,
r = t.start,
i = t.removedCharCount,
s = t.addedCharCount;
if (this._ignoreUndo) return;
this._undoStart !== undefined && (s !== 1 || i !== 0 || this._undoType !== 1 || r !== this._undoStart + this._undoText.length) && (s !== 0 || i !== 1 || this._undoType !== -1 || r + 1 !== this._undoStart && r !== this._undoStart) && this._commitUndo();
if (!this.compoundChange) {
if (s === 1 && i === 0) {
this._undoStart === undefined && (this._undoStart = r), this._undoText = this._undoText + n, this._undoType = 1;
return
}
if (s === 0 && i === 1) {
var o = this._undoText.length > 0 && this._undoStart === r;
this._undoStart = r, this._undoType = -1, o ? this._undoText = this._undoText + this.model.getText(r, r + i) : this._undoText = this.model.getText(r, r + i) + this._undoText;
return
}
}
this.add(new e(r, n, this.model.getText(r, r + i)))
}
}, {
UndoStack: n
}
}), n("orion/editor/textDND", [], function () {
function e(e, t) {
this._view = e, this._undoStack = t, this._dragSelection = null, this._dropOffset = -1, this._dropText = null;
var n = this;
this._listener = {
onDragStart: function (e) {
n._onDragStart(e)
},
onDragEnd: function (e) {
n._onDragEnd(e)
},
onDragEnter: function (e) {
n._onDragEnter(e)
},
onDragOver: function (e) {
n._onDragOver(e)
},
onDrop: function (e) {
n._onDrop(e)
},
onDestroy: function (e) {
n._onDestroy(e)
}
}, e.addEventListener("DragStart", this._listener.onDragStart), e.addEventListener("DragEnd", this._listener.onDragEnd), e.addEventListener("DragEnter", this._listener.onDragEnter), e.addEventListener("DragOver", this._listener.onDragOver), e.addEventListener("Drop", this._listener.onDrop), e.addEventListener("Destroy", this._listener.onDestroy)
}
return e.prototype = {
destroy: function () {
var e = this._view;
if (!e) return;
e.removeEventListener("DragStart", this._listener.onDragStart), e.removeEventListener("DragEnd", this._listener.onDragEnd), e.removeEventListener("DragEnter", this._listener.onDragEnter), e.removeEventListener("DragOver", this._listener.onDragOver), e.removeEventListener("Drop", this._listener.onDrop), e.removeEventListener("Destroy", this._listener.onDestroy), this._view = null
},
_onDestroy: function (e) {
this.destroy()
},
_onDragStart: function (e) {
var t = this._view,
n = t.getSelection(),
r = t.getModel();
r.getBaseModel && (n.start = r.mapOffset(n.start), n.end = r.mapOffset(n.end), r = r.getBaseModel());
var i = r.getText(n.start, n.end);
i && (this._dragSelection = n, e.event.dataTransfer.effectAllowed = "copyMove", e.event.dataTransfer.setData("Text", i))
},
_onDragEnd: function (e) {
var t = this._view;
if (this._dragSelection) {
this._undoStack && this._undoStack.startCompoundChange();
var n = e.event.dataTransfer.dropEffect === "move";
n && t.setText("", this._dragSelection.start, this._dragSelection.end);
if (this._dropText) {
var r = this._dropText,
i = this._dropOffset;
n && (i >= this._dragSelection.end ? i -= this._dragSelection.end - this._dragSelection.start : i >= this._dragSelection.start && (i = this._dragSelection.start)), t.setText(r, i, i), t.setSelection(i, i + r.length), this._dropText = null, this._dropOffset = -1
}
this._undoStack && this._undoStack.endCompoundChange()
}
this._dragSelection = null
},
_onDragEnter: function (e) {
this._onDragOver(e)
},
_onDragOver: function (e) {
var t = e.event.dataTransfer.types;
if (t) {
var n = !this._view.getOptions("readonly");
n && (n = t.contains ? t.contains("text/plain") : t.indexOf("text/plain") !== -1), n || (e.event.dataTransfer.dropEffect = "none")
}
},
_onDrop: function (e) {
var t = this._view,
n = e.event.dataTransfer.getData("Text");
if (n) {
var r = t.getOffsetAtLocation(e.x, e.y);
this._dragSelection ? (this._dropOffset = r, this._dropText = n) : (t.setText(n, r, r), t.setSelection(r, r + n.length))
}
}
}, {
TextDND: e
}
}), n("orion/editor/editor", ["i18n!orion/editor/nls/messages", "orion/editor/keyBinding", "orion/editor/eventTarget", "orion/editor/tooltip", "orion/editor/annotations", "orion/editor/util"], function (e, t, n, r, i, s) {
function a(e) {
this._textViewFactory = e.textViewFactory, this._undoStackFactory = e.undoStackFactory, this._textDNDFactory = e.textDNDFactory, this._annotationFactory = e.annotationFactory, this._foldingRulerFactory = e.foldingRulerFactory, this._lineNumberRulerFactory = e.lineNumberRulerFactory, this._contentAssistFactory = e.contentAssistFactory, this._keyBindingFactory = e.keyBindingFactory, this._statusReporter = e.statusReporter, this._domNode = e.domNode, this._annotationStyler = null, this._annotationModel = null, this._annotationRuler = null, this._lineNumberRuler = null, this._overviewRuler = null, this._foldingRuler = null, this._dirty = !1, this._contentAssist = null, this._title = null, this._keyModes = []
}
function f(e) {
var t = this,
n = Array.prototype.slice.call(arguments, 1);
return n.length ? function () {
return arguments.length ? t.apply(e, n.concat(Array.prototype.slice.call(arguments))) : t.apply(e, n)
} : function () {
return arguments.length ? t.apply(e, arguments) : t.call(e)
}
}
var o, u = "orion.annotation.highlightError";
return a.prototype = {
destroy: function () {
this.uninstallTextView(), this._textViewFactory = this._undoStackFactory = this._textDNDFactory = this._annotationFactory = this._foldingRulerFactory = this._lineNumberRulerFactory = this._contentAssistFactory = this._keyBindingFactory = this._statusReporter = this._domNode = null
},
getAnnotationModel: function () {
return this._annotationModel
},
getAnnotationRuler: function () {
return this._annotationRuler
},
getAnnotationStyler: function () {
return this._annotationStyler
},
getFoldingRuler: function () {
return this._foldingRuler
},
getLineNumberRuler: function () {
return this._lineNumberRuler
},
getModel: function () {
var e = this._textView.getModel();
return e.getBaseModel && (e = e.getBaseModel()), e
},
getOverviewRuler: function () {
return this._overviewRuler
},
getTextView: function () {
return this._textView
},
getTitle: function () {
return this._title
},
getKeyModes: function () {
return this._keyModes
},
isDirty: function () {
return this._dirty
},
setAnnotationRulerVisible: function (e) {
if (this._annotationRulerVisible === e) return;
this._annotationRulerVisible = e;
if (!this._annotationRuler) return;
var t = this._textView;
e ? t.addRuler(this._annotationRuler, 0) : t.removeRuler(this._annotationRuler)
},
setFoldingRulerVisible: function (e) {
if (this._foldingRulerVisible === e) return;
this._foldingRulerVisible = e;
if (!this._foldingRuler) return;
var t = this._textView;
if (!t.getModel().getBaseModel) return;
e ? t.addRuler(this._foldingRuler, 100) : t.removeRuler(this._foldingRuler)
},
setDirty: function (e) {
if (this._dirty === e) return;
this._dirty = e, this.onDirtyChanged({
type: "DirtyChanged"
})
},
setLineNumberRulerVisible: function (e) {
if (this._lineNumberRulerVisible === e) return;
this._lineNumberRulerVisible = e;
if (!this._lineNumberRuler) return;
var t = this._textView;
e ? t.addRuler(this._lineNumberRuler, 1) : t.removeRuler(this._lineNumberRuler)
},
setOverviewRulerVisible: function (e) {
if (this._overviewRulerVisible === e) return;
this._overviewRulerVisible = e;
if (!this._overviewRuler) return;
var t = this._textView;
e ? t.addRuler(this._overviewRuler) : t.removeRuler(this._overviewRuler)
},
mapOffset: function (e, t) {
var n = this._textView,
r = n.getModel();
return r.getBaseModel && (e = r.mapOffset(e, t)), e
},
getCaretOffset: function () {
return this.mapOffset(this._textView.getCaretOffset())
},
getSelection: function () {
var e = this._textView,
t = e.getSelection(),
n = e.getModel();
return n.getBaseModel && (t.start = n.mapOffset(t.start), t.end = n.mapOffset(t.end)), t
},
getText: function (e, t) {
var n = this._textView,
r = n.getModel();
return r.getBaseModel && (r = r.getBaseModel()), r.getText(e, t)
},
_expandOffset: function (e) {
var t = this._textView.getModel(),
n = this._annotationModel;
if (!n || !t.getBaseModel) return;
var r = n.getAnnotations(e, e + 1);
while (r.hasNext()) {
var s = r.next();
s.type === i.AnnotationType.ANNOTATION_FOLDING && s.expand && (s.expand(), n.modifyAnnotation(s))
}
},
setCaretOffset: function (e) {
var t = this._textView,
n = t.getModel();
n.getBaseModel && (this._expandOffset(e), e = n.mapOffset(e, !0)), t.setCaretOffset(e)
},
setText: function (e, t, n) {
var r = this._textView,
i = r.getModel();
i.getBaseModel && (t !== undefined && (this._expandOffset(t), t = i.mapOffset(t, !0)), n !== undefined && (this._expandOffset(n), n = i.mapOffset(n, !0))), r.setText(e, t, n)
},
setFoldingEnabled: function (e) {
this.setFoldingRulerVisible(e)
},
setSelection: function (e, t, n) {
var r = this._textView,
i = r.getModel();
i.getBaseModel && (this._expandOffset(e), this._expandOffset(t), e = i.mapOffset(e, !0), t = i.mapOffset(t, !0)), r.setSelection(e, t, n)
},
moveSelection: function (e, t, n, r) {
t = t || e;
var i = this._textView;
this.setSelection(e, t, !1);
var s = i.getTopPixel(),
u = i.getBottomPixel(),
a = this.getModel(),
f = a.getLineAtOffset(e),
l = i.getLinePixel(f);
if (l < s || l > u) {
var c = u - s,
h = Math.max(0, l - Math.floor((l < s ? 3 : 1) * c / 4)),
p = new o({
node: i,
duration: 300,
curve: [s, h],
onAnimate: function (e) {
i.setTopPixel(Math.floor(e))
},
onEnd: function () {
i.showSelection(), (r === undefined || r) && i.focus(), n && n()
}
});
p.play()
} else i.showSelection(), (r === undefined || r) && i.focus(), n && n()
},
checkDirty: function () {
this.setDirty(!this._undoStack.isClean())
},
reportStatus: function (e, t, n) {
this._statusReporter && this._statusReporter(e, t, n)
},
_getTooltipInfo: function (e, t) {
var n = this._textView,
r = this.getAnnotationModel();
if (!r) return null;
var i = this._annotationStyler;
if (!i) return null;
var s = n.getOffsetAtLocation(e, t);
if (s === -1) return null;
s = this.mapOffset(s);
var o = i.getAnnotationsByType(r, s, s + 1),
u = [];
for (var a = 0; a < o.length; a++) o[a].rangeStyle && u.push(o[a]);
if (u.length === 0) return null;
var f = n.convert({
x: e,
y: t
}, "document", "page"),
l = {
contents: u,
anchor: "left",
x: f.x + 10,
y: f.y + 20
};
return l
},
_highlightCurrentLine: function (e, t) {
var n = this._annotationModel;
if (!n) return;
var r = this._textView,
s = r.getModel(),
o = t ? s.getLineAtOffset(t.start) : -1,
u = s.getLineAtOffset(e.start),
a = e.start === e.end,
f = !t || t.start === t.end,
l = s.getLineStart(u),
c = s.getLineEnd(u);
s.getBaseModel && (l = s.mapOffset(l), c = s.mapOffset(c));
var h = this._currentLineAnnotation;
if (o === u && f && a && h && h.start === l && h.end === c) return;
var p = h ? [h] : null,
d;
if (a) {
var v = i.AnnotationType.ANNOTATION_CURRENT_LINE;
h = i.AnnotationType.createAnnotation(v, l, c), d = [h]
}
this._currentLineAnnotation = h, n.replaceAnnotations(p, d)
},
installTextView: function () {
this._textView = this._textViewFactory(), this._undoStackFactory && (this._undoStack = this._undoStackFactory.createUndoStack(this)), this._textDNDFactory && (this._textDND = this._textDNDFactory.createTextDND(this, this._undoStack));
if (this._contentAssistFactory) {
var n = this._contentAssistFactory.createContentAssistMode(this);
this._keyModes.push(n), this._contentAssist = n.getContentAssist()
}
var s = this,
o = this._textView,
a = this;
this._listener = {
onModelChanged: function (e) {
a.checkDirty()
},
onMouseOver: function (e) {
a._listener.onMouseMove(e)
},
onMouseMove: function (e) {
var t = r.Tooltip.getTooltip(o);
if (!t) return;
t.setTarget({
x: e.x,
y: e.y,
getTooltipInfo: function () {
return a._getTooltipInfo(this.x, this.y)
}
})
},
onMouseOut: function (e, t) {
var n = r.Tooltip.getTooltip(o);
if (!n) return;
n.setTarget(null)
},
onSelection: function (e) {
a._updateCursorStatus(), a._highlightCurrentLine(e.newValue, e.oldValue)
}
}, o.addEventListener("ModelChanged", this._listener.onModelChanged), o.addEventListener("Selection", this._listener.onSelection), o.addEventListener("MouseOver", this._listener.onMouseOver), o.addEventListener("MouseOut", this._listener.onMouseOut), o.addEventListener("MouseMove", this._listener.onMouseMove), this._keyBindingFactory && this._keyBindingFactory(this, this._keyModes, this._undoStack, this._contentAssist), o.setKeyBinding(new t.KeyBinding(27), "cancelMode"), o.setAction("cancelMode", function () {
var e = !1;
for (var t = 0; t < this._keyModes.length; t++) this._keyModes[t].isActive() && (e = this._keyModes[t].cancel() || e);
return e
}.bind(this), {
name: e.cancelMode
}), o.setAction("lineUp", function () {
for (var e = 0; e < this._keyModes.length; e++)
if (this._keyModes[e].isActive()) return this._keyModes[e].lineUp();
return !1
}.bind(this)), o.setAction("lineDown", function () {
for (var e = 0; e < this._keyModes.length; e++)
if (this._keyModes[e].isActive()) return this._keyModes[e].lineDown();
return !1
}.bind(this)), o.setAction("enter", function () {
for (var e = 0; e < this._keyModes.length; e++)
if (this._keyModes[e].isActive()) return this._keyModes[e].enter();
return !1
}.bind(this));
var f = function (e, t) {
if (e === undefined) return;
if (e === -1) return;
var n = this.getView(),
r = n.getModel(),
o = this.getAnnotationModel(),
u = s.mapOffset(r.getLineStart(e)),
a = s.mapOffset(r.getLineEnd(e)),
f = o.getAnnotations(u, a),
l = null;
while (f.hasNext()) {
var c = f.next();
if (c.type === i.AnnotationType.ANNOTATION_BOOKMARK) {
l = c;
break
}
}
l ? o.removeAnnotation(l) : (l = i.AnnotationType.createAnnotation(i.AnnotationType.ANNOTATION_BOOKMARK, u, a), l.title = undefined, o.addAnnotation(l))
};
if (this._annotationFactory) {
var l = o.getModel();
l.getBaseModel && (l = l.getBaseModel()), this._annotationModel = this._annotationFactory.createAnnotationModel(l);
if (this._annotationModel) {
var c = this._annotationStyler = this._annotationFactory.createAnnotationStyler(o, this._annotationModel);
c && (c.addAnnotationType(i.AnnotationType.ANNOTATION_CURRENT_SEARCH), c.addAnnotationType(i.AnnotationType.ANNOTATION_MATCHING_SEARCH), c.addAnnotationType(i.AnnotationType.ANNOTATION_ERROR), c.addAnnotationType(i.AnnotationType.ANNOTATION_WARNING), c.addAnnotationType(i.AnnotationType.ANNOTATION_MATCHING_BRACKET), c.addAnnotationType(i.AnnotationType.ANNOTATION_CURRENT_BRACKET), c.addAnnotationType(i.AnnotationType.ANNOTATION_CURRENT_LINE), c.addAnnotationType(i.AnnotationType.ANNOTATION_READ_OCCURRENCE), c.addAnnotationType(i.AnnotationType.ANNOTATION_WRITE_OCCURRENCE), c.addAnnotationType(u))
}
o.annotationModel = this._annotationModel;
var h = this._annotationFactory.createAnnotationRulers(this._annotationModel),
p = this._annotationRuler = h.annotationRuler;
p && (p.onClick = function (e, t) {
if (e === undefined) return;
if (e === -1) return;
var n = this.getView(),
r = n.getModel(),
i = this.getAnnotationModel(),
o = s.mapOffset(r.getLineStart(e)),
u = s.mapOffset(r.getLineEnd(e)),
a = i.getAnnotations(o, u);
while (a.hasNext()) {
var f = a.next();
if (!this.isAnnotationTypeVisible(f.type)) continue;
var l = s.getModel();
s.onGotoLine(l.getLineAtOffset(o), f.start - o, f.end - o);
break
}
}, p.onDblClick = f, p.setMultiAnnotationOverlay({
html: "<div class='annotationHTML overlay'></div>"
}), p.addAnnotationType(i.AnnotationType.ANNOTATION_ERROR), p.addAnnotationType(i.AnnotationType.ANNOTATION_WARNING), p.addAnnotationType(i.AnnotationType.ANNOTATION_TASK), p.addAnnotationType(i.AnnotationType.ANNOTATION_BOOKMARK)), this.setAnnotationRulerVisible(!0), p = this._overviewRuler = h.overviewRuler, p && (p.onClick = function (e, t) {
if (e === undefined) return;
var n = o.getModel().getLineStart(e);
s.moveSelection(s.mapOffset(n))
}, p.addAnnotationType(i.AnnotationType.ANNOTATION_CURRENT_SEARCH), p.addAnnotationType(i.AnnotationType.ANNOTATION_MATCHING_SEARCH), p.addAnnotationType(i.AnnotationType.ANNOTATION_ERROR), p.addAnnotationType(i.AnnotationType.ANNOTATION_WARNING), p.addAnnotationType(i.AnnotationType.ANNOTATION_TASK), p.addAnnotationType(i.AnnotationType.ANNOTATION_BOOKMARK), p.addAnnotationType(i.AnnotationType.ANNOTATION_MATCHING_BRACKET), p.addAnnotationType(i.AnnotationType.ANNOTATION_CURRENT_BRACKET), p.addAnnotationType(i.AnnotationType.ANNOTATION_CURRENT_LINE), p.addAnnotationType(i.AnnotationType.ANNOTATION_READ_OCCURRENCE), p.addAnnotationType(i.AnnotationType.ANNOTATION_WRITE_OCCURRENCE)), this.setOverviewRulerVisible(!0)
}
this._lineNumberRulerFactory && (this._lineNumberRuler = this._lineNumberRulerFactory.createLineNumberRuler(this._annotationModel), this._lineNumberRuler.onDblClick = f, this.setLineNumberRulerVisible(!0)), this._foldingRulerFactory && (this._foldingRuler = this._foldingRulerFactory.createFoldingRuler(this._annotationModel), this._foldingRuler.addAnnotationType(i.AnnotationType.ANNOTATION_FOLDING), this.setFoldingRulerVisible(!1));
var d = {
type: "TextViewInstalled",
textView: o
};
this.dispatchEvent(d)
},
uninstallTextView: function () {
var e = this._textView;
if (!e) return;
e.destroy(), this._textView = this._undoStack = this._textDND = this._contentAssist = this._listener = this._annotationModel = this._annotationStyler = this._annotationRuler = this._overviewRuler = this._lineNumberRuler = this._foldingRuler = this._currentLineAnnotation = this._title = null, this._dirty = !1, this._keyModes = [];
var t = {
type: "TextViewUninstalled",
textView: e
};
this.dispatchEvent(t)
},
_updateCursorStatus: function () {
var t = this.getModel(),
n = this.getCaretOffset(),
r = t.getLineAtOffset(n),
i = t.getLineStart(r),
o = n - i;
for (var u = 0; u < this._keyModes.length; u++) {
var a = this._keyModes[u];
if (a.isActive() && a.isStatusActive && a.isStatusActive()) return
}
this.reportStatus(s.formatMessage(e.lineColumn, r + 1, o + 1))
},
showProblems: function (e) {
var t = this._annotationModel;
if (!t) return;
var n = [],
r = [],
s = t.getTextModel(),
o = t.getAnnotations(0, s.getCharCount()),
u;
while (o.hasNext()) u = o.next(), (u.type === i.AnnotationType.ANNOTATION_ERROR || u.type === i.AnnotationType.ANNOTATION_WARNING) && n.push(u);
if (e)
for (var a = 0; a < e.length; a++) {
var f = e[a];
if (f) {
var l = f.description.replace(/'/g, "&#39;").replace(/"/g, "&#34;"),
c = f.line - 1,
h = s.getLineStart(c),
p = f.severity,
d = p === "error" ? i.AnnotationType.ANNOTATION_ERROR : i.AnnotationType.ANNOTATION_WARNING,
v = h + f.start - 1,
m = h + f.end;
u = i.AnnotationType.createAnnotation(d, v, m, l), r.push(u)
}
}
t.replaceAnnotations(n, r)
},
showOccurrences: function (e) {
var t = this._annotationModel;
if (!t) return;
var n = [],
r = [],
s = t.getTextModel(),
o = t.getAnnotations(0, s.getCharCount()),
u;
while (o.hasNext()) u = o.next(), (u.type === i.AnnotationType.ANNOTATION_READ_OCCURRENCE || u.type === i.AnnotationType.ANNOTATION_WRITE_OCCURRENCE) && n.push(u);
if (e)
for (var a = 0; a < e.length; a++) {
var f = e[a];
if (f) {
var l = f.line - 1,
c = s.getLineStart(l),
h = c + f.start - 1,
p = c + f.end,
d = f.readAccess === !0 ? i.AnnotationType.ANNOTATION_READ_OCCURRENCE : i.AnnotationType.ANNOTATION_WRITE_OCCURRENCE,
v = f.description;
u = i.AnnotationType.createAnnotation(d, h, p, v), r.push(u)
}
}
t.replaceAnnotations(n, r)
},
showSelection: function (e, t, n, r, i) {
if (typeof e == "number") typeof t != "number" && (t = e), this.moveSelection(e, t);
else if (typeof n == "number") {
var s = this.getModel(),
o = s.getLineStart(n - 1);
typeof r == "number" && (o += r), typeof i != "number" && (i = 0), this.moveSelection(o, o + i)
}
},
setInput: function (e, t, n, r) {
this._title = e, this._textView && (r ? (this._undoStack.markClean(), this.checkDirty()) : (t ? this._textView.setText(t) : n !== null && n !== undefined && (this._textView.setText(n), this._textView.getModel().setLineDelimiter("auto"), this._highlightCurrentLine(this._textView.getSelection())), this._undoStack.reset(), this.checkDirty(), this._textView.focus())), this.onInputChanged({
type: "InputChanged",
title: e,
message: t,
contents: n,
contentsSaved: r
})
},
onInputChanged: function (e) {
return this.dispatchEvent(e)
},
onGotoLine: function (e, t, n) {
if (this._textView) {
var r = this.getModel(),
i = r.getLineStart(e),
s = 0;
n === undefined && (n = 0);
if (typeof t == "string") {
var o = r.getLine(e).indexOf(t);
o !== -1 && (s = o, n = s + t.length)
} else {
s = t;
var u = r.getLineEnd(e) - i;
s = Math.min(s, u), n = Math.min(n, u)
}
this.moveSelection(i + s, i + n)
}
},
onDirtyChanged: function (e) {
return this.dispatchEvent(e)
}
}, n.EventTarget.addMixin(a.prototype), o = function () {
function e(e) {
this.options = e
}
return e.prototype.play = function () {
function c() {
l = l === -1 ? (new Date).getTime() : l;
var t = (new Date).getTime(),
o = (t - l) / e;
if (o < 1) {
var c = n(o);
a = s + c * u, r(a)
} else clearInterval(f), i()
}
var e = typeof this.options.duration == "number" ? this.options.duration : 350,
t = typeof this.options.rate == "number" ? this.options.rate : 20,
n = this.options.easing || this.defaultEasing,
r = this.options.onAnimate || function () {}, i = this.options.onEnd || function () {}, s = this.options.curve[0],
o = this.options.curve[1],
u = o - s,
a, f, l = -1;
f = setInterval(c, t)
}, e.prototype.defaultEasing = function (e) {
return Math.sin(e * (Math.PI / 2))
}, e
}(), Function.prototype.bind || (Function.prototype.bind = f), {
Editor: a,
util: {
bind: f
}
}
}), n("orion/editor/regex", [], function () {
function e(e) {
return e.replace(/([\\$\^*\/+?\.\(\)|{}\[\]])/g, "\\$&")
}
function t(e) {
var t = /^\s*\/(.+)\/([gim]{0,3})\s*$/.exec(e);
return t ? {
pattern: t[1],
flags: t[2]
} : null
}
return {
escape: e,
parse: t
}
}), n("orion/editor/editorFeatures", ["i18n!orion/editor/nls/messages", "orion/editor/undoStack", "orion/editor/keyBinding", "orion/editor/rulers", "orion/editor/annotations", "orion/editor/tooltip", "orion/editor/textDND", "orion/editor/regex", "orion/editor/util"], function (e, t, n, r, i, s, o, u, a) {
function f() {}
function l() {}
function c() {}
function h() {}
function p() {}
function d(e, t, n) {
this.editor = e, this.textView = e.getTextView(), this.undoStack = t, this._incrementalFindActive = !1, this._incrementalFindSuccess = !0, this._incrementalFindIgnoreSelection = !1, this._incrementalFindPrefix = "", this._searcher = n, this._lastEditLocation = null, this.init()
}
function v(e, t, n, r) {
this.editor = e, this.textView = e.getTextView(), this.undoStack = t, this.contentAssist = n, this.linkedMode = r, this.contentAssist && this.contentAssist.addEventListener("ProposalApplied", this.contentAssistProposalApplied.bind(this)), this.init()
}
function m(e) {
this.editor = e, this.textView = e.getTextView(), this.linkedModeActive = !1, this.linkedModePositions = [], this.linkedModeCurrentPositionIndex = 0, this.linkedModeEscapePosition = 0, this.linkedModeListener = {
onVerify: function (e) {
var t = !1,
n = 0;
for (var r = 0; r < this.linkedModePositions.length; ++r) {
var i = this.linkedModePositions[r];
if (t) i.offset += n;
else if (e.start >= i.offset && e.end <= i.offset + i.length) {
var s = i.length;
i.length = e.start - i.offset + e.text.length + (i.offset + i.length - e.end), n = i.length - s, t = !0
}
}
t ? this.linkedModeEscapePosition += n : this.cancel()
}.bind(this)
}
}
return f.prototype = {
createUndoStack: function (n) {
var r = n.getTextView(),
i = new t.UndoStack(r, 200);
return r.setAction("undo", function () {
return i.undo(), !0
}, {
name: e.undo
}), r.setAction("redo", function () {
return i.redo(), !0
}, {
name: e.redo
}), i
}
}, l.prototype = {
createLineNumberRuler: function (e) {
return new r.LineNumberRuler(e, "left", {
styleClass: "ruler lines"
}, {
styleClass: "rulerLines odd"
}, {
styleClass: "rulerLines even"
})
}
}, c.prototype = {
createFoldingRuler: function (e) {
return new r.FoldingRuler(e, "left", {
styleClass: "ruler folding"
})
}
}, h.prototype = {
createAnnotationModel: function (e) {
return new i.AnnotationModel(e)
},
createAnnotationStyler: function (e, t) {
return new i.AnnotationStyler(e, t)
},
createAnnotationRulers: function (e) {
var t = new r.AnnotationRuler(e, "left", {
styleClass: "ruler annotations"
}),
n = new r.OverviewRuler(e, "right", {
styleClass: "ruler overview"
});
return {
annotationRuler: t,
overviewRuler: n
}
}
}, p.prototype = {
createTextDND: function (e, t) {
return new o.TextDND(e.getTextView(), t)
}
}, d.prototype = {
init: function () {
var t = this;
this._incrementalFindListener = {
onVerify: function (n) {
var r = t.editor,
i = r.getModel(),
s = r.mapOffset(n.start),
o = r.mapOffset(n.end),
f = i.getText(s, o),
l = t._incrementalFindPrefix,
c = l.match(new RegExp("^" + u.escape(f), "i"));
if (c && c.length > 0) {
l = t._incrementalFindPrefix += n.text, t.editor.reportStatus(a.formatMessage(e.incrementalFind, l));
var h = r.getSelection().start,
p = r.getModel().find({
string: l,
start: h,
caseInsensitive: l.toLowerCase() === l
}).next();
p ? (t._incrementalFindSuccess = !0, t._incrementalFindIgnoreSelection = !0, r.moveSelection(p.start, p.end), t._incrementalFindIgnoreSelection = !1) : (r.reportStatus(a.formatMessage(e.incrementalFindNotFound, l), "error"), t._incrementalFindSuccess = !1), n.text = null
}
},
onSelection: function () {
t._incrementalFindIgnoreSelection || t.toggleIncrementalFind()
}
}, this._lastEditListener = {
onModelChanged: function (e) {
t.editor.isDirty() && (t._lastEditLocation = e.start + e.addedCharCount)
}
}, this.textView.addEventListener("ModelChanged", this._lastEditListener.onModelChanged), this.textView.setKeyBinding(new n.KeyBinding("k", !0), "findNext"), this.textView.setAction("findNext", function () {
if (this._searcher) {
var e = this.textView.getSelection();
return e.start < e.end ? this._searcher.findNext(!0, this.textView.getText(e.start, e.end)) : this._searcher.findNext(!0), !0
}
return !1
}.bind(this), {
name: e.findNext
}), this.textView.setKeyBinding(new n.KeyBinding("k", !0, !0), "findPrevious"), this.textView.setAction("findPrevious", function () {
if (this._searcher) {
var e = this.textView.getSelection();
return e.start < e.end ? this._searcher.findNext(!1, this.textView.getText(e.start, e.end)) : this._searcher.findNext(!1), !0
}
return !1
}.bind(this), {
name: e.findPrevious
}), this.textView.setKeyBinding(new n.KeyBinding("j", !0), "incrementalFind"), this.textView.setAction("incrementalFind", function () {
if (this._searcher && this._searcher.visible()) return !0;
var t = this.editor;
if (!this._incrementalFindActive) t.setCaretOffset(t.getCaretOffset()), this.toggleIncrementalFind();
else {
var n = this._incrementalFindPrefix;
if (n.length !== 0) {
var r, i = 0;
this._incrementalFindSuccess && (i = t.getSelection().start + 1), r = t.getModel().find({
string: n,
start: i,
caseInsensitive: n.toLowerCase() === n
}).next(), r ? (this._incrementalFindSuccess = !0, this._incrementalFindIgnoreSelection = !0, t.moveSelection(r.start, r.end), this._incrementalFindIgnoreSelection = !1, t.reportStatus(a.formatMessage(e.incrementalFind, n))) : (t.reportStatus(a.formatMessage(e.incrementalFindNotFound, n), "error"), this._incrementalFindSuccess = !1)
}
}
return !0
}.bind(this), {
name: e.incrementalFindKey
}), this.textView.setAction("deletePrevious", function () {
if (this._incrementalFindActive) {
var t = this.editor,
n = this._incrementalFindPrefix;
n = this._incrementalFindPrefix = n.substring(0, n.length - 1);
if (n.length === 0) return this._incrementalFindSuccess = !0, this._incrementalFindIgnoreSelection = !0, t.setCaretOffset(t.getSelection().start), this._incrementalFindIgnoreSelection = !1, this.toggleIncrementalFind(), !0;
t.reportStatus(a.formatMessage(e.incrementalFind, n));
var r = t.getModel().find({
string: n,
start: t.getCaretOffset() - n.length - 1,
reverse: !0,
caseInsensitive: n.toLowerCase() === n
}).next();
return r ? (this._incrementalFindSuccess = !0, this._incrementalFindIgnoreSelection = !0, t.moveSelection(r.start, r.end), this._incrementalFindIgnoreSelection = !1) : t.reportStatus(a.formatMessage(e.incrementalFindNotFound, n), "error"), !0
}
return !1
}.bind(this)), this.textView.setAction("tab", function () {
if (this.textView.getOptions("readonly")) return !1;
if (!this.textView.getOptions("tabMode")) return;
var e = this.editor,
t = e.getModel(),
n = e.getSelection(),
r = t.getLineAtOffset(n.start),
i = t.getLineAtOffset(n.end > n.start ? n.end - 1 : n.end);
if (r !== i) {
var s = [];
s.push("");
for (var o = r; o <= i; o++) s.push(t.getLine(o, !0));
var u = t.getLineStart(r),
a = t.getLineEnd(i, !0),
f = this.textView.getOptions("tabSize", "expandTab"),
l = f.expandTab ? (new Array(f.tabSize + 1)).join(" ") : " ";
return e.setText(s.join(l), u, a), e.setSelection(u === n.start ? n.start : n.start + l.length, n.end + (i - r + 1) * l.length), !0
}
var c = e.getKeyModes();
for (var h = 0; h < c.length; h++)
if (c[h].isActive()) return c[h].tab();
return !1
}.bind(this)), this.textView.setAction("shiftTab", function () {
if (this.textView.getOptions("readonly")) return !1;
if (!this.textView.getOptions("tabMode")) return;
var e = this.editor,
t = e.getModel(),
n = e.getSelection(),
r = t.getLineAtOffset(n.start),
i = t.getLineAtOffset(n.end > n.start ? n.end - 1 : n.end),
s = this.textView.getOptions("tabSize"),
o = (new Array(s + 1)).join(" "),
u = [],
a = 0,
f = 0;
for (var l = r; l <= i; l++) {
var c = t.getLine(l, !0);
if (t.getLineStart(l) !== t.getLineEnd(l))
if (c.indexOf(" ") === 0) c = c.substring(1), a++;
else {
if (c.indexOf(o) !== 0) return !0;
c = c.substring(s), a += s
}
l === r && (f = a), u.push(c)
}
var h = t.getLineStart(r),
p = t.getLineEnd(i, !0),
d = t.getLineStart(i);
e.setText(u.join(""), h, p);
var v = h === n.start ? n.start : n.start - f,
m = Math.max(v, n.end - a + (n.end === d + 1 && n.start !== n.end ? 1 : 0));
return e.setSelection(v, m), !0
}.bind(this), {
name: e.unindentLines
}), this.textView.setKeyBinding(new n.KeyBinding(38, !1, !1, !0), "moveLinesUp"), this.textView.setAction("moveLinesUp", function () {
if (this.textView.getOptions("readonly")) return !1;
var e = this.editor,
t = e.getModel(),
n = e.getSelection(),
r = t.getLineAtOffset(n.start);
if (r === 0) return !0;
var i = t.getLineAtOffset(n.end > n.start ? n.end - 1 : n.end),
s = t.getLineCount(),
o = t.getLineStart(r - 1),
u = t.getLineStart(r),
a = t.getLineEnd(i, !0),
f = t.getText(u, a),
l = 0;
if (i === s - 1) {
var c = t.getLineEnd(r - 1),
h = t.getLineEnd(r - 1, !0);
f += t.getText(c, h), u = c, l = h - c
}
return this.startUndo(), e.setText("", u, a), e.setText(f, o, o), e.setSelection(o, o + f.length - l), this.endUndo(), !0
}.bind(this), {
name: e.moveLinesUp
}), this.textView.setKeyBinding(new n.KeyBinding(40, !1, !1, !0), "moveLinesDown"), this.textView.setAction("moveLinesDown", function () {
if (this.textView.getOptions("readonly")) return !1;
var e = this.editor,
t = e.getModel(),
n = e.getSelection(),
r = t.getLineAtOffset(n.start),
i = t.getLineAtOffset(n.end > n.start ? n.end - 1 : n.end),
s = t.getLineCount();
if (i === s - 1) return !0;
var o = t.getLineStart(r),
u = t.getLineEnd(i, !0),
a = t.getLineEnd(i + 1, !0) - (u - o),
f, l = 0;
if (i !== s - 2) f = t.getText(o, u);
else {
var c = t.getLineEnd(i);
f = t.getText(c, u) + t.getText(o, c), l += u - c
}
return this.startUndo(), e.setText("", o, u), e.setText(f, a, a), e.setSelection(a + l, a + l + f.length), this.endUndo(), !0
}.bind(this), {
name: e.moveLinesDown
}), this.textView.setKeyBinding(new n.KeyBinding(38, !0, !1, !0), "copyLinesUp"), this.textView.setAction("copyLinesUp", function () {
if (this.textView.getOptions("readonly")) return !1;
var e = this.editor,
t = e.getModel(),
n = e.getSelection(),
r = t.getLineAtOffset(n.start),
i = t.getLineAtOffset(n.end > n.start ? n.end - 1 : n.end),
s = t.getLineStart(r),
o = t.getLineEnd(i, !0),
u = t.getLineCount(),
a = "",
f = t.getText(s, o);
i === u - 1 && (f += a = t.getLineDelimiter());
var l = s;
return e.setText(f, l, l), e.setSelection(l, l + f.length - a.length), !0
}.bind(this), {
name: e.copyLinesUp
}), this.textView.setKeyBinding(new n.KeyBinding(40, !0, !1, !0), "copyLinesDown"), this.textView.setAction("copyLinesDown", function () {
if (this.textView.getOptions("readonly")) return !1;
var e = this.editor,
t = e.getModel(),
n = e.getSelection(),
r = t.getLineAtOffset(n.start),
i = t.getLineAtOffset(n.end > n.start ? n.end - 1 : n.end),
s = t.getLineStart(r),
o = t.getLineEnd(i, !0),
u = t.getLineCount(),
a = "",
f = t.getText(s, o);
i === u - 1 && (f = (a = t.getLineDelimiter()) + f);
var l = o;
return e.setText(f, l, l), e.setSelection(l + a.length, l + f.length), !0
}.bind(this), {
name: e.copyLinesDown
}), this.textView.setKeyBinding(new n.KeyBinding("d", !0, !1, !1), "deleteLines"), this.textView.setAction("deleteLines", function () {
if (this.textView.getOptions("readonly")) return !1;
var e = this.editor,
t = e.getSelection(),
n = e.getModel(),
r = n.getLineAtOffset(t.start),
i = n.getLineAtOffset(t.end > t.start ? t.end - 1 : t.end),
s = n.getLineStart(r),
o = n.getLineEnd(i, !0);
return e.setText("", s, o), !0
}.bind(this), {
name: e.deleteLines
}), this.textView.setKeyBinding(new n.KeyBinding("l", !0), "gotoLine"), this.textView.setAction("gotoLine", function () {
var t = this.editor,
n = t.getModel(),
r = n.getLineAtOffset(t.getCaretOffset());
return r = prompt(e.gotoLinePrompty, r + 1), r && (r = parseInt(r, 10), t.onGotoLine(r - 1, 0)), !0
}.bind(this), {
name: e.gotoLine
}), this.textView.setKeyBinding(new n.KeyBinding(190, !0), "nextAnnotation"), this.textView.setAction("nextAnnotation", function () {
var e = this.editor,
t = e.getAnnotationModel();
if (!t) return !0;
var n = e.getModel(),
r = e.getCaretOffset(),
o = t.getAnnotations(r, n.getCharCount());
while (o.hasNext()) {
var u = o.next();
if (u.start <= r) continue;
if (u.type !== i.AnnotationType.ANNOTATION_ERROR && u.type !== i.AnnotationType.ANNOTATION_WARNING && u.type !== i.AnnotationType.ANNOTATION_TASK && u.type !== i.AnnotationType.ANNOTATION_BOOKMARK) continue;
var a = s.Tooltip.getTooltip(this.textView);
if (!a) return e.moveSelection(u.start), !0;
var f = n.getLineAtOffset(u.start),
l = this.textView,
c = function () {
setTimeout(function () {
a.setTarget({
getTooltipInfo: function () {
var e = l.convert({
x: l.getLocationAtOffset(u.start).x,
y: l.getLocationAtOffset(n.getLineStart(f)).y
}, "document", "page");
return {
contents: [u],
x: e.x,
y: e.y + Math.floor(l.getLineHeight(f) * 1.33)
}
}
}, 0)
}, 0)
};
e.moveSelection(u.start, u.start, c);
break
}
return !0
}.bind(this), {
name: e.nextAnnotation
}), this.textView.setKeyBinding(new n.KeyBinding(188, !0), "previousAnnotation"), this.textView.setAction("previousAnnotation", function () {
var e = this.editor,
t = e.getAnnotationModel();
if (!t) return !0;
var n = e.getModel(),
r = e.getCaretOffset(),
o = t.getAnnotations(0, r),
u = null;
while (o.hasNext()) {
var a = o.next();
if (a.start >= r) continue;
if (a.type !== i.AnnotationType.ANNOTATION_ERROR && a.type !== i.AnnotationType.ANNOTATION_WARNING && a.type !== i.AnnotationType.ANNOTATION_TASK && a.type !== i.AnnotationType.ANNOTATION_BOOKMARK) continue;
u = a
}
if (u) {
var f = n.getLineAtOffset(u.start),
l = s.Tooltip.getTooltip(this.textView);
if (!l) return e.moveSelection(u.start), !0;
var c = this.textView,
h = function () {
setTimeout(function () {
l.setTarget({
getTooltipInfo: function () {
var e = c.convert({
x: c.getLocationAtOffset(u.start).x,
y: c.getLocationAtOffset(n.getLineStart(f)).y
}, "document", "page");
return {
contents: [u],
x: e.x,
y: e.y + Math.floor(c.getLineHeight(f) * 1.33)
}
}
}, 0)
}, 0)
};
e.moveSelection(u.start, u.start, h)
}
return !0
}.bind(this), {
name: e.prevAnnotation
}), this.textView.setKeyBinding(new n.KeyBinding("e", !0, !1, !0, !1), "expand"), this.textView.setAction("expand", function () {
var e = this.editor,
t = e.getAnnotationModel();
if (!t) return !0;
var n = e.getModel(),
r = e.getCaretOffset(),
s = n.getLineAtOffset(r),
o = n.getLineStart(s),
u = n.getLineEnd(s, !0);
n.getBaseModel && (o = n.mapOffset(o), u = n.mapOffset(u), n = n.getBaseModel());
var a, f = t.getAnnotations(o, u);
while (!a && f.hasNext()) {
var l = f.next();
if (l.type !== i.AnnotationType.ANNOTATION_FOLDING) continue;
if (l.expanded) continue;
a = l
}
return a && !a.expanded && (a.expand(), t.modifyAnnotation(a)), !0
}.bind(this), {
name: e.expand
}), this.textView.setKeyBinding(new n.KeyBinding("c", !0, !1, !0, !1), "collapse"), this.textView.setAction("collapse", function () {
var e = this.editor,
t = e.getAnnotationModel();
if (!t) return !0;
var n = e.getModel(),
r = e.getCaretOffset(),
s = n.getLineAtOffset(r),
o = n.getLineStart(s),
u = n.getLineEnd(s, !0);
n.getBaseModel && (o = n.mapOffset(o), u = n.mapOffset(u), n = n.getBaseModel());
var a, f = t.getAnnotations(o, u);
while (!a && f.hasNext()) {
var l = f.next();
if (l.type !== i.AnnotationType.ANNOTATION_FOLDING) continue;
a = l
}
return a && a.expanded && (e.setCaretOffset(a.start), a.collapse(), t.modifyAnnotation(a)), !0
}.bind(this), {
name: e.collapse
}), this.textView.setKeyBinding(new n.KeyBinding("e", !0, !0, !0, !1), "expandAll"), this.textView.setAction("expandAll", function () {
var e = this.editor,
t = e.getAnnotationModel();
if (!t) return !0;
var n = e.getModel(),
r, s = t.getAnnotations(0, n.getCharCount());
this.textView.setRedraw(!1);
while (s.hasNext()) {
r = s.next();
if (r.type !== i.AnnotationType.ANNOTATION_FOLDING) continue;
r.expanded || (r.expand(), t.modifyAnnotation(r))
}
return this.textView.setRedraw(!0), !0
}.bind(this), {
name: e.expandAll
}), this.textView.setKeyBinding(new n.KeyBinding("c", !0, !0, !0, !1), "collapseAll"), this.textView.setAction("collapseAll", function () {
var e = this.editor,
t = e.getAnnotationModel();
if (!t) return !0;
var n = e.getModel(),
r, s = t.getAnnotations(0, n.getCharCount());
this.textView.setRedraw(!1);
while (s.hasNext()) {
r = s.next();
if (r.type !== i.AnnotationType.ANNOTATION_FOLDING) continue;
r.expanded && (r.collapse(), t.modifyAnnotation(r))
}
return this.textView.setRedraw(!0), !0
}.bind(this), {
name: e.collapseAll
}), this.textView.setKeyBinding(new n.KeyBinding("q", !a.isMac, !1, !1, a.isMac), "lastEdit"), this.textView.setAction("lastEdit", function () {
return typeof this._lastEditLocation == "number" && this.editor.showSelection(this._lastEditLocation), !0
}.bind(this), {
name: e.lastEdit
})
},
toggleIncrementalFind: function () {
this._incrementalFindActive = !this._incrementalFindActive, this._incrementalFindActive ? (this.editor.reportStatus(a.formatMessage(e.incrementalFind, this._incrementalFindPrefix)), this.textView.addEventListener("Verify", this._incrementalFindListener.onVerify), this.textView.addEventListener("Selection", this._incrementalFindListener.onSelection)) : (this._incrementalFindPrefix = "", this.editor.reportStatus(""), this.textView.removeEventListener("Verify", this._incrementalFindListener.onVerify), this.textView.removeEventListener("Selection", this._incrementalFindListener.onSelection), this.textView.setCaretOffset(this.textView.getCaretOffset()))
},
startUndo: function () {
this.undoStack && this.undoStack.startCompoundChange()
},
endUndo: function () {
this.undoStack && this.undoStack.endCompoundChange()
},
cancel: function () {
this.toggleIncrementalFind()
},
isActive: function () {
return this._incrementalFindActive
},
isStatusActive: function () {
return this._incrementalFindActive
},
lineUp: function () {
if (this._incrementalFindActive) {
var t = this._incrementalFindPrefix;
if (t.length === 0) return !1;
var n = this.editor,
r = n.getModel(),
i;
this._incrementalFindSuccess ? i = n.getCaretOffset() - t.length - 1 : i = r.getCharCount() - 1;
var s = n.getModel().find({
string: t,
start: i,
reverse: !0,
caseInsensitive: t.toLowerCase() === t
}).next();
return s ? (this._incrementalFindSuccess = !0, this._incrementalFindIgnoreSelection = !0, n.moveSelection(s.start, s.end), this._incrementalFindIgnoreSelection = !1, n.reportStatus(a.formatMessage(e.incrementalFind, t))) : (n.reportStatus(a.formatMessage(e.incrementalFindNotFound, t), "error"), this._incrementalFindSuccess = !1), !0
}
return !1
},
lineDown: function () {
if (this._incrementalFindActive) {
var t = this._incrementalFindPrefix;
if (t.length === 0) return !1;
var n = this.editor,
r = 0;
this._incrementalFindSuccess && (r = n.getSelection().start + 1);
var i = n.getModel().find({
string: t,
start: r,
caseInsensitive: t.toLowerCase() === t
}).next();
return i ? (this._incrementalFindSuccess = !0, this._incrementalFindIgnoreSelection = !0, n.moveSelection(i.start, i.end), this._incrementalFindIgnoreSelection = !1, n.reportStatus(a.formatMessage(e.incrementalFind, t))) : (n.reportStatus(a.formatMessage(e.incrementalFindNotFound, t), "error"), this._incrementalFindSuccess = !1), !0
}
return !1
},
enter: function () {
return !1
}
}, v.prototype = {
startUndo: function () {
this.undoStack && this.undoStack.startCompoundChange()
},
endUndo: function () {
this.undoStack && this.undoStack.endCompoundChange()
},
init: function () {
function t(e, t, n) {
var r = "/*",
i = "*/",
s = e.getLineAtOffset(t),
o = e.getLineAtOffset(n),
u, a, f, l, c, h, p;
for (u = s; u >= 0; u--) {
a = e.getLine(u), f = u === s ? t - e.getLineStart(s) : a.length, l = a.lastIndexOf(r, f), c = a.lastIndexOf(i, f);
if (c > l) break;
if (l !== -1) {
h = e.getLineStart(u) + l;
break
}
}
for (u = o; u < e.getLineCount(); u++) {
a = e.getLine(u), f = u === o ? n - e.getLineStart(o) : 0, l = a.indexOf(r, f), c = a.indexOf(i, f);
if (l !== -1 && l < c) break;
if (c !== -1) {
p = e.getLineStart(u) + c;
break
}
}
return {
commentStart: h,
commentEnd: p
}
}
this.textView.setAction("lineStart", function () {
var e = this.editor,
t = e.getModel(),
n = e.getCaretOffset(),
r = t.getLineAtOffset(n),
i = t.getLineStart(r),
s = t.getLine(r),
o;
for (o = 0; o < s.length; o++) {
var u = s.charCodeAt(o);
if (u !== 32 && u !== 9) break
}
return o += i, n !== o ? (e.setSelection(o, o), !0) : !1
}.bind(this)), this.textView.setKeyBinding(new n.KeyBinding(191, !0), "toggleLineComment"), this.textView.setAction("toggleLineComment", function () {
if (this.textView.getOptions("readonly")) return !1;
var e = this.editor,
t = e.getModel(),
n = e.getSelection(),
r = t.getLineAtOffset(n.start),
i = t.getLineAtOffset(n.end > n.start ? n.end - 1 : n.end),
s = !0,
o = [],
u, a;
for (var f = r; f <= i; f++) {
u = t.getLine(f, !0), o.push(u);
if (!s || (a = u.indexOf("//")) === -1) s = !1;
else if (a !== 0) {
var l;
for (l = 0; l < a; l++) {
var c = u.charCodeAt(l);
if (c !== 32 && c !== 9) break
}
s = l === a
}
}
var h, p, d, v = t.getLineStart(r),
m = t.getLineEnd(i, !0);
if (s) {
for (var g = 0; g < o.length; g++) u = o[g], a = u.indexOf("//"), o[g] = u.substring(0, a) + u.substring(a + 2);
h = o.join("");
var y = t.getLineStart(i);
p = v === n.start ? n.start : n.start - 2, d = n.end - 2 * (i - r + 1) + (n.end === y + 1 ? 2 : 0)
} else o.splice(0, 0, ""), h = o.join("//"), p = v === n.start ? n.start : n.start + 2, d = n.end + 2 * (i - r + 1);
return e.setText(h, v, m), e.setSelection(p, d), !0
}.bind(this), {
name: e.toggleLineComment
}), this.textView.setKeyBinding(new n.KeyBinding(191, !0, !a.isMac, !1, a.isMac), "addBlockComment"), this.textView.setAction("addBlockComment", function () {
if (this.textView.getOptions("readonly")) return !1;
var e = this.editor,
n = e.getModel(),
r = e.getSelection(),
i = "/*",
s = "*/",
o = new RegExp("/\\*|\\*/", "g"),
u = t(n, r.start, r.end);
if (u.commentStart !== undefined && u.commentEnd !== undefined) return !0;
var a = n.getText(r.start, r.end);
if (a.length === 0) return !0;
var f = a.length;
a = a.replace(o, "");
var l = a.length;
return e.setText(i + a + s, r.start, r.end), e.setSelection(r.start + i.length, r.end + i.length + (l - f)), !0
}.bind(this), {
name: e.addBlockComment
}), this.textView.setKeyBinding(new n.KeyBinding(220, !0, !a.isMac, !1, a.isMac), "removeBlockComment"), this.textView.setAction("removeBlockComment", function () {
if (this.textView.getOptions("readonly")) return !1;
var e = this.editor,
n = e.getModel(),
r = e.getSelection(),
i = "/*",
s = "*/",
o = n.getText(r.start, r.end),
u, a, f;
for (f = 0; f < o.length; f++)
if (o.substring(f, f + i.length) === i) {
u = r.start + f;
break
}
for (; f < o.length; f++)
if (o.substring(f, f + s.length) === s) {
a = r.start + f;
break
}
if (u !== undefined && a !== undefined) e.setText(n.getText(u + i.length, a), u, a + s.length), e.setSelection(u, a);
else {
var l = t(n, r.start, r.end);
if (l.commentStart === undefined || l.commentEnd === undefined) return !0;
var c = n.getText(l.commentStart + i.length, l.commentEnd);
e.setText(c, l.commentStart, l.commentEnd + s.length), e.setSelection(r.start - i.length, r.end - s.length)
}
return !0
}.bind(this), {
name: e.removeBlockComment
})
},
contentAssistProposalApplied: function (e) {
var t = e.data.proposal;
if (t.positions && this.linkedMode) {
var n = [];
for (var r = 0; r < t.positions.length; ++r) n[r] = {
positions: [{
offset: t.positions[r].offset,
length: t.positions[r].length
}]
};
var i = {
groups: n,
escapePosition: t.escapePosition
};
this.linkedMode.enterLinkedMode(i)
} else t.escapePosition && this.textView.setCaretOffset(t.escapePosition);
return !0
},
cancel: function () {
return !1
},
isActive: function () {
return !0
},
isStatusActive: function () {
return !1
},
lineUp: function () {
return !1
},
lineDown: function () {
return !1
},
enter: function () {
if (this.textView.getOptions("readonly")) return !1;
var e = this.editor,
t = e.getSelection();
if (t.start === t.end) {
var n = e.getModel(),
r = n.getLineAtOffset(t.start),
i = n.getLine(r, !0),
s = n.getLineStart(r),
o = 0,
u = t.start - s,
a;
while (o < u && ((a = i.charCodeAt(o)) === 32 || a === 9)) o++;
if (o > 0) {
var f = i.substring(0, o);
o = u;
while (o < i.length && ((a = i.charCodeAt(o++)) === 32 || a === 9)) t.end++;
return e.setText(n.getLineDelimiter() + f, t.start, t.end), !0
}
}
return !1
},
tab: function () {
return !1
}
}, m.prototype = {
enterLinkedMode: function (t) {
if (this.linkedModeActive) return;
this.linkedModeActive = !0, this.linkedModePositions = [];
for (var r = 0; r < t.groups.length; ++r) {
var i = t.groups[r];
this.linkedModePositions[r] = {
offset: i.positions[0].offset,
length: i.positions[0].length
}
}
this.linkedModeEscapePosition = t.escapePosition, this.linkedModeCurrentPositionIndex = 0, this.selectTextForLinkedModePosition(this.linkedModePositions[this.linkedModeCurrentPositionIndex]), this.textView.addEventListener("Verify", this.linkedModeListener.onVerify), this.textView.setKeyBinding(new n.KeyBinding(9), "nextLinkedModePosition"), this.textView.setAction("nextLinkedModePosition", function () {
return this.linkedModeCurrentPositionIndex = ++this.linkedModeCurrentPositionIndex % this.linkedModePositions.length, this.selectTextForLinkedModePosition(this.linkedModePositions[this.linkedModeCurrentPositionIndex]), !0
}.bind(this)), this.textView.setKeyBinding(new n.KeyBinding(9, !1, !0), "previousLinkedModePosition"), this.textView.setAction("previousLinkedModePosition", function () {
return this.linkedModeCurrentPositionIndex = this.linkedModeCurrentPositionIndex > 0 ? this.linkedModeCurrentPositionIndex - 1 : this.linkedModePositions.length - 1, this.selectTextForLinkedModePosition(this.linkedModePositions[this.linkedModeCurrentPositionIndex]), !0
}.bind(this)), this.editor.reportStatus(e.linkedModeEntered, null, !0)
},
isActive: function () {
return this.linkedModeActive
},
isStatusActive: function () {
return this.linkedModeActive
},
enter: function () {
return this.cancel(), !0
},
cancel: function (t) {
if (!this.linkedModeActive) return;
this.linkedModeActive = !1, this.textView.removeEventListener("Verify", this.linkedModeListener.onVerify), this.textView.setKeyBinding(new n.KeyBinding(9), "tab"), this.textView.setKeyBinding(new n.KeyBinding(9, !1, !0), "shiftTab"), t || this.textView.setCaretOffset(this.linkedModeEscapePosition, !1), this.editor.reportStatus(e.linkedModeExited, null, !0)
},
lineUp: function () {
return this.cancel(!0), !1
},
lineDown: function () {
return this.cancel(!0), !1
},
selectTextForLinkedModePosition: function (e) {
this.textView.setSelection(e.offset, e.offset + e.length)
}
}, {
UndoFactory: f,
LineNumberRulerFactory: l,
FoldingRulerFactory: c,
AnnotationFactory: h,
TextDNDFactory: p,
TextActions: d,
SourceCodeActions: v,
LinkedMode: m
}
}),
function (e, t) {
typeof n == "function" && n.amd ? n("orion/Deferred", [], t) : typeof exports == "object" ? module.exports = t() : (e.orion = e.orion || {}, e.orion.Deferred = t())
}(this, function () {
function r() {
var r;
while (r = e.shift() || t.shift()) r();
n = !1
}
function i(i, s) {
var o = s ? t : e;
o.push(i), n || (n = !0, s ? setTimeout(r, 0) : r())
}
function s(e) {
return function () {
e.apply(null, arguments)
}
}
function o() {}
function u() {
var e = new Error("Cancel");
return e.name = "Cancel", e
}
function a() {
function f() {
var r;
while (r = n.shift()) {
var i = r.deferred,
u = t === "resolved" ? "resolve" : "reject";
if (typeof r[u] == "function") try {
var a = r[u](e);
a && typeof a.then == "function" ? (i.cancel = a.cancel || o, a.then(s(i.resolve), s(i.reject), i.progress)) : i.resolve(a)
} catch (f) {
i.reject(f)
} else i[u](e)
}
}
var e, t, n = [],
r = this;
this.reject = function (s, o) {
return t || (t = "rejected", e = s, n.length && i(f)), r.promise
}, this.resolve = function (s, o) {
return t || (t = "resolved", e = s, n.length && i(f)), r.promise
}, this.progress = function (e, i) {
return t || n.forEach(function (t) {
t.progress && t.progress(e)
}), r.promise
}, this.cancel = function () {
t || r.reject(u())
}, this.then = function (e, r, s) {
var o = {
resolve: e,
reject: r,
progress: s,
deferred: new a
}, u = o.deferred,
l = this.cancel.bind(this),
c = function () {
i(function () {
var e = u.cancel === c ? l : u.cancel;
e()
}, !0)
};
u.cancel = c;
var h = u.promise;
return h.cancel = function () {
u.cancel()
}, n.push(o), t && i(f, !0), h
}, this.promise = {
then: this.then,
cancel: this.cancel
}
}
var e = [],
t = [],
n = !1;
return a.all = function (e, t) {
function o(e, t) {
i || (r[e] = t, --n === 0 && s.resolve(r))
}
function u(e, n) {
if (!i) {
if (t) try {
o(e, t(n));
return
} catch (r) {
n = r
}
s.reject(n)
}
}
var n = e.length,
r = [],
i = !1,
s = new a;
return s.then(null, function () {
i = !0, e.forEach(function (e) {
e.cancel && e.cancel()
})
}), n === 0 ? s.resolve(r) : e.forEach(function (e, t) {
e.then(o.bind(null, t), u.bind(null, t))
}), s.promise
}, a.when = function (e, t, n, r) {
var i, s;
return e && typeof e.then == "function" ? i = e : (s = new a, s.resolve(e), i = s.promise), i.then(t, n, r)
}, a
}), n("orion/editor/contentAssist", ["i18n!orion/editor/nls/messages", "orion/editor/keyBinding", "orion/editor/eventTarget", "orion/Deferred", "orion/editor/util"], function (e, t, n, r, i) {
function u(n) {
this.textView = n, this.state = s.INACTIVE, this.providers = [];
var r = this;
this.contentAssistListener = {
onModelChanging: function (e) {
r.isDeactivatingChange(e) ? r.setState(s.INACTIVE) : r.state === s.ACTIVE && r.setState(s.FILTERING)
},
onScroll: function (e) {
r.setState(s.INACTIVE)
},
onSelection: function (e) {
var t = r.state;
if (t === s.ACTIVE || t === s.FILTERING) r.computeProposals(), r.setState(s.FILTERING)
}
}, n.setKeyBinding(i.isMac ? new t.KeyBinding(" ", !1, !1, !1, !0) : new t.KeyBinding(" ", !0), "contentAssist"), n.setAction("contentAssist", function () {
return r.activate(), !0
}, {
name: e.contentAssist
})
}
function a(e, t) {
this.contentAssist = e, this.widget = t, this.proposals = [];
var n = this;
this.contentAssist.addEventListener("ProposalsComputed", function (e) {
n.proposals = e.data.proposals, n.selectedIndex = n.proposals.length ? 0 : -1
})
}
function f(e, t) {
this.contentAssist = e, this.textView = this.contentAssist.getTextView(), this.textViewListenerAdded = !1, this.isShowing = !1;
var n = this.textView.getOptions("parent").ownerDocument;
this.parentNode = typeof t == "string" ? n.getElementById(t) : t;
if (!this.parentNode) {
this.parentNode = i.createElement(n, "div"), this.parentNode.className = "contentassist";
var r = n.getElementsByTagName("body")[0];
if (!r) throw new Error("parentNode is required");
r.appendChild(this.parentNode)
}
var s = this;
this.textViewListener = {
onMouseDown: function (e) {
e.event.target.parentElement !== s.parentNode && s.contentAssist.deactivate()
}
}, this.contentAssist.addEventListener("ProposalsComputed", function (e) {
s.setProposals(e.data.proposals), s.show(), s.textViewListenerAdded || (s.textView.addEventListener("MouseDown", s.textViewListener.onMouseDown), s.textViewListenerAdded = !0)
}), this.contentAssist.addEventListener("Deactivating", function (e) {
s.setProposals([]), s.hide(), s.textViewListenerAdded && (s.textView.removeEventListener("MouseDown", s.textViewListener.onMouseDown), s.textViewListenerAdded = !1), s.textViewListenerAdded = !1
}), this.scrollListener = function (e) {
s.isShowing && s.position()
}, n.addEventListener("scroll", this.scrollListener)
}
var s = {
INACTIVE: 1,
ACTIVE: 2,
FILTERING: 3
}, o = {
selected: " selected",
hr: "proposal-hr",
emphasis: "proposal-emphasis",
noemphasis: "proposal-noemphasis",
dfault: "proposal-default"
};
return u.prototype = {
apply: function (e) {
if (!e) return !1;
var t = this.textView.getCaretOffset(),
n = {
proposal: e,
start: t,
end: t
};
this.setState(s.INACTIVE);
var r = e.proposal || e;
return this.textView.setText(r, t, t), this.dispatchEvent({
type: "ProposalApplied",
data: n
}), !0
},
activate: function () {
this.state === s.INACTIVE && this.setState(s.ACTIVE)
},
deactivate: function () {
this.setState(s.INACTIVE)
},
getTextView: function () {
return this.textView
},
isActive: function () {
return this.state === s.ACTIVE || this.state === s.FILTERING
},
isDeactivatingChange: function (e) {
var t = e.removedCharCount > 0 && e.addedCharCount === 0,
n = this.textView,
r = e.start + 1 <= n.getModel().getCharCount() && /^\s*$/.test(n.getText(e.start, e.start + 1));
return e.removedLineCount > 0 || e.addedLineCount > 0 || t && r
},
setState: function (e) {
var t;
e === s.ACTIVE ? t = "Activating" : e === s.INACTIVE && (t = "Deactivating"), t && this.dispatchEvent({
type: t
}), this.state = e, this.onStateChange(e)
},
onStateChange: function (e) {
e === s.INACTIVE ? this.listenerAdded && (this.textView.removeEventListener("ModelChanging", this.contentAssistListener.onModelChanging), this.textView.removeEventListener("Scroll", this.contentAssistListener.onScroll), this.textView.removeEventListener("Selection", this.contentAssistListener.onSelection), this.listenerAdded = !1) : e === s.ACTIVE && (this.listenerAdded || (this.textView.addEventListener("ModelChanging", this.contentAssistListener.onModelChanging), this.textView.addEventListener("Scroll", this.contentAssistListener.onScroll), this.textView.addEventListener("Selection", this.contentAssistListener.onSelection), this.listenerAdded = !0), this.computeProposals())
},
computeProposals: function () {
var e = this,
t = this.textView.getCaretOffset();
this._computeProposals(t).then(function (t) {
e.dispatchEvent({
type: "ProposalsComputed",
data: {
proposals: t
}
})
})
},
getPrefixStart: function (e) {
var t = e;
while (t > 0 && /[A-Za-z0-9_]/.test(this.textView.getText(t - 1, t))) t--;
return t
},
handleError: function (e) {
typeof console != "undefined" && (console.log("Error retrieving content assist proposals"), console.log(e))
},
_computeProposals: function (e) {
var t = this.providers,
n = this.textView,
i = n.getModel(),
s = n.getText(),
o = {
line: i.getLine(i.getLineAtOffset(e)),
prefix: n.getText(this.getPrefixStart(e), e),
selection: n.getSelection()
}, u = this,
a = t.map(function (t) {
var n = t.computeProposals || t.getProposals,
i;
try {
typeof n == "function" && (i = u.progress ? u.progress.progress(n.apply(t, [s, e, o]), "Generating content assist proposal") : n.apply(t, [s, e, o]))
} catch (a) {
u.handleError(a)
}
return r.when(i)
});
return r.all(a, this.handleError).then(function (e) {
return e.reduce(function (e, t) {
return t instanceof Array ? e.concat(t) : e
}, [])
})
},
setProviders: function (e) {
this.providers = e.slice(0)
},
setProgress: function (e) {
this.progress = e
}
}, n.EventTarget.addMixin(u.prototype), a.prototype = {
cancel: function () {
this.getContentAssist().deactivate()
},
getContentAssist: function () {
return this.contentAssist
},
isActive: function () {
return this.getContentAssist().isActive()
},
lineUp: function () {
var e = this.selectedIndex === 0 ? this.proposals.length - 1 : this.selectedIndex - 1;
while (this.proposals[e].unselectable && e > 0) e--;
return this.selectedIndex = e, this.widget && this.widget.setSelectedIndex(this.selectedIndex), !0
},
lineDown: function () {
var e = this.selectedIndex === this.proposals.length - 1 ? 0 : this.selectedIndex + 1;
while (this.proposals[e].unselectable && e < this.proposals.length - 1) e++;
return this.selectedIndex = e, this.widget && this.widget.setSelectedIndex(this.selectedIndex), !0
},
enter: function () {
var e = this.proposals[this.selectedIndex] || null;
return this.contentAssist.apply(e)
},
tab: function () {
return this.widget ? (this.widget.createAccessible(this), this.widget.parentNode.focus(), !0) : !1
}
}, f.prototype = {
onClick: function (e) {
this.contentAssist.apply(this.getProposal(e.target)), this.textView.focus()
},
createDiv: function (e, t, n, r) {
var s = n.ownerDocument,
o = i.createElement(s, "div");
o.id = "contentoption" + r, o.setAttribute("role", "option");
var u;
e.style === "hr" ? u = i.createElement(s, "hr") : (o.className = this.calculateClasses(e.style, t), u = s.createTextNode(this.getDisplayString(e)), t && this.parentNode.setAttribute("aria-activedescendant", o.id)), o.appendChild(u, o), n.appendChild(o)
},
createAccessible: function (e) {
this._isAccessible || this.parentNode.addEventListener("keydown", function (t) {
return t.preventDefault(), t.keyCode === 27 ? e.cancel() : t.keyCode === 38 ? e.lineUp() : t.keyCode === 40 ? e.lineDown() : t.keyCode === 13 ? e.enter() : !1
}), this._isAccessible = !0
},
calculateClasses: function (e, t) {
var n = o[e];
return n || (n = o.dfault), t ? n + o.selected : n
},
getDisplayString: function (e) {
return typeof e == "string" ? e : e.description && typeof e.description == "string" ? e.description : e.proposal
},
getProposal: function (e) {
var t = 0;
for (var n = this.parentNode.firstChild; n !== null; n = n.nextSibling) {
if (n === e) return this.proposals[t] || null;
t++
}
return null
},
setSelectedIndex: function (e) {
this.selectedIndex = e, this.selectNode(this.parentNode.childNodes[this.selectedIndex])
},
selectNode: function (e) {
var t = this.parentNode.childNodes;
for (var n = 0; n < t.length; n++) {
var r = t[n],
i = r.className.indexOf(o.selected);
i >= 0 && (r.className = r.className.substring(0, i) + r.className.substring(i + o.selected.length)), r === e && (r.className = r.className + o.selected, this.parentNode.setAttribute("aria-activedescendant", r.id), r.focus(), r.offsetTop < this.parentNode.scrollTop ? r.scrollIntoView(!0) : r.offsetTop + r.offsetHeight > this.parentNode.scrollTop + this.parentNode.clientHeight && r.scrollIntoView(!1))
}
},
setProposals: function (e) {
this.proposals = e
},
show: function () {
if (this.proposals.length === 0) {
this.hide();
return
}
this.parentNode.innerHTML = "";
for (var e = 0; e < this.proposals.length; e++) this.createDiv(this.proposals[e], e === 0, this.parentNode, e);
this.position(), this.parentNode.onclick = this.onClick.bind(this), this.isShowing = !0
},
hide: function () {
this.parentNode.ownerDocument.activeElement === this.parentNode && this.textView.focus(), this.parentNode.style.display = "none", this.parentNode.onclick = null, this.isShowing = !1
},
position: function () {
var e = this.textView.getLocationAtOffset(this.textView.getCaretOffset());
e.y += this.textView.getLineHeight(), this.textView.convert(e, "document", "page"), this.parentNode.style.position = "fixed", this.parentNode.style.left = e.x + "px", this.parentNode.style.top = e.y + "px", this.parentNode.style.display = "block", this.parentNode.scrollTop = 0;
var t = this.parentNode.ownerDocument,
n = t.documentElement.clientWidth,
r = t.documentElement.clientHeight;
e.y + this.parentNode.offsetHeight > r && (this.parentNode.style.top = e.y - this.parentNode.offsetHeight - this.textView.getLineHeight() + "px"), e.x + this.parentNode.offsetWidth > n && (this.parentNode.style.left = n - this.parentNode.offsetWidth + "px")
}
}, {
ContentAssist: u,
ContentAssistMode: a,
ContentAssistWidget: f
}
}), n("orion/editor/cssContentAssist", [], function () {
function t(e, t) {
var n = t;
while (n && /[A-Za-z\-]/.test(e.charAt(n - 1))) n--;
return n ? e.substring(n, t) : ""
}
function n() {}
var e = ["alignment-adjust", "alignment-baseline", "animation", "animation-delay", "animation-direction", "animation-duration", "animation-iteration-count", "animation-name", "animation-play-state", "animation-timing-function", "appearance", "azimuth", "backface-visibility", "background", "background-attachment", "background-clip", "background-color", "background-image", "background-origin", "background-position", "background-repeat", "background-size", "baseline-shift", "binding", "bleed", "bookmark-label", "bookmark-level", "bookmark-state", "bookmark-target", "border", "border-bottom", "border-bottom-color", "border-bottom-left-radius", "border-bottom-right-radius", "border-bottom-style", "border-bottom-width", "border-collapse", "border-color", "border-image", "border-image-outset", "border-image-repeat", "border-image-slice", "border-image-source", "border-image-width", "border-left", "border-left-color", "border-left-style", "border-left-width", "border-radius", "border-right", "border-right-color", "border-right-style", "border-right-width", "border-spacing", "border-style", "border-top", "border-top-color", "border-top-left-radius", "border-top-right-radius", "border-top-style", "border-top-width", "border-width", "bottom", "box-align", "box-decoration-break", "box-direction", "box-flex", "box-flex-group", "box-lines", "box-ordinal-group", "box-orient", "box-pack", "box-shadow", "box-sizing", "break-after", "break-before", "break-inside", "caption-side", "clear", "clip", "color", "color-profile", "column-count", "column-fill", "column-gap", "column-rule", "column-rule-color", "column-rule-style", "column-rule-width", "column-span", "column-width", "columns", "content", "counter-increment", "counter-reset", "crop", "cue", "cue-after", "cue-before", "cursor", "direction", "display", "dominant-baseline", "drop-initial-after-adjust", "drop-initial-after-align", "drop-initial-before-adjust", "drop-initial-before-align", "drop-initial-size", "drop-initial-value", "elevation", "empty-cells", "fit", "fit-position", "flex-align", "flex-flow", "flex-inline-pack", "flex-order", "flex-pack", "float", "float-offset", "font", "font-family", "font-size", "font-size-adjust", "font-stretch", "font-style", "font-variant", "font-weight", "grid-columns", "grid-rows", "hanging-punctuation", "height", "hyphenate-after", "hyphenate-before", "hyphenate-character", "hyphenate-lines", "hyphenate-resource", "hyphens", "icon", "image-orientation", "image-rendering", "image-resolution", "inline-box-align", "left", "letter-spacing", "line-height", "line-stacking", "line-stacking-ruby", "line-stacking-shift", "line-stacking-strategy", "list-style", "list-style-image", "list-style-position", "list-style-type", "margin", "margin-bottom", "margin-left", "margin-right", "margin-top", "mark", "mark-after", "mark-before", "marker-offset", "marks", "marquee-direction", "marquee-loop", "marquee-play-count", "marquee-speed", "marquee-style", "max-height", "max-width", "min-height", "min-width", "move-to", "nav-down", "nav-index", "nav-left", "nav-right", "nav-up", "opacity", "orphans", "outline", "outline-color", "outline-offset", "outline-style", "outline-width", "overflow", "overflow-style", "overflow-x", "overflow-y", "padding", "padding-bottom", "padding-left", "padding-right", "padding-top", "page", "page-break-after", "page-break-before", "page-break-inside", "page-policy", "pause", "pause-after", "pause-before", "perspective", "perspective-origin", "phonemes", "pitch", "pitch-range", "play-during", "position", "presentation-level", "punctuation-trim", "quotes", "rendering-intent", "resize", "rest", "rest-after", "rest-before", "richness", "right", "rotation", "rotation-point", "ruby-align", "ruby-overhang", "ruby-position", "ruby-span", "size", "speak", "speak-header", "speak-numeral", "speak-punctuation", "speech-rate", "stress", "string-set", "table-layout", "target", "target-name", "target-new", "target-position", "text-align", "text-align-last", "text-decoration", "text-emphasis", "text-height", "text-indent", "text-justify", "text-outline", "text-shadow", "text-transform", "text-wrap", "top", "transform", "transform-origin", "transform-style", "transition", "transition-delay", "transition-duration", "transition-property", "transition-timing-function", "unicode-bidi", "vertical-align", "visibility", "voice-balance", "voice-duration", "voice-family", "voice-pitch", "voice-pitch-range", "voice-rate", "voice-stress", "voice-volume", "volume", "white-space", "white-space-collapse", "widows", "width", "word-break", "word-spacing", "word-wrap", "z-index"];
return n.prototype = {
computeProposals: function (n, r, i) {
var s = t(n, r),
o = [];
for (var u = 0; u < e.length; u++) {
var a = e[u];
a.indexOf(s) === 0 && o.push({
proposal: a.substring(s.length),
description: a
})
}
return o
}
}, {
CssContentAssistProvider: n
}
}), n("orion/editor/htmlContentAssist", [], function () {
function e() {}
return e.prototype = {
leadingWhitespace: function (e, t) {
var n = "";
t -= 1;
while (t > 0) {
var r = e.charAt(t--);
if (r === "\n" || r === "\r") break;
/\s/.test(r) ? n = r.concat(n) : n = ""
}
return n
},
computeProposals: function (e, t, n) {
function r(e) {
return e.substring(n.prefix.length)
}
var i = [];
if (e.length === 0) {
var s = '<!DOCTYPE html>\n<html lang="en">\n <head>\n <meta charset=utf-8>\n <title>My Document</title>\n </head>\n <body>\n <h1>A basic HTML document</h1>\n <p>\n \n </p>\n </body>\n</html>';
return i.push({
proposal: s,
description: "Simple HTML document",
escapePosition: t + 152
}), i
}
var o = n.prefix,
u = e.charAt(t - o.length - 1);
if (u !== "<") return i;
var a, f, l, c, h = ["abbr", "b", "button", "canvas", "cite", "command", "dd", "del", "dfn", "dt", "em", "embed", "font", "h1", "h2", "h3", "h4", "h5", "h6", "i", "ins", "kbd", "label", "li", "mark", "meter", "object", "option", "output", "progress", "q", "rp", "rt", "samp", "small", "strong", "sub", "sup", "td", "time", "title", "tt", "u", "var"];
for (var p = 0; p < h.length; p++) a = h[p], a.indexOf(o) === 0 && (f = a + "></" + a + ">", c = t + a.length - o.length + 1, i.push({
proposal: r(f),
description: "<" + f,
escapePosition: c
}));
var d = ["address", "article", "aside", "audio", "bdo", "blockquote", "body", "caption", "code", "colgroup", "datalist", "details", "div", "fieldset", "figure", "footer", "form", "head", "header", "hgroup", "iframe", "legend", "map", "menu", "nav", "noframes", "noscript", "optgroup", "p", "pre", "ruby", "script", "section", "select", "span", "style", "tbody", "textarea", "tfoot", "th", "thead", "tr", "video"],
v = this.leadingWhitespace(e, t);
for (p = 0; p < d.length; p++) a = d[p], a.indexOf(o) === 0 && (f = a + ">\n" + v + " \n" + v + "</" + a + ">", c = t + a.length - o.length + v.length + 3, i.push({
proposal: r(f),
description: "<" + f,
escapePosition: c
}));
var m = ["area", "base", "br", "col", "hr", "input", "link", "meta", "param", "keygen", "source"];
for (p = 0; p < m.length; p++) a = m[p], a.indexOf(o) === 0 && (f = a + "/>", c = t + a.length - o.length + 2, i.push({
proposal: r(f),
description: "<" + f,
escapePosition: c
}));
return "img".indexOf(o) === 0 && (f = 'img src="" alt="Image"/>', i.push({
proposal: r(f),
description: "<" + f,
escapePosition: t + 9 - o.length
})), o === "a" && i.push({
proposal: r('a href=""></a>'),
description: "<a></a> - HTML anchor element",
escapePosition: t + 7
}), "ul".indexOf(o) === 0 && (f = "ul>\n" + v + " <li></li>\n" + v + "</ul>", l = "<ul> - unordered list", c = t - o.length + v.length + 9, i.push({
proposal: r(f),
description: l,
escapePosition: c
})), "ol".indexOf(o) === 0 && (f = "ol>\n" + v + " <li></li>\n" + v + "</ol>", l = "<ol> - ordered list", c = t - o.length + v.length + 9, i.push({
proposal: r(f),
description: l,
escapePosition: c
})), "dl".indexOf(o) === 0 && (f = "dl>\n" + v + " <dt></dt>\n" + v + " <dd></dd>\n" + v + "</dl>", l = "<dl> - definition list", c = t - o.length + v.length + 9, i.push({
proposal: r(f),
description: l,
escapePosition: c
})), "table".indexOf(o) === 0 && (f = "table>\n" + v + " <tr>\n" + v + " <td></td>\n" + v + " </tr>\n" + v + "</table>", l = "<table> - basic HTML table", c = t - o.length + v.length * 2 + 19, i.push({
proposal: r(f),
description: l,
escapePosition: c
})), i
}
}, {
HTMLContentAssistProvider: e
}
}), n("orion/editor/jsTemplateContentAssist", [], function () {
function e(e, t) {
var n = "";
t -= 1;
while (t > 0) {
var r = e.charAt(t--);
if (r === "\n" || r === "\r") break;
/\s/.test(r) ? n = r.concat(n) : n = ""
}
return n
}
function t(e, t) {
var n = "";
while (t >= 0) {
n = e[t];
if (n === "\n" || n === "\r") break;
if (!/\s/.test(n)) break;
t--
}
return n
}
function r(e, r, i) {
var s = t(r, i - e.length - 1);
return !n[s]
}
function i(e, t) {
return t.substring(e.length)
}
function s(t, n, r) {
var s = r - t.length,
o = [],
u = e(n, r),
a, f, l, c;
return "if".indexOf(t) === 0 && (a = "if (condition) {\n" + u + " \n" + u + "}", f = "if - if statement", l = [{
offset: s + 4,
length: 9
}], c = s + u.length + 18, o.push({
proposal: i(t, a),
description: f,
positions: l,
escapePosition: c
}), a = "if (condition) {\n" + u + " \n" + u + "} else {\n" + u + " \n" + u + "}", f = "if - if else statement", l = [{
offset: s + 4,
length: 9
}], c = s + u.length + 18, o.push({
proposal: i(t, a),
description: f,
positions: l,
escapePosition: c
})), "for".indexOf(t) === 0 && (a = "for (var i = 0; i < array.length; i++) {\n" + u + " \n" + u + "}", f = "for - iterate over array", l = [{
offset: s + 9,
length: 1
}, {
offset: s + 20,
length: 5
}], c = s + u.length + 42, o.push({
proposal: i(t, a),
description: f,
positions: l,
escapePosition: c
}), a = "for (var property in object) {\n" + u + " if (object.hasOwnProperty(property)) {\n" + u + " \n" + u + " }\n" + u + "}", f = "for..in - iterate over properties of an object", l = [{
offset: s + 9,
length: 8
}, {
offset: s + 21,
length: 6
}], c = s + 2 * u.length + 73, o.push({
proposal: i(t, a),
description: f,
positions: l,
escapePosition: c
})), "while".indexOf(t) === 0 && (a = "while (condition) {\n" + u + " \n" + u + "}", f = "while - while loop with condition", l = [{
offset: s + 7,
length: 9
}], c = s + u.length + 21, o.push({
proposal: i(t, a),
description: f,
positions: l,
escapePosition: c
})), "do".indexOf(t) === 0 && (a = "do {\n" + u + " \n" + u + "} while (condition);", f = "do - do while loop with condition", l = [{
offset: s + 16,
length: 9
}], c = s + u.length + 6, o.push({
proposal: i(t, a),
description: f,
positions: l,
escapePosition: c
})), "switch".indexOf(t) === 0 && (a = "switch (expression) {\n" + u + " case value1:\n" + u + " \n" + u + " break;\n" + u + " default:\n" + u + "}", f = "switch - switch case statement", l = [{
offset: s + 8,
length: 10
}, {
offset: s + 28,
length: 6
}], c = s + 2 * u.length + 38, o.push({
proposal: i(t, a),
description: f,
positions: l,
escapePosition: c
})), "try".indexOf(t) === 0 && (a = "try {\n" + u + " \n" + u + "} catch (err) {\n" + u + "}", f = "try - try..catch statement", c = s + u.length + 7, o.push({
proposal: i(t, a),
description: f,
escapePosition: c
}), a = "try {\n" + u + " \n" + u + "} catch (err) {\n" + u + "} finally {\n" + u + "}", f = "try - try..catch statement with finally block", c = s + u.length + 7, o.push({
proposal: i(t, a),
description: f,
escapePosition: c
})), o
}
function o(e, t, n) {
var r = ["break", "case", "catch", "continue", "debugger", "default", "delete", "do", "else", "finally", "for", "function", "if", "in", "instanceof", "new", "return", "switch", "this", "throw", "try", "typeof", "var", "void", "while", "with"],
s = [];
for (var o = 0; o < r.length; o++) r[o].indexOf(e) === 0 && s.push({
proposal: i(e, r[o]),
description: r[o]
});
return s
}
function u() {}
var n = {
":": ":",
"!": "!",
"@": "@",
"#": "#",
$: "$",
"^": "^",
"&": "&",
"*": "*",
".": ".",
"?": "?",
"<": "<",
">": ">"
};
return u.prototype = {
computeProposals: function (e, t, n) {
var i = n.prefix,
u = [];
return r(i, e, t) ? (u = u.concat(s(i, e, t)), u = u.concat(o(i, e, t)), u) : u
}
}, {
JSTemplateContentAssistProvider: u
}
}), n("orion/editor/AsyncStyler", ["i18n!orion/editor/nls/messages", "orion/editor/annotations"], function (e, t) {
function s(e) {
return e.getProperty("objectClass").indexOf(n) !== -1 && e.getProperty("type") === "highlighter"
}
function o(e, t, n) {
this.initialize(e, t, n), this.lineStyles = []
}
var n = "orion.edit.highlighter",
r = "orion.annotation.highlightError",
i = n + " service must be an event emitter";
return t.AnnotationType.registerType(r, {
title: e.syntaxError,
html: "<div class='annotationHTML error'></div>",
rangeStyle: {
styleClass: "annotationRange error"
}
}), o.prototype = {
initialize: function (e, t, r) {
this.textView = e, this.serviceRegistry = t, this.annotationModel = r, this.services = [];
var i = this;
this.listener = {
onModelChanging: function (e) {
i.onModelChanging(e)
},
onModelChanged: function (e) {
i.onModelChanged(e)
},
onDestroy: function (e) {
i.onDestroy(e)
},
onLineStyle: function (e) {
i.onLineStyle(e)
},
onStyleReady: function (e) {
i.onStyleReady(e)
},
onServiceAdded: function (e) {
i.onServiceAdded(e.serviceReference, i.serviceRegistry.getService(e.serviceReference))
},
onServiceRemoved: function (e) {
i.onServiceRemoved(e.serviceReference, i.serviceRegistry.getService(e.serviceReference))
}
}, e.addEventListener("ModelChanging", this.listener.onModelChanging), e.addEventListener("ModelChanged", this.listener.onModelChanged), e.addEventListener("Destroy", this.listener.onDestroy), e.addEventListener("LineStyle", this.listener.onLineStyle), t.addEventListener("registered", this.listener.onServiceAdded), t.addEventListener("unregistering", this.listener.onServiceRemoved);
var o = t.getServiceReferences(n);
for (var u = 0; u < o.length; u++) {
var a = o[u];
s(a) && this.addServiceListener(t.getService(a))
}
},
onDestroy: function (e) {
this.destroy()
},
destroy: function () {
this.textView && (this.textView.removeEventListener("ModelChanging", this.listener.onModelChanging), this.textView.removeEventListener("ModelChanged", this.listener.onModelChanged), this.textView.removeEventListener("Destroy", this.listener.onDestroy), this.textView.removeEventListener("LineStyle", this.listener.onLineStyle), this.textView = null);
if (this.services) {
for (var e = 0; e < this.services.length; e++) this.removeServiceListener(this.services[e]);
this.services = null
}
this.serviceRegistry && (this.serviceRegistry.removeEventListener("registered", this.listener.onServiceAdded), this.serviceRegistry.removeEventListener("unregistering", this.listener.onServiceRemoved), this.serviceRegistry = null), this.listener = null, this.lineStyles = null
},
onModelChanging: function (e) {
this.startLine = this.textView.getModel().getLineAtOffset(e.start)
},
onModelChanged: function (e) {
var t = this.startLine;
(e.addedLineCount || e.removedLineCount) && Array.prototype.splice.apply(this.lineStyles, [t, e.removedLineCount].concat(this._getEmptyStyle(e.addedLineCount)))
},
onStyleReady: function (e) {
var n = e.lineStyles || e.style,
i = Number.MAX_VALUE,
s = -1,
o = this.textView.getModel();
for (var u in n) n.hasOwnProperty(u) && (this.lineStyles[u] = n[u], i = Math.min(i, u), s = Math.max(s, u));
i = Math.max(i, 0), s = Math.min(s, o.getLineCount());
var a = this.annotationModel;
if (a) {
var f = a.getAnnotations(o.getLineStart(i), o.getLineEnd(s)),
l = [];
while (f.hasNext()) {
var c = f.next();
c.type === r && l.push(c)
}
var h = [];
for (var p = i; p <= s; p++) {
u = p;
var d = this.lineStyles[u],
v = d && d.errors,
m = o.getLineStart(u);
if (v)
for (var g = 0; g < v.length; g++) {
var y = v[g];
h.push(t.AnnotationType.createAnnotation(r, y.start + m, y.end + m))
}
}
a.replaceAnnotations(l, h)
}
this.textView.redrawLines(i, s + 1)
},
onLineStyle: function (e) {
function t(e, t) {
var n = e.length,
r = [];
for (var i = 0; i < n; i++) {
var s = e[i];
r.push({
start: s.start + t,
end: s.end + t,
style: s.style
})
}
return r
}
var n = this.lineStyles[e.lineIndex];
n && (n.ranges ? e.ranges = t(n.ranges, e.lineStart) : n.style && (e.style = n.style))
},
_getEmptyStyle: function (e) {
var t = [];
for (var n = 0; n < e; n++) t.push(null);
return t
},
setContentType: function (e) {
this.contentType = e;
if (this.services)
for (var t = 0; t < this.services.length; t++) {
var n = this.services[t];
if (n.setContentType) {
var r = this.serviceRegistry.getService("orion.page.progress");
r ? r.progress(n.setContentType(this.contentType), "Styling content type: " + this.contentType.id ? this.contentType.id : this.contentType) : n.setContentType(this.contentType)
}
}
},
onServiceAdded: function (e, t) {
s(e) && this.addServiceListener(t)
},
onServiceRemoved: function (e, t) {
this.services.indexOf(t) !== -1 && this.removeServiceListener(t)
},
addServiceListener: function (e) {
if (typeof e.addEventListener == "function") {
e.addEventListener("orion.edit.highlighter.styleReady", this.listener.onStyleReady), this.services.push(e);
if (e.setContentType && this.contentType) {
var t = this.serviceRegistry.getService("orion.page.progress");
t ? t.progress(e.setContentType(this.contentType), "Styling content type: " + this.contentType.id ? this.contentType.id : this.contentType) : e.setContentType(this.contentType)
}
} else typeof console != "undefined" && console.log(new Error(i))
},
removeServiceListener: function (e) {
if (typeof e.removeEventListener == "function") {
e.removeEventListener("orion.edit.highlighter.styleReady", this.listener.onStyleReady);
var t = this.services.indexOf(e);
t !== -1 && this.services.splice(t, 1)
} else typeof console != "undefined" && console.log(new Error(i))
}
}, o
}), n("orion/editor/mirror", ["i18n!orion/editor/nls/messages", "orion/editor/eventTarget", "orion/editor/annotations"], function (e, t, n) {
function i(e) {
this.string = e, this.pos = 0, this.tokenStart = 0
}
function s(e) {
this._modes = {}, this.mimeModes = {}, this.options = {}, this.StringStream = i
}
function o(e) {
var t = [];
for (var n in e) Object.prototype.hasOwnProperty.call(e, n) && t.push(n);
return t
}
function u(e, t, n) {
n = n || {}, this.model = e, this.codeMirror = t, this.isWhitespaceVisible = typeof n.whitespacesVisible == "undefined" ? !1 : n.whitespacesVisible, this.mode = null, this.isModeLoaded = !1, this.lines = [], this.dirtyLines = [], this.startLine = Number.MAX_VALUE, this.endLine = -1, this.timer = null, this.initialize(e)
}
function v(e, t, n) {
this.init(e, t, n)
}
var r = 4;
i.prototype = {
eol: function () {
return this.pos >= this.string.length
},
sol: function () {
return this.pos === 0
},
peek: function () {
return this.string[this.pos]
},
next: function () {
return this.string[this.pos++]
},
eat: function (e) {
var t = this.string[this.pos],
n = typeof t == "string" && (t === e || e.test && e.test(t) || typeof e == "function" && e(t));
return n ? this.string[this.pos++] : undefined
},
eatWhile: function (e) {
var t = !1;
while (this.eat(e) !== undefined) t = !0;
return t
},
eatSpace: function () {
return this.eatWhile(/\s/)
},
skipToEnd: function () {
this.pos = this.string.length
},
skipTo: function (e) {
var t = this.string.indexOf(e, this.pos);
return t !== -1 ? (this.pos = t, !0) : !1
},
match: function (e, t, n) {
t = t === !0 || typeof t == "undefined";
if (typeof e == "string") {
var r = n ? this.string.toLowerCase() : this.string;
e = n ? e.toLowerCase() : e;
var i = r.indexOf(e, this.pos);
return i !== -1 && t && (this.pos = i + e.length), i !== -1
}
var s = this.string.substring(this.pos).match(e);
return s && t && typeof s[0] == "string" && (this.pos += s.index + s[0].length), s
},
backUp: function (e) {
this.pos -= e
},
column: function () {
var e = 0,
t = 0;
while (t < this.tokenStart) e += this.string[t++] === " " ? r : 1;
return e
},
indentation: function () {
var e = this.string.search(/\S/),
t = 0,
n = 0;
while (n < e) t += this.string[n++] === " " ? r : 1;
return t
},
current: function () {
return this.string.substring(this.tokenStart, this.pos)
},
advance: function () {
this.tokenStart = this.pos
}
}, s.prototype = {
options: {},
setOption: function (e, t) {
this.options[e] = t
},
getOption: function (e) {
return this.options[e]
},
copyState: function (e, t) {
if (typeof e.copyState == "function") return e.copyState(t);
var n = {};
for (var r in t) {
var i = t[r];
n[r] = i instanceof Array ? i.slice() : i
}
return n
},
defineMode: function (e, t) {
this._modes[e] = t
},
defineMIME: function (e, t) {
this.mimeModes[e] = t
},
getMode: function (e, t) {
var n = {}, r;
typeof t == "string" && this.mimeModes[t] && (t = this.mimeModes[t]), typeof t == "object" && (n = t, r = this._modes[t.name]), r = r || this._modes[t];
if (typeof r != "function") throw "Mode not found " + t;
return r(e, n)
},
listModes: function () {
return o(this._modes)
},
listMIMEs: function () {
return o(this.mimeModes)
},
_getModeName: function (e) {
var t = this.mimeModes[e];
return typeof t == "object" && (t = t.name), t
}
};
var a = "token_tab",
f = "token_space",
l = 500,
c = 50,
h = 30,
p = 3,
d = 40;
u.prototype = {
initialize: function (e) {
var t = this;
this.listener = {
onModelChanging: function (e) {
t._onModelChanging(e)
},
onModelChanged: function (e) {
t._onModelChanged(e)
},
onDestroy: function (e) {
t._onDestroy(e)
}
}, this.model.addEventListener("Changing", this.listener.onModelChanging), this.model.addEventListener("Changed", this.listener.onModelChanged), this.model.addEventListener("Destroy", this.listener.onDestroy)
},
destroy: function () {
this.model && (this.model.removeEventListener("Changing", this.listener.onModelChanging), this.model.removeEventListener("Changed", this.listener.onModelChanged), this.model.removeEventListener("Destroy", this.listener.onDestroy)), this.model = null, this.codeMirror = null, this.mode = null, this.lines = null, this.dirtyLines = null, clearTimeout(this.timer), this.timer = null
},
_onModelChanging: function (e) {
this.startLine = this.model.getLineAtOffset(e.start)
},
_onModelChanged: function (e) {
this._dbgEvent(e);
var t = this.startLine;
(e.removedLineCount || e.addedLineCount) && Array.prototype.splice.apply(this.lines, [t + 1, e.removedLineCount].concat(this._newLines(e.addedLineCount)));
if (!this.mode) return;
var n = Math.max(e.addedLineCount, e.removedLineCount),
r = t + Math.min(n, l);
this.highlight(t, r), this.highlightLater(r + 1)
},
_onDestroy: function (e) {
this.destroy()
},
setViewportIndex: function (e) {
this.viewportIndex = e
},
_dbgEvent: function (e) {},
_dbgStyle: function () {},
_newLines: function (e, t) {
typeof t == "undefined" && (t = 0);
var n = [];
for (var r = 0; r < e; r++) n.push({
style: null,
eolState: null
});
return n
},
setMode: function (e, t) {
if (!e) return;
this.mode = this.codeMirror.getMode(this.codeMirror.options, e), this.lines = this._newLines(this.model.getLineCount()), t && this.highlight()
},
highlight: function (e, t, n) {
if (!this.mode) return;
var r = this.model.getLineCount();
e = typeof e == "undefined" ? 0 : e, t = typeof t == "undefined" ? r - 1 : Math.min(t, r - 1);
var i = this.mode,
s = this.getState(e);
for (var o = e; o <= t; o++) {
var u = this.lines[o];
this.highlightLine(o, u, s), u.eolState = this.codeMirror.copyState(i, s)
}
this._expandRange(e, t), n || this.onHighlightDone()
},
highlightLater: function (e) {
this.dirtyLines.push(e);
var t = this;
this.timer = setTimeout(function () {
t._highlightJob()
}, c)
},
_highlightJob: function () {
var e = +(new Date) + h,
t = this.mode.compareStates,
n = this.model.getLineCount();
while (this.dirtyLines.length) {
var r = this.viewportIndex,
i = this.lines[r],
s;
i && !i.eolState ? s = r : s = this.dirtyLines.pop();
if (s >= n) break;
this._expandRange(s, s);
var o = this._getResumeLineIndex(s),
u = o + 1,
a = o >= 0 && this.lines[o].eolState;
a = a ? this.codeMirror.copyState(this.mode, a) : this.mode.startState();
var f = 0;
for (var l = u; l < n; l++) {
var c = this.lines[l],
d = c.eolState,
v = this.highlightLine(l, c, a);
c.eolState = this.codeMirror.copyState(this.mode, a), v && this._expandRange(u, l + 1);
var m = t && d && t(d, c.eolState),
g = !t && !v && f++ > p;
if (m || g) break;
if (!d || v) f = 0;
var y = l < n || this.dirtyLines.length,
b = +(new Date) > e && y;
if (b) {
this.highlightLater(l + 1), this.onHighlightDone();
return
}
}
}
this.onHighlightDone()
},
onHighlightDone: function () {
this.startLine !== Number.MAX_VALUE && this.endLine !== -1 && this.dispatchEvent({
type: "Highlight",
start: this.startLine,
end: this.endLine
}), this.startLine = Number.MAX_VALUE, this.endLine = -1
},
_getResumeLineIndex: function (e) {
var t = this.lines;
for (var n = e - 1; n >= 0; n--)
if (t[n].eolState || e - n > d) return n;
return -1
},
getState: function (e) {
var t = this.mode,
n = this.lines,
r, i;
for (r = e - 1; r >= 0; r--) {
i = n[r];
if (i.eolState || e - r > d) break
}
var s = r >= 0 && n[r].eolState;
if (s) {
s = this.codeMirror.copyState(t, s), r = Math.max(0, r);
for (var o = r; o < e - 1; o++) i = n[o], this.highlightLine(o, i, s), i.eolState = this.codeMirror.copyState(t, s);
return s
}
return t.startState()
},
highlightLine: function (e, t, n) {
if (!this.mode) return;
var r = this.model;
r.getLineStart(e) === r.getLineEnd(e) && this.mode.blankLine && this.mode.blankLine(n);
var s = t.style || [],
o = r.getLine(e),
u = new i(o),
a = !t.style,
f = [],
l;
for (var c = 0; !u.eol(); c++) {
var h = this.mode.token(u, n) || null,
p = u.current();
l = this._whitespaceStyle(h, p, u.tokenStart), l;
var d = [u.tokenStart, u.pos, h],
v = s[c];
f.push(d), a = a || !v || v[0] !== d[0] || v[1] !== d[1] || v[2] !== d[2], u.advance()
}
return a = a || f.length !== s.length, a && (t.style = f.length ? f : null), a
},
_whitespaceStyle: function (e, t, n) {
if (!e && this.isWhitespaceVisible && /\s+/.test(t)) {
var r = [],
i, s;
for (var o = 0; o < t.length; o++) {
var u = t[o];
u !== s && (s && r.push([n + i, n + o, s === " " ? a : f]), i = o, s = u)
}
return r.push([n + i, n + o, s === " " ? a : f]), r
}
return null
},
_expandRange: function (e, t) {
this.startLine = Math.min(this.startLine, e), this.endLine = Math.max(this.endLine, t)
},
toStyleRangesAndErrors: function (e, t) {
function n(e) {
return e ? e === a || e === f ? e : "cm-" + e : null
}
var r = e.style;
if (!r) return null;
var i = [],
s = [],
o = typeof t == "undefined" ? 0 : this.model.getLineStart(t);
for (var u = 0; u < r.length; u++) {
var l = r[u],
c = n(l[2]);
if (!c) continue;
var h = {
start: o + l[0],
end: o + l[1],
style: {
styleClass: c
}
};
i.push(h), c === "cm-error" && s.push(h)
}
return [i, s]
},
getLineStyle: function (e) {
return this.lines[e]
},
getLineStyles: function () {
return this.lines
}
}, t.EventTarget.addMixin(u.prototype);
var m = 20,
g = "orion.annotation.highlightError";
return n.AnnotationType.registerType(g, {
title: e.syntaxError,
html: "<div class='annotationHTML error'></div>",
rangeStyle: {
styleClass: "annotationRange error"
}
}), v.prototype = {
init: function (e, t, n) {
this.textView = e, this.annotationModel = n, this.modeApplier = new u(e.getModel(), t);
var r = this;
this.listener = {
onLineStyle: function (e) {
r.onLineStyle(e)
},
onDestroy: function (e) {
r.onDestroy(e)
},
onHighlight: function (e) {
r.onHighlight(e)
}
}, e.addEventListener("LineStyle", this.listener.onLineStyle), e.addEventListener("Destroy", this.listener.onDestroy), this.modeApplier.addEventListener("Highlight", this.listener.onHighlight)
},
destroy: function () {
this.modeApplier && (this.modeApplier.removeEventListener("Highlight", this.listener.onHighlight), this.modeApplier.destroy()), this.annotationModel, this.textView && (this.textView.removeEventListener("LineStyle", this.listener.onLineStyle), this.textView.removeEventListener("Destroy", this.listener.onDestroy)), this.textView = null, this.annotationModel = null, this.modeApplier = null, this.listener = null
},
setMode: function (e) {
this.modeApplier.setMode(e)
},
onLineStyle: function (e) {
var t = e.lineIndex,
r = this.modeApplier,
i = r.getLineStyle(t);
if (!i || !i.eolState) {
var s = this.textView.getModel().getLineCount();
r.highlight(t, Math.min(t + m, s - 1), !0), i = r.getLineStyle(t)
}
var o = this.textView.getModel();
if (i) {
var u = r.toStyleRangesAndErrors(i, t);
if (u) {
e.ranges = u[0];
var a = this.annotationModel;
if (a) {
var f = [],
l = [],
c = u[1];
if (c)
for (var h = 0; h < c.length; h++) {
var p = c[h];
p.style.styleClass === "cm-error" && l.push(n.AnnotationType.createAnnotation(g, p.start, p.end))
}
var d = a.getAnnotations(o.getLineStart(t), o.getLineEnd(t));
while (d.hasNext()) {
var v = d.next();
v.type === g && f.push(v)
}
a.replaceAnnotations(f, l)
}
}
}
},
onHighlight: function (e) {
var t = e.start,
n = e.end;
this.textView.redrawLines(t, n)
},
onDestroy: function (e) {
this.destroy()
}
}, {
Mirror: s,
ModeApplier: u,
CodeMirrorStyler: v
}
}), n("orion/editor/textMateStyler", ["orion/editor/regex"], function (e) {
function n(e, t, n) {
var r = "",
i = t.textView._parent,
s = i.ownerDocument,
o = t._stylesheet = t.util.createElement(s, "style");
o.appendChild(s.createTextNode(t._styleSheet(e, r, t.util)));
var u = s.getElementsByTagName("head")[0] || s.documentElement;
u.appendChild(o), t.textView.update(!0)
}
function r(e, t) {
var n, r = "JavaScript Editor",
i = this;
e.getPreferences("/settings", 2).then(function (e) {
var s = e.get(r);
if (s !== undefined) {
n = JSON.parse(e.get(r));
if (!n) return;
i._stylesheet && (i._stylesheet.parentNode.removeChild(i._stylesheet), i._stylesheet = null), i._update(n, i, t)
}
})
}
function i(e, t) {
var n = [];
for (var r = 0; r < e.length; r++) n[e[r].element] = e[r].value;
var i = [];
i.push("");
var s = n.fontFamily;
return s === "sans serif" ? s = '"Menlo", "Consolas", "Vera Mono", "monospace"' : s = "monospace", i.push(t + " .textviewContainer {"), i.push("\background-color:" + n.background + ";"), i.push(" font-family: " + s + ";"), i.push(" font-size: " + n.fontSize + ";"), i.push(" min-width: 50px;"), i.push(" min-height: 50px;"), i.push(" color: " + n.text + ";"), i.push("}"), i.push(t + " {"), i.push(" font-family: " + s + ";"), i.push(" font-size: " + n.fontSize + ";"), i.push(" color: " + n.text + ";"), i.push("}"), i.push(t + " .textview {"), i.push(" background-color: " + n.background + ";"), i.push("}"), i.push(t + ".ruler.annotations{"), i.push(" background-color: white;"), i.push("}"), i.push(t + " .ruler {"), i.push(" background-color: " + n.annotationRuler + ";"), i.push("}"), i.push(t + " .rulerLines {"), i.push(" color: " + n.lineNumber + ";"), i.push(" background-color: " + n.annotationRuler + ";"), i.push("}"), i.push(t + " .rulerLines.even {"), i.push(" color: " + n.lineNumber + ";"), i.push(" background-color: " + n.annotationRuler + ";"), i.push("}"), i.push(t + " .rulerLines.odd {"), i.push(" color: " + n.lineNumber + ";"), i.push(" background-color: " + n.annotationRuler + ";"), i.push("}"), i.push(t + " .annotationLine.currentLine {"), i.push(" background-color: " + n.currentLine + ";"), i.push("}"), i.push(t + " .entity-name-tag {"), i.push("color: " + n.keyword + ";"), i.push("}"), i.join("\n")
}
function o(e) {
var t;
if (e instanceof Array) {
t = new Array(e.length);
for (var n = 0; n < e.length; n++) t[n] = o(e[n])
} else {
t = {};
for (var r in e)
if (Object.prototype.hasOwnProperty.call(e, r)) {
var i = e[r];
typeof i == "object" && i !== null ? t[r] = o(i) : t[r] = i
}
}
return t
}
function u(e, t, s, u, a) {
this.initialize(e, u), this.grammar = o(t), this.externalGrammars = s ? o(s) : [], this._styles = {}, this._tree = null, this._allGrammars = {}, this.preprocess(this.grammar), this._updateStylesheet = r, this._update = n, this._styleSheet = i, this.util = a
}
var t, s = {
unsupported: [{
regex: /\(\?[ims\-]:/,
func: function (e) {
return "option on/off for subexp"
}
}, {
regex: /\(\?<([=!])/,
func: function (e) {
return e[1] === "=" ? "lookbehind" : "negative lookbehind"
}
}, {
regex: /\(\?>/,
func: function (e) {
return "atomic group"
}
}],
toRegExp: function (e) {
function t(e, t) {
throw new Error('Unsupported regex feature "' + e + '": "' + t[0] + '" at index: ' + t.index + " in " + t.input)
}
function n(e) {
var t = "",
n = !1,
r = e.length;
for (var i = 0; i < r;) {
var s = e.charAt(i);
if (!n && s === "#")
while (i < r && s !== "\r" && s !== "\n") s = e.charAt(++i);
else if (!n && /\s/.test(s))
while (i < r && /\s/.test(s)) s = e.charAt(++i);
else s === "\\" ? (t += s, /\s/.test(e.charAt(i + 1)) || (t += e.charAt(i + 1), i += 1), i += 1) : s === "[" ? (n = !0, t += s, i += 1) : s === "]" ? (n = !1, t += s, i += 1) : (t += s, i += 1)
}
return t
}
var r = "",
i;
e = s.processGlobalFlag("x", e, function (e) {
return n(e)
}), e = s.processGlobalFlag("i", e, function (e) {
return r += "i", e
});
for (i = 0; i < this.unsupported.length; i++) {
var o;
(o = this.unsupported[i].regex.exec(e)) && t(this.unsupported[i].func(o), o)
}
return new RegExp(e, r)
},
processGlobalFlag: function (e, t, n) {
function r(e, t) {
var n = 0,
r = e.length,
i = -1;
for (var s = t; s < r && i === -1; s++) switch (e.charAt(s)) {
case "\\":
s++;
break;
case "(":
n++;
break;
case ")":
n--, n === 0 && (i = s)
}
return i
}
var i = "(?" + e + ")",
s = "(?" + e + ":";
if (t.substring(0, i.length) === i) return n(t.substring(i.length));
if (t.substring(0, s.length) === s) {
var o = r(t, 0);
if (o < t.length - 1) throw new Error("Only a " + s + ") group that encloses the entire regex is supported in: " + t);
return n(t.substring(s.length, o))
}
return t
},
hasBackReference: function (e) {
return /\\\d+/.test(e.source)
},
getSubstitutedRegex: function (t, n, r) {
r = typeof r == "undefined" ? !0 : !1;
var i = t.source.split(/(\\\d+)/g),
s = [];
for (var o = 0; o < i.length; o++) {
var u = i[o],
a = /\\(\d+)/.exec(u);
if (a) {
var f = n[a[1]] || "";
s.push(r ? e.escape(f) : f)
} else s.push(u)
}
return new RegExp(s.join(""))
},
groupify: function (e, t) {
var n = 1,
r = 2,
i = 3,
s = 4,
o = e.source,
u = o.length,
a = [],
f = 0,
l = [],
c = 1,
h = 1,
p = [],
d = {}, v = {};
for (var m = 0; m < u; m++) {
var g = a[a.length - 1],
y = o.charAt(m);
switch (y) {
case "(":
g === s && (a.pop(), p.push(")"), l[l.length - 1].end = m);
var b = m + 2 < u ? o.charAt(m + 1) + "" + o.charAt(m + 2) : null;
if (b === "?:" || b === "?=" || b === "?!") {
var w;
b === "?:" ? w = n : (w = i, f++), a.push(w), l.push({
start: m,
end: -1,
type: w
}), p.push(y), p.push(b), m += b.length
} else a.push(r), l.push({
start: m,
end: -1,
type: r,
oldNum: c,
num: h
}), p.push(y), f === 0 && (v[h] = null), d[c] = h, c++, h++;
break;
case ")":
var E = a.pop();
E === i && f--, l[l.length - 1].end = m, p.push(y);
break;
case "*":
case "+":
case "?":
case "}":
var S = y,
x = o.charAt(m - 1),
T = m - 1;
if (y === "}") {
for (var N = m - 1; o.charAt(N) !== "{" && N >= 0; N--);
x = o.charAt(N - 1), T = N - 1, S = o.substring(N, m + 1)
}
var C = l[l.length - 1];
if (x === ")" && (C.type === r || C.type === s)) {
p.splice(C.start, 0, "("), p.push(S), p.push(")");
var k = {
start: C.start,
end: p.length - 1,
type: s,
num: C.num
};
for (var L = 0; L < l.length; L++) E = l[L], (E.type === r || E.type === s) && E.start >= C.start && E.end <= T && (E.start += 1, E.end += 1, E.num = E.num + 1, E.type === r && (d[E.oldNum] = E.num));
l.push(k), h++;
break
};
default:
y !== "|" && g !== r && g !== s && f === 0 && (a.push(s), l.push({
start: m,
end: -1,
type: s,
num: h
}), p.push("("), v[h] = null, h++), p.push(y);
if (y === "\\") {
var A = o.charAt(m + 1);
p.push(A), m += 1
}
}
}
while (a.length) a.pop(), p.push(")");
var O = new RegExp(p.join("")),
M = {};
t = t || d;
for (var _ in t) t.hasOwnProperty(_) && (M[_] = "\\" + t[_]);
return O = this.getSubstitutedRegex(O, M, !1), [O, d, v]
},
complexCaptures: function (e) {
if (!e) return !1;
for (var t in e)
if (e.hasOwnProperty(t) && t !== "0") return !0;
return !1
}
};
return u.prototype = {
initialize: function (e, n, r) {
this.textView = e, this.textView.stylerOptions = this;
var i = this;
this.textView && n && n.startup().then(function (e) {
t = e.preferences, i.preferences = t, i._updateStylesheet(t, r), i.storageKey = t.listenForChangedSettings(i._listener.onStorage)
}), this._listener = {
onModelChanged: function (e) {
i.onModelChanged(e)
},
onDestroy: function (e) {
i.onDestroy(e)
},
onLineStyle: function (e) {
i.onLineStyle(e)
},
onStorage: function (e) {
i.onStorage(e)
}
}, e.addEventListener("ModelChanged", this._listener.onModelChanged), e.addEventListener("Destroy", this._listener.onDestroy), e.addEventListener("LineStyle", this._listener.onLineStyle), e.redrawLines()
},
onDestroy: function (e) {
this.destroy()
},
onStorage: function (e) {
e.key === this.storageKey && this._updateStylesheet(this.preferences)
},
destroy: function () {
this.textView && (this.textView.removeEventListener("ModelChanged", this._listener.onModelChanged), this.textView.removeEventListener("Destroy", this._listener.onDestroy), this.textView.removeEventListener("LineStyle", this._listener.onLineStyle), this.textView = null), this.grammar = null, this._styles = null, this._tree = null, this._listener = null
},
preprocess: function (e) {
var t = [e];
for (; t.length !== 0;) {
var n = t.pop();
if (n._resolvedRule && n._typedRule) continue;
n._resolvedRule = this._resolve(n), n._typedRule = this._createTypedRule(n), this.addStyles(n.name), this.addStyles(n.contentName), this.addStylesForCaptures(n.captures), this.addStylesForCaptures(n.beginCaptures), this.addStylesForCaptures(n.endCaptures), n._resolvedRule !== n && t.push(n._resolvedRule);
if (n.patterns)
for (var r = 0; r < n.patterns.length; r++) t.push(n.patterns[r])
}
},
addStyles: function (e) {
if (e && !this._styles[e]) {
this._styles[e] = [];
var t = e.split(".");
for (var n = 0; n < t.length; n++) this._styles[e].push(t.slice(0, n + 1).join("-"))
}
},
addStylesForCaptures: function (e) {
for (var t in e)
if (e.hasOwnProperty(t)) {
var n = e[t].name;
this.addStyles(n)
}
},
ContainerRule: function () {
function e(e) {
this.rule = e, this.subrules = e.patterns
}
return e.prototype.valueOf = function () {
return "aa"
}, e
}(),
BeginEndRule: function () {
function e(e) {
this.rule = e, this.beginRegex = s.toRegExp(e.begin), this.endRegex = s.toRegExp(e.end), this.subrules = e.patterns || [], this.endRegexHasBackRef = s.hasBackReference(this.endRegex);
var t = s.complexCaptures(e.captures),
n = s.complexCaptures(e.beginCaptures) || s.complexCaptures(e.endCaptures);
this.isComplex = t || n;
if (this.isComplex) {
var r = s.groupify(this.beginRegex);
this.beginRegex = r[0], this.beginOld2New = r[1], this.beginConsuming = r[2];
var i = s.groupify(this.endRegex, this.beginOld2New);
this.endRegex = i[0], this.endOld2New = i[1], this.endConsuming = i[2]
}
}
return e.prototype.valueOf = function () {
return this.beginRegex
}, e
}(),
MatchRule: function () {
function e(e) {
this.rule = e, this.matchRegex = s.toRegExp(e.match), this.isComplex = s.complexCaptures(e.captures);
if (this.isComplex) {
var t = s.groupify(this.matchRegex);
this.matchRegex = t[0], this.matchOld2New = t[1], this.matchConsuming = t[2]
}
}
return e.prototype.valueOf = function () {
return this.matchRegex
}, e
}(),
_createTypedRule: function (e) {
return e.match ? new this.MatchRule(e) : e.begin ? new this.BeginEndRule(e) : new this.ContainerRule(e)
},
_resolve: function (e) {
var t = e;
if (e.include) {
if (e.begin || e.end || e.match) throw new Error('Unexpected regex pattern in "include" rule ' + e.include);
var n = e.include;
if (n.charAt(0) === "#") {
t = this.grammar.repository && this.grammar.repository[n.substring(1)];
if (!t) throw new Error("Couldn't find included rule " + n + " in grammar repository")
} else if (n === "$self") t = this.grammar;
else {
if (n === "$base") throw new Error('Include "$base" is not supported');
t = this._allGrammars[n];
if (!t)
for (var r = 0; r < this.externalGrammars.length; r++) {
var i = this.externalGrammars[r];
if (i.scopeName === n) {
this.preprocess(i), this._allGrammars[n] = i, t = i;
break
}
}
}
}
return t
},
ContainerNode: function () {
function e(e, t) {
this.parent = e, this.rule = t, this.children = [], this.start = null, this.end = null
}
return e.prototype.addChild = function (e) {
this.children.push(e)
}, e.prototype.valueOf = function () {
var e = this.rule;
return "ContainerNode { " + (e.include || "") + " " + (e.name || "") + (e.comment || "") + "}"
}, e
}(),
BeginEndNode: function () {
function e(e, t, n) {
this.parent = e, this.rule = t, this.children = [], this.setStart(n), this.end = null, this.endMatch = null, t.endRegexHasBackRef ? this.endRegexSubstituted = s.getSubstitutedRegex(t.endRegex, n) : this.endRegexSubstituted = null
}
return e.prototype.addChild = function (e) {
this.children.push(e)
}, e.prototype.getIndexInParent = function (e) {
return this.parent ? this.parent.children.indexOf(this) : -1
}, e.prototype.setStart = function (e) {
this.start = e.index, this.beginMatch = e
}, e.prototype.setEnd = function (e) {
if (e && typeof e == "object") {
var t = e;
this.endMatch = t, this.end = t.index + t[0].length
} else {
var n = e;
this.endMatch = null, this.end = n
}
}, e.prototype.shiftStart = function (e) {
this.start += e, this.beginMatch.index += e
}, e.prototype.shiftEnd = function (e) {
this.end += e, this.endMatch && (this.endMatch.index += e)
}, e.prototype.valueOf = function () {
return "{" + this.rule.beginRegex + " range=" + this.start + ".." + this.end + "}"
}, e
}(),
push: function (e, t) {
if (!t) return;
for (var n = t.length; n > 0;) e.push(t[--n])
},
exec: function (e, t, n) {
var r = e.exec(t);
return r && (r.index += n), e.lastIndex = 0, r
},
afterMatch: function (e) {
return e.index + e[0].length
},
getEndMatch: function (e, t, n) {
if (e instanceof this.BeginEndNode) {
var r = e.rule,
i = e.endRegexSubstituted || r.endRegex;
return i ? this.exec(i, t, n) : null
}
return null
},
initialParse: function () {
var e = this.textView.getModel().getCharCount(),
t = new this.ContainerNode(null, this.grammar._typedRule);
this._tree = t, this.parse(this._tree, !1, 0)
},
onModelChanged: function (e) {
var t = e.addedCharCount,
n = e.addedLineCount,
r = e.removedCharCount,
i = e.removedLineCount,
s = e.start;
if (!this._tree) this.initialParse();
else {
var o = this.textView.getModel(),
u = o.getCharCount(),
a = o.getLineEnd(o.getLineAtOffset(s) - 1),
f = this.getFirstDamaged(a, a);
a = a === -1 ? 0 : a;
var l;
f ? l = this.parse(f, !0, a, s, t, r) : l = u, this.textView.redrawRange(a, l)
}
},
getFirstDamaged: function (e, t) {
if (e < 0) return this._tree;
var n = [this._tree],
r = null;
while (n.length) {
var i = n.pop();
if (!i.parent || this.isDamaged(i, e, t)) {
i instanceof this.BeginEndNode && (r = i);
for (var s = 0; s < i.children.length; s++) n.push(i.children[s])
}
}
return r || this._tree
},
isDamaged: function (e, t, n) {
return e.start <= n && e.end > t
},
parse: function (e, t, n, r, i, s) {
var o = this.textView.getModel(),
u = o.getLineStart(o.getLineCount() - 1),
a = o.getCharCount(),
f = this.getInitialExpected(e, n),
l = -1;
if (t) {
e.repaired = !0, e.endNeedsUpdate = !0;
var c = e.children[e.children.length - 1],
h = i - s,
p = c ? o.getLineEnd(o.getLineAtOffset(c.end + h)) : -1,
d = o.getLineEnd(o.getLineAtOffset(r + s));
l = Math.max(p, d)
}
l = l === -1 ? a : l;
var v = f,
m = e,
g = !1,
y = n,
b = -1;
while (m && (!t || y < l)) {
var w = this.getNextMatch(o, m, y);
w || (y = y >= u ? a : o.getLineStart(o.getLineAtOffset(y) + 1));
var E = w && w.match,
S = w && w.rule,
x = w && w.isSub,
T = w && w.isEnd;
if (x) {
y = this.afterMatch(E);
if (S instanceof this.BeginEndRule) {
g = !0;
if (t && S === v.rule && m === v.parent) {
var N = v;
N.setStart(E), N.repaired = !0, N.endNeedsUpdate = !0, m = N, v = this.getNextExpected(v, "begin")
} else {
t && (this.prune(m, v), t = !1);
var C = new this.BeginEndNode(m, S, E);
m.addChild(C), m = C
}
}
} else if (T || y === a) m instanceof this.BeginEndNode && (E ? (g = !0, b = Math.max(b, m.end), m.setEnd(E), y = this.afterMatch(E), t && m === v && m.parent === v.parent ? (m.repaired = !0, delete m.endNeedsUpdate, v = this.getNextExpected(v, "end")) : t && (this.prune(m, v), t = !1)) : (m.setEnd(a), delete m.endNeedsUpdate)), m = m.parent;
t && y >= l && !g && (this.prune(e, f), t = !1)
}
return this.removeUnrepairedChildren(e, t, n), this.cleanup(t, e, n, l, a, i, s), t ? Math.max(b, y) : y
},
removeUnrepairedChildren: function (e, t, n) {
if (t) {
var r = e.children,
i = -1;
for (var s = 0; s < r.length; s++) {
var o = r[s];
if (!o.repaired && this.isDamaged(o, n, Number.MAX_VALUE)) {
i = s;
break
}
}
i !== -1 && (e.children.length = i)
}
},
cleanup: function (e, t, n, r, i, s, o) {
var u, a, f;
if (e) {
var l = s - o,
c = this.getIntersecting(r - l + 1, i);
f = this.getIntersecting(n, r);
for (u = 0; u < c.length; u++) a = c[u], !a.repaired && a instanceof this.BeginEndNode && (a.shiftEnd(l), a.shiftStart(l));
for (u = 0; u < f.length; u++) a = f[u], a.repaired && a.endNeedsUpdate && a.shiftEnd(l), delete a.endNeedsUpdate, delete a.repaired
} else {
f = this.getIntersecting(n, r);
for (u = 0; u < f.length; u++) delete f[u].repaired
}
},
getNextMatch: function (e, t, n, r) {
var i = e.getLineAtOffset(n),
s = e.getLineEnd(i),
o = e.getText(n, s),
u = [],
a = [],
f = [],
l = [];
this.push(u, t.rule.subrules);
while (u.length) {
var c = u.length ? u.pop() : null,
h = c && c._resolvedRule._typedRule;
if (h instanceof this.ContainerRule && a.indexOf(h) === -1) {
a.push(h), this.push(u, h.subrules);
continue
}
if (h && r && !h.matchRegex) continue;
var p = h && this.exec(h.matchRegex || h.beginRegex, o, n);
p && (f.push(p), l.push(h))
}
var d = Number.MAX_VALUE,
v = -1;
for (var m = 0; m < f.length; m++) {
var g = f[m];
g.index < d && (d = g.index, v = m)
}
if (!r) {
var y = t,
b = this.getEndMatch(t, o, n);
if (b) {
var w = y.rule.applyEndPatternLast,
E = v === -1 || b.index < d || !w && b.index === d;
if (E) return {
isEnd: !0,
rule: y.rule,
match: b
}
}
}
return v === -1 ? null : {
isSub: !0,
rule: l[v],
match: f[v]
}
},
getInitialExpected: function (e, t) {
var n, r;
if (e === this._tree)
for (n = 0; n < e.children.length; n++) {
r = e.children[n];
if (r.start >= t) return r
} else if (e instanceof this.BeginEndNode && e.endMatch) {
var i = e.endMatch.index;
for (n = 0; n < e.children.length; n++) {
r = e.children[n];
if (r.start >= t) break
}
if (r && r.start < i) return r
}
return e
},
getNextExpected: function (e, t) {
var n = e;
if (t === "begin") {
var r = n.children[0];
return r ? r : n
}
if (t === "end") {
var i = n.parent;
if (i) {
var s = i.children[i.children.indexOf(n) + 1];
return s ? s : i
}
}
return null
},
prune: function (e, t) {
var n = t.parent === e;
n ? e.children.length = t.getIndexInParent() : e instanceof this.BeginEndNode && (e.endMatch = null, e.end = null), e.parent && (e.parent.children.length = e.getIndexInParent() + 1)
},
onLineStyle: function (e) {
function t(e, t) {
return e.start - t.start
}
this._tree || this.initialParse();
var n = e.lineStart,
r = this.textView.getModel(),
i = r.getLineEnd(e.lineIndex),
s = r.getLineEnd(r.getLineAtOffset(n) - 1),
o = this.getFirstDamaged(s, s),
u = this.getLineScope(r, o, n, i);
e.ranges = this.toStyleRanges(u), e.ranges.sort(t)
},
getLineScope: function (e, t, n, r) {
var i = n,
s = this.getInitialExpected(t, n),
o = [],
u = [];
while (t && i < r) {
var a = this.getNextMatch(e, t, i);
if (!a) break;
var f = a && a.match,
l = a && a.rule,
c = a && a.isSub,
h = a && a.isEnd;
f.index !== i && u.push({
start: i,
end: f.index,
node: t
}), c ? (i = this.afterMatch(f), l instanceof this.BeginEndRule ? (this.addBeginScope(o, f, l), t = s, s = this.getNextExpected(s, "begin")) : this.addMatchScope(o, f, l)) : h && (i = this.afterMatch(f), this.addEndScope(o, f, l), s = this.getNextExpected(s, "end"), t = t.parent)
}
i < r && u.push({
start: i,
end: r,
node: t
});
var p = this.getInheritedLineScope(u, n, r);
return o.concat(p)
},
getInheritedLineScope: function (e, t, n) {
var r = [];
for (var i = 0; i < e.length; i++) {
var s = e[i],
o = s.node;
while (o) {
var u = o.rule.rule,
a = u.name,
f = u.contentName,
l = f || a;
if (l) {
this.addScopeRange(r, s.start, s.end, l);
break
}
o = o.parent
}
}
return r
},
addBeginScope: function (e, t, n) {
var r = n.rule;
this.addCapturesScope(e, t, r.beginCaptures || r.captures, n.isComplex, n.beginOld2New, n.beginConsuming)
},
addEndScope: function (e, t, n) {
var r = n.rule;
this.addCapturesScope(e, t, r.endCaptures || r.captures, n.isComplex, n.endOld2New, n.endConsuming)
},
addMatchScope: function (e, t, n) {
var r = n.rule,
i = r.name,
s = r.captures;
s ? this.addCapturesScope(e, t, s, n.isComplex, n.matchOld2New, n.matchConsuming) : this.addScope(e, t, i)
},
addScope: function (e, t, n) {
if (!n) return;
e.push({
start: t.index,
end: this.afterMatch(t),
scope: n
})
},
addScopeRange: function (e, t, n, r) {
if (!r) return;
e.push({
start: t,
end: n,
scope: r
})
},
addCapturesScope: function (e, t, n, r, i, s) {
if (!n) return;
if (!r) this.addScope(e, t, n[0] && n[0].name);
else {
var o = {
1: 0
}, u = 0;
for (var a = 1; t[a] !== undefined; a++) s[a] !== undefined && (u += t[a].length), t[a + 1] !== undefined && (o[a + 1] = u);
var f = t.index;
for (var l = 1; n[l]; l++) {
var c = n[l].name,
h = i[l],
p = f + o[h];
if (typeof t[h] != "undefined") {
var d = p + t[h].length;
this.addScopeRange(e, p, d, c)
}
}
}
},
getIntersecting: function (e, t) {
var n = [],
r = this._tree ? [this._tree] : [];
while (r.length) {
var i = r.pop(),
s = !1;
i instanceof this.ContainerNode ? s = !0 : this.isDamaged(i, e, t) && (s = !0, n.push(i));
if (s) {
var o = i.children.length;
for (var u = 0; u < o; u++) r.push(i.children[u])
}
}
return n.reverse()
},
toStyleRanges: function (e) {
var t = [];
for (var n = 0; n < e.length; n++) {
var r = e[n],
i = this._styles[r.scope];
if (!i) throw new Error("styles not found for " + r.scope);
var s = i.join(" ");
t.push({
start: r.start,
end: r.end,
style: {
styleClass: s
}
})
}
return t
}
}, {
RegexUtil: s,
TextMateStyler: u
}
}), n("orion/editor/htmlGrammar", [], function () {
function e() {
return {
scopeName: "source.html",
uuid: "3B5C76FB-EBB5-D930-F40C-047D082CE99B",
patterns: [{
begin: "<!(doctype|DOCTYPE)",
end: ">",
contentName: "entity.name.tag.doctype.html",
beginCaptures: {
0: {
name: "entity.name.tag.doctype.html"
}
},
endCaptures: {
0: {
name: "entity.name.tag.doctype.html"
}
}
}, {
begin: "<!--",
end: "-->",
beginCaptures: {
0: {
name: "punctuation.definition.comment.html"
}
},
endCaptures: {
0: {
name: "punctuation.definition.comment.html"
}
},
patterns: [{
match: "--",
name: "invalid.illegal.badcomment.html"
}],
contentName: "comment.block.html"
}, {
match: "<[A-Za-z0-9_\\-:]+(?= ?)",
name: "entity.name.tag.html"
}, {
include: "#attrName"
}, {
include: "#qString"
}, {
include: "#qqString"
}, {
include: "#entity"
}, {
match: "</[A-Za-z0-9_\\-:]+>",
name: "entity.name.tag.html"
}, {
match: ">",
name: "entity.name.tag.html"
}],
repository: {
attrName: {
match: "[A-Za-z\\-:]+(?=\\s*=\\s*['\"])",
name: "entity.other.attribute.name.html"
},
qqString: {
match: '(")[^"]+(")',
name: "token.string"
},
qString: {
match: "(')[^']+(')",
name: "token.string"
},
entity: {
match: "&[A-Za-z0-9]+;",
name: "constant.character.entity.html"
}
}
}
}
return {
HtmlGrammar: e
}
}), n("examples/editor/textStyler", ["orion/editor/annotations"], function (e) {
function F(e, t) {
this.keywords = e, this.whitespacesVisible = t, this.setText("")
}
function I() {
F.call(this, null, !0)
}
function q(e) {
F.call(this, null, e)
}
function R() {
F.call(this, null, !1)
}
function U(e, i, s) {
this.commentStart = "/*", this.commentEnd = "*/";
var o = [];
switch (i) {
case "java":
o = n;
break;
case "js":
o = t;
break;
case "css":
o = r
}
this.whitespacesVisible = !1, this.detectHyperlinks = !0, this.highlightCaretLine = !1, this.foldingEnabled = !0, this.detectTasks = !0, this._scanner = new F(o, this.whitespacesVisible), this._firstScanner = new R, this._commentScanner = new q(this.whitespacesVisible), this._whitespaceScanner = new I, i === "css" && (this._scanner.isCSS = !0, this._firstScanner.isCSS = !0), this.view = e, this.annotationModel = s, this._bracketAnnotations = undefined;
var u = this;
this._listener = {
onChanged: function (e) {
u._onModelChanged(e)
},
onDestroy: function (e) {
u._onDestroy(e)
},
onLineStyle: function (e) {
u._onLineStyle(e)
},
onMouseDown: function (e) {
u._onMouseDown(e)
},
onSelection: function (e) {
u._onSelection(e)
}
};
var a = e.getModel();
a.getBaseModel && (a = a.getBaseModel()), a.addEventListener("Changed", this._listener.onChanged), e.addEventListener("MouseDown", this._listener.onMouseDown), e.addEventListener("Selection", this._listener.onSelection), e.addEventListener("Destroy", this._listener.onDestroy), e.addEventListener("LineStyle", this._listener.onLineStyle), this._computeComments(), this._computeFolding(), e.redrawLines()
}
var t = ["break", "case", "class", "catch", "continue", "const", "debugger", "default", "delete", "do", "else", "enum", "export", "extends", "false", "finally", "for", "function", "if", "implements", "import", "in", "instanceof", "interface", "let", "new", "null", "package", "private", "protected", "public", "return", "static", "super", "switch", "this", "throw", "true", "try", "typeof", "undefined", "var", "void", "while", "with", "yield"],
n = ["abstract", "boolean", "break", "byte", "case", "catch", "char", "class", "continue", "default", "do", "double", "else", "extends", "false", "final", "finally", "float", "for", "if", "implements", "import", "instanceof", "int", "interface", "long", "native", "new", "null", "package", "private", "protected", "public", "return", "short", "static", "super", "switch", "synchronized", "this", "throw", "throws", "transient", "true", "try", "void", "volatile", "while"],
r = ["alignment-adjust", "alignment-baseline", "animation", "animation-delay", "animation-direction", "animation-duration", "animation-iteration-count", "animation-name", "animation-play-state", "animation-timing-function", "appearance", "azimuth", "backface-visibility", "background", "background-attachment", "background-clip", "background-color", "background-image", "background-origin", "background-position", "background-repeat", "background-size", "baseline-shift", "binding", "bleed", "bookmark-label", "bookmark-level", "bookmark-state", "bookmark-target", "border", "border-bottom", "border-bottom-color", "border-bottom-left-radius", "border-bottom-right-radius", "border-bottom-style", "border-bottom-width", "border-collapse", "border-color", "border-image", "border-image-outset", "border-image-repeat", "border-image-slice", "border-image-source", "border-image-width", "border-left", "border-left-color", "border-left-style", "border-left-width", "border-radius", "border-right", "border-right-color", "border-right-style", "border-right-width", "border-spacing", "border-style", "border-top", "border-top-color", "border-top-left-radius", "border-top-right-radius", "border-top-style", "border-top-width", "border-width", "bottom", "box-align", "box-decoration-break", "box-direction", "box-flex", "box-flex-group", "box-lines", "box-ordinal-group", "box-orient", "box-pack", "box-shadow", "box-sizing", "break-after", "break-before", "break-inside", "caption-side", "clear", "clip", "color", "color-profile", "column-count", "column-fill", "column-gap", "column-rule", "column-rule-color", "column-rule-style", "column-rule-width", "column-span", "column-width", "columns", "content", "counter-increment", "counter-reset", "crop", "cue", "cue-after", "cue-before", "cursor", "direction", "display", "dominant-baseline", "drop-initial-after-adjust", "drop-initial-after-align", "drop-initial-before-adjust", "drop-initial-before-align", "drop-initial-size", "drop-initial-value", "elevation", "empty-cells", "fit", "fit-position", "flex-align", "flex-flow", "flex-inline-pack", "flex-order", "flex-pack", "float", "float-offset", "font", "font-family", "font-size", "font-size-adjust", "font-stretch", "font-style", "font-variant", "font-weight", "grid-columns", "grid-rows", "hanging-punctuation", "height", "hyphenate-after", "hyphenate-before", "hyphenate-character", "hyphenate-lines", "hyphenate-resource", "hyphens", "icon", "image-orientation", "image-rendering", "image-resolution", "inline-box-align", "left", "letter-spacing", "line-height", "line-stacking", "line-stacking-ruby", "line-stacking-shift", "line-stacking-strategy", "list-style", "list-style-image", "list-style-position", "list-style-type", "margin", "margin-bottom", "margin-left", "margin-right", "margin-top", "mark", "mark-after", "mark-before", "marker-offset", "marks", "marquee-direction", "marquee-loop", "marquee-play-count", "marquee-speed", "marquee-style", "max-height", "max-width", "min-height", "min-width", "move-to", "nav-down", "nav-index", "nav-left", "nav-right", "nav-up", "opacity", "orphans", "outline", "outline-color", "outline-offset", "outline-style", "outline-width", "overflow", "overflow-style", "overflow-x", "overflow-y", "padding", "padding-bottom", "padding-left", "padding-right", "padding-top", "page", "page-break-after", "page-break-before", "page-break-inside", "page-policy", "pause", "pause-after", "pause-before", "perspective", "perspective-origin", "phonemes", "pitch", "pitch-range", "play-during", "position", "presentation-level", "punctuation-trim", "quotes", "rendering-intent", "resize", "rest", "rest-after", "rest-before", "richness", "right", "rotation", "rotation-point", "ruby-align", "ruby-overhang", "ruby-position", "ruby-span", "size", "speak", "speak-header", "speak-numeral", "speak-punctuation", "speech-rate", "stress", "string-set", "table-layout", "target", "target-name", "target-new", "target-position", "text-align", "text-align-last", "text-decoration", "text-emphasis", "text-height", "text-indent", "text-justify", "text-outline", "text-shadow", "text-transform", "text-wrap", "top", "transform", "transform-origin", "transform-style", "transition", "transition-delay", "transition-duration", "transition-property", "transition-timing-function", "unicode-bidi", "vertical-align", "visibility", "voice-balance", "voice-duration", "voice-family", "voice-pitch", "voice-pitch-range", "voice-rate", "voice-stress", "voice-volume", "volume", "white-space", "white-space-collapse", "widows", "width", "word-break", "word-spacing", "word-wrap", "z-index"],
i = 1,
s = 2,
o = 3,
u = 4,
a = 5,
f = 6,
l = 7,
c = 8,
h = 9,
p = 10,
d = 11,
v = 12,
m = 13,
g = 14,
y = "{}()[]<>",
b = {
styleClass: "comment"
}, w = {
styleClass: "token_multiline_comment"
}, E = {
styleClass: "token_doc_comment"
}, S = {
styleClass: "token_doc_html_markup"
}, x = {
styleClass: "token_task_tag"
}, T = {
styleClass: "token_doc_tag"
}, N = {
styleClass: "token-string"
}, C = {
styleClass: "token_number"
}, k = {
styleClass: "token_keyword"
}, L = {
styleClass: "token_space"
}, A = {
styleClass: "token_tab"
}, O = {
styleClass: "line_caret"
}, M = {
styleClass: "ruler"
}, _ = {
styleCLass: "ruler.annotations"
}, D = {
styleClass: "ruler.lines"
}, P = {
styleClass: "ruler.overview"
}, H = {
styleCLass: "rulerLines"
}, B = {
styleClass: "rulerLines.even"
}, j = {
styleClass: "rulerLines.odd"
};
return F.prototype = {
getOffset: function () {
return this.offset
},
getStartOffset: function () {
return this.startOffset
},
getData: function () {
return this.text.substring(this.startOffset, this.offset)
},
getDataLength: function () {
return this.offset - this.startOffset
},
_default: function (e) {
switch (e) {
case 32:
case 9:
if (this.whitespacesVisible) return e === 32 ? d : p;
do e = this._read(); while (e === 32 || e === 9);
return this._unread(e), h;
case 123:
case 125:
case 40:
case 41:
case 91:
case 93:
case 60:
case 62:
return e;
default:
var t = this.isCSS,
n = this.offset - 1;
if (!t && 48 <= e && e <= 57) {
var r = !1,
u = !1,
a = !1,
f = e;
do {
e = this._read();
if (e === 46 && !r) r = !0;
else if (e === 101 && !u) r = u = !0, e = this._read(), e !== 45 && this._unread(e);
else if (e === 120 && f === 48 && this.offset - n === 2) r = u = a = !0;
else if (!(48 <= e && e <= 57 || a && (65 <= e && e <= 70 || 97 <= e && e <= 102))) break
} while (!0);
return this._unread(e), o
}
if (97 <= e && e <= 122 || 65 <= e && e <= 90 || e === 95 || 45 === e && t) {
do e = this._read(); while (97 <= e && e <= 122 || 65 <= e && e <= 90 || e === 95 || 48 <= e && e <= 57 || 45 === e && t);
this._unread(e);
var l = this.keywords;
if (l.length > 0) {
var c = this.text.substring(n, this.offset);
for (var v = 0; v < l.length; v++)
if (this.keywords[v] === c) return s
}
}
return i
}
},
_read: function () {
return this.offset < this.text.length ? this.text.charCodeAt(this.offset++) : -1
},
_unread: function (e) {
e !== -1 && this.offset--
},
nextToken: function () {
this.startOffset = this.offset;
for (;;) {
var e = this._read(),
t;
switch (e) {
case -1:
return null;
case 47:
e = this._read();
if (!this.isCSS && e === 47)
for (;;) {
e = this._read();
if (e === -1 || e === 10 || e === 13) return this._unread(e), f
}
if (e === 42) {
e = this._read();
var n = l;
e === 42 && (n = c);
for (;;) {
while (e === 42) {
e = this._read();
if (e === 47) return n
}
if (e === -1) return this._unread(e), n;
e = this._read()
}
}
return this._unread(e), i;
case 39:
t = u;
for (;;) {
e = this._read();
switch (e) {
case 39:
return t;
case 13:
case 10:
case -1:
return this._unread(e), t;
case 92:
e = this._read();
switch (e) {
case 10:
t = a;
break;
case 13:
t = a, e = this._read(), e !== 10 && this._unread(e)
}
}
}
break;
case 34:
t = u;
for (;;) {
e = this._read();
switch (e) {
case 34:
return t;
case 13:
case 10:
case -1:
return this._unread(e), t;
case 92:
e = this._read();
switch (e) {
case 10:
t = a;
break;
case 13:
t = a, e = this._read(), e !== 10 && this._unread(e)
}
}
}
break;
default:
return this._default(e)
}
}
},
setText: function (e) {
this.text = e, this.offset = 0, this.startOffset = 0
}
}, I.prototype = new F(null), I.prototype.nextToken = function () {
this.startOffset = this.offset;
for (;;) {
var e = this._read();
switch (e) {
case -1:
return null;
case 32:
return d;
case 9:
return p;
default:
do e = this._read(); while (e !== 32 && e !== 9 && e !== -1);
return this._unread(e), i
}
}
}, q.prototype = new F(null), q.prototype.setType = function (e) {
this._type = e
}, q.prototype.nextToken = function () {
this.startOffset = this.offset;
for (;;) {
var e = this._read();
switch (e) {
case -1:
return null;
case 32:
case 9:
if (this.whitespacesVisible) return e === 32 ? d : p;
do e = this._read(); while (e === 32 || e === 9);
return this._unread(e), h;
case 60:
if (this._type === c) {
do e = this._read(); while (e !== 62 && e !== -1);
if (e === 62) return v
}
return i;
case 64:
if (this._type === c) {
do e = this._read(); while (97 <= e && e <= 122 || 65 <= e && e <= 90 || e === 95 || 48 <= e && e <= 57);
return this._unread(e), m
}
return i;
case 84:
if ((e = this._read()) === 79)
if ((e = this._read()) === 68)
if ((e = this._read()) === 79) {
e = this._read();
if (!(97 <= e && e <= 122 || 65 <= e && e <= 90 || e === 95 || 48 <= e && e <= 57)) return this._unread(e), g;
this._unread(e)
} else this._unread(e);
else this._unread(e);
else this._unread(e);
default:
do e = this._read(); while (e !== 32 && e !== 9 && e !== -1 && e !== 60 && e !== 64 && e !== 84);
return this._unread(e), i
}
}
}, R.prototype = new F(null), R.prototype._default = function (e) {
for (;;) {
e = this._read();
switch (e) {
case 47:
case 34:
case 39:
case -1:
return this._unread(e), i
}
}
}, U.prototype = {
getClassNameForToken: function (e) {
switch (e) {
case "singleLineComment":
return b.styleClass;
case "multiLineComment":
return w.styleClass;
case "docComment":
return E.styleClass;
case "docHtmlComment":
return S.styleClass;
case "tasktag":
return x.styleClass;
case "doctag":
return T.styleClass;
case "string":
return N.styleClass;
case "number":
return C.styleClass;
case "keyword":
return k.styleClass;
case "space":
return L.styleClass;
case "tab":
return A.styleClass;
case "caretLine":
return O.styleClass;
case "rulerStyle":
return M.styleClass;
case "annotationsStyle":
return _.styleClass;
case "rulerFolding":
return H.styleClass;
case "rulerOverview":
return P.styleClass;
case "rulerLines":
return H.styleClass;
case "rulerLinesEven":
return B.styleClass;
case "rulerLinesOdd":
return j.styleClass
}
return null
},
destroy: function () {
var e = this.view;
if (e) {
var t = e.getModel();
t.getBaseModel && (t = t.getBaseModel()), t.removeEventListener("Changed", this._listener.onChanged), e.removeEventListener("MouseDown", this._listener.onMouseDown), e.removeEventListener("Selection", this._listener.onSelection), e.removeEventListener("Destroy", this._listener.onDestroy), e.removeEventListener("LineStyle", this._listener.onLineStyle), this.view = null
}
},
setHighlightCaretLine: function (e) {
this.highlightCaretLine = e
},
setWhitespacesVisible: function (e) {
this.whitespacesVisible = e, this._scanner.whitespacesVisible = e, this._commentScanner.whitespacesVisible = e
},
setDetectHyperlinks: function (e) {
this.detectHyperlinks = e
},
setFoldingEnabled: function (e) {
this.foldingEnabled = e
},
setDetectTasks: function (e) {
this.detectTasks = e
},
_binarySearch: function (e, t, n, r, i) {
var s;
r === undefined && (r = -1), i === undefined && (i = e.length);
while (i - r > 1) {
s = Math.floor((i + r) / 2);
if (t <= e[s].start) i = s;
else {
if (n && t < e[s].end) {
i = s;
break
}
r = s
}
}
return i
},
_computeComments: function () {
var e = this.view.getModel();
e.getBaseModel && (e = e.getBaseModel()), this.comments = this._findComments(e.getText())
},
_computeFolding: function () {
if (!this.foldingEnabled) return;
var t = this.view,
n = t.getModel();
if (!n.getBaseModel) return;
var r = this.annotationModel;
if (!r) return;
r.removeAnnotations(e.AnnotationType.ANNOTATION_FOLDING);
var i = [],
s = n.getBaseModel(),
o = this.comments;
for (var u = 0; u < o.length; u++) {
var a = o[u],
f = this._createFoldingAnnotation(n, s, a.start, a.end);
f && i.push(f)
}
r.replaceAnnotations(null, i)
},
_createFoldingAnnotation: function (t, n, r, i) {
var s = n.getLineAtOffset(r),
o = n.getLineAtOffset(i);
return s === o ? null : new(e.AnnotationType.getType(e.AnnotationType.ANNOTATION_FOLDING))(r, i, t)
},
_computeTasks: function (t, n, r) {
if (!this.detectTasks) return;
var i = this.annotationModel;
if (!i) return;
var s = this.view,
o = s.getModel(),
u = o;
o.getBaseModel && (u = o.getBaseModel());
var a = i.getAnnotations(n, r),
l = [],
c = e.AnnotationType.ANNOTATION_TASK;
while (a.hasNext()) {
var h = a.next();
h.type === c && l.push(h)
}
var p = [],
d = this._commentScanner;
d.setText(u.getText(n, r));
var v;
while (v = d.nextToken()) {
var m = d.getStartOffset() + n;
if (v === g) {
var y = u.getLineEnd(u.getLineAtOffset(m));
t !== f && (y = Math.min(y, r - this.commentEnd.length)), p.push(e.AnnotationType.createAnnotation(c, m, y, u.getText(m, y)))
}
}
i.replaceAnnotations(l, p)
},
_getLineStyle: function (e) {
if (this.highlightCaretLine) {
var t = this.view,
n = t.getModel(),
r = t.getSelection();
if (r.start === r.end && n.getLineAtOffset(r.start) === e) return O
}
return null
},
_getStyles: function (e, t, n) {
e.getBaseModel && (n = e.mapOffset(n));
var r = n + t.length,
i = [],
s = n,
o = this.comments,
u = this._binarySearch(o, n, !0);
for (var f = u; f < o.length; f++) {
if (o[f].start >= r) break;
var h = o[f].start,
p = o[f].end;
s < h && this._parse(t.substring(s - n, h - n), s, i);
var d = o[f].type,
v;
switch (d) {
case c:
v = E;
break;
case l:
v = w;
break;
case a:
v = N
}
var m = Math.max(s, h),
g = Math.min(r, p);
d !== c && d !== l || !this.whitespacesVisible && !this.detectHyperlinks ? d === a && this.whitespacesVisible ? this._parseString(t.substring(m - n, g - n), m, i, N) : i.push({
start: m,
end: g,
style: v
}) : this._parseComment(t.substring(m - n, g - n), m, i, v, d), s = p
}
s < r && this._parse(t.substring(s - n, r - n), s, i);
if (e.getBaseModel)
for (var y = 0; y < i.length; y++) {
var b = i[y].end - i[y].start;
i[y].start = e.mapOffset(i[y].start, !0), i[y].end = i[y].start + b
}
return i
},
_parse: function (e, t, n) {
var r = this._scanner;
r.setText(e);
var i;
while (i = r.nextToken()) {
var h = r.getStartOffset() + t,
v = null;
switch (i) {
case s:
v = k;
break;
case o:
v = C;
break;
case a:
case u:
if (this.whitespacesVisible) {
this._parseString(r.getData(), h, n, N);
continue
}
v = N;
break;
case c:
this._parseComment(r.getData(), h, n, E, i);
continue;
case f:
this._parseComment(r.getData(), h, n, b, i);
continue;
case l:
this._parseComment(r.getData(), h, n, w, i);
continue;
case p:
this.whitespacesVisible && (v = A);
break;
case d:
this.whitespacesVisible && (v = L)
}
n.push({
start: h,
end: r.getOffset() + t,
style: v
})
}
},
_parseComment: function (e, t, n, r, i) {
var s = this._commentScanner;
s.setText(e), s.setType(i);
var o;
while (o = s.nextToken()) {
var u = s.getStartOffset() + t,
a = r;
switch (o) {
case p:
this.whitespacesVisible && (a = A);
break;
case d:
this.whitespacesVisible && (a = L);
break;
case v:
a = S;
break;
case m:
a = T;
break;
case g:
a = x;
break;
default:
this.detectHyperlinks && (a = this._detectHyperlinks(s.getData(), u, n, a))
}
a && n.push({
start: u,
end: s.getOffset() + t,
style: a
})
}
},
_parseString: function (e, t, n, r) {
var i = this._whitespaceScanner;
i.setText(e);
var s;
while (s = i.nextToken()) {
var o = i.getStartOffset() + t,
u = r;
switch (s) {
case p:
this.whitespacesVisible && (u = A);
break;
case d:
this.whitespacesVisible && (u = L)
}
u && n.push({
start: o,
end: i.getOffset() + t,
style: u
})
}
},
_detectHyperlinks: function (e, t, n, r) {
var i = null,
s, o;
if ((s = e.indexOf("://")) > 0) {
i = e;
var u = s;
while (u > 0) {
var a = i.charCodeAt(u - 1);
if (!(97 <= a && a <= 122 || 65 <= a && a <= 90 || 45 === a || 48 <= a && a <= 57)) break;
u--
}
if (u > 0) {
var f = "\"\"''(){}[]<>";
s = f.indexOf(i.substring(u - 1, u));
if (s !== -1 && (s & 1) === 0 && (s = i.lastIndexOf(f.substring(s + 1, s + 2))) !== -1) {
var l = s;
return o = this._clone(r), o.tagName = "A", o.attributes = {
href: i.substring(u, l)
}, n.push({
start: t,
end: t + u,
style: r
}), n.push({
start: t + u,
end: t + l,
style: o
}), n.push({
start: t + l,
end: t + e.length,
style: r
}), null
}
}
} else e.toLowerCase().indexOf("bug#") === 0 && (i = "https://bugs.eclipse.org/bugs/show_bug.cgi?id=" + parseInt(e.substring(4), 10));
return i ? (o = this._clone(r), o.tagName = "A", o.attributes = {
href: i
}, o) : r
},
_clone: function (e) {
if (!e) return e;
var t = {};
for (var n in e)
if (e.hasOwnProperty(n)) {
var r = e[n];
t[n] = r
}
return t
},
_findComments: function (e, t) {
t = t || 0;
var n = this._firstScanner,
r;
n.setText(e);
var i = [];
while (r = n.nextToken())(r === l || r === c || r === a) && i.push({
start: n.getStartOffset() + t,
end: n.getOffset() + t,
type: r
}), (r === f || r === l || r === c) && this._computeTasks(r, n.getStartOffset() + t, n.getOffset() + t);
return i
},
_findMatchingBracket: function (e, t) {
var n = y,
r = e.getText(t, t + 1),
i = n.indexOf(r, 0);
if (i === -1) return -1;
var s;
i & 1 ? s = n.substring(i - 1, i) : s = n.substring(i + 1, i + 2);
var o = e.getLineAtOffset(t),
u = e.getLine(o),
a = e.getLineStart(o),
f = e.getLineEnd(o);
n = this._findBrackets(r, s, u, a, a, f);
for (var l = 0; l < n.length; l++) {
var c = n[l] >= 0 ? 1 : -1;
if (n[l] * c - 1 === t) {
var h = 1;
if (i & 1) {
l--;
for (; l >= 0; l--) {
c = n[l] >= 0 ? 1 : -1, h += c;
if (h === 0) return n[l] * c - 1
}
o -= 1;
while (o >= 0) {
u = e.getLine(o), a = e.getLineStart(o), f = e.getLineEnd(o), n = this._findBrackets(r, s, u, a, a, f);
for (var p = n.length - 1; p >= 0; p--) {
c = n[p] >= 0 ? 1 : -1, h += c;
if (h === 0) return n[p] * c - 1
}
o--
}
} else {
l++;
for (; l < n.length; l++) {
c = n[l] >= 0 ? 1 : -1, h += c;
if (h === 0) return n[l] * c - 1
}
o += 1;
var d = e.getLineCount();
while (o < d) {
u = e.getLine(o), a = e.getLineStart(o), f = e.getLineEnd(o), n = this._findBrackets(r, s, u, a, a, f);
for (var v = 0; v < n.length; v++) {
c = n[v] >= 0 ? 1 : -1, h += c;
if (h === 0) return n[v] * c - 1
}
o++
}
}
break
}
}
return -1
},
_findBrackets: function (e, t, n, r, i, s) {
var o = [],
u = e.charCodeAt(0),
a = t.charCodeAt(0),
f = i,
l = this._scanner,
c, h = this.comments,
p = this._binarySearch(h, i, !0);
for (var d = p; d < h.length; d++) {
if (h[d].start >= s) break;
var v = h[d].start,
m = h[d].end;
if (f < v) {
l.setText(n.substring(f - i, v - i));
while (c = l.nextToken()) c === u ? o.push(l.getStartOffset() + f - i + r + 1) : c === a && o.push(-(l.getStartOffset() + f - i + r + 1))
}
f = m
}
if (f < s) {
l.setText(n.substring(f - i, s - i));
while (c = l.nextToken()) c === u ? o.push(l.getStartOffset() + f - i + r + 1) : c === a && o.push(-(l.getStartOffset() + f - i + r + 1))
}
return o
},
_onDestroy: function (e) {
this.destroy()
},
_onLineStyle: function (e) {
e.textView === this.view && (e.style = this._getLineStyle(e.lineIndex)), e.ranges = this._getStyles(e.textView.getModel(), e.lineText, e.lineStart)
},
_onSelection: function (t) {
var n = t.oldValue,
r = t.newValue,
i = this.view,
s = i.getModel(),
o;
if (this.highlightCaretLine) {
var u = s.getLineAtOffset(n.start);
o = s.getLineAtOffset(r.start);
var a = r.start === r.end,
f = n.start === n.end;
if (u !== o || !f || !a) f && i.redrawLines(u, u + 1), (u !== o || !f) && a && i.redrawLines(o, o + 1)
}
if (!this.annotationModel) return;
var l = this._bracketAnnotations,
c, h;
if (r.start === r.end && (h = i.getCaretOffset()) > 0) {
var p = h - 1;
s.getBaseModel && (p = s.mapOffset(p), s = s.getBaseModel());
var d = this._findMatchingBracket(s, p);
d !== -1 && (c = [e.AnnotationType.createAnnotation(e.AnnotationType.ANNOTATION_MATCHING_BRACKET, d, d + 1), e.AnnotationType.createAnnotation(e.AnnotationType.ANNOTATION_CURRENT_BRACKET, p, p + 1)])
}
this._bracketAnnotations = c, this.annotationModel.replaceAnnotations(l, c)
},
_onMouseDown: function (e) {
if (e.clickCount !== 2) return;
var t = this.view,
n = t.getModel(),
r = t.getOffsetAtLocation(e.x, e.y);
if (r > 0) {
var i = r - 1,
s = n;
n.getBaseModel && (i = n.mapOffset(i), s = n.getBaseModel());
var o = this._findMatchingBracket(s, i);
if (o !== -1) {
e.preventDefault();
var u = o;
n.getBaseModel && (u = n.mapOffset(u, !0)), r > u && (r--, u++), t.setSelection(u, r)
}
}
},
_onModelChanged: function (t) {
var n = t.start,
r = t.removedCharCount,
i = t.addedCharCount,
s = i - r,
o = this.view,
u = o.getModel(),
a = u.getBaseModel ? u.getBaseModel() : u,
f = n + r,
l = a.getCharCount(),
c = this.comments.length,
h = a.getLineStart(a.getLineAtOffset(n)),
p = this._binarySearch(this.comments, h, !0),
d = this._binarySearch(this.comments, f, !1, p - 1, c),
v;
p < c && this.comments[p].start <= h && h < this.comments[p].end ? (v = this.comments[p].start, v > n && (v += s)) : p === c && c > 0 && l - s === this.comments[c - 1].end ? v = this.comments[c - 1].start : v = h;
var m;
d < c ? (m = this.comments[d].end, m > n && (m += s), d += 1) : (d = c, m = l);
var g = a.getText(v, m),
y, b = this._findComments(g, v),
w;
for (w = p; w < this.comments.length; w++) y = this.comments[w], y.start > n && (y.start += s), y.start > n && (y.end += s);
var E = d - p !== b.length;
if (!E)
for (w = 0; w < b.length; w++) {
y = this.comments[p + w];
var S = b[w];
if (y.start !== S.start || y.end !== S.end || y.type !== S.type) {
E = !0;
break
}
}
var x = [p, d - p].concat(b);
Array.prototype.splice.apply(this.comments, x);
if (E) {
var T = v,
N = m;
u !== a && (T = u.mapOffset(T, !0), N = u.mapOffset(N, !0)), o.redrawRange(T, N)
}
if (this.foldingEnabled && a !== u && this.annotationModel) {
var C = this.annotationModel,
k = C.getAnnotations(v, m),
L = [],
A = [],
O;
while (k.hasNext()) {
O = k.next();
if (O.type === e.AnnotationType.ANNOTATION_FOLDING) {
A.push(O);
for (w = 0; w < b.length; w++)
if (O.start === b[w].start && O.end === b[w].end) break;
if (w === b.length) L.push(O), O.expand();
else {
var M = O.start,
_ = O.end;
M > n && (M -= s), _ > n && (_ -= s);
if (M <= n && n < _ && M <= f && f < _) {
var D = a.getLineAtOffset(O.start),
P = a.getLineAtOffset(O.end);
D !== P ? O.expanded || (O.expand(), C.modifyAnnotation(O)) : C.removeAnnotation(O)
}
}
}
}
var H = [];
for (w = 0; w < b.length; w++) {
y = b[w];
for (var B = 0; B < A.length; B++)
if (A[B].start === y.start && A[B].end === y.end) break;
B === A.length && (O = this._createFoldingAnnotation(u, a, y.start, y.end), O && H.push(O))
}
C.replaceAnnotations(L, H)
}
}
}, {
TextStyler: U
}
}), n("orion/editor/edit", ["orion/editor/textView", "orion/editor/textModel", "orion/editor/projectionTextModel", "orion/editor/eventTarget", "orion/editor/keyBinding", "orion/editor/rulers", "orion/editor/annotations", "orion/editor/tooltip", "orion/editor/undoStack", "orion/editor/textDND", "orion/editor/editor", "orion/editor/editorFeatures", "orion/editor/contentAssist", "orion/editor/cssContentAssist", "orion/editor/htmlContentAssist", "orion/editor/jsTemplateContentAssist", "orion/editor/AsyncStyler", "orion/editor/mirror", "orion/editor/textMateStyler", "orion/editor/htmlGrammar", "examples/editor/textStyler"], function (e, t, n, r, i, s, o, u, a, f, l, c, h, p, d, v, m, g, y, b, w) {
function E(e) {
var t = e.ownerDocument,
n = t.defaultView || t.parentWindow;
if (!n.getSelection) return e.innerText || e.textContent;
var r = t.createRange();
r.selectNode(e);
var i = n.getSelection(),
s = [],
o;
for (o = 0; o < i.rangeCount; o++) s.push(i.getRangeAt(o));
i.removeAllRanges(), i.addRange(r);
var u = i.toString();
i.removeAllRanges();
for (o = 0; o < s.length; o++) i.addRange(s[o]);
return u
}
function S(e) {
var t = "data-editor-";
if (e.substring(0, t.length) === t) {
var n = e.substring(t.length);
return n = n.replace(/-([a-z])/ig, function (e, t) {
return t.toUpperCase()
}), n
}
return undefined
}
function x(e, t) {
for (var n in t) t.hasOwnProperty(n) && (e[n] = t[n])
}
function T(e, t) {
var n = {};
x(n, t);
for (var r, i = 0, s = e.attributes, o = s.length; i < o; i++) {
r = s.item(i);
var u = S(r.nodeName);
if (u) {
var a = r.nodeValue;
if (a === "true" || a === "false") a = a === "true";
n[u] = a
}
}
return n
}
function N(e) {
var t = e.ownerDocument,
n = t.defaultView || t.parentWindow,
r;
if (n.getComputedStyle) {
var i = n.getComputedStyle(e, null);
r = i.getPropertyValue("height")
} else e.currentStyle && (r = e.currentStyle.height);
return parseInt(r, 10) || 0
}
function C(r) {
var i = r.parent;
i || (i = "editor"), typeof i == "string" && (i = (r.document || document).getElementById(i));
if (!i && r.className) {
var s = (r.document || document).getElementsByClassName(r.className);
if (s) {
r.className = undefined;
var o = [];
for (var u = 0; u < s.length; u++) r.parent = s[u], o.push(C(r));
return o
}
}
if (!i) throw "no parent";
r = T(i, r);
var a = function () {
return new e.TextView({
parent: i,
model: new n.ProjectionTextModel(new t.TextModel("")),
tabSize: r.tabSize ? r.tabSize : 4,
readonly: r.readonly,
fullSelection: r.fullSelection,
tabMode: r.tabMode,
expandTab: r.expandTab,
themeClass: r.themeClass,
wrapMode: r.wrapMode
})
}, f, d;
r.readonly || (d = {
createContentAssistMode: function (e) {
f = new h.ContentAssist(e.getTextView());
var t = new h.ContentAssistWidget(f);
return new h.ContentAssistMode(f, t)
}
});
var m = {
styler: null,
highlight: function (e, t) {
this.styler && (this.styler.destroy(), this.styler = null);
if (e) {
var n = t.getTextView(),
i = t.getAnnotationModel();
switch (e) {
case "js":
case "java":
case "css":
this.styler = new w.TextStyler(n, e, i), t.setFoldingRulerVisible(r.showFoldingRuler === undefined || r.showFoldingRuler);
break;
case "html":
this.styler = new y.TextMateStyler(n, new b.HtmlGrammar)
}
}
}
}, g = function (e, t, n, r) {
var i = new c.TextActions(e, n);
t.push(i);
var s = new c.SourceCodeActions(e, n, r);
t.push(s)
}, S = new l.Editor({
textViewFactory: a,
undoStackFactory: new c.UndoFactory,
annotationFactory: new c.AnnotationFactory,
lineNumberRulerFactory: new c.LineNumberRulerFactory,
foldingRulerFactory: new c.FoldingRulerFactory,
textDNDFactory: new c.TextDNDFactory,
contentAssistFactory: d,
keyBindingFactory: g,
statusReporter: r.statusReporter,
domNode: i
}),
x = r.contents;
x === undefined && (x = E(i)), x || (x = ""), S.installTextView(), S.setLineNumberRulerVisible(r.showLinesRuler === undefined || r.showLinesRuler), S.setAnnotationRulerVisible(r.showAnnotationRuler === undefined || r.showFoldingRuler), S.setOverviewRulerVisible(r.showOverviewRuler === undefined || r.showOverviewRuler), S.setFoldingRulerVisible(r.showFoldingRuler === undefined || r.showFoldingRuler), S.setInput(r.title, null, x), m.highlight(r.lang, S);
if (f) {
var k = new p.CssContentAssistProvider,
L = new v.JSTemplateContentAssistProvider;
f.addEventListener("Activating", function () {
/css$/.test(r.lang) ? f.setProviders([k]) : /js$/.test(r.lang) && f.setProviders([L])
})
}
if (N(i) <= 50) {
var A = S.getTextView().computeSize().height;
i.style.height = A + "px"
}
return S
}
var k = this.orion ? this.orion.editor : undefined;
if (k)
for (var L = 0; L < arguments.length; L++) x(k, arguments[L]);
return C
});
var r = this.orion || (this.orion = {}),
i = r.editor || (r.editor = {});
i.edit = t("orion/editor/edit"), r.require = t, r.define = n
}(), define("vendor/orion", function (e) {
return function () {
return e.orion
}
}(this)), orion.define("orion/codeComplete", [], function () {
function e(e) {
this.proposals = e || []
}
function n(e, n) {
this.textView = e, this.providers = n, this.state = t.INACTIVE, this.listenerAdded = !1
}
e.prototype.leadingWhitespace = function (e, t) {
var n = "";
t -= 1;
while (t > 0) {
var r = e.charAt(t--);
if (r === "\n" || r === "\r") break;
/\s/.test(r) ? n = r.concat(n) : n = ""
}
return n
}, e.prototype.prefix = function (e, t, n) {
var r;
switch (n) {
case "always":
r = function () {
return !0
};
break;
case "word":
r = function (e) {
return e ? /\s/.test(e) : !1
};
break;
case "line":
r = function (e) {
return e ? /\n|\r/.test(e) : !1
};
break;
default:
r = function () {
return !0
}
}
var i = t;
while (i > 0 && !r(e.substring(i, t))) i -= 1;
return e.substring(i === 0 ? 0 : i + 1, t)
}, e.prototype.context = function (e, t) {
return {
leadingWhitespace: this.leadingWhitespace(e, t),
before: e.substring(0, t),
after: e.substring(t, e.length),
word: this.prefix(e, t, "word"),
line: this.prefix(e, t, "line")
}
}, e.prototype.clamp = function (e, t) {
return t === "undefined" || t < 0 ? t = 0 : t > e.length && (t = e.length), t
}, e.prototype.propose = function (e, t) {
t = this.clamp(e, t);
var n = this.context(e, t),
r = null;
for (var i = 0; r == null && i < this.proposals.length; i++) {
var s = this.proposals[i];
s.accept(n) && (r = s.apply(e, t, n))
}
return r
};
var t = {
INACTIVE: 1,
EVALUATING: 2
};
return n.prototype.activate = function () {
this.listenerAdded || (this.textView.addEventListener("ModelChanged", this.onModelChanged.bind(this)), this.listenerAdded = !0), this.state === t.INACTIVE && this.setState(t.EVALUATING)
}, n.prototype.deactivate = function () {
this.setState(t.INACTIVE)
}, n.prototype.setState = function (e) {
if (!e || e !== t.EVALUATING && e !== t.INACTIVE) return;
this.state = e
}, n.prototype.onModelChanged = function (e) {
if (this.state === t.EVALUATING) {
var n = this.textView.getModel().getCharCount() || 0,
r = e.start,
i = e.addedCharCount,
s = e.removedCharCount,
o = s === 0 && i > 0 && (i === 1 || i !== n);
o && this.evaluate(r + i)
}
}, n.prototype.evaluate = function (e) {
if (!(e && e >= 0)) return;
var t = this.textView.getText(),
n = this.providers,
r = null;
for (var i = 0; r == null && i < n.length; i++) r = n[i].propose(t, e);
r && this.apply(r)
}, n.prototype.apply = function (e) {
if (!e || !e.text) return;
var n = this.textView;
this.setState(t.INACTIVE), n.setText(e.text, e.start, e.end), setTimeout(function () {
var t = e.selectPosition,
r = e.caretOffset;
if (t) {
var i = t.start,
s = t.end;
i && s && n.setSelection(i, s)
} else r && n.setCaretOffset(r)
}, 0), this.setState(t.EVALUATING)
}, {
CodeComplete: n,
CodeCompleteProvider: e
}
}), define("plugins/orion-codeComplete", function () {}), orion.define("orion/codeComplete/common", [], function () {
function e() {}
function t() {}
function n() {}
function r() {}
function i() {}
function s() {}
function o() {}
function u() {}
function a() {}
function f() {}
return e.prototype.accept = function (e) {
return /\{$/.test(e.word)
}, e.prototype.apply = function (e, t) {
var n = {};
return n.start = t, n.end = t, n.text = "}", n
}, t.prototype.accept = function (e) {
return /\{[ \t]*\n[ \t]*$/.test(e.before)
}, t.prototype.apply = function (e, t, n) {
var r = {};
return r.start = t, r.end = t, r.text = " \n" + n.leadingWhitespace, r.caretOffset = t + 1, r
}, n.prototype.accept = function (e) {
return /\{\}$/.test(e.word) && /^\}/.test(e.after)
}, n.prototype.apply = function (e, t) {
var n = {};
return n.start = t - 1, n.end = t + 1, n.text = "}", n
}, r.prototype.accept = function (e) {
return /\[$/.test(e.word)
}, r.prototype.apply = function (e, t) {
var n = {};
return n.start = t, n.end = t, n.text = "]", n
}, i.prototype.accept = function (e) {
return /\[[ \t]*\n[ \t]*$/.test(e.before)
}, i.prototype.apply = function (e, t, n) {
var r = {};
return r.start = t, r.end = t, r.text = " \n" + n.leadingWhitespace, r.caretOffset = t + 1, r
}, s.prototype.accept = function (e) {
return /\[\]$/.test(e.word) && /^\]/.test(e.after)
}, s.prototype.apply = function (e, t) {
var n = {};
return n.start = t - 1, n.end = t + 1, n.text = "]", n
}, o.prototype.accept = function (e) {
return /\($/.test(e.word)
}, o.prototype.apply = function (e, t) {
var n = {};
return n.start = t, n.end = t, n.text = ")", n
}, u.prototype.accept = function (e) {
return /\(\)$/.test(e.word) && /^\)/.test(e.after)
}, u.prototype.apply = function (e, t) {
var n = {};
return n.start = t - 1, n.end = t + 1, n.text = ")", n
}, a.prototype.accept = function (e) {
return /'$/.test(e.word)
}, a.prototype.apply = function (e, t) {
var n = {};
return n.start = t, n.end = t, n.text = "'", n
}, f.prototype.accept = function (e) {
return /"$/.test(e.word)
}, f.prototype.apply = function (e, t) {
var n = {};
return n.start = t, n.end = t, n.text = '"', n
}, {
BraceProposal: e,
BraceNewLineProposal: t,
BraceCloseDupProposal: n,
BracketProposal: r,
BracketNewLineProposal: i,
BracketCloseDupProposal: s,
ParenthesesProposal: o,
ParenthesesCloseDupProposal: u,
SingleQuoteProposal: a,
DoubleQuoteProposal: f,
CommonProposals: [new e, new t, new n, new r, new i, new s, new o, new u, new a, new f]
}
}), define("plugins/orion-codeComplete-common", function () {}), orion.define("orion/codeComplete/css", ["orion/codeComplete/common"], function (e) {
return [new e.BraceProposal, new e.BraceNewLineProposal, new e.BraceCloseDupProposal, new e.BracketProposal, new e.BracketNewLineProposal, new e.BracketCloseDupProposal, new e.ParenthesesProposal, new e.ParenthesesCloseDupProposal, new e.SingleQuoteProposal, new e.DoubleQuoteProposal]
}), define("plugins/orion-codeComplete-css", function () {}), orion.define("orion/codeComplete/html", ["orion/codeComplete/common"], function (e) {
function t() {}
function n() {}
return t.prototype.accept = function (e) {
return /^.*?<[\t ]*([A-z0-9]+)(?!.*?\/[\t ]*\>$).*?>$/.test(e.line)
}, t.prototype.apply = function (e, t, n) {
var r = null,
i = /^.*?(<[\t ]*[A-z0-9]+(?!.*?\/[\t ]*>$).*?>)+$/.exec(n.line),
s = i[1];
if (s) {
var o = /^.*?<[\t ]*([A-z0-9]+)(?!.*?\/[\t ]*>$).*?>$/.exec(s),
u = o[1];
u && (r = {
start: t,
end: t,
text: "</" + u + ">",
caretOffset: t
})
}
return r
}, n.prototype.accept = function (e) {
return (new RegExp("[ ]*<[ ]*([A-z0-9]+){1}([ ]+([A-z0-9]+){1}([ ]*=[ ]*(['\"].*['\"]))?)*(?![ ]*/[ ]*>)([ ]*>)[ ]*\n[ ]*$")).test(e.before)
}, n.prototype.apply = function (e, t, n) {
return {
start: t,
end: t,
text: " \n" + n.leadingWhitespace,
caretOffset: t + 1
}
}, [new e.BraceProposal, new e.BraceNewLineProposal, new e.BraceCloseDupProposal, new e.BracketProposal, new e.BracketNewLineProposal, new e.BracketCloseDupProposal, new e.ParenthesesProposal, new e.ParenthesesCloseDupProposal, new e.SingleQuoteProposal, new e.DoubleQuoteProposal, new t, new n]
}), define("plugins/orion-codeComplete-html", function () {}), orion.define("orion/codeComplete/javascript", ["orion/codeComplete/common"], function (e) {
function t() {}
function n() {}
return t.inLineComment = function (e) {
return /([\t ]*)\/\//.test(e.line)
}, t.inBlockComment = function (e) {
var t = !1,
n = e.before;
if (n && n.length > 0) {
var r = n.match(/\/\*/g) || [],
i = n.match(/[^\/]\*\//g) || [];
t = r.length > i.length
}
return t
}, n.prototype.accept = function (e) {
return !t.inLineComment(e) && !t.inBlockComment(e) && /(^|\s+)if$/.test(e.line)
}, n.prototype.apply = function (e, t, n) {
var r = {};
return r.start = t, r.end = t, r.text = " (condition) {\n" + n.leadingWhitespace + " \n" + n.leadingWhitespace + "} ", r.selectPosition = {
start: t + 2,
end: t + 11
}, r
}, [new e.BraceProposal, new e.BraceNewLineProposal, new e.BraceCloseDupProposal, new e.BracketProposal, new e.BracketNewLineProposal, new e.BracketCloseDupProposal, new e.ParenthesesProposal, new e.ParenthesesCloseDupProposal, new e.SingleQuoteProposal, new e.DoubleQuoteProposal, new n]
}), define("plugins/orion-codeComplete-javascript", function () {}), orion.define("orion/codeComplete/python", ["orion/codeComplete/common"], function (e) {
function t() {}
return t.prototype.accept = function (e) {
return /:\n$/.test(e.before)
}, t.prototype.apply = function (e, t) {
var n = {
start: t,
end: t
};
return n.text = " ", n.caretOffset = t + 1, n
}, [new e.BraceProposal, new e.BraceNewLineProposal, new e.BraceCloseDupProposal, new e.BracketProposal, new e.BracketNewLineProposal, new e.BracketCloseDupProposal, new e.ParenthesesProposal, new e.ParenthesesCloseDupProposal, new e.SingleQuoteProposal, new e.DoubleQuoteProposal, new t]
}), define("plugins/orion-codeComplete-python", function () {}), orion.define("orion/codeComplete/ruby", ["orion/codeComplete/common"], function (e) {
function t() {}
return t.prototype.accept = function (e) {
return /do\n$/.test(e.before)
}, t.prototype.apply = function (e, t) {
var n = {};
return n.start = t, n.end = t, n.text = " \nend\n", n.caretOffset = t + 1, n
}, [new e.BraceProposal, new e.BraceNewLineProposal, new e.BraceCloseDupProposal, new e.BracketProposal, new e.BracketNewLineProposal, new e.BracketCloseDupProposal, new e.ParenthesesProposal, new e.ParenthesesCloseDupProposal, new e.SingleQuoteProposal, new e.DoubleQuoteProposal, new t]
}), define("plugins/orion-codeComplete-ruby", function () {}), orion.define("orion/editor/customEditor", ["orion/editor/textView", "orion/editor/textModel", "orion/editor/projectionTextModel", "orion/editor/eventTarget", "orion/editor/keyBinding", "orion/editor/rulers", "orion/editor/annotations", "orion/editor/tooltip", "orion/editor/undoStack", "orion/editor/textDND", "orion/editor/editor", "orion/editor/editorFeatures", "orion/editor/contentAssist", "orion/editor/cssContentAssist", "orion/editor/htmlContentAssist", "orion/editor/jsTemplateContentAssist", "orion/editor/AsyncStyler", "orion/editor/mirror", "orion/codeComplete", "orion/codeComplete/common", "orion/codeComplete/css", "orion/codeComplete/html", "orion/codeComplete/javascript", "orion/codeComplete/python", "orion/codeComplete/ruby"], function (e, t, n, r, i, s, o, u, a, f, l, c, h, p, d, v, m, g, y, b, w, E, S, x, T) {
function N(e) {
var t = e.ownerDocument,
n = t.defaultView || t.parentWindow;
if (!n.getSelection) return e.innerText || e.textContent;
var r = t.createRange();
r.selectNode(e);
var i = n.getSelection(),
s = [],
o;
for (o = 0; o < i.rangeCount; o++) s.push(i.getRangeAt(o));
i.removeAllRanges(), i.addRange(r);
var u = i.toString();
i.removeAllRanges();
for (o = 0; o < s.length; o++) i.addRange(s[o]);
return u
}
function C(e) {
var t = "data-editor-";
if (e.substring(0, t.length) === t) {
var n = e.substring(t.length);
return n = n.replace(/-([a-z])/ig, function (e, t) {
return t.toUpperCase()
}), n
}
return undefined
}
function k(e, t) {
for (var n in t) t.hasOwnProperty(n) && (e[n] = t[n])
}
function L(e, t) {
var n = {};
k(n, t);
for (var r, i = 0, s = e.attributes, o = s.length; i < o; i++) {
r = s.item(i);
var u = C(r.nodeName);
if (u) {
var a = r.nodeValue;
if (a === "true" || a === "false") a = a === "true";
n[u] = a
}
}
return n
}
function A(e) {
var t = e.ownerDocument,
n = t.defaultView || t.parentWindow,
r;
if (n.getComputedStyle) {
var i = n.getComputedStyle(e, null);
r = i.getPropertyValue("height")
} else e.currentStyle && (r = e.currentStyle.height);
return parseInt(r, 10) || 0
}
function O(r) {
var i = r.parent;
i || (i = "editor"), typeof i == "string" && (i = (r.document || document).getElementById(i));
if (!i && r.className) {
var s = (r.document || document).getElementsByClassName(r.className);
if (s) {
r.className = undefined;
var o = [];
for (var u = 0; u < s.length; u++) r.parent = s[u], o.push(O(r));
return o
}
}
if (!i) throw "no parent";
r = L(i, r);
var a = function () {
return new e.TextView({
parent: i,
model: new n.ProjectionTextModel(new t.TextModel("")),
tabSize: r.tabSize ? r.tabSize : 4,
readonly: r.readonly,
fullSelection: r.fullSelection,
tabMode: r.tabMode,
expandTab: r.expandTab,
themeClass: r.themeClass,
wrapMode: r.wrapMode
})
}, f, p;
r.readonly || (p = {
createContentAssistMode: function (e) {
f = new h.ContentAssist(e.getTextView());
var t = new h.ContentAssistWidget(f);
return new h.ContentAssistMode(f, t)
}
});
var d = {
styler: null,
highlight: function (e, t) {
this.styler && (this.styler.destroy(), this.styler = null);
if (e) {
var n = t.getTextView(),
r = t.getAnnotationModel();
switch (e) {
case "js":
case "javascript":
case "css":
case "html":
case "htmlmixed":
case "ruby":
case "python":
case "php":
this.styler = new g.CodeMirrorStyler(n, window.CodeMirror, r), this.styler.modeApplier.setMode(e, !0)
}
}
}
}, v = function (e, t, n, r) {
var i = new c.TextActions(e, n);
t.push(i);
var s = new c.SourceCodeActions(e, n, r);
t.push(s)
}, m = new l.Editor({
textViewFactory: a,
undoStackFactory: new c.UndoFactory,
annotationFactory: new c.AnnotationFactory,
lineNumberRulerFactory: new c.LineNumberRulerFactory,
foldingRulerFactory: new c.FoldingRulerFactory,
textDNDFactory: new c.TextDNDFactory,
contentAssistFactory: p,
keyBindingFactory: v,
statusReporter: r.statusReporter,
domNode: i
}),
C = r.contents;
C === undefined && (C = N(i)), C || (C = ""), m.installTextView(), m.setLineNumberRulerVisible(r.showLinesRuler === undefined || r.showLinesRuler), m.setAnnotationRulerVisible(r.showAnnotationRuler === undefined || r.showFoldingRuler), m.setOverviewRulerVisible(r.showOverviewRuler === undefined || r.showOverviewRuler), m.setFoldingRulerVisible(r.showFoldingRuler === undefined || r.showFoldingRuler), m.setInput(r.title, null, C), d.highlight(r.lang, m), m.syntaxHighlighter = d;
var k = r.lang ? r.lang : "common",
M = m.getTextView(),
_ = null;
switch (k) {
case "css":
_ = w;
break;
case "htmlmixed":
case "html":
_ = E;
break;
case "javascript":
case "js":
_ = S;
break;
case "python":
case "py":
_ = x;
break;
case "ruby":
case "rb":
_ = T;
break;
case "common":
_ = b.CommonProposals
}
if (_ != null) {
var D = new y.CodeCompleteProvider(_),
P = new y.CodeComplete(M, [D]);
P.activate()
}
if (A(i) <= 50) {
var H = m.getTextView().computeSize().height;
i.style.height = H + "px"
}
return m
}
var M = this.orion ? this.orion.editor : undefined;
if (M)
for (var _ = 0; _ < arguments.length; _++) k(M, arguments[_]);
return O
}.bind(window)), define("plugins/orion-custom-editor", function () {}),
function () {
var e = new orion.editor.Mirror;
e.defineMIME("text/plain", "null"), e.defineMode("null", function () {
return {
token: function (e) {
e.skipToEnd()
}
}
}), e.startState = function (e, t, n) {
return e.startState ? e.startState(t, n) : !0
}, window.CodeMirror = e
}(), define("plugins/orion-codemirror", function () {}), CodeMirror.defineMode("clike", function (e, t) {
function p(e, t) {
var n = e.next();
if (f[n]) {
var r = f[n](e, t);
if (r !== !1) return r
}
if (n == '"' || n == "'") return t.tokenize = d(n), t.tokenize(e, t);
if (/[\[\]{}\(\),;\:\.]/.test(n)) return h = n, null;
if (/\d/.test(n)) return e.eatWhile(/[\w\.]/), "number";
if (n == "/") {
if (e.eat("*")) return t.tokenize = v, v(e, t);
if (e.eat("/")) return e.skipToEnd(), "comment"
}
if (c.test(n)) return e.eatWhile(c), "operator";
e.eatWhile(/[\w\$_]/);
var i = e.current();
return s.propertyIsEnumerable(i) ? (u.propertyIsEnumerable(i) && (h = "newstatement"), "keyword") : o.propertyIsEnumerable(i) ? (u.propertyIsEnumerable(i) && (h = "newstatement"), "builtin") : a.propertyIsEnumerable(i) ? "atom" : "variable"
}
function d(e) {
return function (t, n) {
var r = !1,
i, s = !1;
while ((i = t.next()) != null) {
if (i == e && !r) {
s = !0;
break
}
r = !r && i == "\\"
}
if (s || !r && !l) n.tokenize = null;
return "string"
}
}
function v(e, t) {
var n = !1,
r;
while (r = e.next()) {
if (r == "/" && n) {
t.tokenize = null;
break
}
n = r == "*"
}
return "comment"
}
function m(e, t, n, r, i) {
this.indented = e, this.column = t, this.type = n, this.align = r, this.prev = i
}
function g(e, t, n) {
var r = e.indented;
return e.context && e.context.type == "statement" && (r = e.context.indented), e.context = new m(r, t, n, null, e.context)
}
function y(e) {
var t = e.context.type;
if (t == ")" || t == "]" || t == "}") e.indented = e.context.indented;
return e.context = e.context.prev
}
var n = e.indentUnit,
r = t.statementIndentUnit || n,
i = t.dontAlignCalls,
s = t.keywords || {}, o = t.builtin || {}, u = t.blockKeywords || {}, a = t.atoms || {}, f = t.hooks || {}, l = t.multiLineStrings,
c = /[+\-*&%=<>!?|\/]/,
h;
return {
startState: function (e) {
return {
tokenize: null,
context: new m((e || 0) - n, 0, "top", !1),
indented: 0,
startOfLine: !0
}
},
token: function (e, t) {
var n = t.context;
e.sol() && (n.align == null && (n.align = !1), t.indented = e.indentation(), t.startOfLine = !0);
if (e.eatSpace()) return null;
h = null;
var r = (t.tokenize || p)(e, t);
if (r == "comment" || r == "meta") return r;
n.align == null && (n.align = !0);
if (h != ";" && h != ":" && h != "," || n.type != "statement")
if (h == "{") g(t, e.column(), "}");
else if (h == "[") g(t, e.column(), "]");
else if (h == "(") g(t, e.column(), ")");
else if (h == "}") {
while (n.type == "statement") n = y(t);
n.type == "}" && (n = y(t));
while (n.type == "statement") n = y(t)
} else h == n.type ? y(t) : ((n.type == "}" || n.type == "top") && h != ";" || n.type == "statement" && h == "newstatement") && g(t, e.column(), "statement");
else y(t);
return t.startOfLine = !1, r
},
indent: function (e, t) {
if (e.tokenize != p && e.tokenize != null) return CodeMirror.Pass;
var s = e.context,
o = t && t.charAt(0);
s.type == "statement" && o == "}" && (s = s.prev);
var u = o == s.type;
return s.type == "statement" ? s.indented + (o == "{" ? 0 : r) : s.align && (!i || s.type != ")") ? s.column + (u ? 0 : 1) : s.type == ")" && !u ? s.indented + r : s.indented + (u ? 0 : n)
},
electricChars: "{}",
blockCommentStart: "/*",
blockCommentEnd: "*/",
lineComment: "//"
}
}),
function () {
function e(e) {
var t = {}, n = e.split(" ");
for (var r = 0; r < n.length; ++r) t[n[r]] = !0;
return t
}
function n(e, t) {
if (!t.startOfLine) return !1;
for (;;) {
if (!e.skipTo("\\")) {
e.skipToEnd(), t.tokenize = null;
break
}
e.next();
if (e.eol()) {
t.tokenize = n;
break
}
}
return "meta"
}
function r(e, t) {
var n;
while ((n = e.next()) != null)
if (n == '"' && !e.eat('"')) {
t.tokenize = null;
break
}
return "string"
}
function i(e, t) {
for (var n = 0; n < e.length; ++n) CodeMirror.defineMIME(e[n], t)
}
var t = "auto if break int case long char register continue return default short do sizeof double static else struct entry switch extern typedef float union for unsigned goto while enum void const signed volatile";
i(["text/x-csrc", "text/x-c", "text/x-chdr"], {
name: "clike",
keywords: e(t),
blockKeywords: e("case do else for if switch while struct"),
atoms: e("null"),
hooks: {
"#": n
}
}), i(["text/x-c++src", "text/x-c++hdr"], {
name: "clike",
keywords: e(t + " asm dynamic_cast namespace reinterpret_cast try bool explicit new " + "static_cast typeid catch operator template typename class friend private " + "this using const_cast inline public throw virtual delete mutable protected " + "wchar_t"),
blockKeywords: e("catch class do else finally for if struct switch try while"),
atoms: e("true false null"),
hooks: {
"#": n
}
}), CodeMirror.defineMIME("text/x-java", {
name: "clike",
keywords: e("abstract assert boolean break byte case catch char class const continue default do double else enum extends final finally float for goto if implements import instanceof int interface long native new package private protected public return short static strictfp super switch synchronized this throw throws transient try void volatile while"),
blockKeywords: e("catch class do else finally for if switch try while"),
atoms: e("true false null"),
hooks: {
"@": function (e) {
return e.eatWhile(/[\w\$_]/), "meta"
}
}
}), CodeMirror.defineMIME("text/x-csharp", {
name: "clike",
keywords: e("abstract as base break case catch checked class const continue default delegate do else enum event explicit extern finally fixed for foreach goto if implicit in interface internal is lock namespace new operator out override params private protected public readonly ref return sealed sizeof stackalloc static struct switch this throw try typeof unchecked unsafe using virtual void volatile while add alias ascending descending dynamic from get global group into join let orderby partial remove select set value var yield"),
blockKeywords: e("catch class do else finally for foreach if struct switch try while"),
builtin: e("Boolean Byte Char DateTime DateTimeOffset Decimal Double Guid Int16 Int32 Int64 Object SByte Single String TimeSpan UInt16 UInt32 UInt64 bool byte char decimal double short int long object sbyte float string ushort uint ulong"),
atoms: e("true false null"),
hooks: {
"@": function (e, t) {
return e.eat('"') ? (t.tokenize = r, r(e, t)) : (e.eatWhile(/[\w\$_]/), "meta")
}
}
}), CodeMirror.defineMIME("text/x-scala", {
name: "clike",
keywords: e("abstract case catch class def do else extends false final finally for forSome if implicit import lazy match new null object override package private protected return sealed super this throw trait try trye type val var while with yield _ : = => <- <: <% >: # @ assert assume require print println printf readLine readBoolean readByte readShort readChar readInt readLong readFloat readDouble AnyVal App Application Array BufferedIterator BigDecimal BigInt Char Console Either Enumeration Equiv Error Exception Fractional Function IndexedSeq Integral Iterable Iterator List Map Numeric Nil NotNull Option Ordered Ordering PartialFunction PartialOrdering Product Proxy Range Responder Seq Serializable Set Specializable Stream StringBuilder StringContext Symbol Throwable Traversable TraversableOnce Tuple Unit Vector :: #:: Boolean Byte Character CharSequence Class ClassLoader Cloneable Comparable Compiler Double Exception Float Integer Long Math Number Object Package Pair Process Runtime Runnable SecurityManager Short StackTraceElement StrictMath String StringBuffer System Thread ThreadGroup ThreadLocal Throwable Triple Void"),
blockKeywords: e("catch class do else finally for forSome if match switch try while"),
atoms: e("true false null"),
hooks: {
"@": function (e) {
return e.eatWhile(/[\w\$_]/), "meta"
}
}
})
}(), define("vendor/codemirror_modes/clike", function () {}), CodeMirror.defineMode("javascript", function (e, t) {
function u(e, t, n) {
return t.tokenize = n, n(e, t)
}
function a(e, t) {
var n = !1,
r;
while ((r = e.next()) != null) {
if (r == t && !n) return !1;
n = !n && r == "\\"
}
return n
}
function c(e, t, n) {
return f = e, l = n, t
}
function h(e, t) {
var n = e.next();
if (n == '"' || n == "'") return u(e, t, p(n));
if (/[\[\]{}\(\),;\:\.]/.test(n)) return c(n);
if (n == "0" && e.eat(/x/i)) return e.eatWhile(/[\da-f]/i), c("number", "number");
if (/\d/.test(n) || n == "-" && e.eat(/\d/)) return e.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/), c("number", "number");
if (n == "/") return e.eat("*") ? u(e, t, d) : e.eat("/") ? (e.skipToEnd(), c("comment", "comment")) : t.lastType == "operator" || t.lastType == "keyword c" || /^[\[{}\(,;:]$/.test(t.lastType) ? (a(e, "/"), e.eatWhile(/[gimy]/), c("regexp", "string-2")) : (e.eatWhile(o), c("operator", null, e.current()));
if (n == "#") return e.skipToEnd(), c("error", "error");
if (o.test(n)) return e.eatWhile(o), c("operator", null, e.current());
e.eatWhile(/[\w\$_]/);
var r = e.current(),
i = s.propertyIsEnumerable(r) && s[r];
return i && t.lastType != "." ? c(i.type, i.style, r) : c("variable", "variable", r)
}
function p(e) {
return function (t, n) {
return a(t, e) || (n.tokenize = h), c("string", "string")
}
}
function d(e, t) {
var n = !1,
r;
while (r = e.next()) {
if (r == "/" && n) {
t.tokenize = h;
break
}
n = r == "*"
}
return c("comment", "comment")
}
function m(e, t, n, r, i, s) {
this.indented = e, this.column = t, this.type = n, this.prev = i, this.info = s, r != null && (this.align = r)
}
function g(e, t) {
for (var n = e.localVars; n; n = n.next)
if (n.name == t) return !0
}
function y(e, t, n, i, s) {
var o = e.cc;
b.state = e, b.stream = s, b.marked = null, b.cc = o, e.lexical.hasOwnProperty("align") || (e.lexical.align = !0);
for (;;) {
var u = o.length ? o.pop() : r ? O : A;
if (u(n, i)) {
while (o.length && o[o.length - 1].lex) o.pop()();
return b.marked ? b.marked : n == "variable" && g(e, i) ? "variable-2" : t
}
}
}
function w() {
for (var e = arguments.length - 1; e >= 0; e--) b.cc.push(arguments[e])
}
function E() {
return w.apply(null, arguments), !0
}
function S(e) {
function t(t) {
for (var n = t; n; n = n.next)
if (n.name == e) return !0;
return !1
}
var n = b.state;
if (n.context) {
b.marked = "def";
if (t(n.localVars)) return;
n.localVars = {
name: e,
next: n.localVars
}
} else {
if (t(n.globalVars)) return;
n.globalVars = {
name: e,
next: n.globalVars
}
}
}
function T() {
b.state.context = {
prev: b.state.context,
vars: b.state.localVars
}, b.state.localVars = x
}
function N() {
b.state.localVars = b.state.context.vars, b.state.context = b.state.context.prev
}
function C(e, t) {
var n = function () {
var n = b.state;
n.lexical = new m(n.indented, b.stream.column(), e, null, n.lexical, t)
};
return n.lex = !0, n
}
function k() {
var e = b.state;
e.lexical.prev && (e.lexical.type == ")" && (e.indented = e.lexical.indented), e.lexical = e.lexical.prev)
}
function L(e) {
return function (t) {
return t == e ? E() : e == ";" ? w() : E(arguments.callee)
}
}
function A(e) {
return e == "var" ? E(C("vardef"), W, L(";"), k) : e == "keyword a" ? E(C("form"), O, A, k) : e == "keyword b" ? E(C("form"), A, k) : e == "{" ? E(C("}"), R, k) : e == ";" ? E() : e == "if" ? E(C("form"), O, A, k, V(b.state.indented)) : e == "function" ? E(G) : e == "for" ? E(C("form"), L("("), C(")"), $, L(")"), k, A, k) : e == "variable" ? E(C("stat"), B) : e == "switch" ? E(C("form"), O, C("}", "switch"), L("{"), R, k, k) : e == "case" ? E(O, L(":")) : e == "default" ? E(L(":")) : e == "catch" ? E(C("form"), T, L("("), Y, L(")"), A, k, N) : w(C("stat"), O, L(";"), k)
}
function O(e) {
return _(e, P)
}
function M(e) {
return _(e, H)
}
function _(e, t) {
return v.hasOwnProperty(e) ? E(t) : e == "function" ? E(G) : e == "keyword c" ? E(D) : e == "(" ? E(C(")"), D, L(")"), k, t) : e == "operator" ? E(O) : e == "[" ? E(C("]"), q(M, "]"), k, t) : e == "{" ? E(C("}"), q(F, "}"), k, t) : E()
}
function D(e) {
return e.match(/[;\}\)\],]/) ? w() : w(O)
}
function P(e, t) {
return e == "," ? w() : H(e, t, P)
}
function H(e, t, n) {
n || (n = H);
if (e == "operator") return /\+\+|--/.test(t) ? E(n) : t == "?" ? E(O, L(":"), O) : E(O);
if (e == ";") return;
if (e == "(") return E(C(")", "call"), q(M, ")"), k, n);
if (e == ".") return E(j, n);
if (e == "[") return E(C("]"), O, L("]"), k, n)
}
function B(e) {
return e == ":" ? E(k, A) : w(P, L(";"), k)
}
function j(e) {
if (e == "variable") return b.marked = "property", E()
}
function F(e, t) {
if (e == "variable") {
b.marked = "property";
if (t == "get" || t == "set") return E(I)
} else if (e == "number" || e == "string") b.marked = e + " property";
if (v.hasOwnProperty(e)) return E(L(":"), M)
}
function I(e) {
return e == ":" ? E(O) : e != "variable" ? E(L(":"), O) : (b.marked = "property", E(G))
}
function q(e, t) {
function n(r) {
if (r == ",") {
var i = b.state.lexical;
return i.info == "call" && (i.pos = (i.pos || 0) + 1), E(e, n)
}
return r == t ? E() : E(L(t))
}
return function (r) {
return r == t ? E() : w(e, n)
}
}
function R(e) {
return e == "}" ? E() : w(A, R)
}
function U(e) {
return e == ":" ? E(z) : w()
}
function z(e) {
return e == "variable" ? (b.marked = "variable-3", E()) : w()
}
function W(e, t) {
return e == "variable" ? (S(t), i ? E(U, X) : E(X)) : w()
}
function X(e, t) {
if (t == "=") return E(M, X);
if (e == ",") return E(W)
}
function V(e) {
return function (t, n) {
return t == "keyword b" && n == "else" ? (b.state.lexical = new m(e, 0, "form", null, b.state.lexical), E(A, k)) : w()
}
}
function $(e) {
return e == "var" ? E(W, L(";"), K) : e == ";" ? E(K) : e == "variable" ? E(J) : w(O, L(";"), K)
}
function J(e, t) {
return t == "in" ? E(O) : E(P, K)
}
function K(e, t) {
return e == ";" ? E(Q) : t == "in" ? E(O) : w(O, L(";"), Q)
}
function Q(e) {
e != ")" && E(O)
}
function G(e, t) {
if (e == "variable") return S(t), E(G);
if (e == "(") return E(C(")"), T, q(Y, ")"), k, A, N)
}
function Y(e, t) {
if (e == "variable") return S(t), i ? E(U) : E()
}
var n = e.indentUnit,
r = t.json,
i = t.typescript,
s = function () {
function e(e) {
return {
type: e,
style: "keyword"
}
}
var t = e("keyword a"),
n = e("keyword b"),
r = e("keyword c"),
s = e("operator"),
o = {
type: "atom",
style: "atom"
}, u = {
"if": e("if"),
"while": t,
"with": t,
"else": n,
"do": n,
"try": n,
"finally": n,
"return": r,
"break": r,
"continue": r,
"new": r,
"delete": r,
"throw": r,
"var": e("var"),
"const": e("var"),
let: e("var"),
"function": e("function"),
"catch": e("catch"),
"for": e("for"),
"switch": e("switch"),
"case": e("case"),
"default": e("default"),
"in": s,
"typeof": s,
"instanceof": s,
"true": o,
"false": o,
"null": o,
"undefined": o,
NaN: o,
Infinity: o,
"this": e("this")
};
if (i) {
var a = {
type: "variable",
style: "variable-3"
}, f = {
"interface": e("interface"),
"class": e("class"),
"extends": e("extends"),
constructor: e("constructor"),
"public": e("public"),
"private": e("private"),
"protected": e("protected"),
"static": e("static"),
"super": e("super"),
string: a,
number: a,
bool: a,
any: a
};
for (var l in f) u[l] = f[l]
}
return u
}(),
o = /[+\-*&%=<>!?|~^]/,
f, l, v = {
atom: !0,
number: !0,
variable: !0,
string: !0,
regexp: !0,
"this": !0
}, b = {
state: null,
column: null,
marked: null,
cc: null
}, x = {
name: "this",
next: {
name: "arguments"
}
};
return k.lex = !0, {
startState: function (e) {
return {
tokenize: h,
lastType: null,
cc: [],
lexical: new m((e || 0) - n, 0, "block", !1),
localVars: t.localVars,
globalVars: t.globalVars,
context: t.localVars && {
vars: t.localVars
},
indented: 0
}
},
token: function (e, t) {
e.sol() && (t.lexical.hasOwnProperty("align") || (t.lexical.align = !1), t.indented = e.indentation());
if (t.tokenize != d && e.eatSpace()) return null;
var n = t.tokenize(e, t);
return f == "comment" ? n : (t.lastType = f != "operator" || l != "++" && l != "--" ? f : "incdec", y(t, n, f, l, e))
},
indent: function (e, r) {
if (e.tokenize == d) return CodeMirror.Pass;
if (e.tokenize != h) return 0;
var i = r && r.charAt(0),
s = e.lexical;
s.type == "stat" && i == "}" && (s = s.prev);
var o = s.type,
u = i == o;
if (t.statementIndent != null) {
o == ")" && s.prev && s.prev.type == "stat" && (s = s.prev);
if (s.type == "stat") return s.indented + t.statementIndent
}
return o == "vardef" ? s.indented + (e.lastType == "operator" || e.lastType == "," ? 4 : 0) : o == "form" && i == "{" ? s.indented : o == "form" ? s.indented + n : o == "stat" ? s.indented + (e.lastType == "operator" || e.lastType == "," ? n : 0) : s.info == "switch" && !u ? s.indented + (/^(?:case|default)\b/.test(r) ? n : 2 * n) : s.align ? s.column + (u ? 0 : 1) : s.indented + (u ? 0 : n)
},
electricChars: ":{}",
blockCommentStart: r ? null : "/*",
blockCommentEnd: r ? null : "*/",
lineComment: r ? null : "//",
jsonMode: r
}
}), CodeMirror.defineMIME("text/javascript", "javascript"), CodeMirror.defineMIME("text/ecmascript", "javascript"), CodeMirror.defineMIME("application/javascript", "javascript"), CodeMirror.defineMIME("application/ecmascript", "javascript"), CodeMirror.defineMIME("application/json", {
name: "javascript",
json: !0
}), CodeMirror.defineMIME("application/x-json", {
name: "javascript",
json: !0
}), CodeMirror.defineMIME("text/typescript", {
name: "javascript",
typescript: !0
}), CodeMirror.defineMIME("application/typescript", {
name: "javascript",
typescript: !0
}), define("vendor/codemirror_modes/javascript", function () {}), CodeMirror.defineMode("python", function (e, t) {
function r(e) {
return new RegExp("^((" + e.join(")|(") + "))\\b")
}
function b(e, t) {
if (e.sol()) {
var r = t.scopes[0].offset;
if (e.eatSpace()) {
var c = e.indentation();
return c > r ? y = "indent" : c < r && (y = "dedent"), null
}
r > 0 && S(e, t)
}
if (e.eatSpace()) return null;
var h = e.peek();
if (h === "#") return e.skipToEnd(), "comment";
if (e.match(/^[0-9\.]/, !1)) {
var p = !1;
e.match(/^\d*\.\d+(e[\+\-]?\d+)?/i) && (p = !0), e.match(/^\d+\.\d*/) && (p = !0), e.match(/^\.\d+/) && (p = !0);
if (p) return e.eat(/J/i), "number";
var d = !1;
e.match(/^0x[0-9a-f]+/i) && (d = !0), e.match(/^0b[01]+/i) && (d = !0), e.match(/^0o[0-7]+/i) && (d = !0), e.match(/^[1-9]\d*(e[\+\-]?\d+)?/) && (e.eat(/J/i), d = !0), e.match(/^0(?![\dx])/i) && (d = !0);
if (d) return e.eat(/L/i), "number"
}
return e.match(v) ? (t.tokenize = w(e.current()), t.tokenize(e, t)) : e.match(a) || e.match(u) ? null : e.match(o) || e.match(i) || e.match(l) ? "operator" : e.match(s) ? null : e.match(m) ? "keyword" : e.match(g) ? "builtin" : e.match(f) ? "variable" : (e.next(), n)
}
function w(e) {
function s(s, o) {
while (!s.eol()) {
s.eatWhile(/[^'"\\]/);
if (s.eat("\\")) {
s.next();
if (r && s.eol()) return i
} else {
if (s.match(e)) return o.tokenize = b, i;
s.eat(/['"]/)
}
}
if (r) {
if (t.singleLineStringErrors) return n;
o.tokenize = b
}
return i
}
while ("rub".indexOf(e.charAt(0).toLowerCase()) >= 0) e = e.substr(1);
var r = e.length == 1,
i = "string";
return s.isString = !0, s
}
function E(t, n, r) {
r = r || "py";
var i = 0;
if (r === "py") {
if (n.scopes[0].type !== "py") {
n.scopes[0].offset = t.indentation();
return
}
for (var s = 0; s < n.scopes.length; ++s)
if (n.scopes[s].type === "py") {
i = n.scopes[s].offset + e.indentUnit;
break
}
} else i = t.column() + t.current().length;
n.scopes.unshift({
offset: i,
type: r
})
}
function S(e, t, n) {
n = n || "py";
if (t.scopes.length == 1) return;
if (t.scopes[0].type === "py") {
var r = e.indentation(),
i = -1;
for (var s = 0; s < t.scopes.length; ++s)
if (r === t.scopes[s].offset) {
i = s;
break
}
if (i === -1) return !0;
while (t.scopes[0].offset !== r) t.scopes.shift();
return !1
}
return n === "py" ? (t.scopes[0].offset = e.indentation(), !1) : t.scopes[0].type != n ? !0 : (t.scopes.shift(), !1)
}
function x(e, t) {
y = null;
var r = t.tokenize(e, t),
i = e.current();
if (i === ".") return r = e.match(f, !1) ? null : n, r === null && t.lastToken === "meta" && (r = "meta"), r;
if (i === "@") return e.match(f, !1) ? "meta" : n;
(r === "variable" || r === "builtin") && t.lastToken === "meta" && (r = "meta");
if (i === "pass" || i === "return") t.dedent += 1;
i === "lambda" && (t.lambda = !0), (i === ":" && !t.lambda && t.scopes[0].type == "py" || y === "indent") && E(e, t);
var s = "[({".indexOf(i);
return s !== -1 && E(e, t, "])}".slice(s, s + 1)), y === "dedent" && S(e, t) ? n : (s = "])}".indexOf(i), s !== -1 && S(e, t, i) ? n : (t.dedent > 0 && e.eol() && t.scopes[0].type == "py" && (t.scopes.length > 1 && t.scopes.shift(), t.dedent -= 1), r))
}
var n = "error",
i = t.singleOperators || new RegExp("^[\\+\\-\\*/%&|\\^~<>!]"),
s = t.singleDelimiters || new RegExp("^[\\(\\)\\[\\]\\{\\}@,:`=;\\.]"),
o = t.doubleOperators || new RegExp("^((==)|(!=)|(<=)|(>=)|(<>)|(<<)|(>>)|(//)|(\\*\\*))"),
u = t.doubleDelimiters || new RegExp("^((\\+=)|(\\-=)|(\\*=)|(%=)|(/=)|(&=)|(\\|=)|(\\^=))"),
a = t.tripleDelimiters || new RegExp("^((//=)|(>>=)|(<<=)|(\\*\\*=))"),
f = t.identifiers || new RegExp("^[_A-Za-z][_A-Za-z0-9]*"),
l = r(["and", "or", "not", "is", "in"]),
c = ["as", "assert", "break", "class", "continue", "def", "del", "elif", "else", "except", "finally", "for", "from", "global", "if", "import", "lambda", "pass", "raise", "return", "try", "while", "with", "yield"],
h = ["abs", "all", "any", "bin", "bool", "bytearray", "callable", "chr", "classmethod", "compile", "complex", "delattr", "dict", "dir", "divmod", "enumerate", "eval", "filter", "float", "format", "frozenset", "getattr", "globals", "hasattr", "hash", "help", "hex", "id", "input", "int", "isinstance", "issubclass", "iter", "len", "list", "locals", "map", "max", "memoryview", "min", "next", "object", "oct", "open", "ord", "pow", "property", "range", "repr", "reversed", "round", "set", "setattr", "slice", "sorted", "staticmethod", "str", "sum", "super", "tuple", "type", "vars", "zip", "__import__", "NotImplemented", "Ellipsis", "__debug__"],
p = {
builtins: ["apply", "basestring", "buffer", "cmp", "coerce", "execfile", "file", "intern", "long", "raw_input", "reduce", "reload", "unichr", "unicode", "xrange", "False", "True", "None"],
keywords: ["exec", "print"]
}, d = {
builtins: ["ascii", "bytes", "exec", "print"],
keywords: ["nonlocal", "False", "True", "None"]
};
if (!t.version || parseInt(t.version, 10) !== 3) {
c = c.concat(p.keywords), h = h.concat(p.builtins);
var v = new RegExp("^(([rub]|(ur)|(br))?('{3}|\"{3}|['\"]))", "i")
} else {
c = c.concat(d.keywords), h = h.concat(d.builtins);
var v = new RegExp("^(([rb]|(br))?('{3}|\"{3}|['\"]))", "i")
}
var m = r(c),
g = r(h),
y = null,
T = {
startState: function (e) {
return {
tokenize: b,
scopes: [{
offset: e || 0,
type: "py"
}],
lastToken: null,
lambda: !1,
dedent: 0
}
},
token: function (e, t) {
var n = x(e, t);
return t.lastToken = n, e.eol() && e.lambda && (t.lambda = !1), n
},
indent: function (e) {
return e.tokenize != b ? e.tokenize.isString ? CodeMirror.Pass : 0 : e.scopes[0].offset
},
lineComment: "#"
};
return T
}), CodeMirror.defineMIME("text/x-python", "python"), define("vendor/codemirror_modes/python", function () {}), CodeMirror.defineMode("ruby", function (e) {
function t(e) {
var t = {};
for (var n = 0, r = e.length; n < r; ++n) t[e[n]] = !0;
return t
}
function u(e, t, n) {
return n.tokenize.push(e), e(t, n)
}
function a(e, t) {
o = null;
if (e.sol() && e.match("=begin") && e.eol()) return t.tokenize.push(h), "comment";
if (e.eatSpace()) return null;
var n = e.next(),
r;
if (n == "`" || n == "'" || n == '"' || n == "/" && !e.eol() && e.peek() != " ") return u(l(n, "string", n == '"' || n == "`"), e, t);
if (n == "%") {
var i, a = !1;
e.eat("s") ? i = "atom" : e.eat(/[WQ]/) ? (i = "string", a = !0) : e.eat(/[wxqr]/) && (i = "string");
var f = e.eat(/[^\w\s]/);
return f ? (s.propertyIsEnumerable(f) && (f = s[f]), u(l(f, i, a, !0), e, t)) : "operator"
}
if (n == "#") return e.skipToEnd(), "comment";
if (n == "<" && (r = e.match(/^<-?[\`\"\']?([a-zA-Z_?]\w*)[\`\"\']?(?:;|$)/))) return u(c(r[1]), e, t);
if (n == "0") return e.eat("x") ? e.eatWhile(/[\da-fA-F]/) : e.eat("b") ? e.eatWhile(/[01]/) : e.eatWhile(/[0-7]/), "number";
if (/\d/.test(n)) return e.match(/^[\d_]*(?:\.[\d_]+)?(?:[eE][+\-]?[\d_]+)?/), "number";
if (n == "?") {
while (e.match(/^\\[CM]-/));
return e.eat("\\") ? e.eatWhile(/\w/) : e.next(), "string"
}
return n == ":" ? e.eat("'") ? u(l("'", "atom", !1), e, t) : e.eat('"') ? u(l('"', "atom", !0), e, t) : (e.eatWhile(/[\w\?]/), "atom") : n == "@" ? (e.eat("@"), e.eatWhile(/[\w\?]/), "variable-2") : n == "$" ? (e.next(), e.eatWhile(/[\w\?]/), "variable-3") : /\w/.test(n) ? (e.eatWhile(/[\w\?]/), e.eat(":") ? "atom" : "ident") : n != "|" || !t.varList && t.lastTok != "{" && t.lastTok != "do" ? /[\(\)\[\]{}\\;]/.test(n) ? (o = n, null) : n == "-" && e.eat(">") ? "arrow" : /[=+\-\/*:\.^%<>~|]/.test(n) ? (e.eatWhile(/[=+\-\/*:\.^%<>~|]/), "operator") : null : (o = "|", null)
}
function f() {
var e = 1;
return function (t, n) {
if (t.peek() == "}") {
e--;
if (e == 0) return n.tokenize.pop(), n.tokenize[n.tokenize.length - 1](t, n)
} else t.peek() == "{" && e++;
return a(t, n)
}
}
function l(e, t, n, r) {
return function (i, s) {
var o = !1,
u;
while ((u = i.next()) != null) {
if (u == e && (r || !o)) {
s.tokenize.pop();
break
}
if (n && u == "#" && !o && i.eat("{")) {
s.tokenize.push(f(arguments.callee));
break
}
o = !o && u == "\\"
}
return t
}
}
function c(e) {
return function (t, n) {
return t.match(e) ? n.tokenize.pop() : t.skipToEnd(), "string"
}
}
function h(e, t) {
return e.sol() && e.match("=end") && e.eol() && t.tokenize.pop(), e.skipToEnd(), "comment"
}
var n = t(["alias", "and", "BEGIN", "begin", "break", "case", "class", "def", "defined?", "do", "else", "elsif", "END", "end", "ensure", "false", "for", "if", "in", "module", "next", "not", "or", "redo", "rescue", "retry", "return", "self", "super", "then", "true", "undef", "unless", "until", "when", "while", "yield", "nil", "raise", "throw", "catch", "fail", "loop", "callcc", "caller", "lambda", "proc", "public", "protected", "private", "require", "load", "require_relative", "extend", "autoload"]),
r = t(["def", "class", "case", "for", "while", "do", "module", "then", "catch", "loop", "proc", "begin"]),
i = t(["end", "until"]),
s = {
"[": "]",
"{": "}",
"(": ")"
}, o;
return {
startState: function () {
return {
tokenize: [a],
indented: 0,
context: {
type: "top",
indented: -e.indentUnit
},
continuedLine: !1,
lastTok: null,
varList: !1
}
},
token: function (e, t) {
e.sol() && (t.indented = e.indentation());
var s = t.tokenize[t.tokenize.length - 1](e, t),
u;
if (s == "ident") {
var a = e.current();
s = n.propertyIsEnumerable(e.current()) ? "keyword" : /^[A-Z]/.test(a) ? "tag" : t.lastTok == "def" || t.lastTok == "class" || t.varList ? "def" : "variable", r.propertyIsEnumerable(a) ? u = "indent" : i.propertyIsEnumerable(a) ? u = "dedent" : (a == "if" || a == "unless") && e.column() == e.indentation() && (u = "indent")
}
if (o || s && s != "comment") t.lastTok = a || o || s;
return o == "|" && (t.varList = !t.varList), u == "indent" || /[\(\[\{]/.test(o) ? t.context = {
prev: t.context,
type: o || s,
indented: t.indented
} : (u == "dedent" || /[\)\]\}]/.test(o)) && t.context.prev && (t.context = t.context.prev), e.eol() && (t.continuedLine = o == "\\" || s == "operator"), s
},
indent: function (t, n) {
if (t.tokenize[t.tokenize.length - 1] != a) return 0;
var r = n && n.charAt(0),
i = t.context,
o = i.type == s[r] || i.type == "keyword" && /^(?:end|until|else|elsif|when|rescue)\b/.test(n);
return i.indented + (o ? 0 : e.indentUnit) + (t.continuedLine ? e.indentUnit : 0)
},
electricChars: "}de",
lineComment: "#"
}
}), CodeMirror.defineMIME("text/x-ruby", "ruby"), define("vendor/codemirror_modes/ruby", function () {}), CodeMirror.defineMode("css", function (e) {
return CodeMirror.getMode(e, "text/css")
}), CodeMirror.defineMode("css-base", function (e, t) {
function c(e, t) {
return l = t, e
}
function h(e, t) {
var n = e.next();
if (r[n]) {
var i = r[n](e, t);
if (i !== !1) return i
}
if (n == "@") return e.eatWhile(/[\w\\\-]/), c("def", e.current());
if (n == "=") c(null, "compare");
else {
if (!(n != "~" && n != "|" || !e.eat("="))) return c(null, "compare");
if (n == '"' || n == "'") return t.tokenize = p(n), t.tokenize(e, t);
if (n == "#") return e.eatWhile(/[\w\\\-]/), c("atom", "hash");
if (n == "!") return e.match(/^\s*\w*/), c("keyword", "important");
if (/\d/.test(n)) return e.eatWhile(/[\w.%]/), c("number", "unit");
if (n !== "-") return /[,+>*\/]/.test(n) ? c(null, "select-op") : n == "." && e.match(/^-?[_a-z][_a-z0-9-]*/i) ? c("qualifier", "qualifier") : n == ":" ? c("operator", n) : /[;{}\[\]\(\)]/.test(n) ? c(null, n) : n == "u" && e.match("rl(") ? (e.backUp(1), t.tokenize = d, c("property", "variable")) : (e.eatWhile(/[\w\\\-]/), c("property", "variable"));
if (/\d/.test(e.peek())) return e.eatWhile(/[\w.%]/), c("number", "unit");
if (e.match(/^[^-]+-/)) return c("meta", "meta")
}
}
function p(e, t) {
return function (n, r) {
var i = !1,
s;
while ((s = n.next()) != null) {
if (s == e && !i) break;
i = !i && s == "\\"
}
return i || (t && n.backUp(1), r.tokenize = h), c("string", "string")
}
}
function d(e, t) {
return e.next(), e.match(/\s*[\"\']/, !1) ? t.tokenize = h : t.tokenize = p(")", !0), c(null, "(")
}
var n = e.indentUnit,
r = t.hooks || {}, i = t.atMediaTypes || {}, s = t.atMediaFeatures || {}, o = t.propertyKeywords || {}, u = t.colorKeywords || {}, a = t.valueKeywords || {}, f = !! t.allowNested,
l = null;
return {
startState: function (e) {
return {
tokenize: h,
baseIndent: e || 0,
stack: []
}
},
token: function (e, t) {
t.tokenize = t.tokenize || h;
if (t.tokenize == h && e.eatSpace()) return null;
var n = t.tokenize(e, t);
n && typeof n != "string" && (n = c(n[0], n[1]));
var r = t.stack[t.stack.length - 1];
if (n == "variable") return l == "variable-definition" && t.stack.push("propertyValue"), "variable-2";
if (n == "property") {
var p = e.current().toLowerCase();
r == "propertyValue" ? a.hasOwnProperty(p) ? n = "string-2" : u.hasOwnProperty(p) ? n = "keyword" : n = "variable-2" : r == "rule" ? o.hasOwnProperty(p) || (n += " error") : r == "block" ? o.hasOwnProperty(p) ? n = "property" : u.hasOwnProperty(p) ? n = "keyword" : a.hasOwnProperty(p) ? n = "string-2" : n = "tag" : !r || r == "@media{" ? n = "tag" : r == "@media" ? i[e.current()] ? n = "attribute" : /^(only|not)$/.test(p) ? n = "keyword" : p == "and" ? n = "error" : s.hasOwnProperty(p) ? n = "error" : n = "attribute error" : r == "@mediaType" ? i.hasOwnProperty(p) ? n = "attribute" : p == "and" ? n = "operator" : /^(only|not)$/.test(p) ? n = "error" : n = "error" : r == "@mediaType(" ? o.hasOwnProperty(p) || (i.hasOwnProperty(p) ? n = "error" : p == "and" ? n = "operator" : /^(only|not)$/.test(p) ? n = "error" : n += " error") : r == "@import" ? n = "tag" : n = "error"
} else n == "atom" ? !r || r == "@media{" || r == "block" ? n = "builtin" : r == "propertyValue" ? /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/.test(e.current()) || (n += " error") : n = "error" : r == "@media" && l == "{" && (n = "error"); if (l == "{")
if (r == "@media" || r == "@mediaType") t.stack.pop(), t.stack[t.stack.length - 1] = "@media{";
else {
var d = f ? "block" : "rule";
t.stack.push(d)
} else if (l == "}") {
var v = t.stack[t.stack.length - 1];
v == "interpolation" && (n = "operator"), t.stack.pop(), r == "propertyValue" && t.stack.pop()
} else l == "interpolation" ? t.stack.push("interpolation") : l == "@media" ? t.stack.push("@media") : l == "@import" ? t.stack.push("@import") : r == "@media" && /\b(keyword|attribute)\b/.test(n) ? t.stack.push("@mediaType") : r == "@mediaType" && e.current() == "," ? t.stack.pop() : r == "@mediaType" && l == "(" ? t.stack.push("@mediaType(") : r == "@mediaType(" && l == ")" ? t.stack.pop() : r != "rule" && r != "block" || l != ":" ? r == "propertyValue" && l == ";" ? t.stack.pop() : r == "@import" && l == ";" && t.stack.pop() : t.stack.push("propertyValue");
return n
},
indent: function (e, t) {
var r = e.stack.length;
return /^\}/.test(t) && (r -= e.stack[e.stack.length - 1] == "propertyValue" ? 2 : 1), e.baseIndent + r * n
},
electricChars: "}",
blockCommentStart: "/*",
blockCommentEnd: "*/"
}
}),
function () {
function e(e) {
var t = {};
for (var n = 0; n < e.length; ++n) t[e[n]] = !0;
return t
}
function o(e, t) {
var n = !1,
r;
while ((r = e.next()) != null) {
if (n && r == "/") {
t.tokenize = null;
break
}
n = r == "*"
}
return ["comment", "comment"]
}
var t = e(["all", "aural", "braille", "handheld", "print", "projection", "screen", "tty", "tv", "embossed"]),
n = e(["width", "min-width", "max-width", "height", "min-height", "max-height", "device-width", "min-device-width", "max-device-width", "device-height", "min-device-height", "max-device-height", "aspect-ratio", "min-aspect-ratio", "max-aspect-ratio", "device-aspect-ratio", "min-device-aspect-ratio", "max-device-aspect-ratio", "color", "min-color", "max-color", "color-index", "min-color-index", "max-color-index", "monochrome", "min-monochrome", "max-monochrome", "resolution", "min-resolution", "max-resolution", "scan", "grid"]),
r = e(["align-content", "align-items", "align-self", "alignment-adjust", "alignment-baseline", "anchor-point", "animation", "animation-delay", "animation-direction", "animation-duration", "animation-iteration-count", "animation-name", "animation-play-state", "animation-timing-function", "appearance", "azimuth", "backface-visibility", "background", "background-attachment", "background-clip", "background-color", "background-image", "background-origin", "background-position", "background-repeat", "background-size", "baseline-shift", "binding", "bleed", "bookmark-label", "bookmark-level", "bookmark-state", "bookmark-target", "border", "border-bottom", "border-bottom-color", "border-bottom-left-radius", "border-bottom-right-radius", "border-bottom-style", "border-bottom-width", "border-collapse", "border-color", "border-image", "border-image-outset", "border-image-repeat", "border-image-slice", "border-image-source", "border-image-width", "border-left", "border-left-color", "border-left-style", "border-left-width", "border-radius", "border-right", "border-right-color", "border-right-style", "border-right-width", "border-spacing", "border-style", "border-top", "border-top-color", "border-top-left-radius", "border-top-right-radius", "border-top-style", "border-top-width", "border-width", "bottom", "box-decoration-break", "box-shadow", "box-sizing", "break-after", "break-before", "break-inside", "caption-side", "clear", "clip", "color", "color-profile", "column-count", "column-fill", "column-gap", "column-rule", "column-rule-color", "column-rule-style", "column-rule-width", "column-span", "column-width", "columns", "content", "counter-increment", "counter-reset", "crop", "cue", "cue-after", "cue-before", "cursor", "direction", "display", "dominant-baseline", "drop-initial-after-adjust", "drop-initial-after-align", "drop-initial-before-adjust", "drop-initial-before-align", "drop-initial-size", "drop-initial-value", "elevation", "empty-cells", "fit", "fit-position", "flex", "flex-basis", "flex-direction", "flex-flow", "flex-grow", "flex-shrink", "flex-wrap", "float", "float-offset", "font", "font-feature-settings", "font-family", "font-kerning", "font-language-override", "font-size", "font-size-adjust", "font-stretch", "font-style", "font-synthesis", "font-variant", "font-variant-alternates", "font-variant-caps", "font-variant-east-asian", "font-variant-ligatures", "font-variant-numeric", "font-variant-position", "font-weight", "grid-cell", "grid-column", "grid-column-align", "grid-column-sizing", "grid-column-span", "grid-columns", "grid-flow", "grid-row", "grid-row-align", "grid-row-sizing", "grid-row-span", "grid-rows", "grid-template", "hanging-punctuation", "height", "hyphens", "icon", "image-orientation", "image-rendering", "image-resolution", "inline-box-align", "justify-content", "left", "letter-spacing", "line-break", "line-height", "line-stacking", "line-stacking-ruby", "line-stacking-shift", "line-stacking-strategy", "list-style", "list-style-image", "list-style-position", "list-style-type", "margin", "margin-bottom", "margin-left", "margin-right", "margin-top", "marker-offset", "marks", "marquee-direction", "marquee-loop", "marquee-play-count", "marquee-speed", "marquee-style", "max-height", "max-width", "min-height", "min-width", "move-to", "nav-down", "nav-index", "nav-left", "nav-right", "nav-up", "opacity", "order", "orphans", "outline", "outline-color", "outline-offset", "outline-style", "outline-width", "overflow", "overflow-style", "overflow-wrap", "overflow-x", "overflow-y", "padding", "padding-bottom", "padding-left", "padding-right", "padding-top", "page", "page-break-after", "page-break-before", "page-break-inside", "page-policy", "pause", "pause-after", "pause-before", "perspective", "perspective-origin", "pitch", "pitch-range", "play-during", "position", "presentation-level", "punctuation-trim", "quotes", "rendering-intent", "resize", "rest", "rest-after", "rest-before", "richness", "right", "rotation", "rotation-point", "ruby-align", "ruby-overhang", "ruby-position", "ruby-span", "size", "speak", "speak-as", "speak-header", "speak-numeral", "speak-punctuation", "speech-rate", "stress", "string-set", "tab-size", "table-layout", "target", "target-name", "target-new", "target-position", "text-align", "text-align-last", "text-decoration", "text-decoration-color", "text-decoration-line", "text-decoration-skip", "text-decoration-style", "text-emphasis", "text-emphasis-color", "text-emphasis-position", "text-emphasis-style", "text-height", "text-indent", "text-justify", "text-outline", "text-shadow", "text-space-collapse", "text-transform", "text-underline-position", "text-wrap", "top", "transform", "transform-origin", "transform-style", "transition", "transition-delay", "transition-duration", "transition-property", "transition-timing-function", "unicode-bidi", "vertical-align", "visibility", "voice-balance", "voice-duration", "voice-family", "voice-pitch", "voice-range", "voice-rate", "voice-stress", "voice-volume", "volume", "white-space", "widows", "width", "word-break", "word-spacing", "word-wrap", "z-index", "clip-path", "clip-rule", "mask", "enable-background", "filter", "flood-color", "flood-opacity", "lighting-color", "stop-color", "stop-opacity", "pointer-events", "color-interpolation", "color-interpolation-filters", "color-profile", "color-rendering", "fill", "fill-opacity", "fill-rule", "image-rendering", "marker", "marker-end", "marker-mid", "marker-start", "shape-rendering", "stroke", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke-width", "text-rendering", "baseline-shift", "dominant-baseline", "glyph-orientation-horizontal", "glyph-orientation-vertical", "kerning", "text-anchor", "writing-mode"]),
i = e(["aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige", "bisque", "black", "blanchedalmond", "blue", "blueviolet", "brown", "burlywood", "cadetblue", "chartreuse", "chocolate", "coral", "cornflowerblue", "cornsilk", "crimson", "cyan", "darkblue", "darkcyan", "darkgoldenrod", "darkgray", "darkgreen", "darkkhaki", "darkmagenta", "darkolivegreen", "darkorange", "darkorchid", "darkred", "darksalmon", "darkseagreen", "darkslateblue", "darkslategray", "darkturquoise", "darkviolet", "deeppink", "deepskyblue", "dimgray", "dodgerblue", "firebrick", "floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite", "gold", "goldenrod", "gray", "green", "greenyellow", "honeydew", "hotpink", "indianred", "indigo", "ivory", "khaki", "lavender", "lavenderblush", "lawngreen", "lemonchiffon", "lightblue", "lightcoral", "lightcyan", "lightgoldenrodyellow", "lightgray", "lightgreen", "lightpink", "lightsalmon", "lightseagreen", "lightskyblue", "lightslategray", "lightsteelblue", "lightyellow", "lime", "limegreen", "linen", "magenta", "maroon", "mediumaquamarine", "mediumblue", "mediumorchid", "mediumpurple", "mediumseagreen", "mediumslateblue", "mediumspringgreen", "mediumturquoise", "mediumvioletred", "midnightblue", "mintcream", "mistyrose", "moccasin", "navajowhite", "navy", "oldlace", "olive", "olivedrab", "orange", "orangered", "orchid", "palegoldenrod", "palegreen", "paleturquoise", "palevioletred", "papayawhip", "peachpuff", "peru", "pink", "plum", "powderblue", "purple", "red", "rosybrown", "royalblue", "saddlebrown", "salmon", "sandybrown", "seagreen", "seashell", "sienna", "silver", "skyblue", "slateblue", "slategray", "snow", "springgreen", "steelblue", "tan", "teal", "thistle", "tomato", "turquoise", "violet", "wheat", "white", "whitesmoke", "yellow", "yellowgreen"]),
s = e(["above", "absolute", "activeborder", "activecaption", "afar", "after-white-space", "ahead", "alias", "all", "all-scroll", "alternate", "always", "amharic", "amharic-abegede", "antialiased", "appworkspace", "arabic-indic", "armenian", "asterisks", "auto", "avoid", "background", "backwards", "baseline", "below", "bidi-override", "binary", "bengali", "blink", "block", "block-axis", "bold", "bolder", "border", "border-box", "both", "bottom", "break-all", "break-word", "button", "button-bevel", "buttonface", "buttonhighlight", "buttonshadow", "buttontext", "cambodian", "capitalize", "caps-lock-indicator", "caption", "captiontext", "caret", "cell", "center", "checkbox", "circle", "cjk-earthly-branch", "cjk-heavenly-stem", "cjk-ideographic", "clear", "clip", "close-quote", "col-resize", "collapse", "compact", "condensed", "contain", "content", "content-box", "context-menu", "continuous", "copy", "cover", "crop", "cross", "crosshair", "currentcolor", "cursive", "dashed", "decimal", "decimal-leading-zero", "default", "default-button", "destination-atop", "destination-in", "destination-out", "destination-over", "devanagari", "disc", "discard", "document", "dot-dash", "dot-dot-dash", "dotted", "double", "down", "e-resize", "ease", "ease-in", "ease-in-out", "ease-out", "element", "ellipsis", "embed", "end", "ethiopic", "ethiopic-abegede", "ethiopic-abegede-am-et", "ethiopic-abegede-gez", "ethiopic-abegede-ti-er", "ethiopic-abegede-ti-et", "ethiopic-halehame-aa-er", "ethiopic-halehame-aa-et", "ethiopic-halehame-am-et", "ethiopic-halehame-gez", "ethiopic-halehame-om-et", "ethiopic-halehame-sid-et", "ethiopic-halehame-so-et", "ethiopic-halehame-ti-er", "ethiopic-halehame-ti-et", "ethiopic-halehame-tig", "ew-resize", "expanded", "extra-condensed", "extra-expanded", "fantasy", "fast", "fill", "fixed", "flat", "footnotes", "forwards", "from", "geometricPrecision", "georgian", "graytext", "groove", "gujarati", "gurmukhi", "hand", "hangul", "hangul-consonant", "hebrew", "help", "hidden", "hide", "higher", "highlight", "highlighttext", "hiragana", "hiragana-iroha", "horizontal", "hsl", "hsla", "icon", "ignore", "inactiveborder", "inactivecaption", "inactivecaptiontext", "infinite", "infobackground", "infotext", "inherit", "initial", "inline", "inline-axis", "inline-block", "inline-table", "inset", "inside", "intrinsic", "invert", "italic", "justify", "kannada", "katakana", "katakana-iroha", "khmer", "landscape", "lao", "large", "larger", "left", "level", "lighter", "line-through", "linear", "lines", "list-item", "listbox", "listitem", "local", "logical", "loud", "lower", "lower-alpha", "lower-armenian", "lower-greek", "lower-hexadecimal", "lower-latin", "lower-norwegian", "lower-roman", "lowercase", "ltr", "malayalam", "match", "media-controls-background", "media-current-time-display", "media-fullscreen-button", "media-mute-button", "media-play-button", "media-return-to-realtime-button", "media-rewind-button", "media-seek-back-button", "media-seek-forward-button", "media-slider", "media-sliderthumb", "media-time-remaining-display", "media-volume-slider", "media-volume-slider-container", "media-volume-sliderthumb", "medium", "menu", "menulist", "menulist-button", "menulist-text", "menulist-textfield", "menutext", "message-box", "middle", "min-intrinsic", "mix", "mongolian", "monospace", "move", "multiple", "myanmar", "n-resize", "narrower", "ne-resize", "nesw-resize", "no-close-quote", "no-drop", "no-open-quote", "no-repeat", "none", "normal", "not-allowed", "nowrap", "ns-resize", "nw-resize", "nwse-resize", "oblique", "octal", "open-quote", "optimizeLegibility", "optimizeSpeed", "oriya", "oromo", "outset", "outside", "overlay", "overline", "padding", "padding-box", "painted", "paused", "persian", "plus-darker", "plus-lighter", "pointer", "portrait", "pre", "pre-line", "pre-wrap", "preserve-3d", "progress", "push-button", "radio", "read-only", "read-write", "read-write-plaintext-only", "relative", "repeat", "repeat-x", "repeat-y", "reset", "reverse", "rgb", "rgba", "ridge", "right", "round", "row-resize", "rtl", "run-in", "running", "s-resize", "sans-serif", "scroll", "scrollbar", "se-resize", "searchfield", "searchfield-cancel-button", "searchfield-decoration", "searchfield-results-button", "searchfield-results-decoration", "semi-condensed", "semi-expanded", "separate", "serif", "show", "sidama", "single", "skip-white-space", "slide", "slider-horizontal", "slider-vertical", "sliderthumb-horizontal", "sliderthumb-vertical", "slow", "small", "small-caps", "small-caption", "smaller", "solid", "somali", "source-atop", "source-in", "source-out", "source-over", "space", "square", "square-button", "start", "static", "status-bar", "stretch", "stroke", "sub", "subpixel-antialiased", "super", "sw-resize", "table", "table-caption", "table-cell", "table-column", "table-column-group", "table-footer-group", "table-header-group", "table-row", "table-row-group", "telugu", "text", "text-bottom", "text-top", "textarea", "textfield", "thai", "thick", "thin", "threeddarkshadow", "threedface", "threedhighlight", "threedlightshadow", "threedshadow", "tibetan", "tigre", "tigrinya-er", "tigrinya-er-abegede", "tigrinya-et", "tigrinya-et-abegede", "to", "top", "transparent", "ultra-condensed", "ultra-expanded", "underline", "up", "upper-alpha", "upper-armenian", "upper-greek", "upper-hexadecimal", "upper-latin", "upper-norwegian", "upper-roman", "uppercase", "urdu", "url", "vertical", "vertical-text", "visible", "visibleFill", "visiblePainted", "visibleStroke", "visual", "w-resize", "wait", "wave", "wider", "window", "windowframe", "windowtext", "x-large", "x-small", "xor", "xx-large", "xx-small"]);
CodeMirror.defineMIME("text/css", {
atMediaTypes: t,
atMediaFeatures: n,
propertyKeywords: r,
colorKeywords: i,
valueKeywords: s,
hooks: {
"<": function (e, t) {
function n(e, t) {
var n = 0,
r;
while ((r = e.next()) != null) {
if (n >= 2 && r == ">") {
t.tokenize = null;
break
}
n = r == "-" ? n + 1 : 0
}
return ["comment", "comment"]
}
if (e.eat("!")) return t.tokenize = n, n(e, t)
},
"/": function (e, t) {
return e.eat("*") ? (t.tokenize = o, o(e, t)) : !1
}
},
name: "css-base"
}), CodeMirror.defineMIME("text/x-scss", {
atMediaTypes: t,
atMediaFeatures: n,
propertyKeywords: r,
colorKeywords: i,
valueKeywords: s,
allowNested: !0,
hooks: {
$: function (e) {
return e.match(/^[\w-]+/), e.peek() == ":" ? ["variable", "variable-definition"] : ["variable", "variable"]
},
"/": function (e, t) {
return e.eat("/") ? (e.skipToEnd(), ["comment", "comment"]) : e.eat("*") ? (t.tokenize = o, o(e, t)) : ["operator", "operator"]
},
"#": function (e) {
return e.eat("{") ? ["operator", "interpolation"] : (e.eatWhile(/[\w\\\-]/), ["atom", "hash"])
}
},
name: "css-base"
})
}(), define("vendor/codemirror_modes/css", function () {}), CodeMirror.defineMode("xml", function (e, t) {
function a(e, t) {
function n(n) {
return t.tokenize = n, n(e, t)
}
var r = e.next();
if (r == "<") {
if (e.eat("!")) return e.eat("[") ? e.match("CDATA[") ? n(c("atom", "]]>")) : null : e.match("--") ? n(c("comment", "-->")) : e.match("DOCTYPE", !0, !0) ? (e.eatWhile(/[\w\._\-]/), n(h(1))) : null;
if (e.eat("?")) return e.eatWhile(/[\w\._\-]/), t.tokenize = c("meta", "?>"), "meta";
var i = e.eat("/");
o = "";
var s;
while (s = e.eat(/[^\s\u00a0=<>\"\'\/?]/)) o += s;
return o ? (u = i ? "closeTag" : "openTag", t.tokenize = f, "tag") : "error"
}
if (r == "&") {
var a;
return e.eat("#") ? e.eat("x") ? a = e.eatWhile(/[a-fA-F\d]/) && e.eat(";") : a = e.eatWhile(/[\d]/) && e.eat(";") : a = e.eatWhile(/[\w\.\-:]/) && e.eat(";"), a ? "atom" : "error"
}
return e.eatWhile(/[^&<]/), null
}
function f(e, t) {
var n = e.next();
return n == ">" || n == "/" && e.eat(">") ? (t.tokenize = a, u = n == ">" ? "endTag" : "selfcloseTag", "tag") : n == "=" ? (u = "equals", null) : /[\'\"]/.test(n) ? (t.tokenize = l(n), t.tokenize(e, t)) : (e.eatWhile(/[^\s\u00a0=<>\"\']/), "word")
}
function l(e) {
return function (t, n) {
while (!t.eol())
if (t.next() == e) {
n.tokenize = f;
break
}
return "string"
}
}
function c(e, t) {
return function (n, r) {
while (!n.eol()) {
if (n.match(t)) {
r.tokenize = a;
break
}
n.next()
}
return e
}
}
function h(e) {
return function (t, n) {
var r;
while ((r = t.next()) != null) {
if (r == "<") return n.tokenize = h(e + 1), n.tokenize(t, n);
if (r == ">") {
if (e == 1) {
n.tokenize = a;
break
}
return n.tokenize = h(e - 1), n.tokenize(t, n)
}
}
return "meta"
}
}
function m() {
for (var e = arguments.length - 1; e >= 0; e--) p.cc.push(arguments[e])
}
function g() {
return m.apply(null, arguments), !0
}
function y(e, t) {
var n = i.doNotIndent.hasOwnProperty(e) || p.context && p.context.noIndent;
p.context = {
prev: p.context,
tagName: e,
indent: p.indented,
startOfLine: t,
noIndent: n
}
}
function b() {
p.context && (p.context = p.context.prev)
}
function w(e) {
if (e == "openTag") return p.tagName = o, p.tagStart = d.column(), g(T, E(p.startOfLine));
if (e == "closeTag") {
var t = !1;
return p.context ? p.context.tagName != o && (i.implicitlyClosed.hasOwnProperty(p.context.tagName.toLowerCase()) && b(), t = !p.context || p.context.tagName != o) : t = !0, t && (v = "error"), g(S(t))
}
return g()
}
function E(e) {
return function (t) {
var n = p.tagName;
return p.tagName = p.tagStart = null, t == "selfcloseTag" || t == "endTag" && i.autoSelfClosers.hasOwnProperty(n.toLowerCase()) ? (x(n.toLowerCase()), g()) : t == "endTag" ? (x(n.toLowerCase()), y(n, e), g()) : g()
}
}
function S(e) {
return function (t) {
return e && (v = "error"), t == "endTag" ? (b(), g()) : (v = "error", g(arguments.callee))
}
}
function x(e) {
var t;
for (;;) {
if (!p.context) return;
t = p.context.tagName.toLowerCase();
if (!i.contextGrabbers.hasOwnProperty(t) || !i.contextGrabbers[t].hasOwnProperty(e)) return;
b()
}
}
function T(e) {
return e == "word" ? (v = "attribute", g(N, T)) : e == "endTag" || e == "selfcloseTag" ? m() : (v = "error", g(T))
}
function N(e) {
return e == "equals" ? g(C, T) : (i.allowMissing ? e == "word" && (v = "attribute") : v = "error", e == "endTag" || e == "selfcloseTag" ? m() : g())
}
function C(e) {
return e == "string" ? g(k) : e == "word" && i.allowUnquoted ? (v = "string", g()) : (v = "error", e == "endTag" || e == "selfCloseTag" ? m() : g())
}
function k(e) {
return e == "string" ? g(k) : m()
}
var n = e.indentUnit,
r = t.multilineTagIndentFactor || 1,
i = t.htmlMode ? {
autoSelfClosers: {
area: !0,
base: !0,
br: !0,
col: !0,
command: !0,
embed: !0,
frame: !0,
hr: !0,
img: !0,
input: !0,
keygen: !0,
link: !0,
meta: !0,
param: !0,
source: !0,
track: !0,
wbr: !0
},
implicitlyClosed: {
dd: !0,
li: !0,
optgroup: !0,
option: !0,
p: !0,
rp: !0,
rt: !0,
tbody: !0,
td: !0,
tfoot: !0,
th: !0,
tr: !0
},
contextGrabbers: {
dd: {
dd: !0,
dt: !0
},
dt: {
dd: !0,
dt: !0
},
li: {
li: !0
},
option: {
option: !0,
optgroup: !0
},
optgroup: {
optgroup: !0
},
p: {
address: !0,
article: !0,
aside: !0,
blockquote: !0,
dir: !0,
div: !0,
dl: !0,
fieldset: !0,
footer: !0,
form: !0,
h1: !0,
h2: !0,
h3: !0,
h4: !0,
h5: !0,
h6: !0,
header: !0,
hgroup: !0,
hr: !0,
menu: !0,
nav: !0,
ol: !0,
p: !0,
pre: !0,
section: !0,
table: !0,
ul: !0
},
rp: {
rp: !0,
rt: !0
},
rt: {
rp: !0,
rt: !0
},
tbody: {
tbody: !0,
tfoot: !0
},
td: {
td: !0,
th: !0
},
tfoot: {
tbody: !0
},
th: {
td: !0,
th: !0
},
thead: {
tbody: !0,
tfoot: !0
},
tr: {
tr: !0
}
},
doNotIndent: {
pre: !0
},
allowUnquoted: !0,
allowMissing: !0
} : {
autoSelfClosers: {},
implicitlyClosed: {},
contextGrabbers: {},
doNotIndent: {},
allowUnquoted: !1,
allowMissing: !1
}, s = t.alignCDATA,
o, u, p, d, v;
return {
startState: function () {
return {
tokenize: a,
cc: [],
indented: 0,
startOfLine: !0,
tagName: null,
tagStart: null,
context: null
}
},
token: function (e, t) {
!t.tagName && e.sol() && (t.startOfLine = !0, t.indented = e.indentation());
if (e.eatSpace()) return null;
v = u = o = null;
var n = t.tokenize(e, t);
t.type = u;
if ((n || u) && n != "comment") {
p = t, d = e;
for (;;) {
var r = t.cc.pop() || w;
if (r(u || n)) break
}
}
return t.startOfLine = !1, v || n
},
indent: function (e, t, i) {
var o = e.context;
if (e.tokenize != f && e.tokenize != a || o && o.noIndent) return i ? i.match(/^(\s*)/)[0].length : 0;
if (e.tagName) return e.tagStart + n * r;
if (s && /<!\[CDATA\[/.test(t)) return 0;
o && /^<\//.test(t) && (o = o.prev);
while (o && !o.startOfLine) o = o.prev;
return o ? o.indent + n : 0
},
electricChars: "/",
blockCommentStart: "<!--",
blockCommentEnd: "-->",
configuration: t.htmlMode ? "html" : "xml"
}
}), CodeMirror.defineMIME("text/xml", "xml"), CodeMirror.defineMIME("application/xml", "xml"), CodeMirror.mimeModes.hasOwnProperty("text/html") || CodeMirror.defineMIME("text/html", {
name: "xml",
htmlMode: !0
}), define("vendor/codemirror_modes/xml", function () {}), CodeMirror.defineMode("htmlmixed", function (e, t) {
function a(e, t) {
var s = t.htmlState.tagName,
o = n.token(e, t.htmlState);
if (s == "script" && /\btag\b/.test(o) && e.current() == ">") {
var u = e.string.slice(Math.max(0, e.pos - 100), e.pos).match(/\btype\s*=\s*("[^"]+"|'[^']+'|\S+)[^<]*$/i);
u = u ? u[1] : "", u && /[\"\']/.test(u.charAt(0)) && (u = u.slice(1, u.length - 1));
for (var a = 0; a < i.length; ++a) {
var f = i[a];
if (typeof f.matches == "string" ? u == f.matches : f.matches.test(u)) {
f.mode && (t.token = l, t.localMode = f.mode, t.localState = f.mode.startState && f.mode.startState(n.indent(t.htmlState, "")));
break
}
}
} else s == "style" && /\btag\b/.test(o) && e.current() == ">" && (t.token = c, t.localMode = r, t.localState = r.startState(n.indent(t.htmlState, "")));
return o
}
function f(e, t, n) {
var r = e.current(),
i = r.search(t),
s;
if (i > -1) e.backUp(r.length - i);
else if (s = r.match(/<\/?$/)) e.backUp(r.length), e.match(t, !1) || e.match(r[0]);
return n
}
function l(e, t) {
return e.match(/^<\/\s*script\s*>/i, !1) ? (t.token = a, t.localState = t.localMode = null, a(e, t)) : f(e, /<\/\s*script\s*>/, t.localMode.token(e, t.localState))
}
function c(e, t) {
return e.match(/^<\/\s*style\s*>/i, !1) ? (t.token = a, t.localState = t.localMode = null, a(e, t)) : f(e, /<\/\s*style\s*>/, r.token(e, t.localState))
}
var n = CodeMirror.getMode(e, {
name: "xml",
htmlMode: !0
}),
r = CodeMirror.getMode(e, "css"),
i = [],
s = t && t.scriptTypes;
i.push({
matches: /^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^$/i,
mode: CodeMirror.getMode(e, "javascript")
});
if (s)
for (var o = 0; o < s.length; ++o) {
var u = s[o];
i.push({
matches: u.matches,
mode: u.mode && CodeMirror.getMode(e, u.mode)
})
}
return i.push({
matches: /./,
mode: CodeMirror.getMode(e, "text/plain")
}), {
startState: function () {
var e = n.startState();
return {
token: a,
localMode: null,
localState: null,
htmlState: e
}
},
copyState: function (e) {
if (e.localState) var t = CodeMirror.copyState(e.localMode, e.localState);
return {
token: e.token,
localMode: e.localMode,
localState: t,
htmlState: CodeMirror.copyState(n, e.htmlState)
}
},
token: function (e, t) {
return t.token(e, t)
},
indent: function (e, t) {
return !e.localMode || /^\s*<\//.test(t) ? n.indent(e.htmlState, t) : e.localMode.indent ? e.localMode.indent(e.localState, t) : CodeMirror.Pass
},
electricChars: "/{}:",
innerMode: function (e) {
return {
state: e.localState || e.htmlState,
mode: e.localMode || n
}
}
}
}, "xml", "javascript", "css"), CodeMirror.defineMIME("text/html", "htmlmixed"), define("vendor/codemirror_modes/htmlmixed", function () {}),
function () {
function e(e) {
var t = {}, n = e.split(" ");
for (var r = 0; r < n.length; ++r) t[n[r]] = !0;
return t
}
function t(e) {
return function (t, n) {
return t.match(e) ? n.tokenize = null : t.skipToEnd(), "string"
}
}
var n = {
name: "clike",
keywords: e("abstract and array as break case catch class clone const continue declare default do else elseif enddeclare endfor endforeach endif endswitch endwhile extends final for foreach function global goto if implements interface instanceof namespace new or private protected public static switch throw trait try use var while xor die echo empty exit eval include include_once isset list require require_once return print unset __halt_compiler self static parent"),
blockKeywords: e("catch do else elseif for foreach if switch try while"),
atoms: e("true false null TRUE FALSE NULL __CLASS__ __DIR__ __FILE__ __LINE__ __METHOD__ __FUNCTION__ __NAMESPACE__"),
builtin: e("func_num_args func_get_arg func_get_args strlen strcmp strncmp strcasecmp strncasecmp each error_reporting define defined trigger_error user_error set_error_handler restore_error_handler get_declared_classes get_loaded_extensions extension_loaded get_extension_funcs debug_backtrace constant bin2hex sleep usleep time mktime gmmktime strftime gmstrftime strtotime date gmdate getdate localtime checkdate flush wordwrap htmlspecialchars htmlentities html_entity_decode md5 md5_file crc32 getimagesize image_type_to_mime_type phpinfo phpversion phpcredits strnatcmp strnatcasecmp substr_count strspn strcspn strtok strtoupper strtolower strpos strrpos strrev hebrev hebrevc nl2br basename dirname pathinfo stripslashes stripcslashes strstr stristr strrchr str_shuffle str_word_count strcoll substr substr_replace quotemeta ucfirst ucwords strtr addslashes addcslashes rtrim str_replace str_repeat count_chars chunk_split trim ltrim strip_tags similar_text explode implode setlocale localeconv parse_str str_pad chop strchr sprintf printf vprintf vsprintf sscanf fscanf parse_url urlencode urldecode rawurlencode rawurldecode readlink linkinfo link unlink exec system escapeshellcmd escapeshellarg passthru shell_exec proc_open proc_close rand srand getrandmax mt_rand mt_srand mt_getrandmax base64_decode base64_encode abs ceil floor round is_finite is_nan is_infinite bindec hexdec octdec decbin decoct dechex base_convert number_format fmod ip2long long2ip getenv putenv getopt microtime gettimeofday getrusage uniqid quoted_printable_decode set_time_limit get_cfg_var magic_quotes_runtime set_magic_quotes_runtime get_magic_quotes_gpc get_magic_quotes_runtime import_request_variables error_log serialize unserialize memory_get_usage var_dump var_export debug_zval_dump print_r highlight_file show_source highlight_string ini_get ini_get_all ini_set ini_alter ini_restore get_include_path set_include_path restore_include_path setcookie header headers_sent connection_aborted connection_status ignore_user_abort parse_ini_file is_uploaded_file move_uploaded_file intval floatval doubleval strval gettype settype is_null is_resource is_bool is_long is_float is_int is_integer is_double is_real is_numeric is_string is_array is_object is_scalar ereg ereg_replace eregi eregi_replace split spliti join sql_regcase dl pclose popen readfile rewind rmdir umask fclose feof fgetc fgets fgetss fread fopen fpassthru ftruncate fstat fseek ftell fflush fwrite fputs mkdir rename copy tempnam tmpfile file file_get_contents stream_select stream_context_create stream_context_set_params stream_context_set_option stream_context_get_options stream_filter_prepend stream_filter_append fgetcsv flock get_meta_tags stream_set_write_buffer set_file_buffer set_socket_blocking stream_set_blocking socket_set_blocking stream_get_meta_data stream_register_wrapper stream_wrapper_register stream_set_timeout socket_set_timeout socket_get_status realpath fnmatch fsockopen pfsockopen pack unpack get_browser crypt opendir closedir chdir getcwd rewinddir readdir dir glob fileatime filectime filegroup fileinode filemtime fileowner fileperms filesize filetype file_exists is_writable is_writeable is_readable is_executable is_file is_dir is_link stat lstat chown touch clearstatcache mail ob_start ob_flush ob_clean ob_end_flush ob_end_clean ob_get_flush ob_get_clean ob_get_length ob_get_level ob_get_status ob_get_contents ob_implicit_flush ob_list_handlers ksort krsort natsort natcasesort asort arsort sort rsort usort uasort uksort shuffle array_walk count end prev next reset current key min max in_array array_search extract compact array_fill range array_multisort array_push array_pop array_shift array_unshift array_splice array_slice array_merge array_merge_recursive array_keys array_values array_count_values array_reverse array_reduce array_pad array_flip array_change_key_case array_rand array_unique array_intersect array_intersect_assoc array_diff array_diff_assoc array_sum array_filter array_map array_chunk array_key_exists pos sizeof key_exists assert assert_options version_compare ftok str_rot13 aggregate session_name session_module_name session_save_path session_id session_regenerate_id session_decode session_register session_unregister session_is_registered session_encode session_start session_destroy session_unset session_set_save_handler session_cache_limiter session_cache_expire session_set_cookie_params session_get_cookie_params session_write_close preg_match preg_match_all preg_replace preg_replace_callback preg_split preg_quote preg_grep overload ctype_alnum ctype_alpha ctype_cntrl ctype_digit ctype_lower ctype_graph ctype_print ctype_punct ctype_space ctype_upper ctype_xdigit virtual apache_request_headers apache_note apache_lookup_uri apache_child_terminate apache_setenv apache_response_headers apache_get_version getallheaders mysql_connect mysql_pconnect mysql_close mysql_select_db mysql_create_db mysql_drop_db mysql_query mysql_unbuffered_query mysql_db_query mysql_list_dbs mysql_list_tables mysql_list_fields mysql_list_processes mysql_error mysql_errno mysql_affected_rows mysql_insert_id mysql_result mysql_num_rows mysql_num_fields mysql_fetch_row mysql_fetch_array mysql_fetch_assoc mysql_fetch_object mysql_data_seek mysql_fetch_lengths mysql_fetch_field mysql_field_seek mysql_free_result mysql_field_name mysql_field_table mysql_field_len mysql_field_type mysql_field_flags mysql_escape_string mysql_real_escape_string mysql_stat mysql_thread_id mysql_client_encoding mysql_get_client_info mysql_get_host_info mysql_get_proto_info mysql_get_server_info mysql_info mysql mysql_fieldname mysql_fieldtable mysql_fieldlen mysql_fieldtype mysql_fieldflags mysql_selectdb mysql_createdb mysql_dropdb mysql_freeresult mysql_numfields mysql_numrows mysql_listdbs mysql_listtables mysql_listfields mysql_db_name mysql_dbname mysql_tablename mysql_table_name pg_connect pg_pconnect pg_close pg_connection_status pg_connection_busy pg_connection_reset pg_host pg_dbname pg_port pg_tty pg_options pg_ping pg_query pg_send_query pg_cancel_query pg_fetch_result pg_fetch_row pg_fetch_assoc pg_fetch_array pg_fetch_object pg_fetch_all pg_affected_rows pg_get_result pg_result_seek pg_result_status pg_free_result pg_last_oid pg_num_rows pg_num_fields pg_field_name pg_field_num pg_field_size pg_field_type pg_field_prtlen pg_field_is_null pg_get_notify pg_get_pid pg_result_error pg_last_error pg_last_notice pg_put_line pg_end_copy pg_copy_to pg_copy_from pg_trace pg_untrace pg_lo_create pg_lo_unlink pg_lo_open pg_lo_close pg_lo_read pg_lo_write pg_lo_read_all pg_lo_import pg_lo_export pg_lo_seek pg_lo_tell pg_escape_string pg_escape_bytea pg_unescape_bytea pg_client_encoding pg_set_client_encoding pg_meta_data pg_convert pg_insert pg_update pg_delete pg_select pg_exec pg_getlastoid pg_cmdtuples pg_errormessage pg_numrows pg_numfields pg_fieldname pg_fieldsize pg_fieldtype pg_fieldnum pg_fieldprtlen pg_fieldisnull pg_freeresult pg_result pg_loreadall pg_locreate pg_lounlink pg_loopen pg_loclose pg_loread pg_lowrite pg_loimport pg_loexport echo print global static exit array empty eval isset unset die include require include_once require_once"),
multiLineStrings: !0,
hooks: {
$: function (e) {
return e.eatWhile(/[\w\$_]/), "variable-2"
},
"<": function (e, n) {
return e.match(/<</) ? (e.eatWhile(/[\w\.]/), n.tokenize = t(e.current().slice(3)), n.tokenize(e, n)) : !1
},
"#": function (e) {
while (!e.eol() && !e.match("?>", !1)) e.next();
return "comment"
},
"/": function (e) {
if (e.eat("/")) {
while (!e.eol() && !e.match("?>", !1)) e.next();
return "comment"
}
return !1
}
}
};
CodeMirror.defineMode("php", function (e, t) {
function s(e, t) {
var n = t.curMode == i;
e.sol() && t.pending != '"' && (t.pending = null);
if (!n) {
if (e.match(/^<\?\w*/)) return t.curMode = i, t.curState = t.php, "meta";
if (t.pending == '"') {
while (!e.eol() && e.next() != '"');
var s = "string"
} else if (t.pending && e.pos < t.pending.end) {
e.pos = t.pending.end;
var s = t.pending.style
} else var s = r.token(e, t.curState);
t.pending = null;
var o = e.current(),
u = o.search(/<\?/);
return u != -1 && (s == "string" && /\"$/.test(o) && !/\?>/.test(o) ? t.pending = '"' : t.pending = {
end: e.pos,
style: s
}, e.backUp(o.length - u)), s
}
return n && t.php.tokenize == null && e.match("?>") ? (t.curMode = r, t.curState = t.html, "meta") : i.token(e, t.curState)
}
var r = CodeMirror.getMode(e, "text/html"),
i = CodeMirror.getMode(e, n);
return {
startState: function () {
var e = CodeMirror.startState(r),
n = CodeMirror.startState(i);
return {
html: e,
php: n,
curMode: t.startOpen ? i : r,
curState: t.startOpen ? n : e,
pending: null
}
},
copyState: function (e) {
var t = e.html,
n = CodeMirror.copyState(r, t),
s = e.php,
o = CodeMirror.copyState(i, s),
u;
return e.curMode == r ? u = n : u = o, {
html: n,
php: o,
curMode: e.curMode,
curState: u,
pending: e.pending
}
},
token: s,
indent: function (e, t) {
return e.curMode != i && /^\s*<\//.test(t) || e.curMode == i && /^\?>/.test(t) ? r.indent(e.html, t) : e.curMode.indent(e.curState, t)
},
electricChars: "/{}:",
blockCommentStart: "/*",
blockCommentEnd: "*/",
lineComment: "//",
innerMode: function (e) {
return {
state: e.curState,
mode: e.curMode
}
}
}
}, "htmlmixed", "clike"), CodeMirror.defineMIME("application/x-httpd-php", "php"), CodeMirror.defineMIME("application/x-httpd-php-open", {
name: "php",
startOpen: !0
}), CodeMirror.defineMIME("text/x-php", n)
}(), define("vendor/codemirror_modes/php", function () {}), define("libs/orion", ["require", "exports", "module", "vendor/orion", "plugins/orion-codemirror", "plugins/orion-custom-editor", "vendor/codemirror_modes/clike", "vendor/codemirror_modes/javascript", "vendor/codemirror_modes/python", "vendor/codemirror_modes/ruby", "vendor/codemirror_modes/css", "vendor/codemirror_modes/xml", "vendor/codemirror_modes/htmlmixed", "vendor/codemirror_modes/php"], function (e, t, n) {
var r = e("vendor/orion");
e("plugins/orion-codemirror"), e("plugins/orion-custom-editor"), e("vendor/codemirror_modes/clike"), e("vendor/codemirror_modes/javascript"), e("vendor/codemirror_modes/python"), e("vendor/codemirror_modes/ruby"), e("vendor/codemirror_modes/css"), e("vendor/codemirror_modes/xml"), e("vendor/codemirror_modes/htmlmixed"), e("vendor/codemirror_modes/php"), n.exports = {
orion: r,
edit: r.require("orion/editor/customEditor")
}
}), define("widgets/editor/multi_editor/mobile", ["require", "exports", "module", "libs/utils", "widgets/editor/multi_editor/base", "jquery", "libs/orion"], function (e, t, n) {
function u(e, t) {
this.options = t || {}, this._files = {}, this.el = e
}
var r = e("libs/utils"),
i = e("widgets/editor/multi_editor/base"),
s = e("jquery"),
o = e("libs/orion");
r.inherits(u, i), u.prototype.addNewFile = function (e, t) {
this._files[e] = t
}, u.prototype.getFile = function (e) {
if (this._files[e] != null) return {
filename: e,
content: this._files[e]
};
throw new Error("Unkown file: " + e)
}, u.prototype.hasFile = function (e) {
return Object.keys(this._files).indexOf(e) >= 0
}, u.prototype.files = function () {
return _.map(this._files, function (e, t) {
return this.getFile(t)
}.bind(this))
}, u.prototype.fileNames = function () {
return _.map(this._files, function (e, t) {
return t
})
}, u.prototype.renameFile = function (e, t) {
this._files[t] = this._files[e], this.deleteFile(e)
}, u.prototype.deleteFile = function (e) {
delete this._files[e], this.currentFile === e && this.showFile(Object.keys(this._files)[0])
}, u.prototype.showFile = function (e) {
this.currentFile = e, this.$editor && this.$editor.remove(), this.$editor = s("<div/>").css({
width: "100%",
height: "100%"
}).addClass("orion-editor").appendTo(this.el), this.editor = o.edit({
parent: this.$editor[0],
lang: this._getLang(e)
}), this.editor.setText(this._files[e]), this.editor.getTextView().getModel().addEventListener("Changed", this._onChange.bind(this)), this.editor.getTextView().addEventListener("Focus", this.trigger.bind(this, "focus"))
}, u.prototype._onChange = function () {
this._files[this.currentFile] = this.editor.getText(), this.trigger("change")
};
var a = {
js: "javascript",
css: "css",
html: "htmlmixed",
xml: "html",
rb: "ruby",
py: "python",
php: "php"
};
u.prototype._getLang = function (e) {
return a[r.extname(e)]
}, u.prototype.getCurrentFile = function () {
return this.getFile(this.currentFile)
}, u.prototype.setFileContent = function (e, t) {
e === this.currentFile ? this.editor.setText(t) : this._files[e] = t
}, u.prototype.focus = function () {
this.editor.getTextView().focus()
}, u.prototype.addCommand = function () {}, u.prototype.setTheme = function () {}, u.prototype.setReadOnly = function () {}, u.prototype.destroy = function () {}, n.exports = u
}),
function () {
function e(e) {
var t = function (e, t) {
return i("", e, t)
}, s = n;
e && (n[e] || (n[e] = {}), s = n[e]);
if (!s.define || !s.define.packaged) r.original = s.define, s.define = r, s.define.packaged = !0;
if (!s.require || !s.require.packaged) i.original = s.require, s.require = t, s.require.packaged = !0
}
var t = "ace",
n = function () {
return this
}();
if (!t && typeof requirejs != "undefined") return;
var r = function (e, t, n) {
if (typeof e != "string") {
r.original ? r.original.apply(window, arguments) : (console.error("dropping module because define wasn't a string."), console.trace());
return
}
arguments.length == 2 && (n = t), r.modules || (r.modules = {}, r.payloads = {}), r.payloads[e] = n, r.modules[e] = null
}, i = function (e, t, n) {
if (Object.prototype.toString.call(t) === "[object Array]") {
var r = [];
for (var s = 0, u = t.length; s < u; ++s) {
var a = o(e, t[s]);
if (!a && i.original) return i.original.apply(window, arguments);
r.push(a)
}
n && n.apply(null, r)
} else {
if (typeof t == "string") {
var f = o(e, t);
return !f && i.original ? i.original.apply(window, arguments) : (n && n(), f)
}
if (i.original) return i.original.apply(window, arguments)
}
}, s = function (e, t) {
if (t.indexOf("!") !== -1) {
var n = t.split("!");
return s(e, n[0]) + "!" + s(e, n[1])
}
if (t.charAt(0) == ".") {
var r = e.split("/").slice(0, -1).join("/");
t = r + "/" + t;
while (t.indexOf(".") !== -1 && i != t) {
var i = t;
t = t.replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, "")
}
}
return t
}, o = function (e, t) {
t = s(e, t);
var n = r.modules[t];
if (!n) {
n = r.payloads[t];
if (typeof n == "function") {
var o = {}, u = {
id: t,
uri: "",
exports: o,
packaged: !0
}, a = function (e, n) {
return i(t, e, n)
}, f = n(a, o, u);
o = f || u.exports, r.modules[t] = o, delete r.payloads[t]
}
n = r.modules[t] = o || n
}
return n
};
e(t)
}(), ace.define("ace/ace", ["require", "exports", "module", "ace/lib/fixoldbrowsers", "ace/lib/dom", "ace/lib/event", "ace/editor", "ace/edit_session", "ace/undomanager", "ace/virtual_renderer", "ace/multi_select", "ace/worker/worker_client", "ace/keyboard/hash_handler", "ace/placeholder", "ace/mode/folding/fold_mode", "ace/theme/textmate", "ace/config"], function (e, t, n) {
e("./lib/fixoldbrowsers");
var r = e("./lib/dom"),
i = e("./lib/event"),
s = e("./editor").Editor,
o = e("./edit_session").EditSession,
u = e("./undomanager").UndoManager,
a = e("./virtual_renderer").VirtualRenderer,
f = e("./multi_select").MultiSelect;
e("./worker/worker_client"), e("./keyboard/hash_handler"), e("./placeholder"), e("./mode/folding/fold_mode"), e("./theme/textmate"), t.config = e("./config"), t.require = e, t.edit = function (e) {
if (typeof e == "string") {
var n = e,
e = document.getElementById(n);
if (!e) throw "ace.edit can't find div #" + n
}
if (e.env && e.env.editor instanceof s) return e.env.editor;
var o = t.createEditSession(r.getInnerText(e));
e.innerHTML = "";
var u = new s(new a(e));
new f(u), u.setSession(o);
var l = {
document: o,
editor: u,
onResize: u.resize.bind(u, null)
};
return i.addListener(window, "resize", l.onResize), u.on("destroy", function () {
i.removeListener(window, "resize", l.onResize)
}), e.env = u.env = l, u
}, t.createEditSession = function (e, t) {
var n = new o(e, t);
return n.setUndoManager(new u), n
}, t.EditSession = o, t.UndoManager = u
}), ace.define("ace/lib/fixoldbrowsers", ["require", "exports", "module", "ace/lib/regexp", "ace/lib/es5-shim"], function (e, t, n) {
e("./regexp"), e("./es5-shim")
}), ace.define("ace/lib/regexp", ["require", "exports", "module"], function (e, t, n) {
function r(e) {
return (e.global ? "g" : "") + (e.ignoreCase ? "i" : "") + (e.multiline ? "m" : "") + (e.extended ? "x" : "") + (e.sticky ? "y" : "")
}
function i(e, t, n) {
if (Array.prototype.indexOf) return e.indexOf(t, n);
for (var r = n || 0; r < e.length; r++)
if (e[r] === t) return r;
return -1
}
var s = {
exec: RegExp.prototype.exec,
test: RegExp.prototype.test,
match: String.prototype.match,
replace: String.prototype.replace,
split: String.prototype.split
}, o = s.exec.call(/()??/, "")[1] === undefined,
u = function () {
var e = /^/g;
return s.test.call(e, ""), !e.lastIndex
}();
if (u && o) return;
RegExp.prototype.exec = function (e) {
var t = s.exec.apply(this, arguments),
n, a;
if (typeof e == "string" && t) {
!o && t.length > 1 && i(t, "") > -1 && (a = RegExp(this.source, s.replace.call(r(this), "g", "")), s.replace.call(e.slice(t.index), a, function () {
for (var e = 1; e < arguments.length - 2; e++) arguments[e] === undefined && (t[e] = undefined)
}));
if (this._xregexp && this._xregexp.captureNames)
for (var f = 1; f < t.length; f++) n = this._xregexp.captureNames[f - 1], n && (t[n] = t[f]);
!u && this.global && !t[0].length && this.lastIndex > t.index && this.lastIndex--
}
return t
}, u || (RegExp.prototype.test = function (e) {
var t = s.exec.call(this, e);
return t && this.global && !t[0].length && this.lastIndex > t.index && this.lastIndex--, !! t
})
}), ace.define("ace/lib/es5-shim", ["require", "exports", "module"], function (e, t, n) {
function r() {}
function i(e) {
try {
return Object.defineProperty(e, "sentinel", {}), "sentinel" in e
} catch (t) {}
}
function s(e) {
return e = +e, e !== e ? e = 0 : e !== 0 && e !== 1 / 0 && e !== -1 / 0 && (e = (e > 0 || -1) * Math.floor(Math.abs(e))), e
}
function o(e) {
var t = typeof e;
return e === null || t === "undefined" || t === "boolean" || t === "number" || t === "string"
}
function u(e) {
var t, n, r;
if (o(e)) return e;
n = e.valueOf;
if (typeof n == "function") {
t = n.call(e);
if (o(t)) return t
}
r = e.toString;
if (typeof r == "function") {
t = r.call(e);
if (o(t)) return t
}
throw new TypeError
}
Function.prototype.bind || (Function.prototype.bind = function (e) {
var t = this;
if (typeof t != "function") throw new TypeError("Function.prototype.bind called on incompatible " + t);
var n = c.call(arguments, 1),
i = function () {
if (this instanceof i) {
var r = t.apply(this, n.concat(c.call(arguments)));
return Object(r) === r ? r : this
}
return t.apply(e, n.concat(c.call(arguments)))
};
return t.prototype && (r.prototype = t.prototype, i.prototype = new r, r.prototype = null), i
});
var a = Function.prototype.call,
f = Array.prototype,
l = Object.prototype,
c = f.slice,
h = a.bind(l.toString),
p = a.bind(l.hasOwnProperty),
d, v, m, g, y;
if (y = p(l, "__defineGetter__")) d = a.bind(l.__defineGetter__), v = a.bind(l.__defineSetter__), m = a.bind(l.__lookupGetter__), g = a.bind(l.__lookupSetter__);
if ([1, 2].splice(0).length != 2)
if (! function () {
function e(e) {
var t = new Array(e + 2);
return t[0] = t[1] = 0, t
}
var t = [],
n;
t.splice.apply(t, e(20)), t.splice.apply(t, e(26)), n = t.length, t.splice(5, 0, "XXX"), n + 1 == t.length;
if (n + 1 == t.length) return !0
}()) Array.prototype.splice = function (e, t) {
var n = this.length;
e > 0 ? e > n && (e = n) : e == void 0 ? e = 0 : e < 0 && (e = Math.max(n + e, 0)), e + t < n || (t = n - e);
var r = this.slice(e, e + t),
i = c.call(arguments, 2),
s = i.length;
if (e === n) s && this.push.apply(this, i);
else {
var o = Math.min(t, n - e),
u = e + o,
a = u + s - o,
f = n - u,
l = n - o;
if (a < u)
for (var h = 0; h < f; ++h) this[a + h] = this[u + h];
else if (a > u)
for (h = f; h--;) this[a + h] = this[u + h];
if (s && e === l) this.length = l, this.push.apply(this, i);
else {
this.length = l + s;
for (h = 0; h < s; ++h) this[e + h] = i[h]
}
}
return r
};
else {
var b = Array.prototype.splice;
Array.prototype.splice = function (e, t) {
return arguments.length ? b.apply(this, [e === void 0 ? 0 : e, t === void 0 ? this.length - e : t].concat(c.call(arguments, 2))) : []
}
}
Array.isArray || (Array.isArray = function (e) {
return h(e) == "[object Array]"
});
var w = Object("a"),
E = w[0] != "a" || !(0 in w);
Array.prototype.forEach || (Array.prototype.forEach = function (e) {
var t = F(this),
n = E && h(this) == "[object String]" ? this.split("") : t,
r = arguments[1],
i = -1,
s = n.length >>> 0;
if (h(e) != "[object Function]") throw new TypeError;
while (++i < s) i in n && e.call(r, n[i], i, t)
}), Array.prototype.map || (Array.prototype.map = function (e) {
var t = F(this),
n = E && h(this) == "[object String]" ? this.split("") : t,
r = n.length >>> 0,
i = Array(r),
s = arguments[1];
if (h(e) != "[object Function]") throw new TypeError(e + " is not a function");
for (var o = 0; o < r; o++) o in n && (i[o] = e.call(s, n[o], o, t));
return i
}), Array.prototype.filter || (Array.prototype.filter = function (e) {
var t = F(this),
n = E && h(this) == "[object String]" ? this.split("") : t,
r = n.length >>> 0,
i = [],
s, o = arguments[1];
if (h(e) != "[object Function]") throw new TypeError(e + " is not a function");
for (var u = 0; u < r; u++) u in n && (s = n[u], e.call(o, s, u, t) && i.push(s));
return i
}), Array.prototype.every || (Array.prototype.every = function (e) {
var t = F(this),
n = E && h(this) == "[object String]" ? this.split("") : t,
r = n.length >>> 0,
i = arguments[1];
if (h(e) != "[object Function]") throw new TypeError(e + " is not a function");
for (var s = 0; s < r; s++)
if (s in n && !e.call(i, n[s], s, t)) return !1;
return !0
}), Array.prototype.some || (Array.prototype.some = function (e) {
var t = F(this),
n = E && h(this) == "[object String]" ? this.split("") : t,
r = n.length >>> 0,
i = arguments[1];
if (h(e) != "[object Function]") throw new TypeError(e + " is not a function");
for (var s = 0; s < r; s++)
if (s in n && e.call(i, n[s], s, t)) return !0;
return !1
}), Array.prototype.reduce || (Array.prototype.reduce = function (e) {
var t = F(this),
n = E && h(this) == "[object String]" ? this.split("") : t,
r = n.length >>> 0;
if (h(e) != "[object Function]") throw new TypeError(e + " is not a function");
if (!r && arguments.length == 1) throw new TypeError("reduce of empty array with no initial value");
var i = 0,
s;
if (arguments.length >= 2) s = arguments[1];
else
do {
if (i in n) {
s = n[i++];
break
}
if (++i >= r) throw new TypeError("reduce of empty array with no initial value")
} while (!0);
for (; i < r; i++) i in n && (s = e.call(void 0, s, n[i], i, t));
return s
}), Array.prototype.reduceRight || (Array.prototype.reduceRight = function (e) {
var t = F(this),
n = E && h(this) == "[object String]" ? this.split("") : t,
r = n.length >>> 0;
if (h(e) != "[object Function]") throw new TypeError(e + " is not a function");
if (!r && arguments.length == 1) throw new TypeError("reduceRight of empty array with no initial value");
var i, s = r - 1;
if (arguments.length >= 2) i = arguments[1];
else
do {
if (s in n) {
i = n[s--];
break
}
if (--s < 0) throw new TypeError("reduceRight of empty array with no initial value")
} while (!0);
do s in this && (i = e.call(void 0, i, n[s], s, t)); while (s--);
return i
});
if (!Array.prototype.indexOf || [0, 1].indexOf(1, 2) != -1) Array.prototype.indexOf = function (e) {
var t = E && h(this) == "[object String]" ? this.split("") : F(this),
n = t.length >>> 0;
if (!n) return -1;
var r = 0;
arguments.length > 1 && (r = s(arguments[1])), r = r >= 0 ? r : Math.max(0, n + r);
for (; r < n; r++)
if (r in t && t[r] === e) return r;
return -1
};
if (!Array.prototype.lastIndexOf || [0, 1].lastIndexOf(0, -3) != -1) Array.prototype.lastIndexOf = function (e) {
var t = E && h(this) == "[object String]" ? this.split("") : F(this),
n = t.length >>> 0;
if (!n) return -1;
var r = n - 1;
arguments.length > 1 && (r = Math.min(r, s(arguments[1]))), r = r >= 0 ? r : n - Math.abs(r);
for (; r >= 0; r--)
if (r in t && e === t[r]) return r;
return -1
};
Object.getPrototypeOf || (Object.getPrototypeOf = function (e) {
return e.__proto__ || (e.constructor ? e.constructor.prototype : l)
});
if (!Object.getOwnPropertyDescriptor) {
var S = "Object.getOwnPropertyDescriptor called on a non-object: ";
Object.getOwnPropertyDescriptor = function (e, t) {
if (typeof e != "object" && typeof e != "function" || e === null) throw new TypeError(S + e);
if (!p(e, t)) return;
var n, r, i;
n = {
enumerable: !0,
configurable: !0
};
if (y) {
var s = e.__proto__;
e.__proto__ = l;
var r = m(e, t),
i = g(e, t);
e.__proto__ = s;
if (r || i) return r && (n.get = r), i && (n.set = i), n
}
return n.value = e[t], n
}
}
Object.getOwnPropertyNames || (Object.getOwnPropertyNames = function (e) {
return Object.keys(e)
});
if (!Object.create) {
var x;
Object.prototype.__proto__ === null ? x = function () {
return {
__proto__: null
}
} : x = function () {
var e = {};
for (var t in e) e[t] = null;
return e.constructor = e.hasOwnProperty = e.propertyIsEnumerable = e.isPrototypeOf = e.toLocaleString = e.toString = e.valueOf = e.__proto__ = null, e
}, Object.create = function (e, t) {
var n;
if (e === null) n = x();
else {
if (typeof e != "object") throw new TypeError("typeof prototype[" + typeof e + "] != 'object'");
var r = function () {};
r.prototype = e, n = new r, n.__proto__ = e
}
return t !== void 0 && Object.defineProperties(n, t), n
}
}
if (Object.defineProperty) {
var T = i({}),
N = typeof document == "undefined" || i(document.createElement("div"));
if (!T || !N) var C = Object.defineProperty
}
if (!Object.defineProperty || C) {
var k = "Property description must be an object: ",
L = "Object.defineProperty called on non-object: ",
A = "getters & setters can not be defined on this javascript engine";
Object.defineProperty = function (e, t, n) {
if (typeof e != "object" && typeof e != "function" || e === null) throw new TypeError(L + e);
if (typeof n != "object" && typeof n != "function" || n === null) throw new TypeError(k + n);
if (C) try {
return C.call(Object, e, t, n)
} catch (r) {}
if (p(n, "value"))
if (y && (m(e, t) || g(e, t))) {
var i = e.__proto__;
e.__proto__ = l, delete e[t], e[t] = n.value, e.__proto__ = i
} else e[t] = n.value;
else {
if (!y) throw new TypeError(A);
p(n, "get") && d(e, t, n.get), p(n, "set") && v(e, t, n.set)
}
return e
}
}
Object.defineProperties || (Object.defineProperties = function (e, t) {
for (var n in t) p(t, n) && Object.defineProperty(e, n, t[n]);
return e
}), Object.seal || (Object.seal = function (e) {
return e
}), Object.freeze || (Object.freeze = function (e) {
return e
});
try {
Object.freeze(function () {})
} catch (O) {
Object.freeze = function (e) {
return function (t) {
return typeof t == "function" ? t : e(t)
}
}(Object.freeze)
}
Object.preventExtensions || (Object.preventExtensions = function (e) {
return e
}), Object.isSealed || (Object.isSealed = function (e) {
return !1
}), Object.isFrozen || (Object.isFrozen = function (e) {
return !1
}), Object.isExtensible || (Object.isExtensible = function (e) {
if (Object(e) === e) throw new TypeError;
var t = "";
while (p(e, t)) t += "?";
e[t] = !0;
var n = p(e, t);
return delete e[t], n
});
if (!Object.keys) {
var M = !0,
_ = ["toString", "toLocaleString", "valueOf", "hasOwnProperty", "isPrototypeOf", "propertyIsEnumerable", "constructor"],
D = _.length;
for (var P in {
toString: null
}) M = !1;
Object.keys = function I(e) {
if (typeof e != "object" && typeof e != "function" || e === null) throw new TypeError("Object.keys called on a non-object");
var I = [];
for (var t in e) p(e, t) && I.push(t);
if (M)
for (var n = 0, r = D; n < r; n++) {
var i = _[n];
p(e, i) && I.push(i)
}
return I
}
}
Date.now || (Date.now = function () {
return (new Date).getTime()
});
var H = " \n \f\r Â áš€á Žâ€€â€â€‚â€ƒâ€„â€…â€†â€‡â€ˆâ€‰â€Šâ€¯âŸã€€\u2028\u2029";
if (!String.prototype.trim || H.trim()) {
H = "[" + H + "]";
var B = new RegExp("^" + H + H + "*"),
j = new RegExp(H + H + "*$");
String.prototype.trim = function () {
return String(this).replace(B, "").replace(j, "")
}
}
var F = function (e) {
if (e == null) throw new TypeError("can't convert " + e + " to object");
return Object(e)
}
}), ace.define("ace/lib/dom", ["require", "exports", "module"], function (e, t, n) {
if (typeof document == "undefined") return;
var r = "http://www.w3.org/1999/xhtml";
t.getDocumentHead = function (e) {
return e || (e = document), e.head || e.getElementsByTagName("head")[0] || e.documentElement
}, t.createElement = function (e, t) {
return document.createElementNS ? document.createElementNS(t || r, e) : document.createElement(e)
}, t.hasCssClass = function (e, t) {
var n = e.className.split(/\s+/g);
return n.indexOf(t) !== -1
}, t.addCssClass = function (e, n) {
t.hasCssClass(e, n) || (e.className += " " + n)
}, t.removeCssClass = function (e, t) {
var n = e.className.split(/\s+/g);
for (;;) {
var r = n.indexOf(t);
if (r == -1) break;
n.splice(r, 1)
}
e.className = n.join(" ")
}, t.toggleCssClass = function (e, t) {
var n = e.className.split(/\s+/g),
r = !0;
for (;;) {
var i = n.indexOf(t);
if (i == -1) break;
r = !1, n.splice(i, 1)
}
return r && n.push(t), e.className = n.join(" "), r
}, t.setCssClass = function (e, n, r) {
r ? t.addCssClass(e, n) : t.removeCssClass(e, n)
}, t.hasCssString = function (e, t) {
var n = 0,
r;
t = t || document;
if (t.createStyleSheet && (r = t.styleSheets)) {
while (n < r.length)
if (r[n++].owningElement.id === e) return !0
} else if (r = t.getElementsByTagName("style"))
while (n < r.length)
if (r[n++].id === e) return !0;
return !1
}, t.importCssString = function (e, n, i) {
i = i || document;
if (n && t.hasCssString(n, i)) return null;
var s;
i.createStyleSheet ? (s = i.createStyleSheet(), s.cssText = e, n && (s.owningElement.id = n)) : (s = i.createElementNS ? i.createElementNS(r, "style") : i.createElement("style"), s.appendChild(i.createTextNode(e)), n && (s.id = n), t.getDocumentHead(i).appendChild(s))
}, t.importCssStylsheet = function (e, n) {
if (n.createStyleSheet) n.createStyleSheet(e);
else {
var r = t.createElement("link");
r.rel = "stylesheet", r.href = e, t.getDocumentHead(n).appendChild(r)
}
}, t.getInnerWidth = function (e) {
return parseInt(t.computedStyle(e, "paddingLeft"), 10) + parseInt(t.computedStyle(e, "paddingRight"), 10) + e.clientWidth
}, t.getInnerHeight = function (e) {
return parseInt(t.computedStyle(e, "paddingTop"), 10) + parseInt(t.computedStyle(e, "paddingBottom"), 10) + e.clientHeight
}, window.pageYOffset !== undefined ? (t.getPageScrollTop = function () {
return window.pageYOffset
}, t.getPageScrollLeft = function () {
return window.pageXOffset
}) : (t.getPageScrollTop = function () {
return document.body.scrollTop
}, t.getPageScrollLeft = function () {
return document.body.scrollLeft
}), window.getComputedStyle ? t.computedStyle = function (e, t) {
return t ? (window.getComputedStyle(e, "") || {})[t] || "" : window.getComputedStyle(e, "") || {}
} : t.computedStyle = function (e, t) {
return t ? e.currentStyle[t] : e.currentStyle
}, t.scrollbarWidth = function (e) {
var n = t.createElement("ace_inner");
n.style.width = "100%", n.style.minWidth = "0px", n.style.height = "200px", n.style.display = "block";
var r = t.createElement("ace_outer"),
i = r.style;
i.position = "absolute", i.left = "-10000px", i.overflow = "hidden", i.width = "200px", i.minWidth = "0px", i.height = "150px", i.display = "block", r.appendChild(n);
var s = e.documentElement;
s.appendChild(r);
var o = n.offsetWidth;
i.overflow = "scroll";
var u = n.offsetWidth;
return o == u && (u = r.clientWidth), s.removeChild(r), o - u
}, t.setInnerHtml = function (e, t) {
var n = e.cloneNode(!1);
return n.innerHTML = t, e.parentNode.replaceChild(n, e), n
}, "textContent" in document.documentElement ? (t.setInnerText = function (e, t) {
e.textContent = t
}, t.getInnerText = function (e) {
return e.textContent
}) : (t.setInnerText = function (e, t) {
e.innerText = t
}, t.getInnerText = function (e) {
return e.innerText
}), t.getParentWindow = function (e) {
return e.defaultView || e.parentWindow
}
}), ace.define("ace/lib/event", ["require", "exports", "module", "ace/lib/keys", "ace/lib/useragent", "ace/lib/dom"], function (e, t, n) {
function r(e, t, n) {
var r = 0;
!s.isOpera || "KeyboardEvent" in window || !s.isMac ? r = 0 | (t.ctrlKey ? 1 : 0) | (t.altKey ? 2 : 0) | (t.shiftKey ? 4 : 0) | (t.metaKey ? 8 : 0) : r = 0 | (t.metaKey ? 1 : 0) | (t.altKey ? 2 : 0) | (t.shiftKey ? 4 : 0) | (t.ctrlKey ? 8 : 0);
if (!s.isMac && u) {
if (u[91] || u[92]) r |= 8;
if (u.altGr) {
if ((3 & r) == 3) return;
u.altGr = 0
}
if (n === 18 || n === 17) {
var o = t.location || t.keyLocation;
if (n === 17 && o === 1) a = t.timeStamp;
else if (n === 18 && r === 3 && o === 2) {
var f = -a;
a = t.timeStamp, f += a, f < 3 && (u.altGr = !0)
}
}
}
if (n in i.MODIFIER_KEYS) {
switch (i.MODIFIER_KEYS[n]) {
case "Alt":
r = 2;
break;
case "Shift":
r = 4;
break;
case "Ctrl":
r = 1;
break;
default:
r = 8
}
n = 0
}
r & 8 && (n === 91 || n === 93) && (n = 0);
if (!r && n === 13)
if (t.location || t.keyLocation === 3) {
e(t, r, -n);
if (t.defaultPrevented) return
}
return !!r || n in i.FUNCTION_KEYS || n in i.PRINTABLE_KEYS ? e(t, r, n) : !1
}
var i = e("./keys"),
s = e("./useragent"),
o = e("./dom");
t.addListener = function (e, t, n) {
if (e.addEventListener) return e.addEventListener(t, n, !1);
if (e.attachEvent) {
var r = function () {
n.call(e, window.event)
};
n._wrapper = r, e.attachEvent("on" + t, r)
}
}, t.removeListener = function (e, t, n) {
if (e.removeEventListener) return e.removeEventListener(t, n, !1);
e.detachEvent && e.detachEvent("on" + t, n._wrapper || n)
}, t.stopEvent = function (e) {
return t.stopPropagation(e), t.preventDefault(e), !1
}, t.stopPropagation = function (e) {
e.stopPropagation ? e.stopPropagation() : e.cancelBubble = !0
}, t.preventDefault = function (e) {
e.preventDefault ? e.preventDefault() : e.returnValue = !1
}, t.getButton = function (e) {
return e.type == "dblclick" ? 0 : e.type == "contextmenu" || e.ctrlKey && s.isMac ? 2 : e.preventDefault ? e.button : {
1: 0,
2: 2,
4: 1
}[e.button]
}, t.capture = function (e, n, r) {
function i(e) {
n && n(e), r && r(e), t.removeListener(document, "mousemove", n, !0), t.removeListener(document, "mouseup", i, !0), t.removeListener(document, "dragstart", i, !0)
}
t.addListener(document, "mousemove", n, !0), t.addListener(document, "mouseup", i, !0), t.addListener(document, "dragstart", i, !0)
}, t.addMouseWheelListener = function (e, n) {
if ("onmousewheel" in e) {
var r = 8;
t.addListener(e, "mousewheel", function (e) {
e.wheelDeltaX !== undefined ? (e.wheelX = -e.wheelDeltaX / r, e.wheelY = -e.wheelDeltaY / r) : (e.wheelX = 0, e.wheelY = -e.wheelDelta / r), n(e)
})
} else "onwheel" in e ? t.addListener(e, "wheel", function (e) {
e.wheelX = (e.deltaX || 0) * 5, e.wheelY = (e.deltaY || 0) * 5, n(e)
}) : t.addListener(e, "DOMMouseScroll", function (e) {
e.axis && e.axis == e.HORIZONTAL_AXIS ? (e.wheelX = (e.detail || 0) * 5, e.wheelY = 0) : (e.wheelX = 0, e.wheelY = (e.detail || 0) * 5), n(e)
})
}, t.addMultiMouseDownListener = function (e, n, r, i) {
var o = 0,
u, a, f, l = {
2: "dblclick",
3: "tripleclick",
4: "quadclick"
};
t.addListener(e, "mousedown", function (e) {
t.getButton(e) != 0 ? o = 0 : e.detail > 1 ? (o++, o > 4 && (o = 1)) : o = 1;
if (s.isIE) {
var n = Math.abs(e.clientX - u) > 5 || Math.abs(e.clientY - a) > 5;
n && (o = 1), o == 1 && (u = e.clientX, a = e.clientY)
}
r[i]("mousedown", e);
if (o > 4) o = 0;
else if (o > 1) return r[i](l[o], e)
}), s.isOldIE && t.addListener(e, "dblclick", function (e) {
o = 2, f && clearTimeout(f), f = setTimeout(function () {
f = null
}, n[o - 1] || 600), r[i]("mousedown", e), r[i](l[o], e)
})
};
var u = null,
a = 0;
t.addCommandKeyListener = function (e, n) {
var i = t.addListener;
if (s.isOldGecko || s.isOpera && !("KeyboardEvent" in window)) {
var o = null;
i(e, "keydown", function (e) {
o = e.keyCode
}), i(e, "keypress", function (e) {
return r(n, e, o)
})
} else {
var a = null;
i(e, "keydown", function (e) {
u[e.keyCode] = !0;
var t = r(n, e, e.keyCode);
return a = e.defaultPrevented, t
}), i(e, "keypress", function (e) {
a && (e.ctrlKey || e.altKey || e.shiftKey || e.metaKey) && (t.stopEvent(e), a = null)
}), i(e, "keyup", function (e) {
u[e.keyCode] = null
}), u || (u = Object.create(null), i(window, "focus", function (e) {
u = Object.create(null)
}))
}
};
if (window.postMessage && !s.isOldIE) {
var f = 1;
t.nextTick = function (e, n) {
n = n || window;
var r = "zero-timeout-message-" + f;
t.addListener(n, "message", function i(s) {
s.data == r && (t.stopPropagation(s), t.removeListener(n, "message", i), e())
}), n.postMessage(r, "*")
}
}
t.nextFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame || window.oRequestAnimationFrame, t.nextFrame ? t.nextFrame = t.nextFrame.bind(window) : t.nextFrame = function (e) {
setTimeout(e, 17)
}
}), ace.define("ace/lib/keys", ["require", "exports", "module", "ace/lib/oop"], function (e, t, n) {
var r = e("./oop"),
i = function () {
var e = {
MODIFIER_KEYS: {
16: "Shift",
17: "Ctrl",
18: "Alt",
224: "Meta"
},
KEY_MODS: {
ctrl: 1,
alt: 2,
option: 2,
shift: 4,
meta: 8,
command: 8,
cmd: 8
},
FUNCTION_KEYS: {
8: "Backspace",
9: "Tab",
13: "Return",
19: "Pause",
27: "Esc",
32: "Space",
33: "PageUp",
34: "PageDown",
35: "End",
36: "Home",
37: "Left",
38: "Up",
39: "Right",
40: "Down",
44: "Print",
45: "Insert",
46: "Delete",
96: "Numpad0",
97: "Numpad1",
98: "Numpad2",
99: "Numpad3",
100: "Numpad4",
101: "Numpad5",
102: "Numpad6",
103: "Numpad7",
104: "Numpad8",
105: "Numpad9",
"-13": "NumpadEnter",
112: "F1",
113: "F2",
114: "F3",
115: "F4",
116: "F5",
117: "F6",
118: "F7",
119: "F8",
120: "F9",
121: "F10",
122: "F11",
123: "F12",
144: "Numlock",
145: "Scrolllock"
},
PRINTABLE_KEYS: {
32: " ",
48: "0",
49: "1",
50: "2",
51: "3",
52: "4",
53: "5",
54: "6",
55: "7",
56: "8",
57: "9",
59: ";",
61: "=",
65: "a",
66: "b",
67: "c",
68: "d",
69: "e",
70: "f",
71: "g",
72: "h",
73: "i",
74: "j",
75: "k",
76: "l",
77: "m",
78: "n",
79: "o",
80: "p",
81: "q",
82: "r",
83: "s",
84: "t",
85: "u",
86: "v",
87: "w",
88: "x",
89: "y",
90: "z",
107: "+",
109: "-",
110: ".",
188: ",",
190: ".",
191: "/",
192: "`",
219: "[",
220: "\\",
221: "]",
222: "'"
}
};
for (var t in e.FUNCTION_KEYS) {
var n = e.FUNCTION_KEYS[t].toLowerCase();
e[n] = parseInt(t, 10)
}
return r.mixin(e, e.MODIFIER_KEYS), r.mixin(e, e.PRINTABLE_KEYS), r.mixin(e, e.FUNCTION_KEYS), e.enter = e["return"], e.escape = e.esc, e.del = e["delete"], e[173] = "-", e
}();
r.mixin(t, i), t.keyCodeToString = function (e) {
return (i[e] || String.fromCharCode(e)).toLowerCase()
}
}), ace.define("ace/lib/oop", ["require", "exports", "module"], function (e, t, n) {
t.inherits = function () {
var e = function () {};
return function (t, n) {
e.prototype = n.prototype, t.super_ = n.prototype, t.prototype = new e, t.prototype.constructor = t
}
}(), t.mixin = function (e, t) {
for (var n in t) e[n] = t[n];
return e
}, t.implement = function (e, n) {
t.mixin(e, n)
}
}), ace.define("ace/lib/useragent", ["require", "exports", "module"], function (e, t, n) {
t.OS = {
LINUX: "LINUX",
MAC: "MAC",
WINDOWS: "WINDOWS"
}, t.getOS = function () {
return t.isMac ? t.OS.MAC : t.isLinux ? t.OS.LINUX : t.OS.WINDOWS
};
if (typeof navigator != "object") return;
var r = (navigator.platform.match(/mac|win|linux/i) || ["other"])[0].toLowerCase(),
i = navigator.userAgent;
t.isWin = r == "win", t.isMac = r == "mac", t.isLinux = r == "linux", t.isIE = (navigator.appName == "Microsoft Internet Explorer" || navigator.appName.indexOf("MSAppHost") >= 0) && parseFloat(navigator.userAgent.match(/MSIE ([0-9]+[\.0-9]+)/)[1]), t.isOldIE = t.isIE && t.isIE < 9, t.isGecko = t.isMozilla = window.controllers && window.navigator.product === "Gecko", t.isOldGecko = t.isGecko && parseInt((navigator.userAgent.match(/rv\:(\d+)/) || [])[1], 10) < 4, t.isOpera = window.opera && Object.prototype.toString.call(window.opera) == "[object Opera]", t.isWebKit = parseFloat(i.split("WebKit/")[1]) || undefined, t.isChrome = parseFloat(i.split(" Chrome/")[1]) || undefined, t.isAIR = i.indexOf("AdobeAIR") >= 0, t.isIPad = i.indexOf("iPad") >= 0, t.isTouchPad = i.indexOf("TouchPad") >= 0
}), ace.define("ace/editor", ["require", "exports", "module", "ace/lib/fixoldbrowsers", "ace/lib/oop", "ace/lib/dom", "ace/lib/lang", "ace/lib/useragent", "ace/keyboard/textinput", "ace/mouse/mouse_handler", "ace/mouse/fold_handler", "ace/keyboard/keybinding", "ace/edit_session", "ace/search", "ace/range", "ace/lib/event_emitter", "ace/commands/command_manager", "ace/commands/default_commands", "ace/config"], function (e, t, n) {
e("./lib/fixoldbrowsers");
var r = e("./lib/oop"),
i = e("./lib/dom"),
s = e("./lib/lang"),
o = e("./lib/useragent"),
u = e("./keyboard/textinput").TextInput,
a = e("./mouse/mouse_handler").MouseHandler,
f = e("./mouse/fold_handler").FoldHandler,
l = e("./keyboard/keybinding").KeyBinding,
c = e("./edit_session").EditSession,
h = e("./search").Search,
p = e("./range").Range,
d = e("./lib/event_emitter").EventEmitter,
v = e("./commands/command_manager").CommandManager,
m = e("./commands/default_commands").commands,
g = e("./config"),
y = function (e, t) {
var n = e.getContainerElement();
this.container = n, this.renderer = e, this.commands = new v(o.isMac ? "mac" : "win", m), this.textInput = new u(e.getTextAreaContainer(), this), this.renderer.textarea = this.textInput.getElement(), this.keyBinding = new l(this), this.$mouseHandler = new a(this), new f(this), this.$blockScrolling = 0, this.$search = (new h).set({
wrap: !0
}), this.$historyTracker = this.$historyTracker.bind(this), this.commands.on("exec", this.$historyTracker), this.$initOperationListeners(), this._$emitInputEvent = s.delayedCall(function () {
this._signal("input", {}), this.session.bgTokenizer && this.session.bgTokenizer.scheduleStart()
}.bind(this)), this.on("change", function (e, t) {
t._$emitInputEvent.schedule(31)
}), this.setSession(t || new c("")), g.resetOptions(this), g._emit("editor", this)
};
(function () {
r.implement(this, d), this.$initOperationListeners = function () {
function e(e) {
return e[e.length - 1]
}
this.selections = [], this.commands.on("exec", function (t) {
this.startOperation(t);
var n = t.command;
if (n.group == "fileJump") {
var r = this.prevOp;
if (!r || r.command.group != "fileJump") this.lastFileJumpPos = e(this.selections)
} else this.lastFileJumpPos = null
}.bind(this), !0), this.commands.on("afterExec", function (e) {
var t = e.command;
if (t.group == "fileJump" && this.lastFileJumpPos && !this.curOp.selectionChanged) {
this.selection.fromJSON(this.lastFileJumpPos);
return
}
this.endOperation(e)
}.bind(this), !0), this.$opResetTimer = s.delayedCall(this.endOperation.bind(this)), this.on("change", function () {
this.curOp || this.startOperation(), this.curOp.docChanged = !0
}.bind(this), !0), this.on("changeSelection", function () {
this.curOp || this.startOperation(), this.curOp.selectionChanged = !0
}.bind(this), !0)
}, this.curOp = null, this.prevOp = {}, this.startOperation = function (e) {
if (this.curOp) {
if (!e || this.curOp.command) return;
this.prevOp = this.curOp
}
e || (this.previousCommand = null, e = {}), this.$opResetTimer.schedule(), this.curOp = {
command: e.command || {},
args: e.args
}, this.selections.push(this.selection.toJSON())
}, this.endOperation = function () {
this.curOp && (this.prevOp = this.curOp, this.curOp = null)
}, this.$historyTracker = function (e) {
if (!this.$mergeUndoDeltas) return;
var t = this.prevOp,
n = ["backspace", "del", "insertstring"],
r = t.command && e.command.name == t.command.name;
if (e.command.name == "insertstring") {
var i = e.args;
this.mergeNextCommand === undefined && (this.mergeNextCommand = !0), r = r && this.mergeNextCommand && (!/\s/.test(i) || /\s/.test(t.args)), this.mergeNextCommand = !0
} else r = r && n.indexOf(e.command.name) !== -1;
this.$mergeUndoDeltas != "always" && Date.now() - this.sequenceStartTime > 2e3 && (r = !1), r ? this.session.mergeUndoDeltas = !0 : n.indexOf(e.command.name) !== -1 && (this.sequenceStartTime = Date.now())
}, this.setKeyboardHandler = function (e) {
if (!e) this.keyBinding.setKeyboardHandler(null);
else if (typeof e == "string") {
this.$keybindingId = e;
var t = this;
g.loadModule(["keybinding", e], function (n) {
t.$keybindingId == e && t.keyBinding.setKeyboardHandler(n && n.handler)
})
} else this.$keybindingId = null, this.keyBinding.setKeyboardHandler(e)
}, this.getKeyboardHandler = function () {
return this.keyBinding.getKeyboardHandler()
}, this.setSession = function (e) {
if (this.session == e) return;
if (this.session) {
var t = this.session;
this.session.removeEventListener("change", this.$onDocumentChange), this.session.removeEventListener("changeMode", this.$onChangeMode), this.session.removeEventListener("tokenizerUpdate", this.$onTokenizerUpdate), this.session.removeEventListener("changeTabSize", this.$onChangeTabSize), this.session.removeEventListener("changeWrapLimit", this.$onChangeWrapLimit), this.session.removeEventListener("changeWrapMode", this.$onChangeWrapMode), this.session.removeEventListener("onChangeFold", this.$onChangeFold), this.session.removeEventListener("changeFrontMarker", this.$onChangeFrontMarker), this.session.removeEventListener("changeBackMarker", this.$onChangeBackMarker), this.session.removeEventListener("changeBreakpoint", this.$onChangeBreakpoint), this.session.removeEventListener("changeAnnotation", this.$onChangeAnnotation), this.session.removeEventListener("changeOverwrite", this.$onCursorChange), this.session.removeEventListener("changeScrollTop", this.$onScrollTopChange), this.session.removeEventListener("changeScrollLeft", this.$onScrollLeftChange);
var n = this.session.getSelection();
n.removeEventListener("changeCursor", this.$onCursorChange), n.removeEventListener("changeSelection", this.$onSelectionChange)
}
this.session = e, this.$onDocumentChange = this.onDocumentChange.bind(this), e.addEventListener("change", this.$onDocumentChange), this.renderer.setSession(e), this.$onChangeMode = this.onChangeMode.bind(this), e.addEventListener("changeMode", this.$onChangeMode), this.$onTokenizerUpdate = this.onTokenizerUpdate.bind(this), e.addEventListener("tokenizerUpdate", this.$onTokenizerUpdate), this.$onChangeTabSize = this.renderer.onChangeTabSize.bind(this.renderer), e.addEventListener("changeTabSize", this.$onChangeTabSize), this.$onChangeWrapLimit = this.onChangeWrapLimit.bind(this), e.addEventListener("changeWrapLimit", this.$onChangeWrapLimit), this.$onChangeWrapMode = this.onChangeWrapMode.bind(this), e.addEventListener("changeWrapMode", this.$onChangeWrapMode), this.$onChangeFold = this.onChangeFold.bind(this), e.addEventListener("changeFold", this.$onChangeFold), this.$onChangeFrontMarker = this.onChangeFrontMarker.bind(this), this.session.addEventListener("changeFrontMarker", this.$onChangeFrontMarker), this.$onChangeBackMarker = this.onChangeBackMarker.bind(this), this.session.addEventListener("changeBackMarker", this.$onChangeBackMarker), this.$onChangeBreakpoint = this.onChangeBreakpoint.bind(this), this.session.addEventListener("changeBreakpoint", this.$onChangeBreakpoint), this.$onChangeAnnotation = this.onChangeAnnotation.bind(this), this.session.addEventListener("changeAnnotation", this.$onChangeAnnotation), this.$onCursorChange = this.onCursorChange.bind(this), this.session.addEventListener("changeOverwrite", this.$onCursorChange), this.$onScrollTopChange = this.onScrollTopChange.bind(this), this.session.addEventListener("changeScrollTop", this.$onScrollTopChange), this.$onScrollLeftChange = this.onScrollLeftChange.bind(this), this.session.addEventListener("changeScrollLeft", this.$onScrollLeftChange), this.selection = e.getSelection(), this.selection.addEventListener("changeCursor", this.$onCursorChange), this.$onSelectionChange = this.onSelectionChange.bind(this), this.selection.addEventListener("changeSelection", this.$onSelectionChange), this.onChangeMode(), this.$blockScrolling += 1, this.onCursorChange(), this.$blockScrolling -= 1, this.onScrollTopChange(), this.onScrollLeftChange(), this.onSelectionChange(), this.onChangeFrontMarker(), this.onChangeBackMarker(), this.onChangeBreakpoint(), this.onChangeAnnotation(), this.session.getUseWrapMode() && this.renderer.adjustWrapLimit(), this.renderer.updateFull(), this._emit("changeSession", {
session: e,
oldSession: t
})
}, this.getSession = function () {
return this.session
}, this.setValue = function (e, t) {
return this.session.doc.setValue(e), t ? t == 1 ? this.navigateFileEnd() : t == -1 && this.navigateFileStart() : this.selectAll(), e
}, this.getValue = function () {
return this.session.getValue()
}, this.getSelection = function () {
return this.selection
}, this.resize = function (e) {
this.renderer.onResize(e)
}, this.setTheme = function (e) {
this.renderer.setTheme(e)
}, this.getTheme = function () {
return this.renderer.getTheme()
}, this.setStyle = function (e) {
this.renderer.setStyle(e)
}, this.unsetStyle = function (e) {
this.renderer.unsetStyle(e)
}, this.getFontSize = function () {
return this.getOption("fontSize") || i.computedStyle(this.container, "fontSize")
}, this.setFontSize = function (e) {
this.setOption("fontSize", e)
}, this.$highlightBrackets = function () {
this.session.$bracketHighlight && (this.session.removeMarker(this.session.$bracketHighlight), this.session.$bracketHighlight = null);
if (this.$highlightPending) return;
var e = this;
this.$highlightPending = !0, setTimeout(function () {
e.$highlightPending = !1;
var t = e.session.findMatchingBracket(e.getCursorPosition());
if (t) var n = new p(t.row, t.column, t.row, t.column + 1);
else if (e.session.$mode.getMatching) var n = e.session.$mode.getMatching(e.session);
n && (e.session.$bracketHighlight = e.session.addMarker(n, "ace_bracket", "text"))
}, 50)
}, this.focus = function () {
var e = this;
setTimeout(function () {
e.textInput.focus()
}), this.textInput.focus()
}, this.isFocused = function () {
return this.textInput.isFocused()
}, this.blur = function () {
this.textInput.blur()
}, this.onFocus = function () {
if (this.$isFocused) return;
this.$isFocused = !0, this.renderer.showCursor(), this.renderer.visualizeFocus(), this._emit("focus")
}, this.onBlur = function () {
if (!this.$isFocused) return;
this.$isFocused = !1, this.renderer.hideCursor(), this.renderer.visualizeBlur(), this._emit("blur")
}, this.$cursorChange = function () {
this.renderer.updateCursor()
}, this.onDocumentChange = function (e) {
var t = e.data,
n = t.range,
r;
n.start.row == n.end.row && t.action != "insertLines" && t.action != "removeLines" ? r = n.end.row : r = Infinity, this.renderer.updateLines(n.start.row, r), this._emit("change", e), this.$cursorChange()
}, this.onTokenizerUpdate = function (e) {
var t = e.data;
this.renderer.updateLines(t.first, t.last)
}, this.onScrollTopChange = function () {
this.renderer.scrollToY(this.session.getScrollTop())
}, this.onScrollLeftChange = function () {
this.renderer.scrollToX(this.session.getScrollLeft())
}, this.onCursorChange = function () {
this.$cursorChange(), this.$blockScrolling || this.renderer.scrollCursorIntoView(), this.$highlightBrackets(), this.$updateHighlightActiveLine(), this._emit("changeSelection")
}, this.$updateHighlightActiveLine = function () {
var e = this.getSession(),
t;
if (this.$highlightActiveLine) {
if (this.$selectionStyle != "line" || !this.selection.isMultiLine()) t = this.getCursorPosition();
this.renderer.$maxLines && this.session.getLength() === 1 && (t = !1)
}
if (e.$highlightLineMarker && !t) e.removeMarker(e.$highlightLineMarker.id), e.$highlightLineMarker = null;
else if (!e.$highlightLineMarker && t) {
var n = new p(t.row, t.column, t.row, Infinity);
n.id = e.addMarker(n, "ace_active-line", "screenLine"), e.$highlightLineMarker = n
} else t && (e.$highlightLineMarker.start.row = t.row, e.$highlightLineMarker.end.row = t.row, e.$highlightLineMarker.start.column = t.column, e._emit("changeBackMarker"))
}, this.onSelectionChange = function (e) {
var t = this.session;
t.$selectionMarker && t.removeMarker(t.$selectionMarker), t.$selectionMarker = null;
if (!this.selection.isEmpty()) {
var n = this.selection.getRange(),
r = this.getSelectionStyle();
t.$selectionMarker = t.addMarker(n, "ace_selection", r)
} else this.$updateHighlightActiveLine();
var i = this.$highlightSelectedWord && this.$getSelectionHighLightRegexp();
this.session.highlight(i), this._emit("changeSelection")
}, this.$getSelectionHighLightRegexp = function () {
var e = this.session,
t = this.getSelectionRange();
if (t.isEmpty() || t.isMultiLine()) return;
var n = t.start.column - 1,
r = t.end.column + 1,
i = e.getLine(t.start.row),
s = i.length,
o = i.substring(Math.max(n, 0), Math.min(r, s));
if (n >= 0 && /^[\w\d]/.test(o) || r <= s && /[\w\d]$/.test(o)) return;
o = i.substring(t.start.column, t.end.column);
if (!/^[\w\d]+$/.test(o)) return;
var u = this.$search.$assembleRegExp({
wholeWord: !0,
caseSensitive: !0,
needle: o
});
return u
}, this.onChangeFrontMarker = function () {
this.renderer.updateFrontMarkers()
}, this.onChangeBackMarker = function () {
this.renderer.updateBackMarkers()
}, this.onChangeBreakpoint = function () {
this.renderer.updateBreakpoints()
}, this.onChangeAnnotation = function () {
this.renderer.setAnnotations(this.session.getAnnotations())
}, this.onChangeMode = function (e) {
this.renderer.updateText(), this._emit("changeMode", e)
}, this.onChangeWrapLimit = function () {
this.renderer.updateFull()
}, this.onChangeWrapMode = function () {
this.renderer.onResize(!0)
}, this.onChangeFold = function () {
this.$updateHighlightActiveLine(), this.renderer.updateFull()
}, this.getSelectedText = function () {
return this.session.getTextRange(this.getSelectionRange())
}, this.getCopyText = function () {
var e = this.getSelectedText();
return this._signal("copy", e), e
}, this.onCopy = function () {
this.commands.exec("copy", this)
}, this.onCut = function () {
this.commands.exec("cut", this)
}, this.onPaste = function (e) {
if (this.$readOnly) return;
this._emit("paste", e), this.insert(e)
}, this.execCommand = function (e, t) {
this.commands.exec(e, this, t)
}, this.insert = function (e) {
var t = this.session,
n = t.getMode(),
r = this.getCursorPosition();
if (this.getBehavioursEnabled()) {
var i = n.transformAction(t.getState(r.row), "insertion", this, t, e);
i && (e !== i.text && (this.session.mergeUndoDeltas = !1, this.$mergeNextCommand = !1), e = i.text)
}
e == " " && (e = this.session.getTabString());
if (!this.selection.isEmpty()) {
var s = this.getSelectionRange();
r = this.session.remove(s), this.clearSelection()
} else if (this.session.getOverwrite()) {
var s = new p.fromPoints(r, r);
s.end.column += e.length, this.session.remove(s)
}
if (e == "\n" || e == "\r\n") {
var o = t.getLine(r.row);
if (r.column > o.search(/\S|$/)) {
var u = o.substr(r.column).search(/\S|$/);
t.doc.removeInLine(r.row, r.column, r.column + u)
}
}
this.clearSelection();
var a = r.column,
f = t.getState(r.row),
o = t.getLine(r.row),
l = n.checkOutdent(f, o, e),
c = t.insert(r, e);
i && i.selection && (i.selection.length == 2 ? this.selection.setSelectionRange(new p(r.row, a + i.selection[0], r.row, a + i.selection[1])) : this.selection.setSelectionRange(new p(r.row + i.selection[0], i.selection[1], r.row + i.selection[2], i.selection[3])));
if (t.getDocument().isNewLine(e)) {
var h = n.getNextLineIndent(f, o.slice(0, r.column), t.getTabString());
t.insert({
row: r.row + 1,
column: 0
}, h)
}
l && n.autoOutdent(f, t, r.row)
}, this.onTextInput = function (e) {
this.keyBinding.onTextInput(e)
}, this.onCommandKey = function (e, t, n) {
this.keyBinding.onCommandKey(e, t, n)
}, this.setOverwrite = function (e) {
this.session.setOverwrite(e)
}, this.getOverwrite = function () {
return this.session.getOverwrite()
}, this.toggleOverwrite = function () {
this.session.toggleOverwrite()
}, this.setScrollSpeed = function (e) {
this.setOption("scrollSpeed", e)
}, this.getScrollSpeed = function () {
return this.getOption("scrollSpeed")
}, this.setDragDelay = function (e) {
this.setOption("dragDelay", e)
}, this.getDragDelay = function () {
return this.getOption("dragDelay")
}, this.setSelectionStyle = function (e) {
this.setOption("selectionStyle", e)
}, this.getSelectionStyle = function () {
return this.getOption("selectionStyle")
}, this.setHighlightActiveLine = function (e) {
this.setOption("highlightActiveLine", e)
}, this.getHighlightActiveLine = function () {
return this.getOption("highlightActiveLine")
}, this.setHighlightGutterLine = function (e) {
this.setOption("highlightGutterLine", e)
}, this.getHighlightGutterLine = function () {
return this.getOption("highlightGutterLine")
}, this.setHighlightSelectedWord = function (e) {
this.setOption("highlightSelectedWord", e)
}, this.getHighlightSelectedWord = function () {
return this.$highlightSelectedWord
}, this.setAnimatedScroll = function (e) {
this.renderer.setAnimatedScroll(e)
}, this.getAnimatedScroll = function () {
return this.renderer.getAnimatedScroll()
}, this.setShowInvisibles = function (e) {
this.renderer.setShowInvisibles(e)
}, this.getShowInvisibles = function () {
return this.renderer.getShowInvisibles()
}, this.setDisplayIndentGuides = function (e) {
this.renderer.setDisplayIndentGuides(e)
}, this.getDisplayIndentGuides = function () {
return this.renderer.getDisplayIndentGuides()
}, this.setShowPrintMargin = function (e) {
this.renderer.setShowPrintMargin(e)
}, this.getShowPrintMargin = function () {
return this.renderer.getShowPrintMargin()
}, this.setPrintMarginColumn = function (e) {
this.renderer.setPrintMarginColumn(e)
}, this.getPrintMarginColumn = function () {
return this.renderer.getPrintMarginColumn()
}, this.setReadOnly = function (e) {
this.setOption("readOnly", e)
}, this.getReadOnly = function () {
return this.getOption("readOnly")
}, this.setBehavioursEnabled = function (e) {
this.setOption("behavioursEnabled", e)
}, this.getBehavioursEnabled = function () {
return this.getOption("behavioursEnabled")
}, this.setWrapBehavioursEnabled = function (e) {
this.setOption("wrapBehavioursEnabled", e)
}, this.getWrapBehavioursEnabled = function () {
return this.getOption("wrapBehavioursEnabled")
}, this.setShowFoldWidgets = function (e) {
this.setOption("showFoldWidgets", e)
}, this.getShowFoldWidgets = function () {
return this.getOption("showFoldWidgets")
}, this.setFadeFoldWidgets = function (e) {
this.setOption("fadeFoldWidgets", e)
}, this.getFadeFoldWidgets = function () {
return this.getOption("fadeFoldWidgets")
}, this.remove = function (e) {
this.selection.isEmpty() && (e == "left" ? this.selection.selectLeft() : this.selection.selectRight());
var t = this.getSelectionRange();
if (this.getBehavioursEnabled()) {
var n = this.session,
r = n.getState(t.start.row),
i = n.getMode().transformAction(r, "deletion", this, n, t);
if (t.end.column == 0) {
var s = n.getTextRange(t);
if (s[s.length - 1] == "\n") {
var o = n.getLine(t.end.row);
/^\s+$/.test(o) && (t.end.column = o.length)
}
}
i && (t = i)
}
this.session.remove(t), this.clearSelection()
}, this.removeWordRight = function () {
this.selection.isEmpty() && this.selection.selectWordRight(), this.session.remove(this.getSelectionRange()), this.clearSelection()
}, this.removeWordLeft = function () {
this.selection.isEmpty() && this.selection.selectWordLeft(), this.session.remove(this.getSelectionRange()), this.clearSelection()
}, this.removeToLineStart = function () {
this.selection.isEmpty() && this.selection.selectLineStart(), this.session.remove(this.getSelectionRange()), this.clearSelection()
}, this.removeToLineEnd = function () {
this.selection.isEmpty() && this.selection.selectLineEnd();
var e = this.getSelectionRange();
e.start.column == e.end.column && e.start.row == e.end.row && (e.end.column = 0, e.end.row++), this.session.remove(e), this.clearSelection()
}, this.splitLine = function () {
this.selection.isEmpty() || (this.session.remove(this.getSelectionRange()), this.clearSelection());
var e = this.getCursorPosition();
this.insert("\n"), this.moveCursorToPosition(e)
}, this.transposeLetters = function () {
if (!this.selection.isEmpty()) return;
var e = this.getCursorPosition(),
t = e.column;
if (t === 0) return;
var n = this.session.getLine(e.row),
r, i;
t < n.length ? (r = n.charAt(t) + n.charAt(t - 1), i = new p(e.row, t - 1, e.row, t + 1)) : (r = n.charAt(t - 1) + n.charAt(t - 2), i = new p(e.row, t - 2, e.row, t)), this.session.replace(i, r)
}, this.toLowerCase = function () {
var e = this.getSelectionRange();
this.selection.isEmpty() && this.selection.selectWord();
var t = this.getSelectionRange(),
n = this.session.getTextRange(t);
this.session.replace(t, n.toLowerCase()), this.selection.setSelectionRange(e)
}, this.toUpperCase = function () {
var e = this.getSelectionRange();
this.selection.isEmpty() && this.selection.selectWord();
var t = this.getSelectionRange(),
n = this.session.getTextRange(t);
this.session.replace(t, n.toUpperCase()), this.selection.setSelectionRange(e)
}, this.indent = function () {
var e = this.session,
t = this.getSelectionRange();
if (t.start.row < t.end.row) {
var n = this.$getSelectedRows();
e.indentRows(n.first, n.last, " ");
return
}
if (t.start.column < t.end.column) {
var r = e.getTextRange(t);
if (!/^\s+$/.test(r)) {
var n = this.$getSelectedRows();
e.indentRows(n.first, n.last, " ");
return
}
}
var i = e.getLine(t.start.row),
o = t.start,
u = e.getTabSize(),
a = e.documentToScreenColumn(o.row, o.column);
if (this.session.getUseSoftTabs()) var f = u - a % u,
l = s.stringRepeat(" ", f);
else {
var f = a % u;
while (i[t.start.column] == " " && f) t.start.column--, f--;
this.selection.setSelectionRange(t), l = " "
}
return this.insert(l)
}, this.blockIndent = function () {
var e = this.$getSelectedRows();
this.session.indentRows(e.first, e.last, " ")
}, this.blockOutdent = function () {
var e = this.session.getSelection();
this.session.outdentRows(e.getRange())
}, this.sortLines = function () {
var e = this.$getSelectedRows(),
t = this.session,
n = [];
for (i = e.first; i <= e.last; i++) n.push(t.getLine(i));
n.sort(function (e, t) {
return e.toLowerCase() < t.toLowerCase() ? -1 : e.toLowerCase() > t.toLowerCase() ? 1 : 0
});
var r = new p(0, 0, 0, 0);
for (var i = e.first; i <= e.last; i++) {
var s = t.getLine(i);
r.start.row = i, r.end.row = i, r.end.column = s.length, t.replace(r, n[i - e.first])
}
}, this.toggleCommentLines = function () {
var e = this.session.getState(this.getCursorPosition().row),
t = this.$getSelectedRows();
this.session.getMode().toggleCommentLines(e, this.session, t.first, t.last)
}, this.toggleBlockComment = function () {
var e = this.getCursorPosition(),
t = this.session.getState(e.row),
n = this.getSelectionRange();
this.session.getMode().toggleBlockComment(t, this.session, n, e)
}, this.getNumberAt = function (e, t) {
var n = /[\-]?[0-9]+(?:\.[0-9]+)?/g;
n.lastIndex = 0;
var r = this.session.getLine(e);
while (n.lastIndex < t) {
var i = n.exec(r);
if (i.index <= t && i.index + i[0].length >= t) {
var s = {
value: i[0],
start: i.index,
end: i.index + i[0].length
};
return s
}
}
return null
}, this.modifyNumber = function (e) {
var t = this.selection.getCursor().row,
n = this.selection.getCursor().column,
r = new p(t, n - 1, t, n),
i = this.session.getTextRange(r);
if (!isNaN(parseFloat(i)) && isFinite(i)) {
var s = this.getNumberAt(t, n);
if (s) {
var o = s.value.indexOf(".") >= 0 ? s.start + s.value.indexOf(".") + 1 : s.end,
u = s.start + s.value.length - o,
a = parseFloat(s.value);
a *= Math.pow(10, u), o !== s.end && n < o ? e *= Math.pow(10, s.end - n - 1) : e *= Math.pow(10, s.end - n), a += e, a /= Math.pow(10, u);
var f = a.toFixed(u),
l = new p(t, s.start, t, s.end);
this.session.replace(l, f), this.moveCursorTo(t, Math.max(s.start + 1, n + f.length - s.value.length))
}
}
}, this.removeLines = function () {
var e = this.$getSelectedRows(),
t;
e.first === 0 || e.last + 1 < this.session.getLength() ? t = new p(e.first, 0, e.last + 1, 0) : t = new p(e.first - 1, this.session.getLine(e.first - 1).length, e.last, this.session.getLine(e.last).length), this.session.remove(t), this.clearSelection()
}, this.duplicateSelection = function () {
var e = this.selection,
t = this.session,
n = e.getRange(),
r = e.isBackwards();
if (n.isEmpty()) {
var i = n.start.row;
t.duplicateLines(i, i)
} else {
var s = r ? n.start : n.end,
o = t.insert(s, t.getTextRange(n), !1);
n.start = s, n.end = o, e.setSelectionRange(n, r)
}
}, this.moveLinesDown = function () {
this.$moveLines(function (e, t) {
return this.session.moveLinesDown(e, t)
})
}, this.moveLinesUp = function () {
this.$moveLines(function (e, t) {
return this.session.moveLinesUp(e, t)
})
}, this.moveText = function (e, t, n) {
return this.session.moveText(e, t, n)
}, this.copyLinesUp = function () {
this.$moveLines(function (e, t) {
return this.session.duplicateLines(e, t), 0
})
}, this.copyLinesDown = function () {
this.$moveLines(function (e, t) {
return this.session.duplicateLines(e, t)
})
}, this.$moveLines = function (e) {
var t = this.selection;
if (!t.inMultiSelectMode || this.inVirtualSelectionMode) {
var n = t.toOrientedRange(),
r = this.$getSelectedRows(n),
i = e.call(this, r.first, r.last);
n.moveBy(i, 0), t.fromOrientedRange(n)
} else {
var s = t.rangeList.ranges;
t.rangeList.detach(this.session);
for (var o = s.length; o--;) {
var u = o,
r = s[o].collapseRows(),
a = r.end.row,
f = r.start.row;
while (o--) {
var r = s[o].collapseRows();
if (!(f - r.end.row <= 1)) break;
f = r.end.row
}
o++;
var i = e.call(this, f, a);
while (u >= o) s[u].moveBy(i, 0), u--
}
t.fromOrientedRange(t.ranges[0]), t.rangeList.attach(this.session)
}
}, this.$getSelectedRows = function () {
var e = this.getSelectionRange().collapseRows();
return {
first: e.start.row,
last: e.end.row
}
}, this.onCompositionStart = function (e) {
this.renderer.showComposition(this.getCursorPosition())
}, this.onCompositionUpdate = function (e) {
this.renderer.setCompositionText(e)
}, this.onCompositionEnd = function () {
this.renderer.hideComposition()
}, this.getFirstVisibleRow = function () {
return this.renderer.getFirstVisibleRow()
}, this.getLastVisibleRow = function () {
return this.renderer.getLastVisibleRow()
}, this.isRowVisible = function (e) {
return e >= this.getFirstVisibleRow() && e <= this.getLastVisibleRow()
}, this.isRowFullyVisible = function (e) {
return e >= this.renderer.getFirstFullyVisibleRow() && e <= this.renderer.getLastFullyVisibleRow()
}, this.$getVisibleRowCount = function () {
return this.renderer.getScrollBottomRow() - this.renderer.getScrollTopRow() + 1
}, this.$moveByPage = function (e, t) {
var n = this.renderer,
r = this.renderer.layerConfig,
i = e * Math.floor(r.height / r.lineHeight);
this.$blockScrolling++, t == 1 ? this.selection.$moveSelection(function () {
this.moveCursorBy(i, 0)
}) : t == 0 && (this.selection.moveCursorBy(i, 0), this.selection.clearSelection()), this.$blockScrolling--;
var s = n.scrollTop;
n.scrollBy(0, i * r.lineHeight), t != null && n.scrollCursorIntoView(null, .5), n.animateScrolling(s)
}, this.selectPageDown = function () {
this.$moveByPage(1, !0)
}, this.selectPageUp = function () {
this.$moveByPage(-1, !0)
}, this.gotoPageDown = function () {
this.$moveByPage(1, !1)
}, this.gotoPageUp = function () {
this.$moveByPage(-1, !1)
}, this.scrollPageDown = function () {
this.$moveByPage(1)
}, this.scrollPageUp = function () {
this.$moveByPage(-1)
}, this.scrollToRow = function (e) {
this.renderer.scrollToRow(e)
}, this.scrollToLine = function (e, t, n, r) {
this.renderer.scrollToLine(e, t, n, r)
}, this.centerSelection = function () {
var e = this.getSelectionRange(),
t = {
row: Math.floor(e.start.row + (e.end.row - e.start.row) / 2),
column: Math.floor(e.start.column + (e.end.column - e.start.column) / 2)
};
this.renderer.alignCursor(t, .5)
}, this.getCursorPosition = function () {
return this.selection.getCursor()
}, this.getCursorPositionScreen = function () {
return this.session.documentToScreenPosition(this.getCursorPosition())
}, this.getSelectionRange = function () {
return this.selection.getRange()
}, this.selectAll = function () {
this.$blockScrolling += 1, this.selection.selectAll(), this.$blockScrolling -= 1
}, this.clearSelection = function () {
this.selection.clearSelection()
}, this.moveCursorTo = function (e, t) {
this.selection.moveCursorTo(e, t)
}, this.moveCursorToPosition = function (e) {
this.selection.moveCursorToPosition(e)
}, this.jumpToMatching = function (e) {
var t = this.getCursorPosition(),
n = this.session.getBracketRange(t);
if (!n) {
n = this.find({
needle: /[{}()\[\]]/g,
preventScroll: !0,
start: {
row: t.row,
column: t.column - 1
}
});
if (!n) return;
var r = n.start;
r.row == t.row && Math.abs(r.column - t.column) < 2 && (n = this.session.getBracketRange(r))
}
r = n && n.cursor || r, r && (e ? n && n.isEqual(this.getSelectionRange()) ? this.clearSelection() : this.selection.selectTo(r.row, r.column) : (this.clearSelection(), this.moveCursorTo(r.row, r.column)))
}, this.gotoLine = function (e, t, n) {
this.selection.clearSelection(), this.session.unfold({
row: e - 1,
column: t || 0
}), this.$blockScrolling += 1, this.exitMultiSelectMode && this.exitMultiSelectMode(), this.moveCursorTo(e - 1, t || 0), this.$blockScrolling -= 1, this.isRowFullyVisible(e - 1) || this.scrollToLine(e - 1, !0, n)
}, this.navigateTo = function (e, t) {
this.clearSelection(), this.moveCursorTo(e, t)
}, this.navigateUp = function (e) {
if (this.selection.isMultiLine() && !this.selection.isBackwards()) {
var t = this.selection.anchor.getPosition();
return this.moveCursorToPosition(t)
}
this.selection.clearSelection(), e = e || 1, this.selection.moveCursorBy(-e, 0)
}, this.navigateDown = function (e) {
if (this.selection.isMultiLine() && this.selection.isBackwards()) {
var t = this.selection.anchor.getPosition();
return this.moveCursorToPosition(t)
}
this.selection.clearSelection(), e = e || 1, this.selection.moveCursorBy(e, 0)
}, this.navigateLeft = function (e) {
if (!this.selection.isEmpty()) {
var t = this.getSelectionRange().start;
this.moveCursorToPosition(t)
} else {
e = e || 1;
while (e--) this.selection.moveCursorLeft()
}
this.clearSelection()
}, this.navigateRight = function (e) {
if (!this.selection.isEmpty()) {
var t = this.getSelectionRange().end;
this.moveCursorToPosition(t)
} else {
e = e || 1;
while (e--) this.selection.moveCursorRight()
}
this.clearSelection()
}, this.navigateLineStart = function () {
this.selection.moveCursorLineStart(), this.clearSelection()
}, this.navigateLineEnd = function () {
this.selection.moveCursorLineEnd(), this.clearSelection()
}, this.navigateFileEnd = function () {
var e = this.renderer.scrollTop;
this.selection.moveCursorFileEnd(), this.clearSelection(), this.renderer.animateScrolling(e)
}, this.navigateFileStart = function () {
var e = this.renderer.scrollTop;
this.selection.moveCursorFileStart(), this.clearSelection(), this.renderer.animateScrolling(e)
}, this.navigateWordRight = function () {
this.selection.moveCursorWordRight(), this.clearSelection()
}, this.navigateWordLeft = function () {
this.selection.moveCursorWordLeft(), this.clearSelection()
}, this.replace = function (e, t) {
t && this.$search.set(t);
var n = this.$search.find(this.session),
r = 0;
return n ? (this.$tryReplace(n, e) && (r = 1), n !== null && (this.selection.setSelectionRange(n), this.renderer.scrollSelectionIntoView(n.start, n.end)), r) : r
}, this.replaceAll = function (e, t) {
t && this.$search.set(t);
var n = this.$search.findAll(this.session),
r = 0;
if (!n.length) return r;
this.$blockScrolling += 1;
var i = this.getSelectionRange();
this.clearSelection(), this.selection.moveCursorTo(0, 0);
for (var s = n.length - 1; s >= 0; --s) this.$tryReplace(n[s], e) && r++;
return this.selection.setSelectionRange(i), this.$blockScrolling -= 1, r
}, this.$tryReplace = function (e, t) {
var n = this.session.getTextRange(e);
return t = this.$search.replace(n, t), t !== null ? (e.end = this.session.replace(e, t), e) : null
}, this.getLastSearchOptions = function () {
return this.$search.getOptions()
}, this.find = function (e, t, n) {
t || (t = {}), typeof e == "string" || e instanceof RegExp ? t.needle = e : typeof e == "object" && r.mixin(t, e);
var i = this.selection.getRange();
t.needle == null && (e = this.session.getTextRange(i) || this.$search.$options.needle, e || (i = this.session.getWordRange(i.start.row, i.start.column), e = this.session.getTextRange(i)), this.$search.set({
needle: e
})), this.$search.set(t), t.start || this.$search.set({
start: i
});
var s = this.$search.find(this.session);
if (t.preventScroll) return s;
if (s) return this.revealRange(s, n), s;
t.backwards ? i.start = i.end : i.end = i.start, this.selection.setRange(i)
}, this.findNext = function (e, t) {
this.find({
skipCurrent: !0,
backwards: !1
}, e, t)
}, this.findPrevious = function (e, t) {
this.find(e, {
skipCurrent: !0,
backwards: !0
}, t)
}, this.revealRange = function (e, t) {
this.$blockScrolling += 1, this.session.unfold(e), this.selection.setSelectionRange(e), this.$blockScrolling -= 1;
var n = this.renderer.scrollTop;
this.renderer.scrollSelectionIntoView(e.start, e.end, .5), t != 0 && this.renderer.animateScrolling(n)
}, this.undo = function () {
this.$blockScrolling++, this.session.getUndoManager().undo(), this.$blockScrolling--, this.renderer.scrollCursorIntoView(null, .5)
}, this.redo = function () {
this.$blockScrolling++, this.session.getUndoManager().redo(), this.$blockScrolling--, this.renderer.scrollCursorIntoView(null, .5)
}, this.destroy = function () {
this.renderer.destroy(), this._emit("destroy", this)
}, this.setAutoScrollEditorIntoView = function (e) {
if (e === !1) return;
var t, n = this,
r = !1;
this.$scrollAnchor || (this.$scrollAnchor = document.createElement("div"));
var i = this.$scrollAnchor;
i.style.cssText = "position:absolute", this.container.insertBefore(i, this.container.firstChild);
var s = this.on("changeSelection", function () {
r = !0
}),
o = this.renderer.on("beforeRender", function () {
r && (t = n.renderer.container.getBoundingClientRect())
}),
u = this.renderer.on("afterRender", function () {
if (r && t && n.isFocused()) {
var e = n.renderer,
s = e.$cursorLayer.$pixelPos,
o = e.layerConfig,
u = s.top - o.offset;
s.top >= 0 && u + t.top < 0 ? r = !0 : s.top < o.height && s.top + t.top + o.lineHeight > window.innerHeight ? r = !1 : r = null, r != null && (i.style.top = u + "px", i.style.left = s.left + "px", i.style.height = o.lineHeight + "px", i.scrollIntoView(r)), r = t = null
}
});
this.setAutoScrollEditorIntoView = function (e) {
if (e === !0) return;
delete this.setAutoScrollEditorIntoView, this.removeEventListener("changeSelection", s), this.renderer.removeEventListener("afterRender", u), this.renderer.removeEventListener("beforeRender", o)
}
}, this.$resetCursorStyle = function () {
var e = this.$cursorStyle || "ace",
t = this.renderer.$cursorLayer;
if (!t) return;
t.setSmoothBlinking(e == "smooth"), t.isBlinking = !this.$readOnly && e != "wide"
}
}).call(y.prototype), g.defineOptions(y.prototype, "editor", {
selectionStyle: {
set: function (e) {
this.onSelectionChange(), this._emit("changeSelectionStyle", {
data: e
})
},
initialValue: "line"
},
highlightActiveLine: {
set: function () {
this.$updateHighlightActiveLine()
},
initialValue: !0
},
highlightSelectedWord: {
set: function (e) {
this.$onSelectionChange()
},
initialValue: !0
},
readOnly: {
set: function (e) {
this.$resetCursorStyle()
},
initialValue: !1
},
cursorStyle: {
set: function (e) {
this.$resetCursorStyle()
},
values: ["ace", "slim", "smooth", "wide"],
initialValue: "ace"
},
mergeUndoDeltas: {
values: [!1, !0, "always"],
initialValue: !0
},
behavioursEnabled: {
initialValue: !0
},
wrapBehavioursEnabled: {
initialValue: !0
},
hScrollBarAlwaysVisible: "renderer",
vScrollBarAlwaysVisible: "renderer",
highlightGutterLine: "renderer",
animatedScroll: "renderer",
showInvisibles: "renderer",
showPrintMargin: "renderer",
printMarginColumn: "renderer",
printMargin: "renderer",
fadeFoldWidgets: "renderer",
showFoldWidgets: "renderer",
showGutter: "renderer",
displayIndentGuides: "renderer",
fontSize: "renderer",
fontFamily: "renderer",
maxLines: "renderer",
minLines: "renderer",
scrollPastEnd: "renderer",
fixedWidthGutter: "renderer",
scrollSpeed: "$mouseHandler",
dragDelay: "$mouseHandler",
dragEnabled: "$mouseHandler",
focusTimout: "$mouseHandler",
firstLineNumber: "session",
overwrite: "session",
newLineMode: "session",
useWorker: "session",
useSoftTabs: "session",
tabSize: "session",
wrap: "session",
foldStyle: "session"
}), t.Editor = y
}), ace.define("ace/lib/lang", ["require", "exports", "module"], function (e, t, n) {
t.stringReverse = function (e) {
return e.split("").reverse().join("")
}, t.stringRepeat = function (e, t) {
var n = "";
while (t > 0) {
t & 1 && (n += e);
if (t >>= 1) e += e
}
return n
};
var r = /^\s\s*/,
i = /\s\s*$/;
t.stringTrimLeft = function (e) {
return e.replace(r, "")
}, t.stringTrimRight = function (e) {
return e.replace(i, "")
}, t.copyObject = function (e) {
var t = {};
for (var n in e) t[n] = e[n];
return t
}, t.copyArray = function (e) {
var t = [];
for (var n = 0, r = e.length; n < r; n++) e[n] && typeof e[n] == "object" ? t[n] = this.copyObject(e[n]) : t[n] = e[n];
return t
}, t.deepCopy = function (e) {
if (typeof e != "object") return e;
var t = e.constructor();
for (var n in e) typeof e[n] == "object" ? t[n] = this.deepCopy(e[n]) : t[n] = e[n];
return t
}, t.arrayToMap = function (e) {
var t = {};
for (var n = 0; n < e.length; n++) t[e[n]] = 1;
return t
}, t.createMap = function (e) {
var t = Object.create(null);
for (var n in e) t[n] = e[n];
return t
}, t.arrayRemove = function (e, t) {
for (var n = 0; n <= e.length; n++) t === e[n] && e.splice(n, 1)
}, t.escapeRegExp = function (e) {
return e.replace(/([.*+?^${}()|[\]\/\\])/g, "\\$1")
}, t.escapeHTML = function (e) {
return e.replace(/&/g, "&#38;").replace(/"/g, "&#34;").replace(/'/g, "&#39;").replace(/</g, "&#60;")
}, t.getMatchOffsets = function (e, t) {
var n = [];
return e.replace(t, function (e) {
n.push({
offset: arguments[arguments.length - 2],
length: e.length
})
}), n
}, t.deferredCall = function (e) {
var t = null,
n = function () {
t = null, e()
}, r = function (e) {
return r.cancel(), t = setTimeout(n, e || 0), r
};
return r.schedule = r, r.call = function () {
return this.cancel(), e(), r
}, r.cancel = function () {
return clearTimeout(t), t = null, r
}, r
}, t.delayedCall = function (e, t) {
var n = null,
r = function () {
n = null, e()
}, i = function (e) {
n && clearTimeout(n), n = setTimeout(r, e || t)
};
return i.delay = i, i.schedule = function (e) {
n == null && (n = setTimeout(r, e || 0))
}, i.call = function () {
this.cancel(), e()
}, i.cancel = function () {
n && clearTimeout(n), n = null
}, i.isPending = function () {
return n
}, i
}
}), ace.define("ace/keyboard/textinput", ["require", "exports", "module", "ace/lib/event", "ace/lib/useragent", "ace/lib/dom", "ace/lib/lang"], function (e, t, n) {
var r = e("../lib/event"),
i = e("../lib/useragent"),
s = e("../lib/dom"),
o = e("../lib/lang"),
u = i.isChrome < 18,
a = function (e, t) {
function n(e) {
if (v) return;
if (L) t = 0, n = e ? 0 : l.value.length - 1;
else var t = e ? 2 : 1,
n = 2;
try {
l.setSelectionRange(t, n)
} catch (r) {}
}
function a() {
if (v) return;
l.value = c, i.isWebKit && E.schedule()
}
function f() {
setTimeout(function () {
m && (l.style.cssText = m, m = ""), t.renderer.$keepTextAreaAtCursor == null && (t.renderer.$keepTextAreaAtCursor = !0, t.renderer.$moveTextAreaToCursor())
}, 0)
}
var l = s.createElement("textarea");
l.className = "ace_text-input", i.isTouchPad && l.setAttribute("x-palm-disable-auto-cap", !0), l.wrap = "off", l.autocorrect = "off", l.autocapitalize = "off", l.spellcheck = !1, l.style.opacity = "0", e.insertBefore(l, e.firstChild);
var c = "",
h = !1,
p = !1,
d = !1,
v = !1,
m = "",
g = !0;
try {
var y = document.activeElement === l
} catch (b) {}
r.addListener(l, "blur", function () {
t.onBlur(), y = !1
}), r.addListener(l, "focus", function () {
y = !0, t.onFocus(), n()
}), this.focus = function () {
l.focus()
}, this.blur = function () {
l.blur()
}, this.isFocused = function () {
return y
};
var w = o.delayedCall(function () {
y && n(g)
}),
E = o.delayedCall(function () {
v || (l.value = c, y && n())
});
i.isWebKit || t.addEventListener("changeSelection", function () {
t.selection.isEmpty() != g && (g = !g, w.schedule())
}), a(), y && t.onFocus();
var S = function (e) {
return e.selectionStart === 0 && e.selectionEnd === e.value.length
};
!l.setSelectionRange && l.createTextRange && (l.setSelectionRange = function (e, t) {
var n = this.createTextRange();
n.collapse(!0), n.moveStart("character", e), n.moveEnd("character", t), n.select()
}, S = function (e) {
try {
var t = e.ownerDocument.selection.createRange()
} catch (n) {}
return !t || t.parentElement() != e ? !1 : t.text == e.value
});
if (i.isOldIE) {
var x = !1,
T = function (e) {
if (x) return;
var t = l.value;
if (v || !t || t == c) return;
if (e && t == c[0]) return N.schedule();
O(t), x = !0, a(), x = !1
}, N = o.delayedCall(T);
r.addListener(l, "propertychange", T);
var C = {
13: 1,
27: 1
};
r.addListener(l, "keyup", function (e) {
v && (!l.value || C[e.keyCode]) && setTimeout(j, 0);
if ((l.value.charCodeAt(0) || 0) < 129) return N.call();
v ? B() : H()
}), r.addListener(l, "keydown", function (e) {
N.schedule(50)
})
}
var k = function (e) {
h ? h = !1 : p ? p = !1 : S(l) ? (t.selectAll(), n()) : L && n(t.selection.isEmpty())
}, L = null;
this.setInputHandler = function (e) {
L = e
}, this.getInputHandler = function () {
return L
};
var A = !1,
O = function (e) {
L && (e = L(e), L = null), d ? (n(), e && t.onPaste(e), d = !1) : e == c.charAt(0) ? A && t.execCommand("del", {
source: "ace"
}) : (e.substring(0, 2) == c ? e = e.substr(2) : e.charAt(0) == c.charAt(0) ? e = e.substr(1) : e.charAt(e.length - 1) == c.charAt(0) && (e = e.slice(0, -1)), e.charAt(e.length - 1) == c.charAt(0) && (e = e.slice(0, -1)), e && t.onTextInput(e)), A && (A = !1)
}, M = function (e) {
if (v) return;
var t = l.value;
O(t), a()
}, _ = function (e) {
var i = t.getCopyText();
if (!i) {
r.preventDefault(e);
return
}
var s = e.clipboardData || window.clipboardData;
if (s && !u) {
var o = s.setData("Text", i);
o && (t.onCut(), r.preventDefault(e))
}
o || (h = !0, l.value = i, l.select(), setTimeout(function () {
h = !1, a(), n(), t.onCut()
}))
}, D = function (e) {
var i = t.getCopyText();
if (!i) {
r.preventDefault(e);
return
}
var s = e.clipboardData || window.clipboardData;
if (s && !u) {
var o = s.setData("Text", i);
o && (t.onCopy(), r.preventDefault(e))
}
o || (p = !0, l.value = i, l.select(), setTimeout(function () {
p = !1, a(), n(), t.onCopy()
}))
}, P = function (e) {
var s = e.clipboardData || window.clipboardData;
if (s) {
var o = s.getData("Text");
o && t.onPaste(o), i.isIE && setTimeout(n), r.preventDefault(e)
} else l.value = "", d = !0
};
r.addCommandKeyListener(l, t.onCommandKey.bind(t)), r.addListener(l, "select", k), r.addListener(l, "input", M), r.addListener(l, "cut", _), r.addListener(l, "copy", D), r.addListener(l, "paste", P), (!("oncut" in l) || !("oncopy" in l) || !("onpaste" in l)) && r.addListener(e, "keydown", function (e) {
if (i.isMac && !e.metaKey || !e.ctrlKey) return;
switch (e.keyCode) {
case 67:
D(e);
break;
case 86:
P(e);
break;
case 88:
_(e)
}
});
var H = function (e) {
if (v) return;
v = {}, t.onCompositionStart(), setTimeout(B, 0), t.on("mousedown", j), t.selection.isEmpty() || (t.insert(""), t.session.markUndoGroup(), t.selection.clearSelection()), t.session.markUndoGroup()
}, B = function () {
if (!v) return;
var e = l.value.replace(/\x01/g, "");
if (v.lastValue === e) return;
t.onCompositionUpdate(e), v.lastValue && t.undo(), v.lastValue = e;
if (v.lastValue) {
var n = t.selection.getRange();
t.insert(v.lastValue), t.session.markUndoGroup(), v.range = t.selection.getRange(), t.selection.setRange(n), t.selection.clearSelection()
}
}, j = function (e) {
var n = v;
v = !1;
var r = setTimeout(function () {
var e = l.value.replace(/\x01/g, "");
if (v) return;
e == n.lastValue ? a() : !n.lastValue && e && (a(), O(e))
});
L = function (e) {
return clearTimeout(r), e = e.replace(/\x01/g, ""), e == n.lastValue ? "" : (n.lastValue && t.undo(), e)
}, t.onCompositionEnd(), t.removeListener("mousedown", j), e.type == "compositionend" && n.range && t.selection.setRange(n.range)
}, F = o.delayedCall(B, 50);
r.addListener(l, "compositionstart", H), i.isGecko ? r.addListener(l, "text", function () {
F.schedule()
}) : (r.addListener(l, "keyup", function () {
F.schedule()
}), r.addListener(l, "keydown", function () {
F.schedule()
})), r.addListener(l, "compositionend", j), this.getElement = function () {
return l
}, this.setReadOnly = function (e) {
l.readOnly = e
}, this.onContextMenu = function (e) {
A = !0, m || (m = l.style.cssText), l.style.cssText = "z-index:100000;" + (i.isIE ? "opacity:0.1;" : ""), n(t.selection.isEmpty()), t._emit("nativecontextmenu", {
target: t,
domEvent: e
});
var o = t.container.getBoundingClientRect(),
u = s.computedStyle(t.container),
a = o.top + (parseInt(u.borderTopWidth) || 0),
c = o.left + (parseInt(o.borderLeftWidth) || 0),
h = o.bottom - a - l.clientHeight,
p = function (e) {
l.style.left = e.clientX - c - 2 + "px", l.style.top = Math.min(e.clientY - a - 2, h) + "px"
};
p(e);
if (e.type != "mousedown") return;
t.renderer.$keepTextAreaAtCursor && (t.renderer.$keepTextAreaAtCursor = null), i.isWin && r.capture(t.container, p, f)
}, this.onContextMenuClose = f, (!i.isGecko || i.isMac) && r.addListener(l, "contextmenu", function (e) {
t.textInput.onContextMenu(e), f()
})
};
t.TextInput = a
}), ace.define("ace/mouse/mouse_handler", ["require", "exports", "module", "ace/lib/event", "ace/lib/useragent", "ace/mouse/default_handlers", "ace/mouse/default_gutter_handler", "ace/mouse/mouse_event", "ace/mouse/dragdrop_handler", "ace/config"], function (e, t, n) {
var r = e("../lib/event"),
i = e("../lib/useragent"),
s = e("./default_handlers").DefaultHandlers,
o = e("./default_gutter_handler").GutterHandler,
u = e("./mouse_event").MouseEvent,
a = e("./dragdrop_handler").DragdropHandler,
f = e("../config"),
l = function (e) {
this.editor = e, new s(this), new o(this), new a(this);
var t = e.renderer.getMouseEventTarget();
r.addListener(t, "click", this.onMouseEvent.bind(this, "click")), r.addListener(t, "mousemove", this.onMouseMove.bind(this, "mousemove")), r.addMultiMouseDownListener(t, [300, 300, 250], this, "onMouseEvent"), e.renderer.scrollBarV && (r.addMultiMouseDownListener(e.renderer.scrollBarV.inner, [300, 300, 250], this, "onMouseEvent"), r.addMultiMouseDownListener(e.renderer.scrollBarH.inner, [300, 300, 250], this, "onMouseEvent")), r.addMouseWheelListener(e.container, this.onMouseWheel.bind(this, "mousewheel"));
var n = e.renderer.$gutter;
r.addListener(n, "mousedown", this.onMouseEvent.bind(this, "guttermousedown")), r.addListener(n, "click", this.onMouseEvent.bind(this, "gutterclick")), r.addListener(n, "dblclick", this.onMouseEvent.bind(this, "gutterdblclick")), r.addListener(n, "mousemove", this.onMouseEvent.bind(this, "guttermousemove")), r.addListener(t, "mousedown", function (t) {
e.focus()
}), r.addListener(n, "mousedown", function (t) {
return e.focus(), r.preventDefault(t)
})
};
(function () {
this.onMouseEvent = function (e, t) {
this.editor._emit(e, new u(t, this.editor))
}, this.onMouseMove = function (e, t) {
var n = this.editor._eventRegistry && this.editor._eventRegistry.mousemove;
if (!n || !n.length) return;
this.editor._emit(e, new u(t, this.editor))
}, this.onMouseWheel = function (e, t) {
var n = new u(t, this.editor);
n.speed = this.$scrollSpeed * 2, n.wheelX = t.wheelX, n.wheelY = t.wheelY, this.editor._emit(e, n)
}, this.setState = function (e) {
this.state = e
}, this.captureMouse = function (e, t) {
this.x = e.x, this.y = e.y, this.isMousePressed = !0;
var n = this.editor.renderer;
n.$keepTextAreaAtCursor && (n.$keepTextAreaAtCursor = null);
var s = this,
o = function (e) {
s.x = e.clientX, s.y = e.clientY, t && t(e)
}, u = function (e) {
clearInterval(f), a(), s[s.state + "End"] && s[s.state + "End"](e), s.$clickSelection = null, n.$keepTextAreaAtCursor == null && (n.$keepTextAreaAtCursor = !0, n.$moveTextAreaToCursor()), s.isMousePressed = !1, s.onMouseEvent("mouseup", e)
}, a = function () {
s[s.state] && s[s.state]()
};
if (i.isOldIE && e.domEvent.type == "dblclick") return setTimeout(function () {
u(e)
});
r.capture(this.editor.container, o, u);
var f = setInterval(a, 20)
}
}).call(l.prototype), f.defineOptions(l.prototype, "mouseHandler", {
scrollSpeed: {
initialValue: 2
},
dragDelay: {
initialValue: 150
},
dragEnabled: {
initialValue: !0
},
focusTimout: {
initialValue: 0
}
}), t.MouseHandler = l
}), ace.define("ace/mouse/default_handlers", ["require", "exports", "module", "ace/lib/dom", "ace/lib/event", "ace/lib/useragent"], function (e, t, n) {
function r(e) {
e.$clickSelection = null;
var t = e.editor;
t.setDefaultHandler("mousedown", this.onMouseDown.bind(e)), t.setDefaultHandler("dblclick", this.onDoubleClick.bind(e)), t.setDefaultHandler("tripleclick", this.onTripleClick.bind(e)), t.setDefaultHandler("quadclick", this.onQuadClick.bind(e)), t.setDefaultHandler("mousewheel", this.onMouseWheel.bind(e));
var n = ["select", "startSelect", "selectEnd", "selectAllEnd", "selectByWordsEnd", "selectByLinesEnd", "dragWait", "dragWaitEnd", "focusWait"];
n.forEach(function (t) {
e[t] = this[t]
}, this), e.selectByLines = this.extendSelectionBy.bind(e, "getLineRange"), e.selectByWords = this.extendSelectionBy.bind(e, "getWordRange")
}
function i(e, t, n, r) {
return Math.sqrt(Math.pow(n - e, 2) + Math.pow(r - t, 2))
}
function s(e, t) {
if (e.start.row == e.end.row) var n = 2 * t.column - e.start.column - e.end.column;
else if (e.start.row == e.end.row - 1 && !e.start.column && !e.end.column) var n = t.column - 4;
else var n = 2 * t.row - e.start.row - e.end.row;
return n < 0 ? {
cursor: e.start,
anchor: e.end
} : {
cursor: e.end,
anchor: e.start
}
}
var o = e("../lib/dom"),
u = e("../lib/event"),
a = e("../lib/useragent"),
f = 0;
(function () {
this.onMouseDown = function (e) {
var t = e.inSelection(),
n = e.getDocumentPosition();
this.mousedownEvent = e;
var r = this.editor,
i = e.getButton();
if (i !== 0) {
var s = r.getSelectionRange(),
o = s.isEmpty();
o && (r.moveCursorToPosition(n), r.selection.clearSelection()), r.textInput.onContextMenu(e.domEvent);
return
}
if (t && !r.isFocused()) {
r.focus();
if (this.$focusTimout && !this.$clickSelection && !r.inMultiSelectMode) {
this.mousedownEvent.time = (new Date).getTime(), this.setState("focusWait"), this.captureMouse(e);
return
}
}
return !t || this.$clickSelection || e.getShiftKey() || r.inMultiSelectMode ? this.startSelect(n) : t && (this.mousedownEvent.time = (new Date).getTime(), this.startSelect(n)), this.captureMouse(e), e.preventDefault()
}, this.startSelect = function (e) {
e = e || this.editor.renderer.screenToTextCoordinates(this.x, this.y);
var t = this.editor;
setTimeout(function () {
this.mousedownEvent.getShiftKey() ? t.selection.selectToPosition(e) : this.$clickSelection || (t.moveCursorToPosition(e), t.selection.clearSelection())
}.bind(this), 0), t.container.setCapture && t.container.setCapture(), t.setStyle("ace_selecting"), this.setState("select")
}, this.select = function () {
var e, t = this.editor,
n = t.renderer.screenToTextCoordinates(this.x, this.y);
if (this.$clickSelection) {
var r = this.$clickSelection.comparePoint(n);
if (r == -1) e = this.$clickSelection.end;
else if (r == 1) e = this.$clickSelection.start;
else {
var i = s(this.$clickSelection, n);
n = i.cursor, e = i.anchor
}
t.selection.setSelectionAnchor(e.row, e.column)
}
t.selection.selectToPosition(n), t.renderer.scrollCursorIntoView()
}, this.extendSelectionBy = function (e) {
var t, n = this.editor,
r = n.renderer.screenToTextCoordinates(this.x, this.y),
i = n.selection[e](r.row, r.column);
if (this.$clickSelection) {
var o = this.$clickSelection.comparePoint(i.start),
u = this.$clickSelection.comparePoint(i.end);
if (o == -1 && u <= 0) {
t = this.$clickSelection.end;
if (i.end.row != r.row || i.end.column != r.column) r = i.start
} else if (u == 1 && o >= 0) {
t = this.$clickSelection.start;
if (i.start.row != r.row || i.start.column != r.column) r = i.end
} else if (o == -1 && u == 1) r = i.end, t = i.start;
else {
var a = s(this.$clickSelection, r);
r = a.cursor, t = a.anchor
}
n.selection.setSelectionAnchor(t.row, t.column)
}
n.selection.selectToPosition(r), n.renderer.scrollCursorIntoView()
}, this.selectEnd = this.selectAllEnd = this.selectByWordsEnd = this.selectByLinesEnd = function () {
this.editor.unsetStyle("ace_selecting"), this.editor.container.releaseCapture && this.editor.container.releaseCapture()
}, this.focusWait = function () {
var e = i(this.mousedownEvent.x, this.mousedownEvent.y, this.x, this.y),
t = (new Date).getTime();
(e > f || t - this.mousedownEvent.time > this.$focusTimout) && this.startSelect(this.mousedownEvent.getDocumentPosition())
}, this.onDoubleClick = function (e) {
var t = e.getDocumentPosition(),
n = this.editor,
r = n.session,
i = r.getBracketRange(t);
if (i) {
i.isEmpty() && (i.start.column--, i.end.column++), this.$clickSelection = i, this.setState("select");
return
}
this.$clickSelection = n.selection.getWordRange(t.row, t.column), this.setState("selectByWords")
}, this.onTripleClick = function (e) {
var t = e.getDocumentPosition(),
n = this.editor;
this.setState("selectByLines"), this.$clickSelection = n.selection.getLineRange(t.row)
}, this.onQuadClick = function (e) {
var t = this.editor;
t.selectAll(), this.$clickSelection = t.getSelectionRange(), this.setState("selectAll")
}, this.onMouseWheel = function (e) {
if (e.getShiftKey() || e.getAccelKey()) return;
var t = e.domEvent.timeStamp,
n = t - (this.$lastScrollTime || 0),
r = this.editor,
i = r.renderer.isScrollableBy(e.wheelX * e.speed, e.wheelY * e.speed);
if (i || n < 200) return this.$lastScrollTime = t, r.renderer.scrollBy(e.wheelX * e.speed, e.wheelY * e.speed), e.stop()
}
}).call(r.prototype), t.DefaultHandlers = r
}), ace.define("ace/mouse/default_gutter_handler", ["require", "exports", "module", "ace/lib/dom", "ace/lib/event"], function (e, t, n) {
function r(e) {
function t() {
c = i.createElement("div"), c.className = "ace_gutter-tooltip", c.style.display = "none", u.container.appendChild(c)
}
function n() {
c || t();
var e = l.getDocumentPosition().row,
n = a.$annotations[e];
if (!n) return r();
var i = u.session.getLength();
if (e == i) {
var s = u.renderer.pixelToScreenCoordinates(0, l.y).row,
f = l.$pos;
if (s > u.session.documentToScreenRow(f.row, f.column)) return r()
}
if (h == n) return;
h = n.text.join("<br/>"), c.style.display = "block", c.innerHTML = h, u.on("mousewheel", r), o(l)
}
function r() {
f && (f = clearTimeout(f)), h && (c.style.display = "none", h = null, u.removeEventListener("mousewheel", r))
}
function o(e) {
var t = u.renderer.$gutter.getBoundingClientRect();
c.style.left = e.x + 15 + "px";
if (e.y + 3 * u.renderer.lineHeight + 15 < t.bottom) c.style.bottom = "", c.style.top = e.y + 15 + "px";
else {
c.style.top = "";
var n = window.innerHeight || document.documentElement.clientHeight;
c.style.bottom = n - e.y + 5 + "px"
}
}
var u = e.editor,
a = u.renderer.$gutterLayer;
e.editor.setDefaultHandler("guttermousedown", function (t) {
if (!u.isFocused() || t.getButton() != 0) return;
var n = a.getRegion(t);
if (n == "foldWidgets") return;
var r = t.getDocumentPosition().row,
i = u.session.selection;
if (t.getShiftKey()) i.selectTo(r, 0);
else {
if (t.domEvent.detail == 2) return u.selectAll(), t.preventDefault();
e.$clickSelection = u.selection.getLineRange(r)
}
return e.setState("selectByLines"), e.captureMouse(t), t.preventDefault()
});
var f, l, c, h;
e.editor.setDefaultHandler("guttermousemove", function (t) {
var s = t.domEvent.target || t.domEvent.srcElement;
if (i.hasCssClass(s, "ace_fold-widget")) return r();
h && o(t), l = t;
if (f) return;
f = setTimeout(function () {
f = null, l && !e.isMousePressed ? n() : r()
}, 50)
}), s.addListener(u.renderer.$gutter, "mouseout", function (e) {
l = null;
if (!h || f) return;
f = setTimeout(function () {
f = null, r()
}, 50)
}), u.on("changeSession", r)
}
var i = e("../lib/dom"),
s = e("../lib/event");
t.GutterHandler = r
}), ace.define("ace/mouse/mouse_event", ["require", "exports", "module", "ace/lib/event", "ace/lib/useragent"], function (e, t, n) {
var r = e("../lib/event"),
i = e("../lib/useragent"),
s = t.MouseEvent = function (e, t) {
this.domEvent = e, this.editor = t, this.x = this.clientX = e.clientX, this.y = this.clientY = e.clientY, this.$pos = null, this.$inSelection = null, this.propagationStopped = !1, this.defaultPrevented = !1
};
(function () {
this.stopPropagation = function () {
r.stopPropagation(this.domEvent), this.propagationStopped = !0
}, this.preventDefault = function () {
r.preventDefault(this.domEvent), this.defaultPrevented = !0
}, this.stop = function () {
this.stopPropagation(), this.preventDefault()
}, this.getDocumentPosition = function () {
return this.$pos ? this.$pos : (this.$pos = this.editor.renderer.screenToTextCoordinates(this.clientX, this.clientY), this.$pos)
}, this.inSelection = function () {
if (this.$inSelection !== null) return this.$inSelection;
var e = this.editor,
t = e.getSelectionRange();
if (t.isEmpty()) this.$inSelection = !1;
else {
var n = this.getDocumentPosition();
this.$inSelection = t.contains(n.row, n.column)
}
return this.$inSelection
}, this.getButton = function () {
return r.getButton(this.domEvent)
}, this.getShiftKey = function () {
return this.domEvent.shiftKey
}, this.getAccelKey = i.isMac ? function () {
return this.domEvent.metaKey
} : function () {
return this.domEvent.ctrlKey
}
}).call(s.prototype)
}), ace.define("ace/mouse/dragdrop_handler", ["require", "exports", "module", "ace/lib/dom", "ace/lib/event", "ace/lib/useragent"], function (e, t, n) {
function r(e) {
function t(e, t) {
var n = (new Date).getTime(),
r = !t || e.row != t.row,
s = !t || e.column != t.column;
if (!A || r || s) m.$blockScrolling += 1, m.moveCursorToPosition(e), m.$blockScrolling -= 1, A = n, O = {
x: E,
y: S
};
else {
var o = i(O.x, O.y, E, S);
o > l ? A = null : n - A >= f && (m.renderer.scrollCursorIntoView(), A = null)
}
}
function n(e, t) {
var n = (new Date).getTime(),
r = m.renderer.layerConfig.lineHeight,
i = m.renderer.layerConfig.characterWidth,
s = m.renderer.scroller.getBoundingClientRect(),
o = {
x: {
left: E - s.left,
right: s.right - E
},
y: {
top: S - s.top,
bottom: s.bottom - S
}
}, u = Math.min(o.x.left, o.x.right),
f = Math.min(o.y.top, o.y.bottom),
l = {
row: e.row,
column: e.column
};
u / i <= 2 && (l.column += o.x.left < o.x.right ? -3 : 2), f / r <= 1 && (l.row += o.y.top < o.y.bottom ? -1 : 1);
var c = e.row != l.row,
h = e.column != l.column,
p = !t || e.row != t.row;
c || h && !p ? L ? n - L >= a && m.renderer.scrollCursorIntoView(l) : L = n : L = null
}
function r() {
var e = N;
N = m.renderer.screenToTextCoordinates(E, S), t(N, e), n(N, e)
}
function c() {
T = m.selection.toOrientedRange(), w = m.session.addMarker(T, "ace_selection", m.getSelectionStyle()), m.clearSelection(), clearInterval(x), x = setInterval(r, 20), C = 0, o.addListener(document, "mousemove", p)
}
function h() {
clearInterval(x), m.session.removeMarker(w), w = null, m.$blockScrolling += 1, m.selection.fromOrientedRange(T), m.$blockScrolling -= 1, T = null, C = 0, L = null, A = null, o.removeListener(document, "mousemove", p)
}
function p() {
M == null && (M = setTimeout(function () {
M != null && w && h()
}, 20))
}
function d(e) {
var t = e.types;
return !t || Array.prototype.some.call(t, function (e) {
return e == "text/plain" || e == "Text"
})
}
function v(e) {
var t = ["copy", "copymove", "all", "uninitialized"],
n = ["move", "copymove", "linkmove", "all", "uninitialized"],
r = u.isMac ? e.altKey : e.ctrlKey,
i = "uninitialized";
try {
i = e.dataTransfer.effectAllowed.toLowerCase()
} catch (e) {}
var s = "none";
return r && t.indexOf(i) >= 0 ? s = "copy" : n.indexOf(i) >= 0 ? s = "move" : t.indexOf(i) >= 0 && (s = "copy"), s
}
var m = e.editor,
g = s.createElement("img");
g.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==", u.isOpera && (g.style.cssText = "width:1px;height:1px;position:fixed;top:0;left:0;z-index:2147483647;opacity:0;visibility:hidden", m.container.appendChild(g));
var y = ["dragWait", "dragWaitEnd", "startDrag", "dragReadyEnd", "onMouseDrag"];
y.forEach(function (t) {
e[t] = this[t]
}, this), m.addEventListener("mousedown", this.onMouseDown.bind(e));
var b = m.container,
w, E, S, x, T, N, C = 0,
k, L, A, O;
this.onDragStart = function (e) {
if (this.cancelDrag || !b.draggable) {
var t = this;
return setTimeout(function () {
t.startSelect(), t.captureMouse(e)
}, 0), e.preventDefault()
}
u.isOpera && (g.style.visibility = "visible", setTimeout(function () {
g.style.visibility = "hidden"
}, 0)), T = m.getSelectionRange();
var n = e.dataTransfer;
n.effectAllowed = m.getReadOnly() ? "copy" : "copyMove", n.setDragImage && n.setDragImage(g, 0, 0), n.clearData(), n.setData("Text", m.session.getTextRange()), this.setState("drag")
}, this.onDragEnd = function (e) {
b.draggable = !1, this.setState(null);
if (!m.getReadOnly()) {
var t = e.dataTransfer.dropEffect;
!k && t == "move" && m.session.remove(m.getSelectionRange()), m.renderer.$cursorLayer.setBlinking(!0)
}
this.editor.unsetStyle("ace_dragging")
}, this.onDragEnter = function (e) {
if (m.getReadOnly() || !d(e.dataTransfer)) return;
return w || c(), C++, e.dataTransfer.dropEffect = k = v(e), o.preventDefault(e)
}, this.onDragOver = function (e) {
if (m.getReadOnly() || !d(e.dataTransfer)) return;
return w || (c(), C++), M !== null && (M = null), E = e.clientX, S = e.clientY, e.dataTransfer.dropEffect = k = v(e), o.preventDefault(e)
}, this.onDragLeave = function (e) {
C--;
if (C <= 0 && w) return h(), k = null, o.preventDefault(e)
}, this.onDrop = function (e) {
if (!w) return;
var t = e.dataTransfer,
n = this.state == "drag";
if (n) switch (k) {
case "move":
T.contains(N.row, N.column) ? T = {
start: N,
end: N
} : T = m.moveText(T, N);
break;
case "copy":
T = m.moveText(T, N, !0)
} else {
var r = t.getData("Text");
T = {
start: N,
end: m.session.insert(N, r)
}, m.focus(), k = null
}
return h(), o.preventDefault(e)
}, o.addListener(b, "dragstart", this.onDragStart.bind(e)), o.addListener(b, "dragend", this.onDragEnd.bind(e)), o.addListener(b, "dragenter", this.onDragEnter.bind(e)), o.addListener(b, "dragover", this.onDragOver.bind(e)), o.addListener(b, "dragleave", this.onDragLeave.bind(e)), o.addListener(b, "drop", this.onDrop.bind(e));
var M = null
}
function i(e, t, n, r) {
return Math.sqrt(Math.pow(n - e, 2) + Math.pow(r - t, 2))
}
var s = e("../lib/dom"),
o = e("../lib/event"),
u = e("../lib/useragent"),
a = 200,
f = 200,
l = 5;
(function () {
this.dragWait = function () {
var e = (new Date).getTime() - this.mousedownEvent.time;
e > this.editor.getDragDelay() && this.startDrag()
}, this.dragWaitEnd = function () {
var e = this.editor.container;
e.draggable = !1, this.startSelect(this.mousedownEvent.getDocumentPosition()), this.selectEnd()
}, this.dragReadyEnd = function (e) {
this.editor.renderer.$cursorLayer.setBlinking(!this.editor.getReadOnly()), this.editor.unsetStyle("ace_dragging"), this.dragWaitEnd()
}, this.startDrag = function () {
this.cancelDrag = !1;
var e = this.editor.container;
e.draggable = !0, this.editor.renderer.$cursorLayer.setBlinking(!1), this.editor.setStyle("ace_dragging"), this.setState("dragReady")
}, this.onMouseDrag = function (e) {
var t = this.editor.container;
if (u.isIE && this.state == "dragReady") {
var n = i(this.mousedownEvent.x, this.mousedownEvent.y, this.x, this.y);
n > 3 && t.dragDrop()
}
if (this.state === "dragWait") {
var n = i(this.mousedownEvent.x, this.mousedownEvent.y, this.x, this.y);
n > 0 && (t.draggable = !1, this.startSelect(this.mousedownEvent.getDocumentPosition()))
}
}, this.onMouseDown = function (e) {
if (!this.$dragEnabled) return;
this.mousedownEvent = e;
var t = this.editor,
n = e.inSelection(),
r = e.getButton(),
i = e.domEvent.detail || 1;
if (i === 1 && r === 0 && n) {
this.mousedownEvent.time = (new Date).getTime();
var s = e.domEvent.target || e.domEvent.srcElement;
"unselectable" in s && (s.unselectable = "on");
if (t.getDragDelay()) {
if (u.isWebKit) {
self.cancelDrag = !0;
var o = t.container;
o.draggable = !0
}
this.setState("dragWait")
} else this.startDrag();
this.captureMouse(e, this.onMouseDrag.bind(this)), e.defaultPrevented = !0
}
}
}).call(r.prototype), t.DragdropHandler = r
}), ace.define("ace/config", ["require", "exports", "module", "ace/lib/lang", "ace/lib/oop", "ace/lib/net", "ace/lib/event_emitter"], function (e, t, n) {
"no use strict";
function r(e) {
return e.replace(/-(.)/g, function (e, t) {
return t.toUpperCase()
})
}
var i = e("./lib/lang"),
s = e("./lib/oop"),
o = e("./lib/net"),
u = e("./lib/event_emitter").EventEmitter,
a = function () {
return this
}(),
f = {
packaged: !1,
workerPath: null,
modePath: null,
themePath: null,
basePath: "",
suffix: ".js",
$moduleUrls: {}
};
t.get = function (e) {
if (!f.hasOwnProperty(e)) throw new Error("Unknown config key: " + e);
return f[e]
}, t.set = function (e, t) {
if (!f.hasOwnProperty(e)) throw new Error("Unknown config key: " + e);
f[e] = t
}, t.all = function () {
return i.copyObject(f)
}, s.implement(t, u), t.moduleUrl = function (e, t) {
if (f.$moduleUrls[e]) return f.$moduleUrls[e];
var n = e.split("/");
t = t || n[n.length - 2] || "";
var r = t == "snippets" ? "/" : "-",
i = n[n.length - 1];
if (r == "-") {
var s = new RegExp("^" + t + "[-_]|[-_]" + t + "$", "g");
i = i.replace(s, "")
}(!i || i == t) && n.length > 1 && (i = n[n.length - 2]);
var o = f[t + "Path"];
return o == null ? o = f.basePath : r == "/" && (t = r = ""), o && o.slice(-1) != "/" && (o += "/"), o + t + r + i + this.get("suffix")
}, t.setModuleUrl = function (e, t) {
return f.$moduleUrls[e] = t
}, t.$loading = {}, t.loadModule = function (n, r) {
var i, s;
Array.isArray(n) && (s = n[0], n = n[1]);
try {
i = e(n)
} catch (u) {}
if (i && !t.$loading[n]) return r && r(i);
t.$loading[n] || (t.$loading[n] = []), t.$loading[n].push(r);
if (t.$loading[n].length > 1) return;
var a = function () {
e([n], function (e) {
t._emit("load.module", {
name: n,
module: e
});
var r = t.$loading[n];
t.$loading[n] = null, r.forEach(function (t) {
t && t(e)
})
})
};
if (!t.get("packaged")) return a();
o.loadScript(t.moduleUrl(n, s), a)
}, t.init = function () {
f.packaged = e.packaged || n.packaged || a.define && define.packaged;
if (!a.document) return "";
var i = {}, s = "",
o = document.getElementsByTagName("script");
for (var u = 0; u < o.length; u++) {
var l = o[u],
c = l.src || l.getAttribute("src");
if (!c) continue;
var h = l.attributes;
for (var p = 0, d = h.length; p < d; p++) {
var v = h[p];
v.name.indexOf("data-ace-") === 0 && (i[r(v.name.replace(/^data-ace-/, ""))] = v.value)
}
var m = c.match(/^(.*)\/ace(\-\w+)?\.js(\?|$)/);
m && (s = m[1])
}
s && (i.base = i.base || s, i.packaged = !0), i.basePath = i.base, i.workerPath = i.workerPath || i.base, i.modePath = i.modePath || i.base, i.themePath = i.themePath || i.base, delete i.base;
for (var g in i) typeof i[g] != "undefined" && t.set(g, i[g])
};
var l = {
setOptions: function (e) {
Object.keys(e).forEach(function (t) {
this.setOption(t, e[t])
}, this)
},
getOptions: function (e) {
var t = {};
return e ? Array.isArray(e) || (t = e, e = Object.keys(t)) : e = Object.keys(this.$options), e.forEach(function (e) {
t[e] = this.getOption(e)
}, this), t
},
setOption: function (e, t) {
if (this["$" + e] === t) return;
var n = this.$options[e];
if (!n) return undefined;
if (n.forwardTo) return this[n.forwardTo] && this[n.forwardTo].setOption(e, t);
n.handlesSet || (this["$" + e] = t), n && n.set && n.set.call(this, t)
},
getOption: function (e) {
var t = this.$options[e];
return t ? t.forwardTo ? this[t.forwardTo] && this[t.forwardTo].getOption(e) : t && t.get ? t.get.call(this) : this["$" + e] : undefined
}
}, c = {};
t.defineOptions = function (e, t, n) {
return e.$options || (c[t] = e.$options = {}), Object.keys(n).forEach(function (t) {
var r = n[t];
typeof r == "string" && (r = {
forwardTo: r
}), r.name || (r.name = t), e.$options[r.name] = r, "initialValue" in r && (e["$" + r.name] = r.initialValue)
}), s.implement(e, l), this
}, t.resetOptions = function (e) {
Object.keys(e.$options).forEach(function (t) {
var n = e.$options[t];
"value" in n && e.setOption(t, n.value)
})
}, t.setDefaultValue = function (e, n, r) {
var i = c[e] || (c[e] = {});
i[n] && (i.forwardTo ? t.setDefaultValue(i.forwardTo, n, r) : i[n].value = r)
}, t.setDefaultValues = function (e, n) {
Object.keys(n).forEach(function (r) {
t.setDefaultValue(e, r, n[r])
})
}
}), ace.define("ace/lib/net", ["require", "exports", "module", "ace/lib/dom"], function (e, t, n) {
var r = e("./dom");
t.get = function (e, t) {
var n = new XMLHttpRequest;
n.open("GET", e, !0), n.onreadystatechange = function () {
n.readyState === 4 && t(n.responseText)
}, n.send(null)
}, t.loadScript = function (e, t) {
var n = r.getDocumentHead(),
i = document.createElement("script");
i.src = e, n.appendChild(i), i.onload = i.onreadystatechange = function (e, n) {
if (n || !i.readyState || i.readyState == "loaded" || i.readyState == "complete") i = i.onload = i.onreadystatechange = null, n || t()
}
}
}), ace.define("ace/lib/event_emitter", ["require", "exports", "module"], function (e, t, n) {
var r = {}, i = function () {
this.propagationStopped = !0
}, s = function () {
this.defaultPrevented = !0
};
r._emit = r._dispatchEvent = function (e, t) {
this._eventRegistry || (this._eventRegistry = {}), this._defaultHandlers || (this._defaultHandlers = {});
var n = this._eventRegistry[e] || [],
r = this._defaultHandlers[e];
if (!n.length && !r) return;
if (typeof t != "object" || !t) t = {};
t.type || (t.type = e), t.stopPropagation || (t.stopPropagation = i), t.preventDefault || (t.preventDefault = s), n = n.slice();
for (var o = 0; o < n.length; o++) {
n[o](t, this);
if (t.propagationStopped) break
}
if (r && !t.defaultPrevented) return r(t, this)
}, r._signal = function (e, t) {
var n = (this._eventRegistry || {})[e];
if (!n) return;
n = n.slice();
for (var r = 0; r < n.length; r++) n[r](t, this)
}, r.once = function (e, t) {
var n = this;
t && this.addEventListener(e, function r() {
n.removeEventListener(e, r), t.apply(null, arguments)
})
}, r.setDefaultHandler = function (e, t) {
var n = this._defaultHandlers;
n || (n = this._defaultHandlers = {
_disabled_: {}
});
if (n[e]) {
var r = n[e],
i = n._disabled_[e];
i || (n._disabled_[e] = i = []), i.push(r);
var s = i.indexOf(t);
s != -1 && i.splice(s, 1)
}
n[e] = t
}, r.removeDefaultHandler = function (e, t) {
var n = this._defaultHandlers;
if (!n) return;
var r = n._disabled_[e];
if (n[e] == t) {
var i = n[e];
r && this.setDefaultHandler(e, r.pop())
} else if (r) {
var s = r.indexOf(t);
s != -1 && r.splice(s, 1)
}
}, r.on = r.addEventListener = function (e, t, n) {
this._eventRegistry = this._eventRegistry || {};
var r = this._eventRegistry[e];
return r || (r = this._eventRegistry[e] = []), r.indexOf(t) == -1 && r[n ? "unshift" : "push"](t), t
}, r.off = r.removeListener = r.removeEventListener = function (e, t) {
this._eventRegistry = this._eventRegistry || {};
var n = this._eventRegistry[e];
if (!n) return;
var r = n.indexOf(t);
r !== -1 && n.splice(r, 1)
}, r.removeAllListeners = function (e) {
this._eventRegistry && (this._eventRegistry[e] = [])
}, t.EventEmitter = r
}), ace.define("ace/mouse/fold_handler", ["require", "exports", "module"], function (e, t, n) {
function r(e) {
e.on("click", function (t) {
var n = t.getDocumentPosition(),
r = e.session,
i = r.getFoldAt(n.row, n.column, 1);
i && (t.getAccelKey() ? r.removeFold(i) : r.expandFold(i), t.stop())
}), e.on("gutterclick", function (t) {
var n = e.renderer.$gutterLayer.getRegion(t);
if (n == "foldWidgets") {
var r = t.getDocumentPosition().row,
i = e.session;
i.foldWidgets && i.foldWidgets[r] && e.session.onFoldWidgetClick(r, t), e.isFocused() || e.focus(), t.stop()
}
}), e.on("gutterdblclick", function (t) {
var n = e.renderer.$gutterLayer.getRegion(t);
if (n == "foldWidgets") {
var r = t.getDocumentPosition().row,
i = e.session,
s = i.getParentFoldRangeData(r, !0),
o = s.range || s.firstRange;
if (o) {
var r = o.start.row,
u = i.getFoldAt(r, i.getLine(r).length, 1);
u ? i.removeFold(u) : (i.addFold("...", o), e.renderer.scrollCursorIntoView({
row: o.start.row,
column: 0
}))
}
t.stop()
}
})
}
t.FoldHandler = r
}), ace.define("ace/keyboard/keybinding", ["require", "exports", "module", "ace/lib/keys", "ace/lib/event"], function (e, t, n) {
var r = e("../lib/keys"),
i = e("../lib/event"),
s = function (e) {
this.$editor = e, this.$data = {}, this.$handlers = [], this.setDefaultHandler(e.commands)
};
(function () {
this.setDefaultHandler = function (e) {
this.removeKeyboardHandler(this.$defaultHandler), this.$defaultHandler = e, this.addKeyboardHandler(e, 0), this.$data = {
editor: this.$editor
}
}, this.setKeyboardHandler = function (e) {
var t = this.$handlers;
if (t[t.length - 1] == e) return;
while (t[t.length - 1] && t[t.length - 1] != this.$defaultHandler) this.removeKeyboardHandler(t[t.length - 1]);
this.addKeyboardHandler(e, 1)
}, this.addKeyboardHandler = function (e, t) {
if (!e) return;
var n = this.$handlers.indexOf(e);
n != -1 && this.$handlers.splice(n, 1), t == undefined ? this.$handlers.push(e) : this.$handlers.splice(t, 0, e), n == -1 && e.attach && e.attach(this.$editor)
}, this.removeKeyboardHandler = function (e) {
var t = this.$handlers.indexOf(e);
return t == -1 ? !1 : (this.$handlers.splice(t, 1), e.detach && e.detach(this.$editor), !0)
}, this.getKeyboardHandler = function () {
return this.$handlers[this.$handlers.length - 1]
}, this.$callKeyboardHandlers = function (e, t, n, r) {
var s, o = !1,
u = this.$editor.commands;
for (var a = this.$handlers.length; a--;) {
s = this.$handlers[a].handleKeyboard(this.$data, e, t, n, r);
if (!s || !s.command) continue;
s.command == "null" ? o = !0 : o = u.exec(s.command, this.$editor, s.args, r), o && r && e != -1 && s.passEvent != 1 && s.command.passEvent != 1 && i.stopEvent(r);
if (o) break
}
return o
}, this.onCommandKey = function (e, t, n) {
var i = r.keyCodeToString(n);
this.$callKeyboardHandlers(t, i, n, e)
}, this.onTextInput = function (e) {
var t = this.$callKeyboardHandlers(-1, e);
t || this.$editor.commands.exec("insertstring", this.$editor, e)
}
}).call(s.prototype), t.KeyBinding = s
}), ace.define("ace/edit_session", ["require", "exports", "module", "ace/lib/oop", "ace/lib/lang", "ace/config", "ace/lib/event_emitter", "ace/selection", "ace/mode/text", "ace/range", "ace/document", "ace/background_tokenizer", "ace/search_highlight", "ace/edit_session/folding", "ace/edit_session/bracket_match"], function (e, t, n) {
var r = e("./lib/oop"),
i = e("./lib/lang"),
s = e("./config"),
o = e("./lib/event_emitter").EventEmitter,
u = e("./selection").Selection,
a = e("./mode/text").Mode,
f = e("./range").Range,
l = e("./document").Document,
c = e("./background_tokenizer").BackgroundTokenizer,
h = e("./search_highlight").SearchHighlight,
p = function (e, t) {
this.$breakpoints = [], this.$decorations = [], this.$frontMarkers = {}, this.$backMarkers = {}, this.$markerId = 1, this.$undoSelect = !0, this.$foldData = [], this.$foldData.toString = function () {
return this.join("\n")
}, this.on("changeFold", this.onChangeFold.bind(this)), this.$onChange = this.onChange.bind(this);
if (typeof e != "object" || !e.getLine) e = new l(e);
this.setDocument(e), this.selection = new u(this), s.resetOptions(this), this.setMode(t), s._emit("session", this)
};
(function () {
function t(e) {
return e < 4352 ? !1 : e >= 4352 && e <= 4447 || e >= 4515 && e <= 4519 || e >= 4602 && e <= 4607 || e >= 9001 && e <= 9002 || e >= 11904 && e <= 11929 || e >= 11931 && e <= 12019 || e >= 12032 && e <= 12245 || e >= 12272 && e <= 12283 || e >= 12288 && e <= 12350 || e >= 12353 && e <= 12438 || e >= 12441 && e <= 12543 || e >= 12549 && e <= 12589 || e >= 12593 && e <= 12686 || e >= 12688 && e <= 12730 || e >= 12736 && e <= 12771 || e >= 12784 && e <= 12830 || e >= 12832 && e <= 12871 || e >= 12880 && e <= 13054 || e >= 13056 && e <= 19903 || e >= 19968 && e <= 42124 || e >= 42128 && e <= 42182 || e >= 43360 && e <= 43388 || e >= 44032 && e <= 55203 || e >= 55216 && e <= 55238 || e >= 55243 && e <= 55291 || e >= 63744 && e <= 64255 || e >= 65040 && e <= 65049 || e >= 65072 && e <= 65106 || e >= 65108 && e <= 65126 || e >= 65128 && e <= 65131 || e >= 65281 && e <= 65376 || e >= 65504 && e <= 65510
}
r.implement(this, o), this.setDocument = function (e) {
this.doc && this.doc.removeListener("change", this.$onChange), this.doc = e, e.on("change", this.$onChange), this.bgTokenizer && this.bgTokenizer.setDocument(this.getDocument()), this.resetCaches()
}, this.getDocument = function () {
return this.doc
}, this.$resetRowCache = function (e) {
if (!e) {
this.$docRowCache = [], this.$screenRowCache = [];
return
}
var t = this.$docRowCache.length,
n = this.$getRowCacheIndex(this.$docRowCache, e) + 1;
t > n && (this.$docRowCache.splice(n, t), this.$screenRowCache.splice(n, t))
}, this.$getRowCacheIndex = function (e, t) {
var n = 0,
r = e.length - 1;
while (n <= r) {
var i = n + r >> 1,
s = e[i];
if (t > s) n = i + 1;
else {
if (!(t < s)) return i;
r = i - 1
}
}
return n - 1
}, this.resetCaches = function () {
this.$modified = !0, this.$wrapData = [], this.$rowLengthCache = [], this.$resetRowCache(0), this.bgTokenizer && this.bgTokenizer.start(0)
}, this.onChangeFold = function (e) {
var t = e.data;
this.$resetRowCache(t.start.row)
}, this.onChange = function (e) {
var t = e.data;
this.$modified = !0, this.$resetRowCache(t.range.start.row);
var n = this.$updateInternalDataOnChange(e);
!this.$fromUndo && this.$undoManager && !t.ignore && (this.$deltasDoc.push(t), n && n.length != 0 && this.$deltasFold.push({
action: "removeFolds",
folds: n
}), this.$informUndoManager.schedule()), this.bgTokenizer.$updateOnChange(t), this._emit("change", e)
}, this.setValue = function (e) {
this.doc.setValue(e), this.selection.moveCursorTo(0, 0), this.selection.clearSelection(), this.$resetRowCache(0), this.$deltas = [], this.$deltasDoc = [], this.$deltasFold = [], this.getUndoManager().reset()
}, this.getValue = this.toString = function () {
return this.doc.getValue()
}, this.getSelection = function () {
return this.selection
}, this.getState = function (e) {
return this.bgTokenizer.getState(e)
}, this.getTokens = function (e) {
return this.bgTokenizer.getTokens(e)
}, this.getTokenAt = function (e, t) {
var n = this.bgTokenizer.getTokens(e),
r, i = 0;
if (t == null) s = n.length - 1, i = this.getLine(e).length;
else
for (var s = 0; s < n.length; s++) {
i += n[s].value.length;
if (i >= t) break
}
return r = n[s], r ? (r.index = s, r.start = i - r.value.length, r) : null
}, this.setUndoManager = function (e) {
this.$undoManager = e, this.$deltas = [], this.$deltasDoc = [], this.$deltasFold = [], this.$informUndoManager && this.$informUndoManager.cancel();
if (e) {
var t = this;
this.$syncInformUndoManager = function () {
t.$informUndoManager.cancel(), t.$deltasFold.length && (t.$deltas.push({
group: "fold",
deltas: t.$deltasFold
}), t.$deltasFold = []), t.$deltasDoc.length && (t.$deltas.push({
group: "doc",
deltas: t.$deltasDoc
}), t.$deltasDoc = []), t.$deltas.length > 0 && e.execute({
action: "aceupdate",
args: [t.$deltas, t],
merge: t.mergeUndoDeltas
}), t.mergeUndoDeltas = !1, t.$deltas = []
}, this.$informUndoManager = i.delayedCall(this.$syncInformUndoManager)
}
}, this.markUndoGroup = function () {
this.$syncInformUndoManager && this.$syncInformUndoManager()
}, this.$defaultUndoManager = {
undo: function () {},
redo: function () {},
reset: function () {}
}, this.getUndoManager = function () {
return this.$undoManager || this.$defaultUndoManager
}, this.getTabString = function () {
return this.getUseSoftTabs() ? i.stringRepeat(" ", this.getTabSize()) : " "
}, this.setUseSoftTabs = function (e) {
this.setOption("useSoftTabs", e)
}, this.getUseSoftTabs = function () {
return this.$useSoftTabs && !this.$mode.$indentWithTabs
}, this.setTabSize = function (e) {
this.setOption("tabSize", e)
}, this.getTabSize = function () {
return this.$tabSize
}, this.isTabStop = function (e) {
return this.$useSoftTabs && e.column % this.$tabSize == 0
}, this.$overwrite = !1, this.setOverwrite = function (e) {
this.setOption("overwrite", e)
}, this.getOverwrite = function () {
return this.$overwrite
}, this.toggleOverwrite = function () {
this.setOverwrite(!this.$overwrite)
}, this.addGutterDecoration = function (e, t) {
this.$decorations[e] || (this.$decorations[e] = ""), this.$decorations[e] += " " + t, this._emit("changeBreakpoint", {})
}, this.removeGutterDecoration = function (e, t) {
this.$decorations[e] = (this.$decorations[e] || "").replace(" " + t, ""), this._emit("changeBreakpoint", {})
}, this.getBreakpoints = function () {
return this.$breakpoints
}, this.setBreakpoints = function (e) {
this.$breakpoints = [];
for (var t = 0; t < e.length; t++) this.$breakpoints[e[t]] = "ace_breakpoint";
this._emit("changeBreakpoint", {})
}, this.clearBreakpoints = function () {
this.$breakpoints = [], this._emit("changeBreakpoint", {})
}, this.setBreakpoint = function (e, t) {
t === undefined && (t = "ace_breakpoint"), t ? this.$breakpoints[e] = t : delete this.$breakpoints[e], this._emit("changeBreakpoint", {})
}, this.clearBreakpoint = function (e) {
delete this.$breakpoints[e], this._emit("changeBreakpoint", {})
}, this.addMarker = function (e, t, n, r) {
var i = this.$markerId++,
s = {
range: e,
type: n || "line",
renderer: typeof n == "function" ? n : null,
clazz: t,
inFront: !! r,
id: i
};
return r ? (this.$frontMarkers[i] = s, this._emit("changeFrontMarker")) : (this.$backMarkers[i] = s, this._emit("changeBackMarker")), i
}, this.addDynamicMarker = function (e, t) {
if (!e.update) return;
var n = this.$markerId++;
return e.id = n, e.inFront = !! t, t ? (this.$frontMarkers[n] = e, this._emit("changeFrontMarker")) : (this.$backMarkers[n] = e, this._emit("changeBackMarker")), e
}, this.removeMarker = function (e) {
var t = this.$frontMarkers[e] || this.$backMarkers[e];
if (!t) return;
var n = t.inFront ? this.$frontMarkers : this.$backMarkers;
t && (delete n[e], this._emit(t.inFront ? "changeFrontMarker" : "changeBackMarker"))
}, this.getMarkers = function (e) {
return e ? this.$frontMarkers : this.$backMarkers
}, this.highlight = function (e) {
if (!this.$searchHighlight) {
var t = new h(null, "ace_selected-word", "text");
this.$searchHighlight = this.addDynamicMarker(t)
}
this.$searchHighlight.setRegexp(e)
}, this.highlightLines = function (e, t, n, r) {
typeof t != "number" && (n = t, t = e), n || (n = "ace_step");
var i = new f(e, 0, t, Infinity);
return i.id = this.addMarker(i, n, "fullLine", r), i
}, this.setAnnotations = function (e) {
this.$annotations = e, this._emit("changeAnnotation", {})
}, this.getAnnotations = function () {
return this.$annotations || []
}, this.clearAnnotations = function () {
this.setAnnotations([])
}, this.$detectNewLine = function (e) {
var t = e.match(/^.*?(\r?\n)/m);
t ? this.$autoNewLine = t[1] : this.$autoNewLine = "\n"
}, this.getWordRange = function (e, t) {
var n = this.getLine(e),
r = !1;
t > 0 && (r = !! n.charAt(t - 1).match(this.tokenRe)), r || (r = !! n.charAt(t).match(this.tokenRe));
if (r) var i = this.tokenRe;
else if (/^\s+$/.test(n.slice(t - 1, t + 1))) var i = /\s/;
else var i = this.nonTokenRe;
var s = t;
if (s > 0) {
do s--; while (s >= 0 && n.charAt(s).match(i));
s++
}
var o = t;
while (o < n.length && n.charAt(o).match(i)) o++;
return new f(e, s, e, o)
}, this.getAWordRange = function (e, t) {
var n = this.getWordRange(e, t),
r = this.getLine(n.end.row);
while (r.charAt(n.end.column).match(/[ \t]/)) n.end.column += 1;
return n
}, this.setNewLineMode = function (e) {
this.doc.setNewLineMode(e)
}, this.getNewLineMode = function () {
return this.doc.getNewLineMode()
}, this.setUseWorker = function (e) {
this.setOption("useWorker", e)
}, this.getUseWorker = function () {
return this.$useWorker
}, this.onReloadTokenizer = function (e) {
var t = e.data;
this.bgTokenizer.start(t.first), this._emit("tokenizerUpdate", e)
}, this.$modes = {}, this.$mode = null, this.$modeId = null, this.setMode = function (e, t) {
if (e && typeof e == "object") {
if (e.getTokenizer) return this.$onChangeMode(e);
var n = e,
r = n.path
} else r = e || "ace/mode/text";
this.$modes["ace/mode/text"] || (this.$modes["ace/mode/text"] = new a);
if (this.$modes[r] && !n) {
this.$onChangeMode(this.$modes[r]), t && t();
return
}
this.$modeId = r, s.loadModule(["mode", r], function (e) {
if (this.$modeId !== r) return t && t();
if (this.$modes[r] && !n) return this.$onChangeMode(this.$modes[r]);
e && e.Mode && (e = new e.Mode(n), n || (this.$modes[r] = e, e.$id = r), this.$onChangeMode(e), t && t())
}.bind(this)), this.$mode || this.$onChangeMode(this.$modes["ace/mode/text"], !0)
}, this.$onChangeMode = function (e, t) {
t || (this.$modeId = e.$id);
if (this.$mode === e) return;
this.$mode = e, this.$stopWorker(), this.$useWorker && this.$startWorker();
var n = e.getTokenizer();
if (n.addEventListener !== undefined) {
var r = this.onReloadTokenizer.bind(this);
n.addEventListener("update", r)
}
if (!this.bgTokenizer) {
this.bgTokenizer = new c(n);
var i = this;
this.bgTokenizer.addEventListener("update", function (e) {
i._emit("tokenizerUpdate", e)
})
} else this.bgTokenizer.setTokenizer(n);
this.bgTokenizer.setDocument(this.getDocument()), this.tokenRe = e.tokenRe, this.nonTokenRe = e.nonTokenRe, this.$options.wrapMethod.set.call(this, this.$wrapMethod), t || (this.$setFolding(e.foldingRules), this._emit("changeMode"), this.bgTokenizer.start(0))
}, this.$stopWorker = function () {
this.$worker && this.$worker.terminate(), this.$worker = null
}, this.$startWorker = function () {
if (typeof Worker != "undefined" && !e.noWorker) try {
this.$worker = this.$mode.createWorker(this)
} catch (t) {
console.log("Could not load worker"), console.log(t), this.$worker = null
} else this.$worker = null
}, this.getMode = function () {
return this.$mode
}, this.$scrollTop = 0, this.setScrollTop = function (e) {
if (this.$scrollTop === e || isNaN(e)) return;
this.$scrollTop = e, this._signal("changeScrollTop", e)
}, this.getScrollTop = function () {
return this.$scrollTop
}, this.$scrollLeft = 0, this.setScrollLeft = function (e) {
if (this.$scrollLeft === e || isNaN(e)) return;
this.$scrollLeft = e, this._signal("changeScrollLeft", e)
}, this.getScrollLeft = function () {
return this.$scrollLeft
}, this.getScreenWidth = function () {
return this.$computeWidth(), this.screenWidth
}, this.$computeWidth = function (e) {
if (this.$modified || e) {
this.$modified = !1;
if (this.$useWrapMode) return this.screenWidth = this.$wrapLimit;
var t = this.doc.getAllLines(),
n = this.$rowLengthCache,
r = 0,
i = 0,
s = this.$foldData[i],
o = s ? s.start.row : Infinity,
u = t.length;
for (var a = 0; a < u; a++) {
if (a > o) {
a = s.end.row + 1;
if (a >= u) break;
s = this.$foldData[i++], o = s ? s.start.row : Infinity
}
n[a] == null && (n[a] = this.$getStringScreenWidth(t[a])[0]), n[a] > r && (r = n[a])
}
this.screenWidth = r
}
}, this.getLine = function (e) {
return this.doc.getLine(e)
}, this.getLines = function (e, t) {
return this.doc.getLines(e, t)
}, this.getLength = function () {
return this.doc.getLength()
}, this.getTextRange = function (e) {
return this.doc.getTextRange(e || this.selection.getRange())
}, this.insert = function (e, t) {
return this.doc.insert(e, t)
}, this.remove = function (e) {
return this.doc.remove(e)
}, this.undoChanges = function (e, t) {
if (!e.length) return;
this.$fromUndo = !0;
var n = null;
for (var r = e.length - 1; r != -1; r--) {
var i = e[r];
i.group == "doc" ? (this.doc.revertDeltas(i.deltas), n = this.$getUndoSelection(i.deltas, !0, n)) : i.deltas.forEach(function (e) {
this.addFolds(e.folds)
}, this)
}
return this.$fromUndo = !1, n && this.$undoSelect && !t && this.selection.setSelectionRange(n), n
}, this.redoChanges = function (e, t) {
if (!e.length) return;
this.$fromUndo = !0;
var n = null;
for (var r = 0; r < e.length; r++) {
var i = e[r];
i.group == "doc" && (this.doc.applyDeltas(i.deltas), n = this.$getUndoSelection(i.deltas, !1, n))
}
return this.$fromUndo = !1, n && this.$undoSelect && !t && this.selection.setSelectionRange(n), n
}, this.setUndoSelect = function (e) {
this.$undoSelect = e
}, this.$getUndoSelection = function (e, t, n) {
function r(e) {
var n = e.action === "insertText" || e.action === "insertLines";
return t ? !n : n
}
var i = e[0],
s, o, u = !1;
r(i) ? (s = f.fromPoints(i.range.start, i.range.end), u = !0) : (s = f.fromPoints(i.range.start, i.range.start), u = !1);
for (var a = 1; a < e.length; a++) i = e[a], r(i) ? (o = i.range.start, s.compare(o.row, o.column) == -1 && s.setStart(i.range.start), o = i.range.end, s.compare(o.row, o.column) == 1 && s.setEnd(i.range.end), u = !0) : (o = i.range.start, s.compare(o.row, o.column) == -1 && (s = f.fromPoints(i.range.start, i.range.start)), u = !1);
if (n != null) {
f.comparePoints(n.start, s.start) == 0 && (n.start.column += s.end.column - s.start.column, n.end.column += s.end.column - s.start.column);
var l = n.compareRange(s);
l == 1 ? s.setStart(n.start) : l == -1 && s.setEnd(n.end)
}
return s
}, this.replace = function (e, t) {
return this.doc.replace(e, t)
}, this.moveText = function (e, t, n) {
var r = this.getTextRange(e),
i = this.getFoldsInRange(e),
s = f.fromPoints(t, t);
if (!n) {
this.remove(e);
var o = e.start.row - e.end.row,
u = o ? -e.end.column : e.start.column - e.end.column;
u && (s.start.row == e.end.row && s.start.column > e.end.column && (s.start.column += u), s.end.row == e.end.row && s.end.column > e.end.column && (s.end.column += u)), o && s.start.row >= e.end.row && (s.start.row += o, s.end.row += o)
}
s.end = this.insert(s.start, r);
if (i.length) {
var a = e.start,
l = s.start,
o = l.row - a.row,
u = l.column - a.column;
this.addFolds(i.map(function (e) {
return e = e.clone(), e.start.row == a.row && (e.start.column += u), e.end.row == a.row && (e.end.column += u), e.start.row += o, e.end.row += o, e
}))
}
return s
}, this.indentRows = function (e, t, n) {
n = n.replace(/\t/g, this.getTabString());
for (var r = e; r <= t; r++) this.insert({
row: r,
column: 0
}, n)
}, this.outdentRows = function (e) {
var t = e.collapseRows(),
n = new f(0, 0, 0, 0),
r = this.getTabSize();
for (var i = t.start.row; i <= t.end.row; ++i) {
var s = this.getLine(i);
n.start.row = i, n.end.row = i;
for (var o = 0; o < r; ++o)
if (s.charAt(o) != " ") break;
o < r && s.charAt(o) == " " ? (n.start.column = o, n.end.column = o + 1) : (n.start.column = 0, n.end.column = o), this.remove(n)
}
}, this.$moveLines = function (e, t, n) {
e = this.getRowFoldStart(e), t = this.getRowFoldEnd(t);
if (n < 0) {
var r = this.getRowFoldStart(e + n);
if (r < 0) return 0;
var i = r - e
} else if (n > 0) {
var r = this.getRowFoldEnd(t + n);
if (r > this.doc.getLength() - 1) return 0;
var i = r - t
} else {
e = this.$clipRowToDocument(e), t = this.$clipRowToDocument(t);
var i = t - e + 1
}
var s = new f(e, 0, t, Number.MAX_VALUE),
o = this.getFoldsInRange(s).map(function (e) {
return e = e.clone(), e.start.row += i, e.end.row += i, e
}),
u = n == 0 ? this.doc.getLines(e, t) : this.doc.removeLines(e, t);
return this.doc.insertLines(e + i, u), o.length && this.addFolds(o), i
}, this.moveLinesUp = function (e, t) {
return this.$moveLines(e, t, -1)
}, this.moveLinesDown = function (e, t) {
return this.$moveLines(e, t, 1)
}, this.duplicateLines = function (e, t) {
return this.$moveLines(e, t, 0)
}, this.$clipRowToDocument = function (e) {
return Math.max(0, Math.min(e, this.doc.getLength() - 1))
}, this.$clipColumnToRow = function (e, t) {
return t < 0 ? 0 : Math.min(this.doc.getLine(e).length, t)
}, this.$clipPositionToDocument = function (e, t) {
t = Math.max(0, t);
if (e < 0) e = 0, t = 0;
else {
var n = this.doc.getLength();
e >= n ? (e = n - 1, t = this.doc.getLine(n - 1).length) : t = Math.min(this.doc.getLine(e).length, t)
}
return {
row: e,
column: t
}
}, this.$clipRangeToDocument = function (e) {
e.start.row < 0 ? (e.start.row = 0, e.start.column = 0) : e.start.column = this.$clipColumnToRow(e.start.row, e.start.column);
var t = this.doc.getLength() - 1;
return e.end.row > t ? (e.end.row = t, e.end.column = this.doc.getLine(t).length) : e.end.column = this.$clipColumnToRow(e.end.row, e.end.column), e
}, this.$wrapLimit = 80, this.$useWrapMode = !1, this.$wrapLimitRange = {
min: null,
max: null
}, this.setUseWrapMode = function (e) {
if (e != this.$useWrapMode) {
this.$useWrapMode = e, this.$modified = !0, this.$resetRowCache(0);
if (e) {
var t = this.getLength();
this.$wrapData = [];
for (var n = 0; n < t; n++) this.$wrapData.push([]);
this.$updateWrapData(0, t - 1)
}
this._emit("changeWrapMode")
}
}, this.getUseWrapMode = function () {
return this.$useWrapMode
}, this.setWrapLimitRange = function (e, t) {
if (this.$wrapLimitRange.min !== e || this.$wrapLimitRange.max !== t) this.$wrapLimitRange = {
min: e,
max: t
}, this.$modified = !0, this._emit("changeWrapMode")
}, this.adjustWrapLimit = function (e, t) {
var n = this.$wrapLimitRange;
n.max < 0 && (n = {
min: t,
max: t
});
var r = this.$constrainWrapLimit(e, n.min, n.max);
return r != this.$wrapLimit && r > 1 ? (this.$wrapLimit = r, this.$modified = !0, this.$useWrapMode && (this.$updateWrapData(0, this.getLength() - 1), this.$resetRowCache(0), this._emit("changeWrapLimit")), !0) : !1
}, this.$constrainWrapLimit = function (e, t, n) {
return t && (e = Math.max(t, e)), n && (e = Math.min(n, e)), e
}, this.getWrapLimit = function () {
return this.$wrapLimit
}, this.setWrapLimit = function (e) {
this.setWrapLimitRange(e, e)
}, this.getWrapLimitRange = function () {
return {
min: this.$wrapLimitRange.min,
max: this.$wrapLimitRange.max
}
}, this.$updateInternalDataOnChange = function (e) {
var t = this.$useWrapMode,
n, r = e.data.action,
i = e.data.range.start.row,
s = e.data.range.end.row,
o = e.data.range.start,
u = e.data.range.end,
a = null;
r.indexOf("Lines") != -1 ? (r == "insertLines" ? s = i + e.data.lines.length : s = i, n = e.data.lines ? e.data.lines.length : s - i) : n = s - i, this.$updating = !0;
if (n != 0)
if (r.indexOf("remove") != -1) {
this[t ? "$wrapData" : "$rowLengthCache"].splice(i, n);
var f = this.$foldData;
a = this.getFoldsInRange(e.data.range), this.removeFolds(a);
var l = this.getFoldLine(u.row),
c = 0;
if (l) {
l.addRemoveChars(u.row, u.column, o.column - u.column), l.shiftRow(-n);
var h = this.getFoldLine(i);
h && h !== l && (h.merge(l), l = h), c = f.indexOf(l) + 1
}
for (c; c < f.length; c++) {
var l = f[c];
l.start.row >= u.row && l.shiftRow(-n)
}
s = i
} else {
var p;
if (t) {
p = [i, 0];
for (var d = 0; d < n; d++) p.push([]);
this.$wrapData.splice.apply(this.$wrapData, p)
} else p = Array(n), p.unshift(i, 0), this.$rowLengthCache.splice.apply(this.$rowLengthCache, p);
var f = this.$foldData,
l = this.getFoldLine(i),
c = 0;
if (l) {
var v = l.range.compareInside(o.row, o.column);
v == 0 ? (l = l.split(o.row, o.column), l.shiftRow(n), l.addRemoveChars(s, 0, u.column - o.column)) : v == -1 && (l.addRemoveChars(i, 0, u.column - o.column), l.shiftRow(n)), c = f.indexOf(l) + 1
}
for (c; c < f.length; c++) {
var l = f[c];
l.start.row >= i && l.shiftRow(n)
}
} else {
n = Math.abs(e.data.range.start.column - e.data.range.end.column), r.indexOf("remove") != -1 && (a = this.getFoldsInRange(e.data.range), this.removeFolds(a), n = -n);
var l = this.getFoldLine(i);
l && l.addRemoveChars(i, o.column, n)
}
return t && this.$wrapData.length != this.doc.getLength() && console.error("doc.getLength() and $wrapData.length have to be the same!"), this.$updating = !1, t ? this.$updateWrapData(i, s) : this.$updateRowLengthCache(i, s), a
}, this.$updateRowLengthCache = function (e, t, n) {
this.$rowLengthCache[e] = null, this.$rowLengthCache[t] = null
}, this.$updateWrapData = function (e, t) {
var n = this.doc.getAllLines(),
r = this.getTabSize(),
i = this.$wrapData,
s = this.$wrapLimit,
o, u, a = e;
t = Math.min(t, n.length - 1);
while (a <= t) u = this.getFoldLine(a, u), u ? (o = [], u.walk(function (e, t, r, i) {
var s;
if (e != null) {
s = this.$getDisplayTokens(e, o.length), s[0] = l;
for (var u = 1; u < s.length; u++) s[u] = p
} else s = this.$getDisplayTokens(n[t].substring(i, r), o.length);
o = o.concat(s)
}.bind(this), u.end.row, n[u.end.row].length + 1), i[u.start.row] = this.$computeWrapSplits(o, s, r), a = u.end.row + 1) : (o = this.$getDisplayTokens(n[a]), i[a] = this.$computeWrapSplits(o, s, r), a++)
};
var n = 1,
u = 2,
l = 3,
p = 4,
d = 9,
v = 10,
m = 11,
g = 12;
this.$computeWrapSplits = function (e, t) {
function n(t) {
var n = e.slice(s, t),
i = n.length;
n.join("").replace(/12/g, function () {
i -= 1
}).replace(/2/g, function () {
i -= 1
}), o += i, r.push(o), s = t
}
if (e.length == 0) return [];
var r = [],
i = e.length,
s = 0,
o = 0,
u = this.$wrapAsCode;
while (i - s > t) {
var a = s + t;
if (e[a - 1] >= v && e[a] >= v) {
n(a);
continue
}
if (e[a] == l || e[a] == p) {
for (a; a != s - 1; a--)
if (e[a] == l) break;
if (a > s) {
n(a);
continue
}
a = s + t;
for (a; a < e.length; a++)
if (e[a] != p) break;
if (a == e.length) break;
n(a);
continue
}
var f = Math.max(a - (u ? 10 : t - (t >> 2)), s - 1);
while (a > f && e[a] < l) a--;
if (u) {
while (a > f && e[a] < l) a--;
while (a > f && e[a] == d) a--
} else
while (a > f && e[a] < v) a--; if (a > f) {
n(++a);
continue
}
a = s + t, n(a)
}
return r
}, this.$getDisplayTokens = function (e, r) {
var i = [],
s;
r = r || 0;
for (var o = 0; o < e.length; o++) {
var a = e.charCodeAt(o);
if (a == 9) {
s = this.getScreenTabSize(i.length + r), i.push(m);
for (var f = 1; f < s; f++) i.push(g)
} else a == 32 ? i.push(v) : a > 39 && a < 48 || a > 57 && a < 64 ? i.push(d) : a >= 4352 && t(a) ? i.push(n, u) : i.push(n)
}
return i
}, this.$getStringScreenWidth = function (e, n, r) {
if (n == 0) return [0, 0];
n == null && (n = Infinity), r = r || 0;
var i, s;
for (s = 0; s < e.length; s++) {
i = e.charCodeAt(s), i == 9 ? r += this.getScreenTabSize(r) : i >= 4352 && t(i) ? r += 2 : r += 1;
if (r > n) break
}
return [r, s]
}, this.getRowLength = function (e) {
return !this.$useWrapMode || !this.$wrapData[e] ? 1 : this.$wrapData[e].length + 1
}, this.getScreenLastRowColumn = function (e) {
var t = this.screenToDocumentPosition(e, Number.MAX_VALUE);
return this.documentToScreenColumn(t.row, t.column)
}, this.getDocumentLastRowColumn = function (e, t) {
var n = this.documentToScreenRow(e, t);
return this.getScreenLastRowColumn(n)
}, this.getDocumentLastRowColumnPosition = function (e, t) {
var n = this.documentToScreenRow(e, t);
return this.screenToDocumentPosition(n, Number.MAX_VALUE / 10)
}, this.getRowSplitData = function (e) {
return this.$useWrapMode ? this.$wrapData[e] : undefined
}, this.getScreenTabSize = function (e) {
return this.$tabSize - e % this.$tabSize
}, this.screenToDocumentRow = function (e, t) {
return this.screenToDocumentPosition(e, t).row
}, this.screenToDocumentColumn = function (e, t) {
return this.screenToDocumentPosition(e, t).column
}, this.screenToDocumentPosition = function (e, t) {
if (e < 0) return {
row: 0,
column: 0
};
var n, r = 0,
i = 0,
s, o = 0,
u = 0,
a = this.$screenRowCache,
f = this.$getRowCacheIndex(a, e),
l = a.length;
if (l && f >= 0) var o = a[f],
r = this.$docRowCache[f], c = e > a[l - 1];
else var c = !l;
var h = this.getLength() - 1,
p = this.getNextFoldLine(r),
d = p ? p.start.row : Infinity;
while (o <= e) {
u = this.getRowLength(r);
if (o + u - 1 >= e || r >= h) break;
o += u, r++, r > d && (r = p.end.row + 1, p = this.getNextFoldLine(r, p), d = p ? p.start.row : Infinity), c && (this.$docRowCache.push(r), this.$screenRowCache.push(o))
}
if (p && p.start.row <= r) n = this.getFoldDisplayLine(p), r = p.start.row;
else {
if (o + u <= e || r > h) return {
row: h,
column: this.getLine(h).length
};
n = this.getLine(r), p = null
} if (this.$useWrapMode) {
var v = this.$wrapData[r];
v && (s = v[e - o], e > o && v.length && (i = v[e - o - 1] || v[v.length - 1], n = n.substring(i)))
}
return i += this.$getStringScreenWidth(n, t)[1], this.$useWrapMode && i >= s && (i = s - 1), p ? p.idxToPosition(i) : {
row: r,
column: i
}
}, this.documentToScreenPosition = function (e, t) {
if (typeof t == "undefined") var n = this.$clipPositionToDocument(e.row, e.column);
else n = this.$clipPositionToDocument(e, t);
e = n.row, t = n.column;
var r = 0,
i = null,
s = null;
s = this.getFoldAt(e, t, 1), s && (e = s.start.row, t = s.start.column);
var o, u = 0,
a = this.$docRowCache,
f = this.$getRowCacheIndex(a, e),
l = a.length;
if (l && f >= 0) var u = a[f],
r = this.$screenRowCache[f], c = e > a[l - 1];
else var c = !l;
var h = this.getNextFoldLine(u),
p = h ? h.start.row : Infinity;
while (u < e) {
if (u >= p) {
o = h.end.row + 1;
if (o > e) break;
h = this.getNextFoldLine(o, h), p = h ? h.start.row : Infinity
} else o = u + 1;
r += this.getRowLength(u), u = o, c && (this.$docRowCache.push(u), this.$screenRowCache.push(r))
}
var d = "";
h && u >= p ? (d = this.getFoldDisplayLine(h, e, t), i = h.start.row) : (d = this.getLine(e).substring(0, t), i = e);
if (this.$useWrapMode) {
var v = this.$wrapData[i],
m = 0;
while (d.length >= v[m]) r++, m++;
d = d.substring(v[m - 1] || 0, d.length)
}
return {
row: r,
column: this.$getStringScreenWidth(d)[0]
}
}, this.documentToScreenColumn = function (e, t) {
return this.documentToScreenPosition(e, t).column
}, this.documentToScreenRow = function (e, t) {
return this.documentToScreenPosition(e, t).row
}, this.getScreenLength = function () {
var e = 0,
t = null;
if (!this.$useWrapMode) {
e = this.getLength();
var n = this.$foldData;
for (var r = 0; r < n.length; r++) t = n[r], e -= t.end.row - t.start.row
} else {
var i = this.$wrapData.length,
s = 0,
r = 0,
t = this.$foldData[r++],
o = t ? t.start.row : Infinity;
while (s < i) e += this.$wrapData[s].length + 1, s++, s > o && (s = t.end.row + 1, t = this.$foldData[r++], o = t ? t.start.row : Infinity)
}
return e
}
}).call(p.prototype), e("./edit_session/folding").Folding.call(p.prototype), e("./edit_session/bracket_match").BracketMatch.call(p.prototype), s.defineOptions(p.prototype, "session", {
wrap: {
set: function (e) {
!e || e == "off" ? e = !1 : e == "free" ? e = !0 : e == "printMargin" ? e = -1 : typeof e == "string" && (e = parseInt(e, 10) || !1);
if (this.$wrap == e) return;
if (!e) this.setUseWrapMode(!1);
else {
var t = typeof e == "number" ? e : null;
this.setWrapLimitRange(t, t), this.setUseWrapMode(!0)
}
this.$wrap = e
},
get: function () {
return this.getUseWrapMode() ? this.getWrapLimitRange().min || "free" : "off"
},
handlesSet: !0
},
wrapMethod: {
set: function (e) {
e == "auto" ? this.$wrapAsCode = this.$mode.type != "text" : this.$wrapAsCode = e != "text"
},
initialValue: "auto"
},
firstLineNumber: {
set: function () {
this._emit("changeBreakpoint")
},
initialValue: 1
},
useWorker: {
set: function (e) {
this.$useWorker = e, this.$stopWorker(), e && this.$startWorker()
},
initialValue: !0
},
useSoftTabs: {
initialValue: !0
},
tabSize: {
set: function (e) {
if (isNaN(e) || this.$tabSize === e) return;
this.$modified = !0, this.$rowLengthCache = [], this.$tabSize = e, this._emit("changeTabSize")
},
initialValue: 4,
handlesSet: !0
},
overwrite: {
set: function (e) {
this._emit("changeOverwrite")
},
initialValue: !1
},
newLineMode: {
set: function (e) {
this.doc.setNewLineMode(e)
},
get: function () {
return this.doc.getNewLineMode()
},
handlesSet: !0
}
}), t.EditSession = p
}), ace.define("ace/selection", ["require", "exports", "module", "ace/lib/oop", "ace/lib/lang", "ace/lib/event_emitter", "ace/range"], function (e, t, n) {
var r = e("./lib/oop"),
i = e("./lib/lang"),
s = e("./lib/event_emitter").EventEmitter,
o = e("./range").Range,
u = function (e) {
this.session = e, this.doc = e.getDocument(), this.clearSelection(), this.lead = this.selectionLead = this.doc.createAnchor(0, 0), this.anchor = this.selectionAnchor = this.doc.createAnchor(0, 0);
var t = this;
this.lead.on("change", function (e) {
t._emit("changeCursor"), t.$isEmpty || t._emit("changeSelection"), !t.$keepDesiredColumnOnChange && e.old.column != e.value.column && (t.$desiredColumn = null)
}), this.selectionAnchor.on("change", function () {
t.$isEmpty || t._emit("changeSelection")
})
};
(function () {
r.implement(this, s), this.isEmpty = function () {
return this.$isEmpty || this.anchor.row == this.lead.row && this.anchor.column == this.lead.column
}, this.isMultiLine = function () {
return this.isEmpty() ? !1 : this.getRange().isMultiLine()
}, this.getCursor = function () {
return this.lead.getPosition()
}, this.setSelectionAnchor = function (e, t) {
this.anchor.setPosition(e, t), this.$isEmpty && (this.$isEmpty = !1, this._emit("changeSelection"))
}, this.getSelectionAnchor = function () {
return this.$isEmpty ? this.getSelectionLead() : this.anchor.getPosition()
}, this.getSelectionLead = function () {
return this.lead.getPosition()
}, this.shiftSelection = function (e) {
if (this.$isEmpty) {
this.moveCursorTo(this.lead.row, this.lead.column + e);
return
}
var t = this.getSelectionAnchor(),
n = this.getSelectionLead(),
r = this.isBackwards();
(!r || t.column !== 0) && this.setSelectionAnchor(t.row, t.column + e), (r || n.column !== 0) && this.$moveSelection(function () {
this.moveCursorTo(n.row, n.column + e)
})
}, this.isBackwards = function () {
var e = this.anchor,
t = this.lead;
return e.row > t.row || e.row == t.row && e.column > t.column
}, this.getRange = function () {
var e = this.anchor,
t = this.lead;
return this.isEmpty() ? o.fromPoints(t, t) : this.isBackwards() ? o.fromPoints(t, e) : o.fromPoints(e, t)
}, this.clearSelection = function () {
this.$isEmpty || (this.$isEmpty = !0, this._emit("changeSelection"))
}, this.selectAll = function () {
var e = this.doc.getLength() - 1;
this.setSelectionAnchor(0, 0), this.moveCursorTo(e, this.doc.getLine(e).length)
}, this.setRange = this.setSelectionRange = function (e, t) {
t ? (this.setSelectionAnchor(e.end.row, e.end.column), this.selectTo(e.start.row, e.start.column)) : (this.setSelectionAnchor(e.start.row, e.start.column), this.selectTo(e.end.row, e.end.column)), this.getRange().isEmpty() && (this.$isEmpty = !0), this.$desiredColumn = null
}, this.$moveSelection = function (e) {
var t = this.lead;
this.$isEmpty && this.setSelectionAnchor(t.row, t.column), e.call(this)
}, this.selectTo = function (e, t) {
this.$moveSelection(function () {
this.moveCursorTo(e, t)
})
}, this.selectToPosition = function (e) {
this.$moveSelection(function () {
this.moveCursorToPosition(e)
})
}, this.selectUp = function () {
this.$moveSelection(this.moveCursorUp)
}, this.selectDown = function () {
this.$moveSelection(this.moveCursorDown)
}, this.selectRight = function () {
this.$moveSelection(this.moveCursorRight)
}, this.selectLeft = function () {
this.$moveSelection(this.moveCursorLeft)
}, this.selectLineStart = function () {
this.$moveSelection(this.moveCursorLineStart)
}, this.selectLineEnd = function () {
this.$moveSelection(this.moveCursorLineEnd)
}, this.selectFileEnd = function () {
this.$moveSelection(this.moveCursorFileEnd)
}, this.selectFileStart = function () {
this.$moveSelection(this.moveCursorFileStart)
}, this.selectWordRight = function () {
this.$moveSelection(this.moveCursorWordRight)
}, this.selectWordLeft = function () {
this.$moveSelection(this.moveCursorWordLeft)
}, this.getWordRange = function (e, t) {
if (typeof t == "undefined") {
var n = e || this.lead;
e = n.row, t = n.column
}
return this.session.getWordRange(e, t)
}, this.selectWord = function () {
this.setSelectionRange(this.getWordRange())
}, this.selectAWord = function () {
var e = this.getCursor(),
t = this.session.getAWordRange(e.row, e.column);
this.setSelectionRange(t)
}, this.getLineRange = function (e, t) {
var n = typeof e == "number" ? e : this.lead.row,
r, i = this.session.getFoldLine(n);
return i ? (n = i.start.row, r = i.end.row) : r = n, t === !0 ? new o(n, 0, r, this.session.getLine(r).length) : new o(n, 0, r + 1, 0)
}, this.selectLine = function () {
this.setSelectionRange(this.getLineRange())
}, this.moveCursorUp = function () {
this.moveCursorBy(-1, 0)
}, this.moveCursorDown = function () {
this.moveCursorBy(1, 0)
}, this.moveCursorLeft = function () {
var e = this.lead.getPosition(),
t;
if (t = this.session.getFoldAt(e.row, e.column, -1)) this.moveCursorTo(t.start.row, t.start.column);
else if (e.column == 0) e.row > 0 && this.moveCursorTo(e.row - 1, this.doc.getLine(e.row - 1).length);
else {
var n = this.session.getTabSize();
this.session.isTabStop(e) && this.doc.getLine(e.row).slice(e.column - n, e.column).split(" ").length - 1 == n ? this.moveCursorBy(0, -n) : this.moveCursorBy(0, -1)
}
}, this.moveCursorRight = function () {
var e = this.lead.getPosition(),
t;
if (t = this.session.getFoldAt(e.row, e.column, 1)) this.moveCursorTo(t.end.row, t.end.column);
else if (this.lead.column == this.doc.getLine(this.lead.row).length) this.lead.row < this.doc.getLength() - 1 && this.moveCursorTo(this.lead.row + 1, 0);
else {
var n = this.session.getTabSize(),
e = this.lead;
this.session.isTabStop(e) && this.doc.getLine(e.row).slice(e.column, e.column + n).split(" ").length - 1 == n ? this.moveCursorBy(0, n) : this.moveCursorBy(0, 1)
}
}, this.moveCursorLineStart = function () {
var e = this.lead.row,
t = this.lead.column,
n = this.session.documentToScreenRow(e, t),
r = this.session.screenToDocumentPosition(n, 0),
i = this.session.getDisplayLine(e, null, r.row, r.column),
s = i.match(/^\s*/);
s[0].length != t && !this.session.$useEmacsStyleLineStart && (r.column += s[0].length), this.moveCursorToPosition(r)
}, this.moveCursorLineEnd = function () {
var e = this.lead,
t = this.session.getDocumentLastRowColumnPosition(e.row, e.column);
if (this.lead.column == t.column) {
var n = this.session.getLine(t.row);
if (t.column == n.length) {
var r = n.search(/\s+$/);
r > 0 && (t.column = r)
}
}
this.moveCursorTo(t.row, t.column)
}, this.moveCursorFileEnd = function () {
var e = this.doc.getLength() - 1,
t = this.doc.getLine(e).length;
this.moveCursorTo(e, t)
}, this.moveCursorFileStart = function () {
this.moveCursorTo(0, 0)
}, this.moveCursorLongWordRight = function () {
var e = this.lead.row,
t = this.lead.column,
n = this.doc.getLine(e),
r = n.substring(t),
i;
this.session.nonTokenRe.lastIndex = 0, this.session.tokenRe.lastIndex = 0;
var s = this.session.getFoldAt(e, t, 1);
if (s) {
this.moveCursorTo(s.end.row, s.end.column);
return
}
if (i = this.session.nonTokenRe.exec(r)) t += this.session.nonTokenRe.lastIndex, this.session.nonTokenRe.lastIndex = 0, r = n.substring(t);
if (t >= n.length) {
this.moveCursorTo(e, n.length), this.moveCursorRight(), e < this.doc.getLength() - 1 && this.moveCursorWordRight();
return
}
if (i = this.session.tokenRe.exec(r)) t += this.session.tokenRe.lastIndex, this.session.tokenRe.lastIndex = 0;
this.moveCursorTo(e, t)
}, this.moveCursorLongWordLeft = function () {
var e = this.lead.row,
t = this.lead.column,
n;
if (n = this.session.getFoldAt(e, t, -1)) {
this.moveCursorTo(n.start.row, n.start.column);
return
}
var r = this.session.getFoldStringAt(e, t, -1);
r == null && (r = this.doc.getLine(e).substring(0, t));
var s = i.stringReverse(r),
o;
this.session.nonTokenRe.lastIndex = 0, this.session.tokenRe.lastIndex = 0;
if (o = this.session.nonTokenRe.exec(s)) t -= this.session.nonTokenRe.lastIndex, s = s.slice(this.session.nonTokenRe.lastIndex), this.session.nonTokenRe.lastIndex = 0;
if (t <= 0) {
this.moveCursorTo(e, 0), this.moveCursorLeft(), e > 0 && this.moveCursorWordLeft();
return
}
if (o = this.session.tokenRe.exec(s)) t -= this.session.tokenRe.lastIndex, this.session.tokenRe.lastIndex = 0;
this.moveCursorTo(e, t)
}, this.$shortWordEndIndex = function (e) {
var t, n = 0,
r, i = /\s/,
s = this.session.tokenRe;
s.lastIndex = 0;
if (t = this.session.tokenRe.exec(e)) n = this.session.tokenRe.lastIndex;
else {
while ((r = e[n]) && i.test(r)) n++;
if (n < 1) {
s.lastIndex = 0;
while ((r = e[n]) && !s.test(r)) {
s.lastIndex = 0, n++;
if (i.test(r)) {
if (n > 2) {
n--;
break
}
while ((r = e[n]) && i.test(r)) n++;
if (n > 2) break
}
}
}
}
return s.lastIndex = 0, n
}, this.moveCursorShortWordRight = function () {
var e = this.lead.row,
t = this.lead.column,
n = this.doc.getLine(e),
r = n.substring(t),
i = this.session.getFoldAt(e, t, 1);
if (i) return this.moveCursorTo(i.end.row, i.end.column);
if (t == n.length) {
var s = this.doc.getLength();
do e++, r = this.doc.getLine(e); while (e < s && /^\s*$/.test(r));
/^\s+/.test(r) || (r = ""), t = 0
}
var o = this.$shortWordEndIndex(r);
this.moveCursorTo(e, t + o)
}, this.moveCursorShortWordLeft = function () {
var e = this.lead.row,
t = this.lead.column,
n;
if (n = this.session.getFoldAt(e, t, -1)) return this.moveCursorTo(n.start.row, n.start.column);
var r = this.session.getLine(e).substring(0, t);
if (t == 0) {
do e--, r = this.doc.getLine(e); while (e > 0 && /^\s*$/.test(r));
t = r.length, /\s+$/.test(r) || (r = "")
}
var s = i.stringReverse(r),
o = this.$shortWordEndIndex(s);
return this.moveCursorTo(e, t - o)
}, this.moveCursorWordRight = function () {
this.session.$selectLongWords ? this.moveCursorLongWordRight() : this.moveCursorShortWordRight()
}, this.moveCursorWordLeft = function () {
this.session.$selectLongWords ? this.moveCursorLongWordLeft() : this.moveCursorShortWordLeft()
}, this.moveCursorBy = function (e, t) {
var n = this.session.documentToScreenPosition(this.lead.row, this.lead.column);
t === 0 && (this.$desiredColumn ? n.column = this.$desiredColumn : this.$desiredColumn = n.column);
var r = this.session.screenToDocumentPosition(n.row + e, n.column);
this.moveCursorTo(r.row, r.column + t, t === 0)
}, this.moveCursorToPosition = function (e) {
this.moveCursorTo(e.row, e.column)
}, this.moveCursorTo = function (e, t, n) {
var r = this.session.getFoldAt(e, t, 1);
r && (e = r.start.row, t = r.start.column), this.$keepDesiredColumnOnChange = !0, this.lead.setPosition(e, t), this.$keepDesiredColumnOnChange = !1, n || (this.$desiredColumn = null)
}, this.moveCursorToScreen = function (e, t, n) {
var r = this.session.screenToDocumentPosition(e, t);
this.moveCursorTo(r.row, r.column, n)
}, this.detach = function () {
this.lead.detach(), this.anchor.detach(), this.session = this.doc = null
}, this.fromOrientedRange = function (e) {
this.setSelectionRange(e, e.cursor == e.start), this.$desiredColumn = e.desiredColumn || this.$desiredColumn
}, this.toOrientedRange = function (e) {
var t = this.getRange();
return e ? (e.start.column = t.start.column, e.start.row = t.start.row, e.end.column = t.end.column, e.end.row = t.end.row) : e = t, e.cursor = this.isBackwards() ? e.start : e.end, e.desiredColumn = this.$desiredColumn, e
}, this.toJSON = function () {
if (this.rangeCount) var e = this.ranges.map(function (e) {
var t = e.clone();
return t.isBackwards = e.cursor == e.start, t
});
else {
var e = this.getRange();
e.isBackwards = this.isBackwards()
}
return e
}, this.fromJSON = function (e) {
if (e.start == undefined) {
if (this.rangeList) {
this.toSingleRange(e[0]);
for (var t = e.length; t--;) {
var n = o.fromPoints(e[t].start, e[t].end);
e.isBackwards && (n.cursor = n.start), this.addRange(n, !0)
}
return
}
e = e[0]
}
this.rangeList && this.toSingleRange(e), this.setSelectionRange(e, e.isBackwards)
}, this.isEqual = function (e) {
if ((e.length || this.rangeCount) && e.length != this.rangeCount) return !1;
if (!e.length || !this.ranges) return this.getRange().isEqual(e);
for (var t = this.ranges.length; t--;)
if (!this.ranges[t].isEqual(e[t])) return !1;
return !0
}
}).call(u.prototype), t.Selection = u
}), ace.define("ace/range", ["require", "exports", "module"], function (e, t, n) {
var r = function (e, t) {
return e.row - t.row || e.column - t.column
}, i = function (e, t, n, r) {
this.start = {
row: e,
column: t
}, this.end = {
row: n,
column: r
}
};
(function () {
this.isEqual = function (e) {
return this.start.row === e.start.row && this.end.row === e.end.row && this.start.column === e.start.column && this.end.column === e.end.column
}, this.toString = function () {
return "Range: [" + this.start.row + "/" + this.start.column + "] -> [" + this.end.row + "/" + this.end.column + "]"
}, this.contains = function (e, t) {
return this.compare(e, t) == 0
}, this.compareRange = function (e) {
var t, n = e.end,
r = e.start;
return t = this.compare(n.row, n.column), t == 1 ? (t = this.compare(r.row, r.column), t == 1 ? 2 : t == 0 ? 1 : 0) : t == -1 ? -2 : (t = this.compare(r.row, r.column), t == -1 ? -1 : t == 1 ? 42 : 0)
}, this.comparePoint = function (e) {
return this.compare(e.row, e.column)
}, this.containsRange = function (e) {
return this.comparePoint(e.start) == 0 && this.comparePoint(e.end) == 0
}, this.intersects = function (e) {
var t = this.compareRange(e);
return t == -1 || t == 0 || t == 1
}, this.isEnd = function (e, t) {
return this.end.row == e && this.end.column == t
}, this.isStart = function (e, t) {
return this.start.row == e && this.start.column == t
}, this.setStart = function (e, t) {
typeof e == "object" ? (this.start.column = e.column, this.start.row = e.row) : (this.start.row = e, this.start.column = t)
}, this.setEnd = function (e, t) {
typeof e == "object" ? (this.end.column = e.column, this.end.row = e.row) : (this.end.row = e, this.end.column = t)
}, this.inside = function (e, t) {
return this.compare(e, t) == 0 ? this.isEnd(e, t) || this.isStart(e, t) ? !1 : !0 : !1
}, this.insideStart = function (e, t) {
return this.compare(e, t) == 0 ? this.isEnd(e, t) ? !1 : !0 : !1
}, this.insideEnd = function (e, t) {
return this.compare(e, t) == 0 ? this.isStart(e, t) ? !1 : !0 : !1
}, this.compare = function (e, t) {
return !this.isMultiLine() && e === this.start.row ? t < this.start.column ? -1 : t > this.end.column ? 1 : 0 : e < this.start.row ? -1 : e > this.end.row ? 1 : this.start.row === e ? t >= this.start.column ? 0 : -1 : this.end.row === e ? t <= this.end.column ? 0 : 1 : 0
}, this.compareStart = function (e, t) {
return this.start.row == e && this.start.column == t ? -1 : this.compare(e, t)
}, this.compareEnd = function (e, t) {
return this.end.row == e && this.end.column == t ? 1 : this.compare(e, t)
}, this.compareInside = function (e, t) {
return this.end.row == e && this.end.column == t ? 1 : this.start.row == e && this.start.column == t ? -1 : this.compare(e, t)
}, this.clipRows = function (e, t) {
if (this.end.row > t) var n = {
row: t + 1,
column: 0
};
else if (this.end.row < e) var n = {
row: e,
column: 0
};
if (this.start.row > t) var r = {
row: t + 1,
column: 0
};
else if (this.start.row < e) var r = {
row: e,
column: 0
};
return i.fromPoints(r || this.start, n || this.end)
}, this.extend = function (e, t) {
var n = this.compare(e, t);
if (n == 0) return this;
if (n == -1) var r = {
row: e,
column: t
};
else var s = {
row: e,
column: t
};
return i.fromPoints(r || this.start, s || this.end)
}, this.isEmpty = function () {
return this.start.row === this.end.row && this.start.column === this.end.column
}, this.isMultiLine = function () {
return this.start.row !== this.end.row
}, this.clone = function () {
return i.fromPoints(this.start, this.end)
}, this.collapseRows = function () {
return this.end.column == 0 ? new i(this.start.row, 0, Math.max(this.start.row, this.end.row - 1), 0) : new i(this.start.row, 0, this.end.row, 0)
}, this.toScreenRange = function (e) {
var t = e.documentToScreenPosition(this.start),
n = e.documentToScreenPosition(this.end);
return new i(t.row, t.column, n.row, n.column)
}, this.moveBy = function (e, t) {
this.start.row += e, this.start.column += t, this.end.row += e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment