MOBILE-3318 core: Remove ydn.db and its usage

main
Dani Palou 2020-01-24 10:05:27 +01:00
parent d172c34c30
commit 6556e54d0c
3 changed files with 2 additions and 536 deletions

View File

@ -1,365 +0,0 @@
(function(){var l,s=this;function t(a){return void 0!==a}function ba(a){a=a.split(".");for(var b=s,c;c=a.shift();)if(null!=b[c])b=b[c];else return null;return b}
function ca(a){var b=typeof a;if("object"==b)if(a){if(a instanceof Array)return"array";if(a instanceof Object)return b;var c=Object.prototype.toString.call(a);if("[object Window]"==c)return"object";if("[object Array]"==c||"number"==typeof a.length&&"undefined"!=typeof a.splice&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("splice"))return"array";if("[object Function]"==c||"undefined"!=typeof a.call&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("call"))return"function"}else return"null";
else if("function"==b&&"undefined"==typeof a.call)return"object";return b}function u(a){return"array"==ca(a)}function v(a){var b=ca(a);return"array"==b||"object"==b&&"number"==typeof a.length}function w(a){return"string"==typeof a}function da(a){return"boolean"==typeof a}function ea(a){return"number"==typeof a}function fa(a){return"function"==ca(a)}function y(a){var b=typeof a;return"object"==b&&null!=a||"function"==b}var ga="closure_uid_"+(1E9*Math.random()>>>0),ha=0;
function ia(a,b,c){return a.call.apply(a.bind,arguments)}function ja(a,b,c){if(!a)throw Error();if(2<arguments.length){var d=Array.prototype.slice.call(arguments,2);return function(){var c=Array.prototype.slice.call(arguments);Array.prototype.unshift.apply(c,d);return a.apply(b,c)}}return function(){return a.apply(b,arguments)}}function ka(a,b,c){ka=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?ia:ja;return ka.apply(null,arguments)}
function la(a,b){var c=Array.prototype.slice.call(arguments,1);return function(){var b=c.slice();b.push.apply(b,arguments);return a.apply(this,b)}}var ma=Date.now||function(){return+new Date};function na(a,b){var c=a.split("."),d=s;c[0]in d||!d.execScript||d.execScript("var "+c[0]);for(var e;c.length&&(e=c.shift());)!c.length&&t(b)?d[e]=b:d[e]?d=d[e]:d=d[e]={}}
function z(a,b){function c(){}c.prototype=b.prototype;a.r=b.prototype;a.prototype=new c;a.rc=function(a,c,f){return b.prototype[c].apply(a,Array.prototype.slice.call(arguments,2))}};function oa(a){a.prototype.then=a.prototype.then;a.prototype.$goog_Thenable=!0}function pa(a){if(!a)return!1;try{return!!a.$goog_Thenable}catch(b){return!1}};function qa(a){if(Error.captureStackTrace)Error.captureStackTrace(this,qa);else{var b=Error().stack;b&&(this.stack=b)}a&&(this.message=String(a))}z(qa,Error);qa.prototype.name="CustomError";var ra;function sa(a,b){for(var c=a.split("%s"),d="",e=Array.prototype.slice.call(arguments,1);e.length&&1<c.length;)d+=c.shift()+e.shift();return d+c.join("%s")}function ta(a){return/^[\s\xa0]*$/.test(a)}function ua(a,b){return a.replace(/(\r\n|\r|\n)/g,b?"<br />":"<br>")}
function va(a){if(!wa.test(a))return a;-1!=a.indexOf("&")&&(a=a.replace(xa,"&amp;"));-1!=a.indexOf("<")&&(a=a.replace(ya,"&lt;"));-1!=a.indexOf(">")&&(a=a.replace(za,"&gt;"));-1!=a.indexOf('"')&&(a=a.replace(Aa,"&quot;"));-1!=a.indexOf("'")&&(a=a.replace(Ba,"&#39;"));-1!=a.indexOf("\x00")&&(a=a.replace(Ca,"&#0;"));return a}var xa=/&/g,ya=/</g,za=/>/g,Aa=/"/g,Ba=/'/g,Ca=/\x00/g,wa=/[\x00&<>"']/;function Da(a){return ua(a.replace(/ /g," &#160;"),void 0)}
function Ea(a,b){for(var c=b.length,d=0;d<c;d++){var e=1==c?b:b.charAt(d);if(a.charAt(0)==e&&a.charAt(a.length-1)==e)return a.substring(1,a.length-1)}return a}var Fa={"\x00":"\\0","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\x0B":"\\x0B",'"':'\\"',"\\":"\\\\"},Ga={"'":"\\'"};
function Ha(a){a=String(a);if(a.quote)return a.quote();for(var b=['"'],c=0;c<a.length;c++){var d=a.charAt(c),e=d.charCodeAt(0),f=c+1,g;if(!(g=Fa[d])){if(!(31<e&&127>e))if(d in Ga)d=Ga[d];else if(d in Fa)d=Ga[d]=Fa[d];else{e=d;g=d.charCodeAt(0);if(31<g&&127>g)e=d;else{if(256>g){if(e="\\x",16>g||256<g)e+="0"}else e="\\u",4096>g&&(e+="0");e+=g.toString(16).toUpperCase()}d=Ga[d]=e}g=d}b[f]=g}b.push('"');return b.join("")}function Ia(a,b){return a<b?-1:a>b?1:0};function Ja(a,b){b.unshift(a);qa.call(this,sa.apply(null,b));b.shift()}z(Ja,qa);Ja.prototype.name="AssertionError";function Ka(a,b){throw new Ja("Failure"+(a?": "+a:""),Array.prototype.slice.call(arguments,1));};function La(a){s.setTimeout(function(){throw a;},0)}var Ma;
function Na(){if(s.Promise&&s.Promise.resolve){var a=s.Promise.resolve();return function(b){a.then(function(){try{b()}catch(a){La(a)}})}}var b=s.MessageChannel;"undefined"===typeof b&&"undefined"!==typeof window&&window.postMessage&&window.addEventListener&&(b=function(){var a=document.createElement("iframe");a.style.display="none";a.src="";document.documentElement.appendChild(a);var b=a.contentWindow,a=b.document;a.open();a.write("");a.close();var c="callImmediate"+Math.random(),d=b.location.protocol+
"//"+b.location.host,a=ka(function(a){if(a.origin==d||a.data==c)this.port1.onmessage()},this);b.addEventListener("message",a,!1);this.port1={};this.port2={postMessage:function(){b.postMessage(c,d)}}});if("undefined"!==typeof b){var c=new b,d={},e=d;c.port1.onmessage=function(){d=d.next;var a=d.Eb;d.Eb=null;a()};return function(a){e.next={Eb:a};e=e.next;c.port2.postMessage(0)}}return"undefined"!==typeof document&&"onreadystatechange"in document.createElement("script")?function(a){var b=document.createElement("script");
b.onreadystatechange=function(){b.onreadystatechange=null;b.parentNode.removeChild(b);b=null;a();a=null};document.documentElement.appendChild(b)}:function(a){s.setTimeout(a,0)}};function Oa(a,b){if(!Pa){var c=Qa;fa(s.setImmediate)?s.setImmediate(c):(Ma||(Ma=Na()),Ma(c));Pa=!0}Ra.push(new Sa(a,b))}var Pa=!1,Ra=[];[].push(function(){Pa=!1;Ra=[]});function Qa(){for(;Ra.length;){var a=Ra;Ra=[];for(var b=0;b<a.length;b++){var c=a[b];try{c.a.call(c.b)}catch(d){La(d)}}}Pa=!1}function Sa(a,b){this.a=a;this.b=b};function Ta(a,b){this.b=Ua;this.e=void 0;this.a=this.c=null;this.d=this.f=!1;try{var c=this;a.call(b,function(a){Va(c,Wa,a)},function(a){Va(c,Xa,a)})}catch(d){Va(this,Xa,d)}}var Ua=0,Wa=2,Xa=3;Ta.prototype.then=function(a,b,c){return Ya(this,fa(a)?a:null,fa(b)?b:null,c)};oa(Ta);function Za(a){a.b==Ua&&Oa(function(){var a=new $a(void 0);ab(this,a)},a)}
function ab(a,b){if(a.b==Ua)if(a.c){var c=a.c;if(c.a){for(var d=0,e=-1,f=0,g;g=c.a[f];f++)if(g=g.Ga)if(d++,g==a&&(e=f),0<=e&&1<d)break;0<=e&&(c.b==Ua&&1==d?ab(c,b):(d=c.a.splice(e,1)[0],Xa==Wa?d.qb(b):(bb(c),d.rb(b))))}}else Va(a,Xa,b)}function cb(a,b){a.a&&a.a.length||a.b!=Wa&&a.b!=Xa||db(a);a.a||(a.a=[]);a.a.push(b)}
function Ya(a,b,c,d){var e={Ga:null,qb:null,rb:null};e.Ga=new Ta(function(a,g){e.qb=b?function(c){try{var e=b.call(d,c);a(e)}catch(m){g(m)}}:a;e.rb=c?function(b){try{var e=c.call(d,b);!t(e)&&b instanceof $a?g(b):a(e)}catch(m){g(m)}}:g});e.Ga.c=a;cb(a,e);return e.Ga}Ta.prototype.g=function(a){this.b=Ua;Va(this,Wa,a)};Ta.prototype.h=function(a){this.b=Ua;Va(this,Xa,a)};
function Va(a,b,c){if(a.b==Ua){if(a==c)b=Xa,c=new TypeError("Promise cannot resolve to itself");else{if(pa(c)){a.b=1;c.then(a.g,a.h,a);return}if(y(c))try{var d=c.then;if(fa(d)){eb(a,c,d);return}}catch(e){b=Xa,c=e}}a.e=c;a.b=b;db(a);b!=Xa||c instanceof $a||fb(a,c)}}function eb(a,b,c){function d(b){f||(f=!0,a.h(b))}function e(b){f||(f=!0,a.g(b))}a.b=1;var f=!1;try{c.call(b,e,d)}catch(g){d(g)}}function db(a){a.f||(a.f=!0,Oa(a.i,a))}
Ta.prototype.i=function(){for(;this.a&&this.a.length;){var a=this.a;this.a=[];for(var b=0;b<a.length;b++){var c=a[b],d=this.e;this.b==Wa?c.qb(d):(bb(this),c.rb(d))}}this.f=!1};function bb(a){for(;a&&a.d;a=a.c)a.d=!1}function fb(a,b){a.d=!0;Oa(function(){a.d&&gb.call(null,b)})}var gb=La;function $a(a){qa.call(this,a)}z($a,qa);$a.prototype.name="cancel";var hb=Array.prototype,jb=hb.indexOf?function(a,b,c){return hb.indexOf.call(a,b,c)}:function(a,b,c){c=null==c?0:0>c?Math.max(0,a.length+c):c;if(w(a))return w(b)&&1==b.length?a.indexOf(b,c):-1;for(;c<a.length;c++)if(c in a&&a[c]===b)return c;return-1},kb=hb.forEach?function(a,b,c){hb.forEach.call(a,b,c)}:function(a,b,c){for(var d=a.length,e=w(a)?a.split(""):a,f=0;f<d;f++)f in e&&b.call(c,e[f],f,a)},lb=hb.map?function(a,b,c){return hb.map.call(a,b,c)}:function(a,b,c){for(var d=a.length,e=Array(d),f=
w(a)?a.split(""):a,g=0;g<d;g++)g in f&&(e[g]=b.call(c,f[g],g,a));return e},mb=hb.some?function(a,b,c){return hb.some.call(a,b,c)}:function(a,b,c){for(var d=a.length,e=w(a)?a.split(""):a,f=0;f<d;f++)if(f in e&&b.call(c,e[f],f,a))return!0;return!1};function nb(a,b){var c=ob(a,b,void 0);return 0>c?null:w(a)?a.charAt(c):a[c]}function ob(a,b,c){for(var d=a.length,e=w(a)?a.split(""):a,f=0;f<d;f++)if(f in e&&b.call(c,e[f],f,a))return f;return-1}
function pb(a){if(!u(a))for(var b=a.length-1;0<=b;b--)delete a[b];a.length=0}function qb(a,b){var c=jb(a,b),d;(d=0<=c)&&hb.splice.call(a,c,1);return d}function sb(a){var b=a.length;if(0<b){for(var c=Array(b),d=0;d<b;d++)c[d]=a[d];return c}return[]}function tb(a,b){if(!v(a)||!v(b)||a.length!=b.length)return!1;for(var c=a.length,d=ub,e=0;e<c;e++)if(!d(a[e],b[e]))return!1;return!0}function ub(a,b){return a===b};/*
Portions of this code are from MochiKit, received by
The Closure Authors under the MIT license. All other code is Copyright
2005-2009 The Closure Authors. All Rights Reserved.
*/
function B(a,b){this.h=[];this.N=b||null;this.b=this.c=!1;this.f=void 0;this.ma=this.v=this.i=!1;this.g=0;this.d=null;this.u=0}l=B.prototype;l.Ia=function(a,b){this.i=!1;vb(this,a,b)};function vb(a,b,c){a.c=!0;a.f=c;a.b=!b;a.lb()}function wb(a){if(a.c){if(!a.ma)throw new xb;a.ma=!1}}l.callback=function(a){wb(this);vb(this,!0,a)};l.k=function(a){wb(this);vb(this,!1,a)};l.C=function(a,b){return yb(this,a,null,b)};l.Db=function(a,b){return yb(this,null,a,b)};l.Cb=function(a,b){return yb(this,a,a,b)};
function yb(a,b,c,d){a.h.push([b,c,d]);a.c&&a.lb();return a}l.then=function(a,b,c){var d,e,f=new Ta(function(a,b){d=a;e=b});yb(this,d,function(a){e(a)});return f.then(a,b,c)};oa(B);function zb(a,b){b instanceof B?a.C(ka(b.Ya,b)):a.C(function(){return b})}B.prototype.Ya=function(a){var b=new B;yb(this,b.callback,b.k,b);a&&(b.d=this,this.u++);return b};function Ab(a){return mb(a.h,function(a){return fa(a[1])})}
B.prototype.lb=function(){this.g&&this.c&&Ab(this)&&(Bb(this.g),this.g=0);this.d&&(this.d.u--,delete this.d);for(var a=this.f,b=!1,c=!1;this.h.length&&!this.i;){var d=this.h.shift(),e=d[0],f=d[1],d=d[2];if(e=this.b?f:e)try{var g=e.call(d||this.N,a);t(g)&&(this.b=this.b&&(g==a||g instanceof Error),this.f=a=g);pa(a)&&(this.i=c=!0)}catch(h){a=h,this.b=!0,Ab(this)||(b=!0)}}this.f=a;c&&(c=ka(this.Ia,this,!0),g=ka(this.Ia,this,!1),a instanceof B?(yb(a,c,g),a.v=!0):a.then(c,g));b&&(a=new Cb(a),Db[a.Ra]=
a,this.g=a.Ra)};function Eb(a){var b=new B;b.callback(a);return b}function xb(){qa.call(this)}z(xb,qa);xb.prototype.message="Deferred has already fired";xb.prototype.name="AlreadyCalledError";function Cb(a){this.Ra=s.setTimeout(ka(this.b,this),0);this.a=a}Cb.prototype.b=function(){delete Db[this.Ra];throw this.a;};var Db={};function Bb(a){var b=Db[a];b&&(s.clearTimeout(b.Ra),delete Db[a])};function C(a){qa.call(this,a);this.name="ydn.error.ArgumentException"}z(C,qa);function Fb(a){qa.call(this,a);this.name="ydn.error.TypeError"}z(Fb,qa);function Gb(a){qa.call(this,a);this.name="ydn.error.NotSupportedException"}z(Gb,qa);function Hb(a){qa.call(this,a);this.name="ydn.error.NotImplementedException"}z(Hb,qa);function Ib(a){qa.call(this,a);this.name="ydn.error.InvalidOperationException"}z(Ib,qa);
function Jb(a){Error.captureStackTrace?Error.captureStackTrace(this,Jb):this.stack=Error().stack||"";a&&(this.message=String(a));this.name="ydn.error.InternalError"}z(Jb,Error);Jb.prototype.name="ydn.error.InternalError";function Mb(a,b){for(var c in a)b.call(void 0,a[c],c,a)}function Nb(a,b){for(var c=v(b),d=c?b:arguments,c=c?0:1;c<d.length&&(a=a[d[c]],t(a));c++);return a}var Ob="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function Pb(a,b){for(var c,d,e=1;e<arguments.length;e++){d=arguments[e];for(c in d)a[c]=d[c];for(var f=0;f<Ob.length;f++)c=Ob[f],Object.prototype.hasOwnProperty.call(d,c)&&(a[c]=d[c])}};var Qb="StopIteration"in s?s.StopIteration:Error("StopIteration");function Rb(){}Rb.prototype.next=function(){throw Qb;};Rb.prototype.gb=function(){return this};function Sb(a){if(a instanceof Rb)return a;if("function"==typeof a.gb)return a.gb(!1);if(v(a)){var b=0,c=new Rb;c.next=function(){for(;;){if(b>=a.length)throw Qb;if(b in a)return a[b++];b++}};return c}throw Error("Not implemented");}
function Tb(a,b){if(v(a))try{kb(a,b,void 0)}catch(c){if(c!==Qb)throw c;}else{a=Sb(a);try{for(;;)b.call(void 0,a.next(),void 0,a)}catch(d){if(d!==Qb)throw d;}}};function Ub(a,b){this.b={};this.a=[];this.d=this.c=0;var c=arguments.length;if(1<c){if(c%2)throw Error("Uneven number of arguments");for(var d=0;d<c;d+=2)Vb(this,arguments[d],arguments[d+1])}else if(a){var e;if(a instanceof Ub)e=a.fa(),d=a.Oa();else{var c=[],f=0;for(e in a)c[f++]=e;e=c;c=[];f=0;for(d in a)c[f++]=a[d];d=c}for(c=0;c<e.length;c++)Vb(this,e[c],d[c])}}l=Ub.prototype;l.mb=function(){return this.c};l.Oa=function(){Wb(this);for(var a=[],b=0;b<this.a.length;b++)a.push(this.b[this.a[b]]);return a};
l.fa=function(){Wb(this);return this.a.concat()};l.clear=function(){this.b={};this.d=this.c=this.a.length=0};function Wb(a){if(a.c!=a.a.length){for(var b=0,c=0;b<a.a.length;){var d=a.a[b];Object.prototype.hasOwnProperty.call(a.b,d)&&(a.a[c++]=d);b++}a.a.length=c}if(a.c!=a.a.length){for(var e={},c=b=0;b<a.a.length;)d=a.a[b],Object.prototype.hasOwnProperty.call(e,d)||(a.a[c++]=d,e[d]=1),b++;a.a.length=c}}l.get=function(a,b){return Object.prototype.hasOwnProperty.call(this.b,a)?this.b[a]:b};
function Vb(a,b,c){Object.prototype.hasOwnProperty.call(a.b,b)||(a.c++,a.a.push(b),a.d++);a.b[b]=c}l.forEach=function(a,b){for(var c=this.fa(),d=0;d<c.length;d++){var e=c[d],f=this.get(e);a.call(b,f,e,this)}};l.clone=function(){return new Ub(this)};l.gb=function(a){Wb(this);var b=0,c=this.a,d=this.b,e=this.d,f=this,g=new Rb;g.next=function(){for(;;){if(e!=f.d)throw Error("The map has changed since the iterator was created");if(b>=c.length)throw Qb;var g=c[b++];return a?g:d[g]}};return g};var Xb;a:{var Yb=s.navigator;if(Yb){var Zb=Yb.userAgent;if(Zb){Xb=Zb;break a}}Xb=""}function $b(a){return-1!=Xb.indexOf(a)};function ac(){return s.navigator||null}var bc=$b("Opera")||$b("OPR"),cc=$b("Trident")||$b("MSIE"),dc=$b("Gecko")&&-1==Xb.toLowerCase().indexOf("webkit")&&!($b("Trident")||$b("MSIE")),ec=-1!=Xb.toLowerCase().indexOf("webkit");ec&&$b("Mobile");var fc,gc=ac();fc=gc&&gc.platform||"";fc.indexOf("Mac");fc.indexOf("Win");fc.indexOf("Linux");ac()&&(ac().appVersion||"").indexOf("X11");var hc=Xb;hc&&hc.indexOf("Android");hc&&hc.indexOf("iPhone");hc&&hc.indexOf("iPad");
function ic(){var a=s.document;return a?a.documentMode:void 0}var jc=function(){var a="",b;if(bc&&s.opera)return a=s.opera.version,fa(a)?a():a;dc?b=/rv\:([^\);]+)(\)|;)/:cc?b=/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/:ec&&(b=/WebKit\/(\S+)/);b&&(a=(a=b.exec(Xb))?a[1]:"");return cc&&(b=ic(),b>parseFloat(a))?String(b):a}(),kc={};
function lc(a){var b;if(!(b=kc[a])){b=0;for(var c=String(jc).replace(/^[\s\xa0]+|[\s\xa0]+$/g,"").split("."),d=String(a).replace(/^[\s\xa0]+|[\s\xa0]+$/g,"").split("."),e=Math.max(c.length,d.length),f=0;0==b&&f<e;f++){var g=c[f]||"",h=d[f]||"",k=RegExp("(\\d*)(\\D*)","g"),m=RegExp("(\\d*)(\\D*)","g");do{var n=k.exec(g)||["","",""],q=m.exec(h)||["","",""];if(0==n[0].length&&0==q[0].length)break;b=Ia(0==n[1].length?0:parseInt(n[1],10),0==q[1].length?0:parseInt(q[1],10))||Ia(0==n[2].length,0==q[2].length)||
Ia(n[2],q[2])}while(0==b)}b=kc[a]=0<=b}return b}var mc=s.document,nc=mc&&cc?ic()||("CSS1Compat"==mc.compatMode?parseInt(jc,10):5):void 0;function oc(a){var b;b||(b=pc(a||arguments.callee.caller,[]));return b}
function pc(a,b){var c=[];if(0<=jb(b,a))c.push("[...circular reference...]");else if(a&&50>b.length){c.push(qc(a)+"(");for(var d=a.arguments,e=0;d&&e<d.length;e++){0<e&&c.push(", ");var f;f=d[e];switch(typeof f){case "object":f=f?"object":"null";break;case "string":break;case "number":f=String(f);break;case "boolean":f=f?"true":"false";break;case "function":f=(f=qc(f))?f:"[fn]";break;default:f=typeof f}40<f.length&&(f=f.substr(0,40)+"...");c.push(f)}b.push(a);c.push(")\n");try{c.push(pc(a.caller,
b))}catch(g){c.push("[exception trying to get caller]\n")}}else a?c.push("[...long stack...]"):c.push("[end]");return c.join("")}function qc(a){if(rc[a])return rc[a];a=String(a);if(!rc[a]){var b=/function ([^\(]+)/.exec(a);rc[a]=b?b[1]:"[Anonymous]"}return rc[a]}var rc={};function sc(a,b,c,d,e){"number"==typeof e||tc++;this.e=d||ma();this.f=a;this.d=b;this.c=c;delete this.b;delete this.a}sc.prototype.b=null;sc.prototype.a=null;var tc=0;function uc(a){this.e=a;this.a=this.d=this.b=this.c=null}function vc(a,b){this.name=a;this.value=b}vc.prototype.toString=function(){return this.name};var wc=new vc("SHOUT",1200),xc=new vc("SEVERE",1E3),yc=new vc("WARNING",900),zc=new vc("INFO",800),Ac=new vc("CONFIG",700),Bc=new vc("FINE",500),Cc=new vc("FINER",400),Dc=new vc("FINEST",300),Ec=[new vc("OFF",Infinity),wc,xc,yc,zc,Ac,Bc,Cc,Dc,new vc("ALL",0)],Fc=null;uc.prototype.getName=function(){return this.e};
function Gc(a){if(a.b)return a.b;if(a.c)return Gc(a.c);Ka("Root logger has no level set.");return null}uc.prototype.log=function(a,b,c){if(a.value>=Gc(this).value)for(fa(b)&&(b=b()),a=this.f(a,b,c,uc.prototype.log),b="log:"+a.d,s.console&&(s.console.timeStamp?s.console.timeStamp(b):s.console.markTimeline&&s.console.markTimeline(b)),s.msWriteProfilerMark&&s.msWriteProfilerMark(b),b=this;b;){c=b;var d=a;if(c.a)for(var e=0,f=void 0;f=c.a[e];e++)f(d);b=b.c}};
uc.prototype.f=function(a,b,c,d){a=new sc(a,String(b),this.e);if(c){a.b=c;var e;d=d||uc.prototype.f;try{var f;var g=ba("window.location.href");if(w(c))f={message:c,name:"Unknown error",lineNumber:"Not available",fileName:g,stack:"Not available"};else{var h,k;b=!1;try{h=c.lineNumber||c.sc||"Not available"}catch(m){h="Not available",b=!0}try{k=c.fileName||c.filename||c.sourceURL||s.$googDebugFname||g}catch(n){k="Not available",b=!0}f=!b&&c.lineNumber&&c.fileName&&c.stack&&c.message&&c.name?c:{message:c.message||
"Not available",name:c.name||"UnknownError",lineNumber:h,fileName:k,stack:c.stack||"Not available"}}e="Message: "+va(f.message)+'\nUrl: <a href="view-source:'+f.fileName+'" target="_new">'+f.fileName+"</a>\nLine: "+f.lineNumber+"\n\nBrowser stack:\n"+va(f.stack+"-> ")+"[end]\n\nJS stack traversal:\n"+va(oc(d)+"-> ")}catch(q){e="Exception trying to expose exception! You win, we lose. "+q}a.a=e}return a};var Hc={},Ic=null;function Jc(){Ic||(Ic=new uc(""),Hc[""]=Ic,Ic.b=Ac)}
function Kc(){Jc();return Ic}function G(a){Jc();var b;if(!(b=Hc[a])){b=new uc(a);var c=a.lastIndexOf("."),d=a.substr(c+1),c=G(a.substr(0,c));c.d||(c.d={});c.d[d]=b;b.c=c;Hc[a]=b}return b};function Lc(a,b,c){a&&a.log(b,c,void 0)}function Mc(a,b){a&&a.log(xc,b,void 0)}function H(a,b){a&&a.log(yc,b,void 0)}function Nc(a,b){a&&a.log(Bc,b,void 0)};function I(a,b){a&&a.log(Dc,b,void 0)}function J(a,b){a&&a.log(Cc,b,void 0)};function Oc(a,b){B.call(this,0,b);this.e=[]}z(Oc,B);Oc.prototype.Va=function(a,b){this.e.push([a,b]);return this};Oc.prototype.callback=function(a){this.e.length=0;Oc.r.callback.call(this,a)};Oc.prototype.k=function(a){this.e.length=0;Oc.r.k.call(this,a)};B.prototype.done=B.prototype.C;B.prototype.fail=B.prototype.Db;B.prototype.always=B.prototype.Cb;Oc.prototype.then=Oc.prototype.then;function K(a,b,c,d){this.lower=a;this.upper=b;this.lowerOpen=!!c;this.upperOpen=!!d;fa(Object.freeze)&&Object.freeze(this)}K.prototype.lower=void 0;K.prototype.upper=void 0;K.prototype.toJSON=function(){return Pc(this)};function Qc(a){return Rc(a)}K.only=function(a){return new K(a,a,!1,!1)};K.bound=function(a,b,c,d){return new K(a,b,c,d)};K.upperBound=function(a,b){return new K(void 0,a,void 0,!!b)};K.lowerBound=function(a,b){return new K(a,void 0,!!b,void 0)};
function Sc(a){var b;if(u(a))b=sb(a),b.push("\uffff");else if(w(a))b=a+"\uffff";else if(ea(a))b=a+2.220460492503131E-16,a-=2.220460492503131E-16;else return K.only(a);return K.bound(a,b,!1,!0)}function Pc(a){a=a||{};return{lower:a.lower,upper:a.upper,lowerOpen:a.lowerOpen,upperOpen:a.upperOpen}}
function Rc(a){return null!=a?null!=a.upper&&null!=a.lower?Tc.bound(a.lower,a.upper,!!a.lowerOpen,!!a.upperOpen):null!=a.upper?Tc.upperBound(a.upper,a.upperOpen):null!=a.lower?Tc.lowerBound(a.lower,a.lowerOpen):null:null}function Uc(a){if(a instanceof K)return"";if(null!=a){if(y(a)){for(var b in a){var c;if(c=a.hasOwnProperty(b))c=!(0<=jb(["lower","upper","lowerOpen","upperOpen"],b));if(c)return'invalid attribute "'+b+'" in key range object'}return""}return"key range must be an object"}return""}
K.prototype.ba=function(a){var b=this.lower,c=this.upper,d=this.lowerOpen,e=this.upperOpen;null!=a.lower&&(null==this.lower||a.lower>=this.lower)&&(b=a.lower,d=a.lowerOpen||this.lowerOpen);null!=a.upper&&(null==this.upper||a.upper<=this.upper)&&(c=a.upper,e=a.upperOpen||this.upperOpen);return K.bound(b,c,d,e)};function Vc(a){if(!a)return"";var b=a.lowerOpen?"(":"[";null!=a.lower&&(b+=a.lower+", ");null!=a.upper&&(b+=a.upper);return b+=a.upperOpen?")":"]"}
function Wc(a,b,c,d,e){if(c)if(c.lowerOpen||c.upperOpen||null==c.lower||null==c.upper||0!==L(c.lower,c.upper)){if(null!=c.lower){var f=c.lowerOpen?" > ":" >= ";d.push(a+f+"?");e.push(Xc(c.lower,b))}null!=c.upper&&(f=c.upperOpen?" < ":" <= ",d.push(a+f+"?"),e.push(Xc(c.upper,b)))}else d.push(a+" = ?"),e.push(Xc(c.lower,b))}
function Yc(a,b,c,d){var e,f,g,h;if("starts"==a||"^"==a)return Sc(b);if("<"==a||"<="==a)e=b,g="<"==a;else if(">"==a||">="==a)f=b,h=">"==a;else if("="==a||"=="==a)e=f=b;else throw new C("invalid op: "+a);if("<"==c||"<="==c)e=d,g="<"==c;else if(">"==c||">="==c)f=d,h=">"==c;else if(t(c))throw new C("invalid op2: "+c);return K.bound(f,e,h,g)}var Tc=s.IDBKeyRange||s.webkitIDBKeyRange||K;function Zc(a,b){var c,d;2==arguments.length&&w(arguments[1])?(c=!0,d=arguments[1].split(".")):d=(c=v(b))?b:arguments;for(c=c?0:1;c<d.length&&(a=a[d[c]],t(a));c++);return a}function $c(a,b,c){if(a)if(-1==b.indexOf("."))a[b]=c;else{b=b.split(".");for(var d=b.pop(),e;e=b.shift();)y(a[e])||(a[e]={}),a=a[e];a[d]=c}}var ad={};
function bd(a){var b=[a];a=new cd;for(var c=0,d,e;void 0!==(e=b.pop());){0===c%4&&12<c+4&&(a.write(c),c=0);d=typeof e;if(e instanceof Array)if(c+=4,0<e.length){b.push(ad);for(d=e.length;d--;)b.push(e[d]);continue}else a.write(c);else if("number"===d)c+=1,a.write(c),dd(a,e);else if(e instanceof Date)c+=2,a.write(c),dd(a,e.valueOf());else if("string"===d){c+=3;a.write(c);c=a;for(d=0;d<e.length;d++){var f=e.charCodeAt(d);126>=f?c.write(f+1):16510>=f?(f-=127,c.write(128|f>>8,f&255)):c.write(192|f>>10,
f>>2|255,(f|3)<<6)}c.write(0)}else if(e===ad)a.write(0);else return"";c=0}for(b=a.a.length;"00"===a.a[--b];);a.a.length=++b;return a.toString()}function ed(a){for(var b=[],c=b,d=[],e,f,g=new fd(a);null!=gd(g);)if(0===g.a)c=d.pop();else{if(null===g.a)break;do{e=g.a/4|0;a=g.a%4;for(var h=0;h<e;h++)f=[],c.push(f),d.push(c),c=f;if(0===a&&12<g.a+4)gd(g);else break}while(1);1===a?c.push(hd(g)):2===a?c.push(new Date(hd(g))):3===a?c.push(id(g)):0===a&&(c=d.pop())}return b[0]}
function dd(a,b){var c,d,e;c=b;var f=e=d=0;if(0!==c)if(isFinite(c)){0>c&&(d=1,c=-c);f=0;if(2.2250738585072014E-308<=c){for(e=c;1>e;)f--,e*=2;for(;2<=e;)f++,e/=2;e=f+1023}f=e?Math.floor(4503599627370496*(c/Math.pow(2,f)-1)):Math.floor(c/4.9E-324)}else e=2047,isNaN(c)?f=0x8000000000000:-Infinity===c&&(d=1);c=d;d=e;e=f;c&&(e=0xfffffffffffff-e,d=2047-d);a.write((c?0:128)|d>>4);a.write((d&15)<<4|0|e/281474976710656);e%=281474976710656;c=0|e/4294967296;a.write(c>>8,c&255);e%=4294967296;c=0|e/65536;a.write(c>>
8,c&255);c=e%65536;a.write(c>>8,c&255)}function hd(a){var b=gd(a)|0,c=b>>7?!1:!0,d=c?-1:1,e=(b&127)<<4,b=gd(a)|0,e=e+(b>>4);c&&(e=2047-e);for(var b=[c?15-(b&15):b&15],f=6;f--;)b.push(c?255-(gd(a)|0):gd(a)|0);a=0;for(f=7;f--;)a=a/256+b[f];a/=16;return 0===a&&0===e?0:(a+1)*Math.pow(2,e-1023)*d}
function id(a){for(var b=[],c=0,d=0,e=0,f,g;;){f=gd(a);if(0===f||null==f)break;0===c?(g=f>>6,2>g&&!isNaN(f)?b.push(String.fromCharCode(f-1)):(c=g,d=f<<10,e++)):2===c?(b.push(String.fromCharCode(d+f+127)),c=d=e=0):2===e?(d+=f<<2,e++):(b.push(String.fromCharCode(d|f>>6)),c=d=e=0)}return b.join("")}function fd(a){this.a=null;this.b=a;this.c=this.b.length-1;this.index=-1}function gd(a){return a.a=a.index<a.c?parseInt(a.b[++a.index]+a.b[++a.index],16):null}function cd(){this.a=[];this.b=void 0}
cd.prototype.write=function(a){for(var b=0;b<arguments.length;b++)this.b=arguments[b].toString(16),this.a.push(2===this.b.length?this.b:this.b="0"+this.b)};cd.prototype.toString=function(){return this.a.length?this.a.join(""):""};function jd(a,b){var c=bd(a),d=bd(b);return c>d?1:c==d?0:-1};function kd(a,b,c,d,e){if(!(b instanceof K))if(w(b)&&t(c))b=Yc(b,c,d,e);else if(null!=b){if(!(b instanceof K))if(y(b))b=new K(b.lower,b.upper,b.lowerOpen,b.upperOpen);else throw new C("Invalid key range: "+b+" of type "+typeof b);}else b=null;this.a=b;this.ea=a}kd.prototype.ea="";kd.prototype.ba=function(a){if(this.ea!=a.ea)return null;a=null!=this.a&&null!=a.a?this.a.ba(a.a):this.a||a.a;return new kd(this.ea,a)};var ld={READ_ONLY:"readonly",READ_WRITE:"readwrite",VERSION_CHANGE:"versionchange"},md=s.IDBRequest&&"LOADING"in s.IDBRequest?s.IDBTransaction:s.webkitIDBRequest&&"LOADING"in s.webkitIDBRequest&&1===s.webkitIDBTransaction.READ_WRITE?s.webkitIDBTransaction:ld,nd=md.READ_ONLY,M=md.READ_WRITE,od=md.VERSION_CHANGE,pd=s.indexedDB||s.mozIndexedDB||s.webkitIndexedDB||s.moz_indexedDB||s.msIndexedDB;function qd(){0!=rd&&(sd[this[ga]||(this[ga]=++ha)]=this)}var rd=0,sd={};qd.prototype.xa=!1;qd.prototype.kb=function(){if(!this.xa&&(this.xa=!0,this.$(),0!=rd)){var a=this[ga]||(this[ga]=++ha);delete sd[a]}};qd.prototype.$=function(){if(this.Va)for(;this.Va.length;)this.Va.shift()()};function td(a,b,c,d){qd.call(this);this.b=c;this.m=c.getName();this.I=void 0;this.f=!1;this.p=null;this.d=a;this.Mb=b;this.ma=0;this.N=this.v=!1;this.u=d||4;this.h=this.c=this.a=void 0;this.i=function(){throw new Jb;};this.l=function(){throw new Jb;};this.Ya=function(){}}z(td,qd);l=td.prototype;
l.Bb=function(a,b,c,d,e){if(t(b)){a=this.b;var f,g=b;u(b)?(f=ud(a,b),g=b.join(", ")):f=vd(a,b);if(!f)throw new C('require index "'+g+'" not found in store "'+a.getName()+'"');this.I=f.getName()}this.f=w(this.I);this.p=c||null;this.ma=0;this.N=this.v=!1;this.reverse="prev"==d||"prevunique"==d;this.unique="nextunique"==d||"prevunique"==d;this.Q=d;this.wa=e;this.h=this.c=this.a=void 0};l.Q="";l.p=null;l.unique=!1;l.reverse=!1;l.wa=!0;l.logger=G("ydn.db.core.req.AbstractCursor");
function wd(a,b){a.l(b);xd(a);a.v=!0}l.O=function(a,b,c){null==a&&(J(this.logger,this+" finished."),this.v=!0);this.a=a;this.c=b;this.h=c;this.ma++;this.v?(I(this.logger,this+" DONE."),this.i(),xd(this)):(I(this.logger,this+" new cursor position {"+(this.f?this.a+", "+this.c:this.a)+"}"),this.i(this.a))};l.$=function(){this.d=null};l.toString=function(){return"Cursor:"+this.m+(t(this.I)?":"+this.I:"")+"["+(this.d?"":"~")+this.Mb+"]"};
function xd(a){null!=a.c?a.c=yd(a.c):a.c=void 0;null!=a.a?a.a=yd(a.a):a.a=void 0;a.Ya(a.N,a.a,a.c)}l.open=function(a,b,c,d){this.d=a;this.Mb=b;this.v=this.N=!1;this.a=c;this.c=d;this.openCursor(this.a,this.c)};function zd(a){a.N=!0;I(a.logger,a+": exit");xd(a)}l.mb=function(){return this.ma};l.nc=function(){return this.a};l.B=function(){return this.f?this.c:this.a};l.aa=function(){return this.wa?this.B():this.h};l.Da=function(){};l.ja=function(){};
function Ad(a,b,c){I(a.logger,a+" restarting");a.v=!1;a.N=!1;a.openCursor(c,b)};function Bd(){};function N(a,b,c,d,e,f,g){if(!w(a))throw new TypeError("store name must be a string, but "+a+" found.");this.c=a;this.d=b;this.e=g;this.i=!!this.d;if(t(d)&&!da(d))throw new C("reverse value must be a boolean, but "+typeof d+" found");if(t(e)&&!da(e))throw new C("unique value must be a boolean, but "+typeof e+" found");if(t(f)&&!da(f))throw new C("key_only value must be a boolean, but "+typeof f+" found");this.a=t(f)?f:!!w(this.d);a="next";d&&e?a="prevunique":d?a="prev":e&&(a="nextunique");this.l=
a;if(d=Uc(c))throw new C("Invalid key range: "+d);this.b=Rc(c);this.f=Dd;this.o=NaN}z(N,Bd);N.prototype.a=!0;function Ed(a,b,c){if(3<arguments.length)throw new C("too many argument");N.call(this,a,void 0,b,c,void 0,!0)}z(Ed,N);function Fd(a,b,c,d,e){if(!w(b))throw new C("index name must be string");N.call(this,a,b,c,d,e,!0)}z(Fd,N);function Gd(a,b,c){if(3<arguments.length)throw new C("too many argument");N.call(this,a,void 0,b,c,void 0,!1)}z(Gd,N);
function Hd(a,b,c,d,e){if(!w(b))throw new C("index name must be string");N.call(this,a,b,c,d,e,!1)}z(Hd,N);var Dd="init";l=N.prototype;l.logger=G("ydn.db.Iterator");l.ec=function(){return this.c};l.bc=function(){return this.d};l.Nb=function(){return this.b?this.b instanceof Tc?this.b:Tc.bound(this.b.lower,this.b.upper,this.b.lowerOpen,this.b.upperOpen):null};l.fc=function(){return this.a};l.Xb=function(){return this.i};
l.clone=function(){var a=new N(this.c,this.d,this.b,this.V(),this.qa(),this.a,this.e);a.o=this.o;return a};l.unique=function(a){return new N(this.c,this.d,this.b,this.V(),a,this.a,this.e)};l.toJSON=function(){return{store:this.c,index:this.d,keyRange:this.b?Pc(this.b):null,direction:this.l}};
l.toString=function(){var a=t(this.e)?":"+this.e.join(","):t(this.d)?":"+this.d:"",a=a+Vc(this.b);this.f!=Dd&&(a+=this.f+"{"+this.g,this.i&&(a+=", "+this.h),a+="}");var b=this.i?"Index":"",b=b+(this.a?"Key":"Value");return b+"Iterator:"+this.c+a};l.Ob=function(a,b){var c=new N(this.c,this.d,this.b,this.V(),this.qa(),this.a,this.e);c.g=a;c.h=b;c.f="rest";return c};l.reverse=function(){return new N(this.c,this.d,this.b,!this.V(),this.qa(),this.a,this.e)};
l.V=function(){return"prev"===this.l||"prevunique"===this.l};l.qa=function(){return"nextunique"===this.l||"prevunique"===this.l};l.Wb=function(){return this.f};l.load=function(a){a=a[0];a.Bb(this.c,this.e||this.d,this.b,this.l,this.a);this.f="busy";var b=this;a.Ya=function(a,d,e){b.g=d;b.h=e;b.f=a?"rest":"done"};a.openCursor(this.g,this.h);return a};l.cc=function(){return this.g};l.dc=function(){return this.h};
l.wb=function(a,b,c){a=a||Dd;"busy"==this.f?H(this.logger,this+": resetting state to "+a+" ignore during iteration"):(this.g=b,this.h=c,this.f=a)};l.stores=function(){return[this.c]};function O(a,b,c){Oc.call(this,0,c);this.o=a;this.e=[];this.l=[];this.xa=[];this.a=null;this.pa="";this.D=0}z(O,Oc);l=O.prototype;l.pa="";l.logger=G("ydn.db.Request");function Id(a,b,c){a.a=b;a.pa=c;J(a.logger,a+" BEGIN");if(b){for(c=0;c<a.l.length;c++)a.l[c][0].call(a.l[c][1],b);a.l.length=0}}function Jd(a){var b=new O(a.o);a.D++;Id(b,a.a,a.pa+"C"+a.D);return b}function Kd(a){J(a.logger,a+" END");a.a=null}l.Sb=function(){return!!this.a};
l.abort=function(){J(this.logger,this+" aborting "+this.a);if(this.a)if(fa(this.a.abort))this.a.abort();else if(fa(this.a.executeSql))this.a.executeSql("ABORT",[],function(){},function(){return!0});else throw new Gb;else throw new Ld(this+" No active transaction");};function P(a,b,c){var d=a.xa.shift();c=!!c;d?d[0].call(d[1],b,c,function(b,c){P(a,b,c)}):c?a.k(b):a.callback(b)}function Md(a,b,c){a.xa.push([b,c])}function Q(a,b,c){a.a?b.call(c,a.a):a.l.push([b,c])}
l.callback=function(a){J(this.logger,this+" SUCCESS");O.r.callback.call(this,a)};l.k=function(a){J(this.logger,this+" ERROR");O.r.k.call(this,a)};function S(a){var b="";a.pa&&(b=a.a?"*":"",b="["+a.pa+b+"]");return a.o+b}function Nd(a,b){var c=new O(a);P(c,b);return c}l.kc=function(){return this};l.toString=function(){return"Request:"+S(this)};
l.lb=function(){this.g&&this.c&&Ab(this)&&(Bb(this.g),this.g=0);this.d&&(this.d.u--,delete this.d);for(var a=this.f,b=!1;this.h.length&&!this.i;){var c=this.h.shift(),d=c[0],e=c[1],c=c[2];if(d=this.b?e:d)d=d.call(c||this.N,a),t(d)&&(this.b=this.b&&(d==a||d instanceof Error),this.f=a=d),pa(a)&&(this.i=b=!0)}this.f=a;b&&(b=ka(this.Ia,this,!0),d=ka(this.Ia,this,!1),a instanceof B?(yb(a,b,d),a.v=!0):a.then(b,d))};
l.toJSON=function(){var a=(this.pa||"").match(/B(\d+)T(\d+)(?:Q(\d+?))?(?:R(\d+))?/)||[];return{method:this.o?this.o.split(":"):[],branchNo:parseFloat(a[1]),transactionNo:parseFloat(a[2]),queueNo:parseFloat(a[3]),requestNo:parseFloat(a[4])}};var L=pd&&pd.cmp?ka(pd.cmp,pd):jd,Od=[];function Pd(a,b,c,d){if("transaction"in a)this.g=a,this.c=this.e=null;else if("objectStore"in a){if(this.g=null,this.e=a.db,this.c=a,!this.c.db.objectStoreNames.contains(b))throw new Qd('store "'+b+'" not in transaction.');}else throw new Qd("storage instance require.");this.h=b;this.i=c;this.l=d;this.b=[];this.a=0;this.f=!1}Pd.prototype.logger=G("ydn.db.con.IdbCursorStream");Pd.prototype.f=!1;
function Rd(a,b){a.a++;b.onsuccess=function(b){if(b=b.target.result){if(fa(a.l)){var d=b.value;a.l(b.primaryKey,null!=a.i?d[a.i]:d)}else H(a.logger,"sink gone, dropping value for: "+b.primaryKey);if(b&&0<a.b.length)b["continue"](a.b.shift());else a.a--,0==a.a&&a.Y&&a.Y()}};b.onerror=function(){H(a.logger,"seeking fail. "+("error"in b?b.error.name+":"+b.error.message:""));a.a--;0==a.a&&a.Y&&a.Y()}}function Sd(a,b){0==a.b.length&&0==a.a?b():a.Y=b}
function Td(a){if(!a.f){var b=function(b,c){a.c=null;"complete"!==b&&H(a.logger,c.name+":"+c.message);I(a.logger,a+" transaction "+b)},c=function(b){var c=a.b.shift();I(a.logger,a+" transaction started for "+c);b=b.objectStore(a.h);Rd(a,b.openCursor(c))};if(a.c)I(a.logger,a+" using existing tx."),c(a.c);else if(a.e)I(a.logger,a+" creating tx from IDBDatabase."),a.d=a.e.transaction([a.h],nd),a.d.oncomplete=function(a){b("complete",a)},a.d.onerror=function(a){b("error",a)},a.d.onabort=function(a){b("abort",
a)};else if(a.g)I(a.logger,a+" creating tx from ydn.db.con.IStorage."),a.f=!0,a.g.transaction(function(b){a.f=!1;c(b)},[a.h],nd,b);else throw new Ud("no way to create a transaction provided.");}};function Vd(a,b,c){a&&a instanceof T?this.Aa=a:a&&a.db&&(this.Aa=null,Wd(this,a));if(!w(b))throw new C("a store name required.");this.c=b;if(t(c)&&!w(c))throw new C("projection index name must be a string.");this.Ba=c;this.ia=null;this.b=[];this.a=[];this.va=!1}l=Vd.prototype;l.logger=G("ydn.db.Streamer");l.Aa=null;l.yb=null;l.ia=null;l.ac=function(a){this.yb=a};function Wd(a,b){if(b.db)a.ia=new Pd(b,a.c,a.Ba,ka(a.Y,a));else throw new C("Invalid IndexedDB Transaction.");}
function Xd(a){var b=0<a.a.length;if(b&&!a.va&&fa(a.yb)){var c=function(){Xd(a)},d=a.b.shift(),e=a.a.shift(),b=0<a.a.length,c=a.yb(d,e,b?c:null);b&&!c&&Xd(a)}}l.va=!1;l.X=function(a){if(this.ia){this.va=!0;var b=this;Sd(this.ia,function(){a(b.b,b.a);b.b=[];b.a=[];b.va=!1})}else a(this.b,this.a),this.b=[],this.a=[]};l.Y=function(a,b){this.b.push(a);this.a.push(b);Xd(this)};
l.push=function(a,b){if(this.va)throw new Yd("push not allowed after a collection is started");if(2<=arguments.length)this.Y(a,b);else{if(!this.ia){if(!this.Aa)throw new Yd("Database connection is not setup.");var c=this.Aa.ta();if(c)if("indexeddb"===c)this.ia=new Pd(this.Aa,this.c,this.Ba,ka(this.Y,this));else throw new Zd(c);else throw new Yd("Database is not connected.");}c=this.ia;c.b.push(a);Td(c)}};l.toString=function(){return"Streamer:"+this.c+(this.Ba||"")};function $d(a,b){if(null!=a&&!("push"in a))throw new Qd('output receiver object must have "push" method.');this.a=a||null;this.g=b;this.f=0;this.b=!1;this.d=a instanceof Vd&&!!a.Ba}$d.prototype.logger=G("ydn.db.algo.AbstractSolver");
$d.prototype.e=function(a,b){this.b=b[0].V();for(var c=0;c<b.length;c++){if(!(b[c]instanceof N))throw new Fb("item at iterators "+c+" is not an iterator.");if(0<c&&this.b!=b[c].V())throw new Fb("iterator at "+c+" must "+(this.b?"be reverse":"not be reverse"));}this.a instanceof Vd&&Wd(this.a,a);if(this.d)if(c=b[0],(c=c.e||c.d)&&1<c.length){if(c[c.length-1]!=this.a.Ba)throw new Yd("Output streamer projection field must be same as postfix field in the iterator");}else H(this.logger,"Unable to check correctness of output streamer.");
for(var d="{",c=0;c<b.length;c++)0<c&&(d+=", "),d+=b.toString();d+="}";this.b&&(d+=" reverse");Nc(this.logger,this+" begin "+d);return!1};function ae(a,b,c){var d,e=null!=d;if(!t(d)){d=c[0];for(var e=null!=d,f=1;e&&f<c.length;f++)null!=c[f]&&0==L(c[f],d)||(e=!1)}return e&&(a.f++,a.a&&(a.d?a.a.push(d,void 0):a.a.push(d)),t(a.g)&&a.f>=a.g)?[]:b}$d.prototype.c=function(){return[]};function be(a){Error.captureStackTrace?Error.captureStackTrace(this,be):this.stack=Error().stack||"";a&&(this.message=String(a));this.name="ConstraintError"}z(be,Error);be.prototype.name="ConstraintError";be.prototype.toString=function(){return this.name+": "+this.message};function ce(a){Error.captureStackTrace?Error.captureStackTrace(this,ce):this.stack=Error().stack||"";a&&(this.message=String(a));this.name="ydn.db.InvalidKeyException"}z(ce,Error);
ce.prototype.toString=function(){return this.name+": "+this.message};function de(a){Error.captureStackTrace?Error.captureStackTrace(this,de):this.stack=Error().stack||"";a&&(this.message=String(a));this.name="ydn.db.VersionError"}z(de,Error);de.prototype.name="ydn.db.VersionError";de.prototype.toString=function(){return this.name+": "+this.message};function ee(a){Error.captureStackTrace?Error.captureStackTrace(this,ee):this.stack=Error().stack||"";a&&(this.message=String(a))}z(ee,Error);
ee.prototype.name="ydn.db.InternalError";function Ld(a){Error.captureStackTrace?Error.captureStackTrace(this,Ld):this.stack=Error().stack||"";a&&(this.message=String(a));this.name="InvalidStateError"}z(Ld,Error);function fe(a){Error.captureStackTrace?Error.captureStackTrace(this,fe):this.stack=Error().stack||"";a&&(this.message=String(a));this.name="InvalidAccessError"}z(fe,Error);
function ge(a){Error.captureStackTrace?Error.captureStackTrace(this,ge):this.stack=Error().stack||"";a&&(this.message=String(a));this.name="NotFoundError"}z(ge,Error);ge.prototype.name="NotFoundError";ge.prototype.toString=function(){return this.name+": "+this.message};function he(a,b){Error.captureStackTrace?Error.captureStackTrace(this,he):this.stack=Error().stack||"";b&&(this.message=String(b));this.message+=" :"+a.message+" ["+a.code+"]";this.name="SQLError"}z(he,Error);
he.prototype.toString=function(){return this.name+": "+this.message};function ie(a,b){Error.captureStackTrace?Error.captureStackTrace(this,ie):this.stack=Error().stack||"";b&&(this.message=String(b));this.message+=" :"+a.message;this.name="SecurityError"}z(ie,Error);ie.prototype.toString=function(){return this.name+": "+this.message};function je(a){Error.captureStackTrace?Error.captureStackTrace(this,je):this.stack=Error().stack||"";a&&(this.message=String(a));this.name="ydn.db.SqlParseError"}
z(je,Error);function ke(a){Error.captureStackTrace?Error.captureStackTrace(this,ke):this.stack=Error().stack||"";a&&(this.message=String(a));this.name="ydn.db.TimeoutError"}z(ke,Error);function le(a,b,c){var d;if(y(a))d=a.store,b=a.id,null!=a.parent&&(c=new le(a.parent));else if(t(b))d=a;else if(d=a.lastIndexOf("^|"),b=a,0<d&&(b=a.substr(d),c=new le(a.substring(0,d))),b=b.split("^:"),d=b[0],b=b[1],!t(b))throw Error("Invalid key value: "+a);this.m=d;this.id=b;this.parent=c||null}l=le.prototype;l.toJSON=function(){var a={store:this.m,id:this.id};this.parent&&(a.parent=this.parent.toJSON());return a};
l.valueOf=function(){return(this.parent?this.parent.valueOf()+"^|":"")+this.m+"^:"+this.id};l.toString=function(){return this.valueOf().replace("^|","|").replace("^:",":")};l.hc=function(){return this.m};l.Tb=function(){return this.id};function me(a){return u(a.id)?a.id.join("^|"):a.id instanceof Date?+a.id:a.id}l.gc=function(){return this.parent};function yd(a){if(v(a)){for(var b=[],c=0,d=a.length;c<d;c++)b[c]=a[c];return b}return a};function ne(a,b){this.a=b}ne.prototype.logger=G("ydn.db.crud.req.RequestExecuto");ne.prototype.toString=function(){return"RequestExecutor"};function oe(a){this.c=a;this.a=null;this.b=0}oe.prototype.logger=G("ydn.db.tr.Mutex");oe.prototype.J=null;function pe(a){return!!a.a&&!a.d}oe.prototype.F=null;oe.prototype.toString=function(){return"Mutex:"+("B"+this.c+"T"+this.b)+(this.a?"*":"")};function qe(a,b,c,d,e,f){this.v=a;this.D=b;this.a=this.d=0;this.u=d;this.o=e;this.f=c||re;this.h=f||0}qe.prototype.logger=G("ydn.db.tr.Thread");qe.prototype.type=function(){return this.v.ta()};qe.prototype.j=function(){return this.v};qe.prototype.A=function(){return"B"+this.D+"T"+this.d};var re="single";function se(a){if(a)if(fa(a.abort))a.abort();else if(fa(a.executeSql))a.executeSql("ABORT",[],null,function(){return!0});else throw new Gb;else throw new Ld("No active transaction");};function te(a,b,c,d,e,f){qe.call(this,a,b,c,d,e,f);this.c=[];this.e=[];this.g=null;this.b=new oe(b);this.i=f||0;this.l=!1}z(te,qe);l=te.prototype;l.logger=G("ydn.db.tr.Serial");
function ue(a,b,c){if("multi"==a.f)a:if(a=a.b,!a.J||!a.mode||c!=a.mode&&(a.mode!=M||c!=nd)||b.length>a.J.length)b=!1;else{for(c=0;c<b.length;c++)if(-1==a.J.indexOf(b[c])){b=!1;break a}b=!0}else if("repeat"==a.f)a:if(a=a.b,a.J&&a.mode&&c==a.mode&&a.J.length==b.length){for(c=0;c<b.length;c++)if(-1==a.J.indexOf(b[c])){b=!1;break a}b=!0}else b=!1;else b="all"==a.f?!0:!1;return b}function ve(a){var b=0<a.c.length?a.c[0].J:null,c=0<a.c.length?a.c[0].mode:null;return null!=b&&null!=c?ue(a,b,c):!1}
function we(a,b,c,d,e){I(a.logger,"push tx queue["+a.c.length+"]");a.c.push({Ma:b,J:c,mode:d,F:e})}l.abort=function(){J(this.logger,this+": aborting");se(this.g)};
l.ha=function(a,b,c,d){var e=w(b)?[b]:b;if(v(e)){if(0==e.length)throw new C("number of store names must more than 0");for(var f=0;f<e.length;f++){if(!w(e[f]))throw new C("store name at "+f+" must be string but found "+e[f]+" of type "+typeof e[f]);if(this.N&&!(0<=jb(this.N,e[f])))throw new C('store name "'+f+e[f]+'" in scope of '+this);}}else throw new C("store names must be an array");var g=t(c)?c:nd,h=this;if(this.b.a||!xe(this.j())&&this.l)we(this,a,b,g,d);else{var k=this.A();d&&this.e.push(d);
if(this.i&&this.d>=this.i)throw new Ib("Exceed maximum number of transactions of "+this.i);this.l=!0;this.j().transaction(function(c){var d=h.b;d.a=c;d.d=!1;d.J=b;d.mode=g;d.b++;d.F=null;k=h.A();Nc(h.logger,k+" BEGIN "+U(b)+" "+g);a(h);for(a=null;ve(h);)c=h.c.shift(),c.F&&h.e.push(c.F),I(h.logger,"pop tx queue"+(h.c.length+1)+" reusing T"+h.d),c.Ma()},e,g,function(a,b){Nc(h.logger,k+" "+a);var c=h.b;c.a?(c.a=null,c.J=null,c.mode=null,fa(c.F)&&c.F(a,b),c.F=null):H(c.logger,c+" has no TX to be unlocked for "+
a);for(c=0;c<h.e.length;c++)(0,h.e[c])(a,b);h.e.length=0;(c=h.c.shift())&&h.ha(c.Ma,c.J,c.mode,c.F);h.a=0})}};l.A=function(){var a=this.b;return"B"+a.c+"T"+a.b};l.request=function(a,b,c,d){function e(a,b){Kd(f);d&&d(a,b)}var f=new O(a);a=c||nd;var g=this;pe(this.b)&&ue(this,b,a)?(b=this.b.a,this.a++,Id(f,b,this.A()+"R"+this.a),this.e.push(e)):g.ha(function(){var a=g.b.a;g.a++;Id(f,a,g.A()+"R"+g.a)},b,a,e);return f};
l.W=function(a,b,c,d,e){d=d||nd;var f=this,g;if(pe(f.b)&&ue(this,c,d)){var h=f.b.a;f.a++;g=f.A()+"R"+f.a;J(f.logger,g+" BEGIN");b(h,g,function(b,c){f.g=h;c?(J(f.logger,g+" ERROR"),a.k(b)):(J(f.logger,g+" SUCCESS"),a.callback(b));f.g=null});J(f.logger,g+" END");b=null}else f.ha(function(){var c=f.b.a;f.a++;g=f.A()+"R"+f.a;J(f.logger,g+" BEGIN");b(c,g,function(b,d){f.g=c;d?(J(f.logger,g+" ERROR"),a.k(b)):(J(f.logger,g+" SUCCESS"),a.callback(b));f.g=null});J(f.logger,g+" END");b=null},c,d,e)};
l.getName=function(){return this.j().getName()};l.toString=function(){return"Serial:"+this.A()+(this.g?"*":"")};function ye(a,b){te.call(this,a,b)}z(ye,te);ye.prototype.logger=G("ydn.db.tr.AtomicSerial");ye.prototype.request=function(a,b,c){var d,e,f,g=ye.r.request.call(this,a,b,c,function(a,b){Kd(g);if(d)"complete"!=a&&(f=!0,e=b),d(e,f);else{var c=new ke;P(g,c,!0)}});Md(g,function(a,b,c){f=b;e=a;d=c});return g};
ye.prototype.W=function(a,b,c,d,e){var f,g,h=new B;yb(h,function(a){g=!1;f=a},function(a){g=!0;f=a});ye.r.W.call(this,h,b,c,d,function(b,c){if("complete"!=b)a.k(c);else if(!0===g)a.k(f);else if(!1===g)a.callback(f);else{var d=new ke;a.k(d)}e&&(e(b,c),e=void 0)})};ye.prototype.toString=function(){return"Atomic"+ye.r.toString.call(this)};function ze(a,b,c){this.d=a;this.b=b;this.a=c;this.c=null}l=ze.prototype;l.logger=G("ydn.db.tr.DbOperator");l.pc=function(){return this.a.d};l.abort=function(){this.a.abort()};function W(a){a.c||(a.c=a.d.l());return a.c}l.j=function(){return this.d};
function Ae(a,b){var c=a.j(),d=b instanceof Be?b:Ce(b),e=b.name,f=X(c.a,e);if(0==De(d,f).length)Eb(!1);else if(f=f?"update":"add",c.a instanceof Ee)Fe(c.a,d),c.b?(c.b.close(),c.b=null,Ge(c)):Eb(!1);else throw new He("Cannot "+f+" store: "+e+". Not auto schema generation mode.");}l.toString=function(){return"TxStorage:"+this.j().getName()};function Ie(a,b,c){ze.call(this,a,b,c)}z(Ie,ze);l=Ie.prototype;l.logger=G("ydn.db.crud.DbOperator");
l.count=function(a,b,c,d){var e,f,g,h;if(null!=a)if(u(a)){if(t(c)||t(b))throw new C("too many arguments.");f=a;for(var k=0;k<f.length;k++)if(!Je(this.b,f[k]))throw new C('store name "'+f[k]+'" at '+k+" not found.");J(this.logger,"countStores: "+U(f));e=this.a.request("count",f);Q(e,function(){W(this).Ja(e,f)},this)}else if(w(a)){k=X(this.b,a);if(!k)throw new C('store name "'+a+'" not found.');if(t(d)&&!da(d))throw new C('unique value "'+d+'" must be boolean, but found '+typeof d+".");f=[a];if(w(b))if(g=
b,y(c)){var m=Uc(c);if(m)throw new C("invalid key range: "+Ke(c)+" "+m);h=Rc(c)}else{if(null!=c)throw new C("invalid key range: "+Ke(c)+" of type "+typeof c);h=null}else if(y(b)||null==b)if(y(b)){if(m=Uc(b))throw new C("invalid key range: "+Ke(b)+" "+m);h=Rc(b)}else{if(null!=b)throw new C("key range must be an object but found "+Ke(b)+" of type "+typeof b);h=null}else throw new C('invalid second argument for count "'+Ke(c)+'" of type '+typeof b);J(this.logger,"countKeyRange: "+a+" "+(g?g:"")+U(h));
e=this.a.request("count",f);Ne(k,e,arguments);Q(e,function(){W(this).ua(e,f[0],h,g,!!d)},this)}else throw new C("Invalid store name or store names.");else H(this.logger,"count method requires store name(s)"),k=Oe(this.b),e=this.a.request("count",k),Md(e,function(a,b,c){if(b)c(a,!0);else{for(var d=b=0;d<a.length;d++)b+=a[d];c(b,!1)}},this),Q(e,function(){W(this).Ja(e,f)},this);return e};
l.get=function(a,b){var c=this,d;if(a instanceof le){var e=a,f=e.m,g=X(this.b,f);if(!g){if(this.b.a()){if(xe(this.j()))return Nd("get",void 0);d=new O("get");this.j().Ta(function(){yb(c.get(a,b),function(a){d.callback(a)},function(a){d.k(a)})});return d}throw new C("Store: "+f+" not found.");}var h=e.id;J(this.logger,"getByKey: "+f+":"+h);d=this.a.request("get:key",[f]);Ne(g,d,arguments,void 0,this);Q(d,function(){W(this).Na(d,f,h)},this)}else if(w(a)&&t(b)){var k=a,g=X(this.b,k);if(!g){if(this.b.a()){if(xe(this.j()))return Nd("get",
void 0);d=new O("get");this.j().Ta(function(){yb(c.get(a,b),function(a){d.callback(a)},function(a){d.k(a)})});return d}throw new C('Store name "'+k+'" not found.');}var m=b;J(this.logger,"getById: "+k+":"+m);d=this.a.request("get",[k]);Ne(g,d,arguments,void 0,this);Q(d,function(){W(this).Na(d,k,m)},this)}else throw new C("get require valid input arguments.");return d};
l.keys=function(a,b,c,d,e,f,g){var h,k,m=null,n=!1,q=!1,p=a,r=X(this.b,p);if(!w(p))throw new C("store name must be a string, but "+p+" of type "+typeof p+" is not.");if(!this.b.a()){if(!r)throw new C('store name "'+p+'" not found.');if(w(b)&&!vd(r,b))throw new C('index "'+b+'" not found in store "'+p+'".');}if(this.b.a()&&!r)return Nd("keys",[]);var x;if(w(b)){var A=b,E=Uc(c);if(E)throw new C("invalid key range: "+c+" "+E);m=Rc(c);if(ea(d))h=d;else{if(t(d))throw new C("limit must be a number");h=
100}if(ea(e))k=e;else{if(t(e))throw new C("offset must be a number");k=0}if(t(f))if(da(f))n=f;else throw new C("reverse must be a boolean");if(t(g))if(da(g))q=g;else throw new C("unique must be a boolean");J(this.logger,"keysByIndexKeyRange: "+p);x=this.a.request("keys:iter:index",[p]);Ne(r,x,arguments);Q(x,function(){W(this).R(x,2,p,A,m,h,k,n,q)},this)}else{if(y(b)){if(E=Uc(b))throw new C("invalid key range: "+Ke(b)+" "+E);m=Rc(b)}else{if(null!=b)throw new C("invalid key range: "+Ke(b)+" of type "+
typeof b);m=null}if(ea(c))h=c;else{if(t(c))throw new C("limit must be a number");h=100}if(ea(d))k=d;else{if(t(d))throw new C("offset must be a number");k=0}if(t(e))if(da(e))n=e;else throw new C("reverse must be a boolean");J(this.logger,"keysByKeyRange: "+p);x=this.a.request("keys",[p]);Ne(r,x,arguments);Q(x,function(){W(this).R(x,2,p,null,m,h,k,n,!1)},this)}return x};
l.w=function(a,b,c,d,e,f,g){var h=this,k,m,n,q=!1,p=!1;if(w(a)){var r=a,x=X(this.b,r);if(!x){if(this.b.a()){if(xe(this.j()))return Nd("values",[]);k=new O("values");this.j().Ta(function(){yb(h.w(a,b,c,d,e,f),function(a){k.callback(a)},function(a){k.k(a)})});return k}throw new ge(r);}if(u(b)){if(t(c)||t(d))throw new C("too many input arguments");var A=b;J(this.logger,"listByIds: "+r+" "+A.length+" ids");k=this.a.request("values:array",[r]);Ne(x,k,arguments,void 0,this);Q(k,function(){W(this).ob(k,
r,A)},this)}else if(w(b)){var E=b;if(!Pe(x,E))throw new C('index "'+E+'" not found in store "'+r+'"');var D=Uc(c);if(D)throw new C("invalid key range: "+c+" "+D);var F=Rc(c);if(t(d))if(ea(d))m=d;else throw new C("limit must be a number.");else m=100;if(t(e))if(ea(e))n=e;else throw new C("offset must be a number.");else n=0;if(da(f))q=f;else if(t(f))throw new C("reverse must be a boolean, but "+f);if(t(g))if(da(g))p=g;else throw new C("unique must be a boolean");J(this.logger,"listByIndexKeyRange: "+
r+":"+E);k=this.a.request("values:iter:index",[r]);Ne(x,k,arguments);Q(k,function(){W(this).R(k,4,r,E,F,m,n,q,p)},this)}else{F=null;if(y(b)){if(D=Uc(b))throw new C("invalid key range: "+b+" "+D);F=Rc(b)}else if(null!=b)throw new C('expect key range object, but found "'+Ke(b)+'" of type '+typeof b);if(t(c))if(ea(c))m=c;else throw new C("limit must be a number, but "+c+" is "+typeof c);else m=100;if(t(d))if(ea(d))n=d;else throw new C("offset must be a number, but "+d+" is "+typeof d);else n=0;if(t(e))if(da(e))q=
e;else throw new C("reverse must be a boolean, but "+e+" is "+typeof e);J(this.logger,(F?"listByKeyRange: ":"listByStore: ")+r);k=this.a.request("values",[r]);Ne(x,k,arguments);Q(k,function(){W(this).R(k,4,r,null,F,m,n,q,!1)},this)}}else if(u(a))if(a[0]instanceof le){for(var x=[],R=a,D=0;D<R.length;D++){var V=R[D].m;if(!Je(this.b,V)){if(this.b.a())return x=[],x[R.length-1]=void 0,Nd("get",x);throw new C("Store: "+V+" not found.");}0<=jb(x,V)||x.push(V)}J(this.logger,"listByKeys: "+U(x)+" "+R.length+
" keys");k=this.a.request("values:keys",x);Q(k,function(){W(this).pb(k,R)},this)}else throw new C("first argumentmust be array of ydn.db.Key, but "+a[0]+" of "+typeof a[0]+" found.");else throw new C("first argument "+a+" is invalid.");return k};
l.add=function(a,b,c){var d=w(a)?a:y(a)?a.name:void 0;if(!w(d))throw new C("store name "+d+" must be a string, but "+typeof d);var e=X(this.b,d);if(!e){if(!this.b.a())throw new C('store name "'+d+'" not found.');e=Ce(y(a)?a:{name:d});J(this.logger,"Adding object store: "+d);Ae(this,e)}else if(this.b.a()&&y(a)&&(a=Ce(a),a=De(e,a)))throw new Gb(a);var f;if(!e)throw new C('store name "'+d+'" not found.');if(w(e.keyPath)&&t(c))throw new C("key must not be provided while the store uses in-line key.");
if(!e.keyPath&&!e.b&&!t(c))throw new C("out-of-line key must be provided.");if(u(b)){J(this.logger,"addObjects: "+d+" "+b.length+" objects");for(a=0;a<b.length;a++)Qe(e,b[a]);f=this.a.request("add:array",[d],M);Q(f,function(){W(this).S(f,!1,!1,d,b,c)},this);e.da&&f.C(function(a){a=new Re(Se,this.j(),e.getName(),a,b);this.j().H(a)},this)}else if(y(b))a="store: "+d+" key: "+Te(e,b,c),J(this.logger,"addObject: "+a),Qe(e,b),f=this.a.request("add",[d],M),Q(f,function(){W(this).S(f,!1,!0,d,[b],[c])},this),
e.da&&f.C(function(a){a=new Ue(Se,this.j(),e.getName(),a,b);this.j().H(a)},this);else throw new C("record must be an object or array list of objects, but "+b+" of type "+typeof b+" found.");return f};
function Ve(a,b){var c=w(b)?b:y(b)?b.name:void 0;if(!w(c))throw new C("store name must be a string");var d=X(a.b,c);if(!d){if(!a.b.a())throw new ge(c);d=Ce(y(b)?b:{name:c});J(a.logger,"Adding object store: "+c);Ae(a,d)}else if(a.b.a()&&y(b)){var e=Ce(b);if(e=De(d,e))throw new Gb(e);}if(!d)throw new ge(c);return d}l.load=function(a,b,c){var d=c||",",e=Ve(this,a).getName();a=this.a.request("load",[e]);var f=this;this.a.W(a,function(a,c,k){W(f).tb(a,c,k,e,b,d)},[e],M);return a};
l.put=function(a,b,c){var d,e=this;if(a instanceof le){var f=a,g=f.m,h=X(this.b,g);if(!h)throw new C('store "'+g+'" not found.');if(h.keyPath){var k=Te(h,b);if(null!=k){if(0!=L(k,f.id))throw new C("Inline key must be "+f+" but "+k+" found.");}else We(h,b,f.id);return this.put(g,b)}return this.put(g,b,f.id)}if(u(a)){if(t(c))throw new C("too many arguments");var m=a;if(!t(b))throw new C("record values required");for(var n=b,f=[],g=0,h=m.length;g<h;g++){k=m[g].m;-1==jb(f,k)&&f.push(k);var q=X(this.b,
k);if(!q)throw new C('store "'+k+'" not found.');q.keyPath&&We(q,n[g],m[g].id)}J(this.logger,"putByKeys: to "+U(f)+" "+n.length+" objects");for(g=0;g<n.length;g++)Qe(q,n[g]);d=this.a.request("put:keys",f,M);Ne(q,d,arguments);Q(d,function(){W(e).sb(d,n,m)},this)}else if(w(a)||y(a)){var q=Ve(this,a),p=q.getName();if(q.keyPath&&t(c))throw new C("key must not be provided while the store uses in-line key.");if(!q.keyPath&&!q.b&&!t(c))throw new C("out-of-line key must be provided.");if(u(b)){var r=b,x=
c;J(this.logger,"putObjects: "+p+" "+r.length+" objects");for(g=0;g<r.length;g++)Qe(q,r[g]);d=this.a.request("put:array",[p],M);Ne(q,d,arguments);Q(d,function(){W(this).S(d,!0,!1,p,r,x)},this);q.da&&d.C(function(a){a=new Re(Xe,this.j(),p,a,r);this.j().H(a)},this)}else if(y(b)){var A=b,E=c;J(this.logger,"putObject: "+p+" "+(t(E)?E:"(without-key)"));if(t(s.Blob)&&A instanceof Blob&&q.ka&&!q.keyPath&&0==q.a.length&&ec)d=new O("put"),f=new FileReader,f.onload=function(a){var b=a.target.result,c=e.a.request("put",
[p],M);Ne(q,c,[p,A,E]);Q(c,function(){W(e).S(c,!0,!0,p,[b],[E])},this);yb(c,function(a){d.callback(a)},function(a){d.k(a)})},f.onerror=function(a){d.k(a)},f.onabort=function(a){d.k(a)},f.readAsDataURL(A);else{Qe(q,A);d=this.a.request("put",[p],M);var D=[p,A,E];Ne(q,d,D);Q(d,function(){var a=t(E)?[D[2]]:void 0;W(e).S(d,!0,!0,p,[D[1]],a)},this)}q.da&&d.C(function(a){a=new Ue(Xe,this.j(),p,a,A);this.j().H(a)},this)}else throw new C("put record value must be Object or array of Objects");}else throw new C("the first argument of put must be store name, store schema or array of keys.");
return d};
l.clear=function(a,b,c){if(t(c))throw new C("too many input arguments");var d;if(w(a)){c=X(this.b,a);if(!c)throw new C('store name "'+a+'" not found.');if(y(b)){var e=Rc(b);if(null===e)throw new C("clear method requires a valid non-null KeyRange object.");J(this.logger,"clearByKeyRange: "+a+":"+U(e));d=this.a.request("clear",[a],M);Ne(c,d,[a,e]);Q(d,function(){W(this).hb(d,a,e)},this)}else{if(t(b))throw new C("clear method requires a valid KeyRange object as second argument, but found "+b+" of type "+
typeof b);J(this.logger,"clearByStore: "+a);d=this.a.request("clear",[a],M);Q(d,function(){W(this).Ha(d,[a])},this)}}else if(!t(a)||u(a)&&w(a[0])){var f=a||Oe(this.b);J(this.logger,"clearByStores: "+U(f));d=this.a.request("clear",f,M);Q(d,function(){W(this).Ha(d,f)},this)}else throw new C('first argument "'+a+'" is invalid.');return d};
l.fb=function(a,b,c){var d;if(w(a)){var e=X(this.b,a);if(!e)throw new C('store name "'+a+'" not found.');if(t(c))if(w(b)){var f=vd(e,b);if(!f)throw new C("index: "+b+" not found in "+a);if(y(c)||null===c){var g=Rc(c);J(this.logger,"removeByIndexKeyRange: "+a+":"+f.getName()+" "+a);d=this.a.request("rm:iter:index",[a],M);Q(d,function(){W(this).ub(d,a,f.getName(),g)},this)}else throw new C("key range "+c+' is invalid type "'+typeof c+'".');}else throw new C('index name "'+b+'" must be a string, but '+
typeof b+" found.");else if(w(b)||ea(b)||v(b)||b instanceof Date){J(this.logger,"removeById: "+a+":"+b);d=this.a.request("rm",[a],M);var h=[a,b];Ne(e,d,h);Q(d,function(){W(this).Wa(d,a,h[1])},this);e.da&&d.C(function(c){c=1==c?b:void 0;c=new Ue(Ye,this.j(),a,c,void 0);this.j().H(c)},this)}else if(y(b))g=Rc(b),J(this.logger,"removeByKeyRange: "+a+":"+U(g)),d=this.a.request("rm:iter",[a],M),Ne(e,d,[a,g]),Q(d,function(){W(this).Xa(d,a,g)},this),e.da&&d.C(function(b){var c=[];c.length=b;b=new Re(Ye,this.j(),
a,c,void 0);this.j().H(b)},this);else throw new C('Invalid key or key range "'+b+'" of type '+typeof b);}else if(a instanceof le){var k=a.m,e=X(this.b,k);d=this.a.request("rm",[k],M);var m=[k,a.id];Ne(e,d,m);Q(d,function(){W(this).Wa(d,k,m[1])},this)}else if(u(a)){c=[];for(var e=0,n=a.length;e<n;e++){if(!(a[e]instanceof le))throw new C("key list element at "+e+" of "+n+' must be yn.db.Key, but "'+Ke(a[e])+'" ('+ca(a[e])+") is not ydn.db.Key.");var q=a[e].m;-1==jb(c,q)&&c.push(q)}if(1>c.length)throw new C('at least one valid key required in key list "'+
Ke(a)+'"');d=this.a.request("rm:keys",c,M);Q(d,function(){W(this).vb(d,a)},this)}else throw new C('first argument requires store name, key (ydn.db.Key) or list of keys (array) , but "'+Ke(a)+'" ('+ca(a)+") found.");return d};l.toString=function(){return"DbOperator:"+this.j().getName()};function Ze(a,b,c){ze.call(this,a,b,c)}z(Ze,Ie);l=Ze.prototype;l.logger=G("ydn.db.core.DbOperator");l.get=function(a,b){if(a instanceof N){var c=a.c,d=X(this.b,c);if(!d)throw new C('store "'+c+'" not found.');var e=a.d;if(t(e)&&!Pe(d,e))throw new C('index "'+e+'" not found in store "'+c+'".');J(this.logger,"getByIterator:"+a);var f=this.a.request("get:iter",[c]);Q(f,function(){$e(this,5,f,a,1)},this);return f}return Ze.r.get.call(this,a,b)};
l.keys=function(a,b,c,d,e,f,g){if(a instanceof N){var h=100;if(ea(b)){if(h=b,1>h)throw new C("limit must be a positive value, but "+b);}else if(t(b))throw new C("limit must be a number, but "+b);if(t(c))throw new C("offset must not be specified");J(this.logger,"keysByIterator:"+a);var k=this.a.request("keys:iter",[a.c]);Q(k,function(){a.i?$e(this,1,k,a,h):$e(this,2,k,a,h)},this);return k}return Ze.r.keys.call(this,a,b,c,d,e,f,g)};
l.count=function(a,b,c,d){if(a instanceof N){if(t(b)||t(c))throw new C("too many arguments.");J(this.logger,"countIterator:"+a);var e=this.a.request("count",[a.c]);Q(e,function(){$e(this,6,e,a)},this);return e}return Ze.r.count.call(this,a,b,c,d)};
l.w=function(a,b,c,d,e,f){if(a instanceof N){var g;if(ea(b)){if(g=b,1>g)throw new C("limit must be a positive value, but "+g);}else if(t(b))throw new C("limit must be a number, but "+b);if(t(c))throw new C("offset must not be specified");J(this.logger,"listByIterator:"+a);var h=this.a.request("values:iter",[a.c]);Q(h,function(){a.a?$e(this,2,h,a,g):$e(this,4,h,a,g)},this);return h}return Ze.r.w.call(this,a,b,c,d,e,f)};
l.Ab=function(a,b,c){if(!u(b))throw new C("iterators argument must be an array, but "+b+" of type "+typeof b+" found");for(var d=0;d<b.length;d++)if(!(b[d]instanceof N))throw new C("Iterator at "+d+" must be cursor range iterator.");c=c||nd;for(var e=[],d=0;d<b.length;d++)for(var f=b[d].stores(),g=0;g<f.length;g++)0<=jb(e,f[g])||e.push(f[g]);J(this.logger,this+": scan for "+b.length+" iterators on "+e);var h=this,d=this.a.request("scan",e);this.a.W(d,function(c,d,e){function f(){for(var a=0,e=0;e<
b.length;e++){var n=b[e],q=[W(h).b(c,d,n.c)],n=n.load(q);n.l=g;n.i=la(r,a);V[e]=n;D[a]=e;a++}E=b.length}function g(a){for(var b=0;b<V.length;b++)zd(V[b]);pb(V);J(h.logger,x+" error");e(a,!0)}function r(c,d){if(A)throw new Ud;aa++;var f=aa===E,g=D[c],k=b[g],m=V[g],g=m.B(),m=m.aa();F[c]=d;R[c]=k.i?k.a?g:m:k.a?d:m;if(f){var q;a instanceof $d?q=a.c(F,R):q=a(F,R);f=[];k=[];g=[];m=[];if(u(q))for(var p=0;p<q.length;p++)!0===q[p]?g[p]=1:!1===q[p]?m[p]=!0:k[p]=q[p];else if(null===q)f=[];else if(t(q))if(y(q)){f=
["advance","continue","continuePrimary","restart"];for(p in q)if(!(0<=jb(f,p)))throw new Ib('Unknown attribute "'+p+'" in cursor advancement object');f=q.continuePrimary||[];k=q["continue"]||[];g=q.advance||[];m=q.restart||[]}else throw new Ib("scan callback output");else for(f=[],p=0;p<b.length;p++)t(D[p])&&(g[p]=1);for(p=aa=q=0;p<b.length;p++)null!=f[p]||t(k[p])||null!=m[p]||null!=g[p]||aa++;for(p=0;p<b.length;p++)if(null!=f[p]||t(k[p])||null!=m[p]||null!=g[p]){var r=D[p];if(!t(r))throw new af(p+
" is not an iterator.");var r=b[r],Lb=V[p];if(null==F[p]){var Me=p+"/"+b.length;if(null!=g[p])throw new Yd(Lb+" "+Me+" must not advance "+g[p]+" steps");if(t(k[p]))throw new Yd(Lb+" "+Me+" must not continue to key "+k[p]);if(null!=f[p])throw new Yd(Lb+" "+Me+" must not continue to primary key "+f[p]);}F[p]=void 0;R[p]=void 0;if(null!=m[p])Ad(Lb);else if(t(k[p]))Lb.ja(k[p]);else if(null!=f[p])Lb.Da(f[p]);else if(null!=g[p])Lb.advance(1);else throw new Ud(r+": has no action");q++}if(0==q){for(q=0;q<
V.length;q++)zd(V[q]);A=!0;pb(V);J(h.logger,"success "+x);e(void 0)}}}var x=d+" "+h+" scanning";I(h.logger,x);var A=!1,E,D=[],F=[],R=[],V=[],aa=0;a instanceof $d?a.e(c,b,function(){f()})||f():f()},e,c);return d};
l.open=function(a,b,c,d){if(!(b instanceof N))throw new C("Second argument must be cursor range iterator.");for(var e=b.stores(),f=0;f<e.length;f++)if(!X(this.b,e[f]))throw new C('Store "'+e[f]+'" not found.');c=c||nd;var g=this,h=this.a.request("open",b.stores(),c);J(this.logger,"open:"+c+" "+b);Q(h,function(c){var e=S(h);J(g.logger,e+" iterating "+b);for(var f=b.stores(),q=[],p=0;p<f.length;p++)q[p]=W(g).b(c,e,f[p]);var r=b.load(q);r.l=function(a){P(h,a,!0)};r.i=function(b){null!=b?(b=a.call(d,
r),!0===b?Ad(r):y(b)?!0===b.restart?Ad(r,b["continue"],b.continuePrimary):null!=b["continue"]?r.ja(b["continue"]):null!=b.continuePrimary?r.Da(b.continuePrimary):(zd(r),P(h,void 0)):null===b?(zd(r),P(h,void 0)):null!=b?r.ja(b):r.advance(1)):(zd(r),P(h,void 0))}},this);return h};
l.map=function(a,b){for(var c=this,d=a.stores(),e,f=0;e=d[f];f++)if(!e)throw new C('Store "'+e+'" not found.');e=this.a.request("map",d);I(this.logger,"map:"+a);this.a.W(e,function(d,e,f){I(c.logger,e+" iterating "+a);for(var m=a.stores(),n=[],q=0;q<m.length;q++)n[q]=W(c).b(d,e,m[q]);var p=a.load(n);p.l=function(a){f(a,!1)};p.i=function(c){if(null!=c){var d;a.i?a.a?d=c:d=p.B():a.a?d=c:d=p.aa();b(d);p.advance(1)}else f(void 0),b=null}},d,nd);return e};
l.eb=function(a,b,c){for(var d=this,e=a.stores(),f,g=0;f=e[g];g++)if(!f)throw new C('Store "'+f+'" not found.');f=this.a.request("reduce",e);var h=y(c)?bf(U(c)):c;J(this.logger,"reduce:"+a);this.a.W(f,function(c,e,f){for(var g=a.stores(),p=[],r=0;r<g.length;r++)p[r]=W(d).b(c,e,g[r]);var x=a.load(p);x.l=function(a){f(a,!0)};var A=0;x.i=function(c){if(null!=c){var d;a.i?a.a?d=c:d=x.B():a.a?d=c:d=x.aa();h=b(h,d,A++);x.advance(1)}else f(h)}},e,nd);return f};
function cf(a,b,c,d){var e=c.c,f=c.d||null,g=d||100;J(a.logger,"listIter:"+b+" "+c+(d?" limit="+g:"")+"");var h=a.a.request("values:iter:index",[e]),k="done"==c.f||c.f==Dd?[]:[c.g,c.h];Q(h,function(){W(this).R(h,b,e,f,c.Nb(),g,0,c.V(),c.qa(),k)},a);h.C(function(){null!=k[0]?c.wb("rest",k[0],k[1]):c.wb()});return h}
function $e(a,b,c,d,e){var f=[],g=c.a,h=S(c),k=h+" "+b+"ByIterator "+d;0<e&&(k+=" limit "+e);J(a.logger,k);for(var m=W(a),n=[],q=d.stores(),p=0;p<q.length;p++)n[p]=m.b(g,h,q[p]);var r=d.load(n);r.l=function(a){zd(r);P(c,a,!0)};var x=0,A=!1;r.i=function(d){A||(I(a.logger,k+" starting"),A=!0);null!=d?(r.B(),x++,1==b?f.push(d):2==b?f.push(r.B()):3==b?f.push([d,r.B()]):6!=b&&f.push(r.aa()),5==b?(zd(r),P(c,f[0])):6==b||!t(e)||x<e?r.ja():(J(a.logger,"success:"+k+" yields "+f.length+" records"),zd(r),P(c,
f))):(J(a.logger,"success:"+k+" yields "+f.length+" records"),zd(r),P(c,5==b?f[0]:6==b?x:f))}};function df(a,b){this.type=a;this.a=this.target=b;this.Kb=!0}df.prototype.kb=function(){};df.prototype.preventDefault=function(){this.Kb=!1};var Se="created",Ye="deleted",Xe="updated";function ef(a,b){df.call(this,a,b)}z(ef,df);ef.prototype.b=function(){return this.m};function ff(a,b,c,d,e){df.call(this,a,b);this.version=c;this.Pb=d;this.Jb=e}z(ff,ef);l=ff.prototype;l.name="ReadyEvent";l.version=NaN;l.Pb=NaN;l.Jb=null;l.oc=function(){return this.version};l.Vb=function(){return this.Pb};l.Ub=function(){return this.Jb};function gf(a,b,c){df.call(this,c||"error",a);this.error=b}z(gf,ef);
gf.prototype.toString=function(){return this.name+":"+(this.error?this.error:"")};gf.prototype.name="ErrorEvent";gf.prototype.error=null;gf.prototype.c=function(){return this.error};function hf(a,b){gf.call(this,a,b,"fail")}z(hf,gf);hf.prototype.name="FailEvent";function Ue(a,b,c,d,e){df.call(this,a,b);this.m=c;this.key=d;this.value=e}z(Ue,ef);Ue.prototype.name="RecordEvent";Ue.prototype.c=function(){return this.key};Ue.prototype.d=function(){return this.value};
function Re(a,b,c,d,e){df.call(this,a,b);this.m=c;this.keys=d;this.w=e}z(Re,ef);Re.prototype.name="StoreEvent";Re.prototype.fa=function(){return this.keys};Re.prototype.Oa=function(){return this.w};function jf(a,b,c,d,e,f){t(e)||(e=u(a)?a.join(", "):a);if(null!=a&&!w(a)&&!v(a))throw new C("index keyPath for "+e+" must be a string or array, but "+a+" is "+typeof a);u(a)&&Object.freeze&&Object.freeze(a);!t(a)&&t(e)&&(a=e);this.keyPath=a;this.e=v(this.keyPath);this.b=e;this.type=kf(b);if(t(b)){if(!t(this.type))throw new C("type invalid in index: "+this.b);if(u(this.keyPath))throw new C('composite key for store "'+this.b+'" must not specified type');}this.unique=!!c;this.multiEntry=!!d;this.g=w(this.type)?
this.type:lf;this.d=w(e)?e:u(a)?this.keyPath.join(","):a;this.c=Ha(this.d);this.a=this.e?null:this.keyPath.split(".");this.f=f||null}function mf(a,b){if(null!=b){if(v(a.keyPath)){for(var c=[],d=0,e=a.keyPath.length;d<e;d++){var f=Zc(b,a.keyPath[d]);c[d]=f}return c}return Zc(b,a.keyPath)}}function nf(a,b,c){for(var d=0;d<a.a.length;d++)d==a.a.length-1?b[a.a[d]]=c:y(b[a.a[d]])||(b[a.a[d]]={})}var lf="TEXT";function Xc(a,b){if("DATE"==b){if(a instanceof Date)return+a}else return null!=b?a:bd(a)}
function of(a,b){return"DATE"==b?new Date(a):t(b)?a:ed(a)}var pf=["BLOB","DATE","INTEGER","NUMERIC",lf];function kf(a){if(w(a))return a=jb(pf,a),pf[a]}l=jf.prototype;l.getName=function(){return this.b};l.toJSON=function(){return{name:this.b,keyPath:this.keyPath,type:this.type,unique:this.unique,multiEntry:this.multiEntry}};l.clone=function(){var a=u(this.keyPath)?sb(this.keyPath):this.keyPath;return new jf(a,this.type,this.unique,this.multiEntry,this.b,this.f)};
function qf(a,b){return null!=a||null!=b?null!=a?null!=b?v(a)&&v(b)?tb(a,b)?null:"expect: "+a+", but: "+b:rf(a,b)?null:"expect: "+a+", but: "+b:"keyPath: "+a+" no longer defined":"newly define "+b:null}l.hint=function(a){if(!a)return this;var b=u(this.keyPath)?sb(this.keyPath):this.keyPath,c=this.type;t(a.type)||"TEXT"!=c||(c=void 0);return new jf(b,c,this.unique,this.multiEntry,a.b)};
l.toString=function(){var a=this.multiEntry?"MultiEntry":"";this.a&&1<this.a.length&&(a+="Compound");return a+"Index:"+this.b};function Be(a,b,c,d,e,f,g,h){this.c=a;if(!w(this.c))throw new C("store name must be a string");this.keyPath=t(b)?b:null;this.g=v(this.keyPath);if(null!==this.keyPath&&!w(this.keyPath)&&!this.g)throw new C("keyPath must be a string or array");this.b=c;var k;if(null!=d){k=kf(d);if(!t(k))throw new C('type "'+d+'" for primary key in store "'+this.c+'" is invalid.');if(this.g)throw new C('composite key for store "'+this.c+'" must not specified type');}this.type=null!=k?k:this.b?"INTEGER":void 0;this.e=
w(this.keyPath)?this.keyPath.split("."):[];this.a=e||[];this.da=!!f;this.ka=!!g;this.l=w(this.type)?this.type:lf;this.f=u(this.keyPath)?this.keyPath.join(","):w(this.keyPath)?this.keyPath:"_ROWID_";this.d=Ha(this.f);if(this.i=!!h){if(this.keyPath)throw new C('encrypted store "'+this.c+'" must not use inline key');if(this.b)throw new C('encrypted store "'+this.c+'" must not use key generator');}this.h=[]}l=Be.prototype;l.da=!1;l.ka=!1;
l.toJSON=function(){for(var a=[],b=0;b<this.a.length;b++)a.push(this.a[b].toJSON());return{name:this.c,keyPath:this.keyPath,autoIncrement:this.b,type:this.type,indexes:a}};
function Ce(a){var b="name keyPath autoIncrement type indexes dispatchEvents fixed Sync encrypted".split(" "),c;for(c in a)if(a.hasOwnProperty(c)&&-1==jb(b,c))throw new C('Unknown attribute "'+c+'"');b=[];c=a.indexes||[];if(u(c))for(var d=0;d<c.length;d++){var e;e=c[d];var f="name unique type keyPath multiEntry generator".split(" "),g=void 0;for(g in e)if(e.hasOwnProperty(g)&&-1==jb(f,g))throw new C("Unknown field: "+g+" in "+U(e));e=new jf(e.keyPath,e.type,e.unique,e.multiEntry,e.name,e.generator);
t(e.keyPath)&&e.keyPath===a.keyPath||b.push(e)}return new Be(a.name,a.keyPath,a.autoIncrement,"undefined"===a.type||"null"===a.type?void 0:a.type,b,a.dispatchEvents,a.fixed,a.encrypted)}function sf(a,b,c,d,e,f,g){a=tf(a,b,c,d,e,f,g);b="";0!=c&&(b+="SELECT "+a.select);b+=" FROM "+a.M;a.n&&(b+=" WHERE "+a.n);a.group&&(b+=" GROUP BY "+a.group);a.P&&(b+=" ORDER BY "+a.P);return b}
function tf(a,b,c,d,e,f,g){var h={select:"",M:"",n:"",group:"",P:""},k=a.f,m=a.d,n=null;d!==k&&w(d)&&(n=vd(a,d));var q=!!n,p=d||k,r=Ha(p),x=q?n.type:a.type,A=q&&n.multiEntry;h.M=uf(a);6===c?h.select="COUNT("+m+")":3===c||1===c||2===c?(h.select=m,null!=d&&d!=k&&(h.select+=", "+r)):h.select="*";d=g?"DISTINCT ":"";k=[];A?(A=Ha("ydn.db.me:"+a.getName()+":"+n.getName()),h.select=6===c?"COUNT("+d+A+"."+r+")":3===c||1===c||2===c?"DISTINCT "+uf(a)+"."+m+", "+A+"."+r+" AS "+p:"DISTINCT "+uf(a)+".*, "+A+"."+
r+" AS "+p,h.M=A+" INNER JOIN "+uf(a)+" USING ("+m+")",null!=e&&(Wc(A+"."+r,x,e,k,b),0<k.length&&(h.n=h.n?h.n+(" AND "+k.join(" AND ")):k.join(" AND ")))):null!=e&&(Wc(r,x,e,k,b),0<k.length&&(h.n=h.n?h.n+(" AND "+k.join(" AND ")):k.join(" AND ")));q&&!n.unique&&g&&(h.group=r);a=f?"DESC":"ASC";h.P=r+" "+a;q&&(h.P+=", "+m+" "+a);return h}
function vf(a,b,c,d,e,f,g,h,k){var m,n,q,p;null!=e?(m=e.lower,n=e.upper,q=e.lowerOpen,p=e.upperOpen,f?null!=n?(e=L(h,n),-1==e?(n=h,p=k):0==e&&(p=k||p)):(n=h,p=k):null!=m?(e=L(h,m),1==e?(m=h,q=k):0==e&&(q=k||q)):(m=h,q=k)):f?(n=h,p=k):(m=h,q=k);e=new K(m,n,!!q,!!p);d=d?vd(a,d):null;b=tf(a,c,b,d?d.d:a.f,e,f,g);b="SELECT "+b.select+" FROM "+b.M+(b.n?" WHERE "+b.n:"")+(b.group?" GROUP BY "+b.group:"")+" ORDER BY "+b.P;d&&(b+=", "+a.d+(f?"DESC":"ASC"));return b}
function wf(a,b,c,d,e,f,g,h,k,m){var n=vd(a,d),q=n.d;d=n.c;var p=a.d,r=k?" <":" >",r=g?r+" ":r+"= ";g=Xc(f,n.type);h=Xc(h,a.type);n="";e?(a=tf(a,c,b,q,e,k,m),a.n+=" AND ",n=d+r+"?",c.push(g)):(e=k?K.upperBound(f,!0):K.lowerBound(f,!0),a=tf(a,c,b,q,e,k,m),n=a.n,a.n="");a.n+="("+n+" OR ("+d+" = ? AND "+p+r+"?))";c.push(g);c.push(h);return"SELECT "+a.select+" FROM "+a.M+" WHERE "+a.n+(a.group?" GROUP BY "+a.group:"")+" ORDER BY "+a.P}l.clone=function(){return Ce(this.toJSON())};
l.index=function(a){return this.a[a]||null};function vd(a,b){return nb(a.a,function(a){return a.getName()==b})}function ud(a,b){for(var c=0;c<a.a.length;c++)if(!qf(a.a[c].keyPath,b))return a.a[c];return null}function Pe(a,b){return b===a.keyPath?!0:mb(a.a,function(a){return a.getName()==b})}function uf(a){return Ha(a.c)}
function xf(a,b){if(!b)return a;var c=a.b,d=u(a.keyPath)?sb(a.keyPath):a.keyPath,e=a.type,f=lb(a.a,function(a){return a.clone()});t(b.type)||"TEXT"!=e||(e=void 0);u(b.keyPath)&&w(d)&&d==b.keyPath.join(",")&&(d=sb(b.keyPath));for(var g=0,h=b.a.length;g<h;g++)if(b.a[g].e)for(var k=b.a[g].getName(),m=f.length-1;0<=m;m--)if(0<=k.indexOf(f[m].getName())){f[m]=b.a[g].clone();break}for(g=0;g<f.length;g++)(h=vd(b,f[g].getName()))&&(f[g]=f[g].hint(h));return new Be(b.c,d,c,e,f)}l.getName=function(){return this.c};
function yf(a){return!!a.keyPath}function Te(a,b,c){if(b){if(!a.keyPath&&null!=c)return c;if(a.g){c=[];for(var d=0;d<a.keyPath.length;d++)c.push(Zc(b,a.keyPath[d]));return c}if(a.keyPath)return Nb(b,a.e)}}function We(a,b,c){for(var d=0;d<a.e.length;d++){var e=a.e[d];if(d==a.e.length-1){b[e]=c;break}t(b[e])||(b[e]={});b=b[e]}}
function zf(a,b,c){var d=[],e=[];c=t(c)?c:Te(a,b);t(c)&&(e.push(a.d),d.push(Xc(c,a.type)));for(var f=0;f<a.a.length;f++){var g=a.a[f];if(!g.multiEntry&&g.getName()!==a.keyPath&&"_default_"!=g.getName()){var h=mf(g,b);null!=h&&(d.push(Xc(h,g.type)),e.push(g.c))}}a.ka?a.ka&&!a.keyPath&&0==a.a.length&&(w(b)&&-1==b.indexOf(";base64,")?d.push(b):d.push(U(b)),e.push("_default_")):(d.push(U(b)),e.push("_default_"));a=[];for(f=d.length-1;0<=f;f--)a[f]="?";return{Fb:e,Lb:a,w:d,key:c}}
function De(a,b){if(!b)return"missing store: "+a.c;if(a.c!=b.c)return"store name, expect: "+a.c+", but: "+b.c;var c=qf(a.keyPath,b.keyPath);if(c)return"keyPath, "+c;if(t(a.b)&&t(b.b)&&a.b!=b.b)return"autoIncrement, expect: "+a.b+", but: "+b.b;if(a.a.length!=b.a.length)return"indexes length, expect: "+a.a.length+", but: "+b.a.length;if(t(a.type)&&t(b.type)&&(v(a.type)?!tb(a.type,b.type):a.type!=b.type))return"data type, expect: "+a.type+", but: "+b.type;for(c=0;c<a.a.length;c++){var d=vd(b,a.a[c].getName()),
e;e=a.a[c];if(d)if(e.b!=d.b)e="name, expect: "+e.b+", but: "+d.b;else{var f=qf(e.keyPath,d.keyPath);e=f?"keyPath, "+f:null!=e.unique&&null!=d.unique&&e.unique!=d.unique?"unique, expect: "+e.unique+", but: "+d.unique:null!=e.multiEntry&&null!=d.multiEntry&&e.multiEntry!=d.multiEntry?"multiEntry, expect: "+e.multiEntry+", but: "+d.multiEntry:t(e.type)&&t(d.type)&&(v(e.type)?!tb(e.type,d.type):e.type!=d.type)?"data type, expect: "+e.type+", but: "+d.type:""}else e="no index for "+e.b;if(0<e.length)return'index "'+
a.a[c].getName()+'" '+e}return""}function Qe(a,b){if(b)for(var c=0;c<a.a.length;c++){var d=a.a[c],e=b;if(d.f){var f=d.f(e),g=typeof f;if("string"==g||"number"==g||f instanceof Date||u(f)){for(g=0;g<d.a.length-1;g++)y(e[d.a[g]])||(e[d.a[g]]={});e[d.a[d.a.length-1]]=f}}}}function Ne(a,b,c,d,e){for(var f=0;f<a.h.length;f++)d!==f&&a.h[f].call(e,b,c)}l.toString=function(){return"Store:"+this.c+"["+this.a.length+"index]"};G("ydn");function bf(a){return!w(a)||ta(a)?{}:JSON.parse(a)}function Ke(a){var b;try{b=U(a)}catch(c){b=""}return b?b.substr(0,70)+(70<b.length?"...":""):""}function U(a){return JSON.stringify(a,void 0,void 0)};function Af(a,b){if(!a||ta(a))throw new C("store_name must be provided for primary full text index");if(!b||ta(b))throw new C("index_name must be provided for primary full text index");this.m=a};function Bf(a,b,c){this.name=a;this.a=b;this.b=c||"";if(-1==["","en","fr"].indexOf(this.b))throw new C('Unsupported lang "'+c+" for full text search index "+a);}Bf.prototype.getName=function(){return this.name};Bf.prototype.count=function(){return this.a.length};Bf.prototype.index=function(a){return this.a[a]};
function Cf(a){var b=["name","sources","lang"],c;for(c in a)if(a.hasOwnProperty(c)&&-1==jb(b,c))throw new C("Unknown field: "+c+" in "+U(a));if(!u(a.sources))throw new C("indexes require for full text search index "+a.name+", but "+a.sources+" of type "+typeof a.sources+" found.");b=a.sources.map(function(a){var b=["storeName","keyPath","weight"],c;for(c in a)if(a.hasOwnProperty(c)&&-1==jb(b,c))throw new C("Unknown field: "+c+" in "+Ke(a));return new Af(a.storeName,a.keyPath)});return new Bf(a.name,
b,a.lang)};function Df(a,b){var c,d,e=b;if(y(a)){d=a;c=["version","stores","fullTextCatalogs"];for(var f in d)if(d.hasOwnProperty(f)&&-1==jb(c,f))throw new C("Unknown field: "+f+" in schema.");c=d.version;var e=[],g=d.stores||[];if(!u(g))throw new C("stores must be array");for(f=0;f<g.length;f++){var h=Ce(g[f]);if(-1!=ob(e,function(a){return a.name==h.getName()}))throw new C('duplicate store name "'+h.getName()+'".');e.push(h)}}else w(a)?c=0==a.length?void 0:parseFloat(a):ea(a)&&(c=a);if(t(c)){if(!ea(c)||0>
c)throw new C("Invalid version: "+c+" ("+a+")");isNaN(c)&&(c=void 0)}if(t(b)&&(!u(b)||0<b.length&&!(b[0]instanceof Be)))throw new C("stores");this.version=c;this.b=!t(this.version);this.stores=e||[];c=[];if(d&&d.fullTextCatalogs)for(f=0;f<d.fullTextCatalogs.length;f++)e=Cf(d.fullTextCatalogs[f]),c[f]=e,X(this,e.getName())||(g=[new jf("k",lf),new jf("v",lf)],e=new Be(e.getName(),"id",!1,void 0,g,!1,!1,!1),this.stores.push(e));this.c=c}
Df.prototype.toJSON=function(){var a=lb(this.stores,function(a){return a.toJSON()}),b={};b.stores=a;t(this.version)&&(b.version=this.version);return b};Df.prototype.b=!1;Df.prototype.a=function(){return!1};function Oe(a){return lb(a.stores,function(a){return a.getName()})}Df.prototype.count=function(){return this.stores.length};function X(a,b){return nb(a.stores,function(a){return a.getName()==b})}function Je(a,b){return mb(a.stores,function(a){return a.getName()==b})}
function Ef(a,b,c,d){if(!b||a.stores.length!=b.stores.length)return"Number of store: "+a.stores.length+" vs "+b.stores.length;for(var e=0;e<a.stores.length;e++){var f=X(b,a.stores[e].getName());if(f){c&&(f=xf(f,a.stores[e]));if(d)for(var g=f,h=a.stores[e],k=0;k<h.a.length;k++){var m=h.a[k];Pe(g,m.getName())||"BLOB"!=m.type||(m=new jf(m.keyPath,m.type,m.unique,m.multiEntry,m.getName()),g.a.push(m))}f=De(a.stores[e],f);if(0<f.length)return'store: "'+a.stores[e].getName()+'" '+f}else return'missing object store "'+
a.stores[e].getName()+'"'}return""};function Ee(a,b){Df.call(this,a,b)}z(Ee,Df);Ee.prototype.a=function(){return!0};function Fe(a,b){a.stores.push(b)};function Qd(a){Error.captureStackTrace?Error.captureStackTrace(this,Qd):this.stack=Error().stack||"";a&&(this.message=String(a));this.name="ydn.error.ArgumentException"}z(Qd,Error);function Ff(a){Error.captureStackTrace?Error.captureStackTrace(this,Ff):this.stack=Error().stack||"";a&&(this.message=String(a));this.name="ydn.error.NotSupportedException"}z(Qd,Error);Ff.prototype.name="ydn.error.NotSupportedException";
function Zd(a){Error.captureStackTrace?Error.captureStackTrace(this,Zd):this.stack=Error().stack||"";a&&(this.message=String(a));this.name="ydn.error.NotImplementedException"}z(Zd,Error);function Ud(a){Error.captureStackTrace?Error.captureStackTrace(this,Ud):this.stack=Error().stack||"";a&&(this.message=String(a));this.name="ydn.error.InternalError"}z(Ud,Error);Ud.prototype.name="ydn.InternalError";
function He(a){Error.captureStackTrace?Error.captureStackTrace(this,He):this.stack=Error().stack||"";a&&(this.message=String(a));this.name="ydn.error.ConstraintError"}z(He,Error);He.prototype.name="ydn.error.ConstraintError";function af(a){Error.captureStackTrace?Error.captureStackTrace(this,af):this.stack=Error().stack||"";a&&(this.message=String(a));this.name="ydn.error.InvalidOperationException"}z(Qd,Error);
function Yd(a){Error.captureStackTrace?Error.captureStackTrace(this,Yd):this.stack=Error().stack||"";a&&(this.message=String(a));this.name="ydn.error.InvalidOperationError"}z(Yd,Error);function rf(a,b){var c;c=c||{};if(null!=a&&null!=b){if(v(a)&&v(b)){if(a.length!=b.length)return!1;for(var d=0;d<a.length;d++)if(-1==nb(b,function(b){return rf(b,a[d])}))return!1;return!0}if(v(a))return 1==a.length&&rf(a[0],b);if(v(b))return 1==b.length&&rf(b[0],a);if(y(a)&&y(a)){for(var e in a)if(a.hasOwnProperty(e)&&!c[e]){var f=rf(a[e],b[e]);if(!f)return!1}for(e in b)if(b.hasOwnProperty(e)&&!c[e]&&(f=rf(a[e],b[e]),!f))return!1;return!0}return a===b}return!1}
function Gf(a){if(a)for(var b in a)if(a.hasOwnProperty(b))return a[b]};/*
Copyright 2012 YDN Authors, Yathit. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");.
*/
function T(a,b,c){c=c||{};var d="autoSchema connectionTimeout size mechanisms policy isSerial Encryption".split(" "),e;for(e in c)if(c.hasOwnProperty(e)&&-1==jb(d,e))throw new C('Unknown attribute "'+e+'" in options.');if(c.mechanisms){if(!u(c.mechanisms))throw new C("mechanisms attribute must be an array but "+ca(c.mechanisms)+" found.");for(e=0;e<c.mechanisms.length;e++)if(!(0<=jb(Hf,c.mechanisms[e])))throw new C('Invalid mechanism "'+c.mechanisms[e]+'"');}this.u=c.mechanisms||Hf;this.h=c.size;
this.v=t(c.connectionTimeout)?c.connectionTimeout:3E3;this.b=null;this.d=[];this.Sa=!1;var f;if(b instanceof Df)f=b;else if(y(b))for(c.autoSchema||!t(b.stores)?f=new Ee(b):f=new Df(b),c=b.stores?b.stores.length:0,e=0;e<c;e++)d=X(f,b.stores[e].name),b.stores[e].Sync&&H(this.logger,"Synchronization option for "+d.getName()+" ignored.");else f=new Ee;this.a=f;for(e=0;e<this.a.count();e++)if((this.a.stores[e]||null).i)throw Error("encryption option must be defined");t(a)&&this.o(a);this.e=null;this.f=
new B}T.prototype.logger=G("ydn.db.con.Storage");T.prototype.D=function(a){if(t(a)){var b=function(b){a(b.toJSON());a=void 0};if(this.b)this.b.K(b);else{var c=this;this.transaction(function(a){c.b.K(b,a)},null,nd)}}return this.a?this.a.toJSON():null};T.prototype.o=function(a){if(this.b)throw new Ib("Already connected with "+this.g);this.g=a;Ge(this)};T.prototype.getName=function(){return this.g};var Hf="indexeddb sqlite websql localstorage sessionstorage userdata memory".split(" ");l=T.prototype;
l.jb=function(){return null};
function Ge(a){function b(b,e){b?(I(a.logger,a+": ready."),a.Gb=NaN,d.Ca=function(b){a.H(new gf(a,b))},d.bb=function(b){a.H(new hf(a,b));a.b=null},d.Ua=function(b){a.H(b)},setTimeout(function(){If(a,e);Jf(a)},10),c.callback(e)):(H(a.logger,a+": database connection fail "+e.name),setTimeout(function(){If(a,new hf(a,e));if(a.d){var b=a.logger;for(b&&b.log(zc,"Purging "+a.d.length+" transactions request.",void 0);b=a.d.shift();)b.F&&b.F("error",e)}},10),c.k(e))}for(var c=new B,d=null,e=a.u,f=0;f<e.length;f++){var g=
e[f].toLowerCase();if(d=a.jb(g)){d=a.jb(g);break}}null===d?(e=new He("No storage mechanism found."),b(!1,new hf(a,e))):yb(d.ra(a.g,a.a),function(a){this.b=d;b(!0,new ff("ready",this,parseFloat(d.$a()),parseFloat(a),null))},function(a){H(this.logger,this+": opening fail");b(!1,a)},a)}l.ta=function(){if(this.b)return this.b.sa()};l.Ta=function(a,b){this.f.Cb(a,b)};function If(a,b){setTimeout(function(){a.a.b&&a.f.c||(b instanceof gf?a.f.k(b.error):a.f.callback(),a.H(b))},4)}
function xe(a){return!!a.b&&a.b.ab()}l.close=function(){this.b&&(this.b.close(),this.b=null,I(this.logger,this+" closed"))};l.lc=function(){return this.b?this.b.zb():null};l.Gb=NaN;function Jf(a){var b=a.d.shift();b&&(I(a.logger,"pop tx queue["+(a.d.length+1)+"]"),a.transaction(b.Ma,b.$b,b.mode,b.F));a.Gb=ma()}
function Kf(a,b,c,d,e){I(a.logger,"push tx queue["+a.d.length+"]");a.d.push({Ma:b,$b:c,mode:d,F:e});100<a.d.length&&0==a.d.length%100&&H(a.logger,"Transaction queue stack size is "+a.d.length+". It is too large, possibility due to incorrect usage.")}l.Sa=!1;
l.transaction=function(a,b,c,d){var e=b;if(w(b))e=[b];else if(null!=b)if(v(b)){if(0==b.length)throw new C("number of store names must more than 0");for(var f=0;f<b.length;f++)if(!w(b[f]))throw new C("store name at "+f+" must be string but found "+typeof b[f]);}else throw new C("store names must be an array");else e=null;if(this.b&&this.b.ab()&&!this.Sa){var g=this,h=t(c)?c:nd;h==od&&(this.Sa=!0);this.b.La(function(b){a(b);a=null},e,h,function(a,b){fa(d)&&(d(a,b),d=void 0);h==od&&(g.Sa=!1);Jf(g)})}else Kf(this,
a,e,c,d)};l.H=function(){};l.toString=function(){return"Storage:"+this.b};function Lf(a,b,c,d){this.d=a;this.f=b;this.a=sb(c);this.b=d;this.c=[]}Lf.prototype.d=null;function Mf(a,b,c){if(a.d)c&&a.c.push(c),b(a.d);else throw new Jb("tx committed on ParallelTxExecutor");}Lf.prototype.toString=function(){return"ParallelTxExecutor: txNo:"+this.f+" mode:"+this.b+" scopes:"+U(this.a)};function Nf(a,b,c,d,e,f){qe.call(this,a,b,c,d,e,f);this.c=this.b=null}z(Nf,qe);l=Nf.prototype;l.logger=G("ydn.db.tr.Parallel");l.abort=function(){J(this.logger,this+": aborting");se(this.c)};
l.Qb=function(a,b){var c;if("multi"==this.f)a:if(c=this.b,!c.a||!c.b||b!=c.b&&(c.b!=M||b!=nd)||a.length>c.a.length)c=!1;else{for(var d=0;d<a.length;d++)if(-1==c.a.indexOf(a[d])){c=!1;break a}c=!0}else if("repeat"==this.f)a:if(c=this.b,c.a&&c.b&&b==c.b&&c.a.length==a.length){for(d=0;d<a.length;d++)if(-1==c.a.indexOf(a[d])){c=!1;break a}c=!0}else c=!1;else c="all"==this.f?!0:!1;return c};
l.ha=function(a,b,c,d){function e(c){k.d++;m=new Lf(c,k.d,b,h);g=k.A();Nc(k.logger,g+" BEGIN "+U(b)+" "+h);k.b=m;Mf(k.b,a,d)}function f(a,b){Nc(k.logger,g+" "+a);if(m){for(var c=m,d=0;d<c.c.length;d++)c.c[d](a,b);c.c.length=0;c.d=null;c.a=null;c.c=null}k.a=0}var g;this.u&&(b=this.u);this.o&&(c=this.o);var h=t(c)?c:nd,k=this,m;if(this.b&&this.b.d&&this.Qb(b,h))Mf(this.b,a,d);else{if(this.h&&this.d>=this.h)throw new Ib("Exceed maximum number of transactions of "+this.h);this.j().transaction(e,b,h,f)}};
l.request=function(a,b,c,d){var e=new O(a),f=this;this.ha(function(a){f.a++;Id(e,a,f.A()+"R"+f.a)},b,c||nd,function(a,b){Kd(e);d&&d(a,b)});return e};l.W=function(a,b,c,d,e){var f=this,g;this.ha(function(c){f.a++;g=f.A()+"R"+f.a;J(f.logger,g+" BEGIN");b(c,g,function(b,d){f.c=c;g=f.A()+"R"+f.a;d?(J(f.logger,g+" ERROR"),a.k(b)):(J(f.logger,g+" SUCCESS"),a.callback(b));f.c=null});b=null;J(f.logger,g+" END")},c,d,e)};l.toString=function(){return"Parallel:"+this.f+":"+this.A()+(this.c?"*":"")};function Of(a,b){Nf.call(this,a,b,re)}z(Of,Nf);l=Of.prototype;l.logger=G("ydn.db.tr.AtomicParallel");l.Qb=function(){return!1};l.request=function(a,b,c){var d,e,f,g=this,h=Of.r.request.call(this,a,b,c,function(a,b){Kd(h);J(g.logger,"transaction "+a);if(d)"complete"!=a&&(f=!0,e=b),d(e,f);else{var c=new ke;P(h,c,!0)}});Md(h,function(a,b,c){f=b;e=a;d=c});return h};
l.W=function(a,b,c,d,e){var f,g,h=new B;yb(h,function(a){g=!1;f=a},function(a){g=!0;f=a});Of.r.W.call(this,h,b,c,d,function(b,c){if("complete"!=b)a.k(c);else if(!0===g)a.k(f);else if(!1===g)a.callback(f);else{var d=new ke;a.k(d)}e&&(e(b,c),e=void 0)})};l.toString=function(){return"Atomic"+Of.r.toString.call(this)};function Pf(a,b,c){T.call(this,a,b,c);this.na=0;a=!0;b=re;c&&(t(c.isSerial)&&(a=!!c.isSerial),c.policy&&(b=c.policy));c=Qf(this,b,a);this.i=Qf(this,"atomic",!1);this.c=this.la(c,this.i)}z(Pf,T);l=Pf.prototype;l.na=0;l.Rb=function(a,b,c,d,e,f){a=a||re;var g;"readonly"==d?g=nd:"readwrite"==d&&(g=M);a=Qf(this,a,b,c,g,e);return this.la(a,f?null:this.i)};l.la=function(a){return new ze(this,this.a,a)};
function Qf(a,b,c,d,e,f){if(c){if("multi"==b||"repeat"==b||"all"==b||b==re)return new te(a,a.na++,b,d,e,f);if("atomic"==b)return new ye(a,a.na++);throw new C('Invalid requestType "'+b+'"');}if("multi"==b||"repeat"==b||"all"==b||b==re)return new Nf(a,a.na++,b,d,e,f);if("atomic"==b)return new Of(a,a.na++);throw new C('Invalid requestType "'+b+'"');}
l.Zb=function(a,b,c){if(3<arguments.length)throw new C("too many input arguments, run accept not more than 3 input arguments, but "+arguments.length+" found.");this.na++;var d=b||Oe(this.a),e=nd;if(c)if("readwrite"==c)e=M;else if("readonly"!=c)throw new C('Invalid transaction mode "'+c+'"');var f=Qf(this,"all",!1,d,e,1),g=this.la(f,this.i),h=new O("run"),k=this;f.ha(function(b){I(k.logger,"executing run in transaction on "+f);Id(h,b,f.A()+"R0");a(g)},d,e,function(a){Kd(h);P(h,f.d,"complete"!==a)});
return h};l.qc=function(){return this.c?this.c.a.d:NaN};function Y(a,b,c){Pf.call(this,a,b,c);a=this.a;for(b=0;b<a.c.length;b++){c=a.c[b];var d=X(a,c.getName());if(d){if(!Pe(d,"k"))throw new C('full text index store "'+d.getName()+'" must have "keyword" index');if(!Pe(d,"v"))throw new C('full text index store "'+d.getName()+'" must have "keyword" index');if("id"!=d.keyPath)throw new C('full text index store "'+d.getName()+'" must use "id" as key path.');}else throw new C('full text index store "'+c.getName()+'" required.');for(d=0;d<c.count();d++){var e=
c.index(d),f=X(a,e.m);if(f)H(this.logger,"Full text indexer option for "+f.getName()+" ignored.");else throw new C('full text source store "'+e.m+'" does not exist for full text index "'+c.getName()+'"');}}}z(Y,Pf);l=Y.prototype;l.la=function(a){return new Ie(this,this.a,a)};l.add=function(a,b,c){return this.c.add(a,b,c)};l.count=function(a,b,c,d){return this.c.count(a,b,c,d)};l.get=function(a,b){return this.c.get(a,b)};l.keys=function(a,b,c,d,e,f,g){return this.c.keys(a,b,c,d,e,f,g)};
l.w=function(a,b,c,d,e,f){return this.c.w(a,b,c,d,e,f)};l.load=function(a,b,c){return this.c.load(a,b,c)};l.put=function(a,b,c){return this.c.put(a,b,c)};l.clear=function(a,b,c){return this.c.clear(a,b,c)};l.fb=function(a,b,c){return this.c.fb(a,b,c)};l.toString=function(){var a="Storage:"+this.getName();xe(this)&&(a+=" ["+this.ta()+"]");return a};function Rf(a,b,c){Y.call(this,a,b,c)}z(Rf,Y);l=Rf.prototype;l.la=function(a){return new Ze(this,this.a,a)};l.open=function(a,b,c,d){return this.c.open(a,b,c,d)};l.mc=function(a,b){return this.c.Ab(a,b)};l.map=function(a,b){return this.c.map(a,b)};l.eb=function(a,b,c){return this.c.eb(a,b,c)};function Sf(a,b,c,d){td.call(this,a,b,c,d);this.e=null}z(Sf,td);l=Sf.prototype;l.logger=G("ydn.db.core.req.IDBCursor");l.Ka=function(a){(a=a.target.result)?this.O(a.key,a.primaryKey,a.value):this.O()};
l.openCursor=function(a,b){function c(a,b,c){q.e=n;q.e.onsuccess=ka(q.Ka,q);q.O(a,q.f?b:void 0,c);n=null}var d=this+" opening ";null!=a&&(d+="{"+a,d=null!=b?d+(";"+b+"}"):d+"}");I(this.logger,d);var e=this.p,d=this.d.objectStore(this.m),f=w(this.I)?d.index(this.I):null;if(t(a))var g=f?!t(b):!0,h=e?e.lower:void 0,k=e?e.upper:void 0,m=e?!!e.lowerOpen:!1,e=e?!!e.upperOpen:!1,e=Qc(this.reverse?new K(h,a,m,g):new K(a,k,g,e));var n;this.wa?f?n=null!=this.Q?f.openKeyCursor(e,this.Q):null!=e?f.openKeyCursor(e):
f.openKeyCursor():n=null!=this.Q?d.openCursor(e,this.Q):null!=e?d.openCursor(e):d.openCursor():f?n=null!=this.Q?f.openCursor(e,this.Q):null!=e?f.openCursor(e):f.openCursor():n=null!=this.Q?d.openCursor(e,this.Q):null!=e?d.openCursor(e):d.openCursor();var q=this;n.onerror=function(a){var b=n.error;a.preventDefault();wd(q,b)};null!=a?n.onsuccess=function(d){if(d=d.target.result){var e=pd.cmp(d.key,a),f=q.reverse?-1:1;if(e==f)c(d.key,d.primaryKey,d.value);else if(e==-f)d["continue"](a);else if(null!=
b)if(pd.cmp(d.primaryKey,b)==f)c(d.key,d.primaryKey,d.value);else d["continue"]();else d["continue"]()}else c()}:(q.e=n,q.e.onsuccess=ka(q.Ka,q))};l.Qa=function(){return!!this.e};l.update=function(a){var b=this.e.result;if(b){var c=new B;a=b.update(a);a.onsuccess=function(a){c.callback(a.target.result)};a.onerror=function(a){a.preventDefault();c.k(a)};return c}throw new fe("cursor gone");};
l.clear=function(){var a=this.e.result;if(a){var b=new B,a=a["delete"]();a.onsuccess=function(){b.callback(1)};a.onerror=function(a){a.preventDefault();b.k(a)};return b}throw new fe("cursor gone");};l.advance=function(a){var b=this.e.result;if(1==a)b["continue"]();else b.advance(a)};
l.Da=function(a){var b=this.e.result,c=pd.cmp(a,b.primaryKey);if(c!=(this.reverse?-1:1))throw new Jb('continuing primary key "'+a+'" must '+(this.reverse?"lower":"higher")+' than current primary key "'+b.primaryKey+'"');var d=this;this.e.onsuccess=function(e){if(b=e.target.result)if(c=pd.cmp(b.primaryKey,a),0==c||1==c&&!d.reverse||-1==c&&d.reverse)d.e.onsuccess=ka(d.Ka,d),d.O(b.key,d.f?b.primaryKey:void 0,b.value);else b["continue"]();else d.e.onsuccess=ka(d.Ka,d),d.O()};b["continue"]()};
l.ja=function(a){var b=this.e.result;if(null!=a)b["continue"](a);else b["continue"]()};l.$=function(){Sf.r.$.call(this);this.e=null};l.toString=function(){return"IDB"+Sf.r.toString.call(this)};function Tf(a,b){this.a=b}z(Tf,ne);l=Tf.prototype;l.logger=G("ydn.db.crud.req.IndexedDb");l.Ja=function(a,b){function c(e){var f=a.a.objectStore(b[e]).count();f.onsuccess=function(f){d[e]=f.target.result;e++;e==b.length?P(a,d):c(e)};f.onerror=function(b){b.preventDefault();P(a,f.error,!0)}}var d=[];0==b.length?P(a,[]):c(0)};
l.S=function(a,b,c,d,e,f){function g(r){if(null==e[r])if(I(n.logger,"empty object at "+r+" of "+e.length),k++,k==e.length)P(a,h,m);else{var A=r+10;A<e.length&&g(A)}var E,A=e[r];E=f&&null!=f[r]?b?p.put(A,f[r]):p.add(A,f[r]):b?p.put(A):p.add(A);E.onsuccess=function(b){k++;h[r]=b.target.result;k==e.length?P(a,c?h[0]:h,m):(b=r+10,b<e.length&&g(b))};E.onerror=function(b){k++;var f=E.error;I(n.logger,S(a)+q+' request to "'+d+'" cause '+f.name+' for object "'+Ke(e[r])+'" at index '+r+" of "+e.length+" objects.");
h[r]=f;m=!0;b.preventDefault();k==e.length?P(a,c?h[0]:h,m):(b=r+10,b<e.length&&g(b))}}var h=[],k=0,m=!1,n=this,q=b?"put":"add",p=a.a.objectStore(d);I(this.logger,S(a)+" "+q+" "+e.length+' objects to store "'+d+'"');if(0<e.length)for(var r=0;10>r&&r<e.length;r++)g(r);else P(a,[])};
l.sb=function(a,b,c){function d(k){var n=c[k],q=n.m,p=a.a.objectStore(q),r;r=null===p.keyPath?p.put(b[k],n.id):p.put(b[k]);r.onsuccess=function(c){f++;e[k]=c.target.result;f==b.length?P(a,e,g):(c=k+10,c<b.length&&d(c))};r.onerror=function(c){f++;H(h.logger,"request result "+c.name+' error when put keys to "'+q+'" for object "'+Ke(b[k])+'" at index '+k+" of "+b.length+" objects.");e[k]=r.error;g=!0;c.preventDefault();f==b.length?P(a,e,g):(c=k+10,c<b.length&&d(c))}}var e=[],f=0,g=!1,h=this;I(this.logger,
S(a)+" putByKeys: of "+b.length+" objects");if(0<b.length)for(var k=0;10>k&&k<b.length;k++)d(k);else P(a,e,g)};
l.tb=function(a,b,c,d,e,f){function g(){var a={},b=e.indexOf("\n",n),d=!1,r;-1==b?(d=!0,r=e.substring(n)):(r=e.substring(n,b),n=b+1);for(var b=r.split(f),F=0;F<q.length;F++){var R=b[F];p[F]&&(p[F]==lf?R=Ea(R,'"'):"INTEGER"==p[F]?R=parseInt(R,10):"NUMERIC"==p[F]&&(R=parseFloat(R)));a[q[F]]=R}var V=k.put(a);V.onsuccess=function(a){m.push(a.target.result);d?c(m):g()};V.onerror=function(a){"DataError"==a.name&&(a=new ce(h+": "+r.substring(0,70)));a.preventDefault();c(V.error,!0)}}var h=X(this.a,d),k=
a.objectStore(d),m=[],n=e.indexOf("\n"),q=e.substr(0,n).split(f),p=[];for(a=0;a<q.length;a++){var r=vd(h,q[a]);r?p[a]=r.type:q[a]==h.keyPath&&(p[a]=h.type)}n++;I(this.logger,b+" Loading data of "+q.length+"-fields record to "+d);g()};
l.Wa=function(a,b,c){var d=a.a.objectStore(b);I(this.logger,S(a)+" clearById: "+b+" "+c);var e=d.openCursor(Tc.only(c));e.onsuccess=function(b){if(b=b.target.result){var c=b["delete"]();c.onsuccess=function(){P(a,1)};c.onerror=function(){P(a,c.error,!0)}}else P(a,0)};e.onerror=function(b){b.preventDefault();P(a,e.error,!0)}};
l.vb=function(a,b){function c(h){h++;if(h>=b.length)0<g.length?P(a,g,!0):P(a,d);else{b[h].m!=e&&(e=b[h].m,f=a.a.objectStore(e));var k=f["delete"](b[h].id);k.onsuccess=function(){d++;c(h)};k.onerror=function(a){a.preventDefault();g[h]=k.error;c(h)}}}var d=0,e,f;I(this.logger,S(a)+" removeByKeys: "+b.length+" keys");var g=[];c(-1)};
l.Xa=function(a,b,c){var d=a.a.objectStore(b),e=d.count(c);I(this.logger,S(a)+" clearByKeyRange: "+b+" "+c);e.onsuccess=function(b){var e=b.target.result,h=d["delete"](c);h.onsuccess=function(){P(a,e)};h.onerror=function(){P(a,h.error,!0)}};e.onerror=function(b){b.preventDefault();P(a,e.error,!0)}};l.hb=function(a,b,c){var d=a.a.objectStore(b);I(this.logger,S(a)+" "+b+" "+c);var e=d["delete"](c);e.onsuccess=function(){P(a,void 0)};e.onerror=function(b){b.preventDefault();P(a,e.error,!0)}};
l.ub=function(a,b,c,d){var e=a.a.objectStore(b).index(c);I(this.logger,S(a)+" clearByIndexKeyRange: "+b+":"+c+" "+d);var f=[],g=e.openCursor(d),h=0;g.onsuccess=function(b){var c=b.target.result;if(c){var d=c["delete"]();d.onsuccess=function(){h++;c["continue"]()};d.onerror=function(a){f.push(d.error);a.preventDefault();c["continue"]()}}else 0<f.length?P(a,f,!0):P(a,h)};g.onerror=function(b){b.preventDefault();P(a,g.error,!0)}};
l.Ha=function(a,b){var c=b.length,d=0;I(this.logger,S(a)+" clearByStores: "+b);for(var e=0;e<c;e++){var f=a.a.objectStore(b[e]).clear();f.onsuccess=function(){d++;d==c&&P(a,d)};f.onerror=function(b){d++;b.preventDefault();d==c&&P(a,f.error,!0)}}};
l.Na=function(a,b,c){var d=this;I(this.logger,S(a)+b+":"+c);var e=a.a.objectStore(b),f=e.get(c);f.onsuccess=function(b){I(d.logger,S(a)+" record "+c+(null!=b.target.result?" ":" not ")+" exists.");var f=b.target.result;if(!e.keyPath&&0==e.indexNames.length&&ec&&w(f)&&0<=f.indexOf(";base64,")){'"'==f.charAt(0)&&'"'==f.charAt(f.length-1)&&(f=f.substr(1,f.length-2));f=f.split(";base64,");b=f[0].split(":")[1];for(var f=window.atob(f[1]),k=f.length,m=new Uint8Array(k),n=0;n<k;++n)m[n]=f.charCodeAt(n);
P(a,new Blob([m.buffer],{type:b}))}else P(a,b.target.result)};f.onerror=function(b){b.preventDefault();P(a,f.error,!0)}};
l.ob=function(a,b,c){function d(b){if(null==c[b])if(f++,e[b]=void 0,f==h)P(a,e);else{var m=b+10;m<h&&d(m)}var n;n=g.get(c[b]);n.onsuccess=function(c){f++;e[b]=c.target.result;f==h?P(a,e):(c=b+10,c<h&&d(c))};n.onerror=function(b){f++;b.preventDefault();P(a,n.error,!0)}}var e=[];e.length=c.length;var f=0,g=a.a.objectStore(b),h=c.length;I(this.logger,S(a)+" "+b+":"+h+" ids");if(0<h)for(b=0;10>b&&b<h;b++)d(b);else P(a,[])};
l.pb=function(a,b){function c(f){var h=b[f],k=a.a.objectStore(h.m).get(h.id);k.onsuccess=function(h){e++;d[f]=h.target.result;e==b.length?P(a,d):(h=f+10,h<b.length&&c(h))};k.onerror=function(b){e++;b.preventDefault();P(a,k.error,!0)}}var d=[];d.length=b.length;var e=0;I(this.logger,S(a)+" "+b.length+" ids");if(0<b.length)for(var f=0;10>f&&f<b.length;f++)c(f);else P(a,[])};
l.ua=function(a,b,c,d,e){if(d&&e)throw new Ib("unique count not available in IndexedDB");e=a.a.objectStore(b);b=S(a)+" "+b+(d?":"+d:"")+(c?":"+U(c):"");I(this.logger,b);var f;null!=d?(d=e.index(d),f=null!=c?d.count(c):d.count()):f=null!=c?e.count(c):e.count();f.onsuccess=function(b){P(a,b.target.result)};f.onerror=function(b){b.preventDefault();P(a,f.error,!0)}};
l.R=function(a,b,c,d,e,f,g,h,k,m){var n=[],q=a.a.objectStore(c),p=h?k?"prevunique":"prev":k?"nextunique":"next";c=S(a)+" "+b+" "+c+(d?":"+d:"")+(e?U(e):"");h&&(c+=" reverse");k&&(c+=" unique");if(m&&t(m[0])){k=d?!t(m[1]):!0;var r=m[0],x=e?e.lower:void 0,A=e?e.upper:void 0,E=e?!!e.lowerOpen:!1;e=e?!!e.upperOpen:!1;e=Qc(h?new K(x,r,E,k):new K(r,A,k,e));c+=" starting from "+U(m[0]);t(m[1])&&(c+=", "+U(m[1]))}I(this.logger,c);var D;D=1==b||2==b||3==b?d?q.index(d).openKeyCursor(e,p):q.openCursor(e,p):
d?q.index(d).openCursor(e,p):q.openCursor(e,p);var F=!1;D.onsuccess=function(c){if(c=c.target.result){if(!F){if(0<g){F=!0;c.advance(g);return}if(m&&d&&t(m[0]))if(t(m[1])){var e=pd.cmp(c.key,m[0]),k=h?-1:1;if(0==e){e=pd.cmp(c.primaryKey,m[1]);if(0==e){F=!0;c["continue"]();return}if(e==k)F=!0;else{c["continue"]();return}}else F=!0}else F=!0;else F=!0}1==b?n.push(c.key):2==b?n.push(c.primaryKey):3==b?(k={},d&&(k[d]=c.key),q.keyPath?k[q.keyPath]=c.primaryKey:k._ROWID_=c.primaryKey,n.push(k)):4==b?n.push(c.value):
n.push([c.key,c.primaryKey,c.value]);if(n.length<f)c["continue"]();else m&&(m[0]=yd(c.key),m[1]=yd(c.primaryKey)),P(a,n)}else m&&(m[0]=void 0,m[1]=void 0),P(a,n)};D.onerror=function(b){b.preventDefault();P(a,D.error,!0)}};function Uf(a,b){this.a=b}z(Uf,Tf);Uf.prototype.logger=G("ydn.db.core.req.IndexedDb");Uf.prototype.b=function(a,b,c,d){c=X(this.a,c);return new Sf(a,b,c,d)};function Vf(){this.a=!1}Vf.prototype.a=!1;function Wf(a,b,c,d){td.call(this,a,b,c,d);this.h=this.c=this.a=void 0;this.g=this.e=null;this.o=new Vf;this.Za=this.ca=null}z(Wf,td);l=Wf.prototype;l.logger=G("ydn.db.core.req.SimpleCursor");l.Qa=function(){return!!this.d};l.update=function(a){Xf(this.Za,this.B(),a);return Eb()};l.advance=function(a){function b(b){d++;if(!b||d>=a)return Yf(c,b)}var c=this,d=this.e?-1:0;this.reverse?Zf(this.ca,b,this.e):$f(this.ca,b,this.e)};
l.ja=function(a){if(null!=a){var b=this,c=new Z(a),d=function(c){b.e=c;if(!c)return Yf(b,c);var d=L(c.value.key,a);if(b.reverse){if(1!=d)return Yf(b,c)}else if(-1!=d)return Yf(b,c)};this.reverse?Zf(this.ca,d,c):$f(this.ca,d,c)}else this.advance(1)};function ag(a){setTimeout(function(){a.o.a?(a.o.a=!1,a.O(a.a,a.c,a.h),ag(a)):(a.g(),a.g=null)},4)}
function Yf(a,b){if(a.e=b){var c=b.value;if(a.p)if(a.reverse||null==a.p.upper)a.reverse&&null!=a.p.lower&&(d=L(c.key,a.p.lower),-1==d||0==d&&a.p.lowerOpen)&&(a.e=null);else{var d=L(c.key,a.p.upper);if(1==d||0==d&&a.p.upperOpen)a.e=null}if(a.e){if(a.unique&&null!=a.a&&null!=c.key&&0==L(a.a,c.key))return;a.a=c.key;a.c=a.f?c.a:a.a;4==a.u&&(a.wa?a.h=a.c:a.h=bg(a.Za,a.c))}}a.e||(a.a=void 0,a.c=void 0,a.h=void 0);return a.o.a=!0}
l.openCursor=function(a,b){var c=null;if(this.p)if(this.reverse){var d=this.f?"\uffff":void 0;null!=this.p.upper&&(c=new Z(this.p.upper,d))}else null!=this.p.lower&&(c=new Z(this.p.lower));null!=a&&(c=this.f?new Z(a,b):new Z(a));this.g=this.d.j(function(b){function d(b){var e=b.value,f=e.key;if(b&&null!=f)if(null!=a){if(0==cg(c,e))return}else if(this.p&&(!this.reverse&&this.p.lowerOpen&&null!=this.p.lower&&(e=L(f,this.p.lower),0==e)||this.reverse&&this.p.upperOpen&&null!=this.p.upper&&(e=L(f,this.p.upper),
0==e)))return;return Yf(this,b)}this.Za=dg(b,this.m);this.ca=eg(this.Za,this.I);this.reverse?Zf(this.ca,ka(d,this),c):$f(this.ca,ka(d,this),c);ag(this)},this)};l.clear=function(){throw new Hb;};l.Da=function(){throw new Hb;};l.toString=function(){return"Simple"+Wf.r.toString.call(this)};function fg(a,b,c){a=["ydn.db",a];t(b)&&(a.push(b),t(c)&&(a.push(c),t(void 0)&&a.push(bd(void 0))));return a.join("^|")};function Z(a,b){this.key=a;this.a=b}Z.prototype.toString=function(){return"ydn.db.con.simple.Node("+this.key+(null!=this.a?", "+this.a+")":")")};function cg(a,b){var c=L(a.key,b.key);return 0===c?null!=a.a?null!=b.a?L(a.a,b.a):1:null!=b.a?-1:0:c};function gg(a){this.L=a||hg}function hg(a,b){return String(a)<String(b)?-1:String(a)>String(b)?1:0}l=gg.prototype;l.s=null;l.L=null;l.U=null;l.T=null;
l.add=function(a){if(null==this.s)return this.T=this.U=this.s=new ig(a),!0;var b=null;jg(this,function(c){var d=null,e=this.L(c.value,a);0<e?(d=c.left,null==c.left&&(b=new ig(a,c),c.left=b,c==this.U&&(this.U=b))):0>e&&(d=c.right,null==c.right&&(b=new ig(a,c),c.right=b,c==this.T&&(this.T=b)));return d});b&&(jg(this,function(a){a.count++;return a.parent},b.parent),kg(this,b.parent));return!!b};
function lg(a,b){jg(a,function(a){var d=null,e=this.L(a.value,b);0<e?d=a.left:0>e?d=a.right:mg(this,a);return d})}l.clear=function(){this.T=this.U=this.s=null};l.contains=function(a){var b=!1;jg(this,function(c){var d=null,e=this.L(c.value,a);0<e?d=c.left:0>e?d=c.right:b=!0;return d});return b};l.indexOf=function(a){var b=-1,c=0;jg(this,function(d){var e=this.L(d.value,a);if(0<e)return d.left;d.left&&(c+=d.left.count);if(0>e)return c++,d.right;b=c;return null});return b};
l.mb=function(){return this.s?this.s.count:0};l.Oa=function(){var a=[];ng(this,function(b){a.push(b)});return a};function ng(a,b){if(a.s){var c,d=c=og(a);for(c=c.left?c.left:c;null!=d;)if(null!=d.left&&d.left!=c&&d.right!=c)d=d.left;else{if(d.right!=c&&b(d.value))break;var e=d,d=null!=d.right&&d.right!=c?d.right:d.parent;c=e}}}function jg(a,b,c){for(c=c?c:a.s;c&&null!=c;)c=b.call(a,c)}
function kg(a,b){jg(a,function(a){var b=a.left?a.left.height:0,e=a.right?a.right.height:0;1<b-e?(a.left.right&&(!a.left.left||a.left.left.height<a.left.right.height)&&pg(this,a.left),qg(this,a)):1<e-b&&(a.right.left&&(!a.right.right||a.right.right.height<a.right.left.height)&&qg(this,a.right),pg(this,a));b=a.left?a.left.height:0;e=a.right?a.right.height:0;a.height=Math.max(b,e)+1;return a.parent},b)}
function pg(a,b){rg(b)?(b.parent.left=b.right,b.right.parent=b.parent):sg(b)?(b.parent.right=b.right,b.right.parent=b.parent):(a.s=b.right,a.s.parent=null);var c=b.right;b.right=b.right.left;null!=b.right&&(b.right.parent=b);c.left=b;b.parent=c;c.count=b.count;b.count-=(c.right?c.right.count:0)+1}
function qg(a,b){rg(b)?(b.parent.left=b.left,b.left.parent=b.parent):sg(b)?(b.parent.right=b.left,b.left.parent=b.parent):(a.s=b.left,a.s.parent=null);var c=b.left;b.left=b.left.right;null!=b.left&&(b.left.parent=b);c.right=b;b.parent=c;c.count=b.count;b.count-=(c.left?c.left.count:0)+1}
function mg(a,b){if(null!=b.left||null!=b.right){var c=null,d;if(null!=b.left){d=tg(a,b.left);jg(a,function(a){a.count--;return a.parent},d);if(d!=b.left){if(d.parent.right=d.left)d.left.parent=d.parent;d.left=b.left;d.left.parent=d;c=d.parent}d.parent=b.parent;d.right=b.right;d.right&&(d.right.parent=d);b==a.T&&(a.T=d)}else{d=og(a,b.right);jg(a,function(a){a.count--;return a.parent},d);if(d!=b.right){if(d.parent.left=d.right)d.right.parent=d.parent;d.right=b.right;d.right.parent=d;c=d.parent}d.parent=
b.parent;d.left=b.left;d.left&&(d.left.parent=d);b==a.U&&(a.U=d)}d.count=b.count;rg(b)?b.parent.left=d:sg(b)?b.parent.right=d:a.s=d;kg(a,c?c:d)}else jg(a,function(a){a.count--;return a.parent},b.parent),rg(b)?(b.parent.left=null,b==a.U&&(a.U=b.parent),kg(a,b.parent)):sg(b)?(b.parent.right=null,b==a.T&&(a.T=b.parent),kg(a,b.parent)):a.clear()}function og(a,b){if(!b)return a.U;var c=b;jg(a,function(a){var b=null;a.left&&(b=c=a.left);return b},b);return c}
function tg(a,b){if(!b)return a.T;var c=b;jg(a,function(a){var b=null;a.right&&(b=c=a.right);return b},b);return c}function ig(a,b){this.value=a;this.parent=b?b:null;this.count=1}ig.prototype.left=null;ig.prototype.right=null;ig.prototype.height=1;function sg(a){return!!a.parent&&a.parent.right==a}function rg(a){return!!a.parent&&a.parent.left==a};function ug(a){this.L=a||hg}z(ug,gg);function $f(a,b,c){if(a.s){var d;if(c instanceof ig)d=c;else if(c){if(jg(a,function(a){var b=null;0<this.L(a.value,c)?(b=a.left,d=a):0>this.L(a.value,c)?b=a.right:d=a;return b}),!d)return}else d=og(a);a=d;for(var e=d.left?d.left:d;null!=a;)if(null!=a.left&&a.left!=e&&a.right!=e)a=a.left;else{if(a.right!=e&&b(a))return;var f=a;a=null!=a.right&&a.right!=e?a.right:a.parent;e=f}b(null)}}
function Zf(a,b,c){if(a.s){var d;if(c instanceof ig)d=c;else if(c){if(jg(a,ka(function(a){var b=null;0<this.L(a.value,c)?b=a.left:(0>this.L(a.value,c)&&(b=a.right),d=a);return b},a)),!d)return}else d=tg(a);a=d;for(var e=d.right?d.right:d;null!=a;)if(null!=a.right&&a.right!=e&&a.left!=e)a=a.right;else{if(a.left!=e&&b(a))return;var f=a;a=null!=a.left&&a.left!=e?a.left:a.parent;e=f}b(null)}};function vg(a,b,c){this.f=a;this.storage=b;this.b=c;this.a={};a=this.b.keyPath;this.c=u(a)?a.join(","):a||"_ROWID_";this.a[this.c]=null;this.d=fg(this.f,this.b.getName(),this.c)+"^|"}
function eg(a,b){var c=b||a.c;if(!a.a[c]){a.a[c]=new ug(cg);for(var d=a.storage.length,e=0;e<d;e++){var f=a.storage.key(e);if(null!==f&&0==f.lastIndexOf(a.d,0)){var g=ed(f.substr(a.d.length));if(c==a.c)a.a[c].add(new Z(g));else{var h=a.storage.getItem(f);if(null!==h)if(f=vd(a.b,c),h=bf(h),h=mf(f,h),f.multiEntry){if(u(h))for(f=0;f<h.length;f++)a.a[c].add(new Z(h[f],g))}else a.a[c].add(new Z(h,g))}}}}return a.a[c]}
function wg(a,b,c){for(var d in a.a){var e=a.a[d];if(e)if(d==a.c)lg(e,new Z(b));else{var f=vd(a.b,d),f=Zc(c,f.keyPath);lg(e,new Z(b,f))}}}function xg(a){for(var b in a.a){var c=a.a[b];c&&c.clear()}a.a={}}
function Xf(a,b,c,d){if(null==b&&(a.b.keyPath&&(b=Te(a.b,c)),a.b.b&&null==b)){b=a.d+bd(void 0);var e=bf(a.storage.getItem(b));e.key_count||(e.key_count=0);e.key_count++;a.storage.setItem(b,U(e));b=e.key_count}d&&(d=null!==a.storage.getItem(a.d+bd(b)));if(d)return null;a.storage.setItem(a.d+bd(b),U(c));d=b;for(var f in a.a)if(e=a.a[f])if(f==a.c)e.add(new Z(d));else{var g=vd(a.b,f),g=Zc(c,g.keyPath);null!=g&&e.add(new Z(d,g))}return b}
function yg(a,b){var c=a.d+bd(b),d=a.storage.getItem(c);if(null===d)return 0;a.storage.removeItem(c);c=bf(d);wg(a,b,c);return 1}vg.prototype.clear=function(){xg(this);zg(this)};function bg(a,b){var c=a.storage.getItem(a.d+bd(b)),d=void 0;if(null!==c)for(var d=bf(c),c=0,e=a.b.a.length;c<e;c++){var f=a.b.index(c);if("DATE"==f.type){var g=mf(f,d);g&&nf(f,d,new Date(g))}}return d}vg.prototype.getName=function(){return this.b.getName()};
function Ag(a,b,c){b=b||a.c;a=eg(a,b);var d=null,e=null,f=0,g=!1,h=!1;null!=c&&(null!=c.lower&&(d=new Z(c.lower)),null!=c.upper&&(e=new Z(c.upper)),g=c.lowerOpen,h=c.upperOpen);$f(a,function(a){if(null!=a&&(a=a.value,!g||null==d||0!=L(a.key,d.key))){if(null!=e&&(a=L(a.key,e.key),1===a||0===a&&h))return!0;f++}},d);return f}
function zg(a,b){var c=eg(a,a.c),d=null,e=null,f=0,g=[],h=[],k=!1,m=!1;null!=b&&(null!=b.lower&&(d=new Z(b.lower)),null!=b.upper&&(e=new Z(b.upper)),k=b.lowerOpen,m=b.upperOpen);$f(c,function(b){if(null!=b&&(b=b.value,!k||null==d||0!=cg(b,d))){if(null!=e){var c=cg(b,e);if(1===c||0===c&&m)return!0}var c=a.d+bd(b.key),p=a.storage.getItem(c);null!==p&&(a.storage.removeItem(c),f++,10>g.length&&(g.push(b.key),h.push(bf(p))))}},d);if(10>g.length)for(c=0;c<g.length;c++)wg(a,g[c],h[c]);else xg(a);return f}
function Bg(a,b,c,d,e,f,g,h,k){function m(c){if(c&&(E++,!(E<g))){var d=c.value;if(e){if(F&&null!=A&&(c=p?cg(d,A):L(d.key,A.key),0==c))return;if(null!=x&&(c=p?cg(d,x):L(d.key,x.key),-1==c||0==c&&D))return k&&(k[0]=void 0,k[1]=void 0),!0}else{if(D&&null!=x&&(c=p?cg(d,x):L(d.key,x.key),0==c))return;if(null!=A&&(c=p?cg(d,A):L(d.key,A.key),1==c||0==c&&F))return k&&(k[0]=void 0,k[1]=void 0),!0}c=d.key;if(!h||!r||null==q||0!=L(q,c)){d=r?d.a:c;if(2==b)n.push(d);else if(1==b)n.push(c);else if(3==b)n.push([c,
d]);else if(4==b){var m=bg(a,d);n.push(m)}else n.push([c,d,bg(a,d)]);k&&(k[0]=c,k[1]=d)}q=c;if(t(f)&&n.length>=f)return!0}}var n=[],q,p=!!k&&null!=k[0];c=c||a.c;var r=c!=a.c;c=eg(a,c);var x=null,A=null;t(g)||(g=0);var E=-1,D=!1,F=!1;null!=d&&(null!=d.lower&&(x=r&&e?new Z(d.lower,"\uffff"):new Z(d.lower)),null!=d.upper&&(A=r&&!e?new Z(d.upper,"\uffff"):new Z(d.upper)),D=!!d.lowerOpen,F=!!d.upperOpen);if(p){e?F=!0:D=!0;d=k[0];var R=t(k[1])?k[1]:"\uffff";e?A=r?new Z(d,R):new Z(d):x=r?new Z(d,R):new Z(d)}e?
Zf(c,m,A):$f(c,m,x);return n}vg.prototype.fa=function(a,b,c,d,e){return Bg(this,2,a,b,c,d,e)};vg.prototype.toString=function(){return"ydn.db.con.simple.Store:"+this.f+":"+this.b.getName()};function Cg(){this.clear()}l=Cg.prototype;l.ib=function(){return this};l.setItem=function(a,b){t(this.a[a])||(this.keys.push(a.toString()),this.length=this.keys.length);this.a[a]=b};l.getItem=function(a){return t(this.a[a])?this.a[a]:null};l.removeItem=function(a){delete this.a[a];qb(this.keys,a.toString());this.length=this.keys.length};l.length=0;l.key=function(a){a=this.keys[a];return t(a)?this.a[a]:null};l.clear=function(){this.a={};this.keys=[];this.length=0};function Dg(a){this.e=a||new Cg;this.f={}}function dg(a,b){var c=X(a.a,b);if(c)a.f[b]||(a.f[b]=new vg(a.d,a.c,c));else throw new Jb('store name "'+b+'" not found.');return a.f[b]}Dg.prototype.K=function(a){var b=this;setTimeout(function(){var c=fg(b.d),c=b.c.getItem(c),c=new Df(c);a(c)},10)};function Eg(a,b){this.b=a;this.a=b}Eg.prototype.j=function(a,b){var c=this.b;setTimeout(function(){a.call(b,c)},4);var d=this;return function(){d.a("complete",null);d.a=null;d.b=null}};function Fg(a,b){this.a=b}z(Fg,ne);l=Fg.prototype;l.logger=G("ydn.db.crud.req.SimpleStore");l.sb=function(a,b,c){this.S(a,!0,!1,null,b,c)};
l.S=function(a,b,c,d,e,f){I(this.logger,S(a)+" "+(b?"put":"add")+"Object"+(c?"":"s "+e.length+" objects"));var g=a.a.j(function(h){var k;if(c)k=dg(h,d),h=f?f[0]:void 0,h=Xf(k,h,e[0],!b),null!=h?P(a,h):(k=Ke(h),k=new be(k),P(a,k,!0));else{for(var m=d,n=[],q=!1,p=f||{},r=0;r<e.length;r++){var x;d?x=p[r]:(m=f[r],x=m.id,m=m.m);k&&k.getName()==m||(k=dg(h,m));x=Xf(k,x,e[r],!b);null!=x?n.push(x):(q=!0,n.push(new be))}P(a,n,q)}g();g=null},this)};l.tb=function(){throw new Hb("putData");};
l.Na=function(a,b,c){var d=a.a.j(function(e){e=bg(dg(e,b),c);P(a,e);d();d=null},this)};function Gg(a,b,c,d){var e=b.a.j(function(a){for(var g=[],h=c,k,m=0;m<d.length;m++){var n=d[m];n instanceof le&&(h=n,n=h.id,h=h.m);k&&k.getName()==h||(k=dg(a,h));n=bg(k,n);g[m]=n}P(b,g,!1);e();e=null},a)}l.ob=function(a,b,c){Gg(this,a,b,c)};l.pb=function(a,b){Gg(this,a,null,b)};
l.Wa=function(a,b,c){var d=S(a)+" removeById "+b+" "+c;I(this.logger,d);var e=this,f=a.a.j(function(g){g=yg(dg(g,b),c);J(e.logger,"success "+d+(0==g?" [not found]":""));P(a,g);f();f=null},this)};l.vb=function(a,b){I(this.logger,S(a)+" removeByKeys "+b.length+" keys");var c,d=0,e=a.a.j(function(f){for(var g=0;g<b.length;g++){var h=b[g].m,k=b[g].id;c&&c.getName()==h||(c=dg(f,h));d+=yg(c,k)}P(a,d);e();e=null},this)};l.hb=function(a,b,c){this.Xa(a,b,c)};
l.Xa=function(a,b,c){var d=S(a)+" removeByKeyRange "+(c?U(c):"");I(this.logger,d);var e=this,f=a.a.j(function(g){g=zg(dg(g,b),c);J(e.logger,d+" deleted "+g+" records.");P(a,g);f();f=null},this)};l.ub=function(a,b,c,d){var e=S(a)+" removeByIndexKeyRange "+(d?U(d):"");I(this.logger,e);var f=a.a.j(function(e){e=dg(e,b);for(var h=e.fa(c,d),k=h.length,m=0;m<k;m++)yg(e,h[m]);P(a,k);f();f=null},this)};
l.Ha=function(a,b){var c=S(a)+" clearByStores";I(this.logger,c);var d=a.a.j(function(e){for(var f=0;f<b.length;f++)dg(e,b[f]).clear();J(this.logger,"success "+c);P(a,b.length);d();d=null},this)};l.Ja=function(a,b){var c=a.a.j(function(d){for(var e=[],f=0;f<b.length;f++){var g=dg(d,b[f]);e.push(Ag(g))}P(a,e);c();c=null},this)};
l.ua=function(a,b,c,d){var e=S(a)+" count"+(null!=d?"Index":"")+(null!=c?"KeyRange":"Store");I(this.logger,e);var f=a.a.j(function(g){g=Ag(dg(g,b),d,c);J(this.logger,"success "+e);P(a,g);f();f=null},this)};l.R=function(a,b,c,d,e,f,g,h,k,m){var n=S(a)+" "+c+" "+(e?Ke(e):"");I(this.logger,n);var q=a.a.j(function(p){p=Bg(dg(p,c),b,d,e,h,f,g,k,m);J(this.logger,n+" "+p.length+" records found.");P(a,p);q();q=null},this)};function Hg(a,b){this.a=b}z(Hg,Fg);Hg.prototype.b=function(a,b,c,d){c=X(this.a,c);return new Wf(a,b,c,d)};function Ig(a,b,c,d){td.call(this,a,b,c,d);this.D=null;this.e=this.g=void 0}z(Ig,td);l=Ig.prototype;l.logger=G("ydn.db.core.req.WebsqlCursor");l.B=function(){return this.e};l.Bb=function(a,b,c,d,e){Ig.r.Bb.call(this,a,b,c,d,e);this.D=w(b)?vd(this.b,b):null};l.aa=function(){return this.o};
l.X=function(a){this.o=this.e=this.g=void 0;if(t(a))if(y(a)){var b=of(a[this.b.f],this.b.type);this.e=b;if(this.f){var c=vd(this.b,this.I);this.g=of(a[this.I],c.type)}else this.g=b;this.o=this.wa?b:Jg(a,this.b)}else this.o=a};
function Kg(a,b,c){vd(a.b,a.I);var d=[],e=a.I,f=a.p,g=a.g;if(null!=f){var h=f.lower,k=f.upper,m=f.lowerOpen,n=f.upperOpen;a.reverse?k=null!=k&&-1==L(k,g)?k:g:h=null!=h&&1==L(h,g)?h:g;null!=h&&null!=k?f=K.bound(h,k,!!m,!!n):f=null!=h?Tc.lowerBound(h,!!m):Tc.upperBound(k,!!n)}else f=a.reverse?Tc.upperBound(g):Tc.lowerBound(g);e=tf(a.b,d,a.u,e,f,a.reverse,a.unique);c=a.reverse?Tc.upperBound(c,!1):Tc.lowerBound(c,!1);c=tf(a.b,d,a.u,a.b.f,c,a.reverse,a.unique);e.n=e.n?e.n+(" AND "+c.n):c.n;c="SELECT "+
e.select+" FROM "+e.M+(e.n?" WHERE "+e.n:"")+(e.group?" GROUP BY "+e.group:"")+" ORDER BY "+e.P;c+=" LIMIT 1";I(a.logger,a+": continuePrimary: SQL: "+c+" : "+U(d));a.d.executeSql(c,d,function(c,d){0<d.rows.length?a.X(d.rows.item(0)):a.X();b.call(a,a.g,a.e,a.o);b=null},function(c,d){H(a.logger,"get error: "+d.message);wd(a,d);a.X();b.call(a,a.e,a.g,a.o);b=null;return!1})}
function Lg(a,b,c,d,e,f){var g=!d;d=[];a.f&&null!=f&&null!=c?c=wf(a.b,a.u,d,a.D.getName(),a.p,c,g,f,a.reverse,a.unique):null!=c?(f=a.D?a.D.getName():null,c=vf(a.b,a.u,d,f,a.p,a.reverse,a.unique,c,g)):(c=sf(a.b,d,a.u,a.f?a.D.d:a.b.f,a.p,a.reverse,a.unique),a.f&&(c+=", "+a.b.d+" ASC"));c+=" LIMIT 1";0<e&&(c+=" OFFSET "+e);I(a.logger,a+": continue: SQL: "+c+" : "+U(d));a.d.executeSql(c,d,function(c,d){0<d.rows.length?a.X(d.rows.item(0)):a.X();b.call(a,a.g,a.e,a.o);b=null},function(c,d){H(a.logger,"get error: "+
d.message);wd(a,d);a.X();b.call(a,a.e,a.g,a.o);b=null;return!1})}l.Qa=function(){return!!this.d};l.update=function(a){if(!this.Qa())throw new fe;var b=new B,c=this.B();a=zf(this.b,a,c);var d="REPLACE INTO "+uf(this.b)+" ("+a.Fb.join(", ")+") VALUES ("+a.Lb.join(", ")+")";I(this.logger,this+': update "'+d+'" : '+U(a.w));this.d.executeSql(d,a.w,function(){b.callback(c)},function(a,c){b.k(c);return!1});return b};
l.advance=function(a){var b=this.g,c=this.e,d=!0;null==this.g||this.f&&null==this.e||(a-=1,d=!1);Lg(this,function(a,d,g){var h=null!=b&&null!=a&&0==L(b,a);if(this.f){var k=null!=d&&null!=c&&0==L(d,c);if(h&&k)throw new Jb("current: "+b+";"+c+" next: "+a+";"+d);}else if(h)throw new Jb("current: "+b+" next: "+a);this.O(a,d,g)},this.g,d,a,this.e)};l.ja=function(a){null!=a?Lg(this,this.O,a,!0):this.advance(1)};l.openCursor=function(a,b){Lg(this,this.O,a,!1,0,b)};
l.clear=function(){if(!this.Qa())throw new fe;var a=new B,b=this.b.f,b="DELETE FROM "+uf(this.b)+" WHERE "+b+" = ?",c=[this.B()];I(this.logger,this+': clear "'+b+'" : '+U(c));this.d.executeSql(b,c,function(b,c){a.callback(c.rowsAffected)},function(b,c){a.k(c);return!1});return a};l.Da=function(a){var b=L(a,this.e);if(0==b||1==b&&this.reverse||-1==b&&!this.reverse)throw new Yd(this+" to continuePrimaryKey from "+this.e+" to "+a+" on "+this.Q+" direction is wrong");Kg(this,this.O,a)};
l.toString=function(){return"WebSql"+Ig.r.toString.call(this)};function Mg(a,b){this.a=b}z(Mg,ne);l=Mg.prototype;l.logger=G("ydn.db.crud.req.WebSql");
function Jg(a,b){if(b.ka&&!b.keyPath&&0==b.a.length&&a._default_){var c=a._default_;if(-1==c.indexOf(";base64,"))return bf(c);'"'==c.charAt(0)&&'"'==c.charAt(c.length-1)&&(c=c.substr(1,c.length-2));for(var d=c.split(";base64,"),c=d[0].split(":")[1],d=window.atob(d[1]),e=d.length,f=new Uint8Array(e),g=0;g<e;++g)f[g]=d.charCodeAt(g);return new Blob([f.buffer],{type:c})}c=a._default_?bf(a._default_):{};null!=b.keyPath&&(d=of(a[b.keyPath],b.type),null!=d&&We(b,c,d));for(d=0;d<b.a.length;d++)e=b.index(d),
f=e.d,"_default_"==f||e.e||e.multiEntry||"DATE"!=e.type&&!b.ka||(f=of(a[f],e.type),t(f)&&nf(e,c,f));return c}l.tb=function(){throw new Hb("putData");};
l.S=function(a,b,c,d,e,f){function g(b,d){if(null==e[b])if(I(m.logger,"empty object at "+b+" of "+e.length),q++,q==e.length)J(m.logger,p+" success "+p),P(a,n,r);else{var E=b+2;E<e.length&&g(E,d)}var D;D=t(f)?zf(h,e[b],f[b]):zf(h,e[b]);E=k+uf(h)+" ("+D.Fb.join(", ")+") VALUES ("+D.Lb.join(", ")+");";I(m.logger,S(a)+" SQL: "+E+" PARAMS: "+D.w+" REQ: "+b+" of "+e.length);d.executeSql(E,D.w,function(f,p){function E(b,c){var e="ydn.db.me:"+h.getName()+":"+b.getName(),e=k+Ha(e)+" ("+h.d+", "+b.c+") VALUES (?, ?)",
f=[Xc(aa,h.type),Xc(c,b.type)];I(m.logger,S(a)+" multiEntry "+e+" "+f);d.executeSql(e,f,function(){},function(a,b){H(m.logger,"multiEntry index insert error: "+b.message);return!1})}q++;var aa=t(D.key)?D.key:p.insertId;1>p.rowsAffected&&(r=!0,aa=new be(aa+" no-op"));for(var ib=0,Cd=h.a.length;ib<Cd;ib++){var rb=h.index(ib);if(rb.multiEntry)for(var Kb=Zc(e[b],rb.keyPath),di=(Kb?Kb.length:0)||0,Le=0;Le<di;Le++)E(rb,Kb[Le])}c?P(a,aa):(n[b]=aa,q==e.length?P(a,n,r):(ib=b+2,ib<e.length&&g(ib,f)))},function(d,
f){q++;r=!0;6==f.code?f.name="ConstraintError":H(m.logger,"error: "+f.message+" "+p);if(c)P(a,f,!0);else if(n[b]=f,q==e.length)I(m.logger,"success "+p),P(a,n,r);else{var h=b+2;h<e.length&&g(h,d)}return!1})}b=!b;var h=X(this.a,d),k=b?"INSERT INTO ":"INSERT OR REPLACE INTO ";d=a.a;var m=this,n=[],q=0,p=S(a)+" inserting "+e.length+" objects.",r=!1;if(0<e.length)for(b=0;2>b&&b<e.length;b++)g(b,d);else J(this.logger,"success"),P(a,[])};
l.sb=function(a,b,c){if(0==c.length)P(a,[]);else{for(var d=[],e=0,f=0,g=this,h=function(h,k){var m=[];I(g.logger,"put "+k.length+" objects to "+h);for(var n=yf(X(g.a,h)),q=n?void 0:[],p=0;p<k.length;p++)m.push(b[k[p]]),n||q.push(c[k[p]].id);n=Jd(a);yb(n,function(b){for(var c=0;c<k.length;c++)d[k[c]]=b[c];e++;e==f&&P(a,d)},function(){e++;e==f&&P(a,d,!0)});g.S(n,!1,!1,h,m,q)},k="",m=[],n=[],q=0;q<c.length;q++){var p=c[q].m,r=c[q].id;p!=k?(f++,0<m.length&&h(k,m),m=[q],n=[r],k=p):(m.push(q),n.push(r))}0<
m.length&&h(k,m)}};l.Na=function(a,b,c){var d=a.a,e=X(this.a,b),f=this;b=e.d;c=[Xc(c,e.type)];b="SELECT * FROM "+uf(e)+" WHERE "+b+" = ?";var g=S(a)+" SQL: "+b+" PARAMS: "+c;I(this.logger,g);d.executeSql(b,c,function(b,c){if(0<c.rows.length){var d=c.rows.item(0);null!=d?(d=Jg(d,e),P(a,d)):(J(f.logger,"success no result: "+g),P(a,void 0))}else J(f.logger,"success no result: "+g),P(a,void 0)},function(b,c){H(f.logger,"error: "+g+" "+c.message);P(a,c,!0);return!1})};
l.ob=function(a,b,c){function d(b,e){var q=k.d,p=[Xc(c[b],k.type)],r="SELECT * FROM "+uf(k)+" WHERE "+q+" = ?";I(f.logger,"SQL: "+r+" PARAMS: "+p);e.executeSql(r,p,function(e,f){h++;if(0<f.rows.length){var n=f.rows.item(0);null!=n&&(g[b]=Jg(n,k))}else g[b]=void 0;h==c.length?P(a,g):(n=b+10,n<c.length&&d(n,e))},function(e,k){h++;H(f.logger,"error: "+r+" "+k.message);if(h==c.length)P(a,g);else{var n=b+10;n<c.length&&d(n,e)}return!1})}var e=a.a,f=this,g=[],h=0,k=X(this.a,b);if(0<c.length)for(b=0;10>
b&&b<c.length;b++)d(b,e);else J(f.logger,"success"),P(a,[])};
l.pb=function(a,b){function c(d,h){var n=b[d],q=X(e.a,n.m),p=me(n),n=q.d,p=[Xc(p,q.type)],r="SELECT * FROM "+uf(q)+" WHERE "+n+" = ?";I(e.logger,"SQL: "+r+" PARAMS: "+p);h.executeSql(r,p,function(h,m){g++;if(0<m.rows.length){var n=m.rows.item(0);null!=n&&(f[d]=Jg(n,q))}else f[d]=void 0;g==b.length?(I(e.logger,"success "+r),P(a,f)):(n=d+10,n<b.length&&c(n,h))},function(b,c){P(a,c,!0);return!1})}var d=a.a,e=this,f=[],g=0;if(0<b.length)for(var h=0;10>h&&h<b.length;h++)c(h,d);else I(this.logger,"success"),
P(a,[])};
l.Ha=function(a,b){function c(d,g){function h(a){a="ydn.db.me:"+k.getName()+":"+a.getName();a="DELETE FROM "+Ha(a);I(e.logger,"SQL: "+a);g.executeSql(a,[])}var k=X(e.a,b[d]),m="DELETE FROM "+uf(k);I(e.logger,"SQL: "+m+" PARAMS: []");g.executeSql(m,[],function(g){d==b.length-1?(I(e.logger,"success "+m),P(a,b.length)):c(d+1,g)},function(b,c){P(a,c,!0);return!1});for(var n=0,q=k.a.length;n<q;n++){var p=k.index(n);p.multiEntry&&h(p)}}var d=a.a,e=this;0<b.length?c(0,d):(I(this.logger,"success"),P(a,
0))};
l.vb=function(a,b){function c(h){if(h>=b.length)P(a,f,g);else{var k=X(e.a,b[h].m),m=Xc(b[h].id,k.type),n=" WHERE "+k.d+" = ?",q="DELETE FROM "+uf(k)+n,p=S(a)+" SQL: "+q+" PARAMS: "+[m];d.executeSql(q,[m],function(){f++;c(h)},function(a,b){H(e.logger,"error: "+p+b.message);g=!0;c(h);return!1});h++;for(var q=function(b){b="ydn.db.me:"+k.getName()+":"+b.getName();b="DELETE FROM "+Ha(b)+n;I(e.logger,S(a)+NaN+b);d.executeSql(b,[m])},r=0,x=k.a.length;r<x;r++){var A=k.index(r);A.multiEntry&&q(A)}}}var d=
a.a,e=this,f=0,g=!1;I(this.logger,S(a)+" removeByKeys: "+b.length+" keys");c(0)};
l.Wa=function(a,b,c){function d(b){b="ydn.db.me:"+f.getName()+":"+b.getName();b="DELETE FROM "+Ha(b)+k;I(h.logger,S(a)+NaN+b);e.executeSql(b,[g])}var e=a.a,f=X(this.a,b),g=Xc(c,f.type),h=this,k=" WHERE "+f.d+" = ?";b="DELETE FROM "+uf(f)+k;I(this.logger,S(a)+" SQL: "+b+" PARAMS: "+[g]);e.executeSql(b,[g],function(b,c){P(a,c.rowsAffected)},function(b,c){P(a,c,!0);return!1});b=0;for(c=f.a.length;b<c;b++){var m=f.index(b);m.multiEntry&&d(m)}};l.hb=function(a,b,c){Ng(this,a,b,void 0,c)};
l.Xa=function(a,b,c){Ng(this,a,b,void 0,c)};l.ub=function(a,b,c,d){Ng(this,a,b,c,d)};
function Ng(a,b,c,d,e){function f(c){c="ydn.db.me:"+h.getName()+":"+c.getName();c="DELETE FROM "+Ha(c)+n;I(a.logger,S(b)+NaN+c);g.executeSql(c,m)}var g=b.a,h=X(a.a,c);c="DELETE FROM "+uf(h);var k=[],m=[],n="";null!=e&&(t(d)?(d=vd(h,d),Wc(d.c,d.type,e,m,k)):Wc(h.d,h.type,e,m,k),n=" WHERE "+m.join(" AND "));c+=n;var q=S(b)+" SQL: "+c+" PARAMS: "+k;I(a.logger,q);g.executeSql(c,k,function(c,d){I(a.logger,"success "+q);P(b,d.rowsAffected)},function(c,d){H(a.logger,"error: "+q+d.message);P(b,d,!0);return!1});
e=0;for(d=h.a.length;e<d;e++)c=h.index(e),c.multiEntry&&f(c)}l.Ja=function(a,b){function c(g){var h="SELECT COUNT(*) FROM "+Ha(b[g]);I(e.logger,"SQL: "+h+" PARAMS: []");d.executeSql(h,[],function(d,e){var h=e.rows.item(0);f[g]=parseInt(h["COUNT(*)"],10);g++;g==b.length?P(a,f):c(g)},function(b,c){P(a,c,!0);return!1})}var d=a.a,e=this,f=[];0==b.length?(I(this.logger,"success"),P(a,0)):c(0)};
l.ua=function(a,b,c,d,e){var f=[];b=sf(X(this.a,b),f,6,d,c,!1,e);I(this.logger,S(a)+" SQL: "+b+" PARAMS: "+f);a.a.executeSql(b,f,function(b,c){var d=c.rows.item(0);P(a,Gf(d))},function(b,c){P(a,c,!0);return!1})};
l.R=function(a,b,c,d,e,f,g,h,k,m){var n=this,q=[],p=X(this.a,c),r=p.f,x=p.type,A=x,E=null!=d&&d!==r?vd(p,d):null,D=d||r;E&&(A=E.type);c=[];if(m&&t(m[0])){var F=m[0];E&&t(m[1])?(d=m[1],e=wf(p,b,c,E.getName(),e,F,!0,d,h,k)):e=vf(p,b,c,d,e,h,k,F,!0)}else e=sf(p,c,b,D,e,h,k);ea(f)&&(e+=" LIMIT "+f);ea(g)&&(e+=" OFFSET "+g);var R=a+" SQL: "+e+" ;params= "+U(c);I(this.logger,R);a.a.executeSql(e,c,function(c,d){for(var e=d.rows.length,f,g=0;g<e;g++)f=d.rows.item(g),2==b?q[g]=of(f[r],x):1==b?q[g]=of(f[D],
A):3==b?q[g]=[of(f[D],A),of(f[r],x)]:null!=f&&(q[g]=Jg(f,p));J(n.logger,"success "+a);m&&f&&(m[0]=of(f[D],A),m[1]=of(f[r],x));P(a,q)},function(b,c){H(n.logger,"error: "+R+c.message);P(a,c,!0);return!1})};function Og(a,b){this.a=b}z(Og,Mg);Og.prototype.logger=G("ydn.db.core.req.WebSql");Og.prototype.b=function(a,b,c,d){c=X(this.a,c);return new Ig(a,b,c,d)};Rf.prototype.l=function(){var a=this.ta();if("indexeddb"==a)return new Uf(0,this.a);if("websql"==a||"sqlite"==a)return new Og(0,this.a);if("memory"==a||"localstorage"==a||"userdata"==a||"sessionstorage"==a)return new Hg(0,this.a);throw new Jb("No executor for "+a);};function Pg(a){if(!w(a))throw new Qd;this.G=a;this.d=M;this.a=[];Qg(this,a);this.za=""}l=Pg.prototype;l.G="";l.Hb=NaN;l.Ib=NaN;l.xb=!1;l.za="";
function Qg(a,b){var c=b.split(/\sFROM\s/i);if(2==c.length){var d=c[1],c=c[0].match(/\s*?(SELECT|INSERT|UPDATE|DELETE)\s+(.*)/i);if(3==c.length){a.f=c[1].toUpperCase();if("SELECT"==a.f)a.d=nd;else if("INSERT"==a.f)a.d=M;else if("UPDATE"==a.f)a.d=M;else if("DELETE"==a.f)a.d=M;else return;var c=c[2].trim(),e=c.match(/^(MIN|MAX|COUNT|AVG|SUM)/i);e?(a.c=e[0].toUpperCase(),c=c.replace(/^(MIN|MAX|COUNT|AVG|SUM)/i,"").trim()):a.c=void 0;"("==c.charAt(0)&&(")"==c.charAt(c.length-1)?c=c.substring(1,c.length-
1):new je("missing closing parentheses"));a.i=c;c=d.search(/(ORDER BY|LIMIT|OFFSET)/i);0<c?(a.b=d.substring(c),d=d.substring(0,c)):a.b="";c=d.search(/WHERE/i);0<c?(a.e=d.substring(c+6).trim(),d=d.substring(0,c)):a.e="";a.a=d.trim().split(",").map(function(a){a=Ea(a,'"');a=Ea(a,"'");return a.trim()})}}}
function Rg(a,b){if(b){for(var c=0;c<b.length;c++)a.G=a.G.replace("?",b[c]);Qg(a,a.G)}a.g=Sg(a);if(!a.g)return a.za;var c=a.b.length,d=/OFFSET\s+(\d+)/i.exec(a.b);d&&(a.Ib=parseInt(d[1],10),c=a.b.search(/OFFSET/i));if(d=/LIMIT\s+(\d+)/i.exec(a.b))a.Hb=parseInt(d[1],10),d=a.b.search(/LIMIT/i),d<c&&(c=d);(c=/ORDER BY\s+(.+)/i.exec(a.b.substr(0,c)))?(c=c[1].trim(),(d=c.match(/(ASC|DESC)/i))?(a.xb="DESC"==d[0].toUpperCase(),c=c.replace(/\s+(ASC|DESC)/i,"")):a.xb=!1,a.h=Ea(Ea(c,'"'),"'")):a.h=void 0;return""}
function Tg(a){if("*"==a.i)return null;a=a.i.split(",");return a=a.map(function(a){return Ea(a.trim(),'"')})}l.toJSON=function(){return{sql:this.G}};
function Sg(a){function b(a){return ob(c,function(b){return b.ea==a})}var c=[],d=/(.+?)(<=|>=|=|>|<)(.+)/i;if(0<a.e.length)for(var e=a.e.split("AND"),f=0;f<e.length;f++){var g=e[f],h=d.exec(g);if(h){var k=h[1].trim(),k=Ea(k,'"'),k=Ea(k,"'");if(0<k.length){var m=h[3].trim();0==m.lastIndexOf('"',0)?m=Ea(m,'"'):0==m.lastIndexOf("'",0)?m=Ea(m,"'"):m=parseFloat(m);h=new kd(k,h[2],m);k=b(k);if(0<=k){if(c[k]=c[k].ba(h),!c[k])return a.za='where clause "'+g+'" conflict',null}else c.push(h)}else return a.za=
'Invalid clause "'+g+'"',null}else return a.za='Invalid clause "'+g+'"',null}return c}l.toString=function(){return"query:"+this.G};function Ug(a,b){this.a=b;this.c=a}Ug.prototype.logger=G("ydn.db.sql.req.nosql.Node");Ug.prototype.toJSON=function(){return{sql:this.a}};Ug.prototype.toString=function(){return"idb.Node:"};
Ug.prototype.b=function(a,b){var c=sb(this.a.a)[0],d=this.a.g,e=this.a.Hb,e=isNaN(e)?100:e,f=this.a.Ib,f=isNaN(f)?0:f,g=this.a.h,h=Tg(this.a),k=null,m=this.a.xb;if(0==d.length)k=null;else if(1==d.length)k=Rc(d[0].a);else throw new Gb("too many conditions.");null===h||Md(a,function(a,b,c){var d=a;b||(d=a.map(function(a){var b=h.length;if(1==b)return Zc(a,h[0]);for(var c={},d=0;d<b;d++)c[h[d]]=Zc(a,h[d]);return c}));c(d,b)});var d=0<d.length?d[0].ea:void 0,n=S(a)+" executing on"+c;d&&(n+=":"+d);n+=
" "+Vc(k);J(this.logger,n);g&&g!=this.c.keyPath?b.R(a,4,c,g,k,e,f,m,!1):t(d)&&d!=this.c.keyPath?b.R(a,4,c,d,k,e,f,m,!1):b.R(a,4,c,null,k,e,f,m,!1)};function Vg(a,b){Ug.call(this,a,b)}z(Vg,Ug);
Vg.prototype.b=function(a,b){var c,d=sb(this.a.a)[0],e=this.a.g,f=null;if(0==e.length)f=null;else if(1==e.length)f=Rc(e[0].a);else throw new Gb("too many conditions.");var g=this.a.c,e=0<e.length?e[0].ea:void 0,h=S(a)+" executing "+g+" on "+d;e&&(h+=":"+e);h+=" "+Vc(f);J(this.logger,h);if("COUNT"==g)f?b.ua(a,d,f,e,!1):b.ua(a,d,null,void 0,!1);else{var k,h=Tg(this.a);if(!h||0==h.length)throw new Yd("field name require for reduce operation: "+g);h=h[0];if("MIN"==g)k=Wg(h);else if("MAX"==g)k=Xg(h);else if("AVG"==
g)c=0,k=Yg(h);else if("SUM"==g)c=0,k=Zg(h);else throw new Ff(g);var m;t(e)?m=new Hd(d,e,f):m=new Gd(d,f);var d=b.b(a.a,S(a),d,4),n=m.load([d]);n.l=function(b){P(a,b,!0)};var q=0;n.i=function(b){null!=b?(b=m.a?n.B():n.aa(),c=k(b,c,q),n.advance(1),q++):P(a,c)}}};function Yg(a){return function(b,c,d){t(c)||(c=0);return(c*d+b[a])/(d+1)}}function Zg(a){return function(b,c){return c+b[a]}}function Wg(a){return function(b,c){var d=b[a];return t(c)?c<d?c:d:d}}
function Xg(a){return function(b,c){var d=b[a];return t(c)?c>d?c:d:d}};function $g(a,b){this.a=b}z($g,Uf);$g.prototype.logger=G("ydn.db.sql.req.IndexedDb");$g.prototype.executeSql=function(a,b,c){if(c=Rg(b,c))throw new je(c);c=sb(b.a);if(1==c.length){var d=X(this.a,c[0]);if(!d)throw new ge(c[0]);var e=Tg(b);if(e)for(var f=0;f<e.length;f++)if(!Pe(d,e[f]))throw new ge('Index "'+e[f]+'" not found in '+c[0]);var g;b.c?g=new Vg(d,b):g=new Ug(d,b);g.b(a,this)}else throw new Ff(b.G);};function ah(a,b){this.b=b;this.d=a;this.a=Tg(b)}ah.prototype.logger=G("ydn.db.sql.req.websql.Node");ah.prototype.toJSON=function(){return{sql:this.b.G}};ah.prototype.toString=function(){return"websql.Node:"};function bh(a,b){if(a.a){if(1==a.a.length){if(y(b))return Nb(b,a.a[0]);return}for(var c={},d=0;d<a.a.length;d++)c[a.a[d]]=Nb(b,a.a[d]);return c}return Jg(b,a.d)}
ah.prototype.c=function(a,b,c){var d=this,e=[];b.executeSql(this.b.G,c,function(b,c){for(var h=c.rows.length,k=0;k<h;k++){var m=c.rows.item(k);if(y(m))var n=bh(d,m);e.push(n)}a(e)},function(b,c){H(d.logger,"Sqlite error: "+c.message);a(c,!0);return!0})};function ch(a,b){ah.call(this,a,b)}z(ch,ah);ch.prototype.c=function(a,b,c){var d=this;b.executeSql(this.b.G,c,function(b,c){var d=c.rows.length;if(1==d)d=Gf(c.rows.item(0)),a(d);else if(0==d)a(void 0);else throw new ee;},function(b,c){H(d.logger,"Sqlite error: "+c.message);a(c,!0);return!0})};function dh(a,b){this.a=b}z(dh,Og);dh.prototype.logger=G("ydn.db.sql.req.WebSql");dh.prototype.executeSql=function(a,b,c){var d=sb(b.a);if(1==d.length){var e=X(this.a,d[0]);if(!e)throw new ge(d[0]);var f=Tg(b);if(f)for(var g=0;g<f.length;g++)if(!Pe(e,f[g]))throw new ge('Index "'+f[g]+'" not found in '+d[0]);var h;b.c?h=new ch(e,b):h=new ah(e,b);h.c(function(b,c){P(a,b,c)},a.a,c)}else throw new Ff(b.G);};function eh(a,b){this.a=b}z(eh,Hg);eh.prototype.logger=G("ydn.db.sql.req.SimpleStore");eh.prototype.executeSql=function(a,b,c){if(c=Rg(b,c))throw new je(c);c=sb(b.a);if(1==c.length){var d=X(this.a,c[0]);if(!d)throw new ge(c[0]);var e=Tg(b);if(e)for(var f=0;f<e.length;f++)if(!Pe(d,e[f]))throw new C('Index "'+e[f]+'" not found in '+c[0]);var g;b.c?g=new Vg(d,b):g=new Ug(d,b);g.b(a,this)}else throw new Gb(b.G);};function fh(a,b,c){ze.call(this,a,b,c)}z(fh,Ze);fh.prototype.executeSql=function(a,b){for(var c=new Pg(a),d=sb(c.a),e=0;e<d.length;e++){var f=X(this.b,d[e]);if(!f)throw new C("store: "+f+" not exists.");}J(this.logger,"executeSql: "+a+" params: "+b);var g=this.a.request("sql",sb(c.a),c.d);Q(g,function(){W(this).executeSql(g,c,b||[])},this);return g};function gh(a,b,c){Y.call(this,a,b,c)}z(gh,Rf);gh.prototype.la=function(a){return new fh(this,this.a,a)};gh.prototype.executeSql=function(a,b){return this.c.executeSql(a,b)};gh.prototype.l=function(){var a=this.ta();if("indexeddb"==a)return new $g(0,this.a);if("websql"==a||"sqlite"==a)return new dh(0,this.a);if("memory"==a||"localstorage"==a||"sessionstorage"==a)return new eh(0,this.a);throw new Jb("No executor for "+a);};function hh(a,b){t(a)&&5242880<a&&Lc(this.logger,yc,"storage size request ignored, use Quota Management API instead");this.q=null;this.ya=b||NaN}l=hh.prototype;
l.ra=function(a,b){function c(a,c,d){J(e.logger,(d?"changing":"upgrading")+" version to "+a.version+" from "+g);for(d=0;d<b.stores.length;d++)ih(e,a,c,b.stores[d]);c=a.objectStoreNames;var f=c.length;for(d=0;d<f;d++)Je(b,c[d])||(a.deleteObjectStore(c[d]),J(e.logger,"store: "+c[d]+" deleted."))}function d(a,b){f.c?H(e.logger,"database already set."):t(b)?(H(e.logger,b?b.message:"Error received."),e.q=null,f.k(b)):(e.q=a,e.q.onabort=function(a){I(e.logger,e+": abort");e.Ca(a.target.error)},e.q.onerror=
function(a){I(e.logger,e+": error");e.Ca(a.target.error)},e.q.onversionchange=function(a){I(e.logger,e+" closing connection for onversionchange to: "+a.version);if(e.q&&(e.q.onabort=null,e.q.onblocked=null,e.q.onerror=null,e.q.onversionchange=null,e.Ua(a),!a.defaultPrevented)){e.q.close();e.q=null;var b=Error();b.name=a.type;e.bb(b)}},f.callback(parseFloat(g)))}var e=this,f=new B,g=void 0,h=b.version;Lc(this.logger,Cc,"Opening database: "+a+" ver: "+(b.b?"auto":h));var k;k=t(h)?pd.open(a,h):pd.open(a);
k.onsuccess=function(f){var h=f.target.result;t(g)||(g=h.version);Lc(e.logger,Cc,"Database: "+h.name+", ver: "+h.version+" opened.");if(b.b)e.K(function(f){if(b instanceof Ee)for(var g=0;g<f.stores.length;g++)Je(b,f.stores[g].getName())||Fe(b,f.stores[g].clone());f=Ef(b,f,!1,!0);if(0<f.length){Lc(e.logger,Cc,"Schema change require for difference in "+f);var k=ea(h.version)?h.version+1:1;if("IDBOpenDBRequest"in s){h.close();var m=pd.open(a,k);m.onupgradeneeded=function(a){a=a.target.result;Lc(e.logger,
Cc,"re-open for version "+a.version);c(a,m.transaction,!1)};m.onsuccess=function(a){d(a.target.result)};m.onerror=function(){Lc(e.logger,Cc,e+": fail.");d(null)}}else{var q=h.setVersion(k+"");q.a=function(a){H(e.logger,"migrating from "+h.version+" to "+k+" failed.");d(null,a)};q.onsuccess=function(){q.transaction.oncomplete=D;c(h,q.transaction,!0)};var D=function(){var b=pd.open(a);b.onsuccess=function(a){a=a.target.result;Lc(e.logger,Cc,e+": OK.");d(a)};b.onerror=function(){Lc(e.logger,Cc,e+": fail.");
d(null)}};null!=q.transaction&&(q.transaction.oncomplete=D)}}else d(h)},void 0,h);else if(b.version>h.version){var k=h.setVersion(b.version);k.a=function(a){H(e.logger,"migrating from "+h.version+" to "+b.version+" failed.");d(null,a)};k.onsuccess=function(){c(h,k.transaction,!0)}}else b.version==h.version?Lc(e.logger,Cc,"database version "+h.version+" ready to go"):H(e.logger,"connected database version "+h.version+" is higher than requested version."),e.K(function(a){a=Ef(b,a,!1,!0);0<a.length?
(Lc(e.logger,Cc,a),d(null,new He("different schema: "+a))):d(h)},void 0,h)};k.onupgradeneeded=function(a){a=a.target.result;g=NaN;Lc(this.logger,Cc,"upgrade needed for version "+a.version);c(a,k.transaction,!1)};k.onerror=function(c){Mc(e.logger,'open request to database "'+a+'" '+(t(b.version)?" with version "+b.version:"")+" cause error of "+k.error.name);d(null,c)};k.onblocked=function(c){Mc(e.logger,"database "+a+" "+b.version+" block, close other connections.");d(null,c)};ea(this.ya)&&!isNaN(this.ya)&&
setTimeout(function(){"done"!=k.readyState&&(Mc(e.logger,e+": database state is still "+k.readyState),d(null,new ke("connection timeout after "+e.ya)))},this.ya);return f};l.ya=18E4;l.bb=function(){};l.Ca=function(){};l.Ua=function(){};l.sa=function(){return"indexeddb"};l.zb=function(){return this.q||null};l.ab=function(){return!!this.q};l.logger=G("ydn.db.con.IndexedDb");l.q=null;l.$a=function(){return this.q?parseFloat(this.q.version):void 0};
l.K=function(a,b,c){c=c||this.q;if(t(b)){if(null===b){if(0==c.objectStoreNames.length){a(new Df(c.version));return}throw new Ud;}c=b.db}else{b=[];for(var d=c.objectStoreNames.length-1;0<=d;d--)b[d]=c.objectStoreNames[d];if(0==b.length){a(new Df(c.version));return}b=c.transaction(b,nd)}for(var e=c.objectStoreNames,f=[],g=e.length,d=0;d<g;d++){for(var h=b.objectStore(e[d]),k=[],m=0,n=h.indexNames.length;m<n;m++){var q=h.index(h.indexNames[m]);k[m]=new jf(q.keyPath,void 0,q.unique,q.multiEntry,q.name)}f[d]=
new Be(h.name,h.keyPath,h.autoIncrement,void 0,k)}b=new Df(c.version,f);a(b)};
function ih(a,b,c,d){function e(){var a={autoIncrement:!!d.b};null!=d.keyPath&&(a.keyPath=d.keyPath);return b.createObjectStore(d.getName(),a)}Lc(a.logger,Dc,"Creating Object Store for "+d.getName()+" keyPath: "+d.keyPath);if(b.objectStoreNames.contains(d.getName())){c=c.objectStore(d.getName());qf(d.keyPath||"",c.keyPath||"")?(b.deleteObjectStore(d.getName()),Lc(a.logger,yc,"store: "+d.getName()+" deleted due to keyPath change."),c=e()):da(c.autoIncrement)&&da(d.b)&&c.autoIncrement!=d.b&&(b.deleteObjectStore(d.getName()),
Lc(a.logger,yc,"store: "+d.getName()+" deleted due to autoIncrement change."),c=e());for(var f=c.indexNames,g=0;g<d.a.length;g++){var h=d.index(g);!f.contains(h.getName())&&h.f&&(c.clear(),Lc(a.logger,yc,"store: "+d.getName()+" cleared since generator index need re-indexing."))}for(var k=0,m=0,n=0,g=0;g<d.a.length;g++){var h=d.index(g),q=!1;if(f.contains(h.getName())){var p=c.index(h.getName()),r=null!=p.unique&&null!=h.unique&&p.unique!=h.unique,x=null!=p.multiEntry&&null!=h.multiEntry&&p.multiEntry!=
h.multiEntry,p=null!=p.keyPath&&null!=h.keyPath&&!!qf(p.keyPath,h.keyPath);if(r||x||p)c.deleteIndex(h.getName()),q=!0,k--,n++}else"BLOB"!=h.type&&(q=!0);q&&(h.unique||h.multiEntry?(q={unique:h.unique,multiEntry:h.multiEntry},c.createIndex(h.getName(),h.keyPath,q)):c.createIndex(h.getName(),h.keyPath),k++)}for(g=0;g<f.length;g++)Pe(d,f[g])||(c.deleteIndex(f[g]),m++);Lc(a.logger,Dc,"Updated store: "+c.name+", "+k+" index created, "+m+" index deleted, "+n+" modified.")}else{c=e();for(g=0;g<d.a.length;g++)h=
d.index(g),"BLOB"==h.type?Lc(a.logger,zc,"Index "+h+" of blob data type ignored."):(Lc(a.logger,Dc,"Creating index: "+h),h.unique||h.multiEntry?(q={unique:h.unique,multiEntry:h.multiEntry},c.createIndex(h.getName(),h.keyPath,q)):c.createIndex(h.getName(),h.keyPath));Lc(a.logger,Dc,"Created store: "+c)}}
l.La=function(a,b,c,d){var e=this.q;if(!b){b=[];for(var f=e.objectStoreNames.length-1;0<=f;f--)b[f]=e.objectStoreNames[f]}0==b.length?a(null):(b=e.transaction(b,c),b.oncomplete=function(a){d("complete",a)},b.onabort=function(a){d("abort",a)},a(b),a=null)};l.close=function(){Lc(this.logger,Dc,this+" closing connection");this.q.close()};l.toString=function(){return"IndexedDB:"+(this.q?this.q.name+":"+this.q.version:"")};
Od.push(function(a,b){if(!pd||b&&"indexeddb"!=b)return null;var c=pd.deleteDatabase(a),d=new O("IDBVersionChangeEvent ");c.onblocked=function(a){for(var b=0;b<d.e.length;b++)d.e[b][0].call(d.e[b][1],a)};c.onerror=function(a){d.k(a)};c.onsuccess=function(a){d.callback(a)};return d});function jh(a){Dg.call(this,a);this.b=NaN}z(jh,Dg);l=jh.prototype;l.logger=G("ydn.db.con.SimpleStorage");l.$a=function(){return this.b};
l.ra=function(a,b){function c(a,b){setTimeout(function(){b?(J(d.logger,d+" opening fail"),e.k(b)):(J(d.logger,d+" version "+d.$a()+" open"),e.callback(a))},10)}var d=this,e=new B;this.c=this.e.ib(a);this.d=a;this.a=b;var f=fg(this.d);this.b=NaN;var g=bf(this.c.getItem(f));t(g.version)&&!ea(g.version)&&(g.version=NaN);if(g)if(g=new Df(g),Ef(this.a,g,!1,!1))if(!this.a.b&&!isNaN(g.version)&&this.a.version>g.version)c(NaN,new de("existing version "+g.version+" is larger than "+this.a.version));else{var h=
this.a.version;this.b=t(h)?h:g.version+1;for(h=0;h<this.a.count();h++)var k=this.a.stores[h]||null;if(this.a instanceof Ee)for(h=0;h<g.count();h++)k=g.stores[h]||null,Fe(this.a,k);h=this.a.toJSON();h.version=this.b||NaN;this.c.setItem(f,U(h));c(g.version||NaN)}else{for(h=0;h<this.a.count();h++)k=this.a.stores[h]||null;this.b=g.version||NaN;c(this.b)}else g=b.toJSON(),this.b=1,g.version=this.b,this.c.setItem(f,U(g)),c(NaN);return e};l.ab=function(){return!!this.d};l.zb=function(){return this.c||null};
l.bb=function(){};l.Ca=function(){};l.Ua=function(){};l.sa=function(){return"memory"};l.close=function(){};l.La=function(a,b,c,d){a(new Eg(this,function(a,b){d(a,b)}))};l.toString=function(){return"SimpleStorage:"+this.sa()+":"+(this.d+":"+this.b)};function kh(){jh.call(this,this)}z(kh,jh);kh.prototype.ib=function(){return window.localStorage};kh.prototype.sa=function(){return"localstorage"};Od.push(function(a,b){if(!b||"localstorage"==b){var c=new kh,d=new Ee;c.ra(a,d);c.K(function(a){for(var b=0;b<a.stores.length;b++)dg(c,a.stores[b].getName()).clear()})}});function lh(){jh.call(this,this)}z(lh,jh);lh.prototype.ib=function(){return window.sessionStorage};lh.prototype.sa=function(){return"sessionstorage"};
Od.push(function(a,b){if(!b||"sessionstorage"==b){var c=new lh,d=new Ee;c.ra(a,d);c.K(function(a){for(var b=0;b<a.stores.length;b++)dg(c,a.stores[b].getName()).clear()})}});function mh(a,b){this.a=t(a)?a:4194304;this.b=b||"websql"}l=mh.prototype;
l.ra=function(a,b){function c(b,c){var f=b.version?parseInt(b.version,10):0,g=c.b?isNaN(f)?1:f+1:c.version;Nc(e.logger,a+": changing version from "+b.version+" to "+g);var h=!1,k=0;b.changeVersion(b.version,g+"",function(a){e.K(function(b){h=!0;for(var d=0;d<c.count();d++){var f=X(b,(c.stores[d]||null).getName()),f=f?xf(f,c.stores[d]||null):null;nh(e,a,c.stores[d]||null,function(a){a&&k++},f)}for(d=0;d<b.count();d++)f=b.stores[d]||null,Je(c,f.getName())||(c instanceof Ee?Fe(c,f):(f="DROP TABLE "+
uf(f),J(e.logger,f),a.executeSql(f,[],function(){},function(a,b){throw b;})))},a,b)},function(c){Mc(e.logger,"SQLError "+c+" "+c.code+"("+c.message+") while changing version from "+b.version+" to "+g+" on "+a);throw c;},function(){if(h){var f=".";k!=c.stores.length&&(f=" but unexpected stores exists.");I(e.logger,a+":"+b.version+" ready"+f);d(b)}else H(e.logger,a+": changing version voided.")})}function d(a,b){t(b)?(e.t=null,g.k(b)):(e.t=a,g.callback(parseFloat(f)))}var e=this,f=NaN,g=new B,h=null;
try{"sqlite"==this.b?s.sqlitePlugin?(h=s.sqlitePlugin.openDatabase(a,"",a,this.a),h.readTransaction||(h.readTransaction=h.transaction),h.changeVersion=function(a,b,c,d,e){h.transaction(c,d,e)}):(H(this.logger,"sqlitePlugin not found."),h=null,this.cb=Error("sqlitePlugin not found.")):h=s.openDatabase(a,"",a,this.a)}catch(k){if("SECURITY_ERR"==k.name)H(this.logger,"SECURITY_ERR for opening "+a),h=null,this.cb=new ie(k);else throw k;}if(h){var f=h.version||"",m="database "+a+(0==f.length?"":" version "+
h.version);null!=b.version&&b.version==h.version?(Nc(e.logger,"Existing "+m+" opened as requested."),d(h)):this.K(function(a){(a=Ef(b,a,!0,!1))?(0==f?Nc(e.logger,"New "+m+" created."):b.b?Nc(e.logger,"Existing "+m+" opened and schema change for "+a):Nc(e.logger,"Existing "+m+" opened and schema change to version "+b.version+" for "+a),c(h,b)):(Nc(e.logger,"Existing "+m+" with same schema opened."),d(h))},null,h)}else d(null,this.cb);return g};l.sa=function(){return this.b};l.cb=null;l.t=null;
l.zb=function(){return this.t||null};l.logger=G("ydn.db.con.WebSql");l.bb=function(){};l.Ca=function(){};
function oh(a){var b=a.l,c="CREATE TABLE IF NOT EXISTS "+uf(a)+" (",d=a.d,c=c+(d+" "+b+" PRIMARY KEY ");a.b&&(c+=" AUTOINCREMENT ");if(!a.ka||!a.keyPath&&0==a.a.length)c+=" ,_default_ BLOB";for(var e=[],f=[d],g=0,h=a.a.length;g<h;g++){var k=a.index(g),m="";if(k.multiEntry){var m="ydn.db.me:"+a.getName()+":"+k.getName(),n=k.unique?" UNIQUE ":"",k="CREATE TABLE IF NOT EXISTS "+Ha(m)+" ("+d+" "+b+", "+k.c+" "+k.g+n+")";e.push(k)}else k.unique&&(m=" UNIQUE "),n=k.keyPath,"BLOB"!=k.type&&w(n)&&(n="CREATE "+
m+" INDEX IF NOT EXISTS "+Ha(a.getName()+"-"+k.getName())+" ON "+uf(a)+" ("+k.c+")",e.push(n)),n=k.c,-1==f.indexOf(n)&&(c+=", "+n+" "+k.g+m,f.push(n))}e.unshift(c+")");return e}l.$a=function(){return this.t?parseFloat(this.t.version):void 0};
l.K=function(a,b,c){function d(a,b){throw b;}function e(b,c){if(c&&c.rows){for(var d=0;d<c.rows.length;d++){var e=c.rows.item(d);if("__WebKitDatabaseInfoTable__"!=e.name&&"sqlite_sequence"!=e.name&&"table"==e.type){var p="sql"in e?e.sql:void 0;I(f.logger,"Parsing table schema from SQL: "+p);for(var r=p.substr(p.indexOf("("),p.lastIndexOf(")")).match(/(?:"[^"]*"|[^,])+/g),x=void 0,A,p=[],E=!1,D=!1,F=0;F<r.length;F++){var R=r[F].match(/\w+|"[^"]+"/g),V=lb(R,function(a){return a.toUpperCase()}),aa=Ea(R[0],
'"'),R=kf(V[1]);if(-1!=V.indexOf("PRIMARY")&&-1!=V.indexOf("KEY")){A=R;if(w(aa)&&!ta(aa)&&"_ROWID_"!=aa){var ib=aa.split(","),x=aa;1<ib.length&&(x=ib,A=void 0)}-1!=V.indexOf("AUTOINCREMENT")&&(E=!0)}else if("_ROWID_"!=aa)if("_default_"==aa)D=!0;else{var Cd="UNIQUE"==V[2];0==aa.lastIndexOf(e.tbl_name+"-",0)&&(aa=aa.substr(e.tbl_name.length+1));V=new jf(aa,R,Cd);p.push(V)}}if(0==e.name.lastIndexOf("ydn.db.me:",0)){var rb=e.name.split(":");if(3<=rb.length){var Kb=rb[1],x=new jf(rb[2],R,Cd,!0),r=ob(p,
function(a){return a.getName()==rb[2]});0<=r?p[r]=x:p.push(x);r=ob(h,function(a){return a.getName()===Kb});0<=r?(F=h[r],h[r]=new Be(F.getName(),F.keyPath,E,A,p,void 0,!D)):h.push(new Be(Kb,void 0,!1,void 0,[x]));I(f.logger,'multi entry index "'+x.getName()+'" found in '+Kb+(-1==r?"*":""))}else H(f.logger,'Invalid multiEntry store name "'+e.name+'"')}else F=ob(h,function(a){return a.getName()===e.name}),0<=F?(r=h[F].index(0),p.push(r),h[F]=new Be(e.name,x,E,A,p,void 0,!D)):(p=new Be(e.name,x,E,A,p,
void 0,!D),h.push(p))}}d=new Df(g,h);a(d)}}var f=this,g=(c=c||this.t)&&c.version?parseFloat(c.version):void 0,g=isNaN(g)?void 0:g,h=[];b?b.executeSql("SELECT * FROM sqlite_master",[],e,d):c.readTransaction(function(b){f.K(a,b,c)},function(a){Mc(f.logger,"opening tx: "+a.message);throw a;},e)};
function nh(a,b,c,d,e){function f(a){b.executeSql(a,[],function(){g++;g==h.length&&(d(!0),d=null)},function(b,e){g++;g==h.length&&(d(!1),d=null);var f="SQLError creating table: "+c.getName()+" "+e.message+' for executing "'+a;throw new he(e,f);})}var g=0,h=oh(c),k="Create";if(e){e=De(c,e);if(0==e.length){I(a.logger,"same table "+c.getName()+" exists.");d(!0);d=null;return}k="Modify";H(a.logger,"table: "+c.getName()+" has changed by "+e+" ALTER TABLE cannot run in WebSql, dropping old table.");h.unshift("DROP TABLE IF EXISTS "+
Ha(c.getName()))}I(a.logger,k+" table: "+c.getName()+": "+h.join(";"));for(a=0;a<h.length;a++)f(h[a])}l.ab=function(){return!!this.t};l.close=function(){this.t=null};
l.La=function(a,b,c,d){function e(a){I(h.logger,h+": Tx "+c+" request cause error.");d("abort",a)}function f(){d("complete",{type:"complete"})}function g(b){a(b)}var h=this;null===this.t&&(a(null),d("abort",this.cb));c==nd?this.t.readTransaction(g,e,f):c==od?this.t.changeVersion(this.t.version,this.t.version+1+"",g,e,f):this.t.transaction(g,e,f)};
Od.push(function(a,b){if(fa(s.openDatabase)&&(!b||"websql"==b)){var c=new mh,d=new Ee;J(c.logger,"deleting websql database: "+a);var d=c.ra(a,d),e=function(){var b=c.logger;b&&b.log(zc,"all tables in "+a+" deleted.",void 0)};d.C(function(){c.La(function(b){b.executeSql('SELECT * FROM sqlite_master WHERE type = "table"',[],function(d,e){if(e&&e.rows){for(var k=e.rows.length,m=0,n=0;n<k;n++){var q=e.rows.item(n);"__WebKitDatabaseInfoTable__"!=q.name&&"sqlite_sequence"!=q.name&&(m++,I(c.logger,"deleting table: "+
q.name),b.executeSql("DROP TABLE "+q.name))}J(c.logger,m+' tables deleted from "'+a+'"')}},function(a,b){throw b;})},[],M,e)});d.Db(function(){H(c.logger,"Connecting "+a+" failed.")})}});mh.prototype.Ua=function(){};mh.prototype.toString=function(){return"WebSql:"+(this.t?":"+this.t.version:"")};Pf.prototype.jb=function(a){return"indexeddb"==a&&pd?new hh(this.h,this.v):"sqlite"==a&&s.sqlitePlugin?new mh(this.h,"sqlite"):"websql"==a&&fa(s.openDatabase)?new mh(this.h):"localstorage"==a&&window.localStorage?new kh:"sessionstorage"==a&&window.sessionStorage?new lh:"memory"==a?new jh:null};function ph(a,b){qd.call(this);this.d=b;this.b=[];if(a>this.d)throw Error("[goog.structs.SimplePool] Initial cannot be greater than max");for(var c=0;c<a;c++)this.b.push(this.a())}z(ph,qd);ph.prototype.a=function(){return{}};ph.prototype.c=function(a){if(y(a))if(fa(a.kb))a.kb();else for(var b in a)delete a[b]};ph.prototype.$=function(){ph.r.$.call(this);for(var a=this.b;a.length;)this.c(a.pop());delete this.b};function qh(){this.a=[];this.c=new Ub;this.d=new Ub;this.e=1;this.f=new ph(0,4E3);this.f.a=function(){return new rh};this.g=new ph(0,50);this.g.a=function(){return new sh};var a=this;this.b=new ph(0,2E3);this.b.a=function(){return String(a.e++)};this.b.c=function(){}}G("goog.debug.Trace");function sh(){this.time=this.count=0}sh.prototype.toString=function(){var a=[];a.push(this.type," ",this.count," (",Math.round(10*this.time)/10," ms)");return a.join("")};function rh(){}
function th(a,b,c){var d=[];-1==b?d.push(" "):d.push(uh(a.b-b));d.push(" ",vh(a.b-0));0==a.a?d.push(" Start "):1==a.a?(d.push(" Done "),d.push(uh(a.f-a.startTime)," ms ")):d.push(" Comment ");d.push(c,a);0<a.d&&d.push("[VarAlloc ",a.d,"] ");return d.join("")}rh.prototype.toString=function(){return null==this.type?this.c:"["+this.type+"] "+this.c};
qh.prototype.toString=function(){for(var a=[],b=-1,c=[],d=0;d<this.a.length;d++){var e=this.a[d];1==e.a&&c.pop();a.push(" ",th(e,b,c.join("")));b=e.b;a.push("\n");0==e.a&&c.push("| ")}if(0!=this.c.mb()){var f=ma();a.push(" Unstopped timers:\n");Tb(this.c,function(b){a.push(" ",b," (",f-b.startTime," ms, started at ",vh(b.startTime),")\n")})}b=this.d.fa();for(d=0;d<b.length;d++)c=this.d.get(b[d]),1<c.count&&a.push(" TOTAL ",c,"\n");a.push("Total tracers created ",0,"\n","Total comments created ",
0,"\n","Overhead start: ",0," ms\n","Overhead end: ",0," ms\n","Overhead comment: ",0," ms\n");return a.join("")};function uh(a){a=Math.round(a);var b="";1E3>a&&(b=" ");100>a&&(b=" ");10>a&&(b=" ");return b+a}function vh(a){a=Math.round(a);return String(100+a/1E3%60).substring(1,3)+"."+String(1E3+a%1E3).substring(1,4)}new qh;var wh=!cc||cc&&9<=nc,xh=cc&&!lc("9");!ec||lc("528");dc&&lc("1.9b")||cc&&lc("8")||bc&&lc("9.5")||ec&&lc("528");dc&&!lc("8")||cc&&lc("9");function yh(a){yh[" "](a);return a}yh[" "]=function(){};function zh(a,b){df.call(this,a?a.type:"");this.a=this.target=null;this.clientY=this.clientX=0;this.b=null;if(a){this.type=a.type;this.target=a.target||a.srcElement;this.a=b;var c=a.relatedTarget;if(c&&dc)try{yh(c.nodeName)}catch(d){}this.clientX=void 0!==a.clientX?a.clientX:a.pageX;this.clientY=void 0!==a.clientY?a.clientY:a.pageY;this.b=a;a.defaultPrevented&&this.preventDefault()}}z(zh,df);
zh.prototype.preventDefault=function(){zh.r.preventDefault.call(this);var a=this.b;if(a.preventDefault)a.preventDefault();else if(a.returnValue=!1,xh)try{if(a.ctrlKey||112<=a.keyCode&&123>=a.keyCode)a.keyCode=-1}catch(b){}};var Ah="closure_listenable_"+(1E6*Math.random()|0),Bh=0;function Ch(a,b,c,d,e){this.ga=a;this.a=null;this.src=b;this.type=c;this.Fa=!!d;this.Pa=e;this.key=++Bh;this.oa=this.Ea=!1}function Dh(a){a.oa=!0;a.ga=null;a.a=null;a.src=null;a.Pa=null};function Eh(a){this.src=a;this.a={};this.b=0}Eh.prototype.add=function(a,b,c,d,e){var f=a.toString();a=this.a[f];a||(a=this.a[f]=[],this.b++);var g=Fh(a,b,d,e);-1<g?(b=a[g],c||(b.Ea=!1)):(b=new Ch(b,this.src,f,!!d,e),b.Ea=c,a.push(b));return b};function Gh(a,b){var c=b.type;c in a.a&&qb(a.a[c],b)&&(Dh(b),0==a.a[c].length&&(delete a.a[c],a.b--))}function Fh(a,b,c,d){for(var e=0;e<a.length;++e){var f=a[e];if(!f.oa&&f.ga==b&&f.Fa==!!c&&f.Pa==d)return e}return-1};var Hh="closure_lm_"+(1E6*Math.random()|0),Ih={},Jh=0;function Kh(a,b,c,d,e){if(u(b))for(var f=0;f<b.length;f++)Kh(a,b[f],c,d,e);else c=Lh(c),a&&a[Ah]?a.Z.add(String(b),c,!1,d,e):Mh(a,b,c,!1,d,e)}function Mh(a,b,c,d,e,f){if(!b)throw Error("Invalid event type");var g=!!e,h=Nh(a);h||(a[Hh]=h=new Eh(a));c=h.add(b,c,d,e,f);c.a||(d=Oh(),c.a=d,d.src=a,d.ga=c,a.addEventListener?a.addEventListener(b.toString(),d,g):a.attachEvent(Ph(b.toString()),d),Jh++)}
function Oh(){var a=Qh,b=wh?function(c){return a.call(b.src,b.ga,c)}:function(c){c=a.call(b.src,b.ga,c);if(!c)return c};return b}function Rh(a,b,c,d,e){if(u(b))for(var f=0;f<b.length;f++)Rh(a,b[f],c,d,e);else c=Lh(c),a&&a[Ah]?a.Z.add(String(b),c,!0,d,e):Mh(a,b,c,!0,d,e)}
function Sh(a,b,c,d,e){if(u(b))for(var f=0;f<b.length;f++)Sh(a,b[f],c,d,e);else(c=Lh(c),a&&a[Ah])?(a=a.Z,b=String(b).toString(),b in a.a&&(f=a.a[b],c=Fh(f,c,d,e),-1<c&&(Dh(f[c]),hb.splice.call(f,c,1),0==f.length&&(delete a.a[b],a.b--)))):a&&(a=Nh(a))&&(b=a.a[b.toString()],a=-1,b&&(a=Fh(b,c,!!d,e)),(c=-1<a?b[a]:null)&&Th(c))}
function Th(a){if(!ea(a)&&a&&!a.oa){var b=a.src;if(b&&b[Ah])Gh(b.Z,a);else{var c=a.type,d=a.a;b.removeEventListener?b.removeEventListener(c,d,a.Fa):b.detachEvent&&b.detachEvent(Ph(c),d);Jh--;(c=Nh(b))?(Gh(c,a),0==c.b&&(c.src=null,b[Hh]=null)):Dh(a)}}}function Ph(a){return a in Ih?Ih[a]:Ih[a]="on"+a}function Uh(a,b,c,d){var e=1;if(a=Nh(a))if(b=a.a[b.toString()])for(b=b.concat(),a=0;a<b.length;a++){var f=b[a];f&&f.Fa==c&&!f.oa&&(e&=!1!==Vh(f,d))}return Boolean(e)}
function Vh(a,b){var c=a.ga,d=a.Pa||a.src;a.Ea&&Th(a);return c.call(d,b)}
function Qh(a,b){if(a.oa)return!0;if(!wh){var c=b||ba("window.event"),d=new zh(c,this),e=!0;if(!(0>c.keyCode||void 0!=c.returnValue)){a:{var f=!1;if(0==c.keyCode)try{c.keyCode=-1;break a}catch(g){f=!0}if(f||void 0==c.returnValue)c.returnValue=!0}c=[];for(f=d.a;f;f=f.parentNode)c.push(f);for(var f=a.type,h=c.length-1;0<=h;h--)d.a=c[h],e&=Uh(c[h],f,!0,d);for(h=0;h<c.length;h++)d.a=c[h],e&=Uh(c[h],f,!1,d)}return e}return Vh(a,new zh(b,this))}function Nh(a){a=a[Hh];return a instanceof Eh?a:null}
var Wh="__closure_events_fn_"+(1E9*Math.random()>>>0);function Lh(a){return fa(a)?a:a[Wh]||(a[Wh]=function(b){return a.handleEvent(b)})};function Xh(){qd.call(this);this.Z=new Eh(this);this.b=this;this.a=null}z(Xh,qd);Xh.prototype[Ah]=!0;Xh.prototype.addEventListener=function(a,b,c,d){Kh(this,a,b,c,d)};Xh.prototype.removeEventListener=function(a,b,c,d){Sh(this,a,b,c,d)};Xh.prototype.$=function(){Xh.r.$.call(this);if(this.Z){var a=this.Z,b=0,c;for(c in a.a){for(var d=a.a[c],e=0;e<d.length;e++)++b,Dh(d[e]);delete a.a[c];a.b--}}this.a=null};
function Yh(a,b,c,d){b=a.Z.a[String(b)];if(!b)return!0;b=b.concat();for(var e=!0,f=0;f<b.length;++f){var g=b[f];if(g&&!g.oa&&g.Fa==c){var h=g.ga,k=g.Pa||g.src;g.Ea&&Gh(a.Z,g);e=!1!==h.call(k,d)&&e}}return e&&!1!=d.Kb};/*
Copyright 2012 YDN Authors, Yathit. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");.
*/
function Zh(a){a.e||(a.e=new Xh);return a.e}Pf.prototype.addEventListener=function(a,b,c,d){if("ready"==a)Rh(Zh(this),a,b,c,d);else{var e="created error fail ready deleted updated versionchange".split(" "),f=function(a){if(!(0<=jb(e,a)))throw new C('Invalid event type "'+a+'"');};if(v(a))for(var g=0;g<a.length;g++)f(a[g]);else f(a);Kh(Zh(this),a,b,c,d)}};Pf.prototype.removeEventListener=function(a,b,c,d){Sh(Zh(this),a,b,c,d)};
Pf.prototype.H=function(a){var b=Zh(this),c,d=b.a;if(d)for(c=[];d;d=d.a)c.push(d);b=b.b;d=a.type||a;if(w(a))a=new df(a,b);else if(a instanceof df)a.target=a.target||b;else{var e=a;a=new df(d,b);Pb(a,e)}var e=!0,f;if(c)for(var g=c.length-1;0<=g;g--)f=a.a=c[g],e=Yh(f,d,!0,a)&&e;f=a.a=b;e=Yh(f,d,!0,a)&&e;e=Yh(f,d,!1,a)&&e;if(c)for(g=0;g<c.length;g++)f=a.a=c[g],e=Yh(f,d,!1,a)&&e};function $h(a,b,c){Y.call(this,a,b,c)}z($h,gh);function ai(a,b){$d.call(this,a,b)}z(ai,$d);ai.prototype.e=function(){return!1};ai.prototype.c=function(a,b){function c(b){t(a[b])?(e=!1,d[b]=!0):(d[b]=!1,0<=b-1&&c(b-1))}var d=[],e=!0;c(a.length-1);e&&(d=[]);return ae(this,d,b)};function bi(a,b){$d.call(this,a,b)}z(bi,$d);
bi.prototype.c=function(a,b){var c=[],d=b[0];if(null==d)return[];for(var e=!0,f=!1,g=d,h=[],k=1;k<a.length;k++)if(null!=b[k]){var m=L(d,b[k]);h[k]=m;this.b?-1==m?e=!1:1==m&&(e=!1,f=!0,-1==L(b[k],g)&&(g=b[k])):1==m?e=!1:-1==m&&(e=!1,f=!0,1==L(b[k],g)&&(g=b[k]))}else e=!1,f=!0;if(e)for(f=0;f<a.length;f++)null!=b[f]&&(c[f]=!0);else if(f)for(f=0;f<a.length;f++)null!=b[f]&&(this.b?-1==L(g,b[f])&&(c[f]=g):1==L(g,b[f])&&(c[f]=g));else for(k=this.b?-1:1,f=1;f<a.length;f++)h[f]===k&&(c[f]=d);return e?(this.f++,
this.a&&this.a.push(g),c):{continuePrimary:c}};function ci(a,b){$d.call(this,a,b)}z(ci,$d);ci.prototype.logger=G("ydn.db.algo.ZigzagMerge");
ci.prototype.c=function(a,b){function c(a,b){var c=a.slice(0,a.length-1);c.push(b);return c}function d(a){return a[a.length-1]}var e=[];if(0==a.length||null==a[0]||null==a[0])return[];for(var f=!0,g=0,h=d(a[g]),k=[],m=1;m<a.length;m++)if(null!=a[m]){var n=d(a[m]),q=L(h,n);k[m]=q;this.b?-1==q?f=!1:1==q&&(f=!1,h=n,g=1):1==q?f=!1:-1==q&&(f=!1,h=n,g=1)}else return[];m=this.b?-1:1;if(f){for(f=0;f<a.length;f++)null!=a[f]&&(e[f]=!0);this.a&&(this.d?this.a.push(b[0],h):this.a.push(b[0]));return e}if(0==g)for(f=
1;f<a.length;f++)k[f]==m&&(e[f]=c(a[f],h));else for(f=0;f<a.length;f++)f!=g&&null!=a[f]&&L(h,d(a[f]))===m&&(e[f]=c(a[f],h));return{"continue":e}};na("ydn.db.algo.NestedLoop",ai);na("ydn.db.algo.ZigzagMerge",ci);na("ydn.db.algo.SortedMerge",bi);T.prototype.close=T.prototype.close;T.prototype.getType=T.prototype.ta;T.prototype.getName=T.prototype.getName;T.prototype.getSchema=T.prototype.D;T.prototype.onReady=T.prototype.Ta;T.prototype.setName=T.prototype.o;T.prototype.transaction=T.prototype.transaction;T.prototype.db=T.prototype.lc;na("ydn.db.version","1.0.3");na("ydn.db.cmp",L);na("ydn.db.deleteDatabase",function(a,b){for(var c,d=0;d<Od.length;d++){var e=Od[d](a,b);e&&(c=e)}return c||Nd("IDBVersionChangeEvent ",null)});
ff.prototype.name=ff.prototype.name;ff.prototype.getVersion=ff.prototype.oc;ff.prototype.getOldVersion=ff.prototype.Vb;ff.prototype.getOldSchema=ff.prototype.Ub;gf.prototype.getError=gf.prototype.c;O.prototype.abort=O.prototype.abort;O.prototype.canAbort=O.prototype.Sb;O.prototype.progress=O.prototype.Va;O.prototype.promise=O.prototype.kc;Rf.prototype.scan=Rf.prototype.mc;Rf.prototype.map=Rf.prototype.map;Rf.prototype.reduce=Rf.prototype.eb;Rf.prototype.open=Rf.prototype.open;Ze.prototype.scan=Ze.prototype.Ab;Ze.prototype.map=Ze.prototype.map;Ze.prototype.reduce=Ze.prototype.eb;Ze.prototype.open=Ze.prototype.open;td.prototype.getKey=td.prototype.nc;td.prototype.getPrimaryKey=td.prototype.B;td.prototype.getValue=td.prototype.aa;td.prototype.update=td.prototype.update;td.prototype.clear=td.prototype.clear;na("ydn.db.Iterator",N);
na("ydn.db.KeyIterator",Ed);na("ydn.db.ValueIterator",Gd);na("ydn.db.IndexIterator",Fd);na("ydn.db.IndexValueIterator",Hd);N.prototype.getState=N.prototype.Wb;N.prototype.getKeyRange=N.prototype.Nb;N.prototype.getIndexName=N.prototype.bc;N.prototype.getStoreName=N.prototype.ec;N.prototype.isReversed=N.prototype.V;N.prototype.isUnique=N.prototype.qa;N.prototype.isKeyIterator=N.prototype.fc;N.prototype.isIndexIterator=N.prototype.Xb;N.prototype.getPrimaryKey=N.prototype.dc;N.prototype.getKey=N.prototype.cc;
N.prototype.resume=N.prototype.Ob;N.prototype.reset=N.prototype.wb;N.prototype.reverse=N.prototype.reverse;Ed.where=function(a,b,c,d,e){return new Ed(a,Yc(b,c,d,e))};Gd.where=function(a,b,c,d,e){return new Gd(a,Yc(b,c,d,e))};Fd.where=function(a,b,c,d,e,f){return new Fd(a,b,Yc(c,d,e,f))};Hd.where=function(a,b,c,d,e,f){return new Hd(a,b,Yc(c,d,e,f))};na("ydn.db.Streamer",Vd);Vd.prototype.push=Vd.prototype.push;Vd.prototype.collect=Vd.prototype.X;Vd.prototype.setSink=Vd.prototype.ac;Pf.prototype.branch=Pf.prototype.Rb;Pf.prototype.getTxNo=Pf.prototype.qc;ze.prototype.getTxNo=ze.prototype.pc;Pf.prototype.run=Pf.prototype.Zb;Y.prototype.branch=Y.prototype.Rb;Y.prototype.add=Y.prototype.add;Y.prototype.get=Y.prototype.get;Y.prototype.keys=Y.prototype.keys;Y.prototype.values=Y.prototype.w;Y.prototype.put=Y.prototype.put;Y.prototype.clear=Y.prototype.clear;Y.prototype.remove=Y.prototype.fb;Y.prototype.count=Y.prototype.count;Ie.prototype.add=Ie.prototype.add;Ie.prototype.get=Ie.prototype.get;Ie.prototype.keys=Ie.prototype.keys;Ie.prototype.values=Ie.prototype.w;Ie.prototype.put=Ie.prototype.put;Ie.prototype.clear=Ie.prototype.clear;
Ie.prototype.remove=Ie.prototype.fb;Ie.prototype.count=Ie.prototype.count;na("ydn.db.Key",le);le.prototype.id=le.prototype.Tb;le.prototype.parent=le.prototype.gc;le.prototype.storeName=le.prototype.hc;na("ydn.db.KeyRange",K);K.upperBound=K.upperBound;K.lowerBound=K.lowerBound;K.bound=K.bound;K.only=K.only;K.starts=Sc;ef.prototype.store_name=ef.prototype.m;ef.prototype.getStoreName=ef.prototype.b;Ue.prototype.name=Ue.prototype.name;Ue.prototype.getKey=Ue.prototype.c;Ue.prototype.getValue=Ue.prototype.d;
Re.prototype.name=Re.prototype.name;Re.prototype.getKeys=Re.prototype.fa;Re.prototype.getValues=Re.prototype.Oa;function ei(a,b,c){this.db=a;this.b=b;this.type=c||0;this.c=null};function fi(a,b,c,d){this.c=a;this.a=b||null;this.e=!!c;this.f=!!d;this.b=[];this.d=[]}function gi(a,b){for(var c=b.length-1;0<=c;c--)if(b[c]==a.b[a.b.length-1])b=b.slice(0,c);else break;a.d=b;return null}function hi(a,b){if((0!=a.b.length||0!=a.d.length)&&ii(a)&&!ji(a))throw new be('Require index "'+a.b.concat(a.d).join(", ")+'" not found in store "'+a.c.getName()+'"');var c=new N(a.c.getName(),ki(a),a.a,a.e,a.f,!!b);c.o=a.b.length;return c}
fi.prototype.clone=function(){var a=new fi(this.c,this.a,this.e,this.f);a.d=this.d.slice();a.b=this.b.slice();return a};function ji(a){var b=a.b.concat(a.d),c=ud(a.c,b);return c||b[b.length-1]==a.c.keyPath&&(c=ud(a.c,b.slice(0,b.length-1)))?c:null}function ki(a){return(a=ji(a))?a.getName():void 0}fi.prototype.reverse=function(){var a=this.clone();a.e=!this.e;return a};fi.prototype.unique=function(a){var b=this.clone();b.f=!!a;return b};
function ii(a){return 0<a.b.length?!0:1==a.d.length?a.d[0]!=a.c.keyPath:1<a.d.length?!0:!1}
fi.prototype.n=function(a,b,c,d,e){c=Yc(b,c,d,e);if(0<this.b.length)if(this.a)if(null!=this.a.lower&&null!=this.a.upper&&0==L(this.a.lower,this.a.upper))a=u(this.a.lower)?this.a.lower.slice().push(b):[this.a.lower,b],d=null!=d?d:"\uffff",c=u(this.a.upper)?this.a.upper.slice().push(d):[this.a.upper,d],this.a=Yc(b,a,d,c);else if(1==this.b.length&&this.b[0]==a||u(a)&&tb(this.b,a))this.a=this.a.ba(c);else return"cannot use where clause with existing filter";else return"cannot use where clause with existing filter";
else this.b=u(a)?a:[a],this.a=this.a?this.a.ba(c):c;return null};function li(a,b,c,d){ei.call(this,a,b,c);this.a=d}z(li,ei);li.prototype.open=function(){var a={push:function(){}},a=mi(this)?new ci(a):new bi(a);return this.db.Ab(a,ni(this),M)};function ni(a){for(var b=[],c=0;c<a.a.length;c++)b[c]=hi(a.a[c]);return b}function mi(a){for(var b=0;b<a.a.length;b++)if(0<a.a[b].b.length)return!0;return!1}li.prototype.nb=function(){return this.a.slice()};li.prototype.select=function(){throw Error("not impl");};
li.prototype.reverse=function(){var a=this.a.map(function(a){return a.reverse()});return new li(this.db,this.b,this.type,a)};function $(a,b,c,d){ei.call(this,a,b,c);this.a=d}z($,ei);l=$.prototype;l.ic=function(){return new $(this.db,this.b,this.type,this.a.clone())};l.reverse=function(){var a=this.a.reverse();return new $(this.db,this.b,this.type,a)};l.unique=function(a){if(!da(a))throw new C("unique value must be a boolean, but "+typeof a+" found");a=this.a.unique(a);return new $(this.db,this.b,this.type,a)};
l.P=function(a){var b=w(a)?[a]:a;a=this.a.clone();if(b=gi(a,b))throw Error(b);return new $(this.db,this.b,this.type,a)};
l.n=function(a,b,c,d,e){if(ki(this.a)&&ki(this.a)!=a){var f=Yc(b,c,d,e),f=new fi(X(this.b,this.a.c.getName()),f,this.a.e,this.a.f);return this.ba(new $(this.db,this.b,this.type,f))}if(!ki(this.a)&&!Pe(X(this.b,this.a.c.getName()),a))throw new C('index "'+a+'" not exists in '+this.a.c.getName());f=this.a.clone();if(a=f.n(a,b,c,d,e))throw new C(a);return new $(this.db,this.b,this.type,f)};
l.select=function(a){var b=X(this.b,this.a.c.getName()),c=w(a)?[a]:a,d=this.type;a=this.a.clone();d=ki(this.a);if(1==c.length)if(d=c[0],"_ROWID_"==d||d==b.keyPath)d=2;else if(d&&"*"!=d)if(Pe(b,d)){if(b=gi(a,c))throw new C(b);d=1}else throw new C('Invalid select "'+d+'", index not found in store "'+b.getName()+'"');else d=4;else if(2==c.length){if(!d)throw new C("Only primary key can be selected for this query.");for(var e=0;2>e;e++){var f;if(f="_ROWID_"!=c[e]){f=b;var g=c[e];f=!(t(f.keyPath)&&(1==
f.e.length?f.keyPath===g:v(g)&&tb(f.e,g)))}if(f&&c[e]!=d)throw new C('select field name must be "'+d+'", but "'+c[e]+'" found.');}d=3}else throw new C("Selecting more than 2 field names is not supported, but "+c.length+" fields selected.");return new $(this.db,this.b,d,a)};l.jc=function(a){a=a||100;var b=4,c=oi(this);this.c&&this.c[0]&&(c=c.Ob(this.c[0],this.c[1]));if(2==this.type||3==this.type||1==this.type)b=this.type;a=cf(this.db,b,c,a);a.C(function(){"rest"==c.f&&(this.c=[c.g,c.h])},this);return a};
l.nb=function(){return[this.a.clone()]};function oi(a){return hi(a.a,!(2==a.type||3==a.type||1==a.type))}
l.Yb=function(a,b){var c=oi(this);c.a&&(c=new N(c.c,c.d,c.b,c.V(),c.qa(),!1,c.e));if(1>arguments.length)throw new C("too few arguments");if(2==arguments.length){if(!w(a)&&u(a)){if(!u(b))throw new C("an array is expected for second argument but, "+Ke(b)+" of type "+typeof b+" found");if(a.length!=b.length)throw new C("length of two input arguments must be equal but, "+a.length+" and "+b.length+" found");}}else if(1==arguments.length){if(!y(a))throw new C("an object is expected but, "+Ke(a)+" of type "+
typeof a+" found");}else throw new C("too many arguments");var d=this.db.open(function(c){var f=c.aa();if(w(a))$c(f,a,b);else if(u(a))for(var g=0;g<a.length;g++)$c(f,a[g],b[g]);else if(y(a))for(g in a)a.hasOwnProperty(g)&&(f[g]=a[g]);zb(d,c.update(f))},c,M,this);return d};l.open=function(a,b){return this.db.open(a,oi(this),M,b)};l.count=function(){return ii(this.a)?this.a.f?this.db.count(hi(this.a)):this.db.count(this.a.c.getName(),ki(this.a),this.a.a):this.db.count(this.a.c.getName(),this.a.a)};
l.clear=function(){return ii(this.a)?this.db.clear(this.a.c.getName(),ki(this.a),this.a.a):this.db.clear(this.a.c.getName(),this.a.a)};l.ba=function(a){a=a.nb().concat(this.nb());return new li(this.db,this.b,this.type,a)};
Rf.prototype.M=function(a,b,c,d,e){if(!w(a))throw new TypeError('store name "'+a+'"');if(!Je(this.a,a))throw new C('Store "'+a+'" not found.');var f=null;if(t(b)){if(!t(c))throw new C("boundary value must be defined.");f=Yc(b,c,d,e)}else if(t(d))throw new C("second boundary must not be defined.");a=new fi(X(this.a,a),f);return new $(this.c,this.a,null,a)};
Ze.prototype.M=function(a,b,c,d,e){if(!w(a))throw new TypeError('store name "'+a+'"');if(!Je(this.b,a))throw new C('Store "'+a+'" not found.');var f=null;if(t(b)){if(!t(c))throw new C("boundary value must be defined.");f=Yc(b,c,d,e)}else if(t(d))throw new C("second boundary must not be defined.");a=new fi(X(this.b,a),f);return new $(this,this.b,null,a)};G("ydn.db.query.ConjunctionCursor");$.prototype.copy=$.prototype.ic;$.prototype.count=$.prototype.count;$.prototype.list=$.prototype.jc;$.prototype.order=$.prototype.P;$.prototype.patch=$.prototype.Yb;$.prototype.reverse=$.prototype.reverse;$.prototype.unique=$.prototype.unique;$.prototype.where=$.prototype.n;Rf.prototype.from=Rf.prototype.M;Ze.prototype.from=Ze.prototype.M;gh.prototype.executeSql=gh.prototype.executeSql;fh.prototype.executeSql=fh.prototype.executeSql;Pf.prototype.addEventListener=Pf.prototype.addEventListener;Pf.prototype.removeEventListener=Pf.prototype.removeEventListener;function pi(){this.a=ma()}var qi=new pi;pi.prototype.get=function(){return this.a};function ri(a){this.d=a||"";this.f=qi}ri.prototype.a=!0;ri.prototype.b=!1;function si(a){a=new Date(a.e);return ti(a.getFullYear()-2E3)+ti(a.getMonth()+1)+ti(a.getDate())+" "+ti(a.getHours())+":"+ti(a.getMinutes())+":"+ti(a.getSeconds())+"."+ti(Math.floor(a.getMilliseconds()/10))}function ti(a){return 10>a?"0"+a:String(a)}function ui(a,b){var c=(a.e-b)/1E3,d=c.toFixed(3),e=0;if(1>c)e=2;else for(;100>c;)e++,c*=10;for(;0<e--;)d=" "+d;return d}function vi(a){ri.call(this,a)}z(vi,ri);vi.prototype.b=!0;
vi.prototype.c=function(a){var b;switch(a.f.value){case wc.value:b="dbg-sh";break;case xc.value:b="dbg-sev";break;case yc.value:b="dbg-w";break;case zc.value:b="dbg-i";break;default:b="dbg-f"}var c=[];c.push(this.d," ");this.a&&c.push("[",si(a),"] ");c.push("[",Da(ui(a,this.f.get())),"s] ");c.push("[",va(a.c),"] ");c.push('<span class="',b,'">',ua(Da(va(a.d))));this.b&&a.b&&c.push("<br>",ua(Da(a.a||"")));c.push("</span>");c.push("<br>");return c.join("")};function wi(a){ri.call(this,a)}z(wi,ri);
wi.prototype.c=function(a){var b=[];b.push(this.d," ");this.a&&b.push("[",si(a),"] ");b.push("[",ui(a,this.f.get()),"s] ");b.push("[",a.c,"] ");b.push(a.d);this.b&&a.b&&b.push("\n",a.a);b.push("\n");return b.join("")};function xi(){this.f=ka(this.e,this);this.a=new wi;this.a.a=!1;this.b=this.a.b=!1;this.c="";this.d={}}xi.prototype.e=function(a){if(!this.d[a.c]){var b=this.a.c(a),c=yi;if(c)switch(a.f){case wc:zi(c,"info",b);break;case xc:zi(c,"error",b);break;case yc:zi(c,"warn",b);break;default:zi(c,"debug",b)}else window.opera?window.opera.postError(b):this.c+=b}};var yi=window.console;function zi(a,b,c){if(a[b])a[b](c);else a.log(c)};var Ai=!cc||cc&&9<=nc;!dc&&!cc||cc&&cc&&9<=nc||dc&&lc("1.9.1");cc&&lc("9");function Bi(a,b){Mb(b,function(b,d){"style"==d?a.style.cssText=b:"class"==d?a.className=b:"for"==d?a.htmlFor=b:d in Ci?a.setAttribute(Ci[d],b):0==d.lastIndexOf("aria-",0)||0==d.lastIndexOf("data-",0)?a.setAttribute(d,b):a[d]=b})}var Ci={cellpadding:"cellPadding",cellspacing:"cellSpacing",colspan:"colSpan",frameborder:"frameBorder",height:"height",maxlength:"maxLength",role:"role",rowspan:"rowSpan",type:"type",usemap:"useMap",valign:"vAlign",width:"width"};
function Di(a,b,c){function d(c){c&&b.appendChild(w(c)?a.createTextNode(c):c)}for(var e=2;e<c.length;e++){var f=c[e];!v(f)||y(f)&&0<f.nodeType?d(f):kb(Ei(f)?sb(f):f,d)}}function Ei(a){if(a&&"number"==typeof a.length){if(y(a))return"function"==typeof a.item||"string"==typeof a.item;if(fa(a))return"function"==typeof a.item}return!1}function Fi(a){this.a=a||s.document||document}
function Gi(a,b){var c;c=a.a;var d=b&&"*"!=b?b.toUpperCase():"";c.querySelectorAll&&c.querySelector&&d?c=c.querySelectorAll(d+""):c=c.getElementsByTagName(d||"*");return c}
Fi.prototype.b=function(a,b,c){var d=this.a,e=arguments,f=e[0],g=e[1];if(!Ai&&g&&(g.name||g.type)){f=["<",f];g.name&&f.push(' name="',va(g.name),'"');if(g.type){f.push(' type="',va(g.type),'"');var h={};Pb(h,g);delete h.type;g=h}f.push(">");f=f.join("")}f=d.createElement(f);g&&(w(g)?f.className=g:u(g)?f.className=g.join(" "):Bi(f,g));2<e.length&&Di(d,f,e);return f};
Fi.prototype.contains=function(a,b){if(a.contains&&1==b.nodeType)return a==b||a.contains(b);if("undefined"!=typeof a.compareDocumentPosition)return a==b||Boolean(a.compareDocumentPosition(b)&16);for(;b&&a!=b;)b=b.parentNode;return b==a};function Hi(a){this.f=ka(this.e,this);this.b=new vi;this.c=this.b.a=!1;this.a=a;this.d=this.a.ownerDocument||this.a.document;a=(a=this.a)?new Fi(9==a.nodeType?a:a.ownerDocument||a.document):ra||(ra=new Fi);var b=null,c=a.a;cc&&c.createStyleSheet?(a=b=c.createStyleSheet(),cc&&t(a.cssText)?a.cssText=".dbg-sev{color:#F00}.dbg-w{color:#C40}.dbg-sh{font-weight:bold;color:#000}.dbg-i{color:#444}.dbg-f{color:#999}.dbg-ev{color:#0A0}.dbg-m{color:#990}.logmsg{border-bottom:1px solid #CCC;padding:2px}.logsep{background-color: #8C8;}.logdiv{border:1px solid #CCC;background-color:#FCFCFC;font:medium monospace}":
a.innerHTML=".dbg-sev{color:#F00}.dbg-w{color:#C40}.dbg-sh{font-weight:bold;color:#000}.dbg-i{color:#444}.dbg-f{color:#999}.dbg-ev{color:#0A0}.dbg-m{color:#990}.logmsg{border-bottom:1px solid #CCC;padding:2px}.logsep{background-color: #8C8;}.logdiv{border:1px solid #CCC;background-color:#FCFCFC;font:medium monospace}"):(c=Gi(a,"head")[0],c||(b=Gi(a,"body")[0],c=a.b("head"),b.parentNode.insertBefore(c,b)),a=b=a.b("style"),cc&&t(a.cssText)?a.cssText=".dbg-sev{color:#F00}.dbg-w{color:#C40}.dbg-sh{font-weight:bold;color:#000}.dbg-i{color:#444}.dbg-f{color:#999}.dbg-ev{color:#0A0}.dbg-m{color:#990}.logmsg{border-bottom:1px solid #CCC;padding:2px}.logsep{background-color: #8C8;}.logdiv{border:1px solid #CCC;background-color:#FCFCFC;font:medium monospace}":
a.innerHTML=".dbg-sev{color:#F00}.dbg-w{color:#C40}.dbg-sh{font-weight:bold;color:#000}.dbg-i{color:#444}.dbg-f{color:#999}.dbg-ev{color:#0A0}.dbg-m{color:#990}.logmsg{border-bottom:1px solid #CCC;padding:2px}.logsep{background-color: #8C8;}.logdiv{border:1px solid #CCC;background-color:#FCFCFC;font:medium monospace}",c.appendChild(b));this.a.className+=" logdiv"}
Hi.prototype.e=function(a){var b=100>=this.a.scrollHeight-this.a.scrollTop-this.a.clientHeight,c=this.d.createElement("div");c.className="logmsg";c.innerHTML=this.b.c(a);this.a.appendChild(c);b&&(this.a.scrollTop=this.a.scrollHeight)};Hi.prototype.clear=function(){this.a.innerHTML=""};var Ii=null,Ji=null;G("ydn.debug");na("ydn.debug.log",function(a,b,c){if(ea(b))b=new vc("log",b);else if(w(b)){b=b.toUpperCase();if(!Fc){Fc={};for(var d=0,e;e=Ec[d];d++)Fc[e.value]=e,Fc[e.name]=e}b=Fc[b]||null}else b=Bc;G(a||"ydn").b=b;t(c)?Ji||(a=Ji=new Hi(c),!0!=a.c&&(c=Kc(),b=a.f,c.a||(c.a=[]),c.a.push(b),a.c=!0),Kc().b=yc):Ii||Ji||(a=Ii=new xi,!0!=a.b&&(c=Kc(),b=a.f,c.a||(c.a=[]),c.a.push(b),a.b=!0),Kc().b=yc)});na("ydn.db.Storage",$h);})();
//# sourceMappingURL=ydn.db-dev.js.map

