-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpouchdb.authentication.min.js
1 lines (1 loc) · 42.1 KB
/
pouchdb.authentication.min.js
1
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).PouchAuthentication=e()}}(function(){return function e(t,n,r){function o(s,a){if(!n[s]){if(!t[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(i)return i(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var f=n[s]={exports:{}};t[s][0].call(f.exports,function(e){var n=t[s][1][e];return o(n||e)},f,f.exports,e,t,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s<r.length;s++)o(r[s]);return o}({1:[function(e,t,n){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e.default:e}function o(e){var t;if("function"==typeof e.getUrl)t=d(e.getUrl());else{var n=e.__opts&&e.__opts.prefix?e.__opts.prefix+"/":"";t=d(n+e.name)}var r=t.pathname,o=(r="/"===r.substr(-1,1)?r.substr(0,-1):r).split("/").slice(0,-1).join("/");return t.origin+o}function i(e,t){return p(o(e),(t?"/_node/"+t:"")+"/_config")}function s(e){return p(o(e),"/_users")}function a(e){return p(o(e),"/_session")}function u(e){var t;if(e.__opts.auth)t=e.__opts.auth;else{var n=d(e.name);n.auth&&(t=n)}if(!t)return{};var r=t.username+":"+t.password;return{Authorization:"Basic "+y.btoa(unescape(encodeURIComponent(r)))}}function c(e){return function(t,n){return t&&"unknown_error"===t.name&&(t.message=(t.message||"")+" Unknown error! Did you remember to enable CORS?"),e(t,n)}}function f(e){this.status=400,this.name="authentication_error",this.message=e,this.error=!0;try{Error.captureStackTrace(this,f)}catch(e){}}function l(e,t,n,r){var o=["_id","_rev","name","type","roles","password","password_scheme","iterations","derived_key","salt"];if(n.metadata){for(var i in n.metadata)if(n.metadata.hasOwnProperty(i)&&-1!==o.indexOf(i))return r(new f('cannot use reserved word in metadata: "'+i+'"'));t=m.assign(t,n.metadata)}n.roles&&(t=m.assign(t,{roles:n.roles}));var a=s(e)+"/"+encodeURIComponent(t._id),l=m.assign({method:"PUT",url:a,body:t,headers:u(e)},n.ajax||{});v(l,c(r))}var p=r(e(15)),d=r(e(16)),h=r(e(5)),y=e(9),v=r(e(7)),m=e(11),g=r(e(10));h(f,Error);var w=m.toPromise(function(e,t){void 0===t&&(t=e,e={});var n=o(this)+"/_membership",r=m.assign({method:"GET",url:n,headers:u(this)},e.ajax||{});v(r,c(t))}),b=m.toPromise(function(e,t,n,r){var o=this;return void 0===r&&(r=void 0===n?void 0===t?e:t:n,n={}),-1===["http","https"].indexOf(o.type())?r(new f('This plugin only works for the http/https adapter. So you should use new PouchDB("http://mysite.com:5984/mydb") instead.')):e?t?void o.getMembership(n,function(s,a){var f;if(s){if("illegal_database_name"!==s.error)return r(s);f=void 0}else f=a.all_nodes[0];var l=i(o,f),p=(n.configUrl||l)+"/admins/"+encodeURIComponent(e),d=m.assign({method:"PUT",url:p,processData:!1,headers:u(o),body:'"'+t+'"'},n.ajax||{});v(d,c(r))}):r(new f("You must provide a password")):r(new f("You must provide a username"))}),_=m.toPromise(function(e,t,n){var r=this;return void 0===n&&(n=void 0===t?e:t,t={}),-1===["http","https"].indexOf(r.type())?n(new f('This plugin only works for the http/https adapter. So you should use new PouchDB("http://mysite.com:5984/mydb") instead.')):e?void r.getMembership(t,function(o,s){var a;if(o){if("illegal_database_name"!==o.error)return n(o);a=void 0}else a=s.all_nodes[0];var f=i(r,a),l=(t.configUrl||f)+"/admins/"+encodeURIComponent(e),p=m.assign({method:"DELETE",url:l,processData:!1,headers:u(r)},t.ajax||{});v(p,c(n))}):n(new f("You must provide a username"))}),E=m.toPromise(function(e,t,n,r){if(void 0===r&&(r=n,n={}),-1===["http","https"].indexOf(this.type()))return r(new f("this plugin only works for the http/https adapter"));if(!e)return r(new f("you must provide a username"));if(!t)return r(new f("you must provide a password"));var o=m.assign({method:"POST",url:a(this),headers:m.assign({"Content-Type":"application/json"},u(this)),body:{name:e,password:t}},n.ajax||{});v(o,c(r))}),j=m.toPromise(function(e,t){void 0===t&&(t=e,e={});var n=m.assign({method:"DELETE",url:a(this),headers:u(this)},e.ajax||{});v(n,c(t))}),O=m.toPromise(function(e,t){void 0===t&&(t=e,e={});var n=a(this),r=m.assign({method:"GET",url:n,headers:u(this)},e.ajax||{});v(r,c(t))}),x=m.toPromise(function(e,t,n,r){if(void 0===r&&(r=void 0===n?void 0===t?e:t:n,n={}),-1===["http","https"].indexOf(this.type()))return r(new f('This plugin only works for the http/https adapter. So you should use new PouchDB("http://mysite.com:5984/mydb") instead.'));if(!e)return r(new f("You must provide a username"));if(!t)return r(new f("You must provide a password"));l(this,{name:e,password:t,roles:[],type:"user",_id:"org.couchdb.user:"+e},n,r)}),S=m.toPromise(function(e,t,n){if(void 0===n&&(n=void 0===t?e:t,t={}),!e)return n(new f("you must provide a username"));var r=s(this),o=m.assign({method:"GET",url:r+"/"+encodeURIComponent("org.couchdb.user:"+e),headers:u(this)},t.ajax||{});v(o,c(n))}),C=m.toPromise(function(e,t,n){var r=this;return void 0===n&&(n=void 0===t?e:t,t={}),-1===["http","https"].indexOf(r.type())?n(new f('This plugin only works for the http/https adapter. So you should use new PouchDB("http://mysite.com:5984/mydb") instead.')):e?void r.getUser(e,t,function(e,o){if(e)return n(e);l(r,o,t,n)}):n(new f("You must provide a username"))}),A=m.toPromise(function(e,t,n){var r=this;return void 0===n&&(n=void 0===t?e:t,t={}),-1===["http","https"].indexOf(r.type())?n(new f('This plugin only works for the http/https adapter. So you should use new PouchDB("http://mysite.com:5984/mydb") instead.')):e?void r.getUser(e,t,function(e,o){if(e)return n(e);var i=s(r)+"/"+encodeURIComponent(o._id)+"?rev="+o._rev,a=m.assign({method:"DELETE",url:i,headers:u(r)},t.ajax||{});v(a,c(n))}):n(new f("You must provide a username"))}),T=m.toPromise(function(e,t,n,r){var o=this;return void 0===r&&(r=void 0===n?void 0===t?e:t:n,n={}),-1===["http","https"].indexOf(o.type())?r(new f('This plugin only works for the http/https adapter. So you should use new PouchDB("http://mysite.com:5984/mydb") instead.')):e?t?void o.getUser(e,n,function(e,i){if(e)return r(e);i.password=t;var a=s(o)+"/"+encodeURIComponent(i._id),f=m.assign({method:"PUT",url:a,headers:u(o),body:i},n.ajax||{});v(f,c(r))}):r(new f("You must provide a password")):r(new f("You must provide a username"))}),L=m.toPromise(function(e,t,n,r){var o=this,i=function(e,t){var n=s(o)+"/"+encodeURIComponent(e._id);return function(e){return new g(function(t,n){v(e,c(function(e,r){if(e)return n(e);t(r)}))})}(m.assign({method:"PUT",url:n,headers:u(o),body:e},t.ajax))};return void 0===r&&(r=n,n={}),n.ajax=n.ajax||{},-1===["http","https"].indexOf(o.type())?r(new f('This plugin only works for the http/https adapter. So you should use new PouchDB("http://mysite.com:5984/mydb") instead.')):t?e?void o.getUser(t,n).then(function(){var e=new f("user already exists");throw e.taken=!0,e},function(){return o.getUser(e,n)}).then(function(e){var r=m.clone(e);return delete r._rev,r._id="org.couchdb.user:"+t,r.name=t,r.roles=n.roles||e.roles||{},i(r,n).then(function(){return e._deleted=!0,i(e,n)})}).then(function(e){r(null,e)}).catch(r):r(new f("You must provide a username to rename")):r(new f("You must provide a new username"))}),R={};R.login=E,R.logIn=E,R.logout=j,R.logOut=j,R.getSession=O,R.getMembership=w,R.signUpAdmin=b,R.deleteAdmin=_,R.getUsersDatabaseUrl=function(){return s(this)},R.signup=x,R.signUp=x,R.getUser=S,R.putUser=C,R.deleteUser=A,R.changePassword=T,R.changeUsername=L,"undefined"!=typeof window&&window.PouchDB&&window.PouchDB.plugin(R),t.exports=R},{10:10,11:11,15:15,16:16,5:5,7:7,9:9}],2:[function(e,t,n){"use strict";t.exports=function(e){return function(){var t=arguments.length;if(t){for(var n=[],r=-1;++r<t;)n[r]=arguments[r];return e.call(this,n)}return e.call(this,[])}}},{}],3:[function(e,t,n){function r(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=f(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}function o(e){return void 0===e._maxListeners?r.defaultMaxListeners:e._maxListeners}function i(e,t,n,r){var i,s,a;if("function"!=typeof n)throw new TypeError('"listener" argument must be a function');if((s=e._events)?(s.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),s=e._events),a=s[t]):(s=e._events=f(null),e._eventsCount=0),a){if("function"==typeof a?a=s[t]=r?[n,a]:[a,n]:r?a.unshift(n):a.push(n),!a.warned&&(i=o(e))&&i>0&&a.length>i){a.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+a.length+' "'+String(t)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=a.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",u.name,u.message)}}else a=s[t]=n,++e._eventsCount;return e}function s(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var e=new Array(arguments.length),t=0;t<e.length;++t)e[t]=arguments[t];this.listener.apply(this.target,e)}}function a(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},o=p.call(s,r);return o.listener=n,r.wrapFn=o,o}function u(e){var t=this._events;if(t){var n=t[e];if("function"==typeof n)return 1;if(n)return n.length}return 0}function c(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}var f=Object.create||function(e){var t=function(){};return t.prototype=e,new t},l=Object.keys||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return n},p=Function.prototype.bind||function(e){var t=this;return function(){return t.apply(e,arguments)}};t.exports=r,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._maxListeners=void 0;var d,h=10;try{var y={};Object.defineProperty&&Object.defineProperty(y,"x",{value:0}),d=0===y.x}catch(e){d=!1}d?Object.defineProperty(r,"defaultMaxListeners",{enumerable:!0,get:function(){return h},set:function(e){if("number"!=typeof e||e<0||e!=e)throw new TypeError('"defaultMaxListeners" must be a positive number');h=e}}):r.defaultMaxListeners=h,r.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},r.prototype.getMaxListeners=function(){return o(this)},r.prototype.emit=function(e){var t,n,r,o,i,s,a="error"===e;if(s=this._events)a=a&&null==s.error;else if(!a)return!1;if(a){if(arguments.length>1&&(t=arguments[1]),t instanceof Error)throw t;var u=new Error('Unhandled "error" event. ('+t+")");throw u.context=t,u}if(!(n=s[e]))return!1;var f="function"==typeof n;switch(r=arguments.length){case 1:!function(e,t,n){if(t)e.call(n);else for(var r=e.length,o=c(e,r),i=0;i<r;++i)o[i].call(n)}(n,f,this);break;case 2:!function(e,t,n,r){if(t)e.call(n,r);else for(var o=e.length,i=c(e,o),s=0;s<o;++s)i[s].call(n,r)}(n,f,this,arguments[1]);break;case 3:!function(e,t,n,r,o){if(t)e.call(n,r,o);else for(var i=e.length,s=c(e,i),a=0;a<i;++a)s[a].call(n,r,o)}(n,f,this,arguments[1],arguments[2]);break;case 4:!function(e,t,n,r,o,i){if(t)e.call(n,r,o,i);else for(var s=e.length,a=c(e,s),u=0;u<s;++u)a[u].call(n,r,o,i)}(n,f,this,arguments[1],arguments[2],arguments[3]);break;default:for(o=new Array(r-1),i=1;i<r;i++)o[i-1]=arguments[i];!function(e,t,n,r){if(t)e.apply(n,r);else for(var o=e.length,i=c(e,o),s=0;s<o;++s)i[s].apply(n,r)}(n,f,this,o)}return!0},r.prototype.addListener=function(e,t){return i(this,e,t,!1)},r.prototype.on=r.prototype.addListener,r.prototype.prependListener=function(e,t){return i(this,e,t,!0)},r.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,a(this,e,t)),this},r.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,a(this,e,t)),this},r.prototype.removeListener=function(e,t){var n,r,o,i,s;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(r=this._events))return this;if(!(n=r[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=f(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(o=-1,i=n.length-1;i>=0;i--)if(n[i]===t||n[i].listener===t){s=n[i].listener,o=i;break}if(o<0)return this;0===o?n.shift():function(e,t){for(var n=t,r=n+1,o=e.length;r<o;n+=1,r+=1)e[n]=e[r];e.pop()}(n,o),1===n.length&&(r[e]=n[0]),r.removeListener&&this.emit("removeListener",e,s||t)}return this},r.prototype.removeAllListeners=function(e){var t,n,r;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=f(null),this._eventsCount=0):n[e]&&(0==--this._eventsCount?this._events=f(null):delete n[e]),this;if(0===arguments.length){var o,i=l(n);for(r=0;r<i.length;++r)"removeListener"!==(o=i[r])&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=f(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(t)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this},r.prototype.listeners=function(e){var t,n=this._events;return n&&(t=n[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(t):[]},r.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):u.call(e,t)},r.prototype.listenerCount=u,r.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],4:[function(e,t,n){(function(e){"use strict";function n(){c=!0;for(var e,t,n=f.length;n;){for(t=f,f=[],e=-1;++e<n;)t[e]();n=f.length}c=!1}var r,o=e.MutationObserver||e.WebKitMutationObserver;if(o){var i=0,s=new o(n),a=e.document.createTextNode("");s.observe(a,{characterData:!0}),r=function(){a.data=i=++i%2}}else if(e.setImmediate||void 0===e.MessageChannel)r="document"in e&&"onreadystatechange"in e.document.createElement("script")?function(){var t=e.document.createElement("script");t.onreadystatechange=function(){n(),t.onreadystatechange=null,t.parentNode.removeChild(t),t=null},e.document.documentElement.appendChild(t)}:function(){setTimeout(n,0)};else{var u=new e.MessageChannel;u.port1.onmessage=n,r=function(){u.port2.postMessage(0)}}var c,f=[];t.exports=function(e){1!==f.push(e)||c||r()}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],5:[function(e,t,n){"function"==typeof Object.create?t.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},{}],6:[function(e,t,n){"use strict";function r(){}function o(e){if("function"!=typeof e)throw new TypeError("resolver must be a function");this.state=h,this.queue=[],this.outcome=void 0,e!==r&&u(this,e)}function i(e,t,n){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof n&&(this.onRejected=n,this.callRejected=this.otherCallRejected)}function s(e,t,n){f(function(){var r;try{r=t(n)}catch(t){return l.reject(e,t)}r===e?l.reject(e,new TypeError("Cannot resolve promise with itself")):l.resolve(e,r)})}function a(e){var t=e&&e.then;if(e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof t)return function(){t.apply(e,arguments)}}function u(e,t){function n(t){o||(o=!0,l.reject(e,t))}function r(t){o||(o=!0,l.resolve(e,t))}var o=!1,i=c(function(){t(r,n)});"error"===i.status&&n(i.value)}function c(e,t){var n={};try{n.value=e(t),n.status="success"}catch(e){n.status="error",n.value=e}return n}var f=e(4),l={},p=["REJECTED"],d=["FULFILLED"],h=["PENDING"];t.exports=o,o.prototype.catch=function(e){return this.then(null,e)},o.prototype.then=function(e,t){if("function"!=typeof e&&this.state===d||"function"!=typeof t&&this.state===p)return this;var n=new this.constructor(r);if(this.state!==h){s(n,this.state===d?e:t,this.outcome)}else this.queue.push(new i(n,e,t));return n},i.prototype.callFulfilled=function(e){l.resolve(this.promise,e)},i.prototype.otherCallFulfilled=function(e){s(this.promise,this.onFulfilled,e)},i.prototype.callRejected=function(e){l.reject(this.promise,e)},i.prototype.otherCallRejected=function(e){s(this.promise,this.onRejected,e)},l.resolve=function(e,t){var n=c(a,t);if("error"===n.status)return l.reject(e,n.value);var r=n.value;if(r)u(e,r);else{e.state=d,e.outcome=t;for(var o=-1,i=e.queue.length;++o<i;)e.queue[o].callFulfilled(t)}return e},l.reject=function(e,t){e.state=p,e.outcome=t;for(var n=-1,r=e.queue.length;++n<r;)e.queue[n].callRejected(t);return e},o.resolve=function(e){return e instanceof this?e:l.resolve(new this(r),e)},o.reject=function(e){var t=new this(r);return l.reject(t,e)},o.all=function(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var n=e.length,o=!1;if(!n)return this.resolve([]);for(var i=new Array(n),s=0,a=-1,u=new this(r);++a<n;)!function(e,r){t.resolve(e).then(function(e){i[r]=e,++s!==n||o||(o=!0,l.resolve(u,i))},function(e){o||(o=!0,l.reject(u,e))})}(e[a],a);return u},o.race=function(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var n=e.length,o=!1;if(!n)return this.resolve([]);for(var i=-1,s=new this(r);++i<n;)!function(e){t.resolve(e).then(function(e){o||(o=!0,l.resolve(s,e))},function(e){o||(o=!0,l.reject(s,e))})}(e[i]);return s}},{4:4}],7:[function(e,t,n){"use strict";function r(e,t){var n,r,o,i=new Headers,s={method:e.method,credentials:"include",headers:i};return e.json&&(i.set("Accept","application/json"),i.set("Content-Type",e.headers["Content-Type"]||"application/json")),e.body&&e.processData&&"string"!=typeof e.body?s.body=JSON.stringify(e.body):s.body="body"in e?e.body:null,Object.keys(e.headers).forEach(function(t){e.headers.hasOwnProperty(t)&&i.set(t,e.headers[t])}),n=function(){for(var e={},t=new a(function(t,n){e.resolve=t,e.reject=n}),n=new Array(arguments.length),r=0;r<n.length;r++)n[r]=arguments[r];return e.promise=t,a.resolve().then(function(){return fetch.apply(null,n)}).then(function(t){e.resolve(t)}).catch(function(t){e.reject(t)}),e}(e.url,s),e.timeout>0&&(r=setTimeout(function(){n.reject(new Error("Load timeout for resource: "+e.url))},e.timeout)),n.promise.then(function(t){return o={statusCode:t.status},e.timeout>0&&clearTimeout(r),o.statusCode>=200&&o.statusCode<300?e.binary?t.blob():t.text():t.json()}).then(function(e){o.statusCode>=200&&o.statusCode<300?t(null,o,e):(e.status=o.statusCode,t(e))}).catch(function(e){e||(e=new Error("canceled")),t(e)}),{abort:n.reject}}function o(e,t){return f||e.xhr?function(e,t){var n,r,o=!1,i=function(){o=!0,n.abort(),a()},s={abort:function(){n.abort(),a()}},a=function(){clearTimeout(r),s.abort=function(){},n&&(n.onprogress=void 0,n.upload&&(n.upload.onprogress=void 0),n.onreadystatechange=void 0,n=void 0)};n=e.xhr?new e.xhr:new XMLHttpRequest;try{n.open(e.method,e.url)}catch(e){return t(new Error(e.name||"Url is invalid"))}n.withCredentials=!("withCredentials"in e)||e.withCredentials,"GET"===e.method?delete e.headers["Content-Type"]:e.json&&(e.headers.Accept="application/json",e.headers["Content-Type"]=e.headers["Content-Type"]||"application/json",e.body&&e.processData&&"string"!=typeof e.body&&(e.body=JSON.stringify(e.body))),e.binary&&(n.responseType="arraybuffer"),"body"in e||(e.body=null);for(var c in e.headers)e.headers.hasOwnProperty(c)&&n.setRequestHeader(c,e.headers[c]);return e.timeout>0&&(r=setTimeout(i,e.timeout),n.onprogress=function(){clearTimeout(r),4!==n.readyState&&(r=setTimeout(i,e.timeout))},void 0!==n.upload&&(n.upload.onprogress=n.onprogress)),n.onreadystatechange=function(){if(4===n.readyState){var r={statusCode:n.status};if(n.status>=200&&n.status<300){var i;i=e.binary?u.blob([n.response||""],{type:n.getResponseHeader("Content-Type")}):n.responseText,t(null,r,i)}else{var s={};if(o)(s=new Error("ETIMEDOUT")).code="ETIMEDOUT";else if("string"==typeof n.response)try{s=JSON.parse(n.response)}catch(e){}s.status=n.status,t(s)}a()}},e.body&&e.body instanceof Blob?u.readAsArrayBuffer(e.body,function(e){n.send(e)}):n.send(e.body),s}(e,t):r(e,t)}function i(e,t){e=s.clone(e);return(e=s.assign({method:"GET",headers:{},json:!0,processData:!0,timeout:1e4,cache:!1},e)).json&&(e.binary||(e.headers.Accept="application/json"),e.headers["Content-Type"]=e.headers["Content-Type"]||"application/json"),e.binary&&(e.encoding=null,e.json=!1),e.processData||(e.json=!1),o(e,function(n,r,o){if(n)return t(c.generateErrorFromResponse(n));var i,s=r.headers&&r.headers["content-type"],a=o||"";if(!e.binary&&(e.json||!e.processData)&&"object"!=typeof a&&(/json/.test(s)||/^[\s]*\{/.test(a)&&/\}[\s]*$/.test(a)))try{a=JSON.parse(a.toString())}catch(e){}r.statusCode>=200&&r.statusCode<300?function(t,n,r){if(!e.binary&&e.json&&"string"==typeof t)try{t=JSON.parse(t)}catch(e){return r(e)}Array.isArray(t)&&(t=t.map(function(e){return e.error||e.missing?c.generateErrorFromResponse(e):e})),e.binary,r(null,t,n)}(a,r,t):((i=c.generateErrorFromResponse(a)).status=r.statusCode,t(i))})}var s=e(11),a=function(e){return e&&"object"==typeof e&&"default"in e?e.default:e}(e(10)),u=e(9),c=e(8),f=function(){try{return new XMLHttpRequest,!0}catch(e){return!1}}();t.exports=function(e,t){var n=navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",r=-1!==n.indexOf("safari")&&-1===n.indexOf("chrome"),o=-1!==n.indexOf("msie"),s=-1!==n.indexOf("trident"),a=-1!==n.indexOf("edge"),u=r||(o||s||a)&&"GET"===e.method,c=!("cache"in e)||e.cache;if(!/^blob:/.test(e.url)&&(u||!c)){var f=-1!==e.url.indexOf("?");e.url+=(f?"&":"?")+"_nonce="+Date.now()}return i(e,t)}},{10:10,11:11,8:8,9:9}],8:[function(e,t,n){"use strict";function r(e,t,n){Error.call(this,n),this.status=e,this.name=t,this.message=n,this.error=!0}Object.defineProperty(n,"__esModule",{value:!0});(function(e){return e&&"object"==typeof e&&"default"in e?e.default:e})(e(5))(r,Error),r.prototype.toString=function(){return JSON.stringify({status:this.status,name:this.name,message:this.message,reason:this.reason})};var o=new r(401,"unauthorized","Name or password is incorrect."),i=new r(400,"bad_request","Missing JSON list of 'docs'"),s=new r(404,"not_found","missing"),a=new r(409,"conflict","Document update conflict"),u=new r(400,"bad_request","_id field must contain a string"),c=new r(412,"missing_id","_id is required for puts"),f=new r(400,"bad_request","Only reserved document ids may start with underscore."),l=new r(412,"precondition_failed","Database not open"),p=new r(500,"unknown_error","Database encountered an unknown error"),d=new r(500,"badarg","Some query argument is invalid"),h=new r(400,"invalid_request","Request was invalid"),y=new r(400,"query_parse_error","Some query parameter is invalid"),v=new r(500,"doc_validation","Bad special document member"),m=new r(400,"bad_request","Something wrong with the request"),g=new r(400,"bad_request","Document must be a JSON object"),w=new r(404,"not_found","Database not found"),b=new r(500,"indexed_db_went_bad","unknown"),_=new r(500,"web_sql_went_bad","unknown"),E=new r(500,"levelDB_went_went_bad","unknown"),j=new r(403,"forbidden","Forbidden by design doc validate_doc_update function"),O=new r(400,"bad_request","Invalid rev format"),x=new r(412,"file_exists","The database could not be created, the file already exists."),S=new r(412,"missing_stub","A pre-existing attachment stub wasn't found"),C=new r(413,"invalid_url","Provided URL is invalid");n.UNAUTHORIZED=o,n.MISSING_BULK_DOCS=i,n.MISSING_DOC=s,n.REV_CONFLICT=a,n.INVALID_ID=u,n.MISSING_ID=c,n.RESERVED_ID=f,n.NOT_OPEN=l,n.UNKNOWN_ERROR=p,n.BAD_ARG=d,n.INVALID_REQUEST=h,n.QUERY_PARSE_ERROR=y,n.DOC_VALIDATION=v,n.BAD_REQUEST=m,n.NOT_AN_OBJECT=g,n.DB_MISSING=w,n.WSQ_ERROR=_,n.LDB_ERROR=E,n.FORBIDDEN=j,n.INVALID_REV=O,n.FILE_EXISTS=x,n.MISSING_STUB=S,n.IDB_ERROR=b,n.INVALID_URL=C,n.createError=function(e,t){function n(t){for(var n in e)"function"!=typeof e[n]&&(this[n]=e[n]);void 0!==t&&(this.reason=t)}return n.prototype=r.prototype,new n(t)},n.generateErrorFromResponse=function(e){if("object"!=typeof e){var t=e;(e=p).data=t}return"error"in e&&"conflict"===e.error&&(e.name="conflict",e.status=409),"name"in e||(e.name=e.error||"unknown"),"status"in e||(e.status=500),"message"in e||(e.message=e.message||e.reason),e}},{5:5}],9:[function(e,t,n){"use strict";function r(e,t){e=e||[],t=t||{};try{return new Blob(e,t)}catch(o){if("TypeError"!==o.name)throw o;for(var n=new("undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder?MozBlobBuilder:WebKitBlobBuilder),r=0;r<e.length;r+=1)n.append(e[r]);return n.getBlob(t.type)}}function o(e){for(var t=e.length,n=new ArrayBuffer(t),r=new Uint8Array(n),o=0;o<t;o++)r[o]=e.charCodeAt(o);return n}function i(e,t){return r([o(e)],{type:t})}function s(e){for(var t="",n=new Uint8Array(e),r=n.byteLength,o=0;o<r;o++)t+=String.fromCharCode(n[o]);return t}function a(e,t){if("undefined"==typeof FileReader)return t(s((new FileReaderSync).readAsArrayBuffer(e)));var n=new FileReader,r="function"==typeof n.readAsBinaryString;n.onloadend=function(e){var n=e.target.result||"";if(r)return t(n);t(s(n))},r?n.readAsBinaryString(e):n.readAsArrayBuffer(e)}function u(e,t){a(e,function(e){t(e)})}Object.defineProperty(n,"__esModule",{value:!0});var c=function(e){return atob(e)},f=function(e){return btoa(e)};n.atob=c,n.btoa=f,n.base64StringToBlobOrBuffer=function(e,t){return i(c(e),t)},n.binaryStringToArrayBuffer=o,n.binaryStringToBlobOrBuffer=i,n.blob=r,n.blobOrBufferToBase64=function(e,t){u(e,function(e){t(f(e))})},n.blobOrBufferToBinaryString=u,n.readAsArrayBuffer=function(e,t){if("undefined"==typeof FileReader)return t((new FileReaderSync).readAsArrayBuffer(e));var n=new FileReader;n.onloadend=function(e){var n=e.target.result||new ArrayBuffer(0);t(n)},n.readAsArrayBuffer(e)},n.readAsBinaryString=a,n.typedBuffer=function(){}},{}],10:[function(e,t,n){"use strict";var r=function(e){return e&&"object"==typeof e&&"default"in e?e.default:e}(e(6)),o="function"==typeof Promise?Promise:r;t.exports=o},{6:6}],11:[function(e,t,n){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e.default:e}function o(e){if(e instanceof ArrayBuffer)return function(e){if("function"==typeof e.slice)return e.slice(0);var t=new ArrayBuffer(e.byteLength),n=new Uint8Array(t),r=new Uint8Array(e);return n.set(r),t}(e);var t=e.size,n=e.type;return"function"==typeof e.slice?e.slice(0,t,n):e.webkitSlice(0,t,n)}function i(e){var t,n,r;if(!e||"object"!=typeof e)return e;if(Array.isArray(e)){for(t=[],n=0,r=e.length;n<r;n++)t[n]=i(e[n]);return t}if(e instanceof Date)return e.toISOString();if(function(e){return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer||"undefined"!=typeof Blob&&e instanceof Blob}(e))return o(e);if(!function(e){var t=Object.getPrototypeOf(e);if(null===t)return!0;var n=t.constructor;return"function"==typeof n&&n instanceof n&&T.call(n)==L}(e))return e;t={};for(n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var s=i(e[n]);void 0!==s&&(t[n]=s)}return t}function s(e){var t=!1;return j(function(n){if(t)throw new Error("once called more than once");t=!0,e.apply(this,n)})}function a(e){return j(function(t){var n=this,r="function"==typeof(t=i(t))[t.length-1]&&t.pop(),o=new E(function(r,o){var i;try{var a=s(function(e,t){e?o(e):r(t)});t.push(a),(i=e.apply(n,t))&&"function"==typeof i.then&&r(i)}catch(e){o(e)}});return r&&o.then(function(e){r(null,e)},r),o})}function u(e,t){for(var n={},r=0,o=t.length;r<o;r++){var i=t[r];i in e&&(n[i]=e[i])}return n}function c(e){return e}function f(e){return[{ok:e}]}function l(e,t,n){function r(){++l===a&&function(){var e=[];p.forEach(function(t){t.docs.forEach(function(n){e.push({id:t.id,docs:[n]})})}),n(null,{results:e})}()}function o(){if(!(h>=d.length)){var n=Math.min(h+R,d.length),i=d.slice(h,n);!function(n,i){n.forEach(function(n,a){var l=i+a,d=s.get(n),h=u(d[0],["atts_since","attachments"]);h.open_revs=d.map(function(e){return e.rev}),h.open_revs=h.open_revs.filter(c);var y=c;0===h.open_revs.length&&(delete h.open_revs,y=f),["revs","attachments","binary","ajax","latest"].forEach(function(e){e in t&&(h[e]=t[e])}),e.get(n,h,function(e,t){var i;i=e?[{error:e}]:y(t),function(e,t,n){p[e]={id:t,docs:n},r()}(l,n,i),o()})})}(i,h),h+=i.length}}var i=t.docs,s=new O.Map;i.forEach(function(e){s.has(e.id)?s.get(e.id).push(e):s.set(e.id,[e])});var a=s.size,l=0,p=new Array(a),d=[];s.forEach(function(e,t){d.push(t)});var h=0;o()}function p(){return"undefined"!=typeof chrome&&void 0!==chrome.storage&&void 0!==chrome.storage.local}function d(){return b}function h(){x.EventEmitter.call(this),this._listeners={},function(e){p()?chrome.storage.onChanged.addListener(function(t){null!=t.db_name&&e.emit(t.dbName.newValue)}):d()&&("undefined"!=typeof addEventListener?addEventListener("storage",function(t){e.emit(t.key)}):window.attachEvent("storage",function(t){e.emit(t.key)}))}(this)}function y(e){if("undefined"!=typeof console&&"function"==typeof console[e]){var t=Array.prototype.slice.call(arguments,1);console[e].apply(console,t)}}function v(e){var t=0;return e||(t=2e3),function(e,t){return e=parseInt(e,10)||0,(t=parseInt(t,10))!=t||t<=e?t=(e||1)<<1:t+=1,t>6e5&&(e=3e5,t=6e5),~~((t-e)*Math.random()+e)}(e,t)}function m(e){var t={},n=e.filter&&"function"==typeof e.filter;return t.query=e.query_params,function(r){r.doc||(r.doc={});var o=n&&function(e,t,n){try{return!e(t,n)}catch(e){var r="Filter function threw: "+e.toString();return A.createError(A.BAD_REQUEST,r)}}(e.filter,r.doc,t);if("object"==typeof o)return o;if(o)return!1;if(e.include_docs){if(!e.attachments)for(var i in r.doc._attachments)r.doc._attachments.hasOwnProperty(i)&&(r.doc._attachments[i].stub=!0)}else delete r.doc;return!0}}function g(e){if(!e)return null;var t=e.split("/");return 2===t.length?t:1===t.length?[e,e]:null}function w(e,t,n){return new E(function(r,o){e.get(t,function(i,s){if(i){if(404!==i.status)return o(i);s={}}var a=s._rev,u=n(s);if(!u)return r({updated:!1,rev:a});u._id=t,u._rev=a,r(function(e,t,n){return e.put(t).then(function(e){return{updated:!0,rev:e.rev}},function(r){if(409!==r.status)throw r;return w(e,t._id,n)})}(e,u,n))})})}Object.defineProperty(n,"__esModule",{value:!0});var b,_=r(e(18)),E=r(e(10)),j=r(e(2)),O=e(12),x=e(3),S=r(e(5)),C=r(e(4)),A=e(13),T=Function.prototype.toString,L=T.call(Object),R=6;if(p())b=!1;else try{localStorage.setItem("_pouch_check_localstorage",1),b=!!localStorage.getItem("_pouch_check_localstorage")}catch(e){b=!1}S(h,x.EventEmitter),h.prototype.addListener=function(e,t,n,r){function o(){if(i._listeners[t])if(s)s="waiting";else{s=!0;var e=u(r,["style","include_docs","attachments","conflicts","filter","doc_ids","view","since","query_params","binary"]);n.changes(e).on("change",function(e){e.seq>r.since&&!r.cancelled&&(r.since=e.seq,r.onChange(e))}).on("complete",function(){"waiting"===s&&C(o),s=!1}).on("error",function(){s=!1})}}if(!this._listeners[t]){var i=this,s=!1;this._listeners[t]=o,this.on(e,o)}},h.prototype.removeListener=function(e,t){t in this._listeners&&(x.EventEmitter.prototype.removeListener.call(this,e,this._listeners[t]),delete this._listeners[t])},h.prototype.notifyLocalWindows=function(e){p()?chrome.storage.local.set({dbName:e}):d()&&(localStorage[e]="a"===localStorage[e]?"b":"a")},h.prototype.notify=function(e){this.emit(e),this.notifyLocalWindows(e)};var B,D,I=B="function"==typeof Object.assign?Object.assign:function(e){for(var t=Object(e),n=1;n<arguments.length;n++){var r=arguments[n];if(null!=r)for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(t[o]=r[o])}return t},P=D=function(){}.name?function(e){return e.name}:function(e){return e.toString().match(/^\s*function\s*(\S*)\s*\(/)[1]},U=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],k="queryKey",N=/(?:^|&)([^&=]*)=?([^&]*)/g,q=/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,M=_.v4;n.adapterFun=function(e,t){return a(j(function(n){if(this._closed)return E.reject(new Error("database is closed"));if(this._destroyed)return E.reject(new Error("database is destroyed"));var r=this;return function(e,t,n){if(e.constructor.listeners("debug").length){for(var r=["api",e.name,t],o=0;o<n.length-1;o++)r.push(n[o]);e.constructor.emit("debug",r);var i=n[n.length-1];n[n.length-1]=function(n,r){var o=["api",e.name,t];o=o.concat(n?["error",n]:["success",r]),e.constructor.emit("debug",o),i(n,r)}}}(r,e,n),this.taskqueue.isReady?t.apply(this,n):new E(function(t,o){r.taskqueue.addTask(function(i){i?o(i):t(r[e].apply(r,n))})})}))},n.assign=I,n.bulkGetShim=l,n.changesHandler=h,n.clone=i,n.defaultBackOff=v,n.explainError=function(e,t){y("info","The above "+e+" is totally normal. "+t)},n.filterChange=m,n.flatten=function(e){for(var t=[],n=0,r=e.length;n<r;n++)t=t.concat(e[n]);return t},n.functionName=P,n.guardedConsole=y,n.hasLocalStorage=d,n.invalidIdError=function(e){var t;if(e?"string"!=typeof e?t=A.createError(A.INVALID_ID):/^_/.test(e)&&!/^_(design|local)/.test(e)&&(t=A.createError(A.RESERVED_ID)):t=A.createError(A.MISSING_ID),t)throw t},n.isChromeApp=p,n.isCordova=function(){return"undefined"!=typeof cordova||"undefined"!=typeof PhoneGap||"undefined"!=typeof phonegap},n.isRemote=function(e){return"boolean"==typeof e._remote?e._remote:"function"==typeof e.type&&(y("warn","db.type() is deprecated and will be removed in a future version of PouchDB"),"http"===e.type())},n.listenerCount=function(e,t){return"listenerCount"in e?e.listenerCount(t):x.EventEmitter.listenerCount(e,t)},n.nextTick=C,n.normalizeDdocFunctionName=function(e){var t=g(e);return t?t.join("/"):null},n.once=s,n.parseDdocFunctionName=g,n.parseUri=function(e){for(var t=q.exec(e),n={},r=14;r--;){var o=U[r],i=t[r]||"",s=-1!==["user","password"].indexOf(o);n[o]=s?decodeURIComponent(i):i}return n[k]={},n[U[12]].replace(N,function(e,t,r){t&&(n[k][t]=r)}),n},n.pick=u,n.rev=function(){return _.v4().replace(/-/g,"").toLowerCase()},n.scopeEval=function(e,t){var n=[],r=[];for(var o in t)t.hasOwnProperty(o)&&(n.push(o),r.push(t[o]));return n.push(e),Function.apply(null,n).apply(null,r)},n.toPromise=a,n.upsert=w,n.uuid=M},{10:10,12:12,13:13,18:18,2:2,3:3,4:4,5:5}],12:[function(e,t,n){"use strict";function r(e){return"$"+e}function o(e){return e.substring(1)}function i(){this._store={}}function s(e){if(this._store=new i,e&&Array.isArray(e))for(var t=0,n=e.length;t<n;t++)this.add(e[t])}Object.defineProperty(n,"__esModule",{value:!0}),i.prototype.get=function(e){var t=r(e);return this._store[t]},i.prototype.set=function(e,t){var n=r(e);return this._store[n]=t,!0},i.prototype.has=function(e){return r(e)in this._store},i.prototype.delete=function(e){var t=r(e),n=t in this._store;return delete this._store[t],n},i.prototype.forEach=function(e){for(var t=Object.keys(this._store),n=0,r=t.length;n<r;n++){var i=t[n];e(this._store[i],i=o(i))}},Object.defineProperty(i.prototype,"size",{get:function(){return Object.keys(this._store).length}}),s.prototype.add=function(e){return this._store.set(e,!0)},s.prototype.has=function(e){return this._store.has(e)},s.prototype.forEach=function(e){this._store.forEach(function(t,n){e(n)})},Object.defineProperty(s.prototype,"size",{get:function(){return this._store.size}}),!function(){if("undefined"==typeof Symbol||"undefined"==typeof Map||"undefined"==typeof Set)return!1;var e=Object.getOwnPropertyDescriptor(Map,Symbol.species);return e&&"get"in e&&Map[Symbol.species]===Map}()?(n.Set=s,n.Map=i):(n.Set=Set,n.Map=Map)},{}],13:[function(e,t,n){arguments[4][8][0].apply(n,arguments)},{5:5,8:8}],14:[function(e,t,n){"use strict";function r(e){return decodeURIComponent(e.replace(/\+/g," "))}var o=Object.prototype.hasOwnProperty;n.stringify=function(e,t){var n=[];"string"!=typeof(t=t||"")&&(t="?");for(var r in e)o.call(e,r)&&n.push(encodeURIComponent(r)+"="+encodeURIComponent(e[r]));return n.length?t+n.join("&"):""},n.parse=function(e){for(var t,n=/([^=?&]+)=?([^&]*)/g,o={};t=n.exec(e);o[r(t[1])]=r(t[2]));return o}},{}],15:[function(e,t,n){!function(e,n,r){void 0!==t&&t.exports?t.exports=r():n.urljoin=r()}(0,this,function(){return function(){var e;return e="object"==typeof arguments[0]?arguments[0]:[].slice.call(arguments),function(e){var t=[];if(e[0].match(/^[^/:]+:\/*$/)&&e.length>1){var n=e.shift();e[0]=n+e[0]}e[0].match(/^file:\/\/\//)?e[0]=e[0].replace(/^([^/:]+):\/*/,"$1:///"):e[0]=e[0].replace(/^([^/:]+):\/*/,"$1://");for(var r=0;r<e.length;r++){var o=e[r];if("string"!=typeof o)throw new TypeError("Url must be a string. Received "+o);""!==o&&(r>0&&(o=o.replace(/^[\/]+/,"")),o=r<e.length-1?o.replace(/[\/]+$/,""):o.replace(/[\/]+$/,"/"),t.push(o))}var i=t.join("/"),s=(i=i.replace(/\/(\?|&|#[^!])/g,"$1")).split("?");return i=s.shift()+(s.length>0?"?":"")+s.join("&")}(e)}})},{}],16:[function(e,t,n){(function(n){"use strict";function r(e){var t,r={},o=typeof(e=e||n.location||{});if("blob:"===e.protocol)r=new i(unescape(e.pathname),{});else if("string"===o){r=new i(e,{});for(t in l)delete r[t]}else if("object"===o){for(t in e)t in l||(r[t]=e[t]);void 0===r.slashes&&(r.slashes=c.test(e.href))}return r}function o(e){var t=u.exec(e);return{protocol:t[1]?t[1].toLowerCase():"",slashes:!!t[2],rest:t[3]}}function i(e,t,n){if(!(this instanceof i))return new i(e,t,n);var u,c,l,p,d,h,y=f.slice(),v=typeof t,m=this,g=0;for("object"!==v&&"string"!==v&&(n=t,t=null),n&&"function"!=typeof n&&(n=a.parse),t=r(t),u=!(c=o(e||"")).protocol&&!c.slashes,m.slashes=c.slashes||u&&t.slashes,m.protocol=c.protocol||t.protocol||"",e=c.rest,c.slashes||(y[2]=[/(.*)/,"pathname"]);g<y.length;g++)l=(p=y[g])[0],h=p[1],l!=l?m[h]=e:"string"==typeof l?~(d=e.indexOf(l))&&("number"==typeof p[2]?(m[h]=e.slice(0,d),e=e.slice(d+p[2])):(m[h]=e.slice(d),e=e.slice(0,d))):(d=l.exec(e))&&(m[h]=d[1],e=e.slice(0,d.index)),m[h]=m[h]||(u&&p[3]?t[h]||"":""),p[4]&&(m[h]=m[h].toLowerCase());n&&(m.query=n(m.query)),u&&t.slashes&&"/"!==m.pathname.charAt(0)&&(""!==m.pathname||""!==t.pathname)&&(m.pathname=function(e,t){for(var n=(t||"/").split("/").slice(0,-1).concat(e.split("/")),r=n.length,o=n[r-1],i=!1,s=0;r--;)"."===n[r]?n.splice(r,1):".."===n[r]?(n.splice(r,1),s++):s&&(0===r&&(i=!0),n.splice(r,1),s--);return i&&n.unshift(""),"."!==o&&".."!==o||n.push(""),n.join("/")}(m.pathname,t.pathname)),s(m.port,m.protocol)||(m.host=m.hostname,m.port=""),m.username=m.password="",m.auth&&(p=m.auth.split(":"),m.username=p[0]||"",m.password=p[1]||""),m.origin=m.protocol&&m.host&&"file:"!==m.protocol?m.protocol+"//"+m.host:"null",m.href=m.toString()}var s=e(17),a=e(14),u=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\S\s]*)/i,c=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//,f=[["#","hash"],["?","query"],["/","pathname"],["@","auth",1],[NaN,"host",void 0,1,1],[/:(\d+)$/,"port",void 0,1],[NaN,"hostname",void 0,1,1]],l={hash:1,query:1};i.prototype={set:function(e,t,n){var r=this;switch(e){case"query":"string"==typeof t&&t.length&&(t=(n||a.parse)(t)),r[e]=t;break;case"port":r[e]=t,s(t,r.protocol)?t&&(r.host=r.hostname+":"+t):(r.host=r.hostname,r[e]="");break;case"hostname":r[e]=t,r.port&&(t+=":"+r.port),r.host=t;break;case"host":r[e]=t,/:\d+$/.test(t)?(t=t.split(":"),r.port=t.pop(),r.hostname=t.join(":")):(r.hostname=t,r.port="");break;case"protocol":r.protocol=t.toLowerCase(),r.slashes=!n;break;case"pathname":case"hash":if(t){var o="pathname"===e?"/":"#";r[e]=t.charAt(0)!==o?o+t:t}else r[e]=t;break;default:r[e]=t}for(var i=0;i<f.length;i++){var u=f[i];u[4]&&(r[u[1]]=r[u[1]].toLowerCase())}return r.origin=r.protocol&&r.host&&"file:"!==r.protocol?r.protocol+"//"+r.host:"null",r.href=r.toString(),r},toString:function(e){e&&"function"==typeof e||(e=a.stringify);var t,n=this,r=n.protocol;r&&":"!==r.charAt(r.length-1)&&(r+=":");var o=r+(n.slashes?"//":"");return n.username&&(o+=n.username,n.password&&(o+=":"+n.password),o+="@"),o+=n.host+n.pathname,(t="object"==typeof n.query?e(n.query):n.query)&&(o+="?"!==t.charAt(0)?"?"+t:t),n.hash&&(o+=n.hash),o}},i.extractProtocol=o,i.location=r,i.qs=a,t.exports=i}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{14:14,17:17}],17:[function(e,t,n){"use strict";t.exports=function(e,t){if(t=t.split(":")[0],!(e=+e))return!1;switch(t){case"http":case"ws":return 80!==e;case"https":case"wss":return 443!==e;case"ftp":return 21!==e;case"gopher":return 70!==e;case"file":return!1}return 0!==e}},{}],18:[function(e,t,n){var r=e(21),o=e(22),i=o;i.v1=r,i.v4=o,t.exports=i},{21:21,22:22}],19:[function(e,t,n){for(var r=[],o=0;o<256;++o)r[o]=(o+256).toString(16).substr(1);t.exports=function(e,t){var n=t||0,o=r;return o[e[n++]]+o[e[n++]]+o[e[n++]]+o[e[n++]]+"-"+o[e[n++]]+o[e[n++]]+"-"+o[e[n++]]+o[e[n++]]+"-"+o[e[n++]]+o[e[n++]]+"-"+o[e[n++]]+o[e[n++]]+o[e[n++]]+o[e[n++]]+o[e[n++]]+o[e[n++]]}},{}],20:[function(e,t,n){(function(e){var n,r=e.crypto||e.msCrypto;if(r&&r.getRandomValues){var o=new Uint8Array(16);n=function(){return r.getRandomValues(o),o}}if(!n){var i=new Array(16);n=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),i[t]=e>>>((3&t)<<3)&255;return i}}t.exports=n}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],21:[function(e,t,n){var r=e(20),o=e(19),i=r(),s=[1|i[0],i[1],i[2],i[3],i[4],i[5]],a=16383&(i[6]<<8|i[7]),u=0,c=0;t.exports=function(e,t,n){var r=t&&n||0,i=t||[],f=void 0!==(e=e||{}).clockseq?e.clockseq:a,l=void 0!==e.msecs?e.msecs:(new Date).getTime(),p=void 0!==e.nsecs?e.nsecs:c+1,d=l-u+(p-c)/1e4;if(d<0&&void 0===e.clockseq&&(f=f+1&16383),(d<0||l>u)&&void 0===e.nsecs&&(p=0),p>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");u=l,c=p,a=f;var h=(1e4*(268435455&(l+=122192928e5))+p)%4294967296;i[r++]=h>>>24&255,i[r++]=h>>>16&255,i[r++]=h>>>8&255,i[r++]=255&h;var y=l/4294967296*1e4&268435455;i[r++]=y>>>8&255,i[r++]=255&y,i[r++]=y>>>24&15|16,i[r++]=y>>>16&255,i[r++]=f>>>8|128,i[r++]=255&f;for(var v=e.node||s,m=0;m<6;++m)i[r+m]=v[m];return t||o(i)}},{19:19,20:20}],22:[function(e,t,n){var r=e(20),o=e(19);t.exports=function(e,t,n){var i=t&&n||0;"string"==typeof e&&(t="binary"==e?new Array(16):null,e=null);var s=(e=e||{}).random||(e.rng||r)();if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,t)for(var a=0;a<16;++a)t[i+a]=s[a];return t||o(s)}},{19:19,20:20}]},{},[1])(1)});