bible-ref-parse
Version:
Identifies and parses Bible references (like John 3:16) in over 40 languages.
1 lines • 114 kB
JavaScript
(function(){var s,e,a,t,i={}.hasOwnProperty;s=function(){class s{constructor(){var e,a,t;for(e in this.options={},a=s.prototype.options)i.call(a,e)&&(t=a[e],this.options[e]=t);this.versification_system(this.options.versification_system)}parse(s){return this.reset(),this.s=s,s=this.replace_control_characters(s),[s,this.passage.books]=this.match_books(s),[this.entities]=this.match_passages(s),this}parse_with_context(s,e){var a;return this.reset(),[e,this.passage.books]=this.match_books(this.replace_control_characters(e)),[a,e]=this.match_passages(e),this.reset(),this.s=s,s=this.replace_control_characters(s),[s,this.passage.books]=this.match_books(s),this.passage.books.push({value:"",parsed:[],start_index:0,type:"context",context:e}),s=""+(this.passage.books.length-1)+"/9"+s,[this.entities]=this.match_passages(s),this}reset(){return this.s="",this.entities=[],this.passage?(this.passage.books=[],this.passage.indices={}):(this.passage=new e,this.passage.options=this.options,this.passage.translations=this.translations)}set_options(s){var e,a;for(e in s)i.call(s,e)&&(a=s[e],"include_apocrypha"===e||"versification_system"===e||"case_sensitive"===e?this[e](a):this.options[e]=a);return this}include_apocrypha(s){var e,t,r,n,o;if(null==s||!0!==s&&!1!==s)return this;for(n in this.options.include_apocrypha=s,this.regexps.books=this.regexps.get_books(s,this.options.case_sensitive),r=this.translations)i.call(r,n)&&"aliases"!==n&&"alternates"!==n&&(null==(e=this.translations[n]).chapters&&(e.chapters={}),null==(t=this.translations[n].chapters).Ps&&(t.Ps=a.shallow_clone_array(this.translations.default.chapters.Ps)),!0===s?(o=null!=this.translations[n].chapters.Ps151?this.translations[n].chapters.Ps151[0]:this.translations.default.chapters.Ps151[0],this.translations[n].chapters.Ps[150]=o):151===this.translations[n].chapters.Ps.length&&this.translations[n].chapters.Ps.pop());return this}versification_system(s){var e,t,r,n,o,l,u;if(null==s||null==this.translations[s])return this;if(null!=this.translations.alternates.default)if("default"===s)for(n in null!=this.translations.alternates.default.order&&(this.translations.default.order=a.shallow_clone(this.translations.alternates.default.order)),l=this.translations.alternates.default.chapters)i.call(l,n)&&(o=l[n],this.translations.default.chapters[n]=a.shallow_clone_array(o));else this.versification_system("default");if(null==(e=this.translations.alternates).default&&(e.default={order:null,chapters:{}}),"default"!==s&&null!=this.translations[s].order&&(null==(t=this.translations.alternates.default).order&&(t.order=a.shallow_clone(this.translations.default.order)),this.translations.default.order=a.shallow_clone(this.translations[s].order)),"default"!==s&&null!=this.translations[s].chapters)for(n in u=this.translations[s].chapters)i.call(u,n)&&(o=u[n],null==(r=this.translations.alternates.default.chapters)[n]&&(r[n]=a.shallow_clone_array(this.translations.default.chapters[n])),this.translations.default.chapters[n]=a.shallow_clone_array(o));return this.options.versification_system=s,this.include_apocrypha(this.options.include_apocrypha),this}case_sensitive(s){return null==s||"none"!==s&&"books"!==s||s===this.options.case_sensitive||(this.options.case_sensitive=s,this.regexps.books=this.regexps.get_books(this.options.include_apocrypha,s)),this}translation_info(s="default"){var e,t,r,n,o,l,u,x;for(e in null!=s&&null!=(null!=(l=this.translations.aliases[s])?l.alias:void 0)&&(s=this.translations.aliases[s].alias),null!=s&&null!=this.translations[s]||(s="default"),s!==(n=this.options.versification_system)&&this.versification_system(s),o={alias:s,books:[],chapters:{},order:a.shallow_clone(this.translations.default.order)},u=this.translations.default.chapters)i.call(u,e)&&(t=u[e],o.chapters[e]=a.shallow_clone_array(t));for(e in x=o.order)i.call(x,e)&&(r=x[e],o.books[r-1]=e);return s!==n&&this.versification_system(n),o}replace_control_characters(s){return s=s.replace(this.regexps.control," "),"replace"===this.options.non_latin_digits_strategy&&(s=(s=(s=(s=(s=(s=(s=(s=(s=(s=s.replace(/[٠۰߀०০੦૦୦0౦೦൦๐໐༠၀႐០᠐᥆᧐᪀᪐᭐᮰᱀᱐꘠꣐꤀꧐꩐꯰0]/g,"0")).replace(/[١۱߁१১੧૧୧௧౧೧൧๑໑༡၁႑១᠑᥇᧑᪁᪑᭑᮱᱁᱑꘡꣑꤁꧑꩑꯱1]/g,"1")).replace(/[٢۲߂२২੨૨୨௨౨೨൨๒໒༢၂႒២᠒᥈᧒᪂᪒᭒᮲᱂᱒꘢꣒꤂꧒꩒꯲2]/g,"2")).replace(/[٣۳߃३৩੩૩୩௩౩೩൩๓໓༣၃႓៣᠓᥉᧓᪃᪓᭓᮳᱃᱓꘣꣓꤃꧓꩓꯳3]/g,"3")).replace(/[٤۴߄४৪੪૪୪௪౪೪൪๔໔༤၄႔៤᠔᥊᧔᪄᪔᭔᮴᱄᱔꘤꣔꤄꧔꩔꯴4]/g,"4")).replace(/[٥۵߅५৫੫૫୫௫౫೫൫๕໕༥၅႕៥᠕᥋᧕᪅᪕᭕᮵᱅᱕꘥꣕꤅꧕꩕꯵5]/g,"5")).replace(/[٦۶߆६৬੬૬୬௬౬೬൬๖໖༦၆႖៦᠖᥌᧖᪆᪖᭖᮶᱆᱖꘦꣖꤆꧖꩖꯶6]/g,"6")).replace(/[٧۷߇७৭੭૭୭௭౭೭൭๗໗༧၇႗៧᠗᥍᧗᪇᪗᭗᮷᱇᱗꘧꣗꤇꧗꩗꯷7]/g,"7")).replace(/[٨۸߈८৮੮૮୮௮౮೮൮๘໘༨၈႘៨᠘᥎᧘᪈᪘᭘᮸᱈᱘꘨꣘꤈꧘꩘꯸8]/g,"8")).replace(/[٩۹߉९৯੯૯୯௯౯೯൯๙໙༩၉႙៩᠙᥏᧙᪉᪙᭙᮹᱉᱙꘩꣙꤉꧙꩙꯹9]/g,"9")),s}match_books(s){var e,a,t,i,r,n;for(a=[],i=0,r=(n=this.regexps.books).length;i<r&&(e=n[i],t=!1,s=s.replace(e.regexp,(function(s,i,r){var n;return t=!0,a.push({value:r,parsed:e.osis,type:"book"}),n=null!=e.extra?`/${e.extra}`:"",`${i}${a.length-1}${n}`})),!0!==t||!/^[\s\x1f\d:.,;\-\u2013\u2014]+$/.test(s));i++);return[s=s.replace(this.regexps.translations,(function(s){return a.push({value:s,parsed:s.toLowerCase(),type:"translation"}),`${a.length-1}`})),this.get_book_indices(a,s)]}get_book_indices(s,e){var a,t,i;for(a=0,i=/([\x1f\x1e])(\d+)(?:\/\d+)?\1/g;t=i.exec(e);)s[t[2]].start_index=t.index+a,a+=s[t[2]].value.length-t[0].length;return s}match_passages(s){var e,a,i,r,n,o,l,u,x,c,p,g;for(i=[],c={};n=this.regexps.escaped_passage.exec(s);)[r,u,a]=n,l=u.length,n.index+=r.length-l,/\s[2-9]\d\d\s*$|\s\d{4,}\s*$/.test(u)&&(u=u.replace(/\s+\d+\s*$/,"")),/[\d\x1f\x1e)]$/.test(u)||(u=this.replace_match_end(u)),"delete"===this.options.captive_end_digits_strategy&&(o=n.index+u.length,s.length>o&&/^\w/.test(s.substr(o,1))&&(u=u.replace(/[\s*]+\d+$/,"")),u=u.replace(/(\x1e[)\]]?)[\s*]*\d+$/,"$1")),g=""===(u=u.replace(/[A-Z]+/g,(function(s){return s.toLowerCase()}))).substr(0,1)?0:u.split("")[0].length,x={value:t.parse(u,{punctuation_strategy:this.options.punctuation_strategy}),type:"base",start_index:this.passage.books[a].start_index-g,match:u},"full"===this.options.book_alone_strategy&&"include"===this.options.book_range_strategy&&"b"===x.value[0].type&&(1===x.value.length||x.value.length>1&&"translation_sequence"===x.value[1].type)&&0===g&&(1===this.passage.books[a].parsed.length||this.passage.books[a].parsed.length>1&&"translation"===this.passage.books[a].parsed[1].type)&&/^[234]/.test(this.passage.books[a].parsed[0])&&this.create_book_range(s,x,a),[e,c]=this.passage.handle_obj(x),i=i.concat(e),(p=this.adjust_regexp_end(e,l,u.length))>0&&(this.regexps.escaped_passage.lastIndex-=p);return[i,c]}adjust_regexp_end(s,e,a){var t;return t=0,s.length>0?t=e-s[s.length-1].indices[1]-1:e!==a&&(t=e-a),t}replace_match_end(s){var e,a;for(a=s.length;e=this.regexps.match_end_split.exec(s);)a=e.index+e[0].length;return a<s.length&&(s=s.substr(0,a)),s}create_book_range(e,a,t){var i,r,n,o,l,u,x;for(i=[s.prototype.regexps.first,s.prototype.regexps.second,s.prototype.regexps.third],r=n=1,x=o=parseInt(this.passage.books[t].parsed[0].substr(0,1),10);1<=x?n<x:n>x;r=1<=x?++n:--n)if(u=r===o-1?s.prototype.regexps.range_and:s.prototype.regexps.range_only,null!=(l=e.match(RegExp(`(?:^|\\W)(${i[r-1]}\\s*${u}\\s*)\\x1f${t}\\x1f`,"i"))))return this.add_book_range_object(a,l,r);return!1}add_book_range_object(s,e,a){var t,i,r,n,o,l;if(r=e[1].length,s.value[0]={type:"b_range_pre",value:[{type:"b_pre",value:a.toString(),indices:[e.index,e.index+r]},s.value[0]],indices:[0,s.value[0].indices[1]+r]},s.value[0].value[1].indices[0]+=r,s.value[0].value[1].indices[1]+=r,s.start_index-=r,s.match=e[1]+s.match,1!==s.value.length){for(l=[],t=i=1,n=s.value.length;1<=n?i<n:i>n;t=1<=n?++i:--i)null!=s.value[t].value&&(null!=(null!=(o=s.value[t].value[0])?o.indices:void 0)&&(s.value[t].value[0].indices[0]+=r,s.value[t].value[0].indices[1]+=r),s.value[t].indices[0]+=r,l.push(s.value[t].indices[1]+=r));return l}}osis(){var s,e,a,t,i;for(t=[],s=0,e=(i=this.parsed_entities()).length;s<e;s++)(a=i[s]).osis.length>0&&t.push(a.osis);return t.join(",")}osis_and_translations(){var s,e,a,t,i;for(t=[],s=0,e=(i=this.parsed_entities()).length;s<e;s++)(a=i[s]).osis.length>0&&t.push([a.osis,a.translations.join(",")]);return t}osis_and_indices(){var s,e,a,t,i;for(t=[],s=0,e=(i=this.parsed_entities()).length;s<e;s++)(a=i[s]).osis.length>0&&t.push({osis:a.osis,translations:a.translations,indices:a.indices});return t}parsed_entities(){var s,e,a,t,i,r,n,o,l,u,x,c,p,g,h,d,_,f,v,b,y,z,w,k;for(g=[],e=t=0,d=this.entities.length;0<=d?t<d:t>d;e=0<=d?++t:--t)if((s=this.entities[e]).type&&"translation_sequence"===s.type&&g.length>0&&e===g[g.length-1].entity_id+1&&(g[g.length-1].indices[1]=s.absolute_indices[1]),null!=s.passages&&!("b"===s.type&&"ignore"===this.options.book_alone_strategy||"b_range"===s.type&&"ignore"===this.options.book_range_strategy||"context"===s.type)){if(k=[],z=null,null!=s.passages[0].translations)for(i=0,n=(_=s.passages[0].translations).length;i<n;i++)w=(null!=(f=(y=_[i]).osis)?f.length:void 0)>0?y.osis:"",null==z&&(z=y.alias),k.push(w);else k=[""],z="default";for(p=[],a=u=0,v=l=s.passages.length;0<=v?u<v:u>v;a=0<=v?++u:--u)null==(h=s.passages[a]).type&&(h.type=s.type),!1===h.valid.valid&&("ignore"===this.options.invalid_sequence_strategy&&"sequence"===s.type&&this.snap_sequence("ignore",s,p,a,l),"ignore"===this.options.invalid_passage_strategy)||("b"!==h.type&&"b_range"!==h.type||"ignore"!==this.options.book_sequence_strategy||"sequence"!==s.type?("b_range_start"!==h.type&&"range_end_b"!==h.type||"ignore"!==this.options.book_range_strategy||this.snap_range(s,a),null==h.absolute_indices&&(h.absolute_indices=s.absolute_indices),p.push({osis:h.valid.valid?this.to_osis(h.start,h.end,z):"",type:h.type,indices:h.absolute_indices,translations:k,start:h.start,end:h.end,enclosed_indices:h.enclosed_absolute_indices,entity_id:e,entities:[h]})):this.snap_sequence("book",s,p,a,l));if(0!==p.length)if(p.length>1&&"combine"===this.options.consecutive_combination_strategy&&(p=this.combine_consecutive_passages(p,z)),"separate"===this.options.sequence_combination_strategy)g=g.concat(p);else{for(b=[],null!=p[r=p.length-1].enclosed_indices&&p[r].enclosed_indices[1]>=0&&(s.absolute_indices[1]=p[r].enclosed_indices[1]),x=0,o=p.length;x<o;x++)(c=p[x]).osis.length>0&&b.push(c.osis);g.push({osis:b.join(","),indices:s.absolute_indices,translations:k,entity_id:e,entities:p})}}return g}to_osis(s,e,a){var t,i;return null==e.c&&null==e.v&&s.b===e.b&&null==s.c&&null==s.v&&"first_chapter"===this.options.book_alone_strategy&&(e.c=1),t={start:"",end:""},null==s.c&&(s.c=1),null==s.v&&(s.v=1),null==e.c&&(this.options.passage_existence_strategy.indexOf("c")>=0||null!=this.passage.translations[a].chapters[e.b]&&1===this.passage.translations[a].chapters[e.b].length?e.c=this.passage.translations[a].chapters[e.b].length:e.c=999),null==e.v&&(null!=this.passage.translations[a].chapters[e.b][e.c-1]&&this.options.passage_existence_strategy.indexOf("v")>=0?e.v=this.passage.translations[a].chapters[e.b][e.c-1]:e.v=999),this.options.include_apocrypha&&"b"===this.options.ps151_strategy&&(151===s.c&&"Ps"===s.b||151===e.c&&"Ps"===e.b)&&this.fix_ps151(s,e,a),"b"===this.options.osis_compaction_strategy&&1===s.c&&1===s.v&&(999===e.c&&999===e.v||e.c===this.passage.translations[a].chapters[e.b].length&&this.options.passage_existence_strategy.indexOf("c")>=0&&(999===e.v||e.v===this.passage.translations[a].chapters[e.b][e.c-1]&&this.options.passage_existence_strategy.indexOf("v")>=0))?(t.start=s.b,t.end=e.b):this.options.osis_compaction_strategy.length<=2&&1===s.v&&(999===e.v||e.v===this.passage.translations[a].chapters[e.b][e.c-1]&&this.options.passage_existence_strategy.indexOf("v")>=0)?(t.start=s.b+"."+s.c.toString(),t.end=e.b+"."+e.c.toString()):(t.start=s.b+"."+s.c.toString()+"."+s.v.toString(),t.end=e.b+"."+e.c.toString()+"."+e.v.toString()),i=t.start===t.end?t.start:t.start+"-"+t.end,null!=s.extra&&(i=s.extra+","+i),null!=e.extra&&(i+=","+e.extra),i}fix_ps151(s,e,a){var t;return"default"!==a&&null==(null!=(t=this.translations[a])?t.chapters.Ps151:void 0)&&this.passage.promote_book_to_translation("Ps151",a),151===s.c&&"Ps"===s.b?151===e.c&&"Ps"===e.b?(s.b="Ps151",s.c=1,e.b="Ps151",e.c=1):(s.extra=this.to_osis({b:"Ps151",c:1,v:s.v},{b:"Ps151",c:1,v:this.passage.translations[a].chapters.Ps151[0]},a),s.b="Prov",s.c=1,s.v=1):(e.extra=this.to_osis({b:"Ps151",c:1,v:1},{b:"Ps151",c:1,v:e.v},a),e.c=150,e.v=this.passage.translations[a].chapters.Ps[149])}combine_consecutive_passages(s,e){var a,t,i,r,n,o,l,u,x,c,p;for(u=[],x={},a=-1,t=!1,i=n=0,p=o=s.length-1;0<=p?n<=p:n>=p;i=0<=p?++n:--n)(l=s[i]).osis.length>0?(c=u.length-1,r=!1,l.enclosed_indices[0]!==a&&(a=l.enclosed_indices[0]),a>=0&&(i===o||s[i+1].enclosed_indices[0]!==l.enclosed_indices[0])&&(r=!0,t=!0),this.is_verse_consecutive(x,l.start,e)?(u[c].end=l.end,u[c].is_enclosed_last=r,u[c].indices[1]=l.indices[1],u[c].enclosed_indices[1]=l.enclosed_indices[1],u[c].osis=this.to_osis(u[c].start,l.end,e)):u.push(l),x={b:l.end.b,c:l.end.c,v:l.end.v}):(u.push(l),x={});return t&&this.snap_enclosed_indices(u),u}snap_enclosed_indices(s){var e,a,t;for(e=0,a=s.length;e<a;e++)null!=(t=s[e]).is_enclosed_last&&(t.enclosed_indices[0]<0&&t.is_enclosed_last&&(t.indices[1]=t.enclosed_indices[1]),delete t.is_enclosed_last);return s}is_verse_consecutive(s,e,a){var t;if(null==s.b)return!1;if(t=null!=this.passage.translations[a].order?this.passage.translations[a].order:this.passage.translations.default.order,s.b===e.b){if(s.c===e.c){if(s.v===e.v-1)return!0}else if(1===e.v&&s.c===e.c-1&&s.v===this.passage.translations[a].chapters[s.b][s.c-1])return!0}else if(1===e.c&&1===e.v&&t[s.b]===t[e.b]-1&&s.c===this.passage.translations[a].chapters[s.b].length&&s.v===this.passage.translations[a].chapters[s.b][s.c-1])return!0;return!1}snap_range(s,e){var a,t,r,n,o,l,u,x;for(t in"b_range_start"===s.type||"sequence"===s.type&&"b_range_start"===s.passages[e].type?(a=1,o="end",x="b_range_start"):(a=0,o="start",x="range_end_b"),l="end"===o?"start":"end",n=s.passages[e][l])i.call(n,t)&&(s.passages[e][l][t]=s.passages[e][o][t]);return"sequence"===s.type?(e>=s.value.length&&(e=s.value.length-1),null!=(r=this.passage.pluck(x,s.value[e]))&&(u=this.snap_range(r,0),0===e?s.absolute_indices[0]=u.absolute_indices[0]:s.absolute_indices[1]=u.absolute_indices[1])):(s.original_type=s.type,s.type=s.value[a].type,s.absolute_indices=[s.value[a].absolute_indices[0],s.value[a].absolute_indices[1]]),s}snap_sequence(s,e,a,t,i){var r;return(r=e.passages[t]).absolute_indices[0]===e.absolute_indices[0]&&t<i-1&&this.get_snap_sequence_i(e.passages,t,i)!==t?(e.absolute_indices[0]=e.passages[t+1].absolute_indices[0],this.remove_absolute_indices(e.passages,t+1)):r.absolute_indices[1]===e.absolute_indices[1]&&t>0?e.absolute_indices[1]=a.length>0?a[a.length-1].indices[1]:e.passages[t-1].absolute_indices[1]:"book"===s&&t<i-1&&!this.starts_with_book(e.passages[t+1])&&(e.passages[t+1].absolute_indices[0]=r.absolute_indices[0]),e}get_snap_sequence_i(s,e,a){var t,i,r,n;for(t=i=r=e+1,n=a;r<=n?i<n:i>n;t=r<=n?++i:--i){if(this.starts_with_book(s[t]))return t;if(s[t].valid.valid)return e}return e}starts_with_book(s){return"b"===s.type.substr(0,1)||("range"===s.type||"ff"===s.type)&&"b"===s.start.type.substr(0,1)}remove_absolute_indices(s,e){var a,t,i,r,n,o;if(s[e].enclosed_absolute_indices[0]<0)return!1;for([o,a]=s[e].enclosed_absolute_indices,t=0,i=(n=s.slice(e)).length;t<i&&((r=n[t]).enclosed_absolute_indices[0]===o&&r.enclosed_absolute_indices[1]===a);t++)r.enclosed_absolute_indices=[-1,-1];return!0}}return s.prototype.s="",s.prototype.entities=[],s.prototype.passage=null,s.prototype.regexps={},s.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"},s}.call(this),this.bcv_parser=s,e=function(){class s{handle_array(s,e=[],a={}){var t,i,r;for(t=0,i=s.length;t<i;t++)if(null!=(r=s[t])){if("stop"===r.type)break;[e,a]=this.handle_obj(r,e,a)}return[e,a]}handle_obj(s,e,a){return null!=s.type&&null!=this[s.type]?this[s.type](s,e,a):[e,a]}b(s,e,t){var i,r,n,o,l,u,x;for(s.start_context=a.shallow_clone(t),s.passages=[],i=[],n=0,o=(u=this.books[s.value].parsed).length;n<o;n++)l={start:{b:r=u[n]},end:{b:r},valid:x=this.validate_ref(s.start_context.translations,{b:r})},0===s.passages.length&&x.valid?s.passages.push(l):i.push(l);return 0===s.passages.length&&s.passages.push(i.shift()),i.length>0&&(s.passages[0].alternates=i),null!=s.start_context.translations&&(s.passages[0].translations=s.start_context.translations),null==s.absolute_indices&&(s.absolute_indices=this.get_absolute_indices(s.indices)),e.push(s),t={b:s.passages[0].start.b},null!=s.start_context.translations&&(t.translations=s.start_context.translations),[e,t]}b_range(s,e,a){return this.range(s,e,a)}b_range_pre(s,e,t){var i,r,n;return s.start_context=a.shallow_clone(t),s.passages=[],i=this.pluck("b",s.value),[[r],t]=this.b(i,[],t),null==s.absolute_indices&&(s.absolute_indices=this.get_absolute_indices(s.indices)),n={b:s.value[0].value+r.passages[0].start.b.substr(1),type:"b"},s.passages=[{start:n,end:r.passages[0].end,valid:r.passages[0].valid}],null!=s.start_context.translations&&(s.passages[0].translations=s.start_context.translations),e.push(s),[e,t]}b_range_start(s,e,a){return this.range(s,e,a)}base(s,e,a){return this.indices=this.calculate_indices(s.match,s.start_index),this.handle_array(s.value,e,a)}bc(s,e,t){var i,r,n,o,l,u,x,c,p;for(s.start_context=a.shallow_clone(t),s.passages=[],this.reset_context(t,["b","c","v"]),n=this.pluck("c",s.value).value,i=[],l=0,u=(c=this.books[this.pluck("b",s.value).value].parsed).length;l<u;l++)o="c",x={start:{b:r=c[l]},end:{b:r},valid:p=this.validate_ref(s.start_context.translations,{b:r,c:n})},(p.messages.start_chapter_not_exist_in_single_chapter_book||p.messages.start_chapter_1)&&(x.valid=this.validate_ref(s.start_context.translations,{b:r,v:n}),p.messages.start_chapter_not_exist_in_single_chapter_book&&(x.valid.messages.start_chapter_not_exist_in_single_chapter_book=1),x.start.c=1,x.end.c=1,o="v"),x.start[o]=n,[x.start.c,x.start.v]=this.fix_start_zeroes(x.valid,x.start.c,x.start.v),null==x.start.v&&delete x.start.v,x.end[o]=x.start[o],0===s.passages.length&&x.valid.valid?s.passages.push(x):i.push(x);return 0===s.passages.length&&s.passages.push(i.shift()),i.length>0&&(s.passages[0].alternates=i),null!=s.start_context.translations&&(s.passages[0].translations=s.start_context.translations),null==s.absolute_indices&&(s.absolute_indices=this.get_absolute_indices(s.indices)),this.set_context_from_object(t,["b","c","v"],s.passages[0].start),e.push(s),[e,t]}bc_title(s,e,t){var i,r,n,o,l;if(s.start_context=a.shallow_clone(t),[[i],t]=this.bc(this.pluck("bc",s.value),[],t),"Ps"!==i.passages[0].start.b.substr(0,2)&&null!=i.passages[0].alternates)for(r=n=0,o=i.passages[0].alternates.length;0<=o?n<o:n>o;r=0<=o?++n:--n)if("Ps"===i.passages[0].alternates[r].start.b.substr(0,2)){i.passages[0]=i.passages[0].alternates[r];break}return"Ps"!==i.passages[0].start.b.substr(0,2)?(e.push(i),[e,t]):(this.books[this.pluck("b",i.value).value].parsed=["Ps"],null==(l=this.pluck("title",s.value))&&(l=this.pluck("v",s.value)),s.value[1]={type:"v",value:[{type:"integer",value:1,indices:l.indices}],indices:l.indices},s.type="bcv",this.bcv(s,e,s.start_context))}bcv(s,e,t){var i,r,n,o,l,u,x,c,p,g;for(s.start_context=a.shallow_clone(t),s.passages=[],this.reset_context(t,["b","c","v"]),n=this.pluck("bc",s.value),o=this.pluck("c",n.value).value,p=this.pluck("v",s.value).value,i=[],l=0,u=(c=this.books[this.pluck("b",n.value).value].parsed).length;l<u;l++)r=c[l],g=this.validate_ref(s.start_context.translations,{b:r,c:o,v:p}),[o,p]=this.fix_start_zeroes(g,o,p),x={start:{b:r,c:o,v:p},end:{b:r,c:o,v:p},valid:g},0===s.passages.length&&g.valid?s.passages.push(x):i.push(x);return 0===s.passages.length&&s.passages.push(i.shift()),i.length>0&&(s.passages[0].alternates=i),null!=s.start_context.translations&&(s.passages[0].translations=s.start_context.translations),null==s.absolute_indices&&(s.absolute_indices=this.get_absolute_indices(s.indices)),this.set_context_from_object(t,["b","c","v"],s.passages[0].start),e.push(s),[e,t]}bv(s,e,t){var i,r,n;return s.start_context=a.shallow_clone(t),[i,n]=s.value,r={indices:s.indices,value:[{type:"bc",value:[i,{type:"c",value:[{type:"integer",value:1}]}]},n]},[[r],t]=this.bcv(r,[],t),s.passages=r.passages,null==s.absolute_indices&&(s.absolute_indices=this.get_absolute_indices(s.indices)),e.push(s),[e,t]}c(s,e,t){var i,r;return s.start_context=a.shallow_clone(t),i="integer"===s.type?s.value:this.pluck("integer",s.value).value,!(r=this.validate_ref(s.start_context.translations,{b:t.b,c:i})).valid&&r.messages.start_chapter_not_exist_in_single_chapter_book?this.v(s,e,t):([i]=this.fix_start_zeroes(r,i),s.passages=[{start:{b:t.b,c:i},end:{b:t.b,c:i},valid:r}],null!=s.start_context.translations&&(s.passages[0].translations=s.start_context.translations),e.push(s),t.c=i,this.reset_context(t,["v"]),null==s.absolute_indices&&(s.absolute_indices=this.get_absolute_indices(s.indices)),[e,t])}c_psalm(s,e,a){var t;return s.type="bc",t=parseInt(this.books[s.value].value.match(/^\d+/)[0],10),s.value=[{type:"b",value:s.value,indices:s.indices},{type:"c",value:[{type:"integer",value:t,indices:s.indices}],indices:s.indices}],this.bc(s,e,a)}c_title(s,e,t){var i;return s.start_context=a.shallow_clone(t),"Ps"!==t.b?this.c(s.value[0],e,t):(i=this.pluck("title",s.value),s.value[1]={type:"v",value:[{type:"integer",value:1,indices:i.indices}],indices:i.indices},s.type="cv",this.cv(s,e,s.start_context))}cv(s,e,t){var i,r,n;return s.start_context=a.shallow_clone(t),i=this.pluck("c",s.value).value,r=this.pluck("v",s.value).value,n=this.validate_ref(s.start_context.translations,{b:t.b,c:i,v:r}),[i,r]=this.fix_start_zeroes(n,i,r),s.passages=[{start:{b:t.b,c:i,v:r},end:{b:t.b,c:i,v:r},valid:n}],null!=s.start_context.translations&&(s.passages[0].translations=s.start_context.translations),e.push(s),t.c=i,t.v=r,null==s.absolute_indices&&(s.absolute_indices=this.get_absolute_indices(s.indices)),[e,t]}cb_range(s,e,a){var t,i,r;return s.type="range",[t,r,i]=s.value,s.value=[{type:"bc",value:[t,r],indices:s.indices},i],i.indices[1]=s.indices[1],this.range(s,e,a)}context(s,e,t){var r,n;for(r in s.start_context=a.shallow_clone(t),s.passages=[],n=this.books[s.value].context)i.call(n,r)&&(t[r]=this.books[s.value].context[r]);return e.push(s),[e,t]}cv_psalm(s,e,t){var i,r,n;return s.start_context=a.shallow_clone(t),s.type="bcv",[r,n]=s.value,[[i]]=this.c_psalm(r,[],s.start_context),s.value=[i,n],this.bcv(s,e,t)}ff(s,e,t){return s.start_context=a.shallow_clone(t),s.value.push({type:"integer",indices:s.indices,value:999}),[[s],t]=this.range(s,[],s.start_context),s.value[0].indices=s.value[1].indices,s.value[0].absolute_indices=s.value[1].absolute_indices,s.value.pop(),null!=s.passages[0].valid.messages.end_verse_not_exist&&delete s.passages[0].valid.messages.end_verse_not_exist,null!=s.passages[0].valid.messages.end_chapter_not_exist&&delete s.passages[0].valid.messages.end_chapter_not_exist,null!=s.passages[0].end.original_c&&delete s.passages[0].end.original_c,e.push(s),[e,t]}integer_title(s,e,t){return s.start_context=a.shallow_clone(t),"Ps"!==t.b?this.integer(s.value[0],e,t):(s.value[0]={type:"c",value:[s.value[0]],indices:[s.value[0].indices[0],s.value[0].indices[1]]},s.value[1].type="v",s.value[1].original_type="title",s.value[1].value=[{type:"integer",value:1,indices:s.value[1].value.indices}],s.type="cv",this.cv(s,e,s.start_context))}integer(s,e,a){return null!=a.v?this.v(s,e,a):this.c(s,e,a)}next_v(s,e,t){var i,r;return s.start_context=a.shallow_clone(t),null==(i=this.pluck_last_recursively("integer",s.value))&&(i={value:1}),s.value.push({type:"integer",indices:s.indices,value:i.value+1}),[[r],t]=this.range(s,[],s.start_context),null!=r.passages[0].valid.messages.end_verse_not_exist&&null==r.passages[0].valid.messages.start_verse_not_exist&&null==r.passages[0].valid.messages.start_chapter_not_exist&&null!=t.c&&(s.value.pop(),s.value.push({type:"cv",indices:s.indices,value:[{type:"c",value:[{type:"integer",value:t.c+1,indices:s.indices}],indices:s.indices},{type:"v",value:[{type:"integer",value:1,indices:s.indices}],indices:s.indices}]}),[[r],t]=this.range(s,[],s.start_context)),r.value[0].indices=r.value[1].indices,r.value[0].absolute_indices=r.value[1].absolute_indices,r.value.pop(),null!=r.passages[0].valid.messages.end_verse_not_exist&&delete r.passages[0].valid.messages.end_verse_not_exist,null!=r.passages[0].valid.messages.end_chapter_not_exist&&delete r.passages[0].valid.messages.end_chapter_not_exist,null!=r.passages[0].end.original_c&&delete r.passages[0].end.original_c,e.push(r),[e,t]}sequence(s,e,t){var i,r,n,o,l,u,x,c,p;for(s.start_context=a.shallow_clone(t),s.passages=[],i=0,n=(x=s.value).length;i<n;i++)for(l=x[i],[[u],t]=this.handle_array(l,[],t),r=0,o=(c=u.passages).length;r<o;r++)null==(p=c[r]).type&&(p.type=u.type),null==p.absolute_indices&&(p.absolute_indices=u.absolute_indices),null!=u.start_context.translations&&(p.translations=u.start_context.translations),p.enclosed_absolute_indices="sequence_post_enclosed"===u.type?u.absolute_indices:[-1,-1],s.passages.push(p);return null==s.absolute_indices&&(s.passages.length>0&&"sequence"===s.type?s.absolute_indices=[s.passages[0].absolute_indices[0],s.passages[s.passages.length-1].absolute_indices[1]]:s.absolute_indices=this.get_absolute_indices(s.indices)),e.push(s),[e,t]}sequence_post_enclosed(s,e,a){return this.sequence(s,e,a)}v(s,e,t){var i,r,n,o;return n="integer"===s.type?s.value:this.pluck("integer",s.value).value,s.start_context=a.shallow_clone(t),i=null!=t.c?t.c:1,o=this.validate_ref(s.start_context.translations,{b:t.b,c:i,v:n}),[r,n]=this.fix_start_zeroes(o,0,n),s.passages=[{start:{b:t.b,c:i,v:n},end:{b:t.b,c:i,v:n},valid:o}],null!=s.start_context.translations&&(s.passages[0].translations=s.start_context.translations),null==s.absolute_indices&&(s.absolute_indices=this.get_absolute_indices(s.indices)),e.push(s),t.v=n,[e,t]}range(s,e,t){var i,r,n,o,l,u,x,c,p,g,h;return s.start_context=a.shallow_clone(t),[p,i]=s.value,[[p],t]=this.handle_obj(p,[],t),"v"!==i.type||("bc"!==p.type||(null!=(n=p.passages)&&null!=(o=n[0])&&null!=(l=o.valid)&&null!=(u=l.messages)?u.start_chapter_not_exist_in_single_chapter_book:void 0))&&"c"!==p.type||"verse"!==this.options.end_range_digits_strategy?([[i],t]=this.handle_obj(i,[],t),s.value=[p,i],s.indices=[p.indices[0],i.indices[1]],delete s.absolute_indices,g={b:p.passages[0].start.b,c:p.passages[0].start.c,v:p.passages[0].start.v,type:p.type},r={b:i.passages[0].end.b,c:i.passages[0].end.c,v:i.passages[0].end.v,type:i.type},i.passages[0].valid.messages.start_chapter_is_zero&&(r.c=0),i.passages[0].valid.messages.start_verse_is_zero&&(r.v=0),(h=this.validate_ref(s.start_context.translations,g,r)).valid?([x,c]=this.range_handle_valid(h,s,p,g,i,r,e),x?c:(null==s.absolute_indices&&(s.absolute_indices=this.get_absolute_indices(s.indices)),s.passages=[{start:g,end:r,valid:h}],null!=s.start_context.translations&&(s.passages[0].translations=s.start_context.translations),"b"===g.type?"b"===r.type?s.type="b_range":s.type="b_range_start":"b"===r.type&&(s.type="range_end_b"),e.push(s),[e,t])):this.range_handle_invalid(h,s,p,g,i,r,e)):(s.value[0]=p,this.range_change_integer_end(s,e))}range_change_end(s,e,a){var t,i,r;return[r,t]=s.value,"integer"===t.type?(t.original_value=t.value,t.value=a):"v"===t.type?((i=this.pluck("integer",t.value)).original_value=i.value,i.value=a):"cv"===t.type&&((i=this.pluck("c",t.value)).original_value=i.value,i.value=a),this.handle_obj(s,e,s.start_context)}range_change_integer_end(s,e){var a,t;return[t,a]=s.value,null==s.original_type&&(s.original_type=s.type),null==s.original_value&&(s.original_value=[t,a]),s.type="integer"===t.type?"cv":t.type+"v","integer"===t.type&&(s.value[0]={type:"c",value:[t],indices:t.indices}),"integer"===a.type&&(s.value[1]={type:"v",value:[a],indices:a.indices}),this.handle_obj(s,e,s.start_context)}range_check_new_end(s,e,a,t){var i,r,n;return i=0,n=null,t.messages.end_chapter_before_start?n="c":t.messages.end_verse_before_start&&(n="v"),null!=n&&(i=this.range_get_new_end_value(e,a,t,n)),i>0&&((r={b:a.b,c:a.c,v:a.v})[n]=i,this.validate_ref(s,r).valid||(i=0)),i}range_end_b(s,e,a){return this.range(s,e,a)}range_get_new_end_value(s,e,a,t){var i;return i=0,"c"===t&&a.messages.end_chapter_is_zero||"v"===t&&a.messages.end_verse_is_zero||(s[t]>=10&&e[t]<10&&s[t]-10*Math.floor(s[t]/10)<e[t]?i=e[t]+10*Math.floor(s[t]/10):s[t]>=100&&e[t]<100&&s[t]-100<e[t]&&(i=e[t]+100)),i}range_handle_invalid(s,e,a,t,i,r,n){var o,l;return(!1===s.valid&&(s.messages.end_chapter_before_start||s.messages.end_verse_before_start)&&("integer"===i.type||"v"===i.type)||!1===s.valid&&s.messages.end_chapter_before_start&&"cv"===i.type)&&(o=this.range_check_new_end(e.start_context.translations,t,r,s))>0?this.range_change_end(e,n,o):"verse"!==this.options.end_range_digits_strategy||null!=t.v||"integer"!==i.type&&"v"!==i.type||(l="v"===i.type?this.pluck("integer",i.value):i.value,!this.validate_ref(e.start_context.translations,{b:t.b,c:t.c,v:l}).valid)?(null==e.original_type&&(e.original_type=e.type),e.type="sequence",[e.original_value,e.value]=[[a,i],[[a],[i]]],this.sequence(e,n,e.start_context)):this.range_change_integer_end(e,n)}range_handle_valid(s,e,a,t,i,r,n){var o;return s.messages.end_chapter_not_exist&&"verse"===this.options.end_range_digits_strategy&&null==t.v&&("integer"===i.type||"v"===i.type)&&this.options.passage_existence_strategy.indexOf("v")>=0&&(o="v"===i.type?this.pluck("integer",i.value):i.value,this.validate_ref(e.start_context.translations,{b:t.b,c:t.c,v:o}).valid)?[!0,this.range_change_integer_end(e,n)]:(this.range_validate(s,t,r,e),[!1,null])}range_validate(s,e,a,t){return s.messages.end_chapter_not_exist||s.messages.end_chapter_not_exist_in_single_chapter_book?(a.original_c=a.c,a.c=s.messages.end_chapter_not_exist?s.messages.end_chapter_not_exist:s.messages.end_chapter_not_exist_in_single_chapter_book,null!=a.v&&(a.v=this.validate_ref(t.start_context.translations,{b:a.b,c:a.c,v:999}).messages.end_verse_not_exist,delete s.messages.end_verse_is_zero)):s.messages.end_verse_not_exist&&(a.original_v=a.v,a.v=s.messages.end_verse_not_exist),s.messages.end_verse_is_zero&&"allow"!==this.options.zero_verse_strategy&&(a.v=s.messages.end_verse_is_zero),s.messages.end_chapter_is_zero&&(a.c=s.messages.end_chapter_is_zero),[e.c,e.v]=this.fix_start_zeroes(s,e.c,e.v),!0}translation_sequence(s,e,t){var i,r,n,o,l,u,x,c;for(s.start_context=a.shallow_clone(t),(x=[]).push({translation:this.books[s.value[0].value].parsed}),i=0,n=(l=s.value[1]).length;i<n;i++)c=l[i],null!=(c=this.books[this.pluck("translation",c).value].parsed)&&x.push({translation:c});for(r=0,o=x.length;r<o;r++)u=x[r],null!=this.translations.aliases[u.translation]?(u.alias=this.translations.aliases[u.translation].alias,u.osis=this.translations.aliases[u.translation].osis||u.translation.toUpperCase()):(u.alias="default",u.osis=u.translation.toUpperCase());return e.length>0&&(t=this.translation_sequence_apply(e,x)),null==s.absolute_indices&&(s.absolute_indices=this.get_absolute_indices(s.indices)),e.push(s),this.reset_context(t,["translations"]),[e,t]}translation_sequence_apply(s,e){var t,i,r,n,o,l;for(l=0,i=r=o=s.length-1;o<=0?r<=0:r>=0;i=o<=0?++r:--r)if(null!=s[i].original_type&&(s[i].type=s[i].original_type),null!=s[i].original_value&&(s[i].value=s[i].original_value),"translation_sequence"===s[i].type){l=i+1;break}return l<s.length?(s[l].start_context.translations=e,[n,t]=this.handle_array(s.slice(l),[],s[l].start_context)):t=a.shallow_clone(s[s.length-1].start_context),t}pluck(s,e){var a,t,i;for(a=0,t=e.length;a<t;a++)if(null!=(i=e[a])&&null!=i.type&&i.type===s)return"c"===s||"v"===s?this.pluck("integer",i.value):i;return null}pluck_last_recursively(s,e){var a,t,i;for(a=e.length-1;a>=0;a+=-1)if(null!=(t=e[a])&&null!=t.type){if(t.type===s)return this.pluck(s,[t]);if(null!=(i=this.pluck_last_recursively(s,t.value)))return i}return null}set_context_from_object(s,e,a){var t,i,r,n;for(r=[],t=0,i=e.length;t<i;t++)null!=a[n=e[t]]&&r.push(s[n]=a[n]);return r}reset_context(s,e){var a,t,i,r;for(i=[],a=0,t=e.length;a<t;a++)r=e[a],i.push(delete s[r]);return i}fix_start_zeroes(s,e,a){return s.messages.start_chapter_is_zero&&"upgrade"===this.options.zero_chapter_strategy&&(e=s.messages.start_chapter_is_zero),s.messages.start_verse_is_zero&&"upgrade"===this.options.zero_verse_strategy&&(a=s.messages.start_verse_is_zero),[e,a]}calculate_indices(s,e){var a,t,i,r,n,o,l,u,x,c,p,g,h,d,_,f;for(_="book",i=[],c=0,e=parseInt(e,10),h=[s],r=0,o=(d=["",""]).length;r<o;r++){for(a=d[r],f=[],n=0,l=h.length;n<l;n++)p=h[n],f=f.concat(p.split(a));h=f}for(x=0,u=h.length;x<u;x++)_="book"===_?"rest":"book",0!==(g=(p=h[x]).length)&&("book"===_?(p=p.replace(/\/\d+$/,""),t=c+g,i.length>0&&i[i.length-1].index===e?i[i.length-1].end=t:i.push({start:c,end:t,index:e}),c+=g+2,e=this.books[p].start_index+this.books[p].value.length-c,i.push({start:t+1,end:t+1,index:e})):(t=c+g-1,i.length>0&&i[i.length-1].index===e?i[i.length-1].end=t:i.push({start:c,end:t,index:e}),c+=g));return i}get_absolute_indices([s,e]){var a,t,i,r,n,o;for(o=null,a=null,i=0,r=(n=this.indices).length;i<r;i++)if(t=n[i],null===o&&t.start<=s&&s<=t.end&&(o=s+t.index),t.start<=e&&e<=t.end){a=e+t.index+1;break}return[o,a]}validate_ref(s,e,a){var t,i,r,n,o,l;for(null!=s&&s.length>0||(s=[{translation:"default",osis:"",alias:"default"}]),l=!1,r={},t=0,i=s.length;t<i;t++)null==(o=s[t]).alias&&(o.alias="default"),null!=o.alias?(null==this.translations.aliases[o.alias]&&(o.alias="default",null==r.translation_unknown&&(r.translation_unknown=[]),r.translation_unknown.push(o)),[n]=this.validate_start_ref(o.alias,e,r),a&&([n]=this.validate_end_ref(o.alias,e,a,n,r)),!0===n&&(l=!0)):(null==r.translation_invalid&&(r.translation_invalid=[]),r.translation_invalid.push(o));return{valid:l,messages:r}}validate_start_ref(s,e,a){var t,i,r,n;if(n=!0,"default"!==s&&null==(null!=(t=this.translations[s])?t.chapters[e.b]:void 0)&&this.promote_book_to_translation(e.b,s),r=null!=(null!=(i=this.translations[s])?i.order:void 0)?s:"default",null!=e.v&&(e.v=parseInt(e.v,10)),null!=this.translations[r].order[e.b]){if(null==e.c&&(e.c=1),e.c=parseInt(e.c,10),isNaN(e.c))return n=!1,a.start_chapter_not_numeric=!0,[n,a];0===e.c&&(a.start_chapter_is_zero=1,"error"===this.options.zero_chapter_strategy?n=!1:e.c=1),null!=e.v&&0===e.v&&(a.start_verse_is_zero=1,"error"===this.options.zero_verse_strategy?n=!1:"upgrade"===this.options.zero_verse_strategy&&(e.v=1)),e.c>0&&null!=this.translations[s].chapters[e.b][e.c-1]?null!=e.v?isNaN(e.v)?(n=!1,a.start_verse_not_numeric=!0):e.v>this.translations[s].chapters[e.b][e.c-1]&&this.options.passage_existence_strategy.indexOf("v")>=0&&(n=!1,a.start_verse_not_exist=this.translations[s].chapters[e.b][e.c-1]):1===e.c&&"verse"===this.options.single_chapter_1_strategy&&1===this.translations[s].chapters[e.b].length&&(a.start_chapter_1=1):1!==e.c&&1===this.translations[s].chapters[e.b].length?(n=!1,a.start_chapter_not_exist_in_single_chapter_book=1):e.c>0&&this.options.passage_existence_strategy.indexOf("c")>=0&&(n=!1,a.start_chapter_not_exist=this.translations[s].chapters[e.b].length)}else null==e.b?(n=!1,a.start_book_not_defined=!0):(this.options.passage_existence_strategy.indexOf("b")>=0&&(n=!1),a.start_book_not_exist=!0);return[n,a]}validate_end_ref(s,e,a,t,i){var r,n;return n=null!=(null!=(r=this.translations[s])?r.order:void 0)?s:"default",null!=a.c&&(a.c=parseInt(a.c,10),isNaN(a.c)?(t=!1,i.end_chapter_not_numeric=!0):0===a.c&&(i.end_chapter_is_zero=1,"error"===this.options.zero_chapter_strategy?t=!1:a.c=1)),null!=a.v&&(a.v=parseInt(a.v,10),isNaN(a.v)?(t=!1,i.end_verse_not_numeric=!0):0===a.v&&(i.end_verse_is_zero=1,"error"===this.options.zero_verse_strategy?t=!1:"upgrade"===this.options.zero_verse_strategy&&(a.v=1))),null!=this.translations[n].order[a.b]?(null==a.c&&1===this.translations[s].chapters[a.b].length&&(a.c=1),null!=this.translations[n].order[e.b]&&this.translations[n].order[e.b]>this.translations[n].order[a.b]&&(this.options.passage_existence_strategy.indexOf("b")>=0&&(t=!1),i.end_book_before_start=!0),e.b!==a.b||null==a.c||isNaN(a.c)||(null==e.c&&(e.c=1),!isNaN(parseInt(e.c,10))&&e.c>a.c?(t=!1,i.end_chapter_before_start=!0):e.c!==a.c||null==a.v||isNaN(a.v)||(null==e.v&&(e.v=1),!isNaN(parseInt(e.v,10))&&e.v>a.v&&(t=!1,i.end_verse_before_start=!0))),null==a.c||isNaN(a.c)||null==this.translations[s].chapters[a.b][a.c-1]&&(1===this.translations[s].chapters[a.b].length?i.end_chapter_not_exist_in_single_chapter_book=1:a.c>0&&this.options.passage_existence_strategy.indexOf("c")>=0&&(i.end_chapter_not_exist=this.translations[s].chapters[a.b].length)),null==a.v||isNaN(a.v)||(null==a.c&&(a.c=this.translations[s].chapters[a.b].length),a.v>this.translations[s].chapters[a.b][a.c-1]&&this.options.passage_existence_strategy.indexOf("v")>=0&&(i.end_verse_not_exist=this.translations[s].chapters[a.b][a.c-1]))):(t=!1,i.end_book_not_exist=!0),[t,i]}promote_book_to_translation(s,e){var t,i;if(null==(t=this.translations)[e]&&(t[e]={}),null==(i=this.translations[e]).chapters&&(i.chapters={}),null==this.translations[e].chapters[s])return this.translations[e].chapters[s]=a.shallow_clone_array(this.translations.default.chapters[s])}}return s.prototype.books=[],s.prototype.indices={},s.prototype.options={},s.prototype.translations={},s}.call(this),a={shallow_clone:function(s){var e,a,t;if(null==s)return s;for(e in a={},s)i.call(s,e)&&(t=s[e],a[e]=t);return a},shallow_clone_array:function(s){var e,a,t,i;if(null==s)return s;for(t=[],e=a=0,i=s.length;0<=i?a<=i:a>=i;e=0<=i?++a:--a)void 0!==s[e]&&(t[e]=s[e]);return t}},s.prototype.regexps.translations=/(?:(?:NP))\b/gi,s.prototype.translations={aliases:{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,24,22,17,32,24,40,44,26,22,19,32,20,28,18,16,18,22,13,30,5,28,7,47,39,46,64,34],Ezek:[28,9,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,100,34,31,28,28,27,27,21,45,13,65,42],Hos:[11,24,5,19,15,11,16,14,17,15,12,14,15,10],Amos:[15,16,15,13,27,15,17,14,14],Jonah:[16,11,10,11],Mic:[16,13,12,13,14,16,20],Hag:[14,24],Matt:[25,23,17,25,48,34,29,34,38,42,30,50,58,36,39,28,26,35,30,34,46,46,39,51,46,75,66,20],Mark:[45,28,35,40,43,56,37,39,49,52,33,44,37,72,47,20],John:[51,25,36,54,47,72,53,59,41,42,57,50,38,31,27,33,26,40,42,31,25],Acts:[26,47,26,37,42,15,59,40,43,48,30,25,52,27,41,40,34,28,40,38,40,30,35,27,27,32,44,31],"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:[25,23,25,23,28,22,20,24,12,13,21,22,23,17],Jdt:[12,18,15,17,29,21,25,34,19,20,21,20,31,18,15,31],Wis:[16,25,19,20,24,27,30,21,19,21,27,27,19,31,19,29,20,25,20],Sir:[40,23,34,36,18,37,40,22,25,34,36,19,32,27,22,31,31,33,28,33,31,33,38,47,36,28,33,30,35,27,42,28,33,31,26,28,34,39,41,32,28,26,37,27,31,23,31,28,19,31,38,13],Bar:[22,35,38,37,9,72],"1Macc":[67,70,60,61,68,63,50,32,73,89,74,54,54,49,41,24],"2Macc":[36,33,40,50,27,31,42,36,29,38,38,46,26,46,40]}},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,