-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path367.119f6a468e80135f0d75.js
1 lines (1 loc) · 4.83 KB
/
367.119f6a468e80135f0d75.js
1
"use strict";(self.webpackChunksparkworks_console=self.webpackChunksparkworks_console||[]).push([[367],{91367:function(H,I,n){n.r(I),n.d(I,{amplify_s3_album:function(){return w}});var g,v=n(43085),P=n(8239),A=n(75134),C=n(47289),D=n(88774),y=n.n(D),p=n(65513),M=n(45013),R=n(77),x=n(53799),K=n(22594),L=n(30031),U=n(84665),E=n(84158),k=n(55210),W=new Uint8Array(16);function j(){if(!g&&!(g="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return g(W)}var B=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function S(a){return"string"==typeof a&&B.test(a)}for(var o=[],b=0;b<256;++b)o.push((b+256).toString(16).substr(1));function Z(a,t,e){var r=(a=a||{}).random||(a.rng||j)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){e=e||0;for(var s=0;s<16;++s)t[e+s]=r[s];return t}return function(a){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,e=(o[a[t+0]]+o[a[t+1]]+o[a[t+2]]+o[a[t+3]]+"-"+o[a[t+4]]+o[a[t+5]]+"-"+o[a[t+6]]+o[a[t+7]]+"-"+o[a[t+8]]+o[a[t+9]]+"-"+o[a[t+10]]+o[a[t+11]]+o[a[t+12]]+o[a[t+13]]+o[a[t+14]]+o[a[t+15]]).toLowerCase();if(!S(e))throw TypeError("Stringified UUID is invalid");return e}(r)}var f=new M.k("S3Album"),w=function(){function a(t){var e=this;(0,A.Z)(this,a),(0,p.r)(this,t),this.contentType="binary/octet-stream",this.level=K.A.Public,this.picker=!0,this.pickerText=L.T.PICKER_TEXT,this.albumItems=[],this.imgArr={},this.list=(0,P.Z)(y().mark(function r(){var s,m,i,u,c;return y().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:if(i=e.level,u=e.track,c=e.identityId,f.debug("Album path: "+(m=void 0===(s=e.path)?"":s)),E.Ke&&"function"==typeof E.Ke.list){l.next=4;break}throw new Error(U.d);case 4:return l.prev=4,l.next=7,E.Ke.list(m,{level:i,track:u,identityId:c});case 7:e.marshal(l.sent),l.next=14;break;case 11:l.prev=11,l.t0=l.catch(4),f.warn(l.t0);case 14:case"end":return l.stop()}},r,null,[[4,11]])})),this.marshal=function(r){r.forEach(function(i){var c=i.key.toLowerCase().split(".")[1];k.i.has(c)&&(!i.contentType||i.contentType&&"binary/octet-stream"===i.contentType)&&(i.contentType=e.getContentType(i))});var s=r.filter(function(i){return i.contentType&&i.contentType.startsWith("image/")}),m=e.filter?e.filter(s):s;m=e.sort?e.sort(m):m,e.albumItems=m,f.debug("album items",e.albumItems),e.constructImgArray(e.albumItems)},this.constructImgArray=function(r){r.map(function(s){e.imgArr["".concat(s.key)]=s.key})},this.handlePick=function(){var r=(0,P.Z)(y().mark(function s(m){var i,u,h,T,d,O;return y().wrap(function(_){for(;;)switch(_.prev=_.next){case 0:return h=e.level,T=e.track,d=(void 0===(u=e.path)?"":u)+(0,k.c)(i=m.target.files[0],e.fileToKey),_.prev=3,_.next=6,(0,k.p)(d,i,h,T,i.type,f);case 6:_.next=12;break;case 8:throw _.prev=8,_.t0=_.catch(3),f.error(_.t0),new Error(_.t0);case 12:Object.keys(e.imgArr).includes(d)?(e.albumItems=(0,v.Z)(e.albumItems),e.imgArr[d]="".concat(d,"-").concat(Z())):(O=[].concat((0,v.Z)(e.albumItems),(0,v.Z)(e.filter?e.filter([{key:d}]):[{key:d}])),e.albumItems=e.sort?e.sort(O):O);case 13:case"end":return _.stop()}},s,null,[[3,8]])}));return function(s){return r.apply(this,arguments)}}()}return(0,C.Z)(a,[{key:"getContentType",value:function(e){return(0,R.rI)(e.key,"image/*")}},{key:"componentWillLoad",value:function(){this.list()}},{key:"render",value:function(){var e=this;return(0,p.h)("div",null,(0,p.h)("div",{class:"album-container"},(0,p.h)("div",{class:"grid-row"},this.albumItems.map(function(r){return(0,p.h)("div",{class:"grid-item",key:"key-".concat(r.key)},(0,p.h)("amplify-s3-image",{key:e.imgArr[r.key],imgKey:r.key,level:e.level,path:e.path,identityId:e.identityId,track:e.track,handleOnError:e.handleOnError,handleOnLoad:e.handleOnLoad}),(0,p.h)("span",{class:"img-overlay"}))}))),this.picker&&(0,p.h)("amplify-picker",{pickerText:x.o.get(this.pickerText),inputHandler:function(s){return e.handlePick(s)},acceptValue:"image/*"}))}}]),a}();w.style=":host{--overlay-bg-color:rgba(0, 0, 0, 0.15)}.album-container{-webkit-box-sizing:border-box;box-sizing:border-box;max-width:100%;margin:0 auto;padding:0 2rem}.grid-row{display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;margin:-1rem -1rem;padding-bottom:3rem}.grid-item{position:relative;-ms-flex:1 0 22rem;flex:1 0 22rem;-ms-flex-positive:1;flex-grow:1;margin:1rem;display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center}amplify-s3-image{--width:22rem;--height:20rem;border-radius:5px;-o-object-fit:cover;object-fit:cover}.img-overlay{display:none;width:100%;height:21rem;position:absolute;top:0;left:0;background-color:var(--overlay-bg-color)}.grid-item:hover .img-overlay{display:block}"}}]);