swordjs
Version:
swordjs - access modules from crosswire.org/sword in JS
97 lines • 138 kB
JavaScript
(function(){var g,ja,u,G={}.hasOwnProperty;this.bcv_parser=g=function(){function n(){var a,c,d;this.options={};c=n.prototype.options;for(a in c)G.call(c,a)&&(d=c[a],this.options[a]=d);this.versification_system(this.options.versification_system)}n.prototype.s="";n.prototype.entities=[];n.prototype.passage=null;n.prototype.regexps={};n.prototype.options={consecutive_combination_strategy:"combine",osis_compaction_strategy:"b",book_sequence_strategy:"ignore",invalid_sequence_strategy:"ignore",sequence_combination_strategy:"combine",
invalid_passage_strategy:"ignore",non_latin_digits_strategy:"ignore",passage_existence_strategy:"bcv",zero_chapter_strategy:"error",zero_verse_strategy:"error",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"};n.prototype.parse=function(a){var c;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.entities=this.match_passages(a)[0];return this};n.prototype.parse_with_context=function(a,c){var d;this.reset();d=this.match_books(this.replace_control_characters(c));c=d[0];this.passage.books=d[1];c=this.match_passages(c)[1];this.reset();this.s=a;a=this.replace_control_characters(a);d=this.match_books(a);a=d[0];this.passage.books=d[1];this.passage.books.push({value:"",parsed:[],start_index:0,type:"context",context:c});a="\u001f"+(this.passage.books.length-1)+"/9\u001f"+
a;this.entities=this.match_passages(a)[0];return this};n.prototype.reset=function(){this.s="";this.entities=[];if(this.passage)return this.passage.books=[],this.passage.indices={};this.passage=new ja;this.passage.options=this.options;return this.passage.translations=this.translations};n.prototype.set_options=function(a){var c,d;for(c in a)if(G.call(a,c))if(d=a[c],"include_apocrypha"===c||"versification_system"===c||"case_sensitive"===c)this[c](d);else this.options[c]=d;return this};n.prototype.include_apocrypha=
function(a){var c,d,e,h;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);e=this.translations;for(h in e)G.call(e,h)&&"aliases"!==h&&"alternates"!==h&&(null==(c=this.translations[h]).chapters&&(c.chapters={}),null==(d=this.translations[h].chapters).Ps&&(d.Ps=u.shallow_clone_array(this.translations["default"].chapters.Ps)),!0===a?(c=null!=this.translations[h].chapters.Ps151?this.translations[h].chapters.Ps151[0]:
this.translations["default"].chapters.Ps151[0],this.translations[h].chapters.Ps[150]=c):151===this.translations[h].chapters.Ps.length&&this.translations[h].chapters.Ps.pop());return this};n.prototype.versification_system=function(a){var c,d,e,h,t;if(null==a||null==this.translations[a])return this;if(null!=this.translations.alternates["default"])if("default"===a)for(h in null!=this.translations.alternates["default"].order&&(this.translations["default"].order=u.shallow_clone(this.translations.alternates["default"].order)),
t=this.translations.alternates["default"].chapters,t)G.call(t,h)&&(d=t[h],this.translations["default"].chapters[h]=u.shallow_clone_array(d));else this.versification_system("default");null==(c=this.translations.alternates)["default"]&&(c["default"]={order:null,chapters:{}});"default"!==a&&null!=this.translations[a].order&&(null==(d=this.translations.alternates["default"]).order&&(d.order=u.shallow_clone(this.translations["default"].order)),this.translations["default"].order=u.shallow_clone(this.translations[a].order));
if("default"!==a&&null!=this.translations[a].chapters)for(h in c=this.translations[a].chapters,c)G.call(c,h)&&(d=c[h],null==(e=this.translations.alternates["default"].chapters)[h]&&(e[h]=u.shallow_clone_array(this.translations["default"].chapters[h])),this.translations["default"].chapters[h]=u.shallow_clone_array(d));this.options.versification_system=a;this.include_apocrypha(this.options.include_apocrypha);return this};n.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};n.prototype.translation_info=function(a){var c,d,e,h,t;null==a&&(a="default");null!=a&&null!=(null!=(e=this.translations.aliases[a])?e.alias:void 0)&&(a=this.translations.aliases[a].alias);if(null==a||null==this.translations[a])a="default";e=this.options.versification_system;a!==e&&this.versification_system(a);h={order:u.shallow_clone(this.translations["default"].order),
books:[],chapters:{}};t=this.translations["default"].chapters;for(c in t)G.call(t,c)&&(d=t[c],h.chapters[c]=u.shallow_clone_array(d));t=h.order;for(c in t)G.call(t,c)&&(d=t[c],h.books[d-1]=c);a!==e&&this.versification_system(e);return h};n.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};n.prototype.match_books=function(a){var c,d,e,h,t;d=[];t=this.regexps.books;e=0;for(h=t.length;e<h;e++)c=t[e],a=a.replace(c.regexp,function(a,e,h){d.push({value:h,parsed:c.osis,type:"book"});return e+"\u001f"+(d.length-1)+(null!=c.extra?"/"+c.extra:"")+"\u001f"});a=a.replace(this.regexps.translations,function(a){d.push({value:a,parsed:a.toLowerCase(),type:"translation"});return"\u001e"+(d.length-1)+"\u001e"});return[a,this.get_book_indices(d,a)]};n.prototype.get_book_indices=function(a,
c){var d,e,h;d=0;for(h=/([\x1f\x1e])(\d+)(?:\/\d+)?\1/g;e=h.exec(c);)a[e[2]].start_index=e.index+d,d+=a[e[2]].value.length-e[0].length;return a};n.prototype.match_passages=function(a){var c,d,e,h,t,q;e=[];for(d={};c=this.regexps.escaped_passage.exec(a);)h=c[0],q=c[1],d=c[2],t=q.length,c.index+=h.length-t,/\s[2-9]\d\d\s*$|\s\d{4,}\s*$/.test(q)&&(h=/\s+\d+\s*$/,q=q.replace(h,"")),/[\d\x1f\x1e)]$/.test(q)||(q=this.replace_match_end(q)),"delete"===this.options.captive_end_digits_strategy&&(c=c.index+
q.length,a.length>c&&/^\w/.test(a.substr(c,1))&&(q=q.replace(/[\s*]+\d+$/,"")),q=q.replace(/(\x1e[)\]]?)[\s*]*\d+$/,"$1")),q=q.replace(/[A-Z]+/g,function(a){return a.toLowerCase()}),h="\u001f"===q.substr(0,1)?0:q.split("\u001f")[0].length,c={value:La.parse(q),type:"base",start_index:this.passage.books[d].start_index-h,match:q},"full"===this.options.book_alone_strategy&&"include"===this.options.book_range_strategy&&"b"===c.value[0].type&&(1===c.value.length||1<c.value.length&&"translation_sequence"===
c.value[1].type)&&0===h&&(1===this.passage.books[d].parsed.length||1<this.passage.books[d].parsed.length&&"translation"===this.passage.books[d].parsed[1].type)&&/^[234]/.test(this.passage.books[d].parsed[0])&&this.create_book_range(a,c,d),d=this.passage.handle_obj(c),c=d[0],d=d[1],e=e.concat(c),t=this.adjust_regexp_end(c,t,q.length),0<t&&(this.regexps.escaped_passage.lastIndex-=t);return[e,d]};n.prototype.adjust_regexp_end=function(a,c,d){var e;e=0;0<a.length?e=c-a[a.length-1].indices[1]-1:c!==d&&
(e=c-d);return e};n.prototype.replace_match_end=function(a){var c,d;for(d=a.length;c=this.regexps.match_end_split.exec(a);)d=c.index+c[0].length;d<a.length&&(a=a.substr(0,d));return a};n.prototype.create_book_range=function(a,c,d){var e,h,t,q,ka;e=[n.prototype.regexps.first,n.prototype.regexps.second,n.prototype.regexps.third];q=parseInt(this.passage.books[d].parsed[0].substr(0,1),10);for(h=t=1;1<=q?t<q:t>q;h=1<=q?++t:--t)if(ka=h===q-1?n.prototype.regexps.range_and:n.prototype.regexps.range_only,
ka=a.match(RegExp("(?:^|\\W)("+e[h-1]+"\\s*"+ka+"\\s*)\\x1f"+d+"\\x1f","i")),null!=ka)return this.add_book_range_object(c,ka,h);return!1};n.prototype.add_book_range_object=function(a,c,d){var e,h,t,q;e=c[1].length;a.value[0]={type:"b_range_pre",value:[{type:"b_pre",value:d.toString(),indices:[c.index,c.index+e]},a.value[0]],indices:[0,a.value[0].indices[1]+e]};a.value[0].value[1].indices[0]+=e;a.value[0].value[1].indices[1]+=e;a.start_index-=e;a.match=c[1]+a.match;if(1!==a.value.length){q=[];c=d=
1;for(h=a.value.length;1<=h?d<h:d>h;c=1<=h?++d:--d)null!=a.value[c].value&&(null!=(null!=(t=a.value[c].value[0])?t.indices:void 0)&&(a.value[c].value[0].indices[0]+=e,a.value[c].value[0].indices[1]+=e),a.value[c].indices[0]+=e,q.push(a.value[c].indices[1]+=e));return q}};n.prototype.osis=function(){var a,c,d,e,h;e=[];h=this.parsed_entities();a=0;for(c=h.length;a<c;a++)d=h[a],0<d.osis.length&&e.push(d.osis);return e.join(",")};n.prototype.osis_and_translations=function(){var a,c,d,e,h;e=[];h=this.parsed_entities();
a=0;for(c=h.length;a<c;a++)d=h[a],0<d.osis.length&&e.push([d.osis,d.translations.join(",")]);return e};n.prototype.osis_and_indices=function(){var a,c,d,e,h;e=[];h=this.parsed_entities();a=0;for(c=h.length;a<c;a++)d=h[a],0<d.osis.length&&e.push({osis:d.osis,translations:d.translations,indices:d.indices});return e};n.prototype.parsed_entities=function(){var a,c,d,e,h,t,q,n,g,w,A,C,u,J;n=[];c=e=0;for(w=this.entities.length;0<=w?e<w:e>w;c=0<=w?++e:--e)if(a=this.entities[c],a.type&&"translation_sequence"===
a.type&&0<n.length&&c===n[n.length-1].entity_id+1&&(n[n.length-1].indices[1]=a.absolute_indices[1]),null!=a.passages&&!("b"===a.type&&"ignore"===this.options.book_alone_strategy||"b_range"===a.type&&"ignore"===this.options.book_range_strategy||"context"===a.type)){J=[];u=null;if(null!=a.passages[0].translations)for(t=a.passages[0].translations,h=0,d=t.length;h<d;h++)q=t[h],g=0<(null!=(A=q.osis)?A.length:void 0)?q.osis:"",null==u&&(u=q.alias),J.push(g);else J=[""],u="default";h=[];t=a.passages.length;
d=q=0;for(C=t;0<=C?q<C:q>C;d=0<=C?++q:--q){g=a.passages[d];null==g.type&&(g.type=a.type);if(!1===g.valid.valid&&("ignore"===this.options.invalid_sequence_strategy&&"sequence"===a.type&&this.snap_sequence("ignore",a,h,d,t),"ignore"===this.options.invalid_passage_strategy))continue;"b"!==g.type&&"b_range"!==g.type||"ignore"!==this.options.book_sequence_strategy||"sequence"!==a.type?("b_range_start"!==g.type&&"range_end_b"!==g.type||"ignore"!==this.options.book_range_strategy||this.snap_range(a,d),null==
g.absolute_indices&&(g.absolute_indices=a.absolute_indices),h.push({osis:g.valid.valid?this.to_osis(g.start,g.end,u):"",type:g.type,indices:g.absolute_indices,translations:J,start:g.start,end:g.end,enclosed_indices:g.enclosed_absolute_indices,entity_id:c,entities:[g]})):this.snap_sequence("book",a,h,d,t)}if(0!==h.length)if(1<h.length&&"combine"===this.options.consecutive_combination_strategy&&(h=this.combine_consecutive_passages(h,u)),"separate"===this.options.sequence_combination_strategy)n=n.concat(h);
else{u=[];d=h.length-1;null!=h[d].enclosed_indices&&0<=h[d].enclosed_indices[1]&&(a.absolute_indices[1]=h[d].enclosed_indices[1]);t=0;for(d=h.length;t<d;t++)q=h[t],0<q.osis.length&&u.push(q.osis);n.push({osis:u.join(","),indices:a.absolute_indices,translations:J,entity_id:c,entities:h})}}return n};n.prototype.to_osis=function(a,c,d){var e;null==c.c&&null==c.v&&a.b===c.b&&null==a.c&&null==a.v&&"first_chapter"===this.options.book_alone_strategy&&(c.c=1);null==a.c&&(a.c=1);null==a.v&&(a.v=1);null==c.c&&
(0<=this.options.passage_existence_strategy.indexOf("c")||null!=this.passage.translations[d].chapters[c.b]&&1===this.passage.translations[d].chapters[c.b].length?c.c=this.passage.translations[d].chapters[c.b].length:c.c=999);null==c.v&&(null!=this.passage.translations[d].chapters[c.b][c.c-1]&&0<=this.options.passage_existence_strategy.indexOf("v")?c.v=this.passage.translations[d].chapters[c.b][c.c-1]:c.v=999);this.options.include_apocrypha&&"b"===this.options.ps151_strategy&&(151===a.c&&"Ps"===a.b||
151===c.c&&"Ps"===c.b)&&this.fix_ps151(a,c,d);"b"===this.options.osis_compaction_strategy&&1===a.c&&1===a.v&&c.c===this.passage.translations[d].chapters[c.b].length&&c.v===this.passage.translations[d].chapters[c.b][c.c-1]?(d=a.b,e=c.b):2>=this.options.osis_compaction_strategy.length&&1===a.v&&(999===c.v||c.v===this.passage.translations[d].chapters[c.b][c.c-1])?(d=a.b+"."+a.c.toString(),e=c.b+"."+c.c.toString()):(d=a.b+"."+a.c.toString()+"."+a.v.toString(),e=c.b+"."+c.c.toString()+"."+c.v.toString());
d=d===e?d:d+"-"+e;null!=a.extra&&(d=a.extra+","+d);null!=c.extra&&(d+=","+c.extra);return d};n.prototype.fix_ps151=function(a,c,d){var e;"default"!==d&&null==(null!=(e=this.translations[d])?e.chapters.Ps151:void 0)&&this.passage.promote_book_to_translation("Ps151",d);if(151===a.c&&"Ps"===a.b){if(151===c.c&&"Ps"===c.b)return a.b="Ps151",a.c=1,c.b="Ps151",c.c=1;a.extra=this.to_osis({b:"Ps151",c:1,v:a.v},{b:"Ps151",c:1,v:this.passage.translations[d].chapters.Ps151[0]},d);a.b="Prov";a.c=1;return a.v=
1}c.extra=this.to_osis({b:"Ps151",c:1,v:1},{b:"Ps151",c:1,v:c.v},d);c.c=150;return c.v=this.passage.translations[d].chapters.Ps[149]};n.prototype.combine_consecutive_passages=function(a,c){var d,e,h,t,q,n,g,w,A,u;w=[];A={};n=a.length-1;d=-1;e=!1;for(h=q=0;0<=n?q<=n:q>=n;h=0<=n?++q:--q)g=a[h],0<g.osis.length?(u=w.length-1,t=!1,g.enclosed_indices[0]!==d&&(d=g.enclosed_indices[0]),0<=d&&(h===n||a[h+1].enclosed_indices[0]!==g.enclosed_indices[0])&&(e=t=!0),this.is_verse_consecutive(A,g.start,c)?(w[u].end=
g.end,w[u].is_enclosed_last=t,w[u].indices[1]=g.indices[1],w[u].enclosed_indices[1]=g.enclosed_indices[1],w[u].osis=this.to_osis(w[u].start,g.end,c)):w.push(g),A={b:g.end.b,c:g.end.c,v:g.end.v}):(w.push(g),A={});e&&this.snap_enclosed_indices(w);return w};n.prototype.snap_enclosed_indices=function(a){var c,d,e;c=0;for(d=a.length;c<d;c++)e=a[c],null!=e.is_enclosed_last&&(0>e.enclosed_indices[0]&&e.is_enclosed_last&&(e.indices[1]=e.enclosed_indices[1]),delete e.is_enclosed_last);return a};n.prototype.is_verse_consecutive=
function(a,c,d){var e;if(null==a.b)return!1;e=null!=this.passage.translations[d].order?this.passage.translations[d].order:this.passage.translations["default"].order;if(a.b===c.b)if(a.c===c.c){if(a.v===c.v-1)return!0}else{if(1===c.v&&a.c===c.c-1&&a.v===this.passage.translations[d].chapters[a.b][a.c-1])return!0}else if(1===c.c&&1===c.v&&e[a.b]===e[c.b]-1&&a.c===this.passage.translations[d].chapters[a.b].length&&a.v===this.passage.translations[d].chapters[a.b][a.c-1])return!0;return!1};n.prototype.snap_range=
function(a,c){var d,e,h,t,q,g;"b_range_start"===a.type||"sequence"===a.type&&"b_range_start"===a.passages[c].type?(d=1,t="end",g="b_range_start"):(d=0,t="start",g="range_end_b");q="end"===t?"start":"end";h=a.passages[c][q];for(e in h)G.call(h,e)&&(a.passages[c][q][e]=a.passages[c][t][e]);"sequence"===a.type?(c>=a.value.length&&(c=a.value.length-1),d=this.passage.pluck(g,a.value[c]),null!=d&&(d=this.snap_range(d,0),0===c?a.absolute_indices[0]=d.absolute_indices[0]:a.absolute_indices[1]=d.absolute_indices[1])):
(a.original_type=a.type,a.type=a.value[d].type,a.absolute_indices=[a.value[d].absolute_indices[0],a.value[d].absolute_indices[1]]);return a};n.prototype.snap_sequence=function(a,c,d,e,h){var t;t=c.passages[e];t.absolute_indices[0]===c.absolute_indices[0]&&e<h-1&&this.get_snap_sequence_i(c.passages,e,h)!==e?(c.absolute_indices[0]=c.passages[e+1].absolute_indices[0],this.remove_absolute_indices(c.passages,e+1)):t.absolute_indices[1]===c.absolute_indices[1]&&0<e?c.absolute_indices[1]=0<d.length?d[d.length-
1].indices[1]:c.passages[e-1].absolute_indices[1]:"book"===a&&e<h-1&&!this.starts_with_book(c.passages[e+1])&&(c.passages[e+1].absolute_indices[0]=t.absolute_indices[0]);return c};n.prototype.get_snap_sequence_i=function(a,c,d){var e,h,t;for(e=h=t=c+1;t<=d?h<d:h>d;e=t<=d?++h:--h){if(this.starts_with_book(a[e]))return e;if(a[e].valid.valid)break}return c};n.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};
n.prototype.remove_absolute_indices=function(a,c){var d,e,h,t,q,g;if(0>a[c].enclosed_absolute_indices[0])return!1;d=a[c].enclosed_absolute_indices;g=d[0];d=d[1];q=a.slice(c);e=0;for(h=q.length;e<h;e++)if(t=q[e],t.enclosed_absolute_indices[0]===g&&t.enclosed_absolute_indices[1]===d)t.enclosed_absolute_indices=[-1,-1];else break;return!0};return n}();ja=function(){function g(){}g.prototype.books=[];g.prototype.indices={};g.prototype.options={};g.prototype.translations={};g.prototype.handle_array=function(a,
c,d){var e,h,t;null==c&&(c=[]);null==d&&(d={});e=0;for(h=a.length;e<h;e++)if(t=a[e],null!=t){if("stop"===t.type)break;d=this.handle_obj(t,c,d);c=d[0];d=d[1]}return[c,d]};g.prototype.handle_obj=function(a,c,d){return null!=a.type&&null!=this[a.type]?this[a.type](a,c,d):[c,d]};g.prototype.b=function(a,c,d){var e,h,t,g,n;a.start_context=u.shallow_clone(d);a.passages=[];d=[];g=this.books[a.value].parsed;h=0;for(t=g.length;h<t;h++)e=g[h],n=this.validate_ref(a.start_context.translations,{b:e}),e={start:{b:e},
end:{b:e},valid:n},0===a.passages.length&&n.valid?a.passages.push(e):d.push(e);0===a.passages.length&&a.passages.push(d.shift());0<d.length&&(a.passages[0].alternates=d);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));c.push(a);d={b:a.passages[0].start.b};null!=a.start_context.translations&&(d.translations=a.start_context.translations);return[c,d]};g.prototype.b_range=
function(a,c,d){return this.range(a,c,d)};g.prototype.b_range_pre=function(a,c,d){var e,h;a.start_context=u.shallow_clone(d);a.passages=[];e=this.pluck("b",a.value);d=this.b(e,[],d);e=d[0][0];d=d[1];null==a.absolute_indices&&(a.absolute_indices=this.get_absolute_indices(a.indices));h={b:a.value[0].value+e.passages[0].start.b.substr(1),type:"b"};a.passages=[{start:h,end:e.passages[0].end,valid:e.passages[0].valid}];null!=a.start_context.translations&&(a.passages[0].translations=a.start_context.translations);
c.push(a);return[c,d]};g.prototype.b_range_start=function(a,c,d){return this.range(a,c,d)};g.prototype.base=function(a,c,d){this.indices=this.calculate_indices(a.match,a.start_index);return this.handle_array(a.value,c,d)};g.prototype.bc=function(a,c,d){var e,h,t,g,n,x,w,A,C;a.start_context=u.shallow_clone(d);a.passages=[];this.reset_context(d,["b","c","v"]);t=this.pluck("c",a.value).value;e=[];A=this.books[this.pluck("b",a.value).value].parsed;n=0;for(x=A.length;n<x;n++)h=A[n],g="c",C=this.validate_ref(a.start_context.translations,
{b:h,c:t}),w={start:{b:h},end:{b:h},valid:C},C.messages.start_chapter_not_exist_in_single_chapter_book&&(w.valid=this.validate_ref(a.start_context.translations,{b:h,v:t}),w.valid.messages.start_chapter_not_exist_in_single_chapter_book=1,w.start.c=1,w.end.c=1,g="v"),w.start[g]=t,h=this.fix_start_zeroes(w.valid,w.start.c,w.start.v),w.start.c=h[0],w.start.v=h[1],null==w.start.v&&delete w.start.v,w.end[g]=w.start[g],0===a.passages.length&&w.valid.valid?a.passages.push(w):e.push(w);0===a.passages.length&&
a.passages.push(e.shift());0<e.length&&(a.passages[0].alternates=e);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(d,["b","c","v"],a.passages[0].start);c.push(a);return[c,d]};g.prototype.bc_title=function(a,c,d){var e,h,t,g;a.start_context=u.shallow_clone(d);d=this.bc(this.pluck("bc",a.value),[],d);e=d[0][0];d=d[1];if("Ps"!==e.passages[0].start.b.substr(0,
2)&&null!=e.passages[0].alternates)for(h=t=0,g=e.passages[0].alternates.length;0<=g?t<g:t>g;h=0<=g?++t:--t)if("Ps"===e.passages[0].alternates[h].start.b.substr(0,2)){e.passages[0]=e.passages[0].alternates[h];break}if("Ps"!==e.passages[0].start.b.substr(0,2))return c.push(e),[c,d];this.books[this.pluck("b",e.value).value].parsed=["Ps"];e=this.pluck("title",a.value);null==e&&(e=this.pluck("v",a.value));a.value[1]={type:"v",value:[{type:"integer",value:1,indices:e.indices}],indices:e.indices};a.type=
"bcv";return this.bcv(a,c,a.start_context)};g.prototype.bcv=function(a,c,d){var e,h,g,q,n,x,w,A;a.start_context=u.shallow_clone(d);a.passages=[];this.reset_context(d,["b","c","v"]);g=this.pluck("bc",a.value);q=this.pluck("c",g.value).value;w=this.pluck("v",a.value).value;e=[];x=this.books[this.pluck("b",g.value).value].parsed;g=0;for(n=x.length;g<n;g++)h=x[g],A=this.validate_ref(a.start_context.translations,{b:h,c:q,v:w}),w=this.fix_start_zeroes(A,q,w),q=w[0],w=w[1],h={start:{b:h,c:q,v:w},end:{b:h,
c:q,v:w},valid:A},0===a.passages.length&&A.valid?a.passages.push(h):e.push(h);0===a.passages.length&&a.passages.push(e.shift());0<e.length&&(a.passages[0].alternates=e);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(d,["b","c","v"],a.passages[0].start);c.push(a);return[c,d]};g.prototype.bv=function(a,c,d){var e;a.start_context=u.shallow_clone(d);
e=a.value;e={indices:a.indices,value:[{type:"bc",value:[e[0],{type:"c",value:[{type:"integer",value:1}]}]},e[1]]};d=this.bcv(e,[],d);e=d[0][0];d=d[1];a.passages=e.passages;null==a.absolute_indices&&(a.absolute_indices=this.get_absolute_indices(a.indices));c.push(a);return[c,d]};g.prototype.c=function(a,c,d){var e,h;a.start_context=u.shallow_clone(d);e="integer"===a.type?a.value:this.pluck("integer",a.value).value;h=this.validate_ref(a.start_context.translations,{b:d.b,c:e});if(!h.valid&&h.messages.start_chapter_not_exist_in_single_chapter_book)return this.v(a,
c,d);e=this.fix_start_zeroes(h,e)[0];a.passages=[{start:{b:d.b,c:e},end:{b:d.b,c:e},valid:h}];null!=a.start_context.translations&&(a.passages[0].translations=a.start_context.translations);c.push(a);d.c=e;this.reset_context(d,["v"]);null==a.absolute_indices&&(a.absolute_indices=this.get_absolute_indices(a.indices));return[c,d]};g.prototype.c_psalm=function(a,c,d){var e;a.type="bc";e=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:e,indices:a.indices}],indices:a.indices}];return this.bc(a,c,d)};g.prototype.c_title=function(a,c,d){a.start_context=u.shallow_clone(d);if("Ps"!==d.b)return this.c(a.value[0],c,d);d=this.pluck("title",a.value);a.value[1]={type:"v",value:[{type:"integer",value:1,indices:d.indices}],indices:d.indices};a.type="cv";return this.cv(a,c,a.start_context)};g.prototype.cv=function(a,c,d){var e,h,g;a.start_context=u.shallow_clone(d);e=this.pluck("c",a.value).value;h=this.pluck("v",
a.value).value;g=this.validate_ref(a.start_context.translations,{b:d.b,c:e,v:h});h=this.fix_start_zeroes(g,e,h);e=h[0];h=h[1];a.passages=[{start:{b:d.b,c:e,v:h},end:{b:d.b,c:e,v:h},valid:g}];null!=a.start_context.translations&&(a.passages[0].translations=a.start_context.translations);c.push(a);d.c=e;d.v=h;null==a.absolute_indices&&(a.absolute_indices=this.get_absolute_indices(a.indices));return[c,d]};g.prototype.cb_range=function(a,c,d){var e,h,g;a.type="range";h=a.value;e=h[0];g=h[1];h=h[2];a.value=
[{type:"bc",value:[e,g],indices:a.indices},h];h.indices[1]=a.indices[1];return this.range(a,c,d)};g.prototype.context=function(a,c,d){var e,h;a.start_context=u.shallow_clone(d);a.passages=[];h=this.books[a.value].context;for(e in h)G.call(h,e)&&(d[e]=this.books[a.value].context[e]);c.push(a);return[c,d]};g.prototype.cv_psalm=function(a,c,d){var e,h;a.start_context=u.shallow_clone(d);a.type="bcv";h=a.value;e=h[0];h=h[1];e=this.c_psalm(e,[],a.start_context)[0][0];a.value=[e,h];return this.bcv(a,c,d)};
g.prototype.ff=function(a,c,d){a.start_context=u.shallow_clone(d);a.value.push({type:"integer",indices:a.indices,value:999});d=this.range(a,[],a.start_context);a=d[0][0];d=d[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;c.push(a);return[c,d]};g.prototype.integer_title=function(a,c,d){a.start_context=u.shallow_clone(d);if("Ps"!==d.b)return this.integer(a.value[0],c,d);a.value[0]={type:"c",value:[a.value[0]],indices:[a.value[0].indices[0],a.value[0].indices[1]]};d=[a.indices[1]-5,a.indices[1]];a.value[1]={type:"v",value:[{type:"integer",value:1,indices:d}],indices:d};a.type="cv";return this.cv(a,c,a.start_context)};g.prototype.integer=function(a,
c,d){return null!=d.v?this.v(a,c,d):this.c(a,c,d)};g.prototype.sequence=function(a,c,d){var e,h,g,q,n,x,w,A;a.start_context=u.shallow_clone(d);a.passages=[];x=a.value;e=0;for(g=x.length;e<g;e++)for(n=x[e],d=this.handle_array(n,[],d),n=d[0],n=n[0],d=d[1],w=n.passages,h=0,q=w.length;h<q;h++)A=w[h],null==A.type&&(A.type=n.type),null==A.absolute_indices&&(A.absolute_indices=n.absolute_indices),null!=n.start_context.translations&&(A.translations=n.start_context.translations),A.enclosed_absolute_indices=
"sequence_post_enclosed"===n.type?n.absolute_indices:[-1,-1],a.passages.push(A);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));c.push(a);return[c,d]};g.prototype.sequence_post_enclosed=function(a,c,d){return this.sequence(a,c,d)};g.prototype.v=function(a,c,d){var e,h,g;h="integer"===a.type?a.value:this.pluck("integer",a.value).value;
a.start_context=u.shallow_clone(d);e=null!=d.c?d.c:1;g=this.validate_ref(a.start_context.translations,{b:d.b,c:e,v:h});h=this.fix_start_zeroes(g,0,h)[1];a.passages=[{start:{b:d.b,c:e,v:h},end:{b:d.b,c:e,v:h},valid:g}];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));c.push(a);d.v=h;return[c,d]};g.prototype.range=function(a,c,d){var e,h,g,q,n,x;a.start_context=u.shallow_clone(d);
e=a.value;x=e[0];e=e[1];d=this.handle_obj(x,[],d);x=d[0][0];d=d[1];if("v"===e.type&&("bc"===x.type&&(null==(h=x.passages)||null==(g=h[0])||null==(q=g.valid)||null==(n=q.messages)||!n.start_chapter_not_exist_in_single_chapter_book)||"c"===x.type)&&"verse"===this.options.end_range_digits_strategy)return a.value[0]=x,this.range_change_integer_end(a,c);d=this.handle_obj(e,[],d);e=d[0][0];d=d[1];a.value=[x,e];a.indices=[x.indices[0],e.indices[1]];delete a.absolute_indices;g={b:x.passages[0].start.b,c:x.passages[0].start.c,
v:x.passages[0].start.v,type:x.type};h={b:e.passages[0].end.b,c:e.passages[0].end.c,v:e.passages[0].end.v,type:e.type};e.passages[0].valid.messages.start_chapter_is_zero&&(h.c=0);e.passages[0].valid.messages.start_verse_is_zero&&(h.v=0);q=this.validate_ref(a.start_context.translations,g,h);if(q.valid){if(e=this.range_handle_valid(q,a,x,g,e,h,c),x=e[0],e=e[1],x)return e}else return this.range_handle_invalid(q,a,x,g,e,h,c);null==a.absolute_indices&&(a.absolute_indices=this.get_absolute_indices(a.indices));
a.passages=[{start:g,end:h,valid:q}];null!=a.start_context.translations&&(a.passages[0].translations=a.start_context.translations);"b"===g.type?a.type="b"===h.type?"b_range":"b_range_start":"b"===h.type&&(a.type="range_end_b");c.push(a);return[c,d]};g.prototype.range_change_end=function(a,c,d){var e;e=a.value[1];"integer"===e.type?(e.original_value=e.value,e.value=d):"v"===e.type?(e=this.pluck("integer",e.value),e.original_value=e.value,e.value=d):"cv"===e.type&&(e=this.pluck("c",e.value),e.original_value=
e.value,e.value=d);return this.handle_obj(a,c,a.start_context)};g.prototype.range_change_integer_end=function(a,c){var d,e;d=a.value;e=d[0];d=d[1];null==a.original_type&&(a.original_type=a.type);null==a.original_value&&(a.original_value=[e,d]);a.type="integer"===e.type?"cv":e.type+"v";"integer"===e.type&&(a.value[0]={type:"c",value:[e],indices:e.indices});"integer"===d.type&&(a.value[1]={type:"v",value:[d],indices:d.indices});return this.handle_obj(a,c,a.start_context)};g.prototype.range_check_new_end=
function(a,c,d,e){var h,g;h=0;g=null;e.messages.end_chapter_before_start?g="c":e.messages.end_verse_before_start&&(g="v");null!=g&&(h=this.range_get_new_end_value(c,d,e,g));0<h&&(c={b:d.b,c:d.c,v:d.v},c[g]=h,a=this.validate_ref(a,c),a.valid||(h=0));return h};g.prototype.range_end_b=function(a,c,d){return this.range(a,c,d)};g.prototype.range_get_new_end_value=function(a,c,d,e){var h;h=0;if("c"===e&&d.messages.end_chapter_is_zero||"v"===e&&d.messages.end_verse_is_zero)return h;10<=a[e]&&10>c[e]&&a[e]-
10*Math.floor(a[e]/10)<c[e]?h=c[e]+10*Math.floor(a[e]/10):100<=a[e]&&100>c[e]&&a[e]-100<c[e]&&(h=c[e]+100);return h};g.prototype.range_handle_invalid=function(a,c,d,e,h,g,q){if(!1===a.valid&&(a.messages.end_chapter_before_start||a.messages.end_verse_before_start)&&("integer"===h.type||"v"===h.type)||!1===a.valid&&a.messages.end_chapter_before_start&&"cv"===h.type)if(a=this.range_check_new_end(c.start_context.translations,e,g,a),0<a)return this.range_change_end(c,q,a);if("verse"===this.options.end_range_digits_strategy&&
null==e.v&&("integer"===h.type||"v"===h.type)&&(a="v"===h.type?this.pluck("integer",h.value):h.value,e=this.validate_ref(c.start_context.translations,{b:e.b,c:e.c,v:a}),e.valid))return this.range_change_integer_end(c,q);null==c.original_type&&(c.original_type=c.type);c.type="sequence";d=[[d,h],[[d],[h]]];c.original_value=d[0];c.value=d[1];return this.sequence(c,q,c.start_context)};g.prototype.range_handle_valid=function(a,c,d,e,h,g,q){if(a.messages.end_chapter_not_exist&&"verse"===this.options.end_range_digits_strategy&&
null==e.v&&("integer"===h.type||"v"===h.type)&&0<=this.options.passage_existence_strategy.indexOf("v")&&(d="v"===h.type?this.pluck("integer",h.value):h.value,d=this.validate_ref(c.start_context.translations,{b:e.b,c:e.c,v:d}),d.valid))return[!0,this.range_change_integer_end(c,q)];this.range_validate(a,e,g,c);return[!1,null]};g.prototype.range_validate=function(a,c,d,e){a.messages.end_chapter_not_exist||a.messages.end_chapter_not_exist_in_single_chapter_book?(d.original_c=d.c,d.c=a.messages.end_chapter_not_exist?
a.messages.end_chapter_not_exist:a.messages.end_chapter_not_exist_in_single_chapter_book,null!=d.v&&(d.v=this.validate_ref(e.start_context.translations,{b:d.b,c:d.c,v:999}).messages.end_verse_not_exist,delete a.messages.end_verse_is_zero)):a.messages.end_verse_not_exist&&(d.original_v=d.v,d.v=a.messages.end_verse_not_exist);a.messages.end_verse_is_zero&&"allow"!==this.options.zero_verse_strategy&&(d.v=a.messages.end_verse_is_zero);a.messages.end_chapter_is_zero&&(d.c=a.messages.end_chapter_is_zero);
a=this.fix_start_zeroes(a,c.c,c.v);c.c=a[0];c.v=a[1];return!0};g.prototype.translation_sequence=function(a,c,d){var e,h,g,q,n;a.start_context=u.shallow_clone(d);q=[];q.push({translation:this.books[a.value[0].value].parsed});g=a.value[1];e=0;for(h=g.length;e<h;e++)n=g[e],n=this.books[this.pluck("translation",n).value].parsed,null!=n&&q.push({translation:n});e=0;for(h=q.length;e<h;e++)g=q[e],null!=this.translations.aliases[g.translation]?(g.alias=this.translations.aliases[g.translation].alias,g.osis=
this.translations.aliases[g.translation].osis||""):(g.alias="default",g.osis=g.translation.toUpperCase());0<c.length&&(d=this.translation_sequence_apply(c,q));null==a.absolute_indices&&(a.absolute_indices=this.get_absolute_indices(a.indices));c.push(a);this.reset_context(d,["translations"]);return[c,d]};g.prototype.translation_sequence_apply=function(a,c){var d,e,h,g;g=0;for(d=e=h=a.length-1;0>=h?0>=e:0<=e;d=0>=h?++e:--e)if(null!=a[d].original_type&&(a[d].type=a[d].original_type),null!=a[d].original_value&&
(a[d].value=a[d].original_value),"translation_sequence"===a[d].type){g=d+1;break}g<a.length?(a[g].start_context.translations=c,d=this.handle_array(a.slice(g),[],a[g].start_context),d=d[1]):d=u.shallow_clone(a[a.length-1].start_context);return d};g.prototype.pluck=function(a,c){var d,e,h;d=0;for(e=c.length;d<e;d++)if(h=c[d],null!=h&&null!=h.type&&h.type===a)return"c"===a||"v"===a?this.pluck("integer",h.value):h;return null};g.prototype.set_context_from_object=function(a,c,d){var e,h,g,q;g=[];e=0;for(h=
c.length;e<h;e++)q=c[e],null!=d[q]&&g.push(a[q]=d[q]);return g};g.prototype.reset_context=function(a,c){var d,e,h,g;h=[];d=0;for(e=c.length;d<e;d++)g=c[d],h.push(delete a[g]);return h};g.prototype.fix_start_zeroes=function(a,c,d){a.messages.start_chapter_is_zero&&"upgrade"===this.options.zero_chapter_strategy&&(c=a.messages.start_chapter_is_zero);a.messages.start_verse_is_zero&&"upgrade"===this.options.zero_verse_strategy&&(d=a.messages.start_verse_is_zero);return[c,d]};g.prototype.calculate_indices=
function(a,c){var d,e,h,g,q,n,x,w,u,C,O,J;O="book";e=[];x=0;c=parseInt(c,10);u=[a];C=["\u001e","\u001f"];h=0;for(q=C.length;h<q;h++){d=C[h];J=[];g=0;for(n=u.length;g<n;g++)w=u[g],J=J.concat(w.split(d));u=J}g=0;for(h=u.length;g<h;g++)w=u[g],O="book"===O?"rest":"book",q=w.length,0!==q&&("book"===O?(w=w.replace(/\/\d+$/,""),d=x+q,0<e.length&&e[e.length-1].index===c?e[e.length-1].end=d:e.push({start:x,end:d,index:c}),x+=q+2,c=this.books[w].start_index+this.books[w].value.length-x,e.push({start:d+1,end:d+
1,index:c})):(d=x+q-1,0<e.length&&e[e.length-1].index===c?e[e.length-1].end=d:e.push({start:x,end:d,index:c}),x+=q));return e};g.prototype.get_absolute_indices=function(a){var c,d,e,h,g,q,n;q=a[0];a=a[1];c=n=null;g=this.indices;e=0;for(h=g.length;e<h;e++)if(d=g[e],null===n&&d.start<=q&&q<=d.end&&(n=q+d.index),d.start<=a&&a<=d.end){c=a+d.index+1;break}return[n,c]};g.prototype.validate_ref=function(a,c,d){var e,h,g,q,n,x;null!=a&&0<a.length||(a=[{translation:"default",osis:"",alias:"default"}]);x=!1;
g={};e=0;for(h=a.length;e<h;e++)n=a[e],null==n.alias&&(n.alias="default"),null==n.alias?(null==g.translation_invalid&&(g.translation_invalid=[]),g.translation_invalid.push(n)):(null==this.translations.aliases[n.alias]&&(n.alias="default",null==g.translation_unknown&&(g.translation_unknown=[]),g.translation_unknown.push(n)),q=this.validate_start_ref(n.alias,c,g)[0],d&&(q=this.validate_end_ref(n.alias,c,d,q,g)[0]),!0===q&&(x=!0));return{valid:x,messages:g}};g.prototype.validate_start_ref=function(a,
c,d){var e,g,n;n=!0;"default"!==a&&null==(null!=(e=this.translations[a])?e.chapters[c.b]:void 0)&&this.promote_book_to_translation(c.b,a);e=null!=(null!=(g=this.translations[a])?g.order:void 0)?a:"default";null!=c.v&&(c.v=parseInt(c.v,10));if(null!=this.translations[e].order[c.b]){null==c.c&&(c.c=1);c.c=parseInt(c.c,10);if(isNaN(c.c))return d.start_chapter_not_numeric=!0,[!1,d];0===c.c&&(d.start_chapter_is_zero=1,"error"===this.options.zero_chapter_strategy?n=!1:c.c=1);null!=c.v&&0===c.v&&(d.start_verse_is_zero=
1,"error"===this.options.zero_verse_strategy?n=!1:"upgrade"===this.options.zero_verse_strategy&&(c.v=1));0<c.c&&null!=this.translations[a].chapters[c.b][c.c-1]?null!=c.v&&(isNaN(c.v)?(n=!1,d.start_verse_not_numeric=!0):c.v>this.translations[a].chapters[c.b][c.c-1]&&0<=this.options.passage_existence_strategy.indexOf("v")&&(n=!1,d.start_verse_not_exist=this.translations[a].chapters[c.b][c.c-1])):1!==c.c&&1===this.translations[a].chapters[c.b].length?(n=!1,d.start_chapter_not_exist_in_single_chapter_book=
1):0<c.c&&0<=this.options.passage_existence_strategy.indexOf("c")&&(n=!1,d.start_chapter_not_exist=this.translations[a].chapters[c.b].length)}else 0<=this.options.passage_existence_strategy.indexOf("b")&&(n=!1),d.start_book_not_exist=!0;return[n,d]};g.prototype.validate_end_ref=function(a,c,d,e,g){var n,q;q=null!=(null!=(n=this.translations[a])?n.order:void 0)?a:"default";null!=d.c&&(d.c=parseInt(d.c,10),isNaN(d.c)?(e=!1,g.end_chapter_not_numeric=!0):0===d.c&&(g.end_chapter_is_zero=1,"error"===this.options.zero_chapter_strategy?
e=!1:d.c=1));null!=d.v&&(d.v=parseInt(d.v,10),isNaN(d.v)?(e=!1,g.end_verse_not_numeric=!0):0===d.v&&(g.end_verse_is_zero=1,"error"===this.options.zero_verse_strategy?e=!1:"upgrade"===this.options.zero_verse_strategy&&(d.v=1)));null!=this.translations[q].order[d.b]?(null==d.c&&1===this.translations[a].chapters[d.b].length&&(d.c=1),null!=this.translations[q].order[c.b]&&this.translations[q].order[c.b]>this.translations[q].order[d.b]&&(0<=this.options.passage_existence_strategy.indexOf("b")&&(e=!1),
g.end_book_before_start=!0),c.b!==d.b||null==d.c||isNaN(d.c)||(null==c.c&&(c.c=1),!isNaN(parseInt(c.c,10))&&c.c>d.c?(e=!1,g.end_chapter_before_start=!0):c.c!==d.c||null==d.v||isNaN(d.v)||(null==c.v&&(c.v=1),!isNaN(parseInt(c.v,10))&&c.v>d.v&&(e=!1,g.end_verse_before_start=!0))),null==d.c||isNaN(d.c)||null!=this.translations[a].chapters[d.b][d.c-1]||(1===this.translations[a].chapters[d.b].length?g.end_chapter_not_exist_in_single_chapter_book=1:0<d.c&&0<=this.options.passage_existence_strategy.indexOf("c")&&
(g.end_chapter_not_exist=this.translations[a].chapters[d.b].length)),null==d.v||isNaN(d.v)||(null==d.c&&(d.c=this.translations[a].chapters[d.b].length),d.v>this.translations[a].chapters[d.b][d.c-1]&&0<=this.options.passage_existence_strategy.indexOf("v")&&(g.end_verse_not_exist=this.translations[a].chapters[d.b][d.c-1]))):(e=!1,g.end_book_not_exist=!0);return[e,g]};g.prototype.promote_book_to_translation=function(a,c){var d;null==(d=this.translations)[c]&&(d[c]={});null==(d=this.translations[c]).chapters&&
(d.chapters={});if(null==this.translations[c].chapters[a])return this.translations[c].chapters[a]=u.shallow_clone_array(this.translations["default"].chapters[a])};return g}();u={shallow_clone:function(g){var a,c,d;if(null==g)return g;c={};for(a in g)G.call(g,a)&&(d=g[a],c[a]=d);return c},shallow_clone_array:function(g){var a,c,d,e;if(null==g)return g;d=[];a=c=0;for(e=g.length;0<=e?c<=e:c>=e;a=0<=e?++c:--c)"undefined"!==typeof g[a]&&(d[a]=g[a]);return d}};g.prototype.regexps.translations=/(?:(?:A(?:MP|SV)|KJV|TNIV|MSG|HCSB|RSV|N(?:A(?:B(?:RE)?|SB?)|I(?:RV|V)|KJV|LT|RSV)|E[RS]V|CE[BV]))\b/gi;
g.prototype.translations={aliases:{ceb:{osis:"CEB",alias:"ceb"},kjv:{osis:"KJV",alias:"kjv"},nab:{osis:"NAB",alias:"nab"},nabre:{osis:"NABRE",alias:"nab"},nas:{osis:"NASB",alias:"default"},nirv:{osis:"NIRV",alias:"kjv"},niv:{osis:"NIV",alias:"kjv"},nkjv:{osis:"NKJV",alias:"nkjv"},nlt:{osis:"NLT",alias:"nlt"},nrsv:{osis:"NRSV",alias:"nrsv"},tniv:{osis:"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:{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,19,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,20,14,9,7]}},ceb:{chapters:{"2Cor":[24,17,18,18,21,18,16,24,15,18,33,21,13],Rev:[20,29,22,11,14,17,17,13,21,11,19,18,18,20,8,21,18,24,21,15,27,21],Tob:[22,14,17,21,22,18,16,21,6,13,18,22,18,15],PrAzar:[67],EpJer:[72],"1Esd":[55,
26,24,63,71,33,15,92,55]}},kjv:{chapters:{"3John":[14]}},nab:{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,PrMan:15,Ezra:16,Neh:17,"1Esd":18,"2Esd":19,Tob:20,Jdt:21,Esth:22,GkEsth:23,"1Macc":24,"2Macc":25,"3Macc":26,"4Macc":27,Job:28,Ps:29,Prov:30,Eccl:31,Song:32,Wis:33,Sir:34,Isa:35,Jer:36,Lam:37,Bar:38,EpJer:39,Ezek:40,Dan:41,PrAzar:42,Sus:43,Bel:44,SgThree:45,Hos:46,Joel:47,Amos:48,Obad:49,Jonah:50,Mic:51,Nah:52,Hab:53,Zeph:54,
Hag:55,Zech:56,Mal:57,Matt:58,Mark:59,Luke:60,John:61,Acts:62,Rom:63,"1Cor":64,"2Cor":65,Gal:66,Eph:67,Phil:68,Col:69,"1Thess":70,"2Thess":71,"1Tim":72,"2Tim":73,Titus:74,Phlm:75,Heb:76,Jas:77,"1Pet":78,"2Pet":79,"1John":80,"2John":81,"3John":82,Jude:83,Rev: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,54,33,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,29,28,35,29,10,51,22,31,27,36,16,27,25,26,37,30,33,
18,40,37,21,43,46,38,18,35,23,35,35,38,29,31,43,38],Lev:[17,16,17,35,26,23,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,35,28,32,22,29,35,41,30,25,19,65,23,31,39,17,54,42,56,29,34,13],Deut:[46,37,29,49,33,25,26,20,29,22,32,31,19,29,23,22,20,22,21,20,23,29,26,22,19,19,26,69,28,20,30,52,29,12],"1Sam":[28,36,21,22,12,21,17,22,27,27,15,25,23,52,35,23,58,30,24,42,16,23,28,23,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,32,44,26,22,51,39,25],"1Kgs":[53,46,28,20,32,38,51,66,28,29,43,33,34,31,34,34,24,46,21,43,29,54],"2Kgs":[18,25,27,44,27,33,20,29,37,36,20,22,25,29,38,20,41,37,37,21,26,20,37,20,30],"1Chr":[54,55,24,43,41,66,40,40,44,14,47,41,14,17,29,43,27,17,19,8,30,19,32,31,31,32,34,21,30],"2Chr":[18,17,17,22,14,42,22,18,31,19,23,16,23,14,19,14,19,34,11,37,20,12,21,27,28,23,9,27,36,27,21,33,25,33,27,23],Neh:[11,20,38,17,19,19,72,18,37,40,36,47,31],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,32,26,17],Ps:[6,11,9,9,13,11,18,10,21,18,7,9,6,7,5,11,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,27,18,12,10,15,21,23,21,11,7,9,24,14,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,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,14,10,8,12,15,21,10,20,14,9,6],Eccl:[18,
26,22,17,19,12,29,17,18,20,10,14],Song:[17,17,11,16,16,12,14,14],Isa:[31,22,26,6,30,13,25,23,20,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,11,25,24],Jer:[19,37,25,31,31,30,34,23,25,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],Ezek:[28,10,27,17,17,14,27,18,11,22,25,28,23,23,8,63,24,32,14,44,37,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,100,34,30,29,28,27,27,21,45,13,64,42],Hos:[9,25,5,19,15,11,16,14,17,15,11,15,15,10],Joel:[20,27,5,21],Jonah:[16,11,10,11],Mic:[16,13,12,14,14,16,20],Nah:[14,14,19],Zech:[17,17,10,14,11,15,14,23,17,12,17,14,9,21],Mal:[14,17,24],Acts:[26,47,26,37,42,