UNPKG

snakeskin

Version:
1,947 lines (1,599 loc) 286 kB
/*! * Snakeskin v7.5.1 * https://github.com/SnakeskinTpl/Snakeskin * * Released under the MIT license * https://github.com/SnakeskinTpl/Snakeskin/blob/master/LICENSE * * Date: 'Fri, 21 Sep 2018 15:57:43 GMT */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define('Snakeskin', factory) : (global.Snakeskin = factory()); }(this, (function () { 'use strict'; var Snakeskin = void 0; var Snakeskin$1 = Snakeskin = { VERSION: [7, 5, 1] }; /** * The operation UID * @type {?string} */ Snakeskin.UID = null; /** * The namespace for directives * @const */ Snakeskin.Directives = {}; /** * The namespace for filters * @const */ Snakeskin.Filters = {}; /** * The namespace for super-global variables * @const */ Snakeskin.Vars = { /** * Decorator for template overriding * * @param {string} name * @return {!Function} */ override: function override(name) { return function (fn, ctx) { return ctx[name] = fn; }; }, /** * Decorator for template ignoring * @param {!Function} fn */ ignore: function ignore(fn) { fn.ignore = true; } }; /** * The namespace for local variables * @const */ Snakeskin.LocalVars = {}; /** * The cache of templates * @const */ Snakeskin.cache = {}; Array.isArray = Array.isArray || function (obj) { return {}.call(obj) === '[object Array]'; }; String.prototype.trim = String.prototype.trim || function () { var str = this.replace(/^\s\s*/, ''); var i = str.length; for (var rgxp = /\s/; rgxp.test(str.charAt(--i));) { // Do nothing } return str.substring(0, i + 1); }; /** * Returns true if the specified value is a function * * @param {?} obj - source value * @return {boolean} */ function isFunction(obj) { return typeof obj === 'function'; } /** * Returns true if the specified value is a number * * @param {?} obj - source value * @return {boolean} */ /** * Returns true if the specified value is a string * * @param {?} obj - source value * @return {boolean} */ function isString(obj) { return typeof obj === 'string'; } /** * Returns true if the specified value is a boolean * * @param {?} obj - source value * @return {boolean} */ /** * Returns true if the specified value is an array * * @param {?} obj - source value * @return {boolean} */ function isArray(obj) { return Array.isArray(obj); } /** * Returns true if the specified value is a plain object * * @param {?} obj - source value * @return {boolean} */ function isObject(obj) { return Boolean(obj) && obj.constructor === Object; } /** * Special Snakeskin class for escaping HTML entities from an object * * @constructor * @param {?} obj - source object * @param {?string=} [opt_attr] - type of attribute declaration */ Snakeskin$1.HTMLObject = function (obj, opt_attr) { this.value = obj; this.attr = opt_attr; }; /** * StringBuffer constructor * * @constructor * @return {!Array} */ Snakeskin$1.StringBuffer = function () { return []; }; /** * @param {!Function} child * @param {!Function} parent */ function inherit(child, parent) { /** @constructor */ var F = function F() { this.constructor = child; }; F.prototype = parent.prototype; child.prototype = new F(); } /** * Node constructor * @constructor */ Snakeskin$1.Node = function () {}; /** * Returns the number of child elements * @return {number} */ Snakeskin$1.Node.prototype.length = function () { return this.value.childNodes.length; }; /** * Returns text content * @return {string} */ Snakeskin$1.Node.prototype.textContent = function () { return this.value.textContent; }; /** * DocumentFragment constructor * * @constructor * @extends {Snakeskin.Node} * @param {string} renderMode - rendering mode of templates */ Snakeskin$1.DocumentFragment = function (renderMode) { this.renderMode = renderMode; this.value = document.createDocumentFragment(); }; inherit(Snakeskin$1.DocumentFragment, Snakeskin$1.Node); /** * Appends a child to the document fragment * @param {?} el - element for appending */ Snakeskin$1.DocumentFragment.prototype.appendChild = function (el) { this.value.appendChild(el); }; /** * Returns text content * @return {string} */ Snakeskin$1.DocumentFragment.prototype.textContent = function () { var children = this.value.childNodes; var res = ''; for (var i = 0; i < children.length; i++) { res += children[i].outerHTML || children[i].textContent; } return res; }; /** * Element constructor * * @constructor * @extends {Snakeskin.Node} * * @param {string} name - element name * @param {string} renderMode - rendering mode of templates */ Snakeskin$1.Element = function (name, renderMode) { this.renderMode = renderMode; this.value = document.createElement(name); }; inherit(Snakeskin$1.Element, Snakeskin$1.Node); /** * Appends a child to the element * @param {?} el - element for appending */ Snakeskin$1.Element.prototype.appendChild = function (el) { this.value.appendChild(el); }; /** * Sets an attribute to the element * * @param {string} name - attribute name * @param {string} val - attribute value */ Snakeskin$1.Element.prototype.setAttribute = function (name, val) { this.value.setAttribute(name, val); }; /** * Returns text content * @return {string} */ Snakeskin$1.Element.prototype.textContent = function () { return this.value.outerHTML; }; /** * Comment constructor * * @constructor * @extends {Snakeskin.Node} * * @param {string} text - comment text * @param {string} renderMode - rendering mode of templates */ Snakeskin$1.Comment = function (text, renderMode) { this.renderMode = renderMode; this.value = document.createComment(text); }; inherit(Snakeskin$1.Comment, Snakeskin$1.Node); /** * Text constructor * * @constructor * @extends {Snakeskin.Node} * * @param {string} text * @param {string} renderMode - rendering mode of templates */ Snakeskin$1.Text = function (text, renderMode) { this.renderMode = renderMode; this.value = document.createTextNode(text); }; inherit(Snakeskin$1.Text, Snakeskin$1.Node); /** * Map of inline tag names * @const */ Snakeskin$1.inlineTags = { 'html': { 'area': 'href', 'base': 'href', 'br': true, 'col': true, 'embed': 'src', 'hr': true, 'img': 'src', 'input': 'value', 'link': 'href', 'meta': 'content', 'param': 'value', 'source': 'src', 'track': 'src', 'wbr': true }, 'xml': {} }; /** * Appends a value to the specified element * * @param {(!Snakeskin.DocumentFragment|!Snakeskin.Element)} el - base element * @param {?} val - value for appending * @param {string} renderMode - rendering mode of templates * @return {(!Snakeskin.Element|!Snakeskin.Comment|!Snakeskin.Text)} */ Snakeskin$1.appendChild = function (el, val, renderMode) { if (val instanceof Snakeskin$1.Node === false) { val = new Snakeskin$1.Text(String(val), renderMode); } if (el) { el.appendChild(val.value); } return val; }; /** * Sets an attribute to the specified element * * @param {!Snakeskin.Node} node - source element * @param {string} name - attribute name * @param {?} val - attribute value */ Snakeskin$1.setAttribute = function (node, name, val) { node.setAttribute(name, val instanceof Snakeskin$1.Node ? val.textContent() : String(val)); }; var keys = function () { return (/\[native code]/.test(Object.keys && Object.keys.toString()) && Object.keys ); }(); /** * Common iterator * (with hasOwnProperty for objects) * * @param {(Array|Object|undefined)} obj - source object * @param {( * function(?, ?, !Array, {isFirst: boolean, isLast: boolean, length: number})| * function(?, ?, !Object, {i: number, isFirst: boolean, isLast: boolean, length: number}) * )} callback - callback function */ Snakeskin$1.forEach = function (obj, callback) { if (!obj) { return; } var length = 0; if (isArray(obj)) { length = obj.length; for (var i = 0; i < length; i++) { if (callback(obj[i], i, obj, { isFirst: i === 0, isLast: i === length - 1, length: length }) === false) { break; } } } else if (keys) { var arr = keys(obj); length = arr.length; for (var _i = 0; _i < length; _i++) { if (callback(obj[arr[_i]], arr[_i], obj, { i: _i, isFirst: _i === 0, isLast: _i === length - 1, length: length }) === false) { break; } } } else { if (callback.length >= 4) { for (var key in obj) { if (!obj.hasOwnProperty(key)) { break; } length++; } } var _i2 = 0; for (var _key in obj) { if (!obj.hasOwnProperty(_key)) { break; } if (callback(obj[_key], _key, obj, { i: _i2, isFirst: _i2 === 0, isLast: _i2 === length - 1, length: length }) === false) { break; } _i2++; } } }; /** * Object iterator * (without hasOwnProperty) * * @param {(Object|undefined)} obj - source object * @param {function(?, string, !Object, {i: number, isFirst: boolean, isLast: boolean, length: number})} callback - callback function */ Snakeskin$1.forIn = function (obj, callback) { if (!obj) { return; } var length = 0, i = 0; if (callback.length >= 4) { /* eslint-disable guard-for-in */ for (var ignore in obj) { length++; } /* eslint-enable guard-for-in */ } for (var key in obj) { if (callback(obj[key], key, obj, { i: i, isFirst: i === 0, isLast: i === length - 1, length: length }) === false) { break; } i++; } }; /** * Decorates a function by another functions * * @param {!Array<!Function>} decorators - array of decorator functions * @param {!Function} fn - source function * @param {!Object} nms - source namespace * @return {!Function} */ Snakeskin$1.decorate = function (decorators, nms, fn) { Snakeskin$1.forEach(decorators, function (decorator) { return fn = decorator(fn, nms) || fn; }); fn.decorators = decorators; return fn; }; /** * Gets an object with an undefined type * (for the GCC) * * @param {?} val - source object * @return {?} */ function any(val) { return val; } var wsRgxp = /^\s+|[\r\n]+/mg; /** * String tag (for ES6 string templates) for truncate starting whitespaces and eol-s * * @param {!Array<string>} strings * @param {...?} expr * @return {string} */ function ws(strings, expr) { expr = Array.from(arguments).slice(1); var res = ''; for (var i = 0; i < strings.length; i++) { res += strings[i].replace(wsRgxp, ' ') + (i in expr ? expr[i] : ''); } return res; } var rRgxp = /([\\/'*+?|()[\]{}.^$-])/g; /** * Escapes RegExp characters in a string * * @param {string} str - source string * @return {string} */ function r(str) { return str.replace(rRgxp, '\\$1'); } var isNotPrimitiveRgxp = /^\(*\s*(.*?)\s*\)*$/; var isNotPrimitiveMap = { 'false': true, 'null': true, 'true': true, 'undefined': true }; /** * Returns true if the specified string can't be parse as a primitive value * * @param {string} str - source string * @param {Object<string, boolean>=} opt_map - map of primitives * @return {boolean} */ function isNotPrimitive(str, opt_map) { str = ((isNotPrimitiveRgxp.exec(str) || [])[1] || '').trim(); return Boolean(str && isNaN(Number(str)) && !(opt_map || isNotPrimitiveMap)[str]); } var templateRank = { 'interface': 1, 'placeholder': 0, 'template': 2 }; var stringRender = { 'stringBuffer': true, 'stringConcat': true }; var attrSeparators = { '-': true, ':': true, '_': true }; var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; var asyncGenerator = function () { function AwaitValue(value) { this.value = value; } function AsyncGenerator(gen) { var front, back; function send(key, arg) { return new Promise(function (resolve, reject) { var request = { key: key, arg: arg, resolve: resolve, reject: reject, next: null }; if (back) { back = back.next = request; } else { front = back = request; resume(key, arg); } }); } function resume(key, arg) { try { var result = gen[key](arg); var value = result.value; if (value instanceof AwaitValue) { Promise.resolve(value.value).then(function (arg) { resume("next", arg); }, function (arg) { resume("throw", arg); }); } else { settle(result.done ? "return" : "normal", result.value); } } catch (err) { settle("throw", err); } } function settle(type, value) { switch (type) { case "return": front.resolve({ value: value, done: true }); break; case "throw": front.reject(value); break; default: front.resolve({ value: value, done: false }); break; } front = front.next; if (front) { resume(front.key, front.arg); } else { back = null; } } this._invoke = send; if (typeof gen.return !== "function") { this.return = undefined; } } if (typeof Symbol === "function" && Symbol.asyncIterator) { AsyncGenerator.prototype[Symbol.asyncIterator] = function () { return this; }; } AsyncGenerator.prototype.next = function (arg) { return this._invoke("next", arg); }; AsyncGenerator.prototype.throw = function (arg) { return this._invoke("throw", arg); }; AsyncGenerator.prototype.return = function (arg) { return this._invoke("return", arg); }; return { wrap: function (fn) { return function () { return new AsyncGenerator(fn.apply(this, arguments)); }; }, await: function (value) { return new AwaitValue(value); } }; }(); var classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; var defineProperty = function (obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }; var slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); var taggedTemplateLiteral = function (strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }; var _COMMENTS; var _BASE_SYS_ESCAPES; var _SYS_ESCAPES; var _STRONG_SYS_ESCAPES; // The base directive separators // >>> var LEFT_BOUND = '{'; var RIGHT_BOUND = '}'; var ADV_LEFT_BOUND = '#'; // <<< // The additional directive separators // >>> var I18N = '`'; var JS_DOC = '/**'; var SINGLE_COMMENT = '///'; var MULT_COMMENT_START = '/*'; var MULT_COMMENT_END = '*/'; var COMMENTS = (_COMMENTS = {}, defineProperty(_COMMENTS, SINGLE_COMMENT, SINGLE_COMMENT), defineProperty(_COMMENTS, MULT_COMMENT_START, MULT_COMMENT_START), defineProperty(_COMMENTS, MULT_COMMENT_END, MULT_COMMENT_END), _COMMENTS); var MICRO_TEMPLATE = '${'; var BASE_SHORTS = defineProperty({ '-': true }, ADV_LEFT_BOUND, true); var SHORTS = {}; Snakeskin$1.forEach(BASE_SHORTS, function (el, key) { return SHORTS[key] = true; }); // <<< // The context modifiers // >>> var G_MOD = '@'; // <<< // Jade-Like // >>> var CONCAT = '&'; var CONCAT_END = '.'; var IGNORE = '|'; var INLINE = ' :: '; // <<< // The filter modifiers // >>> var FILTER = '|'; // <<< // Escaping // >>> var BASE_SYS_ESCAPES = (_BASE_SYS_ESCAPES = { '\\': true, '"': true, '\'': true, '/': true }, defineProperty(_BASE_SYS_ESCAPES, I18N, true), defineProperty(_BASE_SYS_ESCAPES, LEFT_BOUND, true), defineProperty(_BASE_SYS_ESCAPES, SINGLE_COMMENT.charAt(0), true), defineProperty(_BASE_SYS_ESCAPES, MULT_COMMENT_START.charAt(0), true), _BASE_SYS_ESCAPES); var SYS_ESCAPES = (_SYS_ESCAPES = { '\\': true }, defineProperty(_SYS_ESCAPES, I18N, true), defineProperty(_SYS_ESCAPES, LEFT_BOUND, true), defineProperty(_SYS_ESCAPES, ADV_LEFT_BOUND, true), defineProperty(_SYS_ESCAPES, SINGLE_COMMENT.charAt(0), true), defineProperty(_SYS_ESCAPES, MULT_COMMENT_START.charAt(0), true), defineProperty(_SYS_ESCAPES, CONCAT, true), defineProperty(_SYS_ESCAPES, CONCAT_END, true), defineProperty(_SYS_ESCAPES, IGNORE, true), defineProperty(_SYS_ESCAPES, INLINE.trim().charAt(0), true), _SYS_ESCAPES); Snakeskin$1.forEach(BASE_SHORTS, function (el, key) { return SYS_ESCAPES[key.charAt(0)] = true; }); var STRONG_SYS_ESCAPES = (_STRONG_SYS_ESCAPES = { '\\': true }, defineProperty(_STRONG_SYS_ESCAPES, I18N, true), defineProperty(_STRONG_SYS_ESCAPES, SINGLE_COMMENT.charAt(0), true), defineProperty(_STRONG_SYS_ESCAPES, MULT_COMMENT_START.charAt(0), true), _STRONG_SYS_ESCAPES); var MICRO_TEMPLATE_ESCAPES = defineProperty({ '\\': true }, MICRO_TEMPLATE.charAt(0), true); var ESCAPES = { '"': true, '\'': true, '/': true }; var ESCAPES_END = { '-': true, '+': true, '*': true, '%': true, '~': true, '>': true, '<': true, '^': true, ',': true, ';': true, '=': true, '|': true, '&': true, '!': true, '?': true, ':': true, '(': true, '{': true, '[': true }; var ESCAPES_END_WORD = { 'return': true, 'yield': true, 'await': true, 'typeof': true, 'void': true, 'instanceof': true, 'delete': true, 'in': true, 'new': true }; var B_OPEN = { '(': true, '[': true, '{': true }; var B_CLOSE = { ')': true, ']': true, '}': true }; var P_OPEN = { '(': true, '[': true }; var P_CLOSE = { ')': true, ']': true }; // <<< // The reserved names // >>> var SYS_CONSTS = { '__STORE__': true, '__REQUIRE__': true, '__RESULT__': true, '__STRING_RESULT__': true, '__CDATA__': true, '__RETURN__': true, '__RETURN_VAL__': true, '__LENGTH__': true, '__ESCAPE_D_Q__': true, '__ATTR_STR__': true, '__ATTR_CONCAT_MAP__': true, '__TARGET_REF__': true, '__CALL_POS__': true, '__CALL_TMP__': true, '__CALL_CACHE__': true, '__FILTERS__': true, '__VARS__': true, '__LOCAL__': true, '__THIS__': true, '__INCLUDE__': true, '__INLINE_TAG__': true, '__INLINE_TAGS__': true, '__NODE__': true, '__JOIN__': true, '__GET_XML_ATTR_KEY_DECL__': true, '__APPEND_XML_ATTR_VAL__': true, '__GET_XML_ATTRS_DECL_START__': true, '__GET_XML_TAG_DECL_END__': true, '__GET_END_XML_TAG_DECL__': true, '__TARGET_END__': true, '__PUTIN_CALL__': true, '__PUTIN_TARGET__': true, '__SNAKESKIN_MODULES__': true, '__SNAKESKIN_MODULES_DECL__': true, 'GLOBAL': true, 'TRUE': true, 'FALSE': true, 'module': true, 'exports': true, 'require': true, '__dirname': true, '__filename': true, 'TPL_NAME': true, 'PARENT_TPL_NAME': true, 'EOL': true, 'Raw': true, 'Unsafe': true, 'Snakeskin': true, 'getTplResult': true, 'clearTplResult': true, 'arguments': true, 'self': true, 'callee': true, '$_': true, '$0': true, '$class': true, '$tagName': true, '$attrKey': true, '$attrType': true, '$attrs': true }; var scopeMod = new RegExp('^' + r(G_MOD) + '+'); var escaperPart = /^(?:__ESCAPER_QUOT__|__CDATA__)\d+_/; var tmpSep = []; Snakeskin$1.forEach(attrSeparators, function (el, key) { tmpSep.push(r(key)); }); var emptyCommandParams = new RegExp('^([^\\s]+?[' + tmpSep.join('') + ']\\(|\\()'); var eol = /\r?\n|\r/; var ws$1 = /\s/; var lineWs = / |\t/; var wsStart = new RegExp('^[ \\t]*(?:' + eol.source + ')'); var wsEnd = new RegExp('^(?:' + eol.source + ')[ \\t]*$'); var bEnd = /[^\s\/]/; var sysWord = /[a-z]/; var attrKey = /([^\s=]+)/; var backSlashes = /\\/g; var singleQuotes = /'/g; var doubleQuotes = /"/g; var symbols = '\\u0041-\\u005A\\u0061-\\u007A\\u00AA\\u00B5\\u00BA\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02C1\\u02C6-\\u02D1' + '\\u02E0-\\u02E4\\u02EC\\u02EE\\u0370-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u0386\\u0388-\\u038A\\u038C' + '\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u048A-\\u0525\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u05D0-\\u05EA' + '\\u05F0-\\u05F2\\u0621-\\u064A\\u066E\\u066F\\u0671-\\u06D3\\u06D5\\u06E5\\u06E6\\u06EE\\u06EF\\u06FA-\\u06FC' + '\\u06FF\\u0710\\u0712-\\u072F\\u074D-\\u07A5\\u07B1\\u07CA-\\u07EA\\u07F4\\u07F5\\u07FA' + '\\u0800-\\u0815\\u081A\\u0824\\u0828\\u0904-\\u0939\\u093D\\u0950\\u0958-\\u0961\\u0971\\u0972\\u0979-\\u097F' + '\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BD\\u09CE\\u09DC\\u09DD' + '\\u09DF-\\u09E1\\u09F0\\u09F1\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35' + '\\u0A36\\u0A38\\u0A39\\u0A59-\\u0A5C\\u0A5E\\u0A72-\\u0A74\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8' + '\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABD\\u0AD0\\u0AE0\\u0AE1\\u0B05-\\u0B0C\\u0B0F\\u0B10' + '\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3D\\u0B5C\\u0B5D\\u0B5F-\\u0B61\\u0B71\\u0B83' + '\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA' + '\\u0BAE-\\u0BB9\\u0BD0\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C33\\u0C35-\\u0C39\\u0C3D\\u0C58' + '\\u0C59\\u0C60\\u0C61\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBD\\u0CDE' + '\\u0CE0\\u0CE1\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D28\\u0D2A-\\u0D39\\u0D3D\\u0D60\\u0D61\\u0D7A-\\u0D7F' + '\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0E01-\\u0E30\\u0E32\\u0E33\\u0E40-\\u0E46' + '\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7' + '\\u0EAA\\u0EAB\\u0EAD-\\u0EB0\\u0EB2\\u0EB3\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EDC\\u0EDD\\u0F00\\u0F40-\\u0F47' + '\\u0F49-\\u0F6C\\u0F88-\\u0F8B\\u1000-\\u102A\\u103F\\u1050-\\u1055\\u105A-\\u105D\\u1061\\u1065\\u1066' + '\\u106E-\\u1070\\u1075-\\u1081\\u108E\\u10A0-\\u10C5\\u10D0-\\u10FA\\u10FC\\u1100-\\u1248\\u124A-\\u124D' + '\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE' + '\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u1380-\\u138F\\u13A0-\\u13F4' + '\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u1700-\\u170C\\u170E-\\u1711\\u1720-\\u1731' + '\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17D7\\u17DC\\u1820-\\u1877\\u1880-\\u18A8\\u18AA' + '\\u18B0-\\u18F5\\u1900-\\u191C\\u1950-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19C1-\\u19C7\\u1A00-\\u1A16' + '\\u1A20-\\u1A54\\u1AA7\\u1B05-\\u1B33\\u1B45-\\u1B4B\\u1B83-\\u1BA0\\u1BAE\\u1BAF\\u1C00-\\u1C23\\u1C4D-\\u1C4F' + '\\u1C5A-\\u1C7D\\u1CE9-\\u1CEC\\u1CEE-\\u1CF1\\u1D00-\\u1DBF\\u1E00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45' + '\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE' + '\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u2071' + '\\u207F\\u2090-\\u2094\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D' + '\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2183\\u2184\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2CE4' + '\\u2CEB-\\u2CEE\\u2D00-\\u2D25\\u2D30-\\u2D65\\u2D6F\\u2D80-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6' + '\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2E2F\\u3005\\u3006\\u3031-\\u3035' + '\\u303B\\u303C\\u3041-\\u3096\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E' + '\\u31A0-\\u31B7\\u31F0-\\u31FF\\u3400-\\u4DB5\\u4E00-\\u9FCB\\uA000-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C' + '\\uA610-\\uA61F\\uA62A\\uA62B\\uA640-\\uA65F\\uA662-\\uA66E\\uA67F-\\uA697\\uA6A0-\\uA6E5\\uA717-\\uA71F' + '\\uA722-\\uA788\\uA78B\\uA78C\\uA7FB-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873' + '\\uA882-\\uA8B3\\uA8F2-\\uA8F7\\uA8FB\\uA90A-\\uA925\\uA930-\\uA946\\uA960-\\uA97C\\uA984-\\uA9B2\\uA9CF' + '\\uAA00-\\uAA28\\uAA40-\\uAA42\\uAA44-\\uAA4B\\uAA60-\\uAA76\\uAA7A\\uAA80-\\uAAAF\\uAAB1\\uAAB5\\uAAB6' + '\\uAAB9-\\uAABD\\uAAC0\\uAAC2\\uAADB-\\uAADD\\uABC0-\\uABE2\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB' + '\\uF900-\\uFA2D\\uFA30-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D\\uFB1F-\\uFB28\\uFB2A-\\uFB36' + '\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7' + '\\uFDF0-\\uFDFB\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF21-\\uFF3A\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7' + '\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC'; var filterStart = new RegExp('[!$' + symbols + '_]'); var w = '$' + symbols + '0-9_'; var Filters = Snakeskin$1.Filters; /** * Imports an object to Filters * * @param {!Object} filters - import object * @param {?string=} [opt_namespace] - namespace for saving, for example foo.bar * @return {!Object} */ Snakeskin$1.importFilters = function (filters, opt_namespace) { var obj = Filters; if (opt_namespace) { Snakeskin$1.forEach(opt_namespace.split('.'), function (el) { obj[el] = obj[el] || {}; obj = obj[el]; }); } Snakeskin$1.forEach(filters, function (el, key) { return obj[key] = el; }); return this; }; /** * Sets parameters to the specified Snakeskin filter * * @param {(string|!Function)} filter - filter name or the filter function * @param {Object} params - parameters * @return {!Function} */ Snakeskin$1.setFilterParams = function (filter, params) { var safe = params['safe']; if (safe) { params['bind'] = ['Unsafe'].concat(params['bind'] || []); } var tmp = void 0; function wrapper(val, Unsafe) { var _tmp2; for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { args[_key - 2] = arguments[_key]; } if (val && isFunction(Unsafe) && val instanceof Unsafe) { var _tmp; val.value = (_tmp = tmp).call.apply(_tmp, [this, val.value].concat(args)); return val; } return (_tmp2 = tmp).call.apply(_tmp2, [this, val].concat(args)); } if (isString(filter)) { if (safe) { tmp = Filters[filter]; Filters[filter] = wrapper; } Filters[filter] = Filters[filter] || function (str) { return str; }; Filters[filter]['ssFilterParams'] = params; return Filters[filter]; } if (safe) { tmp = filter; filter = wrapper; } filter['ssFilterParams'] = params; return any(filter); }; /** * Console API * @const */ Filters['console'] = { /** * @param {?} val * @return {?} */ 'dir': function dir(val) { var _console; (_console = console).dir.apply(_console, arguments); return val; }, /** * @param {?} val * @return {?} */ 'error': function error(val) { var _console2; (_console2 = console).error.apply(_console2, arguments); return val; }, /** * @param {?} val * @return {?} */ 'info': function info(val) { var _console3; (_console3 = console).info.apply(_console3, arguments); return val; }, /** * @param {?} val * @return {?} */ 'log': function log(val) { var _console4; (_console4 = console).log.apply(_console4, arguments); return val; }, /** * @param {?} val * @return {?} */ 'table': function table(val) { var _console5; (_console5 = console).table.apply(_console5, arguments); return val; }, /** * @param {?} val * @return {?} */ 'warn': function warn(val) { var _console6; (_console6 = console).warn.apply(_console6, arguments); return val; } }; var entityMap = { '"': '&quot;', '&': '&amp;', '\'': '&#39;', '<': '&lt;', '>': '&gt;' }; var escapeHTMLRgxp = /[<>"'/]|&(?!#|[a-z]+;)/g; var escapeHTML = function escapeHTML(s) { return entityMap[s] || s; }; var uentityMap = { '&#39;': '\'', '&#x2F;': '/', '&amp;': '&', '&gt;': '>', '&lt;': '<', '&quot;': '"' }; var uescapeHTMLRgxp = /&amp;|&lt;|&gt;|&quot;|&#39;|&#x2F;/g; var uescapeHTML = function uescapeHTML(s) { return uentityMap[s]; }; /** * Escapes HTML entities from a string * * @param {?} val - source value * @param {?=} [opt_Unsafe] - unsafe class constructor * @param {?string=} [opt_attr] - type of attribute declaration * @param {Object=} [opt_attrCache] - attribute cache object * @param {?=} [opt_true] - true value * @return {(string|!Snakeskin.HTMLObject|!Snakeskin.Node)} */ Filters['html'] = function (val, opt_Unsafe, opt_attr, opt_attrCache, opt_true) { if (!val || val instanceof Snakeskin$1.Node) { return val; } if (val instanceof Snakeskin$1.HTMLObject) { Snakeskin$1.forEach(val.value, function (el, key, data) { if (val.attr) { opt_attrCache[key] = data[key] = el[0] !== opt_true ? [Filters['html'](el[0], opt_Unsafe, val.attr, opt_attrCache, opt_true)] : el; } else { data[key] = Filters['html'](el, opt_Unsafe); } }); return val; } if (isFunction(opt_Unsafe) && val instanceof opt_Unsafe) { return val.value; } return String(opt_attr ? Filters[opt_attr](val) : val).replace(escapeHTMLRgxp, escapeHTML); }; Snakeskin$1.setFilterParams('html', { bind: ['Unsafe', '$attrType', function (o) { return o.getVar('$attrs'); }, 'TRUE'], test: function test(val) { return isNotPrimitive(val); } }); Filters['htmlObject'] = function (val) { if (val instanceof Snakeskin$1.HTMLObject) { return ''; } return val; }; Snakeskin$1.setFilterParams('htmlObject', { test: function test(val) { return isNotPrimitive(val); } }); /** * Replaces undefined to '' * * @param {?} val - source value * @return {?} */ Filters['undef'] = function (val) { return val !== undefined ? val : ''; }; Snakeskin$1.setFilterParams('undef', { test: function test(val) { return isNotPrimitive(val, { 'false': true, 'null': true, 'true': true }); } }); /** * Replaces escaped HTML entities to real content * * @param {?} val - source value * @return {string} */ Filters['uhtml'] = function (val) { return String(val).replace(uescapeHTMLRgxp, uescapeHTML); }; var stripTagsRgxp = /<\/?[^>]+>/g; /** * Removes < > from a string * * @param {?} val - source value * @return {string} */ Filters['stripTags'] = function (val) { return String(val).replace(stripTagsRgxp, ''); }; var uriO = /%5B/g; var uriC = /%5D/g; /** * Encodes URL * * @see https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/encodeURI * @param {?} val - source value * @return {string} */ Filters['uri'] = function (val) { return encodeURI(String(val)).replace(uriO, '[').replace(uriC, ']'); }; Snakeskin$1.setFilterParams('uri', { safe: true }); /** * Converts a string to uppercase * * @param {?} val - source value * @return {string} */ Filters['upper'] = function (val) { return String(val).toUpperCase(); }; Snakeskin$1.setFilterParams('upper', { safe: true }); /** * Converts the first letter of a string to uppercase * * @param {?} val - source value * @return {string} */ Filters['ucfirst'] = function (val) { val = String(val); return val.charAt(0).toUpperCase() + val.slice(1); }; Snakeskin$1.setFilterParams('ucfirst', { safe: true }); /** * Converts a string to lowercase * * @param {?} val - source value * @return {string} */ Filters['lower'] = function (val) { return String(val).toLowerCase(); }; Snakeskin$1.setFilterParams('lower', { safe: true }); /** * Converts the first letter of a string to lowercase * * @param {?} val - source value * @return {string} */ Filters['lcfirst'] = function (val) { val = String(val); return val.charAt(0).toLowerCase() + val.slice(1); }; Snakeskin$1.setFilterParams('lcfirst', { safe: true }); /** * Removes whitespace from both ends of a string * * @param {?} val - source value * @return {string} */ Filters['trim'] = function (val) { return String(val).trim(); }; Snakeskin$1.setFilterParams('trim', { safe: true }); var spaceCollapseRgxp = /\s{2,}/g; /** * Removes whitespace from both ends of a string * and collapses whitespace * * @param {?} val - source value * @return {string} */ Filters['collapse'] = function (val) { return String(val).replace(spaceCollapseRgxp, ' ').trim(); }; Snakeskin$1.setFilterParams('collapse', { safe: true }); /** * Truncates a string to the specified length * (at the end puts three dots) * * @param {?} val - source value * @param {number} length - maximum length * @param {?boolean=} opt_wordOnly - if is false, then the string will be truncated without * taking into account the integrity of the words * * @param {?boolean=} opt_html - if is true, then the dots will be inserted as HTML-mnemonic * @return {string} */ Filters['truncate'] = function (val, length, opt_wordOnly, opt_html) { val = String(val); if (!val || val.length <= length) { return val; } var tmp = val.slice(0, length - 1); var i = tmp.length, lastInd = void 0; while (i-- && opt_wordOnly) { if (tmp.charAt(i) === ' ') { lastInd = i; } else if (lastInd !== undefined) { break; } } return (lastInd !== undefined ? tmp.slice(0, lastInd) : tmp) + (opt_html ? '&#8230;' : '…'); }; /** * Returns a new string of repetitions of a string * * @param {?} val - source value * @param {?number=} opt_num - number of repetitions * @return {string} */ Filters['repeat'] = function (val, opt_num) { return new Array(opt_num != null ? opt_num + 1 : 3).join(val); }; Snakeskin$1.setFilterParams('repeat', { safe: true }); /** * Removes a slice from a string * * @param {?} val - source value * @param {(string|RegExp)} search - searching slice * @return {string} */ Filters['remove'] = function (val, search) { return String(val).replace(search, ''); }; /** * Replaces a slice from a string to a new string * * @param {?} val - source value * @param {(string|!RegExp)} search - searching slice * @param {string} replace - string for replacing * @return {string} */ Filters['replace'] = function (val, search, replace) { return String(val).replace(search, replace); }; var tplRgxp = /\${(.*?)}/g; /** * Returns a string result of the specified template * * @example * 'hello ${name}' |tpl {name: 'Kobezzza'} * * @param {?} tpl - source template * @param {!Object} map - map of values * @return {string} */ Filters['tpl'] = function (tpl, map) { return String(tpl).replace(tplRgxp, function (str, $0) { return $0 in map ? map[$0] : ''; }); }; /** * Converts a value to JSON * * @param {(Object|Array|string|number|boolean)} val - source value * @return {string} */ Filters['json'] = function (val) { return JSON.stringify(val); }; /** * Converts a value to a string * * @param {(Object|Array|string|number|boolean)} val - source value * @return {string} */ Filters['string'] = function (val) { if ((typeof val === 'undefined' ? 'undefined' : _typeof(val)) === 'object' && val instanceof String === false) { return JSON.stringify(val); } return String(val); }; /** * Parses a string as JSON * * @param {?} val - source value * @return {?} */ Filters['parse'] = function (val) { if (!isString(val)) { return val; } return JSON.parse(val); }; /** * Sets a default value for the specified parameter * * @param {?} val - source value * @param {?} def - value * @return {?} */ Filters['default'] = function (val, def) { return val === undefined ? def : val; }; Snakeskin$1.setFilterParams('default', { '!undef': true }); var nl2brRgxp = /\r?\n|\n/g; /** * Replaces EOL symbols from a string to <br> * * @param {?} val - source value * @param {(!Snakeskin.DocumentFragment|!Snakeskin.Element|undefined)} node - source node * @param {string} renderMode - rendering mode of templates * @param {boolean} stringResult - if is true, then the output will be saved to __STRING_RESULT__ as a string * @param {string} doctype - document type * @return {?} */ Filters['nl2br'] = function (val, node, renderMode, stringResult, doctype) { var arr = val.split(nl2brRgxp); var res = ''; for (var i = 0; i < arr.length; i++) { var el = arr[i], last = i === arr.length - 1; if (!stringResult && !stringRender[renderMode]) { Snakeskin$1.appendChild(any(node), el, renderMode); if (!last) { Snakeskin$1.appendChild(any(node), new Snakeskin$1.Element('br', renderMode), renderMode); } } else { res += Filters['html'](el); if (!last) { res += '<br' + (doctype === 'xml' ? '/' : '') + '>'; } } } return res; }; Snakeskin$1.setFilterParams('nl2br', { '!html': true, bind: ['$0', function (o) { return '\'' + o.renderMode + '\''; }, function (o) { return o.stringResult; }, '$0', function (o) { return '\'' + o.doctype + '\''; }] }); /** * @param str * @return {string} */ function dasherize(str) { var res = str[0].toLowerCase(); for (var i = 1; i < str.length; i++) { var el = str.charAt(i), up = el.toUpperCase(); if (up === el && up !== el.toLowerCase()) { res += '-' + el; } else { res += el; } } return res.toLowerCase(); } /** * Escapes HTML entities from an attribute name * * @param {?} val - source value * @return {string} */ Filters['attrKey'] = function (val) { var tmp = attrKey.exec(String(val)); return tmp && tmp[1] || 'undefined'; }; /** * Escapes HTML entities from an attribute group * * @param {?} val - source value * @return {string} */ Filters['attrKeyGroup'] = function (val) { var tmp = attrKey.exec(String(val)); return tmp && tmp[1] || ''; }; var attrValRgxp = /(javascript)(:|;)/g; /** * Escapes HTML entities from an attribute value * * @param {?} val - source value * @return {string} */ Filters['attrValue'] = function (val) { return String(val).replace(attrValRgxp, '$1&#31;$2'); }; /** * Sets attributes to a node * * @param {?} val - source value * @param {?} Unsafe - unsafe class constructor * @param {string} doctype - document type * @param {string} type - type of attribute declaration * @param {!Object} cache - attribute cache object * @param {!Boolean} TRUE - true value * @param {!Boolean} FALSE - false value * @return {(string|Unsafe|Snakeskin.HTMLObject)} */ Filters['attr'] = function (val, Unsafe, doctype, type, cache, TRUE, FALSE) { if (type !== 'attrKey' || !isObject(val)) { if (isFunction(Unsafe) && val instanceof Unsafe) { return val; } return String(val); } var localCache = {}; /** * @param {Object} obj * @param {?string=} opt_prfx * @return {Snakeskin.HTMLObject} */ function convert(obj, opt_prfx) { opt_prfx = opt_prfx || ''; Snakeskin$1.forEach(obj, function (el, key) { if (el === FALSE) { return; } if (isObject(el)) { var group = Filters['attrKeyGroup'](key); return convert(el, opt_prfx + (!group.length || attrSeparators[group.slice(-1)] ? group : group + '-')); } var tmp = dasherize(opt_prfx + key); cache[tmp] = localCache[tmp] = [el]; }); return new Snakeskin$1.HTMLObject(localCache, 'attrValue'); } return convert(val); }; Snakeskin$1.setFilterParams('attr', { '!html': true, bind: ['Unsafe', function (o) { return '\'' + o.doctype + '\''; }, '$attrType', function (o) { return o.getVar('$attrs'); }, 'TRUE', 'FALSE'], test: function test(val) { return isNotPrimitive(val); } }); /** * Returns a valid template name for overriding * * @param {string} name - base name * @param {!Object} store - link to a store object * @param {string} scope - scope string * @param {boolean} init - true, if a template already defined * @return {string} */ Filters['super'] = function (name, store, scope, init) { var cache = store.templates = store.templates || {}, nm = scope + name; cache[nm] = cache[nm] || [name]; if (init) { return cache[nm].slice(-2)[0] || name; } name = name + Math.random().toString().slice(2); cache[nm].push(name); return name; }; Snakeskin$1.setFilterParams('super', { '!html': true, bind: [function (o) { return o.getVar('__STORE__'); }, function (o) { return JSON.stringify(o.scope[0]); }, function (o) { return Boolean(o.vars[o.tplName]); }] }); var IS_NODE = function () { try { return (typeof process === 'undefined' ? 'undefined' : _typeof(process)) === 'object' && {}.toString.call(process) === '[object process]'; } catch (ignore) { return false; } }(); var HAS_CONSOLE_LOG = (typeof console === 'undefined' ? 'undefined' : _typeof(console)) === 'object' && console && isFunction(console.log); var HAS_CONSOLE_ERROR = (typeof console === 'undefined' ? 'undefined' : _typeof(console)) === 'object' && console && isFunction(console.error); if (IS_NODE) { require('core-js/es6'); } var GLOBAL = Function('return this')(); var ROOT = IS_NODE ? exports : GLOBAL; var NULL = {}; var beautify = GLOBAL.js_beautify || require('js-beautify'); /** * Returns an object for require a file * * @param {string} ctxFile - context file * @return {{require: (function(string): ?|undefined), dirname: (string|undefined)}} */ function getRequire(ctxFile) { if (!IS_NODE) { return {}; } if (!ctxFile) { return { require: require }; } var path = require('path'), findNodeModules = require('find-node-modules'); var basePaths = module.paths.slice(), dirname = path.dirname(ctxFile); var base = findNodeModules({ cwd: dirname, relative: false }) || [], modules = base.concat(module.paths || []); var cache = {}, newPaths = []; for (var i = 0; i < modules.length; i++) { var el = modules[i]; if (!cache[el]) { cache[el] = true; newPaths.push(el); } } var isRelative = { '/': true, '\\': true, '.': true }; return { dirname: dirname, require: function (_require) { function require(_x) { return _require.apply(this, arguments); } require.toString = function () { return _require.toString(); }; return require; }(function (file) { module.paths = newPaths; var res = void 0; if (!path.isAbsolute(file) && isRelative[file[0]]) { res = require(path.resolve(dirname, file)); } else { res = require(file); } module.paths = basePaths; return res; }) }; } var _templateObject = taggedTemplateLiteral(['\n\t\t\t\t', '\n\t\t\t\timport Snakeskin from \'', '\';\n\t\t\t\tvar exports = {};\n\t\t\t\texport default exports;\n\t\t\t'], ['\n\t\t\t\t', '\n\t\t\t\timport Snakeskin from \'', '\';\n\t\t\t\tvar exports = {};\n\t\t\t\texport default exports;\n\t\t\t']); var _templateObject2 = taggedTemplateLiteral(['\n\t\t\t\t(function (global, factory) {\n\t\t\t\t\t', '\n\n\t\t\t\t\t', '\n\n\t\t\t\t\t', '\n\n\t\t\t\t})(this, function (exports, Snakeskin', ') {\n\t\t\t\t\t', '\n\t\t\t'], ['\n\t\t\t\t(function (global, factory) {\n\t\t\t\t\t', '\n\n\t\t\t\t\t', '\n\n\t\t\t\t\t', '\n\n\t\t\t\t})(this, function (exports, Snakeskin', ') {\n\t\t\t\t\t', '\n\t\t\t']); var _templateObject3 = taggedTemplateLiteral(['\n\t\t\t\t\t\t\t\tif (typeof exports === \'object\' && typeof module !== \'undefined\') {\n\t\t\t\t\t\t\t\t\tfactory(exports, typeof Snakeskin === \'undefined\' ? require(\'', '\') : Snakeskin);\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t'], ['\n\t\t\t\t\t\t\t\tif (typeof exports === \'object\' && typeof module !== \'undefined\') {\n\t\t\t\t\t\t\t\t\tfactory(exports, typeof Snakeskin === \'undefined\' ? require(\'', '\') : Snakeskin);\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t']); var _templateObject4 = taggedTemplateLiteral(['\n\t\t\t\t\t\t\t\tif (typeof define === \'function\' && define.amd) {\n\t\t\t\t\t\t\t\t\tdefine(\'', '\', [\'exports\', \'snakeskin\'/*#__SNAKESKIN_MODULES_DECL__*/], factory);\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t'], ['\n\t\t\t\t\t\t\t\tif (typeof define === \'function\' && define.amd) {\n\t\t\t\t\t\t\t\t\tdefine(\'', '\', [\'exports\', \'snakeskin\'/*#__SNAKESKIN_MODULES_DECL__*/], factory);\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t']); var _templateObject5 = taggedTemplateLiteral(['\n\t\t\tvar\n\t\t\t\tGLOBAL = Function(\'return this\')(),\n\t\t\t\t__FILTERS__ = Snakeskin.Filters,\n\t\t\t\t__VARS__ = Snakeskin.Vars,\n\t\t\t\t__LOCAL__ = Snakeskin.LocalVars,\n\t\t\t\t__REQUIRE__;\n\n\t\t\tfunction __LENGTH__(val) {\n\t\t\t\tif (val[0] instanceof Snakeskin.Node) {\n\t\t\t\t\treturn val[0].length();\n\t\t\t\t}\n\n\t\t\t\tif (typeof val === \'string\' || Array.isArray(val)) {\n\t\t\t\t\treturn val.length;\n\t\t\t\t}\n\n\t\t\t\treturn 1;\n\t\t\t}\n\n\t\t\tfunction __JOIN__(arr) {\n\t\t\t\tvar str = \'\';\n\t\t\t\tfor (var i = 0; i < arr.length; i++) {\n\t\t\t\t\tstr += arr[i];\n\t\t\t\t}\n\t\t\t\treturn str;\n\t\t\t}\n\n\t\t\tfunction __ESCAPE_D_Q__(str) {\n\t\t\t\treturn String(str).replace(/"/g, "&quot;")\n\t\t\t}\n\n\t\t\tvar\n\t\t\t\tTRUE = new Boolean(true),\n\t\t\t\tFALSE = new Boolean(false);\n\n\t\t\tfunction Raw(val) {\n\t\t\t\tif (!this || this.constructor !== Raw) {\n\t\t\t\t\treturn new Raw(val);\n\t\t\t\t}\n\n\t\t\t\tthis.value = val;\n\t\t\t}\n\n\t\t\tRaw.prototype.push = function (val) {\n\t\t\t\tthis.value += val;\n\t\t\t};\n\n\t\t\tfunction Unsafe(val) {\n\t\t\t\tif (!this || this.constructor !== Unsafe) {\n\t\t\t\t\tif (typeof val === \'string\') {\n\t\t\t\t\t\treturn new Unsafe(val);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn val;\n\t\t\t\t}\n\n\t\t\t\tthis.value = val;\n\t\t\t}\n\n\t\t\tUnsafe.prototype.toString = function () {\n\t\t\t\treturn this.value;\n\t\t\t};\n\n\t\t\t', '\n\t\t'], ['\n\t\t\tvar\n\t\t\t\tGLOBAL = Function(\'return this\')(),\n\t\t\t\t__FILTERS__ = Snakeskin.Filters,\n\t\t\t\t__VARS__ = Snakeskin.Vars,\n\t\t\t\t__LOCAL__ = Snakeskin.LocalVars,\n\t\t\t\t__REQUIRE__;\n\n\t\t\tfunction __LENGTH__(val) {\n\t\t\t\tif (val[0] instanceof Snakeskin.Node) {\n\t\t\t\t\treturn val[0].length();\n\t\t\t\t}\n\n\t\t\t\tif (typeof val === \'string\' || Array.isArray(val)) {\n\t\t\t\t\treturn val.length;\n\t\t\t\t}\n\n\t\t\t\treturn 1;\n\t\t\t}\n\n\t\t\tfunction __JOIN__(arr) {\n\t\t\t\tvar str = \'\';\n\t\t\t\tfor (var i = 0; i < arr.length; i++) {\n\t\t\t\t\tstr += arr[i];\n\t\t\t\t}\n\t\t\t\treturn str;\n\t\t\t}\n\n\t\t\tfunction __ESCAPE_D_Q__(str) {\n\t\t\t\treturn String(str).replace(/"/g, "&quot;")\n\t\t\t}\n\n\t\t\tvar\n\t\t\t\tTRUE = new Boolean(true),\n\t\t\t\tFALSE = new Boolean(false);\n\n\t\t\tfunction Raw(val) {\n\t\t\t\tif (!this || this.constructor !== Raw) {\n\t\t\t\t\treturn new Raw(val);\n\t\t\t\t}\n\n\t\t\t\tthis.value = val;\n\t\t\t}\n\n\t\t\tRaw.prototype.push = function (val) {\n\t\t\t\tthis.value += val;\n\t\t\t};\n\n\t\t\tfunction Unsafe(val) {\n\t\t\t\tif (!this || this.constructor !== Unsafe) {\n\t\t\t\t\tif (typeof val === \'string\') {\n\t\t\t\t\t\treturn new Unsafe(val);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn val;\n\t\t\t\t}\n\n\t\t\t\tthis.value = val;\n\t\t\t}\n\n\t\t\tUnsafe.prototype.toString = function () {\n\t\t\t\treturn this.value;\n\t\t\t};\n\n\t\t\t', '\n\t\t']); /** * The class for parsing SS templates */ var Parser = /** * @constructor * @implements {$$SnakeskinParser} * * @param {string} src - source text of templates * @param {$$SnakeskinParserParams} params - additional parameters */ function Parser(src, params) { classCallCheck(this, Parser); /** @type {boolean} */ this.throws = params.throws; /** @type {(?function(!Error)|undefined)} */ this.onError = params.onError; /** @type {(?function(string, string): string|undefined)} */ this.resolveModuleSource = params.resolveModuleSource; /** @type {boolean} */ this.pack = params.pack; /** @type {string} */ this.module = params.module; /** @type {(?string|undefined)} */ this.moduleId = params.moduleId; /** @type {(?string|undefined)} */ this.moduleName = params.moduleName; /** @type {boolean} */ this.useStrict = params.useStrict; /** @type {!Array<string>} */ this.literalBounds = params.literalBounds; /** @type {(Array<string>|undefined)} */ this.attrLiteralBounds = params.attrLiteralBounds; /** @type {(?string|undefined)} */ this.tagFilter = params.tagFilter; /** @type {(?string|undefined)} */ this.tagNameFilter = params.tagNameFilter; /** @type {(?string|undefined)} */ this.attrKeyFilter = params.attrKeyFilter; /** @type {(?string|undefined)} */ this.attrValueFilter = params.attrValueFilter; /** @type {(?string|undefined)} */ this.bemFilter = params.bemFilter; /** @type {!Array} */ this.filters = this.appendDefaultFilters(params.filters); /** @type {boolean} */ this.localization = params.localization; /** @type {string} */ this.i18nFn = params.i18nFn; /** @type {(?string|undefined)} */ this.i18nFnOptions = params.i18nFnOptions; /** @type {(Object|undefined)} */ this.language = params.language; /** @type {(Object|undefined)} */ this.words = params.words; /** @type {(RegExp|undefined)} */ this.ignore = params.ignore; /** @type {boolean} */ this.tolerateWhitespaces = params.tolerateWhitespaces; /** @type {string} */ this.eol = params.eol; /** @type {string} */ this.doctype = params.doctype; /** @type {(?string|undefined)} */ this.renderAs = params.renderAs; /** @type {string} */ this.renderMode = p