{"version":3,"sources":["estore/stock/supplier-order-info.ts"],"names":["ExtendedApiError","SupplierOrderInfo","HTMLElement","constructor","productId","super","this","markup","lines","length","map","l","join","attachShadow","mode","getProductIdAttr","productIdAttr","getAttribute","parseInt","update","await","load","attributeChangedCallback","newProductId","connectedCallback","dataResponse","fetch","json","hasError","render","result","shadowRoot","innerHTML","customElements","define"],"mappings":"OAASA,gBAAmF,KAA3D,kEAGpBC,0BAA0BC,YAMnCC,YAAYC,GACRC,MAAK,EAJTC,KAAAC,OAAS,GAAoBC,GAASA,EAAMC,0DACWD,EAAME,IAAIC,UAAYA,QAAQ,EAAEC,KAAK,EAAE,SAAW,KAIrGN,KAAKF,UAAYA,EACjBE,KAAKO,aAAa,CAACC,KAAM,MAAM,CAAC,CACpC,CAEAC,mBACI,IAAMC,EAAgBV,KAAKW,aAAa,YAAY,EACpD,OAAID,GAAiBA,EAAcP,OACxBS,SAASF,CAAa,EAG1B,IACX,CAEAG,aAAaf,GACTE,KAAKF,UAAYA,EACjBgB,MAAMd,KAAKe,KAAI,CACnB,CAEAC,iCACI,IAAMC,EAAejB,KAAKS,iBAAgB,EAEtCQ,GACAH,MAAMd,KAAKa,OAAOI,CAAY,CAEtC,CAEAC,0BACSlB,KAAKF,YACNE,KAAKF,UAAYE,KAAKS,iBAAgB,GAG1CK,MAAMd,KAAKe,KAAI,CACnB,CAEAA,aACI,GAAIf,KAAKF,UAAW,CAChB,IAEMqB,EAAeL,MAFJA,MAAMM,2BAA2BpB,KAAKF,+BAA+B,GAElDuB,KAAI,EAExC,GAAI,CAACF,GAAgBA,EAAaG,SAC9B,MAAM,IAAI5B,iBAAiByB,CAAY,EAG3CnB,KAAKuB,OAAOJ,EAAaK,MAAM,C,CAEvC,CAEAD,OAAOrB,GACHF,KAAKyB,WAAWC,UAAY1B,KAAKC,OAAOC,CAAK,CACjD,C,CAGJyB,eAAeC,OAAO,sBAAuBjC,iBAAiB,SA7DjDA,iBA6DkD","file":"supplier-order-info.js","sourcesContent":["import { ExtendedApiError } from \"../../../components-shared/api/base/extended-api-error.js\";\r\nimport { IExtendedApiResponse } from \"../../../components-shared/api/base/i-extended-api-response.js\";\r\n\r\nexport class SupplierOrderInfo extends HTMLElement {\r\n productId: number;\r\n\r\n markup = (lines:string[]) => lines && lines.length ? \r\n `` : null;\r\n\r\n constructor(productId: number) {\r\n super();\r\n this.productId = productId;\r\n this.attachShadow({mode: \"open\"});\r\n }\r\n\r\n getProductIdAttr(): number {\r\n const productIdAttr = this.getAttribute(\"product-id\");\r\n if (productIdAttr && productIdAttr.length) {\r\n return parseInt(productIdAttr);\r\n }\r\n\r\n return null;\r\n }\r\n\r\n async update(productId: number) {\r\n this.productId = productId;\r\n await this.load();\r\n }\r\n\r\n async attributeChangedCallback() {\r\n const newProductId = this.getProductIdAttr();\r\n\r\n if (newProductId) {\r\n await this.update(newProductId);\r\n }\r\n }\r\n\r\n async connectedCallback() {\r\n if (!this.productId) {\r\n this.productId = this.getProductIdAttr();\r\n }\r\n\r\n await this.load();\r\n }\r\n\r\n async load(): Promise {\r\n if (this.productId) {\r\n const response = await fetch(`/api/estore/stock/${this.productId}/supplier-order-info`);\r\n\r\n const dataResponse = await response.json() as IExtendedApiResponse;\r\n\r\n if (!dataResponse || dataResponse.hasError) {\r\n throw new ExtendedApiError(dataResponse);\r\n }\r\n\r\n this.render(dataResponse.result);\r\n }\r\n }\r\n\r\n render(lines: string[]) {\r\n this.shadowRoot.innerHTML = this.markup(lines);\r\n }\r\n}\r\n\r\ncustomElements.define(\"supplier-order-info\", SupplierOrderInfo);"]}