var textwords={},keywords={allTags:!0,closeAll:!0,list:!0,newJournal:!0,newTiddler:!0,permaview:!0,saveChanges:!0,search:!0,slider:!0,tabs:!0,tag:!0,tagging:!0,tags:!0,tiddler:!0,timeline:!0,today:!0,version:!0,option:!0,with:!0,filter:!0},isSpaceName=/[\w_\-]/i,reHR=/^\-\-\-\-+$/,reWikiCommentStart=/^\/\*\*\*$/,reWikiCommentStop=/^\*\*\*\/$/,reBlockQuote=/^<<<$/,reJsCodeStart=/^\/\/\{\{\{$/,reJsCodeStop=/^\/\/\}\}\}$/,reXmlCodeStart=/^<!--\{\{\{-->$/,reXmlCodeStop=/^<!--\}\}\}-->$/,reCodeBlockStart=/^\{\{\{$/,reCodeBlockStop=/^\}\}\}$/,reUntilCodeStop=/.*?\}\}\}/;function chain(e,t,r){return t.tokenize=r,r(e,t)}function tokenBase(e,t){var r=e.sol(),n=e.peek();if(t.block=!1,r&&/[<\/\*{}\-]/.test(n)){if(e.match(reCodeBlockStart))return t.block=!0,chain(e,t,twTokenCode);if(e.match(reBlockQuote))return "quote";if(e.match(reWikiCommentStart)||e.match(reWikiCommentStop))return "comment";if(e.match(reJsCodeStart)||e.match(reJsCodeStop)||e.match(reXmlCodeStart)||e.match(reXmlCodeStop))return "comment";if(e.match(reHR))return "contentSeparator"}if(e.next(),r&&/[\/\*!#;:>|]/.test(n)){if("!"==n)return e.skipToEnd(),"header";if("*"==n)return e.eatWhile("*"),"comment";if("#"==n)return e.eatWhile("#"),"comment";if(";"==n)return e.eatWhile(";"),"comment";if(":"==n)return e.eatWhile(":"),"comment";if(">"==n)return e.eatWhile(">"),"quote";if("|"==n)return "header"}if("{"==n&&e.match("{{"))return chain(e,t,twTokenCode);if(/[hf]/i.test(n)&&/[ti]/i.test(e.peek())&&e.match(/\b(ttps?|tp|ile):\/\/[\-A-Z0-9+&@#\/%?=~_|$!:,.;]*[A-Z0-9+&@#\/%=~_|$]/i))return "link";if('"'==n)return "string";if("~"==n)return "brace";if(/[\[\]]/.test(n)&&e.match(n))return "brace";if("@"==n)return e.eatWhile(isSpaceName),"link";if(/\d/.test(n))return e.eatWhile(/\d/),"number";if("/"==n){if(e.eat("%"))return chain(e,t,twTokenComment);if(e.eat("/"))return chain(e,t,twTokenEm)}if("_"==n&&e.eat("_"))return chain(e,t,twTokenUnderline);if("-"==n&&e.eat("-")){if(" "!=e.peek())return chain(e,t,twTokenStrike);if(" "==e.peek())return "brace"}return "'"==n&&e.eat("'")?chain(e,t,twTokenStrong):"<"==n&&e.eat("<")?chain(e,t,twTokenMacro):(e.eatWhile(/[\w\$_]/),textwords.propertyIsEnumerable(e.current())?"keyword":null)}function twTokenComment(e,t){for(var r,n=!1;r=e.next();){if("/"==r&&n){t.tokenize=tokenBase;break}n="%"==r;}return "comment"}function twTokenStrong(e,t){for(var r,n=!1;r=e.next();){if("'"==r&&n){t.tokenize=tokenBase;break}n="'"==r;}return "strong"}function twTokenCode(e,t){var r=t.block;return r&&e.current()?"comment":!r&&e.match(reUntilCodeStop)||r&&e.sol()&&e.match(reCodeBlockStop)?(t.tokenize=tokenBase,"comment"):(e.next(),"comment")}function twTokenEm(e,t){for(var r,n=!1;r=e.next();){if("/"==r&&n){t.tokenize=tokenBase;break}n="/"==r;}return "emphasis"}function twTokenUnderline(e,t){for(var r,n=!1;r=e.next();){if("_"==r&&n){t.tokenize=tokenBase;break}n="_"==r;}return "link"}function twTokenStrike(e,t){for(var r,n=!1;r=e.next();){if("-"==r&&n){t.tokenize=tokenBase;break}n="-"==r;}return "deleted"}function twTokenMacro(e,t){if("<<"==e.current())return "meta";var r=e.next();return r?">"==r&&">"==e.peek()?(e.next(),t.tokenize=tokenBase,"meta"):(e.eatWhile(/[\w\$_]/),keywords.propertyIsEnumerable(e.current())?"keyword":null):(t.tokenize=tokenBase,null)}const tiddlyWiki={startState:function(){return {tokenize:tokenBase}},token:function(e,t){return e.eatSpace()?null:t.tokenize(e,t)}};

export { tiddlyWiki };
