@instincthub/react-ui 0.3.3 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +3 -11
  2. package/dist/src/components/forms/uploads/FileUploader.cjs +1 -1
  3. package/dist/src/components/forms/uploads/FileUploader.js +1 -1
  4. package/dist/src/components/forms/uploads/IhubFileUploader.cjs +1 -1
  5. package/dist/src/components/forms/uploads/IhubFileUploader.js +1 -1
  6. package/dist/src/components/forms/uploads/S3MultiUploader.cjs +1 -1
  7. package/dist/src/components/forms/uploads/S3MultiUploader.js +1 -1
  8. package/dist/src/components/forms/uploads/presignedPut.cjs +2 -0
  9. package/dist/src/components/forms/uploads/presignedPut.cjs.map +1 -0
  10. package/dist/src/components/forms/uploads/presignedPut.js +2 -0
  11. package/dist/src/components/forms/uploads/presignedPut.js.map +1 -0
  12. package/dist/src/components/lib/index.cjs +1 -1
  13. package/dist/src/components/lib/index.cjs.map +1 -1
  14. package/dist/src/components/lib/index.js +1 -1
  15. package/dist/src/components/lib/index.js.map +1 -1
  16. package/dist/src/components/lib/paystack.cjs +1 -1
  17. package/dist/src/components/lib/paystack.cjs.map +1 -1
  18. package/dist/src/components/lib/paystack.js +1 -1
  19. package/dist/src/components/lib/paystack.js.map +1 -1
  20. package/dist/src/components/ui/ComponentLists.cjs +1 -1
  21. package/dist/src/components/ui/ComponentLists.js +1 -1
  22. package/dist/src/components/ui/editor/ihub-editor/types.cjs.map +1 -1
  23. package/dist/src/components/ui/editor/ihub-editor/types.js.map +1 -1
  24. package/dist/src/components/ui/editor/ihub-editor/upload/uploadFile.cjs +1 -1
  25. package/dist/src/components/ui/editor/ihub-editor/upload/uploadFile.cjs.map +1 -1
  26. package/dist/src/components/ui/editor/ihub-editor/upload/uploadFile.js +1 -1
  27. package/dist/src/components/ui/editor/ihub-editor/upload/uploadFile.js.map +1 -1
  28. package/dist/src/types/components/forms/uploads/FileUploader.d.ts +9 -2
  29. package/dist/src/types/components/forms/uploads/IhubFileUploader.d.ts +6 -3
  30. package/dist/src/types/components/forms/uploads/presignedPut.d.ts +13 -0
  31. package/dist/src/types/components/lib/paystack.d.ts +48 -12
  32. package/dist/src/types/components/ui/editor/ihub-editor/types.d.ts +3 -10
  33. package/dist/src/types/types/index.d.ts +39 -4
  34. package/dist/tsconfig.build.tsbuildinfo +1 -1
  35. package/package.json +1 -3
  36. package/dist/src/components/forms/uploads/uploadedFileUrl.cjs +0 -2
  37. package/dist/src/components/forms/uploads/uploadedFileUrl.cjs.map +0 -1
  38. package/dist/src/components/forms/uploads/uploadedFileUrl.js +0 -2
  39. package/dist/src/components/forms/uploads/uploadedFileUrl.js.map +0 -1
  40. package/dist/src/components/ui/editor/ihub-editor/upload/s3Direct.cjs +0 -2
  41. package/dist/src/components/ui/editor/ihub-editor/upload/s3Direct.cjs.map +0 -1
  42. package/dist/src/components/ui/editor/ihub-editor/upload/s3Direct.js +0 -2
  43. package/dist/src/components/ui/editor/ihub-editor/upload/s3Direct.js.map +0 -1
  44. package/dist/src/types/components/ui/editor/ihub-editor/upload/s3Direct.d.ts +0 -5
package/README.md CHANGED
@@ -41,18 +41,18 @@ To use the `@instincthub/react-ui` package, another project needs to install the
41
41
  `@instincthub/react-ui` has several peer dependencies that need to be installed separately:
42
42
 
43
43
  ```sh
44
- npm install @aws-sdk/client-s3@^3.777.0 @aws-sdk/lib-storage@^3.777.0 @emotion/react@^11.14.0 @emotion/styled@^11.14.0 @mui/icons-material@^7.0.0 @mui/material@^7.0.0 @reduxjs/toolkit@^2.6.1 @types/redux-logger@^3.0.13 jspdf@^3.0.1 next@^15.2.1 next-auth@beta primereact@^10.9.3 react@^19.0.0 react-dom@^19.0.0 react-redux@^9.2.0 redux-logger@^3.0.6 react-syntax-highlighter@^15.6.1 styled-components@^6.1.16
44
+ npm install @emotion/react@^11.14.0 @emotion/styled@^11.14.0 @mui/icons-material@^7.0.0 @mui/material@^7.0.0 @reduxjs/toolkit@^2.6.1 @types/redux-logger@^3.0.13 jspdf@^3.0.1 next@^15.2.1 next-auth@beta primereact@^10.9.3 react@^19.0.0 react-dom@^19.0.0 react-redux@^9.2.0 redux-logger@^3.0.6 react-syntax-highlighter@^15.6.1 styled-components@^6.1.16
45
45
  ```
46
46
 
47
47
  Or using yarn:
48
48
 
49
49
  ```sh
50
- yarn add @aws-sdk/client-s3@^3.777.0 @aws-sdk/lib-storage@^3.777.0 @emotion/react@^11.14.0 @emotion/styled@^11.14.0 @mui/icons-material@^7.0.0 @mui/material@^7.0.0 @reduxjs/toolkit@^2.6.1 @types/redux-logger@^3.0.13 jspdf@^3.0.1 next@^15.2.1 next-auth@beta primereact@^10.9.3 react@^19.0.0 react-dom@^19.0.0 react-redux@^9.2.0 redux-logger@^3.0.6 react-syntax-highlighter@^15.6.1 styled-components@^6.1.16```
50
+ yarn add @emotion/react@^11.14.0 @emotion/styled@^11.14.0 @mui/icons-material@^7.0.0 @mui/material@^7.0.0 @reduxjs/toolkit@^2.6.1 @types/redux-logger@^3.0.13 jspdf@^3.0.1 next@^15.2.1 next-auth@beta primereact@^10.9.3 react@^19.0.0 react-dom@^19.0.0 react-redux@^9.2.0 redux-logger@^3.0.6 react-syntax-highlighter@^15.6.1 styled-components@^6.1.16```
51
51
 
52
52
  Or using pnmpm:
53
53
 
54
54
  ```sh
55
- pnpm add @aws-sdk/client-s3@^3.777.0 @aws-sdk/lib-storage@^3.777.0 @emotion/react@^11.14.0 @emotion/styled@^11.14.0 @mui/icons-material@^7.0.0 @mui/material@^7.0.0 @reduxjs/toolkit@^2.6.1 @types/redux-logger@^3.0.13 jspdf@^3.0.1 next@^15.2.1 next-auth@beta primereact@^10.9.3 react@^19.0.0 react-dom@^19.0.0 react-redux@^9.2.0 redux-logger@^3.0.6 react-syntax-highlighter@^15.6.1 styled-components@^6.1.16```
55
+ pnpm add @emotion/react@^11.14.0 @emotion/styled@^11.14.0 @mui/icons-material@^7.0.0 @mui/material@^7.0.0 @reduxjs/toolkit@^2.6.1 @types/redux-logger@^3.0.13 jspdf@^3.0.1 next@^15.2.1 next-auth@beta primereact@^10.9.3 react@^19.0.0 react-dom@^19.0.0 react-redux@^9.2.0 redux-logger@^3.0.6 react-syntax-highlighter@^15.6.1 styled-components@^6.1.16```
56
56
 
57
57
  ### Step 2: Install the Package
58
58
 
@@ -324,14 +324,6 @@ Uploads can come from `onFileUpload`, the `upload` prop, or these environment va
324
324
  |----------|----------|-------------|---------|
325
325
  | `NEXT_PUBLIC_IHUB_EDITOR_PRESIGN_URL` | No | Presign endpoint: receives `POST { filename, content_type, size, kind }`, returns `{ url, cdnUrl }` (recommended) | `https://api.example.com/uploads/presign/` |
326
326
  | `NEXT_PUBLIC_IHUB_EDITOR_UPLOAD_URL` | No | Multipart upload endpoint; JSON response must include `url`, `file`, `location` or `cdnUrl` | `https://api.example.com/uploads/` |
327
- | `NEXT_PUBLIC_IHUB_EDITOR_DIRECT_S3` | No | `true` to allow direct browser → S3 uploads with the AWS keys below (off by default; the secret key ships to the browser) | `true` |
328
- | `NEXT_PUBLIC_AWS_BUCKET_NAME` | For direct S3 | Bucket for direct uploads (shared with `FileUploader`) | `instincthub-media` |
329
- | `NEXT_PUBLIC_AWS_ACCESS_KEY_ID` | For direct S3 | Access key; scope it to `PutObject` on one prefix | — |
330
- | `NEXT_PUBLIC_AWS_SECRET_ACCESS_KEY` | For direct S3 | Secret key (exposed to the browser) | — |
331
- | `NEXT_PUBLIC_AWS_REGION` | For direct S3 | Bucket region | `eu-west-2` |
332
- | `NEXT_PUBLIC_AWS_S3_ENDPOINT_URL` | No | Custom S3-compatible endpoint | `https://s3.example.com` |
333
- | `NEXT_PUBLIC_IHUB_EDITOR_S3_FOLDER` | No | Key prefix for direct uploads (default `editor`) | `editor` |
334
- | `NEXT_PUBLIC_IHUB_EDITOR_FILE_URL` | No | Public base URL for uploaded files (falls back to `NEXT_PUBLIC_FILE_URL`, then the bucket URL) | `https://cdn.example.com/` |
335
327
  <!-- END AUTO-GENERATED -->
336
328
 
