-
Notifications
You must be signed in to change notification settings - Fork 0
/
sinon.min.js
3 lines (3 loc) · 73.8 KB
/
sinon.min.js
1
2
3
!function(e,t){"use strict";"function"==typeof define&&define.amd?define("sinon",[],function(){return e.sinon=t()}):"object"==typeof exports?module.exports=t():e.sinon=t()}(this,function(){"use strict";var samsam,formatio,lolex;!function(){function define(e,t,n){"samsam"==e?samsam=t():"function"==typeof t&&0===e.length?lolex=t():"function"==typeof n&&(formatio=n(samsam))}define.amd={},("function"==typeof define&&define.amd&&function(e){define("samsam",e)}||"object"==typeof module&&function(e){module.exports=e()}||function(e){this.samsam=e()})(function(){function e(e){var t=e;return"number"==typeof e&&e!==t}function t(e){return f.toString.call(e).split(/[ \]]/)[1]}function n(e){if("Arguments"===t(e))return!0;if("object"!=typeof e||"number"!=typeof e.length||"Array"===t(e))return!1;if("function"==typeof e.callee)return!0;try{e[e.length]=6,delete e[e.length]}catch(n){return!0}return!1}function r(e){if(!e||1!==e.nodeType||!d)return!1;try{e.appendChild(d),e.removeChild(d)}catch(t){return!1}return!0}function i(e){var t,n=[];for(t in e)f.hasOwnProperty.call(e,t)&&n.push(t);return n}function o(e){return"function"==typeof e.getTime&&e.getTime()==e.valueOf()}function s(e){return 0===e&&1/e===-1/0}function a(t,n){return t===n||e(t)&&e(n)?0!==t||s(t)===s(n):void 0}function u(s,u){function l(e){return"object"!=typeof e||null===e||e instanceof Boolean||e instanceof Date||e instanceof Number||e instanceof RegExp||e instanceof String?!1:!0}function c(e,t){var n;for(n=0;n<e.length;n++)if(e[n]===t)return n;return-1}var d=[],p=[],h=[],y=[],m={};return function g(s,u,v,b){var w=typeof s,x=typeof u;if(s===u||e(s)||e(u)||null==s||null==u||"object"!==w||"object"!==x)return a(s,u);if(r(s)||r(u))return!1;var C=o(s),E=o(u);if(!(!C&&!E||C&&E&&s.getTime()===u.getTime()))return!1;if(s instanceof RegExp&&u instanceof RegExp&&s.toString()!==u.toString())return!1;var T=t(s),A=t(u),k=i(s),j=i(u);if(n(s)||n(u)){if(s.length!==u.length)return!1}else if(w!==x||T!==A||k.length!==j.length)return!1;var S,O,q,R,D,N,I,P,M,L,F;for(O=0,q=k.length;q>O;O++){if(S=k[O],!f.hasOwnProperty.call(u,S))return!1;if(R=s[S],D=u[S],N=l(R),I=l(D),P=N?c(d,R):-1,M=I?c(p,D):-1,L=-1!==P?h[P]:v+"["+JSON.stringify(S)+"]",F=-1!==M?y[M]:b+"["+JSON.stringify(S)+"]",m[L+F])return!0;if(-1===P&&N&&(d.push(R),h.push(L)),-1===M&&I&&(p.push(D),y.push(F)),N&&I&&(m[L+F]=!0),!g(R,D,L,F))return!1}return!0}(s,u,"$1","$2")}function l(e,t){if(0===t.length)return!0;var n,r,i,o;for(n=0,r=e.length;r>n;++n)if(c(e[n],t[0])){for(i=0,o=t.length;o>i;++i)if(!c(e[n+i],t[i]))return!1;return!0}return!1}var c,f=Object.prototype,d="undefined"!=typeof document&&document.createElement("div");return c=function p(e,n){if(n&&"function"==typeof n.test)return n.test(e);if("function"==typeof n)return n(e)===!0;if("string"==typeof n){n=n.toLowerCase();var r="string"==typeof e||!!e;return r&&String(e).toLowerCase().indexOf(n)>=0}if("number"==typeof n)return n===e;if("boolean"==typeof n)return n===e;if("undefined"==typeof n)return"undefined"==typeof e;if(null===n)return null===e;if("Array"===t(e)&&"Array"===t(n))return l(e,n);if(n&&"object"==typeof n){if(n===e)return!0;var i;for(i in n){var o=e[i];if("undefined"==typeof o&&"function"==typeof e.getAttribute&&(o=e.getAttribute(i)),null===n[i]||"undefined"==typeof n[i]){if(o!==n[i])return!1}else if("undefined"==typeof o||!p(o,n[i]))return!1}return!0}throw new Error("Matcher was not a string, a number, a function, a boolean or an object")},{isArguments:n,isElement:r,isDate:o,isNegZero:s,identical:a,deepEqual:u,match:c,keys:i}}),("function"==typeof define&&define.amd&&function(e){define("formatio",["samsam"],e)}||"object"==typeof module&&function(e){module.exports=e(require("samsam"))}||function(e){this.formatio=e(this.samsam)})(function(e){function t(e){if(!e)return"";if(e.displayName)return e.displayName;if(e.name)return e.name;var t=e.toString().match(/function\s+([^\(]+)/m);return t&&t[1]||""}function n(e,n){var r,i,o=t(n&&n.constructor),a=e.excludeConstructors||s.excludeConstructors||[];for(r=0,i=a.length;i>r;++r){if("string"==typeof a[r]&&a[r]===o)return"";if(a[r].test&&a[r].test(o))return""}return o}function r(e,t){if("object"!=typeof e)return!1;var n,r;for(n=0,r=t.length;r>n;++n)if(t[n]===e)return!0;return!1}function i(t,n,o,s){if("string"==typeof n){var u=t.quoteStrings,l="boolean"!=typeof u||u;return o||l?'"'+n+'"':n}if("function"==typeof n&&!(n instanceof RegExp))return i.func(n);if(o=o||[],r(n,o))return"[Circular]";if("[object Array]"===Object.prototype.toString.call(n))return i.array.call(t,n,o);if(!n)return String(1/n===-1/0?"-0":n);if(e.isElement(n))return i.element(n);if("function"==typeof n.toString&&n.toString!==Object.prototype.toString)return n.toString();var c,f;for(c=0,f=a.length;f>c;c++)if(n===a[c].object)return a[c].value;return i.object.call(t,n,o,s)}function o(e){for(var t in e)this[t]=e[t]}var s={excludeConstructors:["Object",/^.$/],quoteStrings:!0,limitChildrenCount:0},a=(Object.prototype.hasOwnProperty,[]);return"undefined"!=typeof global&&a.push({object:global,value:"[object global]"}),"undefined"!=typeof document&&a.push({object:document,value:"[object HTMLDocument]"}),"undefined"!=typeof window&&a.push({object:window,value:"[object Window]"}),i.func=function(e){return"function "+t(e)+"() {}"},i.array=function(e,t){t=t||[],t.push(e);var n,r,o=[];for(r=this.limitChildrenCount>0?Math.min(this.limitChildrenCount,e.length):e.length,n=0;r>n;++n)o.push(i(this,e[n],t));return r<e.length&&o.push("[... "+(e.length-r)+" more elements]"),"["+o.join(", ")+"]"},i.object=function(t,o,s){o=o||[],o.push(t),s=s||0;var a,u,l,c,f,d,p=[],h=e.keys(t).sort(),y=3;for(d=this.limitChildrenCount>0?Math.min(this.limitChildrenCount,h.length):h.length,c=0;d>c;++c)a=h[c],l=t[a],u=r(l,o)?"[Circular]":i(this,l,o,s+2),u=(/\s/.test(a)?'"'+a+'"':a)+": "+u,y+=u.length,p.push(u);var m=n(this,t),g=m?"["+m+"] ":"",v="";for(c=0,f=s;f>c;++c)v+=" ";return d<h.length&&p.push("[... "+(h.length-d)+" more elements]"),y+s>80?g+"{\n "+v+p.join(",\n "+v)+"\n"+v+"}":g+"{ "+p.join(", ")+" }"},i.element=function(e){var t,n,r,i,o,s=e.tagName.toLowerCase(),a=e.attributes,u=[];for(r=0,i=a.length;i>r;++r)t=a.item(r),n=t.nodeName.toLowerCase().replace("html:",""),o=t.nodeValue,("contenteditable"!==n||"inherit"!==o)&&o&&u.push(n+'="'+o+'"');var l="<"+s+(u.length>0?" ":""),c=e.innerHTML;c.length>20&&(c=c.substr(0,20)+"[...]");var f=l+u.join(" ")+">"+c+"</"+s+">";return f.replace(/ contentEditable="inherit"/,"")},o.prototype={functionName:t,configure:function(e){return new o(e)},constructorName:function(e){return n(this,e)},ascii:function(e,t,n){return i(this,e,t,n)}},o.prototype}),!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.lolex=e()}}(function(){var define,module,exports;return function e(t,n,r){function i(s,a){if(!n[s]){if(!t[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(o)return o(s,!0);var l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var c=n[s]={exports:{}};t[s][0].call(c.exports,function(e){var n=t[s][1][e];return i(n?n:e)},c,c.exports,e,t,n,r)}return n[s].exports}for(var o="function"==typeof require&&require,s=0;s<r.length;s++)i(r[s]);return i}({1:[function(require,module,exports){(function(global){function parseTime(e){if(!e)return 0;var t,n=e.split(":"),r=n.length,i=r,o=0;if(r>3||!/^(\d\d:){0,2}\d\d?$/.test(e))throw new Error("tick only understands numbers and 'h:m:s'");for(;i--;){if(t=parseInt(n[i],10),t>=60)throw new Error("Invalid time "+e);o+=t*Math.pow(60,r-i-1)}return 1e3*o}function getEpoch(e){if(!e)return 0;if("function"==typeof e.getTime)return e.getTime();if("number"==typeof e)return e;throw new TypeError("now should be milliseconds since UNIX epoch")}function inRange(e,t,n){return n&&n.callAt>=e&&n.callAt<=t}function mirrorDateProperties(e,t){t.now?e.now=function(){return e.clock.now}:delete e.now,t.toSource?e.toSource=function(){return t.toSource()}:delete e.toSource,e.toString=function(){return t.toString()},e.prototype=t.prototype,e.parse=t.parse,e.UTC=t.UTC,e.prototype.toUTCString=t.prototype.toUTCString;for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e}function createDate(){function e(t,n,r,i,o,s,a){switch(arguments.length){case 0:return new NativeDate(e.clock.now);case 1:return new NativeDate(t);case 2:return new NativeDate(t,n);case 3:return new NativeDate(t,n,r);case 4:return new NativeDate(t,n,r,i);case 5:return new NativeDate(t,n,r,i,o);case 6:return new NativeDate(t,n,r,i,o,s);default:return new NativeDate(t,n,r,i,o,s,a)}}return mirrorDateProperties(e,NativeDate)}function addTimer(e,t){if("undefined"==typeof t.func)throw new Error("Callback must be provided to timer calls");return e.timers||(e.timers={}),t.id=id++,t.createdAt=e.now,t.callAt=e.now+(t.delay||0),e.timers[t.id]=t,addTimerReturnsObject?{id:t.id,ref:function(){},unref:function(){}}:t.id}function firstTimerInRange(e,t,n){var r=e.timers,i=null;for(var o in r)inRange(t,n,r[o])&&(!i||~compareTimers(i,r[o]))&&(i=r[o]);return i}function compareTimers(e,t){return e.callAt<t.callAt?-1:e.callAt>t.callAt?1:e.immediate&&!t.immediate?-1:!e.immediate&&t.immediate?1:e.createdAt<t.createdAt?-1:e.createdAt>t.createdAt?1:e.id<t.id?-1:e.id>t.id?1:void 0}function callTimer(clock,timer){"number"==typeof timer.interval?clock.timers[timer.id].callAt+=timer.interval:delete clock.timers[timer.id];try{"function"==typeof timer.func?timer.func.apply(null,timer.args):eval(timer.func)}catch(e){var exception=e}if(clock.timers[timer.id]){if(exception)throw exception}else if(exception)throw exception}function uninstall(e,t){for(var n,r=0,i=e.methods.length;i>r;r++)if(n=e.methods[r],t[n].hadOwnProperty)t[n]=e["_"+n];else try{delete t[n]}catch(o){}e.methods=[]}function hijackMethod(e,t,n){if(n[t].hadOwnProperty=Object.prototype.hasOwnProperty.call(e,t),n["_"+t]=e[t],"Date"==t){var r=mirrorDateProperties(n[t],e[t]);e[t]=r}else{e[t]=function(){return n[t].apply(n,arguments)};for(var i in n[t])n[t].hasOwnProperty(i)&&(e[t][i]=n[t][i])}e[t].clock=n}var timeoutResult=setTimeout(function(){},0),addTimerReturnsObject="object"==typeof timeoutResult;clearTimeout(timeoutResult);var NativeDate=Date,id=1,timers={setTimeout:setTimeout,clearTimeout:clearTimeout,setImmediate:"undefined"!=typeof setImmediate?setImmediate:void 0,clearImmediate:"undefined"!=typeof clearImmediate?clearImmediate:void 0,setInterval:setInterval,clearInterval:clearInterval,Date:Date},keys=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};exports.timers=timers;var createClock=exports.createClock=function(e){var t={now:getEpoch(e),timeouts:{},Date:createDate()};return t.Date.clock=t,t.setTimeout=function(e,n){return addTimer(t,{func:e,args:Array.prototype.slice.call(arguments,2),delay:n})},t.clearTimeout=function(e){e&&(t.timers||(t.timers=[]),"object"==typeof e&&(e=e.id),e in t.timers&&delete t.timers[e])},t.setInterval=function(e,n){return addTimer(t,{func:e,args:Array.prototype.slice.call(arguments,2),delay:n,interval:n})},t.clearInterval=function(e){t.clearTimeout(e)},t.setImmediate=function(e){return addTimer(t,{func:e,args:Array.prototype.slice.call(arguments,1),immediate:!0})},t.clearImmediate=function(e){t.clearTimeout(e)},t.tick=function(e){e="number"==typeof e?e:parseTime(e);for(var n,r=t.now,i=t.now+e,o=t.now,s=firstTimerInRange(t,r,i);s&&i>=r;){if(t.timers[s.id]){r=t.now=s.callAt;try{callTimer(t,s)}catch(a){n=n||a}}s=firstTimerInRange(t,o,i),o=r}if(t.now=i,n)throw n;return t.now},t.reset=function(){t.timers={}},t};exports.install=function(e,t,n){"number"==typeof e&&(n=t,t=e,e=null),e||(e=global);var r=createClock(t);r.uninstall=function(){uninstall(r,e)},r.methods=n||[],0===r.methods.length&&(r.methods=keys(timers));for(var i=0,o=r.methods.length;o>i;i++)hijackMethod(e,r.methods[i],r);return r}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1])(1)})}();var define,sinon=function(){function e(e,n,r){t=r.exports=e("./sinon/util/core"),e("./sinon/extend"),e("./sinon/typeOf"),e("./sinon/times_in_words"),e("./sinon/spy"),e("./sinon/call"),e("./sinon/behavior"),e("./sinon/stub"),e("./sinon/mock"),e("./sinon/collection"),e("./sinon/assert"),e("./sinon/sandbox"),e("./sinon/test"),e("./sinon/test_case"),e("./sinon/match"),e("./sinon/format"),e("./sinon/log_error")}var t,n="undefined"!=typeof module&&module.exports&&"function"==typeof require,r="function"==typeof define&&"object"==typeof define.amd&&define.amd;return r?define(e):n?(e(require,module.exports,module),t=module.exports):t={},t}();if(function(e){function t(e){var t=!1;try{e.appendChild(l),t=l.parentNode==e}catch(n){return!1}finally{try{e.removeChild(l)}catch(n){}}return t}function n(e){return l&&e&&1===e.nodeType&&t(e)}function r(e){return"function"==typeof e||!!(e&&e.constructor&&e.call&&e.apply)}function i(e){return"number"==typeof e&&isNaN(e)}function o(e,t){for(var n in t)c.call(e,n)||(e[n]=t[n])}function s(e){return"function"==typeof e&&"function"==typeof e.restore&&e.restore.sinon}function a(e){return e.wrapMethod=function(t,n,i){function s(e){if(r(e)){if(e.restore&&e.restore.sinon)a=new TypeError("Attempted to wrap "+n+" which is already wrapped");else if(e.calledBefore){var t=e.returns?"stubbed":"spied on";a=new TypeError("Attempted to wrap "+n+" which is already "+t)}}else a=new TypeError("Attempted to wrap "+typeof e+" property "+n+" as function");if(a)throw e&&e.stackTrace&&(a.stack+="\n--------------\n"+e.stackTrace),a}if(!t)throw new TypeError("Should wrap property of object");if("function"!=typeof i&&"object"!=typeof i)throw new TypeError("Method wrapper should be a function or a property descriptor");var a,u,l=t.hasOwnProperty?t.hasOwnProperty(n):c.call(t,n);if(f){var d,p="function"==typeof i?{value:i}:i,h=e.getPropertyDescriptor(t,n);if(h?h.restore&&h.restore.sinon&&(a=new TypeError("Attempted to wrap "+n+" which is already wrapped")):a=new TypeError("Attempted to wrap "+typeof u+" property "+n+" as function"),a)throw h&&h.stackTrace&&(a.stack+="\n--------------\n"+h.stackTrace),a;var y=e.objectKeys(p);for(d=0;d<y.length;d++)u=h[y[d]],s(u);for(o(p,h),d=0;d<y.length;d++)o(p[y[d]],h[y[d]]);Object.defineProperty(t,n,p)}else u=t[n],s(u),t[n]=i,i.displayName=n;return i.displayName=n,i.stackTrace=new Error("Stack Trace for original").stack,i.restore=function(){if(l)f&&Object.defineProperty(t,n,h);else try{delete t[n]}catch(e){}t[n]===i&&(t[n]=u)},i.restore.sinon=!0,f||o(i,u),i},e.create=function(e){var t=function(){};return t.prototype=e,new t},e.deepEqual=function t(r,o){if(e.match&&e.match.isMatcher(r))return r.test(o);if("object"!=typeof r||"object"!=typeof o)return i(r)&&i(o)?!0:r===o;if(n(r)||n(o))return r===o;if(r===o)return!0;if(null===r&&null!==o||null!==r&&null===o)return!1;if(r instanceof RegExp&&o instanceof RegExp)return r.source===o.source&&r.global===o.global&&r.ignoreCase===o.ignoreCase&&r.multiline===o.multiline;var s=Object.prototype.toString.call(r);if(s!=Object.prototype.toString.call(o))return!1;if("[object Date]"==s)return r.valueOf()===o.valueOf();var a,u=0,l=0;if("[object Array]"==s&&r.length!==o.length)return!1;for(a in r){if(u+=1,!(a in o))return!1;if(!t(r[a],o[a]))return!1}for(a in o)l+=1;return u==l},e.functionName=function(e){var t=e.displayName||e.name;if(!t){var n=e.toString().match(/function ([^\s\(]+)/);t=n&&n[1]}return t},e.functionToString=function(){if(this.getCall&&this.callCount)for(var e,t,n=this.callCount;n--;){e=this.getCall(n).thisValue;for(t in e)if(e[t]===this)return t}return this.displayName||"sinon fake"},e.objectKeys=function(e){if(e!==Object(e))throw new TypeError("sinon.objectKeys called on a non-object");var t,n=[];for(t in e)c.call(e,t)&&n.push(t);return n},e.getPropertyDescriptor=function(e,t){for(var n,r=e;r&&!(n=Object.getOwnPropertyDescriptor(r,t));)r=Object.getPrototypeOf(r);return n},e.getConfig=function(t){var n={};t=t||{};var r=e.defaultConfig;for(var i in r)r.hasOwnProperty(i)&&(n[i]=t.hasOwnProperty(i)?t[i]:r[i]);return n},e.defaultConfig={injectIntoThis:!0,injectInto:null,properties:["spy","stub","mock","clock","server","requests"],useFakeTimers:!0,useFakeServer:!0},e.timesInWords=function(e){return 1==e&&"once"||2==e&&"twice"||3==e&&"thrice"||(e||0)+" times"},e.calledInOrder=function(e){for(var t=1,n=e.length;n>t;t++)if(!e[t-1].calledBefore(e[t])||!e[t].called)return!1;return!0},e.orderByFirstCall=function(e){return e.sort(function(e,t){var n=e.getCall(0),r=t.getCall(0),i=n&&n.callId||-1,o=r&&r.callId||-1;return o>i?-1:1})},e.createStubInstance=function(t){if("function"!=typeof t)throw new TypeError("The constructor should be a function.");return e.stub(e.create(t.prototype))},e.restore=function(e){if(null!==e&&"object"==typeof e)for(var t in e)s(e[t])&&e[t].restore();else s(e)&&e.restore()},e}function u(e,t){a(t)}var l="undefined"!=typeof document&&document.createElement("div"),c=Object.prototype.hasOwnProperty,f="keys"in Object,d="undefined"!=typeof module&&module.exports&&"function"==typeof require,p="function"==typeof define&&"object"==typeof define.amd&&define.amd;if(p)define(u);else if(d)u(require,module.exports);else{if(!e)return;a(e)}}("object"==typeof sinon&&sinon||null),function(e){function t(e){function t(e){var t,r,i,o=Array.prototype.slice.call(arguments,1);for(r=0;r<o.length;r++){t=o[r];for(i in t)t.hasOwnProperty(i)&&(e[i]=t[i]);n&&t.hasOwnProperty("toString")&&t.toString!==e.toString&&(e.toString=t.toString)}return e}var n=function(){var e={constructor:function(){return"0"},toString:function(){return"1"},valueOf:function(){return"2"},toLocaleString:function(){return"3"},prototype:function(){return"4"},isPrototypeOf:function(){return"5"},propertyIsEnumerable:function(){return"6"},hasOwnProperty:function(){return"7"},length:function(){return"8"},unique:function(){return"9"}},t=[];for(var n in e)t.push(e[n]());return"0123456789"!==t.join("")}();return e.extend=t,e.extend}function n(e,n,r){var i=e("./util/core");r.exports=t(i)}var r="undefined"!=typeof module&&module.exports&&"function"==typeof require,i="function"==typeof define&&"object"==typeof define.amd&&define.amd;if(i)define(n);else if(r)n(require,module.exports,module);else{if(!e)return;t(e)}}("object"==typeof sinon&&sinon||null),function(e){function t(e){function t(e){switch(e){case 1:return"once";case 2:return"twice";case 3:return"thrice";default:return(e||0)+" times"}}return e.timesInWords=t,e.timesInWords}function n(e,n,r){var i=e("./util/core");r.exports=t(i)}var r="undefined"!=typeof module&&module.exports&&"function"==typeof require,i="function"==typeof define&&"object"==typeof define.amd&&define.amd;if(i)define(n);else if(r)n(require,module.exports,module);else{if(!e)return;t(e)}}("object"==typeof sinon&&sinon||null),function(e){function t(e){function t(e){if(null===e)return"null";if(void 0===e)return"undefined";var t=Object.prototype.toString.call(e);return t.substring(8,t.length-1).toLowerCase()}return e.typeOf=t,e.typeOf}function n(e,n,r){var i=e("./util/core");r.exports=t(i)}var r="undefined"!=typeof module&&module.exports&&"function"==typeof require,i="function"==typeof define&&"object"==typeof define.amd&&define.amd;if(i)define(n);else if(r)n(require,module.exports,module);else{if(!e)return;t(e)}}("object"==typeof sinon&&sinon||null,"object"==typeof formatio&&formatio),function(e){function t(e){function t(t,n,r){var i=e.typeOf(t);if(i!==n)throw new TypeError("Expected type of "+r+" to be "+n+", but was "+i)}function n(e){return o.isPrototypeOf(e)}function r(t,n){if(null===n||void 0===n)return!1;for(var i in t)if(t.hasOwnProperty(i)){var o=t[i],a=n[i];if(s.isMatcher(o)){if(!o.test(a))return!1}else if("object"===e.typeOf(o)){if(!r(o,a))return!1}else if(!e.deepEqual(o,a))return!1}return!0}function i(n,r){return function(i,o){t(i,"string","property");var a=1===arguments.length,u=r+'("'+i+'"';return a||(u+=", "+o),u+=")",s(function(t){return void 0!==t&&null!==t&&n(t,i)?a||e.deepEqual(o,t[i]):!1},u)}}var o={toString:function(){return this.message}};o.or=function(t){if(!arguments.length)throw new TypeError("Matcher expected");n(t)||(t=s(t));var r=this,i=e.create(o);return i.test=function(e){return r.test(e)||t.test(e)},i.message=r.message+".or("+t.message+")",i},o.and=function(t){if(!arguments.length)throw new TypeError("Matcher expected");n(t)||(t=s(t));var r=this,i=e.create(o);return i.test=function(e){return r.test(e)&&t.test(e)},i.message=r.message+".and("+t.message+")",i};var s=function(t,n){var i=e.create(o),s=e.typeOf(t);switch(s){case"object":if("function"==typeof t.test)return i.test=function(e){return t.test(e)===!0},i.message="match("+e.functionName(t.test)+")",i;var a=[];for(var u in t)t.hasOwnProperty(u)&&a.push(u+": "+t[u]);i.test=function(e){return r(t,e)},i.message="match("+a.join(", ")+")";break;case"number":i.test=function(e){return t==e};break;case"string":i.test=function(e){return"string"!=typeof e?!1:-1!==e.indexOf(t)},i.message='match("'+t+'")';break;case"regexp":i.test=function(e){return"string"!=typeof e?!1:t.test(e)};break;case"function":i.test=t,i.message=n?n:"match("+e.functionName(t)+")";break;default:i.test=function(n){return e.deepEqual(t,n)}}return i.message||(i.message="match("+t+")"),i};return s.isMatcher=n,s.any=s(function(){return!0},"any"),s.defined=s(function(e){return null!==e&&void 0!==e},"defined"),s.truthy=s(function(e){return!!e},"truthy"),s.falsy=s(function(e){return!e},"falsy"),s.same=function(e){return s(function(t){return e===t},"same("+e+")")},s.typeOf=function(n){return t(n,"string","type"),s(function(t){return e.typeOf(t)===n},'typeOf("'+n+'")')},s.instanceOf=function(n){return t(n,"function","type"),s(function(e){return e instanceof n},"instanceOf("+e.functionName(n)+")")},s.has=i(function(e,t){return"object"==typeof e?t in e:void 0!==e[t]},"has"),s.hasOwn=i(function(e,t){return e.hasOwnProperty(t)},"hasOwn"),s.bool=s.typeOf("boolean"),s.number=s.typeOf("number"),s.string=s.typeOf("string"),s.object=s.typeOf("object"),s.func=s.typeOf("function"),s.array=s.typeOf("array"),s.regexp=s.typeOf("regexp"),s.date=s.typeOf("date"),e.match=s,s}function n(e,n,r){var i=e("./util/core");e("./typeOf"),r.exports=t(i)}var r="undefined"!=typeof module&&module.exports&&"function"==typeof require,i="function"==typeof define&&"object"==typeof define.amd&&define.amd;if(i)define(n);else if(r)n(require,module.exports,module);else{if(!e)return;t(e)}}("object"==typeof sinon&&sinon||null),function(e,t){function n(e){function n(e){return""+e}function r(){function e(){return n.ascii.apply(n,arguments)}var n=t.configure({quoteStrings:!1,limitChildrenCount:250});return e}function i(){function e(e){return"object"==typeof e&&e.toString===Object.prototype.toString?t.inspect(e):e}try{var t=require("util")}catch(r){}return t?e:n}var o,s="undefined"!=typeof module&&module.exports&&"function"==typeof require;if(s)try{t=require("formatio")}catch(a){}return o=t?r():s?i():n,e.format=o,e.format}function r(e,t,r){var i=e("./util/core");r.exports=n(i)}var i="undefined"!=typeof module&&module.exports&&"function"==typeof require,o="function"==typeof define&&"object"==typeof define.amd&&define.amd;if(o)define(r);else if(i)r(require,module.exports,module);else{if(!e)return;n(e)}}("object"==typeof sinon&&sinon||null,"object"==typeof formatio&&formatio),function(e){function t(e){function t(t,n,i){var o=e.functionName(t)+n;throw i.length&&(o+=" Received ["+r.call(i).join(", ")+"]"),new Error(o)}function n(t,n,r,o,s,a){if("number"!=typeof a)throw new TypeError("Call id is not a number");var u=e.create(i);return u.proxy=t,u.thisValue=n,u.args=r,u.returnValue=o,u.exception=s,u.callId=a,u}var r=Array.prototype.slice,i={calledOn:function(t){return e.match&&e.match.isMatcher(t)?t.test(this.thisValue):this.thisValue===t},calledWith:function(){var t=arguments.length;if(t>this.args.length)return!1;for(var n=0;t>n;n+=1)if(!e.deepEqual(arguments[n],this.args[n]))return!1;return!0},calledWithMatch:function(){var t=arguments.length;if(t>this.args.length)return!1;for(var n=0;t>n;n+=1){var r=this.args[n],i=arguments[n];if(!e.match||!e.match(i).test(r))return!1}return!0},calledWithExactly:function(){return arguments.length==this.args.length&&this.calledWith.apply(this,arguments)},notCalledWith:function(){return!this.calledWith.apply(this,arguments)},notCalledWithMatch:function(){return!this.calledWithMatch.apply(this,arguments)},returned:function(t){return e.deepEqual(t,this.returnValue)},threw:function(e){return"undefined"!=typeof e&&this.exception?this.exception===e||this.exception.name===e:!!this.exception},calledWithNew:function(){return this.proxy.prototype&&this.thisValue instanceof this.proxy},calledBefore:function(e){return this.callId<e.callId},calledAfter:function(e){return this.callId>e.callId},callArg:function(e){this.args[e]()},callArgOn:function(e,t){this.args[e].apply(t)},callArgWith:function(e){this.callArgOnWith.apply(this,[e,null].concat(r.call(arguments,1)))},callArgOnWith:function(e,t){var n=r.call(arguments,2);this.args[e].apply(t,n)},"yield":function(){this.yieldOn.apply(this,[null].concat(r.call(arguments,0)))},yieldOn:function(e){for(var n=this.args,i=0,o=n.length;o>i;++i)if("function"==typeof n[i])return void n[i].apply(e,r.call(arguments,1));t(this.proxy," cannot yield since no callback was passed.",n)},yieldTo:function(e){this.yieldToOn.apply(this,[e,null].concat(r.call(arguments,1)))},yieldToOn:function(e,n){for(var i=this.args,o=0,s=i.length;s>o;++o)if(i[o]&&"function"==typeof i[o][e])return void i[o][e].apply(n,r.call(arguments,2));t(this.proxy," cannot yield to '"+e+"' since no callback was passed.",i)},toString:function(){for(var t=this.proxy.toString()+"(",n=[],r=0,i=this.args.length;i>r;++r)n.push(e.format(this.args[r]));return t=t+n.join(", ")+")","undefined"!=typeof this.returnValue&&(t+=" => "+e.format(this.returnValue)),this.exception&&(t+=" !"+this.exception.name,this.exception.message&&(t+="("+this.exception.message+")")),t}};return i.invokeCallback=i.yield,n.toString=i.toString,e.spyCall=n,n}function n(e,n,r){var i=e("./util/core");e("./match"),e("./format"),r.exports=t(i)}var r="undefined"!=typeof module&&module.exports&&"function"==typeof require,i="function"==typeof define&&"object"==typeof define.amd&&define.amd;if(i)define(n);else if(r)n(require,module.exports,module);else{if(!e)return;t(e)}}("object"==typeof sinon&&sinon||null),function(sinon){function makeApi(sinon){function spy(e,t,n){if(!t&&"function"==typeof e)return spy.create(e);if(!e&&!t)return spy.create(function(){});if(n){for(var r=sinon.getPropertyDescriptor(e,t),i=0;i<n.length;i++)r[n[i]]=spy.create(r[n[i]]);return sinon.wrapMethod(e,t,r)}var o=e[t];return sinon.wrapMethod(e,t,spy.create(o))}function matchingFake(e,t,n){if(e)for(var r=0,i=e.length;i>r;r++)if(e[r].matches(t,n))return e[r]}function incrementCallCount(){this.called=!0,this.callCount+=1,this.notCalled=!1,this.calledOnce=1==this.callCount,this.calledTwice=2==this.callCount,this.calledThrice=3==this.callCount}function createCallProperties(){this.firstCall=this.getCall(0),this.secondCall=this.getCall(1),this.thirdCall=this.getCall(2),this.lastCall=this.getCall(this.callCount-1)}function createProxy(func,proxyLength){var p;return proxyLength?eval("p = (function proxy("+vars.substring(0,2*proxyLength-1)+") { return p.invoke(func, this, slice.call(arguments)); });"):p=function(){return p.invoke(func,this,slice.call(arguments))},p.isSinonProxy=!0,p}function delegateToCalls(e,t,n,r){spyApi[e]=function(){if(!this.called)return r?r.apply(this,arguments):!1;for(var i,o=0,s=0,a=this.callCount;a>s;s+=1)if(i=this.getCall(s),i[n||e].apply(i,arguments)&&(o+=1,t))return!0;return o===this.callCount}}var push=Array.prototype.push,slice=Array.prototype.slice,callId=0,vars="a,b,c,d,e,f,g,h,i,j,k,l",uuid=0,spyApi={reset:function(){if(this.invoking){var e=new Error("Cannot reset Sinon function while invoking it. Move the call to .reset outside of the callback.");throw e.name="InvalidResetException",e}if(this.called=!1,this.notCalled=!0,this.calledOnce=!1,this.calledTwice=!1,this.calledThrice=!1,this.callCount=0,this.firstCall=null,this.secondCall=null,this.thirdCall=null,this.lastCall=null,this.args=[],this.returnValues=[],this.thisValues=[],this.exceptions=[],this.callIds=[],this.fakes)for(var t=0;t<this.fakes.length;t++)this.fakes[t].reset();return this},create:function(e,t){var n;"function"!=typeof e?e=function(){}:n=sinon.functionName(e),t||(t=e.length);var r=createProxy(e,t);return sinon.extend(r,spy),delete r.create,sinon.extend(r,e),r.reset(),r.prototype=e.prototype,r.displayName=n||"spy",r.toString=sinon.functionToString,r.instantiateFake=sinon.spy.create,r.id="spy#"+uuid++,r},invoke:function(e,t,n){var r,i,o=matchingFake(this.fakes,n);incrementCallCount.call(this),push.call(this.thisValues,t),push.call(this.args,n),push.call(this.callIds,callId++),createCallProperties.call(this);try{this.invoking=!0,i=o?o.invoke(e,t,n):(this.func||e).apply(t,n);var s=this.getCall(this.callCount-1);s.calledWithNew()&&"object"!=typeof i&&(i=t)}catch(a){r=a}finally{delete this.invoking}if(push.call(this.exceptions,r),push.call(this.returnValues,i),createCallProperties.call(this),void 0!==r)throw r;return i},named:function(e){return this.displayName=e,this},getCall:function(e){return 0>e||e>=this.callCount?null:sinon.spyCall(this,this.thisValues[e],this.args[e],this.returnValues[e],this.exceptions[e],this.callIds[e])},getCalls:function(){var e,t=[];for(e=0;e<this.callCount;e++)t.push(this.getCall(e));return t},calledBefore:function(e){return this.called?e.called?this.callIds[0]<e.callIds[e.callIds.length-1]:!0:!1},calledAfter:function(e){return this.called&&e.called?this.callIds[this.callCount-1]>e.callIds[e.callCount-1]:!1},withArgs:function(){var e=slice.call(arguments);if(this.fakes){var t=matchingFake(this.fakes,e,!0);if(t)return t}else this.fakes=[];var n=this,r=this.instantiateFake();r.matchingAguments=e,r.parent=this,push.call(this.fakes,r),r.withArgs=function(){return n.withArgs.apply(n,arguments)};for(var i=0;i<this.args.length;i++)r.matches(this.args[i])&&(incrementCallCount.call(r),push.call(r.thisValues,this.thisValues[i]),push.call(r.args,this.args[i]),push.call(r.returnValues,this.returnValues[i]),push.call(r.exceptions,this.exceptions[i]),push.call(r.callIds,this.callIds[i]));return createCallProperties.call(r),r},matches:function(e,t){var n=this.matchingAguments;return n.length<=e.length&&sinon.deepEqual(n,e.slice(0,n.length))?!t||n.length==e.length:void 0},printf:function(e){var t,n=this,r=slice.call(arguments,1);return(e||"").replace(/%(.)/g,function(e,i){return t=spyApi.formatters[i],"function"==typeof t?t.call(null,n,r):isNaN(parseInt(i,10))?"%"+i:sinon.format(r[i-1])})}};return delegateToCalls("calledOn",!0),delegateToCalls("alwaysCalledOn",!1,"calledOn"),delegateToCalls("calledWith",!0),delegateToCalls("calledWithMatch",!0),delegateToCalls("alwaysCalledWith",!1,"calledWith"),delegateToCalls("alwaysCalledWithMatch",!1,"calledWithMatch"),delegateToCalls("calledWithExactly",!0),delegateToCalls("alwaysCalledWithExactly",!1,"calledWithExactly"),delegateToCalls("neverCalledWith",!1,"notCalledWith",function(){return!0}),delegateToCalls("neverCalledWithMatch",!1,"notCalledWithMatch",function(){return!0}),delegateToCalls("threw",!0),delegateToCalls("alwaysThrew",!1,"threw"),delegateToCalls("returned",!0),delegateToCalls("alwaysReturned",!1,"returned"),delegateToCalls("calledWithNew",!0),delegateToCalls("alwaysCalledWithNew",!1,"calledWithNew"),delegateToCalls("callArg",!1,"callArgWith",function(){throw new Error(this.toString()+" cannot call arg since it was not yet invoked.")}),spyApi.callArgWith=spyApi.callArg,delegateToCalls("callArgOn",!1,"callArgOnWith",function(){throw new Error(this.toString()+" cannot call arg since it was not yet invoked.")}),spyApi.callArgOnWith=spyApi.callArgOn,delegateToCalls("yield",!1,"yield",function(){throw new Error(this.toString()+" cannot yield since it was not yet invoked.")
}),spyApi.invokeCallback=spyApi.yield,delegateToCalls("yieldOn",!1,"yieldOn",function(){throw new Error(this.toString()+" cannot yield since it was not yet invoked.")}),delegateToCalls("yieldTo",!1,"yieldTo",function(e){throw new Error(this.toString()+" cannot yield to '"+e+"' since it was not yet invoked.")}),delegateToCalls("yieldToOn",!1,"yieldToOn",function(e){throw new Error(this.toString()+" cannot yield to '"+e+"' since it was not yet invoked.")}),spyApi.formatters={c:function(e){return sinon.timesInWords(e.callCount)},n:function(e){return e.toString()},C:function(e){for(var t=[],n=0,r=e.callCount;r>n;++n){var i=" "+e.getCall(n).toString();/\n/.test(t[n-1])&&(i="\n"+i),push.call(t,i)}return t.length>0?"\n"+t.join("\n"):""},t:function(e){for(var t=[],n=0,r=e.callCount;r>n;++n)push.call(t,sinon.format(e.thisValues[n]));return t.join(", ")},"*":function(e,t){for(var n=[],r=0,i=t.length;i>r;++r)push.call(n,sinon.format(t[r]));return n.join(", ")}},sinon.extend(spy,spyApi),spy.spyCall=sinon.spyCall,sinon.spy=spy,spy}function loadDependencies(e,t,n){var r=e("./util/core");e("./call"),e("./extend"),e("./times_in_words"),e("./format"),n.exports=makeApi(r)}var isNode="undefined"!=typeof module&&module.exports&&"function"==typeof require,isAMD="function"==typeof define&&"object"==typeof define.amd&&define.amd;if(isAMD)define(loadDependencies);else if(isNode)loadDependencies(require,module.exports,module);else{if(!sinon)return;makeApi(sinon)}}("object"==typeof sinon&&sinon||null),function(e){function t(e,t){return"string"==typeof e?(this.exception=new Error(t||""),this.exception.name=e):this.exception=e?e:new Error("Error"),this}function n(e,t){var n=e.callArgAt;if(n>=0)return t[n];var r;n===a&&(r=t),n===u&&(r=o.call(t).reverse());for(var i=e.callArgProp,s=0,l=r.length;l>s;++s){if(!i&&"function"==typeof r[s])return r[s];if(i&&r[s]&&"function"==typeof r[s][i])return r[s][i]}return null}function r(e){function r(t,n,r){if(t.callArgAt<0){var i;return i=t.callArgProp?e.functionName(t.stub)+" expected to yield to '"+t.callArgProp+"', but no object with such a property was passed.":e.functionName(t.stub)+" expected to yield, but no callback was passed.",r.length>0&&(i+=" Received ["+s.call(r,", ")+"]"),i}return"argument at index "+t.callArgAt+" is not a function: "+n}function i(e,t){if("number"==typeof e.callArgAt){var i=n(e,t);if("function"!=typeof i)throw new TypeError(r(e,i,t));e.callbackAsync?l(function(){i.apply(e.callbackContext,e.callbackArguments)}):i.apply(e.callbackContext,e.callbackArguments)}}var c={create:function(t){var n=e.extend({},e.behavior);return delete n.create,n.stub=t,n},isPresent:function(){return"number"==typeof this.callArgAt||this.exception||"number"==typeof this.returnArgAt||this.returnThis||this.returnValueDefined},invoke:function(e,t){if(i(this,t),this.exception)throw this.exception;return"number"==typeof this.returnArgAt?t[this.returnArgAt]:this.returnThis?e:this.returnValue},onCall:function(e){return this.stub.onCall(e)},onFirstCall:function(){return this.stub.onFirstCall()},onSecondCall:function(){return this.stub.onSecondCall()},onThirdCall:function(){return this.stub.onThirdCall()},withArgs:function(){throw new Error('Defining a stub by invoking "stub.onCall(...).withArgs(...)" is not supported. Use "stub.withArgs(...).onCall(...)" to define sequential behavior for calls with certain arguments.')},callsArg:function(e){if("number"!=typeof e)throw new TypeError("argument index is not number");return this.callArgAt=e,this.callbackArguments=[],this.callbackContext=void 0,this.callArgProp=void 0,this.callbackAsync=!1,this},callsArgOn:function(e,t){if("number"!=typeof e)throw new TypeError("argument index is not number");if("object"!=typeof t)throw new TypeError("argument context is not an object");return this.callArgAt=e,this.callbackArguments=[],this.callbackContext=t,this.callArgProp=void 0,this.callbackAsync=!1,this},callsArgWith:function(e){if("number"!=typeof e)throw new TypeError("argument index is not number");return this.callArgAt=e,this.callbackArguments=o.call(arguments,1),this.callbackContext=void 0,this.callArgProp=void 0,this.callbackAsync=!1,this},callsArgOnWith:function(e,t){if("number"!=typeof e)throw new TypeError("argument index is not number");if("object"!=typeof t)throw new TypeError("argument context is not an object");return this.callArgAt=e,this.callbackArguments=o.call(arguments,2),this.callbackContext=t,this.callArgProp=void 0,this.callbackAsync=!1,this},yields:function(){return this.callArgAt=a,this.callbackArguments=o.call(arguments,0),this.callbackContext=void 0,this.callArgProp=void 0,this.callbackAsync=!1,this},yieldsRight:function(){return this.callArgAt=u,this.callbackArguments=o.call(arguments,0),this.callbackContext=void 0,this.callArgProp=void 0,this.callbackAsync=!1,this},yieldsOn:function(e){if("object"!=typeof e)throw new TypeError("argument context is not an object");return this.callArgAt=a,this.callbackArguments=o.call(arguments,1),this.callbackContext=e,this.callArgProp=void 0,this.callbackAsync=!1,this},yieldsTo:function(e){return this.callArgAt=a,this.callbackArguments=o.call(arguments,1),this.callbackContext=void 0,this.callArgProp=e,this.callbackAsync=!1,this},yieldsToOn:function(e,t){if("object"!=typeof t)throw new TypeError("argument context is not an object");return this.callArgAt=a,this.callbackArguments=o.call(arguments,2),this.callbackContext=t,this.callArgProp=e,this.callbackAsync=!1,this},"throws":t,throwsException:t,returns:function(e){return this.returnValue=e,this.returnValueDefined=!0,this},returnsArg:function(e){if("number"!=typeof e)throw new TypeError("argument index is not number");return this.returnArgAt=e,this},returnsThis:function(){return this.returnThis=!0,this}};for(var f in c)c.hasOwnProperty(f)&&f.match(/^(callsArg|yields)/)&&!f.match(/Async/)&&(c[f+"Async"]=function(e){return function(){var t=this[e].apply(this,arguments);return this.callbackAsync=!0,t}}(f));return e.behavior=c,c}function i(e,t,n){var i=e("./util/core");e("./extend"),n.exports=r(i)}var o=Array.prototype.slice,s=Array.prototype.join,a=-1,u=-2,l=function(){return"object"==typeof process&&"function"==typeof process.nextTick?process.nextTick:"function"==typeof setImmediate?setImmediate:function(e){setTimeout(e,0)}}(),c="undefined"!=typeof module&&module.exports&&"function"==typeof require,f="function"==typeof define&&"object"==typeof define.amd&&define.amd;if(f)define(i);else if(c)i(require,module.exports,module);else{if(!e)return;r(e)}}("object"==typeof sinon&&sinon||null),function(e){function t(e){function t(n,r,i){if(i&&"function"!=typeof i&&"object"!=typeof i)throw new TypeError("Custom stub should be a function or a property descriptor");var o;if(i){if("function"==typeof i)o=e.spy&&e.spy.create?e.spy.create(i):i;else if(o=i,e.spy&&e.spy.create)for(var s=e.objectKeys(o),a=0;a<s.length;a++)o[s[a]]=e.spy.create(o[s[a]])}else{var u=0;"object"==typeof n&&"function"==typeof n[r]&&(u=n[r].length),o=t.create(u)}if(!n&&"undefined"==typeof r)return e.stub.create();if("undefined"==typeof r&&"object"==typeof n){for(var l in n)"function"==typeof e.getPropertyDescriptor(n,l).value&&t(n,l);return n}return e.wrapMethod(n,r,o)}function n(t){return t.defaultBehavior||r(t)||e.behavior.create(t)}function r(e){return e.parent&&i(e.parent)}function i(e){var t=e.behaviors[e.callCount-1];return t&&t.isPresent()?t:n(e)}var o=0,s={create:function(n){var r=function(){return i(r).invoke(this,arguments)};r.id="stub#"+o++;var s=r;return r=e.spy.create(r,n),r.func=s,e.extend(r,t),r.instantiateFake=e.stub.create,r.displayName="stub",r.toString=e.functionToString,r.defaultBehavior=null,r.behaviors=[],r},resetBehavior:function(){var e;if(this.defaultBehavior=null,this.behaviors=[],delete this.returnValue,delete this.returnArgAt,this.returnThis=!1,this.fakes)for(e=0;e<this.fakes.length;e++)this.fakes[e].resetBehavior()},onCall:function(t){return this.behaviors[t]||(this.behaviors[t]=e.behavior.create(this)),this.behaviors[t]},onFirstCall:function(){return this.onCall(0)},onSecondCall:function(){return this.onCall(1)},onThirdCall:function(){return this.onCall(2)}};for(var a in e.behavior)e.behavior.hasOwnProperty(a)&&!s.hasOwnProperty(a)&&"create"!=a&&"withArgs"!=a&&"invoke"!=a&&(s[a]=function(t){return function(){return this.defaultBehavior=this.defaultBehavior||e.behavior.create(this),this.defaultBehavior[t].apply(this.defaultBehavior,arguments),this}}(a));return e.extend(t,s),e.stub=t,t}function n(e,n,r){var i=e("./util/core");e("./behavior"),e("./spy"),e("./extend"),r.exports=t(i)}var r="undefined"!=typeof module&&module.exports&&"function"==typeof require,i="function"==typeof define&&"object"==typeof define.amd&&define.amd;if(i)define(n);else if(r)n(require,module.exports,module);else{if(!e)return;t(e)}}("object"==typeof sinon&&sinon||null),function(e){function t(e){function t(n){return n?t.create(n):e.expectation.create("Anonymous mock")}function n(e,t){if(e)for(var n=0,r=e.length;r>n;n+=1)t(e[n])}function r(e){return 0==e?"never called":"called "+c(e)}function i(e){var t=e.minCalls,n=e.maxCalls;if("number"==typeof t&&"number"==typeof n){var r=c(t);return t!=n&&(r="at least "+r+" and at most "+c(n)),r}return"number"==typeof t?"at least "+c(t):"at most "+c(n)}function o(e){var t="number"==typeof e.minCalls;return!t||e.callCount>=e.minCalls}function s(e){return"number"!=typeof e.maxCalls?!1:e.callCount==e.maxCalls}function a(e,t){return l&&l.isMatcher(e)?e.test(t):!0}var u=[].push,l=e.match;e.extend(t,{create:function(n){if(!n)throw new TypeError("object is null");var r=e.extend({},t);return r.object=n,delete r.create,r},expects:function(t){if(!t)throw new TypeError("method is falsy");if(this.expectations||(this.expectations={},this.proxies=[]),!this.expectations[t]){this.expectations[t]=[];var n=this;e.wrapMethod(this.object,t,function(){return n.invokeMethod(t,this,arguments)}),u.call(this.proxies,t)}var r=e.expectation.create(t);return u.call(this.expectations[t],r),r},restore:function(){var e=this.object;n(this.proxies,function(t){"function"==typeof e[t].restore&&e[t].restore()})},verify:function(){var t=this.expectations||{},r=[],i=[];return n(this.proxies,function(e){n(t[e],function(e){e.met()?u.call(i,e.toString()):u.call(r,e.toString())})}),this.restore(),r.length>0?e.expectation.fail(r.concat(i).join("\n")):i.length>0&&e.expectation.pass(r.concat(i).join("\n")),!0},invokeMethod:function(t,n,r){var i,o=this.expectations&&this.expectations[t],s=o&&o.length||0;for(i=0;s>i;i+=1)if(!o[i].met()&&o[i].allowsCall(n,r))return o[i].apply(n,r);var a,l=[],c=0;for(i=0;s>i;i+=1)o[i].allowsCall(n,r)?a=a||o[i]:c+=1,u.call(l," "+o[i].toString());return 0===c?a.apply(n,r):(l.unshift("Unexpected call: "+e.spyCall.toString.call({proxy:t,args:r})),void e.expectation.fail(l.join("\n")))}});var c=e.timesInWords,f=Array.prototype.slice;return e.expectation={minCalls:1,maxCalls:1,create:function(t){var n=e.extend(e.stub.create(),e.expectation);return delete n.create,n.method=t,n},invoke:function(t,n,r){return this.verifyCallAllowed(n,r),e.spy.invoke.apply(this,arguments)},atLeast:function(e){if("number"!=typeof e)throw new TypeError("'"+e+"' is not number");return this.limitsSet||(this.maxCalls=null,this.limitsSet=!0),this.minCalls=e,this},atMost:function(e){if("number"!=typeof e)throw new TypeError("'"+e+"' is not number");return this.limitsSet||(this.minCalls=null,this.limitsSet=!0),this.maxCalls=e,this},never:function(){return this.exactly(0)},once:function(){return this.exactly(1)},twice:function(){return this.exactly(2)},thrice:function(){return this.exactly(3)},exactly:function(e){if("number"!=typeof e)throw new TypeError("'"+e+"' is not a number");return this.atLeast(e),this.atMost(e)},met:function(){return!this.failed&&o(this)},verifyCallAllowed:function(t,n){if(s(this)&&(this.failed=!0,e.expectation.fail(this.method+" already called "+c(this.maxCalls))),"expectedThis"in this&&this.expectedThis!==t&&e.expectation.fail(this.method+" called with "+t+" as thisValue, expected "+this.expectedThis),"expectedArguments"in this){n||e.expectation.fail(this.method+" received no arguments, expected "+e.format(this.expectedArguments)),n.length<this.expectedArguments.length&&e.expectation.fail(this.method+" received too few arguments ("+e.format(n)+"), expected "+e.format(this.expectedArguments)),this.expectsExactArgCount&&n.length!=this.expectedArguments.length&&e.expectation.fail(this.method+" received too many arguments ("+e.format(n)+"), expected "+e.format(this.expectedArguments));for(var r=0,i=this.expectedArguments.length;i>r;r+=1)a(this.expectedArguments[r],n[r])||e.expectation.fail(this.method+" received wrong arguments "+e.format(n)+", didn't match "+this.expectedArguments.toString()),e.deepEqual(this.expectedArguments[r],n[r])||e.expectation.fail(this.method+" received wrong arguments "+e.format(n)+", expected "+e.format(this.expectedArguments))}},allowsCall:function(t,n){if(this.met()&&s(this))return!1;if("expectedThis"in this&&this.expectedThis!==t)return!1;if(!("expectedArguments"in this))return!0;if(n=n||[],n.length<this.expectedArguments.length)return!1;if(this.expectsExactArgCount&&n.length!=this.expectedArguments.length)return!1;for(var r=0,i=this.expectedArguments.length;i>r;r+=1){if(!a(this.expectedArguments[r],n[r]))return!1;if(!e.deepEqual(this.expectedArguments[r],n[r]))return!1}return!0},withArgs:function(){return this.expectedArguments=f.call(arguments),this},withExactArgs:function(){return this.withArgs.apply(this,arguments),this.expectsExactArgCount=!0,this},on:function(e){return this.expectedThis=e,this},toString:function(){var t=(this.expectedArguments||[]).slice();this.expectsExactArgCount||u.call(t,"[...]");var n=e.spyCall.toString.call({proxy:this.method||"anonymous mock expectation",args:t}),o=n.replace(", [...","[, ...")+" "+i(this);return this.met()?"Expectation met: "+o:"Expected "+o+" ("+r(this.callCount)+")"},verify:function(){return this.met()?e.expectation.pass(this.toString()):e.expectation.fail(this.toString()),!0},pass:function(t){e.assert.pass(t)},fail:function(e){var t=new Error(e);throw t.name="ExpectationError",t}},e.mock=t,t}function n(e,n,r){var i=e("./util/core");e("./times_in_words"),e("./call"),e("./extend"),e("./match"),e("./spy"),e("./stub"),e("./format"),r.exports=t(i)}var r="undefined"!=typeof module&&module.exports&&"function"==typeof require,i="function"==typeof define&&"object"==typeof define.amd&&define.amd;if(i)define(n);else if(r)n(require,module.exports,module);else{if(!e)return;t(e)}}("object"==typeof sinon&&sinon||null),function(e){function t(e){return e.fakes||(e.fakes=[]),e.fakes}function n(e,n){for(var r=t(e),i=0,o=r.length;o>i;i+=1)"function"==typeof r[i][n]&&r[i][n]()}function r(e){for(var n=t(e),r=0;r<n.length;)n.splice(r,1)}function i(e){var i={verify:function(){n(this,"verify")},restore:function(){n(this,"restore"),r(this)},reset:function(){n(this,"reset")},verifyAndRestore:function(){var e;try{this.verify()}catch(t){e=t}if(this.restore(),e)throw e},add:function(e){return s.call(t(this),e),e},spy:function(){return this.add(e.spy.apply(e,arguments))},stub:function(t,n,r){if(n){var i=t[n];if("function"!=typeof i){if(!a.call(t,n))throw new TypeError("Cannot stub non-existent own property "+n);return t[n]=r,this.add({restore:function(){t[n]=i}})}}if(!n&&t&&"object"==typeof t){var o=e.stub.apply(e,arguments);for(var s in o)"function"==typeof o[s]&&this.add(o[s]);return o}return this.add(e.stub.apply(e,arguments))},mock:function(){return this.add(e.mock.apply(e,arguments))},inject:function(e){var t=this;return e.spy=function(){return t.spy.apply(t,arguments)},e.stub=function(){return t.stub.apply(t,arguments)},e.mock=function(){return t.mock.apply(t,arguments)},e}};return e.collection=i,i}function o(e,t,n){var r=e("./util/core");e("./mock"),e("./spy"),e("./stub"),n.exports=i(r)}var s=[].push,a=Object.prototype.hasOwnProperty,u="undefined"!=typeof module&&module.exports&&"function"==typeof require,l="function"==typeof define&&"object"==typeof define.amd&&define.amd;if(l)define(o);else if(u)o(require,module.exports,module);else{if(!e)return;i(e)}}("object"==typeof sinon&&sinon||null),"undefined"==typeof sinon)var sinon={};if(function(){function e(e,t){var n="undefined"!=typeof lolex?lolex:t;e.useFakeTimers=function(){var e,t=Array.prototype.slice.call(arguments);e="string"==typeof t[0]?0:t.shift();var r=n.install(e||0,t);return r.restore=r.uninstall,r},e.clock={create:function(e){return n.createClock(e)}},e.timers={setTimeout:setTimeout,clearTimeout:clearTimeout,setImmediate:"undefined"!=typeof setImmediate?setImmediate:void 0,clearImmediate:"undefined"!=typeof clearImmediate?clearImmediate:void 0,setInterval:setInterval,clearInterval:clearInterval,Date:Date}}function t(t,n,r,i){var o=t("./core");e(o,i),r.exports=o}var n="undefined"!=typeof module&&module.exports&&"function"==typeof require,r="function"==typeof define&&"object"==typeof define.amd&&define.amd;r?define(t):n?t(require,module.exports,module,require("lolex")):e(sinon)}("undefined"!=typeof global&&"function"!=typeof global?global:this),"undefined"==typeof sinon&&(this.sinon={}),function(){function e(e){e.Event=function(e,t,n,r){this.initEvent(e,t,n,r)},e.Event.prototype={initEvent:function(e,t,n,r){this.type=e,this.bubbles=t,this.cancelable=n,this.target=r},stopPropagation:function(){},preventDefault:function(){this.defaultPrevented=!0}},e.ProgressEvent=function(e,t,n){this.initEvent(e,!1,!1,n),this.loaded=t.loaded||null,this.total=t.total||null,this.lengthComputable=!!t.total},e.ProgressEvent.prototype=new e.Event,e.ProgressEvent.prototype.constructor=e.ProgressEvent,e.CustomEvent=function(e,t,n){this.initEvent(e,!1,!1,n),this.detail=t.detail||null},e.CustomEvent.prototype=new e.Event,e.CustomEvent.prototype.constructor=e.CustomEvent,e.EventTarget={addEventListener:function(e,t){this.eventListeners=this.eventListeners||{},this.eventListeners[e]=this.eventListeners[e]||[],n.call(this.eventListeners[e],t)},removeEventListener:function(e,t){for(var n=this.eventListeners&&this.eventListeners[e]||[],r=0,i=n.length;i>r;++r)if(n[r]==t)return n.splice(r,1)},dispatchEvent:function(e){for(var t=e.type,n=this.eventListeners&&this.eventListeners[t]||[],r=0;r<n.length;r++)"function"==typeof n[r]?n[r].call(this,e):n[r].handleEvent(e);return!!e.defaultPrevented}}}function t(t){var n=t("./core");e(n)}var n=[].push,r="undefined"!=typeof module&&module.exports&&"function"==typeof require,i="function"==typeof define&&"object"==typeof define.amd&&define.amd;i?define(t):r?t(require):e(sinon)}(),function(e){function t(e){function t(){}function n(t,r){var i=t+" threw exception: ";e.log(i+"["+r.name+"] "+r.message),r.stack&&e.log(r.stack),n.setTimeout(function(){throw r.message=i+r.message,r},0)}n.setTimeout=function(e,t){r(e,t)};var i={};return i.log=e.log=t,i.logError=e.logError=n,i}function n(e,n,r){var i=e("./util/core");r.exports=t(i)}var r=setTimeout,i="undefined"!=typeof module&&module.exports&&"function"==typeof require,o="function"==typeof define&&"object"==typeof define.amd&&define.amd;if(o)define(n);else if(i)n(require,module.exports,module);else{if(!e)return;t(e)}}("object"==typeof sinon&&sinon||null),"undefined"==typeof sinon&&(this.sinon={}),function(e){function t(t){function n(){this.readyState=n.UNSENT,this.requestBody=null,this.requestHeaders={},this.status=0,this.timeout=null,"function"==typeof n.onCreate&&n.onCreate(this)}function i(e){if(e.readyState!==n.OPENED)throw new Error("INVALID_STATE_ERR");if(e.sendFlag)throw new Error("INVALID_STATE_ERR")}function o(e){if(e.readyState==n.UNSENT)throw new Error("Request not sent");if(e.readyState==n.DONE)throw new Error("Request done")}function s(e){if("string"!=typeof e){var t=new Error("Attempted to respond to fake XDomainRequest with "+e+", which is not a string.");throw t.name="InvalidBodyException",t}}t.xdr=r,t.extend(n.prototype,t.EventTarget,{open:function(e,t){this.method=e,this.url=t,this.responseText=null,this.sendFlag=!1,this.readyStateChange(n.OPENED)},readyStateChange:function(e){this.readyState=e;var r="";switch(this.readyState){case n.UNSENT:break;case n.OPENED:break;case n.LOADING:this.sendFlag&&(r="onprogress");break;case n.DONE:r=this.isTimeout?"ontimeout":this.errorFlag||this.status<200||this.status>299?"onerror":"onload"}if(r&&"function"==typeof this[r])try{this[r]()}catch(i){t.logError("Fake XHR "+r+" handler",i)}},send:function(e){i(this),/^(get|head)$/i.test(this.method)||(this.requestBody=e),this.requestHeaders["Content-Type"]="text/plain;charset=utf-8",this.errorFlag=!1,this.sendFlag=!0,this.readyStateChange(n.OPENED),"function"==typeof this.onSend&&this.onSend(this)},abort:function(){this.aborted=!0,this.responseText=null,this.errorFlag=!0,this.readyState>t.FakeXDomainRequest.UNSENT&&this.sendFlag&&(this.readyStateChange(t.FakeXDomainRequest.DONE),this.sendFlag=!1)},setResponseBody:function(e){o(this),s(e);var t=this.chunkSize||10,r=0;this.responseText="";do this.readyStateChange(n.LOADING),this.responseText+=e.substring(r,r+t),r+=t;while(r<e.length);this.readyStateChange(n.DONE)},respond:function(e,t,n){this.status="number"==typeof e?e:200,this.setResponseBody(n||"")},simulatetimeout:function(){this.status=0,this.isTimeout=!0,this.responseText=void 0,this.readyStateChange(n.DONE)}}),t.extend(n,{UNSENT:0,OPENED:1,LOADING:3,DONE:4}),t.useFakeXDomainRequest=function(){return t.FakeXDomainRequest.restore=function(n){r.supportsXDR&&(e.XDomainRequest=r.GlobalXDomainRequest),delete t.FakeXDomainRequest.restore,n!==!0&&delete t.FakeXDomainRequest.onCreate},r.supportsXDR&&(e.XDomainRequest=t.FakeXDomainRequest),t.FakeXDomainRequest},t.FakeXDomainRequest=n}function n(e,n,r){var i=e("./core");e("../extend"),e("./event"),e("../log_error"),t(i),r.exports=i}var r={XDomainRequest:e.XDomainRequest};r.GlobalXDomainRequest=e.XDomainRequest,r.supportsXDR="undefined"!=typeof r.GlobalXDomainRequest,r.workingXDR=r.supportsXDR?r.GlobalXDomainRequest:!1;var i="undefined"!=typeof module&&module.exports&&"function"==typeof require,o="function"==typeof define&&"object"==typeof define.amd&&define.amd;o?define(n):i?n(require,module.exports,module):t(sinon)}("undefined"!=typeof global?global:self),function(e){function t(){function e(e){r.addEventListener(e,function(t){var n=r["on"+e];n&&"function"==typeof n&&n.call(this,t)})}this.readyState=t.UNSENT,this.requestHeaders={},this.requestBody=null,this.status=0,this.statusText="",this.upload=new n,this.responseType="",this.response="",m.supportsCORS&&(this.withCredentials=!1);for(var r=this,i=["loadstart","load","abort","loadend"],o=i.length-1;o>=0;o--)e(i[o]);"function"==typeof t.onCreate&&t.onCreate(this)}function n(){this.eventListeners={progress:[],load:[],abort:[],error:[]}}function r(e){if(e.readyState!==t.OPENED)throw new Error("INVALID_STATE_ERR");if(e.sendFlag)throw new Error("INVALID_STATE_ERR")}function i(e,t){t=t.toLowerCase();for(var n in e)if(n.toLowerCase()==t)return n;return null}function o(e,t){if(e)for(var n=0,r=e.length;r>n;n+=1)t(e[n])}function s(e,t){for(var n=0;n<e.length;n++)if(t(e[n])===!0)return!0;return!1}function a(e){if(e.readyState!=t.OPENED)throw new Error("INVALID_STATE_ERR - "+e.readyState)}function u(e){if(e.readyState==t.DONE)throw new Error("Request done")}function l(e){if(e.async&&e.readyState!=t.HEADERS_RECEIVED)throw new Error("No headers received")}function c(e){if("string"!=typeof e){var t=new Error("Attempted to respond to fake XMLHttpRequest with "+e+", which is not a string.");throw t.name="InvalidBodyException",t}}function f(n){n.xhr=m,n.extend(t.prototype,n.EventTarget,{async:!0,open:function(e,n,r,i,o){if(this.method=e,this.url=n,this.async="boolean"==typeof r?r:!0,this.username=i,this.password=o,this.responseText=null,this.response="json"===this.responseType?null:"",this.responseXML=null,this.requestHeaders={},this.sendFlag=!1,t.useFilters===!0){var a=arguments,u=s(t.filters,function(e){return e.apply(this,a)});if(u)return t.defake(this,arguments)}this.readyStateChange(t.OPENED)},readyStateChange:function(e){if(this.readyState=e,"function"==typeof this.onreadystatechange)try{this.onreadystatechange()}catch(r){n.logError("Fake XHR onreadystatechange handler",r)}switch(this.readyState){case t.DONE:p&&(this.upload.dispatchEvent(new n.ProgressEvent("progress",{loaded:100,total:100})),this.dispatchEvent(new n.ProgressEvent("progress",{loaded:100,total:100}))),this.upload.dispatchEvent(new n.Event("load",!1,!1,this)),this.dispatchEvent(new n.Event("load",!1,!1,this)),this.dispatchEvent(new n.Event("loadend",!1,!1,this))}this.dispatchEvent(new n.Event("readystatechange"))},setRequestHeader:function(e,t){if(r(this),g[e]||/^(Sec-|Proxy-)/.test(e))throw new Error('Refused to set unsafe header "'+e+'"');this.requestHeaders[e]?this.requestHeaders[e]+=","+t:this.requestHeaders[e]=t},setResponseHeaders:function(e){a(this),this.responseHeaders={};for(var n in e)e.hasOwnProperty(n)&&(this.responseHeaders[n]=e[n]);this.async?this.readyStateChange(t.HEADERS_RECEIVED):this.readyState=t.HEADERS_RECEIVED},send:function(e){if(r(this),!/^(get|head)$/i.test(this.method)){var o=i(this.requestHeaders,"Content-Type");if(this.requestHeaders[o]){var s=this.requestHeaders[o].split(";");this.requestHeaders[o]=s[0]+";charset=utf-8"}else!y||e instanceof FormData||(this.requestHeaders["Content-Type"]="text/plain;charset=utf-8");this.requestBody=e}this.errorFlag=!1,this.sendFlag=this.async,this.response="json"===this.responseType?null:"",this.readyStateChange(t.OPENED),"function"==typeof this.onSend&&this.onSend(this),this.dispatchEvent(new n.Event("loadstart",!1,!1,this))},abort:function(){this.aborted=!0,this.responseText=null,this.response="json"===this.responseType?null:"",this.errorFlag=!0,this.requestHeaders={},this.responseHeaders={},this.readyState>t.UNSENT&&this.sendFlag&&(this.readyStateChange(t.DONE),this.sendFlag=!1),this.readyState=t.UNSENT,this.dispatchEvent(new n.Event("abort",!1,!1,this)),this.upload.dispatchEvent(new n.Event("abort",!1,!1,this)),"function"==typeof this.onerror&&this.onerror()},getResponseHeader:function(e){return this.readyState<t.HEADERS_RECEIVED?null:/^Set-Cookie2?$/i.test(e)?null:(e=i(this.responseHeaders,e),this.responseHeaders[e]||null)},getAllResponseHeaders:function(){if(this.readyState<t.HEADERS_RECEIVED)return"";var e="";for(var n in this.responseHeaders)this.responseHeaders.hasOwnProperty(n)&&!/^Set-Cookie2?$/i.test(n)&&(e+=n+": "+this.responseHeaders[n]+"\r\n");return e},setResponseBody:function(e){u(this),l(this),c(e);var n=this.chunkSize||10,r=0;this.responseText="";do this.async&&this.readyStateChange(t.LOADING),this.responseText+=e.substring(r,r+n),r+=n;while(r<e.length);var i=this.getResponseHeader("Content-Type");if(this.responseText&&(!i||/(text\/xml)|(application\/xml)|(\+xml)/.test(i)))try{this.responseXML=t.parseXML(this.responseText)}catch(o){}this.response="json"===this.responseType?JSON.parse(this.responseText):this.responseText,this.readyStateChange(t.DONE)},respond:function(e,n,r){this.status="number"==typeof e?e:200,this.statusText=t.statusCodes[this.status],this.setResponseHeaders(n||{}),this.setResponseBody(r||"")},uploadProgress:function(e){p&&this.upload.dispatchEvent(new n.ProgressEvent("progress",e))},downloadProgress:function(e){p&&this.dispatchEvent(new n.ProgressEvent("progress",e))},uploadError:function(e){h&&this.upload.dispatchEvent(new n.CustomEvent("error",{detail:e}))}}),n.extend(t,{UNSENT:0,OPENED:1,HEADERS_RECEIVED:2,LOADING:3,DONE:4}),n.useFakeXMLHttpRequest=function(){return t.restore=function(n){m.supportsXHR&&(e.XMLHttpRequest=m.GlobalXMLHttpRequest),m.supportsActiveX&&(e.ActiveXObject=m.GlobalActiveXObject),delete t.restore,n!==!0&&delete t.onCreate},m.supportsXHR&&(e.XMLHttpRequest=t),m.supportsActiveX&&(e.ActiveXObject=function(e){return"Microsoft.XMLHTTP"==e||/^Msxml2\.XMLHTTP/i.test(e)?new t:new m.GlobalActiveXObject(e)}),t},n.FakeXMLHttpRequest=t}function d(e,t,n){var r=e("./core");e("../extend"),e("./event"),e("../log_error"),f(r),n.exports=r}var p="undefined"!=typeof ProgressEvent,h="undefined"!=typeof CustomEvent,y="undefined"!=typeof FormData,m={XMLHttpRequest:e.XMLHttpRequest};m.GlobalXMLHttpRequest=e.XMLHttpRequest,m.GlobalActiveXObject=e.ActiveXObject,m.supportsActiveX="undefined"!=typeof m.GlobalActiveXObject,m.supportsXHR="undefined"!=typeof m.GlobalXMLHttpRequest,m.workingXHR=m.supportsXHR?m.GlobalXMLHttpRequest:m.supportsActiveX?function(){return new m.GlobalActiveXObject("MSXML2.XMLHTTP.3.0")}:!1,m.supportsCORS=m.supportsXHR&&"withCredentials"in new m.GlobalXMLHttpRequest;var g={"Accept-Charset":!0,"Accept-Encoding":!0,Connection:!0,"Content-Length":!0,Cookie:!0,Cookie2:!0,"Content-Transfer-Encoding":!0,Date:!0,Expect:!0,Host:!0,"Keep-Alive":!0,Referer:!0,TE:!0,Trailer:!0,"Transfer-Encoding":!0,Upgrade:!0,"User-Agent":!0,Via:!0};n.prototype.addEventListener=function(e,t){this.eventListeners[e].push(t)},n.prototype.removeEventListener=function(e,t){for(var n=this.eventListeners[e]||[],r=0,i=n.length;i>r;++r)if(n[r]==t)return n.splice(r,1)},n.prototype.dispatchEvent=function(e){for(var t,n=this.eventListeners[e.type]||[],r=0;null!=(t=n[r]);r++)t(e)};var v=function(e,t,n){switch(n.length){case 0:return e[t]();case 1:return e[t](n[0]);case 2:return e[t](n[0],n[1]);case 3:return e[t](n[0],n[1],n[2]);case 4:return e[t](n[0],n[1],n[2],n[3]);case 5:return e[t](n[0],n[1],n[2],n[3],n[4])}};t.filters=[],t.addFilter=function(e){this.filters.push(e)};var b=/MSIE 6/;t.defake=function(e,n){var r=new m.workingXHR;o(["open","setRequestHeader","send","abort","getResponseHeader","getAllResponseHeaders","addEventListener","overrideMimeType","removeEventListener"],function(t){e[t]=function(){return v(r,t,arguments)}});var i=function(t){o(t,function(t){try{e[t]=r[t]}catch(n){if(!b.test(navigator.userAgent))throw n}})},s=function(){e.readyState=r.readyState,r.readyState>=t.HEADERS_RECEIVED&&i(["status","statusText"]),r.readyState>=t.LOADING&&i(["responseText","response"]),r.readyState===t.DONE&&i(["responseXML"]),e.onreadystatechange&&e.onreadystatechange.call(e,{target:e})};if(r.addEventListener){for(var a in e.eventListeners)e.eventListeners.hasOwnProperty(a)&&o(e.eventListeners[a],function(e){r.addEventListener(a,e)});r.addEventListener("readystatechange",s)}else r.onreadystatechange=s;v(r,"open",n)},t.useFilters=!1,t.parseXML=function(e){var t;if("undefined"!=typeof DOMParser){var n=new DOMParser;t=n.parseFromString(e,"text/xml")}else t=new ActiveXObject("Microsoft.XMLDOM"),t.async="false",t.loadXML(e);return t},t.statusCodes={100:"Continue",101:"Switching Protocols",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",300:"Multiple Choice",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Request Entity Too Large",414:"Request-URI Too Long",415:"Unsupported Media Type",416:"Requested Range Not Satisfiable",417:"Expectation Failed",422:"Unprocessable Entity",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported"};var w="undefined"!=typeof module&&module.exports&&"function"==typeof require,x="function"==typeof define&&"object"==typeof define.amd&&define.amd;if(x)define(d);else if(w)d(require,module.exports,module);else{if("undefined"==typeof sinon)return;f(sinon)}}("undefined"!=typeof global?global:self),"undefined"==typeof sinon)var sinon={};return function(){function e(){}function t(t){return e.prototype=t,new e}function n(e){var t=e;if("[object Array]"!=Object.prototype.toString.call(e)&&(t=[200,{},e]),"string"!=typeof t[2])throw new TypeError("Fake server response body should be string, but was "+typeof t[2]);
return t}function r(e,t,n){var r=e.method,i=!r||r.toLowerCase()==t.toLowerCase(),o=e.url,s=!o||o==n||"function"==typeof o.test&&o.test(n);return i&&s}function i(e,t){var n=t.url;if((!/^https?:\/\//.test(n)||l.test(n))&&(n=n.replace(l,"")),r(e,this.getHTTPMethod(t),n)){if("function"==typeof e.response){var i=e.url,o=[t].concat(i&&"function"==typeof i.exec?i.exec(n).slice(1):[]);return e.response.apply(e,o)}return!0}return!1}function o(e){e.fakeServer={create:function(){var n=t(this);return this.xhr=e.xhr.supportsCORS?e.useFakeXMLHttpRequest():e.useFakeXDomainRequest(),n.requests=[],this.xhr.onCreate=function(e){n.addRequest(e)},n},addRequest:function(e){var t=this;a.call(this.requests,e),e.onSend=function(){t.handleRequest(this),t.respondImmediately?t.respond():t.autoRespond&&!t.responding&&(setTimeout(function(){t.responding=!1,t.respond()},t.autoRespondAfter||10),t.responding=!0)}},getHTTPMethod:function(e){if(this.fakeHTTPMethods&&/post/i.test(e.method)){var t=(e.requestBody||"").match(/_method=([^\b;]+)/);return t?t[1]:e.method}return e.method},handleRequest:function(e){e.async?(this.queue||(this.queue=[]),a.call(this.queue,e)):this.processRequest(e)},log:function(t,n){var r;r="Request:\n"+e.format(n)+"\n\n",r+="Response:\n"+e.format(t)+"\n\n",e.log(r)},respondWith:function(e,t,r){return 1==arguments.length&&"function"!=typeof e?void(this.response=n(e)):(this.responses||(this.responses=[]),1==arguments.length&&(r=e,t=e=null),2==arguments.length&&(r=t,t=e,e=null),void a.call(this.responses,{method:e,url:t,response:"function"==typeof r?r:n(r)}))},respond:function(){arguments.length>0&&this.respondWith.apply(this,arguments);for(var e,t=this.queue||[],n=t.splice(0,t.length);e=n.shift();)this.processRequest(e)},processRequest:function(t){try{if(t.aborted)return;var n=this.response||[404,{},""];if(this.responses)for(var r=this.responses.length,o=r-1;o>=0;o--)if(i.call(this,this.responses[o],t)){n=this.responses[o].response;break}4!=t.readyState&&(this.log(n,t),t.respond(n[0],n[1],n[2]))}catch(s){e.logError("Fake server request processing",s)}},restore:function(){return this.xhr.restore&&this.xhr.restore.apply(this.xhr,arguments)}}}function s(e,t,n){var r=e("./core");e("./fake_xdomain_request"),e("./fake_xml_http_request"),e("../format"),o(r),n.exports=r}var a=[].push,u="undefined"!=typeof window?window.location:{},l=new RegExp("^"+u.protocol+"//"+u.host),c="undefined"!=typeof module&&module.exports&&"function"==typeof require,f="function"==typeof define&&"object"==typeof define.amd&&define.amd;f?define(s):c?s(require,module.exports,module):o(sinon)}(),function(){function e(e){function t(){}t.prototype=e.fakeServer,e.fakeServerWithClock=new t,e.fakeServerWithClock.addRequest=function(t){if(t.async&&("object"==typeof setTimeout.clock?this.clock=setTimeout.clock:(this.clock=e.useFakeTimers(),this.resetClock=!0),!this.longestTimeout)){var n=this.clock.setTimeout,r=this.clock.setInterval,i=this;this.clock.setTimeout=function(e,t){return i.longestTimeout=Math.max(t,i.longestTimeout||0),n.apply(this,arguments)},this.clock.setInterval=function(e,t){return i.longestTimeout=Math.max(t,i.longestTimeout||0),r.apply(this,arguments)}}return e.fakeServer.addRequest.call(this,t)},e.fakeServerWithClock.respond=function(){var t=e.fakeServer.respond.apply(this,arguments);return this.clock&&(this.clock.tick(this.longestTimeout||0),this.longestTimeout=0,this.resetClock&&(this.clock.restore(),this.resetClock=!1)),t},e.fakeServerWithClock.restore=function(){return this.clock&&this.clock.restore(),e.fakeServer.restore.apply(this,arguments)}}function t(t){var n=t("./core");t("./fake_server"),t("./fake_timers"),e(n)}var n="undefined"!=typeof module&&module.exports&&"function"==typeof require,r="function"==typeof define&&"object"==typeof define.amd&&define.amd;r?define(t):n?t(require):e(sinon)}(),function(){function e(e){function t(e,t,n,i){i&&(!t.injectInto||n in t.injectInto?r.call(e.args,i):(t.injectInto[n]=i,e.injectedKeys.push(n)))}function n(t){var n=e.create(e.sandbox);return t.useFakeServer&&("object"==typeof t.useFakeServer&&(n.serverPrototype=t.useFakeServer),n.useFakeServer()),t.useFakeTimers&&("object"==typeof t.useFakeTimers?n.useFakeTimers.apply(n,t.useFakeTimers):n.useFakeTimers()),n}var r=[].push;return e.sandbox=e.extend(e.create(e.collection),{useFakeTimers:function(){return this.clock=e.useFakeTimers.apply(e,arguments),this.add(this.clock)},serverPrototype:e.fakeServer,useFakeServer:function(){var t=this.serverPrototype||e.fakeServer;return t&&t.create?(this.server=t.create(),this.add(this.server)):null},inject:function(t){return e.collection.inject.call(this,t),this.clock&&(t.clock=this.clock),this.server&&(t.server=this.server,t.requests=this.server.requests),t.match=e.match,t},restore:function(){e.collection.restore.apply(this,arguments),this.restoreContext()},restoreContext:function(){if(this.injectedKeys){for(var e=0,t=this.injectedKeys.length;t>e;e++)delete this.injectInto[this.injectedKeys[e]];this.injectedKeys=[]}},create:function(r){if(!r)return e.create(e.sandbox);var i=n(r);i.args=i.args||[],i.injectedKeys=[],i.injectInto=r.injectInto;var o,s,a=i.inject({});if(r.properties)for(var u=0,l=r.properties.length;l>u;u++)o=r.properties[u],s=a[o]||"sandbox"==o&&i,t(i,r,o,s);else t(i,r,"sandbox",s);return i},match:e.match}),e.sandbox.useFakeXMLHttpRequest=e.sandbox.useFakeServer,e.sandbox}function t(t,n,r){var i=t("./util/core");t("./extend"),t("./util/fake_server_with_clock"),t("./util/fake_timers"),t("./collection"),r.exports=e(i)}var n="undefined"!=typeof module&&module.exports&&"function"==typeof require,r="function"==typeof define&&"object"==typeof define.amd&&define.amd;if(r)define(t);else if(n)t(require,module.exports,module);else{if(!sinon)return;e(sinon)}}(),function(e){function t(e){function t(t){function r(){var r=e.getConfig(e.config);r.injectInto=r.injectIntoThis&&this||r.injectInto;var i,o,s=e.sandbox.create(r),a=n.call(arguments),u=a.length&&a[a.length-1];"function"==typeof u&&(a[a.length-1]=function(e){if(e)throw s.restore(),i;s.verifyAndRestore(),u(e)});try{o=t.apply(this,a.concat(s.args))}catch(l){i=l}if("function"!=typeof u){if("undefined"!=typeof i)throw s.restore(),i;s.verifyAndRestore()}return o}var i=typeof t;if("function"!=i)throw new TypeError("sinon.test needs to wrap a test function, got "+i);return t.length?function(){return r.apply(this,arguments)}:r}var n=Array.prototype.slice;return t.config={injectIntoThis:!0,injectInto:null,properties:["spy","stub","mock","clock","server","requests"],useFakeTimers:!0,useFakeServer:!0},e.test=t,t}function n(e,n,r){var i=e("./util/core");e("./sandbox"),r.exports=t(i)}var r="undefined"!=typeof module&&module.exports&&"function"==typeof require,i="function"==typeof define&&"object"==typeof define.amd&&define.amd;i?define(n):r?n(require,module.exports,module):e&&t(e)}("object"==typeof sinon&&sinon||null),function(e){function t(e,t,n){return function(){t&&t.apply(this,arguments);var r,i;try{i=e.apply(this,arguments)}catch(o){r=o}if(n&&n.apply(this,arguments),r)throw r;return i}}function n(e){function n(n,r){if(!n||"object"!=typeof n)throw new TypeError("sinon.testCase needs an object with test functions");r=r||"test";var i,o,s,a=new RegExp("^"+r),u={},l=n.setUp,c=n.tearDown;for(i in n)n.hasOwnProperty(i)&&!/^(setUp|tearDown)$/.test(i)&&(o=n[i],"function"==typeof o&&a.test(i)?(s=o,(l||c)&&(s=t(o,l,c)),u[i]=e.test(s)):u[i]=n[i]);return u}return e.testCase=n,n}function r(e,t,r){var i=e("./util/core");e("./test"),r.exports=n(i)}var i="undefined"!=typeof module&&module.exports&&"function"==typeof require,o="function"==typeof define&&"object"==typeof define.amd&&define.amd;if(o)define(r);else if(i)r(require,module.exports,module);else{if(!e)return;n(e)}}("object"==typeof sinon&&sinon||null),function(e,t){function n(e){function n(){for(var e,t=0,r=arguments.length;r>t;++t)e=arguments[t],e||a.fail("fake is not a spy"),e.proxy&&e.proxy.isSinonProxy?n(e.proxy):("function"!=typeof e&&a.fail(e+" is not a function"),"function"!=typeof e.getCall&&a.fail(e+" is not stubbed"))}function r(e,n){e=e||t;var r=e.fail||a.fail;r.call(e,n)}function o(e,t,o){2==arguments.length&&(o=t,t=e),a[e]=function(s){n(s);var u=i.call(arguments,1),l=!1;l="function"==typeof t?!t(s):"function"==typeof s[t]?!s[t].apply(s,u):!s[t],l?r(this,(s.printf||s.proxy.printf).apply(s,[o].concat(u))):a.pass(e)}}function s(e,t){return!e||/^fail/.test(t)?t:e+t.slice(0,1).toUpperCase()+t.slice(1)}var a;return a={failException:"AssertError",fail:function(e){var t=new Error(e);throw t.name=this.failException||a.failException,t},pass:function(){},callOrder:function(){n.apply(null,arguments);var t="",o="";if(e.calledInOrder(arguments))a.pass("callOrder");else{try{t=[].join.call(arguments,", ");for(var s=i.call(arguments),u=s.length;u;)s[--u].called||s.splice(u,1);o=e.orderByFirstCall(s).join(", ")}catch(l){}r(this,"expected "+t+" to be called in order but were called as "+o)}},callCount:function(t,i){if(n(t),t.callCount!=i){var o="expected %n to be called "+e.timesInWords(i)+" but was called %c%C";r(this,t.printf(o))}else a.pass("callCount")},expose:function(e,t){if(!e)throw new TypeError("target is null or undefined");var n=t||{},r="undefined"==typeof n.prefix&&"assert"||n.prefix,i="undefined"==typeof n.includeFail||!!n.includeFail;for(var o in this)"expose"==o||!i&&/^(fail)/.test(o)||(e[s(r,o)]=this[o]);return e},match:function(t,n){var i=e.match(n);if(i.test(t))a.pass("match");else{var o=["expected value to match"," expected = "+e.format(n)," actual = "+e.format(t)];r(this,o.join("\n"))}}},o("called","expected %n to have been called at least once but was never called"),o("notCalled",function(e){return!e.called},"expected %n to not have been called but was called %c%C"),o("calledOnce","expected %n to be called once but was called %c%C"),o("calledTwice","expected %n to be called twice but was called %c%C"),o("calledThrice","expected %n to be called thrice but was called %c%C"),o("calledOn","expected %n to be called with %1 as this but was called with %t"),o("alwaysCalledOn","expected %n to always be called with %1 as this but was called with %t"),o("calledWithNew","expected %n to be called with new"),o("alwaysCalledWithNew","expected %n to always be called with new"),o("calledWith","expected %n to be called with arguments %*%C"),o("calledWithMatch","expected %n to be called with match %*%C"),o("alwaysCalledWith","expected %n to always be called with arguments %*%C"),o("alwaysCalledWithMatch","expected %n to always be called with match %*%C"),o("calledWithExactly","expected %n to be called with exact arguments %*%C"),o("alwaysCalledWithExactly","expected %n to always be called with exact arguments %*%C"),o("neverCalledWith","expected %n to never be called with arguments %*%C"),o("neverCalledWithMatch","expected %n to never be called with match %*%C"),o("threw","%n did not throw exception%C"),o("alwaysThrew","%n did not always throw exception%C"),e.assert=a,a}function r(e,t,r){var i=e("./util/core");e("./match"),e("./format"),r.exports=n(i)}var i=Array.prototype.slice,o="undefined"!=typeof module&&module.exports&&"function"==typeof require,s="function"==typeof define&&"object"==typeof define.amd&&define.amd;if(s)define(r);else if(o)r(require,module.exports,module);else{if(!e)return;n(e)}}("object"==typeof sinon&&sinon||null,"undefined"!=typeof window?window:"undefined"!=typeof self?self:global),sinon});