//>>built
define("dojox/store/DynamoDB","dojo/_base/declare dojo/Stateful dojo/request dojo/store/util/QueryResults dojo/store/util/SimpleQueryEngine dojo/_base/lang dojo/_base/array dojo/errors/RequestError dojo/Deferred ../encoding/digests/SHA256 ../encoding/digests/_base require".split(" "),function(H,I,D,J,K,v,p,L,E,z,w,M){function r(b,a,c){c=c||w.outputTypes.String;return z._hmac(a,b,c)}function N(b,a,c){this._signingDate=b;b=r("AWS4"+a,b);c=r(b,c);c=r(c,"dynamodb");return r(c,"aws4_request")}function O(b){function a(g){g=
String(g);return 1===g.length?"0"+g:g}var c=String(b.getUTCFullYear()),d=a(b.getUTCMonth()+1),e=a(b.getUTCDate()),f=a(b.getUTCHours()),h=a(b.getUTCMinutes());b=a(b.getUTCSeconds());return c+d+e+"T"+f+h+b+"Z"}function P(b){if("undefined"!==typeof document){var a=document.createElement("a");a.href=b;return a.hostname}b=M.parse(b);return b.hostname}function F(b){if(null==b)return"NULL";var a=typeof b;return"string"===a?"S":"boolean"===a?"BOOL":"number"===a?"N":b instanceof Array?"L":"M"}function n(b){var a=
F(b),c={};switch(a){case "BOOL":case "S":var d=b;break;case "N":d=String(b);break;case "NULL":d=!0;break;case "M":d={};for(var e in b)d[e]=n(b[e]);break;case "L":d=[];for(e=0;e<b.length;e++)d[e]=n(b[e]);break;default:throw Error("Unknown Dynamo type: "+a);}c[a]=d;return c}function A(b){function a(e){if("N"===d)return Number(e);if("NULL"===d)return null;if("L"===d)return p.map(e,function(g){return A(g)});if("M"===d){var f={},h;for(h in e)f[h]=A(e[h]);return f}return e}for(d in b)var c=b[d];if("S"===
d.charAt(1)){var d=d.charAt(0);return p.map(c,a)}return a(c)}function G(b){var a={},c;for(c in b)a[c]=n(b[c]);return a}function B(b){if(!b)return null;var a={},c;for(c in b)a[c]=A(b[c]);return a}return H(I,{tableName:"",attributesToGet:null,consistentRead:!1,maxRetries:5,idProperty:"id",queryEngine:K,region:null,endpointUrl:null,credentials:null,_signRequest:function(b,a){a=O(a||new Date);var c=a.slice(0,8),d=this.credentials.SecretAccessKey,e=this.credentials.AccessKeyId,f=this.credentials.SessionToken,
h="",g="";b.headers["x-amz-date"]=a;f&&(h="x-amz-security-token:"+f+"\n",g=";x-amz-security-token",b.headers["x-amz-security-token"]=f);f=b.method+"\n/\n\nhost:"+b.host+"\nx-amz-date:"+a+"\n"+h+"x-amz-target:"+b.headers["x-amz-target"]+"\n\nhost;x-amz-date"+g+";x-amz-target\n"+z(b.body,w.outputTypes.Hex);d=N(c,d,this.region);f="AWS4-HMAC-SHA256\n"+a+"\n"+c+"/"+this.region+"/dynamodb/aws4_request\n"+z(f,w.outputTypes.Hex);d=r(d,f,w.outputTypes.Hex);b.headers.authorization="AWS4-HMAC-SHA256 Credential\x3d"+
e+"/"+c+"/"+this.region+"/dynamodb/aws4_request,SignedHeaders\x3dhost;x-amz-date;x-amz-target"+g+",Signature\x3d"+d},_rpc:function(b,a){var c,d,e=new E(function(){d&&d.cancel.apply(D,arguments);clearTimeout(c)}),f={"Content-Type":"application/x-amz-json-1.0","x-amz-target":"DynamoDB_20120810."+b};a.TableName=this.tableName;a=JSON.stringify(a);this.endpointUrl||(this.endpointUrl="https://dynamodb."+this.region+".amazonaws.com");this.credentials&&this._signRequest({body:a,host:P(this.endpointUrl),method:"POST",
headers:f});var h=this.endpointUrl,g=this.maxRetries,q=0;(function k(){d=D.post(h,{data:a,headers:f,handleAs:"json"}).then(v.hitch(e,"resolve"),function(l){var m=l.response;++q===g?e.reject(l):500<=m.status||400>m.status||400===m.status&&m.data&&m.data.__type&&(-1<m.data.__type.indexOf("#ProvisionedThroughputExceededException")||-1<m.data.__type.indexOf("#ThrottlingException"))?c=setTimeout(k,50*Math.pow(2,q)):e.reject(l)})})();return e.promise.then(function(k){return k},function(k){var l=k.response&&
k.response.data;if(l)throw new L(l.__type+": "+l.message,k.response);throw k;})},_getKeyFromId:function(b){var a={};this.idProperty instanceof Array?("string"===typeof b&&(b=p.map(b.split("/"),function(c){var d=c.charAt(0);c=c.slice(1);"N"===d&&(c=+c);return c})),p.forEach(b,function(c,d){a[this.idProperty[d]]=n(c)},this)):a[this.idProperty]=n(b);return a},get:function(b){b={Key:this._getKeyFromId(b),ConsistentRead:this.consistentRead};this.attributesToGet&&(b.AttributesToGet=this.attributesToGet);
return this._rpc("GetItem",b).then(function(a){return B(a.Item)})},getIdentity:function(b){return this.idProperty instanceof Array?p.map(this.idProperty,function(a){return F(b[a])+b[a]}).join("/"):b[this.idProperty]},query:function(b,a){function c(m){var x={},t;for(t in m)x[t]=n(m[t]);return x}a=a||{};var d={KeyConditions:{},ConsistentRead:this.consistentRead};this.attributesToGet&&(d.AttributesToGet=this.attributesToGet);a.indexName&&(d.IndexName=a.indexName);if(a.sort&&a.sort.length){if(1<a.sort.length)throw Error("Cannot sort by more than one dimension");
d.IndexName||(d.IndexName=a.sort[0].attribute);d.ScanIndexForward=!a.sort[0].descending}for(var e in b){var f=b[e];d.KeyConditions[e]={AttributeValueList:f instanceof Array?p.map(f,n):[n(f)],ComparisonOperator:"EQ"}}a.filter&&(e=a.filter,d.FilterExpression=e.FilterExpression,e.ExpressionAttributeValues&&(d.ExpressionAttributeValues=c(e.ExpressionAttributeValues)),e.ExpressionAttributeNames&&(d.ExpressionAttributeNames=e.ExpressionAttributeNames));var h=new E(function(){l&&l.cancel.apply(l,arguments)});
e=J(h.promise);!1!==a.fetchTotal&&(e.total=this._rpc("Query",v.mixin({},d,{Select:"COUNT"})).then(function(m){return m.Count}));var g=this,q=[],u="number"===typeof a.start?a.start:0,k=u+(a.count||0)||Infinity,l;(function t(x){d.Limit=Infinity>k?k:void 0;d.ExclusiveStartKey=x;l=g._rpc("Query",d).then(function(y){if(y.Items.length){var C=p.map(y.Items.slice(u),B);0<u&&(u=Math.max(u-C.length,0));k-=C.length;q=q.concat(C)}0<k&&y.LastEvaluatedKey?t(y.LastEvaluatedKey):h.resolve(q)},v.hitch(h,"reject"))})("object"===
typeof a.start?G(a.start):void 0);return e},remove:function(b,a){a=a||{};var c={Key:this._getKeyFromId(b),ReturnValues:"ALL_OLD"};if(a.expected){c.Expected={};for(var d in a.expected)c.Expected[d]={Value:n(a.expected[d])}}return this._rpc("DeleteItem",c).then(function(e){return B(e.Attributes)})},put:function(b,a){a=a||{};var c={Item:G(b)};a.id&&v.mixin(c.Item,this._getKeyFromId(a.id));if(!1===a.overwrite)c.Expected={},p.forEach(this.idProperty instanceof Array?this.idProperty:[this.idProperty],function(e){c.Expected[e]=
{Exists:!1}});else if(a.expected){c.Expected={};for(var d in a.expected)c.Expected[d]={Value:n(a.expected[d])}}return this._rpc("PutItem",c).then(function(){})},add:function(b,a){a=a||{};a.overwrite=!1;return this.put(b,a)}})});