var __awaiter=this&&this.__awaiter||function(t,e,n,r){function i(t){return t instanceof n?t:new n((function(e){e(t)}))}return new(n||(n=Promise))((function(n,o){function c(t){try{s(r.next(t))}catch(t){o(t)}}function a(t){try{s(r["throw"](t))}catch(t){o(t)}}function s(t){t.done?n(t.value):i(t.value).then(c,a)}s((r=r.apply(t,e||[])).next())}))};var __generator=this&&this.__generator||function(t,e){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,c;return c={next:a(0),throw:a(1),return:a(2)},typeof Symbol==="function"&&(c[Symbol.iterator]=function(){return this}),c;function a(t){return function(e){return s([t,e])}}function s(c){if(r)throw new TypeError("Generator is already executing.");while(n)try{if(r=1,i&&(o=c[0]&2?i["return"]:c[0]?i["throw"]||((o=i["return"])&&o.call(i),0):i.next)&&!(o=o.call(i,c[1])).done)return o;if(i=0,o)c=[c[0]&2,o.value];switch(c[0]){case 0:case 1:o=c;break;case 4:n.label++;return{value:c[1],done:false};case 5:n.label++;i=c[1];c=[0];continue;case 7:c=n.ops.pop();n.trys.pop();continue;default:if(!(o=n.trys,o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){n=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){n.label=c[1];break}if(c[0]===6&&n.label<o[1]){n.label=o[1];o=c;break}if(o&&n.label<o[2]){n.label=o[2];n.ops.push(c);break}if(o[2])n.ops.pop();n.trys.pop();continue}c=e.call(t,n)}catch(t){c=[6,t];i=0}finally{r=o=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:true}}};import{I as Identifier}from"./Token-ba2c5d5c.js";import{M as Merchant$1}from"./index-c2c33860.js";import{a as Connection}from"./Item-f4cbd6f4.js";import"./ok-c9833bf3.js";import"./index-714bb39b.js";import"./index-063af7ee.js";import"./TextDecoder-357ac2ce.js";import"./_commonjsHelpers-9943807e.js";import"./index-1f953d81.js";var Merchant=function(){function t(t){this.connection=t}t.prototype.create=function(t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){switch(e.label){case 0:return[4,this.connection.post("merchant",t)];case 1:return[2,e.sent()]}}))}))};t.prototype.list=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){return[2,this.connection.get("merchant")]}))}))};t.prototype.change=function(t,e){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(n){switch(n.label){case 0:return[4,this.connection.patch("merchant/"+(Identifier.is(e)?e:""),t)];case 1:return[2,n.sent()]}}))}))};t.prototype.load=function(t){return __awaiter(this,void 0,void 0,(function(){var e,n;var r=this;return __generator(this,(function(i){switch(i.label){case 0:if(!!t)return[3,2];return[4,this.connection.get("merchant")];case 1:e=i.sent();return[3,7];case 2:if(!Identifier.is(t))return[3,4];return[4,this.connection.get("merchant/"+t)];case 3:n=i.sent();return[3,6];case 4:return[4,Promise.all(t.map((function(t){return r.connection.get("merchant/"+t)})))];case 5:n=i.sent().filter(Merchant$1.is);i.label=6;case 6:e=n;i.label=7;case 7:return[2,e]}}))}))};t.open=function(e,n){var r=Connection.open(e,n);return r&&new t(r)};return t}();export{Merchant};