{"size": 62016, "ext": "js", "max_stars_repo_path": "build/static/js/main.93cb13b6.chunk.js", "max_stars_repo_name": "georgejordanov/RESTool", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "build/static/js/main.93cb13b6.chunk.js", "max_issues_repo_name": "georgejordanov/RESTool", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "build/static/js/main.93cb13b6.chunk.js", "max_forks_repo_name": "georgejordanov/RESTool", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 31008.0, "max_line_length": 61968, "alphanum_fraction": 0.6885158669}
(this.webpackJsonprestool=this.webpackJsonprestool||[]).push([[0],{103:function(e,t,a){},104:function(e,t,a){},105:function(e,t,a){},106:function(e,t,a){},107:function(e,t,a){},108:function(e,t,a){},110:function(e,t,a){},113:function(e,t,a){},114:function(e,t,a){},115:function(e,t,a){},117:function(e,t,a){},118:function(e,t,a){},121:function(e,t,a){},122:function(e,t,a){},124:function(e,t,a){},125:function(e,t,a){"use strict";a.r(t);var n=a(0),r=a.n(n),i=a(14),o=a.n(i),l=a(2),s=a.n(l),c=a(4),u=a(18),d=a(15),p=a(9),f=a(7),m=a(8),v=a(21),h=a(19),g=a(22),y=new(function(){function e(){Object(f.a)(this,e)}return Object(m.a)(e,[{key:"extractDataByDataPath",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(!e||!t)return a?e[a]:e;var n=e,r=t.split("."),i=!0,o=!1,l=void 0;try{for(var s,c=r[Symbol.iterator]();!(i=(s=c.next()).done);i=!0){var u=s.value;if("undefined"===typeof n[u])return null;n=n[u]}}catch(d){o=!0,l=d}finally{try{i||null==c.return||c.return()}finally{if(o)throw l}}return"undefined"===typeof n?null:a?n[a]:n}},{key:"checkIfFieldIsObject",value:function(e){return"object"===e.type||!("array"!==e.type||e.arrayType&&"object"!==e.arrayType)}}]),e}()),b=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";Object(f.a)(this,e),this.baseUrl=void 0,this.unauthorizedRedirectUrl=void 0,this.errorMessageDataPath=void 0,this.requestHeaders=void 0,this.baseUrl=t||"",this.unauthorizedRedirectUrl=a||"",this.errorMessageDataPath=n||"",this.requestHeaders={}}return Object(m.a)(e,[{key:"urlIsAbsolute",value:function(e){return 0===e.indexOf("http")||0===e.indexOf("https")}},{key:"replaceParamsInUrl",value:function(e,t){if(!t||"object"!==typeof t)return e;var a=e;return Object.keys(t).forEach((function(e){var n=":".concat(e);a=a.replace(n,t[e])})),a}},{key:"buildUrl",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],a=arguments.length>2?arguments[2]:void 0;if(!t||!t.length)return this.replaceParamsInUrl(e,a);var n=e,r=[],i=!0,o=!1,l=void 0;try{for(var s,c=t[Symbol.iterator]();!(i=(s=c.next()).done);i=!0){var u=s.value;if(u.name&&"undefined"!==typeof u.value)if(u.urlReplaceOnly){var d=":".concat(u.name);n=n.replace(d,u.value)}else r.push("".concat(u.name,"=").concat(u.value||""))}}catch(f){o=!0,l=f}finally{try{i||null==c.return||c.return()}finally{if(o)throw l}}if(r.length){var p=e.indexOf("?")>=0?"&":"?";return n+p+r.join("&")}return n}},{key:"buildRequest",value:function(e){var t=this.urlIsAbsolute(e.origUrl)?e.origUrl:this.baseUrl+e.origUrl;return{url:this.buildUrl(t,e.queryParams,e.rawData),params:{method:e.method?e.method.toUpperCase():"GET",headers:Object.assign({},this.requestHeaders,e.headers||{}),body:"post"===e.method||"put"===e.method||"patch"===e.method?e.body:void 0}}}},{key:"getErrorMessage",value:function(e){var t,a,n,r,i,o,l,c,u;return s.a.async((function(d){for(;;)switch(d.prev=d.next){case 0:return t="",d.prev=1,d.next=4,s.a.awrap(e.json());case 4:for(a=d.sent,n=!0,r=!1,i=void 0,d.prev=8,o=this.errorMessageDataPath[Symbol.iterator]();!(n=(l=o.next()).done);n=!0)c=l.value,(u=y.extractDataByDataPath(a,c))&&(t=u);d.next=16;break;case 12:d.prev=12,d.t0=d.catch(8),r=!0,i=d.t0;case 16:d.prev=16,d.prev=17,n||null==o.return||o.return();case 19:if(d.prev=19,!r){d.next=22;break}throw i;case 22:return d.finish(19);case 23:return d.finish(16);case 24:d.next=28;break;case 26:d.prev=26,d.t1=d.catch(1);case 28:return d.abrupt("return",t&&t.length?t:"".concat(e.status," - ").concat(e.statusText||""));case 29:case"end":return d.stop()}}),null,this,[[1,26],[8,12,16,24],[17,,19,23]])}},{key:"handleError",value:function(e){var t;return s.a.async((function(a){for(;;)switch(a.prev=a.next){case 0:if(401!==e.status||!this.unauthorizedRedirectUrl){a.next=4;break}return t=this.unauthorizedRedirectUrl.replace(":returnUrl",encodeURIComponent(document.location.href)),document.location.href=t,a.abrupt("return");case 4:return a.t0=Error,a.next=7,s.a.awrap(this.getErrorMessage(e));case 7:throw a.t1=a.sent,new a.t0(a.t1);case 9:case"end":return a.stop()}}),null,this)}},{key:"makeRequest",value:function(e){var t,a,n,r=arguments;return s.a.async((function(i){for(;;)switch(i.prev=i.next){case 0:return t=r.length>1&&void 0!==r[1]?r[1]:{},a=r.length>2&&void 0!==r[2]?r[2]:"json",i.next=4,s.a.awrap(fetch(e,Object.assign({},t,{})));case 4:if(!(n=i.sent).ok){i.next=17;break}i.t0=a,i.next="json"===i.t0?9:"text"===i.t0?12:"boolean"===i.t0?15:16;break;case 9:return i.next=11,s.a.awrap(n.json());case 11:return i.abrupt("return",i.sent);case 12:return i.next=14,s.a.awrap(n.text());case 14:return i.abrupt("return",i.sent);case 15:case 16:return i.abrupt("return",!0);case 17:return i.next=19,s.a.awrap(this.handleError(n));case 19:case"end":return i.stop()}}),null,this)}},{key:"fetch",value:function(e){var t,a,n,r,i,o,l,c,u,d;return s.a.async((function(p){for(;;)switch(p.prev=p.next){case 0:return t=e.method,a=e.origUrl,n=e.queryParams,r=e.rawData,i=e.body,o=e.headers,l=e.responseType,c=this.buildRequest({method:t,origUrl:a,queryParams:n,rawData:r,body:i,headers:o}),u=c.url,d=c.params,p.next=4,s.a.awrap(this.makeRequest(u,d,l));case 4:return p.abrupt("return",p.sent);case 5:case"end":return p.stop()}}),null,this)}}]),e}(),E=a(46),w=a.n(E),x=new b,P=new(function(e){function t(){return Object(f.a)(this,t),Object(v.a)(this,Object(h.a)(t).apply(this,arguments))}return Object(g.a)(t,e),Object(m.a)(t,[{key:"getRemoteConfig",value:function(e){return s.a.async((function(t){for(;;)switch(t.prev=t.next){case 0:if(!e.endsWith(".js")){t.next=4;break}return t.next=3,s.a.awrap(import(e));case 3:return t.abrupt("return",t.sent.default);case 4:return t.next=6,s.a.awrap(x.fetch({origUrl:e}));case 6:return t.abrupt("return",t.sent);case 7:case"end":return t.stop()}}))}},{key:"loadDefaultConfig",value:function(){return s.a.async((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,s.a.awrap(this.getRemoteConfig("/config.json"));case 3:return e.abrupt("return",e.sent);case 6:return e.prev=6,e.t0=e.catch(0),e.next=10,s.a.awrap(this.getRemoteConfig("/config.js"));case 10:return e.abrupt("return",e.sent);case 11:case"end":return e.stop()}}),null,this,[[0,6]])}},{key:"validateConfig",value:function(e){if(null===e)return{isValid:!0,errorMessage:null};var t=a(90),n=new w.a({allErrors:!0,verbose:!0}).compile(t),r=n(e);if("boolean"!==typeof r)throw new Error("Unexpected asynchronous JSON validation");if(r)return{isValid:r,errorMessage:null};var i=n.errors?n.errors[0]:void 0,o=null;return o=(null===i||void 0===i?void 0:i.message)&&(null===i||void 0===i?void 0:i.dataPath)?'Error parsing configuration at "'.concat(i.dataPath,'": ').concat(i.message):(null===i||void 0===i?void 0:i.message)?"Error parsing configuration: ".concat(i.message):(null===i||void 0===i?void 0:i.dataPath)?'Error parsing configuration at "'.concat(i.dataPath,'"'):"Error parsing configuration",console.error(o),console.error("All configuration errors: ",n.errors),{isValid:r,errorMessage:o}}}]),t}(b)),j=a(13),O=a(11),k=a(47),C=a(25),N=a(16),S=r.a.createContext({config:null,activePage:null,error:null,setError:function(){},setActivePage:function(){},httpService:new b}),T=function(e){return function(t){return r.a.createElement(S.Consumer,null,(function(a){return r.a.createElement(e,Object.assign({},t,{context:a}))}))}},I=(a(103),function(){return r.a.createElement("div",{className:"app-loader cp-spinner cp-balls small"})}),q=new(function(){function e(){Object(f.a)(this,e)}return Object(m.a)(e,[{key:"hasPreviousPage",value:function(e){return void 0!==e&&("string"===typeof e?parseInt(e)>1:e>1)}},{key:"hasNextPage",value:function(e,t,a){return void 0===a||("string"===typeof e?parseInt(e):e)*("string"===typeof t?parseInt(t):t)<("string"===typeof a?parseInt(a):a)}}]),e}()),A=a(26),U=(a(104),function(e){return r.a.createElement("button",Object.assign({},e,{className:"button ".concat(e.className||""," ").concat(e.color||"")}),e.children)}),D=(a(105),function(){return r.a.createElement("div",{className:"app-infinite-loader cp-spinner cp-balls small"})}),R=(a(106),function(e){var t,a,n=e.callbacks,i=e.pagination,o=e.customLabels,l=(null===o||void 0===o?void 0:null===(t=o.pagination)||void 0===t?void 0:t.previousPageTitle)||"Previous page",s=(null===o||void 0===o?void 0:null===(a=o.pagination)||void 0===a?void 0:a.nextPageTitle)||"Next page";return r.a.createElement("div",{className:"pagination-wrapper"},r.a.createElement(U,{disabled:!i.hasPreviousPage,onClick:function(){return n.previousPage()},title:l},r.a.createElement("i",{className:"fa fa-arrow-left","aria-hidden":"true"})),r.a.createElement(U,{disabled:!i.hasNextPage,onClick:function(){return n.nextPage()},title:s},r.a.createElement("i",{className:"fa fa-arrow-right","aria-hidden":"true"})))}),B=(a(107),function(e){var t,a,i,o=e.items,l=e.fields,s=e.pagination,c=e.callbacks,u=e.customActions,d=e.customLabels,p=(null===d||void 0===d?void 0:null===(t=d.buttons)||void 0===t?void 0:t.editItem)||"Edit",f=(null===d||void 0===d?void 0:null===(a=d.buttons)||void 0===a?void 0:a.deleteItem)||"Delete",m=(null===d||void 0===d?void 0:null===(i=d.tableColumnHeaders)||void 0===i?void 0:i.actions)||"Actions",v={nextPage:c.getNextPage||function(){},previousPage:c.getPreviousPage||function(){}};function h(e,t){return r.a.createElement("tr",{key:"tr_".concat(t)},l.map((function(a,n){var i=y.extractDataByDataPath(e,a.dataPath,a.name);return r.a.createElement("td",{className:a.truncate?"truncate":"",key:"td_".concat(t,"_").concat(n)},function(e,t,a){if("boolean"===e.type&&(a=!!a),a&&"object"===typeof a)return"object";switch(e.type){case"text":return r.a.createElement("span",null,a);case"boolean":return r.a.createElement("div",{className:"bool ".concat(a?"true":"false")});case"image":return r.a.createElement("img",{src:a||"",alt:a||e.label||e.name});case"url":var n=e.url||a||"";return l.forEach((function(e){var a=y.extractDataByDataPath(t,e.dataPath,e.name);n=n.replace(":".concat(e.name),a)})),r.a.createElement("a",{href:n,target:"_blank",rel:"noopener noreferrer"},e.urlLabel||a);case"colorbox":return r.a.createElement("div",{className:"colorbox",style:{backgroundColor:a}});default:return a}}(a,e,i))})),r.a.createElement("td",null,r.a.createElement("div",{className:"actions-wrapper"},c.put&&r.a.createElement(U,{onClick:function(){var t;return null===(t=c.put)||void 0===t?void 0:t.call(c,e)},title:p},r.a.createElement("i",{className:"fa fa-pencil-square-o","aria-hidden":"true"})),u&&u.length>0&&u.map((function(a,n){return r.a.createElement(U,{key:"action_".concat(t,"_").concat(n),onClick:function(){return c.action(e,a)},title:a.name},r.a.createElement("i",{className:"fa fa-".concat(a.icon||"cogs"),"aria-hidden":"true"}))})),c.delete&&r.a.createElement(U,{onClick:function(){var t;return null===(t=c.delete)||void 0===t?void 0:t.call(c,e)},title:f},r.a.createElement("i",{className:"fa fa-times","aria-hidden":"true"})))))}function g(){return r.a.createElement("table",{className:"pure-table"},r.a.createElement("thead",null,r.a.createElement("tr",null,l.map((function(e){return r.a.createElement("th",{key:"th_".concat(e.name)},e.label||e.name)})),r.a.createElement("th",null,m))),r.a.createElement("tbody",null,o.map(h)))}return Object(n.useEffect)((function(){"infinite-scroll"===(null===s||void 0===s?void 0:s.type)&&document.body.clientHeight<=window.innerHeight&&(null===s||void 0===s?void 0:s.hasNextPage)&&v.nextPage()}),[]),"infinite-scroll"===(null===s||void 0===s?void 0:s.type)?r.a.createElement(A.a,{dataLength:o.length,next:c.getNextPage||function(){return null},hasMore:(null===s||void 0===s?void 0:s.hasNextPage)||!1,loader:r.a.createElement(D,null)},g()):r.a.createElement("div",{className:"table-wrapper"},g(),s&&"buttons"===s.type&&r.a.createElement(R,{callbacks:v,pagination:s,customLabels:d}))}),L=a(48),$=a.n(L),F=(a(108),function(e){var t,a,i=e.items,o=e.fields,l=e.callbacks,s=e.customActions,c=e.customLabels,u=e.pagination,d=(null===c||void 0===c?void 0:null===(t=c.buttons)||void 0===t?void 0:t.editItem)||"Edit",p=(null===c||void 0===c?void 0:null===(a=c.buttons)||void 0===a?void 0:a.deleteItem)||"Delete",f={nextPage:l.getNextPage||function(){},previousPage:l.getPreviousPage||function(){}};function m(e,t){return r.a.createElement("div",{className:"actions-wrapper"},l.put&&r.a.createElement(U,{onClick:function(){var t;return null===(t=l.put)||void 0===t?void 0:t.call(l,e)},title:d},r.a.createElement("i",{className:"fa fa-pencil-square-o","aria-hidden":"true"})),s&&s.length>0&&s.map((function(a,n){return r.a.createElement(U,{key:"action_".concat(t,"_").concat(n),onClick:function(){return l.action(e,a)},title:a.name},r.a.createElement("i",{className:"fa fa-".concat(a.icon||"cogs"),"aria-hidden":"true"}))})),l.delete&&r.a.createElement(U,{onClick:function(){var t;return null===(t=l.delete)||void 0===t?void 0:t.call(l,e)},title:p},r.a.createElement("i",{className:"fa fa-times","aria-hidden":"true"})))}function v(e,t){return r.a.createElement("div",{className:"card",key:"card_".concat(t)},o.map((function(a,n){var i=y.extractDataByDataPath(e,a.dataPath,a.name);return r.a.createElement("div",{className:"card-row ".concat(a.type),key:"card_".concat(t,"_").concat(n)},"image"!==a.type&&r.a.createElement("label",null,a.label||a.name,": "),function(e,t,a){if("boolean"===e.type&&(a=!!a),a&&"object"===typeof a)return"object";switch(e.type){case"text":return r.a.createElement("span",null,a);case"boolean":return r.a.createElement("div",{className:"bool ".concat(a?"true":"false")});case"image":return a?r.a.createElement("img",{src:a||"",alt:a||e.label||e.name}):r.a.createElement(r.a.Fragment,null);case"url":var n=e.url||a||"";return o.forEach((function(e){var a=y.extractDataByDataPath(t,e.dataPath,e.name);n=n.replace(":".concat(e.name),a)})),r.a.createElement("a",{href:n,target:"_blank",rel:"noopener noreferrer"},e.urlLabel||a);case"colorbox":return r.a.createElement("div",{className:"colorbox",style:{backgroundColor:a}});default:return a}}(a,e,i))})),m(e,t))}function h(e){return r.a.createElement("div",{className:"card",key:"card_".concat(e)},o.map((function(t,a){return r.a.createElement("div",{className:"card-row ".concat(t.type),key:"card_".concat(e,"_").concat(a)},"image"!==t.type&&r.a.createElement("label",null,t.label||t.name,": "),r.a.createElement($.a,{duration:.6}))})),m({},e))}return Object(n.useEffect)((function(){"infinite-scroll"===(null===u||void 0===u?void 0:u.type)&&document.body.clientHeight<=window.innerHeight&&l.getNextPage&&(null===u||void 0===u?void 0:u.hasNextPage)&&l.getNextPage()}),[]),"infinite-scroll"===(null===u||void 0===u?void 0:u.type)?r.a.createElement(A.a,{className:"cards-wrapper",dataLength:i.length,next:l.getNextPage||function(){return null},hasMore:(null===u||void 0===u?void 0:u.hasNextPage)||!1,loader:function(){var e=i.length;return Array.from(Array(null===u||void 0===u?void 0:u.limit).keys()).map((function(t){return t+e})).map(h)}()},i.map(v)):r.a.createElement(r.a.Fragment,null,r.a.createElement("div",{className:"cards-wrapper"},i.map(v)),u&&"buttons"===u.type&&r.a.createElement(R,{callbacks:f,pagination:u}))}),H=a(24),_=(a(110),T((function(e){var t,a,i=e.context,o=e.field,l=e.direction,u=e.showReset,d=e.onChange,f=Object(n.useState)({}),m=Object(c.a)(f,2),v=m[0],h=m[1],g=i.httpService,b=i.activePage,E=i.config,w=(null===b||void 0===b?void 0:b.requestHeaders)||{},x=Object(O.a)({},null===E||void 0===E?void 0:E.customLabels,{},null===b||void 0===b?void 0:b.customLabels),P=(null===x||void 0===x?void 0:null===(t=x.buttons)||void 0===t?void 0:t.addArrayItem)||"Add Item",k=(null===x||void 0===x?void 0:null===(a=x.buttons)||void 0===a?void 0:a.clearInput)||"Clear";function N(e){var t=e.value||[];return r.a.createElement("div",{className:"array-form"},t.map((function(t,a){var n=S({value:t,name:"".concat(e.name,".").concat(a)},(function(t,n){var r=(e.value||[]).map((function(e,t){return t===a?n:e}));d(e.name,r)}));return r.a.createElement("div",{className:"array-form-item",key:"array_form_".concat(a)},n,r.a.createElement("i",{title:k,onClick:function(){return function(e,t){var a=Object(j.a)(e.value||[]);a.splice(t,1),d(o.name,a)}(e,a)},"aria-label":"Remove",className:"clear-input fa fa-times"}))})),r.a.createElement(U,{className:"add-array-item",onClick:function(t){return function(e,t){e.preventDefault(),d(o.name,[].concat(Object(j.a)(t.value||[]),[""]))}(t,e)},title:P},r.a.createElement("i",{className:"fa fa-plus","aria-hidden":"true"})))}function S(e,t){var a,n,i,o,l,c,u,d,f,m=function(){var a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return{value:e.value,placeholder:e.placeholder||a,disabled:e.readonly,required:e.required,onChange:function(a){return t(e.name,a.target.value)}}};switch(e.type){case"boolean":return r.a.createElement("input",Object.assign({type:"checkbox"},m(),{checked:e.value,onChange:function(a){return t(e.name,a.target.checked,!0)}}));case"select":var b,E=e.optionSource;if(E&&!v[e.name])return function(e,t){var a,n,r,i,o,l,c;s.a.async((function(u){for(;;)switch(u.prev=u.next){case 0:if(u.prev=0,a=t.url,n=t.dataPath,r=t.actualMethod,i=t.requestHeaders,a){u.next=4;break}throw new Error('URL option source (for field "'.concat(e,'") is empty.'));case 4:return u.next=6,s.a.awrap(g.fetch({method:r||"get",origUrl:a,queryParams:[],headers:Object.assign({},w,i||{})}));case 6:if(o=u.sent,(l=y.extractDataByDataPath(o,n))&&l.length){u.next=10;break}throw new Error('Option source data is empty (for field "'.concat(e,'")'));case 10:c=l.map((function(e,a){var n=t.valuePath,r=t.displayPath;return"string"===typeof e?e:{display:r&&e[r]?e[r]:"Option ".concat(a+1),value:n&&e[n]?e[n]:"".concat(a)}})),h(Object(O.a)({},v,Object(H.a)({},e,c))),u.next=17;break;case 14:u.prev=14,u.t0=u.catch(0),p.b.error(u.t0.message);case 17:case"end":return u.stop()}}),null,null,[[0,14]])}(e.name,E),r.a.createElement("select",m(),r.a.createElement("option",null,"-- Loading Options... --"));var P=null===(b=e.optionSource)||void 0===b?void 0:b.sortBy,j=v[e.name]||e.options||[],k=Object(C.a)(j,"string"===typeof P?[P]:P||[]);return r.a.createElement("select",m(),r.a.createElement("option",null,"-- Select --"),k.map((function(e,t){var a="option_".concat(t,"_");return"object"!==typeof e?r.a.createElement("option",{key:"".concat(a,"_").concat(e),value:e},e):r.a.createElement("option",{key:"".concat(a,"_").concat(e.value),value:e.value},e.display||e.value)})));case"object":return r.a.createElement("textarea",m((null===x||void 0===x?void 0:null===(a=x.placeholders)||void 0===a?void 0:a.object)||"Enter JSON..."));case"array":var S,T=e.arrayType;return e.value&&T&&"object"!==T?N(e):r.a.createElement("textarea",m((null===x||void 0===x?void 0:null===(S=x.placeholders)||void 0===S?void 0:S.array)||"Enter JSON array..."));case"long-text":return r.a.createElement("textarea",m((null===x||void 0===x?void 0:null===(n=x.placeholders)||void 0===n?void 0:n.text)||"Enter text..."));case"number":case"integer":return r.a.createElement("input",Object.assign({type:"number"},m((null===x||void 0===x?void 0:null===(i=x.placeholders)||void 0===i?void 0:i.number)||"0"),{onChange:function(a){return t(e.name,a.target.valueAsNumber)}}));case"color":return r.a.createElement("input",Object.assign({type:"color"},m((null===x||void 0===x?void 0:null===(o=x.placeholders)||void 0===o?void 0:o.color)||"Enter color...")));case"email":return r.a.createElement("input",Object.assign({type:"email"},m((null===x||void 0===x?void 0:null===(l=x.placeholders)||void 0===l?void 0:l.email)||"Enter email...")));case"password":return r.a.createElement("input",Object.assign({type:"password"},m((null===x||void 0===x?void 0:null===(c=x.placeholders)||void 0===c?void 0:c.password)||"Enter password...")));case"hidden":return r.a.createElement("input",{type:"hidden",value:e.value});case"file":return r.a.createElement("input",{type:"file",accept:e.accept||"*",placeholder:e.placeholder||(null===x||void 0===x?void 0:null===(u=x.placeholders)||void 0===u?void 0:u.file)||"Select file...",name:e.name||"file",disabled:e.readonly,required:e.required});case"note":return r.a.createElement("p",{className:"note"},e.value);case"date":return r.a.createElement("input",Object.assign({type:"date"},m((null===x||void 0===x?void 0:null===(d=x.placeholders)||void 0===d?void 0:d.date)||"Enter date...")));case"text":default:return r.a.createElement("input",Object.assign({type:"text"},m((null===x||void 0===x?void 0:null===(f=x.placeholders)||void 0===f?void 0:f.text)||"Enter text...")))}}return r.a.createElement("div",{className:"form-row ".concat(l||"row")},"hidden"!==o.type&&r.a.createElement("label",null,o.label||o.originalName,o.required?" *":""),S(o,d),u&&!o.readonly&&o.value&&o.value.length>0&&r.a.createElement("i",{title:k,onClick:function(){return d(o.name,"",!0)},"aria-label":"Clear",className:"clear-input fa fa-times"}))}))),M=(a(113),function(e){var t=e.initialParams,a=e.paginationConfig,i=e.submitCallback,o=Object(n.useState)(t),l=Object(c.a)(o,2),s=l[0],u=l[1];function d(e){e&&e.preventDefault(),a&&"infinite-scroll"===a.type?i(s,!0):i(s)}function p(e,t,a){var n=Object(j.a)(s).map((function(a){return a.name===e&&(a.value=t),a}));u(n),a&&d()}return Object(n.useEffect)((function(){if(a&&"infinite-scroll"===a.type){var e=t.filter((function(e){return!["page","limit"].includes(e.name)}));u(e)}else u(t)}),[a,t]),s.length?r.a.createElement("section",{className:"query-params-form"},r.a.createElement("h5",null,"Query Params:"),r.a.createElement("form",{onSubmit:d},s.map((function(e,t){return r.a.createElement(_,{key:"query_param_".concat(t),field:e,onChange:p,showReset:!e.type||"text"===e.type})})),r.a.createElement(U,{type:"submit",onClick:d},"Submit"))):r.a.createElement(r.a.Fragment,null)}),J=(a(114),document.getElementById("popup-portal"));J||((J=document.createElement("div")).setAttribute("id","popup-portal"),document.body.append(J));var z=function(e){function t(e){var a;return Object(f.a)(this,t),(a=Object(v.a)(this,Object(h.a)(t).call(this,e))).el=void 0,a.componentDidMount=function(){J.appendChild(a.el)},a.componentWillUnmount=function(){J.removeChild(a.el)},a.el=document.createElement("div"),a}return Object(g.a)(t,e),Object(m.a)(t,[{key:"render",value:function(){return o.a.createPortal(this.props.children,this.el)}}]),t}(n.Component),W=function(e){function t(){var e,a;Object(f.a)(this,t);for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return(a=Object(v.a)(this,(e=Object(h.a)(t)).call.apply(e,[this].concat(r))))._handleKeyDown=function(e){var t=a.props,n=t.show,r=t.closeCallback;n&&27===e.keyCode&&r(e)},a}return Object(g.a)(t,e),Object(m.a)(t,[{key:"render",value:function(){var e,t,a=this,n=Object.assign({},{display:this.props.show?"block":"none"},this.props.style||{}),i=(null===(e=this.props.customLabels)||void 0===e?void 0:null===(t=e.buttons)||void 0===t?void 0:t.closeForm)||"Close";return r.a.createElement(z,null,this.props.show?r.a.createElement("div",{className:"popup ".concat(this.props.className||""),style:n},r.a.createElement("div",{className:"overlay",onClick:function(e){return a.props.closeCallback(e)}}),r.a.createElement("div",{className:"popup-content",ref:this.props.refCallback},this.props.children,r.a.createElement("button",{title:i,className:"close-popup",onClick:function(e){return a.props.closeCallback(e)}},r.a.createElement("i",{className:"fa fa-times","aria-hidden":"true"})))):null)}},{key:"componentDidMount",value:function(){document.addEventListener("keydown",this._handleKeyDown.bind(this))}},{key:"componentWillUnmount",value:function(){document.removeEventListener("keydown",this._handleKeyDown.bind(this))}}]),t}(n.Component),Q=new(function(){function e(){Object(f.a)(this,e)}return Object(m.a)(e,[{key:"isMultipartForm",value:function(e){for(var t in e){if("file"===e[t].type)return!0}return!1}}]),e}()),G=(a(115),a(43)),Y=a(43).unflatten,K=T((function(e){var t=e.context,a=e.title,i=e.fields,o=e.rawData,l=e.getSingleConfig,u=e.methodConfig,d=e.submitCallback,f=e.closeCallback,m=JSON.parse(JSON.stringify(i)),v=t.httpService,h=t.activePage,g=t.config,b=Object(n.useState)(!0),E=Object(c.a)(b,2),w=E[0],x=E[1],P=Object(n.useState)([]),j=Object(c.a)(P,2),k=j[0],C=j[1],N=Object(n.useState)(null),S=Object(c.a)(N,2),T=S[0],q=S[1],A=(null===h||void 0===h?void 0:h.requestHeaders)||{},D=Object(O.a)({},null===g||void 0===g?void 0:g.customLabels,{},null===h||void 0===h?void 0:h.customLabels);function R(e){var t,a,n,r,i;return s.a.async((function(o){for(;;)switch(o.prev=o.next){case 0:if(e.preventDefault(),t=u.includeOriginalFields?Object.assign({},T):{},a=new FormData,n=Q.isMultipartForm(k),r=null,k.forEach((function(i){if("file"!==i.type){if(t[i.name]=i.value,n&&a.append(i.name,i.value),i.required&&"boolean"!==i.type&&!i.value&&(r="Please fill up all required fields."),y.checkIfFieldIsObject(i)&&i.value)try{t[i.name]=JSON.parse(i.value)}catch(e){r='Invalid JSON for field "'.concat(i.name,'".')}"boolean"===i.type&&(t[i.name]=i.value||!1),"encode"===i.type&&(t[i.name]=encodeURIComponent(i.value))}else{var o=document.querySelector('input[name="'.concat(i.name||"file",'"]'));if(o.files.length>0){var l=o.files[0];a.append(i.name||"file",l,l.name)}}})),!r){o.next=9;break}return p.b.error(r),o.abrupt("return");case 9:return x(!0),o.prev=10,i=n?a:Y(t),o.next=14,s.a.awrap(d(i,n));case 14:p.b.success("Great Success!"),f(!0),o.next=21;break;case 18:o.prev=18,o.t0=o.catch(10),p.b.error(o.t0.message);case 21:x(!1);case 22:case"end":return o.stop()}}),null,null,[[10,18]])}function B(e,t){var a=JSON.parse(JSON.stringify(k));a=a.map((function(a){return a.name===e&&(a.value=t),a})),C(a)}return Object(n.useEffect)((function(){!function(){var e,t,a,n,r,i,c,u,d;s.a.async((function(f){for(;;)switch(f.prev=f.next){case 0:if(e=o||{},!l||!l.url){f.next=15;break}return f.prev=2,t=l.url,a=l.requestHeaders,n=l.actualMethod,r=l.dataPath,i=l.queryParams,f.next=6,s.a.awrap(v.fetch({method:n||"get",origUrl:t,queryParams:i,headers:Object.assign({},A,a||{}),rawData:o}));case 6:c=f.sent,(u=y.extractDataByDataPath(c,r))&&"object"===typeof u&&(e=u),f.next=15;break;case 11:f.prev=11,f.t0=f.catch(2),console.error("Could not load single item's data.",f.t0),p.b.error("Could not load single item's data.");case 15:q(e),d=G(e||{}),C(m.map((function(t){var a=t.name;return t.originalName=t.name,t.dataPath&&(a="".concat(t.dataPath,".").concat(t.name)),t.name=a,y.checkIfFieldIsObject(t)?((e[a]||t.value)&&(t.value=JSON.stringify(e[a]||t.value,null,"  ")||""),t):"array"===t.type?(t.value=e[a]||t.value||[],t):("undefined"!==typeof d[a]?t.value=d[a]:t.value="undefined"===typeof t.value?"":t.value,t)}))),x(!1);case 19:case"end":return f.stop()}}),null,null,[[2,11]])}()}),[]),r.a.createElement(W,{show:!0,className:"form-popup",closeCallback:function(){return f(!1)},customLabels:D},r.a.createElement(r.a.Fragment,null,r.a.createElement("h2",null,a),r.a.createElement("section",null,w?r.a.createElement(I,null):r.a.createElement("form",{onSubmit:R},k.map((function(e,t){return r.a.createElement(_,{key:"field_".concat(t),field:e,onChange:B,showReset:!e.type||"text"===e.type})})),r.a.createElement("div",{className:"buttons-wrapper center"},r.a.createElement(U,{type:"submit",onClick:R,color:"green"},"Submit"))))))})),V=(a(117),function(e){var t=e.onChange;return r.a.createElement("section",{className:"filter-wrapper"},r.a.createElement("h5",null,"Filter:"),r.a.createElement("div",{className:"form-row"},r.a.createElement("input",{type:"text",placeholder:"Search...",onChange:function(e){return t(e.target.value.toLowerCase())}})))}),X=(a(118),function(e,t){var a,n,r,i,o,l,s,c,u=t?{type:t.type,page:parseInt((null===(a=t.params)||void 0===a?void 0:null===(n=a.page)||void 0===n?void 0:n.value)||"1"),limit:parseInt((null===(r=t.params)||void 0===r?void 0:null===(i=r.limit)||void 0===i?void 0:i.value)||"10"),descending:"true"===(null===(o=t.params)||void 0===o?void 0:null===(l=o.descending)||void 0===l?void 0:l.value)||!1,hasPreviousPage:!1,hasNextPage:!1,sortBy:null===(s=t.params)||void 0===s?void 0:null===(c=s.sortBy)||void 0===c?void 0:c.value}:void 0;if(t){var d,p,f,m,v,h,g;if(!Object(N.find)(e,{name:"page"}))e.push({name:null===t||void 0===t?void 0:null===(m=t.params)||void 0===m?void 0:null===(v=m.page)||void 0===v?void 0:v.name,label:(null===t||void 0===t?void 0:null===(h=t.params)||void 0===h?void 0:null===(g=h.page)||void 0===g?void 0:g.label)||"Page",value:null===u||void 0===u?void 0:u.page});(null===t||void 0===t?void 0:null===(d=t.params)||void 0===d?void 0:d.limit)&&!Object(N.find)(e,{name:"limit"})&&e.push({name:t.params.limit.name,label:t.params.limit.label||"Limit",value:null===u||void 0===u?void 0:u.limit}),(null===t||void 0===t?void 0:null===(p=t.params)||void 0===p?void 0:p.descending)&&!Object(N.find)(e,{name:"descending"})&&e.push({name:t.params.descending.name,label:t.params.descending.label||"Descending",value:null===u||void 0===u?void 0:u.descending}),(null===t||void 0===t?void 0:null===(f=t.params)||void 0===f?void 0:f.sortBy)&&!Object(N.find)(e,{name:"sortBy"})&&e.push({name:t.params.sortBy.name,label:"Sort by",value:null===u||void 0===u?void 0:u.sortBy})}return{initQueryParams:e,initialPagination:u}}),Z=T((function(e){var t,a,i,o,l=e.context,u=Object(d.h)().page,f=Object(d.g)(),m=f.push,v=f.location,h=l.activePage,g=l.error,b=l.setError,E=l.httpService,w=l.config,x=(null===h||void 0===h?void 0:h.requestHeaders)||{},P=null===h||void 0===h?void 0:h.methods,S=(null===h||void 0===h?void 0:h.customActions)||[],T=null===P||void 0===P?void 0:P.getAll,A=null===T||void 0===T?void 0:T.pagination,D="infinite-scroll"===(null===A||void 0===A?void 0:A.type),R=null===P||void 0===P?void 0:P.getSingle,L=null===P||void 0===P?void 0:P.post,$=null===P||void 0===P?void 0:P.put,H=null===P||void 0===P?void 0:P.delete,_=Object(O.a)({},null===w||void 0===w?void 0:w.customLabels,{},null===h||void 0===h?void 0:h.customLabels),J=(null===_||void 0===_?void 0:null===(t=_.buttons)||void 0===t?void 0:t.addItem)||"+ Add Item",z=(null===_||void 0===_?void 0:null===(a=_.formTitles)||void 0===a?void 0:a.addItem)||"Add Item",W=(null===_||void 0===_?void 0:null===(i=_.formTitles)||void 0===i?void 0:i.editItem)||"Update Item",Q=X((null===T||void 0===T?void 0:T.queryParams)||[],A),G=Q.initQueryParams,Y=Q.initialPagination,Z=Object(n.useState)(!1),ee=Object(c.a)(Z,2),te=ee[0],ae=ee[1],ne=Object(n.useState)(null),re=Object(c.a)(ne,2),ie=re[0],oe=re[1],le=Object(n.useState)(G),se=Object(c.a)(le,2),ce=se[0],ue=se[1],de=Object(n.useState)(Y),pe=Object(c.a)(de,2),fe=pe[0],me=pe[1],ve=Object(n.useState)([]),he=Object(c.a)(ve,2),ge=he[0],ye=he[1],be=Object(n.useState)(""),Ee=Object(c.a)(be,2),we=Ee[0],xe=Ee[1];function Pe(e){return s.a.async((function(t){for(;;)switch(t.prev=t.next){case 0:oe({rawData:e,type:"update",title:W,config:$,getSingleConfig:R,submitCallback:function(t,a){return s.a.async((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,s.a.awrap(Ne(t,e,a));case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}))}});case 2:case"end":return t.stop()}}))}function je(e,t){var a={rawData:e,type:"action",title:t.name||"Custom Action",config:t,submitCallback:function(a,n){return s.a.async((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,s.a.awrap(Oe(a,e,t,n));case 2:return r.abrupt("return",r.sent);case 3:case"end":return r.stop()}}))}};oe(a)}function Oe(e,t,a,n){var r,i,o;return s.a.async((function(l){for(;;)switch(l.prev=l.next){case 0:return r=a.url,i=a.requestHeaders,o=a.actualMethod,l.next=3,s.a.awrap(E.fetch({method:o||"put",origUrl:r,rawData:t,body:n?e:JSON.stringify(e),headers:Object(O.a)({},x,{},i||{},{},n?{}:{"content-type":"application/json"}),responseType:"boolean"}));case 3:return l.abrupt("return",l.sent);case 4:case"end":return l.stop()}}))}function ke(){var e,t,a,n,r,i,o,l,c,u,d,p;return s.a.async((function(f){for(;;)switch(f.prev=f.next){case 0:if(D&&1!==(null===fe||void 0===fe?void 0:fe.page)?ae(!1):ae(!0),b(null),f.prev=2,T){f.next=5;break}throw new Error("Get all method is not defined.");case 5:if(!A||fe){f.next=7;break}throw new Error("Pagination not initialized.");case 7:return e=T.url,t=T.requestHeaders,a=T.actualMethod,n=T.dataPath,r=T.sortBy,i=T.dataTransform,f.next=10,s.a.awrap(E.fetch({method:a||"get",origUrl:e,queryParams:ce,headers:Object.assign({},x,t||{})}));case 10:if(o=f.sent,l=y.extractDataByDataPath(o,n)){f.next=14;break}throw new Error("Could not extract data from response.");case 14:if(Array.isArray(l)){f.next=16;break}throw new Error("Extracted data is invalid.");case 16:if("function"!==typeof i){f.next=20;break}return f.next=19,s.a.awrap(i(l));case 19:l=f.sent;case 20:c=Object(C.a)(l,"string"===typeof r?[r]:r||[]),A&&(d=(null===(u=A.fields)||void 0===u?void 0:u.total)?y.extractDataByDataPath(o,A.fields.total.dataPath):void 0,(p=Ie(ce,d))&&me(p)),ye(D?[].concat(Object(j.a)(ge),Object(j.a)(c)):c),f.next=28;break;case 25:f.prev=25,f.t0=f.catch(2),b(f.t0.message);case 28:ae(!1);case 29:case"end":return f.stop()}}),null,null,[[2,25]])}function Ce(e,t){var a,n,r;return s.a.async((function(i){for(;;)switch(i.prev=i.next){case 0:if(L){i.next=2;break}throw new Error("Post method is not defined.");case 2:return a=L.url,n=L.requestHeaders,r=L.actualMethod,i.next=5,s.a.awrap(E.fetch({method:r||"post",origUrl:a,body:t?e:JSON.stringify(e),headers:Object(O.a)({},x,{},n||{},{},t?{}:{"content-type":"application/json"}),responseType:"boolean"}));case 5:return i.abrupt("return",i.sent);case 6:case"end":return i.stop()}}))}function Ne(e,t,a){var n,r,i;return s.a.async((function(o){for(;;)switch(o.prev=o.next){case 0:if($){o.next=2;break}throw new Error("Put method is not defined.");case 2:return n=$.url,r=$.requestHeaders,i=$.actualMethod,o.next=5,s.a.awrap(E.fetch({method:i||"put",origUrl:n,rawData:t,body:a?e:JSON.stringify(e),headers:Object(O.a)({},x,{},r||{},{},a?{}:{"content-type":"application/json"}),responseType:"boolean"}));case 5:return o.abrupt("return",o.sent);case 6:case"end":return o.stop()}}))}function Se(e){var t,a,n,r;return s.a.async((function(i){for(;;)switch(i.prev=i.next){case 0:if(window.confirm("Are you sure you want to delete this item?")){i.next=3;break}return i.abrupt("return");case 3:if(i.prev=3,H){i.next=6;break}throw new Error("Delete method is not defined.");case 6:return t=H.url,a=H.requestHeaders,n=H.actualMethod,i.next=9,s.a.awrap(E.fetch({method:n||"delete",origUrl:t,rawData:e,headers:Object.assign({},x,a||{}),responseType:"boolean"}));case 9:i.sent&&("infinite-scroll"===(null===fe||void 0===fe?void 0:fe.type)?(ye([]),r=Object(j.a)(ce),Object(N.remove)(r,(function(e){return["page","limit"].includes(e.name)})),ue(X(r,A).initQueryParams)):ke()),i.next=16;break;case 13:i.prev=13,i.t0=i.catch(3),p.b.error(i.t0.message);case 16:case"end":return i.stop()}}),null,null,[[3,13]])}function Te(e,t){if(!te){t&&(ye([]),Object(N.remove)(e,(function(e){return["page","limit"].includes(e.name)})),e=X(e,A).initQueryParams),ue(e),me(Ie(e));var a=Object(j.a)(e);"infinite-scroll"===(null===A||void 0===A?void 0:A.type)&&(a=a.filter((function(e){return!["page","limit"].includes(e.name)})));var n=a.map((function(e,t){var a=e.value;return"select"===e.type&&"-- Select --"===a&&(a=""),"".concat(0===t?"?":"").concat(e.name,"=").concat(encodeURIComponent(a||""))})).join("&");u&&n&&m(n)}}function Ie(e,t){var a,n,r,i,o,l,s,c,u,d,p,f;if(A){var m=fe||{type:A.type,page:parseInt((null===(a=A.params)||void 0===a?void 0:null===(n=a.page)||void 0===n?void 0:n.value)||"1"),limit:parseInt((null===(r=A.params)||void 0===r?void 0:null===(i=r.limit)||void 0===i?void 0:i.value)||"10"),descending:"true"===(null===(o=A.params)||void 0===o?void 0:null===(l=o.descending)||void 0===l?void 0:l.value)||!1,hasPreviousPage:!1,hasNextPage:!1,sortBy:null===(s=A.params)||void 0===s?void 0:null===(c=s.sortBy)||void 0===c?void 0:c.value};return m.total=t||(null===fe||void 0===fe?void 0:fe.total),m.page=parseInt(null===(u=e.find((function(e){var t,a;return e.name===(null===A||void 0===A?void 0:null===(t=A.params)||void 0===t?void 0:null===(a=t.page)||void 0===a?void 0:a.name)})))||void 0===u?void 0:u.value)||m.page,m.limit=parseInt(null===(d=e.find((function(e){var t,a;return e.name===(null===A||void 0===A?void 0:null===(t=A.params)||void 0===t?void 0:null===(a=t.limit)||void 0===a?void 0:a.name)})))||void 0===d?void 0:d.value)||m.limit,m.descending="true"===(null===(p=e.find((function(e){var t,a;return e.name===(null===A||void 0===A?void 0:null===(t=A.params)||void 0===t?void 0:null===(a=t.descending)||void 0===a?void 0:a.name)})))||void 0===p?void 0:p.value)||m.descending,m.sortBy=(null===(f=e.find((function(e){var t,a;return e.name===(null===A||void 0===A?void 0:null===(t=A.params)||void 0===t?void 0:null===(a=t.sortBy)||void 0===a?void 0:a.name)})))||void 0===f?void 0:f.value)||m.sortBy,m.hasPreviousPage=q.hasPreviousPage(m.page),m.hasNextPage=q.hasNextPage(m.page,m.limit,m.total),m}}return Object(n.useEffect)((function(){var e,t,a=(null===l||void 0===l?void 0:null===(e=l.config)||void 0===e?void 0:null===(t=e.pages)||void 0===t?void 0:t.filter((function(e,t){return e.id===u||t+1===parseInt(u||"")}))[0])||null;l.setActivePage(a)}),[u]),Object(n.useEffect)((function(){var e=X((null===T||void 0===T?void 0:T.queryParams)||[],A),t=e.initQueryParams,a=e.initialPagination;ye([]),ue(function(e){var t=k.parse(v.search),a=e.map((function(e){return"undefined"!==typeof t[e.name]?e.value="boolean"===e.type?"true"===t[e.name]:decodeURIComponent(t[e.name]):e.value=e.value||"",e}));return me(Ie(a)),a}(t)),me(a)}),[h]),Object(n.useEffect)((function(){ke()}),[ce]),r.a.createElement("div",{className:"app-page"},r.a.createElement("header",{className:"app-page-header"},r.a.createElement("hgroup",null,r.a.createElement("h2",null,null===h||void 0===h?void 0:h.name),(null===h||void 0===h?void 0:h.description)&&r.a.createElement("h4",null,null===h||void 0===h?void 0:h.description)),L&&r.a.createElement(U,{className:"add-item",color:"green",onClick:function(){return oe({type:"add",title:z,config:L,submitCallback:Ce})}},J)),r.a.createElement("main",{className:"app-page-content"},function(){var e,t=((null===T||void 0===T?void 0:T.fields)||(null===T||void 0===T?void 0:null===(e=T.display)||void 0===e?void 0:e.fields)||[]).filter((function(e){return e.filterable})).map((function(e){return e.name}));return r.a.createElement(r.a.Fragment,null,r.a.createElement(M,{initialParams:ce,paginationConfig:A,submitCallback:Te}),t.length>0&&r.a.createElement(V,{onChange:xe}),(null===fe||void 0===fe?void 0:fe.total)&&function(){var e;if(!te&&ge.length){var t,a=(((null===fe||void 0===fe?void 0:fe.page)||1)-1)*((null===fe||void 0===fe?void 0:fe.limit)||10)+1,n=a+ge.length-1,i="Showing results ".concat(a,"-").concat(n," out of ").concat(null===fe||void 0===fe?void 0:fe.total," items");if("infinite-scroll"===(null===fe||void 0===fe?void 0:fe.type)&&(i="Showing ".concat(null===fe||void 0===fe?void 0:fe.total," items")),null===_||void 0===_?void 0:null===(e=_.pagination)||void 0===e?void 0:e.itemsCount)i=null===_||void 0===_?void 0:null===(t=_.pagination)||void 0===t?void 0:t.itemsCount.replace(":currentCountFrom",a).replace(":currentCountTo",a).replace(":totalCount",null===fe||void 0===fe?void 0:fe.total);return r.a.createElement("p",{className:"center pagination-state"},i)}}(),g?r.a.createElement("div",{className:"app-error"},g):function(){var e;if(te)return r.a.createElement(I,null);var t=(null===T||void 0===T?void 0:T.fields)||(null===T||void 0===T?void 0:null===(e=T.display)||void 0===e?void 0:e.fields)||[],a=t.filter((function(e){return e.filterable})).map((function(e){return e.name})),n=ge;if(we&&a.length&&(n=ge.filter((function(e){var t=!1;return a.forEach((function(a){var n=e[a];"string"===typeof n&&n.toLowerCase().indexOf(we)>=0&&(t=!0)})),t}))),!n.length)return r.a.createElement("div",{className:"app-error"},"Nothing to see here. Result is empty.");var i=A?function(){if((null===fe||void 0===fe?void 0:fe.page)&&ce.length>0){var e=(null===fe||void 0===fe?void 0:fe.page)+1;Te(ce.map((function(t){var a,n;return t.name===(null===(a=A.params)||void 0===a?void 0:null===(n=a.page)||void 0===n?void 0:n.name)?Object(O.a)({},t,{value:e}):t})))}}:null,o=A?function(){if((null===fe||void 0===fe?void 0:fe.page)&&fe.page>1&&ce.length>0){var e=(null===fe||void 0===fe?void 0:fe.page)-1;Te(ce.map((function(t){var a,n;return t.name===(null===(a=A.params)||void 0===a?void 0:null===(n=a.page)||void 0===n?void 0:n.name)?Object(O.a)({},t,{value:e}):t})))}}:null,l={delete:H?Se:null,put:$?Pe:null,action:S.length?je:function(){},getNextPage:i,getPreviousPage:o};return"cards"===(null===T||void 0===T?void 0:T.display.type)?r.a.createElement(F,{pagination:fe,callbacks:l,fields:t,items:n,customActions:S,customLabels:_}):r.a.createElement(B,{pagination:fe,callbacks:l,fields:t,items:n,customActions:S,customLabels:_})}())}()),ie&&r.a.createElement(K,{title:ie.title,closeCallback:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(oe(null),!0===e)if("infinite-scroll"===(null===fe||void 0===fe?void 0:fe.type)){ye([]);var t=Object(j.a)(ce);Object(N.remove)(t,(function(e){return["page","limit"].includes(e.name)})),ue(X(t,A).initQueryParams)}else ke()},submitCallback:ie.submitCallback,fields:(null===(o=ie.config)||void 0===o?void 0:o.fields)||[],rawData:ie.rawData,getSingleConfig:ie.getSingleConfig,methodConfig:ie.config}))})),ee=(a(121),T((function(e){var t=e.context.config,a=Object(n.useState)(!1),i=Object(c.a)(a,2),o=i[0],l=i[1];return r.a.createElement("nav",{className:"app-nav"},r.a.createElement(U,{className:"app-nav-opener",onClick:function(){return l(!o)}},o?r.a.createElement("i",{className:"fa fa-times","aria-hidden":"true"}):r.a.createElement("i",{className:"fa fa-bars","aria-hidden":"true"})),r.a.createElement("div",{className:"app-nav-wrapper ".concat(o?"opened":"")},r.a.createElement("div",{className:"app-nav-links"},((null===t||void 0===t?void 0:t.pages)||[]).map((function(e,t){return r.a.createElement(u.b,{to:"/".concat(e.id||t+1),activeClassName:"active",key:"page_".concat(t),onClick:function(){return l(!1)}},e.name)})))))}))),te=function(e){var t=e.styles.vars||{},a=[];for(var n in t)a.push("--".concat(n,": ").concat(t[n]));return r.a.createElement("style",{dangerouslySetInnerHTML:{__html:"\n      :root {\n        ".concat(a.join(";"),"\n      }\n    ")}})},ae=(a(122),a(123),new b),ne="RESTool App";function re(e){var t=document.createElement("link"),a=document.getElementById("favicon");t.id="favicon",t.rel="shortcut icon",t.href=e,a&&document.head.removeChild(a),document.head.appendChild(t)}var ie=function(){var e,t,a,i=Object(n.useState)(!0),o=Object(c.a)(i,2),l=o[0],f=o[1],m=Object(n.useState)(null),v=Object(c.a)(m,2),h=v[0],g=v[1],y=Object(n.useState)((null===h||void 0===h?void 0:null===(e=h.pages)||void 0===e?void 0:e[0])||null),b=Object(c.a)(y,2),E=b[0],w=b[1],x=Object(n.useState)(null),j=Object(c.a)(x,2),O=j[0],k=j[1],C=(null===h||void 0===h?void 0:h.name)||ne;return Object(n.useEffect)((function(){!function e(t){var a,n,r,i,o;return s.a.async((function(l){for(;;)switch(l.prev=l.next){case 0:if(l.prev=0,i=null===(a=window.RESTool)||void 0===a?void 0:a.config,t||!i){l.next=6;break}o=Object.assign({},i,{}),l.next=16;break;case 6:if(!t){l.next=12;break}return l.next=9,s.a.awrap(P.getRemoteConfig(t));case 9:l.t0=l.sent,l.next=15;break;case 12:return l.next=14,s.a.awrap(P.loadDefaultConfig());case 14:l.t0=l.sent;case 15:o=l.t0;case 16:if(ae.baseUrl=o.baseUrl||"",ae.errorMessageDataPath=o.errorMessageDataPath||"",ae.unauthorizedRedirectUrl=o.unauthorizedRedirectUrl||"",ae.requestHeaders=o.requestHeaders||{},document.title=o.name||ne,(null===(n=o)||void 0===n?void 0:n.favicon)&&re(o.favicon),!(null===(r=o)||void 0===r?void 0:r.remoteUrl)){l.next=26;break}return l.next=25,s.a.awrap(e(o.remoteUrl));case 25:return l.abrupt("return",l.sent);case 26:g(o),l.next=32;break;case 29:l.prev=29,l.t1=l.catch(0),console.error("Could not load config file",l.t1);case 32:f(!1);case 33:case"end":return l.stop()}}),null,null,[[0,29]])}()}),[]),Object(n.useEffect)((function(){var e=P.validateConfig(h),t=e.isValid,a=e.errorMessage;if(!t)return k(a),void p.b.error(a)}),[h]),r.a.createElement("div",{className:"restool-app"},h?r.a.createElement(S.Provider,{value:{config:h,activePage:E,setActivePage:w,error:O,setError:k,httpService:ae}},h.customStyles&&r.a.createElement(te,{styles:h.customStyles}),r.a.createElement(u.a,null,r.a.createElement("aside",null,r.a.createElement("h1",{title:C,onClick:function(){return function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:250,t=window.scrollY/2,a=0,n=performance.now();window.requestAnimationFrame((function r(i){(a+=Math.PI/(e/(i-n)))>=Math.PI&&window.scrollTo(0,0),0!==window.scrollY&&(window.scrollTo(0,Math.round(t+t*Math.cos(a))),n=i,window.requestAnimationFrame(r))}))}()}},C),r.a.createElement(ee,null)),h&&r.a.createElement(d.d,null,r.a.createElement(d.b,{exact:!0,path:"/:page",component:Z}),r.a.createElement(d.a,{path:"/",to:"/".concat((null===h||void 0===h?void 0:null===(t=h.pages)||void 0===t?void 0:null===(a=t[0])||void 0===a?void 0:a.id)||"1")})),r.a.createElement(p.a,{position:p.b.POSITION.TOP_CENTER,autoClose:4e3,draggable:!1}))):r.a.createElement("div",{className:"app-error"},l?"Loading Configuration...":"Could not find config file."))};Boolean("localhost"===window.location.hostname||"[::1]"===window.location.hostname||window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/));a(124);o.a.render(r.a.createElement(ie,null),document.getElementById("root")),"serviceWorker"in navigator&&navigator.serviceWorker.ready.then((function(e){e.unregister()}))},51:function(e,t,a){e.exports=a(125)},90:function(e){e.exports=JSON.parse('{"$id":"https://github.com/dsternlicht/RESTool/blob/master/config.schema.json","$schema":"http://json-schema.org/draft-07/schema#","description":"The configuration file used for a RESTool application, see https://github.com/dsternlicht/RESTool","type":"object","additionalProperties":false,"properties":{"name":{"type":"string","description":"The name of your app."},"pages":{"type":"array","items":{"$ref":"#/definitions/page"}},"baseUrl":{"type":"string","description":"Base url of the api. This will prefix the url of all the api methods defined for all pages. This is normally the domain plus a base path. For example: \\"https://restool-sample-app.herokuapp.com/api\\"\\n\\nNote: If different pages use different base urls this should not be used. Instead, you should explicitly define absolute urls for each method."},"errorMessageDataPath":{"$ref":"#/definitions/errorMessageDataPath"},"requestHeaders":{"$ref":"#/definitions/requestHeaders"},"unauthorizedRedirectUrl":{"type":"string","description":"Path to navigate to when the api returns a 401 (Unauthorized) error. You can use :returnUrl to pass a return location. For example: \\"/login/myLoginPage?return=:returnUrl\\""},"favicon":{"type":"string","description":"A URL for you app\'s favicon."},"customStyles":{"$ref":"#/definitions/customStyles"},"customLabels":{"$ref":"#/definitions/customLabels"}},"required":["name","pages"],"definitions":{"errorMessageDataPath":{"type":"array","items":{"type":"string"},"description":"The path within an error response object to look for an error message. If multiple are provided, each will be tried in order until a message is found."},"customStyles":{"type":"object","additionalProperties":false,"properties":{"vars":{"type":"object","additionalProperties":false,"properties":{"appText":{"type":"string","description":"Root text color."},"appBackground":{"type":"string","description":"App background color."},"navBackground":{"type":"string","description":"Navigation menu background color."},"navText":{"type":"string","description":"Navigation menu text color."},"navItemText":{"type":"string","description":"Navigation item text color."},"navItemHoverBackground":{"type":"string","description":"Navigation item background color on hover event."},"navItemActiveBackground":{"type":"string","description":"Active navigation item background color."},"actionButtonBackground":{"type":"string","description":"Action button background color."},"actionButtonHoverBackground":{"type":"string","description":"Action button background color on hover event."},"actionButtonText":{"type":"string","description":"Action button text  color."}}}}},"page":{"type":"object","additionalProperties":false,"properties":{"name":{"type":"string","description":"The name of the page. This will be presented in the menu."},"id":{"type":"string","description":"A unique identifier for the page. RESTool will use it to navigate between pages."},"description":{"type":"string","description":"A short description about the page and its usage."},"requestHeaders":{"$ref":"#/definitions/requestHeaders"},"methods":{"$ref":"#/definitions/methods"},"customActions":{"type":"array","items":{"$ref":"#/definitions/customAction"},"description":"A list of extra (non RESTful) endpoints available in your RESTful API. Specifically customActions is a list of PUT or POST method objects."},"customLabels":{"$ref":"#/definitions/customLabels"}},"required":["name","id"]},"requestHeaders":{"patternProperties":{"^":{"type":"string"}},"description":"A list of key-value headers you wish to add to every request we\'re making.\\nFor example:\\n{ Authentication: \'SECRET_KEY\', \'X-USER-ID\': \'USER_ID\' }"},"methods":{"type":"object","additionalProperties":false,"properties":{"getAll":{"$ref":"#/definitions/getAll"},"getSingle":{"$ref":"#/definitions/getSingle"},"post":{"$ref":"#/definitions/post"},"put":{"$ref":"#/definitions/put"},"delete":{"$ref":"#/definitions/delete"}},"required":["getAll"]},"method":{"type":"object","properties":{"url":{"type":"string","description":"The url for making the request. The url could be either relative or absolute. If a baseUrl is defined then you should only provide a relative path. For example: /users/:id.\\nThe url could contain parameters that will be extracted if needed. For example: \\nhttps://website.com/users/:id - note that the parameter name in the url should match the one you\'re returning in your API."},"actualMethod":{"type":"string","enum":["get","put","post","delete","patch"]},"requestHeaders":{"$ref":"#/definitions/requestHeaders"},"queryParams":{"type":"array","items":{"$ref":"#/definitions/inputField"},"description":"An array of query parameters fields that will be added to the request.\\nIf your url includes the name of the parameter, it will be used as part of the path rather than as a query parameter. For example if your url is /api/contact/234/address you might make a parameter called contactId then set the url as follows: /api/contact/:contactId/address.\\nEach query param item is an object. See input fields."}},"required":["url"]},"getAll":{"allOf":[{"$ref":"#/definitions/method"},{"properties":{"fields":{"type":"array","items":{"$ref":"#/definitions/displayField"}},"dataPath":{"type":"string","description":"TODO"},"display":{"type":"object","properties":{"type":{"enum":["table","cards"]}},"description":"RESTool allows you to control how to output the data. The display object has a type property that will define how to display the data. RESTool supports two display type: \\"table\\" and \\"cards\\"."},"sortBy":{"type":["string","array"],"items":{"type":"string"},"description":"One or more paths to properties in the result object to sort the list by."},"pagination":{"$ref":"#/definitions/pagination"},"dataTransform":{"description":"Relevant only when using dynamic (js) config. A function to allow manipulation on the response data. Useful for changing/adding data for display purposes."}},"required":["display","fields"]}]},"getSingle":{"$ref":"#/definitions/method","description":"This method will be fired once you hit the edit button on an item in order to get a single item\'s data. By default, if this method hasn\'t been set, when editing an item, RESTool will take the raw data from the original getAll request."},"post":{"allOf":[{"$ref":"#/definitions/method"},{"properties":{"fields":{"type":"array","items":{"$ref":"#/definitions/inputField"}}},"required":["fields"]}],"description":"The post method will be used to create new items in your API resource."},"put":{"allOf":[{"$ref":"#/definitions/method"},{"properties":{"fields":{"type":"array","items":{"$ref":"#/definitions/inputField"}},"includeOriginalFields":{"type":"boolean","description":"When set to true, all fields from the original object are merged and sent in the request body. Default is false."}},"required":["fields"]}],"description":"The put method will be used to update an existing item in your API resource."},"delete":{"$ref":"#/definitions/method","description":"The delete method will be used to delete an existing item in your API resource."},"inputField":{"additionalProperties":false,"properties":{"name":{"type":"string","description":"The name of the field / parameter to be sent."},"type":{"type":"string","enum":["text","long-text","object","encode","integer","number","boolean","date","email","color","select","array","file","password","note","hidden"],"description":"Use the type field to define the type of the field."},"readonly":{"type":"boolean"},"label":{"type":"string","description":"A label that describes the field. This will act as a label in RESTool\'s forms."},"dataPath":{"type":"string","description":"Use this field to let RESTool know what is the path of this field in the body of the request."},"options":{"type":"array","items":{"anyOf":[{"type":"string"},{"type":"object","properties":{"display":{"type":"string"},"value":{}}}]},"description":"Add the options field if you chose a select as a type. This field should contain an array of options to be displayed in the select box."},"arrayType":{"type":"string","enum":["text","object"],"description":"For array field type, you should specify another property called arrayType so RESTool will know how to present & send the data in the POST and PUT methods."},"value":{"description":"Set a default value to the field."},"required":{"type":"boolean","description":"If true, a field will be marked as required on PUT and POST forms."},"placeholder":{"type":"string","description":"Input field placeholder."},"accept":{"type":"string","description":"An optional setting for file type inputs. When set, the file input\'s accept property will perform file type filtering when browsing for files."},"useInUrl":{"type":"boolean","description":"If true, a field can be used as a parameter in a PUT url. Otherwise only fields retrieved in the original GET can be used as parameters. It\'s data will still be added to the PUT request body."},"urlReplaceOnly":{"type":"boolean","description":"If true, a field will only be replaced in the URL and is not appended to the final query string."},"optionSource":{"$ref":"#/definitions/optionSource","description":"Use the optionSource field to load options for a select box from a REST service. If this is used with options, the items from options will be added to the select box before those fetched from the api."}},"required":["name","type"]},"displayField":{"additionalProperties":false,"properties":{"name":{"type":"string","description":"The property name of the field that contains the value in the API result."},"type":{"type":"string","enum":["text","url","image","colorbox","boolean"],"description":"This will help RESTool to render the main view.\\ntext -  will parse the value as a text\\nurl -  will render an anchor element with a clickable link\\nimage -  will render an image from the url\\ncolorbox -  will render a #RRGGBB hex string as an 80 x 20 pixel colored rectangle, overlaid with the hex color string"},"label":{"type":"string","description":"A label that describes the field. Will be presented as table headers in the main view."},"dataPath":{"type":"string","description":""},"url":{"type":"string","description":"URL for url typed fields"},"urlLabel":{"type":"string","description":"Display the url label rather than the entire value."},"filterable":{"type":"boolean","description":"Set to true to enable a text control to do simple client-side filtering by values of this field. Can be specified for multiple fields."},"truncate":{"type":"boolean","description":"Causes long values to be truncated. By default, truncation is not enabled for fields."}},"required":["name","type"]},"optionSource":{"additionalProperties":false,"properties":{"url":{"type":"string","description":"url to fetch data from"},"dataPath":{"type":["string","null"],"description":"let us know where we should take the data from"},"displayPath":{"type":"string","description":"property of the object to take the display value from"},"valuePath":{"type":"string","description":"property of the object to take the option value from"},"sortBy":{"type":["string","array"],"items":{"type":"string"},"description":"one or more properties to sort the objects by"}}},"pagination":{"additionalProperties":false,"required":["source","type","params"],"properties":{"source":{"enum":["query"],"description":"Where the pagination parameters are written to. Only supports query parameters for now."},"type":{"enum":["buttons","infinite-scroll"],"description":"Type of pagination. Buttons is the standard one. You can also have a inifite scroll with lazy loading."},"params":{"$ref":"#/definitions/paginationParams"},"fields":{"$ref":"#/definitions/paginationFields"}}},"paginationParams":{"additionalProperties":false,"required":["page"],"properties":{"page":{"$ref":"#/definitions/queryParamConfig","description":"The parameter definition of the page number."},"limit":{"$ref":"#/definitions/queryParamConfig","description":"The parameter definition of the maximum number of items to be returned by the API."},"sortBy":{"$ref":"#/definitions/queryParamConfig","description":"The parameter definition of the sorting value."},"descending":{"$ref":"#/definitions/queryParamConfig","description":"The parameter definition of the order in which the API should return items. false by default."}}},"paginationFields":{"additionalProperties":false,"properties":{"page":{"$ref":"#/definitions/paginationField"},"total":{"$ref":"#/definitions/paginationField"}}},"paginationField":{"additionalProperties":false,"required":["dataPath"],"properties":{"dataPath":{"type":"string"},"display":{"type":"boolean"}}},"queryParamConfig":{"additionalProperties":false,"required":["name"],"properties":{"name":{"type":"string"},"value":{"type":"string"},"urlReplaceOnly":{"type":"boolean"},"label":{"type":"string"}}},"customAction":{"allOf":[{"$ref":"#/definitions/put"},{"type":"object","properties":{"icon":{"type":"string","description":"You may configure the icon of the action. RESTool uses font-awesome and you may use any icon name you want from their collection."}}}],"description":"Specifically customActions is a list of PUT or POST method objects. For example this could enable an endpoint like: PUT /users/:id/disable"},"customLabels":{"additionalProperties":false,"properties":{"buttons":{"$ref":"#/definitions/buttonLabels"},"formTitles":{"$ref":"#/definitions/formTitleLabels"},"placeholders":{"$ref":"#/definitions/placeholderLabels"},"tableColumnHeaders":{"$ref":"#/definitions/tableColumnHeaders"},"pagination":{"$ref":"#/definitions/paginationLabels"}}},"buttonLabels":{"additionalProperties":false,"properties":{"addItem":{"type":"string","description":"Content of the add button on a page.","default":"+ Add Item"},"editItem":{"type":"string","description":"Title of the edit button on a row or a card.","default":"Edit"},"deleteItem":{"type":"string","description":"Title of the delete button on a row or a card.","default":"Delete"},"clearInput":{"type":"string","description":"Title of the clear button on form inputs.","default":"Clear"},"closeForm":{"type":"string","description":"Title of the close button in forms.","default":"Close"},"addArrayItem":{"type":"string","description":"Title of the add button on arrays inputs in forms.","default":"Add Item"}}},"formTitleLabels":{"additionalProperties":false,"properties":{"addItem":{"type":"string","description":"Content of the add button on a page.","default":"Add Item"},"editItem":{"type":"string","description":"Title of the edit button on a row or a card.","default":"Edit Item"}}},"placeholderLabels":{"additionalProperties":false,"properties":{"object":{"type":"string","description":"JSON input placeholder.","default":"Enter JSON..."},"array":{"type":"string","description":"JSON array input placeholder.","default":"Enter JSON array..."},"text":{"type":"string","description":"Text input placeholder.","default":"Enter text..."},"number":{"type":"string","description":"Number input placeholder.","default":0},"color":{"type":"string","description":"Color input placeholder.","default":"Enter color..."},"email":{"type":"string","description":"Email input placeholder.","default":"Enter email..."},"password":{"type":"string","description":"Password input placeholder.","default":"Enter password..."},"date":{"type":"string","description":"Date input placeholder.","default":"Enter date..."},"file":{"type":"string","description":"File input placeholder.","default":"Select file..."}}},"tableColumnHeaders":{"additionalProperties":false,"properties":{"actions":{"type":"string","description":"Header of the action column in tables.","default":"Actions"}}},"paginationLabels":{"additionalProperties":false,"properties":{"itemsCount":{"type":"string","description":"","default":"Showing :currentCountFrom-:currentCountTo out of :totalCount items"},"previousPageTitle":{"type":"string","description":"","default":"Previous page"},"nextPageTitle":{"type":"string","description":"","default":"Next page"}}}}}')}},[[51,1,2]]]);
//# sourceMappingURL=main.93cb13b6.chunk.js.map