View File

@ -34,8 +34,6 @@
})(); })();
</script> </script>
<script src="assets/ydn.db-dev.js"></script>
<link rel="icon" type="image/x-icon" href="assets/icon/favicon.ico"> <link rel="icon" type="image/x-icon" href="assets/icon/favicon.ico">
<link rel="manifest" href="manifest.json"> <link rel="manifest" href="manifest.json">
<meta name="theme-color" content="#4e8ef7"> <meta name="theme-color" content="#4e8ef7">

View File

@ -13,7 +13,6 @@
// limitations under the License. // limitations under the License.
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { CoreAppProvider } from './app';
import { CoreConfigProvider } from './config'; import { CoreConfigProvider } from './config';
import { CoreFilepoolProvider } from './filepool'; import { CoreFilepoolProvider } from './filepool';
import { CoreInitHandler, CoreInitDelegate } from './init'; import { CoreInitHandler, CoreInitDelegate } from './init';
@ -24,7 +23,6 @@ import { CoreUtilsProvider } from './utils/utils';
import { CoreTimeUtilsProvider } from './utils/time'; import { CoreTimeUtilsProvider } from './utils/time';
import { CoreConfigConstants } from '../configconstants'; import { CoreConfigConstants } from '../configconstants';
import { AddonCalendarProvider } from '@addon/calendar/providers/calendar'; import { AddonCalendarProvider } from '@addon/calendar/providers/calendar';
import { SQLiteDB } from '@classes/sqlitedb';
/** /**
* Data to migrate a store of Ionic 1 app to the SQLite DB. * Data to migrate a store of Ionic 1 app to the SQLite DB.
@ -315,7 +313,7 @@ export class CoreUpdateManagerProvider implements CoreInitHandler {
constructor(logger: CoreLoggerProvider, private configProvider: CoreConfigProvider, private sitesProvider: CoreSitesProvider, constructor(logger: CoreLoggerProvider, private configProvider: CoreConfigProvider, private sitesProvider: CoreSitesProvider,
private filepoolProvider: CoreFilepoolProvider, private notifProvider: CoreLocalNotificationsProvider, private filepoolProvider: CoreFilepoolProvider, private notifProvider: CoreLocalNotificationsProvider,
private utils: CoreUtilsProvider, private appProvider: CoreAppProvider, private timeUtils: CoreTimeUtilsProvider, private utils: CoreUtilsProvider, private timeUtils: CoreTimeUtilsProvider,
private calendarProvider: AddonCalendarProvider) { private calendarProvider: AddonCalendarProvider) {
this.logger = logger.getInstance('CoreUpdateManagerProvider'); this.logger = logger.getInstance('CoreUpdateManagerProvider');
} }
@ -330,20 +328,7 @@ export class CoreUpdateManagerProvider implements CoreInitHandler {
const promises = [], const promises = [],
versionCode = CoreConfigConstants.versioncode; versionCode = CoreConfigConstants.versioncode;
return this.configProvider.get(this.VERSION_APPLIED, 0).then((versionApplied) => { return this.configProvider.get(this.VERSION_APPLIED, 0).then((versionApplied: number) => {
if (!versionApplied) {
// No version applied, either the app was just installed or it's being updated from Ionic 1.
return this.migrateAllDBs().then(() => {
// Now that the DBs have been migrated, migrate the local notification components names.
return this.migrateLocalNotificationsComponents();
}).then(() => {
// DBs migrated, get the version applied again.
return this.configProvider.get(this.VERSION_APPLIED, 0);
});
} else {
return versionApplied;
}
}).then((versionApplied: number) => {
if (versionCode >= 2013 && versionApplied < 2013 && versionApplied > 0) { if (versionCode >= 2013 && versionApplied < 2013 && versionApplied > 0) {
promises.push(this.migrateFileExtensions()); promises.push(this.migrateFileExtensions());
@ -419,134 +404,6 @@ export class CoreUpdateManagerProvider implements CoreInitHandler {
this.localNotificationsComponentsMigrate[oldName] = newName; this.localNotificationsComponentsMigrate[oldName] = newName;
} }
/**
* Migrate all DBs and tables from the old format to SQLite.
*
* @return Promise resolved when done.
*/
protected migrateAllDBs(): Promise<any> {
if (!(<any> window).ydn) {
// The ydn-db library is not loaded, stop.
return Promise.resolve();
}
// First migrate the app DB.
return this.migrateAppDB().then(() => {
// Now migrate all site DBs.
return this.sitesProvider.getSitesIds();
}).then((ids) => {
const promises = [];
ids.forEach((id) => {
promises.push(this.migrateSiteDB(id));
});
return this.utils.allPromises(promises);
});
}
/**
* Migrate the app DB.
*
* @return Promise resolved when done.
*/
protected migrateAppDB(): Promise<any> {
const oldDb = new (<any> window).ydn.db.Storage('MoodleMobile'),
newDb = this.appProvider.getDB();
return this.migrateDB(oldDb, newDb, this.appDBTables);
}
/**
* Migrate the DB of a certain site.
*
* @param siteId The site ID.
* @return Promise resolved when done.
*/
protected migrateSiteDB(siteId: string): Promise<any> {
// Get the site DB.
return this.sitesProvider.getSiteDb(siteId).then((newDb) => {
const oldDb = new (<any> window).ydn.db.Storage('Site-' + siteId);
return this.migrateDB(oldDb, newDb, this.siteDBTables);
});
}
/**
* Migrate all the tables of a certain DB to the SQLite DB.
*
* @param oldDb The old DB (created using ydn-db).
* @param newDb The new DB.
* @param tables The tables to migrate.
* @return Promise resolved when done.
*/
protected migrateDB(oldDb: any, newDb: SQLiteDB, tables: CoreUpdateManagerMigrateTable[]): Promise<any> {
if (!oldDb || !newDb) {
// Some of the DBs doesn't exist, stop.
return Promise.resolve();
}
const promises = [];
tables.forEach((table) => {
// Get current values.
promises.push(Promise.resolve(oldDb.values(table.name, undefined, 99999999)).then((entries) => {
const fields = table.fields || [],
filterFields = table.filterFields || [];
// Treat the entries.
for (let i = 0; i < entries.length; i++) {
const entry = entries[i];
// Convert and rename the fields to match the new schema.
fields.forEach((field) => {
const value = entry[field.name];
// Convert the field to the right format.
if (field.type == 'object' || (field.type == 'any' && typeof value == 'object')) {
entry[field.name] = JSON.stringify(value);
} else if (field.type == 'date' && value) {
entry[field.name] = value.getTime();
} else if (field.type == 'boolean' || (field.type == 'any' && typeof value == 'boolean')) {
entry[field.name] = value ? 1 : 0;
}
if (field.newName) {
// Rename the field.
entry[field.newName] = entry[field.name];
delete entry[field.name];
}
if (field.delete) {
// Delete the field.
delete entry[field.name];
}
});
// Remove invalid and unneeded properties.
for (const name in entry) {
if (name.indexOf('$') === 0) {
// Property not valid, remove.
delete entry[name];
} else if (filterFields.length && filterFields.indexOf(name) == -1) {
// The property isn't present in filterFields, remove it.
delete entry[name];
}
}
}
// Now store the entries in the new DB.
return newDb.insertRecords(table.newName || table.name, entries);
}).catch((error) => {
this.logger.error('Error migrating table ' + table.name + ' to ' + (table.newName || table.name) + ': ', error);
}));
});
return this.utils.allPromises(promises);
}
/** /**
* Migrates files filling extensions. * Migrates files filling extensions.
* *
@ -564,30 +421,6 @@ export class CoreUpdateManagerProvider implements CoreInitHandler {
}); });
} }
/**
* Migrate local notifications components from the old nomenclature to the new one.
*
* @return Promise resolved when done.
*/
protected migrateLocalNotificationsComponents(): Promise<any> {
if (!this.notifProvider.isAvailable()) {
// Local notifications not available, nothing to do.
return Promise.resolve();
}
const promises = [];
for (const oldName in this.localNotificationsComponentsMigrate) {
const newName = this.localNotificationsComponentsMigrate[oldName];
promises.push(this.notifProvider.updateComponentName(oldName, newName).catch((error) => {
this.logger.error('Error migrating local notif component from ' + oldName + ' to ' + newName + ': ', error);
}));
}
return Promise.all(promises);
}
/** /**
* Calendar default notification time is configurable from version 3.2.1, and a new option "Default" is added. * Calendar default notification time is configurable from version 3.2.1, and a new option "Default" is added.
* All events that were configured to use the fixed default time should now be configured to use "Default" option. * All events that were configured to use the fixed default time should now be configured to use "Default" option.