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