Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 海阔视界规则分享,当前分享的是:小程序¥home_rule_v2¥base64://@DrpyHiker@eyJmaXJzdEhlYWRlciI6ImNsYXNzIiwibGFzdF9jaGFwdGVyX3J1bGUiOiIiLCJ0aXRsZSI6IkRycHlIaWtlciIsImF1dGhvciI6IkBMb3lEZ0lrJnpldGFscGhhIiwidXJsIjoiaGlrZXI6Ly9lbXB0eSMjZnlwYWdlIiwidmVyc2lvbiI6MTksImNvbF90eXBlIjoibW92aWVfMyIsImNsYXNzX25hbWUiOiIiLCJ0eXBlIjoidmlkZW8iLCJjbGFzc191cmwiOiIiLCJhcmVhX25hbWUiOiIiLCJhcmVhX3VybCI6IiIsInNvcnRfbmFtZSI6IiIsInllYXJfbmFtZSI6IiIsInNvcnRfdXJsIjoiIiwieWVhcl91cmwiOiIiLCJmaW5kX3J1bGUiOiJqczokLnJlcXVpcmUoXCJNaWFuTG9hZFwiKTsiLCJzZWFyY2hfdXJsIjoiaGlrZXI6Ly9lbXB0eT9zPSoqJnBhZ2U9ZnlwYWdlIiwiZ3JvdXAiOiLlvIDlj5HkuK3lv4MiLCJzZWFyY2hGaW5kIjoianM6XG4oZnVuY3Rpb24oKSB7XG4gICAgbGV0IHNtb2RlID0gTnVtYmVyKGdldEl0ZW0oXCJzbW9kZVwiLCBcIjBcIikpO1xuICAgIGxldCB0ZW1zbW9kZSA9IGdldE15VmFyKFwidGVtc21vZGVcIiwgXCJcIik7XG4gICAgaWYgKHRlbXNtb2RlKSB7XG4gICAgICAgIHNtb2RlID0gTnVtYmVyKHRlbXNtb2RlKTtcbiAgICAgICAgY2xlYXJNeVZhcihcInRlbXNtb2RlXCIpO1xuICAgIH1cbiAgICBpZiAoIWZpbGVFeGlzdChcImhpa2VyOi8vZmlsZXMvZGF0YS9cIiArIE1ZX1JVTEUudGl0bGUgKyBcIi9saWJzX2hpa2VyL2RycHkyLmpzXCIpKSByZXR1cm4gc2V0UmVzdWx0KFt7XG4g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Y2gge31cbiAgICAgICAgbGV0IGQgPSBbXTtcbiAgICAgICAgZm9yIChsZXQgaXQgb2YgaG9tZUxpc3QpIHtcbiAgICAgICAgICAgIGQucHVzaCh7XG4gICAgICAgICAgICAgICAgdGl0bGU6IGl0LnZvZF9uYW1lLFxuICAgICAgICAgICAgICAgIGRlc2M6IGl0LnZvZF9yZW1hcmtzICsgXCLCt1wiICsgc291cmNlLm5hbWUsXG4gICAgICAgICAgICAgICAgY29udGVudDogaXQudm9kX2NvbnRlbnQsXG4gICAgICAgICAgICAgICAgdXJsOiBcImhpa2VyOi8vcGFnZS9kZXRhaWxlZCNpbW1lcnNpdmVUaGVtZSNcIixcbiAgICAgICAgICAgICAgICBwaWNfdXJsOiBpdC52b2RfcGljLFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcIm1vdmllXzNcIixcbiAgICAgICAgICAgICAgICBleHRyYToge1xuICAgICAgICAgICAgICAgICAgICB2b2RJZDogaXQudm9kX2lkLFxuICAgICAgICAgICAgICAgICAgICBpbWc6IGl0LnZvZF9waWMsXG4gICAgICAgICAgICAgICAgICAgIHNuYW1lOiBzb3VyY2UubmFtZSxcbiAgICAgICAgICAgICAgICAgICAgc2tleTogc291cmNlLmtleVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgICAgIHNldFJlc3VsdChkKTtcbiAgICB9IGVsc2Uge1xuICAgICAgICBzZXRSZXN1bHQoW3tcbiAgICAgICAgICAgIHRpdGxlOiBcIueCueaIkeW8gOWni+iBmuWQiOaQnOe0olwiICsgTVlfS0VZV09SRCxcbiAgICAgICAgICAgIHVybDogXCJoaWtlcjovL3NlYXJjaD9zPVwiICsgTVlfS0VZV09SRCxcbiAgICAgICAgICAgIGV4dHJhOiB7XG4gICAgICAgICAgICAgICAgZGVsZWdhdGVPbmx5U2VhcmNoOiB0cnVlLFxuICAgICAgICAgICAgICAgIHJ1bGVzOiAkLnRvU3RyaW5nKCgpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBydW50aW1lQ29uZmlnID0gR00uZGVmaW5lTW9kdWxlKFwicnVudGltZUNvbmZpZ1wiLCBcInJ1bnRpbWVDb25maWdcIik7XG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgbGlzdCA9IHJ1bnRpbWVDb25maWcuZ2V0QWxsb3dTZWFyY2hTb3VyY2UoKTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHNvdXJjZSA9IHJ1bnRpbWVDb25maWcuZ2V0Q3VycmVudFNvdXJjZSgpO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgbGlzdGkgPSBsaXN0LmZpbmRJbmRleCh4ID0+IHgua2V5ID09IHNvdXJjZS5rZXkpO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoc291cmNlLnNlYXJjaGFibGUgJiYgbGlzdGkgIT0gLTEpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsaXN0LnNwbGljZShsaXN0LmluZGV4T2Yoc291cmNlKSwgMSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbGlzdC51bnNoaWZ0KHNvdXJjZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBydWxlcyA9IFtdO1xuICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaXQgb2YgbGlzdCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJ1bGVzLnB1c2goe1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogaXQubmFtZSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VhcmNoX3VybDogXCJoaWtlcjovL2VtcHR5P3BhZ2U9ZnlwYWdlJnNlYXJjaFRlcm1zPSoqXCIsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlYXJjaEZpbmQ6IFwianM6XCIgKyAkLnRvU3RyaW5nKChpdGVtKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgZHJweSA9IEdNLmRlZmluZU1vZHVsZShcIkRycHlNYW5hZ2VcIikuZ2V0KGl0ZW0ua2V5KTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGhvbWVMaXN0ID0gSlNPTi5wYXJzZShkcnB5LnNlYXJjaChNWV9LRVlXT1JELCBmYWxzZSwgTVlfUEFHRSkpLmxpc3QgfHwgW107XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgZCA9IFtdO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaXQgb2YgaG9tZUxpc3QpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkLnB1c2goe1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogaXQudm9kX25hbWUsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc2M6IGl0LnZvZF9yZW1hcmtzLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250ZW50OiBpdC52b2RfY29udGVudCxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdXJsOiBcImhpa2VyOi8vcGFnZS9kZXRhaWxlZCNpbW1lcnNpdmVUaGVtZSNcIixcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGljX3VybDogaXQudm9kX3BpYyxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6IFwibW92aWVfM1wiLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBleHRyYToge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdm9kSWQ6IGl0LnZvZF9pZCxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzUG9seW1lcml6ZTogdHJ1ZSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGltZzogaXQudm9kX3BpYyxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNuYW1lOiBpdGVtLm5hbWUsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBza2V5OiBpdGVtLmtleSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0UmVzdWx0KGQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LCBpdClcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeShydWxlcyk7XG4gICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGxvZyhlLnRvU3RyaW5nKCkpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSlcbiAgICAgICAgICAgIH1cbiAgICAgICAgfV0pO1xuICAgIH1cbn0pKCkiLCJkZXRhaWxfY29sX3R5cGUiOiJtb3ZpZV8xIiwiZGV0YWlsX2ZpbmRfcnVsZSI6IiIsInNkZXRhaWxfY29sX3R5cGUiOiJtb3ZpZV8xIiwic2RldGFpbF9maW5kX3J1bGUiOiIiLC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JqLnRvSGV4ID0gdHJ1ZTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgb2JqLmhlYWRlcnMgPSBPYmplY3QuYXNzaWduKHtcXG4gICAgICAgICAgICAgICAgQ29va2llOiBcXFwiI25vQ29va2llI1xcXCJcXG4gICAgICAgICAgICB9LCBvYmouaGVhZGVycyk7XFxuICAgICAgICAgICAgaWYgKHVybCA9PT0gXFxcImh0dHBzOi8vYXBpLm5uLmNpL29jci9iNjQvdGV4dFxcXCIgJiYgb2JqLmhlYWRlcnMpIHtcXG4gICAgICAgICAgICAgICAgb2JqLmhlYWRlcnNbXFxcIkNvbnRlbnQtVHlwZVxcXCJdID0gXFxcInRleHQvcGxhaW5cXFwiO1xcbiAgICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgICBpZiAodXJsLnN0YXJ0c1dpdGgoXFxcImZpbGU6Ly9cXFwiKSAmJiAodXJsLmluY2x1ZGVzKFxcXCI/dHlwZT1cXFwiKSB8fCB1cmwuaW5jbHVkZXMoXFxcIj9wYXJhbXM9XFxcIikpKSB7XFxuICAgICAgICAgICAgICAgIHVybCA9IHVybC5zbGljZSgwLCB1cmwubGFzdEluZGV4T2YoXFxcIj9cXFwiKSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGZvciAobGV0IGtleSBpbiBvYmouaGVhZGVycykge1xcbiAgICAgICAgICAgICAgICBpZiAodHlwZW9mIG9iai5oZWFkZXJzW2tleV0gIT09IFxcXCJzdHJpbmdcXFwiKSB7XFxuICAgICAgICAgICAgICAgICAgICBvYmouaGVhZGVyc1trZXldID0gU3RyaW5nKG9iai5oZWFkZXJzW2tleV0pO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCByID0gXFxcIlxcXCI7XFxuICAgICAgICAgICAgLyogaWYgKFN0cmluZyhvYmoubWV0aG9kKS50b0xvd2VyQ2FzZSgpID09PSBcXFwicG9zdFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgIHIgPSAkcG9zdCh1cmwsIG9iaik7XFxuICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICByID0gJHJlcXVlc3QodXJsLCBvYmopO1xcbiAgICAgICAgICAgICB9Ki9cXG4gICAgICAgICAgICByID0gJHJlcXVlc3QodXJsLCBvYmopO1xcbiAgICAgICAgICAgIGlmIChvYmoud2l0aEhlYWRlcnMpIHtcXG4gICAgICAgICAgICAgICAgciA9IEpTT04ucGFyc2Uocik7XFxuICAgICAgICAgICAgICAgIHJlcy5jb250ZW50ID0gci5ib2R5O1xcbiAgICAgICAgICAgICAgICByZXMuaGVhZGVycyA9IHt9O1xcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBbaywgdl0gb2YgT2JqZWN0LmVudHJpZXMoci5oZWFkZXJzIHx8IHt9KSkge1xcbiAgICAgICAgICAgICAgICAgICAgcmVzLmhlYWRlcnNba10gPSB2WzBdO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgcmVzLmNvbnRlbnQgPSByO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAob2JqLmJ1ZmZlciA9PT0gMikge1xcbiAgICAgICAgICAgICAgICByZXMuY29udGVudCA9IENyeXB0b1V0aWwuRGF0YS5wYXJzZUhleChyZXMuY29udGVudCkudG9CYXNlNjQoX2Jhc2U2NC5OT19XUkFQKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIHJlcztcXG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICBsb2coXFxcIkVycm9yXFxcIiArIGUudG9TdHJpbmcoKSk7XFxuICAgICAgICB9XFxuICAgIH1cXG4gICAgLypcXG4gICAgY29uc3QgSmluSmEgPSAkLnJlcXVpcmUoXFxcImh0dHBzOi8vY2RuLmJvb3RjZG4ubmV0L2FqYXgvbGlicy9tdXN0YWNoZS5q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zID0gcGFyYW1zLnRhZ3MgfHwgXFxcIlxcXCI7XFxuICAgICAgICBpZiAocGFyYW1zLmMgIT0gdW5kZWZpbmVkKSB7XFxuICAgICAgICAgICAgdGV4dCA9IHRleHQuZm9udGNvbG9yKHBhcmFtcy5jKTtcXG4gICAgICAgIH1cXG4gICAgICAgIGlmICh0YWdzKSB7XFxuICAgICAgICAgICAgdmFyIHRhZ0FycmF5ID0gdGFncy5zcGxpdCgnfCcpLmZpbHRlcihlID0+IGUpO1xcbiAgICAgICAgICAgIHZhciBvcGVuVGFncyA9ICcnO1xcbiAgICAgICAgICAgIHZhciBjbG9zZVRhZ3MgPSAnJztcXG4gICAgICAgICAgICBmb3IgKHZhciBpID0gMDsgaSA8IHRhZ0FycmF5Lmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgIG9wZW5UYWdzICs9ICc8JyArIHRhZ0FycmF5W2ldICsgJz4nO1xcbiAgICAgICAgICAgICAgICBjbG9zZVRhZ3MgPSAnPC8nICsgdGFnQXJyYXlbaV0gKyAnPicgKyBjbG9zZVRhZ3M7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHRleHQgPSBvcGVuVGFncyArIHRleHQgKyBjbG9zZVRhZ3M7XFxuICAgICAgICB9XFxuICAgICAgICByZXR1cm4gaCArIHRleHQ7XFxuICAgIH1cXG5cXG4gICAgZnVuY3Rpb24gZmluZExvbmdlc3RFbGVtZW50KGFycikge1xcbiAgICAgICAgcmV0dXJuIGFyci5yZWR1Y2UoKGEsIGIpID0+IGEubGVuZ3RoID4gYi5sZW5ndGggPyBhIDogYik7XFxuICAgIH1cXG5cXG4gICAgZnVuY3Rpb24gY291bnRUb3RhbEJ5dGVzKHRleHQpIHtcXG4gICAgICAgIHZhciBjb3VudCA9IDA7XFxuICAgICAgICBmb3IgKHZhciBpID0gMDsgaSA8IHRleHQubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICB2YXIgY29kZSA9IHRleHQuY2hhckNvZGVBdChpKTtcXG4gICAgICAgICAgICBpZiAoY29kZSA+PSAweDAxMDApIHsgLy8g5Y+M5a2X6IqC5a2X56ym55qEIFVuaWNvZGUg57yW56CB5aSn5LqOIDI1NVxcbiAgICAgICAgICAgICAgICBjb3VudCArPSAyOyAvLyDlj4zlrZfoioLlrZfnrKborqHmlbDkuLoyXFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgY291bnQgKz0gMTsgLy8g5Y2V5a2X6IqC5a2X56ym6K6h5pWw5Li6MVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH1cXG4gICAgICAgIHJldHVybiBjb3VudDtcXG4gICAgfVxcblxcbiAgICBmdW5jdGlvbiBjYWNoZVNob3dUaXBzKCkge1xcbiAgICAgICAgLyppZiAoc3RvcmFnZTAuZ2V0TXlWYXIoaWQgKyBcXFwiZXJpbmZvXFxcIikpIHtcXG4gICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogZm9udHN0eWxlKFxcXCLlvZPliY3kuLrnvJPlrZgs54K55oiR5Yi35pawXFxcIiwge1xcbiAgICAgICAgICAgICAgICAgICAgYzogXFxcImdyZXlcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgdGFnczogXFxcInNtYWxsXFxcIlxcbiAgICAgICAgICAgICAgICB9KSxcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICAgICAgdXJsOiAkKCcjbm9Mb2FkaW5nIycpLmxhenlSdWxlKChpZCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgY2xlYXJNeVZhcihpZCArIFxcXCJlcmluZm9cXFwiKVxcbiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICAgICAgfSwgaWQpLFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgbGluZVZpc2libGU6IGZhbHNlXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KVxcbiAgICAgICAgfSovXFxuICAgIH1cXG5cXG4gICAgZnVuY3Rpb24gc3Vic3RyKHN0ciwgbWF4TGVuZ3RoKSB7XFxuICAgICAgICBsZXQgbGVuID0gMDtcXG4gICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgc3RyLmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgaWYgKHN0ci5jaGFyQ29kZUF0KGkpID4gMjU1KSB7XFxuICAgICAgICAgICAgICAgIGxlbiArPSAyO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIGxlbisrO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAobGVuID4gbWF4TGVuZ3RoKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBzdHIuc2xpY2UoMCwgaSkgKyAnLi4uJztcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgICAgICByZXR1cm4gc3RyO1xcbiAgICB9XFxuXFxuICAgIGZ1bmN0aW9uIHNldERlc2MoZGVzYywgbnVtKSB7XFxuICAgICAgICBpZiAoZGVzYyA9PSB1bmRlZmluZWQpIHtcXG4gICAgICAgICAgICByZXR1cm47XFxuICAgICAgICB9XFxuICAgICAgICBkZXNjID0gZGVzYy5jb25zdHJ1Y3RvciA9PSBBcnJheSA/IGRlc2Muam9pbignPGJyPicpIDogZGVzYztcXG4gICAgICAgIGlmIChkZXNjLnJlcGxhY2UoLyg8YnI+fFxcXFxzKykvZywgJycpLmxlbmd0aCA9PSAwKSB7XFxuICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6ICdiaWdfYmxhbmtfYmxvY2snXFxuICAgICAgICAgICAgfSlcXG4gICAgICAgICA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onO1xcbiAgICAgICAgICAgIHZhciByZXQgPSAn5pS26LW3Oic7XFxuICAgICAgICAgICAgaWYgKHNob3cgPT0gJzEnKSB7XFxuICAgICAgICAgICAgICAgIHVwZGF0ZUl0ZW0oJ2Rlc2MnLCB7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogdGl0bGVcXG4gICAgICAgICAgICAgICAgICAgICAgICAucmVwbGFjZShyZXQsIGV4cClcXG4gICAgICAgICAgICAgICAgICAgICAgICAucmVwbGFjZShyZSwgJyQxJyArIHNkYyArICc8L3NtYWxsPicpXFxuICAgICAgICAgICAgICAgICAgICAgICAgLnJlcGxhY2UoLyg8XFxcXC9zbWFsbD48YnI+XFxcXDxmb250IGNvbG9yPVxcXCIpLio/KFxcXCI+KS8sICckMScgKyBjcy5oaWRlICsgJyQyJylcXG5cXG4gICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgc3RvcmFnZTAuc2V0SXRlbShtLCAnMCcpO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHVwZGF0ZUl0ZW0oJ2Rlc2MnLCB7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogdGl0bGVcXG4gICAgICAgICAgICAgICAgICAgICAgICAucmVwbGFjZShleHAsIHJldClcXG4gICAgICAgICAgICAgICAgICAgICAgICAucmVwbGFjZShyZSwgJyQxJyArIGRjICsgJzwvc21hbGw+JylcXG4gICAgICAgICAgICAgICAgICAgICAgICAucmVwbGFjZSgvKDxcXFxcL3NtYWxsPjxicj5cXFxcPGZvbnQgY29sb3I9XFxcIikuKj8oXFxcIj4pLywgJyQxJyArIGNzLnNob3cgKyAnJDInKVxcbiAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgICBzdG9yYWdlMC5zZXRJdGVtKG0sICcxJyk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBgaGlrZXI6Ly9lbXB0eWBcXG4gICAgICAgIH0sIGRl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ZSkge1xcbiAgICAgICAgICAgIGlmIChlKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnNwbGl0KHMpLmZpbHRlcihpdGVtID0+IGl0ZW0gIT09ICcnKTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5zcGxpdChzKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9LFxcbiAgICAgICAgZW51bWVyYWJsZTogZmFsc2UsXFxuICAgIH0pO1xcblxcbiAgICBPYmplY3QuZGVmaW5lUHJvcGVydGllcyhBcnJheS5wcm90b3R5cGUsIHtcXG4gICAgICAgIGV4Y2x1ZGVLZXlzOiB7XFxuICAgICAgICAgICAgdmFsdWU6IGZ1bmN0aW9uKGtleXMsIGV4Y2x1ZGUsIHJlbmFtZUNhbGxiYWNrKSB7XFxuICAgICAgICAgICAgICAgIC8vIOehruWumuaYr+aOkumZpOi/mOaYr+WPquS/neeVmemUrlxcbiAgICAgICAgICAgICAgICBjb25zdCBzaG91bGRFeGNsdWRlID0gdHlwZW9mIGV4Y2x1ZGUgPT09ICdib29sZWFuJyA/IGV4Y2x1ZGUgOiB0cnVlO1xcbiAgICAgICAgICAgICAgICBjb25zdCBrZXlzVG9IYW5kbGUgPSBBcnJheS5pc0FycmF5KGtleXMpID8ga2V5cyA6IFtdO1xcblxcbiAgICAgICAgICAgICAgICAvLyDkvb/nlKhBcnJheS5wcm90b3R5cGUubWFw6YGN5Y6G5pWw57uE5Lit55qE5q+P5Liq5YWD57SgXFxuICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLm1hcChpdGVtID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIC8vIOWmguaenOWFg+e0oOaYr+S4gOS4quaVsOe7hO+8jOmAkuW9kuiwg+eUqGV4Y2x1ZGVLZXlzXFxuICAgICAgICAgICAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShpdGVtKSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpdGVtLmV4Y2x1ZGVLZXlzKGV4Y2x1ZGUsIGtleXMsIHJlbmFtZUNhbGxiYWNrKTtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAodHlwZW9mIGl0ZW0gPT09ICdvYmplY3QnICYmIGl0ZW0gIT09IG51bGwpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAvLyDlpoLmnpzlhYPntKDmmK/kuIDkuKrlr7nosaHvvIzkvb/nlKhPYmplY3QuZnJvbUVudHJpZXPlkoxPYmplY3QuZW50cmllc+adpeWkhOeQhumUrlxcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGVudHJpZXMgPSBPYmplY3QuZW50cmllcyhpdGVtKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwcm9jZXNzZWRFbnRyaWVzID0gZW50cmllcy5tYXAoKFtrZXksIHZhbHVlXSkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyDlpoLmnpzmnInph43lkb3lkI3lm57osIPlh73mlbDvvIzliJnosIPnlKjlroNcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiByZW5hbWVDYWxsYmFjayA9PT0gJ2Z1bmN0aW9uJykge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtyZW5hbWVDYWxsYmFjayhrZXksIHZhbHVlKSwgdmFsdWVdO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBba2V5LCB2YWx1ZV07XFxuICAgICAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZmlsdGVyZWRFbnRyaWVzID0gc2hvdWxkRXhjbHVkZSA/XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByb2Nlc3NlZEVudHJpZXMuZmlsdGVyKChba2V5XSkgPT4gIWtleXNUb0hhbmRsZS5pbmNsdWRlcyhrZXkpKSA6XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByb2Nlc3NlZEVudHJpZXMuZmlsdGVyKChba2V5XSkgPT4ga2V5c1RvSGFuZGxlLmluY2x1ZGVzKGtleSkpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBPYmplY3QuZnJvbUVudHJpZXMoZmlsdGVyZWRFbnRyaWVzKTtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgLy8g5aaC5p6c5YWD57Sg5LiN5piv5a+56LGh5oiW5pWw57uE77yM55u05o6l6L+U5ZueXFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGl0ZW07XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgZW51bWVyYWJsZTogZmFsc2UsIC8vIOiuvue9ruS4uuS4jeWPr+aemuS4vlxcbiAgICAgICAgfSxcXG4gICAgICAgIHRyYW5zZm9ybUtleXM6IHtcXG4gICAgICAgICAgICB2YWx1ZTogZnVuY3Rpb24oa2V5TWFwcGluZykge1xcbiAgICAgICAgICAgICAgICAvLyDkvb/nlKhBcnJheS5wcm90b3R5cGUubWFw6YGN5Y6G5pWw57uE5Lit55qE5q+P5Liq5YWD57SgXFxuICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLm1hcChpdGVtID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIC8vIOWmguaenOWFg+e0oOaYr+S4gOS4quaVsOe7hO+8jOmAkuW9kuiwg+eUqHRyYW5zZm9ybUtleXNcXG4gICAgICAgICAgICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KGl0ZW0pKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGl0ZW0udHJhbnNmb3JtS2V5cyhrZXlNYXBwaW5nKTtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAodHlwZW9mIGl0ZW0gPT09ICdvYmplY3QnICYmIGl0ZW0gIT09IG51bGwpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAvLyDlpoLmnpzlhYPntKDmmK/kuIDkuKrlr7nosaHvvIzkvb/nlKhPYmplY3QuZnJvbUVudHJpZXPlkoxPYmplY3QuZW50cmllc+adpeWkhOeQhumUrlxcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGVudHJpZXMgPSBPYmplY3QuZW50cmllcyhpdGVtKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0cmFuc2Zvcm1lZEVudHJpZXMgPSBlbnRyaWVzLm1hcCgoW2tleSwgdmFsdWVdKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG5ld0tleSA9IGtleU1hcHBpbmdba2V5XSB8fCBrZXk7IC8vIOWmguaenOmUruWcqOaYoOWwhOS4re+8jOS9v+eUqOaWsOmUru+8m+WQpuWImeS9v+eUqOWOn+Wni+mUrlxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW25ld0tleSwgdmFsdWVdO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBPYmplY3QuZnJvbUVudHJpZXModHJhbnNmb3JtZWRFbnRyaWVzKTtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgLy8g5aaC5p6c5YWD57Sg5LiN5piv5a+56LGh5oiW5pWw57uE77yM55u05o6l6L+U5ZueXFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGl0ZW07XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgZW51bWVyYWJsZTogZmFsc2UsIC8vIOiuvue9ruS4uuS4jeWPr+aemuS4vlxcbiAgICAgICAgfVxcbiAgICB9KTtcXG5cXG4gICAgbGV0IHNvcnRvYmogPSBbXFxuICAgICAgICBmb250c3R5bGUoXFxcIuato+W6j1xcXCIsIHtcXG4gICAgICAgICAgICBjOiBcXFwiIzFBQUQxOVxcXCIsXFxuICAgICAgICAgICAgdGFnczogXFxcImJcXFwiXFxuICAgICAgICB9KSxcXG4gICAgICAgIGZvbnRzdHlsZShcXFwi6YCG5bqPXFxcIiwge1xcbiAgICAgICAgICAgIGM6IFxcXCIjRkYwMDAwXFxcIixcXG4gICAgICAgICAgICB0YWdzOiBcXFwiYlxcXCJcXG4gICAgICAgIH0pXFxuICAgIF1cXG4gICAgLy/mlrnms5VcXG5cXG4gICAgdmFyIHNvcnRpID0gZ2V0TXlWYXIoXFxcInNvcnRpXFxcIiwgXFxcIjBcXFwiKTtcXG5cXG4gICAgLy9sb2coc29ydG9iailcXG4gICAgJC5leHRlbmQoe1xcbiAgICAgICAgc3BsaXRQYWdlKHRvdGFsSXRlbXMsIHBhZ2VTaXplKSB7XFxuICAgICAgICAgICAgcGFnZVNpemUgPSBwYWdlU2l6ZSB8fCA1MDtcXG4gICAgICAgICAgICBsZXQgcmVzdWx0ID0gW107XFxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDE7IGkgPD0gdG90YWxJdGVtczsgaSArPSBwYWdlU2l6ZSkge1xcbiAgICAgICAgICAgICAgICBsZXQgZW5kID0gaSArIHBhZ2VTaXplIC0gMTtcXG4gICAgICAgICAgICAgICAgaWYgKGVuZCA+IHRvdGFsSXRlbXMpIHtcXG4gICAgICAgICAgICAgICAgICAgIGVuZCA9IHRvdGFsSXRlbXM7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgcmVzdWx0LnB1c2goYCR7aX0tJHtlbmR9YCk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiByZXN1bHQ7XFxuICAgICAgICB9LFxcbiAgICAgICAgc3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gICAgbG9nKHBsYXkpXFxuICAgICAgICAgIGxvZyhcXFwicGxheS51cmxcXFwiKVxcbiAgICAgICAgICBsZXQgcGFyc2Vfb2JqID0ge1xcbiAgICAgICAgICAgIGRlZl9yZWdleDogU3RyaW5nLnJhd2BcXFxcLihtcDR8bTN1OCl8Y24vdG9zYCxcXG4gICAgICAgICAgfTtcXG5cXG4gICAgICAgICAgaWYgKHBsYXkudXJsLmluY2x1ZGVzKFxcXCJwcm94eT9kb1xcXCIpKSB7XFxuICAgICAgICAgICAgTVlfVVJMID0gcGxheS51cmw7XFxuICAgICAgICAgICAgcGxheS51cmwgPSBkZWNvZGVVUklDb21wb25lbnQoZ2V0UGFyYW0oXFxcInVybFxcXCIsIFxcXCJcXFwiKSk7XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgaWYgKHBsYXkudXJsLnN0YXJ0c1dpdGgoXFxcImh0dHBzOi8vcGFuLnF1YXJrLmNuL1xcXCIpKSB7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3NlYXJjaD9zPVxcXCIgKyBwbGF5LnVybCArIFxcXCImcnVsZT11Y2tr5LqRXFxcIlxcbiAgICAgICAgICB9XFxuICAgICAgICAgIGlmIChwbGF5LnVybC5zdGFydHNXaXRoKCdodHRwczovL3d3dy5hbGl5dW5kcml2ZS5jb20vcy8nKSB8fCBwbGF5LnVybC5zdGFydHNXaXRoKFxcXCJodHRwczovL3d3dy5hbGlwYW4uY29tL3MvXFxcIikpIHtcXG4gICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vcGFnZS9hbGl5dW4/cnVsZT3kupHnm5jlkJsu566AJnBhZ2U9ZnlwYWdlJnJlYWx1cmw9XFxcIiArIGVuY29kZVVSSUNvbXBvbmVudChwbGF5LnVybCk7XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgaWYgKHBsYXkucGFyc2UgPT09IDEpIHtcXG4gICAgICAgICAgICBpZiAocGxheS51cmwuc3RhcnRzV2l0aChcXFwibWFnbmV0OlxcXCIpKSB7XFxuICAgICAgICAgICAgICByZXR1cm4gcGxheS51cmw7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGlmIChpc29mZmljaWFsKHBsYXkudXJsKSkge1xcbiAgICAgICAgICAgICAgcmV0dXJuICQucmVxdWlyZShcXFwiaGlrZXI6Ly9wYWdlL211bFBhcnNlP3J1bGU96YWN572u5Yqp5omLXFxcIikubXVsUGFyc2UocGxheS51cmwpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gXFxcInZpZGVvOi8vXFxcIiArIHBsYXkudXJsO1xcbiAgICAgICAgICB9IGVsc2UgaWYgKHBsYXkucGFyc2UgPT09IDApIHtcXG4gICAgICAgICAgICByZXR1cm4gcGxheS51cmw7XFxuICAgICAgICAgIH1cXG4gICAgICAgIH0pOyovXFxuICAgIH1cXG5cXG4gICAgbGV0IHBsYXlMYXp5ID0gJChcXFwiXFxcIikubGF6eVJ1bGUoKGlkLCBzb3VyY2UpID0+IHtcXG4gICAgICAgIHJldHVybiAkLnJlcXVpcmUoXFxcInZpZGVvVXJsXFxcIikucGFyc2UoaW5wdXQsIGlkLCBzb3VyY2UpO1xcbiAgICB9LCBcXFwiaWRcXFwiLCBzb3VyY2UpO1xcblxcblxcblxcbiAgICBsZXQgcGxheVVybExpc3QgPSBbXTtcXG4gICAgLy9jb25zb2xlLmxvZyhpbmZvLnZvZF9wbGF5X3VybCk7XFxuICAgIGxldCBpc05vdmVsPXN0eXBlPT09XFxcIuWwj+ivtFxcXCI7XFxuICAgIGxldCBwbGF5cGFnZXMgPSBbXTtcXG4gICAgaWYgKGluZm8udm9kX3BsYXlfdXJsICYmIGluZm8udm9kX3BsYXlfdXJsICE9IFxcXCJcXFwiKSB7XFxuICAgICAgICBsZXQgY29sID0gXFxcInRleHRfNFxcXCI7XFxuICAgICAgICBsZXQgdGV4dGFsaWduID0gXFxcIlxcXCI7XFxuICAgICAgICBwbGF5VXJsTGlzdCA9IGluZm8udm9kX3BsYXlfdXJsLnNwbGl0KFxcXCIkJCRcXFwiKS5tYXAoKHQsIGkpID0+IHtcXG4gICAgICAgICAgICBsZXQgaW1nID0gXFxcIlxcXCI7XFxuICAgICAgICAgICAgbGV0IHRzID0gdC5zcGxpdChcXFwiI1xcXCIpLm1hcCgoaykgPT4gay5zcGxpdChcXFwiJFxcXCIpWzBdKTtcXG4gICAgICAgICAgICBsZXQgcGFnZXMgPSAkLnNwbGl0UGFnZSh0cy5sZW5ndGgpXFxuICAgICAgICAgICAgbGV0IHRjID0gY291bnRUb3RhbEJ5dGVzKGZpbmRMb25nZXN0RWxlbWVudCh0cykpO1xcbiAgICAgICAgICAgIGlmICh0cy5maWx0ZXIoZSA9PiBlICE9IFxcXCJcXFwiKS5sZW5ndGgpIHtcXG4gICAgICAgICAgICAgICAgcGxheXBhZ2VzW2ldID0gcGFnZXM7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGlmICh0YyA+IDI0KSB7XFxuICAgICAgICAgICAgICAgIGNvbCA9IFxcXCJ0ZXh0XzFcXFwiO1xcbiAgICAgICAgICAgICAgICBpbWcgPSBcXFwiaHR0cHM6Ly9oaWtlcmZhbnMuY29tL3R1Ymlhby9tb3ZpZS8xNDYuc3ZnXFxcIjtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKHRjID49IDEyICYmIHRjIDwgMTUpIHtcXG4gICAgICAgICAgICAgICAgY29sID0gXFxcInRleHRfM1xcXCI7XFxuICAgICAgICAgICAgfSBlbHNlIGlmICh0YyA+PSAxNSkge1xcbiAgICAgICAgICAgICAgICBjb2wgPSBcXFwidGV4dF8yXFxcIjtcXG4gICAgICAgICAgICAgICAgdGV4dGFsaWduID0gXFxcImxlZnRcXFwiO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgcGxheW9iaiA9IHQuc3BsaXQoXFxcIiNcXFwiKS5tYXAoKGopID0+IHtcXG4gICAgICAgICAgICAgICAgbGV0IGsgPSBqLnNwbGl0KFxcXCIkXFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCB0ID0ga1swXTtcXG4gICAgICAgICAgICAgICAgbGV0IHVpZCA9IChrWzFdIHx8IGtbMF0pO1xcbiAgICAgICAgICAgICAgICByZXR1cm4ge1xcbiAgICAgICAgICAgICAgICAgICAgc3RpdGxlOiB0LFxcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IGZvbnRzdHlsZSh0LCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdGFnczogXFxcInNtYWxsXFxcIlxcbiAgICAgICAgICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgICAgICAgICBzdXJsOiB1aWQgKyBcXFwiI1xcXCIgKyBmcm9tW2ldLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiBpc05vdmVsP1xcXCJoaWtlcjovL3BhZ2Uvbm92ZWwjYXV0b1BhZ2UjI3JlYWRUaGVtZSNcXFwiOih1aWQgKyBcXFwiI1xcXCIgKyBmcm9tW2ldICsgcGxheUxhenkucmVwbGFjZSgnXFxcImlkXFxcIicsICdcXFwiJyArIHVpZCArICdcXFwiJykpLFxcbiAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6IGNvbCxcXG4gICAgICAgICAgICAgICAgICAgIGltZzogaW1nLFxcbiAgICAgICAgICAgICAgICAgICAgLypleHRyYTogT2JqZWN0LmFzc2lnbih7fSwgZXh0cmEsIHtcXG4gICAgICAgICAgICAgICAgICAgICAgXFxcIlJlZmVyZXJcXFwiOiBkZWNvZGVVUklDb21wb25lbnQoa1sxXSksXFxuICAgICAgICAgICAgICAgICAgICAgIGlkOiBrWzFdLFxcbiAgICAgICAgICAgICAgICAgICAgICAvL2xpbmVWaXNpYmxlOiBmYWxzZSxcXG4gICAgICAgICAgICAgICAgICAgICAgdGV4dEFsaWduOiB0ZXh0YWxpZ24sXFxuICAgICAgICAgICAgICAgICAgICAgIGNsczogXFxcInBsYXlsaXN0XFxcIixcXG4gICAgICAgICAgICAgICAgICAgIH0pKi9cXG4gICAgICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgZnJvbTogZnJvbVtpXSxcXG4gICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2U6IHNvdXJjZSxcXG4gICAgICAgICAgICAgICAgICAgICAgICBpZDogdWlkLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGJsb2NrUnVsZXM6IFsnYmIuKi5wbmcnLCAnLmpwZycsIFxcXCJobVxcXFwuYmFpZHVcXFxcLmNvbVxcXFwvaG0uanNcXFwiXSxcXG4gICAgICAgICAgICAgICAgICAgICAgICB2aWRlb0V4Y2x1ZGVSdWxlczogWyc/dXJsPSddLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGxpbmVWaXNpYmxlOiBmYWxzZSxcXG4gICAgICAgICAgICAgICAgICAgICAgICB0ZXh0QWxpZ246IHRleHRhbGlnbixcXG4gICAgICAgICAgICAgICAgICAgICAgICBjbHM6IFxcXCJwbGF5bGlzdFxcXCIsXFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH07XFxuICAgICAgICAgICAgfSk7XFxuXFxuICAgICAgICAgICAgaWYgKHN0eXBlID09IFxcXCLmvKvnlLtcXFwiIHx8IHN0eXBlID09IFxcXCLlsI/or7RcXFwiKSB7XFxuXFxuICAgICAgICAgICAgICAgIHZhciBkb3dubG9hZGxhenkgPSAkLnRvU3RyaW5nKChrZXksIHNrZXksIHRpdGxlKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIEdNXFxuICAgICAgICAgICAgICAgICAgICB9ID0gJC5yZXF1aXJlKFxcXCJodHRwOi8vaGlrZXIubm9raWEucHJlc3MvaGlrZXJ1bGUvcnVsZWxpc3QuanNvbj9pZD02OTE2JmF1dGg9MWQzNWU4ZjAtMjJlOC01MjcwLWE5ZDEtODI2ZjUzZjE3N2FkXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICBHTS5zZXRTZWxmS2V5KGtleSk7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgRHJweU1hbmFnZSA9IEdNLmRlZmluZU1vZHVsZShcXFwiRHJweU1hbmFnZVxcXCIsXFxcIkRycHlNYW5hZ2U/cnVsZT1cXFwiK3RpdGxlKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBkcnB5ID0gRHJweU1hbmFnZS5nZXQoc2tleSk7XFxuICAgICAgICAgICAgICAgICAgICBpbnB1dCA9IGlucHV0LnNwbGl0KFxcXCIjXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcmVzdWx0ID0gSlNPTi5wYXJzZShkcnB5LnBsYXkoaW5wdXRbMV0sIGlucHV0WzBdKSk7XFxuICAgICAgICAgICAgICAgICAgICBpZiAocmVzdWx0LnVybC5zdGFydHNXaXRoKFxcXCJwaWNzOi8vXFxcIikpIHJldHVybiByZXN1bHQudXJsO1xcbiAgICAgICAgICAgICAgICAgICAgZWxzZSBpZiAocmVzdWx0LnVybC5zdGFydHNXaXRoKFxcXCJub3ZlbDovL1xcXCIpKSByZXR1cm4gSlNPTi5wYXJzZShyZXN1bHQudXJsLnJlcGxhY2UoXFxcIm5vdmVsOi8vXFxcIiwgXFxcIlxcXCIpKS5jb250ZW50O1xcbiAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKFxcXCLmvKvnlLvmiJbmraPmlofojrflj5blpLHotKVcXFwiKTtcXG4gICAgICAgICAgICAgICAgfSwgR00uZ2V0U2VsZktleSgpLCBNWV9QQVJBTVMuc2tleSwgTVlfUlVMRS50aXRsZSk7XFxuXFxuICAgICAgICAgICAgICAgIGxldCBjaGFwdGVyTGlzdCA9IHBsYXlvYmouZXhjbHVkZUtleXMoW1xcXCJzdXJsXFxcIiwgXFxcInN0aXRsZVxcXCJdLCBmYWxzZSkudHJhbnNmb3JtS2V5cyh7XFxuICAgICAgICAgICAgICAgICAgICBcXFwic3VybFxcXCI6IFxcXCJ1cmxcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgXFxcInN0aXRsZVxcXCI6IFxcXCJ0aXRsZVxcXCJcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIHdyaXRlRmlsZShcXFwiaGlrZXI6Ly9maWxlcy9fY2FjaGUvZHJfZG93X2xpc3QuanNvblxcXCIsIEpTT04uc3RyaW5naWZ5KGNoYXB0ZXJMaXN0KSk7XFxuICAgICAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuS4i+i9vVxcXCIgKyBzdHlwZSxcXG4gICAgICAgICAgICAgICAgICAgIHVybDogJ2hpa2VyOi8vcGFnZS9kb3dubG9hZC52aWV3I25vUmVjb3JkSGlzdG9yeSMjbm9SZWZyZXNoIz9ydWxlPeacrOWcsOi1hOa6kOeuoeeQhicsXFxuICAgICAgICAgICAgICAgICAgICBjb2xfdHlwZTogJ3Njcm9sbF9idXR0b24nLFxcbiAgICAgICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjaGFwdGVyTGlzdDogXFxcImhpa2VyOi8vZmlsZXMvX2NhY2hlL2RyX2Rvd19saXN0Lmpzb25cXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGluZm86IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9va05hbWU6IGluZm8udm9kX25hbWUsIC8v5ryr55S75ZCN56ewLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBydWxlTmFtZTogTVlfUlVMRS50aXRsZSAsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJvb2tUb3BQaWM6IGluZm8udm9kX3BpYyxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFyc2VDb2RlOiBkb3dubG9hZGxhenksXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJvb2tJZDogTVlfUEFSQU1TLnNuYW1lLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBzdHlwZSA9PT0gXFxcIua8q+eUu1xcXCIgPyBcXFwiY29taWNcXFwiIDogXFxcIm5vdmVsXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHRWaWV3OiBcXFwiMVxcXCJcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuacrOWcsOS5puaetlxcXCIsXFxuICAgICAgICAgICAgICAgICAgICB1cmw6ICdoaWtlcjovL3BhZ2UvQm9va3JhY2sudmlldyNub1JlY29yZEhpc3RvcnkjP3J1bGU95pys5Zyw6LWE5rqQ566h55CGJnJ1bGVOYW1lPScgKyBNWV9SVUxFLnRpdGxlLFxcbiAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6ICdzY3JvbGxfYnV0dG9uJyxcXG4gICAgICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdHlwZTogc3R5cGUgPT09IFxcXCLmvKvnlLtcXFwiID8gXFxcImNvbWljXFxcIiA6IFxcXCJub3ZlbFxcXCIsXFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH0sIHtcXG4gICAgICAgICAgICAgICAgICAgIGNvbF90eXBlOiAnYmxhbmtfYmxvY2snXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgICBwbGF5b2JqID0gJC5zcGxpdEFycmF5QnlSYW5nZXMocGxheW9iaiwgcGFnZXMpO1xcbiAgICAgICAgICAgIHJldHVybiBwbGF5b2JqO1xcbiAgICAgICAgfSk7XFxuICAgIH0gZWxzZSB7XFxuICAgICAgICBkLnB1c2goe1xcbiAgICAg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N0KSB7XFxuICAgICAgICAgICAgICAgICAgICBwYWdlbnVtID0gaTtcXG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKGdldE15VmFyKFxcXCJzb3J0aVxcXCIsIFxcXCIwXFxcIikgPT0gMSkge1xcbiAgICAgICAgICAgIGxpc3QucmV2ZXJzZSgpO1xcbiAgICAgICAgfVxcbiAgICAgICAgJC5leHRlbmQoe1xcbiAgICAgICAgICAgIHRlbXBfbGlzdDogcGxheVVybExpc3RbbG9jYXRpb25dLFxcbiAgICAgICAgfSlcXG4gICAgICAgIGxldCBwbGF5cCA9IHBsYXlwYWdlc1tsb2NhdGlvbl07XFxuXFxuICAgICAgICBpZiAocGxheXAgJiYgcGxheXAubGVuZ3RoID4gMSkge1xcbiAgICAgICAgICAgIGxldCB0ZW1wID0ge1xcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogJ3RleHRfMScsXFxuICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICBjbHM6IFxcXCJwbGF5cGFnZVxcXCJcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgcGFnZWFyciA9IHBsYXlwLm1hcCgoeCwgaSkgPT4gaSA9PSBwYWdlbnVtID8gJ+KAnOKAnOKAneKAnScgKyB4LmZvbnRjb2xvcihcXFwicmVkXFxcIikgOiB4KTtcXG4gICAgICAgICAgICBkZWxldGVJdGVtQnlDbHMoXFxcInBsYXlwYWdlXFxcIilcXG4gICAgICAgICAgICBhZGRJdGVtQWZ0ZXIoXFxcInBsYXlwYWdlbGluZVxcXCIsIFt7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiAn5LiK5LiA6aG1JyxcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0XzRcXFwiLFxcbiAgICAgICAgICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKGxvY2F0aW9uLCBwY291bnQpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBwYWdlbnVtID0gZ2V0TXlWYXIoXFxcInBhZ2VudW1cXFwiLCBcXFwiMFxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKHBhZ2VudW0gPT0gMCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VudW0gPSBwY291bnQgLSAxO1xcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBwYWdlbnVtLS07XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICBwdXRNeVZhcihcXFwicGFnZW51bVxcXCIsIFN0cmluZyhwYWdlbnVtKSk7XFxuICAgICAgICAgICAgICAgICAgICBHTS5nZXQoXFxcInJlbm92YXRlTGlzdFxcXCIsICgpID0+IHt9KShsb2NhdGlvbik7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgICAgICB9LCBsb2NhdGlvbiwgcGNvdW50KSxcXG4gICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgIGNsczogXFxcInBsYXlwYWdlXFxcIlxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSwge1xcbiAgICAgICAgICAgICAgICB0aXRsZTogcGxheXBbcGFnZW51bV0sXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF8yXFxcIixcXG4gICAgICAgICAgICAgICAgdXJsOiAkKHBhZ2VhcnIsIDMpLnNlbGVjdCgobG9jYXRpb24pID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIHB1dE15VmFyKFxcXCJwYWdlbnVtXFxcIiwgU3RyaW5nKE1ZX0lOREVYKSk7XFxuICAgICAgICAgICAgICAgICAgICBHTS5nZXQoXFxcInJlbm92YXRlTGlzdFxcXCIsICgpID0+IHt9KShsb2NhdGlvbik7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiXFxuICAgICAgICAgICAgICAgIH0sIGxvY2F0aW9uKSxcXG4gICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgIGNsczogXFxcInBsYXlwYWdlXFxcIlxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSwge1xcbiAgICAgICAgICAgICAgICB0aXRsZTogJ+S4i+S4gOmhtScsXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF80XFxcIixcXG4gICAgICAgICAgICAgICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKChsb2NhdGlvbiwgcGNvdW50KSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcGFnZW51bSA9IGdldE15VmFyKFxcXCJwYWdlbnVtXFxcIiwgXFxcIjBcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChwYWdlbnVtID49IHBjb3VudCAtIDEpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBwYWdlbnVtID0gMDtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcGFnZW51bSsrO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgcHV0TXlWYXIoXFxcInBhZ2VudW1cXFwiLCBTdHJpbmcocGFnZW51bSkpO1xcbiAgICAgICAgICAgICAgICAgICAgR00uZ2V0KFxcXCJyZW5vdmF0ZUxpc3RcXFwiLCAoKSA9PiB7fSkobG9jYXRpb24pO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICAgICAgfSwgbG9jYXRpb24sIHBjb3VudCksXFxuICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICBjbHM6IFxcXCJwbGF5cGFnZVxcXCJcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1dKVxcbiAgICAgICAgICAgIC8qcGxheXAgPSBwbGF5cC5tYXAoKHgsIGkpID0+IHtcXG4gICAgICAgICAgICAgICBsZXQgb2JqID0gT2JqZWN0LmFzc2lnbih7fSwgdGVtcCwge1xcbiAgICAgICAgICAgICAgICAgdGl0bGU6ICfigJzigJzigJ3igJ0nICsgKHBhZ2VudW0gPT0gaSA/IHguZm9udGNvbG9yKFxcXCJyZWRcXFwiKSA6IHgpLFxcbiAgICAgICAgICAgICAgICAgdXJsOiAkKCcjbm9Mb2FkaW5nIycpLmxhenlSdWxlKChpKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgIGlmIChnZXRNeVZhcihcXFwicGFnZW51bVxcXCIpID09IGkpIHtcXG4gICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiXFxuICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgcHV0TXlWYXIoXFxcInBhZ2VudW1cXFwiLCBTdHJpbmcoaSkpO1xcbiAgICAgICAgICAgICAgICAgICBkZWxldGVJdGVtQnlDbHMoXFxcInBsYXlsaXN0XFxcIik7XFxuICAgICAgICAgICAgICAgICAgIGFkZEl0ZW1BZnRlcihcXFwicGxheWxpc3RzXFxcIiwgJC50ZW1wX2xpc3RbaV0pO1xcbiAgICAgICAgICAgICAgICAgICBmaW5kSXRlbXNCeUNscyhcXFwicGxheXBhZ2VcXFwiKS5mb3JFYWNoKCh4LCBpaSkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgIGxldCB0aXRsZSA9IHgudGl0bGUucmVwbGFjZSgv4oCYfOKAmXzigJx84oCdfDxbXj5dKz4vZywgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgIGlmIChpaSA9PSBpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICB0aXRsZSA9ICfigJzigJzigJ3igJ0nICsgdGl0bGUuZm9udGNvbG9yKFxcXCJyZWRcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgdXBkYXRlSXRlbSh4LmV4dHJhLmlkLCB7XFxuICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogdGl0bGUsXFxuICAgICAgICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICAgICAgIH0sIGkpLFxcbiAgICAgICAgICAgICAgICAgZXh0cmE6IE9iamVjdC5hc3NpZ24oe30sIHRlbXAuZXh0cmEsIHtcXG4gICAgICAgICAgICAgICAgICAgaWQ6IFxcXCJwYWdlbnVtXFxcIiArIGksXFxuICAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgcmV0dXJuIG9iajtcXG4gICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgYWRkSXRlbUFmdGVyKFxcXCJwbGF5cGFnZWxpbmVcXFwiLCBwbGF5cCkqL1xcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKGxpc3QpIHtcXG4gICAgICAgICAgICBhZGRJdGVtQWZ0ZXIoXFxcInBsYXlsaXN0c1xcXCIsIGxpc3QpO1xcbiAgICAgICAgfVxcbiAgICAgICAgdXBkYXRlSXRlbShcXFwibG9jYXRpb25AXFxcIiArIGN1cnJlbnRMb2NhdGlvbiwge1xcbiAgICAgICAgICAgIHRpdGxlOiBmcm9tW2N1cnJlbnRMb2NhdGlvbl0sXFxuICAgICAgICB9KTtcXG4gICAgICAgIHVwZGF0ZUl0ZW0oXFxcImxv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HguY29sX3R5cGUgPSB4LnR5cGU7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4geDtcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIGRlbGV0ZUl0ZW1CeUNscyhcXFwicGxheWxpc3RcXFwiKTtcXG4gICAgICAgICAgICAgICAgYWRkSXRlbUFmdGVyKFxcXCJwbGF5bGlzdHNcXFwiLCBwbGF5cyk7XFxuXFxuICAgICAgICAgICAgICAgIHB1dE15VmFyKFxcXCJzb3J0aVxcXCIsIGlpKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICB9LCBzb3J0b2JqKSxcXG4gICAgICAgICAgICBjb2xfdHlwZTogJ3Njcm9sbF9idXR0b24nLFxcbiAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgIGlkOiBcXFwiQHNvcnRcXFwiLFxcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0pXFxuICAgICAgICBmb3IgKGxldCBpIGluIGZyb20pIHtcXG4gICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogZnJvbVtpXSxcXG4gICAgICAgICAgICAgICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKChpLCBpZCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKGdldE15VmFyKGlkICsgXFxcInNvdXJjZWlcXFwiLCBcXFwiMFxcXCIpID09IGkpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgcHV0TXlWYXIoaWQgKyBcXFwic291cmNlaVxcXCIsIFN0cmluZyhpKSk7XFxuICAgICAgICAgICAgICAgICAgICBHTS5nZXQoXFxcInJlbm92YXRlTGlzdFxcXCIsICgpID0+IHt9KShpKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgICAgICAgIH0sIGksIGlkKSxcXG4gICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgIGlkOiBcXFwibG9jYXRpb25AXFxcIiArIGlcXG4gICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJzY3JvbGxfYnV0dG9uXFxcIlxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfVxcbiAgICB9XFxuICAgIC8vY29uc29sZS5sb2cocGxheVVybExpc3QpO1xcbiAgICAvKmlmIChwbGF5VXJsTGlzdC5sZW5ndGgpIHtcXG4gICAgICB2YXIgZWpvYmogPSB7XFxuICAgICAgICBcXFwibGlzdFxcXCI6IHBsYXlVcmxMaXN0LFxcbiAgICAgICAgXFxcInRhYlxcXCI6IGZyb20ubWFwKCh4LCBpKSA9PiBmcm9tW2ldKVxcbiAgICAgIH07XFxuICAgICAg5Yid5aeL5YyWKGQsIGVqb2JqKVxcbiAgICB9IGVsc2Uge1xcbiAgICAgIGQucHVzaCh7XFxuICAgICAgICB0aXRsZTogXFxcIuaaguaXoOaSreaUvua6kFxcXCIsXFxuICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfM1xcXCIsXFxuICAgICAgICB1cmw6IE1ZX1BBUkFNUy52b2RJZCxcXG4gICAgICB9KTtcXG4gICAgfSovXFxuXFxuICAgIGQucHVzaCh7XFxuICAgICAgICBjb2xfdHlwZTogXFxcImJsYW5rX2Jsb2NrXFxcIixcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgaWQ6IFxcXCJwbGF5cGFnZWxpbmVcXFwiXFxuICAgICAgICB9XFxuICAgIH0pXFxuXFxuXFxuICAgIGQucHVzaCh7XFxuICAgICAgICBjb2xfdHlwZTogXFxcImxpbmVcXFwiLF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p6QXFxcIlxcbiAgICB9XFxufSk7XFxuXFxuZC5wdXNoKHtcXG4gICAgdGl0bGU6IFxcXCLliIbkuqtcXFwiLFxcbiAgICB1cmw6ICQoXFxcIi0xXFxcIiwgXFxcIui+k+WFpeS9oOimgeWIhuS6q+ino+aekOeahOW6j+WPt1xcXFxuLTHlhajpg6jvvIwtMuW3suWQr+eUqOeahO+8jC0z5bey56aB55So55qEXFxcIikuaW5wdXQoKGxlbmd0aCkgPT4ge1xcbiAgICAgICAgbGV0IGluZGV4YyA9IGlucHV0LnNwbGl0KC8sfO+8jC8pO1xcbiAgICAgICAgbGV0IGluZGV4cyA9IFtdO1xcbiAgICAgICAgbGV0IG1vID0gcGFyc2VJbnQoaW5kZXhjWzBdKTtcXG4gICAgICAgIGlmICghKGluZGV4Yy5sZW5ndGggIT09IDAgJiYgbW8gPCAwICYmIG1vID4gLTUpKSB7XFxuICAgICAgICAgICAgZm9yIChsZXQgaXQgb2YgaW5kZXhjKSB7XFxuICAgICAgICAgICAgICAgIGxldCBudW0gPSBwYXJzZUludChpdCk7XFxuICAgICAgICAgICAgICAgIGlmIChOdW1iZXIuaXNOYU4obnVtKSB8fCBudW0gPj0gbGVuZ3RoIHx8IG51bSA8IDApIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/mlbDlrZfkuI3lkIjms5VcXFwiO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGluZGV4cy5wdXNoKG51bSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfVxcbiAgICAgICAgcmV0dXJuICQoW1xcXCJISUtFUlxcXCIsIFxcXCJUWFRcXFwiXS5jb25jYXQoZ2V0UGFzdGVzKCkpLCAyLCBcXFwi5YiG5Lqr5pa55byPXFxcIikuc2VsZWN0KChtbywgaW5kZXhzLCBleHQpID0+IHtcXG4gICAgICAgICAgICBmdW5jdGlvbiB1cChydWxlcykge1xcbiAgICAgICAgICAgICAgICBsZXQ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XCIpKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwic2hhcmU6Ly9cXFwiICsgcGF0aDtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgcnVsZXM7XFxuICAgICAgICAgICAgaWYgKG1vID09PSAtMSkge1xcbiAgICAgICAgICAgICAgICBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKG1vID09PSAtMikge1xcbiAgICAgICAgICAgICAgICBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldFVzZWZ1bEpzb24oKTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKG1vID09PSAtMykge1xcbiAgICAgICAgICAgICAgICBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEZvcmJpZGRlbkpzb24oKTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKS5maWx0ZXIoKHYsIGkpID0+IGluZGV4cy5pbmNsdWRlcyhpKSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJ1bGVzID0gcnVsZXMubWFwKCh2KSA9PiB7XFxuICAgICAgICAgICAgICAgIHYuZm9yYmlkZGVuID0gdW5kZWZpbmVkO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gdjtcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICByZXR1cm4gdXAocnVsZXMpO1xcbiAgICAgICAgfSwgbW8sIGluZGV4cywgaW5kZXhjWzFdKTtcXG5cXG4gICAgfSwgbGVuZ3RoKSxcXG4gICAgY29sX3R5cGU6IFxcXCJpY29uX3NtYWxsXzRcXFwiLFxcbiAgICBwaWNfdXJsOiBcXFwiaGlrZXI6Ly9pbWFnZX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Bhc3MocnVsZS5uYW1lLCBydWxlYjY0LCBcXFwiYVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgdSA9IHNoYXJlUGFzdGUocnVsZWI2NCwgaW5wdXQpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiY29weTovL1xcXCIgKyBnZXRQYXNzKHJ1bGUubmFtZSwgdSwgXFxcImJcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfSwgaW5kZXgpO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoaW5wdXQgPT09IFxcXCLnp7vliqhcXFwiKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiAkKGluZGV4ICsgXFxcIlxcXCIsIFxcXCLovpPlhaXkvY3nva5cXFwiKS5pbnB1dCgoaW5kZXgsIGxlbmd0aCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IG5ld0luZGV4ID0gTnVtYmVyKGlucHV0KTtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChOdW1iZXIuaXNOYU4obmV3SW5kZXgpIHx8IG5ld0luZGV4ID49IGxlbmd0aCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/kuI3lkozop4TnmoTkvY3nva5cXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGUgPSBydWxlcy5zcGxpY2UoaW5kZXgsIDEpWzBdO1xcbiAgICAgICAgICAgICAgICAgICAgcnVsZXMuc3BsaWNlKG5ld0luZGV4LCAwLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgICAgICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLnNhdmVKc29uKHJ1bGVzKTtcXG4gICAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKGZhbHNlKTtcXG4gICAgICAgICAgICAgICAgfSwgaW5kZXgsIGxlbmd0aCk7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChpbnB1dCA9PT0gXFxcIue9rumhtlxcXCIpIHtcXG4gICAgICAgICAgICAgICAgbGV0IG5ld0luZGV4ID0gMDtcXG4gICAgICAgICAgICAgICAgbGV0IHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgICAgICBsZXQgcnVsZSA9IHJ1bGVzLnNwbGljZShpbmRleCwgMSlbMF07XFxuICAgICAgICAgICAgICAgIHJ1bGVzLnNwbGljZShuZXdJbmRleCwgMCwgcnVsZSk7XFxuICAgICAgICAgICAgICAgICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLnNhdmVKc29uKHJ1bGVzKTtcXG4gICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoaW5wdXQgPT09IFxcXCLliKDpmaRcXFwiKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiAkKFxcXCLnoa7orqTliKDpmaTvvJ9cXFwiKS5jb25maXJtKChpbmRleCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGUgPSBydWxlcy5zcGxpY2UoaW5kZXgsIDEpWzBdO1xcbiAgICAgICAgICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuc2F2ZUpzb24ocnVsZXMpO1xcbiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcbiAgICAgICAgICAgICAgIC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9qaWV4aVNpbXBsZUltcG9ydC5qc29uXFxcIik7XFxuICAgICAgICBsZXQgdGlwID0gaW5kZXggIT09IHZvaWQoMCkgPyBcXFwi5pu05paw6Kej5p6QXFxcIiA6IFxcXCLlr7zlhaXop6PmnpBcXFwiO1xcbiAgICAgICAgc2V0UGFnZVRpdGxlKHRpcCArIFxcXCI6XFxcIiArIG9iai5uYW1lKTtcXG4gICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLigJjigJhcXFwiICsgdGlwICsgXFxcIuKAmeKAmVxcXCIsXFxuICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2VcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9KTtcXG5cXG4gICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgb2JqID0ge307XFxuICAgICAgICBiYWNrKCk7XFxuICAgICAgICB0b2FzdChcXFwi5a+85YWl6ZSZ6K+vXFxcIik7XFxuICAgIH1cXG59IGVsc2UgaWYgKGluZGV4ICE9PSB2b2lkKDApKSB7XFxuICAgIG9iaiA9IGFycltpbmRleF07XFxuICAgIHNldFBhZ2VUaXRsZShcXFwi57yW6L6R6Kej5p6QOlxcXCIgKyBvYmoubmFtZSk7XFxufSBlbHNlIHtcXG4gICAgb2JqID0ge1xcbiAgICAgICAgcnVuVHlwZTogXFxcIldFQlxcXCIsXFxuICAgICAgICBtZXRob2Q6IFxcXCJHRVRcXFwiXFxuICAgIH07XFxuICAgIHNldFBhZ2VUaXRsZShcXFwi5paw5bu66Kej5p6QXFxcIik7XFxufVxcblxcbmQucHVzaCh7XFxuICAgIGNvbF90eXBlOiBcXFwiaW5wdXRcXFwiLFxcbiAgICBkZXNjOiBcXFwi5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ICAgbGV0IGpzID0gZ2V0TXlWYXIoXFxcInBzX2pzXFxcIiwgXFxcIlxcXCIpIHx8IHZvaWQgMDtcXG4gICAgICAgICAgICBpZiAoaGVhZGVycykge1xcbiAgICAgICAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgICAgICAgICAgaGVhZGVycyA9IEpTT04ucGFyc2UoaGVhZGVycyk7XFxuICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGVhZGVyc+agvOW8j+mUmeivrzpcXFwiICsgZS50b1N0cmluZygpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiAkLnJlcXVpcmUoXFxcInZpZGVvVXJsXFxcIikucHJlcGFyZVBhcnNlcyhbe1xcbiAgICAgICAgICAgICAgICBuYW1lLFxcbiAgICAgICAgICAgICAgICB1cmwsXFxuICAgICAgICAgICAgICAgIGZsYWcsXFxuICAgICAgICAgICAgICAgIGhlYWRlcnMsXFxuICAgICAgICAgICAgICAgIHJ1blR5cGUsXFxuICAgICAgICAgICAgICAgIG1ldGhvZCxcXG4gICAgICAgICAgICAgICAganNvblBhdGgsXFxuICAgICAgICAgICAgICAgIGpzXFxuICAgICAgICAgICAgfV0sIGlucHV0LG51bGwsIHRydWUpO1xcbiAgICAgICAgfSk7XFxuICAgIH0pLFxcbiAgICBjb2xfdHlwZTogXFxcInRleHRfM1xcXCIsXFxufSk7XFxuXFxuZC5wdXNoKHtcXG4gICAgdGl0bGU6IFxcXCLkv53lrZhcXFwiLFxcbiAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKGluZGV4LCBpc0ltcG9ydCkgPT4ge1xcbiAgICAgICAgbGV0IG5hbWUgPSBnZXRNeVZhcihcXFwicHNfbmFtZVxcXCIsIFxcXCJcXFwiKS50cmltKCk7XFxuICAgICAgICBpZiAoIW5hbWUpIHtcXG4gICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5ZCN5a2X5b6X5pyJ5LiA5Liq5ZCnXFxcIjtcXG4gICAgICAgIH1cXG4gICAgICAgIGxldCB1cmwgPSBnZXRNeVZhcihcXFwicHNfdXJsXFxcIiwgXFxcIlxcXCIpLnRyaW0oKTtcXG4gICAgICAgIGlmICghdXJsKSB7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+ino+aekOWcsOWdgOS4jeiDveS4uuepulxcXCI7XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgZmxhZyA9IGdldE15VmFyKFxcXCJwc19mbGFnXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgaWYgKCFmbGFnKSB7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+ino+aekOWcsOWdgOagh+ivhuS4jeiDveS4uuepulxcXCI7XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgaGVhZGVycyA9IGdldE15VmFyKFxcXCJwc19oZWFkZXJzXFxcIiwgXFxcIlxcXCIpLnRyaW0oKTtcXG4gICAgICAgIGlmIChoZWFkZXJzKSB7XFxuICAgICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAgICAgaGVhZGVycyA9IEpTT04ucGFyc2UoaGVhZGVycyk7XFxuICAgICAgICAgICAgICAgIGlmKHR5cGVvZiBoZWFkZXJzIT09XFxcIm9iamVjdFxcXCIpIHRocm93IG5ldyBFcnJvcihcXFwi6ZSZ6K+v57G75Z6L77yM5b+F6aG75Li6T2JqZWN0XFxcIik7XFxuICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhlYWRlcnPmoLzlvI/plJnor686XFxcIiArIGUudG9TdHJpbmcoKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgcnVuVHlwZSA9IGdldE15VmFyKFxcXCJwc19ydW5UeXBlXFxcIiwgXFxcIldFQlxcXCIpO1xcbiAgICAgICAgbGV0IG1ldGhvZCA9IGdldE15VmFyKFxcXCJwc19tZXRob2RcXFwiLCBcXFwiR0VUXFxcIik7XFxuICAgICAgICBsZXQganNvblBhdGggPSBnZXRNeVZhcihcXFwicHNfanNvblBhdGhcXFwiLCBcXFwiXFxcIikudHJpbSgpIHx8IHZvaWQgMDtcXG4gICAgICAgIGxldCBqcyA9IGdldE15VmFyKFxcXCJwc19qc1xcXCIsIFxcXCJcXFwiKSB8fCB2b2lkIDA7XFxuICAgICAgICBpZiAocnVuVHlwZSA9PT0gXFxcIkpTT05cXFwiICYmICFqc29uUGF0aCkge1xcbiAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly9KU09O5qih5byP5LiL5b+F6aG75aGranNvblBhdGhcXFwiO1xcbiAgICAgICAgfSBlbHNlIGlmIChydW5UeXBlID09PSBcXFwiSlNcXFwiICYmICFqcykge1xcbiAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly9KU+aooeW8j+S4i+W/hemhu+Whq2pzXFxcIjtcXG4gICAgICAgIH1cXG4gICAgICAgIGxldCBhcnIgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICBsZXQgb2JqMSA9IHtcXG4gICAgICAgICAgICBuYW1lLFxcbiAgICAgICAgICAgIHVybCxcXG4gICAgICAgICAgICBmbGFnLFxcbiAgICAgICAgICAgIGhlYWRlcnMsXFxuICAgICAgICAgICAgcnVuVHlwZSxcXG4gICAgICAgICAgICBtZXRob2QsXFxuICAgICAgICAgICAganNvblBhdGgsXFxuICAgICAgICAgICAganNcXG4gICAgICAgIH07XFxuICAgICAgICBpZiAoaW5kZXggPT09IHZvaWQoMCkpIHtcXG4gICAgICAgICAgICBpZiAoYXJyLnNvbWUodiA9PiB2Lm5hbWUgPT09IG5hbWUpKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/lt7Lnu4/lrZjlnKjor6Xop6PmnpBcXFwiO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAob2JqMS5ncm91cCkge1xcbiAgICAgICAgICAgICAgICBsZXQgZ3JvdXAgPSBvYmoxLmdyb3VwO1xcbiAgICAgICAgICAgICAgICBsZXQgaW5kZXggPSBhcnIuZmluZEluZGV4KHYgPT4gdi5ncm91cCA9PT0gZ3JvdXApO1xcbiAgICAgICAgICAgICAgICBpZiAoaW5kZXggPT09IC0xKSB7XFxuICAgICAgICAgICAgICAgICAgICBhcnIudW5zaGlmdChvYmoxKTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIGFyci5zcGxpY2UoaW5kZXgsIDAsIG9iajEpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgaWYgKGlzSW1wb3J0KSB7XFxuICAgICAgICAgICAgICAgICAgICBhcnIucHVzaChvYmoxKTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIGFyci51bnNoaWZ0KG9iajEpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBsZXQgbmFtZXkgPSBhcnJbaW5kZXhdLm5hbWU7XFxuICAgICAgICAgICAgaWYgKG5hbWUgIT09IG5hbWV5KSB7XFxuICAgICAgICAgICAgICAgIGlmIChhcnIuc29tZSh2ID0+IHYubmFtZSA9PT0gbmFtZSkpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/lt7Lnu4/lrZjlnKjor6Xop6PmnpBcXFwiO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIG9iajEgPSBPYmplY3QuYXNzaWduKGFycltpbmRleF0sIG9iajEpO1xcbiAg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AgICAgICBNWV9VUkwgPSBtb2R1bGUuaWQ7XFxuICAgICAgICBsZXQgcnVsZVRpdGxlID0gZ2V0UGFyYW0oXFxcInJ1bGVcXFwiKTtcXG4gICAgICAgIGxldCBhcnIgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3M/cnVsZT1cXFwiICsgcnVsZVRpdGxlKS5nZXRKc29uKCk7XFxuICAgICAgICBsZXQgbmV3SSA9IDA7XFxuICAgICAgICBmb3IgKGxldCBydWxlIG9mIHJ1bGVzKSB7XFxuICAgICAgICAgICAgbGV0IGluZGV4ID0gYXJyLmZpbmRJbmRleCh2ID0+IHYubmFtZSA9PT0gcnVsZS5uYW1lKTtcXG4gICAgICAgICAgICBpZiAoaW5kZXggPiAtMSkge1xcbiAgICAgICAgICAgICAgICBydWxlID0gT2JqZWN0LmFzc2lnbihhcnJbaW5kZXhdLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgYXJyLnNwbGljZShpbmRleCwgMSwgcnVsZSk7XFxuICAgICAgICAgICAgICAgIGlmIChydWxlcy5sZW5ndGggPT09IDEpIHtcXG4gICAgICAgICAgICAgICAgICAgIHNhdmVDYWNoZShydWxlKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL3J1bGVFZGl0I25vSGlzdG9yeSMjbm9SZWNvcmRIaXN0b3J5Iz9pc0ltcG9ydD10cnVlJmluZGV4PVxcXCIgKyBpbmRleCArIFxcXCImcnVsZT1cXFwiICsgcnVsZVRpdGxlO1xcbiAgICAgICAgICAgICAgICAgICAgLy90b2FzdChcXFwi5bey5pu05paw6KeE5YiZ77yaXFxcIiArIHJ1bGUubmFtZSk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBsb2coXFxcIuW3suabtOaWsOinhOWIme+8mlxcXCIgKyBydWxlLm5hbWUpXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBuZXdJKys7XFxuICAgICAgICAgICAgICAgIGFyci5wdXNoKHJ1bGUpO1xcbiAgICAgICAgICAgICAgICBpZiAocnVsZXMubGVuZ3RoID09PSAxKSB7XFxuICAgICAgICAgICAgICAgICAgICBzYXZlQ2FjaGUocnVsZSk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vcGFnZS9ydWxlRWRpdCNub0hpc3RvcnkjI25vUmVjb3JkSGlzdG9yeSM/aXNJbXBvcnQ9dHJ1ZSZydWxlPVxcXCIgKyBydWxlVGl0bGU7XFxuICAgICAgICAgICAgICAgICAgICAvL3RvYXN0KFxcXCLlt7Llr7zlhaXop4TliJnvvJpcXFwiICsgcnVsZS5uYW1lKTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIGxvZyhcXFwi5bey5a+85YWl6KeE5YiZ77yaXFxcIiArIHJ1bGUubmFtZSlcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH1cXG4gICAgICAgIGlmIChydWxlcy5sZW5ndGggPiAxKSB7XFxuICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzP3J1bGU9XFxcIiArIHJ1bGVUaXRsZSkuc2F2ZUpzb24oYXJyKTtcXG4gICAgICAgICAgICB0b2FzdChcXFwi5paw5aKe77yaXFxcIiArIG5ld0kgKyBcXFwiIOimhuebluabtOaWsO+8mlxcXCIgKyAocnVsZXMubGVuZ3RoIC0gbmV3SSkpO1xcbiAgICAgICAgfVxcbiAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICBsb2coZS50b1N0cmluZygpKTtcXG4gICAgICAgIHRvYXN0KFxcXCLlr7zlhaXlpLHotKVcXFwiKTtcXG4gICAgfVxcbn1cXG5cXG5mdW5jdGlvbiBpbXBvcnRSdWxlKHBhc3MpIHtcXG4gICAgdHJ5IHtcXG4gICAgICAgIGxldCBbX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odiwgaSkgPT4ge1xcbiAgICAgICAgXFxuICAgICAgICBwbGF5bGlzdC5uYW1lcy5wdXNoKHYubmFtZSk7XFxuICAgICAgICBpZiAodi5oZWFkZXJzKSB7XFxuICAgICAgICAgICAgcGxheWxpc3QuaGVhZGVycy5wdXNoKHYuaGVhZGVycyk7XFxuICAgICAgICB9XFxuICAgICAgICBpZiAodi5ydW5UeXBlID09PSBcXFwiSlNPTlxcXCIpIHtcXG4gICAgICAgICAgICBsZXQgcGFyYW0gPSB7XFxuICAgICAgICAgICAgICAgIC8vdXJsOiB2LnVybCxcXG4gICAgICAgICAgICAgICAgbWV0aG9kOiB2Lm1ldGhvZCxcXG4gICAgICAgICAgICAgICAgaGVhZGVyczogdi5oZWFkZXJzLFxcbiAgICAgICAgICAgICAgICBqc29uUGF0aDogdi5qc29uUGF0aFxcbiAgICAgICAgICAgIH07XFxuICAgICAgICAgICAgcGxheWxpc3QudXJscy5wdXNoKHByb3h5VXJsICsgXFxcIj9ydW5UeXBlPUpTT04mdXJsPVxcXCIgKyBlbmNvZGVVUklDb21wb25lbnQoYmFzZTY0RW5jb2RlKHYudXJsICsgdXJsKSkgKyBcXFwiJnBhcmFtPVxcXCIgKyBlbmNvZGVVUklDb21wb25lbnQoYmFzZTY0RW5jb2RlKEpTT04uc3RyaW5naWZ5KHBhcmFtKSkpKTtcXG4gICAgICAgIH0gZWxzZSBpZiAodi5ydW5UeXBlID09PSBcXFwiSlNcXFwiKSB7XFxuICAgICAgICAgICAgcGxheWxpc3QudXJscy5wdXNoKHByb3h5VXJsICsgXFxcIj9ydW5UeXBlPUpTJnVybD1cXFwiICsgZW5jb2RlVVJJQ29tcG9uZW50KGJhc2U2NEVuY29kZSh1cmwpKSArIChpc1Rlc3QgPyBcXFwiJnBhcmFtPVxcXCIgKyBlbmNvZGVVUklDb21wb25lbnQoYmFzZTY0RW5jb2RlKEpTT04uc3RyaW5naWZ5KHYpKSkgOiBcXFwiJmluZGV4PVxcXCIgKyBpKSk7XF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0dXJuIFxcXCJoaWtlcjovL3BhZ2UvYWxpeXVuP3J1bGU95LqR55uY5ZCbLueugCZwYWdlPWZ5cGFnZSZyZWFsdXJsPVxcXCIgKyBlbmNvZGVVUklDb21wb25lbnQocGxheS51cmwpO1xcbiAgICB9XFxuICAgIGlmIChwbGF5LnVybC5zdGFydHNXaXRoKFxcXCJwaWNzOi8vXFxcIikpIHtcXG4gICAgICAgIHJldHVybiBwbGF5LnVybDtcXG4gICAgfVxcbiAgICBpZiAocGxheS51cmwuc3RhcnRzV2l0aChcXFwibm92ZWw6Ly9cXFwiKSkge1xcbiAgICAgICAgcmV0dXJuICQoXFxcImhpa2VyOi8vZW1wdHkjcmVhZFRoZW1lI1xcXCIpLnJ1bGUoKGRhdGEpID0+IHtcXG4gICAgICAgICAgICBsZXQgZGF0YSA9IEpTT04ucGFyc2UoZGF0YSk7XFxuICAgICAgICAgICAgbGV0IGxheW91dCA9IFtdO1xcbiAgICAgICAgICAgIGxldCBjb250ZW50ID0gXFxcIuOAgOOAgFxcXCIgKyBkYXRhLmNvbnRlbnQuc3BsaXQoLyhcXFxcbnxcXFxccikrLykuZmlsdGVyKGl0ID0+IGl0LnRyaW0oKS5sZW5ndGggPiAxKS5tYXAoaXQgPT4gaXQudHJpbSgpKS5qb2luKFxcXCI8YnI+44CA44CAXFxcIik7XFxuICAgICAgICAgICAgbGF5b3V0LnB1c2goe1xcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcInJpY2hfdGV4dFxcXCIsXFxuICAgICAgICAgICAgICAgIHRpdGxlOiAoXFxcIjxzdHJvbmc+XFxcIiArIGRhdGEudGl0bGUgKyBcXFwiPC9zdHJvbmc+XFxcIikuYmlnKCksXFxuICAgICAgICAgICAgfSk7XFxuXFxuICAgICAgICAgICAgbGF5b3V0LnB1c2goe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogY29udGVudCxcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6ICdyaWNoX3RleHQnLFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgdGV4dFNpemU6IDE4LFxcbiAgICAgICAgICAgICAgICAgICAgY2xpY2s6IHRydWVcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIHNldFJlc3VsdChsYXlvdXQpO1xcbiAgICAgICAgfSwgcGxheS51cmwucmVwbGFjZShcXFwibm92ZWw6Ly9cXFwiLFxcXCJcXFwiKSk7XFxuICAgIH1cXG4gICAgLy9sb2cocGxheSk7XFxuICAgIGlmIChwbGF5LnBhcnNlID09PSAxfHxwbGF5Lmp4PT09MSkge1xcbiAgICAgICAgaWYgKHBsYXkudXJsLnN0YXJ0c1dpdGgoXFxcIm1hZ25ldDpcXFwiKSkge1xcbiAgICAgICAgICAgIHJldHVybiBwbGF5LnVybDtcXG4gICAgICAgIH1cXG4gICAgICAgIGNhcnJ5SnMocGxheSwgaWQpO1xcbiAgICAgICAgaWYgKHBsYXkuang9PT0xfHwoaXNvZmZpY2lhbChwbGF5LnVybCkgJiYgKHBsYXkuZmxhZyB8fCBpbnB1dFsxXSkpKSB7ICAgICAgICAgICAgXFxuICAgICAgICAgICAgcmV0dXJuIHVzZVBhcnNlcyhwbGF5LnVybCwgcGxheS5mbGFnIHx8IGlucHV0WzFdKTtcXG4gICAgICAgIH1cXG4gICAgICAgIHJldHVybiBcXFwidmlkZW86Ly9cXFwiICsgcGxheS51cmw7XFxuICAgIH0gZWxzZSBpZiAocGxheS5wYXJzZSA9PT0gMCkge1xcbiAgICAgICAgaWYgKHBsYXkudXJsLnN0YXJ0c1dpdGgoXFxcIm1hZ25ldDpcXFwiKSkge1xcbiAgICAgICAgICAgIHJldHVybiBwbGF5LnVybDtcXG4gICAgICAgIH1cXG4gICAgICAgIC8vbG9nKHBsYXkpXFxuICAgICAgICB2YXIgcGxheW9iaiA9IHt9O1xcbiAgICAgICAgcGxheW9iai51cmxzID0gW3BsYXkudXJsICsgXFxc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gICAgICAgIHdyaXRlRmlsZShwYXRoICsgaXQubmFtZSwgcnVsZSk7XFxuICAgICAgICAgICAgICAgIHJ1bGVzLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgJ2tleSc6IGBoaXB5X2pzXyR7bmFtZX1gLFxcbiAgICAgICAgICAgICAgICAgICAgJ25hbWUnOiBgJHtuYW1lfWAsXFxuICAgICAgICAgICAgICAgICAgICAndHlwZSc6IDMsXFxuICAgICAgICAgICAgICAgICAgICAnYXBpJzonLi4vbGlicy9kcnB5Mi5qcycsXFxuICAgICAgICAgICAgICAgICAgICAnc2VhcmNoYWJsZSc6IDEsXFxuICAgICAgICAgICAgICAgICAgICAncXVpY2tTZWFyY2gnOiAxLFxcbiAgICAgICAgICAgICAgICAgICAgJ2ZpbHRlcmFibGUnOiAxLFxcbiAgICAgICAgICAgICAgICAgICAgJ2V4dCc6IFxcXCIuL1xcXCIgKyBpdC5uYW1lLFxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgY291bnQrKztcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgbG9nKGUudG9TdHJpbmcoKSk7XFxuICAgICAgICB9XFxuICAgIH1cXG4gICAgd3JpdGVGaWxlKHBhdGggKyBcXFwiaW5kZXguanNvblxcXCIsIEpTT04uc3RyaW5naWZ5KHtzaXRlczpydWxlc30pKTtcXG4gICAgcmV0dXJuIFxcXCJ0b2FzdDovL+aIkOWKn+abtOaWsFxcXCIgKyBjb3VudCArIFxcXCLkuKpcXFwiOztcXG59XFxuXFxuZnVuY3Rpb24gZ2VuZXJhdGVDb25maWdCeUluZGV4KHVybCwgcGF0aCkge1xcbiAgICBsZXQganNvbiA9IEpTT04ucGFyc2UodG9Db3JyZWN0SlNPTlN0cmluZyhyZXF1ZXN0KHVybCkpKTtcXG4gICAgbGV0IGFyciA9IGpzb24uc2l0ZXM7XFxuICAgIGxldCBjb3VudCA9IDA7XFxuICAgIGxldCBpID0gMDtcXG4gICAgZm9yIChsZXQgaXQgb2YgYXJyKSB7XFxuICAgICAgICB0cnkge1xcbiAgICAgICAgICAgIGlmICgoU3RyaW5nKGl0LmFwaSkuaW5jbHVkZXMoXFxcImRycHkyLm1pbi5qc1xcXCIpIHx8IFN0cmluZyhpdC5hcGkpLmluY2x1ZGVzKFxcXCJkcnB5Mi5qc1xcXCIpKSkge1xcbiAgICAgICAgICAgICAgICBsZXQgbmFtZSA9IGl0LmV4dC5lbmRzV2l0aChcXFwiLmpzXFxcIikgPyBkZWNvZGVVUklDb21wb25lbnQoaXQuZXh0LnNwbGl0KFxcXCIvXFxcIikuYXQoLTEpKSA6IChpdC5uYW1lICsgXFxcIi5qc1xcXCIpO1xcbiAgICAgICAgICAgICAgICBsZXQgcnVsZTtcXG4gICAgICAgICAgICAgICAgaWYgKFN0cmluZyhpdC5leHQpLnN0YXJ0c1dpdGgoXFxcImh0dHBcXFwiKSkge1xcbiAgICAgICAgICAgICAgICAgICAgcnVsZSA9IHJlcXVlc3QoaXQuZXh0KTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIHJ1bGUgPSByZXF1ZXN0KGpvaW5VcmwodXJsLCBpdC5leHQpKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBpdC5leHQgPSBcXFwiLi9cXFwiICsgbmFtZTtcXG4gICAgICAgICAgICAgICAgaWYgKCFydWxlIHx8ICFydWxlLmluY2x1ZGVzKFxcXCJydWxlXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgICAgIGlmICghZmlsZUV4aXN0KHBhdGggKyBuYW1lKSlcXG4gICAgICAgICAgICAgICAgICAgICAgICBhcnIuc3BsaWNlKGksIDEpO1xcbiAgICAgICAgICAgICAgICAgICAgY29udGludWU7XFxuICAgICAgICAgICAgICAgIH07XFxuICAgICAgICAgICAgICAgIHdyaXRlRmlsZShwYXRoICsgbmFtZSwgcnVsZ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0gZWxzZSB7XFxuICAgICAgICAgICAgbGV0IGpzb24gPSBKU09OLnBhcnNlKHRvQ29ycmVjdEpTT05TdHJpbmcoZmV0Y2goY29uZmlnLnBhdGgpIHx8IFxcXCJ7fVxcXCIpKTtcXG4gICAgICAgICAgICBpZiAoIUFycmF5LmlzQXJyYXkoanNvbi5zaXRlcykgfHwgIWpzb24uc2l0ZXMubGVuZ3RoKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBudWxsO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBzb3VyY2VMaXN0ID0gZmlsdGVyT3RoZXIoanNvbi5zaXRlcyk7XFxuICAgICAgICAgICAgY29uZmlnLnR5cGUgPSBcXFwiaW5kZXhcXFwiO1xcbiAgICAgICAgfVxcbiAgICAgICAgZmlsZSA9IHZvaWQgMDtcXG4gICAgICAgIGxldCBjdXJyZW50U291cmNlLCBzZWFyY2hBbGxvdztcXG4gICAgICAgIGlmIChjb25maWcuY0tleSkge1xcbiAgICAgICAgICAgIGN1cnJlbnRTb3VyY2UgPSBzb3VyY2VMaXN0LmZpbmQodiA9PiB2LmtleSA9PT0gY29uZmlnLmNLZXkpO1xcbiAgICAgICAgICAgIGlmICghY3VycmVudFNvdXJjZSkge1xcbiAgICAgICAgICAgICAgICBjdXJyZW50U291cmNlID0gc291cmNlTGlzdFswXTtcXG4gICAgICAgICAgICAgICAgLy9jdXJyZW50Q29uZmlnLmNLZXkgPSBzb3VyY2VMaXN0WzBdLmtleTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGN1cnJlbnRTb3VyY2UgPSBzb3VyY2VMaXN0WzBdO1xcbiAgICAgICAgICAgIC8vY29uZmlnLmNLZXkgPSBzb3VyY2VMaXN0WzBdLmtleTtcXG4gICAgICAgIH1cXG4gICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgc2VhcmNoQWxsb3cgPSBKU09OLnBhcnNlKGZldGNoKHNlYXJjaEFsbG93UGF0aCkgfHwgXFxcIltdXFxcIik7XFxuICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgZGVsZXRlRmlsZShzZWFyY2hBbGxvd1BhdGgpO1xcbiAgICAgICAgICAgIHNlYXJjaEFsbG93ID0gW107XFxuICAgICAgICB9XFxuICAgICAgICByZXR1cm4ge1xcbiAgICAgICAgICAgIGN1cnJlbnRTb3VyY2UsXFxuICAgICAgICAgICAgc2VhcmNoQWxsb3csXFxuICAgICAgICAgICAgc291cmNlTGlzdFxcbiAgICAgICAgfTtcXG4gICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgbG9nKGUudG9TdHJpbmcoKSk7XFxuICAgIH1cXG4gICAgcmV0dXJuIG51bGw7XFxufVxcblxcbmZ1bmN0aW9uIGdlbmVyYXRlQ29uZmlnQnlMb2NhbChkaXJGaWxlKSB7XFxuICAgIGxldCBsaXN0ID0gZGlyRmlsZS5saXN0RmlsZXMoKTtcXG4gICAgbGV0IHJ1bGVzID0gW107XFxuICAgIGZvciAobGV0IGl0IG9mIGxpc3QpIHtcXG4gICAgICAgIGxldCBuYW1lID0gU3RyaW5nKGl0LmdldE5hbWUoKSk7XFxuICAgICAgICBsZXQgcGF0aCA9IGl0LmdldFBhdGgoKTtcXG4gICAgICAgIGlmICghbmFtZS5lbmRzV2l0aChcXFwiLmpzXFxcIikgfHwgaXQuaXNEaXJlY3RvcnkoKSkgY29udGludWU7XFxuICAgICAgICBuYW1lID0gbmFtZS5zbGljZSgwLCBuYW1lLmxhc3RJbmRleE9mKFxcXCIuXFxcIikpO1xcbiAgICAgICAgcnVsZXMucHVzaCh7XFxuICAgICAgICAgICAgJ2tleSc6IGBoaXB5X2pzXyR7bmFtZX1gLFxcbiAgICAgICAgICAgICduYW1lJzogYCR7bmFtZX1gLFxcbiAgICAgICAgICAgICd0eXBlJzogMyxcXG4gICAgICAgICAgICAnc2VhcmNoYWJsZSc6IDEsXFxuICAgICAgICAgICAgJ3F1aWNrU2Vh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9oaWtlcmZhbnMuY29tL3R1Ymlhby9zeXN0ZW0vMjcucG5nXFxcIixcXG4gICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKCgpID0+IHtcXG4gICAgICAgIGNvbnN0IGhpa2VyUG9wID0gJC5yZXF1aXJlKFxcXCJodHRwOi8vaGlrZXIubm9raWEucHJlc3MvaGlrZXJ1bGUvcnVsZWxpc3QuanNvbj9pZD02OTY2XFxcIik7XFxuICAgICAgICBsZXQgcG9wID0gaGlrZXJQb3AuaW5mb0JvdHRvbSh7XFxuICAgICAgICAgICAgY29udGVudDogXFxcIuivpue7hlxcXCIsXFxuICAgICAgICAgICAgb3B0aW9uczogW1xcbiAgICAgICAgICAgICAgICBcXFwi56ys5LiA56m6KOWQjeensCk65pa55L6/5LiL5qyh5om+5YiwXFxcIixcXG4gICAgICAgICAgICAgICAgXFxcIuesrOS6jOepuijot6/lvoQpW+Whq+acrOWcsOe0ouW8leWcsOWdgF066YCJ5oupSlNPTi9VUkzpgInpobnvvIzngrnlh7vml4HovrnnmoTpgInmi6nlj6/ku6XmtY/op4jmnKzlnLDmlofku7bpgInmi6nmnKzlnLDljIXnmoQuanNvbue0ouW8leaWh+S7tuWNs+WPr+OAglxcXFxuKOazqOaEj++8muS9v+eUqOatpOenjeaWueW8j++8jOWcqOacrOWcsOaWh+S7tuWkueWGheaWsOWinuaIluWIoOmZpC5qc+a6kOaXtumcgOimgeiHquihjOWImuWImi5qc29u6YWN572u5paH5Lu2KVxcXCIsXFxuICAgICAgICAgICAgICAgIFxcXCLnrKzkuoznqboo6Lev5b6EKVvloavmnKzloavov5znqIvlnLDlnYBdOuebtOaOpeWhq+WGmei/nOeoi+mTvuaOpeWNs+WPr+S4gOiIrOaYr+S7pWh0dHDlvIDlpLQuanNvbue7k+Wwvu+8jOS5n+WPr+WPr+S7pei+k+WFpWdpdGh1YuS7k+W6k+eahOaWh+S7tuWkueWcsOWdgOOAguatpOenjeaWueW8j+WPr+S7peS/neaMgeS4jui/nOeoi+mFjee9ruiAheWQjOatpeabtOaWsO+8jOS9huS4jeWmguacrOWcsOW/q+OAglxcXCIsXFxuICAgICAgICAgICAgICAgIFxcXCLnrKzkuoznqboo6Lev5b6EKVvloavmnKzlnLDmlofku7blpLnlnLDlnYBdOumAieaLqeaWh+S7tuWkuemAiemhue+8jOWPr+S7peebtOaOpei+k+WFpWpz5rqQ5omA5ZyoI+aWh+S7tuWkuSEhISPnmoTot6/lvoTvvIzkuZ/lj6/ku6Xngrnlh7vml4HovrnpgInmi6nmtY/op4jmnKzlnLDot6/lvoTpgInmi6kj5paH5Lu25aS5ISEhI++8jOS9v+eUqOivpeenjeaWueazle+8jOWcqOaWh+S7tuWkueaWsOWinuaIluWIoOmZpOa6kOaXtu+8jOS4jeeUqOaJi+WKqOmFjee9ri5qc29u5paH5Lu277yM6Ieq5Yqo6K+75Y+W44CCKOazqOaEj++8mumcgOimgeWIt+aWsOmFjee9ruaIlumHjeWQr+i9r+S7tuaJjeiDveivu+WPlilcXFwiLFxcbiAgICAgICAgICAgICAgICBcXFwiW1EmQV3kuLrku4DkuYjorqLpmIXpk77mjqXmnInlvojlpJrmupDvvIzljbTlj6ror4bliKvliLDkuoblh6DkuKrmupDvvJ9cXFxcbuacrOWwj+eoi+W6j+WPquaUr+aMgemBk+mVv+eahGRycHlbanNd6KeG6aKR5rqQ77yM5YW25LuW5LiA5qaC5LiN5pSv5oyB44CC5Zug5q2k5Lya6Ieq5Yqo6L+H5ruk5YW25LuW5rqQXFxcIixcXG4gICAgICAgICAgICAgICAgXFxcIltRJkFd5omT566X5pSv5oyB5YW25LuWdHZib3jnmoTmupDlkJfvvJ/kuI3mlK/mjIHkuI3ogIPomZHjgILor7fnnIvlkI3lrZdEcnB5SGlrZXLvvIzlj6rmlK/mjIFkcnB577yM6KaB55So5YW25LuW5rqQ77yM5bu66K6u5Yig6Zmk5pys5bCP56iL5bqP77yM5Y6755So5ZCE56eN5aOz5a2Q44CCXFx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FwiKTtcXG4gICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICB9LCBpKSxcXG4gICAgICAgIGNvbF90eXBlOiAnc2Nyb2xsX2J1dHRvbicsXFxuICAgIH0pXFxufSlcXG5cXG5cXG5sZXQgcGF0aCA9IGpvaW5VcmwoZ2V0UGF0aChcXFwiaGlrZXI6Ly9maWxlcy9cXFwiKSwgXFxcIi4uL1xcXCIucmVwZWF0KDUpKS5zbGljZSg3KTtcXG5cXG5pZiAoc2VsZWN0X21vZGUgPT0gXFxcIjBcXFwiKSB7XFxuICAgIGxheW91dC5wdXNoKHtcXG4gICAgICAgIHRpdGxlOiBcXFwi6YCJ5oupXFxcIixcXG4gICAgICAgIHVybDogSlNPTi5zdHJpbmdpZnkoZi5maWxlU2VsZWN0aW9uVXJpKHtcXG4gICAgICAgICAgICBjYWxsYmFjazogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgICAgICAgIGxldCB0YXJnZXQgPSBmaW5kSXRlbShcXFwiZHJweUhpa2VyX2NvbmZpZ19wYXRoXFxcIikuZXh0cmE7XFxuICAgICAgICAgICAgICAgIHVwZGF0ZUl0ZW0oXFxcImRycHlIaWtlcl9jb25maWdfcGF0aFxcXCIsIHtcXG4gICAgICAgICAgICAgICAgICAgIGV4dHJhOiBPYmplY3QuYXNzaWduKHRhcmdldCwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHRWYWx1ZTogUEFUSFxcbiAgICAgICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIHJldHVybiB0cnVlO1xcbiAgICAgICAgICAgIH0pLFxcbiAgICAgICAgICAgIHJvb3REaXJQYXRoOiBwYXRoLFxcbiAgICAgICAgICAgIGluaXRpYWxQYXRoOiBwYXRoLFxcbiAgICAgICAgICAgIHBhdHRlcm46IDAsXFxuICAgICAgICAgICAgZmlsZVR5cGU6IFxcXCIuanNvblxcXCIsXFxuICAgICAgICB9KSksXFxuICAgICAgICBjb2xfdHlwZTogXFxcImlucHV0XFxcIixcXG4gICAgICAgIGRlc2M6IFxcXCLot6/lvoQoVVJML0pTT04vZ2l0aHViKVxcXCIsXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIGRlZmF1bHRWYWx1ZTogXFxcIlxcXCIsXFxuICAgICAgICAgICAgb25DaGFuZ2U6ICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICBwdXRNeVZhcihcXFwiZHJweUhpa2VyX2NvbmZpZ19wYXRoXFxcIiwgaW5wdXQpO1xcbiAgICAgICAgICAgIH0pLFxcbiAgICAgICAgICAgIGlkOiBcXFwiZHJweUhpa2VyX2NvbmZpZ19wYXRoXFxcIlxcbiAgICAgICAgfVxcbiAgICB9KTtcXG59XFxuaWYgKHNlbGVjdF9tb2RlID09IFxcXCIxXFxcIikge1xcbiAgICBsYXlvdXQucHVzaCh7XFxuICAgICAgICB0aXRsZTogXFxcIumAieaLqVxcXCIsXFxuICAgICAgICB1cmw6IEpTT04uc3RyaW5naWZ5KGYuZmlsZVNlbGVjdGlvblVyaSh7XFxuICAgICAgICAgICAgY2FsbGJhY2s6ICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICBsZXQgdGFyZ2V0ID0gZmluZEl0ZW0oXFxcImRycHlIaWtlcl9jb25maWdfZm9sZGVyXFxcIikuZXh0cmE7XFxuICAgICAgICAgICAgICAgIHVwZGF0ZUl0ZW0oXFxcImRycHlIaWtlcl9jb25maWdfZm9sZGVyXFxcIiwge1xcbiAgICAgICAgICAgICAgICAgICAgZXh0cmE6IE9iamVjdC5hc3NpZ24odGFyZ2V0LCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdFZhbHVlOiBQQVRIXFxuICAgICAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7XFxuICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgcm9vdERpclBhdGg6IHBhdGgsXFxuICAgICAgICAgICAgaW5pdGlhbFBhdGg6IHBhdGgsXFxuICAgICAgICAgICAgcGF0dGVybjogMSxcXG4gICAgICAgICAgICAvL2ZpbGVUeXBlOiBcXFwiLmpzb25cXFwiLFxcbiAgICAgICAgfSkpLFxcbiAgICAgICAgY29sX3R5cGU6IFxcXCJpbnB1dFxcXCIsXFxuICAgICAgICBkZXNjOiBcXFwi6Lev5b6EKOaWh+S7tuWkuSlcXFwiLFxcbiAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICBkZWZhdWx0VmFsdWU6IFxcXCJcXFwiLFxcbiAgICAgICAgICAgIG9uQ2hhbmdlOiAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICAgICAgICAgICAgcHV0TXlWYXIoXFxcImRycHlIaWtlcl9jb25maWdfcGF0aFxcXCIsIGlucHV0KTtcXG4gICAgICAgICAgICB9KSxcXG4gICAgICAgICAgICBpZDogXFxcImRycHlIaWtlcl9jb25maWdfZm9sZGVyXFxcIlxcbiAgICAgICAgfVxcbiAgICB9KTtcXG59XFxubGF5b3V0LnB1c2goe1xcbiAgICBjb2xfdHlwZTogXFxcImxpbmVfYmxhbmtcXFwiXFxufSk7XFxubGF5b3V0LnB1c2goe1xcbiAgICB0aXRsZTogXFxcIuehruiupFxcXCIsXFxuICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgoY29iaikgPT4ge1xcbiAgICAgICAgbGV0IHBhdGggPSBnZXRNeVZhcihcXFwiZHJweUhpa2VyX2NvbmZpZ19wYXRoXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgbGV0IG5hbWUgPSBnZXRNeVZhcihcXFwiZHJweUhpa2VyX2NvbmZpZ19uYW1lXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgaWYgKCEocGF0aCAmJiBuYW1lKSkge1xcbiAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/kuI3lj6/kuLrnqbpcXFwiO1xcbiAgICAgICAgfVxcbiAgICAgICAgcGF0aCA9IHBhdGguc3RhcnRzV2l0aChcXFwiaHR0cFxcXCIpID8gcGF0aCA6IHBhdGguc3RhcnRzV2l0aChcXFwiL1xcXCIpID8gKFxcXCJmaWxlOi8vXFxcIiArIHBhdGgpIDogcGF0aDtcXG4gICAgICAgIC8vbG9nKHBhdGgpXFxuICAgICAgICB0cnkge1xcbiAgICAgICAgICAgIGxldCBydW50aW1lQ29uZmlnID0gR00uZGVmaW5lTW9kdWxlKFxcXCJydW50aW1lQ29uZmlnXFxcIik7XFxuICAgICAgICAgICAgaWYgKHBhdGguc3RhcnRzV2l0aChcXFwiaHR0cFxcXCIpKSB7XFxuICAgICAgICAgICAgICAgIHNob3dMb2FkaW5nKFxcXCLmraPlnKjliqDovb3phY3nva4uLi5cXFwiKTtcXG4gICAgICAgICAgICB9XFxuXFxuICAgICAgICAgICAgaWYgKHJ1bnRpbWVDb25maWcuc2V0Q3VycmVudENvbmZpZyh7XFxuICAgICAgICAgICAgICAgICAgICBwYXRoLFxcbiAgICAgICAgICAgICAgICAgICAgbmFtZSxcXG4gICAgICAgICAgICAgICAgfSkpIHtcXG4gICAgICAgICAgICAgICAgY29iai5jb25maWdzLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgcGF0aCxcXG4gICAgICAgICAgICAgICAgICAgIG5hbWUsXFxuICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgIGNsZWFySXRlbShcXFwibm9fbG9hZGluZ1xcXCIpO1xcbiAgICAgICAgICAgICAgICBzYXZlRmlsZShjb2JqLnBhdGgsIEpTT04uc3RyaW5naWZ5KGNvYmouY29uZmlncykpO1xcbiAgICAgICAgICAgICAgICBiYWNrKGZhbHNlKTtcXG4gICAgICAgICAgICAgICAgbGV0IERycHlNYW5hZ2UgPSBHTS5kZWZpbmVNb2R1bGUoXFxcIkRycHlNYW5hZ2VcXFwiKTtcXG4gICAgICAgICAgICAgICAgRHJweU1hbmFnZS5jbGVhcigpO1xcbiAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcIkNoYW5nZVNvdXJjZVBvcFxcXCIpLnNob3coMTAwKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+iuvue9ruaIkOWKn1xcXCI7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/phY3nva7mlofku7bmnInor69cXFwiO1xcbiAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly9cXFwiICsgZS50b1N0cmluZygpO1xcbiAgICAgICAgfSBmaW5hbGx5IHtcXG4gICAgICAgICAgICBoaWRlTG9hZGluZygpO1xcbiAgICAgICAgfVxcbiAgICB9LCBjb25maWdzX29iaiksXFxuICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxufSk7XFxuXFxuaWYgKHBhdGhjb25maWdzLmxlbmd0aCkge1xcbiAgICBsYXlvdXQucHVzaCh7XFxuICAgICAgICB0aXRsZTogJ+KAnOKAnOKAneKAnScgKyBcXFwiPHNtYWxsPuWOhuWPsumFjee9ruiusOW9lSDngrnmiJHov5vooYzphY3nva7mo4Dpqow8L3NtYWxsPlxcXCIsXFxuICAgICAgICB1cmw6ICQoJyNub0xvYWRpbmcjJykubGF6eVJ1bGUoKHApID0+IHtcXG4gICAgICAgICAgICAvL2xvZyhwKVxcbiAgICAgICAgICAgIGZ1bmN0aW9uIHVuaXF1ZShhcnIpIHtcXG4gICAgICAgICAgICAgICAgY29uc3QgcmVzID0gbmV3IE1hcCgpO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gYXJyLmZpbHRlcigoYSkgPT4gIXJlcy5oYXMoYSkgJiYgcmVzLnNldChhLCAxKSlcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgdmFyIHJlc3VsdHMgPSBbXTtcXG4gICAgICAgICAgICBpZiAocC5sZW5ndGggPT0gMCkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5peg5Zyw5Z2AXFxcIjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGlzdCA9IHAubWFwKHggPT4geC5wYXRoKTtcXG4gICAgICAgICAgICB2YXIgdGFzayA9IGZ1bmN0aW9uKG9iaikge1xcbiAgICAgICAgICAgICAgICBsZXQgcyA9IERhdGUubm93KCk7XFxuICAgICAgICAgICAgICAgIGxldCBqc0ZpbGVzID0gW107XFxuICAgICAgICAgICAgICAgIGxldCBjb3VudCA9IDA7XFxuXFxuICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGZpbHRlck90aGVyKGxpc3QpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBsaXN0LmZpbHRlcihpdCA9PiBTdHJpbmcoaXQuYXBpKS5pbmNsdWRlcyhcXFwiZHJweTIubWluLmpzXFxcIikgfHwgU3RyaW5nKGl0LmFwaSkuaW5jbHVkZXMoXFxcImRycHkyLmpzXFxcIikpXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgaWYgKG9iai51cmwuc3RhcnRzV2l0aChcXFwiZmlsZTpcXFwiKSkge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IGNvZGUgPSBcXFwibm9cXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHBhdGggPSBvYmoudXJsLnJlcGxhY2UoXFxcImZpbGU6Ly9cXFwiLCBcXFwiXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgZGlyID0gbmV3IGphdmEuaW8uRmlsZShwYXRoKTtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChkaXIuaXNEaXJlY3RvcnkoKSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBmbGlzdCA9IGRpci5saXN0RmlsZXMoKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBmb3IgKHZhciBmIG9mIGZsaXN0KSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIOajgOafpeaWh+S7tuWQjeaYr+WQpuS7pS5qc+e7k+WwvlxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZi5pc0ZpbGUoKSAmJiBmLmdldE5hbWUoKS50b0xvd2VyQ2FzZSgpLmVuZHNXaXRoKFxcXCIuanNcXFwiKSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAganNGaWxlcy5wdXNoKGYpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgaWYgKGRpci5pc0ZpbGUoKSAmJiBmaWxlRXhpc3Qob2JqLnVybCkpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBqc29uID0gSlNPTi5wYXJzZShyZWFkRmlsZShvYmoudXJsKSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KGpzb24uc2l0ZXMpIHx8IGpzb24uc2l0ZXMubGVuZ3RoKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb3VudCA9IGZpbHRlck90aGVyKGpzb24uc2l0ZXMpLmxlbmd0aDtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHt9XFxuICAgICAgICAgICAgICAgICAgICAgICAgY29kZSA9IFxcXCJva1xcXCI7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICBpZiAoanNGaWxlcy5sZW5ndGggPj0gNSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvdW50ID0ganNGaWxlcy5sZW5ndGg7XFxuICAgICAgICAgICAgICAgICAgICAgICAgY29kZSA9IFxcXCJva1xcXCI7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHRpbWU6IChEYXRlLm5vdygpIC0gcyksXFxuICAgICAgICAgICAgICAgICAgICAgICAgdXJsOiBvYmoudXJsLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvdW50OiBjb3VudCxcXG4gICAgICAgICAgICAgICAgICAgICAgICBjb2RlOiBjb2RlLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGluZGV4OiBvYmouaVxcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIHZhciBqID0gSlNPTi5wYXJzZShmZXRjaChvYmoudXJsLCB7XFxuICAgICAgICAgICAgICAgICAgICB3aXRoSGVhZGVyczogdHJ1ZSxcXG4gICAgICAgICAgICAgICAgICAgIHRpbWVvdXQ6IDUwMDAsXFxuICAgICAgICAgICAgICAgIH0pKTtcXG4gICAgICAgICAgICAgICAgbGV0IGUgPSBEYXRlLm5vdygpO1xcbiAgICAgICAgICAgICAgICBsZXQgYyA9IGUgLSBzO1xcbiAgICAgICAgICAgICAgICBpZiAob2JqLnVybC5pbmNsdWRlcyhcXFwiZ2l0aHViLmNvbVxcXCIpICYmIGouc3RhdHVzQ29kZSA9PSAyMDApIHtcXG4gICAgICAgICAgICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGh0bWwgPSBqLmJvZHk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGpzb24gPSBKU09OLnBhcnNlKHBkZmgoaHRtbCwgXFxcIiNyZXBvLWNvbnRlbnQtcGpheC1jb250YWluZXImJnNjcmlwdCYmSHRtbFxcXCIpKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgbGlzdCA9IGpzb24ucGF5bG9hZC50cmVlLml0ZW1zO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvdW50ID0gbGlzdC5maWx0ZXIoeCA9PiB4Lm5hbWUuZW5kc1dpdGgoXFxcIi5qc1xcXCIpKS5sZW5ndGg7XFxuICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIHt9XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBqc29uID0gSlNPTi5wYXJzZSh0b0NvcnJlY3RKU09OU3RyaW5nKGouYm9keSkgfHwgXFxcInt9XFxcIik7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShqc29uLnNpdGVzKSB8fCBqc29uLnNpdGVzLmxlbmd0aCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvdW50ID0gZmlsdGVyT3RoZXIoanNvbi5zaXRlcykubGVuZ3RoO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7fVxcblxcbiAgICAgICAgICAgICAgICByZXR1cm4ge1xcbiAgICAgICAgICAgICAgICAgICAgdGltZTogYyxcXG4gICAgICAgICAgICAgICAgICAgIHVybDogai51cmwsXFxuICAgICAgICAgICAgICAgICAgICBjb3VudDogY291bnQsXFxuICAgICAgICAgICAgICAgICAgICBjb2RlOiBqLnN0YXR1c0NvZGUsXFxuICAgICAgICAgICAgICAgICAgICBpbmRleDogb2JqLmksXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9O1xcbiAgICAgICAgICAgIGxldCB0YXNrcyA9IGxpc3QubWFwKCh4LCBpKSA9PiB7XFxuICAgICAgICAgICAgICAgIGkgPSBpICsgMTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIHtcXG4gICAgICAgICAgICAgICAgICAgIGZ1bmM6IHRhc2ssXFxuICAgICAgICAgICAgICAgICAgICBwYXJhbToge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHVybDogeCxcXG4gICAgICAgICAgICAgICAgICAgICAgICBpOiBpIC0gMSxcXG4gICAgICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgICAgICBpZDogJ3Rhc2tpZCcgKyBpXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB2YXIgY291bnQgPSBzdWNjZXNzID0gdGFza3MubGVuZ3RoO1xcbiAgICAgICAgICAgIGJlKHRhc2tzLCB7XFxuICAgICAgICAgICAgICAgIGZ1bmM6IGZ1bmN0aW9uKG9iaiwgaWQsIGVycm9yLCB0YXNrUmVzdWx0KSB7XFxuICAgICAgICAgICAgICAgICAgICBvYmoucmVzdWx0cy5wdXNoKHRhc2tSZXN1bHQpXFxuICAgICAgICAgICAgICAgICAgICBjb3VudCA9IGNvdW50IC0gMTtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChjb3VudCA+IDApIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBzaG93TG9hZGluZyhcXFwi5qOA5rWL5LitLi4u5Ymp5L2Z5Zyw5Z2A77yaXFxcIiArIGNvdW50KVxcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBoaWRlTG9hZGluZygpO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICBwYXJhbToge1xcbiAgICAgICAgICAgICAgICAgICAgaGk6ICdjY2MnLFxcbiAgICAgICAgICAgICAgICAgICAgcmVzdWx0czogcmVzdWx0c1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSwgc3VjY2Vzcyk7XFxuICAgICAgICAgICAgLy9sb2cocmVzdWx0cylcXG4gICAgICAgICAgICByZXN1bHRzID0gcmVzdWx0cy5maWx0ZXIoZiA9PiBmKTtcXG4gICAgICAgICAgICByZXN1bHRzLmZvckVhY2goKHgsIGkpID0+IHtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ZW0gPSBmaW5kSXRlbShcXFwicGF0aFxcXCIgKyB4LmluZGV4KTtcXG4gICAgICAgICAgICAgICAgbGV0IHJlZ2V4ID0gLyjlkI3np7A6Lio/KShcXFxccyspP1xcXFxuL2c7XFxuICAgICAgICAgICAgICAgIGxldCB0aXRsZSA9IFxcXCLlkI3np7A6XFxcIiArIHBbeC5pbmRleF0ubmFtZSArIFxcXCIgXFxcIjtcXG4gICAgICAgICAgICAgICAgbGV0IHVybCA9IHBbeC5pbmRleF0ucGF0aDtcXG4gICAgICAgICAgICAgICAgbGV0IG1zZyA9IFxcXCJcXFwiO1xcbiAgICAgICAgICAgICAgICBsZXQgY291bnQgPSB4LmNvdW50ICE9IDAgPyBcXFwiIOa6kOaVsOmHjzpcXFwiICsgeC5jb3VudCA6IFxcXCJcXFwiO1xcbiAgICAgICAgICAgICAgICBpZiAoL25vLy50ZXN0KHguY29kZSkpIHtcXG4gICAgICAgICAgICAgICAgICAgIG1zZyA9IGl0ZW0udGl0bGUucmVwbGFjZShyZWdleCwgdGl0bGUgKyBcXFwi6YWN572u5pyJ6K+vXFxcIi5mb250Y29sb3IoXFxcInJlZFxcXCIpICsgXFxcIlxcXFxuXFxcIik7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoL14oLTF8MHw0MDQpLy50ZXN0KHguY29kZSkpIHtcXG4gICAgICAgICAgICAgICAgICAgIG1zZyA9IGl0ZW0udGl0bGUucmVwbGFjZShyZWdleCwgdGl0bGUgKyBcXFwi5peg5rOV6K6/6ZeuXFxcIi5mb250Y29sb3IoXFxcInJlZFxcXCIpICsgXFxcIlxcXFxuXFxcIik7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoL14yMDAvLnRlc3QoeC5jb2RlKSkge1xcbiAgICAgICAgICAgICAgICAgICAgbXNnID0gaXRlbS50aXRsZS5yZXBsYWNlKHJlZ2V4LCB0aXRsZSArIFxcXCLpgJrorq/mraPluLhcXFwiLmZvbnRjb2xvcihcXFwiIzNDQjM3MVxcXCIpICsgXFxcIiAg5bu26L+fOlxcXCIgKyB4LnRpbWUgKyBjb3VudCArIFxcXCJcXFxcblxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgLy91cmwgPSBpdGVtLnVybDtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIG1zZyA9IGl0ZW0udGl0bGUucmVwbGFjZShyZWdleCwgdGl0bGUgKyBcXFwi6YWN572u5q2j56GuXFxcIi5mb250Y29sb3IoXFxcIiMzQ0IzNzFcXFwiKSArIGNvdW50ICsgXFxcIlxcXFxuXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAvL3VybCA9IGl0ZW0udXJsO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIHVwZGF0ZUl0ZW0oaXRlbS5leHRyYS5pZCwge1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IG1zZyxcXG4gICAgICAgICAgICAgICAgICAgIC8vdXJsOiB1cmwsXFxuICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIlxcbiAgICAgICAgfSwgcGF0aGNvbmZpZ3MpLFxcbiAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIlxcbiAgICB9KVxcbiAgICBwYXRoY29uZmlncy5mb3JFYWNoKChpdGVtLCBpKSA9PiB7XFxuICAgICAgICBsZXQgbG9uZ0MgPSBbe1xcbiAgICAgICAgICAgIHRpdGxlOiBcXFwi5ZCN56ewXFxcIixcXG4gICAgICAgICAgICBqczogJC50b1N0cmluZygoaXRlbSwgcCwgYykgPT4ge1xcbiAgICAgICAgICAgICAgICBsZXQgaSA9IGMuZmluZEluZGV4KHggPT4geC5uYW1lID09IGl0ZW0ubmFtZSk7XFxuICAgICAgICAgICAgICAgIGlmIChpICE9IC0xKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gJChjW2ldLm5hbWUsIFxcXCLovpPlhaXmlrDlkI3np7BcXFwiKS5pbnB1dCgoYywgcCwgaSkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNbaV0ubmFtZSA9IGlucHV0O1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHNhdmVGaWxlKHAsIEpTT04uc3RyaW5naWZ5KGMpKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgICAgICAgICAgfSwgYywgcCwgaSlcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0sIGl0ZW0sIGNwYXRoLCBwYXRoY29uZmlncylcXG4gICAgICAgIH0sIHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIui3r+W+hFxcXCIsXFxuICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKGl0ZW0sIHAsIGMpID0+IHtcXG4gICAgICAgICAgICAgICAgbGV0IGkgPSBjLmZpbmRJbmRleCh4ID0+IHgubmFtZSA9PSBpdGVtLm5hbWUpO1xcbiAgICAgICAgICAgICAgICBpZiAoaSAhPSAtMSkge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuICQoY1tpXS5wYXRoLCBcXFwi6L6T5YWl5paw6Lev5b6EXFxcIikuaW5wdXQoKGMsIHAsIGkpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjW2ldLnBhdGggPSBpbnB1dDtcXG4gICAgICAgICAgICAgICAgICAgICAgICBzYXZlRmlsZShwLCBKU09OLnN0cmluZ2lmeShjKSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICAgICAgICAgIH0sIGMsIHAsIGkpXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9LCBpdGVtLCBjcGF0aCwgcGF0aGNvbmZpZ3MpXFxuICAgICAgICB9LCB7XFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLliKDpmaRcXFwiLFxcbiAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKChpdGVtLCBwLCBjKSA9PiB7XFxuICAgICAgICAgICAgICAgIGxldCBpID0gYy5maW5kSW5kZXgoeCA9PiB4Lm5hbWUgPT0gaXRlbS5uYW1lKTtcXG4gICAgICAgICAgICAgICAgaWYgKGkgIT0gLTEpIHtcXG4gICAgICAgICAgICAgICAgICAgIGMuc3BsaWNlKGksIDEpO1xcbiAgICAgICAgICAgICAgICAgICAgc2F2ZUZpbGUocCwgSlNPTi5zdHJpbmdpZnkoYykpO1xcbiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0sIGl0ZW0sIGNwYXRoLCBwYXRoY29uZmlncylcXG4gICAgICAgIH1dXFxuICAgICAgICBpZiAoaXRlbS5wYXRoLnN0YXJ0c1dpdGgoXFxcImh0dHBcXFwiKSkge1xcbiAgICAgICAgICAgIGxvbmdDLnB1c2goe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuiuv+mXrlxcXCIsXFxuICAgICAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKChpdGVtKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoaXRlbS5wYXRoLnN0YXJ0c1dpdGgoXFxcImh0dHBcXFwiKSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwid2ViOi8vXFxcIiArIGl0ZW0ucGF0aDtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfSwgaXRlbSlcXG4gICAgICAgICAgICB9KVxcbiAgICAgICAgfVxcbiAgICAgICAgbGV0IGN1cnJlbnQgPSBcXFwiXFxcIjtcXG4gICAgICAgIGlmIChjdXJyZW50Y29uZmlnICYmIGN1cnJlbnRjb25maWcuaGFzT3duUHJvcGVydHkoXFxcInBhdGhcXFwiKSkge1xcbiAgICAgICAgICAgIGlmIChpdGVtLnBhdGggPT0gY3VycmVudGNvbmZpZy5wYXRoKSB7XFxuICAgICAgICAgICAgICAgIGN1cnJlbnQgPSBcXFwi4p6h77iPXFxcIjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgICAgICBsYXlvdXQucHVzaCh7XFxuICAgICAgICAgICAgdGl0bGU6ICfigJzigJzigJ3igJ0nICsgXFxcIjxzbWFsbD5cXFwiICsgY3VycmVudCArIFxcXCLlkI3np7A6XFxcIiArIGl0ZW0ubmFtZSArIFxcXCJcXFxcbui3r+W+hDpcXFwiICsgaXRlbS5wYXRoICsgXFxcIjwvc21hbGw+XFxcIixcXG4gICAgICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoaXRlbSA9PiB7XFxuICAgICAgICAgICAgICAgIGNsZWFySXRlbShcXFwibm9fbG9hZGluZ1xcXCIpO1xcbiAgICAgICAgICAgICAgICBsZXQgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcXFwicnVudGltZUNvbmZpZ1xcXCIpO1xcbiAgICAgICAgICAgICAgICBsZXQge1xcbiAgICAgICAgICAgICAgICAgICAgcGF0aCxcXG4gICAgICAgICAgICAgICAgICAgIG5hbWVcXG4gICAgICAgICAgICAgICAgfSA9IGl0ZW07XFxuICAgICAgICAgICAgICAgIGlmIChwYXRoLnN0YXJ0c1dpdGgoXFxcImh0dHBcXFwiKSkge1xcbiAgICAgICAgICAgICAgICAgICAgc2hvd0xvYWRpbmcoXFxcIuato+WcqOWKoOi9vemFjee9ri4uLlxcXCIpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGlmIChydW50aW1lQ29uZmlnLnNldEN1cnJlbnRDb25maWcoe1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHBhdGgsXFxuICAgICAgICAgICAgICAgICAgICAgICAgbmFtZSxcXG4gICAgICAgICAgICAgICAgICAgIH0pKSB7XFxuICAgICAgICAgICAgICAgICAgICBiYWNrKGZhbHNlKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBEcnB5TWFuYWdlID0gR00uZGVmaW5lTW9kdWxlKFxcXCJEcnB5TWFuYWdlXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICBEcnB5TWFuYWdlLmNsZWFyKCk7XFxuICAgICAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcIkNoYW5nZVNvdXJjZVBvcFxcXCIpLnNob3coMTAwKTtcXG4gICAgICAgICAgICAgICAgICAgIGhpZGVMb2FkaW5nKCk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgaGlkZUxvYWRpbmcoKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/liIfmjaLlpLHotKVcXFwiO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSwgaXRlbSksXFxuICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0XzFcXFwiLFxcbiAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgIGlkOiAncGF0aCcgKyBpLFxcbiAgICAgICAgICAgICAgICBsb25nQ2xpY2s6IGxvbmdDXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSlcXG4gICAgfSlcXG59XFxuXFxuXFxuc2V0UmVzdWx0KGxheW91dCk7XCJ9LHtcImNvbF90eXBlXCI6XCJtb3ZpZV8zXCIsXCJuYW1lXCI6XCLmjaLmupDlvLnnqpdcIixcInBhdGhcIjpcIkNoYW5nZVNvdXJjZVBvcFwiLFwicnV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uICAgICAgICBtYW5hZ2UubGlzdC5sZW5ndGggPSAwO1xcbiAgICAgICAgZmxpc3QuZm9yRWFjaCh4ID0+IHtcXG4gICAgICAgICAgbWFuYWdlLmxpc3QucHVzaCh4KTtcXG4gICAgICAgIH0pO1xcbiAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcbiAgICAgIH0sXFxuICAgICAgZGVmYXVsdFZhbHVlOiBcXFwiXFxcIixcXG4gICAgICBjbGljayhzLCBtYW5hZ2UpIHtcXG4gICAgICAgIC8vdG9hc3Qocyk7XFxuICAgICAgICAvL2xvZyhtYW5hZ2UubGlzdCk7XFxuICAgICAgfSxcXG4gICAgICB0aXRsZVZpc2libGU6IGZhbHNlXFxuICAgIH0pLCBcXG4gICAgbG9uZ0NsaWNrKHMsIGkpIHtcXG4gICAgICAgICAgICBzaG93U2VsZWN0T3B0aW9ucyh7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi5YiG5Lqr6KeG6aKR5rqQXFxcIixcXG4gICAgICAgICAgICAgICAgb3B0aW9uczogW1xcXCJKU+aWh+S7tuWIhuS6q1xcXCJdLmNvbmNhdChnZXRQYXN0ZXMoKSksXFxuICAgICAgICAgICAgICAgIGNvbDogMixcXG4gICAgICAgICAgICAgICAganM6ICQudG9TdHJpbmcobmFtZSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBjb25zdCBydW50aW1lQ29uZmlnID0gR00uZGVmaW5lTW9kdWxlKFxcXCJydW50aW1lQ29uZmlnXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgc291cmNlcyA9IHJ1bnRpbWVDb25maWcuZ2V0QWxsU291cmNlKCk7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgc291cmNlID0gc291cmNlcy5maW5kKHYgPT4gdi5uYW1lID09IG5hbWUpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHBhdGggPSBydW50aW1lQ29uZmlnLmdldEFic29sdXRlUGF0aChzb3VyY2UuZXh0KTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBwbmFtZSA9IHBhdGguc3BsaXQoXFxcIi9cXFwiKS5hdCgtMSk7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZSA9IGZldGNoKHBhdGgpO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFydWxlKSByZXR1cm4gXFxcInRvYXN0Oi8v6I635Y+W5aSx6LSlXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChNWV9JTkRFWCA9PT0gMCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRlRmlsZShcXFwiaGlrZXI6Ly9maWxlcy9fY2FjaGUvXFxcIiArIHBuYW1lLCBmZXRjaChwYXRoKSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJzaGFyZTovL2hpa2VyOi8vZmlsZXMvX2NhY2hlL1xcXCIgKyBwbmFtZTtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHVybCA9IHNoYXJlUGFzdGUoYmFzZTY0RW5jb2RlKHJ1bGUpLCBpbnB1dCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJjb3B5Oi8v5rW36ZiU6KeG55WM77yMRFJQWeinhumikea6kOOAjFxcXCIgKyBuYW1lICsgXFxcIuOAjeWkjeWItuaVtOadoeWPo+S7pOaJk+W8gOi9r+S7tuWwseS8muiHquWKqOWvvOWFpSRcXFwiICsgdXJsICsgXFxcIiRcXFwiICsgcG5hbWUgKyBcXFwiQGltcG9ydD1qczokLnJlcXVpcmUoJ2ltcG9ydD9ydWxlPScrXFxcIiArIEpTT04uc3RyaW5naWZ5KE1ZX1JVTEUudGl0bGUpICsgXFxcIikoaW5wdXQsIHRydWUpXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfSwgcy5yZXBsYWNlKC9b4oCZ4oCYXS9nLCBcXF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gICAgICAgICAgICAgIG5vQXV0b1NvZnQ6IGZhbHNlLFxcbiAgICAgICAgICAgICAgLy9oaWRlQ2FuY2VsOiB0cnVlLFxcbiAgICAgICAgICAgICAgY29uZmlybSh0ZXh0KSB7XFxuICAgICAgICAgICAgICAgIGxldCBydW50aW1lQ29uZmlnID0gR00uZGVmaW5lTW9kdWxlKFxcXCJydW50aW1lQ29uZmlnXFxcIiwgXFxcInJ1bnRpbWVDb25maWdcXFwiKTtcXG4gICAgICAgICAgICAgICAgc2VhcmNoS2V5ID0gdGV4dDtcXG4gICAgICAgICAgICAgICAgbGV0IGxpc3QgPSBydW50aW1lQ29uZmlnLmdldEFsbFNvdXJjZSgpLm1hcCh4ID0+IHgubmFtZSk7XFxuICAgICAgICAgICAgICAgIGxldCBmbGlzdCA9IGxpc3QuZmlsdGVyKHggPT4geC5pbmNsdWRlcyh0ZXh0KSk7XFxuICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0Lmxlbmd0aCA9IDA7XFxuICAgICAgICAgICAgICAgIGZsaXN0LmZvckVhY2goeCA9PiB7XFxuICAgICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QucHVzaCh4KTtcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgICAgICAgLy9yZXR1cm4gXFxcInRvYXN0Oi8v6L6T5YWl5LqGXFxcIiArIHRleHQ7XFxuICAgICAgICAgICAgICB9LFxcblxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICB9IGVsc2UgaWYgKGkgPT09IDIpIHtcXG4gICAgICAgICAgICBsZXQgbGlzdCA9IE9iamVjdC5hc3NpZ24oW10sIG1hbmFnZS5saXN0KTtcXG4gICAgICAgICAgICBsZXQgbmF0dXJhbCA9IGdldEl0ZW0oXFxcIm5hdHVyYWxcXFwiLCBcXFwiXFxcIik7XFxuICAgICAgICAgICAgaWYgKG5hdHVyYWwgPT0gXFxcIlxcXCIpIHtcXG4gICAgICAgICAgICAgIG1hbmFnZS5saXN0Lmxlbmd0aCA9IDA7XFxuICAgICAgICAgICAgICBsaXN0LnNvcnQobmF0dXJhbFNvcnQpLmZvckVhY2goeCA9PiB7XFxuICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnB1c2goeCk7XFxuICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgbWFuYWdlLmxpc3QubGVuZ3RoID0gMDtcXG4gICAgICAgICAgICAgIHNuYW1lLmZvckVhY2goeCA9PiB7XFxuICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnB1c2goeCk7XFxuICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgICAgc2V0SXRlbShcXFwibmF0dXJhbFxcXCIsIG5hdHVyYWwgPyBcXFwiXFxcIiA6IFxcXCIxXFxcIik7XFxuICAgICAgICAgIH0gZWxzZSBpZiAoaSA9PSAzKSB7XFxuICAgICAgICAgICAgbWFuYWdlLmxpc3QucmV2ZXJzZSgpO1xcbiAgICAgICAgICAgIG5hbWVzLnJldmVyc2UoKTtcXG4gICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgZnVuY3Rpb24gYXJyYXlEaWZmZXJlbmNlKGFycjEsIGFycjIpIHtcXG4gICAgICAgICAgICAgIGNvbnN0IG1hcCA9IG5ldyBNYXAoYXJyMi5tYXAoaXRlbSA9PiBbaXRlbS5rZXksIGl0ZW1dKSk7XFxuICAgICAgICAgICAgICByZXR1cm4gYXJyMS5maWx0ZXIoaXRlbSA9PiAhbWFwLmhhcyhpdGVtLmtleSkpO1xcbiAgICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgICBsZXQgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcXFwicnVudGltZUNvbmZpZ1xcXCIsIFxcXCJydW50aW1lQ29uZmlnXFxcIik7XFxuICAgICAgICAgICAgbGV0IGxpc3QgPSBydW50aW1lQ29uZmlnLmdldEFsbFNvdXJjZSgpO1xcbiAgICAgICAgICAgIGxldCBDa2V5ID0gcnVudGltZUNvbmZpZy5nZXRDdXJyZW50U291cmNlKCkua2V5O1xcbiAgICAgICAgICAgIC8vbG9nKENrZXkpXFxuICAgICAgICAgICAgbGV0IGNmZyA9IHJ1bnRpbWVDb25maWcuZ2V0Q3VycmVudENvbmZpZygpXFxuICAgICAgICAgICAgbGV0IHtcXG4gICAgICAgICAgICAgIHBhdGgsXFxuICAgICAgICAgICAgICBuYW1lXFxuICAgICAgICAgICAgfSA9IGNmZztcXG4gICAgICAgICAgICBydW50aW1lQ29uZmlnLnNldEN1cnJlbnRDb25maWcoe1xcbiAgICAgICAgICAgICAgcGF0aCxcXG4gICAgICAgICAgICAgIG5hbWUsXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgcnVudGltZUNvbmZpZy5zZXRDdXJyZW50U291cmNlKENrZXkpO1xcbiAgICAgICAgICAgIGxldCBuc291cmNlcyA9IHJ1bnRpbWVDb25maWcuZ2V0QWxsU291cmNlKCk7XFxuXFxuICAgICAgICAgICAgbGV0IGFsaXN0ID0gYXJyYXlEaWZmZXJlbmNlKG5zb3VyY2VzLCBsaXN0KTtcXG4gICAgICAgICAgICBsZXQgZGxpc3QgPSBhcnJheURpZmZlcmVuY2UobGlzdCwgbnNvdXJjZXMpO1xcblxcbiAgICAgICAgICAgIGlmIChhbGlzdC5sZW5ndGggPiAwIHx8IGRsaXN0Lmxlbmd0aCA+IDApIHtcXG4gICAgICAgICAgICAgIGxldCBtc2cgPSBcXFwiXFxcIjtcXG4gICAgICAgICAgICAgIGlmIChhbGlzdC5sZW5ndGggPiAwKSB7XFxuICAgICAgICAgICAgICAgIGFsaXN0LmZvckVhY2goeCA9PiB7XFxuICAgICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QucHVzaCh4Lm5hbWUpO1xcbiAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgICBsb2coXFxcIuaWsOWinjpcXFwiICsgYWxpc3QubWFwKGsgPT4gay5uYW1lKS5qb2luKFxcXCIsXFxcIikpXFxuICAgICAgICAgICAgICAgIG1zZyArPSBcXFwi5paw5aKeXFxcIiArIGFsaXN0Lmxlbmd0aCArIFxcXCLkuKrmupBcXFwiO1xcbiAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgaWYgKGRsaXN0Lmxlbmd0aCA+IDApIHtcXG4gICAgICAgICAgICAgICAgZGxpc3QuZm9yRWFjaCh4ID0+IHtcXG4gICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5zcGxpY2UobWFuYWdlLmxpc3QuaW5kZXhPZih4Lm5hbWUpLCAxKTtcXG4gICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgbG9nKFxcXCLnp7vpmaQ6XFxcIiArIGRsaXN0Lm1hcChrID0+IGsubmFtZSkuam9pbihcXFwiLFxcXCIpKVxcbiAgICAgICAgICAgICAgICBtc2cgKz0gXFxcIiDnp7vpmaRcXFwiICsgZGxpc3QubGVuZ3RoICsgXFxcIuS4qua6kFxcXCI7XFxuICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgICAgICB0b2FzdChtc2cgKyBcXFwiIOabtOWkmuivpuaDheeci2xvZ1xcXCIpO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICB0b2FzdChcXFwi5bey5Yi35pawXFxcIik7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICB9XFxuICAgICAgICB9LFxcbiAgICAgIH0pO1xcbiAgICB9XFxuICB9KTtcXG59XCJ9LHtcImNvbF90eXBlXCI6XCJtb3ZpZV8zXCIsXCJuYW1lXCI6XCJkcnB5566h55CGXCIsXCJwYXR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ICAgICAgICAgICAgaWYgKGRycHkuZ2V0UnVsZShcXFwicHJveHlfcnVsZVxcXCIpKSB7XFxuICAgICAgICAgICAgICAgIGxldCBQcm94eSA9ICQucmVxdWlyZShcXFwiTG9jYWxQcm94eVxcXCIpO1xcbiAgICAgICAgICAgICAgICBsZXQgcHJveHlVcmwgPSBQcm94eS5zdGFydFByb3h5KE1ZX1JVTEUudGl0bGUsIEdNLmdldFNlbGZLZXkoKSk7XFxuICAgICAgICAgICAgICAgIHB1dE15VmFyKFxcXCJQcm94eV9VcmxcXFwiLCBwcm94eVVybCk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSBjYXRjaCAoZSkge1xcblxcbiAgICAgICAgfVxcbiAgICAgICAgcmV0dXJuIGRycHk7XFxuICAgIH0sIHRoaXMpLmNhbGwoKTtcXG59XFxuLy9zb3VyY2UuZXh05b+F6aG75Li657ud5a+56Lev5b6EXFxuZnVuY3Rpb24gZ2V0QnlTb3VyY2Uoc291cmNlKSB7XFxuICAgIHJldHVybiBzeW5jKCgpID0+IHtcXG4gICAgICAgIGxldCBrZXkgPSBzb3VyY2Uua2V5O1xcbiAgICAgICAgLy9sb2coZHJweU1hcC5zaXplKVxcbiAgICAgICAgaWYgKGRycHlNYXAuaGFzKGtleSkpIHtcXG4gICAgICAgICAgICByZXR1cm4gZHJweU1hcC5nZXQoa2V5KTtcXG4gICAgICAgIH1cXG4gICAgICAgIGlmIChkcnB5TWFwLnNpemUgPj0gNSkge1xcbiAgICAgICAgICAgIC8vbG9nKFxcXCLor7fmsYI6XFxcIiArIGtleSlcXG4gICAgICAgICAgICBkZWwoQXJyYXkuZnJvbShkcnB5TWFwLmtleXMoKSkuYXQoMCkpO1xcbiAgICAgICAgfVxcbiAgICAgICAgY3JlYXRlRHJweShrZXkpO1xcbiAgICAgICAgbGV0IGRycHkgPSBkcnB5TWFwLmdldChrZXkpO1xcbiAgICAgICAgZHJweS5pbml0KHNvdXJjZS5leHQpO1xcbiAgICAgICAgcmV0dXJuIGRycHk7XFxuICAgIH0sIHRoaXMpLmNhbGwoKTtcXG59XFxuXFxuZnVuY3Rpb24gcHV0KGtleSwgZHJweSkge1xcbiAgICBzeW5jKCgpID0+IGRycHlNYXAuc2V0KGtleSwgZHJweSksIHRoaXMpLmNhbGwoKTtcXG59XFxuXFxuZnVuY3Rpb24gcnVuUHJveHkoZHJweSwgYXJncykge1xcbiAgICBpZiAodHlwZW9mIGRycHkucHJveHkgPT09IFxcXCJmdW5jdGlvblxcXCIpIHtcXG4gICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgLy9sZXQgdGltZTEgPSBEYXRlLm5vdygpO1xcbiAgICAgICAgICAgIHByb3h5U2VtYXBob3JlLmFjcXVpcmUoKTtcXG4gICAgICAgICAgICAvL2xldCB0aW1lMiA9IERhdGUubm93KCk7XFxuICAgICAgICAgICAgLy9sb2coXFxcIjHnrYnlvoXml7bpl7Q6XFxcIiArICh0aW1lMiAtIHRpbWUxKSArIFxcXCJtc1xcXCIpO1xcbiAgICAgICAgICAgIGxldCByZXMgPSBkcnB5LnByb3h5LmFwcGx5KGRycHksIGFyZ3MpO1xcbiAgICAgICAgICAgIC8vbGV0IHRpbWUzID0gRGF0ZS5ub3coKTtcXG4gICAgICAgICAgICAvL2xvZyhcXFwiMuaJp+ihjOS7o+eQhuiAl+aXtjpcXFwiICsgKHRpbWUzIC0gdGltZTIpICsgXFxcIm1zXFxcIik7XFxuICAgICAgICAgICAgLy9sb2coXFxcIjPmgLvogJfml7bogJfml7Y6XFxcIiArICh0aW1lMyAtIHRpbWUxKSArIFxcXCJtc1xcXCIpO1xcblxcbiAgICAgICAgICAgIHJldHVybiByZXM7XFxuICAgICAgICB9IGZpbmFsbHkge1xcbiAgICAgICAgICAgIHByb3h5U2VtYXBob3JlLnJlbGVhc2UoKTtcXG4gICAgICAgIH1cXG4gICAgfVxcbn1cXG5cXG5mdW5jdGlvbiBkZWwoa2V5KSB7XFxuICAgIHN5bmMoKCkgPT4ge1xcbiA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ieq54S25o6S5bqPXFxcIiwgXFxcIuWAkuW6j1xcXCIsIFxcXCLlhajpgIlcXFwiLCBcXFwi5Y+N6YCJXFxcIl0sXFxuICAgICAgICBjb2x1bW5zOiAyLFxcbiAgICAgICAgdGl0bGU6IFxcXCLor7fpgInmi6lcXFwiLFxcbiAgICAgICAgY2xpY2socywgaSkge1xcbiAgICAgICAgICBpZiAoaSA9PT0gMCkge1xcbiAgICAgICAgICAgIHNwZW4gPSBzcGVuID09IDMgPyAxIDogMztcXG4gICAgICAgICAgICBtYW5hZ2UuY2hhbmdlQ29sdW1ucyhzcGVuKTtcXG4gICAgICAgICAgfSBlbHNlIGlmIChpID09PSAxKSB7XFxuICAgICAgICAgICAgaGlrZXJQb3AuaW5wdXRDb25maXJtKHtcXG4gICAgICAgICAgICAgIGNvbnRlbnQ6IFxcXCLovpPlhaXlhbPplK7lrZcg56m65pi+56S65YWo6YOoXFxcIixcXG4gICAgICAgICAgICAgIHRpdGxlOiBcXFwi562b6YCJ5rqQXFxcIixcXG4gICAgICAgICAgICAgIGhpbnQ6IFxcXCLmupDlhbPplK7lrZcg5aSa5Liq55SofOmalOW8gFxcXCIsXFxuICAgICAgICAgICAgICBkZWZhdWx0VmFsdWU6IHNlYXJjaEtleSxcXG4gICAgICAgICAgICAgIHRleHRhcmVhOiBmYWxzZSwgLy/lpJrooYzmqKHlvI9cXG4gICAgICAgICAgICAgIG1heFRleHRhcmVhOiB0cnVlLFxcbiAgICAgICAgICAgICAgbm9BdXRvU29mdDogZmFsc2UsXFxuICAgICAgICAgICAgICAvL2hpZGVDYW5jZWw6IHRydWUsXFxuICAgICAgICAgICAgICBjb25maXJtKHRleHQpIHtcXG4gICAgICAgICAgICAgICAgc2VhcmNoS2V5ID0gdGV4dDtcXG4gICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QubGVuZ3RoID0gMDtcXG4gICAgICAgICAgICAgICAgZHluYW1pY1NvdXJjZS5sZW5ndGggPSAwO1xcbiAgICAgICAgICAgICAgICBpZiAodGV4dCkge1xcbiAgICAgICAgICAgICAgICAgIGNhblNlYXJjaFNvdXJjZS5mb3JFYWNoKCh2LCBpKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBpZiAodGV4dC5zcGxpdCgvXFxcXHwvKS5maWx0ZXIoZiA9PiBmKS5zb21lKHggPT4gdi5uYW1lLmluY2x1ZGVzKHgpKSkge1xcbiAgICAgICAgICAgICAgICAgICAgICBkeW5hbWljU291cmNlLnB1c2godik7XFxuICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnB1c2goc2VhcmNoQWxsb3cuaW5jbHVkZXModi5rZXkpID8gXFxcIuKAnOKAnOKAneKAnVxcXCIgKyAodi5uYW1lICsgXFxcIlxcXCIpLmZvbnRjb2xvcihcXFwiIzAwOTk2NlxcXCIpIDogdi5uYW1lKVxcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UgPSBjYW5TZWFyY2hTb3VyY2Uuc2xpY2UoKTtcXG4gICAgICAgICAgICAgICAgICBPYmplY3QuYXNzaWduKG1hbmFnZS5saXN0LCBnZXROYW1lcygpKTtcXG5cXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgICAgICAgIC8vcmV0dXJuIFxcXCJ0b2FzdDovL+i+k+WFpeS6hlxcXCIgKyB0ZXh0O1xcbiAgICAgICAgICAgICAgfSxcXG5cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgfSBlbHNlIGlmIChpID09PSAyKSB7XFxuICAgICAgICAgICAgbGV0IGxpc3QgPSBPYmplY3QuYXNzaWduKFtdLCBtYW5hZ2UubGlzdCk7XFxuICAgICAgICAgICAgbWFuYWdlLmxpc3QubGVuZ3RoID0gMDtcXG5cXG5cXG4gICAgICAgICAgICBkeW5hbWljU291cmNlLnNvcnQoKGEsIGIpID0+IHtcXG4gICAgICAgICAgICAgIHJldHVybiBTdHJpbmcoYS5uYW1lKS5sb2NhbGVDb21wYXJlKFN0cmluZyhiLm5hbWUpLCB1bmRlZmluZWQsIHtcXG4gICAgICAgICAgICAgICAgbnVtZXJpYzogdHJ1ZSxcXG4gICAgICAgICAgICAgICAgc2Vuc2l0aXZpdHk6ICdiYXNlJ1xcbiAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgT2JqZWN0LmFzc2lnbihtYW5hZ2UubGlzdCwgZ2V0TmFtZXMoKSk7XFxuICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcbiAgICAgICAgICB9IGVsc2UgaWYgKGkgPT0gMykge1xcbiAgICAgICAgICAgIG1hbmFnZS5saXN0LnJldmVyc2UoKTtcXG4gICAgICAgICAgICBkeW5hbWljU291cmNlLnJldmVyc2UoKTtcXG5cXG4gICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgIH0gZWxzZSBpZiAoaSA9PSA0KSB7XFxuICAgICAgICAgICAgZHluYW1pY1NvdXJjZS5mb3JFYWNoKHYgPT4ge1xcbiAgICAgICAgICAgICAgaWYgKCFzZWFyY2hBbGxvdy5pbmNsdWRlcyh2KSkge1xcbiAgICAgICAgICAgICAgICBzZWFyY2hBbGxvdy5wdXNoKHYua2V5KTtcXG4gICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBPYmplY3QuYXNzaWduKG1hbmFnZS5saXN0LCBnZXROYW1lcygpKTtcXG4gICAgICAgICAgICBydW50aW1lQ29uZmlnLnNldFNlYXJjaEFsbG93KCk7XFxuICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcbiAgICAgICAgICB9IGVsc2UgaWYgKGkgPT0gNSkge1xcbiAgICAgICAgICAgIGxldCB0ZW1saXN0ID0gc2V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FwiPC9mb250PjwvYj5cXFwiO1xcbiAgICAgICAgICAgIGZsW3gua2V5XSA9IGl0LnY7XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgaWYgKGNhdGVfdGVtcFtpbmRleF0gPT0gXFxcIi0xXFxcIikge1xcbiAgICAgICAgICAgIGZsW3gua2V5XSA9IFxcXCJ1bmRlZmluZWRcXFwiO1xcbiAgICAgICAgICB9XFxuICAgICAgICAgIGlmIChmb2xkID09IDEpIHtcXG4gICAgICAgICAgICBsYXlvdXQucHVzaCh7XFxuICAgICAgICAgICAgICB0aXRsZTogJ+KAnOKAnOKAneKAnScgKyB0LFxcbiAgICAgICAgICAgICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKChvKSA9PiB7XFxuICAgICAgICAgICAgICAgIGxldCBpID0gby5pO1xcbiAgICAgICAgICAgICAgICBzdG9yYWdlMC5wdXRNeVZhcihcXFwiaXNfZGVmXFxcIiwgXFxcIjFcXFwiKTtcXG4gICAgICAgICAgICAgICAgbGV0IGNhdGVfb2JqID0gc3RvcmFnZTAuZ2V0TXlWYXIoXFxcImNhdGVfb2JqXFxcIiwge30pO1xcblxcbiAgICAgICAgICAgICAgICBsZXQgY2F0ZV90ZW1wID0gby5jYXRlX3RlbXA7XFxuICAgICAgICAgICAgICAgIGlmIChjYXRlX3RlbXAuY29uc3RydWN0b3IgIT0gQXJyYXkpIHtcXG4gICAgICAgICAgICAgICAgICBjYXRlX3RlbXAgPSBbXTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBsZXQgaW5kZXggPSBvLmluZGV4O1xcbiAgICAgICAgICAgICAgICBsZXQgYyA9IGNhdGVfdGVtcFtpbmRleF0gfHwgXFxcIi0xXFxcIjtcXG4gICAgICAgICAgICAgICAgLy9sb2coYylcXG4gICAgICAgICAgICAgICAgaWYgKGMgPT0gaSkge1xcbiAgICAgICAgICAgICAgICAgIG8uY2F0ZV90ZW1wW2luZGV4XSA9IFxcXCItMVxcXCI7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgby5jYXRlX3RlbXBbaW5kZXhdID0gaSArIFxcXCJcXFwiO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGNhdGVfb2JqW28uY2F0ZV0gPSBjYXRlX3RlbXA7XFxuICAgICAgICAgICAgICAgIC8vbG9nKGNhdGVfdGVtcClcXG4gICAgICAgICAgICAgICAgLy9zdG9yYWdlMC5wdXRNeVZhcihcXFwiY2F0ZV90ZW1wXFxcIiwgY2F0ZV90ZW1wKTtcXG4gICAgICAgICAgICAgICAgc3RvcmFnZTAucHV0TXlWYXIoXFxcImNhdGVfb2JqXFxcIiwgY2F0ZV9vYmopO1xcbiAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgICAgfSwge1xcbiAgICAgICAgICAgICAgICBpbmRleDogaW5kZXgsXFxuICAgICAgICAgICAgICAgIGNhdGVfdGVtcDogY2F0ZV90ZW1wLFxcbiAgICAgICAgICAgICAgICBpOiBpLFxcbiAgICAgICAgICAgICAgICBjYXRlOiBjYXRlXFxuICAgICAgICAgICAgICB9KSxcXG4gICAgICAgICAgICAgIGNvbF90eXBlOiAnc2Nyb2xsX2J1dHRvbicsXFxuICAgICAgICAgICAgfSlcXG4gICAgICAgICAgfVxcbiAgICAgICAgfSlcXG4gICAgICB9KVxcbiAgICB9XFxuICB9XFxufVxcblxcbmZ1bmN0aW9uIGdldEZsKCkge1xcbiAgZmwgPSBPYmplY3Qua2V5cyhmbCkuZmlsdGVyKGtleSA9PiBmbFtrZXldICE9PSBcXFwidW5kZWZpbmVkXFxcIikucmVkdWNlKChyZXMsIGtleSkgPT4ge1xcbiAgICByZXNba2V5XSA9IGZsW2tleV07XFxuICAgIHJldHVybiByZXM7XFxuICB9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ICAgICAgdXJsOiB1cmwsXFxuICAgICAgICAgICAgICAgIHBpY191cmw6IGl0LnZvZF9waWMsXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBob21lTGlzdENvbCxcXG4gICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgIGltZzogaXQudm9kX3BpYyxcXG4gICAgICAgICAgICAgICAgICAgIHZvZElkOiBpZCxcXG4gICAgICAgICAgICAgICAgICAgIHNuYW1lOiBzb3VyY2UubmFtZSxcXG4gICAgICAgICAgICAgICAgICAgIHNrZXk6IHNvdXJjZS5rZXksXFxuICAgICAgICAgICAgICAgICAgICBsb25nQ2xpY2s6IFt7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLogZrlkIjmkJzntKJcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGpzOiBcXFwicHV0TXlWYXIoJ3RlbXNtb2RlJywgJzEnKTsnaGlrZXI6Ly9zZWFyY2g/cnVsZT0nICsgTVlfUlVMRS50aXRsZSArICcmcz1cXFwiICsgbmFtZSArIFxcXCInO1xcXCJcXG4gICAgICAgICAgICAgICAgICAgIH1dXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH1cXG4gICAgfVxcbiAgICBkZWxldGVJdGVtKE1ZX1JVTEUudGl0bGUgKyBcXFwibG9hZFxcXCIpO1xcbn1cXG5cXG5mdW5jdGlvbiBzZXREcnB5UGF0aChkKSB7XFxuICAgIGQucHVzaCh7XFxuICAgICAgICB0aXRsZTogXFxcIue8uuWwkei/kOihjOW6k1xcXFxu6K+l5bCP56iL5bqP5LiN6IO96YCa6L+H5LqR5Ymq6LS05p2/5YiG5Lqr77yM5Y+q6IO96YCa6L+H5omT5YyF5YiG5LqrXFxcIixcXG4gICAgICAgIGRlc2M6IFxcXCLlsIbov5DooYzlupPmlL7lhaVcXFwiICsgZ2V0UGF0aChcXFwiaGlrZXI6Ly9maWx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Mjbm9IaXN0b3J5I1xcXCIpXFxuICAgICAgICAgICAgfSwge1xcbiAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuWIt+aWsOa6kFxcXCIsXFxuICAgICAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydW50aW1lQ29uZmlnID0gR00uZGVmaW5lTW9kdWxlKFxcXCJydW50aW1lQ29uZmlnXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgc291cmNlID0gcnVudGltZUNvbmZpZy5nZXRDdXJyZW50U291cmNlKCk7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgRHJweU1hbmFnZSA9IEdNLmRlZmluZU1vZHVsZShcXFwiRHJweU1hbmFnZVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgRHJweU1hbmFnZS5nZXQoc291cmNlLmtleSkuaW5pdChydW50aW1lQ29uZmlnLmdldEFic29sdXRlUGF0aChzb3VyY2UuZXh0KSk7XFxuICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIH0sIHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLlrozlhajliLfmlrDmupBcXFwiLFxcbiAgICAgICAgICAgICAgICBqczogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcXFwicnVudGltZUNvbmZpZ1xcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHNvdXJjZSA9IHJ1bnRpbWVDb25maWcuZ2V0Q3VycmVudFNvdXJjZSgpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IERycHlNYW5hZ2UgPSBHTS5kZWZpbmVNb2R1bGUoXFxcIkRycHlNYW5hZ2VcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIERycHlNYW5hZ2UuZ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YCJ5LitXFxcIiwgXFxcIuiBmuWQiFxcXCJdW01ZX0lOREVYXSxcXG4gICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICAgICAgLy9yZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgIH0sIE1ZX1JVTEUudGl0bGUpXFxuICAgICAgICB9KSxcXG4gICAgICAgIHBpY191cmw6IFxcXCJodHRwczovL2hpa2VyZmFucy5jb20vdHViaWFvL3N5c3RlbS80MS5wbmdcXFwiLFxcbiAgICAgICAgY29sX3R5cGU6IFxcXCJpY29uX3JvdW5kX3NtYWxsXzRcXFwiLFxcbiAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICBpZDogTVlfUlVMRS50aXRsZSArIFxcXCJAc2VhcmNoX21vZGVcXFwiLFxcbiAgICAgICAgICAgIGxvbmdDbGljazogW3tcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLmjIflrprmkJzntKLmupBcXFwiLFxcbiAgICAgICAgICAgICAgICBqczogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcIlNlYXJjaEFsbG93UG9wXFxcIikuc2hvdygpO1xcbiAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIH1dXFxuICAgICAgICB9XFxuICAgIH0pO1xcbiAgICBkLnB1c2goe1xcbiAgICAgICAgdGl0bGU6IFxcXCLmiJHnmoRcXFwiLFxcbiAgICAgICAgdXJsOiAkKFt7XFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLljoblj7JcXFwiLFxcbiAgICAgICAgICAgIGljb246ICdodHRwczovL2hpa2VyZmFucy5jb20vdHViaWFvL3N5c3RlbS8xMzYucG5nJ1xcbiAgICAgICAgfSwge1xcbiAgICAgICAgICAgIHRpdGxlOiBcXFwi5pS26JePXFxcIixcXG4gICAgICAgICAgICBpY29uOi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AgICAgICBzZXRJdGVtKFxcXCJ1c2VMb2dcXFwiLCB1c2VMb2cgPyBcXFwiXFxcIiA6IFxcXCIxXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcXFwicnVudGltZUNvbmZpZ1xcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHNvdXJjZSA9IHJ1bnRpbWVDb25maWcuZ2V0Q3VycmVudFNvdXJjZSgpO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKHNvdXJjZSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBEcnB5TWFuYWdlID0gR00uZGVmaW5lTW9kdWxlKFxcXCJEcnB5TWFuYWdlXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgRHJweU1hbmFnZS5kZWwoc291cmNlLmtleSk7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL1xcXCIgKyAodXNlTG9nID8gXFxcIuW3suWFs+mXrVxcXCIgOiBcXFwi5bey5byA5ZCvXFxcIik7XFxuICAgICAgICAgICAgICAgIH0sIHVzZUxvZyk7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChpbnB1dCA9PT0gXFxcIuWIm+W7uuiuoumYheWcsOWdgFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3BhZ2UvY3JlYXRlU3Vic2NyaXB0aW9uI25vUmVjb3JkSGlzdG9yeSMjbm9IaXN0b3J5I1xcXCI7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChpbnB1dCA9PT0gXFxcIuWIh+aNouWIl+ihqOagt+W8j1xcXCIpIHtcXG4gICAgICAgICAgICAgICAgbGV0IGNvbGxpc3QgPSBbXFxcIum7mOiupFxcXCIsIFxcXCJtb3ZpZV8zX21hcnF1ZWVcXFwiLCBcXFwibW92aWVfM1xcXCIsIFxcXCJtb3ZpZV8yXFxcIiwgXFxcIm1vdmllXzFcXFwiLCBcXFwidGV4dF8xXFxcIl07XFxuICAgICAgICAgICAgICAgIGxldCBob21lTGlzdENvbCA9IGdldEl0ZW0oXFxcImhvbWVMaXN0Q29sXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgICAgICBsZXQgaW5kZXggPSBob21lTGlzdENvbCA/IGNvbGxpc3QuaW5kZXhPZihob21lTGlzdENvbCkgOiAwO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gJChjb2xsaXN0LCAxLCBcXFwi6YCJ5oup5qC35byPXFxcIiwgaW5kZXgpLnNlbGVjdCgoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoTVlfSU5ERVggPT09IDApIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJob21lTGlzdENvbFxcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgc2V0SXRlbShcXFwiaG9tZUxpc3RDb2xcXFwiLCBpbnB1dCk7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlucHV0ID09PSBcXFwi5pu05o2i6YWN572uXFxcIikge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vcGFnZS9jcmVhdGVDb25maWcjbm9SZWNvcmRIaXN0b3J5IyNub0hpc3RvcnkjXFxcIjtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKFxcXCLmlK/mjIHkvZzogIVcXFwiID09IGlucHV0KSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL0Rvbm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Mjbm9IaXN0b3J5I1xcXCIsXFxuICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgIH0pO1xcbiAgICB9IGVsc2UgaWYgKGZpbGVFeGlzdChcXFwiaGlrZXI6Ly9maWxlcy9kYXRhL1xcXCIgKyBNWV9SVUxFLnRpdGxlICsgXFxcIi9saWJzX2hpa2VyL2RycHkyLmpzXFxcIikpIHtcXG4gICAgICAgIGxldCBzb3VyY2UgPSBydW50aW1lQ29uZmlnLmdldEN1cnJlbnRTb3VyY2UoKTtcXG4gICAgICAgIGlmIChNWV9QQUdFID09PSAxKSB7XFxuICAgICAgICAgICAgaWYgKHNvdXJjZSA9PSB1bmRlZmluZWQpIHtcXG4gICAgICAgICAgICAgICAgc2V0SGllZChkKVxcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHNldEhpZWQoZCwgc291cmNlLm5hbWUsIHJ1bnRpbWVDb25maWcuZ2V0Q3VycmVudENvbmZpZygpIHx8IHt9KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgICAgICAvL2xvZyhEcnB5TWFuYWdlLmdldChzb3VyY2Uua2V5KSlcXG4gICAgICAgIGxldCBoYXNIYWVkID0gZmFsc2U7XFxuICAgICAgICBpZiAoZ2V0TXlWYXIoXFxcImxpbmtzXFxcIiwgXFxcIlxcXCIpID09IFxcXCJcXFwiKSB7XFxuICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6ICfliqDovb3kuK0uLi4nLFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogJ3RleHRfY2VudGVyXzEnLFxcbiAgICAgICAgICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgIGxpbmVWaXNpYmxlOiBmYWxzZSxcXG4gICAgICAgICA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6IHtcXG4gICAgICAgIGxpbmVWaXNpYmxlOiBmYWxzZVxcbiAgICB9XFxufSk7XFxuc2V0UmVzdWx0KGQpO1wifSx7XCJjb2xfdHlwZVwiOlwibW92aWVfM1wiLFwibmFtZVwiOlwiTG9jYWxQcm94eVwiLFwicGF0aFwiOlwiTG9jYWxQcm94eVwiLFwicnVsZVwiOlwiZnVuY3Rpb24gcHJveHkoKSB7XFxuICAgIGZ1bmN0aW9uIHBhcnNlVmlkZW8oTVlfUEFSQU1TLCB0aXRsZSkge1xcbiAgICAgICAgZnVuY3Rpb24gdG9QYXRoKHZhbHVlKSB7XFxuICAgICAgICAgICAgaWYgKHR5cGVvZiB2YWx1ZSAhPT0gJ3N0cmluZycpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFtdO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgcGF0aCA9IFtdO1xcbiAgICAgICAgICAgIGxldCBjdXJyZW50ID0gJyc7XFxuICAgICAgICAgICAgbGV0IGluQnJhY2tldHMgPSBmYWxzZTtcXG4gICAgICAgICAgICBsZXQgZXNjYXBlID0gZmFsc2U7XFxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCB2YWx1ZS5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgICAgICBsZXQgY2hhciA9IHZhbHVlW2ldO1xcbiAgICAgICAgICAgICAgICBpZiAoZXNjYXBlKSB7XFxuICAgICAgICAgICAgICAgICAgICBjdXJyZW50ICs9IGNoYXI7XFxuICAgICAgICAgICAgICAgICAgICBlc2NhcGUgPSBmYWxzZTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChjaGFyID09PSAnXFxcXFxcXFwnKSB7XFxuICAgICAgICAgICAgICAgICAgICBlc2NhcGUgPSB0cnVlO1xcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGNoYXIgPT09ICcuJyAmJiAhaW5CcmFja2V0cykge1xcbiAgICAgICAgICAgICAgICAgICAgcGF0aC5wdXNoKGN1cnJlbnQpO1xcbiAgICAgICAgICAgICAgICAgICAgY3VycmVudCA9ICcnO1xcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGNoYXIgPT09ICdbJykge1xcbiAgICAgICAgICAgICAgICAgICAgaW5CcmFja2V0cyA9IHRydWU7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoY2hhciA9PT0gJ10nKSB7XFxuICAgICAgICAgICAgICAgICAgICBpbkJyYWNrZXRzID0gZmFsc2U7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBjdXJyZW50ICs9IGNoYXI7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKGN1cnJlbnQpIHtcXG4gICAgICAgICAgICAgICAgcGF0aC5wdXNoKGN1cnJlbnQpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gcGF0aDtcXG4gICAgICAgIH1cXG5cXG4gICAgICAgIGZ1bmN0aW9uIGdldEpzb24ob2JqLCBwYXRoKSB7XFxuICAgICAgICAgICAgaWYgKCFvYmogfHwgIUFycmF5LmlzQXJyYXkocGF0aCkpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIHVuZGVmaW5lZDtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKHBhdGgubGVuZ3RoID09PSAwKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBvYmo7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCBjdXJyZW50ID0gb2JqO1xcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgcGF0aC5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgICAgICBsZXQga2V5ID0gcGF0aFtpXTtcXG4gICAgICAgICAgICAgICAgaWYgKGN1cnJlbnQgPT09IG51bGwgfHwgY3VycmVudCA9PT0gdW5kZWZpbmVkIHx8IHR5cGVvZiBjdXJyZW50ICE9PSAnb2JqZWN0Jykge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHVuZGVmaW5lZDtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBjdXJyZW50ID0gY3VycmVudFtrZXldO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gY3VycmVudDtcXG4gICAgICAgIH1cXG4gICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgbGV0IHJ1blR5cGUgPSBNWV9QQVJBTVMucnVuVHlwZVswXTtcXG4gICAgICAgICAgICBsZXQgdXJsID0gZGVjb2RlVVJJQ29tcG9uZW50KGJhc2U2NERlY29kZShNWV9QQVJBTVMudXJsWzBdKSk7XFxuICAgICAgICAgICAgaWYgKHJ1blR5cGUgPT0gXFxcIkpTT05cXFwiKSB7XFxuXFxuICAgICAgICAgICAgICAgIGxldCBwYXJhbSA9IEpTT04ucGFyc2UoZGVjb2RlVVJJQ29tcG9uZW50KGJhc2U2NERlY29kZShNWV9QQVJBTVMucGFyYW1bMF0pKSk7XFxuICAgICAgICAgICAgICAgIGxldCBqc29uID0gSlNPTi5wYXJzZShyZXF1ZXN0KHVybCwge1xcbiAgICAgICAgICAgICAgICAgICAgaGVhZGVyczogcGFyYW0uaGVhZGVycyB8fCB7fSxcXG4gICAgICAgICAgICAgICAgICAgIG1ldGhvZDogcGFyYW0ubWV0aG9kIHx8IHZvaWQgMFxcbiAgICAgICAgICAgICAgICB9KSk7XFxuICAgICAgICAgICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeSh7XFxuICAgICAgICAgICAgICAgICAgICBzdGF0dXNDb2RlOiAzMDIsXFxuICAgICAgICAgICAgICAgICAgICBoZWFkZXJzOiBPYmplY3QuYXNzaWduKHt9LCBwYXJhbS5oZWFkZXJzIHx8IHt9LCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgXFxcIkxvY2F0aW9uXFxcIjogZ2V0SnNvbihqc29uLCB0b1BhdGgocGFyYW0uanNvblBhdGgpKSxcXG4gICAgICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAocnVuVHlwZSA9PSBcXFwiSlNcXFwiKSB7XFxuXFxuICAgICAgICAgICAgICAgIGxldCBwYXJzZTtcXG4gICAgICAgICAgICAgICAgaWYgKE1ZX1BBUkFNUy5pbmRleCkge1xcbiAgICAgICAgICAgICAgICAgICAgcGFyc2UgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3M/cnVsZT1cXFwiICsgdGl0bGUpLmdldEpzb24oKVtNWV9QQVJBTVMuaW5kZXhbMF1dO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgcGFyc2UgPSBKU09OLnBhcnNlKGRlY29kZVVSSUNvbXBvbmVudChiYXNlNjREZWNvZGUoTVlfUEFSQU1TLnBhcmFtWzBdKSkpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGxldCByZXMgPSBuZXcgRnVuY3Rpb24oXFxcInVybFxcXCIsIFxcXCJzZWxmXFxcIiwgcGFyc2UuanMpKHVybCwgcGFyc2UpO1xcbiAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHJlcyA9PT0gXFxcInN0cmluZ1xcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeSh7XFxuICAgICAgICAgICAgICAgICAgICAgICAgc3RhdHVzQ29kZTogMzAyLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgXFxcIkxvY2F0aW9uXFxcIjogcmVzXFxuICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoJC50eXBlKHJlcykgPT09IFxcXCJvYmplY3RcXFwiKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkoe1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHN0YXR1c0NvZGU6IDMwMixcXG4gICAgICAgICAgICAgICAgICAgICAgICBoZWFkZXJzOiByZXNcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgIGxvZyhlLnRvU3RyaW5nKCkpO1xcbiAgICAgICAgfVxcbiAgICB9XFxuXFxuICAgIGZ1bmN0aW9uIGRvSnMoTVlfUEFSQU1TLCB0aXRsZSwgZ2tleSkge1xcbiAgICAgICAgbGV0IHtcXG4gICAgICAgICAgICBHTVxcbiAgICAgICAgfSA9ICQucmVxdWlyZShcXFwiaHR0cDovL2hpa2VyLm5va2lhLnByZXNzL2hpa2VydWxlL3J1bGVsaXN0Lmpzb24/aWQ9NjkxNiZhdXRoPTFkMzVlOGYwLTIyZTgtNTI3MC1hOWQxLTgyNmY1M2YxNzdhZFxcXCIpO1xcbiAgICAgICAgR00uc2V0U2VsZktleShna2V5KTtcXG4gICAgICAgIGxldCBEcnB5TWFuYWdlID0gR00uZGVmaW5lTW9kdWxlKFxcXCJEcnB5TWFuYWdlXFxcIiwgXFxcIkRycHlNYW5hZ2U/cnVsZT1cXFwiICsgdGl0bGUpO1xcbiAgICAgICAgbGV0IGRycHkgPSBEcnB5TWFuYWdlLmdldChkZWNvZGVVUklDb21wb25lbnQoTVlfUEFSQU1TLmhpa2VyU2tleVswXSkpO1xcbiAgICAgICAgbGV0IHBhcmFtcyA9IHt9O1xcbiAgICAgICAgZm9yIChsZXQga2V5IGluIE1ZX1BBUkFNUykge1xcbiAgICAgICAgICAgIHBhcmFtc1trZXldID0gU3RyaW5nKE1ZX1BBUkFNU1trZXldWzBdKTtcXG4gICAgICAgIH1cXG4gICAgICAgIF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TLmRvICYmIE1ZX1BBUkFNUy5kb1swXSA9PT0gXFxcImpzXFxcIikge1xcbiAgICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBkb0pzKE1ZX1BBUkFNUywgdGl0bGUsIGdrZXkpO1xcbiAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICAgICAgbG9nKGUudG9TdHJpbmcoKSk7XFxuICAgICAgICAgICAgICAgIHJldHVybjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIHJldHVybiBwYXJzZVZpZGVvKE1ZX1BBUkFNUywgdGl0bGUpO1xcbiAgICAgICAgfVxcbiAgICB9XFxuICAgIHRoaXMuZW50cmFuY2UgPSBlbnRyYW5jZTtcXG59XFxuXFxuZnVuY3Rpb24gc3RhcnRQcm94eSh0aXRsZSwgZ2tleSkge1xcbiAgICByZXR1cm4gc3RhcnRQcm94eVNlcnZlcigkLnRvU3RyaW5nKChwcm94eSwgdGl0bGUsIGdrZXkpID0+IHtcXG4gICAgICAgIHJldHVybiBuZXcgcHJveHkoKS5lbnRyYW5jZShNWV9QQVJBTVMsIHRpdGxlLCBna2V5KTtcXG4gICAgfSwgcHJveHksIHRpdGxlLCBna2V5KSk7XFxufVxcbiQuZXhwb3J0cy5zdGFydFByb3h5ID0gc3RhcnRQcm94eTtcIn1dIiwiaWNvbiI6IiIsInByb3h5IjoiIn0=
Add Comment
Please, Sign In to add comment