\n\n"
}), e = e.replace(/^(\#{1,6})[ \t]*(.+?)[ \t]*\#*\n+/gm, function(e, t, n) {
var i = t.length;
return "" + a(n) + "\n\n"
})
}
function f(e, t) {
e += "~0";
var n = /^(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm;
return B ? e = e.replace(n, function(e, n, i) {
var r = n,
o = i.search(/[*+-]/g) > -1 ? "ul" : "ol",
a = m(r, o, t);
return a = a.replace(/\s+$/, ""), a = "<" + o + ">" + a + "" + o + ">\n"
}) : (n = /(\n\n|^\n?)(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/g, e = e.replace(n, function(e, t, n, i) {
var r = t,
o = n,
a = i.search(/[*+-]/g) > -1 ? "ul" : "ol",
s = m(o, a);
return s = r + "<" + a + ">\n" + s + "" + a + ">\n"
})), e = e.replace(/~0/, "")
}
function m(e, t, n) {
B++, e = e.replace(/\n{2,}$/, "\n"), e += "~0";
var i = $[t],
r = new RegExp("(^[ \\t]*)(" + i + ")[ \\t]+([^\\r]+?(\\n+))(?=(~0|\\1(" + i + ")[ \\t]+))", "gm"),
s = !1;
return e = e.replace(r, function(e, t, i, r) {
var l = r,
c = /\n\n$/.test(l),
u = c || l.search(/\n{2,}/) > -1;
return u || s ? l = o(I(l), !0) : (l = f(I(l), !0), l = l.replace(/\n$/, ""), n || (l = a(l))), s = c, "
" + l + "
\n"
}), e = e.replace(/~0/g, ""), B--, e
}
function g(e) {
return e += "~0", e = e.replace(/(?:\n\n|^\n?)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g, function(e, t, n) {
var i = t,
r = n;
return i = y(I(i)), i = D(i), i = i.replace(/^\n+/g, ""), i = i.replace(/\n+$/g, ""), i = "
" + i + "\n
", "\n\n" + i + "\n\n" + r
}), e = e.replace(/~0/, "")
}
function v(e) {
return e = e.replace(/(^\n+|\n+$)/g, ""), "\n\n~K" + (O.push(e) - 1) + "K\n\n"
}
function b(e) {
return e = e.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm, function(e, t, n, i) {
var r = i;
return r = r.replace(/^([ \t]*)/g, ""), r = r.replace(/[ \t]*$/g, ""), r = y(r), r = r.replace(/:\/\//g, "~P"), t + "" + r + ""
})
}
function y(e) {
return e = e.replace(/&/g, "&"), e = e.replace(//g, ">"), e = L(e, "*_{}[]\\", !1)
}
function x(e) {
return e = e.replace(/([\W_]|^)(\*\*|__)(?=\S)([^\r]*?\S[\*_]*)\2([\W_]|$)/g, "$1$3$4"), e = e.replace(/([\W_]|^)(\*|_)(?=\S)([^\r\*_]*?\S)\2([\W_]|$)/g, "$1$3$4")
}
function w(e) {
return e = e.replace(/((^[ \t]*>[ \t]?.+\n(.+\n)*\n*)+)/gm, function(e, t) {
var n = t;
return n = n.replace(/^[ \t]*>[ \t]?/gm, "~0"), n = n.replace(/~0/g, ""), n = n.replace(/^[ \t]+$/gm, ""), n = o(n), n = n.replace(/(^|\n)/g, "$1 "), n = n.replace(/(\s*
[^\r]+?<\/pre>)/gm, function(e, t) {
var n = t;
return n = n.replace(/^ /gm, "~0"), n = n.replace(/~0/g, "")
}), v("
\n" + n + "\n
")
})
}
function S(e, t) {
e = e.replace(/^\n+/g, ""), e = e.replace(/\n+$/g, "");
for(var n = e.split(/\n{2,}/g), i = [], r = /~K(\d+)K/, o = n.length, s = 0; o > s; s++) {
var l = n[s];
r.test(l) ? i.push(l) : /\S/.test(l) && (l = a(l), l = l.replace(/^([ \t]*)/g, "
"), l += "
", i.push(l))
}
if(!t) {
o = i.length;
for(var s = 0; o > s; s++)
for(var c = !0; c;) c = !1, i[s] = i[s].replace(/~K(\d+)K/g, function(e, t) {
return c = !0, O[t]
})
}
return i.join("\n\n")
}
function C(e) {
return e = e.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g, "&"), e = e.replace(/<(?![a-z\/?!]|~D)/gi, "<")
}
function _(e) {
return e = e.replace(/\\(\\)/g, M), e = e.replace(/\\([`*_{}\[\]()>#+-.!])/g, M)
}
function k(e, t, n, i) {
if(t) return e;
if(")" !== i.charAt(i.length - 1)) return "<" + n + i + ">";
for(var r = i.match(/[()]/g), o = 0, a = 0; a < r.length; a++) "(" === r[a] ? 0 >= o ? o = 1 : o++ : o--;
var s = "";
if(0 > o) {
var l = new RegExp("\\){1," + -o + "}$");
i = i.replace(l, function(e) {
return s = e, ""
})
}
if(s) {
var c = i.charAt(i.length - 1);
U.test(c) || (s = c + s, i = i.substr(0, i.length - 1))
}
return "<" + n + i + ">" + s
}
function T(e) {
e = e.replace(H, k);
var t = function(e, t) {
return '' + R.plainLinkText(t) + ""
};
return e = e.replace(/<((https?|ftp):[^'">\s]+)>/gi, t)
}
function E(e) {
return e = e.replace(/~E(\d+)E/g, function(e, t) {
var n = parseInt(t);
return String.fromCharCode(n)
})
}
function I(e) {
return e = e.replace(/^(\t|[ ]{1,4})/gm, "~0"), e = e.replace(/~0/g, "")
}
function D(e) {
if(!/\t/.test(e)) return e;
var t, n = [" ", " ", " ", " "],
i = 0;
return e.replace(/[\n\t]/g, function(e, r) {
return "\n" === e ? (i = r + 1, e) : (t = (r - i) % 4, i = r + 1, n[t])
})
}
function N(e) {
if(!e) return "";
e.length;
return e.replace(z, function(e) {
return "~D" == e ? "%24" : ":" == e ? ":" : "%" + e.charCodeAt(0).toString(16)
})
}
function L(e, t, n) {
var i = "([" + t.replace(/([\[\]\\])/g, "\\$1") + "])";
n && (i = "\\\\" + i);
var r = new RegExp(i, "g");
return e = e.replace(r, M)
}
function M(e, t) {
var n = t.charCodeAt(0);
return "~E" + n + "E"
}
var A = {};
this.setOptions = function(e) {
A = e
};
var R = this.hooks = new n;
R.addNoop("plainLinkText"), R.addNoop("preConversion"), R.addNoop("postNormalization"), R.addNoop("preBlockGamut"), R.addNoop("postBlockGamut"), R.addNoop("preSpanGamut"), R.addNoop("postSpanGamut"), R.addNoop("postConversion");
var P, F, O, B;
this.makeHtml = function(n) {
if(P) throw new Error("Recursive call to converter.makeHtml");
return P = new i, F = new i, O = [], B = 0, n = R.preConversion(n), n = n.replace(/~/g, "~T"), n = n.replace(/\$/g, "~D"), n = n.replace(/\r\n/g, "\n"), n = n.replace(/\r/g, "\n"), n = "\n\n" + n + "\n\n", n = D(n), n = n.replace(/^[ \t]+$/gm, ""), n = R.postNormalization(n), n = t(n), n = e(n), n = o(n), n = E(n), n = n.replace(/~D/g, "$$"), n = n.replace(/~T/g, "~"), n = R.postConversion(n), O = F = P = null, n
};
var j = function(e) {
return o(e)
}, $ = {
ol: "\\d+[.]",
ul: "[*+-]"
}, q = "[-A-Z0-9+&@#/%?=~_|[\\]()!:,.;]",
G = "[-A-Z0-9+&@#/%=~_|[\\])]",
H = new RegExp('(="|<)?\\b(https?|ftp)(://' + q + "*" + G + ")(?=$|\\W)", "gi"),
U = new RegExp(G, "i"),
z = /(?:["'*()[\]:]|~D)/g
}
}(), define("libs/Markdown.Converter", function() {}), function() {
function e(e) {
return e.replace(/^\s+|\s+$/g, "")
}
function t(e) {
return e.replace(/\s+$/g, "")
}
function n(e) {
return e.replace(new RegExp("^(\\t|[ ]{1,4})", "gm"), "")
}
function i(e, t) {
return -1 != e.indexOf(t)
}
function r(e, t) {
return e.replace(/<[^>]*>?/gi, function(e) {
return e.match(t) ? e : ""
})
}
function o(e, t) {
for(var n = {}, i = 0; i < e.length; i++) n[e[i]] = e[i];
for(i = 0; i < t.length; i++) n[t[i]] = t[i];
var r = [];
for(var o in n) n.hasOwnProperty(o) && r.push(n[o]);
return r
}
function a(e) {
return "" != e.charAt(0) && (e = "" + e), "" != e.charAt(e.length - 1) && (e += ""), e
}
function s(e) {
return "" == e.charAt(0) && (e = e.substr(1)), "" == e.charAt(e.length - 1) && (e = e.substr(0, e.length - 1)), e
}
function l(e, t) {
return r(c(e, t), m)
}
function c(e, t) {
var n = t.blockGamutHookCallback(e);
return n = p(n), n = n.replace(/~D/g, "$$").replace(/~T/g, "~"), n = t.previousPostConversion(n)
}
function u(e) {
return e.replace(/\\\|/g, "~I").replace(/\\:/g, "~i")
}
function d(e) {
return e.replace(/~I/g, "|").replace(/~i/g, ":")
}
function p(e) {
return e = e.replace(/~E(\d+)E/g, function(e, t) {
var n = parseInt(t);
return String.fromCharCode(n)
})
}
function h(e) {
return e.toLowerCase().replace(/\s+/g, "-").replace(/[^\w\-]+/g, "").replace(/\-\-+/g, "-").replace(/^-+/, "").replace(/-+$/, "")
}
function f(e, t) {
var n = t;
return n = n.replace(/&\#8220;/g, '"'), n = n.replace(/&\#8221;/g, '"'), n = n.replace(/&\#8216;/g, "'"), n = n.replace(/&\#8217;/g, "'"), n = n.replace(/&\#8212;/g, "---"), n = n.replace(/&\#8211;/g, "--"), n = n.replace(/&\#8230;/g, "...")
}
var m = new RegExp(["^(<\\/?(a|abbr|acronym|applet|area|b|basefont|", "bdo|big|button|cite|code|del|dfn|em|figcaption|", "font|i|iframe|img|input|ins|kbd|label|map|", "mark|meter|object|param|progress|q|ruby|rp|rt|s|", "samp|script|select|small|span|strike|strong|", "sub|sup|textarea|time|tt|u|var|wbr)[^>]*>|", "<(br)\\s?\\/?>)$"].join(""), "i");
Array.indexOf || (Array.prototype.indexOf = function(e) {
for(var t = 0; t < this.length; t++)
if(this[t] == e) return t;
return -1
}), Markdown.Extra = function() {
this.converter = null, this.hashBlocks = [], this.footnotes = {}, this.usedFootnotes = [], this.attributeBlocks = !1, this.googleCodePrettify = !1, this.highlightJs = !1, this.tableClass = "", this.tabWidth = 4
}, Markdown.Extra.init = function(e, t) {
var n = new Markdown.Extra,
r = [],
o = [],
a = [],
s = ["unHashExtraBlocks"];
return t = t || {}, t.extensions = t.extensions || ["all"], i(t.extensions, "all") && (t.extensions = ["tables", "fenced_code_gfm", "def_list", "attr_list", "footnotes", "smartypants", "strikethrough", "newlines"]), o.push("wrapHeaders"), i(t.extensions, "attr_list") && (r.push("hashFcbAttributeBlocks"), o.push("hashHeaderAttributeBlocks"), s.push("applyAttributeBlocks"), n.attributeBlocks = !0), i(t.extensions, "fenced_code_gfm") && (o.push("fencedCodeBlocks"), r.push("fencedCodeBlocks")), i(t.extensions, "tables") && o.push("tables"), i(t.extensions, "def_list") && o.push("definitionLists"), i(t.extensions, "footnotes") && (r.push("stripFootnoteDefinitions"), o.push("doFootnotes"), s.push("printFootnotes")), i(t.extensions, "smartypants") && s.push("runSmartyPants"), i(t.extensions, "strikethrough") && a.push("strikethrough"), i(t.extensions, "newlines") && a.push("newlines"), e.hooks.chain("postNormalization", function(e) {
return n.doTransform(r, e) + "\n"
}), e.hooks.chain("preBlockGamut", function(e, t) {
return n.blockGamutHookCallback = t, e = u(e), e = n.doTransform(o, e) + "\n", e = d(e)
}), e.hooks.chain("postSpanGamut", function(e) {
return n.doTransform(a, e)
}), n.previousPostConversion = e.hooks.postConversion, e.hooks.chain("postConversion", function(e) {
return e = n.doTransform(s, e), n.hashBlocks = [], n.footnotes = {}, n.usedFootnotes = [], e
}), "highlighter" in t && (n.googleCodePrettify = "prettify" === t.highlighter, n.highlightJs = "highlight" === t.highlighter), "table_class" in t && (n.tableClass = t.table_class), n.converter = e, n
}, Markdown.Extra.prototype.doTransform = function(e, t) {
for(var n = 0; n < e.length; n++) t = this[e[n]](t);
return t
}, Markdown.Extra.prototype.hashExtraBlock = function(e) {
return "\n
~X" + (this.hashBlocks.push(e) - 1) + "X
\n"
}, Markdown.Extra.prototype.hashExtraInline = function(e) {
return "~X" + (this.hashBlocks.push(e) - 1) + "X"
}, Markdown.Extra.prototype.unHashExtraBlocks = function(e) {
function t() {
var i = !1;
e = e.replace(/(?:
)?~X(\d+)X(?:<\/p>)?/g, function(e, t) {
i = !0;
var r = parseInt(t, 10);
return n.hashBlocks[r]
}), i === !0 && t()
}
var n = this;
return t(), e
}, Markdown.Extra.prototype.wrapHeaders = function(e) {
function t(e) {
return "\n" + e + "\n"
}
return e = e.replace(/^.+[ \t]*\n=+[ \t]*\n+/gm, t), e = e.replace(/^.+[ \t]*\n-+[ \t]*\n+/gm, t), e = e.replace(/^\#{1,6}[ \t]*.+?[ \t]*\#*\n+/gm, t)
};
var g = "\\{[ \\t]*((?:[#.][-_:a-zA-Z0-9]+[ \\t]*)+)\\}",
v = new RegExp("^(#{1,6}.*#{0,6})[ \\t]+" + g + "[ \\t]*(?:\\n|0x03)", "gm"),
b = new RegExp("^(.*)[ \\t]+" + g + "[ \\t]*\\n(?=[\\-|=]+\\s*(?:\\n|0x03))", "gm"),
y = new RegExp("^(```[ \\t]*[^{\\s]*)[ \\t]+" + g + "[ \\t]*\\n(?=([\\s\\S]*?)\\n```[ \\t]*(\\n|0x03))", "gm");
Markdown.Extra.prototype.hashHeaderAttributeBlocks = function(e) {
function t(e, t, i) {
return "
~XX" + (n.hashBlocks.push(i) - 1) + "XX
\n" + t + "\n"
}
var n = this;
return e = e.replace(v, t), e = e.replace(b, t)
}, Markdown.Extra.prototype.hashFcbAttributeBlocks = function(e) {
function t(e, t, i) {
return "
~XX" + (n.hashBlocks.push(i) - 1) + "XX
\n" + t + "\n"
}
var n = this;
return e.replace(y, t)
}, Markdown.Extra.prototype.applyAttributeBlocks = function(e) {
var t = this,
n = new RegExp('
~XX(\\d+)XX
[\\s]*(?:<(h[1-6]|pre)(?: +class="(\\S+)")?(>[\\s\\S]*?\\2>))', "gm");
return e = e.replace(n, function(e, n, i, r, a) {
if(!i) return "";
for(var s = parseInt(n, 10), l = t.hashBlocks[s], c = l.match(/#[^\s#.]+/g) || [], u = c[0] ? ' id="' + c[0].substr(1, c[0].length - 1) + '"' : "", d = l.match(/\.[^\s#.]+/g) || [], p = 0; p < d.length; p++) d[p] = d[p].substr(1, d[p].length - 1);
var h = "";
return r && (d = o(d, [r])), d.length > 0 && (h = ' class="' + d.join(" ") + '"'), "<" + i + u + h + a
})
}, Markdown.Extra.prototype.tables = function(t) {
function n(t, n, r, o) {
n = n.replace(/^ *[|]/m, ""), r = r.replace(/^ *[|]/m, ""), o = o.replace(/^ *[|]/gm, ""), n = n.replace(/[|] *$/m, ""), r = r.replace(/[|] *$/m, ""), o = o.replace(/[|] *$/gm, ""), alignspecs = r.split(/ *[|] */), align = [];
for(var a = 0; a < alignspecs.length; a++) {
var s = alignspecs[a];
align[a] = s.match(/^ *-+: *$/m) ? ' style="text-align:right;"' : s.match(/^ *:-+: *$/m) ? ' style="text-align:center;"' : s.match(/^ *:-+ *$/m) ? ' style="text-align:left;"' : ""
}
var c = n.split(/ *[|] */),
u = c.length,
d = i.tableClass ? ' class="' + i.tableClass + '"' : "",
p = ["
\n", "\n", "
\n"].join("");
for(a = 0; u > a; a++) {
var h = l(e(c[a]), i);
p += ["
", h, "
\n"].join("")
}
p += "
\n\n";
var f = o.split("\n");
for(a = 0; a < f.length; a++)
if(!f[a].match(/^\s*$/)) {
for(var m = f[a].split(/ *[|] */), g = u - m.length, v = 0; g > v; v++) m.push("");
for(p += "
\n", v = 0; u > v; v++) {
var b = l(e(m[v]), i);
p += ["
", b, "
\n"].join("")
}
p += "
\n"
}
return p += "
\n", i.hashExtraBlock(p)
}
var i = this,
r = new RegExp(["^", "[ ]{0,3}", "[|]", "(.+)\\n", "[ ]{0,3}", "[|]([ ]*[-:]+[-| :]*)\\n", "(", "(?:[ ]*[|].*\\n?)*", ")", "(?:\\n|$)"].join(""), "gm"),
o = new RegExp(["^", "[ ]{0,3}", "(\\S.*[|].*)\\n", "[ ]{0,3}", "([-:]+[ ]*[|][-| :]*)\\n", "(", "(?:.*[|].*\\n?)*", ")", "(?:\\n|$)"].join(""), "gm");
return t = t.replace(r, n), t = t.replace(o, n)
}, Markdown.Extra.prototype.stripFootnoteDefinitions = function(e) {
var t = this;
return e = e.replace(/\n[ ]{0,3}\[\^(.+?)\]\:[ \t]*\n?([\s\S]*?)\n{1,2}((?=\n[ ]{0,3}\S)|$)/g, function(e, n, i) {
return n = h(n), i += "\n", i = i.replace(/^[ ]{0,3}/g, ""), t.footnotes[n] = i, "\n"
})
}, Markdown.Extra.prototype.doFootnotes = function(e) {
var t = this;
if(t.isConvertingFootnote === !0) return e;
var n = 0;
return e = e.replace(/\[\^(.+?)\]/g, function(e, i) {
var r = h(i),
o = t.footnotes[r];
if(void 0 === o) return e;
n++, t.usedFootnotes.push(r);
var a = '' + n + "";
return t.hashExtraInline(a)
})
}, Markdown.Extra.prototype.printFootnotes = function(e) {
var t = this;
if(0 === t.usedFootnotes.length) return e;
e += '\n\n
\n\n\n\n';
for(var n = 0; n < t.usedFootnotes.length; n++) {
var i = t.usedFootnotes[n],
r = t.footnotes[i];
t.isConvertingFootnote = !0;
var o = l(r, t);
delete t.isConvertingFootnote, e += '
"
}, Markdown.Extra.prototype.fencedCodeBlocks = function(e) {
function t(e) {
return e = e.replace(/&/g, "&"), e = e.replace(//g, ">"), e = e.replace(/~D/g, "$$"), e = e.replace(/~T/g, "~")
}
var n = this;
return e = e.replace(/(?:^|\n)```[ \t]*(\S*)[ \t]*\n([\s\S]*?)\n```[ \t]*(?=\n)/g, function(e, i, r) {
var o = i,
a = r,
s = n.googleCodePrettify ? ' class="prettyprint"' : "",
l = "";
o && (l = n.googleCodePrettify || n.highlightJs ? ' class="language-' + o + '"' : ' class="' + o + '"');
var c = ["
", t(a), "
"].join("");
return n.hashExtraBlock(c)
})
}, Markdown.Extra.prototype.educatePants = function(e) {
var t = this,
n = "",
i = 0;
e.replace(/(?:)|(<)([a-zA-Z1-6]+)([^\n]*?>)([\s\S]*?)(<\/\2>)/g, function(r, o, a, s, l, c, u) {
var d = e.substring(i, u);
return n += t.applyPants(d), t.smartyPantsLastChar = n.substring(n.length - 1), i = u + r.length, o ? (/code|kbd|pre|script|noscript|iframe|math|ins|del|pre/i.test(a) ? t.smartyPantsLastChar = l.substring(l.length - 1) : l = t.educatePants(l), void(n += o + a + s + l + c)) : void(n += r)
});
var r = e.substring(i);
return n += t.applyPants(r), t.smartyPantsLastChar = n.substring(n.length - 1), n
}, Markdown.Extra.prototype.applyPants = function(e) {
return e = e.replace(/---/g, "—").replace(/--/g, "–"), e = e.replace(/\.\.\./g, "…").replace(/\.\s\.\s\./g, "…"), e = e.replace(/``/g, "“").replace(/''/g, "”"), /^'$/.test(e) ? /\S/.test(this.smartyPantsLastChar) ? "’" : "‘" : /^"$/.test(e) ? /\S/.test(this.smartyPantsLastChar) ? "”" : "“" : (e = e.replace(/^'(?=[!"#\$\%'()*+,\-.\/:;<=>?\@\[\\]\^_`{|}~]\B)/, "’"), e = e.replace(/^"(?=[!"#\$\%'()*+,\-.\/:;<=>?\@\[\\]\^_`{|}~]\B)/, "”"), e = e.replace(/"'(?=\w)/g, "“‘"), e = e.replace(/'"(?=\w)/g, "‘“"), e = e.replace(/'(?=\d{2}s)/g, "’"), e = e.replace(/(\s| |--|&[mn]dash;|&\#8211;|&\#8212;|&\#x201[34];)'(?=\w)/g, "$1‘"), e = e.replace(/([^\s\[\{\(\-])'/g, "$1’"), e = e.replace(/'(?=\s|s\b)/g, "’"), e = e.replace(/'/g, "‘"), e = e.replace(/(\s| |--|&[mn]dash;|&\#8211;|&\#8212;|&\#x201[34];)"(?=\w)/g, "$1“"), e = e.replace(/([^\s\[\{\(\-])"/g, "$1”"), e = e.replace(/"(?=\s)/g, "”"), e = e.replace(/"/gi, "“"))
}, Markdown.Extra.prototype.runSmartyPants = function(e) {
return this.smartyPantsLastChar = "", e = this.educatePants(e), e = e.replace(/(<([a-zA-Z1-6]+)\b([^\n>]*?)(\/)?>)/g, f)
}, Markdown.Extra.prototype.definitionLists = function(t) {
var n = new RegExp(["(\\x02\\n?|\\n\\n)", "(?:", "(", "(", "[ ]{0,3}", "((?:[ \\t]*\\S.*\\n)+)", "\\n?", "[ ]{0,3}:[ ]+", ")", "([\\s\\S]+?)", "(", "(?=\\0x03)", "|", "(?=", "\\n{2,}", "(?=\\S)", "(?!", "[ ]{0,3}", "(?:\\S.*\\n)+?", "\\n?", "[ ]{0,3}:[ ]+", ")", "(?!", "[ ]{0,3}:[ ]+", ")", ")", ")", ")", ")"].join(""), "gm"),
i = this;
return t = a(t), t = t.replace(n, function(t, n, r) {
var o = e(i.processDefListItems(r));
return o = "
\n" + o + "\n
", n + i.hashExtraBlock(o) + "\n\n"
}), s(t)
}, Markdown.Extra.prototype.processDefListItems = function(i) {
var r = this,
o = new RegExp(["(\\x02\\n?|\\n\\n+)", "(", "[ ]{0,3}", "(?![:][ ]|[ ])", "(?:\\S.*\\n)+?", ")", "(?=\\n?[ ]{0,3}:[ ])"].join(""), "gm"),
u = new RegExp(["\\n(\\n+)?", "(", "[ ]{0,3}", "[:][ ]+", ")", "([\\s\\S]+?)", "(?=\\n*", "(?:", "\\n[ ]{0,3}[:][ ]|", "
|\\x03", ")", ")"].join(""), "gm");
return i = a(i), i = i.replace(/\n{2,}(?=\\x03)/, "\n"), i = i.replace(o, function(t, n, i) {
for(var o = e(i).split("\n"), a = "", s = 0; s < o.length; s++) {
var c = o[s];
c = l(e(c), r), a += "\n
" + c + "
"
}
return a + "\n"
}), i = i.replace(u, function(e, i, o, a) {
return i || a.match(/\n{2,}/) ? (a = Array(o.length + 1).join(" ") + a, a = n(a) + "\n\n", a = "\n" + c(a, r) + "\n") : (a = t(a), a = l(n(a), r)), "\n
Allows StackEdit to interpret LaTeX mathematical expressions.
\n
\n
\n \n
\n \n
\n
\n
\n \n
\n \n
\n
\n
\nMore info'
}), define("text!libs/mathjax_config.js", [], function() {
return 'MathJax.Hub.Config({\n skipStartupTypeset: true,\n "HTML-CSS": {\n preferredFont: "TeX",\n availableFonts: [\n "STIX",\n "TeX"\n ],\n linebreaks: {\n automatic: true\n },\n EqnChunk: 10,\n imageFont: null\n },\n tex2jax: <%= tex2jax || \'{ inlineMath: [["$","$"],["\\\\\\\\\\\\\\\\(","\\\\\\\\\\\\\\\\)"]], displayMath: [["$$","$$"],["\\\\\\\\[","\\\\\\\\]"]], processEscapes: true }\' %>,\n TeX: $.extend({\n noUndefined: {\n attributes: {\n mathcolor: "red",\n mathbackground: "#FFEEEE",\n mathsize: "90%"\n }\n },\n Safe: {\n allow: {\n URLs: "safe",\n classes: "safe",\n cssIDs: "safe",\n styles: "safe",\n fontsize: "all"\n }\n }\n }, <%= tex %>),\n messageStyle: "none"\n});\n'
}), define("libs/mathjax_init", ["settings", "text!libs/mathjax_config.js"], function(e, t) {
var n = document.createElement("script");
n.type = "text/x-mathjax-config", n.innerHTML = _.template(t, {
tex: e.extensionSettings.mathJax ? e.extensionSettings.mathJax.tex : "undefined",
tex2jax: e.extensionSettings.mathJax ? e.extensionSettings.mathJax.tex2jax : void 0
}), document.getElementsByTagName("head")[0].appendChild(n)
}), define("extensions/mathJax", ["utils", "classes/Extension", "text!html/mathJaxSettingsBlock.html", "mathjax"], function(e, t, n) {
function i(e, t, n) {
var i = u.slice(e, t + 1).join("").replace(/&/g, "&").replace(//g, ">");
for(x.Browser.isMSIE && (i = i.replace(/(%[^\n]*)\n/g, "$1 \n")); t > e;) u[t] = "", t--;
u[e] = "@@" + m.length + "@@", n && (i = n(i)), m.push(i), d = p = h = null
}
function r(e) {
d = p = h = null, m = [];
var t;
/`/.test(e) ? (e = e.replace(/~/g, "~T").replace(/(^|[^\\])(`+)([^\n]*?[^`\n])\2(?!`)/gm, function(e) {
return e.replace(/\$/g, "~D")
}), t = function(e) {
return e.replace(/~([TD])/g, function(e, t) {
return {
T: "~",
D: "$"
}[t]
})
}) : t = function(e) {
return e
}, u = w(e.replace(/\r\n?/g, "\n"), S);
for(var n = 1, r = u.length; r > n; n += 2) {
var o = u[n];
"@" === o.charAt(0) ? (u[n] = "@@" + m.length + "@@", m.push(o)) : d ? p == y && "\n" == o.charAt(0) ? (h && (n = h, i(d, n, t)), d = p = h = null, f = 0) : o === p ? f ? h = n : i(d, n, t) : o.match(/\n.*\n/) ? (h && (n = h, i(d, n, t)), d = p = h = null, f = 0) : "{" === o ? f++ : "}" === o && f && f-- : o === y || "$$" === o ? (d = n, p = o, f = 0) : "begin" === o.substr(1, 5) && (d = n, p = "\\end" + o.substr(6), f = 0)
}
return h && i(d, h, t), t(u.join(""))
}
function o(e) {
return e = e.replace(/@@(\d+)@@/g, function(e, t) {
return m[t]
}), m = null, e
}
function a() {
v = !1, x.cancelTypeset = !1, x.Queue(["Typeset", x, b]), x.Queue(c)
}
function s() {
v || (v = !0, x.Cancel(), x.Queue(a))
}
var l = new t("mathJax", "MathJax", !0);
l.settingsBlock = n, l.defaultConfig = {
tex: "{}",
tex2jax: '{ inlineMath: [["$","$"],["\\\\\\\\(","\\\\\\\\)"]], displayMath: [["$$","$$"],["\\\\[","\\\\]"]], processEscapes: true }'
}, l.onLoadSettings = function() {
e.setInputValue("#input-mathjax-config-tex", l.config.tex), e.setInputValue("#input-mathjax-config-tex2jax", l.config.tex2jax)
}, l.onSaveSettings = function(t, n) {
t.tex = e.getInputJsValue("#input-mathjax-config-tex", n), t.tex2jax = e.getInputJsValue("#input-mathjax-config-tex2jax", n)
}, l.onPagedownConfigure = function(e) {
b = document.getElementById("preview-contents");
var t = e.getConverter();
t.hooks.chain("preConversion", r), t.hooks.chain("postConversion", o)
};
var c;
l.onAsyncPreview = function(e) {
c = e, s()
};
var u, d, p, h, f, m, g = !1,
v = !1,
b = null,
y = "$",
x = MathJax.Hub;
x.Queue(function() {
g = !0, x.processUpdateTime = 50, x.Config({
"HTML-CSS": {
EqnChunk: 10,
EqnChunkFactor: 1
},
SVG: {
EqnChunk: 10,
EqnChunkFactor: 1
}
})
});
var w, S = /(\$\$?|\\(?:begin|end)\{[a-z]*\*?\}|\\[\\{}$]|[{}]|(?:\n\s*)+|@@\d+@@)/i;
return w = 3 === "aba".split(/(b)/).length ? function(e, t) {
return e.split(t)
} : function(e, t) {
var n, i = [];
if(!t.global) {
n = t.toString();
var r = "";
n = n.replace(/^\/(.*)\/([im]*)$/, function(e, t, n) {
return r = n, t
}), t = RegExp(n, r + "g")
}
for(var o = t.lastIndex = 0; n = t.exec(e);) i.push(e.substring(o, n.index)), i.push.apply(i, n.slice(1)), o = n.index + n[0].length;
return i.push(e.substring(o)), i
},
function() {
var e = MathJax.Hub;
if(!e.Cancel) {
e.cancelTypeset = !1, e.Register.StartupHook("HTML-CSS Jax Config", function() {
var t = MathJax.OutputJax["HTML-CSS"],
n = t.Translate;
t.Augment({
Translate: function(i, r) {
if(e.cancelTypeset || r.cancelled) throw Error("MathJax Canceled");
return n.call(t, i, r)
}
})
}), e.Register.StartupHook("SVG Jax Config", function() {
var t = MathJax.OutputJax.SVG,
n = t.Translate;
t.Augment({
Translate: function(i, r) {
if(e.cancelTypeset || r.cancelled) throw Error("MathJax Canceled");
return n.call(t, i, r)
}
})
}), e.Register.StartupHook("TeX Jax Config", function() {
var t = MathJax.InputJax.TeX,
n = t.Translate;
t.Augment({
Translate: function(i, r) {
if(e.cancelTypeset || r.cancelled) throw Error("MathJax Canceled");
return n.call(t, i, r)
}
})
});
var t = e.processError;
e.processError = function(n, i, r) {
return "MathJax Canceled" !== n.message ? t.call(e, n, i, r) : (MathJax.Message.Clear(0, 0), i.jaxIDs = [], i.jax = {}, i.scripts = [], i.i = i.j = 0, i.cancelled = !0, null)
}, e.Cancel = function() {
this.cancelTypeset = !0
}
}
}(), l
}), define("text!html/partialRenderingSettingsBlock.html", [], function() {
return "
Renders modified sections only.
\n
\n Note: Document sections are based on title elements (h1, h2...). Therefore if\n your document does not contain any title, performance will not be increased.\n
"
}), define("extensions/partialRendering", ["underscore", "crel", "extensions/markdownExtra", "classes/Extension", "text!html/partialRenderingSettingsBlock.html"], function(e, t, n, i, r) {
function o() {
var t = [],
n = "\n";
if(m = !1, e.each(g, function(e) {
var i = '\n\n\n' + e.text + "\n\n";
f && (i = i.replace(/^```.*\n[\s\S]*?\n```|\n[ ]{0,3}\[\^(.+?)\]\:[ \t]*\n?([\s\S]*?)\n{1,2}((?=\n[ ]{0,3}\S)|$)/gm, function(e, t) {
return t ? (m = !0, n += e.replace(/^\s*\n/gm, "") + "\n", "") : e
})), i = i.replace(/^```.*\n[\s\S]*?\n```|^[ ]{0,3}\[(.+)\]:[ \t]*\n?[ \t]*(\S+?)>?(?=\s|$)[ \t]*\n?[ \t]*((\n*)["(](.+?)[")][ \t]*)?(?:\n+)/gm, function(e, t) {
return t ? (n += e.replace(/^\s*\n/gm, "") + "\n", "") : e
}), t.push({
id: e.id,
text: i + "\n"
})
}), y = [], b = [], d = void 0, x === !0 || u != n) return x = !1, u = n, b = v, v = t, void(y = t);
var i = v.length;
e.some(v, function(e, n) {
return n >= t.length || e.text != t[n].text ? (i = n, !0) : void 0
});
var r = -v.length;
e.some(v.slice().reverse(), function(e, n) {
return n >= t.length || e.text != t[t.length - n - 1].text ? (r = -n, !0) : void 0
}), i - r > v.length && (r = i - v.length);
var o = v.slice(0, i);
y = t.slice(i, t.length + r);
var a = v.slice(v.length + r, v.length);
d = e.first(a), b = v.slice(i, v.length + r), v = o.concat(y).concat(a)
}
function a(e) {
var t = e.id.substring(3);
w[t] = e
}
function s() {
function n(n) {
for(var i = t("div", {
id: "wmd-preview-section-" + n.id,
"class": "wmd-preview-section preview-content"
}), o = !1; r;) {
var s = r.nextSibling,
l = "se-preview-section-delimiter" == r.className;
if(o === !0 && "DIV" == r.tagName && l) break;
o = !0, "DIV" == r.tagName && "footnotes" == r.className ? e.each(r.querySelectorAll("ol > li"), a) : l || i.appendChild(r), r = s
}
return i
}
e.each(b, function(e) {
var t = document.getElementById("wmd-preview-section-" + e.id);
h.removeChild(t)
});
var i = document.getElementById("wmd-preview"),
r = i.firstChild,
o = document.createDocumentFragment();
e.each(y, function(e) {
o.appendChild(n(e))
}), i.innerHTML = "";
var s = p;
void 0 !== d && (s = document.getElementById("wmd-preview-section-" + d.id)), h.insertBefore(o, s), p.innerHTML = "";
var l = [];
if(m === !0) {
var c = t("ol");
e.each(h.querySelectorAll("a.footnote"), function(e, t) {
e.textContent = t + 1;
var n = e.id.substring(6);
l.push(n);
var i = w[n];
i && c.appendChild(i.cloneNode(!0))
}), l.length > 0 && p.appendChild(t("div", {
"class": "footnotes"
}, t("hr"), c)), w = e.pick(w, l)
}
}
var l = new i("partialRendering", "Partial Rendering", !0);
l.settingsBlock = r;
var c, u, d, p, h, f = !1,
m = !1,
g = [],
v = [],
b = [],
y = [],
x = !1,
w = {};
return l.onSectionsCreated = function(e) {
g = e
}, l.onPagedownConfigure = function(t) {
c = t.getConverter(), c.hooks.chain("preConversion", function() {
o();
var t = e.map(y, function(e) {
return e.text
});
return t.push(u + "\n\n"), t.join("")
}), t.hooks.chain("onPreviewRefresh", function() {
s()
})
}, l.onInit = function() {
n.enabled && e.some(n.config.extensions, function(e) {
return "footnotes" == e
}) && (f = !0)
}, l.onReady = function() {
p = t("div", {
id: "wmd-preview-section-footnotes",
"class": "preview-content"
}), h = document.getElementById("preview-contents"), h.appendChild(p)
}, l.onFileSelected = function() {
x = !0
}, l
}), define("extensions/markdownSectionParser", ["underscore", "extensions/markdownExtra", "extensions/mathJax", "extensions/partialRendering", "classes/Extension", "crel"], function(e, t, n, i, r, o) {
function a(e, t) {
function n(e, t) {
var n = o.substring(a, t);
u.push({
id: ++h,
text: n,
textWithFrontMatter: i + n
}), i = ""
}
if(e === p) {
var i = (p.frontMatter || {})._frontMatter || "",
r = t.substring(i.length),
o = r + "\n\n";
u = [];
var a = 0;
o.replace(d, function(e, t) {
n(a, t), a = t
}), n(a, r.length), s.onSectionsCreated(u)
}
}
var s, l = new r("markdownSectionParser", "Markdown section parser");
l.onEventMgrCreated = function(e) {
s = e
};
var c, u = [],
d = "^.+[ \\t]*\\n=+[ \\t]*\\n+|^.+[ \\t]*\\n-+[ \\t]*\\n+|^\\#{1,6}[ \\t]*.+?[ \\t]*\\#*\\n+";
l.onPagedownConfigure = function(r) {
t.enabled && e.some(t.config.extensions, function(e) {
return "fenced_code_gfm" == e
}) && (d = "^```.*\\n[\\s\\S]*?\\n```|" + d), n.enabled && (d = "^[ \\t]*\\n\\$\\$[\\s\\S]*?\\$\\$|" + d, d = "^[ \\t]*\\n\\\\\\\\[[\\s\\S]*?\\\\\\\\]|" + d, d = "^[ \\t]*\\n\\\\?\\\\begin\\{[a-z]*\\*?\\}[\\s\\S]*?\\\\end\\{[a-z]*\\*?\\}|" + d), d = new RegExp(d, "gm");
var a = r.getConverter();
i.enabled || (a.hooks.chain("preConversion", function() {
return e.reduce(u, function(e, t) {
return e + '\n\n\n' + t.text + "\n\n"
}, "")
}), r.hooks.chain("onPreviewRefresh", function() {
function e() {
for(var e = o("div", {
"class": "wmd-preview-section preview-content"
}), t = !1; n;) {
var i = n.nextSibling,
r = "se-preview-section-delimiter" == n.className;
if(t === !0 && "DIV" == n.tagName && r) break;
t = !0, r || e.appendChild(n), n = i
}
return e
}
var t = document.getElementById("wmd-preview"),
n = t.firstChild,
i = document.createDocumentFragment();
u.forEach(function(t) {
i.appendChild(e(t))
}), c.innerHTML = "", c.appendChild(t), c.appendChild(i)
}))
}, l.onReady = function() {
c = document.getElementById("preview-contents")
};
var p;
l.onFileSelected = function(e) {
p = e
};
var h = 0;
return l.onFileOpen = a, l.onContentChanged = a, l
}), define("text!html/buttonMarkdownSyntax.html", [], function() {
return '\n
\n
Markdown syntax
\n \n
\n
Phrase Emphasis
\n\n
*italic* **bold**\n_italic_ __bold__\n
\n\n
Links
\n\n
Inline:
\n\n
An [example](http://url.com/ "Title")\n
\n\n
Reference-style labels (titles are optional):
\n\n
An [example][id]. Then, anywhere\nelse in the doc, define the link:\n\n [id]: http://example.com/ "Title"\n
> Email-style angle brackets\n> are used for blockquotes.\n\n> > And, they can be nested.\n\n> #### Headers in blockquotes\n>\n> * You can quote a list.\n> * Etc.\n
\n\n
Code Spans
\n\n
`<code>` spans are delimited\nby backticks.\n\nYou can include literal backticks\nlike `` `this` ``.\n
\n\n
Preformatted Code Blocks
\n\n
Indent every line of a code block by at least 4 spaces or 1 tab.
\n\n
This is a normal paragraph.\n\n This is a preformatted\n code block.\n
\n'
}), define("extensions/buttonMarkdownSyntax", ["jquery", "classes/Extension", "text!html/buttonMarkdownSyntax.html"], function(e, t, n) {
var i = new t("buttonMarkdownSyntax", 'Button "Markdown syntax', !0, !0);
return i.settingsBlock = '
Adds a "Markdown syntax" button over the preview.
', i.onCreatePreviewButton = function() {
return n
}, i
}), define("extensions/googleAnalytics", ["jquery", "underscore", "constants", "utils", "classes/Extension", "settings"], function(e, t, n, i, r, o) {
function a() {
i.currentTime - d > 18e4 && (_gaq.push(["_trackPageview"]), d = i.currentTime)
}
var s = new r("googleAnalytics", "Google Analytics", !0);
s.settingsBlock = "
Sends anonymous statistics about usage and errors to help improve StackEdit.
";
var l = !1,
c = !1;
window._gaq = [];
var u = function() {
if(l === !1 && c === !1) {
var t = "/ga.js";
location.search.match(/(\?|&)console/) && (t = "/u/ga_debug.js"), e.ajax({
url: "https://ssl.google-analytics.com" + t,
dataType: "script"
}).done(function() {
l = !0
})
}
}, d = 0;
s.onPeriodicRun = function() {
a()
}, s.onReady = function() {
_gaq.push(["_setAccount", n.GOOGLE_ANALYTICS_ACCOUNT_ID]), a(), _gaq.push(["_trackEvent", "About", "version", n.VERSION]), _gaq.push(["_trackEvent", "Settings", "layoutOrientation", "" + o.layoutOrientation]), _gaq.push(["_trackEvent", "Settings", "theme", "" + window.theme]), _gaq.push(["_trackEvent", "Settings", "lazyRendering", "" + o.lazyRendering]), _gaq.push(["_trackEvent", "Settings", "editorFontFamily", "" + o.editorFontFamily]), _gaq.push(["_trackEvent", "Settings", "editorFontSize", "" + o.editorFontSize]), _gaq.push(["_trackEvent", "Settings", "defaultContent backlink", "" + (-1 !== o.defaultContent.indexOf(n.MAIN_URL))]), _gaq.push(["_trackEvent", "Settings", "commitMsg backlink", "" + (-1 !== o.commitMsg.indexOf(n.MAIN_URL))]), _gaq.push(["_trackEvent", "Settings", "sshProxy unchanged", "" + (o.sshProxy == n.SSH_PROXY_URL)]), t.each(o.extensionSettings, function(e, t) {
_gaq.push(["_trackEvent", "Extensions", t + " enabled", "" + (e.enabled === !0)])
}), window.onerror = function(e, t, n) {
_gaq.push(["_trackEvent", "Error", e, t + ":" + n + i.formatEventList()])
}, u()
}, s.onOfflineChanged = function(e) {
c = e, u()
};
var p = 0;
return s.onSyncRunning = function(e) {
e === !0 && (p = (new Date).getTime())
}, s.onPublishRunning = function(e) {
e === !0 && (p = (new Date).getTime())
}, s.onSyncSuccess = function() {
var e = (new Date).getTime();
_gaq.push(["_trackTiming", "Sync", "SyncTime", e - p])
}, s.onSyncImportSuccess = function(e, t) {
_gaq.push(["_trackEvent", "Sync", "SyncImport"]), _gaq.push(["_trackEvent", "Sync", "SyncImport provider", t.providerId])
}, s.onSyncExportSuccess = function(e, t) {
_gaq.push(["_trackEvent", "Sync", "SyncExport"]), _gaq.push(["_trackEvent", "Sync", "SyncExport provider", t.provider.providerId])
}, s.onPublishSuccess = function(e) {
var n = (new Date).getTime();
_gaq.push(["_trackTiming", "Publish", "PublishSuccess", n - p]), t.each(e.publishLocations, function(e) {
_gaq.push(["_trackEvent", "Publish", "PublishSuccess provider", e.provider.providerId])
})
}, s.onNewPublishSuccess = function(e, t) {
_gaq.push(["_trackEvent", "Publish", "NewPublish provider", t.provider.providerId])
}, s.onError = function(e) {
!t.isString(e) && e.message && _gaq.push(["_trackEvent", "Error", "message", e.message + i.formatEventList()])
}, s
}), define("extensions/twitter", ["jquery", "underscore", "constants", "utils", "classes/Extension"], function(e, t, n, i, r) {
var o = new r("twitter", "Twitter", !1, !0),
a = !1,
s = !1,
l = function() {
a === !1 && s === !1 && e.ajax({
url: "https://platform.twitter.com/widgets.js",
dataType: "script"
}).done(function() {
a = !0
})
};
return o.onReady = function() {
l()
}, o.onOfflineChanged = function(e) {
s = e, l()
}, o.onTweet = function() {
a && window.twttr.widgets.load()
}, o
}), function() {
function e() {
if(u) return u;
var e = {
width: "1px",
height: "1px",
position: "absolute",
top: "-100px"
};
return u = document.createElement("iframe"), u.setAttribute("style", Object.keys(e).map(function(t) {
return t + ":" + e[t]
}).join(";")), document.body.appendChild(u), u.onerror = u.onload = function() {
setTimeout(function() {
p && p({
error: k
})
}, 10)
}, u
}
function t(e, t) {
var n = y + e;
return t.q = Date.now(), t = t && Object.keys(t).map(function(e) {
return e + "=" + encodeURIComponent(t[e])
}).join("&"), t ? n + "?" + t : n
}
function n(n, i) {
p = function(e) {
p = void 0, i(e)
};
var r = {
immediate: !0,
response_type: "token",
client_id: n.applicationID,
redirect_uri: n.redirectURL
};
b(function() {
e().src = t("/authorize", r), clearTimeout(g), g = setTimeout(function() {
p && p({
error: _
})
}, S)
})
}
function i(e, t) {
t.pricingOptions && t.pricingOptions.length && (e.pricing_options = t.pricingOptions.join ? t.pricingOptions.join(",") : t.pricingOptions), t.summary && (e.summary = !0)
}
function r(e, n) {
h = function(e) {
h = void 0, n(e)
};
var r = {
popup: !0,
response_type: "token",
client_id: e.applicationID,
redirect_uri: e.redirectURL
};
i(r, e);
var o = {
toolbar: "no",
location: "no",
directories: "no",
status: "no",
menubar: "no",
scrollbars: "no",
resizable: "no",
copyhistory: "no",
width: x,
height: w,
left: (screen.width - x) / 2,
top: (screen.height - w) / 2
};
window.open(t("/authorize", r), void 0, Object.keys(o).map(function(e) {
return e + "=" + o[e]
}).join(","))
}
function o() {
return d && document.body.removeChild(d), d = document.createElement("script"), d.onerror = d.onload = function() {
setTimeout(function() {
f && f({
error: k
})
}, 10)
}, document.body.appendChild(d), d
}
function a(e) {
f = function(t) {
f = void 0, e(t)
};
var n = {
access_token: m.token,
callback: "_monetizeJsonpCallback"
};
b(function() {
o().src = t("/api/payments", n), clearTimeout(v), v = setTimeout(function() {
f && f({
error: _
})
}, S)
})
}
function s(e) {
var n = {
redirect: !0,
response_type: "token",
client_id: e.applicationID,
redirect_uri: e.redirectURL
};
i(n, e), window.location = t("/authorize", n)
}
function l(e, t) {
for(var n in t) e[n] = t[n]
}
function c(e) {
function t(e) {
return function(t, n) {
"function" == typeof t && (n = t, t = {});
var r = {};
l(r, i), l(r, t || {}), e(r, n)
}
}
var i = {};
l(i, T), l(i, e || {});
var o = {};
return o.getTokenImmediate = t(function(e, t) {
return m && m.token && m.refreshDate > Date.now() ? t(void 0, m.token) : void n(e, function(e) {
t(e.error, e.token)
})
}), o.getPaymentsImmediate = t(function(e, t) {
return m && m.token && m.refreshDate > Date.now() ? a(function(e) {
t(e.error, e.payments)
}) : void n(e, function(e) {
t(e.error, e.payments)
})
}), o.getTokenInteractive = t(function(e, t) {
return t ? void r(e, function(e) {
t(e.error, e.token)
}) : s(e)
}), o.getPaymentsInteractive = t(function(e, t) {
return t ? void r(e, function(e) {
t(e.error, e.payments)
}) : s(e)
}), o.getToken = t(function(e, t) {
return(e.immeditate ? o.getTokenImmediate : o.getTokenInteractive)(e, t)
}), o.getPayments = t(function(e, t) {
return(e.immeditate ? o.getPaymentsImmediate : o.getPaymentsInteractive)(e, t)
}), o
}
var u, d, p, h, f, m, g, v, b = function() {
var e, t = [],
n = /^loaded|c/.test(document.readyState),
i = "DOMContentLoaded";
return document.addEventListener(i, e = function() {
for(document.removeEventListener(i, e, !1), n = 1; e = t.shift();) e()
}, !1),
function(e) {
n ? e() : t.push(e)
}
}(),
y = "https://monetizejs.com",
x = 1e3,
w = 700,
S = 3e4,
C = 3e5,
_ = "Request timeout",
k = "Please check your JS console";
window.addEventListener("message", function(e) {
e.origin == y && (m = e.data, m.expiresIn && (m.refreshDate = Date.now() + m.expiresIn - C), m.popup ? h && h(m) : (clearTimeout(g), p && p(m)))
}), window._monetizeJsonpCallback = function E(e) {
return window._monetizeJsonpCallback !== E ? f && f({
error: "Callback replaced!"
}) : (clearTimeout(v), void(f && f({
payments: e
})))
};
var T = {
redirectURL: window.location.href
};
window.MonetizeJS = c, "function" == typeof define && define.amd && define("monetizejs", [], function() {
return c
})
}(), define("text!html/dialogAbout.html", [], function() {
return '
\n'
}), define("extensions/dialogAbout", ["jquery", "underscore", "constants", "utils", "classes/Extension", "monetizejs", "text!html/dialogAbout.html"], function(e, t, n, i, r, o, a) {
var s = new r("dialogAbout", 'Dialog "About"'),
l = new o({
applicationID: "iklMbzDI7dvMEScb"
});
return s.onReady = function() {
i.addModal("modal-about", t.template(a, {
version: n.VERSION
})), e(".modal-about .sponsorship-button").click(function() {
l.getPayments({
summary: !0
}, function() {})
})
}, s
}), define("text!html/dialogManagePublicationLocation.html", [], function() {
return '
\n \n \n \n
\n \n
\n
\n'
}), define("extensions/dialogManagePublication", ["jquery", "underscore", "classes/Extension", "text!html/dialogManagePublicationLocation.html"], function(e, t, n, i) {
var r, o = new n("dialogManagePublication", 'Dialog "Manage publication"', !1, !0);
o.onEventMgrCreated = function(e) {
r = e
};
var a, s, l, c = function(e) {
if(void 0 === e || e === a) {
l.toggleClass("hide", 0 === t.size(a.publishLocations));
var n = t.reduce(a.publishLocations, function(e, n) {
var r = t.omit(n, "provider", "publishIndex", "sharingLink");
return r.password && (r.password = "********"), r = JSON.stringify(r).replace(/{|}|"/g, "").replace(/,/g, ", "), e + t.template(i, {
publishAttributes: n,
publishDesc: r
})
}, "");
s.innerHTML = n
}
};
return o.onFileSelected = function(e) {
a = e, c(e)
}, o.onNewPublishSuccess = c, o.onPublishRemoved = c, o.onReady = function() {
var t = document.querySelector(".modal-manage-publish");
s = t.querySelector(".publish-list"), l = e(document.querySelectorAll(".show-already-published")), e(s).on("click", ".remove-button", function() {
var t = e(this),
n = a.publishLocations[t.data("publishIndex")];
a.removePublishLocation(n), r.onPublishRemoved(a, n)
})
}, o
}), define("text!html/dialogManageSynchronizationLocation.html", [], function() {
return '
\n \n \n \n
\n \n
\n
\n'
}), define("extensions/dialogManageSynchronization", ["jquery", "underscore", "classes/Extension", "text!html/dialogManageSynchronizationLocation.html"], function(e, t, n, i) {
var r, o = new n("dialogManageSynchronization", 'Dialog "Manage synchronization"', !1, !0);
o.onEventMgrCreated = function(e) {
r = e
};
var a;
o.onSynchronizerCreated = function(e) {
a = e
};
var s, l, c, u = function(e) {
if(void 0 === e || e === s) {
c.toggleClass("hide", 0 === t.size(s.syncLocations));
var n = t.reduce(s.syncLocations, function(e, n) {
return e + t.template(i, {
syncAttributes: n,
syncDesc: n.id || n.path
})
}, "");
l.innerHTML = n
}
};
return o.onFileSelected = function(e) {
s = e, u(e)
}, o.onSyncExportSuccess = u, o.onSyncRemoved = u, o.onReady = function() {
var t = document.querySelector(".modal-manage-sync");
l = t.querySelector(".sync-list"), c = e(document.querySelectorAll(".show-already-synchronized")), e(l).on("click", ".remove-button", function() {
var t = e(this),
n = s.syncLocations[t.data("syncIndex")];
s.removeSyncLocation(n), r.onSyncRemoved(s, n)
})
}, o
}), define("text!html/dialogManageSharingLocation.html", [], function() {
return '
\n \n
\n
\n \n
\n'
}), define("extensions/dialogManageSharing", ["jquery", "underscore", "classes/Extension", "text!html/dialogManageSharingLocation.html"], function(e, t, n, i) {
var r, o = new n("dialogManageSharing", 'Button "Share"', !1, !0);
o.onEventMgrCreated = function(e) {
r = e
};
var a, s, l, c, u = function(e) {
if(void 0 === e || e === a) {
var n = t.reduce(a.publishLocations, function(e, n) {
return n.sharingLink && (e += t.template(i, {
link: n.sharingLink,
title: a.title
})), e
}, "");
s.innerHTML = n, r.onTweet(), l.toggleClass("hide", 0 === n.length), c.toggleClass("hide", 0 !== n.length)
}
};
return o.onFileSelected = function(e) {
a = e, u(e)
}, o.onNewPublishSuccess = function(t, n) {
u(t), n.sharingLink && (e(".modal").modal("hide"), e(".modal-manage-sharing").modal("show"))
}, o.onPublishRemoved = u, o.onReady = function() {
var t = document.querySelector(".modal-manage-sharing");
s = t.querySelector(".share-list"), l = e(t.querySelectorAll(".msg-share-list")), c = e(t.querySelectorAll(".msg-no-share"))
}, o
}), function() {
var e = this,
t = {}, n = !1;
"undefined" != typeof module && module.exports ? (module.exports = t, e.toMarkdown = t, n = !0) : e.toMarkdown = t, t.converter = function(e) {
e && e.elements && $.isArray(e.elements) && (c = c.concat(e.elements)), this.makeMd = function(e, t) {
var r;
if(n) {
var o = require("jsdom");
o.env({
html: e,
scripts: ["http://code.jquery.com/jquery-1.6.4.min.js"],
done: function(n, r) {
"function" == typeof t && t(i(e, r.$))
}
})
} else r = i(e, $);
return r
}
};
var i = function(e, t) {
e = e.replace(/(\d+)\. /g, "$1\\. ");
var n = t(""),
i = n.html(e);
i.find("*:not(pre, code)").contents().filter(function() {
return 3 === this.nodeType && /^\s+$/.test(this.nodeValue)
}).remove();
for(var r = [], o = 0, s = c.length; s > o; o++) r.push(c[o].selector);
for(r = r.join(","); i.find(r).length;)
for(var o = 0, s = c.length; s > o; o++) $matches = i.find(c[o].selector + ':not(:has("' + r + '"))'), $matches.each(function(e, n) {
var i = t(n);
i.before(c[o].replacement(i.html(), i)).remove()
});
return a(i.html())
}, r = function(e) {
return e.replace(/^[\n\r\f]+|[\n\r\f]+$/g, "")
}, o = function(e) {
return String(e).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"')
}, a = function(e) {
return e = e.replace(/^[\t\r\n]+|[\t\r\n]+$/g, ""), e = e.replace(/\n\s+\n/g, "\n\n"), e = e.replace(/\n{3,}/g, "\n\n"), e = o(e)
}, s = function(e) {
return e = r(e), e ? "**" + e + "**" : ""
}, l = function(e) {
return e = r(e), e ? "_" + e + "_" : ""
}, c = [{
selector: "p",
replacement: function(e) {
return e = $.trim(e), e ? "\n\n" + e + "\n\n" : ""
}
}, {
selector: "br",
replacement: function() {
return "\n"
}
}, {
selector: "h1,h2,h3,h4,h5,h6",
replacement: function(e, t) {
e = $.trim(e);
for(var n = t.prop("nodeName").charAt(1), i = "", r = 0; n > r; r++) i += "#";
return e ? "\n\n" + i + " " + e + "\n\n" : ""
}
}, {
selector: "hr",
replacement: function() {
return "\n\n* * *\n\n"
}
}, {
selector: "a[href]",
replacement: function(e, t) {
if(e) {
e = r(e);
var n = t.attr("href"),
i = t.attr("title") || "";
return "[" + e + "](" + n + (i ? ' "' + i + '"' : "") + ")"
}
return !1
}
}, {
selector: "b",
replacement: s
}, {
selector: "strong",
replacement: s
}, {
selector: "i",
replacement: l
}, {
selector: "em",
replacement: l
}, {
selector: "code",
replacement: function(e) {
return e = r(e), e ? "`" + e + "`" : ""
}
}, {
selector: "img",
replacement: function(e, t) {
var n = t.attr("alt") || "",
i = t.attr("src") || "",
r = t.attr("title") || "";
return "![" + n + "](" + i + (r ? ' "' + r + '"' : "") + ")"
}
}, {
selector: "pre",
replacement: function(e) {
return /^\s*\`/.test(e) ? (e = e.replace(/\`/g, ""), " " + e.replace(/\n/g, "\n ")) : ""
}
}, {
selector: "li",
replacement: function(e, t) {
e = e.replace(/^\s+|\s+$/, "").replace(/\n/gm, "\n ");
var n = "* ",
i = "",
r = t.parent(),
o = r.contents().filter(function() {
return 1 === this.nodeType && "LI" === this.nodeName || 3 === this.nodeType
}),
a = o.index(t) + 1;
return n = r.is("ol") ? a + ". " : "* ", a == o.length && (t.parents("li").length || (i = "\n"), e = e.replace(/\s+$/, ""), t.unwrap()), n + e + i + "\n"
}
}, {
selector: "blockquote",
replacement: function(e) {
return e = e = $.trim(e).replace(/\n{3,}/g, "\n\n"), e = e.replace(/\n/g, "\n> "), "> " + e
}
}]
}(), define("toMarkdown", ["jquery"], function(e) {
return function() {
var t;
return t || e.toMarkdown
}
}(this)), define("extensions/dialogOpenHarddrive", ["jquery", "underscore", "constants", "utils", "classes/Extension", "toMarkdown"], function(e, t, n, i, r, o) {
function a(i) {
i.stopPropagation(), i.preventDefault();
var r = (i.dataTransfer || i.target).files;
e(".modal-import-harddrive-markdown, .modal-import-harddrive-html").modal("hide"), t.each(r, function(t) {
if(!e(i.target).is("#wmd-input *") || !t.name.match(/.(jpe?g|png|gif)$/i)) {
var r = new FileReader;
r.onload = function(e) {
return function(t) {
var n = t.target.result;
if(n.match(/\uFFFD/)) return void p.onError(e.name + " is a binary file.");
if(n = h ? h(n) : n, void 0 === n) return void p.onError(e.name + " is not a valid HTML file.");
var i = e.name,
r = i.lastIndexOf(".");
i = -1 !== r ? i.substring(0, r) : i;
var o = u.createFile(i, n);
u.selectFile(o)
}
}(t);
var o = t.slice(0, n.IMPORT_FILE_MAX_CONTENT_SIZE);
r.readAsText(o)
}
})
}
function s(e) {
h = void 0, a(e)
}
function l(e) {
h = m, a(e)
}
function c(e) {
e.stopPropagation(), e.preventDefault(), e.dataTransfer.dropEffect = "copy"
}
var u, d = new r("dialogOpenHarddrive", 'Dialog "Open from"');
d.onFileMgrCreated = function(e) {
u = e
};
var p;
d.onEventMgrCreated = function(e) {
p = e
};
var h, f, m = function(e) {
return f.makeMd(e)
};
return d.onReady = function() {
f = new o.converter, e("#input-file-import-harddrive-markdown").change(s), e("#dropzone-import-harddrive-markdown, #wmd-input").each(function() {
this.addEventListener("dragover", c, !1), this.addEventListener("drop", s, !1)
}), e("#input-file-import-harddrive-html").change(l), e("#dropzone-import-harddrive-html").each(function() {
this.addEventListener("dragover", c, !1), this.addEventListener("drop", l, !1)
}), e(".action-convert-html").click(function(e) {
var t = i.getInputTextValue("#input-convert-html", e);
if(void 0 !== t) {
if(t = f.makeMd(t), void 0 === t) return void p.onError("Invalid HTML code.");
var n = u.createFile(void 0, t);
u.selectFile(n)
}
})
}, d
}), define("extensions/documentTitle", ["jquery", "underscore", "classes/Extension"], function(e, t, n) {
var i, r, o = new n("documentTitle", "Document Title"),
a = t.debounce(function(t) {
if(t === i) {
var n = i.title;
document.title = "StackEdit – " + n, r.html(i.composeTitle()), e(".file-title").text(n), e(".input-file-title").val(n)
}
}, 50);
return o.onFileSelected = function(e) {
i = e, a(e)
}, o.onTitleChanged = a, o.onSyncExportSuccess = a, o.onSyncRemoved = a, o.onNewPublishSuccess = a, o.onPublishRemoved = a, o.onReady = a, o.onReady = function() {
r = e(".file-title-navbar"), r.hover(function() {
var e = r[0].scrollWidth - r.outerWidth();
r.stop(!0, !0).animate({
scrollLeft: e
}, 15 * e, "linear")
}, function() {
r.stop(!0, !0).scrollLeft(0)
}).click(function() {
r.stop(!0, !0).scrollLeft(0)
})
}, o
}), define("classes/FileDescriptor", ["underscore", "utils", "storage"], function(e, t, n) {
function i(e, t, i, r) {
this.fileIndex = e, this._title = t || n[e + ".title"], this._editorScrollTop = parseInt(n[e + ".editorScrollTop"]) || 0, this._editorStart = parseInt(n[e + ".editorEnd"]) || 0, this._editorEnd = parseInt(n[e + ".editorEnd"]) || 0, this._previewScrollTop = parseInt(n[e + ".previewScrollTop"]) || 0, this._selectTime = parseInt(n[e + ".selectTime"]) || 0, this._discussionList = JSON.parse(n[e + ".discussionList"] || "{}"), this.syncLocations = i || {}, this.publishLocations = r || {}, Object.defineProperty(this, "title", {
get: function() {
return this._title
},
set: function(e) {
this._title = e, n[this.fileIndex + ".title"] = e
}
}), Object.defineProperty(this, "content", {
get: function() {
return n[this.fileIndex + ".content"]
},
set: function(e) {
n[this.fileIndex + ".content"] = e
}
}), Object.defineProperty(this, "editorScrollTop", {
get: function() {
return this._editorScrollTop
},
set: function(e) {
this._editorScrollTop = e, n[this.fileIndex + ".editorScrollTop"] = e
}
}), Object.defineProperty(this, "editorStart", {
get: function() {
return this._editorStart
},
set: function(e) {
this._editorStart = e, n[this.fileIndex + ".editorStart"] = e
}
}), Object.defineProperty(this, "editorEnd", {
get: function() {
return this._editorEnd
},
set: function(e) {
this._editorEnd = e, n[this.fileIndex + ".editorEnd"] = e
}
}), Object.defineProperty(this, "previewScrollTop", {
get: function() {
return this._previewScrollTop
},
set: function(e) {
this._previewScrollTop = e, n[this.fileIndex + ".previewScrollTop"] = e
}
}), Object.defineProperty(this, "selectTime", {
get: function() {
return this._selectTime
},
set: function(e) {
this._selectTime = e, n[this.fileIndex + ".selectTime"] = e
}
}), Object.defineProperty(this, "discussionList", {
get: function() {
return this._discussionList
},
set: function(e) {
this._discussionList = e, n[this.fileIndex + ".discussionList"] = JSON.stringify(e)
}
}), Object.defineProperty(this, "discussionListJSON", {
get: function() {
return n[this.fileIndex + ".discussionList"] || "{}"
},
set: function(e) {
this._discussionList = JSON.parse(e), n[this.fileIndex + ".discussionList"] = e
}
})
}
return i.prototype.addSyncLocation = function(e) {
t.storeAttributes(e), t.appendIndexToArray(this.fileIndex + ".sync", e.syncIndex), this.syncLocations[e.syncIndex] = e
}, i.prototype.removeSyncLocation = function(e) {
t.removeIndexFromArray(this.fileIndex + ".sync", e.syncIndex), delete this.syncLocations[e.syncIndex]
}, i.prototype.addPublishLocation = function(e) {
t.storeAttributes(e), t.appendIndexToArray(this.fileIndex + ".publish", e.publishIndex), this.publishLocations[e.publishIndex] = e
}, i.prototype.removePublishLocation = function(e) {
t.removeIndexFromArray(this.fileIndex + ".publish", e.publishIndex), delete this.publishLocations[e.publishIndex]
}, i.prototype.composeTitle = function() {
var t = [];
return e.chain(this.syncLocations).sortBy(function(e) {
return e.provider.providerId
}).each(function(e) {
t.push('')
}), 0 !== e.size(this.syncLocations) && t.push(''), e.chain(this.publishLocations).sortBy(function(e) {
return e.provider.providerId
}).each(function(e) {
t.push('')
}), 0 !== e.size(this.publishLocations) && t.push(''), t.push(e.escape(this.title)), t.join("")
}, i
}), define("fileSystem", ["underscore", "utils", "classes/FileDescriptor", "storage"], function(e, t, n, i) {
var r = {};
return t.retrieveIndexArray("file.list").forEach(function(e) {
r[e] = new n(e)
}), Object.keys(i).forEach(function(e) {
var t = e.match(/(file\.\S+?)\.\S+/);
t && !r.hasOwnProperty(t[1]) && i.removeItem(e)
}), r
}), define("text!html/documentSelectorSettingsBlock.html", [], function() {
return '
Allows toggling document with keyboard shortcuts.
\n
\n
\n \n
\n \n
\n
\n
\n \n
\n \n
\n
\n
\n \n
\n \n
\n
\n
'
}), define("extensions/documentSelector", ["jquery", "underscore", "crel", "utils", "classes/Extension", "mousetrap", "fileSystem", "text!html/documentSelectorSettingsBlock.html"], function(e, t, n, i, r, o, a, s) {
var l = new r("documentSelector", "Document Selector", !0);
l.settingsBlock = s, l.defaultConfig = {
orderBy: "mru",
shortcutPrevious: "Ctrl+[",
shortcutNext: "Ctrl+]"
}, l.onLoadSettings = function() {
i.setInputValue("#select-document-selector-orderby", l.config.orderBy), i.setInputValue("#input-document-selector-shortcut-previous", l.config.shortcutPrevious), i.setInputValue("#input-document-selector-shortcut-next", l.config.shortcutNext)
}, l.onSaveSettings = function(e, t) {
e.orderBy = i.getInputValue("#select-document-selector-orderby"), e.shortcutPrevious = i.getInputTextValue("#input-document-selector-shortcut-previous", t), e.shortcutNext = i.getInputTextValue("#input-document-selector-shortcut-next", t)
};
var c;
l.onFileMgrCreated = function(e) {
c = e
};
var u, d, p, h, f, m, g, v = ['
"].join(""),
n = t.chain(w).sortBy(function(e) {
return e.title.toLowerCase()
}).reduce(function(e, n) {
return e + t.template(k, {
fileDesc: n
})
}, "").value();
n = n && '
' + n + "
", e += '
' + n + "
", t.chain(s).sortBy(function(e) {
return e.name.toLowerCase()
}).each(function(n) {
var i = t.chain(n.fileList).sortBy(function(e) {
return e.title.toLowerCase()
}).reduce(function(e, n) {
return e + t.template(k, {
fileDesc: n
})
}, "").value();
i = i && '
' + i + "
", e += t.template(_, {
folderDesc: n,
fileListHtml: i,
id: n.folderIndex.replace(".", "")
})
}), v.innerHTML = e
}
}, 50);
return h.onFileCreated = L, h.onFileDeleted = L, h.onSyncExportSuccess = L, h.onSyncRemoved = L, h.onNewPublishSuccess = L, h.onPublishRemoved = L, h.onFoldersChanged = L, h.onTitleChanged = function(t) {
m !== !1 && (e(v).find('[data-file-index="' + t.fileIndex + '"] .name').html(t.composeTitle()).removeClass("hide"), e(v.querySelectorAll(".input-rename")).addClass("hide"))
}, h.onReady = function() {
g = document.querySelector(".modal-document-manager"), v = g.querySelector(".list-group.document-list"), S = e(g.querySelectorAll(".document-count")), C = e(g.querySelectorAll(".folder-count")), b = g.querySelector(".list-group.selected-document-list");
var o = g.querySelector(".list-group.select-folder-list");
e(g).on("show.bs.modal", function() {
m = !0, L(), setTimeout(function() {
e(v.querySelectorAll(".root-folder")).click()
}, 250)
}).on("hide.bs.modal", function() {
m = !1, v.innerHTML = ""
}), e(g.querySelectorAll(".action-create-folder")).click(function() {
var o;
do o = "folder." + i.randomString(); while (t.has(s, o));
r[o + ".name"] = n.DEFAULT_FOLDER_NAME;
var l = new a(o, n.DEFAULT_FOLDER_NAME);
i.appendIndexToArray("folder.list", o), s[o] = l, f.onFoldersChanged(), setTimeout(function() {
var t = e(g.querySelector('[data-folder-index="' + o + '"] .button-rename')).click();
g.scrollTop += t.offset().top - 50
}, 60)
}), e(g.querySelectorAll(".action-select-all")).click(function() {
e(v.querySelectorAll('.folder input[type="checkbox"]')).prop("checked", !0).change()
}), e(g.querySelectorAll(".action-unselect-all")).click(function() {
e(v.querySelectorAll('.folder input[type="checkbox"]')).prop("checked", !1).change()
});
var p = e(g.querySelectorAll(".action-delete-items")).click(function() {
x.hasClass("disabled") || (c(), u())
});
x = p.parent(), e(g.querySelectorAll(".action-delete-items-confirm")).click(function() {
d(), e(g.querySelectorAll(".document-list")).removeClass("hide"), e(g.querySelectorAll(".confirm-delete, .selected-document-list")).addClass("hide")
});
var h = e(g.querySelectorAll(".action-move-items")).click(function() {
if(!y.hasClass("disabled")) {
c();
var n = ['', '
Generates a table of contents when a [TOC] marker is found.
\n
\n
\n \n
\n \n \n
\n
\n
\n \n
\n \n
\n
\n
\n \n
\n
\n \n
\n
\n
\n \n
'
}), define("extensions/toc", ["jquery", "underscore", "utils", "classes/Extension", "text!html/buttonToc.html", "text!html/tocSettingsBlock.html"], function(e, t, n, i, r, o) {
function a(e, t, n) {
this.tagName = e, this.anchor = t, this.text = n, this.children = []
}
function s(e, n) {
function i() {
void 0 !== r && (r.children.length > 0 && (r.children = s(r.children, n + 1)), l.push(r))
}
n = n || 1;
var r, o = "H" + n,
l = [];
return t.each(e, function(e) {
e.tagName != o ? n !== c.config.maxDepth && (void 0 === r && (r = new a), r.children.push(e)) : (i(), r = e)
}), i(), l
}
function l() {
function e(e) {
for(var r = e.id || n.slugify(e.textContent) || "title", o = r, a = 0; t.has(i, o);) o = r + "-" + ++a;
return i[o] = !0, e.id = o, o
}
var i = {}, r = [];
return t.each(u.querySelectorAll("h1, h2, h3, h4, h5, h6"), function(t) {
r.push(new a(t.tagName, e(t), t.textContent))
}), r = s(r), '
\n
\n' + r.join("") + "
\n
\n"
}
var c = new i("toc", "Table of Contents", !0);
c.settingsBlock = o, c.defaultConfig = {
marker: "\\[(TOC|toc)\\]",
maxDepth: 6,
button: !0
}, c.onLoadSettings = function() {
n.setInputValue("#input-toc-marker", c.config.marker), n.setInputValue("#input-toc-maxdepth", c.config.maxDepth), n.setInputChecked("#input-toc-button", c.config.button)
}, c.onSaveSettings = function(e, t) {
e.marker = n.getInputRegExpValue("#input-toc-marker", t), e.maxDepth = n.getInputIntValue("#input-toc-maxdepth"), e.button = n.getInputChecked("#input-toc-button")
}, c.onCreatePreviewButton = function() {
return c.config.button ? r : void 0
}, a.prototype.childrenToString = function() {
if(0 === this.children.length) return "";
var e = "
\n";
return t.each(this.children, function(t) {
e += t.toString()
}), e += "
\n"
}, a.prototype.toString = function() {
var e = "
";
return this.anchor && this.text && (e += '' + this.text + ""), e += this.childrenToString() + "
\n"
};
var u;
return c.onPagedownConfigure = function(e) {
u = document.getElementById("preview-contents");
var n = new RegExp("^\\s*" + c.config.marker + "\\s*$");
e.hooks.chain("onPreviewRefresh", function() {
var e = document.querySelectorAll(".table-of-contents, .toc"),
i = l();
t.each(u.getElementsByTagName("p"), function(e) {
n.test(e.innerHTML) && (e.innerHTML = i)
}), t.each(e, function(e) {
e.innerHTML = i
})
})
}, c.onReady = function() {
var t = !0;
e(".preview-panel").on("hide.layout.toggle", function() {
t = !1
}).on("shown.layout.toggle", function() {
t = !0
}), e(".extension-preview-buttons .table-of-contents").on("click", "a", function(e) {
!t && e.preventDefault()
})
}, c
}), define("extensions/emailConverter", ["classes/Extension"], function(e) {
var t = new e("emailConverter", "Markdown Email", !0);
return t.settingsBlock = "
Converts email adresses in the form <email@example.com> into clickable links.
\n Note: The mapping between Markdown and HTML is based on the\n position of the title elements (h1, h2...) in the page. Therefore if\n your document does not contain any title, the mapping will be linear and\n consequently less accurate.\n
"
}), define("extensions/scrollSync", ["jquery", "underscore", "classes/Extension", "text!html/scrollSyncSettingsBlock.html"], function(e, t, n, i) {
function r(e, n, i) {
var r, o = t.find(n, function(t, n) {
return r = n, e < t.endOffset
});
if(void 0 !== o) {
var a = (e - o.startOffset) / (o.height || 1),
s = i[r];
return s.startOffset + s.height * a
}
}
function o(e, t, n, i, r) {
function o() {
var l = Date.now(),
c = (l - s) / 200;
if(1 > c) {
var u = t + a * Math.cos((1 - c) * Math.PI / 2);
e.scrollTop = u, i(u), p = setTimeout(o, 1)
} else h = void 0, e.scrollTop = n, setTimeout(r, 100)
}
h && (clearTimeout(p), h()), h = r;
var a = n - t,
s = Date.now();
o()
}
var a = new n("scrollSync", "Scroll Sync", !0, !0);
a.settingsBlock = i;
var s;
a.onSectionsCreated = function(e) {
s = e
};
var l, c, u, d, p, h, f = [],
m = [],
g = t.debounce(function() {
f = [];
var e, n;
t.each(l.querySelectorAll(".wmd-input-section"), function(t) {
if(void 0 === e) return void(e = 0);
t = t.firstChild;
var n = t.offsetTop;
f.push({
startOffset: e,
endOffset: n,
height: n - e
}), e = n
}), n = l.scrollHeight, f.push({
startOffset: e,
endOffset: n,
height: n - e
}), m = [];
var i;
t.each(c.querySelectorAll(".wmd-preview-section"), function(e) {
if(void 0 === i) return void(i = 0);
var t = e.offsetTop;
m.push({
startOffset: i,
endOffset: t,
height: t - i
}), i = t
}), n = c.scrollHeight, m.push({
startOffset: i,
endOffset: n,
height: n - i
}), u = -10, d = -10, S()
}, 500),
v = !0,
b = !1,
y = !1,
x = !1,
w = !1,
S = t.throttle(function() {
if(v && 0 !== f.length && f.length === m.length) {
var e = l.scrollTop;
0 > e && (e = 0);
var n, i = c.scrollTop;
if(b === !0) {
if(Math.abs(e - u) <= 9) return;
if(b = !1, u = e, n = r(e, f, m), n = t.min([n, c.scrollHeight - c.offsetHeight]), Math.abs(n - i) <= 9) return void(d = i);
o(c, i, n, function(e) {
w = !0, d = e
}, function() {
w = !1
})
} else if(y === !0) {
if(Math.abs(i - d) <= 9) return;
if(y = !1, d = i, n = r(i, m, f), n = t.min([n, l.scrollHeight - l.offsetHeight]), Math.abs(n - e) <= 9) return void(u = e);
o(l, e, n, function(e) {
x = !0, u = e
}, function() {
x = !1
})
}
}
}, 100);
a.onLayoutResize = function() {
b = !0, g()
}, a.onFileClosed = function() {
f = []
};
var C = !1;
a.onReady = function() {
c = document.querySelector(".preview-container"), l = document.querySelector("#wmd-input"), e(c).scroll(function() {
w === !1 && C === !1 && (y = !0, b = !1, S()), C = !1
}), e(l).scroll(function() {
x === !1 && (b = !0, y = !1, S())
}), e(".preview-panel").on("hide.layout.toggle", function() {
v = !1
}).on("shown.layout.toggle", function() {
v = !0
}), e(".extension-preview-buttons .table-of-contents").on("click", "a", function(t) {
t.preventDefault();
var n = this.hash,
i = e(n);
if(i.length) {
var o = i[0].getBoundingClientRect().top - c.getBoundingClientRect().top + c.scrollTop;
c.scrollTop = o;
var a = r(o, m, f);
l.scrollTop = a
}
})
};
var _, k;
return a.onPagedownConfigure = function(e) {
_ = document.getElementById("preview-contents"), e.getConverter().hooks.chain("postConversion", function(e) {
return k = _.offsetHeight, _.style.height = k + "px", e
})
}, a.onPreviewFinished = function() {
_.style.removeProperty("height");
var e = _.offsetHeight;
b = !0, k > e && (C = !0), g()
}, a
}), define("text!html/buttonSyncSettingsBlock.html", [], function() {
return '
Adds a "Synchronize documents" button in the navigation bar.
\n
\n
\n \n
\n ms\n
\n
\n
\n \n
\n \n
\n
\n
'
}), define("extensions/buttonSync", ["jquery", "underscore", "crel", "utils", "classes/Extension", "mousetrap", "text!html/buttonSyncSettingsBlock.html"], function(e, t, n, i, r, o, a) {
var s = new r("buttonSync", 'Button "Synchronize"', !1, !0);
s.settingsBlock = a, s.defaultConfig = {
syncPeriod: 18e4,
syncShortcut: "mod+s"
}, s.onLoadSettings = function() {
i.setInputValue("#input-sync-period", s.config.syncPeriod), i.setInputValue("#input-sync-shortcut", s.config.syncShortcut)
}, s.onSaveSettings = function(e, t) {
e.syncPeriod = i.getInputIntValue("#input-sync-period", t, 0), e.syncShortcut = i.getInputTextValue("#input-sync-shortcut", t)
};
var l;
s.onSynchronizerCreated = function(e) {
l = e
};
var c, u = !1,
d = !1,
p = function() {
void 0 !== c && (u === !0 || l.hasSync() === !1 || d ? c.addClass("disabled") : c.removeClass("disabled"))
}, h = 0;
return s.onPeriodicRun = function() {
!s.config.syncPeriod || h + s.config.syncPeriod > i.currentTime || l.sync() && (h = i.currentTime)
}, s.onCreateButton = function() {
var t = n("a", {
"class": "btn btn-success button-synchronize",
title: "Force synchronization Ctrl/Cmd+S"
}, n("i", {
"class": "icon-refresh"
}));
return c = e(t), c.click(function() {
c.hasClass("disabled") || l.sync() && (h = i.currentTime)
}), t
}, s.onReady = p, s.onFileCreated = p, s.onFileDeleted = p, s.onSyncImportSuccess = p, s.onSyncExportSuccess = p, s.onSyncRemoved = p, s.onSyncRunning = function(e) {
u = e, p()
}, s.onOfflineChanged = function(e) {
d = e, p()
}, s.onReady = function() {
o.bind(s.config.syncShortcut, function(e) {
l.sync() && (h = i.currentTime), e.preventDefault()
}), e(".action-force-synchronization").click(function() {
l.sync() && (h = i.currentTime)
})
}, s
}), define("extensions/buttonPublish", ["jquery", "underscore", "crel", "classes/Extension"], function(e, t, n, i) {
function r() {
void 0 !== o && (c === !0 || u === !1 || d === !0 ? o.addClass("disabled") : o.removeClass("disabled"))
}
var o, a, s, l = new i("buttonPublish", 'Button "Publish"'),
c = !1,
u = !1,
d = !1;
l.onPublisherCreated = function(e) {
s = e
}, l.onCreateButton = function() {
var t = n("a", {
"class": "btn btn-success button-publish",
title: "Update document publication"
}, n("i", {
"class": "icon-upload"
}));
return o = e(t).click(function() {
o.hasClass("disabled") || s.publish()
}), t
}, l.onPublishRunning = function(e) {
c = e, r()
}, l.onOfflineChanged = function(e) {
d = e, r()
};
var p = function() {
u = 0 === t.size(a.publishLocations) ? !1 : !0, r()
};
return l.onFileSelected = function(e) {
a = e, p()
}, l.onReady = function() {
e(".action-update-publication").click(s.publish)
}, l.onPublishRemoved = p, l.onNewPublishSuccess = p, l
}), define("text!html/buttonStat.html", [], function() {
return '\n
StackEdit keeps getting better and I hope you appreciate it.
", "Please click Next to take a quick tour."].join(""),
placement: "bottom"
}, {
element: ".document-panel .toggle-button",
title: "Documents",
content: ['
The document panel allows you to manage your local documents.
', "Tip: Use Ctrl+[ and Ctrl+] to toggle documents."].join(""),
placement: "left",
reflex: !0
}, {
element: ".menu-panel .toggle-button",
title: "Menu",
content: ['
The menu panel allows you to synchronize your documents on Google Drive, Dropbox or to publish them on GitHub, Blogger...
', 'Tip: Use the menu panel to access the settings.'].join(""),
placement: "right",
reflex: !0
}, {
element: ".navbar-inner > .nav .button-open-discussion, .navbar .buttons-dropdown > .nav > .btn:not(:hidden)",
title: "Comments/discussions",
content: ['
New in StackEdit 4: the comments button lets you create inline discussions!
', "Tip: Reopen the Welcome Document from Settings>Utils to discover other new features."].join(""),
placement: "right",
reflex: !0
}, {
element: ".navbar-inner",
title: "Happy StackWriting!",
content: ['
Enjoy, and don\'t forget to rate 5 stars on the Chrome Web Store...
Tip: You can use a\n YAML front matter to specify the title of your page.
\n
Interpreted variables:title.
\n
\n
\n
About URL: For newly created page , Blogger API will append a generated number to the url like about-me-1234.html, if you deeply care about your URL naming, you should first create the page on Blogger and then update them with StackEdit specifying the pageId when publishing.\n
\n
About page visibility: Blogger API does not respect published status for pages.When publishing the page to Blogger, the page will be live but not added to the page listing. You should arrange the page listing from Blogger dashboard.\n
\n
\n
\n \n
\n
\n
\n\n\n
\n
\n
\n\n
\n \n
Publication
\n
\n
\n
\n "" is published on the following\n location(s):\n
\n \n
\n Note: Removing a publish location will not delete the actual publication.\n
\n
\n \n
\n
\n
\n\n\n
\n
\n
\n\n
\n \n
Sharing
\n
\n
\n
\n "" can be shared using the following link(s):\n
\n \n
No sharing link yet!\n
\n
To collaborate on this document, use Google Drive\n or Dropbox synchronization from the menu.\n
\n
To share a frozen version of this document within StackEdit, just publish it as a Gist in\n Markdown format from the menu.\n
\n
\n Tip: You can open any URL within StackEdit using viewer#!url=.\n
');
n.find("a").click(C), t.insertBefore(n[0], t.firstChild), O = O.add(n)
})
})
}, 1e3);
return c.addListener("onOfflineChanged", B), c.addListener("onReady", function() {
function n(e) {
if(e = e || "default", r != e) {
var t = "less!themes/" + e; - 1 !== window.baseDir.indexOf("-min") && (t = "css!themes/" + e), requirejs.undef(t), require([t]), r = e
}
}
e(".modal").on("shown.bs.modal", function() {
var t = e(this);
setTimeout(function() {
t.find(".btn:first").focus(), t.find("button:first").focus(), t.find("input:enabled:visible:first").focus()
}, 50)
}).on("hidden.bs.modal", function() {
i.focus(), n(window.theme)
}).keyup(function(t) {
13 != t.which || e(t.target).is("textarea") || e(this).find(".modal-footer a:last").click()
}), e(".action-insert-link").click(function(t) {
var n = a.getInputTextValue(e("#input-insert-link"), t);
void 0 !== n && (T.insertLinkCallback(n), T.insertLinkCallback = void 0)
}), e(".action-insert-image").click(function(t) {
var n = a.getInputTextValue(e("#input-insert-image"), t);
void 0 !== n && (T.insertLinkCallback(n), T.insertLinkCallback = void 0)
}), e(".modal-insert-link, .modal-insert-image").on("hidden.bs.modal", function() {
void 0 !== T.insertLinkCallback && (T.insertLinkCallback(null), T.insertLinkCallback = void 0)
}), e(".action-load-settings").click(function() {
y()
}), e(".action-apply-settings").click(function(e) {
x(e), e.isPropagationStopped() || window.location.reload()
}), e(".action-add-google-drive-account").click(function() {
3 !== l.gdriveMultiAccount && (l.gdriveMultiAccount++, s.settings = JSON.stringify(l), window.location.reload())
});
var r = window.theme;
A = e("#input-settings-theme"), A.on("change", function() {
n(this.value)
}), e(".action-import-docs-settings").click(function() {
e("#input-file-import-docs-settings").click()
});
var u;
if(e("#input-file-import-docs-settings").change(function(n) {
var i = (n.dataTransfer || n.target).files;
e(".modal-settings").modal("hide"), t.each(i, function(t) {
var n = new FileReader;
n.onload = function(t) {
return function(n) {
try {
u = JSON.parse(n.target.result);
var i = parseInt(u.version.match(/^v(\d+)$/)[1], 10),
r = parseInt(s.version.match(/^v(\d+)$/)[1], 10);
i > r ? c.onError("Incompatible version. Please upgrade StackEdit.") : e(".modal-import-docs-settings").modal("show")
} catch(o) {
c.onError("Wrong format: " + t.name)
}
e("#input-file-import-docs-settings").val("")
}
}(t), n.readAsText(t)
})
}), e(".action-import-docs-settings-confirm").click(function() {
s.clear();
var e = /^file\.|^folder\.|^publish\.|^settings$|^sync\.|^google\.|^author\.|^themeV3$|^version$/;
t.each(u, function(t, n) {
e.test(n) && (s[n] = t)
}), window.location.reload()
}), e(".action-export-docs-settings").click(function() {
a.saveAs(JSON.stringify(s), "StackEdit local storage.json")
}), e(".action-default-settings").click(function() {
s.removeItem("settings"), s.removeItem("theme"), l.dropboxFullAccess || s.removeItem("dropbox.lastChangeId"), window.location.reload()
}), e(".action-app-reset").click(function() {
s.clear(), window.location.reload()
}), e(".action-reset-input").click(function() {
a.resetModalInputs()
}), a.createTooltip(".tooltip-lazy-rendering", "Disable preview rendering while typing in order to offload CPU. Refresh preview after 500 ms of inactivity."), a.createTooltip(".tooltip-default-content", ["Thanks for supporting StackEdit by adding a backlink in your documents!
", 'NOTE: Backlinks in Stack Exchange Q/A are not welcome.'].join("")), a.createTooltip(".tooltip-template", h), e("div.dropdown-menu").click(function(e) {
e.stopPropagation()
}), e(".modal-non-unique").modal({
backdrop: "static",
keyboard: !1,
show: !1
}), t.each(document.querySelectorAll("img"), function(t) {
var n = e(t),
i = n.data("stackeditSrc");
i && n.attr("src", window.baseDir + "/img/" + i)
}), window.viewerMode === !1) {
var d = t.reduce(o.THEME_LIST, function(e, t, n) {
return e + '"
}, "");
document.getElementById("input-settings-theme").innerHTML = d
}
B()
}), T
}), define("text!WELCOME.md", [], function() {
return 'Welcome to StackEdit!\n===================\n\n\nHello, I\'m your first Markdown document in **StackEdit**[^stackedit]. Don\'t delete me, I can be helpful. I can be recovered anyway in the **Utils** tab of the **Settings** dialog.\n\n----------\n\n\nDocuments\n-------------\n\n**StackEdit** stores your documents in your browser, which means all your documents are automatically saved locally and are accessible **offline!**\n\n> **Note:**\n\n> - StackEdit is accessible offline after the application has been loaded for the first time.\n> - Your local documents are not shared between different browsers or computers.\n> - Clearing your browser\'s data may **delete all your local documents!** Make sure your documents are synchronized with your **Google Drive** or your **Dropbox** account (check out the [ Synchronization](#synchronization) section).\n\n#### Create a document\n\nThe document panel is accessible using button in the navigation bar. You can create a new document by clicking **New document** in the document panel.\n\n#### Switch to another document\n\nAll your local documents are listed in the document panel. You can switch from one to another by clicking a document in the list or you can toggle documents using Ctrl+[ and Ctrl+].\n\n#### Rename a document\n\nYou can rename the current document by clicking the document title in the navigation bar.\n\n#### Delete a document\n\nYou can delete the current document by clicking **Delete document** in the document panel.\n\n#### Export a document\n\nYou can save the current document to a file by clicking **Export to disk** from the menu panel.\n\n> **Tip:** Check out the [ Publish a document](#publish-a-document) section for a description of the different output formats.\n\n\n----------\n\n\nSynchronization\n-------------------\n\n**StackEdit** can be combined with **Google Drive** and **Dropbox** to have your documents centralized in the *Cloud*. The synchronization mechanism will take care of uploading your modifications or downloading the latest version of your documents.\n\n> **Note:**\n\n> - Full access to **Google Drive** or **Dropbox** is required to be able to import any document in StackEdit. Permission restrictions can be configured in the settings.\n> - Imported documents are downloaded in your browser and are not transmitted to a server.\n> - If you experience problems saving your documents on Google Drive, check and optionally disable browser extensions, such as Disconnect.\n\n#### Open a document\n\nYou can open a document from **Google Drive** or the **Dropbox** by opening the **Synchronize** sub-menu and by clicking **Open from...**. Once opened, any modification in your document will be automatically synchronized with the file in your **Google Drive** / **Dropbox** account.\n\n#### Save a document\n\nYou can save any document by opening the **Synchronize** sub-menu and by clicking **Save on...**. Even if your document is already synchronized with **Google Drive** or **Dropbox**, you can export it to a another location. **StackEdit** can synchronize one document with multiple locations and accounts.\n\n#### Synchronize a document\n\nOnce your document is linked to a **Google Drive** or a **Dropbox** file, **StackEdit** will periodically (every 3 minutes) synchronize it by downloading/uploading any modification. A merge will be performed if necessary and conflicts will be detected.\n\nIf you just have modified your document and you want to force the synchronization, click the button in the navigation bar.\n\n> **Note:** The button is disabled when you have no document to synchronize.\n\n#### Manage document synchronization\n\nSince one document can be synchronized with multiple locations, you can list and manage synchronized locations by clicking **Manage synchronization** in the **Synchronize** sub-menu. This will let you remove synchronization locations that are associated to your document.\n\n> **Note:** If you delete the file from **Google Drive** or from **Dropbox**, the document will no longer be synchronized with that location.\n\n----------\n\n\nPublication\n-------------\n\nOnce you are happy with your document, you can publish it on different websites directly from **StackEdit**. As for now, **StackEdit** can publish on **Blogger**, **Dropbox**, **Gist**, **GitHub**, **Google Drive**, **Tumblr**, **WordPress** and on any SSH server.\n\n#### Publish a document\n\nYou can publish your document by opening the **Publish** sub-menu and by choosing a website. In the dialog box, you can choose the publication format:\n\n- Markdown, to publish the Markdown text on a website that can interpret it (**GitHub** for instance),\n- HTML, to publish the document converted into HTML (on a blog for example),\n- Template, to have a full control of the output.\n\n> **Note:** The default template is a simple webpage wrapping your document in HTML format. You can customize it in the **Advanced** tab of the **Settings** dialog.\n\n#### Update a publication\n\nAfter publishing, **StackEdit** will keep your document linked to that publication which makes it easy for you to update it. Once you have modified your document and you want to update your publication, click on the button in the navigation bar.\n\n> **Note:** The button is disabled when your document has not been published yet.\n\n#### Manage document publication\n\nSince one document can be published on multiple locations, you can list and manage publish locations by clicking **Manage publication** in the menu panel. This will let you remove publication locations that are associated to your document.\n\n> **Note:** If the file has been removed from the website or the blog, the document will no longer be published on that location.\n\n----------\n\n\nMarkdown Extra\n--------------------\n\n**StackEdit** supports **Markdown Extra**, which extends **Markdown** syntax with some nice features.\n\n> **Tip:** You can disable any **Markdown Extra** feature in the **Extensions** tab of the **Settings** dialog.\n\n> **Note:** You can find more information about **Markdown** syntax [here][2] and **Markdown Extra** extension [here][3].\n\n\n### Tables\n\n**Markdown Extra** has a special syntax for tables:\n\nItem | Value\n-------- | ---\nComputer | $1600\nPhone | $12\nPipe | $1\n\nYou can specify column alignment with one or two colons:\n\n| Item | Value | Qty |\n| :------- | ----: | :---: |\n| Computer | $1600 | 5 |\n| Phone | $12 | 12 |\n| Pipe | $1 | 234 |\n\n\n### Definition Lists\n\n**Markdown Extra** has a special syntax for definition lists too:\n\nTerm 1\nTerm 2\n: Definition A\n: Definition B\n\nTerm 3\n\n: Definition C\n\n: Definition D\n\n > part of definition D\n\n\n### Fenced code blocks\n\nGitHub\'s fenced code blocks[^gfm] are also supported with **Prettify** syntax highlighting:\n\n```\n// Foo\nvar bar = 0;\n```\n\n> **Tip:** To use **Highlight.js** instead of **Prettify**, just configure the **Markdown Extra** extension in the **Settings** dialog.\n\n> **Note:** You can find more information:\n\n> - about **Prettify** syntax highlighting [here][5],\n> - about **Highlight.js** syntax highlighting [here][6].\n\n\n### Footnotes\n\nYou can create footnotes like this[^footnote].\n\n [^footnote]: Here is the *text* of the **footnote**.\n\n\n### SmartyPants\n\nSmartyPants converts ASCII punctuation characters into "smart" typographic punctuation HTML entities. For example:\n\n| | ASCII | HTML |\n ----------------- | ---------------------------- | ------------------\n| Single backticks | `\'Isn\'t this fun?\'` | \'Isn\'t this fun?\' |\n| Quotes | `"Isn\'t this fun?"` | "Isn\'t this fun?" |\n| Dashes | `-- is en-dash, --- is em-dash` | -- is en-dash, --- is em-dash |\n\n\n### Table of contents\n\nYou can insert a table of contents using the marker `[TOC]`:\n\n[TOC]\n\n\n### MathJax\n\nYou can render *LaTeX* mathematical expressions using **MathJax**, as on [math.stackexchange.com][1]:\n\nThe *Gamma function* satisfying $\\Gamma(n) = (n-1)!\\quad\\forall n\\in\\mathbb N$ is via the Euler integral\n\n$$\n\\Gamma(z) = \\int_0^\\infty t^{z-1}e^{-t}dt\\,.\n$$\n\n> **Tip:** Make sure you include **MathJax** into your publications to render mathematical expression properly. Your page/template should include something like this:\n\n```\n\n```\n\n> **Note:** You can find more information about **LaTeX** mathematical expressions [here][4].\n\n\n### UML diagrams\n\nYou can also render sequence diagrams like this:\n\n```sequence\nAlice->Bob: Hello Bob, how are you?\nNote right of Bob: Bob thinks\nBob-->Alice: I am good thanks!\n```\n\nAnd flow charts like this:\n\n```flow\nst=>start: Start\ne=>end\nop=>operation: My Operation\ncond=>condition: Yes or No?\n\nst->op->cond\ncond(yes)->e\ncond(no)->op\n```\n\n> **Note:** You can find more information:\n\n> - about **Sequence diagrams** syntax [here][7],\n> - about **Flow charts** syntax [here][8].\n\n [^stackedit]: [StackEdit](https://stackedit.io/) is a full-featured, open-source Markdown editor based on PageDown, the Markdown library used by Stack Overflow and the other Stack Exchange sites.\n\n [^gfm]: **GitHub Flavored Markdown** (GFM) is supported in StackEdit.\n\n\n [1]: http://math.stackexchange.com/\n [2]: http://daringfireball.net/projects/markdown/syntax "Markdown"\n [3]: https://github.com/jmcmanus/pagedown-extra "Pagedown Extra"\n [4]: http://meta.math.stackexchange.com/questions/5020/mathjax-basic-tutorial-and-quick-reference\n [5]: https://code.google.com/p/google-code-prettify/\n [6]: http://highlightjs.org/\n [7]: http://bramp.github.io/js-sequence-diagrams/\n [8]: http://adrai.github.io/flowchart.js/\n'
}), define("fileMgr", ["jquery", "underscore", "constants", "core", "utils", "storage", "settings", "eventMgr", "fileSystem", "classes/FileDescriptor", "text!WELCOME.md"], function(e, t, n, i, r, o, a, s, l, c, u) {
var d = {};
return d.currentFile = void 0, d.selectFile = function(r) {
if(r = r || d.currentFile, void 0 === r) {
var o = t.size(l);
r = 0 === o ? d.createFile(n.WELCOME_DOCUMENT_TITLE, u) : t.max(l, function(e) {
return e.selectTime || 0
})
}
d.currentFile !== r && (d.currentFile = r, r.selectTime = (new Date).getTime(), s.onFileSelected(r), e(".action-edit-document").toggleClass("hide", r.fileIndex != n.TEMPORARY_FILE_INDEX)), i.initEditor(r)
}, d.createFile = function(e, i, u, d, p) {
if(i = void 0 !== i ? i : a.defaultContent, !e) {
e = n.DEFAULT_FILE_TITLE;
for(var h = 2, f = function(t) {
return t.title == e
}; t.some(l, f);) e = n.DEFAULT_FILE_TITLE + h++
}
var m = n.TEMPORARY_FILE_INDEX;
if(!p)
do m = "file." + r.randomString(); while (t.has(l, m));
d = d || {};
var g = t.reduce(d, function(e, t) {
return r.storeAttributes(t), e + t.syncIndex + ";"
}, ";");
o[m + ".title"] = e, o[m + ".content"] = i, o[m + ".sync"] = g, o[m + ".publish"] = ";";
var v = new c(m, e, d);
return u && (v.discussionListJSON = u), p || (r.appendIndexToArray("file.list", m), l[m] = v, s.onFileCreated(v)), v
}, d.deleteFile = function(e) {
e = e || d.currentFile, e.folder && (e.folder.removeFile(e), s.onFoldersChanged()), r.removeIndexFromArray("file.list", e.fileIndex), delete l[e.fileIndex], d.currentFile === e && (d.currentFile = void 0, d.selectFile()), s.onFileDeleted(e)
}, d.getFileFromSyncIndex = function(e) {
return t.find(l, function(n) {
return t.has(n.syncLocations, e)
})
}, d.getFileFromPublishIndex = function(e) {
return t.find(l, function(n) {
return t.has(n.publishLocations, e)
})
}, s.addListener("onReady", function() {
function t() {
o.addClass("hide"), r.removeClass("hide");
var t = e.trim(o.val()),
n = d.currentFile;
t && t != n.title && (n.title = t, s.onTitleChanged(n)), o.val(n.title), i.focus()
}
var i = e("#wmd-input");
d.selectFile();
var r = e(".file-title-navbar"),
o = e(".input-file-title");
e(".action-create-file").click(function() {
setTimeout(function() {
var e = d.createFile();
d.selectFile(e), r.click()
}, 400)
}), e(".action-remove-file-confirm").click(function() {
e(".modal-remove-file-confirm").modal("show")
}), e(".action-remove-file").click(function() {
d.deleteFile()
}), r.click(function() {
if(window.viewerMode !== !0) {
r.addClass("hide");
var e = o.removeClass("hide");
setTimeout(function() {
e.focus().get(0).select()
}, 10)
}
}), o.blur(function() {
t()
}).keyup(function(e) {
13 == e.keyCode && t(), 27 == e.keyCode && (o.val(""), t())
}), e(".action-open-stackedit").click(function() {
window.location.href = "."
}), e(".action-edit-document").click(function() {
var e = i.val(),
t = d.currentFile.title,
n = d.createFile(t, e);
d.selectFile(n), window.location.href = "."
}), e(".action-welcome-file").click(function() {
var e = d.createFile(n.WELCOME_DOCUMENT_TITLE, u);
d.selectFile(e)
})
}), s.onFileMgrCreated(d), d
}), define("classes/Provider", ["underscore", "utils", "settings", "eventMgr", "fileMgr", "editor", "diff_match_patch_uncompressed", "jsondiffpatch"], function(e, t, n, i, r, o, a, s) {
function l(e, t) {
this.providerId = e, this.providerName = t, this.isPublishEnabled = !0
}
l.prototype.parseDiscussionList = function(t) {
try {
var n = JSON.parse(t);
return e.each(n, function(t, n) {
if(t.discussionIndex != n || !e.isNumber(t.selectionStart) || !e.isNumber(t.selectionEnd)) throw "invalid";
t.commentList && t.commentList.forEach(function(t) {
if(t.author && !e.isString(t.author) || !e.isString(t.content)) throw "invalid"
})
}), n
} catch(i) {}
}, l.prototype.serializeContent = function(e, t) {
return t.length > 2 ? e + "" : e
}, l.prototype.parseContent = function(e) {
var t, n = "{}",
i = /$/.exec(e);
return i && (t = this.parseDiscussionList(i[1])) && (e = e.substring(0, i.index), n = i[1]), {
content: e,
discussionList: t || {},
discussionListJSON: n
}
};
var c = new a;
c.Match_Threshold = 0, c.Patch_DeleteThreshold = 0;
var u = s.create({
objectHash: function(e) {
return JSON.stringify(e)
},
textDiff: {
minLength: 9999999
}
}),
d = "merge" == n.conflictMode;
return l.prototype.syncMerge = function(n, a, s, l, p, h) {
function f(e) {
function t() {
(i[1] || r[1]) && (i[1] && r[1] ? (i[1] = "⧸⧸" + i[1] + "⧸⧸", r[1] += "⧸⧸", n.push(i), n.push(r)) : n.push([0, i[1] + r[1]]), i = [-1, ""], r = [1, ""])
}
var n = [],
i = [-1, ""],
r = [1, ""],
o = 20;
return e.forEach(function(a, s) {
function l() {
return 0 === s || s === e.length - 1
}
var c = a[0],
u = a[1];
if(0 === c)
if(l() || u.length > o) {
if(i[1] || r[1]) {
var d = /\s/.exec(u);
if(d) {
var p = d.index,
h = u.substring(0, p);
u = u.substring(p), i[1] += h, r[1] += h
}
}
if(u) {
for(var f = u.length; f && /\S/.test(u[f - 1]);) f--;
var m = u.substring(f);
u = u.substring(0, f), l() || u.length > o ? (t(), n.push([0, u])) : (i[1] += u, r[1] += u), i[1] += m, r[1] += m
}
} else i[1] += u, r[1] += u;
else -1 === c ? i[1] += u : 1 === c && (r[1] += u)
}), i[1] == r[1] ? n.push([0, r[1]]) : t(), n
}
var m = n.content,
g = n.title,
v = n.discussionListJSON,
b = n.discussionList,
y = t.crc32(m),
x = t.crc32(g),
w = t.crc32(v),
S = t.crc32(s),
C = t.crc32(l),
_ = t.crc32(h),
k = a.contentCRC != y,
T = a.contentCRC != S,
E = m != s && T,
I = E && k;
a.titleCRC = a.titleCRC || x;
var D, N, L = a.titleCRC != x,
M = a.titleCRC != C,
A = g != l && M,
R = A && L,
P = a.discussionListCRC != w,
F = a.discussionListCRC != _,
O = v != h && F,
B = O && P,
j = [],
$ = s,
q = l,
G = p,
H = !1,
U = !1,
z = !1;
if(!d && (I || R || B) || I && void 0 === a.content || R && void 0 === a.title || B && void 0 === a.discussionList) r.createFile(g + " (backup)", m, v), i.onMessage('Conflict detected on "' + g + '". A backup has been created locally.');
else {
if(I) {
var V = a.content;
D = c.diff_main(V, m), c.diff_cleanupSemantic(D), N = c.patch_make(V, D);
var W = c.patch_apply(N, s);
if($ = W[0], !W[1].every(e.identity)) {
D = c.diff_main(m, $), D = f(D), $ = "";
var X;
D.forEach(function(e) {
var t = e[0],
n = e[1];
0 === t || X ? 0 === t && X && (X.selectionEnd = $.length, j.push(X), X = void 0) : X = {
selectionStart: $.length,
type: "conflict"
}, $ += n
}), X && (X.selectionEnd = $.length, j.push(X))
}
}
E && (P && (H = !0), F ? U = !0 : (H = !0, G = b)), B && (z = !0), R && (N = c.patch_make(a.title, g), q = c.patch_apply(N, l)[0])
}
var Q;
if(E) {
var Y = [];
r.currentFile === n && (Q = {
selectionStart: o.selectionMgr.selectionStart,
selectionEnd: o.selectionMgr.selectionEnd
}, Y.push(Q), n.newDiscussion && Y.push(n.newDiscussion)), H && (Y = Y.concat(e.values(b))), O |= o.adjustCommentOffsets(m, $, Y)
}
if(U) {
var K = e.values(p);
o.adjustCommentOffsets(s, $, K)
}
if(z) {
var J = JSON.parse(a.discussionList);
D = u.diff(J, b), u.patch(p, D), e.each(p, function(e, t) {
e || delete p[t]
})
}
return j.length && (O = !0, j.forEach(function(n) {
var i;
do i = t.randomString() + t.randomString(); while (e.has(G, i));
n.discussionIndex = i, G[i] = n
})), A && (n.title = q, i.onTitleChanged(n), i.onMessage('"' + g + '" has been renamed to "' + q + '" on ' + this.providerName + ".")), (E || O) && o.watcher.noWatch(e.bind(function() {
if(E && (r.currentFile === n && (o.setValueNoWatch($), Q && o.selectionMgr.setSelectionStartEnd(Q.selectionStart, Q.selectionEnd)), n.content = $, i.onContentChanged(n, $)), O) {
n.discussionList = G;
var t = u.diff(b, G),
a = !1;
e.each(t, function(t, r) {
e.isArray(t) ? 1 === t.length ? i.onDiscussionCreated(n, G[r]) : i.onDiscussionRemoved(n, b[r]) : a = !0
}), a && i.onCommentsChanged(n)
}
o.undoMgr.currentMode = "sync", o.undoMgr.saveState(), i.onMessage('"' + l + '" has been updated from ' + this.providerName + "."), j.length && i.onMessage('"' + l + '" has conflicts that you have to review.')
}, this)), {
contentCRC: S,
titleCRC: C,
discussionListCRC: _
}
}, l
}), define("classes/AsyncTask", ["underscore", "constants", "utils", "eventMgr"], function(e, t, n, i) {
function r(e) {
this.finished = !1, this.timeout = t.ASYNC_TASK_DEFAULT_TIMEOUT, this.retryCounter = 0, this.runCallbacks = [], this.successCallbacks = [], this.errorCallbacks = [], this.force = e
}
function o() {
if(c === !0) return void(l + u.timeout < n.currentTime && u.error(new Error("A timeout occurred.")));
if(void 0 === u) {
if(0 === s.length || !s[0].force && p === !1) return;
u = s.shift(), l = n.currentTime, d === !1 && (d = !0, i.onAsyncRunning(!0))
}
l <= n.currentTime && (c = !0, u.chain())
}
function a(t, n, r) {
try {
e.each(n, function(e) {
e(r)
})
} finally {
t.finished = !0, u === t && (u = void 0, c = !1), 0 === s.length ? (d = !1, i.onAsyncRunning(!1)) : o()
}
}
var s = [];
r.prototype.onRun = function(e) {
this.runCallbacks.push(e)
}, r.prototype.onSuccess = function(e) {
this.successCallbacks.push(e)
}, r.prototype.onError = function(e) {
this.errorCallbacks.push(e)
};
var l = 0;
r.prototype.chain = function(e) {
if(l = n.currentTime, n.logStackTrace(), this.finished !== !0) {
if(void 0 === this.queue && (this.queue = this.runCallbacks.slice()), void 0 !== e) return void e();
if(0 === this.queue.length) return void a(this, this.successCallbacks);
var t = this.queue.shift();
t()
}
}, r.prototype.error = function(e) {
if(n.logStackTrace(), this.finished !== !0) throw e = e || new Error("Unknown error"), e.message && i.onError(e), a(this, this.errorCallbacks, e), e
};
var c = !1;
r.prototype.retry = function(e, t) {
if(this.finished !== !0) {
if(t = t || 5, this.queue = void 0, this.retryCounter >= t) return void this.error(e);
var i = 1e3 * Math.pow(2, this.retryCounter++);
l = n.currentTime + i, c = !1, o()
}
}, r.prototype.enqueue = function() {
s.push(this), o()
};
var u, d = !1,
p = !1;
return i.addListener("onUserActive", function() {
p = !0
}), i.addListener("onPeriodicRun", o), r
}), define("helpers/dropboxHelper", ["jquery", "underscore", "constants", "core", "utils", "storage", "logger", "settings", "eventMgr", "classes/AsyncTask"], function(e, t, n, i, r, o, a, s, l, c) {
function u(t) {
t.onRun(function() {
return v === !0 ? (f = void 0, void t.error(new Error("Operation not available in offline mode.|stopPublish"))) : void 0 !== f ? void t.chain() : void e.ajax({
url: "libs/dropbox.min.js",
dataType: "script",
timeout: n.AJAX_TIMEOUT
}).done(function() {
f = new Dropbox.Client({
key: s.dropboxFullAccess === !0 ? n.DROPBOX_APP_KEY : n.DROPBOX_RESTRICTED_APP_KEY,
secret: s.dropboxFullAccess === !0 ? n.DROPBOX_APP_SECRET : n.DROPBOX_RESTRICTED_APP_SECRET
}), f.authDriver(new Dropbox.AuthDriver.Popup({
receiverUrl: n.BASE_URL + "html/dropbox-oauth-receiver.html",
rememberUser: !0
})), t.chain()
}).fail(function(e) {
var n = {
status: e.status,
responseText: e.statusText
};
p(n, t)
})
})
}
function d(e) {
e.onRun(function() {
function t() {
r.redirectConfirm("You are being redirected to Dropbox authorization page.", function() {
e.chain(i)
}, function() {
e.error(new Error("Operation canceled."))
})
}
function i() {
o === !1 ? e.timeout = n.ASYNC_TASK_LONG_TIMEOUT : f.reset(), f.authenticate({
interactive: !o
}, function(n, i) {
return i.isAuthenticated() === !0 ? (m = !0, void e.chain()) : o === !0 ? (o = !1, void e.chain(t)) : void e.error(new Error("Access to Dropbox account is not authorized."))
})
}
if(m === !0) return void e.chain();
var o = !0;
e.chain(i)
})
}
function p(e, n) {
var r = !0;
if(e)
if(a.error(e), "string" == typeof e) r = e;
else {
if(r = "Dropbox error (" + e.status + ": " + e.responseText + ").", 401 === e.status || 403 === e.status) return m = !1, r = "Access to Dropbox account is not authorized.", void n.retry(new Error(r), 1);
if(400 === e.status && -1 !== e.responseText.indexOf("oauth_nonce")) return t.each(t.keys(o), function(e) {
0 === e.indexOf("dropbox-auth") && o.removeItem(e)
}), m = !1, void n.retry(new Error(r), 1);
e.status <= 0 && (f = void 0, m = !1, i.setOffline(), r = "|stopPublish")
}
n.error(new Error(r))
}
function h(t) {
t.onRun(function() {
function i() {
r.redirectConfirm("You are being redirected to Dropbox Chooser page.", function() {
t.chain()
}, function() {
t.error(new Error("Operation canceled."))
})
}
return b === !0 ? void t.chain() : void e.ajax({
url: "https://www.dropbox.com/static/api/1/dropbox.js",
dataType: "script",
timeout: n.AJAX_TIMEOUT
}).done(function() {
b = !0, t.chain(i)
}).fail(function(e) {
var n = {
status: e.status,
responseText: e.statusText
};
p(n, t)
})
})
}
var f, m = !1,
g = {}, v = !1;
l.addListener("onOfflineChanged", function(e) {
v = e
}), g.upload = function(e, t, n) {
var i, r = new c;
u(r), d(r), r.onRun(function() {
f.writeFile(e, t, function(t, n) {
return t ? (400 === t.status && (t = 'Could not upload document into path "' + e + '".'), void p(t, r)) : (i = n, void r.chain())
})
}), r.onSuccess(function() {
n(void 0, i)
}), r.onError(function(e) {
n(e)
}), r.enqueue()
}, g.checkChanges = function(e, t) {
var n = [],
i = e || 0,
r = new c;
u(r), d(r), r.onRun(function() {
function e() {
f.pullChanges(i, function(t, o) {
return t ? void p(t, r) : (i = o.cursor(), void 0 !== o.changes && (n = n.concat(o.changes)), void(o.shouldPullAgain ? r.chain(e) : r.chain()))
})
}
r.chain(e)
}), r.onSuccess(function() {
t(void 0, n, i)
}), r.onError(function(e) {
t(e)
}), r.enqueue()
}, g.downloadMetadata = function(e, t) {
var n = [],
i = new c;
u(i), d(i), i.onRun(function() {
function t() {
if(0 === e.length) return void i.chain();
var r = e[0];
f.stat(r, function(r, o) {
return o ? (n.push(o), e.shift(), void i.chain(t)) : void p(r, i)
})
}
i.chain(t)
}), i.onSuccess(function() {
t(void 0, n)
}), i.onError(function(e) {
t(e)
}), i.enqueue()
}, g.downloadContent = function(e, n) {
var i = [],
r = new c;
u(r), d(r), r.onRun(function() {
function n() {
if(0 === e.length) return void r.chain();
var o = e[0];
i.push(o);
var a;
return o.isFile === !0 ? a = o : void 0 !== o.wasRemoved && (a = o.stat), a ? void f.readFile(a.path, function(i, o) {
return t.isString(o) ? (a.content = o, e.shift(), void r.chain(n)) : void p(i, r)
}) : (e.shift(), void r.chain(n))
}
r.chain(n)
}), r.onSuccess(function() {
n(void 0, i)
}), r.onError(function(e) {
n(e)
}), r.enqueue()
};
var b = !1;
return g.picker = function(e) {
var t = [],
i = new c;
i.timeout = n.ASYNC_TASK_LONG_TIMEOUT, u(i), h(i), i.onRun(function() {
var e = {};
e.multiselect = !0, e.linkType = "direct", e.success = function(e) {
for(var n = 0; n < e.length; n++) {
var r = e[n].link;
r = r.replace(/.*\/view\/[^\/]*/, ""), t.push(decodeURI(r))
}
i.chain()
}, e.cancel = function() {
i.chain()
}, Dropbox.choose(e)
}), i.onSuccess(function() {
e(void 0, t)
}), i.onError(function(t) {
e(t)
}), i.enqueue()
}, g
}), define("providers/dropboxProvider", ["underscore", "utils", "storage", "settings", "classes/Provider", "eventMgr", "fileMgr", "helpers/dropboxHelper"], function(e, t, n, i, r, o, a, s) {
function l(e) {
return void 0 === e ? void 0 : e.match(/^[^\\<>:"\|?\*]+$/) ? 0 !== e.indexOf("/") ? "/" + e : e : void o.onError('"' + e + '" contains invalid characters.')
}
function c(e) {
return "sync." + p + "." + encodeURIComponent(e.toLowerCase())
}
function u(e, n, i, r) {
r = r || "{}";
var o = {};
return o.provider = h, o.path = e, o.version = n, o.contentCRC = t.crc32(i), o.discussionListCRC = t.crc32(r), o.syncIndex = c(e), f === !0 && (o.content = i, o.discussionList = r), o
}
function d(t) {
s.downloadMetadata(t, function(t, n) {
t || s.downloadContent(n, function(t, n) {
if(!t) {
var i = [];
e.each(n, function(e) {
var t = h.parseContent(e.content),
n = u(e.path, e.versionTag, t.content, t.discussionListJSON),
r = {};
r[n.syncIndex] = n;
var o = a.createFile(e.name, t.content, t.discussionListJSON, r);
a.selectFile(o), i.push(o)
}), 0 !== i.length && o.onSyncImportSuccess(i, h)
}
})
})
}
var p = "dropbox",
h = new r(p, "Dropbox");
h.defaultPublishFormat = "template";
var f = "merge" == i.conflictMode;
return h.importFiles = function() {
s.picker(function(t, n) {
if(!t && 0 !== n.length) {
var i = [];
e.each(n, function(e) {
var t = c(e),
n = a.getFileFromSyncIndex(t);
return void 0 !== n ? o.onError('"' + n.title + '" was already imported.') : void i.push(e)
}), d(i)
}
})
}, h.exportFile = function(e, n, i, r, d) {
var p = t.getInputTextValue("#input-sync-export-dropbox-path", e);
if(p = l(p), void 0 === p) return d(!0);
var f = c(p),
m = a.getFileFromSyncIndex(f);
if(void 0 !== m) {
var g = m.title;
return o.onError('File path is already synchronized with "' + g + '".'), d(!0)
}
var v = h.serializeContent(i, r);
s.upload(p, v, function(e, t) {
if(e) return d(e);
var n = u(t.path, t.versionTag, i, r);
d(void 0, n)
})
}, h.syncUp = function(e, t, n, i, r, o, a, l) {
if(a.contentCRC == t && a.discussionListCRC == o) return l(void 0, !1);
var c = h.serializeContent(e, r);
s.upload(a.path, c, function(n, s) {
return n ? l(n, !0) : (a.version = s.versionTag, f === !0 && (a.content = e, a.discussionList = r), a.contentCRC = t, a.titleCRC = i, a.discussionListCRC = o, void l(void 0, !0))
})
}, h.syncDown = function(i) {
var r = n[p + ".lastChangeId"];
s.checkChanges(r, function(r, l, u) {
if(r) return i(r);
var d = [];
e.each(l, function(e) {
var t = c(e.path),
n = a.getFileFromSyncIndex(t),
i = n && n.syncLocations[t];
return i ? (e.fileDesc = n, e.syncAttributes = i, e.wasRemoved === !0 ? void d.push(e) : void(i.version != e.stat.versionTag && d.push(e))) : void 0
}), s.downloadContent(d, function(e, r) {
function a() {
if(0 === r.length) return n[p + ".lastChangeId"] = u, i();
var e = r.pop(),
s = e.fileDesc,
l = e.syncAttributes;
if(e.wasRemoved === !0) return o.onError('"' + s.title + '" has been removed from Dropbox.'), s.removeSyncLocation(l), o.onSyncRemoved(s, l);
var c = e.stat,
d = h.parseContent(c.content),
m = d.content,
g = d.discussionListJSON,
v = d.discussionList,
b = h.syncMerge(s, l, m, s.title, v, g);
l.version = c.versionTag, f === !0 && (l.content = m, l.discussionList = v), l.contentCRC = b.contentCRC, l.discussionListCRC = b.discussionListCRC, t.storeAttributes(l), setTimeout(a, 5)
}
return e ? void i(e) : void setTimeout(a, 5)
})
})
}, h.publish = function(e, t, n, i, r) {
var o = l(e.path);
return void 0 === o ? r(!0) : void s.upload(o, i, r)
}, h.newPublishAttributes = function(e) {
var n = {};
return n.path = t.getInputTextValue("#input-publish-dropbox-path", e), e.isPropagationStopped() ? void 0 : n
}, h
}), define("helpers/googleHelper", ["underscore", "jquery", "constants", "core", "utils", "storage", "logger", "settings", "eventMgr", "classes/AsyncTask"], function(e, t, n, i, r, o, a, s, l, c) {
function u(t) {
var n = {
profile: !0
}, i = !0;
e.each((o[t + ".permissions"] || "").split(";"), function(e) {
e && (n[e] = !0)
}), this.setRefreshFlag = function() {
i = !0
}, this.isAuthorized = function(t) {
return i === !1 && e.has(n, t)
}, this.add = function(r) {
n[r] = !0, o[t + ".permissions"] = e.keys(n).join(";"), i = !1
}, this.getListWithNew = function(t) {
var i = e.keys(n);
return e.has(n, t) || i.push(t), i
};
var r = o[t + ".userId"];
this.setUserId = function(e) {
r = e, o[t + ".userId"] = r
}, this.getUserId = function() {
return r
}
}
function d(e) {
e.onRun(function() {
return y === !0 ? (g = !1, e.error(new Error("Operation not available in offline mode.|stopPublish"))) : g === !0 ? e.chain() : (window.delayedFunction = function() {
gapi.load("client", function() {
gapi.client.load("drive", "v2", function() {
g = !0, e.chain()
})
})
}, void t.ajax({
url: "https://apis.google.com/js/api.js?onload=runDelayedFunction",
dataType: "script",
timeout: n.AJAX_TIMEOUT
}).fail(function(t) {
var n = {
code: t.status,
message: t.statusText
};
f(n, e)
}))
})
}
function p(i, o, a) {
var s = v[a];
s || (s = new u(a), v[a] = s), i.onRun(function() {
function a() {
t.ajax({
url: "https://www.googleapis.com/oauth2/v1/tokeninfo",
data: {
access_token: d.access_token
},
timeout: n.AJAX_TIMEOUT,
type: "GET"
}).done(function(e) {
s.getUserId() && s.getUserId() != e.user_id ? u() : (s.setUserId(e.user_id), s.add(o), s.token = d, i.chain())
}).fail(function(e) {
var t = {
code: e.status,
message: e.statusText
};
f(t, i)
})
}
function l() {
if(m > 5) return i.error(new Error("Unable to authenticate user " + s.getUserId() + ", please sign in with Google."));
p === !1 && (i.timeout = n.ASYNC_TASK_LONG_TIMEOUT);
var t = e.chain(x).pick(s.getListWithNew(o)).flatten().value();
gapi.auth.authorize({
client_id: n.GOOGLE_CLIENT_ID,
scope: t,
immediate: p,
authuser: p === !1 ? "" : m
}, function(e) {
d = gapi.auth.getToken(), gapi.auth.setToken(h), !e || e.error ? g === !0 && p === !0 ? (p = !1, i.chain(c)) : i.error(new Error("Access to Google account is not authorized.")) : (p === !0 && m++, i.chain(a))
})
}
function c() {
return p === !0 ? i.chain(l) : void r.redirectConfirm("You are being redirected to Google authorization page.", function() {
i.chain(l)
}, function() {
i.error(new Error("Operation canceled."))
})
}
function u() {
return p = !0, s.token && s.isAuthorized(o) ? void i.chain() : (s.getUserId() || (p = !1), void i.chain(c))
}
var d, p, h = gapi.auth.getToken(),
m = 0;
u()
})
}
function h(e, t) {
var n = gapi.auth.getToken(),
i = v[e];
gapi.auth.setToken(i.token), t(), gapi.auth.setToken(n)
}
function f(t, n) {
var r;
if(t)
if(a.error(t), "string" == typeof t) r = t;
else {
if(r = "Google error (" + t.code + ": " + t.message + ").", t.code >= 500 && t.code < 600) return n.retry(new Error(r));
if(401 === t.code || 403 === t.code || "token_refresh_required" == t.code) return e.each(v, function(e) {
e.setRefreshFlag()
}), r = "Access to Google account is not authorized.", n.retry(new Error(r), 1);
(0 === t.code || -1 === t.code) && (g = !1, e.each(v, function(e) {
e.setRefreshFlag()
}), i.setOffline(), r = "|stopPublish")
}
n.error(new Error(r))
}
function m(e) {
e.onRun(function() {
return w === !0 ? e.chain() : void t.ajax({
url: "//www.google.com/jsapi",
data: {
key: n.GOOGLE_API_KEY
},
dataType: "script",
timeout: n.AJAX_TIMEOUT
}).done(function() {
google.load("picker", "1", {
callback: function() {
e.chain()
}
}), w = !0
}).fail(function(t) {
var n = {
code: t.status,
message: t.statusText
};
f(n, e)
})
})
}
var g = !1,
v = {}, b = {}, y = !1;
l.addListener("onOfflineChanged", function(e) {
y = e
});
var x = {
profile: ["https://www.googleapis.com/auth/userinfo.profile"],
gdrive: ["https://www.googleapis.com/auth/drive.install", s.gdriveFullAccess === !0 ? "https://www.googleapis.com/auth/drive" : "https://www.googleapis.com/auth/drive.file"],
blogger: ["https://www.googleapis.com/auth/blogger"],
picasa: ["https://www.googleapis.com/auth/photos"]
};
b.refreshGdriveToken = function(e) {
var t = new c;
d(t);
var n = v[e];
n && n.setRefreshFlag(), p(t, "gdrive", e), t.enqueue()
}, b.upload = function(e, t, n, i, a, l, u, m) {
var g, v = new c;
d(v), p(v, "gdrive", u), v.onRun(function() {
var l = "-------314159265358979323846",
c = "\r\n--" + l + "\r\n",
d = "\r\n--" + l + "--";
a = a || s.markdownMimeType;
var p = {
title: n,
mimeType: a
};
t && (p.parents = [{
kind: "drive#fileLink",
id: t
}]);
var m = "/upload/drive/v2/files",
b = "POST";
e && (m += "/" + e, b = "PUT");
var y = {
"Content-Type": 'multipart/mixed; boundary="' + l + '"'
}, x = r.encodeBase64(i),
w = [c, "Content-Type: application/json\r\n\r\n", JSON.stringify(p), c, "Content-Type: ", a, "\r\n", "Content-Transfer-Encoding: base64\r\n", "\r\n", x, d].join("");
h(u, function() {
var t = gapi.client.request({
path: m,
method: b,
params: {
uploadType: "multipart"
},
headers: y,
body: w
});
t.execute(function(t) {
if(t && t.id) return g = t, g.content = i, v.chain();
var n = t.error;
void 0 !== n && void 0 !== e && (404 === n.code ? n = 'File ID "' + e + '" not found on Google Drive.|removePublish' : 412 === n.code && (o.removeItem(u + ".gdrive.lastChangeId"), n = 'Conflict on file ID "' + e + '". Please restart the synchronization.')), f(n, v)
})
})
}), v.onSuccess(function() {
m(void 0, g)
}), v.onError(function(e) {
m(e)
}), v.enqueue()
}, b.rename = function(e, t, n, i) {
var r, o = new c;
d(o), p(o, "gdrive", n), o.onRun(function() {
var i = {
title: t
};
h(n, function() {
var t = gapi.client.drive.files.patch({
fileId: e,
resource: i
});
t.execute(function(t) {
if(t && t.id) return r = t, o.chain();
var n = t.error;
void 0 !== n && void 0 !== e && 404 === n.code && (n = 'File ID "' + e + '" not found on Google Drive.|removePublish'), f(n, o)
})
})
}), o.onSuccess(function() {
i(void 0, r)
}), o.onError(function(e) {
i(e)
}), o.enqueue()
}, b.checkChanges = function(e, t, n) {
var i = [],
r = e || 0,
o = new c;
d(o), p(o, "gdrive", t), o.onRun(function() {
function e() {
h(t, function() {
var t;
t = gapi.client.drive.changes.list(void 0 === n ? {
startChangeId: r + 1
} : {
pageToken: n
}), t.execute(function(t) {
return t && t.largestChangeId ? (r = t.largestChangeId, n = t.nextPageToken, void 0 !== t.items && (i = i.concat(t.items)), void(void 0 !== n ? o.chain(e) : o.chain())) : f(t.error, o)
})
})
}
var n;
o.chain(e)
}), o.onSuccess(function() {
n(void 0, i, r)
}), o.onError(function(e) {
n(e)
}), o.enqueue()
}, b.downloadMetadata = function(e, i, r, o) {
var a = [],
s = new c;
d(s), o || p(s, "gdrive", i), s.onRun(function() {
function r() {
if(0 === e.length) return s.chain();
var o = e[0],
l = {}, c = v[i];
c && c.token && (l.Authorization = "Bearer " + c.token.access_token), t.ajax({
url: "https://www.googleapis.com/drive/v2/files/" + o,
headers: l,
data: {
key: n.GOOGLE_API_KEY
},
dataType: "json",
timeout: n.AJAX_TIMEOUT
}).done(function(t) {
a.push(t), e.shift(), s.chain(r)
}).fail(function(e) {
var t = {
code: e.status,
message: e.statusText
};
404 === t.code && (t = 'File ID "' + o + '" not found on Google Drive.'), f(t, s)
})
}
s.chain(r)
}), s.onSuccess(function() {
r(void 0, a)
}), s.onError(function(e) {
r(e)
}), s.enqueue()
}, b.downloadContent = function(e, i, r, o) {
var a = [],
s = new c;
s.timeout = n.ASYNC_TASK_LONG_TIMEOUT, d(s), o || p(s, "gdrive", i), s.onRun(function() {
function r() {
if(0 === e.length) return s.chain();
var o = e[0];
a.push(o);
var l;
if("drive#file" == o.kind ? l = o : "drive#change" == o.kind && (l = o.file), !l) return e.shift(), s.chain(r);
var c = l.downloadUrl;
0 === l.mimeType.indexOf("application/vnd.google-apps.drive-sdk") && (l.isRealtime = !0, c = "https://www.googleapis.com/drive/v2/files/" + l.id + "/realtime");
var u = {}, d = v[i];
d && d.token && (u.Authorization = "Bearer " + d.token.access_token), t.ajax({
url: c,
headers: u,
data: {
key: n.GOOGLE_API_KEY
},
dataType: l.isRealtime ? "json" : "text",
timeout: n.AJAX_TIMEOUT
}).done(function(t) {
l.content = l.isRealtime ? t.data.value.content.value : t, e.shift(), s.chain(r)
}).fail(function(e) {
var t = {
code: e.status,
message: e.statusText
};
f(t, s)
})
}
s.chain(r)
}), s.onSuccess(function() {
r(void 0, a)
}), s.onError(function(e) {
r(e)
}), s.enqueue()
}, b.uploadImg = function(e, i, r, o) {
var a, s = "google.picasa0",
l = new c;
d(l), p(l, "picasa", s), l.onRun(function() {
var o = {
Slug: e
};
e.match(/.jpe?g$/i) ? o["Content-Type"] = "image/jpeg" : e.match(/.png$/i) ? o["Content-Type"] = "image/png" : e.match(/.gif$/i) && (o["Content-Type"] = "image/gif");
var c = v[s];
c && c.token && (o.Authorization = "Bearer " + c.token.access_token), t.ajax({
url: n.PICASA_PROXY_URL + "upload/" + r,
headers: o,
data: i,
processData: !1,
dataType: "xml",
timeout: n.AJAX_TIMEOUT,
type: "POST"
}).done(function(e) {
a = e, l.chain()
}).fail(function(e) {
var t = {
code: e.status,
message: e.statusText
};
200 == t.code && (t.message = e.responseText), f(t, l)
})
}), l.onSuccess(function() {
o(void 0, a)
}), l.onError(function(e) {
o(e)
}), l.enqueue()
};
var w = !1;
return b.picker = function(e, i, o) {
function a() {
void 0 !== s && (s.setVisible(!1), t(".modal-backdrop, .picker").remove())
}
var s, l = [],
u = new c;
u.timeout = n.ASYNC_TASK_LONG_TIMEOUT, d(u), "doc" == i || "folder" == i ? p(u, "gdrive", o) : (o = "google.picasa0", p(u, "picasa", o)), m(u), u.onRun(function() {
var e = v[o],
c = new google.picker.PickerBuilder;
c.setAppId(n.GOOGLE_DRIVE_APP_ID);
var d;
"doc" == i ? (d = new google.picker.DocsView(google.picker.ViewId.DOCS), d.setParent("root"), d.setIncludeFolders(!0), d.setMimeTypes(["text/x-markdown", "text/plain", "application/octet-stream", "application/vnd.google-apps.drive-sdk." + n.GOOGLE_DRIVE_APP_ID].join(",")), c.enableFeature(google.picker.Feature.NAV_HIDDEN), c.enableFeature(google.picker.Feature.MULTISELECT_ENABLED), c.addView(d), e && e.token && c.setOAuthToken(e.token.access_token)) : "folder" == i ? (d = new google.picker.DocsView(google.picker.ViewId.FOLDERS), d.setParent("root"), d.setIncludeFolders(!0), d.setSelectFolderEnabled(!0), d.setMimeTypes("application/vnd.google-apps.folder"), c.enableFeature(google.picker.Feature.NAV_HIDDEN), c.addView(d), e && e.token && c.setOAuthToken(e.token.access_token)) : "img" == i && (d = new google.picker.PhotosView, d.setType("flat"), c.addView(d), d = new google.picker.PhotosView, d.setType("ofuser"), c.addView(d), c.addView(google.picker.ViewId.PHOTO_UPLOAD), e && e.token && c.setOAuthToken(e.token.access_token)), c.setCallback(function(e) {
(e.action == google.picker.Action.PICKED || e.action == google.picker.Action.CANCEL) && (e.action == google.picker.Action.PICKED && (l = e.docs), a(), u.chain())
}), s = c.build(), t(r.createBackdrop()).on("click.backdrop", function() {
a(), u.chain()
}), s.setVisible(!0)
}), u.onSuccess(function() {
e(void 0, l)
}), u.onError(function(t) {
a(), e(t)
}), u.enqueue()
}, b.uploadBlogger = function(e, i, r, o, a, s, l, u, h) {
var m = "google.blogger0",
g = new c;
d(g), p(g, "blogger", m), g.onRun(function() {
function c() {
var e = "https://www.googleapis.com/blogger/v3/blogs/" + i + "/posts/",
a = {
kind: "blogger#post",
blog: {
id: i
},
labels: o,
title: l,
content: u
};
s && (a.published = s.toISOString());
var c = "POST";
void 0 !== r && (e += r, a.id = r, c = "PUT"), t.ajax({
url: e,
data: JSON.stringify(a),
headers: h,
type: c,
contentType: "application/json",
dataType: "json",
timeout: n.AJAX_TIMEOUT
}).done(function(e) {
r = e.id, g.chain(d)
}).fail(function(e) {
var t = {
code: e.status,
message: e.statusText
};
404 === t.code && void 0 !== r && (t = "Post " + r + " not found on Blogger.|removePublish"), f(t, g)
})
}
function d() {
var e = "https://www.googleapis.com/blogger/v3/blogs/" + i + "/posts/" + r;
a ? e += "/revert" : (e += "/publish", s && (e += "?publishDate=" + s.toISOString())), t.ajax({
url: e,
headers: h,
type: "POST",
dataType: "json",
timeout: n.AJAX_TIMEOUT
}).done(function() {
g.chain()
}).fail(function(e) {
var t = {
code: e.status,
message: e.statusText
};
404 === t.code && (t = "Post " + r + " not found on Blogger.|removePublish"), f(t, g)
})
}
function p() {
return void 0 !== i ? void g.chain(c) : void t.ajax({
url: "https://www.googleapis.com/blogger/v3/blogs/byurl",
data: {
url: e
},
headers: h,
dataType: "json",
timeout: n.AJAX_TIMEOUT
}).done(function(e) {
i = e.id, g.chain(c)
}).fail(function(t) {
var n = {
code: t.status,
message: t.statusText
};
404 === n.code && (n = 'Blog "' + e + '" not found on Blogger.|removePublish'), f(n, g)
})
}
var h = {}, b = v[m];
b && b.token && (h.Authorization = "Bearer " + b.token.access_token), g.chain(p)
}), g.onSuccess(function() {
h(void 0, i, r)
}), g.onError(function(e) {
h(e)
}), g.enqueue()
}, b.uploadBloggerPage = function(e, i, r, o, a, s, l, u) {
var h = "google.blogger0",
m = new c;
d(m), p(m, "blogger", h), m.onRun(function() {
function o() {
var e = "https://www.googleapis.com/blogger/v3/blogs/" + i + "/pages/",
o = {
kind: "blogger#page",
blog: {
id: i
},
title: s,
content: l
}, a = "POST";
void 0 !== r && (e += r, o.id = r, a = "PUT"), t.ajax({
url: e,
data: JSON.stringify(o),
headers: c,
type: a,
contentType: "application/json",
dataType: "json",
timeout: n.AJAX_TIMEOUT
}).done(function(e) {
r = e.id, m.chain()
}).fail(function(e) {
var t = {
code: e.status,
message: e.statusText
};
404 === t.code && void 0 !== r && (t = "Page " + r + " not found on Blogger.|removePublish"), f(t, m)
})
}
function a() {
return void 0 !== i ? void m.chain(o) : void t.ajax({
url: "https://www.googleapis.com/blogger/v3/blogs/byurl",
data: {
url: e
},
headers: c,
dataType: "json",
timeout: n.AJAX_TIMEOUT
}).done(function(e) {
i = e.id, m.chain(o)
}).fail(function(t) {
var n = {
code: t.status,
message: t.statusText
};
404 === n.code && (n = 'Blog "' + e + '" not found on Blogger.|removePublish'), f(n, m)
})
}
var c = {}, u = v[h];
u && u.token && (c.Authorization = "Bearer " + u.token.access_token), m.chain(a)
}), m.onSuccess(function() {
u(void 0, i, r)
}), m.onError(function(e) {
u(e)
}), m.enqueue()
}, window.delayedFunction = void 0, window.runDelayedFunction = function() {
void 0 !== window.delayedFunction && window.delayedFunction()
}, b
}), define("text!html/dialogExportGdrive.html", [], function() {
return '
\n
\n\n
\n \n
Save on <%= providerName %>
\n
\n
\n
\n This will save "" to your \n Google Drive\n account and keep it synchronized.\n
\n
\n
\n \n
\n
\n \n
\n \n
\n
\n If no folder ID is supplied, the\n file will be created in your root folder. \n
\n
\n
\n \n
\n This will overwrite the existing file\n on the server. \n