bible-passage-reference-parser
Version:
Identifies and parses Bible references (like John 3:16) in over 40 languages.
97 lines • 133 kB
JavaScript
(function(){var n,B={}.hasOwnProperty;this.bcv_parser=n=function(){function k(){var a;this.options={};var d=k.prototype.options;for(a in d)if(B.call(d,a)){var c=d[a];this.options[a]=c}this.versification_system(this.options.versification_system)}k.prototype.s="";k.prototype.entities=[];k.prototype.passage=null;k.prototype.regexps={};k.prototype.options={consecutive_combination_strategy:"combine",osis_compaction_strategy:"b",book_sequence_strategy:"ignore",invalid_sequence_strategy:"ignore",sequence_combination_strategy:"combine",
punctuation_strategy:"us",invalid_passage_strategy:"ignore",non_latin_digits_strategy:"ignore",passage_existence_strategy:"bcv",zero_chapter_strategy:"error",zero_verse_strategy:"error",single_chapter_1_strategy:"chapter",book_alone_strategy:"ignore",book_range_strategy:"ignore",captive_end_digits_strategy:"delete",end_range_digits_strategy:"verse",include_apocrypha:!1,ps151_strategy:"c",versification_system:"default",case_sensitive:"none"};k.prototype.parse=function(a){this.reset();this.s=a;a=this.replace_control_characters(a);
var d=this.match_books(a);a=d[0];this.passage.books=d[1];this.entities=this.match_passages(a)[0];return this};k.prototype.parse_with_context=function(a,d){this.reset();var c=this.match_books(this.replace_control_characters(d));d=c[0];this.passage.books=c[1];d=this.match_passages(d)[1];this.reset();this.s=a;a=this.replace_control_characters(a);c=this.match_books(a);a=c[0];this.passage.books=c[1];this.passage.books.push({value:"",parsed:[],start_index:0,type:"context",context:d});a="\u001f"+(this.passage.books.length-
1)+"/9\u001f"+a;this.entities=this.match_passages(a)[0];return this};k.prototype.reset=function(){this.s="";this.entities=[];if(this.passage)return this.passage.books=[],this.passage.indices={};this.passage=new Ga;this.passage.options=this.options;return this.passage.translations=this.translations};k.prototype.set_options=function(a){var d;for(d in a)if(B.call(a,d)){var c=a[d];if("include_apocrypha"===d||"versification_system"===d||"case_sensitive"===d)this[d](c);else this.options[d]=c}return this};
k.prototype.include_apocrypha=function(a){var d,c,f;if(null==a||!0!==a&&!1!==a)return this;this.options.include_apocrypha=a;this.regexps.books=this.regexps.get_books(a,this.options.case_sensitive);var g=this.translations;for(f in g)B.call(g,f)&&"aliases"!==f&&"alternates"!==f&&(null==(d=this.translations[f]).chapters&&(d.chapters={}),null==(c=this.translations[f].chapters).Ps&&(c.Ps=y.shallow_clone_array(this.translations["default"].chapters.Ps)),!0===a?(d=null!=this.translations[f].chapters.Ps151?
this.translations[f].chapters.Ps151[0]:this.translations["default"].chapters.Ps151[0],this.translations[f].chapters.Ps[150]=d):151===this.translations[f].chapters.Ps.length&&this.translations[f].chapters.Ps.pop());return this};k.prototype.versification_system=function(a){var d,c,f;if(null==a||null==this.translations[a])return this;if(null!=this.translations.alternates["default"])if("default"===a){null!=this.translations.alternates["default"].order&&(this.translations["default"].order=y.shallow_clone(this.translations.alternates["default"].order));
var g=this.translations.alternates["default"].chapters;for(f in g)if(B.call(g,f)){var l=g[f];this.translations["default"].chapters[f]=y.shallow_clone_array(l)}}else this.versification_system("default");null==(d=this.translations.alternates)["default"]&&(d["default"]={order:null,chapters:{}});"default"!==a&&null!=this.translations[a].order&&(null==(l=this.translations.alternates["default"]).order&&(l.order=y.shallow_clone(this.translations["default"].order)),this.translations["default"].order=y.shallow_clone(this.translations[a].order));
if("default"!==a&&null!=this.translations[a].chapters)for(f in d=this.translations[a].chapters,d)B.call(d,f)&&(l=d[f],null==(c=this.translations.alternates["default"].chapters)[f]&&(c[f]=y.shallow_clone_array(this.translations["default"].chapters[f])),this.translations["default"].chapters[f]=y.shallow_clone_array(l));this.options.versification_system=a;this.include_apocrypha(this.options.include_apocrypha);return this};k.prototype.case_sensitive=function(a){if(null==a||"none"!==a&&"books"!==a||a===
this.options.case_sensitive)return this;this.options.case_sensitive=a;this.regexps.books=this.regexps.get_books(this.options.include_apocrypha,a);return this};k.prototype.translation_info=function(a){var d,c;null==a&&(a="default");null!=a&&null!=(null!=(c=this.translations.aliases[a])?c.alias:void 0)&&(a=this.translations.aliases[a].alias);if(null==a||null==this.translations[a])a="default";c=this.options.versification_system;a!==c&&this.versification_system(a);var f={alias:a,books:[],chapters:{},
order:y.shallow_clone(this.translations["default"].order)};var g=this.translations["default"].chapters;for(d in g)if(B.call(g,d)){var l=g[d];f.chapters[d]=y.shallow_clone_array(l)}g=f.order;for(d in g)B.call(g,d)&&(l=g[d],f.books[l-1]=d);a!==c&&this.versification_system(c);return f};k.prototype.replace_control_characters=function(a){a=a.replace(this.regexps.control," ");"replace"===this.options.non_latin_digits_strategy&&(a=a.replace(/[\u0660\u06f0\u07c0\u0966\u09e6\u0a66\u0ae6\u0b660\u0c66\u0ce6\u0d66\u0e50\u0ed0\u0f20\u1040\u1090\u17e0\u1810\u1946\u19d0\u1a80\u1a90\u1b50\u1bb0\u1c40\u1c50\ua620\ua8d0\ua900\ua9d0\uaa50\uabf0\uff10]/g,
"0"),a=a.replace(/[\u0661\u06f1\u07c1\u0967\u09e7\u0a67\u0ae7\u0b67\u0be7\u0c67\u0ce7\u0d67\u0e51\u0ed1\u0f21\u1041\u1091\u17e1\u1811\u1947\u19d1\u1a81\u1a91\u1b51\u1bb1\u1c41\u1c51\ua621\ua8d1\ua901\ua9d1\uaa51\uabf1\uff11]/g,"1"),a=a.replace(/[\u0662\u06f2\u07c2\u0968\u09e8\u0a68\u0ae8\u0b68\u0be8\u0c68\u0ce8\u0d68\u0e52\u0ed2\u0f22\u1042\u1092\u17e2\u1812\u1948\u19d2\u1a82\u1a92\u1b52\u1bb2\u1c42\u1c52\ua622\ua8d2\ua902\ua9d2\uaa52\uabf2\uff12]/g,"2"),a=a.replace(/[\u0663\u06f3\u07c3\u0969\u09e9\u0a69\u0ae9\u0b69\u0be9\u0c69\u0ce9\u0d69\u0e53\u0ed3\u0f23\u1043\u1093\u17e3\u1813\u1949\u19d3\u1a83\u1a93\u1b53\u1bb3\u1c43\u1c53\ua623\ua8d3\ua903\ua9d3\uaa53\uabf3\uff13]/g,
"3"),a=a.replace(/[\u0664\u06f4\u07c4\u096a\u09ea\u0a6a\u0aea\u0b6a\u0bea\u0c6a\u0cea\u0d6a\u0e54\u0ed4\u0f24\u1044\u1094\u17e4\u1814\u194a\u19d4\u1a84\u1a94\u1b54\u1bb4\u1c44\u1c54\ua624\ua8d4\ua904\ua9d4\uaa54\uabf4\uff14]/g,"4"),a=a.replace(/[\u0665\u06f5\u07c5\u096b\u09eb\u0a6b\u0aeb\u0b6b\u0beb\u0c6b\u0ceb\u0d6b\u0e55\u0ed5\u0f25\u1045\u1095\u17e5\u1815\u194b\u19d5\u1a85\u1a95\u1b55\u1bb5\u1c45\u1c55\ua625\ua8d5\ua905\ua9d5\uaa55\uabf5\uff15]/g,"5"),a=a.replace(/[\u0666\u06f6\u07c6\u096c\u09ec\u0a6c\u0aec\u0b6c\u0bec\u0c6c\u0cec\u0d6c\u0e56\u0ed6\u0f26\u1046\u1096\u17e6\u1816\u194c\u19d6\u1a86\u1a96\u1b56\u1bb6\u1c46\u1c56\ua626\ua8d6\ua906\ua9d6\uaa56\uabf6\uff16]/g,
"6"),a=a.replace(/[\u0667\u06f7\u07c7\u096d\u09ed\u0a6d\u0aed\u0b6d\u0bed\u0c6d\u0ced\u0d6d\u0e57\u0ed7\u0f27\u1047\u1097\u17e7\u1817\u194d\u19d7\u1a87\u1a97\u1b57\u1bb7\u1c47\u1c57\ua627\ua8d7\ua907\ua9d7\uaa57\uabf7\uff17]/g,"7"),a=a.replace(/[\u0668\u06f8\u07c8\u096e\u09ee\u0a6e\u0aee\u0b6e\u0bee\u0c6e\u0cee\u0d6e\u0e58\u0ed8\u0f28\u1048\u1098\u17e8\u1818\u194e\u19d8\u1a88\u1a98\u1b58\u1bb8\u1c48\u1c58\ua628\ua8d8\ua908\ua9d8\uaa58\uabf8\uff18]/g,"8"),a=a.replace(/[\u0669\u06f9\u07c9\u096f\u09ef\u0a6f\u0aef\u0b6f\u0bef\u0c6f\u0cef\u0d6f\u0e59\u0ed9\u0f29\u1049\u1099\u17e9\u1819\u194f\u19d9\u1a89\u1a99\u1b59\u1bb9\u1c49\u1c59\ua629\ua8d9\ua909\ua9d9\uaa59\uabf9\uff19]/g,
"9"));return a};k.prototype.match_books=function(a){var d;var c=[];var f=this.regexps.books;var g=0;for(d=f.length;g<d;g++){var l=f[g];var k=!1;a=a.replace(l.regexp,function(a,d,f){k=!0;c.push({value:f,parsed:l.osis,type:"book"});return d+"\u001f"+(c.length-1)+(null!=l.extra?"/"+l.extra:"")+"\u001f"});if(!0===k&&/^[\s\x1f\d:.,;\-\u2013\u2014]+$/.test(a))break}a=a.replace(this.regexps.translations,function(a){c.push({value:a,parsed:a.toLowerCase(),type:"translation"});return"\u001e"+(c.length-1)+"\u001e"});
return[a,this.get_book_indices(c,a)]};k.prototype.get_book_indices=function(a,d){var c,f;var g=0;for(f=/([\x1f\x1e])(\d+)(?:\/\d+)?\1/g;c=f.exec(d);)a[c[2]].start_index=c.index+g,g+=a[c[2]].value.length-c[0].length;return a};k.prototype.match_passages=function(a){var d,c;var f=[];for(c={};d=this.regexps.escaped_passage.exec(a);){var g=d[0];var l=d[1];c=d[2];var k=l.length;d.index+=g.length-k;/\s[2-9]\d\d\s*$|\s\d{4,}\s*$/.test(l)&&(l=l.replace(/\s+\d+\s*$/,""));/[\d\x1f\x1e)]$/.test(l)||(l=this.replace_match_end(l));
"delete"===this.options.captive_end_digits_strategy&&(d=d.index+l.length,a.length>d&&/^\w/.test(a.substr(d,1))&&(l=l.replace(/[\s*]+\d+$/,"")),l=l.replace(/(\x1e[)\]]?)[\s*]*\d+$/,"$1"));l=l.replace(/[A-Z]+/g,function(a){return a.toLowerCase()});g="\u001f"===l.substr(0,1)?0:l.split("\u001f")[0].length;d={value:oa.parse(l,{punctuation_strategy:this.options.punctuation_strategy}),type:"base",start_index:this.passage.books[c].start_index-g,match:l};"full"===this.options.book_alone_strategy&&"include"===
this.options.book_range_strategy&&"b"===d.value[0].type&&(1===d.value.length||1<d.value.length&&"translation_sequence"===d.value[1].type)&&0===g&&(1===this.passage.books[c].parsed.length||1<this.passage.books[c].parsed.length&&"translation"===this.passage.books[c].parsed[1].type)&&/^[234]/.test(this.passage.books[c].parsed[0])&&this.create_book_range(a,d,c);c=this.passage.handle_obj(d);d=c[0];c=c[1];f=f.concat(d);k=this.adjust_regexp_end(d,k,l.length);0<k&&(this.regexps.escaped_passage.lastIndex-=
k)}return[f,c]};k.prototype.adjust_regexp_end=function(a,d,c){var f=0;0<a.length?f=d-a[a.length-1].indices[1]-1:d!==c&&(f=d-c);return f};k.prototype.replace_match_end=function(a){var d,c;for(c=a.length;d=this.regexps.match_end_split.exec(a);)c=d.index+d[0].length;c<a.length&&(a=a.substr(0,c));return a};k.prototype.create_book_range=function(a,d,c){var f,g;var l=[k.prototype.regexps.first,k.prototype.regexps.second,k.prototype.regexps.third];var fa=parseInt(this.passage.books[c].parsed[0].substr(0,
1),10);for(f=g=1;1<=fa?g<fa:g>fa;f=1<=fa?++g:--g){var m=f===fa-1?k.prototype.regexps.range_and:k.prototype.regexps.range_only;m=a.match(RegExp("(?:^|\\W)("+l[f-1]+"\\s*"+m+"\\s*)\\x1f"+c+"\\x1f","i"));if(null!=m)return this.add_book_range_object(d,m,f)}return!1};k.prototype.add_book_range_object=function(a,d,c){var f,g;var l=d[1].length;a.value[0]={type:"b_range_pre",value:[{type:"b_pre",value:c.toString(),indices:[d.index,d.index+l]},a.value[0]],indices:[0,a.value[0].indices[1]+l]};a.value[0].value[1].indices[0]+=
l;a.value[0].value[1].indices[1]+=l;a.start_index-=l;a.match=d[1]+a.match;if(1!==a.value.length){var k=[];d=c=1;for(f=a.value.length;1<=f?c<f:c>f;d=1<=f?++c:--c)null!=a.value[d].value&&(null!=(null!=(g=a.value[d].value[0])?g.indices:void 0)&&(a.value[d].value[0].indices[0]+=l,a.value[d].value[0].indices[1]+=l),a.value[d].indices[0]+=l,k.push(a.value[d].indices[1]+=l));return k}};k.prototype.osis=function(){var a;var d=[];var c=this.parsed_entities();var f=0;for(a=c.length;f<a;f++){var g=c[f];0<g.osis.length&&
d.push(g.osis)}return d.join(",")};k.prototype.osis_and_translations=function(){var a;var d=[];var c=this.parsed_entities();var f=0;for(a=c.length;f<a;f++){var g=c[f];0<g.osis.length&&d.push([g.osis,g.translations.join(",")])}return d};k.prototype.osis_and_indices=function(){var a;var d=[];var c=this.parsed_entities();var f=0;for(a=c.length;f<a;f++){var g=c[f];0<g.osis.length&&d.push({osis:g.osis,translations:g.translations,indices:g.indices})}return d};k.prototype.parsed_entities=function(){var a,
d,c,f,g;var l=[];var k=d=0;for(c=this.entities.length;0<=c?d<c:d>c;k=0<=c?++d:--d){var m=this.entities[k];m.type&&"translation_sequence"===m.type&&0<l.length&&k===l[l.length-1].entity_id+1&&(l[l.length-1].indices[1]=m.absolute_indices[1]);if(null!=m.passages&&!("b"===m.type&&"ignore"===this.options.book_alone_strategy||"b_range"===m.type&&"ignore"===this.options.book_range_strategy||"context"===m.type)){var n=[];var v=null;if(null!=m.passages[0].translations){var t=m.passages[0].translations;var u=
0;for(a=t.length;u<a;u++){var z=t[u];var x=0<(null!=(f=z.osis)?f.length:void 0)?z.osis:"";null==v&&(v=z.alias);n.push(x)}}else n=[""],v="default";u=[];t=m.passages.length;a=z=0;for(g=t;0<=g?z<g:z>g;a=0<=g?++z:--z){x=m.passages[a];null==x.type&&(x.type=m.type);if(!1===x.valid.valid&&("ignore"===this.options.invalid_sequence_strategy&&"sequence"===m.type&&this.snap_sequence("ignore",m,u,a,t),"ignore"===this.options.invalid_passage_strategy))continue;"b"!==x.type&&"b_range"!==x.type||"ignore"!==this.options.book_sequence_strategy||
"sequence"!==m.type?("b_range_start"!==x.type&&"range_end_b"!==x.type||"ignore"!==this.options.book_range_strategy||this.snap_range(m,a),null==x.absolute_indices&&(x.absolute_indices=m.absolute_indices),u.push({osis:x.valid.valid?this.to_osis(x.start,x.end,v):"",type:x.type,indices:x.absolute_indices,translations:n,start:x.start,end:x.end,enclosed_indices:x.enclosed_absolute_indices,entity_id:k,entities:[x]})):this.snap_sequence("book",m,u,a,t)}if(0!==u.length)if(1<u.length&&"combine"===this.options.consecutive_combination_strategy&&
(u=this.combine_consecutive_passages(u,v)),"separate"===this.options.sequence_combination_strategy)l=l.concat(u);else{v=[];a=u.length-1;null!=u[a].enclosed_indices&&0<=u[a].enclosed_indices[1]&&(m.absolute_indices[1]=u[a].enclosed_indices[1]);t=0;for(a=u.length;t<a;t++)z=u[t],0<z.osis.length&&v.push(z.osis);l.push({osis:v.join(","),indices:m.absolute_indices,translations:n,entity_id:k,entities:u})}}}return l};k.prototype.to_osis=function(a,d,c){null==d.c&&null==d.v&&a.b===d.b&&null==a.c&&null==a.v&&
"first_chapter"===this.options.book_alone_strategy&&(d.c=1);null==a.c&&(a.c=1);null==a.v&&(a.v=1);null==d.c&&(0<=this.options.passage_existence_strategy.indexOf("c")||null!=this.passage.translations[c].chapters[d.b]&&1===this.passage.translations[c].chapters[d.b].length?d.c=this.passage.translations[c].chapters[d.b].length:d.c=999);null==d.v&&(null!=this.passage.translations[c].chapters[d.b][d.c-1]&&0<=this.options.passage_existence_strategy.indexOf("v")?d.v=this.passage.translations[c].chapters[d.b][d.c-
1]:d.v=999);this.options.include_apocrypha&&"b"===this.options.ps151_strategy&&(151===a.c&&"Ps"===a.b||151===d.c&&"Ps"===d.b)&&this.fix_ps151(a,d,c);if("b"===this.options.osis_compaction_strategy&&1===a.c&&1===a.v&&(999===d.c&&999===d.v||d.c===this.passage.translations[c].chapters[d.b].length&&0<=this.options.passage_existence_strategy.indexOf("c")&&(999===d.v||d.v===this.passage.translations[c].chapters[d.b][d.c-1]&&0<=this.options.passage_existence_strategy.indexOf("v")))){c=a.b;var f=d.b}else 2>=
this.options.osis_compaction_strategy.length&&1===a.v&&(999===d.v||d.v===this.passage.translations[c].chapters[d.b][d.c-1]&&0<=this.options.passage_existence_strategy.indexOf("v"))?(c=a.b+"."+a.c.toString(),f=d.b+"."+d.c.toString()):(c=a.b+"."+a.c.toString()+"."+a.v.toString(),f=d.b+"."+d.c.toString()+"."+d.v.toString());c=c===f?c:c+"-"+f;null!=a.extra&&(c=a.extra+","+c);null!=d.extra&&(c+=","+d.extra);return c};k.prototype.fix_ps151=function(a,d,c){var f;"default"!==c&&null==(null!=(f=this.translations[c])?
f.chapters.Ps151:void 0)&&this.passage.promote_book_to_translation("Ps151",c);if(151===a.c&&"Ps"===a.b){if(151===d.c&&"Ps"===d.b)return a.b="Ps151",a.c=1,d.b="Ps151",d.c=1;a.extra=this.to_osis({b:"Ps151",c:1,v:a.v},{b:"Ps151",c:1,v:this.passage.translations[c].chapters.Ps151[0]},c);a.b="Prov";a.c=1;return a.v=1}d.extra=this.to_osis({b:"Ps151",c:1,v:1},{b:"Ps151",c:1,v:d.v},c);d.c=150;return d.v=this.passage.translations[c].chapters.Ps[149]};k.prototype.combine_consecutive_passages=function(a,d){var c,
f;var g=[];var l={};var k=a.length-1;var m=-1;var n=!1;for(c=f=0;0<=k?f<=k:f>=k;c=0<=k?++f:--f){var v=a[c];if(0<v.osis.length){var t=g.length-1;var u=!1;v.enclosed_indices[0]!==m&&(m=v.enclosed_indices[0]);0<=m&&(c===k||a[c+1].enclosed_indices[0]!==v.enclosed_indices[0])&&(n=u=!0);this.is_verse_consecutive(l,v.start,d)?(g[t].end=v.end,g[t].is_enclosed_last=u,g[t].indices[1]=v.indices[1],g[t].enclosed_indices[1]=v.enclosed_indices[1],g[t].osis=this.to_osis(g[t].start,v.end,d)):g.push(v);l={b:v.end.b,
c:v.end.c,v:v.end.v}}else g.push(v),l={}}n&&this.snap_enclosed_indices(g);return g};k.prototype.snap_enclosed_indices=function(a){var d;var c=0;for(d=a.length;c<d;c++){var f=a[c];null!=f.is_enclosed_last&&(0>f.enclosed_indices[0]&&f.is_enclosed_last&&(f.indices[1]=f.enclosed_indices[1]),delete f.is_enclosed_last)}return a};k.prototype.is_verse_consecutive=function(a,d,c){if(null==a.b)return!1;var f=null!=this.passage.translations[c].order?this.passage.translations[c].order:this.passage.translations["default"].order;
if(a.b===d.b)if(a.c===d.c){if(a.v===d.v-1)return!0}else{if(1===d.v&&a.c===d.c-1&&a.v===this.passage.translations[c].chapters[a.b][a.c-1])return!0}else if(1===d.c&&1===d.v&&f[a.b]===f[d.b]-1&&a.c===this.passage.translations[c].chapters[a.b].length&&a.v===this.passage.translations[c].chapters[a.b][a.c-1])return!0;return!1};k.prototype.snap_range=function(a,d){var c;if("b_range_start"===a.type||"sequence"===a.type&&"b_range_start"===a.passages[d].type){var f=1;var g="end";var l="b_range_start"}else f=
0,g="start",l="range_end_b";var k="end"===g?"start":"end";var m=a.passages[d][k];for(c in m)B.call(m,c)&&(a.passages[d][k][c]=a.passages[d][g][c]);"sequence"===a.type?(d>=a.value.length&&(d=a.value.length-1),f=this.passage.pluck(l,a.value[d]),null!=f&&(f=this.snap_range(f,0),0===d?a.absolute_indices[0]=f.absolute_indices[0]:a.absolute_indices[1]=f.absolute_indices[1])):(a.original_type=a.type,a.type=a.value[f].type,a.absolute_indices=[a.value[f].absolute_indices[0],a.value[f].absolute_indices[1]]);
return a};k.prototype.snap_sequence=function(a,d,c,f,g){var l=d.passages[f];l.absolute_indices[0]===d.absolute_indices[0]&&f<g-1&&this.get_snap_sequence_i(d.passages,f,g)!==f?(d.absolute_indices[0]=d.passages[f+1].absolute_indices[0],this.remove_absolute_indices(d.passages,f+1)):l.absolute_indices[1]===d.absolute_indices[1]&&0<f?d.absolute_indices[1]=0<c.length?c[c.length-1].indices[1]:d.passages[f-1].absolute_indices[1]:"book"===a&&f<g-1&&!this.starts_with_book(d.passages[f+1])&&(d.passages[f+1].absolute_indices[0]=
l.absolute_indices[0]);return d};k.prototype.get_snap_sequence_i=function(a,d,c){var f,g,l;for(f=g=l=d+1;l<=c?g<c:g>c;f=l<=c?++g:--g){if(this.starts_with_book(a[f]))return f;if(a[f].valid.valid)break}return d};k.prototype.starts_with_book=function(a){return"b"===a.type.substr(0,1)||("range"===a.type||"ff"===a.type)&&"b"===a.start.type.substr(0,1)?!0:!1};k.prototype.remove_absolute_indices=function(a,d){var c;if(0>a[d].enclosed_absolute_indices[0])return!1;var f=a[d].enclosed_absolute_indices;var g=
f[0];f=f[1];var l=a.slice(d);var k=0;for(c=l.length;k<c;k++){var m=l[k];if(m.enclosed_absolute_indices[0]===g&&m.enclosed_absolute_indices[1]===f)m.enclosed_absolute_indices=[-1,-1];else break}return!0};return k}();var Ga=function(){function k(){}k.prototype.books=[];k.prototype.indices={};k.prototype.options={};k.prototype.translations={};k.prototype.handle_array=function(a,d,c){var f;null==d&&(d=[]);null==c&&(c={});var g=0;for(f=a.length;g<f;g++){var l=a[g];if(null!=l){if("stop"===l.type)break;
c=this.handle_obj(l,d,c);d=c[0];c=c[1]}}return[d,c]};k.prototype.handle_obj=function(a,d,c){return null!=a.type&&null!=this[a.type]?this[a.type](a,d,c):[d,c]};k.prototype.b=function(a,d,c){var f;a.start_context=y.shallow_clone(c);a.passages=[];c=[];var g=this.books[a.value].parsed;var l=0;for(f=g.length;l<f;l++){var k=g[l];var m=this.validate_ref(a.start_context.translations,{b:k});k={start:{b:k},end:{b:k},valid:m};0===a.passages.length&&m.valid?a.passages.push(k):c.push(k)}0===a.passages.length&&
a.passages.push(c.shift());0<c.length&&(a.passages[0].alternates=c);null!=a.start_context.translations&&(a.passages[0].translations=a.start_context.translations);null==a.absolute_indices&&(a.absolute_indices=this.get_absolute_indices(a.indices));d.push(a);c={b:a.passages[0].start.b};null!=a.start_context.translations&&(c.translations=a.start_context.translations);return[d,c]};k.prototype.b_range=function(a,d,c){return this.range(a,d,c)};k.prototype.b_range_pre=function(a,d,c){a.start_context=y.shallow_clone(c);
a.passages=[];var f=this.pluck("b",a.value);c=this.b(f,[],c);f=c[0][0];c=c[1];null==a.absolute_indices&&(a.absolute_indices=this.get_absolute_indices(a.indices));var g={b:a.value[0].value+f.passages[0].start.b.substr(1),type:"b"};a.passages=[{start:g,end:f.passages[0].end,valid:f.passages[0].valid}];null!=a.start_context.translations&&(a.passages[0].translations=a.start_context.translations);d.push(a);return[d,c]};k.prototype.b_range_start=function(a,d,c){return this.range(a,d,c)};k.prototype.base=
function(a,d,c){this.indices=this.calculate_indices(a.match,a.start_index);return this.handle_array(a.value,d,c)};k.prototype.bc=function(a,d,c){var f;a.start_context=y.shallow_clone(c);a.passages=[];this.reset_context(c,["b","c","v"]);var g=this.pluck("c",a.value).value;var l=[];var k=this.books[this.pluck("b",a.value).value].parsed;var m=0;for(f=k.length;m<f;m++){var n=k[m];var v="c";var t=this.validate_ref(a.start_context.translations,{b:n,c:g});var u={start:{b:n},end:{b:n},valid:t};if(t.messages.start_chapter_not_exist_in_single_chapter_book||
t.messages.start_chapter_1)u.valid=this.validate_ref(a.start_context.translations,{b:n,v:g}),t.messages.start_chapter_not_exist_in_single_chapter_book&&(u.valid.messages.start_chapter_not_exist_in_single_chapter_book=1),u.start.c=1,u.end.c=1,v="v";u.start[v]=g;n=this.fix_start_zeroes(u.valid,u.start.c,u.start.v);u.start.c=n[0];u.start.v=n[1];null==u.start.v&&delete u.start.v;u.end[v]=u.start[v];0===a.passages.length&&u.valid.valid?a.passages.push(u):l.push(u)}0===a.passages.length&&a.passages.push(l.shift());
0<l.length&&(a.passages[0].alternates=l);null!=a.start_context.translations&&(a.passages[0].translations=a.start_context.translations);null==a.absolute_indices&&(a.absolute_indices=this.get_absolute_indices(a.indices));this.set_context_from_object(c,["b","c","v"],a.passages[0].start);d.push(a);return[d,c]};k.prototype.bc_title=function(a,d,c){var f,g;a.start_context=y.shallow_clone(c);c=this.bc(this.pluck("bc",a.value),[],c);var l=c[0][0];c=c[1];if("Ps"!==l.passages[0].start.b.substr(0,2)&&null!=
l.passages[0].alternates){var k=f=0;for(g=l.passages[0].alternates.length;0<=g?f<g:f>g;k=0<=g?++f:--f)if("Ps"===l.passages[0].alternates[k].start.b.substr(0,2)){l.passages[0]=l.passages[0].alternates[k];break}}if("Ps"!==l.passages[0].start.b.substr(0,2))return d.push(l),[d,c];this.books[this.pluck("b",l.value).value].parsed=["Ps"];l=this.pluck("title",a.value);null==l&&(l=this.pluck("v",a.value));a.value[1]={type:"v",value:[{type:"integer",value:1,indices:l.indices}],indices:l.indices};a.type="bcv";
return this.bcv(a,d,a.start_context)};k.prototype.bcv=function(a,d,c){var f;a.start_context=y.shallow_clone(c);a.passages=[];this.reset_context(c,["b","c","v"]);var g=this.pluck("bc",a.value);var l=this.pluck("c",g.value).value;var k=this.pluck("v",a.value).value;var m=[];var n=this.books[this.pluck("b",g.value).value].parsed;g=0;for(f=n.length;g<f;g++){var v=n[g];var t=this.validate_ref(a.start_context.translations,{b:v,c:l,v:k});k=this.fix_start_zeroes(t,l,k);l=k[0];k=k[1];v={start:{b:v,c:l,v:k},
end:{b:v,c:l,v:k},valid:t};0===a.passages.length&&t.valid?a.passages.push(v):m.push(v)}0===a.passages.length&&a.passages.push(m.shift());0<m.length&&(a.passages[0].alternates=m);null!=a.start_context.translations&&(a.passages[0].translations=a.start_context.translations);null==a.absolute_indices&&(a.absolute_indices=this.get_absolute_indices(a.indices));this.set_context_from_object(c,["b","c","v"],a.passages[0].start);d.push(a);return[d,c]};k.prototype.bv=function(a,d,c){a.start_context=y.shallow_clone(c);
var f=a.value;f={indices:a.indices,value:[{type:"bc",value:[f[0],{type:"c",value:[{type:"integer",value:1}]}]},f[1]]};c=this.bcv(f,[],c);f=c[0][0];c=c[1];a.passages=f.passages;null==a.absolute_indices&&(a.absolute_indices=this.get_absolute_indices(a.indices));d.push(a);return[d,c]};k.prototype.c=function(a,d,c){a.start_context=y.shallow_clone(c);var f="integer"===a.type?a.value:this.pluck("integer",a.value).value;var g=this.validate_ref(a.start_context.translations,{b:c.b,c:f});if(!g.valid&&g.messages.start_chapter_not_exist_in_single_chapter_book)return this.v(a,
d,c);f=this.fix_start_zeroes(g,f)[0];a.passages=[{start:{b:c.b,c:f},end:{b:c.b,c:f},valid:g}];null!=a.start_context.translations&&(a.passages[0].translations=a.start_context.translations);d.push(a);c.c=f;this.reset_context(c,["v"]);null==a.absolute_indices&&(a.absolute_indices=this.get_absolute_indices(a.indices));return[d,c]};k.prototype.c_psalm=function(a,d,c){a.type="bc";var f=parseInt(this.books[a.value].value.match(/^\d+/)[0],10);a.value=[{type:"b",value:a.value,indices:a.indices},{type:"c",
value:[{type:"integer",value:f,indices:a.indices}],indices:a.indices}];return this.bc(a,d,c)};k.prototype.c_title=function(a,d,c){a.start_context=y.shallow_clone(c);if("Ps"!==c.b)return this.c(a.value[0],d,c);c=this.pluck("title",a.value);a.value[1]={type:"v",value:[{type:"integer",value:1,indices:c.indices}],indices:c.indices};a.type="cv";return this.cv(a,d,a.start_context)};k.prototype.cv=function(a,d,c){a.start_context=y.shallow_clone(c);var f=this.pluck("c",a.value).value;var g=this.pluck("v",
a.value).value;var l=this.validate_ref(a.start_context.translations,{b:c.b,c:f,v:g});g=this.fix_start_zeroes(l,f,g);f=g[0];g=g[1];a.passages=[{start:{b:c.b,c:f,v:g},end:{b:c.b,c:f,v:g},valid:l}];null!=a.start_context.translations&&(a.passages[0].translations=a.start_context.translations);d.push(a);c.c=f;c.v=g;null==a.absolute_indices&&(a.absolute_indices=this.get_absolute_indices(a.indices));return[d,c]};k.prototype.cb_range=function(a,d,c){a.type="range";var f=a.value;var g=f[0];var l=f[1];f=f[2];
a.value=[{type:"bc",value:[g,l],indices:a.indices},f];f.indices[1]=a.indices[1];return this.range(a,d,c)};k.prototype.context=function(a,d,c){var f;a.start_context=y.shallow_clone(c);a.passages=[];var g=this.books[a.value].context;for(f in g)B.call(g,f)&&(c[f]=this.books[a.value].context[f]);d.push(a);return[d,c]};k.prototype.cv_psalm=function(a,d,c){a.start_context=y.shallow_clone(c);a.type="bcv";var f=a.value;var g=f[0];f=f[1];g=this.c_psalm(g,[],a.start_context)[0][0];a.value=[g,f];return this.bcv(a,
d,c)};k.prototype.ff=function(a,d,c){a.start_context=y.shallow_clone(c);a.value.push({type:"integer",indices:a.indices,value:999});c=this.range(a,[],a.start_context);a=c[0][0];c=c[1];a.value[0].indices=a.value[1].indices;a.value[0].absolute_indices=a.value[1].absolute_indices;a.value.pop();null!=a.passages[0].valid.messages.end_verse_not_exist&&delete a.passages[0].valid.messages.end_verse_not_exist;null!=a.passages[0].valid.messages.end_chapter_not_exist&&delete a.passages[0].valid.messages.end_chapter_not_exist;
null!=a.passages[0].end.original_c&&delete a.passages[0].end.original_c;d.push(a);return[d,c]};k.prototype.integer_title=function(a,d,c){a.start_context=y.shallow_clone(c);if("Ps"!==c.b)return this.integer(a.value[0],d,c);a.value[0]={type:"c",value:[a.value[0]],indices:[a.value[0].indices[0],a.value[0].indices[1]]};a.value[1].type="v";a.value[1].original_type="title";a.value[1].value=[{type:"integer",value:1,indices:a.value[1].value.indices}];a.type="cv";return this.cv(a,d,a.start_context)};k.prototype.integer=
function(a,d,c){return null!=c.v?this.v(a,d,c):this.c(a,d,c)};k.prototype.next_v=function(a,d,c){a.start_context=y.shallow_clone(c);var f=this.pluck_last_recursively("integer",a.value);null==f&&(f={value:1});a.value.push({type:"integer",indices:a.indices,value:f.value+1});c=this.range(a,[],a.start_context);f=c[0][0];c=c[1];null!=f.passages[0].valid.messages.end_verse_not_exist&&null==f.passages[0].valid.messages.start_verse_not_exist&&null==f.passages[0].valid.messages.start_chapter_not_exist&&null!=
c.c&&(a.value.pop(),a.value.push({type:"cv",indices:a.indices,value:[{type:"c",value:[{type:"integer",value:c.c+1,indices:a.indices}],indices:a.indices},{type:"v",value:[{type:"integer",value:1,indices:a.indices}],indices:a.indices}]}),a=this.range(a,[],a.start_context),f=a[0],f=f[0],c=a[1]);f.value[0].indices=f.value[1].indices;f.value[0].absolute_indices=f.value[1].absolute_indices;f.value.pop();null!=f.passages[0].valid.messages.end_verse_not_exist&&delete f.passages[0].valid.messages.end_verse_not_exist;
null!=f.passages[0].valid.messages.end_chapter_not_exist&&delete f.passages[0].valid.messages.end_chapter_not_exist;null!=f.passages[0].end.original_c&&delete f.passages[0].end.original_c;d.push(f);return[d,c]};k.prototype.sequence=function(a,d,c){var f,g;a.start_context=y.shallow_clone(c);a.passages=[];var l=a.value;var k=0;for(f=l.length;k<f;k++){var m=l[k];c=this.handle_array(m,[],c);m=c[0];m=m[0];c=c[1];var n=m.passages;var v=0;for(g=n.length;v<g;v++){var t=n[v];null==t.type&&(t.type=m.type);
null==t.absolute_indices&&(t.absolute_indices=m.absolute_indices);null!=m.start_context.translations&&(t.translations=m.start_context.translations);t.enclosed_absolute_indices="sequence_post_enclosed"===m.type?m.absolute_indices:[-1,-1];a.passages.push(t)}}null==a.absolute_indices&&(a.absolute_indices=0<a.passages.length&&"sequence"===a.type?[a.passages[0].absolute_indices[0],a.passages[a.passages.length-1].absolute_indices[1]]:this.get_absolute_indices(a.indices));d.push(a);return[d,c]};k.prototype.sequence_post_enclosed=
function(a,d,c){return this.sequence(a,d,c)};k.prototype.v=function(a,d,c){var f="integer"===a.type?a.value:this.pluck("integer",a.value).value;a.start_context=y.shallow_clone(c);var g=null!=c.c?c.c:1;var l=this.validate_ref(a.start_context.translations,{b:c.b,c:g,v:f});f=this.fix_start_zeroes(l,0,f)[1];a.passages=[{start:{b:c.b,c:g,v:f},end:{b:c.b,c:g,v:f},valid:l}];null!=a.start_context.translations&&(a.passages[0].translations=a.start_context.translations);null==a.absolute_indices&&(a.absolute_indices=
this.get_absolute_indices(a.indices));d.push(a);c.v=f;return[d,c]};k.prototype.range=function(a,d,c){var f,g,l,k;a.start_context=y.shallow_clone(c);var m=a.value;var n=m[0];m=m[1];c=this.handle_obj(n,[],c);n=c[0][0];c=c[1];if("v"===m.type&&("bc"===n.type&&(null==(f=n.passages)||null==(g=f[0])||null==(l=g.valid)||null==(k=l.messages)||!k.start_chapter_not_exist_in_single_chapter_book)||"c"===n.type)&&"verse"===this.options.end_range_digits_strategy)return a.value[0]=n,this.range_change_integer_end(a,
d);c=this.handle_obj(m,[],c);m=c[0][0];c=c[1];a.value=[n,m];a.indices=[n.indices[0],m.indices[1]];delete a.absolute_indices;g={b:n.passages[0].start.b,c:n.passages[0].start.c,v:n.passages[0].start.v,type:n.type};f={b:m.passages[0].end.b,c:m.passages[0].end.c,v:m.passages[0].end.v,type:m.type};m.passages[0].valid.messages.start_chapter_is_zero&&(f.c=0);m.passages[0].valid.messages.start_verse_is_zero&&(f.v=0);l=this.validate_ref(a.start_context.translations,g,f);if(l.valid){if(m=this.range_handle_valid(l,
a,n,g,m,f,d),n=m[0],m=m[1],n)return m}else return this.range_handle_invalid(l,a,n,g,m,f,d);null==a.absolute_indices&&(a.absolute_indices=this.get_absolute_indices(a.indices));a.passages=[{start:g,end:f,valid:l}];null!=a.start_context.translations&&(a.passages[0].translations=a.start_context.translations);"b"===g.type?a.type="b"===f.type?"b_range":"b_range_start":"b"===f.type&&(a.type="range_end_b");d.push(a);return[d,c]};k.prototype.range_change_end=function(a,d,c){var f=a.value[1];"integer"===f.type?
(f.original_value=f.value,f.value=c):"v"===f.type?(f=this.pluck("integer",f.value),f.original_value=f.value,f.value=c):"cv"===f.type&&(f=this.pluck("c",f.value),f.original_value=f.value,f.value=c);return this.handle_obj(a,d,a.start_context)};k.prototype.range_change_integer_end=function(a,d){var c=a.value;var f=c[0];c=c[1];null==a.original_type&&(a.original_type=a.type);null==a.original_value&&(a.original_value=[f,c]);a.type="integer"===f.type?"cv":f.type+"v";"integer"===f.type&&(a.value[0]={type:"c",
value:[f],indices:f.indices});"integer"===c.type&&(a.value[1]={type:"v",value:[c],indices:c.indices});return this.handle_obj(a,d,a.start_context)};k.prototype.range_check_new_end=function(a,d,c,f){var g=0;var l=null;f.messages.end_chapter_before_start?l="c":f.messages.end_verse_before_start&&(l="v");null!=l&&(g=this.range_get_new_end_value(d,c,f,l));0<g&&(d={b:c.b,c:c.c,v:c.v},d[l]=g,a=this.validate_ref(a,d),a.valid||(g=0));return g};k.prototype.range_end_b=function(a,d,c){return this.range(a,d,c)};
k.prototype.range_get_new_end_value=function(a,d,c,f){var g=0;if("c"===f&&c.messages.end_chapter_is_zero||"v"===f&&c.messages.end_verse_is_zero)return g;10<=a[f]&&10>d[f]&&a[f]-10*Math.floor(a[f]/10)<d[f]?g=d[f]+10*Math.floor(a[f]/10):100<=a[f]&&100>d[f]&&a[f]-100<d[f]&&(g=d[f]+100);return g};k.prototype.range_handle_invalid=function(a,d,c,f,g,l,k){if(!1===a.valid&&(a.messages.end_chapter_before_start||a.messages.end_verse_before_start)&&("integer"===g.type||"v"===g.type)||!1===a.valid&&a.messages.end_chapter_before_start&&
"cv"===g.type)if(a=this.range_check_new_end(d.start_context.translations,f,l,a),0<a)return this.range_change_end(d,k,a);if("verse"===this.options.end_range_digits_strategy&&null==f.v&&("integer"===g.type||"v"===g.type)&&(a="v"===g.type?this.pluck("integer",g.value):g.value,f=this.validate_ref(d.start_context.translations,{b:f.b,c:f.c,v:a}),f.valid))return this.range_change_integer_end(d,k);null==d.original_type&&(d.original_type=d.type);d.type="sequence";c=[[c,g],[[c],[g]]];d.original_value=c[0];
d.value=c[1];return this.sequence(d,k,d.start_context)};k.prototype.range_handle_valid=function(a,d,c,f,g,l,k){if(a.messages.end_chapter_not_exist&&"verse"===this.options.end_range_digits_strategy&&null==f.v&&("integer"===g.type||"v"===g.type)&&0<=this.options.passage_existence_strategy.indexOf("v")&&(c="v"===g.type?this.pluck("integer",g.value):g.value,c=this.validate_ref(d.start_context.translations,{b:f.b,c:f.c,v:c}),c.valid))return[!0,this.range_change_integer_end(d,k)];this.range_validate(a,
f,l,d);return[!1,null]};k.prototype.range_validate=function(a,d,c,f){a.messages.end_chapter_not_exist||a.messages.end_chapter_not_exist_in_single_chapter_book?(c.original_c=c.c,c.c=a.messages.end_chapter_not_exist?a.messages.end_chapter_not_exist:a.messages.end_chapter_not_exist_in_single_chapter_book,null!=c.v&&(c.v=this.validate_ref(f.start_context.translations,{b:c.b,c:c.c,v:999}).messages.end_verse_not_exist,delete a.messages.end_verse_is_zero)):a.messages.end_verse_not_exist&&(c.original_v=c.v,
c.v=a.messages.end_verse_not_exist);a.messages.end_verse_is_zero&&"allow"!==this.options.zero_verse_strategy&&(c.v=a.messages.end_verse_is_zero);a.messages.end_chapter_is_zero&&(c.c=a.messages.end_chapter_is_zero);a=this.fix_start_zeroes(a,d.c,d.v);d.c=a[0];d.v=a[1];return!0};k.prototype.translation_sequence=function(a,d,c){var f;a.start_context=y.shallow_clone(c);var g=[];g.push({translation:this.books[a.value[0].value].parsed});var l=a.value[1];var k=0;for(f=l.length;k<f;k++){var m=l[k];m=this.books[this.pluck("translation",
m).value].parsed;null!=m&&g.push({translation:m})}k=0;for(f=g.length;k<f;k++)l=g[k],null!=this.translations.aliases[l.translation]?(l.alias=this.translations.aliases[l.translation].alias,l.osis=this.translations.aliases[l.translation].osis||l.translation.toUpperCase()):(l.alias="default",l.osis=l.translation.toUpperCase());0<d.length&&(c=this.translation_sequence_apply(d,g));null==a.absolute_indices&&(a.absolute_indices=this.get_absolute_indices(a.indices));d.push(a);this.reset_context(c,["translations"]);
return[d,c]};k.prototype.translation_sequence_apply=function(a,d){var c,f,g;var l=0;for(c=f=g=a.length-1;0>=g?0>=f:0<=f;c=0>=g?++f:--f)if(null!=a[c].original_type&&(a[c].type=a[c].original_type),null!=a[c].original_value&&(a[c].value=a[c].original_value),"translation_sequence"===a[c].type){l=c+1;break}l<a.length?(a[l].start_context.translations=d,c=this.handle_array(a.slice(l),[],a[l].start_context),c=c[1]):c=y.shallow_clone(a[a.length-1].start_context);return c};k.prototype.pluck=function(a,d){var c;
var f=0;for(c=d.length;f<c;f++){var g=d[f];if(null!=g&&null!=g.type&&g.type===a)return"c"===a||"v"===a?this.pluck("integer",g.value):g}return null};k.prototype.pluck_last_recursively=function(a,d){var c;for(c=d.length-1;0<=c;c+=-1){var f=d[c];if(null!=f&&null!=f.type){if(f.type===a)return this.pluck(a,[f]);f=this.pluck_last_recursively(a,f.value);if(null!=f)return f}}return null};k.prototype.set_context_from_object=function(a,d,c){var f;var g=[];var l=0;for(f=d.length;l<f;l++){var k=d[l];null!=c[k]&&
g.push(a[k]=c[k])}return g};k.prototype.reset_context=function(a,d){var c;var f=[];var g=0;for(c=d.length;g<c;g++){var l=d[g];f.push(delete a[l])}return f};k.prototype.fix_start_zeroes=function(a,d,c){a.messages.start_chapter_is_zero&&"upgrade"===this.options.zero_chapter_strategy&&(d=a.messages.start_chapter_is_zero);a.messages.start_verse_is_zero&&"upgrade"===this.options.zero_verse_strategy&&(c=a.messages.start_verse_is_zero);return[d,c]};k.prototype.calculate_indices=function(a,d){var c,f;var g=
"book";var l=[];var k=0;d=parseInt(d,10);var m=[a];var n=["\u001e","\u001f"];var v=0;for(c=n.length;v<c;v++){var t=n[v];var u=[];var z=0;for(f=m.length;z<f;z++){var x=m[z];u=u.concat(x.split(t))}m=u}z=0;for(v=m.length;z<v;z++)x=m[z],g="book"===g?"rest":"book",c=x.length,0!==c&&("book"===g?(x=x.replace(/\/\d+$/,""),t=k+c,0<l.length&&l[l.length-1].index===d?l[l.length-1].end=t:l.push({start:k,end:t,index:d}),k+=c+2,d=this.books[x].start_index+this.books[x].value.length-k,l.push({start:t+1,end:t+1,index:d})):
(t=k+c-1,0<l.length&&l[l.length-1].index===d?l[l.length-1].end=t:l.push({start:k,end:t,index:d}),k+=c));return l};k.prototype.get_absolute_indices=function(a){var d,c;var f=a[0];a=a[1];var g=c=null;var l=this.indices;var k=0;for(d=l.length;k<d;k++){var m=l[k];null===c&&m.start<=f&&f<=m.end&&(c=f+m.index);if(m.start<=a&&a<=m.end){g=a+m.index+1;break}}return[c,g]};k.prototype.validate_ref=function(a,d,c){var f;null!=a&&0<a.length||(a=[{translation:"default",osis:"",alias:"default"}]);var g=!1;var l=
{};var k=0;for(f=a.length;k<f;k++){var m=a[k];null==m.alias&&(m.alias="default");if(null==m.alias)null==l.translation_invalid&&(l.translation_invalid=[]),l.translation_invalid.push(m);else{null==this.translations.aliases[m.alias]&&(m.alias="default",null==l.translation_unknown&&(l.translation_unknown=[]),l.translation_unknown.push(m));var n=this.validate_start_ref(m.alias,d,l)[0];c&&(n=this.validate_end_ref(m.alias,d,c,n,l)[0]);!0===n&&(g=!0)}}return{valid:g,messages:l}};k.prototype.validate_start_ref=
function(a,d,c){var f,g;var l=!0;"default"!==a&&null==(null!=(f=this.translations[a])?f.chapters[d.b]:void 0)&&this.promote_book_to_translation(d.b,a);f=null!=(null!=(g=this.translations[a])?g.order:void 0)?a:"default";null!=d.v&&(d.v=parseInt(d.v,10));if(null!=this.translations[f].order[d.b]){null==d.c&&(d.c=1);d.c=parseInt(d.c,10);if(isNaN(d.c))return c.start_chapter_not_numeric=!0,[!1,c];0===d.c&&(c.start_chapter_is_zero=1,"error"===this.options.zero_chapter_strategy?l=!1:d.c=1);null!=d.v&&0===
d.v&&(c.start_verse_is_zero=1,"error"===this.options.zero_verse_strategy?l=!1:"upgrade"===this.options.zero_verse_strategy&&(d.v=1));0<d.c&&null!=this.translations[a].chapters[d.b][d.c-1]?null!=d.v?isNaN(d.v)?(l=!1,c.start_verse_not_numeric=!0):d.v>this.translations[a].chapters[d.b][d.c-1]&&0<=this.options.passage_existence_strategy.indexOf("v")&&(l=!1,c.start_verse_not_exist=this.translations[a].chapters[d.b][d.c-1]):1===d.c&&"verse"===this.options.single_chapter_1_strategy&&1===this.translations[a].chapters[d.b].length&&
(c.start_chapter_1=1):1!==d.c&&1===this.translations[a].chapters[d.b].length?(l=!1,c.start_chapter_not_exist_in_single_chapter_book=1):0<d.c&&0<=this.options.passage_existence_strategy.indexOf("c")&&(l=!1,c.start_chapter_not_exist=this.translations[a].chapters[d.b].length)}else null==d.b?(l=!1,c.start_book_not_defined=!0):(0<=this.options.passage_existence_strategy.indexOf("b")&&(l=!1),c.start_book_not_exist=!0);return[l,c]};k.prototype.validate_end_ref=function(a,d,c,f,g){var l;var k=null!=(null!=
(l=this.translations[a])?l.order:void 0)?a:"default";null!=c.c&&(c.c=parseInt(c.c,10),isNaN(c.c)?(f=!1,g.end_chapter_not_numeric=!0):0===c.c&&(g.end_chapter_is_zero=1,"error"===this.options.zero_chapter_strategy?f=!1:c.c=1));null!=c.v&&(c.v=parseInt(c.v,10),isNaN(c.v)?(f=!1,g.end_verse_not_numeric=!0):0===c.v&&(g.end_verse_is_zero=1,"error"===this.options.zero_verse_strategy?f=!1:"upgrade"===this.options.zero_verse_strategy&&(c.v=1)));null!=this.translations[k].order[c.b]?(null==c.c&&1===this.translations[a].chapters[c.b].length&&
(c.c=1),null!=this.translations[k].order[d.b]&&this.translations[k].order[d.b]>this.translations[k].order[c.b]&&(0<=this.options.passage_existence_strategy.indexOf("b")&&(f=!1),g.end_book_before_start=!0),d.b!==c.b||null==c.c||isNaN(c.c)||(null==d.c&&(d.c=1),!isNaN(parseInt(d.c,10))&&d.c>c.c?(f=!1,g.end_chapter_before_start=!0):d.c!==c.c||null==c.v||isNaN(c.v)||(null==d.v&&(d.v=1),!isNaN(parseInt(d.v,10))&&d.v>c.v&&(f=!1,g.end_verse_before_start=!0))),null==c.c||isNaN(c.c)||null!=this.translations[a].chapters[c.b][c.c-
1]||(1===this.translations[a].chapters[c.b].length?g.end_chapter_not_exist_in_single_chapter_book=1:0<c.c&&0<=this.options.passage_existence_strategy.indexOf("c")&&(g.end_chapter_not_exist=this.translations[a].chapters[c.b].length)),null==c.v||isNaN(c.v)||(null==c.c&&(c.c=this.translations[a].chapters[c.b].length),c.v>this.translations[a].chapters[c.b][c.c-1]&&0<=this.options.passage_existence_strategy.indexOf("v")&&(g.end_verse_not_exist=this.translations[a].chapters[c.b][c.c-1]))):(f=!1,g.end_book_not_exist=
!0);return[f,g]};k.prototype.promote_book_to_translation=function(a,d){var c;null==(c=this.translations)[d]&&(c[d]={});null==(c=this.translations[d]).chapters&&(c.chapters={});if(null==this.translations[d].chapters[a])return this.translations[d].chapters[a]=y.shallow_clone_array(this.translations["default"].chapters[a])};return k}();var y={shallow_clone:function(k){var a;if(null==k)return k;var d={};for(a in k)if(B.call(k,a)){var c=k[a];d[a]=c}return d},shallow_clone_array:function(k){var a,d;if(null==
k)return k;var c=[];var f=a=0;for(d=k.length;0<=d?a<=d:a>=d;f=0<=d?++a:--a)"undefined"!==typeof k[f]&&(c[f]=k[f]);return c}};n.prototype.regexps.translations=/(?:(?:(?:E[RS]|AS|TNI|RS|KJ)V|LXX|MSG|CE[BV]|AMP|HCSB|N(?:(?:KJ|RS)V|LT|IR?V|A(?:B(?:RE)?|SB?))))\b/gi;n.prototype.translations={aliases:{ceb:{alias:"ceb"},kjv:{alias:"kjv"},lxx:{alias:"nab"},nab:{alias:"nab"},nabre:{alias:"nab"},nas:{osis:"NASB",alias:"default"},nirv:{alias:"kjv"},niv:{alias:"kjv"},nkjv:{alias:"nkjv"},nlt:{alias:"nlt"},nrsv:{alias:"nrsv"},
tniv:{alias:"kjv"},"default":{osis:"",alias:"default"}},alternates:{},"default":{order:{Gen:1,Exod:2,Lev:3,Num:4,Deut:5,Josh:6,Judg:7,Ruth:8,"1Sam":9,"2Sam":10,"1Kgs":11,"2Kgs":12,"1Chr":13,"2Chr":14,Ezra:15,Neh:16,Esth:17,Job:18,Ps:19,Prov:20,Eccl:21,Song:22,Isa:23,Jer:24,Lam:25,Ezek:26,Dan:27,Hos:28,Joel:29,Amos:30,Obad:31,Jonah:32,Mic:33,Nah:34,Hab:35,Zeph:36,Hag:37,Zech:38,Mal:39,Matt:40,Mark:41,Luke:42,John:43,Acts:44,Rom:45,"1Cor":46,"2Cor":47,Gal:48,Eph:49,Phil:50,Col:51,"1Thess":52,"2Thess":53,
"1Tim":54,"2Tim":55,Titus:56,Phlm:57,Heb:58,Jas:59,"1Pet":60,"2Pet":61,"1John":62,"2John":63,"3John":64,Jude:65,Rev:66,Tob:67,Jdt:68,GkEsth:69,Wis:70,Sir:71,Bar:72,PrAzar:73,Sus:74,Bel:75,SgThree:76,EpJer:77,"1Macc":78,"2Macc":79,"3Macc":80,"4Macc":81,"1Esd":82,"2Esd":83,PrMan:84},chapters:{Gen:[31,25,24,26,32,22,24,22,29,32,32,20,18,24,21,16,27,33,38,18,34,24,20,67,34,35,46,22,35,43,55,32,20,31,29,43,36,30,23,23,57,38,34,34,28,34,31,22,33,26],Exod:[22,25,22,31,23,30,25,32,35,29,10,51,22,31,27,36,
16,27,25,26,36,31,33,18,40,37,21,43,46,38,18,35,23,35,35,38,29,31,43,38],Lev:[17,16,17,35,19,30,38,36,24,20,47,8,59,57,33,34,16,30,37,27,24,33,44,23,55,46,34],Num:[54,34,51,49,31,27,89,26,23,36,35,16,33,45,41,50,13,32,22,29,35,41,30,25,18,65,23,31,40,16,54,42,56,29,34,13],Deut:[46,37,29,49,33,25,26,20,29,22,32,32,18,29,23,22,20,22,21,20,23,30,25,22,19,19,26,68,29,20,30,52,29,12],Josh:[18,24,17,24,15,27,26,35,27,43,23,24,33,15,63,10,18,28,51,9,45,34,16,33],Judg:[36,23,31,24,31,40,25,35,57,18,40,15,
25,20,20,31,13,31,30,48,25],Ruth:[22,23,18,22],"1Sam":[28,36,21,22,12,21,17,22,27,27,15,25,23,52,35,23,58,30,24,42,15,23,29,22,44,25,12,25,11,31,13],"2Sam":[27,32,39,12,25,23,29,18,13,19,27,31,39,33,37,23,29,33,43,26,22,51,39,25],"1Kgs":[53,46,28,34,18,38,51,66,28,29,43,33,34,31,34,34,24,46,21,43,29,53],"2Kgs":[18,25,27,44,27,33,20,29,37,36,21,21,25,29,38,20,41,37,37,21,26,20,37,20,30],"1Chr":[54,55,24,43,26,81,40,40,44,14,47,40,14,17,29,43,27,17,19,8,30,19,32,31,31,32,34,21,30],"2Chr":[17,18,17,
22,14,42,22,18,31,19,23,16,22,15,19,14,19,34,11,37,20,12,21,27,28,23,9,27,36,27,21,33,25,33,27,23],Ezra:[11,70,13,24,17,22,28,36,15,44],Neh:[11,20,32,23,19,19,73,18,38,39,36,47,31],Esth:[22,23,15,17,14,14,10,17,32,3],Job:[22,13,26,21,27,30,21,22,35,22,20,25,28,22,35,22,16,21,29,29,34,30,17,25,6,14,23,28,25,31,40,22,33,37,16,33,24,41,30,24,34,17],Ps:[6,12,8,8,12,10,17,9,20,18,7,8,6,7,5,11,15,50,14,9,13,31,6,10,22,12,14,9,11,12,24,11,22,22,28,12,40,22,13,17,13,11,5,26,17,11,9,14,20,23,19,9,6,7,23,13,
11,11,17,12,8,12,11,10,13,20,7,35,36,5,24,20,28,23,10,12,20,72,13,19,16,8,18,12,13,17,7,18,52,17,16,15,5,23,11,13,12,9,9,5,8,28,22,35,45,48,43,13,31,7,10,10,9,8,18,19,2,29,176,7,8,9,4,8,5,6,5,6,8,8,3,18,3,3,21,26,9,8,24,13,10,7,12,15,21,10,20,14,9,6],Prov:[33,22,35,27,23,35,27,36,18,32,31,28,25,35,33,33,28,24,29,30,31,29,35,34,28,28,27,28,27,33,31],Eccl:[18,26,22,16,20,12,29,17,18,20,10,14],Song:[17,17,11,16,16,13,13,14],Isa:[31,22,26,6,30,13,25,22,21,34,16,6,22,32,9,14,14,7,25,6,17,25,18,23,12,21,
13,29,24,33,9,20,24,17,10,22,38,22,8,31,29,25,28,28,25,13,15,22,26,11,23,15,12,17,13,12,21,14,21,22,11,12,19,12,25,24],Jer:[19,37,25,31,31,30,34,22,26,25,23,17,27,22,21,21,27,23,15,18,14,30,40,10,38,24,22,17,32,24,40,44,26,22,19,32,21,28,18,16,18,22,13,30,5,28,7,47,39,46,64,34],Lam:[22,22,66,22,22],Ezek:[28,10,27,17,17,14,27,18,11,22,25,28,23,23,8,63,24,32,14,49,32,31,49,27,17,21,36,26,21,26,18,32,33,31,15,38,28,23,29,49,26,20,27,31,25,24,23,35],Dan:[21,49,30,37,31,28,28,27,27,21,45,13],Hos:[11,23,
5,19,15,11,16,14,17,15,12,14,16,9],Joel:[20,32,21],Amos:[15,16,15,13,27,14,17,14,15],Obad:[21],Jonah:[17,10,10,11],Mic:[16,13,12,13,15,16,20],Nah:[15,13,19],Hab:[17,20,19],Zeph:[18,15,20],Hag:[15,23],Zech:[21,13,10,14,11,15,14,23,17,12,17,14,9,21],Mal:[14,17,18,6],Matt:[25,23,17,25,48,34,29,34,38,42,30,50,58,36,39,28,27,35,30,34,46,46,39,51,46,75,66,20],Mark:[45,28,35,41,43,56,37,38,50,52,33,44,37,72,47,20],Luke:[80,52,38,44,39,49,50,56,62,42,54,59,35,35,32,31,37,43,48,47,38,71,56,53],John:[51,25,
36,54,47,71,53,59,41,42,57,50,38,31,27,33,26,40,42,31,25],Acts:[26,47,26,37,42,15,60,40,43,48,30,25,52,28,41,40,34,28,41,38,40,30,35,27,27,32,44,31],Rom:[32,29,31,25,21,23,25,39,33,21,36,21,14,23,33,27],"1Cor":[31,16,23,21,13,20,40,13,27,33,34,31,13,40,58,24],"2Cor":[24,17,18,18,21,18,16,24,15,18,33,21,14],Gal:[24,21,29,31,26,18],Eph:[23,22,21,32,33,24],Phil:[30,30,21,23],Col:[29,23,25,18],"1Thess":[10,20,13,18,28],"2Thess":[12,17,18],"1Tim":[20,15,16,16,25,21],"2Tim":[18,26,17,22],Titus:[16,15,15],
Phlm:[25],Heb:[14,18,19,16,14,20,28,13,28,39,40,29,25],Jas:[27,26,18,17,20],"1Pet":[25,25,22,19,14],"2Pet":[21,22,18],"1John":[10,29,24,21,21],"2John":[13],"3John":[15],Jude:[25],Rev:[20,29,22,11,14,17,17,13,21,11,19,17,18,20,8,21,18,24,21,15,27,21],Tob:[22,14,17,21,22,18,16,21,6,13,18,22,17,15],Jdt:[16,28,10,15,24,21,32,36,14,23,23,20,20,19,14,25],GkEsth:[22,23,15,17,14,14,10,17,32,13,12,6,18,19,16,24],Wis:[16,24,19,20,23,25,30,21,18,21,26,27,19,31,19,29,21,25,22],Sir:[30,18,31,31,15,37,36,19,18,
31,34,18,26,27,20,30,32,33,30,31,28,27,27,34,26,29,30,26,28,25,31,24,33,31,26,31,31,34,35,30,22,25,33,23,26,20,25,25,16,29,30],Bar:[22,35,37,37,9],PrAzar:[68],Sus:[64],Bel:[42],SgThree:[39],EpJer:[73],"1Macc":[64,70,60,61,68,63,50,32,73,89,74,53,53,49,41,24],"2Macc":[36,32,40,50,27,31,42,36,29,38,38,45,26,46,39],"3Macc":[29,33,30,21,51,41,23],"4Macc":[35,24,21,26,38,35,23,29,32,21,27,19,27,20,32,25,24,24],"1Esd":[58,30,24,63,73,34,15,96,55],"2Esd":[40,48,36,52,56,59,70,63,47,59,46,51,58,48,63,78],
PrMan:[15],Ps151:[7]}},vulgate:{chapters:{Gen:[31,25,24,26,32,22,24,22,29,32,32,20,18,24,21,16,27,33,38,18,34,24,20,67,34,35,46,22,35,43,55,32,20,31,29,43,36,30,23,23,57,38,34,34,28,34,31,22,32,25],Exod:[22,25,22,31,23,30,25,32,35,29,10,51,22,31,27,36,16,27,25,26,36,31,33,18,40,37,21,43,46,38,18,35,23,35,35,38,29,31,43,36],Lev:[17,16,17,35,19,30,38,36,24,20,47,8,59,57,33,34,16,30,37,27,24,33,44,23,55,45,34],Num:[54,34,51,49,31,27,89,26,23,36,34,15,34,45,41,50,13,32,22,30,35,41,30,25,18,65,23,31,39,
17,54,42,56,29,34,13],Josh:[18,24,17,25,16,27,26,35,27,44,23,24,33,15,63,10,18,28,51,9,43,34,16,33],Judg:[36,23,31,24,32,40,25,35,57,18,40,15,25,20,20,31,13,31,30,48,24],"1Sam":[28,36,21,22,12,21,17,22,27,27,15,25,23,52,35,23,58,30,24,43,15,23,28,23,44,25,12,25,11,31,13],"1Kgs":[53,46,28,34,18,38,51,66,28,29,43,33,34,31,34,34,24,46,21,43,29,54],"1Chr":[54,55,24,43,26,81,40,40,44,14,46,40,14,17,29,43,27,17,19,7,30,19,32,31,31,32,34,21,30],Neh:[11,20,31,23,19,19,73,18,38,39,36,46,31],Job:[22,13,26,
21,27,30,21,22,35,22,20,25,28,22,35,23,16,21,29,29,34,30,17,25,6,14,23,28,25,31,40,22,33,37,16,33,24,41,35,28,25,16],Ps:[6,13,9,10,13,11,18,10,39,8,9,6,7,5,10,15,51,15,10,14,32,6,10,22,12,14,9,11,13,25,11,22,23,28,13,40,23,14,18,14,12,5,26,18,12,10,15,21,23,21,11,7,9,24,13,12,12,18,14,9,13,12,11,14,20,8,36,37,6,24,20,28,23,11,13,21,72,13,20,17,8,19,13,14,17,7,19,53,17,16,16,5,23,11,13,12,9,9,5,8,29,22,35,45,48,43,14,31,7,10,10,9,26,9,10,2,29,176,7,8,9,4,8,5,6,5,6,8,8,3,18,3,3,21,26,9,8,24,14,10,8,
12,15,21,10,11,9,14,9,6],Eccl:[18,26,22,17,19,11,30,17,18,20,10,14],Song:[16,17,11,16,17,12,13,14],Jer:[19,37,25,31,31,30,34,22,26,25,23,17,27,22,21,21,27,23,15,18,14,30,40,10,38,