{"version":3,"sources":["webpack:///./node_modules/@rails/actiontext/app/javascript/actiontext/attachment_upload.js","webpack:///./node_modules/@rails/actiontext/app/javascript/actiontext/index.js"],"names":["_defineProperties","target","props","i","length","descriptor","enumerable","configurable","writable","Object","defineProperty","key","AttachmentUpload","attachment","element","instance","Constructor","TypeError","_classCallCheck","this","directUpload","file","directUploadUrl","protoProps","staticProps","value","create","directUploadDidComplete","bind","xhr","_this","upload","addEventListener","event","progress","loaded","total","setUploadProgress","error","attributes","Error","concat","setAttributes","sgid","attachable_sgid","url","createBlobUrl","signed_id","filename","signedId","blobUrlTemplate","replace","encodeURIComponent","get","dataset","prototype","start"],"mappings":"+GAEA,SAASA,EAAkBC,EAAQC,GAAS,IAAK,IAAIC,EAAI,EAAGA,EAAID,EAAME,OAAQD,IAAK,CAAE,IAAIE,EAAaH,EAAMC,GAAIE,EAAWC,WAAaD,EAAWC,aAAc,EAAOD,EAAWE,cAAe,EAAU,UAAWF,IAAYA,EAAWG,UAAW,GAAMC,OAAOC,eAAeT,EAAQI,EAAWM,IAAKN,IAKtS,IAAI,EAAgC,WACzC,SAASO,EAAiBC,EAAYC,IARxC,SAAyBC,EAAUC,GAAe,KAAMD,aAAoBC,GAAgB,MAAM,IAAIC,UAAU,qCAS5GC,CAAgBC,KAAMP,GAEtBO,KAAKN,WAAaA,EAClBM,KAAKL,QAAUA,EACfK,KAAKC,aAAe,IAAI,eAAaP,EAAWQ,KAAMF,KAAKG,gBAAiBH,MAThF,IAAsBH,EAAaO,EAAYC,EAyD7C,OAzDoBR,EAYPJ,GAZoBW,EAYF,CAAC,CAC9BZ,IAAK,QACLc,MAAO,WACLN,KAAKC,aAAaM,OAAOP,KAAKQ,wBAAwBC,KAAKT,SAE5D,CACDR,IAAK,mCACLc,MAAO,SAA0CI,GAC/C,IAAIC,EAAQX,KAEZU,EAAIE,OAAOC,iBAAiB,YAAY,SAAUC,GAChD,IAAIC,EAAWD,EAAME,OAASF,EAAMG,MAAQ,IAE5CN,EAAMjB,WAAWwB,kBAAkBH,QAGtC,CACDvB,IAAK,0BACLc,MAAO,SAAiCa,EAAOC,GAC7C,GAAID,EACF,MAAM,IAAIE,MAAM,yBAAyBC,OAAOH,IAGlDnB,KAAKN,WAAW6B,cAAc,CAC5BC,KAAMJ,EAAWK,gBACjBC,IAAK1B,KAAK2B,cAAcP,EAAWQ,UAAWR,EAAWS,cAG5D,CACDrC,IAAK,gBACLc,MAAO,SAAuBwB,EAAUD,GACtC,OAAO7B,KAAK+B,gBAAgBC,QAAQ,aAAcF,GAAUE,QAAQ,YAAaC,mBAAmBJ,MAErG,CACDrC,IAAK,kBACL0C,IAAK,WACH,OAAOlC,KAAKL,QAAQwC,QAAQhC,kBAE7B,CACDX,IAAK,kBACL0C,IAAK,WACH,OAAOlC,KAAKL,QAAQwC,QAAQJ,qBArD4ClD,EAAkBgB,EAAYuC,UAAWhC,GAAiBC,GAAaxB,EAAkBgB,EAAaQ,GAAcf,OAAOC,eAAeM,EAAa,YAAa,CAAER,UAAU,IAyDrPI,EAtDkC,GCN3CoB,iBAAiB,uBAAuB,SAAUC,GAChD,IAAIpB,EAAaoB,EAAMpB,WACnBZ,EAASgC,EAAMhC,OAEfY,EAAWQ,MACA,IAAI,EAAiBR,EAAYZ,GACvCuD","file":"js/28-f23eb77310fe0c6e0005.chunk.js","sourcesContent":["function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\n\nimport { DirectUpload } from \"@rails/activestorage\";\nexport var AttachmentUpload = /*#__PURE__*/function () {\n function AttachmentUpload(attachment, element) {\n _classCallCheck(this, AttachmentUpload);\n\n this.attachment = attachment;\n this.element = element;\n this.directUpload = new DirectUpload(attachment.file, this.directUploadUrl, this);\n }\n\n _createClass(AttachmentUpload, [{\n key: \"start\",\n value: function start() {\n this.directUpload.create(this.directUploadDidComplete.bind(this));\n }\n }, {\n key: \"directUploadWillStoreFileWithXHR\",\n value: function directUploadWillStoreFileWithXHR(xhr) {\n var _this = this;\n\n xhr.upload.addEventListener(\"progress\", function (event) {\n var progress = event.loaded / event.total * 100;\n\n _this.attachment.setUploadProgress(progress);\n });\n }\n }, {\n key: \"directUploadDidComplete\",\n value: function directUploadDidComplete(error, attributes) {\n if (error) {\n throw new Error(\"Direct upload failed: \".concat(error));\n }\n\n this.attachment.setAttributes({\n sgid: attributes.attachable_sgid,\n url: this.createBlobUrl(attributes.signed_id, attributes.filename)\n });\n }\n }, {\n key: \"createBlobUrl\",\n value: function createBlobUrl(signedId, filename) {\n return this.blobUrlTemplate.replace(\":signed_id\", signedId).replace(\":filename\", encodeURIComponent(filename));\n }\n }, {\n key: \"directUploadUrl\",\n get: function get() {\n return this.element.dataset.directUploadUrl;\n }\n }, {\n key: \"blobUrlTemplate\",\n get: function get() {\n return this.element.dataset.blobUrlTemplate;\n }\n }]);\n\n return AttachmentUpload;\n}();","import { AttachmentUpload } from \"./attachment_upload\";\naddEventListener(\"trix-attachment-add\", function (event) {\n var attachment = event.attachment,\n target = event.target;\n\n if (attachment.file) {\n var upload = new AttachmentUpload(attachment, target);\n upload.start();\n }\n});"],"sourceRoot":""}