337
329
  Block, table and media styles are in `src/assets/css/ui/ihub-text-editor-blocks.css`, which is included by `ui-index.css`. Full reference: [docs/static-docs/components/IHubTextEditor.md](docs/static-docs/components/IHubTextEditor.md).
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_rollupPluginBabelHelpers.cjs"),r=require("react/jsx-runtime"),n=require("react"),t=require("primereact/fileupload"),a=require("../../lib/helpFunction.cjs"),s=require("./uploadedFileUrl.cjs"),o=require("@aws-sdk/client-s3"),c=require("../../lib/modals/modals.cjs");function i(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach(function(n){if("default"!==n){var t=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,t.get?t:{enumerable:!0,get:function(){return e[n]}})}}),r.default=e,Object.freeze(r)}exports.default=function(l){var u=n.useState([]),d=e.slicedToArray(u,2),p=d[0],f=d[1],m=n.useState(null),y=e.slicedToArray(m,2),v=y[0],h=y[1],_=n.useState(l.placeholder||l.labels||"Drag and drop files here to upload."),g=e.slicedToArray(_,2),b=g[0],S=g[1],T=n.useState(0),x=e.slicedToArray(T,2),E=x[0],U=x[1],j=function(){var r=e.asyncToGenerator(e.regenerator().m(function r(n){var t;return e.regenerator().w(function(e){for(;;)switch(e.n){case 0:t=n.files,f(t),h(t[0]),U(0),l.onFilesSelected&&l.onFilesSelected(t);case 1:return e.a(2)}},r)}));return function(e){return r.apply(this,arguments)}}(),C=function(){var r=e.asyncToGenerator(e.regenerator().m(function r(){var n,t,u,d,f,m,y,h,_,g,b,S,T,x,E,j,C,N,I,A,k,w;return e.regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:if(0!==(n=p.length>0?p:v?[v]:[]).length){e.n=1;break}return e.a(2);case 1:if(!l.onUpload){e.n=5;break}return e.p=2,e.n=3,l.onUpload(n);case 3:return e.a(2);case 4:return e.p=4,k=e.v,console.error("Upload callback error:",k),c.openToast("Error uploading file!",400),e.a(2);case 5:return t=n[0],e.p=6,d=new o.S3Client({region:process.env.NEXT_PUBLIC_AWS_REGION,endpoint:process.env.NEXT_PUBLIC_AWS_S3_ENDPOINT_URL,credentials:{accessKeyId:process.env.NEXT_PUBLIC_AWS_ACCESS_KEY_ID||"",secretAccessKey:process.env.NEXT_PUBLIC_AWS_SECRET_ACCESS_KEY||""}}),f=(new Date).toISOString(),m=a.slugifyFileName("".concat(l.username||"anonymous","-").concat(f,"-").concat(t.name)),y=a.IN_DEV_MODE?"test-env__".concat(m):m,h=l.accepts||null!==(u=l.acceptedFileTypes)&&void 0!==u&&u.includes("video/*")?process.env.NEXT_PUBLIC_AWS_LOCATION:process.env.NEXT_PUBLIC_AWS_LOCATION_FILES,_=process.env.NEXT_PUBLIC_AWS_BUCKET_NAME||"",g="".concat(h,"/").concat(y),e.n=7,t.arrayBuffer();case 7:if(b=e.v,S=new Uint8Array(b),!(t.size<104857600)){e.n=10;break}return e.n=8,Promise.resolve().then(function(){return i(require("@aws-sdk/client-s3"))});case 8:return T=e.v,x=T.PutObjectCommand,U(10),E=new x({Bucket:_,Key:g,Body:S,ContentType:t.type,ACL:"public-read"}),j=setInterval(function(){U(function(e){return Math.min(e+5,95)})},300),e.n=9,d.send(E);case 9:clearInterval(j),U(100),e.n=12;break;case 10:return e.n=11,Promise.resolve().then(function(){return i(require("@aws-sdk/lib-storage"))});case 11:return C=e.v,N=C.Upload,(I=new N({client:d,params:{Bucket:_,Key:g,Body:S,ContentType:t.type,ACL:"public-read"}})).on("httpUploadProgress",function(e){var r=Math.round(e.loaded/e.total*100);U(r)}),e.n=12,I.done();case 12:c.openToast("File Uploaded Successfully!"),A={bucket:_,title:t.name,key:y,content_type:t.type,size:t.size,location:s.uploadedFileUrl(g,a.FILE_URL,process.env.NEXT_PUBLIC_AWS_LOCATION_FILES)},l.setResponse&&l.setResponse(A),l.setValues&&l.setValues(l.names||"",A.key),l.setModules&&l.setModules(l.module||"",l.names||"",A.key),l.setSteps&&l.setSteps(l.module||"",l.step||"",l.names||"",A.key),e.n=14;break;case 13:e.p=13,w=e.v,console.error("Upload error:",w),c.openToast("Error uploading file!",400),U(0);case 14:return e.a(2)}},r,null,[[6,13],[2,4]])}));return function(){return r.apply(this,arguments)}}(),N=function(e){var n=e.percentage;return r.jsx("div",{className:"ihub-progress",style:{width:"100%",height:"8px",background:"var(--Gray, #e5e7eb)",borderRadius:"4px",overflow:"hidden",margin:"8px 0"},children:r.jsx("div",{className:"ihub-progress-bar",style:{width:"".concat(n,"%"),height:"100%",background:"var(--DarkCyan, #00838f)",borderRadius:"4px",transition:"width 0.3s ease",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"10px",color:"#fff",fontWeight:600,minWidth:n>10?"auto":0},children:n>10?"".concat(n,"%"):""})})};return r.jsxs("div",{className:"ihub-uploader card primereact ".concat(l.className||""),children:[l.headers&&r.jsx("h3",{children:l.headers}),r.jsx(t.FileUpload,{name:"upload",customUpload:!0,accept:l.acceptedFileTypes&&l.acceptedFileTypes.length>0?l.acceptedFileTypes.join(","):l.accepts||"*",maxFileSize:l.maxFileSize||0,multiple:!l.maxFiles||l.maxFiles>1,onSelect:j,uploadHandler:C,emptyTemplate:r.jsx("p",{className:"m-0",children:b}),onError:function(){return S("Upload failed, try again!")},progressBarTemplate:!1!==l.showProgress?function(){return r.jsxs("div",{children:[r.jsx(N,{percentage:E}),r.jsxs("p",{style:{fontSize:"12px",color:"var(--Rhythm, #69779b)",margin:"4px 0 0"},children:["Uploading… ",E,"%"]})]})}:void 0,itemTemplate:E&&!1!==l.showProgress?function(e){var n,t=(null==e?void 0:e.name)||(null==e||null===(n=e.objectURL)||void 0===n?void 0:n.split("/").pop())||"File";return r.jsx("div",{style:{fontSize:"12px",color:"var(--Rhythm, #69779b)",padding:"4px 0"},children:t})}:void 0,disabled:l.isUploading,pt:{content:{className:"surface-ground"},message:{root:{className:"w-1rem"}}}})]})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_rollupPluginBabelHelpers.cjs"),r=require("react/jsx-runtime"),a=require("react"),n=require("primereact/fileupload"),t=require("../../lib/modals/modals.cjs"),s=require("./presignedPut.cjs");exports.default=function(o){var l=a.useState([]),i=e.slicedToArray(l,2),c=i[0],d=i[1],p=a.useState(null),u=e.slicedToArray(p,2),m=u[0],f=u[1],g=a.useState(o.placeholder||o.labels||"Drag and drop files here to upload."),h=e.slicedToArray(g,2),y=h[0],v=h[1],x=a.useState(0),b=e.slicedToArray(x,2),j=b[0],T=b[1],U=function(){var r=e.asyncToGenerator(e.regenerator().m(function r(a){var n;return e.regenerator().w(function(e){for(;;)switch(e.n){case 0:n=a.files,d(n),f(n[0]),T(0),o.onFilesSelected&&o.onFilesSelected(n);case 1:return e.a(2)}},r)}));return function(e){return r.apply(this,arguments)}}(),S=function(){var r=e.asyncToGenerator(e.regenerator().m(function r(){var a,n,l,i,d,p;return e.regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:if(0!==(a=c.length>0?c:m?[m]:[]).length){e.n=1;break}return e.a(2);case 1:if(!o.onUpload){e.n=5;break}return e.p=2,e.n=3,o.onUpload(a);case 3:return e.a(2);case 4:return e.p=4,d=e.v,console.error("Upload callback error:",d),t.openToast("Error uploading file!",400),e.a(2);case 5:if(o.getPresignedUrl){e.n=6;break}return console.error(s.UPLOADS_NOT_CONFIGURED),t.openToast("Uploads are not configured.",400),e.a(2);case 6:return n=a[0],e.p=7,e.n=8,s.presignAndUpload(n,o.getPresignedUrl,T);case 8:l=e.v,T(100),t.openToast("File Uploaded Successfully!"),i={title:n.name,key:l.key,content_type:l.contentType,size:n.size,location:l.cdnUrl},o.setResponse&&o.setResponse(i),o.setValues&&o.setValues(o.names||"",i.key),o.setModules&&o.setModules(o.module||"",o.names||"",i.key),o.setSteps&&o.setSteps(o.module||"",o.step||"",o.names||"",i.key),e.n=10;break;case 9:e.p=9,p=e.v,console.error("Upload error:",p),t.openToast("Error uploading file!",400),T(0);case 10:return e.a(2)}},r,null,[[7,9],[2,4]])}));return function(){return r.apply(this,arguments)}}(),k=function(e){var a=e.percentage;return r.jsx("div",{className:"ihub-progress",style:{width:"100%",height:"8px",background:"var(--Gray, #e5e7eb)",borderRadius:"4px",overflow:"hidden",margin:"8px 0"},children:r.jsx("div",{className:"ihub-progress-bar",style:{width:"".concat(a,"%"),height:"100%",background:"var(--DarkCyan, #00838f)",borderRadius:"4px",transition:"width 0.3s ease",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"10px",color:"#fff",fontWeight:600,minWidth:a>10?"auto":0},children:a>10?"".concat(a,"%"):""})})};return r.jsxs("div",{className:"ihub-uploader card primereact ".concat(o.className||""),children:[o.headers&&r.jsx("h3",{children:o.headers}),r.jsx(n.FileUpload,{name:"upload",customUpload:!0,accept:o.acceptedFileTypes&&o.acceptedFileTypes.length>0?o.acceptedFileTypes.join(","):o.accepts||"*",maxFileSize:o.maxFileSize||0,multiple:!o.maxFiles||o.maxFiles>1,onSelect:U,uploadHandler:S,emptyTemplate:r.jsx("p",{className:"m-0",children:y}),onError:function(){return v("Upload failed, try again!")},progressBarTemplate:!1!==o.showProgress?function(){return r.jsxs("div",{children:[r.jsx(k,{percentage:j}),r.jsxs("p",{style:{fontSize:"12px",color:"var(--Rhythm, #69779b)",margin:"4px 0 0"},children:["Uploading… ",j,"%"]})]})}:void 0,itemTemplate:j&&!1!==o.showProgress?function(e){var a,n=(null==e?void 0:e.name)||(null==e||null===(a=e.objectURL)||void 0===a?void 0:a.split("/").pop())||"File";return r.jsx("div",{style:{fontSize:"12px",color:"var(--Rhythm, #69779b)",padding:"4px 0"},children:n})}:void 0,disabled:o.isUploading,pt:{content:{className:"surface-ground"},message:{root:{className:"w-1rem"}}}})]})};
2
2
  //# sourceMappingURL=FileUploader.cjs.map
@@ -1,2 +1,2 @@
1
- import{slicedToArray as e,asyncToGenerator as r,regenerator as n}from"../../../../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as a,jsx as t}from"react/jsx-runtime";import{useState as o}from"react";import{FileUpload as s}from"primereact/fileupload";import{FILE_URL as c,slugifyFileName as i,IN_DEV_MODE as l}from"../../lib/helpFunction.js";import{uploadedFileUrl as p}from"./uploadedFileUrl.js";import{S3Client as d}from"@aws-sdk/client-s3";import{openToast as u}from"../../lib/modals/modals.js";var m=function(m){var f=o([]),h=e(f,2),v=h[0],y=h[1],_=o(null),g=e(_,2),S=g[0],b=g[1],T=o(m.placeholder||m.labels||"Drag and drop files here to upload."),C=e(T,2),U=C[0],E=C[1],N=o(0),I=e(N,2),k=I[0],w=I[1],A=function(){var e=r(n().m(function e(r){var a;return n().w(function(e){for(;;)switch(e.n){case 0:a=r.files,y(a),b(a[0]),w(0),m.onFilesSelected&&m.onFilesSelected(a);case 1:return e.a(2)}},e)}));return function(r){return e.apply(this,arguments)}}(),L=function(){var e=r(n().m(function e(){var r,a,t,o,s,f,h,y,_,g,b,T,C,U,E,N,I,k,A,L,x,B;return n().w(function(e){for(;;)switch(e.p=e.n){case 0:if(0!==(r=v.length>0?v:S?[S]:[]).length){e.n=1;break}return e.a(2);case 1:if(!m.onUpload){e.n=5;break}return e.p=2,e.n=3,m.onUpload(r);case 3:return e.a(2);case 4:return e.p=4,x=e.v,console.error("Upload callback error:",x),u("Error uploading file!",400),e.a(2);case 5:return a=r[0],e.p=6,o=new d({region:process.env.NEXT_PUBLIC_AWS_REGION,endpoint:process.env.NEXT_PUBLIC_AWS_S3_ENDPOINT_URL,credentials:{accessKeyId:process.env.NEXT_PUBLIC_AWS_ACCESS_KEY_ID||"",secretAccessKey:process.env.NEXT_PUBLIC_AWS_SECRET_ACCESS_KEY||""}}),s=(new Date).toISOString(),f=i("".concat(m.username||"anonymous","-").concat(s,"-").concat(a.name)),h=l?"test-env__".concat(f):f,y=m.accepts||null!==(t=m.acceptedFileTypes)&&void 0!==t&&t.includes("video/*")?process.env.NEXT_PUBLIC_AWS_LOCATION:process.env.NEXT_PUBLIC_AWS_LOCATION_FILES,_=process.env.NEXT_PUBLIC_AWS_BUCKET_NAME||"",g="".concat(y,"/").concat(h),e.n=7,a.arrayBuffer();case 7:if(b=e.v,T=new Uint8Array(b),!(a.size<104857600)){e.n=10;break}return e.n=8,import("@aws-sdk/client-s3");case 8:return C=e.v,U=C.PutObjectCommand,w(10),E=new U({Bucket:_,Key:g,Body:T,ContentType:a.type,ACL:"public-read"}),N=setInterval(function(){w(function(e){return Math.min(e+5,95)})},300),e.n=9,o.send(E);case 9:clearInterval(N),w(100),e.n=12;break;case 10:return e.n=11,import("@aws-sdk/lib-storage");case 11:return I=e.v,k=I.Upload,(A=new k({client:o,params:{Bucket:_,Key:g,Body:T,ContentType:a.type,ACL:"public-read"}})).on("httpUploadProgress",function(e){var r=Math.round(e.loaded/e.total*100);w(r)}),e.n=12,A.done();case 12:u("File Uploaded Successfully!"),L={bucket:_,title:a.name,key:h,content_type:a.type,size:a.size,location:p(g,c,process.env.NEXT_PUBLIC_AWS_LOCATION_FILES)},m.setResponse&&m.setResponse(L),m.setValues&&m.setValues(m.names||"",L.key),m.setModules&&m.setModules(m.module||"",m.names||"",L.key),m.setSteps&&m.setSteps(m.module||"",m.step||"",m.names||"",L.key),e.n=14;break;case 13:e.p=13,B=e.v,console.error("Upload error:",B),u("Error uploading file!",400),w(0);case 14:return e.a(2)}},e,null,[[6,13],[2,4]])}));return function(){return e.apply(this,arguments)}}(),x=function(e){var r=e.percentage;return t("div",{className:"ihub-progress",style:{width:"100%",height:"8px",background:"var(--Gray, #e5e7eb)",borderRadius:"4px",overflow:"hidden",margin:"8px 0"},children:t("div",{className:"ihub-progress-bar",style:{width:"".concat(r,"%"),height:"100%",background:"var(--DarkCyan, #00838f)",borderRadius:"4px",transition:"width 0.3s ease",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"10px",color:"#fff",fontWeight:600,minWidth:r>10?"auto":0},children:r>10?"".concat(r,"%"):""})})};return a("div",{className:"ihub-uploader card primereact ".concat(m.className||""),children:[m.headers&&t("h3",{children:m.headers}),t(s,{name:"upload",customUpload:!0,accept:m.acceptedFileTypes&&m.acceptedFileTypes.length>0?m.acceptedFileTypes.join(","):m.accepts||"*",maxFileSize:m.maxFileSize||0,multiple:!m.maxFiles||m.maxFiles>1,onSelect:A,uploadHandler:L,emptyTemplate:t("p",{className:"m-0",children:U}),onError:function(){return E("Upload failed, try again!")},progressBarTemplate:!1!==m.showProgress?function(){return a("div",{children:[t(x,{percentage:k}),a("p",{style:{fontSize:"12px",color:"var(--Rhythm, #69779b)",margin:"4px 0 0"},children:["Uploading… ",k,"%"]})]})}:void 0,itemTemplate:k&&!1!==m.showProgress?function(e){var r,n=(null==e?void 0:e.name)||(null==e||null===(r=e.objectURL)||void 0===r?void 0:r.split("/").pop())||"File";return t("div",{style:{fontSize:"12px",color:"var(--Rhythm, #69779b)",padding:"4px 0"},children:n})}:void 0,disabled:m.isUploading,pt:{content:{className:"surface-ground"},message:{root:{className:"w-1rem"}}}})]})};export{m as default};
1
+ import{slicedToArray as e,asyncToGenerator as r,regenerator as a}from"../../../../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as n,jsx as t}from"react/jsx-runtime";import{useState as o}from"react";import{FileUpload as l}from"primereact/fileupload";import{openToast as s}from"../../lib/modals/modals.js";import{presignAndUpload as i,UPLOADS_NOT_CONFIGURED as c}from"./presignedPut.js";var p=function(p){var d=o([]),u=e(d,2),m=u[0],f=u[1],h=o(null),g=e(h,2),v=g[0],y=g[1],b=o(p.placeholder||p.labels||"Drag and drop files here to upload."),x=e(b,2),U=x[0],k=x[1],w=o(0),F=e(w,2),S=F[0],T=F[1],j=function(){var e=r(a().m(function e(r){var n;return a().w(function(e){for(;;)switch(e.n){case 0:n=r.files,f(n),y(n[0]),T(0),p.onFilesSelected&&p.onFilesSelected(n);case 1:return e.a(2)}},e)}));return function(r){return e.apply(this,arguments)}}(),z=function(){var e=r(a().m(function e(){var r,n,t,o,l,d;return a().w(function(e){for(;;)switch(e.p=e.n){case 0:if(0!==(r=m.length>0?m:v?[v]:[]).length){e.n=1;break}return e.a(2);case 1:if(!p.onUpload){e.n=5;break}return e.p=2,e.n=3,p.onUpload(r);case 3:return e.a(2);case 4:return e.p=4,l=e.v,console.error("Upload callback error:",l),s("Error uploading file!",400),e.a(2);case 5:if(p.getPresignedUrl){e.n=6;break}return console.error(c),s("Uploads are not configured.",400),e.a(2);case 6:return n=r[0],e.p=7,e.n=8,i(n,p.getPresignedUrl,T);case 8:t=e.v,T(100),s("File Uploaded Successfully!"),o={title:n.name,key:t.key,content_type:t.contentType,size:n.size,location:t.cdnUrl},p.setResponse&&p.setResponse(o),p.setValues&&p.setValues(p.names||"",o.key),p.setModules&&p.setModules(p.module||"",p.names||"",o.key),p.setSteps&&p.setSteps(p.module||"",p.step||"",p.names||"",o.key),e.n=10;break;case 9:e.p=9,d=e.v,console.error("Upload error:",d),s("Error uploading file!",400),T(0);case 10:return e.a(2)}},e,null,[[7,9],[2,4]])}));return function(){return e.apply(this,arguments)}}(),N=function(e){var r=e.percentage;return t("div",{className:"ihub-progress",style:{width:"100%",height:"8px",background:"var(--Gray, #e5e7eb)",borderRadius:"4px",overflow:"hidden",margin:"8px 0"},children:t("div",{className:"ihub-progress-bar",style:{width:"".concat(r,"%"),height:"100%",background:"var(--DarkCyan, #00838f)",borderRadius:"4px",transition:"width 0.3s ease",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"10px",color:"#fff",fontWeight:600,minWidth:r>10?"auto":0},children:r>10?"".concat(r,"%"):""})})};return n("div",{className:"ihub-uploader card primereact ".concat(p.className||""),children:[p.headers&&t("h3",{children:p.headers}),t(l,{name:"upload",customUpload:!0,accept:p.acceptedFileTypes&&p.acceptedFileTypes.length>0?p.acceptedFileTypes.join(","):p.accepts||"*",maxFileSize:p.maxFileSize||0,multiple:!p.maxFiles||p.maxFiles>1,onSelect:j,uploadHandler:z,emptyTemplate:t("p",{className:"m-0",children:U}),onError:function(){return k("Upload failed, try again!")},progressBarTemplate:!1!==p.showProgress?function(){return n("div",{children:[t(N,{percentage:S}),n("p",{style:{fontSize:"12px",color:"var(--Rhythm, #69779b)",margin:"4px 0 0"},children:["Uploading… ",S,"%"]})]})}:void 0,itemTemplate:S&&!1!==p.showProgress?function(e){var r,a=(null==e?void 0:e.name)||(null==e||null===(r=e.objectURL)||void 0===r?void 0:r.split("/").pop())||"File";return t("div",{style:{fontSize:"12px",color:"var(--Rhythm, #69779b)",padding:"4px 0"},children:a})}:void 0,disabled:p.isUploading,pt:{content:{className:"surface-ground"},message:{root:{className:"w-1rem"}}}})]})};export{p as default};
2
2
  //# sourceMappingURL=FileUploader.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_rollupPluginBabelHelpers.cjs"),n=require("react/jsx-runtime"),r=require("react"),t=require("../../lib/helpFunction.cjs"),o=require("./uploadedFileUrl.cjs"),s=require("@aws-sdk/client-s3"),i=require("@aws-sdk/lib-storage"),a=require("../../lib/modals/modals.cjs");exports.default=function(l){var c,u=l.header,d=l.label,p=void 0===d?"Drag and drop files here or click to browse":d,h=l.accept,v=void 0===h?"*":h,x=l.maxFileSize,m=void 0===x?0:x,b=l.name,f=void 0===b?"upload":b,g=l.module,j=void 0===g?"":g,y=l.step,w=void 0===y?"":y,k=l.username,_=void 0===k?null:k,C=l.onUploadComplete,N=l.setValues,E=l.setModules,S=l.setSteps,L=l.className,T=void 0===L?"":L,B=l.saveEndpoint,I=l.deleteEndpoint,A=l.token,U=l.enableS3Delete,W=void 0!==U&&U,P=l.onRemove,D=r.useState(null),O=e.slicedToArray(D,2),R=O[0],F=O[1],M=r.useState(!1),K=e.slicedToArray(M,2),z=K[0],X=K[1],q=r.useState(0),G=e.slicedToArray(q,2),H=G[0],V=G[1],Y=r.useState("idle"),Q=e.slicedToArray(Y,2),J=Q[0],Z=Q[1],$=r.useState(""),ee=e.slicedToArray($,2),ne=ee[0],re=ee[1],te=r.useState([]),oe=e.slicedToArray(te,2),se=oe[0],ie=oe[1],ae=r.useState(null),le=e.slicedToArray(ae,2),ce=le[0],ue=le[1],de=r.useRef(null),pe=function(e){if(0===e)return"0 Bytes";var n=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,n)).toFixed(2))+" "+["Bytes","KB","MB","GB"][n]},he=function(e){re(""),function(e){var n;if("*"===v)return!0;var r=e.type,t=".".concat(null===(n=e.name.split(".").pop())||void 0===n?void 0:n.toLowerCase());return!!v.split(",").map(function(e){return e.trim()}).some(function(e){return e.startsWith(".")?t===e.toLowerCase():e.endsWith("/*")?r.startsWith("".concat(e.replace("/*",""),"/")):r===e})||(re("File type not accepted. Please upload: ".concat(v)),!1)}(e)&&function(e){return!(m&&e.size>m&&(re("File size exceeds the maximum limit of ".concat(pe(m))),1))}(e)&&(F(e),Z("idle"),V(0))},ve=function(){var n=e.asyncToGenerator(e.regenerator().m(function n(r){var o,s,i,a,l,c,u,d;return e.regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:if(B&&A){e.n=1;break}return e.a(2,null);case 1:return e.p=1,s=JSON.stringify({file_url:r.location,file_key:r.key,file_name:r.title,file_size:r.size,content_type:r.content_type,media_type:null!==(o=r.content_type)&&void 0!==o&&o.startsWith("video/")?"video":"image"}),i=t.reqOptions("POST",s,A,"json"),e.n=2,fetch(B,i);case 2:if(!(a=e.v).ok){e.n=4;break}return e.n=3,a.json();case 3:return l=e.v,e.a(2,l.id);case 4:return c=console,u=a.status,e.n=5,a.text();case 5:c.error.call(c,"Save to DB failed:",u,e.v),e.n=7;break;case 6:e.p=6,d=e.v,console.error("Save to DB error:",d);case 7:return e.a(2,null)}},n,null,[[1,6]])}));return function(e){return n.apply(this,arguments)}}(),xe=function(){var n=e.asyncToGenerator(e.regenerator().m(function n(r){var t,o,i,a;return e.regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:if(e.p=0,t=new URL(r),o=t.pathname.replace(/^\//,"")){e.n=1;break}return e.a(2);case 1:return i=new s.S3Client({region:process.env.NEXT_PUBLIC_AWS_REGION,endpoint:process.env.NEXT_PUBLIC_AWS_S3_ENDPOINT_URL,requestChecksumCalculation:"WHEN_REQUIRED",credentials:{accessKeyId:process.env.NEXT_PUBLIC_AWS_ACCESS_KEY_ID||"",secretAccessKey:process.env.NEXT_PUBLIC_AWS_SECRET_ACCESS_KEY||""}}),e.n=2,i.send(new s.DeleteObjectCommand({Bucket:process.env.NEXT_PUBLIC_AWS_BUCKET_NAME||"",Key:o}));case 2:e.n=4;break;case 3:e.p=3,a=e.v,console.error("S3 delete error:",a);case 4:return e.a(2)}},n,null,[[0,3]])}));return function(e){return n.apply(this,arguments)}}(),me=function(){var n=e.asyncToGenerator(e.regenerator().m(function n(r){var o,s,i;return e.regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:if(I&&A){e.n=1;break}return e.a(2,!1);case 1:return e.p=1,o=t.reqOptions("DELETE",null,A),e.n=2,fetch("".concat(I).concat(r,"/"),o);case 2:return s=e.v,e.a(2,s.ok||404===s.status);case 3:return e.p=3,i=e.v,console.error("DB delete error:",i),e.a(2,!1)}},n,null,[[1,3]])}));return function(e){return n.apply(this,arguments)}}(),be=function(){var n=e.asyncToGenerator(e.regenerator().m(function n(r){var t;return e.regenerator().w(function(e){for(;;)switch(e.n){case 0:if(t=se[r]){e.n=1;break}return e.a(2);case 1:if(!t.dbId||!I){e.n=2;break}return e.n=2,me(t.dbId);case 2:if(!W||!t.response.location){e.n=3;break}return e.n=3,xe(t.response.location);case 3:ie(function(e){return e.filter(function(e,n){return n!==r})}),P&&P(t.response),a.openToast("File removed");case 4:return e.a(2)}},n)}));return function(e){return n.apply(this,arguments)}}(),fe=function(){var n=e.asyncToGenerator(e.regenerator().m(function n(){var r,l,c,u,d,p,h,x,m,b,g,y,k,L;return e.regenerator().w(function(n){for(;;)switch(n.p=n.n){case 0:if(R){n.n=1;break}return re("Please select a file first"),n.a(2);case 1:if(Z("uploading"),re(""),n.p=2,r=new s.S3Client({region:process.env.NEXT_PUBLIC_AWS_REGION,endpoint:process.env.NEXT_PUBLIC_AWS_S3_ENDPOINT_URL,requestChecksumCalculation:"WHEN_REQUIRED",credentials:{accessKeyId:process.env.NEXT_PUBLIC_AWS_ACCESS_KEY_ID||"",secretAccessKey:process.env.NEXT_PUBLIC_AWS_SECRET_ACCESS_KEY||""}}),l=(new Date).toISOString(),c=t.slugifyFileName("".concat(_||"anonymous","-").concat(l,"-").concat(R.name)),u=t.IN_DEV_MODE?"test-env__".concat(c):c,d="video/*"===v?process.env.NEXT_PUBLIC_AWS_LOCATION:process.env.NEXT_PUBLIC_AWS_LOCATION_FILES,p=process.env.NEXT_PUBLIC_AWS_BUCKET_NAME||"",h="".concat(d,"/").concat(u),!(R.size<104857600)){n.n=4;break}return V(10),x=new s.PutObjectCommand({Bucket:p,Key:h,Body:R,ContentType:R.type,ACL:"public-read"}),m=setInterval(function(){V(function(e){return Math.min(e+5,95)})},300),n.n=3,r.send(x);case 3:clearInterval(m),V(100),n.n=5;break;case 4:return(b=new i.Upload({client:r,params:{Bucket:p,Key:h,Body:R,ContentType:R.type,ACL:"public-read"}})).on("httpUploadProgress",function(e){var n=Math.round(e.loaded/e.total*100);V(n)}),n.n=5,b.done();case 5:if(Z("success"),a.openToast("File Uploaded Successfully!"),g={bucket:p,title:R.name,key:u,content_type:R.type,size:R.size,location:o.uploadedFileUrl(h,t.FILE_URL,process.env.NEXT_PUBLIC_AWS_LOCATION_FILES)},!B||!A){n.n=7;break}return n.n=6,ve(g);case 6:(k=n.v)&&(y=k);case 7:ie(function(n){return[].concat(e.toConsumableArray(n),[{response:g,dbId:y,fullS3Key:h}])}),C&&C(g),N&&N(f,g.key),E&&E(j,f,g.key),S&&S(j,w,f,g.key),setTimeout(function(){F(null),Z("idle"),V(0)},2e3),n.n=9;break;case 8:n.p=8,L=n.v,console.error("Upload error:",L),Z("error"),re("Error uploading file. Please try again."),a.openToast("Error uploading file!",400),V(0);case 9:return n.a(2)}},n,null,[[2,8]])}));return function(){return n.apply(this,arguments)}}(),ge=function(){F(null),Z("idle"),V(0),re("")};return n.jsxs("div",{className:"ihub-uploader ".concat(T),children:[u&&n.jsx("h3",{className:"ihub-uploader-header",children:u}),n.jsxs("div",{className:"ihub-uploader-container",children:[!R&&n.jsxs("div",{className:"ihub-uploader-dropzone ".concat(z?"ihub-uploader-dropzone-active":""),onDragOver:function(e){e.preventDefault(),e.stopPropagation(),X(!0)},onDragLeave:function(e){e.preventDefault(),e.stopPropagation(),X(!1)},onDrop:function(e){e.preventDefault(),e.stopPropagation(),X(!1);var n=e.dataTransfer.files;n&&n.length>0&&he(n[0])},onClick:function(){var e;null===(e=de.current)||void 0===e||e.click()},children:[n.jsx("div",{className:"ihub-uploader-icon",children:n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),n.jsx("polyline",{points:"17 8 12 3 7 8"}),n.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"15"})]})}),n.jsx("p",{className:"ihub-uploader-text",children:p}),n.jsx("p",{className:"ihub-uploader-hint",children:m>0&&"Maximum file size: ".concat(pe(m))}),n.jsx("input",{ref:de,type:"file",accept:v,onChange:function(e){var n=e.target.files;n&&n.length>0&&he(n[0])},className:"ihub-uploader-input"})]}),R&&n.jsxs("div",{className:"ihub-uploader-preview",children:[n.jsxs("div",{className:"ihub-uploader-file-info",children:[n.jsx("div",{className:"ihub-uploader-file-icon",children:R.type.startsWith("image/")?n.jsx("img",{src:URL.createObjectURL(R),alt:R.name,className:"ihub-uploader-thumbnail"}):n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),n.jsx("polyline",{points:"14 2 14 8 20 8"}),n.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),n.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),n.jsx("polyline",{points:"10 9 9 9 8 9"})]})}),n.jsxs("div",{className:"ihub-uploader-file-details",children:[n.jsx("p",{className:"ihub-uploader-file-name",children:R.name}),n.jsx("p",{className:"ihub-uploader-file-size",children:pe(R.size)})]})]}),"uploading"===J&&n.jsx("div",{className:"ihub-uploader-progress",children:n.jsx("div",{className:"ihub-uploader-progress-bar",style:{width:"".concat(H,"%")},children:n.jsxs("span",{className:"ihub-uploader-progress-text",children:[H,"%"]})})}),n.jsxs("div",{className:"ihub-uploader-actions",children:["idle"===J&&n.jsxs(n.Fragment,{children:[n.jsx("button",{className:"ihub-uploader-upload-btn ihub-important-btn",onClick:fe,children:"Upload"}),n.jsx("button",{className:"ihub-uploader-cancel-btn outlined-btn",onClick:ge,children:"Cancel"})]}),"uploading"===J&&n.jsx("button",{className:"ihub-uploader-cancel-btn outlined-btn",onClick:ge,children:"Cancel"}),"success"===J&&n.jsxs("div",{className:"ihub-uploader-success",children:[n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),n.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}),n.jsx("span",{children:"Upload Complete"})]}),"error"===J&&n.jsxs(n.Fragment,{children:[n.jsx("button",{className:"ihub-uploader-retry-btn ihub-important-btn",onClick:fe,children:"Retry"}),n.jsx("button",{className:"ihub-uploader-cancel-btn outlined-btn",onClick:ge,children:"Cancel"})]})]})]}),se.length>0&&n.jsx("div",{className:"ihub-uploader-thumbs",children:se.map(function(e,r){var t,o=null===(t=e.response.content_type)||void 0===t?void 0:t.startsWith("video/");return n.jsxs("div",{className:"ihub-uploader-thumb",children:[n.jsxs("div",{className:"ihub-uploader-thumb-preview",onClick:function(){return ue(r)},title:"Click to preview",children:[o?n.jsx("video",{src:e.response.location,muted:!0}):n.jsx("img",{src:e.response.location,alt:e.response.title}),o&&n.jsx("span",{className:"ihub-uploader-thumb-badge",children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor",children:n.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})})})]}),n.jsx("button",{type:"button",className:"ihub-uploader-thumb-remove",onClick:function(e){e.stopPropagation(),be(r)},title:"Remove",children:n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},r)})}),null!==ce&&se[ce]&&n.jsx("div",{className:"ihub-uploader-lightbox",onClick:function(){return ue(null)},children:n.jsxs("div",{className:"ihub-uploader-lightbox-content",onClick:function(e){return e.stopPropagation()},children:[n.jsx("button",{className:"ihub-uploader-lightbox-close",onClick:function(){return ue(null)},children:n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}),ce>0&&n.jsx("button",{className:"ihub-uploader-lightbox-nav ihub-uploader-lightbox-prev",onClick:function(){return ue(ce-1)},children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:n.jsx("polyline",{points:"15 18 9 12 15 6"})})}),n.jsx("div",{className:"ihub-uploader-lightbox-media",children:null!==(c=se[ce].response.content_type)&&void 0!==c&&c.startsWith("video/")?n.jsx("video",{src:se[ce].response.location,controls:!0,autoPlay:!0}):n.jsx("img",{src:se[ce].response.location,alt:se[ce].response.title})}),ce<se.length-1&&n.jsx("button",{className:"ihub-uploader-lightbox-nav ihub-uploader-lightbox-next",onClick:function(){return ue(ce+1)},children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:n.jsx("polyline",{points:"9 18 15 12 9 6"})})}),n.jsxs("div",{className:"ihub-uploader-lightbox-info",children:[n.jsx("span",{children:se[ce].response.title}),n.jsxs("span",{children:[ce+1," / ",se.length]})]})]})}),ne&&n.jsxs("div",{className:"ihub-uploader-error",children:[n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("circle",{cx:"12",cy:"12",r:"10"}),n.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),n.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),n.jsx("span",{children:ne})]})]})]})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_rollupPluginBabelHelpers.cjs"),n=require("react/jsx-runtime"),r=require("react"),t=require("../../lib/helpFunction.cjs"),o=require("../../lib/modals/modals.cjs"),i=require("./presignedPut.cjs");exports.default=function(s){var l,a=s.header,c=s.label,u=void 0===c?"Drag and drop files here or click to browse":c,d=s.accept,p=void 0===d?"*":d,h=s.maxFileSize,x=void 0===h?0:h,v=s.name,b=void 0===v?"upload":v,f=s.module,m=void 0===f?"":f,g=s.step,j=void 0===g?"":g,y=s.onUploadComplete,k=s.setValues,w=s.setModules,N=s.setSteps,C=s.className,L=void 0===C?"":C,T=s.saveEndpoint,B=s.deleteEndpoint,_=s.token,P=s.getPresignedUrl,S=s.deleteFile,W=s.onRemove,z=r.useState(null),D=e.slicedToArray(z,2),F=D[0],U=D[1],M=r.useState(!1),A=e.slicedToArray(M,2),O=A[0],q=A[1],E=r.useState(0),R=e.slicedToArray(E,2),G=R[0],I=R[1],H=r.useState("idle"),V=e.slicedToArray(H,2),J=V[0],K=V[1],Q=r.useState(""),X=e.slicedToArray(Q,2),Y=X[0],Z=X[1],$=r.useState([]),ee=e.slicedToArray($,2),ne=ee[0],re=ee[1],te=r.useState(null),oe=e.slicedToArray(te,2),ie=oe[0],se=oe[1],le=r.useRef(null),ae=function(e){if(0===e)return"0 Bytes";var n=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,n)).toFixed(2))+" "+["Bytes","KB","MB","GB"][n]},ce=function(e){Z(""),function(e){var n;if("*"===p)return!0;var r=e.type,t=".".concat(null===(n=e.name.split(".").pop())||void 0===n?void 0:n.toLowerCase());return!!p.split(",").map(function(e){return e.trim()}).some(function(e){return e.startsWith(".")?t===e.toLowerCase():e.endsWith("/*")?r.startsWith("".concat(e.replace("/*",""),"/")):r===e})||(Z("File type not accepted. Please upload: ".concat(p)),!1)}(e)&&function(e){return!(x&&e.size>x&&(Z("File size exceeds the maximum limit of ".concat(ae(x))),1))}(e)&&(U(e),K("idle"),I(0))},ue=function(){var n=e.asyncToGenerator(e.regenerator().m(function n(r){var o,i,s,l,a,c,u,d;return e.regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:if(T&&_){e.n=1;break}return e.a(2,null);case 1:return e.p=1,i=JSON.stringify({file_url:r.location,file_key:r.key,file_name:r.title,file_size:r.size,content_type:r.content_type,media_type:null!==(o=r.content_type)&&void 0!==o&&o.startsWith("video/")?"video":"image"}),s=t.reqOptions("POST",i,_,"json"),e.n=2,fetch(T,s);case 2:if(!(l=e.v).ok){e.n=4;break}return e.n=3,l.json();case 3:return a=e.v,e.a(2,a.id);case 4:return c=console,u=l.status,e.n=5,l.text();case 5:c.error.call(c,"Save to DB failed:",u,e.v),e.n=7;break;case 6:e.p=6,d=e.v,console.error("Save to DB error:",d);case 7:return e.a(2,null)}},n,null,[[1,6]])}));return function(e){return n.apply(this,arguments)}}(),de=function(){var n=e.asyncToGenerator(e.regenerator().m(function n(r){var o,i,s;return e.regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:if(B&&_){e.n=1;break}return e.a(2,!1);case 1:return e.p=1,o=t.reqOptions("DELETE",null,_),e.n=2,fetch("".concat(B).concat(r,"/"),o);case 2:return i=e.v,e.a(2,i.ok||404===i.status);case 3:return e.p=3,s=e.v,console.error("DB delete error:",s),e.a(2,!1)}},n,null,[[1,3]])}));return function(e){return n.apply(this,arguments)}}(),pe=function(){var n=e.asyncToGenerator(e.regenerator().m(function n(r){var t,i;return e.regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t=ne[r]){e.n=1;break}return e.a(2);case 1:if(!t.dbId||!B){e.n=2;break}return e.n=2,de(t.dbId);case 2:if(!S){e.n=6;break}return e.p=3,e.n=4,S(t.response);case 4:e.n=6;break;case 5:e.p=5,i=e.v,console.error("File delete error:",i);case 6:re(function(e){return e.filter(function(e,n){return n!==r})}),W&&W(t.response),o.openToast("File removed");case 7:return e.a(2)}},n,null,[[3,5]])}));return function(e){return n.apply(this,arguments)}}(),he=function(){var n=e.asyncToGenerator(e.regenerator().m(function n(){var r,t,s,l,a;return e.regenerator().w(function(n){for(;;)switch(n.p=n.n){case 0:if(F){n.n=1;break}return Z("Please select a file first"),n.a(2);case 1:if(K("uploading"),Z(""),P){n.n=2;break}return console.error(i.UPLOADS_NOT_CONFIGURED),K("error"),Z("Uploads are not configured."),n.a(2);case 2:return n.p=2,n.n=3,i.presignAndUpload(F,P,I);case 3:if(r=n.v,I(100),K("success"),o.openToast("File Uploaded Successfully!"),t={title:F.name,key:r.key,content_type:r.contentType,size:F.size,location:r.cdnUrl},!T||!_){n.n=5;break}return n.n=4,ue(t);case 4:(l=n.v)&&(s=l);case 5:re(function(n){return[].concat(e.toConsumableArray(n),[{response:t,dbId:s}])}),y&&y(t),k&&k(b,t.key),w&&w(m,b,t.key),N&&N(m,j,b,t.key),setTimeout(function(){U(null),K("idle"),I(0)},2e3),n.n=7;break;case 6:n.p=6,a=n.v,console.error("Upload error:",a),K("error"),Z("Error uploading file. Please try again."),o.openToast("Error uploading file!",400),I(0);case 7:return n.a(2)}},n,null,[[2,6]])}));return function(){return n.apply(this,arguments)}}(),xe=function(){U(null),K("idle"),I(0),Z("")};return n.jsxs("div",{className:"ihub-uploader ".concat(L),children:[a&&n.jsx("h3",{className:"ihub-uploader-header",children:a}),n.jsxs("div",{className:"ihub-uploader-container",children:[!F&&n.jsxs("div",{className:"ihub-uploader-dropzone ".concat(O?"ihub-uploader-dropzone-active":""),onDragOver:function(e){e.preventDefault(),e.stopPropagation(),q(!0)},onDragLeave:function(e){e.preventDefault(),e.stopPropagation(),q(!1)},onDrop:function(e){e.preventDefault(),e.stopPropagation(),q(!1);var n=e.dataTransfer.files;n&&n.length>0&&ce(n[0])},onClick:function(){var e;null===(e=le.current)||void 0===e||e.click()},children:[n.jsx("div",{className:"ihub-uploader-icon",children:n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),n.jsx("polyline",{points:"17 8 12 3 7 8"}),n.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"15"})]})}),n.jsx("p",{className:"ihub-uploader-text",children:u}),n.jsx("p",{className:"ihub-uploader-hint",children:x>0&&"Maximum file size: ".concat(ae(x))}),n.jsx("input",{ref:le,type:"file",accept:p,onChange:function(e){var n=e.target.files;n&&n.length>0&&ce(n[0])},className:"ihub-uploader-input"})]}),F&&n.jsxs("div",{className:"ihub-uploader-preview",children:[n.jsxs("div",{className:"ihub-uploader-file-info",children:[n.jsx("div",{className:"ihub-uploader-file-icon",children:F.type.startsWith("image/")?n.jsx("img",{src:URL.createObjectURL(F),alt:F.name,className:"ihub-uploader-thumbnail"}):n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),n.jsx("polyline",{points:"14 2 14 8 20 8"}),n.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),n.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),n.jsx("polyline",{points:"10 9 9 9 8 9"})]})}),n.jsxs("div",{className:"ihub-uploader-file-details",children:[n.jsx("p",{className:"ihub-uploader-file-name",children:F.name}),n.jsx("p",{className:"ihub-uploader-file-size",children:ae(F.size)})]})]}),"uploading"===J&&n.jsx("div",{className:"ihub-uploader-progress",children:n.jsx("div",{className:"ihub-uploader-progress-bar",style:{width:"".concat(G,"%")},children:n.jsxs("span",{className:"ihub-uploader-progress-text",children:[G,"%"]})})}),n.jsxs("div",{className:"ihub-uploader-actions",children:["idle"===J&&n.jsxs(n.Fragment,{children:[n.jsx("button",{className:"ihub-uploader-upload-btn ihub-important-btn",onClick:he,children:"Upload"}),n.jsx("button",{className:"ihub-uploader-cancel-btn outlined-btn",onClick:xe,children:"Cancel"})]}),"uploading"===J&&n.jsx("button",{className:"ihub-uploader-cancel-btn outlined-btn",onClick:xe,children:"Cancel"}),"success"===J&&n.jsxs("div",{className:"ihub-uploader-success",children:[n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),n.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}),n.jsx("span",{children:"Upload Complete"})]}),"error"===J&&n.jsxs(n.Fragment,{children:[n.jsx("button",{className:"ihub-uploader-retry-btn ihub-important-btn",onClick:he,children:"Retry"}),n.jsx("button",{className:"ihub-uploader-cancel-btn outlined-btn",onClick:xe,children:"Cancel"})]})]})]}),ne.length>0&&n.jsx("div",{className:"ihub-uploader-thumbs",children:ne.map(function(e,r){var t,o=null===(t=e.response.content_type)||void 0===t?void 0:t.startsWith("video/");return n.jsxs("div",{className:"ihub-uploader-thumb",children:[n.jsxs("div",{className:"ihub-uploader-thumb-preview",onClick:function(){return se(r)},title:"Click to preview",children:[o?n.jsx("video",{src:e.response.location,muted:!0}):n.jsx("img",{src:e.response.location,alt:e.response.title}),o&&n.jsx("span",{className:"ihub-uploader-thumb-badge",children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor",children:n.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})})})]}),n.jsx("button",{type:"button",className:"ihub-uploader-thumb-remove",onClick:function(e){e.stopPropagation(),pe(r)},title:"Remove",children:n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},r)})}),null!==ie&&ne[ie]&&n.jsx("div",{className:"ihub-uploader-lightbox",onClick:function(){return se(null)},children:n.jsxs("div",{className:"ihub-uploader-lightbox-content",onClick:function(e){return e.stopPropagation()},children:[n.jsx("button",{className:"ihub-uploader-lightbox-close",onClick:function(){return se(null)},children:n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}),ie>0&&n.jsx("button",{className:"ihub-uploader-lightbox-nav ihub-uploader-lightbox-prev",onClick:function(){return se(ie-1)},children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:n.jsx("polyline",{points:"15 18 9 12 15 6"})})}),n.jsx("div",{className:"ihub-uploader-lightbox-media",children:null!==(l=ne[ie].response.content_type)&&void 0!==l&&l.startsWith("video/")?n.jsx("video",{src:ne[ie].response.location,controls:!0,autoPlay:!0}):n.jsx("img",{src:ne[ie].response.location,alt:ne[ie].response.title})}),ie<ne.length-1&&n.jsx("button",{className:"ihub-uploader-lightbox-nav ihub-uploader-lightbox-next",onClick:function(){return se(ie+1)},children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:n.jsx("polyline",{points:"9 18 15 12 9 6"})})}),n.jsxs("div",{className:"ihub-uploader-lightbox-info",children:[n.jsx("span",{children:ne[ie].response.title}),n.jsxs("span",{children:[ie+1," / ",ne.length]})]})]})}),Y&&n.jsxs("div",{className:"ihub-uploader-error",children:[n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("circle",{cx:"12",cy:"12",r:"10"}),n.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),n.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),n.jsx("span",{children:Y})]})]})]})};
2
2
  //# sourceMappingURL=IhubFileUploader.cjs.map
@@ -1,2 +1,2 @@
1
- import{slicedToArray as e,asyncToGenerator as n,regenerator as r,toConsumableArray as t}from"../../../../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as o,jsx as i,Fragment as l}from"react/jsx-runtime";import{useState as a,useRef as s}from"react";import{FILE_URL as c,slugifyFileName as u,IN_DEV_MODE as d,reqOptions as p}from"../../lib/helpFunction.js";import{uploadedFileUrl as h}from"./uploadedFileUrl.js";import{S3Client as v,PutObjectCommand as m,DeleteObjectCommand as f}from"@aws-sdk/client-s3";import{Upload as b}from"@aws-sdk/lib-storage";import{openToast as g}from"../../lib/modals/modals.js";function w(w){var k,y=w.header,_=w.label,C=void 0===_?"Drag and drop files here or click to browse":_,N=w.accept,x=void 0===N?"*":N,E=w.maxFileSize,L=void 0===E?0:E,S=w.name,B=void 0===S?"upload":S,I=w.module,T=void 0===I?"":I,W=w.step,U=void 0===W?"":W,A=w.username,P=void 0===A?null:A,D=w.onUploadComplete,j=w.setValues,R=w.setModules,K=w.setSteps,O=w.className,z=void 0===O?"":O,M=w.saveEndpoint,X=w.deleteEndpoint,F=w.token,H=w.enableS3Delete,G=void 0!==H&&H,Y=w.onRemove,V=a(null),q=e(V,2),Q=q[0],J=q[1],Z=a(!1),$=e(Z,2),ee=$[0],ne=$[1],re=a(0),te=e(re,2),oe=te[0],ie=te[1],le=a("idle"),ae=e(le,2),se=ae[0],ce=ae[1],ue=a(""),de=e(ue,2),pe=de[0],he=de[1],ve=a([]),me=e(ve,2),fe=me[0],be=me[1],ge=a(null),we=e(ge,2),ke=we[0],ye=we[1],_e=s(null),Ce=function(e){if(0===e)return"0 Bytes";var n=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,n)).toFixed(2))+" "+["Bytes","KB","MB","GB"][n]},Ne=function(e){he(""),function(e){var n;if("*"===x)return!0;var r=e.type,t=".".concat(null===(n=e.name.split(".").pop())||void 0===n?void 0:n.toLowerCase());return!!x.split(",").map(function(e){return e.trim()}).some(function(e){return e.startsWith(".")?t===e.toLowerCase():e.endsWith("/*")?r.startsWith("".concat(e.replace("/*",""),"/")):r===e})||(he("File type not accepted. Please upload: ".concat(x)),!1)}(e)&&function(e){return!(L&&e.size>L&&(he("File size exceeds the maximum limit of ".concat(Ce(L))),1))}(e)&&(J(e),ce("idle"),ie(0))},xe=function(){var e=n(r().m(function e(n){var t,o,i,l,a,s,c,u;return r().w(function(e){for(;;)switch(e.p=e.n){case 0:if(M&&F){e.n=1;break}return e.a(2,null);case 1:return e.p=1,o=JSON.stringify({file_url:n.location,file_key:n.key,file_name:n.title,file_size:n.size,content_type:n.content_type,media_type:null!==(t=n.content_type)&&void 0!==t&&t.startsWith("video/")?"video":"image"}),i=p("POST",o,F,"json"),e.n=2,fetch(M,i);case 2:if(!(l=e.v).ok){e.n=4;break}return e.n=3,l.json();case 3:return a=e.v,e.a(2,a.id);case 4:return s=console,c=l.status,e.n=5,l.text();case 5:s.error.call(s,"Save to DB failed:",c,e.v),e.n=7;break;case 6:e.p=6,u=e.v,console.error("Save to DB error:",u);case 7:return e.a(2,null)}},e,null,[[1,6]])}));return function(n){return e.apply(this,arguments)}}(),Ee=function(){var e=n(r().m(function e(n){var t,o,i,l;return r().w(function(e){for(;;)switch(e.p=e.n){case 0:if(e.p=0,t=new URL(n),o=t.pathname.replace(/^\//,"")){e.n=1;break}return e.a(2);case 1:return i=new v({region:process.env.NEXT_PUBLIC_AWS_REGION,endpoint:process.env.NEXT_PUBLIC_AWS_S3_ENDPOINT_URL,requestChecksumCalculation:"WHEN_REQUIRED",credentials:{accessKeyId:process.env.NEXT_PUBLIC_AWS_ACCESS_KEY_ID||"",secretAccessKey:process.env.NEXT_PUBLIC_AWS_SECRET_ACCESS_KEY||""}}),e.n=2,i.send(new f({Bucket:process.env.NEXT_PUBLIC_AWS_BUCKET_NAME||"",Key:o}));case 2:e.n=4;break;case 3:e.p=3,l=e.v,console.error("S3 delete error:",l);case 4:return e.a(2)}},e,null,[[0,3]])}));return function(n){return e.apply(this,arguments)}}(),Le=function(){var e=n(r().m(function e(n){var t,o,i;return r().w(function(e){for(;;)switch(e.p=e.n){case 0:if(X&&F){e.n=1;break}return e.a(2,!1);case 1:return e.p=1,t=p("DELETE",null,F),e.n=2,fetch("".concat(X).concat(n,"/"),t);case 2:return o=e.v,e.a(2,o.ok||404===o.status);case 3:return e.p=3,i=e.v,console.error("DB delete error:",i),e.a(2,!1)}},e,null,[[1,3]])}));return function(n){return e.apply(this,arguments)}}(),Se=function(){var e=n(r().m(function e(n){var t;return r().w(function(e){for(;;)switch(e.n){case 0:if(t=fe[n]){e.n=1;break}return e.a(2);case 1:if(!t.dbId||!X){e.n=2;break}return e.n=2,Le(t.dbId);case 2:if(!G||!t.response.location){e.n=3;break}return e.n=3,Ee(t.response.location);case 3:be(function(e){return e.filter(function(e,r){return r!==n})}),Y&&Y(t.response),g("File removed");case 4:return e.a(2)}},e)}));return function(n){return e.apply(this,arguments)}}(),Be=function(){var e=n(r().m(function e(){var n,o,i,l,a,s,p,f,w,k,y,_,C,N;return r().w(function(e){for(;;)switch(e.p=e.n){case 0:if(Q){e.n=1;break}return he("Please select a file first"),e.a(2);case 1:if(ce("uploading"),he(""),e.p=2,n=new v({region:process.env.NEXT_PUBLIC_AWS_REGION,endpoint:process.env.NEXT_PUBLIC_AWS_S3_ENDPOINT_URL,requestChecksumCalculation:"WHEN_REQUIRED",credentials:{accessKeyId:process.env.NEXT_PUBLIC_AWS_ACCESS_KEY_ID||"",secretAccessKey:process.env.NEXT_PUBLIC_AWS_SECRET_ACCESS_KEY||""}}),o=(new Date).toISOString(),i=u("".concat(P||"anonymous","-").concat(o,"-").concat(Q.name)),l=d?"test-env__".concat(i):i,a="video/*"===x?process.env.NEXT_PUBLIC_AWS_LOCATION:process.env.NEXT_PUBLIC_AWS_LOCATION_FILES,s=process.env.NEXT_PUBLIC_AWS_BUCKET_NAME||"",p="".concat(a,"/").concat(l),!(Q.size<104857600)){e.n=4;break}return ie(10),f=new m({Bucket:s,Key:p,Body:Q,ContentType:Q.type,ACL:"public-read"}),w=setInterval(function(){ie(function(e){return Math.min(e+5,95)})},300),e.n=3,n.send(f);case 3:clearInterval(w),ie(100),e.n=5;break;case 4:return(k=new b({client:n,params:{Bucket:s,Key:p,Body:Q,ContentType:Q.type,ACL:"public-read"}})).on("httpUploadProgress",function(e){var n=Math.round(e.loaded/e.total*100);ie(n)}),e.n=5,k.done();case 5:if(ce("success"),g("File Uploaded Successfully!"),y={bucket:s,title:Q.name,key:l,content_type:Q.type,size:Q.size,location:h(p,c,process.env.NEXT_PUBLIC_AWS_LOCATION_FILES)},!M||!F){e.n=7;break}return e.n=6,xe(y);case 6:(C=e.v)&&(_=C);case 7:be(function(e){return[].concat(t(e),[{response:y,dbId:_,fullS3Key:p}])}),D&&D(y),j&&j(B,y.key),R&&R(T,B,y.key),K&&K(T,U,B,y.key),setTimeout(function(){J(null),ce("idle"),ie(0)},2e3),e.n=9;break;case 8:e.p=8,N=e.v,console.error("Upload error:",N),ce("error"),he("Error uploading file. Please try again."),g("Error uploading file!",400),ie(0);case 9:return e.a(2)}},e,null,[[2,8]])}));return function(){return e.apply(this,arguments)}}(),Ie=function(){J(null),ce("idle"),ie(0),he("")};return o("div",{className:"ihub-uploader ".concat(z),children:[y&&i("h3",{className:"ihub-uploader-header",children:y}),o("div",{className:"ihub-uploader-container",children:[!Q&&o("div",{className:"ihub-uploader-dropzone ".concat(ee?"ihub-uploader-dropzone-active":""),onDragOver:function(e){e.preventDefault(),e.stopPropagation(),ne(!0)},onDragLeave:function(e){e.preventDefault(),e.stopPropagation(),ne(!1)},onDrop:function(e){e.preventDefault(),e.stopPropagation(),ne(!1);var n=e.dataTransfer.files;n&&n.length>0&&Ne(n[0])},onClick:function(){var e;null===(e=_e.current)||void 0===e||e.click()},children:[i("div",{className:"ihub-uploader-icon",children:o("svg",{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),i("polyline",{points:"17 8 12 3 7 8"}),i("line",{x1:"12",y1:"3",x2:"12",y2:"15"})]})}),i("p",{className:"ihub-uploader-text",children:C}),i("p",{className:"ihub-uploader-hint",children:L>0&&"Maximum file size: ".concat(Ce(L))}),i("input",{ref:_e,type:"file",accept:x,onChange:function(e){var n=e.target.files;n&&n.length>0&&Ne(n[0])},className:"ihub-uploader-input"})]}),Q&&o("div",{className:"ihub-uploader-preview",children:[o("div",{className:"ihub-uploader-file-info",children:[i("div",{className:"ihub-uploader-file-icon",children:Q.type.startsWith("image/")?i("img",{src:URL.createObjectURL(Q),alt:Q.name,className:"ihub-uploader-thumbnail"}):o("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),i("polyline",{points:"14 2 14 8 20 8"}),i("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),i("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),i("polyline",{points:"10 9 9 9 8 9"})]})}),o("div",{className:"ihub-uploader-file-details",children:[i("p",{className:"ihub-uploader-file-name",children:Q.name}),i("p",{className:"ihub-uploader-file-size",children:Ce(Q.size)})]})]}),"uploading"===se&&i("div",{className:"ihub-uploader-progress",children:i("div",{className:"ihub-uploader-progress-bar",style:{width:"".concat(oe,"%")},children:o("span",{className:"ihub-uploader-progress-text",children:[oe,"%"]})})}),o("div",{className:"ihub-uploader-actions",children:["idle"===se&&o(l,{children:[i("button",{className:"ihub-uploader-upload-btn ihub-important-btn",onClick:Be,children:"Upload"}),i("button",{className:"ihub-uploader-cancel-btn outlined-btn",onClick:Ie,children:"Cancel"})]}),"uploading"===se&&i("button",{className:"ihub-uploader-cancel-btn outlined-btn",onClick:Ie,children:"Cancel"}),"success"===se&&o("div",{className:"ihub-uploader-success",children:[o("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),i("polyline",{points:"22 4 12 14.01 9 11.01"})]}),i("span",{children:"Upload Complete"})]}),"error"===se&&o(l,{children:[i("button",{className:"ihub-uploader-retry-btn ihub-important-btn",onClick:Be,children:"Retry"}),i("button",{className:"ihub-uploader-cancel-btn outlined-btn",onClick:Ie,children:"Cancel"})]})]})]}),fe.length>0&&i("div",{className:"ihub-uploader-thumbs",children:fe.map(function(e,n){var r,t=null===(r=e.response.content_type)||void 0===r?void 0:r.startsWith("video/");return o("div",{className:"ihub-uploader-thumb",children:[o("div",{className:"ihub-uploader-thumb-preview",onClick:function(){return ye(n)},title:"Click to preview",children:[t?i("video",{src:e.response.location,muted:!0}):i("img",{src:e.response.location,alt:e.response.title}),t&&i("span",{className:"ihub-uploader-thumb-badge",children:i("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor",children:i("polygon",{points:"5 3 19 12 5 21 5 3"})})})]}),i("button",{type:"button",className:"ihub-uploader-thumb-remove",onClick:function(e){e.stopPropagation(),Se(n)},title:"Remove",children:o("svg",{xmlns:"http://www.w3.org/2000/svg",width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[i("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),i("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},n)})}),null!==ke&&fe[ke]&&i("div",{className:"ihub-uploader-lightbox",onClick:function(){return ye(null)},children:o("div",{className:"ihub-uploader-lightbox-content",onClick:function(e){return e.stopPropagation()},children:[i("button",{className:"ihub-uploader-lightbox-close",onClick:function(){return ye(null)},children:o("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),i("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}),ke>0&&i("button",{className:"ihub-uploader-lightbox-nav ihub-uploader-lightbox-prev",onClick:function(){return ye(ke-1)},children:i("svg",{xmlns:"http://www.w3.org/2000/svg",width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:i("polyline",{points:"15 18 9 12 15 6"})})}),i("div",{className:"ihub-uploader-lightbox-media",children:null!==(k=fe[ke].response.content_type)&&void 0!==k&&k.startsWith("video/")?i("video",{src:fe[ke].response.location,controls:!0,autoPlay:!0}):i("img",{src:fe[ke].response.location,alt:fe[ke].response.title})}),ke<fe.length-1&&i("button",{className:"ihub-uploader-lightbox-nav ihub-uploader-lightbox-next",onClick:function(){return ye(ke+1)},children:i("svg",{xmlns:"http://www.w3.org/2000/svg",width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:i("polyline",{points:"9 18 15 12 9 6"})})}),o("div",{className:"ihub-uploader-lightbox-info",children:[i("span",{children:fe[ke].response.title}),o("span",{children:[ke+1," / ",fe.length]})]})]})}),pe&&o("div",{className:"ihub-uploader-error",children:[o("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i("circle",{cx:"12",cy:"12",r:"10"}),i("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),i("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),i("span",{children:pe})]})]})]})}export{w as default};
1
+ import{slicedToArray as e,asyncToGenerator as n,regenerator as r,toConsumableArray as o}from"../../../../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as t,jsx as i,Fragment as l}from"react/jsx-runtime";import{useState as a,useRef as s}from"react";import{reqOptions as c}from"../../lib/helpFunction.js";import{openToast as u}from"../../lib/modals/modals.js";import{presignAndUpload as d,UPLOADS_NOT_CONFIGURED as p}from"./presignedPut.js";function h(h){var v,m=h.header,f=h.label,b=void 0===f?"Drag and drop files here or click to browse":f,g=h.accept,k=void 0===g?"*":g,w=h.maxFileSize,y=void 0===w?0:w,x=h.name,N=void 0===x?"upload":x,C=h.module,L=void 0===C?"":C,B=h.step,j=void 0===B?"":B,W=h.onUploadComplete,z=h.setValues,P=h.setModules,_=h.setSteps,D=h.className,F=void 0===D?"":D,M=h.saveEndpoint,U=h.deleteEndpoint,E=h.token,S=h.getPresignedUrl,T=h.deleteFile,R=h.onRemove,O=a(null),H=e(O,2),I=H[0],V=H[1],A=a(!1),G=e(A,2),J=G[0],K=G[1],q=a(0),Q=e(q,2),X=Q[0],Y=Q[1],Z=a("idle"),$=e(Z,2),ee=$[0],ne=$[1],re=a(""),oe=e(re,2),te=oe[0],ie=oe[1],le=a([]),ae=e(le,2),se=ae[0],ce=ae[1],ue=a(null),de=e(ue,2),pe=de[0],he=de[1],ve=s(null),me=function(e){if(0===e)return"0 Bytes";var n=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,n)).toFixed(2))+" "+["Bytes","KB","MB","GB"][n]},fe=function(e){ie(""),function(e){var n;if("*"===k)return!0;var r=e.type,o=".".concat(null===(n=e.name.split(".").pop())||void 0===n?void 0:n.toLowerCase());return!!k.split(",").map(function(e){return e.trim()}).some(function(e){return e.startsWith(".")?o===e.toLowerCase():e.endsWith("/*")?r.startsWith("".concat(e.replace("/*",""),"/")):r===e})||(ie("File type not accepted. Please upload: ".concat(k)),!1)}(e)&&function(e){return!(y&&e.size>y&&(ie("File size exceeds the maximum limit of ".concat(me(y))),1))}(e)&&(V(e),ne("idle"),Y(0))},be=function(){var e=n(r().m(function e(n){var o,t,i,l,a,s,u,d;return r().w(function(e){for(;;)switch(e.p=e.n){case 0:if(M&&E){e.n=1;break}return e.a(2,null);case 1:return e.p=1,t=JSON.stringify({file_url:n.location,file_key:n.key,file_name:n.title,file_size:n.size,content_type:n.content_type,media_type:null!==(o=n.content_type)&&void 0!==o&&o.startsWith("video/")?"video":"image"}),i=c("POST",t,E,"json"),e.n=2,fetch(M,i);case 2:if(!(l=e.v).ok){e.n=4;break}return e.n=3,l.json();case 3:return a=e.v,e.a(2,a.id);case 4:return s=console,u=l.status,e.n=5,l.text();case 5:s.error.call(s,"Save to DB failed:",u,e.v),e.n=7;break;case 6:e.p=6,d=e.v,console.error("Save to DB error:",d);case 7:return e.a(2,null)}},e,null,[[1,6]])}));return function(n){return e.apply(this,arguments)}}(),ge=function(){var e=n(r().m(function e(n){var o,t,i;return r().w(function(e){for(;;)switch(e.p=e.n){case 0:if(U&&E){e.n=1;break}return e.a(2,!1);case 1:return e.p=1,o=c("DELETE",null,E),e.n=2,fetch("".concat(U).concat(n,"/"),o);case 2:return t=e.v,e.a(2,t.ok||404===t.status);case 3:return e.p=3,i=e.v,console.error("DB delete error:",i),e.a(2,!1)}},e,null,[[1,3]])}));return function(n){return e.apply(this,arguments)}}(),ke=function(){var e=n(r().m(function e(n){var o,t;return r().w(function(e){for(;;)switch(e.p=e.n){case 0:if(o=se[n]){e.n=1;break}return e.a(2);case 1:if(!o.dbId||!U){e.n=2;break}return e.n=2,ge(o.dbId);case 2:if(!T){e.n=6;break}return e.p=3,e.n=4,T(o.response);case 4:e.n=6;break;case 5:e.p=5,t=e.v,console.error("File delete error:",t);case 6:ce(function(e){return e.filter(function(e,r){return r!==n})}),R&&R(o.response),u("File removed");case 7:return e.a(2)}},e,null,[[3,5]])}));return function(n){return e.apply(this,arguments)}}(),we=function(){var e=n(r().m(function e(){var n,t,i,l,a;return r().w(function(e){for(;;)switch(e.p=e.n){case 0:if(I){e.n=1;break}return ie("Please select a file first"),e.a(2);case 1:if(ne("uploading"),ie(""),S){e.n=2;break}return console.error(p),ne("error"),ie("Uploads are not configured."),e.a(2);case 2:return e.p=2,e.n=3,d(I,S,Y);case 3:if(n=e.v,Y(100),ne("success"),u("File Uploaded Successfully!"),t={title:I.name,key:n.key,content_type:n.contentType,size:I.size,location:n.cdnUrl},!M||!E){e.n=5;break}return e.n=4,be(t);case 4:(l=e.v)&&(i=l);case 5:ce(function(e){return[].concat(o(e),[{response:t,dbId:i}])}),W&&W(t),z&&z(N,t.key),P&&P(L,N,t.key),_&&_(L,j,N,t.key),setTimeout(function(){V(null),ne("idle"),Y(0)},2e3),e.n=7;break;case 6:e.p=6,a=e.v,console.error("Upload error:",a),ne("error"),ie("Error uploading file. Please try again."),u("Error uploading file!",400),Y(0);case 7:return e.a(2)}},e,null,[[2,6]])}));return function(){return e.apply(this,arguments)}}(),ye=function(){V(null),ne("idle"),Y(0),ie("")};return t("div",{className:"ihub-uploader ".concat(F),children:[m&&i("h3",{className:"ihub-uploader-header",children:m}),t("div",{className:"ihub-uploader-container",children:[!I&&t("div",{className:"ihub-uploader-dropzone ".concat(J?"ihub-uploader-dropzone-active":""),onDragOver:function(e){e.preventDefault(),e.stopPropagation(),K(!0)},onDragLeave:function(e){e.preventDefault(),e.stopPropagation(),K(!1)},onDrop:function(e){e.preventDefault(),e.stopPropagation(),K(!1);var n=e.dataTransfer.files;n&&n.length>0&&fe(n[0])},onClick:function(){var e;null===(e=ve.current)||void 0===e||e.click()},children:[i("div",{className:"ihub-uploader-icon",children:t("svg",{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),i("polyline",{points:"17 8 12 3 7 8"}),i("line",{x1:"12",y1:"3",x2:"12",y2:"15"})]})}),i("p",{className:"ihub-uploader-text",children:b}),i("p",{className:"ihub-uploader-hint",children:y>0&&"Maximum file size: ".concat(me(y))}),i("input",{ref:ve,type:"file",accept:k,onChange:function(e){var n=e.target.files;n&&n.length>0&&fe(n[0])},className:"ihub-uploader-input"})]}),I&&t("div",{className:"ihub-uploader-preview",children:[t("div",{className:"ihub-uploader-file-info",children:[i("div",{className:"ihub-uploader-file-icon",children:I.type.startsWith("image/")?i("img",{src:URL.createObjectURL(I),alt:I.name,className:"ihub-uploader-thumbnail"}):t("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),i("polyline",{points:"14 2 14 8 20 8"}),i("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),i("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),i("polyline",{points:"10 9 9 9 8 9"})]})}),t("div",{className:"ihub-uploader-file-details",children:[i("p",{className:"ihub-uploader-file-name",children:I.name}),i("p",{className:"ihub-uploader-file-size",children:me(I.size)})]})]}),"uploading"===ee&&i("div",{className:"ihub-uploader-progress",children:i("div",{className:"ihub-uploader-progress-bar",style:{width:"".concat(X,"%")},children:t("span",{className:"ihub-uploader-progress-text",children:[X,"%"]})})}),t("div",{className:"ihub-uploader-actions",children:["idle"===ee&&t(l,{children:[i("button",{className:"ihub-uploader-upload-btn ihub-important-btn",onClick:we,children:"Upload"}),i("button",{className:"ihub-uploader-cancel-btn outlined-btn",onClick:ye,children:"Cancel"})]}),"uploading"===ee&&i("button",{className:"ihub-uploader-cancel-btn outlined-btn",onClick:ye,children:"Cancel"}),"success"===ee&&t("div",{className:"ihub-uploader-success",children:[t("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),i("polyline",{points:"22 4 12 14.01 9 11.01"})]}),i("span",{children:"Upload Complete"})]}),"error"===ee&&t(l,{children:[i("button",{className:"ihub-uploader-retry-btn ihub-important-btn",onClick:we,children:"Retry"}),i("button",{className:"ihub-uploader-cancel-btn outlined-btn",onClick:ye,children:"Cancel"})]})]})]}),se.length>0&&i("div",{className:"ihub-uploader-thumbs",children:se.map(function(e,n){var r,o=null===(r=e.response.content_type)||void 0===r?void 0:r.startsWith("video/");return t("div",{className:"ihub-uploader-thumb",children:[t("div",{className:"ihub-uploader-thumb-preview",onClick:function(){return he(n)},title:"Click to preview",children:[o?i("video",{src:e.response.location,muted:!0}):i("img",{src:e.response.location,alt:e.response.title}),o&&i("span",{className:"ihub-uploader-thumb-badge",children:i("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor",children:i("polygon",{points:"5 3 19 12 5 21 5 3"})})})]}),i("button",{type:"button",className:"ihub-uploader-thumb-remove",onClick:function(e){e.stopPropagation(),ke(n)},title:"Remove",children:t("svg",{xmlns:"http://www.w3.org/2000/svg",width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[i("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),i("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},n)})}),null!==pe&&se[pe]&&i("div",{className:"ihub-uploader-lightbox",onClick:function(){return he(null)},children:t("div",{className:"ihub-uploader-lightbox-content",onClick:function(e){return e.stopPropagation()},children:[i("button",{className:"ihub-uploader-lightbox-close",onClick:function(){return he(null)},children:t("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),i("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}),pe>0&&i("button",{className:"ihub-uploader-lightbox-nav ihub-uploader-lightbox-prev",onClick:function(){return he(pe-1)},children:i("svg",{xmlns:"http://www.w3.org/2000/svg",width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:i("polyline",{points:"15 18 9 12 15 6"})})}),i("div",{className:"ihub-uploader-lightbox-media",children:null!==(v=se[pe].response.content_type)&&void 0!==v&&v.startsWith("video/")?i("video",{src:se[pe].response.location,controls:!0,autoPlay:!0}):i("img",{src:se[pe].response.location,alt:se[pe].response.title})}),pe<se.length-1&&i("button",{className:"ihub-uploader-lightbox-nav ihub-uploader-lightbox-next",onClick:function(){return he(pe+1)},children:i("svg",{xmlns:"http://www.w3.org/2000/svg",width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:i("polyline",{points:"9 18 15 12 9 6"})})}),t("div",{className:"ihub-uploader-lightbox-info",children:[i("span",{children:se[pe].response.title}),t("span",{children:[pe+1," / ",se.length]})]})]})}),te&&t("div",{className:"ihub-uploader-error",children:[t("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i("circle",{cx:"12",cy:"12",r:"10"}),i("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),i("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),i("span",{children:te})]})]})]})}export{h as default};
2
2
  //# sourceMappingURL=IhubFileUploader.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_rollupPluginBabelHelpers.cjs"),r=require("react/jsx-runtime"),t=require("react"),n=require("../../lib/modals/modals.cjs"),s=function(e){return e<1048576?"".concat((e/1024).toFixed(0)," KB"):"".concat((e/1048576).toFixed(1)," MB")},i=function(){return r.jsxs("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("polyline",{points:"16 16 12 12 8 16"}),r.jsx("line",{x1:"12",y1:"12",x2:"12",y2:"21"}),r.jsx("path",{d:"M20.39 18.39A5 5 0 0 0 18 9h-1.26A8 8 0 1 0 3 16.3"})]})},o=function(){return r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"11",cy:"11",r:"8"}),r.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})},a=function(){return r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"spin",children:[r.jsx("line",{x1:"12",y1:"2",x2:"12",y2:"6"}),r.jsx("line",{x1:"12",y1:"18",x2:"12",y2:"22"}),r.jsx("line",{x1:"4.93",y1:"4.93",x2:"7.76",y2:"7.76"}),r.jsx("line",{x1:"16.24",y1:"16.24",x2:"19.07",y2:"19.07"}),r.jsx("line",{x1:"2",y1:"12",x2:"6",y2:"12"}),r.jsx("line",{x1:"18",y1:"12",x2:"22",y2:"12"}),r.jsx("line",{x1:"4.93",y1:"19.07",x2:"7.76",y2:"16.24"}),r.jsx("line",{x1:"16.24",y1:"7.76",x2:"19.07",y2:"4.93"})]})},u=function(){return r.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("polyline",{points:"20 6 9 17 4 12"})})},l=function(){return r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"12",cy:"12",r:"10"}),r.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),r.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]})},c=function(e){var t=e.size,n=void 0===t?13:t;return r.jsxs("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})};function d(r,t,n,s){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};return new Promise(function(o,a){var u=new XMLHttpRequest;u.upload.onprogress=function(e){e.lengthComputable&&s(Math.round(e.loaded/e.total*100))},u.onload=function(){u.status>=200&&u.status<300?o():a(new Error("Upload failed: HTTP ".concat(u.status)))},u.onerror=function(){return a(new Error("Network error during upload"))},u.ontimeout=function(){return a(new Error("Upload timed out"))},u.open("PUT",r),u.setRequestHeader("Content-Type",n),Object.entries(i).filter(function(r){return"content-type"!==e.slicedToArray(r,1)[0].toLowerCase()}).forEach(function(r){var t=e.slicedToArray(r,2),n=t[0],s=t[1];return u.setRequestHeader(n,s)}),u.send(t)})}exports.default=function(m){var f=m.accepts,x=m.maxFileSizeBytes,p=void 0===x?524288e3:x,h=m.maxFiles,j=m.concurrency,v=void 0===j?1:j,y=m.getPresignedUrl,g=m.label,k=void 0===g?"Drop files here or click to browse":g,b=m.hint,w=m.onFileComplete,N=m.onQueueComplete,C=m.onError,L=m.disabled,T=void 0!==L&&L,q=m.className,A=void 0===q?"":q,B=t.useState([]),M=e.slicedToArray(B,2),U=M[0],z=M[1],D=t.useState(!1),F=e.slicedToArray(D,2),R=F[0],E=F[1],P=t.useState(""),S=e.slicedToArray(P,2),W=S[0],H=S[1],_=t.useRef(null),O=t.useRef(0),G=t.useRef([]);G.current=U;var Q=Math.min(Math.max(v,1),4),I=t.useCallback(function(r,t){var n=function(n){return n.map(function(n){return n.id===r?e.objectSpread2(e.objectSpread2({},n),t):n})};G.current=n(G.current),z(n)},[]),K=t.useCallback(function(){var r=e.asyncToGenerator(e.regenerator().m(function r(t){var n,s,i,o,a,u,l,c,m;return e.regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:return I(t.id,{status:"uploading",progress:0}),e.p=1,e.n=2,y(t.file);case 2:return n=e.v,s=n.url,i=n.key,o=n.cdnUrl,a=n.contentType,u=n.headers,e.n=3,d(s,t.file,a,function(e){I(t.id,{progress:e})},u);case 3:l={title:t.file.name,key:i,content_type:a,size:t.file.size,location:o},I(t.id,{status:"complete",progress:100}),w(l),e.n=5;break;case 4:e.p=4,m=e.v,c=m instanceof Error?m.message:"Upload failed",I(t.id,{status:"error",error:c}),null==C||C(t.file.name,c);case 5:return e.a(2)}},r,null,[[1,4]])}));return function(e){return r.apply(this,arguments)}}(),[y,I,w,C]),X=t.useCallback(e.asyncToGenerator(e.regenerator().m(function r(){var t;return e.regenerator().w(function(e){for(;;)switch(e.n){case 0:if(!(O.current>=Q)){e.n=1;break}return e.a(2);case 1:if(t=G.current.find(function(e){return"queued"===e.status})){e.n=2;break}return 0===O.current&&G.current.length>0&&G.current.every(function(e){return"complete"===e.status||"error"===e.status})&&(null==N||N()),e.a(2);case 2:return O.current+=1,e.n=3,K(t);case 3:O.current-=1,X();case 4:return e.a(2)}},r)})),[Q,K,N]),J=t.useCallback(function(r){var t=r.filter(function(e){return e.size<=p});if(h&&h>0){var s=G.current.length,i=h-s;if(i<=0)return void n.openToast("Maximum ".concat(h," file").concat(1!==h?"s":""," allowed"),400);t.length>i&&(n.openToast("Only ".concat(i," more file").concat(1!==i?"s":""," allowed (limit: ").concat(h,"). First ").concat(i," selected."),400),t=t.slice(0,i))}if(t.length){var o=t.map(function(e){return{id:crypto.randomUUID(),file:e,status:"queued",progress:0}});z(function(r){var t=[].concat(e.toConsumableArray(r),e.toConsumableArray(o));G.current=t;for(var n=0;n<Q;n++)setTimeout(X,0);return t})}},[p,h,Q,X]),V=U.filter(function(e){return"complete"===e.status}).length,Y=U.some(function(e){return"uploading"===e.status||"queued"===e.status}),Z=W?U.filter(function(e){return e.file.name.toLowerCase().includes(W.toLowerCase())}):U;return r.jsxs("div",{className:"s3mu-root".concat(T?" s3mu-disabled":""," ").concat(A).trim(),children:[r.jsxs("div",{className:"s3mu-dropzone".concat(R?" dragging":""),onDragOver:function(e){e.preventDefault(),T||E(!0)},onDragLeave:function(){return E(!1)},onDrop:function(e){e.preventDefault(),E(!1),T||J(Array.from(e.dataTransfer.files))},onClick:function(){var e;return!T&&(null===(e=_.current)||void 0===e?void 0:e.click())},children:[r.jsx("input",{ref:_,type:"file",accept:f,multiple:!0,disabled:T,style:{display:"none"},onChange:function(e){e.target.files&&J(Array.from(e.target.files)),e.target.value=""}}),r.jsx("div",{className:"s3mu-drop-icon",children:r.jsx(i,{})}),r.jsx("p",{className:"s3mu-drop-label",children:k}),b&&r.jsx("p",{className:"s3mu-drop-hint",children:b}),r.jsxs("p",{className:"s3mu-drop-hint",children:["Max ",s(p)," per file"]}),h&&h>0&&r.jsxs("span",{className:"s3mu-maxfiles-badge",children:["Up to ",h," file",1!==h?"s":""]})]}),U.length>0&&r.jsxs("div",{className:"s3mu-queue",children:[r.jsxs("div",{className:"s3mu-queue-header",children:[r.jsx("span",{children:W&&Z.length!==U.length?"".concat(Z.length," of ").concat(U.length," file").concat(1!==U.length?"s":""):"".concat(U.length," file").concat(1!==U.length?"s":"")}),V>0&&!Y&&r.jsx("button",{type:"button",className:"s3mu-clear-btn",onClick:function(){z(function(e){return e.filter(function(e){return"complete"!==e.status})})},children:"Clear completed"})]}),U.length>=5&&r.jsxs("div",{className:"s3mu-filter",children:[r.jsx(o,{}),r.jsx("input",{type:"text",placeholder:"Filter files…",value:W,onChange:function(e){return H(e.target.value)}})]}),Z.map(function(e){return r.jsxs("div",{className:"s3mu-item s3mu-item--".concat(e.status),children:[r.jsxs("div",{className:"s3mu-item-icon",children:["complete"===e.status&&r.jsx(u,{}),"error"===e.status&&r.jsx(l,{}),"uploading"===e.status&&r.jsx(a,{}),"queued"===e.status&&r.jsx("div",{className:"s3mu-queued-dot"})]}),r.jsxs("div",{className:"s3mu-item-body",children:[r.jsxs("div",{className:"s3mu-item-name-row",children:[r.jsx("span",{className:"s3mu-item-name",title:e.file.name,children:e.file.name}),r.jsx("span",{className:"s3mu-item-size",children:s(e.file.size)})]}),("uploading"===e.status||"complete"===e.status)&&r.jsx("div",{className:"s3mu-bar-wrap",children:r.jsx("div",{className:"s3mu-bar-fill",style:{width:"".concat(e.progress,"%")}})}),"uploading"===e.status&&r.jsxs("span",{className:"s3mu-item-pct",children:[e.progress,"%"]}),"error"===e.status&&r.jsx("span",{className:"s3mu-item-err",children:e.error}),"queued"===e.status&&r.jsx("span",{className:"s3mu-item-pct",style:{opacity:.5},children:"Queued"})]}),"uploading"!==e.status&&r.jsx("button",{type:"button",className:"s3mu-item-remove",onClick:function(){return r=e.id,void z(function(e){return e.filter(function(e){return e.id!==r})});var r},title:"Remove",children:r.jsx(c,{})})]},e.id)})]})]})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_rollupPluginBabelHelpers.cjs"),r=require("react/jsx-runtime"),n=require("react"),t=require("../../lib/modals/modals.cjs"),s=require("./presignedPut.cjs"),i=function(e){return e<1048576?"".concat((e/1024).toFixed(0)," KB"):"".concat((e/1048576).toFixed(1)," MB")},o=function(){return r.jsxs("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("polyline",{points:"16 16 12 12 8 16"}),r.jsx("line",{x1:"12",y1:"12",x2:"12",y2:"21"}),r.jsx("path",{d:"M20.39 18.39A5 5 0 0 0 18 9h-1.26A8 8 0 1 0 3 16.3"})]})},a=function(){return r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"11",cy:"11",r:"8"}),r.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})},l=function(){return r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"spin",children:[r.jsx("line",{x1:"12",y1:"2",x2:"12",y2:"6"}),r.jsx("line",{x1:"12",y1:"18",x2:"12",y2:"22"}),r.jsx("line",{x1:"4.93",y1:"4.93",x2:"7.76",y2:"7.76"}),r.jsx("line",{x1:"16.24",y1:"16.24",x2:"19.07",y2:"19.07"}),r.jsx("line",{x1:"2",y1:"12",x2:"6",y2:"12"}),r.jsx("line",{x1:"18",y1:"12",x2:"22",y2:"12"}),r.jsx("line",{x1:"4.93",y1:"19.07",x2:"7.76",y2:"16.24"}),r.jsx("line",{x1:"16.24",y1:"7.76",x2:"19.07",y2:"4.93"})]})},c=function(){return r.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("polyline",{points:"20 6 9 17 4 12"})})},u=function(){return r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"12",cy:"12",r:"10"}),r.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),r.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]})},d=function(e){var n=e.size,t=void 0===n?13:n;return r.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})};exports.default=function(m){var x=m.accepts,f=m.maxFileSizeBytes,p=void 0===f?524288e3:f,h=m.maxFiles,j=m.concurrency,v=void 0===j?1:j,y=m.getPresignedUrl,g=m.label,k=void 0===g?"Drop files here or click to browse":g,b=m.hint,N=m.onFileComplete,w=m.onQueueComplete,C=m.onError,L=m.disabled,q=void 0!==L&&L,T=m.className,B=void 0===T?"":T,A=n.useState([]),z=e.slicedToArray(A,2),D=z[0],F=z[1],M=n.useState(!1),U=e.slicedToArray(M,2),S=U[0],W=U[1],P=n.useState(""),_=e.slicedToArray(P,2),R=_[0],O=_[1],E=n.useRef(null),G=n.useRef(0),Q=n.useRef([]);Q.current=D;var H=Math.min(Math.max(v,1),4),I=n.useCallback(function(r,n){var t=function(t){return t.map(function(t){return t.id===r?e.objectSpread2(e.objectSpread2({},t),n):t})};Q.current=t(Q.current),F(t)},[]),K=n.useCallback(function(){var r=e.asyncToGenerator(e.regenerator().m(function r(n){var t,i,o,a,l,c,u,d,m;return e.regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:return I(n.id,{status:"uploading",progress:0}),e.p=1,e.n=2,y(n.file);case 2:return t=e.v,i=t.url,o=t.key,a=t.cdnUrl,l=t.contentType,c=t.headers,e.n=3,s.uploadToPresignedUrl(i,n.file,l,function(e){I(n.id,{progress:e})},c);case 3:u={title:n.file.name,key:o,content_type:l,size:n.file.size,location:a},I(n.id,{status:"complete",progress:100}),N(u),e.n=5;break;case 4:e.p=4,m=e.v,d=m instanceof Error?m.message:"Upload failed",I(n.id,{status:"error",error:d}),null==C||C(n.file.name,d);case 5:return e.a(2)}},r,null,[[1,4]])}));return function(e){return r.apply(this,arguments)}}(),[y,I,N,C]),J=n.useCallback(e.asyncToGenerator(e.regenerator().m(function r(){var n;return e.regenerator().w(function(e){for(;;)switch(e.n){case 0:if(!(G.current>=H)){e.n=1;break}return e.a(2);case 1:if(n=Q.current.find(function(e){return"queued"===e.status})){e.n=2;break}return 0===G.current&&Q.current.length>0&&Q.current.every(function(e){return"complete"===e.status||"error"===e.status})&&(null==w||w()),e.a(2);case 2:return G.current+=1,e.n=3,K(n);case 3:G.current-=1,J();case 4:return e.a(2)}},r)})),[H,K,w]),V=n.useCallback(function(r){var n=r.filter(function(e){return e.size<=p});if(h&&h>0){var s=Q.current.length,i=h-s;if(i<=0)return void t.openToast("Maximum ".concat(h," file").concat(1!==h?"s":""," allowed"),400);n.length>i&&(t.openToast("Only ".concat(i," more file").concat(1!==i?"s":""," allowed (limit: ").concat(h,"). First ").concat(i," selected."),400),n=n.slice(0,i))}if(n.length){var o=n.map(function(e){return{id:crypto.randomUUID(),file:e,status:"queued",progress:0}});F(function(r){var n=[].concat(e.toConsumableArray(r),e.toConsumableArray(o));Q.current=n;for(var t=0;t<H;t++)setTimeout(J,0);return n})}},[p,h,H,J]),X=D.filter(function(e){return"complete"===e.status}).length,Y=D.some(function(e){return"uploading"===e.status||"queued"===e.status}),Z=R?D.filter(function(e){return e.file.name.toLowerCase().includes(R.toLowerCase())}):D;return r.jsxs("div",{className:"s3mu-root".concat(q?" s3mu-disabled":""," ").concat(B).trim(),children:[r.jsxs("div",{className:"s3mu-dropzone".concat(S?" dragging":""),onDragOver:function(e){e.preventDefault(),q||W(!0)},onDragLeave:function(){return W(!1)},onDrop:function(e){e.preventDefault(),W(!1),q||V(Array.from(e.dataTransfer.files))},onClick:function(){var e;return!q&&(null===(e=E.current)||void 0===e?void 0:e.click())},children:[r.jsx("input",{ref:E,type:"file",accept:x,multiple:!0,disabled:q,style:{display:"none"},onChange:function(e){e.target.files&&V(Array.from(e.target.files)),e.target.value=""}}),r.jsx("div",{className:"s3mu-drop-icon",children:r.jsx(o,{})}),r.jsx("p",{className:"s3mu-drop-label",children:k}),b&&r.jsx("p",{className:"s3mu-drop-hint",children:b}),r.jsxs("p",{className:"s3mu-drop-hint",children:["Max ",i(p)," per file"]}),h&&h>0&&r.jsxs("span",{className:"s3mu-maxfiles-badge",children:["Up to ",h," file",1!==h?"s":""]})]}),D.length>0&&r.jsxs("div",{className:"s3mu-queue",children:[r.jsxs("div",{className:"s3mu-queue-header",children:[r.jsx("span",{children:R&&Z.length!==D.length?"".concat(Z.length," of ").concat(D.length," file").concat(1!==D.length?"s":""):"".concat(D.length," file").concat(1!==D.length?"s":"")}),X>0&&!Y&&r.jsx("button",{type:"button",className:"s3mu-clear-btn",onClick:function(){F(function(e){return e.filter(function(e){return"complete"!==e.status})})},children:"Clear completed"})]}),D.length>=5&&r.jsxs("div",{className:"s3mu-filter",children:[r.jsx(a,{}),r.jsx("input",{type:"text",placeholder:"Filter files…",value:R,onChange:function(e){return O(e.target.value)}})]}),Z.map(function(e){return r.jsxs("div",{className:"s3mu-item s3mu-item--".concat(e.status),children:[r.jsxs("div",{className:"s3mu-item-icon",children:["complete"===e.status&&r.jsx(c,{}),"error"===e.status&&r.jsx(u,{}),"uploading"===e.status&&r.jsx(l,{}),"queued"===e.status&&r.jsx("div",{className:"s3mu-queued-dot"})]}),r.jsxs("div",{className:"s3mu-item-body",children:[r.jsxs("div",{className:"s3mu-item-name-row",children:[r.jsx("span",{className:"s3mu-item-name",title:e.file.name,children:e.file.name}),r.jsx("span",{className:"s3mu-item-size",children:i(e.file.size)})]}),("uploading"===e.status||"complete"===e.status)&&r.jsx("div",{className:"s3mu-bar-wrap",children:r.jsx("div",{className:"s3mu-bar-fill",style:{width:"".concat(e.progress,"%")}})}),"uploading"===e.status&&r.jsxs("span",{className:"s3mu-item-pct",children:[e.progress,"%"]}),"error"===e.status&&r.jsx("span",{className:"s3mu-item-err",children:e.error}),"queued"===e.status&&r.jsx("span",{className:"s3mu-item-pct",style:{opacity:.5},children:"Queued"})]}),"uploading"!==e.status&&r.jsx("button",{type:"button",className:"s3mu-item-remove",onClick:function(){return r=e.id,void F(function(e){return e.filter(function(e){return e.id!==r})});var r},title:"Remove",children:r.jsx(d,{})})]},e.id)})]})]})};
2
2
  //# sourceMappingURL=S3MultiUploader.cjs.map
@@ -1,2 +1,2 @@
1
- import{slicedToArray as e,asyncToGenerator as n,toConsumableArray as t,objectSpread2 as r,regenerator as i}from"../../../../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as o,jsx as s}from"react/jsx-runtime";import{useState as a,useRef as u,useCallback as l}from"react";import{openToast as c}from"../../lib/modals/modals.js";var d=function(e){return e<1048576?"".concat((e/1024).toFixed(0)," KB"):"".concat((e/1048576).toFixed(1)," MB")},m=function(){return o("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s("polyline",{points:"16 16 12 12 8 16"}),s("line",{x1:"12",y1:"12",x2:"12",y2:"21"}),s("path",{d:"M20.39 18.39A5 5 0 0 0 18 9h-1.26A8 8 0 1 0 3 16.3"})]})},f=function(){return o("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s("circle",{cx:"11",cy:"11",r:"8"}),s("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})},p=function(){return o("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"spin",children:[s("line",{x1:"12",y1:"2",x2:"12",y2:"6"}),s("line",{x1:"12",y1:"18",x2:"12",y2:"22"}),s("line",{x1:"4.93",y1:"4.93",x2:"7.76",y2:"7.76"}),s("line",{x1:"16.24",y1:"16.24",x2:"19.07",y2:"19.07"}),s("line",{x1:"2",y1:"12",x2:"6",y2:"12"}),s("line",{x1:"18",y1:"12",x2:"22",y2:"12"}),s("line",{x1:"4.93",y1:"19.07",x2:"7.76",y2:"16.24"}),s("line",{x1:"16.24",y1:"7.76",x2:"19.07",y2:"4.93"})]})},h=function(){return s("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:s("polyline",{points:"20 6 9 17 4 12"})})},v=function(){return o("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s("circle",{cx:"12",cy:"12",r:"10"}),s("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),s("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]})},g=function(e){var n=e.size,t=void 0===n?13:n;return o("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[s("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),s("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})};function y(n,t,r,i){var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};return new Promise(function(s,a){var u=new XMLHttpRequest;u.upload.onprogress=function(e){e.lengthComputable&&i(Math.round(e.loaded/e.total*100))},u.onload=function(){u.status>=200&&u.status<300?s():a(new Error("Upload failed: HTTP ".concat(u.status)))},u.onerror=function(){return a(new Error("Network error during upload"))},u.ontimeout=function(){return a(new Error("Upload timed out"))},u.open("PUT",n),u.setRequestHeader("Content-Type",r),Object.entries(o).filter(function(n){return"content-type"!==e(n,1)[0].toLowerCase()}).forEach(function(n){var t=e(n,2),r=t[0],i=t[1];return u.setRequestHeader(r,i)}),u.send(t)})}function x(x){var k=x.accepts,w=x.maxFileSizeBytes,N=void 0===w?524288e3:w,b=x.maxFiles,C=x.concurrency,L=void 0===C?1:C,j=x.getPresignedUrl,q=x.label,B=void 0===q?"Drop files here or click to browse":q,T=x.hint,U=x.onFileComplete,z=x.onQueueComplete,M=x.onError,D=x.disabled,F=void 0!==D&&D,A=x.className,E=void 0===A?"":A,W=a([]),H=e(W,2),P=H[0],R=H[1],O=a(!1),_=e(O,2),Q=_[0],S=_[1],G=a(""),I=e(G,2),K=I[0],X=I[1],J=u(null),V=u(0),Y=u([]);Y.current=P;var Z=Math.min(Math.max(L,1),4),$=l(function(e,n){var t=function(t){return t.map(function(t){return t.id===e?r(r({},t),n):t})};Y.current=t(Y.current),R(t)},[]),ee=l(function(){var e=n(i().m(function e(n){var t,r,o,s,a,u,l,c,d;return i().w(function(e){for(;;)switch(e.p=e.n){case 0:return $(n.id,{status:"uploading",progress:0}),e.p=1,e.n=2,j(n.file);case 2:return t=e.v,r=t.url,o=t.key,s=t.cdnUrl,a=t.contentType,u=t.headers,e.n=3,y(r,n.file,a,function(e){$(n.id,{progress:e})},u);case 3:l={title:n.file.name,key:o,content_type:a,size:n.file.size,location:s},$(n.id,{status:"complete",progress:100}),U(l),e.n=5;break;case 4:e.p=4,d=e.v,c=d instanceof Error?d.message:"Upload failed",$(n.id,{status:"error",error:c}),null==M||M(n.file.name,c);case 5:return e.a(2)}},e,null,[[1,4]])}));return function(n){return e.apply(this,arguments)}}(),[j,$,U,M]),ne=l(n(i().m(function e(){var n;return i().w(function(e){for(;;)switch(e.n){case 0:if(!(V.current>=Z)){e.n=1;break}return e.a(2);case 1:if(n=Y.current.find(function(e){return"queued"===e.status})){e.n=2;break}return 0===V.current&&Y.current.length>0&&Y.current.every(function(e){return"complete"===e.status||"error"===e.status})&&(null==z||z()),e.a(2);case 2:return V.current+=1,e.n=3,ee(n);case 3:V.current-=1,ne();case 4:return e.a(2)}},e)})),[Z,ee,z]),te=l(function(e){var n=e.filter(function(e){return e.size<=N});if(b&&b>0){var r=Y.current.length,i=b-r;if(i<=0)return void c("Maximum ".concat(b," file").concat(1!==b?"s":""," allowed"),400);n.length>i&&(c("Only ".concat(i," more file").concat(1!==i?"s":""," allowed (limit: ").concat(b,"). First ").concat(i," selected."),400),n=n.slice(0,i))}if(n.length){var o=n.map(function(e){return{id:crypto.randomUUID(),file:e,status:"queued",progress:0}});R(function(e){var n=[].concat(t(e),t(o));Y.current=n;for(var r=0;r<Z;r++)setTimeout(ne,0);return n})}},[N,b,Z,ne]),re=P.filter(function(e){return"complete"===e.status}).length,ie=P.some(function(e){return"uploading"===e.status||"queued"===e.status}),oe=K?P.filter(function(e){return e.file.name.toLowerCase().includes(K.toLowerCase())}):P;return o("div",{className:"s3mu-root".concat(F?" s3mu-disabled":""," ").concat(E).trim(),children:[o("div",{className:"s3mu-dropzone".concat(Q?" dragging":""),onDragOver:function(e){e.preventDefault(),F||S(!0)},onDragLeave:function(){return S(!1)},onDrop:function(e){e.preventDefault(),S(!1),F||te(Array.from(e.dataTransfer.files))},onClick:function(){var e;return!F&&(null===(e=J.current)||void 0===e?void 0:e.click())},children:[s("input",{ref:J,type:"file",accept:k,multiple:!0,disabled:F,style:{display:"none"},onChange:function(e){e.target.files&&te(Array.from(e.target.files)),e.target.value=""}}),s("div",{className:"s3mu-drop-icon",children:s(m,{})}),s("p",{className:"s3mu-drop-label",children:B}),T&&s("p",{className:"s3mu-drop-hint",children:T}),o("p",{className:"s3mu-drop-hint",children:["Max ",d(N)," per file"]}),b&&b>0&&o("span",{className:"s3mu-maxfiles-badge",children:["Up to ",b," file",1!==b?"s":""]})]}),P.length>0&&o("div",{className:"s3mu-queue",children:[o("div",{className:"s3mu-queue-header",children:[s("span",{children:K&&oe.length!==P.length?"".concat(oe.length," of ").concat(P.length," file").concat(1!==P.length?"s":""):"".concat(P.length," file").concat(1!==P.length?"s":"")}),re>0&&!ie&&s("button",{type:"button",className:"s3mu-clear-btn",onClick:function(){R(function(e){return e.filter(function(e){return"complete"!==e.status})})},children:"Clear completed"})]}),P.length>=5&&o("div",{className:"s3mu-filter",children:[s(f,{}),s("input",{type:"text",placeholder:"Filter files…",value:K,onChange:function(e){return X(e.target.value)}})]}),oe.map(function(e){return o("div",{className:"s3mu-item s3mu-item--".concat(e.status),children:[o("div",{className:"s3mu-item-icon",children:["complete"===e.status&&s(h,{}),"error"===e.status&&s(v,{}),"uploading"===e.status&&s(p,{}),"queued"===e.status&&s("div",{className:"s3mu-queued-dot"})]}),o("div",{className:"s3mu-item-body",children:[o("div",{className:"s3mu-item-name-row",children:[s("span",{className:"s3mu-item-name",title:e.file.name,children:e.file.name}),s("span",{className:"s3mu-item-size",children:d(e.file.size)})]}),("uploading"===e.status||"complete"===e.status)&&s("div",{className:"s3mu-bar-wrap",children:s("div",{className:"s3mu-bar-fill",style:{width:"".concat(e.progress,"%")}})}),"uploading"===e.status&&o("span",{className:"s3mu-item-pct",children:[e.progress,"%"]}),"error"===e.status&&s("span",{className:"s3mu-item-err",children:e.error}),"queued"===e.status&&s("span",{className:"s3mu-item-pct",style:{opacity:.5},children:"Queued"})]}),"uploading"!==e.status&&s("button",{type:"button",className:"s3mu-item-remove",onClick:function(){return n=e.id,void R(function(e){return e.filter(function(e){return e.id!==n})});var n},title:"Remove",children:s(g,{})})]},e.id)})]})]})}export{x as default};
1
+ import{slicedToArray as e,asyncToGenerator as n,toConsumableArray as t,objectSpread2 as r,regenerator as i}from"../../../../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as o,jsx as s}from"react/jsx-runtime";import{useState as a,useRef as l,useCallback as c}from"react";import{openToast as u}from"../../lib/modals/modals.js";import{uploadToPresignedUrl as d}from"./presignedPut.js";var m=function(e){return e<1048576?"".concat((e/1024).toFixed(0)," KB"):"".concat((e/1048576).toFixed(1)," MB")},f=function(){return o("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s("polyline",{points:"16 16 12 12 8 16"}),s("line",{x1:"12",y1:"12",x2:"12",y2:"21"}),s("path",{d:"M20.39 18.39A5 5 0 0 0 18 9h-1.26A8 8 0 1 0 3 16.3"})]})},p=function(){return o("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s("circle",{cx:"11",cy:"11",r:"8"}),s("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})},h=function(){return o("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"spin",children:[s("line",{x1:"12",y1:"2",x2:"12",y2:"6"}),s("line",{x1:"12",y1:"18",x2:"12",y2:"22"}),s("line",{x1:"4.93",y1:"4.93",x2:"7.76",y2:"7.76"}),s("line",{x1:"16.24",y1:"16.24",x2:"19.07",y2:"19.07"}),s("line",{x1:"2",y1:"12",x2:"6",y2:"12"}),s("line",{x1:"18",y1:"12",x2:"22",y2:"12"}),s("line",{x1:"4.93",y1:"19.07",x2:"7.76",y2:"16.24"}),s("line",{x1:"16.24",y1:"7.76",x2:"19.07",y2:"4.93"})]})},v=function(){return s("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:s("polyline",{points:"20 6 9 17 4 12"})})},y=function(){return o("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s("circle",{cx:"12",cy:"12",r:"10"}),s("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),s("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]})},g=function(e){var n=e.size,t=void 0===n?13:n;return o("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[s("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),s("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})};function x(x){var k=x.accepts,N=x.maxFileSizeBytes,w=void 0===N?524288e3:N,b=x.maxFiles,C=x.concurrency,L=void 0===C?1:C,j=x.getPresignedUrl,B=x.label,q=void 0===B?"Drop files here or click to browse":B,z=x.hint,D=x.onFileComplete,F=x.onQueueComplete,A=x.onError,M=x.disabled,U=void 0!==M&&M,W=x.className,T=void 0===W?"":W,P=a([]),_=e(P,2),E=_[0],O=_[1],Q=a(!1),S=e(Q,2),G=S[0],H=S[1],I=a(""),K=e(I,2),R=K[0],J=K[1],V=l(null),X=l(0),Y=l([]);Y.current=E;var Z=Math.min(Math.max(L,1),4),$=c(function(e,n){var t=function(t){return t.map(function(t){return t.id===e?r(r({},t),n):t})};Y.current=t(Y.current),O(t)},[]),ee=c(function(){var e=n(i().m(function e(n){var t,r,o,s,a,l,c,u,m;return i().w(function(e){for(;;)switch(e.p=e.n){case 0:return $(n.id,{status:"uploading",progress:0}),e.p=1,e.n=2,j(n.file);case 2:return t=e.v,r=t.url,o=t.key,s=t.cdnUrl,a=t.contentType,l=t.headers,e.n=3,d(r,n.file,a,function(e){$(n.id,{progress:e})},l);case 3:c={title:n.file.name,key:o,content_type:a,size:n.file.size,location:s},$(n.id,{status:"complete",progress:100}),D(c),e.n=5;break;case 4:e.p=4,m=e.v,u=m instanceof Error?m.message:"Upload failed",$(n.id,{status:"error",error:u}),null==A||A(n.file.name,u);case 5:return e.a(2)}},e,null,[[1,4]])}));return function(n){return e.apply(this,arguments)}}(),[j,$,D,A]),ne=c(n(i().m(function e(){var n;return i().w(function(e){for(;;)switch(e.n){case 0:if(!(X.current>=Z)){e.n=1;break}return e.a(2);case 1:if(n=Y.current.find(function(e){return"queued"===e.status})){e.n=2;break}return 0===X.current&&Y.current.length>0&&Y.current.every(function(e){return"complete"===e.status||"error"===e.status})&&(null==F||F()),e.a(2);case 2:return X.current+=1,e.n=3,ee(n);case 3:X.current-=1,ne();case 4:return e.a(2)}},e)})),[Z,ee,F]),te=c(function(e){var n=e.filter(function(e){return e.size<=w});if(b&&b>0){var r=Y.current.length,i=b-r;if(i<=0)return void u("Maximum ".concat(b," file").concat(1!==b?"s":""," allowed"),400);n.length>i&&(u("Only ".concat(i," more file").concat(1!==i?"s":""," allowed (limit: ").concat(b,"). First ").concat(i," selected."),400),n=n.slice(0,i))}if(n.length){var o=n.map(function(e){return{id:crypto.randomUUID(),file:e,status:"queued",progress:0}});O(function(e){var n=[].concat(t(e),t(o));Y.current=n;for(var r=0;r<Z;r++)setTimeout(ne,0);return n})}},[w,b,Z,ne]),re=E.filter(function(e){return"complete"===e.status}).length,ie=E.some(function(e){return"uploading"===e.status||"queued"===e.status}),oe=R?E.filter(function(e){return e.file.name.toLowerCase().includes(R.toLowerCase())}):E;return o("div",{className:"s3mu-root".concat(U?" s3mu-disabled":""," ").concat(T).trim(),children:[o("div",{className:"s3mu-dropzone".concat(G?" dragging":""),onDragOver:function(e){e.preventDefault(),U||H(!0)},onDragLeave:function(){return H(!1)},onDrop:function(e){e.preventDefault(),H(!1),U||te(Array.from(e.dataTransfer.files))},onClick:function(){var e;return!U&&(null===(e=V.current)||void 0===e?void 0:e.click())},children:[s("input",{ref:V,type:"file",accept:k,multiple:!0,disabled:U,style:{display:"none"},onChange:function(e){e.target.files&&te(Array.from(e.target.files)),e.target.value=""}}),s("div",{className:"s3mu-drop-icon",children:s(f,{})}),s("p",{className:"s3mu-drop-label",children:q}),z&&s("p",{className:"s3mu-drop-hint",children:z}),o("p",{className:"s3mu-drop-hint",children:["Max ",m(w)," per file"]}),b&&b>0&&o("span",{className:"s3mu-maxfiles-badge",children:["Up to ",b," file",1!==b?"s":""]})]}),E.length>0&&o("div",{className:"s3mu-queue",children:[o("div",{className:"s3mu-queue-header",children:[s("span",{children:R&&oe.length!==E.length?"".concat(oe.length," of ").concat(E.length," file").concat(1!==E.length?"s":""):"".concat(E.length," file").concat(1!==E.length?"s":"")}),re>0&&!ie&&s("button",{type:"button",className:"s3mu-clear-btn",onClick:function(){O(function(e){return e.filter(function(e){return"complete"!==e.status})})},children:"Clear completed"})]}),E.length>=5&&o("div",{className:"s3mu-filter",children:[s(p,{}),s("input",{type:"text",placeholder:"Filter files…",value:R,onChange:function(e){return J(e.target.value)}})]}),oe.map(function(e){return o("div",{className:"s3mu-item s3mu-item--".concat(e.status),children:[o("div",{className:"s3mu-item-icon",children:["complete"===e.status&&s(v,{}),"error"===e.status&&s(y,{}),"uploading"===e.status&&s(h,{}),"queued"===e.status&&s("div",{className:"s3mu-queued-dot"})]}),o("div",{className:"s3mu-item-body",children:[o("div",{className:"s3mu-item-name-row",children:[s("span",{className:"s3mu-item-name",title:e.file.name,children:e.file.name}),s("span",{className:"s3mu-item-size",children:m(e.file.size)})]}),("uploading"===e.status||"complete"===e.status)&&s("div",{className:"s3mu-bar-wrap",children:s("div",{className:"s3mu-bar-fill",style:{width:"".concat(e.progress,"%")}})}),"uploading"===e.status&&o("span",{className:"s3mu-item-pct",children:[e.progress,"%"]}),"error"===e.status&&s("span",{className:"s3mu-item-err",children:e.error}),"queued"===e.status&&s("span",{className:"s3mu-item-pct",style:{opacity:.5},children:"Queued"})]}),"uploading"!==e.status&&s("button",{type:"button",className:"s3mu-item-remove",onClick:function(){return n=e.id,void O(function(e){return e.filter(function(e){return e.id!==n})});var n},title:"Remove",children:s(g,{})})]},e.id)})]})]})}export{x as default};
2
2
  //# sourceMappingURL=S3MultiUploader.js.map
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_rollupPluginBabelHelpers.cjs");function r(r,t,n,o){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};return new Promise(function(u,s){var i=new XMLHttpRequest;i.upload.onprogress=function(e){e.lengthComputable&&o(Math.round(e.loaded/e.total*100))},i.onload=function(){i.status>=200&&i.status<300?u():s(new Error("Upload failed: HTTP ".concat(i.status)))},i.onerror=function(){return s(new Error("Network error during upload"))},i.ontimeout=function(){return s(new Error("Upload timed out"))},i.open("PUT",r),i.setRequestHeader("Content-Type",n),Object.entries(a).filter(function(r){return"content-type"!==e.slicedToArray(r,1)[0].toLowerCase()}).forEach(function(r){var t=e.slicedToArray(r,2),n=t[0],o=t[1];return i.setRequestHeader(n,o)}),i.send(t)})}function t(){return(t=e.asyncToGenerator(e.regenerator().m(function t(n,o,a){var u;return e.regenerator().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,o(n);case 1:return u=e.v,e.n=2,r(u.url,n,u.contentType,a,u.headers);case 2:return e.a(2,u)}},t)}))).apply(this,arguments)}exports.UPLOADS_NOT_CONFIGURED="Uploads are not configured: pass getPresignedUrl (a function that asks your server for a presigned PUT URL).",exports.presignAndUpload=function(e,r,n){return t.apply(this,arguments)},exports.uploadToPresignedUrl=r;
2
+ //# sourceMappingURL=presignedPut.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"presignedPut.cjs","sources":["../../../../../src/components/forms/uploads/presignedPut.ts"],"sourcesContent":["import type { PresignedUploadResult } from \"@/types\";\n\n/**\n * Upload a file to a presigned PUT URL, reporting progress via XHR.\n *\n * The uploaders never hold bucket credentials: the consumer's\n * `getPresignedUrl(file)` asks its own server for a short-lived URL, and this\n * sends the bytes. `contentType` and any `headers` must match what the server\n * signed, so they are sent verbatim.\n */\nexport function uploadToPresignedUrl(\n url: string,\n file: File,\n contentType: string,\n onProgress: (pct: number) => void,\n headers: Record<string, string> = {}\n): Promise<void> {\n return new Promise((resolve, reject) => {\n const xhr = new XMLHttpRequest();\n\n xhr.upload.onprogress = (e) => {\n if (e.lengthComputable) {\n onProgress(Math.round((e.loaded / e.total) * 100));\n }\n };\n\n xhr.onload = () => {\n if (xhr.status >= 200 && xhr.status < 300) {\n resolve();\n } else {\n reject(new Error(`Upload failed: HTTP ${xhr.status}`));\n }\n };\n\n xhr.onerror = () => reject(new Error(\"Network error during upload\"));\n xhr.ontimeout = () => reject(new Error(\"Upload timed out\"));\n\n xhr.open(\"PUT\", url);\n // Use the server-validated content type, never trust file.type alone.\n xhr.setRequestHeader(\"Content-Type\", contentType);\n // Any other headers the signature covers (e.g. x-amz-acl) must match exactly.\n Object.entries(headers)\n .filter(([name]) => name.toLowerCase() !== \"content-type\")\n .forEach(([name, value]) => xhr.setRequestHeader(name, value));\n xhr.send(file);\n });\n}\n\n/** Presign with the consumer's function, then PUT. Resolves with the presign result. */\nexport async function presignAndUpload(\n file: File,\n getPresignedUrl: (file: File) => Promise<PresignedUploadResult>,\n onProgress: (pct: number) => void\n): Promise<PresignedUploadResult> {\n const presigned = await getPresignedUrl(file);\n await uploadToPresignedUrl(\n presigned.url,\n file,\n presigned.contentType,\n onProgress,\n presigned.headers\n );\n return presigned;\n}\n\nexport const UPLOADS_NOT_CONFIGURED =\n \"Uploads are not configured: pass getPresignedUrl (a function that asks your server for a presigned PUT URL).\";\n"],"names":["uploadToPresignedUrl","url","file","contentType","onProgress","headers","arguments","length","undefined","Promise","resolve","reject","xhr","XMLHttpRequest","upload","onprogress","e","lengthComputable","Math","round","loaded","total","onload","status","Error","concat","onerror","ontimeout","open","setRequestHeader","Object","entries","filter","_ref","_slicedToArray","toLowerCase","forEach","_ref3","_ref4","name","value","send","_presignAndUpload","_asyncToGenerator","_regenerator","m","_callee","getPresignedUrl","presigned","w","_context","n","v","a","apply","this","_x","_x2","_x3"],"mappings":"wIAUgB,SAAAA,EACdC,EACAC,EACAC,EACAC,GACoC,IAApCC,EAAAC,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GAAkC,CAAA,EAElC,OAAO,IAAIG,QAAQ,SAACC,EAASC,GAC3B,IAAMC,EAAM,IAAIC,eAEhBD,EAAIE,OAAOC,WAAa,SAACC,GACnBA,EAAEC,kBACJb,EAAWc,KAAKC,MAAOH,EAAEI,OAASJ,EAAEK,MAAS,OAIjDT,EAAIU,OAAS,WACPV,EAAIW,QAAU,KAAOX,EAAIW,OAAS,IACpCb,IAEAC,EAAO,IAAIa,MAAKC,uBAAAA,OAAwBb,EAAIW,WAIhDX,EAAIc,QAAU,WAAA,OAAMf,EAAO,IAAIa,MAAM,+BAA+B,EACpEZ,EAAIe,UAAY,WAAA,OAAMhB,EAAO,IAAIa,MAAM,oBAAoB,EAE3DZ,EAAIgB,KAAK,MAAO3B,GAEhBW,EAAIiB,iBAAiB,eAAgB1B,GAErC2B,OAAOC,QAAQ1B,GACZ2B,OAAO,SAAAC,GAAM,MAA6B,iBAAnCC,EAAAA,cAAAD,EAAA,GAAM,GAAWE,aAAgC,GACxDC,QAAQ,SAAAC,GAAA,IAAAC,EAAAJ,EAAAA,cAAAG,EAAA,GAAEE,EAAID,EAAA,GAAEE,EAAKF,EAAA,GAAA,OAAM1B,EAAIiB,iBAAiBU,EAAMC,KACzD5B,EAAI6B,KAAKvC,EACX,EACF,CAiBC,SAAAwC,IAAA,OAAAA,EAAAC,EAAAA,iBAAAC,EAAAA,cAAAC,EAdM,SAAAC,EACL5C,EACA6C,EACA3C,GAAiC,IAAA4C,EAAA,OAAAJ,gBAAAK,EAAA,SAAAC,GAAA,cAAAA,EAAAC,GAAA,KAAA,EAAA,OAAAD,EAAAC,EAAA,EAETJ,EAAgB7C,GAAK,KAAA,EAA9B,OAAT8C,EAASE,EAAAE,EAAAF,EAAAC,EAAA,EACTnD,EACJgD,EAAU/C,IACVC,EACA8C,EAAU7C,YACVC,EACA4C,EAAU3C,SACX,KAAA,EAAA,OAAA6C,EAAAG,EAAA,EACML,GAAS,EAAAF,EACjB,KAAAQ,MAAAC,KAAAjD,UAAA,gCAGC,wIAjBF,SAAsCkD,EAAAC,EAAAC,GAAA,OAAAhB,EAAAY,MAAAC,KAAAjD,UAAA"}
@@ -0,0 +1,2 @@
1
+ import{slicedToArray as r,asyncToGenerator as e,regenerator as t}from"../../../../_virtual/_rollupPluginBabelHelpers.js";function n(e,t,n,o){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};return new Promise(function(u,s){var i=new XMLHttpRequest;i.upload.onprogress=function(r){r.lengthComputable&&o(Math.round(r.loaded/r.total*100))},i.onload=function(){i.status>=200&&i.status<300?u():s(new Error("Upload failed: HTTP ".concat(i.status)))},i.onerror=function(){return s(new Error("Network error during upload"))},i.ontimeout=function(){return s(new Error("Upload timed out"))},i.open("PUT",e),i.setRequestHeader("Content-Type",n),Object.entries(a).filter(function(e){return"content-type"!==r(e,1)[0].toLowerCase()}).forEach(function(e){var t=r(e,2),n=t[0],o=t[1];return i.setRequestHeader(n,o)}),i.send(t)})}function o(r,e,t){return a.apply(this,arguments)}function a(){return(a=e(t().m(function r(e,o,a){var u;return t().w(function(r){for(;;)switch(r.n){case 0:return r.n=1,o(e);case 1:return u=r.v,r.n=2,n(u.url,e,u.contentType,a,u.headers);case 2:return r.a(2,u)}},r)}))).apply(this,arguments)}var u="Uploads are not configured: pass getPresignedUrl (a function that asks your server for a presigned PUT URL).";export{u as UPLOADS_NOT_CONFIGURED,o as presignAndUpload,n as uploadToPresignedUrl};
2
+ //# sourceMappingURL=presignedPut.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"presignedPut.js","sources":["../../../../../src/components/forms/uploads/presignedPut.ts"],"sourcesContent":["import type { PresignedUploadResult } from \"@/types\";\n\n/**\n * Upload a file to a presigned PUT URL, reporting progress via XHR.\n *\n * The uploaders never hold bucket credentials: the consumer's\n * `getPresignedUrl(file)` asks its own server for a short-lived URL, and this\n * sends the bytes. `contentType` and any `headers` must match what the server\n * signed, so they are sent verbatim.\n */\nexport function uploadToPresignedUrl(\n url: string,\n file: File,\n contentType: string,\n onProgress: (pct: number) => void,\n headers: Record<string, string> = {}\n): Promise<void> {\n return new Promise((resolve, reject) => {\n const xhr = new XMLHttpRequest();\n\n xhr.upload.onprogress = (e) => {\n if (e.lengthComputable) {\n onProgress(Math.round((e.loaded / e.total) * 100));\n }\n };\n\n xhr.onload = () => {\n if (xhr.status >= 200 && xhr.status < 300) {\n resolve();\n } else {\n reject(new Error(`Upload failed: HTTP ${xhr.status}`));\n }\n };\n\n xhr.onerror = () => reject(new Error(\"Network error during upload\"));\n xhr.ontimeout = () => reject(new Error(\"Upload timed out\"));\n\n xhr.open(\"PUT\", url);\n // Use the server-validated content type, never trust file.type alone.\n xhr.setRequestHeader(\"Content-Type\", contentType);\n // Any other headers the signature covers (e.g. x-amz-acl) must match exactly.\n Object.entries(headers)\n .filter(([name]) => name.toLowerCase() !== \"content-type\")\n .forEach(([name, value]) => xhr.setRequestHeader(name, value));\n xhr.send(file);\n });\n}\n\n/** Presign with the consumer's function, then PUT. Resolves with the presign result. */\nexport async function presignAndUpload(\n file: File,\n getPresignedUrl: (file: File) => Promise<PresignedUploadResult>,\n onProgress: (pct: number) => void\n): Promise<PresignedUploadResult> {\n const presigned = await getPresignedUrl(file);\n await uploadToPresignedUrl(\n presigned.url,\n file,\n presigned.contentType,\n onProgress,\n presigned.headers\n );\n return presigned;\n}\n\nexport const UPLOADS_NOT_CONFIGURED =\n \"Uploads are not configured: pass getPresignedUrl (a function that asks your server for a presigned PUT URL).\";\n"],"names":["uploadToPresignedUrl","url","file","contentType","onProgress","headers","arguments","length","undefined","Promise","resolve","reject","xhr","XMLHttpRequest","upload","onprogress","e","lengthComputable","Math","round","loaded","total","onload","status","Error","concat","onerror","ontimeout","open","setRequestHeader","Object","entries","filter","_ref","_slicedToArray","toLowerCase","forEach","_ref3","_ref4","name","value","send","presignAndUpload","_x","_x2","_x3","_presignAndUpload","apply","this","_asyncToGenerator","_regenerator","m","_callee","getPresignedUrl","presigned","w","_context","n","v","a","UPLOADS_NOT_CONFIGURED"],"mappings":"yHAUgB,SAAAA,EACdC,EACAC,EACAC,EACAC,GACoC,IAApCC,EAAAC,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GAAkC,CAAA,EAElC,OAAO,IAAIG,QAAQ,SAACC,EAASC,GAC3B,IAAMC,EAAM,IAAIC,eAEhBD,EAAIE,OAAOC,WAAa,SAACC,GACnBA,EAAEC,kBACJb,EAAWc,KAAKC,MAAOH,EAAEI,OAASJ,EAAEK,MAAS,OAIjDT,EAAIU,OAAS,WACPV,EAAIW,QAAU,KAAOX,EAAIW,OAAS,IACpCb,IAEAC,EAAO,IAAIa,MAAKC,uBAAAA,OAAwBb,EAAIW,WAIhDX,EAAIc,QAAU,WAAA,OAAMf,EAAO,IAAIa,MAAM,+BAA+B,EACpEZ,EAAIe,UAAY,WAAA,OAAMhB,EAAO,IAAIa,MAAM,oBAAoB,EAE3DZ,EAAIgB,KAAK,MAAO3B,GAEhBW,EAAIiB,iBAAiB,eAAgB1B,GAErC2B,OAAOC,QAAQ1B,GACZ2B,OAAO,SAAAC,GAAM,MAA6B,iBAAnCC,EAAAD,EAAA,GAAM,GAAWE,aAAgC,GACxDC,QAAQ,SAAAC,GAAA,IAAAC,EAAAJ,EAAAG,EAAA,GAAEE,EAAID,EAAA,GAAEE,EAAKF,EAAA,GAAA,OAAM1B,EAAIiB,iBAAiBU,EAAMC,KACzD5B,EAAI6B,KAAKvC,EACX,EACF,CAGA,SAAsBwC,EAAgBC,EAAAC,EAAAC,GAAA,OAAAC,EAAAC,MAAAC,KAAA1C,UAAA,CAcrC,SAAAwC,IAAA,OAAAA,EAAAG,EAAAC,IAAAC,EAdM,SAAAC,EACLlD,EACAmD,EACAjD,GAAiC,IAAAkD,EAAA,OAAAJ,IAAAK,EAAA,SAAAC,GAAA,cAAAA,EAAAC,GAAA,KAAA,EAAA,OAAAD,EAAAC,EAAA,EAETJ,EAAgBnD,GAAK,KAAA,EAA9B,OAAToD,EAASE,EAAAE,EAAAF,EAAAC,EAAA,EACTzD,EACJsD,EAAUrD,IACVC,EACAoD,EAAUnD,YACVC,EACAkD,EAAUjD,SACX,KAAA,EAAA,OAAAmD,EAAAG,EAAA,EACML,GAAS,EAAAF,EACjB,KAAAL,MAAAC,KAAA1C,UAAA,CAEM,IAAMsD,EACX"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./auth/dbRequestst.cjs"),r=require("./roles.cjs"),t=require("./json/accounts.cjs"),o=require("./json/unsplashDefaultObject.cjs"),s=require("./createSubscription.cjs"),a=require("./elementIsVisibleInViewport.cjs"),i=require("./formError.cjs"),p=require("./fileToBase64.cjs"),n=require("./getPriceObjects.cjs"),l=require("./convertArrayToObject.cjs"),E=require("./loadScript.cjs"),x=require("./format.cjs"),u=require("./phoneUtils.cjs"),N=require("./helpFunction.cjs"),_=require("./oauth_json.cjs"),S=require("./paystack.cjs"),O=require("./permissions.cjs"),c=require("./utils.cjs"),I=require("./queryParameters/index.cjs"),R=require("./charts.cjs"),T=require("./modals/modals.cjs"),m=require("./modals/openConfirmDelete.cjs");exports.getChannel=e.getChannel,exports.getData=e.getData,exports.INSTRUCTOR_TYPE=r.INSTRUCTOR_TYPE,exports.ROLE_GROUPING=r.ROLE_GROUPING,exports.adminAccessValidation=r.adminAccessValidation,exports.AllCoursesdataList=t.AllCoursesdataList,exports.COMMENTS_BY=t.COMMENTS_BY,exports.DataList=t.DataList,exports.accounts=t.accounts,exports.dataList=t.dataList,exports.pending=t.pending,exports.projectStartHistory=t.projectStartHistory,exports.statesNigeria=t.statesNigeria,exports.unsplashDefaultObject=o.unsplashDefaultObject,exports.createSubscription=s.default,exports.elementIsVisibleInViewport=a.default,exports.handleFormErrors=i.default,exports.fileToBase64=p.default,exports.getPriceObjects=n.default,exports.convertArrayToObject=l.default,exports.loadScript=E.default,exports.formatTime=x.formatTime,exports.E164_MAX_DIGITS=u.E164_MAX_DIGITS,exports.MAX_NATIONAL_DIGITS=u.MAX_NATIONAL_DIGITS,exports.MIN_NATIONAL_DIGITS=u.MIN_NATIONAL_DIGITS,exports.PHONE_COUNTRIES=u.PHONE_COUNTRIES,exports.buildPhoneValue=u.buildPhoneValue,exports.digitsOnly=u.digitsOnly,exports.findCountryByDialCode=u.findCountryByDialCode,exports.findCountryByIso=u.findCountryByIso,exports.formatNationalNumber=u.formatNationalNumber,exports.matchDialCode=u.matchDialCode,exports.maxNationalDigits=u.maxNationalDigits,exports.normalizeDialCode=u.normalizeDialCode,exports.parsePhoneNumber=u.parsePhoneNumber,exports.resolveCountry=u.resolveCountry,exports.searchCountries=u.searchCountries,exports.withPreferredCountries=u.withPreferredCountries,exports.API_HOST_URL=N.API_HOST_URL,exports.CODECS_URL_M3U8=N.CODECS_URL_M3U8,exports.FILE_URL=N.FILE_URL,exports.IN_DEV_MODE=N.IN_DEV_MODE,exports.TrackViewPort=N.TrackViewPort,exports.VIDEO_URL=N.VIDEO_URL,exports.abbreviateNumber=N.abbreviateNumber,exports.addUserDomain=N.addUserDomain,exports.calculateAmountAfterDeduction=N.calculateAmountAfterDeduction,exports.calculateAverageRating=N.calculateAverageRating,exports.calculateCouponDeduction=N.calculateCouponDeduction,exports.calculateTotalCredits=N.calculateTotalCredits,exports.convertArrayToFormData=N.convertArrayToFormData,exports.convertToFloat=N.convertToFloat,exports.convertToSlug=N.convertToSlug,exports.extractSubDomain=N.extractSubDomain,exports.fetchAPI=N.fetchAPI,exports.fetchData=N.fetchData,exports.findNullOrEmptyKeys=N.findNullOrEmptyKeys,exports.formatDateToWord=N.formatDateToWord,exports.formatDuration=N.formatDuration,exports.formatNumberWithCommas=N.formatNumberWithCommas,exports.getCookie=N.getCookie,exports.getNestedValue=N.getNestedValue,exports.handleError=N.handleError,exports.handleInvalid=N.handleInvalid,exports.handleResendOTP=N.handleResendOTP,exports.handleStatusError=N.handleStatusError,exports.hostUrlEncode=N.hostUrlEncode,exports.inputTagErrorEvent=N.inputTagErrorEvent,exports.isValidAlphanumeric=N.isValidAlphanumeric,exports.isValidEmail=N.isValidEmail,exports.objectIsEmpty=N.objectIsEmpty,exports.printErr=N.printErr,exports.printErrNew=N.printErrNew,exports.removeCookie=N.removeCookie,exports.removeErrMsg=N.removeErrMsg,exports.reqOptions=N.reqOptions,exports.romansFigure=N.romansFigure,exports.setCookie=N.setCookie,exports.slugifyFileName=N.slugifyFileName,exports.spinBtn=N.spinBtn,exports.stripCommaFromNumber=N.stripCommaFromNumber,exports.stripHtmlTags=N.stripHtmlTags,exports.toTitleCase=N.toTitleCase,exports.truncateHtml=N.truncateHtml,exports.paystackHook=_.paystackHook,exports.profile_goggle_provider=_.profile_goggle_provider,exports.chargeAuthorization=S.chargeAuthorization,exports.handlePaymentSubmit=S.handlePaymentSubmit,exports.handlePaymentWithoutUserData=S.handlePaymentWithoutUserData,exports.payWithPaystack=S.payWithPaystack,exports.paystackDataConfig=S.paystackDataConfig,exports.CHANNEL_ADMIN_ROLES=O.CHANNEL_ADMIN_ROLES,exports.CHANNEL_BLOGGER_ROLES=O.CHANNEL_BLOGGER_ROLES,exports.CHANNEL_EVENT_ROLES=O.CHANNEL_EVENT_ROLES,exports.CHANNEL_FINANCE_ROLES=O.CHANNEL_FINANCE_ROLES,exports.CHANNEL_INSTRUCTOR_ROLES=O.CHANNEL_INSTRUCTOR_ROLES,exports.CHANNEL_LEARNER_ROLES=O.CHANNEL_LEARNER_ROLES,exports.CHANNEL_MODERATOR_ROLES=O.CHANNEL_MODERATOR_ROLES,exports.CHANNEL_REGISTRAR_ROLES=O.CHANNEL_REGISTRAR_ROLES,exports.CHANNEL_SUPER_ADMIN_ROLES=O.CHANNEL_SUPER_ADMIN_ROLES,exports.ROLE_MAP=O.ROLE_MAP,exports.findPermissions=O.findPermissions,exports.hasUserPermission=O.hasUserPermission,exports.headerKeyPermission=O.headerKeyPermission,exports.headerUsernamePermission=O.headerUsernamePermission,exports.ADMIN_PERMISSION=c.ADMIN_PERMISSION,exports.APPLICATION_FEE_TYPE_OPTIONS=c.APPLICATION_FEE_TYPE_OPTIONS,exports.CODE_LANGUAGES=c.CODE_LANGUAGES,exports.COMPANY_SIZES_CHOICES=c.COMPANY_SIZES_CHOICES,exports.CONTENT_TYPE_OPTIONS=c.CONTENT_TYPE_OPTIONS,exports.COURSE_REWARD_OPTIONS=c.COURSE_REWARD_OPTIONS,exports.CREDENTIALS=c.CREDENTIALS,exports.CURRENCY_SYMBOL=c.CURRENCY_SYMBOL,exports.DURATION_FILTERS=c.DURATION_FILTERS,exports.INDUSTRIES=c.INDUSTRIES,exports.KEYWORD_DESCRIPTION=c.KEYWORD_DESCRIPTION,exports.NEXT_AUTH_SESSION_DATA_DUMMY=c.NEXT_AUTH_SESSION_DATA_DUMMY,exports.NIGERIA_BANKS=c.NIGERIA_BANKS,exports.PAYMENT_PROCESSING_OPTIONS=c.PAYMENT_PROCESSING_OPTIONS,exports.PRIVACY=c.PRIVACY,exports.PROGRAM_LEVELS=c.PROGRAM_LEVELS,exports.REGISTRAR_PERMISSION=c.REGISTRAR_PERMISSION,exports.SCOREBOARD_DURATION=c.SCOREBOARD_DURATION,exports.SKILLS_LEVELS=c.SKILLS_LEVELS,exports.STUDENT_STATUS=c.STUDENT_STATUS,exports.SUBSCRIPTION_OPTION=c.SUBSCRIPTION_OPTION,exports.SUPER_PERMISSION=c.SUPER_PERMISSION,exports.TRUE_FALSE=c.TRUE_FALSE,exports.VIDEO_PLAYER_OPTIONS=c.VIDEO_PLAYER_OPTIONS,exports.YES_NO=c.YES_NO,exports.gaugeData=c.gaugeData,exports.buildDataFilterUrl=I.buildDataFilterUrl,exports.buildPaginationUrl=I.buildPaginationUrl,exports.buildUrl=I.buildUrl,exports.cleanUrl=I.cleanUrl,exports.getQueryParam=I.getQueryParam,exports.getQueryParams=I.getQueryParams,exports.hasQueryParam=I.hasQueryParam,exports.navigateWithQuery=I.navigateWithQuery,exports.urlQueryHelper=I.urlQueryHelper,exports.calculatePercentageChange=R.calculatePercentageChange,exports.createTimeSeriesTemplate=R.createTimeSeriesTemplate,exports.formatChartValue=R.formatChartValue,exports.formatDateForChart=R.formatDateForChart,exports.generateChartColors=R.generateChartColors,exports.groupAndAggregateData=R.groupAndAggregateData,exports.transformChartData=R.transformChartData,exports.getUserEmailInputModal=T.getUserEmailInputModal,exports.openConfirmModal=T.openConfirmModal,exports.openToast=T.openToast,exports.openConfirmDelete=m.openConfirmDelete,exports.instinctHubLogoUrl="/assets/logo/instincthub-logo-color.png",exports.instinctHubLogoUrlBlack="/assets/logo/instincthub-logo-black.png",exports.instinctHubLogoUrlWhite="/assets/logo/instincthub-logo-white.png",exports.instinctHubThumbnailLogo="/assets/logo/instincthub-logo-thumbnail.png";
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./auth/dbRequestst.cjs"),r=require("./roles.cjs"),t=require("./json/accounts.cjs"),o=require("./json/unsplashDefaultObject.cjs"),s=require("./createSubscription.cjs"),a=require("./elementIsVisibleInViewport.cjs"),i=require("./formError.cjs"),p=require("./fileToBase64.cjs"),n=require("./getPriceObjects.cjs"),E=require("./convertArrayToObject.cjs"),l=require("./loadScript.cjs"),x=require("./format.cjs"),N=require("./phoneUtils.cjs"),u=require("./helpFunction.cjs"),_=require("./oauth_json.cjs"),S=require("./paystack.cjs"),O=require("./permissions.cjs"),c=require("./utils.cjs"),I=require("./queryParameters/index.cjs"),R=require("./charts.cjs"),T=require("./modals/modals.cjs"),A=require("./modals/openConfirmDelete.cjs");exports.getChannel=e.getChannel,exports.getData=e.getData,exports.INSTRUCTOR_TYPE=r.INSTRUCTOR_TYPE,exports.ROLE_GROUPING=r.ROLE_GROUPING,exports.adminAccessValidation=r.adminAccessValidation,exports.AllCoursesdataList=t.AllCoursesdataList,exports.COMMENTS_BY=t.COMMENTS_BY,exports.DataList=t.DataList,exports.accounts=t.accounts,exports.dataList=t.dataList,exports.pending=t.pending,exports.projectStartHistory=t.projectStartHistory,exports.statesNigeria=t.statesNigeria,exports.unsplashDefaultObject=o.unsplashDefaultObject,exports.createSubscription=s.default,exports.elementIsVisibleInViewport=a.default,exports.handleFormErrors=i.default,exports.fileToBase64=p.default,exports.getPriceObjects=n.default,exports.convertArrayToObject=E.default,exports.loadScript=l.default,exports.formatTime=x.formatTime,exports.E164_MAX_DIGITS=N.E164_MAX_DIGITS,exports.MAX_NATIONAL_DIGITS=N.MAX_NATIONAL_DIGITS,exports.MIN_NATIONAL_DIGITS=N.MIN_NATIONAL_DIGITS,exports.PHONE_COUNTRIES=N.PHONE_COUNTRIES,exports.buildPhoneValue=N.buildPhoneValue,exports.digitsOnly=N.digitsOnly,exports.findCountryByDialCode=N.findCountryByDialCode,exports.findCountryByIso=N.findCountryByIso,exports.formatNationalNumber=N.formatNationalNumber,exports.matchDialCode=N.matchDialCode,exports.maxNationalDigits=N.maxNationalDigits,exports.normalizeDialCode=N.normalizeDialCode,exports.parsePhoneNumber=N.parsePhoneNumber,exports.resolveCountry=N.resolveCountry,exports.searchCountries=N.searchCountries,exports.withPreferredCountries=N.withPreferredCountries,exports.API_HOST_URL=u.API_HOST_URL,exports.CODECS_URL_M3U8=u.CODECS_URL_M3U8,exports.FILE_URL=u.FILE_URL,exports.IN_DEV_MODE=u.IN_DEV_MODE,exports.TrackViewPort=u.TrackViewPort,exports.VIDEO_URL=u.VIDEO_URL,exports.abbreviateNumber=u.abbreviateNumber,exports.addUserDomain=u.addUserDomain,exports.calculateAmountAfterDeduction=u.calculateAmountAfterDeduction,exports.calculateAverageRating=u.calculateAverageRating,exports.calculateCouponDeduction=u.calculateCouponDeduction,exports.calculateTotalCredits=u.calculateTotalCredits,exports.convertArrayToFormData=u.convertArrayToFormData,exports.convertToFloat=u.convertToFloat,exports.convertToSlug=u.convertToSlug,exports.extractSubDomain=u.extractSubDomain,exports.fetchAPI=u.fetchAPI,exports.fetchData=u.fetchData,exports.findNullOrEmptyKeys=u.findNullOrEmptyKeys,exports.formatDateToWord=u.formatDateToWord,exports.formatDuration=u.formatDuration,exports.formatNumberWithCommas=u.formatNumberWithCommas,exports.getCookie=u.getCookie,exports.getNestedValue=u.getNestedValue,exports.handleError=u.handleError,exports.handleInvalid=u.handleInvalid,exports.handleResendOTP=u.handleResendOTP,exports.handleStatusError=u.handleStatusError,exports.hostUrlEncode=u.hostUrlEncode,exports.inputTagErrorEvent=u.inputTagErrorEvent,exports.isValidAlphanumeric=u.isValidAlphanumeric,exports.isValidEmail=u.isValidEmail,exports.objectIsEmpty=u.objectIsEmpty,exports.printErr=u.printErr,exports.printErrNew=u.printErrNew,exports.removeCookie=u.removeCookie,exports.removeErrMsg=u.removeErrMsg,exports.reqOptions=u.reqOptions,exports.romansFigure=u.romansFigure,exports.setCookie=u.setCookie,exports.slugifyFileName=u.slugifyFileName,exports.spinBtn=u.spinBtn,exports.stripCommaFromNumber=u.stripCommaFromNumber,exports.stripHtmlTags=u.stripHtmlTags,exports.toTitleCase=u.toTitleCase,exports.truncateHtml=u.truncateHtml,exports.paystackHook=_.paystackHook,exports.profile_goggle_provider=_.profile_goggle_provider,exports.PAYSTACK_INLINE_V2_URL=S.PAYSTACK_INLINE_V2_URL,exports.chargeAuthorization=S.chargeAuthorization,exports.handlePaymentSubmit=S.handlePaymentSubmit,exports.handlePaymentWithoutUserData=S.handlePaymentWithoutUserData,exports.payWithAccessCode=S.payWithAccessCode,exports.payWithPaystack=S.payWithPaystack,exports.paystackDataConfig=S.paystackDataConfig,exports.CHANNEL_ADMIN_ROLES=O.CHANNEL_ADMIN_ROLES,exports.CHANNEL_BLOGGER_ROLES=O.CHANNEL_BLOGGER_ROLES,exports.CHANNEL_EVENT_ROLES=O.CHANNEL_EVENT_ROLES,exports.CHANNEL_FINANCE_ROLES=O.CHANNEL_FINANCE_ROLES,exports.CHANNEL_INSTRUCTOR_ROLES=O.CHANNEL_INSTRUCTOR_ROLES,exports.CHANNEL_LEARNER_ROLES=O.CHANNEL_LEARNER_ROLES,exports.CHANNEL_MODERATOR_ROLES=O.CHANNEL_MODERATOR_ROLES,exports.CHANNEL_REGISTRAR_ROLES=O.CHANNEL_REGISTRAR_ROLES,exports.CHANNEL_SUPER_ADMIN_ROLES=O.CHANNEL_SUPER_ADMIN_ROLES,exports.ROLE_MAP=O.ROLE_MAP,exports.findPermissions=O.findPermissions,exports.hasUserPermission=O.hasUserPermission,exports.headerKeyPermission=O.headerKeyPermission,exports.headerUsernamePermission=O.headerUsernamePermission,exports.ADMIN_PERMISSION=c.ADMIN_PERMISSION,exports.APPLICATION_FEE_TYPE_OPTIONS=c.APPLICATION_FEE_TYPE_OPTIONS,exports.CODE_LANGUAGES=c.CODE_LANGUAGES,exports.COMPANY_SIZES_CHOICES=c.COMPANY_SIZES_CHOICES,exports.CONTENT_TYPE_OPTIONS=c.CONTENT_TYPE_OPTIONS,exports.COURSE_REWARD_OPTIONS=c.COURSE_REWARD_OPTIONS,exports.CREDENTIALS=c.CREDENTIALS,exports.CURRENCY_SYMBOL=c.CURRENCY_SYMBOL,exports.DURATION_FILTERS=c.DURATION_FILTERS,exports.INDUSTRIES=c.INDUSTRIES,exports.KEYWORD_DESCRIPTION=c.KEYWORD_DESCRIPTION,exports.NEXT_AUTH_SESSION_DATA_DUMMY=c.NEXT_AUTH_SESSION_DATA_DUMMY,exports.NIGERIA_BANKS=c.NIGERIA_BANKS,exports.PAYMENT_PROCESSING_OPTIONS=c.PAYMENT_PROCESSING_OPTIONS,exports.PRIVACY=c.PRIVACY,exports.PROGRAM_LEVELS=c.PROGRAM_LEVELS,exports.REGISTRAR_PERMISSION=c.REGISTRAR_PERMISSION,exports.SCOREBOARD_DURATION=c.SCOREBOARD_DURATION,exports.SKILLS_LEVELS=c.SKILLS_LEVELS,exports.STUDENT_STATUS=c.STUDENT_STATUS,exports.SUBSCRIPTION_OPTION=c.SUBSCRIPTION_OPTION,exports.SUPER_PERMISSION=c.SUPER_PERMISSION,exports.TRUE_FALSE=c.TRUE_FALSE,exports.VIDEO_PLAYER_OPTIONS=c.VIDEO_PLAYER_OPTIONS,exports.YES_NO=c.YES_NO,exports.gaugeData=c.gaugeData,exports.buildDataFilterUrl=I.buildDataFilterUrl,exports.buildPaginationUrl=I.buildPaginationUrl,exports.buildUrl=I.buildUrl,exports.cleanUrl=I.cleanUrl,exports.getQueryParam=I.getQueryParam,exports.getQueryParams=I.getQueryParams,exports.hasQueryParam=I.hasQueryParam,exports.navigateWithQuery=I.navigateWithQuery,exports.urlQueryHelper=I.urlQueryHelper,exports.calculatePercentageChange=R.calculatePercentageChange,exports.createTimeSeriesTemplate=R.createTimeSeriesTemplate,exports.formatChartValue=R.formatChartValue,exports.formatDateForChart=R.formatDateForChart,exports.generateChartColors=R.generateChartColors,exports.groupAndAggregateData=R.groupAndAggregateData,exports.transformChartData=R.transformChartData,exports.getUserEmailInputModal=T.getUserEmailInputModal,exports.openConfirmModal=T.openConfirmModal,exports.openToast=T.openToast,exports.openConfirmDelete=A.openConfirmDelete,exports.instinctHubLogoUrl="/assets/logo/instincthub-logo-color.png",exports.instinctHubLogoUrlBlack="/assets/logo/instincthub-logo-black.png",exports.instinctHubLogoUrlWhite="/assets/logo/instincthub-logo-white.png",exports.instinctHubThumbnailLogo="/assets/logo/instincthub-logo-thumbnail.png";
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../../../src/components/lib/index.ts"],"sourcesContent":["// src/components/lib/index.ts\n\nexport * from \"./auth/dbRequestst\";\nexport * from \"./roles\";\n\n// JSON exports\nexport * from \"./json/accounts\";\nexport * from \"./json/countryNigeria\";\nexport * from \"./json/countryObjects\";\nexport * from \"./json/educationLevels\";\nexport * from \"./json/unsplashDefaultObject\";\n\n// Utility functions\nexport { default as createSubscription } from \"./createSubscription\";\nexport { default as elementIsVisibleInViewport } from \"./elementIsVisibleInViewport\";\nexport { default as handleFormErrors } from \"./formError\";\nexport { default as fileToBase64 } from \"./fileToBase64\";\nexport { default as getPriceObjects } from \"./getPriceObjects\";\nexport {default as convertArrayToObject} from \"./convertArrayToObject\";\nexport {default as loadScript} from \"./loadScript\";\nexport * from \"./format\";\nexport * from \"./phoneUtils\";\nexport * from \"./helpFunction\";\nexport * from \"./oauth_json\";\nexport * from \"./paystack\";\nexport * from \"./permissions\";\nexport * from \"./utils\";\nexport * from \"./queryParameters\";\n\n// Charts\nexport * from \"./charts\";\n\n// Modals\nexport * from \"./modals/modals\";\nexport * from \"./modals/openConfirmDelete\";\n\n// Logo\nexport const instinctHubLogoUrl = \"/assets/logo/instincthub-logo-color.png\";\nexport const instinctHubLogoUrlWhite =\n \"/assets/logo/instincthub-logo-white.png\";\nexport const instinctHubLogoUrlBlack =\n \"/assets/logo/instincthub-logo-black.png\";\nexport const instinctHubThumbnailLogo =\n \"/assets/logo/instincthub-logo-thumbnail.png\";\n"],"names":[],"mappings":"2rOAqCkC,0EAIhC,0EAFA,2EAIA"}
1
+ {"version":3,"file":"index.cjs","sources":["../../../../src/components/lib/index.ts"],"sourcesContent":["// src/components/lib/index.ts\n\nexport * from \"./auth/dbRequestst\";\nexport * from \"./roles\";\n\n// JSON exports\nexport * from \"./json/accounts\";\nexport * from \"./json/countryNigeria\";\nexport * from \"./json/countryObjects\";\nexport * from \"./json/educationLevels\";\nexport * from \"./json/unsplashDefaultObject\";\n\n// Utility functions\nexport { default as createSubscription } from \"./createSubscription\";\nexport { default as elementIsVisibleInViewport } from \"./elementIsVisibleInViewport\";\nexport { default as handleFormErrors } from \"./formError\";\nexport { default as fileToBase64 } from \"./fileToBase64\";\nexport { default as getPriceObjects } from \"./getPriceObjects\";\nexport {default as convertArrayToObject} from \"./convertArrayToObject\";\nexport {default as loadScript} from \"./loadScript\";\nexport * from \"./format\";\nexport * from \"./phoneUtils\";\nexport * from \"./helpFunction\";\nexport * from \"./oauth_json\";\nexport * from \"./paystack\";\nexport * from \"./permissions\";\nexport * from \"./utils\";\nexport * from \"./queryParameters\";\n\n// Charts\nexport * from \"./charts\";\n\n// Modals\nexport * from \"./modals/modals\";\nexport * from \"./modals/openConfirmDelete\";\n\n// Logo\nexport const instinctHubLogoUrl = \"/assets/logo/instincthub-logo-color.png\";\nexport const instinctHubLogoUrlWhite =\n \"/assets/logo/instincthub-logo-white.png\";\nexport const instinctHubLogoUrlBlack =\n \"/assets/logo/instincthub-logo-black.png\";\nexport const instinctHubThumbnailLogo =\n \"/assets/logo/instincthub-logo-thumbnail.png\";\n"],"names":[],"mappings":"iyOAqCkC,0EAIhC,0EAFA,2EAIA"}
@@ -1,2 +1,2 @@
1
- export{getChannel,getData}from"./auth/dbRequestst.js";export{INSTRUCTOR_TYPE,ROLE_GROUPING,adminAccessValidation}from"./roles.js";export{AllCoursesdataList,COMMENTS_BY,DataList,accounts,dataList,pending,projectStartHistory,statesNigeria}from"./json/accounts.js";export{unsplashDefaultObject}from"./json/unsplashDefaultObject.js";export{default as createSubscription}from"./createSubscription.js";export{default as elementIsVisibleInViewport}from"./elementIsVisibleInViewport.js";export{default as handleFormErrors}from"./formError.js";export{default as fileToBase64}from"./fileToBase64.js";export{default as getPriceObjects}from"./getPriceObjects.js";export{default as convertArrayToObject}from"./convertArrayToObject.js";export{default as loadScript}from"./loadScript.js";export{formatTime}from"./format.js";export{E164_MAX_DIGITS,MAX_NATIONAL_DIGITS,MIN_NATIONAL_DIGITS,PHONE_COUNTRIES,buildPhoneValue,digitsOnly,findCountryByDialCode,findCountryByIso,formatNationalNumber,matchDialCode,maxNationalDigits,normalizeDialCode,parsePhoneNumber,resolveCountry,searchCountries,withPreferredCountries}from"./phoneUtils.js";export{API_HOST_URL,CODECS_URL_M3U8,FILE_URL,IN_DEV_MODE,TrackViewPort,VIDEO_URL,abbreviateNumber,addUserDomain,calculateAmountAfterDeduction,calculateAverageRating,calculateCouponDeduction,calculateTotalCredits,convertArrayToFormData,convertToFloat,convertToSlug,extractSubDomain,fetchAPI,fetchData,findNullOrEmptyKeys,formatDateToWord,formatDuration,formatNumberWithCommas,getCookie,getNestedValue,handleError,handleInvalid,handleResendOTP,handleStatusError,hostUrlEncode,inputTagErrorEvent,isValidAlphanumeric,isValidEmail,objectIsEmpty,printErr,printErrNew,removeCookie,removeErrMsg,reqOptions,romansFigure,setCookie,slugifyFileName,spinBtn,stripCommaFromNumber,stripHtmlTags,toTitleCase,truncateHtml}from"./helpFunction.js";export{paystackHook,profile_goggle_provider}from"./oauth_json.js";export{chargeAuthorization,handlePaymentSubmit,handlePaymentWithoutUserData,payWithPaystack,paystackDataConfig}from"./paystack.js";export{CHANNEL_ADMIN_ROLES,CHANNEL_BLOGGER_ROLES,CHANNEL_EVENT_ROLES,CHANNEL_FINANCE_ROLES,CHANNEL_INSTRUCTOR_ROLES,CHANNEL_LEARNER_ROLES,CHANNEL_MODERATOR_ROLES,CHANNEL_REGISTRAR_ROLES,CHANNEL_SUPER_ADMIN_ROLES,ROLE_MAP,findPermissions,hasUserPermission,headerKeyPermission,headerUsernamePermission}from"./permissions.js";export{ADMIN_PERMISSION,APPLICATION_FEE_TYPE_OPTIONS,CODE_LANGUAGES,COMPANY_SIZES_CHOICES,CONTENT_TYPE_OPTIONS,COURSE_REWARD_OPTIONS,CREDENTIALS,CURRENCY_SYMBOL,DURATION_FILTERS,INDUSTRIES,KEYWORD_DESCRIPTION,NEXT_AUTH_SESSION_DATA_DUMMY,NIGERIA_BANKS,PAYMENT_PROCESSING_OPTIONS,PRIVACY,PROGRAM_LEVELS,REGISTRAR_PERMISSION,SCOREBOARD_DURATION,SKILLS_LEVELS,STUDENT_STATUS,SUBSCRIPTION_OPTION,SUPER_PERMISSION,TRUE_FALSE,VIDEO_PLAYER_OPTIONS,YES_NO,gaugeData}from"./utils.js";export{buildDataFilterUrl,buildPaginationUrl,buildUrl,cleanUrl,getQueryParam,getQueryParams,hasQueryParam,navigateWithQuery,urlQueryHelper}from"./queryParameters/index.js";export{calculatePercentageChange,createTimeSeriesTemplate,formatChartValue,formatDateForChart,generateChartColors,groupAndAggregateData,transformChartData}from"./charts.js";export{getUserEmailInputModal,openConfirmModal,openToast}from"./modals/modals.js";export{openConfirmDelete}from"./modals/openConfirmDelete.js";var e="/assets/logo/instincthub-logo-color.png",t="/assets/logo/instincthub-logo-white.png",r="/assets/logo/instincthub-logo-black.png",a="/assets/logo/instincthub-logo-thumbnail.png";export{e as instinctHubLogoUrl,r as instinctHubLogoUrlBlack,t as instinctHubLogoUrlWhite,a as instinctHubThumbnailLogo};
1
+ export{getChannel,getData}from"./auth/dbRequestst.js";export{INSTRUCTOR_TYPE,ROLE_GROUPING,adminAccessValidation}from"./roles.js";export{AllCoursesdataList,COMMENTS_BY,DataList,accounts,dataList,pending,projectStartHistory,statesNigeria}from"./json/accounts.js";export{unsplashDefaultObject}from"./json/unsplashDefaultObject.js";export{default as createSubscription}from"./createSubscription.js";export{default as elementIsVisibleInViewport}from"./elementIsVisibleInViewport.js";export{default as handleFormErrors}from"./formError.js";export{default as fileToBase64}from"./fileToBase64.js";export{default as getPriceObjects}from"./getPriceObjects.js";export{default as convertArrayToObject}from"./convertArrayToObject.js";export{default as loadScript}from"./loadScript.js";export{formatTime}from"./format.js";export{E164_MAX_DIGITS,MAX_NATIONAL_DIGITS,MIN_NATIONAL_DIGITS,PHONE_COUNTRIES,buildPhoneValue,digitsOnly,findCountryByDialCode,findCountryByIso,formatNationalNumber,matchDialCode,maxNationalDigits,normalizeDialCode,parsePhoneNumber,resolveCountry,searchCountries,withPreferredCountries}from"./phoneUtils.js";export{API_HOST_URL,CODECS_URL_M3U8,FILE_URL,IN_DEV_MODE,TrackViewPort,VIDEO_URL,abbreviateNumber,addUserDomain,calculateAmountAfterDeduction,calculateAverageRating,calculateCouponDeduction,calculateTotalCredits,convertArrayToFormData,convertToFloat,convertToSlug,extractSubDomain,fetchAPI,fetchData,findNullOrEmptyKeys,formatDateToWord,formatDuration,formatNumberWithCommas,getCookie,getNestedValue,handleError,handleInvalid,handleResendOTP,handleStatusError,hostUrlEncode,inputTagErrorEvent,isValidAlphanumeric,isValidEmail,objectIsEmpty,printErr,printErrNew,removeCookie,removeErrMsg,reqOptions,romansFigure,setCookie,slugifyFileName,spinBtn,stripCommaFromNumber,stripHtmlTags,toTitleCase,truncateHtml}from"./helpFunction.js";export{paystackHook,profile_goggle_provider}from"./oauth_json.js";export{PAYSTACK_INLINE_V2_URL,chargeAuthorization,handlePaymentSubmit,handlePaymentWithoutUserData,payWithAccessCode,payWithPaystack,paystackDataConfig}from"./paystack.js";export{CHANNEL_ADMIN_ROLES,CHANNEL_BLOGGER_ROLES,CHANNEL_EVENT_ROLES,CHANNEL_FINANCE_ROLES,CHANNEL_INSTRUCTOR_ROLES,CHANNEL_LEARNER_ROLES,CHANNEL_MODERATOR_ROLES,CHANNEL_REGISTRAR_ROLES,CHANNEL_SUPER_ADMIN_ROLES,ROLE_MAP,findPermissions,hasUserPermission,headerKeyPermission,headerUsernamePermission}from"./permissions.js";export{ADMIN_PERMISSION,APPLICATION_FEE_TYPE_OPTIONS,CODE_LANGUAGES,COMPANY_SIZES_CHOICES,CONTENT_TYPE_OPTIONS,COURSE_REWARD_OPTIONS,CREDENTIALS,CURRENCY_SYMBOL,DURATION_FILTERS,INDUSTRIES,KEYWORD_DESCRIPTION,NEXT_AUTH_SESSION_DATA_DUMMY,NIGERIA_BANKS,PAYMENT_PROCESSING_OPTIONS,PRIVACY,PROGRAM_LEVELS,REGISTRAR_PERMISSION,SCOREBOARD_DURATION,SKILLS_LEVELS,STUDENT_STATUS,SUBSCRIPTION_OPTION,SUPER_PERMISSION,TRUE_FALSE,VIDEO_PLAYER_OPTIONS,YES_NO,gaugeData}from"./utils.js";export{buildDataFilterUrl,buildPaginationUrl,buildUrl,cleanUrl,getQueryParam,getQueryParams,hasQueryParam,navigateWithQuery,urlQueryHelper}from"./queryParameters/index.js";export{calculatePercentageChange,createTimeSeriesTemplate,formatChartValue,formatDateForChart,generateChartColors,groupAndAggregateData,transformChartData}from"./charts.js";export{getUserEmailInputModal,openConfirmModal,openToast}from"./modals/modals.js";export{openConfirmDelete}from"./modals/openConfirmDelete.js";var e="/assets/logo/instincthub-logo-color.png",t="/assets/logo/instincthub-logo-white.png",r="/assets/logo/instincthub-logo-black.png",a="/assets/logo/instincthub-logo-thumbnail.png";export{e as instinctHubLogoUrl,r as instinctHubLogoUrlBlack,t as instinctHubLogoUrlWhite,a as instinctHubThumbnailLogo};
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/components/lib/index.ts"],"sourcesContent":["// src/components/lib/index.ts\n\nexport * from \"./auth/dbRequestst\";\nexport * from \"./roles\";\n\n// JSON exports\nexport * from \"./json/accounts\";\nexport * from \"./json/countryNigeria\";\nexport * from \"./json/countryObjects\";\nexport * from \"./json/educationLevels\";\nexport * from \"./json/unsplashDefaultObject\";\n\n// Utility functions\nexport { default as createSubscription } from \"./createSubscription\";\nexport { default as elementIsVisibleInViewport } from \"./elementIsVisibleInViewport\";\nexport { default as handleFormErrors } from \"./formError\";\nexport { default as fileToBase64 } from \"./fileToBase64\";\nexport { default as getPriceObjects } from \"./getPriceObjects\";\nexport {default as convertArrayToObject} from \"./convertArrayToObject\";\nexport {default as loadScript} from \"./loadScript\";\nexport * from \"./format\";\nexport * from \"./phoneUtils\";\nexport * from \"./helpFunction\";\nexport * from \"./oauth_json\";\nexport * from \"./paystack\";\nexport * from \"./permissions\";\nexport * from \"./utils\";\nexport * from \"./queryParameters\";\n\n// Charts\nexport * from \"./charts\";\n\n// Modals\nexport * from \"./modals/modals\";\nexport * from \"./modals/openConfirmDelete\";\n\n// Logo\nexport const instinctHubLogoUrl = \"/assets/logo/instincthub-logo-color.png\";\nexport const instinctHubLogoUrlWhite =\n \"/assets/logo/instincthub-logo-white.png\";\nexport const instinctHubLogoUrlBlack =\n \"/assets/logo/instincthub-logo-black.png\";\nexport const instinctHubThumbnailLogo =\n \"/assets/logo/instincthub-logo-thumbnail.png\";\n"],"names":["instinctHubLogoUrl","instinctHubLogoUrlWhite","instinctHubLogoUrlBlack","instinctHubThumbnailLogo"],"mappings":"kwGAqCO,IAAMA,EAAqB,0CACrBC,EACX,0CACWC,EACX,0CACWC,EACX"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/components/lib/index.ts"],"sourcesContent":["// src/components/lib/index.ts\n\nexport * from \"./auth/dbRequestst\";\nexport * from \"./roles\";\n\n// JSON exports\nexport * from \"./json/accounts\";\nexport * from \"./json/countryNigeria\";\nexport * from \"./json/countryObjects\";\nexport * from \"./json/educationLevels\";\nexport * from \"./json/unsplashDefaultObject\";\n\n// Utility functions\nexport { default as createSubscription } from \"./createSubscription\";\nexport { default as elementIsVisibleInViewport } from \"./elementIsVisibleInViewport\";\nexport { default as handleFormErrors } from \"./formError\";\nexport { default as fileToBase64 } from \"./fileToBase64\";\nexport { default as getPriceObjects } from \"./getPriceObjects\";\nexport {default as convertArrayToObject} from \"./convertArrayToObject\";\nexport {default as loadScript} from \"./loadScript\";\nexport * from \"./format\";\nexport * from \"./phoneUtils\";\nexport * from \"./helpFunction\";\nexport * from \"./oauth_json\";\nexport * from \"./paystack\";\nexport * from \"./permissions\";\nexport * from \"./utils\";\nexport * from \"./queryParameters\";\n\n// Charts\nexport * from \"./charts\";\n\n// Modals\nexport * from \"./modals/modals\";\nexport * from \"./modals/openConfirmDelete\";\n\n// Logo\nexport const instinctHubLogoUrl = \"/assets/logo/instincthub-logo-color.png\";\nexport const instinctHubLogoUrlWhite =\n \"/assets/logo/instincthub-logo-white.png\";\nexport const instinctHubLogoUrlBlack =\n \"/assets/logo/instincthub-logo-black.png\";\nexport const instinctHubThumbnailLogo =\n \"/assets/logo/instincthub-logo-thumbnail.png\";\n"],"names":["instinctHubLogoUrl","instinctHubLogoUrlWhite","instinctHubLogoUrlBlack","instinctHubThumbnailLogo"],"mappings":"2yGAqCO,IAAMA,EAAqB,0CACrBC,EACX,0CACWC,EACX,0CACWC,EACX"}