-- -- Astra: Web Interface -- https://cesbo.com/astra/ -- -- Copyright (C) 2019, Andrey Dyldin -- log.info("Load UI bundle") astra_storage["/"] = [==[ Astra Control Panel ]==] astra_storage["/app.js"] = base64.decode([==[ LyoKICogQXN0cmE6IFdlYiBJbnRlcmZhY2UKICogaHR0cHM6Ly9jZXNiby5jb20vYXN0cmEvCiAqCiAqIENvcHlyaWdodCAoQykgMjAxOSwgQW5kcmV5IER5bGRpbiA8YW5kQGNlc2JvLmNvbT4KICovCgovKiBwb255LmpzICovCgovKgogKiBQb255SlMKICogKGMpIDIwMTYtMjAxNyBBbmRyZXkgRHlsZGluIDxhbmRAY2VzYm8uY29tPgogKiBMaWNlbnNlOiBNSVQKICovCgooZnVuY3Rpb24oKSB7CiJ1c2Ugc3RyaWN0IjsKCndpbmRvdy4kID0gZnVuY3Rpb24oc2VsZWN0b3IpIHsKCXJldHVybiBkb2N1bWVudC5xdWVyeVNlbGVjdG9yQWxsKHNlbGVjdG9yKTsKfTsKCiQuaXNNb2JpbGUgPSBmdW5jdGlvbigpIHsKCXZhciB4ID0gL2lQaG9uZXxpUGFkfGlQb2R8QW5kcm9pZHxXaW5kb3dzIFBob25lL2kudGVzdChuYXZpZ2F0b3IudXNlckFnZW50KTsKCSQuaXNNb2JpbGUgPSBmdW5jdGlvbigpIHsgcmV0dXJuIHggfTsKCXJldHVybiB4Owp9OwoKaWYod2luZG93LkN1c3RvbUV2ZW50ID09IHVuZGVmaW5lZCkgewoJdmFyIGN1c3RvbUV2ZW50ID0gZnVuY3Rpb24oZXZlbnQsIHBhcmFtcykgewoJCXBhcmFtcyA9IHBhcmFtcyB8fCB7IGJ1YmJsZXM6IGZhbHNlLCBjYW5jZWxhYmxlOiBmYWxzZSwgZGV0YWlsOiB1bmRlZmluZWQgfTsKCQl2YXIgZSA9IGRvY3VtZW50LmNyZWF0ZUV2ZW50KCJDdXN0b21FdmVudCIpOwoJCWUuaW5pdEN1c3RvbUV2ZW50KGV2ZW50LCBwYXJhbX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