function e(e,t,r){return function(i,a){for(;!i.eol();){if(i.match(t)){a.tokenize=n;break}i.next()}return r&&(a.tokenize=r),e}}function t(e){return function(t,r){for(;!t.eol();)t.next();return r.tokenize=n,e}}function n(r,i){function o(e){return i.tokenize=e,e(r,i)}var s=r.sol(),c=r.next();switch(c){case`{`:return r.eat(`/`),r.eatSpace(),r.eatWhile(/[^\s\u00a0=\"\'\/?(}]/),i.tokenize=a,`tag`;case`_`:if(r.eat(`_`))return o(e(`strong`,`__`,n));break;case`'`:if(r.eat(`'`))return o(e(`em`,`''`,n));break;case`(`:if(r.eat(`(`))return o(e(`link`,`))`,n));break;case`[`:return o(e(`url`,`]`,n));case`|`:if(r.eat(`|`))return o(e(`comment`,`||`));break;case`-`:if(r.eat(`=`))return o(e(`header string`,`=-`,n));if(r.eat(`-`))return o(e(`error tw-deleted`,`--`,n));break;case`=`:if(r.match(`==`))return o(e(`tw-underline`,`===`,n));break;case`:`:if(r.eat(`:`))return o(e(`comment`,`::`));break;case`^`:return o(e(`tw-box`,`^`));case`~`:if(r.match(`np~`))return o(e(`meta`,`~/np~`));break}if(s)switch(c){case`!`:return r.match(`!!!!!`)||r.match(`!!!!`)||r.match(`!!!`)||r.match(`!!`),o(t(`header string`));case`*`:case`#`:case`+`:return o(t(`tw-listitem bracket`))}return null}var r,i;function a(e,t){var r=e.next(),a=e.peek();return r==`}`?(t.tokenize=n,`tag`):r==`(`||r==`)`?`bracket`:r==`=`?(i=`equals`,a==`>`&&(e.next(),a=e.peek()),/[\'\"]/.test(a)||(t.tokenize=s()),`operator`):/[\'\"]/.test(r)?(t.tokenize=o(r),t.tokenize(e,t)):(e.eatWhile(/[^\s\u00a0=\"\'\/?]/),`keyword`)}function o(e){return function(t,n){for(;!t.eol();)if(t.next()==e){n.tokenize=a;break}return`string`}}function s(){return function(e,t){for(;!e.eol();){var n=e.next(),r=e.peek();if(n==` `||n==`,`||/[ )}]/.test(r)){t.tokenize=a;break}}return`string`}}var c,l;function u(){for(var e=arguments.length-1;e>=0;e--)c.cc.push(arguments[e])}function d(){return u.apply(null,arguments),!0}function f(e,t){var n=c.context&&c.context.noIndent;c.context={prev:c.context,pluginName:e,indent:c.indented,startOfLine:t,noIndent:n}}function p(){c.context&&=c.context.prev}function m(e){if(e==`openPlugin`)return c.pluginName=r,d(_,h(c.startOfLine));if(e==`closePlugin`){var t=!1;return c.context?(t=c.context.pluginName!=r,p()):t=!0,t&&(l=`error`),d(g(t))}else if(e==`string`)return(!c.context||c.context.name!=`!cdata`)&&f(`!cdata`),c.tokenize==n&&p(),d();else return d()}function h(e){return function(t){return t==`selfclosePlugin`||t==`endPlugin`||t==`endPlugin`&&f(c.pluginName,e),d()}}function g(e){return function(t){return e&&(l=`error`),t==`endPlugin`?d():u()}}function _(e){return e==`keyword`?(l=`attribute`,d(_)):e==`equals`?d(v,_):u()}function v(e){return e==`keyword`?(l=`string`,d()):e==`string`?d(y):u()}function y(e){return e==`string`?d(y):u()}var b={name:`tiki`,startState:function(){return{tokenize:n,cc:[],indented:0,startOfLine:!0,pluginName:null,context:null}},token:function(e,t){if(e.sol()&&(t.startOfLine=!0,t.indented=e.indentation()),e.eatSpace())return null;l=i=r=null;var n=t.tokenize(e,t);if((n||i)&&n!=`comment`)for(c=t;!(t.cc.pop()||m)(i||n););return t.startOfLine=!1,l||n},indent:function(e,t,n){var r=e.context;if(r&&r.noIndent)return 0;for(r&&/^{\//.test(t)&&(r=r.prev);r&&!r.startOfLine;)r=r.prev;return r?r.indent+n.unit:0}};export{b as tiki};