(this["webpackJsonpmy-app"]=this["webpackJsonpmy-app"]||[]).push([[0],{262:function(e,a){e.exports="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBw0NDQ0NDQ0NDQ0NDw0NDw0NDQ8NDQ8NFREYIhURExUYHSksGhslHxUTLTEiJSk3Li4uGCAzODMtNygtLjcBCgoKDQ0OFQ8QFS0dHR0rKys3Ky0rKysrKysrKy0rMjcvLSsrLS0rLi0rLSstKysrLSs1Ly0rKystLS0tLS0rLf/AABEIAOEA4QMBIgACEQEDEQH/xAAcAAEBAAIDAQEAAAAAAAAAAAAAAQIHAwYIBQT/xAA7EAACAgECBAIHBAgHAQAAAAAAAQIDBAURBgcSIRMxFCJBUWFxkTKBkqEVI0JTYnKCoiRSk7Gys8E1/8QAGgEBAQADAQEAAAAAAAAAAAAAAQACAwQFBv/EACIRAQEBAAICAgIDAQAAAAAAAAABAgMRBBIhQSIxE1GRFP/aAAwDAQACEQMRAD8A1kAD6KOVF5mRAmI6UAEgACApASUhQZBCogFKACQABCoEKKCkAyhQAKUERSCFBBSgAk4SkKcjcEKQVVTKYmQgABIAAhQQo9gIUCgpiVCgFISAAIUACgpAZQKUgIKCFIAAJOEAHI3qCFFIEUgpkAgIAAIAASUMhRCApBS7ghUKAAICkBJQEBlQUhTIIZEBBQTcEnECFORvAAQUEKKQqZGEIrIACgACApASUAGUCFBCSgAUAAQFICSgAZUoIUyCAoJOEAHG3KABQUgEKQoJImZEImZBkACQABAUgJKQoMghUyAkyIEysUgAEKCFJAAMoFIAKcQAONuCkKSAAICkApSFAxKmCFTEAAJAAEBUQogAAoBCigAEAAClBCigAEnCikCORuUACApCigAEApCighSCqyTBEyiAAEgACFBCj2AhQKEUxKKAUhIKiAQoICTiAByNyghRQABCghRQABCghSSFTBGKrIACAACAAElDIUyCApCS7gAUAAQAAk4SkKcbchUCGSZAiKQCkApQAKAAIUEKKCpmLCIVkABQABAUgFKABCFICSgICgAEHCAgcjeoIUQMJgClAQIKCFFAAFBSAQpGUChMpiVMQoAJAAEBSAUpCgQhluYlJKCEIuEpAcjaoAFKGEBAikG4pQAICkKSAAICkApSbACmW4IiiAAF2AFIKCkKKQFIIAAScIAORvVAhRAUgJKABAikLuKCwezT2T2aez32ffyZAId30XiHh9tRz9CVa/fY2Rdavi3XJpr7mzZ2jcGcNZ1McjFxKraZbpTjZf5rzi05dmvczz0be5Cam/8AH4Un2/VZVa9u73jZ/tUcXk8dzm6zb/rZm/VfL5t8FYmmwx8vDi6qrrXj2U9UpxU3CUoyi2912hLt8jWr+PkejOb2D4+h5T23eO6shfDomup/hcjS3L7RHqOq4lDjvVCfpF/u8Gvu0/hJ9Mf6jLxua/xW6+mO589RtfhDlrp36OxZZ2KrcuyvxbZSnZFpze6hsmvJNL7jovNjS9Pw8jGwdNxY15Eo+LY4znJtzfTVX6zfm1J/hN85ORCmqy2yShXVCdk5PyjCKbb+iPPPD189Z4lpvsTauy/SXF9+mmpdUI/coQRz8Gt6ut2/E+WW+pJG3MflpokYRjPChOUYxUpeJcuqSXd/a9rNMcaadStayMLTqGoxsqx6qa3Kblb0Lq23f+Zv5bHpS6ajFyb2UU235JJebNFco5QzeIMnLsW8nXm5tfV5qy26O7+fTbP6svH5dT23b31DuT4jtHC3KLErhG3UpSyb3s3TCUq8et/5d13m/j2Xw9p2+HA+ixW36LwH8ZY1c5fVrc+xnu5Y9zx1F3qqzwVY9oeN0vo6n7Fvtueb9X4i16nInDLzdQx8hPeVTusoiv5YRaj0/FdviYcc5ee38ulbMfTYfNHhDSMLTbMunFjRep1V1eDOUIOU5rfeG+z7KT8vYaZPuaxxbqOdjwxsvI8euuxWxcoRVnUotLeS23W0n59/icXCejPUdQxcNJ9Ns07Wv2aI97H9E182j0eHOuLF961avtfhs3l1y5wrsGnK1Cl3W5UXbGEpzjCulv1NlFrdtbPv79vYfe1zlrpPoeV6NiRryPAudM+u19N3Q+h7OXv2O2ajm04OJbkTShTi0ysaivKEI/ZX02R+um1TgprupJST9jTXY8vXkclvt23+s66eRk+yfvKfQ4jwfRc/NxvZTkXQj/J1tx/Jo+ee9jXeZXLQAGQcJCg429AAIUEKKCkBJQgBCghRAds5Waj6LrWI29o39eLJ77drF6v90YHUzOi+dU4W1vayqcLYP+OL3X5pGO8+2bDHq3XcNZOHk47W6vpuq7+W8oNf+mvOROiOrEuz7I7WZUvCgmu8aa21L6z6vwo2RpuZDJopyIbOu+qu6LXdOM4pr8mZ4mJXRXCqqKhCtdMYr2I8abuc3H9t/Xd7dA52a76Np8cOEtrc+XQ0vNY0NnY/k/Vj/UzqHIrB8TUcnI23WNjqC9ylbPs/ntXL6nX+ZevfpHVciyMt6aP8LTt5OEG+qS+cnPv7tjZXInT+jTsjIa75OTJRfvrqikv7nYdlz/H4/X3Wvv207TzCz/RdH1C1PaXgTqg/47PVj+cjzrw3rV2m5dOXRt1VPZwf2bK39qEvg19Hs/Ybf57ah0adjYyffIyVKS37uuuLb/udZqzC4P1LJw452NjTyKJSsjtT69qcJNP1PN90/s7+TMvEmZx26+xvvv4b84T4zwNVhHwLlG/b18W3aN8X7dl+0vjHsfQ13QMPUanVl48Lo99pNdNkH74TXeL+TPMlWk58bI9GHnxti949OLkxtjL3x2jun8j0jwMs5abj/pLf0vaXidW3X07vo69u3V09O/xNHPwzi61jTPOu/ixofj3hOej5Uaup2Y98ZTx7ZbdTjFrqhLb9qO8fn1I77yK0LpryNSsj61u+NQ3+7jJOxr5ySX9BlzxXjy0nDpXXk3XW+HFd3s+iK3+DlJfhfuNj6DpleDiY+JX9jHrhWm/OTS7yfxb3f3mzl8jV4cy/usc5/J0PnlrHhYFWDGW08yxSmt+/gVNN/WXh/mdp5fZ/pWjYFre8vAjVP+eveEvziz9WscL6dn2Rty8WvInGPRGU3PtDffZbP3tn7NJ0vGwqVj4tUaaYuUlXFtpSk92+79rOXW83jmZPln1e+2iOcmD4OtWTSaWTRRkb+xy2cH/1r6/E6Qbe5+YPq6flJfZlfjyf8yUof8J/U1Aex4mvbiy59zrVUgB0sHCUxKcboUMEMgAAgoG4FKCFIIVAGSUAEG9OWXGmn1aTjUZubjY12P4lPRddCuTqU/1bSb8ulpfcz9/GfMHT6tOynhZ2LkZUoeFTCm6Fk1Kb28TZPyim39x58By/8ePb27Z+966U39wHxLo+FpWDjWalgwthTGVsHk1qUbZtymmt/NOTNAg3c3DOWSW/pjm+rv8Azk1/Hz83Fji31ZFOPjy/WUzjZX4lk/WimvalCH1R3rl1xZo9OmYWLLOx6bqqoqyF8vA/Xye80nPZP1nLun3NDAw142dYmO/0Zrq9vVb13BUer03F6dt9/Sattvqdc13mfpGJB+FfHNt79NWK1ZHf+Kxeql9/3HnfpXuX0Ka8+Bnv5vZvJWyOC9epztbt1bV8vFxvR6+nHrtsjXCMpOSjGvqfdRj17v3zT7eRsXXuP9Lpw8izH1DDvvjVPwqa74TnO3b1Ukn72jziyxNm/DxrUvbGbsfeXGes7f8A083/AFmdy5YcdWRy74atqMvBnSnXPLuShC2M12Tftak/wmsAbd+Px6zZ10xmrK3bzS17Ss/SbasfUcK2+uym6uuGRXOcnGe0kkn3fTKRpIAy4OGcWfWVa17XsABuYuAqIDkb2QZAMAABAUAUFAIBABiVFAEAAFCKAKAgCCgAYUZYgCxqgAUAAQAAk//Z"},263:function(e,a,t){e.exports=t.p+"static/media/mastercard.362e39be.png"},264:function(e,a){e.exports="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASwAAAEsCAMAAABOo35HAAACT1BMVEUKdNATedIAbs4Ab88Abc4AbM4JctBAk9tureNsrONLmd0BcM8LddFco+BtrONHl9wBb88QeNJgpeFwruQWe9PK4fX////b6/glhNYafdPX6PfS5fYYfNNQnN73+v3////6/P55s+UZfdP4+/1Tnt6cx+wMddG31vHQ5PYbftSjy+0Ecc8igtXe7PhFltzx9/z8/f5nqeLi7vkphtZkp+Ghyu3D3fMReNL9/v4Ic9Cx0/Ayi9jn8fpXoN+62PLo8vqHu+iz1PDw9vw8kdp7tOYggNXy9/yJvOjF3vREldvz+PwSedLG3/Tq8/s4jtlVn9+QwOqTwurV5/cKdNArh9dZod+At+dwruSlzO4DcM+bxuy92vINdtHj7/ktiNfk7/nl8Pr9/f4+ktr7/P7l8PqDuedaouAkg9UmhdbJ4PQUetI0jNg6kNqLvenB3PMvidcuidcdf9SMvulepODO4/UPd9GOv+nu9fsKc9BqquM2jdn5+/1Wn9+FuugGctD1+f1Om92+2vLL4vVRnd72+v1zsORMmt2r0O8FctCu0e/P5Pb7/f6XxOtJmNwAa81ipuF9teav0vCVw+vs9Pu11fH+/v/+//93suWpzu5+tub0+Pyw0vAng9anze4ohdYAbs8xitgOd9EnhdaeyO3T5vbN4vXg7fnI3/RKmd2Nv+mZxezk8PplqOJyr+S01fHZ6fjS5vbP4/X3+/11seXE3vRClNswitjm8Prf7fkZfdPQ5Pbp8vv+/v6w0vAdf9QJc9DN4/UMddD2+v3E3fSNvulHB3y4AAAAxXRSTlP79//////7////////////////9///////////////8f//////////////////////////////////////////////////////////////////////////////////////////8v//////////////+f/////////7//////////////////////////////////////////////////////////////////////////////////////rz//H3+/v/+/L/9W0AZRwAABKxSURBVHgB7NCBAAAgAASxq/ydU3iADWHNOF1W9RjJkiVLlixZyJIlS5YsWciSJUuWLFnIkiVLlixZyJIlS5YsWciSJUuWLFnIkiVLlixZyPrU2YNzPEsUxfGq07dj48a2nfxs27ZtIzae+dc+q+9itqeDft8yemr3szqZ/B+wQNoqQuij4ioiWBxPWhssIDkl1aKUtHT8fTQjMys1XCnZOVILuXmJXy1/jbAKCtmqomL6+2hJKYetrFxi6YpKTriqtcGizGq2q4bwF1ZteKy6eq2MkN7AvmOhsYkta26BOxa3tsF80do7vMeizi62rLuH3LG4t4/MB9Lf7TsW2gbYusEhuGOtSzGwsH4D+45FGzexdXWbtTsWb2mE8UC2+o4FbOMQbc+AO9aOnfTfsbeLfcei3aGe7p5s7Y7Fe4H/jKx9vmOBUtY5/JQ5YjX/Z2rR/gPeYx08xKE6fITcseqOavVXUMfYdyy9uY7DdTwHLlhyalHLCd+xcHJD6JV0ipywxNTSp6t9x6LkHRy2M4Az1rqzhL/W3jn2HAvnL3DoSneTMxZfvPQnFvVd9h2Lrlxls3U7rsXs8Do5wCGxqjddC+jwdXNq3aCoP8o3t14L6NYqYwG3WdR15+69GBUnd7DR/QcRWCceFt+LW/Ej8wA/Bv64L7aFjZ48DbrQs1XGoucnWNR0kmKGF2xU/ZIk1qvXFBDesFFZ7e9Y9OiteNdqCujdamO9v85m1ZmkYkYfDrPRlksUgYXAnxTzHsfHT1op4DMbXe4jz+7BY+gJiwoLoGKG4XNsNDKqrbFwaYyNzrVB4cE4Gw20wTMsPTHJZuumCPEOTI+w0cysNZais+si3kR6ejLyJqpXWFg/x6KiuxT/XXGRjd7uLLDH6rscMbXSxYKZL4BnWLTzLYteKMQ/0r/ARovPrbHQNiCnFu0uYqPP8AwLOYssOvyBAs6UlLHR5aUTtlhKT9SJqfXFl93mG/YIKb+wqK+XRa3DCBpmX7HRuoFSaywUvBJTa/hrsV8y4AGWeN6iA0tkLbzjgMSyn8LNaZvMV6CHlGdYLWXMcjYh8FT6NyyzxVJ05FtzgRwyvwk77nqGFfldzTfzdALHbrx1xsLJ74xD36/7gf/bhXT4hYXXYyx6VQ7LvWGBZfEPwpFprfzC0qMjLPqRkMjB+kp3rHYxFeTf535hYfgnFnUUU2I37QddscRqkf1MPmCJ71jRsRwoGaBkoNTrrlhK/0rcWffYjTxRVCqXdzfMHWZmTobCzMzMzMzMzMzMDN/uB+G8Ps9pay1V/T2yno/t9u26dT0VruZ3Qoo1MoPFl9azUs6REBRJYTQyLCbePb9HeK1Q4AiGsPS6N69yAwSp3KxK574jFSwp4x9ZtKHLU8f8d7JEU24ZweLfSq8gmXJ8XQykb5ekgjVuiN9v0VUlCZ39nJI7y8QQVp31nnEAz4/enVFUKLATvpcO1iA4/52H8tqRPtnlHdUOllZukHvzd4Gfo5PcOdpa65D2aWC1ngxqN59NOLSd/xTqgv6xGSyZ3tMbOqgpoFtXcrNEyp5PtWbdKIJVq+V9HvyCAwx7cNoOVnzCG8HorwJ/tsu52jWFhlC3pYE1+dxt/znMcT8SlHF8orHdnSWtW6GL7p3k1C8ORozjzWlgtaJroXPJCy+Z6WOteNY1NIOlW3vBqgrL+8M8sicSPVCQCtajYYItaq8u+w+srqllB0uiFZ4gXe7fWLe+GQvYPdVFbVPB2vU4hp2AD7zBBHgVlGtgB0sXebvYQ4W4vOfvh0v0JBUs99TvumiNhy637rf0n8LDl50NLH6E9teNI17e+QTIb02AFd1zrm0bn8IUX66tFZ/p+GeGsJZ6i/PKSgLqvemPnqCi3xq8N9SzznV4rtAlym32tP/bR6ovnB2seOE2PwFwK/Iv6A937+U4gcOU3hUOCw8Cl23adGED2wiWlG1OCwXsHnOmgvBlFg4LtgKiE73Jtls8GmEEC7YqE0XgYV0CnS7o4YfCchNBai0b8bvau8na1QqWtL5Hs6HJzeNXbRT91lSwqnnNYi9/AtMgUvO1ESxurxwvI3/oOhdsUfQdU8HaDz2g+FSHP0yDxD0a2MDixt0mWpF02W8if88dYb81HBZLrQGv3M96Uwc6FpedDSxuCZ8plD96xkMrxOi3poJVHaRWxTH+NIgnsixgcfZkP9z7/nrUdIqg35oGVocu8JT9EkHZtFxBQDs7WMM8n6DbMBJR6xpAVwL91nBYrk+h4J7qxzSr+P3klXaw4u1v3e81Z4sK2Ot9ciG8U8FXZhpYI5bBrfPOmwbxRJYBLMiesD1AU27sEsuw9+Gw2D3VmbPzT4OIbHQ2sDh7sgBbChtdbtXbB0sbdFkSYS0ZBq+7G9+XxTLQeh5rA4uzJ89WaRThC51sRX65hsPaVZqE1DaXV4YtbGAGS2c+cy7kLbcF2qC9ipVlWzgsnCWSRrUdC/wvdpkVLJGJXkb5Q/gWeYEQ14+fwmGx1JJB+Q6vMz/ZwOLsSZ9xBKDdUEzoNhLcaqaB1aELtBWWb+JJi1v6zlnBEt3SITd0ux2FOaTqwObhJkYyLJRaZZt/EVmswSxgcfZkOAlSvfnZFUC5onHC7bFwWCS1viyRBVvglvsw0AYWZ0/+0Vtw+mvWVcZqUlYi9lvDYbnTKuQUffYH6b4EzI1gSeEhEqRQkvRtMPZbw2EtGSb03HedgnahFSxQ5b1FMjKLwmHtOhFDfGrTPrIL51nBkopnPaf8tmZlQ4bDcscrin9zPq3JIssCFnfq7rWWbAzuJ2lgVYdZrTJrpvC0mw0sUa8H3H6IZjU6MSIFrA6n4LwF5igvORNY7C6cLytZTYnfSAHL0SwhZRq6mcBi32rbwgxuLM9vDYBFUovE7lArWLJhGoWhMyq5My0cFkqtiJvzFrAg2+wKXmhmsG5pl2PhsHDfACLLAJa3qpBvmsGKGA4LpBaZAMesYOlIbz5ohUim79pAWCC1+OoecUawIHvSa5lmreLCYb3ypJbfJutlBUtrtKVvfGVQnt8aBKtD5TgkAGIAy9N37DBntfNMhsUmOMegjGDVecBh6Oy/p5EMi/v5HLAzgMX2smuwTv/FR+ElKd+aDIsjCrzpN4ElzbzsyV4KQ9+Sj/vqhlRL4XxrCliDPalFVpwBrLhCrv9Q8E4FE+YFDQKqww4R9lvDYe1KXDPjyseMYEnrrhyGDk3iwqy68DBTOCx3NkFqSeEZZwRLl3nZk40Vhe1qKrZ50G9NhBUutfR2LyNYIivo07Vk6nQKhMU2T6QfZyfD4mwvbwdsYGkbb7GcTFMLt/RFgUsub+qM/FaGxalxLhn2yAiW+Ax2lY5RB3ZzwbVChP3WcFi9wAD4EYMxgOWNs2OKgX9ico1doxhHOJ8Mi/9lCH8fwwKWTsjNnsw7BScKoSMoWHG8oEswrMHdJY/Iqm4EC8LM63/Md3BShwsGSthvTYbFwXEajTeApR/a804DB1bCa1M/xY7pgURYEJ4FkXXN2cCCh+vzTU3Y5gfXxkjQb/3cIhkWSi2I8xjA0o8lfD25R5+iavESH40Oh3VsHU6pXnE2sER2QBg6k/+8QwGAL4NpPSuFwnJHQO/9l727cG8jSaIAvl+pFGaocKIwmO3AKMy3Zwozc8xLScy0bL7IYWZmPMb/69gk9ZN61jRpzfvQ1FZ+plZ1VYfSsnoJSzF7crGcFPHufyI207yFVPG/WcQUHIC14qY39JEMqABYFJIuxhpiBbf6Dd47XJG9l8RuVscrVzpVMC30lbdmgkvFQpdYBN71mOKz/faz7p09OTK+Zo4qZ8RurGT1SjU1itcFRJlA6HtOSBVlliqW/V1XYvGGyWJypnQhFm25IiAuFrzrxcXSOMp7LC6WZnj/PhfL9uyJi6XRs3PXxdINJyW6WJqh4fmiGRfLO6nCxbIxe6IZF4tzAy6WfqufdUQjiZZ0iNW9EXuxYA5ZXYkV8+tlpZEz41jQLQ+px+Y/7VzmP2uaj95Utlrs5Luz8MHMls5i2W+1augb1AqSsb/B27k0XJ35JVpj17MK0Y/vqy3ocwzYB7C6M953FUFYBdzJJfn2h8UTGX2/X5quX7euA82JxPH3xRSsg7IzDWltyfOJXqx5ixhYrXkhBmEl7kYdq7T3caLo5PzP4NvzBhffFZOw5MjpLUCL03ZaopHlXzJYoKBazMKS6cfKkdbExRpWC8ciq+tvxTQsqXizC2mt2yORcq+A8QebhyUJRcOQ1vX0SA1NxaAbicetEhOx5MzXROBX9M05Ei5xfZHVqB8tM7FkxQxGG6Xc8YJzYACyWrTAEkOxJLmeCW8rUX6/jAhsO+oSxVgsGXMYak1aihq/GpHVlq+OiMFYcreYb4DTlMHqElJqv2HAyn+sRIzGktH7GdWQitarCg1rY4BVzNTvxHAsyT+BtHZdCP3Xl6z0E3jvHanySWCRvRJNByyZ/SXSKg/5uardNAhYDXuqKoX9wXlYFPvDAP3UJwWC2vtgwWbLxo6zX9adU8CKjmeoCl5/dB6Wd0fJ9Nf6KQmuVC9YBLT41Mz272v9mM3ASvm307rzJwdifS+dyiFUxfNw9sV2Ws1zgRUPTVYWvLL/bB6WHMmDBZu5zdKSqlhk1XeM2oo/MxBLpm+HBZvYlnPzrBRklbkZWJGRWFLxPSzYbP3fhYETljCBQc2/ACuPoViyPgltzDnnroi8WIOsUtKRlbFYEhhMSOvwGEmOR1axVcjKYCxZOglqPayeQcBq7mxkZTSWJA+Fw5hzd6Fi388WsDIcC/9eIgJWafOQlfFYcjcHaKEN/uNEZGU+lozeimsa6KkjsDIfS/JjtbXIX+YDVk7G4kmLr+hn9moJk9lzNbUopmkysHI0Fg38ST8xE8Mec1k/jtLSol3PKoCVs7E8ZCdpNcAJFGzAbiJpteJjd7ZYORLLfiJhSeLZWRRxEfo6oLAKLiOajyW+X/kpktWMFSqrceyJNiyZ3BQTVov44T5sFWVYcvnZLgpn9S4OW0Udlqx+OozwNc2544GV+VigYAO1eMkECc1ihVW0YEl+GsR6mCGhuXYqerHuDyWCW6zGM4oNx+5FHKVYHyqZ8ArD+qVirajDykAdWKgHBGhFA9aZxmEU4S74shK89Y8qrNQhu+gXlbJ8G2dRlGFVTNW4iJ5O7baAltOxiPXjTXslMGCaQBHO3gm0HI5Fabf1MzZzvISJ79EW0ivAT7wCnoQ7G4uTDj7RzoGlPjtjcTi8brmEZvKxFi1za/C48ofDYxcqf4z9FB1YqKYM57/g95b5WM2gvZTITrPR9EsxZD7WnlhkRWSnja3iQgyZjpWeAjtGN0Ct+n1Ay2ysmvcMQVZMYoLVeKBlMtb4TCb8o3Z/KNT6+oxK69kuMhULjxASF28O32EzrChBVZjuv4tMxdpXDyx4/z1p6SlFZ9NvKoCWmVgrZhBF2nhmpcCxle3TgZaJWIGvieBTGtAHjwcNW5KQZCLW6qRhpHNrwfO57IEjrMqvwV+dh8WlVTayJ2t60JEq6oHntGuWtIt1MZs9eDg6NCsuOA+LYrbYiP/9Ur3Dejo185AET4UhrVE/iiJ/+9RbjoKGM31w3HLLxiMhFZxNswhofTlbxPRJ1sSNs4CVX3UoUVLmR1on8k3HsmaeYnzcBWak0ZBPltlY1rVshgepds9+OGeC0VhXpgEralwNNxqNRPCSMYOxlq9DVssyBCajlPA9I8ZiLTwBrPiHJ6JxFw24Z8RIrOqtrNHZB0oUcAo/YCTWyxxUlAEni+D+LHC/g0FYuEBFfFOjJ6l6PyzY7KgwDutjPJPutWzgzj88pmIY1sFKZLWuSqRTt0mSf6XPKKyMbYTv7NMMvpVl1qZEc7CWwn0lZ/9oqfahH8ENuGho847lECwvdS58/UW/YeBNp+6orCZfyByvbiJhsE72RcsJWIHcQbc6l70F/bL3qt8yalOtCuW031u/VHlrN1jo1qCUKidg+Wreft65vM1KXwje8pfpys6aU0Q0IkH1LXcPPZiFLywHYPV8Vv3nFzntWlsi9hNtWG9P8P/qpnWWixUhL1vOVjn7Ny5W+Nx/x9R668znLla4ZLS/UJiLx7tYOAlPiTqUuZa6WCiT13YstxM9TXWx1Kl95KeQ/zylxMUSsBn1BIUG1VkuFtiMKo7pF7tYofn7CVY3bGW5WMG5ixr9OPOFiwU2oyEhrlzhYnXcjOK5X6KkVGdi8YmyvJ7PVzOGUbih38avNBf6R49ieahXwhHuotFdpjAasKiLHlTPNuB+2vlXO3QsAAAAADDI33oU+wohWbJkyZIlC1myZMmSJQtZsmTJkiULWbJkyZIlC1myZMmSJQtZsmTJkiULWbJkyZIlC1myrqwAid/mCk8pwvYAAAAASUVORK5CYII="},444:function(e,a,t){e.exports=t.p+"static/media/grafana.07824330.png"},492:function(e,a,t){e.exports=t(713)},713:function(e,a,t){"use strict";t.r(a);var n=t(0),r=t.n(n),l=t(28),o=t.n(l),c=t(44),s=t(70),i=t(4);const d={EDIT_FORM_VALUE:"EDIT_FORM_VALUE",EDIT_METADATA_VALUES:"EDIT_METADATA_VALUES",SET_METADATA_VALUES:"SET_METADATA_VALUES",EMPTY_FORM_VALUE:"EMPTY_FORM_VALUE",SET_PRODUCTS:"SET_PRODUCTS",ADD_PRODUCT:"ADD_PRODUCT",UPDATE_PRODUCT:"UPDATE_PRODUCT",ARCHIVE_PRODUCT:"ARCHIVE_PRODUCT",SET_USERS:"SET_USERS",ADD_USER:"ADD_USER",UPDATE_USER:"UPDATE_USER",DELETE_USER:"DELETE_USER",SET_CONNECTORS:"SET_CONNECTORS",UPDATE_CONNECTOR:"UPDATE_CONNECTOR",ADD_CONNECTOR:"ADD_CONNECTOR",DELETE_CONNECTOR:"DELETE_CONNECTOR",UPDATE_TOPICS_STATUS:"UPDATE_TOPICS_STATUS",SET_CONNECTOR_INFO:"SET_CONNECTOR_INFO",SET_TOPICS:"SET_TOPICS",ADD_TOPIC:"ADD_TOPIC",DELETE_TOPIC:"DELETE_TOPIC",UPDATE_TOPIC:"UPDATE_TOPIC",SET_THINGS:"SET_THINGS",ADD_THING:"ADD_THING",DELETE_THING:"DELETE_THING",UPDATE_THING:"UPDATE_THING",DELETE_TOPICS:"DELETE_TOPICS",SET_DATABASES:"SET_DATABASES",ADD_DATABASE:"ADD_DATABASE",DELETE_DATABASE:"DELETE_DATABASE",UPDATE_DATABASE:"UPDATE_DATABASE",SET_NOTIFICATIONS:"SET_NOTIFICATIONS",ADD_NOTIFICATION:"ADD_NOTIFICATION",DELETE_NOTIFICATIONS:"DELETE_NOTIFICATIONS",UPDATE_NOTIFICATION:"UPDATE_NOTIFICATION",SET_FLOWS:"SET_FLOWS",ADD_FLOW:"ADD_FLOW",DELETE_FLOW:"DELETE_FLOW",UPDATE_FLOW:"UPDATE_FLOW",OPEN_DRAWER:"OPEN_DRAWER",CLOSE_DRAWER:"CLOSE_DRAWER",DELETE_FLOWS:"DELETE_FLOWS",SET_APIS:"SET_APIS",ADD_API:"ADD_API",DELETE_API:"DELETE_API",DELETE_APIS:"DELETE_APIS",UPDATE_API:"UPDATE_API",SET_SOURCES:"SET_SOURCES",ADD_SOURCE:"ADD_SOURCE",DELETE_SOURCE:"DELETE_SOURCE",DELETE_SOURCES:"DELETE_SOURCES",SET_ADDRESSES:"SET_ADDRESSES",ADD_ADDRESS:"ADD_ADDRESS",DELETE_ADDRESS:"DELETE_ADDRESS",UPDATE_ADDRESS:"UPDATE_ADDRESS",SET_DEFAULT_ADDRESS:"SET_DEFAULT_ADDRESS",SET_METHODS:"SET_METHODS",ADD_METHOD:"ADD_METHOD",DELETE_METHOD:"DELETE_METHOD",UPDATE_METHOD:"UPDATE_METHOD"},m={date:"",service:"",facebook:"",twitter:"",firstname:"",lastname:"",email:"",line1:"",line2:"",postal_code:"",city:"",state:"",country:null,currency:null,amount:""},u=(e,a)=>{switch(a.type){case d.EDIT_FORM_VALUE:return Object(i.a)(Object(i.a)({},e),{},{[a.key.toLowerCase()]:a.value});case d.EMPTY_FORM_VALUE:return m;default:return e}},p=(e,a)=>{switch(a.type){case d.EDIT_METADATA_VALUES:return Object(i.a)(Object(i.a)({},e),{},{[a.key.toLowerCase()]:a.value});case d.SET_METADATA_VALUES:return a.value;default:return e}},g=(e,a)=>{switch(a.type){case d.SET_PRODUCTS:return a.value;case d.UPDATE_PRODUCT:return e.map(e=>e.id===a.productId?Object(i.a)(Object(i.a)({},e),a.value):e);case d.ADD_PRODUCT:return[...e,a.value];case d.ARCHIVE_PRODUCT:return e.map(e=>e.id===a.productId?Object(i.a)(Object(i.a)({},e),{},{active:a.active}):e);default:return e}},y=(e,a)=>{switch(console.log(a),a.type){case d.SET_USERS:return a.value;case d.ADD_USER:return[...e,a.value];case d.DELETE_USER:return e.filter(e=>e.id!==a.userId);case d.UPDATE_USER:return e.map(e=>e.id===a.userId?Object(i.a)(Object(i.a)({},e),a.value):e);default:return e}},E=(e,a)=>{var t;switch(a.type){case d.SET_ADDRESSES:return a.value;case d.ADD_ADDRESS:return[a.value,...e];case d.DELETE_ADDRESS:return e.filter(e=>e.id!==a.addressId);case d.SET_DEFAULT_ADDRESS:return e.map(e=>e.id===a.addressId?Object(i.a)(Object(i.a)({},e),{},{is_default:!0}):Object(i.a)(Object(i.a)({},e),{},{is_default:!1}));case d.UPDATE_ADDRESS:const n=!0===(null===(t=a.value)||void 0===t?void 0:t.is_default);return e.map(e=>e.id===a.addressId?Object(i.a)(Object(i.a)(Object(i.a)({},e),a.value),{},{is_default:!!n||e.is_default}):n?Object(i.a)(Object(i.a)({},e),{},{is_default:!1}):e);default:return e}},b=(e,a)=>{switch(a.type){case d.SET_METHODS:return a.value;case d.ADD_METHOD:return[...e,a.value];case d.DELETE_METHOD:return e.filter(e=>e.id!==a.methodId);case d.UPDATE_METHOD:return e.map(e=>e.id===a.methodId?Object(i.a)(Object(i.a)({},e),a.value):e);default:return e}},h=(e,a)=>{switch(a.type){case d.SET_CONNECTORS:return a.value;case d.UPDATE_CONNECTOR:return e.map(e=>e.name===a.connectorName?Object(i.a)(Object(i.a)({},e),a.value):e);case d.ADD_CONNECTOR:return[...e,a.connector];case d.DELETE_CONNECTOR:return e.filter(e=>e.id!==a.value);default:return e}},v=(e,a)=>{switch(a.type){case d.SET_CONNECTOR_INFO:return a.value;default:return e}},f=(e,a)=>{switch(a.type){case d.OPEN_DRAWER:return!0;case d.CLOSE_DRAWER:return!1;default:return e}},C=(e,a)=>{switch(a.type){case d.SET_TOPICS:return a.value;case d.ADD_TOPIC:return[...e,a.topic];case d.DELETE_TOPIC:return e.filter(e=>e.id!==a.topicId);case d.DELETE_TOPICS:return e.filter(e=>!a.topicIds.includes(e.id));case d.UPDATE_TOPIC:return e.map(e=>e.id===a.topicId?Object(i.a)(Object(i.a)({},e),a.value):e);case d.UPDATE_TOPICS_STATUS:return e.map(e=>a.payload.topicIds.includes(e.id)?Object(i.a)(Object(i.a)({},e),{},{status:a.payload.status}):e);default:return e}},S=(e,a)=>{switch(a.type){case d.SET_THINGS:return a.value;case d.ADD_THING:return[...e,a.thing];case d.DELETE_THING:return e.filter(e=>e.thing_id!==a.thingId);case d.UPDATE_THING:return e.map(e=>e.thing_id===a.thingId?Object(i.a)(Object(i.a)({},e),{},{name:a.name}):e);default:return e}},x=(e,a)=>{switch(a.type){case d.SET_DATABASES:return a.value;case d.ADD_DATABASE:return[a.database,...e];case d.DELETE_DATABASE:return e.filter(e=>e.id!==a.id);case d.UPDATE_DATABASE:return e.map(e=>e.id===a.id?Object(i.a)(Object(i.a)({},e),a.value):e);default:return e}},w=(e,a)=>{switch(a.type){case d.SET_NOTIFICATIONS:return a.value;case d.ADD_NOTIFICATION:return[a.notification,...e];case d.DELETE_NOTIFICATIONS:return e.filter(e=>!a.topicIds.includes(e.id));case d.UPDATE_NOTIFICATION:return e.map(e=>e.id===a.id?Object(i.a)(Object(i.a)({},e),{},{seen:1}):e);default:return e}},O=(e,a)=>{switch(a.type){case d.SET_FLOWS:return a.value;case d.ADD_FLOW:return[...e,a.value];case d.DELETE_FLOW:return e.filter(e=>e.id!==a.flowId);case d.DELETE_FLOWS:return e.filter(e=>!a.flowIds.includes(e.id));case d.UPDATE_FLOW:return e.map(e=>e.id===a.flowId?Object(i.a)(Object(i.a)({},e),{},{name:a.name}):e);default:return e}},A=(e,a)=>{switch(a.type){case d.SET_APIS:return a.value;case d.ADD_API:return[...e,a.value];case d.DELETE_API:return e.filter(e=>e.id!==a.apiId);case d.DELETE_APIS:return e.filter(e=>!a.apiIds.includes(e.id));case d.UPDATE_API:return e.map(e=>e.id===a.apiId?Object(i.a)(Object(i.a)({},e),{},{name:a.name}):e);default:return e}},T=(e,a)=>{switch(a.type){case d.SET_SOURCES:return a.value;case d.ADD_SOURCE:return[...e,a.value];case d.DELETE_SOURCE:return e.filter(e=>e.id!==a.sourceId);case d.DELETE_SOURCES:return e.filter(e=>!a.sourceIds.includes(e.id));default:return e}},j=m,k={productId:null,productName:null,price:null,devices:0,messages:0,level:0},N=Object(n.createContext)(),D=e=>{let{children:a}=e;const[t,l]=Object(n.useReducer)(u,j),[o,c]=Object(n.useReducer)(p,k),[s,i]=Object(n.useReducer)(g,[]),[d,m]=Object(n.useReducer)(y,[]),[D,I]=Object(n.useReducer)(h,[]),[M,P]=Object(n.useReducer)(v,[]),[R,F]=Object(n.useReducer)(C,[]),[B,L]=Object(n.useReducer)(S,[]),[U,W]=Object(n.useReducer)(x,[]),[_,z]=Object(n.useReducer)(T,[]),[q,G]=Object(n.useReducer)(w,[]),[H,V]=Object(n.useReducer)(O,[]),[K,Y]=Object(n.useReducer)(f,!1),[Z,X]=Object(n.useReducer)(A,[]),[J,Q]=Object(n.useReducer)(E,[]),[$,ee]=Object(n.useReducer)(b,[]);return r.a.createElement(N.Provider,{value:{formValuesState:t,formValuesDispatch:l,metadataState:o,metadataDispatch:c,productsState:s,productsDispatch:i,usersState:d,usersDispatch:m,connectorsState:D,connectorsDispatch:I,connectorInfoState:M,connectorInfoDispatch:P,kafkaTopicsState:R,kafkaTopicsDispatch:F,thingsState:B,thingsDispatch:L,databasesState:U,databasesDispatch:W,notificationsState:q,notificationsDispatch:G,flowsState:H,flowsDispatch:V,drawerState:K,drawerDispatch:Y,apisState:Z,apisDispatch:X,sourcesState:_,sourcesDispatch:z,billingAddressesState:J,billingAddressesDispatch:Q,paymentMethodsState:$,paymentMethodsDispatch:ee}},a)},I=()=>Object(n.useContext)(N);var M=t(812),P=t(747);var R=function(e){let a,t,{open:n,message:l,severity:o,onClose:c}=e;const s="string"===typeof l?l:JSON.stringify(l,null,2);switch(o){case"success":a="green",t="white";break;case"error":a="red",t="white";break;case"info":a="blue",t="white";break;case"warning":a="orange",t="white";break;default:a="grey",t="black"}return r.a.createElement(P.a,{open:n,autoHideDuration:6e3,onClose:c},r.a.createElement(M.a,{severity:o,onClose:c,variant:"filled",sx:{width:"100%",color:t,backgroundColor:a}},s))},F=t(12),B=t.n(F);const L=()=>{const e=localStorage.getItem("user");return e?JSON.parse(e):null},U=()=>localStorage.getItem("token")||null,W=()=>{localStorage.removeItem("token"),localStorage.removeItem("user"),localStorage.removeItem("role"),localStorage.removeItem("notifications")},_=(e,a,t)=>{localStorage.setItem("token",e),localStorage.setItem("user",JSON.stringify(a)),localStorage.setItem("role",JSON.stringify(t))},z=e=>{console.error("Full error object:",e);let a="An unknown error occurred";var t,n,r,l,o,c;e.response?(console.error("Response data:",e.response.data),console.error("Status:",e.response.status),"Token expired, please sign in again"==(null===(t=e.response.data)||void 0===t?void 0:t.message)&&(W(),window.location.href="/signin"),a=(null===(n=e.response.data)||void 0===n||null===(r=n.error)||void 0===r?void 0:r.message)||(null===(l=e.response.data)||void 0===l?void 0:l.message)||(null===(o=e.response.data)||void 0===o?void 0:o.error)||(null===(c=e.response.data)||void 0===c?void 0:c.toString())||"Server error occurred"):e.request?(console.error("No response received:",e.request),a="No response received from server"):(console.error("Request setup error:",e.message),a=e.message||"Failed to setup request");throw new Error(a)},q="https://www.thingwings.com/api",G=q+"/topics",H=q+"/things",V=q+"/acl",K=q+"/data-source",Y=q+"/data-source-mapping",Z=q+"/notifications",X=q+"/nodered",J=q+"/predictions",Q=()=>{const e=localStorage.getItem("token");return e?"Bearer ".concat(e):null},$=()=>{const e=localStorage.getItem("user");return e?JSON.parse(e):null},ee=()=>{const e=$();return e&&1===e.admin},ae=e=>{try{let a;if(isNaN(e))a=new Date(e);else{const t="string"===typeof e?parseInt(e,10):e;a=new Date(t)}if(isNaN(a.getTime()))throw new Error("Invalid date");return a.toLocaleString()}catch(a){return null}},te=()=>{let e="#";for(let a=0;a<6;a++)e+="0123456789ABCDEF"[Math.floor(16*Math.random())];return e},ne=e=>e>1e6?e/1e6+" M":e>1e3?e/1e3+" K":e,re=()=>{const e="https://www.thingwings.com";window.location.href=e},le=(e,a,t)=>async function(){try{a(!0),await e(...arguments)}catch(s){var n,r,l,o,c;console.error("Caught Error:",s);let e="An unknown error occurred";e=(null===s||void 0===s||null===(n=s.response)||void 0===n||null===(r=n.data)||void 0===r?void 0:r.message)?s.response.data.message:(null===s||void 0===s||null===(l=s.response)||void 0===l||null===(o=l.data)||void 0===o||null===(c=o.error)||void 0===c?void 0:c.message)?s.response.data.error.message:(null===s||void 0===s?void 0:s.message)?"string"===typeof s.message?s.message:JSON.stringify(s.message):"object"===typeof s?JSON.stringify(s):String(s),t(!0,"Error: ".concat(e),"error")}finally{a(!1)}};B.a.defaults.headers.common.Authorization=Q();const oe=async()=>{try{return(await B.a.get("".concat(G))).data}catch(e){z(e)}},ce=async()=>{try{return(await B.a.get("".concat(G,"/latest/messages"))).data}catch(e){z(e)}},se=async e=>{try{const a=e.map(async e=>(await B.a.delete("".concat(G,"/").concat(e)),e));return await Promise.all(a),a}catch(a){z(a)}},ie=async e=>{try{return(await B.a.post("".concat(G,"/pause-topics"),{topicIds:e})).data}catch(a){z(a)}},de=async e=>{try{return(await B.a.post("".concat(G,"/resume-topics"),{topicIds:e})).data}catch(a){z(a)}},me=async()=>{try{return(await B.a.get("".concat(H))).data}catch(e){z(e)}},ue=async e=>{try{return(await B.a.get("".concat(V,"/aclUser/").concat(e))).data}catch(a){z(a)}},pe=async e=>{try{return(await B.a.post("".concat(V),e)).data}catch(a){z(a)}},ge=async()=>{try{return(await B.a.get("".concat(K))).data}catch(e){z(e)}},ye=async e=>{try{return(await B.a.put("".concat(Z,"/").concat(e))).data}catch(a){z(a)}};var Ee=t(332),be=t(33),he=t(725),ve=t(300),fe=t(89),Ce=t(754),Se=t(31),xe=t(2),we=t(719),Oe=t(720),Ae=t(384),Te=t(751),je=t(752),ke=t(753),Ne=t(749);const De=["pages","className"],Ie=Object(Ee.a)(e=>({root:{},item:{display:"flex",paddingTop:0,paddingBottom:0,textDecoration:"none"},button:{padding:"10px 8px",justifyContent:"flex-start",textTransform:"none",letterSpacing:0,width:"100%",fontWeight:e.typography.fontWeightMedium},icon:{color:e.palette.icon,width:24,height:24,display:"flex",alignItems:"center",marginRight:e.spacing(1)},active:{color:e.palette.primary.main,fontWeight:e.typography.fontWeightMedium,"& $icon":{color:e.palette.primary.main}}}));var Me=e=>{const{pages:a,className:t}=e,n=Object(Se.a)(e,De),l=Ie(),o=Object(c.h)(),[s,i]=r.a.useState(!1),[d,m]=r.a.useState(""),u=Object(c.g)(),p=()=>{i(!1)};return r.a.createElement(we.a,Object.assign({},n,{className:Object(xe.a)(l.root,t)}),a.map(e=>r.a.createElement(Oe.a,{className:Object(xe.a)(l.item,{[l.active]:o.pathname===e.href}),disableGutters:!0,key:e.title},r.a.createElement(Ae.a,{className:l.button,onClick:()=>{return a=e.href,void("/steps"===o.pathname?(m(a),i(!0)):u.push(a));var a}},r.a.createElement("div",{className:l.icon},e.icon),e.title))),r.a.createElement(Ne.a,{open:s,onClose:p},r.a.createElement(Te.a,null,"Confirmation"),r.a.createElement(je.a,{dividers:!0},"Are you sure you want to exit this process?"),r.a.createElement(ke.a,null,r.a.createElement(Ae.a,{onClick:()=>{u.push(d),i(!1)},color:"primary",size:"small"},"Yes"),r.a.createElement(Ae.a,{onClick:p,color:"primary",size:"small"},"No"))))};const Pe=Object(Ee.a)(e=>({drawer:{width:240,flexShrink:0},drawerPaper:{width:240},drawerHeader:Object(i.a)(Object(i.a)({display:"flex",alignItems:"center",padding:e.spacing(0,1)},e.mixins.toolbar),{},{justifyContent:"flex-end"})}));var Re=e=>{let{open:a,pages:t,history:n,variant:l,handleDrawerClose:o}=e;const c=Pe();Object(be.a)();return r.a.createElement(fe.a,{className:c.drawer,variant:l,anchor:"left",open:a,onClose:"temporary"===l?o:void 0,classes:{paper:c.drawerPaper},ModalProps:{keepMounted:!0}},r.a.createElement("div",{className:c.drawerHeader}),r.a.createElement(Ce.a,null),r.a.createElement(Me,{className:c.nav,pages:t,history:n}))},Fe=t(760),Be=t(388),Le=t(315),Ue=t(814),We=t(71),_e=t(762),ze=t(239),qe=t(761),Ge=t(763),He=t(447),Ve=t.n(He),Ke=t(50),Ye=t(445),Ze=t.n(Ye),Xe=t(385);var Je=()=>r.a.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",margin:10}},r.a.createElement(Xe.a,{size:20})),Qe=t(386),$e=t(756),ea=t(387),aa=t(759),ta=t(755),na=t(757),ra=t(758);const la=Object(Ee.a)(e=>({notificationMenu:{padding:e.spacing(1),minWidth:280,maxWidth:380},menuHeader:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:e.spacing(0,1),borderBottom:"1px solid ".concat(e.palette.divider),marginBottom:e.spacing(1)},notificationItem:{margin:e.spacing(.5,0),borderRadius:e.shape.borderRadius,transition:e.transitions.create(["background-color"],{easing:e.transitions.easing.sharp,duration:e.transitions.duration.shortest}),"&:hover":{backgroundColor:e.palette.action.hover}},unreadNotification:{backgroundColor:e.palette.info.light},avatarPlaceholder:{backgroundColor:e.palette.primary.light,color:e.palette.primary.contrastText},dialogContentBox:{backgroundColor:e.palette.background.paper,padding:e.spacing(2),borderRadius:e.shape.borderRadius,border:"1px solid ".concat(e.palette.divider),marginTop:e.spacing(2)},dialogTitleRoot:{padding:e.spacing(2,3),"& .MuiTypography-root":{display:"flex",alignItems:"center"}},dialogActions:{padding:e.spacing(1,2),justifyContent:"flex-end"}})),oa=e=>{let{setLoading:a,handleAlert:t,onClose:l}=e;const o=la(),{notificationsState:c,notificationsDispatch:s}=I(),[i,m]=Object(n.useState)(!1),[u,p]=Object(n.useState)(null),g=le(async e=>{e.seen||(await ye(e.id),s({type:d.UPDATE_NOTIFICATION,id:e.id})),p(e),m(!0)},a,t),y=()=>{m(!1),p(null)},E=le(async()=>{const e=c.filter(e=>!e.seen);if(e.length>0){for(const a of e)await ye(a.id);s({type:d.MARK_ALL_AS_READ})}l&&l()},a,t),b=function(e){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:60;return e&&e.length>a?e.substring(0,a)+"...":e};return r.a.createElement(r.a.Fragment,null,r.a.createElement(we.a,{className:o.notificationMenu},r.a.createElement(Oe.a,{className:o.menuHeader},r.a.createElement(We.a,{variant:"h6",component:"div"},"Notifications"),r.a.createElement(Qe.a,{title:"Mark all as read"},r.a.createElement(Le.a,{color:"primary",onClick:E,size:"small"},r.a.createElement(ta.a,{fontSize:"small"})))),r.a.createElement(Ce.a,null),c.length>0?c.map(e=>r.a.createElement(Oe.a,{button:!0,className:Object(xe.a)(o.notificationItem,{[o.unreadNotification]:!e.seen}),key:e.id,alignItems:"flex-start",onClick:async()=>{await g(e)}},r.a.createElement($e.a,null,r.a.createElement(Ue.a,{className:o.avatarPlaceholder},r.a.createElement(na.a,null))),r.a.createElement(ea.a,{primary:r.a.createElement(We.a,{variant:"subtitle2"},e.typeN),secondary:r.a.createElement(r.a.Fragment,null,r.a.createElement(We.a,{component:"span",variant:"body2",color:"textPrimary",style:{display:"block"}},b(e.message)),r.a.createElement(We.a,{variant:"caption",color:"textSecondary",display:"block"},ae(e.created)))}))):r.a.createElement(Oe.a,{alignItems:"flex-start"},r.a.createElement($e.a,null,r.a.createElement(Ue.a,{className:o.avatarPlaceholder},r.a.createElement(na.a,null))),r.a.createElement(ea.a,{primary:r.a.createElement(We.a,{variant:"subtitle2"},"No New Notifications"),secondary:r.a.createElement(We.a,{component:"span",variant:"body2",color:"textSecondary"},"You are all caught up!")}))),r.a.createElement(Ne.a,{open:i,onClose:y,fullWidth:!0,maxWidth:"sm"},r.a.createElement(Te.a,{disableTypography:!0,className:o.dialogTitleRoot},r.a.createElement(ve.a,{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},r.a.createElement(We.a,{variant:"h6"},r.a.createElement(na.a,{style:{marginRight:8}})," Notification Details"),r.a.createElement(Le.a,{onClick:y,size:"small",edge:"end"},r.a.createElement(ra.a,null)))),r.a.createElement(Ce.a,null),r.a.createElement(je.a,{dividers:!0}," ",u&&r.a.createElement(aa.a,{container:!0,spacing:2},r.a.createElement(aa.a,{item:!0,xs:12},r.a.createElement(We.a,{variant:"body2",color:"textSecondary"},r.a.createElement("strong",null,"Type:")," ",u.typeN)),r.a.createElement(aa.a,{item:!0,xs:12},r.a.createElement(We.a,{variant:"body2",color:"textSecondary"},r.a.createElement("strong",null,"Topic:")," ",u.topic||"N/A")),r.a.createElement(aa.a,{item:!0,xs:12},r.a.createElement(We.a,{variant:"body2",color:"textSecondary"},r.a.createElement("strong",null,"Created:")," ",ae(u.created))),r.a.createElement(aa.a,{item:!0,xs:12},r.a.createElement(ve.a,{className:o.dialogContentBox},r.a.createElement(We.a,{variant:"body1",style:{whiteSpace:"pre-wrap"}},u.message))))),r.a.createElement(ke.a,{className:o.dialogActions},r.a.createElement(Ae.a,{onClick:y,color:"primary",variant:"outlined"},"Close"))))};var ca=t(446),sa=t.n(ca),ia=t(444),da=t.n(ia);const ma=Object(Ee.a)(e=>({appBar:{transition:e.transitions.create(["margin","width"],{easing:e.transitions.easing.sharp,duration:e.transitions.duration.leavingScreen}),marginLeft:0,minWidth:240},appBarShift:{width:"calc(100% - ".concat(240,"px)"),transition:e.transitions.create(["margin","width"],{easing:e.transitions.easing.easeOut,duration:e.transitions.duration.enteringScreen}),marginLeft:240},flexGrow:{flexGrow:1},menuButton:{marginRight:e.spacing(2)},avatar:{cursor:"pointer",width:32,height:32},avatarSmall:{width:e.spacing(3),height:e.spacing(3)}}));var ua=e=>{let{open:a,handleDrawerOpen:t,handleDrawerClose:l,url:o,handleAlert:c}=e;const s=ma(),[i,d]=Object(n.useState)(null),[m,u]=Object(n.useState)(!1),p=Boolean(i),{notificationsState:g}=I(),y=L(),E=Object(be.a)(),b=Object(he.a)(E.breakpoints.down("sm"));return r.a.createElement(Fe.a,{position:"fixed",className:Object(xe.a)(s.appBar,{[s.appBarShift]:a})},r.a.createElement(Be.a,null,a?r.a.createElement(Le.a,{color:"inherit",onClick:l,edge:"start",className:s.menuButton},r.a.createElement(Ze.a,null)):r.a.createElement(Le.a,{color:"inherit",onClick:t,edge:"start",className:s.menuButton},r.a.createElement(qe.a,null)),r.a.createElement(Ue.a,{className:s.avatarSmall,onClick:t,alt:"Thingwings",src:"/logo.png"}),!b&&r.a.createElement(We.a,{variant:"h6",noWrap:!0}," ThingWings "),r.a.createElement("div",{className:s.flexGrow}),r.a.createElement(Qe.a,{title:"Grafana"},r.a.createElement(Le.a,{onClick:()=>window.open("".concat("https://www.thingwings.com/grafana/"))},r.a.createElement(Ue.a,{className:s.avatarSmall,alt:"Grafana",src:da.a}))),r.a.createElement(Qe.a,{title:"Notifications"},r.a.createElement(Le.a,{color:"inherit",onClick:e=>{d(e.currentTarget)}},r.a.createElement(_e.a,{overlap:"rectangular",badgeContent:g.filter(e=>!e.seen).length,color:"error"},r.a.createElement(Ge.a,null)))),r.a.createElement(ze.a,{anchorEl:i,open:p,onClose:()=>{d(null)},anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},getContentAnchorEl:null},r.a.createElement(oa,{setLoading:u,handleAlert:c})),r.a.createElement(Qe.a,{title:"Profile"},r.a.createElement(Le.a,{color:"inherit",component:Ke.a,to:"/account"},y.location?r.a.createElement(Ue.a,{className:s.avatarSmall,alt:"Person",src:"".concat("https://www.thingwings.com/api","/").concat(y.location)}):r.a.createElement(sa.a,null))),r.a.createElement(Qe.a,{title:"Logout"},r.a.createElement(Le.a,{color:"inherit",onClick:()=>{W(),window.location.href="/signin"}},r.a.createElement(Ve.a,null)))))},pa=t(764);var ga=e=>{let{align:a="center"}=e;return r.a.createElement(ve.a,{width:"100%"},r.a.createElement(We.a,{variant:"body2",color:"textSecondary",align:a},"Copyright \xa9 ",r.a.createElement(pa.a,{color:"inherit",href:"https://www.beemetrix.com"},"BeeMetrix")," ",(new Date).getFullYear(),"."))},ya=t(319),Ea=t.n(ya),ba=t(449),ha=t.n(ba),va=t(251),fa=t.n(va),Ca=t(454),Sa=t.n(Ca),xa=t(448),wa=t.n(xa),Oa=t(457),Aa=t.n(Oa),Ta=t(455),ja=t.n(Ta),ka=t(456),Na=t.n(ka),Da=t(451),Ia=t.n(Da),Ma=t(320),Pa=t.n(Ma),Ra=t(452),Fa=t.n(Ra),Ba=t(453),La=t.n(Ba),Ua=t(450),Wa=t.n(Ua);const _a=Object(Ee.a)(e=>({root:{display:"flex",flexDirection:"column",minHeight:"90vh"},mainContent:{display:"flex",flex:1},contentWrapper:{display:"flex",flexDirection:"column",flex:1},content:{flexGrow:1,padding:e.spacing(2),transition:e.transitions.create("margin",{easing:e.transitions.easing.sharp,duration:e.transitions.duration.leavingScreen}),marginLeft:-240,[e.breakpoints.down("sm")]:{paddingLeft:e.spacing(2),paddingRight:e.spacing(2),paddingTop:e.spacing(2),paddingBottom:e.spacing(2),marginLeft:0},flex:1},contentShift:{transition:e.transitions.create("margin",{easing:e.transitions.easing.easeOut,duration:e.transitions.duration.enteringScreen}),marginLeft:0},drawerHeader:Object(i.a)(Object(i.a)({maxWidth:"100%",display:"flex",alignItems:"center",padding:e.spacing(0,1)},e.mixins.toolbar),{},{justifyContent:"flex-end"}),footerContainer:{marginTop:"auto",padding:e.spacing(2,3),[e.breakpoints.down("sm")]:{padding:e.spacing(2)}},fixedFooter:{position:"fixed",bottom:0,right:0,left:e=>e?240:0,padding:e.spacing(2),backgroundColor:e.palette.background.paper,borderTop:"1px solid ".concat(e.palette.divider),transition:e.transitions.create(["left"],{easing:e.transitions.easing.sharp,duration:e.transitions.duration.leavingScreen}),zIndex:e.zIndex.drawer-1}}));var za=e=>{const{children:a,url:t,history:l}=e,{drawerState:o,drawerDispatch:c}=I(),{notificationsDispatch:s}=I(),[m,u]=Object(n.useState)(!1),p=Object(be.a)(),g=Object(he.a)(p.breakpoints.down("sm")),y=_a(o),[E,b]=Object(n.useState)({open:!1,message:"",severity:"info"}),h=(e,a,t)=>{b({open:e,message:a,severity:t})},v=async()=>{await c({type:d.CLOSE_DRAWER})},f=le(async()=>{const e=await(async()=>{try{return(await B.a.get("".concat(Z))).data}catch(e){z(e)}})();await s({type:d.SET_NOTIFICATIONS,value:e})},u,h);Object(n.useEffect)(()=>{f()},[]);const C=L(),S=[{title:"Dashboard",href:"/dashboard",icon:r.a.createElement(wa.a,null)},{title:"Process",href:"/steps",icon:r.a.createElement(ha.a,null)},{title:"Things",href:"/things",icon:r.a.createElement(Wa.a,null)},{title:"Plans",href:"/plan",icon:r.a.createElement(Ia.a,null)},{title:"Topics",href:"/topics",icon:r.a.createElement(Fa.a,null)},{title:"Connectors",href:"/connectors",icon:r.a.createElement(Ea.a,null)},{title:"AI Models",href:"/ai-models",icon:r.a.createElement(La.a,null)},{title:"Flows",href:"/flows",icon:r.a.createElement(fa.a,null)},{title:"DataStores",href:"/datastores",icon:r.a.createElement(Sa.a,null)},{title:"Downloads",href:"/downloads",icon:r.a.createElement(Pa.a,null)},{title:"Account",href:"/account",icon:r.a.createElement(ja.a,null)},{title:"Settings",href:"/settings",icon:r.a.createElement(Na.a,null)}];return null!=C&&C.admin&&S.push({title:"Users",href:"/users",icon:r.a.createElement(Aa.a,null)}),r.a.createElement("div",{className:y.root},r.a.createElement(R,{open:E.open,message:E.message,onClose:()=>{b(e=>Object(i.a)(Object(i.a)({},e),{},{open:!1}))},severity:E.severity}),r.a.createElement(ua,{open:o,handleDrawerOpen:async()=>{await c({type:d.OPEN_DRAWER})},handleDrawerClose:v,url:t,fetchData:f,loading:m,setLoading:u,handleAlert:h}),r.a.createElement("div",{className:y.mainContent},r.a.createElement(Re,{open:o,variant:g?"temporary":"persistent",handleDrawerClose:v,pages:S,history:l,url:t}),r.a.createElement("div",{className:y.contentWrapper},r.a.createElement("main",{className:Object(xe.a)(y.content,{[y.contentShift]:o&&!g})},r.a.createElement("div",{className:y.drawerHeader}),a),r.a.createElement(ve.a,{pt:4,pb:2},r.a.createElement(ve.a,{className:y.fixedFooter},r.a.createElement(ga,{align:"center"}))))))};const qa=["className"],Ga=Object(Ee.a)(()=>({root:{boxShadow:"none"}}));var Ha=e=>{const{className:a}=e,t=Object(Se.a)(e,qa),n=Ga();return r.a.createElement(Fe.a,Object.assign({},t,{className:Object(xe.a)(n.root,a),color:"primary",position:"fixed"}),r.a.createElement(Be.a,null,r.a.createElement(Ke.a,{to:"/"})))};const Va=Object(Ee.a)(()=>({root:{paddingTop:64,height:"100%"},content:{height:"100%"}}));var Ka=e=>{const{children:a}=e,t=Va();return r.a.createElement("div",{className:t.root},r.a.createElement(Ha,null),r.a.createElement("main",{className:t.content},a))};var Ya=e=>{let{routes:a}=e;const t=L(),n=Boolean(t),l=Boolean(null===t||void 0===t?void 0:t.admin);return r.a.createElement(c.d,null,a.map((e,a)=>{const t="MainLayout"===e.layout?za:Ka;return r.a.createElement(c.b,{key:a,path:e.path,exact:e.exact,render:a=>!n||"/signin"!==e.path&&"/signup"!==e.path&&"/"!==e.path?e.requiresAuth&&!n?r.a.createElement(c.a,{to:"/signin"}):n&&!l&&"/users"===e.path?r.a.createElement(c.a,{to:"/not-found"}):r.a.createElement(t,null,r.a.createElement(e.component,a)):r.a.createElement(c.a,{to:"/dashboard"})})}),r.a.createElement(c.b,{render:()=>r.a.createElement(c.a,{to:"/not-found"})}))},Za=t(813),Xa=t(785),Ja=t(767),Qa=t(770),$a=t(396),et=t(771),at=t(26),tt=t(11);const nt=q+"/api/users",rt=q+"/billing";B.a.defaults.headers.common.Authorization=Q();const lt=async()=>{try{return(await B.a.get("".concat(nt))).data.users}catch(e){z(e)}},ot=async(e,a)=>{try{const t=e?"".concat(nt,"/admin"):nt;return(await B.a.post(t,a)).data}catch(t){z(t)}},ct=async(e,a)=>{try{return(e?await B.a.put("".concat(nt,"/admin/").concat(a.id),a):await B.a.put("".concat(nt,"/").concat(a.id),a)).data}catch(t){z(t)}},st=async e=>{try{return(await B.a.post("".concat(rt,"/address"),e)).data}catch(a){z(a)}},it=async()=>{try{return(await B.a.get("".concat(rt,"/address"))).data}catch(e){z(e)}},dt=async e=>{try{return(await B.a.delete("".concat(rt,"/address/").concat(e))).data}catch(a){z(a)}};var mt=t(115),ut=t(252),pt=t(321),gt=t.n(pt);const yt=["className","onChange","style"],Et=Object(Ee.a)(e=>({root:{borderRadius:"4px",alignItems:"center",padding:e.spacing(1),display:"flex",flexBasis:420},icon:{marginRight:e.spacing(1),color:e.palette.text.secondary},input:{flexGrow:1,fontSize:"14px",lineHeight:"16px",letterSpacing:"-0.05px"}}));var bt=e=>{const{className:a,onChange:t,style:n}=e,l=Object(Se.a)(e,yt),o=Et();return r.a.createElement(mt.a,Object.assign({},l,{className:Object(xe.a)(o.root,a),style:n}),r.a.createElement(gt.a,{className:o.icon}),r.a.createElement(ut.a,Object.assign({},l,{className:o.input,disableUnderline:!0,onChange:t})))};const ht=["className","size","color"],vt=Object(Ee.a)(e=>({root:{display:"inline-block",borderRadius:"50%",flexGrow:0,flexShrink:0},sm:{height:e.spacing(1),width:e.spacing(1)},md:{height:e.spacing(2),width:e.spacing(2)},lg:{height:e.spacing(3),width:e.spacing(3)},neutral:{backgroundColor:e.palette.neutral},primary:{backgroundColor:e.palette.primary.main},info:{backgroundColor:e.palette.info.main},warning:{backgroundColor:e.palette.warning.main},danger:{backgroundColor:e.palette.error.main},success:{backgroundColor:e.palette.success.main}})),ft=e=>{const{className:a,size:t,color:n}=e,l=Object(Se.a)(e,ht),o=vt();return r.a.createElement("span",Object.assign({},l,{className:Object(xe.a)({[o.root]:!0,[o[t]]:t,[o[n]]:n},a)}))};ft.defaultProps={size:"md",color:"default"};var Ct=ft;const St=Object(Ee.a)(e=>({root:{marginBottom:e.spacing(2)},searchInput:{width:"100%",[e.breakpoints.up("sm")]:{maxWidth:300}},addButton:{whiteSpace:"nowrap"}}));var xt=e=>{let{title:a,handleSearch:t,openForm:n}=e;const l=St();return r.a.createElement(ve.a,{className:l.root},r.a.createElement(aa.a,{container:!0,spacing:2,alignItems:"center",justifyContent:"space-between"},r.a.createElement(aa.a,{item:!0,xs:12,sm:"auto"},r.a.createElement(bt,{size:"small",className:l.searchInput,placeholder:"Search ".concat(a),onChange:t})),r.a.createElement(aa.a,{item:!0,xs:12,sm:"auto"},r.a.createElement(Ae.a,{className:l.addButton,color:"primary",variant:"contained",onClick:()=>n("ADD"),fullWidth:!0},"Add ".concat(a)))))},wt=t(765),Ot=t(123),At=t.n(Ot);const Tt=Object(Ee.a)(e=>({titleWrapper:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:e.spacing(2),borderBottom:"1px solid ".concat(e.palette.divider)},titleText:{fontWeight:600,fontSize:"1.1rem"},closeButton:{color:e.palette.grey[500]},content:{padding:e.spacing(2.5),backgroundColor:e.palette.background.paper},contentText:{margin:e.spacing(2),color:e.palette.text.secondary},actions:{padding:e.spacing(1.5,2),borderTop:"1px solid ".concat(e.palette.divider),display:"flex",justifyContent:"flex-end",gap:e.spacing(1.5)}}));var jt=e=>{let{open:a,maxWidth:t="sm",onClose:n,title:l,contentText:o,onConfirm:c,confirmText:s="Confirm",cancelText:i="Cancel",children:d,showCancel:m=!0}=e;const u=Tt();return r.a.createElement(Ne.a,{open:a,onClose:n,fullWidth:!0,maxWidth:t,"aria-labelledby":"generic-dialog-title"},r.a.createElement(ve.a,{className:u.titleWrapper},r.a.createElement(We.a,{variant:"h6",className:u.titleText},l),n&&r.a.createElement(Le.a,{size:"small",onClick:n,className:u.closeButton},r.a.createElement(At.a,null))),o&&r.a.createElement(wt.a,{className:u.contentText},o),r.a.createElement(je.a,{dividers:!0,className:u.content},d),r.a.createElement(ke.a,{className:u.actions},c&&r.a.createElement(Ae.a,{onClick:c,color:"primary",variant:"contained"},s)))},kt=t(5),Nt=t(389),Dt=t(766);const It=Object(kt.a)(e=>({paper:{borderRadius:8,minWidth:180,maxWidth:280,color:e.palette.text.primary,boxShadow:"0px 2px 10px rgba(0, 0, 0, 0.08), 0px 4px 16px rgba(0, 0, 0, 0.08)","& .MuiListItemIcon-root":{minWidth:36}}}))(e=>r.a.createElement(ze.a,Object.assign({elevation:3,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},getContentAnchorEl:null},e))),Mt=Object(kt.a)(e=>({root:{fontSize:14,paddingTop:e.spacing(1),paddingBottom:e.spacing(1),"&:hover":{backgroundColor:e.palette.action.hover},"&.Mui-selected":{backgroundColor:e.palette.action.selected},"&.MuiMenuItem-dense":{paddingTop:e.spacing(.5),paddingBottom:e.spacing(.5)}}}))(Nt.a),Pt=e=>{let{anchorEl:a,open:t,handleClose:n,menuItems:l=[],selectedItem:o=null,dense:c=!1}=e;const s=e=>a=>{a.stopPropagation(),e.onClick&&void 0!==o?e.onClick(o):e.onClick&&e.onClick(),!1!==e.closeOnClick&&n()};return r.a.createElement(It,{id:"action-menu",anchorEl:a,keepMounted:!0,open:t,onClose:n},l.map((e,a)=>e.hidden?null:r.a.createElement(Mt,{key:e.id||"menu-item-".concat(a),onClick:s(e),disabled:e.disabled,dense:c||e.dense,divider:e.divider},e.icon&&r.a.createElement(Dt.a,null,"string"===typeof e.icon?r.a.createElement("span",{className:e.icon}):e.icon),r.a.createElement(ea.a,{primary:e.label,primaryTypographyProps:{variant:e.textVariant||"body2",color:e.color||"inherit"}}),e.extraContent&&r.a.createElement("span",{style:{marginLeft:"auto",fontSize:"12px",opacity:.7}},e.extraContent))))};Pt.defaultProps={menuItems:[],dense:!1};var Rt=Pt,Ft=t(768),Bt=t(769),Lt=t(391),Ut=t(392),Wt=t(393),_t=t(394),zt=t(438),qt=t(395),Gt=t(440),Ht=t(390),Vt=t(197),Kt=t.n(Vt);const Yt=Object(Ht.a)(e=>({card:{display:"flex",flexDirection:"column",height:"100%",minHeight:0},tableWrapper:{flex:1,display:"flex",flexDirection:"column",minHeight:0},tableContainer:{flex:1,overflow:"auto",minHeight:0,"& .MuiTableCell-root":{padding:"15px"}},selectableRow:{cursor:"pointer","&:hover":{backgroundColor:e.palette.action.hover}},selectedRow:{backgroundColor:e.palette.action.selected+"!important"},checkboxCell:{width:60,padding:"0 16px !important"},bulkSelectionHeader:{backgroundColor:e.palette.action.selected,padding:e.spacing(1,2),borderBottom:"1px solid ".concat(e.palette.divider)},paginationContainer:{flexShrink:0,borderTop:"1px solid ".concat(e.palette.divider)}}));var Zt=r.a.memo(e=>{let{data:a=[],columns:t=[],title:l="items",rowActions:o=[],onRowAction:c,loading:s=!1,emptyMessage:i="No data available",pagination:d=!0,rowsPerPageOptions:m=[5,10,15],onPageChange:u,onRowsPerPageChange:p,page:g=0,rowsPerPage:y=5,count:E=0,selectable:b=!1,selectedRows:h=[],onSelectedRowsChange:v,bulkActions:f=null}=e;const[C,S]=Object(n.useState)(null),[x,w]=Object(n.useState)(null),O=Yt(),A=Object(n.useMemo)(()=>d?a.slice(g*y,g*y+y):a,[a,d,g,y]),T=Object(n.useCallback)(e=>{b&&v&&v(e.target.checked?A:[])},[b,v,A]),j=Object(n.useCallback)((e,a)=>{if(!b||!v)return;e.stopPropagation();const t=h.some(e=>e.id===a.id||e===a)?h.filter(e=>e.id!==a.id&&e!==a):[...h,a];v(t)},[b,h,v]),k=Object(n.useCallback)((e,a)=>{b&&j(e,a)},[b,j]),N=Object(n.useCallback)(e=>h.some(a=>a.id===e.id||a===e),[h]),D=A.length>0&&A.every(N),I=!D&&h.length>0,M=Object(n.useCallback)((e,a)=>{w(a),S(e.currentTarget),c&&c(a)},[c]),P=Object(n.useCallback)(()=>{S(null),w(null)},[]),R=Object(n.useCallback)(e=>{e.onClick&&e.onClick(x),P()},[x,P]),F=E>0?E:a.length;return r.a.createElement(r.a.Fragment,null,r.a.createElement(Rt,{anchorEl:C,open:Boolean(C),handleClose:P,menuItems:o.map(e=>({label:e.label,onClick:()=>R(e),icon:e.icon})),selectedItem:x}),r.a.createElement(Ja.a,{className:O.card},r.a.createElement(Ft.a,{title:l}),r.a.createElement(Ce.a,null),b&&h.length>0&&f&&r.a.createElement(ve.a,{className:O.bulkSelectionHeader},f),r.a.createElement(ve.a,{className:O.tableWrapper},r.a.createElement(Bt.a,{className:O.tableContainer},r.a.createElement(Lt.a,{stickyHeader:!0},r.a.createElement(Ut.a,null,r.a.createElement(Wt.a,null,b&&r.a.createElement(_t.a,{padding:"checkbox",className:O.checkboxCell},r.a.createElement(zt.a,{indeterminate:I,checked:D,onChange:T,disabled:0===A.length})),t.map(e=>r.a.createElement(_t.a,{key:e.key||e.label,align:e.align||"left"},e.label)),o.length>0&&r.a.createElement(_t.a,{align:"center"},"Actions"))),r.a.createElement(qt.a,null,A.length>0?A.map((e,a)=>{const n=N(e),l=e.id||a;return r.a.createElement(Wt.a,{key:l,hover:!0,className:"".concat(O.selectableRow," ").concat(n?O.selectedRow:""),onClick:a=>k(a,e)},b&&r.a.createElement(_t.a,{padding:"checkbox",className:O.checkboxCell},r.a.createElement(zt.a,{checked:n,onClick:a=>j(a,e)})),t.map(a=>r.a.createElement(_t.a,{key:a.key,align:a.align||"left"},a.render?a.render(e):e[a.key])),o.length>0&&r.a.createElement(_t.a,{align:"center",onClick:e=>e.stopPropagation()},r.a.createElement(Qe.a,{title:"Actions"},r.a.createElement(Le.a,{onClick:a=>M(a,e),size:"small"},r.a.createElement(Kt.a,null)))))}):r.a.createElement(Wt.a,null,r.a.createElement(_t.a,{colSpan:t.length+(o.length>0?1:0)+(b?1:0),align:"center"},r.a.createElement(We.a,{variant:"body1"},i)))))),d&&r.a.createElement(ve.a,{className:O.paginationContainer},r.a.createElement(Gt.a,{component:"div",count:F,page:g,onPageChange:u,rowsPerPage:y,onRowsPerPageChange:p,rowsPerPageOptions:m})))))}),Xt=t(198),Jt=t.n(Xt);var Qt=e=>{let{name:a,message:t,handleAlert:n}=e;console.log(t);const l=(()=>{try{return JSON.parse(t.message)}catch(e){return t.message}})();return r.a.createElement(Ja.a,null,r.a.createElement(ve.a,{style:{padding:"10px"},display:"flex",justifyContent:"space-between",alignItems:"center"},l.creationDate&&r.a.createElement(We.a,{variant:"h6"}," Date : ",ae(Number(l.creationDate))," ")),r.a.createElement(Qa.a,null,r.a.createElement(aa.a,{container:!0,justifyContent:"space-between",alignItems:"center"},r.a.createElement(aa.a,{item:!0,xs:12},r.a.createElement(Jt.a,{name:a,src:l,enableClipboard:e=>{navigator.clipboard.writeText(JSON.stringify(e.src,null,2)),n(!0,"Copied to clipboard","success")}})))))},$t=t(460),en=t.n($t),an=t(45),tn=t.n(an);var nn=e=>{let{name:a,timestamp:t,message:n,onOpen:l,onDelete:o}=e;return r.a.createElement(Ja.a,null,r.a.createElement(Qa.a,null,r.a.createElement(ve.a,{display:"flex",justifyContent:"space-between",alignItems:"center"},r.a.createElement(We.a,{variant:"h6"},a),r.a.createElement(ve.a,null,l&&r.a.createElement(Le.a,{onClick:()=>l(n)},r.a.createElement(en.a,{color:"primary"})),o&&r.a.createElement(Le.a,{onClick:()=>o(n)},r.a.createElement(tn.a,null)))),r.a.createElement(We.a,{variant:"body2",color:"textSecondary"},t)))};var rn=e=>{const{handleAlert:a}=e,[t,l]=Object(n.useState)(!1),o=L(),c=le(async e=>{await ct(!1,Object(i.a)({id:o.id},e));const t=Object(i.a)(Object(i.a)({},o),e);_(U(),t,(()=>{const e=localStorage.getItem("role");return e?JSON.parse(e):null})()),a(!0,"Info updated successfully","success")},l,a);return r.a.createElement(Ja.a,{sx:{height:"100%"}},r.a.createElement(at.d,{initialValues:{name:o.name||"",username:o.username||"",email:o.email||"",phone:ae(o.created)||""},validationSchema:tt.c({name:tt.d().required("Name is required"),username:tt.d().required("Username is required"),email:tt.d().email("Invalid email address").required("Email is required")}),onSubmit:c},e=>{let{errors:a,touched:n,isSubmitting:l}=e;return r.a.createElement(at.c,{autoComplete:"off",noValidate:!0},r.a.createElement(Qa.a,null,t&&r.a.createElement(Je,null),r.a.createElement(aa.a,{container:!0,spacing:3},r.a.createElement(aa.a,{item:!0,md:6,xs:12},r.a.createElement(at.b,{name:"name",as:$a.a,label:"Name",fullWidth:!0,variant:"outlined",error:n.name&&Boolean(a.name),helperText:n.name&&a.name})),r.a.createElement(aa.a,{item:!0,md:6,xs:12},r.a.createElement(at.b,{name:"username",as:$a.a,label:"Username",fullWidth:!0,variant:"outlined",error:n.username&&Boolean(a.username),helperText:n.username&&a.username})),r.a.createElement(aa.a,{item:!0,md:6,xs:12},r.a.createElement(at.b,{name:"email",as:$a.a,label:"Email Address",fullWidth:!0,variant:"outlined",error:n.email&&Boolean(a.email),helperText:n.email&&a.email})),r.a.createElement(aa.a,{item:!0,md:6,xs:12},r.a.createElement(at.b,{name:"phone",as:$a.a,label:"Creation Date",fullWidth:!0,variant:"outlined",InputProps:{readOnly:!0}})))),r.a.createElement(Ce.a,null),r.a.createElement(et.a,{style:{float:"right"}},r.a.createElement(Ae.a,{color:"primary",variant:"contained",type:"submit",disabled:l},"Update")))}))},ln=t(269),on=t(403),cn=t(163),sn=t.n(cn);const dn=["className","handleAlert"],mn=Object(Ee.a)(e=>({root:{},details:{display:"flex"},avatar:{height:110,width:100},dialog:{padding:e.spacing(2)},dropzoneClass:{background:"#212121",fontSize:12,border:"1px solid ".concat(e.palette.divider),borderRadius:e.shape.borderRadius,padding:e.spacing(2),marginBottom:e.spacing(2)},progress:{marginTop:e.spacing(2),textAlign:"center"},dialogActions:{justifyContent:"flex-end"},button:{marginLeft:e.spacing(1)}}));var un=e=>{let{className:a,handleAlert:t}=e,l=Object(Se.a)(e,dn);const o=mn(),[c,s]=Object(n.useState)([]),[i,d]=Object(n.useState)(0),[m,u]=Object(n.useState)(!1),[p,g]=Object(n.useState)(!1),y=L(),[E,b]=Object(n.useState)(y.location),h=le(async()=>{try{const e=await(async(e,a)=>{try{const t=new FormData;e.forEach(e=>t.append("file",e));return(await B.a.post("".concat("https://www.thingwings.com/api/account","/update-photo/").concat(e[0].name),t,{headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(U())},onUploadProgress:e=>{a(e.loaded/e.total*100)}})).data}catch(t){console.log(t),z(t)}})(c,d),a=null===e||void 0===e?void 0:e.location;b(a),y.location=a,_(U(),y,{}),v(),t(!0,"Profile picture updated successfully","success")}catch(e){console.error("Error uploading file:",e)}},u,t),v=()=>g(!1);return r.a.createElement(Ja.a,Object.assign({},l,{className:Object(xe.a)(o.root,a)}),r.a.createElement(Qa.a,null,r.a.createElement(aa.a,{container:!0,justifyContent:"center",alignItems:"center"},r.a.createElement(aa.a,{item:!0,style:{position:"relative",display:"inline-block"}},r.a.createElement(Ue.a,{className:o.avatar,src:"".concat("https://www.thingwings.com/api","/").concat(E)}),r.a.createElement(Le.a,{style:{position:"absolute",bottom:0,right:0,backgroundColor:"white",border:"2px solid white"},onClick:()=>g(!0)},r.a.createElement(sn.a,null)))),r.a.createElement(aa.a,{style:{marginTop:10},container:!0,justifyContent:"center",alignItems:"center"},r.a.createElement(aa.a,{item:!0},r.a.createElement(We.a,{gutterBottom:!0,variant:"body1",align:"center"},y.name),r.a.createElement(We.a,{color:"textSecondary",variant:"body1",align:"center"},y.email))),r.a.createElement("div",{className:o.progress},r.a.createElement(on.a,{value:100,variant:"determinate"}))),r.a.createElement(Ce.a,null),r.a.createElement(Ne.a,{open:p,onClose:v,classes:{paper:o.dialog}},r.a.createElement(Te.a,null,"Upload Image"),r.a.createElement(je.a,{dividers:!0},r.a.createElement(ln.a,{onChange:e=>s(e),dropzoneClass:o.dropzoneClass,acceptedFiles:["image/*"],showPreviews:!0,showPreviewsInDropzone:!0,maxFileSize:5e6}),r.a.createElement("div",{className:o.progress},m&&r.a.createElement(Je,null),r.a.createElement(on.a,{variant:"determinate",value:i}),r.a.createElement(We.a,{variant:"body2"},"".concat(Math.round(i),"%")))),r.a.createElement(ke.a,{className:o.dialogActions},r.a.createElement(Ae.a,{onClick:v,color:"default",variant:"outlined",className:o.button},"Cancel"),r.a.createElement(Ae.a,{onClick:h,color:"primary",variant:"contained",className:o.button},"Upload"))))},pn=t(322),gn=t(323),yn=t(327),En=t(324),bn=t(404);const hn=[{name:"Andorra",currency:"EUR",symbol:"\u20ac",code:"AD"},{name:"United Arab Emirates",currency:"AED",symbol:"\u062f.\u0625",dateFormat:"dd/MM/yyyy",code:"AE"},{name:"Afghanistan",currency:"AFN",symbol:"Af",code:"AF"},{name:"Antigua and Barbuda",currency:"XCD",symbol:"XCD",code:"AG"},{name:"Anguilla",currency:"XCD",symbol:"XCD",code:"AI"},{name:"Albania",currency:"ALL",symbol:"ALL",dateFormat:"yyyy-MM-dd",code:"AL"},{name:"Armenia",currency:"AMD",symbol:"AMD",code:"AM"},{name:"Angola",currency:"AOA",symbol:"AOA",code:"AO"},{name:"Argentina",currency:"ARS",symbol:"AR$",dateFormat:"dd/MM/yyyy",code:"AR"},{name:"American Samoa",currency:"USD",symbol:"$",code:"AS"},{name:"Austria",currency:"EUR",symbol:"\u20ac",dateFormat:"dd.MM.yyyy",code:"AT"},{name:"Australia",currency:"AUD",symbol:"AU$",dateFormat:"d/MM/yyyy",code:"AU"},{name:"Aruba",currency:"AWG",symbol:"AWG",code:"AW"},{name:"Aland Islands",currency:"EUR",symbol:"\u20ac",code:"AX"},{name:"Azerbaijan",currency:"AZN",symbol:"man.",code:"AZ"},{name:"Algeria",currency:"DZD",symbol:"DA",dateFormat:"dd/MM/yyyy",code:"DZ"},{name:"Bosnia and Herzegovina",currency:"BAM",symbol:"KM",dateFormat:"yyyy-MM-dd",code:"BA"},{name:"Barbados",currency:"BBD",symbol:"BBD",code:"BB"},{name:"Bangladesh",currency:"BDT",symbol:"Tk",code:"BD"},{name:"Belgium",currency:"EUR",symbol:"\u20ac",dateFormat:"d/MM/yyyy",code:"BE"},{name:"Burkina Faso",currency:"XOF",symbol:"CFA",code:"BF"},{name:"Bulgaria",currency:"BGN",symbol:"BGN",dateFormat:"yyyy-M-d",code:"BG"},{name:"Bahrain",currency:"BHD",symbol:"BD",dateFormat:"dd/MM/yyyy",code:"BH"},{name:"Burundi",currency:"BIF",symbol:"FBu",code:"BI"},{name:"Benin",currency:"XOF",symbol:"CFA",code:"BJ"},{name:"Saint Barthelemy",currency:"EUR",symbol:"\u20ac",code:"BL"},{name:"Bermuda",currency:"BMD",symbol:"BMD",code:"BM"},{name:"Brunei",currency:"BND",symbol:"BN$",code:"BN"},{name:"Bolivia",currency:"BOB",symbol:"Bs",dateFormat:"dd-MM-yyyy",code:"BO"},{name:"Bonaire, Saint Eustatius and Saba ",currency:"USD",symbol:"$",code:"BQ"},{name:"Brazil",currency:"BRL",symbol:"R$",dateFormat:"dd/MM/yyyy",code:"BR"},{name:"Bahamas",currency:"BSD",symbol:"BSD",code:"BS"},{name:"Bhutan",currency:"BTN",symbol:"BTN",code:"BT"},{name:"Bouvet Island",currency:"NOK",symbol:"Nkr",code:"BV"},{name:"Botswana",currency:"BWP",symbol:"BWP",code:"BW"},{name:"Belarus",currency:"BYN",symbol:"BYN",dateFormat:"d.M.yyyy",code:"BY"},{name:"Belize",currency:"BZD",symbol:"BZ$",code:"BZ"},{name:"Canada",currency:"CAD",symbol:"CA$",dateFormat:"dd/MM/yyyy",code:"CA"},{name:"Cocos Islands",currency:"AUD",symbol:"AU$",code:"CC"},{name:"Democratic Republic of the Congo",currency:"CDF",symbol:"CDF",code:"CD"},{name:"Central African Republic",currency:"XAF",symbol:"FCFA",code:"CF"},{name:"Republic of the Congo",currency:"XAF",symbol:"FCFA",code:"CG"},{name:"Switzerland",currency:"CHF",symbol:"CHF",dateFormat:"dd.MM.yyyy",code:"CH"},{name:"Ivory Coast",currency:"XOF",symbol:"CFA",code:"CI"},{name:"Cook Islands",currency:"NZD",symbol:"NZ$",code:"CK"},{name:"Chile",currency:"CLP",symbol:"CL$",dateFormat:"dd-MM-yyyy",code:"CL"},{name:"Cameroon",currency:"XAF",symbol:"FCFA",code:"CM"},{name:"China",currency:"CNY",symbol:"CN\xa5",dateFormat:"yyyy-M-d",code:"CN"},{name:"Colombia",currency:"COP",symbol:"CO$",dateFormat:"d/MM/yyyy",code:"CO"},{name:"Costa Rica",currency:"CRC",symbol:"\u20a1",dateFormat:"dd/MM/yyyy",code:"CR"},{name:"Cuba",currency:"CUP",symbol:"CUP",code:"CU"},{name:"Cape Verde",currency:"CVE",symbol:"CV$",code:"CV"},{name:"Curacao",currency:"ANG",symbol:"ANG",code:"CW"},{name:"Christmas Island",currency:"AUD",symbol:"AU$",code:"CX"},{name:"Cyprus",currency:"EUR",symbol:"\u20ac",dateFormat:"dd/MM/yyyy",code:"CY"},{name:"Czech Republic",currency:"CZK",symbol:"K\u010d",dateFormat:"d.M.yyyy",code:"CZ"},{name:"Germany",currency:"EUR",symbol:"\u20ac",dateFormat:"dd.MM.yyyy",code:"DE"},{name:"Djibouti",currency:"DJF",symbol:"Fdj",code:"DJ"},{name:"Denmark",currency:"DKK",symbol:"Dkr",dateFormat:"dd-MM-yyyy",code:"DK"},{name:"Dominica",currency:"XCD",symbol:"XCD",code:"DM"},{name:"Dominican Republic",currency:"DOP",symbol:"RD$",dateFormat:"MM/dd/yyyy",code:"DO"},{name:"Ecuador",currency:"USD",symbol:"$",dateFormat:"dd/MM/yyyy",code:"EC"},{name:"Estonia",currency:"EUR",symbol:"\u20ac",dateFormat:"d.MM.yyyy",code:"EE"},{name:"Egypt",currency:"EGP",symbol:"EGP",dateFormat:"dd/MM/yyyy",code:"EG"},{name:"Western Sahara",currency:"MAD",symbol:"MAD",code:"EH"},{name:"Eritrea",currency:"ERN",symbol:"Nfk",code:"ER"},{name:"Spain",currency:"EUR",symbol:"\u20ac",dateFormat:"dd/MM/yyyy",code:"ES"},{name:"Ethiopia",currency:"ETB",symbol:"Br",code:"ET"},{name:"Finland",currency:"EUR",symbol:"\u20ac",dateFormat:"d.M.yyyy",code:"FI"},{name:"Fiji",currency:"FJD",symbol:"FJD",code:"FJ"},{name:"Falkland Islands",currency:"FKP",symbol:"FKP",code:"FK"},{name:"Micronesia",currency:"USD",symbol:"$",code:"FM"},{name:"Faroe Islands",currency:"DKK",symbol:"Dkr",code:"FO"},{name:"France",currency:"EUR",symbol:"\u20ac",dateFormat:"dd/MM/yyyy",code:"FR"},{name:"Gabon",currency:"XAF",symbol:"FCFA",code:"GA"},{name:"United Kingdom",currency:"GBP",symbol:"\xa3",dateFormat:"dd/MM/yyyy",code:"GB"},{name:"Grenada",currency:"XCD",symbol:"XCD",code:"GD"},{name:"Georgia",currency:"GEL",symbol:"GEL",code:"GE"},{name:"French Guiana",currency:"EUR",symbol:"\u20ac",code:"GF"},{name:"Guernsey",currency:"GBP",symbol:"\xa3",code:"GG"},{name:"Ghana",currency:"GHS",symbol:"GH\u20b5",code:"GH"},{name:"Gibraltar",currency:"GIP",symbol:"GIP",code:"GI"},{name:"Greenland",currency:"DKK",symbol:"Dkr",code:"GL"},{name:"Gambia",currency:"GMD",symbol:"GMD",code:"GM"},{name:"Guinea",currency:"GNF",symbol:"FG",code:"GN"},{name:"Guadeloupe",currency:"EUR",symbol:"\u20ac",code:"GP"},{name:"Equatorial Guinea",currency:"XAF",symbol:"FCFA",code:"GQ"},{name:"Greece",currency:"EUR",symbol:"\u20ac",dateFormat:"d/M/yyyy",code:"GR"},{name:"South Georgia and the South Sandwich Islands",currency:"GBP",symbol:"\xa3",code:"GS"},{name:"Guatemala",currency:"GTQ",symbol:"GTQ",dateFormat:"d/MM/yyyy",code:"GT"},{name:"Guam",currency:"USD",symbol:"$",code:"GU"},{name:"Guinea-Bissau",currency:"XOF",symbol:"CFA",code:"GW"},{name:"Guyana",currency:"GYD",symbol:"GYD",code:"GY"},{name:"Hong Kong",currency:"HKD",symbol:"HK$",dateFormat:"yyyy\u5e74M\u6708d\u65e5",code:"HK"},{name:"Heard Island and McDonald Islands",currency:"AUD",symbol:"AU$",code:"HM"},{name:"Honduras",currency:"HNL",symbol:"HNL",dateFormat:"MM-dd-yyyy",code:"HN"},{name:"Croatia",currency:"HRK",symbol:"kn",dateFormat:"dd.MM.yyyy.",code:"HR"},{name:"Haiti",currency:"HTG",symbol:"HTG",code:"HT"},{name:"Hungary",currency:"HUF",symbol:"Ft",dateFormat:"yyyy.MM.dd.",code:"HU"},{name:"Indonesia",currency:"IDR",symbol:"Rp",dateFormat:"dd/MM/yyyy",code:"ID"},{name:"Ireland",currency:"EUR",symbol:"\u20ac",dateFormat:"dd/MM/yyyy",code:"IE"},{name:"Israel",currency:"ILS",symbol:"\u20aa",dateFormat:"dd/MM/yyyy",code:"IL"},{name:"Isle of Man",currency:"GBP",symbol:"\xa3",code:"IM"},{name:"India",currency:"INR",symbol:"Rs",dateFormat:"d/M/yyyy",code:"IN"},{name:"British Indian Ocean Territory",currency:"USD",symbol:"$",code:"IO"},{name:"Iraq",currency:"IQD",symbol:"IQD",dateFormat:"dd/MM/yyyy",code:"IQ"},{name:"Iran",currency:"IRR",symbol:"IRR",code:"IR"},{name:"Iceland",currency:"ISK",symbol:"Ikr",dateFormat:"d.M.yyyy",code:"IS"},{name:"Italy",currency:"EUR",symbol:"\u20ac",dateFormat:"dd/MM/yyyy",code:"IT"},{name:"Jersey",currency:"GBP",symbol:"\xa3",code:"JE"},{name:"Jamaica",currency:"JMD",symbol:"J$",code:"JM"},{name:"Jordan",currency:"JOD",symbol:"JD",dateFormat:"dd/MM/yyyy",code:"JO"},{name:"Japan",currency:"JPY",symbol:"\xa5",dateFormat:"H24.MM.dd",code:"JP"},{name:"Kenya",currency:"KES",symbol:"Ksh",code:"KE"},{name:"Kyrgyzstan",currency:"KGS",symbol:"KGS",code:"KG"},{name:"Cambodia",currency:"KHR",symbol:"KHR",code:"KH"},{name:"Kiribati",currency:"AUD",symbol:"AU$",code:"KI"},{name:"Comoros",currency:"KMF",symbol:"CF",code:"KM"},{name:"Saint Kitts and Nevis",currency:"XCD",symbol:"XCD",code:"KN"},{name:"North Korea",currency:"KPW",symbol:"KPW",code:"KP"},{name:"South Korea",currency:"KRW",symbol:"\u20a9",dateFormat:"yyyy. M. d",code:"KR"},{name:"Kuwait",currency:"KWD",symbol:"KD",dateFormat:"dd/MM/yyyy",code:"KW"},{name:"Cayman Islands",currency:"KYD",symbol:"KYD",code:"KY"},{name:"Kazakhstan",currency:"KZT",symbol:"KZT",code:"KZ"},{name:"Laos",currency:"LAK",symbol:"LAK",code:"LA"},{name:"Lebanon",currency:"LBP",symbol:"LB\xa3",dateFormat:"dd/MM/yyyy",code:"LB"},{name:"Saint Lucia",currency:"XCD",symbol:"XCD",code:"LC"},{name:"Liechtenstein",currency:"CHF",symbol:"CHF",code:"LI"},{name:"Sri Lanka",currency:"LKR",symbol:"SLRs",code:"LK"},{name:"Liberia",currency:"LRD",symbol:"LRD",code:"LR"},{name:"Lesotho",currency:"LSL",symbol:"LSL",code:"LS"},{name:"Lithuania",currency:"EUR",symbol:"\u20ac",dateFormat:"yyyy.M.d",code:"LT"},{name:"Luxembourg",currency:"EUR",symbol:"\u20ac",dateFormat:"dd.MM.yyyy",code:"LU"},{name:"Latvia",currency:"EUR",symbol:"\u20ac",dateFormat:"yyyy.d.M",code:"LV"},{name:"Libya",currency:"LYD",symbol:"LD",dateFormat:"dd/MM/yyyy",code:"LY"},{name:"Morocco",currency:"MAD",symbol:"MAD",dateFormat:"dd/MM/yyyy",code:"MA"},{name:"Monaco",currency:"EUR",symbol:"\u20ac",code:"MC"},{name:"Moldova",currency:"MDL",symbol:"MDL",code:"MD"},{name:"Montenegro",currency:"EUR",symbol:"\u20ac",dateFormat:"d.M.yyyy.",code:"ME"},{name:"Saint Martin",currency:"EUR",symbol:"\u20ac",code:"MF"},{name:"Madagascar",currency:"MGA",symbol:"MGA",code:"MG"},{name:"Marshall Islands",currency:"USD",symbol:"$",code:"MH"},{name:"Macedonia",currency:"MKD",symbol:"MKD",dateFormat:"d.M.yyyy",code:"MK"},{name:"Mali",currency:"XOF",symbol:"CFA",code:"ML"},{name:"Myanmar",currency:"MMK",symbol:"MMK",code:"MM"},{name:"Mongolia",currency:"MNT",symbol:"MNT",code:"MN"},{name:"Macao",currency:"MOP",symbol:"MOP$",code:"MO"},{name:"Northern Mariana Islands",currency:"USD",symbol:"$",code:"MP"},{name:"Martinique",currency:"EUR",symbol:"\u20ac",code:"MQ"},{name:"Mauritania",currency:"MRU",symbol:"MRU",code:"MR"},{name:"Montserrat",currency:"XCD",symbol:"XCD",code:"MS"},{name:"Malta",currency:"EUR",symbol:"\u20ac",dateFormat:"dd/MM/yyyy",code:"MT"},{name:"Mauritius",currency:"MUR",symbol:"MURs",code:"MU"},{name:"Maldives",currency:"MVR",symbol:"MVR",code:"MV"},{name:"Malawi",currency:"MWK",symbol:"MWK",code:"MW"},{name:"Mexico",currency:"MXN",symbol:"MX$",dateFormat:"d/MM/yyyy",code:"MX"},{name:"Malaysia",currency:"MYR",symbol:"RM",dateFormat:"dd/MM/yyyy",code:"MY"},{name:"Mozambique",currency:"MZN",symbol:"MTn",code:"MZ"},{name:"Namibia",currency:"NAD",symbol:"N$",code:"NA"},{name:"New Caledonia",currency:"XPF",symbol:"XPF",code:"NC"},{name:"Niger",currency:"XOF",symbol:"CFA",code:"NE"},{name:"Norfolk Island",currency:"AUD",symbol:"AU$",code:"NF"},{name:"Nigeria",currency:"NGN",symbol:"\u20a6",code:"NG"},{name:"Nicaragua",currency:"NIO",symbol:"C$",dateFormat:"MM-dd-yyyy",code:"NI"},{name:"Netherlands",currency:"EUR",symbol:"\u20ac",dateFormat:"d-M-yyyy",code:"NL"},{name:"Norway",currency:"NOK",symbol:"Nkr",dateFormat:"dd.MM.yyyy",code:"NO"},{name:"Nepal",currency:"NPR",symbol:"NPRs",code:"NP"},{name:"Nauru",currency:"AUD",symbol:"AU$",code:"NR"},{name:"Niue",currency:"NZD",symbol:"NZ$",code:"NU"},{name:"New Zealand",currency:"NZD",symbol:"NZ$",dateFormat:"d/MM/yyyy",code:"NZ"},{name:"Oman",currency:"OMR",symbol:"OMR",dateFormat:"dd/MM/yyyy",code:"OM"},{name:"Panama",currency:"PAB",symbol:"B/.",dateFormat:"MM/dd/yyyy",code:"PA"},{name:"Peru",currency:"PEN",symbol:"S/.",dateFormat:"dd/MM/yyyy",code:"PE"},{name:"French Polynesia",currency:"XPF",symbol:"XPF",code:"PF"},{name:"Papua New Guinea",currency:"PGK",symbol:"PGK",code:"PG"},{name:"Philippines",currency:"PHP",symbol:"\u20b1",dateFormat:"M/d/yyyy",code:"PH"},{name:"Pakistan",currency:"PKR",symbol:"PKRs",code:"PK"},{name:"Poland",currency:"PLN",symbol:"z\u0142",dateFormat:"dd.MM.yyyy",code:"PL"},{name:"Saint Pierre and Miquelon",currency:"EUR",symbol:"\u20ac",code:"PM"},{name:"Pitcairn",currency:"NZD",symbol:"NZ$",code:"PN"},{name:"Puerto Rico",currency:"USD",symbol:"$",dateFormat:"MM-dd-yyyy",code:"PR"},{name:"Palestinian Territory",currency:"ILS",symbol:"\u20aa",code:"PS"},{name:"Portugal",currency:"EUR",symbol:"\u20ac",dateFormat:"dd-MM-yyyy",code:"PT"},{name:"Palau",currency:"USD",symbol:"$",code:"PW"},{name:"Paraguay",currency:"PYG",symbol:"\u20b2",dateFormat:"dd/MM/yyyy",code:"PY"},{name:"Qatar",currency:"QAR",symbol:"QR",dateFormat:"dd/MM/yyyy",code:"QA"},{name:"Reunion",currency:"EUR",symbol:"\u20ac",code:"RE"},{name:"Romania",currency:"RON",symbol:"RON",dateFormat:"dd.MM.yyyy",code:"RO"},{name:"Serbia",currency:"RSD",symbol:"din.",dateFormat:"d.M.yyyy.",code:"RS"},{name:"Russia",currency:"RUB",symbol:"RUB",dateFormat:"dd.MM.yyyy",code:"RU"},{name:"Rwanda",currency:"RWF",symbol:"RWF",code:"RW"},{name:"Saudi Arabia",currency:"SAR",symbol:"SR",dateFormat:"dd/MM/yyyy",code:"SA"},{name:"Solomon Islands",currency:"SBD",symbol:"SBD",code:"SB"},{name:"Seychelles",currency:"SCR",symbol:"SCR",code:"SC"},{name:"Sudan",currency:"SDG",symbol:"SDG",dateFormat:"dd/MM/yyyy",code:"SD"},{name:"Sweden",currency:"SEK",symbol:"Skr",dateFormat:"yyyy-MM-dd",code:"SE"},{name:"Singapore",currency:"SGD",symbol:"S$",dateFormat:"M/d/yyyy",code:"SG"},{name:"Saint Helena",currency:"SHP",symbol:"SHP",code:"SH"},{name:"Slovenia",currency:"EUR",symbol:"\u20ac",dateFormat:"d.M.yyyy",code:"SI"},{name:"Svalbard and Jan Mayen",currency:"NOK",symbol:"Nkr",code:"SJ"},{name:"Slovakia",currency:"EUR",symbol:"\u20ac",dateFormat:"d.M.yyyy",code:"SK"},{name:"Sierra Leone",currency:"SLL",symbol:"SLL",code:"SL"},{name:"San Marino",currency:"EUR",symbol:"\u20ac",code:"SM"},{name:"Senegal",currency:"XOF",symbol:"CFA",code:"SN"},{name:"Somalia",currency:"SOS",symbol:"Ssh",code:"SO"},{name:"Suriname",currency:"SRD",symbol:"SRD",code:"SR"},{name:"South Sudan",currency:"SSP",symbol:"SSP",code:"SS"},{name:"Sao Tome and Principe",currency:"STD",symbol:"STD",code:"ST"},{name:"El Salvador",currency:"USD",symbol:"$",dateFormat:"MM-dd-yyyy",code:"SV"},{name:"Sint Maarten",currency:"ANG",symbol:"ANG",code:"SX"},{name:"Syria",currency:"SYP",symbol:"SY\xa3",dateFormat:"dd/MM/yyyy",code:"SY"},{name:"Swaziland",currency:"SZL",symbol:"SZL",code:"SZ"},{name:"Turks and Caicos Islands",currency:"USD",symbol:"$",code:"TC"},{name:"Chad",currency:"XAF",symbol:"FCFA",code:"TD"},{name:"French Southern Territories",currency:"EUR",symbol:"\u20ac",code:"TF"},{name:"Togo",currency:"XOF",symbol:"CFA",code:"TG"},{name:"Thailand",currency:"THB",symbol:"\u0e3f",dateFormat:"\u0e53/\u0e56/\u0e52\u0e55\u0e55\u0e55",code:"TH"},{name:"Tajikistan",currency:"TJS",symbol:"TJS",code:"TJ"},{name:"Tokelau",currency:"NZD",symbol:"NZ$",code:"TK"},{name:"East Timor",currency:"USD",symbol:"$",code:"TL"},{name:"Turkmenistan",currency:"TMT",symbol:"TMT",code:"TM"},{name:"Tunisia",currency:"TND",symbol:"DT",dateFormat:"dd/MM/yyyy",code:"TN"},{name:"Tonga",currency:"TOP",symbol:"T$",code:"TO"},{name:"Turkey",currency:"TRY",symbol:"TL",dateFormat:"dd.MM.yyyy",code:"TR"},{name:"Trinidad and Tobago",currency:"TTD",symbol:"TT$",code:"TT"},{name:"Tuvalu",currency:"AUD",symbol:"AU$",code:"TV"},{name:"Taiwan",currency:"TWD",symbol:"NT$",dateFormat:"yyyy/M/d",code:"TW"},{name:"Tanzania",currency:"TZS",symbol:"TSh",code:"TZ"},{name:"Ukraine",currency:"UAH",symbol:"\u20b4",dateFormat:"dd.MM.yyyy",code:"UA"},{name:"Uganda",currency:"UGX",symbol:"USh",code:"UG"},{name:"United States Minor Outlying Islands",currency:"USD",symbol:"$",code:"UM"},{name:"United States",currency:"USD",symbol:"$",dateFormat:"M/d/yyyy",code:"US"},{name:"Uruguay",currency:"UYU",symbol:"$U",dateFormat:"dd/MM/yyyy",code:"UY"},{name:"Uzbekistan",currency:"UZS",symbol:"UZS",code:"UZ"},{name:"Vatican",currency:"EUR",symbol:"\u20ac",code:"VA"},{name:"Saint Vincent and the Grenadines",currency:"XCD",symbol:"XCD",code:"VC"},{name:"Venezuela",currency:"VEF",symbol:"Bs.F.",dateFormat:"dd/MM/yyyy",code:"VE"},{name:"British Virgin Islands",currency:"USD",symbol:"$",code:"VG"},{name:"U.S. Virgin Islands",currency:"USD",symbol:"$",code:"VI"},{name:"Vietnam",currency:"VND",symbol:"\u20ab",dateFormat:"dd/MM/yyyy",code:"VN"},{name:"Vanuatu",currency:"VUV",symbol:"VUV",code:"VU"},{name:"Wallis and Futuna",currency:"XPF",symbol:"XPF",code:"WF"},{name:"Samoa",currency:"WST",symbol:"WST",code:"WS"},{name:"Kosovo",currency:"EUR",symbol:"\u20ac",code:"XK"},{name:"Yemen",currency:"YER",symbol:"YR",dateFormat:"dd/MM/yyyy",code:"YE"},{name:"Mayotte",currency:"EUR",symbol:"\u20ac",code:"YT"},{name:"South Africa",currency:"ZAR",symbol:"R",dateFormat:"yyyy/MM/dd",code:"ZA"},{name:"Zambia",currency:"ZMW",symbol:"ZK",code:"ZM"},{name:"Zimbabwe",currency:"ZWL",symbol:"ZWL",code:"ZW"}];var vn=e=>{var a;let{open:t,onClose:l,handleAlert:o,addressData:c}=e;const{billingAddressesDispatch:s}=I(),[m,u]=Object(n.useState)(!1),p=le(async e=>{let a;c.id?(await st(Object(i.a)(Object(i.a)({},e),{},{id:c.id})),s({type:d.UPDATE_ADDRESS,value:Object(i.a)(Object(i.a)({},e),{},{id:c.id}),addressId:c.id})):(a=await st(e),s({type:d.ADD_ADDRESS,value:Object(i.a)(Object(i.a)({},e),{},{id:a.id})})),l()},u,o),g=Object(at.e)({initialValues:{firstname:(null===c||void 0===c?void 0:c.firstname)||"",lastname:(null===c||void 0===c?void 0:c.lastname)||"",phone:(null===c||void 0===c?void 0:c.phone)||"",address_line1:(null===c||void 0===c?void 0:c.address_line1)||"",address_line2:(null===c||void 0===c?void 0:c.address_line2)||"",address_state:(null===c||void 0===c?void 0:c.address_state)||"",address_zip:(null===c||void 0===c?void 0:c.address_zip)||"",address_city:(null===c||void 0===c?void 0:c.address_city)||"",address_country:(null===c||void 0===c?void 0:c.address_country)||"FR",is_default:null!==(a=null===c||void 0===c?void 0:c.is_default)&&void 0!==a&&a},enableReinitialize:!0,validationSchema:tt.c({firstname:tt.d().required("First name is required"),lastname:tt.d().required("Last name is required"),address_line1:tt.d().required("Street address is required"),address_city:tt.d().required("City is required"),address_state:tt.d().required("State is required"),address_zip:tt.d().required("Postal code is required"),phone:tt.d(),address_country:tt.d().required("Country is required"),is_default:tt.a()}),onSubmit:p});return r.a.createElement(Ne.a,{open:t,onClose:l,fullWidth:!0,maxWidth:"sm"},r.a.createElement(Te.a,null,(null===c||void 0===c?void 0:c.id)?"Edit Billing Address":"Add New Billing Address"),r.a.createElement("form",{onSubmit:g.handleSubmit},r.a.createElement(je.a,{dividers:!0},r.a.createElement(aa.a,{container:!0,spacing:2},r.a.createElement(aa.a,{item:!0,xs:12,md:6},r.a.createElement($a.a,Object.assign({size:"small",label:"First Name",variant:"outlined",fullWidth:!0},g.getFieldProps("firstname"),{error:g.touched.firstname&&Boolean(g.errors.firstname),helperText:g.touched.firstname&&g.errors.firstname}))),r.a.createElement(aa.a,{item:!0,xs:12,md:6},r.a.createElement($a.a,Object.assign({size:"small",label:"Last Name",variant:"outlined",fullWidth:!0},g.getFieldProps("lastname"),{error:g.touched.lastname&&Boolean(g.errors.lastname),helperText:g.touched.lastname&&g.errors.lastname}))),r.a.createElement(aa.a,{item:!0,xs:12},r.a.createElement($a.a,Object.assign({size:"small",label:"Street Address 1",variant:"outlined",fullWidth:!0},g.getFieldProps("address_line1"),{error:g.touched.address_line1&&Boolean(g.errors.address_line1),helperText:g.touched.address_line1&&g.errors.address_line1}))),r.a.createElement(aa.a,{item:!0,xs:12},r.a.createElement($a.a,Object.assign({size:"small",label:"Street Address 2 (optional)",variant:"outlined",fullWidth:!0},g.getFieldProps("address_line2")))),r.a.createElement(aa.a,{item:!0,xs:12,md:6},r.a.createElement($a.a,Object.assign({size:"small",label:"Postal Code",variant:"outlined",fullWidth:!0},g.getFieldProps("address_zip"),{error:g.touched.address_zip&&Boolean(g.errors.address_zip),helperText:g.touched.address_zip&&g.errors.address_zip}))),r.a.createElement(aa.a,{item:!0,xs:12,md:6},r.a.createElement($a.a,Object.assign({size:"small",label:"City",variant:"outlined",fullWidth:!0},g.getFieldProps("address_city"),{error:g.touched.address_city&&Boolean(g.errors.address_city),helperText:g.touched.address_city&&g.errors.address_city}))),r.a.createElement(aa.a,{item:!0,xs:12,md:6},r.a.createElement($a.a,Object.assign({size:"small",label:"State",variant:"outlined",fullWidth:!0},g.getFieldProps("address_state"),{error:g.touched.address_state&&Boolean(g.errors.address_state),helperText:g.touched.address_state&&g.errors.address_state}))),r.a.createElement(aa.a,{item:!0,xs:12,md:6},r.a.createElement($a.a,Object.assign({size:"small",label:"Phone",variant:"outlined",fullWidth:!0},g.getFieldProps("phone"),{error:g.touched.phone&&Boolean(g.errors.phone),helperText:g.touched.phone&&g.errors.phone}))),r.a.createElement(aa.a,{item:!0,xs:12,md:6},r.a.createElement(pn.a,{size:"small",variant:"outlined",fullWidth:!0,error:g.touched.address_country&&Boolean(g.errors.address_country)},r.a.createElement(gn.a,null,"Country"),r.a.createElement(yn.a,{name:"address_country",value:g.values.address_country,onChange:g.handleChange,onBlur:g.handleBlur,label:"Country"},hn.map(e=>r.a.createElement(Nt.a,{key:e.code,value:e.code},e.name))),g.touched.address_country&&g.errors.address_country&&r.a.createElement(En.a,null,g.errors.address_country))),r.a.createElement(aa.a,{item:!0,xs:12},r.a.createElement(bn.a,{control:r.a.createElement(zt.a,{name:"is_default",color:"primary",checked:g.values.is_default,onChange:g.handleChange}),label:"Set as default billing address"})))),r.a.createElement(ke.a,null,r.a.createElement(Ae.a,{onClick:l,color:"secondary",disabled:m},"Cancel"),r.a.createElement(Ae.a,{type:"submit",color:"primary",variant:"contained",disabled:m},m?r.a.createElement(Xe.a,{size:20}):"Submit"))))};const fn=["className","handleAlert"],Cn=Object(Ee.a)(()=>({root:{padding:"16px",margin:"16px 0",borderRadius:"8px",boxShadow:"0 2px 4px rgba(0, 0, 0, 0.1)"},centeredMessage:{textAlign:"center",marginTop:"16px"},headerActions:{display:"flex",justifyContent:"space-between",alignItems:"center"},addressCard:{padding:"10px",borderRadius:"8px",boxShadow:"0 2px 4px rgba(0, 0, 0, 0.1)",position:"relative",display:"flex",justifyContent:"space-between",alignItems:"center"}}));var Sn=e=>{const{className:a,handleAlert:t}=e,l=Object(Se.a)(e,fn),o=Cn(),[c,s]=Object(n.useState)(!1),{billingAddressesDispatch:i,billingAddressesState:m}=I(),[u,p]=Object(n.useState)(!1),[g,y]=Object(n.useState)(!1),[E,b]=Object(n.useState)(null),[h,v]=Object(n.useState)(null),f=()=>{p(!0)},C=()=>{y(!1),v(null)};return Object(n.useEffect)(()=>{le(async()=>{const e=await it();await i({type:d.SET_ADDRESSES,value:e})},s,t)()},[]),r.a.createElement(r.a.Fragment,null,r.a.createElement(Ja.a,Object.assign({sx:{height:"100%"}},l,{className:Object(xe.a)(o.root,a)}),r.a.createElement(Ft.a,{title:r.a.createElement("div",{className:o.headerActions},r.a.createElement("span",null,"Billing Address"),r.a.createElement(Ae.a,{variant:"contained",color:"primary",onClick:f},"Add Address"))}),r.a.createElement(Qa.a,null,c?r.a.createElement(Je,{size:20}):0===(null===m||void 0===m?void 0:m.length)?r.a.createElement(We.a,{variant:"body1",className:o.centeredMessage},"No billing addresses available."):r.a.createElement(aa.a,{container:!0,spacing:3},null===m||void 0===m?void 0:m.map((e,a)=>r.a.createElement(aa.a,{style:{display:"flex",alignItems:"center"},item:!0},r.a.createElement(Ja.a,{variant:"outlined",className:o.addressCard},r.a.createElement(Qa.a,null,r.a.createElement(Le.a,{style:{color:"blue"},"aria-label":"edit",className:o.editButton,onClick:()=>(e=>{b(e),f()})(e)},r.a.createElement(sn.a,null)),r.a.createElement(Le.a,{style:{color:"red"},"aria-label":"delete",className:o.deleteButton,onClick:()=>{return a=e.id,v(a),void y(!0);var a}},r.a.createElement(tn.a,null)),r.a.createElement(We.a,{align:"center",variant:"body1"},e.firstname," ",e.lastname),r.a.createElement(We.a,{align:"center",variant:"body2"},e.phone),r.a.createElement(We.a,{align:"center",variant:"body2"},e.address_line1),r.a.createElement(We.a,{align:"center",variant:"body2"},e.address_city),r.a.createElement(We.a,{align:"center",variant:"body2"}," ",e.address_zip," ",e.address_country)))))))),r.a.createElement(vn,{handleAlert:t,open:u,onClose:()=>{p(!1),b(null)},addressData:E}),r.a.createElement(Ne.a,{open:g,onClose:C},r.a.createElement(Te.a,null,"Confirm Delete"),r.a.createElement(je.a,null,r.a.createElement(wt.a,null,"Are you sure you want to delete this address?")),r.a.createElement(ke.a,null,r.a.createElement(Ae.a,{onClick:C,color:"primary"},"Cancel"),r.a.createElement(Ae.a,{onClick:async()=>{console.log("Delete address with ID:",h),await dt(h),await i({type:d.DELETE_SOURCE,addressId:h}),C()},color:"secondary"},"Delete"))))},xn=t(92);const wn=q+"/payments";B.a.defaults.headers.common.Authorization=Q();const On=async e=>{try{return(await B.a.get("".concat(wn,"/subscription-info/").concat(e))).data}catch(a){z(a)}},An=async(e,a,t,n)=>{try{return(await B.a.post("".concat(wn,"/confirm-payment"),{customerId:e,paymentMethod:a,priceId:t,preview:n})).data}catch(r){z(r)}},Tn=async e=>{try{return(await B.a.get("".concat(wn,"/methods/").concat(e))).data}catch(a){z(a)}},jn=async(e,a)=>{try{return(await B.a.post("".concat(wn,"/set-default-method/").concat(e),{customerId:e,paymentMethodId:a})).data}catch(t){z(t)}},kn=e=>{let{invoice:a,isMobile:t}=e;return r.a.createElement(Wt.a,null,r.a.createElement(_t.a,null,(n=a.amount_paid,l=a.currency,"".concat((n/100).toFixed(2)," ").concat(l.toUpperCase()))),r.a.createElement(_t.a,null,a.currency.toUpperCase()),r.a.createElement(_t.a,null,a.status.charAt(0).toUpperCase()+a.status.slice(1)),r.a.createElement(_t.a,null,(e=>{const a=e.lines.data.find(e=>e.plan&&e.plan.interval);return a?a.plan.interval.charAt(0).toUpperCase()+a.plan.interval.slice(1):"\u2014"})(a)),r.a.createElement(_t.a,null,a.number),r.a.createElement(_t.a,null,(e=>{const a=new Date(1e3*e);return"".concat(a.toLocaleDateString()," ").concat(a.toLocaleTimeString())})(a.created)),!t&&r.a.createElement(_t.a,null,r.a.createElement(pa.a,{href:a.invoice_pdf,target:"_blank",rel:"noopener"},"Download PDF")));var n,l};var Nn=e=>{let{user:a,handleAlert:t}=e;const[l,o]=Object(n.useState)([]),[c,s]=Object(n.useState)(!1),i=Object(he.a)("(max-width:600px)");return Object(n.useEffect)(()=>{le(async()=>{const e=await async function(e){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10;try{return(await B.a.get("".concat(wn,"/invoices/").concat(e,"?limit=").concat(a),{headers:{"Content-Type":"application/json"}})).data}catch(t){z(t)}}(a.CusId);o(e)},s,t)()},[]),r.a.createElement(mt.a,{style:{padding:"16px",marginBottom:"16px"}},r.a.createElement(Bt.a,{style:{overflowX:"auto"}},r.a.createElement(Lt.a,null,r.a.createElement(Ut.a,null,r.a.createElement(Wt.a,null,r.a.createElement(_t.a,null,"Amount Paid"),r.a.createElement(_t.a,null,"Currency"),r.a.createElement(_t.a,null,"Status"),r.a.createElement(_t.a,null,"Frequency"),r.a.createElement(_t.a,null,"Invoice Number"),r.a.createElement(_t.a,null,"Created"),!i&&r.a.createElement(_t.a,null,"Actions"))),r.a.createElement(qt.a,null,l.map(e=>r.a.createElement(kn,{key:e.id,invoice:e,isMobile:i}))))),c&&r.a.createElement(Je,{size:20}))},Dn=t(466),In=t.n(Dn),Mn=t(467),Pn=t.n(Mn),Rn=t(778),Fn=t(779),Bn=t(780),Ln=t(781),Un=t(773),Wn=t(262),_n=t.n(Wn),zn=t(263),qn=t.n(zn),Gn=t(264),Hn=t.n(Gn),Vn=t(774),Kn=t(775),Yn=t(776);const Zn={visa:_n.a,mastercard:qn.a,amex:Hn.a},Xn=Object(Ee.a)(e=>({defaultCard:{padding:e.spacing(1.5),marginBottom:e.spacing(1),borderRadius:e.spacing(1),border:"1px solid ".concat(e.palette.divider),position:"relative",transition:"all 0.2s ease","&:hover":{boxShadow:e.shadows[3]}},defaultBadge:{position:"absolute",top:-6,right:-6,backgroundColor:e.palette.success.main,color:"white",borderRadius:"50%",width:20,height:20,display:"flex",alignItems:"center",justifyContent:"center",fontSize:"0.75rem"},smallAvatar:{width:32,height:20,borderRadius:3},denseContent:{padding:"8px !important",position:"relative"},paymentInfoBox:{padding:e.spacing(1),backgroundColor:e.palette.grey[100],borderRadius:e.spacing(1),border:"1px solid ".concat(e.palette.primary.main)},actionMenu:{"& .MuiMenuItem-root":{fontSize:"0.875rem",padding:e.spacing(1,2)},"& .MuiListItemIcon-root":{minWidth:36}}})),Jn=e=>{var a,t;let{method:l,isDefault:o,onSetDefault:c,onDelete:s,compact:i=!1}=e;const d=Xn(),[m,u]=Object(n.useState)(!1),[p,g]=Object(n.useState)(null),[y,E]=Object(n.useState)(!1),b=()=>g(null);return r.a.createElement(r.a.Fragment,null,r.a.createElement(Ja.a,{className:o?"".concat(d.paymentInfoBox," ").concat(d.defaultCard):d.defaultCard},r.a.createElement(Qa.a,{className:d.denseContent},o&&r.a.createElement(ve.a,{className:d.defaultBadge},r.a.createElement(Un.a,{fontSize:"inherit"})),r.a.createElement(ve.a,{display:"flex",alignItems:"center",justifyContent:"space-between",gap:1.5},r.a.createElement(ve.a,{display:"flex",alignItems:"center",gap:1.5,flex:1},r.a.createElement(Ue.a,{alt:null===(a=l.card)||void 0===a?void 0:a.brand,src:Zn[null===(t=l.card)||void 0===t?void 0:t.brand],className:d.smallAvatar}),r.a.createElement(ve.a,{flex:1},r.a.createElement(We.a,{variant:"body1",style:{fontWeight:500}},"\u2022\u2022\u2022\u2022 ",l.card.last4),r.a.createElement(We.a,{variant:"caption",color:"textSecondary"},"Exp: ",l.card.exp_month,"/",l.card.exp_year))),!i&&r.a.createElement(r.a.Fragment,null,!o&&r.a.createElement(Le.a,{size:"small",onClick:e=>g(e.currentTarget)},r.a.createElement(Vn.a,null)),r.a.createElement(ze.a,{anchorEl:p,open:Boolean(p),onClose:b,className:d.actionMenu,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"}},!o&&r.a.createElement(Nt.a,{onClick:async()=>{b();try{u(!0),await c(l.id)}finally{u(!1)}},disabled:m},r.a.createElement(Dt.a,null,r.a.createElement(Kn.a,{color:"primary"})),r.a.createElement(ea.a,{primary:m?"Updating...":"Set as Default"})),!o&&r.a.createElement(Nt.a,{onClick:()=>{b(),E(!0)}},r.a.createElement(Dt.a,null,r.a.createElement(Yn.a,{color:"error"})),r.a.createElement(ea.a,{primary:"Delete"}))))))),r.a.createElement(Ne.a,{open:y,onClose:()=>E(!1),"aria-labelledby":"delete-dialog-title"},r.a.createElement(Te.a,{id:"delete-dialog-title"},"Confirm Delete"),r.a.createElement(je.a,null,r.a.createElement(wt.a,null,"Are you sure you want to delete this payment method ending with"," ",r.a.createElement("strong",null,l.card.last4),"?")),r.a.createElement(ke.a,null,r.a.createElement(Ae.a,{onClick:()=>E(!1),color:"default"},"Cancel"),r.a.createElement(Ae.a,{onClick:async()=>{E(!1),u(!0);try{await s(l.id)}finally{u(!1)}},color:"secondary",autoFocus:!0},"Delete"))))};var Qn=t(777);const $n=Object(Ee.a)(e=>({defaultCard:{padding:e.spacing(1.5),marginBottom:e.spacing(1),borderRadius:e.spacing(1),border:"1px solid ".concat(e.palette.divider),position:"relative",transition:"all 0.2s ease","&:hover":{boxShadow:e.shadows[3]}},defaultBadge:{position:"absolute",top:-6,right:-6,backgroundColor:e.palette.success.main,color:"white",borderRadius:"50%",width:20,height:20,display:"flex",alignItems:"center",justifyContent:"center",fontSize:"0.75rem"},denseContent:{padding:"8px !important",position:"relative"},paymentInfoBox:{padding:e.spacing(1),backgroundColor:e.palette.grey[100],borderRadius:e.spacing(1),border:"1px solid ".concat(e.palette.primary.main)},actionMenu:{"& .MuiMenuItem-root":{fontSize:"0.875rem",padding:e.spacing(1,2)},"& .MuiListItemIcon-root":{minWidth:36}}})),er=e=>{let{address:a,isDefault:t,onSetDefault:l,onEdit:o,onDelete:c,compact:s=!1}=e;const i=$n(),[d,m]=Object(n.useState)(!1),[u,p]=Object(n.useState)(!1),[g,y]=Object(n.useState)(null),E=()=>y(null);return r.a.createElement(r.a.Fragment,null,r.a.createElement(Ja.a,{className:t?"".concat(i.paymentInfoBox," ").concat(i.defaultCard):i.defaultCard},r.a.createElement(Qa.a,{className:i.denseContent},t&&r.a.createElement(ve.a,{className:i.defaultBadge},r.a.createElement(Un.a,{fontSize:"inherit"})),r.a.createElement(ve.a,{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},r.a.createElement(ve.a,{flex:1},r.a.createElement(We.a,{variant:"body1",style:{fontWeight:500},gutterBottom:!0},a.firstname," ",a.lastname),r.a.createElement(We.a,{variant:"body2",color:"textSecondary",style:{fontSize:"0.875rem"}},a.address_line1,a.address_line2?", ".concat(a.address_line2):"",","," ",a.address_city,", ",a.address_state," ",a.address_zip,", ",a.address_country)),!s&&r.a.createElement(r.a.Fragment,null,r.a.createElement(Le.a,{size:"small",onClick:e=>y(e.currentTarget)},r.a.createElement(Vn.a,null)),r.a.createElement(ze.a,{anchorEl:g,open:Boolean(g),onClose:E,className:i.actionMenu,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"}},!t&&r.a.createElement(Nt.a,{onClick:async()=>{E();try{m(!0),await l(a.id)}finally{m(!1)}},disabled:d},r.a.createElement(Dt.a,null,r.a.createElement(Kn.a,{color:"primary"})),r.a.createElement(ea.a,{primary:d?"Updating...":"Set as Default"})),r.a.createElement(Nt.a,{onClick:()=>{E(),o(a)}},r.a.createElement(Dt.a,null,r.a.createElement(Qn.a,{color:"action"})),r.a.createElement(ea.a,{primary:"Edit Address"})),!t&&r.a.createElement(Nt.a,{onClick:()=>{E(),p(!0)}},r.a.createElement(Dt.a,null,r.a.createElement(Yn.a,{color:"error"})),r.a.createElement(ea.a,{primary:"Delete"}))))))),r.a.createElement(Ne.a,{open:u,onClose:()=>p(!1),"aria-labelledby":"confirm-delete-title"},r.a.createElement(Te.a,{id:"confirm-delete-title"},"Delete Address"),r.a.createElement(je.a,null,r.a.createElement(wt.a,null,"Are you sure you want to delete this address? This action cannot be undone.")),r.a.createElement(ke.a,null,r.a.createElement(Ae.a,{onClick:()=>p(!1),color:"primary"},"Cancel"),r.a.createElement(Ae.a,{onClick:async()=>{p(!1),await c(a.id)},color:"secondary",autoFocus:!0},"Delete"))))},ar=Object(Ee.a)(e=>({defaultCard:{padding:e.spacing(1.5),marginBottom:e.spacing(1),borderRadius:e.spacing(1),border:"1px solid ".concat(e.palette.divider),position:"relative",transition:"all 0.2s ease"},summaryRow:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:e.spacing(.75,0),fontSize:"0.875rem"},totalRow:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:e.spacing(1.5,0),borderTop:"2px solid ".concat(e.palette.divider),marginTop:e.spacing(1.5),fontWeight:600}})),tr=e=>{let{data:a}=e;const t=ar();if(!a||!a.line_item)return null;const n=a.line_item,l=e=>{return t=e,n=a.currency,"number"===typeof t&&n?(t/100).toLocaleString(void 0,{style:"currency",currency:n.toUpperCase()}):"N/A";var t,n},o=(e,a,n)=>r.a.createElement(ve.a,{className:t.summaryRow},r.a.createElement(ve.a,null,r.a.createElement(We.a,{variant:"body2"},e),n&&r.a.createElement(We.a,{variant:"caption",color:"textSecondary"},n)),r.a.createElement(We.a,{variant:"body2"},a));return r.a.createElement(ve.a,{className:t.defaultCard},r.a.createElement(We.a,{variant:"h6",fontWeight:600,gutterBottom:!0,color:"primary"},"Order Summary"),n.description&&o("Description:",n.description),void 0!==n.quantity&&o("Quantity:",n.quantity),void 0!==n.unit_price&&o("Unit Price:",l(n.unit_price)),void 0!==n.credit&&0!==n.credit&&o("Credit:",l(n.credit),"The unused amount carried over from your previous plan."),void 0!==n.subtotal_after_proration&&0!==n.subtotal_after_proration&&o("Subtotal After Proration:",l(n.subtotal_after_proration),"Adjusted subtotal after accounting for proration."),void 0!==n.tax_rate&&o("Tax (".concat(n.tax_rate,"%):"),l(n.tax_amount||0),"Calculated tax based on your billing address."),void 0!==n.applied_from_balance&&0!==n.applied_from_balance&&o("Applied from Balance:",l(n.applied_from_balance),"Amount deducted from your existing balance."),void 0!==n.credited_to_customer_balance&&0!==n.credited_to_customer_balance&&o("Credited to Balance:",l(n.credited_to_customer_balance),"Excess amount credited back to your balance."),void 0!==n.total&&r.a.createElement(ve.a,{className:t.totalRow},r.a.createElement(ve.a,null,r.a.createElement(We.a,{variant:"body1",fontWeight:600},"Total:"),r.a.createElement(We.a,{variant:"caption",color:"textSecondary"},"Final amount you need to pay.")),r.a.createElement(We.a,{variant:"body1",fontWeight:600,color:"primary"},l(n.total))))},nr={visa:_n.a,mastercard:qn.a,amex:Hn.a},rr=Object(Ee.a)(e=>({container:{padding:e.spacing(2),maxWidth:1200,margin:"0 auto"},section:{padding:e.spacing(1.5),borderRadius:e.spacing(1.5),backgroundColor:e.palette.background.paper,boxShadow:e.shadows[1],border:"1px solid ".concat(e.palette.divider),height:"fit-content"},sectionHeader:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:e.spacing(1),paddingBottom:e.spacing(.5),borderBottom:"1px solid ".concat(e.palette.divider)},defaultCard:{padding:e.spacing(1.5),marginBottom:e.spacing(1),borderRadius:e.spacing(1),border:"1px solid ".concat(e.palette.divider),position:"relative",transition:"all 0.2s ease"},smallAvatar:{width:32,height:20,borderRadius:3},paymentInfoBox:{padding:e.spacing(1),backgroundColor:e.palette.grey[20],borderRadius:e.spacing(1),border:"1px solid ".concat(e.palette.primary.main)},changeLink:{color:e.palette.primary.main,cursor:"pointer",display:"flex",alignItems:"center",marginTop:e.spacing(1),fontSize:"0.875rem",fontWeight:500}}));function lr(e){var a,t,l,o;let{onAdd:s,onAddressAdd:i,user:m,priceId:u,isSelectable:p,handleAlert:g,editingAddress:y,setEditingAddress:E}=e;const{paymentMethodsState:b,paymentMethodsDispatch:h}=I(),{billingAddressesState:v,billingAddressesDispatch:f}=I(),[C,S]=Object(n.useState)(!1),[x,w]=Object(n.useState)(!1),[O,A]=Object(n.useState)(null),[T,j]=Object(n.useState)(!1),[k,N]=Object(n.useState)(null),[D,M]=Object(n.useState)(!1),[P,R]=Object(n.useState)(!1),F=rr(),L=Object(c.g)();Object(n.useEffect)(()=>{le(async()=>{const[e,a]=await Promise.all([Tn(m.CusId),it()]);h({type:d.SET_METHODS,value:e.methods}),f({type:d.SET_ADDRESSES,value:a}),A(e.default)},w,g)()},[m.CusId]);const U=le(async()=>{if(!p||!u)return;if(!O)return void g(!0,"Please set a default payment method","warning");if(!q)return void g(!0,"Please set a default billing address","warning");const e=await An(m.CusId,O,u,!0);N(e),j(!0)},S,g),W=le(async()=>{const e=await An(m.CusId,O,u,!1);e.success?(g(!0,"Payment successful!","success"),j(!1),L.push({pathname:"/plan",state:{upgradeSuccess:!0}})):g(!0,e.error||"Payment failed","error")},S,g),_=null===b||void 0===b?void 0:b.find(e=>e.id===O),q=v.find(e=>e.is_default);return r.a.createElement(ve.a,{className:F.container},r.a.createElement(aa.a,{container:!0,alignItems:"center",spacing:1},r.a.createElement(aa.a,{item:!0},r.a.createElement(Le.a,{onClick:()=>L.goBack(),color:"primary"},r.a.createElement(Rn.a,null))),r.a.createElement(aa.a,{item:!0},r.a.createElement(We.a,{variant:"h5",style:{fontWeight:300},gutterBottom:!0,color:"primary"},"Payment & Billing Information"))),r.a.createElement(aa.a,{container:!0,spacing:2},r.a.createElement(aa.a,{item:!0,xs:12,className:F.defaultCard},r.a.createElement(ve.a,{className:F.sectionHeader},r.a.createElement(We.a,{variant:"h6",style:{fontWeight:600}},r.a.createElement(Fn.a,{fontSize:"small",style:{marginRight:8}}),"Billing Address"),r.a.createElement(ve.a,{display:"flex",justifyContent:"flex-end"},r.a.createElement(We.a,{className:F.changeLink,onClick:()=>R(!0)},"Change billing address ",r.a.createElement(Bn.a,null)))),x?r.a.createElement(ve.a,{display:"flex",flexDirection:"column",alignItems:"center",py:3},r.a.createElement(Xe.a,{size:24}),r.a.createElement(We.a,{variant:"body2",color:"textSecondary",style:{marginTop:8}},"Loading billing address...")):q?r.a.createElement(er,{address:q,isDefault:!0,compact:!0}):r.a.createElement(We.a,{variant:"body2",color:"textSecondary"},'No billing address selected. Click "Change Address" to add one.')),r.a.createElement(aa.a,{item:!0,xs:12,className:F.defaultCard},r.a.createElement(ve.a,{className:F.sectionHeader},r.a.createElement(We.a,{variant:"h6",style:{fontWeight:600}},r.a.createElement(Ln.a,{fontSize:"small",style:{marginRight:8}}),"Payment Method"),r.a.createElement(ve.a,{display:"flex",justifyContent:"flex-end"},r.a.createElement(We.a,{className:F.changeLink,onClick:()=>M(!0)},"Change billing method ",r.a.createElement(Bn.a,null)))),x?r.a.createElement(ve.a,{display:"flex",flexDirection:"column",alignItems:"center",py:3},r.a.createElement(Xe.a,{size:24}),r.a.createElement(We.a,{variant:"body2",color:"textSecondary",style:{marginTop:8}},"Loading payment method...")):_?r.a.createElement(Jn,{method:_,isDefault:!0,compact:!0}):r.a.createElement(We.a,{variant:"body2",color:"textSecondary"},'No payment method selected. Click "Change Method" to add one.'))),p&&u&&r.a.createElement(ve.a,{mt:3,display:"flex",justifyContent:"flex-end"},r.a.createElement(Ae.a,{variant:"contained",onClick:U,color:"primary",disabled:!O||!q||C,startIcon:r.a.createElement(Un.a,null)},C?r.a.createElement(r.a.Fragment,null," Processing... ",r.a.createElement(Xe.a,{size:20})):"Review and Pay")),r.a.createElement(Ne.a,{open:D,onClose:()=>M(!1),maxWidth:"sm",fullWidth:!0},r.a.createElement(ve.a,{display:"flex",justifyContent:"space-between",alignItems:"center",pr:2},r.a.createElement(Te.a,null,r.a.createElement(We.a,{variant:"h6",fontWeight:600},"Payment Methods")),r.a.createElement(Le.a,{onClick:()=>M(!1),size:"small"},r.a.createElement(ra.a,null))),r.a.createElement(je.a,null,null===b||void 0===b?void 0:b.map(e=>r.a.createElement(Jn,{key:e.id,method:e,isDefault:O===e.id,onSetDefault:e=>le(async()=>{await jn(m.CusId,e),A(e),g(!0,"Default payment method updated.","success")},S,g)(),onDelete:e=>le(async()=>{await(async(e,a)=>{try{return(await B.a.post("".concat(wn,"/delete-payment-method/").concat(e),{customerId:e,paymentMethodId:a})).data}catch(t){z(t)}})(m.CusId,e),h({type:d.DELETE_METHOD,methodId:e}),g(!0,"Payment method deleted.","success")},S,g)()})),r.a.createElement(ve.a,{display:"flex",justifyContent:"flex-end"},r.a.createElement(We.a,{className:F.changeLink,onClick:s},"Add New Payment Method ",r.a.createElement(Bn.a,null))))),r.a.createElement(Ne.a,{open:P,onClose:()=>R(!1),maxWidth:"sm",fullWidth:!0},r.a.createElement(ve.a,{display:"flex",justifyContent:"space-between",alignItems:"center",pr:2},r.a.createElement(Te.a,null,r.a.createElement(We.a,{variant:"h6",fontWeight:600},"Billing Addresses")),r.a.createElement(Le.a,{onClick:()=>R(!1),size:"small"},r.a.createElement(ra.a,null))),r.a.createElement(je.a,null,v.map(e=>r.a.createElement(er,{key:e.id,address:e,isDefault:(null===q||void 0===q?void 0:q.id)===e.id,onEdit:e=>{E(e),i()},onDelete:e=>le(async()=>{await dt(e),f({type:d.DELETE_ADDRESS,addressId:e}),g(!0,"Address deleted successfully","success")},S,g)(),onSetDefault:e=>le(async()=>{await(async(e,a)=>{try{return(await B.a.put("".concat(rt,"/address/default"),{addressId:e,customerId:a})).data}catch(t){z(t)}})(e,m.CusId),f({type:d.SET_DEFAULT_ADDRESS,addressId:e}),g(!0,"Default address changed successfully.","success")},S,g)()})),r.a.createElement(ve.a,{display:"flex",justifyContent:"flex-end"},r.a.createElement(We.a,{className:F.changeLink,onClick:()=>{E({}),i(!0)}},"Add New Address ",r.a.createElement(Bn.a,null))))),r.a.createElement(Ne.a,{open:T,onClose:()=>j(!1),maxWidth:"sm",fullWidth:!0},r.a.createElement(je.a,null,k?r.a.createElement(r.a.Fragment,null,r.a.createElement(tr,{data:k}),r.a.createElement(aa.a,{container:!0,spacing:2},r.a.createElement(aa.a,{item:!0,xs:12,sm:6},r.a.createElement(ve.a,{className:F.paymentInfoBox,height:"100%"},r.a.createElement(We.a,{variant:"subtitle2",gutterBottom:!0},"\ud83d\udcb3 Payment Method"),_&&r.a.createElement(ve.a,{display:"flex",alignItems:"center",gap:1.5},r.a.createElement(Ue.a,{src:nr[null===(a=_.card)||void 0===a?void 0:a.brand],className:F.smallAvatar}),r.a.createElement(ve.a,{flex:1},r.a.createElement(We.a,{variant:"body2",fontWeight:500},"\u2022\u2022\u2022\u2022 ",null===(t=_.card)||void 0===t?void 0:t.last4),r.a.createElement(We.a,{variant:"caption",color:"textSecondary"},"Expires ",null===(l=_.card)||void 0===l?void 0:l.exp_month,"/",null===(o=_.card)||void 0===o?void 0:o.exp_year))))),r.a.createElement(aa.a,{item:!0,xs:12,sm:6},r.a.createElement(ve.a,{className:F.paymentInfoBox,height:"100%"},r.a.createElement(We.a,{variant:"subtitle2",gutterBottom:!0},"\ud83d\udccd Billing Address"),q&&r.a.createElement(r.a.Fragment,null,r.a.createElement(We.a,{variant:"body2",fontWeight:500},q.firstname),r.a.createElement(We.a,{variant:"body2"},q.address_line1),q.address_line2&&r.a.createElement(We.a,{variant:"body2"},q.address_line2),r.a.createElement(We.a,{variant:"body2",color:"textSecondary"},q.address_city,", ",q.address_state," ",q.address_zip)))))):r.a.createElement(ve.a,{display:"flex",justifyContent:"center",p:3},r.a.createElement(Xe.a,{size:24}))),r.a.createElement(ke.a,null,r.a.createElement(Ae.a,{onClick:()=>j(!1),disabled:C},"Cancel"),r.a.createElement(Ae.a,{variant:"contained",onClick:W,disabled:C,color:"primary"},C?r.a.createElement(r.a.Fragment,null," Processing... ",r.a.createElement(Xe.a,{size:20})):"Confirm Payment"))))}var or=t(815);const cr=Object(Ht.a)(e=>({sectionTitle:{fontWeight:700,color:e.palette.primary.main,marginBottom:e.spacing(2),borderBottom:"2px solid ".concat(e.palette.primary.light),paddingBottom:e.spacing(1)},textField:{marginBottom:e.spacing(2),"& .MuiOutlinedInput-root":{borderRadius:12}},stripeFieldContainer:{padding:e.spacing(1.5,2),border:"1px solid ".concat(e.palette.grey[300]),borderRadius:12,backgroundColor:e.palette.background.paper,display:"flex",alignItems:"center",transition:"all 0.2s ease","&:focus-within":{borderColor:e.palette.primary.main,boxShadow:"0 0 0 3px ".concat(e.palette.primary.light,"40")},"& .StripeElement":{width:"100%",fontSize:"16px",letterSpacing:"0.5px"}},button:{marginTop:e.spacing(3),padding:e.spacing(1.4,4),borderRadius:12,fontWeight:600,fontSize:"1rem",textTransform:"none",boxShadow:e.shadows[3],"&:hover":{boxShadow:e.shadows[6]}},closeButton:{position:"absolute",right:e.spacing(1),top:e.spacing(1),color:e.palette.grey[500],"&:hover":{color:e.palette.primary.main}},label:{fontWeight:500,marginBottom:e.spacing(.5),color:e.palette.text.secondary},dialogContent:{padding:e.spacing(3)},cardSection:{borderRadius:16,boxShadow:e.shadows[2],padding:e.spacing(2),background:e.palette.background.default}})),sr=tt.c().shape({firstname:tt.d().required("First name is required"),lastname:tt.d().required("Last name is required"),line1:tt.d().required("Street address is required"),city:tt.d().required("City is required"),postal_code:tt.d().required("Postal code is required"),address_country:tt.c().nullable().required("Country is required")});var ir=e=>{let{open:a,setOpen:t,stripe:l,handleAlert:o,customerId:c}=e;const s=cr(),[i,m]=Object(n.useState)(!1),u=Object(xn.useElements)(),{paymentMethodsDispatch:p}=I(),g=le(async e=>{var a;if(!l||!u)return void o(!0,"Stripe has not loaded correctly. Please refresh.","error");const n=u.getElement(xn.CardNumberElement);if(!n)return void o(!0,"Card details are incomplete.","error");const r=await(async e=>{try{return(await B.a.post("".concat(wn,"/create-setupintent"),{customerId:e},{headers:{"Content-Type":"application/json"}})).data.clientSecret}catch(i){z(i)}})(c);if(!r)return void o(!0,"Failed to retrieve client secret.","error");const{setupIntent:s,error:i}=await l.confirmCardSetup(r,{payment_method:{card:n,billing_details:{address:{line1:e.line1,city:e.city,state:e.state,postal_code:e.postal_code,country:null===(a=e.address_country)||void 0===a?void 0:a.code},name:"".concat(e.firstname," ").concat(e.lastname)}}});if(i)o(!0,"Error: ".concat(i.message),"error");else if(s){const e=await(async(e,a)=>{try{return(await B.a.post("".concat(wn,"/attach-payment-method/").concat(e),{methodId:a},{headers:{"Content-Type":"application/json"}})).data}catch(i){z(i)}})(c,s.payment_method);console.log("newPaymentMethod",e),e&&p({type:d.ADD_METHOD,value:null===e||void 0===e?void 0:e.attachedMethod}),o(!0,"Card saved successfully.","success"),t(!1)}},m,o);return r.a.createElement(Ne.a,{open:a,onClose:()=>t(!1),maxWidth:"md",fullWidth:!0},r.a.createElement(Te.a,null,"Add Payment Method",r.a.createElement(Le.a,{"aria-label":"close",className:s.closeButton,onClick:()=>t(!1)},r.a.createElement(At.a,null))),r.a.createElement(je.a,{dividers:!0,className:s.dialogContent},r.a.createElement(at.d,{initialValues:{firstname:"",lastname:"",line1:"",city:"",state:"",postal_code:"",address_country:null},validationSchema:sr,onSubmit:async e=>{await g(e)}},e=>{let{values:a,errors:t,touched:n,handleChange:l,setFieldValue:o}=e;return r.a.createElement(at.c,null,r.a.createElement(aa.a,{container:!0,spacing:4},r.a.createElement(aa.a,{item:!0,xs:12,md:6},r.a.createElement(Ja.a,{className:s.cardSection},r.a.createElement(Qa.a,null,r.a.createElement(We.a,{variant:"h6",className:s.sectionTitle},"Billing Information"),r.a.createElement(aa.a,{container:!0,spacing:2},r.a.createElement(aa.a,{item:!0,xs:12,sm:6},r.a.createElement($a.a,{label:"First Name",name:"firstname",fullWidth:!0,size:"small",value:a.firstname,onChange:l,error:n.firstname&&Boolean(t.firstname),helperText:n.firstname&&t.firstname,required:!0})),r.a.createElement(aa.a,{item:!0,xs:12,sm:6},r.a.createElement($a.a,{label:"Last Name",name:"lastname",fullWidth:!0,size:"small",value:a.lastname,onChange:l,error:n.lastname&&Boolean(t.lastname),helperText:n.lastname&&t.lastname,required:!0})),r.a.createElement(aa.a,{item:!0,xs:12},r.a.createElement($a.a,{label:"Street Address",name:"line1",fullWidth:!0,size:"small",value:a.line1,onChange:l,error:n.line1&&Boolean(t.line1),helperText:n.line1&&t.line1,required:!0})),r.a.createElement(aa.a,{item:!0,xs:12,sm:6},r.a.createElement($a.a,{label:"Postal Code",name:"postal_code",fullWidth:!0,size:"small",value:a.postal_code,onChange:l,error:n.postal_code&&Boolean(t.postal_code),helperText:n.postal_code&&t.postal_code,required:!0})),r.a.createElement(aa.a,{item:!0,xs:12,sm:6},r.a.createElement($a.a,{label:"City",name:"city",fullWidth:!0,size:"small",value:a.city,onChange:l,error:n.city&&Boolean(t.city),helperText:n.city&&t.city,required:!0})),r.a.createElement(aa.a,{item:!0,xs:12,sm:6},r.a.createElement($a.a,{label:"State",name:"state",fullWidth:!0,size:"small",value:a.state,onChange:l,error:n.state&&Boolean(t.state),helperText:n.state&&t.state,required:!0})),r.a.createElement(aa.a,{item:!0,xs:12,sm:6},r.a.createElement(or.a,{options:hn,getOptionLabel:e=>e.name,value:a.address_country,onChange:(e,a)=>o("address_country",a),renderInput:e=>r.a.createElement($a.a,Object.assign({},e,{label:"Country",size:"small",error:n.address_country&&Boolean(t.address_country),helperText:n.address_country&&t.address_country,required:!0}))})))))),r.a.createElement(aa.a,{item:!0,xs:12,md:6},r.a.createElement(Ja.a,{className:s.cardSection},r.a.createElement(Qa.a,null,r.a.createElement(We.a,{variant:"h6",className:s.sectionTitle},"Payment Details"),r.a.createElement(aa.a,{container:!0,spacing:2},r.a.createElement(aa.a,{item:!0,xs:12},r.a.createElement(We.a,{variant:"body2",className:s.label},"Card Number *"),r.a.createElement("div",{className:s.stripeFieldContainer},r.a.createElement(xn.CardNumberElement,null))),r.a.createElement(aa.a,{item:!0,xs:12,sm:6},r.a.createElement(We.a,{variant:"body2",className:s.label},"Expiry Date *"),r.a.createElement("div",{className:s.stripeFieldContainer},r.a.createElement(xn.CardExpiryElement,null))),r.a.createElement(aa.a,{item:!0,xs:12,sm:6},r.a.createElement(We.a,{variant:"body2",className:s.label},"CVC *"),r.a.createElement("div",{className:s.stripeFieldContainer},r.a.createElement(xn.CardCvcElement,null)))),r.a.createElement(Ae.a,{type:"submit",variant:"contained",color:"primary",fullWidth:!0,className:s.button,disabled:i,endIcon:i&&r.a.createElement(Xe.a,{size:24})},i?"Adding...":"Add Payment Method"))))))})))};const dr=Object(Ht.a)(e=>({boxWrapper:{display:"flex",padding:e.spacing(3),maxWidth:600,margin:"0 auto"},paper:{padding:e.spacing(2),backgroundColor:e.palette.background.paper,borderRadius:"8px",boxShadow:e.shadows[3],minWidth:"90%"},dialogPaper:{borderRadius:12,padding:e.spacing(2),minWidth:600,[e.breakpoints.down("sm")]:{minWidth:"95%"}}}));var mr=e=>{let{isSelectable:a,user:t,planInfo:l,alert:o,handleAlert:c,loading:s,handleClose:i}=e;const d=Object(xn.useStripe)(),m=dr(),[u,p]=Object(n.useState)(!1),[g,y]=Object(n.useState)(!1),[E,b]=Object(n.useState)(null);return r.a.createElement(ve.a,{component:"main",className:m.boxWrapper},r.a.createElement(R,{open:o.open,message:o.message,onClose:i,severity:o.severity}),r.a.createElement(mt.a,{className:m.paper,elevation:5},s&&r.a.createElement(Je,{size:20}),r.a.createElement(lr,{stripe:d,handleAlert:c,user:t,onAdd:()=>p(!0),onAddressAdd:()=>y(!0),priceId:l.priceId,isSelectable:a,editingAddress:E,setEditingAddress:b})),r.a.createElement(ir,{open:u,setOpen:p,stripe:d,handleAlert:c,customerId:null===t||void 0===t?void 0:t.CusId}),r.a.createElement(vn,{open:g,onClose:()=>{y(!1),b(null)},handleAlert:c,addressData:E}))},ur=t(465);var pr=()=>{const e=Object(c.h)(),{planName:a,priceId:t}=e.state||{},[l,o]=Object(n.useState)(null),[s,d]=Object(n.useState)({planName:"",priceId:""}),[m,u]=Object(n.useState)(!1),[p,g]=Object(n.useState)(null),[y,E]=Object(n.useState)(!1),[b,h]=Object(n.useState)({open:!1,message:"",severity:"info"}),v=Object(n.useCallback)((e,a,t)=>{h({open:e,message:a,severity:t})},[]),f=Object(n.useCallback)(()=>h(e=>Object(i.a)(Object(i.a)({},e),{},{open:!1})),[]);return Object(n.useEffect)(()=>{"/payments"===window.location.pathname?E(!0):E(!1);le(async()=>{const e=await(async()=>{try{const e=await B.a.get("".concat(wn,"/publishable-key")),{pk:a}=e.data;return a}catch(e){z(e)}})(),a=Object(ur.a)(e);g(a)},u,v)(),(async()=>{const e=$();e&&e.CusId&&(o(e),d({planName:a,priceId:t}))})()},[null===l||void 0===l?void 0:l.CusId,s.planName,s.priceId]),r.a.createElement("div",{style:{flexGrow:1}},p&&r.a.createElement(xn.Elements,{stripe:p},r.a.createElement(mr,{alert:b,user:l,planInfo:s,isSelectable:y,handleAlert:v,loading:m,setLoading:u,handleClose:f})))};const gr=["children","value","index"],yr=Object(Ee.a)(e=>({root:{padding:e.spacing(.5)},container:{borderRadius:e.shape.borderRadius},item:{padding:e.spacing(2),display:"flex",flexDirection:"column"}}));function Er(e){const{children:a,value:t,index:n}=e,l=Object(Se.a)(e,gr);return r.a.createElement("div",Object.assign({role:"tabpanel",hidden:t!==n,id:"vertical-tabpanel-".concat(n),"aria-labelledby":"vertical-tab-".concat(n)},l),t===n&&r.a.createElement(ve.a,{sx:{p:3}},r.a.createElement(We.a,null,a)))}function br(e){return{id:"vertical-tab-".concat(e),"aria-controls":"vertical-tabpanel-".concat(e)}}var hr=e=>{let{url:a}=e;const t=yr(),[l,o]=Object(n.useState)({}),[c,s]=Object(n.useState)(!1),[d,m]=Object(n.useState)(0),[u,p]=Object(n.useState)(0),[g,y]=Object(n.useState)({open:!1,message:"",severity:"info"}),E=Object(n.useCallback)((e,a,t)=>{y({open:e,message:a,severity:t})},[]),b=Object(n.useCallback)(()=>y(e=>Object(i.a)(Object(i.a)({},e),{},{open:!1})),[]);return Object(n.useEffect)(()=>{const e=$();o(e)},[]),r.a.createElement("div",{className:t.root},r.a.createElement(ve.a,{sx:{bgcolor:"background.paper"}},r.a.createElement(R,{open:g.open,message:g.message,onClose:b,severity:g.severity}),r.a.createElement(Za.a,{style:{marginRight:20},variant:"scrollable",value:d,onChange:(e,a)=>{m(a)},sx:{borderRight:1}},r.a.createElement(Xa.a,Object.assign({icon:r.a.createElement(In.a,null),label:"PROFILE"},br(0))),(null===l||void 0===l?void 0:l.CusId)&&r.a.createElement(Xa.a,Object.assign({icon:r.a.createElement(Pn.a,null),label:"BILLING"},br(1)))),r.a.createElement(Er,{value:d,index:0},r.a.createElement(aa.a,{container:!0,spacing:2,className:t.container},r.a.createElement(aa.a,{item:!0,xs:12,md:4,className:t.item},r.a.createElement(un,{handleAlert:E})),r.a.createElement(aa.a,{item:!0,xs:12,md:8,className:t.item},r.a.createElement(rn,{handleAlert:E,url:a})),r.a.createElement(aa.a,{item:!0,lg:12,md:12,xl:8,xs:12,className:t.item},r.a.createElement(Sn,{handleAlert:E})))),r.a.createElement(Er,{value:d,index:1},r.a.createElement(Za.a,{style:{marginRight:20},variant:"scrollable",value:u,onChange:(e,a)=>{p(a)},sx:{borderRight:1}},r.a.createElement(Xa.a,Object.assign({label:"Billing History"},br(2))),r.a.createElement(Xa.a,Object.assign({label:"Payment Methods"},br(3)))),r.a.createElement(Er,{value:u,index:0},r.a.createElement(Nn,{user:l})),r.a.createElement(Er,{value:u,index:1},r.a.createElement(pr,{isSelectable:!1})))))},vr=t(787),fr=t(788),Cr=t(789),Sr=t(790),xr=t(786);const wr=Object(Ee.a)(e=>({paper:{backgroundColor:e.palette.background.paper,color:e.palette.text.secondary,height:"100%",display:"flex",flexDirection:"column",justifyContent:"space-between",borderRadius:2*e.shape.borderRadius,boxShadow:e.shadows[3],transition:"transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out","&:hover":{transform:"translateY(-4px)",boxShadow:e.shadows[8]},[e.breakpoints.down("xs")]:{marginBottom:e.spacing(2)}},cardContent:{padding:e.spacing(3),flexGrow:1,display:"flex",flexDirection:"column",justifyContent:"space-between"},cardHeader:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:e.spacing(2)},cardTitle:{display:"flex",alignItems:"center",fontWeight:600,color:e.palette.text.primary},cardIcon:{marginLeft:e.spacing(1),fontSize:"1.2rem"},avatar:{backgroundColor:e.palette.primary.main,height:48,width:48,color:e.palette.primary.contrastText,display:"flex",alignItems:"center",justifyContent:"center",[e.breakpoints.down("sm")]:{height:40,width:40}},loadingContainer:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%",minHeight:120}}));var Or=e=>{let{title:a,component:t,componentIcon:n,path:l,loading:o=!1,history:c}=e;const s=wr();return r.a.createElement(mt.a,{className:s.paper},r.a.createElement(ve.a,{className:s.cardContent},r.a.createElement(ve.a,{className:s.cardHeader},r.a.createElement(We.a,{className:s.cardTitle,variant:"subtitle1",color:"textPrimary"},a,l&&r.a.createElement(Le.a,{size:"small",onClick:()=>{c&&l&&c.push(l)},"aria-label":"go to ".concat(l)},r.a.createElement(xr.a,{className:s.cardIcon}))),r.a.createElement(Ue.a,{className:s.avatar},n&&r.a.isValidElement(n)?n:null)),o?r.a.createElement(ve.a,{className:s.loadingContainer},r.a.createElement(Xe.a,null)):r.a.createElement(ve.a,null,t)))};const Ar=Object(Ee.a)(e=>({dataGrid:{display:"flex",flexDirection:"column",gap:e.spacing(1)},dataRow:{display:"flex",justifyContent:"space-between",alignItems:"center"},statusIndicator:{display:"flex",alignItems:"center",fontSize:"0.875rem","& svg":{fontSize:"1rem",marginRight:e.spacing(.5)}},runningStatus:{color:e.palette.success.main},pausedStatus:{color:e.palette.warning.main},failedStatus:{color:e.palette.error.main}}));var Tr=e=>{let{loading:a,totalCount:t,connectedCount:n,notConnectedCount:l,pausedCount:o,history:c}=e;const s=Ar();return r.a.createElement(Or,{title:"Total Topics",component:()=>r.a.createElement(ve.a,null,r.a.createElement(We.a,{variant:"h4",color:"textPrimary"},t),r.a.createElement(ve.a,{mt:1,className:s.dataGrid},r.a.createElement(Qe.a,{title:"Connected topics",arrow:!0},r.a.createElement(ve.a,{className:s.dataRow},r.a.createElement(We.a,{variant:"body2",className:Object(xe.a)(s.statusIndicator,s.runningStatus)},r.a.createElement(vr.a,null)," Connected"),r.a.createElement(We.a,{variant:"body2",color:"textPrimary"},n))),r.a.createElement(Qe.a,{title:"Paused topics",arrow:!0},r.a.createElement(ve.a,{className:s.dataRow},r.a.createElement(We.a,{variant:"body2",className:Object(xe.a)(s.statusIndicator,s.pausedStatus)},r.a.createElement(fr.a,null)," Paused"),r.a.createElement(We.a,{variant:"body2",color:"textPrimary"},o))),r.a.createElement(Qe.a,{title:"Not connected topics",arrow:!0},r.a.createElement(ve.a,{className:s.dataRow},r.a.createElement(We.a,{variant:"body2",className:Object(xe.a)(s.statusIndicator,s.failedStatus)},r.a.createElement(Cr.a,null)," Not Connected"),r.a.createElement(We.a,{variant:"body2",color:"textPrimary"},l))))),componentIcon:r.a.createElement(Sr.a,null),path:"/topics",history:c,loading:a})},jr=(t(405),t(526),t(199)),kr=t.n(jr),Nr=t(93),Dr=t.n(Nr),Ir=(Dr()(),Dr()(),Dr()(),Dr()(),Dr()(),Dr()(),t(791));const Mr=["className","url","history"],Pr=Object(Ee.a)(e=>({root:{height:"100%"},content:{alignItems:"center",display:"flex"},title:{fontWeight:700},avatar:{backgroundColor:e.palette.success.main,height:56,width:56},icon:{height:32,width:32},difference:{marginTop:e.spacing(.5),display:"flex",alignItems:"center"},differenceIcon:{color:e.palette.success.dark},icondown:{color:e.palette.warning.dark,marginRight:e.spacing(.5)},icondowntype:{color:e.palette.warning.dark},caption:{marginRight:e.spacing(.5)},differenceValue:{color:e.palette.success.dark,marginRight:e.spacing(.5)}}));var Rr=e=>{const{className:a,url:t,history:l}=e,o=Object(Se.a)(e,Mr),c=Pr(),[s,i]=Object(n.useState)(""),[d,m]=Object(n.useState)(0),[u,p]=Object(n.useState)(0),[g,y]=Object(n.useState)(0),[E,b]=Object(n.useState)(0),[h,v]=Object(n.useState)(0);return Object(n.useEffect)(()=>{(async()=>{try{(new Date).toISOString();let r=await fetch("".concat(t,"/getMetrics/")+"ram",{method:"GET",mode:"cors",headers:{"Content-Type":"application/json",Authorization:"Bearer "+U()}});var e=(await r.json()).data.result,a=0;for(let t=0;t{(async()=>{try{(new Date).toISOString();let n=await fetch("".concat(t,"/getMetrics/")+"in",{method:"GET",mode:"cors",headers:{"Content-Type":"application/json",Authorization:"Bearer "+U()}});var e=(await n.json()).data.result,a=0;for(let t=0;t{(async()=>{try{(new Date).toISOString();let n=await fetch("".concat(t,"/getMetrics/")+"out",{method:"GET",mode:"cors",headers:{"Content-Type":"application/json",Authorization:"Bearer "+U()}});var e=(await n.json()).data.result,a=0;for(let t=0;t{(async()=>{try{(new Date).toISOString();let n=await fetch("".concat(t,"/getMetrics/")+"messages",{method:"GET",mode:"cors",headers:{"Content-Type":"application/json",Authorization:"Bearer "+U()}});var e=(await n.json()).data.result,a=0;for(let t=0;t{(async()=>{try{(new Date).toISOString();let n=await fetch("".concat(t,"/getMetrics/")+"cpu",{method:"GET",mode:"cors",headers:{"Content-Type":"application/json",Authorization:"Bearer "+U()}});var e=(await n.json()).data.result,a=Number.parseFloat(100*e[0].value[1]).toFixed(2);p(a.toString())}catch(n){console.log("fetch data error "+n)}})()},[]),r.a.createElement(Ja.a,Object.assign({},o,{className:Object(xe.a)(c.root,a)}),r.a.createElement(Ir.a,{onClick:()=>{window.open("https://www.thingwings.com/grafana/d/GCd4-WYVz/kafka-cluster-global-healthcheck?orgId=1&refresh=5s","_blank")},target:"_blank",href:"https://www.thingwings.com/grafana/d/GCd4-WYVz/kafka-cluster-global-healthcheck?orgId=1&refresh=5s"},r.a.createElement(Qa.a,null,r.a.createElement(aa.a,{container:!0,justify:"space-between"},r.a.createElement(aa.a,{item:!0},r.a.createElement(We.a,{className:c.title,color:"textSecondary",gutterBottom:!0,variant:"body2"},"Disk (Global topic size) / CPU"),r.a.createElement(We.a,{variant:"h3"},s," | ",u+"%")),r.a.createElement(aa.a,{item:!0},r.a.createElement(Ue.a,{className:c.avatar},r.a.createElement(kr.a,{className:c.icon})))),r.a.createElement(aa.a,{container:!0,justify:"space-between"},r.a.createElement(aa.a,{xs:12},r.a.createElement("div",{className:c.difference},r.a.createElement(We.a,{className:c.caption,variant:"caption"},"Bytes in per sec"),r.a.createElement(We.a,{className:c.differenceValue,variant:"body2"},g," |"),r.a.createElement(We.a,{className:c.caption,variant:"caption"},"Bytes out per sec"),r.a.createElement(We.a,{className:c.differenceValue,variant:"body2"},E," |"),r.a.createElement(We.a,{className:c.caption,variant:"caption"},"Message in per sec"),r.a.createElement(We.a,{className:c.differenceValue,variant:"body2"},h),r.a.createElement(We.a,{className:c.caption,variant:"caption"})))))))},Fr=t(792);var Br=e=>{let{topicsDetails:a,history:t,loading:n}=e;return r.a.createElement(Or,{title:"Latest Messages",component:()=>r.a.createElement(ve.a,null,a&&a.length>0?r.a.createElement(we.a,{disablePadding:!0},a.slice(0,5).map((e,a)=>r.a.createElement(Oe.a,{key:e.name,disableGutters:!0,divider:a<4},r.a.createElement(ea.a,{primary:e.name}),r.a.createElement(ve.a,{edge:"end",size:"small"},r.a.createElement(We.a,{variant:"body2",color:"textSecondary"},e.messages_count.toLocaleString()," messages"))))):r.a.createElement(We.a,{variant:"body2",color:"textSecondary"},"No recent message data available.")),componentIcon:r.a.createElement(Fr.a,null),path:"/topics",history:t,loading:n})},Lr=t(200),Ur=t(468),Wr=t.n(Ur),_r=t(8);const zr="#FFFFFF";var qr={black:"#000000",white:zr,primary:{contrastText:zr,dark:_r.colors.indigo[900],main:_r.colors.indigo[500],light:_r.colors.indigo[100]},secondary:{contrastText:zr,dark:_r.colors.blue[900],main:_r.colors.blue.A400,light:_r.colors.blue.A400},success:{contrastText:zr,dark:_r.colors.green[900],main:_r.colors.green[600],light:_r.colors.green[400]},info:{contrastText:zr,dark:_r.colors.blue[900],main:_r.colors.blue[600],light:_r.colors.blue[400]},warning:{contrastText:zr,dark:_r.colors.orange[900],main:_r.colors.orange[600],light:_r.colors.orange[400]},error:{contrastText:zr,dark:_r.colors.red[900],main:_r.colors.red[600],light:_r.colors.red[400]},text:{primary:_r.colors.blueGrey[900],secondary:_r.colors.blueGrey[600],link:_r.colors.blue[600]},background:{default:"#F4F6F8",paper:zr},icon:_r.colors.blueGrey[600],divider:_r.colors.grey[200]};qr.primary.main,qr.text.primary,qr.text.secondary,qr.text.secondary,qr.text.secondary,qr.text.secondary;const Gr=["className","url","history"],Hr=Object(Ee.a)(e=>({root:{height:"100%"},content:{alignItems:"center",display:"flex"},title:{fontWeight:700},avatar:{backgroundColor:e.palette.success.main,height:56,width:56},icon:{height:32,width:32},difference:{marginTop:e.spacing(.5),display:"flex",alignItems:"center"},differenceIcon:{color:e.palette.success.dark},icondown:{color:e.palette.warning.dark,marginRight:e.spacing(.5)},icondowntype:{color:e.palette.warning.dark},caption:{marginRight:e.spacing(.5)},differenceValue:{color:e.palette.success.dark,marginRight:e.spacing(.5)}}));var Vr=e=>{const{className:a,url:t,history:l}=e,o=Object(Se.a)(e,Gr),c=Hr(),[s,i]=Object(n.useState)(""),[d,m]=Object(n.useState)(0),[u,p]=Object(n.useState)(0),[g,y]=Object(n.useState)(0),[E,b]=Object(n.useState)(0),[h,v]=Object(n.useState)(0);return Object(n.useEffect)(()=>{(async()=>{try{(new Date).toISOString();let n=await fetch("".concat(t,"/getMetrics/")+"totalclient",{method:"GET",mode:"cors",headers:{"Content-Type":"application/json",Authorization:"Bearer "+U()}});var e=(await n.json()).data.result,a=0;for(let t=0;t{(async()=>{try{(new Date).toISOString();let n=await fetch("".concat(t,"/getMetrics/")+"mosin",{method:"GET",mode:"cors",headers:{"Content-Type":"application/json",Authorization:"Bearer "+U()}});var e=(await n.json()).data.result,a=0;for(let t=0;t{(async()=>{try{(new Date).toISOString();let n=await fetch("".concat(t,"/getMetrics/")+"mosout",{method:"GET",mode:"cors",headers:{"Content-Type":"application/json",Authorization:"Bearer "+U()}});var e=(await n.json()).data.result,a=0;for(let t=0;t{(async()=>{try{(new Date).toISOString();let n=await fetch("".concat(t,"/getMetrics/")+"messagemos",{method:"GET",mode:"cors",headers:{"Content-Type":"application/json",Authorization:"Bearer "+U()}});var e=(await n.json()).data.result,a=0;for(let t=0;t{(async()=>{try{(new Date).toISOString();let n=await fetch("".concat(t,"/getMetrics/")+"mossub",{method:"GET",mode:"cors",headers:{"Content-Type":"application/json",Authorization:"Bearer "+U()}});var e=(await n.json()).data.result,a=e[0].value[1];p(a.toString())}catch(n){p("error")}})()},[]),r.a.createElement(Ja.a,Object.assign({},o,{className:Object(xe.a)(c.root,a)}),r.a.createElement(Ir.a,{onClick:()=>{window.open("https://www.thingwings.com/grafana/d/Ie16aZLVz/mosquitto-broke?orgId=1&refresh=10s","_blank")},target:"_blank",href:"https://www.thingwings.com/grafana/d/Ie16aZLVz/mosquitto-broke?orgId=1&refresh=10s"},r.a.createElement(Qa.a,null,r.a.createElement(aa.a,{container:!0,justify:"space-between"},r.a.createElement(aa.a,{item:!0},r.a.createElement(We.a,{className:c.title,color:"textSecondary",gutterBottom:!0,variant:"body2"},"Client Total | Total subscriptions"),r.a.createElement(We.a,{variant:"h3"},s," | ",u)),r.a.createElement(aa.a,{item:!0},r.a.createElement(Ue.a,{className:c.avatar},r.a.createElement(Wr.a,{className:c.icon})))),r.a.createElement(aa.a,{container:!0,justify:"space-between"},r.a.createElement(aa.a,{xs:12},r.a.createElement("div",{className:c.difference},r.a.createElement(We.a,{className:c.caption,variant:"caption"},"Bytes in per sec"),r.a.createElement(We.a,{className:c.differenceValue,variant:"body2"},g," |"),r.a.createElement(We.a,{className:c.caption,variant:"caption"},"Bytes out per sec"),r.a.createElement(We.a,{className:c.differenceValue,variant:"body2"},E," |"),r.a.createElement(We.a,{className:c.caption,variant:"caption"},"Tolal messages received"),r.a.createElement(We.a,{className:c.differenceValue,variant:"body2"},h),r.a.createElement(We.a,{className:c.caption,variant:"caption"})))))))},Kr=t(469),Yr=t.n(Kr);const Zr=Object(Ee.a)(e=>({dataGrid:{display:"flex",flexDirection:"column",gap:e.spacing(1)},dataRow:{display:"flex",justifyContent:"space-between",alignItems:"center"},statusIndicator:{display:"flex",alignItems:"center",fontSize:"0.875rem","& svg":{fontSize:"1rem",marginRight:e.spacing(.5)}},activeStatus:{color:e.palette.success.main},inactiveStatus:{color:e.palette.error.main}}));var Xr=e=>{let{loading:a,apisCount:t,activeApisCount:n,inactiveApisCount:l,history:o}=e;const c=Zr();return r.a.createElement(Or,{title:"AI Models",component:()=>r.a.createElement(ve.a,null,r.a.createElement(We.a,{variant:"h4",color:"textPrimary"},t),r.a.createElement(ve.a,{mt:1,className:c.dataGrid},r.a.createElement(Qe.a,{title:"Active AI Models",arrow:!0},r.a.createElement(ve.a,{className:c.dataRow},r.a.createElement(We.a,{variant:"body2",className:"".concat(c.statusIndicator," ").concat(c.activeStatus)},r.a.createElement(vr.a,null)," Active"),r.a.createElement(We.a,{variant:"body2",color:"textPrimary"},n))),r.a.createElement(Qe.a,{title:"Inactive AI Models",arrow:!0},r.a.createElement(ve.a,{className:c.dataRow},r.a.createElement(We.a,{variant:"body2",className:"".concat(c.statusIndicator," ").concat(c.inactiveStatus)},r.a.createElement(Cr.a,null)," Inactive"),r.a.createElement(We.a,{variant:"body2",color:"textPrimary"},l))))),componentIcon:r.a.createElement(Yr.a,null),path:"/ai-models",history:o,loading:a})},Jr=t(802);const Qr=Object(Ee.a)(e=>({dataGrid:{display:"flex",flexDirection:"column",gap:e.spacing(1)},dataRow:{display:"flex",justifyContent:"space-between",alignItems:"center"},statusIndicator:{display:"flex",alignItems:"center",fontSize:"0.875rem","& svg":{fontSize:"1rem",marginRight:e.spacing(.5)}},runningStatus:{color:e.palette.success.main},failedStatus:{color:e.palette.error.main}}));var $r=e=>{let{history:a,loading:t,sourceConnectorsCount:n,sinkConnectorsCount:l,httpConnectorsCount:o,runningConnectorsCount:c,failedConnectorsCount:s}=e;const i=Qr(),d=n+l+o;return r.a.createElement(Or,{title:"Total Connectors",component:()=>r.a.createElement(ve.a,null,r.a.createElement(We.a,{variant:"h4",color:"textPrimary"},d),r.a.createElement(ve.a,{mt:1,className:i.dataGrid},r.a.createElement(Qe.a,{title:"Running connectors",arrow:!0},r.a.createElement(ve.a,{className:i.dataRow},r.a.createElement(We.a,{variant:"body2",className:Object(xe.a)(i.statusIndicator,i.runningStatus)},r.a.createElement(vr.a,null)," Running"),r.a.createElement(We.a,{variant:"body2",color:"textPrimary"},c))),r.a.createElement(Qe.a,{title:"Failed connectors",arrow:!0},r.a.createElement(ve.a,{className:i.dataRow},r.a.createElement(We.a,{variant:"body2",className:Object(xe.a)(i.statusIndicator,i.failedStatus)},r.a.createElement(Cr.a,null)," Failed"),r.a.createElement(We.a,{variant:"body2",color:"textPrimary"},s))))),componentIcon:r.a.createElement(Jr.a,null),path:"/connectors",history:a,loading:t})},el=t(803);const al=Object(Ee.a)(e=>({dataGrid:{display:"flex",flexDirection:"column",gap:e.spacing(1)},dataRow:{display:"flex",justifyContent:"space-between",alignItems:"center"},statusIndicator:{display:"flex",alignItems:"center",fontSize:"0.875rem","& svg":{fontSize:"1rem",marginRight:e.spacing(.5)}},runningStatus:{color:e.palette.success.main},pausedStatus:{color:e.palette.warning.main},notConnectedStatus:{color:e.palette.error.main}}));var tl=e=>{let{loading:a,totalCount:t,runningCount:n,pausedCount:l,notConnectedCount:o,history:c}=e;const s=al();return r.a.createElement(Or,{title:"Total Things",component:()=>r.a.createElement(ve.a,null,r.a.createElement(We.a,{variant:"h4",color:"textPrimary"},t),r.a.createElement(ve.a,{mt:1,className:s.dataGrid},r.a.createElement(Qe.a,{title:"Running things",arrow:!0},r.a.createElement(ve.a,{className:s.dataRow},r.a.createElement(We.a,{variant:"body2",className:Object(xe.a)(s.statusIndicator,s.runningStatus)},r.a.createElement(vr.a,null)," Running"),r.a.createElement(We.a,{variant:"body2",color:"textPrimary"},n))),r.a.createElement(Qe.a,{title:"Paused things",arrow:!0},r.a.createElement(ve.a,{className:s.dataRow},r.a.createElement(We.a,{variant:"body2",className:Object(xe.a)(s.statusIndicator,s.pausedStatus)},r.a.createElement(fr.a,null)," Paused"),r.a.createElement(We.a,{variant:"body2",color:"textPrimary"},l))),r.a.createElement(Qe.a,{title:"Not Connected things",arrow:!0},r.a.createElement(ve.a,{className:s.dataRow},r.a.createElement(We.a,{variant:"body2",className:Object(xe.a)(s.statusIndicator,s.notConnectedStatus)},r.a.createElement(Cr.a,null)," Not Connected"),r.a.createElement(We.a,{variant:"body2",color:"textPrimary"},o))))),componentIcon:r.a.createElement(el.a,null),path:"/things",history:c,loading:a})},nl=t(804);const rl=Object(Ee.a)(e=>({dataGrid:{display:"flex",flexDirection:"column",gap:e.spacing(1)},dataRow:{display:"flex",justifyContent:"space-between",alignItems:"center"},statusIndicator:{display:"flex",alignItems:"center",fontSize:"0.875rem","& svg":{fontSize:"1rem",marginRight:e.spacing(.5)}},deployedStatus:{color:e.palette.success.main},undeployedStatus:{color:e.palette.error.main}}));var ll=e=>{let{loading:a,flowsCount:t,deployedFlowsCount:n,undeployedFlowsCount:l,history:o}=e;const c=rl();return r.a.createElement(Or,{title:"Total Flows",component:()=>r.a.createElement(ve.a,null,r.a.createElement(We.a,{variant:"h4",color:"textPrimary"},t),r.a.createElement(ve.a,{mt:1,className:c.dataGrid},r.a.createElement(Qe.a,{title:"Deployed flows",arrow:!0},r.a.createElement(ve.a,{className:c.dataRow},r.a.createElement(We.a,{variant:"body2",className:"".concat(c.statusIndicator," ").concat(c.deployedStatus)},r.a.createElement(vr.a,null)," Deployed"),r.a.createElement(We.a,{variant:"body2",color:"textPrimary"},n))),r.a.createElement(Qe.a,{title:"Undeployed flows",arrow:!0},r.a.createElement(ve.a,{className:c.dataRow},r.a.createElement(We.a,{variant:"body2",className:"".concat(c.statusIndicator," ").concat(c.undeployedStatus)},r.a.createElement(Cr.a,null)," Undeployed"),r.a.createElement(We.a,{variant:"body2",color:"textPrimary"},l))))),componentIcon:r.a.createElement(nl.a,null),path:"/flows",history:o,loading:a})},ol=t(805);const cl=Object(Ht.a)(e=>({usageContainer:{flexGrow:1},totalMessagesText:{fontWeight:700,marginBottom:e.spacing(.5)},totalMessagesTextSuccess:{color:e.palette.success.main},totalMessagesTextWarning:{color:e.palette.warning.main},totalMessagesTextError:{color:e.palette.error.main},usageItem:{marginBottom:e.spacing(2),"&:last-child":{marginBottom:0}},usageText:{display:"flex",justifyContent:"space-between",marginBottom:e.spacing(.5)},usageProgress:{height:8,borderRadius:4}}));var sl=e=>{let{loading:a,userUsage:t,plan:n,history:l,subscription:o}=e;const c=cl();if(!t||0===Object.keys(t).length)return r.a.createElement(Or,{title:"User Usage",component:()=>r.a.createElement(We.a,{variant:"body2",color:"textSecondary"},"No usage data available yet."),componentIcon:r.a.createElement(ol.a,null),path:"/plan",history:l,loading:a});const s=(e,a)=>!a||a<=0?"".concat(ne(e)," / Unlimited"):"".concat(ne(e)," / ").concat(ne(a)),i=(e,a)=>!a||a<=0?0:Math.min(e/a*100,100),d=n.planType||"mqtt_kafka",m=t.totalMessagesCount||0,u=n.planMessages*o.quantity||0,p=i(m,u),g=(y=p)>90?c.totalMessagesTextError:y>70?c.totalMessagesTextWarning:c.totalMessagesTextSuccess;var y;const E=[{label:"Total Messages",current:m,limit:u},d.includes("kafka")&&{label:"Kafka Messages",current:t.kafkaMessagesCount||0,limit:u},d.includes("mqtt")&&{label:"MQTT Messages",current:t.mqttMessagesCount||0,limit:u},{label:"Devices",current:t.devicesCount||0,limit:n.planDevices}].filter(Boolean);return r.a.createElement(Or,{title:"User Usage",component:()=>r.a.createElement(ve.a,{className:c.usageContainer},r.a.createElement(ve.a,{sx:{marginBottom:2}},r.a.createElement(We.a,{variant:"h6",className:Object(xe.a)(c.totalMessagesText,g)},"Total: ",ne(m)),r.a.createElement(We.a,{variant:"body2",color:"textSecondary"},"Messages Consumed",u>0&&" / ".concat(ne(u)))),E.map((e,a)=>0===e.limit&&0===e.current?null:r.a.createElement(Qe.a,{key:a,title:"".concat(e.label,": ").concat(s(e.current,e.limit)),arrow:!0},r.a.createElement(ve.a,{className:c.usageItem},r.a.createElement(ve.a,{className:c.usageText},r.a.createElement(We.a,{variant:"body2",color:"textPrimary"},e.label),r.a.createElement(We.a,{variant:"body2",color:"textSecondary"},s(e.current,e.limit))),r.a.createElement(on.a,{className:c.usageProgress,variant:"determinate",value:i(e.current,e.limit),color:i(e.current,e.limit)>90?"secondary":i(e.current,e.limit)>70?"warning":"primary"}))))),componentIcon:r.a.createElement(ol.a,null),path:"/plan",history:l,loading:a})},il=t(441),dl=t(806),ml=t(807),ul=t(808),pl=t(809),gl=t(810);const yl=Object(Ht.a)(e=>({chip:{marginBottom:e.spacing(1),height:28,fontWeight:600,"& .MuiChip-icon":{fontSize:"1rem",marginRight:e.spacing(.5)}},planName:{fontWeight:600,color:e.palette.text.primary,display:"flex",alignItems:"center",justifyContent:"center",gap:e.spacing(1)},detailTextWithIcon:{display:"flex",alignItems:"center"},smallIcon:{fontSize:"1rem",marginRight:e.spacing(.5)},iconColorInfo:{color:e.palette.info.main},iconColorError:{color:e.palette.error.main},detailRow:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:e.spacing(1.5),backgroundColor:e.palette.grey[50],borderRadius:e.shape.borderRadius,marginBottom:e.spacing(1),borderLeft:"3px solid ".concat(e.palette.primary.main),transition:"border-color 0.3s ease","&:hover":{borderColor:e.palette.primary.dark}},detailRowError:{borderLeft:"3px solid ".concat(e.palette.error.main),backgroundColor:e.palette.error.light,"&:hover":{borderColor:e.palette.error.dark}},expiredWarningText:{fontWeight:600,color:e.palette.error.main},statusContainer:{display:"flex",justifyContent:"center",flexWrap:"wrap",gap:e.spacing(1),marginBottom:e.spacing(1)}})),El={active:{label:"Payment Active",color:"primary",icon:Un.a},past_due:{label:"Payment Overdue",color:"secondary",icon:dl.a},unpaid:{label:"Payment Failed",color:"secondary",icon:dl.a},canceled:{label:"Subscription Canceled",color:"secondary",icon:dl.a},cancelled:{label:"Subscription Cancelled",color:"secondary",icon:dl.a}};var bl=e=>{let{loading:a,subscription:t,plan:n,history:l,userUsage:o}=e;const c=yl();if((!t||0===Object.keys(t).length)&&!o)return r.a.createElement(Or,{title:"User Subscription",component:()=>r.a.createElement(We.a,{variant:"body1",color:"textSecondary",align:"center"},"No active subscription or usage found."),componentIcon:r.a.createElement(ml.a,null),path:"/plan",history:l,loading:a});if(!t||0===Object.keys(t).length)return r.a.createElement(Or,{title:"User Subscription",component:()=>r.a.createElement(We.a,{variant:"body1",color:"textSecondary",align:"center"},"No active subscription found."),componentIcon:r.a.createElement(ml.a,null),path:"/plan",history:l,loading:a});const{label:s="Unknown Status",color:i="default",icon:d=null}=El[t.status]||{},m=n.planName||"No Plan Assigned",u=function(e){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:20;return e.length>a?"".concat(e.substring(0,a),"..."):e}(m),p=t.currentPeriodStart?ae(t.currentPeriodStart):"N/A",g=t.quantity||1,y=1===t.isPaused,E=!!t.upcomingPlanId,b=t.cancelAtPeriodEnd?"Ends At":"Next Cycle",h=t.cancelAtPeriodEnd?t.endsAt?ae(t.endsAt):"N/A":t.currentPeriodEnd?ae(t.currentPeriodEnd):"N/A",v=t.cancelAtPeriodEnd&&t.endsAt&&new Date(1e3*t.endsAt)r.a.createElement(ve.a,null,r.a.createElement(ve.a,{className:c.statusContainer},r.a.createElement(Qe.a,{title:"Subscription payment status",arrow:!0},r.a.createElement(il.a,{label:s,color:i,icon:d?r.a.createElement(d,null):null,className:c.chip})),y&&r.a.createElement(Qe.a,{title:"Your subscription is paused",arrow:!0},r.a.createElement(il.a,{label:"Subscription Paused",color:"secondary",icon:r.a.createElement(ul.a,null),className:c.chip}))),r.a.createElement(Qe.a,{title:m,arrow:!0},r.a.createElement(We.a,{variant:"h6",className:c.planName},u,r.a.createElement(We.a,{variant:"body2",color:"textSecondary",component:"span"},"(Qty: ",g,")"))),r.a.createElement(ve.a,null,r.a.createElement(Qe.a,{title:"Subscription start date",arrow:!0},r.a.createElement(ve.a,{className:c.detailRow},r.a.createElement(We.a,{variant:"body2",className:c.detailTextWithIcon},r.a.createElement(pl.a,{className:Object(xe.a)(c.smallIcon,c.iconColorInfo)})," Start Date:"),r.a.createElement(We.a,{variant:"body2",color:"textSecondary"},p))),r.a.createElement(Qe.a,{title:b,arrow:!0},r.a.createElement(ve.a,{className:Object(xe.a)(c.detailRow,{[c.detailRowError]:v})},r.a.createElement(We.a,{variant:"body2",className:Object(xe.a)(c.detailTextWithIcon,{[c.iconColorError]:v,[c.iconColorInfo]:!v})},r.a.createElement(pl.a,{className:c.smallIcon})," ",b,":"),r.a.createElement(We.a,{variant:"body2",className:v?c.expiredWarningText:void 0},h))),E&&r.a.createElement(Qe.a,{title:"Upcoming plan change",arrow:!0},r.a.createElement(il.a,{label:"Upcoming Plan: ".concat(t.upcomingPlanId),variant:"outlined",size:"small",color:"primary",icon:r.a.createElement(gl.a,null),className:c.chip,style:{marginTop:8}})))),componentIcon:r.a.createElement(ml.a,null),path:"/plan",history:l,loading:a})};var hl=e=>{let{loading:a,data:t,history:n}=e;const l=Object(be.a)(),o={labels:t.map(e=>e.label),datasets:[{label:"Messages Count",data:t.map(e=>e.value),backgroundColor:l.palette.primary.main,borderColor:l.palette.primary.dark,borderWidth:1,barPercentage:.05}]},c={scales:{y:{beginAtZero:!0}}};return r.a.createElement(Or,{title:"Topic Messages",component:()=>r.a.createElement(ve.a,null,r.a.createElement(ve.a,null,r.a.createElement(Lr.Bar,{data:o,options:c}))),componentIcon:r.a.createElement(ol.a,null),path:"/topics",history:n,loading:a})};const vl=Object(Ee.a)(e=>({dataGrid:{display:"flex",flexDirection:"column",gap:e.spacing(1)},dataRow:{display:"flex",justifyContent:"space-between",alignItems:"center"},statusIndicator:{display:"flex",alignItems:"center",fontSize:"0.875rem","& svg":{fontSize:"1rem",marginRight:e.spacing(.5)}},connectedStatus:{color:e.palette.success.main},disconnectedStatus:{color:e.palette.error.main}}));var fl=e=>{let{loading:a,dataSourceMappingsCount:t,connectedDataSourcesCount:n,disconnectedDataSourcesCount:l,history:o}=e;const c=vl();return r.a.createElement(Or,{title:"Data Stores",component:()=>r.a.createElement(ve.a,null,r.a.createElement(We.a,{variant:"h4",color:"textPrimary"},t),r.a.createElement(ve.a,{mt:1,className:c.dataGrid},r.a.createElement(Qe.a,{title:"Connected data stores",arrow:!0},r.a.createElement(ve.a,{className:c.dataRow},r.a.createElement(We.a,{variant:"body2",className:"".concat(c.statusIndicator," ").concat(c.connectedStatus)},r.a.createElement(vr.a,null)," Connected"),r.a.createElement(We.a,{variant:"body2",color:"textPrimary"},n))),r.a.createElement(Qe.a,{title:"Disconnected data stores",arrow:!0},r.a.createElement(ve.a,{className:c.dataRow},r.a.createElement(We.a,{variant:"body2",className:"".concat(c.statusIndicator," ").concat(c.disconnectedStatus)},r.a.createElement(Cr.a,null)," Disconnected"),r.a.createElement(We.a,{variant:"body2",color:"textPrimary"},l))))),componentIcon:r.a.createElement(Fr.a,null),path:"/datastores",history:o,loading:a})};const Cl=Object(Ee.a)(e=>({paper:{backgroundColor:e.palette.background.paper,color:e.palette.text.secondary,display:"flex",flexDirection:"column",justifyContent:"space-between",borderRadius:2*e.shape.borderRadius,boxShadow:e.shadows[3],transition:"transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out","&:hover":{transform:"translateY(-4px)",boxShadow:e.shadows[8]},[e.breakpoints.down("xs")]:{marginBottom:e.spacing(2)}}}));var Sl=e=>{let{history:a,url:t}=e;Cl();const[l,o]=Object(n.useState)(null),[c,s]=Object(n.useState)(!0),[d,m]=Object(n.useState)([]),[u,p]=Object(n.useState)({open:!1,message:"",severity:"info"}),g=(e,a,t)=>{p({open:e,message:a,severity:t})},y=L();return Object(n.useEffect)(()=>{le(async()=>{const e=await(async()=>{try{return(await B.a.get("".concat("https://www.thingwings.com/api/dashboard"))).data}catch(e){z(e)}})(),a=e.topicsDetails.map(e=>({label:e.name,value:e.messages_count}));m(a),o(e)},s,g)()},[]),r.a.createElement(r.a.Fragment,null,r.a.createElement(R,{open:u.open,message:u.message,onClose:()=>{p(e=>Object(i.a)(Object(i.a)({},e),{},{open:!1}))},severity:u.severity}),r.a.createElement(aa.a,{container:!0,spacing:2},y.admin?r.a.createElement(r.a.Fragment,null,r.a.createElement(aa.a,{item:!0,xs:12,md:6,lg:6},r.a.createElement(Rr,{url:t,history:a})),r.a.createElement(aa.a,{item:!0,xs:12,md:6,lg:6},r.a.createElement(Vr,{url:t,history:a}))):null,r.a.createElement(aa.a,{item:!0,container:!0,spacing:2},r.a.createElement(aa.a,{item:!0,xs:12,sm:6,md:3,lg:3},r.a.createElement(Tr,{loading:c,totalCount:(null===l||void 0===l?void 0:l.topicsCount)||0,connectedCount:(null===l||void 0===l?void 0:l.connectedTopicsCount)||0,notConnectedCount:(null===l||void 0===l?void 0:l.notConnectedTopicsCount)||0,pausedCount:(null===l||void 0===l?void 0:l.pausedTopicsCount)||0,history:a})),r.a.createElement(aa.a,{item:!0,xs:12,sm:6,md:3,lg:3},r.a.createElement($r,{loading:c,sourceConnectorsCount:(null===l||void 0===l?void 0:l.sourceConnectorsCount)||0,sinkConnectorsCount:(null===l||void 0===l?void 0:l.sinkConnectorsCount)||0,httpConnectorsCount:(null===l||void 0===l?void 0:l.httpConnectorsCount)||0,runningConnectorsCount:(null===l||void 0===l?void 0:l.runningConnectorsCount)||0,failedConnectorsCount:(null===l||void 0===l?void 0:l.failedConnectorsCount)||0,history:a})),r.a.createElement(aa.a,{item:!0,xs:12,sm:6,md:3,lg:3},r.a.createElement(Xr,{loading:c,apisCount:(null===l||void 0===l?void 0:l.apisCount)||0,history:a,activeApisCount:(null===l||void 0===l?void 0:l.activeApisCount)||0,inactiveApisCount:(null===l||void 0===l?void 0:l.inactiveApisCount)||0})),r.a.createElement(aa.a,{item:!0,xs:12,sm:6,md:3,lg:3},r.a.createElement(tl,{loading:c,totalCount:(null===l||void 0===l?void 0:l.thingsCount)||0,runningCount:(null===l||void 0===l?void 0:l.runningThingsCount)||0,pausedCount:(null===l||void 0===l?void 0:l.pausedThingsCount)||0,notConnectedCount:(null===l||void 0===l?void 0:l.notConnectedThingsCount)||0,history:a}))),r.a.createElement(aa.a,{item:!0,container:!0,spacing:2},r.a.createElement(aa.a,{item:!0,xs:12,sm:6,md:3,lg:3},r.a.createElement(ll,{loading:c,flowsCount:(null===l||void 0===l?void 0:l.flowsCount)||0,history:a,deployedFlowsCount:(null===l||void 0===l?void 0:l.deployedFlowsCount)||0,undeployedFlowsCount:(null===l||void 0===l?void 0:l.undeployedFlowsCount)||0})),r.a.createElement(aa.a,{item:!0,xs:12,sm:6,md:3,lg:3},r.a.createElement(fl,{loading:c,dataSourceMappingsCount:(null===l||void 0===l?void 0:l.dataSourceMappingsCount)||0,history:a,connectedDataSourcesCount:(null===l||void 0===l?void 0:l.connectedDataSourcesCount)||0,disconnectedDataSourcesCount:(null===l||void 0===l?void 0:l.disconnectedDataSourcesCount)||0})),r.a.createElement(aa.a,{item:!0,xs:12,sm:6,md:3,lg:3},r.a.createElement(sl,{loading:c,userUsage:(null===l||void 0===l?void 0:l.userUsage)||{},subscription:(null===l||void 0===l?void 0:l.subscription)||{},plan:(null===l||void 0===l?void 0:l.plan)||{},history:a})),r.a.createElement(aa.a,{item:!0,xs:12,sm:6,md:3,lg:3},r.a.createElement(bl,{loading:c,subscription:(null===l||void 0===l?void 0:l.subscription)||{},plan:(null===l||void 0===l?void 0:l.plan)||{},history:a}))),r.a.createElement(aa.a,{item:!0,container:!0,spacing:2},r.a.createElement(aa.a,{item:!0,xs:12,md:6,lg:6},r.a.createElement(Br,{topicsDetails:(null===l||void 0===l?void 0:l.topicsDetails)||[],history:a,loading:c})),r.a.createElement(aa.a,{item:!0,xs:12,md:6,lg:6},r.a.createElement(hl,{data:d,history:a,loading:c})))))};const xl=Object(Ee.a)(e=>({root:{height:"100vh",display:"flex",justifyContent:"center",alignItems:"center",padding:e.spacing(2)},content:{textAlign:"center"},image:{marginTop:50,display:"inline-block",maxWidth:"100%",width:240},button:{marginTop:20}}));var wl=()=>{const e=xl(),a=Object(c.g)();return r.a.createElement("div",{className:e.root},r.a.createElement(aa.a,{container:!0,direction:"column",alignItems:"center",spacing:4},r.a.createElement(aa.a,{item:!0},r.a.createElement(We.a,{variant:"h3"},"The page you are looking for isn\u2019t here")),r.a.createElement(aa.a,{item:!0},r.a.createElement(We.a,{variant:"subtitle2"},"You either tried some shady route or you came here by mistake. Whichever it is, try using the navigation.")),r.a.createElement(aa.a,{item:!0},r.a.createElement("img",{alt:"Under development",className:e.image,src:"/images/undraw_page_not_found_su7k.svg"})),r.a.createElement(aa.a,{item:!0},r.a.createElement(Ae.a,{variant:"contained",color:"primary",className:e.button,onClick:()=>{a.push("/")}},"Return to Home"))))},Ol=t(202),Al=t.n(Ol),Tl=t(201),jl=t.n(Tl),kl=t(104),Nl=t.n(kl);const Dl=q+"/connectors",Il=Object(Ee.a)(e=>({status:{marginRight:e.spacing(1)}}));var Ml=e=>{var a,t;let{name:l,id:o,status:c,config:s,handleAlert:m,openForm:u}=e;const p=Il(),[g,y]=Object(n.useState)(!1),{connectorInfoDispatch:E}=I(),[b,h]=Object(n.useState)(!1),{connectorsDispatch:v}=I(),f=()=>{y(!1)},C=le(async()=>{await(async e=>{try{return(await B.a.delete("".concat(Dl,"/").concat(e))).data}catch(a){z(a)}})(o),await v({type:d.DELETE_CONNECTOR,value:o}),f()},h,m),{imageSrc:S,classType:x}=(()=>{let e,a;switch(s.connectorClass){case"io.confluent.connect.elasticsearch.ElasticsearchSinkConnector":e="/images/products/product_3.jpg",a="Elasticsearch";break;case"io.confluent.connect.jdbc.JdbcSinkConnector":e="/images/products/product_8.png",a="JDBC";break;case"com.thingwings.MqttSourceConnector":e="/images/products/product_1.png",a="MQTT";break;default:e="/images/products/product_7.png",a="Default"}return{imageSrc:e,classType:a}})();return r.a.createElement(r.a.Fragment,null,r.a.createElement(Ja.a,{style:{display:"flex",flexDirection:"column",height:"100%"}},r.a.createElement(Qa.a,{style:{flex:1}},r.a.createElement(aa.a,{container:!0,justifyContent:"space-between"},r.a.createElement(aa.a,{item:!0},r.a.createElement(Qe.a,{title:l.length>25?l:"",arrow:!0},r.a.createElement(We.a,{variant:"h6"},(e=>e.length>25?e.substring(0,25)+"...":e)(l)))),r.a.createElement(aa.a,{item:!0},r.a.createElement(aa.a,{container:!0,alignItems:"center",justifyContent:"flex-end"},r.a.createElement(aa.a,{item:!0},r.a.createElement(Le.a,{"aria-label":"info",onClick:async()=>{try{await E({type:d.SET_CONNECTOR_INFO,value:Object(i.a)(Object(i.a)({},s),{},{name:l})}),u("INFO")}catch(e){console.error("Error updating connector:",e)}}},r.a.createElement(Qe.a,{title:"Info"},r.a.createElement(Nl.a,{color:"primary"}))),r.a.createElement(Le.a,{"aria-label":"delete",onClick:()=>{y(!0)}},r.a.createElement(Qe.a,{title:"Delete"},r.a.createElement(tn.a,null))))))),r.a.createElement(aa.a,{container:!0,justifyContent:"center"},r.a.createElement(aa.a,{item:!0},r.a.createElement(Ue.a,{alt:"Product",src:S}))),r.a.createElement(We.a,{align:"center",variant:"body2"},x)),r.a.createElement(et.a,null,r.a.createElement(aa.a,{container:!0,justifyContent:"space-between"},r.a.createElement(aa.a,{item:!0},r.a.createElement("div",null,r.a.createElement(We.a,{display:"inline",variant:"body2"},c.type.toUpperCase()))),r.a.createElement(aa.a,{item:!0},r.a.createElement("div",null,r.a.createElement(Ct,{className:p.status,color:"FAILED"===(null===(a=c.connector)||void 0===a?void 0:a.state)?"warning":"success",size:"sm"}),r.a.createElement(We.a,{display:"inline",variant:"body2"},null===(t=c.connector)||void 0===t?void 0:t.state)))))),r.a.createElement(Ne.a,{open:g,onClose:f},r.a.createElement(Te.a,{disableTypography:!1},"Confirmation"),r.a.createElement(je.a,{dividers:!0},"Are you sure you want to delete this connector?"),r.a.createElement(ke.a,null,r.a.createElement(Ae.a,{disabled:b,onClick:C,color:"primary",size:"small"},"Yes"),r.a.createElement(Ae.a,{disabled:b,onClick:f,color:"primary",size:"small"},"No"),b&&r.a.createElement(Je,{size:12}))))};const Pl=Object(Ee.a)(e=>({smallSelect:{"& .MuiInputBase-root":{height:40},"& .MuiSelect-select":{fontSize:"0.875rem"},"& .MuiInputLabel-root":{transform:"translate(14px, 9px) scale(1)"},"& .MuiInputLabel-shrink":{transform:"translate(14px, -6px) scale(0.75)"}}}));var Rl=e=>{let{formik:a,disabled:t,onTypeChange:l,kafkaTopicsState:o}=e;const c=Pl(),[s,i]=Object(n.useState)([]),[d,m]=Object(n.useState)([]),u={"com.thingwings.MqttSourceConnector":[{value:"org.apache.kafka.connect.converters.ByteArrayConverter",label:"Byte Array Converter"}],"io.confluent.connect.elasticsearch.ElasticsearchSinkConnector":[{value:"org.apache.kafka.connect.json.JsonConverter",label:"JSON Converter"}],"io.confluent.connect.jdbc.JdbcSinkConnector":[{value:"io.confluent.connect.avro.AvroConverter",label:"Avro Converter"}]},p=Object(n.useCallback)(e=>{const t=e.target.value;a.setFieldValue("connectorClass",t),m(u[t]||[]),a.setFieldValue("valueConverter","")},[a]);return r.a.createElement(aa.a,{container:!0,spacing:3},r.a.createElement(aa.a,{item:!0,xs:12,sm:6},r.a.createElement($a.a,{fullWidth:!0,label:"Name",size:"small",variant:"outlined",name:"name",value:a.values.name,onChange:a.handleChange,onBlur:a.handleBlur,error:a.touched.name&&!!a.errors.name,helperText:a.touched.name&&a.errors.name?a.errors.name:""})),r.a.createElement(aa.a,{item:!0,xs:12,sm:6},r.a.createElement(pn.a,{className:c.smallSelect,variant:"outlined",fullWidth:!0,error:a.touched.type&&!!a.errors.type},r.a.createElement(gn.a,{htmlFor:"type"},"Type"),r.a.createElement(yn.a,{disabled:t,native:!0,label:"Type",value:a.values.type,onChange:e=>{const t=e.target.value;l(e),i("source"===t?[{value:"com.thingwings.MqttSourceConnector",label:"MQTT Connector"}]:[{value:"io.confluent.connect.elasticsearch.ElasticsearchSinkConnector",label:"Elasticsearch Connector"},{value:"io.confluent.connect.jdbc.JdbcSinkConnector",label:"PostgreSQL Connector"}]),a.setFieldValue("connectorClass",""),a.setFieldValue("valueConverter","")},onBlur:a.handleBlur},r.a.createElement("option",{"aria-label":"None",value:""}),r.a.createElement("option",{value:"source"},"Source"),r.a.createElement("option",{value:"sink"},"Sink")),a.touched.type&&a.errors.type&&r.a.createElement(ve.a,{color:"error.main"},a.errors.type))),r.a.createElement(aa.a,{item:!0,xs:12,sm:6},r.a.createElement(pn.a,{className:c.smallSelect,variant:"outlined",fullWidth:!0,error:a.touched.topic&&!!a.errors.topic},r.a.createElement(gn.a,{htmlFor:"topic"},"Topic"),r.a.createElement(yn.a,{disabled:t,native:!0,label:"Topic",name:"topic",value:a.values.topic,onChange:a.handleChange,onBlur:a.handleBlur},r.a.createElement("option",{"aria-label":"None",value:""}),o.map(e=>r.a.createElement("option",{key:e.id,value:e.id},e.name))),a.touched.topic&&a.errors.topic&&r.a.createElement(ve.a,{color:"error.main"},a.errors.topic))),r.a.createElement(aa.a,{item:!0,xs:12,sm:6},r.a.createElement(pn.a,{className:c.smallSelect,variant:"outlined",fullWidth:!0,error:a.touched.connectorClass&&!!a.errors.connectorClass},r.a.createElement(gn.a,{htmlFor:"connectorClass"},"Connector Class"),r.a.createElement(yn.a,{native:!0,label:"Connector Class",name:"connectorClass",value:a.values.connectorClass,onChange:p,onBlur:a.handleBlur},r.a.createElement("option",{"aria-label":"None",value:""}),s.map(e=>r.a.createElement("option",{key:e.value,value:e.value},e.label))),a.touched.connectorClass&&a.errors.connectorClass&&r.a.createElement(ve.a,{color:"error.main"},a.errors.connectorClass))),r.a.createElement(aa.a,{item:!0,xs:12,sm:12},r.a.createElement(pn.a,{className:c.smallSelect,variant:"outlined",fullWidth:!0,error:a.touched.valueConverter&&!!a.errors.valueConverter},r.a.createElement(gn.a,{htmlFor:"valueConverter"},"Value Converter"),r.a.createElement(yn.a,{native:!0,label:"Value Converter",name:"valueConverter",value:a.values.valueConverter,onChange:a.handleChange,onBlur:a.handleBlur},r.a.createElement("option",{"aria-label":"None",value:""}),d.map(e=>r.a.createElement("option",{key:e.value,value:e.value},e.label))),a.touched.valueConverter&&a.errors.valueConverter&&r.a.createElement(ve.a,{color:"error.main"},a.errors.valueConverter))))},Fl=t(731),Bl=t(111),Ll=t.n(Bl),Ul=t(470),Wl=t.n(Ul);Object(Ee.a)(e=>({}));var _l=e=>{let{formik:a,disabled:t}=e;const[l,o]=Object(n.useState)([]),[c,s]=Object(n.useState)(null),[i,m]=Object(n.useState)(!1),[u,p]=Object(n.useState)(""),[g,y]=Object(n.useState)(!1),{thingsDispatch:E,thingsState:b,handleAlert:h}=I();Object(n.useEffect)(()=>{le(async()=>{const e=await me();E({type:d.SET_THINGS,value:e})},y,h)()},[E]),Object(n.useEffect)(()=>{if(a.values.thing&&c){le(async()=>{const e=await ue(c.id);o(e)},y,h)()}},[a.values.thing,c]);const v=le(async()=>{if(!c||!u.trim())return;const e=await pe({aclUserId:c.id,thingId:c.thing_id,deviceId:c.device_id,topicPath:u,pubsub:3});o(a=>[...a,{acl_id:e.id,topic:"".concat(c.device_id,"/").concat(u),pubsub:3}]),p(""),m(!1),h(!0,"Permission added successfully","success")},y,h);return r.a.createElement(r.a.Fragment,null,r.a.createElement("br",null),r.a.createElement(aa.a,{container:!0,spacing:3},r.a.createElement(aa.a,{item:!0,xs:12,sm:6},r.a.createElement(pn.a,{variant:"outlined",fullWidth:!0,error:a.touched.thing&&!!a.errors.thing},r.a.createElement(gn.a,{htmlFor:"thing"},"Thing"),r.a.createElement(yn.a,{native:!0,disabled:t,label:"Thing",name:"thing",value:a.values.thing,onChange:e=>{const t=e.target.value;a.setFieldValue("thing",t);const n=b.find(e=>e.thing_id===Number(t));s(n)},onBlur:a.handleBlur},r.a.createElement("option",{"aria-label":"None",value:""}),b.map(e=>r.a.createElement("option",{key:e.thing_id,value:e.thing_id},e.name))),a.touched.thing&&a.errors.thing&&r.a.createElement(ve.a,{color:"error.main"},a.errors.thing))),r.a.createElement(aa.a,{item:!0,xs:12,sm:6},r.a.createElement(pn.a,{variant:"outlined",fullWidth:!0,error:a.touched.acl&&!!a.errors.acl},r.a.createElement(gn.a,{htmlFor:"acl"},"ACL"),r.a.createElement(yn.a,{disabled:t,label:"ACL",name:"acl",value:a.values.acl,onChange:a.handleChange,onBlur:a.handleBlur},r.a.createElement("option",{"aria-label":"None",value:""}),l.map(e=>r.a.createElement("option",{key:e.acl_id,value:e},e.topic))),a.touched.acl&&a.errors.acl&&r.a.createElement(ve.a,{color:"error.main"},a.errors.acl)),a.values.thing&&0===l.length&&r.a.createElement(r.a.Fragment,null,r.a.createElement("span",{style:{color:"red"}}," Add ACL to use this topic"),r.a.createElement(Le.a,{onClick:()=>m(!i)},r.a.createElement(Ll.a,null)),r.a.createElement(Fl.a,{in:i},r.a.createElement(ve.a,{display:"flex",alignItems:"center"},r.a.createElement($a.a,{label:"New Permission",value:u,onChange:e=>p(e.target.value),fullWidth:!0,variant:"outlined",margin:"normal"}),r.a.createElement(Le.a,{onClick:v},r.a.createElement(Wl.a,null))))))))},zl=t(138),ql=t.n(zl),Gl=t(258),Hl=t.n(Gl),Vl=t(259),Kl=t.n(Vl),Yl=t(261),Zl=t.n(Yl);const Xl=Object(Ht.a)(e=>({root:{flexGrow:1,padding:e.spacing(2)},paper:{padding:e.spacing(3),textAlign:"center",color:e.palette.text.secondary,boxShadow:"0 4px 6px rgba(0,0,0,0.1)",border:"2px dashed",borderColor:e.palette.grey[400],transition:"all 0.3s ease",height:150,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",cursor:"pointer",position:"relative","&:hover":{borderColor:e.palette.primary.main,backgroundColor:e.palette.action.hover},"&.dragover":{borderColor:e.palette.primary.main,backgroundColor:e.palette.primary.light}},fileSelected:{borderColor:e.palette.success.main,backgroundColor:e.palette.success.light},fileIcon:{fontSize:48,color:e.palette.grey[500],marginBottom:e.spacing(1)},fileName:{marginTop:e.spacing(1),wordBreak:"break-word"},uploadButton:{marginTop:e.spacing(3)},progressContainer:{marginTop:e.spacing(2),width:"100%"},fileChip:{marginTop:e.spacing(1)},errorChip:{marginTop:e.spacing(1)}}));var Jl=e=>{let{onUploadSuccess:a,onUploadError:t,onFileChange:l,disabled:o=!1}=e;const c=Xl(),[s,d]=Object(n.useState)(0),[m,u]=Object(n.useState)(!1),[p,g]=Object(n.useState)(Array.from({length:3},()=>null)),[y,E]=Object(n.useState)(null),[b,h]=Object(n.useState)({}),v=["SSL Cert","SSL Key","CA"],f=Object(n.useCallback)((e,a)=>{if(a){if(a.size>5242880)return void h(a=>Object(i.a)(Object(i.a)({},a),{},{[e]:"File too large (max 5MB)"}));if(!a.name.match(/\.(pem|crt|key|cer|der)$/i))return void h(a=>Object(i.a)(Object(i.a)({},a),{},{[e]:"Invalid file type (PEM, CRT, KEY, CER, DER)"}));h(a=>Object(i.a)(Object(i.a)({},a),{},{[e]:null}))}const t=[...p];t[e]=a,g(t),l&&l(t)},[p,l]),C=Object(n.useCallback)((e,a)=>{a.preventDefault(),E(e)},[]),S=Object(n.useCallback)((e,a)=>{a.preventDefault(),y===e&&E(null)},[y]),x=Object(n.useCallback)((e,a)=>{a.preventDefault(),E(null);const t=a.dataTransfer.files[0];t&&!p[e]&&f(e,t)},[p,f]),w=Object(n.useCallback)(async()=>{if(p.some(e=>!e))return void(t&&t("Please select all 3 certificate files"));if(Object.values(b).some(e=>e))t&&t("Fix file errors before uploading");else{u(!0);try{const e=await((e,a)=>{const t=new FormData;t.append("sslcert",e[0]),t.append("sslkey",e[1]),t.append("sslca",e[2]),B.a.post("".concat("https://www.thingwings.com/api/mqtt","/upload-ssl"),t,{headers:{"Content-Type":"multipart/form-data"},onUploadProgress:e=>{a(parseInt(Math.round(100*e.loaded/e.total)))}}).then(e=>e.data).catch(e=>{z(e)})})(p,d);a&&a(e.files||[]),d(0)}catch(e){console.error(e),t&&t("Upload failed: "+e.message),d(0)}finally{u(!1)}}},[p,b,a,t]);return r.a.createElement("div",{className:c.root},r.a.createElement(R,{severity:"info",icon:!1},r.a.createElement(We.a,{variant:"body2"},"Upload your SSL certificates (PEM, CRT, KEY, CER formats, max 5MB each).")),r.a.createElement(aa.a,{container:!0,spacing:3},p.map((e,a)=>r.a.createElement(aa.a,{item:!0,xs:12,sm:4,key:a},r.a.createElement(mt.a,{className:[c.paper,e&&!b[a]?c.fileSelected:null,y===a?"dragover":null].filter(Boolean).join(" "),onDragOver:e=>C(a,e),onDragLeave:e=>S(a,e),onDrop:e=>x(a,e),onClick:()=>!o&&document.getElementById("file-input-".concat(a)).click()},r.a.createElement("input",{id:"file-input-".concat(a),type:"file",style:{display:"none"},onChange:e=>f(a,e.target.files[0]),accept:".pem,.crt,.key,.cer,.der",disabled:o}),r.a.createElement(Hl.a,{className:c.fileIcon}),r.a.createElement(We.a,{variant:"h6",gutterBottom:!0},v[a]),r.a.createElement(We.a,{variant:"body2",color:"textSecondary"},e?"Ready":"Click or drag to upload"),((e,a)=>e?b[a]?r.a.createElement(il.a,{icon:r.a.createElement(Zl.a,null),label:b[a],color:"error",variant:"outlined",className:c.errorChip,size:"small"}):r.a.createElement(il.a,{icon:r.a.createElement(Kl.a,null),label:e.name,color:"success",variant:"outlined",className:c.fileChip,size:"small"}):r.a.createElement(il.a,{label:"Missing",color:"default",size:"small"}))(e,a))))),r.a.createElement(ve.a,{className:c.progressContainer},s>0&&r.a.createElement(ve.a,{mb:2},r.a.createElement(on.a,{variant:"determinate",value:s,color:"primary"}),r.a.createElement(We.a,{variant:"body2",align:"right"},Math.round(s),"%"))),r.a.createElement(Ae.a,{variant:"contained",color:"primary",startIcon:r.a.createElement(ql.a,null),className:c.uploadButton,onClick:w,disabled:m||o||p.some(e=>!e)||Object.values(b).some(Boolean)},m?"Uploading...":"Upload Certificates"))};const Ql=tt.c({dbname:tt.d().required("Database Name is required"),dbtype:tt.d().required("Database Type is required"),username:tt.d().required("Username is required"),password:tt.d().required("Password is required"),url:tt.d().required("URL is required")}),$l=Object(Ee.a)(e=>({smallSelect:{"& .MuiInputBase-root":{height:40,borderRadius:6},"& .MuiSelect-select":{padding:"8px 12px",fontSize:"0.875rem",textAlign:"center"}},formContainer:{padding:e.spacing(2)},actions:{marginTop:e.spacing(2),display:"flex",justifyContent:"flex-end",gap:e.spacing(1.5)}}));var eo=e=>{let{handleCloseNew:a,db:t,setLoading:l,handleAlert:o}=e;const c=$l(),{databasesDispatch:s}=I(),m=le(async e=>{const t=await(async e=>{try{return(await B.a.post("".concat(K),e)).data}catch(a){z(a)}})(e);s({type:d.ADD_DATABASE,database:Object(i.a)({id:t.insertId},e)}),a()},l,o),u=le(async(e,t)=>{await(async(e,a)=>{try{return(await B.a.put("".concat(K,"/").concat(e),a)).data}catch(t){z(t)}})(e,t),s({type:d.UPDATE_DATABASE,DatabaseId:e,name:t}),a()},l,o),p=Object(at.e)({initialValues:{dbname:(null===t||void 0===t?void 0:t.dbname)||"",dbtype:(null===t||void 0===t?void 0:t.dbtype)||"",username:(null===t||void 0===t?void 0:t.username)||"",password:(null===t||void 0===t?void 0:t.password)||"",url:(null===t||void 0===t?void 0:t.url)||""},validationSchema:Ql,onSubmit:e=>{t?u(t.id,e):m(e)}});return Object(n.useEffect)(()=>{p.setValues({dbname:(null===t||void 0===t?void 0:t.dbname)||"",dbtype:(null===t||void 0===t?void 0:t.dbtype)||"",username:(null===t||void 0===t?void 0:t.username)||"",password:(null===t||void 0===t?void 0:t.password)||"",url:(null===t||void 0===t?void 0:t.url)||""})},[t]),r.a.createElement("form",{onSubmit:p.handleSubmit},r.a.createElement(aa.a,{container:!0,spacing:2,className:c.formContainer},r.a.createElement(aa.a,{item:!0,xs:12,md:6},r.a.createElement($a.a,Object.assign({fullWidth:!0,label:"Database Name",variant:"outlined",size:"small",name:"dbname"},p.getFieldProps("dbname"),{error:p.touched.dbname&&Boolean(p.errors.dbname),helperText:p.touched.dbname&&p.errors.dbname}))),r.a.createElement(aa.a,{item:!0,xs:12,md:6},r.a.createElement(pn.a,{fullWidth:!0,variant:"outlined",size:"small",className:c.smallSelect,error:p.touched.dbtype&&Boolean(p.errors.dbtype)},r.a.createElement(gn.a,null,"Database Type"),r.a.createElement(yn.a,{label:"Database Type",name:"dbtype",value:p.values.dbtype,onChange:p.handleChange,onBlur:p.handleBlur},r.a.createElement(Nt.a,{value:""},r.a.createElement("em",null,"None")),r.a.createElement(Nt.a,{value:"elasticsearch"},"Elasticsearch"),r.a.createElement(Nt.a,{value:"postgres"},"Postgres")),r.a.createElement(En.a,null,p.touched.dbtype&&p.errors.dbtype))),r.a.createElement(aa.a,{item:!0,xs:12,md:6},r.a.createElement($a.a,Object.assign({fullWidth:!0,label:"Username",variant:"outlined",size:"small",name:"username"},p.getFieldProps("username"),{error:p.touched.username&&Boolean(p.errors.username),helperText:p.touched.username&&p.errors.username}))),r.a.createElement(aa.a,{item:!0,xs:12,md:6},r.a.createElement($a.a,Object.assign({fullWidth:!0,label:"Password",variant:"outlined",size:"small",type:"password",name:"password"},p.getFieldProps("password"),{error:p.touched.password&&Boolean(p.errors.password),helperText:p.touched.password&&p.errors.password}))),r.a.createElement(aa.a,{item:!0,xs:12},r.a.createElement($a.a,Object.assign({fullWidth:!0,label:"URL",variant:"outlined",size:"small",name:"url"},p.getFieldProps("url"),{error:p.touched.url&&Boolean(p.errors.url),helperText:p.touched.url&&p.errors.url})))),r.a.createElement(ke.a,{className:c.actions},r.a.createElement(Ae.a,{onClick:a,variant:"outlined",color:"default"},"Cancel"),r.a.createElement(Ae.a,{type:"submit",variant:"contained",color:"primary"},t?"Update":"Submit")))};const ao=Object(Ee.a)(e=>({smallSelect:{"& .MuiInputBase-root":{height:40},"& .MuiSelect-select":{fontSize:"0.875rem"}}}));var to=e=>{let{useCustomConfig:a,useMqttSSL:t,connectorType:l,formik:o,onCheckboxChange:c,onMqttSSLChange:s,disabled:i}=e;const m=ao(),[u,p]=Object(n.useState)(!1),[g,y]=Object(n.useState)(!1),{databasesDispatch:E,databasesState:b,handleAlert:h}=I();return r.a.useEffect(()=>{if(a&&"sink"===l){le(async()=>{const e=await ge();E({type:d.SET_DATABASES,value:e})},y,h)()}},[a,l,E]),r.a.createElement(r.a.Fragment,null,r.a.createElement(aa.a,{container:!0,spacing:3},r.a.createElement(aa.a,{item:!0,xs:12},r.a.createElement(bn.a,{control:r.a.createElement(zt.a,{checked:a,onChange:c,name:"useCustomConfig"}),label:"Use Custom Configuration"}))),r.a.createElement(Fl.a,{in:a,timeout:"auto",unmountOnExit:!0},r.a.createElement(aa.a,{container:!0,spacing:3},"source"===l?r.a.createElement(r.a.Fragment,null,r.a.createElement(aa.a,{item:!0,xs:12,sm:6},r.a.createElement($a.a,{size:"small",fullWidth:!0,label:"Username",variant:"outlined",name:"username",value:o.values.username,onChange:o.handleChange,onBlur:o.handleBlur,error:o.touched.username&&!!o.errors.username,helperText:o.touched.username&&o.errors.username})),r.a.createElement(aa.a,{item:!0,xs:12,sm:6},r.a.createElement($a.a,{size:"small",fullWidth:!0,label:"Password",variant:"outlined",name:"password",type:"password",value:o.values.password,onChange:o.handleChange,onBlur:o.handleBlur,error:o.touched.password&&!!o.errors.password,helperText:o.touched.password&&o.errors.password})),r.a.createElement(aa.a,{item:!0,xs:12,sm:6},r.a.createElement($a.a,{size:"small",fullWidth:!0,label:"Connection URL",variant:"outlined",name:"connectionUrl",value:o.values.connectionUrl,onChange:o.handleChange,onBlur:o.handleBlur,error:o.touched.connectionUrl&&!!o.errors.connectionUrl,helperText:o.touched.connectionUrl&&o.errors.connectionUrl})),r.a.createElement(aa.a,{item:!0,xs:12,sm:6},r.a.createElement($a.a,{size:"small",fullWidth:!0,label:"Source Topic",variant:"outlined",name:"sourceTopic",value:o.values.sourceTopic,onChange:o.handleChange,onBlur:o.handleBlur,error:o.touched.sourceTopic&&!!o.errors.sourceTopic,helperText:o.touched.sourceTopic&&o.errors.sourceTopic})),r.a.createElement(aa.a,{item:!0,xs:12,sm:6},r.a.createElement(bn.a,{control:r.a.createElement(zt.a,{checked:t,onChange:s,name:"useMqttSSL"}),label:"Use SSL"}))):"sink"===l?r.a.createElement(aa.a,{item:!0,xs:12},r.a.createElement(pn.a,{className:m.smallSelect,fullWidth:!0,variant:"outlined"},r.a.createElement(gn.a,null,"Select database"),r.a.createElement(yn.a,{label:"Select database",name:"dbId",value:o.values.dbId,onChange:e=>{const{value:a}=e.target;"add.db"===a?(p(!0),o.setFieldValue("dbId","")):o.handleChange(e)},onBlur:o.handleBlur},r.a.createElement(Nt.a,{key:"add.db",value:"add.db"},"Add new database"),b.map(e=>r.a.createElement(Nt.a,{key:e.id,value:e.id},e.dbname))))):null),r.a.createElement(Fl.a,{in:t&&"source"===l,timeout:"auto",unmountOnExit:!0},r.a.createElement(aa.a,{item:!0,xs:12},r.a.createElement(Jl,null)))),r.a.createElement(jt,{open:u,onClose:()=>p(!1),title:"Database Information",contentText:"Databases are used to store data received from Kafka server."},r.a.createElement(eo,{handleCloseNew:()=>p(!1),handleAlert:h,setLoading:y})))};const no=Object(Ee.a)(e=>({root:{margin:e.spacing(2)},button:{margin:e.spacing(1)}}));var ro=e=>{let{handleAlert:a,handleCloseForm:t,connectorType:l,connectorTopic:o,connectorThing:c,connectorPermission:s,setValues:m,disabled:u}=e;const p=no(),[g,y]=Object(n.useState)(!1),[E,b]=Object(n.useState)(!1),[h,v]=Object(n.useState)(!1),{connectorsDispatch:f,kafkaTopicsDispatch:C,kafkaTopicsState:S}=I(),x=Object(at.e)({initialValues:{name:"",type:l||"",topic:o||"",connectorClass:"",valueConverter:"",thing:c||"",acl:s||"",username:"",password:"",connectionUrl:"",sourceTopic:"",dbId:""},validationSchema:tt.c().shape({name:tt.d().required("Name is required"),type:tt.d().required("Connector Type is required"),topic:tt.d().required("Topic is required"),connectorClass:tt.d().required("Connector Class is required"),valueConverter:tt.d().required("Value Converter is required")}),onSubmit:le(async e=>{const n=await(async e=>{try{return(await B.a.post("".concat(Dl),e)).data}catch(a){z(a)}})(Object(i.a)({useCustomConfig:E,useMqttSSL:h},e));f({type:d.ADD_CONNECTOR,connector:n.concatenatedData}),m&&m(e=>Object(i.a)(Object(i.a)({},e),{},{connectors:Object(i.a)(Object(i.a)({},e.connectors),{},{[l]:n.concatenatedData})})),t(),a(!0,"Connector added successfully","success")},y,a)});return Object(n.useEffect)(()=>{le(async()=>{const e=await oe();C({type:d.SET_TOPICS,value:e.topics})},y,a)()},[C]),r.a.createElement(Ja.a,{className:p.root},r.a.createElement(Ft.a,{title:"Connector Information"}),r.a.createElement(Ce.a,null),r.a.createElement(Qa.a,null,g&&r.a.createElement(Je,{size:24}),r.a.createElement("br",null),r.a.createElement("form",{onSubmit:x.handleSubmit},r.a.createElement(Rl,{formik:x,disabled:u,kafkaTopicsState:S,onTypeChange:e=>{const a=e.target.value;x.setFieldValue("type",a)}}),"source"===x.values.type&&!E&&r.a.createElement(_l,{formik:x,disabled:u}),r.a.createElement(to,{useCustomConfig:E,useMqttSSL:h,connectorType:x.values.type,formik:x,onCheckboxChange:e=>{b(e.target.checked)},onMqttSSLChange:e=>{v(e.target.checked)},disabled:u}),r.a.createElement(ve.a,{display:"flex",justifyContent:"flex-end"},r.a.createElement(Ae.a,{type:"submit",variant:"contained",color:"primary",className:p.button,disabled:g},g?"Saving...":"Save")))))};const lo=Object(Ht.a)(e=>({formContainer:{padding:e.spacing(3)},formField:{marginBottom:e.spacing(2)},formButton:{marginTop:e.spacing(2)}}));var oo=e=>{let{initialValues:a,onSubmit:t}=e;const n=lo(),l=tt.c({name:tt.d().required("Name is required"),topics:tt.d().required("Topics are required"),connectorClass:tt.d().required("Connector Class is required")}),o=Object(i.a)(Object(i.a)({},a),{},{topics:(e=>{const a=null===e||void 0===e?void 0:e.indexOf("_");return-1===a?"":null===e||void 0===e?void 0:e.substring(a+1)})(a.topics)});return r.a.createElement(at.d,{initialValues:o,validationSchema:l,onSubmit:t},e=>{let{values:a,handleChange:t,handleBlur:l,handleSubmit:o,touched:c,errors:s,isSubmitting:i}=e;return r.a.createElement(at.c,{onSubmit:o,className:n.formContainer},r.a.createElement(aa.a,{container:!0,spacing:3},r.a.createElement(aa.a,{item:!0,xs:12,sm:6},r.a.createElement($a.a,{fullWidth:!0,label:"Name",variant:"outlined",name:"name",value:a.name,onChange:t,onBlur:l,error:c.name&&!!s.name,helperText:c.name&&s.name?s.name:"",className:n.formField})),r.a.createElement(aa.a,{item:!0,xs:12,sm:6},r.a.createElement($a.a,{fullWidth:!0,label:"Topics",variant:"outlined",name:"topics",value:a.topics,onChange:t,onBlur:l,error:c.topics&&!!s.topics,helperText:c.topics&&s.topics?s.topics:"",className:n.formField})),r.a.createElement(aa.a,{item:!0,xs:12},r.a.createElement($a.a,{fullWidth:!0,label:"Connector Class",variant:"outlined",name:"connectorClass",value:a.connectorClass,onChange:t,onBlur:l,error:c.connectorClass&&!!s.connectorClass,helperText:c.connectorClass&&s.connectorClass?s.connectorClass:"",className:n.formField}))))})};const co=Object(Ee.a)(e=>({root:{padding:e.spacing(3)},pagination:{marginTop:e.spacing(3),display:"flex",alignItems:"center",justifyContent:"flex-end"}}));var so=e=>{let{history:a}=e;const t=co(),[l,o]=Object(n.useState)(!1),[c,s]=Object(n.useState)(!1),[m,u]=Object(n.useState)(""),[p,g]=Object(n.useState)({open:!1,message:"",severity:"info"}),{connectorsState:y,connectorsDispatch:E,connectorInfoState:b}=I(),[h,v]=Object(n.useState)(""),[f,C]=Object(n.useState)(1),S=e=>{u(e)},x=()=>{u("")},w=(e,a,t)=>{g({open:e,message:a,severity:t})};Object(n.useEffect)(()=>{le(async()=>{const e=await(async()=>{try{return(await B.a.get("".concat(Dl))).data}catch(e){z(e)}})();E({type:d.SET_CONNECTORS,value:e})},o,w)()},[E]);const O=y.filter(e=>e.name.toLowerCase().includes(h.toLowerCase())),A=12*f,T=A-12,j=O.slice(T,A),k=e=>{"next"===e&&fe+1):"prev"===e&&f>1&&C(e=>e-1)};return r.a.createElement(r.a.Fragment,null,r.a.createElement(R,{open:p.open,message:p.message,onClose:()=>{g(e=>Object(i.a)(Object(i.a)({},e),{},{open:!1}))},severity:p.severity}),r.a.createElement(xt,{title:"Connector",handleSearch:e=>{v(e.target.value)},openForm:S}),l?r.a.createElement(Je,null):r.a.createElement(aa.a,{container:!0,spacing:3},r.a.createElement(aa.a,{item:!0,xs:12},r.a.createElement(Ce.a,null)," "),j.map(e=>r.a.createElement(aa.a,{item:!0,key:e.id,xs:12,sm:6,md:4,lg:3},r.a.createElement(Ml,{history:a,name:e.name,id:e.id,status:e.status,config:e.config,handleAlert:w,openForm:S})))),r.a.createElement("div",{className:t.pagination},r.a.createElement(Le.a,{onClick:()=>k("prev"),disabled:1===f},r.a.createElement(jl.a,null)),r.a.createElement(We.a,{variant:"caption"},"".concat(f," of ").concat(Math.ceil(O.length/12))),r.a.createElement(Le.a,{onClick:()=>k("next"),disabled:f===Math.ceil(O.length/12)},r.a.createElement(Al.a,null))),r.a.createElement(Ne.a,{open:Boolean(m),onClose:x},"ADD"===m?r.a.createElement(ro,{handleAlert:w,handleCloseForm:x}):"INFO"===m?r.a.createElement(r.a.Fragment,null,r.a.createElement(Te.a,{disableTypography:!1},b.name),r.a.createElement(je.a,{dividers:!0},r.a.createElement(oo,{initialValues:b}))):null))},io=t(797),mo=t(796);const uo=q+"/auth";var po=t(424),go=t(113),yo=t.n(go),Eo=t(208),bo=t.n(Eo);const ho=Object(Ht.a)(e=>({root:{display:"flex",justifyContent:"center",alignItems:"center",padding:e.spacing(2),backgroundColor:e.palette.background.default},paper:{marginTop:40,width:"100%",maxWidth:600,padding:e.spacing(4),backgroundColor:e.palette.background.paper,borderRadius:e.shape.borderRadius,boxShadow:e.shadows[5]},submit:{margin:e.spacing(3,0,2)}})),vo=e=>{const[a,t]=Object(n.useState)(e);return{value:a,onChange:e=>t(e.target.value)}};var fo=e=>{let{onSubmit:a,loading:t,title:l}=e;const o=ho(),[c,s]=Object(n.useState)(!1),[i,d]=Object(n.useState)(!1),m=vo(""),u=vo("");return r.a.createElement(mo.a,{className:o.root,component:"main",maxWidth:"xs"},r.a.createElement("div",{className:o.paper},r.a.createElement(We.a,{variant:"h6"},l),r.a.createElement($a.a,Object.assign({type:c?"text":"password"},m,{variant:"outlined",margin:"normal",required:!0,fullWidth:!0,label:"New Password",name:"newPassword",size:"small",InputProps:{endAdornment:r.a.createElement(po.a,{position:"end"},r.a.createElement(Le.a,{onClick:()=>s(e=>!e),edge:"end"},c?r.a.createElement(yo.a,null):r.a.createElement(bo.a,null)))}})),r.a.createElement($a.a,Object.assign({type:i?"text":"password"},u,{variant:"outlined",margin:"normal",required:!0,fullWidth:!0,label:"Confirm Password",name:"confirmPassword",size:"small",InputProps:{endAdornment:r.a.createElement(po.a,{position:"end"},r.a.createElement(Le.a,{onClick:()=>d(e=>!e),edge:"end"},i?r.a.createElement(yo.a,null):r.a.createElement(bo.a,null)))}})),r.a.createElement(Ae.a,{type:"submit",fullWidth:!0,variant:"contained",color:"primary",className:o.submit,onClick:e=>{e.preventDefault(),a(m.value,u.value)},disabled:t},t?r.a.createElement(Je,null):"Submit")))};var Co=()=>{const[e,a]=Object(n.useState)(!1),[t,l]=Object(n.useState)({open:!1,message:"",severity:"info"}),[o,c]=Object(n.useState)(!1),s=Object(n.useCallback)((e,a,t)=>{l({open:e,message:a,severity:t})},[]),d=Object(n.useCallback)(()=>l(e=>Object(i.a)(Object(i.a)({},e),{},{open:!1})),[]),m=le(async(e,a)=>{if(e===a)try{await(async e=>{try{return(await B.a.post("".concat(uo,"/password-reset"),{newPassword:e})).data}catch(a){console.log(a),z(a)}})(e),s(!0,"Password successfully updated.","success"),c(!0)}catch(t){console.error(t),s(!0,"An error occurred while updating your password.","error")}else s(!0,"Passwords do not match","error")},a,s);return r.a.createElement(mo.a,{component:"main",maxWidth:"xs"},r.a.createElement(io.a,null),r.a.createElement(R,{open:t.open,message:t.message,onClose:d,severity:t.severity}),r.a.createElement("div",null,r.a.createElement(fo,{title:o?"Success":"Update Password",onSubmit:m,loading:e})))};var So=()=>r.a.createElement(r.a.Fragment,null,r.a.createElement(io.a,null),r.a.createElement(Co,null));const xo=Object(Ht.a)(e=>({root:{display:"flex",justifyContent:"center",alignItems:"center",padding:e.spacing(2)},paper:{marginTop:40,width:"100%",maxWidth:600,padding:e.spacing(4),backgroundColor:e.palette.background.paper,borderRadius:e.shape.borderRadius,boxShadow:e.shadows[5]},avatar:{margin:e.spacing(1),backgroundColor:e.palette.secondary.main},form:{width:"100%",marginTop:e.spacing(1)},submit:{margin:e.spacing(3,0,2)},link:{margin:5,"&:hover":{textDecoration:"underline",color:e.palette.secondary.main}}})),wo=e=>{const[a,t]=Object(n.useState)(e);return{value:a,onChange:e=>t(e.target.value)}};var Oo=()=>{const[e,a]=Object(n.useState)(!1),[t,l]=Object(n.useState)({open:!1,message:"",severity:"info"}),o=Object(n.useCallback)((e,a,t)=>{l({open:e,message:a,severity:t})},[]),c=Object(n.useCallback)(()=>l(e=>Object(i.a)(Object(i.a)({},e),{},{open:!1})),[]),s=wo(""),d=wo(""),m=xo(),u=le(async()=>{const e=await(async e=>{try{return(await B.a.post("".concat(uo,"/login"),e)).data}catch(a){z(a)}})({identifier:s.value,password:d.value});var a;_(e.token,e.user,{}),a={},localStorage.setItem("notifications",JSON.stringify(a)),window.location.reload()},a,o),p=async e=>{"Enter"===e.key&&await u()};return r.a.createElement(mo.a,{className:m.root,component:"main",maxWidth:"xs"},r.a.createElement(io.a,null),r.a.createElement(R,{open:t.open,message:t.message,onClose:c,severity:t.severity}),r.a.createElement("div",{className:m.paper},r.a.createElement("div",{style:{display:"flex",justifyContent:"center"}},r.a.createElement("img",{src:"signin.png",alt:"BeeMetrix",width:"250px"})),r.a.createElement("div",{className:m.form},r.a.createElement($a.a,Object.assign({type:"text"},s,{autoComplete:"username",variant:"outlined",margin:"normal",required:!0,fullWidth:!0,id:"username",label:"Username/Email",name:"username",onKeyDown:p,autoFocus:!0,size:"small"})),r.a.createElement($a.a,Object.assign({type:"password"},d,{autoComplete:"new-password",variant:"outlined",margin:"normal",required:!0,fullWidth:!0,onKeyDown:p,id:"password",label:"Password",name:"password",size:"small"})),r.a.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},r.a.createElement(bn.a,{control:r.a.createElement(zt.a,{value:"remember",color:"primary"}),label:"Remember me"}),r.a.createElement(pa.a,{component:Ke.a,to:"/request-token?type=password-reset",className:m.link},"Forgot password ?")),r.a.createElement(Ae.a,{type:"submit",fullWidth:!0,variant:"contained",color:"primary",className:m.submit,onClick:u,disabled:e},e?"Loading...":"Sign In"),e&&r.a.createElement(Je,null),r.a.createElement("p",null,"Don't have an account?",r.a.createElement(pa.a,{component:Ke.a,to:"/signup",className:m.link},"Register Now")))))};const Ao=Object(Ee.a)(e=>({root:{backgroundColor:e.palette.background.default,display:"flex",justifyContent:"center",alignItems:"center",padding:e.spacing(2)},formContainer:{marginTop:30,width:"100%",maxWidth:400,padding:e.spacing(3),backgroundColor:e.palette.background.paper,borderRadius:e.shape.borderRadius,boxShadow:e.shadows[5]},signUpButton:{margin:e.spacing(2,0)},loginButton:{marginTop:e.spacing(2)}}));var To=Object(c.j)(()=>{const e=Ao(),[a,t]=Object(n.useState)(!1),[l,o]=Object(n.useState)({open:!1,message:"",severity:""}),[c,s]=Object(n.useState)(!1),d=tt.c().shape({name:tt.d().required("Name is required"),username:tt.d().required("Username is required"),email:tt.d().email("Invalid email").required("Email is required"),organization:tt.d().required("Organization is required"),password:tt.d().min(6,"Password must be at least 6 characters").required("Password is required"),country:tt.d().required("Country is required"),city:tt.d().required("City is required"),address:tt.d().required("Address is required"),currency:tt.d().required("Currency is required")}),m=le(async(e,a)=>{let{setSubmitting:t,resetForm:n}=a;await ot(!1,e),t(!1),n(),s(!0)},t,(e,a,t)=>{o({open:e,message:a,severity:t})});return r.a.createElement("div",{className:e.root},r.a.createElement(R,{open:l.open,message:l.message,onClose:()=>{o(e=>Object(i.a)(Object(i.a)({},e),{},{open:!1}))},severity:l.severity}),c?r.a.createElement("div",{className:e.formContainer},r.a.createElement(We.a,{variant:"h5",align:"center"},"Check your email!"),r.a.createElement(We.a,{color:"textSecondary",align:"center"},"An email has been sent to you. Please check your inbox to verify your account."),r.a.createElement(Ae.a,{component:Ke.a,to:"/signin",variant:"contained",color:"primary",className:e.loginButton,fullWidth:!0},"Go to Login")):r.a.createElement(at.d,{initialValues:{name:"",username:"",email:"",organization:"",password:"",country:"",city:"",address:"",currency:""},validationSchema:d,onSubmit:m},t=>{let{isSubmitting:n,errors:l,touched:o,values:c,handleChange:s,setFieldValue:i}=t;return r.a.createElement(at.c,{className:e.formContainer},r.a.createElement(We.a,{variant:"h5",align:"center"},"Create new account"),r.a.createElement(We.a,{color:"textSecondary",gutterBottom:!0,align:"center"},"Use your email to create new account"),r.a.createElement(aa.a,{style:{marginTop:10},container:!0,spacing:2},r.a.createElement(aa.a,{item:!0,xs:12,sm:6},r.a.createElement(at.b,{as:$a.a,size:"small",fullWidth:!0,label:"First/Last Name",name:"name",variant:"outlined",error:o.name&&!!l.name,helperText:o.name&&l.name})),r.a.createElement(aa.a,{item:!0,xs:12,sm:6},r.a.createElement(at.b,{as:$a.a,size:"small",fullWidth:!0,label:"Username",name:"username",variant:"outlined",error:o.username&&!!l.username,helperText:o.username&&l.username})),r.a.createElement(aa.a,{item:!0,xs:12},r.a.createElement(at.b,{as:$a.a,size:"small",fullWidth:!0,label:"Email address",name:"email",variant:"outlined",error:o.email&&!!l.email,helperText:o.email&&l.email})),r.a.createElement(aa.a,{item:!0,xs:12},r.a.createElement(at.b,{as:$a.a,size:"small",fullWidth:!0,label:"Organization",name:"organization",variant:"outlined",error:o.organization&&!!l.organization,helperText:o.organization&&l.organization})),r.a.createElement(aa.a,{item:!0,xs:12},r.a.createElement(at.b,{as:$a.a,size:"small",fullWidth:!0,label:"Password",name:"password",type:"password",variant:"outlined",error:o.password&&!!l.password,helperText:o.password&&l.password})),r.a.createElement(aa.a,{item:!0,xs:12,sm:8},r.a.createElement(pn.a,{fullWidth:!0,variant:"outlined",size:"small",error:o.country&&!!l.country},r.a.createElement(gn.a,null,"Country"),r.a.createElement(yn.a,{label:"Country",name:"country",value:c.country,onChange:e=>{if(s(e),"country"===e.target.name){const a=hn.find(a=>a.code===e.target.value);i("currency",a?a.currency:"")}}},hn.map(e=>r.a.createElement(Nt.a,{key:e.code,value:e.code},e.name))),o.country&&l.country&&r.a.createElement(We.a,{variant:"body2",color:"error"},l.country))),r.a.createElement(aa.a,{item:!0,xs:12,sm:4},r.a.createElement($a.a,{size:"small",fullWidth:!0,label:"Currency",name:"currency",variant:"outlined",value:c.currency,InputProps:{readOnly:!0}})),r.a.createElement(aa.a,{item:!0,xs:12},r.a.createElement(at.b,{as:$a.a,size:"small",fullWidth:!0,label:"City",name:"city",variant:"outlined",error:o.city&&!!l.city,helperText:o.city&&l.city})),r.a.createElement(aa.a,{item:!0,xs:12},r.a.createElement(at.b,{as:$a.a,size:"small",fullWidth:!0,label:"Address",name:"address",variant:"outlined",error:o.address&&!!l.address,helperText:o.address&&l.address}))),n||a?r.a.createElement(Je,null):r.a.createElement(Ae.a,{className:e.signUpButton,color:"primary",fullWidth:!0,size:"large",type:"submit",variant:"contained"},"Sign up now"),r.a.createElement(We.a,{color:"textSecondary",variant:"body1",align:"center"},"Already have an account?"," ",r.a.createElement(pa.a,{component:Ke.a,to:"/signin"},"Sign in")))}))});var jo=e=>{let{open:a,onClose:t,initialValues:l,handleAlertOpen:o}=e;const[c,s]=Object(n.useState)(!1),{usersDispatch:m}=I(),u=tt.c({name:tt.d().required("Name is required"),username:tt.d().required("Username is required"),email:tt.d().email("Invalid email").required("Email is required"),organization:tt.d().required("Organization is required"),password:tt.d().min(6,"Password must be at least 6 characters").required("Password is required"),country:tt.d().required("Country is required"),city:tt.d().required("City is required"),address:tt.d().required("Address is required")}),p=e=>{const a=hn.find(a=>a.code===e.country);return Object(i.a)(Object(i.a)({},e),{},{currency:(null===a||void 0===a?void 0:a.currency)||"",symbol:(null===a||void 0===a?void 0:a.symbol)||""})},g=le(async e=>{const a=p(e),n=await ot(!0,a);m({type:d.ADD_USER,value:Object(i.a)({id:n.id},a)}),o(!0,"User added successfully","success"),t()},s,o),y=le(async e=>{const a=p(e);await ct(!0,a),m({type:d.UPDATE_USER,userId:l.id,value:a}),o(!0,"User updated successfully","success"),t()},s,o),E=le(async()=>{await(async e=>{try{return(await B.a.delete("".concat(nt,"/").concat(e))).data}catch(a){z(a)}})(l.id),m({type:d.DELETE_USER,userId:l.id}),o(!0,"User deleted successfully","success"),t()},s,o);return r.a.createElement(r.a.Fragment,null,"DELETE"===a?r.a.createElement(Ne.a,{open:!0,onClose:t,maxWidth:"xs",fullWidth:!0},r.a.createElement(Te.a,null,"Confirm Deletion"),r.a.createElement(je.a,null,r.a.createElement(We.a,null,"Are you sure you want to delete this user?")),r.a.createElement(ke.a,null,r.a.createElement(Ae.a,{onClick:t,color:"primary"},"Cancel"),r.a.createElement(Ae.a,{disabled:c,onClick:E,color:"secondary"}," ",c?"Processing ...":"Confirm"))):"ADD"===a||"EDIT"===a?r.a.createElement(Ne.a,{open:Boolean(a),onClose:t,maxWidth:"xs",fullWidth:!0},r.a.createElement(Te.a,null,"EDIT"===a?"Edit User":"Add User"),r.a.createElement(je.a,null,r.a.createElement(at.d,{initialValues:l,validationSchema:u,onSubmit:async e=>{"EDIT"===a?await y(e):"ADD"===a&&await g(e)}},e=>{let{values:n,handleChange:l,handleBlur:o,errors:s,touched:i}=e;return r.a.createElement(at.c,null,r.a.createElement(aa.a,{container:!0,spacing:2,style:{backgroundColor:"#f9f9f9",padding:"8px",borderRadius:"4px"}},r.a.createElement(aa.a,{item:!0,xs:12,sm:6},r.a.createElement(at.b,{as:$a.a,name:"name",label:"Name",fullWidth:!0,variant:"outlined",size:"small",value:n.name,onChange:l,onBlur:o,error:i.name&&!!s.name,helperText:i.name&&s.name})),r.a.createElement(aa.a,{item:!0,xs:12,sm:6},r.a.createElement(at.b,{as:$a.a,name:"username",label:"Username",fullWidth:!0,variant:"outlined",size:"small",value:n.username,onChange:l,onBlur:o,error:i.username&&!!s.username,helperText:i.username&&s.username})),r.a.createElement(aa.a,{item:!0,xs:12},r.a.createElement(at.b,{as:$a.a,name:"email",label:"Email",fullWidth:!0,variant:"outlined",size:"small",value:n.email,onChange:l,onBlur:o,error:i.email&&!!s.email,helperText:i.email&&s.email})),"ADD"===a&&r.a.createElement(aa.a,{item:!0,xs:12},r.a.createElement(at.b,{as:$a.a,name:"organization",label:"Organization",fullWidth:!0,variant:"outlined",size:"small",value:n.organization,onChange:l,onBlur:o,error:i.organization&&!!s.organization,helperText:i.organization&&s.organization})),r.a.createElement(aa.a,{item:!0,xs:12},r.a.createElement(at.b,{as:$a.a,name:"password",label:"Password",type:"password",fullWidth:!0,variant:"outlined",size:"small",value:n.password,onChange:l,onBlur:o,error:i.password&&!!s.password,helperText:i.password&&s.password})),r.a.createElement(aa.a,{item:!0,xs:12,sm:6},r.a.createElement(pn.a,{fullWidth:!0,variant:"outlined",size:"small",error:i.country&&!!s.country},r.a.createElement(gn.a,null,"Country"),r.a.createElement(yn.a,{name:"country",label:"Country",value:n.country,onChange:l,onBlur:o},hn.map(e=>r.a.createElement(Nt.a,{key:e.code,value:e.code},e.name))),i.country&&s.country&&r.a.createElement(We.a,{variant:"caption",color:"error"},s.country))),r.a.createElement(aa.a,{item:!0,xs:12,sm:6},r.a.createElement(at.b,{as:$a.a,name:"city",label:"City",fullWidth:!0,variant:"outlined",size:"small",value:n.city,onChange:l,onBlur:o,error:i.city&&!!s.city,helperText:i.city&&s.city})),r.a.createElement(aa.a,{item:!0,xs:12},r.a.createElement(at.b,{as:$a.a,name:"address",label:"Address",fullWidth:!0,variant:"outlined",size:"small",value:n.address,onChange:l,onBlur:o,error:i.address&&!!s.address,helperText:i.address&&s.address}))),r.a.createElement(ke.a,{style:{paddingRight:16,paddingTop:10}},r.a.createElement(Ae.a,{onClick:t,color:"primary"},"Cancel"),r.a.createElement(Ae.a,{type:"submit",color:"primary",disabled:c},c?"Processing ...":"EDIT"===a?"Update":"Add"),c&&r.a.createElement(Je,{size:20})))}))):null)};const ko=Object(Ht.a)(e=>({tableContainer:{padding:10,overflow:"auto",maxHeight:"calc(100vh - 220px)","& .MuiTableCell-root":{padding:"10px"},"& .MuiPaper-elevation4":{boxShadow:"0 0 0 0"},[e.breakpoints.down("sm")]:{maxWidth:"90vw",overflowX:"auto"}}}));function No(){const e=ko(),[a,t]=Object(n.useState)(!1),{usersState:l,usersDispatch:o}=I(),[c,s]=Object(n.useState)(null),[m,u]=Object(n.useState)(""),[p,g]=Object(n.useState)({open:!1,message:"",severity:""}),[y,E]=Object(n.useState)(""),b=e=>u(e),h=(e,a,t)=>g({open:e,message:a,severity:t});Object(n.useEffect)(()=>{le(async()=>{const e=await lt();o({type:d.SET_USERS,value:e})},t,h)()},[o]);const v=(e,a)=>{"ADD"!==a&&s(e),b(a)},f=l.filter(e=>e.name.toLowerCase().includes(y.toLowerCase()));return r.a.createElement(r.a.Fragment,null,r.a.createElement(R,{open:p.open,message:p.message,onClose:()=>g(e=>Object(i.a)(Object(i.a)({},e),{},{open:!1})),severity:p.severity}),a?r.a.createElement(Je,null):r.a.createElement(r.a.Fragment,null,r.a.createElement(xt,{title:"User",handleSearch:e=>{E(e.target.value)},openForm:b}),r.a.createElement(Bt.a,{className:e.tableContainer,component:mt.a},r.a.createElement(Lt.a,null,r.a.createElement(Ut.a,null,r.a.createElement(Wt.a,null,r.a.createElement(_t.a,null,"Name"),r.a.createElement(_t.a,null,"Username"),r.a.createElement(_t.a,null,"Email"),r.a.createElement(_t.a,null,"Organization"),r.a.createElement(_t.a,null,"Country"),r.a.createElement(_t.a,null,"Status"),r.a.createElement(_t.a,null,"Actions"))),r.a.createElement(qt.a,null,f.map(e=>r.a.createElement(Wt.a,{key:e.id},r.a.createElement(_t.a,null,e.name),r.a.createElement(_t.a,null,e.username),r.a.createElement(_t.a,null,e.email),r.a.createElement(_t.a,null,e.organization),r.a.createElement(_t.a,null,e.country),r.a.createElement(_t.a,null,r.a.createElement(il.a,{label:e.active?"Active":"Inactive",color:e.active?"primary":"secondary",style:{backgroundColor:e.active?"#4caf50":"#f44336",color:"#fff",fontWeight:"bold"},size:"small"})),r.a.createElement(_t.a,null,r.a.createElement(Le.a,{onClick:()=>v(e,"EDIT"),"aria-label":"edit"},r.a.createElement(Qn.a,null)),r.a.createElement(Le.a,{onClick:()=>v(e,"DELETE"),"aria-label":"delete"},r.a.createElement(Yn.a,null)))))))),r.a.createElement(jo,{open:m,onClose:()=>u(""),handleAlertOpen:h,initialValues:"EDIT"===m||"DELETE"===m?c:{name:"",username:"",email:"",organization:"",password:""}})))}var Do=t(265),Io=t.n(Do),Mo=t(266),Po=t.n(Mo);const Ro=tt.c({modelName:tt.d().required("API Name is required"),modelID:tt.d().required("Model ID is required"),host:tt.d().required("Host is required"),topic:tt.d().required("Topic is required")});var Fo=e=>{let{initialValues:a,isEditMode:t,handleAlert:l,onClose:o,setValues:c,topic:s}=e;const{kafkaTopicsState:m,kafkaTopicsDispatch:u,apisDispatch:p}=I(),[g,y]=Object(n.useState)(!1);Object(n.useEffect)(()=>{le(async()=>{const e=await oe();u({type:d.SET_TOPICS,value:e.topics})},y,l)()},[]);const E=Object(at.e)({initialValues:a||{modelName:"",modelID:"",username:"",password:"",host:"",topic:s||"",Apikey:""},validationSchema:Ro,onSubmit:le(async e=>{if(t)await(async e=>{try{return(await B.a.put("".concat(J,"/").concat(e.id),e)).data}catch(a){z(a)}})(e),l(!0,"API updated successfully","success"),p({type:d.UPDATE_API,value:e});else{const a=await(async e=>{try{return(await B.a.post("".concat(J),e)).data}catch(a){z(a)}})(e);E.resetForm(),l(!0,"API added successfully","success"),p({type:d.ADD_API,value:a}),c&&c(e=>Object(i.a)(Object(i.a)({},e),{},{api:a}))}await o()},y,l)});return r.a.createElement("form",{onSubmit:E.handleSubmit},r.a.createElement(Qa.a,null,r.a.createElement(aa.a,{container:!0,spacing:3},r.a.createElement(aa.a,{item:!0,md:6,sm:12,xs:12},r.a.createElement($a.a,{fullWidth:!0,label:"API Name",name:"modelName",variant:"outlined",margin:"dense",value:E.values.modelName,onChange:E.handleChange,error:E.touched.modelName&&Boolean(E.errors.modelName),helperText:E.touched.modelName&&E.errors.modelName}),r.a.createElement($a.a,{fullWidth:!0,label:"Host",name:"host",variant:"outlined",margin:"dense",value:E.values.host,onChange:E.handleChange,error:E.touched.host&&Boolean(E.errors.host),helperText:E.touched.host&&E.errors.host}),r.a.createElement($a.a,{fullWidth:!0,label:"Username",name:"username",variant:"outlined",margin:"dense",value:E.values.username,onChange:E.handleChange})),r.a.createElement(aa.a,{item:!0,md:6,sm:12,xs:12},r.a.createElement(pn.a,{fullWidth:!0,variant:"outlined",margin:"dense"},r.a.createElement(gn.a,{htmlFor:"topic"},"Topic"),r.a.createElement(yn.a,{disabled:s,native:!0,label:"Topic",name:"topic",value:E.values.topic,onChange:E.handleChange,error:E.touched.topic&&Boolean(E.errors.topic)},r.a.createElement("option",{"aria-label":"None",value:""}),m.map(e=>r.a.createElement("option",{key:e.name,value:e.id},e.name))),E.touched.topic&&E.errors.topic&&r.a.createElement(We.a,{color:"error"},E.errors.topic)),r.a.createElement($a.a,{fullWidth:!0,label:"Model ID",name:"modelID",variant:"outlined",margin:"dense",value:E.values.modelID,onChange:E.handleChange,error:E.touched.modelID&&Boolean(E.errors.modelID),helperText:E.touched.modelID&&E.errors.modelID}),r.a.createElement($a.a,{fullWidth:!0,label:"Password",name:"password",type:"password",variant:"outlined",margin:"dense",value:E.values.password,onChange:E.handleChange})),r.a.createElement(aa.a,{item:!0,md:12,sm:12,xs:12},r.a.createElement($a.a,{fullWidth:!0,label:"API Key",name:"Apikey",variant:"outlined",margin:"dense",value:E.values.Apikey,onChange:E.handleChange})))),r.a.createElement(ke.a,null,r.a.createElement(aa.a,{container:!0,spacing:3},r.a.createElement(aa.a,{item:!0,md:12,sm:12,xs:12},r.a.createElement(Ce.a,null))),r.a.createElement(Ae.a,{type:"submit",color:"primary",variant:"contained"},t?"Update":"Save"),g&&r.a.createElement(Je,null)))};const Bo=["className","product","handleAlert"],Lo=Object(Ee.a)(e=>({root:{maxWidth:"100%",margin:"0 auto"},imageContainer:{height:64,width:64,margin:"0 auto",border:"1px solid ".concat(e.palette.divider),borderRadius:"5px",overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center"},image:{width:"100%"},statsItem:{display:"flex",alignItems:"center"},statsIcon:{color:e.palette.icon,marginRight:e.spacing(1)},avatar:{backgroundColor:e.palette.primary.main}}));var Uo=Object(n.memo)(e=>{let{className:a,product:t,handleAlert:l}=e,o=Object(Se.a)(e,Bo);const c=Lo(),{apisDispatch:s}=I(),[i,m]=Object(n.useState)(!1),[u,p]=Object(n.useState)(!1),[g,y]=Object(n.useState)(!1),E=()=>{p(!1)},b=()=>{y(!1)},h=le(async()=>{await(async e=>{try{return(await B.a.delete("".concat(J,"/").concat(e))).data}catch(a){z(a)}})(t.id),await s({type:d.DELETE_API,apiId:t.id}),l(!0,"API deleted successfully")},m,l);return r.a.createElement(r.a.Fragment,null,r.a.createElement(Ja.a,Object.assign({},o,{className:Object(xe.a)(c.root,a)}),r.a.createElement(Ft.a,{avatar:r.a.createElement(Ue.a,{"aria-label":"recipe",className:c.avatar},t.modelName.charAt(0).toUpperCase()),action:r.a.createElement(r.a.Fragment,null,r.a.createElement(Le.a,{"aria-label":"edit",onClick:()=>{y(!0)}},r.a.createElement(sn.a,null)),r.a.createElement(Le.a,{"aria-label":"delete",onClick:()=>{p(!0)}},r.a.createElement(tn.a,null))),title:t.modelName,subheader:t.id}),r.a.createElement(Qa.a,null,r.a.createElement("div",{className:c.imageContainer},r.a.createElement("img",{alt:"Product",className:c.image,src:"/images/products/product_2.png"})),r.a.createElement(We.a,{align:"center",gutterBottom:!0,variant:"h4"},t.name)),r.a.createElement(Ce.a,null),r.a.createElement(et.a,null,r.a.createElement(aa.a,{container:!0,justify:"space-between"},r.a.createElement(aa.a,{className:c.statsItem,item:!0},r.a.createElement(Io.a,{className:c.statsIcon}),r.a.createElement(Qe.a,{title:t.host},r.a.createElement(We.a,{variant:"body2",color:"textSecondary"},(v=t.host,f=20,v.length>f?v.slice(0,f)+"...":v))),r.a.createElement(Le.a,{onClick:()=>{return e=t.host,void navigator.clipboard.writeText(e).then(()=>{alert("Copied to clipboard")}).catch(e=>{console.error("Could not copy text: ",e)});var e}},r.a.createElement(Po.a,null))),r.a.createElement(aa.a,{className:c.statsItem,item:!0},r.a.createElement(Ct,{color:"success",size:"sm"}))))),r.a.createElement(Ne.a,{open:u,onClose:E,maxWidth:"sm"},r.a.createElement(Te.a,null,"Confirmation"),r.a.createElement(je.a,{dividers:!0},"Are you sure you want to delete this API?"),r.a.createElement(ke.a,null,r.a.createElement(Ae.a,{onClick:h,color:"primary",size:"small"},"Yes"),r.a.createElement(Ae.a,{onClick:E,color:"primary",size:"small"},"No"))),r.a.createElement(Ne.a,{open:g,onClose:b,fullWidth:!0,maxWidth:"sm"},r.a.createElement(Te.a,null,"Edit API"),r.a.createElement(je.a,{dividers:!0},r.a.createElement(Fo,{initialValues:t,isEditMode:!0,handleAlert:l,onClose:b}))));var v,f});Object(Ee.a)(e=>({root:{},row:{height:"42px",display:"flex",alignItems:"center",marginTop:e.spacing(1)},spacer:{flexGrow:1},importButton:{marginRight:e.spacing(1)},exportButton:{marginRight:e.spacing(1)},searchInput:{marginRight:e.spacing(1)}}));const Wo=e=>{let{dialogOpen:a,handleDialogClose:t,handleAlert:n,setValues:l,topic:o}=e;return r.a.createElement(Ne.a,{open:a,onClose:t,fullWidth:!0,maxWidth:"sm"},r.a.createElement(Te.a,{id:"form-dialog-title"},"API Information"),r.a.createElement(je.a,{dividers:!0},r.a.createElement(Fo,{handleAlert:n,onClose:t,topic:o,setValues:l})))},_o=Object(Ee.a)(e=>({root:{padding:e.spacing(3)},content:{marginTop:e.spacing(2)},pagination:{marginTop:e.spacing(3),display:"flex",alignItems:"center",justifyContent:"flex-end"}}));var zo=e=>{const a=_o(),{apisState:t,apisDispatch:l}=I(),[o,c]=Object(n.useState)(!1),[s,m]=Object(n.useState)({open:!1,message:"",severity:"info"}),u=Object(n.useCallback)((e,a,t)=>{m({open:e,message:a,severity:t})},[]),p=Object(n.useCallback)(()=>m(e=>Object(i.a)(Object(i.a)({},e),{},{open:!1})),[]),[g,y]=Object(n.useState)(!1),E=le(async()=>{const e=await(async()=>{try{return(await B.a.get("".concat(J))).data}catch(e){z(e)}})();l({type:d.SET_APIS,value:e})},c,u);Object(n.useEffect)(()=>{E()},[]);const[b,h]=Object(n.useState)(""),v=t.filter(e=>e.modelName.toLowerCase().includes(b.toLowerCase()));return r.a.createElement("div",{className:a.root},r.a.createElement(R,{open:s.open,message:s.message,onClose:p,severity:s.severity}),r.a.createElement(xt,{title:"AI-Model",handleSearch:e=>{h(e.target.value)},openForm:()=>{y(!0)}}),r.a.createElement("div",{className:a.content},r.a.createElement(aa.a,{container:!0,spacing:3},r.a.createElement(aa.a,{item:!0,xs:12},r.a.createElement(Ce.a,null)),o?r.a.createElement(aa.a,{container:!0,justifyContent:"center",alignItems:"center"},r.a.createElement(Je,null)):v.map(e=>r.a.createElement(aa.a,{item:!0,key:e.id,xs:12,sm:6,md:4,lg:3},r.a.createElement(Uo,{product:e,handleAlert:u}))))),r.a.createElement("div",{className:a.pagination},r.a.createElement(Le.a,null,r.a.createElement(jl.a,null)),r.a.createElement(We.a,{variant:"caption"},o?0:t.length),r.a.createElement(Le.a,null,r.a.createElement(Al.a,null))),r.a.createElement(Wo,{dialogOpen:g,handleDialogClose:()=>{y(!1)},handleAlert:u}))};const qo=(e,a,t,r)=>{const l=Object(n.useCallback)(le(async()=>{const[a,t]=await Promise.all([oe(),ce()]);r(t),e({type:d.SET_TOPICS,value:a.topics})},a,t),[e,t,r]),o=Object(n.useCallback)(le(async e=>{const a=await(async e=>{try{return(await B.a.get("".concat(G,"/messages/").concat(e))).data}catch(a){z(a)}})(e);r(a)},a,t),[t,r]),c=Object(n.useCallback)(()=>{l(),t(!0,"Data refreshed successfully","success")},[l,t]);return{listKafkaTopics:l,listMessages:o,handleRefresh:c}};var Go=t(471),Ho=t.n(Go),Vo=t(124),Ko=t.n(Vo),Yo=t(267),Zo=t.n(Yo);const Xo=Object(Ht.a)(e=>({tableContainer:{height:"100%",display:"flex",flexDirection:"column",minHeight:0}})),Jo=e=>{let{kafkaTopicsState:a,loading:t,selectedTopics:l,setSelectedTopics:o,handlers:c,additionalHandlers:s,bulkActionsComponent:i,state:d}=e;const m=Xo(),u=Object(n.useMemo)(()=>(e=>[{key:"id",label:"ID",width:80},{key:"name",label:"Name",render:e=>r.a.createElement(Qe.a,{title:e.name},r.a.createElement(We.a,{variant:"body2",noWrap:!0,style:{fontWeight:600}},e.name))},{key:"partitions",label:"Partitions",align:"center"},{key:"messages_count",label:"Messages",align:"center"},{key:"status",label:"Status",align:"center",render:a=>{const t={connected:{label:"Connected",color:"#4caf50"},not_connected:{label:"Not Connected",color:"#f44336"},paused:{label:"Paused",color:"#ff9800"}}[a.status]||{label:a.status,color:"#9e9e9e"};return r.a.createElement(il.a,{label:t.label,size:"small",style:{backgroundColor:t.color,color:"white",fontWeight:600,minWidth:120},className:e.statusChip})}}])(m),[m]),p=Object(n.useMemo)(()=>(e=>[{label:"View Messages",onClick:e.handleViewMessages,icon:r.a.createElement(yo.a,{fontSize:"small"}),color:"primary"},{label:"Pause",onClick:e.handlePauseTopic,icon:r.a.createElement(Zo.a,{fontSize:"small"}),color:"secondary",show:e=>"connected"===e.status},{label:"Resume",onClick:e.handleResumeTopic,icon:r.a.createElement(Ko.a,{fontSize:"small"}),color:"primary",show:e=>"paused"===e.status},{label:"Delete",onClick:e.handleDeleteTopic,icon:r.a.createElement(tn.a,{fontSize:"small"}),color:"secondary"}])(c),[c]),[g,y]=Object(n.useState)(0),[E,b]=Object(n.useState)(10),h=Object(n.useCallback)((e,a)=>{y(a)},[]),v=Object(n.useCallback)(e=>{b(parseInt(e.target.value,10)),y(0)},[]),f=Object(n.useCallback)(()=>{d.openDialog(0)},[d]),C=Object(n.useMemo)(()=>r.a.createElement(ve.a,{display:"flex",justifyContent:"space-between",alignItems:"center",p:1},r.a.createElement(We.a,{variant:"h6"},"Topics"),r.a.createElement(ve.a,null,r.a.createElement(Qe.a,{title:"Refresh Data"},r.a.createElement(Le.a,{color:"primary",onClick:s.handleRefresh,size:"small"},r.a.createElement(Ho.a,null))),r.a.createElement(Qe.a,{title:"Add New Topic"},r.a.createElement(Le.a,{color:"primary",onClick:f,size:"small"},r.a.createElement(Ll.a,null))))),[s,f]);return r.a.createElement(ve.a,{className:m.tableContainer},r.a.createElement(Zt,{data:a,columns:u,title:C,rowActions:p,loading:t,emptyMessage:"No topics found",pagination:!0,rowsPerPageOptions:[5,10,25],onPageChange:h,onRowsPerPageChange:v,page:g,rowsPerPage:E,count:a.length,selectable:!0,selectedRows:l,onSelectedRowsChange:o,bulkActions:i}))};var Qo=t(472),$o=t.n(Qo);const ec=e=>{let{classes:a,viewMode:t,handleViewModeChange:n,selectedTopics:l,totalMessagesCount:o,children:c}=e;return r.a.createElement(mt.a,{elevation:3,style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"}},r.a.createElement(ve.a,{sx:{borderBottom:1,borderColor:"divider",backgroundColor:"#fafafa",position:"sticky",top:0,zIndex:2}},r.a.createElement(Za.a,{value:t,onChange:n,indicatorColor:"primary",textColor:"primary",variant:"fullWidth"},r.a.createElement(Xa.a,{value:"messages",label:r.a.createElement(ve.a,{display:"flex",alignItems:"center",gap:1},r.a.createElement($o.a,{fontSize:"small"}),r.a.createElement("span",null,"Messages"),"messages"===t&&r.a.createElement(il.a,{label:o,size:"small",color:"primary"}))}),r.a.createElement(Xa.a,{value:"streaming",disabled:0===l.length,label:r.a.createElement(ve.a,{display:"flex",alignItems:"center",gap:1},r.a.createElement(Ko.a,{fontSize:"small"}),r.a.createElement("span",null,"Streaming"),"streaming"===t&&l.length>0&&r.a.createElement(il.a,{label:"LIVE",size:"small",color:"secondary"}))}))),r.a.createElement(ve.a,{sx:{flex:1,overflowY:"auto",padding:2,backgroundColor:"white"}},c))},ac=e=>{let{classes:a,messages:t,loading:n,handleOpenClick:l}=e;return r.a.createElement(r.a.Fragment,null,r.a.createElement(ve.a,{sx:{flex:1,overflowY:"auto",p:2,backgroundColor:"white"}},n?r.a.createElement(ve.a,{display:"flex",justifyContent:"center",alignItems:"center",height:"200px"},r.a.createElement(Je,null)):0===(null===t||void 0===t?void 0:t.length)?r.a.createElement(ve.a,{display:"flex",justifyContent:"center",alignItems:"center",height:"200px"},r.a.createElement(We.a,{color:"textSecondary",variant:"h6"},"No messages available")):r.a.createElement(aa.a,{container:!0,spacing:2},t.map((e,a)=>r.a.createElement(aa.a,{item:!0,xs:12,sm:6,key:a},r.a.createElement(nn,{name:e.topic_name,timestamp:new Date(e.creationDate).toLocaleString(),message:e,onOpen:()=>l(e),elevation:2}))))))};var tc=t(473),nc=t.n(tc);const rc=Object(Ee.a)(()=>({graphCard:{padding:12,height:"100%",width:"100%",display:"flex",flexDirection:"column",borderRadius:10,boxSizing:"border-box"},title:{marginBottom:8,flexShrink:0},graphContainer:{flexGrow:1,position:"relative",width:"100%",height:"100%",minHeight:0}}));var lc=e=>{let{selectedTopicsIds:a=[],streaming:t=!1}=e;const l=rc(),[o,c]=Object(n.useState)({datasets:[]}),s=Object(n.useCallback)(e=>{c(a=>{const t={datasets:[...a.datasets]},n=e.map(e=>e.name);return t.datasets=t.datasets.filter(e=>n.includes(e.label)),e.forEach(e=>{const a=t.datasets.findIndex(a=>a.label===e.name),n={x:new Date,y:e.messages_count};if(a>=0){const e=Object(i.a)({},t.datasets[a]);e.data=[...e.data,n].slice(-200),t.datasets[a]=e}else t.datasets.push({label:e.name,fill:!1,borderColor:te(),backgroundColor:"transparent",data:[n],lineTension:.2,pointRadius:2})}),t})},[]),d=Object(n.useCallback)(async()=>{if(t&&a.length)try{const e=await(async e=>{try{return(await B.a.post("".concat(G,"/messages_count"),{topicIds:e})).data}catch(a){z(a)}})(a);s(e||[])}catch(e){console.error("Error fetching message counts:",e)}},[t,a,s]);Object(n.useEffect)(()=>{let e;return t&&a.length?(d(),e=setInterval(d,5e3)):c({datasets:[]}),()=>clearInterval(e)},[t,a,d]);const m=Object(n.useMemo)(()=>({datasets:o.datasets}),[o]);return r.a.createElement(Ja.a,{className:l.graphCard,variant:"outlined"},r.a.createElement(We.a,{variant:"h6",className:l.title},"Messages Count"),r.a.createElement("div",{className:l.graphContainer},r.a.createElement(Lr.Line,{data:m,options:{maintainAspectRatio:!1,scales:{xAxes:[{type:"time",time:{unit:"second",tooltipFormat:"HH:mm:ss"},ticks:{autoSkip:!0,maxTicksLimit:10}}],yAxes:[{ticks:{beginAtZero:!0}}]},animation:!1,tooltips:{mode:"nearest",intersect:!1},hover:{mode:"nearest",intersect:!1}}})))};const oc=e=>{let{selectedTopics:a,selectedTopicsIds:t,handleStopStreaming:n}=e;return r.a.createElement(mt.a,{elevation:3,style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"}},r.a.createElement(ve.a,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:2,position:"sticky",top:0,backgroundColor:"#fafafa",zIndex:2,borderBottom:"1px solid #e0e0e0"}},r.a.createElement(We.a,{variant:"h6",style:{fontWeight:600}},"Real-time Streaming"," ",r.a.createElement(il.a,{label:"".concat(a.length," topic").concat(a.length>1?"s":""),size:"small",color:"primary",style:{marginLeft:8}})),r.a.createElement(Ae.a,{size:"small",startIcon:r.a.createElement(nc.a,null),onClick:n,variant:"outlined",color:"secondary"},"Stop Streaming")),r.a.createElement(ve.a,{sx:{flex:1,overflowY:"auto",p:2,backgroundColor:"white"}},r.a.createElement(lc,{selectedTopicsIds:t,streaming:!0})))},cc=e=>{let{selectedTopics:a,loading:t,actionLoading:l,classes:o,isXs:c,onViewMessages:s,onStartStreaming:i,onPause:d,onResume:m,onDelete:u}=e;const p=Object(n.useMemo)(()=>l.pause||l.resume||l.delete||l.viewMessages,[l]);return a&&0!==a.length?r.a.createElement(ve.a,{className:o.bulkActions},r.a.createElement("div",{className:o.bulkSelectionInfo},r.a.createElement(il.a,{label:"".concat(a.length," selected"),color:"primary",size:"small"}),p&&r.a.createElement(Xe.a,{size:20,className:o.buttonProgress})),r.a.createElement("div",{className:o.actionButtons},r.a.createElement(Qe.a,{title:"View messages from selected topics"},r.a.createElement(Ae.a,{className:"".concat(o.actionButton," ").concat(o.viewButton),startIcon:r.a.createElement(yo.a,null),onClick:s,disabled:l.viewMessages||t,size:"small",variant:"contained"},c?"View":"View Messages",l.viewMessages&&r.a.createElement(Xe.a,{size:16,className:o.buttonProgress}))),r.a.createElement(Qe.a,{title:"Stream messages from selected topics"},r.a.createElement(Ae.a,{className:"".concat(o.actionButton," ").concat(o.streamButton),startIcon:r.a.createElement(Ko.a,null),onClick:i,disabled:t,size:"small",variant:"contained"},c?"Stream":"Start Streaming")),r.a.createElement(Qe.a,{title:"Pause selected topics"},r.a.createElement(Ae.a,{className:"".concat(o.actionButton," ").concat(o.viewButton),startIcon:r.a.createElement(Zo.a,null),onClick:d,disabled:l.pause||t,size:"small",variant:"contained"},"Pause",l.pause&&r.a.createElement(Xe.a,{size:16,className:o.buttonProgress}))),r.a.createElement(Qe.a,{title:"Resume selected topics"},r.a.createElement(Ae.a,{className:"".concat(o.actionButton," ").concat(o.streamButton),startIcon:r.a.createElement(Ko.a,null),onClick:m,disabled:l.resume||t,size:"small",variant:"contained"},"Resume",l.resume&&r.a.createElement(Xe.a,{size:16,className:o.buttonProgress}))),r.a.createElement(Qe.a,{title:"Delete selected topics"},r.a.createElement(Ae.a,{className:"".concat(o.actionButton," ").concat(o.deleteButton),startIcon:r.a.createElement(tn.a,null),onClick:u,disabled:l.delete||t,size:"small",variant:"contained"},"Delete",l.delete&&r.a.createElement(Xe.a,{size:16,className:o.buttonProgress}))))):null};var sc=t(260),ic=t.n(sc);const dc=Object(Ht.a)(e=>({actionButton:{borderRadius:e.spacing(1.5),textTransform:"none",fontWeight:600,fontSize:"0.75rem",padding:e.spacing(.75,1.5),minWidth:"auto",transition:"all 0.2s ease-in-out","&:hover":{transform:"translateY(-1px)",boxShadow:"0 4px 12px rgba(0,0,0,0.15)"},"&:disabled":{opacity:.5,transform:"none"}},viewButton:{backgroundColor:e.palette.info.main,color:e.palette.info.contrastText,"&:hover":{backgroundColor:e.palette.info.dark}},streamButton:{backgroundColor:e.palette.success.main,color:e.palette.success.contrastText,"&:hover":{backgroundColor:e.palette.success.dark}},deleteButton:{backgroundColor:e.palette.error.main,color:e.palette.error.contrastText,"&:hover":{backgroundColor:e.palette.error.dark}},buttonProgress:{marginLeft:e.spacing(1)},dialogHeader:{display:"flex",alignItems:"center",gap:e.spacing(2),padding:e.spacing(2.5),borderBottom:"1px solid ".concat(e.palette.divider),background:"linear-gradient(135deg, ".concat(e.palette.background.default," 0%, ").concat(e.palette.background.paper," 100%)")},deleteDialogIcon:{fontSize:32,color:e.palette.error.main},infoDialogIcon:{fontSize:32,color:e.palette.info.main},dialogContent:{padding:e.spacing(3)},topicList:{maxHeight:200,overflow:"auto",backgroundColor:e.palette.background.default,borderRadius:e.spacing(1),padding:e.spacing(1.5),marginTop:e.spacing(2),border:"1px solid ".concat(e.palette.divider)},topicItem:{padding:e.spacing(1),borderBottom:"1px solid ".concat(e.palette.divider),"&:last-child":{borderBottom:"none"},"&:hover":{backgroundColor:e.palette.action.hover,borderRadius:e.spacing(.5)}},actionButtonContainer:{display:"flex",gap:e.spacing(1),alignItems:"center"}})),mc=e=>{let{open:a,onClose:t,type:n,title:l,message:o,topicNames:c=[],onConfirm:s,loading:i=!1}=e;const d=dc(),m=Object(be.a)(),u=(()=>{switch(n){case"delete":return{icon:r.a.createElement(ic.a,{className:d.deleteDialogIcon}),confirmButtonClass:d.deleteButton,confirmText:"Delete",loadingText:"Deleting..."};case"pause":return{icon:r.a.createElement(Nl.a,{className:d.infoDialogIcon}),confirmButtonClass:d.viewButton,confirmText:"Pause",loadingText:"Pausing..."};case"resume":return{icon:r.a.createElement(Nl.a,{className:d.infoDialogIcon}),confirmButtonClass:d.streamButton,confirmText:"Resume",loadingText:"Resuming..."};default:return{icon:r.a.createElement(Nl.a,{className:d.infoDialogIcon}),confirmButtonClass:d.viewButton,confirmText:"Confirm",loadingText:"Processing..."}}})();return r.a.createElement(Ne.a,{open:a,onClose:t,"aria-labelledby":"confirmation-dialog-title",maxWidth:"sm",fullWidth:!0,PaperProps:{elevation:16,style:{borderRadius:16,background:m.palette.background.paper}}},r.a.createElement("div",{className:d.dialogHeader},u.icon,r.a.createElement(Te.a,{id:"confirmation-dialog-title",style:{padding:0,fontWeight:700,color:m.palette.text.primary}},l)),r.a.createElement(je.a,{className:d.dialogContent},r.a.createElement(wt.a,{style:{whiteSpace:"pre-line",fontSize:"1rem",lineHeight:1.6,color:m.palette.text.secondary,marginBottom:c.length>0?m.spacing(2):0}},o),c.length>0&&r.a.createElement(ve.a,{className:d.topicList},r.a.createElement(We.a,{variant:"subtitle1",gutterBottom:!0,style:{fontWeight:600}},"Affected Topics (",c.length,")"),c.map((e,a)=>r.a.createElement(ve.a,{key:a,className:d.topicItem},r.a.createElement(We.a,{variant:"body2",noWrap:!0,style:{fontWeight:500}},e))))),r.a.createElement(ke.a,{style:{padding:m.spacing(2.5),gap:m.spacing(1)}},r.a.createElement(Ae.a,{onClick:t,color:"primary",disabled:i,variant:"outlined",style:{borderRadius:8}},"Cancel"),r.a.createElement(Ae.a,{onClick:s,className:u.confirmButtonClass,variant:"contained",disabled:i,autoFocus:!0,style:{borderRadius:8}},i?r.a.createElement("div",{className:d.actionButtonContainer},r.a.createElement(Xe.a,{size:16,className:d.buttonProgress}),u.loadingText):u.confirmText)))},uc=Object(Ee.a)(e=>({root:{},item:{display:"flex",flexDirection:"column"},formControl:{minWidth:120,margin:e.spacing(1)},errorText:{color:"red",margin:e.spacing(1,0)}})),pc=tt.c().shape({name:tt.d().required("Field required").matches(/^[^_]*$/,"Name cannot contain underscores"),partitions:tt.b().required("Field required"),replications:tt.b().required("Field required")});var gc=e=>{let{dialogType:a,closeDialog:t,handleAlert:l,kafkaTopicsDispatch:o}=e;const c=uc(),[s,i]=Object(n.useState)(!1),m=le(async e=>{const a=await(async e=>{try{return(await B.a.post("".concat(G),e)).data}catch(a){z(a)}})(e);o({type:d.ADD_TOPIC,topic:a.topic}),t(a.topic)},i,l);return r.a.createElement(jt,{maxWidth:"sm",title:"Add Topic",onClose:t,open:0===a},r.a.createElement(at.d,{initialValues:{name:"",partitions:1,replications:1},validationSchema:pc,onSubmit:m},e=>{let{isSubmitting:a}=e;return r.a.createElement(at.c,null,r.a.createElement(pn.a,{variant:"outlined",fullWidth:!0,className:c.formControl},r.a.createElement(at.b,{as:$a.a,fullWidth:!0,label:"Name",margin:"dense",name:"name",required:!0,variant:"outlined",error:Boolean(r.a.createElement(at.a,{name:"name"})),helperText:r.a.createElement(at.a,{name:"name",component:"div",className:c.errorText})})),r.a.createElement(pn.a,{variant:"outlined",fullWidth:!0,className:c.formControl},r.a.createElement(gn.a,{htmlFor:"partitions-select"},"# of partitions"),r.a.createElement(at.b,{as:yn.a,native:!0,label:"# of partitions",name:"partitions",inputProps:{id:"partitions-select"}},[1,2,3,4].map(e=>r.a.createElement("option",{key:e,value:e},e))),r.a.createElement(at.a,{name:"partitions",component:"div",className:c.errorText})),r.a.createElement(pn.a,{variant:"outlined",fullWidth:!0,className:c.formControl},r.a.createElement(gn.a,{htmlFor:"replications-select"},"Replication factor"),r.a.createElement(at.b,{as:yn.a,native:!0,label:"Replication factor",name:"replications",inputProps:{id:"replications-select"}},[1,2,3,4,5].map(e=>r.a.createElement("option",{key:e,value:e},e))),r.a.createElement(at.a,{name:"replications",component:"div",className:c.errorText})),r.a.createElement(ve.a,{display:"flex",justifyContent:"flex-end"},r.a.createElement(Ae.a,{variant:"contained",size:"medium",color:"primary",type:"submit",disabled:s},"Add"),s&&r.a.createElement(Je,{size:24})))}))};const yc=Object(Ht.a)(e=>({root:{display:"flex",flexDirection:"column",[e.breakpoints.down("sm")]:{height:"100%",minHeight:"100vh"}},mainContent:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",[e.breakpoints.down("sm")]:{padding:e.spacing(1),minHeight:"calc(100vh - 120px)"}},layoutContainer:{flex:1,display:"flex",gap:e.spacing(2),minHeight:0,[e.breakpoints.down("md")]:{flexDirection:"column"},[e.breakpoints.down("sm")]:{gap:e.spacing(1)}},tablePanel:{height:"78vh",flex:"1 1 60%",display:"flex",flexDirection:"column",minHeight:0,minWidth:0,[e.breakpoints.down("md")]:{flex:"1 1 300px",minHeight:500}},contentPanel:{height:"78vh",flex:"1 1 40%",display:"flex",flexDirection:"column",minHeight:0,minWidth:0,[e.breakpoints.down("md")]:{flex:"1 1 400px",minHeight:500},[e.breakpoints.down("sm")]:{flex:"1 1 350px",minHeight:400}},panelContainer:{flex:1,display:"flex",flexDirection:"column",minHeight:0,backgroundColor:e.palette.background.paper,borderRadius:e.spacing(2),boxShadow:"0 2px 12px rgba(0,0,0,0.08)",border:"1px solid ".concat(e.palette.divider),overflow:"hidden",[e.breakpoints.down("sm")]:{borderRadius:e.spacing(1)}},loadingOverlay:{justifyContent:"center",alignItems:"center"},bulkActions:{display:"flex",alignItems:"center",gap:e.spacing(1),flexWrap:"wrap",padding:e.spacing(1.5,2),backgroundColor:e.palette.primary.light,borderBottom:"1px solid ".concat(e.palette.divider),minHeight:60,"&.hidden":{display:"none"}},bulkSelectionInfo:{display:"flex",alignItems:"center",gap:e.spacing(1),marginRight:"auto",padding:e.spacing(.5,1.5),backgroundColor:e.palette.primary.main,color:e.palette.primary.contrastText,borderRadius:e.spacing(1),fontWeight:600},actionButtons:{display:"flex",gap:e.spacing(1),flexWrap:"wrap",[e.breakpoints.down("xs")]:{"& > *":{flex:"1 1 calc(50% - 8px)",minWidth:0}}},actionButton:{borderRadius:e.spacing(1.5),textTransform:"none",fontWeight:600,fontSize:"0.75rem",padding:e.spacing(.75,1.5),minWidth:"auto",transition:"all 0.2s ease-in-out","&:hover":{transform:"translateY(-1px)",boxShadow:"0 4px 12px rgba(0,0,0,0.15)"},"&:disabled":{opacity:.5,transform:"none"}},viewButton:{backgroundColor:e.palette.info.main,color:e.palette.info.contrastText,"&:hover":{backgroundColor:e.palette.info.dark}},streamButton:{backgroundColor:e.palette.success.main,color:e.palette.success.contrastText,"&:hover":{backgroundColor:e.palette.success.dark}},deleteButton:{backgroundColor:e.palette.error.main,color:e.palette.error.contrastText,"&:hover":{backgroundColor:e.palette.error.dark}}}));var Ec=r.a.memo(()=>{const e=yc(),a=Object(be.a)(),t=Object(he.a)(a.breakpoints.down("xs")),{kafkaTopicsState:l,kafkaTopicsDispatch:o}=I(),c=(()=>{const[e,a]=Object(n.useState)([]),[t,r]=Object(n.useState)({}),[l,o]=Object(n.useState)(!1),[c,s]=Object(n.useState)("messages"),[d,m]=Object(n.useState)([]),[u,p]=Object(n.useState)(null),[g,y]=Object(n.useState)(!1),[E,b]=Object(n.useState)({open:!1,message:"",severity:"info"}),h=Object(n.useMemo)(()=>d.map(e=>e.id),[d]),v=Object(n.useMemo)(()=>e.reduce((e,a)=>e+(a.message_count||1),0),[e]),f=Object(n.useCallback)((e,a,t)=>{b({open:e,message:a,severity:t})},[]),C=Object(n.useCallback)(()=>{b(e=>Object(i.a)(Object(i.a)({},e),{},{open:!1}))},[]),S=Object(n.useCallback)(e=>{p(e)},[]),x=Object(n.useCallback)(()=>{p(null)},[]),w=Object(n.useCallback)((e,a)=>{s(a)},[]),O=Object(n.useCallback)(()=>{s("streaming")},[]),A=Object(n.useCallback)(()=>{s("messages")},[]),T=Object(n.useCallback)(e=>{r(e),S("viewMessage")},[S]);return{messages:e,message:t,loading:l,viewMode:c,selectedTopics:d,selectedTopicsIds:h,dialogType:u,autoRefresh:g,alert:E,totalMessagesCount:v,setMessages:a,setLoading:o,setSelectedTopics:m,setAutoRefresh:y,handleAlert:f,handleCloseAlert:C,openDialog:S,closeDialog:x,handleViewModeChange:w,handleStartStreaming:O,handleStopStreaming:A,handleOpenClick:T}})(),s=qo(o,c.setLoading,c.handleAlert,c.setMessages),m=((e,a,t,r,l)=>{const o=Object(n.useCallback)(async n=>{try{t(!0),await ie([n.id]),e({type:d.UPDATE_TOPICS_STATUS,payload:{topicIds:[n.id],status:"paused"}}),a(!0,'Topic "'.concat(n.name,'" paused successfully'),"success")}catch(r){console.error("Error pausing topic:",r),a(!0,'Error pausing topic "'.concat(n.name,'"'),"error")}finally{t(!1)}},[e,a,t]),c=Object(n.useCallback)(async n=>{try{t(!0),await de([n.id]),e({type:d.UPDATE_TOPICS_STATUS,payload:{topicIds:[n.id],status:"connected"}}),a(!0,'Topic "'.concat(n.name,'" resumed successfully'),"success")}catch(r){console.error("Error resuming topic:",r),a(!0,'Error resuming topic "'.concat(n.name,'"'),"error")}finally{t(!1)}},[e,a,t]),s=Object(n.useCallback)(async n=>{try{t(!0);const l=await se([n.id]),o=await Promise.all(l);e({type:d.DELETE_TOPICS,topicIds:o}),r(e=>e.filter(e=>e.id!==n.id)),a(!0,'Topic "'.concat(n.name,'" deleted successfully'),"success")}catch(l){console.error("Error deleting topic:",l),a(!0,'Error deleting topic "'.concat(n.name,'"'),"error")}finally{t(!1)}},[e,a,t,r]),i=Object(n.useCallback)(async e=>{await l(e.id)},[l]),m=Object(n.useCallback)(async(e,n,r)=>{try{t(!0),await e(n),a(!0,r,"success")}catch(l){console.error("Error performing bulk action:",l),a(!0,"Error performing action","error")}finally{t(!1)}},[a,t]);return{handlePauseTopic:o,handleResumeTopic:c,handleDeleteTopic:s,handleViewMessages:i,handlePauseSelected:Object(n.useCallback)(async(a,t)=>{0!==a.length&&(await m(ie,t,"".concat(a.length," topic(s) paused successfully")),e({type:d.UPDATE_TOPICS_STATUS,payload:{topicIds:t,status:"paused"}}))},[m,e]),handleResumeSelected:Object(n.useCallback)(async(a,t)=>{0!==a.length&&(await m(de,t,"".concat(a.length," topic(s) resumed successfully")),e({type:d.UPDATE_TOPICS_STATUS,payload:{topicIds:t,status:"connected"}}))},[m,e]),handleDeleteSelected:Object(n.useCallback)(async(a,t,n)=>{0!==a.length&&(await m(se,t,"".concat(a.length," topic(s) deleted successfully")),e({type:d.DELETE_TOPICS,topicIds:t}),n([]))},[m,e])}})(o,c.handleAlert,c.setLoading,c.setSelectedTopics,s.listMessages),[u,p]=Object(n.useState)({open:!1,type:"",title:"",message:"",topicNames:[],onConfirm:null}),[g,y]=Object(n.useState)({pause:!1,resume:!1,delete:!1,viewMessages:!1,refresh:!1}),E=()=>{p({open:!1,type:"",title:"",message:"",topicNames:[],onConfirm:null})},b=((e,a,t,r,l)=>{const o=Object(n.useCallback)((async function(e,a){r(a=>Object(i.a)(Object(i.a)({},a),{},{[e]:!0}));try{for(var t=arguments.length,n=new Array(t>2?t-2:0),l=2;lObject(i.a)(Object(i.a)({},a),{},{[e]:!1}))}}),[r]),c=Object(n.useCallback)((e,t,n)=>()=>{const r=a.selectedTopics.length,o=a.selectedTopics.map(e=>e.name);l(e,"".concat(e.charAt(0).toUpperCase()+e.slice(1)," Topics"),n(r,o),o,()=>t(a.selectedTopics,a.selectedTopicsIds))},[a.selectedTopics,a.selectedTopicsIds,l]),s=c("delete",(e,n)=>t.handleDeleteSelected(e,n,a.setSelectedTopics),(e,a)=>1===e?'Are you sure you want to delete topic "'.concat(a[0],'"? This action cannot be undone.'):"Are you sure you want to delete ".concat(e," selected topics? This action cannot be undone.")),d=c("pause",t.handlePauseSelected,(e,a)=>1===e?'Are you sure you want to pause topic "'.concat(a[0],'"?'):"Are you sure you want to pause ".concat(e," selected topics?")),m=c("resume",t.handleResumeSelected,(e,a)=>1===e?'Are you sure you want to resume topic "'.concat(a[0],'"?'):"Are you sure you want to resume ".concat(e," selected topics?")),u=Object(n.useCallback)((e,a,t)=>{l(e,"".concat(e.charAt(0).toUpperCase()+e.slice(1)," Topic"),"Are you sure you want to ".concat(e,' topic "').concat(a.name,'"?').concat("delete"===e?" This action cannot be undone.":""),[a.name],()=>t(a))},[l]),p=Object(n.useMemo)(()=>Object(i.a)(Object(i.a)({},t),{},{handlePauseTopic:e=>u("pause",e,t.handlePauseTopic),handleResumeTopic:e=>u("resume",e,t.handleResumeTopic),handleDeleteTopic:e=>u("delete",e,t.handleDeleteTopic)}),[t,u]),g=Object(n.useCallback)(async()=>{await o("viewMessages",async()=>{for(let e=0;et.handleViewMessages(e)))}})},[a.selectedTopics,t.handleViewMessages,o]),y=Object(n.useCallback)(async()=>{await o("refresh",async()=>{await e.listKafkaTopics(),a.selectedTopics.length>0&&await g()})},[o,g]),E=Object(n.useCallback)(()=>{a.handleStartStreaming()},[a]);return{handleActionWithLoading:o,handleDeleteSelected:s,handlePauseSelected:d,handleResumeSelected:m,enhancedHandlers:p,handleViewSelectedMessages:g,handleRefreshData:y,handleStartStreamingSelected:E}})(s,c,m,y,(e,a,t,n,r)=>{p({open:!0,type:e,title:a,message:t,topicNames:n,onConfirm:r})}),h=Object(n.useMemo)(()=>r.a.createElement(cc,{selectedTopics:c.selectedTopics,loading:c.loading,actionLoading:g,classes:e,isXs:t,onViewMessages:b.handleViewSelectedMessages,onStartStreaming:b.handleStartStreamingSelected,onPause:b.handlePauseSelected,onResume:b.handleResumeSelected,onDelete:b.handleDeleteSelected}),[c.selectedTopics,c.loading,g,e,t,b]),v=Object(n.useMemo)(()=>({handleRefresh:b.handleRefreshData,openDialog:c.openDialog}),[b.handleRefreshData,c.openDialog]);return Object(n.useEffect)(()=>{s.listKafkaTopics()},[s.listKafkaTopics]),Object(n.useEffect)(()=>{let e;return c.autoRefresh&&"messages"===c.viewMode&&(e=setInterval(()=>{s.listKafkaTopics()},1e4)),()=>clearInterval(e)},[c.autoRefresh,c.viewMode,s.listKafkaTopics]),r.a.createElement(ve.a,{className:e.root},r.a.createElement(R,{open:c.alert.open,message:c.alert.message,onClose:c.handleCloseAlert,severity:c.alert.severity}),r.a.createElement(mc,{open:u.open,onClose:E,type:u.type,title:u.title,message:u.message,topicNames:u.topicNames,onConfirm:async()=>{u.onConfirm&&await b.handleActionWithLoading(u.type,u.onConfirm),E()},loading:g[u.type]}),r.a.createElement(ve.a,{className:e.mainContent},r.a.createElement(ve.a,{className:e.layoutContainer},r.a.createElement(ve.a,{className:e.tablePanel},r.a.createElement(ve.a,{className:e.panelContainer},c.loading?r.a.createElement(ve.a,{display:"flex",justifyContent:"center",alignItems:"center",height:"200px"},r.a.createElement(Je,null)):r.a.createElement(Jo,{classes:e,kafkaTopicsState:l,loading:c.loading,selectedTopics:c.selectedTopics,setSelectedTopics:c.setSelectedTopics,handlers:b.enhancedHandlers,state:c,additionalHandlers:v,bulkActionsComponent:h}))),r.a.createElement(ve.a,{className:e.contentPanel},r.a.createElement(ve.a,{className:e.panelContainer},r.a.createElement(ec,{classes:e,viewMode:c.viewMode,handleViewModeChange:c.handleViewModeChange,selectedTopics:c.selectedTopics,totalMessagesCount:c.totalMessagesCount},"streaming"===c.viewMode?r.a.createElement(oc,{classes:e,selectedTopics:c.selectedTopics,selectedTopicsIds:c.selectedTopicsIds,handleStopStreaming:c.handleStopStreaming}):r.a.createElement(ac,{classes:e,messages:c.messages,loading:c.loading||g.viewMessages,totalMessagesCount:c.totalMessagesCount,autoRefresh:c.autoRefresh,setAutoRefresh:c.setAutoRefresh,selectedTopics:c.selectedTopics,handleStartStreaming:c.handleStartStreaming,handleOpenClick:c.handleOpenClick})))))),r.a.createElement(gc,{dialogType:c.dialogType,kafkaTopicsDispatch:o,handleAlert:c.handleAlert,closeDialog:c.closeDialog}),r.a.createElement(Ne.a,{open:"viewMessage"===c.dialogType,onClose:c.closeDialog,"aria-labelledby":"message-dialog-title",maxWidth:"md",fullWidth:!0,PaperProps:{elevation:16,style:{borderRadius:16,background:a.palette.background.paper}}},r.a.createElement(je.a,{style:{padding:0}},r.a.createElement(Qt,{name:c.message.topic_name,message:c.message,handleAlert:c.handleAlert}))))}),bc=t(801),hc=t(798),vc=t(799),fc=t(782);const Cc=Object(Ee.a)(e=>({root:{padding:e.spacing(2)},inputContainer:{width:"100%",maxWidth:400,marginTop:20}}));var Sc=e=>{let{values:a,setValues:t,handleAlert:l,setLoading:o,loading:c}=e;const s=Cc(),{kafkaTopicsState:m,kafkaTopicsDispatch:u}=I(),[p,g]=Object(n.useState)(null),y=Object(fc.a)();Object(n.useEffect)(()=>{le(async()=>{const e=await oe();await u({type:d.SET_TOPICS,value:e.topics})},o,l)()},[u,o,l]);return r.a.createElement("div",{className:s.root},r.a.createElement(aa.a,{container:!0,justifyContent:"center"},r.a.createElement(aa.a,{item:!0,xs:12,md:6},r.a.createElement(We.a,{variant:"h6"},"kafkaTopic & Permission"),c&&r.a.createElement(Je,null),r.a.createElement("div",{className:s.inputContainer},r.a.createElement(or.a,{size:"small",value:a.topic||null,onChange:(e,a)=>{"Add New kafka Topic"===a?(g(0),t(e=>Object(i.a)(Object(i.a)({},e),{},{topic:null}))):t(e=>Object(i.a)(Object(i.a)({},e),{},{topic:Object(i.a)(Object(i.a)({},a),{},{name:null===a||void 0===a?void 0:a.name})}))},options:["Add New kafka Topic",...m],getOptionLabel:e=>"string"===typeof e?e:e.name,renderInput:e=>r.a.createElement($a.a,Object.assign({},e,{label:"kafkaTopic",variant:"outlined",fullWidth:!0})),filterOptions:(e,a)=>y(e,a),clearOnBlur:!0})))),r.a.createElement(gc,{dialogType:p,kafkaTopicsDispatch:u,handleAlert:l,closeDialog:e=>{t(a=>Object(i.a)(Object(i.a)({},a),{},{topic:e})),g(null)}}))};const xc=Object(Ee.a)(e=>({root:{padding:e.spacing(2),backgroundColor:e.palette.background.default,borderRadius:8},connectorPaper:{padding:e.spacing(2),margin:e.spacing(2,0),border:"1px solid #ccc",borderRadius:8,backgroundColor:"#f9f9f9",textAlign:"center",cursor:"pointer",transition:"background-color 0.3s","&:hover":{backgroundColor:"#e0e0e0"}},title:{marginBottom:e.spacing(2),color:e.palette.text.primary}}));var wc=e=>{var a;let{values:t,setValues:l,handleAlert:o,setLoading:c,loading:s}=e;const i=xc(),[d,m]=Object(n.useState)({open:!1,type:""}),u=e=>{m({open:!0,type:e})},p=()=>{m({open:!1,type:""})};return r.a.createElement(aa.a,{justifyContent:"center",container:!0,spacing:2},r.a.createElement(aa.a,{item:!0,xs:12},r.a.createElement(We.a,{align:"center",variant:"h6"},"Add Connectors")),r.a.createElement(aa.a,{item:!0,xs:12,md:4},r.a.createElement(mt.a,{className:i.connectorPaper,onClick:()=>u("source")},t.connectors.source?r.a.createElement(r.a.Fragment,null,r.a.createElement(We.a,{variant:"subtitle1"},"Source Connector "),r.a.createElement(We.a,{variant:"h6"}," ",t.connectors.source.name," ")):r.a.createElement(We.a,{variant:"subtitle1"},"Add Source Connector"))),r.a.createElement(aa.a,{item:!0,xs:12,md:4},r.a.createElement(mt.a,{className:i.connectorPaper,onClick:()=>u("sink")},t.connectors.sink?r.a.createElement(r.a.Fragment,null,r.a.createElement(We.a,{variant:"subtitle1"},"Sink Connector "),r.a.createElement(We.a,{variant:"h6"}," ",t.connectors.sink.name," ")):r.a.createElement(We.a,{variant:"subtitle1"},"Add Sink Connector"))),r.a.createElement(Ne.a,{open:d.open,onClose:p},r.a.createElement(ro,{open:d.open,handleCloseForm:p,handleAlert:o,connectorType:d.type,connectorTopic:null===(a=t.topic)||void 0===a?void 0:a.id,connectorThing:t.thing.thing_id,connectorPermission:t.thing.permission.topic,setValues:l,disabled:!0})))};const Oc=Object(Ee.a)(e=>({root:{padding:e.spacing(2),backgroundColor:e.palette.background.default,borderRadius:8},apiPaper:{padding:e.spacing(2),margin:e.spacing(2,0),border:"1px solid #ccc",borderRadius:8,backgroundColor:"#f9f9f9",textAlign:"center",cursor:"pointer",transition:"background-color 0.3s","&:hover":{backgroundColor:"#e0e0e0"}},title:{marginBottom:e.spacing(2),color:e.palette.text.primary}}));var Ac=e=>{var a;let{values:t,setValues:l,handleAlert:o,setLoading:c,loading:s}=e;const i=Oc(),[d,m]=Object(n.useState)(!1);return r.a.createElement(aa.a,{justifyContent:"center",container:!0,spacing:2},r.a.createElement(aa.a,{item:!0,xs:12},r.a.createElement(We.a,{align:"center",variant:"h6"},"API Information")),r.a.createElement(aa.a,{item:!0,xs:12,md:4},r.a.createElement(mt.a,{className:i.apiPaper,onClick:()=>{m(!0)}},t.api.modelName?r.a.createElement(r.a.Fragment,null,r.a.createElement(We.a,{variant:"subtitle1"},"API Model "),r.a.createElement(We.a,{variant:"h6"}," ",t.api.modelName," ")):r.a.createElement(We.a,{variant:"subtitle1"},"Add New Modal"))),r.a.createElement(Wo,{dialogOpen:d,handleDialogClose:()=>{m(!1)},handleAlert:o,isProcess:!0,setValues:l,topic:null===(a=t.topic)||void 0===a?void 0:a.id}))};const Tc=["children","classes","onClose"];Object(Ee.a)(e=>({root:{},row:{height:"42px",display:"flex",alignItems:"center",marginTop:e.spacing(1)},spacer:{flexGrow:1},importButton:{marginRight:e.spacing(1)},exportButton:{marginRight:e.spacing(1)},searchInput:{marginRight:e.spacing(1)}})),Object(kt.a)(e=>({root:{margin:0,padding:e.spacing(2)},closeButton:{position:"absolute",right:e.spacing(1),top:e.spacing(1),color:e.palette.grey[500]}}))(e=>{const{children:a,classes:t,onClose:n}=e,l=Object(Se.a)(e,Tc);return r.a.createElement(Te.a,Object.assign({disableTypography:!0,className:t.root},l),r.a.createElement(We.a,{variant:"h6"},a),n?r.a.createElement(Le.a,{"aria-label":"close",className:t.closeButton,onClick:n},r.a.createElement(At.a,null)):null)}),Object(kt.a)(e=>({root:{padding:e.spacing(2)}}))(je.a),Object(kt.a)(e=>({root:{margin:0,padding:e.spacing(1)}}))(ke.a);t(439),t(800),t(329),t(330),t(624),t(268);Object(Ht.a)(e=>({dropzoneClass:{borderRadius:0,border:"2px dashed white",padding:"30px 0px",height:150,background:"#c2c5c0",[e.breakpoints.down("sm")]:{width:"100%"},width:"100%",overflow:"auto",borderColor:"#FFFAFA",marginBottom:10,textAlign:"center"},dropzone:{borderRadius:0,border:"2px dashed white",padding:"30px 0px",height:150,background:"#a5a3a0",[e.breakpoints.down("sm")]:{width:"100%"},width:"100%",overflow:"auto",borderColor:"#FFFAFA",marginBottom:10,textAlign:"center"},inputFile1:{fontSize:30,height:150,width:300,position:"absolute",opacity:0},label:{fontSize:15,fontFamily:"sans-serif",fontStyle:"normal"},db:{[e.breakpoints.down("sm")]:{width:"100%"}}}));var jc=t(164);function kc(e){return r.a.createElement(jc.a,{styles:{padding:20},url:"".concat("https://www.thingwings.com","/flow-editor/").concat(e.containerName,"/?token=").concat(e.token),width:"100%",height:"500px",position:"relative",onLoad:e.onLoad,allowFullScreen:!0})}const Nc=r.a.memo(e=>{let{flowControl:a,name:t,setProgress:l,handleAlert:o,handleDialogClose:c,flow:s,progress:i,history:m,isProcess:u}=e;const{flowsDispatch:p}=I(),[g,y]=Object(n.useState)(""),[E,b]=Object(n.useState)(!1),[h,v]=Object(n.useState)(""),[f,C]=Object(n.useState)(!1),S=U();Object(n.useEffect)(()=>{a.edit&&s?y(s.name||""):a.add&&y("")},[a.edit,a.add,s]);const x=Object(n.useCallback)(()=>C(!0),[]),w=Object(n.useCallback)(e=>{y(e.target.value)},[]),O=Object(n.useCallback)(le(async()=>{const e=await(async e=>{try{return(await B.a.post("".concat(X,"/flows"),e)).data}catch(a){z(a)}})({name:g});p({type:d.ADD_FLOW,value:e.flow}),v(e.flow.containerName),u?b(!0):m.push("/nodered/".concat(e.flow.containerName)),c("add")},l,o),[g,p,u,m,c,o]),A=Object(n.useCallback)(le(async()=>{await(async(e,a)=>{try{return(await B.a.put("".concat(X,"/flows/").concat(e),{name:a})).data}catch(t){z(t)}})(null===s||void 0===s?void 0:s.id,g),p({type:d.UPDATE_FLOW,flowId:null===s||void 0===s?void 0:s.id,name:g}),c("edit"),o(!0,"Flow updated successfully","success")},l,o),[null===s||void 0===s?void 0:s.id,g,p,c,o]),T=Object(n.useCallback)(e=>{y(""),c(e)},[c]),j=a.add,k=a.edit;return r.a.createElement(r.a.Fragment,null,r.a.createElement(Ne.a,{open:j||k,onClose:()=>T(j?"add":"edit"),fullWidth:!0,maxWidth:"sm"},r.a.createElement(Te.a,null,j?"Create New Flow":"Update Flow Name"),r.a.createElement(je.a,null,r.a.createElement(wt.a,null,j?"Enter a name for your new flow:":"Update the flow name:"),i&&r.a.createElement(Je,{size:24}),r.a.createElement($a.a,{autoFocus:!0,value:g,margin:"dense",label:"Flow Name",fullWidth:!0,variant:"outlined",onChange:w,disabled:i,inputProps:{maxLength:100}})),r.a.createElement(ke.a,null,r.a.createElement(Ae.a,{onClick:()=>T(j?"add":"edit"),disabled:i},"Cancel"),r.a.createElement(Ae.a,{onClick:j?O:A,color:"primary",variant:"contained",disabled:!g.trim()||i},j?"Create":"Update"))),r.a.createElement(Ne.a,{open:E,onClose:()=>b(!1),fullWidth:!0,maxWidth:"lg",fullScreen:!1},r.a.createElement(Te.a,null,"Flow: ".concat(g)),r.a.createElement(je.a,null,r.a.createElement(ve.a,{display:"flex",justifyContent:"center",minHeight:400},!f&&r.a.createElement(Je,null),r.a.createElement(kc,{containerName:h,token:S,onLoad:x})))))}),Dc=Object(Ee.a)(e=>({root:{padding:e.spacing(2),backgroundColor:e.palette.background.default,borderRadius:8},connectorPaper:{padding:e.spacing(2),margin:e.spacing(2,0),border:"1px solid #ccc",borderRadius:8,backgroundColor:"#f9f9f9",textAlign:"center",cursor:"pointer",transition:"background-color 0.3s","&:hover":{backgroundColor:"#e0e0e0"}},title:{marginBottom:e.spacing(2),color:e.palette.text.primary}}));var Ic=e=>{let{history:a,handleAlert:t,setLoading:l,loading:o,values:c,setValues:s}=e;const d=Dc(),[m,u]=Object(n.useState)({add:!1,type:""}),[p,g]=Object(n.useState)(null),[y,E]=Object(n.useState)(!1),b=U();return r.a.createElement(aa.a,{justifyContent:"center",container:!0,spacing:2},r.a.createElement(aa.a,{item:!0,xs:12},r.a.createElement(We.a,{align:"center",variant:"h6"},"Flow Information")),r.a.createElement(aa.a,{item:!0,xs:12,md:4},r.a.createElement(mt.a,{className:d.connectorPaper,onClick:()=>{u({add:!0,type:""})}},r.a.createElement(We.a,{variant:"subtitle1"},"Add New Flow"))),c.flowList.length>0&&r.a.createElement(aa.a,{item:!0,container:!0,xs:12,justifyContent:1===c.flowList.length?"center":"flex-start",spacing:2},c.flowList.map((e,a)=>r.a.createElement(aa.a,{item:!0,xs:12,md:4,key:a},r.a.createElement(mt.a,{className:d.connectorPaper,onClick:()=>(e=>{g(e)})(e)},r.a.createElement(We.a,{variant:"subtitle1"},e.flowName))))),r.a.createElement(Nc,{flowControl:m,setProgress:l,addProcessFlow:e=>{s(a=>Object(i.a)(Object(i.a)({},a),{},{flowList:[...a.flowList,e]})),u({add:!1,type:""})},handleAlert:t,handleDialogClose:()=>{u({add:!1,type:""})},progress:o,history:a,isProcess:!0}),p&&r.a.createElement(jt,{open:Boolean(p),maxWidth:"lg",onClose:()=>{g(null)},title:"Flow: ".concat(p.flowName)},r.a.createElement(ve.a,{display:"flex",justifyContent:"center"},y?r.a.createElement(r.a.Fragment,null):r.a.createElement(Je,null)," "),r.a.createElement(kc,{containerName:p.containerName,token:b,onLoad:function(){E(!0)}})))};const Mc=tt.c({thingName:tt.d().required("Thing Name is required")});var Pc=e=>{let{open:a,handleAlert:t,handleCloseNew:l,thingName:o}=e;const{thingsDispatch:c}=I(),[s,i]=Object(n.useState)(!1),m=le(async e=>{const a=await(async e=>{try{return(await B.a.post("".concat(H),e)).data}catch(a){z(a)}})({name:e.thingName});await c({type:d.ADD_THING,thing:a.newThing}),t(!0,"Thing added successfully","success"),l(a.newThing)},i,t),u=Object(at.e)({initialValues:{thingName:o||""},validationSchema:Mc,onSubmit:e=>{m(e)}});return r.a.createElement(Ne.a,{open:a,onClose:l},r.a.createElement(Te.a,null," New Thing "),r.a.createElement(Ce.a,null),r.a.createElement(je.a,null,r.a.createElement(wt.a,null,"Things are used to allow you to connect a pure MQTT client to Thingwings"),r.a.createElement("form",{onSubmit:u.handleSubmit},r.a.createElement($a.a,{autoFocus:!0,margin:"dense",label:"Thing Name",name:"thingName",type:"text",fullWidth:!0,value:u.values.thingName,onChange:u.handleChange,onBlur:u.handleBlur,error:u.touched.thingName&&Boolean(u.errors.thingName),helperText:u.touched.thingName&&u.errors.thingName}),r.a.createElement(ke.a,null,r.a.createElement(Ae.a,{onClick:l,color:"primary"},"Cancel"),r.a.createElement(Ae.a,{type:"submit",color:"primary"},"Add"),s&&r.a.createElement(Je,{size:24})))))};const Rc=e=>{let{openDialog:a,handleCloseDialog:t,selectData:l,setLoading:o,handleAlert:c,fetchDataAcl:s}=e;const[d,m]=Object(n.useState)({name:"",pubsub:3}),u=e=>{m(Object(i.a)(Object(i.a)({},d),{},{[e.target.name]:e.target.value}))},p=le(async()=>{const e={aclUserId:l.id,deviceId:l.device_id,thingId:l.thing_id,topicPath:d.name,pubsub:d.pubsub},a=await pe(e);t({topic:"".concat(l.device_id,"/").concat(d.name),acl_id:a.id}),s()},o,c);return r.a.createElement(Ne.a,{open:a.add,onClose:t},r.a.createElement(Te.a,null,"Add Permission"),r.a.createElement(je.a,null,r.a.createElement(wt.a,null),r.a.createElement($a.a,{fullWidth:!0,label:"Topic path",margin:"dense",name:"name",variant:"outlined",value:d.name,onChange:u}),r.a.createElement(pn.a,{fullWidth:!0},r.a.createElement(gn.a,null,"Apply to"),r.a.createElement(yn.a,{native:!0,value:d.pubsub,onChange:u,inputProps:{name:"pubsub",id:"pubsub-select"}},r.a.createElement("option",{value:3},"Publishes & Subscriptions"),r.a.createElement("option",{value:2},"Publishes"),r.a.createElement("option",{value:1},"Subscriptions")))),r.a.createElement(ke.a,null,r.a.createElement(Ae.a,{onClick:t,color:"primary"},"Cancel"),r.a.createElement(Ae.a,{onClick:p,color:"primary"},"Add")))},Fc=Object(fc.a)(),Bc=Object(Ee.a)(e=>({root:{padding:e.spacing(2)},inputContainer:{width:"100%",maxWidth:400,marginTop:20}}));var Lc=e=>{let{values:a,setValues:t,handleAlert:l,setLoading:o,loading:c}=e;const s=Bc(),{thingsState:m,thingsDispatch:u}=I(),[p,g]=Object(n.useState)([]),[y,E]=Object(n.useState)({add:!1,formType:""}),[b,h]=Object(n.useState)(!1);Object(n.useEffect)(()=>{le(async()=>{const e=await me();await u({type:d.SET_THINGS,value:e})},o,l)()},[u,o,l]);const v=le(async()=>{var e;if(null===(e=a.thing)||void 0===e?void 0:e.thing_id){const e=await ue(a.thing.thing_id);g(e)}},h,l);Object(n.useEffect)(()=>{v()},[a.thing]);const f=e=>{"thing"===y.formType&&t(a=>Object(i.a)(Object(i.a)({},a),{},{thing:e})),"permission"===y.formType&&t(t=>Object(i.a)(Object(i.a)({},t),{},{thing:Object(i.a)(Object(i.a)({},a.thing),{},{permission:e})})),E({add:!1,formType:""})};return r.a.createElement("div",{className:s.root},r.a.createElement(aa.a,{container:!0,justifyContent:"center"},r.a.createElement(aa.a,{item:!0,xs:12,md:6},r.a.createElement(We.a,{variant:"h6"},"Thing & Permission"),r.a.createElement("div",{className:s.inputContainer},r.a.createElement(or.a,{loading:c,size:"small",value:a.thing,onChange:(e,a)=>{a?"Add New Thing"==a?E({add:!0,formType:"thing"}):t(e=>Object(i.a)(Object(i.a)({},e),{},{thing:Object(i.a)(Object(i.a)({},a),{},{name:null===a||void 0===a?void 0:a.name})})):g([])},options:["Add New Thing",...m],getOptionLabel:e=>"string"===typeof e?e:e.name,renderInput:e=>r.a.createElement($a.a,Object.assign({},e,{label:"Thing",variant:"outlined",fullWidth:!0})),filterOptions:(e,a)=>Fc(e,a)})),r.a.createElement("div",{className:s.inputContainer},r.a.createElement(or.a,{loading:b,size:"small",value:a.thing.permission,onChange:(e,a)=>{"Add New Permission"===a?E({add:!0,formType:"permission"}):t(e=>Object(i.a)(Object(i.a)({},e),{},{thing:Object(i.a)(Object(i.a)({},e.thing),{},{permission:a})}))},options:["Add New Permission",...p],getOptionLabel:e=>"string"===typeof e?e:e.topic,renderInput:e=>r.a.createElement($a.a,Object.assign({},e,{label:"Permission",variant:"outlined",fullWidth:!0})),filterOptions:(e,a)=>Fc(e,a),clearOnBlur:!0})))),"thing"===y.formType&&r.a.createElement(Pc,{open:y.add,handleCloseNew:f,handleAlert:l,thingName:a.thing.name}),"permission"===y.formType&&r.a.createElement(Rc,{openDialog:y,handleCloseDialog:f,selectData:a.thing,setLoading:o,handleAlert:l,fetchDataAcl:v}))};const Uc=e=>{let{stepIndex:a,values:t,setValues:n,history:l,setLoading:o,handleAlert:c,loading:s,isStepValid:i}=e;const d=[r.a.createElement(Lc,{values:t,setValues:n,setLoading:o,handleAlert:c,loading:s}),r.a.createElement(Sc,{values:t,setValues:n,setLoading:o,handleAlert:c,loading:s}),r.a.createElement(wc,{values:t,setValues:n,handleAlert:c,setLoading:o,loading:s}),r.a.createElement(Ic,{values:t,setValues:n,handleAlert:c,setLoading:o,loading:s,history:l}),r.a.createElement(Ac,{values:t,setValues:n,handleAlert:c,setLoading:o,loading:s})];return a({grid:{background:e.palette.background.default},stepContent:{margin:10,flex:"0 0 80%",transition:"transform 0.5s ease",opacity:1},buttonContainer:{display:"flex",justifyContent:"flex-end",marginTop:e.spacing(2)}})),_c=["Thing","Topic","Connectors","Flow","Model"];var zc=e=>{const{history:a}=e,t=Wc(),[l,o]=Object(n.useState)(0),[c,s]=Object(n.useState)({thing:{thing_id:null,name:"",permission:""},topic:{topic_id:null,name:""},connectors:{sink:null,source:null},api:{modelName:""},flowList:[]}),[d,m]=Object(n.useState)(!1),[u,p]=Object(n.useState)(!1),[g,y]=Object(n.useState)({open:!1,message:"",severity:"info"}),E=Object(n.useCallback)((e,a,t)=>{y({open:e,message:a,severity:t})},[]),b=Object(n.useCallback)(()=>y(e=>Object(i.a)(Object(i.a)({},e),{},{open:!1})),[]),h=e=>{switch(e){case 0:case 1:case 2:case 3:case 4:default:return!0}};return r.a.createElement(aa.a,{row:!0,container:!0,justifyContent:"center",spacing:2},r.a.createElement(aa.a,{item:!0,xs:12,md:10,className:t.grid},r.a.createElement(mt.a,null,r.a.createElement(R,{open:g.open,message:g.message,severity:g.severity,onClose:b}),r.a.createElement(bc.a,{activeStep:l,alternativeLabel:!0},_c.map(e=>r.a.createElement(hc.a,{key:e},r.a.createElement(vc.a,null,e)))))),r.a.createElement(aa.a,{item:!0,xs:12,md:10,className:t.grid},r.a.createElement(mt.a,{style:{padding:10}},r.a.createElement(Uc,{stepIndex:l,values:c,setValues:s,history:a,setLoading:m,handleAlert:E,loading:d,isStepValid:h(l)}),r.a.createElement("div",{className:t.buttonContainer},r.a.createElement(Ae.a,{disabled:0===l,onClick:()=>{o(e=>Math.max(e-1,0))}},"Back"),r.a.createElement(Ae.a,{variant:"contained",color:"primary",onClick:()=>{l===_c.length-1?(o(0),s({thing:{thing_id:null,name:"",permission:""},topic:{topic_id:null,name:""},connectors:{sink:null,source:null}}),E(!0,"Process finished successfully","success")):o(e=>Math.min(e+1,_c.length-1))},disabled:!h(l)},l===_c.length-1?"Finish":"Next"))),r.a.createElement(Ne.a,{fullScreen:!0,open:u,onClose:()=>p(!1)},r.a.createElement(Te.a,null,"Reset"),r.a.createElement(je.a,null,"Do you want to resume the pipeline process?"),r.a.createElement(ke.a,null,r.a.createElement(Ae.a,{onClick:()=>p(!1),color:"primary"},"No"),r.a.createElement(Ae.a,{onClick:()=>o(0),color:"primary"},"Yes")))))},qc=t(475),Gc=t.n(qc);const Hc=Object(Ee.a)(e=>({root:{marginBottom:e.spacing(2)},searchInput:{marginRight:e.spacing(1),width:"100%",maxWidth:300},addButton:{[e.breakpoints.down("sm")]:{marginTop:e.spacing(1),width:"100%"}}}));var Vc=e=>{let{handleSearch:a,openForm:t}=e;const n=Hc();return r.a.createElement("div",{className:n.root},r.a.createElement(aa.a,{container:!0},r.a.createElement(aa.a,{item:!0,xs:12,sm:6},r.a.createElement(bt,{className:n.searchInput,placeholder:"Search database",onChange:a})),r.a.createElement(aa.a,{item:!0,xs:12,sm:6,style:{textAlign:"right"}},r.a.createElement(Ae.a,{className:n.addButton,color:"primary",variant:"contained",onClick:()=>{t()}},"Add Database"))))};const Kc=Object(Ht.a)(e=>({root:{[e.breakpoints.down("sm")]:{width:"100%"}},padding:{padding:e.spacing(1)},username:{padding:e.spacing(1)},searchInputContainer:{display:"flex",alignItems:"center",padding:e.spacing(1),borderRadius:e.shape.borderRadius,backgroundColor:e.palette.background.paper,boxShadow:e.shadows[1],flexGrow:1},searchInput:{marginLeft:e.spacing(1),flex:1},iconButton:{padding:10},btn:{[e.breakpoints.down("xs")]:{width:"100%",marginBottom:e.spacing(1)}},table:{minWidth:650,[e.breakpoints.down("xs")]:{minWidth:"100%","& thead":{display:"none"},"& tbody, & tr, & td":{display:"block",width:"100%"},"& td":{textAlign:"right",paddingLeft:"50%",position:"relative"},"& td::before":{content:"attr(data-label)",position:"absolute",left:0,width:"50%",paddingLeft:e.spacing(2),fontWeight:"bold",textAlign:"left"}}},popover:{pointerEvents:"none"},paper:{padding:e.spacing(1)},fallbackMessage:{margin:10}}));var Yc=e=>{let{handleAlert:a}=e;const t=Kc(),{databasesState:l,databasesDispatch:o}=I(),[c,s]=Object(n.useState)(null),[i,m]=Object(n.useState)(!1),[u,p]=Object(n.useState)(!1),g=()=>{c&&s(null),p(!1)},[y,E]=Object(n.useState)(!1),b=()=>{E(!1)},h=le(async()=>{const e=await ge();await o({type:d.SET_DATABASES,value:e})},m,a),v=le(async()=>{await(async e=>{try{return(await B.a.delete("".concat(K,"/").concat(e))).data}catch(a){z(a)}})(c.id),b(),await o({type:d.DELETE_DATABASE,id:c.id})},m,a);Object(n.useEffect)(()=>{h()},[]);const[f,C]=Object(n.useState)(""),S=l.filter(e=>e.dbname.toLowerCase().includes(f.toLowerCase())),x=[{key:"edit",label:"Edit Database",onClick:()=>{p(!0),A()}},{key:"delete",label:"Delete Database",onClick:()=>{E(!0),A()}}],[w,O]=r.a.useState(null),A=()=>{O(null)};return r.a.createElement(r.a.Fragment,null,r.a.createElement(Vc,{handleSearch:e=>{C(e.target.value)},openForm:()=>{p(!0),A()}}),r.a.createElement(Ja.a,{style:{padding:5}},r.a.createElement(ze.a,{anchorEl:w,open:Boolean(w),onClose:A},x.map(e=>r.a.createElement(Nt.a,{key:e.key,onClick:e.onClick},e.label))),r.a.createElement(aa.a,{style:{padding:10},item:!0,xs:12},i?r.a.createElement(Je,{size:20}):r.a.createElement(Bt.a,null,r.a.createElement(Lt.a,{className:t.table,"aria-label":"responsive table"},r.a.createElement(Ut.a,null,r.a.createElement(Wt.a,null,r.a.createElement(_t.a,null,"Name"),r.a.createElement(_t.a,{align:"center"},"Type"),r.a.createElement(_t.a,{align:"center"},"Username"),r.a.createElement(_t.a,{align:"center"},"URL"),r.a.createElement(_t.a,{align:"center"},"Actions"))),r.a.createElement(qt.a,null,S.map(e=>r.a.createElement(Wt.a,{key:e.id},r.a.createElement(_t.a,{align:"center","data-label":"Name"},e.dbname),r.a.createElement(_t.a,{align:"center","data-label":"Type"},e.dbtype),r.a.createElement(_t.a,{align:"center","data-label":"Username"},e.username),r.a.createElement(_t.a,{align:"center","data-label":"URL"},e.url),r.a.createElement(_t.a,{align:"center","data-label":"Actions"},r.a.createElement(Le.a,{edge:"end",onClick:a=>((e,a)=>{s(w?[]:a),O(w?null:e.currentTarget)})(a,e)},r.a.createElement(Kt.a,null))))))),0===(null===S||void 0===S?void 0:S.length)&&r.a.createElement(aa.a,{item:!0,xs:12,style:{display:"flex",justifyContent:"center"}},r.a.createElement(We.a,{className:t.fallbackMessage,variant:"h6"},"No available databases"))))),r.a.createElement(jt,{open:y,onClose:b,title:"Confirm Deletion",contentText:"Are you sure you want to delete this item?",onConfirm:v,confirmText:"Delete"}),r.a.createElement(jt,{open:u,onClose:g,title:"Database Information"},r.a.createElement(eo,{db:c,handleCloseNew:g,handleAlert:a,setLoading:m})))},Zc=t(476),Xc=t.n(Zc);const Jc=Object(Ht.a)(e=>({root:{backgroundColor:e.palette.background.default},tableContainer:{flexGrow:1,overflow:"auto","& .MuiTableCell-root":{padding:"15px"},"& .MuiPaper-elevation4":{boxShadow:"0 0 0 0"}},fallbackMessage:{textAlign:"center",marginTop:e.spacing(4),color:e.palette.text.secondary},paginationControls:{display:"flex",alignItems:"center",justifyContent:"center",marginTop:e.spacing(3)},pageInfo:{margin:e.spacing(0,2)},messagesContainer:{flex:1,overflowY:"auto",maxHeight:"calc(100vh - 250px - 100px)"}}));var Qc=e=>{let{handleAlert:a}=e;const t=Jc(),{sourcesState:l,sourcesDispatch:o}=I(),[c,s]=Object(n.useState)({id:"",name:""}),[i,m]=Object(n.useState)([]),[u,p]=Object(n.useState)({}),[g,y]=Object(n.useState)(1),[E,b]=Object(n.useState)(50),[h,v]=Object(n.useState)(0),[f,C]=Object(n.useState)(!1),[S,x]=Object(n.useState)(!1),[w,O]=r.a.useState(null),[A,T]=Object(n.useState)(null),j=e=>{T(e)},k=()=>{T(null)},N=le(async()=>{await(async e=>{try{return(await B.a.delete("".concat(Y,"/").concat(e))).data}catch(a){z(a)}})(w),await o({type:d.DELETE_SOURCE,sourceId:w}),k()},x,a);Object(n.useEffect)(()=>{le(async()=>{const e=await(async()=>{try{return(await B.a.get("".concat(Y))).data}catch(e){z(e)}})();e.length>0&&await s({id:e[0].id,name:e[0].source_name}),await o({type:d.SET_SOURCES,value:e})},x,a)()},[]),Object(n.useEffect)(()=>{const e=le(async()=>{const{messages:e,total:a}=c.id?await(async(e,a,t)=>{try{return(await B.a.get("".concat(Y,"/messages/").concat(e,"?page=").concat(a,"&size=").concat(t))).data}catch(n){z(n)}})(c.id,g,E):{fetchedMessages:[],total:0};m(e),v(a)},x,a);c.id&&e()},[g,E,c.id,f]);return r.a.createElement(r.a.Fragment,null,r.a.createElement(aa.a,{container:!0,style:{height:"calc(100vh - 250px)"},spacing:2},r.a.createElement(aa.a,{item:!0,xs:12,md:5,style:{height:"100%"}},r.a.createElement(Bt.a,{component:mt.a,className:t.tableContainer},r.a.createElement(Lt.a,{"aria-label":"simple table"},r.a.createElement(Ut.a,null,r.a.createElement(Wt.a,null,r.a.createElement(_t.a,null,"ID"),r.a.createElement(_t.a,null,"DataStore Type"),r.a.createElement(_t.a,null,"DataStore Name"),r.a.createElement(_t.a,null,"Actions"))),r.a.createElement(qt.a,null,l.map(e=>r.a.createElement(Wt.a,{key:e.id,selected:e.id===c.id},r.a.createElement(_t.a,null,e.id),r.a.createElement(_t.a,{component:"th",scope:"row"},e.dbname),r.a.createElement(_t.a,{component:"th",scope:"row"},e.source_name),r.a.createElement(_t.a,null,r.a.createElement(Le.a,{"aria-label":"play",onClick:()=>{return a=e.id,t=e.source_name,m([]),s({id:a,name:t}),void C(e=>!e);var a,t}},r.a.createElement(Xc.a,null)),r.a.createElement(Le.a,{"aria-label":"delete",onClick:()=>{O(e.id),j(1)}},r.a.createElement(tn.a,null))))))))),r.a.createElement(aa.a,{item:!0,xs:12,md:7,style:{height:"100%"}},r.a.createElement(mt.a,{style:{height:"100%",padding:10,display:"flex",flexDirection:"column"}},r.a.createElement(We.a,{variant:"h6"},"Messages"),r.a.createElement(Ce.a,{style:{margin:5}}),r.a.createElement(aa.a,{container:!0,spacing:1,className:t.messagesContainer},S?r.a.createElement(aa.a,{container:!0,justifyContent:"center"},r.a.createElement(Je,null)):0===i.length?r.a.createElement(aa.a,{container:!0,justifyContent:"center",alignItems:"center",style:{marginTop:20,height:"100%"}},r.a.createElement(We.a,null,"No messages available")):null===i||void 0===i?void 0:i.map((e,a)=>r.a.createElement(aa.a,{style:{padding:"10px"},item:!0,lg:4,md:6,sm:12,xs:12,key:a},r.a.createElement(nn,{name:c.name,timestamp:e._source?ae(e._source.creationDate):ae(e.creationDate),message:e,onOpen:()=>(e=>{p({message:e._source||e}),j(3)})(e)})))),0!==(null===i||void 0===i?void 0:i.length)&&r.a.createElement("div",{className:t.paginationControls,style:{marginTop:"20px",alignSelf:"flex-end"}},r.a.createElement(Le.a,{color:"primary",onClick:()=>{g>1&&y(g-1)},disabled:1===g,size:"small"},r.a.createElement(Rn.a,null)),r.a.createElement(We.a,{variant:"caption",className:t.pageInfo},"Page ",g," of ",Math.ceil(h/E)),r.a.createElement(Le.a,{color:"primary",onClick:()=>{g*E=h,size:"small"},r.a.createElement(xr.a,null)))))),r.a.createElement(Ne.a,{open:1===A,onClose:k},r.a.createElement(Te.a,{disableTypography:!1},"Confirmation"),r.a.createElement(je.a,{dividers:!0},"Are you sure you want to delete this source?",r.a.createElement(M.a,{severity:"error"},"Note that deleting the data store will delete all of its data and its associated sink connector!!")),r.a.createElement(ke.a,null,r.a.createElement(Ae.a,{onClick:N,color:"primary",size:"small"},"Yes"),r.a.createElement(Ae.a,{onClick:k,color:"primary",size:"small"},"No"))),r.a.createElement(Ne.a,{open:3===A,onClose:k},r.a.createElement(Te.a,{disableTypography:!1},c.name),r.a.createElement(je.a,{dividers:!0},r.a.createElement(Qt,{name:c.name,message:u._source?u._source:u,handleAlert:a}))))};const $c=Object(Ht.a)(e=>({root:{backgroundColor:e.palette.background.default}}));function es(e){const a=$c(),{children:t,value:n,index:l}=e;return r.a.createElement(mt.a,{className:a.root,square:!0},n===l&&r.a.createElement(ve.a,{p:3},r.a.createElement(We.a,null,t)))}function as(e){let{handleAlert:a}=e;const t=Object(be.a)(),[n,l]=r.a.useState(0);return r.a.createElement(r.a.Fragment,null,r.a.createElement(Za.a,{value:n,onChange:(e,a)=>{l(a)},indicatorColor:"primary",textColor:"primary"},r.a.createElement(Xa.a,{label:"DataStores"}),r.a.createElement(Xa.a,{label:"Databases"})),r.a.createElement(Gc.a,{axis:"rtl"===t.direction?"x-reverse":"x",index:n,onChangeIndex:e=>{l(e)}},r.a.createElement(es,{value:n,index:0,dir:t.direction},r.a.createElement(Qc,{handleAlert:a})),r.a.createElement(es,{value:n,index:1,dir:t.direction},r.a.createElement(Yc,{handleAlert:a}))))}var ts=()=>{const[e,a]=Object(n.useState)({open:!1,message:"",severity:""});return r.a.createElement(r.a.Fragment,null,r.a.createElement(R,{open:e.open,message:e.message,onClose:()=>{a(e=>Object(i.a)(Object(i.a)({},e),{},{open:!1}))},severity:e.severity}),r.a.createElement(as,{handleAlert:(e,t,n)=>{a({open:e,message:t,severity:n})}}))};Object(Ee.a)(e=>({root:{},imageContainer:{height:64,width:64,margin:"0 auto",border:"1px solid ".concat(e.palette.divider),borderRadius:"5px",overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center"},image:{width:"100%"},statsItem:{display:"flex",alignItems:"center"},statsIcon:{color:e.palette.icon,marginRight:e.spacing(1)}}));t(714);Object(Ee.a)(e=>({root:{},row:{height:"42px",display:"flex",alignItems:"center",marginTop:e.spacing(1)},spacer:{flexGrow:1},importButton:{marginRight:e.spacing(1)},exportButton:{marginRight:e.spacing(1)},searchInput:{marginRight:e.spacing(1)}}));Dr()(),Dr()();const ns=Object(Ee.a)(e=>({root:{padding:e.spacing(3)},content:{marginTop:e.spacing(2)},pagination:{marginTop:e.spacing(3),display:"flex",alignItems:"center",justifyContent:"flex-end"}}));var rs=e=>{const{history:a,url:t}=e,n=ns();return r.a.createElement("div",{className:n.root},r.a.createElement(jc.a,{url:"https://www.thingwings.com:4000/apis",width:"100%",height:"800px",id:"myId",className:"myClassname",display:"initial",position:"relative"}))};const ls=Object(Ht.a)(e=>({pageRoot:{width:"100%",height:"calc(100vh - 120px)",display:"flex",flexDirection:"column"},iframeContainer:{position:"relative",flexGrow:1,border:"1px solid ".concat(e.palette.divider),borderRadius:e.shape.borderRadius,marginTop:e.spacing(1),overflow:"hidden",padding:10,background:"#fafafa"},loadingOverlay:{position:"absolute",top:0,left:0,width:"100%",height:"100%",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",backgroundColor:"rgba(255, 255, 255, 0.9)",zIndex:10},iframe:{border:"0",width:"100%",height:"100%",display:"block"}}));var os=e=>{const a=ls(),t=Object(be.a)(),l=U(),o=e.match.params.id,c="".concat("https://www.thingwings.com","/flow-editor/").concat(o,"/?token=").concat(l),[s,i]=Object(n.useState)(!1);return r.a.createElement(ve.a,{className:a.pageRoot},r.a.createElement(ve.a,{className:a.iframeContainer},!s&&r.a.createElement(ve.a,{className:a.loadingOverlay},r.a.createElement(Xe.a,{color:"primary",size:60}),r.a.createElement(We.a,{variant:"h6",color:"primary",style:{marginTop:t.spacing(2)}},"Loading Node-RED...")),r.a.createElement(jc.a,{url:c,className:a.iframe,onLoad:()=>i(!0),allowFullScreen:!0})))},cs=t(161);const ss=Object(Ht.a)(e=>({buttonProgress:{color:cs.a[500],position:"absolute",top:"50%",left:"50%",marginTop:-12,marginLeft:-12},chip:{color:"white",padding:"4px 10px",borderRadius:"12px",boxShadow:"0 2px 5px rgba(0,0,0,0.2)",display:"inline-block"}}));var is=r.a.memo(e=>{let{history:a}=e;const t=ss(),{flowsState:l,flowsDispatch:o}=I(),[c,s]=Object(n.useState)(null),[m,u]=Object(n.useState)(""),[p,g]=Object(n.useState)(!1),[y,E]=Object(n.useState)(!1),[b,h]=Object(n.useState)({open:!1,message:"",severity:"info"}),[v,f]=Object(n.useState)(0),[C,S]=Object(n.useState)(5),[x,w]=Object(n.useState)(""),[O,A]=Object(n.useState)({add:!1,edit:!1,delete:!1}),T=Object(n.useCallback)((e,a,t)=>{h({open:e,message:a,severity:t})},[]),j=Object(n.useCallback)(()=>{h(e=>Object(i.a)(Object(i.a)({},e),{},{open:!1}))},[]),k=Object(n.useCallback)(e=>{A(a=>Object(i.a)(Object(i.a)({},a),{},{[e]:!0}))},[]),N=Object(n.useCallback)(e=>{A(a=>Object(i.a)(Object(i.a)({},a),{},{[e]:!1}))},[]),D=Object(n.useCallback)((e,a)=>{f(a)},[]),M=Object(n.useCallback)(e=>{const a=parseInt(e.target.value,10);S(a),f(0)},[]),P=Object(n.useCallback)(e=>{w(e.target.value)},[]);Object(n.useEffect)(()=>{le(async()=>{const e=await(async()=>{try{return(await B.a.get("".concat(X,"/flows"))).data}catch(e){z(e)}})();o({type:d.SET_FLOWS,value:e})},E,T)()},[o,T]);const F=Object(n.useCallback)(le(async()=>{(null===c||void 0===c?void 0:c.id)&&(await(async e=>{try{return(await B.a.delete("".concat(X,"/flows/").concat(e))).data}catch(a){z(a)}})(c.id),o({type:d.DELETE_FLOW,flowId:c.id}),T(!0,"Flow deleted successfully","success"),N("delete"))},g,T),[c,o,T,N]),L=Object(n.useCallback)(e=>{a.push("nodered/".concat(e.containerName))},[a]),U=Object(n.useCallback)(e=>{s(e),u(e.name),k("edit")},[k]),W=Object(n.useCallback)(e=>{s(e),k("delete")},[k]),_=Object(n.useMemo)(()=>[{label:"Edit Flow",onClick:L},{label:"Update Name",onClick:U},{label:"Delete Flow",onClick:W}],[L,U,W]),q=Object(n.useMemo)(()=>[{key:"name",label:"Name"},{key:"created",label:"Created",render:e=>ae(e.created)},{key:"updated",label:"Updated",render:e=>ae(e.updated)},{key:"status",label:"Status",render:e=>{const a={deployed:{label:"Deployed",color:"#4caf50"},undeployed:{label:"Undeployed",color:"#f44336"},paused:{label:"Paused",color:"#ff9800"}}[e.status]||{label:e.status,color:"#9e9e9e"};return r.a.createElement(il.a,{label:a.label,size:"small",style:{backgroundColor:a.color,color:"white",fontWeight:600,minWidth:120},className:t.statusChip})}}],[t.chip]),G=Object(n.useMemo)(()=>l.filter(e=>e.name.toLowerCase().includes(x.toLowerCase())),[l,x]),H=Object(n.useMemo)(()=>{const e=v*C;return G.slice(e,e+C)},[G,v,C]);return r.a.createElement(r.a.Fragment,null,r.a.createElement(R,{open:b.open,message:b.message,onClose:j,severity:b.severity}),r.a.createElement(xt,{title:"Flows",handleSearch:P,openForm:()=>k("add")}),r.a.createElement(aa.a,{container:!0,spacing:3},r.a.createElement(aa.a,{item:!0,xs:12},r.a.createElement(Ce.a,null)),r.a.createElement(aa.a,{item:!0,xs:12},y?r.a.createElement(Je,null):r.a.createElement(Zt,{data:H,columns:q,title:"Flows",rowActions:_,pagination:!0,loading:y,page:v,rowsPerPage:C,onPageChange:D,onRowsPerPageChange:M,count:G.length}))),r.a.createElement(Nc,{flowControl:O,name:m,setProgress:g,handleAlert:T,handleDialogClose:N,flow:c,progress:p,history:a}),r.a.createElement(Ne.a,{open:O.delete,onClose:()=>N("delete"),maxWidth:"xs",fullWidth:!0},r.a.createElement(Te.a,null,"Delete Flow"),r.a.createElement(je.a,{dividers:!0},'Are you sure you want to delete "',null===c||void 0===c?void 0:c.name,'"? This action cannot be undone.'),r.a.createElement(ke.a,null,r.a.createElement(ve.a,{position:"relative"},r.a.createElement(Ae.a,{onClick:F,color:"secondary",variant:"contained",disabled:p},"Delete"),r.a.createElement(Ae.a,{onClick:()=>N("delete"),color:"primary",disabled:p},"Cancel"),p&&r.a.createElement(Xe.a,{size:24,className:t.buttonProgress})))))}),ds=t(478),ms=t.n(ds),us=t(477),ps=t.n(us);const gs=["value","onChange"],ys=["label"],Es=["children","value","index"],bs=e=>{let{value:a,onChange:t}=e,n=Object(Se.a)(e,gs);return r.a.createElement(Za.a,Object.assign({value:a,onChange:t},n))},hs=e=>{let{label:a}=e,t=Object(Se.a)(e,ys);return r.a.createElement(Xa.a,Object.assign({label:a},t))},vs=e=>{let{children:a,value:t,index:n}=e,l=Object(Se.a)(e,Es);return r.a.createElement("div",Object.assign({role:"tabpanel",hidden:t!==n,id:"simple-tabpanel-".concat(n),"aria-labelledby":"simple-tab-".concat(n)},l),t===n&&r.a.createElement("div",null,a))},fs=Object(Ht.a)(e=>({root:{padding:e.spacing(3)},itemContainer:{padding:e.spacing(2),marginBottom:e.spacing(1)},label:{fontWeight:500,color:e.palette.text.secondary,fontSize:"0.875rem"},value:{fontWeight:600,color:e.palette.text.primary,fontSize:"0.95rem"},statusChip:{fontWeight:600}})),Cs=e=>{var a;let{selectData:t}=e;const n=fs();if(!t)return r.a.createElement(ve.a,{p:3},r.a.createElement(We.a,{color:"textSecondary"},"No data available"));const l=e=>{switch(null===e||void 0===e?void 0:e.toLowerCase()){case"running":return"primary";case"stopped":return"secondary";case"error":return"error";default:return"default"}},o=e=>{let{label:a,value:t,isStatus:o=!1}=e;return r.a.createElement(mt.a,{elevation:0,className:n.itemContainer},r.a.createElement(aa.a,{container:!0,alignItems:"center",spacing:2},r.a.createElement(aa.a,{item:!0,xs:12,sm:4},r.a.createElement(We.a,{variant:"body2",className:n.label},a)),r.a.createElement(aa.a,{item:!0,xs:12,sm:8},o?r.a.createElement(il.a,{label:t,color:l(t),size:"small",className:n.statusChip}):r.a.createElement(We.a,{variant:"body1",className:n.value},t))))};return r.a.createElement(ve.a,{className:n.root},r.a.createElement(o,{label:"Created",value:new Date(t.created_at).toLocaleString()}),r.a.createElement(o,{label:"Updated",value:new Date(t.updated_at).toLocaleString()}),r.a.createElement(o,{label:"Device ID",value:t.device_id||"N/A"}),r.a.createElement(o,{label:"Status",value:t.status||"Unknown",isStatus:!0}),r.a.createElement(o,{label:"Messages Count",value:(null===(a=t.messages_count)||void 0===a?void 0:a.toString())||"0"}))},Ss=Object(Ht.a)(e=>({root:{padding:e.spacing(3)},credentialItem:{padding:e.spacing(2),marginBottom:e.spacing(1),backgroundColor:e.palette.background.default,borderRadius:"8px"},label:{fontWeight:500,color:e.palette.text.secondary,fontSize:"0.875rem"},value:{fontWeight:600,color:e.palette.text.primary,fontFamily:"Monaco, Consolas, monospace",fontSize:"0.9rem"},copyButton:{marginLeft:e.spacing(1),color:e.palette.primary.main}})),xs=e=>{let{selectData:a}=e;const t=Ss(),l=e=>{let{label:a,value:l,isSensitive:o=!1}=e;const[c,s]=Object(n.useState)(!o);return r.a.createElement(mt.a,{elevation:0,className:t.credentialItem},r.a.createElement(aa.a,{container:!0,alignItems:"center",spacing:2},r.a.createElement(aa.a,{item:!0,xs:12,sm:4},r.a.createElement(We.a,{variant:"body2",className:t.label},a)),r.a.createElement(aa.a,{item:!0,xs:12,sm:8},r.a.createElement(ve.a,{display:"flex",alignItems:"center"},r.a.createElement(We.a,{variant:"body1",className:t.value},c?l:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022"),r.a.createElement(ve.a,{ml:1},o&&r.a.createElement(Qe.a,{title:c?"Hide":"Show"},r.a.createElement(Le.a,{size:"small",onClick:()=>s(!c)},c?r.a.createElement(bo.a,null):r.a.createElement(yo.a,null))),r.a.createElement(Qe.a,{title:"Copy to clipboard"},r.a.createElement(Le.a,{size:"small",className:t.copyButton,onClick:()=>{return e=l,void navigator.clipboard.writeText(e);var e}},r.a.createElement(Po.a,null))))))))};return a?r.a.createElement(ve.a,{className:t.root},r.a.createElement(l,{label:"Host",value:"mqtts://mqtt.thingwings.com"}),r.a.createElement(l,{label:"Port",value:"8883"}),r.a.createElement(l,{label:"Username",value:a.username||"N/A"}),r.a.createElement(l,{label:"Password",value:a.password||"N/A",isSensitive:!0})):r.a.createElement(ve.a,{p:3},r.a.createElement(We.a,{color:"textSecondary"},"No credentials available"))};var ws=e=>{let{aclUserId:a,thingId:t,handleAlert:l,fetchDataAcl:o,Acls:c}=e;const[s,i]=Object(n.useState)(!1),[d,m]=Object(n.useState)(null),[u,p]=Object(n.useState)(!1),g=le(async()=>{await(async(e,a)=>{try{return(await B.a.delete("".concat(V,"/").concat(e,"/").concat(a))).data}catch(t){z(t)}})(a,d),o(),i(!1)},p,l),y=()=>{i(!1)};return r.a.createElement(Bt.a,null,r.a.createElement(Lt.a,null,r.a.createElement(Ut.a,null,r.a.createElement(Wt.a,null,r.a.createElement(_t.a,null,"Topic"),r.a.createElement(_t.a,null,"Access Type"),r.a.createElement(_t.a,null,"Action"))),r.a.createElement(qt.a,null,c.map(e=>r.a.createElement(Wt.a,{key:e.acl_id},r.a.createElement(_t.a,null,e.topic),r.a.createElement(_t.a,null,3==e.rw?"Publishes & Subscriptions":1==e.rw?"Subscriptions":"Publishes"),r.a.createElement(_t.a,null,r.a.createElement(Le.a,{onClick:()=>{return a=e.acl_id,m(a),void i(!0);var a}},r.a.createElement(tn.a,null))))))),r.a.createElement(Ne.a,{open:s,onClose:y},r.a.createElement(Te.a,null,"Confirmation"),r.a.createElement(je.a,null,r.a.createElement(wt.a,null,"Are you sure you want to delete this permission?")),r.a.createElement(ke.a,null,r.a.createElement(Ae.a,{onClick:y,color:"primary"},"Cancel"),r.a.createElement(Ae.a,{disabled:u,onClick:g,color:"primary"},"Delete"),u&&r.a.createElement(Je,{size:24}))))};const Os=Object(Ht.a)(e=>({root:{padding:e.spacing(2)},header:{padding:e.spacing(2),marginBottom:e.spacing(2),display:"flex",justifyContent:"space-between",alignItems:"center",backgroundColor:e.palette.background.default},headerLeft:{display:"flex",alignItems:"center",gap:e.spacing(1)},aclCount:{backgroundColor:e.palette.primary.main,color:"white",borderRadius:"12px",padding:e.spacing(.5,1.5),fontSize:"0.75rem",fontWeight:600},loadingContainer:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:120}})),As=e=>{let{selectData:a,handleAlert:t}=e;const l=Os(),[o,c]=Object(n.useState)([]),[s,d]=Object(n.useState)(!0),[m,u]=Object(n.useState)({add:!1,delete:!1});Object(n.useEffect)(()=>{a&&p()},[a]);const p=le(async()=>{d(!0);const e=a.id;if(!e)throw new Error("No valid ID found for fetching ACL records");const t=await ue(e);c(t)},d,t);return a?r.a.createElement(ve.a,{className:l.root},r.a.createElement(mt.a,{elevation:0,className:l.header},r.a.createElement(ve.a,{className:l.headerLeft},r.a.createElement(We.a,{variant:"h6"},"Permissions"),!s&&o.length>0&&r.a.createElement(ve.a,{className:l.aclCount},o.length)),r.a.createElement(Ae.a,{variant:"contained",color:"primary",startIcon:r.a.createElement(Ll.a,null),onClick:()=>{return e="add",void u(a=>Object(i.a)(Object(i.a)({},a),{},{[e]:!0}));var e},disabled:s,size:"small"},"Add Permission")),s?r.a.createElement(ve.a,{className:l.loadingContainer},r.a.createElement(Je,null)):r.a.createElement(ws,{handleAlert:t,setAcls:c,Acls:o,aclUserId:a.id,thingId:a.thing_id,fetchDataAcl:p}),r.a.createElement(Rc,{openDialog:m,handleCloseDialog:()=>{u({add:!1,delete:!1})},selectData:a,setLoading:d,handleAlert:t,fetchDataAcl:p})):r.a.createElement(ve.a,{p:2},r.a.createElement(We.a,{color:"textSecondary"},"No thing data available"))},Ts=Object(Ht.a)(e=>({root:{padding:e.spacing(2),backgroundColor:e.palette.background.default,minHeight:"100%"},headerCard:{backgroundColor:e.palette.background.paper,boxShadow:"0 2px 12px rgba(0,0,0,0.1)",borderRadius:"12px",marginBottom:e.spacing(3)},tabSection:{backgroundColor:e.palette.background.paper,borderRadius:"12px",boxShadow:"0 2px 12px rgba(0,0,0,0.1)",overflow:"hidden"},saveButton:{backgroundColor:e.palette.primary.main,color:"white","&:hover":{backgroundColor:e.palette.primary.dark,transform:"translateY(-1px)"},transition:"all 0.2s ease-in-out"},disabledSave:{backgroundColor:e.palette.action.disabled},title:{fontWeight:600,color:e.palette.text.primary,marginBottom:e.spacing(1)},loadingContainer:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:200,backgroundColor:e.palette.background.paper,borderRadius:"12px"}})),js=e=>{let{selectData:a,thingName:t,handleThingNameChange:l,handleAlert:o,handleChange:c,value:s}=e;const i=Ts(),[m,u]=Object(n.useState)(!1),{thingsDispatch:p}=I(),g=Object(n.useMemo)(()=>null===a||void 0===a?void 0:a.thing_id,[null===a||void 0===a?void 0:a.thing_id]),y=Object(n.useCallback)(le(async()=>{g?(await(async(e,a)=>{try{return(await B.a.put("".concat(H,"/").concat(e),a)).data}catch(t){z(t)}})(g,{name:t}),p({type:d.UPDATE_THING,thingId:g,name:t}),o(!0,"Thing updated successfully","success")):o(!0,"Thing ID is required","error")},u,o),[g,t,p,o]);return a?r.a.createElement(ve.a,{className:i.root},r.a.createElement(Ja.a,{className:i.headerCard},r.a.createElement(Qa.a,null,r.a.createElement(We.a,{variant:"h6",className:i.title},"Thing Configuration"),r.a.createElement(aa.a,{container:!0,spacing:3,alignItems:"center"},r.a.createElement(aa.a,{item:!0,xs:12,sm:8,md:9},r.a.createElement($a.a,{autoFocus:!0,value:t,margin:"dense",label:"Thing Name",type:"text",fullWidth:!0,onChange:l,variant:"outlined",disabled:m,inputProps:{"aria-label":"Thing name input field",maxLength:100},size:"small"})),r.a.createElement(aa.a,{item:!0,xs:12,sm:4,md:3},r.a.createElement(ve.a,{display:"flex",justifyContent:"flex-end",alignItems:"center"},r.a.createElement(Le.a,{"aria-label":"Save thing changes",className:"".concat(i.saveButton," ").concat(m||!t.trim()?i.disabledSave:""),onClick:y,disabled:m||!t.trim(),size:"medium"},r.a.createElement(kr.a,null)),m&&r.a.createElement(ve.a,{ml:2},r.a.createElement(Je,{color:"primary",size:20}))))))),r.a.createElement(mt.a,{className:i.tabSection},r.a.createElement(bs,{value:s,onChange:c,"aria-label":"Thing details tabs"},r.a.createElement(hs,{label:r.a.createElement(r.a.Fragment,null,r.a.createElement(Nl.a,{style:{marginRight:8,fontSize:18}}),"Details"),id:"thing-details-tab-0"}),r.a.createElement(hs,{label:r.a.createElement(r.a.Fragment,null,r.a.createElement(ps.a,{style:{marginRight:8,fontSize:18}}),"Credentials"),id:"thing-details-tab-1"}),r.a.createElement(hs,{label:r.a.createElement(r.a.Fragment,null,r.a.createElement(ms.a,{style:{marginRight:8,fontSize:18}}),"Permissions"),id:"thing-details-tab-2"})),r.a.createElement(vs,{value:s,index:0,"aria-labelledby":"thing-details-tab-0"},r.a.createElement(Cs,{selectData:a})),r.a.createElement(vs,{value:s,index:1,"aria-labelledby":"thing-details-tab-1"},r.a.createElement(xs,{selectData:a})),r.a.createElement(vs,{value:s,index:2,"aria-labelledby":"thing-details-tab-2"},r.a.createElement(As,{selectData:a,handleAlert:o})))):r.a.createElement(ve.a,{className:i.loadingContainer},r.a.createElement(Je,{color:"primary"}))};js.defaultProps={selectData:null,value:0};var ks=r.a.memo(js);const Ns=Object(Ht.a)(e=>({drawerPaper:{width:550,top:"65px",padding:"10px",[e.breakpoints.down("sm")]:{width:"80%"}},statusChip:{fontWeight:600,fontSize:"0.75rem",minWidth:100},tableContainer:{height:"100%",display:"flex",flexDirection:"column",minHeight:0}}));var Ds=()=>{const e=Ns(),{thingsState:a,thingsDispatch:t}=I(),[l,o]=Object(n.useState)(null),[c,s]=Object(n.useState)(""),[m,u]=Object(n.useState)(!1),[p,g]=Object(n.useState)(!1),[y,E]=Object(n.useState)(!1),[b,h]=Object(n.useState)(!1),[v,f]=Object(n.useState)(!1),[C,S]=Object(n.useState)(""),[x,w]=Object(n.useState)(0),[O,A]=Object(n.useState)(5),[T,j]=Object(n.useState)({open:!1,message:"",severity:"info"}),[k,N]=Object(n.useState)(0),D=Object(n.useCallback)((e,a,t)=>{j({open:e,message:a,severity:t})},[]),M=Object(n.useCallback)(()=>{j(e=>Object(i.a)(Object(i.a)({},e),{},{open:!1}))},[]),P=Object(n.useCallback)((function(e){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;u(e),a&&(o(a),s(a.name))}),[]),F=Object(n.useCallback)(()=>g(!0),[]),L=Object(n.useCallback)(()=>g(!1),[]),U=Object(n.useCallback)((function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;o(e),E(!0)}),[]),W=Object(n.useCallback)(()=>{E(!1),o(null)},[]),_=Object(n.useCallback)(le(async()=>{l&&(await(async e=>{try{return(await B.a.delete("".concat(H,"/").concat(e))).data}catch(a){z(a)}})(l.thing_id),t({type:d.DELETE_THING,thingId:l.thing_id}),W(),D(!0,"Thing deleted successfully","success"))},f,D),[l,t,W,D]),q=Object(n.useCallback)(e=>{o(e),s(e.name)},[]),G=Object(n.useCallback)(e=>{S(e.target.value),w(0)},[]),V=Object(n.useCallback)((e,a)=>w(a),[]),K=Object(n.useCallback)(e=>{A(parseInt(e.target.value,10)),w(0)},[]);Object(n.useEffect)(()=>{le(async()=>{const e=await me();t({type:d.SET_THINGS,value:e})},h,D)()},[t,D]);const Y=Object(n.useCallback)(e=>{s(e.target.value)},[]),Z=Object(n.useMemo)(()=>a.filter(e=>e.name.toLowerCase().includes(C.toLowerCase())),[a,C]),X=Object(n.useMemo)(()=>[{key:"name",label:"Name",render:e=>r.a.createElement(aa.a,{container:!0,alignItems:"center"},r.a.createElement(Ct,{color:"success",size:"sm",style:{marginRight:10}}),r.a.createElement(We.a,{variant:"body1"},e.name))},{key:"messages_count",label:"Total Messages",align:"center"},{key:"created_at",label:"Created",align:"center",render:e=>ae(e.created_at)},{key:"status",label:"Status",align:"center",render:a=>{const t={running:{label:"Running",color:"#4caf50"},paused:{label:"Paused",color:"#ff9800"},not_connected:{label:"Not Connected",color:"#f44336"}}[a.status]||{label:a.status,color:"#9e9e9e"};return r.a.createElement(il.a,{label:t.label,size:"small",style:{backgroundColor:t.color,color:"white",fontWeight:600,minWidth:120},className:e.statusChip})}}],[e.statusChip]),J=Object(n.useMemo)(()=>[{label:"Details",onClick:e=>P(!0,e),icon:"visibility"},{label:"Delete",onClick:e=>U(e),icon:"delete"}],[P,U]);return r.a.createElement(r.a.Fragment,null,r.a.createElement(R,{open:T.open,message:T.message,onClose:M,severity:T.severity}),r.a.createElement(fe.a,{anchor:"right",open:m,onClose:()=>P(!1),classes:{paper:e.drawerPaper}},l&&r.a.createElement(ks,{selectData:l,handleThingNameChange:Y,loading:b,thingName:c,toggleDrawer:P,handleAlert:D,handleChange:(e,a)=>{N(a)},value:k})),r.a.createElement(xt,{title:"Thing",handleSearch:G,openForm:F}),r.a.createElement(aa.a,{container:!0,spacing:3,justifyContent:"space-between"},r.a.createElement(aa.a,{item:!0,xs:12},r.a.createElement(Ce.a,null)),r.a.createElement(aa.a,{item:!0,xs:12},b?r.a.createElement(Je,null):r.a.createElement(Zt,{data:Z,columns:X,title:"List of Things",rowActions:J,onRowAction:q,loading:b,searchEnabled:!0,searchQuery:C,onSearchChange:G,pagination:!0,page:x,rowsPerPage:O,onPageChange:V,onRowsPerPageChange:K,count:Z.length,emptyMessage:"No things found"}))),r.a.createElement(Ne.a,{open:p,onClose:L,"aria-labelledby":"form-dialog-title",maxWidth:"sm",fullWidth:!0},r.a.createElement(Te.a,{id:"form-dialog-title"},"New Thing"),r.a.createElement(Pc,{handleAlert:D,handleCloseNew:L,open:p})),r.a.createElement(Ne.a,{open:y,onClose:W,maxWidth:"xs",fullWidth:!0},r.a.createElement(Te.a,null,"Confirmation"),r.a.createElement(je.a,{dividers:!0},'Are you sure you want to delete "',null===l||void 0===l?void 0:l.name,'"?'),r.a.createElement(ke.a,null,r.a.createElement(Ae.a,{onClick:W,color:"primary",size:"small"},"Cancel"),r.a.createElement(Ae.a,{onClick:_,color:"secondary",size:"small",variant:"contained"},"Delete"),v&&r.a.createElement(Je,{size:24}))))},Is=t(795),Ms=t(811);const Ps=["history","url","className"],Rs=Object(Ht.a)(e=>({root:{height:"100%"},content:{alignItems:"center",display:"flex"},title:{fontWeight:700},avatar:{backgroundColor:e.palette.error.main,height:56,width:56},icon:{height:32,width:32},difference:{marginTop:e.spacing(2),display:"flex",alignItems:"center"},differenceIcon:{color:e.palette.error.dark},differenceValue:{color:e.palette.error.dark,marginRight:e.spacing(1)},row:{height:"42px",display:"flex",alignItems:"center",marginTop:e.spacing(1)},spacer:{flexGrow:1},importButton:{marginRight:e.spacing(1)},exportButton:{marginRight:e.spacing(1)},searchInput:{marginRight:e.spacing(1)},media:{height:150,paddingTop:"40.25%"},expand:{transform:"rotate(0deg)",marginLeft:"auto",transition:e.transitions.create("transform",{duration:e.transitions.duration.shortest})},expandOpen:{transform:"rotate(180deg)"}}));var Fs=e=>{let{history:a,url:t,className:l}=e;Object(Se.a)(e,Ps);const o=Rs(),[c,s]=Object(n.useState)([]),[d,m]=Object(n.useState)(!1),[u,p]=Object(n.useState)({open:!1,message:"",severity:"info"}),[g,y]=Object(n.useState)(!1),[E,b]=Object(n.useState)({}),[h,v]=Object(n.useState)(""),[f,C]=Object(n.useState)(!1),S=le(async()=>{const e=await(async()=>{try{return(await B.a.get("".concat(q,"/allSDK"))).data}catch(e){z(e)}})();s(e)},m,(e,a,t)=>{p({open:e,message:a,severity:t})});Object(n.useEffect)(()=>{S()},[]);const x=async e=>{await(async e=>{try{window.open("".concat(q,"/download/").concat(e))}catch(a){z(a)}})(e)};return r.a.createElement("div",{className:o.root},r.a.createElement(R,{open:u.open,message:u.message,onClose:()=>{p(e=>Object(i.a)(Object(i.a)({},e),{},{open:!1}))},severity:u.severity}),d&&r.a.createElement(Je,null),r.a.createElement(aa.a,{container:!0,spacing:3},r.a.createElement(aa.a,{item:!0,xs:12},r.a.createElement(Ft.a,{title:"Downloads"})),r.a.createElement(aa.a,{item:!0,xs:12},r.a.createElement(Ce.a,null)),r.a.createElement(aa.a,{container:!0,spacing:3},c.map(e=>r.a.createElement(aa.a,{item:!0,lg:3,sm:6,xl:2,xs:12,key:e.label},r.a.createElement(Ja.a,{className:o.root},r.a.createElement(Ft.a,{avatar:r.a.createElement(Ue.a,{"aria-label":"recipe",className:o.avatar},"SDK"),title:e.label,subheader:new Date(Date.now()).toDateString()}),r.a.createElement(Is.a,{className:o.media,image:"".concat(t,"/").concat(e.link),title:e.info}),r.a.createElement(Qa.a,null,r.a.createElement(We.a,{variant:"body2",color:"textSecondary",component:"p"},e.info),["espressif","gsm","arduino"].map(a=>e.get===a&&r.a.createElement(We.a,{key:a,className:o.root},r.a.createElement(pa.a,{href:"#",onClick:()=>x(e.get)},a.toUpperCase()),r.a.createElement(Le.a,{onClick:()=>x(e.get)},r.a.createElement(Ms.a,null))))),r.a.createElement(et.a,{disableSpacing:!0}))))),r.a.createElement(Ne.a,{open:f,onClose:()=>C(!1)},r.a.createElement(Te.a,null,"Confirmation"),r.a.createElement(je.a,{dividers:!0},"Are you sure you want to delete this template?"),r.a.createElement(ke.a,null,r.a.createElement(Ae.a,{onClick:async()=>{try{await(async e=>{try{return(await B.a.get("".concat(q,"/deleteSchema/").concat(e))).data}catch(a){z(a)}})(h),await S(),C(!1)}catch(e){console.error("Error:",e)}},color:"primary",size:"small"},"Yes"),r.a.createElement(Ae.a,{onClick:()=>C(!1),color:"primary",size:"small"},"No"))),r.a.createElement(Ne.a,{onClose:()=>{y(!1)},open:g},r.a.createElement(Te.a,null,"Description"),r.a.createElement(je.a,{dividers:!0},r.a.createElement(Jt.a,{src:E})))))};const Bs=Object(Ht.a)(e=>({formContainer:{padding:e.spacing(2),borderRadius:e.spacing(1)}}));var Ls=e=>{let{handleClose:a,handleAlert:t}=e;const l=Bs(),{productsDispatch:o}=I(),[c,s]=Object(n.useState)(!1),i=Object(at.e)({initialValues:{name:"",unitAmount:"",taxCode:"txcd_10000000",devices:"",messages:"",level:"",interval:"month",currency:"EUR",isCustom:!0,planType:"Mqtt"},validationSchema:tt.c({name:tt.d().required("Required"),unitAmount:tt.b().required("Required"),taxCode:tt.d().required("Required"),devices:tt.d().required("Required"),messages:tt.d().required("Required"),level:tt.d().required("Required"),interval:tt.d().required("Required"),currency:tt.d().required("Required"),planType:tt.d().required("Required")}),onSubmit:le(async(e,n)=>{let{resetForm:r}=n;try{const n={name:e.name,unitAmount:e.unitAmount,taxCode:e.taxCode,metadata:{devices:e.devices,messages:e.messages,level:e.level},interval:e.interval,currency:e.currency,planType:e.planType,isCustom:e.isCustom},l=await(async e=>{try{return(await B.a.post("".concat(wn,"/add-product"),e)).data}catch(a){z(a)}})(n);await o({type:d.ADD_PRODUCT,value:l.new_product}),r(),a(),t(!0)}catch(l){console.error("Error adding product:",l)}},s,t)});return r.a.createElement(r.a.Fragment,null,r.a.createElement("form",{onSubmit:i.handleSubmit},r.a.createElement(aa.a,{container:!0,spacing:2,className:l.formContainer},r.a.createElement(aa.a,{item:!0,xs:12},r.a.createElement(We.a,{variant:"h6"},"Add New Product")),r.a.createElement(aa.a,{item:!0,xs:12,sm:6},r.a.createElement($a.a,{label:"Product Name",name:"name",variant:"outlined",required:!0,fullWidth:!0,value:i.values.name,onChange:i.handleChange,onBlur:i.handleBlur,error:i.touched.name&&Boolean(i.errors.name),helperText:i.touched.name&&i.errors.name})),r.a.createElement(aa.a,{item:!0,xs:12,sm:6},r.a.createElement($a.a,{label:"Unit Amount",name:"unitAmount",variant:"outlined",required:!0,fullWidth:!0,type:"number",value:i.values.unitAmount,onChange:i.handleChange,onBlur:i.handleBlur,error:i.touched.unitAmount&&Boolean(i.errors.unitAmount),helperText:i.touched.unitAmount&&i.errors.unitAmount})),r.a.createElement(aa.a,{item:!0,xs:12,sm:6},r.a.createElement($a.a,{label:"Tax Code",name:"taxCode",variant:"outlined",required:!0,fullWidth:!0,value:i.values.taxCode,onChange:i.handleChange,onBlur:i.handleBlur,error:i.touched.taxCode&&Boolean(i.errors.taxCode),helperText:i.touched.taxCode&&i.errors.taxCode})),r.a.createElement(aa.a,{item:!0,xs:12,sm:6},r.a.createElement($a.a,{label:"Devices",name:"devices",variant:"outlined",required:!0,fullWidth:!0,value:i.values.devices,onChange:i.handleChange,onBlur:i.handleBlur,error:i.touched.devices&&Boolean(i.errors.devices),helperText:i.touched.devices&&i.errors.devices})),r.a.createElement(aa.a,{item:!0,xs:12,sm:6},r.a.createElement($a.a,{label:"Messages",name:"messages",variant:"outlined",required:!0,fullWidth:!0,value:i.values.messages,onChange:i.handleChange,onBlur:i.handleBlur,error:i.touched.messages&&Boolean(i.errors.messages),helperText:i.touched.messages&&i.errors.messages})),r.a.createElement(aa.a,{item:!0,xs:12,sm:6},r.a.createElement($a.a,{label:"Level",name:"level",variant:"outlined",required:!0,fullWidth:!0,value:i.values.level,onChange:i.handleChange,onBlur:i.handleBlur,error:i.touched.level&&Boolean(i.errors.level),helperText:i.touched.level&&i.errors.level})),r.a.createElement(aa.a,{item:!0,xs:12,sm:6},r.a.createElement($a.a,{select:!0,label:"Interval",name:"interval",variant:"outlined",required:!0,fullWidth:!0,value:i.values.interval,onChange:i.handleChange,onBlur:i.handleBlur,error:i.touched.interval&&Boolean(i.errors.interval),helperText:i.touched.interval&&i.errors.interval},r.a.createElement(Nt.a,{value:"week"},"Weekly"),r.a.createElement(Nt.a,{value:"month"},"Monthly"),r.a.createElement(Nt.a,{value:"year"},"Yearly"))),r.a.createElement(aa.a,{item:!0,xs:12,sm:6},r.a.createElement($a.a,{label:"Currency",name:"currency",variant:"outlined",required:!0,fullWidth:!0,value:i.values.currency,onChange:i.handleChange,onBlur:i.handleBlur,error:i.touched.currency&&Boolean(i.errors.currency),helperText:i.touched.currency&&i.errors.currency})),r.a.createElement(aa.a,{item:!0,xs:12,sm:6},r.a.createElement(pn.a,{variant:"outlined",fullWidth:!0},r.a.createElement(gn.a,{id:"plan-type-label"},"Plan Type"),r.a.createElement(yn.a,{labelId:"plan-type-label",id:"plan-type-select",name:"planType",value:i.values.planType,onChange:i.handleChange,onBlur:i.handleBlur,label:"Plan Type",error:i.touched.planType&&Boolean(i.errors.planType)},r.a.createElement(Nt.a,{value:"mqtt"},"Mqtt alone"),r.a.createElement(Nt.a,{value:"kafka"},"Kafka alone"),r.a.createElement(Nt.a,{value:"mqtt_Kafka"},"Mqtt + Kafka")),i.touched.planType&&i.errors.planType&&r.a.createElement(We.a,{color:"error",variant:"caption"},i.errors.planType))),r.a.createElement(aa.a,{item:!0,xs:12,sm:6},r.a.createElement(bn.a,{control:r.a.createElement(zt.a,{checked:i.values.isCustom,onChange:e=>i.setFieldValue("isCustom",e.target.checked),name:"isCustom",color:"primary"}),label:"Custom Plan"})),r.a.createElement(aa.a,{container:!0,justifyContent:"flex-end"},r.a.createElement(Ae.a,{disabled:c,type:"submit",variant:"contained",color:"primary"},c?"Adding ...":"Add Product")))))};const Us=Object(Ht.a)(e=>({formContainer:{padding:e.spacing(2),backgroundColor:"#f9f9f9",borderRadius:e.spacing(1)},formControl:{width:"100%"}}));var Ws=()=>{const e=Us(),{metadataState:a,metadataDispatch:t}=I();console.log(a);const n=e=>{t({type:d.EDIT_METADATA_VALUES,key:e.target.name,value:e.target.value})};return r.a.createElement(aa.a,{container:!0,spacing:2,className:e.formContainer},r.a.createElement(aa.a,{item:!0,xs:12},r.a.createElement(We.a,{variant:"h6"},"Product: ",a.productName)),r.a.createElement(aa.a,{item:!0,xs:12,sm:4},r.a.createElement($a.a,{label:"Devices",name:"devices",variant:"outlined",type:"number",required:!0,fullWidth:!0,value:a.devices,onChange:n})),r.a.createElement(aa.a,{item:!0,xs:12,sm:4},r.a.createElement($a.a,{label:"Messages",name:"messages",variant:"outlined",type:"number",required:!0,fullWidth:!0,value:a.messages,onChange:n})),r.a.createElement(aa.a,{item:!0,xs:12,sm:4},r.a.createElement($a.a,{label:"Level",name:"level",variant:"outlined",type:"number",required:!0,fullWidth:!0,value:a.level,onChange:n})),r.a.createElement(aa.a,{item:!0,xs:12,sm:4},r.a.createElement($a.a,{label:"Price",name:"price",variant:"outlined",type:"number",required:!0,fullWidth:!0,value:a.price,onChange:n})),r.a.createElement(aa.a,{item:!0,xs:12,sm:4},r.a.createElement(pn.a,{variant:"outlined",className:e.formControl},r.a.createElement(gn.a,null,"Currency"),r.a.createElement(yn.a,{disabled:!0,name:"currency",value:a.currency||"eur",onChange:n,label:"Currency"},r.a.createElement(Nt.a,{value:"eur"},"EUR (\u20ac)"),r.a.createElement(Nt.a,{value:"usd"},"USD ($)"),r.a.createElement(Nt.a,{value:"gbp"},"GBP (\xa3)")))))};const _s=Object(Ht.a)(e=>({root:{padding:e.spacing(3),backgroundColor:e.palette.background.paper,borderRadius:e.shape.borderRadius,boxShadow:e.shadows[4]},title:{fontWeight:600,marginBottom:e.spacing(1)},subtitle:{color:e.palette.text.secondary,marginBottom:e.spacing(2)},autocomplete:{marginBottom:e.spacing(3)},actions:{display:"flex",justifyContent:"flex-end",gap:e.spacing(2),marginTop:e.spacing(2)},cancelButton:{borderColor:e.palette.primary.main,color:e.palette.primary.main},assignButton:{color:"#fff"}}));var zs=e=>{let{productId:a,onClose:t,handleAlert:l}=e;const o=_s(),[c,s]=Object(n.useState)([]),[i,m]=Object(n.useState)(!1),{usersState:u,usersDispatch:p}=I();Object(n.useEffect)(()=>{le(async()=>{const e=await lt();p({type:d.SET_USERS,value:e})},m,l)()},[p,l]);const g=le(async()=>{if(0===c.length)return void l(!0,"Please select at least one user to continue.","warning");const e=c.map(e=>e.id);await(async(e,a)=>{try{return(await B.a.post("".concat(wn,"/plans/assign-users"),{planId:e,userIds:a})).data}catch(t){z(t)}})(a,e),l(!0,"Users successfully assigned to the plan.","success"),s([]),t()},m,l);return r.a.createElement(je.a,null,r.a.createElement(ve.a,{className:o.root},r.a.createElement(We.a,{variant:"body2",className:o.subtitle},"Select the users you want to include in this custom plan."),r.a.createElement(or.a,{multiple:!0,options:u,getOptionLabel:e=>e.email||e.name||e.id,getOptionSelected:(e,a)=>e.id===a.id,value:c,onChange:(e,a)=>s(a),renderInput:e=>r.a.createElement($a.a,Object.assign({},e,{variant:"outlined",label:"Search and select users",fullWidth:!0})),className:o.autocomplete}),r.a.createElement(ve.a,{className:o.actions},r.a.createElement(Ae.a,{variant:"outlined",onClick:t,disabled:i,className:o.cancelButton},"Cancel"),r.a.createElement(Ae.a,{variant:"contained",color:"primary",onClick:g,disabled:i||0===c.length,className:o.assignButton,startIcon:i&&r.a.createElement(Xe.a,{size:20,color:"inherit"})},i?"Assigning...":"Assign Users"))))};const qs=Object(Ht.a)(e=>({tableRow:{"&:hover":{backgroundColor:e.palette.action.hover}},statusCell:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:e.spacing(1)}}));var Gs=Object(n.memo)(e=>{let{product:a,onArchiveToggle:t,handleMenuOpen:n}=e;const l=qs(),{id:o,name:c,isCustom:s,price:i,metadata:d={},active:m,priceId:u}=a,{devices:p="N/A",messages:g="N/A",level:y="N/A"}=d;return r.a.createElement(Wt.a,{className:l.tableRow,key:o},r.a.createElement(_t.a,{component:"th",scope:"row"},c),r.a.createElement(_t.a,{align:"right"},s?"Yes":"No"),r.a.createElement(_t.a,{align:"right"},0===i?"Free":"$".concat(i)),r.a.createElement(_t.a,{align:"right"},p),r.a.createElement(_t.a,{align:"right"},g),r.a.createElement(_t.a,{align:"right"},y),r.a.createElement(_t.a,{align:"right"},r.a.createElement(il.a,{onClick:()=>t(a),label:m?"Active":"Archived",size:"small",style:{backgroundColor:m?"#4caf50":"#f44336",color:"white",marginRight:"8px"}})),r.a.createElement(_t.a,{align:"right"},r.a.createElement(Le.a,{onClick:e=>n(e,a),"aria-label":"More actions for ".concat(c),size:"small"},r.a.createElement(Vn.a,null))))});const Hs=(e,a)=>"number"===typeof e&&a?(e/100).toLocaleString(void 0,{style:"currency",currency:a.toUpperCase()}):"N/A";var Vs=e=>{var a;const[t,l]=Object(n.useState)(!1),[o,s]=Object(n.useState)({open:!1,title:"",content:"",onConfirm:()=>{}}),[d,m]=Object(n.useState)({open:!1,title:"",content:""}),u=e.customerId,p=e.priceid&&e.currentPlan.priceId===e.priceid,g=e.currentPlan.nextPriceId===e.priceid,y=e.currentPlan.level,E=!e.currentPlan.currentend,b=(null===(a=e.currentPlan)||void 0===a?void 0:a.currentend)?function(e){let a;return a="number"===typeof e?new Date(1e3*e):new Date(e),a.toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}(e.currentPlan.currentend):null,h=e.price,v=e.features,f=Object(c.g)(),C=le(async()=>{f.push("/payments",{planName:e.name,priceId:e.priceid,customerId:u})},l,e.handleAlert),S=le(async()=>{l(!0);if((await An(e.customerId,null,e.priceid,!1)).success){const a=await e.fetchCustomerInfo(e.customerId);await e.setCurrentPlan(a)}l(!1)},l,e.handleAlert),x=le(async()=>{const a=await An(e.customerId,null,e.priceid,!0);if(a.preview&&"downgrade_preview"===a.type){const{line_item:t,context:n,currency:l}=a,o=n.effective_date?new Date(1e3*n.effective_date).toLocaleDateString():"your next billing date";m({open:!0,title:"Confirm Plan Downgrade",content:r.a.createElement(r.a.Fragment,null,r.a.createElement(We.a,{variant:"body1",gutterBottom:!0},"You are scheduling a downgrade from ",r.a.createElement("b",null,e.currentPlan.name)," to ",r.a.createElement("b",null,n.new_plan_name),"."),r.a.createElement(We.a,{variant:"body2",color:"textSecondary"},"This change will take effect on ",r.a.createElement("b",null,o),". There is no immediate charge."),r.a.createElement(ve.a,{my:2},r.a.createElement(Ce.a,null)),r.a.createElement(We.a,{variant:"subtitle1",gutterBottom:!0},"Future Recurring Charge"),r.a.createElement(ve.a,null,r.a.createElement(ve.a,{display:"flex",justifyContent:"space-between"},r.a.createElement(We.a,{variant:"body2"},"Subtotal:"),r.a.createElement(We.a,{variant:"body2"},Hs(t.unit_price,l))),t.tax_amount>0&&r.a.createElement(ve.a,{display:"flex",justifyContent:"space-between"},r.a.createElement(We.a,{variant:"body2"},"Tax (",t.tax_rate,"%):"),r.a.createElement(We.a,{variant:"body2"},Hs(t.tax_amount,l))),r.a.createElement(ve.a,{display:"flex",justifyContent:"space-between",mt:1,pt:1,style:{borderTop:"1px solid #e0e0e0"}},r.a.createElement(We.a,{variant:"subtitle1"},"New Total:"),r.a.createElement(We.a,{variant:"subtitle1"},Hs(t.total,l)))))})}else a.error&&e.handleAlert(!0,a.error,"error")},l,e.handleAlert),w=le(async()=>{await(async e=>{try{return(await B.a.put("".concat(wn,"/subscription-continuation/").concat(e))).data}catch(a){z(a)}})(e.customerId);const a=await e.fetchCustomerInfo(e.customerId);await e.setCurrentPlan(a)},l,e.handleAlert);return r.a.createElement(Ja.a,{variant:"outlined",style:{height:"100%",minHeight:"500px",display:"flex",flexDirection:"column",boxShadow:"8px 8px 8px rgba(0, 0, 0, 0.1)",backgroundColor:p?"rgba(0, 0, 255, 0.1)":"",border:g?"2px solid blue":void 0}},r.a.createElement(Ft.a,{style:{marginBottom:"30px"},title:r.a.createElement(We.a,{variant:"h5",align:"center"}," ",e.name," ")}),r.a.createElement(Ft.a,{style:{height:"100%",minHeight:"100px"},title:0===h?r.a.createElement(We.a,{variant:"h4",align:"center"}," Free "):r.a.createElement(r.a.Fragment,null,r.a.createElement(We.a,{variant:"h4",align:"center"},"\u20ac",h),r.a.createElement(We.a,{variant:"subtitle2",align:"center"},"Per Unit/Month"))}),r.a.createElement(Qa.a,null,r.a.createElement("ul",null,r.a.createElement("hr",null),Object.entries(v).map(a=>{let[t,n]=a;const l=p?n*e.currentPlan.quantity:n;return"level"===t?null:r.a.createElement("li",{key:t},ne(l)+" "+t)})),!E&&r.a.createElement(We.a,{style:{color:"Red"}},p?"Ends ".concat(b):g?"Starting ".concat(b):"")),r.a.createElement("div",{style:{flexGrow:1}}),r.a.createElement(et.a,{style:{justifyContent:"flex-end"}},p?r.a.createElement(r.a.Fragment,null,h>0&&r.a.createElement(r.a.Fragment,null,r.a.createElement(Ae.a,{variant:"contained",color:"primary",onClick:C},e.currentPlan.quantity+" Units | +"),r.a.createElement(Ae.a,{variant:"contained",color:"primary",disabled:t,onClick:()=>((e,a,t,n)=>{t({open:!0,title:e?"Cancel Subscription?":"Reactivate Subscription?",content:e?r.a.createElement(r.a.Fragment,null,r.a.createElement(We.a,{variant:"body1"},"Are you sure you want to ",r.a.createElement("b",null,"cancel")," your subscription to ",r.a.createElement("b",null,a.name),"?"),r.a.createElement(We.a,{variant:"body2",style:{marginTop:8,color:"red"}},"Your subscription will remain active until the end of the current period and will not renew.")):r.a.createElement(r.a.Fragment,null,r.a.createElement(We.a,{variant:"body1"},"Reactivate your subscription to ",r.a.createElement("b",null,a.name),"?"),r.a.createElement(We.a,{variant:"body2",style:{marginTop:8,color:"green"}},"Your billing will resume as before.")),onConfirm:n})})(E,e.currentPlan,s,w)},t?"Processing...":E?"Cancel":"Reactivate"))):!g&&r.a.createElement(Ae.a,{variant:"contained",color:"primary",disabled:t,onClick:()=>{e.features.levels(Object(i.a)(Object(i.a)({},o),{},{open:!1}))},r.a.createElement(Te.a,null,o.title),r.a.createElement(je.a,null,o.content),r.a.createElement(ke.a,null,r.a.createElement(Ae.a,{onClick:()=>s(Object(i.a)(Object(i.a)({},o),{},{open:!1})),color:"primary"},"Cancel"),r.a.createElement(Ae.a,{disabled:t,onClick:async()=>{await o.onConfirm(),s(Object(i.a)(Object(i.a)({},o),{},{open:!1}))},color:"secondary"},t?"Processing...":"Confirm"))),r.a.createElement(Ne.a,{open:d.open,onClose:()=>m(Object(i.a)(Object(i.a)({},d),{},{open:!1}))},r.a.createElement(Te.a,null,d.title),r.a.createElement(je.a,null,d.content),r.a.createElement(ke.a,null,r.a.createElement(Ae.a,{onClick:()=>m(Object(i.a)(Object(i.a)({},d),{},{open:!1})),color:"primary"},"Back"),r.a.createElement(Ae.a,{disabled:t,onClick:async()=>{await S(),m(Object(i.a)(Object(i.a)({},d),{},{open:!1}))},color:"secondary"},t?"Processing...":"Schedule Downgrade"))))};const Ks=Object(Ht.a)(e=>({table:{minWidth:650},dialogContent:{paddingTop:e.spacing(1)},dialogActions:{padding:e.spacing(2,3)},pagePadding:{padding:e.spacing(1)},headerMargin:{margin:e.spacing()}}));function Ys(){const e=Ks(),{metadataState:a,metadataDispatch:t,productsState:l,productsDispatch:o}=I(),[c,s]=Object(n.useState)(null),[m,u]=Object(n.useState)(!1),[p,g]=Object(n.useState)(null),[y,E]=Object(n.useState)(null),[b,h]=Object(n.useState)(null),[v,f]=Object(n.useState)({open:!1,message:"",severity:"info"}),[C,S]=Object(n.useState)(!1),[x,w]=Object(n.useState)(!1),[O,A]=Object(n.useState)(!1),[T,j]=Object(n.useState)(!1),k=Object(n.useCallback)((e,a,t)=>{f({open:e,message:a,severity:t})},[]),N=(e,a)=>{h(e.currentTarget),E(a)},D=()=>h(null),M=le(async()=>{const e=await(async e=>{try{return(await B.a.put("".concat(wn,"/update-product"),e)).data}catch(a){z(a)}})(a);o({type:d.UPDATE_PRODUCT,productId:a.productId,value:e.updated_product}),w(!1),k(!0,"Metadata updated successfully.","success")},u,k),P=le(async()=>{if(!y)return;const e=!y.active;await(async(e,a)=>{try{return(await B.a.put("".concat(wn,"/archive-product/").concat(e),{active:a})).data}catch(t){z(t)}})(y.id,e),o({type:d.ARCHIVE_PRODUCT,productId:y.id,active:e}),j(!1),k(!0,'Product "'.concat(y.name,'" ').concat(e?"unarchived":"archived"," successfully."),"success")},u,k);Object(n.useEffect)(()=>{const e=$();(null===e||void 0===e?void 0:e.CusId)&&s(e.CusId);(async()=>{await le(async()=>{const e=await(async()=>{try{return(await B.a.get("".concat(wn,"/products"))).data}catch(e){z(e)}})();o({type:d.SET_PRODUCTS,value:e})},u,k)(),(null===e||void 0===e?void 0:e.CusId)?await le(async()=>{const a=await On(e.CusId);g(a)},u,k)():g(null)})()},[o,k]);const F=Object(n.useMemo)(()=>{var e,a;if(l&&p)return null===(e=l.find(e=>e.priceid===p.priceId))||void 0===e||null===(a=e.metadata)||void 0===a?void 0:a.level},[l,p]),L=Object(n.useMemo)(()=>l?[...l].sort((e,a)=>e.price-a.price):[],[l]);return r.a.createElement(r.a.Fragment,null,r.a.createElement(R,{open:v.open,message:v.message,onClose:()=>f(e=>Object(i.a)(Object(i.a)({},e),{},{open:!1})),severity:v.severity}),r.a.createElement(aa.a,{container:!0,justifyContent:"space-between",alignItems:"center",className:e.headerMargin},r.a.createElement("div",null,r.a.createElement(We.a,{variant:"h4"},"Pricing"),!ee()&&r.a.createElement(We.a,{variant:"subtitle1",gutterBottom:!0},"Credit balance: ",m?r.a.createElement("b",null,"..."):r.a.createElement("b",null,"\u20ac",null===p||void 0===p?void 0:p.balance))),ee()&&r.a.createElement(Ae.a,{variant:"contained",color:"primary",onClick:()=>S(!0)},"Add Product"),r.a.createElement(aa.a,{item:!0,xs:12},r.a.createElement(Ce.a,null))),r.a.createElement("div",{className:e.pagePadding},m?r.a.createElement(Je,{size:40}):ee()?r.a.createElement(Bt.a,{component:mt.a,elevation:3},r.a.createElement(Lt.a,{className:e.table},r.a.createElement(Ut.a,null,r.a.createElement(Wt.a,null,["Name","Is Custom","Price","Devices","Messages","Level","Status","Actions"].map(e=>r.a.createElement(_t.a,{key:e,align:"Name"===e?"left":"right"},r.a.createElement("strong",null,e))))),r.a.createElement(qt.a,null,L.map(e=>r.a.createElement(Gs,{key:e.id,product:e,isActive:e.active,isCustom:e.isCustom,productId:e.id,name:e.name,price:e.price,features:e.metadata,priceid:e.priceid,handleMenuOpen:N,onArchiveToggle:()=>(e=>{E(e),j(!0)})(e)}))))):r.a.createElement(aa.a,{container:!0,spacing:3,justifyContent:"center"},L.map(e=>r.a.createElement(aa.a,{item:!0,key:e.id,xs:12,sm:6,md:4,lg:3},r.a.createElement(Vs,{handleAlert:k,product:e,productId:e.id,name:e.name,price:e.price,features:e.metadata,priceid:e.priceid,setCurrentPlan:g,currentPlan:Object(i.a)(Object(i.a)({},p),{},{level:F}),customerId:c,fetchCustomerInfo:On})))),r.a.createElement(Ne.a,{fullWidth:!0,maxWidth:"sm",open:C,onClose:()=>S(!1)},r.a.createElement(je.a,{className:e.dialogContent},r.a.createElement(Ls,{onClose:()=>S(!1),handleAlert:k}))),r.a.createElement(Ne.a,{open:x,onClose:()=>w(!1),maxWidth:"sm",fullWidth:!0},r.a.createElement(Te.a,null,"Update Product Metadata"),r.a.createElement(je.a,{className:e.dialogContent},r.a.createElement(Ws,null)),r.a.createElement(ke.a,{className:e.dialogActions},r.a.createElement(Ae.a,{onClick:()=>w(!1),color:"primary"},"Cancel"),r.a.createElement(Ae.a,{onClick:M,color:"primary",disabled:m},m&&x?r.a.createElement(Je,{size:18,color:"inherit"}):"Update"))),r.a.createElement(Ne.a,{open:O,onClose:()=>A(!1),maxWidth:"sm",fullWidth:!0},r.a.createElement(Te.a,null,"Assign User to Custom Plan"),r.a.createElement(je.a,{className:e.dialogContent},r.a.createElement(zs,{productId:null===y||void 0===y?void 0:y.id,onClose:()=>A(!1),handleAlert:k})),r.a.createElement(ke.a,{className:e.dialogActions},r.a.createElement(Ae.a,{onClick:()=>A(!1),color:"primary"},"Cancel"))),r.a.createElement(Ne.a,{open:T,onClose:()=>j(!1),maxWidth:"xs",fullWidth:!0},r.a.createElement(Te.a,null,"Confirm Action"),r.a.createElement(je.a,{className:e.dialogContent},r.a.createElement(We.a,null,"Are you sure you want to ",(null===y||void 0===y?void 0:y.active)?"archive":"unarchive",' the product "',null===y||void 0===y?void 0:y.name,'"?')),r.a.createElement(ke.a,{className:e.dialogActions},r.a.createElement(Ae.a,{onClick:()=>j(!1),color:"primary"},"Cancel"),r.a.createElement(Ae.a,{onClick:P,color:"primary",disabled:m},m&&T?r.a.createElement(Je,{size:18,color:"inherit"}):"Confirm"))),r.a.createElement(ze.a,{anchorEl:b,keepMounted:!0,open:Boolean(b),onClose:D},r.a.createElement(Nt.a,{onClick:()=>{y&&(t({type:d.SET_METADATA_VALUES,value:Object(i.a)({productId:y.id,price:y.price,currency:y.currency,productName:y.name},y.metadata)}),w(!0)),D()}},"Edit Metadata"),r.a.createElement(Nt.a,{onClick:()=>j(!0)},"Archive/Unarchive"),(null===y||void 0===y?void 0:y.isCustom)&&r.a.createElement(Nt.a,{onClick:()=>{y&&A(!0),D()}},"Assign User"))))}const Zs=Object(Ht.a)(e=>({form:{width:"100%",marginTop:e.spacing(1)},submit:{margin:e.spacing(3,0,2)}})),Xs=e=>{let{isTokenExpired:a,passwordReset:t,userActivation:l}=e;const o=Zs(),[c,s]=Object(n.useState)(!1),[d,m]=Object(n.useState)({open:!1,message:"",severity:"info"}),[u,p]=Object(n.useState)(!1),[g,y]=Object(n.useState)(""),E=Object(n.useCallback)((e,a,t)=>{m({open:e,message:a,severity:t})},[]),b=Object(n.useCallback)(()=>m(e=>Object(i.a)(Object(i.a)({},e),{},{open:!1})),[]),h=le(async e=>{let n="activation";t&&(n="password-reset"),a&&(n=l?"token-reset":"password-reset"),await(async(e,a)=>{try{return(await B.a.post("".concat(uo,"/send-email"),{email:e,type:a})).data}catch(r){var t,n;throw new Error((null===(t=r.response)||void 0===t||null===(n=t.data)||void 0===n?void 0:n.message)||"Failed to send reset email.")}})(e.email,n),y(e.email),p(!0),E(!0,"Please check your email for further instructions.","success")},s,E),v=Object(at.e)({initialValues:{email:""},validationSchema:tt.c({email:tt.d().email("Invalid email address").required("Email is required")}),onSubmit:async e=>{await h(e)}});return r.a.createElement(r.a.Fragment,null,r.a.createElement(R,{open:d.open,message:d.message,onClose:b,severity:d.severity}),r.a.createElement(We.a,{variant:"h6"},t?"Password Reset":a&&l?"Request New Verification Link":"Account Activation"),r.a.createElement(We.a,{variant:"caption"},t&&!u?"Enter your email address to receive a password reset link.":a&&l?"Your verification link has expired. Enter your email to receive a new activation link.":""),a&&!u&&r.a.createElement(We.a,{color:"error",style:{marginTop:20}},"Your link has expired. Please request a new one."),r.a.createElement("form",{onSubmit:v.handleSubmit,className:o.form},u?r.a.createElement(r.a.Fragment,null,r.a.createElement(We.a,{variant:"body1",style:{marginTop:20}},"Email sent to: ",r.a.createElement("strong",null,g)),r.a.createElement(We.a,{style:{marginTop:"10px",color:"#555"}},"Didn\u2019t receive the email? Check your spam folder or request a new link."),r.a.createElement(Ae.a,{onClick:()=>h({email:g}),fullWidth:!0,variant:"contained",style:{marginTop:"20px",backgroundColor:"#11b276",color:"#fff"},disabled:c},c?"Resending...":"Resend Email")):r.a.createElement(r.a.Fragment,null,r.a.createElement($a.a,{type:"email",variant:"outlined",margin:"normal",required:!0,fullWidth:!0,id:"email",label:"Email",name:"email",autoComplete:"email",autoFocus:!0,size:"small",value:v.values.email,onChange:v.handleChange,onBlur:v.handleBlur,error:v.touched.email&&Boolean(v.errors.email),helperText:v.touched.email&&v.errors.email}),r.a.createElement(Ae.a,{type:"submit",fullWidth:!0,variant:"contained",color:"primary",className:o.submit,disabled:c||!v.isValid},c?"Sending...":"Send Email")),c&&r.a.createElement(Je,null)))},Js=Object(Ht.a)(e=>({paper:{marginTop:40,width:"100%",maxWidth:600,padding:e.spacing(4),backgroundColor:e.palette.background.paper,borderRadius:e.shape.borderRadius,boxShadow:e.shadows[5]}}));var Qs=()=>{const e=Object(c.h)(),a=Js(),t=new URLSearchParams(e.search).get("token"),[l,o]=Object(n.useState)(!1),[s,d]=Object(n.useState)({open:!1,message:"",severity:"info"}),[m,u]=Object(n.useState)(!1),[p,g]=Object(n.useState)(!1),y=Object(n.useCallback)((e,a,t)=>{d({open:e,message:a,severity:t})},[]),E=Object(n.useCallback)(()=>d(e=>Object(i.a)(Object(i.a)({},e),{},{open:!1})),[]),b=le(async(e,a)=>{if(e===a)try{await(async(e,a)=>{try{return(await B.a.post("".concat(uo,"/password-reset"),{newPassword:a},{headers:{Authorization:"Bearer ".concat(e)}})).data}catch(t){console.log(t),z(t)}})(t,e),y(!0,"Password successfully reset.","success"),u(!0)}catch(n){console.error(n),"Token expired, please sign in again"===n.message||"Invalid token."===n.message?(y(!0,"Your link has expired. Please request a new one.","error"),g(!0)):y(!0,"An error occurred while resetting your password.","error")}else y(!0,"Passwords do not match","error")},o,y);return r.a.createElement(mo.a,{component:"main",maxWidth:"xs"},r.a.createElement(io.a,null),r.a.createElement(R,{open:s.open,message:s.message,onClose:E,severity:s.severity}),m?r.a.createElement("div",{className:a.paper},r.a.createElement(We.a,{variant:"subtitle1"},"Password successfully reset. You may now log in."),r.a.createElement(Ae.a,{fullWidth:!0,variant:"contained",disabled:l,style:{marginTop:"20px",backgroundColor:"#11b276",color:"#fff"},onClick:re},"Go to login page")):r.a.createElement(fo,{title:m?"Success":"Set New Password",onSubmit:b,loading:l}),r.a.createElement(Ne.a,{open:p,onClose:()=>g(!1)},r.a.createElement(je.a,null,r.a.createElement(Xs,{isTokenExpired:!0,passwordReset:!0}))))};const $s=Object(Ht.a)(e=>({root:{display:"flex",justifyContent:"center",alignItems:"center",padding:e.spacing(2)},paper:{marginTop:40,width:"100%",maxWidth:600,padding:e.spacing(4),backgroundColor:e.palette.background.paper,borderRadius:e.shape.borderRadius,boxShadow:e.shadows[5]}}));var ei=()=>{const e=$s();return r.a.createElement(mo.a,{className:e.root,component:"main",maxWidth:"xs"},r.a.createElement(io.a,null),r.a.createElement("div",{className:e.paper},r.a.createElement(Xs,{passwordReset:!0})))};const ai=Object(Ht.a)(e=>({root:{display:"flex",justifyContent:"center",alignItems:"center",padding:e.spacing(2),backgroundColor:e.palette.background.default},paper:{marginTop:40,width:"100%",maxWidth:600,padding:e.spacing(4),backgroundColor:e.palette.background.paper,borderRadius:e.shape.borderRadius,boxShadow:e.shadows[5]},submit:{margin:e.spacing(3,0,2)}}));var ti=()=>{const e=ai(),[a,t]=Object(n.useState)(!1),[l,o]=Object(n.useState)({open:!1,message:"",severity:"info"}),[s,d]=Object(n.useState)(!1),[m,u]=Object(n.useState)(!1),{token:p}=Object(c.i)(),[g,y]=Object(n.useState)(!1),E=Object(n.useCallback)((e,a,t)=>{o({open:e,message:a,severity:t})},[]),b=Object(n.useCallback)(()=>o(e=>Object(i.a)(Object(i.a)({},e),{},{open:!1})),[]),h=le(async e=>{try{await(async e=>{try{return(await B.a.get("".concat(nt,"/activate-user"),{headers:{Authorization:"Bearer ".concat(e)}})).data}catch(a){console.log(a),z(a)}})(e),d(!0),E(!0,"Your account has been successfully activated!","success")}catch(a){console.log(a),"Token expired, please sign in again"===a.message?(u(!0),E(!0,"Your activation link has expired. Please request a new one.","error"),y(!0)):E(!0,"An error occurred while activating your account.","error")}},t,E);return r.a.createElement(r.a.Fragment,null,r.a.createElement(mo.a,{className:e.root,component:"main",maxWidth:"xs"},r.a.createElement(io.a,null),r.a.createElement(R,{open:l.open,message:l.message,onClose:b,severity:l.severity}),r.a.createElement("div",{className:e.paper},!m&&r.a.createElement(r.a.Fragment,null,r.a.createElement(We.a,{variant:"h6"},s?"Success":"User Activation"),!s&&r.a.createElement(We.a,{variant:"caption"},"Click the button below to activate your account."),a&&r.a.createElement(Je,null),!a&&!s&&r.a.createElement(Ae.a,{type:"submit",fullWidth:!0,variant:"contained",color:"primary",className:e.submit,onClick:()=>h(p)},"Activate Account")),s&&r.a.createElement(r.a.Fragment,null,r.a.createElement(We.a,{variant:"caption",align:"center"},"Your account has been activated! You can now log in."),r.a.createElement(Ae.a,{fullWidth:!0,variant:"contained",style:{marginTop:"20px",backgroundColor:"#11b276",color:"#fff"},className:e.submit,onClick:re,disabled:a},"Go to login page")),m&&r.a.createElement(r.a.Fragment,null,r.a.createElement(We.a,{variant:"h6"},"Token Activation Expired"),r.a.createElement(We.a,{variant:"caption"},"Your activation link has expired. Click below to request a new link."),r.a.createElement(Ae.a,{fullWidth:!0,variant:"contained",color:"primary",className:e.submit,onClick:()=>jn(!0)},"Request New Link")))),r.a.createElement(Ne.a,{open:g,onClose:()=>y(!1)},r.a.createElement(je.a,null,r.a.createElement(Xs,{isTokenExpired:!0,userActivation:!0}))))};var ni=()=>[{path:"/signin",exact:!0,component:Oo,layout:"MinimalLayout"},{path:"/request-token",exact:!0,component:ei,layout:"MinimalLayout"},{path:"/new-password",exact:!0,component:Qs,layout:"MinimalLayout"},{path:"/activate-user/:token",exact:!0,component:ti,layout:"MinimalLayout"},{path:"/signup",exact:!0,component:To,layout:"MinimalLayout"},{path:"/",exact:!0,component:Sl,layout:"MainLayout",requiresAuth:!0},{path:"/dashboard",exact:!0,component:Sl,layout:"MainLayout",requiresAuth:!0},{path:"/things",exact:!0,component:Ds,layout:"MainLayout",requiresAuth:!0},{path:"/nodered/:id/",exact:!0,component:os,layout:"MainLayout",requiresAuth:!0},{path:"/flows",exact:!0,component:is,layout:"MainLayout",requiresAuth:!0},{path:"/datastores",exact:!0,component:ts,layout:"MainLayout",requiresAuth:!0},{path:"/steps",exact:!0,component:zc,layout:"MainLayout",requiresAuth:!0},{path:"/account",exact:!0,component:hr,layout:"MainLayout",requiresAuth:!0},{path:"/plan",exact:!0,component:Ys,layout:"MainLayout",requiresAuth:!0},{path:"/payments",exact:!0,component:pr,layout:"MainLayout",requiresAuth:!0},{path:"/settings",exact:!0,component:So,layout:"MainLayout",requiresAuth:!0},{path:"/topics",exact:!0,component:Ec,layout:"MainLayout",requiresAuth:!0},{path:"/ai-models",exact:!0,component:zo,layout:"MainLayout",requiresAuth:!0},{path:"/downloads",exact:!0,component:Fs,layout:"MainLayout",requiresAuth:!0},{path:"/connectors",exact:!0,component:so,layout:"MainLayout",requiresAuth:!0},{path:"/swagger",exact:!0,component:rs,layout:"MainLayout",requiresAuth:!0},{path:"/not-found",exact:!0,component:wl,layout:"MinimalLayout"},{path:"/users",exact:!0,component:No,layout:"MainLayout",requiresAuth:!0}];const ri=Object(s.a)(),li=ni();function oi(){const{notificationsDispatch:e}=I(),[a,t]=Object(n.useState)({open:!1,message:"",severity:""});return Object(n.useEffect)(()=>{const a=Q();if(a){const n=new WebSocket("wss://www.thingwings.com/wss",[a.split(" ")[1]]);return n.addEventListener("open",()=>{console.log("Connected to server")}),n.addEventListener("message",async a=>{const n=JSON.parse(a.data);var r,l;console.log("Received message:",n),r=!0,l=n.message,t({open:r,message:l,severity:"warning"}),await e({type:d.ADD_NOTIFICATION,notification:n})}),n.addEventListener("ping",e=>{n.pong(),console.log("Received ping, sent pong")}),()=>{n.close()}}},[]),r.a.createElement(r.a.Fragment,null,r.a.createElement(R,{open:a.open,message:a.message,onClose:()=>{t({open:!1,message:"",severity:"info"})},severity:a.severity}),r.a.createElement(c.c,{history:ri},r.a.createElement(Ya,{routes:li})))}var ci=t(135),si=t(794);const ii=Object(ci.b)({palette:{primary:{main:"#1C4E80"}}});o.a.render(r.a.createElement(si.a,{theme:ii},r.a.createElement(D,null,r.a.createElement(oi,null))),document.getElementById("root"))}},[[492,1,2]]]); //# sourceMappingURL=main.10f7cd50.chunk.js.map