forked from withanage/UBHD-OMPPortal
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlens2.js
executable file
·1 lines (1 loc) · 235 KB
/
lens2.js
1
!function o(s,a,c){function u(e,t){if(!a[e]){if(!s[e]){var n="function"==typeof require&&require;if(!t&&n)return n(e,!0);if(l)return l(e,!0);var r=new Error("Cannot find module '"+e+"'");throw r.code="MODULE_NOT_FOUND",r}var i=a[e]={exports:{}};s[e][0].call(i.exports,function(t){return u(s[e][1][t]||t)},i,i.exports,o,s,a,c)}return a[e].exports}for(var l="function"==typeof require&&require,t=0;t<c.length;t++)u(c[t]);return u}({1:[function(t,e,n){window.Lens=t("./src/ubhd-lens")},{"./src/ubhd-lens":205}],2:[function(t,e,n){},{}],3:[function(t,e,n){"use strict";var a=t("underscore"),r=t("../substance/util"),i=t("../substance/document"),c=function(t){t=c.prepareOptions(t),i.call(this,t),this.bySourceId=this.addIndex("by_source_id",{property:"source_id"}),this.nodeTypes=t.nodeTypes,void 0===t.seed&&(this.create({id:"document",type:"document",guid:t.id,creator:t.creator,created_at:t.created_at,views:c.views,title:"",abstract:"",authors:[]}),a.each(c.views,function(t){this.create({id:t,type:"view",nodes:[]})},this))};c.Prototype=function(){this.fromSnapshot=function(t,e){return c.fromSnapshot(t,e)},this.getNodeBySourceId=function(t){var e=this.bySourceId.get(t);return e[Object.keys(e)[0]]},this.getHeadings=function(){return a.filter(this.get("content").getNodes(),function(t){return"heading"===t.type})},this.getTocNodes=function(){return a.filter(this.get("content").getNodes(),function(t){return t.includeInToc()})}},c.prepareOptions=function(t){return(t=t||{}).nodeTypes=a.extend(c.nodeTypes,t.nodeTypes),t.schema=c.getSchema(t.nodeTypes),t},c.getSchema=function(t){var n=r.deepclone(i.schema);return n.id="lens-article",n.version="2.0.0",a.each(t,function(t,e){n.types[e]=t.Model.type}),n},c.fromSnapshot=function(t,e){return(e=e||{}).seed=t,new c(e)},c.views=["content","figures","footnotes","citations","definitions","info"],c.nodeTypes=t("./nodes"),c.ViewFactory=t("./view_factory"),c.ResourceView=t("./resource_view");var u={id:"lens_article",nodes:{document:{type:"document",id:"document",views:["content"],title:"The Anatomy of a Lens Article",authors:["contributor_1","contributor_2","contributor_3"],guid:"lens_article"},content:{type:"view",id:"content",nodes:["cover"]},cover:{id:"cover",type:"cover"},contributor_1:{id:"contributor_1",type:"contributor",name:"Michael Aufreiter"},contributor_2:{id:"contributor_2",type:"contributor",name:"Ivan Grubisic"},contributor_3:{id:"contributor_3",type:"contributor",name:"Rebecca Close"}}};c.describe=function(){var o=new c({seed:u}),s=0;return a.each(c.nodeTypes,function(t){var e="heading_"+(t=t.Model).type.id;o.create({id:e,type:"heading",content:t.description.name,level:1});var n=t.description.remarks.join(" "),r="text_"+t.type.id+"_intro";o.create({id:r,type:"text",content:n}),o.show("content",[e,r],-1),o.create({id:e+"_properties",type:"text",content:t.description.name+" uses the following properties:"}),o.show("content",[e+"_properties"],-1);var i=[];a.each(t.description.properties,function(t,e){var n="text_"+ ++s;o.create({id:n,type:"text",content:e+": "+t}),o.create({id:s+"_annotation",type:"code",path:[n,"content"],range:[0,e.length]}),i.push(n)}),o.create({id:e+"_property_list",type:"list",items:i,ordered:!1}),o.show("content",[e+"_property_list"],-1),o.create({id:e+"_example",type:"text",content:"Here's an example:"}),o.create({id:e+"_example_codeblock",type:"codeblock",content:JSON.stringify(t.example,null," ")}),o.show("content",[e+"_example",e+"_example_codeblock"],-1)}),o},c.Prototype.prototype=i.prototype,c.prototype=new c.Prototype,c.prototype.constructor=c,Object.defineProperties(c.prototype,{id:{get:function(){return this.get("document").guid},set:function(t){this.get("document").guid=t}},creator:{get:function(){return this.get("document").creator},set:function(t){this.get("document").creator=t}},created_at:{get:function(){return this.get("document").created_at},set:function(t){this.get("document").created_at=t}},title:{get:function(){return this.get("document").title},set:function(t){this.get("document").title=t}},abstract:{get:function(){return this.get("document").abstract},set:function(t){this.get("document").abstract=t}},on_behalf_of:{get:function(){return this.get("document").on_behalf_of},set:function(t){this.get("document").on_behalf_of=t}},authors:{get:function(){var t=this.get("document");return t.authors?a.map(t.authors,function(t){return this.get(t)},this):""},set:function(t){this.get("document").authors=a.clone(t)}},views:{get:function(){return this.get("document").views.slice(0)}}}),e.exports=c},{"../substance/document":174,"../substance/util":183,"./nodes":76,"./resource_view":126,"./view_factory":127,underscore:131}],4:[function(t,e,n){var i={1:"January",2:"February",3:"March",4:"April",5:"May",6:"June",7:"July",8:"August",9:"September",10:"October",11:"November",12:"December"},r={formatDate:function(t){var e=t.split("-");if(3<=e.length)return new Date(e[0],e[1]-1,e[2]).toUTCString().slice(5,16);if(2!==e.length)return r;var n=e[1].replace(/^0/,""),r=e[0];return i[n]+" "+r}};e.exports=r},{}],5:[function(t,e,n){"use strict";var r=t("./article");e.exports=r},{"./article":3}],6:[function(t,e,n){"use strict";function r(t,e){i.Node.call(this,t,e)}var i=t("../../../substance/document");r.type={id:"affiliation",parent:"content",properties:{source_id:"string",city:"string",country:"string",department:"string",institution:"string",label:"string",specific_use:"string"}},r.description={name:"Affiliation",description:"Person affiliation",remarks:["Name of a institution or organization, such as a university or corporation, that is the affiliation for a contributor such as an author or an editor."],properties:{institution:"Name of institution",department:"Department name",country:"Country where institution is located",city:"City of institution",label:"Affilation label. Usually a number counting up"}},r.example={id:"affiliation_1",source_id:"aff1",city:"Jena",country:"Germany",department:"Department of Molecular Ecology",institution:"Max Planck Institute for Chemical Ecology",label:"1",type:"affiliation"},(r.Prototype=function(){}).prototype=i.Node.prototype,(r.prototype=new r.Prototype).constructor=r,i.Node.defineProperties(r),e.exports=r},{"../../../substance/document":174}],7:[function(t,e,n){"use strict";e.exports={Model:t("./affiliation")}},{"./affiliation":6}],8:[function(t,e,n){function r(t,e){i.Node.call(this,t,e)}var i=t("../../../substance/document");r.type={id:"annotation",properties:{path:["array","string"],range:["array","number"]}},(r.Prototype=function(){this.getLevel=function(){return this.constructor.fragmentation}}).prototype=i.Node.prototype,((r.prototype=new r.Prototype).constructor=r).NEVER=1,r.OK=2,r.fragmentation=r.DONT_CARE=3,i.Node.defineProperties(r),e.exports=r},{"../../../substance/document":174}],9:[function(t,e,n){"use strict";function r(t,e){this.node=t,this.viewFactory=e,this.el=this.createElement(),this.el.dataset.id=t.id,this.$el=$(this.el),this.setClasses()}r.Prototype=function(){this.createElement=function(){return document.createElement("span")},this.setClasses=function(){this.$el.addClass("annotation").addClass(this.node.type)},this.render=function(){return this}},r.prototype=new r.Prototype,e.exports=r},{}],10:[function(t,e,n){e.exports={Model:t("./annotation.js"),View:t("./annotation_view.js")}},{"./annotation.js":8,"./annotation_view.js":9}],11:[function(t,e,n){function r(t,e){o.call(this,t,e)}var i=t("../../../substance/document"),o=t("../annotation/annotation");r.type={id:"emphasis",parent:"annotation",properties:{style:"string"}},(r.Prototype=function(){}).prototype=o.prototype,((r.prototype=new r.Prototype).constructor=r).fragmentation=o.DONT_CARE,i.Node.defineProperties(r),e.exports=r},{"../../../substance/document":174,"../annotation/annotation":8}],12:[function(t,e,n){function r(t){i.call(this,t)}var i=t("../annotation").View;(r.Prototype=function(){this.setClasses=function(){i.prototype.setClasses.call(this),this.$el.addClass(this.node.style)}}).prototype=i.prototype,r.prototype=new r.Prototype,e.exports=r},{"../annotation":10}],13:[function(t,e,n){e.exports={Model:t("./author_callout.js"),View:t("./author_callout_view.js")}},{"./author_callout.js":11,"./author_callout_view.js":12}],14:[function(t,e,n){"use strict";function r(t,e){o.call(this,t,e)}var i=t("../../../substance/document"),o=i.Composite;r.type={id:"box",parent:"content",properties:{source_id:"string",label:"string",children:["array","paragraph"]}},r.description={name:"Box",remarks:["A box type."],properties:{label:"string",children:"0..n Paragraph nodes"}},r.example={id:"box_1",type:"box",label:"Box 1",children:["paragraph_1","paragraph_2"]},(r.Prototype=function(){this.getChildrenIds=function(){return this.properties.children}}).prototype=o.prototype,(r.prototype=new r.Prototype).constructor=r,i.Node.defineProperties(r),e.exports=r},{"../../../substance/document":174}],15:[function(t,e,n){"use strict";function r(t,e){o.call(this,t,e)}var i=t("../node").View,o=t("../composite").View,s=t("../../../substance/application").$$;(r.Prototype=function(){this.render=function(){if(i.prototype.render.call(this),this.node.label){var t=s(".label",{text:this.node.label});this.content.appendChild(t)}return this.renderChildren(),this.el.appendChild(this.content),this}}).prototype=o.prototype,r.prototype=new r.Prototype,e.exports=r},{"../../../substance/application":161,"../composite":33,"../node":91}],16:[function(t,e,n){"use strict";e.exports={Model:t("./box"),View:t("./box_view")}},{"./box":14,"./box_view":15}],17:[function(t,e,n){function r(t,e){i.call(this,t,e)}var i=t("../annotation/annotation");r.type={id:"capitalize",parent:"annotation",properties:{}},(r.Prototype=function(){}).prototype=i.prototype,((r.prototype=new r.Prototype).constructor=r).fragmentation=i.DONT_CARE,e.exports=r},{"../annotation/annotation":8}],18:[function(t,e,n){e.exports={Model:t("./capitalize.js"),View:t("../annotation/annotation_view.js")}},{"../annotation/annotation_view.js":9,"./capitalize.js":17}],19:[function(t,e,n){"use strict";function r(t,e){i.Composite.call(this,t,e)}var i=t("../../../substance/document");r.type={id:"caption",parent:"content",properties:{source_id:"string",title:"paragraph",children:["array","paragraph"]}},r.description={name:"Caption",remarks:["Container element for the textual description that is associated with a Figure, Table, Video node etc.","This is the title for the figure or the description of the figure that prints or displays with the figure."],properties:{title:"Caption title (optional)",children:"0..n Paragraph nodes"}},r.example={id:"caption_1",children:["paragraph_1","paragraph_2"]},(r.Prototype=function(){this.getChildrenIds=function(){return this.properties.children||[]},this.hasTitle=function(){return!!this.properties.title},this.getTitle=function(){if(this.properties.title)return this.document.get(this.properties.title)}}).prototype=i.Composite.prototype,(r.prototype=new r.Prototype).constructor=r,i.Node.defineProperties(r),e.exports=r},{"../../../substance/document":174}],20:[function(t,e,n){"use strict";function r(t,e){i.call(this,t,e)}var i=t("../composite").View,o=t("../../../substance/application").$$;(r.Prototype=function(){this.render=function(){if(this.content=o("div.content"),this.node.getTitle()){var t=this.createChildView(this.node.title).render().el;t.classList.add("caption-title"),this.content.appendChild(t)}return this.renderChildren(),this.el.appendChild(this.content),this}}).prototype=i.prototype,r.prototype=new r.Prototype,e.exports=r},{"../../../substance/application":161,"../composite":33}],21:[function(t,e,n){"use strict";e.exports={Model:t("./caption"),View:t("./caption_view")}},{"./caption":19,"./caption_view":20}],22:[function(t,e,n){function r(t,e){o.Node.call(this,t,e)}var i=t("underscore"),o=t("../../../substance/document");r.type={id:"article_citation",parent:"content",properties:{source_id:"string",title:"string",label:"string",authors:["array","string"],doi:"string",source:"string",volume:"string",citation_type:"string",publisher_name:"string",publisher_location:"string",fpage:"string",lpage:"string",year:"string",comment:"string",citation_urls:["array","object"],source_formats:["array","object"]}},r.description={name:"Citation",remarks:["A journal citation.","This element can be used to describe all kinds of citations."],properties:{title:"The article's title",label:"Optional label (could be a number for instance)",doi:"DOI reference",source:"Usually the journal name",volume:"Issue number",citation_type:"Citation Type",publisher_name:"Publisher Name",publisher_location:"Publisher Location",fpage:"First page",lpage:"Last page",year:"The year of publication",comment:"Author comment.",citation_urls:"A list of links for accessing the article on the web"}},r.example={id:"article_nature08160",type:"article_citation",label:"5",title:"The genome of the blood fluke Schistosoma mansoni",authors:["M Berriman","BJ Haas","PT LoVerde"],citation_type:"Journal Article",doi:"http://dx.doi.org/10.1038/nature08160",source:"Nature",volume:"460",fpage:"352",lpage:"8",year:"1984",comment:"This is a comment.",citation_urls:[{name:"PubMed",url:"http://www.ncbi.nlm.nih.gov/pubmed/19606141"}]},(r.Prototype=function(){this.urls=function(){return 0<this.properties.citation_urls.length?this.properties.citation_urls:[this.properties.doi]},this.getHeader=function(){return i.compact([this.properties.label,this.properties.citation_type||"Reference"]).join(" - ")}}).prototype=o.Node.prototype,(r.prototype=new r.Prototype).constructor=r,o.Node.defineProperties(r),e.exports=r},{"../../../substance/document":174,underscore:131}],23:[function(t,e,n){"use strict";function r(t,e,n){i.apply(this,arguments),o.call(this,n)}var l=t("underscore"),p=t("../../../substance/application").$$,i=t("../node").View,o=t("../../resource_view");(r.Prototype=function(){l.extend(this,o.prototype),this.renderBody=function(){var t=document.createDocumentFragment(),e=this.node,n=this.createTextPropertyView([e.id,"title"],{classes:"title"});t.appendChild(n.render().el),t.appendChild(p(".authors",{html:e.authors.join(", ")}));var r="",i="",o="",s="";e.source&&""===e.volume?i=e.source:e.source&&e.volume&&(i=[e.source,e.volume].join(", ")),e.fpage&&e.lpage&&(o=[e.fpage,e.lpage].join("-"));var a=[];if(e.publisher_name&&e.publisher_location&&(a.push(e.publisher_name),a.push(e.publisher_location)),e.year&&a.push(e.year),s=a.join(", "),(r=i)&&(o||s)&&(r+=": "),o&&s?r+=[o,s].join(", "):(r+=o,r+=s),t.appendChild(p(".source",{html:r})),e.comment){var c=this.createTextView({path:[e.id,"comment"],classes:"comment"});t.appendChild(c.render().el)}if(e.doi&&t.appendChild(p(".doi",{children:[p("b",{text:"DOI: "}),p("a",{href:e.doi,target:"_new",text:e.doi})]})),0<e.citation_urls.length){var u=p(".citation-urls");l.each(e.citation_urls,function(t){u.appendChild(p("a.url",{href:t.url,text:t.name,target:"_blank"}))}),t.appendChild(u)}this.content.appendChild(t)}}).prototype=i.prototype,(r.prototype=new r.Prototype).constructor=r,e.exports=r},{"../../../substance/application":161,"../../resource_view":126,"../node":91,underscore:131}],24:[function(t,e,n){"use strict";e.exports={Model:t("./citation"),View:t("./citation_view")}},{"./citation":22,"./citation_view":23}],25:[function(t,e,n){function r(t,e){s.call(this,t,e)}var i=t("../../../substance/document"),o=t("../annotation/annotation"),s=t("../resource_reference/resource_reference");r.type={id:"citation_reference",parent:"resource_reference",properties:{target:"citation"}},(r.Prototype=function(){}).prototype=s.prototype,((r.prototype=new r.Prototype).constructor=r).fragmentation=o.NEVER,i.Node.defineProperties(r),e.exports=r},{"../../../substance/document":174,"../annotation/annotation":8,"../resource_reference/resource_reference":104}],26:[function(t,e,n){e.exports={Model:t("./citation_reference.js"),View:t("../resource_reference/resource_reference_view.js")}},{"../resource_reference/resource_reference_view.js":105,"./citation_reference.js":25}],27:[function(t,e,n){function r(t,e){i.call(this,t,e)}var i=t("../annotation/annotation");r.type={id:"underline",parent:"annotation",properties:{}},(r.Prototype=function(){}).prototype=i.prototype,((r.prototype=new r.Prototype).constructor=r).fragmentation=i.DONT_CARE,e.exports=r},{"../annotation/annotation":8}],28:[function(t,e,n){e.exports={Model:t("./code.js"),View:t("../annotation/annotation_view.js")}},{"../annotation/annotation_view.js":9,"./code.js":27}],29:[function(t,e,n){"use strict";function r(t,e){i.call(this,t,e)}var i=t("../text").Model;r.type={id:"codeblock",parent:"content",properties:{source_id:"string",content:"string"}},r.config={zoomable:!0},r.description={name:"Codeblock",remarks:["Text in a codeblock is displayed in a fixed-width font, and it preserves both spaces and line breaks"],properties:{content:"Content"}},r.example={type:"codeblock",id:"codeblock_1",content:'var text = "Sun";\nvar op1 = null;\ntext = op2.apply(op1.apply(text));\nconsole.log(text);'},(r.Prototype=function(){}).prototype=i.prototype,(r.prototype=new r.Prototype).constructor=r,e.exports=r},{"../text":115}],30:[function(t,e,n){"use strict";function r(t){i.call(this,t)}var i=t("../text/text_view");(r.Prototype=function(){}).prototype=i.prototype,r.prototype=new r.Prototype,e.exports=r},{"../text/text_view":118}],31:[function(t,e,n){"use strict";e.exports={Model:t("./codeblock"),View:t("./codeblock_view")}},{"./codeblock":29,"./codeblock_view":30}],32:[function(t,e,n){"use strict";function r(t,e){i.call(this,t,e),this.childrenViews=[]}var i=t("../node").View;(r.Prototype=function(){this.render=function(){return i.prototype.render.call(this),this.renderChildren(),this},this.renderChildren=function(){for(var t=this.node.getChildrenIds(),e=0;e<t.length;e++){var n=this.createChildView(t[e]).render().el;this.content.appendChild(n)}},this.dispose=function(){i.prototype.dispose.call(this);for(var t=0;t<this.childrenViews.length;t++)this.childrenViews[t].dispose()},this.delete=function(){},this.getCharPosition=function(){return 0},this.getDOMPosition=function(){var t=this.$(".content")[0],e=document.createRange();return e.setStartBefore(t.childNodes[0]),e},this.createChildView=function(t){var e=this.createView(t);return this.childrenViews.push(e),e}}).prototype=i.prototype,r.prototype=new r.Prototype,e.exports=r},{"../node":91}],33:[function(t,e,n){"use strict";var r=t("../../../substance/document");e.exports={Model:r.Composite,View:t("./composite_view")}},{"../../../substance/document":174,"./composite_view":32}],34:[function(t,e,n){function r(t,e){o.Node.call(this,t,e)}var i=t("underscore"),o=t("../../../substance/document");r.type={id:"contributor",parent:"content",properties:{source_id:"string",name:"string",role:"string",contributor_type:"string",affiliations:["array","affiliation"],present_address:["string"],fundings:["array","string"],image:"string",emails:["array","string"],contribution:"string",bio:["array","paragraph"],deceased:"boolean",members:["array","string"],orcid:"string",equal_contrib:["array","string"],competing_interests:["array","string"]}},r.description={name:"Contributor",remarks:["A contributor entity."],properties:{name:"Full name",affiliations:"A list of affiliation ids",present_address:"Present address of the contributor",role:"Role of contributor (e.g. Author, Editor)",fundings:"A list of funding descriptions",deceased:!1,emails:"A list of emails",orcid:"ORCID",contribution:"Description of contribution",equal_contrib:"A list of people who contributed equally",competing_interests:"A list of conflicts",members:"a list of group members"}},r.example={id:"person_1",type:"contributor",name:"John Doe",affiliations:["affiliation_1","affiliation_2"],role:"Author",fundings:["Funding Organisation 1"],emails:["[email protected]"],contribution:"Revising the article, data cleanup",equal_contrib:["John Doe","Jane Doe"]},(r.Prototype=function(){this.getAffiliations=function(){return i.map(this.properties.affiliations,function(t){return this.document.get(t)},this)},this.getHeader=function(){return this.properties.contributor_type||"Author"}}).prototype=o.Node.prototype,(r.prototype=new r.Prototype).constructor=r,o.Node.defineProperties(r),e.exports=r},{"../../../substance/document":174,underscore:131}],35:[function(t,e,n){"use strict";function r(t,e,n){o.call(this,t,e),a.call(this,n)}var i=t("underscore"),o=t("../node").View,s=t("../../../substance/application").$$,a=t("../../resource_view");(r.Prototype=function(){i.extend(this,a.prototype),this.renderBody=function(){if(this.content.appendChild(s(".contributor-name",{text:this.node.name})),this.node.role&&this.content.appendChild(s(".role",{text:this.node.role})),this.content.appendChild(s(".affiliations",{children:i.map(this.node.getAffiliations(),function(t){var e=i.compact([t.department,t.institution,t.city,t.country]).join(", ");return s(".affiliation",{text:e})})})),this.node.present_address&&this.content.appendChild(s(".present-address.contrib-data",{children:[s("span.contrib-label",{text:"Present address: "}),s("span",{text:this.node.present_address})]})),this.node.contribution&&this.content.appendChild(s(".contribution.contrib-data",{children:[s("span.contrib-label",{text:"Contribution: "}),s("span",{text:this.node.contribution})]})),this.node.equal_contrib&&0<this.node.equal_contrib.length&&this.content.appendChild(s(".equal-contribution.contrib-data",{children:[s("span.contrib-label",{text:"Contributed equally with: "}),s("span",{text:this.node.equal_contrib.join(", ")})]})),0<this.node.emails.length&&this.content.appendChild(s(".emails.contrib-data",{children:[s("span.contrib-label",{text:"For correspondence: "}),s("span",{children:i.map(this.node.emails,function(t){return s("a",{href:"mailto:"+t,text:t+" "})})})]})),0<this.node.fundings.length&&this.content.appendChild(s(".fundings.contrib-data",{children:[s("span.contrib-label",{text:"Funding: "}),s("span",{text:this.node.fundings.join("; ")})]})),this.node.competing_interests.length&&this.content.appendChild(s(".competing-interests.contrib-data",{children:[s("span.contrib-label",{text:"Competing Interests: "}),s("span",{text:this.node.competing_interests.join(", ")})]})),this.node.orcid&&this.content.appendChild(s(".contrib-data",{children:[s("span.contrib-label",{text:"ORCID: "}),s("a.orcid",{href:this.node.orcid,text:this.node.orcid})]})),0<this.node.members.length&&this.content.appendChild(s(".group-members.contrib-data",{children:[s("span.contrib-label",{text:"Group Members: "}),s("span",{text:this.node.members.join(", ")})]})),this.node.image||this.node.bio&&0<this.node.bio.length){var e=s(".bio"),t=[s("img",{src:this.node.image}),e];i.each(this.node.bio,function(t){e.appendChild(this.createView(t).render().el)},this),this.content.appendChild(s(".contributor-bio.container",{children:t}))}this.node.deceased&&this.content.appendChild(s(".label",{text:"* Deceased"}))}}).prototype=o.prototype,r.prototype=new r.Prototype,e.exports=r},{"../../../substance/application":161,"../../resource_view":126,"../node":91,underscore:131}],36:[function(t,e,n){"use strict";e.exports={Model:t("./contributor"),View:t("./contributor_view")}},{"./contributor":34,"./contributor_view":35}],37:[function(t,e,n){function r(t,e){s.call(this,t,e)}var i=t("../../../substance/document"),o=t("../annotation/annotation"),s=t("../resource_reference/resource_reference");r.type={id:"contributor_reference",parent:"resource_reference",properties:{target:"contributor"}},(r.Prototype=function(){}).prototype=s.prototype,((r.prototype=new r.Prototype).constructor=r).fragmentation=o.NEVER,i.Node.defineProperties(r),e.exports=r},{"../../../substance/document":174,"../annotation/annotation":8,"../resource_reference/resource_reference":104}],38:[function(t,e,n){e.exports={Model:t("./contributor_reference.js"),View:t("../resource_reference/resource_reference_view.js")}},{"../resource_reference/resource_reference_view.js":105,"./contributor_reference.js":37}],39:[function(t,e,n){function r(t,e){o.Node.call(this,t,e)}var i=t("underscore"),o=t("../../../substance/document");r.type={id:"cover",parent:"content",properties:{source_id:"string",authors:["array","paragraph"],breadcrumbs:"object",abstract:"object"}},r.description={name:"Cover",remarks:["Virtual view on the title and authors of the paper."],properties:{authors:"A paragraph that has the authors names plus references to the person cards"}},r.example={id:"cover",type:"cover"},(r.Prototype=function(){this.getAuthors=function(){return i.map(this.properties.authors,function(t){return this.document.get(t)},this)},this.getTitle=function(){return this.document.title},this.getAbstract=function(){return this.document.get(this.properties.abstract)}}).prototype=o.Node.prototype,(r.prototype=new r.Prototype).constructor=r,o.Node.defineProperties(r),e.exports=r},{"../../../substance/document":174,underscore:131}],40:[function(t,e,n){"use strict";function r(t,e){f.call(this,t,e)}var d=t("underscore"),f=t("../node").View,g=t("../../../substance/application").$$,y=t("../../article_util");(r.Prototype=function(){this.render=function(){f.prototype.render.call(this);var t=this.node,e=this.node.document.get("publication_info");if(e){var n,r=e.subjects;if(r)n=e.subject_link?g(".subjects",{children:d.map(e.getSubjectLinks(),function(t){return g("a",{href:t.url,text:t.name})})}):g(".subjects",{html:r.join(" ")}),this.content.appendChild(n)}var i=this.createTextPropertyView(["document","title"],{classes:"title",elementType:"div"});this.content.appendChild(i.render().el);var o=g(".authors",{children:d.map(t.getAuthors(),function(t){var e=this.viewFactory.createView(t).render().el;return this.content.appendChild(e),e},this)});if(o.appendChild(g(".content-node.text.plain",{children:[g(".content",{text:this.node.document.on_behalf_of})]})),this.content.appendChild(o),e){var s=e.published_on,a=e.article_type;if(s){var c=[y.formatDate(s)];if(a)if(e.article_type_link){var u=e.getArticleTypeLink();c.unshift('<a href="'+u.url+'">'+u.name+"</a>")}else c.unshift(a);this.content.appendChild(g(".published-on",{html:c.join(" ")}))}}if(e&&0<e.links.length){var l=g(".links");d.each(e.links,function(t){if("json"===t.type&&""===t.url){var e=JSON.stringify(this.node.document.toJSON(),null," "),n=new Blob([e],{type:"application/json"});l.appendChild(g("a.json",{href:window.URL?window.URL.createObjectURL(n):"#",html:'<i class="fa fa-external-link-square"></i> '+t.name,target:"_blank"}))}else l.appendChild(g("a."+t.type,{href:t.url,html:'<i class="fa fa-external-link-square"></i> '+t.name,target:"_blank"}))},this),this.content.appendChild(l)}if(e){var p=e.doi;p&&this.content.appendChild(g(".doi",{html:'DOI: <a href="https://doi.org/'+p+'">'+p+"</a>"}))}if(t.getAbstract()){var h=this.viewFactory.createView(t.getAbstract()).render().el;this.content.appendChild(h)}return this}}).prototype=f.prototype,r.prototype=new r.Prototype,e.exports=r},{"../../../substance/application":161,"../../article_util":4,"../node":91,underscore:131}],41:[function(t,e,n){"use strict";e.exports={Model:t("./cover"),View:t("./cover_view")}},{"./cover":39,"./cover_view":40}],42:[function(t,e,n){function r(t,e){o.call(this,t,e)}var i=t("../../../substance/document"),o=t("../annotation/annotation");r.type={id:"cross_reference",parent:"resource_reference",properties:{target:"toc"}},(r.Prototype=function(){}).prototype=o.prototype,((r.prototype=new r.Prototype).constructor=r).fragmentation=o.NEVER,i.Node.defineProperties(r),e.exports=r},{"../../../substance/document":174,"../annotation/annotation":8}],43:[function(t,e,n){"use strict";function r(t,e){i.call(this,t,e),this.$el.addClass("cross-reference")}var i=t("../annotation/annotation_view");(r.Prototype=function(){this.createElement=function(){var t=document.createElement("a");return t.setAttribute("href",""),t}}).prototype=i.prototype,r.prototype=new r.Prototype,e.exports=r},{"../annotation/annotation_view":9}],44:[function(t,e,n){e.exports={Model:t("./cross_reference.js"),View:t("./cross_reference_view.js")}},{"./cross_reference.js":42,"./cross_reference_view.js":43}],45:[function(t,e,n){function r(t,e){o.call(this,t,e)}var i=t("../../../substance/document"),o=t("../annotation/annotation");r.type={id:"custom_annotation",parent:"annotation",properties:{name:"string"}},(r.Prototype=function(){}).prototype=o.prototype,((r.prototype=new r.Prototype).constructor=r).fragmentation=o.DONT_CARE,i.Node.defineProperties(r),e.exports=r},{"../../../substance/document":174,"../annotation/annotation":8}],46:[function(t,e,n){function r(t){i.call(this,t)}var i=t("../annotation").View;(r.Prototype=function(){this.setClasses=function(){i.prototype.setClasses.call(this),this.$el.addClass(this.node.name)}}).prototype=i.prototype,r.prototype=new r.Prototype,e.exports=r},{"../annotation":10}],47:[function(t,e,n){e.exports={Model:t("./custom_annotation.js"),View:t("./custom_annotation_view.js")}},{"./custom_annotation.js":45,"./custom_annotation_view.js":46}],48:[function(t,e,n){function r(t){i.Node.call(this,t)}var i=t("../../../substance/document");r.type={id:"definition",parent:"content",properties:{source_id:"string",title:"string",description:"string"}},r.description={name:"Definition",remarks:["A journal citation.","This element can be used to describe all kinds of citations."],properties:{title:"The article's title",description:"Definition description"}},r.example={id:"definition_def1",type:"Definition",title:"IAP",description:"Integrated Analysis Platform"},(r.Prototype=function(){this.urls=function(){return 0<this.properties.citation_urls.length?this.properties.citation_urls:[this.properties.doi]},this.getHeader=function(){return this.properties.label?[this.properties.label,this.properties.title].join(". "):this.properties.title}}).prototype=i.Node.prototype,(r.prototype=new r.Prototype).constructor=r,i.Node.defineProperties(r),e.exports=r},{"../../../substance/document":174}],49:[function(t,e,n){"use strict";function r(t,e,n){o.call(this,t,e),a.call(this,n)}var i=t("underscore"),o=t("../node").View,s=t("../../../substance/application").$$,a=t("../../resource_view");(r.Prototype=function(){i.extend(this,a.prototype),this.renderBody=function(){this.content.appendChild(s(".description",{text:this.node.description}))}}).prototype=o.prototype,(r.prototype=new r.Prototype).constructor=r,e.exports=r},{"../../../substance/application":161,"../../resource_view":126,"../node":91,underscore:131}],50:[function(t,e,n){"use strict";e.exports={Model:t("./definition"),View:t("./definition_view")}},{"./definition":48,"./definition_view":49}],51:[function(t,e,n){function r(t,e){s.call(this,t,e)}var i=t("../../../substance/document"),o=t("../annotation/annotation"),s=t("../resource_reference/resource_reference");r.type={id:"definition_reference",parent:"resource_reference",properties:{target:"definition"}},(r.Prototype=function(){}).prototype=s.prototype,((r.prototype=new r.Prototype).constructor=r).fragmentation=o.NEVER,i.Node.defineProperties(r),e.exports=r},{"../../../substance/document":174,"../annotation/annotation":8,"../resource_reference/resource_reference":104}],52:[function(t,e,n){e.exports={Model:t("./definition_reference.js"),View:t("../resource_reference/resource_reference_view.js")}},{"../resource_reference/resource_reference_view.js":105,"./definition_reference.js":51}],53:[function(t,e,n){"use strict";function r(t,e){i.Node.call(this,t,e)}var i=t("../../../substance/document");r.type={id:"document",parent:"content",properties:{views:["array","view"],guid:"string",creator:"string",title:"string",authors:["array","contributor"],on_behalf_of:"string",abstract:"string"}},(r.Prototype=function(){}).prototype=i.Node.prototype,(r.prototype=new r.Prototype).constructor=r,i.Node.defineProperties(r),e.exports=r},{"../../../substance/document":174}],54:[function(t,e,n){"use strict";e.exports={Model:t("./document_node")}},{"./document_node":53}],55:[function(t,e,n){function r(t,e){i.call(this,t,e)}var i=t("../annotation/annotation");r.type={id:"emphasis",parent:"annotation",properties:{}},(r.Prototype=function(){}).prototype=i.prototype,((r.prototype=new r.Prototype).constructor=r).fragmentation=i.DONT_CARE,e.exports=r},{"../annotation/annotation":8}],56:[function(t,e,n){e.exports={Model:t("./emphasis.js"),View:t("../annotation/annotation_view.js")}},{"../annotation/annotation_view.js":9,"./emphasis.js":55}],57:[function(t,e,n){"use strict";function r(t,e){i.Composite.call(this,t,e)}var i=t("../../../substance/document");r.type={parent:"content",properties:{source_id:"string",label:"string",url:"string",caption:"caption",position:"string",attrib:"string"}},r.config={zoomable:!0},r.description={name:"Figure",remarks:["A figure is a figure is figure."],properties:{label:"Label used as header for the figure cards",url:"Image url",caption:"A reference to a caption node that describes the figure",attrib:"Figure attribution"}},r.example={id:"figure_1",label:"Figure 1",url:"http://example.com/fig1.png",caption:"caption_1"},(r.Prototype=function(){this.hasCaption=function(){return!!this.properties.caption},this.getChildrenIds=function(){var t=[];return this.properties.caption&&t.push(this.properties.caption),t},this.getCaption=function(){if(this.properties.caption)return this.document.get(this.properties.caption)},this.getHeader=function(){return this.properties.label},this.includeInToc=function(){return!0}}).prototype=i.Composite.prototype,(r.prototype=new r.Prototype).constructor=r,i.Node.defineProperties(r.prototype,Object.keys(r.type.properties)),e.exports=r},{"../../../substance/document":174}],58:[function(t,e,n){"use strict";function r(t,e,n){o.call(this,t,e),a.call(this,n)}var i=t("underscore"),o=t("../composite").View,s=t("../../../substance/application").$$,a=t("../../resource_view");(r.Prototype=function(){i.extend(this,a.prototype),this.isZoomable=!0,this.renderBody=function(){if(this.content.appendChild(s(".label",{text:this.node.label})),this.node.url){var t=s(".image-wrapper",{children:[s("a",{href:this.node.url,target:"_blank",class:"toggle toggle-fullscreen",children:[s("img",{src:this.node.url})]})]});this.content.appendChild(t)}this.renderChildren(),this.node.attrib&&this.content.appendChild(s(".figure-attribution",{text:this.node.attrib}))},this.renderLabel=function(){var t=s(".name",{href:"#"});return this.renderAnnotatedText([this.node.id,"label"],t),t}}).prototype=o.prototype,r.prototype=new r.Prototype,e.exports=r},{"../../../substance/application":161,"../../resource_view":126,"../composite":33,underscore:131}],59:[function(t,e,n){"use strict";e.exports={Model:t("./figure"),View:t("./figure_view")}},{"./figure":57,"./figure_view":58}],60:[function(t,e,n){function r(t,e){s.call(this,t,e)}var i=t("../../../substance/document"),o=t("../annotation/annotation"),s=t("../resource_reference/resource_reference");r.type={id:"figure_reference",parent:"resource_reference",properties:{target:"figure"}},(r.Prototype=function(){}).prototype=s.prototype,((r.prototype=new r.Prototype).constructor=r).fragmentation=o.NEVER,i.Node.defineProperties(r),e.exports=r},{"../../../substance/document":174,"../annotation/annotation":8,"../resource_reference/resource_reference":104}],61:[function(t,e,n){e.exports={Model:t("./figure_reference.js"),View:t("../resource_reference/resource_reference_view.js")}},{"../resource_reference/resource_reference_view.js":105,"./figure_reference.js":60}],62:[function(t,e,n){function r(t,e){o.Node.call(this,t,e)}var i=t("underscore"),o=t("../../../substance/document");r.type={id:"article_footnote",parent:"content",properties:{source_id:"string",text:["array","paragraph"],label:"string",authors:["array","string"],doi:"string",source:"string",volume:"string",citation_type:"string",publisher_name:"string",publisher_location:"string",fpage:"string",lpage:"string",year:"string",comment:"string",citation_urls:["array","object"],source_formats:["array","object"]}},r.description={name:"Footnote",remarks:["A journal citation.","This element can be used to describe all kinds of citations."],properties:{title:"The article's title",label:"Optional label (could be a number for instance)",doi:"DOI reference",source:"Usually the journal name",volume:"Issue number",citation_type:"Footnote Type",publisher_name:"Publisher Name",publisher_location:"Publisher Location",fpage:"First page",lpage:"Last page",year:"The year of publication",comment:"Author comment.",citation_urls:"A list of links for accessing the article on the web"}},r.example={id:"article_nature08160",type:"article_citation",label:"5",title:"The genome of the blood fluke Schistosoma mansoni",authors:["M Berriman","BJ Haas","PT LoVerde"],citation_type:"Journal Article",doi:"http://dx.doi.org/10.1038/nature08160",source:"Nature",volume:"460",fpage:"352",lpage:"8",year:"1984",comment:"This is a comment.",citation_urls:[{name:"PubMed",url:"http://www.ncbi.nlm.nih.gov/pubmed/19606141"}]},(r.Prototype=function(){this.urls=function(){return 0<this.properties.citation_urls.length?this.properties.citation_urls:[this.properties.doi]},this.getHeader=function(){return i.compact([this.properties.label,this.properties.citation_type||locales.Reference]).join(" - ")}}).prototype=o.Node.prototype,(r.prototype=new r.Prototype).constructor=r,o.Node.defineProperties(r),e.exports=r},{"../../../substance/document":174,underscore:131}],63:[function(t,e,n){"use strict";function r(t,e,n){i.apply(this,arguments),o.call(this,n)}var _=t("underscore"),x=t("../../../substance/application").$$,i=t("../node").View,o=t("../../resource_view"),C=t("../../../substance/util");(r.Prototype=function(){_.extend(this,o.prototype),this.renderBody=function(){var t,e,n,r,i=document.createDocumentFragment(),o=this.node,s=o.properties.text;function a(t,e,n){var r=document.createElement(e);return r.className=n,r.innerHTML=t.textContent,void 0!==t.target&&r.setAttribute("data-id",t.target),r}for(t=0;t<s.length;t++)for(var c=s[t],u=0;u<c.length;u++){var l=c[u];if(void 0!==l){if(r=document.createElement("div"),"paragraph"===l.handler)for(l=l.nodes,e=0;e<l.length;e++)if("italic"==l[e].tagName)r.appendChild(a(l[e],"span","citation-italic"));else if("xref"==l[e].tagName&&"sec"===l[e].getAttribute("ref-type"))r.appendChild(a(l[e],"a","annotation cross_reference cross-reference"));else if("xref"==l[e].tagName&&"bibr"===l[e].getAttribute("ref-type"))(n=a(l[e],"a","")).setAttribute("href","#citations/"+l[e].target),r.appendChild(n);else if("ext-link"==l[e].tagName){(n=a(l[e],"a","content-node link")).setAttribute("href",l[e]),n.setAttribute("target","_blank");var p=l[e].getAttributeNodeNS("http://www.w3.org/1999/xlink","href");p&&(n.innerHTML=l[e].textContent,n.setAttribute("href",p.textContent)),r.appendChild(n)}else r.appendChild(l[e]);else if("tableWrap"===l.handler){var h=C.dom.getChildren(l.node);if(h[0]){var d=document.createElement("table");d.innerHTML=h[0].innerHTML,d.className="table",i.appendChild(d)}}i.appendChild(r)}}i.appendChild(x(".authors",{html:o.authors.join(", ")}));var f="",g="",y="",m="";o.source&&""===o.volume?g=o.source:o.source&&o.volume&&(g=[o.source,o.volume].join(", ")),o.fpage&&o.lpage&&(y=[o.fpage,o.lpage].join("-"));var v=[];if(o.publisher_name&&o.publisher_location&&(v.push(o.publisher_name),v.push(o.publisher_location)),o.year&&v.push(o.year),m=v.join(", "),(f=g)&&(y||m)&&(f+=": "),y&&m?f+=[y,m].join(", "):(f+=y,f+=m),i.appendChild(x(".source",{html:f})),o.comment){var b=this.createTextView({path:[o.id,"comment"],classes:"comment"});i.appendChild(b.render().el)}if(o.doi&&i.appendChild(x(".doi",{children:[x("b",{text:"DOI: "}),x("a",{href:o.doi,target:"_new",text:o.doi})]})),0<o.citation_urls.length){var w=x(".citation-urls");_.each(o.citation_urls,function(t){w.appendChild(x("a.url",{href:t.url,text:t.name,target:"_blank"}))}),i.appendChild(w)}this.content.appendChild(i)}}).prototype=i.prototype,(r.prototype=new r.Prototype).constructor=r,e.exports=r},{"../../../substance/application":161,"../../../substance/util":183,"../../resource_view":126,"../node":91,underscore:131}],64:[function(t,e,n){"use strict";e.exports={Model:t("./footnote"),View:t("./footnote_view")}},{"./footnote":62,"./footnote_view":63}],65:[function(t,e,n){function r(t,e){s.call(this,t,e)}var i=t("../../../substance/document"),o=t("../annotation/annotation"),s=t("../resource_reference/resource_reference");r.type={id:"footnote_reference",parent:"resource_reference",properties:{target:"footnote"}},(r.Prototype=function(){}).prototype=s.prototype,((r.prototype=new r.Prototype).constructor=r).fragmentation=o.NEVER,i.Node.defineProperties(r),e.exports=r},{"../../../substance/document":174,"../annotation/annotation":8,"../resource_reference/resource_reference":104}],66:[function(t,e,n){e.exports={Model:t("./footnote_reference.js"),View:t("../resource_reference/resource_reference_view.js")}},{"../resource_reference/resource_reference_view.js":105,"./footnote_reference.js":65}],67:[function(t,e,n){function r(t){i.Node.call(this,t)}var i=t("../../../substance/document");r.type={id:"formula",parent:"content",properties:{source_id:"string",inline:"boolean",label:"string",format:["array","string"],data:["array","string"]}},r.description={name:"Formula",remarks:["Can either be expressed in MathML format or using an image url"],properties:{label:"Formula label (4)",data:"Formula data, either MathML or image url",format:"Can either be `mathml` or `image`"}},r.example={type:"formula",id:"formula_eqn1",label:"(1)",content:"<mml:mrow>...</mml:mrow>",format:"mathml"},(r.Prototype=function(){this.inline=!1}).prototype=i.Node.prototype,(r.prototype=new r.Prototype).constuctor=r,i.Node.defineProperties(r),e.exports=r},{"../../../substance/document":174}],68:[function(t,e,n){"use strict";function r(t,e){i.call(this,t,e)}var i=t("../node").View;(r.Prototype=function(){var u={latex:"math/tex",mathml:"math/mml"},l={image:0,mathml:1,latex:2};this.render=function(){this.node.inline&&this.$el.addClass("inline");var t,e=[];for(t=0;t<this.node.data.length;t++)e.push({format:this.node.format[t],data:this.node.data[t]});if(e.sort(function(t,e){return l[t.format]-l[e.format]}),0<e.length){var n=!1,r=!1;for(t=0;t<e.length;t++){var i=e[t].format,o=e[t].data;switch(i){case"mathml":r||(this.$el.append($(o)),r=!0,n&&(this.$preview.hide(),n=!0));break;case"latex":if(!r){var s=u[i];this.node.inline||(s+="; mode=display");var a=$("<script>").attr("type",s).html(o);this.$el.append(a),r=!0}break;case"image":if(!n){var c=$("<div>").addClass("MathJax_Preview");c.append($("<img>").attr("src",o)),this.$el.append(c),this.$preview=c,n=!0}break;default:console.error("Unknown formula format:",i)}}}return this.node.label&&this.$el.append($('<div class="label">').html(this.node.label)),this}}).prototype=i.prototype,r.prototype=new r.Prototype,e.exports=r},{"../node":91}],69:[function(t,e,n){"use strict";e.exports={Model:t("./formula"),View:t("./formula_view")}},{"./formula":67,"./formula_view":68}],70:[function(t,e,n){"use strict";function r(t,e){o.call(this,t,e)}var i=t("../../../substance/document").Node,o=t("../text/text_node");r.type={id:"heading",parent:"content",properties:{source_id:"string",content:"string",label:"string",level:"number",authors:["array","string"]}},r.example={type:"heading",id:"heading_1",content:"Introduction",level:1},r.description={name:"Heading",remarks:["Denotes a section or sub section in your article."],properties:{content:"Heading title",label:"Heading label",level:"Heading level. Ranges from 1..4"}},(r.Prototype=function(){this.splitInto="paragraph",this.includeInToc=function(){return!0},this.getLevel=function(){return this.level}}).prototype=o.prototype,(r.prototype=new r.Prototype).constructor=r,i.defineProperties(r),e.exports=r},{"../../../substance/document":174,"../text/text_node":116}],71:[function(t,e,n){"use strict";function r(t,e){i.call(this,t,e),this.$el.addClass("level-"+this.node.level)}var i=t("../node").View,s=t("../../../substance/application").$$;(r.Prototype=function(){this.render=function(){if(this.node.content.length){i.prototype.render.call(this);var t=this.createTextPropertyView([this.node.id,"content"],{classes:"title"});if(this.node.label){var e=s(".label",{text:this.node.label});this.content.appendChild(e)}this.content.appendChild(t.render().el)}return this},this.renderTocItem=function(){var t=s("div");if(this.node.label){var e=s(".label",{text:this.node.label});t.appendChild(e)}var n=s("span");if(this.renderAnnotatedText([this.node.id,"content"],n),t.appendChild(n),void 0!==this.node.authors&&0<this.node.authors.length){var r=s("div");$(r).addClass("authors");for(var i=0;i<this.node.authors.length;i++){var o=document.createElement("span");$(o).addClass("author"),o.appendChild(document.createTextNode(this.node.authors[i])),r.appendChild(o),t.appendChild(r)}}return t}}).prototype=i.prototype,r.prototype=new r.Prototype,e.exports=r},{"../../../substance/application":161,"../node":91}],72:[function(t,e,n){"use strict";e.exports={Model:t("./heading"),View:t("./heading_view")}},{"./heading":70,"./heading_view":71}],73:[function(t,e,n){"use strict";t("../../../substance/document").Node;function r(t,e){i.call(this,t,e)}var i=t("../web_resource").Model;r.type={id:"image",parent:"webresource",properties:{source_id:"string"}},r.example={type:"image",id:"image_1",url:"http://substance.io/image_1.png"},r.description={name:"Image",remarks:["Represents a web-resource for an image."],properties:{}},(r.Prototype=function(){}).prototype=i.prototype,(r.prototype=new r.Prototype).constructor=r,e.exports=r},{"../../../substance/document":174,"../web_resource":124}],74:[function(t,e,n){"use strict";function r(t,e){i.call(this,t,e)}var i=t("../node").View;(r.Prototype=function(){var r=Array.prototype.indexOf;this.render=function(){var t=document.createElement("div");t.className="content";var e=document.createElement("div");e.className="image-char",this._imgChar=e;var n=document.createElement("img");return n.src=this.node.url,n.alt="alt text",n.title="alt text",e.appendChild(n),t.appendChild(e),this.el.appendChild(t),this._imgPos=r.call(e.childNodes,n),this},this.delete=function(t,e){for(var n=this.$(".content")[0],r=n.childNodes,i=e-1;0<=i;i--)n.removeChild(r[t+i])},this.getCharPosition=function(t,e){if(t===this._imgChar)return e>this._imgPos?1:0;console.log("Errhhh..")},this.getDOMPosition=function(t){var e=this.$(".content")[0],n=document.createRange();return 0===t?n.setStartBefore(e.childNodes[0]):n.setStartAfter(e.childNodes[0]),n}}).prototype=i.prototype,r.prototype=new r.Prototype,e.exports=r},{"../node":91}],75:[function(t,e,n){"use strict";e.exports={Model:t("./image"),View:t("./image_view")}},{"./image":73,"./image_view":74}],76:[function(t,e,n){"use strict";e.exports={node:t("./node"),capitalize:t("./capitalize"),composite:t("./composite"),annotation:t("./annotation"),emphasis:t("./emphasis"),strong:t("./strong"),subscript:t("./subscript"),superscript:t("./superscript"),underline:t("./underline"),code:t("./code"),author_callout:t("./author_callout"),custom_annotation:t("./custom_annotation"),"inline-formula":t("./inline_formula"),resource_reference:t("./resource_reference"),contributor_reference:t("./contributor_reference"),figure_reference:t("./figure_reference"),citation_reference:t("./citation_reference"),footnote_reference:t("./footnote_reference"),definition_reference:t("./definition_reference"),cross_reference:t("./cross_reference"),publication_info:t("./publication_info"),link:t("./link"),inline_image:t("./inline_image"),document:t("./document"),text:t("./text"),paragraph:t("./paragraph"),heading:t("./heading"),box:t("./box"),cover:t("./cover"),figure:t("./figure"),caption:t("./caption"),image:t("./image"),webresource:t("./web_resource"),supplement:t("./supplement"),video:t("./video"),contributor:t("./contributor"),definition:t("./definition"),citation:t("./citation"),mixed_citation:t("./mixed_citation"),formula:t("./formula"),list:t("./list"),codeblock:t("./codeblock"),affiliation:t("./_affiliation"),footnote:t("./footnote"),quote:t("./quote")}},{"./_affiliation":7,"./annotation":10,"./author_callout":13,"./box":16,"./capitalize":18,"./caption":21,"./citation":24,"./citation_reference":26,"./code":28,"./codeblock":31,"./composite":33,"./contributor":36,"./contributor_reference":38,"./cover":41,"./cross_reference":44,"./custom_annotation":47,"./definition":50,"./definition_reference":52,"./document":54,"./emphasis":56,"./figure":59,"./figure_reference":61,"./footnote":64,"./footnote_reference":66,"./formula":69,"./heading":72,"./image":75,"./inline_formula":77,"./inline_image":80,"./link":82,"./list":85,"./mixed_citation":88,"./node":91,"./paragraph":94,"./publication_info":97,"./quote":100,"./resource_reference":103,"./strong":106,"./subscript":108,"./superscript":110,"./supplement":112,"./text":115,"./underline":119,"./video":121,"./web_resource":124}],77:[function(t,e,n){e.exports={Model:t("./inline_formula.js"),View:t("./inline_formula_view.js")}},{"./inline_formula.js":78,"./inline_formula_view.js":79}],78:[function(t,e,n){function r(t,e){o.call(this,t,e)}var i=t("../../../substance/document"),o=t("../annotation/annotation");r.type={id:"inline-formula",parent:"annotation",properties:{target:"formula"}},(r.Prototype=function(){}).prototype=o.prototype,((r.prototype=new r.Prototype).constructor=r).fragmentation=o.NEVER,i.Node.defineProperties(r),e.exports=r},{"../../../substance/document":174,"../annotation/annotation":8}],79:[function(t,e,n){"use strict";function r(t,e){i.call(this,t,e),$(this.el).removeClass("resource-reference")}var i=t("../resource_reference").View;(r.Prototype=function(){this.createElement=function(){return document.createElement("span")},this.render=function(){var t=this.node.document.get(this.node.target),e=this.viewFactory.createView(t);return this.el.innerHTML=e.render().el.innerHTML,this}}).prototype=i.prototype,r.prototype=new r.Prototype,e.exports=r},{"../resource_reference":103}],80:[function(t,e,n){e.exports={Model:t("./inline_image.js"),View:t("../annotation/annotation_view.js")}},{"../annotation/annotation_view.js":9,"./inline_image.js":81}],81:[function(t,e,n){function r(t,e){o.call(this,t,e)}var i=t("../../../substance/document"),o=t("../annotation/annotation");r.type={id:"inline-image",parent:"annotation",properties:{target:"image"}},(r.Prototype=function(){}).prototype=o.prototype,((r.prototype=new r.Prototype).constructor=r).fragmentation=o.NEVER,i.Node.defineProperties(r),e.exports=r},{"../../../substance/document":174,"../annotation/annotation":8}],82:[function(t,e,n){e.exports={Model:t("./link.js"),View:t("./link_view.js")}},{"./link.js":83,"./link_view.js":84}],83:[function(t,e,n){function r(t,e){o.call(this,t,e)}var i=t("../../../substance/document"),o=t("../annotation/annotation");r.type={id:"link",parent:"annotation",properties:{url:"string"}},(r.Prototype=function(){}).prototype=o.prototype,((r.prototype=new r.Prototype).constructor=r).fragmentation=o.NEVER,i.Node.defineProperties(r),e.exports=r},{"../../../substance/document":174,"../annotation/annotation":8}],84:[function(t,e,n){function r(t){i.call(this,t)}var i=t("../annotation").View;(r.Prototype=function(){this.createElement=function(){var t=document.createElement("a");return t.setAttribute("href",this.node.url),t.setAttribute("target","_blank"),t},this.setClasses=function(){this.$el.addClass("link")}}).prototype=i.prototype,r.prototype=new r.Prototype,e.exports=r},{"../annotation":10}],85:[function(t,e,n){"use strict";e.exports={Model:t("./list"),View:t("./list_view")}},{"./list":86,"./list_view":87}],86:[function(t,e,n){"use strict";function r(t,e){a.call(this,t,e)}var i=t("underscore"),o=t("../../../substance/document"),s=o.Node,a=o.Composite;r.type={id:"list",parent:"content",properties:{source_id:"string",items:["array","paragraph"],item_ids:["array","integer"],ordered:"boolean",list_type:"string"}},r.description={name:"List",remarks:["Lists can either be numbered or bullet lists"],properties:{ordered:"Specifies wheter the list is ordered or not",items:"An array of paragraph references"}},r.example={type:"list",id:"list_1","items ":["paragraph_listitem_1","paragraph_listitem_2"]},(r.Prototype=function(){this.getLength=function(){return this.properties.items.length},this.getChildrenIds=function(){return i.clone(this.items)},this.getItems=function(){return i.map(this.properties.items,function(t){return this.document.get(t)},this)},this.getChangePosition=function(t){if("items"===t.path[1])if("update"===t.type){var e=t.diff;if(e.isInsert())return t.diff.pos+1;if(e.isDelete())return t.diff.pos;if(e.isMove())return t.diff.target}else if("set"===t.type)return this.properties.items.length-1;return-1},this.isMutable=function(){return!0},this.insertChild=function(t,e,n){t.update([this.id,"items"],["+",e,n])},this.deleteChild=function(t,e){var n=this.items.indexOf(e);t.update([this.id,"items"],["-",n,e]),t.delete(e)},this.canJoin=function(t){return"list"===t.type},this.isBreakable=function(){return!0},this.break=function(t,e,n){var r=this.properties.items.indexOf(e);if(r<0)throw new Error("Unknown child "+e);var i=t.get(e).break(t,n);return t.update([this.id,"items"],["+",r+1,i.id]),i}}).prototype=a.prototype,(r.prototype=new r.Prototype).constructor=r,s.defineProperties(r.prototype,["items","ordered"]),e.exports=r},{"../../../substance/document":174,underscore:131}],87:[function(t,e,n){"use strict";function r(t,e){i.call(this,t,e)}var i=t("../composite/composite_view"),u=t("./list");t("underscore");r.whoami="SubstanceListView",(r.Prototype=function(){this.render=function(){this.el.innerHTML="";var t=this.node.ordered?"OL":"UL";this.content=document.createElement(t),this.content.classList.add("content");var e,n=this.node.properties.list_type;for(n&&this.content.classList.add(n),e=0;e<this.childrenViews.length;e++)this.childrenViews[e].dispose();var r=this.node.getNodes(),i=this.node.properties.item_ids,o=0;for(e=0;e<r.length;e++){var s,a=this.node.document.get(r[e]),c=this.viewFactory.createView(a);a instanceof u?s=c.render().el:(o!=i[e]|0==o&&(s=document.createElement("LI")),s.appendChild(c.render().el)),this.content.appendChild(s),this.childrenViews.push(c),o=i[e]}return this.el.appendChild(this.content),this},this.onNodeUpdate=function(t){t.path[0]===this.node.id&&"items"===t.path[1]&&this.render()}}).prototype=i.prototype,r.prototype=new r.Prototype,e.exports=r},{"../composite/composite_view":32,"./list":86,underscore:131}],88:[function(t,e,n){"use strict";e.exports={Model:t("./mixed_citation"),View:t("./mixed_citation_view")}},{"./mixed_citation":89,"./mixed_citation_view":90}],89:[function(t,e,n){function r(t,e){o.Node.call(this,t,e)}var i=t("underscore"),o=t("../../../substance/document");r.type={id:"mixed_citation",parent:"content",properties:{source_id:"string",text:"object",title:"string",label:"string",authors:["array","string"],doi:"string",source:"string",volume:"string",citation_type:"string",publisher_name:"string",publisher_location:"string",fpage:"string",lpage:"string",year:"string",comment:"string",citation_urls:["array","object"],source_formats:["array","object"]}},r.description={name:"MixedCitation",remarks:["A journal citation.","This element can be used to describe all kinds of citations."],properties:{title:"The article's title",label:"Optional label (could be a number for instance)",doi:"DOI reference",source:"Usually the journal name",volume:"Issue number",citation_type:"Footnote Type",publisher_name:"Publisher Name",publisher_location:"Publisher Location",fpage:"First page",lpage:"Last page",year:"The year of publication",comment:"Author comment.",citation_urls:"A list of links for accessing the article on the web"}},r.example={id:"article_nature08160",type:"article_citation",label:"5",title:"The genome of the blood fluke Schistosoma mansoni",authors:["M Berriman","BJ Haas","PT LoVerde"],citation_type:"Journal Article",doi:"http://dx.doi.org/10.1038/nature08160",source:"Nature",volume:"460",fpage:"352",lpage:"8",year:"1984",comment:"This is a comment.",citation_urls:[{name:"PubMed",url:"http://www.ncbi.nlm.nih.gov/pubmed/19606141"}]},(r.Prototype=function(){this.urls=function(){return 0<this.properties.citation_urls.length?this.properties.citation_urls:[this.properties.doi]},this.getHeader=function(){return i.compact([this.properties.label,this.properties.citation_type||locales.Reference]).join(" - ")}}).prototype=o.Node.prototype,(r.prototype=new r.Prototype).constructor=r,o.Node.defineProperties(r),e.exports=r},{"../../../substance/document":174,underscore:131}],90:[function(t,e,n){"use strict";function r(t,e,n){o.apply(this,arguments),s.call(this,n)}var i=t("underscore"),o=(t("../../../substance/application").$$,t("../node").View),s=t("../../resource_view");(r.Prototype=function(){i.extend(this,s.prototype),this.renderBody=function(){var t,e,n=document.createDocumentFragment(),r=this.node.properties.text[0].nodes;if(void 0!==r){for(var i=0;i<r.length;i++)if("italic"==r[i].tagName)(t=document.createElement("span")).className="citation-italic",t.innerHTML=r[i].textContent,n.appendChild(t);else if("ext-link"==r[i].tagName){(e=document.createElement("a")).className="content-node link",e.setAttribute("href",r[i]);var o=r[i].getAttributeNodeNS("http://www.w3.org/1999/xlink","href");o&&(e.innerHTML=r[i].textContent,e.setAttribute("href",o.textContent)),e.setAttribute("target","_blank"),n.appendChild(e)}else n.appendChild(r[i]);this.content.appendChild(n)}}}).prototype=o.prototype,(r.prototype=new r.Prototype).constructor=r,e.exports=r},{"../../../substance/application":161,"../../resource_view":126,"../node":91,underscore:131}],91:[function(t,e,n){"use strict";e.exports={Model:t("./node"),View:t("./node_view")}},{"./node":92,"./node_view":93}],92:[function(t,e,n){"use strict";var r=t("../../../substance/document").Node;r.description={name:"Node",remarks:["Abstract node type."],properties:{source_id:"Useful for document conversion where the original id of an element should be remembered."}},e.exports=r},{"../../../substance/document":174}],93:[function(t,e,n){"use strict";function r(t,e,n){if(s.call(this,n),this.node=t,!(this.viewFactory=e))throw new Error('Illegal argument. Argument "viewFactory" is mandatory.');if(this.$el.addClass("content-node").addClass(t.type.replace("_","-")),this.el.dataset.id=this.node.id,"paragraph"===t.type&&void 0!==t.properties.attributes){var r=t.properties.attributes;if(0<r.length)for(var i=0;i<r.length;i++){var o=r[i];"content-type"===o.name&&this.$el.addClass(o.value)}}}var s=t("../../../substance/application").View,i=t("../text/text_property_view");(r.Prototype=function(){this.render=function(){return this.content=document.createElement("DIV"),this.content.classList.add("content"),this.focusHandle=document.createElement("DIV"),this.focusHandle.classList.add("focus-handle"),this.el.appendChild(this.content),this.el.appendChild(this.focusHandle),this},this.dispose=function(){this.stopListening()},this.createView=function(t){var e=this.node.document.get(t);return this.viewFactory.createView(e)},this.createTextView=function(t){return console.error("FIXME: NodeView.createTextView() is deprecated. Use NodeView.createTextPropertyView() instead."),this.viewFactory.createView(this.node,t,"text")},this.createTextPropertyView=function(t,e){return new i(this.node.document,t,this.viewFactory,e)},this.renderAnnotatedText=function(t,e){return i.renderAnnotatedText(this.node.document,t,e,this.viewFactory)}}).prototype=s.prototype,r.prototype=new r.Prototype,e.exports=r},{"../../../substance/application":161,"../text/text_property_view":117}],94:[function(t,e,n){"use strict";e.exports={Model:t("./paragraph"),View:t("./paragraph_view")}},{"./paragraph":95,"./paragraph_view":96}],95:[function(t,e,n){"use strict";function r(t,e){a.call(this,t,e)}var i=t("underscore"),o=t("../../../substance/document"),s=o.Node,a=o.Composite;r.type={id:"paragraph",parent:"content",properties:{children:["array","content"]},attributes:"object"},r.description={name:"Paragraph",remarks:["A Paragraph can have inline elements such as images."],properties:{children:"An array of content node references"}},r.example={type:"paragraph",id:"paragraph_1","children ":["text_1","image_1","text_2"]},(r.Prototype=function(){this.getLength=function(){return this.properties.children.length},this.getChildrenIds=function(){return i.clone(this.properties.children)},this.getChildren=function(){return i.map(this.properties.children,function(t){return this.document.get(t)},this)}}).prototype=a.prototype,(r.prototype=new r.Prototype).constructor=r,s.defineProperties(r.prototype,["children"]),e.exports=r},{"../../../substance/document":174,underscore:131}],96:[function(t,e,n){"use strict";function r(t,e){i.call(this,t,e)}var i=t("../composite/composite_view");(r.Prototype=function(){}).prototype=i.prototype,r.prototype=new r.Prototype,e.exports=r},{"../composite/composite_view":32}],97:[function(t,e,n){"use strict";e.exports={Model:t("./publication_info"),View:t("./publication_info_view")}},{"./publication_info":98,"./publication_info_view":99}],98:[function(t,e,n){"use strict";function r(t,e){i.Node.call(this,t,e)}var i=t("../../../substance/document");r.type={id:"publication_info",parent:"content",properties:{history:["array","object"],published_on:"string",journal:"string",provider:"string",article_type:"string",keywords:["array","string"],research_organisms:["array","string"],subjects:["array","string"],links:["array","objects"],doi:"string",related_article:"string",article_info:"paragraph",subject_link:"string",article_type_link:"string"}},r.description={name:"PublicationInfo",description:"PublicationInfo Node",remarks:["Summarizes the article's meta information. Meant to be customized by publishers"],properties:{received_on:"Submission received",accepted_on:"Paper accepted on",published_on:"Paper published on",history:"History of the submission cycle",journal:"The Journal",provider:"Who is hosting this article",article_type:"Research Article vs. Insight, vs. Correction etc.",keywords:"Article's keywords",research_organisms:"Research Organisms",subjects:"Article Subjects",doi:"Article DOI",related_article:"DOI of related article if there is any"}},r.example={id:"publication_info",published_on:"2012-11-13",history:[{type:"received",date:"2012-06-20"},{type:"accepted",date:"2012-09-05"}],journal:"eLife",provider:"eLife",article_type:"Research Article",keywords:["innate immunity","histones","lipid droplet","anti-bacterial"],research_organisms:["B. subtilis","D. melanogaster","E. coli","Mouse"],subjects:["Immunology","Microbiology and infectious disease"],doi:"http://dx.doi.org/10.7554/eLife.00003"},(r.Prototype=function(){this.getArticleInfo=function(){return this.document.get("articleinfo")},this.getSubjectLinks=function(){return this.subjects.map(function(t){return{name:t,url:this.subject_link+"/"+t.replace(/ /g,"-").toLowerCase()}}.bind(this))},this.getArticleTypeLink=function(){return{name:this.article_type,url:this.article_type_link+"/"+this.article_type.replace(/ /g,"-").toLowerCase()}}}).prototype=i.Node.prototype,(r.prototype=new r.Prototype).constructor=r,i.Node.defineProperties(r),e.exports=r},{"../../../substance/document":174}],99:[function(t,e,n){"use strict";function r(t,e){l.call(this,t,e)}var l=t("../node").View,p=t("../../../substance/application").$$,i=t("../../article_util"),o={received:"received",accepted:"accepted",revised:"revised",corrected:"corrected","rev-recd":"revised","rev-request":"returned for modification",published:"Published",default:"updated"};(r.Prototype=function(){this.render=function(){l.prototype.render.call(this);var t=p(".meta-data");if(this.node.article_type){var e=p(".article-type.container",{children:[p("div.label",{text:"Article Type"}),p("div.value",{text:this.node.article_type})]});t.appendChild(e)}if(this.node.subjects&&0<this.node.subjects.length){var n=p(".subject.container",{children:[p("div.label",{text:"Subject"}),p("div.value",{text:this.node.subjects.join(", ")})]});t.appendChild(n)}if(this.node.research_organisms&&0<this.node.research_organisms.length){var r=p(".subject.container",{children:[p("div.label",{text:"Organism"}),p("div.value",{text:this.node.research_organisms.join(", ")})]});t.appendChild(r)}if(this.node.keywords&&0<this.node.keywords.length){var i=p(".keywords.container",{children:[p("div.label",{text:"Keywords"}),p("div.value",{text:this.node.keywords.join(", ")})]});t.appendChild(i)}if(this.node.doi){var o=p(".doi.container",{children:[p("div.label",{text:"DOI"}),p("div.value",{children:[p("a",{href:"https://doi.org/"+this.node.doi,text:this.node.doi,target:"_blank"})]})]});t.appendChild(o)}if(this.node.related_article){var s=p(".related-article.container",{children:[p("div.label",{text:"Related Article"}),p("div.value",{children:[p("a",{href:this.node.related_article,text:this.node.related_article})]})]});t.appendChild(s)}var a=this.describePublicationHistory();t.appendChild(a),this.content.appendChild(t);var c=this.node.getArticleInfo(),u=this.viewFactory.createView(c).render().el;return this.content.appendChild(u),this},this.describePublicationHistory=function(){var t,e=p(".dates"),n=[];if(this.node.history&&0<this.node.history.length&&(n=n.concat(this.node.history)),this.node.published_on&&n.push({type:"published",date:this.node.published_on}),0<n.length){for(e.appendChild(document.createTextNode("")),t=0;t<n.length;t++){0<t&&(e.appendChild(document.createTextNode(", ")),t===n.length-1&&e.appendChild(document.createTextNode("and ")));var r=n[t];e.appendChild(document.createTextNode((o[r.type]||o.default)+" on ")),e.appendChild(p("b",{text:i.formatDate(r.date)}))}e.appendChild(document.createTextNode("."))}return e},this.dispose=function(){l.prototype.dispose.call(this)}}).prototype=l.prototype,r.prototype=new r.Prototype,e.exports=r},{"../../../substance/application":161,"../../article_util":4,"../node":91}],100:[function(t,e,n){"use strict";e.exports={Model:t("./quote"),View:t("./quote_view")}},{"./quote":101,"./quote_view":102}],101:[function(t,e,n){"use strict";function r(t,e){o.call(this,t,e)}var i=t("../../../substance/document"),o=i.Composite;r.type={id:"quote",parent:"content",properties:{source_id:"string",label:"string",children:["array","object"]}},r.description={name:"Quote",remarks:["A quote type."],properties:{label:"string",children:"0..n Paragraph nodes"}},r.example={id:"quote_1",type:"quote",label:"Quote 1",children:["paragraph_1","paragraph_2"]},(r.Prototype=function(){this.getChildrenIds=function(){return this.properties.children}}).prototype=o.prototype,(r.prototype=new r.Prototype).constructor=r,i.Node.defineProperties(r),e.exports=r},{"../../../substance/document":174}],102:[function(t,e,n){"use strict";function r(t,e){o.call(this,t,e)}var i=t("../node").View,o=t("../composite").View,s=t("../../../substance/application").$$;(r.Prototype=function(){this.render=function(){if(i.prototype.render.call(this),this.node.label){var t=s(".label",{text:this.node.label});this.content.appendChild(t)}return this.renderChildren(),this.el.appendChild(this.content),this}}).prototype=o.prototype,r.prototype=new r.Prototype,e.exports=r},{"../../../substance/application":161,"../composite":33,"../node":91}],103:[function(t,e,n){e.exports={Model:t("./resource_reference.js"),View:t("./resource_reference_view.js")}},{"./resource_reference.js":104,"./resource_reference_view.js":105}],104:[function(t,e,n){function r(t,e){o.call(this,t,e)}var i=t("../../../substance/document"),o=t("../annotation/annotation");r.type={id:"resource_reference",parent:"annotation",properties:{target:"node"}},(r.Prototype=function(){}).prototype=o.prototype,((r.prototype=new r.Prototype).constructor=r).fragmentation=o.NEVER,i.Node.defineProperties(r),e.exports=r},{"../../../substance/document":174,"../annotation/annotation":8}],105:[function(t,e,n){"use strict";function r(t,e){i.call(this,t,e),this.$el.addClass("resource-reference")}var i=t("../annotation/annotation_view");(r.Prototype=function(){this.createElement=function(){var t=document.createElement("a");return t.setAttribute("href",""),t}}).prototype=i.prototype,r.prototype=new r.Prototype,e.exports=r},{"../annotation/annotation_view":9}],106:[function(t,e,n){e.exports={Model:t("./strong.js"),View:t("../annotation/annotation_view.js")}},{"../annotation/annotation_view.js":9,"./strong.js":107}],107:[function(t,e,n){function r(t,e){i.call(this,t,e)}var i=t("../annotation/annotation");r.type={id:"strong",parent:"annotation",properties:{}},(r.Prototype=function(){}).prototype=i.prototype,((r.prototype=new r.Prototype).constructor=r).fragmentation=i.DONT_CARE,e.exports=r},{"../annotation/annotation":8}],108:[function(t,e,n){e.exports={Model:t("./subscript.js"),View:t("../annotation/annotation_view.js")}},{"../annotation/annotation_view.js":9,"./subscript.js":109}],109:[function(t,e,n){function r(t,e){i.call(this,t,e)}var i=t("../annotation/annotation");r.type={id:"subscript",parent:"annotation",properties:{}},(r.Prototype=function(){}).prototype=i.prototype,((r.prototype=new r.Prototype).constructor=r).fragmentation=i.DONT_CARE,e.exports=r},{"../annotation/annotation":8}],110:[function(t,e,n){e.exports={Model:t("./superscript.js"),View:t("../annotation/annotation_view.js")}},{"../annotation/annotation_view.js":9,"./superscript.js":111}],111:[function(t,e,n){function r(t,e){i.call(this,t,e)}var i=t("../annotation/annotation");r.type={id:"superscript",parent:"annotation",properties:{}},(r.Prototype=function(){}).prototype=i.prototype,((r.prototype=new r.Prototype).constructor=r).fragmentation=i.DONT_CARE,e.exports=r},{"../annotation/annotation":8}],112:[function(t,e,n){"use strict";e.exports={Model:t("./supplement"),View:t("./supplement_view")}},{"./supplement":113,"./supplement_view":114}],113:[function(t,e,n){t("underscore");function r(t,e){i.Composite.call(this,t,e)}var i=t("../../../substance/document");r.type={id:"supplement",parent:"content",properties:{source_id:"string",label:"string",url:"string",caption:"caption"}},r.description={name:"Supplement",remarks:["A Supplement entity."],properties:{source_id:"Supplement id as it occurs in the source NLM file",label:"Supplement label",caption:"References a caption node, that has all the content",url:"URL of downloadable file"}},r.example={id:"supplement_1",source_id:"SD1-data",type:"supplement",label:"Supplementary file 1.",url:"http://myserver.com/myfile.pdf",caption:"caption_supplement_1"},(r.Prototype=function(){this.getChildrenIds=function(){var t=[];return this.properties.caption&&t.push(this.properties.caption),t},this.getCaption=function(){return this.properties.caption?this.document.get(this.properties.caption):null},this.getHeader=function(){return this.properties.label}}).prototype=i.Composite.prototype,(r.prototype=new r.Prototype).constructor=r,i.Node.defineProperties(r),e.exports=r},{"../../../substance/document":174,underscore:131}],114:[function(t,e,n){"use strict";function r(t,e,n){o.call(this,t,e),a.call(this,n)}var i=t("underscore"),o=t("../composite").View,s=t("../../../substance/application").$$,a=t("../../resource_view");(r.Prototype=function(){i.extend(this,a.prototype),this.renderBody=function(){this.renderChildren();var t=s("div.file",{children:[s("a",{href:this.node.url,html:'<i class="fa fa-download"/> Download'})]});this.content.appendChild(t)}}).prototype=o.prototype,(r.prototype=new r.Prototype).constructor=r,e.exports=r},{"../../../substance/application":161,"../../resource_view":126,"../composite":33,underscore:131}],115:[function(t,e,n){"use strict";e.exports={Model:t("./text_node"),View:t("./text_view")}},{"./text_node":116,"./text_view":118}],116:[function(t,e,n){"use strict";var r=t("../../../substance/document");e.exports=r.TextNode},{"../../../substance/document":174}],117:[function(t,e,n){"use strict";function r(t,e,n,r){(r=r||{}).elementType=r.elementType||"span",i.call(this,r),this.path=e,this.document=t,this.viewFactory=n,this.options=r||{},this.property=t.resolve(this.path),this.$el.addClass("text"),this.options.classes&&this.$el.addClass(this.options.classes)}var l=t("../../../substance/util").Fragmenter,i=t("../../../substance/application").View;(r.Prototype=function(){this.render=function(){return this.el.innerHTML="",r.renderAnnotatedText(this.document,this.path,this.el,this.viewFactory),this},this.dispose=function(){this.stopListening()},this.renderWithAnnotations=function(t){var i=this,e=this.property.get(),n=document.createDocumentFragment(),o=this.document,s=[],r=new l;r.onText=function(t,e){t.appendChild(document.createTextNode(e))},r.onEnter=function(t,e){var n=o.get(t.id),r=i.viewFactory.createView(n);return e.appendChild(r.el),s.push(r),r.el},r.start(n,e,t);for(var a=0;a<s.length;a++)s[a].render();this.el.innerHTML="",this.el.appendChild(n)}}).prototype=i.prototype,r.prototype=new r.Prototype,r.renderAnnotatedText=function(i,t,e,o){var n=window.document.createDocumentFragment(),r=i.get(t),s=i.getIndex("annotations").get(t),a=[],c=new l;c.onText=function(t,e){t.appendChild(window.document.createTextNode(e))},c.onEnter=function(t,e){var n=i.get(t.id),r=o.createView(n);return e.appendChild(r.el),a.push(r),r.el},c.start(n,r,s);for(var u=0;u<a.length;u++)a[u].render();e.appendChild(n)},e.exports=r},{"../../../substance/application":161,"../../../substance/util":183}],118:[function(t,e,n){"use strict";function r(t,e,n){i.call(this,t,e),n=this.options=n||{},this.path=n.path||[t.id,"content"],this.property=t.document.resolve(this.path),this.$el.addClass("text"),n.classes&&this.$el.addClass(n.classes),n.path&&this.$el.removeClass("content-node"),this._annotations={}}var c=t("../../../substance/util").Fragmenter,i=t("../node/node_view"),o=t("../../../substance/application").$$;(r.Prototype=function(){this.render=function(){return i.prototype.render.call(this),this.renderContent(),this},this.dispose=function(){i.prototype.dispose.call(this)},this.renderContent=function(){this.content.innerHTML="",this._annotations=this.node.document.getIndex("annotations").get(this.path),this.renderWithAnnotations(this._annotations)},this.createAnnotationElement=function(t){return this.options.createAnnotationElement?this.options.createAnnotationElement.call(this,t):"link"===t.type?o("a.annotation."+t.type,{id:t.id,href:this.node.document.get(t.id).url}):o("span.annotation."+t.type,{id:t.id})},this.renderWithAnnotations=function(t){var i=this,e=this.property.get(),n=document.createDocumentFragment(),o=this.node.document,s=[],r=new c;r.onText=function(t,e){t.appendChild(document.createTextNode(e))},r.onEnter=function(t,e){var n=o.get(t.id),r=i.viewFactory.createView(n);return e.appendChild(r.el),s.push(r),r.el},r.start(n,e,t);for(var a=0;a<s.length;a++)s[a].render();this.content.innerHTML="",this.content.appendChild(n)}}).prototype=i.prototype,r.prototype=new r.Prototype,e.exports=r},{"../../../substance/application":161,"../../../substance/util":183,"../node/node_view":93}],119:[function(t,e,n){e.exports={Model:t("./underline.js"),View:t("../annotation/annotation_view.js")}},{"../annotation/annotation_view.js":9,"./underline.js":120}],120:[function(t,e,n){function r(t,e){i.call(this,t,e)}var i=t("../annotation/annotation");r.type={id:"underline",parent:"annotation",properties:{}},(r.Prototype=function(){}).prototype=i.prototype,((r.prototype=new r.Prototype).constructor=r).fragmentation=i.DONT_CARE,e.exports=r},{"../annotation/annotation":8}],121:[function(t,e,n){"use strict";e.exports={Model:t("./video"),View:t("./video_view")}},{"./video":122,"./video_view":123}],122:[function(t,e,n){function r(t,e){i.Node.call(this,t,e)}var i=t("../../../substance/document");r.type={id:"video",parent:"content",properties:{source_id:"string",label:"string",url:"string",url_webm:"string",url_ogv:"string",caption:"caption",poster:"string"}},r.config={zoomable:!0},r.description={name:"Video",remarks:["A video type intended to refer to video resources.","MP4, WebM and OGV formats are supported."],properties:{label:"Label shown in the resource header.",url:"URL to mp4 version of the video.",url_webm:"URL to WebM version of the video.",url_ogv:"URL to OGV version of the video.",poster:"Video poster image.",caption:"References a caption node, that has all the content"}},r.example={id:"video_1",type:"video",label:"Video 1.",url:"https://cdn.elifesciences.org/video/eLifeLensIntro2.mp4",url_webm:"https://cdn.elifesciences.org/video/eLifeLensIntro2.webm",url_ogv:"https://cdn.elifesciences.org/video/eLifeLensIntro2.ogv",poster:"https://cdn.elifesciences.org/video/eLifeLensIntro2.png",caption:"caption_25"},(r.Prototype=function(){this.getHeader=function(){return this.properties.label},this.getCaption=function(){return this.properties.caption?this.document.get(this.properties.caption):""},this.includeInToc=function(){return!1}}).prototype=i.Node.prototype,(r.prototype=new r.Prototype).constructor=r,i.Node.defineProperties(r),e.exports=r},{"../../../substance/document":174}],123:[function(t,e,n){"use strict";function r(t,e,n){s.call(this,t,e),a.call(this,n)}var i=t("underscore"),o=t("../../../substance/application").$$,s=t("../node").View,a=t("../../resource_view");(r.Prototype=function(){i.extend(this,a.prototype),this.isZoomable=!0,this.renderBody=function(){var t=this.node,e=[o("source",{src:t.url})];t.url_ogv&&e.push(o("source",{src:t.url_ogv,type:"video/ogg; codecs="theora, vorbis""})),t.url_webm&&e.push(o("source",{src:t.url_webm,type:"video/webm"}));var n=o(".video-wrapper",{children:[o("video",{controls:"controls",poster:t.poster,preload:"none",style:"background-color: black",children:e})]});if(this.content.appendChild(n),t.title&&this.content.appendChild(o(".title",{text:t.title})),this.node.caption){var r=this.createView(this.node.caption);this.content.appendChild(r.render().el),this.captionView=r}t.doi&&this.content.appendChild(o(".doi",{children:[o("b",{text:"DOI: "}),o("a",{href:t.doi,target:"_new",text:t.doi})]}))}}).prototype=s.prototype,r.prototype=new r.Prototype,e.exports=r},{"../../../substance/application":161,"../../resource_view":126,"../node":91,underscore:131}],124:[function(t,e,n){"use strict";e.exports={Model:t("./web_resource"),View:t("../node").View}},{"../node":91,"./web_resource":125}],125:[function(t,e,n){"use strict";function r(t,e){i.call(this,t,e)}var i=t("../../../substance/document").Node;r.type={id:"webresource",parent:"content",properties:{source_id:"string",url:"string"}},r.description={name:"WebResource",description:"A resource which can be accessed via URL",remarks:["This element is a parent for several other nodes such as Image."],properties:{url:"URL to a resource"}},r.example={type:"webresource",id:"webresource_3",url:"http://elife.elifesciences.org/content/elife/1/e00311/F3.medium.gif"},(r.Prototype=function(){}).prototype=i.prototype,(r.prototype=new r.Prototype).constructor=r,i.defineProperties(r.prototype,["url"]),e.exports=r},{"../../../substance/document":174}],126:[function(t,e,n){"use strict";function r(t){this.options=i.extend({},a,t)}var i=t("underscore"),o=t("./nodes/node").View,s=t("../substance/application").$$,a={header:!1,zoom:!1};r.Prototype=function(){this.isResourceView=!0,this.render=function(){return o.prototype.render.call(this),this.renderHeader(),this.renderBody(),this},this.renderHeader=function(){this.node;if(this.options.header){var t=s(".resource-header");t.appendChild(this.renderLabel());var e=s(".toggles");this.options.zoom&&e.appendChild(s("a.toggle.toggle-fullscreen",{href:"#",html:'<i class="fa fa-expand"></i> Fullscreen'})),e.appendChild(s("a.toggle-res.toggle.action-toggle-resource",{href:"#",html:'<i class="fa fa-eye"></i> Focus'})),t.appendChild(e),this.headerEl=t,this.el.insertBefore(t,this.content)}},this.renderLabel=function(){return s("div.name",{html:this.getHeader()})},this.renderBody=function(){},this.getHeader=function(){return this.node.getHeader()}},r.prototype=new r.Prototype,e.exports=r},{"../substance/application":161,"./nodes/node":91,underscore:131}],127:[function(t,e,n){function r(t,e){this.nodeTypes=t,this.options=e||{}}r.Prototype=function(){this.getNodeViewClass=function(t,e){e=e||t.type;var n=this.nodeTypes[e];if(!n)throw new Error("No node registered for type "+e+".");var r=n.View;if(!r)throw new Error('No view registered for type "'+t.type+'".');return r},this.createView=function(t,e,n){return new(this.getNodeViewClass(t,n))(t,this,e)}},r.prototype=new r.Prototype,e.exports=r},{}],128:[function(t,e,n){"use strict";function r(t){i.call(this,t)}var c=t("../substance/util"),d=t("underscore"),i=t("lens/converter");(r.Prototype=function(){var n=i.prototype;this.test=function(t,e){return"eLife Sciences Publications, Ltd"===t.querySelector("publisher-name").textContent},this.__ignoreCustomMetaNames=["elife-xml-version"],this.enhanceArticle=function(t,e){var n,r,i=[],o=t.doc,s=e.querySelector("#SA1");s&&(n={id:t.nextId("heading"),type:"heading",level:1,content:"Article Commentary"},o.create(n),i.push(n),n={id:t.nextId("heading"),type:"heading",level:2,content:"Decision letter"},o.create(n),i.push(n),r=s.querySelector("body"),i=i.concat(this.bodyNodes(t,c.dom.getChildren(r))));var a=e.querySelector("#SA2");a&&(n={id:t.nextId("heading"),type:"heading",level:2,content:"Author response"},o.create(n),i.push(n),r=a.querySelector("body"),i=i.concat(this.bodyNodes(t,c.dom.getChildren(r)))),0<i.length&&this.show(t,i)},this.enhanceCover=function(t,e,n){var r,i=n.querySelector("subj-group[subj-group-type=display-channel] subject").textContent;try{r=n.querySelector("subj-group[subj-group-type=heading] subject").textContent}catch(t){r=null}e.breadcrumbs=[{name:"eLife",url:"http://elifesciences.org/",image:"http://lens.elifesciences.org/lens-elife/styles/elife.png"},{name:i,url:"http://elifesciences.org/category/"+i.replace(/ /g,"-").toLowerCase()}],r&&e.breadcrumbs.push({name:r,url:"http://elifesciences.org/category/"+r.replace(/ /g,"-").toLowerCase()})},this.enhanceFigure=function(t,e,n){var r=n.querySelector("graphic").getAttribute("xlink:href");e.url=this.resolveURL(t,r)},this.resolveURL=function(t,e){if(e.match(/http:\/\//))return e;var n=this.getBaseURL(t);return n?[n,e].join(""):(e.match(/\.tif$/g)?e=e.replace(/\.tif$/g,".jpg"):e.match(/\.gif$/g)||(e+=".jpg"),["https://cdn.elifesciences.org/articles/",t.doc.id,"/",e].join(""))},this.enhanceSupplement=function(t,e){var n=this.getBaseURL(t);if(n)return[n,e.url].join("");e.url=["https://cdn.elifesciences.org/articles/",t.doc.id,"/",e.url].join("")},this.enhancePublicationInfo=function(t){var e=t.xmlDoc.querySelector("article"),n=e.querySelector("article-meta"),r=t.doc.get("publication_info"),i=n.querySelectorAll("kwd-group[kwd-group-type=research-organism] kwd"),o=n.querySelectorAll("kwd-group[kwd-group-type=author-keywords] kwd"),s=n.querySelectorAll("subj-group[subj-group-type=heading] subject"),a=n.querySelector("subj-group[subj-group-type=display-channel] subject"),c=e.querySelector("self-uri[content-type=pdf]");if(c)var u=["https://cdn.elifesciences.org/articles/",t.doc.id,"/",c?c.getAttribute("xlink:href"):"#"].join("");var l=null;c&&(l=c.getAttribute("xlink:href").match(/\w*-\w*-v(\d*).pdf$/));var p=l?l[1]:1,h=[];u&&h.push({url:u,name:"PDF",type:"pdf"}),h.push({url:"https://cdn.elifesciences.org/articles/"+t.doc.id+"/elife-"+t.doc.id+"-v"+p+".xml",name:"Source XML",type:"xml"}),h.push({url:"",name:"Lens JSON",type:"json"}),r.research_organisms=d.pluck(i,"textContent"),r.keywords=d.pluck(o,"textContent"),r.subjects=d.pluck(s,"textContent"),r.article_type=a?a.textContent:"",r.links=h,r.subject_link="https://elifesciences.org/category",r.article_type_link="https://elifesciences.org/category",r.related_article&&(r.related_article="https://doi.org/"+r.related_article)},this.enhanceSupplement=function(t,e){var n=this.getBaseURL(t);if(n)return[n,e.url].join("");e.url=["https://cdn.elifesciences.org/articles/",t.doc.id,"/",e.url].join("")},this.enhanceTable=function(t,e,n){this.mapCitations(t),e.content=this.enhanceHTML(e.content)},this.mapCitations=function(t){this.citationCitationReferenceMap=[];var e=[],n=t.doc;d.each(n.nodes,function(t){"citation"==t.type&&(e[t.source_id]=t.id)}.bind(this));var r=t.annotations;d.each(r,function(t){"citation_reference"==t.type&&(this.citationCitationReferenceMap[t.target]=t.id)}.bind(this))},this.enhanceHTML=function(i){if(i=(i=(i=(i=i.replace(/<(\/)?bold>/g,"<$1strong>")).replace(/<(\/)?italic>/g,"<$1em>")).replace(/<td style=\"([^"]+)\"([^>]*)>/g,'<td class="$1"$2>')).replace(/<named-content content-type="([^"]+)"([^>]*)>([^<]*)<\/named-content>/g,'<span class="$1"$2>$3</span>'),this.citationCitationReferenceMap){var o=/<xref ref-type="bibr" rid="([^"]+)">([^<]*)<\/xref>/g,t=i.match(o);d.each(t,function(t){var e=t.replace(o,"$1"),n=t.replace(o,"$2"),r='<a href="" data-id="'+this.citationCitationReferenceMap[e]+'" class="annotation citation_reference resource-reference">'+n+"</a>";i=i.replace(t,r)}.bind(this))}return i},this.enhanceVideo=function(t,e,n){var r=n.getAttribute("xlink:href").split(".")[0];e.url="https://legacy--api.elifesciences.org/v2/articles/"+t.doc.id+"/media/file/"+r+".mp4",e.url_ogv="https://legacy--api.elifesciences.org/v2/articles/"+t.doc.id+"/media/file//"+r+".ogv",e.url_webm="https://legacy--api.elifesciences.org/v2/articles/"+t.doc.id+"/media/file//"+r+".webm",e.poster="https://legacy--api.elifesciences.org/v2/articles/"+t.doc.id+"/media/file/"+r+".jpg"},this.resolveURL=function(t,e){if(e.match(/http:\/\//))return e;var n=this.getBaseURL(t);return n?[n,e].join(""):(e.match(/\.tif$/g)?e=e.replace(/\.tif$/g,".jpg"):e.match(/\.gif$/g)||(e+=".jpg"),["https://cdn.elifesciences.org/articles/",t.doc.id,"/",e].join(""))};var o=/author-callout-style/;this.enhanceAnnotationData=function(t,e,n,r){if("named-content"===r){var i=n.getAttribute("content-type");o.test(i)&&(e.type="author_callout",e.style=i)}},this.back=function(e,t){var n=t.querySelectorAll("app-group");n&&0<n.length&&d.each(n,function(t){this.appGroup(e,t)}.bind(this))},this.showNode=function(t,e){e.type,n.showNode.apply(this,arguments)}}).prototype=i.prototype,(r.prototype=new r.Prototype).constructor=r,e.exports=r},{"../substance/util":183,"lens/converter":129,underscore:131}],129:[function(t,e,n){"use strict";var r=t("./lens_converter");e.exports=r},{"./lens_converter":130}],130:[function(t,e,n){"use strict";var b=t("underscore"),f=t("../substance/util"),s=f.errors.define("ImporterError"),r=t("../article"),i=function(t){this.options=t||i.DefaultOptions};i.Prototype=function(){this._annotationTypes={bold:"strong",italic:"emphasis",monospace:"code",sub:"subscript",sup:"superscript",sc:"capitalize",underline:"underline",strike:"strike","ext-link":"link",xref:"",email:"link","named-content":"","inline-formula":"inline-formula",uri:"link"},this._refTypeMapping={bibr:"citation_reference",fn:"footnote_reference",fig:"figure_reference",table:"figure_reference","supplementary-material":"figure_reference",other:"figure_reference",list:"definition_reference"},this._contribTypeMapping={author:"Author","author non-byline":"Author",autahor:"Author",auther:"Author",editor:"Editor","guest-editor":"Guest Editor","group-author":"Group Author",collab:"Collaborator","reviewed-by":"Reviewer","nominated-by":"Nominator",corresp:"Corresponding Author",other:"Other","assoc-editor":"Associate Editor","associate editor":"Associate Editor","series-editor":"Series Editor",contributor:"Contributor",chairman:"Chairman","monographs-editor":"Monographs Editor","contrib-author":"Contributing Author",organizer:"Organizer",chair:"Chair",discussant:"Discussant",presenter:"Presenter","guest-issue-editor":"Guest Issue Editor",participant:"Participant",translator:"Translator","section-editor":"Section Editor","section-author":"Section Author","chapter-author":"Chapter Author"},this.isAnnotation=function(t){return void 0!==this._annotationTypes[t]},this.isParagraphish=function(t){for(var e=0;e<t.childNodes.length;e++){var n=t.childNodes[e];if(n.nodeType!==Node.TEXT_NODE&&!this.isAnnotation(n.tagName.toLowerCase()))return!1}return!0},this.test=function(t,e){return!0},this.getName=function(t){if(!t)return"N/A";var e=[],n=t.querySelector("surname"),r=t.querySelector("given-names"),i=t.querySelector("suffix");return r&&e.push(r.textContent),n&&e.push(n.textContent),i?[e.join(" "),i.textContent].join(", "):e.join(" ")},this.toHtml=function(t){if(!t)return"";var e=document.createElement("DIV");return e.appendChild(t.cloneNode(!0)),e.innerHTML},this.mmlToHtmlString=function(t){var e=this.toHtml(t);return e=e.replace(/<(\/)?mml:([^>]+)>/g,"<$1$2>")},this.selectDirectChildren=function(t,e){for(var n=[],r=t.querySelectorAll(e),i=0;i<r.length;i++){var o=r[i];o.parentElement===t&&n.push(o)}return n},this.import=function(t){var e;b.isString(t)?e=(new DOMParser).parseFromString(t,"text/xml"):e=t;this.sanitizeXML(e);var n=this.createDocument();window.doc=n;var r=this.createState(e,n);return this.document(r,e)},this.sanitizeXML=function(t){},this.createState=function(t,e){return new i.State(this,t,e)},this.createDocument=function(){return new r},this.show=function(e,t){b.each(t,function(t){this.showNode(e,t)},this)},this.extractDate=function(t){if(!t)return null;var e=t.querySelector("year"),n=t.querySelector("month"),r=t.querySelector("day"),i=null!==e?[e.textContent]:[];return n&&i.push(n.textContent),r&&i.push(r.textContent),i.join("-")},this.extractURLSuffix=function(t){return t=t.replace("https://doi.org/","")},this.extractPublicationInfo=function(t,e){for(var n=t.doc,r=e.querySelector("article-meta"),i=r.querySelector("pub-date"),o=r.querySelectorAll("history date"),s=e.querySelector("journal-title"),a=e.querySelector("article-id[pub-id-type=doi]"),c=e.querySelector("related-article"),u=this.extractArticleInfo(t,e),l={id:"publication_info",type:"publication_info",published_on:this.extractDate(i),journal:s?s.textContent:"",related_article:c?c.getAttribute("xlink:href"):"",doi:a?this.extractURLSuffix(a.textContent):"",article_info:u.id,article_type:"",keywords:[],links:[],subjects:[],supplements:[],history:[],research_organisms:[],provider:""},p=0;p<o.length;p++){var h=o[p],d={type:h.getAttribute("date-type"),date:this.extractDate(h)};l.history.push(d)}n.create(l),n.show("info",l.id,0),this.enhancePublicationInfo(t,l)},this.extractArticleInfo=function(t,e){var n={id:"articleinfo",type:"paragraph"},r=t.doc,i=[];return i=(i=(i=(i=(i=(i=i.concat(this.extractEditor(t,e))).concat(this.extractDatasets(t,e))).concat(this.extractCustomMetaGroup(t,e))).concat(this.extractAcknowledgements(t,e))).concat(this.extractCopyrightAndLicense(t,e))).concat(this.extractNotes(t,e)),n.children=i,r.create(n),n},this.extractEditor=function(t,e){var n=[],r=t.doc,i=e.querySelector("contrib[contrib-type=editor]");if(i){var o=[],s=this.getName(i.querySelector("name"));s&&o.push(s);var a=i.querySelector("institution");a&&o.push(a.textContent);var c=i.querySelector("country");c&&o.push(c.textContent);var u={type:"heading",id:t.nextId("heading"),level:3,content:"Reviewing Editor"};r.create(u),n.push(u.id);var l={type:"text",id:t.nextId("text"),content:o.join(", ")};r.create(l),n.push(l.id)}return n},this.extractDatasets=function(t,e){for(var n=[],r=t.doc,i=e.querySelectorAll("sec"),o=0;o<i.length;o++){var s=i[o];if("datasets"===s.getAttribute("sec-type")){var a={type:"heading",id:t.nextId("heading"),level:3,content:"Major Datasets"};r.create(a),n.push(a.id);for(var c=this.datasets(t,f.dom.getChildren(s)),u=0;u<c.length;u++)c[u]&&n.push(c[u])}}return n};var n=function(t,e){return e?t.split(" ").map(function(t){return n(t)}).join(" "):t.charAt(0).toUpperCase()+t.slice(1)};this.capitalized=function(t,e){return n(t,e)},this.extractAcknowledgements=function(i,t){var o=[],s=i.doc,e=t.querySelectorAll("ack");return e&&0<e.length&&b.each(e,function(t){var e=t.querySelector("title"),n={type:"heading",id:i.nextId("heading"),level:3,content:e?this.capitalized(e.textContent.toLowerCase(),"all"):"Acknowledgements"};s.create(n),o.push(n.id);var r=this.bodyNodes(i,f.dom.getChildren(t),{ignore:["title"]});b.each(r,function(t){o.push(t.id)})},this),o},this.extractNotes=function(){return[]},this.__ignoreCustomMetaNames=[],this.extractCustomMetaGroup=function(t,e){var n=[],r=t.doc,i=e.querySelectorAll("article-meta-group custom-meta");if(0===i.length)return n;for(var o=0;o<i.length;o++){var s=i[o],a=s.querySelector("meta-name"),c=s.querySelector("meta-value");if(!b.include(this.__ignoreCustomMetaNames,a.textContent)){var u={type:"heading",id:t.nextId("heading"),level:3,content:""};u.content=this.annotatedText(t,a,[u.id,"content"]),r.create(u);var l=this.paragraphGroup(t,c);n.push(u.id),n=n.concat(b.pluck(l,"id"))}}return n},this.extractCopyrightAndLicense=function(t,e){var n=[],r=t.doc,i=e.querySelector("permissions");if(i){var o,s={type:"heading",id:t.nextId("heading"),level:3,content:"Copyright & License"};r.create(s),n.push(s.id);var a,c=i.querySelector("copyright-statement");if(c&&(o=this.paragraphGroup(t,c))&&o.length&&(n=n.concat(b.map(o,function(t){return t.id})),"."!==c.textContent.trim().slice(-1))){var u=b.last(b.last(o).children);r.nodes[u].content+=". "}var l=i.querySelectorAll("license");for(a=0;a<l.length;a++)if((1==l[a].length||"en"==l[a].getAttribute("xml:lang"))&&l[a])for(var p=l[a].firstElementChild;p;p=p.nextElementSibling){var h=f.dom.getNodeType(p);"p"!==h&&"license-p"!==h||(o=this.paragraphGroup(t,p))&&o.length&&(n=n.concat(b.pluck(o,"id")))}}return n},this.extractCover=function(o,t){var s=o.doc,e=s.get("document"),n=t.querySelector("article-meta"),r=this._abstract(o,n),a={id:"cover",type:"cover",title:e.title,authors:[],abstract:void 0!==r?r.id:""},c=!1;b.each(e.authors,function(t){s.get(t).contributor_type.toLowerCase()==="Translator".toLowerCase()&&(c=!0)},this),b.each(e.authors,function(t){var e=s.get(t),n=e.name;!0===c&&(n+="("+e.contributor_type+")");var r={id:"text_"+t+"_reference",type:"text",content:n};s.create(r),a.authors.push(r.id);var i={id:o.nextId("contributor_reference"),type:"contributor_reference",path:["text_"+t+"_reference","content"],range:[0,n.length],target:t};s.create(i)},this),this.enhanceCover(o,a,t),s.create(a),s.show("content",a.id,0)},this.contribGroup=function(t,e){var n,r=[],i=e.querySelectorAll("contrib");for(n=0;n<i.length;n++){var o=this.contributor(t,i[n]);r.push(o)}var s=t.doc,a=e.querySelector("on-behalf-of");return a&&(s.on_behalf_of=a.textContent.trim()),r},this.affiliation=function(t,e){var n=t.doc,r=e.querySelector("institution"),i=e.querySelector("country"),o=e.querySelector("label"),s=e.querySelector("addr-line named-content[content-type=department]"),a=e.querySelector("addr-line named-content[content-type=city]"),c={id:t.nextId("affiliation"),type:"affiliation",source_id:e.getAttribute("id"),label:o?o.textContent:null,department:s?s.textContent:null,city:a?a.textContent:null,institution:r?r.textContent:null,country:i?i.textContent:null};n.create(c)},this.contributor=function(i,t){var e=i.doc,n=i.nextId("contributor"),o={id:n,source_id:t.getAttribute("id"),type:"contributor",name:"",affiliations:[],fundings:[],bio:[],image:"",deceased:!1,emails:[],contribution:"",members:[]},r=t.getAttribute("contrib-type");o.contributor_type=this._contribTypeMapping[r];var s=t.querySelector("role");s&&(o.role=s.textContent);var a=t.querySelector("bio");a&&b.each(f.dom.getChildren(a),function(t){var e=t.querySelector("graphic");if(e){var n=e.getAttribute("xlink:href");o.image=n}else{var r=this.paragraphGroup(i,t);0<r.length&&(o.bio=[r[0].id])}},this),"yes"===t.getAttribute("deceased")&&(o.deceased=!0);var c=t.querySelector("uri[content-type=orcid]");c&&(o.orcid=c.getAttribute("xlink:href"));var u=t.querySelector("name");if(u)o.name=this.getName(u);else{var l=t.querySelector("collab");o.name=l?l.textContent:"N/A"}return this.extractContributorProperties(i,t,o),0===o.affiliations.length&&(o.affiliations=i.affiliations),1<o.competing_interests.length&&(o.competing_interests=b.filter(o.competing_interests,function(t){return t.indexOf("no competing")<0})),"author"===t.getAttribute("contrib-type")&&e.nodes.document.authors.push(n),"editor"===t.getAttribute("contrib-type")&&e.nodes.document.authors.push(n),"translator"===t.getAttribute("contrib-type")&&e.nodes.document.authors.push(n),"section-editor"===t.getAttribute("contrib-type")&&e.nodes.document.authors.push(n),"section-author"===t.getAttribute("contrib-type")&&e.nodes.document.authors.push(n),"chapter-author"===t.getAttribute("contrib-type")&&e.nodes.document.authors.push(n),e.create(o),e.show("info",o.id),o},this._getEqualContribs=function(t,n,e){var r=[],i=t.xmlDoc.querySelectorAll("xref[rid="+e+"]");return b.each(i,function(t){var e=t.parentNode;e!==n&&r.push(this.getName(e.querySelector("name")))},this),r},this.extractContributorProperties=function(d,f,g){var y=d.doc,m=[],v=[],t=f.querySelectorAll("xref");b.each(t,function(t){if("aff"===t.getAttribute("ref-type")){var e=t.getAttribute("rid"),n=y.getNodeBySourceId(e);n&&(g.affiliations.push(n.id),d.used[e]=!0)}else if("other"===t.getAttribute("ref-type")){console.log("FIXME: please add documentation about using 'other' as indicator for extracting an awardGroup.");var r=d.xmlDoc.getElementById(t.getAttribute("rid"));if(!r)return;var i=r.querySelector("funding-source");if(!i)return;var o=r.querySelector("award-id");o=o?", "+o.textContent:"";var s=i.childNodes[0].textContent;g.fundings.push([s,o].join(""))}else if("corresp"===t.getAttribute("ref-type")){var a=t.getAttribute("rid"),c=d.xmlDoc.getElementById(a);if(!c)return;var u=c.querySelector("email");if(!u)return;g.emails.push(u.textContent)}else if("fn"===t.getAttribute("ref-type")){var l=t.getAttribute("rid"),p=d.xmlDoc.getElementById(l),h=!0;if(p){switch(p.getAttribute("fn-type")){case"con":g.contribution=p.textContent;break;case"conflict":v.push(p.textContent.trim());break;case"present-address":g.present_address=p.querySelector("p").textContent;break;case"equal":console.log("FIXME: isn't fnElem.getAttribute(id) === fnId?"),m=this._getEqualContribs(d,f,p.getAttribute("id"));break;case"other":console.log("FIXME: isn't fnElem.getAttribute(id) === fnId?"),0<=p.getAttribute("id").indexOf("equal-contrib")?m=this._getEqualContribs(d,f,p.getAttribute("id")):h=!1;break;default:h=!1}h&&(d.used[l]=!0)}}else console.log("Skipping contrib's xref",t.textContent)},this),1<v.length&&(v=b.filter(v,function(t){return t.indexOf("no competing")<0})),g.competing_interests=v;var e=f.querySelector("xref[ref-type=other]");if(e){var n=e.getAttribute("rid"),r=d.xmlDoc.querySelectorAll("#"+n+" contrib");g.members=b.map(r,function(t){return this.getName(t.querySelector("name"))},this)}g.equal_contrib=m,g.competing_interests=v},this.document=function(t,e){var n=t.doc,r=e.querySelector("article");if(!r)throw new s("Expected to find an 'article' element.");return this.article(t,r),this.postProcess(t),b.each(n.containers,function(t){t.rebuild()}),n},this.postProcess=function(t){this.postProcessAnnotations(t)},this.postProcessAnnotations=function(t){for(var e=0;e<t.annotations.length;e++){var n=t.annotations[e];if(n.target){var r=t.doc.getNodeBySourceId(n.target);r&&(n.target=r.id)}t.doc.create(t.annotations[e])}},this.article=function(t,e){var n=t.doc,r=e.querySelector("article-id");n.id=r?r.textContent:f.uuid(),this.extractDefinitions(t,e),this.extractAffilitations(t,e),this.extractContributors(t,e),this.extractCitations(t,e),this.extractFootnotes(t,e),this.extractCover(t,e),this.extractArticleMeta(t,e),this.extractPublicationInfo(t,e);var i=e.querySelector("body");i&&this.body(t,i),this.extractFigures(t,e),this.enhanceArticle(t,e)},this.extractDefinitions=function(i){var t=i.xmlDoc.querySelectorAll("def-item");b.each(t,function(t){var e=t.querySelector("term"),n=t.querySelector("def"),r={id:n.id||n.getAttribute("hwp:id")||i.nextId("definition"),type:"definition",title:e.textContent,description:n.textContent};i.doc.create(r),i.doc.show("definitions",r.id)})},this.extractArticleMeta=function(t,e){var n=e.querySelector("article-meta");if(!n)throw new s("Expected element: 'article-meta'");var r=n.querySelectorAll("article-id");this.articleIds(t,r);var i=n.querySelector("title-group");i&&this.titleGroup(t,i);var o=n.querySelectorAll("pub-date");this.pubDates(t,o)},this.extractAffilitations=function(t,e){for(var n=e.querySelectorAll("aff"),r=0;r<n.length;r++)this.affiliation(t,n[r])},this.extractContributors=function(t,e){var n=e.querySelector("contrib-group");n&&this.contribGroup(t,n)},this.extractFigures=function(t,e){for(var n=e.querySelector("body").querySelectorAll("fig, table-wrap, supplementary-material, media[mimetype=video]"),r=[],i=0;i<n.length;i++){var o=n[i];if(!o._converted){var s=f.dom.getNodeType(o),a=null;"fig"===s?a=this.figure(t,o):"table-wrap"===s||("media"===s?a=this.video(t,o):"supplementary-material"===s&&(a=this.supplement(t,o))),a&&r.push(a)}}this.show(t,r)},this.extractCitations=function(t,e){var n=e.querySelector("ref-list");n&&this.refList(t,n)},this.extractFootnotes=function(t,e){var n=e.querySelector("fn-group");n&&this.fnList(t,n)},this.articleIds=function(t,e){var n=t.doc;0<e.length?n.id=e[0].textContent:n.id=f.uuid()},this.titleGroup=function(t,e){var n=t.doc,r=e.querySelector("article-title");r&&(n.title=this.annotatedText(t,r,["document","title"],{ignore:["xref"]}))},this.pubDates=function(t,e){var n=t.doc;if(0<e.length){var r=this.pubDate(t,e[0]);n.created_at=r.date}},this.pubDate=function(t,e){var r=-1,i=-1,o=-1;return b.each(f.dom.getChildren(e),function(t){var e=f.dom.getNodeType(t),n=t.textContent;"day"===e?r=parseInt(n,10):"month"===e?i=parseInt(n,10):"year"===e&&(o=parseInt(n,10))},this),{date:new Date(o,i,r)}},this.abstracts=function(e,t){var n=t.querySelectorAll("abstract");b.each(n,function(t){this.abstract(e,t)},this)},this._abstract=function(n,t){var e=t.querySelector("title"),r=n.doc,i={id:n.nextId("abstract"),type:"abstract",label:"",title:"",children:[]};if(null!==e&&0<e.textContent.length){for(var o=new f.dom.ChildNodeIterator(e);o.hasNext();){var s=o.next(),a=f.dom.getNodeType(s);if("text"===a||this.isAnnotation(a))var c={id:n.nextId("text"),type:"text",content:null}}n.stack.push({path:[c.id,"content"]});var u=this._annotatedText(n,o.back(),{offset:0,breakOnUnknown:!0});0<u.length&&(c.content=u,r.create(c)),i.title=c.id}var l=[],p=t.querySelectorAll("p");return b.each(p,function(t){var e=this.paragraph(n,t);e&&l.push(e.id)},this),0<p.length&&(i.children=l,r.create(i)),i},this.body=function(t,e){var n=t.doc,r={id:t.nextId("heading"),type:"heading",level:1,content:""};n.create(r);var i=[r].concat(this.bodyNodes(t,f.dom.getChildren(e)));0<i.length&&this.show(t,i)},this._ignoredBodyNodes={fig:!0,table:!0,speaker:!0},this._bodyNodes={},this.bodyNodes=function(t,e,n){for(var r,i=[],o=0;o<e.length;o++){var s=e[o],a=f.dom.getNodeType(s);if(this._bodyNodes[a]){var c=this._bodyNodes[a].call(this,t,s);b.isArray(c)?i=i.concat(c):c&&i.push(c)}else this._ignoredBodyNodes[a]||n&&n.ignore&&0<=n.ignore.indexOf(a)?(r=this.ignoredNode(t,s,a))&&i.push(r):console.warn("Node not yet supported as top-level node: "+a)}return i},this._bodyNodes.p=function(t,e){return this.paragraphGroup(t,e)},this._bodyNodes.sec=function(t,e){return this.section(t,e)},this._bodyNodes.list=function(t,e){return this.list(t,e)},this._bodyNodes["disp-formula"]=function(t,e){return this.formula(t,e)},this._bodyNodes.caption=function(t,e){return this.caption(t,e)},this._bodyNodes["boxed-text"]=function(t,e){return this.boxedText(t,e)},this._bodyNodes["disp-quote"]=function(t,e){return this.quoteText(t,e)},this._bodyNodes.attrib=function(t,e){return this.paragraphGroup(t,e)},this._bodyNodes.comment=function(t,e){return this.comment(t,e)},this._bodyNodes.fig=function(t,e){return this.figure(t,e)},this._bodyNodes.speech=function(t,e){return this.speechText(t,e)},this._bodyNodes["table-wrap"]=function(t,e){return this.tableWrap(t,e)},this._bodyNodes["sec-meta"]=function(t,e){return this.secMeta(t,e)},this._bodyNodes.abstract=function(t,e){return this._abstract(t,e)},this._bodyNodes["contrib-group"]=function(t,e){return this.contribGroup(t,e)},this.secMeta=function(o,t){var s,a=o.doc,e=a.get("document"),c=this.bodyNodes(o,f.dom.getChildren(t)),u={id:o.nextId("sec_meta"),type:"sec_meta",children:b.pluck(c,"id"),authors:[],abstract:[]},l=["Section Editor","Section Author","Translator","Chapter Author"],p=!1;return b.each(e.authors,function(t){a.get(t).contributor_type.toLowerCase()==="Translator".toLowerCase()&&(p=!0)},this),b.each(e.authors,function(t){var e=a.get(t),n=e.name;for(!0===p&&(n+=" ("+e.contributor_type+")"),s=0;s<l.length;s++)if(e.contributor_type===l[s]){var r={id:"text_"+t+"_reference",type:"text",content:n},i={id:o.nextId("contributor_reference"),type:"contributor_reference",path:["text_"+t+"_reference","content"],range:[0,n.length],target:t};b.each(c,function(t){"contributor"===t.type&t.id===e.id&&(a.create(r),u.authors.push(r.id),a.create(i))},this)}},this),b.each(c,function(t){"abstract"===t.type&&u.abstract.push(t.id)},this),a.create(u),u},this.ignoredNode=function(){},this.comment=function(){return null},this.boxedText=function(t,e){var n=t.doc,r=this.bodyNodes(t,f.dom.getChildren(e)),i={type:"box",id:t.nextId("box"),source_id:e.getAttribute("id"),label:"",children:b.pluck(r,"id")};return n.create(i),i},this.childNodes=function(t,e){for(var n=[],r=0;r<e.length;r++){var i=e[r],o=f.dom.getNodeType(i);if(this.childNodes[o]){var s=this.childNodes[o].call(this,t,i);b.isArray(s)?n=n.concat(s):s&&n.push(s)}}return n},this.speakerName=function(t,e){return{type:"speaker",label:"Speaker",children:e.innerHTML}},this.quoteText=function(t,e){var n=t.doc,r=this.bodyNodes(t,f.dom.getChildren(e)),i={type:"quote",id:t.nextId("quote"),source_id:e.getAttribute("id"),label:"",children:b.pluck(r,"id")};return n.create(i),i},this.speechText=function(t,e){var n=t.doc,r=this.bodyNodes(t,f.dom.getChildren(e)),i={type:"speech",id:t.nextId("speech"),source_id:e.getAttribute("id"),label:"",speaker:e.querySelectorAll("speaker"),children:b.pluck(r,"id")};return n.create(i),i},this.datasets=function(t,e){for(var n=[],r=0;r<e.length;r++){var i=e[r];if("p"===f.dom.getNodeType(i)){var o=i.querySelector("related-object");if(o)n=n.concat(this.indivdata(t,o));else{var s=this.paragraphGroup(t,i);0<s.length&&n.push(s[0].id)}}}return n},this.indivdata=function(t,e){var n=t.doc,r={type:"paragraph",id:t.nextId("paragraph"),children:[]},i={type:"text",id:t.nextId("text"),content:""};r.children.push(i.id);for(var o=f.dom.getChildren(e),s=0;s<o.length;s++){var a,c=o[s];if("name"===f.dom.getNodeType(c))for(var u=f.dom.getChildren(c),l=0;l<u.length;l++){var p=u[l];if(0===l)a=this.paragraphGroup(t,p),r.children.push(a[0].children[0]);else{var h={type:"text",id:t.nextId("text"),content:", "};n.create(h),r.children.push(h.id),a=this.paragraphGroup(t,p),r.children.push(a[0].children[0])}}else(a=this.paragraphGroup(t,c))&&a[0]&&a[0].children&&r.children.push(a[0].children[0])}return n.create(r),n.create(i),r.id},this.section=function(t,e){t.sectionLevel++;var n=t.doc,r=f.dom.getChildren(e),i=[],o=this.selectDirectChildren(e,"label")[0],s=this.selectDirectChildren(e,"title")[0];if(s||console.warn("FIXME: every section should have a title",this.toHtml(e)),0<(i=i.concat(this.bodyNodes(t,r,{ignore:["title","label","sec-meta"]}))).length&&s){var a=t.nextId("heading"),c={id:a,source_id:e.getAttribute("id"),type:"heading",level:t.sectionLevel,content:s?this.annotatedText(t,s,[a,"content"]):"",authors:[]};if(1<c.content.length){var u=this.selectDirectChildren(e,"sec-meta")[0];if(void 0!==u)for(var l=u.querySelector("contrib-group").querySelectorAll("contrib"),p=0;p<l.length;p++){var h=l[p].querySelector("name");if(h){var d=this.getName(h);c.authors.push(d)}}}o&&(c.label=o.textContent),0<c.content.length&&(n.create(c),i.unshift(c))}else 0===i.length&&console.info("NOTE: skipping section without content:",s?s.innerHTML:"no title");return t.sectionLevel--,i},this.ignoredParagraphElements={comment:!0,"supplementary-material":!0,fig:!0,"fig-group":!0,media:!0},this.acceptedParagraphElements={"boxed-text":{handler:"boxedText"},"disp-quote":{handler:"quoteText"},list:{handler:"list"},"disp-formula":{handler:"formula"},speech:{handler:"speechText"},"table-wrap":{handler:"tableWrap"}},this.inlineParagraphElements={"inline-graphic":!0,"inline-formula":!0},this.segmentParagraphElements=function(t){for(var e=[],n="",r=new f.dom.ChildNodeIterator(t);r.hasNext();){var i=r.next(),o=f.dom.getNodeType(i);this.ignoredParagraphElements[o]||("text"===o||this.isAnnotation(o)||this.inlineParagraphElements[o]?("paragraph"!==n&&(e.push({handler:"paragraph",nodes:[]}),n="paragraph"),b.last(e).nodes.push(i)):(this.acceptedParagraphElements[o]&&e.push(b.extend({node:i},this.acceptedParagraphElements[o])),n=o))}return e},this.paragraphGroup=function(t,e){for(var n=[],r=this.segmentParagraphElements(e),i=0;i<r.length;i++){var o,s=r[i];"paragraph"===s.handler?(o=this.paragraph(t,s.nodes))&&(o.source_id=e.getAttribute("id"),o.attributes=e.attributes):o=this[s.handler](t,s.node),o&&n.push(o)}return n},this.paragraph=function(t,e){var n=t.doc;t.skipWS=!0;for(var r={id:t.nextId("paragraph"),type:"paragraph",children:null},i=[],o=new f.dom.ChildNodeIterator(e);o.hasNext();){var s=o.next(),a=f.dom.getNodeType(s);if("text"===a||this.isAnnotation(a)){var c={id:t.nextId("text"),type:"text",content:null};t.stack.push({path:[c.id,"content"]});var u=this._annotatedText(t,o.back(),{offset:0,breakOnUnknown:!0});0<u.length&&(c.content=u,n.create(c),i.push(c)),t.stack.pop()}else if("inline-graphic"===a){var l=s.getAttribute("xlink:href"),p={id:t.nextId("image"),type:"image",url:this.resolveURL(t,l)};n.create(p),i.push(p)}else if("inline-formula"===a){var h=this.formula(t,s,"inline");h?i.push(h):"table-wrap"===a&&this.tableWrap(t,s)}}return 0===i.length?null:(r.children=b.map(i,function(t){return t.id}),n.create(r),r)},this.list=function(t,e){var n=t.doc,r={id:t.nextId("list"),source_id:e.getAttribute("id"),type:"list",items:[],item_ids:[],ordered:!1,list_type:""},i=e.getAttribute("list-type"),o=["alpha-lower","alpha-upper","ordered","roman-lower","roman-upper"];for(a=0;a<o.length;a++)i===o[a]&&(r.ordered=!0);r.list_type=e.getAttribute("list-type");for(var s=e.querySelectorAll("list-item"),a=0;a<s.length;a++){var c=s[a];if(c.parentNode===e)for(var u=this.bodyNodes(t,f.dom.getChildren(c)),l=0;l<u.length;l++)r.items.push(u[l].id),r.item_ids.push(a)}return n.create(r),r},this.figure=function(t,e){var n=t.doc,r={type:"figure",id:t.nextId("figure"),source_id:e.getAttribute("id"),label:"Figure",url:"",caption:null},i=e.querySelector("label");i&&(r.label=this.annotatedText(t,i,[r.id,"label"]));var o=e.querySelector("caption");if(o){var s=this.caption(t,o);s&&(r.caption=s.id)}var a=e.querySelector("attrib");a&&(r.attrib=a.textContent);var c=e.getAttribute("position");return c&&(r.position=c||""),this.enhanceFigure(t,r,e),n.create(r),e._converted=!0,r},this.supplement=function(t,e){var n=t.doc,r=e.querySelector("label"),i=e.querySelector("media"),o=i?i.getAttribute("xlink:href"):null,s=e.querySelector("object-id[pub-id-type='doi']");s=s?s.textContent:"";var a={id:t.nextId("supplement"),source_id:e.getAttribute("id"),type:"supplement",label:r?r.textContent:"",url:o,caption:null},c=e.querySelector("caption");if(c){var u=this.caption(t,c);u&&(a.caption=u.id)}return this.enhanceSupplement(t,a,e),n.create(a),a},this.caption=function(n,r){var t=n.doc,e={id:n.nextId("caption"),source_id:r.getAttribute("id"),type:"caption",title:"",children:[]},i=r.querySelector("title");if(i){var o=this.paragraph(n,i);o&&(e.title=o.id)}var s=[],a=r.querySelectorAll("p");return b.each(a,function(t){if(t.parentNode===r){var e=this.paragraph(n,t);e&&s.push(e.id)}},this),e.children=s,t.create(e),e},this.video=function(t,e){var n=t.doc,r=e.querySelector("label").textContent,i={id:t.nextId("video"),source_id:e.getAttribute("id"),type:"video",label:r,title:"",caption:null,poster:""},o=e.querySelector("caption");if(o){var s=this.caption(t,o);s&&(i.caption=s.id)}var a=e.querySelector("object-id");return a&&"poster"===a.getAttribute("specific-use")&&(i.poster=a.textContent),this.enhanceVideo(t,i,e),n.create(i),i},this.tableWrap=function(t,e){for(var n=t.doc,r=e.querySelector("label"),i=e.querySelector("table"),o={},s={},a={},c=i.children,u=0;u<c.length;u++){for(var l=c[u].children,p=0;p<l.length;p++){for(var h=l[p].childNodes,d=0;d<h.length;d++){var f=h[d];if(a[d]={},"#text"===f.nodeName){var g=f.data.trim();if(0<g.length){var y=document.createElement("p"),m=document.createTextNode(g);y.appendChild(m),a[d].nodes=this.paragraphGroup(t,y)}}else"p"===f.nodeName&&(a[d].nodes=this.paragraphGroup(t,f));a[d].attributes=l[p].attributes}s[p]=a,a={}}o[u]=s,s={}}var v={id:t.nextId("table"),source_id:e.getAttribute("id"),type:"table",title:"",label:r?r.textContent:"Table",children:o,table_attributes:i.attributes,caption:null,footers:[]};return this.extractTableCaption(t,v,e),n.create(v),v},this.extractTableCaption=function(t,e,n){var r=n.querySelector("caption");if(r){var i=this.caption(t,r);i&&(e.caption=i.id)}else console.warn("caption node not found for",n)},this._getFormulaData=function(t){for(var e=[],n=t.firstElementChild;n;n=n.nextElementSibling){var r=f.dom.getNodeType(n);switch(r){case"graphic":case"inline-graphic":e.push({format:"image",data:n.getAttribute("xlink:href")});break;case"svg":e.push({format:"svg",data:this.toHtml(n)});break;case"mml:math":case"math":e.push({format:"mathml",data:this.mmlToHtmlString(n)});break;case"tex-math":e.push({format:"latex",data:n.textContent});break;case"label":break;default:console.warn("Unsupported formula element of type "+r)}}return e},this.formula=function(t,e,n){var r=t.doc,i={id:t.nextId("formula"),source_id:e.getAttribute("id"),type:"formula",label:"",inline:!!n,data:[],format:[]},o=e.querySelector("label");o&&(i.label=o.textContent);for(var s=this._getFormulaData(e,n),a=0;a<s.length;a++)i.format.push(s[a].format),i.data.push(s[a].data);return r.create(i),i},this.fnList=function(t,e){for(var n=e.querySelectorAll("fn"),r=0;r<n.length;r++)this.fn(t,n[r])},this.rererenceTypes={p:!0},this.fn=function(t,e){var n=f.dom.getChildren(e);null!==n&&this.footnote(t,e,n)},this.footnote=function(t,e,n){var r,i,o,s,a,c=t.doc,u=[],l=t.nextId("article_footnote");for(a=0;a<n.length;a++){var p=n[a];u.push(this.segmentParagraphElements(p))}for(r={id:l,source_id:e.getAttribute("id"),type:"footnote",text:"N/A",label:"",authors:[],doi:"",source:"",volume:"",fpage:"",lpage:"",citation_urls:[]},i=0;i<u.length;i++){var h=u[i];for(o=0;o<h.length;o++){var d=h[o].nodes;if(void 0!==d)for(s=0;s<d.length;s++)if("xref"==d[s].tagName){var f=d[s].getAttribute("rid"),g=t.doc.getNodeBySourceId(f);void 0!==g&&(d[s].target=g.properties.id)}}}return r.text=u,c.create(r),c.show("footnotes",l),r},this.citationTypes={"mixed-citation":!0,"element-citation":!0},this.refList=function(t,e){for(var n=e.querySelectorAll("ref"),r=0;r<n.length;r++)this.ref(t,n[r])},this.ref=function(t,e){for(var n=f.dom.getChildren(e),r=0;r<n.length;r++){var i=n[r],o=f.dom.getNodeType(i);this.citationTypes[o]?this.citation(t,e,i):"label"===o||console.warn("Not supported in 'ref': ",o)}},this.citation=function(t,e,n){var r,i=t.doc,o=t.nextId("article_citation"),s=n.querySelector("person-group");if(s){r={id:o,source_id:e.getAttribute("id"),type:"citation",title:"N/A",label:"",authors:[],doi:"",source:"",volume:"",fpage:"",lpage:"",citation_urls:[]};var a=s.querySelectorAll("name");for(w=0;w<a.length;w++)r.authors.push(this.getName(a[w]));var c=s.querySelectorAll("collab");for(w=0;w<c.length;w++)r.authors.push(c[w].textContent);var u=n.querySelector("source");u&&(r.source=u.textContent);var l=n.querySelector("article-title");if(l)r.title=this.annotatedText(t,l,[o,"title"]);else{var p=n.querySelector("comment");p?r.title=this.annotatedText(t,p,[o,"title"]):u?r.title=this.annotatedText(t,u,[o,"title"]):console.warn("FIXME: this citation has no title",n)}var h=n.querySelector("volume");h&&(r.volume=h.textContent);var d=n.querySelector("publisher-loc");d&&(r.publisher_location=d.textContent);var f=n.querySelector("publisher-name");f&&(r.publisher_name=f.textContent);var g=n.querySelector("fpage");g&&(r.fpage=g.textContent);var y=n.querySelector("lpage");y&&(r.lpage=y.textContent);var m=n.querySelector("year");m&&(r.year=m.textContent);var v=e.querySelector("label");v&&(r.label=v.textContent);var b=n.querySelector("pub-id[pub-id-type='doi'], ext-link[ext-link-type='doi']");b&&(r.doi=b.textContent)}else{var w,_,x=this.segmentParagraphElements(n);for(w=0;w<x.length;w++){var C=x[w];for(_=0;_<C.nodes.length;_++)if("xref"==C.nodes[_].tagName){var P=C.nodes[_].getAttribute("rid"),N=t.doc.getNodeBySourceId(P);void 0!==N&&(C.nodes[_].target=N.properties.id)}}r={id:o,source_id:e.getAttribute("id"),type:"mixed_citation",text:x,doi:""}}return i.create(r),i.show("citations",o),r},this.back=function(){return null},this.createAnnotation=function(t,e,n,r){if(n!==r){var i=e.tagName.toLowerCase(),o={type:"annotation",path:b.last(t.stack).path,range:[n,r]};this.addAnnotationData(t,o,e,i),this.enhanceAnnotationData(t,o,e,i),o.id=t.nextId(o.type),t.annotations.push(o)}},this.addAnnotationData=function(t,e,n,r){if(e.type=this._annotationTypes[r]||"annotation","xref"===r)this.addAnnotationDataForXref(t,e,n);else if("ext-link"===r||"uri"===r){e.url=n.getAttribute("xlink:href");var i=n.getAttribute("ext-link-type")||"";"uri"!==r&&"uri"!==i.toLowerCase()||/^\w+:\/\//.exec(e.url)||/^\//.exec(e.url)?i.toLowerCase():e.url="http://"+e.url}else if("email"===r)e.url="mailto:"+n.textContent.trim();else if("inline-graphic"===r)e.url=n.getAttribute("xlink:href");else if("inline-formula"===r){var o=this.formula(t,n,"inline");e.target=o.id}},this.addAnnotationDataForXref=function(t,e,n){var r=n.getAttribute("ref-type"),i=n.getAttribute("rid");e.type=this._refTypeMapping[r]||"cross_reference",i&&(e.target=i)},this.annotatedText=function(t,e,n,r){r=r||{},t.stack.push({path:n,ignore:r.ignore});var i=new f.dom.ChildNodeIterator(e),o=this._annotatedText(t,i,r);return t.stack.pop(),o},this._annotatedText=function(t,e,n){for(var r="",i=void 0===n.offset?0:n.offset,o=!!n.nested,s=!!n.breakOnUnknown;e.hasNext();){var a=e.next();if(a.nodeType===Node.TEXT_NODE){var c=t.acceptText(a.textContent);r+=c,i+=c.length}else{var u,l=f.dom.getNodeType(a);if(this.isAnnotation(l)){if(t.top().ignore.indexOf(l)<0){var p=i;r+=u=this._annotationTextHandler[l]?this._annotationTextHandler[l].call(this,t,a,l,i):this._getAnnotationText(t,a,l,i),i+=u.length,t.ignoreAnnotations||this.createAnnotation(t,a,p,i)}}else if(s){if(!o){e.back();break}console.warn("Node not yet supported in annoted text: "+l)}else t.top().ignore.indexOf(l)<0&&(r+=u=this._getAnnotationText(t,a,l,i),i+=u.length)}}return r},this._annotationTextHandler={},this._getAnnotationText=function(t,e,n,r){var i=new f.dom.ChildNodeIterator(e);return this._annotatedText(t,i,{offset:r,nested:!0})},this._annotationTextHandler["ext-link"]=function(t,e,n,r){var i=this._getAnnotationText(t,e,r);return"ext-link"===n&&e.getAttribute("xlink:href")===i.trim()&&(i=this.shortenLinkLabel(t,i)),i},this._annotationTextHandler["inline-formula"]=function(t){return t.acceptText("{{inline-formula}}")},this.shortenLinkLabel=function(t,e){if(50<e.length){var n=/((?:\w+:\/\/)?[\/]?[^\/]+[\/]?)(.*)/.exec(e);if(n){var r=n[1]||"",i=n[2]||"";if(40<r.length)e=r.substring(0,40)+"..."+i.substring(i.length-10-3);else{var o=Math.max(50-r.length-3,7);e=r+"..."+i.substring(i.length-o)}}else e=e.substring(0,40)+"..."+e.substring(e.length-10-3)}return e},this.getBaseURL=function(t){return t.xmlDoc.querySelector("article").getAttribute("xml:base")||t.options.baseURL},this.enhanceArticle=function(t,e){},this.enhanceCover=function(t,e,n){},this.enhanceFigure=function(t,e,n){var r=n.querySelector("graphic").getAttribute("xlink:href");e.url=this.resolveURL(t,r)},this.enhancePublicationInfo=function(t,e,n){},this.enhanceSupplement=function(t,e,n){},this.enhanceTable=function(t,e,n){},this.enhanceVideo=function(t,e,n){var r=n.getAttribute("xlink:href");e.url=r},this.resolveURL=function(t,e){return e.match(/http:/)?e:[t.options.baseURL,e].join("")},this.viewMapping={box:"content",supplement:"figures",figure:"figures",video:"figures"},this.enhanceAnnotationData=function(t,e,n,r){},this.showNode=function(t,e){var n=this.viewMapping[e.type]||"content";t.doc.show(n,e.id)}},i.State=function(t,e,n){var r=this;this.xmlDoc=e,this.doc=n,this.options=t.options,this.annotations=[],this.stack=[],this.sectionLevel=1,this.affiliations=[];var i={};this.nextId=function(t){return i[t]=i[t]||0,i[t]++,t+"_"+i[t]},this.used={};var o=/^\s+/g,s=/^\s*/g,a=/\s+$/g,c=/\s+/g,u=/[\t\n\r]+/g;this.lastChar="",this.skipWS=!1,this.acceptText=function(t){return this.options.TRIM_WHITESPACES&&(t=t.replace(u,""),t=" "===this.lastChar||this.skipWS?t.replace(s,""):t.replace(o," "),this.skipWS=!1,t=t.replace(a," "),this.options.REMOVE_INNER_WS&&(t=t.replace(c," ")),this.lastChar=t[t.length-1]||this.lastChar),t},this.top=function(){var t=b.last(r.stack);return(t=t||{}).ignore=t.ignore||[],t}},i.prototype=new i.Prototype,(i.prototype.constructor=i).DefaultOptions={TRIM_WHITESPACES:!0,REMOVE_INNER_WS:!0},e.exports=i},{"../article":5,"../substance/util":183,underscore:131}],131:[function(t,H,U){(function(){function n(){}var t=this,e=t._,r=Array.prototype,s=Object.prototype,i=Function.prototype,o=r.push,c=r.slice,p=s.toString,a=s.hasOwnProperty,u=Array.isArray,l=Object.keys,h=i.bind,d=Object.create,f=function(t){return t instanceof f?t:this instanceof f?void(this._wrapped=t):new f(t)};void 0!==U?(void 0!==H&&H.exports&&(U=H.exports=f),U._=f):t._=f,f.VERSION="1.8.3";var g=function(i,o,t){if(void 0===o)return i;switch(null==t?3:t){case 1:return function(t){return i.call(o,t)};case 2:return function(t,e){return i.call(o,t,e)};case 3:return function(t,e,n){return i.call(o,t,e,n)};case 4:return function(t,e,n,r){return i.call(o,t,e,n,r)}}return function(){return i.apply(o,arguments)}},y=function(t,e,n){return null==t?f.identity:f.isFunction(t)?g(t,e,n):f.isObject(t)?f.matcher(t):f.property(t)};f.iteratee=function(t,e){return y(t,e,1/0)};function m(c,u){return function(t){var e=arguments.length;if(e<2||null==t)return t;for(var n=1;n<e;n++)for(var r=arguments[n],i=c(r),o=i.length,s=0;s<o;s++){var a=i[s];u&&void 0!==t[a]||(t[a]=r[a])}return t}}function v(t){if(!f.isObject(t))return{};if(d)return d(t);n.prototype=t;var e=new n;return n.prototype=null,e}function b(e){return function(t){return null==t?void 0:t[e]}}var w=Math.pow(2,53)-1,_=b("length"),x=function(t){var e=_(t);return"number"==typeof e&&0<=e&&e<=w};function C(a){return function(t,e,n,r){e=g(e,r,4);var i=!x(t)&&f.keys(t),o=(i||t).length,s=0<a?0:o-1;return arguments.length<3&&(n=t[i?i[s]:s],s+=a),function(t,e,n,r,i,o){for(;0<=i&&i<o;i+=a){var s=r?r[i]:i;n=e(n,t[s],s,t)}return n}(t,e,n,i,s,o)}}f.each=f.forEach=function(t,e,n){var r,i;if(e=g(e,n),x(t))for(r=0,i=t.length;r<i;r++)e(t[r],r,t);else{var o=f.keys(t);for(r=0,i=o.length;r<i;r++)e(t[o[r]],o[r],t)}return t},f.map=f.collect=function(t,e,n){e=y(e,n);for(var r=!x(t)&&f.keys(t),i=(r||t).length,o=Array(i),s=0;s<i;s++){var a=r?r[s]:s;o[s]=e(t[a],a,t)}return o},f.reduce=f.foldl=f.inject=C(1),f.reduceRight=f.foldr=C(-1),f.find=f.detect=function(t,e,n){var r;if(void 0!==(r=x(t)?f.findIndex(t,e,n):f.findKey(t,e,n))&&-1!==r)return t[r]},f.filter=f.select=function(t,r,e){var i=[];return r=y(r,e),f.each(t,function(t,e,n){r(t,e,n)&&i.push(t)}),i},f.reject=function(t,e,n){return f.filter(t,f.negate(y(e)),n)},f.every=f.all=function(t,e,n){e=y(e,n);for(var r=!x(t)&&f.keys(t),i=(r||t).length,o=0;o<i;o++){var s=r?r[o]:o;if(!e(t[s],s,t))return!1}return!0},f.some=f.any=function(t,e,n){e=y(e,n);for(var r=!x(t)&&f.keys(t),i=(r||t).length,o=0;o<i;o++){var s=r?r[o]:o;if(e(t[s],s,t))return!0}return!1},f.contains=f.includes=f.include=function(t,e,n,r){return x(t)||(t=f.values(t)),"number"==typeof n&&!r||(n=0),0<=f.indexOf(t,e,n)},f.invoke=function(t,n){var r=c.call(arguments,2),i=f.isFunction(n);return f.map(t,function(t){var e=i?n:t[n];return null==e?e:e.apply(t,r)})},f.pluck=function(t,e){return f.map(t,f.property(e))},f.where=function(t,e){return f.filter(t,f.matcher(e))},f.findWhere=function(t,e){return f.find(t,f.matcher(e))},f.max=function(t,r,e){var n,i,o=-1/0,s=-1/0;if(null==r&&null!=t)for(var a=0,c=(t=x(t)?t:f.values(t)).length;a<c;a++)n=t[a],o<n&&(o=n);else r=y(r,e),f.each(t,function(t,e,n){i=r(t,e,n),(s<i||i===-1/0&&o===-1/0)&&(o=t,s=i)});return o},f.min=function(t,r,e){var n,i,o=1/0,s=1/0;if(null==r&&null!=t)for(var a=0,c=(t=x(t)?t:f.values(t)).length;a<c;a++)(n=t[a])<o&&(o=n);else r=y(r,e),f.each(t,function(t,e,n){((i=r(t,e,n))<s||i===1/0&&o===1/0)&&(o=t,s=i)});return o},f.shuffle=function(t){for(var e,n=x(t)?t:f.values(t),r=n.length,i=Array(r),o=0;o<r;o++)(e=f.random(0,o))!==o&&(i[o]=i[e]),i[e]=n[o];return i},f.sample=function(t,e,n){return null==e||n?(x(t)||(t=f.values(t)),t[f.random(t.length-1)]):f.shuffle(t).slice(0,Math.max(0,e))},f.sortBy=function(t,r,e){return r=y(r,e),f.pluck(f.map(t,function(t,e,n){return{value:t,index:e,criteria:r(t,e,n)}}).sort(function(t,e){var n=t.criteria,r=e.criteria;if(n!==r){if(r<n||void 0===n)return 1;if(n<r||void 0===r)return-1}return t.index-e.index}),"value")};function P(s){return function(r,i,t){var o={};return i=y(i,t),f.each(r,function(t,e){var n=i(t,e,r);s(o,t,n)}),o}}f.groupBy=P(function(t,e,n){f.has(t,n)?t[n].push(e):t[n]=[e]}),f.indexBy=P(function(t,e,n){t[n]=e}),f.countBy=P(function(t,e,n){f.has(t,n)?t[n]++:t[n]=1}),f.toArray=function(t){return t?f.isArray(t)?c.call(t):x(t)?f.map(t,f.identity):f.values(t):[]},f.size=function(t){return null==t?0:x(t)?t.length:f.keys(t).length},f.partition=function(t,r,e){r=y(r,e);var i=[],o=[];return f.each(t,function(t,e,n){(r(t,e,n)?i:o).push(t)}),[i,o]},f.first=f.head=f.take=function(t,e,n){if(null!=t)return null==e||n?t[0]:f.initial(t,t.length-e)},f.initial=function(t,e,n){return c.call(t,0,Math.max(0,t.length-(null==e||n?1:e)))},f.last=function(t,e,n){if(null!=t)return null==e||n?t[t.length-1]:f.rest(t,Math.max(0,t.length-e))},f.rest=f.tail=f.drop=function(t,e,n){return c.call(t,null==e||n?1:e)},f.compact=function(t){return f.filter(t,f.identity)};var N=function(t,e,n,r){for(var i=[],o=0,s=r||0,a=_(t);s<a;s++){var c=t[s];if(x(c)&&(f.isArray(c)||f.isArguments(c))){e||(c=N(c,e,n));var u=0,l=c.length;for(i.length+=l;u<l;)i[o++]=c[u++]}else n||(i[o++]=c)}return i};function k(o){return function(t,e,n){e=y(e,n);for(var r=_(t),i=0<o?0:r-1;0<=i&&i<r;i+=o)if(e(t[i],i,t))return i;return-1}}function A(o,s,a){return function(t,e,n){var r=0,i=_(t);if("number"==typeof n)0<o?r=0<=n?n:Math.max(n+i,r):i=0<=n?Math.min(n+1,i):n+i+1;else if(a&&n&&i)return t[n=a(t,e)]===e?n:-1;if(e!=e)return 0<=(n=s(c.call(t,r,i),f.isNaN))?n+r:-1;for(n=0<o?r:i-1;0<=n&&n<i;n+=o)if(t[n]===e)return n;return-1}}f.flatten=function(t,e){return N(t,e,!1)},f.without=function(t){return f.difference(t,c.call(arguments,1))},f.uniq=f.unique=function(t,e,n,r){f.isBoolean(e)||(r=n,n=e,e=!1),null!=n&&(n=y(n,r));for(var i=[],o=[],s=0,a=_(t);s<a;s++){var c=t[s],u=n?n(c,s,t):c;e?(s&&o===u||i.push(c),o=u):n?f.contains(o,u)||(o.push(u),i.push(c)):f.contains(i,c)||i.push(c)}return i},f.union=function(){return f.uniq(N(arguments,!0,!0))},f.intersection=function(t){for(var e=[],n=arguments.length,r=0,i=_(t);r<i;r++){var o=t[r];if(!f.contains(e,o)){for(var s=1;s<n&&f.contains(arguments[s],o);s++);s===n&&e.push(o)}}return e},f.difference=function(t){var e=N(arguments,!0,!0,1);return f.filter(t,function(t){return!f.contains(e,t)})},f.zip=function(){return f.unzip(arguments)},f.unzip=function(t){for(var e=t&&f.max(t,_).length||0,n=Array(e),r=0;r<e;r++)n[r]=f.pluck(t,r);return n},f.object=function(t,e){for(var n={},r=0,i=_(t);r<i;r++)e?n[t[r]]=e[r]:n[t[r][0]]=t[r][1];return n},f.findIndex=k(1),f.findLastIndex=k(-1),f.sortedIndex=function(t,e,n,r){for(var i=(n=y(n,r,1))(e),o=0,s=_(t);o<s;){var a=Math.floor((o+s)/2);n(t[a])<i?o=a+1:s=a}return o},f.indexOf=A(1,f.findIndex,f.sortedIndex),f.lastIndexOf=A(-1,f.findLastIndex),f.range=function(t,e,n){null==e&&(e=t||0,t=0),n=n||1;for(var r=Math.max(Math.ceil((e-t)/n),0),i=Array(r),o=0;o<r;o++,t+=n)i[o]=t;return i};function T(t,e,n,r,i){if(!(r instanceof e))return t.apply(n,i);var o=v(t.prototype),s=t.apply(o,i);return f.isObject(s)?s:o}f.bind=function(t,e){if(h&&t.bind===h)return h.apply(t,c.call(arguments,1));if(!f.isFunction(t))throw new TypeError("Bind must be called on a function");var n=c.call(arguments,2),r=function(){return T(t,r,e,this,n.concat(c.call(arguments)))};return r},f.partial=function(i){var o=c.call(arguments,1),s=function(){for(var t=0,e=o.length,n=Array(e),r=0;r<e;r++)n[r]=o[r]===f?arguments[t++]:o[r];for(;t<arguments.length;)n.push(arguments[t++]);return T(i,s,this,this,n)};return s},f.bindAll=function(t){var e,n,r=arguments.length;if(r<=1)throw new Error("bindAll must be passed function names");for(e=1;e<r;e++)t[n=arguments[e]]=f.bind(t[n],t);return t},f.memoize=function(r,i){var o=function(t){var e=o.cache,n=""+(i?i.apply(this,arguments):t);return f.has(e,n)||(e[n]=r.apply(this,arguments)),e[n]};return o.cache={},o},f.delay=function(t,e){var n=c.call(arguments,2);return setTimeout(function(){return t.apply(null,n)},e)},f.defer=f.partial(f.delay,f,1),f.throttle=function(n,r,i){var o,s,a,c=null,u=0;i||(i={});function l(){u=!1===i.leading?0:f.now(),c=null,a=n.apply(o,s),c||(o=s=null)}return function(){var t=f.now();u||!1!==i.leading||(u=t);var e=r-(t-u);return o=this,s=arguments,e<=0||r<e?(c&&(clearTimeout(c),c=null),u=t,a=n.apply(o,s),c||(o=s=null)):c||!1===i.trailing||(c=setTimeout(l,e)),a}},f.debounce=function(e,n,r){var i,o,s,a,c,u=function(){var t=f.now()-a;t<n&&0<=t?i=setTimeout(u,n-t):(i=null,r||(c=e.apply(s,o),i||(s=o=null)))};return function(){s=this,o=arguments,a=f.now();var t=r&&!i;return i||(i=setTimeout(u,n)),t&&(c=e.apply(s,o),s=o=null),c}},f.wrap=function(t,e){return f.partial(e,t)},f.negate=function(t){return function(){return!t.apply(this,arguments)}},f.compose=function(){var n=arguments,r=n.length-1;return function(){for(var t=r,e=n[r].apply(this,arguments);t--;)e=n[t].call(this,e);return e}},f.after=function(t,e){return function(){if(--t<1)return e.apply(this,arguments)}},f.before=function(t,e){var n;return function(){return 0<--t&&(n=e.apply(this,arguments)),t<=1&&(e=null),n}},f.once=f.partial(f.before,2);var S=!{toString:null}.propertyIsEnumerable("toString"),j=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"];function V(t,e){var n=j.length,r=t.constructor,i=f.isFunction(r)&&r.prototype||s,o="constructor";for(f.has(t,o)&&!f.contains(e,o)&&e.push(o);n--;)(o=j[n])in t&&t[o]!==i[o]&&!f.contains(e,o)&&e.push(o)}f.keys=function(t){if(!f.isObject(t))return[];if(l)return l(t);var e=[];for(var n in t)f.has(t,n)&&e.push(n);return S&&V(t,e),e},f.allKeys=function(t){if(!f.isObject(t))return[];var e=[];for(var n in t)e.push(n);return S&&V(t,e),e},f.values=function(t){for(var e=f.keys(t),n=e.length,r=Array(n),i=0;i<n;i++)r[i]=t[e[i]];return r},f.mapObject=function(t,e,n){e=y(e,n);for(var r,i=f.keys(t),o=i.length,s={},a=0;a<o;a++)s[r=i[a]]=e(t[r],r,t);return s},f.pairs=function(t){for(var e=f.keys(t),n=e.length,r=Array(n),i=0;i<n;i++)r[i]=[e[i],t[e[i]]];return r},f.invert=function(t){for(var e={},n=f.keys(t),r=0,i=n.length;r<i;r++)e[t[n[r]]]=n[r];return e},f.functions=f.methods=function(t){var e=[];for(var n in t)f.isFunction(t[n])&&e.push(n);return e.sort()},f.extend=m(f.allKeys),f.extendOwn=f.assign=m(f.keys),f.findKey=function(t,e,n){e=y(e,n);for(var r,i=f.keys(t),o=0,s=i.length;o<s;o++)if(e(t[r=i[o]],r,t))return r},f.pick=function(t,e,n){var r,i,o={},s=t;if(null==s)return o;f.isFunction(e)?(i=f.allKeys(s),r=g(e,n)):(i=N(arguments,!1,!1,1),r=function(t,e,n){return e in n},s=Object(s));for(var a=0,c=i.length;a<c;a++){var u=i[a],l=s[u];r(l,u,s)&&(o[u]=l)}return o},f.omit=function(t,e,n){if(f.isFunction(e))e=f.negate(e);else{var r=f.map(N(arguments,!1,!1,1),String);e=function(t,e){return!f.contains(r,e)}}return f.pick(t,e,n)},f.defaults=m(f.allKeys,!0),f.create=function(t,e){var n=v(t);return e&&f.extendOwn(n,e),n},f.clone=function(t){return f.isObject(t)?f.isArray(t)?t.slice():f.extend({},t):t},f.tap=function(t,e){return e(t),t},f.isMatch=function(t,e){var n=f.keys(e),r=n.length;if(null==t)return!r;for(var i=Object(t),o=0;o<r;o++){var s=n[o];if(e[s]!==i[s]||!(s in i))return!1}return!0};var E=function(t,e,n,r){if(t===e)return 0!==t||1/t==1/e;if(null==t||null==e)return t===e;t instanceof f&&(t=t._wrapped),e instanceof f&&(e=e._wrapped);var i=p.call(t);if(i!==p.call(e))return!1;switch(i){case"[object RegExp]":case"[object String]":return""+t==""+e;case"[object Number]":return+t!=+t?+e!=+e:0==+t?1/+t==1/e:+t==+e;case"[object Date]":case"[object Boolean]":return+t==+e}var o="[object Array]"===i;if(!o){if("object"!=typeof t||"object"!=typeof e)return!1;var s=t.constructor,a=e.constructor;if(s!==a&&!(f.isFunction(s)&&s instanceof s&&f.isFunction(a)&&a instanceof a)&&"constructor"in t&&"constructor"in e)return!1}r=r||[];for(var c=(n=n||[]).length;c--;)if(n[c]===t)return r[c]===e;if(n.push(t),r.push(e),o){if((c=t.length)!==e.length)return!1;for(;c--;)if(!E(t[c],e[c],n,r))return!1}else{var u,l=f.keys(t);if(c=l.length,f.keys(e).length!==c)return!1;for(;c--;)if(u=l[c],!f.has(e,u)||!E(t[u],e[u],n,r))return!1}return n.pop(),r.pop(),!0};f.isEqual=function(t,e){return E(t,e)},f.isEmpty=function(t){return null==t||(x(t)&&(f.isArray(t)||f.isString(t)||f.isArguments(t))?0===t.length:0===f.keys(t).length)},f.isElement=function(t){return!(!t||1!==t.nodeType)},f.isArray=u||function(t){return"[object Array]"===p.call(t)},f.isObject=function(t){var e=typeof t;return"function"==e||"object"==e&&!!t},f.each(["Arguments","Function","String","Number","Date","RegExp","Error"],function(e){f["is"+e]=function(t){return p.call(t)==="[object "+e+"]"}}),f.isArguments(arguments)||(f.isArguments=function(t){return f.has(t,"callee")}),"function"!=typeof/./&&"object"!=typeof Int8Array&&(f.isFunction=function(t){return"function"==typeof t||!1}),f.isFinite=function(t){return isFinite(t)&&!isNaN(parseFloat(t))},f.isNaN=function(t){return f.isNumber(t)&&t!==+t},f.isBoolean=function(t){return!0===t||!1===t||"[object Boolean]"===p.call(t)},f.isNull=function(t){return null===t},f.isUndefined=function(t){return void 0===t},f.has=function(t,e){return null!=t&&a.call(t,e)},f.noConflict=function(){return t._=e,this},f.identity=function(t){return t},f.constant=function(t){return function(){return t}},f.noop=function(){},f.property=b,f.propertyOf=function(e){return null==e?function(){}:function(t){return e[t]}},f.matcher=f.matches=function(e){return e=f.extendOwn({},e),function(t){return f.isMatch(t,e)}},f.times=function(t,e,n){var r=Array(Math.max(0,t));e=g(e,n,1);for(var i=0;i<t;i++)r[i]=e(i);return r},f.random=function(t,e){return null==e&&(e=t,t=0),t+Math.floor(Math.random()*(e-t+1))},f.now=Date.now||function(){return(new Date).getTime()};function I(e){function n(t){return e[t]}var t="(?:"+f.keys(e).join("|")+")",r=RegExp(t),i=RegExp(t,"g");return function(t){return t=null==t?"":""+t,r.test(t)?t.replace(i,n):t}}var $={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},M=f.invert($);f.escape=I($),f.unescape=I(M),f.result=function(t,e,n){var r=null==t?void 0:t[e];return void 0===r&&(r=n),f.isFunction(r)?r.call(t):r};var O=0;f.uniqueId=function(t){var e=++O+"";return t?t+e:e},f.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};function q(t){return"\\"+R[t]}var L=/(.)^/,R={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},F=/\\|'|\r|\n|\u2028|\u2029/g;f.template=function(o,t,e){!t&&e&&(t=e),t=f.defaults({},t,f.templateSettings);var n=RegExp([(t.escape||L).source,(t.interpolate||L).source,(t.evaluate||L).source].join("|")+"|$","g"),s=0,a="__p+='";o.replace(n,function(t,e,n,r,i){return a+=o.slice(s,i).replace(F,q),s=i+t.length,e?a+="'+\n((__t=("+e+"))==null?'':_.escape(__t))+\n'":n?a+="'+\n((__t=("+n+"))==null?'':__t)+\n'":r&&(a+="';\n"+r+"\n__p+='"),t}),a+="';\n",t.variable||(a="with(obj||{}){\n"+a+"}\n"),a="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+a+"return __p;\n";try{var r=new Function(t.variable||"obj","_",a)}catch(t){throw t.source=a,t}function i(t){return r.call(this,t,f)}var c=t.variable||"obj";return i.source="function("+c+"){\n"+a+"}",i},f.chain=function(t){var e=f(t);return e._chain=!0,e};function D(t,e){return t._chain?f(e).chain():e}f.mixin=function(n){f.each(f.functions(n),function(t){var e=f[t]=n[t];f.prototype[t]=function(){var t=[this._wrapped];return o.apply(t,arguments),D(this,e.apply(f,t))}})},f.mixin(f),f.each(["pop","push","reverse","shift","sort","splice","unshift"],function(e){var n=r[e];f.prototype[e]=function(){var t=this._wrapped;return n.apply(t,arguments),"shift"!==e&&"splice"!==e||0!==t.length||delete t[0],D(this,t)}}),f.each(["concat","join","slice"],function(t){var e=r[t];f.prototype[t]=function(){return D(this,e.apply(this._wrapped,arguments))}}),f.prototype.value=function(){return this._wrapped},f.prototype.valueOf=f.prototype.toJSON=f.prototype.value,f.prototype.toString=function(){return""+this._wrapped},"function"==typeof define&&define.amd&&define("underscore",[],function(){return f})}).call(this)},{}],132:[function(t,e,n){var r=t("./panels/container_panel"),i=new r({type:"resource",name:"figures",container:"figures",title:"Media",icon:"fa-picture-o",references:["figure_reference"],zoom:!0}),o=new r({type:"resource",name:"citations",container:"citations",title:"References",icon:"fa-link",references:["citation_reference"]}),s=new r({type:"resource",name:"footnotes",container:"footnotes",title:"Footnotes",icon:"fa-link",references:["footnote_reference"]}),a=new r({type:"resource",name:"definitions",container:"definitions",title:"Glossary",icon:"fa-book",references:["definition_reference"]}),c=new r({type:"resource",name:"info",container:"info",title:"",icon:"fa-info",references:["contributor_reference"]});e.exports=[o,a,i,s,c]},{"./panels/container_panel":139}],133:[function(t,e,n){var r=t("./workflows/toggle_resource_reference"),i=t("./workflows/follow_crossrefs"),o=t("./workflows/jump_to_top"),s=[new r,new i,new o];e.exports=s},{"./workflows/follow_crossrefs":155,"./workflows/jump_to_top":156,"./workflows/toggle_resource_reference":157}],134:[function(t,e,n){e.exports=t("./lens")},{"./lens":135}],135:[function(t,e,n){"use strict";function r(t){(t=t||{}).routes=t.routes||this.getRoutes(),t.panels=t.panels||this.getPanels(),t.workflows=t.workflows||this.getWorkflows(),t.converters=this.getConverters(t.converterOptions),i.call(this,t),this.controller=t.controller||this.createController(t)}var i=t("../substance/application"),o=t("./lens_controller"),s=t("lens/converter"),a=t("lens/article"),c=t("./panels/resource_panel_viewfactory"),u=t("./reader_controller"),l=t("./reader_view"),p=t("./panels/panel"),h=t("./panels/panel_controller"),d=t("./panels/panel_view"),f=t("./panels/container_panel"),g=t("./panels/container_panel_controller"),y=t("./panels/container_panel_view"),m=t("./workflows/workflow"),v=t("./default_panels"),b=t("./default_workflows");(r.Prototype=function(){this.start=function(){i.prototype.start.call(this)},this.render=function(){this.view=this.controller.createView(),this.$el.html(this.view.render().el)},this.getRoutes=function(){return r.getDefaultRoutes()},this.getPanels=function(){return r.getDefaultPanels()},this.getWorkflows=function(){return r.getDefaultWorkflows()},this.getConverters=function(t){return[r.getDefaultConverter(t)]},this.createController=function(t){return new o(t)}}).prototype=i.prototype,((r.prototype=new r.Prototype).constructor=r).DEFAULT_ROUTES=[{route:":context/:focussedNode/:fullscreen",name:"document-focussed-fullscreen",command:"openReader"},{route:":context/:focussedNode",name:"document-focussed",command:"openReader"},{route:":context",name:"document-context",command:"openReader"},{route:"url/:url",name:"document",command:"openReader"},{route:"",name:"document",command:"openReader"}],r.getDefaultRoutes=function(){return r.DEFAULT_ROUTES},r.getDefaultPanels=function(){return v.slice(0)},r.getDefaultWorkflows=function(){return b.slice(0)},r.getDefaultConverter=function(t){return new s(t)},r.Article=a,r.ReaderController=u,r.ReaderView=l,r.Controller=o,r.LensController=o,r.Panel=p,r.PanelController=h,r.PanelView=d,r.ContainerPanel=f,r.ContainerPanelController=g,r.ContainerPanelView=y,r.ResourcePanelViewFactory=c,r.Workflow=m,e.exports=r},{"../substance/application":161,"./default_panels":132,"./default_workflows":133,"./lens_controller":136,"./panels/container_panel":139,"./panels/container_panel_controller":140,"./panels/container_panel_view":141,"./panels/panel":148,"./panels/panel_controller":149,"./panels/panel_view":150,"./panels/resource_panel_viewfactory":151,"./reader_controller":153,"./reader_view":154,"./workflows/workflow":158,"lens/article":5,"lens/converter":129}],136:[function(t,e,n){"use strict";function r(t){s.call(this),this.config=t,this.Article=t.articleClass||u,this.converter=t.converter,this.converters=t.converters,this.converterOptions=i.extend({},l.DefaultOptions,t.converterOptions),this.on("open:reader",this.openReader)}var i=t("underscore"),o=t("../substance/util"),s=t("../substance/application").Controller,a=t("./lens_view"),c=t("./reader_controller"),u=t("lens/article"),l=t("lens/converter");(r.Prototype=function(){this.createView=function(){var t=new a(this);return this.view=t},this.importXML=function(t){var e=(new DOMParser).parseFromString(t,"text/xml"),n=this.convertDocument(e);this.createReader(n,{panel:"toc"})},this.updatePath=function(t){var e=[];e.push(t.panel),t.focussedNode&&e.push(t.focussedNode),t.fullscreen&&e.push("fullscreen"),window.app.router.navigate(e.join("/"),{trigger:!1,replace:!1})},this.createReader=function(t,e){var n=this;this.reader=new c(t,e,this.config),this.reader.on("state-changed",function(){n.updatePath(n.reader.state)}),this.modifyState({context:"reader"})},this.convertDocument=function(t){for(var e,n=0;!e&&n<this.converters.length;){var r=this.converters[n];r.test(t,this.config.document_url)&&(e=r.import(t)),n+=1}if(!e)throw new Error("No suitable converter found for this document",t);return e},this.openReader=function(t,e,n){var r=this,i={panel:t||"toc",focussedNode:e,fullscreen:!!n};if(this.reader)this.reader.modifyState(i);else if("lens_article.xml"===this.config.document_url){var o=this.Article.describe();r.createReader(o,i)}else this.trigger("loading:started","Loading"),$.get(this.config.document_url).done(function(t){var e;e=$.isXMLDoc(t)?r.convertDocument(t):("string"==typeof t&&(t=$.parseJSON(t)),r.Article.fromSnapshot(t)),"toc"===i.panel&&e.getHeadings().length<=2&&(i.panel="info"),r.createReader(e,i)}).fail(function(t){r.view.startLoading("Error during loading. Please try again."),console.error(t)})}}).prototype=s.prototype,r.prototype=new r.Prototype,i.extend(r.prototype,o.Events),e.exports=r},{"../substance/application":161,"../substance/util":183,"./lens_view":138,"./reader_controller":153,"lens/article":5,"lens/converter":129,underscore:131}],137:[function(t,e,n){function r(t,e){o.call(this,e),this.docCtrl=t,this.options=e,this.document=t.getDocument(),this.options.viewFactory?this.viewFactory=this.options.viewFactory:this.viewFactory=new this.document.constructor.ViewFactory(this.document.nodeTypes),this.$el.addClass("surface"),this.$nodes=$("<div>").addClass("nodes"),this.$el.append(this.$nodes)}var i=t("underscore"),o=t("../substance/application").View;(r.Prototype=function(){this.render=function(){return this.$nodes.html(this.build()),this},this.findNodeView=function(t){return this.el.querySelector("*[data-id="+t+"]")},this.build=function(){var n=document.createDocumentFragment();i.each(this.nodes,function(t){t.dispose()}),this.nodes={};var t=this.docCtrl.container.getTopLevelNodes();return i.each(t,function(t){var e=this.renderNodeView(t);this.nodes[t.id]=e,n.appendChild(e.el)},this),n},this.renderNodeView=function(t){var e=this.viewFactory.createView(t,{topLevel:!0});return e.render(),e}}).prototype=o.prototype,(r.prototype=new r.Prototype).constructor=r,e.exports=r},{"../substance/application":161,underscore:131}],138:[function(t,e,n){"use strict";function r(t){o.call(this),this.controller=t,this.$el.attr({id:"container"}),this.listenTo(this.controller,"state-changed",this.onStateChanged),this.listenTo(this.controller,"loading:started",this.startLoading),$(document).on("dragover",function(){return!1}),$(document).on("ondragend",function(){return!1}),$(document).on("drop",this.handleDroppedFile.bind(this))}var i=t("underscore"),o=t("../substance/application").View,s=t("../substance/application").$$;(r.Prototype=function(){this.handleDroppedFile=function(){var e=this.controller,t=event.dataTransfer.files[0],n=new FileReader;return n.onload=function(t){e.importXML(t.target.result)},n.readAsText(t),!1},this.onStateChanged=function(){var t=this.controller.state;"reader"===t.context?this.openReader():console.log("Unknown application state: "+t)},this.startLoading=function(t){t||(t="Loading"),$(".spinner-wrapper .message").html(t),$("body").addClass("loading")},this.stopLoading=function(){$("body").removeClass("loading")},this.openReader=function(){var t=this.controller.reader.createView(),e=this;e.replaceMainView("reader",t),e.startLoading("Typesetting"),this.$("#main").css({opacity:0}),i.delay(function(){e.stopLoading(),e.$("#main").css({opacity:1})},1e3)},this.replaceMainView=function(t,e){$("body").removeClass().addClass("current-view "+t),this.mainView&&this.mainView!==e&&this.mainView.dispose(),this.mainView=e,this.$("#main").html(e.render().el)},this.render=function(){return this.el.innerHTML="",this.el.appendChild(s(".browser-not-supported",{text:"Sorry, your browser is not supported.",style:"display: none;"})),this.el.appendChild(s(".spinner-wrapper",{children:[s(".spinner"),s(".message",{html:"Loading"})]})),this.el.appendChild(s("#main")),this},this.dispose=function(){this.stopListening(),this.mainView&&this.mainView.dispose()}}).prototype=o.prototype,r.prototype=new r.Prototype,e.exports=r},{"../substance/application":161,underscore:131}],139:[function(t,e,n){"use strict";function r(t){i.call(this,t)}var i=t("./panel"),o=t("./container_panel_controller");(r.Prototype=function(){this.createController=function(t){return new o(t,this.config)}}).prototype=i.prototype,r.prototype=new r.Prototype,e.exports=r},{"./container_panel_controller":140,"./panel":148}],140:[function(t,e,n){"use strict";function r(t,e){o.call(this,t,e),this.docCtrl=new i.Controller(t,{view:e.container})}var i=t("../../substance/document"),o=t("./panel_controller"),s=t("./resource_panel_viewfactory"),a=t("./container_panel_view");(r.Prototype=function(){this.createView=function(){var t,e=this.getDocument();"resource"===this.config.type?t=this.config.createViewFactory?this.config.createViewFactory(e,this.config):new s(e.nodeTypes,this.config):t=new e.constructor.ViewFactory(e.nodeTypes,this.config);return this.viewFactory=t,new a(this,t,this.config)},this.getContainer=function(){return this.docCtrl.getContainer()}}).prototype=o.prototype,r.prototype=new r.Prototype,e.exports=r},{"../../substance/document":174,"./container_panel_view":141,"./panel_controller":149,"./resource_panel_viewfactory":151}],141:[function(t,e,n){"use strict";function r(t,e,n){a.call(this,t,n),this.surface=new s(t.docCtrl,{editable:!1,viewFactory:e}),this.docCtrl=t.docCtrl,this.scrollbar=new o(this.surface),this._onScroll=i.bind(this.onScroll,this),this.surface.$el.on("scroll",this._onScroll),this.surface.$el.addClass("resource-view").addClass(n.container),this.el.appendChild(this.surface.el),this.el.appendChild(this.scrollbar.el),this.$activeResource=null}var i=t("underscore"),o=t("./surface_scrollbar"),s=t("../lens_surface"),a=t("./panel_view"),c=t("../../substance/util/getRelativeBoundingRect");(r.Prototype=function(){this.render=function(){return 0===this.getContainer().getLength()?(this.hideToggle(),this.hide()):(this.surface.render(),this.scrollbar.render()),this},this.getContainer=function(){return this.docCtrl.container},this.onScroll=function(){this.scrollbar.onScroll()},this.hasScrollbar=function(){return!0},this.scrollTo=function(t){var e=this.findNodeView(t);if(e){var n=this.surface.$el.height(),r=this.surface.$el.scrollTop(),i=r+n,o=c([e],this.surface.$nodes[0]),s=(o.height,o.top),a=s+o.height;if(r<=s&&a<=i)return;this.surface.$el.scrollTop(s),this.scrollbar.update()}else console.info("ContainerPanelView.scrollTo(): Unknown resource '%s'",t)},this.findNodeView=function(t){return this.surface.findNodeView(t)},this.addHighlight=function(t,e){a.prototype.addHighlight.call(this,t,e);var n=this.getDocument().get(t);n&&this.scrollbar.addHighlight(t,e+" "+n.type)},this.removeHighlights=function(){a.prototype.removeHighlights.call(this),this.scrollbar.removeHighlights(),this.scrollbar.update()},this.update=function(){this.scrollbar.update()},this.hide=function(){this.hidden||a.prototype.hide.call(this)},this.show=function(){this.scrollbar.update(),a.prototype.show.call(this)}}).prototype=a.prototype,(r.prototype=new r.Prototype).constructor=r,e.exports=r},{"../../substance/util/getRelativeBoundingRect":181,"../lens_surface":137,"./panel_view":150,"./surface_scrollbar":152,underscore:131}],142:[function(t,e,n){"use strict";function r(){i.call(this,{name:"content",type:"document",container:"content",label:"Contents",title:"Contents",icon:"fa-align-left"})}var i=t("../container_panel"),o=t("./content_panel_controller");(r.Prototype=function(){this.createController=function(t){return new o(t,this.config)}}).prototype=i.prototype,r.prototype=new r.Prototype,e.exports=r},{"../container_panel":139,"./content_panel_controller":143}],143:[function(t,e,n){"use strict";function r(t,e){i.call(this,t,e)}var i=t("../container_panel_controller"),o=t("./content_panel_view");(r.Prototype=function(){this.createView=function(){if(!this.view){var t=this.getDocument(),e=new t.constructor.ViewFactory(t.nodeTypes,this.config);this.view=new o(this,e,this.config)}return this.view}}).prototype=i.prototype,r.prototype=new r.Prototype,e.exports=r},{"../container_panel_controller":140,"./content_panel_view":144}],144:[function(t,e,n){"use strict";function r(t,e,n){i.call(this,t,e,n),this.tocView=new o(t,e,c.extend({},n,{type:"resource",name:"toc"})),this.tocNodeElements={},this._onTocItemSelected=c.bind(this.onTocItemSelected,this),this.resources=t.getDocument().addIndex("referenceByTarget",{types:["resource_reference"],property:"target"}),this.tocView.toc.on("toc-item-selected",this._onTocItemSelected),this.$el.addClass("document")}var c=t("underscore"),i=t("../container_panel_view"),o=t("./toc_panel_view");(r.Prototype=function(){this.dispose=function(){this.tocView.toc.off("toc-item-selected",this._onTocItemSelected),this.stopListening()},this.getTocView=function(){return this.tocView},this.onScroll=function(){var t=this.surface.$el.scrollTop();this.scrollbar.update(),this.markActiveHeading(t)},this.onTocItemSelected=function(t){var e=this.findNodeView(t);e&&e.scrollIntoView()},this.markActiveHeading=function(t){var e=$(".nodes").height(),n=this.getDocument().getTocNodes(),r=function(t){var e=this.tocNodeElements[t];return e||(e=this.tocNodeElements[t]=this.findNodeView(t)),e}.bind(this);if(0!==n.length){var i;r(n[0].id);if(i=n[0].id,t+this.$el.height()>=e)i=c.last(n).id;else for(var o=n.length-1;1<=o;o--){var s=n[o],a=r(s.id);if(a){if($(a).offset().top-1<=0){i=a.dataset.id;break}}else console.error("Could not find element for node %s",s.id)}this.tocView.setActiveNode(i)}},this.markReferencesTo=function(t){var e=this.resources.get(t);c.each(e,function(t){$(this.findNodeView(t.id)).addClass("active")},this)},this.removeHighlights=function(){i.prototype.removeHighlights.call(this),this.$el.find(".content-node.active").removeClass("active"),this.$el.find(".annotation.active").removeClass("active")}}).prototype=i.prototype,(r.prototype=new r.Prototype).constructor=r,e.exports=r},{"../container_panel_view":141,"./toc_panel_view":146,underscore:131}],145:[function(t,e,n){e.exports=t("./content_panel")},{"./content_panel":142}],146:[function(t,e,n){"use strict";function r(t,e,n){o.call(this,t,n),this.toc=new i(t.getDocument(),e)}var i=t("./toc_view"),o=t("../panel_view");(r.Prototype=function(){this.render=function(){return this.el.appendChild(this.toc.render().el),this},this.setActiveNode=function(t){this.toc.setActiveNode(t)},this.onToggle=function(t){this.trigger("toggle","toc"),t.preventDefault(),t.stopPropagation()}}).prototype=o.prototype,(r.prototype=new r.Prototype).constructor=r,e.exports=r},{"../panel_view":150,"./toc_view":147}],147:[function(t,e,n){"use strict";function r(t,e){i.call(this),this.doc=t,this.viewFactory=e,this.$el.addClass("toc")}var i=t("../../../substance/application").View,s=(t("../../../substance/application").$$,t("../../../substance/data").Graph.Index,t("underscore"));(r.Prototype=function(){this.render=function(){var o=-1,t=this.doc.getTocNodes(),e=document.createElement("div");e.setAttribute("class","navigation");var n=document.createElement("a");return n.setAttribute("href",""),n.textContent="Back",e.appendChild(n),t.length<2||s.each(t,function(t){var e=this.viewFactory.createView(t),n=t.getLevel();if(n<5){-1===n?n=o+1:o=n;var r=e.renderTocItem(),i=$(r);r.id="toc_"+t.id,i.addClass("heading-ref"),i.addClass("level-"+n),i.click(s.bind(this.onClick,this,t.id)),this.el.appendChild(r)}},this),this},this.setActiveNode=function(t){this.$(".heading-ref.active").removeClass("active"),this.$("#toc_"+t).addClass("active")},this.onClick=function(t){this.trigger("toc-item-selected",t)}}).prototype=i.prototype,r.prototype=new r.Prototype,e.exports=r},{"../../../substance/application":161,"../../../substance/data":167,underscore:131}],148:[function(t,e,n){"use strict";function r(t){this.config=t,this.config.label=t.title}r.Prototype=function(){this.createController=function(t){throw new Error("this method is abstract")},this.getName=function(){return this.config.name},this.getConfig=function(){return this.config}},(r.prototype=new r.Prototype).constructor=r,e.exports=r},{}],149:[function(t,e,n){"use strict";function r(t,e){this.document=t,this.config=e}var i=t("../../substance/application").Controller;t("underscore"),t("../../substance/util");(r.Prototype=function(){i.prototype;this.createView=function(){throw new Error("this is an abstract method")},this.getConfig=function(){return this.config},this.getName=function(){return this.config.name},this.getDocument=function(){return this.document}}).prototype=i.prototype,r.prototype=new r.Prototype,e.exports=r},{"../../substance/application":161,"../../substance/util":183,underscore:131}],150:[function(t,e,n){function r(t,e){a.call(this),this.controller=t,this.config=e,this.doc=t.getDocument(),this.name=e.name,this.toggleEl=s("a.context-toggle."+this.name,{href:"#",title:this.config.title,html:'<i class="fa '+this.config.icon+'"></i> '+this.config.title}),this.$toggleEl=$(this.toggleEl),this.$el.addClass("panel").addClass(this.name),"resource"===this.config.type&&this.$el.addClass("resource-view"),this._onToggle=i.bind(this.onToggle,this),this._onToggleResource=i.bind(this.onToggleResource,this),this._onToggleResourceReference=i.bind(this.onToggleResourceReference,this),this._onToggleFullscreen=i.bind(this.onToggleFullscreen,this),this.$toggleEl.click(this._onToggle),this.$el.on("click",".action-toggle-resource",this._onToggleResource),this.$el.on("click",".toggle-fullscreen",this._onToggleFullscreen),this.$el.on("click",".annotation.resource-reference",this._onToggleResourceReference),this.highlightedNodes=[]}var i=t("underscore"),o=t("../../substance/application"),s=o.$$,a=o.View;(r.Prototype=function(){this.dispose=function(){this.$toggleEl.off("click",this._onClick),this.$el.off("scroll",this._onScroll),this.$el.off("click",".a.action-toggle-resource",this._onToggleResource),this.$el.off("click",".a.toggle-fullscreen",this._onToggleFullscreen),this.$el.off("click",".annotation.reference",this._onToggleResourceReference),this.stopListening()},this.onToggle=function(t){this.trigger("toggle",this.name),t.preventDefault(),t.stopPropagation()},this.getToggleControl=function(){return this.toggleEl},this.hasScrollbar=function(){return!1},this.show=function(){this.$el.removeClass("hidden"),this.hidden=!1},this.hide=function(){this.hidden||(this.$el.addClass("hidden"),this.$toggleEl.removeClass("active"),this.hidden=!0)},this.isHidden=function(){return this.hidden},this.activate=function(){this.show(),$("#main .article")[0].dataset.context=this.name,this.$toggleEl.addClass("active")},this.addHighlight=function(t,e){var n=this.findNodeView(t);if(n){var r=$(n);r.addClass(e),this.highlightedNodes.push({$el:r,cssClass:e})}},this.removeHighlights=function(){for(var t=0;t<this.highlightedNodes.length;t++){var e=this.highlightedNodes[t];e.$el.removeClass(e.cssClass)}this.highlightedNodes=[]},this.showToggle=function(){this.$toggleEl.removeClass("hidden")},this.hideToggle=function(){this.$toggleEl.addClass("hidden")},this.getDocument=function(){return this.doc},this.findNodeView=function(t){return this.el.querySelector("*[data-id="+t+"]")},this.onToggleResource=function(t){t.preventDefault(),t.stopPropagation();var e=$(t.currentTarget).parents(".content-node")[0],n=e.dataset.id;this.trigger("toggle-resource",this.name,n,e)},this.onToggleResourceReference=function(t){t.preventDefault(),t.stopPropagation();var e=t.currentTarget,n=t.currentTarget.dataset.id;this.trigger("toggle-resource-reference",this.name,n,e)},this.onToggleFullscreen=function(t){t.preventDefault(),t.stopPropagation();var e=$(t.currentTarget).parents(".content-node")[0],n=e.dataset.id;this.trigger("toggle-fullscreen",this.name,n,e)}}).prototype=a.prototype,(r.prototype=new r.Prototype).constructor=r,e.exports=r},{"../../substance/application":161,underscore:131}],151:[function(t,e,n){var r=t("../../article").ViewFactory,i=function(t,e){r.call(this,t),this.options=e||{},void 0===this.options.header&&(this.options.header=!0),void 0===this.options.zoom&&(this.options.zoom=i.enableZoom)};i.Prototype=function(){this.createView=function(t,e,n){e=e||{};var r=this.getNodeViewClass(t,n);return e.topLevel&&r.prototype.isResourceView&&this.options.header&&(e.header=!0,r.prototype.isZoomable&&this.options.zoom&&(e.zoom=!0)),new r(t,this,e)}},i.Prototype.prototype=r.prototype,i.prototype=new i.Prototype,i.enableZoom=!1,e.exports=i},{"../../article":5}],152:[function(t,e,n){"use strict";function o(t){r.call(this),this.surface=t,this.$nodes=this.surface.$nodes,this.$el.addClass("surface-scrollbar"),this.$el.addClass(t.docCtrl.getContainer().id),this.overlays=[],s.bindAll(this,"mouseDown","mouseUp","mouseMove","updateVisibleArea"),this.$el.mousedown(this.mouseDown),$(window).mousemove(this.mouseMove),$(window).mouseup(this.mouseUp)}var r=t("../../substance/application").View,i=t("../../substance/application").$$,s=t("underscore");(o.Prototype=function(){this.render=function(){var t=this.$nodes.height(),e=this.surface.$el.height();return this.factor=t/e,this.visibleArea=i(".visible-area"),this.scrollTop=this.surface.$el.scrollTop(),this.el.innerHTML="",this.el.appendChild(this.visibleArea),this.updateVisibleArea(),this},this.updateVisibleArea=function(){$(this.visibleArea).css({top:this.scrollTop/this.factor,height:this.surface.$el.height()/this.factor})},this.addOverlay=function(t){var e=$("<div>").addClass("node overlay");return this.overlays.push({el:t,$overlay:e}),this.$el.append(e),e},this.updateOverlay=function(t,e){var n=$(t),r=n.outerHeight(!0)/this.factor,i=(n.offset().top-this.surfaceTop)/this.factor;r<o.OverlayMinHeight&&(i-=.5*(r=o.OverlayMinHeight)),e.css({height:r,top:i})},this.addHighlight=function(t,e){var n=this.surface.findNodeView(t);if(n){var r=this.addOverlay(n);return this.updateOverlay(n,r),r.addClass(e),r[0]}},this.addHighlights=function(t,e){for(var n=[],r=0;r<t.length;r++){var i=this.addHighlight(t[r],e);n.push(i)}return this.update(),n},this.removeHighlights=function(){for(var t=0;t<this.overlays.length;t++){this.overlays[t].$overlay.remove()}},this.update=function(){var t=this.$nodes.height(),e=this.surface.$el.height();e<t?$(this.el).removeClass("hidden"):$(this.el).addClass("hidden"),this.factor=t/e,this.surfaceTop=this.$nodes.offset().top,this.scrollTop=this.surface.$el.scrollTop(),this.updateVisibleArea();for(var n=0;n<this.overlays.length;n++){var r=this.overlays[n];this.updateOverlay(r.el,r.$overlay)}},this.mouseDown=function(t){this._mouseDown=!0;var e=t.pageY;return t.target!==this.visibleArea?(this.offset=$(this.visibleArea).height()/2,this.mouseMove(t)):this.offset=e-$(this.visibleArea).position().top,!1},this.mouseUp=function(){this._mouseDown=!1},this.mouseMove=function(t){if(this._mouseDown){var e=(t.pageY-this.offset)*this.factor;this.scrollTop=this.surface.$el.scrollTop(e),this.updateVisibleArea()}},this.onScroll=function(){this.surface&&(this.scrollTop=this.surface.$el.scrollTop(),this.updateVisibleArea())}}).prototype=r.prototype,o.prototype=new o.Prototype,o.OverlayMinHeight=5,e.exports=o},{"../../substance/application":161,underscore:131}],153:[function(t,e,n){"use strict";function r(e,t,n){this.__document=e,this.options=n||{},this.panels=n.panels,this.contentPanel=new a(e),this.panelCtrls={},this.panelCtrls.content=this.contentPanel.createController(e),i.each(this.panels,function(t){this.panelCtrls[t.getName()]=t.createController(e)},this),this.workflows=n.workflows||[],this.state=t,this.currentPanel="toc"}var i=t("underscore"),o=t("../substance/application").Controller,s=t("./reader_view"),a=t("./panels/content");(r.Prototype=function(){this.createView=function(){return this.view||(this.view=new s(this)),this.view},this.switchPanel=function(t){this.currentPanel=t,this.modifyState({panel:t,focussedNode:null,fullscreen:!1})},this.getDocument=function(){return this.__document}}).prototype=o.prototype,r.prototype=new r.Prototype,e.exports=r},{"../substance/application":161,"./panels/content":145,"./reader_view":154,underscore:131}],154:[function(t,e,n){"use strict";function r(r){i.call(this),this.readerCtrl=r,this.doc=this.readerCtrl.getDocument(),this.$el.addClass("article"),this.$el.addClass(this.doc.schema.id),this.bodyScroll={},this.contentView=r.panelCtrls.content.createView(),this.tocView=this.contentView.getTocView(),this.panelViews={},this.panelForRef={},l.each(r.panels,function(t){var e=t.getName(),n=r.panelCtrls[e];this.panelViews[e]=n.createView(),l.each(t.config.references,function(t){this.panelForRef[t]=e},this)},this),this.panelViews.toc=this.tocView,this.resources=new o(this.readerCtrl.getDocument(),{types:["resource_reference"],property:"target"}),this.lastWorkflow=null,this.lastPanel="toc",this._onTogglePanel=l.bind(this.switchPanel,this),this.listenTo(this.readerCtrl,"state-changed",this.updateState),this.listenTo(this.tocView,"toggle",this._onTogglePanel),l.each(this.panelViews,function(t){this.listenTo(t,"toggle",this._onTogglePanel),this.listenTo(t,"toggle-resource",this.onToggleResource),this.listenTo(t,"toggle-resource-reference",this.onToggleResourceReference),this.listenTo(t,"toggle-fullscreen",this.onToggleFullscreen)},this),this.listenTo(this.contentView,"toggle",this._onTogglePanel),this.listenTo(this.contentView,"toggle-resource",this.onToggleResource),this.listenTo(this.contentView,"toggle-resource-reference",this.onToggleResourceReference),this.listenTo(this.contentView,"toggle-fullscreen",this.onToggleFullscreen),l.each(this.readerCtrl.workflows,function(t){t.attach(this.readerCtrl,this)},this),$(window).resize(l.debounce(l.bind(function(){this.contentView.scrollbar.update();var t=this.panelViews[this.readerCtrl.state.panel];t&&t.hasScrollbar()&&t.scrollbar.update()},this),1))}var l=t("underscore"),i=t("../substance/application").View,o=t("../substance/data").Graph.Index,c=t("../substance/application").$$;(r.Prototype=function(){this.render=function(){var t=document.createDocumentFragment();t.appendChild(this.contentView.render().el);var e=c(".scrollbar-cover"),n=parseInt($(".panel.content.document").width(),10),r=parseInt($(".surface.resource-view.content").width(),10),i=parseInt($(".scrollbar-cover").width(),10);parseInt(10*(n+r+i)/100,10),$(".scrollbar-cover").offset(),$(".surface.resource-view.content");this.contentView.el.appendChild(e);var o=c(".context-toggles");o.appendChild(this.tocView.getToggleControl()),this.tocView.on("toggle",this._onClickPanel),l.each(this.readerCtrl.panels,function(t){var e=this.panelViews[t.getName()],n=e.getToggleControl();o.appendChild(n),e.on("toggle",this._onClickPanel)},this);var s=c(".resources");s.appendChild(this.tocView.render().el),l.each(this.readerCtrl.panels,function(t){var e=this.panelViews[t.getName()];s.appendChild(e.render().el)},this);var a=c(".menu-bar");return a.appendChild(o),s.appendChild(a),t.appendChild(s),this.el.appendChild(t),l.delay(l.bind(function(){this.updateState();var t=this;window.MathJax&&(window.MathJax.Hub.Queue(["Typeset",window.MathJax.Hub]),window.MathJax.Hub.Queue(function(){t.updateState()}))},this),1),this},this.dispose=function(){l.each(this.workflows,function(t){t.detach()}),this.contentView.dispose(),l.each(this.panelViews,function(t){t.off("toggle",this._onClickPanel),t.dispose()},this),this.resources.dispose(),this.stopListening()},this.getState=function(){return this.readerCtrl.state},this.switchPanel=function(t){this.readerCtrl.switchPanel(t),this.lastPanel=t},this.updateState=function(){var t,e=this,n=this.readerCtrl.state,r={focussedNode:n.focussedNode?this.doc.get(n.focussedNode):null},i="content"===n.panel?this.contentView:this.panelViews[n.panel];if(l.each(this.panelViews,function(t){t.isHidden()||t.hide()}),this.contentView.removeHighlights(),l.each(this.panelViews,function(t){t.removeHighlights()}),n.focussedNode){var o=["focussed","highlighted"];n.fullscreen&&o.push("fullscreen"),this.contentView.addHighlight(n.focussedNode,o.concat("main-occurrence").join(" ")),i.addHighlight(n.focussedNode,o.join(" ")),i.scrollTo(n.focussedNode)}if(this.lastWorkflow&&(t=this.lastWorkflow.handleStateUpdate(n,r)),!t)for(var s=0;s<this.readerCtrl.workflows.length;s++){var a=this.readerCtrl.workflows[s];if(a!==this.lastWorkflow&&a.handlesStateUpdate&&(t=a.handleStateUpdate(n,r))){this.lastWorkflow=a;break}}if(!t)if("content"!==n.panel){var c=this.panelViews[n.panel];if(this.showPanel(n.panel),n.focussedNode){var u=this.resources.get(n.focussedNode);l.each(u,function(t){this.contentView.addHighlight(t.id,"highlighted "),this.contentView.scrollTo(t.target)},this),c.hasScrollbar()&&c.scrollTo(n.focussedNode)}}else this.showPanel("toc");e.updateScrollbars(),l.delay(function(){e.updateScrollbars()},2e3)},this.updateScrollbars=function(){this.readerCtrl.state;this.contentView.scrollbar.update(),l.each(this.panelViews,function(t){t.hasScrollbar()&&t.scrollbar.update()})},this.showPanel=function(t){this.panelViews[t]?(this.panelViews[t].activate(),this.el.dataset.context=t):"content"===t&&(this.panelViews.toc.activate(),this.el.dataset.context=t)},this.getPanelView=function(t){return this.panelViews[t]},this.onToggleResource=function(t,e,n){n.classList.contains("highlighted")?this.readerCtrl.modifyState({panel:t,focussedNode:null,fullscreen:!1}):this.readerCtrl.modifyState({panel:t,focussedNode:e})},this.onToggleResourceReference=function(t,e,n){n.classList.contains("highlighted")||this.readerCtrl.modifyState({panel:"content",focussedNode:e,fullscreen:!1})},this.onToggleFullscreen=function(t,e){var n=!this.readerCtrl.state.fullscreen;this.readerCtrl.modifyState({panel:t,focussedNode:e,fullscreen:n})}}).prototype=i.prototype,(r.prototype=new r.Prototype).constructor=r,e.exports=r},{"../substance/application":161,"../substance/data":167,underscore:131}],155:[function(t,e,n){"use strict";function r(){o.apply(this,arguments),this._followCrossReference=i.bind(this.followCrossReference,this)}var i=t("underscore"),o=t("./workflow");(r.Prototype=function(){this.registerHandlers=function(){this.readerView.$el.on("click",".annotation.cross_reference",this._followCrossReference)},this.unRegisterHandlers=function(){this.readerView.$el.off("click",".annotation.cross_reference",this._followCrossReference)},this.followCrossReference=function(t){t.preventDefault(),t.stopPropagation();var e,n=t.currentTarget.dataset.id,r=this.readerCtrl.getDocument().get(n);void 0!==r&&(void 0!==r.target&&(e=r.target,this.readerView.contentView.scrollTo(e)),void 0===e&&void 0!==r.properties&&(e=r.properties.id,this.readerView.contentView.scrollTo(e)))}}).prototype=o.prototype,r.prototype=new r.Prototype,e.exports=r},{"./workflow":158,underscore:131}],156:[function(t,n,r){"use strict";function i(){s.apply(this,arguments),this._gotoTop=o.bind(this.gotoTop,this)}var o=t("underscore"),s=t("./workflow");(i.Prototype=function(){this.registerHandlers=function(){this.readerView.$el.on("click",".document .content-node.heading .top",this._gotoTop)},this.unRegisterHandlers=function(){this.readerView.$el.off("click",".document .content-node.heading .top",this._gotoTop)},this.gotoTop=function(){e.preventDefault(),e.stopPropagation(),this.readerCtrl.contentView.jumpToNode("cover")}}).prototype=s.prototype,i.prototype=new i.Prototype,n.exports=i},{"./workflow":158,underscore:131}],157:[function(t,e,n){"use strict";function r(){i.apply(this,arguments)}var c=t("underscore"),i=t("./workflow");(r.Prototype=function(){this.registerHandlers=function(){},this.unRegisterHandlers=function(){},this.handlesStateUpdate=!0,this.handleStateUpdate=function(t,e){if(e.focussedNode&&this.readerView.panelForRef[e.focussedNode.type]){var n=e.focussedNode,r=this.readerView.panelForRef[n.type],i=this.readerView.panelViews[r],o=this.readerView.contentView,s=n.target;i.activate();i.addHighlight(s,["highlighted"].join(" ")),i.scrollTo(s);var a=this.readerView.resources.get(s);return delete a[n.id],c.each(a,function(t){o.addHighlight(t.id,"highlighted")},this),!0}return!1}}).prototype=i.prototype,r.prototype=new r.Prototype,e.exports=r},{"./workflow":158,underscore:131}],158:[function(t,e,n){"use strict";function r(){this.readerController=null,this.readerView=null}r.Prototype=function(){this.attach=function(t,e){this.readerCtrl=t,this.readerView=e,this.registerHandlers()},this.detach=function(){this.unRegisterHandlers(),this.readerView=null,this.readerController=null},this.registerHandlers=function(){throw new Error("This method is abstract")},this.unRegisterHandlers=function(){throw new Error("This method is abstract")},this.handlesStateUpdate=!1,this.handleStateUpdate=function(t,e){throw new Error("This method is abstract")}},r.prototype=new r.Prototype,e.exports=r},{}],159:[function(t,e,n){"use strict";function r(t){i.call(this),this.config=t}var i=t("./view"),o=t("./router"),s=(t("../../substance/util"),t("underscore"));(r.Prototype=function(){this.initRouter=function(){this.router=new o,s.each(this.config.routes,function(t){this.router.route(t.route,t.name,s.bind(this.controller[t.command],this.controller))},this),o.history.start()},this.start=function(){this.$el=$("body"),this.el=this.$el[0],this.render(),this.initRouter()}}).prototype=i.prototype,r.prototype=new r.Prototype,e.exports=r},{"../../substance/util":183,"./router":163,"./view":164,underscore:131}],160:[function(t,e,n){"use strict";function r(t){this.state={},this.context=null}var i=t("../../substance/util"),o=t("underscore");(r.Prototype=function(){this.updateState=function(t,e){console.error("updateState is deprecated, use modifyState. State is now a rich object where context replaces the old state variable");var n=this.context;this.context=t,this.state=e,this.trigger("state-changed",this.context,n,e)},this.modifyState=function(t){var e=this.state.context;o.extend(this.state,t),t.context&&t.context!==e&&this.trigger("context-changed",t.context),this.trigger("state-changed",this.state.context)}}).prototype=i.Events,r.prototype=new r.Prototype,e.exports=r},{"../../substance/util":183,underscore:131}],161:[function(t,e,n){"use strict";var r=t("./application");r.View=t("./view"),r.Router=t("./router"),r.Controller=t("./controller"),r.ElementRenderer=t("./renderers/element_renderer"),r.$$=r.ElementRenderer.$$,e.exports=r},{"./application":159,"./controller":160,"./renderers/element_renderer":162,"./router":163,"./view":164}],162:[function(t,e,n){"use strict";function o(t){return this.attributes=t,this.tagName=t.tag,this.children=t.children||[],this.text=t.text||"",this.html=t.html,delete t.children,delete t.text,delete t.html,delete t.tag,this.render()}var r=t("../../../substance/util"),s=r.RegExp;o.Prototype=function(){this.render=function(){var t=document.createElement(this.tagName);for(var e in this.html?t.innerHTML=this.html:t.textContent=this.text,this.attributes){var n=this.attributes[e];t.setAttribute(e,n)}for(var r=0;r<this.children.length;r++){var i=this.children[r];t.appendChild(i)}return this.el=t}};o.$$=function(t,e){e=e||{};var n=/^([a-zA-Z0-9]*)/.exec(t);e.tag=n&&n[1]?n[1]:"div";var r=/#([a-zA-Z0-9_]*)/.exec(t);r&&r[1]&&(e.id=r[1]);var i=new s(/\.([a-zA-Z0-9_-]*)/g);return e.class||(e.class=i.match(t).map(function(t){return t.match[1]}).join(" ")),new o(e)},o.Prototype.prototype=r.Events,o.prototype=new o.Prototype,e.exports=o},{"../../../substance/util":183}],163:[function(t,e,n){"use strict";function s(t){t||(t={}),t.routes&&(this.routes=t.routes),this._bindRoutes(),this.initialize.apply(this,arguments)}var r=t("../../substance/util"),a=t("underscore"),i=/\((.*?)\)/g,o=/(\(\?)?:\w+/g,c=/\*\w+/g,u=/[\-{}\[\]+?.,\\\^$|#\s]/g;a.extend(s.prototype,r.Events,{initialize:function(){},route:function(n,r,i){a.isRegExp(n)||(n=this._routeToRegExp(n)),a.isFunction(r)&&(i=r,r=""),i||(i=this[r]);var o=this;return s.history.route(n,function(t){var e=o._extractParameters(n,t);i&&i.apply(o,e),o.trigger.apply(o,["route:"+r].concat(e)),o.trigger("route",r,e),s.history.trigger("route",o,r,e)}),this},navigate:function(t,e){return s.history.navigate(t,e),this},_bindRoutes:function(){if(this.routes){this.routes=a.result(this,"routes");for(var t,e=a.keys(this.routes);null!=(t=e.pop());)this.route(t,this.routes[t])}},_routeToRegExp:function(t){return t=t.replace(u,"\\$&").replace(i,"(?:$1)?").replace(o,function(t,e){return e?t:"([^/]+)"}).replace(c,"(.*?)"),new RegExp("^"+t+"$")},_extractParameters:function(t,e){var n=t.exec(e).slice(1);return a.map(n,function(t){return t?decodeURIComponent(t):null})}});var l=s.History=function(){this.handlers=[],a.bindAll(this,"checkUrl"),"undefined"!=typeof window&&(this.location=window.location,this.history=window.history)},p=/^[#\/]|\s+$/g,h=/^\/+|\/+$/g,d=/msie [\w.]+/,f=/\/$/;l.started=!1,a.extend(l.prototype,r.Events,{interval:50,getHash:function(t){var e=(t||this).location.href.match(/#(.*)$/);return e?e[1]:""},getFragment:function(t,e){if(null==t)if(this._hasPushState||!this._wantsHashChange||e){t=this.location.pathname;var n=this.root.replace(f,"");t.indexOf(n)||(t=t.substr(n.length))}else t=this.getHash();return t.replace(p,"")},start:function(t){if(l.started)throw new Error("Router.history has already been started");l.started=!0,this.options=a.extend({},{root:"/"},this.options,t),this.root=this.options.root,this._wantsHashChange=!1!==this.options.hashChange,this._wantsPushState=!!this.options.pushState,this._hasPushState=!!(this.options.pushState&&this.history&&this.history.pushState);var e=this.getFragment(),n=document.documentMode,r=d.exec(navigator.userAgent.toLowerCase())&&(!n||n<=7);this.root=("/"+this.root+"/").replace(h,"/"),r&&this._wantsHashChange&&(this.iframe=$('<iframe src="javascript:0" tabindex="-1" />').hide().appendTo("body")[0].contentWindow,this.navigate(e)),this._hasPushState?$(window).on("popstate",this.checkUrl):this._wantsHashChange&&"onhashchange"in window&&!r?$(window).on("hashchange",this.checkUrl):this._wantsHashChange&&(this._checkUrlInterval=setInterval(this.checkUrl,this.interval)),this.fragment=e;var i=this.location,o=i.pathname.replace(/[^\/]$/,"$&/")===this.root;return this._wantsHashChange&&this._wantsPushState&&!this._hasPushState&&!o?(this.fragment=this.getFragment(null,!0),this.location.replace(this.root+this.location.search+"#"+this.fragment),!0):(this._wantsPushState&&this._hasPushState&&o&&i.hash&&(this.fragment=this.getHash().replace(p,""),this.history.replaceState({},document.title,this.root+this.fragment+i.search)),this.options.silent?void 0:this.loadUrl())},stop:function(){$(window).off("popstate",this.checkUrl).off("hashchange",this.checkUrl),clearInterval(this._checkUrlInterval),l.started=!1},route:function(t,e){this.handlers.unshift({route:t,callback:e})},checkUrl:function(t){var e=this.getFragment();if(e===this.fragment&&this.iframe&&(e=this.getFragment(this.getHash(this.iframe))),e===this.fragment)return!1;this.iframe&&this.navigate(e),this.loadUrl()||this.loadUrl(this.getHash())},loadUrl:function(t){var e=this.fragment=this.getFragment(t);return a.any(this.handlers,function(t){if(t.route.test(e))return t.callback(e),!0})},navigate:function(t,e){if(!l.started)return!1;if(e&&!0!==e||(e={trigger:e}),t=this.getFragment(t||""),this.fragment!==t){this.fragment=t;var n=this.root+t;if(this._hasPushState)this.history[e.replace?"replaceState":"pushState"]({},document.title,n);else{if(!this._wantsHashChange)return this.location.assign(n);this._updateHash(this.location,t,e.replace),this.iframe&&t!==this.getFragment(this.getHash(this.iframe))&&(e.replace||this.iframe.document.open().close(),this._updateHash(this.iframe.location,t,e.replace))}e.trigger&&this.loadUrl(t)}},_updateHash:function(t,e,n){if(n){var r=t.href.replace(/(javascript:|#).*$/,"");t.replace(r+"#"+e)}else t.hash="#"+e}}),s.history=new l,e.exports=s},{"../../substance/util":183,underscore:131}],164:[function(t,e,n){"use strict";function r(t){t=t||{},this.el=t.el||window.document.createElement(t.elementType||"div"),this.$el=$(this.el),this.dispatchDOMEvents()}var i=t("../../substance/util");(r.Prototype=function(){this.$=function(t){return this.$el.find(t)},this.render=function(){return this},this.dispatchDOMEvents=function(){var r=this;this.$el.delegate("[sbs-click]","click",function(t){console.error("FIXME: sbs-click is deprecated. Use jquery handlers with selectors instead.");var e=function(t){var e=/(\w+)\((.*)\)/.exec(t);if(!e)throw new Error("Invalid click handler '"+t+"'");return{method:e[1],args:e[2].split(",")}}($(t.currentTarget).attr("sbs-click")),n=r[e.method];if(n)return t.stopPropagation(),t.preventDefault(),n.apply(r,e.args),!1})}}).prototype=i.Events,r.prototype=new r.Prototype,e.exports=r},{"../../substance/util":183}],165:[function(t,e,n){"use strict";function o(t){return i.isArray(t)&&(t=t[0]),0<=h.indexOf(t)}function r(t,e){if(e=e||{},this.schema=new c(t),this.schema.id&&e.seed&&e.seed.schema&&!i.isEqual(e.seed.schema,[this.schema.id,this.schema.version]))throw new p(["Graph does not conform to schema. Expected: ",this.schema.id+"@"+this.schema.version," Actual: ",e.seed.schema[0]+"@"+e.seed.schema[1]].join(""));this.nodes={},this.indexes={},this.__seed__=e.seed,this.init()}var i=t("underscore"),s=t("../../substance/util"),a=s.errors,c=t("./schema"),u=t("./property"),l=t("./graph_index"),p=a.define("GraphError"),h=["object","array","string","number","boolean","date"];r.Prototype=function(){i.extend(this,s.Events),this.create=function(t){this.nodes[t.id]=t,this._updateIndexes({type:"create",path:[t.id],val:t})},this.delete=function(t){var e=this.nodes[t];delete this.nodes[t],this._updateIndexes({type:"delete",path:[t],val:e})},this.set=function(t,e){var n=this.resolve(t);if(!n)throw new p("Could not resolve property with path "+JSON.stringify(t));var r=n.get();n.set(e),this._updateIndexes({type:"set",path:t,val:e,original:r})},this.get=function(t){if(!i.isArray(t)&&!i.isString(t))throw new p("Invalid argument path. Must be String or Array");return 1<arguments.length&&(t=i.toArray(arguments)),i.isString(t)?this.nodes[t]:this.resolve(t).get()},this.query=function(t){var e=this.resolve(t),n=e.type,r=e.baseType,i=e.get();return"array"===r?this._queryArray.call(this,i,n):o(r)?i:this.get(i)},this.toJSON=function(){return{id:this.id,schema:[this.schema.id,this.schema.version],nodes:s.deepclone(this.nodes)}},this.contains=function(t){return!!this.nodes[t]},this.resolve=function(t){return new u(this,t)},this.reset=function(){this.init(),this.trigger("graph:reset")},this.init=function(){this.__is_initializing__=!0,this.__seed__?this.nodes=s.clone(this.__seed__.nodes):this.nodes={},i.each(this.indexes,function(t){t.reset()}),delete this.__is_initializing__},this.addIndex=function(t,e){if(this.indexes[t])throw new p("Index with name "+t+"already exists.");var n=new l(this,e);return this.indexes[t]=n},this.removeIndex=function(t){delete this.indexes[t]},this._updateIndexes=function(e){i.each(this.indexes,function(t){e?t.onGraphChange(e):t.rebuild()},this)},this._queryArray=function(t,e){if(!i.isArray(e))throw new p("Illegal argument: array types must be specified as ['array'(, 'array')*, <type>]");var n,r;if("array"===e[1])for(n=[],r=0;r<t.length;r++)n.push(this._queryArray(t[r],e.slice(1)));else if(o(e[1]))n=t;else for(n=[],r=0;r<t.length;r++)n.push(this.get(t[r]));return n}},r.DEFAULT_MODE=r.STRICT_INDEXING=2,r.prototype=new r.Prototype,r.Schema=c,r.Property=u,r.Index=l,e.exports=r},{"../../substance/util":183,"./graph_index":166,"./property":168,"./schema":169,underscore:131}],166:[function(t,e,n){var a=t("underscore"),r=t("../../substance/util"),o=function(t,e){e=e||{},this.graph=t,this.nodes={},this.scopes={},e.filter?this.filter=e.filter:e.types&&(this.filter=o.typeFilter(t.schema,e.types)),e.property&&(this.property=e.property),this.createIndex()};o.Prototype=function(){function s(t){var e=this;if(null!==t)for(var n=0;n<t.length;n++){var r=t[n];e.scopes[r]=e.scopes[r]||{nodes:{},scopes:{}},e=e.scopes[r]}return e}function n(t){if(!this.property)return null;var e=t[this.property]?t[this.property]:null;return a.isString(e)&&(e=[e]),e}var i=function(t){var n=a.extend({},t.nodes);return a.each(t.scopes,function(t,e){"nodes"!==e&&a.extend(n,i(t))}),n};this.onGraphChange=function(t){this.applyOp(t)},this._add=function(t){if(!this.filter||this.filter(t)){var e=n.call(this,t);s.call(this,e).nodes[t.id]=t.id}},this._remove=function(t){if(!this.filter||this.filter(t)){var e=n.call(this,t);delete s.call(this,e).nodes[t.id]}},this._update=function(t,e,n,r){if(this.property===e&&(!this.filter||this.filter(t))){var i=r;a.isString(i)&&(i=[i]);var o=s.call(this,i);delete o.nodes[t.id],i=n,o.nodes[t.id]=t.id}},this.applyOp=function(t){if("create"===t.type)this._add(t.val);else if("delete"===t.type)this._remove(t.val);else{var e,n=this.graph.resolve(this,t.path),r=n.get();if(void 0===r)return;"set"===t.type?e=t.original:console.error("Operational updates are not supported in this implementation"),this._update(n.node,n.key,r,e)}},this.createIndex=function(){this.reset();var t=this.graph.nodes;a.each(t,function(t){if(!this.filter||this.filter(t)){var e=n.call(this,t);s.call(this,e).nodes[t.id]=t.id}},this)},this.get=function(t){0===arguments.length?t=null:a.isString(t)&&(t=[t]);var e=s.call(this,t),n=i(e),r=new o.Result;return a.each(n,function(t){r[t]=this.graph.get(t)},this),r},this.reset=function(){this.nodes={},this.scopes={}},this.dispose=function(){this.stopListening()},this.rebuild=function(){this.reset(),this.createIndex()}},o.prototype=a.extend(new o.Prototype,r.Events.Listener),o.typeFilter=function(r,i){return function(t){for(var e=r.typeChain(t.type),n=0;n<i.length;n++)if(0<=e.indexOf(i[n]))return!0;return!1}},o.Result=function(){},o.Result.prototype.asList=function(){var t=[];for(var e in this)t.push(this[e])},o.Result.prototype.getLength=function(){return Object.keys(this).length},e.exports=o},{"../../substance/util":183,underscore:131}],167:[function(t,e,n){"use strict";var r={VERSION:"0.8.0"};r.Graph=t("./graph"),e.exports=r},{"./graph":165}],168:[function(t,e,n){"use strict";function r(t,e){if(!e)throw new Error("Illegal argument: path is null/undefined.");this.graph=t,this.schema=t.schema,i.extend(this,this.resolve(e))}var i=t("underscore");r.Prototype=function(){this.resolve=function(t){for(var e,n,r=this.graph,i=r,o="graph",s=0;s<t.length;s++)if("graph"===o||void 0!==this.schema.types[o]){if(void 0===(i=this.graph.get(t[s])))return;r=i,o=this.schema.properties(i.type),n=r,e=void 0}else{if(void 0===i)return;e=t[s];var a=t[s];o=o[a],n=i[e],s<t.length-1&&(i=i[a])}return{node:r,parent:i,type:o,key:e,value:n}},this.get=function(){return void 0!==this.key?this.parent[this.key]:this.node},this.set=function(t){if(void 0===this.key)throw new Error("'set' is only supported for node properties.");this.parent[this.key]=this.schema.parseValue(this.baseType,t)}},r.prototype=new r.Prototype,Object.defineProperties(r.prototype,{baseType:{get:function(){return i.isArray(this.type)?this.type[0]:this.type}},path:{get:function(){return[this.node.id,this.key]}}}),e.exports=r},{underscore:131}],169:[function(t,e,n){"use strict";function r(t){i.extend(this,t)}var i=t("underscore"),o=t("../../substance/util");r.Prototype=function(){this.defaultValue=function(t){return"object"===t?{}:"array"===t?[]:"string"===t?"":"number"===t?0:"boolean"!==t&&("date"===t?new Date:null)},this.parseValue=function(t,e){if(null===e)return e;if(i.isString(e)){if("object"===t)return JSON.parse(e);if("array"===t)return JSON.parse(e);if("string"===t)return e;if("number"===t)return parseInt(e,10);if("boolean"!==t)return"date"===t?new Date(e):e;if("true"===e)return!0;if("false"===e)return!1;throw new Error("Can not parse boolean value from: "+e)}if("array"===t){if(!i.isArray(e))throw new Error("Illegal value type: expected array.");e=o.deepclone(e)}else if("string"===t){if(!i.isString(e))throw new Error("Illegal value type: expected string.")}else if("object"===t){if(!i.isObject(e))throw new Error("Illegal value type: expected object.");e=o.deepclone(e)}else if("number"===t){if(!i.isNumber(e))throw new Error("Illegal value type: expected number.")}else if("boolean"===t){if(!i.isBoolean(e))throw new Error("Illegal value type: expected boolean.")}else{if("date"!==t)throw new Error("Unsupported value type: "+t);e=new Date(e)}return e},this.type=function(t){return this.types[t]},this.typeChain=function(t){var e=this.types[t];if(!e)throw new Error("Type "+t+" not found in schema");var n=e.parent?this.typeChain(e.parent):[];return n.push(t),n},this.isInstanceOf=function(t,e){var n=this.typeChain(t);return!!(n&&0<=n.indexOf(e))},this.baseType=function(t){return this.typeChain(t)[0]},this.properties=function(t){var e=(t=i.isObject(t)?t:this.type(t)).parent?this.properties(t.parent):{};return i.extend(e,t.properties),e},this.propertyType=function(t,e){var n=this.properties(t)[e];if(!n)throw new Error("Property not found for"+t+"."+e);return i.isArray(n)?n:[n]},this.propertyBaseType=function(t,e){return this.propertyType(t,e)[0]}},r.prototype=new r.Prototype,e.exports=r},{"../../substance/util":183,underscore:131}],170:[function(t,e,n){function r(t,e){i.call(this,t,e)}var i=t("./node");r.type={id:"composite",parent:"content",properties:{}},r.description={name:"Composite",remarks:["A file reference to an external resource."],properties:{}},r.example={no_example:"yet"},(r.Prototype=function(){this.getLength=function(){throw new Error("Composite.getLength() is abstract.")},this.getNodes=function(){return this.getChildrenIds()},this.getChildrenIds=function(){throw new Error("Composite.getChildrenIds() is abstract.")},this.isMutable=function(){return!1},this.insertOperation=function(){return null},this.deleteOperation=function(){return null},this.insertChild=function(){throw new Error("This composite is immutable.")},this.deleteChild=function(){throw new Error("This composite is immutable.")},this.getChangePosition=function(t){return 0}}).prototype=i.prototype,r.prototype=new r.Prototype,e.exports=r},{"./node":175}],171:[function(t,e,n){"use strict";function r(t,e){this.document=t,this.view=e,this.treeView=[],this.listView=[],this.__parents={},this.__composites={},this.rebuild()}var i=t("underscore"),o=t("../../substance/util"),a=t("./composite");r.Prototype=function(){this.rebuild=function(){this.treeView.splice(0,this.treeView.length),this.listView.splice(0,this.listView.length),this.treeView=i.clone(this.view.nodes);for(var t=0;t<this.view.length;t++)this.treeView.push(this.view[t]);this.__parents={},this.__composites={},function(t,e){var n,r,i,o=[];for(n=this.treeView.length-1;0<=n;n--)o.unshift({id:this.treeView[n],parent:null});for(;0<o.length;){if(r=o.shift(),(i=this.document.get(r.id))instanceof a){var s=i.getNodes();for(n=s.length-1;0<=n;n--)o.unshift({id:s[n],parent:i.id})}t.call(e,i,r.parent)}}.call(this,function(t,e){if(t instanceof a)this.__parents[t.id]=e,this.__composites[e]=e;else{if(this.listView.push(t.id),this.__parents[t.id])throw new Error("Nodes must be unique in one view.");this.__parents[t.id]=e,this.__composites[e]=e}},this)},this.getTopLevelNodes=function(){return i.map(this.treeView,function(t){return this.document.get(t)},this)},this.getNodes=function(t){var e=this.listView;if(t)return i.clone(e);for(var n=[],r=0;r<e.length;r++)n.push(this.document.get(e[r]));return n},this.getPosition=function(t){return this.listView.indexOf(t)},this.getNodeFromPosition=function(t){var e=this.listView[t];return void 0!==e?this.document.get(e):null},this.getParent=function(t){return this.__parents[t]},this.getRoot=function(t){for(var e=t;e;)t=e,e=this.getParent(t);return t},this.update=function(t){var e=t.path;e[0]!==this.view.id&&void 0===this.__composites[e[0]]||this.rebuild()},this.getLength=function(){return this.listView.length},this.hasSuccessor=function(t){return t<this.getLength()-1},this.hasPredecessor=function(t){return 0<t},this.getPredecessor=function(t){var e=this.getPosition(t);return e<=0?null:this.getNodeFromPosition(e-1)},this.getSuccessor=function(t){var e=this.getPosition(t);return e>=this.getLength()-1?null:this.getNodeFromPosition(e+1)},this.firstChild=function(t){if(t instanceof a){var e=this.document.get(t.getNodes()[0]);return this.firstChild(e)}return t},this.lastChild=function(t){if(t instanceof a){var e=this.document.get(i.last(t.getNodes()));return this.lastChild(e)}return t},this.before=function(t){var e=this.firstChild(t);return[this.getPosition(e.id),0]},this.after=function(t){var e=this.lastChild(t);return[this.getPosition(e.id),e.getLength()]}},r.prototype=i.extend(new r.Prototype,o.Events.Listener),Object.defineProperties(r.prototype,{id:{get:function(){return this.view.id}},type:{get:function(){return this.view.type}},nodes:{get:function(){return this.view.nodes},set:function(t){this.view.nodes=t}}}),e.exports=r},{"../../substance/util":183,"./composite":170,underscore:131}],172:[function(t,e,n){"use strict";function r(t,e){e=e||{},this.view=e.view||"content",this.__document=t,this.container=t.get(this.view)}var i=t("underscore"),o=t("../../substance/util");r.Prototype=function(){this.getNodes=function(t){return this.container.getNodes(t)},this.getContainer=function(){return this.container},this.getPosition=function(t,e){return this.container.getPosition(t,e)},this.getNodeFromPosition=function(t){return this.container.getNodeFromPosition(t)},this.getAnnotations=function(t){return(t=t||{}).view=this.view,this.annotator.getAnnotations(t)},this.get=function(){return this.__document.get.apply(this.__document,arguments)},this.on=function(){return this.__document.on.apply(this.__document,arguments)},this.off=function(){return this.__document.off.apply(this.__document,arguments)},this.getDocument=function(){return this.__document}},r.prototype=i.extend(new r.Prototype,o.Events.Listener),Object.defineProperties(r.prototype,{id:{get:function(){return this.__document.id},set:function(){throw"immutable property"}},nodeTypes:{get:function(){return this.__document.nodeTypes},set:function(){throw"immutable property"}},title:{get:function(){return this.__document.get("document").title},set:function(){throw"immutable property"}},updated_at:{get:function(){return this.__document.get("document").updated_at},set:function(){throw"immutable property"}},creator:{get:function(){return this.__document.get("document").creator},set:function(){throw"immutable property"}}}),e.exports=r},{"../../substance/util":183,underscore:131}],173:[function(t,e,n){"use strict";function r(t){a.Graph.call(this,t.schema,t),this.containers={},this.addIndex("annotations",{types:["annotation"],property:"path"})}var s=t("underscore"),o=t("../../substance/util"),i=o.errors,a=t("../../substance/data"),c=t("./container"),u=i.define("DocumentError");r.schema={indexes:{},types:{content:{properties:{}},view:{properties:{nodes:["array","content"]}}}},(r.Prototype=function(){var i=o.prototype(this);this.getIndex=function(t){return this.indexes[t]},this.getSchema=function(){return this.schema},this.create=function(t){return i.create.call(this,t),this.get(t.id)},this.get=function(t){var e=i.get.call(this,t);if(!e)return e;if("view"===e.type)return this.containers[e.id]||(this.containers[e.id]=new c(this,e)),this.containers[e.id];var n=this.nodeTypes[e.type],r=void 0!==n?n.Model:null;return!r||e instanceof r||(e=new r(e,this),this.nodes[e.id]=e),e},this.toJSON=function(){var t=i.toJSON.call(this);return t.id=this.id,t},this.hide=function(t,e){var n=this.get(t);if(!n)throw new u("Invalid view id: "+t);s.isString(e)&&(e=[e]);var r=[];if(s.each(e,function(t){var e=n.nodes.indexOf(t);0<=e&&r.push(e)},this),0!==r.length){r=r.sort().reverse(),r=s.uniq(r);for(var i=this.nodes[t],o=0;o<r.length;o++)i.nodes.splice(r[o],1)}},this.show=function(t,e,n){void 0===n&&(n=-1);var r=this.get(t);if(!r)throw new u("Invalid view id: "+t);var i=r.nodes.length;(n=Math.min(n,i))<0&&(n=Math.max(0,i+n+1)),r.nodes.splice(n,0,e)},this.fromSnapshot=function(t,e){return r.fromSnapshot(t,e)},this.uuid=function(t){return t+"_"+o.uuid()}}).prototype=a.Graph.prototype,r.prototype=new r.Prototype,r.fromSnapshot=function(t,e){return(e=e||{}).seed=t,new r(e)},r.DocumentError=u,e.exports=r},{"../../substance/data":167,"../../substance/util":183,"./container":171,underscore:131}],174:[function(t,e,n){"use strict";t("underscore");var r=t("./document");r.Container=t("./container"),r.Controller=t("./controller"),r.Node=t("./node"),r.Composite=t("./composite"),r.TextNode=t("./text_node"),e.exports=r},{"./composite":170,"./container":171,"./controller":172,"./document":173,"./node":175,"./text_node":176,underscore:131}],175:[function(t,e,n){"use strict";function r(t,e){this.document=e,this.properties=t}var o=t("underscore");r.type={parent:"content",properties:{}},r.properties={abstract:!0,immutable:!0,mergeableWith:[],preventEmpty:!0,allowedAnnotations:[]},r.Prototype=function(){this.toJSON=function(){return o.clone(this.properties)},this.getLength=function(){throw new Error("Node.getLength() is abstract.")},this.getChangePosition=function(t){throw new Error("Node.getCharPosition() is abstract.")},this.insertOperation=function(t,e){throw new Error("Node.insertOperation() is abstract.")},this.deleteOperation=function(t,e){throw new Error("Node.deleteOperation() is abstract.")},this.canJoin=function(t){return!1},this.join=function(t){throw new Error("Node.join() is abstract.")},this.isBreakable=function(){return!1},this.break=function(t,e){throw new Error("Node.split() is abstract.")},this.getAnnotations=function(){return this.document.getIndex("annotations").get(this.properties.id)},this.includeInToc=function(){return!1}},((r.prototype=new r.Prototype).constructor=r).defineProperties=function(t,e,n){var r=t;if(1===arguments.length){var i=t;if(!(r=i.prototype)||!i.type)throw new Error("Illegal argument: expected NodeClass");e=Object.keys(i.type.properties)}o.each(e,function(e){var t={get:function(){return this.properties[e]}};n||(t.set=function(t){return this.properties[e]=t,this}),Object.defineProperty(r,e,t)})},r.defineProperties(r.prototype,["id","type"]),e.exports=r},{underscore:131}],176:[function(t,e,n){"use strict";function r(t,e){i.call(this,t,e)}var i=t("./node");r.type={id:"text",parent:"content",properties:{source_id:"Text element source id",content:"string"}},r.description={name:"Text",remarks:["A simple text fragement that can be annotated. Usually text nodes are combined in a paragraph."],properties:{content:"Content"}},r.example={type:"paragraph",id:"paragraph_1",content:"Lorem ipsum dolor sit amet, adipiscing elit."},(r.Prototype=function(){this.getLength=function(){return this.properties.content.length}}).prototype=i.prototype,(r.prototype=new r.Prototype).constructor=r,i.defineProperties(r.prototype,["content"]),e.exports=r},{"./node":175}],177:[function(t,e,n){"use strict";var h=t("underscore"),u=t("./util.js"),r={};function d(t,n){var i=t.finally||function(t,e){n(t,e)};i=h.once(i);var e=t.data||{},o=t.functions;if(!h.isFunction(n))return n("Illegal arguments: a callback function must be provided");var s=0,a=void 0===t.stopOnError||t.stopOnError,c=[];!function n(t){var e=o[s];if(!e)return 0<c.length?i(new Error("Multiple errors occurred.",t)):i(null,t);var r=h.once(function(t,e){if(t){if(a)return i(t,null);c.push(t)}s+=1,n(e)});try{0===e.length?(e(),r(null,t)):1===e.length?e(r):e(t,r)}catch(t){console.log("util.async caught error:",t),u.printStackTrace(t),i(t)}}(e)}function i(p){return function(t,n){var e=p.selector?p.selector(t):p.items,r=p.finally||function(t,e){n(t,e)};if(r=h.once(r),!e)return r(null,t);var i=h.isArray(e);p.before&&p.before(t);var o=[],s=p.iterator;function a(n,r){return function(t,e){2===s.length?s(n,e):3===s.length?s(n,r,e):s(n,r,t,e)}}function c(n,r){return function(t,e){2===s.length?s(n,e):3===s.length?s(n,r,e):s(n,r,t,e)}}if(i)for(var u=0;u<e.length;u++)o.push(a(e[u],u));else for(var l in e)o.push(c(e[l],l));d({functions:o,data:t,finally:r,stopOnError:p.stopOnError},n)}}r.sequential=function(t,e){h.isArray(t)&&(t={functions:t}),d(t,e)},r.iterator=function(t,e){return i(1==arguments.length?t:{items:t,iterator:e})},r.each=function(t,e){i(t)(null,e)},e.exports=r},{"./util.js":185,underscore:131}],178:[function(t,e,n){"use strict";var r=t("underscore"),i={ChildNodeIterator:function(t){r.isArray(t)?this.nodes=t:this.nodes=t.childNodes,this.length=this.nodes.length,this.pos=-1}};i.ChildNodeIterator.prototype={hasNext:function(){return this.pos<this.length-1},next:function(){return this.pos+=1,this.nodes[this.pos]},back:function(){return 0<=this.pos&&(this.pos-=1),this}},i.getChildren=function(t){if(void 0!==t.children)return t.children;for(var e=[],n=t.firstElementChild;n;)e.push(n),n=n.nextElementSibling;return e},i.getNodeType=function(t){return t.nodeType===window.Node.TEXT_NODE?"text":t.nodeType===window.Node.COMMENT_NODE?"comment":t.tagName?t.tagName.toLowerCase():(console.error("Can't get node type for ",t),"unknown")},e.exports=i},{underscore:131}],179:[function(t,e,n){"use strict";var r=t("./util"),o={},s=function(t,e){e?(Error.call(this,t,e.fileName,e.lineNumber),e instanceof s?this.__stack=e.__stack:e.stack?this.__stack=r.parseStackTrace(e):this.__stack=r.callstack(1)):(Error.call(this,t),this.__stack=r.callstack(1)),this.message=t};s.Prototype=function(){this.name="SubstanceError",this.code=-1,this.toString=function(){return this.name+":"+this.message},this.toJSON=function(){return{name:this.name,message:this.message,code:this.code,stack:this.stack}},this.printStackTrace=function(){r.printStackTrace(this)}},s.Prototype.prototype=Error.prototype,s.prototype=new s.Prototype,Object.defineProperty(s.prototype,"stack",{get:function(){for(var t=[],e=0;e<this.__stack.length;e++){var n=this.__stack[e];t.push(n.file+":"+n.line+":"+n.col+" ("+n.func+")")}return t.join("\n")},set:function(){throw new Error("SubstanceError.stack is read-only.")}}),o.SubstanceError=s;o.define=function(t,e,n){if(!t)throw new s("Name is required.");void 0===e&&(e=-1);function r(){}var i=function(e,n,r){return function(t){e.call(this,t),this.name=n,this.code=r}}(n=n||s,t,e);return r.prototype=n.prototype,i.prototype=new r,i.prototype.constructor=i,o[t]=i},e.exports=o},{"./util":185}],180:[function(t,e,n){"use strict";function r(t){this.levels=t||{}}var l=t("underscore");r.Prototype=function(){this.onText=function(){},this.onEnter=function(){return null},this.onExit=function(){},this.enter=function(t,e){return this.onEnter(t,e)},this.exit=function(t,e){this.onExit(t,e)},this.createText=function(t,e){this.onText(t,e)},this.start=function(t,e,n){var r=function(t){var n=[];return l.each(t,function(t){var e=this.levels[t.type]||1e3;n.push({pos:t.range[0],mode:1,level:e,id:t.id,type:t.type,node:t}),n.push({pos:t.range[1],mode:-1,level:e,id:t.id,type:t.type,node:t})},this),n}.call(this,n);r.sort(function(t,e){if(t.pos<e.pos)return-1;if(t.pos>e.pos)return 1;if(t.mode<e.mode)return-1;if(t.mode>e.mode)return 1;if(1===t.mode){if(t.level<e.level)return-1;if(t.level>e.level)return 1}if(-1===t.mode){if(t.level>e.level)return-1;if(t.level<e.level)return 1}return 0}.bind(this));for(var i=[{context:t,entry:null}],o=0,s=0;s<r.length;s++){var a=r[s];this.createText(i[i.length-1].context,e.substring(o,a.pos)),o=a.pos;var c,u=1;if(1===a.mode){for(;u<i.length&&!(a.level<i[u].entry.level);u++);i.splice(u,0,{entry:a})}else if(-1===a.mode){for(;u<i.length&&i[u].entry.id!==a.id;u++);for(c=u;c<i.length;c++)this.exit(i[c].entry,i[c-1].context);i.splice(u,1)}for(c=u;c<i.length;c++)i[c].context=this.enter(i[c].entry,i[c-1].context)}this.createText(t,e.substring(o))}},r.prototype=new r.Prototype,e.exports=r},{underscore:131}],181:[function(t,e,n){"use strict";var r=t("underscore"),i=r.map,o=r.each;function s(t){var e={left:Number.POSITIVE_INFINITY,top:Number.POSITIVE_INFINITY,right:Number.NEGATIVE_INFINITY,bottom:Number.NEGATIVE_INFINITY,width:Number.NaN,height:Number.NaN};return o(t,function(t){t.left<e.left&&(e.left=t.left),t.top<e.top&&(e.top=t.top),t.left+t.width>e.right&&(e.right=t.left+t.width),t.top+t.height>e.bottom&&(e.bottom=t.top+t.height)}),e.width=e.right-e.left,e.height=e.bottom-e.top,e}e.exports=function(t,e){void 0===t.length&&(t=[t]);var n=s(i(t,function(t){return function(t,e){var n=e.getBoundingClientRect(),r=s(t.getClientRects()),i=r.left-n.left,o=r.top-n.top;return{left:i,top:o,right:n.width-i-r.width,bottom:n.height-o-r.height,width:r.width,height:r.height}}(t,e)})),r=e.getBoundingClientRect();return{left:n.left,top:n.top,right:r.width-n.left-n.width,bottom:r.height-n.top-n.height,width:n.width,height:n.height}}},{underscore:131}],182:[function(t,e,n){"use strict";var r={},i=t("underscore");r.templates={},r.renderTemplate=function(t,e){return r.templates[t](e)},"undefined"!=typeof window&&(window.console||(window.console={log:function(){}})),r.tpl=function(t,e){e=e||{};var n=window.$("script[name="+t+"]").html();return i.template(n,e)},e.exports=r},{underscore:131}],183:[function(t,e,n){"use strict";var r=t("./util");r.async=t("./async"),r.errors=t("./errors"),r.html=t("./html"),r.dom=t("./dom"),r.RegExp=t("./regexp"),r.Fragmenter=t("./fragmenter"),e.exports=r},{"./async":177,"./dom":178,"./errors":179,"./fragmenter":180,"./html":182,"./regexp":184,"./util":185}],184:[function(t,e,n){"use strict";function r(t){this.index=t.index,this.match=[];for(var e=0;e<t.length;e++)this.match.push(t[e])}r.Prototype=function(){this.captures=function(){return this.match.slice(1)},this.toString=function(){return this.match[0]}},r.prototype=new r.Prototype;function i(t){this.exp=t}i.Prototype=function(){this.match=function(t){if(void 0===t)throw new Error("No string given");if(this.exp.global){var e,n=[];for(this.exp.compile(this.exp);null!==(e=this.exp.exec(t));)n.push(new r(e));return n}return this.exp.exec(t)}},i.prototype=new i.Prototype,i.Match=r,e.exports=i},{}],185:[function(i,t,e){"use strict";function o(t,e){var n,r=-1,i=t.length,o=e[0],s=e[1],a=e[2];switch(e.length){case 0:for(;++r<i;)(n=t[r]).callback.call(n.ctx);return;case 1:for(;++r<i;)(n=t[r]).callback.call(n.ctx,o);return;case 2:for(;++r<i;)(n=t[r]).callback.call(n.ctx,o,s);return;case 3:for(;++r<i;)(n=t[r]).callback.call(n.ctx,o,s,a);return;default:for(;++r<i;)(n=t[r]).callback.apply(n.ctx,e)}}function p(t,e,n,r){if(!n)return!0;if("object"==typeof n){for(var i in n)t[e].apply(t,[i,n[i]].concat(r));return!1}if(c.test(n)){for(var o=n.split(c),s=0,a=o.length;s<a;s++)t[e].apply(t,[o[s]].concat(r));return!1}return!0}var h=i("underscore"),s={uuid:function(t,e){var n,r,i="0123456789abcdefghijklmnopqrstuvwxyz".split(""),o=[];if(e=e||32)for(n=0;n<e;n++)o[n]=i[0|16*Math.random()];else for(o[8]=o[13]=o[18]=o[23]="-",o[14]="4",n=0;n<36;n++)o[n]||(r=0|16*Math.random(),o[n]=i[19==n?3&r|8:r]);return(t||"")+o.join("")},uuidGen:function(e){var n=1;return e=void 0!==e?e:"uuid_",function(t){return(t=t||e)+n++}}},c=/\s+/;s.Events={on:function(t,e,n){return p(this,"on",t,[e,n])&&e&&(this._events=this._events||{},(this._events[t]||(this._events[t]=[])).push({callback:e,context:n,ctx:n||this})),this},once:function(t,e,n){if(!p(this,"once",t,[e,n])||!e)return this;var r=this,i=h.once(function(){r.off(t,i),e.apply(this,arguments)});return i._callback=e,this.on(t,i,n)},off:function(t,e,n){var r,i,o,s,a,c,u,l;if(!this._events||!p(this,"off",t,[e,n]))return this;if(!t&&!e&&!n)return this._events={},this;for(a=0,c=(s=t?[t]:h.keys(this._events)).length;a<c;a++)if(t=s[a],o=this._events[t]){if(this._events[t]=r=[],e||n)for(u=0,l=o.length;u<l;u++)i=o[u],(e&&e!==i.callback&&e!==i.callback._callback||n&&n!==i.context)&&r.push(i);r.length||delete this._events[t]}return this},trigger:function(t){if(!this._events)return this;var e=Array.prototype.slice.call(arguments,1);if(!p(this,"trigger",t,e))return this;var n=this._events[t],r=this._events.all;return n&&o(n,e),r&&o(r,arguments),this},triggerLater:function(){var t=this,e=arguments;window.setTimeout(function(){t.trigger.apply(t,e)},0)},stopListening:function(t,e,n){var r=this._listeners;if(!r)return this;var i=!e&&!n;for(var o in"object"==typeof e&&(n=this),t&&((r={})[t._listenerId]=t),r)r[o].off(e,n,this),i&&delete this._listeners[o];return this}};h.each({listenTo:"on",listenToOnce:"once"},function(i,t){s.Events[t]=function(t,e,n){var r=this._listeners||(this._listeners={});return"object"==typeof e&&(n=this),(r[t._listenerId||(t._listenerId=h.uniqueId("l"))]=t)[i](e,n,this),this}}),s.Events.bind=s.Events.on,s.Events.unbind=s.Events.off,s.Events.Listener={listenTo:function(t,e,n){if(!h.isFunction(n))throw new Error("Illegal argument: expecting function as callback, was: "+n);return this._handlers=this._handlers||[],t.on(e,n,this),this._handlers.push({unbind:function(){t.off(e,n)}}),this},stopListening:function(){if(this._handlers)for(var t=0;t<this._handlers.length;t++)this._handlers[t].unbind()}},s.propagate=function(e,n){if(!h.isFunction(n))throw"Illegal argument: provided callback is not a function";return function(t){if(t)return n(t);n(null,e)}};function a(){}s.inherits=function(t,e,n){var r;return r=e&&e.hasOwnProperty("constructor")?e.constructor:function(){t.apply(this,arguments)},h.extend(r,t),a.prototype=t.prototype,r.prototype=new a,e&&h.extend(r.prototype,e),n&&h.extend(r,n),(r.prototype.constructor=r).__super__=t.prototype,r},s.getJSON=function(t,e){if("undefined"==typeof window||"undefined"!=typeof nwglobal){var n=i("fs"),r=JSON.parse(n.readFileSync(t,"utf8"));e(null,r)}else{window.$.getJSON(t).done(function(t){e(null,t)}).error(function(t){e(t,null)})}},s.prototype=function(t){return Object.getPrototypeOf?Object.getPrototypeOf(t):t.__proto__},s.inherit=function(t,e){var n,r=h.isFunction(t)?new t:t;if(h.isFunction(e))e.prototype=r,n=new e;else{var i=function(){};i.prototype=r,n=h.extend(new i,e)}return n},s.pimpl=function(t){function e(t){this.self=t}return e.prototype=t,function(t){return new e(t=t||this)}},s.parseStackTrace=function(t){var e,n=/([^@]*)@(.*):(\d+)/,r=/\s*at ([^(]*)[(](.*):(\d+):(\d+)[)]/,i=t.stack.split("\n"),o=[];for(e=0;e<i.length;e++){var s,a=n.exec(i[e]);a||(a=r.exec(i[e])),a?""===(s={func:a[1],file:a[2],line:a[3],col:a[4]||0}).func&&(s.func="<anonymous>"):s={func:"",file:i[e],line:"",col:""},o.push(s)}return o},s.callstack=function(t){var e;try{throw new Error}catch(t){e=t}return t=t||0,s.parseStackTrace(e).splice(t+1)},s.stacktrace=function(t){var e=0===arguments.length?s.callstack().splice(1):s.parseStackTrace(t),n=[];return h.each(e,function(t){n.push(t.file+":"+t.line+":"+t.col+" ("+t.func+")")}),n.join("\n")},s.printStackTrace=function(t,e){if(t.stack){var n;if(void 0!==t.__stack)n=t.__stack;else{if(!h.isString(t.stack))return;n=s.parseStackTrace(t)}e=e||n.length,e=Math.min(e,n.length);for(var r=0;r<e;r++){var i=n[r];console.log(i.file+":"+i.line+":"+i.col,"("+i.func+")")}}},s.diff=function(n,r){var i;return h.isArray(n)&&h.isArray(r)?0===(i=h.difference(r,n)).length?null:i:h.isObject(n)&&h.isObject(r)?(i={},h.each(Object.keys(r),function(t){var e=s.diff(n[t],r[t]);e&&(i[t]=e)}),h.isEmpty(i)?null:i):n!==r?r:void 0},s.deepclone=function(t){if(void 0!==t)return null===t?null:JSON.parse(JSON.stringify(t))},s.clone=function(t){return null==t?t:h.isFunction(t.clone)?t.clone():s.deepclone(t)},s.freeze=function(t){var e;if(h.isObject(t)){if(Object.isFrozen(t))return t;var n=Object.keys(t);for(e=0;e<n.length;e++){var r=n[e];t[r]=s.freeze(t[r])}return Object.freeze(t)}if(h.isArray(t)){var i=t;for(e=0;e<i.length;e++)i[e]=s.freeze(i[e]);return Object.freeze(i)}return t},s.later=function(e,n){return function(){var t=arguments;window.setTimeout(function(){e.apply(n,t)},0)}},s.isEmpty=function(t){return!t.match(/\w/)},s.slug=function(t){t=(t=t.replace(/^\s+|\s+$/g,"")).toLowerCase();for(var e="àáäâèéëêìíïîòóöôùúüûñç·/_,:;",n=0,r=e.length;n<r;n++)t=t.replace(new RegExp(e.charAt(n),"g"),"aaaaeeeeiiiioooouuuunc------".charAt(n));return t=t.replace(/[^a-z0-9 -]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-")},s.getReadableFileSizeString=function(t){for(var e=-1;e++,1024<(t/=1024););return Math.max(t,.1).toFixed(1)+[" kB"," MB"," GB"," TB","PB","EB","ZB","YB"][e]},t.exports=s},{fs:2,underscore:131}],186:[function(t,K,Z){(function(X){!function(){function n(){}var t="object"==typeof self&&self.self===self&&self||"object"==typeof X&&X.global===X&&X||this||{},e=t._,r=Array.prototype,s=Object.prototype,p="undefined"!=typeof Symbol?Symbol.prototype:null,i=r.push,c=r.slice,h=s.toString,o=s.hasOwnProperty,a=Array.isArray,u=Object.keys,l=Object.create,d=function(t){return t instanceof d?t:this instanceof d?void(this._wrapped=t):new d(t)};void 0===Z||Z.nodeType?t._=d:(void 0!==K&&!K.nodeType&&K.exports&&(Z=K.exports=d),Z._=d),d.VERSION="1.9.1";function f(i,o,t){if(void 0===o)return i;switch(null==t?3:t){case 1:return function(t){return i.call(o,t)};case 3:return function(t,e,n){return i.call(o,t,e,n)};case 4:return function(t,e,n,r){return i.call(o,t,e,n,r)}}return function(){return i.apply(o,arguments)}}function g(t,e,n){return d.iteratee!==y?d.iteratee(t,e):null==t?d.identity:d.isFunction(t)?f(t,e,n):d.isObject(t)&&!d.isArray(t)?d.matcher(t):d.property(t)}var y;d.iteratee=y=function(t,e){return g(t,e,1/0)};function m(i,o){return o=null==o?i.length-1:+o,function(){for(var t=Math.max(arguments.length-o,0),e=Array(t),n=0;n<t;n++)e[n]=arguments[n+o];switch(o){case 0:return i.call(this,e);case 1:return i.call(this,arguments[0],e);case 2:return i.call(this,arguments[0],arguments[1],e)}var r=Array(o+1);for(n=0;n<o;n++)r[n]=arguments[n];return r[o]=e,i.apply(this,r)}}function v(t){if(!d.isObject(t))return{};if(l)return l(t);n.prototype=t;var e=new n;return n.prototype=null,e}function b(e){return function(t){return null==t?void 0:t[e]}}function w(t,e){return null!=t&&o.call(t,e)}function _(t,e){for(var n=e.length,r=0;r<n;r++){if(null==t)return;t=t[e[r]]}return n?t:void 0}function x(t){var e=P(t);return"number"==typeof e&&0<=e&&e<=C}var C=Math.pow(2,53)-1,P=b("length");d.each=d.forEach=function(t,e,n){var r,i;if(e=f(e,n),x(t))for(r=0,i=t.length;r<i;r++)e(t[r],r,t);else{var o=d.keys(t);for(r=0,i=o.length;r<i;r++)e(t[o[r]],o[r],t)}return t},d.map=d.collect=function(t,e,n){e=g(e,n);for(var r=!x(t)&&d.keys(t),i=(r||t).length,o=Array(i),s=0;s<i;s++){var a=r?r[s]:s;o[s]=e(t[a],a,t)}return o};function N(c){return function(t,e,n,r){var i=3<=arguments.length;return function(t,e,n,r){var i=!x(t)&&d.keys(t),o=(i||t).length,s=0<c?0:o-1;for(r||(n=t[i?i[s]:s],s+=c);0<=s&&s<o;s+=c){var a=i?i[s]:s;n=e(n,t[a],a,t)}return n}(t,f(e,r,4),n,i)}}d.reduce=d.foldl=d.inject=N(1),d.reduceRight=d.foldr=N(-1),d.find=d.detect=function(t,e,n){var r=(x(t)?d.findIndex:d.findKey)(t,e,n);if(void 0!==r&&-1!==r)return t[r]},d.filter=d.select=function(t,r,e){var i=[];return r=g(r,e),d.each(t,function(t,e,n){r(t,e,n)&&i.push(t)}),i},d.reject=function(t,e,n){return d.filter(t,d.negate(g(e)),n)},d.every=d.all=function(t,e,n){e=g(e,n);for(var r=!x(t)&&d.keys(t),i=(r||t).length,o=0;o<i;o++){var s=r?r[o]:o;if(!e(t[s],s,t))return!1}return!0},d.some=d.any=function(t,e,n){e=g(e,n);for(var r=!x(t)&&d.keys(t),i=(r||t).length,o=0;o<i;o++){var s=r?r[o]:o;if(e(t[s],s,t))return!0}return!1},d.contains=d.includes=d.include=function(t,e,n,r){return x(t)||(t=d.values(t)),"number"==typeof n&&!r||(n=0),0<=d.indexOf(t,e,n)},d.invoke=m(function(t,n,r){var i,o;return d.isFunction(n)?o=n:d.isArray(n)&&(i=n.slice(0,-1),n=n[n.length-1]),d.map(t,function(t){var e=o;if(!e){if(i&&i.length&&(t=_(t,i)),null==t)return;e=t[n]}return null==e?e:e.apply(t,r)})}),d.pluck=function(t,e){return d.map(t,d.property(e))},d.where=function(t,e){return d.filter(t,d.matcher(e))},d.findWhere=function(t,e){return d.find(t,d.matcher(e))},d.max=function(t,r,e){var n,i,o=-1/0,s=-1/0;if(null==r||"number"==typeof r&&"object"!=typeof t[0]&&null!=t)for(var a=0,c=(t=x(t)?t:d.values(t)).length;a<c;a++)null!=(n=t[a])&&o<n&&(o=n);else r=g(r,e),d.each(t,function(t,e,n){i=r(t,e,n),(s<i||i===-1/0&&o===-1/0)&&(o=t,s=i)});return o},d.min=function(t,r,e){var n,i,o=1/0,s=1/0;if(null==r||"number"==typeof r&&"object"!=typeof t[0]&&null!=t)for(var a=0,c=(t=x(t)?t:d.values(t)).length;a<c;a++)null!=(n=t[a])&&n<o&&(o=n);else r=g(r,e),d.each(t,function(t,e,n){((i=r(t,e,n))<s||i===1/0&&o===1/0)&&(o=t,s=i)});return o},d.shuffle=function(t){return d.sample(t,1/0)},d.sample=function(t,e,n){if(null==e||n)return x(t)||(t=d.values(t)),t[d.random(t.length-1)];var r=x(t)?d.clone(t):d.values(t),i=P(r);e=Math.max(Math.min(e,i),0);for(var o=i-1,s=0;s<e;s++){var a=d.random(s,o),c=r[s];r[s]=r[a],r[a]=c}return r.slice(0,e)},d.sortBy=function(t,r,e){var i=0;return r=g(r,e),d.pluck(d.map(t,function(t,e,n){return{value:t,index:i++,criteria:r(t,e,n)}}).sort(function(t,e){var n=t.criteria,r=e.criteria;if(n!==r){if(r<n||void 0===n)return 1;if(n<r||void 0===r)return-1}return t.index-e.index}),"value")};function k(s,e){return function(r,i,t){var o=e?[[],[]]:{};return i=g(i,t),d.each(r,function(t,e){var n=i(t,e,r);s(o,t,n)}),o}}d.groupBy=k(function(t,e,n){w(t,n)?t[n].push(e):t[n]=[e]}),d.indexBy=k(function(t,e,n){t[n]=e}),d.countBy=k(function(t,e,n){w(t,n)?t[n]++:t[n]=1});var A=/[^\ud800-\udfff]|[\ud800-\udbff][\udc00-\udfff]|[\ud800-\udfff]/g;d.toArray=function(t){return t?d.isArray(t)?c.call(t):d.isString(t)?t.match(A):x(t)?d.map(t,d.identity):d.values(t):[]},d.size=function(t){return null==t?0:x(t)?t.length:d.keys(t).length},d.partition=k(function(t,e,n){t[n?0:1].push(e)},!0),d.first=d.head=d.take=function(t,e,n){return null==t||t.length<1?null==e?void 0:[]:null==e||n?t[0]:d.initial(t,t.length-e)},d.initial=function(t,e,n){return c.call(t,0,Math.max(0,t.length-(null==e||n?1:e)))},d.last=function(t,e,n){return null==t||t.length<1?null==e?void 0:[]:null==e||n?t[t.length-1]:d.rest(t,Math.max(0,t.length-e))},d.rest=d.tail=d.drop=function(t,e,n){return c.call(t,null==e||n?1:e)},d.compact=function(t){return d.filter(t,Boolean)};var T=function(t,e,n,r){for(var i=(r=r||[]).length,o=0,s=P(t);o<s;o++){var a=t[o];if(x(a)&&(d.isArray(a)||d.isArguments(a)))if(e)for(var c=0,u=a.length;c<u;)r[i++]=a[c++];else T(a,e,n,r),i=r.length;else n||(r[i++]=a)}return r};d.flatten=function(t,e){return T(t,e,!1)},d.without=m(function(t,e){return d.difference(t,e)}),d.uniq=d.unique=function(t,e,n,r){d.isBoolean(e)||(r=n,n=e,e=!1),null!=n&&(n=g(n,r));for(var i=[],o=[],s=0,a=P(t);s<a;s++){var c=t[s],u=n?n(c,s,t):c;e&&!n?(s&&o===u||i.push(c),o=u):n?d.contains(o,u)||(o.push(u),i.push(c)):d.contains(i,c)||i.push(c)}return i},d.union=m(function(t){return d.uniq(T(t,!0,!0))}),d.intersection=function(t){for(var e=[],n=arguments.length,r=0,i=P(t);r<i;r++){var o=t[r];if(!d.contains(e,o)){var s;for(s=1;s<n&&d.contains(arguments[s],o);s++);s===n&&e.push(o)}}return e},d.difference=m(function(t,e){return e=T(e,!0,!0),d.filter(t,function(t){return!d.contains(e,t)})}),d.unzip=function(t){for(var e=t&&d.max(t,P).length||0,n=Array(e),r=0;r<e;r++)n[r]=d.pluck(t,r);return n},d.zip=m(d.unzip),d.object=function(t,e){for(var n={},r=0,i=P(t);r<i;r++)e?n[t[r]]=e[r]:n[t[r][0]]=t[r][1];return n};function S(o){return function(t,e,n){e=g(e,n);for(var r=P(t),i=0<o?0:r-1;0<=i&&i<r;i+=o)if(e(t[i],i,t))return i;return-1}}d.findIndex=S(1),d.findLastIndex=S(-1),d.sortedIndex=function(t,e,n,r){for(var i=(n=g(n,r,1))(e),o=0,s=P(t);o<s;){var a=Math.floor((o+s)/2);n(t[a])<i?o=a+1:s=a}return o};function j(o,s,a){return function(t,e,n){var r=0,i=P(t);if("number"==typeof n)0<o?r=0<=n?n:Math.max(n+i,r):i=0<=n?Math.min(n+1,i):n+i+1;else if(a&&n&&i)return t[n=a(t,e)]===e?n:-1;if(e!=e)return 0<=(n=s(c.call(t,r,i),d.isNaN))?n+r:-1;for(n=0<o?r:i-1;0<=n&&n<i;n+=o)if(t[n]===e)return n;return-1}}d.indexOf=j(1,d.findIndex,d.sortedIndex),d.lastIndexOf=j(-1,d.findLastIndex),d.range=function(t,e,n){null==e&&(e=t||0,t=0),n||(n=e<t?-1:1);for(var r=Math.max(Math.ceil((e-t)/n),0),i=Array(r),o=0;o<r;o++,t+=n)i[o]=t;return i},d.chunk=function(t,e){if(null==e||e<1)return[];for(var n=[],r=0,i=t.length;r<i;)n.push(c.call(t,r,r+=e));return n};function V(t,e,n,r,i){if(!(r instanceof e))return t.apply(n,i);var o=v(t.prototype),s=t.apply(o,i);return d.isObject(s)?s:o}d.bind=m(function(e,n,r){if(!d.isFunction(e))throw new TypeError("Bind must be called on a function");var i=m(function(t){return V(e,i,n,this,r.concat(t))});return i}),d.partial=m(function(i,o){var s=d.partial.placeholder,a=function(){for(var t=0,e=o.length,n=Array(e),r=0;r<e;r++)n[r]=o[r]===s?arguments[t++]:o[r];for(;t<arguments.length;)n.push(arguments[t++]);return V(i,a,this,this,n)};return a}),(d.partial.placeholder=d).bindAll=m(function(t,e){var n=(e=T(e,!1,!1)).length;if(n<1)throw new Error("bindAll must be passed function names");for(;n--;){var r=e[n];t[r]=d.bind(t[r],t)}}),d.memoize=function(r,i){var o=function(t){var e=o.cache,n=""+(i?i.apply(this,arguments):t);return w(e,n)||(e[n]=r.apply(this,arguments)),e[n]};return o.cache={},o},d.delay=m(function(t,e,n){return setTimeout(function(){return t.apply(null,n)},e)}),d.defer=d.partial(d.delay,d,1),d.throttle=function(n,r,i){var o,s,a,c,u=0;i||(i={});function l(){u=!1===i.leading?0:d.now(),o=null,c=n.apply(s,a),o||(s=a=null)}function t(){var t=d.now();u||!1!==i.leading||(u=t);var e=r-(t-u);return s=this,a=arguments,e<=0||r<e?(o&&(clearTimeout(o),o=null),u=t,c=n.apply(s,a),o||(s=a=null)):o||!1===i.trailing||(o=setTimeout(l,e)),c}return t.cancel=function(){clearTimeout(o),u=0,o=s=a=null},t},d.debounce=function(n,r,i){function o(t,e){s=null,e&&(a=n.apply(t,e))}var s,a,t=m(function(t){if(s&&clearTimeout(s),i){var e=!s;s=setTimeout(o,r),e&&(a=n.apply(this,t))}else s=d.delay(o,r,this,t);return a});return t.cancel=function(){clearTimeout(s),s=null},t},d.wrap=function(t,e){return d.partial(e,t)},d.negate=function(t){return function(){return!t.apply(this,arguments)}},d.compose=function(){var n=arguments,r=n.length-1;return function(){for(var t=r,e=n[r].apply(this,arguments);t--;)e=n[t].call(this,e);return e}},d.after=function(t,e){return function(){if(--t<1)return e.apply(this,arguments)}},d.before=function(t,e){var n;return function(){return 0<--t&&(n=e.apply(this,arguments)),t<=1&&(e=null),n}},d.once=d.partial(d.before,2),d.restArguments=m;function E(t,e){var n=$.length,r=t.constructor,i=d.isFunction(r)&&r.prototype||s,o="constructor";for(w(t,o)&&!d.contains(e,o)&&e.push(o);n--;)(o=$[n])in t&&t[o]!==i[o]&&!d.contains(e,o)&&e.push(o)}var I=!{toString:null}.propertyIsEnumerable("toString"),$=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"];d.keys=function(t){if(!d.isObject(t))return[];if(u)return u(t);var e=[];for(var n in t)w(t,n)&&e.push(n);return I&&E(t,e),e},d.allKeys=function(t){if(!d.isObject(t))return[];var e=[];for(var n in t)e.push(n);return I&&E(t,e),e},d.values=function(t){for(var e=d.keys(t),n=e.length,r=Array(n),i=0;i<n;i++)r[i]=t[e[i]];return r},d.mapObject=function(t,e,n){e=g(e,n);for(var r=d.keys(t),i=r.length,o={},s=0;s<i;s++){var a=r[s];o[a]=e(t[a],a,t)}return o},d.pairs=function(t){for(var e=d.keys(t),n=e.length,r=Array(n),i=0;i<n;i++)r[i]=[e[i],t[e[i]]];return r},d.invert=function(t){for(var e={},n=d.keys(t),r=0,i=n.length;r<i;r++)e[t[n[r]]]=n[r];return e},d.functions=d.methods=function(t){var e=[];for(var n in t)d.isFunction(t[n])&&e.push(n);return e.sort()};function M(c,u){return function(t){var e=arguments.length;if(u&&(t=Object(t)),e<2||null==t)return t;for(var n=1;n<e;n++)for(var r=arguments[n],i=c(r),o=i.length,s=0;s<o;s++){var a=i[s];u&&void 0!==t[a]||(t[a]=r[a])}return t}}d.extend=M(d.allKeys),d.extendOwn=d.assign=M(d.keys),d.findKey=function(t,e,n){e=g(e,n);for(var r,i=d.keys(t),o=0,s=i.length;o<s;o++)if(e(t[r=i[o]],r,t))return r};function O(t,e,n){return e in n}var q,L;d.pick=m(function(t,e){var n={},r=e[0];if(null==t)return n;d.isFunction(r)?(1<e.length&&(r=f(r,e[1])),e=d.allKeys(t)):(r=O,e=T(e,!1,!1),t=Object(t));for(var i=0,o=e.length;i<o;i++){var s=e[i],a=t[s];r(a,s,t)&&(n[s]=a)}return n}),d.omit=m(function(t,n){var e,r=n[0];return d.isFunction(r)?(r=d.negate(r),1<n.length&&(e=n[1])):(n=d.map(T(n,!1,!1),String),r=function(t,e){return!d.contains(n,e)}),d.pick(t,r,e)}),d.defaults=M(d.allKeys,!0),d.create=function(t,e){var n=v(t);return e&&d.extendOwn(n,e),n},d.clone=function(t){return d.isObject(t)?d.isArray(t)?t.slice():d.extend({},t):t},d.tap=function(t,e){return e(t),t},d.isMatch=function(t,e){var n=d.keys(e),r=n.length;if(null==t)return!r;for(var i=Object(t),o=0;o<r;o++){var s=n[o];if(e[s]!==i[s]||!(s in i))return!1}return!0},q=function(t,e,n,r){if(t===e)return 0!==t||1/t==1/e;if(null==t||null==e)return!1;if(t!=t)return e!=e;var i=typeof t;return("function"==i||"object"==i||"object"==typeof e)&&L(t,e,n,r)},L=function(t,e,n,r){t instanceof d&&(t=t._wrapped),e instanceof d&&(e=e._wrapped);var i=h.call(t);if(i!==h.call(e))return!1;switch(i){case"[object RegExp]":case"[object String]":return""+t==""+e;case"[object Number]":return+t!=+t?+e!=+e:0==+t?1/+t==1/e:+t==+e;case"[object Date]":case"[object Boolean]":return+t==+e;case"[object Symbol]":return p.valueOf.call(t)===p.valueOf.call(e)}var o="[object Array]"===i;if(!o){if("object"!=typeof t||"object"!=typeof e)return!1;var s=t.constructor,a=e.constructor;if(s!==a&&!(d.isFunction(s)&&s instanceof s&&d.isFunction(a)&&a instanceof a)&&"constructor"in t&&"constructor"in e)return!1}r=r||[];for(var c=(n=n||[]).length;c--;)if(n[c]===t)return r[c]===e;if(n.push(t),r.push(e),o){if((c=t.length)!==e.length)return!1;for(;c--;)if(!q(t[c],e[c],n,r))return!1}else{var u,l=d.keys(t);if(c=l.length,d.keys(e).length!==c)return!1;for(;c--;)if(u=l[c],!w(e,u)||!q(t[u],e[u],n,r))return!1}return n.pop(),r.pop(),!0},d.isEqual=function(t,e){return q(t,e)},d.isEmpty=function(t){return null==t||(x(t)&&(d.isArray(t)||d.isString(t)||d.isArguments(t))?0===t.length:0===d.keys(t).length)},d.isElement=function(t){return!(!t||1!==t.nodeType)},d.isArray=a||function(t){return"[object Array]"===h.call(t)},d.isObject=function(t){var e=typeof t;return"function"==e||"object"==e&&!!t},d.each(["Arguments","Function","String","Number","Date","RegExp","Error","Symbol","Map","WeakMap","Set","WeakSet"],function(e){d["is"+e]=function(t){return h.call(t)==="[object "+e+"]"}}),d.isArguments(arguments)||(d.isArguments=function(t){return w(t,"callee")});var R=t.document&&t.document.childNodes;"function"!=typeof/./&&"object"!=typeof Int8Array&&"function"!=typeof R&&(d.isFunction=function(t){return"function"==typeof t||!1}),d.isFinite=function(t){return!d.isSymbol(t)&&isFinite(t)&&!isNaN(parseFloat(t))},d.isNaN=function(t){return d.isNumber(t)&&isNaN(t)},d.isBoolean=function(t){return!0===t||!1===t||"[object Boolean]"===h.call(t)},d.isNull=function(t){return null===t},d.isUndefined=function(t){return void 0===t},d.has=function(t,e){if(!d.isArray(e))return w(t,e);for(var n=e.length,r=0;r<n;r++){var i=e[r];if(null==t||!o.call(t,i))return!1;t=t[i]}return!!n},d.noConflict=function(){return t._=e,this},d.identity=function(t){return t},d.constant=function(t){return function(){return t}},d.noop=function(){},d.property=function(e){return d.isArray(e)?function(t){return _(t,e)}:b(e)},d.propertyOf=function(e){return null==e?function(){}:function(t){return d.isArray(t)?_(e,t):e[t]}},d.matcher=d.matches=function(e){return e=d.extendOwn({},e),function(t){return d.isMatch(t,e)}},d.times=function(t,e,n){var r=Array(Math.max(0,t));e=f(e,n,1);for(var i=0;i<t;i++)r[i]=e(i);return r},d.random=function(t,e){return null==e&&(e=t,t=0),t+Math.floor(Math.random()*(e-t+1))},d.now=Date.now||function(){return(new Date).getTime()};function F(e){function n(t){return e[t]}var t="(?:"+d.keys(e).join("|")+")",r=RegExp(t),i=RegExp(t,"g");return function(t){return t=null==t?"":""+t,r.test(t)?t.replace(i,n):t}}var D={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},H=d.invert(D);d.escape=F(D),d.unescape=F(H),d.result=function(t,e,n){d.isArray(e)||(e=[e]);var r=e.length;if(!r)return d.isFunction(n)?n.call(t):n;for(var i=0;i<r;i++){var o=null==t?void 0:t[e[i]];void 0===o&&(o=n,i=r),t=d.isFunction(o)?o.call(t):o}return t};var U=0;d.uniqueId=function(t){var e=++U+"";return t?t+e:e},d.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};function B(t){return"\\"+G[t]}var z=/(.)^/,G={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},J=/\\|'|\r|\n|\u2028|\u2029/g;d.template=function(o,t,e){!t&&e&&(t=e),t=d.defaults({},t,d.templateSettings);var n,r=RegExp([(t.escape||z).source,(t.interpolate||z).source,(t.evaluate||z).source].join("|")+"|$","g"),s=0,a="__p+='";o.replace(r,function(t,e,n,r,i){return a+=o.slice(s,i).replace(J,B),s=i+t.length,e?a+="'+\n((__t=("+e+"))==null?'':_.escape(__t))+\n'":n?a+="'+\n((__t=("+n+"))==null?'':__t)+\n'":r&&(a+="';\n"+r+"\n__p+='"),t}),a+="';\n",t.variable||(a="with(obj||{}){\n"+a+"}\n"),a="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+a+"return __p;\n";try{n=new Function(t.variable||"obj","_",a)}catch(t){throw t.source=a,t}function i(t){return n.call(this,t,d)}var c=t.variable||"obj";return i.source="function("+c+"){\n"+a+"}",i},d.chain=function(t){var e=d(t);return e._chain=!0,e};function W(t,e){return t._chain?d(e).chain():e}d.mixin=function(n){return d.each(d.functions(n),function(t){var e=d[t]=n[t];d.prototype[t]=function(){var t=[this._wrapped];return i.apply(t,arguments),W(this,e.apply(d,t))}}),d},d.mixin(d),d.each(["pop","push","reverse","shift","sort","splice","unshift"],function(e){var n=r[e];d.prototype[e]=function(){var t=this._wrapped;return n.apply(t,arguments),"shift"!==e&&"splice"!==e||0!==t.length||delete t[0],W(this,t)}}),d.each(["concat","join","slice"],function(t){var e=r[t];d.prototype[t]=function(){return W(this,e.apply(this._wrapped,arguments))}}),d.prototype.value=function(){return this._wrapped},d.prototype.valueOf=d.prototype.toJSON=d.prototype.value,d.prototype.toString=function(){return String(this._wrapped)},"function"==typeof define&&define.amd&&define("underscore",[],function(){return d})}()}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],187:[function(t,e,n){"use strict";function r(t){i.call(this,t)}var i=t("lens/converter"),o=t("lens/article"),s=t("./nodes");r.Prototype=function(){this.test=function(t){return null!=t.querySelector("article")},this.createDocument=function(){return new o({nodeTypes:s})}},this.caption=function(n,r){var t=n.doc,e={id:n.nextId("caption"),source_id:r.getAttribute("id"),type:"caption",title:"",children:[]},i=r.querySelector("title");if(i){var o=this.paragraph(n,i);o&&(e.title=o.id)}var s=[],a=r.querySelectorAll("p");return _.each(a,function(t){if(t.parentNode===r){var e=this.paragraph(n,t);e&&s.push(e.id)}},this),e.children=s,t.create(e),e},r.Prototype.prototype=i.prototype,(r.prototype=new r.Prototype).constructor=r,e.exports=r},{"./nodes":193,"lens/article":5,"lens/converter":129}],188:[function(t,e,n){"use strict";function r(t,e){o.call(this,t,e)}var i=t("../../../node_modules/lens/substance/document/index"),o=i.Composite;r.type={id:"abstract",parent:"content",properties:{title:"text",children:["array","paragraph"]}},r.description={name:"Abstract",remarks:["Abstract"],properties:{children:{abstract:"abstract element"}}},r.example={id:"abstract_1",type:"abstract",children:{abstract:"abstract_id"}},(r.Prototype=function(){this.getChildrenIds=function(){return this.properties.children}}).prototype=o.prototype,(r.prototype=new r.Prototype).constructor=r,i.Node.defineProperties(r),e.exports=r},{"../../../node_modules/lens/substance/document/index":174}],189:[function(t,e,n){"use strict";function r(t,e){o.call(this,t,e)}var i=t("../../../node_modules/lens/article/nodes/node/index").View,o=t("../../../node_modules/lens/article/nodes/composite/index").View;t("../../../node_modules/lens/substance/application/index").$$;(r.Prototype=function(){this.render=function(){i.prototype.render.call(this),this.content=document.createElement("div");var t=this.node.title;if(null!=t||void 0!==t)if(void 0===t.textContent&0==t.length){(t=document.createElement("div")).className="content";var e=document.createElement("div");e.className="content-node text",t.appendChild(e),this.content.appendChild(t)}else if(0<t.length){var n=this.createChildView(t).render().el;n.className+=" title",this.content.appendChild(n)}return 0<this.node.children.length&&(this.el.appendChild(this.content),this.renderChildren()),this}}).prototype=o.prototype,r.prototype=new r.Prototype,e.exports=r},{"../../../node_modules/lens/article/nodes/composite/index":33,"../../../node_modules/lens/article/nodes/node/index":91,"../../../node_modules/lens/substance/application/index":161}],190:[function(t,e,n){e.exports={Model:t("./abstract"),View:t("./abstract_view")}},{"./abstract":188,"./abstract_view":189}],191:[function(t,e,n){function r(t,e){i.call(this,t,e)}var i=t("lens/article/nodes").cover.View,o=t("lens/substance/application").$$;(r.Prototype=function(){this.render=function(){i.prototype.render.call(this);encodeURIComponent(window.location.href);var t=o(".intro.container",{children:[o(".intro-text",{html:'<i class="fa fa-exclamation"></i> <b>Internet Explorer is only partially supported.</b>'})]}),e=o(".intro.container",{children:[o(".intro-text",{html:'<i class="fa fa-exclamation"></i> <b> Minimum screen width of 1024px recommended for best user experience</b>'})]}),n=navigator.userAgent;return(-1<n.indexOf("MSIE ")||-1<n.indexOf("Trident/"))&&this.content.insertBefore(t,this.content.firstChild),window.screen.width<1024&&this.content.insertBefore(e,this.content.firstChild),this}}).prototype=i.prototype,(r.prototype=new r.Prototype).constructor=r,e.exports=r},{"lens/article/nodes":76,"lens/substance/application":161}],192:[function(t,e,n){"use strict";var r=t("lens/article/nodes").cover.Model;e.exports={Model:r,View:t("./cover_view")}},{"./cover_view":191,"lens/article/nodes":76}],193:[function(t,e,n){e.exports={abstract:t("./abstract"),cover:t("./cover"),sec_meta:t("./sec_meta"),speech:t("./speech"),strike:t("./strike"),table:t("./table")}},{"./abstract":190,"./cover":192,"./sec_meta":194,"./speech":197,"./strike":200,"./table":202}],194:[function(t,e,n){"use strict";e.exports={Model:t("./sec_meta"),View:t("./sec_meta_view")}},{"./sec_meta":195,"./sec_meta_view":196}],195:[function(t,e,n){"use strict";function r(t,e){s.call(this,t,e)}var i=t("underscore"),o=t("../../../node_modules/lens/substance/document/index"),s=o.Composite;r.type={id:"sec_meta",parent:"content",properties:{children:{abstract:"abstract"},authors:["array","paragraph"],abstract:["array","abstract"]}},r.description={name:"Section",remarks:["Sectin Element for metadata"],properties:{children:{abstract:"abstract element"}}},r.example={id:"sec_meta_1",type:"sec_meta",children:{abstract:"abstract_id"}},(r.Prototype=function(){this.getChildrenIds=function(){return this.properties.children},this.getAuthors=function(){return i.map(this.properties.authors,function(t){return this.document.get(t)},this)},this.getAbstract=function(){return i.map(this.properties.abstract,function(t){return this.document.get(t)},this)}}).prototype=s.prototype,(r.prototype=new r.Prototype).constructor=r,o.Node.defineProperties(r),e.exports=r},{"../../../node_modules/lens/substance/document/index":174,underscore:186}],196:[function(t,e,n){"use strict";function r(t,e){o.call(this,t,e)}var i=t("underscore"),o=(t("../../../node_modules/lens/article/nodes/node/index").View,t("../../../node_modules/lens/article/nodes/composite/index").View),s=t("../../../node_modules/lens/substance/application/index").$$;(r.Prototype=function(){this.render=function(){var t=this.node;this.content=document.createElement("div");var e=s(".authors",{children:i.map(t.getAuthors(),function(t){var e=this.viewFactory.createView(t).render().el;return this.content.appendChild(e),e},this)});e.appendChild(s(".content-node.text.plain",{children:[s(".content",{text:this.node.document.on_behalf_of})]})),this.content.appendChild(e);var n=s(".abstract",{children:i.map(t.getAbstract(),function(t){var e=this.viewFactory.createView(t).render().el;return this.content.appendChild(e),e},this)});return 0<t.properties.abstract.length&&this.content.appendChild(n),this.el.appendChild(this.content),this}}).prototype=o.prototype,r.prototype=new r.Prototype,e.exports=r},{"../../../node_modules/lens/article/nodes/composite/index":33,"../../../node_modules/lens/article/nodes/node/index":91,"../../../node_modules/lens/substance/application/index":161,underscore:186}],197:[function(t,e,n){"use strict";e.exports={Model:t("./speech"),View:t("./speech_view")}},{"./speech":198,"./speech_view":199}],198:[function(t,e,n){"use strict";function r(t,e){o.call(this,t,e)}var i=t("../../../node_modules/lens/substance/document/index"),o=i.Composite;r.type={id:"speech",parent:"content",properties:{source_id:"string",label:"string",children:["array","paragraph"],speaker:["content"]}},r.description={name:"Speech",remarks:["A speech type."],properties:{label:"string",children:"0..n Paragraph nodes"}},r.example={id:"speech_1",type:"speech",label:"Speech 1",children:["paragraph_1","paragraph_2"]},(r.Prototype=function(){this.getChildrenIds=function(){return this.properties.children}}).prototype=o.prototype,(r.prototype=new r.Prototype).constructor=r,i.Node.defineProperties(r),e.exports=r},{"../../../node_modules/lens/substance/document/index":174}],199:[function(t,e,n){"use strict";function r(t,e){i.call(this,t,e)}var a=t("../../../node_modules/lens/article/nodes/node/index").View,i=t("../../../node_modules/lens/article/nodes/composite/index").View;t("../../../node_modules/lens/substance/application/index").$$;(r.Prototype=function(){this.render=function(){var t,e;a.prototype.render.call(this),(t=document.createElement("table")).setAttribute("class","speeches"),e=document.createElement("tr");var n=this.node.speaker;for(i=0;i<n.length;i++)(o=document.createElement("td")).setAttribute("class","speaker"),o.innerText=n[i].textContent;e.appendChild(o);for(var r=this.node.getChildrenIds(),i=0;i<r.length;i++){var o;(o=document.createElement("td")).setAttribute("class","speech");var s=this.createChildView(r[i]).render().el;o.appendChild(s),e.appendChild(o)}return t.appendChild(e),this.content.appendChild(t),this.el.appendChild(this.content),this}}).prototype=i.prototype,r.prototype=new r.Prototype,e.exports=r},{"../../../node_modules/lens/article/nodes/composite/index":33,"../../../node_modules/lens/article/nodes/node/index":91,"../../../node_modules/lens/substance/application/index":161}],200:[function(t,e,n){e.exports={Model:t("./strike.js"),View:t("../../../node_modules/lens/article/nodes/annotation/annotation_view.js")}},{"../../../node_modules/lens/article/nodes/annotation/annotation_view.js":9,"./strike.js":201}],201:[function(t,e,n){function r(t,e){i.call(this,t,e)}var i=t("../../../node_modules/lens/article/nodes/annotation/annotation");r.type={id:"strike",parent:"annotation",properties:{}},(r.Prototype=function(){}).prototype=i.prototype,((r.prototype=new r.Prototype).constructor=r).fragmentation=i.DONT_CARE,e.exports=r},{"../../../node_modules/lens/article/nodes/annotation/annotation":8}],202:[function(t,e,n){"use strict";e.exports={Model:t("./table"),View:t("./table_view")}},{"./table":203,"./table_view":204}],203:[function(t,e,n){t("underscore");function r(t,e){o.call(this,t,e)}var i=t("../../../node_modules/lens/substance/document/index"),o=i.Composite;r.type={id:"table",parent:"content",properties:{source_id:"string",label:"string",children:"object",footers:["array","string"],caption:"caption",table_attributes:"object"}},r.config={zoomable:!0},r.description={name:"HTMLTable",remarks:["A table figure which is expressed in HTML notation"],properties:{source_id:"string",label:"Label shown in the resource header.",title:"Full table title",children:"object",footers:"HTMLTable footers expressed as an array strings",caption:"References a caption node, that has all the content",table_attributes:"Named Node map of attributes"}},r.example={id:"table_1",type:"table",label:"HTMLTable 1.",title:"Lorem ipsum table",children:"object",footers:[],caption:"caption_1"},(r.Prototype=function(){this.getChildrenIds=function(){return this.properties.children},this.getCaption=function(){if(this.properties.caption)return this.document.get(this.properties.caption)},this.getHeader=function(){return this.properties.label}}).prototype=o.prototype,(r.prototype=new r.Prototype).constructor=r,i.Node.defineProperties(r),e.exports=r},{"../../../node_modules/lens/substance/document/index":174,underscore:186}],204:[function(t,e,n){"use strict";function r(t,e){i.call(this,t,e)}var g=t("../../../node_modules/lens/article/nodes/node/index").View,i=t("../../../node_modules/lens/article/nodes/composite/index").View;t("../../../node_modules/lens/substance/application/index").$$;(r.Prototype=function(){this.render=function(){var t,e,n,r;g.prototype.render.call(this),e=document.createElement("table");var i,o,s,a=this.node.properties.table_attributes;if(0<a.length)for(var c=0;c<a.length;c++)e.setAttribute(a[c].nodeName,a[c].nodeValue);null===a.getNamedItem("specific-use")?e.setAttribute("class","layout-tabelle"):e.setAttribute("class",a.getNamedItem("specific-use").nodeValue);var u=this.node.getChildrenIds();if(void 0!==u)for(var l in u)for(o in n=u[l],i=document.createElement("tr"),n){r=document.createElement("td");var p=n[o];for(s in p){var h=p[s].nodes,d=p[s].attributes;if(void 0!==h){for(c=0;c<h.length;c++)t=this.createChildView(h[c].id).render().el,r.appendChild(t);for(var f=0;f<d.length;f++)r.setAttribute(d[f].nodeName,d[f].nodeValue)}}i.appendChild(r),e.appendChild(i)}return this.content.appendChild(e),this.el.appendChild(this.content),this}}).prototype=i.prototype,r.prototype=new r.Prototype,e.exports=r},{"../../../node_modules/lens/article/nodes/composite/index":33,"../../../node_modules/lens/article/nodes/node/index":91,"../../../node_modules/lens/substance/application/index":161}],205:[function(t,e,n){"use strict";function r(t){i.call(this,t)}var i=t("lens/reader"),o=i.getDefaultPanels(),s=(t("lens/converter"),t("./custom_converter"));t("lens/converter/elife_converter");(r.Prototype=function(){this.getConverters=function(t){return[new s(t)]},this.getPanels=function(){return o.slice(0)}}).prototype=i.prototype,(r.prototype=new r.Prototype).constructor=r,e.exports=r},{"./custom_converter":187,"lens/converter":129,"lens/converter/elife_converter":128,"lens/reader":134}]},{},[1]);