text: var sinon=function(){"use strict";var buster=function(a,b){var c="function"==typeof require&&"object"==typeof module,d="undefined"!=typeof document&&document.createElement("div"),e=function(){},f={bind:function(a,b){var c="string"==typeof b?a[b]:b,d=Array.prototype.slice.call(arguments,2);return function(){var b=d.concat(Array.prototype.slice.call(arguments));return c.apply(a,b)}},partial:function(a){var b=[].slice.call(arguments,1);return function(){return a.apply(this,b.concat([].slice.call(arguments)))}},create:function(a){return e.prototype=a,new e},extend:function(a){if(a){for(var b,c=1,d=arguments.length;d>c;++c)for(b in arguments[c])a[b]=arguments[c][b];return a}},nextTick:function(b){return"undefined"!=typeof process&&process.nextTick?process.nextTick(b):(a(b,0),void 0)},functionName:function(a){if(!a)return"";if(a.displayName)return a.displayName;if(a.name)return a.name;var b=a.toString().match(/function\s+([^\(]+)/m);return b&&b[1]||""},isNode:function(a){if(!d)return!1;try{a.appendChild(d),a.removeChild(d)}catch(b){return!1}return!0},isElement:function(a){return a&&1===a.nodeType&&f.isNode(a)},isArray:function(a){return"[object Array]"==Object.prototype.toString.call(a)},flatten:function i(a){for(var b=[],a=a||[],c=0,d=a.length;d>c;++c)b=b.concat(f.isArray(a[c])?i(a[c]):a[c]);return b},each:function(a,b){for(var c=0,d=a.length;d>c;++c)b(a[c])},map:function(a,b){for(var c=[],d=0,e=a.length;e>d;++d)c.push(b(a[d]));return c},parallel:function(a,b){function c(a,c){"function"==typeof b&&(b(a,c),b=null)}function d(a){return function(b,d){return b?c(b):(f[a]=d,0==--e&&c(null,f),void 0)}}if(0==a.length)return c(null,[]);for(var e=a.length,f=[],g=0,h=a.length;h>g;++g)a[g](d(g))},series:function(a,b){function c(a,c){"function"==typeof b&&b(a,c)}function d(){if(0==g.length)return c(null,h);var a=g.shift()(e);a&&"function"==typeof a.then&&a.then(f.partial(e,null),e)}function e(a,b){return a?c(a):(h.push(b),d(),void 0)}var g=a.slice(),h=[];d()},countdown:function(a,b){return function(){0==--a&&b()}}};if("object"==typeof process&&"function"==typeof require&&"object"==typeof module){var g=require("crypto"),h=require("path");f.tmpFile=function(a){var b=g.createHash("sha1");b.update(a);var c=b.digest("hex");return"win32"==process.platform?h.join(process.env.TEMP,c):h.join("/tmp",c)}}return f.some=Array.prototype.some?function(a,b,c){return a.some(b,c)}:function(a,b,c){if(null==a)throw new TypeError;a=Object(a);var d=a.length>>>0;if("function"!=typeof b)throw new TypeError;for(var e=0;d>e;e++)if(a.hasOwnProperty(e)&&b.call(c,a[e],e,a))return!0;return!1},f.filter=Array.prototype.filter?function(a,b,c){return a.filter(b,c)}:function(a,b){if(null==this)throw new TypeError;var c=Object(this),d=c.length>>>0;if("function"!=typeof a)throw new TypeError;for(var e=[],f=0;d>f;f++)if(f in c){var g=c[f];a.call(b,g,f,c)&&e.push(g)}return e},c&&(module.exports=f,f.eventEmitter=require("./buster-event-emitter"),Object.defineProperty(f,"defineVersionGetter",{get:function(){return require("./define-version-getter")}})),f.extend(b||{},f)}(setTimeout,buster);if("undefined"==typeof buster)var buster={};"object"==typeof module&&"function"==typeof require&&(buster=require("buster-core")),buster.format=buster.format||{},buster.format.excludeConstructors=["Object",/^.$/],buster.format.quoteStrings=!0,buster.format.ascii=function(){function a(a){var b=Object.keys&&Object.keys(a)||[];if(0==b.length)for(var c in a)d.call(a,c)&&b.push(c);return b.sort()}function b(a,b){if("object"!=typeof a)return!1;for(var c=0,d=b.length;d>c;++c)if(b[c]===a)return!0;return!1}function c(a,d,f){if("string"==typeof a){var g="boolean"!=typeof this.quoteStrings||this.quoteStrings;return d||g?'"'+a+'"':a}if("function"==typeof a&&!(a instanceof RegExp))return c.func(a);if(d=d||[],b(a,d))return"[Circular]";if("[object Array]"==Object.prototype.toString.call(a))return c.array.call(this,a,d);if(!a)return""+a;if(buster.isElement(a))return c.element(a);if("function"==typeof a.toString&&a.toString!==Object.prototype.toString)return a.toString();for(var h=0,i=e.length;i>h;h++)if(a===e[h].obj)return e[h].value;return c.object.call(this,a,d,f)}var d=Object.prototype.hasOwnProperty,e=[];return"undefined"!=typeof global&&e.push({obj:global,value:"[object global]"}),"undefined"!=typeof document&&e.push({obj:document,value:"[object HTMLDocument]"}),"undefined"!=typeof window&&e.push({obj:window,value:"[object Window]"}),c.func=function(a){return"function "+buster.functionName(a)+"() {}"},c.array=function(a,b){b=b||[],b.push(a);for(var d=[],e=0,f=a.length;f>e;++e)d.push(c.call(this,a[e],b));return"["+d.join(", ")+"]"},c.object=function(d,e,f){e=e||[],e.push(d),f=f||0;for(var g,h,i,j=[],k=a(d),l="",m=3,n=0,o=f;o>n;++n)l+=" ";for(n=0,o=k.length;o>n;++n)g=k[n],i=d[g],h=b(i,e)?"[Circular]":c.call(this,i,e,f+2),h=(/\s/.test(g)?'"'+g+'"':g)+": "+h,m+=h.length,j.push(h);var p=c.constructorName.call(this,d),q=p?"["+p+"] ":"";return m+f>80?q+"{\n  "+l+j.join(",\n  "+l)+"\n"+l+"}":q+"{ "+j.join(", ")+" }"},c.element=function(a){for(var b,c,d=a.tagName.toLowerCase(),e=a.attributes,f=[],g=0,h=e.length;h>g;++g)b=e.item(g),c=b.nodeName.toLowerCase().replace("html:",""),("contenteditable"!=c||"inherit"!=b.nodeValue)&&b.nodeValue&&f.push(c+'="'+b.nodeValue+'"');var i="<"+d+(f.length>0?" ":""),j=a.innerHTML;j.length>20&&(j=j.substr(0,20)+"[...]");var k=i+f.join(" ")+">"+j+"</"+d+">";return k.replace(/ contentEditable="inherit"/,"")},c.constructorName=function(a){for(var b=buster.functionName(a&&a.constructor),c=this.excludeConstructors||buster.format.excludeConstructors||[],d=0,e=c.length;e>d;++d){if("string"==typeof c[d]&&c[d]==b)return"";if(c[d].test&&c[d].test(b))return""}return b},c}(),"undefined"!=typeof module&&(module.exports=buster.format);var sinon=function(a){function b(a){var b=!1;try{a.appendChild(f),b=f.parentNode==a}catch(c){return!1}finally{try{a.removeChild(f)}catch(c){}}return b}function c(a){return f&&a&&1===a.nodeType&&b(a)}function d(a){return"function"==typeof a||!!(a&&a.constructor&&a.call&&a.apply)}function e(a,b){for(var c in b)g.call(a,c)||(a[c]=b[c])}var f="undefined"!=typeof document&&document.createElement("div"),g=Object.prototype.hasOwnProperty,h={wrapMethod:function(a,b,c){if(!a)throw new TypeError("Should wrap property of object");if("function"!=typeof c)throw new TypeError("Method wrapper should be function");var f=a[b];if(!d(f))throw new TypeError("Attempted to wrap "+typeof f+" property "+b+" as function");if(f.restore&&f.restore.sinon)throw new TypeError("Attempted to wrap "+b+" which is already wrapped");if(f.calledBefore){var h=f.returns?"stubbed":"spied on";throw new TypeError("Attempted to wrap "+b+" which is already "+h)}var i=g.call(a,b);return a[b]=c,c.displayName=b,c.restore=function(){i||delete a[b],a[b]===c&&(a[b]=f)},c.restore.sinon=!0,e(c,f),c},extend:function(a){for(var b=1,c=arguments.length;c>b;b+=1)for(var d in arguments[b])arguments[b].hasOwnProperty(d)&&(a[d]=arguments[b][d]),arguments[b].hasOwnProperty("toString")&&arguments[b].toString!=a.toString&&(a.toString=arguments[b].toString);return a},create:function(a){var b=function(){};return b.prototype=a,new b},deepEqual:function m(a,b){if(h.match&&h.match.isMatcher(a))return a.test(b);if("object"!=typeof a||"object"!=typeof b)return a===b;if(c(a)||c(b))return a===b;if(a===b)return!0;if(null===a&&null!==b||null!==a&&null===b)return!1;var d=Object.prototype.toString.call(a);if(d!=Object.prototype.toString.call(b))return!1;if("[object Array]"==d){if(a.length!==b.length)return!1;for(var e=0,f=a.length;f>e;e+=1)if(!m(a[e],b[e]))return!1;return!0}var g,i=0,j=0;for(g in a)if(i+=1,!m(a[g],b[g]))return!1;for(g in b)j+=1;return i!=j?!1:!0},functionName:function(a){var b=a.displayName||a.name;if(!b){var c=a.toString().match(/function ([^\s\(]+)/);b=c&&c[1]}return b},functionToString:function(){if(this.getCall&&this.callCount)for(var a,b,c=this.callCount;c--;){a=this.getCall(c).thisValue;for(b in a)if(a[b]===this)return b}return this.displayName||"sinon fake"},getConfig:function(a){var b={};a=a||{};var c=h.defaultConfig;for(var d in c)c.hasOwnProperty(d)&&(b[d]=a.hasOwnProperty(d)?a[d]:c[d]);return b},format:function(a){return""+a},defaultConfig:{injectIntoThis:!0,injectInto:null,properties:["spy","stub","mock","clock","server","requests"],useFakeTimers:!0,useFakeServer:!0},timesInWords:function(a){return 1==a&&"once"||2==a&&"twice"||3==a&&"thrice"||(a||0)+" times"},calledInOrder:function(a){for(var b=1,c=a.length;c>b;b++)if(!a[b-1].calledBefore(a[b])||!a[b].called)return!1;return!0},orderByFirstCall:function(a){return a.sort(function(a,b){var c=a.getCall(0),d=b.getCall(0),e=c&&c.callId||-1,f=d&&d.callId||-1;return f>e?-1:1})},log:function(){},logError:function(a,b){var c=a+" threw exception: ";h.log(c+"["+b.name+"] "+b.message),b.stack&&h.log(b.stack),setTimeout(function(){throw b.message=c+b.message,b},0)},typeOf:function(a){if(null===a)return"null";if(void 0===a)return"undefined";var b=Object.prototype.toString.call(a);return b.substring(8,b.length-1).toLowerCase()},createStubInstance:function(a){if("function"!=typeof a)throw new TypeError("The constructor should be a function.");return h.stub(h.create(a.prototype))}},i="object"==typeof module&&"function"==typeof require;if(i){try{a={format:require("buster-format")}}catch(j){}module.exports=h,module.exports.spy=require("./sinon/spy"),module.exports.stub=require("./sinon/stub"),module.exports.mock=require("./sinon/mock"),module.exports.collection=require("./sinon/collection"),module.exports.assert=require("./sinon/assert"),module.exports.sandbox=require("./sinon/sandbox"),module.exports.test=require("./sinon/test"),module.exports.testCase=require("./sinon/test_case"),module.exports.assert=require("./sinon/assert"),module.exports.match=require("./sinon/match")}if(a){var k=h.create(a.format);k.quoteStrings=!1,h.format=function(){return k.ascii.apply(k,arguments)}}else if(i)try{var l=require("util");h.format=function(a){return"object"==typeof a&&a.toString===Object.prototype.toString?l.inspect(a):a}}catch(j){}return h}("object"==typeof buster&&buster);if(function(a){function b(b,c,d){var e=a.typeOf(b);if(e!==c)throw new TypeError("Expected type of "+d+" to be "+c+", but was "+e)}function c(a){return g.isPrototypeOf(a)}function d(b,c){if(null===c||void 0===c)return!1;for(var e in b)if(b.hasOwnProperty(e)){var f=b[e],g=c[e];if(h.isMatcher(f)){if(!f.test(g))return!1}else if("object"===a.typeOf(f)){if(!d(f,g))return!1}else if(!a.deepEqual(f,g))return!1}return!0}function e(c,d){return function(e,f){b(e,"string","property");var g=1===arguments.length,i=d+'("'+e+'"';return g||(i+=", "+f),i+=")",h(function(b){return void 0!==b&&null!==b&&c(b,e)?g||a.deepEqual(f,b[e]):!1},i)}}var f="object"==typeof module&&"function"==typeof require;if(!a&&f&&(a=require("../sinon")),a){var g={toString:function(){return this.message}};g.or=function(b){if(!c(b))throw new TypeError("Matcher expected");var d=this,e=a.create(g);return e.test=function(a){return d.test(a)||b.test(a)},e.message=d.message+".or("+b.message+")",e},g.and=function(b){if(!c(b))throw new TypeError("Matcher expected");var d=this,e=a.create(g);return e.test=function(a){return d.test(a)&&b.test(a)},e.message=d.message+".and("+b.message+")",e};var h=function(b,c){var e=a.create(g),f=a.typeOf(b);switch(f){case"object":if("function"==typeof b.test)return e.test=function(a){return b.test(a)===!0},e.message="match("+a.functionName(b.test)+")",e;var h=[];for(var i in b)b.hasOwnProperty(i)&&h.push(i+": "+b[i]);e.test=function(a){return d(b,a)},e.message="match("+h.join(", ")+")";break;case"number":e.test=function(a){return b==a};break;case"string":e.test=function(a){return"string"!=typeof a?!1:-1!==a.indexOf(b)},e.message='match("'+b+'")';break;case"regexp":e.test=function(a){return"string"!=typeof a?!1:b.test(a)};break;case"function":e.test=b,e.message=c?c:"match("+a.functionName(b)+")";break;default:e.test=function(c){return a.deepEqual(b,c)}}return e.message||(e.message="match("+b+")"),e};h.isMatcher=c,h.any=h(function(){return!0},"any"),h.defined=h(function(a){return null!==a&&void 0!==a},"defined"),h.truthy=h(function(a){return!!a},"truthy"),h.falsy=h(function(a){return!a},"falsy"),h.same=function(a){return h(function(b){return a===b},"same("+a+")")},h.typeOf=function(c){return b(c,"string","type"),h(function(b){return a.typeOf(b)===c},'typeOf("'+c+'")')},h.instanceOf=function(c){return b(c,"function","type"),h(function(a){return a instanceof c},"instanceOf("+a.functionName(c)+")")},h.has=e(function(a,b){return"object"==typeof a?b in a:void 0!==a[b]},"has"),h.hasOwn=e(function(a,b){return a.hasOwnProperty(b)},"hasOwn"),h.bool=h.typeOf("boolean"),h.number=h.typeOf("number"),h.string=h.typeOf("string"),h.object=h.typeOf("object"),h.func=h.typeOf("function"),h.array=h.typeOf("array"),h.regexp=h.typeOf("regexp"),h.date=h.typeOf("date"),f?module.exports=h:a.match=h}}("object"==typeof sinon&&sinon||null),function(sinon){function spy(a,b){if(!b&&"function"==typeof a)return spy.create(a);if(!a&&!b)return spy.create(function(){});var c=a[b];return sinon.wrapMethod(a,b,spy.create(c))}var commonJSModule="object"==typeof module&&"function"==typeof require,spyCall,callId=0,push=[].push,slice=Array.prototype.slice;!sinon&&commonJSModule&&(sinon=require("../sinon")),sinon&&(sinon.extend(spy,function(){function delegateToCalls(a,b,c,d,e){a[b]=function(){if(!this.called)return e?e.apply(this,arguments):!1;for(var a,f=0,g=0,h=this.callCount;h>g;g+=1)if(a=this.getCall(g),a[d||b].apply(a,arguments)&&(f+=1,c))return!0;return f===this.callCount}}function matchingFake(a,b,c){if(a){b.length;for(var d=0,e=a.length;e>d;d++)if(a[d].matches(b,c))return a[d]}}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){var p;return func.length?eval("p = (function proxy("+vars.substring(0,2*func.length-1)+") { return p.invoke(func, this, slice.call(arguments)); });"):p=function(){return p.invoke(func,this,slice.call(arguments))},p}var vars="a,b,c,d,e,f,g,h,i,j,k,l",uuid=0,spyApi={reset:function(){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 a=0;a<this.fakes.length;a++)this.fakes[a].reset()},create:function(a){var b;"function"!=typeof a?a=function(){}:b=sinon.functionName(a);var c=createProxy(a);return sinon.extend(c,spy),delete c.create,sinon.extend(c,a),c.reset(),c.prototype=a.prototype,c.displayName=b||"spy",c.toString=sinon.functionToString,c._create=sinon.spy.create,c.id="spy#"+uuid++,c},invoke:function(a,b,c){var d,e,f=matchingFake(this.fakes,c);incrementCallCount.call(this),push.call(this.thisValues,b),push.call(this.args,c),push.call(this.callIds,callId++);try{e=f?f.invoke(a,b,c):(this.func||a).apply(b,c)}catch(g){throw push.call(this.returnValues,void 0),d=g,g}finally{push.call(this.exceptions,d)}return push.call(this.returnValues,e),createCallProperties.call(this),e},getCall:function(a){return 0>a||a>=this.callCount?null:spyCall.create(this,this.thisValues[a],this.args[a],this.returnValues[a],this.exceptions[a],this.callIds[a])},calledBefore:function(a){return this.called?a.called?this.callIds[0]<a.callIds[a.callIds.length-1]:!0:!1},calledAfter:function(a){return this.called&&a.called?this.callIds[this.callCount-1]>a.callIds[a.callCount-1]:!1},withArgs:function(){var a=slice.call(arguments);if(this.fakes){var b=matchingFake(this.fakes,a,!0);if(b)return b}else this.fakes=[];var c=this,d=this._create();d.matchingAguments=a,push.call(this.fakes,d),d.withArgs=function(){return c.withArgs.apply(c,arguments)};for(var e=0;e<this.args.length;e++)d.matches(this.args[e])&&(incrementCallCount.call(d),push.call(d.thisValues,this.thisValues[e]),push.call(d.args,this.args[e]),push.call(d.returnValues,this.returnValues[e]),push.call(d.exceptions,this.exceptions[e]),push.call(d.callIds,this.callIds[e]));return createCallProperties.call(d),d},matches:function(a,b){var c=this.matchingAguments;return c.length<=a.length&&sinon.deepEqual(c,a.slice(0,c.length))?!b||c.length==a.length:void 0},printf:function(a){var b,c=this,d=slice.call(arguments,1);return(a||"").replace(/%(.)/g,function(a,e){return b=spyApi.formatters[e],"function"==typeof b?b.call(null,c,d):isNaN(parseInt(e),10)?"%"+e:sinon.format(d[e-1])})}};return delegateToCalls(spyApi,"calledOn",!0),delegateToCalls(spyApi,"alwaysCalledOn",!1,"calledOn"),delegateToCalls(spyApi,"calledWith",!0),delegateToCalls(spyApi,"calledWithMatch",!0),delegateToCalls(spyApi,"alwaysCalledWith",!1,"calledWith"),delegateToCalls(spyApi,"alwaysCalledWithMatch",!1,"calledWithMatch"),delegateToCalls(spyApi,"calledWithExactly",!0),delegateToCalls(spyApi,"alwaysCalledWithExactly",!1,"calledWithExactly"),delegateToCalls(spyApi,"neverCalledWith",!1,"notCalledWith",function(){return!0}),delegateToCalls(spyApi,"neverCalledWithMatch",!1,"notCalledWithMatch",function(){return!0}),delegateToCalls(spyApi,"threw",!0),delegateToCalls(spyApi,"alwaysThrew",!1,"threw"),delegateToCalls(spyApi,"returned",!0),delegateToCalls(spyApi,"alwaysReturned",!1,"returned"),delegateToCalls(spyApi,"calledWithNew",!0),delegateToCalls(spyApi,"alwaysCalledWithNew",!1,"calledWithNew"),delegateToCalls(spyApi,"callArg",!1,"callArgWith",function(){throw new Error(this.toString()+" cannot call arg since it was not yet invoked.")}),spyApi.callArgWith=spyApi.callArg,delegateToCalls(spyApi,"callArgOn",!1,"callArgOnWith",function(){throw new Error(this.toString()+" cannot call arg since it was not yet invoked.")}),spyApi.callArgOnWith=spyApi.callArgOn,delegateToCalls(spyApi,"yield",!1,"yield",function(){throw new Error(this.toString()+" cannot yield since it was not yet invoked.")}),spyApi.invokeCallback=spyApi.yield,delegateToCalls(spyApi,"yieldOn",!1,"yieldOn",function(){throw new Error(this.toString()+" cannot yield since it was not yet invoked.")}),delegateToCalls(spyApi,"yieldTo",!1,"yieldTo",function(a){throw new Error(this.toString()+" cannot yield to '"+a+"' since it was not yet invoked.")}),delegateToCalls(spyApi,"yieldToOn",!1,"yieldToOn",function(a){throw new Error(this.toString()+" cannot yield to '"+a+"' since it was not yet invoked.")}),spyApi.formatters={c:function(a){return sinon.timesInWords(a.callCount)},n:function(a){return a.toString()},C:function(a){for(var b=[],c=0,d=a.callCount;d>c;++c){var e="    "+a.getCall(c).toString();/\n/.test(b[c-1])&&(e="\n"+e),push.call(b,e)}return b.length>0?"\n"+b.join("\n"):""},t:function(a){for(var b=[],c=0,d=a.callCount;d>c;++c)push.call(b,sinon.format(a.thisValues[c]));return b.join(", ")},"*":function(a,b){for(var c=[],d=0,e=b.length;e>d;++d)push.call(c,sinon.format(b[d]));return c.join(", ")}},spyApi}()),spyCall=function(){function a(a,b,c){var d=sinon.functionName(a)+b;throw c.length&&(d+=" Received ["+slice.call(c).join(", ")+"]"),new Error(d)}var b={create:function(a,b,c,d,e,f){var g=sinon.create(spyCall);return delete g.create,g.proxy=a,g.thisValue=b,g.args=c,g.returnValue=d,g.exception=e,g.callId="number"==typeof f&&f||callId++,g},calledOn:function(a){return sinon.match&&sinon.match.isMatcher(a)?a.test(this.thisValue):this.thisValue===a},calledWith:function(){for(var a=0,b=arguments.length;b>a;a+=1)if(!sinon.deepEqual(arguments[a],this.args[a]))return!1;return!0},calledWithMatch:function(){for(var a=0,b=arguments.length;b>a;a+=1){var c=this.args[a],d=arguments[a];if(!sinon.match||!sinon.match(d).test(c))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(a){return sinon.deepEqual(a,this.returnValue)},threw:function(a){return"undefined"!=typeof a&&this.exception?"string"==typeof a?this.exception.name==a:this.exception===a:!!this.exception},calledWithNew:function(){return this.thisValue instanceof this.proxy},calledBefore:function(a){return this.callId<a.callId},calledAfter:function(a){return this.callId>a.callId},callArg:function(a){this.args[a]()},callArgOn:function(a,b){this.args[a].apply(b)},callArgWith:function(a){this.callArgOnWith.apply(this,[a,null].concat(slice.call(arguments,1)))},callArgOnWith:function(a,b){var c=slice.call(arguments,2);this.args[a].apply(b,c)},yield:function(){this.yieldOn.apply(this,[null].concat(slice.call(arguments,0)))},yieldOn:function(b){for(var c=this.args,d=0,e=c.length;e>d;++d)if("function"==typeof c[d])return c[d].apply(b,slice.call(arguments,1)),void 0;a(this.proxy," cannot yield since no callback was passed.",c)},yieldTo:function(a){this.yieldToOn.apply(this,[a,null].concat(slice.call(arguments,1)))},yieldToOn:function(b,c){for(var d=this.args,e=0,f=d.length;f>e;++e)if(d[e]&&"function"==typeof d[e][b])return d[e][b].apply(c,slice.call(arguments,2)),void 0;a(this.proxy," cannot yield to '"+b+"' since no callback was passed.",d)},toString:function(){for(var a=this.proxy.toString()+"(",b=[],c=0,d=this.args.length;d>c;++c)push.call(b,sinon.format(this.args[c]));return a=a+b.join(", ")+")","undefined"!=typeof this.returnValue&&(a+=" => "+sinon.format(this.returnValue)),this.exception&&(a+=" !"+this.exception.name,this.exception.message&&(a+="("+this.exception.message+")")),a}};return b.invokeCallback=b.yield,b}(),spy.spyCall=spyCall,sinon.spyCall=spyCall,commonJSModule?module.exports=spy:sinon.spy=spy)}("object"==typeof sinon&&sinon||null),function(a){function b(c,d,e){if(e&&"function"!=typeof e)throw new TypeError("Custom stub should be function");var f;if(f=e?a.spy&&a.spy.create?a.spy.create(e):e:b.create(),!c&&!d)return a.stub.create();if(!d&&c&&"object"==typeof c){for(var g in c)"function"==typeof c[g]&&b(c,g);return c}return a.wrapMethod(c,d,f)}function c(a,b){var c=a.callCount-1,d=a[b],e=c in d?d[c]:d[d.length-1];return a[b+"Last"]=e,e}function d(a,b){var d=c(a,"callArgAts");if(0>d){for(var e=c(a,"callArgProps"),f=0,g=b.length;g>f;++f){if(!e&&"function"==typeof b[f])return b[f];if(e&&b[f]&&"function"==typeof b[f][e])return b[f][e]}return null}return b[d]}function e(b,c,d){if(b.callArgAtsLast<0){var e;return e=b.callArgPropsLast?a.functionName(b)+" expected to yield to '"+b.callArgPropsLast+"', but no object with such a property was passed.":a.functionName(b)+" expected to yield, but no callback was passed.",d.length>0&&(e+=" Received ["+h.call(d,", ")+"]"),e}return"argument at index "+b.callArgAtsLast+" is not a function: "+c}function f(a,b){if(a.callArgAts.length>0){var f=d(a,b);if("function"!=typeof f)throw new TypeError(e(a,f,b));var g=c(a,"callbackArguments"),h=c(a,"callbackContexts");a.callbackAsync?i(function(){f.apply(h,g)}):f.apply(h,g)}}var g="object"==typeof module&&"function"==typeof require;if(!a&&g&&(a=require("../sinon")),a){var h=Array.prototype.join,i=function(){return"object"==typeof process&&"function"==typeof process.nextTick?process.nextTick:"function"==typeof setImmediate?setImmediate:function(a){setTimeout(a,0)}}(),j=0;a.extend(b,function(){function c(a,b){return"string"==typeof a?(this.exception=new Error(b||""),this.exception.name=a):this.exception=a?a:new Error("Error"),this}var d,e=Array.prototype.slice;d={create:function(){var c=function(){if(f(c,arguments),c.exception)throw c.exception;return"number"==typeof c.returnArgAt?arguments[c.returnArgAt]:c.returnThis?this:c.returnValue};c.id="stub#"+j++;var d=c;return c=a.spy.create(c),c.func=d,c.callArgAts=[],c.callbackArguments=[],c.callbackContexts=[],c.callArgProps=[],a.extend(c,b),c._create=a.stub.create,c.displayName="stub",c.toString=a.functionToString,c},resetBehavior:function(){var a;if(this.callArgAts=[],this.callbackArguments=[],this.callbackContexts=[],this.callArgProps=[],delete this.returnValue,delete this.returnArgAt,this.returnThis=!1,this.fakes)for(a=0;a<this.fakes.length;a++)this.fakes[a].resetBehavior()},returns:function(a){return this.returnValue=a,this},returnsArg:function(a){if("number"!=typeof a)throw new TypeError("argument index is not number");return this.returnArgAt=a,this},returnsThis:function(){return this.returnThis=!0,this},"throws":c,throwsException:c,callsArg:function(a){if("number"!=typeof a)throw new TypeError("argument index is not number");return this.callArgAts.push(a),this.callbackArguments.push([]),this.callbackContexts.push(void 0),this.callArgProps.push(void 0),this},callsArgOn:function(a,b){if("number"!=typeof a)throw new TypeError("argument index is not number");if("object"!=typeof b)throw new TypeError("argument context is not an object");return this.callArgAts.push(a),this.callbackArguments.push([]),this.callbackContexts.push(b),this.callArgProps.push(void 0),this},callsArgWith:function(a){if("number"!=typeof a)throw new TypeError("argument index is not number");return this.callArgAts.push(a),this.callbackArguments.push(e.call(arguments,1)),this.callbackContexts.push(void 0),this.callArgProps.push(void 0),this},callsArgOnWith:function(a,b){if("number"!=typeof a)throw new TypeError("argument index is not number");if("object"!=typeof b)throw new TypeError("argument context is not an object");return this.callArgAts.push(a),this.callbackArguments.push(e.call(arguments,2)),this.callbackContexts.push(b),this.callArgProps.push(void 0),this},yields:function(){return this.callArgAts.push(-1),this.callbackArguments.push(e.call(arguments,0)),this.callbackContexts.push(void 0),this.callArgProps.push(void 0),this},yieldsOn:function(a){if("object"!=typeof a)throw new TypeError("argument context is not an object");return this.callArgAts.push(-1),this.callbackArguments.push(e.call(arguments,1)),this.callbackContexts.push(a),this.callArgProps.push(void 0),this},yieldsTo:function(a){return this.callArgAts.push(-1),this.callbackArguments.push(e.call(arguments,1)),this.callbackContexts.push(void 0),this.callArgProps.push(a),this},yieldsToOn:function(a,b){if("object"!=typeof b)throw new TypeError("argument context is not an object");return this.callArgAts.push(-1),this.callbackArguments.push(e.call(arguments,2)),this.callbackContexts.push(b),this.callArgProps.push(a),this}};for(var g in d)d.hasOwnProperty(g)&&g.match(/^(callsArg|yields|thenYields$)/)&&!g.match(/Async/)&&(d[g+"Async"]=function(a){return function(){return this.callbackAsync=!0,this[a].apply(this,arguments)}}(g));return d}()),g?module.exports=b:a.stub=b}}("object"==typeof sinon&&sinon||null),function(a){function b(c){return c?b.create(c):a.expectation.create("Anonymous mock")}var c="object"==typeof module&&"function"==typeof require,d=[].push;if(!a&&c&&(a=require("../sinon")),a){a.mock=b,a.extend(b,function(){function c(a,b){if(a)for(var c=0,d=a.length;d>c;c+=1)b(a[c])}return{create:function(c){if(!c)throw new TypeError("object is null");var d=a.extend({},b);return d.object=c,delete d.create,d},expects:function(b){if(!b)throw new TypeError("method is falsy");if(this.expectations||(this.expectations={},this.proxies=[]),!this.expectations[b]){this.expectations[b]=[];var c=this;a.wrapMethod(this.object,b,function(){return c.invokeMethod(b,this,arguments)}),d.call(this.proxies,b)}var e=a.expectation.create(b);return d.call(this.expectations[b],e),e},restore:function(){var a=this.object;c(this.proxies,function(b){"function"==typeof a[b].restore&&a[b].restore()})},verify:function(){var b=this.expectations||{},e=[],f=[];return c(this.proxies,function(a){c(b[a],function(a){a.met()?d.call(f,a.toString()):d.call(e,a.toString())})}),this.restore(),e.length>0?a.expectation.fail(e.concat(f).join("\n")):a.expectation.pass(e.concat(f).join("\n")),!0},invokeMethod:function(b,c,e){var f,g=this.expectations&&this.expectations[b],h=g&&g.length||0;for(f=0;h>f;f+=1)if(!g[f].met()&&g[f].allowsCall(c,e))return g[f].apply(c,e);var i,j=[],k=0;for(f=0;h>f;f+=1)g[f].allowsCall(c,e)?i=i||g[f]:k+=1,d.call(j,"    "+g[f].toString());return 0===k?i.apply(c,e):(j.unshift("Unexpected call: "+a.spyCall.toString.call({proxy:b,args:e})),a.expectation.fail(j.join("\n")),void 0)}}}());var e=a.timesInWords;a.expectation=function(){function b(a){return 0==a?"never called":"called "+e(a)}function c(a){var b=a.minCalls,c=a.maxCalls;if("number"==typeof b&&"number"==typeof c){var d=e(b);return b!=c&&(d="at least "+d+" and at most "+e(c)),d}return"number"==typeof b?"at least "+e(b):"at most "+e(c)}function f(a){var b="number"==typeof a.minCalls;return!b||a.callCount>=a.minCalls}function g(a){return"number"!=typeof a.maxCalls?!1:a.callCount==a.maxCalls}var h=Array.prototype.slice,i=a.spy.invoke;return{minCalls:1,maxCalls:1,create:function(b){var c=a.extend(a.stub.create(),a.expectation);return delete c.create,c.method=b,c},invoke:function(a,b,c){return this.verifyCallAllowed(b,c),i.apply(this,arguments)},atLeast:function(a){if("number"!=typeof a)throw new TypeError("'"+a+"' is not number");return this.limitsSet||(this.maxCalls=null,this.limitsSet=!0),this.minCalls=a,this},atMost:function(a){if("number"!=typeof a)throw new TypeError("'"+a+"' is not number");return this.limitsSet||(this.minCalls=null,this.limitsSet=!0),this.maxCalls=a,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(a){if("number"!=typeof a)throw new TypeError("'"+a+"' is not a number");return this.atLeast(a),this.atMost(a)},met:function(){return!this.failed&&f(this)},verifyCallAllowed:function(b,c){if(g(this)&&(this.failed=!0,a.expectation.fail(this.method+" already called "+e(this.maxCalls))),"expectedThis"in this&&this.expectedThis!==b&&a.expectation.fail(this.method+" called with "+b+" as thisValue, expected "+this.expectedThis),"expectedArguments"in this){c||a.expectation.fail(this.method+" received no arguments, expected "+a.format(this.expectedArguments)),c.length<this.expectedArguments.length&&a.expectation.fail(this.method+" received too few arguments ("+a.format(c)+"), expected "+a.format(this.expectedArguments)),this.expectsExactArgCount&&c.length!=this.expectedArguments.length&&a.expectation.fail(this.method+" received too many arguments ("+a.format(c)+"), expected "+a.format(this.expectedArguments));for(var d=0,f=this.expectedArguments.length;f>d;d+=1)a.deepEqual(this.expectedArguments[d],c[d])||a.expectation.fail(this.method+" received wrong arguments "+a.format(c)+", expected "+a.format(this.expectedArguments))}},allowsCall:function(b,c){if(this.met()&&g(this))return!1;if("expectedThis"in this&&this.expectedThis!==b)return!1;if(!("expectedArguments"in this))return!0;if(c=c||[],c.length<this.expectedArguments.length)return!1;if(this.expectsExactArgCount&&c.length!=this.expectedArguments.length)return!1;for(var d=0,e=this.expectedArguments.length;e>d;d+=1)if(!a.deepEqual(this.expectedArguments[d],c[d]))return!1;return!0},withArgs:function(){return this.expectedArguments=h.call(arguments),this},withExactArgs:function(){return this.withArgs.apply(this,arguments),this.expectsExactArgCount=!0,this},on:function(a){return this.expectedThis=a,this},toString:function(){var e=(this.expectedArguments||[]).slice();this.expectsExactArgCount||d.call(e,"[...]");var f=a.spyCall.toString.call({proxy:this.method||"anonymous mock expectation",args:e}),g=f.replace(", [...","[, ...")+" "+c(this);return this.met()?"Expectation met: "+g:"Expected "+g+" ("+b(this.callCount)+")"},verify:function(){return this.met()?a.expectation.pass(this.toString()):a.expectation.fail(this.toString()),!0},pass:function(b){a.assert.pass(b)},fail:function(a){var b=new Error(a);throw b.name="ExpectationError",b}}}(),c?module.exports=b:a.mock=b}}("object"==typeof sinon&&sinon||null),function(a){function b(a){return a.fakes||(a.fakes=[]),a.fakes
  }function c(a,c){for(var d=b(a),e=0,f=d.length;f>e;e+=1)"function"==typeof d[e][c]&&d[e][c]()}function d(a){for(var c=b(a),d=0;d<c.length;)c.splice(d,1)}var e="object"==typeof module&&"function"==typeof require,f=[].push,g=Object.prototype.hasOwnProperty;if(!a&&e&&(a=require("../sinon")),a){var h={verify:function(){c(this,"verify")},restore:function(){c(this,"restore"),d(this)},verifyAndRestore:function(){var a;try{this.verify()}catch(b){a=b}if(this.restore(),a)throw a},add:function(a){return f.call(b(this),a),a},spy:function(){return this.add(a.spy.apply(a,arguments))},stub:function(b,c,d){if(c){var e=b[c];if("function"!=typeof e){if(!g.call(b,c))throw new TypeError("Cannot stub non-existent own property "+c);return b[c]=d,this.add({restore:function(){b[c]=e}})}}if(!c&&b&&"object"==typeof b){var f=a.stub.apply(a,arguments);for(var h in f)"function"==typeof f[h]&&this.add(f[h]);return f}return this.add(a.stub.apply(a,arguments))},mock:function(){return this.add(a.mock.apply(a,arguments))},inject:function(a){var b=this;return a.spy=function(){return b.spy.apply(b,arguments)},a.stub=function(){return b.stub.apply(b,arguments)},a.mock=function(){return b.mock.apply(b,arguments)},a}};e?module.exports=h:a.collection=h}}("object"==typeof sinon&&sinon||null),"undefined"==typeof sinon)var sinon={};if(function(global){function addTimer(a,b){if(0===a.length)throw new Error("Function requires at least 1 parameter");var c=id++,d=a[1]||0;return this.timeouts||(this.timeouts={}),this.timeouts[c]={id:c,func:a[0],callAt:this.now+d,invokeArgs:Array.prototype.slice.call(a,2)},b===!0&&(this.timeouts[c].interval=d),c}function parseTime(a){if(!a)return 0;var b,c=a.split(":"),d=c.length,e=d,f=0;if(d>3||!/^(\d\d:){0,2}\d\d?$/.test(a))throw new Error("tick only understands numbers and 'h:m:s'");for(;e--;){if(b=parseInt(c[e],10),b>=60)throw new Error("Invalid time "+a);f+=b*Math.pow(60,d-e-1)}return 1e3*f}function createObject(a){var b;if(Object.create)b=Object.create(a);else{var c=function(){};c.prototype=a,b=new c}return b.Date.clock=b,b}function mirrorDateProperties(a,b){return b.now?a.now=function(){return a.clock.now}:delete a.now,b.toSource?a.toSource=function(){return b.toSource()}:delete a.toSource,a.toString=function(){return b.toString()},a.prototype=b.prototype,a.parse=b.parse,a.UTC=b.UTC,a.prototype.toUTCString=b.prototype.toUTCString,a}function restore(){for(var a,b=0,c=this.methods.length;c>b;b++)a=this.methods[b],global[a].hadOwnProperty?global[a]=this["_"+a]:delete global[a];this.methods=[]}function stubGlobal(a,b){if(b[a].hadOwnProperty=Object.prototype.hasOwnProperty.call(global,a),b["_"+a]=global[a],"Date"==a){var c=mirrorDateProperties(b[a],global[a]);global[a]=c}else{global[a]=function(){return b[a].apply(b,arguments)};for(var d in b[a])b[a].hasOwnProperty(d)&&(global[a][d]=b[a][d])}global[a].clock=b}var id=1;sinon.clock={now:0,create:function(a){var b=createObject(this);if("number"==typeof a&&(b.now=a),a&&"object"==typeof a)throw new TypeError("now should be milliseconds since UNIX epoch");return b},setTimeout:function(){return addTimer.call(this,arguments,!1)},clearTimeout:function(a){this.timeouts||(this.timeouts=[]),a in this.timeouts&&delete this.timeouts[a]},setInterval:function(){return addTimer.call(this,arguments,!0)},clearInterval:function(a){this.clearTimeout(a)},tick:function(a){a="number"==typeof a?a:parseTime(a);for(var b,c=this.now,d=this.now+a,e=this.now,f=this.firstTimerInRange(c,d);f&&d>=c;){if(this.timeouts[f.id]){c=this.now=f.callAt;try{this.callTimer(f)}catch(g){b=b||g}}f=this.firstTimerInRange(e,d),e=c}if(this.now=d,b)throw b;return this.now},firstTimerInRange:function(a,b){var c,d,e;for(var f in this.timeouts)if(this.timeouts.hasOwnProperty(f)){if(this.timeouts[f].callAt<a||this.timeouts[f].callAt>b)continue;(!d||this.timeouts[f].callAt<d)&&(e=this.timeouts[f],d=this.timeouts[f].callAt,c={func:this.timeouts[f].func,callAt:this.timeouts[f].callAt,interval:this.timeouts[f].interval,id:this.timeouts[f].id,invokeArgs:this.timeouts[f].invokeArgs})}return c||null},callTimer:function(timer){"number"==typeof timer.interval?this.timeouts[timer.id].callAt+=timer.interval:delete this.timeouts[timer.id];try{"function"==typeof timer.func?timer.func.apply(null,timer.invokeArgs):eval(timer.func)}catch(e){var exception=e}if(this.timeouts[timer.id]){if(exception)throw exception}else if(exception)throw exception},reset:function(){this.timeouts={}},Date:function(){function a(c,d,e,f,g,h,i){switch(arguments.length){case 0:return new b(a.clock.now);case 1:return new b(c);case 2:return new b(c,d);case 3:return new b(c,d,e);case 4:return new b(c,d,e,f);case 5:return new b(c,d,e,f,g);case 6:return new b(c,d,e,f,g,h);default:return new b(c,d,e,f,g,h,i)}}var b=Date;return mirrorDateProperties(a,b)}()};var methods=["Date","setTimeout","setInterval","clearTimeout","clearInterval"];sinon.useFakeTimers=function(a){var b=sinon.clock.create(a);b.restore=restore,b.methods=Array.prototype.slice.call(arguments,"number"==typeof a?1:0),0===b.methods.length&&(b.methods=methods);for(var c=0,d=b.methods.length;d>c;c++)stubGlobal(b.methods[c],b);return b}}("undefined"!=typeof global&&"function"!=typeof global?global:this),sinon.timers={setTimeout:setTimeout,clearTimeout:clearTimeout,setInterval:setInterval,clearInterval:clearInterval,Date:Date},"object"==typeof module&&"function"==typeof require&&(module.exports=sinon),"undefined"==typeof sinon&&(this.sinon={}),function(){var a=[].push;sinon.Event=function(a,b,c){this.initEvent(a,b,c)},sinon.Event.prototype={initEvent:function(a,b,c){this.type=a,this.bubbles=b,this.cancelable=c},stopPropagation:function(){},preventDefault:function(){this.defaultPrevented=!0}},sinon.EventTarget={addEventListener:function(b,c){this.eventListeners=this.eventListeners||{},this.eventListeners[b]=this.eventListeners[b]||[],a.call(this.eventListeners[b],c)},removeEventListener:function(a,b){for(var c=this.eventListeners&&this.eventListeners[a]||[],d=0,e=c.length;e>d;++d)if(c[d]==b)return c.splice(d,1)},dispatchEvent:function(a){for(var b=a.type,c=this.eventListeners&&this.eventListeners[b]||[],d=0;d<c.length;d++)"function"==typeof c[d]?c[d].call(this,a):c[d].handleEvent(a);return!!a.defaultPrevented}}}(),"undefined"==typeof sinon&&(this.sinon={}),sinon.xhr={XMLHttpRequest:this.XMLHttpRequest},function(a){function b(){this.readyState=b.UNSENT,this.requestHeaders={},this.requestBody=null,this.status=0,this.statusText="","function"==typeof b.onCreate&&b.onCreate(this)}function c(a){if(a.readyState!==b.OPENED)throw new Error("INVALID_STATE_ERR");if(a.sendFlag)throw new Error("INVALID_STATE_ERR")}function d(a,b){if(a)for(var c=0,d=a.length;d>c;c+=1)b(a[c])}function e(a,b){for(var c=0;c<a.length;c++)if(b(a[c])===!0)return!0;return!1}function f(a){if(a.readyState==b.DONE)throw new Error("Request done")}function g(a){if(a.async&&a.readyState!=b.HEADERS_RECEIVED)throw new Error("No headers received")}function h(a){if("string"!=typeof a){var b=new Error("Attempted to respond to fake XMLHttpRequest with "+a+", which is not a string.");throw b.name="InvalidBodyException",b}}var i=sinon.xhr;i.GlobalXMLHttpRequest=a.XMLHttpRequest,i.GlobalActiveXObject=a.ActiveXObject,i.supportsActiveX="undefined"!=typeof i.GlobalActiveXObject,i.supportsXHR="undefined"!=typeof i.GlobalXMLHttpRequest,i.workingXHR=i.supportsXHR?i.GlobalXMLHttpRequest:i.supportsActiveX?function(){return new i.GlobalActiveXObject("MSXML2.XMLHTTP.3.0")}:!1;var j={"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},k=function(a,b,c){switch(c.length){case 0:return a[b]();case 1:return a[b](c[0]);case 2:return a[b](c[0],c[1]);case 3:return a[b](c[0],c[1],c[2]);case 4:return a[b](c[0],c[1],c[2],c[3]);case 5:return a[b](c[0],c[1],c[2],c[3],c[4])}};b.filters=[],b.addFilter=function(a){this.filters.push(a)};var l=/MSIE 6/;b.defake=function(a,c){var e=new sinon.xhr.workingXHR;d(["open","setRequestHeader","send","abort","getResponseHeader","getAllResponseHeaders","addEventListener","overrideMimeType","removeEventListener"],function(b){a[b]=function(){return k(e,b,arguments)}});var f=function(b){d(b,function(b){try{a[b]=e[b]}catch(c){if(!l.test(navigator.userAgent))throw c}})},g=function(){a.readyState=e.readyState,e.readyState>=b.HEADERS_RECEIVED&&f(["status","statusText"]),e.readyState>=b.LOADING&&f(["responseText"]),e.readyState===b.DONE&&f(["responseXML"]),a.onreadystatechange&&a.onreadystatechange.call(a)};if(e.addEventListener){for(var h in a.eventListeners)a.eventListeners.hasOwnProperty(h)&&d(a.eventListeners[h],function(a){e.addEventListener(h,a)});e.addEventListener("readystatechange",g)}else e.onreadystatechange=g;k(e,"open",c)},b.useFilters=!1,sinon.extend(b.prototype,sinon.EventTarget,{async:!0,open:function(a,c,d,f,g){if(this.method=a,this.url=c,this.async="boolean"==typeof d?d:!0,this.username=f,this.password=g,this.responseText=null,this.responseXML=null,this.requestHeaders={},this.sendFlag=!1,sinon.FakeXMLHttpRequest.useFilters===!0){var h=arguments,i=e(b.filters,function(a){return a.apply(this,h)});if(i)return sinon.FakeXMLHttpRequest.defake(this,arguments)}this.readyStateChange(b.OPENED)},readyStateChange:function(a){if(this.readyState=a,"function"==typeof this.onreadystatechange)try{this.onreadystatechange()}catch(b){sinon.logError("Fake XHR onreadystatechange handler",b)}this.dispatchEvent(new sinon.Event("readystatechange"))},setRequestHeader:function(a,b){if(c(this),j[a]||/^(Sec-|Proxy-)/.test(a))throw new Error('Refused to set unsafe header "'+a+'"');this.requestHeaders[a]?this.requestHeaders[a]+=","+b:this.requestHeaders[a]=b},setResponseHeaders:function(a){this.responseHeaders={};for(var c in a)a.hasOwnProperty(c)&&(this.responseHeaders[c]=a[c]);this.async?this.readyStateChange(b.HEADERS_RECEIVED):this.readyState=b.HEADERS_RECEIVED},send:function(a){if(c(this),!/^(get|head)$/i.test(this.method)){if(this.requestHeaders["Content-Type"]){var d=this.requestHeaders["Content-Type"].split(";");this.requestHeaders["Content-Type"]=d[0]+";charset=utf-8"}else this.requestHeaders["Content-Type"]="text/plain;charset=utf-8";this.requestBody=a}this.errorFlag=!1,this.sendFlag=this.async,this.readyStateChange(b.OPENED),"function"==typeof this.onSend&&this.onSend(this)},abort:function(){this.aborted=!0,this.responseText=null,this.errorFlag=!0,this.requestHeaders={},this.readyState>sinon.FakeXMLHttpRequest.UNSENT&&this.sendFlag&&(this.readyStateChange(sinon.FakeXMLHttpRequest.DONE),this.sendFlag=!1),this.readyState=sinon.FakeXMLHttpRequest.UNSENT},getResponseHeader:function(a){if(this.readyState<b.HEADERS_RECEIVED)return null;if(/^Set-Cookie2?$/i.test(a))return null;a=a.toLowerCase();for(var c in this.responseHeaders)if(c.toLowerCase()==a)return this.responseHeaders[c];return null},getAllResponseHeaders:function(){if(this.readyState<b.HEADERS_RECEIVED)return"";var a="";for(var c in this.responseHeaders)this.responseHeaders.hasOwnProperty(c)&&!/^Set-Cookie2?$/i.test(c)&&(a+=c+": "+this.responseHeaders[c]+"\r\n");return a},setResponseBody:function(a){f(this),g(this),h(a);var c=this.chunkSize||10,d=0;this.responseText="";do this.async&&this.readyStateChange(b.LOADING),this.responseText+=a.substring(d,d+c),d+=c;while(d<a.length);var e=this.getResponseHeader("Content-Type");if(this.responseText&&(!e||/(text\/xml)|(application\/xml)|(\+xml)/.test(e)))try{this.responseXML=b.parseXML(this.responseText)}catch(i){}this.async?this.readyStateChange(b.DONE):this.readyState=b.DONE},respond:function(a,c,d){this.setResponseHeaders(c||{}),this.status="number"==typeof a?a:200,this.statusText=b.statusCodes[this.status],this.setResponseBody(d||"")}}),sinon.extend(b,{UNSENT:0,OPENED:1,HEADERS_RECEIVED:2,LOADING:3,DONE:4}),b.parseXML=function(a){var b;if("undefined"!=typeof DOMParser){var c=new DOMParser;b=c.parseFromString(a,"text/xml")}else b=new ActiveXObject("Microsoft.XMLDOM"),b.async="false",b.loadXML(a);return b},b.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",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"},sinon.useFakeXMLHttpRequest=function(){return sinon.FakeXMLHttpRequest.restore=function(b){i.supportsXHR&&(a.XMLHttpRequest=i.GlobalXMLHttpRequest),i.supportsActiveX&&(a.ActiveXObject=i.GlobalActiveXObject),delete sinon.FakeXMLHttpRequest.restore,b!==!0&&delete sinon.FakeXMLHttpRequest.onCreate},i.supportsXHR&&(a.XMLHttpRequest=sinon.FakeXMLHttpRequest),i.supportsActiveX&&(a.ActiveXObject=function(a){return"Microsoft.XMLHTTP"==a||/^Msxml2\.XMLHTTP/i.test(a)?new sinon.FakeXMLHttpRequest:new i.GlobalActiveXObject(a)}),sinon.FakeXMLHttpRequest},sinon.FakeXMLHttpRequest=b}(this),"object"==typeof module&&"function"==typeof require&&(module.exports=sinon),"undefined"==typeof sinon)var sinon={};if(sinon.fakeServer=function(){function a(){}function b(b){return a.prototype=b,new a}function c(a){var b=a;if("[object Array]"!=Object.prototype.toString.call(a)&&(b=[200,{},a]),"string"!=typeof b[2])throw new TypeError("Fake server response body should be string, but was "+typeof b[2]);return b}function d(a,b,c){var d=a.method,e=!d||d.toLowerCase()==b.toLowerCase(),f=a.url,g=!f||f==c||"function"==typeof f.test&&f.test(c);return e&&g}function e(a,b){this.getHTTPMethod(b);var c=b.url;if((!/^https?:\/\//.test(c)||i.test(c))&&(c=c.replace(i,"")),d(a,this.getHTTPMethod(b),c)){if("function"==typeof a.response){var e=a.url,f=[b].concat(e?c.match(e).slice(1):[]);return a.response.apply(a,f)}return!0}return!1}function f(a,b){var c;c="Request:\n"+sinon.format(b)+"\n\n",c+="Response:\n"+sinon.format(a)+"\n\n",sinon.log(c)}var g=[].push,h="undefined"!=typeof window?window.location:{},i=new RegExp("^"+h.protocol+"//"+h.host);return{create:function(){var a=b(this);return this.xhr=sinon.useFakeXMLHttpRequest(),a.requests=[],this.xhr.onCreate=function(b){a.addRequest(b)},a},addRequest:function(a){var b=this;g.call(this.requests,a),a.onSend=function(){b.handleRequest(this)},this.autoRespond&&!this.responding&&(setTimeout(function(){b.responding=!1,b.respond()},this.autoRespondAfter||10),this.responding=!0)},getHTTPMethod:function(a){if(this.fakeHTTPMethods&&/post/i.test(a.method)){var b=(a.requestBody||"").match(/_method=([^\b;]+)/);return b?b[1]:a.method}return a.method},handleRequest:function(a){a.async?(this.queue||(this.queue=[]),g.call(this.queue,a)):this.processRequest(a)},respondWith:function(a,b,d){return 1==arguments.length&&"function"!=typeof a?(this.response=c(a),void 0):(this.responses||(this.responses=[]),1==arguments.length&&(d=a,b=a=null),2==arguments.length&&(d=b,b=a,a=null),g.call(this.responses,{method:a,url:b,response:"function"==typeof d?d:c(d)}),void 0)},respond:function(){arguments.length>0&&this.respondWith.apply(this,arguments);for(var a,b=this.queue||[];a=b.shift();)this.processRequest(a)},processRequest:function(a){try{if(a.aborted)return;var b=this.response||[404,{},""];if(this.responses)for(var c=0,d=this.responses.length;d>c;c++)if(e.call(this,this.responses[c],a)){b=this.responses[c].response;break}4!=a.readyState&&(f(b,a),a.respond(b[0],b[1],b[2]))}catch(g){sinon.logError("Fake server request processing",g)}},restore:function(){return this.xhr.restore&&this.xhr.restore.apply(this.xhr,arguments)}}}(),"object"==typeof module&&"function"==typeof require&&(module.exports=sinon),function(){function a(){}a.prototype=sinon.fakeServer,sinon.fakeServerWithClock=new a,sinon.fakeServerWithClock.addRequest=function(a){if(a.async&&("object"==typeof setTimeout.clock?this.clock=setTimeout.clock:(this.clock=sinon.useFakeTimers(),this.resetClock=!0),!this.longestTimeout)){var b=this.clock.setTimeout,c=this.clock.setInterval,d=this;this.clock.setTimeout=function(a,c){return d.longestTimeout=Math.max(c,d.longestTimeout||0),b.apply(this,arguments)},this.clock.setInterval=function(a,b){return d.longestTimeout=Math.max(b,d.longestTimeout||0),c.apply(this,arguments)}}return sinon.fakeServer.addRequest.call(this,a)},sinon.fakeServerWithClock.respond=function(){var a=sinon.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)),a},sinon.fakeServerWithClock.restore=function(){return this.clock&&this.clock.restore(),sinon.fakeServer.restore.apply(this,arguments)}}(),"object"==typeof module&&"function"==typeof require){var sinon=require("../sinon");sinon.extend(sinon,require("./util/fake_timers"))}return function(){function a(a,b,d,e){e&&(b.injectInto?b.injectInto[d]=e:c.call(a.args,e))}function b(a){var b=sinon.create(sinon.sandbox);return a.useFakeServer&&("object"==typeof a.useFakeServer&&(b.serverPrototype=a.useFakeServer),b.useFakeServer()),a.useFakeTimers&&("object"==typeof a.useFakeTimers?b.useFakeTimers.apply(b,a.useFakeTimers):b.useFakeTimers()),b}var c=[].push;sinon.sandbox=sinon.extend(sinon.create(sinon.collection),{useFakeTimers:function(){return this.clock=sinon.useFakeTimers.apply(sinon,arguments),this.add(this.clock)},serverPrototype:sinon.fakeServer,useFakeServer:function(){var a=this.serverPrototype||sinon.fakeServer;return a&&a.create?(this.server=a.create(),this.add(this.server)):null},inject:function(a){return sinon.collection.inject.call(this,a),this.clock&&(a.clock=this.clock),this.server&&(a.server=this.server,a.requests=this.server.requests),a},create:function(c){if(!c)return sinon.create(sinon.sandbox);var d=b(c);d.args=d.args||[];var e,f,g=d.inject({});if(c.properties)for(var h=0,i=c.properties.length;i>h;h++)e=c.properties[h],f=g[e]||"sandbox"==e&&d,a(d,c,e,f);else a(d,c,"sandbox",f);return d}}),sinon.sandbox.useFakeXMLHttpRequest=sinon.sandbox.useFakeServer,"object"==typeof module&&"function"==typeof require&&(module.exports=sinon.sandbox)}(),function(a){function b(b){var c=typeof b;if("function"!=c)throw new TypeError("sinon.test needs to wrap a test function, got "+c);return function(){var c=a.getConfig(a.config);c.injectInto=c.injectIntoThis&&this||c.injectInto;var d,e,f=a.sandbox.create(c),g=Array.prototype.slice.call(arguments).concat(f.args);try{e=b.apply(this,g)}catch(h){d=h}if("undefined"!=typeof d)throw f.restore(),d;return f.verifyAndRestore(),e}}var c="object"==typeof module&&"function"==typeof require;!a&&c&&(a=require("../sinon")),a&&(b.config={injectIntoThis:!0,injectInto:null,properties:["spy","stub","mock","clock","server","requests"],useFakeTimers:!0,useFakeServer:!0},c?module.exports=b:a.test=b)}("object"==typeof sinon&&sinon||null),function(a){function b(a,b,c){return function(){b&&b.apply(this,arguments);var d,e;try{e=a.apply(this,arguments)}catch(f){d=f}if(c&&c.apply(this,arguments),d)throw d;return e}}function c(c,d){if(!c||"object"!=typeof c)throw new TypeError("sinon.testCase needs an object with test functions");d=d||"test";var e,f,g,h=new RegExp("^"+d),i={},j=c.setUp,k=c.tearDown;for(e in c)if(c.hasOwnProperty(e)){if(f=c[e],/^(setUp|tearDown)$/.test(e))continue;"function"==typeof f&&h.test(e)?(g=f,(j||k)&&(g=b(f,j,k)),i[e]=a.test(g)):i[e]=c[e]}return i}var d="object"==typeof module&&"function"==typeof require;!a&&d&&(a=require("../sinon")),a&&Object.prototype.hasOwnProperty&&(d?module.exports=c:a.testCase=c)}("object"==typeof sinon&&sinon||null),function(a,b){function c(){for(var a,b=0,c=arguments.length;c>b;++b)a=arguments[b],a||g.fail("fake is not a spy"),"function"!=typeof a&&g.fail(a+" is not a function"),"function"!=typeof a.getCall&&g.fail(a+" is not stubbed")}function d(a,c){a=a||b;var d=a.fail||g.fail;d.call(a,c)}function e(a,b,e){2==arguments.length&&(e=b,b=a),g[a]=function(f){c(f);var h=i.call(arguments,1),j=!1;j="function"==typeof b?!b(f):"function"==typeof f[b]?!f[b].apply(f,h):!f[b],j?d(this,f.printf.apply(f,[e].concat(h))):g.pass(a)}}function f(a,b){return!a||/^fail/.test(b)?b:a+b.slice(0,1).toUpperCase()+b.slice(1)}var g,h="object"==typeof module&&"function"==typeof require,i=Array.prototype.slice;!a&&h&&(a=require("../sinon")),a&&(g={failException:"AssertError",fail:function(a){var b=new Error(a);throw b.name=this.failException||g.failException,b},pass:function(){},callOrder:function(){c.apply(null,arguments);var b="",e="";if(a.calledInOrder(arguments))g.pass("callOrder");else{try{b=[].join.call(arguments,", "),e=a.orderByFirstCall(i.call(arguments)).join(", ")}catch(f){}d(this,"expected "+b+" to be "+"called in order but were called as "+e)}},callCount:function(b,e){if(c(b),b.callCount!=e){var f="expected %n to be called "+a.timesInWords(e)+" but was called %c%C";d(this,b.printf(f))}else g.pass("callCount")},expose:function(a,b){if(!a)throw new TypeError("target is null or undefined");var c=b||{},d="undefined"==typeof c.prefix&&"assert"||c.prefix,e="undefined"==typeof c.includeFail||!!c.includeFail;for(var g in this)"export"==g||!e&&/^(fail)/.test(g)||(a[f(d,g)]=this[g]);return a}},e("called","expected %n to have been called at least once but was never called"),e("notCalled",function(a){return!a.called},"expected %n to not have been called but was called %c%C"),e("calledOnce","expected %n to be called once but was called %c%C"),e("calledTwice","expected %n to be called twice but was called %c%C"),e("calledThrice","expected %n to be called thrice but was called %c%C"),e("calledOn","expected %n to be called with %1 as this but was called with %t"),e("alwaysCalledOn","expected %n to always be called with %1 as this but was called with %t"),e("calledWithNew","expected %n to be called with new"),e("alwaysCalledWithNew","expected %n to always be called with new"),e("calledWith","expected %n to be called with arguments %*%C"),e("calledWithMatch","expected %n to be called with match %*%C"),e("alwaysCalledWith","expected %n to always be called with arguments %*%C"),e("alwaysCalledWithMatch","expected %n to always be called with match %*%C"),e("calledWithExactly","expected %n to be called with exact arguments %*%C"),e("alwaysCalledWithExactly","expected %n to always be called with exact arguments %*%C"),e("neverCalledWith","expected %n to never be called with arguments %*%C"),e("neverCalledWithMatch","expected %n to never be called with match %*%C"),e("threw","%n did not throw exception%C"),e("alwaysThrew","%n did not always throw exception%C"),h?module.exports=g:a.assert=g)}("object"==typeof sinon&&sinon||null,"undefined"!=typeof window?window:global),sinon}.call("undefined"!=typeof window&&window||{});define("gallery/sinon/1.6.0/sinon",[],function(a,b,c){c.exports=sinon});
  