-
Notifications
You must be signed in to change notification settings - Fork 1
/
bundle.js
2 lines (2 loc) · 36.8 KB
/
bundle.js
1
2
!function(e){function t(i){if(n[i])return n[i].exports;var s=n[i]={exports:{},id:i,loaded:!1};return e[i].call(s.exports,s,s.exports,t),s.loaded=!0,s.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){n(1),n(1),e.exports=n(6)},function(e,t,n){n(2)},function(e,t,n){var i=n(3),s=n(4);n(5);i.createComponent().bindElement("#app1",{message:"Hello, LiKy!"}),i.createComponent({onInitialRendered:function(){this.convertToMD()},convertToMD:function(){this.setState({preview:s(this.state.text)})}}).bindElement("#app2",{text:"# Hello LiKy\n---\ncontent"}),i.createComponent().bindElement("#app3",{items:[{text:"Learn JavaScript"},{text:"Learn LiKy"},{text:"Build Something Awesome"}]}),i.createComponent({reverseMessage:function(){this.setState({message:this.state.message.split("").reverse().join("")})}}).bindElement("#app4",{message:"Hello LiKy!"}),i.createComponent({addTodo:function(e){13===e.keyCode&&this.state.newTodo&&(this.state.todos.push({text:this.state.newTodo}),this.setState({newTodo:""}))},removeTodo:function(e){this.state.todos.splice(e,1),this.setState()}}).bindElement("#app5",{newTodo:"",todos:[{text:"Add some todos!"}]}),i.createComponent({removeTodo:function(e){this.state.todos.splice(e,1),this.setState()},removeItem:function(e){this.state.todos.forEach(function(t){t.items.forEach(function(n,i){0===e--&&t.items.splice(i,1)})}),this.setState()}}).bindElement("#app6",{todos:[{title:"todo 1",items:["item 1","item 2"]},{title:"todo 2",items:["item 1","item 2"]}]});var r=i.createComponent({$state:{title:"Same Conponent"},removeItem:function(e){this.state.items.splice(e,1),this.setState()}});r.bindElement("#app7-list1",{items:["Learn JavaScript","Learn LiKy","Build Something Awesome"]}),r.bindElement("#app7-list2",{items:["item 1","item 2","item 3"]}),i.createComponent({submit:function(){var e={maleShow:"sex.male",femaleShow:"sex.female",checkboxShow:"checkbox"};for(var t in e)this.state[t]=this.state[e[t]]?"true":"false";return this.setState(),!1}}).bindElement("#app8"),i.createComponent({$remoteUrl:"/posts",fetchPosts:function(){console.log(this),this.remoteRead(function(e){this.state.posts=e.posts,console.log(this.state)})}}).bindElement("#app9",{posts:[]});var o=i.createComponent({onInitialRendered:function(){this.setState({htmlPreview:s(this.state.html),jsPreview:s(this.state.js)})}});o.bindElement("#code1",{html:'```html\n<div id="app1">\n {{!message}}\n</div>```',js:"```javascript\nViewModel.createComponent().bindElement('#app1', {\n message: 'Hello, LiKy!'\n});```"}),o.bindElement("#code2",{html:'```html\n<div id="app2">\n <textarea lk-state="text" lk-on="input:convertToMD"></textarea>\n <div>{{{!preview}}}</div>\n</div>```',js:"```javascript\nViewModel.createComponent({\n onInitialRendered: function () {\n this.convertToMD();\n },\n convertToMD: function () {\n this.setState({\n preview: marked(this.state.text)\n });\n }\n}).bindElement('#app2', {\n text: '# Hello LiKy\\n---\\ncontent'\n});```"}),o.bindElement("#code3",{html:'```html\n<div id="app3">\n <ul lk-for="item in items">\n <li>{{!item.text}}</li>\n </ul>\n</div>```',js:"```javascript\nViewModel.createComponent().bindElement('#app3', {\n items: [\n { text: 'Learn JavaScript' },\n { text: 'Learn LiKy' },\n { text: 'Build Something Awesome' }\n ]\n});```"}),o.bindElement("#code4",{html:'```html\n<div id="app4">\n <p>{{!message}}</p>\n <button lk-on="click:reverseMessage">Reverse</button>\n</div>```',js:"```javascript\nViewModel.createComponent({\n reverseMessage: function () {\n this.setState({\n message: this.state.message.split('').reverse().join('')\n });\n }\n}).bindElement('#app4', {\n message: 'Hello LiKy!'\n});```"}),o.bindElement("#code5",{html:'```html\n<div id="app5">\n <input type="text" lk-state="newTodo" lk-on="keyup:addTodo">\n <ul lk-for="todo in todos">\n <li>\n {{!todo.text}} <button lk-on="click:removeTodo($index)"> x </button>\n </li>\n </ul>\n</div>```',js:"```javascript\nViewModel.createComponent({\n addTodo: function (e) {\n if (e.keyCode !== 13) return;\n if (!this.state.newTodo) return;\n this.state.todos.push({text: this.state.newTodo});\n this.setState({newTodo: ''});\n },\n removeTodo: function (index) {\n this.state.todos.splice(index, 1);\n this.setState();\n }\n}).bindElement('#app5', {\n newTodo: '',\n todos: [{text: 'Add some todos!'}]\n});```"}),o.bindElement("#code6",{html:'```html\n<div class="col width-fill" id="app6">\n <ul lk-for="todo in todos">\n <li>\n {{!todo.title}} <button lk-on="click:removeTodo($index)"> x </button><br>\n <ul lk-for="item in todo.items">\n <li>{{!item}} <button lk-on="click:removeItem($index)"> x </button></li>\n </ul>\n </li>\n </ul>\n</div>```',js:"```javascript\nViewModel.createComponent({\n removeTodo: function (index) {\n this.state.todos.splice(index, 1);\n this.setState();\n },\n removeItem: function (index) {\n this.state.todos.forEach(function (todo) {\n todo.items.forEach( function (item, i) {\n if (index-- === 0)\n todo.items.splice(i, 1);\n });\n });\n this.setState();\n }\n}).bindElement('#app6', {\n todos : [{\n title: 'todo 1',\n items: ['item 1', 'item 2']\n }, {\n title: 'todo 2',\n items: ['item 1', 'item 2']\n }]\n});```"}),o.bindElement("#code7",{html:'```html\n<div class="col width-fill" id="app7">\n <div id="app7-list1">\n <h3>List - {{!title}}</h3>\n <ul lk-for="item in items">\n <li>{{!item}}</li>\n </ul>\n </div>\n <div id="app7-list2">\n <h3>Another List - {{!title}}</h3>\n <ul lk-for="item in items">\n <li>{{!item}}</li>\n </ul>\n </div>\n</div>```',js:"```javascript\nvar List = ViewModel.createComponent({\n $state: {\n title: 'Same Conponent'\n },\n removeItem: function (index) {\n this.state.items.splice(index, 1);\n this.setState();\n }\n});\n\nList.bindElement('#app7-list1', {\n items: ['Learn JavaScript', 'Learn LiKy', 'Build Something Awesome']\n});\n\nList.bindElement('#app7-list2', {\n items: ['item 1', 'item 2', 'item 3']\n});```"}),o.bindElement("#code8",{html:'```html\n\n<div id="app8">\n <form lk-on="submit:submit">\n <div>Input <input name="input" lk-state="input" type="text"></div>\n <div>Textarea <textarea lk-state="textarea" cols="30" rows="10"></textarea>\n </div>\n <div> Radio \n <input type="radio" name="sex" value="male" lk-state="sex.male" /> Male<br>\n <input type="radio" name="sex" value="female" lk-state="sex.female" /> Female \n </div>\n <div>Checkbox <input type="checkbox" value="1" name="bike" lk-state="checkbox"/> I have a bike\n </div>\n <div>Select\n <select name="select" lk-state="select">\n <option disabled selected value> -- select an option -- </option>\n <option value="select1">Volvo</option>\n <option value="select2">Saab</option>\n </select>\n </div>\n <div>Select Option Group\n <select name="optionGroup" lk-state="optionGroup">\n <option disabled selected value> -- select an option -- </option>\n <optgroup label="Swedish Cars">\n <option value="volvo">Volvo</option>\n </optgroup>\n <optgroup label="German Cars">\n <option value="mercedes">Mercedes</option>\n </optgroup>\n </select>\n </div>\n <div><button type="submit">Submit</button></div>\n </form>\n <div>\n <h2>Form Data</h2>\n <p>Input {{!input}}</p>\n <p>Textarea {{!textarea}}</p>\n <p>Radio </p>\n <ul>\n <li>Male {{!maleShow}}</li>\n <li>Female {{!femaleShow}}</li>\n </ul>\n <p>Checkbox {{!checkboxShow}}</p>\n <p>Select {{!select}}</p>\n <p>Select Option Group {{!optionGroup}}</p>\n </div>\n</div>```',js:"```javascript\nViewModel.createComponent({\n submit: function () {\n var map = {\n maleShow: 'sex.male',\n femaleShow: 'sex.female',\n checkboxShow: 'checkbox'\n };\n for (var i in map) this.state[i] = (this.state[map[i]] ? 'true' : 'false');\n this.setState();\n return false;\n }\n}).bindElement('#app8');```"}),i.createComponent({onInitialRendered:function(){this.setState({introPreview:s(this.state.intro)})}}).bindElement("#intro",{intro:"[LiKy](https://github.com/kyleslight/LiKy) is a Javascript MVVM Library to help web developers building user interface. It is a project created by [Kyles Light](https://github.com/kyleslight) for learning and personal use. In fact the page you view is driven by little LiKy ( by the way, thanks for the help of framework [Cascade](http://jslegers.github.io/cascadeframeworklight/) ).\n\nLiKy is inspired by a series of awesome librarys such as [React](https://facebook.github.io/react/) , [Vue](https://vuejs.org/) and [Spine](http://spinejs.com/), it contains a few ideas to make web development more simple and efficient :\n\n- **Component**. The component holds the common methods and data shared by all LiKy instances created by it, it also supports inheritance. So you can divide your application into segments and give the each segment more reusability with the help of component.\n- **Element and State**. You create a LiKy instance by binding it with a element name ( using CSS selector syntax ) and initial state object ( optional ). So the element will be rendered with the state. You can also trigger event and generate structure ( and other staffs ) by adding attributes to the element.\n\nAnd that's it! \n\nHere are some demos created with LiKy so you can have a more clear concept about how to develop with it.\n\n"})},function(e,t,n){(function(t){(function(){var t=function(e){var t=function(){e&&e.prototype.init&&(this.superInit=e.prototype.init),this.init.apply(this,arguments)};if(e){var n=function(){};n.prototype=e.prototype,t.prototype=new n}return t.fn=t.prototype,t.fn.init=function(){},t.fn.parent=t,t.fn._super=t.__proto__,t.proxy=function(e){var t=this;return function(){return e.apply(t,arguments)}},t.fn.proxy=t.proxy,t.include=function(e){var n=e.included;for(var i in e)t.fn[i]=e[i];n&&n(t)},t.extend=function(e){var n=e.extended;for(var i in e)t[i]=e[i];n&&n(t)},t},n=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0,n="x"==e?t:3&t|8;return n.toString(16)})};"function"!=typeof Object.create&&(Object.create=function(e){var t=function(){};return t.prototype=e,new t});var i={localCreate:function(){console.log("localCreate",this.state)},localRead:function(){console.log("localRead",this.state)},localUpdate:function(){console.log("localUpdate",this.state)},localDelete:function(){console.log("localDelete",this.state)},remoteCreate:function(){console.log("remoteCreate",this.state)},remoteRead:function(e,t){var n=this;if(!this.$remoteUrl)return void console.error("No $remoteUrl, please set it in component");if("function"!=typeof e)return void console.error("The first argument must be a function");t="object"==typeof t?this._serialize(t):"";var i=new XMLHttpRequest;i.onreadystatechange=function(){4===i.readyState&&(200===i.status?e.call(n,JSON.parse(i.responseText)):console.warn("Request failed, status: %d",i.status))},i.open("GET",this.$remoteUrl+"?"+t,!0),i.send()},remoteUpdate:function(){console.log("remoteUpdate",this.state)},remoteDelete:function(){console.log("remoteDelete",this.state)},_serialize:function(e,t){var n=[];for(var i in e)if(e.hasOwnProperty(i)){var s=t?t+"["+i+"]":i,r=e[i];n.push("object"==typeof r?serialize(r,s):encodeURIComponent(s)+"="+encodeURIComponent(r))}return n.join("&")},_updateState:function(e){for(var t in e)this.state[t]=e[t]}},s=new t;s.extend({createInstance:function(){var e=Object.create(this.prototype);return e.parent=this,e.createSelf.apply(e),e.initialState.apply(e,arguments),e},createClass:function(e){var t=Object.create(this);return t._records={},t.parent=this,t.fn=t.prototype=Object.create(this.prototype),t.include(e||{}),this.onCreated.apply(this),this.onInherited.call(this,t),t},addClassStatic:function(e){for(var t in e)this[t]=e[t]},getRecord:function(e){return this._records[e]},onInherited:function(){},onCreated:function(){},onRecordCreated:function(){},onRecordChanged:function(){},onRecordDestroyed:function(){}}),s.include({init:function(){},createSelf:function(){this._id||(this._id=n()),this.parent._records[this._id]=this,this.proxy(this.onCreated(this)),this.parent.onRecordCreated(this),this.state={}},initialState:function(e){return"object"!=typeof e?void console.warn("Parameter of createInstance should be an object."):(this.state=JSON.parse(JSON.stringify(e)),this.proxy(this.onStateCreated(this)),void this.proxy(this._onStateCreated(this)))},getState:function(e){return this.state[e]?this.state[e]:(console.warn("State attribute %s is not available.",e),null)},setState:function(e){if(e=e||{},"object"!=typeof e)return void console.error("Parameter of setState should be an object.");var t={};t.state={};for(var n in e)t.state[n]=this.state[n],this.state[n]=e[n];this.$dirty=!0,e&&this.parent.onRecordChanged(this,t,e),this.proxy(this.onStateChanged(this,t,e)),this.proxy(this._onStateChanged(this,t,e)),this.$dirty=!1},destroy:function(){this.proxy(this.onStateDestroyed(this)),this.proxy(this._onStateDestroyed(this)),this.onDestroyed.apply(this),this.parent.onRecordDestroyed(this),delete this.parent._records[this._id]},onCreated:function(){},onStateCreated:function(){},_onStateCreated:function(){},onStateChanged:function(){},_onStateChanged:function(){},onStateDestroyed:function(){},onDestroyed:function(){}});var r=function(e,t){var n={};t=t||"";var i=e+" "+t;return n._el=document.querySelectorAll(i),n.each=function(e){if("function"!=typeof e)return n;for(var t=0;t<this._el.length;t++)e.apply(this._el[t]);return n},n.html=function(e){var t=this;return e?(t.each(function(){this.innerHTML=e}),n):t._el[0].innerHTML},n.delegate=function(e,t,i){var s=this,r=t.split(" "),o=s._el[0];return r.forEach(function(t){o.addEventListener(t,function(t){for(var n=t.target,s=o.querySelectorAll(e),r=0;r<s.length;r++){var a=s[r];if(n===a)return i.call(a,event)}},!1)}),n},n},o=function(e,t){e=e.split("\n").map(function(e){return e.trim()}).join("").replace(/[\t\n\r]/g,"");var n,i,s=[],r=[],o=0,a=new RegExp("<([^>]*?) [^>]*lk-"+t+"=['\"]([^'\"]*)['\"][^>]*>"),l=function(e){e=e||"";var t=e.match(a),n=t?t[1]:"";i=new RegExp("<"+n+"|</"+n+">","g")},h=e;l(h),n=i.exec(h);var c=n?n.index:0;for(s.push(h.slice(0,c)),h=h.slice(c),l(h);n=i.exec(h);){var p=n[0];/<\/.*/.test(p)?r.pop():r.push(p),r.length||(s.push(h.slice(o,o=n.index+p.length)),h=h.slice(o),o=0,l(h))}return s.push(h),s},a=function(e,t){e=e.split("\n").map(function(e){return e.trim()}).join("").replace(/[\t\n\r]/g,"").replace(/"/g,"'");var n=/<(\S*?) [^>]*lk-if='([^\']*)'[^>]*>(.*)<\/\1>/g,i=/<(\S*?) [^>]*lk-not='([^\']*)'[^>]*>(.*)<\/\1>/g,s=/<(\S*?) [^>]*lk-for='([^\']*)'[^>]*>(.*)<\/\1>/g,r=/\{\{\{([^!][^\}\}\}]+)?\}\}\}/g,a=/\{\{([^!][^\}\}]+)?\}\}(?=[^}])/g,l=function(e){var s={"if":n,not:i},r="",a=function(e){return e.replace(s[r],function(e,n,i){return i="this."+i.replace(/\{|\}/g,""),"if"===r&&new Function("return "+i).apply(t)===!1?"":"not"===r&&new Function("return "+i).apply(t)!==!1?"":e})};return e=o(e,r="if").map(a).join(""),e=o(e,r="not").map(a).join("")},h=function(e,t){var n=o(e,"for");return n.map(function(e){return e?e.replace(s,function(e,n,i,r){var o=i.split(" "),a=o[0],l=o[2],c=r,p="this."+l;return t++,s.test(r)&&(c=h(r,t)),e.replace(r,function(){var e=c.replace(new RegExp("{{ *("+a+")([^}]*) *}}","g"),function(e,n,i){return"{{"+l+"[i"+t+"]"+i+"}}"});return e=e.replace(new RegExp("this.("+a+")(.*).length","g"),function(e,n,i){return"this."+l+"[i"+t+"]"+i+".length"}),'");\nfor(var i'+t+" = 0; i"+t+" < "+p+".length; i"+t+'++) {\n s.push("'+e+'");\n}\ns.push("'})}):""}).join("")},c=function(e){return e.replace(a,function(e,t){return t?'" + handleValue(get(this, "'+t.trim()+'"), "'+e+'") + "':e})},p=function(e){return e.replace(r,function(e,t){return t?'" + handleHTML(get(this, "'+t.trim()+'"), "'+e+'") + "':e})},u='var get = function(obj, key) {return key.split(".").reduce(function(o, x) {var re = new RegExp("([^[]+)([^ ]*)"); var ox = x.match(re); var x = ox[1]; var suf = ox[2]; return (typeof o == "undefined" || o === null) ? o : eval("o[x]" + suf);}, obj);}; var handleValue = function(value, m) {if (value) {return value.replace(/>/g, ">").replace(/</g, "<");} return m;}; var handleHTML = function(value, m) {if (value) {return value;} return m;}; var s = [];',d='return s.join("").replace(/{{([^!][^}}]+)?}}(?=[^}])|{{{([^!][^}}}]+)?}}}/g, "").replace(/{{!/g, "{{")';return body=l(e),body='s.push("'+h(body,-1)+'");',body=c(body),body=p(body),body=u+body+d,new Function(body.replace(/[\t\n\r]/g,"")).apply(t).replace(/'/g,'"')};a.tagPair=o;var l=s.createClass({_preElInner:function(){var e=this;this._selectInScope("[lk-on]").each(function(){var t=this.getAttribute("lk-on"),i=t.replace(/ /g,"").split(";").map(function(e){return e.split(":")}),s=n();this.classList.add("le-"+s),e._eventMap[s]={ems:i,elClass:".le-"+s}}),this._elInner=this._el.html().replace(/^ +/gm,"").replace(/\n/gm,"").trim(),this._elInner=a.tagPair(e._elInner,"for").map(function(t){if(!/lk-for/.test(t))return t;var i=n(),s='<span class="cs-'+i+'">'+t+"</span>";return e._controlMap[i]=s,s}).join(""),this._elInner=this._elInner.replace(/\{{2}([^\{\}]*)\}{2}(?=[^\}])|{{2}([^}]*)\}{2}$|\{{3}([^\{\}]*)\}{3}(?=[^\}])|{{3}([^}]*)\}{3}$/g,function(t){var i=n(),s='<span class="lm-'+i+'">'+t+"</span>";return e._stateElMap[i]=s,s}),e._el.delegate("[lk-state]","change paste input",function(){var t=this.getAttribute("lk-state"),n=this.value;"checkbox"===this.type&&(n=this.checked),"radio"===this.type&&(n=this.checked,e._selectInScope("input[name="+this.name+"][lk-state]:radio").each(function(){var t=this.getAttribute("lk-state");e.state[t]=!n})),e.state[t]=n,e.$reactive&&e._renderPassivity()})},_render:function(e){var t=this;if(this.$state=this.$state||{},e)t._renderPassivity();else{for(var n in this.state)this.$state[n]=this.state[n];var i=a(this._elInner,this.$state);this._el.html(i),this.onInitialRendered()}this._selectInScope("[lk-state]").each(function(){var n=this.getAttribute("lk-state");"undefined"!=typeof t.state[n]&&("checkbox"===this.type||"radio"===this.type?this.checked=t.state[n]:"INPUT"!==this.tagName&&(this.value=t.state[n]),e&&void 0!==e[n]&&(this.value=e[n]))})},_delegateEvents:function(){var e=this;for(var t in this._eventMap){var n=this._eventMap[t].elClass,i=this._eventMap[t].ems;i.forEach(function(t){var i=t[0],s=t[1],r=/(.*\(\$index\).*)/g,o=s.replace("($index)","");return e[o]?void(r.test(s)?e._el.delegate(n,i,function(t){var n=t.target.className,i=[].indexOf.call(document.querySelectorAll("."+n),t.target);e.proxy(e[o].call(e,i))}):e._el.delegate(n,i,e.proxy(e[o]))):void console.error("Can not solve %s, create it in createClass of ViewModel",o)})}},_renderPassivity:function(){for(var e in this.state)this.$state[e]=this.state[e];for(var e in this._stateElMap){var t=a(this._stateElMap[e],this.$state);this._selectInScope(".lm-"+e).html(t)}for(var e in this._controlMap){var t=a(this._controlMap[e],this.$state);t=t.match(/<([^ ]+)[^\>]*>((.|\n)*)<\/\1>/)[2]||"",this._selectInScope(".cs-"+e).html(t)}},_onStateChanged:function(){this._render(arguments[2])},_selectInScope:function(e){return r(this.$el,e)},onInitialRendered:function(){}});l.addClassStatic({createComponent:function(e){var t=this.createClass();for(var n in e)t.prototype[n]=e[n];return t},bindElement:function(e,t){var n=this.createInstance(t||{});return n.$el=e,n._el=r(e),n._elInner=n._el.html(),n._eventMap={},n._stateElMap={},n._controlMap={},n._elStateMap={},n._preElInner(),n._render(),n._delegateEvents(),n}}),l.addClassStatic(i);var h=l;e.exports=h}).call(function(){return this||("undefined"!=typeof window?window:t)}())}).call(t,function(){return this}())},function(e,t,n){(function(t){(function(){function t(e){this.tokens=[],this.tokens.links={},this.options=e||c.defaults,this.rules=p.normal,this.options.gfm&&(this.options.tables?this.rules=p.tables:this.rules=p.gfm)}function n(e,t){if(this.options=t||c.defaults,this.links=e,this.rules=u.normal,this.renderer=this.options.renderer||new i,this.renderer.options=this.options,!this.links)throw new Error("Tokens array requires a `links` property.");this.options.gfm?this.options.breaks?this.rules=u.breaks:this.rules=u.gfm:this.options.pedantic&&(this.rules=u.pedantic)}function i(e){this.options=e||{}}function s(e){this.tokens=[],this.token=null,this.options=e||c.defaults,this.options.renderer=this.options.renderer||new i,this.renderer=this.options.renderer,this.renderer.options=this.options}function r(e,t){return e.replace(t?/&/g:/&(?!#?\w+;)/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function o(e){return e.replace(/&([#\w]+);/g,function(e,t){return t=t.toLowerCase(),"colon"===t?":":"#"===t.charAt(0)?"x"===t.charAt(1)?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""})}function a(e,t){return e=e.source,t=t||"",function n(i,s){return i?(s=s.source||s,s=s.replace(/(^|[^\[])\^/g,"$1"),e=e.replace(i,s),n):new RegExp(e,t)}}function l(){}function h(e){for(var t,n,i=1;i<arguments.length;i++){t=arguments[i];for(n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}function c(e,n,i){if(i||"function"==typeof n){i||(i=n,n=null),n=h({},c.defaults,n||{});var o,a,l=n.highlight,p=0;try{o=t.lex(e,n)}catch(u){return i(u)}a=o.length;var d=function(e){if(e)return n.highlight=l,i(e);var t;try{t=s.parse(o,n)}catch(r){e=r}return n.highlight=l,e?i(e):i(null,t)};if(!l||l.length<3)return d();if(delete n.highlight,!a)return d();for(;p<o.length;p++)!function(e){return"code"!==e.type?--a||d():l(e.text,e.lang,function(t,n){return t?d(t):null==n||n===e.text?--a||d():(e.text=n,e.escaped=!0,void(--a||d()))})}(o[p])}else try{return n&&(n=h({},c.defaults,n)),s.parse(t.lex(e,n),n)}catch(u){if(u.message+="\nPlease report this to https://github.com/chjj/marked.",(n||c.defaults).silent)return"<p>An error occured:</p><pre>"+r(u.message+"",!0)+"</pre>";throw u}}var p={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:l,hr:/^( *[-*_]){3,} *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,nptable:l,lheading:/^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,blockquote:/^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,list:/^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:/^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,table:l,paragraph:/^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,text:/^[^\n]+/};p.bullet=/(?:[*+-]|\d+\.)/,p.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/,p.item=a(p.item,"gm")(/bull/g,p.bullet)(),p.list=a(p.list)(/bull/g,p.bullet)("hr","\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))")("def","\\n+(?="+p.def.source+")")(),p.blockquote=a(p.blockquote)("def",p.def)(),p._tag="(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b",p.html=a(p.html)("comment",/<!--[\s\S]*?-->/)("closed",/<(tag)[\s\S]+?<\/\1>/)("closing",/<tag(?:"[^"]*"|'[^']*'|[^'">])*?>/)(/tag/g,p._tag)(),p.paragraph=a(p.paragraph)("hr",p.hr)("heading",p.heading)("lheading",p.lheading)("blockquote",p.blockquote)("tag","<"+p._tag)("def",p.def)(),p.normal=h({},p),p.gfm=h({},p.normal,{fences:/^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]*?)\s*\1 *(?:\n+|$)/,paragraph:/^/,heading:/^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/}),p.gfm.paragraph=a(p.paragraph)("(?!","(?!"+p.gfm.fences.source.replace("\\1","\\2")+"|"+p.list.source.replace("\\1","\\3")+"|")(),p.tables=h({},p.gfm,{nptable:/^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,table:/^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/}),t.rules=p,t.lex=function(e,n){var i=new t(n);return i.lex(e)},t.prototype.lex=function(e){return e=e.replace(/\r\n|\r/g,"\n").replace(/\t/g," ").replace(/\u00a0/g," ").replace(/\u2424/g,"\n"),this.token(e,!0)},t.prototype.token=function(e,t,n){for(var i,s,r,o,a,l,h,c,u,e=e.replace(/^ +$/gm,"");e;)if((r=this.rules.newline.exec(e))&&(e=e.substring(r[0].length),r[0].length>1&&this.tokens.push({type:"space"})),r=this.rules.code.exec(e))e=e.substring(r[0].length),r=r[0].replace(/^ {4}/gm,""),this.tokens.push({type:"code",text:this.options.pedantic?r:r.replace(/\n+$/,"")});else if(r=this.rules.fences.exec(e))e=e.substring(r[0].length),this.tokens.push({type:"code",lang:r[2],text:r[3]||""});else if(r=this.rules.heading.exec(e))e=e.substring(r[0].length),this.tokens.push({type:"heading",depth:r[1].length,text:r[2]});else if(t&&(r=this.rules.nptable.exec(e))){for(e=e.substring(r[0].length),l={type:"table",header:r[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:r[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:r[3].replace(/\n$/,"").split("\n")},c=0;c<l.align.length;c++)/^ *-+: *$/.test(l.align[c])?l.align[c]="right":/^ *:-+: *$/.test(l.align[c])?l.align[c]="center":/^ *:-+ *$/.test(l.align[c])?l.align[c]="left":l.align[c]=null;for(c=0;c<l.cells.length;c++)l.cells[c]=l.cells[c].split(/ *\| */);this.tokens.push(l)}else if(r=this.rules.lheading.exec(e))e=e.substring(r[0].length),this.tokens.push({type:"heading",depth:"="===r[2]?1:2,text:r[1]});else if(r=this.rules.hr.exec(e))e=e.substring(r[0].length),this.tokens.push({type:"hr"});else if(r=this.rules.blockquote.exec(e))e=e.substring(r[0].length),this.tokens.push({type:"blockquote_start"}),r=r[0].replace(/^ *> ?/gm,""),this.token(r,t,!0),this.tokens.push({type:"blockquote_end"});else if(r=this.rules.list.exec(e)){for(e=e.substring(r[0].length),o=r[2],this.tokens.push({type:"list_start",ordered:o.length>1}),r=r[0].match(this.rules.item),i=!1,u=r.length,c=0;u>c;c++)l=r[c],h=l.length,l=l.replace(/^ *([*+-]|\d+\.) +/,""),~l.indexOf("\n ")&&(h-=l.length,l=this.options.pedantic?l.replace(/^ {1,4}/gm,""):l.replace(new RegExp("^ {1,"+h+"}","gm"),"")),this.options.smartLists&&c!==u-1&&(a=p.bullet.exec(r[c+1])[0],o===a||o.length>1&&a.length>1||(e=r.slice(c+1).join("\n")+e,c=u-1)),s=i||/\n\n(?!\s*$)/.test(l),c!==u-1&&(i="\n"===l.charAt(l.length-1),s||(s=i)),this.tokens.push({type:s?"loose_item_start":"list_item_start"}),this.token(l,!1,n),this.tokens.push({type:"list_item_end"});this.tokens.push({type:"list_end"})}else if(r=this.rules.html.exec(e))e=e.substring(r[0].length),this.tokens.push({type:this.options.sanitize?"paragraph":"html",pre:!this.options.sanitizer&&("pre"===r[1]||"script"===r[1]||"style"===r[1]),text:r[0]});else if(!n&&t&&(r=this.rules.def.exec(e)))e=e.substring(r[0].length),this.tokens.links[r[1].toLowerCase()]={href:r[2],title:r[3]};else if(t&&(r=this.rules.table.exec(e))){for(e=e.substring(r[0].length),l={type:"table",header:r[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:r[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:r[3].replace(/(?: *\| *)?\n$/,"").split("\n")},c=0;c<l.align.length;c++)/^ *-+: *$/.test(l.align[c])?l.align[c]="right":/^ *:-+: *$/.test(l.align[c])?l.align[c]="center":/^ *:-+ *$/.test(l.align[c])?l.align[c]="left":l.align[c]=null;for(c=0;c<l.cells.length;c++)l.cells[c]=l.cells[c].replace(/^ *\| *| *\| *$/g,"").split(/ *\| */);this.tokens.push(l)}else if(t&&(r=this.rules.paragraph.exec(e)))e=e.substring(r[0].length),this.tokens.push({type:"paragraph",text:"\n"===r[1].charAt(r[1].length-1)?r[1].slice(0,-1):r[1]});else if(r=this.rules.text.exec(e))e=e.substring(r[0].length),this.tokens.push({type:"text",text:r[0]});else if(e)throw new Error("Infinite loop on byte: "+e.charCodeAt(0));return this.tokens};var u={escape:/^\\([\\`*{}\[\]()#+\-.!_>])/,autolink:/^<([^ >]+(@|:\/)[^ >]+)>/,url:l,tag:/^<!--[\s\S]*?-->|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,link:/^!?\[(inside)\]\(href\)/,reflink:/^!?\[(inside)\]\s*\[([^\]]*)\]/,nolink:/^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,strong:/^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,em:/^\b_((?:[^_]|__)+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,code:/^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,br:/^ {2,}\n(?!\s*$)/,del:l,text:/^[\s\S]+?(?=[\\<!\[_*`]| {2,}\n|$)/};u._inside=/(?:\[[^\]]*\]|[^\[\]]|\](?=[^\[]*\]))*/,u._href=/\s*<?([\s\S]*?)>?(?:\s+['"]([\s\S]*?)['"])?\s*/,u.link=a(u.link)("inside",u._inside)("href",u._href)(),u.reflink=a(u.reflink)("inside",u._inside)(),u.normal=h({},u),u.pedantic=h({},u.normal,{strong:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,em:/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/}),u.gfm=h({},u.normal,{escape:a(u.escape)("])","~|])")(),url:/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,del:/^~~(?=\S)([\s\S]*?\S)~~/,text:a(u.text)("]|","~]|")("|","|https?://|")()}),u.breaks=h({},u.gfm,{br:a(u.br)("{2,}","*")(),text:a(u.gfm.text)("{2,}","*")()}),n.rules=u,n.output=function(e,t,i){var s=new n(t,i);return s.output(e)},n.prototype.output=function(e){for(var t,n,i,s,o="";e;)if(s=this.rules.escape.exec(e))e=e.substring(s[0].length),o+=s[1];else if(s=this.rules.autolink.exec(e))e=e.substring(s[0].length),"@"===s[2]?(n=":"===s[1].charAt(6)?this.mangle(s[1].substring(7)):this.mangle(s[1]),i=this.mangle("mailto:")+n):(n=r(s[1]),i=n),o+=this.renderer.link(i,null,n);else if(this.inLink||!(s=this.rules.url.exec(e))){if(s=this.rules.tag.exec(e))!this.inLink&&/^<a /i.test(s[0])?this.inLink=!0:this.inLink&&/^<\/a>/i.test(s[0])&&(this.inLink=!1),e=e.substring(s[0].length),o+=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(s[0]):r(s[0]):s[0];else if(s=this.rules.link.exec(e))e=e.substring(s[0].length),this.inLink=!0,o+=this.outputLink(s,{href:s[2],title:s[3]}),this.inLink=!1;else if((s=this.rules.reflink.exec(e))||(s=this.rules.nolink.exec(e))){if(e=e.substring(s[0].length),t=(s[2]||s[1]).replace(/\s+/g," "),t=this.links[t.toLowerCase()],!t||!t.href){o+=s[0].charAt(0),e=s[0].substring(1)+e;continue}this.inLink=!0,o+=this.outputLink(s,t),this.inLink=!1}else if(s=this.rules.strong.exec(e))e=e.substring(s[0].length),o+=this.renderer.strong(this.output(s[2]||s[1]));else if(s=this.rules.em.exec(e))e=e.substring(s[0].length),o+=this.renderer.em(this.output(s[2]||s[1]));else if(s=this.rules.code.exec(e))e=e.substring(s[0].length),o+=this.renderer.codespan(r(s[2],!0));else if(s=this.rules.br.exec(e))e=e.substring(s[0].length),o+=this.renderer.br();else if(s=this.rules.del.exec(e))e=e.substring(s[0].length),o+=this.renderer.del(this.output(s[1]));else if(s=this.rules.text.exec(e))e=e.substring(s[0].length),o+=this.renderer.text(r(this.smartypants(s[0])));else if(e)throw new Error("Infinite loop on byte: "+e.charCodeAt(0))}else e=e.substring(s[0].length),n=r(s[1]),i=n,o+=this.renderer.link(i,null,n);return o},n.prototype.outputLink=function(e,t){var n=r(t.href),i=t.title?r(t.title):null;return"!"!==e[0].charAt(0)?this.renderer.link(n,i,this.output(e[1])):this.renderer.image(n,i,r(e[1]))},n.prototype.smartypants=function(e){return this.options.smartypants?e.replace(/---/g,"—").replace(/--/g,"–").replace(/(^|[-\u2014\/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014\/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…"):e},n.prototype.mangle=function(e){if(!this.options.mangle)return e;for(var t,n="",i=e.length,s=0;i>s;s++)t=e.charCodeAt(s),Math.random()>.5&&(t="x"+t.toString(16)),n+="&#"+t+";";return n},i.prototype.code=function(e,t,n){if(this.options.highlight){var i=this.options.highlight(e,t);null!=i&&i!==e&&(n=!0,
e=i)}return t?'<pre><code class="'+this.options.langPrefix+r(t,!0)+'">'+(n?e:r(e,!0))+"\n</code></pre>\n":"<pre><code>"+(n?e:r(e,!0))+"\n</code></pre>"},i.prototype.blockquote=function(e){return"<blockquote>\n"+e+"</blockquote>\n"},i.prototype.html=function(e){return e},i.prototype.heading=function(e,t,n){return"<h"+t+' id="'+this.options.headerPrefix+n.toLowerCase().replace(/[^\w]+/g,"-")+'">'+e+"</h"+t+">\n"},i.prototype.hr=function(){return this.options.xhtml?"<hr/>\n":"<hr>\n"},i.prototype.list=function(e,t){var n=t?"ol":"ul";return"<"+n+">\n"+e+"</"+n+">\n"},i.prototype.listitem=function(e){return"<li>"+e+"</li>\n"},i.prototype.paragraph=function(e){return"<p>"+e+"</p>\n"},i.prototype.table=function(e,t){return"<table>\n<thead>\n"+e+"</thead>\n<tbody>\n"+t+"</tbody>\n</table>\n"},i.prototype.tablerow=function(e){return"<tr>\n"+e+"</tr>\n"},i.prototype.tablecell=function(e,t){var n=t.header?"th":"td",i=t.align?"<"+n+' style="text-align:'+t.align+'">':"<"+n+">";return i+e+"</"+n+">\n"},i.prototype.strong=function(e){return"<strong>"+e+"</strong>"},i.prototype.em=function(e){return"<em>"+e+"</em>"},i.prototype.codespan=function(e){return"<code>"+e+"</code>"},i.prototype.br=function(){return this.options.xhtml?"<br/>":"<br>"},i.prototype.del=function(e){return"<del>"+e+"</del>"},i.prototype.link=function(e,t,n){if(this.options.sanitize){try{var i=decodeURIComponent(o(e)).replace(/[^\w:]/g,"").toLowerCase()}catch(s){return""}if(0===i.indexOf("javascript:")||0===i.indexOf("vbscript:"))return""}var r='<a href="'+e+'"';return t&&(r+=' title="'+t+'"'),r+=">"+n+"</a>"},i.prototype.image=function(e,t,n){var i='<img src="'+e+'" alt="'+n+'"';return t&&(i+=' title="'+t+'"'),i+=this.options.xhtml?"/>":">"},i.prototype.text=function(e){return e},s.parse=function(e,t,n){var i=new s(t,n);return i.parse(e)},s.prototype.parse=function(e){this.inline=new n(e.links,this.options,this.renderer),this.tokens=e.reverse();for(var t="";this.next();)t+=this.tok();return t},s.prototype.next=function(){return this.token=this.tokens.pop()},s.prototype.peek=function(){return this.tokens[this.tokens.length-1]||0},s.prototype.parseText=function(){for(var e=this.token.text;"text"===this.peek().type;)e+="\n"+this.next().text;return this.inline.output(e)},s.prototype.tok=function(){switch(this.token.type){case"space":return"";case"hr":return this.renderer.hr();case"heading":return this.renderer.heading(this.inline.output(this.token.text),this.token.depth,this.token.text);case"code":return this.renderer.code(this.token.text,this.token.lang,this.token.escaped);case"table":var e,t,n,i,s,r="",o="";for(n="",e=0;e<this.token.header.length;e++)i={header:!0,align:this.token.align[e]},n+=this.renderer.tablecell(this.inline.output(this.token.header[e]),{header:!0,align:this.token.align[e]});for(r+=this.renderer.tablerow(n),e=0;e<this.token.cells.length;e++){for(t=this.token.cells[e],n="",s=0;s<t.length;s++)n+=this.renderer.tablecell(this.inline.output(t[s]),{header:!1,align:this.token.align[s]});o+=this.renderer.tablerow(n)}return this.renderer.table(r,o);case"blockquote_start":for(var o="";"blockquote_end"!==this.next().type;)o+=this.tok();return this.renderer.blockquote(o);case"list_start":for(var o="",a=this.token.ordered;"list_end"!==this.next().type;)o+=this.tok();return this.renderer.list(o,a);case"list_item_start":for(var o="";"list_item_end"!==this.next().type;)o+="text"===this.token.type?this.parseText():this.tok();return this.renderer.listitem(o);case"loose_item_start":for(var o="";"list_item_end"!==this.next().type;)o+=this.tok();return this.renderer.listitem(o);case"html":var l=this.token.pre||this.options.pedantic?this.token.text:this.inline.output(this.token.text);return this.renderer.html(l);case"paragraph":return this.renderer.paragraph(this.inline.output(this.token.text));case"text":return this.renderer.paragraph(this.parseText())}},l.exec=l,c.options=c.setOptions=function(e){return h(c.defaults,e),c},c.defaults={gfm:!0,tables:!0,breaks:!1,pedantic:!1,sanitize:!1,sanitizer:null,mangle:!0,smartLists:!1,silent:!1,highlight:null,langPrefix:"lang-",smartypants:!1,headerPrefix:"",renderer:new i,xhtml:!1},c.Parser=s,c.parser=s.parse,c.Renderer=i,c.Lexer=t,c.lexer=t.lex,c.InlineLexer=n,c.inlineLexer=n.output,c.parse=c,e.exports=c}).call(function(){return this||("undefined"!=typeof window?window:t)}())}).call(t,function(){return this}())},function(e,t){var n={localCreate:function(){console.log("localCreate",this.state)},localRead:function(){console.log("localRead",this.state)},localUpdate:function(){console.log("localUpdate",this.state)},localDelete:function(){console.log("localDelete",this.state)},remoteCreate:function(){console.log("remoteCreate",this.state)},remoteRead:function(e,t){var n=this;if(!this.$remoteUrl)return void console.error("No $remoteUrl, please set it in component");if("function"!=typeof e)return void console.error("The first argument must be a function");t="object"==typeof t?this._serialize(t):"";var i=new XMLHttpRequest;i.onreadystatechange=function(){4===i.readyState&&(200===i.status?e.call(n,JSON.parse(i.responseText)):console.warn("Request failed, status: %d",i.status))},i.open("GET",this.$remoteUrl+"?"+t,!0),i.send()},remoteUpdate:function(){console.log("remoteUpdate",this.state)},remoteDelete:function(){console.log("remoteDelete",this.state)},_serialize:function(e,t){var n=[];for(var i in e)if(e.hasOwnProperty(i)){var s=t?t+"["+i+"]":i,r=e[i];n.push("object"==typeof r?serialize(r,s):encodeURIComponent(s)+"="+encodeURIComponent(r))}return n.join("&")},_updateState:function(e){for(var t in e)this.state[t]=e[t]}};e.exports=n},function(e,t){}]);