jio-v3.4.1.min.js 152 KB
Newer Older
Xiaowu Zhang's avatar
Xiaowu Zhang committed
1 2 3 4 5 6
/*! jio v3.4.1 2015-10-28 */
function Query(){this.onParseStart=emptyFunction,this.onParseSimpleQuery=emptyFunction,this.onParseComplexQuery=emptyFunction,this.onParseEnd=emptyFunction}function parseStringToObject(a){function b(a){g+=a+"\n"}function c(a){var b=0,c=-1,d=0,e=0,f=a.offset+1;do{if(f--,b=0,c=-2,e=f,a.src.length<=e)return 19;do{switch(b){case 0:b=a.src.charCodeAt(f)>=0&&a.src.charCodeAt(f)<=8||a.src.charCodeAt(f)>=10&&a.src.charCodeAt(f)<=31||a.src.charCodeAt(f)>=35&&a.src.charCodeAt(f)<=39||a.src.charCodeAt(f)>=42&&a.src.charCodeAt(f)<=57||59==a.src.charCodeAt(f)||a.src.charCodeAt(f)>=63&&a.src.charCodeAt(f)<=64||a.src.charCodeAt(f)>=66&&a.src.charCodeAt(f)<=77||a.src.charCodeAt(f)>=80&&a.src.charCodeAt(f)<=254?1:9==a.src.charCodeAt(f)?2:40==a.src.charCodeAt(f)?3:41==a.src.charCodeAt(f)?4:60==a.src.charCodeAt(f)||62==a.src.charCodeAt(f)?5:33==a.src.charCodeAt(f)?11:79==a.src.charCodeAt(f)?12:32==a.src.charCodeAt(f)?13:61==a.src.charCodeAt(f)?14:34==a.src.charCodeAt(f)?15:65==a.src.charCodeAt(f)?19:78==a.src.charCodeAt(f)?20:-1;break;case 1:b=a.src.charCodeAt(f)>=0&&a.src.charCodeAt(f)<=31||33==a.src.charCodeAt(f)||a.src.charCodeAt(f)>=35&&a.src.charCodeAt(f)<=39||a.src.charCodeAt(f)>=42&&a.src.charCodeAt(f)<=57||a.src.charCodeAt(f)>=59&&a.src.charCodeAt(f)<=254?1:58==a.src.charCodeAt(f)?6:-1,c=10,d=f;break;case 2:b=a.src.charCodeAt(f)>=0&&a.src.charCodeAt(f)<=31||33==a.src.charCodeAt(f)||a.src.charCodeAt(f)>=35&&a.src.charCodeAt(f)<=39||a.src.charCodeAt(f)>=42&&a.src.charCodeAt(f)<=57||a.src.charCodeAt(f)>=59&&a.src.charCodeAt(f)<=254?1:58==a.src.charCodeAt(f)?6:-1,c=1,d=f;break;case 3:b=-1,c=3,d=f;break;case 4:b=-1,c=4,d=f;break;case 5:b=61==a.src.charCodeAt(f)?14:-1,c=11,d=f;break;case 6:b=-1,c=8,d=f;break;case 7:b=-1,c=9,d=f;break;case 8:b=a.src.charCodeAt(f)>=0&&a.src.charCodeAt(f)<=31||33==a.src.charCodeAt(f)||a.src.charCodeAt(f)>=35&&a.src.charCodeAt(f)<=39||a.src.charCodeAt(f)>=42&&a.src.charCodeAt(f)<=57||a.src.charCodeAt(f)>=59&&a.src.charCodeAt(f)<=254?1:58==a.src.charCodeAt(f)?6:-1,c=6,d=f;break;case 9:b=a.src.charCodeAt(f)>=0&&a.src.charCodeAt(f)<=31||33==a.src.charCodeAt(f)||a.src.charCodeAt(f)>=35&&a.src.charCodeAt(f)<=39||a.src.charCodeAt(f)>=42&&a.src.charCodeAt(f)<=57||a.src.charCodeAt(f)>=59&&a.src.charCodeAt(f)<=254?1:58==a.src.charCodeAt(f)?6:-1,c=5,d=f;break;case 10:b=a.src.charCodeAt(f)>=0&&a.src.charCodeAt(f)<=31||33==a.src.charCodeAt(f)||a.src.charCodeAt(f)>=35&&a.src.charCodeAt(f)<=39||a.src.charCodeAt(f)>=42&&a.src.charCodeAt(f)<=57||a.src.charCodeAt(f)>=59&&a.src.charCodeAt(f)<=254?1:58==a.src.charCodeAt(f)?6:-1,c=7,d=f;break;case 11:b=61==a.src.charCodeAt(f)?14:-1;break;case 12:b=a.src.charCodeAt(f)>=0&&a.src.charCodeAt(f)<=31||33==a.src.charCodeAt(f)||a.src.charCodeAt(f)>=35&&a.src.charCodeAt(f)<=39||a.src.charCodeAt(f)>=42&&a.src.charCodeAt(f)<=57||a.src.charCodeAt(f)>=59&&a.src.charCodeAt(f)<=81||a.src.charCodeAt(f)>=83&&a.src.charCodeAt(f)<=254?1:58==a.src.charCodeAt(f)?6:82==a.src.charCodeAt(f)?8:-1,c=10,d=f;break;case 13:b=-1,c=1,d=f;break;case 14:b=-1,c=11,d=f;break;case 15:b=34==a.src.charCodeAt(f)?7:a.src.charCodeAt(f)>=0&&a.src.charCodeAt(f)<=33||a.src.charCodeAt(f)>=35&&a.src.charCodeAt(f)<=91||a.src.charCodeAt(f)>=93&&a.src.charCodeAt(f)<=254||a.src.charCodeAt(f)>255?15:92==a.src.charCodeAt(f)?17:-1;break;case 16:b=a.src.charCodeAt(f)>=0&&a.src.charCodeAt(f)<=31||33==a.src.charCodeAt(f)||a.src.charCodeAt(f)>=35&&a.src.charCodeAt(f)<=39||a.src.charCodeAt(f)>=42&&a.src.charCodeAt(f)<=57||a.src.charCodeAt(f)>=59&&a.src.charCodeAt(f)<=67||a.src.charCodeAt(f)>=69&&a.src.charCodeAt(f)<=254?1:58==a.src.charCodeAt(f)?6:68==a.src.charCodeAt(f)?9:-1,c=10,d=f;break;case 17:b=a.src.charCodeAt(f)>=0&&a.src.charCodeAt(f)<=254?15:-1;break;case 18:b=a.src.charCodeAt(f)>=0&&a.src.charCodeAt(f)<=31||33==a.src.charCodeAt(f)||a.src.charCodeAt(f)>=35&&a.src.charCodeAt(f)<=39||a.src.charCodeAt(f)>=42&&a.src.charCodeAt(f)<=57||a.src.charCodeAt(f)>=59&&a.src.charCodeAt(f)<=83||a.src.charCodeAt(f)>=85&&a.src.charCodeAt(f)<=254?1:58==a.src.charCodeAt(f)?6:84==a.src.charCodeAt(f)?10:-1,c=10,d=f;break;case 19:b=a.src.charCodeAt(f)>=0&&a.src.charCodeAt(f)<=31||33==a.src.charCodeAt(f)||a.src.charCodeAt(f)>=35&&a.src.charCodeAt(f)<=39||a.src.charCodeAt(f)>=42&&a.src.charCodeAt(f)<=57||a.src.charCodeAt(f)>=59&&a.src.charCodeAt(f)<=77||a.src.charCodeAt(f)>=79&&a.src.charCodeAt(f)<=254?1:58==a.src.charCodeAt(f)?6:78==a.src.charCodeAt(f)?16:-1,c=10,d=f;break;case 20:b=a.src.charCodeAt(f)>=0&&a.src.charCodeAt(f)<=31||33==a.src.charCodeAt(f)||a.src.charCodeAt(f)>=35&&a.src.charCodeAt(f)<=39||a.src.charCodeAt(f)>=42&&a.src.charCodeAt(f)<=57||a.src.charCodeAt(f)>=59&&a.src.charCodeAt(f)<=78||a.src.charCodeAt(f)>=80&&a.src.charCodeAt(f)<=254?1:58==a.src.charCodeAt(f)?6:79==a.src.charCodeAt(f)?18:-1,c=10,d=f}f++}while(b>-1)}while(1==c);return c>-1?(a.att=a.src.substr(e,d-e),a.offset=d):(a.att=new String,c=-1),c}function d(a,d,h){var m,n,o,p,q=new Array,r=new Array,s=0,t=new Function("","var offset; var src; var att;"),u=new t,v=new Array(new Array(0,1),new Array(13,1),new Array(12,1),new Array(12,2),new Array(12,3),new Array(14,1),new Array(14,3),new Array(15,2),new Array(15,1),new Array(16,3),new Array(16,2),new Array(16,1),new Array(17,2),new Array(17,1),new Array(18,1),new Array(18,1)),w=new Array(new Array(7,5,3,7,8,8,11,10,10,12,9,13),new Array(19,0),new Array(19,-1),new Array(6,14,7,5,3,7,8,8,11,10,10,12,9,13,19,-2,4,-2),new Array(5,16,19,-5,7,-5,3,-5,8,-5,11,-5,10,-5,9,-5,6,-5,4,-5),new Array(3,7,8,8,11,10,10,12,9,13),new Array(19,-8,7,-8,3,-8,8,-8,11,-8,10,-8,9,-8,6,-8,5,-8,4,-8),new Array(7,5,3,7,8,8,11,10,10,12,9,13),new Array(3,7,8,8,11,10,10,12,9,13),new Array(19,-11,7,-11,3,-11,8,-11,11,-11,10,-11,9,-11,6,-11,5,-11,4,-11),new Array(10,12,9,13),new Array(19,-13,7,-13,3,-13,8,-13,11,-13,10,-13,9,-13,6,-13,5,-13,4,-13),new Array(19,-14,7,-14,3,-14,8,-14,11,-14,10,-14,9,-14,6,-14,5,-14,4,-14),new Array(19,-15,7,-15,3,-15,8,-15,11,-15,10,-15,9,-15,6,-15,5,-15,4,-15),new Array(7,5,3,7,8,8,11,10,10,12,9,13),new Array(19,-3,4,-3),new Array(7,5,3,7,8,8,11,10,10,12,9,13),new Array(19,-7,7,-7,3,-7,8,-7,11,-7,10,-7,9,-7,6,-7,5,-7,4,-7),new Array(4,23),new Array(19,-10,7,-10,3,-10,8,-10,11,-10,10,-10,9,-10,6,-10,5,-10,4,-10),new Array(19,-12,7,-12,3,-12,8,-12,11,-12,10,-12,9,-12,6,-12,5,-12,4,-12),new Array(19,-4,4,-4),new Array(19,-6,7,-6,3,-6,8,-6,11,-6,10,-6,9,-6,6,-6,4,-6),new Array(19,-9,7,-9,3,-9,8,-9,11,-9,10,-9,9,-9,6,-9,5,-9,4,-9)),x=new Array(new Array(13,1,12,2,14,3,15,4,16,6,17,9,18,11),new Array,new Array,new Array(12,15,14,3,15,4,16,6,17,9,18,11),new Array,new Array(16,17,17,9,18,11),new Array,new Array(12,18,14,3,15,4,16,6,17,9,18,11),new Array(16,19,17,9,18,11),new Array,new Array(18,20),new Array,new Array,new Array,new Array(12,21,14,3,15,4,16,6,17,9,18,11),new Array,new Array(14,22,15,4,16,6,17,9,18,11),new Array,new Array,new Array,new Array,new Array,new Array,new Array),y=new Array("begin'","WHITESPACE","WHITESPACE","LEFT_PARENTHESE","RIGHT_PARENTHESE","AND","OR","NOT","COLUMN","STRING","WORD","OPERATOR","search_text","begin","and_expression","boolean_expression","expression","value","string","$");for(u.offset=0,u.src=a,u.att=new String,d||(d=new Array),h||(h=new Array),q.push(0),r.push(0),o=c(u);;){m=25;for(var z=0;z<w[q[q.length-1]].length;z+=2)if(w[q[q.length-1]][z]==o){m=w[q[q.length-1]][z+1];break}if(f&&q.length>0&&b("\nState "+q[q.length-1]+"\n	Lookahead: "+y[o]+' ("'+u.att+'")\n	Action: '+m+'\n	Source: "'+u.src.substr(u.offset,30)+(u.offset+30<u.src.length?"...":"")+'"\n	Stack: '+q.join()+"\n	Value stack: "+r.join()+"\n"),25==m){f&&b("Error detected: There is no reduce or shift on the symbol "+y[o]),s++,d.push(u.offset-u.att.length),h.push(new Array);for(var z=0;z<w[q[q.length-1]].length;z+=2)h[h.length-1].push(y[w[q[q.length-1]][z]]);for(var A=new Array,B=new Array,z=0;z<q.length;z++)A[z]=q[z],B[z]=r[z];for(;25==m&&19!=o;){for(f&&b("	Error recovery\nCurrent lookahead: "+y[o]+" ("+u.att+")\nAction: "+m+"\n\n"),-1==o&&u.offset++;25==m&&q.length>0&&(q.pop(),r.pop(),0!=q.length);){m=25;for(var z=0;z<w[q[q.length-1]].length;z+=2)if(w[q[q.length-1]][z]==o){m=w[q[q.length-1]][z+1];break}}if(25!=m)break;for(var z=0;z<A.length;z++)q.push(A[z]),r.push(B[z]);o=c(u)}if(25==m){f&&b("	Error recovery failed, terminating parse process...");break}f&&b("	Error recovery succeeded, continuing")}if(m>0)f&&b("Shifting symbol: "+y[o]+" ("+u.att+")"),q.push(m),r.push(u.att),o=c(u),f&&b("	New lookahead symbol: "+y[o]+" ("+u.att+")");else{switch(m*=-1,f&&b("Reducing by producution: "+m),p=void 0,f&&b("	Performing semantic action..."),m){case 0:p=r[r.length-1];break;case 1:e=r[r.length-1];break;case 2:p=r[r.length-1];break;case 3:p=k("OR",[r[r.length-2],r[r.length-1]]);break;case 4:p=k("OR",[r[r.length-3],r[r.length-1]]);break;case 5:p=r[r.length-1];break;case 6:p=k("AND",[r[r.length-3],r[r.length-1]]);break;case 7:p=j(r[r.length-1]);break;case 8:p=r[r.length-1];break;case 9:p=r[r.length-2];break;case 10:l(r[r.length-1],r[r.length-2].split(":").slice(0,-1).join(":")),p=r[r.length-1];break;case 11:p=r[r.length-1];break;case 12:r[r.length-1].operator=r[r.length-2],p=r[r.length-1];break;case 13:p=r[r.length-1];break;case 14:p=i("",r[r.length-1]);break;case 15:p=i("",r[r.length-1].split('"').slice(1,-1).join('"'))}f&&b("	Popping "+v[m][1]+" off the stack...");for(var z=0;z<v[m][1];z++)q.pop(),r.pop();n=-1;for(var z=0;z<x[q[q.length-1]].length;z+=2)if(x[q[q.length-1]][z]==v[m][0]){n=x[q[q.length-1]][z+1];break}if(0==m)break;f&&b("	Pushing non-terminal "+y[v[m][0]]),q.push(n),r.push(p)}f&&(alert(g),g=new String)}return f&&(b("\nParse complete."),alert(g)),s}var e,f=!1,g=new String,h=function(){var a,b,c=[],d=arguments;for(a=0;a<d.length;a+=1)for(b=0;b<d[a].length;b+=1)c.push(d[a][b]);return c},i=function(a,b,c){var d={type:"simple",key:a,value:b};return void 0!==c&&(d.operator=c),d},j=function(a){return"NOT"===a.operator?a.query_list[0]:{type:"complex",operator:"NOT",query_list:[a]}},k=function(a,b){var c,d=[];for(c=0;c<b.length;c+=1)b[c].operator===a?d=h(d,b[c].query_list):d.push(b[c]);return{type:"complex",operator:a,query_list:d}},l=function(a,b){var c;if("complex"===a.type){for(c=0;c<a.query_list.length;++c)l(a.query_list[c],b);return!0}return"simple"!==a.type||a.key?!1:(a.key=b,!0)},m=[],n=[],o=0;if((o=d(a,m,n))>0){var p;for(p=0;o>p;p+=1)throw new Error('Parse error near "'+a.substr(m[p])+'", expecting "'+n[p].join()+'"')}return e}function ComplexQuery(a,b){Query.call(this),this.operator=a.operator,this.query_list=a.query_list||[],this.query_list=this.query_list.map(function(a,c){return QueryFactory.create(a,b)})}function QueryFactory(){}function objectToSearchText(a){var b=[];if("complex"===a.type)return b.push("("),(a.query_list||[]).forEach(function(c){b.push(objectToSearchText(c)),b.push(a.operator)}),b.length-=1,b.push(")"),b.join(" ");if("simple"===a.type)return(a.key?a.key+": ":"")+(a.operator||"")+' "'+a.value+'"';throw new TypeError("This object is not a query")}function SimpleQuery(a,b){Query.call(this),checkKeySchema(b),this._key_schema=b||{},this.operator=a.operator,this.key=a.key,this.value=a.value}function stringEscapeRegexpCharacters(a){if("string"==typeof a)return a.replace(/([\\\.\$\[\]\(\)\{\}\^\?\*\+\-])/g,"\\$1");throw new TypeError("Query.stringEscapeRegexpCharacters(): Argument no 1 is not of type 'string'")}function metadataValueToStringArray(a){var b,c=[];if(void 0===a)return void 0;for(Array.isArray(a)||(a=[a]),b=0;b<a.length;b+=1)"object"==typeof a[b]?c[b]=a[b].content:c[b]=a[b];return c}function sortFunction(a,b){var c;if("descending"===b)c=1;else{if("ascending"!==b)throw new TypeError("Query.sortFunction(): Argument 2 must be 'ascending' or 'descending'");c=-1}return function(b,d){var e,f;for(b=metadataValueToStringArray(b[a])||[],d=metadataValueToStringArray(d[a])||[],f=b.length>d.length?b.length:d.length,e=0;f>e;e+=1){if(void 0===b[e])return c;if(void 0===d[e])return-c;if(b[e]>d[e])return-c;if(b[e]<d[e])return c}return 0}}function inherits(a,b){a.super_=b,a.prototype=Object.create(b.prototype,{constructor:{configurable:!0,enumerable:!1,writable:!0,value:a}})}function emptyFunction(){}function select(a,b,c){var d,e,f;if(!Array.isArray(a))throw new TypeError("jioquery.select(): Argument 1 is not of type Array");if(!Array.isArray(b))throw new TypeError("jioquery.select(): Argument 2 is not of type Array");for(c===!0&&(b=deepClone(b)),d=0;d<b.length;d+=1){for(f={},e=0;e<a.length;e+=1)b[d].hasOwnProperty([a[e]])&&(f[a[e]]=b[d][a[e]]);for(e in f)if(f.hasOwnProperty(e)){b[d]=f;break}}return b}function sortOn(a,b,c){var d;if(!Array.isArray(a))throw new TypeError("jioquery.sortOn(): Argument 1 is not of type 'array'");for(c&&(b=deepClone(b)),d=a.length-1;d>=0;d-=1)b.sort(sortFunction(a[d][0],a[d][1]));return b}function limit(a,b,c){if(!Array.isArray(a))throw new TypeError("jioquery.limit(): Argument 1 is not of type 'array'");if(!Array.isArray(b))throw new TypeError("jioquery.limit(): Argument 2 is not of type 'array'");return c&&(b=deepClone(b)),b.splice(0,a[0]),a[1]&&b.splice(a[1]),b}function searchTextToRegExp(a,b){if("string"!=typeof a)throw new TypeError("jioquery.searchTextToRegExp(): Argument 1 is not of type 'string'");return b===!1?new RegExp("^"+stringEscapeRegexpCharacters(a)+"$"):new RegExp("^"+stringEscapeRegexpCharacters(a).replace(/%/g,".*").replace(/_/g,".")+"$")}!function(a,b){"object"==typeof exports?module.exports=b():"function"==typeof define&&define.amd?define(b):a.IPv6=b(a)}(this,function(a){var b=a&&a.IPv6;return{best:function(a){a=a.toLowerCase().split(":");var b=a.length,c=8;""===a[0]&&""===a[1]&&""===a[2]?(a.shift(),a.shift()):""===a[0]&&""===a[1]?a.shift():""===a[b-1]&&""===a[b-2]&&a.pop(),b=a.length,-1!==a[b-1].indexOf(".")&&(c=7);var d;for(d=0;b>d&&""!==a[d];d++);if(c>d)for(a.splice(d,1,"0000");a.length<c;)a.splice(d,0,"0000");for(d=0;c>d;d++){for(var b=a[d].split(""),e=0;3>e&&("0"===b[0]&&1<b.length);e++)b.splice(0,1);a[d]=b.join("")}var b=-1,f=e=0,g=-1,h=!1;for(d=0;c>d;d++)h?"0"===a[d]?f+=1:(h=!1,f>e&&(b=g,e=f)):"0"==a[d]&&(h=!0,g=d,f=1);for(f>e&&(b=g,e=f),e>1&&a.splice(b,e,""),b=a.length,c="",""===a[0]&&(beststr=":"),d=0;b>d&&(c+=a[d],d!==b-1);d++)c+=":";return""===a[b-1]&&(c+=":"),c},noConflict:function(){return a.IPv6===this&&(a.IPv6=b),this}}}),function(a){function b(a){throw RangeError(B[a])}function c(a,b){for(var c=a.length;c--;)a[c]=b(a[c]);return a}function d(a,b){return c(a.split(A),b).join(".")}function e(a){for(var b,c,d=[],e=0,f=a.length;f>e;)b=a.charCodeAt(e++),b>=55296&&56319>=b&&f>e?(c=a.charCodeAt(e++),56320==(64512&c)?d.push(((1023&b)<<10)+(1023&c)+65536):(d.push(b),e--)):d.push(b);return d}function f(a){return c(a,function(a){var b="";return a>65535&&(a-=65536,b+=E(a>>>10&1023|55296),a=56320|1023&a),b+=E(a)}).join("")}function g(a,b){return a+22+75*(26>a)-((0!=b)<<5)}function h(a,b,c){var d=0;for(a=c?D(a/u):a>>1,a+=D(a/b);a>C*s>>1;d+=q)a=D(a/C);return D(d+(C+1)*a/(a+t))}function i(a){var c,d,e,g,i,j,k=[],l=a.length,m=0,n=w,o=v;for(d=a.lastIndexOf(x),0>d&&(d=0),e=0;d>e;++e)128<=a.charCodeAt(e)&&b("not-basic"),k.push(a.charCodeAt(e));for(d=d>0?d+1:0;l>d;){for(e=m,c=1,g=q;d>=l&&b("invalid-input"),i=a.charCodeAt(d++),i=10>i-48?i-22:26>i-65?i-65:26>i-97?i-97:q,(i>=q||i>D((p-m)/c))&&b("overflow"),m+=i*c,j=o>=g?r:g>=o+s?s:g-o,!(j>i);g+=q)i=q-j,c>D(p/i)&&b("overflow"),c*=i;c=k.length+1,o=h(m-e,c,0==e),D(m/c)>p-n&&b("overflow"),n+=D(m/c),m%=c,k.splice(m++,0,n)}return f(k)}function j(a){var c,d,f,i,j,k,l,m,n,o,t,u,y=[];for(a=e(a),o=a.length,c=w,d=0,j=v,k=0;o>k;++k)n=a[k],128>n&&y.push(E(n));for((f=i=y.length)&&y.push(x);o>f;){for(l=p,k=0;o>k;++k)n=a[k],n>=c&&l>n&&(l=n);for(t=f+1,l-c>D((p-d)/t)&&b("overflow"),d+=(l-c)*t,c=l,k=0;o>k;++k)if(n=a[k],c>n&&++d>p&&b("overflow"),n==c){for(m=d,l=q;n=j>=l?r:l>=j+s?s:l-j,!(n>m);l+=q)u=m-n,m=q-n,y.push(E(g(n+u%m,0))),m=D(u/m);y.push(E(g(m,0))),j=h(d,t,f==i),d=0,++f}++d,++c}return y.join("")}var k="object"==typeof exports&&exports,l="object"==typeof module&&module&&module.exports==k&&module,m="object"==typeof global&&global;(m.global===m||m.window===m)&&(a=m);var n,o,p=2147483647,q=36,r=1,s=26,t=38,u=700,v=72,w=128,x="-",y=/^xn--/,z=/[^ -~]/,A=/\x2E|\u3002|\uFF0E|\uFF61/g,B={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},C=q-r,D=Math.floor,E=String.fromCharCode;if(n={version:"1.2.3",ucs2:{decode:e,encode:f},decode:i,encode:j,toASCII:function(a){return d(a,function(a){return z.test(a)?"xn--"+j(a):a})},toUnicode:function(a){return d(a,function(a){return y.test(a)?i(a.slice(4).toLowerCase()):a})}},"function"==typeof define&&"object"==typeof define.amd&&define.amd)define(function(){return n});else if(k&&!k.nodeType)if(l)l.exports=n;else for(o in n)n.hasOwnProperty(o)&&(k[o]=n[o]);else a.punycode=n}(this),function(a,b){"object"==typeof exports?module.exports=b():"function"==typeof define&&define.amd?define(b):a.SecondLevelDomains=b(a)}(this,function(a){var b=a&&a.SecondLevelDomains,c=Object.prototype.hasOwnProperty,d={list:{ac:"com|gov|mil|net|org",ae:"ac|co|gov|mil|name|net|org|pro|sch",af:"com|edu|gov|net|org",al:"com|edu|gov|mil|net|org",ao:"co|ed|gv|it|og|pb",ar:"com|edu|gob|gov|int|mil|net|org|tur",at:"ac|co|gv|or",au:"asn|com|csiro|edu|gov|id|net|org",ba:"co|com|edu|gov|mil|net|org|rs|unbi|unmo|unsa|untz|unze",bb:"biz|co|com|edu|gov|info|net|org|store|tv",bh:"biz|cc|com|edu|gov|info|net|org",bn:"com|edu|gov|net|org",bo:"com|edu|gob|gov|int|mil|net|org|tv",br:"adm|adv|agr|am|arq|art|ato|b|bio|blog|bmd|cim|cng|cnt|com|coop|ecn|edu|eng|esp|etc|eti|far|flog|fm|fnd|fot|fst|g12|ggf|gov|imb|ind|inf|jor|jus|lel|mat|med|mil|mus|net|nom|not|ntr|odo|org|ppg|pro|psc|psi|qsl|rec|slg|srv|tmp|trd|tur|tv|vet|vlog|wiki|zlg",bs:"com|edu|gov|net|org",bz:"du|et|om|ov|rg",ca:"ab|bc|mb|nb|nf|nl|ns|nt|nu|on|pe|qc|sk|yk",ck:"biz|co|edu|gen|gov|info|net|org",cn:"ac|ah|bj|com|cq|edu|fj|gd|gov|gs|gx|gz|ha|hb|he|hi|hl|hn|jl|js|jx|ln|mil|net|nm|nx|org|qh|sc|sd|sh|sn|sx|tj|tw|xj|xz|yn|zj",co:"com|edu|gov|mil|net|nom|org",cr:"ac|c|co|ed|fi|go|or|sa",cy:"ac|biz|com|ekloges|gov|ltd|name|net|org|parliament|press|pro|tm","do":"art|com|edu|gob|gov|mil|net|org|sld|web",dz:"art|asso|com|edu|gov|net|org|pol",ec:"com|edu|fin|gov|info|med|mil|net|org|pro",eg:"com|edu|eun|gov|mil|name|net|org|sci",er:"com|edu|gov|ind|mil|net|org|rochest|w",es:"com|edu|gob|nom|org",et:"biz|com|edu|gov|info|name|net|org",fj:"ac|biz|com|info|mil|name|net|org|pro",fk:"ac|co|gov|net|nom|org",fr:"asso|com|f|gouv|nom|prd|presse|tm",gg:"co|net|org",gh:"com|edu|gov|mil|org",gn:"ac|com|gov|net|org",gr:"com|edu|gov|mil|net|org",gt:"com|edu|gob|ind|mil|net|org",gu:"com|edu|gov|net|org",hk:"com|edu|gov|idv|net|org",id:"ac|co|go|mil|net|or|sch|web",il:"ac|co|gov|idf|k12|muni|net|org","in":"ac|co|edu|ernet|firm|gen|gov|i|ind|mil|net|nic|org|res",iq:"com|edu|gov|i|mil|net|org",ir:"ac|co|dnssec|gov|i|id|net|org|sch",it:"edu|gov",je:"co|net|org",jo:"com|edu|gov|mil|name|net|org|sch",jp:"ac|ad|co|ed|go|gr|lg|ne|or",ke:"ac|co|go|info|me|mobi|ne|or|sc",kh:"com|edu|gov|mil|net|org|per",ki:"biz|com|de|edu|gov|info|mob|net|org|tel",km:"asso|com|coop|edu|gouv|k|medecin|mil|nom|notaires|pharmaciens|presse|tm|veterinaire",kn:"edu|gov|net|org",kr:"ac|busan|chungbuk|chungnam|co|daegu|daejeon|es|gangwon|go|gwangju|gyeongbuk|gyeonggi|gyeongnam|hs|incheon|jeju|jeonbuk|jeonnam|k|kg|mil|ms|ne|or|pe|re|sc|seoul|ulsan",kw:"com|edu|gov|net|org",ky:"com|edu|gov|net|org",kz:"com|edu|gov|mil|net|org",lb:"com|edu|gov|net|org",lk:"assn|com|edu|gov|grp|hotel|int|ltd|net|ngo|org|sch|soc|web",lr:"com|edu|gov|net|org",lv:"asn|com|conf|edu|gov|id|mil|net|org",ly:"com|edu|gov|id|med|net|org|plc|sch",ma:"ac|co|gov|m|net|org|press",mc:"asso|tm",me:"ac|co|edu|gov|its|net|org|priv",mg:"com|edu|gov|mil|nom|org|prd|tm",mk:"com|edu|gov|inf|name|net|org|pro",ml:"com|edu|gov|net|org|presse",mn:"edu|gov|org",mo:"com|edu|gov|net|org",mt:"com|edu|gov|net|org",mv:"aero|biz|com|coop|edu|gov|info|int|mil|museum|name|net|org|pro",mw:"ac|co|com|coop|edu|gov|int|museum|net|org",mx:"com|edu|gob|net|org",my:"com|edu|gov|mil|name|net|org|sch",nf:"arts|com|firm|info|net|other|per|rec|store|web",ng:"biz|com|edu|gov|mil|mobi|name|net|org|sch",ni:"ac|co|com|edu|gob|mil|net|nom|org",np:"com|edu|gov|mil|net|org",nr:"biz|com|edu|gov|info|net|org",om:"ac|biz|co|com|edu|gov|med|mil|museum|net|org|pro|sch",pe:"com|edu|gob|mil|net|nom|org|sld",ph:"com|edu|gov|i|mil|net|ngo|org",pk:"biz|com|edu|fam|gob|gok|gon|gop|gos|gov|net|org|web",pl:"art|bialystok|biz|com|edu|gda|gdansk|gorzow|gov|info|katowice|krakow|lodz|lublin|mil|net|ngo|olsztyn|org|poznan|pwr|radom|slupsk|szczecin|torun|warszawa|waw|wroc|wroclaw|zgora",pr:"ac|biz|com|edu|est|gov|info|isla|name|net|org|pro|prof",ps:"com|edu|gov|net|org|plo|sec",pw:"belau|co|ed|go|ne|or",ro:"arts|com|firm|info|nom|nt|org|rec|store|tm|www",rs:"ac|co|edu|gov|in|org",sb:"com|edu|gov|net|org",sc:"com|edu|gov|net|org",sh:"co|com|edu|gov|net|nom|org",sl:"com|edu|gov|net|org",st:"co|com|consulado|edu|embaixada|gov|mil|net|org|principe|saotome|store",sv:"com|edu|gob|org|red",sz:"ac|co|org",tr:"av|bbs|bel|biz|com|dr|edu|gen|gov|info|k12|name|net|org|pol|tel|tsk|tv|web",tt:"aero|biz|cat|co|com|coop|edu|gov|info|int|jobs|mil|mobi|museum|name|net|org|pro|tel|travel",tw:"club|com|ebiz|edu|game|gov|idv|mil|net|org",mu:"ac|co|com|gov|net|or|org",mz:"ac|co|edu|gov|org",na:"co|com",nz:"ac|co|cri|geek|gen|govt|health|iwi|maori|mil|net|org|parliament|school",pa:"abo|ac|com|edu|gob|ing|med|net|nom|org|sld",pt:"com|edu|gov|int|net|nome|org|publ",py:"com|edu|gov|mil|net|org",qa:"com|edu|gov|mil|net|org",re:"asso|com|nom",ru:"ac|adygeya|altai|amur|arkhangelsk|astrakhan|bashkiria|belgorod|bir|bryansk|buryatia|cbg|chel|chelyabinsk|chita|chukotka|chuvashia|com|dagestan|e-burg|edu|gov|grozny|int|irkutsk|ivanovo|izhevsk|jar|joshkar-ola|kalmykia|kaluga|kamchatka|karelia|kazan|kchr|kemerovo|khabarovsk|khakassia|khv|kirov|koenig|komi|kostroma|kranoyarsk|kuban|kurgan|kursk|lipetsk|magadan|mari|mari-el|marine|mil|mordovia|mosreg|msk|murmansk|nalchik|net|nnov|nov|novosibirsk|nsk|omsk|orenburg|org|oryol|penza|perm|pp|pskov|ptz|rnd|ryazan|sakhalin|samara|saratov|simbirsk|smolensk|spb|stavropol|stv|surgut|tambov|tatarstan|tom|tomsk|tsaritsyn|tsk|tula|tuva|tver|tyumen|udm|udmurtia|ulan-ude|vladikavkaz|vladimir|vladivostok|volgograd|vologda|voronezh|vrn|vyatka|yakutia|yamal|yekaterinburg|yuzhno-sakhalinsk",rw:"ac|co|com|edu|gouv|gov|int|mil|net",sa:"com|edu|gov|med|net|org|pub|sch",sd:"com|edu|gov|info|med|net|org|tv",se:"a|ac|b|bd|c|d|e|f|g|h|i|k|l|m|n|o|org|p|parti|pp|press|r|s|t|tm|u|w|x|y|z",sg:"com|edu|gov|idn|net|org|per",sn:"art|com|edu|gouv|org|perso|univ",sy:"com|edu|gov|mil|net|news|org",th:"ac|co|go|in|mi|net|or",tj:"ac|biz|co|com|edu|go|gov|info|int|mil|name|net|nic|org|test|web",tn:"agrinet|com|defense|edunet|ens|fin|gov|ind|info|intl|mincom|nat|net|org|perso|rnrt|rns|rnu|tourism",tz:"ac|co|go|ne|or",ua:"biz|cherkassy|chernigov|chernovtsy|ck|cn|co|com|crimea|cv|dn|dnepropetrovsk|donetsk|dp|edu|gov|if|in|ivano-frankivsk|kh|kharkov|kherson|khmelnitskiy|kiev|kirovograd|km|kr|ks|kv|lg|lugansk|lutsk|lviv|me|mk|net|nikolaev|od|odessa|org|pl|poltava|pp|rovno|rv|sebastopol|sumy|te|ternopil|uzhgorod|vinnica|vn|zaporizhzhe|zhitomir|zp|zt",ug:"ac|co|go|ne|or|org|sc",uk:"ac|bl|british-library|co|cym|gov|govt|icnet|jet|lea|ltd|me|mil|mod|national-library-scotland|nel|net|nhs|nic|nls|org|orgn|parliament|plc|police|sch|scot|soc",us:"dni|fed|isa|kids|nsn",uy:"com|edu|gub|mil|net|org",ve:"co|com|edu|gob|info|mil|net|org|web",vi:"co|com|k12|net|org",vn:"ac|biz|com|edu|gov|health|info|int|name|net|org|pro",ye:"co|com|gov|ltd|me|net|org|plc",yu:"ac|co|edu|gov|org",za:"ac|agric|alt|bourse|city|co|cybernet|db|edu|gov|grondar|iaccess|imt|inca|landesign|law|mil|net|ngo|nis|nom|olivetti|org|pix|school|tm|web",zm:"ac|co|com|edu|gov|net|org|sch"},has_expression:null,is_expression:null,has:function(a){return!!a.match(d.has_expression)},is:function(a){return!!a.match(d.is_expression)},get:function(a){return(a=a.match(d.has_expression))&&a[1]||null},noConflict:function(){return a.SecondLevelDomains===this&&(a.SecondLevelDomains=b),this},init:function(){var a,b="";for(a in d.list)c.call(d.list,a)&&(b+="|("+("("+d.list[a]+")."+a)+")");d.has_expression=RegExp("\\.("+b.substr(1)+")$","i"),d.is_expression=RegExp("^("+b.substr(1)+")$","i")}};return d.init(),d}),function(a,b){"object"==typeof exports?module.exports=b(require("./punycode"),require("./IPv6"),require("./SecondLevelDomains")):"function"==typeof define&&define.amd?define(["./punycode","./IPv6","./SecondLevelDomains"],b):a.URI=b(a.punycode,a.IPv6,a.SecondLevelDomains,a)}(this,function(a,b,c,d){function e(a,b){return this instanceof e?(void 0===a&&(a="undefined"!=typeof location?location.href+"":""),this.href(a),void 0!==b?this.absoluteTo(b):this):new e(a,b)}function f(a){return a.replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")}function g(a){return void 0===a?"Undefined":String(Object.prototype.toString.call(a)).slice(8,-1)}function h(a){return"Array"===g(a)}function i(a,b){var c,d;if(h(b)){for(c=0,d=b.length;d>c;c++)if(!i(a,b[c]))return!1;return!0}var e=g(b);for(c=0,d=a.length;d>c;c++)if("RegExp"===e){if("string"==typeof a[c]&&a[c].match(b))return!0}else if(a[c]===b)return!0;return!1}function j(a,b){if(!h(a)||!h(b)||a.length!==b.length)return!1;a.sort(),b.sort();for(var c=0,d=a.length;d>c;c++)if(a[c]!==b[c])return!1;return!0}function k(a){return escape(a)}function l(a){return encodeURIComponent(a).replace(/[!'()*]/g,k).replace(/\*/g,"%2A")}var m=d&&d.URI;e.version="1.12.0";var n=e.prototype,o=Object.prototype.hasOwnProperty;e._parts=function(){return{protocol:null,username:null,password:null,hostname:null,urn:null,port:null,path:null,query:null,fragment:null,duplicateQueryParameters:e.duplicateQueryParameters,escapeQuerySpace:e.escapeQuerySpace}},e.duplicateQueryParameters=!1,e.escapeQuerySpace=!0,e.protocol_expression=/^[a-z][a-z0-9.+-]*$/i,e.idn_expression=/[^a-z0-9\.-]/i,e.punycode_expression=/(xn--)/i,e.ip4_expression=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,e.ip6_expression=/^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/,e.find_uri_expression=/\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?\u00ab\u00bb\u201c\u201d\u2018\u2019]))/gi,e.findUri={start:/\b(?:([a-z][a-z0-9.+-]*:\/\/)|www\.)/gi,end:/[\s\r\n]|$/,trim:/[`!()\[\]{};:'".,<>?\u00ab\u00bb\u201c\u201d\u201e\u2018\u2019]+$/},e.defaultPorts={http:"80",https:"443",ftp:"21",gopher:"70",ws:"80",wss:"443"},e.invalid_hostname_characters=/[^a-zA-Z0-9\.-]/,e.domAttributes={a:"href",blockquote:"cite",link:"href",base:"href",script:"src",form:"action",img:"src",area:"href",iframe:"src",embed:"src",source:"src",track:"src",input:"src"},e.getDomAttribute=function(a){if(a&&a.nodeName){var b=a.nodeName.toLowerCase();return"input"===b&&"image"!==a.type?void 0:e.domAttributes[b]}},e.encode=l,e.decode=decodeURIComponent,e.iso8859=function(){e.encode=escape,e.decode=unescape},e.unicode=function(){e.encode=l,e.decode=decodeURIComponent},e.characters={pathname:{encode:{expression:/%(24|26|2B|2C|3B|3D|3A|40)/gi,map:{"%24":"$","%26":"&","%2B":"+","%2C":",","%3B":";","%3D":"=","%3A":":","%40":"@"}},decode:{expression:/[\/\?#]/g,map:{"/":"%2F","?":"%3F","#":"%23"}}},reserved:{encode:{expression:/%(21|23|24|26|27|28|29|2A|2B|2C|2F|3A|3B|3D|3F|40|5B|5D)/gi,map:{"%3A":":","%2F":"/","%3F":"?","%23":"#","%5B":"[","%5D":"]","%40":"@","%21":"!","%24":"$","%26":"&","%27":"'","%28":"(","%29":")","%2A":"*","%2B":"+","%2C":",","%3B":";","%3D":"="}}}},e.encodeQuery=function(a,b){var c=e.encode(a+"");return b?c.replace(/%20/g,"+"):c},e.decodeQuery=function(a,b){a+="";try{return e.decode(b?a.replace(/\+/g,"%20"):a)}catch(c){return a}},e.recodePath=function(a){a=(a+"").split("/");for(var b=0,c=a.length;c>b;b++)a[b]=e.encodePathSegment(e.decode(a[b]));return a.join("/")},e.decodePath=function(a){a=(a+"").split("/");for(var b=0,c=a.length;c>b;b++)a[b]=e.decodePathSegment(a[b]);return a.join("/")};var p,q={encode:"encode",decode:"decode"},r=function(a,b){return function(c){return e[b](c+"").replace(e.characters[a][b].expression,function(c){return e.characters[a][b].map[c]})}};for(p in q)e[p+"PathSegment"]=r("pathname",q[p]);e.encodeReserved=r("reserved","encode"),e.parse=function(a,b){var c;return b||(b={}),c=a.indexOf("#"),c>-1&&(b.fragment=a.substring(c+1)||null,a=a.substring(0,c)),c=a.indexOf("?"),c>-1&&(b.query=a.substring(c+1)||null,a=a.substring(0,c)),"//"===a.substring(0,2)?(b.protocol=null,a=a.substring(2),a=e.parseAuthority(a,b)):(c=a.indexOf(":"),c>-1&&(b.protocol=a.substring(0,c)||null,b.protocol&&!b.protocol.match(e.protocol_expression)?b.protocol=void 0:"file"===b.protocol?a=a.substring(c+3):"//"===a.substring(c+1,c+3)?(a=a.substring(c+3),a=e.parseAuthority(a,b)):(a=a.substring(c+1),b.urn=!0))),b.path=a,b},e.parseHost=function(a,b){var c,d=a.indexOf("/");return-1===d&&(d=a.length),"["===a.charAt(0)?(c=a.indexOf("]"),b.hostname=a.substring(1,c)||null,b.port=a.substring(c+2,d)||null):a.indexOf(":")!==a.lastIndexOf(":")?(b.hostname=a.substring(0,d)||null,b.port=null):(c=a.substring(0,d).split(":"),b.hostname=c[0]||null,b.port=c[1]||null),b.hostname&&"/"!==a.substring(d).charAt(0)&&(d++,a="/"+a),a.substring(d)||"/"},e.parseAuthority=function(a,b){return a=e.parseUserinfo(a,b),e.parseHost(a,b)},e.parseUserinfo=function(a,b){var c=a.indexOf("/"),d=c>-1?a.lastIndexOf("@",c):a.indexOf("@");return d>-1&&(-1===c||c>d)?(c=a.substring(0,d).split(":"),b.username=c[0]?e.decode(c[0]):null,c.shift(),b.password=c[0]?e.decode(c.join(":")):null,a=a.substring(d+1)):(b.username=null,b.password=null),a},e.parseQuery=function(a,b){if(!a)return{};if(a=a.replace(/&+/g,"&").replace(/^\?*&*|&+$/g,""),!a)return{};for(var c,d,f={},g=a.split("&"),h=g.length,i=0;h>i;i++)c=g[i].split("="),d=e.decodeQuery(c.shift(),b),c=c.length?e.decodeQuery(c.join("="),b):null,f[d]?("string"==typeof f[d]&&(f[d]=[f[d]]),f[d].push(c)):f[d]=c;return f},e.build=function(a){var b="";return a.protocol&&(b+=a.protocol+":"),a.urn||!b&&!a.hostname||(b+="//"),b+=e.buildAuthority(a)||"","string"==typeof a.path&&("/"!==a.path.charAt(0)&&"string"==typeof a.hostname&&(b+="/"),b+=a.path),"string"==typeof a.query&&a.query&&(b+="?"+a.query),"string"==typeof a.fragment&&a.fragment&&(b+="#"+a.fragment),b},e.buildHost=function(a){var b="";return a.hostname?(e.ip6_expression.test(a.hostname)?b=a.port?b+("["+a.hostname+"]:"+a.port):b+a.hostname:(b+=a.hostname,a.port&&(b+=":"+a.port)),b):""},e.buildAuthority=function(a){return e.buildUserinfo(a)+e.buildHost(a)},e.buildUserinfo=function(a){var b="";return a.username&&(b+=e.encode(a.username),a.password&&(b+=":"+e.encode(a.password)),b+="@"),b},e.buildQuery=function(a,b,c){var d,f,g,i,j="";for(f in a)if(o.call(a,f)&&f)if(h(a[f]))for(d={},g=0,i=a[f].length;i>g;g++)void 0!==a[f][g]&&void 0===d[a[f][g]+""]&&(j+="&"+e.buildQueryParameter(f,a[f][g],c),
!0!==b&&(d[a[f][g]+""]=!0));else void 0!==a[f]&&(j+="&"+e.buildQueryParameter(f,a[f],c));return j.substring(1)},e.buildQueryParameter=function(a,b,c){return e.encodeQuery(a,c)+(null!==b?"="+e.encodeQuery(b,c):"")},e.addQuery=function(a,b,c){if("object"==typeof b)for(var d in b)o.call(b,d)&&e.addQuery(a,d,b[d]);else{if("string"!=typeof b)throw new TypeError("URI.addQuery() accepts an object, string as the name parameter");void 0===a[b]?a[b]=c:("string"==typeof a[b]&&(a[b]=[a[b]]),h(c)||(c=[c]),a[b]=a[b].concat(c))}},e.removeQuery=function(a,b,c){var d;if(h(b))for(c=0,d=b.length;d>c;c++)a[b[c]]=void 0;else if("object"==typeof b)for(d in b)o.call(b,d)&&e.removeQuery(a,d,b[d]);else{if("string"!=typeof b)throw new TypeError("URI.addQuery() accepts an object, string as the first parameter");if(void 0!==c){if(a[b]===c)a[b]=void 0;else if(h(a[b])){d=a[b];var f,g,i={};if(h(c))for(f=0,g=c.length;g>f;f++)i[c[f]]=!0;else i[c]=!0;for(f=0,g=d.length;g>f;f++)void 0!==i[d[f]]&&(d.splice(f,1),g--,f--);a[b]=d}}else a[b]=void 0}},e.hasQuery=function(a,b,c,d){if("object"==typeof b){for(var f in b)if(o.call(b,f)&&!e.hasQuery(a,f,b[f]))return!1;return!0}if("string"!=typeof b)throw new TypeError("URI.hasQuery() accepts an object, string as the name parameter");switch(g(c)){case"Undefined":return b in a;case"Boolean":return a=Boolean(h(a[b])?a[b].length:a[b]),c===a;case"Function":return!!c(a[b],b,a);case"Array":return h(a[b])?(d?i:j)(a[b],c):!1;case"RegExp":return h(a[b])?d?i(a[b],c):!1:Boolean(a[b]&&a[b].match(c));case"Number":c=String(c);case"String":return h(a[b])?d?i(a[b],c):!1:a[b]===c;default:throw new TypeError("URI.hasQuery() accepts undefined, boolean, string, number, RegExp, Function as the value parameter")}},e.commonPath=function(a,b){var c,d=Math.min(a.length,b.length);for(c=0;d>c;c++)if(a.charAt(c)!==b.charAt(c)){c--;break}return 1>c?a.charAt(0)===b.charAt(0)&&"/"===a.charAt(0)?"/":"":(("/"!==a.charAt(c)||"/"!==b.charAt(c))&&(c=a.substring(0,c).lastIndexOf("/")),a.substring(0,c+1))},e.withinString=function(a,b,c){c||(c={});var d=c.start||e.findUri.start,f=c.end||e.findUri.end,g=c.trim||e.findUri.trim,h=/[a-z0-9-]=["']?$/i;for(d.lastIndex=0;;){var i=d.exec(a);if(!i)break;if(i=i.index,c.ignoreHtml){var j=a.slice(Math.max(i-3,0),i);if(j&&h.test(j))continue}var j=i+a.slice(i).search(f),k=a.slice(i,j).replace(g,"");c.ignore&&c.ignore.test(k)||(j=i+k.length,k=b(k,i,j,a),a=a.slice(0,i)+k+a.slice(j),d.lastIndex=i+k.length)}return d.lastIndex=0,a},e.ensureValidHostname=function(b){if(b.match(e.invalid_hostname_characters)){if(!a)throw new TypeError("Hostname '"+b+"' contains characters other than [A-Z0-9.-] and Punycode.js is not available");if(a.toASCII(b).match(e.invalid_hostname_characters))throw new TypeError("Hostname '"+b+"' contains characters other than [A-Z0-9.-]")}},e.noConflict=function(a){return a?(a={URI:this.noConflict()},URITemplate&&"function"==typeof URITemplate.noConflict&&(a.URITemplate=URITemplate.noConflict()),b&&"function"==typeof b.noConflict&&(a.IPv6=b.noConflict()),SecondLevelDomains&&"function"==typeof SecondLevelDomains.noConflict&&(a.SecondLevelDomains=SecondLevelDomains.noConflict()),a):(d.URI===this&&(d.URI=m),this)},n.build=function(a){return!0===a?this._deferred_build=!0:(void 0===a||this._deferred_build)&&(this._string=e.build(this._parts),this._deferred_build=!1),this},n.clone=function(){return new e(this)},n.valueOf=n.toString=function(){return this.build(!1)._string},q={protocol:"protocol",username:"username",password:"password",hostname:"hostname",port:"port"},r=function(a){return function(b,c){return void 0===b?this._parts[a]||"":(this._parts[a]=b||null,this.build(!c),this)}};for(p in q)n[p]=r(q[p]);q={query:"?",fragment:"#"},r=function(a,b){return function(c,d){return void 0===c?this._parts[a]||"":(null!==c&&(c+="",c.charAt(0)===b&&(c=c.substring(1))),this._parts[a]=c,this.build(!d),this)}};for(p in q)n[p]=r(p,q[p]);q={search:["?","query"],hash:["#","fragment"]},r=function(a,b){return function(c,d){var e=this[a](c,d);return"string"==typeof e&&e.length?b+e:e}};for(p in q)n[p]=r(q[p][1],q[p][0]);n.pathname=function(a,b){if(void 0===a||!0===a){var c=this._parts.path||(this._parts.hostname?"/":"");return a?e.decodePath(c):c}return this._parts.path=a?e.recodePath(a):"/",this.build(!b),this},n.path=n.pathname,n.href=function(a,b){var c;if(void 0===a)return this.toString();this._string="",this._parts=e._parts();var d=a instanceof e,f="object"==typeof a&&(a.hostname||a.path||a.pathname);if(a.nodeName&&(f=e.getDomAttribute(a),a=a[f]||"",f=!1),!d&&f&&void 0!==a.pathname&&(a=a.toString()),"string"==typeof a)this._parts=e.parse(a,this._parts);else{if(!d&&!f)throw new TypeError("invalid input");for(c in d=d?a._parts:a)o.call(this._parts,c)&&(this._parts[c]=d[c])}return this.build(!b),this},n.is=function(a){var b=!1,d=!1,f=!1,g=!1,h=!1,i=!1,j=!1,k=!this._parts.urn;switch(this._parts.hostname&&(k=!1,d=e.ip4_expression.test(this._parts.hostname),f=e.ip6_expression.test(this._parts.hostname),b=d||f,h=(g=!b)&&c&&c.has(this._parts.hostname),i=g&&e.idn_expression.test(this._parts.hostname),j=g&&e.punycode_expression.test(this._parts.hostname)),a.toLowerCase()){case"relative":return k;case"absolute":return!k;case"domain":case"name":return g;case"sld":return h;case"ip":return b;case"ip4":case"ipv4":case"inet4":return d;case"ip6":case"ipv6":case"inet6":return f;case"idn":return i;case"url":return!this._parts.urn;case"urn":return!!this._parts.urn;case"punycode":return j}return null};var s=n.protocol,t=n.port,u=n.hostname;n.protocol=function(a,b){if(void 0!==a&&a&&(a=a.replace(/:(\/\/)?$/,""),!a.match(e.protocol_expression)))throw new TypeError("Protocol '"+a+"' contains characters other than [A-Z0-9.+-] or doesn't start with [A-Z]");return s.call(this,a,b)},n.scheme=n.protocol,n.port=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0!==a&&(0===a&&(a=null),a&&(a+="",":"===a.charAt(0)&&(a=a.substring(1)),a.match(/[^0-9]/))))throw new TypeError("Port '"+a+"' contains characters other than [0-9]");return t.call(this,a,b)},n.hostname=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0!==a){var c={};e.parseHost(a,c),a=c.hostname}return u.call(this,a,b)},n.host=function(a,b){return this._parts.urn?void 0===a?"":this:void 0===a?this._parts.hostname?e.buildHost(this._parts):"":(e.parseHost(a,this._parts),this.build(!b),this)},n.authority=function(a,b){return this._parts.urn?void 0===a?"":this:void 0===a?this._parts.hostname?e.buildAuthority(this._parts):"":(e.parseAuthority(a,this._parts),this.build(!b),this)},n.userinfo=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a){if(!this._parts.username)return"";var c=e.buildUserinfo(this._parts);return c.substring(0,c.length-1)}return"@"!==a[a.length-1]&&(a+="@"),e.parseUserinfo(a,this._parts),this.build(!b),this},n.resource=function(a,b){var c;return void 0===a?this.path()+this.search()+this.hash():(c=e.parse(a),this._parts.path=c.path,this._parts.query=c.query,this._parts.fragment=c.fragment,this.build(!b),this)},n.subdomain=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a){if(!this._parts.hostname||this.is("IP"))return"";var c=this._parts.hostname.length-this.domain().length-1;return this._parts.hostname.substring(0,c)||""}return c=this._parts.hostname.length-this.domain().length,c=this._parts.hostname.substring(0,c),c=RegExp("^"+f(c)),a&&"."!==a.charAt(a.length-1)&&(a+="."),a&&e.ensureValidHostname(a),this._parts.hostname=this._parts.hostname.replace(c,a),this.build(!b),this},n.domain=function(a,b){if(this._parts.urn)return void 0===a?"":this;if("boolean"==typeof a&&(b=a,a=void 0),void 0===a){if(!this._parts.hostname||this.is("IP"))return"";var c=this._parts.hostname.match(/\./g);return c&&2>c.length?this._parts.hostname:(c=this._parts.hostname.length-this.tld(b).length-1,c=this._parts.hostname.lastIndexOf(".",c-1)+1,this._parts.hostname.substring(c)||"")}if(!a)throw new TypeError("cannot set domain empty");return e.ensureValidHostname(a),!this._parts.hostname||this.is("IP")?this._parts.hostname=a:(c=RegExp(f(this.domain())+"$"),this._parts.hostname=this._parts.hostname.replace(c,a)),this.build(!b),this},n.tld=function(a,b){if(this._parts.urn)return void 0===a?"":this;if("boolean"==typeof a&&(b=a,a=void 0),void 0===a){if(!this._parts.hostname||this.is("IP"))return"";var d=this._parts.hostname.lastIndexOf("."),d=this._parts.hostname.substring(d+1);return!0!==b&&c&&c.list[d.toLowerCase()]?c.get(this._parts.hostname)||d:d}if(!a)throw new TypeError("cannot set TLD empty");if(a.match(/[^a-zA-Z0-9-]/)){if(!c||!c.is(a))throw new TypeError("TLD '"+a+"' contains characters other than [A-Z0-9]");d=RegExp(f(this.tld())+"$"),this._parts.hostname=this._parts.hostname.replace(d,a)}else{if(!this._parts.hostname||this.is("IP"))throw new ReferenceError("cannot set TLD on non-domain host");d=RegExp(f(this.tld())+"$"),this._parts.hostname=this._parts.hostname.replace(d,a)}return this.build(!b),this},n.directory=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a||!0===a){if(!this._parts.path&&!this._parts.hostname)return"";if("/"===this._parts.path)return"/";var c=this._parts.path.length-this.filename().length-1,c=this._parts.path.substring(0,c)||(this._parts.hostname?"/":"");return a?e.decodePath(c):c}return c=this._parts.path.length-this.filename().length,c=this._parts.path.substring(0,c),c=RegExp("^"+f(c)),this.is("relative")||(a||(a="/"),"/"!==a.charAt(0)&&(a="/"+a)),a&&"/"!==a.charAt(a.length-1)&&(a+="/"),a=e.recodePath(a),this._parts.path=this._parts.path.replace(c,a),this.build(!b),this},n.filename=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a||!0===a){if(!this._parts.path||"/"===this._parts.path)return"";var c=this._parts.path.lastIndexOf("/"),c=this._parts.path.substring(c+1);return a?e.decodePathSegment(c):c}c=!1,"/"===a.charAt(0)&&(a=a.substring(1)),a.match(/\.?\//)&&(c=!0);var d=RegExp(f(this.filename())+"$");return a=e.recodePath(a),this._parts.path=this._parts.path.replace(d,a),c?this.normalizePath(b):this.build(!b),this},n.suffix=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a||!0===a){if(!this._parts.path||"/"===this._parts.path)return"";var c=this.filename(),d=c.lastIndexOf(".");return-1===d?"":(c=c.substring(d+1),c=/^[a-z0-9%]+$/i.test(c)?c:"",a?e.decodePathSegment(c):c)}if("."===a.charAt(0)&&(a=a.substring(1)),c=this.suffix())d=a?RegExp(f(c)+"$"):RegExp(f("."+c)+"$");else{if(!a)return this;this._parts.path+="."+e.recodePath(a)}return d&&(a=e.recodePath(a),this._parts.path=this._parts.path.replace(d,a)),this.build(!b),this},n.segment=function(a,b,c){var d=this._parts.urn?":":"/",e=this.path(),f="/"===e.substring(0,1),e=e.split(d);if(void 0!==a&&"number"!=typeof a&&(c=b,b=a,a=void 0),void 0!==a&&"number"!=typeof a)throw Error("Bad segment '"+a+"', must be 0-based integer");if(f&&e.shift(),0>a&&(a=Math.max(e.length+a,0)),void 0===b)return void 0===a?e:e[a];if(null===a||void 0===e[a])if(h(b)){e=[],a=0;for(var g=b.length;g>a;a++)(b[a].length||e.length&&e[e.length-1].length)&&(e.length&&!e[e.length-1].length&&e.pop(),e.push(b[a]))}else(b||"string"==typeof b)&&(""===e[e.length-1]?e[e.length-1]=b:e.push(b));else b||"string"==typeof b&&b.length?e[a]=b:e.splice(a,1);return f&&e.unshift(""),this.path(e.join(d),c)},n.segmentCoded=function(a,b,c){var d,f;if("number"!=typeof a&&(c=b,b=a,a=void 0),void 0===b){if(a=this.segment(a,b,c),h(a))for(d=0,f=a.length;f>d;d++)a[d]=e.decode(a[d]);else a=void 0!==a?e.decode(a):void 0;return a}if(h(b))for(d=0,f=b.length;f>d;d++)b[d]=e.decode(b[d]);else b="string"==typeof b?e.encode(b):b;return this.segment(a,b,c)};var v=n.query;return n.query=function(a,b){if(!0===a)return e.parseQuery(this._parts.query,this._parts.escapeQuerySpace);if("function"==typeof a){var c=e.parseQuery(this._parts.query,this._parts.escapeQuerySpace),d=a.call(this,c);return this._parts.query=e.buildQuery(d||c,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),this.build(!b),this}return void 0!==a&&"string"!=typeof a?(this._parts.query=e.buildQuery(a,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),this.build(!b),this):v.call(this,a,b)},n.setQuery=function(a,b,c){var d=e.parseQuery(this._parts.query,this._parts.escapeQuerySpace);if("object"==typeof a)for(var f in a)o.call(a,f)&&(d[f]=a[f]);else{if("string"!=typeof a)throw new TypeError("URI.addQuery() accepts an object, string as the name parameter");d[a]=void 0!==b?b:null}return this._parts.query=e.buildQuery(d,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),"string"!=typeof a&&(c=b),this.build(!c),this},n.addQuery=function(a,b,c){var d=e.parseQuery(this._parts.query,this._parts.escapeQuerySpace);return e.addQuery(d,a,void 0===b?null:b),this._parts.query=e.buildQuery(d,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),"string"!=typeof a&&(c=b),this.build(!c),this},n.removeQuery=function(a,b,c){var d=e.parseQuery(this._parts.query,this._parts.escapeQuerySpace);return e.removeQuery(d,a,b),this._parts.query=e.buildQuery(d,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),"string"!=typeof a&&(c=b),this.build(!c),this},n.hasQuery=function(a,b,c){var d=e.parseQuery(this._parts.query,this._parts.escapeQuerySpace);return e.hasQuery(d,a,b,c)},n.setSearch=n.setQuery,n.addSearch=n.addQuery,n.removeSearch=n.removeQuery,n.hasSearch=n.hasQuery,n.normalize=function(){return this._parts.urn?this.normalizeProtocol(!1).normalizeQuery(!1).normalizeFragment(!1).build():this.normalizeProtocol(!1).normalizeHostname(!1).normalizePort(!1).normalizePath(!1).normalizeQuery(!1).normalizeFragment(!1).build()},n.normalizeProtocol=function(a){return"string"==typeof this._parts.protocol&&(this._parts.protocol=this._parts.protocol.toLowerCase(),this.build(!a)),this},n.normalizeHostname=function(c){return this._parts.hostname&&(this.is("IDN")&&a?this._parts.hostname=a.toASCII(this._parts.hostname):this.is("IPv6")&&b&&(this._parts.hostname=b.best(this._parts.hostname)),this._parts.hostname=this._parts.hostname.toLowerCase(),this.build(!c)),this},n.normalizePort=function(a){return"string"==typeof this._parts.protocol&&this._parts.port===e.defaultPorts[this._parts.protocol]&&(this._parts.port=null,this.build(!a)),this},n.normalizePath=function(a){if(this._parts.urn||!this._parts.path||"/"===this._parts.path)return this;var b,c,d,f=this._parts.path,g="";for("/"!==f.charAt(0)&&(b=!0,f="/"+f),f=f.replace(/(\/(\.\/)+)|(\/\.$)/g,"/").replace(/\/{2,}/g,"/"),b&&(g=f.substring(1).match(/^(\.\.\/)+/)||"")&&(g=g[0]);c=f.indexOf("/.."),-1!==c;)0!==c?(d=f.substring(0,c).lastIndexOf("/"),-1===d&&(d=c),f=f.substring(0,d)+f.substring(c+3)):f=f.substring(3);return b&&this.is("relative")&&(f=g+f.substring(1)),f=e.recodePath(f),this._parts.path=f,this.build(!a),this},n.normalizePathname=n.normalizePath,n.normalizeQuery=function(a){return"string"==typeof this._parts.query&&(this._parts.query.length?this.query(e.parseQuery(this._parts.query,this._parts.escapeQuerySpace)):this._parts.query=null,this.build(!a)),this},n.normalizeFragment=function(a){return this._parts.fragment||(this._parts.fragment=null,this.build(!a)),this},n.normalizeSearch=n.normalizeQuery,n.normalizeHash=n.normalizeFragment,n.iso8859=function(){var a=e.encode,b=e.decode;return e.encode=escape,e.decode=decodeURIComponent,this.normalize(),e.encode=a,e.decode=b,this},n.unicode=function(){var a=e.encode,b=e.decode;return e.encode=l,e.decode=unescape,this.normalize(),e.encode=a,e.decode=b,this},n.readable=function(){var b=this.clone();b.username("").password("").normalize();var c="";if(b._parts.protocol&&(c+=b._parts.protocol+"://"),b._parts.hostname&&(b.is("punycode")&&a?(c+=a.toUnicode(b._parts.hostname),b._parts.port&&(c+=":"+b._parts.port)):c+=b.host()),b._parts.hostname&&b._parts.path&&"/"!==b._parts.path.charAt(0)&&(c+="/"),c+=b.path(!0),b._parts.query){for(var d="",f=0,g=b._parts.query.split("&"),h=g.length;h>f;f++){var i=(g[f]||"").split("="),d=d+("&"+e.decodeQuery(i[0],this._parts.escapeQuerySpace).replace(/&/g,"%26"));void 0!==i[1]&&(d+="="+e.decodeQuery(i[1],this._parts.escapeQuerySpace).replace(/&/g,"%26"))}c+="?"+d.substring(1)}return c+=e.decodeQuery(b.hash(),!0)},n.absoluteTo=function(a){var b,c,d=this.clone(),f=["protocol","username","password","hostname","port"];if(this._parts.urn)throw Error("URNs do not have any generally defined hierarchical components");if(a instanceof e||(a=new e(a)),d._parts.protocol||(d._parts.protocol=a._parts.protocol),this._parts.hostname)return d;for(b=0;c=f[b];b++)d._parts[c]=a._parts[c];return d._parts.path?".."===d._parts.path.substring(-2)&&(d._parts.path+="/"):(d._parts.path=a._parts.path,d._parts.query||(d._parts.query=a._parts.query)),"/"!==d.path().charAt(0)&&(a=a.directory(),d._parts.path=(a?a+"/":"")+d._parts.path,d.normalizePath()),d.build(),d},n.relativeTo=function(a){var b,c,d,f,g=this.clone().normalize();if(g._parts.urn)throw Error("URNs do not have any generally defined hierarchical components");if(a=new e(a).normalize(),b=g._parts,c=a._parts,d=g.path(),f=a.path(),"/"!==d.charAt(0))throw Error("URI is already relative");if("/"!==f.charAt(0))throw Error("Cannot calculate a URI relative to another relative URI");return b.protocol===c.protocol&&(b.protocol=null),b.username!==c.username||b.password!==c.password||null!==b.protocol||null!==b.username||null!==b.password||b.hostname!==c.hostname||b.port!==c.port?g.build():(b.hostname=null,b.port=null,d===f?(b.path="",g.build()):(a=e.commonPath(g.path(),a.path()))?(c=c.path.substring(a.length).replace(/[^\/]*$/,"").replace(/.*?\//g,"../"),b.path=c+b.path.substring(a.length),g.build()):g.build())},n.equals=function(a){var b=this.clone();a=new e(a);var c,d={},f={},g={};if(b.normalize(),a.normalize(),b.toString()===a.toString())return!0;if(d=b.query(),f=a.query(),b.query(""),a.query(""),b.toString()!==a.toString()||d.length!==f.length)return!1;d=e.parseQuery(d,this._parts.escapeQuerySpace),f=e.parseQuery(f,this._parts.escapeQuerySpace);for(c in d)if(o.call(d,c)){if(h(d[c])){if(!j(d[c],f[c]))return!1}else if(d[c]!==f[c])return!1;g[c]=!0}for(c in f)if(o.call(f,c)&&!g[c])return!1;return!0},n.duplicateQueryParameters=function(a){return this._parts.duplicateQueryParameters=!!a,this},n.escapeQuerySpace=function(a){return this._parts.escapeQuerySpace=!!a,this},e}),function(a,b){"object"==typeof exports?module.exports=b(require("./URI")):"function"==typeof define&&define.amd?define(["./URI"],b):b(a.URI)}(this,function(a){var b=a.prototype,c=b.fragment;a.fragmentPrefix="?";var d=a._parts;return a._parts=function(){var b=d();return b.fragmentPrefix=a.fragmentPrefix,b},b.fragmentPrefix=function(a){return this._parts.fragmentPrefix=a,this},b.fragment=function(b,d){var e=this._parts.fragmentPrefix,f=this._parts.fragment||"";return!0===b?f.substring(0,e.length)!==e?{}:a.parseQuery(f.substring(e.length)):void 0!==b&&"string"!=typeof b?(this._parts.fragment=e+a.buildQuery(b),this.build(!d),this):c.call(this,b,d)},b.addFragment=function(b,c,d){var e=this._parts.fragmentPrefix,f=a.parseQuery((this._parts.fragment||"").substring(e.length));return a.addQuery(f,b,c),this._parts.fragment=e+a.buildQuery(f),"string"!=typeof b&&(d=c),this.build(!d),this},b.removeFragment=function(b,c,d){var e=this._parts.fragmentPrefix,f=a.parseQuery((this._parts.fragment||"").substring(e.length));return a.removeQuery(f,b,c),this._parts.fragment=e+a.buildQuery(f),"string"!=typeof b&&(d=c),this.build(!d),this},b.addHash=b.addFragment,b.removeHash=b.removeFragment,{}}),function(a){"use strict";function b(a){var c;if(null===a||void 0===a)return!1;if(d.isArray(a))return a.length>0;if("string"==typeof a||"number"==typeof a||"boolean"==typeof a)return!0;for(c in a)if(a.hasOwnProperty(c)&&b(a[c]))return!0;return!1}var c=function(){function a(a){this.options=a}return a.prototype.toString=function(){return JSON&&JSON.stringify?JSON.stringify(this.options):this.options},a}(),d=function(){function a(a){return"[object Array]"===Object.prototype.toString.apply(a)}function b(a){return"[object String]"===Object.prototype.toString.apply(a)}function c(a){return"[object Number]"===Object.prototype.toString.apply(a)}function d(a){return"[object Boolean]"===Object.prototype.toString.apply(a)}function e(a,b){var c,d="",e=!0;for(c=0;c<a.length;c+=1)e?e=!1:d+=b,d+=a[c];return d}function f(a,b){for(var c=[],d=0;d<a.length;d+=1)c.push(b(a[d]));return c}function g(a,b){for(var c=[],d=0;d<a.length;d+=1)b(a[d])&&c.push(a[d]);return c}function h(a){if("object"!=typeof a||null===a)return a;Object.freeze(a);var b,c;for(c in a)a.hasOwnProperty(c)&&(b=a[c],"object"==typeof b&&i(b));return a}function i(a){return"function"==typeof Object.freeze?h(a):a}return{isArray:a,isString:b,isNumber:c,isBoolean:d,join:e,map:f,filter:g,deepFreeze:i}}(),e=function(){function a(a){return a>="a"&&"z">=a||a>="A"&&"Z">=a}function b(a){return a>="0"&&"9">=a}function c(a){return b(a)||a>="a"&&"f">=a||a>="A"&&"F">=a}return{isAlpha:a,isDigit:b,isHexDigit:c}}(),f=function(){function a(a){var b,c,d="",e=g.encode(a);for(c=0;c<e.length;c+=1)b=e.charCodeAt(c),d+="%"+(16>b?"0":"")+b.toString(16).toUpperCase();return d}function b(a,b){return"%"===a.charAt(b)&&e.isHexDigit(a.charAt(b+1))&&e.isHexDigit(a.charAt(b+2))}function c(a,b){return parseInt(a.substr(b,2),16)}function d(a){if(!b(a,0))return!1;var d=c(a,1),e=g.numBytes(d);if(0===e)return!1;for(var f=1;e>f;f+=1)if(!b(a,3*f)||!g.isValidFollowingCharCode(c(a,3*f+1)))return!1;return!0}function f(a,d){var e=a.charAt(d);if(!b(a,d))return e;var f=c(a,d+1),h=g.numBytes(f);if(0===h)return e;for(var i=1;h>i;i+=1)if(!b(a,d+3*i)||!g.isValidFollowingCharCode(c(a,d+3*i+1)))return e;return a.substr(d,3*h)}var g={encode:function(a){return unescape(encodeURIComponent(a))},numBytes:function(a){return 127>=a?1:a>=194&&223>=a?2:a>=224&&239>=a?3:a>=240&&244>=a?4:0},isValidFollowingCharCode:function(a){return a>=128&&191>=a}};return{encodeCharacter:a,isPctEncoded:d,pctCharAt:f}}(),g=function(){function a(a){return e.isAlpha(a)||e.isDigit(a)||"_"===a||f.isPctEncoded(a)}function b(a){return e.isAlpha(a)||e.isDigit(a)||"-"===a||"."===a||"_"===a||"~"===a}function c(a){return":"===a||"/"===a||"?"===a||"#"===a||"["===a||"]"===a||"@"===a||"!"===a||"$"===a||"&"===a||"("===a||")"===a||"*"===a||"+"===a||","===a||";"===a||"="===a||"'"===a}return{isVarchar:a,isUnreserved:b,isReserved:c}}(),h=function(){function a(a,b){var c,d="",e="";for(("number"==typeof a||"boolean"==typeof a)&&(a=a.toString()),c=0;c<a.length;c+=e.length)e=a.charAt(c),d+=g.isUnreserved(e)||b&&g.isReserved(e)?e:f.encodeCharacter(e);return d}function b(b){return a(b,!0)}function c(a,b){var c=f.pctCharAt(a,b);return c.length>1?c:g.isReserved(c)||g.isUnreserved(c)?c:f.encodeCharacter(c)}function d(a){var b,c="",d="";for(b=0;b<a.length;b+=d.length)d=f.pctCharAt(a,b),c+=d.length>1?d:g.isReserved(d)||g.isUnreserved(d)?d:f.encodeCharacter(d);return c}return{encode:a,encodePassReserved:b,encodeLiteral:d,encodeLiteralCharacter:c}}(),i=function(){function a(a){b[a]={symbol:a,separator:"?"===a?"&":""===a||"+"===a||"#"===a?",":a,named:";"===a||"&"===a||"?"===a,ifEmpty:"&"===a||"?"===a?"=":"",first:"+"===a?"":a,encode:"+"===a||"#"===a?h.encodePassReserved:h.encode,toString:function(){return this.symbol}}}var b={};return a(""),a("+"),a("#"),a("."),a("/"),a(";"),a("?"),a("&"),{valueOf:function(a){return b[a]?b[a]:"=,!@|".indexOf(a)>=0?null:b[""]}}}(),j=function(){function a(a){this.literal=h.encodeLiteral(a)}return a.prototype.expand=function(){return this.literal},a.prototype.toString=a.prototype.expand,a}(),k=function(){function a(a){function b(){var b=a.substring(n,j);if(0===b.length)throw new c({expressionText:a,message:"a varname must be specified",position:j});m={varname:b,exploded:!1,maxLength:null},n=null}function d(){if(o===j)throw new c({expressionText:a,message:"after a ':' you have to specify the length",position:j});m.maxLength=parseInt(a.substring(o,j),10),o=null}var h,j,k=[],m=null,n=null,o=null,p="";for(h=function(b){var d=i.valueOf(b);if(null===d)throw new c({expressionText:a,message:"illegal use of reserved operator",position:j,operator:b});return d}(a.charAt(0)),j=h.symbol.length,n=j;j<a.length;j+=p.length){if(p=f.pctCharAt(a,j),null!==n){if("."===p){if(n===j)throw new c({expressionText:a,message:"a varname MUST NOT start with a dot",position:j});continue}if(g.isVarchar(p))continue;b()}if(null!==o){if(j===o&&"0"===p)throw new c({expressionText:a,message:"A :prefix must not start with digit 0",position:j});if(e.isDigit(p)){if(j-o>=4)throw new c({expressionText:a,message:"A :prefix must have max 4 digits",position:j});continue}d()}if(":"!==p)if("*"!==p){if(","!==p)throw new c({expressionText:a,message:"illegal character",character:p,position:j});k.push(m),m=null,n=j+1}else{if(null===m)throw new c({expressionText:a,message:"exploded without varspec",position:j});if(m.exploded)throw new c({expressionText:a,message:"exploded twice",position:j});if(m.maxLength)throw new c({expressionText:a,message:"an explode (*) MUST NOT follow to a prefix",position:j});m.exploded=!0}else{if(null!==m.maxLength)throw new c({expressionText:a,message:"only one :maxLength is allowed per varspec",position:j});if(m.exploded)throw new c({expressionText:a,message:"an exploeded varspec MUST NOT be varspeced",position:j});o=j+1}}return null!==n&&b(),null!==o&&d(),k.push(m),new l(a,h,k)}function b(a){return a.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function d(d){var e,f,g,h=[],i=null,k="",l=!0,n=0;for(e=0;e<d.length;e+=1)if(f=d.charAt(e),null===n){if(null===i)throw new Error("reached unreachable code");if("{"===f)throw new c({templateText:d,message:"brace already opened",position:e});if("}"===f){if(i+1===e)throw new c({templateText:d,message:"empty braces",position:i});try{g=a(d.substring(i+1,e))}catch(o){if(o.prototype===c.prototype)throw new c({templateText:d,message:o.options.message,position:i+o.options.position,details:o.options});throw o}h.push(g),0===g.operator.symbol.length?k+="([^/]+)":l=!1,i=null,n=e+1}}else{if("}"===f)throw new c({templateText:d,message:"unopened brace closed",position:e});"{"===f&&(e>n&&(g=new j(d.substring(n,e)),h.push(g),k+=b(g.literal)),n=null,i=e)}if(null!==i)throw new c({templateText:d,message:"unclosed brace",position:i});return n<d.length&&(g=new j(d.substring(n)),h.push(g),k+=b(g.literal)),l===!1&&(k=void 0),new m(d,h,k)}return d}(),l=function(){function a(a){return JSON&&JSON.stringify?JSON.stringify(a):a}function c(a){if(!b(a))return!0;if(d.isString(a))return""===a;if(d.isNumber(a)||d.isBoolean(a))return!1;if(d.isArray(a))return 0===a.length;for(var c in a)if(a.hasOwnProperty(c))return!1;return!0}function e(a){var b,c=[];for(b in a)a.hasOwnProperty(b)&&c.push({name:b,value:a[b]});return c}function f(a,b,c){this.templateText=a,this.operator=b,this.varspecs=c}function g(a,b,c){var d="";if(c=c.toString(),b.named){if(d+=h.encodeLiteral(a.varname),""===c)return d+=b.ifEmpty;d+="="}return null!==a.maxLength&&(c=c.substr(0,a.maxLength)),d+=b.encode(c)}function i(a){return b(a.value)}function j(a,f,g){var j=[],k="";if(f.named){if(k+=h.encodeLiteral(a.varname),c(g))return k+=f.ifEmpty;k+="="}return d.isArray(g)?(j=g,j=d.filter(j,b),j=d.map(j,f.encode),k+=d.join(j,",")):(j=e(g),j=d.filter(j,i),j=d.map(j,function(a){return f.encode(a.name)+","+f.encode(a.value)}),k+=d.join(j,",")),k}function k(a,f,g){var j=d.isArray(g),k=[];return j?(k=g,k=d.filter(k,b),k=d.map(k,function(b){var d=h.encodeLiteral(a.varname);return d+=c(b)?f.ifEmpty:"="+f.encode(b)})):(k=e(g),k=d.filter(k,i),k=d.map(k,function(a){var b=h.encodeLiteral(a.name);return b+=c(a.value)?f.ifEmpty:"="+f.encode(a.value)})),d.join(k,f.separator)}function l(a,c){var f=[],g="";return d.isArray(c)?(f=c,f=d.filter(f,b),f=d.map(f,a.encode),g+=d.join(f,a.separator)):(f=e(c),f=d.filter(f,function(a){return b(a.value)}),f=d.map(f,function(b){return a.encode(b.name)+"="+a.encode(b.value)}),g+=d.join(f,a.separator)),g}return f.prototype.toString=function(){return this.templateText},f.prototype.expand=function(e){var f,h,i,m,n=[],o=!1,p=this.operator;for(f=0;f<this.varspecs.length;f+=1)if(h=this.varspecs[f],i=e[h.varname],null!==i&&void 0!==i)if(h.exploded&&(o=!0),m=d.isArray(i),"string"==typeof i||"number"==typeof i||"boolean"==typeof i)n.push(g(h,p,i));else{if(h.maxLength&&b(i))throw new Error("Prefix modifiers are not applicable to variables that have composite values. You tried to expand "+this+" with "+a(i));h.exploded?b(i)&&(p.named?n.push(k(h,p,i)):n.push(l(p,i))):(p.named||!c(i))&&n.push(j(h,p,i))}return 0===n.length?"":p.first+d.join(n,p.separator)},f}(),m=function(){function a(a,b,c){this.templateText=a,this.expressions=b,void 0!==c&&(this.regexp=new RegExp("^"+c+"$")),d.deepFreeze(this)}return a.prototype.toString=function(){return this.templateText},a.prototype.expand=function(a){var b,c="";for(b=0;b<this.expressions.length;b+=1)c+=this.expressions[b].expand(a);return c},a.prototype.extract=function(a){var b,c,d,e,f=1,g=!0,h={};if(void 0!==this.regexp&&this.regexp.test(a)){for(e=this.regexp.exec(a),b=0;b<this.expressions.length;b+=1)c=this.expressions[b],void 0===c.literal&&(void 0!==c.operator&&0===c.operator.symbol.length&&1===c.varspecs.length?(d=c.varspecs[0],d.exploded===!1&&null===d.maxLength&&-1===e[f].indexOf(",")?(h[d.varname]=decodeURIComponent(e[f]),f+=1):g=!1):g=!1);if(g)return h}return!1},a.parse=k,a.UriTemplateError=c,a}();a(m)}(function(a){"use strict";"undefined"!=typeof module?module.exports=a:"function"==typeof define?define([],function(){return a}):"undefined"!=typeof window?window.UriTemplate=a:global.UriTemplate=a});var LZString=function(){function a(a,b){if(!e[a]){e[a]={};for(var c=0;c<a.length;c++)e[a][a.charAt(c)]=c}return e[a][b]}var b=String.fromCharCode,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",e={},f={compressToBase64:function(a){if(null==a)return"";var b=f._compress(a,6,function(a){return c.charAt(a)});switch(b.length%4){default:case 0:return b;case 1:return b+"===";case 2:return b+"==";case 3:return b+"="}},decompressFromBase64:function(b){return null==b?"":""==b?null:f._decompress(b.length,32,function(d){return a(c,b.charAt(d))})},compressToUTF16:function(a){return null==a?"":f._compress(a,15,function(a){return b(a+32)})+" "},decompressFromUTF16:function(a){return null==a?"":""==a?null:f._decompress(a.length,16384,function(b){return a.charCodeAt(b)-32})},compressToUint8Array:function(a){for(var b=f.compress(a),c=new Uint8Array(2*b.length),d=0,e=b.length;e>d;d++){var g=b.charCodeAt(d);c[2*d]=g>>>8,c[2*d+1]=g%256}return c},decompressFromUint8Array:function(a){if(null===a||void 0===a)return f.decompress(a);for(var c=new Array(a.length/2),d=0,e=c.length;e>d;d++)c[d]=256*a[2*d]+a[2*d+1];var g=[];return c.forEach(function(a){g.push(b(a))}),f.decompress(g.join(""))},compressToEncodedURIComponent:function(a){return null==a?"":f._compress(a,6,function(a){return d.charAt(a)})},decompressFromEncodedURIComponent:function(b){return null==b?"":""==b?null:(b=b.replace(/ /g,"+"),f._decompress(b.length,32,function(c){return a(d,b.charAt(c))}))},compress:function(a){return f._compress(a,16,function(a){return b(a)})},_compress:function(a,b,c){if(null==a)return"";var d,e,f,g={},h={},i="",j="",k="",l=2,m=3,n=2,o=[],p=0,q=0;for(f=0;f<a.length;f+=1)if(i=a.charAt(f),Object.prototype.hasOwnProperty.call(g,i)||(g[i]=m++,h[i]=!0),j=k+i,Object.prototype.hasOwnProperty.call(g,j))k=j;else{if(Object.prototype.hasOwnProperty.call(h,k)){if(k.charCodeAt(0)<256){for(d=0;n>d;d++)p<<=1,q==b-1?(q=0,o.push(c(p)),p=0):q++;for(e=k.charCodeAt(0),d=0;8>d;d++)p=p<<1|1&e,q==b-1?(q=0,o.push(c(p)),p=0):q++,e>>=1}else{for(e=1,d=0;n>d;d++)p=p<<1|e,q==b-1?(q=0,o.push(c(p)),p=0):q++,e=0;for(e=k.charCodeAt(0),d=0;16>d;d++)p=p<<1|1&e,q==b-1?(q=0,o.push(c(p)),p=0):q++,e>>=1}l--,0==l&&(l=Math.pow(2,n),n++),delete h[k]}else for(e=g[k],d=0;n>d;d++)p=p<<1|1&e,q==b-1?(q=0,o.push(c(p)),p=0):q++,e>>=1;l--,0==l&&(l=Math.pow(2,n),n++),g[j]=m++,k=String(i);
}if(""!==k){if(Object.prototype.hasOwnProperty.call(h,k)){if(k.charCodeAt(0)<256){for(d=0;n>d;d++)p<<=1,q==b-1?(q=0,o.push(c(p)),p=0):q++;for(e=k.charCodeAt(0),d=0;8>d;d++)p=p<<1|1&e,q==b-1?(q=0,o.push(c(p)),p=0):q++,e>>=1}else{for(e=1,d=0;n>d;d++)p=p<<1|e,q==b-1?(q=0,o.push(c(p)),p=0):q++,e=0;for(e=k.charCodeAt(0),d=0;16>d;d++)p=p<<1|1&e,q==b-1?(q=0,o.push(c(p)),p=0):q++,e>>=1}l--,0==l&&(l=Math.pow(2,n),n++),delete h[k]}else for(e=g[k],d=0;n>d;d++)p=p<<1|1&e,q==b-1?(q=0,o.push(c(p)),p=0):q++,e>>=1;l--,0==l&&(l=Math.pow(2,n),n++)}for(e=2,d=0;n>d;d++)p=p<<1|1&e,q==b-1?(q=0,o.push(c(p)),p=0):q++,e>>=1;for(;;){if(p<<=1,q==b-1){o.push(c(p));break}q++}return o.join("")},decompress:function(a){return null==a?"":""==a?null:f._decompress(a.length,32768,function(b){return a.charCodeAt(b)})},_decompress:function(a,c,d){var e,f,g,h,i,j,k,l,m=[],n=4,o=4,p=3,q="",r=[],s={val:d(0),position:c,index:1};for(f=0;3>f;f+=1)m[f]=f;for(h=0,j=Math.pow(2,2),k=1;k!=j;)i=s.val&s.position,s.position>>=1,0==s.position&&(s.position=c,s.val=d(s.index++)),h|=(i>0?1:0)*k,k<<=1;switch(e=h){case 0:for(h=0,j=Math.pow(2,8),k=1;k!=j;)i=s.val&s.position,s.position>>=1,0==s.position&&(s.position=c,s.val=d(s.index++)),h|=(i>0?1:0)*k,k<<=1;l=b(h);break;case 1:for(h=0,j=Math.pow(2,16),k=1;k!=j;)i=s.val&s.position,s.position>>=1,0==s.position&&(s.position=c,s.val=d(s.index++)),h|=(i>0?1:0)*k,k<<=1;l=b(h);break;case 2:return""}for(m[3]=l,g=l,r.push(l);;){if(s.index>a)return"";for(h=0,j=Math.pow(2,p),k=1;k!=j;)i=s.val&s.position,s.position>>=1,0==s.position&&(s.position=c,s.val=d(s.index++)),h|=(i>0?1:0)*k,k<<=1;switch(l=h){case 0:for(h=0,j=Math.pow(2,8),k=1;k!=j;)i=s.val&s.position,s.position>>=1,0==s.position&&(s.position=c,s.val=d(s.index++)),h|=(i>0?1:0)*k,k<<=1;m[o++]=b(h),l=o-1,n--;break;case 1:for(h=0,j=Math.pow(2,16),k=1;k!=j;)i=s.val&s.position,s.position>>=1,0==s.position&&(s.position=c,s.val=d(s.index++)),h|=(i>0?1:0)*k,k<<=1;m[o++]=b(h),l=o-1,n--;break;case 2:return r.join("")}if(0==n&&(n=Math.pow(2,p),p++),m[l])q=m[l];else{if(l!==o)return null;q=g+g.charAt(0)}r.push(q),m[o++]=g+q.charAt(0),n--,g=q,0==n&&(n=Math.pow(2,p),p++)}}};return f}();"function"==typeof define&&define.amd?define(function(){return LZString}):"undefined"!=typeof module&&null!=module&&(module.exports=LZString),function(a){function b(a,b){return function(c){return i(a.call(this,c),b)}}function c(a,b){return function(c){return this.lang().ordinal(a.call(this,c),b)}}function d(){}function e(a){u(a),g(this,a)}function f(a){var b=o(a),c=b.year||0,d=b.month||0,e=b.week||0,f=b.day||0,g=b.hour||0,h=b.minute||0,i=b.second||0,j=b.millisecond||0;this._milliseconds=+j+1e3*i+6e4*h+36e5*g,this._days=+f+7*e,this._months=+d+12*c,this._data={},this._bubble()}function g(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);return b.hasOwnProperty("toString")&&(a.toString=b.toString),b.hasOwnProperty("valueOf")&&(a.valueOf=b.valueOf),a}function h(a){return 0>a?Math.ceil(a):Math.floor(a)}function i(a,b,c){for(var d=Math.abs(a)+"",e=a>=0;d.length<b;)d="0"+d;return(e?c?"+":"":"-")+d}function j(a,b,c,d){var e,f,g=b._milliseconds,h=b._days,i=b._months;g&&a._d.setTime(+a._d+g*c),(h||i)&&(e=a.minute(),f=a.hour()),h&&a.date(a.date()+h*c),i&&a.month(a.month()+i*c),g&&!d&&ca.updateOffset(a),(h||i)&&(a.minute(e),a.hour(f))}function k(a){return"[object Array]"===Object.prototype.toString.call(a)}function l(a){return"[object Date]"===Object.prototype.toString.call(a)||a instanceof Date}function m(a,b,c){var d,e=Math.min(a.length,b.length),f=Math.abs(a.length-b.length),g=0;for(d=0;e>d;d++)(c&&a[d]!==b[d]||!c&&q(a[d])!==q(b[d]))&&g++;return g+f}function n(a){if(a){var b=a.toLowerCase().replace(/(.)s$/,"$1");a=Qa[a]||Ra[b]||b}return a}function o(a){var b,c,d={};for(c in a)a.hasOwnProperty(c)&&(b=n(c),b&&(d[b]=a[c]));return d}function p(b){var c,d;if(0===b.indexOf("week"))c=7,d="day";else{if(0!==b.indexOf("month"))return;c=12,d="month"}ca[b]=function(e,f){var g,h,i=ca.fn._lang[b],j=[];if("number"==typeof e&&(f=e,e=a),h=function(a){var b=ca().utc().set(d,a);return i.call(ca.fn._lang,b,e||"")},null!=f)return h(f);for(g=0;c>g;g++)j.push(h(g));return j}}function q(a){var b=+a,c=0;return 0!==b&&isFinite(b)&&(c=b>=0?Math.floor(b):Math.ceil(b)),c}function r(a,b){return new Date(Date.UTC(a,b+1,0)).getUTCDate()}function s(a){return t(a)?366:365}function t(a){return a%4===0&&a%100!==0||a%400===0}function u(a){var b;a._a&&-2===a._pf.overflow&&(b=a._a[ia]<0||a._a[ia]>11?ia:a._a[ja]<1||a._a[ja]>r(a._a[ha],a._a[ia])?ja:a._a[ka]<0||a._a[ka]>23?ka:a._a[la]<0||a._a[la]>59?la:a._a[ma]<0||a._a[ma]>59?ma:a._a[na]<0||a._a[na]>999?na:-1,a._pf._overflowDayOfYear&&(ha>b||b>ja)&&(b=ja),a._pf.overflow=b)}function v(a){a._pf={empty:!1,unusedTokens:[],unusedInput:[],overflow:-2,charsLeftOver:0,nullInput:!1,invalidMonth:null,invalidFormat:!1,userInvalidated:!1,iso:!1}}function w(a){return null==a._isValid&&(a._isValid=!isNaN(a._d.getTime())&&a._pf.overflow<0&&!a._pf.empty&&!a._pf.invalidMonth&&!a._pf.nullInput&&!a._pf.invalidFormat&&!a._pf.userInvalidated,a._strict&&(a._isValid=a._isValid&&0===a._pf.charsLeftOver&&0===a._pf.unusedTokens.length)),a._isValid}function x(a){return a?a.toLowerCase().replace("_","-"):a}function y(a,b){return b._isUTC?ca(a).zone(b._offset||0):ca(a).local()}function z(a,b){return b.abbr=a,oa[a]||(oa[a]=new d),oa[a].set(b),oa[a]}function A(a){delete oa[a]}function B(a){var b,c,d,e,f=0,g=function(a){if(!oa[a]&&pa)try{require("./lang/"+a)}catch(b){}return oa[a]};if(!a)return ca.fn._lang;if(!k(a)){if(c=g(a))return c;a=[a]}for(;f<a.length;){for(e=x(a[f]).split("-"),b=e.length,d=x(a[f+1]),d=d?d.split("-"):null;b>0;){if(c=g(e.slice(0,b).join("-")))return c;if(d&&d.length>=b&&m(e,d,!0)>=b-1)break;b--}f++}return ca.fn._lang}function C(a){return a.match(/\[[\s\S]/)?a.replace(/^\[|\]$/g,""):a.replace(/\\/g,"")}function D(a){var b,c,d=a.match(ta);for(b=0,c=d.length;c>b;b++)Va[d[b]]?d[b]=Va[d[b]]:d[b]=C(d[b]);return function(e){var f="";for(b=0;c>b;b++)f+=d[b]instanceof Function?d[b].call(e,a):d[b];return f}}function E(a,b){return a.isValid()?(b=F(b,a.lang()),Sa[b]||(Sa[b]=D(b)),Sa[b](a)):a.lang().invalidDate()}function F(a,b){function c(a){return b.longDateFormat(a)||a}var d=5;for(ua.lastIndex=0;d>=0&&ua.test(a);)a=a.replace(ua,c),ua.lastIndex=0,d-=1;return a}function G(a,b){var c,d=b._strict;switch(a){case"DDDD":return Ga;case"YYYY":case"GGGG":case"gggg":return d?Ha:xa;case"YYYYYY":case"YYYYY":case"GGGGG":case"ggggg":return d?Ia:ya;case"S":if(d)return Ea;case"SS":if(d)return Fa;case"SSS":case"DDD":return d?Ga:wa;case"MMM":case"MMMM":case"dd":case"ddd":case"dddd":return Aa;case"a":case"A":return B(b._l)._meridiemParse;case"X":return Da;case"Z":case"ZZ":return Ba;case"T":return Ca;case"SSSS":return za;case"MM":case"DD":case"YY":case"GG":case"gg":case"HH":case"hh":case"mm":case"ss":case"ww":case"WW":return d?Fa:va;case"M":case"D":case"d":case"H":case"h":case"m":case"s":case"w":case"W":case"e":case"E":return d?Ea:va;default:return c=new RegExp(O(N(a.replace("\\","")),"i"))}}function H(a){a=a||"";var b=a.match(Ba)||[],c=b[b.length-1]||[],d=(c+"").match(Na)||["-",0,0],e=+(60*d[1])+q(d[2]);return"+"===d[0]?-e:e}function I(a,b,c){var d,e=c._a;switch(a){case"M":case"MM":null!=b&&(e[ia]=q(b)-1);break;case"MMM":case"MMMM":d=B(c._l).monthsParse(b),null!=d?e[ia]=d:c._pf.invalidMonth=b;break;case"D":case"DD":null!=b&&(e[ja]=q(b));break;case"DDD":case"DDDD":null!=b&&(c._dayOfYear=q(b));break;case"YY":e[ha]=q(b)+(q(b)>68?1900:2e3);break;case"YYYY":case"YYYYY":case"YYYYYY":e[ha]=q(b);break;case"a":case"A":c._isPm=B(c._l).isPM(b);break;case"H":case"HH":case"h":case"hh":e[ka]=q(b);break;case"m":case"mm":e[la]=q(b);break;case"s":case"ss":e[ma]=q(b);break;case"S":case"SS":case"SSS":case"SSSS":e[na]=q(1e3*("0."+b));break;case"X":c._d=new Date(1e3*parseFloat(b));break;case"Z":case"ZZ":c._useUTC=!0,c._tzm=H(b);break;case"w":case"ww":case"W":case"WW":case"d":case"dd":case"ddd":case"dddd":case"e":case"E":a=a.substr(0,1);case"gg":case"gggg":case"GG":case"GGGG":case"GGGGG":a=a.substr(0,2),b&&(c._w=c._w||{},c._w[a]=b)}}function J(a){var b,c,d,e,f,g,h,i,j,k,l=[];if(!a._d){for(d=L(a),a._w&&null==a._a[ja]&&null==a._a[ia]&&(f=function(b){var c=parseInt(b,10);return b?b.length<3?c>68?1900+c:2e3+c:c:null==a._a[ha]?ca().weekYear():a._a[ha]},g=a._w,null!=g.GG||null!=g.W||null!=g.E?h=Y(f(g.GG),g.W||1,g.E,4,1):(i=B(a._l),j=null!=g.d?U(g.d,i):null!=g.e?parseInt(g.e,10)+i._week.dow:0,k=parseInt(g.w,10)||1,null!=g.d&&j<i._week.dow&&k++,h=Y(f(g.gg),k,j,i._week.doy,i._week.dow)),a._a[ha]=h.year,a._dayOfYear=h.dayOfYear),a._dayOfYear&&(e=null==a._a[ha]?d[ha]:a._a[ha],a._dayOfYear>s(e)&&(a._pf._overflowDayOfYear=!0),c=T(e,0,a._dayOfYear),a._a[ia]=c.getUTCMonth(),a._a[ja]=c.getUTCDate()),b=0;3>b&&null==a._a[b];++b)a._a[b]=l[b]=d[b];for(;7>b;b++)a._a[b]=l[b]=null==a._a[b]?2===b?1:0:a._a[b];l[ka]+=q((a._tzm||0)/60),l[la]+=q((a._tzm||0)%60),a._d=(a._useUTC?T:S).apply(null,l)}}function K(a){var b;a._d||(b=o(a._i),a._a=[b.year,b.month,b.day,b.hour,b.minute,b.second,b.millisecond],J(a))}function L(a){var b=new Date;return a._useUTC?[b.getUTCFullYear(),b.getUTCMonth(),b.getUTCDate()]:[b.getFullYear(),b.getMonth(),b.getDate()]}function M(a){a._a=[],a._pf.empty=!0;var b,c,d,e,f,g=B(a._l),h=""+a._i,i=h.length,j=0;for(d=F(a._f,g).match(ta)||[],b=0;b<d.length;b++)e=d[b],c=(h.match(G(e,a))||[])[0],c&&(f=h.substr(0,h.indexOf(c)),f.length>0&&a._pf.unusedInput.push(f),h=h.slice(h.indexOf(c)+c.length),j+=c.length),Va[e]?(c?a._pf.empty=!1:a._pf.unusedTokens.push(e),I(e,c,a)):a._strict&&!c&&a._pf.unusedTokens.push(e);a._pf.charsLeftOver=i-j,h.length>0&&a._pf.unusedInput.push(h),a._isPm&&a._a[ka]<12&&(a._a[ka]+=12),a._isPm===!1&&12===a._a[ka]&&(a._a[ka]=0),J(a),u(a)}function N(a){return a.replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,function(a,b,c,d,e){return b||c||d||e})}function O(a){return a.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}function P(a){var b,c,d,e,f;if(0===a._f.length)return a._pf.invalidFormat=!0,void(a._d=new Date(NaN));for(e=0;e<a._f.length;e++)f=0,b=g({},a),v(b),b._f=a._f[e],M(b),w(b)&&(f+=b._pf.charsLeftOver,f+=10*b._pf.unusedTokens.length,b._pf.score=f,(null==d||d>f)&&(d=f,c=b));g(a,c||b)}function Q(a){var b,c=a._i,d=Ja.exec(c);if(d){for(a._pf.iso=!0,b=4;b>0;b--)if(d[b]){a._f=La[b-1]+(d[6]||" ");break}for(b=0;4>b;b++)if(Ma[b][1].exec(c)){a._f+=Ma[b][0];break}c.match(Ba)&&(a._f+="Z"),M(a)}else a._d=new Date(c)}function R(b){var c=b._i,d=qa.exec(c);c===a?b._d=new Date:d?b._d=new Date(+d[1]):"string"==typeof c?Q(b):k(c)?(b._a=c.slice(0),J(b)):l(c)?b._d=new Date(+c):"object"==typeof c?K(b):b._d=new Date(c)}function S(a,b,c,d,e,f,g){var h=new Date(a,b,c,d,e,f,g);return 1970>a&&h.setFullYear(a),h}function T(a){var b=new Date(Date.UTC.apply(null,arguments));return 1970>a&&b.setUTCFullYear(a),b}function U(a,b){if("string"==typeof a)if(isNaN(a)){if(a=b.weekdaysParse(a),"number"!=typeof a)return null}else a=parseInt(a,10);return a}function V(a,b,c,d,e){return e.relativeTime(b||1,!!c,a,d)}function W(a,b,c){var d=ga(Math.abs(a)/1e3),e=ga(d/60),f=ga(e/60),g=ga(f/24),h=ga(g/365),i=45>d&&["s",d]||1===e&&["m"]||45>e&&["mm",e]||1===f&&["h"]||22>f&&["hh",f]||1===g&&["d"]||25>=g&&["dd",g]||45>=g&&["M"]||345>g&&["MM",ga(g/30)]||1===h&&["y"]||["yy",h];return i[2]=b,i[3]=a>0,i[4]=c,V.apply({},i)}function X(a,b,c){var d,e=c-b,f=c-a.day();return f>e&&(f-=7),e-7>f&&(f+=7),d=ca(a).add("d",f),{week:Math.ceil(d.dayOfYear()/7),year:d.year()}}function Y(a,b,c,d,e){var f,g,h=new Date(i(a,6,!0)+"-01-01").getUTCDay();return c=null!=c?c:e,f=e-h+(h>d?7:0),g=7*(b-1)+(c-e)+f+1,{year:g>0?a:a-1,dayOfYear:g>0?g:s(a-1)+g}}function Z(a){var b=a._i,c=a._f;return"undefined"==typeof a._pf&&v(a),null===b?ca.invalid({nullInput:!0}):("string"==typeof b&&(a._i=b=B().preparse(b)),ca.isMoment(b)?(a=g({},b),a._d=new Date(+b._d)):c?k(c)?P(a):M(a):R(a),new e(a))}function $(a,b){ca.fn[a]=ca.fn[a+"s"]=function(a){var c=this._isUTC?"UTC":"";return null!=a?(this._d["set"+c+b](a),ca.updateOffset(this),this):this._d["get"+c+b]()}}function _(a){ca.duration.fn[a]=function(){return this._data[a]}}function aa(a,b){ca.duration.fn["as"+a]=function(){return+this/b}}function ba(a){var b=!1,c=ca;"undefined"==typeof ender&&(a?(fa.moment=function(){return!b&&console&&console.warn&&(b=!0,console.warn("Accessing Moment through the global scope is deprecated, and will be removed in an upcoming release.")),c.apply(null,arguments)},g(fa.moment,c)):fa.moment=ca)}for(var ca,da,ea="2.5.0",fa=this,ga=Math.round,ha=0,ia=1,ja=2,ka=3,la=4,ma=5,na=6,oa={},pa="undefined"!=typeof module&&module.exports&&"undefined"!=typeof require,qa=/^\/?Date\((\-?\d+)/i,ra=/(\-)?(?:(\d*)\.)?(\d+)\:(\d+)(?:\:(\d+)\.?(\d{3})?)?/,sa=/^(-)?P(?:(?:([0-9,.]*)Y)?(?:([0-9,.]*)M)?(?:([0-9,.]*)D)?(?:T(?:([0-9,.]*)H)?(?:([0-9,.]*)M)?(?:([0-9,.]*)S)?)?|([0-9,.]*)W)$/,ta=/(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|S{1,4}|X|zz?|ZZ?|.)/g,ua=/(\[[^\[]*\])|(\\)?(LT|LL?L?L?|l{1,4})/g,va=/\d\d?/,wa=/\d{1,3}/,xa=/\d{1,4}/,ya=/[+\-]?\d{1,6}/,za=/\d+/,Aa=/[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i,Ba=/Z|[\+\-]\d\d:?\d\d/gi,Ca=/T/i,Da=/[\+\-]?\d+(\.\d{1,3})?/,Ea=/\d/,Fa=/\d\d/,Ga=/\d{3}/,Ha=/\d{4}/,Ia=/[+\-]?\d{6}/,Ja=/^\s*\d{4}-(?:(\d\d-\d\d)|(W\d\d$)|(W\d\d-\d)|(\d\d\d))((T| )(\d\d(:\d\d(:\d\d(\.\d+)?)?)?)?([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/,Ka="YYYY-MM-DDTHH:mm:ssZ",La=["YYYY-MM-DD","GGGG-[W]WW","GGGG-[W]WW-E","YYYY-DDD"],Ma=[["HH:mm:ss.SSSS",/(T| )\d\d:\d\d:\d\d\.\d{1,3}/],["HH:mm:ss",/(T| )\d\d:\d\d:\d\d/],["HH:mm",/(T| )\d\d:\d\d/],["HH",/(T| )\d\d/]],Na=/([\+\-]|\d\d)/gi,Oa="Date|Hours|Minutes|Seconds|Milliseconds".split("|"),Pa={Milliseconds:1,Seconds:1e3,Minutes:6e4,Hours:36e5,Days:864e5,Months:2592e6,Years:31536e6},Qa={ms:"millisecond",s:"second",m:"minute",h:"hour",d:"day",D:"date",w:"week",W:"isoWeek",M:"month",y:"year",DDD:"dayOfYear",e:"weekday",E:"isoWeekday",gg:"weekYear",GG:"isoWeekYear"},Ra={dayofyear:"dayOfYear",isoweekday:"isoWeekday",isoweek:"isoWeek",weekyear:"weekYear",isoweekyear:"isoWeekYear"},Sa={},Ta="DDD w W M D d".split(" "),Ua="M D H h m s w W".split(" "),Va={M:function(){return this.month()+1},MMM:function(a){return this.lang().monthsShort(this,a)},MMMM:function(a){return this.lang().months(this,a)},D:function(){return this.date()},DDD:function(){return this.dayOfYear()},d:function(){return this.day()},dd:function(a){return this.lang().weekdaysMin(this,a)},ddd:function(a){return this.lang().weekdaysShort(this,a)},dddd:function(a){return this.lang().weekdays(this,a)},w:function(){return this.week()},W:function(){return this.isoWeek()},YY:function(){return i(this.year()%100,2)},YYYY:function(){return i(this.year(),4)},YYYYY:function(){return i(this.year(),5)},YYYYYY:function(){var a=this.year(),b=a>=0?"+":"-";return b+i(Math.abs(a),6)},gg:function(){return i(this.weekYear()%100,2)},gggg:function(){return this.weekYear()},ggggg:function(){return i(this.weekYear(),5)},GG:function(){return i(this.isoWeekYear()%100,2)},GGGG:function(){return this.isoWeekYear()},GGGGG:function(){return i(this.isoWeekYear(),5)},e:function(){return this.weekday()},E:function(){return this.isoWeekday()},a:function(){return this.lang().meridiem(this.hours(),this.minutes(),!0)},A:function(){return this.lang().meridiem(this.hours(),this.minutes(),!1)},H:function(){return this.hours()},h:function(){return this.hours()%12||12},m:function(){return this.minutes()},s:function(){return this.seconds()},S:function(){return q(this.milliseconds()/100)},SS:function(){return i(q(this.milliseconds()/10),2)},SSS:function(){return i(this.milliseconds(),3)},SSSS:function(){return i(this.milliseconds(),3)},Z:function(){var a=-this.zone(),b="+";return 0>a&&(a=-a,b="-"),b+i(q(a/60),2)+":"+i(q(a)%60,2)},ZZ:function(){var a=-this.zone(),b="+";return 0>a&&(a=-a,b="-"),b+i(q(a/60),2)+i(q(a)%60,2)},z:function(){return this.zoneAbbr()},zz:function(){return this.zoneName()},X:function(){return this.unix()},Q:function(){return this.quarter()}},Wa=["months","monthsShort","weekdays","weekdaysShort","weekdaysMin"];Ta.length;)da=Ta.pop(),Va[da+"o"]=c(Va[da],da);for(;Ua.length;)da=Ua.pop(),Va[da+da]=b(Va[da],2);for(Va.DDDD=b(Va.DDD,3),g(d.prototype,{set:function(a){var b,c;for(c in a)b=a[c],"function"==typeof b?this[c]=b:this["_"+c]=b},_months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),months:function(a){return this._months[a.month()]},_monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),monthsShort:function(a){return this._monthsShort[a.month()]},monthsParse:function(a){var b,c,d;for(this._monthsParse||(this._monthsParse=[]),b=0;12>b;b++)if(this._monthsParse[b]||(c=ca.utc([2e3,b]),d="^"+this.months(c,"")+"|^"+this.monthsShort(c,""),this._monthsParse[b]=new RegExp(d.replace(".",""),"i")),this._monthsParse[b].test(a))return b},_weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),weekdays:function(a){return this._weekdays[a.day()]},_weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),weekdaysShort:function(a){return this._weekdaysShort[a.day()]},_weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),weekdaysMin:function(a){return this._weekdaysMin[a.day()]},weekdaysParse:function(a){var b,c,d;for(this._weekdaysParse||(this._weekdaysParse=[]),b=0;7>b;b++)if(this._weekdaysParse[b]||(c=ca([2e3,1]).day(b),d="^"+this.weekdays(c,"")+"|^"+this.weekdaysShort(c,"")+"|^"+this.weekdaysMin(c,""),this._weekdaysParse[b]=new RegExp(d.replace(".",""),"i")),this._weekdaysParse[b].test(a))return b},_longDateFormat:{LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D YYYY",LLL:"MMMM D YYYY LT",LLLL:"dddd, MMMM D YYYY LT"},longDateFormat:function(a){var b=this._longDateFormat[a];return!b&&this._longDateFormat[a.toUpperCase()]&&(b=this._longDateFormat[a.toUpperCase()].replace(/MMMM|MM|DD|dddd/g,function(a){return a.slice(1)}),this._longDateFormat[a]=b),b},isPM:function(a){return"p"===(a+"").toLowerCase().charAt(0)},_meridiemParse:/[ap]\.?m?\.?/i,meridiem:function(a,b,c){return a>11?c?"pm":"PM":c?"am":"AM"},_calendar:{sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"},calendar:function(a,b){var c=this._calendar[a];return"function"==typeof c?c.apply(b):c},_relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},relativeTime:function(a,b,c,d){var e=this._relativeTime[c];return"function"==typeof e?e(a,b,c,d):e.replace(/%d/i,a)},pastFuture:function(a,b){var c=this._relativeTime[a>0?"future":"past"];return"function"==typeof c?c(b):c.replace(/%s/i,b)},ordinal:function(a){return this._ordinal.replace("%d",a)},_ordinal:"%d",preparse:function(a){return a},postformat:function(a){return a},week:function(a){return X(a,this._week.dow,this._week.doy).week},_week:{dow:0,doy:6},_invalidDate:"Invalid date",invalidDate:function(){return this._invalidDate}}),ca=function(b,c,d,e){return"boolean"==typeof d&&(e=d,d=a),Z({_i:b,_f:c,_l:d,_strict:e,_isUTC:!1})},ca.utc=function(b,c,d,e){var f;return"boolean"==typeof d&&(e=d,d=a),f=Z({_useUTC:!0,_isUTC:!0,_l:d,_i:b,_f:c,_strict:e}).utc()},ca.unix=function(a){return ca(1e3*a)},ca.duration=function(a,b){var c,d,e,g=a,h=null;return ca.isDuration(a)?g={ms:a._milliseconds,d:a._days,M:a._months}:"number"==typeof a?(g={},b?g[b]=a:g.milliseconds=a):(h=ra.exec(a))?(c="-"===h[1]?-1:1,g={y:0,d:q(h[ja])*c,h:q(h[ka])*c,m:q(h[la])*c,s:q(h[ma])*c,ms:q(h[na])*c}):(h=sa.exec(a))&&(c="-"===h[1]?-1:1,e=function(a){var b=a&&parseFloat(a.replace(",","."));return(isNaN(b)?0:b)*c},g={y:e(h[2]),M:e(h[3]),d:e(h[4]),h:e(h[5]),m:e(h[6]),s:e(h[7]),w:e(h[8])}),d=new f(g),ca.isDuration(a)&&a.hasOwnProperty("_lang")&&(d._lang=a._lang),d},ca.version=ea,ca.defaultFormat=Ka,ca.updateOffset=function(){},ca.lang=function(a,b){var c;return a?(b?z(x(a),b):null===b?(A(a),a="en"):oa[a]||B(a),c=ca.duration.fn._lang=ca.fn._lang=B(a),c._abbr):ca.fn._lang._abbr},ca.langData=function(a){return a&&a._lang&&a._lang._abbr&&(a=a._lang._abbr),B(a)},ca.isMoment=function(a){return a instanceof e},ca.isDuration=function(a){return a instanceof f},da=Wa.length-1;da>=0;--da)p(Wa[da]);for(ca.normalizeUnits=function(a){return n(a)},ca.invalid=function(a){var b=ca.utc(NaN);return null!=a?g(b._pf,a):b._pf.userInvalidated=!0,b},ca.parseZone=function(a){return ca(a).parseZone()},g(ca.fn=e.prototype,{clone:function(){return ca(this)},valueOf:function(){return+this._d+6e4*(this._offset||0)},unix:function(){return Math.floor(+this/1e3)},toString:function(){return this.clone().lang("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")},toDate:function(){return this._offset?new Date(+this):this._d},toISOString:function(){var a=ca(this).utc();return 0<a.year()&&a.year()<=9999?E(a,"YYYY-MM-DD[T]HH:mm:ss.SSS[Z]"):E(a,"YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]")},toArray:function(){var a=this;return[a.year(),a.month(),a.date(),a.hours(),a.minutes(),a.seconds(),a.milliseconds()]},isValid:function(){return w(this)},isDSTShifted:function(){return this._a?this.isValid()&&m(this._a,(this._isUTC?ca.utc(this._a):ca(this._a)).toArray())>0:!1},parsingFlags:function(){return g({},this._pf)},invalidAt:function(){return this._pf.overflow},utc:function(){return this.zone(0)},local:function(){return this.zone(0),this._isUTC=!1,this},format:function(a){var b=E(this,a||ca.defaultFormat);return this.lang().postformat(b)},add:function(a,b){var c;return c="string"==typeof a?ca.duration(+b,a):ca.duration(a,b),j(this,c,1),this},subtract:function(a,b){var c;return c="string"==typeof a?ca.duration(+b,a):ca.duration(a,b),j(this,c,-1),this},diff:function(a,b,c){var d,e,f=y(a,this),g=6e4*(this.zone()-f.zone());return b=n(b),"year"===b||"month"===b?(d=432e5*(this.daysInMonth()+f.daysInMonth()),e=12*(this.year()-f.year())+(this.month()-f.month()),e+=(this-ca(this).startOf("month")-(f-ca(f).startOf("month")))/d,e-=6e4*(this.zone()-ca(this).startOf("month").zone()-(f.zone()-ca(f).startOf("month").zone()))/d,"year"===b&&(e/=12)):(d=this-f,e="second"===b?d/1e3:"minute"===b?d/6e4:"hour"===b?d/36e5:"day"===b?(d-g)/864e5:"week"===b?(d-g)/6048e5:d),c?e:h(e)},from:function(a,b){return ca.duration(this.diff(a)).lang(this.lang()._abbr).humanize(!b)},fromNow:function(a){return this.from(ca(),a)},calendar:function(){var a=y(ca(),this).startOf("day"),b=this.diff(a,"days",!0),c=-6>b?"sameElse":-1>b?"lastWeek":0>b?"lastDay":1>b?"sameDay":2>b?"nextDay":7>b?"nextWeek":"sameElse";return this.format(this.lang().calendar(c,this))},isLeapYear:function(){return t(this.year())},isDST:function(){return this.zone()<this.clone().month(0).zone()||this.zone()<this.clone().month(5).zone()},day:function(a){var b=this._isUTC?this._d.getUTCDay():this._d.getDay();return null!=a?(a=U(a,this.lang()),this.add({d:a-b})):b},month:function(a){var b,c=this._isUTC?"UTC":"";return null!=a?"string"==typeof a&&(a=this.lang().monthsParse(a),"number"!=typeof a)?this:(b=this.date(),this.date(1),this._d["set"+c+"Month"](a),this.date(Math.min(b,this.daysInMonth())),ca.updateOffset(this),this):this._d["get"+c+"Month"]()},startOf:function(a){switch(a=n(a)){case"year":this.month(0);case"month":this.date(1);case"week":case"isoWeek":case"day":this.hours(0);case"hour":this.minutes(0);case"minute":this.seconds(0);case"second":this.milliseconds(0)}return"week"===a?this.weekday(0):"isoWeek"===a&&this.isoWeekday(1),this},endOf:function(a){return a=n(a),this.startOf(a).add("isoWeek"===a?"week":a,1).subtract("ms",1)},isAfter:function(a,b){return b="undefined"!=typeof b?b:"millisecond",+this.clone().startOf(b)>+ca(a).startOf(b)},isBefore:function(a,b){return b="undefined"!=typeof b?b:"millisecond",+this.clone().startOf(b)<+ca(a).startOf(b)},isSame:function(a,b){return b=b||"ms",+this.clone().startOf(b)===+y(a,this).startOf(b)},min:function(a){return a=ca.apply(null,arguments),this>a?this:a},max:function(a){return a=ca.apply(null,arguments),a>this?this:a},zone:function(a){var b=this._offset||0;return null==a?this._isUTC?b:this._d.getTimezoneOffset():("string"==typeof a&&(a=H(a)),Math.abs(a)<16&&(a=60*a),this._offset=a,this._isUTC=!0,b!==a&&j(this,ca.duration(b-a,"m"),1,!0),this)},zoneAbbr:function(){return this._isUTC?"UTC":""},zoneName:function(){return this._isUTC?"Coordinated Universal Time":""},parseZone:function(){return this._tzm?this.zone(this._tzm):"string"==typeof this._i&&this.zone(this._i),this},hasAlignedHourOffset:function(a){return a=a?ca(a).zone():0,(this.zone()-a)%60===0},daysInMonth:function(){return r(this.year(),this.month())},dayOfYear:function(a){var b=ga((ca(this).startOf("day")-ca(this).startOf("year"))/864e5)+1;return null==a?b:this.add("d",a-b)},quarter:function(){return Math.ceil((this.month()+1)/3)},weekYear:function(a){var b=X(this,this.lang()._week.dow,this.lang()._week.doy).year;return null==a?b:this.add("y",a-b)},isoWeekYear:function(a){var b=X(this,1,4).year;return null==a?b:this.add("y",a-b)},week:function(a){var b=this.lang().week(this);return null==a?b:this.add("d",7*(a-b))},isoWeek:function(a){var b=X(this,1,4).week;return null==a?b:this.add("d",7*(a-b))},weekday:function(a){var b=(this.day()+7-this.lang()._week.dow)%7;return null==a?b:this.add("d",a-b)},isoWeekday:function(a){return null==a?this.day()||7:this.day(this.day()%7?a:a-7)},get:function(a){return a=n(a),this[a]()},set:function(a,b){return a=n(a),"function"==typeof this[a]&&this[a](b),this},lang:function(b){return b===a?this._lang:(this._lang=B(b),this)}}),da=0;da<Oa.length;da++)$(Oa[da].toLowerCase().replace(/s$/,""),Oa[da]);$("year","FullYear"),ca.fn.days=ca.fn.day,ca.fn.months=ca.fn.month,ca.fn.weeks=ca.fn.week,ca.fn.isoWeeks=ca.fn.isoWeek,ca.fn.toJSON=ca.fn.toISOString,g(ca.duration.fn=f.prototype,{_bubble:function(){var a,b,c,d,e=this._milliseconds,f=this._days,g=this._months,i=this._data;i.milliseconds=e%1e3,a=h(e/1e3),i.seconds=a%60,b=h(a/60),i.minutes=b%60,c=h(b/60),i.hours=c%24,f+=h(c/24),i.days=f%30,g+=h(f/30),i.months=g%12,d=h(g/12),i.years=d},weeks:function(){return h(this.days()/7)},valueOf:function(){return this._milliseconds+864e5*this._days+this._months%12*2592e6+31536e6*q(this._months/12)},humanize:function(a){var b=+this,c=W(b,!a,this.lang());return a&&(c=this.lang().pastFuture(b,c)),this.lang().postformat(c)},add:function(a,b){var c=ca.duration(a,b);return this._milliseconds+=c._milliseconds,this._days+=c._days,this._months+=c._months,this._bubble(),this},subtract:function(a,b){var c=ca.duration(a,b);return this._milliseconds-=c._milliseconds,this._days-=c._days,this._months-=c._months,this._bubble(),this},get:function(a){return a=n(a),this[a.toLowerCase()+"s"]()},as:function(a){return a=n(a),this["as"+a.charAt(0).toUpperCase()+a.slice(1)+"s"]()},lang:ca.fn.lang,toIsoString:function(){var a=Math.abs(this.years()),b=Math.abs(this.months()),c=Math.abs(this.days()),d=Math.abs(this.hours()),e=Math.abs(this.minutes()),f=Math.abs(this.seconds()+this.milliseconds()/1e3);return this.asSeconds()?(this.asSeconds()<0?"-":"")+"P"+(a?a+"Y":"")+(b?b+"M":"")+(c?c+"D":"")+(d||e||f?"T":"")+(d?d+"H":"")+(e?e+"M":"")+(f?f+"S":""):"P0D"}});for(da in Pa)Pa.hasOwnProperty(da)&&(aa(da,Pa[da]),_(da.toLowerCase()));aa("Weeks",6048e5),ca.duration.fn.asMonths=function(){return(+this-31536e6*this.years())/2592e6+12*this.years()},ca.lang("en",{ordinal:function(a){var b=a%10,c=1===q(a%100/10)?"th":1===b?"st":2===b?"nd":3===b?"rd":"th";return a+c}}),pa?(module.exports=ca,ba(!0)):"function"==typeof define&&define.amd?define("moment",function(b,c,d){return d.config&&d.config()&&d.config().noGlobal!==!0&&ba(d.config().noGlobal===a),ca}):ba()}.call(this);var query_class_dict={};Query.prototype.exec=function(a,b){var c,d=[];if(!Array.isArray(a))throw new TypeError("Query().exec(): Argument 1 is not of type 'array'");if(void 0===b&&(b={}),"object"!=typeof b)throw new TypeError("Query().exec(): Optional argument 2 is not of type 'object'");for(c=0;c<a.length;c+=1)a[c]?d.push(this.match(a[c])):d.push(RSVP.resolve(!1));return(new RSVP.Queue).push(function(){return RSVP.all(d)}).push(function(c){var d;for(d=c.length-1;d>=0;d-=1)c[d]||a.splice(d,1);return b.sort_on?sortOn(b.sort_on,a):void 0}).push(function(){return b.limit?limit(b.limit,a):void 0}).push(function(){return select(b.select_list||[],a)}).push(function(){return a})},Query.prototype.match=function(){return RSVP.resolve(!0)},Query.prototype.parse=function(a){function b(a,c){function e(d){h.push(function(){return a.parsed=g.query_list[d],b(a,c)}).push(function(){g.query_list[d]=a.parsed})}var f,g=a.parsed,h=new RSVP.Queue;if("complex"===g.type){for(f=0;f<g.query_list.length;f+=1)e(f);return h.push(function(){return a.parsed=g,d.onParseComplexQuery(a,c)})}return"simple"===g.type?d.onParseSimpleQuery(a,c):void 0}var c,d=this;return c={parsed:JSON.parse(JSON.stringify(d.serialized()))},(new RSVP.Queue).push(function(){return d.onParseStart(c,a)}).push(function(){return b(c,a)}).push(function(){return d.onParseEnd(c,a)}).push(function(){return c.parsed})},Query.prototype.toString=function(){return""},Query.prototype.serialized=function(){return void 0},window.Query=Query,Query.parseStringToObject=parseStringToObject,inherits(ComplexQuery,Query),ComplexQuery.prototype.operator="AND",ComplexQuery.prototype.type="complex",ComplexQuery.prototype.match=function(a){var b=this.operator;return/^(?:AND|OR|NOT)$/i.test(b)||(b="AND"),this[b.toUpperCase()](a)},ComplexQuery.prototype.toString=function(){var a=[],b=this.operator;return"NOT"===this.operator?(a.push("NOT ("),a.push(this.query_list[0].toString()),a.push(")"),a.join(" ")):(this.query_list.forEach(function(c){a.push("("),a.push(c.toString()),a.push(")"),a.push(b)}),a.length-=1,a.join(" "))},ComplexQuery.prototype.serialized=function(){var a={type:"complex",operator:this.operator,query_list:[]};return this.query_list.forEach(function(b){a.query_list.push("function"==typeof b.toJSON?b.toJSON():b)}),a},ComplexQuery.prototype.toJSON=ComplexQuery.prototype.serialized,ComplexQuery.prototype.AND=function(a){function b(f){return f===!1?f:d.query_list.length===e?!0:void c.push(function(){var b=d.query_list[e].match(a);return e+=1,b}).push(b)}var c=new RSVP.Queue,d=this,e=0;return b(!0),c},ComplexQuery.prototype.OR=function(a){function b(f){return f===!0?f:d.query_list.length===e?!1:void c.push(function(){var b=d.query_list[e].match(a);return e+=1,b}).push(b)}var c=new RSVP.Queue,d=this,e=0;return b(!1),c},ComplexQuery.prototype.NOT=function(a){return(new RSVP.Queue).push(function(){return this.query_list[0].match(a)}).push(function(a){return!a})},query_class_dict.complex=ComplexQuery,window.ComplexQuery=ComplexQuery,QueryFactory.create=function(a,b){if(""===a)return new Query;if("string"==typeof a&&(a=parseStringToObject(a)),"string"==typeof(a||{}).type&&query_class_dict[a.type])return new query_class_dict[a.type](a,b);throw new TypeError("QueryFactory.create(): Argument 1 is not a search text or a parsable object")},window.QueryFactory=QueryFactory,Query.objectToSearchText=objectToSearchText;var checkKeySchema=function(a){var b;if(void 0!==a){if("object"!=typeof a)throw new TypeError("SimpleQuery().create(): key_schema is not of type 'object'");if(void 0===a.key_set)throw new TypeError("SimpleQuery().create(): key_schema has no 'key_set' property");for(b in a)if(a.hasOwnProperty(b))switch(b){case"key_set":case"cast_lookup":case"match_lookup":break;default:throw new TypeError("SimpleQuery().create(): key_schema has unknown property '"+b+"'")}}};inherits(SimpleQuery,Query),SimpleQuery.prototype.type="simple";var checkKey=function(a){var b;if(void 0===a.read_from)throw new TypeError("Custom key is missing the read_from property");for(b in a)if(a.hasOwnProperty(b))switch(b){case"read_from":case"cast_to":case"equal_match":break;default:throw new TypeError("Custom key has unknown property '"+b+"'")}};SimpleQuery.prototype.match=function(a){var b=null,c=null,d=null,e=null,f=this.operator,g=null,h=this.key;if(/^(?:!?=|<=?|>=?)$/i.test(f)||(f=/%/.test(this.value)?"like":"="),
e=this[f],this._key_schema.key_set&&void 0!==this._key_schema.key_set[h]&&(h=this._key_schema.key_set[h]),"object"==typeof h){if(checkKey(h),b=a[h.read_from],c=h.equal_match,"string"==typeof c&&(c=this._key_schema.match_lookup[c]),void 0!==c&&(e="="===f||"like"===f?c:e),g=this.value,d=h.cast_to){"string"==typeof d&&(d=this._key_schema.cast_lookup[d]);try{g=d(g)}catch(i){g=void 0}try{b=d(b)}catch(i){b=void 0}}}else b=a[h],g=this.value;return void 0===b||void 0===g?RSVP.resolve(!1):e(b,g)},SimpleQuery.prototype.toString=function(){return(this.key?this.key+":":"")+(this.operator?" "+this.operator:"")+' "'+this.value+'"'},SimpleQuery.prototype.serialized=function(){var a={type:"simple",key:this.key,value:this.value};return void 0!==this.operator&&(a.operator=this.operator),a},SimpleQuery.prototype.toJSON=SimpleQuery.prototype.serialized,SimpleQuery.prototype["="]=function(a,b){var c,d;for(Array.isArray(a)||(a=[a]),d=0;d<a.length;d+=1){if(c=a[d],"object"==typeof c&&c.hasOwnProperty("content")&&(c=c.content),"function"==typeof c.cmp)return RSVP.resolve(0===c.cmp(b));if(searchTextToRegExp(b.toString(),!1).test(c.toString()))return RSVP.resolve(!0)}return RSVP.resolve(!1)},SimpleQuery.prototype.like=function(a,b){var c,d;for(Array.isArray(a)||(a=[a]),d=0;d<a.length;d+=1){if(c=a[d],"object"==typeof c&&c.hasOwnProperty("content")&&(c=c.content),"function"==typeof c.cmp)return RSVP.resolve(0===c.cmp(b));if(searchTextToRegExp(b.toString()).test(c.toString()))return RSVP.resolve(!0)}return RSVP.resolve(!1)},SimpleQuery.prototype["!="]=function(a,b){var c,d;for(Array.isArray(a)||(a=[a]),d=0;d<a.length;d+=1){if(c=a[d],"object"==typeof c&&c.hasOwnProperty("content")&&(c=c.content),"function"==typeof c.cmp)return RSVP.resolve(0!==c.cmp(b));if(searchTextToRegExp(b.toString(),!1).test(c.toString()))return RSVP.resolve(!1)}return RSVP.resolve(!0)},SimpleQuery.prototype["<"]=function(a,b){var c;return Array.isArray(a)||(a=[a]),c=a[0],"object"==typeof c&&c.hasOwnProperty("content")&&(c=c.content),"function"==typeof c.cmp?RSVP.resolve(c.cmp(b)<0):RSVP.resolve(b>c)},SimpleQuery.prototype["<="]=function(a,b){var c;return Array.isArray(a)||(a=[a]),c=a[0],"object"==typeof c&&c.hasOwnProperty("content")&&(c=c.content),"function"==typeof c.cmp?RSVP.resolve(c.cmp(b)<=0):RSVP.resolve(b>=c)},SimpleQuery.prototype[">"]=function(a,b){var c;return Array.isArray(a)||(a=[a]),c=a[0],"object"==typeof c&&c.hasOwnProperty("content")&&(c=c.content),"function"==typeof c.cmp?RSVP.resolve(c.cmp(b)>0):RSVP.resolve(c>b)},SimpleQuery.prototype[">="]=function(a,b){var c;return Array.isArray(a)||(a=[a]),c=a[0],"object"==typeof c&&c.hasOwnProperty("content")&&(c=c.content),"function"==typeof c.cmp?RSVP.resolve(c.cmp(b)>=0):RSVP.resolve(c>=b)},query_class_dict.simple=SimpleQuery,window.SimpleQuery=SimpleQuery,Query.stringEscapeRegexpCharacters=stringEscapeRegexpCharacters,Query.select=select,Query.sortOn=sortOn,Query.limit=limit,Query.searchTextToRegExp=searchTextToRegExp,function(a,b){"use strict";var c,d="year",e="month",f="day",g="hour",h="minute",i="second",j="millisecond",k={year:0,month:1,day:2,hour:3,minute:4,second:5,millisecond:6},l=function(a,b){return k[a]<k[b]?a:b};c=function(a){if(!(this instanceof c))return new c(a);if(a instanceof c)return this.mom=a.mom.clone(),void(this._precision=a._precision);if(void 0===a)return this.mom=b(),void this.setPrecision(j);if(this.mom=null,this._str=a,a.match(/\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+\-][0-2]\d:[0-5]\d|Z)/)||a.match(/\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d\.\d\d\d/)?(this.mom=b(a),this.setPrecision(j)):a.match(/\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+\-][0-2]\d:[0-5]\d|Z)/)||a.match(/\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d/)?(this.mom=b(a),this.setPrecision(i)):a.match(/\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+\-][0-2]\d:[0-5]\d|Z)/)||a.match(/\d\d\d\d-\d\d-\d\d \d\d:\d\d/)?(this.mom=b(a),this.setPrecision(h)):a.match(/\d\d\d\d-\d\d-\d\d \d\d/)?(this.mom=b(a),this.setPrecision(g)):a.match(/\d\d\d\d-\d\d-\d\d/)?(this.mom=b(a),this.setPrecision(f)):a.match(/\d\d\d\d-\d\d/)?(this.mom=b(a),this.setPrecision(e)):a.match(/\d\d\d\d/)&&(this.mom=b(a),this.setPrecision(d)),!this.mom)throw new Error("Cannot parse: "+a)},c.prototype.setPrecision=function(a){this._precision=a},c.prototype.getPrecision=function(){return this._precision},c.prototype.cmp=function(a){var b=this.mom,c=a.mom,d=l(this._precision,a._precision);return b.isBefore(c,d)?-1:b.isSame(c,d)?0:1},c.prototype.toPrecisionString=function(a){var b;if(a=a||this._precision,b={millisecond:"YYYY-MM-DD HH:mm:ss.SSS",second:"YYYY-MM-DD HH:mm:ss",minute:"YYYY-MM-DD HH:mm",hour:"YYYY-MM-DD HH",day:"YYYY-MM-DD",month:"YYYY-MM",year:"YYYY"}[a],!b)throw new TypeError("Unsupported precision value '"+a+"'");return this.mom.format(b)},c.prototype.toString=function(){return this._str},a.jiodate={JIODate:c,YEAR:d,MONTH:e,DAY:f,HOUR:g,MIN:h,SEC:i,MSEC:j}}(window,moment),function(a,b,c,d,e,f,g,h,i){"use strict";function j(a,b){if(void 0!==a&&"string"!=typeof a)throw new TypeError("You must pass a string.");this.message=a||"Default Message",this.status_code=b||500}function k(a){var c=new XMLHttpRequest;return new b.Promise(function(b,d,e){var f;if(c.open(a.type||"GET",a.url,!0),c.responseType=a.dataType||"","object"==typeof a.headers&&null!==a.headers)for(f in a.headers)a.headers.hasOwnProperty(f)&&c.setRequestHeader(f,a.headers[f]);if(c.addEventListener("load",function(a){return a.target.status>=400?d(a):void b(a)}),c.addEventListener("error",d),c.addEventListener("progress",e),"object"==typeof a.xhrFields&&null!==a.xhrFields)for(f in a.xhrFields)a.xhrFields.hasOwnProperty(f)&&(c[f]=a.xhrFields[f]);"function"==typeof a.beforeSend&&a.beforeSend(c),c.send(a.data)},function(){c.abort()})}function l(a){var b,c;if(Array.isArray(a)){for(c=[],b=0;b<a.length;b+=1)c[b]=l(a[b]);return c}if(null===a)return null;if("object"==typeof a){if(Object.getPrototypeOf(a)===Object.prototype){c={};for(b in a)a.hasOwnProperty(b)&&(c[b]=l(a[b]));return c}return a instanceof Date?isFinite(a.getTime())?new Date(a.toJSON()):new Date("Invalid Date"):"function"==typeof a.toJSON?new(Object.getPrototypeOf(a).constructor)(a.toJSON()):a}return a}function m(a,c){var d=new g;return new b.Promise(function(b,e,f){d.addEventListener("load",b),d.addEventListener("error",e),d.addEventListener("progress",f),d.readAsText(a,c)},function(){d.abort()})}function n(a){var c=new g;return new b.Promise(function(b,d,e){c.addEventListener("load",b),c.addEventListener("error",d),c.addEventListener("progress",e),c.readAsArrayBuffer(a)},function(){c.abort()})}function o(a){var c=new g;return new b.Promise(function(b,d,e){c.addEventListener("load",b),c.addEventListener("error",d),c.addEventListener("progress",e),c.readAsDataURL(a)},function(){c.abort()})}function p(a){var b,d=f(a.split(",")[1]),e=a.split(",")[0].split(":")[1],g=new h(d.length),j=new i(g);for(e=e.slice(0,e.length-";base64".length),b=0;b<d.length;b+=1)j[b]=d.charCodeAt(b);return new c([g],{type:e})}function q(a,b,c){if("string"!=typeof a[0]||""===a[0])throw new v.util.jIOError("Document id must be a non empty string on '"+b.__type+"."+c+"'.",400)}function r(a,b,c){if("string"!=typeof a[1]||""===a[1])throw new v.util.jIOError("Attachment id must be a non empty string on '"+b.__type+"."+c+"'.",400)}function s(a,c,d,e){return a.prototype[c]=function(){var a,f=arguments,g=this;return(new b.Queue).push(function(){return void 0!==d?d.apply(g.__storage,[f,g,c]):void 0}).push(function(b){var d=g.__storage[c];if(a=b,void 0===d)throw new v.util.jIOError("Capacity '"+c+"' is not implemented on '"+g.__type+"'",501);return d.apply(g.__storage,f)}).push(function(b){return void 0!==e?e.call(g,f,b,a):b})},this}function t(a,b){return this instanceof t?(this.__type=a,void(this.__storage=b)):new t}function u(){return this instanceof u?void(this.__storage_types={}):new u}var v,w={};j.prototype=new Error,j.prototype.constructor=j,w.jIOError=j,w.ajax=k,w.deepClone=l,w.readBlobAsText=m,w.readBlobAsArrayBuffer=n,w.readBlobAsDataURL=o,w.dataURItoBlob=p,s(t,"put",q,function(a){return a[0]}),s(t,"get",q),s(t,"bulk"),s(t,"remove",q,function(a){return a[0]}),t.prototype.post=function(){var a=this,c=arguments;return(new b.Queue).push(function(){var b=a.__storage.post;if(void 0===b)throw new v.util.jIOError("Capacity 'post' is not implemented on '"+a.__type+"'",501);return a.__storage.post.apply(a.__storage,c)})},s(t,"putAttachment",function(a,b,d){q(a,b,d),r(a,b,d);var e=a[3]||{};if("string"==typeof a[2])a[2]=new c([a[2]],{type:e._content_type||e._mimetype||"text/plain;charset=utf-8"});else if(!(a[2]instanceof c))throw new v.util.jIOError("Attachment content is not a blob",400)}),s(t,"removeAttachment",function(a,b,c){q(a,b,c),r(a,b,c)}),s(t,"getAttachment",function(a,b,c){var d="blob";return q(a,b,c),r(a,b,c),void 0!==a[2]&&(d=a[2].format||d,delete a[2].format),d},function(a,d,e){var f;if(!(d instanceof c))throw new v.util.jIOError("'getAttachment' ("+a[0]+" , "+a[1]+") on '"+this.__type+"' does not return a Blob.",501);if("blob"===e)f=d;else if("data_url"===e)f=(new b.Queue).push(function(){return v.util.readBlobAsDataURL(d)}).push(function(a){return a.target.result});else if("array_buffer"===e)f=(new b.Queue).push(function(){return v.util.readBlobAsArrayBuffer(d)}).push(function(a){return a.target.result});else if("text"===e)f=(new b.Queue).push(function(){return v.util.readBlobAsText(d)}).push(function(a){return a.target.result});else{if("json"!==e)throw new v.util.jIOError(this.__type+".getAttachment format: '"+e+"' is not supported",400);f=(new b.Queue).push(function(){return v.util.readBlobAsText(d)}).push(function(a){return JSON.parse(a.target.result)})}return f}),t.prototype.buildQuery=function(){var a=this.__storage.buildQuery,c=this,d=arguments;if(void 0===a)throw new v.util.jIOError("Capacity 'buildQuery' is not implemented on '"+this.__type+"'",501);return(new b.Queue).push(function(){return a.apply(c.__storage,d)})},t.prototype.hasCapacity=function(a){var b=this.__storage.hasCapacity,c=this.__storage[a];if(void 0!==c)return!0;if(void 0===b||!b.apply(this.__storage,arguments))throw new v.util.jIOError("Capacity '"+a+"' is not implemented on '"+this.__type+"'",501);return!0},t.prototype.allDocs=function(a){var c=this;return void 0===a&&(a={}),(new b.Queue).push(function(){return!c.hasCapacity("list")||void 0!==a.query&&!c.hasCapacity("query")||void 0!==a.sort_on&&!c.hasCapacity("sort")||void 0!==a.select_list&&!c.hasCapacity("select")||void 0!==a.include_docs&&!c.hasCapacity("include")||void 0!==a.limit&&!c.hasCapacity("limit")?void 0:c.buildQuery(a)}).push(function(a){return{data:{rows:a,total_rows:a.length}}})},s(t,"allAttachments",q),s(t,"repair"),t.prototype.repair=function(){var a=this,c=arguments;return(new b.Queue).push(function(){var b=a.__storage.repair;return void 0!==b?a.__storage.repair.apply(a.__storage,c):void 0})},u.prototype.createJIO=function(a,b){if("string"!=typeof a.type)throw new TypeError("Invalid storage description");if(!this.__storage_types[a.type])throw new TypeError("Unknown storage '"+a.type+"'");return new t(a.type,new this.__storage_types[a.type](a,b))},u.prototype.addStorage=function(a,b){if("string"!=typeof a)throw new TypeError("jIO.addStorage(): Argument 1 is not of type 'string'");if("function"!=typeof b)throw new TypeError("jIO.addStorage(): Argument 2 is not of type 'function'");if(void 0!==this.__storage_types[a])throw new TypeError("jIO.addStorage(): Storage type already exists");this.__storage_types[a]=b},u.prototype.util=w,u.prototype.QueryFactory=d,u.prototype.Query=e,v=new u,a.jIO=v}(window,RSVP,Blob,QueryFactory,Query,atob,FileReader,ArrayBuffer,Uint8Array),function(){function a(a){"use strict";var d={fill:0},f=function(a){for(a+=9;a%64>0;a+=1);return a},g=function(a,b){for(var c=b>>2;c<a.length;c++)a[c]=0},h=function(a,b,c){a[b>>2]|=128<<24-(b%4<<3),a[((b>>2)+2&-16)+14]=c>>29,a[((b>>2)+2&-16)+15]=c<<3},i=function(a,b,c,d,e){var f,g=this,h=e%4,i=d%4,j=d-i;if(j>0)switch(h){case 0:a[e+3|0]=g.charCodeAt(c);case 1:a[e+2|0]=g.charCodeAt(c+1);case 2:a[e+1|0]=g.charCodeAt(c+2);case 3:a[0|e]=g.charCodeAt(c+3)}for(f=h;j>f;f=f+4|0)b[e+f>>2]=g.charCodeAt(c+f)<<24|g.charCodeAt(c+f+1)<<16|g.charCodeAt(c+f+2)<<8|g.charCodeAt(c+f+3);switch(i){case 3:a[e+j+1|0]=g.charCodeAt(c+j+2);case 2:a[e+j+2|0]=g.charCodeAt(c+j+1);case 1:a[e+j+3|0]=g.charCodeAt(c+j)}},j=function(a,b,c,d,e){var f,g=this,h=e%4,i=d%4,j=d-i;if(j>0)switch(h){case 0:a[e+3|0]=g[c];case 1:a[e+2|0]=g[c+1];case 2:a[e+1|0]=g[c+2];case 3:a[0|e]=g[c+3]}for(f=4-h;j>f;f=f+=4)b[e+f>>2]=g[c+f]<<24|g[c+f+1]<<16|g[c+f+2]<<8|g[c+f+3];switch(i){case 3:a[e+j+1|0]=g[c+j+2];case 2:a[e+j+2|0]=g[c+j+1];case 1:a[e+j+3|0]=g[c+j]}},k=function(a,b,d,e,f){var g,h=this,i=f%4,j=e%4,k=e-j,l=new Uint8Array(c.readAsArrayBuffer(h.slice(d,d+e)));if(k>0)switch(i){case 0:a[f+3|0]=l[0];case 1:a[f+2|0]=l[1];case 2:a[f+1|0]=l[2];case 3:a[0|f]=l[3]}for(g=4-i;k>g;g=g+=4)b[f+g>>2]=l[g]<<24|l[g+1]<<16|l[g+2]<<8|l[g+3];switch(j){case 3:a[f+k+1|0]=l[k+2];case 2:a[f+k+2|0]=l[k+1];case 1:a[f+k+3|0]=l[k]}},l=function(a){switch(e.getDataType(a)){case"string":return i.bind(a);case"array":return j.bind(a);case"buffer":return j.bind(a);case"arraybuffer":return j.bind(new Uint8Array(a));case"view":return j.bind(new Uint8Array(a.buffer,a.byteOffset,a.byteLength));case"blob":return k.bind(a)}},m=function(a){var b,c,d="0123456789abcdef",e=[],f=new Uint8Array(a);for(b=0;b<f.length;b++)c=f[b],e[b]=d.charAt(c>>4&15)+d.charAt(c>>0&15);return e.join("")},n=function(a){var b;if(65536>=a)return 65536;if(16777216>a)for(b=1;a>b;b<<=1);else for(b=16777216;a>b;b+=16777216);return b},o=function(a){if(a%64>0)throw new Error("Chunk size must be a multiple of 128 bit");d.maxChunkLen=a,d.padMaxChunkLen=f(a),d.heap=new ArrayBuffer(n(d.padMaxChunkLen+320+20)),d.h32=new Int32Array(d.heap),d.h8=new Int8Array(d.heap),d.core=b({Int32Array:Int32Array,DataView:DataView},{},d.heap),d.buffer=null};o(a||65536);var p=function(a,b){var c=new Int32Array(a,b+320,5);c[0]=1732584193,c[1]=-271733879,c[2]=-1732584194,c[3]=271733878,c[4]=-1009589776},q=function(a,b){var c=f(a),e=new Int32Array(d.heap,0,c>>2);return g(e,a),h(e,a,b),c},r=function(a,b,c){l(a)(d.h8,d.h32,b,c,0)},s=function(a,b,c,e,f){var g=c;f&&(g=q(c,e)),r(a,b,c),d.core.hash(g,d.padMaxChunkLen)},t=function(a,b){var c=new Int32Array(a,b+320,5),d=new Int32Array(5),e=new DataView(d.buffer);return e.setInt32(0,c[0],!1),e.setInt32(4,c[1],!1),e.setInt32(8,c[2],!1),e.setInt32(12,c[3],!1),e.setInt32(16,c[4],!1),d},u=this.rawDigest=function(a){var b=a.byteLength||a.length||a.size||0;p(d.heap,d.padMaxChunkLen);var c=0,e=d.maxChunkLen;for(c=0;b>c+e;c+=e)s(a,c,e,b,!1);return s(a,c,b-c,b,!0),t(d.heap,d.padMaxChunkLen)};this.digest=this.digestFromString=this.digestFromBuffer=this.digestFromArrayBuffer=function(a){return m(u(a).buffer)}}function b(a,b,c){"use asm";function d(a,b){a|=0,b|=0;var c=0,d=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;for(f=e[b+320>>2]|0,h=e[b+324>>2]|0,j=e[b+328>>2]|0,l=e[b+332>>2]|0,n=e[b+336>>2]|0,c=0;(c|0)<(a|0);c=c+64|0){for(g=f,i=h,k=j,m=l,o=n,d=0;(d|0)<64;d=d+4|0)q=e[c+d>>2]|0,p=((f<<5|f>>>27)+(h&j|~h&l)|0)+((q+n|0)+1518500249|0)|0,n=l,l=j,j=h<<30|h>>>2,h=f,f=p,e[a+d>>2]=q;for(d=a+64|0;(d|0)<(a+80|0);d=d+4|0)q=(e[d-12>>2]^e[d-32>>2]^e[d-56>>2]^e[d-64>>2])<<1|(e[d-12>>2]^e[d-32>>2]^e[d-56>>2]^e[d-64>>2])>>>31,p=((f<<5|f>>>27)+(h&j|~h&l)|0)+((q+n|0)+1518500249|0)|0,n=l,l=j,j=h<<30|h>>>2,h=f,f=p,e[d>>2]=q;for(d=a+80|0;(d|0)<(a+160|0);d=d+4|0)q=(e[d-12>>2]^e[d-32>>2]^e[d-56>>2]^e[d-64>>2])<<1|(e[d-12>>2]^e[d-32>>2]^e[d-56>>2]^e[d-64>>2])>>>31,p=((f<<5|f>>>27)+(h^j^l)|0)+((q+n|0)+1859775393|0)|0,n=l,l=j,j=h<<30|h>>>2,h=f,f=p,e[d>>2]=q;for(d=a+160|0;(d|0)<(a+240|0);d=d+4|0)q=(e[d-12>>2]^e[d-32>>2]^e[d-56>>2]^e[d-64>>2])<<1|(e[d-12>>2]^e[d-32>>2]^e[d-56>>2]^e[d-64>>2])>>>31,p=((f<<5|f>>>27)+(h&j|h&l|j&l)|0)+((q+n|0)-1894007588|0)|0,n=l,l=j,j=h<<30|h>>>2,h=f,f=p,e[d>>2]=q;for(d=a+240|0;(d|0)<(a+320|0);d=d+4|0)q=(e[d-12>>2]^e[d-32>>2]^e[d-56>>2]^e[d-64>>2])<<1|(e[d-12>>2]^e[d-32>>2]^e[d-56>>2]^e[d-64>>2])>>>31,p=((f<<5|f>>>27)+(h^j^l)|0)+((q+n|0)-899497514|0)|0,n=l,l=j,j=h<<30|h>>>2,h=f,f=p,e[d>>2]=q;f=f+g|0,h=h+i|0,j=j+k|0,l=l+m|0,n=n+o|0}e[b+320>>2]=f,e[b+324>>2]=h,e[b+328>>2]=j,e[b+332>>2]=l,e[b+336>>2]=n}var e=new a.Int32Array(c);return{hash:d}}if("undefined"!=typeof module?module.exports=a:"undefined"!=typeof window&&(window.Rusha=a),"undefined"!=typeof FileReaderSync){var c=new FileReaderSync,d=new a(4194304);self.onmessage=function(a){var b,c=a.data.data;try{b=d.digest(c),self.postMessage({id:a.data.id,hash:b})}catch(e){self.postMessage({id:a.data.id,error:e.name})}}}var e={getDataType:function(a){if("string"==typeof a)return"string";if(a instanceof Array)return"array";if("undefined"!=typeof global&&global.Buffer&&global.Buffer.isBuffer(a))return"buffer";if(a instanceof ArrayBuffer)return"arraybuffer";if(a.buffer instanceof ArrayBuffer)return"view";if(a instanceof Blob)return"blob";throw new Error("Unsupported data type.")}}}(),function(a,b,c){"use strict";function d(a){return f.digestFromString(a)}function e(b){if(this._query_options=b.query||{},this._local_sub_storage=a.createJIO(b.local_sub_storage),this._remote_sub_storage=a.createJIO(b.remote_sub_storage),this._signature_hash="_replicate_"+d(JSON.stringify(b.local_sub_storage)+JSON.stringify(b.remote_sub_storage)+JSON.stringify(this._query_options)),this._signature_sub_storage=a.createJIO({type:"document",document_id:this._signature_hash,sub_storage:b.local_sub_storage}),this._use_remote_post=b.use_remote_post||!1,this._conflict_handling=b.conflict_handling||0,this._conflict_handling!==g&&this._conflict_handling!==h&&this._conflict_handling!==i&&this._conflict_handling!==j)throw new a.util.jIOError("Unsupported conflict handling: "+this._conflict_handling,400);this._check_local_modification=b.check_local_modification,void 0===this._check_local_modification&&(this._check_local_modification=!0),this._check_local_creation=b.check_local_creation,void 0===this._check_local_creation&&(this._check_local_creation=!0),this._check_local_deletion=b.check_local_deletion,void 0===this._check_local_deletion&&(this._check_local_deletion=!0),this._check_remote_modification=b.check_remote_modification,void 0===this._check_remote_modification&&(this._check_remote_modification=!0),this._check_remote_creation=b.check_remote_creation,void 0===this._check_remote_creation&&(this._check_remote_creation=!0),this._check_remote_deletion=b.check_remote_deletion,void 0===this._check_remote_deletion&&(this._check_remote_deletion=!0)}var f=new c,g=0,h=1,i=2,j=3;e.prototype.remove=function(b){if(b===this._signature_hash)throw new a.util.jIOError(this._signature_hash+" is frozen",403);return this._local_sub_storage.remove.apply(this._local_sub_storage,arguments)},e.prototype.post=function(){return this._local_sub_storage.post.apply(this._local_sub_storage,arguments)},e.prototype.put=function(b){if(b===this._signature_hash)throw new a.util.jIOError(this._signature_hash+" is frozen",403);return this._local_sub_storage.put.apply(this._local_sub_storage,arguments)},e.prototype.get=function(){return this._local_sub_storage.get.apply(this._local_sub_storage,arguments)},e.prototype.hasCapacity=function(){return this._local_sub_storage.hasCapacity.apply(this._local_sub_storage,arguments)},e.prototype.buildQuery=function(){return this._local_sub_storage.buildQuery.apply(this._local_sub_storage,arguments)},e.prototype.repair=function(){function c(a,b,c,d,e,f){var g,h,i=!0;return void 0===f&&(f={}),g=f.use_post?b.post(c).push(function(b){return i=!1,h=b,a.put(h,c)}).push(function(){return a.remove(e)}).push(function(){return m._signature_sub_storage.remove(e)}).push(function(){return i=!0,m._signature_sub_storage.put(h,{hash:d})}).push(function(){o[h]=null}):b.put(e,c).push(function(){return m._signature_sub_storage.put(e,{hash:d})}),g.push(function(){i&&(o[e]=null)})}function e(b,e,f,g,h,i){var j;b.push(function(){return f.get(g)}).push(function(a){j=a},function(b){if(!(b instanceof a.util.jIOError&&404===b.status_code))throw b}).push(function(){return i(g)}).push(function(b){var i,k=d(JSON.stringify(b));if(void 0===j)return c(e,f,b,k,g,h);if(i=d(JSON.stringify(j)),k===i)return m._signature_sub_storage.put(g,{hash:k}).push(function(){o[g]=null});if(h.conflict_ignore!==!0){if(h.conflict_force===!0)return c(e,f,b,k,g,h);throw new a.util.jIOError("Conflict on '"+g+"'",409)}})}function f(a,c,d,f,g){a.push(function(){return c.bulk(f)}).push(function(a){function h(b){return function(c){if(c!==f[b].parameter_list[0])throw new Error("Does not access expected ID "+c);return a[b]}}var i,j=new b.Queue;for(i=0;i<a.length;i+=1)e(j,c,d,f[i].parameter_list[0],g,h(i));return j})}function g(b,e,f,g){var h;b.push(function(){return m._signature_sub_storage.get(f)}).push(function(b){return h=b.hash,e.get(f).push(function(a){var b=d(JSON.stringify(a));return b===h?e.remove(f).push(function(){return m._signature_sub_storage.remove(f)}).push(function(){o[f]=null}):c(e,g,a,b,f)},function(b){if(b instanceof a.util.jIOError&&404===b.status_code)return m._signature_sub_storage.remove(f).push(function(){o[f]=null});throw b})})}function k(e,f,g,h,i,j){e.push(function(){return b.all([f.get(h),m._signature_sub_storage.get(h)])}).push(function(b){var e=b[0],k=d(JSON.stringify(e)),l=b[1].hash;return k!==l?g.get(h).push(function(b){var n=d(JSON.stringify(b));if(n!==l){if(k===n)return m._signature_sub_storage.put(h,{hash:k}).push(function(){o[h]=null});if(j===!0)return;if(i!==!0)throw new a.util.jIOError("Conflict on '"+h+"'",409)}return c(f,g,e,k,h)},function(b){if(b instanceof a.util.jIOError&&404===b.status_code)return c(f,g,e,k,h);throw b}):void 0})}function l(a,c,d){var h=new b.Queue;return d.hasOwnProperty("use_post")||(d.use_post=!1),h.push(function(){return b.all([a.allDocs(m._query_options),m._signature_sub_storage.allDocs()])}).push(function(b){var i,j,l={},m=[],n={};for(i=0;i<b[0].data.total_rows;i+=1)o.hasOwnProperty(b[0].data.rows[i].id)||(l[b[0].data.rows[i].id]=i);for(i=0;i<b[1].data.total_rows;i+=1)o.hasOwnProperty(b[1].data.rows[i].id)||(n[b[1].data.rows[i].id]=i);if(d.check_creation===!0){for(j in l)l.hasOwnProperty(j)&&(n.hasOwnProperty(j)||(d.use_bulk_get===!0?m.push({method:"get",parameter_list:[j]}):e(h,a,c,j,d,a.get.bind(a))));d.use_bulk_get===!0&&0!==m.length&&f(h,a,c,m,d)}for(j in n)n.hasOwnProperty(j)&&(l.hasOwnProperty(j)?d.check_modification===!0&&k(h,a,c,j,d.conflict_force,d.conflict_ignore):d.check_deletion===!0&&g(h,c,j,a))})}var m=this,n=arguments,o={};return o[m._signature_hash]=null,(new b.Queue).push(function(){return m._signature_sub_storage.__storage._sub_storage.get(m._signature_hash)}).push(void 0,function(b){if(b instanceof a.util.jIOError&&404===b.status_code)return m._signature_sub_storage.__storage._sub_storage.put(m._signature_hash,{});throw b}).push(function(){return b.all([m._local_sub_storage.repair.apply(m._local_sub_storage,n),m._remote_sub_storage.repair.apply(m._remote_sub_storage,n)])}).push(function(){return m._check_local_modification||m._check_local_creation||m._check_local_deletion?l(m._local_sub_storage,m._remote_sub_storage,{use_post:m._use_remote_post,conflict_force:m._conflict_handling===h,conflict_ignore:m._conflict_handling===j||m._conflict_handling===i,check_modification:m._check_local_modification,check_creation:m._check_local_creation,check_deletion:m._check_local_deletion}):void 0}).push(function(){var b=!1;try{b=m._remote_sub_storage.hasCapacity("bulk")}catch(c){if(!(c instanceof a.util.jIOError&&501===c.status_code))throw c}return m._check_remote_modification||m._check_remote_creation||m._check_remote_deletion?l(m._remote_sub_storage,m._local_sub_storage,{use_bulk_get:b,conflict_force:m._conflict_handling===i,conflict_ignore:m._conflict_handling===j,check_modification:m._check_remote_modification,check_creation:m._check_remote_creation,check_deletion:m._check_remote_deletion}):void 0})},a.addStorage("replicate",e)}(jIO,RSVP,Rusha),function(a){"use strict";function b(a){this._sub_storage=jIO.createJIO(a.sub_storage)}var c=new a;b.prototype.post=function(a){return this._sub_storage.put(c.digestFromString(JSON.stringify(a)),a)},b.prototype.get=function(){return this._sub_storage.get.apply(this._sub_storage,arguments)},b.prototype.remove=function(){return this._sub_storage.remove.apply(this._sub_storage,arguments)},b.prototype.hasCapacity=function(){return this._sub_storage.hasCapacity.apply(this._sub_storage,arguments)},b.prototype.buildQuery=function(){return this._sub_storage.buildQuery.apply(this._sub_storage,arguments)},b.prototype.getAttachment=function(){return this._sub_storage.getAttachment.apply(this._sub_storage,arguments)},b.prototype.putAttachment=function(){return this._sub_storage.putAttachment.apply(this._sub_storage,arguments)},b.prototype.removeAttachment=function(){return this._sub_storage.removeAttachment.apply(this._sub_storage,arguments)},b.prototype.allAttachments=function(){return this._sub_storage.allAttachments.apply(this._sub_storage,arguments)},b.prototype.repair=function(){return this._sub_storage.repair.apply(this._sub_storage,arguments)},jIO.addStorage("sha",b)}(Rusha),function(a){"use strict";function b(b){this._sub_storage=a.createJIO(b.sub_storage)}b.prototype.get=function(){return this._sub_storage.get.apply(this._sub_storage,arguments)},b.prototype.allAttachments=function(){return this._sub_storage.allAttachments.apply(this._sub_storage,arguments)},b.prototype.post=function(a){function b(){return("0000"+Math.floor(65536*Math.random()).toString(16)).slice(-4)}var c=b()+b()+"-"+b()+"-"+b()+"-"+b()+"-"+b()+b()+b();return this.put(c,a)},b.prototype.put=function(){return this._sub_storage.put.apply(this._sub_storage,arguments)},b.prototype.remove=function(){return this._sub_storage.remove.apply(this._sub_storage,arguments)},b.prototype.getAttachment=function(){return this._sub_storage.getAttachment.apply(this._sub_storage,arguments)},b.prototype.putAttachment=function(){return this._sub_storage.putAttachment.apply(this._sub_storage,arguments)},b.prototype.removeAttachment=function(){return this._sub_storage.removeAttachment.apply(this._sub_storage,arguments)},b.prototype.repair=function(){return this._sub_storage.repair.apply(this._sub_storage,arguments)},b.prototype.hasCapacity=function(a){return this._sub_storage.hasCapacity(a)},b.prototype.buildQuery=function(){return this._sub_storage.buildQuery.apply(this._sub_storage,arguments)},a.addStorage("uuid",b)}(jIO),function(a){"use strict";function b(){this._database={}}b.prototype.put=function(a,b){return this._database.hasOwnProperty(a)||(this._database[a]={attachments:{}}),this._database[a].doc=JSON.stringify(b),a},b.prototype.get=function(b){try{return JSON.parse(this._database[b].doc)}catch(c){if(c instanceof TypeError)throw new a.util.jIOError("Cannot find document: "+b,404);throw c}},b.prototype.allAttachments=function(b){var c,d={};try{for(c in this._database[b].attachments)this._database[b].attachments.hasOwnProperty(c)&&(d[c]={})}catch(e){if(e instanceof TypeError)throw new a.util.jIOError("Cannot find document: "+b,404);throw e}return d},b.prototype.remove=function(a){return delete this._database[a],a},b.prototype.getAttachment=function(b,c){try{var d=this._database[b].attachments[c];if(void 0===d)throw new a.util.jIOError("Cannot find attachment: "+b+" , "+c,404);return d}catch(e){if(e instanceof TypeError)throw new a.util.jIOError("Cannot find attachment: "+b+" , "+c,404);throw e}},b.prototype.putAttachment=function(b,c,d){var e;try{e=this._database[b].attachments}catch(f){if(f instanceof TypeError)throw new a.util.jIOError("Cannot find document: "+b,404);throw f}e[c]=d},b.prototype.removeAttachment=function(b,c){try{delete this._database[b].attachments[c]}catch(d){if(d instanceof TypeError)throw new a.util.jIOError("Cannot find document: "+b,404);throw d}},b.prototype.hasCapacity=function(a){return"list"===a},b.prototype.buildQuery=function(){var a,b=[];for(a in this._database)this._database.hasOwnProperty(a)&&b.push({id:a,value:{}});return b},a.addStorage("memory",b)}(jIO),function(a,b,c,d){"use strict";function e(a){a.sessiononly===!0?this._storage=b:this._storage=c}function f(b){if("/"!==b)throw new a.util.jIOError("id "+b+" is forbidden (!== /)",400)}e.prototype.get=function(a){return f(a),{}},e.prototype.allAttachments=function(a){f(a);var b,c={};for(b in this._storage)this._storage.hasOwnProperty(b)&&(c[b]={});return c},e.prototype.getAttachment=function(b,c){f(b);var d=this._storage.getItem(c);if(null===d)throw new a.util.jIOError("Cannot find attachment "+c,404);return a.util.dataURItoBlob(d)},e.prototype.putAttachment=function(b,c,e){var g=this;return f(b),(new d.Queue).push(function(){return a.util.readBlobAsDataURL(e)}).push(function(a){g._storage.setItem(c,a.target.result)})},e.prototype.removeAttachment=function(a,b){return f(a),this._storage.removeItem(b)},e.prototype.hasCapacity=function(a){return"list"===a},e.prototype.buildQuery=function(){return[{id:"/",value:{}}]},a.addStorage("local",e)}(jIO,sessionStorage,localStorage,RSVP),function(a,b,c,d){"use strict";function e(a){this._sub_storage=jIO.createJIO(a.sub_storage)}function f(a,b){return a.indexOf(b)===a.length-b.length}var g="application/x-jio-utf16_lz_string";e.prototype.get=function(){return this._sub_storage.get.apply(this._sub_storage,arguments)},e.prototype.post=function(){return this._sub_storage.post.apply(this._sub_storage,arguments)},e.prototype.put=function(){return this._sub_storage.put.apply(this._sub_storage,arguments)},e.prototype.remove=function(){return this._sub_storage.remove.apply(this._sub_storage,arguments)},e.prototype.hasCapacity=function(){return this._sub_storage.hasCapacity.apply(this._sub_storage,arguments)},e.prototype.buildQuery=function(){return this._sub_storage.buildQuery.apply(this._sub_storage,arguments)},e.prototype.getAttachment=function(b,e){var f=this;return f._sub_storage.getAttachment(b,e).push(function(b){return b.type!==g?b:(new a.Queue).push(function(){return jIO.util.readBlobAsText(b,"utf16")}).push(function(a){var e=c.decompressFromUTF16(a.target.result);if(""===e)return b;try{return jIO.util.dataURItoBlob(e)}catch(f){if(f instanceof d)return b;throw f}})})},e.prototype.putAttachment=function(d,e,h){var i=this;return 0===h.type.indexOf("text/")||f(h.type,"xml")||f(h.type,"json")?(new a.Queue).push(function(){return jIO.util.readBlobAsDataURL(h)}).push(function(a){var f=c.compressToUTF16(a.target.result);return h=new b([f],{type:g}),i._sub_storage.putAttachment(d,e,h)}):this._sub_storage.putAttachment.apply(this._sub_storage,arguments)},e.prototype.removeAttachment=function(){return this._sub_storage.removeAttachment.apply(this._sub_storage,arguments)},e.prototype.allAttachments=function(){return this._sub_storage.allAttachments.apply(this._sub_storage,arguments)},jIO.addStorage("zip",e)}(RSVP,Blob,LZString,DOMException),function(a,b,c,d){"use strict";function e(b){if(0!==b.indexOf("/"))throw new a.util.jIOError("id "+b+" is forbidden (no begin /)",400);if(b.lastIndexOf("/")!==b.length-1)throw new a.util.jIOError("id "+b+" is forbidden (no end /)",400);return b}function f(b){if(-1!==b.indexOf("/"))throw new a.util.jIOError("attachment "+b+" is forbidden",400)}function g(a){if("string"!=typeof a.access_token||!a.access_token)throw new TypeError("Access Token' must be a string which contains more than one character.");if("string"!=typeof a.root||!a.root||"dropbox"!==a.root&&"sandbox"!==a.root)throw new TypeError("root must be 'dropbox' or 'sandbox'");this._access_token=a.access_token,this._root=a.root}var h="https://content.dropboxapi.com/1/files_put/{+root}{+id}{+name}{?access_token}",i=d.parse(h),j="https://api.dropboxapi.com/1/fileops/create_folder{?access_token,root,path}",k=d.parse(j),l="https://api.dropboxapi.com/1/fileops/delete/{?access_token,root,path}",m=d.parse(l),n="https://content.dropboxapi.com/1/files{/root,id}{+name}{?access_token}",o=d.parse(n),p="https://api.dropboxapi.com/1/metadata{/root}{+id}{?access_token}",q=d.parse(p);
g.prototype.put=function(c,d){var f=this;if(c=e(c),Object.getOwnPropertyNames(d).length>0)throw new a.util.jIOError("Can not store properties: "+Object.getOwnPropertyNames(d),400);return(new b.Queue).push(function(){return a.util.ajax({type:"POST",url:k.expand({access_token:f._access_token,root:f._root,path:c})})}).push(void 0,function(a){if(void 0===a.target||405!==a.target.status)throw a})},g.prototype.remove=function(b){return b=e(b),a.util.ajax({type:"POST",url:m.expand({access_token:this._access_token,root:this._root,path:b})})},g.prototype.get=function(c){var d=this;return"/"===c?{}:(c=e(c),(new b.Queue).push(function(){return a.util.ajax({type:"GET",url:q.expand({access_token:d._access_token,root:d._root,id:c})})}).push(function(b){var d=JSON.parse(b.target.response||b.target.responseText);if(d.is_dir)return{};throw new a.util.jIOError("Not a directory: "+c,404)},function(b){if(void 0!==b.target&&404===b.target.status)throw new a.util.jIOError("Cannot find document: "+c,404);throw b}))},g.prototype.allAttachments=function(c){var d=this;return c=e(c),(new b.Queue).push(function(){return a.util.ajax({type:"GET",url:q.expand({access_token:d._access_token,root:d._root,id:c})})}).push(function(b){var d,e=JSON.parse(b.target.response||b.target.responseText),f={};if(!e.is_dir)throw new a.util.jIOError("Not a directory: "+c,404);for(d=0;d<e.contents.length;d+=1)e.contents[d].is_dir||(f[e.contents[d].path.split("/").pop()]={});return f},function(b){if(void 0!==b.target&&404===b.target.status)throw new a.util.jIOError("Cannot find document: "+c,404);throw b})},g.prototype.putAttachment=function(b,c,d){return b=e(b),f(c),a.util.ajax({type:"PUT",url:i.expand({root:this._root,id:b,name:c,access_token:this._access_token}),dataType:d.type,data:d})},g.prototype.getAttachment=function(d,g){var h=this;return d=e(d),f(g),(new b.Queue).push(function(){return a.util.ajax({type:"GET",dataType:"blob",url:o.expand({root:h._root,id:d,name:g,access_token:h._access_token})})}).push(function(a){return new c([a.target.response||a.target.responseText],{type:a.target.getResponseHeader("Content-Type")||"application/octet-stream"})},function(b){if(void 0!==b.target&&404===b.target.status)throw new a.util.jIOError("Cannot find attachment: "+d+", "+g,404);throw b})},g.prototype.removeAttachment=function(c,d){var g=this;return c=e(c),f(d),(new b.Queue).push(function(){return a.util.ajax({type:"POST",url:m.expand({access_token:g._access_token,root:g._root,path:c+d})})}).push(void 0,function(b){if(void 0!==b.target&&404===b.target.status)throw new a.util.jIOError("Cannot find attachment: "+c+", "+d,404);throw b})},a.addStorage("dropbox",g)}(jIO,RSVP,Blob,UriTemplate),function(a,b,c,d){"use strict";function e(c,d){return void 0===d&&(d={}),void 0!==c._authorization&&(void 0===d.headers&&(d.headers={}),d.headers.Authorization=c._authorization),(new b.Queue).push(function(){return a.util.ajax(d)})}function f(b){if(0!==b.indexOf("/"))throw new a.util.jIOError("id "+b+" is forbidden (no begin /)",400);if(b.lastIndexOf("/")!==b.length-1)throw new a.util.jIOError("id "+b+" is forbidden (no end /)",400);return b}function g(b){if(-1!==b.indexOf("/"))throw new a.util.jIOError("attachment "+b+" is forbidden",400)}function h(a){if("string"!=typeof a.url)throw new TypeError("DavStorage 'url' is not of type string");this._url=a.url,"string"==typeof a.basic_login&&(this._authorization="Basic "+a.basic_login)}h.prototype.put=function(c,d){var g=this;if(c=f(c),Object.getOwnPropertyNames(d).length>0)throw new a.util.jIOError("Can not store properties: "+Object.getOwnPropertyNames(d),400);return(new b.Queue).push(function(){return e(g,{type:"MKCOL",url:g._url+c})}).push(void 0,function(a){if(void 0===a.target||405!==a.target.status)throw a})},h.prototype.remove=function(a){return a=f(a),e(this,{type:"DELETE",url:this._url+a})},h.prototype.get=function(c){var d=this;return c=f(c),(new b.Queue).push(function(){return e(d,{type:"PROPFIND",url:d._url+c,dataType:"text",headers:{Depth:"1"}})}).push(function(){return{}},function(b){if(void 0!==b.target&&404===b.target.status)throw new a.util.jIOError("Cannot find document",404);throw b})},h.prototype.allAttachments=function(d){var g=this;return d=f(d),(new b.Queue).push(function(){return e(g,{type:"PROPFIND",url:g._url+d,dataType:"text",headers:{Depth:"1"}})}).push(function(a){var b,d,e={},f=(new c).parseFromString(a.target.responseText,"text/xml").querySelectorAll("D\\:response, response");for(b=1;b<f.length;b+=1)d=f[b].querySelector("D\\:href, href").textContent.split("/").slice(-1)[0],void 0!==d&&""!==d&&(e[d]={});return e},function(b){if(void 0!==b.target&&404===b.target.status)throw new a.util.jIOError("Cannot find document",404);throw b})},h.prototype.putAttachment=function(c,d,h){var i=this;return c=f(c),g(d),(new b.Queue).push(function(){return e(i,{type:"PUT",url:i._url+c+d,data:h})}).push(void 0,function(b){if(403===b.target.status)throw new a.util.jIOError("Cannot access subdocument",404);throw b})},h.prototype.getAttachment=function(c,h){var i=this;return c=f(c),g(h),(new b.Queue).push(function(){return e(i,{type:"GET",url:i._url+c+h,dataType:"blob"})}).push(function(a){return new d([a.target.response||a.target.responseText],{type:a.target.getResponseHeader("Content-Type")||"application/octet-stream"})},function(b){if(void 0!==b.target&&404===b.target.status)throw new a.util.jIOError("Cannot find attachment: "+c+" , "+h,404);throw b})},h.prototype.removeAttachment=function(c,d){var h=this;return c=f(c),g(d),(new b.Queue).push(function(){return e(h,{type:"DELETE",url:h._url+c+d})}).push(void 0,function(b){if(void 0!==b.target&&404===b.target.status)throw new a.util.jIOError("Cannot find attachment: "+c+" , "+d,404);throw b})},a.addStorage("dav",h)}(jIO,RSVP,DOMParser,Blob),function(a,b){"use strict";function c(b){if(!Array.isArray(b.storage_list))throw new a.util.jIOError("storage_list is not an Array",400);var c;for(this._storage_list=[],c=0;c<b.storage_list.length;c+=1)this._storage_list.push(a.createJIO(b.storage_list[c]))}c.prototype._getWithStorageIndex=function(){function b(b){g.push(void 0,function(c){if(c instanceof a.util.jIOError&&404===c.status_code)return e._storage_list[b].get.apply(e._storage_list[b],f).push(function(a){return d=b,a});throw c})}var c,d=0,e=this,f=arguments,g=this._storage_list[0].get.apply(this._storage_list[0],f);for(c=1;c<this._storage_list.length;c+=1)b(c);return g.push(function(a){return[d,a]})},c.prototype.get=function(){return this._getWithStorageIndex.apply(this,arguments).push(function(a){return a[1]})},c.prototype.allAttachments=function(){var a=arguments,b=this;return this._getWithStorageIndex.apply(this,arguments).push(function(c){var d=b._storage_list[c[0]];return d.allAttachments.apply(d,a)})},c.prototype.post=function(){return this._storage_list[0].post.apply(this._storage_list[0],arguments)},c.prototype.put=function(){var b=arguments,c=this;return this._getWithStorageIndex(b[0]).push(void 0,function(b){if(b instanceof a.util.jIOError&&404===b.status_code)return[0];throw b}).push(function(a){var d=c._storage_list[a[0]];return d.put.apply(d,b)})},c.prototype.remove=function(){var a=arguments,b=this;return this._getWithStorageIndex(a[0]).push(function(c){var d=b._storage_list[c[0]];return d.remove.apply(d,a)})},c.prototype.buildQuery=function(){var a,c,d=[],e={},f=this._storage_list.length;for(a=0;f>a;a+=1)c=this._storage_list[a],d.push(c.buildQuery.apply(c,arguments));return(new b.Queue).push(function(){return b.all(d)}).push(function(b){var c,d,g,h=[];for(f=b.length,a=0;f>a;a+=1)for(c=b[a],d=c.length,g=0;d>g;g+=1)e.hasOwnProperty(c[g].id)||(e[c[g].id]=null,h.push(c[g]));return h})},c.prototype.hasCapacity=function(a){var b,c,d,e;if("list"===a||"query"===a||"select"===a){for(d=!0,c=this._storage_list.length,b=0;c>b;b+=1)e=this._storage_list[b],d=d&&e.hasCapacity(a);return d}return!1},c.prototype.repair=function(){var a,c=[];for(a=0;a<this._storage_list.length;a+=1)c.push(this._storage_list[a].repair.apply(this._storage_list[a],arguments));return b.all(c)},c.prototype.getAttachment=function(){var a=arguments,b=this;return this._getWithStorageIndex.apply(this,arguments).push(function(c){var d=b._storage_list[c[0]];return d.getAttachment.apply(d,a)})},c.prototype.putAttachment=function(){var a=arguments,b=this;return this._getWithStorageIndex.apply(this,arguments).push(function(c){var d=b._storage_list[c[0]];return d.putAttachment.apply(d,a)})},c.prototype.removeAttachment=function(){var a=arguments,b=this;return this._getWithStorageIndex.apply(this,arguments).push(function(c){var d=b._storage_list[c[0]];return d.removeAttachment.apply(d,a)})},a.addStorage("union",c)}(jIO,RSVP),function(a,b,c,d,e,f){"use strict";function g(b){return(new d.Queue).push(function(){return a.util.ajax({type:"GET",url:b._url,xhrFields:{withCredentials:!0}})}).push(function(a){return JSON.parse(a.target.responseText)})}function h(c,e,f){return void 0===f&&(f={}),g(c).push(function(c){return(new d.Queue).push(function(){return a.util.ajax({type:"GET",url:b.parse(c._links.traverse.href).expand({relative_url:e,view:f._view}),xhrFields:{withCredentials:!0}})}).push(void 0,function(b){if(void 0!==b.target&&404===b.target.status)throw new a.util.jIOError("Cannot find document: "+e,404);throw b})})}function i(a){return(new d.Queue).push(function(){var b,c,d,e=a._embedded._view,f={portal_type:a.portal_type},g={};g.form_id={key:[e.form_id.key],"default":e.form_id["default"]};for(c in e)e.hasOwnProperty(c)&&(b=e[c],d=0,0===c.indexOf("my_")&&b.editable&&(d=3),0===c.indexOf("your_")&&(d=5),0!==d&&m.hasOwnProperty(b.type)&&(g[c.substring(d)]={"default":b["default"],key:b.key},f[c.substring(d)]=b["default"]));return{action_href:e._actions.put.href,data:f,form_data:g}})}function j(b,c){return b.getAttachment(c,"view").push(function(b){return a.util.readBlobAsText(b)}).push(function(a){return JSON.parse(a.target.result)}).push(function(a){return i(a)})}function k(a){if("string"!=typeof a.url||!a.url)throw new TypeError("ERP5 'url' must be a string which contains more than one character.");this._url=a.url,this._default_view_reference=a.default_view_reference}function l(a){var b,c=a.data;for(b in c)c.hasOwnProperty(b)&&(c[b]||delete c[b]);return c}var m={StringField:null,EmailField:null,IntegerField:null,FloatField:null,TextAreaField:null};k.prototype.get=function(a){return j(this,a).push(function(a){return l(a)})},k.prototype.bulk=function(b){var e,f=this,h=[];for(e=0;e<b.length;e+=1){if("get"!==b[e].method)throw new Error("ERP5Storage: not supported "+b[e].method+" in bulk");h.push({relative_url:b[e].parameter_list[0],view:f._default_view_reference})}return g(f).push(function(b){var d=new c;return d.append("bulk_list",JSON.stringify(h)),a.util.ajax({type:"POST",url:b._actions.bulk.href,data:d,xhrFields:{withCredentials:!0}})}).push(function(a){function b(a){return a.portal_type=a._links.type.name,i(a).push(function(a){return l(a)})}var c=[],f=JSON.parse(a.target.responseText);for(e=0;e<f.result_list.length;e+=1)c.push(b(f.result_list[e]));return d.all(c)})},k.prototype.post=function(b){var d,f=this;return g(this).push(function(d){var e=new c;return e.append("portal_type",b.portal_type),e.append("parent_relative_url",b.parent_relative_url),a.util.ajax({type:"POST",url:d._actions.add.href,data:e,xhrFields:{withCredentials:!0}})}).push(function(a){var c=a.target.getResponseHeader("X-Location"),g=new e(c);return d=g.segment(2),f.put(d,b)}).push(function(){return d})},k.prototype.put=function(b,c){var d=this;return j(d,b).push(function(e){var g,h=e.form_data,i={};i[h.form_id.key]=h.form_id["default"];for(g in c)if(c.hasOwnProperty(g)){if("form_id"===g)throw new a.util.jIOError("ERP5: forbidden property: "+g,400);if("portal_type"!==g&&"parent_relative_url"!==g){if(!h.hasOwnProperty(g))throw new a.util.jIOError("ERP5: can not store property: "+g,400);i[h[g].key]=c[g]}}return d.putAttachment(b,e.action_href,new f([JSON.stringify(i)],{type:"application/json"}))})},k.prototype.allAttachments=function(a){var b=this;return h(this,a).push(function(){return void 0===b._default_view_reference?{links:{}}:{view:{},links:{}}})},k.prototype.getAttachment=function(b,c){if("view"===c){if(void 0===this._default_view_reference)throw new a.util.jIOError("Cannot find attachment view for: "+b,404);return h(this,b,{_view:this._default_view_reference}).push(function(a){var c=JSON.parse(a.target.responseText);return c._id=b,c.portal_type=c._links.type.name,new f([JSON.stringify(c)],{type:"application/hal+json"})})}if("links"===c)return h(this,b).push(function(a){return new f([JSON.stringify(JSON.parse(a.target.responseText))],{type:"application/hal+json"})});if(0===c.indexOf(this._url))return(new d.Queue).push(function(){return a.util.ajax({type:"GET",url:c,xhrFields:{withCredentials:!0}})}).push(function(a){var c=JSON.parse(a.target.responseText);return c._id=b,new f([JSON.stringify(c)],{type:a.target.getResponseHeader("Content-Type")})});throw new a.util.jIOError("ERP5: not support get attachment: "+c,400)},k.prototype.putAttachment=function(b,e,f){if(0!==e.indexOf(this._url))throw new a.util.jIOError("Can not store outside ERP5: "+e,400);return(new d.Queue).push(function(){return a.util.readBlobAsText(f)}).push(function(b){var d,f,g=JSON.parse(b.target.result),h=new c;for(f in g)if(g.hasOwnProperty(f))if(Array.isArray(g[f]))for(d=0;d<g[f].length;d+=1)h.append(f,g[f][d]);else h.append(f,g[f]);return a.util.ajax({type:"POST",url:e,data:h,xhrFields:{withCredentials:!0}})})},k.prototype.hasCapacity=function(a){return"list"===a||"query"===a||"select"===a||"limit"===a||"sort"===a},k.prototype.buildQuery=function(c){return g(this).push(function(d){return a.util.ajax({type:"GET",url:b.parse(d._links.raw_search.href).expand({query:c.query,select_list:c.select_list||["title","reference"],limit:c.limit,sort_on:c.sort_on}),xhrFields:{withCredentials:!0}})}).push(function(a){return JSON.parse(a.target.responseText)}).push(function(a){var b,c,d,f=a._embedded.contents,g=f.length,h=[];for(b=0;g>b;b+=1)d=f[b],c=new e(d._links.self.href),delete d._links,h.push({id:c.segment(2),value:d});return h})},a.addStorage("erp5",k)}(jIO,UriTemplate,FormData,RSVP,URI,Blob),function(a,b){"use strict";function c(b){this._sub_storage=a.createJIO(b.sub_storage),this._key_schema=b.key_schema}c.prototype.get=function(){return this._sub_storage.get.apply(this._sub_storage,arguments)},c.prototype.allAttachments=function(){return this._sub_storage.allAttachments.apply(this._sub_storage,arguments)},c.prototype.post=function(){return this._sub_storage.post.apply(this._sub_storage,arguments)},c.prototype.put=function(){return this._sub_storage.put.apply(this._sub_storage,arguments)},c.prototype.remove=function(){return this._sub_storage.remove.apply(this._sub_storage,arguments)},c.prototype.getAttachment=function(){return this._sub_storage.getAttachment.apply(this._sub_storage,arguments)},c.prototype.putAttachment=function(){return this._sub_storage.putAttachment.apply(this._sub_storage,arguments)},c.prototype.removeAttachment=function(){return this._sub_storage.removeAttachment.apply(this._sub_storage,arguments)},c.prototype.repair=function(){return this._sub_storage.repair.apply(this._sub_storage,arguments)},c.prototype.hasCapacity=function(a){return"list"===a?this._sub_storage.hasCapacity(a):!0},c.prototype.buildQuery=function(c){var d=this._sub_storage,e=this,f={},g=!1,h=!1;if(d.hasCapacity("list")){try{void 0!==c.query&&!d.hasCapacity("query")||void 0!==c.sort_on&&!d.hasCapacity("sort")||void 0!==c.select_list&&!d.hasCapacity("select")||void 0!==c.limit&&!d.hasCapacity("limit")||(f.query=c.query,f.sort_on=c.sort_on,f.select_list=c.select_list,f.limit=c.limit)}catch(i){if(!(i instanceof a.util.jIOError&&501===i.status_code))throw i;g=!0}try{(g||c.include_docs===!0)&&d.hasCapacity("include")&&(f.include_docs=!0)}catch(i){if(!(i instanceof a.util.jIOError&&501===i.status_code))throw i;h=!0}return d.buildQuery(f).push(function(c){function e(b){var e=c[b].id;return d.get(e).push(function(a){return a._id=e,a},function(b){if(!(b instanceof a.util.jIOError&&404===b.status_code))throw b})}var f,g,i=[c];if(h){for(f=c.length,g=0;f>g;g+=1)i.push(e(g));c=b.all(i)}return c}).push(function(a){var b,c,d;if(h){for(b=a[0],c=b.length,d=0;c>d;d+=1)b[d].doc=a[d+1];a=b}return a}).push(function(b){var d,f,h=[];if(g){for(d=b.length,f=0;d>f;f+=1)b[f].doc.__id=b[f].id,h.push(b[f].doc);c.select_list&&c.select_list.push("__id"),b=a.QueryFactory.create(c.query||"",e._key_schema).exec(h,c)}return b}).push(function(a){var b,d,e,f=[];if(g){for(d=a.length,e=0;d>e;e+=1){if(b={id:a[e].__id,value:c.select_list?a[e]:{},doc:{}},c.select_list&&delete b.value.__id,c.include_docs)throw new Error("QueryStorage does not support include docs");f.push(b)}a=f}return a})}},a.addStorage("query",c)}(jIO,RSVP),function(a,b,c){"use strict";function d(b){this._sub_storage=a.createJIO(b.sub_storage)}function e(a,b){return-1!==a.indexOf(b,a.length-b.length)}var f=".json",g="/.jio_documents/",h="/";d.prototype.get=function(c){var d=this;return(new b.Queue).push(function(){return d._sub_storage.getAttachment(g,c+f,{format:"json"})}).push(void 0,function(b){if(b instanceof a.util.jIOError&&404===b.status_code)return d._sub_storage.allAttachments(h).push(function(b){if(b.hasOwnProperty(c))return{};throw new a.util.jIOError("Cannot find document "+c,404)});throw b})},d.prototype.allAttachments=function(b){var c=this;return c._sub_storage.allAttachments(h).push(function(d){return d.hasOwnProperty(b)?{enclosure:{}}:c._sub_storage.getAttachment(g,b+f).push(function(){return{}},function(c){if(c instanceof a.util.jIOError&&404===c.status_code)throw new a.util.jIOError("Cannot find document "+b,404);throw c})})},d.prototype.put=function(b,d){var e=this;return e._sub_storage.putAttachment(g,b+f,new c([JSON.stringify(d)],{type:"application/json"})).push(void 0,function(h){if(h instanceof a.util.jIOError&&404===h.status_code)return e._sub_storage.put(g,{}).push(function(){return e._sub_storage.putAttachment(g,b+f,new c([JSON.stringify(d)],{type:"application/json"}))});throw h}).push(function(){return b})},d.prototype.remove=function(c){var d=this,e=!1;return(new b.Queue).push(function(){return d._sub_storage.removeAttachment(h,c)}).push(void 0,function(b){if(b instanceof a.util.jIOError&&404===b.status_code)return void(e=!0);throw b}).push(function(){return d._sub_storage.removeAttachment(g,c+f)}).push(void 0,function(b){if(!e&&b instanceof a.util.jIOError&&404===b.status_code)return c;throw b})},d.prototype.hasCapacity=function(a){return"list"===a},d.prototype.buildQuery=function(){var c={},d=this;return(new b.Queue).push(function(){return d._sub_storage.allAttachments(g)}).push(function(a){var b;for(b in a)a.hasOwnProperty(b)&&e(b,f)&&(c[b.substring(0,b.length-f.length)]=null)},function(b){if(!(b instanceof a.util.jIOError&&404===b.status_code))throw b}).push(function(){return d._sub_storage.allAttachments(h)}).push(function(a){var b;for(b in a)a.hasOwnProperty(b)&&(c[b]=null)}).push(function(){var a,b=[];for(a in c)c.hasOwnProperty(a)&&b.push({id:a,value:{}});return b})},d.prototype.getAttachment=function(b,c){if("enclosure"!==c)throw new a.util.jIOError("Only support 'enclosure' attachment",400);return this._sub_storage.getAttachment(h,b)},d.prototype.putAttachment=function(b,c,d){if("enclosure"!==c)throw new a.util.jIOError("Only support 'enclosure' attachment",400);return this._sub_storage.putAttachment(h,b,d)},d.prototype.removeAttachment=function(b,c){if("enclosure"!==c)throw new a.util.jIOError("Only support 'enclosure' attachment",400);return this._sub_storage.removeAttachment(h,b)},d.prototype.repair=function(){return this._sub_storage.repair.apply(this._sub_storage,arguments)},a.addStorage("drivetojiomapping",d)}(jIO,RSVP,Blob),function(a,b,c,d,e){"use strict";function f(b){this._sub_storage=a.createJIO(b.sub_storage),this._document_id=b.document_id,this._repair_attachment=b.repair_attachment||!1}function g(a,b){return void 0===b?"jio_document/"+d(a)+h:"jio_attachment/"+d(a)+"/"+d(b)}var h=".json",i=new RegExp("^jio_document/([\\w=]+)"+h+"$"),j=new RegExp("^jio_attachment/([\\w=]+)/([\\w=]+)$");f.prototype.get=function(a){return this._sub_storage.getAttachment(this._document_id,g(a),{format:"json"})},f.prototype.allAttachments=function(a){return this._sub_storage.allAttachments(this._document_id).push(function(b){var d,e,f={};for(e in b)if(b.hasOwnProperty(e)&&j.test(e)){d=j.exec(e);try{c(d[1])===a&&(f[c(d[2])]={})}catch(g){if(!g instanceof ReferenceError)throw g}}return f})},f.prototype.put=function(a,c){return this._sub_storage.putAttachment(this._document_id,g(a),new b([JSON.stringify(c)],{type:"application/json"})).push(function(){return a})},f.prototype.remove=function(a){var b=this;return this.allAttachments(a).push(function(c){var d,f=[];for(d in c)c.hasOwnProperty(d)&&f.push(b.removeAttachment(a,d));return e.all(f)}).push(function(){return b._sub_storage.removeAttachment(b._document_id,g(a))}).push(function(){return a})},f.prototype.repair=function(){var a=this;return this._sub_storage.repair.apply(this._sub_storage,arguments).push(function(b){return a._repair_attachment?a._sub_storage.allAttachments(a._document_id).push(function(b){var d,f,g,h,k=[],l={},m={};for(h in b)if(b.hasOwnProperty(h))if(d=void 0,f=void 0,i.test(h)){try{d=c(i.exec(h)[1])}catch(n){if(!n instanceof ReferenceError)throw n}void 0!==d&&(l[d]=null)}else if(j.test(h)){g=j.exec(h);try{d=c(g[1]),f=c(g[2])}catch(n){if(!n instanceof ReferenceError)throw n}void 0!==f&&(l.hasOwnProperty(d)||(m.hasOwnProperty(d)||(m[d]={}),m[d][f]=null))}for(d in m)if(m.hasOwnProperty(d)&&!l.hasOwnProperty(d))for(f in m[d])m[d].hasOwnProperty(f)&&k.push(a.removeAttachment(d,f));return e.all(k)}):b})},f.prototype.hasCapacity=function(a){return"list"===a},f.prototype.buildQuery=function(){return this._sub_storage.allAttachments(this._document_id).push(function(a){var b,d=[];for(b in a)if(a.hasOwnProperty(b)&&i.test(b))try{d.push({id:c(i.exec(b)[1]),value:{}})}catch(e){if(!e instanceof ReferenceError)throw e}return d})},f.prototype.getAttachment=function(a,b){return this._sub_storage.getAttachment(this._document_id,g(a,b))},f.prototype.putAttachment=function(a,b,c){return this._sub_storage.putAttachment(this._document_id,g(a,b),c)},f.prototype.removeAttachment=function(a,b){return this._sub_storage.removeAttachment(this._document_id,g(a,b))},a.addStorage("document",f)}(jIO,Blob,atob,btoa,RSVP),function(a,b,c,d,e,f){"use strict";function g(a){if("string"!=typeof a.database||""===a.database)throw new TypeError("IndexedDBStorage 'database' description property must be a non-empty string");this._database_name="jio:"+a.database}function h(a){return a.join("_")}function i(a){var b,c=a.target.result;b=c.createObjectStore("metadata",{keyPath:"_id",autoIncrement:!1}),b.createIndex("_id","_id",{unique:!0}),b=c.createObjectStore("attachment",{keyPath:"_key_path",autoIncrement:!1}),b.createIndex("_id","_id",{unique:!1}),b=c.createObjectStore("blob",{keyPath:"_key_path",autoIncrement:!1}),b.createIndex("_id_attachment",["_id","_attachment"],{unique:!1}),b.createIndex("_id","_id",{unique:!1})}function j(b){function d(b,c){var d=a.open(e);d.onerror=function(a){d.result&&d.result.close(),c(a)},d.onabort=function(){d.result.close(),c("Aborting connection to: "+e)},d.ontimeout=function(){d.result.close(),c("Connection to: "+e+" timeout")},d.onblocked=function(){d.result.close(),c("Connection to: "+e+" was blocked")},d.onupgradeneeded=i,d.onversionchange=function(){d.result.close(),c(e+" was upgraded")},d.onsuccess=function(){b(d.result)}}var e=b._database_name;return(new c.Queue).push(function(){return new c.Promise(d)})}function k(a,b,c,d){var e=a.transaction(b,c);return d!==!1&&(e.oncomplete=function(){a.close()}),e.onabort=function(){a.close()},e}function l(a,b){function d(c,d){a.onerror=function(b){a.transaction&&a.transaction.abort(),d(b)},a.onsuccess=function(a){var e=a.target.result;if(e){try{b(e)}catch(f){d(f)}e["continue"]()}else c()}}return new c.Promise(d)}function m(a){function d(c,d){a.onerror=d,a.onsuccess=function(){a.result&&c(a.result),d(new b.util.jIOError("Cannot find document",404))}}return new c.Promise(d)}function n(a){function b(b,c){a.onerror=c,a.onsuccess=function(){b(a.result)}}return new c.Promise(b)}function o(a){a["delete"]()}function p(a,b,d){return c.all([n(a.objectStore("attachment")["delete"](h([b,d]))),l(a.objectStore("blob").index("_id_attachment").openCursor(f.only([b,d])),o)])}var q=2e6;g.prototype.hasCapacity=function(a){return"list"===a||"include"===a},g.prototype.buildQuery=function(a){function b(a){d.push({id:a.key,value:{},doc:a.value.doc})}function c(a){d.push({id:a.key,value:{}})}var d=[];return j(this).push(function(d){var e=k(d,["metadata"],"readonly");return a.include_docs===!0?l(e.objectStore("metadata").index("_id").openCursor(),b):l(e.objectStore("metadata").index("_id").openKeyCursor(),c)}).push(function(){return d})},g.prototype.get=function(a){return j(this).push(function(b){var c=k(b,["metadata"],"readonly");return m(c.objectStore("metadata").get(a))}).push(function(a){return a.doc})},g.prototype.allAttachments=function(a){function b(a){d[a.value._attachment]={}}var d={};return j(this).push(function(d){var e=k(d,["metadata","attachment"],"readonly");return c.all([m(e.objectStore("metadata").get(a)),l(e.objectStore("attachment").index("_id").openCursor(f.only(a)),b)])}).push(function(){return d})},g.prototype.put=function(a,b){return j(this).push(function(c){var d=k(c,["metadata"],"readwrite");return n(d.objectStore("metadata").put({_id:a,doc:b}))})},g.prototype.remove=function(a){return j(this).push(function(b){var d=k(b,["metadata","attachment","blob"],"readwrite");return c.all([n(d.objectStore("metadata")["delete"](a)),l(d.objectStore("attachment").index("_id").openCursor(f.only(a)),o),l(d.objectStore("blob").index("_id").openCursor(f.only(a)),o)])})},g.prototype.getAttachment=function(a,f,g){var i,l,n,o;return void 0===g&&(g={}),j(this).push(function(b){return i=k(b,["attachment","blob"],"readonly"),m(i.objectStore("attachment").get(h([a,f])))}).push(function(d){var j,k,p,r=d.info.length,s=[],t=i.objectStore("blob");if(l=d.info.content_type,n=g.start||0,o=g.end||r,o>r&&(o=r),0>n||0>o)throw new b.util.jIOError("_start and _end must be positive",400);if(n>o)throw new b.util.jIOError("_start is greater than _end",400);for(k=e.floor(n/q),p=e.floor(o/q),o%q===0&&(p-=1),j=k;p>=j;j+=1)s.push(m(t.get(h([a,f,j]))));return c.all(s)}).push(function(a){var b,c,e=[],f=a.length;for(c=0;f>c;c+=1)e.push(a[c].blob);return void 0===g.start&&void 0===g.end?new d(e,{type:l}):(b=new d(e,{type:"application/octet-stream"}),b.slice(n,o,"application/octet-stream"))})},g.prototype.putAttachment=function(a,d,e){var f,g,i=[];return j(this).push(function(a){return g=a,b.util.readBlobAsArrayBuffer(e)}).push(function(b){for(var c=b.target.result,h=e.size,j=0;h>j;)i.push(c.slice(j,j+q)),j+=q;return f=k(g,["attachment","blob"],"readwrite"),p(f,a,d)}).push(function(){var b,g=[n(f.objectStore("attachment").put({_key_path:h([a,d]),_id:a,_attachment:d,info:{content_type:e.type,length:e.size}}))],j=i.length,k=f.objectStore("blob");for(b=0;j>b;b+=1)g.push(n(k.put({_key_path:h([a,d,b]),_id:a,_attachment:d,_part:b,blob:i[b]})));return c.all(g)})},g.prototype.removeAttachment=function(a,b){return j(this).push(function(c){var d=k(c,["attachment","blob"],"readwrite");return p(d,a,b)})},b.addStorage("indexeddb",g)}(indexedDB,jIO,RSVP,Blob,Math,IDBKeyRange);