"use strict";(self.webpackChunkmaingate_console=self.webpackChunkmaingate_console||[]).push([[340],{68340:function(e,n,r){r.r(n),r.d(n,{default:function(){return S}});var i=r(74165),s=r(15861),t=r(1413),c=r(70885),a=r(47313),l=r(27998),o=r(22370),u=r(33471),d=r(45498),v=r(21139),x=r(33019),h=r(34491),p=(r(88282),r(86480)),j=r(58467),m=r(21330),f=r(85554),Z=r(21963),b=r(30657),k=r(62721),g=r(46417);function S(){var e=(0,j.s0)(),n=(0,f.I0)(),r=(0,m.lr)(),S=(0,c.Z)(r,2),y=S[0],A=(S[1],y.get("name")),C=(0,f.v9)((function(e){return e.accessToken})),N=(0,Z.Bw)(C),U=(0,b.Fp)(),w=U.instance,O=U.accounts,T=(0,a.useState)(!1),I=(0,c.Z)(T,2),D=I[0],L=I[1];(0,a.useEffect)((function(){!function(){Sn.apply(this,arguments)}()}),[]);var H=(0,a.useState)({Id:"",ServiceName:"",Divisions:{},ServiceCode:"",UseWhitelist:!1,Closed:!1,ServerApiTokens:[],ApiUsers:{account:[],service:[],whitelist:[]}}),P=(0,c.Z)(H,2),Y=P[0],q=P[1],B=(0,a.useState)(!1),E=(0,c.Z)(B,2),V=E[0],G=E[1],M=(0,a.useState)(""),W=(0,c.Z)(M,2),z=W[0],J=W[1],R=(0,a.useState)(""),$=(0,c.Z)(R,2),_=$[0],F=$[1],Q=(0,a.useState)(""),X=(0,c.Z)(Q,2),K=X[0],ee=X[1],ne=(0,a.useState)(""),re=(0,c.Z)(ne,2),ie=re[0],se=re[1],te=(0,a.useState)(""),ce=(0,c.Z)(te,2),ae=ce[0],le=ce[1],oe=(0,a.useState)(""),ue=(0,c.Z)(oe,2),de=ue[0],ve=ue[1],xe=(0,a.useState)(""),he=(0,c.Z)(xe,2),pe=he[0],je=he[1],me=(0,a.useState)(!1),fe=(0,c.Z)(me,2),Ze=fe[0],be=fe[1],ke=(0,a.useState)(""),ge=(0,c.Z)(ke,2),Se=ge[0],ye=ge[1],Ae=(0,a.useState)(!1),Ce=(0,c.Z)(Ae,2),Ne=Ce[0],Ue=Ce[1],we=(0,a.useState)(""),Oe=(0,c.Z)(we,2),Te=Oe[0],Ie=Oe[1],De=(0,a.useState)(!1),Le=(0,c.Z)(De,2),He=Le[0],Pe=Le[1],Ye=(0,a.useState)(""),qe=(0,c.Z)(Ye,2),Be=qe[0],Ee=qe[1],Ve=(0,a.useState)(!1),Ge=(0,c.Z)(Ve,2),Me=Ge[0],We=Ge[1],ze=(0,a.useState)(""),Je=(0,c.Z)(ze,2),Re=Je[0],$e=Je[1],_e=(0,a.useState)(!1),Fe=(0,c.Z)(_e,2),Qe=Fe[0],Xe=Fe[1],Ke=(0,a.useState)(""),en=(0,c.Z)(Ke,2),nn=en[0],rn=en[1],sn=(0,a.useState)(!1),tn=(0,c.Z)(sn,2),cn=tn[0],an=tn[1],ln=(0,a.useState)(""),on=(0,c.Z)(ln,2),un=on[0],dn=on[1],vn=(0,a.useState)(!1),xn=(0,c.Z)(vn,2),hn=xn[0],pn=xn[1],jn=(0,a.useState)(""),mn=(0,c.Z)(jn,2),fn=mn[0],Zn=mn[1];function bn(){be(!1),Ue(!1),Pe(!1),We(!1),Xe(!1),an(!1),pn(!1),ye(""),Ie(""),Ee(""),$e(""),rn(""),dn(""),Zn("")}function kn(){return gn.apply(this,arguments)}function gn(){return(gn=(0,s.Z)((0,i.Z)().mark((function e(){var r;return(0,i.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!N){e.next=6;break}return e.next=3,w.acquireTokenSilent((0,t.Z)((0,t.Z)({},k.Q),{},{account:O[0]}));case 3:return r=e.sent,n({type:"set",accessToken:r.accessToken}),e.abrupt("return",r.accessToken);case 6:return e.abrupt("return",C);case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Sn(){return(Sn=(0,s.Z)((0,i.Z)().mark((function e(){var n,r;return(0,i.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,kn();case 2:return n=e.sent,e.prev=3,e.next=6,p.ZP.get("".concat("","/api/service?name=").concat(A),{headers:{Authorization:"Bearer ".concat(n)}});case 6:if(200!==(r=e.sent).status){e.next=16;break}if(r.data&&r.data.Id){e.next=12;break}return h.Am.error("\uc11c\ube44\uc2a4 \uc0c1\uc138 \uc815\ubcf4 \uc870\ud68c\ub97c \uc2e4\ud328\ud588\uc2b5\ub2c8\ub2e4. Service Name: ".concat(A)),G(!0),e.abrupt("return");case 12:q((0,t.Z)((0,t.Z)((0,t.Z)({},Y),r.data),{},{Divisions:(0,t.Z)((0,t.Z)({},Y.Divisions),r.data.Divisions),ApiUsers:(0,t.Z)((0,t.Z)({},Y.ApiUsers),r.data.ApiUsers)})),G(!1),e.next=18;break;case 16:h.Am.error("\uc11c\ube44\uc2a4 \uc0c1\uc138 \uc815\ubcf4 \uc870\ud68c\ub97c \uc2e4\ud328\ud588\uc2b5\ub2c8\ub2e4: ".concat(r.statusText)),G(!0);case 18:e.next=24;break;case 20:e.prev=20,e.t0=e.catch(3),h.Am.error("\uc11c\ube44\uc2a4 \uc0c1\uc138 \uc815\ubcf4 \uc870\ud68c\ub97c \uc2e4\ud328\ud588\uc2b5\ub2c8\ub2e4: ".concat(e.t0.message)),G(!0);case 24:case"end":return e.stop()}}),e,null,[[3,20]])})))).apply(this,arguments)}function yn(){return(yn=(0,s.Z)((0,i.Z)().mark((function n(){var r,s;return(0,i.Z)().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return L(!0),n.next=3,kn();case 3:return r=n.sent,n.prev=4,n.next=7,p.ZP.post("".concat("","/api/service"),Y,{headers:{Authorization:"Bearer ".concat(r)}});case 7:200===(s=n.sent).status?(h.Am.success("\uc11c\ube44\uc2a4 \uc5c5\ub370\uc774\ud2b8\ub97c \uc131\uacf5\ud588\uc2b5\ub2c8\ub2e4.",{position:"top-center",autoClose:2e3,hideProgressBar:!0,theme:"colored"}),setTimeout((function(){e("/services")}),2e3)):h.Am.error("\uc11c\ube44\uc2a4 \uc5c5\ub370\uc774\ud2b8\ub97c \uc2e4\ud328\ud588\uc2b5\ub2c8\ub2e4: ".concat(s.statusText)),n.next=14;break;case 11:n.prev=11,n.t0=n.catch(4),h.Am.error("\uc11c\ube44\uc2a4 \uc5c5\ub370\uc774\ud2b8\ub97c \uc2e4\ud328\ud588\uc2b5\ub2c8\ub2e4: ".concat(n.t0.message));case 14:L(!1);case 15:case"end":return n.stop()}}),n,null,[[4,11]])})))).apply(this,arguments)}return(0,g.jsxs)(l.rb,{children:[(0,g.jsx)(l.b7,{xs:12,children:(0,g.jsxs)(l.xH,{className:"mb-4",children:[(0,g.jsx)(l.bn,{children:(0,g.jsx)("strong",{children:"\uc11c\ube44\uc2a4 \uc0c1\uc138 \uc815\ubcf4"})}),(0,g.jsx)(l.sl,{children:(0,g.jsxs)(l.lx,{className:"row g-3",children:[(0,g.jsx)(l.b7,{md:6,children:(0,g.jsx)(l.jO,{label:"ID",type:"text",value:Y.Id,readOnly:!0})}),(0,g.jsx)(l.b7,{md:6,children:(0,g.jsx)(l.jO,{label:"Service Name",type:"text",value:Y.ServiceName,readOnly:!0})}),(0,g.jsx)(l.b7,{md:6,children:(0,g.jsx)(l.jO,{label:"Service Code",type:"text",value:Y.ServiceCode,readOnly:!0})}),(0,g.jsx)(l.b7,{md:6,children:(0,g.jsxs)(l.LX,{label:"Use Whitelist",onChange:function(e){q((0,t.Z)((0,t.Z)({},Y),{},{UseWhitelist:"Y"===e.target.value}))},value:Y.UseWhitelist?"Y":"N",children:[(0,g.jsx)("option",{value:"Y",children:"Yes"}),(0,g.jsx)("option",{value:"N",children:"No"})]})}),(0,g.jsx)(l.b7,{md:6,children:(0,g.jsxs)(l.LX,{label:"Closed",onChange:function(e){q((0,t.Z)((0,t.Z)({},Y),{},{Closed:"Y"===e.target.value}))},value:Y.Closed?"Y":"N",children:[(0,g.jsx)("option",{value:"Y",children:"Yes"}),(0,g.jsx)("option",{value:"N",children:"No"})]})}),(0,g.jsx)("hr",{}),(0,g.jsxs)(l.b7,{xs:12,children:[(0,g.jsx)(l.L8,{children:"Divisions"}),(0,g.jsxs)(l.rb,{className:"align-items-end mb-3",children:[(0,g.jsx)(l.b7,{md:3,children:(0,g.jsx)(l.jO,{label:"Name",type:"text",value:z,onChange:function(e){J(e.target.value)},invalid:Ze,feedbackInvalid:Se})}),(0,g.jsx)(l.b7,{md:2,children:(0,g.jsx)(l.jO,{label:"Priority",type:"number",value:_,onChange:function(e){F(e.target.value)},invalid:Ne,feedbackInvalid:Te})}),(0,g.jsx)(l.b7,{md:5,children:(0,g.jsx)(l.jO,{label:"URL",type:"text",value:K,onChange:function(e){ee(e.target.value)},invalid:He,feedbackInvalid:Be})}),(0,g.jsx)(l.b7,{md:2,children:(0,g.jsxs)(l.u5,{color:"warning",variant:"outline",onClick:function(e){if(bn(),!z)return be(!0),void ye("Name \uc744 \uc785\ub825\ud558\uc138\uc694.");if(z in Y.Divisions)return be(!0),void ye("\uc774\ubbf8 \ub4f1\ub85d\ud55c Name \uc785\ub2c8\ub2e4.");if(!_)return Ue(!0),void Ie("Priority \ub97c \uc785\ub825\ud558\uc138\uc694.");if(!K)return Pe(!0),void Ee("URL \uc744 \uc785\ub825\ud558\uc138\uc694.");var n=(0,t.Z)({},Y.Divisions);n[z]={priority:_,url:K},q((0,t.Z)((0,t.Z)({},Y),{},{Divisions:n})),J(""),F(""),ee(""),bn()},children:[(0,g.jsx)(o.Z,{icon:u.q}),"\ucd94\uac00"]})})]}),(0,g.jsx)(l.GZ,{children:Object.entries(Y.Divisions).map((function(e){var n=(0,c.Z)(e,2),r=n[0],i=n[1];return(0,g.jsx)(l.Eb,{children:(0,g.jsxs)(l.rb,{className:"align-items-center",children:[(0,g.jsx)(l.b7,{md:3,children:r}),(0,g.jsx)(l.b7,{md:2,children:i.priority}),(0,g.jsx)(l.b7,{md:5,children:i.url}),(0,g.jsx)(l.b7,{md:2,children:(0,g.jsx)(l.u5,{color:"link",onClick:function(){return function(e){var n=(0,t.Z)({},Y.Divisions);delete n[e],q((0,t.Z)((0,t.Z)({},Y),{},{Divisions:n}))}(r)},children:(0,g.jsx)(o.Z,{icon:d.N})})})]})},r)}))})]}),(0,g.jsx)("hr",{}),(0,g.jsxs)(l.b7,{xs:12,children:[(0,g.jsx)(l.L8,{children:"Server API Tokens"}),(0,g.jsxs)(l.rb,{className:"align-items-end mb-3",children:[(0,g.jsx)("div",{className:"col-auto",children:(0,g.jsx)(l.jO,{label:"Token",type:"text",value:ie,onChange:function(e){se(e.target.value)},invalid:Me,feedbackInvalid:Re})}),(0,g.jsx)("div",{className:"col-auto",children:(0,g.jsxs)(l.u5,{color:"warning",variant:"outline",onClick:function(e){return bn(),ie?Y.ServerApiTokens.indexOf(ie)>=0?(We(!0),void $e("\uc774\ubbf8 \ub4f1\ub85d\ud55c Token \uc785\ub2c8\ub2e4.")):(q((0,t.Z)((0,t.Z)({},Y),{},{ServerApiTokens:Y.ServerApiTokens.concat(ie)})),void se("")):(We(!0),void $e("Token \uc744 \uc785\ub825\ud558\uc138\uc694."))},children:[(0,g.jsx)(o.Z,{icon:u.q}),"\ucd94\uac00"]})})]}),(0,g.jsx)(l.GZ,{children:Y.ServerApiTokens.map((function(e){return(0,g.jsx)(l.Eb,{children:(0,g.jsxs)(l.rb,{className:"align-items-center",children:[(0,g.jsx)(l.b7,{md:10,children:e}),(0,g.jsx)(l.b7,{md:2,children:(0,g.jsx)(l.u5,{color:"link",onClick:function(){return n=e,void q((0,t.Z)((0,t.Z)({},Y),{},{ServerApiTokens:Y.ServerApiTokens.filter((function(e){return e!==n}))}));var n},children:(0,g.jsx)(o.Z,{icon:d.N})})})]})},e)}))})]}),(0,g.jsx)("hr",{}),(0,g.jsxs)(l.b7,{xs:12,children:[(0,g.jsx)(l.L8,{children:"API Users"}),(0,g.jsxs)(l.rb,{className:"align-items-end mb-3",children:[(0,g.jsx)("div",{className:"col-auto",children:(0,g.jsx)(l.jO,{label:"Account",type:"text",value:ae,onChange:function(e){le(e.target.value)},invalid:Qe,feedbackInvalid:nn})}),(0,g.jsx)("div",{className:"col-auto",children:(0,g.jsxs)(l.u5,{color:"warning",variant:"outline",onClick:function(){return bn(),ae?ae.match(/^\S+@\S+\.\S+$/)?Y.ApiUsers.account.indexOf(ae)>=0?(Xe(!0),void rn("\uc774\ubbf8 \ub4f1\ub85d\ud55c \uc774\uba54\uc77c\uc785\ub2c8\ub2e4.")):(q((0,t.Z)((0,t.Z)({},Y),{},{ApiUsers:(0,t.Z)((0,t.Z)({},Y.ApiUsers),{},{account:Y.ApiUsers.account.concat(ae)})})),void le("")):(Xe(!0),void rn("\uc62c\ubc14\ub978 \uc774\uba54\uc77c \ud615\uc2dd\uc774 \uc544\ub2d9\ub2c8\ub2e4.")):(Xe(!0),void rn("\uc774\uba54\uc77c\uc744 \uc785\ub825\ud558\uc138\uc694."))},children:[(0,g.jsx)(o.Z,{icon:u.q}),"\ucd94\uac00"]})})]}),(0,g.jsx)(l.GZ,{children:Y.ApiUsers.account.map((function(e){return(0,g.jsx)(l.Eb,{children:(0,g.jsxs)(l.rb,{className:"align-items-center",children:[(0,g.jsx)(l.b7,{md:10,children:e}),(0,g.jsx)(l.b7,{md:2,children:(0,g.jsx)(l.u5,{color:"link",onClick:function(){return n=e,void q((0,t.Z)((0,t.Z)({},Y),{},{ApiUsers:(0,t.Z)((0,t.Z)({},Y.ApiUsers),{},{account:Y.ApiUsers.account.filter((function(e){return e!==n}))})}));var n},children:(0,g.jsx)(o.Z,{icon:d.N})})})]})},e)}))}),(0,g.jsxs)(l.rb,{className:"align-items-end mb-3 mt-3",children:[(0,g.jsx)("div",{className:"col-auto",children:(0,g.jsx)(l.jO,{label:"Service",type:"text",value:de,onChange:function(e){ve(e.target.value)},invalid:cn,feedbackInvalid:un})}),(0,g.jsx)("div",{className:"col-auto",children:(0,g.jsxs)(l.u5,{color:"warning",variant:"outline",onClick:function(e){return bn(),de?de.match(/^\S+@\S+\.\S+$/)?Y.ApiUsers.service.indexOf(de)>=0?(an(!0),void dn("\uc774\ubbf8 \ub4f1\ub85d\ud55c \uc774\uba54\uc77c\uc785\ub2c8\ub2e4.")):(q((0,t.Z)((0,t.Z)({},Y),{},{ApiUsers:(0,t.Z)((0,t.Z)({},Y.ApiUsers),{},{service:Y.ApiUsers.service.concat(de)})})),void ve("")):(an(!0),void dn("\uc62c\ubc14\ub978 \uc774\uba54\uc77c \ud615\uc2dd\uc774 \uc544\ub2d9\ub2c8\ub2e4.")):(an(!0),void dn("\uc774\uba54\uc77c\uc744 \uc785\ub825\ud558\uc138\uc694."))},children:[(0,g.jsx)(o.Z,{icon:u.q}),"\ucd94\uac00"]})})]}),(0,g.jsx)(l.GZ,{children:Y.ApiUsers.service.map((function(e){return(0,g.jsx)(l.Eb,{children:(0,g.jsxs)(l.rb,{className:"align-items-center",children:[(0,g.jsx)(l.b7,{md:10,children:e}),(0,g.jsx)(l.b7,{md:2,children:(0,g.jsx)(l.u5,{color:"link",onClick:function(){return n=e,void q((0,t.Z)((0,t.Z)({},Y),{},{ApiUsers:(0,t.Z)((0,t.Z)({},Y.ApiUsers),{},{service:Y.ApiUsers.service.filter((function(e){return e!==n}))})}));var n},children:(0,g.jsx)(o.Z,{icon:d.N})})})]})},e)}))}),(0,g.jsxs)(l.rb,{className:"align-items-end mb-3 mt-3",children:[(0,g.jsx)("div",{className:"col-auto",children:(0,g.jsx)(l.jO,{label:"Whitelist",type:"text",value:pe,onChange:function(e){je(e.target.value)},invalid:hn,feedbackInvalid:fn})}),(0,g.jsx)("div",{className:"col-auto",children:(0,g.jsxs)(l.u5,{color:"warning",variant:"outline",onClick:function(e){return bn(),pe?pe.match(/^\S+@\S+\.\S+$/)?Y.ApiUsers.whitelist.indexOf(pe)>=0?(pn(!0),void Zn("\uc774\ubbf8 \ub4f1\ub85d\ud55c \uc774\uba54\uc77c\uc785\ub2c8\ub2e4.")):(q((0,t.Z)((0,t.Z)({},Y),{},{ApiUsers:(0,t.Z)((0,t.Z)({},Y.ApiUsers),{},{whitelist:Y.ApiUsers.whitelist.concat(pe)})})),void je("")):(pn(!0),void Zn("\uc62c\ubc14\ub978 \uc774\uba54\uc77c \ud615\uc2dd\uc774 \uc544\ub2d9\ub2c8\ub2e4.")):(pn(!0),void Zn("\uc774\uba54\uc77c\uc744 \uc785\ub825\ud558\uc138\uc694."))},children:[(0,g.jsx)(o.Z,{icon:u.q}),"\ucd94\uac00"]})})]}),(0,g.jsx)(l.GZ,{children:Y.ApiUsers.whitelist.map((function(e){return(0,g.jsx)(l.Eb,{children:(0,g.jsxs)(l.rb,{className:"align-items-center",children:[(0,g.jsx)(l.b7,{md:10,children:e}),(0,g.jsx)(l.b7,{md:2,children:(0,g.jsx)(l.u5,{color:"link",onClick:function(){return n=e,void q((0,t.Z)((0,t.Z)({},Y),{},{ApiUsers:(0,t.Z)((0,t.Z)({},Y.ApiUsers),{},{whitelist:Y.ApiUsers.whitelist.filter((function(e){return e!==n}))})}));var n},children:(0,g.jsx)(o.Z,{icon:d.N})})})]})},e)}))})]}),(0,g.jsx)("hr",{}),(0,g.jsxs)("div",{className:"d-flex justify-content-between",children:[(0,g.jsxs)(l.u5,{color:"secondary",onClick:function(){e("/services")},children:[(0,g.jsx)(o.Z,{icon:v.k}),"\ub4a4\ub85c"]}),(0,g.jsxs)(l.u5,{color:"success",onClick:function(){bn(),function(){yn.apply(this,arguments)}()},disabled:V||D,children:[!D&&(0,g.jsx)(o.Z,{icon:x.J,className:"me-2"}),D&&(0,g.jsx)(l.LQ,{component:"span",size:"sm","aria-hidden":"true",className:"me-2"}),"\uc11c\ube44\uc2a4\ub97c \uc5c5\ub370\uc774\ud2b8\ud569\ub2c8\ub2e4."]})]})]})})]})}),(0,g.jsx)(h.Ix,{position:"top-right",autoClose:5e3,hideProgressBar:!1,newestOnTop:!1,closeOnClick:!0,rtl:!1,pauseOnFocusLoss:!1,draggable:!0,pauseOnHover:!0})]})}},21139:function(e,n,r){r.d(n,{k:function(){return i}});var i=["512 512",""]},33019:function(e,n,r){r.d(n,{J:function(){return i}});var i=["512 512",""]},33471:function(e,n,r){r.d(n,{q:function(){return i}});var i=["512 512",""]},45498:function(e,n,r){r.d(n,{N:function(){return i}});var i=["512 512",""]},21963:function(e,n,r){r.d(n,{Bw:function(){return s}});r(47313);function i(e){try{if(3!==e.split(".").length||"string"!==typeof e)return null;var n=e.split(".")[1],r="=".repeat((4-n.length%4)%4),i=n.replace("-","+").replace("_","/")+r,s=decodeURIComponent(window.atob(i).split("").map((function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)})).join(""));return JSON.parse(s)}catch(t){return null}}function s(e){var n=i(e),r=!0;if(n&&n.exp){var s=new Date(0);s.setUTCSeconds(n.exp),r=s.valueOf()<(new Date).valueOf()}return r}}}]);