!function t(e,n,r){function o(s,a){if(!n[s]){if(!e[s]){var c="function"==typeof require&&require;if(!a&&c)return c(s,!0);if(i)return i(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var l=n[s]={exports:{}};e[s][0].call(l.exports,function(t){var n=e[s][1][t];return o(n?n:t)},l,l.exports,t,e,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s=3){var n=new Date(e[0],e[1]-1,e[2]);return n.toUTCString().slice(0,16)}if(2===e.length){var o=e[1].replace(/^0/,""),i=e[0];return r[o]+" "+i}return i},e.exports=o},{}],6:[function(t,e,n){"use strict";var r=t("./article");e.exports=r},{"./article":4}],7:[function(t,e,n){"use strict";var r=t("../../../substance/document"),o=function(t,e){r.Node.call(this,t,e)};o.type={id:"affiliation",parent:"content",properties:{source_id:"string",city:"string",country:"string",department:"string",institution:"string",label:"string"}},o.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"}},o.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"},o.Prototype=function(){},o.Prototype.prototype=r.Node.prototype,o.prototype=new o.Prototype,o.prototype.constructor=o,r.Node.defineProperties(o),e.exports=o},{"../../../substance/document":167}],8:[function(t,e,n){"use strict";e.exports={Model:t("./affiliation")}},{"./affiliation":7}],9:[function(t,e,n){var r=t("../../../substance/document"),o=function(t,e){r.Node.call(this,t,e)};o.type={id:"annotation",properties:{path:["array","string"],range:["array","number"]}},o.Prototype=function(){this.getLevel=function(){return this.constructor.fragmentation}},o.Prototype.prototype=r.Node.prototype,o.prototype=new o.Prototype,o.prototype.constructor=o,o.NEVER=1,o.OK=2,o.DONT_CARE=3,o.fragmentation=o.DONT_CARE,r.Node.defineProperties(o),e.exports=o},{"../../../substance/document":167}],10:[function(t,e,n){"use strict";var r=function(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},{}],11:[function(t,e,n){e.exports={Model:t("./annotation.js"),View:t("./annotation_view.js")}},{"./annotation.js":9,"./annotation_view.js":10}],12:[function(t,e,n){var r=t("../../../substance/document"),o=t("../annotation/annotation"),i=function(t,e){o.call(this,t,e)};i.type={id:"emphasis",parent:"annotation",properties:{style:"string"}},i.Prototype=function(){},i.Prototype.prototype=o.prototype,i.prototype=new i.Prototype,i.prototype.constructor=i,i.fragmentation=o.DONT_CARE,r.Node.defineProperties(i),e.exports=i},{"../../../substance/document":167,"../annotation/annotation":9}],13:[function(t,e,n){var r=t("../annotation").View,o=function(t){r.call(this,t)};o.Prototype=function(){this.setClasses=function(){r.prototype.setClasses.call(this),this.$el.addClass(this.node.style)}},o.Prototype.prototype=r.prototype,o.prototype=new o.Prototype,e.exports=o},{"../annotation":11}],14:[function(t,e,n){e.exports={Model:t("./author_callout.js"),View:t("./author_callout_view.js")}},{"./author_callout.js":12,"./author_callout_view.js":13}],15:[function(t,e,n){"use strict";var r=t("../../../substance/document"),o=r.Composite,i=function(t,e){o.call(this,t,e)};i.type={id:"box",parent:"content",properties:{source_id:"string",label:"string",children:["array","paragraph"]}},i.description={name:"Box",remarks:["A box type."],properties:{label:"string",children:"0..n Paragraph nodes"}},i.example={id:"box_1",type:"box",label:"Box 1",children:["paragraph_1","paragraph_2"]},i.Prototype=function(){this.getChildrenIds=function(){return this.properties.children}},i.Prototype.prototype=o.prototype,i.prototype=new i.Prototype,i.prototype.constructor=i,r.Node.defineProperties(i),e.exports=i},{"../../../substance/document":167}],16:[function(t,e,n){"use strict";var r=t("../node").View,o=t("../composite").View,i=t("../../../substance/application").$$,s=function(t,e){o.call(this,t,e)};s.Prototype=function(){this.render=function(){if(r.prototype.render.call(this),this.node.label){var t=i(".label",{text:this.node.label});this.content.appendChild(t)}return this.renderChildren(),this.el.appendChild(this.content),this}},s.Prototype.prototype=o.prototype,s.prototype=new s.Prototype,e.exports=s},{"../../../substance/application":154,"../composite":32,"../node":87}],17:[function(t,e,n){"use strict";e.exports={Model:t("./box"),View:t("./box_view")}},{"./box":15,"./box_view":16}],18:[function(t,e,n){"use strict";var r=t("../../../substance/document"),o=function(t,e){r.Composite.call(this,t,e)};o.type={id:"caption",parent:"content",properties:{source_id:"string",title:"paragraph",children:["array","paragraph"]}},o.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"}},o.example={id:"caption_1",children:["paragraph_1","paragraph_2"]},o.Prototype=function(){this.getChildrenIds=function(){return this.properties.children||[]},this.hasTitle=function(){return!!this.properties.title},this.getTitle=function(){return this.properties.title?this.document.get(this.properties.title):void 0}},o.Prototype.prototype=r.Composite.prototype,o.prototype=new o.Prototype,o.prototype.constructor=o,r.Node.defineProperties(o),e.exports=o},{"../../../substance/document":167}],19:[function(t,e,n){"use strict";var r=t("../composite").View,o=t("../../../substance/application").$$,i=function(t,e){r.call(this,t,e)};i.Prototype=function(){this.render=function(){this.content=o("div.content");var t=this.node.getTitle();if(t){var e=this.createChildView(this.node.title),n=e.render().el;n.classList.add("caption-title"),this.content.appendChild(n)}return this.renderChildren(),this.el.appendChild(this.content),this}},i.Prototype.prototype=r.prototype,i.prototype=new i.Prototype,e.exports=i},{"../../../substance/application":154,"../composite":32}],20:[function(t,e,n){"use strict";e.exports={Model:t("./caption"),View:t("./caption_view")}},{"./caption":18,"./caption_view":19}],21:[function(t,e,n){var r=t("underscore"),o=t("../../../substance/document"),i=function(t,e){o.Node.call(this,t,e)};i.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"]}},i.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"}},i.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"}]},i.Prototype=function(){this.urls=function(){return this.properties.citation_urls.length>0?this.properties.citation_urls:[this.properties.doi]},this.getHeader=function(){return r.compact([this.properties.label,this.properties.citation_type||"Reference"]).join(" - ")}},i.Prototype.prototype=o.Node.prototype,i.prototype=new i.Prototype,i.prototype.constructor=i,o.Node.defineProperties(i),e.exports=i},{"../../../substance/document":167,underscore:124}],22:[function(t,e,n){"use strict";var r=t("underscore"),o=t("../../../substance/application").$$,i=t("../node").View,s=t("../../resource_view"),a=function(t,e,n){i.apply(this,arguments),s.call(this,n)};a.Prototype=function(){r.extend(this,s.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(o(".authors",{html:e.authors.join(", ")}));var i="",s="",a="",c="";e.source&&""===e.volume?s=e.source:e.source&&e.volume&&(s=[e.source,e.volume].join(", ")),e.fpage&&e.lpage&&(a=[e.fpage,e.lpage].join("-"));var u=[];if(e.publisher_name&&e.publisher_location&&(u.push(e.publisher_name),u.push(e.publisher_location)),e.year&&u.push(e.year),c=u.join(", "),i=s,s&&(a||c)&&(i+=": "),a&&c?i+=[a,c].join(", "):(i+=a,i+=c),t.appendChild(o(".source",{html:i})),e.comment){var l=this.createTextView({path:[e.id,"comment"],classes:"comment"});t.appendChild(l.render().el)}if(e.doi&&t.appendChild(o(".doi",{children:[o("b",{text:"DOI: "}),o("a",{href:e.doi,target:"_new",text:e.doi})]})),e.citation_urls.length>0){var p=o(".citation-urls");r.each(e.citation_urls,function(t){p.appendChild(o("a.url",{href:t.url,text:t.name,target:"_blank"}))}),t.appendChild(p)}this.content.appendChild(t)}},a.Prototype.prototype=i.prototype,a.prototype=new a.Prototype,a.prototype.constructor=a,e.exports=a},{"../../../substance/application":154,"../../resource_view":119,"../node":87,underscore:124}],23:[function(t,e,n){"use strict";e.exports={Model:t("./citation"),View:t("./citation_view")}},{"./citation":21,"./citation_view":22}],24:[function(t,e,n){var r=t("../../../substance/document"),o=t("../annotation/annotation"),i=t("../resource_reference/resource_reference"),s=function(t,e){i.call(this,t,e)};s.type={id:"citation_reference",parent:"resource_reference",properties:{target:"citation"}},s.Prototype=function(){},s.Prototype.prototype=i.prototype,s.prototype=new s.Prototype,s.prototype.constructor=s,s.fragmentation=o.NEVER,r.Node.defineProperties(s),e.exports=s},{"../../../substance/document":167,"../annotation/annotation":9,"../resource_reference/resource_reference":97}],25:[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":98,"./citation_reference.js":24}],26:[function(t,e,n){var r=t("../annotation/annotation"),o=function(t,e){r.call(this,t,e)};o.type={id:"underline",parent:"annotation",properties:{}},o.Prototype=function(){},o.Prototype.prototype=r.prototype,o.prototype=new o.Prototype,o.prototype.constructor=o,o.fragmentation=r.DONT_CARE,e.exports=o},{"../annotation/annotation":9}],27:[function(t,e,n){e.exports={Model:t("./code.js"),View:t("../annotation/annotation_view.js")}},{"../annotation/annotation_view.js":10,"./code.js":26}],28:[function(t,e,n){"use strict";var r=t("../text").Model,o=function(t,e){r.call(this,t,e)};o.type={id:"codeblock",parent:"content",properties:{source_id:"string",content:"string"}},o.config={zoomable:!0},o.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"}},o.example={type:"codeblock",id:"codeblock_1",content:'var text = "Sun";\nvar op1 = null;\ntext = op2.apply(op1.apply(text));\nconsole.log(text);'},o.Prototype=function(){},o.Prototype.prototype=r.prototype,o.prototype=new o.Prototype,o.prototype.constructor=o,e.exports=o},{"../text":108}],29:[function(t,e,n){"use strict";var r=t("../text/text_view"),o=function(t){r.call(this,t)};o.Prototype=function(){},o.Prototype.prototype=r.prototype,o.prototype=new o.Prototype,e.exports=o},{"../text/text_view":111}],30:[function(t,e,n){"use strict";e.exports={Model:t("./codeblock"),View:t("./codeblock_view")}},{"./codeblock":28,"./codeblock_view":29}],31:[function(t,e,n){"use strict";var r=t("../node").View,o=function(t,e){r.call(this,t,e),this.childrenViews=[]};o.Prototype=function(){this.render=function(){return r.prototype.render.call(this),this.renderChildren(),this},this.renderChildren=function(){for(var t=this.node.getChildrenIds(),e=0;e0&&(this.content.appendChild(i(".label",{text:"Contributed equally with"})),this.content.appendChild(i(".equal-contribution",{text:this.node.equal_contrib}))),this.node.emails.length>0&&(this.content.appendChild(i(".label",{text:"For correspondence"})),this.content.appendChild(i(".emails",{children:r.map(this.node.emails,function(t){return i("a",{href:"mailto:"+t,text:t})})}))),this.node.fundings.length>0&&(this.content.appendChild(i(".label",{text:"Funding"})),this.content.appendChild(i(".fundings",{children:r.map(this.node.fundings,function(t){return i(".funding",{text:t})})}))),this.node.competing_interests.length>0&&(this.content.appendChild(i(".label",{text:"Competing Interests"})),this.content.appendChild(i(".competing-interests",{children:r.map(this.node.competing_interests,function(t){return i(".conflict",{text:t})})}))),this.node.orcid&&(this.content.appendChild(i(".label",{text:"ORCID"})),this.content.appendChild(i("a.orcid",{href:this.node.orcid,text:this.node.orcid}))),this.node.members.length>0&&(this.content.appendChild(i(".label",{text:"Group Members"})),this.content.appendChild(i(".members",{children:r.map(this.node.members,function(t){return i(".member",{text:t})})}))),this.node.image||this.node.bio&&this.node.bio.length>0){var t=i(".bio"),e=[i("img",{src:this.node.image}),t];r.each(this.node.bio,function(e){t.appendChild(this.createView(e).render().el)},this),this.content.appendChild(i(".contributor-bio.container",{children:e}))}this.node.deceased&&this.content.appendChild(i(".label",{text:"* Deceased"}))}},a.Prototype.prototype=o.prototype,a.prototype=new a.Prototype,e.exports=a},{"../../../substance/application":154,"../../resource_view":119,"../node":87,underscore:124}],35:[function(t,e,n){"use strict";e.exports={Model:t("./contributor"),View:t("./contributor_view")}},{"./contributor":33,"./contributor_view":34}],36:[function(t,e,n){var r=t("../../../substance/document"),o=t("../annotation/annotation"),i=t("../resource_reference/resource_reference"),s=function(t,e){i.call(this,t,e)};s.type={id:"contributor_reference",parent:"resource_reference",properties:{target:"contributor"}},s.Prototype=function(){},s.Prototype.prototype=i.prototype,s.prototype=new s.Prototype,s.prototype.constructor=s,s.fragmentation=o.NEVER,r.Node.defineProperties(s),e.exports=s},{"../../../substance/document":167,"../annotation/annotation":9,"../resource_reference/resource_reference":97}],37:[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":98,"./contributor_reference.js":36}],38:[function(t,e,n){var r=t("underscore"),o=t("../../../substance/document"),i=function(t,e){o.Node.call(this,t,e)};i.type={id:"cover",parent:"content",properties:{source_id:"string",authors:["array","paragraph"],breadcrumbs:"object"}},i.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"}},i.example={id:"cover",type:"cover"},i.Prototype=function(){this.getAuthors=function(){return r.map(this.properties.authors,function(t){return this.document.get(t)},this)},this.getTitle=function(){return this.document.title}},i.Prototype.prototype=o.Node.prototype,i.prototype=new i.Prototype,i.prototype.constructor=i,o.Node.defineProperties(i),e.exports=i},{"../../../substance/document":167,underscore:124}],39:[function(t,e,n){"use strict";var r=t("underscore"),o=t("../node").View,i=t("../../../substance/application").$$,s=t("../../article_util"),a=function(t,e){o.call(this,t,e)};a.Prototype=function(){this.render=function(){o.prototype.render.call(this);var t=this.node,e=this.node.document.get("publication_info");if(t.breadcrumbs&&t.breadcrumbs.length>0){var n=i(".breadcrumbs",{children:r.map(t.breadcrumbs,function(t){var e;return e=t.image?'':t.name,i("a",{href:t.url,html:e})})});this.content.appendChild(n)}if(e){var a=e.published_on;if(a){var c=[s.formatDate(a)];e.journal&&!t.breadcrumbs&&c.push(" in "+e.journal+""),this.content.appendChild(i(".published-on",{html:c.join("")}))}}var u=this.createTextPropertyView(["document","title"],{classes:"title",elementType:"div"});this.content.appendChild(u.render().el);var l=i(".authors",{children:r.map(t.getAuthors(),function(t){var e=this.viewFactory.createView(t),n=e.render().el;return this.content.appendChild(n),n},this)});if(l.appendChild(i(".content-node.text.plain",{children:[i(".content",{text:this.node.document.on_behalf_of})]})),this.content.appendChild(l),e&&e.links.length>0){var p=i(".links");r.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"});p.appendChild(i("a.json",{href:window.URL?window.URL.createObjectURL(n):"#",html:' '+t.name,target:"_blank"}))}else p.appendChild(i("a."+t.type,{href:t.url,html:' '+t.name,target:"_blank"}))},this),this.content.appendChild(p)}if(e){var h=e.doi;h&&this.content.appendChild(i(".doi",{html:'DOI: '+h+""}))}return this}},a.Prototype.prototype=o.prototype,a.prototype=new a.Prototype,e.exports=a},{"../../../substance/application":154,"../../article_util":5,"../node":87,underscore:124}],40:[function(t,e,n){"use strict";e.exports={Model:t("./cover"),View:t("./cover_view")}},{"./cover":38,"./cover_view":39}],41:[function(t,e,n){var r=t("../../../substance/document"),o=t("../annotation/annotation"),i=function(t,e){o.call(this,t,e)};i.type={id:"cross_reference",parent:"annotation",properties:{target:"node"}},i.Prototype=function(){},i.Prototype.prototype=o.prototype,i.prototype=new i.Prototype,i.prototype.constructor=i,i.fragmentation=o.NEVER,r.Node.defineProperties(i),e.exports=i},{"../../../substance/document":167,"../annotation/annotation":9}],42:[function(t,e,n){e.exports={Model:t("./cross_reference.js"),View:t("../resource_reference/resource_reference_view.js")}},{"../resource_reference/resource_reference_view.js":98,"./cross_reference.js":41}],43:[function(t,e,n){var r=t("../../../substance/document"),o=t("../annotation/annotation"),i=function(t,e){o.call(this,t,e)};i.type={id:"custom_annotation",parent:"annotation",properties:{name:"string"}},i.Prototype=function(){},i.Prototype.prototype=o.prototype,i.prototype=new i.Prototype,i.prototype.constructor=i,i.fragmentation=o.DONT_CARE,r.Node.defineProperties(i),e.exports=i},{"../../../substance/document":167,"../annotation/annotation":9}],44:[function(t,e,n){var r=t("../annotation").View,o=function(t){r.call(this,t)};o.Prototype=function(){this.setClasses=function(){r.prototype.setClasses.call(this),this.$el.addClass(this.node.name)}},o.Prototype.prototype=r.prototype,o.prototype=new o.Prototype,e.exports=o},{"../annotation":11}],45:[function(t,e,n){e.exports={Model:t("./custom_annotation.js"),View:t("./custom_annotation_view.js")}},{"./custom_annotation.js":43,"./custom_annotation_view.js":44}],46:[function(t,e,n){var r=t("../../../substance/document"),o=function(t){r.Node.call(this,t)};o.type={id:"definition",parent:"content",properties:{source_id:"string",title:"string",description:"string"}},o.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"}},o.example={id:"definition_def1",type:"Definition",title:"IAP",description:"Integrated Analysis Platform"},o.Prototype=function(){this.urls=function(){return this.properties.citation_urls.length>0?this.properties.citation_urls:[this.properties.doi]},this.getHeader=function(){return this.properties.label?[this.properties.label,this.properties.title].join(". "):this.properties.title}},o.Prototype.prototype=r.Node.prototype,o.prototype=new o.Prototype,o.prototype.constructor=o,r.Node.defineProperties(o),e.exports=o},{"../../../substance/document":167}],47:[function(t,e,n){"use strict";var r=t("underscore"),o=t("../node").View,i=t("../../../substance/application").$$,s=t("../../resource_view"),a=function(t,e,n){o.call(this,t,e),s.call(this,n)};a.Prototype=function(){r.extend(this,s.prototype),this.renderBody=function(){this.content.appendChild(i(".description",{text:this.node.description}))}},a.Prototype.prototype=o.prototype,a.prototype=new a.Prototype,a.prototype.constructor=a,e.exports=a},{"../../../substance/application":154,"../../resource_view":119,"../node":87,underscore:124}],48:[function(t,e,n){"use strict";e.exports={Model:t("./definition"),View:t("./definition_view")}},{"./definition":46,"./definition_view":47}],49:[function(t,e,n){var r=t("../../../substance/document"),o=t("../annotation/annotation"),i=t("../resource_reference/resource_reference"),s=function(t,e){i.call(this,t,e)};s.type={id:"definition_reference",parent:"resource_reference",properties:{target:"definition"}},s.Prototype=function(){},s.Prototype.prototype=i.prototype,s.prototype=new s.Prototype,s.prototype.constructor=s,s.fragmentation=o.NEVER,r.Node.defineProperties(s),e.exports=s},{"../../../substance/document":167,"../annotation/annotation":9,"../resource_reference/resource_reference":97}],50:[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":98,"./definition_reference.js":49}],51:[function(t,e,n){"use strict";var r=t("../../../substance/document"),o=function(t,e){r.Node.call(this,t,e)};o.type={id:"document",parent:"content",properties:{views:["array","view"],guid:"string",creator:"string",title:"string",authors:["array","contributor"],on_behalf_of:"string","abstract":"string"}},o.Prototype=function(){},o.Prototype.prototype=r.Node.prototype,o.prototype=new o.Prototype,o.prototype.constructor=o,r.Node.defineProperties(o),e.exports=o},{"../../../substance/document":167}],52:[function(t,e,n){"use strict";e.exports={Model:t("./document_node")}},{"./document_node":51}],53:[function(t,e,n){var r=t("../annotation/annotation"),o=function(t,e){r.call(this,t,e)};o.type={id:"emphasis",parent:"annotation",properties:{}},o.Prototype=function(){},o.Prototype.prototype=r.prototype, o.prototype=new o.Prototype,o.prototype.constructor=o,o.fragmentation=r.DONT_CARE,e.exports=o},{"../annotation/annotation":9}],54:[function(t,e,n){e.exports={Model:t("./emphasis.js"),View:t("../annotation/annotation_view.js")}},{"../annotation/annotation_view.js":10,"./emphasis.js":53}],55:[function(t,e,n){"use strict";var r=t("../../../substance/document"),o=function(t,e){r.Composite.call(this,t,e)};o.type={parent:"content",properties:{source_id:"string",label:"string",url:"string",caption:"caption",position:"string",attrib:"string"}},o.config={zoomable:!0},o.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"}},o.example={id:"figure_1",label:"Figure 1",url:"http://example.com/fig1.png",caption:"caption_1"},o.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(){return this.properties.caption?this.document.get(this.properties.caption):void 0},this.getHeader=function(){return this.properties.label}},o.Prototype.prototype=r.Composite.prototype,o.prototype=new o.Prototype,o.prototype.constructor=o,r.Node.defineProperties(o.prototype,Object.keys(o.type.properties)),e.exports=o},{"../../../substance/document":167}],56:[function(t,e,n){"use strict";var r=t("underscore"),o=t("../composite").View,i=t("../../../substance/application").$$,s=t("../../resource_view"),a=function(t,e,n){o.call(this,t,e),s.call(this,n)};a.Prototype=function(){r.extend(this,s.prototype),this.isZoomable=!0,this.renderBody=function(){if(this.content.appendChild(i(".label",{text:this.node.label})),this.node.url){var t=i(".image-wrapper",{children:[i("a",{href:this.node.url,target:"_blank",children:[i("img",{src:this.node.url})]})]});this.content.appendChild(t)}this.renderChildren(),this.node.attrib&&this.content.appendChild(i(".figure-attribution",{text:this.node.attrib}))},this.renderLabel=function(){var t=i(".name",{href:"#"});return this.renderAnnotatedText([this.node.id,"label"],t),t}},a.Prototype.prototype=o.prototype,a.prototype=new a.Prototype,e.exports=a},{"../../../substance/application":154,"../../resource_view":119,"../composite":32,underscore:124}],57:[function(t,e,n){"use strict";e.exports={Model:t("./figure"),View:t("./figure_view")}},{"./figure":55,"./figure_view":56}],58:[function(t,e,n){var r=t("../../../substance/document"),o=t("../annotation/annotation"),i=t("../resource_reference/resource_reference"),s=function(t,e){i.call(this,t,e)};s.type={id:"figure_reference",parent:"resource_reference",properties:{target:"figure"}},s.Prototype=function(){},s.Prototype.prototype=i.prototype,s.prototype=new s.Prototype,s.prototype.constructor=s,s.fragmentation=o.NEVER,r.Node.defineProperties(s),e.exports=s},{"../../../substance/document":167,"../annotation/annotation":9,"../resource_reference/resource_reference":97}],59:[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":98,"./figure_reference.js":58}],60:[function(t,e,n){"use strict";var r=t("../../../substance/document"),o=r.Node,i=t("../paragraph").Model,s=function(t,e){i.call(this,t,e)};s.type={id:"footnote",parent:"paragraph",properties:{label:"string"}},s.description={name:"Footnote",remarks:["A Footnote is basically a Paragraph with a label."],properties:{label:"A string used as label"}},s.example={type:"footnote",id:"footnote_1",label:"a","children ":["text_1","image_1","text_2"]},s.Prototype=function(){},s.Prototype.prototype=i.prototype,s.prototype=new s.Prototype,s.prototype.constructor=s,o.defineProperties(s),e.exports=s},{"../../../substance/document":167,"../paragraph":90}],61:[function(t,e,n){"use strict";var r=t("../paragraph").View,o=function(t,e){r.call(this,t,e)};o.Prototype=function(){this.render=function(){r.prototype.render.call(this);var t=document.createElement("span");return t.classList.add("label"),t.innerHTML=this.node.label,this.el.insertBefore(t,this.content),this}},o.Prototype.prototype=r.prototype,o.prototype=new o.Prototype,e.exports=o},{"../paragraph":90}],62:[function(t,e,n){"use strict";e.exports={Model:t("./footnote"),View:t("./footnote_view")}},{"./footnote":60,"./footnote_view":61}],63:[function(t,e,n){var r=t("../../../substance/document"),o=function(t){r.Node.call(this,t)};o.type={id:"formula",parent:"content",properties:{source_id:"string",inline:"boolean",label:"string",format:["array","string"],data:["array","string"]}},o.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`"}},o.example={type:"formula",id:"formula_eqn1",label:"(1)",content:"...",format:"mathml"},o.Prototype=function(){this.inline=!1},o.Prototype.prototype=r.Node.prototype,o.prototype=new o.Prototype,o.prototype.constuctor=o,r.Node.defineProperties(o),e.exports=o},{"../../../substance/document":167}],64:[function(t,e,n){"use strict";var r=t("../node").View,o=function(t,e){r.call(this,t,e)};o.Prototype=function(){var t={latex:"math/tex",mathml:"math/mml"},e={image:0,mathml:1,latex:2};this.render=function(){this.node.inline&&this.$el.addClass("inline");var n,r=[];for(n=0;n0){var o=!1,i=!1;for(n=0;n").attr("type",c).html(a);this.$el.append(u),i=!0}break;case"image":if(!o){var l=$("
").addClass("MathJax_Preview");l.append($("").attr("src",a)),this.$el.append(l),this.$preview=l,o=!0}break;default:console.error("Unknown formula format:",s)}}}return this.node.label&&this.$el.append($('
').html(this.node.label)),this}},o.Prototype.prototype=r.prototype,o.prototype=new o.Prototype,e.exports=o},{"../node":87}],65:[function(t,e,n){"use strict";e.exports={Model:t("./formula"),View:t("./formula_view")}},{"./formula":63,"./formula_view":64}],66:[function(t,e,n){"use strict";var r=t("../../../substance/document"),o=r.Node,i=t("../text/text_node"),s=function(t,e){i.call(this,t,e)};s.type={id:"heading",parent:"content",properties:{source_id:"string",content:"string",label:"string",level:"number"}},s.example={type:"heading",id:"heading_1",content:"Introduction",level:1},s.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"}},s.Prototype=function(){this.splitInto="paragraph",this.includeInToc=function(){return!0},this.getLevel=function(){return this.level}},s.Prototype.prototype=i.prototype,s.prototype=new s.Prototype,s.prototype.constructor=s,o.defineProperties(s),e.exports=s},{"../../../substance/document":167,"../text/text_node":109}],67:[function(t,e,n){"use strict";var r=t("../node").View,o=t("../../../substance/application").$$,i=function(t,e){r.call(this,t,e),this.$el.addClass("level-"+this.node.level)};i.Prototype=function(){this.render=function(){r.prototype.render.call(this);var t=this.createTextPropertyView([this.node.id,"content"],{classes:"title"});if(this.node.label){var e=o(".label",{text:this.node.label});this.content.appendChild(e)}return this.content.appendChild(t.render().el),this},this.renderTocItem=function(){var t=o("div");if(this.node.label){var e=o(".label",{text:this.node.label});t.appendChild(e)}var n=o("span");return this.renderAnnotatedText([this.node.id,"content"],n),t.appendChild(n),t}},i.Prototype.prototype=r.prototype,i.prototype=new i.Prototype,e.exports=i},{"../../../substance/application":154,"../node":87}],68:[function(t,e,n){"use strict";e.exports={Model:t("./heading"),View:t("./heading_view")}},{"./heading":66,"./heading_view":67}],69:[function(t,e,n){var r=(t("underscore"),t("../../../substance/document")),o=function(t,e){r.Node.call(this,t,e)};o.type={id:"html_table",parent:"content",properties:{source_id:"string",label:"string",content:"string",footers:["array","string"],caption:"caption"}},o.config={zoomable:!0},o.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",content:"HTML data",footers:"HTMLTable footers expressed as an array strings",caption:"References a caption node, that has all the content"}},o.example={id:"html_table_1",type:"html_table",label:"HTMLTable 1.",title:"Lorem ipsum table",content:"...
",footers:[],caption:"caption_1"},o.Prototype=function(){this.getCaption=function(){return this.properties.caption?this.document.get(this.properties.caption):void 0},this.getHeader=function(){return this.properties.label}},o.Prototype.prototype=r.Node.prototype,o.prototype=new o.Prototype,o.prototype.constructor=o,r.Node.defineProperties(o),e.exports=o},{"../../../substance/document":167,underscore:124}],70:[function(t,e,n){"use strict";var r=t("underscore"),o=t("../node").View,i=t("../../../substance/application").$$,s=t("../../resource_view"),a=function(t,e,n){o.call(this,t,e),s.call(this,n)};a.Prototype=function(){r.extend(this,s.prototype),this.isZoomable=!0,this.renderBody=function(){var t=i(".table-wrapper",{html:this.node.content});this.content.appendChild(t);var e=i(".footers",{children:r.map(this.node.footers,function(t){return i(".footer",{html:""+t.label+" "+t.content})})});if(this.node.caption){var n=this.createView(this.node.caption);this.content.appendChild(n.render().el)}this.content.appendChild(e)}},a.Prototype.prototype=o.prototype,a.prototype=new a.Prototype,e.exports=a},{"../../../substance/application":154,"../../resource_view":119,"../node":87,underscore:124}],71:[function(t,e,n){"use strict";e.exports={Model:t("./html_table"),View:t("./html_table_view")}},{"./html_table":69,"./html_table_view":70}],72:[function(t,e,n){"use strict";var r=(t("../../../substance/document").Node,t("../web_resource").Model),o=function(t,e){r.call(this,t,e)};o.type={id:"image",parent:"webresource",properties:{source_id:"string"}},o.example={type:"image",id:"image_1",url:"http://substance.io/image_1.png"},o.description={name:"Image",remarks:["Represents a web-resource for an image."],properties:{}},o.Prototype=function(){},o.Prototype.prototype=r.prototype,o.prototype=new o.Prototype,o.prototype.constructor=o,e.exports=o},{"../../../substance/document":167,"../web_resource":117}],73:[function(t,e,n){"use strict";var r=t("../node").View,o=function(t,e){r.call(this,t,e)};o.Prototype=function(){var t=Array.prototype.indexOf;this.render=function(){var e=document.createElement("div");e.className="content";var n=document.createElement("div");n.className="image-char",this._imgChar=n;var r=document.createElement("img");return r.src=this.node.url,r.alt="alt text",r.title="alt text",n.appendChild(r),e.appendChild(n),this.el.appendChild(e),this._imgPos=t.call(n.childNodes,r),this},this["delete"]=function(t,e){for(var n=this.$(".content")[0],r=n.childNodes,o=e-1;o>=0;o--)n.removeChild(r[t+o])},this.getCharPosition=function(t,e){return t===this._imgChar?e>this._imgPos?1:0:void 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}},o.Prototype.prototype=r.prototype,o.prototype=new o.Prototype,e.exports=o},{"../node":87}],74:[function(t,e,n){"use strict";e.exports={Model:t("./image"),View:t("./image_view")}},{"./image":72,"./image_view":73}],75:[function(t,e,n){"use strict";e.exports={node:t("./node"),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"),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"),html_table:t("./html_table"),supplement:t("./supplement"),video:t("./video"),contributor:t("./contributor"),definition:t("./definition"),citation:t("./citation"),formula:t("./formula"),list:t("./list"),codeblock:t("./codeblock"),affiliation:t("./_affiliation"),footnote:t("./footnote")}},{"./_affiliation":8,"./annotation":11,"./author_callout":14,"./box":17,"./caption":20,"./citation":23,"./citation_reference":25,"./code":27,"./codeblock":30,"./composite":32,"./contributor":35,"./contributor_reference":37,"./cover":40,"./cross_reference":42,"./custom_annotation":45,"./definition":48,"./definition_reference":50,"./document":52,"./emphasis":54,"./figure":57,"./figure_reference":59,"./footnote":62,"./formula":65,"./heading":68,"./html_table":71,"./image":74,"./inline_formula":76,"./inline_image":79,"./link":81,"./list":84,"./node":87,"./paragraph":90,"./publication_info":93,"./resource_reference":96,"./strong":99,"./subscript":101,"./superscript":103,"./supplement":105,"./text":108,"./underline":112,"./video":114,"./web_resource":117}],76:[function(t,e,n){e.exports={Model:t("./inline_formula.js"),View:t("./inline_formula_view.js")}},{"./inline_formula.js":77,"./inline_formula_view.js":78}],77:[function(t,e,n){var r=t("../../../substance/document"),o=t("../annotation/annotation"),i=function(t,e){o.call(this,t,e)};i.type={id:"inline-formula",parent:"annotation",properties:{target:"formula"}},i.Prototype=function(){},i.Prototype.prototype=o.prototype,i.prototype=new i.Prototype,i.prototype.constructor=i,i.fragmentation=o.NEVER,r.Node.defineProperties(i),e.exports=i},{"../../../substance/document":167,"../annotation/annotation":9}],78:[function(t,e,n){"use strict";var r=t("../resource_reference").View,o=function(t,e){r.call(this,t,e),$(this.el).removeClass("resource-reference")};o.Prototype=function(){this.createElement=function(){var t=document.createElement("span");return t},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}},o.Prototype.prototype=r.prototype,o.prototype=new o.Prototype,e.exports=o},{"../resource_reference":96}],79:[function(t,e,n){e.exports={Model:t("./inline_image.js"),View:t("../annotation/annotation_view.js")}},{"../annotation/annotation_view.js":10,"./inline_image.js":80}],80:[function(t,e,n){var r=t("../../../substance/document"),o=t("../annotation/annotation"),i=function(t,e){o.call(this,t,e)};i.type={id:"inline-image",parent:"annotation",properties:{target:"image"}},i.Prototype=function(){},i.Prototype.prototype=o.prototype,i.prototype=new i.Prototype,i.prototype.constructor=i,i.fragmentation=o.NEVER,r.Node.defineProperties(i),e.exports=i},{"../../../substance/document":167,"../annotation/annotation":9}],81:[function(t,e,n){e.exports={Model:t("./link.js"),View:t("./link_view.js")}},{"./link.js":82,"./link_view.js":83}],82:[function(t,e,n){var r=t("../../../substance/document"),o=t("../annotation/annotation"),i=function(t,e){o.call(this,t,e)};i.type={id:"link",parent:"annotation",properties:{url:"string"}},i.Prototype=function(){},i.Prototype.prototype=o.prototype,i.prototype=new i.Prototype,i.prototype.constructor=i,i.fragmentation=o.NEVER,r.Node.defineProperties(i),e.exports=i},{"../../../substance/document":167,"../annotation/annotation":9}],83:[function(t,e,n){var r=t("../annotation").View,o=function(t){r.call(this,t)};o.Prototype=function(){this.createElement=function(){var t=document.createElement("a");return t.setAttribute("href",this.node.url),t},this.setClasses=function(){this.$el.addClass("link")}},o.Prototype.prototype=r.prototype,o.prototype=new o.Prototype,e.exports=o},{"../annotation":11}],84:[function(t,e,n){"use strict";e.exports={Model:t("./list"),View:t("./list_view")}},{"./list":85,"./list_view":86}],85:[function(t,e,n){"use strict";var r=t("underscore"),o=t("../../../substance/document"),i=o.Node,s=o.Composite,a=function(t,e){s.call(this,t,e)};a.type={id:"list",parent:"content",properties:{source_id:"string",items:["array","paragraph"],ordered:"boolean"}},a.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"}},a.example={type:"list",id:"list_1","items ":["paragraph_listitem_1","paragraph_listitem_2"]},a.Prototype=function(){this.getLength=function(){return this.properties.items.length},this.getChildrenIds=function(){return r.clone(this.items)},this.getItems=function(){return r.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(0>r)throw new Error("Unknown child "+e);var o=t.get(e),i=o["break"](t,n);return t.update([this.id,"items"],["+",r+1,i.id]),i}},a.Prototype.prototype=s.prototype,a.prototype=new a.Prototype,a.prototype.constructor=a,i.defineProperties(a.prototype,["items","ordered"]),e.exports=a},{"../../../substance/document":167,underscore:124}],86:[function(t,e,n){"use strict";var r=t("../composite/composite_view"),o=t("./list"),i=function(t,e){r.call(this,t,e)};i.whoami="SubstanceListView",i.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;for(e=0;e0){var n=o(".subject.container",{children:[o("div.label",{text:"Subject"}),o("div.value",{text:this.node.subjects.join(", ")})]});t.appendChild(n)}if(this.node.research_organisms&&this.node.research_organisms.length>0){var i=o(".subject.container",{children:[o("div.label",{text:"Organism"}),o("div.value",{text:this.node.research_organisms.join(", ")})]});t.appendChild(i)}if(this.node.keywords&&this.node.keywords.length>0){var s=o(".keywords.container",{children:[o("div.label",{text:"Keywords"}),o("div.value",{text:this.node.keywords.join(", ")})]});t.appendChild(s)}if(this.node.doi){var a=o(".doi.container",{children:[o("div.label",{text:"DOI"}),o("div.value",{children:[o("a",{href:"http://dx.doi.org/"+this.node.doi,text:this.node.doi,target:"_blank"})]})]});t.appendChild(a)}if(this.node.related_article){var c=o(".related-article.container",{children:[o("div.label",{text:"Related Article"}),o("div.value",{children:[o("a",{href:this.node.related_article,text:this.node.related_article})]})]});t.appendChild(c)}var u=this.describePublicationHistory();t.appendChild(u),this.content.appendChild(t);var l=this.node.getArticleInfo(),p=this.viewFactory.createView(l),h=p.render().el;return this.content.appendChild(h),this},this.describePublicationHistory=function(){var t,e=o(".dates"),n=[];if(this.node.history&&this.node.history.length>0&&(n=n.concat(this.node.history)),this.node.published_on&&n.push({type:"published",date:this.node.published_on}),n.length>0){for(e.appendChild(document.createTextNode("The article was ")),t=0;t0&&(e.appendChild(document.createTextNode(", ")),t===n.length-1&&e.appendChild(document.createTextNode("and ")));var r=n[t];e.appendChild(document.createTextNode((s[r.type]||s["default"])+" on ")),e.appendChild(o("b",{text:i.formatDate(r.date)}))}e.appendChild(document.createTextNode("."))}return e},this.dispose=function(){r.prototype.dispose.call(this)}},a.Prototype.prototype=r.prototype,a.prototype=new a.Prototype,e.exports=a},{"../../../substance/application":154,"../../article_util":5,"../node":87}],96:[function(t,e,n){e.exports={Model:t("./resource_reference.js"),View:t("./resource_reference_view.js")}},{"./resource_reference.js":97,"./resource_reference_view.js":98}],97:[function(t,e,n){var r=t("../../../substance/document"),o=t("../annotation/annotation"),i=function(t,e){o.call(this,t,e)};i.type={id:"resource_reference",parent:"annotation",properties:{target:"node"}},i.Prototype=function(){},i.Prototype.prototype=o.prototype,i.prototype=new i.Prototype,i.prototype.constructor=i,i.fragmentation=o.NEVER,r.Node.defineProperties(i),e.exports=i},{"../../../substance/document":167,"../annotation/annotation":9}],98:[function(t,e,n){"use strict";var r=t("../annotation/annotation_view"),o=function(t,e){r.call(this,t,e),this.$el.addClass("resource-reference")};o.Prototype=function(){this.createElement=function(){var t=document.createElement("a");return t.setAttribute("href",""),t}},o.Prototype.prototype=r.prototype,o.prototype=new o.Prototype,e.exports=o},{"../annotation/annotation_view":10}],99:[function(t,e,n){e.exports={Model:t("./strong.js"),View:t("../annotation/annotation_view.js")}},{"../annotation/annotation_view.js":10,"./strong.js":100}],100:[function(t,e,n){var r=t("../annotation/annotation"),o=function(t,e){r.call(this,t,e)};o.type={id:"strong",parent:"annotation",properties:{}},o.Prototype=function(){},o.Prototype.prototype=r.prototype,o.prototype=new o.Prototype,o.prototype.constructor=o,o.fragmentation=r.DONT_CARE,e.exports=o},{"../annotation/annotation":9}],101:[function(t,e,n){e.exports={Model:t("./subscript.js"),View:t("../annotation/annotation_view.js")}},{"../annotation/annotation_view.js":10,"./subscript.js":102}],102:[function(t,e,n){var r=t("../annotation/annotation"),o=function(t,e){r.call(this,t,e)};o.type={id:"subscript",parent:"annotation",properties:{}},o.Prototype=function(){},o.Prototype.prototype=r.prototype,o.prototype=new o.Prototype,o.prototype.constructor=o,o.fragmentation=r.DONT_CARE,e.exports=o},{"../annotation/annotation":9}],103:[function(t,e,n){e.exports={Model:t("./superscript.js"),View:t("../annotation/annotation_view.js")}},{"../annotation/annotation_view.js":10,"./superscript.js":104}],104:[function(t,e,n){var r=t("../annotation/annotation"),o=function(t,e){r.call(this,t,e)};o.type={id:"superscript",parent:"annotation",properties:{}},o.Prototype=function(){},o.Prototype.prototype=r.prototype,o.prototype=new o.Prototype,o.prototype.constructor=o,o.fragmentation=r.DONT_CARE,e.exports=o},{"../annotation/annotation":9}],105:[function(t,e,n){"use strict";e.exports={Model:t("./supplement"),View:t("./supplement_view")}},{"./supplement":106,"./supplement_view":107}],106:[function(t,e,n){var r=(t("underscore"),t("../../../substance/document")),o=function(t,e){r.Composite.call(this,t,e)};o.type={id:"supplement",parent:"content",properties:{source_id:"string",label:"string",url:"string",caption:"caption"}},o.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"}},o.example={id:"supplement_1",source_id:"SD1-data",type:"supplement",label:"Supplementary file 1.",url:"http://myserver.com/myfile.pdf",caption:"caption_supplement_1"},o.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}},o.Prototype.prototype=r.Composite.prototype,o.prototype=new o.Prototype,o.prototype.constructor=o,r.Node.defineProperties(o),e.exports=o},{"../../../substance/document":167,underscore:124}],107:[function(t,e,n){"use strict";var r=t("underscore"),o=t("../composite").View,i=t("../../../substance/application").$$,s=t("../../resource_view"),a=function(t,e,n){o.call(this,t,e),s.call(this,n)};a.Prototype=function(){r.extend(this,s.prototype),this.renderBody=function(){this.renderChildren();var t=i("div.file",{children:[i("a",{href:this.node.url,html:' Download'})]});this.content.appendChild(t)}},a.Prototype.prototype=o.prototype,a.prototype=new a.Prototype,a.prototype.constructor=a,e.exports=a},{"../../../substance/application":154,"../../resource_view":119,"../composite":32,underscore:124}],108:[function(t,e,n){"use strict";e.exports={Model:t("./text_node"),View:t("./text_view") }},{"./text_node":109,"./text_view":111}],109:[function(t,e,n){"use strict";var r=t("../../../substance/document");e.exports=r.TextNode},{"../../../substance/document":167}],110:[function(t,e,n){"use strict";var r=t("../../../substance/util"),o=r.Fragmenter,i=t("../../../substance/application").View,s=function(t,e,n,r){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)};s.Prototype=function(){this.render=function(){return this.el.innerHTML="",s.renderAnnotatedText(this.document,this.property,this.el,this.viewFactory),this},this.dispose=function(){this.stopListening()},this.renderWithAnnotations=function(t){var e=this,n=this.property.get(),r=document.createDocumentFragment(),i=this.document,s=[],a=new o;a.onText=function(t,e){t.appendChild(document.createTextNode(e))},a.onEnter=function(t,n){var r=i.get(t.id),o=e.viewFactory.createView(r);return n.appendChild(o.el),s.push(o),o.el},a.start(r,n,t);for(var c=0;c Fullscreen'})),e.appendChild(i("a.toggle-res.toggle.action-toggle-resource",{href:"#",html:' Focus'})),t.appendChild(e),this.headerEl=t,this.el.insertBefore(t,this.content)}},this.renderLabel=function(){var t=i("div.name",{html:this.getHeader()});return t},this.renderBody=function(){},this.getHeader=function(){return this.node.getHeader()}},a.prototype=new a.Prototype,e.exports=a},{"../substance/application":154,"./nodes/node":87,underscore:124}],120:[function(t,e,n){var r=function(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){var r=this.getNodeViewClass(t,n),o=new r(t,this,e);return o}},r.prototype=new r.Prototype,e.exports=r},{}],121:[function(t,e,n){"use strict";var r=t("../substance/util"),o=t("underscore"),i=t("lens/converter"),s=function(t){i.call(this,t)};s.Prototype=function(){var t=i.prototype;this.test=function(t,e){var n=t.querySelector("publisher-name").textContent;return"eLife Sciences Publications, Ltd"===n},this.__ignoreCustomMetaNames=["elife-xml-version"],this.enhanceArticle=function(t,e){var n,o,i=[],s=t.doc,a=e.querySelector("#SA1");a&&(n={id:t.nextId("heading"),type:"heading",level:1,content:"Article Commentary"},s.create(n),i.push(n),n={id:t.nextId("heading"),type:"heading",level:2,content:"Decision letter"},s.create(n),i.push(n),o=a.querySelector("body"),i=i.concat(this.bodyNodes(t,r.dom.getChildren(o))));var c=e.querySelector("#SA2");c&&(n={id:t.nextId("heading"),type:"heading",level:2,content:"Author response"},s.create(n),i.push(n),o=c.querySelector("body"),i=i.concat(this.bodyNodes(t,r.dom.getChildren(o)))),i.length>0&&this.show(t,i)},this.enhanceCover=function(t,e,n){var r,o=n.querySelector("subj-group[subj-group-type=display-channel] subject").textContent;try{r=n.querySelector("subj-group[subj-group-type=heading] subject").textContent}catch(i){r=null}e.breadcrumbs=[{name:"eLife",url:"http://elifesciences.org/",image:"http://lens.elifesciences.org/lens-elife/styles/elife.png"},{name:o,url:"http://elifesciences.org/category/"+o.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"),o=r.getAttribute("xlink:href");e.url=this.resolveURL(t,o)},this.resolveURL=function(t,e){if(e.match(/http:\/\//))return e;var n=this.getBaseURL(t);return n?[n,e].join(""):["http://cdn.elifesciences.org/elife-articles/",t.doc.id,"/jpg/",e,".jpg"].join("")},this.enhanceSupplement=function(t,e){var n=this.getBaseURL(t);return n?[n,e.url].join(""):void(e.url=["http://cdn.elifesciences.org/elife-articles/",t.doc.id,"/suppl/",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"),s=n.querySelectorAll("kwd-group[kwd-group-type=author-keywords] kwd"),a=n.querySelectorAll("subj-group[subj-group-type=heading] subject"),c=n.querySelector("subj-group[subj-group-type=display-channel] subject"),u=e.querySelector("self-uri[content-type=pdf]"),l=["http://cdn.elifesciences.org/elife-articles/",t.doc.id,"/pdf/",u?u.getAttribute("xlink:href"):"#"].join(""),p=[];l&&p.push({url:l,name:"PDF",type:"pdf"}),p.push({url:"https://s3.amazonaws.com/elife-cdn/elife-articles/"+t.doc.id+"/elife"+t.doc.id+".xml",name:"Source XML",type:"xml"}),p.push({url:"",name:"Lens JSON",type:"json"}),r.research_organisms=o.pluck(i,"textContent"),r.keywords=o.pluck(s,"textContent"),r.subjects=o.pluck(a,"textContent"),r.article_type=c?c.textContent:"",r.links=p,r.related_article&&(r.related_article="http://dx.doi.org/"+r.related_article)},this.enhanceSupplement=function(t,e){var n=this.getBaseURL(t);return n?[n,e.url].join(""):void(e.url=["http://cdn.elifesciences.org/elife-articles/",t.doc.id,"/suppl/",e.url].join(""))},this.enhanceVideo=function(t,e,n){var r=n.getAttribute("xlink:href").split("."),o=r[0];e.url="http://api.elifesciences.org/v2/articles/"+t.doc.id+"/media/file/"+o+".mp4",e.url_ogv="http://api.elifesciences.org/v2/articles/"+t.doc.id+"/media/file//"+o+".ogv",e.url_webm="http://api.elifesciences.org/v2/articles/"+t.doc.id+"/media/file//"+o+".webm",e.poster="http://api.elifesciences.org/v2/articles/"+t.doc.id+"/media/file/"+o+".jpg"},this.resolveURL=function(t,e){if(e.match(/http:\/\//))return e;var n=this.getBaseURL(t);return n?[n,e].join(""):["http://cdn.elifesciences.org/elife-articles/",t.doc.id,"/jpg/",e,".jpg"].join("")};var e=/author-callout-style/;this.enhanceAnnotationData=function(t,n,r,o){if("named-content"===o){var i=r.getAttribute("content-type");e.test(i)&&(n.type="author_callout",n.style=i)}},this.showNode=function(e,n){switch(n.type){case"box":n.label&&e.doc.show("figures",n.id);break;default:t.showNode.apply(this,arguments)}}},s.Prototype.prototype=i.prototype,s.prototype=new s.Prototype,s.prototype.constructor=s,e.exports=s},{"../substance/util":175,"lens/converter":122,underscore:124}],122:[function(t,e,n){"use strict";var r=t("./lens_converter");e.exports=r},{"./lens_converter":123}],123:[function(t,e,n){"use strict";var r=t("underscore"),o=t("../substance/util"),i=o.errors,s=i.define("ImporterError"),a=t("../article"),c=function(t){this.options=t||c.DefaultOptions};c.Prototype=function(){this._annotationTypes={bold:"strong",italic:"emphasis",monospace:"code",sub:"subscript",sup:"superscript",sc:"custom_annotation",underline:"underline","ext-link":"link",xref:"",email:"link","named-content":"","inline-formula":"inline-formula",uri:"link"},this._refTypeMapping={bibr:"citation_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"},this.isAnnotation=function(t){return void 0!==this._annotationTypes[t]},this.isParagraphish=function(t){for(var e=0;e]+)>/g,"<$1$2>")},this.selectDirectChildren=function(t,e){for(var n=[],r=t.querySelectorAll(e),o=0;o0&&r.each(s,function(e){var s=e.querySelector("title"),a={type:"heading",id:t.nextId("heading"),level:3,content:s?this.capitalized(s.textContent.toLowerCase(),"all"):"Acknowledgements"};i.create(a),n.push(a.id);var c=this.bodyNodes(t,o.dom.getChildren(e),{ignore:["title"]});r.each(c,function(t){n.push(t.id)})},this),n},this.extractNotes=function(){var t=[];return t},this.__ignoreCustomMetaNames=[],this.extractCustomMetaGroup=function(t,e){var n=[],o=t.doc,i=e.querySelectorAll("article-meta-group custom-meta");if(0===i.length)return n;for(var s=0;s0&&(s.bio=[o[0].id])}},this),"yes"===e.getAttribute("deceased")&&(s.deceased=!0);var l=e.querySelector("uri[content-type=orcid]");l&&(s.orcid=l.getAttribute("xlink:href"));var p=e.querySelector("name");if(p)s.name=this.getName(p);else{var h=e.querySelector("collab");h?s.name=h.textContent:s.name="N/A"}this.extractContributorProperties(t,e,s),0===s.affiliations.length&&(s.affiliations=t.affiliations),s.competing_interests.length>1&&(s.competing_interests=r.filter(s.competing_interests,function(t){return t.indexOf("no competing")<0})),"author"===e.getAttribute("contrib-type")&&n.nodes.document.authors.push(i),n.create(s),n.show("info",s.id)},this._getEqualContribs=function(t,e,n){var o=[],i=t.xmlDoc.querySelectorAll("xref[rid="+n+"]");return r.each(i,function(t){var n=t.parentNode;n!==e&&o.push(this.getName(n.querySelector("name")))},this),o},this.extractContributorProperties=function(t,e,n){var o=t.doc,i=[],s=[],a=e.querySelectorAll("xref");r.each(a,function(r){if("aff"===r.getAttribute("ref-type")){var a=r.getAttribute("rid"),c=o.getNodeBySourceId(a);c&&(n.affiliations.push(c.id),t.used[a]=!0)}else if("other"===r.getAttribute("ref-type")){console.log("FIXME: please add documentation about using 'other' as indicator for extracting an awardGroup.");var u=t.xmlDoc.getElementById(r.getAttribute("rid"));if(!u)return;var l=u.querySelector("funding-source");if(!l)return;var p=u.querySelector("award-id");p=p?", "+p.textContent:"";var h=l.childNodes[0].textContent;n.fundings.push([h,p].join(""))}else if("corresp"===r.getAttribute("ref-type")){var d=r.getAttribute("rid"),f=t.xmlDoc.getElementById(d);if(!f)return;var g=f.querySelector("email");if(!g)return;n.emails.push(g.textContent)}else if("fn"===r.getAttribute("ref-type")){var y=r.getAttribute("rid"),m=t.xmlDoc.getElementById(y),v=!0;if(m){var b=m.getAttribute("fn-type");switch(b){case"con":n.contribution=m.textContent;break;case"conflict":s.push(m.textContent.trim());break;case"present-address":n.present_address=m.querySelector("p").textContent;break;case"equal":console.log("FIXME: isn't fnElem.getAttribute(id) === fnId?"),i=this._getEqualContribs(t,e,m.getAttribute("id"));break;case"other":console.log("FIXME: isn't fnElem.getAttribute(id) === fnId?"),m.getAttribute("id").indexOf("equal-contrib")>=0?i=this._getEqualContribs(t,e,m.getAttribute("id")):v=!1;break;default:v=!1}v&&(t.used[y]=!0)}}else console.log("Skipping contrib's xref",r.textContent)},this),s.length>1&&(s=r.filter(s,function(t){return t.indexOf("no competing")<0})),n.competing_interests=s;var c=e.querySelector("xref[ref-type=other]");if(c){var u=c.getAttribute("rid"),l=t.xmlDoc.querySelectorAll("#"+u+" contrib");n.members=r.map(l,function(t){return this.getName(t.querySelector("name"))},this)}n.equal_contrib=i,n.competing_interests=s},this.document=function(t,e){var n=t.doc,o=e.querySelector("article");if(!o)throw new s("Expected to find an 'article' element.");return this.article(t,o),this.postProcess(t),r.each(n.containers,function(t){t.rebuild()}),n},this.postProcess=function(t){this.postProcessAnnotations(t)},this.postProcessAnnotations=function(t){for(var e=0;e0?n.id=e[0].textContent:n.id=o.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(e.length>0){var r=this.pubDate(t,e[0]);n.created_at=r.date}},this.pubDate=function(t,e){var n=-1,i=-1,s=-1;r.each(o.dom.getChildren(e),function(t){var e=o.dom.getNodeType(t),r=t.textContent;"day"===e?n=parseInt(r,10):"month"===e?i=parseInt(r,10):"year"===e&&(s=parseInt(r,10))},this);var a=new Date(s,i,n);return{date:a}},this.abstracts=function(t,e){var n=e.querySelectorAll("abstract");r.each(n,function(e){this["abstract"](t,e)},this)},this["abstract"]=function(t,e){var n=t.doc,r=[],i=e.querySelector("title"),s={id:t.nextId("heading"),type:"heading",level:1,content:i?i.textContent:"Abstract"};n.create(s),r.push(s),r=r.concat(this.bodyNodes(t,o.dom.getChildren(e),{ignore:["title","object-id"]})),r.length>0&&this.show(t,r)},this.body=function(t,e){var n=t.doc,r={id:t.nextId("heading"),type:"heading",level:1,content:"Main Text"};n.create(r);var i=[r].concat(this.bodyNodes(t,o.dom.getChildren(e)));i.length>0&&this.show(t,i)},this._ignoredBodyNodes={fig:!0,"table-wrap":!0},this._bodyNodes={},this.bodyNodes=function(t,e,n){for(var i,s=[],a=0;a=0?(i=this.ignoredNode(t,c,u),i&&s.push(i)):console.error("Node not yet supported as top-level node: "+u)}return s},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.boxedText(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.ignoredNode=function(){},this.comment=function(){return null},this.boxedText=function(t,e){var n=t.doc,i=this.bodyNodes(t,o.dom.getChildren(e)),s=t.nextId("box"),a={type:"box",id:s,source_id:e.getAttribute("id"),label:"",children:r.pluck(i,"id")};return n.create(a),a},this.datasets=function(t,e){for(var n=[],r=0;r0&&n.push(c[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 s=o.dom.getChildren(e),a=0;a0&&a){var c=t.nextId("heading"),u={id:c,source_id:e.getAttribute("id"),type:"heading",level:t.sectionLevel,content:a?this.annotatedText(t,a,[c,"content"]):""};s&&(u.label=s.textContent),u.content.length>0&&(n.create(u),i.unshift(u))}else 0===i.length&&console.info("NOTE: skipping section without content:",a?a.innerHTML:"no title");return t.sectionLevel--,i},this.ignoredParagraphElements={comment:!0,"supplementary-material":!0,fig:!0,"fig-group":!0,"table-wrap":!0,media:!0},this.acceptedParagraphElements={"boxed-text":{handler:"boxedText"},list:{handler:"list"},"disp-formula":{handler:"formula"}},this.inlineParagraphElements={"inline-graphic":!0,"inline-formula":!0},this.segmentParagraphElements=function(t){for(var e=[],n="",i=new o.dom.ChildNodeIterator(t);i.hasNext();){var s=i.next(),a=o.dom.getNodeType(s);this.ignoredParagraphElements[a]||("text"===a||this.isAnnotation(a)||this.inlineParagraphElements[a]?("paragraph"!==n&&(e.push({handler:"paragraph", nodes:[]}),n="paragraph"),r.last(e).nodes.push(s)):(this.acceptedParagraphElements[a]&&e.push(r.extend({node:s},this.acceptedParagraphElements[a])),n=a))}return e},this.paragraphGroup=function(t,e){for(var n=[],r=this.segmentParagraphElements(e),o=0;o0&&(l.content=p,n.create(l),s.push(l)),t.stack.pop()}else if("inline-graphic"===u){var h=c.getAttribute("xlink:href"),d={id:t.nextId("image"),type:"image",url:this.resolveURL(t,h)};n.create(d),s.push(d)}else if("inline-formula"===u){var f=this.formula(t,c,"inline");f&&s.push(f)}}return 0===s.length?null:(i.children=r.map(s,function(t){return t.id}),n.create(i),i)},this.list=function(t,e){var n=t.doc,r={id:t.nextId("list"),source_id:e.getAttribute("id"),type:"list",items:[],ordered:!1};"ordered"===e.getAttribute("list-type")&&(r.ordered=!0);for(var i=e.querySelectorAll("list-item"),s=0;sn){var o=/((?:\w+:\/\/)?[\/]?[^\/]+[\/]?)(.*)/.exec(e);if(o){var i=o[1]||"",s=o[2]||"";if(i.length>n-r)e=i.substring(0,n-r)+"..."+s.substring(s.length-r-3);else{var a=Math.max(n-i.length-3,r-3);e=i+"..."+s.substring(s.length-a)}}else e=e.substring(0,n-r)+"..."+e.substring(e.length-r-3)}return e},this.getBaseURL=function(t){var e=t.xmlDoc.querySelector("article").getAttribute("xml:base");return e||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"),o=r.getAttribute("xlink:href");e.url=this.resolveURL(t,o)},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,o=n.getAttribute("xlink:href");if(o.match(/http:/)){var i=o.lastIndexOf(".");return r=o.substring(0,i),e.url=r+".mp4",e.url_ogv=r+".ogv",e.url_webm=r+".webm",void(e.poster=r+".png")}var s=this.getBaseURL(t);r=o.split(".")[0],e.url=s+r+".mp4",e.url_ogv=s+r+".ogv",e.url_webm=s+r+".webm",e.poster=s+r+".png"},this.resolveURL=function(t,e){return e.match(/http:/)?e:[t.options.baseURL,e].join("")},this.viewMapping={box:"content",supplement:"figures",figure:"figures",html_table:"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)}},c.State=function(t,e,n){var o=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 s=/^\s+/g,a=/^\s*/g,c=/\s+$/g,u=/\s+/g,l=" ",p=/[\t\n\r]+/g;this.lastChar="",this.skipWS=!1,this.acceptText=function(t){return this.options.TRIM_WHITESPACES?(t=t.replace(p,""),t=this.lastChar===l||this.skipWS?t.replace(a,""):t.replace(s,l),this.skipWS=!1,t=t.replace(c,l),this.options.REMOVE_INNER_WS&&(t=t.replace(u,l)),this.lastChar=t[t.length-1]||this.lastChar,t):t},this.top=function(){var t=r.last(o.stack);return t=t||{},t.ignore=t.ignore||[],t}},c.prototype=new c.Prototype,c.prototype.constructor=c,c.DefaultOptions={TRIM_WHITESPACES:!0,REMOVE_INNER_WS:!0},e.exports=c},{"../article":6,"../substance/util":175,underscore:124}],124:[function(t,e,n){(function(){function t(t){function e(e,n,r,o,i,s){for(;i>=0&&s>i;i+=t){var a=o?o[i]:i;r=n(r,e[a],a,e)}return r}return function(n,r,o,i){r=_(r,i,4);var s=!S(n)&&w.keys(n),a=(s||n).length,c=t>0?0:a-1;return arguments.length<3&&(o=n[s?s[c]:c],c+=t),e(n,r,o,s,c,a)}}function r(t){return function(e,n,r){n=x(n,r);for(var o=k(e),i=t>0?0:o-1;i>=0&&o>i;i+=t)if(n(e[i],i,e))return i;return-1}}function o(t,e,n){return function(r,o,i){var s=0,a=k(r);if("number"==typeof i)t>0?s=i>=0?i:Math.max(i+a,s):a=i>=0?Math.min(i+1,a):i+a+1;else if(n&&i&&a)return i=n(r,o),r[i]===o?i:-1;if(o!==o)return i=e(h.call(r,s,a),w.isNaN),i>=0?i+s:-1;for(i=t>0?s:a-1;i>=0&&a>i;i+=t)if(r[i]===o)return i;return-1}}function i(t,e){var n=$.length,r=t.constructor,o=w.isFunction(r)&&r.prototype||u,i="constructor";for(w.has(t,i)&&!w.contains(e,i)&&e.push(i);n--;)i=$[n],i in t&&t[i]!==o[i]&&!w.contains(e,i)&&e.push(i)}var s=this,a=s._,c=Array.prototype,u=Object.prototype,l=Function.prototype,p=c.push,h=c.slice,d=u.toString,f=u.hasOwnProperty,g=Array.isArray,y=Object.keys,m=l.bind,v=Object.create,b=function(){},w=function(t){return t instanceof w?t:this instanceof w?void(this._wrapped=t):new w(t)};"undefined"!=typeof n?("undefined"!=typeof e&&e.exports&&(n=e.exports=w),n._=w):s._=w,w.VERSION="1.8.3";var _=function(t,e,n){if(void 0===e)return t;switch(null==n?3:n){case 1:return function(n){return t.call(e,n)};case 2:return function(n,r){return t.call(e,n,r)};case 3:return function(n,r,o){return t.call(e,n,r,o)};case 4:return function(n,r,o,i){return t.call(e,n,r,o,i)}}return function(){return t.apply(e,arguments)}},x=function(t,e,n){return null==t?w.identity:w.isFunction(t)?_(t,e,n):w.isObject(t)?w.matcher(t):w.property(t)};w.iteratee=function(t,e){return x(t,e,1/0)};var C=function(t,e){return function(n){var r=arguments.length;if(2>r||null==n)return n;for(var o=1;r>o;o++)for(var i=arguments[o],s=t(i),a=s.length,c=0;a>c;c++){var u=s[c];e&&void 0!==n[u]||(n[u]=i[u])}return n}},P=function(t){if(!w.isObject(t))return{};if(v)return v(t);b.prototype=t;var e=new b;return b.prototype=null,e},T=function(t){return function(e){return null==e?void 0:e[t]}},N=Math.pow(2,53)-1,k=T("length"),S=function(t){var e=k(t);return"number"==typeof e&&e>=0&&N>=e};w.each=w.forEach=function(t,e,n){e=_(e,n);var r,o;if(S(t))for(r=0,o=t.length;o>r;r++)e(t[r],r,t);else{var i=w.keys(t);for(r=0,o=i.length;o>r;r++)e(t[i[r]],i[r],t)}return t},w.map=w.collect=function(t,e,n){e=x(e,n);for(var r=!S(t)&&w.keys(t),o=(r||t).length,i=Array(o),s=0;o>s;s++){var a=r?r[s]:s;i[s]=e(t[a],a,t)}return i},w.reduce=w.foldl=w.inject=t(1),w.reduceRight=w.foldr=t(-1),w.find=w.detect=function(t,e,n){var r;return r=S(t)?w.findIndex(t,e,n):w.findKey(t,e,n),void 0!==r&&-1!==r?t[r]:void 0},w.filter=w.select=function(t,e,n){var r=[];return e=x(e,n),w.each(t,function(t,n,o){e(t,n,o)&&r.push(t)}),r},w.reject=function(t,e,n){return w.filter(t,w.negate(x(e)),n)},w.every=w.all=function(t,e,n){e=x(e,n);for(var r=!S(t)&&w.keys(t),o=(r||t).length,i=0;o>i;i++){var s=r?r[i]:i;if(!e(t[s],s,t))return!1}return!0},w.some=w.any=function(t,e,n){e=x(e,n);for(var r=!S(t)&&w.keys(t),o=(r||t).length,i=0;o>i;i++){var s=r?r[i]:i;if(e(t[s],s,t))return!0}return!1},w.contains=w.includes=w.include=function(t,e,n,r){return S(t)||(t=w.values(t)),("number"!=typeof n||r)&&(n=0),w.indexOf(t,e,n)>=0},w.invoke=function(t,e){var n=h.call(arguments,2),r=w.isFunction(e);return w.map(t,function(t){var o=r?e:t[e];return null==o?o:o.apply(t,n)})},w.pluck=function(t,e){return w.map(t,w.property(e))},w.where=function(t,e){return w.filter(t,w.matcher(e))},w.findWhere=function(t,e){return w.find(t,w.matcher(e))},w.max=function(t,e,n){var r,o,i=-(1/0),s=-(1/0);if(null==e&&null!=t){t=S(t)?t:w.values(t);for(var a=0,c=t.length;c>a;a++)r=t[a],r>i&&(i=r)}else e=x(e,n),w.each(t,function(t,n,r){o=e(t,n,r),(o>s||o===-(1/0)&&i===-(1/0))&&(i=t,s=o)});return i},w.min=function(t,e,n){var r,o,i=1/0,s=1/0;if(null==e&&null!=t){t=S(t)?t:w.values(t);for(var a=0,c=t.length;c>a;a++)r=t[a],i>r&&(i=r)}else e=x(e,n),w.each(t,function(t,n,r){o=e(t,n,r),(s>o||o===1/0&&i===1/0)&&(i=t,s=o)});return i},w.shuffle=function(t){for(var e,n=S(t)?t:w.values(t),r=n.length,o=Array(r),i=0;r>i;i++)e=w.random(0,i),e!==i&&(o[i]=o[e]),o[e]=n[i];return o},w.sample=function(t,e,n){return null==e||n?(S(t)||(t=w.values(t)),t[w.random(t.length-1)]):w.shuffle(t).slice(0,Math.max(0,e))},w.sortBy=function(t,e,n){return e=x(e,n),w.pluck(w.map(t,function(t,n,r){return{value:t,index:n,criteria:e(t,n,r)}}).sort(function(t,e){var n=t.criteria,r=e.criteria;if(n!==r){if(n>r||void 0===n)return 1;if(r>n||void 0===r)return-1}return t.index-e.index}),"value")};var A=function(t){return function(e,n,r){var o={};return n=x(n,r),w.each(e,function(r,i){var s=n(r,i,e);t(o,r,s)}),o}};w.groupBy=A(function(t,e,n){w.has(t,n)?t[n].push(e):t[n]=[e]}),w.indexBy=A(function(t,e,n){t[n]=e}),w.countBy=A(function(t,e,n){w.has(t,n)?t[n]++:t[n]=1}),w.toArray=function(t){return t?w.isArray(t)?h.call(t):S(t)?w.map(t,w.identity):w.values(t):[]},w.size=function(t){return null==t?0:S(t)?t.length:w.keys(t).length},w.partition=function(t,e,n){e=x(e,n);var r=[],o=[];return w.each(t,function(t,n,i){(e(t,n,i)?r:o).push(t)}),[r,o]},w.first=w.head=w.take=function(t,e,n){return null==t?void 0:null==e||n?t[0]:w.initial(t,t.length-e)},w.initial=function(t,e,n){return h.call(t,0,Math.max(0,t.length-(null==e||n?1:e)))},w.last=function(t,e,n){return null==t?void 0:null==e||n?t[t.length-1]:w.rest(t,Math.max(0,t.length-e))},w.rest=w.tail=w.drop=function(t,e,n){return h.call(t,null==e||n?1:e)},w.compact=function(t){return w.filter(t,w.identity)};var V=function(t,e,n,r){for(var o=[],i=0,s=r||0,a=k(t);a>s;s++){var c=t[s];if(S(c)&&(w.isArray(c)||w.isArguments(c))){e||(c=V(c,e,n));var u=0,l=c.length;for(o.length+=l;l>u;)o[i++]=c[u++]}else n||(o[i++]=c)}return o};w.flatten=function(t,e){return V(t,e,!1)},w.without=function(t){return w.difference(t,h.call(arguments,1))},w.uniq=w.unique=function(t,e,n,r){w.isBoolean(e)||(r=n,n=e,e=!1),null!=n&&(n=x(n,r));for(var o=[],i=[],s=0,a=k(t);a>s;s++){var c=t[s],u=n?n(c,s,t):c;e?(s&&i===u||o.push(c),i=u):n?w.contains(i,u)||(i.push(u),o.push(c)):w.contains(o,c)||o.push(c)}return o},w.union=function(){return w.uniq(V(arguments,!0,!0))},w.intersection=function(t){for(var e=[],n=arguments.length,r=0,o=k(t);o>r;r++){var i=t[r];if(!w.contains(e,i)){for(var s=1;n>s&&w.contains(arguments[s],i);s++);s===n&&e.push(i)}}return e},w.difference=function(t){var e=V(arguments,!0,!0,1);return w.filter(t,function(t){return!w.contains(e,t)})},w.zip=function(){return w.unzip(arguments)},w.unzip=function(t){for(var e=t&&w.max(t,k).length||0,n=Array(e),r=0;e>r;r++)n[r]=w.pluck(t,r);return n},w.object=function(t,e){for(var n={},r=0,o=k(t);o>r;r++)e?n[t[r]]=e[r]:n[t[r][0]]=t[r][1];return n},w.findIndex=r(1),w.findLastIndex=r(-1),w.sortedIndex=function(t,e,n,r){n=x(n,r,1);for(var o=n(e),i=0,s=k(t);s>i;){var a=Math.floor((i+s)/2);n(t[a])i;i++,t+=n)o[i]=t;return o};var E=function(t,e,n,r,o){if(!(r instanceof e))return t.apply(n,o);var i=P(t.prototype),s=t.apply(i,o);return w.isObject(s)?s:i};w.bind=function(t,e){if(m&&t.bind===m)return m.apply(t,h.call(arguments,1));if(!w.isFunction(t))throw new TypeError("Bind must be called on a function");var n=h.call(arguments,2),r=function(){return E(t,r,e,this,n.concat(h.call(arguments)))};return r},w.partial=function(t){var e=h.call(arguments,1),n=function(){for(var r=0,o=e.length,i=Array(o),s=0;o>s;s++)i[s]=e[s]===w?arguments[r++]:e[s];for(;r=r)throw new Error("bindAll must be passed function names");for(e=1;r>e;e++)n=arguments[e],t[n]=w.bind(t[n],t);return t},w.memoize=function(t,e){var n=function(r){var o=n.cache,i=""+(e?e.apply(this,arguments):r);return w.has(o,i)||(o[i]=t.apply(this,arguments)),o[i]};return n.cache={},n},w.delay=function(t,e){var n=h.call(arguments,2);return setTimeout(function(){return t.apply(null,n)},e)},w.defer=w.partial(w.delay,w,1),w.throttle=function(t,e,n){var r,o,i,s=null,a=0;n||(n={});var c=function(){a=n.leading===!1?0:w.now(),s=null,i=t.apply(r,o),s||(r=o=null)};return function(){var u=w.now();a||n.leading!==!1||(a=u);var l=e-(u-a);return r=this,o=arguments,0>=l||l>e?(s&&(clearTimeout(s),s=null),a=u,i=t.apply(r,o),s||(r=o=null)):s||n.trailing===!1||(s=setTimeout(c,l)),i}},w.debounce=function(t,e,n){var r,o,i,s,a,c=function(){var u=w.now()-s;e>u&&u>=0?r=setTimeout(c,e-u):(r=null,n||(a=t.apply(i,o),r||(i=o=null)))};return function(){i=this,o=arguments,s=w.now();var u=n&&!r;return r||(r=setTimeout(c,e)),u&&(a=t.apply(i,o),i=o=null),a}},w.wrap=function(t,e){return w.partial(e,t)},w.negate=function(t){return function(){return!t.apply(this,arguments)}},w.compose=function(){var t=arguments,e=t.length-1;return function(){for(var n=e,r=t[e].apply(this,arguments);n--;)r=t[n].call(this,r);return r}},w.after=function(t,e){return function(){return--t<1?e.apply(this,arguments):void 0}},w.before=function(t,e){var n;return function(){return--t>0&&(n=e.apply(this,arguments)),1>=t&&(e=null),n}},w.once=w.partial(w.before,2);var j=!{toString:null}.propertyIsEnumerable("toString"),$=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"];w.keys=function(t){if(!w.isObject(t))return[];if(y)return y(t);var e=[];for(var n in t)w.has(t,n)&&e.push(n);return j&&i(t,e),e},w.allKeys=function(t){if(!w.isObject(t))return[];var e=[];for(var n in t)e.push(n);return j&&i(t,e),e},w.values=function(t){for(var e=w.keys(t),n=e.length,r=Array(n),o=0;n>o;o++)r[o]=t[e[o]];return r},w.mapObject=function(t,e,n){e=x(e,n);for(var r,o=w.keys(t),i=o.length,s={},a=0;i>a;a++)r=o[a],s[r]=e(t[r],r,t);return s},w.pairs=function(t){for(var e=w.keys(t),n=e.length,r=Array(n),o=0;n>o;o++)r[o]=[e[o],t[e[o]]];return r},w.invert=function(t){for(var e={},n=w.keys(t),r=0,o=n.length;o>r;r++)e[t[n[r]]]=n[r];return e},w.functions=w.methods=function(t){var e=[];for(var n in t)w.isFunction(t[n])&&e.push(n);return e.sort()},w.extend=C(w.allKeys),w.extendOwn=w.assign=C(w.keys),w.findKey=function(t,e,n){e=x(e,n);for(var r,o=w.keys(t),i=0,s=o.length;s>i;i++)if(r=o[i],e(t[r],r,t))return r},w.pick=function(t,e,n){var r,o,i={},s=t;if(null==s)return i;w.isFunction(e)?(o=w.allKeys(s),r=_(e,n)):(o=V(arguments,!1,!1,1),r=function(t,e,n){return e in n},s=Object(s));for(var a=0,c=o.length;c>a;a++){var u=o[a],l=s[u];r(l,u,s)&&(i[u]=l)}return i},w.omit=function(t,e,n){if(w.isFunction(e))e=w.negate(e);else{var r=w.map(V(arguments,!1,!1,1),String);e=function(t,e){return!w.contains(r,e)}}return w.pick(t,e,n)},w.defaults=C(w.allKeys,!0),w.create=function(t,e){var n=P(t);return e&&w.extendOwn(n,e),n},w.clone=function(t){return w.isObject(t)?w.isArray(t)?t.slice():w.extend({},t):t},w.tap=function(t,e){return e(t),t},w.isMatch=function(t,e){var n=w.keys(e),r=n.length;if(null==t)return!r;for(var o=Object(t),i=0;r>i;i++){var s=n[i];if(e[s]!==o[s]||!(s in o))return!1}return!0};var I=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 w&&(t=t._wrapped),e instanceof w&&(e=e._wrapped);var o=d.call(t);if(o!==d.call(e))return!1;switch(o){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 i="[object Array]"===o;if(!i){if("object"!=typeof t||"object"!=typeof e)return!1;var s=t.constructor,a=e.constructor;if(s!==a&&!(w.isFunction(s)&&s instanceof s&&w.isFunction(a)&&a instanceof a)&&"constructor"in t&&"constructor"in e)return!1}n=n||[],r=r||[];for(var c=n.length;c--;)if(n[c]===t)return r[c]===e;if(n.push(t),r.push(e),i){if(c=t.length,c!==e.length)return!1;for(;c--;)if(!I(t[c],e[c],n,r))return!1}else{var u,l=w.keys(t);if(c=l.length,w.keys(e).length!==c)return!1;for(;c--;)if(u=l[c],!w.has(e,u)||!I(t[u],e[u],n,r))return!1}return n.pop(),r.pop(),!0};w.isEqual=function(t,e){return I(t,e)},w.isEmpty=function(t){return null==t?!0:S(t)&&(w.isArray(t)||w.isString(t)||w.isArguments(t))?0===t.length:0===w.keys(t).length},w.isElement=function(t){return!(!t||1!==t.nodeType)},w.isArray=g||function(t){return"[object Array]"===d.call(t)},w.isObject=function(t){var e=typeof t;return"function"===e||"object"===e&&!!t},w.each(["Arguments","Function","String","Number","Date","RegExp","Error"],function(t){w["is"+t]=function(e){return d.call(e)==="[object "+t+"]"}}),w.isArguments(arguments)||(w.isArguments=function(t){return w.has(t,"callee")}),"function"!=typeof/./&&"object"!=typeof Int8Array&&(w.isFunction=function(t){return"function"==typeof t||!1}),w.isFinite=function(t){return isFinite(t)&&!isNaN(parseFloat(t))},w.isNaN=function(t){return w.isNumber(t)&&t!==+t},w.isBoolean=function(t){return t===!0||t===!1||"[object Boolean]"===d.call(t)},w.isNull=function(t){return null===t},w.isUndefined=function(t){return void 0===t},w.has=function(t,e){return null!=t&&f.call(t,e)},w.noConflict=function(){return s._=a,this},w.identity=function(t){return t},w.constant=function(t){return function(){return t}},w.noop=function(){},w.property=T,w.propertyOf=function(t){return null==t?function(){}:function(e){return t[e]}},w.matcher=w.matches=function(t){return t=w.extendOwn({},t),function(e){return w.isMatch(e,t)}},w.times=function(t,e,n){var r=Array(Math.max(0,t));e=_(e,n,1);for(var o=0;t>o;o++)r[o]=e(o);return r},w.random=function(t,e){return null==e&&(e=t,t=0),t+Math.floor(Math.random()*(e-t+1))},w.now=Date.now||function(){return(new Date).getTime()};var M={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},O=w.invert(M),R=function(t){var e=function(e){return t[e]},n="(?:"+w.keys(t).join("|")+")",r=RegExp(n),o=RegExp(n,"g");return function(t){return t=null==t?"":""+t,r.test(t)?t.replace(o,e):t}};w.escape=R(M),w.unescape=R(O),w.result=function(t,e,n){var r=null==t?void 0:t[e];return void 0===r&&(r=n),w.isFunction(r)?r.call(t):r};var L=0;w.uniqueId=function(t){var e=++L+"";return t?t+e:e},w.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var q=/(.)^/,D={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},F=/\\|'|\r|\n|\u2028|\u2029/g,H=function(t){return"\\"+D[t]};w.template=function(t,e,n){!e&&n&&(e=n),e=w.defaults({},e,w.templateSettings);var r=RegExp([(e.escape||q).source,(e.interpolate||q).source,(e.evaluate||q).source].join("|")+"|$","g"),o=0,i="__p+='";t.replace(r,function(e,n,r,s,a){return i+=t.slice(o,a).replace(F,H),o=a+e.length,n?i+="'+\n((__t=("+n+"))==null?'':_.escape(__t))+\n'":r?i+="'+\n((__t=("+r+"))==null?'':__t)+\n'":s&&(i+="';\n"+s+"\n__p+='"),e}),i+="';\n",e.variable||(i="with(obj||{}){\n"+i+"}\n"),i="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+i+"return __p;\n";try{var s=new Function(e.variable||"obj","_",i)}catch(a){throw a.source=i,a}var c=function(t){return s.call(this,t,w)},u=e.variable||"obj";return c.source="function("+u+"){\n"+i+"}",c},w.chain=function(t){var e=w(t);return e._chain=!0,e};var U=function(t,e){return t._chain?w(e).chain():e};w.mixin=function(t){w.each(w.functions(t),function(e){var n=w[e]=t[e];w.prototype[e]=function(){var t=[this._wrapped];return p.apply(t,arguments),U(this,n.apply(w,t))}})},w.mixin(w),w.each(["pop","push","reverse","shift","sort","splice","unshift"],function(t){var e=c[t];w.prototype[t]=function(){var n=this._wrapped;return e.apply(n,arguments),"shift"!==t&&"splice"!==t||0!==n.length||delete n[0],U(this,n)}}),w.each(["concat","join","slice"],function(t){var e=c[t];w.prototype[t]=function(){return U(this,e.apply(this._wrapped,arguments))}}),w.prototype.value=function(){return this._wrapped},w.prototype.valueOf=w.prototype.toJSON=w.prototype.value,w.prototype.toString=function(){return""+this._wrapped},"function"==typeof define&&define.amd&&define("underscore",[],function(){return w})}).call(this)},{}],125:[function(t,e,n){var r=t("./panels/container_panel"),o=new r({type:"resource",name:"figures",container:"figures",title:"Figures",icon:"fa-picture-o",references:["figure_reference"],zoom:!0}),i=new r({type:"resource",name:"citations",container:"citations",title:"References",icon:"fa-link",references:["citation_reference"]}),s=new r({type:"resource",name:"definitions",container:"definitions",title:"Glossary",icon:"fa-book",references:["definition_reference"]}),a=new r({type:"resource",name:"info",container:"info",title:"Info",icon:"fa-info",references:["contributor_reference"]});e.exports=[o,i,s,a]},{"./panels/container_panel":132}],126:[function(t,e,n){var r=t("./workflows/toggle_resource_reference"),o=t("./workflows/follow_crossrefs"),i=t("./workflows/jump_to_top"),s=[new r,new o,new i];e.exports=s},{"./workflows/follow_crossrefs":148,"./workflows/jump_to_top":149,"./workflows/toggle_resource_reference":150}],127:[function(t,e,n){e.exports=t("./lens")},{"./lens":128}],128:[function(t,e,n){"use strict";var r=t("../substance/application"),o=t("./lens_controller"),i=t("lens/converter"),s=t("lens/article"),a=t("./panels/resource_panel_viewfactory"),c=t("./reader_controller"),u=t("./reader_view"),l=t("./panels/panel"),p=t("./panels/panel_controller"),h=t("./panels/panel_view"),d=t("./panels/container_panel"),f=t("./panels/container_panel_controller"),g=t("./panels/container_panel_view"),y=t("./workflows/workflow"),m=t("./default_panels"),v=t("./default_workflows"),b=function(t){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),r.call(this,t),this.controller=t.controller||this.createController(t)};b.Prototype=function(){this.start=function(){r.prototype.start.call(this)},this.render=function(){this.view=this.controller.createView(),this.$el.html(this.view.render().el)},this.getRoutes=function(){return b.getDefaultRoutes()},this.getPanels=function(){return b.getDefaultPanels()},this.getWorkflows=function(){return b.getDefaultWorkflows()},this.getConverters=function(t){return[b.getDefaultConverter(t)]},this.createController=function(t){return new o(t)}},b.Prototype.prototype=r.prototype,b.prototype=new b.Prototype,b.prototype.constructor=b,b.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"}],b.getDefaultRoutes=function(){return b.DEFAULT_ROUTES},b.getDefaultPanels=function(){return m.slice(0)},b.getDefaultWorkflows=function(){return v.slice(0)},b.getDefaultConverter=function(t){return new i(t)},b.Article=s,b.ReaderController=c,b.ReaderView=u,b.Controller=o,b.LensController=o,b.Panel=l,b.PanelController=p,b.PanelView=h,b.ContainerPanel=d,b.ContainerPanelController=f,b.ContainerPanelView=g,b.ResourcePanelViewFactory=a,b.Workflow=y,e.exports=b},{"../substance/application":154,"./default_panels":125,"./default_workflows":126,"./lens_controller":129,"./panels/container_panel":132,"./panels/container_panel_controller":133,"./panels/container_panel_view":134,"./panels/panel":141,"./panels/panel_controller":142,"./panels/panel_view":143,"./panels/resource_panel_viewfactory":144,"./reader_controller":146,"./reader_view":147,"./workflows/workflow":151,"lens/article":6,"lens/converter":122}],129:[function(t,e,n){"use strict";var r=t("underscore"),o=t("../substance/util"),i=t("../substance/application").Controller,s=t("./lens_view"),a=t("./reader_controller"),c=t("lens/article"),u=t("lens/converter"),l=function(t){i.call(this),this.config=t,this.Article=t.articleClass||c,this.converter=t.converter,this.converters=t.converters,this.converterOptions=r.extend({},u.DefaultOptions,t.converterOptions),this.on("open:reader",this.openReader)};l.Prototype=function(){this.createView=function(){var t=new s(this);return this.view=t,t},this.importXML=function(t){var e=new DOMParser,n=e.parseFromString(t,"text/xml"),r=this.convertDocument(n);this.createReader(r,{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 a(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").addClass("nodes"),this.$el.append(this.$nodes)};s.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 t=document.createDocumentFragment();r.each(this.nodes,function(t){t.dispose()}),this.nodes={};var e=this.docCtrl.container.getTopLevelNodes();return r.each(e,function(e){var n=this.renderNodeView(e);this.nodes[e.id]=n,t.appendChild(n.el)},this),t},this.renderNodeView=function(t){var e=this.viewFactory.createView(t,{topLevel:!0});return e.render(),e}},s.Prototype.prototype=i.prototype,s.prototype=new s.Prototype,s.prototype.constructor=s,e.exports=s},{"../substance/application":154,underscore:124}],131:[function(t,e,n){"use strict";var r=t("underscore"),o=t("../substance/application").View,i=t("../substance/application").$$,s=function(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))};s.Prototype=function(){this.handleDroppedFile=function(){var t=this.controller,e=event.dataTransfer.files,n=e[0],r=new FileReader;return r.onload=function(e){t.importXML(e.target.result)},r.readAsText(n),!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 article"),$(".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}),r.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(i(".browser-not-supported",{text:"Sorry, your browser is not supported.",style:"display: none;"})),this.el.appendChild(i(".spinner-wrapper",{children:[i(".spinner"),i(".message",{html:"Loading article"})]})),this.el.appendChild(i("#main")),this},this.dispose=function(){this.stopListening(),this.mainView&&this.mainView.dispose()}},s.Prototype.prototype=o.prototype,s.prototype=new s.Prototype,e.exports=s},{"../substance/application":154,underscore:124}],132:[function(t,e,n){"use strict";var r=t("./panel"),o=t("./container_panel_controller"),i=function(t){r.call(this,t)};i.Prototype=function(){this.createController=function(t){return new o(t,this.config)}},i.Prototype.prototype=r.prototype,i.prototype=new i.Prototype,e.exports=i},{"./container_panel_controller":133,"./panel":141}],133:[function(t,e,n){"use strict";var r=t("../../substance/document"),o=t("./panel_controller"),i=t("./resource_panel_viewfactory"),s=t("./container_panel_view"),a=function(t,e){o.call(this,t,e),this.docCtrl=new r.Controller(t,{view:e.container})};a.Prototype=function(){this.createView=function(){var t,e=this.getDocument();if("resource"===this.config.type)t=this.config.createViewFactory?this.config.createViewFactory(e,this.config):new i(e.nodeTypes,this.config);else{var n=e.constructor.ViewFactory;t=new n(e.nodeTypes,this.config)}return this.viewFactory=t,new s(this,t,this.config)},this.getContainer=function(){return this.docCtrl.getContainer()}},a.Prototype.prototype=o.prototype,a.prototype=new a.Prototype,e.exports=a},{"../../substance/document":167,"./container_panel_view":134,"./panel_controller":142,"./resource_panel_viewfactory":144}],134:[function(t,e,n){"use strict";var r=t("underscore"),o=t("./surface_scrollbar"),i=t("../lens_surface"),s=t("./panel_view"),a=40,c=function(t,e,n){s.call(this,t,n),this.surface=new i(t.docCtrl,{editable:!1,viewFactory:e}),this.docCtrl=t.docCtrl,this.scrollbar=new o(this.surface),this._onScroll=r.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};c.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,r=$(e),o=($(window).height(),this.surface.$el.height());n=this.surface.$el.scrollTop();var i,s=r.offset().top,c=r.height();if(s>0&&o>s+c||s>=0&&o>s)return;i=n+s-a,this.surface.$el.scrollTop(i),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){s.prototype.addHighlight.call(this,t,e);var n=this.getDocument().get(t);n&&this.scrollbar.addHighlight(t,e+" "+n.type)},this.removeHighlights=function(){s.prototype.removeHighlights.call(this),this.scrollbar.removeHighlights(),this.scrollbar.update()},this.update=function(){this.scrollbar.update()},this.hide=function(){this.hidden||s.prototype.hide.call(this)},this.show=function(){this.scrollbar.update(),s.prototype.show.call(this)}},c.Prototype.prototype=s.prototype,c.prototype=new c.Prototype,c.prototype.constructor=c,e.exports=c},{"../lens_surface":130,"./panel_view":143,"./surface_scrollbar":145,underscore:124}],135:[function(t,e,n){"use strict";var r=t("../container_panel"),o=t("./content_panel_controller"),i=function(){r.call(this,{name:"content",type:"document",container:"content",label:"Contents",title:"Contents",icon:"fa-align-left"})};i.Prototype=function(){this.createController=function(t){return new o(t,this.config)}},i.Prototype.prototype=r.prototype,i.prototype=new i.Prototype,e.exports=i},{"../container_panel":132,"./content_panel_controller":136}],136:[function(t,e,n){"use strict";var r=t("../container_panel_controller"),o=t("./content_panel_view"),i=function(t,e){r.call(this,t,e)};i.Prototype=function(){this.createView=function(){if(!this.view){var t=this.getDocument(),e=t.constructor.ViewFactory,n=new e(t.nodeTypes,this.config);this.view=new o(this,n,this.config)}return this.view}},i.Prototype.prototype=r.prototype,i.prototype=new i.Prototype,e.exports=i},{"../container_panel_controller":133,"./content_panel_view":137}],137:[function(t,e,n){"use strict";var r=t("underscore"),o=t("../container_panel_view"),i=t("./toc_panel_view"),s=0,a=1,c=function(t,e,n){o.call(this,t,e,n),this.tocView=new i(t,e,r.extend({},n,{type:"resource",name:"toc"})),this.tocNodeElements={},this._onTocItemSelected=r.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")};c.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);if(e){var n=$(e).position().top+s;this.surface.$el.scrollTop(n)}},this.markActiveHeading=function(t){var e=$(".nodes").height(),n=this.getDocument().getTocNodes(),o=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;o(n[0].id);if(i=n[0].id,t+this.$el.height()>=e)i=r.last(n).id;else for(var s=n.length-1;s>=1;s--){var c=n[s],u=o(c.id);if(u){var l=$(u).offset().top-a;if(0>=l){i=u.dataset.id;break}}else console.error("Could not find element for node %s",c.id)}this.tocView.setActiveNode(i)}},this.markReferencesTo=function(t){var e=this.resources.get(t);r.each(e,function(t){$(this.findNodeView(t.id)).addClass("active")},this)},this.removeHighlights=function(){o.prototype.removeHighlights.call(this),this.$el.find(".content-node.active").removeClass("active"),this.$el.find(".annotation.active").removeClass("active")}},c.Prototype.prototype=o.prototype,c.prototype=new c.Prototype,c.prototype.constructor=c,e.exports=c},{"../container_panel_view":134,"./toc_panel_view":139,underscore:124}],138:[function(t,e,n){e.exports=t("./content_panel")},{"./content_panel":135}],139:[function(t,e,n){"use strict";var r=t("./toc_view"),o=t("../panel_view"),i=function(t,e,n){o.call(this,t,n),this.toc=new r(t.getDocument(),e)};i.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()}},i.Prototype.prototype=o.prototype,i.prototype=new i.Prototype,i.prototype.constructor=i,e.exports=i},{"../panel_view":143,"./toc_view":140}],140:[function(t,e,n){"use strict";var r=t("../../../substance/application").View,o=(t("../../../substance/application").$$,t("../../../substance/data")),i=(o.Graph.Index,t("underscore")),s=function(t,e){r.call(this),this.doc=t,this.viewFactory=e,this.$el.addClass("toc")};s.Prototype=function(){this.render=function(){var t=-1,e=this.doc.getTocNodes();return e.length<2?this:(i.each(e,function(e){var n=this.viewFactory.createView(e),r=e.getLevel();-1===r?r=t+1:t=r;var o=n.renderTocItem(),s=$(o);o.id="toc_"+e.id,s.addClass("heading-ref"),s.addClass("level-"+r),s.click(i.bind(this.onClick,this,e.id)),this.el.appendChild(o)},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)}},s.Prototype.prototype=r.prototype,s.prototype=new s.Prototype,e.exports=s},{"../../../substance/application":154,"../../../substance/data":160,underscore:124}],141:[function(t,e,n){"use strict";var r=function(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,r.prototype.constructor=r,e.exports=r},{}],142:[function(t,e,n){"use strict";var r=t("../../substance/application").Controller,o=(t("underscore"),t("../../substance/util"),function(t,e){this.document=t,this.config=e});o.Prototype=function(){r.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}},o.Prototype.prototype=r.prototype,o.prototype=new o.Prototype,e.exports=o},{"../../substance/application":154,"../../substance/util":175,underscore:124}],143:[function(t,e,n){var r=t("underscore"),o=t("../../substance/application"),i=o.$$,s=o.View,a=function(t,e){s.call(this),this.controller=t,this.config=e,this.doc=t.getDocument(),this.name=e.name,this.toggleEl=i("a.context-toggle."+this.name,{href:"#",title:this.config.title,html:' '+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=r.bind(this.onToggle,this),this._onToggleResource=r.bind(this.onToggleResource,this),this._onToggleResourceReference=r.bind(this.onToggleResourceReference,this),this._onToggleFullscreen=r.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=[]};a.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").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,o=(n.offset().top-this.surfaceTop)/this.factor;re?$(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=n);this.root=("/"+this.root+"/").replace(h,"/"),r&&this._wantsHashChange&&(this.iframe=$('