(this["webpackJsonppixxio-importer"]=this["webpackJsonppixxio-importer"]||[]).push([[0],{123:function(e,t,a){},147:function(e,t,a){"use strict";a.r(t);var n=a(0),s=a.n(n),i=a(11),r=a(38),c=(a(120),a(121),a(122),a(123),a(9)),o=a.n(c),l=a(17),d=a(42),u=a(43),p=a(16),h=a(68),b=a(67),j=a(15),g=a(97),x=a(2),f=function(e){Object(h.a)(a,e);var t=Object(b.a)(a);function a(e){var n;return Object(d.a)(this,a),(n=t.call(this,e)).onConfigure=Object(l.a)(o.a.mark((function e(){var t;return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.props.sdk.app.getCurrentState();case 2:return t=e.sent,e.abrupt("return",{parameters:n.state.parameters,targetState:t});case 4:case"end":return e.stop()}}),e)}))),n.state={parameters:{pixxioApiUrl:"",pixxioApiKey:"",assetTitlePrefix:""}},n.handleChange=n.handleChange.bind(Object(p.a)(n)),e.sdk.app.onConfigure((function(){return n.onConfigure()})),n}return Object(u.a)(a,[{key:"handleChange",value:function(e){var t=this.state.parameters;t[e.currentTarget.name]=e.currentTarget.value,this.setState({parameters:t})}},{key:"componentDidMount",value:function(){var e=Object(l.a)(o.a.mark((function e(){var t,a=this;return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.props.sdk.app.getParameters();case 2:t=e.sent,this.setState(t?{parameters:t}:this.state,(function(){a.props.sdk.app.setReady()}));case 4:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"render",value:function(){return Object(x.jsx)(j.g,{className:Object(g.a)({margin:"80px"}),children:Object(x.jsxs)(j.a,{children:[Object(x.jsx)(j.b,{children:"Pixxio Importer - App Config"}),Object(x.jsx)(j.d,{children:"This app imports media from Pixxio into Contentful. Please configure the following parameters."}),Object(x.jsx)(j.e,{id:"pixxioApiUrl",labelText:"Pixxio API URL",name:"pixxioApiUrl",required:!0,value:this.state.parameters.pixxioApiUrl,onChange:this.handleChange,textInputProps:{disabled:!1,maxLength:100,placeholder:""},width:"full"}),Object(x.jsx)(j.e,{id:"pixxioApiKey",labelText:"Pixxio API Key",name:"pixxioApiKey",required:!0,value:this.state.parameters.pixxioApiKey,onChange:this.handleChange,textInputProps:{disabled:!1,maxLength:100,placeholder:""},width:"full"}),Object(x.jsx)(j.e,{id:"assetTitlePrefix",labelText:"Contentful Asset Title Prefix",name:"assetTitlePrefix",value:this.state.parameters.assetTitlePrefix,onChange:this.handleChange,textInputProps:{disabled:!1,maxLength:100,placeholder:""},width:"full"})]})})}}]),a}(n.Component),m=function(e){return Object(x.jsx)(j.d,{children:"Hello Entry Editor Component"})},v=a(98),O=a(72),y=a(69),k=a(22),C=a(14),T=a(99),S=a(28),w=a.n(S),F=function(){function e(t){Object(d.a)(this,e),this.spaceId=void 0,this.spaceId=t}return Object(u.a)(e,[{key:"set",value:function(e,t,a){var n={value:t,expiry:(new Date).getTime()+1e3*a*60*60};localStorage.setItem(this.spaceId+"-"+e,JSON.stringify(n))}},{key:"get",value:function(e){var t=localStorage.getItem(this.spaceId+"-"+e);if(!t)return null;var a=JSON.parse(t);return(new Date).getTime()>a.expiry?(localStorage.removeItem(this.spaceId+"-"+e),null):a.value}},{key:"remove",value:function(e){return localStorage.removeItem(this.spaceId+"-"+e)}}]),e}(),A=a(216),I=a(192),D=a(199),P=a(200),N=a(222),L=a(201),B=a(202),E=a(221),K=a(55),R=a(205),z=a(215),M=a(102),U=a(217),Q=a(207),_=a(223),q=a(206),H=a(210),W=a(211),J=a(212),Y=a(214),G=a(189),Z=a(5),V=a(193),X=a(194),$=a(197),ee=a(196),te=a(195),ae=Object(G.a)({root:{cardWidth:320}});function ne(e){var t=ae(),a=e.file,n=Object(Z.a)((function(e){return{tooltip:{backgroundColor:"white",color:"rgba(0, 0, 0, 0.87)",cardWidth:320,fontSize:e.typography.pxToRem(12),border:"2px solid #dadde9"}}}))(I.a);return Object(x.jsx)(V.a,{onClick:function(){return e.imageClicked(a)},className:t.root,style:{backgroundColor:e.selected?"#16875D":"white",height:320,width:320},children:Object(x.jsxs)(X.a,{children:[Object(x.jsx)(te.a,{component:"img",alt:a.description,height:240,image:a.imagePath,title:a.description}),Object(x.jsx)(n,{disableFocusListener:!0,disableTouchListener:!0,placement:"right",arrow:!0,title:Object(x.jsxs)(s.a.Fragment,{children:[Object(x.jsx)(K.a,{style:{textAlign:"center"},variant:"h6",color:"textPrimary",children:a.subject}),Object(x.jsxs)(K.a,{variant:"body1",color:"textSecondary",component:"p",children:[Object(x.jsx)("strong",{children:"Beschreibung:"})," ",a.description," ",Object(x.jsx)("br",{}),Object(x.jsx)("strong",{children:"Kategorie:"})," ",a.category," ",Object(x.jsx)("br",{}),Object(x.jsx)("strong",{children:"Status:"})," ",a.fileStatus.statusTitle," ",Object(x.jsx)("br",{}),Object(x.jsx)("strong",{children:"Upload Datum:"})," ",a.uploadDate," ",Object(x.jsx)("br",{}),Object(x.jsx)("strong",{children:"Lizenz:"})," ",a.licenses.map((function(e){return e.licenseName})).toString()," ",Object(x.jsx)("br",{}),Object(x.jsx)("strong",{children:"Keywords:"})," ",a.keywords]})]}),children:Object(x.jsx)(ee.a,{children:Object(x.jsx)(K.a,{style:{textAlign:"center"},variant:"h6",children:a.subject})})}),Object(x.jsx)($.a,{})]})})}var se=a(208),ie=a(209),re=a(213),ce=a(219),oe=a(151),le=a(204),de=a(96),ue=a(203),pe=a(220),he=a(218),be=Object(de.a)({palette:{primary:{main:"#2E75D4"},secondary:{main:"#BF3045"},error:{main:"#BF3045"},warning:{main:"#F79B0C"},info:{main:"#2E75D4"},success:{main:"#16875D"}}});function je(e){var t=e.children,a=e.value,n=e.index,s=Object(T.a)(e,["children","value","index"]);return Object(x.jsx)("div",Object(C.a)(Object(C.a)({role:"tabpanel",hidden:a!==n},s),{},{children:a===n&&Object(x.jsx)(A.a,{children:t})}))}function ge(e){return Object(x.jsx)(ce.a,Object(C.a)({elevation:6,variant:"filled"},e))}var xe,fe=Object(Z.a)((function(e){return{tooltip:{backgroundColor:"#ffffff",color:"rgba(0, 0, 0, 0.87)",fontSize:e.typography.pxToRem(12),border:"2px solid #dadde9"}}}))(I.a),me="pixxio-asset-",ve="pixxio-mediaAsset-",Oe=20,ye=1e7,ke=["id","originalFilename","keywords","uploadDate","category","imagePath","imageHeight","imageWidth","subject","description","fileSize","fileType","formatType","fileStatus","collections","licenses"],Ce=["webimage","raw","image","other"],Te=function(e){Object(h.a)(a,e);var t=Object(b.a)(a);function a(e){var n;Object(d.a)(this,a),(n=t.call(this,e)).render=function(){var e,t,a,i,r,c,o,l,d,u,h,b,j,g,f,m,v,O,y,k,T,S,w=n.props.classes,F="".concat(n.state.user.preName," ").concat(n.state.user.surName),I=n.state.collections.map((function(e){var t,a,s,i;return Object(x.jsxs)(D.a,{button:!0,onClick:function(t){return n.getCollection(e.id)},children:[Object(x.jsx)(P.a,{children:Object(x.jsx)(N.a,{alt:null===e||void 0===e||null===(t=e.filesSnippet)||void 0===t||null===(a=t[0])||void 0===a?void 0:a.originalFilename,src:null===e||void 0===e||null===(s=e.filesSnippet)||void 0===s||null===(i=s[0])||void 0===i?void 0:i.imagePath})}),Object(x.jsx)(L.a,{primary:e.collectionName,secondary:e.quantity+" Dateien | Zuletzt ge\xe4ndert: "+e.modifyDate})]},e.id)})),G=[];(null===(e=n.state)||void 0===e||null===(t=e.files)||void 0===t?void 0:t.length)>0&&(G=n.state.files.map((function(e){var t;return Object(x.jsx)(B.a,{item:!0,children:Object(x.jsx)(ne,{selected:void 0!==(null===(t=n.state.selectedFiles)||void 0===t?void 0:t.find((function(t){return t.id===e.id}))),imageClicked:n.imageClicked,file:e})},e.id)})));var Z=n.state.existingFiles.files.map((function(e){return Object(x.jsxs)(D.a,{children:[Object(x.jsx)(P.a,{children:Object(x.jsx)(N.a,{alt:e.originalFilename,src:e.imagePath})}),Object(x.jsx)(L.a,{primary:e.subject,secondary:e.description})]},e.id)})),V=n.state.failedFiles.map((function(e){return Object(x.jsxs)(D.a,{children:[Object(x.jsx)(P.a,{children:Object(x.jsx)(N.a,{alt:e.originalFilename,src:e.imagePath})}),Object(x.jsx)(L.a,{primary:e.subject,secondary:e.description})]},e.id)}));return Object(x.jsx)(ue.a,{theme:be,children:Object(x.jsxs)("div",{style:{margin:"20px"},children:[Object(x.jsx)(E.a,{open:n.state.snackbar.open,autoHideDuration:5e3,onClose:function(e,t){"clickaway"!==t&&n.setState({snackbar:Object(C.a)(Object(C.a)({},n.state.snackbar),{},{open:!1})})},children:Object(x.jsx)(ge,{onClose:function(e,t){"clickaway"!==t&&n.setState({snackbar:Object(C.a)(Object(C.a)({},n.state.snackbar),{},{open:!1})})},severity:n.state.snackbar.severity,children:n.state.snackbar.message})}),Object(x.jsx)(oe.a,{className:w.backdrop,open:n.state.loading,children:Object(x.jsxs)(A.a,{position:"relative",display:"inline-flex",children:[Object(x.jsx)(le.a,{variant:"determinate",color:"primary",value:n.state.progress,size:100,thickness:5}),Object(x.jsx)(A.a,{top:0,left:0,bottom:0,right:0,position:"absolute",display:"flex",alignItems:"center",justifyContent:"center",children:Object(x.jsx)(K.a,{variant:"h5",component:"div",color:"inherit",children:"".concat(Math.round(n.state.progress),"%")})})]})}),Object(x.jsxs)(B.a,{container:!0,style:{marginBottom:"20px"},children:[Object(x.jsx)(B.a,{item:!0,xs:9,children:Object(x.jsx)(K.a,{variant:"h4",children:"Pixxio Importer"})}),Object(x.jsx)(B.a,{item:!0,xs:3,children:!0===n.state.loggedIn&&Object(x.jsxs)(B.a,{container:!0,justify:"flex-end",children:[Object(x.jsxs)(K.a,{variant:"body1",style:{marginRight:"20px",display:"inline-block"},children:["Angemeldet als ",Object(x.jsx)("br",{})," ",Object(x.jsx)("strong",{children:F})]}),Object(x.jsx)(R.a,{variant:"contained",color:"secondary",onClick:function(){n.logout(),n.setState({snackbar:{open:!0,message:"Abmeldung erfolgreich.",severity:"info"}})},children:"Abmelden"})]})})]}),!1===n.state.loggedIn&&Object(x.jsxs)(A.a,{children:[Object(x.jsx)(K.a,{variant:"h6",gutterBottom:!0,children:"Login"}),Object(x.jsxs)(B.a,{container:!0,children:[Object(x.jsx)(z.a,{id:"refreshToken",label:"Pixxio Refresh Token",name:"refreshToken",value:n.state.refreshToken,onChange:n.handleChange,variant:"outlined",style:{marginRight:"20px"}}),Object(x.jsx)(R.a,{variant:"contained",color:"primary",disabled:0===n.state.refreshToken.length,onClick:n.handleLogin,children:"Anmelden"})]})]}),!0===n.state.loggedIn&&Object(x.jsxs)("div",{children:[Object(x.jsx)(M.a,{style:{marginBottom:"20px"},children:Object(x.jsxs)(U.a,{value:n.state.selectedTab,onChange:n.handleChangeTab,indicatorColor:"primary",textColor:"primary",centered:!0,children:[Object(x.jsx)(Q.a,{label:"Media"}),Object(x.jsx)(Q.a,{label:"Collections"})]})}),Object(x.jsxs)(je,{value:n.state.selectedTab,index:0,children:[Object(x.jsxs)(A.a,{padding:"20px",marginBottom:"20px",border:2,borderRadius:16,borderColor:"#2E75D4",children:[Object(x.jsxs)(B.a,{container:!0,justify:"center",style:{marginBottom:"20px"},children:[Object(x.jsx)(B.a,{item:!0,xs:11,children:Object(x.jsx)(pe.a,{multiple:!0,freeSolo:!0,id:"searchBar",options:[],value:n.state.searchBar,onChange:function(e,t){n.setState({searchBar:t})},getOptionLabel:function(e){return e},renderTags:function(e,t){return e.map((function(e,a){return Object(x.jsx)(_.a,Object(C.a)({color:"primary",label:e},t({index:a})))}))},renderInput:function(e){return Object(x.jsx)(z.a,Object(C.a)(Object(C.a)({},e),{},{label:"Suchbegriffe",variant:"outlined",placeholder:"Suchbegriff mit Enter eingeben"}))}})}),Object(x.jsx)(B.a,{item:!0,xs:1,children:Object(x.jsx)(fe,{disableFocusListener:!0,disableTouchListener:!0,placement:"top",arrow:!0,title:Object(x.jsx)(s.a.Fragment,{children:Object(x.jsx)(K.a,{variant:"body1",color:"textSecondary",component:"p",children:"Dateien werden nach Beschreibung, Keywords, Kategorie, Dateiname und Dateiformat gefiltert."})}),children:Object(x.jsx)(se.a,{})})})]}),Object(x.jsxs)(B.a,{container:!0,spacing:2,children:[Object(x.jsx)(B.a,{item:!0,xs:5,children:Object(x.jsx)(pe.a,{multiple:!0,id:"fileStatusFilter",value:n.state.selectedFileStati,onChange:function(e,t){n.setState({selectedFileStati:t})},options:n.state.fileStati,getOptionLabel:function(e){return e.statusTitle},renderTags:function(e,t){return e.map((function(e,a){return Object(x.jsx)(_.a,Object(C.a)({color:"primary",label:e.statusTitle},t({index:a})))}))},renderInput:function(e){return Object(x.jsx)(z.a,Object(C.a)(Object(C.a)({},e),{},{label:"Datei Status",variant:"outlined",placeholder:"Filtern nach Datei Status"}))}})}),Object(x.jsx)(B.a,{item:!0,xs:5,children:Object(x.jsx)(pe.a,{multiple:!0,id:"categoriesFilter",value:n.state.selectedCategories,onChange:function(e,t){n.setState({selectedCategories:t})},options:n.state.categories,getOptionLabel:function(e){return e},renderTags:function(e,t){return e.map((function(e,a){return Object(x.jsx)(_.a,Object(C.a)({color:"primary",label:e},t({index:a})))}))},renderInput:function(e){return Object(x.jsx)(z.a,Object(C.a)(Object(C.a)({},e),{},{label:"Datei Kategorie",variant:"outlined",placeholder:"Filtern nach Datei Kategorie"}))}})})," ",Object(x.jsx)(B.a,{container:!0,item:!0,xs:2,children:Object(x.jsx)(R.a,{variant:"contained",color:"primary",onClick:function(){return n.searchMedia()},children:"Suchen"})})]})]}),n.state.files.length>0&&Object(x.jsxs)("div",{children:[Object(x.jsxs)(B.a,{container:!0,spacing:1,style:{marginBottom:"20px"},children:[Object(x.jsxs)(B.a,{item:!0,xs:4,children:[Object(x.jsx)(R.a,{color:"default",variant:"contained",onClick:function(){return n.setState({selectedFiles:[],page:Object(C.a)(Object(C.a)({},n.state.page),{},{files:1}),selectedCategories:[],selectedFileStati:[],searchBar:[],files:[]})},children:"Suche zur\xfccksetzen"})," "]}),Object(x.jsxs)(B.a,{item:!0,xs:4,style:{textAlign:"center"},children:[Object(x.jsxs)(R.a,{className:w.success,variant:"contained",color:"inherit",disabled:0===(null===(a=n.state.selectedFiles)||void 0===a?void 0:a.length),onClick:n.confirmImport,children:["Auswahl importieren"," ",(null===(i=n.state)||void 0===i||null===(r=i.selectedFiles)||void 0===r?void 0:r.length)>0?"(".concat(n.state.selectedFiles.length,")"):""]})," "]}),Object(x.jsxs)(B.a,{item:!0,xs:4,style:{textAlign:"right"},children:[Object(x.jsx)(R.a,{style:{marginRight:"10px"},variant:"contained",onClick:function(){return n.setState({selectedFiles:[]})},children:"Alle abw\xe4hlen"}),Object(x.jsxs)(R.a,{variant:"contained",onClick:function(){return n.setState({selectedFiles:n.state.files})},children:["Seite ausw\xe4hlen ","(".concat(n.state.files.length,")")]})]})]}),Object(x.jsx)(B.a,{container:!0,justify:"center",spacing:1,children:G}),Object(x.jsx)(B.a,{container:!0,justify:"center",style:{marginTop:"50px"},children:Object(x.jsx)(he.a,{count:Math.ceil((n.state.filesQuantity>0?n.state.filesQuantity:1)/Oe),page:n.state.page.files,color:"primary",onChange:n.filesPageChange})})]})]}),Object(x.jsxs)(je,{value:n.state.selectedTab,index:1,children:[void 0===n.state.collection&&n.state.collections.length>0&&Object(x.jsxs)("div",{children:[Object(x.jsx)(q.a,{children:I}),Object(x.jsx)(B.a,{container:!0,justify:"center",style:{marginTop:"50px"},children:Object(x.jsx)(he.a,{count:Math.ceil(n.state.collectionsQuantity/Oe),page:n.state.page.collections,color:"primary",onChange:n.collectionsPageChange})})]}),null!=n.state.collection&&Object(x.jsxs)("div",{children:[Object(x.jsx)(K.a,{variant:"h5",style:{textAlign:"center"},children:null===(c=Object(p.a)(n))||void 0===c||null===(o=c.state)||void 0===o||null===(l=o.collection)||void 0===l?void 0:l.collectionName}),Object(x.jsxs)(K.a,{variant:"body1",style:{marginBottom:"20px"},children:[Object(x.jsx)("strong",{children:"Anzahl Dateien:"})," ",null===(d=Object(p.a)(n))||void 0===d||null===(u=d.state)||void 0===u||null===(h=u.collection)||void 0===h?void 0:h.quantity,Object(x.jsx)("br",{}),Object(x.jsx)("strong",{children:"Zuletzt ge\xe4ndert:"})," ",null===(b=Object(p.a)(n))||void 0===b||null===(j=b.state)||void 0===j||null===(g=j.collection)||void 0===g?void 0:g.modifyDate,Object(x.jsx)("br",{}),Object(x.jsx)("strong",{children:"Beschreibung:"})," ",null===(f=Object(p.a)(n))||void 0===f||null===(m=f.state)||void 0===m||null===(v=m.collection)||void 0===v?void 0:v.description,Object(x.jsx)("br",{})]}),Object(x.jsxs)(B.a,{container:!0,spacing:1,style:{marginBottom:"20px"},children:[Object(x.jsxs)(B.a,{item:!0,xs:4,children:[Object(x.jsx)(R.a,{color:"default",variant:"contained",startIcon:Object(x.jsx)(ie.a,{}),onClick:function(){return n.setState({collection:void 0,selectedFiles:[],page:Object(C.a)(Object(C.a)({},n.state.page),{},{files:1})})},children:"Zur\xfcck"})," "]}),Object(x.jsxs)(B.a,{item:!0,xs:4,style:{textAlign:"center"},children:[Object(x.jsxs)(R.a,{className:w.success,variant:"contained",color:"inherit",disabled:0===(null===(O=n.state.selectedFiles)||void 0===O?void 0:O.length),onClick:n.confirmImport,children:["Auswahl importieren"," ",(null===(y=n.state)||void 0===y||null===(k=y.selectedFiles)||void 0===k?void 0:k.length)>0?"(".concat(n.state.selectedFiles.length,")"):""]})," "]}),Object(x.jsxs)(B.a,{item:!0,xs:4,style:{textAlign:"right"},children:[Object(x.jsx)(R.a,{style:{marginRight:"10px"},variant:"contained",onClick:function(){return n.setState({selectedFiles:[]})},children:"Alle abw\xe4hlen"}),Object(x.jsxs)(R.a,{variant:"contained",onClick:function(){return n.setState({selectedFiles:n.state.files})},children:["Seite ausw\xe4hlen ","(".concat(n.state.files.length,")")]})]})]}),Object(x.jsx)(B.a,{container:!0,justify:"center",spacing:1,children:G.length>0?G:Object(x.jsx)(K.a,{style:{margin:"50px"},variant:"body1",children:"Keine Bild-Dateien vorhanden."})}),Object(x.jsx)(B.a,{container:!0,justify:"center",style:{marginTop:"50px"},children:Object(x.jsx)(he.a,{count:Math.ceil((n.state.filesQuantity>0?n.state.filesQuantity:1)/Oe),page:n.state.page.files,color:"primary",onChange:n.filesPageChange})})]})]})]}),Object(x.jsxs)(H.a,{open:n.state.confirmDialogOpen,onClose:function(){n.setState({confirmDialogOpen:!1})},"aria-labelledby":"responsive-dialog-title",children:[Object(x.jsx)(W.a,{className:n.state.existingFiles.files.length>0?w.warning:w.info,style:{textAlign:"center"},id:"responsive-dialog-title",children:"Import best\xe4tigen"}),Object(x.jsxs)(J.a,{children:[Object(x.jsxs)(K.a,{variant:"body1",children:["Dateien, die importiert werden: ",null!==(T=n.state.selectedFiles.length)&&void 0!==T?T:"0"]}),n.state.existingFiles.files.length>0&&Object(x.jsxs)("div",{children:[Object(x.jsxs)("div",{style:{textAlign:"center"},children:[" ",Object(x.jsx)(re.a,{})]}),Object(x.jsx)(K.a,{variant:"body1",children:Object(x.jsxs)("strong",{children:[n.state.existingFiles.files.length+" ","Dateien sind bereits in Contentful vorhanden und w\xfcrden \xfcberschrieben werden!"]})}),Object(x.jsx)(q.a,{children:Z})]})]}),Object(x.jsxs)(Y.a,{children:[Object(x.jsx)(R.a,{onClick:function(){n.setState({confirmDialogOpen:!1})},color:"secondary",variant:"contained",children:"Abbrechen"}),Object(x.jsx)(R.a,{className:w.success,onClick:n.importFiles,color:"inherit",variant:"contained",children:"Best\xe4tigen"})]})]}),Object(x.jsxs)(H.a,{open:n.state.resultDialogOpen,onClose:function(){n.setState({failedFiles:[],resultDialogOpen:!1})},"aria-labelledby":"responsive-dialog-title",children:[n.state.failedFiles.length>0?Object(x.jsx)(W.a,{className:w.warning,style:{textAlign:"center"},id:"responsive-dialog-title",children:"Fehler beim Import"}):Object(x.jsx)(W.a,{className:w.success,style:{textAlign:"center"},id:"responsive-dialog-title",children:"Import abgeschlossen"}),Object(x.jsx)(J.a,{children:n.state.failedFiles.length>0?Object(x.jsxs)("div",{children:[Object(x.jsx)(K.a,{variant:"body1",children:Object(x.jsxs)("strong",{children:["Dateien, die nicht erfolgreich importiert wurden: ",null!==(S=n.state.failedFiles.length)&&void 0!==S?S:"0"]})}),Object(x.jsx)(q.a,{children:V})]}):Object(x.jsx)(K.a,{variant:"body1",children:"Alle Dateien wurden erfolgreich importiert."})}),Object(x.jsx)(Y.a,{children:Object(x.jsx)(R.a,{className:w.success,onClick:function(){n.setState({failedFiles:[],resultDialogOpen:!1})},color:"inherit",variant:"contained",children:"Okay"})})]})]})})};var i=e.sdk.parameters.invocation,r=e.sdk.parameters.installation,c=!1;return null!=(xe=new F(e.sdk.ids.space)).get("refreshToken")&&(c=!0),n.state={invocationParams:i,installationParams:r,pixxioTagId:"",refreshToken:"",loggedIn:c,user:{userName:"",preName:"",surName:"",email:""},collections:[],collectionsQuantity:0,collection:void 0,files:[],filesQuantity:0,media:[],selectedFiles:[],existingFiles:{assets:[],mediaAssets:[],files:[]},failedFiles:[],selectedTab:0,page:{files:1,collections:1},loading:!1,progress:0,snackbar:{open:!1,message:"",severity:""},confirmDialogOpen:!1,resultDialogOpen:!1,searchBar:[],fileStati:[],selectedFileStati:[],categories:[],selectedCategories:[]},w.a.defaults.baseURL=n.state.installationParams.pixxioApiUrl,w.a.interceptors.request.use(function(){var e=Object(l.a)(o.a.mark((function e(t){var a;return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==(null===(a=t.params)||void 0===a?void 0:a.accessToken)||"/accessToken"===t.url){e.next=4;break}return e.next=3,n.getAccessToken();case 3:t.params=Object(C.a)(Object(C.a)({},t.params),{},{accessToken:xe.get("accessToken")});case 4:return e.abrupt("return",t);case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),(function(e){return Promise.reject(e)})),n.handleChange=n.handleChange.bind(Object(p.a)(n)),n.handleChangeTab=n.handleChangeTab.bind(Object(p.a)(n)),n.handleLogin=n.handleLogin.bind(Object(p.a)(n)),n.logout=n.logout.bind(Object(p.a)(n)),n.getCollections=n.getCollections.bind(Object(p.a)(n)),n.getCollection=n.getCollection.bind(Object(p.a)(n)),n.imageClicked=n.imageClicked.bind(Object(p.a)(n)),n.confirmImport=n.confirmImport.bind(Object(p.a)(n)),n.importFiles=n.importFiles.bind(Object(p.a)(n)),n.filesPageChange=n.filesPageChange.bind(Object(p.a)(n)),n.collectionsPageChange=n.collectionsPageChange.bind(Object(p.a)(n)),n.searchMedia=n.searchMedia.bind(Object(p.a)(n)),n}return Object(u.a)(a,[{key:"setStateAsync",value:function(e){var t=this;return new Promise((function(a){t.setState(e,a)}))}},{key:"searchMedia",value:function(){var e=Object(l.a)(o.a.mark((function e(){var t,a,n,s,i=arguments;return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(t=!(i.length>0&&void 0!==i[0])||i[0])&&this.setState({files:[],filesQuantity:0,selectedFiles:[],page:Object(C.a)(Object(C.a)({},this.state.page),{},{files:1})}),e.next=4,w.a.get("/files",{params:{accessToken:xe.get("accessToken"),options:{pagination:"".concat(Oe,"-").concat(this.state.page.files),sortBy:"subject",searchTerm:this.state.searchBar.toString(),fileStatus:this.state.selectedFileStati.map((function(e){return e.id})),category:this.state.selectedCategories.toString(),formatType:Ce,fields:ke}}});case 4:if("200"!==(a=e.sent).data.status){e.next=12;break}return n=a.data.files,s=a.data.quantity,this.setState({files:n,filesQuantity:s}),console.log("Search result:",n),t&&this.setState({snackbar:{open:!0,message:"".concat(s," Dateien gefunden."),severity:"info"}}),e.abrupt("return",!0);case 12:return this.setState({snackbar:{open:!0,message:"Fehler bei der Suche!",severity:"error"}}),console.error(null===a||void 0===a?void 0:a.data),e.abrupt("return",!1);case 15:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"getFileStati",value:function(){var e=Object(l.a)(o.a.mark((function e(){var t,a;return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,w.a.get("/statuses",{params:{accessToken:xe.get("accessToken"),options:{pagination:"100-1",sortBy:"statusTitle",fields:["statusTitle","id"]}}});case 2:if("200"!==(t=e.sent).data.status){e.next=9;break}return(a=t.data.statuses).push({id:"none",statusTitle:"Kein Status"}),a.sort((function(e,t){return e.statusTitle.localeCompare(t.statusTitle)})),this.setState({fileStati:a}),e.abrupt("return",!0);case 9:return this.setState({snackbar:{open:!0,message:"Fehler beim Laden der Dateien Stati!",severity:"error"}}),console.error(null===t||void 0===t?void 0:t.data),e.abrupt("return",!1);case 12:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"getCategories",value:function(){var e=Object(l.a)(o.a.mark((function e(){var t,a;return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,w.a.get("/categories",{params:{accessToken:xe.get("accessToken")}});case 2:if("200"!==(t=e.sent).data.status){e.next=8;break}return(a=t.data.categories).sort(),this.setState({categories:a}),e.abrupt("return",!0);case 8:return this.setState({snackbar:{open:!0,message:"Fehler beim Laden der Kategorien!",severity:"error"}}),console.error(null===t||void 0===t?void 0:t.data),e.abrupt("return",!1);case 11:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"handleChange",value:function(e){this.setState(Object(k.a)({},e.currentTarget.name,e.currentTarget.value))}},{key:"handleChangeTab",value:function(){var e=Object(l.a)(o.a.mark((function e(t,a){return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.setState({selectedTab:a,files:[],selectedFiles:[],collection:void 0,page:Object(C.a)(Object(C.a)({},this.state.page),{},{files:1})}),1!==a){e.next=4;break}return e.next=4,this.getCollections();case 4:case"end":return e.stop()}}),e,this)})));return function(t,a){return e.apply(this,arguments)}}()},{key:"filesPageChange",value:function(){var e=Object(l.a)(o.a.mark((function e(t,a){var n,s;return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.setStateAsync({page:Object(C.a)(Object(C.a)({},this.state.page),{},{files:a})});case 2:if(0!==this.state.selectedTab){e.next=7;break}return e.next=5,this.searchMedia(!1);case 5:e.next=10;break;case 7:if(!(null===(n=this.state)||void 0===n||null===(s=n.collection)||void 0===s?void 0:s.id)){e.next=10;break}return e.next=10,this.getCollection(this.state.collection.id);case 10:case"end":return e.stop()}}),e,this)})));return function(t,a){return e.apply(this,arguments)}}()},{key:"collectionsPageChange",value:function(){var e=Object(l.a)(o.a.mark((function e(t,a){return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.setStateAsync({page:Object(C.a)(Object(C.a)({},this.state.page),{},{collections:a})});case 2:return e.next=4,this.getCollections();case 4:case"end":return e.stop()}}),e,this)})));return function(t,a){return e.apply(this,arguments)}}()},{key:"handleLogin",value:function(){var e=Object(l.a)(o.a.mark((function e(t){return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return xe.set("refreshToken",this.state.refreshToken,8760),e.next=3,this.getAccessToken();case 3:if(!e.sent){e.next=5;break}this.setState({snackbar:{open:!0,message:"Anmeldung erfolgreich!",severity:"info"}});case 5:t.preventDefault();case 6:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"getAccessToken",value:function(){var e=Object(l.a)(o.a.mark((function e(){var t,a,n;return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=(t=xe.get("refreshToken"))){e.next=3;break}return e.abrupt("return",this.setState({loggedIn:!1}));case 3:return e.next=5,w.a.post("/accessToken",{apiKey:this.state.installationParams.pixxioApiKey,refreshToken:t});case 5:if("200"!==(a=e.sent).data.status){e.next=16;break}return xe.set("accessToken",a.data.accessToken,1),xe.set("refreshToken",t,8760),e.next=11,this.getUser();case 11:return(n=e.sent)&&(this.getFileStati(),this.getCategories()),e.abrupt("return",n);case 16:"2004"===a.data.errorcode?this.setState({snackbar:{open:!0,message:"Login fehlgeschlagen! API Key ist ung\xfcltig",severity:"error"}}):"2005"===a.data.errorcode?this.setState({snackbar:{open:!0,message:"Login fehlgeschlagen! Refresh Token ist ung\xfcltig.",severity:"error"}}):"2008"===a.data.errorcode?this.setState({snackbar:{open:!0,message:"Login fehlgeschlagen! User ist als inaktiv gesetzt.",severity:"error"}}):this.setState({snackbar:{open:!0,message:"Login fehlgeschlagen!",severity:"error"}});case 17:return console.error(null===a||void 0===a?void 0:a.data),this.logout(),e.abrupt("return",!1);case 20:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"logout",value:function(){xe.remove("accessToken"),xe.remove("refreshToken"),this.setState({loggedIn:!1}),this.setState({refreshToken:""}),this.setState({user:{userName:"",preName:"",surName:"",email:""},selectedFiles:[],page:Object(C.a)(Object(C.a)({},this.state.page),{},{files:1}),selectedCategories:[],selectedFileStati:[],searchBar:[],files:[]})}},{key:"getUser",value:function(){var e=Object(l.a)(o.a.mark((function e(){var t,a;return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,w.a.get("/users/current",{params:{accessToken:xe.get("accessToken"),options:{fields:["preName","surName","userName","email"]}}});case 2:if("200"!==(t=e.sent).data.status){e.next=7;break}return a={userName:t.data.userName,preName:t.data.preName,surName:t.data.surName,email:t.data.email},this.setState({user:a,loggedIn:!0}),e.abrupt("return",!0);case 7:return console.error(null===t||void 0===t?void 0:t.data),e.abrupt("return",!1);case 9:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"componentDidMount",value:function(){var e=Object(l.a)(o.a.mark((function e(){return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getAccessToken();case 2:return e.next=4,this.getPixxioTagId();case 4:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"getCollections",value:function(){var e=Object(l.a)(o.a.mark((function e(){var t,a,n;return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,w.a.get("/collections",{params:{accessToken:xe.get("accessToken"),options:{pagination:"".concat(Oe,"-").concat(this.state.page.collections),sortBy:"collectionName"}}});case 2:if("200"!==(t=e.sent).data.status){e.next=9;break}return a=t.data.collections,n=t.data.quantity,this.setState({collections:a,collectionsQuantity:n}),console.log("Collections:",this.state.collections),e.abrupt("return",!0);case 9:return this.setState({snackbar:{open:!0,message:"Fehler beim Laden der Collections!",severity:"error"}}),console.error(null===t||void 0===t?void 0:t.data),e.abrupt("return",!1);case 12:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"getCollection",value:function(){var e=Object(l.a)(o.a.mark((function e(t){var a,n,s,i;return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,w.a.get("/collections/"+t,{params:{accessToken:xe.get("accessToken"),options:{pagination:"".concat(Oe,"-").concat(this.state.page.files),sortBy:"subject",fields:ke,formatType:Ce}}});case 2:if("200"!==(a=e.sent).data.status){e.next=10;break}return n=a.data,s=n.files,i=a.data.quantity,this.setState({collection:n,files:s,filesQuantity:i}),console.log("Collection:",this.state.collection),e.abrupt("return",!0);case 10:return this.setState({snackbar:{open:!0,message:"Fehler beim Laden der Collection!",severity:"error"}}),console.error(null===a||void 0===a?void 0:a.data),e.abrupt("return",!1);case 13:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"imageClicked",value:function(e){var t,a,n,s;(null===this||void 0===this||null===(t=this.state)||void 0===t||null===(a=t.selectedFiles)||void 0===a?void 0:a.find((function(t){return t.id===e.id})))?this.setState({selectedFiles:null!==(n=null===this||void 0===this||null===(s=this.state)||void 0===s?void 0:s.selectedFiles.filter((function(t){return t.id!==e.id})))&&void 0!==n?n:[]}):this.setState({selectedFiles:[].concat(Object(y.a)(this.state.selectedFiles),[e])})}},{key:"existingFiles",value:function(){var e=Object(l.a)(o.a.mark((function e(){var t,a,n,s,i,r,c,l,d,u,p,h,b,j,g;return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,void 0!==this.state.selectedFiles){e.next=4;break}return this.setState({snackbar:{open:!0,message:"Keine Dateien ausgew\xe4hlt!",severity:"info"}}),e.abrupt("return",!1);case 4:t=this.state.selectedFiles.map((function(e){return e.id})),a=t.map((function(e){return me+e})).toString(),n=t.map((function(e){return ve+e})).toString(),s=[],i=[],r=0,c=!0;case 10:if(!c){e.next=19;break}return e.next=13,this.props.sdk.space.getAssets({limit:1e3,skip:r,"sys.id[in]":a});case 13:l=e.sent,s.push.apply(s,Object(y.a)(l.items)),c=(r+=1e3)2&&void 0!==arguments[2]?arguments[2]:"";return e.lengthye?(b=(b=h/ye)>1?b:1.2,c=Math.floor(c/b),console.log('File "'.concat(i.subject,'" is too big (').concat(Math.round(h/1e6)," MB). Resizing image: ").concat(i.imageWidth,"px width -> ").concat(c,"px width"))):l=!1,e.next=6;break;case 22:if(j=s.props.sdk.locales.default,g=i.originalFilename,x=g.lastIndexOf("."),g=g.substr(0,x<0?g.length:x)+".jpg",m={fields:{title:Object(k.a)({},j,s.state.installationParams.assetTitlePrefix+i.subject),description:Object(k.a)({},j,i.description),file:Object(k.a)({},j,{upload:d,contentType:"image/jpeg",fileName:g})},sys:{id:me+i.id,version:void 0},metadata:{tags:[{sys:{type:"Link",linkType:"Tag",id:s.state.pixxioTagId}}]}},void 0===(O=s.state.existingFiles.assets.find((function(e){return e.pixxioId===i.id})))){e.next=36;break}return m.sys.version=O.version,e.next=32,s.props.sdk.space.updateAsset(m);case 32:f=e.sent,console.log("Updated Asset ".concat(f.sys.id),f),e.next=40;break;case 36:return e.next=38,s.props.sdk.space.createAsset(m);case 38:f=e.sent,console.log("Created Asset ".concat(f.sys.id),f);case 40:return e.next=42,s.props.sdk.space.processAsset(f,j);case 42:return e.next=44,s.props.sdk.space.waitUntilAssetProcessed(f.sys.id,s.props.sdk.locales.default);case 44:return f.sys.version++,console.log("Processed Asset ".concat(f.sys.id),f),e.next=48,s.props.sdk.space.publishAsset(f);case 48:if(f=e.sent,console.log("Published Asset ".concat(f.sys.id),f),void 0===f.sys.id){e.next=69;break}if(C={fields:{title:Object(k.a)({},j,i.subject),titleTag:Object(k.a)({},j,i.subject),description:Object(k.a)({},j,s.truncateString(i.description,180)),copyright:Object(k.a)({},j,i.licenses.map((function(e){return e.licenseName.replaceAll(/\xa9\s|\xa9/g,"")})).toString()),altText:Object(k.a)({},j,s.truncateString(i.description,256)),media:Object(k.a)({},j,{sys:{type:"Link",linkType:"Asset",id:f.sys.id}}),externalId:Object(k.a)({},j,i.id),metadata:Object(k.a)({},j,{keywords:i.keywords,category:i.category,collections:i.collections.map((function(e){return e.collectionName})),status:i.fileStatus.statusTitle})},sys:{id:ve+i.id,version:void 0},metadata:{tags:[{sys:{type:"Link",linkType:"Tag",id:s.state.pixxioTagId}}]}},void 0===(T=s.state.existingFiles.mediaAssets.find((function(e){return e.pixxioId===i.id})))){e.next=61;break}return C.sys.version=T.version,e.next=57,s.props.sdk.space.updateEntry(C);case 57:y=e.sent,console.log("Updated Entry ".concat(y.sys.id),y),e.next=65;break;case 61:return e.next=63,s.props.sdk.space.createEntry("mediaAsset",C);case 63:y=e.sent,console.log("Created Entry ".concat(y.sys.id),y);case 65:return e.next=67,s.props.sdk.space.publishEntry(y);case 67:y=e.sent,console.log("Published Entry ".concat(y.sys.id),y);case 69:e.next=75;break;case 71:e.prev=71,e.t0=e.catch(1),console.error("Error for importing file ".concat(i.subject," into Contentful!"),e.t0),s.state.failedFiles.push(i);case 75:s.setState({progress:(n+1)/s.state.selectedFiles.length*100});case 76:case"end":return e.stop()}}),e,null,[[1,71]])})),t.s();case 8:if((a=t.n()).done){e.next=15;break}return e.delegateYield(n(),"t0",10);case 10:if("continue|fileLoop"!==e.t0){e.next=13;break}return e.abrupt("continue",13);case 13:e.next=8;break;case 15:e.next=20;break;case 17:e.prev=17,e.t1=e.catch(5),t.e(e.t1);case 20:return e.prev=20,t.f(),e.finish(20);case 23:this.setState({loading:!1,selectedFiles:[],resultDialogOpen:!0,progress:0}),this.state.failedFiles.length>0?this.setState({snackbar:{open:!0,message:"Import abgeschlossen! Einige Dateien wurden nicht importiert!",severity:"warning"}}):this.setState({snackbar:{open:!0,message:"Alle Dateien wurden erfolgreich importiert!",severity:"success"}});case 25:case"end":return e.stop()}}),e,this,[[5,17,20,23]])})));return function(){return e.apply(this,arguments)}}()}]),a}(n.Component),Se=Object(Z.a)((function(e){return{backdrop:{zIndex:e.zIndex.drawer+1,color:"white"},success:{color:"white",backgroundColor:"#16875D"},warning:{color:"white",backgroundColor:"#F79B0C"},info:{color:"white",backgroundColor:"#2E75D4"}}}))(Te),we=function(e){return Object(x.jsx)(j.d,{children:"Hello Sidebar Component"})},Fe=function(e){return Object(x.jsx)(j.d,{children:"Hello Entry Field Component"})},Ae=function(e){return Object(x.jsx)(j.d,{children:"Hello Dialog Component"})};Object(r.init)((function(e){var t=document.getElementById("root");[{location:r.locations.LOCATION_APP_CONFIG,component:Object(x.jsx)(f,{sdk:e})},{location:r.locations.LOCATION_ENTRY_FIELD,component:Object(x.jsx)(Fe,{sdk:e})},{location:r.locations.LOCATION_ENTRY_EDITOR,component:Object(x.jsx)(m,{sdk:e})},{location:r.locations.LOCATION_DIALOG,component:Object(x.jsx)(Ae,{sdk:e})},{location:r.locations.LOCATION_ENTRY_SIDEBAR,component:Object(x.jsx)(we,{sdk:e})},{location:r.locations.LOCATION_PAGE,component:Object(x.jsx)(Se,{sdk:e})}].forEach((function(a){e.location.is(a.location)&&Object(i.render)(a.component,t)}))}))}},[[147,1,2]]]); //# sourceMappingURL=main.fb74d04b.chunk.js.map