text: /*!
   * RyuseiLight.js
   * Version  : 1.2.0
   * License  : MIT
   * Copyright: 2020 Naotoshi Fujita
   */
  !function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(t="undefined"!=typeof globalThis?globalThis:t||self).RyuseiLight=n()}(this,(function(){"use strict";var t="\n",n="keyword",i="comment",r="selector",e="prop",o="prolog",a="string",u="number",s="function",c="operator",f="bracket",l="delimiter",d="space",v="text";function p(t){return null!==t&&"object"==typeof t}function h(t){return Array.isArray(t)}function m(t){return"string"==typeof t}function g(t){return void 0===t}function b(t){return t instanceof HTMLElement}function y(t){return h(t)?t:[t]}function _(t,n){y(n).forEach((function(n){n&&t.classList.add(n)}))}function S(t,n){n=y(n);for(var i=0;i<n.length;i++)t.appendChild(n[i])}function w(t,n){if(t)for(var i=Object.keys(t),r=0;r<i.length;r++)n(t[i[r]],i[r])}function k(t){for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];return i.forEach((function(n){p(n)&&w(n,(function(i,r){g(n[r])||(t[r]=n[r])}))})),t}function x(t,n){if(m(n))return t.getAttribute(n)||"";p(n)&&w(n,(function(n,i){t.setAttribute(i,String(n))}))}function A(t,n){return void 0===n&&(n=document),n.querySelector(t)}function F(t,n){w(n,(function(n,i){t.style[i]=String(n)}))}function L(t,n){return"<"+(n||"div")+' class="'+t.join(" ")+'">'}function T(t,n){if(g(n))return t.textContent;t.textContent=n}function $(t,n){if(void 0===n&&(n=""),!t)throw new Error(n)}var C="ryuseilight";function z(t,n){return t.charAt(0)===n}var D=!g(/x/.sticky),E=function(){function n(t){this.language=t,this.t(t)}var i=n.prototype;return i.t=function(t){var n=this;w(t.grammar,(function(i,r){t.grammar[r]=n.i(t,i)})),w(t.use,this.t.bind(this))},i.i=function(t,n){for(var i=[],r=0;r<n.length;r++){var e=n[r],o=n[r],a=o[0],u=o[1];z(a,"#")&&!u?i.push.apply(i,this.i(t,t.grammar[a.slice(1)])):function(){var n=u.toString().match(/[gimsy]*$/)[0].replace(/[gy]/g,""),r=u.source+(D?"":"|()");w(t.source,(function(t,n){r=r.replace(new RegExp("%"+n,"g"),t.source)})),e[1]=new RegExp(r,(D?"y":"g")+n),i.push(e)}()}return i},i.o=function(t,n,i,r){var e=0,o=0;this.u++;t:for(;e<t.length&&!this.l;){for(var a=0;a<i.length;a++){var u=i[a],s=u[1],c=u[2];s.lastIndex=e;var f=s.exec(t);if(f&&f[0]){if(o<e&&this.v([v,t.slice(o,e)],n,r),"@back"===c){o=e;break t}if(o=e+=this.p(f,n,u,r)||1,"@break"===c)break t;continue t}}e++}return o<e&&this.v([v,t.slice(o)],n,r),this.u--,e},i.v=function(n,i,r){for(var e=this.u,o=n[0],a=n[1],u=this.h,s=0,c=0;s>-1&&!this.l;){s=a.indexOf(t,c);var f=this.m[this.h],l=c===s&&!f.length,d=l?t:a.slice(c,s<0?void 0:s),p={depth:e,language:i.id,state:r};d&&(o!==v&&(p.head=s>-1&&!c,p.tail=s<0&&!!c,p.split=s>-1||!!c,p.distance=this.h-u),f.push([o===v&&l?"lb":o,d,p])),s>-1&&(this.h++,this.l=this.g&&this.h>=this.g,this.l||(c=s+1,this.m[this.h]=[]))}},i.p=function(t,n,i,r){var e=i[0];if(!e)return 0;var o=t[0];if("@debug"===i[3]&&console.log(o,i),z(e,"@")){$(n.use);var a=n.use[e.slice(1)];return $(a),this.o(o,a,a.grammar.main,e)}if(z(e,"#")){var u=n.grammar[e.slice(1)];return $(u),"@rest"===i[2]&&(o=t.input.slice(t.index)),this.o(o,n,u,e)}return this.v([e,o],n,r),o.length},i.tokenize=function(t,n){return this.m=[[]],this.h=0,this.u=-1,this.g=n||0,this.l=!1,this.o(t,this.language,this.language.grammar.main,"#main"),this.m},n}(),R=C,j="rl__body",M="rl__code",N="rl__token",O="is-active",H=function(){function t(){this.handlers={}}var n=t.prototype;return n.on=function(t,n,i){void 0===i&&(i=10);var r=this.handlers[t]=this.handlers[t]||[];r.push({callback:n,priority:i}),r.sort((function(t,n){return t.priority-n.priority}))},n.emit=function(t){for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];(this.handlers[t]||[]).forEach((function(t){t.callback.apply(t,i)}))},n.destroy=function(){this.handlers={}},t}(),B={},J=function(){function t(t,n,i,r){void 0===r&&(r={}),this.lines=[],this.event=new H,this.lines=t,this.info=n,this.root=i,this.options=r,this.t()}t.compose=function(t){w(t,(function(t,n){B[n]=t}))};var n=t.prototype;return n.t=function(){var t=this,n=this.lines;if(n.length){var i=n[n.length-1];i.length&&(1!==i.length||i[0][1].trim())||n.pop()}w(B,(function(n){n(t)})),this.event.emit("mounted")},n._=function(t){for(var n=this.event,i=this.options.span?"span":"code",r=0;r<this.lines.length;r++){var e=this.lines[r],o=["rl__line"];n.emit("line:open",t,o,r),t(L(o));for(var a=function(r){var o=e[r],a=o[0].split("."),u="rl__"+a[0],s=a.slice(1).map((function(t){return u+"--"+t})),c=[N,u].concat(s);n.emit("token",o,c),t(""+L(c,i)+(o[1].replace(/&/g,"&amp;").replace(/</g,"&lt;")+"</")+i+">")},u=0;u<e.length;u++)a(u);t("</div>"),n.emit("line:closed",t,r)}},n.html=function(t){var n=this.event,i="</div>",r="",e=function(t){r+=t};t&&(r+=L([R+" "+R+"--"+this.info.id],"pre"));var o=["rl__container"];n.emit("open",e,o),r+=L(o);var a=[j+(this.options.wrap?" rl__body--wrap":"")];return n.emit("body:open",e,a),r+=L(a),n.emit("code:open",e),r+=L([M]),this._(e),r+=i,n.emit("body:close",e),r+=i,n.emit("close",e),r+=i,n.emit("closed",e),t&&(r+="</pre>"),r},n.destroy=function(){this.event.emit("destroy"),this.event.destroy()},t}(),P=/[+-]?(\d+\.?\d*|\d*\.?\d+)([eE][+-]?\d+)?/,G=/\b(?:true|false)\b/,I=/[[\]{}()]/,U=/[ \t]+/,W=/'(?:\\'|.)*?'/,X=/"(?:\\"|.)*?"/,Y=/\/\*[\s\S]*?(\*\/|$)/,Z=/\/\/.*/,q=/\b(?:break|catch|class|continue|do|else|extends|finally|for|function|if|implements|in|instanceof|interface|new|null|return|throw|try|while)\b/;function K(){return{id:"css",name:"CSS",grammar:{main:[["#common"],["#findSingleAtrule"],["#findBlock"]],findBlock:[["#block",/(?:(?![\t\n\r ;\{\}])[\s\S])(?:(?![;\{\}])[\s\S])*\{[\s\S]*?\}/,"@rest"]],findSingleAtrule:[["#atrule",/@(?:(?![;\{])[\s\S])+?;/]],findAtrule:[["#atrule",/@(?:(?![;\{])[\s\S])*?(?=[;\{])/]],findSelector:[["#selector",/(?:(?![\t\n\r ;\{\}])[\s\S])[\s\S]*?(?=\{)/]],common:[[a,/(["'])[\s\S]*?(?:(?!\\)[\s\S])\1/],[i,Y],[d,U]],block:[["#inner",/{/,"@rest"],[f,/}/,"@break"],["#findAtrule"],["#findSelector"],[d,U]],inner:[[f,/{/],["#common"],["#findBlock"],["#props"],["#findAtrule"],["",/}/,"@back"]],atrule:[["#common"],["#url",/\burl\(/,"@rest"],[d,U],["atrule",/[^\s();]+/],[l,/[:;,]/],["#paren",/\(/,"@rest"]],paren:[[f,/^\(/],["#common"],["#paren",/\(/,"@rest"],[f,/\)/,"@break"],["#props"]],selector:[["#common"],[c,/[>+~]/],[f,/[[\]()]/],[l,/=/],[r,/::?\S+/],[r,/[\W\d]\S+/],["tag",/\b[a-z]+|\*/i],[r,/\S+/]],url:[["#common"],[s,/^url/],[f,/\(/],[a,/[^)]+/],[f,/\)/,"@break"]],props:[[e,/[a-z0-9-_\xA0-\uFFFF]+(?=:)/i],["#url",/\burl\(/,"@rest"],[s,/\b[\w-]+(?=\()\b/],[n,/!important|\b(?:initial|inherit|unset)/],[e,/[a-z0-9-]+(?=:)/],[u,/#([0-9a-f]{6}|[0-9a-f]{3})/i],[u,/\bU\+[0-9a-f?-]+/i],[u,/[+-]?(\d+\.?\d*|\d*\.?\d+)/],[l,/[:;,]/],["#paren",/\(/,"@rest"],[f,/[[\])]/],[d,U]]}}}function Q(){return{id:"javascript",name:"JavaScript",alias:["js"],source:{func:/[_$a-z\xA0-\uFFFF][_$a-z0-9\xA0-\uFFFF]*/},grammar:{main:[[a,W],[a,X],["#backtick",/`/,"@rest"],[i,Y],[i,Z],["regexp",/\/(\[.*?]|\\\/|.)+?\/[gimsuy]*/],[n,q],[n,/\b(?:as|async|await|case|catch|const|debugger|default|delete|enum|export|from|import|let|package|private|protected|public|super|switch|static|this|typeof|undefined|var|void|with|yield)\b/],[n,/\b((get|set)(?=\s+%func))/i],["class",/\b[A-Z][\w$]*\b/],[s,/%func(?=\s*\()/i],["boolean",G],["decorator",/@[^\s(@]+/],["identifier",/\b[a-z_$][\w$]*\b/],[u,P],[c,/=>/],[c,/\+[+=]?|-[-=]?|\*\*?=?|[/%^]=?|&&?=?|\|\|?=?|\?\??=?|<<?=?|>>>=?|>>?=?|[!=]=?=?|[~:^]/],[f,I],[l,/[;.,]+/],[d,U]],backtick:[[a,/^`/],[a,/(\$[^{]|\\[$`]|[^`$])+/],["#expression",/\${/,"@rest"],[a,/`/,"@break"]],expression:[[l,/^\${/],[l,/}/,"@break"],["#main"]]}}}function V(t){void 0===t&&(t={});var n=(t.script||Q)(),r=(t.style||K)(),e=["cdata",/<!\[CDATA\[[\s\S]*\]\]>/i];return n.grammar.main.unshift(e),r.grammar.main.unshift(e),{id:"html",alias:["markup"],name:"HTML",use:{script:n,style:r},grammar:{main:[[i,/<!\x2D\x2D[\s\S]*?\x2D\x2D>/],[o,/<!DOCTYPE[\s\S]*?>/i],e,["#script",/<script[\s\S]*?>[\s\S]*?<\/script>/],["#style",/<style[\s\S]*?>[\s\S]*?<\/style>/],["#tag",/<[\s\S]*?>/],["entity",/&[\da-z]+;|&#\d+;/i],[d,U]],script:[["#tag",/^<script[\s\S]*?>/],e,["@script",/[\s\S]+(?=<\/script>)/],["#tag",/<\/script>/]],style:[["#tag",/^<style[\s\S]*?>/],["@style",/[\s\S]+(?=<\/style>)/],["#tag",/<\/style>/]],tag:[["#closeTag",/<\/.+>/],["#tagContent"]],closeTag:[["tag.close",/[^\s/<>"'=]+/],["#tagContent"]],tagContent:[["#attr",/[\t\n\r ]+[\s\S]+(?=[\t\n\r \/>])/],["tag",/[^\s/<>"'=]+/],[f,/[<>]/],[l,/[/]/]],attr:[[d,U],["value",/(['"])(\\\1|.)*?\1/],[l,/[/=]/],["attr",/[^\s/>"'=]+/]]}}}var tt={},nt=function(){function t(t){this.S=[],this.k=k({},t)}t.register=function(t){y(t).forEach((function(t){var n=t.id;n&&!tt[n]&&(t.alias||[]).concat(n).forEach((function(n){tt[n]=new E(t)}))}))},t.tokenize=function(n,i,r){return t.A(i).tokenize(n,r)},t.has=function(t){return!!tt[t]},t.A=function(n){return tt.none||t.register({id:"none",name:"",grammar:{main:[]}}),tt[n]||tt.none};var n=t.prototype;return n.F=function(n,i,r){var e=(r=k({},this.k,r)).language,o=t.A(e).language,a=o.name,u=o.id;return new J(t.tokenize(n,e),{name:a,id:u},i,r)},n.apply=function(t,n){for(var i=m(t)?document.querySelectorAll(t):[t],r=0;r<i.length;r++){var e=i[r];if(b(e)){var o=k({},n,{language:x(e,"data-rl-language")||void 0}),a=this.F(T(e),e,o),u=e instanceof HTMLPreElement;u&&_(e,[R,R+"--"+a.info.id]),e.innerHTML=a.html(!u),a.event.emit("applied",e),this.S.push(a)}}},n.html=function(t,n){return $(m(t),"Invalid code."),this.F(t,null,n).html(!0)},n.destroy=function(){this.S.forEach((function(t){t.destroy()}))},t}();nt.compose=J.compose;var it="data-rl-active-lines";function rt(t,n,i){var r="rl__figcaption";t('<figcaption class="'+r+" "+r+(i?"--bottom":"--top")+'">'),t("<span>"+n+"</span>"),t("</figcaption>")}var et={html:"Copy",activeHtml:"Done",duration:1e3,ariaLabel:"Copy code to clipboard",position:"topRight"};function ot(t,n){var i,r=function(t,n,i){var r=document.createElement(t);return n&&_(r,n),i&&S(i,r),r}("textarea");r.textContent=t,F(r,{position:"absolute",left:"-99999px"}),S(document.body,r),r.focus(),r.select();try{document.execCommand("copy")}catch(t){alert("Failed to copy."),i=!0}document.body.removeChild(r),i||n()}var at={addedSymbol:"+",deletedSymbol:"-"};function ut(t,n,i,r){t.indexOf(i)>-1?r.push("is-added"):n.indexOf(i)>-1&&r.push("is-deleted")}var st="rl__gutter__row";var ct,ft=Object.freeze({__proto__:null,ActiveLines:function(t){var n=t.event,i=t.root,r=t.options,e=i&&function(t){var n=x(t,it);if(n)try{return JSON.parse(n)}catch(t){i=t.message,console.error("[ryuseilight] "+i)}var i}(i)||r.activeLines;if(h(e)){var o=function(t){var n=[];return t.forEach((function(t){h(t)||(t=[t,t]);for(var i=(+t[0]||1)-1,r=(+t[1]||1)-1,e=i;e<=r;e++)n[e]=O})),n}(e);n.on("gutter:row:open",(function(t,n,i){o[i]&&n.push(o[i])})),n.on("line:open",(function(t,n,i){o[i]&&n.push(o[i])}))}},Caption:function(t){var n=t.event,i=t.root,r=t.options,e=i&&x(i,"data-rl-caption");if(e||r.caption){var o=r.caption,a=k({},p(o)?o:null),u=a.position,s=a.html,c=e||s||(m(o)?o:"");if(c){var f="bottom"===u;n.on("open",(function(t){t('<figure class="rl__figure">'),f||rt(t,c)})),n.on("closed",(function(t){f&&rt(t,c,!0),t("</figure>")}))}}},Copy:function(n){var i=n.lines,r=n.event,e=n.options;if(e.copy){var o=k({},et,p(e.copy)?e.copy:{}),a="rl__button__label";e.tools=o.position,r.on("tools:"+o.position,(function(t){t('<button type="button" class="rl__button rl__copy" aria-label="'+o.ariaLabel+'">'),t('<span class="'+a+" "+a+'--inactive">'+o.html+"</span>"),t('<span class="'+a+" "+a+'--active">'+o.activeHtml+"</span>"),t("</button>")})),r.on("applied",(function(n){var e=A(".rl__copy",n),a=i.map((function(t){return t.map((function(t){return t[1]})).join("")})).join(t);if(e){var u=function(){!function(t,n,i){var r=function(){i&&function(t,n){_(t,O);var i="_rlTimer";t[i]&&clearTimeout(t[i]);t[i]=setTimeout((function(){t.classList.remove(O)}),n)}(n,i)};navigator.clipboard?navigator.clipboard.writeText(t).then(r).catch((function(){return ot(t,r)})):ot(t,r)}(a,e,o.duration)};e.addEventListener("click",u),r.on("destroy",(function(){e.removeEventListener("click",u)}))}}))}},Diff:function(n){var i=n.event,r=n.lines,e=n.options;if(e.diff){e.gutter=!0;var o=k({},at,p(e.diff)?e.diff:null),a=[],u=[];r.forEach((function(t,n){if(t.length){var i,r=t[0][1];z(r,o.addedSymbol)?(a.push(n),i=!0):z(r,o.deletedSymbol)&&(u.push(n),i=!0),i&&function(t,n){var i=n[0],r=i[0],e=i[1];if(t)1===e.length?n.shift():n[0]=[r,e.slice(1)];else{var o=[d," "];1===e.length?n[0]=o:(n[0]=[r,e.slice(1)],n.unshift(o))}}(o.removeSymbols,t)}})),(a.length||u.length)&&(i.on("line:open",(function(t,n,i){ut(a,u,i,n)})),i.on("gutter:row:open",(function(t,n,i){ut(a,u,i,n)})),i.on("gutter:row:opened",(function(n,i){var r=t;a.indexOf(i)>-1?r=o.addedSymbol:u.indexOf(i)>-1&&(r=o.deletedSymbol),n('<span class="rl__diff">'+r+"</span>")}),20),i.on("lineNumber:open",(function(t,n,i,r){r.skip=u.indexOf(i)>-1})))}},Gutter:function(t){var n=t.lines,i=t.event,r=t.root,e=t.options;i.on("mounted",(function(){var t,o,a;e.gutter&&(i.on("open",(function(t,n){n.push("has-gutter")})),i.on("code:open",(function(t){t('<div class="rl__gutter" aria-hidden="true">');for(var r=0;r<n.length;r++){var e=[st];i.emit("gutter:row:open",t,e,r),t('<div class="'+e.join(" ")+'">'),i.emit("gutter:row:opened",t,r),t("</div>")}t("</div>")})),r&&"undefined"!=typeof window&&(window.addEventListener("resize",(t=u,o=100,function(){a||(a=setTimeout((function(){t(),a=null}),o))})),u(),i.on("destroy",(function(){window.removeEventListener("resize",u)}))));function u(){var t=r.getElementsByClassName(st),n=A("."+M,r);if(t.length&&n)for(var i=0;i<n.children.length;i++){var e=t[i],o=n.children[i];b(e)&&e.clientHeight!==o.clientHeight&&F(e,{height:o.clientHeight+"px"})}}}))},LanguageName:function(t){var n=t.event,i=t.info,r=t.options,e=i.name;if(r.languageName&&e){var o="topLeft"===r.languageName?"topLeft":"topRight";r.overlay=r.overlay||{},r.overlay[o]=!0,n.on("overlay:"+o,(function(t){t('<span class="rl__name">'+i.name+"</span>")}))}},LineNumbers:function(n){var i=n.root,r=n.event,e=n.options,o=i?x(i,"data-rl-line-numbers"):"",a=""===o?+e.lineNumbers:+o;if(a||0===a){e.gutter=!0;var u=Math.floor(a)-1;r.on("gutter:row:opened",(function(n,i){var e=["rl__line-number"],o={skip:!1,content:i+1+u};r.emit("lineNumber:open",n,e,i,o),o.skip&&(o.content=t,u--),n('<span class="'+e.join(" ")+'">'+o.content+"</span>")}))}},Overlay:function(t){var n=t.event,i=t.options;n.on("mounted",(function(){var t=i.overlay,r=void 0===t?{}:t,e=i.tools,o=r.topRight,a=r.topLeft;[o=o||"topRight"===e,a=a||"topLeft"===e].forEach((function(t,i){t&&(e&&function(t,n){var i=n?"Left":"Right";t.on("overlay:top"+i,(function(n){n('<span class="rl__tools">'),t.emit("tools:top"+i,n),n("</span>")}))}(n,1===i),function(t,n){var i="rl__overlay";t.on("close",(function(r){r('<div class="'+i+" "+i+"--top-"+(n?"left":"right")+'">'),t.emit("overlay:top"+(n?"Left":"Right"),r),r("</div>")}))}(n,1===i))})),(o||a)&&n.on("open",(function(t,n){n.push("has-top-overlay")}))}))}});return nt.register([{id:"none",name:"",grammar:{main:[]}},Q(),V(),K(),(ct=k(V(),{id:"xml",name:"XML",alias:[]}),ct.grammar.main.unshift([o,/<\?[\s\S]*?\?>/]),ct)]),nt.compose(ft),nt}));
  //# sourceMappingURL=ryuseilight-extensions.min.js.map
  