@firestitch/froala
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.
3 lines (2 loc) • 42.3 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(require("froala-editor")):"function"==typeof define&&define.amd?define(["froala-editor"],e):e(t.FroalaEditor)}(this,function(t){"use strict";(t=t&&t.hasOwnProperty("default")?t.default: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=void 0===t.selector_separator_newline||t.selector_separator_newline,o=void 0!==t.end_with_newline&&t.end_with_newline,c=void 0===t.newline_between_rules||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(),v.push(t),b.newLine()},"}":function(t){b.newLine(),v.push(t),b.newLine()},_lastCharWhitespace:function(){return h.test(v[v.length-1])},newLine:function(t){v.length&&(t||"\n"===v[v.length-1]||b.trim(),v.push("\n"),x)&&v.push(x)},singleSpace:function(){v.length&&!b._lastCharWhitespace()&&v.push(" ")},preserveSingleSpace:function(){D&&b.singleSpace()},trim:function(){for(;b._lastCharWhitespace();)v.pop()}},v=[],S=!1,A=!1,k=!1,y="";;){var O,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=y,y=n;if(!n)break;"/"===n&&"*"===f()?(O=0===R,(N||O)&&b.newLine(),v.push(g()),b.newLine(),O&&b.newLine(!0)):"/"===n&&"/"===f()?(N||"{"===C||b.trim(),b.singleSpace(),v.push(g()),b.newLine()):"@"===n?(b.preserveSingleSpace(),v.push(n),O=void 0,O=p,N=T(N=": , {}()[]/='\""),p=O-1,d(),(C=N).match(/[ :]$/)&&(d(),C=T(": ").replace(/\s$/,""),v.push(C),b.singleSpace()),(C=C.replace(/\s$/,""))in e&&(m+=1,C in r)&&(k=!0)):"#"===n&&"{"===f()?(b.preserveSingleSpace(),v.push(T("}"))):"{"===n?"}"===f(!0)?(E(),d(),b.singleSpace(),v.push("{}"),b.newLine(),c&&0===R&&b.newLine(!0)):(R++,x+=K,b["{"](n),S=k?(k=!1,m<R):m<=R):"}"===n?(R--,x=x.slice(0,-s),b["}"](n),A=S=!1,m&&m--,c&&0===R&&b.newLine(!0)):":"===n?(E(),!S&&!k||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(),v.push("::")):v.push(":"):(A=!0,v.push(":"),b.singleSpace())):'"'===n||"'"===n?(b.preserveSingleSpace(),v.push(T(n))):" "===n?(A=!1,v.push(n),b.newLine()):"("===n?w("url")?(v.push(n),E(),d()&&(")"!==n&&'"'!==n&&"'"!==n?v.push(T(")")):p--)):(u++,b.preserveSingleSpace(),v.push(n),E()):")"===n?(v.push(n),u--):","===n?(v.push(n),E(),a&&!A&&u<1?b.newLine():b.singleSpace()):("]"!==n&&("["!==n&&"="===n?(E(),n="="):b.preserveSingleSpace()),v.push(n))}t="";return x&&(t+=x),t+=v.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="ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԧԱ-Ֆՙա-ևא-תװ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࢠࢢ-ࢬऄ-हऽॐक़-ॡॱ-ॷॹ-ॿঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-ళవ-హఽౘౙౠౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡೱೲഅ-ഌഎ-ഐഒ-ഺഽൎൠൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛰᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡷᢀ-ᢨᢪᢰ-ᣵᤀ-ᤜᥐ-ᥭᥰ-ᥴᦀ-ᦫᧁ-ᧇᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᳩ-ᳬᳮ-ᳱᳵᳶᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⸯ々-〇〡-〩〱-〵〸-〼ぁ-ゖゝ-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿌ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚗꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐ-ꞓꞠ-Ɦꟸ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꪀ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꯀ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",n=new RegExp("[".concat(e,"]")),i=new RegExp("[".concat(e," ").concat("̀-ͯ҃-֑҇-ׇֽֿׁׂׅׄؐ-ؚؠ-ىٲ-ۓۧ-ۨۻ-ۼܰ-݊ࠀ-ࠔࠛ-ࠣࠥ-ࠧࠩ-࠭ࡀ-ࡗࣤ-ࣾऀ-ःऺ-़ा-ॏ॑-ॗॢ-ॣ०-९ঁ-ঃ়া-ৄেৈৗয়-ৠਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢ-ૣ૦-૯ଁ-ଃ଼ା-ୄେୈୋ-୍ୖୗୟ-ୠ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఁ-ఃె-ైొ-్ౕౖౢ-ౣ౦-౯ಂಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢ-ೣ೦-೯ംഃെ-ൈൗൢ-ൣ൦-൯ංඃ්ා-ුූෘ-ෟෲෳิ-ฺเ-ๅ๐-๙ິ-ູ່-ໍ໐-໙༘༙༠-༩༹༵༷ཁ-ཇཱ-྄྆-྇ྍ-ྗྙ-ྼ࿆က-ဩ၀-၉ၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟ᜎ-ᜐᜠ-ᜰᝀ-ᝐᝲᝳក-ឲ៝០-៩᠋-᠍᠐-᠙ᤠ-ᤫᤰ-᤻ᥑ-ᥭᦰ-ᧀᧈ-ᧉ᧐-᧙ᨀ-ᨕᨠ-ᩓ᩠-᩿᩼-᪉᪐-᪙ᭆ-ᭋ᭐-᭙᭫-᭳᮰-᮹᯦-᯳ᰀ-ᰢ᱀-᱉ᱛ-ᱽ᳐-᳒ᴀ-ᶾḁ-ἕ‿⁀⁔⃐-⃥⃜⃡-⃰ⶁ-ⶖⷠ-ⷿ〡-〨゙゚Ꙁ-ꙭꙴ-꙽ꚟ꛰-꛱ꟸ-ꠀ꠆ꠋꠣ-ꠧꢀ-ꢁꢴ-꣄꣐-꣙ꣳ-ꣷ꤀-꤉ꤦ-꤭ꤰ-ꥅꦀ-ꦃ꦳-꧀ꨀ-ꨧꩀ-ꩁꩌ-ꩍ꩐-꩙ꩻꫠ-ꫩꫲ-ꫳꯀ-ꯡ꯬꯭꯰-꯹ﬠ-ﬨ︀-️︠-︦︳︴﹍-﹏0-9_","]")),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(){O();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),v(t),m(),b(),void(d.space_in_paren&&(_.space_before_token=!0));t=L.ArrayLiteral,!S(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||y()||x();v(t),m(),d.space_in_paren&&(_.space_before_token=!0);b()},TK_END_EXPR:function(){for(;l.mode===L.Statement;)k();l.multiline_frame&&x("]"===a.text&&S(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(),k):(k(),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"])?v(L.BlockStatement):v(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:S(n.mode)&&","===l.last_text&&("}"===c?_.space_before_token=!0:K());m(),b()},TK_END_BLOCK:function(){for(;l.mode===L.Statement;)k();var t="TK_START_BLOCK"===o;"expand"===d.brace_style?t||K():t||(S(l.mode)&&d.keep_array_indentation?(d.keep_array_indentation=!1,K(),d.keep_array_indentation=!0):K());k(),m()},TK_WORD:C,TK_RESERVED:C,TK_SEMICOLON:function(){O()&&(_.space_before_token=!1);for(;l.mode===L.Statement&&!l.if_block&&!l.do_block;)k();m()},TK_STRING:function(){O()||"TK_RESERVED"===o||"TK_WORD"===o?_.space_before_token=!0:"TK_COMMA"===o||"TK_START_EXPR"===o||"TK_EQUALS"===o||"TK_OPERATOR"===o?y()||x():K();m()},TK_EQUALS:function(){O();l.declaration_statement&&(l.declaration_assignment=!0);_.space_before_token=!0,m(),_.space_before_token=!0},TK_OPERATOR:function(){O();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&&A(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?(A(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&&k(),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(){O();"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;)k()}},d={},void 0!==(t=t||{}).braces_on_own_line&&(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=void 0===t.preserve_newlines||t.preserve_newlines,d.break_chained_methods=void 0!==t.break_chained_methods&&t.break_chained_methods,d.max_preserve_newlines=void 0===t.max_preserve_newlines?0:parseInt(t.max_preserve_newlines,10),d.space_in_paren=void 0!==t.space_in_paren&&t.space_in_paren,d.space_in_empty_paren=void 0!==t.space_in_empty_paren&&t.space_in_empty_paren,d.jslint_happy=void 0!==t.jslint_happy&&t.jslint_happy,d.space_after_anon_function=void 0!==t.space_after_anon_function&&t.space_after_anon_function,d.keep_array_indentation=void 0!==t.keep_array_indentation&&t.keep_array_indentation,d.space_before_conditional=void 0===t.space_before_conditional||t.space_before_conditional,d.unescape_strings=void 0!==t.unescape_strings&&t.unescape_strings,d.wrap_line_length=void 0===t.wrap_line_length?0:parseInt(t.wrap_line_length,10),d.e4x=void 0!==t.e4x&&t.e4x,d.end_with_newline=void 0!==t.end_with_newline&&t.end_with_newline,d.comma_first=void 0!==t.comma_first&&t.comma_first,d.test_output_raw=void 0!==t.test_output_raw&&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&&S(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=void 0!==t&&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;)k();_.add_new_line(t)&&(l.multiline_frame=!0)}function R(){_.just_added_newline()&&(d.keep_array_indentation&&S(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 v(t){n=l?(h.push(l),l):E(null,t),l=E(n,t)}function S(t){return t===L.ArrayLiteral}function A(t){return G(t,[L.Expression,L.ForInitializer,L.Conditional])}function k(){0<h.length&&(n=l,l=h.pop(),n.mode===L.Statement)&&_.remove_redundant_indentation(n)}function y(){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 O(){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"])))&&(v(L.Statement),b(),"TK_RESERVED"===o&&G(l.last_text,["const","let","const"])&&"TK_WORD"===a.type&&(l.declaration_statement=!0),y()||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"),O()||!a.wanted_newline||A(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;)k();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&&(A(l.mode)||S(l.mode))||K()),"TK_COMMA"!==o&&"TK_START_EXPR"!==o&&"TK_EQUALS"!==o&&"TK_OPERATOR"!==o||y()||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&&A(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&&S(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=[],v(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=void 0!==t&&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(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 v,S,A,k,y,O,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(v=0,S="",O<=y)return["","TK_EOF"];var e=k.length?k[k.length-1]:new F("TK_START_BLOCK","{"),n=m.charAt(y);for(y+=1;G(n,N);){if(z.newline.test(n)?"\n"===n&&"\r"===m.charAt(y-2)||(v+=1,t=[]):t.push(n),O<=y)return["","TK_EOF"];n=m.charAt(y),y+=1}if(t.length&&(S=t.join("")),D.test(n)){var i=!0,r=!0,s=D;for("0"===n&&y<O&&/[Xxo]/.test(m.charAt(y))?(r=i=!1,n+=m.charAt(y),y+=1,s=/[o]/.test(m.charAt(y))?C:L):(n="",--y);y<O&&s.test(m.charAt(y));)n+=m.charAt(y),y+=1,i&&y<O&&"."===m.charAt(y)&&(n+=m.charAt(y),y+=1,i=!1),r&&y<O&&/[Ee]/.test(m.charAt(y))&&(n+=m.charAt(y),(y+=1)<O&&/[+-]/.test(m.charAt(y))&&(n+=m.charAt(y),y+=1),i=r=!1);return[n,"TK_WORD"]}if(z.isIdentifierStart(m.charCodeAt(y-1))){if(y<O)for(;z.isIdentifierChar(m.charCodeAt(y))&&(n+=m.charAt(y),(y+=1)!==O););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(y))return y+=1,P.lastIndex=y,R=P.exec(m),_="/*".concat(R[0]),y+=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=y,_+=(R=U.exec(m))[0],y+=R[0].length),[_=_.replace(z.lineBreak,"\n"),"TK_BLOCK_COMMENT",x];if("/"===m.charAt(y))return y+=1,B.lastIndex=y,R=B.exec(m),_="//".concat(R[0]),y+=R[0].length,[_,"TK_COMMENT"]}if("`"===n||"'"===n||'"'===n||("/"===n||b.e4x&&"<"===n&&m.slice(y-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;y<O&&(o||h||m.charAt(y)!==a)&&!z.newline.test(m.charAt(y));)l+=m.charAt(y),o?o=!1:(o="\\"===m.charAt(y),"["===m.charAt(y)?h=!0:"]"===m.charAt(y)&&(h=!1)),y+=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(y-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 y+=x-1,[u=u.replace(z.lineBreak,"\n"),"TK_STRING"]}}else for(;y<O&&(o||m.charAt(y)!==a&&("`"===a||!z.newline.test(m.charAt(y))));)(o||"`"===a)&&z.newline.test(m.charAt(y))?("\r"===m.charAt(y)&&"\n"===m.charAt(y+1)&&(y+=1),l+="\n"):l+=m.charAt(y),o=o?("x"!==m.charAt(y)&&"u"!==m.charAt(y)||(c=!0),!1):"\\"===m.charAt(y),y+=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)),y<O&&m.charAt(y)===a&&(l+=a,y+=1,"/"===a))for(;y<O&&z.isIdentifierStart(m.charCodeAt(y));)l+=m.charAt(y),y+=1;return[l,"TK_STRING"]}if("#"===n){if(0===k.length&&"!"===m.charAt(y)){for(l=n;y<O&&"\n"!==n;)l+=n=m.charAt(y),y+=1;return["".concat(X(l),"\n"),"TK_UNKNOWN"]}var K="#";if(y<O&&D.test(m.charAt(y))){for(;K+=n=m.charAt(y),(y+=1)<O&&"#"!==n&&"="!==n;);return"#"!==n&&("["===m.charAt(y)&&"]"===m.charAt(y+1)?(K+="[]",y+=2):"{"===m.charAt(y)&&"}"===m.charAt(y+1)&&(K+="{}",y+=2)),[K,"TK_WORD"]}}if("<"===n&&("?"===m.charAt(y)||"%"===m.charAt(y))){W.lastIndex=y-1;var R=W.exec(m);if(R)return n=R[0],y+=n.length-1,[n=n.replace(z.lineBreak,"\n"),"TK_STRING"]}if("<"===n&&"\x3c!--"===m.substring(y-1,y+3)){for(y+=3,n="\x3c!--";!z.newline.test(m.charAt(y))&&y<O;)n+=m.charAt(y),y++;return A=!0,[n,"TK_COMMENT"]}if("-"===n&&A&&"--\x3e"===m.substring(y-1,y+2))return A=!1,y+=2,["--\x3e","TK_COMMENT"];if("."===n)return[n,"TK_DOT"];if(G(n,I)){for(;y<O&&G(n+m.charAt(y),I)&&(n+=m.charAt(y),!(O<=(y+=1))););return","===n?[n,"TK_COMMA"]:"="===n?[n,"TK_EQUALS"]:[n,"TK_OPERATOR"]}return[n,"TK_UNKNOWN"]}this.tokenize=function(){O=m.length,y=0,A=!1,k=[];for(var t,e,n,i=null,r=[],s=[];!e||"TK_EOF"!==e.type;){for(n=_(),t=new F(n[1],n[0],v,S);"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],v,S);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()),k.push(t),e=t}return k}}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(void 0!==(e=e||{}).wrap_line_length&&0!==parseInt(e.wrap_line_length,10)||void 0===e.max_char||0===parseInt(e.max_char,10)||(e.wrap_line_length=e.max_char),i=void 0!==e.indent_inner_html&&e.indent_inner_html,r=void 0===e.indent_size?4:parseInt(e.indent_size,10),d=void 0===e.indent_char?" ":e.indent_char,a=void 0===e.brace_style?"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=void 0===e.preserve_newlines||e.preserve_newlines,c=o?isNaN(parseInt(e.max_preserve_newlines,10))?32786:parseInt(e.max_preserve_newlines,10):0,T=void 0!==e.indent_handlebars&&e.indent_handlebars,E=void 0===e.wrap_attributes?"auto":e.wrap_attributes,g=void 0!==e.wrap_attributes_indent_size&&parseInt(e.wrap_attributes_indent_size,10)||r,l=void 0!==e.end_with_newline&&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(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=void 0!==t&&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=!0;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(!s){this.line_char_count--;continue}if("\n"===n||"\r"===n){i+="\n",this.line_char_count=0;continue}}i+=n,this.line_char_count++,s=!0,T&&"{"===n&&i.length&&"{"===i[i.length-2]&&(r=(i+=this.get_unformatted("}}")).length)}while(-1===i.toLowerCase().indexOf(t,r));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}}}});
//# sourceMappingURL=code_beautifier.min.js.map