froala-editor
Version:
The next generation Javascript WYSIWYG HTML rich text editor made by devs for devs. High performance and modern design make it easy to use for developers and loved by users.
7 lines (6 loc) • 45.6 kB
JavaScript
/*!
* froala_editor v5.0.1 (https://www.froala.com/wysiwyg-editor)
* License https://froala.com/wysiwyg-editor/terms/
* Copyright 2014-2026 Froala Labs
*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(require("froala-editor")):"function"==typeof define&&define.amd?define(["froala-editor"],e):e(("undefined"!=typeof globalThis?globalThis:t||self).FroalaEditor)}(this,function(t){"use strict";t.PLUGINS.codeBeautifier=function(){var t,e,n,i,z={};function m(i,t){var n,e={"@page":!0,"@font-face":!0,"@keyframes":!0,"@media":!0,"@supports":!0,"@document":!0},r={"@media":!0,"@supports":!0,"@document":!0},s=(t=t||{},i=(i=i||"").replace(/\r\n|[\r\u2028\u2029]/g,"\n"),t.indent_size||4),_=t.indent_char||" ",a=t.selector_separator_newline===undefined||t.selector_separator_newline,o=t.end_with_newline!==undefined&&t.end_with_newline,c=t.newline_between_rules===undefined||t.newline_between_rules,l=t.eol||"\n",h=("string"==typeof s&&(s=parseInt(s,10)),t.indent_with_tabs&&(_="\t",s=1),l=l.replace(/\\r/,"\r").replace(/\\n/,"\n"),/^\s+$/),p=-1,u=0;function d(){return(n=i.charAt(++p))||""}function f(t){var e=p;return t&&E(),t=i.charAt(p+1)||"",p=e-1,d(),t}function T(t){for(var e=p;d();)if("\\"===n)d();else{if(-1!==t.indexOf(n))break;if("\n"===n)break}return i.substring(e,p+1)}function E(){for(;h.test(f());)d(),0}function g(t){var e=p;for(t="/"===f(),d();d();){if(!t&&"*"===n&&"/"===f()){d();break}if(t&&"\n"===n)return i.substring(e,p)}return i.substring(e,p)+n}function w(t){return i.substring(p-t.length,p).toLowerCase()===t}var x=i.match(/^[\t ]*/)[0],K=new Array(s+1).join(_),R=0,m=0;for(var b={"{":function(t){b.singleSpace(),S.push(t),b.newLine()},"}":function(t){b.newLine(),S.push(t),b.newLine()},_lastCharWhitespace:function(){return h.test(S[S.length-1])},newLine:function(t){S.length&&(t||"\n"===S[S.length-1]||b.trim(),S.push("\n"),x)&&S.push(x)},singleSpace:function(){S.length&&!b._lastCharWhitespace()&&S.push(" ")},preserveSingleSpace:function(){D&&b.singleSpace()},trim:function(){for(;b._lastCharWhitespace();)S.pop()}},S=[],A=!1,k=!1,y=!1,O="";;){var v,N=function(){var t="";for(n&&h.test(n)&&(t=n);h.test(d());)t+=n;return t}(),D=""!==N,N=-1!==N.indexOf("\n"),C=O,O=n;if(!n)break;"/"===n&&"*"===f()?(v=0===R,(N||v)&&b.newLine(),S.push(g()),b.newLine(),v&&b.newLine(!0)):"/"===n&&"/"===f()?(N||"{"===C||b.trim(),b.singleSpace(),S.push(g()),b.newLine()):"@"===n?(b.preserveSingleSpace(),S.push(n),v=void 0,v=p,N=T(N=": , {}()[]/='\""),p=v-1,d(),(C=N).match(/[ :]$/)&&(d(),C=T(": ").replace(/\s$/,""),S.push(C),b.singleSpace()),(C=C.replace(/\s$/,""))in e&&(m+=1,C in r)&&(y=!0)):"#"===n&&"{"===f()?(b.preserveSingleSpace(),S.push(T("}"))):"{"===n?"}"===f(!0)?(E(),d(),b.singleSpace(),S.push("{}"),b.newLine(),c&&0===R&&b.newLine(!0)):(R++,x+=K,b["{"](n),A=y?(y=!1,m<R):m<=R):"}"===n?(R--,x=x.slice(0,-s),b["}"](n),k=A=!1,m&&m--,c&&0===R&&b.newLine(!0)):":"===n?(E(),!A&&!y||w("&")||function(){for(var t=0,e=p+1;e<i.length;e++){var n=i.charAt(e);if("{"===n)return 1;if("("===n)t+=1;else if(")"===n){if(0===t)return;--t}else if(" "===n||"}"===n)return}}()?":"===f()?(d(),S.push("::")):S.push(":"):(k=!0,S.push(":"),b.singleSpace())):'"'===n||"'"===n?(b.preserveSingleSpace(),S.push(T(n))):" "===n?(k=!1,S.push(n),b.newLine()):"("===n?w("url")?(S.push(n),E(),d()&&(")"!==n&&'"'!==n&&"'"!==n?S.push(T(")")):p--)):(u++,b.preserveSingleSpace(),S.push(n),E()):")"===n?(S.push(n),u--):","===n?(S.push(n),E(),a&&!k&&u<1?b.newLine():b.singleSpace()):("]"!==n&&("["!==n&&"="===n?(E(),n="="):b.preserveSingleSpace()),S.push(n))}t="";return x&&(t+=x),t+=S.join("").replace(/[\r\n\t ]+$/,""),o&&(t+="\n"),t="\n"!=l?t.replace(/[\n]/g,l):t}function G(t,e){for(var n=0;n<e.length;n+=1)if(e[n]===t)return!0;return!1}function X(t){return t.replace(/^\s+|\s+$/g,"")}function b(t,e){return new r(t,e).beautify()}t=z,e="\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0620-\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\u0840-\u0858\u08a0\u08a2-\u08ac\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0977\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\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\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-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\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\u16ee-\u16f0\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\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1ce9-\u1cec\u1cee-\u1cf1\u1cf5\u1cf6\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-\u209c\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2e2f\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua697\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\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\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\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",n=new RegExp("[".concat(e,"]")),i=new RegExp("[".concat(e," ").concat("\u0300-\u036f\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u0620-\u0649\u0672-\u06d3\u06e7-\u06e8\u06fb-\u06fc\u0730-\u074a\u0800-\u0814\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0840-\u0857\u08e4-\u08fe\u0900-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962-\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09d7\u09df-\u09e0\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2-\u0ae3\u0ae6-\u0aef\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b5f-\u0b60\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c01-\u0c03\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62-\u0c63\u0c66-\u0c6f\u0c82\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2-\u0ce3\u0ce6-\u0cef\u0d02\u0d03\u0d46-\u0d48\u0d57\u0d62-\u0d63\u0d66-\u0d6f\u0d82\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0df2\u0df3\u0e34-\u0e3a\u0e40-\u0e45\u0e50-\u0e59\u0eb4-\u0eb9\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f41-\u0f47\u0f71-\u0f84\u0f86-\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u1000-\u1029\u1040-\u1049\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u170e-\u1710\u1720-\u1730\u1740-\u1750\u1772\u1773\u1780-\u17b2\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u1920-\u192b\u1930-\u193b\u1951-\u196d\u19b0-\u19c0\u19c8-\u19c9\u19d0-\u19d9\u1a00-\u1a15\u1a20-\u1a53\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1b46-\u1b4b\u1b50-\u1b59\u1b6b-\u1b73\u1bb0-\u1bb9\u1be6-\u1bf3\u1c00-\u1c22\u1c40-\u1c49\u1c5b-\u1c7d\u1cd0-\u1cd2\u1d00-\u1dbe\u1e01-\u1f15\u200c\u200d\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2d81-\u2d96\u2de0-\u2dff\u3021-\u3028\u3099\u309a\ua640-\ua66d\ua674-\ua67d\ua69f\ua6f0-\ua6f1\ua7f8-\ua800\ua806\ua80b\ua823-\ua827\ua880-\ua881\ua8b4-\ua8c4\ua8d0-\ua8d9\ua8f3-\ua8f7\ua900-\ua909\ua926-\ua92d\ua930-\ua945\ua980-\ua983\ua9b3-\ua9c0\uaa00-\uaa27\uaa40-\uaa41\uaa4c-\uaa4d\uaa50-\uaa59\uaa7b\uaae0-\uaae9\uaaf2-\uaaf3\uabc0-\uabe1\uabec\uabed\uabf0-\uabf9\ufb20-\ufb28\ufe00-\ufe0f\ufe20-\ufe26\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f","]")),t.newline=/[\n\r\u2028\u2029]/,t.lineBreak=new RegExp("\r\n|".concat(t.newline.source)),t.allLineBreaks=new RegExp(t.lineBreak.source,"g"),t.isIdentifierStart=function(t){return t<65?36===t||64===t:t<91||(t<97?95===t:t<123||170<=t&&n.test(String.fromCharCode(t)))},t.isIdentifierChar=function(t){return t<48?36===t:t<58||!(t<65)&&(t<91||(t<97?95===t:t<123||170<=t&&i.test(String.fromCharCode(t))))};var L={BlockStatement:"BlockStatement",Statement:"Statement",ObjectLiteral:"ObjectLiteral",ArrayLiteral:"ArrayLiteral",ForInitializer:"ForInitializer",Conditional:"Conditional",Expression:"Expression"};function r(i,t){var _,r,s,a,o,c,e,l,n,h,p,u,d,f=[],T="";function E(t,e){var n=0;return t&&(n=t.indentation_level,!_.just_added_newline())&&t.line_indent_level>n&&(n=t.line_indent_level),{mode:e,parent:t,last_text:t?t.last_text:"",last_word:t?t.last_word:"",declaration_statement:!1,declaration_assignment:!1,multiline_frame:!1,if_block:!1,else_block:!1,do_block:!1,do_while:!1,in_case_statement:!1,in_case:!1,case_body:!1,indentation_level:n,line_indent_level:t?t.line_indent_level:n,start_line_index:_.get_line_number(),ternary_depth:0}}for(u={TK_START_EXPR:function(){v();var t=L.Expression;if("["===a.text){if("TK_WORD"===o||")"===l.last_text)return"TK_RESERVED"===o&&G(l.last_text,s.line_starters)&&(_.space_before_token=!0),S(t),m(),b(),void(d.space_in_paren&&(_.space_before_token=!0));t=L.ArrayLiteral,!A(l.mode)||"["!==l.last_text&&(","!==l.last_text||"]"!==c&&"}"!==c)||d.keep_array_indentation||K()}else"TK_RESERVED"===o&&"for"===l.last_text?t=L.ForInitializer:"TK_RESERVED"===o&&G(l.last_text,["if","while"])&&(t=L.Conditional);" "===l.last_text||"TK_START_BLOCK"===o?K():"TK_END_EXPR"===o||"TK_START_EXPR"===o||"TK_END_BLOCK"===o||"."===l.last_text?x(a.wanted_newline):"TK_RESERVED"===o&&"("===a.text||"TK_WORD"===o||"TK_OPERATOR"===o?"TK_RESERVED"===o&&("function"===l.last_word||"typeof"===l.last_word)||"*"===l.last_text&&"function"===c?d.space_after_anon_function&&(_.space_before_token=!0):"TK_RESERVED"!==o||!G(l.last_text,s.line_starters)&&"catch"!==l.last_text||d.space_before_conditional&&(_.space_before_token=!0):_.space_before_token=!0;"("===a.text&&"TK_RESERVED"===o&&"await"===l.last_word&&(_.space_before_token=!0);"("!==a.text||"TK_EQUALS"!==o&&"TK_OPERATOR"!==o||O()||x();S(t),m(),d.space_in_paren&&(_.space_before_token=!0);b()},TK_END_EXPR:function(){for(;l.mode===L.Statement;)y();l.multiline_frame&&x("]"===a.text&&A(l.mode)&&!d.keep_array_indentation);d.space_in_paren&&("TK_START_EXPR"!==o||d.space_in_empty_paren?_.space_before_token=!0:(_.trim(),_.space_before_token=!1));("]"===a.text&&d.keep_array_indentation?(m(),y):(y(),m))();_.remove_redundant_indentation(n),l.do_while&&n.mode===L.Conditional&&(n.mode=L.Expression,l.do_block=!1,l.do_while=!1)},TK_START_BLOCK:function(){var t=D(1),e=D(2);!e||!(":"===e.text&&G(t.type,["TK_STRING","TK_WORD","TK_RESERVED"])||G(t.text,["get","set"])&&G(e.type,["TK_WORD","TK_RESERVED"]))||G(c,["class","interface"])?S(L.BlockStatement):S(L.ObjectLiteral);e=!t.comments_before.length&&"}"===t.text&&"function"===l.last_word&&"TK_END_EXPR"===o;"expand"===d.brace_style||"none"===d.brace_style&&a.wanted_newline?"TK_OPERATOR"!==o&&(e||"TK_EQUALS"===o||"TK_RESERVED"===o&&N(l.last_text)&&"else"!==l.last_text)?_.space_before_token=!0:K(!1,!0):"TK_OPERATOR"!==o&&"TK_START_EXPR"!==o?"TK_START_BLOCK"===o?K():_.space_before_token=!0:A(n.mode)&&","===l.last_text&&("}"===c?_.space_before_token=!0:K());m(),b()},TK_END_BLOCK:function(){for(;l.mode===L.Statement;)y();var t="TK_START_BLOCK"===o;"expand"===d.brace_style?t||K():t||(A(l.mode)&&d.keep_array_indentation?(d.keep_array_indentation=!1,K(),d.keep_array_indentation=!0):K());y(),m()},TK_WORD:C,TK_RESERVED:C,TK_SEMICOLON:function(){v()&&(_.space_before_token=!1);for(;l.mode===L.Statement&&!l.if_block&&!l.do_block;)y();m()},TK_STRING:function(){v()||"TK_RESERVED"===o||"TK_WORD"===o?_.space_before_token=!0:"TK_COMMA"===o||"TK_START_EXPR"===o||"TK_EQUALS"===o||"TK_OPERATOR"===o?O()||x():K();m()},TK_EQUALS:function(){v();l.declaration_statement&&(l.declaration_assignment=!0);_.space_before_token=!0,m(),_.space_before_token=!0},TK_OPERATOR:function(){v();var t,e;"TK_RESERVED"===o&&N(l.last_text)?(_.space_before_token=!0,m()):"*"===a.text&&"TK_DOT"===o?m():":"===a.text&&l.in_case?(l.case_body=!0,b(),m(),K(),l.in_case=!1):"::"===a.text?m():("TK_OPERATOR"===o&&x(),e=t=!0,G(a.text,["--","++","!","~"])||G(a.text,["-","+"])&&(G(o,["TK_START_BLOCK","TK_START_EXPR","TK_EQUALS","TK_OPERATOR"])||G(l.last_text,s.line_starters)||","===l.last_text)?(e=t=!1,!a.wanted_newline||"--"!==a.text&&"++"!==a.text||K(!1,!0)," "===l.last_text&&k(l.mode)&&(t=!0),"TK_RESERVED"===o?t=!0:"TK_END_EXPR"===o?t=!("]"===l.last_text&&("--"===a.text||"++"===a.text)):"TK_OPERATOR"===o&&(t=G(a.text,["--","-","++","+"])&&G(l.last_text,["--","-","++","+"]),G(a.text,["+","-"]))&&G(l.last_text,["--","++"])&&(e=!0),l.mode!==L.BlockStatement&&l.mode!==L.Statement||"{"!==l.last_text&&" "!==l.last_text||K()):":"===a.text?0===l.ternary_depth?t=!1:--l.ternary_depth:"?"===a.text?l.ternary_depth+=1:"*"===a.text&&"TK_RESERVED"===o&&"function"===l.last_text&&(e=t=!1),_.space_before_token=_.space_before_token||t,m(),_.space_before_token=e)},TK_COMMA:function(){l.declaration_statement?(k(l.parent.mode)&&(l.declaration_assignment=!1),m(),l.declaration_assignment?K(l.declaration_assignment=!1,!0):(_.space_before_token=!0,d.comma_first&&x())):(m(),l.mode===L.ObjectLiteral||l.mode===L.Statement&&l.parent.mode===L.ObjectLiteral?(l.mode===L.Statement&&y(),K()):(_.space_before_token=!0,d.comma_first&&x()))},TK_BLOCK_COMMENT:function(){if(_.raw)_.add_raw_token(a),!a.directives||"end"!==a.directives.preserve||d.test_output_raw||(_.raw=!1);else if(a.directives)K(!1,!0),m(),"start"===a.directives.preserve&&(_.raw=!0),K(!1,!0);else if(z.newline.test(a.text)||a.wanted_newline){var t,e=function(t){t=t.replace(/\x0d/g,"");var e,n=[];e=t.indexOf("\n");for(;-1!==e;)n.push(t.substring(0,e)),t=t.substring(e+1),e=t.indexOf("\n");t.length&&n.push(t);return n}(a.text),n=!1,i=!1,r=a.whitespace_before,s=r.length;for(K(!1,!0),1<e.length&&(!function(t,e){for(var n=0;n<t.length;n++)if(X(t[n]).charAt(0)!==e)return;return 1}(e.slice(1),"*")?function(t,e){for(var n,i=0,r=t.length;i<r;i++)if((n=t[i])&&0!==n.indexOf(e))return;return 1}(e.slice(1),r)&&(i=!0):n=!0),m(e[0]),t=1;t<e.length;t++)K(!1,!0),n?m(" ".concat(e[t].replace(/^\s+/g,""))):i&&e[t].length>s?m(e[t].substring(s)):_.add_token(e[t]);K(!1,!0)}else _.space_before_token=!0,m(),_.space_before_token=!0},TK_COMMENT:function(){a.wanted_newline?K(!1,!0):_.trim(!0);_.space_before_token=!0,m(),K(!1,!0)},TK_DOT:function(){v();"TK_RESERVED"===o&&N(l.last_text)?_.space_before_token=!0:x(")"===l.last_text&&d.break_chained_methods);m()},TK_UNKNOWN:function(){m(),"\n"===a.text[a.text.length-1]&&K()},TK_EOF:function(){for(;l.mode===L.Statement;)y()}},d={},(t=t||{}).braces_on_own_line!==undefined&&(d.brace_style=t.braces_on_own_line?"expand":"collapse"),d.brace_style=t.brace_style||d.brace_style||"collapse","expand-strict"===d.brace_style&&(d.brace_style="expand"),d.indent_size=t.indent_size?parseInt(t.indent_size,10):4,d.indent_char=t.indent_char||" ",d.eol=t.eol||"\n",d.preserve_newlines=t.preserve_newlines===undefined||t.preserve_newlines,d.break_chained_methods=t.break_chained_methods!==undefined&&t.break_chained_methods,d.max_preserve_newlines=t.max_preserve_newlines===undefined?0:parseInt(t.max_preserve_newlines,10),d.space_in_paren=t.space_in_paren!==undefined&&t.space_in_paren,d.space_in_empty_paren=t.space_in_empty_paren!==undefined&&t.space_in_empty_paren,d.jslint_happy=t.jslint_happy!==undefined&&t.jslint_happy,d.space_after_anon_function=t.space_after_anon_function!==undefined&&t.space_after_anon_function,d.keep_array_indentation=t.keep_array_indentation!==undefined&&t.keep_array_indentation,d.space_before_conditional=t.space_before_conditional===undefined||t.space_before_conditional,d.unescape_strings=t.unescape_strings!==undefined&&t.unescape_strings,d.wrap_line_length=t.wrap_line_length===undefined?0:parseInt(t.wrap_line_length,10),d.e4x=t.e4x!==undefined&&t.e4x,d.end_with_newline=t.end_with_newline!==undefined&&t.end_with_newline,d.comma_first=t.comma_first!==undefined&&t.comma_first,d.test_output_raw=t.test_output_raw!==undefined&&t.test_output_raw,d.jslint_happy&&(d.space_after_anon_function=!0),t.indent_with_tabs&&(d.indent_char="\t",d.indent_size=1),d.eol=d.eol.replace(/\\r/,"\r").replace(/\\n/,"\n"),e="";0<d.indent_size;)e+=d.indent_char,--d.indent_size;var g=0;if(i&&i.length){for(;" "===i.charAt(g)||"\t"===i.charAt(g);)T+=i.charAt(g),g+=1;i=i.substring(g)}function w(t){var e=t.newlines;if(d.keep_array_indentation&&A(l.mode))for(var n=0;n<e;n+=1)K(0<n);else if(d.max_preserve_newlines&&e>d.max_preserve_newlines&&(e=d.max_preserve_newlines),d.preserve_newlines&&1<t.newlines){K();for(var i=1;i<e;i+=1)K(!0)}u[(a=t).type]()}function x(t){t=t!==undefined&&t,_.just_added_newline()||(d.preserve_newlines&&a.wanted_newline||t||d.wrap_line_length&&_.current_line.get_character_count()+a.text.length+(_.space_before_token?1:0)>=d.wrap_line_length)&&K(!1,!0)}function K(t,e){if(!e&&" "!==l.last_text&&","!==l.last_text&&"="!==l.last_text&&"TK_OPERATOR"!==o)for(;l.mode===L.Statement&&!l.if_block&&!l.do_block;)y();_.add_new_line(t)&&(l.multiline_frame=!0)}function R(){_.just_added_newline()&&(d.keep_array_indentation&&A(l.mode)&&a.wanted_newline?(_.current_line.push(a.whitespace_before),_.space_before_token=!1):_.set_indent(l.indentation_level)&&(l.line_indent_level=l.indentation_level))}function m(t){_.raw?_.add_raw_token(a):(d.comma_first&&"TK_COMMA"===o&&_.just_added_newline()&&","===_.previous_line.last()&&(_.previous_line.pop(),R(),_.add_token(","),_.space_before_token=!0),t=t||a.text,R(),_.add_token(t))}function b(){l.indentation_level+=1}function S(t){n=l?(h.push(l),l):E(null,t),l=E(n,t)}function A(t){return t===L.ArrayLiteral}function k(t){return G(t,[L.Expression,L.ForInitializer,L.Conditional])}function y(){0<h.length&&(n=l,l=h.pop(),n.mode===L.Statement)&&_.remove_redundant_indentation(n)}function O(){return l.parent.mode===L.ObjectLiteral&&l.mode===L.Statement&&(":"===l.last_text&&0===l.ternary_depth||"TK_RESERVED"===o&&G(l.last_text,["get","set"]))}function v(){return("TK_RESERVED"===o&&G(l.last_text,["const","let","const"])&&"TK_WORD"===a.type||"TK_RESERVED"===o&&"do"===l.last_text||"TK_RESERVED"===o&&"return"===l.last_text&&!a.wanted_newline||"TK_RESERVED"===o&&"else"===l.last_text&&("TK_RESERVED"!==a.type||"if"!==a.text)||"TK_END_EXPR"===o&&(n.mode===L.ForInitializer||n.mode===L.Conditional)||"TK_WORD"===o&&l.mode===L.BlockStatement&&!l.in_case&&"--"!==a.text&&"++"!==a.text&&"function"!==c&&"TK_WORD"!==a.type&&"TK_RESERVED"!==a.type||l.mode===L.ObjectLiteral&&(":"===l.last_text&&0===l.ternary_depth||"TK_RESERVED"===o&&G(l.last_text,["get","set"])))&&(S(L.Statement),b(),"TK_RESERVED"===o&&G(l.last_text,["const","let","const"])&&"TK_WORD"===a.type&&(l.declaration_statement=!0),O()||x("TK_RESERVED"===a.type&&G(a.text,["do","for","if","while"])),1)}function N(t){return G(t,["case","return","do","if","throw","else"])}function D(t){t=r+(t||0);return t<0||t>=f.length?null:f[t]}function C(){if("TK_RESERVED"===a.type&&l.mode!==L.ObjectLiteral&&G(a.text,["set","get"])&&(a.type="TK_WORD"),"TK_RESERVED"===a.type&&l.mode===L.ObjectLiteral&&":"===D(1).text&&(a.type="TK_WORD"),v()||!a.wanted_newline||k(l.mode)||"TK_OPERATOR"===o&&"--"!==l.last_text&&"++"!==l.last_text||"TK_EQUALS"===o||!d.preserve_newlines&&"TK_RESERVED"===o&&G(l.last_text,["const","let","const","set","get"])||K(),l.do_block&&!l.do_while){if("TK_RESERVED"===a.type&&"while"===a.text)return _.space_before_token=!0,m(),_.space_before_token=!0,void(l.do_while=!0);K(),l.do_block=!1}if(l.if_block)if(l.else_block||"TK_RESERVED"!==a.type||"else"!==a.text){for(;l.mode===L.Statement;)y();l.if_block=!1,l.else_block=!1}else l.else_block=!0;"TK_RESERVED"===a.type&&("case"===a.text||"default"===a.text&&l.in_case_statement)?(K(),(l.case_body||d.jslint_happy)&&(0<l.indentation_level&&(!l.parent||l.indentation_level>l.parent.indentation_level)&&--l.indentation_level,l.case_body=!1),m(),l.in_case=!0,l.in_case_statement=!0):("TK_RESERVED"===a.type&&"function"===a.text&&(!(G(l.last_text,["}"," "])||_.just_added_newline()&&!G(l.last_text,["[","{",":","=",","]))||_.just_added_blankline()||a.comments_before.length||(K(),K(!0)),"TK_RESERVED"===o||"TK_WORD"===o?"TK_RESERVED"===o&&G(l.last_text,["get","set","new","return","export","async"])||"TK_RESERVED"===o&&"default"===l.last_text&&"export"===c?_.space_before_token=!0:K():"TK_OPERATOR"===o||"="===l.last_text?_.space_before_token=!0:!l.multiline_frame&&(k(l.mode)||A(l.mode))||K()),"TK_COMMA"!==o&&"TK_START_EXPR"!==o&&"TK_EQUALS"!==o&&"TK_OPERATOR"!==o||O()||x(),"TK_RESERVED"===a.type&&G(a.text,["function","get","set"])?(m(),l.last_word=a.text):(p="NONE","TK_END_BLOCK"===o?"TK_RESERVED"!==a.type||!G(a.text,["else","catch","finally"])||"expand"===d.brace_style||"end-expand"===d.brace_style||"none"===d.brace_style&&a.wanted_newline?p="NEWLINE":(p="SPACE",_.space_before_token=!0):"TK_SEMICOLON"===o&&l.mode===L.BlockStatement?p="NEWLINE":"TK_SEMICOLON"===o&&k(l.mode)?p="SPACE":"TK_STRING"===o?p="NEWLINE":"TK_RESERVED"===o||"TK_WORD"===o||"*"===l.last_text&&"function"===c?p="SPACE":"TK_START_BLOCK"===o?p="NEWLINE":"TK_END_EXPR"===o&&(_.space_before_token=!0,p="NEWLINE"),"TK_RESERVED"===a.type&&G(a.text,s.line_starters)&&")"!==l.last_text&&(p="else"===l.last_text||"export"===l.last_text?"SPACE":"NEWLINE"),"TK_RESERVED"===a.type&&G(a.text,["else","catch","finally"])?"TK_END_BLOCK"!==o||"expand"===d.brace_style||"end-expand"===d.brace_style||"none"===d.brace_style&&a.wanted_newline?K():(_.trim(!0),"}"!==_.current_line.last()&&K(),_.space_before_token=!0):"NEWLINE"===p?"TK_RESERVED"===o&&N(l.last_text)?_.space_before_token=!0:"TK_END_EXPR"!==o?"TK_START_EXPR"===o&&"TK_RESERVED"===a.type&&G(a.text,["const","let","const"])||":"===l.last_text||("TK_RESERVED"===a.type&&"if"===a.text&&"else"===l.last_text?_.space_before_token=!0:K()):"TK_RESERVED"===a.type&&G(a.text,s.line_starters)&&")"!==l.last_text&&K():l.multiline_frame&&A(l.mode)&&","===l.last_text&&"}"===c?K():"SPACE"===p&&(_.space_before_token=!0),m(),l.last_word=a.text,"TK_RESERVED"===a.type&&"do"===a.text&&(l.do_block=!0),"TK_RESERVED"===a.type&&"if"===a.text&&(l.if_block=!0)))}o="TK_START_BLOCK",c="",(_=new I(e,T)).raw=d.test_output_raw,h=[],S(L.BlockStatement),this.beautify=function(){var t,e;for(s=new V(i,d),f=s.tokenize(),r=0;t=D();){for(var n=0;n<t.comments_before.length;n++)w(t.comments_before[n]);w(t),c=l.last_text,o=t.type,l.last_text=t.text,r+=1}return e=_.get_code(),d.end_with_newline&&(e+="\n"),e="\n"!=d.eol?e.replace(/[\n]/g,d.eol):e}}function s(e){var n=0,i=-1,r=[],s=!0;this.set_indent=function(t){n=e.baseIndentLength+t*e.indent_length,i=t},this.get_character_count=function(){return n},this.is_empty=function(){return s},this.last=function(){return this._empty?null:r[r.length-1]},this.push=function(t){r.push(t),n+=t.length,s=!1},this.pop=function(){var t=null;return s||(t=r.pop(),n-=t.length,s=0===r.length),t},this.remove_indent=function(){0<i&&(--i,n-=e.indent_length)},this.trim=function(){for(;" "===this.last();)r.pop(),--n;s=0===r.length},this.toString=function(){var t="";return this._empty||(0<=i&&(t=e.indent_cache[i]),t+=r.join("")),t}}function I(e,n){n=n||"",this.indent_cache=[n],this.baseIndentLength=n.length,this.indent_length=e.length,this.raw=!1;var i=[];this.baseIndentString=n,this.indent_string=e,this.previous_line=null,this.current_line=null,this.space_before_token=!1,this.add_outputline=function(){this.previous_line=this.current_line,this.current_line=new s(this),i.push(this.current_line)},this.add_outputline(),this.get_line_number=function(){return i.length},this.add_new_line=function(t){return!(1===this.get_line_number()&&this.just_added_newline()||!t&&this.just_added_newline()||(this.raw||this.add_outputline(),0))},this.get_code=function(){return i.join("\n").replace(/[\r\n\t ]+$/,"")},this.set_indent=function(t){if(1<i.length){for(;t>=this.indent_cache.length;)this.indent_cache.push(this.indent_cache[this.indent_cache.length-1]+this.indent_string);return this.current_line.set_indent(t),!0}return this.current_line.set_indent(0),!1},this.add_raw_token=function(t){for(var e=0;e<t.newlines;e++)this.add_outputline();this.current_line.push(t.whitespace_before),this.current_line.push(t.text),this.space_before_token=!1},this.add_token=function(t){this.add_space_before_token(),this.current_line.push(t)},this.add_space_before_token=function(){this.space_before_token&&!this.just_added_newline()&&this.current_line.push(" "),this.space_before_token=!1},this.remove_redundant_indentation=function(t){if(!t.multiline_frame&&t.mode!==L.ForInitializer&&t.mode!==L.Conditional)for(var e=t.start_line_index,n=i.length;e<n;)i[e].remove_indent(),e++},this.trim=function(t){for(t=t!==undefined&&t,this.current_line.trim(e,n);t&&1<i.length&&this.current_line.is_empty();)i.pop(),this.current_line=i[i.length-1],this.current_line.trim();this.previous_line=1<i.length?i[i.length-2]:null},this.just_added_newline=function(){return this.current_line.is_empty()},this.just_added_blankline=function(){return!!this.just_added_newline()&&(1===i.length||i[i.length-2].is_empty())}}var F=function F(t,e,n,i,r,s){this.type=t,this.text=e,this.comments_before=[],this.newlines=n||0,this.wanted_newline=0<n,this.whitespace_before=i||"",this.parent=null,this.directives=null};function V(m,b,t){var S,A,k,y,O,v,N="\n\r\t ".split(""),D=/[0-9]/,C=/[01234567]/,L=/[0123456789abcdefABCDEF]/,I="+ - * / % & ++ -- = += -= *= /= %= == === != !== > < >= <= >> << >>> >>>= >>= <<= && &= | || ! ~ , : ? ^ ^= |= :: =>".split(" "),V=(this.line_starters="continue,try,throw,return,const,let,const,if,switch,case,default,for,while,break,function,import,export".split(","),this.line_starters.concat(["do","in","else","get","set","new","catch","finally","typeof","yield","async","await"])),P=/([\s\S]*?)((?:\*\/)|$)/g,B=/([^\n\r\u2028\u2029]*)/g,j=/\/\* beautify( \w+[:]\w+)+ \*\//g,M=/ (\w+)[:](\w+)/g,U=/([\s\S]*?)((?:\/\*\sbeautify\signore:end\s\*\/)|$)/g,W=/((<\?php|<\?=)[\s\S]*?\?>)|(<%[\s\S]*?%>)/g;function _(){var t=[];if(S=0,A="",v<=O)return["","TK_EOF"];var e=y.length?y[y.length-1]:new F("TK_START_BLOCK","{"),n=m.charAt(O);for(O+=1;G(n,N);){if(z.newline.test(n)?"\n"===n&&"\r"===m.charAt(O-2)||(S+=1,t=[]):t.push(n),v<=O)return["","TK_EOF"];n=m.charAt(O),O+=1}if(t.length&&(A=t.join("")),D.test(n)){var i=!0,r=!0,s=D;for("0"===n&&O<v&&/[Xxo]/.test(m.charAt(O))?(r=i=!1,n+=m.charAt(O),O+=1,s=/[o]/.test(m.charAt(O))?C:L):(n="",--O);O<v&&s.test(m.charAt(O));)n+=m.charAt(O),O+=1,i&&O<v&&"."===m.charAt(O)&&(n+=m.charAt(O),O+=1,i=!1),r&&O<v&&/[Ee]/.test(m.charAt(O))&&(n+=m.charAt(O),(O+=1)<v&&/[+-]/.test(m.charAt(O))&&(n+=m.charAt(O),O+=1),i=r=!1);return[n,"TK_WORD"]}if(z.isIdentifierStart(m.charCodeAt(O-1))){if(O<v)for(;z.isIdentifierChar(m.charCodeAt(O))&&(n+=m.charAt(O),(O+=1)!==v););return"TK_DOT"===e.type||"TK_RESERVED"===e.type&&G(e.text,["set","get"])||!G(n,V)?[n,"TK_WORD"]:"in"===n?[n,"TK_OPERATOR"]:[n,"TK_RESERVED"]}if("("===n||"["===n)return[n,"TK_START_EXPR"];if(")"===n||"]"===n)return[n,"TK_END_EXPR"];if("{"===n)return[n,"TK_START_BLOCK"];if("}"===n)return[n,"TK_END_BLOCK"];if(" "===n)return[n,"TK_SEMICOLON"];if("/"===n){var _="";if("*"===m.charAt(O))return O+=1,P.lastIndex=O,R=P.exec(m),_="/*".concat(R[0]),O+=R[0].length,(x=function(t){if(!t.match(j))return null;for(var e={},n=(M.lastIndex=0,M.exec(t));n;)e[n[1]]=n[2],n=M.exec(t);return e}(_))&&"start"===x.ignore&&(U.lastIndex=O,_+=(R=U.exec(m))[0],O+=R[0].length),[_=_.replace(z.lineBreak,"\n"),"TK_BLOCK_COMMENT",x];if("/"===m.charAt(O))return O+=1,B.lastIndex=O,R=B.exec(m),_="//".concat(R[0]),O+=R[0].length,[_,"TK_COMMENT"]}if("`"===n||"'"===n||'"'===n||("/"===n||b.e4x&&"<"===n&&m.slice(O-1).match(/^<([-a-zA-Z:0-9_.]+|{[^{}]*}|!\[CDATA\[[\s\S]*?\]\])(\s+[-a-zA-Z:0-9_.]+\s*=\s*('[^']*'|"[^"]*"|{.*?}))*\s*(\/?)\s*>/))&&("TK_RESERVED"===e.type&&G(e.text,["return","case","throw","else","do","typeof","yield"])||"TK_END_EXPR"===e.type&&")"===e.text&&e.parent&&"TK_RESERVED"===e.parent.type&&G(e.parent.text,["if","while","for"])||G(e.type,["TK_COMMENT","TK_START_EXPR","TK_START_BLOCK","TK_END_BLOCK","TK_OPERATOR","TK_EQUALS","TK_EOF","TK_SEMICOLON","TK_COMMA"]))){var a=n,o=!1,c=!1,l=n;if("/"===a)for(var h=!1;O<v&&(o||h||m.charAt(O)!==a)&&!z.newline.test(m.charAt(O));)l+=m.charAt(O),o?o=!1:(o="\\"===m.charAt(O),"["===m.charAt(O)?h=!0:"]"===m.charAt(O)&&(h=!1)),O+=1;else if(b.e4x&&"<"===a){var p=/<(\/?)([-a-zA-Z:0-9_.]+|{[^{}]*}|!\[CDATA\[[\s\S]*?\]\])(\s+[-a-zA-Z:0-9_.]+\s*=\s*('[^']*'|"[^"]*"|{.*?}))*\s*(\/?)\s*>/g,u=m.slice(O-1),d=p.exec(u);if(d&&0===d.index){for(var f=d[2],T=0;d;){var E=!!d[1],g=d[2],w=!!d[d.length-1]||"![CDATA["===g.slice(0,8);if(g!==f||w||(E?--T:++T),T<=0)break;d=p.exec(u)}var x=d?d.index+d[0].length:u.length,u=u.slice(0,x);return O+=x-1,[u=u.replace(z.lineBreak,"\n"),"TK_STRING"]}}else for(;O<v&&(o||m.charAt(O)!==a&&("`"===a||!z.newline.test(m.charAt(O))));)(o||"`"===a)&&z.newline.test(m.charAt(O))?("\r"===m.charAt(O)&&"\n"===m.charAt(O+1)&&(O+=1),l+="\n"):l+=m.charAt(O),o=o?("x"!==m.charAt(O)&&"u"!==m.charAt(O)||(c=!0),!1):"\\"===m.charAt(O),O+=1;if(c&&b.unescape_strings&&(l=function(t){var e,n=!1,i="",r=0,s="",_=0;for(;n||r<t.length;)if(e=t.charAt(r),r++,n){if(n=!1,"x"===e)s=t.substr(r,2),r+=2;else{if("u"!==e){i+="\\".concat(e);continue}s=t.substr(r,4),r+=4}if(!s.match(/^[0123456789abcdefABCDEF]+$/))return t;if(0<=(_=parseInt(s,16))&&_<32)i+=("x"===e?"\\x":"\\u").concat(s);else if(34===_||39===_||92===_)i+="\\".concat(String.fromCharCode(_));else{if("x"===e&&126<_&&_<=255)return t;i+=String.fromCharCode(_)}}else"\\"===e?n=!0:i+=e;return i}(l)),O<v&&m.charAt(O)===a&&(l+=a,O+=1,"/"===a))for(;O<v&&z.isIdentifierStart(m.charCodeAt(O));)l+=m.charAt(O),O+=1;return[l,"TK_STRING"]}if("#"===n){if(0===y.length&&"!"===m.charAt(O)){for(l=n;O<v&&"\n"!==n;)l+=n=m.charAt(O),O+=1;return["".concat(X(l),"\n"),"TK_UNKNOWN"]}var K="#";if(O<v&&D.test(m.charAt(O))){for(;K+=n=m.charAt(O),(O+=1)<v&&"#"!==n&&"="!==n;);return"#"!==n&&("["===m.charAt(O)&&"]"===m.charAt(O+1)?(K+="[]",O+=2):"{"===m.charAt(O)&&"}"===m.charAt(O+1)&&(K+="{}",O+=2)),[K,"TK_WORD"]}}if("<"===n&&("?"===m.charAt(O)||"%"===m.charAt(O))){W.lastIndex=O-1;var R=W.exec(m);if(R)return n=R[0],O+=n.length-1,[n=n.replace(z.lineBreak,"\n"),"TK_STRING"]}if("<"===n&&"\x3c!--"===m.substring(O-1,O+3)){for(O+=3,n="\x3c!--";!z.newline.test(m.charAt(O))&&O<v;)n+=m.charAt(O),O++;return k=!0,[n,"TK_COMMENT"]}if("-"===n&&k&&"--\x3e"===m.substring(O-1,O+2))return k=!1,O+=2,["--\x3e","TK_COMMENT"];if("."===n)return[n,"TK_DOT"];if(G(n,I)){for(;O<v&&G(n+m.charAt(O),I)&&(n+=m.charAt(O),!(v<=(O+=1))););return","===n?[n,"TK_COMMA"]:"="===n?[n,"TK_EQUALS"]:[n,"TK_OPERATOR"]}return[n,"TK_UNKNOWN"]}this.tokenize=function(){v=m.length,O=0,k=!1,y=[];for(var t,e,n,i=null,r=[],s=[];!e||"TK_EOF"!==e.type;){for(n=_(),t=new F(n[1],n[0],S,A);"TK_COMMENT"===t.type||"TK_BLOCK_COMMENT"===t.type||"TK_UNKNOWN"===t.type;)"TK_BLOCK_COMMENT"===t.type&&(t.directives=n[2]),s.push(t),n=_(),t=new F(n[1],n[0],S,A);s.length&&(t.comments_before=s,s=[]),"TK_START_BLOCK"===t.type||"TK_START_EXPR"===t.type?(t.parent=e,r.push(i),i=t):("TK_END_BLOCK"===t.type||"TK_END_EXPR"===t.type)&&i&&("]"===t.text&&"["===i.text||")"===t.text&&"("===i.text||"}"===t.text&&"{"===i.text)&&(t.parent=i.parent,i=r.pop()),y.push(t),e=t}return y}}return{run:function(t,e){function _(t){return t.replace(/\s+$/g,"")}var n,i,r,d,s,a,f,o,c,T,E,g,l,h;for((e=e||{}).wrap_line_length!==undefined&&0!==parseInt(e.wrap_line_length,10)||e.max_char===undefined||0===parseInt(e.max_char,10)||(e.wrap_line_length=e.max_char),i=e.indent_inner_html!==undefined&&e.indent_inner_html,r=e.indent_size===undefined?4:parseInt(e.indent_size,10),d=e.indent_char===undefined?" ":e.indent_char,a=e.brace_style===undefined?"collapse":e.brace_style,s=0===parseInt(e.wrap_line_length,10)?32786:parseInt(e.wrap_line_length||250,10),f=e.unformatted||["a","span","img","bdo","em","strong","dfn","code","samp","kbd","const","cite","abbr","acronym","q","sub","sup","tt","i","b","big","small","u","s","strike","font","ins","del","address","pre"],o=e.preserve_newlines===undefined||e.preserve_newlines,c=o?isNaN(parseInt(e.max_preserve_newlines,10))?32786:parseInt(e.max_preserve_newlines,10):0,T=e.indent_handlebars!==undefined&&e.indent_handlebars,E=e.wrap_attributes===undefined?"auto":e.wrap_attributes,g=e.wrap_attributes_indent_size!==undefined&&parseInt(e.wrap_attributes_indent_size,10)||r,l=e.end_with_newline!==undefined&&e.end_with_newline,h=Array.isArray(e.extra_liners)?e.extra_liners.concat():("string"==typeof e.extra_liners?e.extra_liners:"head,body,/html").split(","),e.indent_with_tabs&&(d="\t",r=1),(n=new function(){return this.pos=0,this.token="",this.current_mode="CONTENT",this.tags={parent:"parent1",parentcount:1,parent1:""},this.tag_type="",this.token_text=this.last_token=this.last_text=this.token_type="",this.newlines=0,this.indent_content=i,this.Utils={whitespace:"\n\r\t ".split(""),single_token:"br,input,link,meta,source,!doctype,basefont,base,area,hr,wbr,param,img,isindex,embed".split(","),extra_liners:h,in_array:function G(t,e){for(var n=0;n<e.length;n++)if(t===e[n])return!0;return!1}},this.is_whitespace=function(t){for(;0<t.length;t++)if(!this.Utils.in_array(t.charAt(0),this.Utils.whitespace))return!1;return!0},this.traverse_whitespace=function(){var t="",t=this.input.charAt(this.pos);if(this.Utils.in_array(t,this.Utils.whitespace)){for(this.newlines=0;this.Utils.in_array(t,this.Utils.whitespace);)o&&"\n"===t&&this.newlines<=c&&(this.newlines+=1),this.pos++,t=this.input.charAt(this.pos);return!0}return!1},this.space_or_wrap=function(t){this.line_char_count>=this.wrap_line_length?(this.print_newline(!1,t),this.print_indentation(t)):(this.line_char_count++,t.push(" "))},this.get_content=function(){for(var t=[];"<"!=this.input.charAt(this.pos);){if(this.pos>=this.input.length)return t.length?t.join(""):["","TK_EOF"];if(this.traverse_whitespace())this.space_or_wrap(t);else{if(T){var e=this.input.substr(this.pos,3);if("{{#"===e||"{{/"===e)break;if("{{!"===e)return[this.get_tag(),"TK_TAG_HANDLEBARS_COMMENT"];if("{{"===this.input.substr(this.pos,2)&&"{{else}}"===this.get_tag(!0))break}e=this.input.charAt(this.pos),this.pos++,this.line_char_count++,t.push(e)}}return t.length?t.join(""):""},this.get_contents_to=function(t){var e;return this.pos===this.input.length?["","TK_EOF"]:(e="",(t=new RegExp("</".concat(t,"\\s*>"),"igm")).lastIndex=this.pos,t=(t=t.exec(this.input))?t.index:this.input.length,this.pos<t&&(e=this.input.substring(this.pos,t),this.pos=t),e)},this.record_tag=function(t){this.tags["".concat(t,"count")]?this.tags["".concat(t,"count")]++:this.tags["".concat(t,"count")]=1,this.tags[t+this.tags["".concat(t,"count")]]=this.indent_level,this.tags[t+this.tags["".concat(t,"count")]+"parent"]=this.tags.parent,this.tags.parent=t+this.tags["".concat(t,"count")]},this.retrieve_tag=function(t){if(this.tags["".concat(t,"count")]){for(var e=this.tags.parent;e&&t+this.tags["".concat(t,"count")]!==e;)e=this.tags["".concat(e,"parent")];e&&(this.indent_level=this.tags[t+this.tags["".concat(t,"count")]],this.tags.parent=this.tags[e+"parent"]),delete this.tags[t+this.tags["".concat(t,"count")]+"parent"],delete this.tags[t+this.tags["".concat(t,"count")]],1===this.tags["".concat(t,"count")]?delete this.tags["".concat(t,"count")]:this.tags["".concat(t,"count")]--}},this.indent_to_tag=function(t){if(this.tags["".concat(t,"count")]){for(var e=this.tags.parent;e&&t+this.tags["".concat(t,"count")]!==e;)e=this.tags["".concat(e,"parent")];e&&(this.indent_level=this.tags[t+this.tags["".concat(t,"count")]])}},this.get_tag=function(t){var e,n,i="",r=[],s=!1,_=!0,a=this.pos,o=this.line_char_count;t=t!==undefined&&t;do{if(this.pos>=this.input.length)return t&&(this.pos=a,this.line_char_count=o),r.length?r.join(""):["","TK_EOF"];if(i=this.input.charAt(this.pos),this.pos++,this.Utils.in_array(i,this.Utils.whitespace))s=!0;else{if("'"!==i&&'"'!==i||(i+=this.get_unformatted(i),s=!0),"="===i&&(s=!1),r.length&&"="!=r[r.length-1]&&">"!=i&&s){if(this.space_or_wrap(r),s=!1,!_&&"force"===E&&"/"!=i){this.print_newline(!0,r),this.print_indentation(r);for(var c=0;c<g;c++)r.push(d)}for(var l=0;l<r.length;l++)if(" "===r[l]){_=!1;break}}if(T&&"<"===n&&i+this.input.charAt(this.pos)==="{{"&&(i+=this.get_unformatted("}}"),r.length&&" "!=r[r.length-1]&&"<"!=r[r.length-1]&&(i=" ".concat(i)),s=!0),"<"!==i||n||(e=this.pos-1,n="<"),T&&!n&&2<=r.length&&"{"===r[r.length-1]&&"{"===r[r.length-2]&&(e="#"===i||"/"===i||"!"===i?this.pos-3:this.pos-2,n="{"),this.line_char_count++,r.push(i),r[1]&&("!"===r[1]||"?"===r[1]||"%"===r[1])){r=[this.get_comment(e)];break}if(T&&r[1]&&"{"===r[1]&&r[2]&&"!"===r[2]){r=[this.get_comment(e)];break}if(T&&"{"===n&&2<r.length&&"}"===r[r.length-2]&&"}"===r[r.length-1])break}}while(">"!=i);var h=r.join(""),p=-1!=h.indexOf(" ")?h.indexOf(" "):"{"===h[0]?h.indexOf("}"):h.indexOf(">"),u="<"!==h[0]&&T?"#"===h[2]?3:2:1,u=h.substring(u,p).toLowerCase();return"/"===h.charAt(h.length-2)||this.Utils.in_array(u,this.Utils.single_token)?t||(this.tag_type="SINGLE"):T&&"{"===h[0]&&"else"===u?t||(this.indent_to_tag("if"),this.tag_type="HANDLEBARS_ELSE",this.indent_content=!0,this.traverse_whitespace()):this.is_unformatted(u,f)?(p=this.get_unformatted("</".concat(u,">"),h),r.push(p),this.pos,this.tag_type="SINGLE"):"script"===u&&(-1===h.search("type")||-1<h.search("type")&&-1<h.search(/\b(text|application)\/(x-)?(javascript|ecmascript|jscript|livescript)/))?t||(this.record_tag(u),this.tag_type="SCRIPT"):"style"===u&&(-1===h.search("type")||-1<h.search("type")&&-1<h.search("text/css"))?t||(this.record_tag(u),this.tag_type="STYLE"):"!"===u.charAt(0)?t||(this.tag_type="SINGLE",this.traverse_whitespace()):t||("/"===u.charAt(0)?(this.retrieve_tag(u.substring(1)),this.tag_type="END"):(this.record_tag(u),"html"!=u.toLowerCase()&&(this.indent_content=!0),this.tag_type="START"),this.traverse_whitespace()&&this.space_or_wrap(r),this.Utils.in_array(u,this.Utils.extra_liners)&&(this.print_newline(!1,this.output),this.output.length)&&"\n"!=this.output[this.output.length-2]&&this.print_newline(!0,this.output)),t&&(this.pos=a,this.line_char_count=o),r.join("")},this.get_comment=function(t){var e="",n=">",i=!1,r=(this.pos=t,this.input.charAt(this.pos));for(this.pos++;this.pos<=this.input.length&&((e+=r)[e.length-1]!==n[n.length-1]||-1==e.indexOf(n));)!i&&e.length<10&&(0===e.indexOf("<![if")?(n="<![endif]>",i=!0):0===e.indexOf("<![cdata[")?(n="]]>",i=!0):0===e.indexOf("<![")?(n="]>",i=!0):0===e.indexOf("\x3c!--")?(n="--\x3e",i=!0):0===e.indexOf("{{!")?(n="}}",i=!0):0===e.indexOf("<?")?(n="?>",i=!0):0===e.indexOf("<%")&&(n="%>",i=!0)),r=this.input.charAt(this.pos),this.pos++;return e},this.get_unformatted=function(t,e){if(e&&-1!=e.toLowerCase().indexOf(t))return"";var n="",i="",r=!0,s="";do{if(this.pos>=this.input.length)return i;if(n=this.input.charAt(this.pos),this.pos++,this.Utils.in_array(n,this.Utils.whitespace)){if(!r){this.line_char_count--;continue}if("\n"===n||"\r"===n){i+="\n",this.line_char_count=0;continue}}i+=n,(s+=n.toLowerCase()).length>t.length&&(s=s.substring(1)),this.line_char_count++,r=!0,T&&"{"===n&&i.length&&"{"===i[i.length-2]&&(i+=this.get_unformatted("}}"))}while(s!==t);return i},this.get_token=function(){var t,e;return"TK_TAG_SCRIPT"===this.last_token||"TK_TAG_STYLE"===this.last_token?(t=this.last_token.substr(7),"string"!=typeof(e=this.get_contents_to(t))?e:[e,"TK_".concat(t)]):"CONTENT"===this.current_mode?"string"!=typeof(e=this.get_content())?e:[e,"TK_CONTENT"]:"TAG"===this.current_mode?"string"!=typeof(e=this.get_tag())?e:[e,"TK_TAG_".concat(this.tag_type)]:void 0},this.get_full_indent=function(t){return(t=this.indent_level+t||0)<1?"":new Array(t+1).join(this.indent_string)},this.is_unformatted=function(t,e){return!(!this.Utils.in_array(t,e)||"a"==t.toLowerCase()&&this.Utils.in_array("a",e)&&(t=(this.get_tag(!0)||"").match(/^\s*<\s*\/?([a-z]*)\s*[^>]*>\s*$/))&&!this.Utils.in_array(t,e))},this.printer=function(t,e,n,i,r){this.input=t||"",this.output=[],this.indent_character=e,this.indent_string="",this.indent_size=n,this.brace_style=r,this.indent_level=0,this.wrap_line_length=i;for(var s=this.line_char_count=0;s<this.indent_size;s++)this.indent_string+=this.indent_character;this.print_newline=function(t,e){this.line_char_count=0,e&&e.length&&(!t&&"\n"==e[e.length-1]||("\n"!=e[e.length-1]&&(e[e.length-1]=_(e[e.length-1])),e.push("\n")))},this.print_indentation=function(t){for(var e=0;e<this.indent_level;e++)t.push(this.indent_string),this.line_char_count+=this.indent_string.length},this.print_token=function(t){this.is_whitespace(t)&&!this.output.length||((t||""!==t)&&this.output.length&&"\n"===this.output[this.output.length-1]&&(this.print_indentation(this.output),t=t.replace(/^\s+/g,"")),this.print_token_raw(t))},this.print_token_raw=function(t){(t=0<this.newlines?_(t):t)&&""!==t&&(1<t.length&&"\n"===t[t.length-1]?(this.output.push(t.slice(0,-1)),this.print_newline(!1,this.output)):this.output.push(t));for(var e=0;e<this.newlines;e++)this.print_newline(0<e,this.output);this.newlines=0},this.indent=function(){this.indent_level++},this.unindent=function(){0<this.indent_level&&this.indent_level--}},this}).printer(t,d,r,s,a);;){var p,u,w,x,K=n.get_token();if(n.token_text=K[0],n.token_type=K[1],"TK_EOF"===n.token_type)break;switch(n.token_type){case"TK_TAG_START":n.print_newline(!1,n.output),n.print_token(n.token_text),n.indent_content&&(n.indent(),n.indent_content=!1),n.current_mode="CONTENT";break;case"TK_TAG_STYLE":case"TK_TAG_SCRIPT":n.print_newline(!1,n.output),n.print_token(n.token_text),n.current_mode="CONTENT";break;case"TK_TAG_END":"TK_CONTENT"===n.last_token&&""===n.last_text&&(R=n.token_text.match(/\w+/)[0],(x=null)!==(x=n.output.length?n.output[n.output.length-1].match(/(?:<|{{#)\/?\s*(\w+)/):x)&&(x[1]==R||n.Utils.in_array(x[1],f))||n.print_newline(!1,n.output)),n.print_token(n.token_text),n.current_mode="CONTENT";break;case"TK_TAG_SINGLE":var R=n.token_text.match(/^\s*<([a-z-]+)/i);R&&n.Utils.in_array(R[1],f)||n.print_newline(!1,n.output),n.print_token(n.token_text),n.current_mode="CONTENT";break;case"TK_TAG_HANDLEBARS_ELSE":n.print_token(n.token_text),n.indent_content&&(n.indent(),n.indent_content=!1),n.current_mode="CONTENT";break;case"TK_TAG_HANDLEBARS_COMMENT":case"TK_CONTENT":n.print_token(n.token_text),n.current_mode="TAG";break;case"TK_STYLE":case"TK_SCRIPT":""!==n.token_text&&(n.print_newline(!1,n.output),x=n.token_text,u=void 0,w=1,"TK_SCRIPT"===n.token_type?u=b:"TK_STYLE"===n.token_type&&(u=m),"keep"===e.indent_scripts?w=0:"separate"===e.indent_scripts&&(w=-n.indent_level),p=n.get_full_indent(w),x=u?u(x.replace(/^\s*/,p),e):(u=x.match(/^\s*/)[0].match(/[^\n\r]*$/)[0].split(n.indent_string).length-1,w=n.get_full_indent(w-u),x.replace(/^\s*/,p).replace(/\r\n|\r|\n/g,"\n"+w).replace(/\s+$/,"")))&&(n.print_token_raw(x),n.print_newline(!0,n.output)),n.current_mode="TAG";break;default:""!==n.token_text&&n.print_token(n.token_text)}n.last_token=n.token_type,n.last_text=n.token_text}return t=n.output.join("").replace(/[\r\n\t ]+$/,""),l&&(t+="\n"),t}}}});