-
Notifications
You must be signed in to change notification settings - Fork 0
/
367.f22b98b8de754ef79b73.js
1 lines (1 loc) · 4.83 KB
/
367.f22b98b8de754ef79b73.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 A}});var g,v=n(60332),P=n(8239),C=n(75134),D=n(47289),M=n(88774),h=n.n(M),p=n(65513),w=n(45013),U=n(77),R=n(53799),x=n(22594),K=n(33754),L=n(84665),E=n(78660),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 i=[],b=0;b<256;++b)i.push((b+256).toString(16).substr(1));function Z(a,r,e){var t=(a=a||{}).random||(a.rng||j)();if(t[6]=15&t[6]|64,t[8]=63&t[8]|128,r){e=e||0;for(var s=0;s<16;++s)r[e+s]=t[s];return r}return function(a){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,e=(i[a[r+0]]+i[a[r+1]]+i[a[r+2]]+i[a[r+3]]+"-"+i[a[r+4]]+i[a[r+5]]+"-"+i[a[r+6]]+i[a[r+7]]+"-"+i[a[r+8]]+i[a[r+9]]+"-"+i[a[r+10]]+i[a[r+11]]+i[a[r+12]]+i[a[r+13]]+i[a[r+14]]+i[a[r+15]]).toLowerCase();if(!S(e))throw TypeError("Stringified UUID is invalid");return e}(t)}var f=new w.k("S3Album"),A=function(){function a(r){var e=this;(0,C.Z)(this,a),(0,p.r)(this,r),this.contentType="binary/octet-stream",this.level=x.A.Public,this.picker=!0,this.pickerText=K.T.PICKER_TEXT,this.albumItems=[],this.imgArr={},this.list=(0,P.Z)(h().mark(function t(){var s,m,o,u,d;return h().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:if(o=e.level,u=e.track,d=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(L.d);case 4:return l.prev=4,l.next=7,E.Ke.list(m,{level:o,track:u,identityId:d});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()}},t,null,[[4,11]])})),this.marshal=function(t){t.forEach(function(o){var d=o.key.toLowerCase().split(".")[1];k.i.has(d)&&(!o.contentType||o.contentType&&"binary/octet-stream"===o.contentType)&&(o.contentType=e.getContentType(o))});var s=t.filter(function(o){return o.contentType&&o.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(t){t.map(function(s){e.imgArr["".concat(s.key)]=s.key})},this.handlePick=function(){var t=(0,P.Z)(h().mark(function s(m){var o,u,y,T,c,O;return h().wrap(function(_){for(;;)switch(_.prev=_.next){case 0:return y=e.level,T=e.track,c=(void 0===(u=e.path)?"":u)+(0,k.c)(o=m.target.files[0],e.fileToKey),_.prev=3,_.next=6,(0,k.p)(c,o,y,T,o.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(c)?(e.albumItems=(0,v.Z)(e.albumItems),e.imgArr[c]="".concat(c,"-").concat(Z())):(O=[].concat((0,v.Z)(e.albumItems),(0,v.Z)(e.filter?e.filter([{key:c}]):[{key:c}])),e.albumItems=e.sort?e.sort(O):O);case 13:case"end":return _.stop()}},s,null,[[3,8]])}));return function(s){return t.apply(this,arguments)}}()}return(0,D.Z)(a,[{key:"getContentType",value:function(e){return(0,U.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(t){return(0,p.h)("div",{class:"grid-item",key:"key-".concat(t.key)},(0,p.h)("amplify-s3-image",{key:e.imgArr[t.key],imgKey:t.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:R.o.get(this.pickerText),inputHandler:function(s){return e.handlePick(s)},acceptValue:"image/*"}))}}]),a}();A.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}"}}]);