md/js/app.7dd9b965.js
2020-06-18 01:40:20 +00:00

2 lines
63 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

(function(e){function t(t){for(var o,a,s=t[0],l=t[1],c=t[2],d=0,f=[];d<s.length;d++)a=s[d],Object.prototype.hasOwnProperty.call(i,a)&&i[a]&&f.push(i[a][0]),i[a]=0;for(o in l)Object.prototype.hasOwnProperty.call(l,o)&&(e[o]=l[o]);u&&u(t);while(f.length)f.shift()();return r.push.apply(r,c||[]),n()}function n(){for(var e,t=0;t<r.length;t++){for(var n=r[t],o=!0,s=1;s<n.length;s++){var l=n[s];0!==i[l]&&(o=!1)}o&&(r.splice(t--,1),e=a(a.s=n[0]))}return e}var o={},i={app:0},r=[];function a(t){if(o[t])return o[t].exports;var n=o[t]={i:t,l:!1,exports:{}};return e[t].call(n.exports,n,n.exports,a),n.l=!0,n.exports}a.m=e,a.c=o,a.d=function(e,t,n){a.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},a.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,t){if(1&t&&(e=a(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(a.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)a.d(n,o,function(t){return e[t]}.bind(null,o));return n},a.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return a.d(t,"a",t),t},a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.p="/md/";var s=window["webpackJsonp"]=window["webpackJsonp"]||[],l=s.push.bind(s);s.push=t,s=s.slice();for(var c=0;c<s.length;c++)t(s[c]);var u=l;r.push([0,"chunk-vendors"]),n()})({0:function(e,t,n){e.exports=n("56d7")},1:function(e,t){},"2a20":function(e,t,n){"use strict";var o=n("5a64"),i=n.n(o);i.a},"56d7":function(e,t,n){"use strict";n.r(t);n("e260"),n("e6cf"),n("cca6"),n("a79d");var o=n("2b0e"),i=function(){var e=this,t=e.$createElement,n=e._self._c||t;return e.loading?n("loading"):n("codemirror-editor")},r=[],a=function(){var e=this,t=e.$createElement;e._self._c;return e._m(0)},s=[function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"loading",attrs:{id:"loading"}},[n("div",{staticClass:"loading-wrapper"},[n("div",{staticClass:"loading-text"},[e._v("Loading...")]),n("div",{staticClass:"loading-anim"})])])}],l={},c=l,u=n("2877"),d=Object(u["a"])(c,a,s,!1,null,"71788ed8",null),f=d.exports,p=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"container",class:{container_night:e.nightMode}},[n("el-container",[n("el-header",{staticClass:"editor__header"},[n("editor-header",{on:{refresh:e.onEditorRefresh,uploaded:e.uploaded,cssChanged:e.cssChanged,showBox:function(t){e.showBox=!e.showBox},showAboutDialog:function(t){e.aboutDialogVisible=!0},showDialogForm:function(t){e.dialogFormVisible=!0},startCopy:function(t){e.isCoping=!0,e.backLight=!0},endCopy:e.endCopy}})],1),n("el-main",{staticClass:"main-body"},[n("el-row",{staticClass:"main-section",attrs:{gutter:10}},[n("el-col",{attrs:{span:12}},[n("textarea",{directives:[{name:"model",rawName:"v-model",value:e.source,expression:"source"}],attrs:{id:"editor",type:"textarea",placeholder:"Your markdown text here."},domProps:{value:e.source},on:{input:function(t){t.target.composing||(e.source=t.target.value)}}})]),n("el-col",{staticClass:"preview-wrapper",class:{"preview-wrapper_night":e.nightMode&&e.isCoping},attrs:{span:12,id:"preview"}},[n("section",{class:{output_night:e.nightMode&&!e.backLight},attrs:{id:"output-wrapper"}},[n("div",{staticClass:"preview"},[n("section",{attrs:{id:"output"},domProps:{innerHTML:e._s(e.output)}}),e.nightMode&&e.isCoping?n("div",{staticClass:"loading-mask"},[n("div",{staticClass:"loading__img"}),n("span",[e._v("正在生成")])]):e._e()])])]),n("transition",{attrs:{name:"custom-classes-transition","enter-active-class":"animated bounceInRight"}},[n("el-col",{directives:[{name:"show",rawName:"v-show",value:e.showBox,expression:"showBox"}],attrs:{id:"cssBox",span:12}},[n("textarea",{attrs:{id:"cssEditor",type:"textarea",placeholder:"Your custom css here."}})])],1)],1)],1)],1),n("about-dialog",{attrs:{aboutDialogVisible:e.aboutDialogVisible},on:{close:function(t){e.aboutDialogVisible=!1}}}),n("insert-form-dialog",{attrs:{dialogFormVisible:e.dialogFormVisible},on:{close:function(t){e.dialogFormVisible=!1}}})],1)},g=[],h=(n("ac1f"),n("5319"),n("5530")),m=n("56b3"),b=n.n(m);n("7b00"),n("959b"),n("8c33"),n("31c5"),n("9b74"),n("111b"),n("c975"),n("baa5"),n("fb6a"),n("1276");(function(){b.a.extendMode("css",{commentStart:"/*",commentEnd:"*/",newlineAfterToken:function(e,t){return/^[;{}]$/.test(t)}}),b.a.defineExtension("commentRange",(function(e,t,n){var o=this,i=b.a.innerMode(o.getMode(),o.getTokenAt(t).state).mode;o.operation((function(){if(e)o.replaceRange(i.commentEnd,n),o.replaceRange(i.commentStart,t),t.line==n.line&&t.ch==n.ch&&o.setCursor(t.line,t.ch+i.commentStart.length);else{var r=o.getRange(t,n),a=r.indexOf(i.commentStart),s=r.lastIndexOf(i.commentEnd);a>-1&&s>-1&&s>a&&(r=r.substr(0,a)+r.substring(a+i.commentStart.length,s)+r.substr(s+i.commentEnd.length)),o.replaceRange(r,t,n)}}))})),b.a.defineExtension("autoIndentRange",(function(e,t){var n=this;this.operation((function(){for(var o=e.line;o<=t.line;o++)n.indentLine(o,"smart")}))})),b.a.defineExtension("autoFormatRange",(function(e,t){var n=this,o=n.getMode(),i=n.getRange(e,t).split("\n"),r=b.a.copyState(o,n.getTokenAt(e).state),a=n.getOption("tabSize"),s="",l=0,c=0==e.ch;function u(){s+="\n",c=!0,++l}for(var d=0;d<i.length;++d){var f=new b.a.StringStream(i[d],a);while(!f.eol()){var p=b.a.innerMode(o,r),g=o.token(f,r),h=f.current();f.start=f.pos,c&&!/\S/.test(h)||(s+=h,c=!1),!c&&p.mode.newlineAfterToken&&p.mode.newlineAfterToken(g,h,f.string.slice(f.pos)||i[d+1]||"",p.state)&&u()}!f.pos&&o.blankLine&&o.blankLine(r),c||u()}n.operation((function(){n.replaceRange(s,e,t);for(var o=e.line+1,i=e.line+l;o<=i;++o)n.indentLine(o,"smart");n.setSelection(e,n.getCursor(!1))}))}))})();n("d3b7");var v=n("bc3a"),y=n.n(v),x=y.a.create({baseURL:"",timeout:1e4});x.interceptors.request.use((function(e){return/^(post)|(put)|(delete)$/i.test(e.method)&&e.data&&e.data.upload&&(e.headers["Content-Type"]="multipart/form-data"),e}),(function(e){Promise.reject(e)})),x.interceptors.response.use((function(e){return e.data.success?e.data:(console.log(e),Promise.reject(e.data))}),(function(e){return Promise.reject(e)}));var w=x;function C(e){return w({url:"https://imgkr.com/api/files/upload",method:"post",data:e})}var k={fileUpload:C},S=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("el-container",{staticClass:"top is-dark"},[n("el-upload",{staticClass:"header__item",attrs:{action:"https://imgkr.com/api/files/upload",headers:{"Content-Type":"multipart/form-data"},"show-file-list":!1,multiple:!0,accept:".jpg,.jpeg,.png,.gif",name:"file","before-upload":e.beforeUpload}},[n("el-tooltip",{attrs:{effect:e.effect,content:"上传图片",placement:"bottom-start"}},[n("i",{staticClass:"el-icon-upload",attrs:{size:"medium"}})])],1),n("el-tooltip",{staticClass:"header__item",attrs:{effect:e.effect,content:"下载编辑框Markdown文档",placement:"bottom-start"}},[n("i",{staticClass:"el-icon-download",attrs:{size:"medium"},on:{click:e.downloadEditorContent}})]),n("el-tooltip",{staticClass:"header__item",attrs:{effect:e.effect,content:"重置页面",placement:"bottom-start"}},[n("i",{staticClass:"el-icon-refresh",attrs:{size:"medium"},on:{click:function(t){e.showResetConfirm=!0}}})]),n("el-tooltip",{staticClass:"header__item header__item_last",attrs:{effect:e.effect,content:"插入表格",placement:"bottom-start"}},[n("i",{staticClass:"el-icon-s-grid",attrs:{size:"medium"},on:{click:function(t){return e.$emit("showDialogForm")}}})]),n("el-form",{staticClass:"ctrl",attrs:{size:"mini",inline:!0}},[n("el-form-item",[n("el-select",{attrs:{size:"mini",placeholder:"选择字体",clearable:""},on:{change:e.fontChanged},model:{value:e.selectFont,callback:function(t){e.selectFont=t},expression:"selectFont"}},e._l(e.config.builtinFonts,(function(t){return n("el-option",{key:t.value,style:{fontFamily:t.value},attrs:{label:t.label,value:t.value}},[n("span",{staticClass:"select-item-left"},[e._v(e._s(t.label))]),n("span",{staticClass:"select-item-right"},[e._v("Abc")])])})),1)],1),n("el-form-item",[n("el-select",{attrs:{size:"mini",placeholder:"选择段落字号",clearable:""},on:{change:e.sizeChanged},model:{value:e.selectSize,callback:function(t){e.selectSize=t},expression:"selectSize"}},e._l(e.config.sizeOption,(function(t){return n("el-option",{key:t.value,attrs:{label:t.label,value:t.value}},[n("span",{staticClass:"select-item-left"},[e._v(e._s(t.label))]),n("span",{staticClass:"select-item-right"},[e._v(e._s(t.desc))])])})),1)],1),n("el-form-item",[n("el-select",{attrs:{size:"mini",placeholder:"选择颜色",clearable:""},on:{change:e.colorChanged},model:{value:e.selectColor,callback:function(t){e.selectColor=t},expression:"selectColor"}},e._l(e.config.colorOption,(function(t){return n("el-option",{key:t.value,attrs:{label:t.label,value:t.value}},[n("span",{staticClass:"select-item-left"},[e._v(e._s(t.label))]),n("span",{staticClass:"select-item-right"},[e._v(e._s(t.hex))])])})),1)],1),n("el-tooltip",{attrs:{content:"自定义颜色",effect:e.effect,placement:"top"}},[n("el-color-picker",{attrs:{size:"mini","show-alpha":""},on:{change:e.colorChanged},model:{value:e.selectColor,callback:function(t){e.selectColor=t},expression:"selectColor"}})],1),n("el-tooltip",{attrs:{content:"微信外链自动转为文末引用",effect:e.effect,placement:"top"}},[n("el-switch",{staticClass:"header__switch",attrs:{"active-color":"#67c23a","inactive-color":"#dcdfe6"},on:{change:e.statusChanged},model:{value:e.citeStatus,callback:function(t){e.citeStatus=t},expression:"citeStatus"}})],1)],1),n("el-tooltip",{staticClass:"item",attrs:{effect:e.effect,content:"自定义CSS样式",placement:"left"}},[n("el-button",{attrs:{type:e.btnType,plain:"",size:"medium",icon:"el-icon-setting"},on:{click:e.customStyle}})],1),n("el-button",{attrs:{type:e.btnType,plain:"",size:"medium"},on:{click:e.copy}},[e._v("复制")]),n("el-button",{staticClass:"about",attrs:{type:e.btnType,plain:"",size:"medium"},on:{click:function(t){return e.$emit("showAboutDialog")}}},[e._v("关于")]),n("el-tooltip",{attrs:{content:"夜间模式",placement:"bottom-start"}},[e.nightMode?n("div",{staticClass:"mode__switch mode__switch_black",on:{click:e.themeChanged}}):n("div",{staticClass:"mode__switch",on:{click:e.themeChanged}})]),n("resetDialog",{attrs:{showResetConfirm:e.showResetConfirm},on:{confirm:e.confirmReset,close:e.cancelReset}})],1)},_=[],E=(n("3ca3"),n("ddb0"),n("2b3d"),n("96cf"),n("1da1")),O=(n("4de4"),n("4160"),n("d81d"),n("b0c0"),n("b64b"),n("498a"),n("9911"),n("159b"),{BASE:{"text-align":"left",color:"#3f3f3f","line-height":"1.75"},BASE_BLOCK:{margin:"1em 8px"},block:{h1:{"font-size":"1.2em","text-align":"center","font-weight":"bold",display:"table",margin:"2em auto 1em",padding:"0 1em","border-bottom":"2px solid rgba(0, 152, 116, 0.9)"},h2:{"font-size":"1.2em","text-align":"center","font-weight":"bold",display:"table",margin:"4em auto 2em",padding:"0 0.2em",background:"rgba(0, 152, 116, 0.9)",color:"#fff"},h3:{"font-weight":"bold","font-size":"1.1em",margin:"2em 8px 0.75em 0","line-height":"1.2","padding-left":"8px","border-left":"3px solid rgba(0, 152, 116, 0.9)"},h4:{"font-weight":"bold","font-size":"1em",margin:"2em 8px 0.5em",color:"rgba(66, 185, 131, 0.9)"},p:{margin:"1.5em 8px","letter-spacing":"0.1em"},blockquote:{"font-style":"normal","border-left":"none",padding:"1em","border-radius":"4px",color:"#FEEEED",background:"rgba(27,31,35,.05)",margin:"2em 8px"},blockquote_p:{"letter-spacing":"0.1em",color:"rgb(80, 80, 80)","font-family":"PingFangSC-light, PingFangTC-light, Open Sans, Helvetica Neue, sans-serif","font-size":"1em",display:"inline"},code:{"font-size":"80%",overflow:"auto",color:"#333",background:"rgb(247, 247, 247)","border-radius":"2px",padding:"10px","line-height":"1.5",border:"1px solid rgb(236,236,236)",margin:"20px 0"},image:{"border-radius":"4px",display:"block",margin:"0.1em auto 0.5em",width:"100% !important"},image_org:{"border-radius":"4px",display:"block"},ol:{"margin-left":"0","padding-left":"1em"},ul:{"margin-left":"0","padding-left":"1em","list-style":"circle"},footnotes:{margin:"0.5em 8px","font-size":"80%"},figure:{margin:"1.5em 8px"}},inline:{listitem:{"text-indent":"-1em",display:"block",margin:"0.2em 8px"},codespan:{"font-size":"90%",color:"#d14",background:"rgba(27,31,35,.05)",padding:"3px 5px","border-radius":"4px"},link:{color:"#576b95"},wx_link:{color:"#576b95","text-decoration":"none"},strong:{color:"rgba(15, 76, 129, 0.9)","font-weight":"bold"},table:{"border-collapse":"collapse","text-align":"center",margin:"1em 8px"},thead:{background:"rgba(0, 0, 0, 0.05)","font-weight":"bold"},td:{border:"1px solid #dfdfdf",padding:"0.25em 0.5em"},footnote:{"font-size":"12px"},figcaption:{"text-align":"center",color:"#888","font-size":"0.8em"}}}),R=n("325b"),T=n.n(R),j=n("4fc3"),N=n.n(j);function z(e){return function(t){var n=JSON.parse(JSON.stringify(e));return n.block.h1["border-bottom"]="2px solid ".concat(t),n.block.h2["background"]=t,n.block.h3["border-left"]="3px solid ".concat(t),n.block.h4["color"]=t,n.inline.strong["color"]=t,n}}var $=function(e,t){var n=JSON.parse(JSON.stringify(e));return n.block.h1["border-bottom"]="2px solid ".concat(t),n.block.h2["background"]=t,n.block.h3["border-left"]="3px solid ".concat(t),n.block.h4["color"]=t,n.inline.strong["color"]=t,n};function A(e){return function(t){var n=JSON.parse(JSON.stringify(e));return n.block.h1["font-size"]="".concat(1.14*t,"px"),n.block.h2["font-size"]="".concat(1.1*t,"px"),n.block.h3["font-size"]="".concat(t,"px"),n.block.h4["font-size"]="".concat(t,"px"),n}}var P=z(O),F=A(O);function M(e,t,n){var o=JSON.parse(JSON.stringify(n));return o.block.h1["border-bottom"]="2px solid ".concat(t),o.block.h2["background"]=t,o.block.h3["border-left"]="3px solid ".concat(t),o.block.h4["color"]=t,o.inline.strong["color"]=t,o.block.h1=Object.assign(o.block.h1,e.h1),o.block.h2=Object.assign(o.block.h2,e.h2),o.block.h3=Object.assign(o.block.h3,e.h3),o.block.h4=Object.assign(o.block.h4,e.h4),o.block.p=Object.assign(o.block.p,e.p),o.block.blockquote=Object.assign(o.block.blockquote,e.blockquote),o.block.blockquote_p=Object.assign(o.block.blockquote_p,e.blockquote_p),o.block.image=Object.assign(o.block.image,e.image),o.inline.strong=Object.assign(o.inline.strong,e.strong),o.inline.codespan=Object.assign(o.inline.codespan,e.codespan),o.inline.link=Object.assign(o.inline.link,e.link),o.inline.wx_link=Object.assign(o.inline.wx_link,e.wx_link),o}function I(e){while(-1!==(open=e.indexOf("/*"))&&-1!==(close=e.indexOf("*/")))e=e.substring(0,open)+e.substring(close+2);var t={},n=function(){var n=e.indexOf("{"),o=e.indexOf("}");function i(e){var t={};return e.forEach((function(e){var n=e.indexOf(":"),o=e.substring(0,n).trim(),i=e.substring(n+1).trim();t[o]=i})),t}var r=e.substring(n+1,o).split(";").map((function(e){return e.trim()})).filter((function(e){return e.length>0}));r=i(r);var a=e.substring(0,n).split(",").map((function(e){return e.trim()}));a.forEach((function(e){t[e]||(t[e]={}),Object.keys(r).forEach((function(n){t[e][n]=r[n]}))})),e=e.slice(o+1).trim()};while(e.length>0&&-1!==e.indexOf("{")&&-1!==e.indexOf("}"))n();return t}function D(e,t){var n=e.getValue(0);n?localStorage.setItem(t,n):localStorage.removeItem(t)}function L(e){return/\.(gif|jpg|jpeg|png|GIF|JPG|PNG)$/.test(e.name)?e.size>5242880&&"由于公众号限制,图片大小不能超过 5.0M":"请上传 JPG/PNG/GIF 格式的图片"}function B(e){var t=T.a.format(e,{parser:"markdown",plugins:[N.a]});return t}var G=n("466b"),V=n.n(G);function q(){for(var e=document.getElementById("output"),t=e.getElementsByTagName("img"),n=0;n<t.length;n++){var o=t[n],i=o.getAttribute("width"),r=o.getAttribute("height");o.removeAttribute("width"),o.removeAttribute("height"),o.style.width=i,o.style.height=r}}function H(){var e=document.getElementById("output-wrapper"),t=e.innerHTML,n="";return n=V.a.inlineContent(t,{inlinePseudoElements:!0,preserveImportant:!0}),n}var U={builtinFonts:[{label:"无衬线",value:"-apple-system-font,BlinkMacSystemFont, Helvetica Neue, PingFang SC, Hiragino Sans GB , Microsoft YaHei UI , Microsoft YaHei ,Arial,sans-serif"},{label:"衬线",value:"Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, 'PingFang SC', Cambria, Cochin, Georgia, Times, 'Times New Roman', serif"}],sizeOption:[{label:"12px",value:"12px",desc:"更小"},{label:"13px",value:"13px",desc:"稍小"},{label:"14px",value:"14px",desc:"推荐"},{label:"15px",value:"15px",desc:"稍大"},{label:"16px",value:"16px",desc:"更大"}],colorOption:[{label:"经典蓝",value:"rgba(15, 76, 129, 1)",hex:"最新流行"},{label:"翡翠绿",value:"rgba(0, 152, 116, 1)",hex:"优雅清新"},{label:"活力橘",value:"rgba(250, 81, 81, 1)",hex:"热情活泼"}],form:{rows:1,cols:1}},J="/*\n 按Ctrl+F可格式化\n*/\n/* 一级标题样式 */\nh1 {\n}\n/* 二级标题样式 */\nh2 {\n}\n/* 三级标题样式 */\nh3 {\n}\n/* 四级标题样式 */\nh4 {\n}\n/* 图片样式 */\nimage {\n}\n/* 引用样式 */\nblockquote {\n}\n/* 引用段落样式 */\nblockquote_p {\n}\n/* 段落样式 */\np {\n}\n/* 行内代码样式 */\ncodespan {\n}\n/* 粗体样式 */\nstrong {\n}\n/* 链接样式 */\nlink {\n}\n/* 微信链接样式 */\nwx_link {\n}\n",W=J,K=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("el-dialog",{staticClass:"reset__dialog",attrs:{title:"提示",visible:e.showResetConfirm},on:{close:function(t){return e.$emit("close")}}},[n("div",{staticClass:"text"},[e._v(" 此操作将丢失本地缓存的文本和自定义样式,是否继续? ")]),n("div",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[n("el-button",{attrs:{type:e.btnType,plain:""},on:{click:function(t){return e.$emit("close")}}},[e._v("取 消")]),n("el-button",{attrs:{type:e.btnType,plain:""},on:{click:function(t){return e.$emit("confirm")}}},[e._v("确 定")])],1)])},Y=[],Q=n("2f62"),Z={props:{showResetConfirm:{type:Boolean,default:!1}},computed:Object(h["a"])({btnType:function(){return this.nightMode?"default":"success"}},Object(Q["c"])({nightMode:function(e){return e.nightMode}}))},X=Z,ee=(n("e5b0"),Object(u["a"])(X,K,Y,!1,null,"7fbc8ba6",null)),te=ee.exports,ne={name:"editor-header",data:function(){return{config:U,citeStatus:!1,showResetConfirm:!1,selectFont:"",selectSize:"",selectColor:""}},components:{resetDialog:te},computed:Object(h["a"])({effect:function(){return this.nightMode?"dark":"light"},btnType:function(){return this.nightMode?"default":"success"}},Object(Q["c"])({output:function(e){return e.output},editor:function(e){return e.editor},cssEditor:function(e){return e.cssEditor},currentFont:function(e){return e.currentFont},currentSize:function(e){return e.currentSize},currentColor:function(e){return e.currentColor},nightMode:function(e){return e.nightMode}})),methods:Object(h["a"])({fontChanged:function(e){this.setWxRendererOptions({fonts:e}),this.setCurrentFont(e),this.$emit("refresh")},sizeChanged:function(e){var t=F(e.replace("px",""));t=$(t,this.currentColor),this.setWxRendererOptions({size:e,theme:t}),this.setCurrentSize(e),this.$emit("refresh")},colorChanged:function(e){var t=F(this.currentSize.replace("px",""));t=$(t,e),this.setWxRendererOptions({theme:t}),this.setCurrentColor(e),this.$emit("refresh")},statusChanged:function(e){this.setCiteStatus(e),this.$emit("refresh")},beforeUpload:function(e){var t=this,n=L(e);if(n)return this.$message({showClose:!0,message:n,type:"error"}),!1;var o=new FormData;return o.append("file",e),k.fileUpload(o).then((function(e){t.$emit("uploaded",e)})).catch((function(e){console.log(e.message)})),!1},copy:function(){var e=this;this.$emit("startCopy"),setTimeout((function(){var t=document.getElementById("output");q(),e.setHtml(H(e.nightMode)),t.focus(),window.getSelection().removeAllRanges();var n=document.createRange();n.setStartBefore(t.firstChild),n.setEndAfter(t.lastChild),window.getSelection().addRange(n),document.execCommand("copy"),e.$notify({showClose:!0,message:"已复制渲染后的文章到剪贴板,可直接到公众号后台粘贴",offset:80,duration:1600,type:"success"}),t.innerHTML=e.output,e.$emit("refresh"),e.$emit("endCopy")}),350)},customStyle:function(){var e=this;return Object(E["a"])(regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:return e.$emit("showBox"),e.$nextTick((function(){e.cssEditor||e.cssEditor.refresh()})),setTimeout((function(){e.cssEditor.refresh()}),50),t.next=5,localStorage.getItem("__css_content");case 5:n=t.sent,n||e.setCssEditorValue(W);case 7:case"end":return t.stop()}}),t)})))()},confirmReset:function(){localStorage.clear(),this.clearEditorToDefault(),this.editor.focus(),this.citeStatus=!1,this.statusChanged(!1),this.fontChanged(this.config.builtinFonts[0].value),this.colorChanged(this.config.colorOption[1].value),this.sizeChanged(this.config.sizeOption[2].value),this.$emit("cssChanged"),this.selectFont=this.currentFont,this.selectSize=this.currentSize,this.selectColor=this.currentColor,this.showResetConfirm=!1},cancelReset:function(){this.showResetConfirm=!1,this.editor.focus()},downloadEditorContent:function(){var e=document.createElement("a");e.download="content.md",e.style.display="none";var t=new Blob([this.editor.getValue(0)]);e.href=URL.createObjectURL(t),document.body.appendChild(e),e.click(),document.body.removeChild(e)}},Object(Q["b"])(["clearEditorToDefault","setCurrentColor","setCiteStatus","themeChanged","setHtml","setCurrentFont","setCurrentSize","setCssEditorValue","setWxRendererOptions"])),mounted:function(){this.selectFont=this.currentFont,this.selectSize=this.currentSize,this.selectColor=this.currentColor}},oe=ne,ie=(n("2a20"),Object(u["a"])(oe,S,_,!1,null,"5240e4af",null)),re=ie.exports,ae=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("el-dialog",{staticClass:"about__dialog",attrs:{title:"关于",visible:e.aboutDialogVisible,width:"30%",center:""},on:{close:function(t){return e.$emit("close")}}},[n("div",{staticStyle:{"text-align":"center"}},[n("h3",[e._v("一款高度简洁的微信 Markdown 编辑器")])]),n("div",{staticStyle:{"text-align":"center","margin-top":"10px"}},[n("p",[e._v("扫码关注我的公众号,原创技术文章第一时间推送!")]),n("img",{staticStyle:{width:"40%",display:"block",margin:"20px auto 10px"},attrs:{src:"https://imgkr.cn-bj.ufileos.com/09f8e662-42ed-4731-a0d7-419deb74dfb6.png"}})]),n("span",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[n("el-button",{attrs:{type:"success",plain:""},on:{click:function(t){return e.onRedirect("https://github.com/doocs/md")}}},[e._v("GitHub 仓库")]),n("el-button",{attrs:{type:"success",plain:""},on:{click:function(t){return e.onRedirect("https://gitee.com/doocs/md")}}},[e._v("Gitee 仓库")])],1)])},se=[],le={props:{aboutDialogVisible:{type:Boolean,default:!1}},methods:{onRedirect:function(e){window.open(e)}}},ce=le,ue=Object(u["a"])(ce,ae,se,!1,null,"362063c8",null),de=ue.exports,fe=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("el-dialog",{staticClass:"insert__dialog",attrs:{title:"插入表格",visible:e.dialogFormVisible},on:{close:function(t){return e.$emit("close")}}},[n("el-form",{staticClass:"insert__form",attrs:{model:e.config.form}},[n("el-form-item",{attrs:{label:"行数(表头不计入行数)"}},[n("el-input",{model:{value:e.config.form.rows,callback:function(t){e.$set(e.config.form,"rows",t)},expression:"config.form.rows"}})],1),n("el-form-item",{attrs:{label:"列数"}},[n("el-input",{model:{value:e.config.form.cols,callback:function(t){e.$set(e.config.form,"cols",t)},expression:"config.form.cols"}})],1)],1),n("div",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[n("el-button",{attrs:{type:e.btnType,plain:""},on:{click:function(t){return e.$emit("close")}}},[e._v("取 消")]),n("el-button",{attrs:{type:e.btnType,plain:""},on:{click:e.insertTable}},[e._v("确 定")])],1)],1)},pe=[],ge={props:{dialogFormVisible:{type:Boolean,default:!1}},data:function(){return{config:U}},computed:Object(h["a"])({btnType:function(){return this.nightMode?"default":"success"}},Object(Q["c"])({nightMode:function(e){return e.nightMode},editor:function(e){return e.editor}})),methods:Object(h["a"])({insertTable:function(){var e=this.editor.getCursor(),t=parseInt(this.config.form.rows),n=parseInt(this.config.form.cols);if(isNaN(t)||isNaN(n)||t<1||n<1)this.$message({showClose:!0,message:"输入的行/列数无效,请重新输入",type:"error"});else{for(var o="",i=0;i<t+2;++i){for(var r=0;r<n+1;++r)o+=0===r?"|":1!==i?" |":" --- |";o+="\n"}this.editor.replaceSelection("\n".concat(o,"\n"),e),this.$emit("close"),this.editorRefresh()}}},Object(Q["b"])(["editorRefresh"]))},he=ge,me=Object(u["a"])(he,fe,pe,!1,null,"0bb71b82",null),be=me.exports,ve=(n("18a5"),n("53ca"));(function(e){var t={pairs:"()[]{}''\"\"",closeBefore:")]}'\":;>",triples:"",explode:"[]{}"},n=e.Pos;function o(e,n){return"pairs"==n&&"string"==typeof e?e:"object"==Object(ve["a"])(e)&&null!=e[n]?e[n]:t[n]}e.defineOption("autoCloseBrackets",!1,(function(t,n,a){a&&a!=e.Init&&(t.removeKeyMap(i),t.state.closeBrackets=null),n&&(r(o(n,"pairs")),t.state.closeBrackets=n,t.addKeyMap(i))}));var i={Backspace:l,Enter:c};function r(e){for(var t=0;t<e.length;t++){var n=e.charAt(t),o="'"+n+"'";i[o]||(i[o]=a(n))}}function a(e){return function(t){return d(t,e)}}function s(e){var t=e.state.closeBrackets;if(!t||t.override)return t;var n=e.getModeAt(e.getCursor());return n.closeBrackets||t}function l(t){var i=s(t);if(!i||t.getOption("disableInput"))return e.Pass;for(var r=o(i,"pairs"),a=t.listSelections(),l=0;l<a.length;l++){if(!a[l].empty())return e.Pass;var c=f(t,a[l].head);if(!c||r.indexOf(c)%2!=0)return e.Pass}for(l=a.length-1;l>=0;l--){var u=a[l].head;t.replaceRange("",n(u.line,u.ch-1),n(u.line,u.ch+1),"+delete")}}function c(t){var n=s(t),i=n&&o(n,"explode");if(!i||t.getOption("disableInput"))return e.Pass;for(var r=t.listSelections(),a=0;a<r.length;a++){if(!r[a].empty())return e.Pass;var l=f(t,r[a].head);if(!l||i.indexOf(l)%2!=0)return e.Pass}t.operation((function(){var e=t.lineSeparator()||"\n";t.replaceSelection(e+e,null),t.execCommand("goCharLeft"),r=t.listSelections();for(var n=0;n<r.length;n++){var o=r[n].head.line;t.indentLine(o,null,!0),t.indentLine(o+1,null,!0)}}))}function u(t){var o=e.cmpPos(t.anchor,t.head)>0;return{anchor:new n(t.anchor.line,t.anchor.ch+(o?-1:1)),head:new n(t.head.line,t.head.ch+(o?1:-1))}}function d(t,i){var r=s(t);if(!r||t.getOption("disableInput"))return e.Pass;var a=o(r,"pairs"),l=a.indexOf(i);if(-1==l)return e.Pass;for(var c,d=o(r,"closeBefore"),f=o(r,"triples"),g=a.charAt(l+1)==i,h=t.listSelections(),m=l%2==0,b=0;b<h.length;b++){var v,y=h[b],x=y.head,w=t.getRange(x,n(x.line,x.ch+1));if(m&&!y.empty())v="surround";else if(!g&&m||w!=i)if(g&&x.ch>1&&f.indexOf(i)>=0&&t.getRange(n(x.line,x.ch-2),x)==i+i){if(x.ch>2&&/\bstring/.test(t.getTokenTypeAt(n(x.line,x.ch-2))))return e.Pass;v="addFour"}else if(g){var C=0==x.ch?" ":t.getRange(n(x.line,x.ch-1),x);if(e.isWordChar(w)||C==i||e.isWordChar(C))return e.Pass;v="both"}else{if(!m||!(0===w.length||/\s/.test(w)||d.indexOf(w)>-1))return e.Pass;v="both"}else v=g&&p(t,x)?"both":f.indexOf(i)>=0&&t.getRange(x,n(x.line,x.ch+3))==i+i+i?"skipThree":"skip";if(c){if(c!=v)return e.Pass}else c=v}var k=l%2?a.charAt(l-1):i,S=l%2?i:a.charAt(l+1);t.operation((function(){if("skip"==c)t.execCommand("goCharRight");else if("skipThree"==c)for(var e=0;e<3;e++)t.execCommand("goCharRight");else if("surround"==c){var n=t.getSelections();for(e=0;e<n.length;e++)n[e]=k+n[e]+S;t.replaceSelections(n,"around"),n=t.listSelections().slice();for(e=0;e<n.length;e++)n[e]=u(n[e]);t.setSelections(n)}else"both"==c?(t.replaceSelection(k+S,null),t.triggerElectric(k+S),t.execCommand("goCharLeft")):"addFour"==c&&(t.replaceSelection(k+k+k+k,"before"),t.execCommand("goCharRight"))}))}function f(e,t){var o=e.getRange(n(t.line,t.ch-1),n(t.line,t.ch+1));return 2==o.length?o:null}function p(e,t){var o=e.getTokenAt(n(t.line,t.ch+1));return/\bstring/.test(o.type)&&o.start==t.ch&&(0==t.ch||!/\bstring/.test(e.getTokenTypeAt(t)))}r(t.pairs+"`")})(b.a);var ye=n("1157"),xe=n.n(ye);n("f9d4"),n("e022");var we={data:function(){return{config:U,showBox:!1,aboutDialogVisible:!1,dialogFormVisible:!1,isCoping:!1,backLight:!1,timeout:null,changeTimer:null,source:""}},components:{editorHeader:re,aboutDialog:de,insertFormDialog:be},computed:Object(h["a"])({},Object(Q["c"])({wxRenderer:function(e){return e.wxRenderer},output:function(e){return e.output},editor:function(e){return e.editor},cssEditor:function(e){return e.cssEditor},currentSize:function(e){return e.currentSize},currentColor:function(e){return e.currentColor},html:function(e){return e.html},nightMode:function(e){return e.nightMode}})),created:function(){var e=this;this.initEditorState(),this.$nextTick((function(){e.initEditor(),e.initCssEditor(),e.onEditorRefresh()}))},methods:Object(h["a"])({initEditor:function(){var e=this;this.initEditorEntity(),this.editor.on("change",(function(t,n){e.changeTimer&&clearTimeout(e.changeTimer),e.changeTimer=setTimeout((function(){e.onEditorRefresh(),D(e.editor,"__editor_content")}),300)})),this.editor.on("paste",(function(t,n){if(n.clipboardData&&n.clipboardData.items)for(var o=0,i=n.clipboardData.items.length;o<i;++o){var r=n.clipboardData.items[o];if("file"===r.kind){var a=r.getAsFile(),s=L(a);if(s)return void e.$message({showClose:!0,message:s,type:"error"});var l=new FormData;l.append("file",a),k.fileUpload(l).then((function(t){e.uploaded(t)})).catch((function(e){console.log(e.message)}))}}}))},initCssEditor:function(){var e=this;this.initCssEditorEntity(),this.cssEditor.on("keyup",(function(e,t){(t.keyCode>=65&&t.keyCode<=90||189===t.keyCode)&&e.showHint(t)})),this.cssEditor.on("update",(function(t){e.cssChanged(),D(e.cssEditor,"__css_content")}))},cssChanged:function(){var e=I(this.cssEditor.getValue(0)),t=F(this.currentSize.replace("px",""));t=M(e,this.currentColor,t),this.setWxRendererOptions({theme:t}),this.onEditorRefresh()},onTextareaChange:function(){console.log("change")},uploaded:function(e,t,n){if(e)if(e.success){var o=this.editor.getCursor(),i=e.data,r="![](".concat(i,")");this.editor.replaceSelection("\n".concat(r,"\n"),o),this.$message({showClose:!0,message:"图片插入成功",type:"success"}),this.onEditorRefresh()}else this.$message({showClose:!0,message:e.message,type:"error"});else this.$message({showClose:!0,message:"上传图片未知异常",type:"error"})},leftAndRightScroll:function(){xe()("#preview").on("scroll",(function e(){clearTimeout(this.timeout);var t=xe()(this),n=xe()(t.is("#preview")?"div.CodeMirror-scroll":"#preview");n.off("scroll");var o=t[0],i=n[0],r=o.scrollTop/(o.scrollHeight-o.offsetHeight),a=r*(i.scrollHeight-i.offsetHeight);i.scrollTo(0,a),this.timeout=setTimeout((function(){n.on("scroll",e)}),100)}))},onEditorRefresh:function(){this.editorRefresh(),setTimeout((function(){return PR.prettyPrint()}),0)},endCopy:function(){var e=this;this.backLight=!1,setTimeout((function(){e.isCoping=!1}),800)}},Object(Q["b"])(["initEditorState","initEditorEntity","setWxRendererOptions","editorRefresh","initCssEditorEntity"])),mounted:function(){this.leftAndRightScroll(),setTimeout((function(){PR.prettyPrint()}),300)}},Ce=we,ke=(n("d03a"),Object(u["a"])(Ce,p,g,!1,null,"66ac7c7c",null)),Se=ke.exports,_e={name:"App",components:{Loading:f,CodemirrorEditor:Se},data:function(){return{loading:!0}},mounted:function(){var e=this;setTimeout((function(){e.loading=!1}),200),window.console&&window.console.log&&console.log("Think big, train fast, learn deep. See https://github.com/yanglbme")}},Ee=_e,Oe=Object(u["a"])(Ee,i,r,!1,null,"1407684e",null),Re=Oe.exports,Te=(n("99af"),n("a15b"),n("e0c1")),je=n.n(Te),Ne=function(e){var t=this;this.opts=e;var n=!0,o=[],i=0,r=null,a="Menlo, Operator Mono, Consolas, Monaco, monospace",s=function(e,t){return Object.assign({},e,t)};this.buildTheme=function(e){var n={},o=s(e.BASE,{"font-family":t.opts.fonts,"font-size":t.opts.size}),i=s(o,{});for(var r in e.inline)if(e.inline.hasOwnProperty(r)){var l=e.inline[r];"codespan"===r&&(l["font-family"]=a,l["white-space"]="normal"),n[r]=s(o,l)}for(var c in e.block)if(e.block.hasOwnProperty(c)){var u=e.block[c];"code"===c&&(u["font-family"]=a),n[c]=s(i,u)}return n};var l=function(e,t){var n=[],o=r[e];if(!o)return"";for(var i in o)n.push(i+":"+o[i]);return'style="'.concat(n.join(";")+(t||""),'"')},c=function(e,t){return o.push([++i,e,t]),i};this.buildFootnotes=function(){var e=o.map((function(e){return e[1]===e[2]?'<code style="font-size: 90%; opacity: 0.6;">['.concat(e[0],"]</code>: <i>").concat(e[1],"</i><br/>"):'<code style="font-size: 90%; opacity: 0.6;">['.concat(e[0],"]</code> ").concat(e[1],": <i>").concat(e[2],"</i><br/>")}));return"<h4 ".concat(l("h4"),">引用链接</h4><p ").concat(l("footnotes"),">").concat(e.join("\n"),"</p>")},this.buildAddition=function(){return'\n <style>\n .preview-wrapper pre::before {\n font-family: "SourceSansPro", "HelveticaNeue", Arial, sans-serif;\n position: absolute;\n top: 0;\n right: 0;\n color: #ccc;\n text-align: center;\n font-size: 0.8em;\n padding: 5px 10px 0;\n line-height: 15px;\n height: 15px;\n font-weight: 600;\n }\n </style>\n '},this.setOptions=function(e){t.opts=s(t.opts,e)},this.hasFootnotes=function(){return 0!==o.length},this.getRenderer=function(e){o=[],i=0,r=t.buildTheme(t.opts.theme);var a=new je.a.Renderer;return a.heading=function(e,t){switch(t){case 1:return"<h1 ".concat(l("h1"),">").concat(e,"</h1>");case 2:return"<h2 ".concat(l("h2"),">").concat(e,"</h2>");case 3:return"<h3 ".concat(l("h3"),">").concat(e,"</h3>");default:return"<h4 ".concat(l("h4"),">").concat(e,"</h4>")}},a.paragraph=function(e){return"<p ".concat(l("p"),">").concat(e,"</p>")},a.blockquote=function(e){return e=e.replace(/<p.*?>/,"<p ".concat(l("blockquote_p"),">")),"<blockquote ".concat(l("blockquote"),">").concat(e,"</blockquote>")},a.code=function(e,t){e=e.replace(/</g,"&lt;"),e=e.replace(/>/g,"&gt;");for(var n=e.split("\n"),o=[],i=[],r=0;r<n.length;r++){var a=n[r];o.push('<code class="prettyprint"><span class="code-snippet_outer">'.concat(a||"<br>","</span></code>")),i.push("<li></li>")}var s=t||"";return'\n <section class="code-snippet__fix code-snippet__js">\n <ul class="code-snippet__line-index code-snippet__js">'.concat(i.join(""),'</ul>\n <pre class="code-snippet__js" data-lang="').concat(s,'">\n ').concat(o.join(""),"\n </pre>\n </section>\n ")},a.codespan=function(e,t){return"<code ".concat(l("codespan"),">").concat(e,"</code>")},a.listitem=function(e){return"<span ".concat(l("listitem"),'><span style="margin-right: 10px;"><%s/></span>').concat(e,"</span>")},a.list=function(e,t,n){e=e.replace(/<\/*p.*?>/g,"");var o=e.split("<%s/>");if(!t)return e=o.join("•"),"<p ".concat(l("ul"),">").concat(e,"</p>");e=o[0];for(var i=1;i<o.length;i++)e=e+i+"."+o[i];return"<p ".concat(l("ol"),">").concat(e,"</p>")},a.image=function(e,t,o){var i="";o&&(i="<figcaption ".concat(l("figcaption"),">").concat(o,"</figcaption>"));var r=l("figure"),a=l(n?"image":"image_org");return"<figure ".concat(r,"><img ").concat(a,' src="').concat(e,'" title="').concat(t,'" alt="').concat(o,'"/>').concat(i,"</figure>")},a.link=function(t,n,o){if(0===t.indexOf("https://mp.weixin.qq.com"))return'<a href="'.concat(t,'" title="').concat(n||o,'" ').concat(l("wx_link"),">").concat(o,"</a>");if(t===o)return o;if(e){var i=c(n||o,t);return"<span ".concat(l("link"),">").concat(o,"<sup>[").concat(i,"]</sup></span>")}return o},a.strong=function(e){return"<strong ".concat(l("strong"),">").concat(e,"</strong>")},a.em=function(e){return"<p ".concat(l("p",";font-style: italic;"),">").concat(e,"</p>")},a.table=function(e,t){return'<section style="padding:0 8px;"><table class="preview-table"><thead '.concat(l("thead"),">").concat(e,"</thead><tbody>").concat(t,"</tbody></table></section>")},a.tablecell=function(e,t){return"<td ".concat(l("td"),">").concat(e,"</td>")},a.hr=function(){return'<hr style="border-style: solid;border-width: 1px 0 0;border-color: rgba(0,0,0,0.1);-webkit-transform-origin: 0 0;-webkit-transform: scale(1, 0.5);transform-origin: 0 0;transform: scale(1, 0.5);">'},a}},ze=Ne,$e='# 示例文章Google 搜索的即时自动补全功能究竟是如何“工作”的?\n> Google 搜索**自动补全功能**的强大,相信不少朋友都能感受到,它帮助我们更快地“补全”我们所要输入的搜索关键字。那么,它怎么知道我们要输入什么内容?它又是如何工作的?在这篇文章里,我们一起来看看。\n\n## 使用自动补全\nGoogle 搜索的自动补全功能可以在 Google 搜索应用的大多数位置使用,包括 [Google](https://www.google.com/) 主页、适用于 IOS 和 Android 的 Google 应用,我们只需要在 Google 搜索框上开始键入关键字,就可以看到联想词了。\n\n![](https://imgkr.cn-bj.ufileos.com/17ed83bf-e028-4db2-9503-5a3b4e64deee.gif)\n\n在上图示例中我们可以看到输入关键字 `juej`Google 搜索会联想到“掘金”、“掘金小册”、“绝句”等等,好处就是,我们无须输入完整的关键字即可轻松完成针对这些 topics 的搜索。\n\n谷歌搜索的自动补全功能对于使用移动设备的用户来说特别有用用户可以轻松在难以键入的小屏幕上完成搜索。当然对于移动设备用户和台式机用户而言这都节省了大量的时间。根据 Google 官方报告,自动补全功能可以减少大约 25% 的打字,累积起来,预计每天可以节省 200 多年的打字时间。是的,每天!\n\n> 注意,本文所提到的“**联想词**”与“**预测**”,是同一个意思。\n\n## 基于“预测”而非“建议”\nGoogle 官方将自动补全功能称之为“预测”,而不是“建议”,为什么呢?其实是有充分理由的。自动补全功能是为了**帮助用户完成他们打算进行的搜索**,而不是建议用户要执行什么搜索。\n\n那么Google 是如何确定这些“预测”的其实Google 会根据趋势搜索 [trends](https://trends.google.com/trends/?geo=US) 给到我们这些“预测”。简单来说,哪个热门、哪个搜索频率高,就更可能推给我们。当然,这也与我们当前所处的位置以及我们的搜索历史相关。\n\n另外这些“预测”也会随着我们键入的关键字的变更而更改。例如当我们把键入的关键字从 `juej` 更改为 `juex` 时,与“掘金”相关的预测会“消失”,同时,与“觉醒”、“决心”相关联的词会出现。\n\n![](https://imgkr.cn-bj.ufileos.com/5b17dc99-606d-42c1-9f86-e09e88aaa822.gif)\n\n## 为什么看不到某些联想词?\n如果我们在输入某个关键字时看不到联想词那么表明 Google 的算法可能检测到:\n\n- 这个关键字不是热门字词;\n- 搜索的字词太新了,我们可能需要等待几天或几周才能看到联想词;\n- 这是一个侮辱性或敏感字词,这个搜索字词违反了 Google 的相关政策。更加详细的情况,可以了解 [Google 搜索自动补全政策](https://support.google.com/websearch/answer/7368877)。\n\n## 为什么会看到某些不当的联想词?\nGoogle 拥有专门设计的系统可以自动捕获不适当的预测结果而不显示出来。然而Google 每天需要处理数十亿次搜索,这意味着 Google 每天会显示数十亿甚至上百亿条预测。再好的系统,也可能存在缺陷,不正确的预测也可能随时会出现。\n\n我们作为 Google 搜索的用户,如果认定某条预测违反了相关的搜索自动补全政策,可以进行举报反馈,点击右下角“**举报不当的联想查询**”并勾选相关选项即可。\n\n![](https://imgkr.cn-bj.ufileos.com/6ca8185d-12c6-4550-bb4e-e49cfbf56db7.gif)\n\n## 如何实现自动补全算法?\n目前Google 官方似乎并没有公开搜索自动补全的算法实现,但是业界在这方面已经有了不少研究。\n\n一个好的自动补全器必须是快速的并且在用户键入下一个字符后立即更新联想词列表。**自动补全器的核心是一个函数,它接受输入的前缀,并搜索以给定前缀开头的词汇或语句列表**。通常来说,只需要返回少量的数目即可。\n\n接下来我们先从一个简单且低效的实现开始并在此基础上逐步构建更高效的方法。\n\n### 词汇表实现\n一个**简单粗暴的实现方式**是:顺序查找词汇表,依次检查每个词汇,看它是否以给定的前缀开头。\n\n但是此方法需要将前缀与每个词汇进行匹配检查若词汇量较少这种方式可能勉强行得通。但是如果词汇量规模较大效率就太低了。\n\n一个**更好的实现方式是**:让词汇按字典顺序排序。借助二分搜索算法,可以快速搜索有序词汇表中的前缀。由于二分搜索的每一步都会将搜索的范围减半,因此,总的搜索时间与词汇表中单词数量的对数成正比,即时间复杂度是 `O(log N)`。二分搜索的性能很好,但有没有更好的实现呢?当然有,往下看。\n\n### 前缀树实现\n通常来说许多词汇都以相同的前缀开头比如 `need`、`nested` 都以 `ne` 开头,`seed`、`speed` 都以 `s` 开头。要是为每个单词分别存储公共前缀似乎很浪费。\n\n![](https://imgkr.cn-bj.ufileos.com/7cc3cf37-040a-420e-8ef9-d05e92c82cfd.png)\n\n前缀树是一种利用公共前缀来加速补全速度的数据结构。前缀树在节点树中排列一组单词单词沿着从根节点到叶子节点的路径存储树的层次对应于前缀的字母位置。\n\n前缀的补全是顺着前缀定义的路径来查找的。例如在上图的前缀树中前缀 `ne` 对应于从子节点取左边缘 `N` 和唯一边缘 `E` 的路径。然后可以通过继续遍历从 `E` 节点可以达到的所有叶节点来生成补全列表。在图中,`ne` 的补全可以是两个分支:`-ed` 和 `-sted`。如果在数中找不到由前缀定义的路径,则说明词汇表中不包含以该前缀开头的单词。\n\n### 有限状态自动机(DFA)实现\n前缀树可以有效处理公共前缀但是对于其他共享词部分仍会分别存储在每个分支中。比如后缀 `ed`、`ing`、`tion` 在英文单词中特别常见。在上一个例子中,`e`、`d` 分别存放在了每一个分支上。\n\n有没有一种方法可以更加节省存储空间呢有的那就是 DFA。\n\n<center>\n<img src="https://imgkr.cn-bj.ufileos.com/02bc143e-e1a7-4b3c-bd5d-8d6d39139f0a.png" style="width: 50%;"></center>\n\n在上面的例子中单词 `need`、`nested`、`seed` 和 `speed` 仅由 9 个节点组成,而上一张图中的前缀树包含了 17 个节点。\n\n可以看出最小化前缀树 DFA 可以在很大程度上减少数据结构的大小。即使词汇量很大,最小化 DFA 通常也适合在内存中存储,避免昂贵的磁盘访问是实现快速自动补全的关键。\n\n### 一些扩展\n上面介绍了如何利用合理的数据结构实现基本的自动补全功能。这些数据结构可以通过多种方式进行扩展从而改善用户体验。\n\n通常满足特定前缀的词汇可能很多而用户界面上能够显示的却不多我们更希望能显示最常搜索或者最有价值的词汇。这通常可以通过为词汇表中的每个单词增加一个代表单词值的**权重** `weight`,并且按照权重高低来排序自动补全列表。\n\n- 对于排序后的词汇表来说,在词汇表每个元素上增加 `weight` 属性并不难;\n- 对于前缀树来说,将 `weight` 存储在叶子节点中,也是很简单的一个实现;\n- 对于 `DFA` 来说,则较为复杂。因为一个叶子节点可以通过多条路径到达。一种解决方案是将权重关联到路径而不是叶子节点。\n\n目前有不少开源库都提供了这个功能比如主流的搜索引擎框架 [Elasticsearch](https://www.elastic.co/products/elasticsearch)、[Solr](https://lucene.apache.org/solr/) 等,基于此,我们可以实现高效而强大的自动补全功能。\n\n#### 推荐阅读\n- [阿里又一个 20k+ stars 开源项目诞生,恭喜 fastjson](https://mp.weixin.qq.com/s/RNKDCK2KoyeuMeEs6GUrow)\n- [刷掉 90% 候选人的互联网大厂海量数据面试题(附题解 + 方法总结)](https://mp.weixin.qq.com/s/rjGqxUvrEqJNlo09GrT1Dw)\n- [好用!期待已久的文本块功能究竟如何在 Java 13 中发挥作用?](https://mp.weixin.qq.com/s/kalGv5T8AZGxTnLHr2wDsA)\n- [2019 GitHub 开源贡献排行榜新鲜出炉!微软谷歌领头,阿里跻身前 12](https://mp.weixin.qq.com/s/_q812aGD1b9QvZ2WFI0Qgw)\n\n---\n\n欢迎关注我的公众号“**Doocs开源社区**”,原创技术文章第一时间推送。\n\n<center>\n <img src="https://imgkr.cn-bj.ufileos.com/1092dc45-e817-4bb0-82b0-2b2b4826ccf2.gif" style="width: 100px;">\n</center>\n\n',Ae=$e;o["default"].use(Q["a"]);var Pe={wxRenderer:null,output:"",editor:null,cssEditor:null,html:"",currentFont:"",currentSize:"",currentColor:"",citeStatus:0,nightMode:!1},Fe={setHtml:function(e,t){e.html=t},setEditorValue:function(e,t){e.editor.setValue(t)},setCssEditorValue:function(e,t){e.cssEditor.setValue(t)},setWxRendererOptions:function(e,t){e.wxRenderer.setOptions(t)},setCiteStatus:function(e,t){e.citeStatus=t,localStorage.setItem("citeStatus",t)},setCurrentFont:function(e,t){e.currentFont=t,localStorage.setItem("fonts",t)},setCurrentSize:function(e,t){e.currentSize=t,localStorage.setItem("size",t)},setCurrentColor:function(e,t){e.currentColor=t,localStorage.setItem("color",t)},themeChanged:function(e){e.nightMode=!e.nightMode},initEditorState:function(e){e.currentFont=localStorage.getItem("fonts")||U.builtinFonts[0].value,e.currentColor=localStorage.getItem("color")||U.colorOption[1].value,e.currentSize=localStorage.getItem("size")||U.sizeOption[2].value,e.citeStatus="true"===localStorage.getItem("citeStatus"),e.wxRenderer=new ze({theme:P(e.currentColor),fonts:e.currentFont,size:e.currentSize,status:e.citeStatus})},initEditorEntity:function(e){if(e.editor=b.a.fromTextArea(document.getElementById("editor"),{value:"",mode:"text/x-markdown",theme:"xq-light",lineNumbers:!1,lineWrapping:!0,styleActiveLine:!0,autoCloseBrackets:!0,extraKeys:{"Ctrl-F":function(e){var t=B(e.getValue(0));localStorage.setItem("__editor_content",t),e.setValue(t)}}}),localStorage.getItem("__editor_content"))e.editor.setValue(localStorage.getItem("__editor_content"));else{var t=B(Ae);e.editor.setValue(t)}},initCssEditorEntity:function(e){e.cssEditor=b.a.fromTextArea(document.getElementById("cssEditor"),{value:"",mode:"css",theme:"style-mirror",lineNumbers:!1,lineWrapping:!0,matchBrackets:!0,autofocus:!0,extraKeys:{"Ctrl-F":function(e){var t=e.lineCount();e.autoFormatRange({line:0,ch:0},{line:t})}}}),localStorage.getItem("__css_content")?e.cssEditor.setValue(localStorage.getItem("__css_content")):e.cssEditor.setValue(W)},editorRefresh:function(e){var t=je()(e.editor.getValue(0),{renderer:e.wxRenderer.getRenderer(e.citeStatus)});t=t.replace(/(style=".*?)"/,'$1;margin-top: 0"'),e.citeStatus&&(t+=e.wxRenderer.buildFootnotes(),t+=e.wxRenderer.buildAddition()),e.output=t},clearEditorToDefault:function(e){var t=B(Ae);e.editor.setValue(t),e.cssEditor.setValue(W)}},Me=new Q["a"].Store({state:Pe,mutations:Fe,actions:{},modules:{}}),Ie=n("5c96"),De=n.n(Ie);n("0fae");o["default"].use(Ie["Container"]),o["default"].use(Ie["Header"]),o["default"].use(Ie["Upload"]),o["default"].use(Ie["Tooltip"]),o["default"].use(Ie["Form"]),o["default"].use(Ie["FormItem"]),o["default"].use(Ie["Select"]),o["default"].use(Ie["Option"]),o["default"].use(Ie["ColorPicker"]),o["default"].use(Ie["Switch"]),o["default"].use(Ie["Button"]),o["default"].use(Ie["Main"]),o["default"].use(Ie["Col"]),o["default"].use(Ie["Row"]),o["default"].use(Ie["Dialog"]),o["default"].use(Ie["Loading"]),o["default"].component(Ie["Message"].name,Ie["Message"]),o["default"].prototype.$loading=Ie["Loading"].service,o["default"].prototype.$message=Ie["Message"];n("a7be"),n("0f7c"),n("f6b6"),n("8d7e"),n("90ba");o["default"].use(De.a),o["default"].config.productionTip=!1,new o["default"]({store:Me,render:function(e){return e(Re)}}).$mount("#app")},"5a64":function(e,t,n){},"84bb":function(e,t,n){},"90ba":function(e,t,n){},"9e7d":function(e,t,n){},d03a:function(e,t,n){"use strict";var o=n("84bb"),i=n.n(o);i.a},e022:function(e,t,n){n("99af"),n("c975"),n("a15b"),n("d3b7"),n("4d63"),n("ac1f"),n("25f0"),n("466d"),n("5319"),n("1276"),function(){"undefined"!==typeof window&&(window.PR_SHOULD_USE_CONTINUATION=!0),function(){function e(e){function t(e){var t=e.charCodeAt(0);if(92!==t)return t;var n=e.charAt(1);return(t=d[n])?t:"0"<=n&&"7">=n?parseInt(e.substring(1),8):"u"===n||"x"===n?parseInt(e.substring(2),16):e.charCodeAt(1)}function n(e){return 32>e?(16>e?"\\x0":"\\x")+e.toString(16):(e=String.fromCharCode(e),"\\"===e||"-"===e||"]"===e||"^"===e?"\\"+e:e)}function o(e){var o=e.substring(1,e.length-1).match(RegExp("\\\\u[0-9A-Fa-f]{4}|\\\\x[0-9A-Fa-f]{2}|\\\\[0-3][0-7]{0,2}|\\\\[0-7]{1,2}|\\\\[\\s\\S]|-|[^-\\\\]","g"));e=[];var i="^"===o[0],r=["["];i&&r.push("^");i=i?1:0;for(var a=o.length;i<a;++i){var s=o[i];if(/\\[bdsw]/i.test(s))r.push(s);else{var l;s=t(s);i+2<a&&"-"===o[i+1]?(l=t(o[i+2]),i+=2):l=s,e.push([s,l]),65>l||122<s||(65>l||90<s||e.push([32|Math.max(65,s),32|Math.min(l,90)]),97>l||122<s||e.push([-33&Math.max(97,s),-33&Math.min(l,122)]))}}for(e.sort((function(e,t){return e[0]-t[0]||t[1]-e[1]})),o=[],a=[],i=0;i<e.length;++i)s=e[i],s[0]<=a[1]+1?a[1]=Math.max(a[1],s[1]):o.push(a=s);for(i=0;i<o.length;++i)s=o[i],r.push(n(s[0])),s[1]>s[0]&&(s[1]+1>s[0]&&r.push("-"),r.push(n(s[1])));return r.push("]"),r.join("")}function i(e){for(var t=e.source.match(RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g")),i=t.length,s=[],l=0,c=0;l<i;++l){var u=t[l];"("===u?++c:"\\"===u.charAt(0)&&(u=+u.substring(1))&&(u<=c?s[u]=-1:t[l]=n(u))}for(l=1;l<s.length;++l)-1===s[l]&&(s[l]=++r);for(c=l=0;l<i;++l)u=t[l],"("===u?(++c,s[c]||(t[l]="(?:")):"\\"===u.charAt(0)&&(u=+u.substring(1))&&u<=c&&(t[l]="\\"+s[u]);for(l=0;l<i;++l)"^"===t[l]&&"^"!==t[l+1]&&(t[l]="");if(e.ignoreCase&&a)for(l=0;l<i;++l)u=t[l],e=u.charAt(0),2<=u.length&&"["===e?t[l]=o(u):"\\"!==e&&(t[l]=u.replace(/[a-zA-Z]/g,(function(e){return e=e.charCodeAt(0),"["+String.fromCharCode(-33&e,32|e)+"]"})));return t.join("")}for(var r=0,a=!1,s=!1,l=0,c=e.length;l<c;++l){var u=e[l];if(u.ignoreCase)s=!0;else if(/[a-z]/i.test(u.source.replace(/\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi,""))){a=!0,s=!1;break}}var d={b:8,t:9,n:10,v:11,f:12,r:13},f=[];for(l=0,c=e.length;l<c;++l){if(u=e[l],u.global||u.multiline)throw Error(""+u);f.push("(?:"+i(u)+")")}return new RegExp(f.join("|"),s?"gi":"g")}function t(e,t){function n(e){var l=e.nodeType;if(1==l){if(!o.test(e.className)){for(l=e.firstChild;l;l=l.nextSibling)n(l);l=e.nodeName.toLowerCase(),"br"!==l&&"li"!==l||(i[s]="\n",a[s<<1]=r++,a[s++<<1|1]=e)}}else 3!=l&&4!=l||(l=e.nodeValue,l.length&&(l=t?l.replace(/\r\n?/g,"\n"):l.replace(/[ \t\r\n]+/g," "),i[s]=l,a[s<<1]=r,r+=l.length,a[s++<<1|1]=e))}var o=/(?:^|\s)nocode(?:\s|$)/,i=[],r=0,a=[],s=0;return n(e),{a:i.join("").replace(/\n$/,""),c:a}}function n(e,t,n,o,i){n&&(e={h:e,l:1,j:null,m:null,a:n,c:null,i:t,g:null},o(e),i.push.apply(i,e.g))}function o(e){for(var t=void 0,n=e.firstChild;n;n=n.nextSibling){var o=n.nodeType;t=1===o?t?e:n:3===o&&y.test(n.nodeValue)?e:t}return t===e?void 0:t}function i(t,o){function i(e){for(var t=e.i,c=e.h,u=[t,"pln"],d=0,f=e.a.match(r)||[],p={},g=0,h=f.length;g<h;++g){var m,b=f[g],v=p[b],y=void 0;if("string"===typeof v)m=!1;else{var x=a[b.charAt(0)];if(x)y=b.match(x[1]),v=x[0];else{for(m=0;m<s;++m)if(x=o[m],y=b.match(x[1])){v=x[0];break}y||(v="pln")}!(m=5<=v.length&&"lang-"===v.substring(0,5))||y&&"string"===typeof y[1]||(m=!1,v="src"),m||(p[b]=v)}if(x=d,d+=b.length,m){m=y[1];var w=b.indexOf(m),C=w+m.length;y[2]&&(C=b.length-y[2].length,w=C-m.length),v=v.substring(5),n(c,t+x,b.substring(0,w),i,u),n(c,t+x+w,m,l(v,m),u),n(c,t+x+C,b.substring(C),i,u)}else u.push(t+x,v)}e.g=u}var r,a={};(function(){for(var n=t.concat(o),i=[],s={},l=0,c=n.length;l<c;++l){var u=n[l],d=u[3];if(d)for(var f=d.length;0<=--f;)a[d.charAt(f)]=u;u=u[1],d=""+u,s.hasOwnProperty(d)||(i.push(u),s[d]=null)}i.push(/[\0-\uffff]/),r=e(i)})();var s=o.length;return i}function r(e){var t=[],n=[];e.tripleQuotedStrings?t.push(["str",/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""]):e.multiLineStrings?t.push(["str",/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"]):t.push(["str",/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"]),e.verbatimStrings&&n.push(["str",/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null]);var o=e.hashComments;if(o&&(e.cStyleComments?(1<o?t.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"]):t.push(["com",/^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"]),n.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,null])):t.push(["com",/^#[^\r\n]*/,null,"#"])),e.cStyleComments&&(n.push(["com",/^\/\/[^\r\n]*/,null]),n.push(["com",/^\/\*[\s\S]*?(?:\*\/|$)/,null])),o=e.regexLiterals){var r=(o=1<o?"":"\n\r")?".":"[\\S\\s]";n.push(["lang-regex",RegExp("^(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<<?=?|>>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*(/(?=[^/*"+o+"])(?:[^/\\x5B\\x5C"+o+"]|\\x5C"+r+"|\\x5B(?:[^\\x5C\\x5D"+o+"]|\\x5C"+r+")*(?:\\x5D|$))+/)")])}return(o=e.types)&&n.push(["typ",o]),o=(""+e.keywords).replace(/^ | $/g,""),o.length&&n.push(["kwd",new RegExp("^(?:"+o.replace(/[\s,]+/g,"|")+")\\b"),null]),t.push(["pln",/^\s+/,null," \r\n\t "]),o="^.[^\\s\\w.$@'\"`/\\\\]*",e.regexLiterals&&(o+="(?!s*/)"),n.push(["lit",/^@[a-z_$][a-z_$@0-9]*/i,null],["typ",/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],["pln",/^[a-z_$][a-z_$@0-9]*/i,null],["lit",/^(?:0x[a-f0-9]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+\-]?\d+)?)[a-z]*/i,null,"0123456789"],["pln",/^\\[\s\S]?/,null],["pun",new RegExp(o),null]),i(t,n)}function a(e,t,n){function o(e){var t=e.nodeType;if(1!=t||r.test(e.className)){if((3==t||4==t)&&n){var l=e.nodeValue,c=l.match(a);c&&(t=l.substring(0,c.index),e.nodeValue=t,(l=l.substring(c.index+c[0].length))&&e.parentNode.insertBefore(s.createTextNode(l),e.nextSibling),i(e),t||e.parentNode.removeChild(e))}}else if("br"===e.nodeName.toLowerCase())i(e),e.parentNode&&e.parentNode.removeChild(e);else for(e=e.firstChild;e;e=e.nextSibling)o(e)}function i(e){function t(e,n){var o=n?e.cloneNode(!1):e,i=e.parentNode;if(i){i=t(i,1);var r=e.nextSibling;i.appendChild(o);for(var a=r;a;a=r)r=a.nextSibling,i.appendChild(a)}return o}for(;!e.nextSibling;)if(e=e.parentNode,!e)return;e=t(e.nextSibling,0);for(var n;(n=e.parentNode)&&1===n.nodeType;)e=n;c.push(e)}for(var r=/(?:^|\s)nocode(?:\s|$)/,a=/\r\n?|\n/,s=e.ownerDocument,l=s.createElement("li");e.firstChild;)l.appendChild(e.firstChild);for(var c=[l],u=0;u<c.length;++u)o(c[u]);t===(0|t)&&c[0].setAttribute("value",t);var d=s.createElement("ol");d.className="linenums",t=Math.max(0,t-1|0)||0;u=0;for(var f=c.length;u<f;++u)l=c[u],l.className="L"+(u+t)%10,l.firstChild||l.appendChild(s.createTextNode(" ")),d.appendChild(l);e.appendChild(d)}function s(e,t){for(var n=t.length;0<=--n;){var o=t[n];w.hasOwnProperty(o)?u.console&&console.warn("cannot override language handler %s",o):w[o]=e}}function l(e,t){return e&&w.hasOwnProperty(e)||(e=/^\s*</.test(t)?"default-markup":"default-code"),w[e]}function c(e){var n=e.j;try{var o=t(e.h,e.l),i=o.a;e.a=i,e.c=o.c,e.i=0,l(n,i)(e);var r,a,s=/\bMSIE\s(\d+)/.exec(navigator.userAgent),c=(s=s&&8>=+s[1],n=/\n/g,e.a),d=c.length,f=(o=0,e.c),p=f.length,g=(i=0,e.g),h=g.length,m=0;for(g[h]=d,a=r=0;a<h;)g[a]!==g[a+2]?(g[r++]=g[a++],g[r++]=g[a++]):a+=2;for(h=r,a=r=0;a<h;){for(var b=g[a],v=g[a+1],y=a+2;y+2<=h&&g[y+1]===v;)y+=2;g[r++]=b,g[r++]=v,a=y}g.length=r;var x=e.h;e="",x&&(e=x.style.display,x.style.display="none");try{for(;i<p;){var w,C=f[i+2]||d,k=g[m+2]||d,S=(y=Math.min(C,k),f[i+1]);if(1!==S.nodeType&&(w=c.substring(o,y))){s&&(w=w.replace(n,"\r")),S.nodeValue=w;var _=S.ownerDocument,E=_.createElement("span");E.className=g[m+1];var O=S.parentNode;O.replaceChild(E,S),E.appendChild(S),o<C&&(f[i+1]=S=_.createTextNode(c.substring(y,C)),O.insertBefore(S,E.nextSibling))}o=y,o>=C&&(i+=2),o>=k&&(m+=2)}}finally{x&&(x.style.display=e)}}catch(R){u.console&&console.log(R&&R.stack||R)}}var u="undefined"!==typeof window?window:{},d=["break,continue,do,else,for,if,return,while"],f=[[d,"auto,case,char,const,default,double,enum,extern,float,goto,inline,int,long,register,restrict,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"],"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],p=[f,"alignas,alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,delegate,dynamic_cast,explicit,export,friend,generic,late_check,mutable,namespace,noexcept,noreturn,nullptr,property,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],g=[f,"abstract,assert,boolean,byte,extends,finally,final,implements,import,instanceof,interface,null,native,package,strictfp,super,synchronized,throws,transient"],h=[f,"abstract,add,alias,as,ascending,async,await,base,bool,by,byte,checked,decimal,delegate,descending,dynamic,event,finally,fixed,foreach,from,get,global,group,implicit,in,interface,internal,into,is,join,let,lock,null,object,out,override,orderby,params,partial,readonly,ref,remove,sbyte,sealed,select,set,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,value,var,virtual,where,yield"],m=(f=[f,"abstract,async,await,constructor,debugger,enum,eval,export,from,function,get,import,implements,instanceof,interface,let,null,of,set,undefined,var,with,yield,Infinity,NaN"],[d,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"]),b=[d,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],v=(d=[d,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],/^(DIR|FILE|array|vector|(de|priority_)?queue|(forward_)?list|stack|(const_)?(reverse_)?iterator|(unordered_)?(multi)?(set|map)|bitset|u?(int|float)\d*)\b/),y=/\S/,x=r({keywords:[p,h,g,f,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",m,b,d],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),w={};s(x,["default-code"]),s(i([],[["pln",/^[^<?]+/],["dec",/^<!\w[^>]*(?:>|$)/],["com",/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",/^<xmp\b[^>]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^<script\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^<style\b[^>]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),"default-markup htm html mxml xhtml xml xsl".split(" ")),s(i([["pln",/^[\s]+/,null," \t\r\n"],["atv",/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],["pun",/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]),s(i([],[["atv",/^[\s\S]+/]]),["uq.val"]),s(r({keywords:p,hashComments:!0,cStyleComments:!0,types:v}),"c cc cpp cxx cyc m".split(" ")),s(r({keywords:"null,true,false"}),["json"]),s(r({keywords:h,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:v}),["cs"]),s(r({keywords:g,cStyleComments:!0}),["java"]),s(r({keywords:d,hashComments:!0,multiLineStrings:!0}),["bash","bsh","csh","sh"]),s(r({keywords:m,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),["cv","py","python"]),s(r({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",hashComments:!0,multiLineStrings:!0,regexLiterals:2}),["perl","pl","pm"]),s(r({keywords:b,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb","ruby"]),s(r({keywords:f,cStyleComments:!0,regexLiterals:!0}),["javascript","js","ts","typescript"]),s(r({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,throw,true,try,unless,until,when,while,yes",hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]),s(i([],[["str",/^[\s\S]+/]]),["regex"]);var C=u.PR={createSimpleLexer:i,registerLangHandler:s,sourceDecorator:r,PR_ATTRIB_NAME:"atn",PR_ATTRIB_VALUE:"atv",PR_COMMENT:"com",PR_DECLARATION:"dec",PR_KEYWORD:"kwd",PR_LITERAL:"lit",PR_NOCODE:"nocode",PR_PLAIN:"pln",PR_PUNCTUATION:"pun",PR_SOURCE:"src",PR_STRING:"str",PR_TAG:"tag",PR_TYPE:"typ",prettyPrintOne:u.prettyPrintOne=function(e,t,n){n=n||!1,t=t||null;var o=document.createElement("div");return o.innerHTML="<pre>"+e+"</pre>",o=o.firstChild,n&&a(o,n,!0),c({j:t,m:n,h:o,l:1,a:null,i:null,c:null,g:null}),o.innerHTML},prettyPrint:u.prettyPrint=function(e,t){function n(){for(var t=u.PR_SHOULD_USE_CONTINUATION?p.now()+250:1/0;g<s.length&&p.now()<t;g++){for(var i=s[g],l=w,d=i;d=d.previousSibling;){var f=d.nodeType,C=(7===f||8===f)&&d.nodeValue;if(C?!/^\??prettify\b/.test(C):3!==f||/\S/.test(d.nodeValue))break;if(C){l={},C.replace(/\b(\w+)=([\w:.%+-]+)/g,(function(e,t,n){l[t]=n}));break}}if(d=i.className,(l!==w||m.test(d))&&!b.test(d)){for(f=!1,C=i.parentNode;C;C=C.parentNode)if(x.test(C.tagName)&&C.className&&m.test(C.className)){f=!0;break}if(!f){if(i.className+=" prettyprinted",f=l.lang,!f){var k;f=d.match(h);!f&&(k=o(i))&&y.test(k.tagName)&&(f=k.className.match(h)),f&&(f=f[1])}if(v.test(i.tagName))C=1;else{C=i.currentStyle;var S=r.defaultView;C=(C=C?C.whiteSpace:S&&S.getComputedStyle?S.getComputedStyle(i,null).getPropertyValue("white-space"):0)&&"pre"===C.substring(0,3)}S=l.linenums,(S="true"===S||+S)||(S=!!(S=d.match(/\blinenums\b(?::(\d+))?/))&&(!S[1]||!S[1].length||+S[1])),S&&a(i,S,C),c({j:f,h:i,m:S,l:C,a:null,i:null,c:null,g:null})}}}g<s.length?u.setTimeout(n,250):"function"===typeof e&&e()}for(var i=t||document.body,r=i.ownerDocument||document,s=(i=[i.getElementsByTagName("pre"),i.getElementsByTagName("code"),i.getElementsByTagName("xmp")],[]),l=0;l<i.length;++l)for(var d=0,f=i[l].length;d<f;++d)s.push(i[l][d]);i=null;var p=Date;p.now||(p={now:function(){return+new Date}});var g=0,h=/\blang(?:uage)?-([\w.]+)(?!\S)/,m=/\bprettyprint\b/,b=/\bprettyprinted\b/,v=/pre|xmp/i,y=/^code$/i,x=/^(?:pre|code|xmp)$/i,w={};n()}};p=u.define;"function"===typeof p&&p.amd&&p("google-code-prettify",[],(function(){return C}))}()}()},e5b0:function(e,t,n){"use strict";var o=n("9e7d"),i=n.n(o);i.a}});
//# sourceMappingURL=app.7dd9b965.js.map