xiaomianao666

小程序:云盘君.简

Nov 20th, 2024
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 海阔视界规则分享,当前分享的是:小程序¥home_rule_v2¥base64://@云盘君.简@eyJsYXN0X2NoYXB0ZXJfcnVsZSI6IiIsInRpdGxlIjoi5LqR55uY5ZCbLueugCIsImF1dGhvciI6IuWwj+ajieiihPCfjJ4mQExveURnSWsiLCJ1cmwiOiJoaWtlcjovL2VtcHR5IyNmeXBhZ2UiLCJ2ZXJzaW9uIjoxODEsImNvbF90eXBlIjoibW92aWVfMyIsImNsYXNzX25hbWUiOiIiLCJ0eXBlIjoiYWxsIiwiY2xhc3NfdXJsIjoiIiwiYXJlYV9uYW1lIjoiIiwiYXJlYV91cmwiOiIiLCJzb3J0X25hbWUiOiIiLCJ5ZWFyX25hbWUiOiIiLCJzb3J0X3VybCI6IiIsInllYXJfdXJsIjoiIiwiZmluZF9ydWxlIjoianM6JC5yZXF1aXJlKFwiTWFpblwiKTsiLCJzZWFyY2hfdXJsIjoiaGlrZXI6Ly9lbXB0eT9zZWFyY2hUZXJtcz0qKiIsImdyb3VwIjoi4pGg572R55uYIiwic2VhcmNoRmluZCI6ImpzOlxubGV0IGlzZERlbGVnYXRlID0gISFnZXRJdGVtKFwiaXNkRGVsZWdhdGVcIiwgXCJcIik7XG5pZiAoaXNkRGVsZWdhdGUpIHtcbiAgICBzZXRSZXN1bHQoW3tcbiAgICAgICAgdGl0bGU6IFwi54K55oiR5byA5aeL6IGa5ZCI5pCc57SiXCIgKyBNWV9LRVlXT1JELFxuICAgICAgICB1cmw6IFwiaGlrZXI6Ly9zZWFyY2g/cz1cIiArIE1ZX0tFWVdPUkQsXG4gICAgICAgIGV4dHJhOiB7XG4gICAgICAgICAgICBkZWxlZ2F0ZU9ubHlTZWFyY2g6IHRydWUsXG4gICAgICAgICAgICBydWxlczogJC50b1N0cmluZygoKSA9PiB7XG4gICAgICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGVHcm91cCA9IGdldEl0ZW0oXCJydWxlR3JvdXBcIiwgXCJcIik7XG4gICAgICAgICAgICAgICAgICAgIGxldCBkYXRhID0gJC5yZXF1aXJlKFwiZGF0YVwiKS5nZXRBbGxEYXRhKHJ1bGVHcm91cCk7XG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlcyA9IFtdO1xuICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpdCBvZiBkYXRhKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBydWxlcy5wdXNoKHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogaXQubmFtZSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWFyY2hfdXJsOiBcImhpa2VyOi8vZW1wdHk/cGFnZT1meXBhZ2Umc2VhcmNoVGVybXM9KipcIixcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWFyY2hGaW5kOiBcImpzOlwiICsgJC50b1N0cmluZygocnVsZSkgPT4ge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXRSZXN1bHQoJC5yZXF1aXJlKFwiZGF0YVwiKS5jYXJyeVNSdWxlKHJ1bGUsIE1ZX0tFWVdPUkQsIE1ZX1BBR0UsIGdldFNlYXJjaE1vZGUoKSkpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sIGl0KVxuICAgICAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHJ1bGVzKTtcbiAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7XG4gICAgICAgICAgICAgICAgICAgIGxvZyhlLnRvU3RyaW5nKCkpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pXG4gICAgICAgIH1cbiAgICB9XSk7XG59IGVsc2Uge1xuICAgIHNldFJlc3VsdChbe1xuICAgICA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dHlwZTogaXQucGljX3VybCA/IFxcXCJtb3ZpZV8xX3ZlcnRpY2FsX3BpY1xcXCIgOiBcXFwidGV4dF8xXFxcIixcXG4gICAgICAgICAgICBleHRyYTogT2JqZWN0LmFzc2lnbih7XFxuICAgICAgICAgICAgICAgIGluaGVyaXRUaXRsZTogZmFsc2UsXFxuICAgICAgICAgICAgICAgIG5vUGljOiB0cnVlXFxuICAgICAgICAgICAgfSwgaXQuZXh0cmEpXFxuICAgICAgICB9KTtcXG4gICAgfVxcbiAgICByZXR1cm4gcmVzTGlzdDtcXG59XFxuJC5leHBvcnRzLmNhcnJ5U1J1bGUgPSBmdW5jdGlvbihydWxlLCBzLCBwYWdlLCBzZWFyY2hNb2RlKSB7XFxuICAgIHJ1bGUgPSBnZXRDb21wbGV0ZVJ1bGUocnVsZSk7XFxuICAgIGxldCBsaXN0ID0gcnVsZS5maW5kKHMsIHBhZ2UpO1xcbiAgICBpZiAoIWxpc3QpIHJldHVybiBbXTtcXG4gICAgbGV0IHJlc0xpc3QgPSBbXTtcXG4gICAgZm9yIChsZXQgaXQgb2YgbGlzdCkge1xcbiAgICAgICAgaWYgKGl0LnNraXApIHtcXG4gICAgICAgICAgICByZXNMaXN0LnB1c2goaXQpO1xcbiAgICAgICAgICAgIGNvbnRpbnVlO1xcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKHNlYXJjaE1vZGUgJiYgIXNlYXJjaENvbnRhaW5zKGl0LnRpdGxlLCBzLCB0cnVlKSkgY29udGludWU7XFxuICAgICAgICBpZiAocnVsZS5maW5kQWxpVXJsKSB7XFxuICAgICAgICAgICAgaXQudXJsID0gJChpdC51cmwpLmxhenlSdWxlKHRvUmVkaXJlY3RUcmVhdGluZywge1xcbiAgICAgICAgICAgICAgICBmaW5kQWxpVXJsOiBydWxlLmZpbmRBbGlVcmwsXFxuICAgICAgICAgICAgICAgIGJhc2ljVXJsOiBydWxlLmJhc2ljVXJsLFxcbiAgICAgICAgICAgICAgICBuYW1lOiBydWxlLm5hbWUsXFxuICAgICAgICAgICAgICAgIGF1dGhvcjogcnVsZS5hdXRob3IsXFxuICAgICAgICAgICAgICAgIGFsaVVybDogaXQudXJsLFxcbiAgICAgICAgICAgICAgICBydWxlVHlwZTogcnVsZS5ydWxlVHlwZVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBpdC51cmwgPSAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKHRvUmVkaXJlY3QsIGl0LnVybCwgaXQuc2hhcmVQd2QgfHwgXFxcIlxcXCIpO1xcbiAgICAgICAgfVxcbiAgICAgICAgcmVzTGlzdC5wdXNoKHtcXG4gICAgICAgICAgICB0aXRsZTogaXQudGl0bGUsXFxuICAgICAgICAgICAgZGVzYzogaXQuZGVzYyB8fCBcXFwiXFxcIixcXG4gICAgICAgICAgICB1cmw6IGl0LnVybCxcXG4gICAgICAgICAgICBwaWNfdXJsOiBpdC5waWNfdXJsLFxcbiAgICAgICAgICAgIGV4dHJhOiBPYmplY3QuYXNzaWduKHtcXG4gICAgICAgICAgICAgICAgaW5oZXJpdFRpdGxlOiBmYWxzZSxcXG4gICAgICAgICAgICAgICAgbm9QaWM6IHRydWVcXG4gICAgICAgICAgICB9LCBpdC5leHRyYSlcXG4gICAgICAgIH0pO1xcbiAgICB9XFxuICAgIHJldHVybiByZXNMaXN0O1xcbn1cXG5sZXQgc2l6ZSA9IDEwO1xcblxcbmxldCBydWxlcztcXG5cXG5mdW5jdGlvbiBnZXRSdWxlcyhncm91cCkge1xcbiAgICBsZXQgcnVsZXNUbXA7XFxuICAgIGlmICghcnVsZXMpIHtcXG4gICAgICAgIHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0VXNlZnVsSnNvbigpO1xcbiAgICB9XFxuICAgIGlmIChncm91cCkge1xcbiAgICAgICAgcnVsZXNUbXAgPSBydWxlcy5maWx0ZXIodiA9PiB2Lmdyb3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ICAgICAgbGV0IGNsaXBib2FyZCA9IGNvbnRleHQuZ2V0U3lzdGVtU2VydmljZShDb250ZXh0LkNMSVBCT0FSRF9TRVJWSUNFKTtcXG4gICAgICAgICAgICAvLyDov5Tlm57mlbDmja5cXG4gICAgICAgICAgICBsZXQgY2xpcERhdGEgPSBjbGlwYm9hcmQuZ2V0UHJpbWFyeUNsaXAoKTtcXG4gICAgICAgICAgICBpZiAoY2xpcERhdGEgIT0gbnVsbCAmJiBjbGlwRGF0YS5nZXRJdGVtQ291bnQoKSA+IDApIHtcXG4gICAgICAgICAgICAgICAgLy8g5LuO5pWw5o2u6ZuG5Lit6I635Y+W77yI57KY6LS077yJ56ys5LiA5p2h5paH5pys5pWw5o2uXFxuICAgICAgICAgICAgICAgIGxldCB0ZXh0ID0gY2xpcERhdGEuZ2V0SXRlbUF0KDApLmdldFRleHQoKTtcXG4gICAgICAgICAgICAgICAgaWYgKHRleHQgIT0gbnVsbCkge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFN0cmluZyh0ZXh0LnRvU3RyaW5nKCkpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBudWxsO1xcbiAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgIHJldHVybiBudWxsO1xcbiAgICAgICAgfVxcbiAgICB9XFxuICAgIGxldCB0ZXh0ID0gZ2V0Q29weSgpIHx8IFxcXCJcXFwiO1xcbiAgICBsZXQgdXJsID0gYWxpdGVzdC5tYXRjaEFsaVVybCh0ZXh0KTtcXG4gICAgaWYgKHVybCkge1xcbiAgICAgICAgbGV0IGNhY2hlID0gZ2V0SXRlbShcXFwiY2xpcGJvYXJkQ2FjaGVcXFwiLCBcXFwiXFxcIik7XFxuICAgICAgICBpZiAodXJsICE9PSBjYWNoZSkge1xcbiAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiAn4oCc4oCc4oCd4oCdPGZvbnQgY29sb3I9XFxcIiMxM0I2MUJcXFwiPuKWkCA8L2ZvbnQ+PGI+5rip6aao5o+Q56S6PGI+JyxcXG4gICAgICAgICAgICAgICAgZGVzYzogXFxcIuajgOa1i+WIsOWJqui0tOadv+WQq+aciemYv+mHjOmTvuaOpeaYr+WQpuaJk+W8gD9cXFxcblxcXCIgKyB1cmwsXFxuICAgICAgICAgICAgICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgoaW5wdXQsIGlkKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBkZWxldGVJdGVtKGlkICsgXFxcImNsaXBib2FyZFxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3BhZ2UvYWxpeXVuP3BhZ2U9ZnlwYWdlJnJlYWx1cmw9XFxcIiArIGVuY29kZVVSSUNvbXBvbmVudChpbnB1dCkgKyBcXFwiJnNoYXJlUHdkPVxcXCI7XFxuICAgICAgICAgICAgICAgIH0sIHVybCwgaWQpLFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfMVxcXCIsXFxuICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICBpZDogaWQgKyBcXFwiY2xpcGJvYXJkXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIHBhZ2VUaXRsZTogXFxcIuaJk+W8gOmTvuaOpVxcXCJcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIHNldEl0ZW0oXFxcImNsaXBib2FyZENhY2hlXFxcIiwgdXJsKTtcXG4gICAgICAgIH1cXG4gICAgfVxcbn1cXG5cXG5mdW5jdGlvbiBzZXRQcmVwb3NlKCkge1xcbiAgICBpZiAob3Blbk1vZGUgPT0gXFxcIuacrOWcsOino+aekFxcXCIpIHtcXG4gICAgICAgIGxldCBhbGlUb2tlbnNGaWxlcGF0aCA9ICQucmVxdWlyZShcXFwiaGlrZXI6Ly9wYWdlL3Rva2VuUGF0aFxcXCIpLmFsaVRva2Vuc0ZpbGVwYXRoO1xcbiAgICAgICAgbGV0IGEgPSBmZXRjaChhbGlUb2tlbnNGaWxlcGF0aCk7XFxuICAgICAgICBpZiAoIWEgfHwgYSA9PSBcXFwiXFxcIikge1xcbiAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiAnPGZvbnQgY29sb3I9XFxcIiMxM0I2MUJcXFwiPuKWkCA8L2ZvbnQ+PGI+5rip6aao5o+Q56S6PGI+JyxcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJyaWNoX3RleHRcXFwiLFxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgoKSA9PiAkLnJlcXVpcmUoXFxcImxvZ2luTW9kZVxcXCIpKSxcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0XzFcXFwiLFxcbiAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuacquajgOa1i+WIsOeZu+W9leS/oeaBr++8jOeCueaIkei3s+i9rOeZu+W9lei0puWPt+mhtemdou+8jOeZu+W9lemYv+mHjOS6keebmOi0puWPt+WQjuaWueWPr+S9v+eUqOacrOWcsOino+aekOaooeW8j1xcXCIsXFxuICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICBwYWdlVGl0bGU6IFxcXCLnmbvlvZXpmL/ph4zkupHnm5hcXFwiXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH1cXG4gICAgfVxcbiAgICBhZGRMaXN0ZW5lcihcXFwib25DbG9zZVxcXCIsICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgY2xlYXJNeVZhcihcX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U9XFxcIikgKyBcXFwiK2VuY29kZVVSSUNvbXBvbmVudChwbGF5ZGF0YS50aXRsZS5zcGxpdCgnLScpWzBdKTtcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgXFxcIm5hbWVcXFwiOiBNWV9SVUxFLnRpdGxlICsgXFxcIuW8ueW5leaQnOe0olxcXCJcXG4gICAgICAgICAgICAgICAgfTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJydWxlOi8vXFxcIiArIGJhc2U2NEVuY29kZShcXFwi77+lcHJvamVjdGlvbl9zY3JlZW7vv6VcXFwiICsgSlNPTi5zdHJpbmdpZnkocnVsZSkpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAoXFxcIuaSreaUvuaooeW8j1xcXCIgPT09IGlucHV0KSB7XFxuICAgICAgICAgICAgICAgIGxldCBtb2RlcyA9IFtcXFwi6L2s56CBXFxcIiwgXFxcIuWOn+eUu1xcXCIsIFxcXCLljp/ovaxcXFwiXTtcXG4gICAgICAgICAgICAgICAgbGV0IG1vZGUgPSBnZXRJdGVtKFxcXCJhbGl5dW5fcGxheU1vZGVcXFwiLCBtb2Rlc1swXSk7XFxuICAgICAgICAgICAgICAgIGxldCBpbmRleCA9IG1vZGVzLmluZGV4T2YobW9kZSk7XFxuICAgICAgICAgICAgICAgIHJldHVybiAkKG1vZGVzLCAxLCBcXFwi5pKt5pS+5qih5byPXFxcIiwgaW5kZXgpLnNlbGVjdCgoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJhbGl5dW5fcGxheU1vZGVcXFwiLCBpbnB1dCk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5YiH5o2i5oiQ5YqfXFxcIjtcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGlmIChcXFwi55m75b2V5L+h5oGvXFxcIiA9PSBpbnB1dCkge1xcbiAgICAgICAgICAgICAgICBjb25zdCB7XFxuICAgICAgICAgICAgICAgICAgICBvcGVuVG9rZW5zRmlsZXBhdGgsXFxuICAgICAgICAgICAgICAgICAgICBhbGlUb2tlbnNGaWxlcGF0aFxcbiAgICAgICAgICAgICAgICB9ID0gJC5yZXF1aXJlKFxcXCJ0b2tlblBhdGhcXFwiKTtcXG4gICAgICAgICAgICAgICAgaWYgKCFmaWxlRXhpc3QoYWxpVG9rZW5zRmlsZXBhdGgpKSByZXR1cm4gXFxcInRvYXN0Oi8v6L+Y5pyq55m76ZmGXFxcIjtcXG4gICAgICAgICAgICAgICAgbGV0IGFsaSA9IHJlcXVlc3QoYWxpVG9rZW5zRmlsZXBhdGgpO1xcbiAgICAgICAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgICAgICAgICAgYWxpID0gSlNPTi5wYXJzZShhbGkpO1xcbiAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgICAgICAgICBkZWxldGVGaWxlKGFsaVRva2Vuc0ZpbGVwYXRoKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/ojrflj5blpLHotKVcXFwiO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGNvbmZpcm0oe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6ICfnmbvlvZXkv6Hmga8nLFxcbiAgICAgICAgICAgICAgICAgICAgY29udGVudDogXFxcIueUqOaItzpcXFwiICsgKGFsaS5uaWNrX25hbWUgfHwgYWxpLnVzZXJfbmFtZSB8fCBcXFwiVG9rZW7nmbvlvZVcXFwiKSArIFxcXCJcXFxcblRva2VuOlxcXCIgKyBhbGkucmVmcmVzaF90b2tlbiArIFxcXCJcXFxcbijlj5bmtojvvJrms6jplIDnmbvlvZXvvJvnoa7lrprvvJrlpI3liLZUb2tlbilcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgY29uZmlybTogJC50b1N0cmluZygodG9rZW4pID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImNvcHk6Ly9cXFwiICsgdG9rZW47XFxuICAgICAgICAgICAgICAgICAgICB9LCBhbGkucmVmcmVzaF90b2tlbiksXFxuICAgICAgICAgICAgICAgICAgICBjYW5jZWw6ICQudG9TdHJpbmcoKHBhdGgxLCBwYXRoMikgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAkKFxcXCLnoa7orqTms6jplIDnmbvlvZVcXFwiKS5jb25maXJtKChwYXRoMSwgcGF0aDIpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVsZXRlRmlsZShwYXRoMSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZUZpbGUocGF0aDIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5bey5oiQ5Yqf6YCA5Ye655m76ZmGXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgICB9LCBwYXRoMSwgcGF0aDIpO1xcbiAgICAgICAgICAgICAgICAgICAgfSwgYWxpVG9rZW5zRmlsZXBhdGgsIG9wZW5Ub2tlbnNGaWxlcGF0aClcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIHJldHVybjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaW5wdXQgPSBpbnB1dC5yZXBsYWNlKFxcXCLmqKHlvI/vvJpcXFwiLCBcXFwiXFxcIik7XFxuICAgICAgICAgICAgc2V0SXRlbShcXFwib3Blbk1vZGVcXFwiLCBpbnB1dCk7XFxuICAgICAgICAgICAgdXBkYXRlSXRlbShpZHMsIHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLorr7nva58XFxcIiArIGlucHV0XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgaWY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vdXApICsgMTtcXG4gICAgICAgICAgICBncm91cC51bnNoaWZ0KFxcXCLwn5Kh5YWo6YOo8J+SoVxcXCIpO1xcbiAgICAgICAgICAgIGxldCBzZWxlY3ROdW0gPSAkLnJlcXVpcmUoXFxcImRhdGFcXFwiKS5maW5kTW9kdWxvKGdyb3VwLmxlbmd0aCk7XFxuICAgICAgICAgICAgcmV0dXJuICQoZ3JvdXAsIHNlbGVjdE51bSwgXFxcIuivt+mAieaLqeWIhue7hFxcXCIsIGluZGV4KS5zZWxlY3QoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICBpZiAoIU1ZX0lOREVYKSB7XFxuICAgICAgICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJydWxlR3JvdXBcXFwiLCBcXFwiXFxcIik7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJydWxlR3JvdXBcXFwiLCBpbnB1dCk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgY2xlYXJJdGVtKFxcXCJydWxlXFxcIik7XFxuICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9KSxcXG4gICAgICAgIGNvbF90eXBlOiBcXFwic2Nyb2xsX2J1dHRvblxcXCJcXG4gICAgfSwge1xcbiAgICAgICAgdGl0bGU6IFxcXCJcXFwiID09IHIgPyBcXFwi4oCc4oCc5YWo6YOo4oCd4oCdXFxcIiA6IFxcXCLlhajpg6hcXFwiLFxcbiAgICAgICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKChzLCBpZCkgPT4ge1xcbiAgICAgICAgICAgIGxldCBxciA9IGdldEl0ZW0oXFxcInJ1bGVcXFwiLCBcXFwiXFxcIik7XFxuICAgICAgICAgICAgY2xlYXJJdGVtKFxcXCJydWxlXFxcIik7XFxuICAgICAgICAgICAgaWYgKHMpIHtcXG4gICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKFxcXCLlhajpg6hcXFwiICsgaWQsIHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi4oCc4oCc5YWo6YOo4oCd4oCdXFxcIlxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgaWYgKHFyKSB7XFxuICAgICAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKGlkICsgcXIsIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogcXJcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICB9LCBzLCBpZCksXFxuICAgICAgICBjb2xfdHlwZTogXFxcInNjcm9sbF9idXR0b25cXFwiLFxcbiAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICBpZDogXFxcIuWFqOmDqFxcXCIgKyBpZFxcbiAgICAgICAgfVxcbiAgICB9KTtcXG4gICAgZm9yIChsZXQgW2l0LCBiYXNpY1VybF0gb2YgcnVsZXMpIHtcXG4gICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgdGl0bGU6IGl0ID09IHIgPyBcXFwi4oCc4oCcXFxcIiArIGl0ICsgXFxcIuKAneKAnVxcXCIgOiBpdCxcXG4gICAgICAgICAgICB1cmw6ICQoKGdldEhvbWUoYmFzaWNVcmwpIHx8IFxcXCJcXFwiKSArIFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKChyLCBzLCBpZCkgPT4ge1xcbiAgICAgICAgICAgICAgICBsZXQgcXIgPSBnZXRJdGVtKFxcXCJydWxlXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJydWxlXFxcIiwgcik7XFxuICAgICAgICAgICAgICAgIGlmIChzKSB7XFxuICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgdXBkYXRlSXRlbShxciA/IChpZCArIHFyKSA6IChcXFwi5YWo6YOoXFxcIiArIGlkKSwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBxciB8fCBcXFwi5YWo6YOoXFxcIlxcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKGlkICsgciwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi4oCc4oCcXFxcIiArIHIgKyBcXFwi4oCd4oCdXFxcIlxcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICB9LCBpdCwgcywgaWQpLFxcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwic2Nyb2xsX2J1dHRvblxcXCIsXFxuICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgaWQ6IGlkICsgaXRcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9KTtcXG4gICAgfVxcblxcbn1cXG5cXG5mdW5jdGlvbiByZWNvcmQoKSB7XFxuICAgIGxldCBoaXN0b3J5ID0gc3RvcmFnZTAuZ2V0SXRlbShcXFwic2VhcmNoSGlzdG9yeVxcXCIsIFtdKTtcXG4gICAgbGV0IGlpID0gaGlzdG9yeS5pbmRleE9mKHMpO1xcbiAgICBpZiAoaWkgPiAtMSkge1xcbiAgICAgICAgaGlzdG9yeS5zcGxpY2UoaWksIDEpO1xcbiAgICB9XFxuICAgIGlmIChoaXN0b3J5Lmxlbm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AgICAgICAgICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJC5yZXF1aXJlKFxcXCJkYXRhXFxcIikuY2FycnlSdWxlKHJ1bGUsIHMsIHJlYWxQYWdlLCBzZWFyY2hNb2RlKTtcXG4gICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBsb2cocnVsZS5uYW1lICsgXFxcIjpcXFwiICsgZS50b1N0cmluZygpKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAvKmlmKGRhdGEubGVuZ3RoPT09MSYmcD09PTEpe1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW3tcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOlxcXCLigJzigJxcXFwiK3J1bGUubmFtZStcXFwiIEVSUk9S4oCd4oCdXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc2M6IGUudG9TdHJpbmcoKSxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbF90eXBlOlxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVybDpcXFwiaGlrZXI6Ly9lbXB0eVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBleHRyYTp7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGluZVZpc2libGU6IGZhbHNlXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1dO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH0qL1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgLy9yZXR1cm4gcnVsZS5maW5kKHMsIHJlYWxQYWdlKTtcXG4gICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgcGFyYW06IGl0LFxcbiAgICAgICAgICAgICAgICBpZDogXFxcInJ1bGVAXFxcIiArIGl0Lm5hbWVcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9KTtcXG5cXG4gICAgICAgIGJhdGNoRXhlY3V0ZSh0YXNrcywge1xcbiAgICAgICAgICAgIGZ1bmM6IGZ1bmN0aW9uKHBhcmFtLCBpZCwgZXJyb3IsIHJlc3VsdCkge1xcbiAgICAgICAgICAgICAgICBwYXJhbS5pICs9IDE7XFxuICAgICAgICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KHJlc3VsdCkpIHtcXG4gICAgICAgICAgICAgICAgICAgIGRlbGV0ZUl0ZW0oXFxcIl9ub3RoYXZlXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICBhZGRJdGVtQmVmb3JlKHBhZ2VpZCwgcmVzdWx0KTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBpZiAocGFyYW0uaSA9PT0gcGFyYW0uYWxsKSB7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoIXJlc3VsdCB8fCAhcmVzdWx0Lmxlbmd0aCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZUl0ZW0oXFxcIl9ub3RoYXZlXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgYWRkSXRlbUJlZm9yZShwYWdlaWQsIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdXJsOiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi4oCc4oCc4oCd4oCdXFxcIiArIFxcXCJ+fn7ku4DkuYjotYTmupDpg73msqHmnInlk6Z+fn5cXFwiLmZvbnRjb2xvcihcXFwiR3JheVxcXCIpLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGluZVZpc2libGU6IGZhbHNlLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWQ6IFxcXCJfbm90aGF2ZVxcXCJcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgZGVsZXRlSXRlbShwYWdlaWQpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgdXBkYXRlSXRlbShwYWdlaWQsIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuWKoOi9veesrFxcXCIgKyBNWV9QQUdFICsgXFxcIumhteS4re+8jOi/m+W6pu+8mlxcXCIgKyAocGFyYW0uaSArIDEpICsgXFxcIi9cXFwiICsgcGFyYW0uYWxsLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgdXJsOiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCJcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICBwYXJhbToge1xcbiAgICAgICAgICAgICAgICBhbGw6IGRhdGEubGVuZ3RoLFxcbiAgICAgICAgICAgICAgICBpOiAwLFxcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0pXFxuICAgIH1cXG59XFxuXFxuZnVuY3Rpb24gc2V0SGlzdG9yeSgpIHtcXG4gICAgZC5wdXNoKHtcXG4gICAgICAgIHRpdGxlOiAnPHNwYW4gc3R5bGU9XFxcImNvbG9yOiNmZjY2MDFcXFwiPjxiPuWOhuWPsuiusOW9lTwvYj48L3NwYW4+JyxcXG4gICAgICAgIHBpY191cmw6IFxcXCJoaWtlcjovL2ltYWdlcy9pY29uX2Nsb2NrXFxcIixcXG4gICAgICAgIGNvbF90eXBlOiBcXFwiYXZhdGFyXFxcIixcXG4gICAgICAgIHVybDogJChbXFxcIua4hemZpOaQnOe0ouiusOW9lVxcXCIsIFxcXCLmiZPlvIDop4LnnIvorrDlvZVcXFwiXSkuc2VsZWN0KChpZCkgPT4ge1xcbiAgICAgICAgICAgIGlmIChpbnB1dCA9PT0gXFxcIua4hemZpOaQnOe0ouiusOW9lVxcXCIpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuICQoXFxcIuehruWumua4hemZpOWFqOmDqOaQnOe0ouiusOW9le+8n1xcXCIpLmNvbmZpcm0oKGlkKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBjbGVhckl0ZW0oXFxcInNlYXJjaEhpc3RvcnlcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIGRlbGV0ZUl0ZW1CeUNscyhpZCArIFxcXCI6a2V5XFxcIik7XFxuICAgICAgICAgICAgICAgICAgICBhZGRJdGVtQWZ0ZXIoaWQgKyBcXFwiOnNlYXJjaEhpc3RvcnlcXFwiLCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuKAnOKAnOKAneKAnVxcXCIgKyBcXFwifn5+5LuA5LmI6YO95rKh5pyJ5ZOmfn5+XFxcIi5mb250Y29sb3IoXFxcIkdyYXlcXFwiKSxcXG4gICAgICAgICAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbHM6IGlkICsgXFxcIjprZXlcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2VcXG4gICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgfSwgaWQpO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9oaXN0b3J5P3J1bGU9XFxcIiArIE1ZX1JVTEUudGl0bGU7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSwgaWQpLFxcbiAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICBpZDogaWQgKyBcXFwiOnNlYXJjaEhpc3RvcnlcXFwiLFxcbiAgICAgICAgfVxcbiAgICB9KTtcXG5cXG4gICAgbGV0IGhpc3RvcnkgPSBzdG9yYWdlMC5nZXRJdGVtKFxcXCJzZWFyY2hIaXN0b3J5XFxcIiwgW10pO1xcbiAgICBsZXQgaSA9IDA7XFxuICAgIGZvciAobGV0IGtleSBvZiBoaXN0b3J5KSB7XFxuICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgIHRpdGxlOiBrZXksXFxuICAgICAgICAgICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKChpZCwga2V5KSA9PiB7XFxuICAgICAgICAgICAgICAgIGxldCBleHRyYSA9IGZpbmRJdGVtKGlkICsgXFxcInNzXFxcIikuZXh0cmE7XFxuICAgICAgICAgICAgICAgIGV4dHJhLmRlZmF1bHRWYWx1ZSA9IGtleTtcXG4gICAgICAgICAgICAgICAgdXBkYXRlSXRlbSh7XFxuICAgICAgICAgICAgICAgICAgICBleHRyYTogZXh0cmFcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgICAgfSwgaWQsIGtleSksXFxuICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJmbGV4X2J1dHRvblxcXCIsXFxuICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgaWQ6IGlkICsgXFxcIjprZXk6XFxcIiArIGtleSxcXG4gICAgICAgICAgICAgICAgY2xzOiBpZCArIFxcXCI6a2V5XFxcIixcXG4gICAgICAgICAgICAgICAgbG9uZ0NsaWNrOiBbe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLliKDpmaTlhbPplK7or406XFxcIiArIGtleSxcXG4gICAgICAgICAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKChpZCwga2V5LCBpKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGhpc3RvcnkgPSBzdG9yYWdlMC5nZXRJdGVtKFxcXCJzZWFyY2hIaXN0b3J5XFxcIiwgW10pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGhpc3Rvcnkuc3BsaWNlKGksIDEpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JhZ2UwLnNldEl0ZW0oXFxcInNlYXJjaEhpc3RvcnlcXFwiLCBoaXN0b3J5KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBkZWxldGVJdGVtKGlkICsgXFxcIjprZXk6XFxcIiArIGtleSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgLy90b2FzdCgpO1xcbiAgICAgICAgICAgICAgICAgICAgfSwgaWQsIGtleSwgaSlcXG4gICAgICAgICAgICAgICAgfV1cXG4gICAgICAgICAgICB9XFxuICAgICAgICB9KTtcXG4gICAgICAgIGkrKztcXG4gICAgfVxcbiAgICBpZiAoaGlzdG9yeS5sZW5ndGggPT09IDApIHtcXG4gICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuKAnOKAnOKAneKAnVxcXCIgKyBcXFwifn5+5LuA5LmI6YO95rKh5pyJ5ZOmfn5+XFxcIi5mb250Y29sb3IoXFxcIkdyYXlcXFwiKSxcXG4gICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICBjbHM6IGlkICsgXFxcIjprZXlcXFwiLFxcbiAgICAgICAgICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2VcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9KTtcXG4gICAgfVxcbn1cXG5cXG5mdW5jdGlvbiBzZXRUcmVuZGluZ1RhYkVuZCgpIHtcXG4gICAgbGV0IGhvdENsYXNzID0ge1xcbiAgICAgICAgXFxcIueZvuW6plxcXCI6IHtcXG4gICAgICAgICAgICBcXFwi55S16KeG5YmnXFxcIjogXFxcInRlbGVwbGF5XFxcIixcXG4gICAgICAgICAgICBcXFwi55S15b2xXFxcIjogXFxcIm1vdmllXFxcIlxcbiAgICAgICAgfSxcXG4gICAgICAgIFxcXCLlpLjlhYtcXFwiOiB7XFxuICAgICAgICAgICAgXFxcIueUteinhuWJp1xcXCI6IFxcXCLnlLXop4bliadcXFwiLFxcbiAgICAgICAgICAgIFxcXCLnlLXlvbFcXFwiOiBcXFwi55S15b2xXFxcIixcXG4gICAgICAgICAgICBcXFwi5Yqo5ryrXFxcIjogXFxcIuWKqOa8q1xcXCIsXFxuICAgICAgICAgICAgXFxcIue7vOiJulxcXCI6IFxcXCLnu7zoibpcXFwiXFxuICAgICAgICB9XFxuICAgIH07XFxuICAgIGxldCBkYXRhU291cmNlID0gT2JqZWN0LmtleXMoaG90Q2xhc3MpO1xcbiAgICBsZXQgc2VsZWN0c291cmNlID0gZ2V0SXRlbShcXFwiZGF0YVNvdXJjZVxcXCIsIGRhdGFTb3VyY2VbMF0pO1xcbiAgICBsZXQgaG90a2V5cyA9IE9iamVjdC5rZXlzKGhvdENsYXNzW3NlbGVjdHNvdXJjZV0pO1xcbiAgICBsZXQgc2VsZWN0a2V5ID0gZ2V0SXRlbShcXFw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tKFxcXCJob3RrZXlcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+W3suWIh+aNouS4ulxcXCIgKyBpbnB1dDtcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9LCBkYXRhU291cmNlKVxcbiAgICAgICAgICAgIH1dXFxuICAgICAgICB9XFxuICAgIH0pO1xcbiAgICBkLnB1c2goe1xcbiAgICAgICAgdGl0bGU6IFxcXCLmraPlnKjliqDovb0uLi5cXFwiLFxcbiAgICAgICAgdXJsOiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCIsXFxuICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbiAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICBpZDogaWQgKyBcXFwiOmhvdGtleVxcXCIsXFxuICAgICAgICAgICAgbGluZVZpc2libGU6IGZhbHNlXFxuICAgICAgICB9XFxuICAgIH0pO1xcbiAgICBzZXRSZXN1bHQoZCk7XFxuICAgIGxldCBzZCA9IFtdO1xcbiAgICBsZXQgc2V0U2VhcmNoS2V5ID0gbmFtZSA9PiB7XFxuICAgICAgICBwdXRNeVZhcigncycsIG5hbWUpO1xcbiAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgIHJldHVybiAnaGlrZXI6Ly9lbXB0eSdcXG4gICAgfTtcXG5cXG4gICAgbGV0IGdldFRpdGxlID0gKGksIG5hbWUpID0+IHtcXG4gICAgICAgIGxldCBjb2xvcjtcXG4gICAgICAgIHN3aXRjaCAoaSkge1xcbiAgICAgICAgICAgIGNhc2UgMDpcXG4gICAgICAgICAgICAgICAgY29sb3IgPSBcXFwiI2ZmMzMwMFxcXCI7XFxuICAgICAgICAgICAgICAgIGJyZWFrO1xcbiAgICAgICAgICAgIGNhc2UgMTpcXG4g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ICd0b3AuYmFpZHUuY29tJyxcXG4gICAgICAgICAgICAgICAgICAgICAgICAnQWNjZXB0JzogJ2FwcGxpY2F0aW9uL2pzb24sIHRleHQvcGxhaW4sICovKicsXFxuICAgICAgICAgICAgICAgICAgICAgICAgJ0FjY2VwdC1MYW5ndWFnZSc6ICd6aC1DTix6aDtxPTAuOSxlbi1VUztxPTAuOCxlbjtxPTAuNycsXFxuICAgICAgICAgICAgICAgICAgICAgICAgJ0FjY2VwdC1FbmNvZGluZyc6ICdnemlwLCBkZWZsYXRlLCBicicsXFxuICAgICAgICAgICAgICAgICAgICAgICAgJ1JlZmVyZXInOiAnaHR0cHM6Ly90b3AuYmFpZHUuY29tL2JvYXJkP3RhYj1ub3ZlbCcsXFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAvL3ZhciBzID0gRGF0ZS5ub3coKTtcXG4gICAgICAgICAgICAgICAgdmFyIGxpc3QgPSBKU09OLnBhcnNlKGpzb24pLmRhdGEuY2FyZHNbMF0uY29udGVudDtcXG4gICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBsaXN0Lmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgaXRlbSA9IGxpc3RbaV07XFxuICAgICAgICAgICAgICAgICAgICBsZXQgbmFtZSA9IGl0ZW0ud29yZCArICcgKCcgKyBpdGVtLnNob3dbMl0gKyAnKSc7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgZGVzID0gaXRlbS5kZXNjO1xcbiAgICAgICAgICAgICAgICAgICAgc2QucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IGdldFRpdGxlKGksIG5hbWUpLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHVybDogJCgnI25vTG9hZGluZyMnKS5sYXp5UnVsZShzZXRTZWFyY2hLZXksIGl0ZW0ud29yZCksXFxuICAgICAgICAgICAgICAgICAgICAgICAgZGVzYzogZGVzLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGltZzogaXRlbS5pbWcsXFxuICAgICAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJtb3ZpZV8xX3ZlcnRpY2FsX3BpY1xcXCJcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGJyZWFrO1xcbiAgICAgICAgICAgIGNhc2UgXFxcIuWkuOWFi1xcXCI6XFxuICAgICAgICAgICAgICAgIHZhciBqc29uID0gcmVxdWVzdChcXFwiaHR0cHM6Ly9uZXdzLm15cXVhcmsuY24vdjIvdG9wbGlzdC9tb3ZpZT8mY2hhbm5lbD1cXFwiICsgdGFia2V5ICsgXFxcIiZyYW5rX3R5cGU9JUU2JTlDJTgwJUU3JTgzJUFEXFxcIik7XFxuICAgICAgICAgICAgICAgIHZhciB4bWxEYXRhID0gKEpTT04ucGFyc2UoanNvbikuZGF0YSB8fCBcXFwiXFxcIikucmVwbGFjZSgvdGl0bGU+L2csIFxcXCJoX3RpdGxlPlxcXCIpLnJlcGxhY2UoL3NyYz4vZywgXFxcImhfc3JjPlxcXCIpLnJlcGxhY2UoL2FyZWE+L2csIFxcXCJoX2FyZWFcXFwiKTtcXG4gICAgICAgICAgICAgICAgdmFyIGxpc3QgPSBwZGZhKHhtbERhdGEsIFxcXCJib2R5JiZpdGVtXFxcIik7XFxuICAgICAgICAgICAgICAgIHZhciBnZXRUZXh0ID0gdCA9PiB0O1xcbiAgICAgICAgICAgICAgICB2YXIgdHJlbmQgPSBbXFxcIuOEp1xcXCIsIFxcXCLihpFcXFwiLCBcXFwi4oaTXFxcIl07XFxuICAgICAgICAgICAgICAgIC8vdmFyIHMgPSBEYXRlLm5vdygpO1xcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGxpc3QubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgICAgIG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gMV07XFxuICAgIH1cXG4gICAgaWYgKGlucHV0LnN0YXJ0c1dpdGgoXFxcIm1hZ25ldFxcXCIpKSB7XFxuICAgICAgICBjb25maXJtKHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIua4qemmqOaPkOekulxcXCIsXFxuICAgICAgICAgICAgY29udGVudDogXFxcIuajgOa1i+WIsOaWsOeahOejgemTvuWcsOWdgO+8jOeCueWHu+ehruWumuaMiemSruWNs+WPr+aSreaUvu+8jOeCueWHu+WPlua2iOaMiemSruWPr+S7peWkjeWItumTvuaOpVxcXCIsXFxuICAgICAgICAgICAgY29uZmlybTogJC50b1N0cmluZygobWFnKSA9PiB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBtYWc7XFxuICAgICAgICAgICAgfSwgaW5wdXQpLFxcbiAgICAgICAgICAgIGNhbmNlbDogJC50b1N0cmluZygobWFnKSA9PiB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwiY29weTovL1xcXCIgKyBtYWdcXG4gICAgICAgICAgICB9LCBpbnB1dClcXG4gICAgICAgIH0pO1xcbiAgICAgICAgcmV0dXJuIHRydWU7XFxuICAgIH0gZWxzZSBpZiAoJC5yZXF1aXJlKFxcXCJhbGl0ZXN0P3J1bGU9XFxcIitydWxlKS50ZXN0KGlucHV0KSAmJiBvcGVuTW9kZSAhPSBcXFwi5a6Y5pa5QVBQXFxcIikge1xcbiAgICAgICAgbG9nKGlucHV0KTtcXG4gICAgICAgIGlmIChpbnB1dC5pbmNsdWRlcygnY2hlY2t1cmw/dXJsPScpICYmIGlucHV0LmluY2x1ZGVzKCcmdXJscmVmZXInKSkge1xcbiAgICAgICAgICAgIGlucHV0ID0gZGVjb2RlVVJJQ29tcG9uZW50KGlucHV0LnNwbGl0KCcmdXJscmVmZXInKVswXS5zcGxpdCgnY2hlY2t1cmw/dXJsPScpWzFdKTtcXG4gICAgICAgICAgICAvL2xvZygn6LS05ZCnJytpbnB1dCk7XFxuICAgICAgICB9XFxuICAgICAgIC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ykuc3BsaXQoXFxcIiZcXFwiKVswXSk7XFxuICAgICAgICAgICAgICAgIGlmICh1cmwuc3Vic3RyKHVybC5pbmRleE9mKCcvbWVkaWEtJyksIHVybC5pbmRleE9mKCcudHMnKSkgPT0gZnVybC5zdWJzdHIoZnVybC5pbmRleE9mKCcvbWVkaWEtJyksIGZ1cmwuaW5kZXhPZignLnRzJykpKSB7XFxuICAgICAgICAgICAgICAgICAgICB1cmwgPSBmdXJsO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSlcXG4gICAgICAgIGxldCBleHBpcmVzID0gdXJsLnNwbGl0KCd4LW9zcy1leHBpcmVzPScpWzFdLnNwbGl0KCcmJylbMF07XFxuICAgICAgICBjb25zdCBsYXN0dGltZSA9IHBhcnNlSW50KGV4cGlyZXMpIC0gRGF0ZS5ub3coKSAvIDEwMDA7XFxuICAgICAgICBpZiAobGFzdHRpbWUgPCA2MCkge1xcbiAgICAgICAgICAgIC8vbG9nKCfov4fmnJ/mm7TmlrAnKVxcbiAgICAgICAgICAgIGxldCBsaW5lID0gdXJsLnNwbGl0KCcvbWVkaWEnKVswXTsgLy/lj5bkuYvliY3mkq3mlL7nmoR0c+autee6v+i3r1xcbiAgICAgICAgICAgIGxpbmUgPSBsaW5lLnN1YnN0cmluZyhsaW5lLmxhc3RJbmRleE9mKCcvJykgKyAxKTtcXG4gICAgICAgICAgICBsZXQgZiA9IGdldE0zdThDb250ZW50KGdldEFsaVBsYXlVcmwoZmlkLCBsaW5lKSkuc3BsaXQoXFxcIlxcXFxuXFxcIik7XFxuICAgICAgICAgICAgZi5mb3JFYWNoKGl0ID0+IHtcXG4gICAgICAgICAgICAgICAgaWYgKGl0ICYmIGl0LnN0YXJ0c1dpdGgoJy9wcm94eT91cmw9JykpIHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBmdXJsID0gYmFzZTY0RGVjb2RlKGl0LnJlcGxhY2UoJy9wcm94eT91cmw9JywgJycpKTtcXG4gICAgICAgICAgICAgICAgICAgIGlmICh1cmwuc3Vic3RyKHVybC5pbmRleE9mKCcvbWVkaWEtJyksIHVybC5pbmRleE9mKCcudHMnKSkgPT0gZnVybC5zdWJzdHIoZnVybC5pbmRleE9mKCcvbWVkaWEtJyksIGZ1cmwuaW5kZXhPZignLnRzJykpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdXJsID0gZnVybDtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pXFxuXFxuICAgICAgICB9XFxuICAgICAgICByZXR1cm4gdXJsO1xcbiAgICB9XFxuICAgIHRyeSB7XFxuICAgICAgICBsZXQgdXJsID0gYmFzZTY0RGVjb2RlKE1ZX1BBUkFNUy51cmxbMF0pO1xcbiAgICAgICAgaWYgKHVybC5pbmNsdWRlcyhcXFwiLnRzXFxcIikpIHtcXG4gICAgICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkoe1xcbiAgICAgICAgICAgICAgICBzdGF0dXNDb2RlOiAzMDIsXFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJMb2NhdGlvblxcXCI6IHVwZGF0ZVRzVXJsKHVybCksXFxuICAgICAgICAgICAgICAgICAgICBcXFwiVXNlci1BZ2VudFxcXCI6IFBDX1VBLFxcbiAgICAgICAgICAgICAgICAgICAgXFxcIlJlZmVyZXJcXFwiOiBcXFwiaHR0cHM6Ly93d3cuYWxpeXVuZHJpdmUuY29tL1xcXCJcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBsZXQgdGVtcGxhdGVJZCA9IE1ZX1BBUkFNUy50ZW1wbGF0ZUlkWzBdO1xcbiAgICAgICAgICAgIGlmKGZpbGVFeGlzdChjYWNoZUZpbGVQYXRoKSl7XFxuICAgICAgICAgICAgICAgIH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mlL7or7fmuIXnkIbjgIJcXFwiO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5pKt5pS+5aSx6LSl77yM6ZSZ6K+v5L+h5oGv5bey5omT5Y2w44CCXFxcXG7or7fmn6XnnIvml6Xlv5coTE9HKVxcXCI7XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgbW91bnRzdWIgPSBzdG9yYWdlMC5nZXRNeVZhcignbW91bnR6aW11Jywge30pO1xcbiAgICAgICAgaWYgKE9iamVjdC5rZXlzKG1vdW50c3ViKS5sZW5ndGggPiAwKSB7XFxuICAgICAgICAgICAgemltdSA9IG1vdW50c3ViO1xcbiAgICAgICAgfVxcbiAgICAgICAgbGV0IHN1YnRpdGxlO1xcbiAgICAgICAgaWYgKE9iamVjdC5rZXlzKHppbXUgfHwge30pLmxlbmd0aCA+IDAgJiYgcGxheUxpc3QgJiYgcGxheUxpc3QudXJscyAmJiBwbGF5TGlzdC51cmxzLmxlbmd0aCA+IDApIHtcXG4gICAgICAgICAgICBqYXZhLmxhbmcuVGhyZWFkLnNsZWVwKDEwMCk7XFxuICAgICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAgICAgdmFyIHptdXJsID0gYWxpQWNjZXNzQXBpLmdldFZpZGVvVGVtUGxheVVybCh6aW11LmZpbGVfaWQpO1xcbiAgICAgICAgICAgICAgICBsZXQgcGF0aCA9ICdoaWtlcjovL2ZpbGVzL2NhY2hlL+S6keebmOWQmy9zdWIuJyArIHppbXUuZXh0O1xcbiAgICAgICAgICAgICAgICBkb3dubG9hZEZpbGUoem11cmwsIHBhdGgsIHtcXG4gICAgICAgICAgICAgICAgICAgICdSZWZlcmVyJzogJ2h0dHBzOi8vd3d3LmFsaXl1bmRyaXZlLmNvbS8nXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICBzdWJ0aXRsZSA9IGdldFBhdGgocGF0aCk7XFxuICAgICAgICAgICAgfSBjY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sZXQgc2hhcmVJbmZvID0gYWxpU2hhcmVBcGkuZ2V0U2hhcmVJbmZvKCk7XFxuICAgICAgICAgICAgbGV0IGZpbGVJbmZvID0gc2hhcmVJbmZvLmZpbGVfaW5mb3MgfHwgW107XFxuICAgICAgICAgICAgaWYgKGZpbGVJbmZvLmxlbmd0aCA9PT0gMSAmJiBmaWxlSW5mb1swXS50eXBlID09PSBcXFwiZm9sZGVyXFxcIiAmJiAhZmlsZUlkKSB7XFxuICAgICAgICAgICAgICAgIGZpbGVJZCA9IGZpbGVJbmZvWzBdLmZpbGVfaWQ7XFxuICAgICAgICAgICAgICAgIHNldE15UGFDYWNoZShcXFwiZmlsZUlkXFxcIiwgZmlsZUlkKTtcXG4gICAgICAgICAgICAgICAgc2V0UGFnZVRpdGxlKGZpbGVJbmZvWzBdLmZpbGVfbmFtZSk7XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgc2V0UGFnZVRpdGxlKHNoYXJlSW5mby5zaGFyZV9uYW1lKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IGRlYWRsaW5lID0gXFxcIuawuOS5heacieaViFxcXCI7XFxuXFxuICAgICAgICAgICAgaWYgKHNoYXJlSW5mby5leHBpcmF0aW9uKSB7XFxuICAgICAgICAgICAgICAgIGRlYWRsaW5lID0gXFxcIuacieaViOiHs++8mlxcXCIgKyBmb3JtYXREYXRlKHNoYXJlSW5mby5leHBpcmF0aW9uKTtcXG4gICAgICAgICAgICAgICAgLy9zaGFyZUluZm8udXBkYXRlZF9hdFxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IChzaGFyZUluZm8uY3JlYXRvcl9uYW1lIHx8IHNoYXJlSW5mby5jcmVhdG9yX3Bob25lKSArIFxcXCImbmJzcDsmbmJzcDtcXFwiICsgZGVhZGxpbmUuc21hbGwoKSxcXG4gICAgICAgICAgICAgICAgdXJsOiByZWFsdXJsICsgXFxcIiNub0hpc3RvcnkjXFxcIixcXG4gICAgICAgICAgICAgICAgaW1nOiBzaGFyZUluZm8uYXZhdGFyIHx8IFxcXCJoaWtlcjovL2ltYWdlcy9pY29uX3Vua25vd25cXFwiLFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcImF2YXRhclxcXCJcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH1cXG4gICAgICAgIGlmICghaXNTZWFyY2gpIHtcXG4gICAgICAgICAgICBpdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLmkJzntKJcXFwiLFxcbiAgICAgICAgICAgICAgICB1cmw6ICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgaW5wdXQgPSBpbnB1dC50cmltKCk7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoIWlucHV0KSByZXR1cm4gXFxcInRvYXN0Oi8v6K+36L6T5YWl5YWz6ZSu6K+NXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL2FsaXl1biNub0hpc3RvcnkjI2Z1bGxUaGVtZSM/cGFnZT1meXBhZ2Umc2VhcmNoS2V5PVxcXCIgKyBlbmNvZGVVUklDb21wb25lbnQoaW5wdXQpO1xcbiAgICAgICAgICAgICAgICB9KSxcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJpbnB1dFxcXCIsXFxuICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICBvbkNoYW5nZTogXFxcInB1dE15VmFyKCdsaXN0U2VhcmNoS2V5JyxpbnB1dClcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgc2hhcmVQd2Q6IHNoYXJlUHdkLFxcbiAgICAgICAgICAgICAgICAgICAgc2hhcmVJZDogc2hhcmVJZCxcXG4gICAgICAgICAgICAgICAgICAgIHNoYXJlVG9rZW46IHNoYXJlVG9rZW5cXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBpdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLigJzigJxcXFwiICsgc2VhcmNoS2V5ICsgXFxcIuKAneKAneeahOaQnOe0oue7k+aenFxcXCIsXFxuICAgICAgICAgICAgICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgbGluZVZpc2libGU6IGZhbHNlXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH1cXG4gICAgICAgIGxldCBmdW5jSXRlbXMgPSBbXTtcXG4gICAgICAgIGZ1bmNJdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICB0aXRsZTogc3R5bGUsXFxuICAgICAgICAgICAgdXJsOiAkKHN0eWxlcywgMSwgXFxcIuaOkuW4g+agt+W8j1xcXCIpLnNlbGVjdCgoKSA9PiB7XFxuICAgICAgICAgICAgICAgIHNldEl0ZW0oXFxcImFsaXl1bl9zdHlsZVxcXCIsIGlucHV0KTtcXG4gICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+W3suWIh+aNolxcXCI7XFxuICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgcGljX3VybDogXFxcImh0dHBzOi8vaGlrZXJmYW5zLmNvbS9pbWcvYWxpX2ljb24uc3ZnXFxcIlxcbiAgICAgICAgfSwge1xcbiAgICAgICAgICAgIHRpdGxlOiBvcmRlck5hbWUsXFxuICAgICAgICAgICAgdXJsOiAkKG9yZGVyc0tleXMsIDIsIFxcXC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TliJlcXFwiLCBcXFwi5om56YeP5oyC6L295pys5Zyw5by55bmVXFxcIiwgXFxcIuaOqOmAgeWIsFRWQm94XFxcIiwgXFxcIuiuvue9ruaUtuiXj+WwgemdolxcXCIsIFxcXCLojrflj5bmipXlsY9JUFxcXCIgLCBcXFwi5p6B6YCf5Y6f55S75LiL6L2957q/56iLXFxcIiAsIFxcXCLovazlrZjlvZPliY3mlofku7blpLlcXFwiXSwgMiwgXFxcIuabtOWkmuWKn+iDvVxcXCIpLnNlbGVjdCgoc2hhcmVJZCwgc2hhcmVQd2QsIGZpbGVJZCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChpbnB1dCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgXFxcIui9rOWtmOS6keebmFxcXCI6XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBgc21hcnRkcml2ZTovL3NoYXJlL2Jyb3dzZT9zaGFyZUlkPSR7c2hhcmVJZH0mc2hhcmVQd2Q9JHtzaGFyZVB3ZHx8XFxcIlxcXCJ9YDtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFxcXCLnmbvpmYbotKblj7dcXFwiOlxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vcGFnZS9sb2dpbiNub1JlY29yZEhpc3RvcnkjI25vSGlzdG9yeSNcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgXFxcIuWkjeWItuWIhuS6q+mTvuaOpVxcXCI6XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAkKFtcXFwi5aSN5Yi26ZO+5o6lXFxcIiwgXFxcIuWkjeWItua1t+mYlOWPo+S7pFxcXCJdLCAxLCBcXFwi5YiG5Lqr5pa55byPXFxcIikuc2VsZWN0KCh1cmwpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbnB1dCA9PT0gXFxcIuWkjeWItumTvuaOpVxcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImNvcHk6Ly9cXFwiICsgdXJsO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImNvcHk6Ly/pmL/ph4zkupHnm5jliIbkuqvlj6Pku6TjgIxcXFwiICsgZ2V0UGFnZVRpdGxlKCkgKyBcXFwi44CNXFxcXG5cXFwiICsgdXJsICsgXFxcIiBAaW1wb3J0PWpzOmBoaWtlcjovL3BhZ2UvYWxpeXVuP3JlYWx1cmw9JHtpbnB1dC50cmltKCl9JnJ1bGU9XFxcIiArIE1ZX1JVTEUudGl0bGUgKyBcXFwiYDtcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LCBcXFwiaHR0cHM6Ly93d3cuYWxpeXVuZHJpdmUuY29tL3MvXFxcIiArIHNoYXJlSWQgKyAoZmlsZUlkID8gXFxcIi9mb2xkZXIvXFxcIiArIGZpbGVJZCA6IFxcXCJcXFwiKSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBcXFwi5om56YeP5oyC6L295pys5Zyw5by55bmVXFxcIjpcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3BhZ2UvZG1Nb3VudCNub0hpc3RvcnkjI25vUmVjb3JkSGlzdG9yeSNcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgXFxcIuafpeeci+aJi+WKqOaMgui9veWtl+W5lVxcXCI6XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCB6bSA9IHN0b3JhZ2UwLmdldE15VmFyKFxcXCJtb3VudHppbXVcXFwiLCB7fSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCB0aXAgPSB6bS5uYW1lID8gXFxcIuW9k+WJjeWtl+W5leaWh+S7tlxcXFxuXFxcIiArIHptLm5hbWUgKyBcXFwiLlxcXCIgKyB6bS5leHQgOiBcXFwi6L+Y5pyq5omL5Yqo5oyC6L295a2X5bmVXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uZmlybSh7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogJ+aJi+WKqOaMgui9veWtl+W5lScsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250ZW50OiB0aXAgKyBcXFwiXFxcXG4o54K55Ye75Y+W5raI5Y+v5Lul5riF6Zmk5oyC6L295a2X5bmVKVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYW5jZWw6ICgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGVhck15VmFyKFxcXCJtb3VudHppbXVcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5bey5riF6Zmk5omL5Yqo5oyC6L295a2X5bmVXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFxcXCLojrflj5blvLnluZXmkJzntKLop4TliJlcXFwiOlxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZSA9IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFxcXCJqc1xcXCI6IEpTT04uc3RyaW5naWZ5KFxcXCJoaWtlcjovL3BhZ2UvbG9hZERtP3J1bGU9XFxcIiArIE1ZX1JVTEUudGl0bGUgKyBcXFwiJnRpdGxlPVxcXCIpICsgXFxcIitlbmNvZGVVUklDb21wb25lbnQocGxheWRhdGEudGl0bGUuc3BsaXQoJy0nKVswXSk7XFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFxcXCJuYW1lXFxcIjogTVlfUlVMRS50aXRsZSArIFxcXCLlvLnluZXmkJzntKJcXFwiXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwicnVsZTovL1xcXCIgKyBiYXNlNjRFbmNvZGUoXFxcIu+/pXByb2plY3Rpb25fc2NyZWVu77+lXFxcIiArIEpTT04uc3RyaW5naWZ5KHJ1bGUpKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFxcXCLmjqjpgIHliLBUVkJveFxcXCI6XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL3R2Ym94UHVzaCNub0hpc3RvcnkjI25vUmVjb3JkSGlzdG9yeSNcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgXFxcIuiuvue9ruaUtuiXj+WwgemdolxcXCI6XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAkKFtcXFwi6K6+572u5bCB6Z2i5Zyw5Z2AXFxcIiwgXFxcIuaQnOe0ouWwgemdolxcXCJdLCAxKS5zZWxlY3QoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlucHV0ID09PSBcXFwi6K6+572u5bCB6Z2i5Zyw5Z2AXFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAkKFxcXCJcXFwiLCBcXFwi6K+36L6T5YWl5Zu+54mH5Zyw5Z2AXFxcIikuaW5wdXQoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnB1dCA9IGlucHV0LnRyaW0oKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFpbnB1dCkgcmV0dXJuIFxcXCJ0b2FzdDovL+ivt+i+k+WFpeWcsOWdgFxcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldFBhZ2VQaWNVcmwoaW5wdXQpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5L+u5pS55oiQ5YqfXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3BhZ2UvZnJvbnRDb3ZlciNub0hpc3RvcnkjI25vUmVjb3JkSGlzdG9yeSNcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFxcXCLojrflj5bmipXlsY9JUFxcXCI6XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBpcCA9ICQucmVxdWlyZShcXFwiYWxpVXRpbFxcXCIpLmdldElQdjRBZGRyZXNzKCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpcC5zdGFydHNXaXRoKFxcXCIxOTIuMTY4LlxcXCIpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJChpcCArIFxcXCJcXFxcbuivpUlQ6YCC55So5LqO5rWB6YePK+eDreeCueeahOaKleWxj1xcXFxu6K+35pu/5o2i6ZO+5o6l5Lit55qEMC4wLjAuMFxcXCIpLmNvbmZpcm0oKGlwKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJjb3B5Oi8vXFxcIiArIGlwO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwgaXApO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICQoaXAgKyBcXFwiXFxcXG7ojrflj5blpLHotKXpnZ7nqLPlrppJUCzor7flvIDlkK/ng63ngrnlho3kvb/nlKgs6K+lSVDlj6/og73kvJrlj5gs5LiN6IO95oqV5bGPXFxcIikuY29uZmlybSgoKSA9PiB7fSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFxcXCLmnoHpgJ/ljp/nlLvkuIvovb3nur/nqItcXFwiOlxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJChnZXRJdGVtKFxcXCJzcGVlZFRocmVhZFxcXCIsIFxcXCIxMFxcXCIpLCBcXFwi6K+36L6T5YWlMy0zMuS5i+mXtOeahOaVtOaVsFxcXCIpLmlucHV0KCgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzcGVlZFRocmVhZCA9IHBhcnNlSW50KGlucHV0KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzcGVlZFRocmVhZCA8IDMgfHwgc3BlZWRUaHJlYWQgPiAzMikge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/orr7nva7kuI3lkIjms5VcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0SXRlbShcXFwic3BlZWRUaHJlYWRcXFwiLCBTdHJpbmcoc3BlZWRUaHJlYWQpKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/orr7nva7miJDlip9cXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFxcXCLovazlrZjlvZPliY3mlofku7blpLlcXFwiOlxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vcGFnZS9teWFsaXl1biNub0hpc3RvcnkjI25vUmVjb3JkSGlzdG9yeSM/cGFnZT1meXBhZ2VcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9LCBzaGFyZUlkLCBzaGFyZVB3ZCwgZmlsZUlkKSxcXG4gICAgICAgICAgICAgICAgcGljX3VybDogXFxcImh0dHBzOi8vaGlrZXJmYW5zLmNvbS9pbWcvYWxpX2ZpbGVpbnRvLnN2Z1xcXCIsXFxuICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICBwYWdlSWQ6IHBhZ2VJZCxcXG4gICAgICAgICAgICAgICAgICAgIGZpbGVJZDogZmlsZUlkLFxcbiAgICAgICAgICAgICAgICAgICAgc2hhcmVJZDogc2hhcmVJZCxcXG4gICAgICAgICAgICAgICAgICAgIHNoYXJlVG9rZW46IHNoYXJlVG9rZW4sXFxuICAgICAgICAgICAgICAgICAgICBzaGFyZVB3ZDogc2hhcmVQd2QsXFxuICAgICAgICAgICAgICAgICAgICB0cmFuc2ZlcjogdHJ1ZSxcXG4gICAgICAgICAgICAgICAgICAgIGZvbGRlck5hbWU6IGdldFBhZ2VUaXRsZSgpXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgZnVuY0l0ZW1zLnB1c2goe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogW1xcXCJBTExcXFwiLCBcXFwi6Lez6L+H5paH5Lu2XFxcIl1bTnVtYmVyKHNraX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O1xcbiAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0sIGZpbGVJdGVtLnRodW1ibmFpbCk7XFxuICAgICAgICB9XFxuICAgIH1cXG4gICAgbGV0IGZvbGRlclN0eWxlLCBmaWxlU3R5bGU7XFxuICAgIGxldCBmaWx0ZXJUeXBlID0gW107XFxuICAgIGlmIChzdHlsZSA9PT0gXFxcIui/veWJp1xcXCIpIHtcXG4gICAgICAgIGZvbGRlclN0eWxlID0gXFxcImF2YXRhclxcXCI7XFxuICAgICAgICBmaWxlU3R5bGUgPSBcXFwibW92aWVfMlxcXCI7XFxuICAgICAgICBmaWx0ZXJUeXBlLnB1c2goXFxcInZpZGVvXFxcIik7XFxuICAgICAgICBpdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuKAnOKAnOKAneKAnVxcXCIgKyBcXFwi6L+95Ymn5qih5byP5Y+q5pi+56S65paH5Lu25aS55ZKM6KeG6aKRXFxcIi5zbWFsbCgpLmZvbnRjb2xvcihcXFwiZ3JleVxcXCIpLFxcbiAgICAgICAgICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgbGluZVZpc2libGU6IGZhbHNlXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSk7XFxuICAgIH0gZWxzZSBpZiAoc3R5bGUgPT09IFxcXCLnnIvlm75cXFwiKSB7XFxuICAgICAgICBmb2xkZXJTdHlsZSA9IFxcXCJhdmF0YXJcXFwiO1xcbiAgICAgICAgZmlsZVN0eWxlID0gXFxcImNhcmRfcGljXzNcXFwiO1xcbiAgICAgICAgZmlsdGVyVHlwZS5wdXNoKFxcX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ZUl0ZW0ubmFtZTtcXG4gICAgICAgICAgICBpdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IHRpdGxlLFxcbiAgICAgICAgICAgICAgICB1cmw6ICdoaWtlcjovL3BhZ2UvYWxpeXVuP3BhZ2U9ZnlwYWdlJyxcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IGZvbGRlclN0eWxlLFxcbiAgICAgICAgICAgICAgICBkZXNjOiBmb3JtYXREYXRlKGZpbGVJdGVtLnVwZGF0ZWRfYXQpLFxcbiAgICAgICAgICAgICAgICBwaWNfdXJsOiBwaWNfdXJsLFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgc2hhcmVJZDogc2hhcmVJZCxcXG4gICAgICAgICAgICAgICAgICAgIHNoYXJlVG9rZW46IE1ZX1BBUkFNUy5zaGFyZVRva2VuLFxcbiAgICAgICAgICAgICAgICAgICAgZmlsZUlkOiBmaWxlSXRlbS5maWxlX2lkLFxcbiAgICAgICAgICAgICAgICAgICAgc2hhcmVQd2Q6IHNoYXJlUHdkLFxcbiAgICAgICAgICAgICAgICAgICAgcGFnZVRpdGxlOiBmaWxlSXRlbS5uYW1lLFxcbiAgICAgICAgICAgICAgICAgICAgdHJhbnNmZXI6IHRydWUsXFxuICAgICAgICAgICAgICAgICAgICBub1BpYzogdHJ1ZSxcXG4gICAgICAgICAgICAgICAgICAgIGxvbmdDbGljazogW3tcXG4gICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIui9rOWtmFxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAganM6IEpTT04uc3RyaW5naWZ5KFxcXCJoaWtlcjovL3BhZ2UvbXlhbGl5dW4jbm9IaXN0b3J5IyNub1JlY29yZEhpc3RvcnkjP3BhZ2U9ZnlwYWdlXFxcIilcXG4gICAgICAgICAgICAgICAgICAgIH1dXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH0gZWxzZSBpZiAobm9Ta2lwRmlsZSkge1xcbiAgICAgICAgICAgIGlmIChmaWx0ZXJUeXBlLmxlbmd0aCA+IDAgJiYgIWZpbHRlclR5cGUuaW5jbHVkZXMoY2F0ZSkpIHtcXG4gICAgICAgICAgICAgICAgY29udGludWU7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCBzdWJ0aXRsZSwgY2xzLCBsb25nYyA9IFt7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi6L2s5a2YXFxcIixcXG4gICAgICAgICAgICAgICAganM6IEpTT04uc3RyaW5naWZ5KFxcXCJoaWtlcjovL3BhZ2UvbXlhbGl5dW4jbm9IaXN0b3J5IyNub1JlY29yZEhpc3RvcnkjP3BhZ2U9ZnlwYWdlXFxcIilcXG4gICAgICAgICAgICB9XTtcXG4gICAgICAgICAgICBsZXQgdGl0bGUgPSBmaWxlSXRlbS5uYW1lO1xcbiAgICAgICAgICAgIGxldCBuYW1lTm90RXh0ID0gZmlsZUl0ZW0ubmFtZS5yZXBsYWNlKCcuJyArIGZpbGVJdGVtLmZpbGVfZXh0ZW5zaW9uLCAnJyk7XFxuICAgICAgICAgICAgaWYgKHN1YkV4dHMuaW5jbHVkZXMoZmlsZUl0ZW0uZmlsZV9leHRlbnNpb24pKSB7XFxuICAgICAgICAgICAgICAgIGxvbmdjLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLmjILovb3lrZfluZVcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKHptKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmFnZTAucHV0TXlWYXIoJ21vdW50emltdScsIHptKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJ3RvYXN0Oi8v5oyC6L295a6M5oiQ77yM5b2T5YmN5a2X5bmV5paH5Lu2OiAnICsgem0ubmFtZSArICcuJyArIHptLmV4dDtcXG4gICAgICAgICAgICAgICAgICAgIH0sIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBleHQ6IGZpbGVJdGVtLmZpbGVfZXh0ZW5zaW9uLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGZpbGVfaWQ6IGZpbGVJdGVtLmZpbGVfaWQsXFxuICAgICAgICAgICAgICAgICAgICAgICAgbmFtZTogbmFtZU5vdEV4dFxcbiAgICAgICAgICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAoY2F0ZSA9PT0gXFxcInZpZGVvXFxcIikge1xcbiAgICAgICAgICAgICAgICBpZiAoemltdWxpc3QubGVuZ3RoKSB7XFxuICAgICAgICAgICAgICAgICAgICBzdWJ0aXRsZSA9IHppbXVsaXN0LmZpbmQodiA9PiB2Lm5hbWUuaW5jbHVkZXMobmFtZU5vdEV4dCkpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGNscyA9IFxcXCJwbGF5bGlzdCB2XFxcIiArIHBhZ2VJZDtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKGZpbGVTdHlsZSA9PT0gXFxcInRleHRfMVxcXCIpIHtcXG4gICAgICAgICAgICAgICAgZGVzYyArPSBcXFwiXFxcXHRcXFxcdFxcXCIgKyBmb3JtYXRTaXplKGZpbGVJdGVtLnNpemUpO1xcbiAgICAgICAgICAgICAgICB0aXRsZSA9IGdldEhlYWQoY2F0ZSwgZmlsZUl0ZW0uZmlsZV9leHRlbnNpb24pICsgdGl0bGU7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChbXFxcInZpZGVvXFxcIiwgXFxcImltYWdlXFxcIl0uaW5jbHVkZXMoY2F0ZSkpIHtcXG4gICAgICAgICAgICAgICAgcGljX3VybCA9IGdldFByZXZpZXdQaWMoZmlsZUl0ZW0pIHx8IHBpY191cmw7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGl0ZW1zLnB1c2goe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogdGl0bGUsXFxuICAgICAgICAgICAgICAgIHVybDogJChcXFwiI25vUHJlI1xcXCIpLmxhenlSdWxlKChzaGFyZUlkLCBzaGFyZVB3ZCwgc2hhcmVUb2tlbiwgZmlsZUlkLCBjYXRlLCBzdWJ0aXRsZSkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuICQucmVxdWlyZShcXFwiaGlrZXI6Ly9wYWdlL2FsaWxhenlcXFwiKShzaGFyZUlkLCBzaGFyZVB3ZCwgc2hhcmVUb2tlbiwgZmlsZUlkLCBjYXRlLCBzdWJ0aXRsZSk7XFxuICAgICAgICAgICAgICAgIH0sIHNoYXJlSWQsIHNoYXJlUHdkLCBNWV9QQVJBTVMuc2hhcmVUb2tlbiwgZmlsZUl0ZW0uZmlsZV9pZCwgY2F0ZSwgc3VidGl0bGUpLFxcbiAgICAgICAgICAgICAgICBkZXNjOiBkZXNjLFxcbiAgICAgICAgICAgICAgICBwaWNfdXJsOiBwaWNfdXJsLFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgaWQ6IGZpbGVJdGVtLmZpbGVfaWQsXFxuICAgICAgICAgICAgICAgICAgICB0cmFuc2ZlcjogdHJ1ZSxcXG4gICAgICAgICAgICAgICAgICAgIHNoYXJlSW5mbzoge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VJZDogcGFnZUlkLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGZpbGVJZDogZmlsZUl0ZW0uZmlsZV9pZCxcXG4gICAgICAgICAgICAgICAgICAgICAgICBzaGFyZUlkOiBzaGFyZUlkLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHNoYXJlVG9rZW46IHNoYXJlVG9rZW4sXFxuICAgICAgICAgICAgICAgICAgICAgICAgc2hhcmVQd2Q6IHNoYXJlUHdkLFxcbiAgICAgICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgICAgIGxvbmdDbGljazogbG9uZ2MsXFxuICAgICAgICAgICAgICAgICAgICBjbHM6IGNscyxcXG4gICAgICAgICAgICAgICAgICAgIC8vaW5oZXJpdFRpdGxlOiBmYWxzZSxcXG4gICAgICAgICAgICAgICAgICAgIHBhZ2VUaXRsZTogZmlsZUl0ZW0ubmFtZVxcbiAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogZmlsZVN0eWxlXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9XFxuICAgIH1cXG4gICAgaWYgKGNvbnRzLmxlbmd0aCA9PT0gMCkge1xcbiAgICAgICAgaXRlbXMucHVzaCh7XFxuICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuKAnOKAnOKAneKAnVxcXCIgKyBcXFwifn5+5LuA5LmI6YO95rKh5pyJ5LqG5ZOmfn5+XFxcIi5mb250Y29sb3IoXFxcIkdyYXlcXFwiKSxcXG4gICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2UsXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSk7XFxuICAgIH1cXG59XFxuXFxubGV0IGl0ZW1zID0gW107XFxudHJ5IHtcXG4gICAgaWYgKE1ZX1BBR0UgPiAxICYmICFNWV9QQVJBTVMubWFya2VyKSB7XFxuICAgICAgICBpdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbiAgICAgICAgICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgICAgIHRpdGxlOiBcXFwi4oCc4oCc4oCd4oCdXFxcIiArIFxcXCJ+fn7ku4DkuYjpg73msqHmnInkuoblk6Z+fn5cXFwiLmZvbnRjb2xvcihcXFwiR3JheVxcXCIpLFxcbiAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgIGxpbmVWaXNpYmxlOiBmYWxzZSxcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9KTtcXG4gICAgfSBlbHNlIHtcXG4gICAgICAgIGxvYWQoaXRlbXMpO1xcbiAgICB9XFxufSBjYXRjaCAoZSkge1xcbiAgICBpZiAoZS5uYW1lID09PSBcXFwiQWxpRXJyb3JcXFwiKSB7XFxuICAgICAgICBpZiAoZS5jb2RlID09PSBcXFwiSW52YWxpZFJlc291cmNlLlNoYXJlUHdkXFxcIikge1xcbiAgICAgICAgICAgIGl0ZW1zLnB1c2goe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuivt+i+k+WFpeaPkOWPlueggVxcXCIsXFxuICAgICAgICAgICAgICAgIGRlc2M6IHNoYXJlUHdkID8gXFxcIuKAnOKAnOaPkOWPlueggemUmeivr+KAneKAnVxcXCIgOiBcXFwiXFxcIixcXG4gICAgICAgICAgICAgICAgdXJsOiAkKCkuaW5wdXQoKE1ZX1BBUkFNUykgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgc2V0UGFnZVBhcmFtcyhPYmplY3QuYXNzaWduKHt9LCBNWV9QQVJBTVMsIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBzaGFyZVB3ZDogaW5wdXRcXG4gICAgICAgICAgICAgICAgICAgIH0pKTtcXG4gICAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgICAgIH0sIE1ZX1BBUkFNUyksXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCJcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgaWYgKGUuc2lnbmlmaWNhbmNlID09PSAxKSB7XFxuICAgICAgICAgICAgICAgIGl0ZW1zLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLigJzigJzigJ3igJ1cXFwiICsgZS5tZXNzYWdlLmJpZygpLmJpZygpLmZvbnRjb2xvcihcXFwicmVkXFxcIiksXFxuICAgICAgICAgICAgICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgICAgICAgICAgICAgIGNvbF90eXBlOiAndGV4dF9jZW50ZXJfMScsXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoZS5zaWduaWZpY2FuY2UgPT09IDMpIHtcXG4gICAgICAgICAgICAgICAgaXRlbXMucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuKAnOKAnOKAneKAnVxcXCIgKyBlLm1lc3NhZ2UuYmlnKCkuZm9udGNvbG9yKFxcXCJncmVlblxcXCIpLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICBjb2xfdHlwZTogJ3RleHRfY2VudGVyXzEnXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH1cXG5cXG4gICAgfSBlbHNlIHtcXG4gICAgICAgIGxvZyhcXFwi5YiX6KGo5Yqg6L295aSx6LSlI1xcXFxu6ZSZ6K+v5L+h5oGvPlxcXCIgKyBlLnRvU3RyaW5nKCkgKyBcXFwiXFxcXG7plJnor6/ooYw+XFxcIiArIGUubGluZU51bWJlcik7XFxuICAgICAgICBpdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICB0aXRsZTogJ+asp+asp++8jOaKpemUmeS6huOAguWcqOWIt+aWsOWHoOasoe+8n+aIluiAheabtOaNouaWh+S7tuWkueOAgicsXFxuICAgICAgICAgICAgdXJsOiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI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G4gICAgICAgICAgICAgICAgICAgIH07XFxuICAgICAgICAgICAgICAgICAgICB3cml0ZUZpbGUoYWxpVG9rZW5zRmlsZXBhdGgsIEpTT04uc3RyaW5naWZ5KGFsaVRva2VuKSk7XFxuICAgICAgICAgICAgICAgICAgICBhZGRJdGVtQWZ0ZXIoXFxcImxvZ2lueVxcXCIsIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIueZu+W9leaIkOWKnyjngrnlh7vov5Tlm54pXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBiYWNrKGZhbHNlKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgICB9KSxcXG4gICAgICAgICAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICBiYWNrSG9tZShcXFwi55m75b2V5oiQ5YqfXFxcIiwgdHJ1ZSk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBiYWNrSG9tZShcXFwi55m75b2V5aSx6LSlLOivt+WwneivleWFtuS7lueahOaWueazlVxcXCIpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIHJldHVybjtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKHFyQ29kZVN0YXR1cyA9PT0gXFxcIkNBTkNFTEVEXFxcIikge1xcbiAgICAgICAgICAgICAgICBiYWNrSG9tZShcXFwi5Y+W5raI55m75b2V5o6I5p2DXFxcIik7XFxuICAgICAgICAgICAgICAgIHJldHVybjtcXG4gICAgICAgICAgICB9XFxu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oXFxcIikuYWxpVG9rZW5zRmlsZXBhdGg7XFxuXFxuICAgIHZhciBqcyA9ICQudG9TdHJpbmcoKGlzUmVmcmVzaCwgYWxpVG9rZW5zRmlsZXBhdGgpID0+IHtcXG4gICAgICAgIHNldEludGVydmFsKCgpID0+IHtcXG4gICAgICAgICAgICB2YXIgdG9rZW4gPSBKU09OLnBhcnNlKGxvY2FsU3RvcmFnZS5nZXRJdGVtKCd0b2tlbicpKTtcXG4gICAgICAgICAgICBpZiAodG9rZW4gJiYgdG9rZW4udXNlcl9pZCkge1xcbiAgICAgICAgICAgICAgICBsZXQgdG9rZW5fdXJsID0gYWxpVG9rZW5zRmlsZXBhdGg7XFxuICAgICAgICAgICAgICAgIGZ5X2JyaWRnZV9hcHAud3JpdGVGaWxlKHRva2VuX3VybCwgSlNPTi5zdHJpbmdpZnkodG9rZW4pKTtcXG4gICAgICAgICAgICAgICAgbG9jYWxTdG9yYWdlLmNsZWFyKCk7XFxuICAgICAgICAgICAgICAgIGZ5X2JyaWRnZV9hcHAuYmFjayhpc1JlZnJlc2gpO1xcbiAgICAgICAgICAgICAgICBmeV9icmlkZ2VfYXBwLnRvYXN0KCdUT0tFTuiOt+WPluaIkOWKn++8jOivt+WLv+azhOa8j+S4quS6uumakOenge+8ge+8ge+8gScpO1xcbiAgICAgICAgICAgICAgICByZXR1cm47XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSwgMzAwKTtcXG4gICAgfSwgaXNSZWZyZXNoLCBhbGlUb2tlbnNGaWxlcGF0aCk7XFxuXFxuICAgIGQucHVzaCh7XFxuICAgICAgICB1cmw6IHVybCxcXG4gICAgICAgIGNvbF90eXBlOiAneDVfd2Vidmlld19zaW5nbGUnLFxcbiAgICAgICAgZGVzYzogJzEwMCUmJmZsb2F0JyxcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgY2FuQmFjazogZmFsc2UsXFxuICAgICAgICAgICAganM6IGpzLFxcbiAgICAgICAgICAgIHVybEludGVy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Gl5dW5kcml2ZVxcXCIgKyB0aGlzLm9wZW5TdWZmaXgpO1xcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XFxuICAgICAgICAgICAgICAgIGNhc2UgXFxcIjJcXFwiOlxcbiAgICAgICAgICAgICAgICAgICAgT3BlbkFwaVRvb2xzID0gJC5yZXF1aXJlKFxcXCJvcGVuQXBpX3R2Ym94XFxcIiArIHRoaXMub3BlblN1ZmZpeCk7XFxuICAgICAgICAgICAgICAgICAgICBicmVhaztcXG4gICAgICAgICAgICAgICAgY2FzZSBcXFwiM1xcXCI6XFxuICAgICAgICAgICAgICAgICAgICBPcGVuQXBpVG9vbHMgPSAkLnJlcXVpcmUoXFxcIm9wZW5BcGlfWEJZXFxcIiArIHRoaXMub3BlblN1ZmZpeCk7XFxuICAgICAgICAgICAgICAgICAgICBicmVhaztcXG4gICAgICAgICAgICAgICAgY2FzZSBcXFwiNFxcXCI6XFxuICAgICAgICAgICAgICAgICAgICBPcGVuQXBpVG9vbHMgPSAkLnJlcXVpcmUoXFxcIm9wZW5BcGlfdHZcXFwiICsgdGhpcy5vcGVuU3VmZml4KTtcXG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xcbiAgICAgICAgICAgICAgICBjYXNlIFxcXCIwXFxcIjpcXG4gICAgICAgICAgICAgICAgZGVmYXVsdDpcXG4gICAgICAgICAgICAgICAgICAgIE9wZW5BcGlUb29scyA9ICQucmVxdWlyZShcXFwib3BlbkFwaV9hbGlzdFxcXCIgKyB0aGlzLm9wZW5TdWZmaXgpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB0aGlzLl9vcGVuVG9vbHMgPSBuZXcgT3BlbkFwaVRvb2xzKHRoaXMpO1xcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl9vcGVuVG9vbHM7XFxuICAgICAgICB9XFxuICAgIH0pO1xcbiAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgXFxcIm9wZW5Ub2tlbnNcXFwiLCB7XF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Ym9keVRvU3RyaW5nKHRydWUpLmVycm9yKChlcnIpID0+IHtcXG4gICAgICAgICAgICB0aHJvdyBlcnI7XFxuICAgICAgICB9KS5lcnJvclR5cGUoKGVyciwgcmVzKSA9PiB7XFxuICAgICAgICAgICAgbGV0IHJlc3VsdCA9IHt9O1xcbiAgICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgICAgIHJlc3VsdCA9IEpTT04ucGFyc2UocmVzLmJvZHkpO1xcbiAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIGVycjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IHJib2R5ID0gKHJlc3VsdC5jb2RlID8gcmVzdWx0IDogKHJlc3VsdCAmJiByZXN1bHQucmVzcG9uc2VzICYmIHJlc3VsdC5yZXNwb25zZXNbMF0gJiYgcmVzdWx0LnJlc3BvbnNlc1swXS5ib2R5KSkgfHwge307XFxuICAgICAgICAgICAgaWYgKHJib2R5LmNvZGUpIHtcXG4gICAgICAgICAgICAgICAgbGV0IG1zZyA9IHJib2R5LmRpc3BsYXlfbWVzc2FnZSB8fCByYm9keS5tZXNzYWdlO1xcbiAgICAgICAgICAgICAgICBsZXQgZXJyb3IgPSBuZXcgRXJyb3IoYXBpICsgXFxcIj0+XFxcIiArIHJib2R5LmNvZGUgKyBcXFwiOlxcXCIgKyBtc2cpO1xcbiAgICAgICAgICAgICAgICBlcnJvci5jb2RlID0gcmJvZHkuY29kZTtcXG4gICAgICAgICAgICAgICAgZXJyb3IuanVkZ2VNc2cgPSBtc2c7XFxuICAgICAgICAgICAgICAgIHJldHVybiBlcnJvcjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIGVycjtcXG4gICAgICAgIH0pO1xcbiAgICB9LFxcbiAgICBzZXRNeURyaXZpZFR5cGUoaXNCYWNrdXApIHtcXG4gICAgICAgIHRoaXMubXlEcml2aWRUeXBlID0gISFpc0JhY2t1c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gIH0pLmVycm9yV2l0aFJldHJ5KChlLCBfLCBodHRwKSA9PiB7XFxuICAgICAgICAgICAgaWYgKGUuY29kZSA9PT0gXFxcIlF1b3RhRXhoYXVzdGVkLkRyaXZlXFxcIikge1xcbiAgICAgICAgICAgICAgICB0aHJvdyBlO1xcbiAgICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgICBpZiAoIXRoaXMudHJ5U29sdmUoZSkpIHtcXG4gICAgICAgICAgICAgICAgdGhpcy53YWl0U2xlZXAoMjApLnJlZnJlc2hBY2Nlc3NUb2tlbigpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgYm9keSA9IGh0dHAub3B0aW9ucy5ib2R5LnJlcXVlc3RzWzBdLmJvZHk7XFxuICAgICAgICAgICAgaWYgKGJvZHkuZHJpdmVfaWQpIHtcXG4gICAgICAgICAgICAgICAgYm9keS5kcml2ZV9pZCA9IHRoaXMuZ2V0TXlEcml2aWQoKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKGJvZHkudG9fZHJpdmVfaWQpIHtcXG4gICAgICAgICAgICAgICAgYm9keS50b19kcml2ZV9pZCA9IHRoaXMuZ2V0TXlEcml2aWQoKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaHR0cC5tZXJnZUhlYWRBbmRCb2R5KHtcXG4gICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgJ2F1dGhvcml6YXRpb24nOiB0aGlzLnJlYWNjZXNzVGssXFxuICAgICAgICAgICAgICAgICAgICAneC1zaGFyZS10b2tlbic6IHRoaXMuc2hhcmVUb2tlblxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgcmV0dXJuIHRydWU7XFxuICAgICAgICB9KS5zdGFydCh0cnVlKTtcXG4gICAgICAgIHJldHVybiByZXN1bHQ7XFxuICAgIH0sXFxuICAgIGNvcHlGaWxlVG9DbG91ZEZ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mluZ2lmeShyZXN1bHQpKTtcXG4gICAgICAgICAgICBlLmNvZGUgPSBib2R5LmNvZGU7XFxuICAgICAgICAgICAgdGhyb3cgZTtcXG4gICAgICAgIH1cXG4gICAgICAgIHJldHVybiByZXN1bHQucmVzcG9uc2VzWzBdLmJvZHkuZmlsZV9pZDtcXG4gICAgfSxcXG4gICAgb3BlbkNsb3VkRmlsZVRvRG93blVybChjbG91ZEZpbGVJZCkge1xcbiAgICAgICAgbGV0IGZpbGVJbmZvID0gdGhpcy5wb3N0QXBpKCdodHRwczovL29wZW4uYWxpeXVuZHJpdmUuY29tL2Fkcml2ZS92MS4wL29wZW5GaWxlL2dldERvd25sb2FkVXJsJykuYm9keSh7XFxuICAgICAgICAgICAgJ2ZpbGVfaWQnOiBjbG91ZEZpbGVJZCxcXG4gICAgICAgICAgICAnZHJpdmVfaWQnOiB0aGlzLmdldE15RHJpdmlkKClcXG4gICAgICAgIH0pLmhlYWRlcnMoe1xcbiAgICAgICAgICAgICdVc2VyLUFnZW50JzogUENfVUEsXFxuICAgICAgICAgICAgJ1JlZmVyZXInOiAnaHR0cHM6Ly93d3cuYWxpeXVuZHJpdmUuY29tLycsXFxuICAgICAgICAgICAgJ2F1dGhvcml6YXRpb24nOiB0aGlzLm9wZW5Ub2tlbnMuQWNjZXNzVG9rZW5PcGVuXFxuICAgICAgICB9KS5lcnJvcldpdGhSZXRyeSgyLCAoZSwgXywgaHR0cCkgPT4ge1xcbiAgICAgICAgICAgIC8vdGhpcy53YWl0U2xlZXAoMzApLnRyeVNvbHZlKGUpO1xcbiAgICAgICAgICAgIHRoaXMud2FpdFNsZWVwKDMwKS50cnlPcGVuQXBpU29sdmUoZSk7XFxuICAgICAgICAgICAgaHR0cC5tZXJnZUhlYWRBbmRCb2R5KHtcXG4gICAgICAgICAgICAgICAgYm9keToge1xcbiAgICAgICAgICAgICAgICAgICAgJ2RyaXZlX2lkJzogdGhpcy5nZXRNeURyaXZpZCgpLFxcbiAgICAgICAgICAgICA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lsZV9pZCc6IGNsb3VkRmlsZUlkLFxcbiAgICAgICAgICAgICdkcml2ZV9pZCc6IHRoaXMuZ2V0TXlEcml2aWQoKSxcXG4gICAgICAgICAgICBcXFwiY2F0ZWdvcnlcXFwiOiBcXFwibGl2ZV90cmFuc2NvZGluZ1xcXCIsXFxuICAgICAgICAgICAgXFxcInRlbXBsYXRlX2lkXFxcIjogXFxcIlxcXCIsXFxuICAgICAgICAgICAgXFxcImdldF9zdWJ0aXRsZV9pbmZvXFxcIjogdHJ1ZSxcXG4gICAgICAgICAgICBcXFwidXJsX2V4cGlyZV9zZWNcXFwiOiAxNDQwMCxcXG4gICAgICAgICAgICBcXFwid2l0aF9wbGF5X2N1cnNvclxcXCI6IHRydWVcXG4gICAgICAgIH0pLmhlYWRlcnMoe1xcbiAgICAgICAgICAgICdVc2VyLUFnZW50JzogUENfVUEsXFxuICAgICAgICAgICAgJ1JlZmVyZXInOiAnaHR0cHM6Ly93d3cuYWxpeXVuZHJpdmUuY29tLycsXFxuICAgICAgICAgICAgJ2F1dGhvcml6YXRpb24nOiB0aGlzLm9wZW5Ub2tlbnMuQWNjZXNzVG9rZW5PcGVuXFxuICAgICAgICB9KS5lcnJvcldpdGhSZXRyeSgyLCAoZSwgXywgaHR0cCkgPT4ge1xcbiAgICAgICAgICAgIC8vdGhpcy53YWl0U2xlZXAoMzApLnRyeVNvbHZlKGUpO1xcbiAgICAgICAgICAgIHRoaXMud2FpdFNsZWVwKDMwKS50cnlPcGVuQXBpU29sdmUoZSk7XFxuICAgICAgICAgICAgaHR0cC5tZXJnZUhlYWRBbmRCb2R5KHtcXG4gICAgICAgICAgICAgICAgYm9keToge1xcbiAgICAgICAgICAgICAgICAgICAgJ2RyaXZlX2lkJzogdGhpcy5nZXRNeURyaXZpZCgpLFxcbiAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICAnYXV0aG9yaXphdGlvbic6IHRoa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IGVtcHR5XFxcIikge1xcbiAgICAgICAgICAgICAgICB0aGlzLndhaXRTbGVlcCgyMCkucmVmcmVzaEFjY2Vzc1Rva2VuKCk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHRoaXMudHJ5U29sdmUoZSk7XFxuICAgICAgICAgICAgdGhpcy53YWl0U2xlZXAoNTApO1xcbiAgICAgICAgICAgIG5ld1NpZ24gPSBjYWxjdWxhdGVOZXdTaWduKCk7XFxuICAgICAgICAgICAgaHR0cC5tZXJnZUhlYWRBbmRCb2R5KHtcXG4gICAgICAgICAgICAgICAgYm9keToge1xcbiAgICAgICAgICAgICAgICAgICAgXFxcInB1YktleVxcXCI6IG5ld1NpZ24ucHViS2V5XFxuICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgICdBdXRob3JpemF0aW9uJzogdGhpcy5yZWFjY2Vzc1RrLFxcbiAgICAgICAgICAgICAgICAgICAgJ1gtU2hhcmUtVG9rZW4nOiB0aGlzLnNoYXJlVG9rZW4sXFxuICAgICAgICAgICAgICAgICAgICAneC1kZXZpY2UtaWQnOiB0aGlzLmFsaVRva2Vucy5kZXZpY2VfaWQsXFxuICAgICAgICAgICAgICAgICAgICAneC1zaWduYXR1cmUnOiBuZXdTaWduLnNpZ25hdHVyZVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgcmV0dXJuIHRydWU7XFxuICAgICAgICB9KS5lcnJvcigoZXJyLCByZXMpID0+IHtcXG4gICAgICAgICAgICByZXR1cm4ge307XFxuICAgICAgICB9KS5zdWNjZXNzKChib2R5KSA9PiB7XFxuICAgICAgICAgICAgcmV0dXJuIGJvZHk7XFxuICAgICAgICB9KS5zdGFydCh0cnVlKTtcXG4gICAgICAgIGlmIChyZXN1bHQuc3VjY2Vzcykge1xcbiAgICAgICAgICAgIHJldHVybiBuZXdTaWduO1xcbiAgIC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G4gICAgICAgICAgICAgICAgICAgICd4LWRldmljZS1pZCc6IHRoaXMuYWxpVG9rZW5zLmRldmljZV9pZCxcXG4gICAgICAgICAgICAgICAgICAgICd4LXNpZ25hdHVyZSc6IHNpZ24uc2lnbmF0dXJlXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICByZXR1cm4gdHJ1ZTtcXG4gICAgICAgIH0pLnN0YXJ0KHRydWUpO1xcbiAgICAgICAgcmV0dXJuIGpzb24udmlkZW9fcHJldmlld19wbGF5X2luZm8ubGl2ZV90cmFuc2NvZGluZ190YXNrX2xpc3QucmV2ZXJzZSgpO1xcbiAgICB9LFxcbiAgICBnZXRNeURyaXZpZCgpIHtcXG4gICAgICAgIHJldHVybiAodGhpcy5teURyaXZpZFR5cGUgPyB0aGlzLmFsaVRva2Vucy5kZWZhdWx0X2RyaXZlX2lkIDogdGhpcy5hbGlUb2tlbnMucmVzb3VyY2VfZHJpdmVfaWQpIHx8IHRoaXMuZGVmRHJpdmVJZDtcXG4gICAgfSxcXG4gICAgZ2V0TGlzdEZpbGUoZmlsZUlkLCBtYXJrZXIsIG9yZGVyQnksIG9yZGVyRGlyZWN0aW9uKSB7XFxuICAgICAgICBsZXQgcmVzdWx0ID0gdGhpcy5wb3N0QXBpKFxcXCJodHRwczovL29wZW4uYWxpeXVuZHJpdmUuY29tL2Fkcml2ZS92MS4wL29wZW5GaWxlL2xpc3RcXFwiKS5ib2R5KHtcXG4gICAgICAgICAgICBcXFwiZHJpdmVfaWRcXFwiOiB0aGlzLmdldE15RHJpdmlkKCksXFxuICAgICAgICAgICAgXFxcInBhcmVudF9maWxlX2lkXFxcIjogZmlsZUlkIHx8IFxcXCJyb290XFxcIixcXG4gICAgICAgICAgICBcXFwibGltaXRcXFwiOiAxMDAsXFxuICAgICAgICAgICAgXFxcImFsbFxcXCI6IHRydWUsXFxuICAgICAgICAgICAgXFxcInVybF9leHBpcmVfc2VjXFxcIjogODY0MD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iOiBvcmRlckJ5ICsgXFxcIiBcXFwiICsgb3JkZXJEaXJlY3Rpb24sXFxuICAgICAgICAgICAgXFxcIm1hcmtlclxcXCI6IG1hcmtlciB8fCB1bmRlZmluZWRcXG4gICAgICAgIH0pLmhlYWRlcnMoe1xcbiAgICAgICAgICAgICdVc2VyLUFnZW50JzogUENfVUEsXFxuICAgICAgICAgICAgJ1JlZmVyZXInOiAnaHR0cHM6Ly93d3cuYWxpeXVuZHJpdmUuY29tLycsXFxuICAgICAgICAgICAgJ2F1dGhvcml6YXRpb24nOiB0aGlzLnJlYWNjZXNzVGtcXG4gICAgICAgIH0pLmVycm9yV2l0aFJldHJ5KDIsIChlLCBfLCBodHRwKSA9PiB7XFxuICAgICAgICAgICAgdGhpcy53YWl0U2xlZXAoMjApLnJlZnJlc2hBY2Nlc3NUb2tlbigpO1xcbiAgICAgICAgICAgIC8vdGhpcy53YWl0U2xlZXAoMzApLnRyeU9wZW5BcGlTb2x2ZShlKTtcXG4gICAgICAgICAgICBodHRwLm1lcmdlSGVhZEFuZEJvZHkoe1xcbiAgICAgICAgICAgICAgICBib2R5OiB7XFxuICAgICAgICAgICAgICAgICAgICAnZHJpdmVfaWQnOiB0aGlzLmdldE15RHJpdmlkKCksXFxuICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgICdhdXRob3JpemF0aW9uJzogdGhpcy5yZWFjY2Vzc1RrXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICByZXR1cm4gdHJ1ZTtcXG4gICAgICAgIH0pLnN0YXJ0KHRydWUpO1xcbiAgICAgICAgaWYgKE9iamVjdC5rZXlzKHJlc3VsdCkubGVuZ3RoID09PSAwKSB7XFxuICAgICAgICAgICAgcmVzdWx0Lml0ZW1zID0gW107XFxuICAgICAgICB9XFxuICAgICAgICByZXR1cm4gcmVzdWx0O1xcbiAgICB9LFxcbiAgICBzaWduSW5SZXdhcmQoKSB7XFxuICAgICAgICBsZXQgc2lsRGF0YSA9IHRoaXMucG9zdEFwaSgnaHR0cHM6Ly9tZW1iZXIuYWxpeXVuZHJpdmUuY29tL3YxL2FjdGl2aXR5L3NpZ25faW5fbGlzdCcpLmJvZHkoe1xcbiAgICAgICAgICAgICdncmFudF90eXBlJzogJ3JlZnJlc2hfdG9rZW4nLFxcbiAgICAgICAgICAgICdyZWZyZXNoX3Rva2VuJzogdGhpcy5hbGlUb2tlbnMucmVmcmVzaF90b2tlblxcbiAgICAgICAgfSkuaGVhZGVycyh7XFxuICAgICAgICAgICAgJ0F1dGhvcml6YXRpb24nOiB0aGlzLnJlYWNjZXNzVGssXFxuICAgICAgICAgICAgJ0NvbnRlbnQtVHlwZSc6ICdhcHBsaWNhdGlvbi9qc29uJ1xcbiAgICAgICAgfSkuZXJyb3JXaXRoUmV0cnkoKGUsIF8sIGh0dHApID0+IHtcXG4gICAgICAgICAgICB0aGlzLnRyeVNvbHZlKGUpO1xcbiAgICAgICAgICAgIGh0dHAubWVyZ2VIZWFkQW5kQm9keSh7XFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgICdBdXRob3JpemF0aW9uJzogdGhpcy5yZWFjY2Vzc1RrLFxcblxcbiAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICBib2R5OiB7XFxuICAgICAgICAgICAgICAgICAgICAncmVmcmVzaF90b2tlbic6IHRoaXMuYWxpVG9rZW5zLnJlZnJlc2hfdG9rZW5cXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIHJldHVybiB0cnVlO1xcbiAgICAgICAgfSkuc3RhcnQodHJ1ZSk7XFxuICAgICAgICBsZXQgZGF5ID0gc2lsRGF0YS5yZXN1bHQuc2lnbkluQ291bnQ7XFxuICAgICAgICBsZXQgaXNSZXdhcmQgPSBzaWxEYXRhLnJlc3VsdC5zaWduSW5Mb2dzW2RheSAtIDFdLmlzUmV3YXJkO1xcbiAgICAgICAgaWYgKGlzUmV3YXJkKSB7XFxuICAgICAgICAgICAgbGV0IHJld2FyZCA9IHNpbERhdGEucmVzdWx0LnNpZ25JbkxvZ3NbZGF5IC0gMV0ucmV3YXJkO1xcbiAgICAgICAgICAgIGlmIChyZXdhcmQpIHtcXG4gICAgICAgICAgICAgICAgbGV0IHJld25vdGljZSA9IHJld2FyZC5ub3RpY2U7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwi5LuK5aSp5bey57uP562+5Yiw77yM6K+35LiN6KaB6YeN5aSN562+5Yiw77yBXFxcXG5cXFwiICsgcmV3bm90aWNlO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIC8v5rKh5pyJ5aWW5Yqx77yM5Y+q5pyJ5bm46L+Q562+5ZCN54mHXFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwi5LuK5aSp5bey57uP562+5Yiw77yM6K+35LiN6KaB6YeN5aSN562+5Yiw77yBXFxcXG7ku4rml6Xlpb3ov5Dnrb46XFxcIiArIHNpbERhdGEucmVzdWx0LmJsZXNzaW5nO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgbGV0IHNpckRhdGEgPSB0aGlzLnBvc3RBcGkoJ2h0dHBzOi8vbWVtYmVyLmFsaXl1bmRyaXZlLmNvbS92MS9hY3Rpdml0eS9zaWduX2luX3Jld2FyZCcpLmJvZHkoe1xcbiAgICAgICAgICAgICAgICBcXFwic2lnbkluRGF5XFxcIjogZGF5XFxuICAgICAgICAgICAgfSkuaGVhZGVycyh7XFxuICAgICAgICAgICAgICAgICdBdXRob3JpemF0aW9uJzogdGhpcy5yZWFjY2Vzc1RrLFxcbiAgICAgICAgICAgICAgICAnQ29udGVudC1UeXBlJzogJ2FwcGxpY2F0aW9uL2pzb24nXFxuICAgICAgICAgICAgfSkuc3Rhcn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FxuICAgICAgICBpZiAodHlwZW9mIG9wdGlvbnMuYm9keSA9PT0gXFxcIm9iamVjdFxcXCIgJiYgdGhpcy5fYm9keVRvU3RyaW5nKSB7XFxuICAgICAgICAgICAgb3B0aW9ucy5ib2R5ID0gSlNPTi5zdHJpbmdpZnkob3B0aW9ucy5ib2R5KTtcXG4gICAgICAgIH1cXG4gICAgICAgIHZhciByZXMgPSBKU09OLnBhcnNlKHRoaXMuc3RhcnRSZXF1ZXN0KHRoaXMudXJsLCBvcHRpb25zKSk7XFxuICAgICAgICB0cnkge1xcbiAgICAgICAgICAgIGlmIChyZXMuc3RhdHVzQ29kZSA+PSAyMDAgJiYgcmVzLnN0YXR1c0NvZGUgPD0gMzAwKSB7XFxuICAgICAgICAgICAgICAgIGxldCBib2R5ID0gcmVzLmJvZHk7XFxuICAgICAgICAgICAgICAgIGlmICh0b0pzb24pIHtcXG4gICAgICAgICAgICAgICAgICAgIGJvZHkgPSBKU09OLnBhcnNlKGJvZHkpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnN1Y2Nlc3NDYWxsYmFjayhib2R5LCByZXMpO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihTdHJpbmcocmVzLnN0YXR1c0NvZGUpKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGNhdGNoIChlcnIpIHtcXG4gICAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgICAgICBlcnIgPSB0aGlzLmVycm9yVHlwZUNhbGxiYWNrKGVyciwgcmVzKTtcXG4gICAgICAgICAgICB9IGNhdGNoIChlKSB7XFxuXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGlmICh0aGlzLnJldHJ5Q291bnQpIHtcXG5cXG4gICAgICAgICAgICAgICAgbGV0IHRyeVJlc3VsdCA9IHRoaXMuZXJyb3JDYWxsYmFja1dpdGhSZXRyeShlcnIsIHJlcywgdGhpcyk7XFxuICAgICAgICAgICAgICAgIGlmICh0cnlSZXN1bHQpIHtcXG4gICAgICAgICAgICAgICAgICAgIHRoaXMucmV0cnlDb3VudC0tO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuc3RhcnQodG9Kc29uKTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIHRoaXMucmV0cnlDb3VudCA9IDA7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5lcnJvckNhbGxiYWNrKGVyciwgcmVzKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmVycm9yQ2FsbGJhY2soZXJyLCByZXMpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH1cXG4gICAgfSxcXG4gICAgc2V0T3B0aW9ucyhvcHRpb25zKSB7XFxuICAgICAgICB0aGlzLm9wdGlvbnMgPSBPYmplY3QuYXNzaWduKHt9LCBvcHRpb25zLCB7XFxuICAgICAgICAgICAgd2l0aEhlYWRlcnM6IHRydWVcXG4gICAgICAgIH0pO1xcbiAgICAgICAgcmV0dXJuIHRoaXM7XFxuICAgIH0sXFxuICAgIG1lcmdlSGVhZEFuZEJvZHkob3B0aW9ucykge1xcbiAgICAgICAgb3B0aW9ucyA9IG9wdGlvbnMgfHwge307XFxuICAgICAgICB0aGlzLm9wdGlvbnMuaGVhZGVycyA9IE9iamVjdC5hc3NpZ24odGhpcy5vcHRpb25zLmhlYWRlcnMsIG9wdGlvbnMuaGVhZGVycyk7XFxuICAgICAgICBpZiAodHlwZW9mIHRoaXMub3B0aW9ucy5ib2R5ID09PSBcXFwib2JqZWN0XFxcIiAmJiB0eXBlb2Ygb3B0aW9ucy5ib2R5ID09PSBcXFwib2JqZWN0XFxcIikge1xcbiAgICAgICAgICAgIHRoaXMub3B0aW9ucy5ib2R5ID0gT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ICAgICAgY2hDb252ZXJ0OiAxXFxuICAgIH0pKSk7XFxuICAgIGxldCBkTWNvbnRleHQgPSBcXFwiXFxcIjtcXG4gICAgLy9sZXQgZnBzbSA9IGdldFJlZnJlc2hSYXRlKCkvNjAqMC45NTtcXG4gICAgLy9kYW5NdURhdGEuY29tbWVudHMuc29ydCgodix4KT0+di5wLnNwbGl0KFxcXCIsXFxcIilbMF0teC5wLnNwbGl0KFxcXCIsXFxcIilbMF0pO1xcbiAgICBmb3IgKGxldCBjb21tZW50IG9mIGRhbk11RGF0YS5jb21tZW50cykge1xcbiAgICAgICAgLy9kTWNvbnRleHQgKz0gYDxkIHA9XFxcIiR7TWF0aC5yb3VuZCh0aW1lcG9pbnQpfSwke2N0fSwke3NpemV9LCR7Y29sb3J9LDBcXFwiPiR7Y29udGVudH08L2Q+XFxcXG5gO1xcbiAgICAgICAgbGV0IHBhcmFtVGV4dCA9IGNvbW1lbnQucDtcXG4gICAgICAgIGxldCBjb21tZW50VGV4dCA9IGNvbW1lbnQubTtcXG4gICAgICAgIGlmIChwYXJhbVRleHQgPT0gbnVsbCB8fCBjb21tZW50VGV4dCA9PSBudWxsKSBjb250aW51ZTtcXG4gICAgICAgIGxldCBwYXJhbXMgPSBwYXJhbVRleHQuc3BsaXQoXFxcIixcXFwiKTtcXG4gICAgICAgIGxldCBwYXJhbXNUID0gW107XFxuICAgICAgICBmb3IgKGxldCBpIGluIHBhcmFtcykge1xcbiAgICAgICAgICAgIC8qaWYgKGkgPT0gMCkge1xcbiAgICAgICAgICAgICAgICBwYXJhbXNULnB1c2gocGFyc2VJbnQocGFyYW1zW2ldKSk7XFxuICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xcbiAgICAgICAgICAgIH0qL1xcbiAgICAgICAgICAgIGlmIChpID09IDIpIHtcXG4gICAgICAgICAgICAgICAgcGFyYW1zVC5wdXNoKFxcXCIyNVxcXCIpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAoaSA9PSAzKSB7XFxuICAgICAgICAgICAgICAgIC8v6aKc6Imy5YC85Li6MOaXtu+8jOm7mOiupOiuvue9ruS4uueZveiJslxcbiAgICAgICAgICAgICAgICBpZiAocGFyYW1zW2ldID09IFxcXCIwXFxcIiB8fCBwYXJhbXNbaV0gPT0gXFxcIi0xXFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgcGFyYW1zVC5wdXNoKFxcXCIxNjc3NzIxNVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgY29udGludWVcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBicmVhaztcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcGFyYW1zVC5wdXNoKHBhcmFtc1tpXSk7XFxuICAgICAgICB9XFxuICAgICAgICBwYXJhbXNULnB1c2goXFxcIjBcXFwiKTtcXG4gICAgICAgIGxldCB0aW1lcz1wYXJzZUludChwYXJhbXNbMF0vNjApK1xcXCI6XFxcIitwYXJzZUludChwYXJhbXNbMF0lNjApO1xcbiAgICAgICAgZE1jb250ZXh0ICs9IGA8ZCBwPVxcXCIke3BhcmFtc1Quam9pbignLCcpfVxcXCI+JHtlbmNvZGVIdG1sKGNvbW1lbnRUZXh0KS8qK1xcXCIjXFxcIit0aW1lcyovfTwvZD5cXFxcbmA7XFxuICAgIH1cXG4gICAgaWYgKCFkTWNvbnRleHQpIHJldHVybjtcXG4gICAgZE1jb250ZXh0ID0gYDw/eG1sIHZlcnNpb249XFxcIjEuMFxcXCIgZW5jb2Rpbmc9XFxcIlVURi04XFxcIj8+PGk+XFxcXG4ke2RNY29udGV4dH08L2k+YDtcXG4gICAgbGV0IHBhdGggPSBzZXZlUGF0aCArIG5hbWUucmVwbGFjZSgvXFxcXC8vZywgXFxcIl9cXFwiKSArIFxcXCJfXFxcIiArIGVwaXNvZGVJZCArIFxcXCIueG1sXFxcIjtcXG4gICAgd3JpdGVGaWxlKHBhdGgsIGRNY29udGV4dCk7XFxuICAgIHJldHVybiBwYXRo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1xcbmQucHVzaCh7XFxuICAgIHRpdGxlOiBcXFwi5YaF572u5pCc57SiUFxcXCIsXFxuICAgIHVybDogJChrZXksIFxcXCLor7fmkJzntKLnlarliaflkI3np7BcXFwiKS5pbnB1dCgoTVlfUEFSQU1TKSA9PiB7XFxuICAgICAgICBzZXRQYWdlUGFyYW1zKE9iamVjdC5hc3NpZ24oTVlfUEFSQU1TLCB7XFxuICAgICAgICAgICAgbmFtZTogaW5wdXQsXFxuICAgICAgICB9KSk7XFxuICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICB9LCBNWV9QQVJBTVMpLFxcbiAgICBjb2xfdHlwZTogXFxcInRleHRfM1xcXCJcXG59KTtcXG5kLnB1c2goe1xcbiAgICB0aXRsZTogXFxcIuWGhee9ruaQnOe0olRcXFwiLFxcbiAgICB1cmw6ICQoa2V5LCBcXFwi5qC85byP77ya5pCc57Si5YWz6ZSu6K+NW+Wbnui9pl3pm4bmlbBcXFwiKS5pbnB1dCgob25seURvd25sb2FkKSA9PiB7XFxuICAgICAgICB0cnkge1xcbiAgICAgICAgICAgIHNob3dMb2FkaW5nKFxcXCLmraPlnKjmkJzntKLlubbkuIvovb0uLi5cXFwiKTtcXG4gICAgICAgICAgICBsZXQgW25hbWUsIHBvc10gPSBpbnB1dC5zcGxpdChcXFwiXFxcXG5cXFwiKTtcXG4gICAgICAgICAgICBpZiAoIW5hbWUgfHwgIXBvcykge1xcbiAgICAgICAgICAgICAgICB0aHJvdyBcXFwi5qC85byP6ZSZ6K+vXFxcIjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IHVybEluZm8gPSBmZXRjaChidWlsZFVybChcXFwiaHR0cHM6Ly9henVyZS5sZXVzZS50b3Avc2VhcmNoZG1cXFwiLCB7XFxuICAgICAgICAgICAgICAgIHBhcmFtczoge1xcbiAgICAgICAgICAgICAgICAgICAgXFxcIm5hbWVcXFwiOiBuYW1lLFxcbiAgICAgICAgICAgICAgICAgICAgXFxcInBvc1xcXCI6IHBvc1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSkpO1xcbiAgICAgICAgICAgIHVybEluZm8gPSBKU09OLnBhcnNlKHVybEluZm8pO1xcbiAgICAgICAgICAgIGlmICghdXJsSW5mby51cmwpIHRocm93IFxcXCLmmoLml7bmsqHmnInmib7liLDor6Xop4bpopHnmoTlvLnluZVcXFwiO1xcbiAgICAgICAgICAgIGxldCB4bWwgPSBmZXRjaChidWlsZFVybChcXFwiaHR0cHM6Ly9henVyZS5sZXVzZS50b3AvZGFubXVcXFwiLCB7XFxuICAgICAgICAgICAgICAgIHBhcmFtczogdXJsSW5mb1xcbiAgICAgICAgICAgIH0pKTtcXG4gICAgICAgICAgICBoaWRlTG9hZGluZygpO1xcbiAgICAgICAgICAgIGlmICgheG1sKSB7XFxuICAgICAgICAgICAgICAgIHRocm93IFxcXCLov5jmsqHmnInlvLnluZXlk59+XFxcIjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IHBhdGggPSBcXFwiaGlrZXI6Ly9maWxlcy9jYWNoZS9kYW5tdS9cXFwiICsgdXJsSW5mby5wbGF0Zm9ybSArIFxcXCJfXFxcIiArIG5hbWUgKyBcXFwiX1xcXCIgKyBwb3MgKyBcXFwiLnhtbFxcXCI7XFxuICAgICAgICAgICAgd3JpdGVGaWxlKHBhdGgsICc8P3htbCB2ZXJzaW9uPVxcXCIxLjBcXFwiIGVuY29kaW5nPVxcXCJVVEYtOFxcXCI/PlxcXFxuJyArIHhtbCk7XFxuICAgICAgICAgICAgaWYgKG9ubHlEb3dubG9hZCkgcmV0dXJuIFxcXCJ0b2FzdDovL+S4i+i9veWujOaIkFxcXCI7XFxuICAgICAgICAgICAgcmVmcmVzaFZpZGVvVXJsKHtcXG4gICAgICAgICAgICAgICAgZGFubXU6IHBhdGhcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBiYWNrKGZhbHNlKTtcXG4gICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5Yqg6L295a6M5oiQXFxcIjtcXG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICBoaWRlTG9hZGluZygpO1xcbiAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly9cXFwiICsgZS50b1N0cmluZygpO1xcbiAgICAgICAgfVxcbiAgICB9LCBvbmx5RG93bmxvYWQpLFxcbiAgICBjb2xfdHlwZTogXFxcInRleHRfM1xcXCJcXG59KTtcXG5kLnB1c2goe1xcbiAgICB0aXRsZTogXFxcImRt55uS5a2Q5pCc57SiXFxcIixcXG4gICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKChrZXksIG9ubHlEb3dubG9hZCkgPT4ge1xcbiAgICAgICAgbGV0IGRtID0gZ2V0VmFyKFxcXCJkbV9zaGFyZVxcXCIpO1xcbiAgICAgICAgaWYgKGRtICYmICFvbmx5RG93bmxvYWQpIHtcXG4gICAgICAgICAgICBjbGVhclZhcihcXFwiZG1fc2hhcmVcXFwiKTtcXG4gICAgICAgICAgICByZWZyZXNoVmlkZW9Vcmwoe1xcbiAgICAgICAgICAgICAgICBkYW5tdTogZG1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBiYWNrKGZhbHNlKTtcXG4gICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5Yqg6L295a6M5oiQXFxcIjtcXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgcmV0dXJuICQoa2V5LCBcXFwiZG3nm5LlrZDmkJzntKJcXFwiKS5pbnB1dCgoKSA9PiB7XFxuICAgICAgICAgICAgICAgIHRvYXN0KFxcXCLkuIvovb3lrozmiJDlvLnluZXlkI7or7fph43mlrDngrnlh7vmkJzntKJcXFwiKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3NlYXJjaD9ydWxlPWRt55uS5a2QJnM9XFxcIiArIGlucHV0O1xcbiAgICA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OKGEpIHx8IE51bWJlci5pc05hTihiKSkge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+ivt+aMieagvOW8j+i+k+WFpeaVsOWtl1xcXCI7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgaWYgKGEgPCAxIHx8IGIgPiBlcGlzb2Rlcy5sZW5ndGgpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/or7fovpPlhaXop4TlrprojIPlm7TlhoXnmoTmlbDlrZdcXFwiO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGNvbnN0IGRhbm11ID0gJC5yZXF1aXJlKFxcXCJkYW5tdVxcXCIpO1xcbiAgICAgICAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IGEgLSAxLCBqID0gMTsgaSA8IGI7IGkrKywgaisrKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGVwaXNvZGUgPSBlcGlzb2Rlc1tpXTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgZG1UaXRsZSA9IGFuaW1lVGl0bGUgKyBcXFwiX1xcXCIgKyBlcGlzb2RlLmVwaXNvZGVUaXRsZTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBzaG93TG9hZGluZyhcXFwi5q2j5Zyo5LiL6L2977yaXFxcIiArIGVwaXNvZGUuZXBpc29kZVRpdGxlICsgXFxcIlxcXFx0KFxcXCIgKyBqICsgXFxcIi9cXFwiICsgKGIgLSBhICsgMSkgKyBcXFwiKVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGRhbm11LmRvd25sb2FkRGFuTXUoZXBpc29kZS5lcGlzb2RlSWQsIGRtVGl0bGUpO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgICAgICAgICBsb2coZS50b1N0cmluZygpKTtcXG4gICAgICAgICAgICAgICAgICAgIGhpZGVMb2FkaW5nKCk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5ZOm5ZOm5LiL6L295aSx6LSlLi4uXFxcIjtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBoaWRlTG9hZGluZygpO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5LiL6L295a6M5oiQXFxcIjtcXG4gICAgICAgICAgICB9LCBhbmltZS5hbmltZVRpdGxlLCBhbmltZS5lcGlzb2RlcyksXFxuICAgICAgICAgICAgcGljX3VybDogXFxcImh0dHBzOi8vaGlrZXJmYW5zLmNvbS90dWJpYW8vbW92aWUvMTQuc3ZnXFxcIlxcbiAgICAgICAgfSk7XFxuICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwibGluZVxcXCJcXG4gICAgICAgIH0pO1xcbiAgICAgICAgZm9yIChsZXQgZXBpc29kZSBvZiBhbmltZS5lcGlzb2Rlcykge1xcbiAgICAgICAgICAgIGxldCBkbVRpdGxlID0gYW5pbWUuYW5pbWVUaXRsZSArIFxcXCJfXFxcIiArIGVwaXNvZGUuZXBpc29kZVRpdGxlO1xcbiAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBlcGlzb2RlLmVwaXNvZGVUaXRsZSxcXG4gICAgICAgICAgICAgICAgdXJsOiAkKGVwaXNvZGUuZXBpc29kZUlkKS5sYXp5UnVsZSgodXJsLCB0aXRsZSwgb25seURvd25sb2FkKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBjb25zdCBkYW5tdSA9ICQucmVxdWlyZShcXFwiZGFubXVcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBwYXRoID0gZGFubXUuZ2V0TG9jYWxEYW5NdShpbnB1dCwgdGl0bGUpIHx8IGRhbm11LmRvd25sb2FkRGFuTXUoaW5wdXQsIHRpdGxlKTtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChvbmx5RG93bmxvYWQpIHJldHVybiBcXFwidG9hc3Q6Ly/kuIvovb3lrozmiJBcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IGRhbm11VGV4dCA9IGZldGNoKHBhdGgpO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFkYW5tdVRleHQpIHJldHVybiBcXFwidG9hc3Q6Ly/ov5jmsqHmnInlvLnluZXlk59+XFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIHJlZnJlc2hWaWRlb1VybCh7XFxuICAgICAgICAgICAgICAgICAgICAgICAgZGFubXU6IHBhdGhcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgYmFjayhmYWxzZSk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5Yqg6L295a6M5oiQXFxcIjtcXG4gICAgICAgICAgICAgICAgfSwgTVlfUEFSQU1TLmR1cmwsIGRtVGl0bGUsIG9ubHlEb3dubG9hZCksXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF8xXFxcIixcXG4gICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgIGxvbmdDbGljazogW3tcXG4gICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuW8uuWItuS4i+i9vVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKGVwaXNvZGVUaXRsZSwgZXBpc29kZUlkKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNob3dMb2FkaW5nKFxcXCLor7fnrYnlvoVcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZGFubXUgPSAkLnJlcXVpcmUoXFxcImRhbm11XFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhbm11LmRvd25sb2FkRGFuTXUoZXBpc29kZUlkLCBlcGlzb2RlVGl0bGUpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoaWRlTG9hZGluZygpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v6YeN5paw5LiL6L295a6M5oiQ77yM5Y2V5Ye75oyC6L2944CCXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgICB9LCBkbVRpdGxlLCBlcGlzb2RlLmVwaXNvZGVJZClcXG4gICAgICAgICAgICAgICAgICAgIH1dXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH1cXG4gICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJsaW5lX2JsYW5rXFxcIlxcbiAgICAgICAgfSk7XFxuICAgIH1cXG4gICAgaWYgKCFkbUxpc3QuYW5pbWVzLmxlbmd0aCkge1xcbiAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuayoeacieaJvuWIsOS4jltcXFwiICsgbmFtZSArIFxcXCJd55u45YWz55qE5by55bmVXFxcIixcXG4gICAgICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgICAgICBkZXNjOiBcXFwi5pCc5LiN5Yiw5oCO5LmI5Yqe77yfXFxcXG7mo4Dmn6XlkI3np7DmmK/lkKbmraPnoa7vvJvlj6/ku6XlsJ3or5XliKDpmaTpg6jliIbpmZDlrpror43vvIzlpoLnrKzkuIDlraPnrYnvvJvogIzkuJTlj6rog73mkJzntKLnlarliaflk6bvvIHlhbbku5blvLnluZXlj6/nlKhkbeebkuWtkOOAglxcXCIsXFxuICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIlxcbiAgICAgICAgfSk7XFxuICAgIH1cXG59XFxub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R5cGUnOiAnYXBwbGljYXRpb24vanNvbicsXFxuICAgICAgICAgICAgICAgICAgICAgICAgXFxcIlVzZXItQWdlbnRcXFwiOiBQQ19VQSxcXG4gICAgICAgICAgICAgICAgICAgICAgICBcXFwiUmVmZXJlclxcXCI6IFxcXCJodHRwczovL3d3dy5hbGl5dW5kcml2ZS5jb20vXFxcIlxcbiAgICAgICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgICAgIGJvZHk6IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBcXFwic2hhcmVfaWRcXFwiOiBzaGFyZUlkXFxuICAgICAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICAgICAgbWV0aG9kOiAnUE9TVCdcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIGlmIChzaGFyZS5pbmNsdWRlcyhcXFwic2hhcmVfbGluayBpc1xcXCIpIHx8IHNoYXJlLmluY2x1ZGVzKFxcXCJzaGFyZV9saW5rIGNhbm5vdFxcXCIpKSByZXR1cm4gZmFsc2U7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSBjYXRjaCAoZSkge31cXG4gICAgICAgIHJldHVybiB0cnVlO1xcbiAgICB9LFxcbiAgICBieXRlc1RvU2l6ZShzaXplKSB7XFxuICAgICAgICBpZiAoIXNpemUpIHtcXG4gICAgICAgICAgICByZXR1cm4gJzAnO1xcbiAgICAgICAgfVxcbiAgICAgICAgY29uc3QgdW5pdHMgPSBbJ0InLCAnS0InLCAnTUInLCAnR0InLCAnVEInLCAnUEInLCAnRUInLCAnWkInLCAnWUInXTtcXG4gICAgICAgIGxldCBpID0gMDtcXG4gICAgICAgIHdoaWxlIChzaXplID49IDEwMjQpIHtcXG4gICAgICAgICAgICBzaXplIC89IDEwMjQ7XFxuICAgICAgICAgICAgaSsrO1xcbiAgICAgICAgfVxcbiAgICAgICAgc2l6ZSA9IGkgPyBOdW1iZXIoc2l6ZS50b0ZpeGVkKDIpKSA6I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FxuICAgIGlmICh1cGRhdGVJbmZvKSB7XFxuICAgICAgICBjb25maXJtKHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuabtOaWsOWGheWuuVxcXCIsXFxuICAgICAgICAgICAgY29udGVudDogdXBkYXRlSW5mbyxcXG4gICAgICAgICAgICBjb25maXJtKCl7fSxcXG4gICAgICAgICAgICBjYW5jZWwoKXt9XFxuICAgICAgICB9KTtcXG4gICAgfVxcbiAgICBzZXRSZXN1bHQoZCk7XFxuICAgIHdoaWxlICh0aW1lICE9IDApIHtcXG4gICAgICAgIGphdmEubGFuZy5UaHJlYWQuc2xlZXAoMTAwMCk7XFxuICAgICAgICB0aW1lIC09IDE7XFxuICAgICAgICB1cGRhdGVJdGVtKGlkICsgXFxcInRpbWVyXFxcIiwge1xcbiAgICAgICAgICAgIHRpdGxlOiB0aW1lICsgXFxcIuenkuWQjue7p+e7rVxcXCJcXG4gICAgICAgIH0pO1xcbiAgICB9XFxuICAgIHVwZGF0ZUl0ZW0oaWQgKyBcXFwidGltZXJcXFwiLCB7XFxuICAgICAgICB0aXRsZTogXFxcIuKAnOKAnOaIkeWQjOaEj+S7peS4iuimgeaxguKAneKAnVxcXCIsXFxuICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKHYpID0+IHtcXG4gICAgICAgICAgICBzZXRJdGVtKFxcXCJmaXJzdFxcXCIsIFN0cmluZyh2KSk7XFxuICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5oSf6LCi5oKo55qE55CG6KejXFxcIjtcXG4gICAgICAgIH0sIE1ZX1JVTEUudmVyc2lvbiksXFxuICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiXFxuICAgIH0pO1xcbn1cIn0se1wiY29sX3R5cGVcIjpcIm1vdmllXzNcIixcIm5hbWVcIjpcIuaNkOi1oFwiLFwicGF0aFwi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AgbGV0IGFsbFVybHMgPSBbXTtcXG4gICAgbGV0IGxpc3QgPSBmaW5kSXRlbXNCeUNscyhcXFwidlxcXCIgKyBwYWdlSWQpO1xcbiAgICBpZiAoIUFycmF5LmlzQXJyYXkobGlzdCkgfHwgbGlzdC5sZW5ndGggPT09IDApIHtcXG4gICAgICAgIC8qdG9hc3QoXFxcIui/mOayoeacieWKoOi9veWujOaIkOeahOinhumikVxcXCIpO1xcbiAgICAgICAgYmFjayhmYWxzZSk7XFxuICAgICAgICByZXR1cm47Ki9cXG4gICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLigJzigJzigJ3igJ1cXFwiICsgXFxcIn5+fui/mOacqOacieinhumikeWTpn5+flxcXCIuZm9udGNvbG9yKFxcXCJncmV5XFxcIiksXFxuICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2VcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9KTtcXG4gICAgICAgIGFsbC51cmwgPSBcXFwidG9hc3Q6Ly/msqHmnInop4bpopHml6Dms5XmjqjpgIFcXFwiO1xcbiAgICB9IGVsc2Uge1xcbiAgICAgICAgbGlzdC5mb3JFYWNoKHYgPT4ge1xcbiAgICAgICAgICAgIHYuY29sX3R5cGUgPSB2LnR5cGU7XFxuICAgICAgICAgICAgbGV0IG5hbWUgPSB2LmV4dHJhLnBhZ2VUaXRsZTtcXG4gICAgICAgICAgICBsZXQgdXJsID0gbmFtZS5yZXBsYWNlKC9cXFxcIy9nLCAnXycpLnJlcGxhY2UoL1xcXFwkL2csICdfJykgKyBcXFwiJHZpZGVvfFxcXCIgKyB2LmV4dHJhLmlkO1xcbiAgICAgICAgICAgIGFsbFVybHMucHVzaCh1c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cXFwiKS5pbnB1dCgobGVuZ3RoKSA9PiB7XFxuICAgICAgICBsZXQgaW5kZXhjID0gaW5wdXQuc3BsaXQoLyx877yMLyk7XFxuICAgICAgICBsZXQgaW5kZXhzID0gW107XFxuICAgICAgICBsZXQgbW8gPSBwYXJzZUludChpbmRleGNbMF0pO1xcbiAgICAgICAgaWYgKCEoaW5kZXhjLmxlbmd0aCAhPT0gMCAmJiBtbyA8IDAgJiYgbW8gPiAtNSkpIHtcXG4gICAgICAgICAgICBmb3IgKGxldCBpdCBvZiBpbmRleGMpIHtcXG4gICAgICAgICAgICAgICAgbGV0IG51bSA9IHBhcnNlSW50KGl0KTtcXG4gICAgICAgICAgICAgICAgaWYgKE51bWJlci5pc05hTihudW0pIHx8IG51bSA+PSBsZW5ndGggfHwgbnVtIDwgMCkge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+aVsOWtl+S4jeWQiOazlVxcXCI7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgaW5kZXhzLnB1c2gobnVtKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgICAgICByZXR1cm4gJChbXFxcIkhJS0VSXFxcIiwgXFxcIlRYVFxcXCJdLmNvbmNhdChnZXRQYXN0ZXMoKSksIDIsIFxcXCLliIbkuqvmlrnlvI9cXFwiKS5zZWxlY3QoKG1vLCBpbmRleHMsIGV4dCkgPT4ge1xcbiAgICAgICAgICAgIGZ1bmN0aW9uIHVwKHJ1bGVzKSB7XFxuICAgICAgICAgICAgICAgIGxldCBydWxlYjY0ID0gYmFzZTY0RW5jb2RlKEpTT04uc3RyaW5naWZ5KHJ1bGVzKSk7XFxuICAgICAgICAgICAgICAgIGxldCBnZXRQYXNzID0gKGxlbmd0aCwgcnVsZSwgdHlwZSkgPT4gXFxcIua1t+mYlOinhueVjOS6keeugOaQnOe0ouW8leaTju+8jOWFseOAjFxcXCIgKyBsZW5ndGggKyBcXFwi44CN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ICAgICAgICAgICBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKG1vID09PSAtMikge1xcbiAgICAgICAgICAgICAgICBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldFVzZWZ1bEpzb24oKTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKG1vID09PSAtMykge1xcbiAgICAgICAgICAgICAgICBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEZvcmJpZGRlbkpzb24oKTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKG1vID09PSAtNCkge1xcbiAgICAgICAgICAgICAgICBsZXQgZ3JvdXAgPSBleHQ7XFxuICAgICAgICAgICAgICAgIHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0R3JvdXBKc29uKGV4dCk7XFxuICAgICAgICAgICAgICAgIGlmICghcnVsZXMubGVuZ3RoKSByZXR1cm4gXFxcInRvYXN0Oi8v5LiN5a2Y5Zyo6K+l57uEXFxcIjtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKS5maWx0ZXIoKHYsIGkpID0+IGluZGV4cy5pbmNsdWRlcyhpKSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJ1bGVzID0gcnVsZXMubWFwKCh2KSA9PiB7XFxuICAgICAgICAgICAgICAgIHYudXNlciA9IHVuZGVmaW5lZDtcXG4gICAgICAgICAgICAgICAgdi5mb3JiaWRkZW4gPSB1bmRlZmluZWQ7XFxuICAgICAgICAgICAgICAgIHJldHVybiB2O1xcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIHJldHVybiB1cChydWxlcyk7XFxuICAgICAgICB9LCBtbywgaW5kZXhzLCBpbmR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vKTtcXG4gICAgICAgICAgICAgICAgc3RhcnQgPSBwYXJzZUludChzdGFydCksIGVuZCA9IHBhcnNlSW50KGVuZCk7XFxuICAgICAgICAgICAgICAgIGlmIChOdW1iZXIuaXNOYU4oc3RhcnQpIHx8IE51bWJlci5pc05hTihlbmQpIHx8IHN0YXJ0IDwgMCB8fCBlbmQgPiBsZW5ndGggLSAxIHx8IHN0YXJ0ID4gZW5kKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5pWw5a2X5LiN5ZCI5rOVXFxcIjtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBsZXQgbnVtYmVyID0gZW5kIC0gc3RhcnQgKyAxO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gJChcXFwi56Gu6K6k5Yig6Zmk77yaW1xcXCIgKyBzdGFydCArIFxcXCIsXFxcIiArIGVuZCArIFxcXCJdXFxcXG7lhbFcXFwiICsgbnVtYmVyICsgXFxcIuadoeaQnOe0ouW8leaTjlxcXCIpLmNvbmZpcm0oKHN0YXJ0LCBudW1iZXIpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICAgICAgICAgIHJ1bGVzLnNwbGljZShzdGFydCwgbnVtYmVyKTtcXG4gICAgICAgICAgICAgICAgICAgICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLnNhdmVKc29uKHJ1bGVzKTtcXG4gICAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKGZhbHNlKTtcXG4gICAgICAgICAgICAgICAgfSwgc3RhcnQsIG51bWJlcik7XFxuICAgICAgICAgICAgfSwgbGVuZ3RoKTtcXG4gICAgICAgIH1cXG4gICAgfSwgZ3JvdXAsIGxlbmd0aCksXFxuICAgIGNvbF90eXBlOiBcXFwic2Nyb2xsX2J1dHRvblxcXCJcXG59KTtcXG5mb3IgKGxldCBpdCBvZiBncm91cHMpIHtcXG4gICAgZC5wdXNoKHtcXG4gICAgICAgIHRpdGxlOiBpdCA9PT0gZ3JvdXAgPyBcXFwi4oCc4oCcXFxcIiArIGl0ICsgXFxcIuKAneKAnVxcXCIgOiBpdCxcXG4gICAgICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgoaXQsIGdyb3VwKSA9PiB7XFxuICAgICAgICAgICAgaWYgKGdyb3VwICE9PSBpdCkge1xcbiAgICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJydWxlTWFuYWdlX2dyb3VwXFxcIiwgaXQpO1xcbiAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiAkKFtcXFwi572u6aG2XFxcIiwgXFxcIue9ruW6lVxcXCIsIFxcXCLmlLnlkI1cXFwiLCBcXFwi5Yig6ZmkXFxcIl0pLnNlbGVjdCgoaXQpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChcXFwi5pS55ZCNXFxcIiA9PT0gaW5wdXQpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJChpdCwgXFxcIuivt+i+k+WFpeaWsOWQjeensFxcXCIpLmlucHV0KChpdCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZXMgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJ1bGVzLmZvckVhY2godiA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXQgPT09IHYuZ3JvdXApIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2Lmdyb3VwID0gaW5wdXQ7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5zYXZlSnNvbihydWxlcyk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsZWFySXRlbShcXFwicnVsZU1hbmFnZV9ncm91cFxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgfSwgaXQpO1xcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChcXFwi5Yig6ZmkXFxcIiA9PT0gaW5wdXQpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJChcXFwi5piv5ZCm5Yig6Zmk6K+l57uE5pCc57Si5byV5pOO77yaXFxcIiArIGl0KS5jb25maXJtKChpdCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZXMgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJ1bGVzID0gcnVsZXMuZmlsdGVyKHYgPT4gdi5ncm91cCAhPT0gaXQpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5zYXZlSnNvbihydWxlcyk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsZWFySXRlbShcXFwicnVsZU1hbmFnZV9ncm91cFxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgfSwgaXQpO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHRnUnVsZXMgPSBbXSxcXG4gICAgICAgICAgICAgICAgICAgICAgICB0eFJ1bGVzID0gW107XFxuICAgICAgICAgICAgICAgICAgICBydWxlcy5mb3JFYWNoKCh2KSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGl0ID09PSB2Lmdyb3VwKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRnUnVsZXMucHVzaCh2KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0eFJ1bGVzLnB1c2godik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoaW5wdXQgPT09IFxcXCLnva7pobZcXFwiKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdGdSdWxlcyA9IHRnUnVsZXMuY29uY2F0KHR4UnVsZXMpO1xcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB0Z1J1bGVzID0gdHhSdWxlcy5jb25jYXQodGdSdWxlcyk7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5zYXZlSnNvbih0Z1J1bGVzKTtcXG4gICAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKGZhbHNlKTtcXG4gICAgICAgICAgICAgICAgfSwgaXQpO1xcbiAgICAgICAgICAgIH1cXG5cXG4gICAgICAgIH0sIGl0LCBncm91cCksXFxuICAgICAgICBjb2xfdHlwZTogXFxcInNjcm9sbF9idXR0b25cXFwiXFxuICAgIH0pO1xcbn1cXG5cXG5sZXQg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FxcIjtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlucHV0ID09PSBcXFwi6LSm5Y+3XFxcIikge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vcGFnZS9wYXNzd29yZCNub1JlY29yZEhpc3RvcnkjI25vSGlzdG9yeSMjbm9SZWZyZXNoI1xcXCI7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChpbnB1dCA9PT0gXFxcIuWIhuS6q1xcXCIpIHtcXG4gICAgICAgICAgICAgICAgbGV0IG9wcyA9IGdldFBhc3RlcygpO1xcbiAgICAgICAgICAgICAgICBvcHMudW5zaGlmdChcXFwi5a6M5pW05Y+j5LukXFxcIik7XFxuICAgICAgICAgICAgICAgIHJldHVybiAkKG9wcywgMiwgXFxcIuWIhuS6q+aWueW8j1xcXCIpLnNlbGVjdCgoaW5kZXgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpW2luZGV4XTtcXG4gICAgICAgICAgICAgICAgICAgIHJ1bGUudXNlciA9IHVuZGVmaW5lZDtcXG4gICAgICAgICAgICAgICAgICAgIHJ1bGUuZm9yYmlkZGVuID0gdW5kZWZpbmVkO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGViNjQgPSBiYXNlNjRFbmNvZGUoSlNPTi5zdHJpbmdpZnkocnVsZSkpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IGdldFBhc3MgPSAobmFtZSwgcnVsZSwgdHlwZSkgPT4gXFxcIua1t+mYlOinhueVjO+8jOOAjFxcXCIgKyBuYW1lICsgXFxcIuOAjeS6keeugOaQnOe0ouW8leaTju+8jOWkjeWItuaVtOadoeWPo+S7pOaJk+W8gOi9r+S7tuWwseS8muiHquWKqOWvvOWFpSRcXFwiICsgcnVsZSArIFxcXCIkXFxcIiArIHR5cGUgKyBcXFwiQGltcG9ydD1qczokLnJlcXVpcmUoJ2ltcG9ydD9ydWxlPScrXFxcIiArIEpTT04uc3RyaW5naWZ5KE1ZX1JVTEUudGl0bGUpICsgXFxcIikoaW5wdXQpXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChpbnB1dCA9PSBcXFwi5a6M5pW05Y+j5LukXFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiY29weTovL1xcXCIgKyBnZXRQYXNzKHJ1bGUubmFtZSwgcnVsZWI2NCwgXFxcImFcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHUgPSBzaGFyZVBhc3RlKHJ1bGViNjQsIGlucHV0KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImNvcHk6Ly9cXFwiICsgZ2V0UGFzcyhydWxlLm5hbWUsIHUsIFxcXCJiXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH0sIGluZGV4KTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlucHV0ID09PSBcXFwi56e75YqoXFxcIikge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gJChpbmRleCArIFxcXCJcXFwiLCBcXFwi6L6T5YWl5L2N572uXFxcIikuaW5wdXQoKGluZGV4LCBsZW5ndGgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBuZXdJbmRleCA9IE51bWJlcihpbnB1dCk7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoTnVtYmVyLmlzTmFOKG5ld0luZGV4KSB8fCBuZXdJbmRleCA+PSBsZW5ndGgpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5LiN5ZKM6KeE55qE5L2N572uXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlID0gcnVsZXMuc3BsaWNlKGluZGV4LCAxKVswXTtcXG4gICAgICAgICAgICAgICAgICAgIHJ1bGVzLnNwbGljZShuZXdJbmRleCwgMCwgcnVsZSk7XFxuICAgICAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5zYXZlSnNvbihydWxlcyk7XFxuICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAgICAgICAgIH0sIGluZGV4LCBsZW5ndGgpO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoaW5wdXQgPT09IFxcXCLnva7pobZcXFwiKSB7XFxuICAgICAgICAgICAgICAgIGxldCBuZXdJbmRleCA9IDA7XFxuICAgICAgICAgICAgICAgIGxldCBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICAgICAgaWYgKGdyb3VwKSB7XFxuICAgICAgICAgICAgICAgICAgICBuZXdJbmRleCA9IHJ1bGVzLmZpbmRJbmRleCh2ID0+IHYuZ3JvdXAgPT09IGdyb3VwKTtcXG4gICAgICAgICAgICAgICAgICAgIG5ld0luZGV4ID0gbmV3SW5kZXggPT09IC0xID8gMCA6IG5ld0luZGV4O1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGxldCBydWxlID0gcnVsZXMuc3BsaWNlKGluZGV4LCAxKVswXTtcXG4gICAgICAgICAgICAgICAgcnVsZXMuc3BsaWNlKG5ld0luZGV4LCAwLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuc2F2ZUpzb24ocnVsZXMpO1xcbiAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChpbnB1dCA9PT0gXFxcIuWIoOmZpFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuICQoXFxcIuehruiupOWIoOmZpO+8n1xcXCIpLmNvbmZpcm0oKGluZGV4KSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZXMgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZSA9IHJ1bGVzLnNwbGljZShpbmRleCwgMSlbMF07XFxuICAgICAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5zYXZlSnNvbihydWxlcyk7XFxuICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5bey5Yig6ZmkXFxcIiArIHJ1bGUubmFtZTtcXG4gICAgICAgICAgICAgICAgfSwgaW5kZXgpO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIGxldCBhcnIgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICAgICAgICAgIGxldCBydWxlID0gYXJyW2luZGV4XTtcXG4gICAgICAgICAgICAgICAgcnVsZS5mb3JiaWRkZW4gPSAhcnVsZS5mb3JiaWRkZW47XFxuICAgICAgICAgICAgICAgICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLnNhdmVKc29uKGFycik7XFxuICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKGZhbHNlKTtcXG4gICAgICAgICAgICAgICAgLy9yZXR1cm4gXFxcInRvYXN0Oi8vXFxcIiArIChydWxlLmZvcmJpZGRlbiA/IFxcXCLnpoHnlKhcXFwiIDogXFxcIuWQr+eUqFxcXCIpICsgcnVsZS5uYW1lO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0sIGksIGxlbmd0a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hLCB7XFxuICAgICAgICAgICAgICAgIGRlZmF1bHRWYWx1ZTogbmV3QXV0aG9yXFxuICAgICAgICAgICAgfSlcXG4gICAgICAgIH0pO1xcbiAgICB9KSxcXG4gICAgZXh0cmE6IHtcXG4gICAgICAgIG9uQ2hhbmdlOiAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICAgICAgICBwdXRNeVZhcihcXFwicHNfYXV0aG9yXFxcIiwgaW5wdXQpO1xcbiAgICAgICAgfSksXFxuICAgICAgICBkZWZhdWx0VmFsdWU6IG9iai5hdXRob3IsXFxuICAgICAgICBpZDogXFxcImlkQHBzX2F1dGhvclxcXCJcXG4gICAgICAgIC8vdGl0bGVWaXNpYmxlOiBmYWxzZVxcbiAgICB9XFxufSk7XFxuZC5wdXNoKHtcXG4gICAgdGl0bGU6IFxcXCLpgInmi6lcXFwiLFxcbiAgICBjb2xfdHlwZTogXFxcImlucHV0XFxcIixcXG4gICAgZGVzYzogXFxcIuWIhue7hCjpgInloaspXFxcIixcXG4gICAgdXJsOiAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICAgIGxldCBncm91cCA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEdyb3VwTmFtZXMoKTtcXG4gICAgICAgIGlmICghZ3JvdXAubGVuZ3RoKSB7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJcXFwiO1xcbiAgICAgICAgfVxcbiAgICAgICAgcmV0dXJuICQoZ3JvdXApLnNlbGVjdCgoKSA9PiB7XFxuICAgICAgICAgICAgbGV0IGV4dHJhID0gZmluZEl0ZW0oXFxcInJ1bGVFZGl0R3JvdXBcXFwiKS5leHRyYTtcXG4gICAgICAgICAgICB1cGRhdGVJdGVtKFxcXCJydWxlRWRpdEdyb3VwXFxcIiwge1xcbiAgICAgICAgICAgICAgICBleHRyYTogT2JqZWN0LmFzc2lnbihleHRyYSwge1xcbiAgICAgICAgICAgICAgICAgICAgZGVmYXVsdFZhbHVlOiBpbnB1dFx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biAgICAgICAgICAgIGJhc2ljVXJsOiBnZXRNeVZhcihcXFwicHNfYmFzaWNVcmxcXFwiLCBcXFwiXFxcIiksXFxuICAgICAgICAgICAgZmluZEFsaVVybDogZ2V0TXlWYXIoXFxcInBzX2ZpbmRBbGlVcmxcXFwiLCBcXFwiXFxcIiksXFxuICAgICAgICAgICAgcGFnZTogISFnZXRNeVZhcihcXFwicHNfcGFnZVxcXCIsIHBhZ2UgPyBcXFwiMVxcXCIgOiBcXFwiXFxcIiksXFxuICAgICAgICAgICAgcmVnaXN0ZXJVcmw6IGdldE15VmFyKFxcXCJwc19yZWdpc3RlclVybFxcXCIsIFxcXCJcXFwiKSB8fCB1bmRlZmluZWQsXFxuICAgICAgICAgICAgbGFzdE1vZGlmeTogRGF0ZS5ub3coKSxcXG4gICAgICAgICAgICBncm91cDogZ2V0TXlWYXIoXFxcInBzX2dyb3VwXFxcIiwgXFxcIlxcXCIpLFxcbiAgICAgICAgICAgIHJ1bGVUeXBlOiBnZXRNeVZhcihcXFwicHNfcnVsZVR5cGVcXFwiLCBcXFwiXFxcIiksXFxuICAgICAgICB9O1xcbiAgICAgICAgaWYgKGluZGV4ID09PSB2b2lkKDApKSB7XFxuICAgICAgICAgICAgaWYgKGFyci5zb21lKHYgPT4gdi5uYW1lID09PSBuYW1lKSkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5bey57uP5a2Y5Zyo6K+l6KeE5YiZXFxcIjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKG9iajEuZ3JvdXApIHtcXG4gICAgICAgICAgICAgICAgbGV0IGdyb3VwID0gb2JqMS5ncm91cDtcXG4gICAgICAgICAgICAgICAgbGV0IGluZGV4ID0gYXJyLmZpbmRJbmRleCh2ID0+IHYuZ3JvdXAgPT09IGdyb3VwKTtcXG4gICAgICAgICAgICAgICAgaWYgKGluZGV4ID09PSAtMSkge1xcbiAgICAgICAgICAgICAgICAgICAgYXJyLnVuc2hpZnQob2JqMSk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBhcnIuc3BsaWNlKGluZGV4LCAwLCBvYmoxKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIGlmIChpc0ltcG9ydCkge1xcbiAgICAgICAgICAgICAgICAgICAgYXJyLnB1c2gob2JqMSk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBhcnIudW5zaGlmdChvYmoxKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgbGV0IG5hbWV5ID0gYXJyW2luZGV4XS5uYW1lO1xcbiAgICAgICAgICAgIGlmIChuYW1lICE9PSBuYW1leSkge1xcbiAgICAgICAgICAgICAgICBpZiAoYXJyLnNvbWUodiA9PiB2Lm5hbWUgPT09IG5hbWUpKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5bey57uP5a2Y5Zyo6K+l6KeE5YiZXFxcIjtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBvYmoxID0gT2JqZWN0LmFzc2lnbihhcnJbaW5kZXhdLCBvYmoxKTtcXG4gICAgICAgICAgICBhcnIuc3BsaWNlKGluZGV4LCAxLCBvYmoxKTtcXG4gICAgICAgIH1cXG4gICAgICAgICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLnNhdmVKc29uKGFycik7XFxuICAgICAgICBiYWNrKHRydWUpO1xcbiAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+S/neWtmOaIkOWKn1xcXCI7XFxuICAgIH0sIGluZGV4LCBvYmoucGFnZSwgaXNJbXBvcnQpLFxcbiAgICBjb2xfdHlwZTogXFxcInRleHRfM1xcXCIsXFxufS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ICAgICAgY29sX3R5cGU6XFxcIng1X3dlYnZpZXdfc2luZ2xlXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIHVybDpyZWdpc3RlclVybCxcXG4gICAgICAgICAgICAgICAgICAgIGRlc2M6XFxcImZsb2F0JiYxMDAlXFxcIlxcbiAgICAgICAgICAgICAgICB9XSk7XFxuICAgICAgICAgICAgfSwgcmVnaXN0ZXJVcmwpLFxcbiAgICAgICAgICAgIGV4dHJhOntcXG4gICAgICAgICAgICAgICAgcGFnZVRpdGxlOiBcXFwi5rOo5YaM6LSm5Y+3OlxcXCIgKyBvYmoubmFtZVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0pO1xcbiAgICB9XFxuICAgIG9iaiA9IG9iai51c2VyIHx8IHt9O1xcbiAgICBkLnB1c2goe1xcbiAgICAgICAgY29sX3R5cGU6IFxcXCJpbnB1dFxcXCIsXFxuICAgICAgICBkZXNjOiBcXFwi55So5oi35ZCNXFxcIixcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgb25DaGFuZ2U6ICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICBwdXRNeVZhcihcXFwicHNfYWNjb3VudFxcXCIsIGlucHV0KTtcXG4gICAgICAgICAgICB9KSxcXG4gICAgICAgICAgICBkZWZhdWx0VmFsdWU6IG9iai5hY2NvdW50LFxcbiAgICAgICAgICAgIHRpdGxlVmlzaWJsZTogZmFsc2VcXG4gICAgICAgIH1cXG4gICAgfSk7XFxuICAgIGQucHVzaCh7XFxuICAgICAgICBjb2xfdHlwZTogXFxcImlucHV0XFxcIixcXG4gICAgICAgIGRlc2M6IFxcXCLlr4bnoIFcXFwiLFxcbiAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICB0eXBlOiBcXFwicGFzc3dvcmRcXFwiLFxcbiAgICAgICAgICAgIG9uQ2hhbmdlOiAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICAgICAgICAgICAgcHV0TXlWYXIoXFxcInBzX3Bhc3N3b3JkXFxcIiwgaW5wdXQpO1xcbiAgICAgICAgICAgIH0pLFxcbiAgICAgICAgICAgIGRlZmF1bHRWYWx1ZTogb2JqLnBhc3N3b3JkLFxcbiAgICAgICAgICAgIHRpdGxlVmlzaWJsZTogZmFsc2UsXFxuICAgICAgICB9XFxuICAgIH0pO1xcbiAgICBkLnB1c2goe1xcbiAgICAgICAgY29sX3R5cGU6IFxcXCJpbnB1dFxcXCIsXFxuICAgICAgICBkZXNjOiBcXFwi6aKd5aSWXFxcIixcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgdHlwZTogXFxcInRleHRhcmVhXFxcIixcXG4gICAgICAgICAgICBvbkNoYW5nZTogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgICAgICAgIHB1dE15VmFyKFxcXCJwc19leHRyYVxcXCIsIGlucHV0KTtcXG4gICAgICAgICAgICB9KSxcXG4gICAgICAgICAgICBkZWZhdWx0VmFsdWU6IG9iai5leHRyYSxcXG4gICAgICAgICAgICB0aXRsZVZpc2libGU6IGZhbHNlLFxcbiAgICAgICAgICAgIGhlaWdodDogLTFcXG4gICAgICAgIH1cXG4gICAgfSk7XFxuICAgIGQucHVzaCh7XFxuICAgICAgICB0aXRsZTogXFxcIuS/neWtmFxcXCIsXFxuICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKGluZGV4KSA9PiB7XFxuICAgICAgICAgICAgbGV0IGFjY291bnQgPSBnZXRNeVZhcihcXFwicHNfYWNjb3VudFxcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICBsZXQgcGFzc3dvcmQgPSBnZXRNeVZhcihcXFwicHNfcGFzc3dvcmRcXFwiLCBcXFwiXFxcIik7XFxuICAgICAgICAgICAgbGV0IGV4dHJhID0gZ2V0TXlWYXIoXFxcInBzX2V4dHJhXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgIC8qaWYgKCEoYWNjb3VudHx8cGFzc3dvcmR8fGV4dHJhKSkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5LiN6IO95YWo6YOo5Li656m6XFxcIjtcXG4gICAgICAgICAgICB9Ki9cXG4gICAgICAgICAgICBsZXQgYXJyID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgIGxldCBpdGVtID0gYXJyW2luZGV4XTtcXG4gICAgICAgICAgICBpdGVtLnVzZXIgPSB7fTtcXG4gICAgICAgICAgICBpdGVtLnVzZXIuYWNjb3VudCA9IGFjY291bnRcXG4gICAgICAgICAgICBpdGVtLnVzZXIucGFzc3dvcmQgPSBwYXNzd29yZDtcXG4gICAgICAgICAgICBpdGVtLnVzZXIuZXh0cmEgPSBleHRyYTtcXG4gICAgICAgICAgICBpZiAoaW5kZXggPT09IHZvaWQoMCkpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL2lk6ZSZ6K+vXFxcIjtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBhcnIuc3BsaWNlKGluZGV4LCAxLCBpdGVtKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuc2F2ZUpzb24oYXJyKTtcXG4gICAgICAgICAgICBiYWNrKHRydWUpO1xcbiAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/kv53lrZjmiJDlip9cXFwiO1xcbiAgICAgICAgfSwgaW5kZXgpLFxcbiAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgfSk7XFxuICAgIHNldFJlc3VsdChkKTtcXG59KSgpXCJ9LHtcImNvbF90eXBlXCI6XCJtb3ZpZV8zXCIsXCJuYW1lXCI6XCLop4TliJnlr7zlhaVcIixcInBhdGhcIjpcImltcG9ydFwiLFwicnVsZVwiOlwianM6XFxuZnVuY3Rpb24gc2F2ZUNhY2hlKGpzb24pIHtcXG4gICAgd3JpdGVGaWxlKFxcXCJoaWtlcjovL2ZpbGVzL19jYWNoZS95dW5TaW1wbGVJbXBvcnQuanNvblxcXCIsIEpTT04uc3RyaW5naWZ5KGpzb24pKTtcXG59XFxuJC5leHBvcnRzID0gZnVuY3Rpb24ocGFzcykge1xcbiAgICB0cnkge1xcbiAgICAgICAgbGV0IFtfLCBydWxlLCB0eXBlXSA9IHBhc3Muc3BsaXQoXFxcIiRcXFwiKTtcXG4gICAgICAgIGlmICh0eXBlID09PSBcXFwiYlxcXCIpIHtcXG4gICAgICAgICAgICBydWxlID0gcGFyc2VQYXN0ZShydWxlKTtcXG4gICAgICAgIH1cXG4gICAgICAgIGxldCBydWxlcyA9IEpTT04ucGFyc2UoYmFzZTY0RGVjb2RlKHJ1bGUpKTtcXG4gICAgICAgIGlmICghQXJyYXkuaXNBcnJheShydWxlcykpIHtcXG4gICAgICAgICAgICBydWxlcyA9IFtydWxlc107XFxuICAgICAgICB9XFxuICAgICAgICAvL3J1bGVzLnJldmVyc2UoKTtcXG4gICAgICAgIE1ZX1VSTCA9IG1vZHVsZS5pZDtcXG4gICAgICAgIGxldCBydWxlVGl0bGUgPSBnZXRQYXJhbShcXFwicnVsZVxcXCIpO1xcbiAgICAgICAgbGV0IGFyciA9ICQucmVxdWlyZShcXFwiY29uZmlncz9ydWxlPVxcXCIgKyBydWxlVGl0bGUpLmdldEpzb24oKTtcXG4gICAgICAgIGxldCBuZXdJID0gMDtcXG4gICAgICAgIGZvciAobGV0IHJ1bGUgb2YgcnVsZXMpIHtcXG4gICAgICAgICAgICBsZXQgaW5kZXggPSBhcnIuZmluZEluZGV4KHYgPT4gdi5uYW1lID09PSBydWxlLm5hbWUpO1xcbiAgICAgICAgICAgIGlmIChpbmRleCA+IC0xKSB7XFxuICAgICAgICAgICAgICAgIHJ1bGUgPSBPYmplY3QuYXNzaWduKGFycltpbmRleF0sIHJ1bGUpO1xcbiAgICAgICAgICAgICAgICBhcnIuc3BsaWNlKGluZGV4LCAxLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgaWYgKHJ1bGVzLmxlbmd0aCA9PT0gMSkge1xcbiAgICAgICAgICAgICAgICAgICAgc2F2ZUNhY2hlKHJ1bGUpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3BhZ2UvcnVsZUVkaXQjbm9IaXN0b3J5IyNub1JlY29yZEhpc3RvcnkjP2lzSW1wb3J0PXRydWUmaW5kZXg9XFxcIiArIGluZGV4ICsgXFxcIiZydWxlPVxcXCIgKyBydWxlVGl0bGU7XFxuICAgICAgICAgICAgICAgICAgICAvL3RvYXN0KFxcXCLlt7Lmm7TmlrDop4TliJnvvJpcXFwiICsgcnVsZS5uYW1lKTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIGxvZyhcXFwi5bey5pu05paw6KeE5YiZ77yaXFxcIiArIHJ1bGUubmFtZSlcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIG5ld0krKztcXG4gICAgICAgICAgICAgICAgYXJyLnB1c2gocnVsZSk7XFxuICAgICAgICAgICAgICAgIGlmIChydWxlcy5sZW5ndGggPT09IDEpIHtcXG4gICAgICAgICAgICAgICAgICAgIHNhdmVDYWNoZShydWxlKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL3J1bGVFZGl0I25vSGlzdG9yeSMjbm9SZWNvcmRIaXN0b3J5Iz9pc0ltcG9ydD10cnVlJnJ1bGU9XFxcIiArIHJ1bGVUaXRsZTtcXG4gICAgICAgICAgICAgICAgICAgIC8vdG9hc3QoXFxcIuW3suWvvOWFpeinhOWIme+8mlxcXCIgKyBydWxlLm5hbWUpO1xcbiAgICAgICAgICAgICAgICB9IGV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X2ZpbGV0eXBlPXVuZGVmaW5lZFxcXCI7XFxuICAgICAgICAgICAgbGV0IGpzb24gPSBwb3N0KGJhc2ljVXJsICsgYXBpLCB7XFxuICAgICAgICAgICAgICAgIGJvZHk6IFxcXCJkYXRhPVxcXCIgKyBhcGksXFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgIFJlZmVyZXI6IFxcXCJodHRwczovL3d3dy55dW5zby5uZXQvaW5kZXgvdXNlci9zP3dkPVxcXCIgKyBlbmNvZGVVUklDb21wb25lbnQocylcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIGxldCBodG1sID0gSlNPTi5wYXJzZShqc29uKS5kYXRhO1xcbiAgICAgICAgICAgIGxldCBsaXN0ID0gcGRmYShodG1sLCBcXFwiYm9keSYmLmxheXVpLWNhcmQ6aGFzKGEpXFxcIik7XFxuICAgICAgICAgICAgbGV0IGQgPSBbXTtcXG4gICAgICAgICAgICBmb3IgKGxldCBpdGVtIG9mIGxpc3QpIHtcXG4gICAgICAgICAgICAgICAgbGV0IHRpdGxlID0gcGRmaChpdGVtLCBcXFwiYSYmVGV4dFxcXCIpLnJlcGxhY2UoXFxcIiPmlofku7blpLkgXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgICAgICAvL2xldCB0aW1lID0gL1xcXFxkezR9KC1cXFxcZHsyfSl7Mn0gXFxcXGR7Mn0oXFxcXDpcXFxcZHsyfSl7Mn0vLmV4ZWMocGRmaChpdGVtLCBcXFwiLmxheXVpLWNhcmQtYm9keSYmVGV4dFxcXCIpKSB8fCBbXTtcXG4gICAgICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiB0aXRsZSxcXG4gICAgICAgICAgICAgICAgICAgIC8vZGVzYzogdGltZVswXSxcXG4gICAgICAgICAgICAgICAgICAgIHVybDogYmFzZTY0RGVjb2RlKHBkZmgoaXRlbSwgXFxcImEmJnVybFxcXCIpKVxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIGQ7XFxuICAgICAgICB9XFxuICAgIH0sIHtcXG4gICAgICAgIG5hbWU6IFxcXCLmt7flkIjnm5hcXFwiLFxcbiAgICAgICAgcGFnZTogdHJ1ZSxcXG4gICAgICAgIGZpbmQocywgcGFnZSkge1xcbiAgICAgICAgICAgIGxldCB1cmwgPSBcXFwiaHR0cHM6Ly9hcGkuaHVuaGVwYW4uY29tL3YxL3NlYXJjaFxcXCI7XFxuICAgICAgICAgICAgbGV0IGpzb24gPSBwb3N0KHVybCwge1xcbiAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICBSZWZlcmVyOiBcXFwiaHR0cHM6Ly9odW5oZXBhbi5jb20vXFxcIlxcbiAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICBib2R5OiBKU09OLnN0cmluZ2lmeSh7XFxuICAgICAgICAgICAgICAgICAgICBcXFwicVxcXCI6IHMsXFxuICAgICAgICAgICAgICAgICAgICBcXFwicGFnZVxcXCI6IHBhZ2UsXFxuICAgICAgICAgICAgICAgICAgICBcXFwic2l6ZVxcXCI6IDE1XFxuICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAganNvbiA9IEpTT04ucGFyc2UoanNvbik7XFxuICAgICAgICAgICAgbGV0IGxpc3QgPSBqc29uLmRhdGEubGlzdDtcXG4gICAgICAgICAgICBsZXQgZCA9IFtdO1xcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbGlzdC5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgICAgICBsZXQgaXQgPSBsaXN0W2ldO1xcbiAgICAgICAgICAgICAgICBpZiAoaXQuZGlza190eXBlICE9PSBcXFwiQUxZXFxcIiB8fCBpdC5zaGFyZV91c2VyID09PSBcXFwi5Li2Kioq5Li2XFxcIikgY29udGludWU7XFxuICAgICAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogaXQuZGlza19uYW1lLFxcbiAgICAgICAgICAgICAgICAgICAgcGljX3VybDogcGQoaXQsIFxcXCJpbWcmJnNyY1xcXCIsIHVybCksXFxuICAgICAgICAgICAgICAgICAgICB1cmw6IGl0LmxpbmssXFxuICAgICAgICAgICAgICAgICAgICBkZXNjOiBpdC51cGRhdGVfdGltZSArIFxcXCJcXFxcblxcXCIgKyBpdC5saW5rLFxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIGQ7XFxuICAgICAgICB9XFxuICAgIH0sIHtcXG4gICAgICAgIG5hbWU6IFxcXCLotYTmupDluK5cXFwiLFxcbiAgICAgICAgcGFnZTogdHJ1ZSxcXG4gICAgICAgIGZpbmQocywgcGFnZSkge1xcbiAgICAgICAgICAgIGZ1bmN0aW9uIHNlYXJjaCgpIHtcXG4gICAgICAgICAgICAgICAgbGV0IHJ0bkxpc3QgPSBbXTtcXG4gICAgICAgICAgICAgICAgbGV0IHJlc3AgPSByZXF1ZXN0KFxcXCJodHRwczovL3p5Yi51cHl1bnNvLmNvbS92MTUvc2VhcmNoP2tleXdvcmQ9XFxcIiArIGVuX2FlcyhzKSArIFxcXCImc190eXBlPTImcGFnZT1cXFwiICsgcGFnZSArIFxcXCImYXRrPSZkaWQ9XFxcIiArIGdlbmVyYXRlUmFuZG9tSGV4U3RyaW5nKDY0KSwge1xcbiAgICAgICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIFxcXCJ1c2VyLWFnZW50XFxcIjogXFxcIk1vemlsbGEvNS4wIChMaW51eDsgQW5kcm9pZCAxMDsgUmVkbWkgTm90ZSA3IEJ1aWxkL1FLUTEuMTkwOTEwLjAwMjsgd3YpIEFwcGxlV2ViS2l0LzUzNy4zNiAoS0hUTUwsIGxpa2UgR2Vja28pIFZlcnNpb24vNC4wIENocm9tZS84MS4wLjQwNDQuMTM4IE1vYmlsZSBTYWZhcmkvNTM3LjM2IHVuaS1hcHAgSHRtbDVQbHVzLzEuMCAoSW1tZXJzZWQvMjkuMDkwOTEpXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICBsZXQgcmVzcERhdGEgPSBkZV9hZXMocmVzcCk7XFxuICAgICAgICAgICAgICAgIGxldCBqc29uRGF0YSA9IEpTT04ucGFyc2UocmVzcERhdGEpIHx8IHt9O1xcbiAgICAgICAgICAgICAgICBsZXQgcmVzdWx0ID0ganNvbkRhdGEucmVzdWx0IHx8IHt9O1xcbiAgICAgICAgICAgICAgICBsZXQgaXRlbXMgPSByZXN1bHQuaXRlbXMgfHwgW107XFxuXFxuICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgaXRlbXMubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBpdGVtID0gaXRlbXNbaV07XFxuICAgICAgICAgICAgICAgICAgICBsZXQgY29udGVudCA9IGl0ZW0uY29udGVudCB8fCBbXTtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChjb250ZW50Lmxlbmd0aCA9PSAwIHx8ICFpdGVtLnBhZ2VfdXJsKSBjb250aW51ZTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCB1cmwgPSBkZV9hZXMoaXRlbS5wYWdlX3VybCkgfHwgXFxcIlxcXCI7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoIXVybCkgY29udGludWU7XFxuICAgICAgICAgICAgICAgICAgICBydG5MaXN0LnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiAoaXRlbS50aXRsZS5sZW5ndGggPiAzMCA/IGl0ZW0udGl0bGUuc2xpY2UoMCwgMjcpICsgXFxcIi4uLlxcXCIgOiBpdGVtLnRpdGxlKSB8fCBcXFwiXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICBkZXNjOiBcXFwi5YiG5Lqr5pe26Ze077yaXFxcIiArIGl0ZW0uaW5zZXJ0X3RpbWUsXFxuICAgICAgICAgICAgICAgICAgICAgICAgdXJsOiB1cmxcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9XFxuXFxuICAgICAgICAgICAgICAgIHJldHVybiBydG5MaXN0O1xcbiAgICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgICBmdW5jdGlvbiBnZW5lcmF0ZVJhbmRvbUhleFN0cmluZyhsZW5ndGgpIHtcXG4gICAgICAgICAgICAgICAgbGV0IHJlc3VsdCA9IFxcXCJcXFwiO1xcbiAgICAgICAgICAgICAgICBjb25zdCBjaGFyYWN0ZXJzID0gXFxcIjAxMjM0NTY3ODlhYmNkZWZcXFwiO1xcbiAgICAgICAgICAgICAgICBjb25zdCBjaGFyYWN0ZXJzTGVuZ3RoID0gY2hhcmFjdGVycy5sZW5ndGg7XFxuICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgICAgIHJlc3VsdCArPSBjaGFyYWN0ZXJzLmNoYXJBdChNYXRoLmZsb29yKE1hdGgucmFuZG9tKCkgKiBjaGFyYWN0ZXJzTGVuZ3RoKSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgcmV0dXJuIHJlc3VsdDtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IGFsaVV0aWwgPSAkLnJlcXVpcmUoXFxcImFsaVV0aWxcXFwiKTtcXG4gICAgICAgICAgICBsZXQgQ3J5cHRvSlMgPSBhbGlVdGlsLmdldENyeXB0b0pTKCk7XFxuXFxuICAgICAgICAgICAgZnVuY3Rpb24gZW5fYWVzKGUpIHtcXG4gICAgICAgICAgICAgICAgbGV0IGkgPSBcXFwicXExOTIwNTIwNDYwcXF6elxcXCI7XFxuICAgICAgICAgICAgICAgIC8vIGVuX2Flc1xcbiAgICAgICAgICAgICAgICBsZXQga2V5ID0gQ3J5cHRvSlMuZW5jLlV0ZjgucGFyc2UoaSk7XFxuICAgICAgICAgICAgICAgIHZhciB0ID0gQ3J5cHRvSlMuZW5jLlV0ZjgucGFyc2UoZSksXFxuICAgICAgICAgICAgICAgICAgICByID0gQ3J5cHRvSlMuQUVTLmVuY3J5cHQodCwga2V5LCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgaXY6IGtleSxcXG4gICAgICAgICAgICAgICAgICAgICAgICBtb2RlOiBDcnlwdG9KUy5tb2RlLkNCQyxcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gci5jaXBoZXJ0ZXh0LnRvU3RyaW5nKCk7XFxuICAgICAgICAgICAgfVxcblxcbiAgICAgICAgICAgIGZ1bmN0aW9uIGRlX2Flcyh2dikge1xcbiAgICAgICAgICAgICAgICBsZXQgaSA9IFxcXCJxcTE5MjA1MjA0NjBxcXp6XFxcIjtcXG4gICAgICAgICAgICAgICAgLy8gZGVfYWVzXFxuICAgICAgICAgICAgICAgIGxldCBrZXkgPSBDcnlwdG9KUy5lbmMuVXRmOC5wYXJzZShpKTtcXG4gICAgICAgICAgICAgICAgbGV0IGhleFZhbCA9IENyeXB0b0pTLmVuYy5IZXgucGFyc2UodnYpLFxcbiAgICAgICAgICAgICAgICAgICAgdmFsID0gQ3J5cHRvSlMuZW5jLkJhc2U2NC5zdHJpbmdpZnkoaGV4VmFsKSxcXG4gICAgICAgICAgICAgICAgICAgIGRlY3J5cHRlZCA9IENyeXB0b0pTLkFFUy5kZWNyeXB0KHZhbCwga2V5LCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgaXY6IGtleSxcXG4gICAgICAgICAgICAgICAgICAgICAgICBtb2RlOiBDcnlwdG9KUy5tb2RlLkNCQyxcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gZGVjcnlwdGVkLnRvU3RyaW5nKENyeXB0b0pTLmVuYy5VdGY4KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIHNlYXJjaCgpO1xcbiAgICAgICAgfVxcbiAgICB9LCB7XFxuICAgICAgICBuYW1lOiBcXFwi5LqR55uY6LWE5rqQXFxcIixcXG4gICAgICAgIHBhZ2U6IHRydWUsXFxuICAgICAgICBmaW5kOiBmdW5jdGlvbihzLCBwYWdlKSB7XFxuICAgICAgICAgICAgbGV0IHVybCA9IFxcXCJodHRwczovL3Jlcy55dW5wYW4ud2luLz9QYWdlSW5kZXg9XFxcIiArIHBhZ2UgKyBcXFwiJlBhZ2VTaXplPTEyJktleXdvcmQ9XFxcIiArIHMgKyBcXFwiJlR5cGU9JlRhZz1cXFwiO1xcbiAgICAgICAgICAgIGxldCBodG1sID0gcmVxdWVzdCh1cmwsIHtcXG4gICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgXFxcIlJlZmVyZXJcXFwiOiBcXFwiaHR0cHM6Ly9yZXMueXVucGFuLndpbi9cXFwiXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG5cXG4gICAgICAgICAgICBsZXQgYXJyID0gcGRmYShodG1sLCBcXFwibWFpbiYmLmNhcmRcXFwiKTtcXG4gICAgICAgICAgICAvL2xvZyhhcnIpO1xcbiAgICAgICAgICAgIGxldCBkID0gW107XFxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBhcnIubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ID0gYXJyW2ldO1xcbiAgICAgICAgICAgICAgICBsZXQgdSA9IHBkZmgoaXQsIFxcXCIuY2FyZC1saW5rLDEmJm9uY2xpY2tcXFwiKS5tYXRjaCgvaHR0cHM6XFxcXC9cXFxcLyh3d3dcXFxcLmFsaXl1bmRyaXZlXFxcXC5jb21cXFxcL3N8YWx5d3BcXFxcLm5ldClcXFxcL1xcXFx3Ki9nKSB8fCBbXTtcXG4gICAgICAgICAgICAgICAgdSA9IHUubGVuZ3RoID4gMCA/IHVbMF0gOiB1cmw7XFxuICAgICAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogcGRmaChpdCwgXFxcIi5jYXJkLXRpdGxlJiZUZXh0XFxcIiksXFxuICAgICAgICAgICAgICAgICAgICBwaWNfdXJsOiBwZChpdCwgXFxcImltZyYmc3JjXFxcIiwgdXJsKSxcXG4gICAgICAgICAgICAgICAgICAgIHVybDogdSxcXG4gICAgICAgICAgICAgICAgICAgIGRlc2M6IHBkZmgoaXQsIFxcXCIuY2FyZC10ZXh0LC0xJiZUZXh0XFxcIikgKyBcXFwiXFxcXG5cXFwiICsgdSxcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBkO1xcbiAgICAgICAgfVxcbiAgICB9LFxcbiAgICB7XFxuICAgICAgICBuYW1lOiBcXFwiVVDkupHmkJxcXFwiLFxcbiAgICAgICAgcGFnZTogdHJ1ZSxcXG4gICAgICAgIGZpbmQ6IGZ1bmN0aW9uKHMsIHBhZ2UpIHtcXG4gICAgICAgICAgICBsZXQgdXJsID0gXFxcImh0dHBzOi8vYXBpLnVweXVuc28yLmNvbS9zZWFyY2g/a2V5d29yZD1cXFwiICsgcyArIFxcXCImcGFnZT1cXFwiICsgcGFnZSArIFxcXCImc190eXBlPTFcXFwiO1xcbiAgICAgICAgICAgIGxldCBodG1sID0gcmVxdWVzdCh1cmwsIHtcXG4gICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgXFxcIlJlZmVyZXJcXFwiOiBcXFwiaHR0cHM6Ly93d3cudXB5dW5zby5jb21cXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgXFxcIkNvb2tpZVxcXCI6IFxcXCJjb2RlPTE5MTlcXFwiXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAvL2xvZyhiYXNlNjREZWNvZGUoaHRtbCkpO1xcbiAgICAgICAgICAgIGxldCBhcnIgPSBKU09OLnBhcnNlKGJhc2U2NERlY29kZShodG1sKSkucmVzdWx0Lml0ZW1zO1xcbiAgICAgICAgICAgIC8vbG9nKGFycik7XFxuICAgICAgICAgICAgbGV0IGQgPSBbXTtcXG4gICAgICAgICAgICBpZiAoIWFycikgcmV0dXJuIFtdO1xcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgYXJyLmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgIGxldCBpdCA9IGFycltpXTtcXG4gICAgICAgICAgICAgICAgbGV0IHUgPSBpdC5wYWdlX3VybDtcXG4gICAgICAgICAgICAgICAgLy91ID0gdS5sZW5ndGggPiAwID8gdVswXSA6IHVybDtcXG4gICAgICAgICAgICAgICAgaWYgKCF1LmluY2x1ZGVzKFxcXCJhbGl5dW5kcml2ZVxcXCIpKSB7XFxuICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IGl0LnRpdGxlLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiB1LFxcbiAgICAgICAgICAgICAgICAgICAgZGVzYzogXFxcIlxcXFxuXFxcIiArICh1KSxcXG4gICAgICAgICAgICAgICAgfSk7XFxuXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBkO1xcbiAgICAgICAgfVxcbiAgICB9LFxcbiAgICB7XFxuICAgICAgICBuYW1lOiBcXFwi54yr54u455uY5pCcXFxcIixcXG4gICAgICAgIHBhZ2U6IGZhbHNlLFxcbiAgICAgICAgZmluZDogZnVuY3Rpb24ocywgcGFnZSkge1xcbiAgICAgICAgICAgIGxldCBodG1sID0gcmVxdWVzdChcXFwiaHR0cHM6Ly93d3cuYWxpcGFuc291LmNvbS9zZWFyY2g/az1cXFwiICsgcywge1xcbiAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICBcXFwiUmVmZXJlclxcXCI6IFxcXCJodHRwczovL3d3dy5hbGlwYW5zb3UuY29tL3NlYXJjaD9rPVxcXCIgKyBzXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBsZXQgYXJyID0gcGRmYShodG1sLCBcXFwiI2FwcCYmYVxcXCIpO1xcbiAgICAgICAgICAgIC8vbG9nKGFycik7XFxuICAgICAgICAgICAgbGV0IGQgPSBbXTtcXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGFyci5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgICAgICBsZXQgaXQgPSBcXFwiPGRpdj5cXFwiICsgYXJyW2ldICsgXFxcIjwvZGl2PlxcXCI7XFxuICAgICAgICAgICAgICAgIGxldCB1ID0gcGRmaChpdCwgXFxcImEmJmhyZWZcXFwiKTtcXG4gICAgICAgICAgICAgICAgLy9sb2codSk7XFxuICAgICAgICAgICAgICAgIGlmICghdS5pbmNsdWRlcyhcXFwiL3MvXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIHUgPSBcXFwiaHR0cHM6Ly93d3cuYWxpcGFuc291LmNvbVxcXCIgKyB1LnJlcGxhY2UoXFxcIi9zL1xcXCIsIFxcXCIvY3YvXFxcIik7XFxuICAgICAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogcGRmaChpdCwgXFxcInRlbXBsYXRlJiZUZXh0XFxcIiksXFxuICAgICAgICAgICAgICAgICAgICB1cmw6IHUsXFxuICAgICAgICAgICAgICAgICAgICBkZXNjOiBwZGZoKGl0LCBcXFwidGVtcGxhdGUsMSYmVGV4dFxcXCIpLFxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIGQ7XFxuICAgICAgICB9LFxcbiAgICAgICAgZmluZEFsaVVybChpbnB1dCkge1xcbiAgICAgICAgICAgIGxldCBodG1sID0gcmVxdWVzdChpbnB1dCwge1xcbiAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICBcXFwiQ29va2llXFxcIjogXFxcIm5vX3Nob3dfZG9uYXRlPTFcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgXFxcIlJlZmVyZXJcXFwiOiBpbnB1dC5yZXBsYWNlKFxcXCIvY3YvXFxcIiwgXFxcIi9zL1xcXCIpXFxuICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgIHJlZGlyZWN0OiBmYWxzZVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIGh0bWwgPSBwYXJzZURvbUZvckh0bWwoaHRtbCwgJ2EmJmhyZWYnKTtcXG4gICAgICAgICAgICBpZiAoaHRtbC5sZW5ndGggPiAwKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBodG1sO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBpbnB1dDtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgIH0sXFxuICAgIHtcXG4gICAgICAgIG5hbWU6IFxcXCLmmJPmkJxcXFwiLFxcbiAgICAgICAgcGFnZTogdHJ1ZSxcXG4gICAgICAgIHJlZ2lzdGVyVXJsOiBcXFwiaHR0cHM6Ly95aXNvLmZ1blxcXCIsXFxuICAgICAgICBmaW5kOiBmdW5jdGlvbihzLCBwYWdlKSB7XFxuICAgICAgICAgICAgbG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iBcXFwiaHR0cHM6Ly95aXNvLmZ1bi9pbmZvP3NlYXJjaEtleT1cXFwiICsgcyxcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJDb29raWVcXFwiOiBnZXRJdGVtKCd5aXNvdWNvb2tlJywgJycpXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAvL2xvZyhodG1sKTtcXG4gICAgICAgICAgICBpZiAoaHRtbC5pbmNsdWRlcygn55m75b2V55So5oi35peg6ZmQ5Yi2JykpIHtcXG4gICAgICAgICAgICAgICAgdmFyIGkgPSAwO1xcbiAgICAgICAgICAgICAgICBkbyB7XFxuICAgICAgICAgICAgICAgICAgICB2YXIgdHlpbWdsaW4gPSAnaHR0cHM6Ly95aXNvLmZ1bi9hcGkvdXNlci9sb2dpbi9jYXB0Y2hhP3Q9JyArIHBhcnNlSW50KG5ldyBEYXRlKCkuZ2V0VGltZSgpKSArICcnO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IGltZyA9IGNvbnZlcnRCYXNlNjRJbWFnZSh0eWltZ2xpbikuc3BsaXQoJywnKVsxXTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBjb2QgPSByZXF1ZXN0KCdodHRwczovL2FwaS54aG9mZS50b3Avb2NyL2I2NC90ZXh0Jywge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgJ0NvbnRlbnQtVHlwZSc6ICd0ZXh0L3BsYWluJ1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgICAgICAgICAgYm9keTogaW1nLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIG1ldGhvZDogJ1BPU1QnXFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgIHZhciB2ZXIgPSBKU09OLnBhcnNlKHJlcXVlc3QoJ2h0dHBzOi8veWlzby5mdW4vYXBpL3VzZXIvbG9naW4nLCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAnY29udGVudC10eXBlJzogJ2FwcGxpY2F0aW9uL2pzb24nLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAncmVmZXJlcic6ICdodHRwczovL3lpc28uZnVuL2xvZ2luJyxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgJ0Nvb2tpZSc6IGdldENvb2tpZSh0eWltZ2xpbilcXG4gICAgICAgICAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGJvZHk6IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgXFxcInVzZXJOYW1lXFxcIjogdXNlci5hY2NvdW50LFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBcXFwicGFzc3dvcmRcXFwiOiB1c2VyLnBhc3N3b3JkLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBcXFwiY29kZVxcXCI6IGNvZFxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgICAgICAgICAgbWV0aG9kOiAnUE9TVCdcXG4gICAgICAgICAgICAgICAgICAgIH0pKTtcXG4gICAgICAgICAgICAgICAgICAgIGlmICh2ZXIuY29kZSA9PSAyMDApIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBsb2coJ+aYk+aQnOeZu+WFpemqjOivgeaIkOWKnycpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHNldEl0ZW0oJ3lpc291Y29va2UnLCBnZXRDb29raWUoJ2h0dHBzOi8veWlzby5mdW4nKSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgaHRtbCA9IHJlcXVlc3QoXFxcImh0dHBzOi8veWlzby5mdW4vYXBpL3NlYXJjaD9uYW1lPVxcXCIgKyBzICsgXFxcIiZwYWdlTm89XFxcIiArIHBhZ2UsIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXFxcIlJlZmVyZXJcXFwiOiBcXFwiaHR0cHM6Ly95aXNvLmZ1bi9pbmZvP3NlYXJjaEtleT1cXFwiICsgcyxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFxcXCJDb29raWVcXFwiOiBnZXRJdGVtKCd5aXNvdWNvb2tlJywgJycpXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIGkrKztcXG4gICAgICAgICAgICAgICAgfSB3aGlsZSAoaSA8IDQpO1xcblxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgYXJyID0gSlNPTi5wYXJzZShodG1sKS5kYXRhLmxpc3Q7XFxuICAgICAgICAgICAgLy9sb2coYXJyKTtcXG4gICAgICAgICAgICBsZXQgZCA9IFtdO1xcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgYXJyLmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgIGxldCBpdCA9IGFycltpXTtcXG4gICAgICAgICAgICAgICAgbGV0IHUgPSBrZXllbihpdC51cmwpO1xcbiAgICAgICAgICAgICAgICAvL2xvZyh1KTtcXG4gICAgICAgICAgICAgICAgaWYgKHUgPT0gbnVsbCB8fCAhdS5pbmNsdWRlcyhcXFwiYWxpeXVuXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogaXQubmFtZSxcXG4gICAgICAgICAgICAgICAgICAgIHVybDogdSxcXG4gICAgICAgICAgICAgICAgICAgIGRlc2M6IChpdC5nbXRTaGFyZSB8fCBpdC5nbXRDcmVhdGUpICsgXFxcIlxcXFxuXFxcIiArICh1KSxcXG4gICAgICAgICAgICAgICAgfSk7XFxuXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBkO1xcbiAgICAgICAgfVxcbiAgICB9LFxcbiAgICB7XFxuICAgICAgICBuYW1lOiBcXFwi5bCP57q45p2hXFxcIixcXG4gICAgICAgIHBhZ2U6IGZhbHNlLFxcbiAgICAgICAgZmluZDogZnVuY3Rpb24ocywgcGFnZSkge1xcbiAgICAgICAgICAgIGxldCBhbGlVdGlsID0gJC5yZXF1aXJlKFxcXCJhbGlVdGlsXFxcIik7XFxuXFxuICAgICAgICAgICAgZnVuY3Rpb24gZ2V0dG9rZW4oKSB7XFxuICAgICAgICAgICAgICAgIGlmIChnZXRNeVZhcigneHp5dG9rZW4nLCAnJykubGVuZ3RoID09IDApIHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCB0b2tlbiA9IEpTT04ucGFyc2UocG9zdCgnaHR0cHM6Ly9naXRjYWZlLm5ldC90b29sL2FsaXBhcGVyLycsIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICdSZWZlcmVyJzogJ2h0dHBzOi8vdS5naXRjYWZlLmluay8nXFxuICAgICAgICAgICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgICAgICAgICBib2R5OiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFjdGlvbjogJ2dldF90b2tlbidcXG4gICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICB9KSkuZGF0YTtcXG4gICAgICAgICAgICAgICAgICAgIHB1dE15VmFyKCd4enR0b2tlbicsIHRva2VuKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICByZXR1cm4gZ2V0TXlWYXIoJ3h6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iB7XFxuICAgICAgICAgICAgICAgICAgICBhY3Rpb246IFxcXCJzZWFyY2hcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgZnJvbTogXFxcIndlYlxcXCIsXFxuICAgICAgICAgICAgICAgICAgICB0b2tlbjogZ2V0dG9rZW4oKSxcXG4gICAgICAgICAgICAgICAgICAgIGtleXdvcmQ6IHNcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgbGV0IGxpc3QgPSBKU09OLnBhcnNlKGh0bWwpO1xcbiAgICAgICAgICAgIGlmIChsaXN0LmRhdGEpIHtcXG4gICAgICAgICAgICAgICAgbGlzdCA9IGxpc3QuZGF0YTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBsaXN0Lmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgIGxldCBpdCA9IGxpc3RbaV1cXG4gICAgICAgICAgICAgICAgbGV0IHRpdGxlID0gaXQudGl0bGU7XFxuICAgICAgICAgICAgICAgIGxldCBtdXJsID0gJ2h0dHBzOi8vd3d3LmFsaXl1bmRyaXZlLmNvbS9zLycgKyBpdC5hbGlrZXlcXG4gICAgICAgICAgICAgICAgaWYgKCFhbGlVdGlsLmNoZWNrYWxpKG11cmwpKSB7XFxuICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBpZiAodGl0bGUuaW5jbHVkZXMocykpIHtcXG4gICAgICAgICAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLiiJogXFxcIiArIHRpdGxlLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGRlc2M6IGNhdF9jb2RlKGl0LmNhdCksXFxuICAgICAgICAgICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzOiBpdC5kZXNcXG4gICAgICAgICAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHVybDogbXVybFxcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIGQ7XFxuICAgICAgICB9XFxuICAgIH0sXFxuICAgIHtcXG4gICAgICAgIG5hbWU6IFxcXCLnjqnlgbblk6Xlk6VcXFwiLFxcbiAgICAgICAgcGFnZTogdHJ1ZSxcXG4gICAgICAgIGJhc2ljVXJsOiBcXFwiaHR0cDovL3dvZ2cueHl6XFxcIixcXG4gICAgICAgIGZpbmQ6IGZ1bmN0aW9uKHMsIHBhZ2UpIHtcXG4gICAgICAgICAgICBsZXQgdXJsID0gYmFzaWNVcmwgKyBcXFwiL2luZGV4LnBocC92b2RzZWFyY2gvXFxcIiArIHMgKyBcXFwiLS0tLS0tLS0tLVxcXCIgKyBwYWdlICsgXFxcIi0tLS5odG1sXFxcIjtcXG4gICAgICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QodXJsKTtcXG4gICAgICAgICAgICBsZXQgYXJyID0gcGFyc2VEb21Gb3JBcnJheShodG1sLCBcXFwiLm1vZHVsZS1pdGVtcyYmLm1vZHVsZS1zZWFyY2gtaXRlbVxcXCIpO1xcblxcbiAgICAgICAgICAgIGxldCBiZXQgPSBbXTtcXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGFyci5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgICAgICBsZXQgaXQgPSBhcnJbaV07XFxuICAgICAgICAgICAgICAgIGxldCB1dGl0bGUgPSBwZGZoKGl0LCBcXFwiaDMmJmEmJlRleHRcXFwiKTtcXG4gICAgICAgICAgICAgICAgbGV0IHVzZXJpYWwgPSBwZGZoKGl0LCBcXFwiLnZpZGVvLXNlcmlhbCYmVGV4dFxcXCIpO1xcbiAgICAgICAgICAgICAgICBsZXQgdWltYWdlID0gcGRmaChpdCwgXFxcImltZyYmZGF0YS1zcmNcXFwiKTtcXG4gICAgICAgICAgICAgICAgbGV0IHUgPSBwZChpdCwgXFxcImgzJiZhJiZocmVmXFxcIiwgYmFzaWNVcmwpO1xcbiAgICAgICAgICAgICAgICBiZXQucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogdXRpdGxlLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiB1LFxcbiAgICAgICAgICAgICAgICAgICAgcGljX3VybDogdWltYWdlLFxcbiAgICAgICAgICAgICAgICAgICAgZGVzYzogdXNlcmlhbFxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9XFxuXFxuICAgICAgICAgICAgcmV0dXJuIGJldDtcXG4gICAgICAgIH0sXFxuICAgICAgICBmaW5kQWxpVXJsKGlucHV0KSB7XFxuICAgICAgICAgICAgcmV0dXJuIHBkZmEocmVxdWVzdChpbnB1dCksIFxcXCJib2R5JiYubW9kdWxlLXJvdy10ZXh0LmNvcHlcXFwiKS5tYXAodiA9PiBwZGZoKHYsIFxcXCJhJiZkYXRhLWNsaXBib2FyZC10ZXh0XFxcIikpO1xcbiAgICAgICAgfVxcbiAgICB9LFxcbiAgICB7XFxuICAgICAgICBuYW1lOiBcXFwi6Zi/6YeM5LqR55uY572RXFxcIixcXG4gICAgICAgIHBhZ2U6IHRydWUsXFxuICAgICAgICBiYXNpY1VybDogXFxcImh0dHBzOi8vd3d3LmFseXB3LmNuXFxcIixcXG4gICAgICAgIGZpbmQ6IGZ1bmN0aW9uKHMsIHBhZ2UpIHtcXG4gICAgICAgICAgICBsZXQgdXJsID0gYmFzaWNVcmwgKyBcXFwiL3NlYXJjaC5waHA/cT1cXFwiICsgcyArIFxcXCImcGFnZT1cXFwiICsgcGFnZTtcXG4gICAgICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QodXJsLCB7fSk7XFxuICAgICAgICAgICAgbGV0IGFyciA9IHBkZmEoaHRtbCwgXFxcIi5saXN0JiZsaVxcXCIpO1xcbiAgICAgICAgICAgIGxldCBiZXQgPSBbXTtcXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGFyci5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgICAgICBsZXQgaXQgPSBhcnJbaV07XFxuICAgICAgICAgICAgICAgIGxldCB1dGl0bGUgPSBwZGZoKGl0LCBcXFwiYSYmdGl0bGVcXFwiKTtcXG4gICAgICAgICAgICAgICAgbGV0IHVzZXJpYWwgPSBwZGZoKGl0LCBcXFwiLmZhLWNsb2NrLW8mJlRleHRcXFwiKTtcXG4gICAgICAgICAgICAgICAgbGV0IHVpbWFnZSA9IHBkZmgoaXQsIFxcXCJpbWcmJnNyY1xcXCIpO1xcbiAgICAgICAgICAgICAgICBsZXQgdSA9IHBkKGl0LCBcXFwiYSYmaHJlZlxcXCIsIGJhc2ljVXJsKTtcXG4gICAgICAgICAgICAgICAgaWYgKCF1dGl0bGUuaW5jbHVkZXMocykpIHtcXG4gICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGJldC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiB1dGl0bGUsXFxuICAgICAgICAgICAgICAgICAgICB1cmw6IHUsXFxuICAgICAgICAgICAgICAgICAgICBwaWNfdXJsOiB1aW1hZ2UsXFxuICAgICAgICAgICAgICAgICAgICBkZXNjOiB1c2VyaWFsXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgICByZXR1cm4gYmV0O1xcbiAgICAgICAgfSxcXG4gICAgICAgIGZpbmRBbGlVcmwoaW5wdXQpIHtcXG4gICAgICAgICAgICByZXR1cm4gcGRmYShyZXF1ZXN0KGlucHV0KSwgXFxcImJvZHkmJmFbaHJlZl49aHR0cHM6Ly93d3cuYWxpeXVuZHJpdmUuY29tL3MvXVxcXCIpLm1hcCh2ID0+IHBkZmgodiwgXFxcImEmJmhyZWZcXFwiKSk7XFxuICAgICAgICB9XFxuICAgIH0sXFxuICAgIHtcXG4gICAgICAgIG5hbWU6IFxcXCLlnJ/mi6jpvKBcXFwiLFxcbiAgICAgICAgcGFnZTogZmFsc2UsXFxuICAgICAgICBmaW5kOiBmdW5jdGlvbihzLCBwYWdlKSB7XFxuICAgICAgICAgICAgbGV0IGh0bWwgPSBmZXRjaCgnaHR0cHM6Ly93d3cudGJzZHkuY29tL3NlYXJjaC5odG1sP2tleXdvcmQ9JyArIHMgKyAnJmNhdGVnb3J5PTk4MzkyMCZkYXRhX3R5cGU9OTg3OTEwJywge1xcbiAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICAnVXNlci1BZ2VudCc6IFBDX1VBXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG5cXG4gICAgICAgICAgICBsZXQgYXJyID0gcGFyc2VEb21Gb3JBcnJheShodG1sLCAnLnNlYXJjaF9yZXN1bHRfbmV0ZGlza19saXN0JiZhJyk7XFxuICAgICAgICAgICAgbGV0IGQgPSBbXTtcXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGFyci5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgICAgICBsZXQgaXQgPSBhcnJbaV07XFxuICAgICAgICAgICAgICAgIC8vbG9nKGl0KTtcXG4gICAgICAgICAgICAgICAgbGV0IHUgPSBwYXJzZURvbUZvckh0bWwoaXQsICdhJiZocmVmJyk7XFxuICAgICAgICAgICAgICAgIGxldCB0aXQgPSBwYXJzZURvbUZvckh0bWwoaXQsICcubmV0ZGlza19pdGVtX2RldGFpbF9uYW1lJiZUZXh0Jyk7XFxuICAgICAgICAgICAgICAgIGlmICghdGl0LmluY2x1ZGVzKHMpKSB7XFxuICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAvL2xvZyh1KTtcXG4gICAgICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiB0aXQsXFxuICAgICAgICAgICAgICAgICAgICB1cmw6IHUsXFxuICAgICAgICAgICAgICAgICAgICBkZXNjOiBcXFwiXFxcXG5cXFwiICsgdSxcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBkO1xcbiAgICAgICAgfVxcbiAgICB9LFxcbiAgICB7XFxuICAgICAgICBuYW1lOiBcXFwi6Zi/6YeM5pCcXFxcIixcXG4gICAgICAgIHBhZ2U6IHRydWUsXFxuICAgICAgICBmaW5kOiBmdW5jdGlvbihzLCBwYWdlKSB7XFxuICAgICAgICAgICAgbGV0IGQgPSBbXTtcXG4gICAgICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QoJ2h0dHBzOi8vYWxpc28uY2Mvcy8nICsgcyArICctJyArIHBhZ2UgKyAnLTAuaHRtbCcsIHt9KTtcXG5cXG4gICAgICAgICAgICBsZXQgbGlzdCA9IHBhcnNlRG9tRm9yQXJyYXkoaHRtbCwgJy5zZWFyY2gtcmVzdWx0JiYucmVzb3VyY2UtaXRlbScpO1xcbiAgICAgICAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgbGlzdC5sZW5ndGg7IGorKykge1xcbiAgICAgICAgICAgICAgICBsZXQgdSA9IGxpc3Rbal07XFxuICAgICAgICAgICAgICAgIGxldCB0aXQgPSBwYXJzZURvbUZvckh0bWwodSwgJ2gzJiZUZXh0Jyk7XFxuICAgICAgICAgICAgICAgIGlmICghdGl0LmluY2x1ZGVzKHMpKSB7XFxuICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IHRpdCxcXG4gICAgICAgICAgICAgICAgICAgIHVybDogcGFyc2VEb20odSwgJ2gzJiZhJiZocmVmJywgJ2h0dHBzOi8vYWxpc28uY2MvJyksXFxuICAgICAgICAgICAgICAgICAgICBkZXNjOiBwYXJzZURvbUZvckh0bWwodSwgJy50aW1lJiZUZXh0JyksXFxuICAgICAgICAgICAgICAgIH0pO1xcblxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gZDtcXG4gICAgICAgIH0sXFxuICAgICAgICBmaW5kQWxpVXJsKGlucHV0KSB7XFxuICAgICAgICAgICAgZXZhbChnZXRDcnlwdG9KUygpKTtcXG5cXG4gICAgICAgICAgICBmdW5jdGlvbiBkZWNyeShzdHIpIHtcXG4gICAgICAgICAgICAgICAgdmFyIGtleSA9IENyeXB0b0pTLmVuYy5VdGY4LnBhcnNlKFxcXCI5RUIyMERERkQ2QUZCRDY4XFxcIik7XFxuICAgICAgICAgICAgICAgIHZhciBlbmNyeXB0ZWQgPSBDcnlwdG9KUy5BRVMuZGVjcnlwdChzdHIsIGtleSwge1xcbiAgICAgICAgICAgICAgICAgICAgaXY6IGtleSxcXG4gICAgICAgICAgICAgICAgICAgIG1vZGU6IENyeXB0b0pTLm1vZGUuQ0JDLFxcbiAgICAgICAgICAgICAgICAgICAgcGFkZGluZzogQ3J5cHRvSlMucGFkLlBrY3M3XFxuICAgICAgICAgICAgICAgIH0pLnRvU3RyaW5nKENyeXB0b0pTLmVuYy5VdGY4KTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIGVuY3J5cHRlZDtcXG4gICAgICAgICAgICB9XFxuXFxuICAgICAgICAgICAgbGV0IGh0bWwgPSByZXF1ZXN0KGlucHV0KTtcXG4gICAgICAgICAgICBsZXQgYnV0ID0gcGFyc2VEb20oaHRtbCwgJy5idXR0b24mJmhyZWYnLCAnaHR0cHM6Ly9hbGlzby5jYy8nKTtcXG4gICAgICAgICAgICAvL2xvZyhidXQpO1xcbiAgICAgICAgICAgIGxldCBnb3QgPSByZXF1ZXN0KGJ1dCk7XFxuICAgICAgICAgICAgLy9sb2coZ290KTtcXG4gICAgICAgICAgICBldmFsKHBhcnNlRG9tRm9ySHRtbChnb3QsICdoZWFkJiZzY3JpcHQsMSYmSHRtbCcpKTtcXG4gICAgICAgICAgICByZXR1cm4gZGVjcnkoYmFzZTY0LnNwbGl0KCchJylbMF0pO1xcbiAgICAgICAgfVxcbiAgICB9LFxcbiAgICB7XFxuICAgICAgICBuYW1lOiBcXFwi5LqR55uY5YiG5Lqr56S+XFxcIixcXG4gICAgICAgIHBhZ2U6IGZhbHNlLFxcbiAgICAgICAgZmluZDogZnVuY3Rpb24ocywgcGFnZSkge1xcbiAgICAgICAgICAgIGxldCBhbGlVdGlsID0gJC5yZXF1aXJlKFxcXCJhbGlVdGlsXFxcIik7XFxuICAgICAgICAgICAgbGV0IENyeXB0b0pTID0gYWxpVXRpbC5nZXRDcnlwdG9KUygpO1xcblxcbiAgICAgICAgICAgIGZ1bmN0aW9uIGRlY3J5KHN0cikge1xcbiAgICAgICAgICAgICAgICB2YXIga2V5ID0gQ3J5cHRvSlMuZW5jLlV0ZjgucGFyc2UoXFxcIjVGNkIyQUszM0RBU0QxMjNcXFwiKTtcXG4gICAgICAgICAgICAgICAgdmFyIGVuY3J5cHRlZCA9IENyeXB0b0pTLkFFUy5kZWNyeXB0KHN0ciwga2V5LCB7XFxuICAgICAgICAgICAgICAgICAgICBtb2RlOiBDcnlwdG9KUy5tb2RlLkVDQixcXG4gICAgICAgICAgICAgICAgICAgIHBhZGRpbmc6IENyeXB0b0pTLnBhZC5Qa2NzN1xcbiAgICAgICAgICAgICAgICB9KS50b1N0cmluZyhDcnlwdG9KUy5lbmMuVXRmOCk7XFxuICAgICAgICAgICAgICAgIHJldHVybiBlbmNyeXB0ZWQ7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCBodG1sID0gcmVxdWVzdChcXFwiaHR0cHM6Ly93d3cueXVucGFuZmVueGlhbmcuY24vYXBpL2Jicy9hcGkvZ2V0ZGF0YT9rZXk9XFxcIiArIHMgKyBcXFwiJnR5cGU9dmlkZW9cXFwiLCB7XFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJSZWZlcmVyXFxcIjogXFxcImh0dHBzOi8vd3d3Lnl1bnBhbmZlbnhpYW5nLmNuL1xcXCJcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIGxldCBqc29uID0gZGVjcnkoSlNPTi5wYXJzZShodG1sKS5kYXRhKTtcXG4gICAgICAgICAgICBsZXQgYXJyID0gSlNPTi5wYXJzZShqc29uKTtcXG5cXG4gICAgICAgICAgICBsZXQgYmV0ID0gW107XFxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBhcnIubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ID0gYXJyW2ldO1xcbiAgICAgICAgICAgICAgICBsZXQgdXJsID0gaXQucGlkO1xcbiAgICAgICAgICAgICAgICBiZXQucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICB1cmw6IFxcXCJodHRwczovL3d3dy55dW5wYW5mZW54aWFuZy5jbi9hcGkvYmJzL2FwaS9nZXRhcnRpY2xlP2lkPVxcXCIgKyB1cmwsXFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogaXQudGl0bGUsXFxuICAgICAgICAgICAgICAgICAgICBkZXNjOiBpdC5jcmVhdGV0aW1lXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgICByZXR1cm4gYmV0O1xcbiAgICAgICAgfSxcXG4gICAgICAgIGZpbmRBbGlVcmwoaW5wdXQpIHtcXG4gICAgICAgICAgICBsZXQganNvbiA9IEpTT04ucGFyc2UocmVxdWVzdChpbnB1dCwge1xcbiAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICA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iAgICAgICAgICAgIC8vbG9nKGFycik7XFxuICAgICAgICAgICAgbGV0IGQgPSBbXTtcXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGFyci5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgICAgICBsZXQgaXQgPSBhcnJbaV07XFxuICAgICAgICAgICAgICAgIGxldCB1ID0gcGFyc2VEb21Gb3JIdG1sKGl0LCAnYVtocmVmXj1odHRwczovL3d3dy5hbGl5dW5kcml2ZS5jb20vcy9dJiZocmVmJyk7XFxuICAgICAgICAgICAgICAgIGxldCBwaWNfdXJsID0gcGFyc2VEb21Gb3JIdG1sKGl0LCAnaW1nJiZzcmMnKTtcXG4gICAgICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBwYXJzZURvbUZvckh0bWwoaXQsICcuYnJlYWstYWxsJiZUZXh0Jykuc3BsaXQoJ2h0dHAnKVswXSxcXG4gICAgICAgICAgICAgICAgICAgIHBpY191cmw6IHBpY191cmwgPT09IFxcXCIvZmF2aWNvbi5wbmdcXFwiID8gXFxcImh0dHBzOi8vd3d3LnBhbnNlYXJjaC5tZS9cXFwiICsgcGljX3VybCA6IHBpY191cmwsXFxuICAgICAgICAgICAgICAgICAgICB1cmw6IHUsXFxuICAgICAgICAgICAgICAgICAgICBkZXNjOiBwYXJzZURvbUZvckh0bWwoaXQsICdwJiZUZXh0JykgKyBcXFwiXFxcXG5cXFwiICsgdSxcXG4gICAgICAgICAgICAgICAgfSk7XFxuXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBkO1xcbiAgICAgICAgfVxcbiAgICB9LFxcbiAgICB7XFxuICAgICAgICBuYW1lOiBcXFwiRE9WWOaQnFxcXCIsXFxuICAgICAgICBwYWdlOiBmYWxzZSxcXG4gICAgICAgIGZpbmQ6IGZ1bmN0aW9uKHMsIHBhZ2UpIHtcXG4gICAgICAgICAgICBsZXQgdXJsID0gXFxcImh0dHBzOi8vYXBpLmRvdngudGsvYWxpL3NlYXJjaD93ZD1cXFwiICsgcztcXG4gICAgICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QodXJsKTtcXG4gICAgICAgICAgICBsZXQgYXJyID0gSlNPTi5wYXJzZShodG1sKS5saXN0O1xcbiAgICAgICAgICAgIGxldCBkID0gW107XFxuICAgICAgICAgICAgbGV0IGFsaVV0aWwgPSAkLnJlcXVpcmUoXFxcImFsaVV0aWxcXFwiKTtcXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGFyci5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgICAgICBsZXQgaXQgPSBhcnJbaV07XFxuICAgICAgICAgICAgICAgIGxldCB1ID0gaXQudm9kX2NvbnRlbnQ7XFxuICAgICAgICAgICAgICAgIGlmICghdS5pbmNsdWRlcyhcXFwiYWxpeXVuZHJpdmVcXFwiKSB8fCAhYWxpVXRpbC5jaGVja2FsaSh1KSkge1xcbiAgICAgICAgICAgICAgICAgICAgY29udGludWU7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi4oiaIFxcXCIgKyBpdC52b2RfbmFtZSxcXG4gICAgICAgICAgICAgICAgICAgIHBpY191cmw6IGl0LnZvZF9waWMsXFxuICAgICAgICAgICAgICAgICAgICB1cmw6IHUsXFxuICAgICAgICAgICAgICAgICAgICBkZXNjOiBcXFwiXFxcXG5cXFwiICsgdSxcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBkO1xcbiAgICAgICAgfVxcbiAgICB9LFxcbiAgICB7XFxuICAgICAgICBuYW1lOiBcXFwi5b+F5bqUXFxcIixcXG4gICAgICAgIHBhZ2U6IHRydWUsXFxuICAgICAgICBmaW5kOiBmdW5jdGlvbihzLCBwYWdlKSB7XFxuICAgICAgICAgICAgbGV0IHVybCA9IFxcXCJodHRwczovL2NuLmJpbmcuY29tL3NlYXJjaD9xPVxcXCIgKyBzICsgXFxcIithbGl5dW5kcml2ZSZxcz1kcyZmb3JtPVFCUkVcXFwiO1xcbiAgICAgICAgICAgIGlmIChwYWdlICE9IDEpIHtcXG4gICAgICAgICAgICAgICAgdXJsID0gZ2V0TXlWYXIoXFxcImJpbmdcXFwiLCB1cmwpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QodXJsLCB7XFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJSZWZlcmVyXFxcIjogXFxcImh0dHBzOi8vY24uYmluZy5jb20vXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIC8vXFxcIlgtUmVxdWVzdGVkLVdpdGhcXFwiOiBcXFwiY29tLmV4YW1wbGUuaGlrZXJ2aWV3XFxcIixcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJBY2NlcHRcXFwiOiBcXFwidGV4dC9odG1sLGFwcGxpY2F0aW9uL3hodG1sK3htbCxhcHBsaWNhdGlvbi94bWw7cT0wLjksaW1hZ2UvYXZpZixpbWFnZS93ZWJwLGltYWdlL2FwbmcsKi8qO3E9MC44LGFwcGxpY2F0aW9uL3NpZ25lZC1leGNoYW5nZTt2PWIzO3E9MC45XFxcIlxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgbGV0IGFyciA9IHBkZmEoaHRtbCwgXFxcImJvZHkmJmFcXFwiKTtcXG4gICAgICAgICAgICAvL2xvZyhhcnIpO1xcbiAgICAgICAgICAgIGxldCBkID0gW107XFxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBhcnIubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ID0gYXJyW2ldO1xcbiAgICAgICAgICAgICAgICBsZXQgdSA9IHBkKGl0LCBcXFwiYSYmaHJlZlxcXCIsIHVybCk7XFxuICAgICAgICAgICAgICAgIGxldCB0ID0gcGRmaChpdCwgXFxcImEmJlRleHRcXFwiKTtcXG4gICAgICAgICAgICAgICAgaWYgKGl0LmluY2x1ZGVzKFxcXCJOZXh0IHBhZ2VcXFwiKSB8fCBpdC5pbmNsdWRlcyhcXFwi5LiL5LiA6aG1XFxcIikpIHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCB1MiA9IHBkKGl0LCBcXFwiYSYmaHJlZlxcXCIsIHVybCk7XFxuICAgICAgICAgICAgICAgICAgICAvL2xvZyhcXFwibmV4dCBwYWdlXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAvL2xvZyh1Mik7XFxuICAgICAgICAgICAgICAgICAgICBwdXRNeVZhcihcXFwiYmluZ1xcXCIsIHUyKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBpZiAodSA9PSBudWxsIHx8IHQgPT0gbnVsbCB8fCAhaXQuaW5jbHVkZXMocykpIHtcXG4gICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGlmICghaXQuaW5jbHVkZXMoXFxcIue9keebmFxcXCIpICYmICFpdC5pbmNsdWRlcyhcXFwi5LqR55uYXFxcIikgJiZcXG4gICAgICAgICAgICAgICAgICAgICFpdC5pbmNsdWRlcyhcXFwiYWxpeXVuZHJpdmVcXFwiKSAmJiAhaXQuaW5jbHVkZXMoXFxcInl1bnBhblxcXCIpKSB7XFxuICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBpZiAodS5zdGFydHNXaXRoKFxcXCJodHRwczovL2NuLmJpbmcuY29tL1xcXCIpKSB7XFxuICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBsZXQgZG9tID0gZ2V0SG9tZSh1KS5yZXBsYWNlKFxcXCJodHRwOi8vXFxcIiwgXFxcIlxcXCIpLnJlcGxhY2UoXFxcImh0dHBzOi8vXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgICAgICBsZXQgX2xpbmtzID0gdC5tYXRjaCgvaHR0cHM6XFxcXC9cXFxcLyh3d3dcXFxcLmFsaXl1bmRyaXZlXFxcXC5jb21cXFxcL3N8YWx5d3BcXFxcLm5ldClcXFxcL1xcXFx3Ki9nKSB8fCBbXTtcXG4gICAgICAgICAgICAgICAgbGV0IGMgPSBudWxsO1xcbiAgICAgICAgICAgICAgICBpZiAoX2xpbmtzLmxlbmd0aCA+IDEgJiYgX2xpbmtzWzFdLnJlcGxhY2UoX2xpbmtzWzBdLCBcXFwiXFxcIikucmVwbGFjZSgvW2EtekEtWjAtOV0rL2csIFxcXCJcXFwiKSA9PSBcXFwiXFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgYyA9IF9saW5rc1sxXTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChfbGlua3MubGVuZ3RoID4gMCkge1xcbiAgICAgICAgICAgICAgICAgICAgYyA9IF9saW5rc1swXTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IHQsXFxuICAgICAgICAgICAgICAgICAgICBkZXNjOiBkb20sXFxuICAgICAgICAgICAgICAgICAgICB1cmw6IGMgIT0gbnVsbCA/IGMgOiB1LFxcbiAgICAgICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBsb25nQ2xpY2s6IFt7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi6L+b5YWl572R56uZXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAganM6IEpTT04uc3RyaW5naWZ5KFxcXCJoaWtlcjovL3BhZ2UveXNmeD93ZWJVcmw9XFxcIiArIGVuY29kZVVSSUNvbXBvbmVudCh1KSlcXG4gICAgICAgICAgICAgICAgICAgICAgICB9XVxcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIGQ7XFxuICAgICAgICB9LFxcbiAgICAgICAgZmluZEFsaVVybChpbnB1dCkge1xcbiAgICAgICAgICAgIGlmIChpbnB1dC5pbmNsdWRlcyhcXFwiYWxpeXVuZHJpdmVcXFwiKSkgcmV0dXJuIGlucHV0O1xcbiAgICAgICAgICAgIGxldCBodG1sID0gcmVxdWVzdChpbnB1dCk7XFxuICAgICAgICAgICAgdmFyIF9saW5rcyA9IGh0bWwubWF0Y2goL2h0dHBzOlxcXFwvXFxcXC8od3d3XFxcXC5hbGl5dW5kcml2ZVxcXFwuY29tXFxcXC9zfGFseXdwXFxcXC5uZXQpXFxcXC9cXFxcdyovZykgfHwgW107XFxuICAgICAgICAgICAgaWYgKF9saW5rcy5sZW5ndGggPiAxICYmIF9saW5rc1sxXS5yZXBsYWNlKF9saW5rc1swXSwgXFxcIlxcXCIpLnJlcGxhY2UoL1thLXpBLVowLTldKy9nLCBcXFwiXFxcIikgPT0gXFxcIlxcXCIpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIF9saW5rc1sxXTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKF9saW5rcy5sZW5ndGggPiAwKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBfbGlua3NbMF07XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3BhZ2UveXNmeD93ZWJVcmw9XFxcIiArIGVuY29kZVVSSUNvbXBvbmVudChpbnB1dCk7XFxuICAgICAgICAgICAgfVxcblxcbiAgICAgICAgfVxcbiAgICB9LFxcbiAgICB7XFxuICAgICAgICBuYW1lOiAnQ0NPRicsXFxuICAgICAgICBwYWdlOiB0cnVlLFxcbiAgICAgICAgZmluZDogZnVuY3Rpb24ocywgcGFnZSkge1xcbiAgICAgICAgICAgIGxldCBkID0gW11cXG4gICAgICAgICAgICBsZXQgYWxpVXRpbCA9ICQucmVxdWlyZShcXFwiYWxpVXRpbFxcXCIpO1xcbiAgICAgICAgICAgIGxldCBodG1sID0gZmV0Y2goJ2h0dHBzOi8vcGFuLmNjb2YuY2MvYXBpL3NlYXJjaCcsIHtcXG4gICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgXFxcImNvbnRlbnQtdHlwZVxcXCI6ICdhcHBsaWNhdGlvbi9qc29uJyxcXG4gICAgICAgICAgICAgICAgICAgICdSZWZlcmVyJzogJ2h0dHBzOi8vcGFuLmNjb2YuY2Mvc2VhcmNoP2tleXdvcmQ9JyArIHNcXG4gICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgYm9keToge1xcbiAgICAgICAgICAgICAgICAgICAgXFxcInBhZ2VTaXplXFxcIjogMjAsXFxuICAgICAgICAgICAgICAgICAgICBcXFwicGFnZU51bVxcXCI6IHBhZ2UsXFxuICAgICAgICAgICAgICAgICAgICBcXFwia2V5d29yZFxcXCI6IHMsXFxuICAgICAgICAgICAgICAgICAgICBcXFwiZnJvbU1vYmlsZVxcXCI6IHRydWVcXG4gICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgbWV0aG9kOiAnUE9TVCdcXG4gICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIGxldCBsaXN0ID0gSlNPTi5wYXJzZShodG1sKVxcbiAgICAgICAgICAgICAgICAuZGF0YS5yb3dzXFxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBsaXN0Lmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgIGxldCBpdCA9IGxpc3RbaV07XFxuICAgICAgICAgICAgICAgIGxldCB0aXRsZSA9IGl0LmZpbGVOYW1lXFxuICAgICAgICAgICAgICAgIGxldCBtdXJsID0gaXQudXJsXFxuICAgICAgICAgICAgICAgIGxldCB0eXBlID0gaXQudHlwZS5yZXBsYWNlKC9mb2xkZXIvLCAn5paH5Lu25aS5JykucmVwbGFjZSgvZmlsZS8sICfmlofku7YnKVxcbiAgICAgICAgICAgICAgICBpZiAodGl0bGUuaW5jbHVkZXMocykpIHtcXG4gICAgICAgICAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IHRpdGxlLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGRlc2M6ICfmlofku7bnsbvlnovvvJonICsgdHlwZSArICfvvIzmlofku7blpKflsI/vvJonICsgYWxpVXRpbC5ieXRlc1RvU2l6ZShpdC5zaXplKSxcXG4gICAgICAgICAgICAgICAgICAgICAgICB1cmw6IG11cmxcXG4gICAgICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIGRcXG4gICAgICAgIH1cXG4gICAgfSxcXG4gICAge1xcbiAgICAgICAgbmFtZTogJ+mYv+mHjOWwj+ermScsXFxuICAgICAgICBwYWdlOiB0cnVlLFxcbiAgICAgICAgZmluZDogZnVuY3Rpb24ocywgcGFnZSkge1xcbiAgICAgICAgICAgIGxldCBob21lID0gXFxcImh0dHBzOi8vcGFuNjY2Lm5ldFxcXCI7XFxuICAgICAgICAgICAgbGV0IGQgPSBbXTtcXG4gICAgICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QoYnVpbGRVcmwoaG9tZSArIFxcXCIvYXBpL2Rpc2N1c3Npb25zXFxcIiwge1xcbiAgICAgICAgICAgICAgICBcXFwiaW5jbHVkZVxcXCI6IFxcXCJ1c2VyLGxhc3RQb3N0ZWRVc2VyLG1vc3RSZWxldmFudFBvc3QsbW9zdFJlbGV2YW50UG9zdC51c2VyLHRhZ3MsdGFncy5wYXJlbnQsZmlyc3RQb3N0XFxcIixcXG4gICAgICAgICAgICAgICAgXFxcImZpbHRlcltxXVxcXCI6IHMgLyogKyBcXFwiIHRhZzp2aWRlbyxjb21pY1xcXCIqLyAsXFxuICAgICAgICAgICAgICAgIC8vXFxcImZpbHRlclt0YWddXFxcIjogXFxcInZpZGVvLGNvbWljXFxcIixcXG4gICAgICAgICAgICAgICAgXFxcInBhZ2Vbb2Zmc2V0XVxcXCI6IDIwICogKHBhZ2UgLSAxKVxcbiAgICAgICAgICAgIH0pLCB7XFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJjb250ZW50LXR5cGVcXFwiOiBcXFwiYXBwbGljYXRpb24vanNvblxcXCIsXFxuICAgICAgICAgICAgICAgICAgICBcXFwiUmVmZXJlclxcXCI6IFxcXCJodHRwczovL3BhbjY2Ni5uZXQvP3E9XFxcIiArIHNcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIGxldCBsaXN0ID0gSlNPTi5wYXJzZShodG1sKS5kYXRhO1xcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbGlzdC5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgICAgICBsZXQgaXRlbSA9IGxpc3RbaV0uYXR0cmlidXRlcztcXG4gICAgICAgICAgICAgICAgbGV0IHVybCA9IGhvbWUgKyBcXFwiL2QvXFxcIiArIGl0ZW0uc2x1ZztcXG4gICAgICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBpdGVtLnRpdGxlLFxcbiAgICAgICAgICAgICAgICAgICAgZGVzYzogJ+WPkeW4g+aXtumXtO+8micgKyAkLmRhdGVGb3JtYXQobmV3IERhdGUoaXRlbS5jcmVhdGVkQXQpLCBcXFwieXl5eS1NTS1kZCBISDptbTpzc1xcXCIpLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiB1cmwsXFxuICAgICAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxvbmdDbGljazogW3tcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLov5vlhaXluJblrZBcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBqczogSlNPTi5zdHJpbmdpZnkoXFxcImhpa2VyOi8vcGFnZS95c2Z4P3dlYlVybD1cXFwiICsgZW5jb2RlVVJJQ29tcG9uZW50KHVybCkpXFxuICAgICAgICAgICAgICAgICAgICAgICAgfV1cXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBkO1xcbiAgICAgICAgfSxcXG4gICAgICAgIGZpbmRBbGlVcmwoaW5wdXQpIHtcXG4gICAgICAgICAgICBsZXQgaHRtbCA9IHBkZmgocmVxdWVzdChpbnB1dCksIFxcXCJUZXh0XFxcIik7XFxuICAgICAgICAgICAgbGV0IF9saW5rcyA9IGh0bWwubWF0Y2goL2h0dHBzOlxcXFwvXFxcXC8od3d3XFxcXC5hbGl5dW5kcml2ZVxcXFwuY29tXFxcXC9zfGFseXdwXFxcXC5uZXQpXFxcXC9cXFxcdyovZykgfHwgW107XFxuICAgICAgICAgICAgbGV0IHNoYXJlUHdkID0gaHRtbC5tYXRjaCgv5o+Q5Y+W56CBWzrvvJpdXFxcXHMqPyhcXFxcd3s0fSkvKTtcXG4gICAgICAgICAgICBzaGFyZVB3ZCA9IEFycmF5LmlzQXJyYXkoc2hhcmVQd2QpICYmIHNoYXJlUHdkLmxlbmd0aCA+IDAgPyBzaGFyZVB3ZFsxXSA6IFxcXCJcXFwiO1xcbiAgICAgICAgICAgIGlmIChfbGlua3MubGVuZ3RoID4gMSAmJiBfbGlua3NbMV0ucmVwbGFjZShfbGlua3NbMF0sIFxcXCJcXFwiKS5yZXBsYWNlKC9bYS16QS1aMC05XSsvZywgXFxcIlxcXCIpID09IFxcXCJcXFwiKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiB7XFxuICAgICAgICAgICAgICAgICAgICBhbGlVcmw6IF9saW5rc1sxXSxcXG4gICAgICAgICAgICAgICAgICAgIHNoYXJlUHdkOiBzaGFyZVB3ZFxcbiAgICAgICAgICAgICAgICB9O1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoX2xpbmtzLmxlbmd0aCA+IDApIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIHtcXG4gICAgICAgICAgICAgICAgICAgIGFsaVVybDogX2xpbmtzWzBdLFxcbiAgICAgICAgICAgICAgICAgICAgc2hhcmVQd2Q6IHNoYXJlUHdkXFxuICAgICAgICAgICAgICAgIH07XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3BhZ2UveXNmeD93ZWJVcmw9XFxcIiArIGVuY29kZVVSSUNvbXBvbmVudChpbnB1dCk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfVxcbiAgICB9LFxcbiAgICB7XFxuICAgICAgICBuYW1lOiAn5LqR55uY5YiG5Lqr56S+5Yy6JyxcXG4gICAgICAgIHBhZ2U6IHRydWUsXFxuICAgICAgICBmaW5kOiBmdW5jdGlvbihzLCBwYWdlKSB7XFxuICAgICAgICAgICAgbGV0IGhvbWUgPSBcXFwiaHR0cHM6Ly95dW5wYW4xLmNjXFxcIjtcXG4gICAgICAgICAgICBsZXQgZCA9IFtdO1xcbiAgICAgICAgICAgIGxldCBodG1sID0gcmVxdWVzdChidWlsZFVybChob21lICsgXFxcIi9hcGkvZGlzY3Vzc2lvbnNcXFwiLCB7XFxuICAgICAgICAgICAgICAgIFxcXCJpbmNsdWRlXFxcIjogXFxcInVzZXIsbGFzdFBvc3RlZFVzZXIsbW9zdFJlbGV2YW50UG9zdCxtb3N0UmVsZXZhbnRQb3N0LnVzZXIsdGFncyx0YWdzLnBhcmVudCxmaXJzdFBvc3RcXFwiLFxcbiAgICAgICAgICAgICAgICBcXFwiZmlsdGVyW3FdXFxcIjogcyAvKiArIFxcXCIgdGFnOnZpZGVvLGNvbWljXFxcIiovICxcXG4gICAgICAgICAgICAgICAgLy9cXFwiZmlsdGVyW3RhZ11cXFwiOiBcXFwidmlkZW8sY29taWNcXFwiLFxcbiAgICAgICAgICAgICAgICBcXFwicGFnZVtvZmZzZXRdXFxcIjogMjAgKiAocGFnZSAtIDEpXFxuICAgICAgICAgICAgfSksIHtcXG4gICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgXFxcImNvbnRlbnQtdHlwZVxcXCI6IFxcXCJhcHBsaWNhdGlvbi9qc29uXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJSZWZlcmVyXFxcIjogXFxcImh0dHBzOi8vcGFuNjY2Lm5ldC8/cT1cXFwiICsgc1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgbGV0IGxpc3QgPSBKU09OLnBhcnNlKGh0bWwpLmRhdGE7XFxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBsaXN0Lmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgIGxldCBpdGVtID0gbGlzdFtpXS5hdHRyaWJ1dGVzO1xcbiAgICAgICAgICAgICAgICBsZXQgdXJsID0gaG9tZSArIFxcXCIvZC9cXFwiICsgaXRlbS5zbHVnO1xcbiAgICAgICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IGl0ZW0udGl0bGUsXFxuICAgICAgICAgICAgICAgICAgICBkZXNjOiAn5Y+R5biD5pe26Ze077yaJyArICQuZGF0ZUZvcm1hdChuZXcgRGF0ZShpdGVtLmNyZWF0ZWRBdCksIFxcXCJ5eXl5LU1NLWRkIEhIOm1tOnNzXFxcIiksXFxuICAgICAgICAgICAgICAgICAgICB1cmw6IHVybCxcXG4gICAgICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbG9uZ0NsaWNrOiBbe1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIui/m+WFpeW4luWtkFxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGpzOiBKU09OLnN0cmluZ2lmeShcXFwiaGlrZXI6Ly9wYWdlL3lzZng/d2ViVXJsPVxcXCIgKyBlbmNvZGVVUklDb21wb25lbnQodXJsKSlcXG4gICAgICAgICAgICAgICAgICAgICAgICB9XVxcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIGQ7XFxuICAgICAgICB9LFxcbiAgICAgICAgZmluZEFsaVVybChpbnB1dCkge1xcbiAgICAgICAgICAgIGxldCBodG1sID0gcGRmaChyZXF1ZXN0KGlucHV0KSwgXFxcIlRleHRcXFwiKTtcXG4gICAgICAgICAgICBsZXQgX2xpbmtzID0gaHRtbC5tYXRjaCgvaHR0cHM6XFxcXC9cXFxcLyh3d3dcXFxcLmFsaXl1bmRyaXZlXFxcXC5jb21cXFxcL3N8YWx5d3BcXFxcLm5ldClcXFxcL1xcXFx3Ki9nKSB8fCBbXTtcXG4gICAgICAgICAgICBsZXQgc2hhcmVQd2QgPSBodG1sLm1hdGNoKC/mj5Dlj5bnoIFbOu+8ml1cXFxccyo/KFxcXFx3ezR9KS8pO1xcbiAgICAgICAgICAgIHNoYXJlUHdkID0gQXJyYXkuaXNBcnJheShzaGFyZVB3ZCkgJiYgc2hhcmVQd2QubGVuZ3RoID4gMCA/IHNoYXJlUHdkWzFdIDogXFxcIlxcXCI7XFxuICAgICAgICAgICAgaWYgKF9saW5rcy5sZW5ndGggPiAxICYmIF9saW5rc1sxXS5yZXBsYWNlKF9saW5rc1swXSwgXFxcIlxcXCIpLnJlcGxhY2UoL1thLXpBLVowLTldKy9nLCBcXFwiXFxcIikgPT0gXFxcIlxcXCIpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIHtcXG4gICAgICAgICAgICAgICAgICAgIGFsaVVybDogX2xpbmtzWzFdLFxcbiAgICAgICAgICAgICAgICAgICAgc2hhcmVQd2Q6IHNoYXJlUHdkXFxuICAgICAgICAgICAgICAgIH07XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChfbGlua3MubGVuZ3RoID4gMCkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4ge1xcbiAgICAgICAgICAgICAgICAgICAgYWxpVXJsOiBfbGlua3NbMF0sXFxuICAgICAgICAgICAgICAgICAgICBzaGFyZVB3ZDogc2hhcmVQd2RcXG4gICAgICAgICAgICAgICAgfTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vcGFnZS95c2Z4P3dlYlVybD1cXFwiICsgZW5jb2RlVVJJQ29tcG9uZW50KGlucHV0KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgIH0sIHtcXG4gICAgICAgIG5hbWU6IFxcXCLniLHnnIvnvo7liadcXFwiLFxcbiAgICAgICAgcGFnZTogdHJ1ZSxcXG4gICAgICAgIGZpbmQ6IGZ1bmN0aW9uKHMsIHBhZ2UpIHtcXG4gICAgICAgICAgICBsZXQgdXJsID0gXFxcImh0dHBzOi8vd3d3LjJrbWouY24vc2VhcmNoLnBocD9xPVxcXCIgKyBzICsgXFxcIiZwYWdlL1xcXCIgKyBwYWdlICsgXFxcIi9cXFwiO1xcbiAgICAgICAgICAgIGxldCBodG1sID0gcmVxdWVzdCh1cmwpO1xcbiAgICAgICAgICAgIGxldCBhcnIgPSBwYXJzZURvbUZvckFycmF5KGh0bWwsIFxcXCIubGlzdC1pdCYmbGlcXFwiKTtcXG5cXG4gICAgICAgICAgICBsZXQgYmV0ID0gW107XFxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBhcnIubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ID0gYXJyW2ldO1xcbiAgICAgICAgICAgICAgICBsZXQgdXRpdGxlID0gcGFyc2VEb21Gb3JIdG1sKGl0LCBcXFwiYSYmdGl0bGVcXFwiKTtcXG4gICAgICAgICAgICAgICAgbGV0IHVzZXJpYWwgPSBwYXJzZURvbUZvckh0bWwoaXQsIFxcXCIuaW5mbyYmc3Bhbjpub3QoOmhhcyhhKSktLWkmJlRleHRcXFwiKTtcXG4gICAgICAgICAgICAgICAgbGV0IHVpbWFnZSA9IHBhcnNlRG9tKGl0LCBcXFwiaW1nJiZzcmNcXFwiKTtcXG4gICAgICAgICAgICAgICAgbGV0IHUgPSBwYXJzZURvbShpdCwgXFxcImEmJmhyZWZcXFwiKTtcXG4gICAgICAgICAgICAgICAgYmV0LnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IHV0aXRsZSxcXG4gICAgICAgICAgICAgICAgICAgIHVybDogdSxcXG4gICAgICAgICAgICAgICAgICAgIHBpY191cmw6IHVpbWFnZSxcXG4gICAgICAgICAgICAgICAgICAgIGRlc2M6IHVzZXJpYWxcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfVxcblxcbiAgICAgICAgICAgIHJldHVybiBiZXQ7XFxuXFxuICAgICAgICB9LFxcbiAgICAgICAgZmluZEFsaVVybChpbnB1dCkge1xcbiAgICAgICAgICAgIHJldHVybiBwZGZhKHJlcXVlc3QoaW5wdXQpLCBcXFwiYm9keSYmI2Rvd25sb2FkXFxcIikubWFwKHYgPT4gcGRmaCh2LCBcXFwiLmRvd24mJmhyZWZcXFwiKSk7XFxuICAgICAgICB9XFxuICAgIH0sXFxuICAgIHtcXG4gICAgICAgIG5hbWU6IFxcXCLlpYflppnmkJzntKJcXFwiLFxcbiAgICAgICAgcGFnZTogdHJ1ZSxcXG4gICAgICAgIGZpbmQocywgcGFnZSkge1xcbiAgICAgICAgICAgIGxldCB1cmw7XFxuICAgICAgICAgICAgaWYgKHBhZ2UgPT09IDEpIHtcXG4gICAgICAgICAgICAgICAgdXJsID0gYnVpbGRVcmwoXFxcImh0dHBzOi8vd3d3Lm1hZ2ljYWxzZWFyY2gudG9wL2FwaS9wc2hvdS9nZXREYXRhXFxcIiwge1xcbiAgICAgICAgICAgICAgICAgICAgd29yZDogcyxcXG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IFxcXCLpmL/ph4znvZHnm5hcXFwiXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHVybCA9IGJ1aWxkVXJsKFxcXCJodHRwczovL3d3dy5tYWdpY2Fsc2VhcmNoLnRvcC9hcGkvcHNob3UvZ2V0TmV4dFBhZ2VcXFwiLCB7XFxuICAgICAgICAgICAgICAgICAgICB1cmw6IFxcXCJodHRwczovL2FwaS51cHl1bnNvMi5jb20vc2VhcmNoP3NfdHlwZT0yQHBhZ2U9XFxcIiArIHBhZ2UgKyBcXFwiQGtleXdvcmQ9XFxcIiArIGVuY29kZVVSSUNvbXBvbmVudChzKSxcXG4gICAgICAgICAgICAgICAgICAgIHdlYnNpdGU6IFxcXCLpmL/ph4znvZHnm5hcXFwiXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgcmVzdWx0ID0gcmVxdWVzdCh1cmwsIHtcXG4gICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgUmVmZXJlcjogYnVpbGRVcmwoXFxcImh0dHBzOi8vd3d3Lm1hZ2ljYWxzZWFyY2gudG9wL3NlYXJjaFxcXCIsIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB3b3JkOiBzLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGNwYWdlOiAwXFxuICAgICAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgcmVzdWx0ID0gSlNPTi5wYXJzZShKU09OLnBhcnNlKHJlc3VsdCkpO1xcbiAgICAgICAgICAgIGxldCBsaXN0ID0gcmVzdWx0LnJlc3VsdC5pdGVtcztcXG4gICAgICAgICAgICBsZXQgZCA9IFtdO1xcbiAgICAgICAgICAgIGZvciAobGV0IGl0IG9mIGxpc3QpIHtcXG4gICAgICAgICAgICAgICAgaWYgKGl0LmlkID09IC0xKSB7XFxuICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IGl0LnRpdGxlLFxcbiAgICAgICAgICAgICAgICAgICAgZGVzYzogXFxcIuaXpeacn++8mlxcXCIgKyBpdC5pbnNlcnRfdGltZSArIFxcXCJcXFxcbui3r+W+hO+8mlxcXCIgKyBpdC5wYXRoLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiBpdC5wYWdlX3VybFxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIGQ7XFxuICAgICAgICB9XFxuICAgIH1cXG5dO1wifSx7XCJjb2xfdHlwZVwiOlwibW92aWVfM1wiLFwibmFtZVwiOlwi5paH5Lu25o6S5bqPXCIsXCJwYXRoXCI6XCJGaWxlU29ydGluZ1wiLFwicnVsZVwiOlwibGV0IGNobk51bUNoYXIgPSB7XFxuICAgIOmbtjogMCxcXG4gICAg5LiAOiAxLFxcbiAgICDkuow6IDIsXFxuICAgIOS4iTogMyxcXG4gICAg5ZubOiA0LFxcbiAgICDkupQ6IDUsXFxuICAgIOWFrTogNixcXG4gICAg5LiDOiA3LFxcbiAgICDlhas6IDgsXFxuICAgIOS5nTogOVxcbn07XFxuXFxubGV0IGNobk5hbWVW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0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICBjbHM6IFxcXCJsb2dpblxcXCJcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9KTtcXG4gICAgICAgIGRlbGV0ZUl0ZW0oXFxcImdldFFDXFxcIik7XFxuICAgICAgICBoaWRlTG9hZGluZygpO1xcbiAgICAgICAgbGV0IHJlZnJlc2hfdG9rZW47XFxuICAgICAgICB3aGlsZSAodHJ1ZSkge1xcbiAgICAgICAgICAgIGxldCBkYXRhO1xcbiAgICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgICAgIGRhdGEgPSBnZXRfcXJjb2RlX3N0YXR1cyhzaWQpO1xcbiAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+afpeivouaJq+eggee7k+aenOi2heaXtiwg5Y+v6IO95piv6Kem5Y+R5LqG6Zi/6YeM5LqR55uY5o6l5Y+j6ZmQ5Yi2LCDor7fnqI3lkI7lho3or5UuXFxcIjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IHN0YXR1cyA9IGRhdGFbXFxcInN0YXR1c1xcXCJdO1xcbiAgICAgICAgICAgIGlmIChzdGF0dXMgPT0gXFxcIkxvZ2luU3VjY2Vzc1xcXCIpIHtcXG4gICAgICAgICAgICAgICAgcmVmcmVzaF90b2tlbiA9IGdldF9yZWZyZXNoX3Rva2VuKGRhdGFbXFxcImF1dGhDb2RlXFxcIl0pO1xcbiAgICAgICAgICAgICAgICBicmVha1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoc3RhdHVzID09IFxcXCJRUkNvZGVFeHBpcmVkXFxcIikge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5LqM57u056CB5bey6L+H5pyfLCDor7fliLfmlrDpobXpnaLlkI7ph43or5VcXFwiO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAoIWdldE15VmFyKFxcXCJMb2dnaW5naW5cXFwiLCBcXFwiXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL2NhbmNlbFxcXCI7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGphdmEubGFuZy5UaHJlYWQuc2xlZXAoMTUwMCk7XFxuICAgICAgICB9XFxuICAgICAgICBpZiAocmVmcmVzaF90b2tlbikge1xcbiAgICAgICAgICAgIGNvbnN0IHtcXG4gICAgICAgICAgICAgICAgb3BlblRva2Vuc0ZpbGVwYXRoLFxcbiAgICAgICAgICAgIH0gPSAkLnJlcXVpcmUoXFxcInRva2VuUGF0aFxcXCIpO1xcbiAgICAgICAgICAgIGxldCBvcGVuID0ge1xcbiAgICAgICAgICAgICAgICBSZWZyZXNoVG9rZW5PcGVuOiByZWZyZXNoX3Rva2VuLFxcbiAgICAgICAgICAgICAgICBpc1YyOiB0cnVlXFxuICAgICAgICAgICAgfTtcXG4gICAgICAgICAgICB3cml0ZUZpbGUob3BlblRva2Vuc0ZpbGVwYXRoLCBKU09OLnN0cmluZ2lmeShvcGVuKSk7XFxuICAgICAgICAgICAgYWRkSXRlbUFmdGVyKFxcXCJpbmZvT3V0cHV0XFxcIiwge1xcbiAgICAgICAgICAgICAgICB0aXRsZTogXFxcIueZu+W9leaIkOWKnyjngrnlh7vov5Tlm54pXFxcIixcXG4gICAgICAgICAgICAgICAgdXJsOiQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKCk9PntcXG4gICAgICAgICAgICAgICAgICAgIGJhY2soZmFsc2UpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICAgICAgfSk7XFxuICA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XFxuICAgICAgICAgICAgXFxcImF1dGhvcml6ZVxcXCI6IDEsXFxuICAgICAgICAgICAgXFxcInNjb3BlXFxcIjogXFxcInVzZXI6YmFzZSxmaWxlOmFsbDpyZWFkLGZpbGU6YWxsOndyaXRlXFxcIlxcbiAgICAgICAgfSkuaGVhZGVycyh7XFxuICAgICAgICAgICAgJ1VzZXItQWdlbnQnOiBQQ19VQSxcXG4gICAgICAgICAgICAnUmVmZXJlcic6ICdodHRwczovL3d3dy5hbGl5dW5kcml2ZS5jb20vJyxcXG4gICAgICAgICAgICAnYXV0aG9yaXphdGlvbic6IHRoaXMuJHRoaXMucmVhY2Nlc3NUaywgLy9nZXRBY2Nlc3NUb2tlblxcbiAgICAgICAgICAgICd4LWNhbmFyeSc6ICdjbGllbnQ9d2ViLGFwcD1zaGFyZSx2ZXJzaW9uPXYyLjMuMScsXFxuICAgICAgICAgICAgJ3gtc2hhcmUtdG9rZW4nOiB0aGlzLiR0aGlzLnNoYXJlVG9rZW5cXG4gICAgICAgIH0pLmVycm9yV2l0aFJldHJ5KChlLCBfLCBodHRwKSA9PiB7XFxuICAgICAgICAgICAgdGhpcy4kdGhpcy50cnlTb2x2ZShlKTtcXG4gICAgICAgICAgICBodHRwLm1lcmdlSGVhZEFuZEJvZHkoe1xcbiAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICAnYXV0aG9yaXphdGlvbic6IHRoaXMuJHRoaXMucmVhY2Nlc3NUayxcXG4gICAgICAgICAgICAgICAgICAgICd4LXNoYXJlLXRva2VuJzogdGhpcy4kdGhpcy5zaGFyZVRva2VuXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICByZXR1cm4gdHJ1ZTtcXG4gICAgICAgIH0pLnN0YXJ0KHRydWUpO1xcbiAgICAgICAgbGV0IGNvZGUgPSByZXN1bHQucmVkaXJlY3RVcmkuc3BsaXQoXFxcImNvZGU9XFxcIilbMV07XFxuICAgICAgICByZXR1cm4gY29kZTtcXG4gICAgfSxcXG4gICAgZ2V0VG9rZW4oYm9keSkge1xcbiAgICAgICAgbGV0IGpzb24gPSBwb3N0KCdodHRwczovL2FwaS54aG9mZS50b3AvYWxpc3QvYWxpX29wZW4vY29kZScsIHtcXG4gICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICdVc2VyLUFnZW50JzogUENfVUEsXFxuICAgICAgICAgICAgICAgICdSZWZlcmVyJzogJ2h0dHBzOi8vd3d3LmFsaXl1bmRyaXZlLmNvbS8nXFxuICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICBib2R5OiBKU09OLnN0cmluZ2lmeShib2R5KSxcXG4gICAgICAgIH0pO1xcbiAgICAgICAgaWYgKCFqc29uKSB7XFxuICAgICAgICAgICAganNvbiA9IHBvc3QoJ2h0dHBzOi8vYXBpLWNmLm5uLmNpL2FsaXN0L2FsaV9vcGVuL2NvZGUnLCB7XFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgICdVc2VyLUFnZW50JzogUENfVUEsXFxuICAgICAgICAgICAgICAgICAgICAnUmVmZXJlcic6ICdodHRwczovL3d3dy5hbGl5dW5kcml2ZS5jb20vJ1xcbiAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICBib2R5OiBKU09OLnN0cmluZ2lmeShib2R5KSxcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH1cXG4gICAgICAgIGlmIChqc29uLmluY2x1ZGVzKCdUb28gTWFueSBSZXF1ZXN0cycpIHx8IGpzb24uaW5jbHVkZXMoXFxcIjUwMiBCYWQgR2F0ZXdheVxcXCIpKSB7XFxuICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKFxcXCLpopHnuYHor7fmsYLmmoLml7booqvlsIHnpoFcXFxcblxcXCIgKyBqc29uKTtcXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgbGV0IG9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VcXFwiXSxcXG4gICAgICAgICAgICBcXFwic2lkXFxcIjogc2lkXFxuICAgICAgICB9XFxuICAgICAgICBsZXQgaGVhZGVycyA9IHtcXG4gICAgICAgICAgICAnYXV0aG9yaXphdGlvbic6IHRoaXMuJHRoaXMucmVhY2Nlc3NUa1xcbiAgICAgICAgfTtcXG4gICAgICAgIGxldCByZXMyID0gdGhpcy4kdGhpcy5wb3N0QXBpKFxcXCJodHRwczovL29wZW4uYWxpeXVuZHJpdmUuY29tL29hdXRoL3VzZXJzL3FyY29kZS9hdXRob3JpemU/c2lkPVxcXCIgKyBzaWQpLmJvZHkoYm9keSkuaGVhZGVycyhoZWFkZXJzKS5lcnJvcldpdGhSZXRyeSgoZSwgXywgaHR0cCkgPT4ge1xcbiAgICAgICAgICAgIHRoaXMuJHRoaXMudHJ5U29sdmUoZSk7XFxuICAgICAgICAgICAgaHR0cC5tZXJnZUhlYWRBbmRCb2R5KHtcXG4gICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgJ2F1dGhvcml6YXRpb24nOiB0aGlzLiR0aGlzLnJlYWNjZXNzVGssXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICByZXR1cm4gdHJ1ZTtcXG4gICAgICAgIH0pLnN0YXJ0KHRydWUpO1xcbiAgICAgICAgcmV0dXJuIGdldF9xcmNvZGVfY29kZShzaWQpO1xcbiAgICB9LFxcbiAgICBnZXRUb2tlbihib2R5KSB7XFxuICAgICAgICBsZXQgcmVzID0gcG9zdChcXFwiaHR0cHM6Ly9hbGl5dW5kcml2ZS1vYXV0aC5tZXNzZW5zZS5tZS9vYXV0aC9hY2Nlc3NfdG9rZW5cXFwiLCB7XFxuICAgICAgICAgICAgYm9keTogSlNPTi5zdHJpbmdpZnkoYm9keSksXFxuICAgICAgICB9KTtcXG4gICAgICAgIGxldCBkYXRhID0gSlNPTi5wYXJzZShyZXMpO1xcblxcbiAgICAg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oaXMudHJ5U29sdmUoZSk7XFxuICAgICAgICAgICAgaHR0cC5tZXJnZUhlYWRBbmRCb2R5KHtcXG4gICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgJ2F1dGhvcml6YXRpb24nOiB0aGlzLiR0aGlzLnJlYWNjZXNzVGssXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICByZXR1cm4gdHJ1ZTtcXG4gICAgICAgIH0pLnN0YXJ0KHRydWUpO1xcbiAgICAgICAgcmV0dXJuIGdldF9xcmNvZGVfY29kZShzaWQpO1xcbiAgICB9LFxcbiAgICBnZXRUb2tlbihib2R5KSB7XFxuICAgICAgICBsZXQgdXJsID0gXFxcIlxcXCI7XFxuICAgICAgICBpZiAoYm9keS5jb2RlKSB7XFxuICAgICAgICAgICAgdXJsID0gYnVpbGRVcmwoXFxcImh0dHA6Ly8xNTkuNzUuMjA4LjQ3L2Nsb3VkaXNrL2FwaS9vYXV0aC9hY2Nlc3NUb2tlblxcXCIsIHtcXG4gICAgICAgICAgICAgICAgYXV0aENvZGU6IGJvZHkuY29kZVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICB1cmwgPSBidWlsZFVybChcXFwiaHR0cDovLzE1OS43NS4yMDguNDcvY2xvdWRpc2svYXBpL29hdXRoL2FjY2Vzc1Rva2VuXFxcIiwge1xcbiAgICAgICAgICAgICAgICByZWZyZXNoVG9rZW46IGJvZHkucmVmcmVzaF90b2tlblxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfVxcbiAgICAgICAgbGV0IHJlcyA9IGZldGNoKHVybCk7XFxuICAgICAgICBsZXQgZGF0YSA9IEpTT04ucGFyc2UocmVzKTtcXG4gICAgICAgIGxldCByZXQgPSB7XFxuICAgICAgICAgICAgcmVmcmVzaF90b2tlbjogZGF0YS5yZWZyZXNoVG9rZW4sXFxuICAgICAgIC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xuICAgICAgICAgICAgY3VycmVudCArPSBjaGFyO1xcbiAgICAgICAgICAgIGVzY2FwZSA9IGZhbHNlO1xcbiAgICAgICAgfSBlbHNlIGlmIChjaGFyID09PSAnXFxcXFxcXFwnKSB7XFxuICAgICAgICAgICAgZXNjYXBlID0gdHJ1ZTtcXG4gICAgICAgIH0gZWxzZSBpZiAoY2hhciA9PT0gJy4nICYmICFpbkJyYWNrZXRzKSB7XFxuICAgICAgICAgICAgcGF0aC5wdXNoKGN1cnJlbnQpO1xcbiAgICAgICAgICAgIGN1cnJlbnQgPSAnJztcXG4gICAgICAgIH0gZWxzZSBpZiAoY2hhciA9PT0gJ1snKSB7XFxuICAgICAgICAgICAgaW5CcmFja2V0cyA9IHRydWU7XFxuICAgICAgICB9IGVsc2UgaWYgKGNoYXIgPT09ICddJykge1xcbiAgICAgICAgICAgIGluQnJhY2tldHMgPSBmYWxzZTtcXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgY3VycmVudCArPSBjaGFyO1xcbiAgICAgICAgfVxcbiAgICB9XFxuICAgIGlmIChjdXJyZW50KSB7XFxuICAgICAgICBwYXRoLnB1c2goY3VycmVudCk7XFxuICAgIH1cXG4gICAgcmV0dXJuIHBhdGg7XFxufVxcblxcbmZ1bmN0aW9uIGdldEpzb24ob2JqLCBwYXRoKSB7XFxuICAgIGlmICghb2JqIHx8ICFBcnJheS5pc0FycmF5KHBhdGgpKSB7XFxuICAgICAgICByZXR1cm4gdW5kZWZpbmVkO1xcbiAgICB9XFxuICAgIGlmIChwYXRoLmxlbmd0aCA9PT0gMCkge1xcbiAgICAgICAgcmV0dXJuIG9iajtcXG4gICAgfVxcbiAgICBsZXQgY3VycmVudCA9IG9iajtcXG4gICAgZm9yIChsZXQgaSA9IDA7IGkgPCBwYXRoLmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICBsZXQga2V5ID0gcGF0aFtpXTtcXG5cXG4gICAgICAgIGlmIChjdXJyZW50ID09PSBudWxsIHx8I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tlblxcXCIpO1xcbiAgICAgICAgICAgICAgICBjbGVhclZhcihcXFwiZG1fc2hhcmVcXFwiKTtcXG4gICAgICAgICAgICAgICAgY2xlYXJNeVZhcihcXFwiZG1saXN0XFxcIik7XFxuICAgICAgICAgICAgICAgIGNsZWFyTXlWYXIoXFxcImxpc3RTZWFyY2hLZXlcXFwiKTtcXG4gICAgICAgICAgICAgICAgY2xlYXJNeVZhcihcXFwiZG1fbGlzdFVybExpc3RcXFwiKTtcXG4gICAgICAgICAgICB9KSk7XFxuICAgICAgICB9XFxuICAgICAgICBzZXRNYXJrZXIoKTtcXG4gICAgICAgIGlmIChNWV9QQVJBTVMuaXNIb21lKSB7XFxuICAgICAgICAgICAgLy9zaWduSW5SZXdhcmQoYWxpQWNjZXNzQXBpKTtcXG4gICAgICAgICAgICBpdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLlpIfku73nm5hcXFwiICsgW1xcXCJcXFwiLCBcXFwi4oiaXFxcIl1bTnVtYmVyKGlzQmFja3VwRHJpdmlkKV0sXFxuICAgICAgICAgICAgICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJteUFsaVBhbkRyaXZpZFxcXCIsIFxcXCJ0cnVlXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF8yXFxcIixcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBpdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLotYTmupDnm5hcXFwiICsgW1xcXCLiiJpcXFwiLCBcXFwiXFxcIl1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ICAgICAgICAgICAgICAgICAgYWxpQWNjZXNzQXBpLmNvcHlGaWxlVG9DbG91ZEZpbGUoc2hhcmVJbmZvLmZpbGVJZCwgZmlsZUlkKTtcXG4gICAgICAgICAgICAgICAgICAgIGJhY2tUb0hvbWUoKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgICAgICAgIH0sIHNoYXJlSW5mbywgaXNCYWNrdXBEcml2aWQsIGZpbGVJZCksXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9XFxuICAgICAgICBpZiAoIWlzU2VhcmNoKSB7XFxuICAgICAgICAgICAgaXRlbXMucHVzaCh7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi5pCc57SiXFxcIixcXG4gICAgICAgICAgICAgICAgdXJsOiAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGlucHV0ID0gaW5wdXQudHJpbSgpO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFpbnB1dCkgcmV0dXJuIFxcXCJ0b2FzdDovL+ivt+i+k+WFpeWFs+mUruivjVxcXCI7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vcGFnZS9teWFsaXl1biNub0hpc3RvcnkjI2Z1bGxUaGVtZSM/cGFnZT1meXBhZ2Umc2VhcmNoS2V5PVxcXCIgKyBlbmNvZGVVUklDb21wb25lbnQoaW5wdXQpO1xcbiAgICAgICAgICAgICAgICB9KSxcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJpbnB1dFxcXCIsXFxuICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICBvbkNoYW5nZTogXFxcInB1dE15VmFyKCdsaXN0U2VhcmNoS2V5JyxpbnB1dClcXFwiLFxcblxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGl0ZW1zLnB1c2goe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuKAnOKAnFxcXCIgKyBzZWFyY2hLZXkgKyBcXFwi4oCd4oCd55qE5pCc57Si57uT5p6cXFxcIixcXG4gICAgICAgICAgICAgICAgdXJsOiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCIsXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2VcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfVxcbiAgICAgICAgbGV0IGZ1bmNJdGVtcyA9IFtdO1xcbiAgICAgICAgZnVuY0l0ZW1zLnB1c2goe1xcbiAgICAgICAgICAgIHRpdGxlOiBzdHlsZSxcXG4gICAgICAgICAgICB1cmw6ICQoc3R5bGVzLCAxLCBcXFwi5o6S5biD5qC35byPXFxcIikuc2VsZWN0KCgpID0+IHtcXG4gICAgICAgICAgICAgICAgc2V0SXRlbShcXFwiYWxpeXVuX3N0eWxlXFxcIiwgaW5wdXQpO1xcbiAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5bey5YiH5o2iXFxcIjtcXG4gICAgICAgICAgICB9KSxcXG4gICAgICAgICAgICBwaWNfdXJsOiBcXFwiaHR0cHM6Ly9oaWtlcmZhbnMuY29tL2ltZy9hbGlfaWNvbi5zdmdcXFwiXFxuICAgICAgICB9LCB7XFxuICAgICAgICAgICAgdGl0bGU6IG9yZGVyTmFtZSxcXG4gICAgICAgICAgICB1cmw6ICQob3JkZXJzS2V5cywgMi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3aXRjaCAoaW5wdXQpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFxcXCLmibnph4/mjILovb3mnKzlnLDlvLnluZVcXFwiOlxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vcGFnZS9kbU1vdW50I25vSGlzdG9yeSMjbm9SZWNvcmRIaXN0b3J5I1xcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBcXFwi5p+l55yL5omL5Yqo5oyC6L295a2X5bmVXFxcIjpcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHptID0gc3RvcmFnZTAuZ2V0TXlWYXIoXFxcIm1vdW50emltdVxcXCIsIHt9KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHRpcCA9IHptLm5hbWUgPyBcXFwi5b2T5YmN5a2X5bmV5paH5Lu2XFxcXG5cXFwiICsgem0ubmFtZSArIFxcXCIuXFxcIiArIHptLmV4dCA6IFxcXCLov5jmnKrmiYvliqjmjILovb3lrZfluZVcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25maXJtKHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiAn5omL5Yqo5oyC6L295a2X5bmVJyxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRlbnQ6IHRpcCArIFxcXCJcXFxcbijngrnlh7vlj5bmtojlj6/ku6XmuIXpmaTmjILovb3lrZfluZUpXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbmNlbDogKCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsZWFyTXlWYXIoXFxcIm1vdW50emltdVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/lt7LmuIXpmaTmiYvliqjmjILovb3lrZfluZVcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgXFxcIuiOt+WPluW8ueW5leaQnOe0ouinhOWImVxcXCI6XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBydWxlID0ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXFxcImpzXFxcIjogSlNPTi5zdHJpbmdpZnkoXFxcImhpa2VyOi8vcGFnZS9sb2FkRG0/cnVsZT1cXFwiICsgTVlfUlVMRS50aXRsZSArIFxcXCImdGl0bGU9XFxcIikgKyBcXFwiK2VuY29kZVVSSUNvbXBvbmVudChwbGF5ZGF0YS50aXRsZS5zcGxpdCgnLScpWzBdKTtcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXFxcIm5hbWVcXFwiOiBNWV9SVUxFLnRpdGxlICsgXFxcIuW8ueW5leaQnOe0olxcXCJcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJydWxlOi8vXFxcIiArIGJhc2U2NEVuY29kZShcXFwi77+lcHJvamVjdGlvbl9zY3JlZW7vv6VcXFwiICsgSlNPTi5zdHJpbmdpZnkocnVsZSkpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgXFxcIuaOqOmAgeWIsFRWQm94XFxcIjpcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3BhZ2UvdHZib3hQdXNoI25vSGlzdG9yeSMjbm9SZWNvcmRIaXN0b3J5I1xcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBcXFwi6K6+572u5pS26JeP5bCB6Z2iXFxcIjpcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICQoW1xcXCLorr7nva7lsIHpnaLlnLDlnYBcXFwiLCBcXFwi5pCc57Si5bCB6Z2iXFxcIl0sIDEpLnNlbGVjdCgoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaW5wdXQgPT09IFxcXCLorr7nva7lsIHpnaLlnLDlnYBcXFwiKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICQoXFxcIlxcXCIsIFxcXCLor7fovpPlhaXlm77niYflnLDlnYBcXFwiKS5pbnB1dCgoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlucHV0ID0gaW5wdXQudHJpbSgpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlucHV0KSByZXR1cm4gXFxcInRvYXN0Oi8v6K+36L6T5YWl5Zyw5Z2AXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0UGFnZVBpY1VybChpbnB1dCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/kv67mlLnmiJDlip9cXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vcGFnZS9mcm9udENvdmVyI25vSGlzdG9yeSMjbm9SZWNvcmRIaXN0b3J5I1xcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgXFxcIuiOt+WPluaKleWxj0lQXFxcIjpcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGlwID0gJC5yZXF1aXJlKFxcXCJhbGlVdGlsXFxcIikuZ2V0SVB2NEFkZHJlc3MoKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlwLnN0YXJ0c1dpdGgoXFxcIjE5Mi4xNjguXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAkKGlwICsgXFxcIlxcXFxu6K+lSVDpgILnlKjkuo7mtYHph48r54Ot54K555qE5oqV5bGPXFxcXG7or7fmm7/mjaLpk77mjqXkuK3nmoQwLjAuMC4wXFxcIikuY29uZmlybSgoaXApID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImNvcHk6Ly9cXFwiICsgaXA7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LCBpcCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJChpcCArIFxcXCJcXFxcbuiOt+WPluWksei0pemdnueos+WumklQLOivt+W8gOWQr+eDreeCueWGjeS9v+eUqCzor6VJUOWPr+iDveS8muWPmCzkuI3og73mipXlsY9cXFwiKS5jb25maXJtKCgpID0+IHt9KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgXFxcIuaegemAn+WOn+eUu+S4i+i9vee6v+eoi1xcXCI6XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAkKGdldEl0ZW0oXFxcInNwZWVkVGhyZWFkXFxcIiwgXFxcIjEwXFxcIiksIFxcXCLor7fovpPlhaUzLTMy5LmL6Ze055qE5pW05pWwXFxcIikuaW5wdXQoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHNwZWVkVGhyZWFkID0gcGFyc2VJbnQoaW5wdXQpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNwZWVkVGhyZWFkIDwgMyB8fCBzcGVlZFRocmVhZCA+IDMyKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+iuvue9ruS4jeWQiOazlVxcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJzcGVlZFRocmVhZFxcXCIsIFN0cmluZyhzcGVlZFRocmVhZCkpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+iuvue9ruaIkOWKn1xcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9KSxcXG4gICAgICAgICAgICAgICAgcGljX3VybDogXFxcImh0dHBzOi8vaGlrZXJmYW5zLmNvbS9pbWcvYWxpX2ZpbGVpbnRvLnN2Z1xcXCIsXFxuICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICBwYWdlSWQ6IHBhZ2VJZCxcXG4gICAgICAgICAgICAgICAgICAgIGZpbGVJZDogZmlsZUlkLFxcbiAgICAgICAgICAgICAgICAgICAgZm9sZGVyTmFtZTogZ2V0UGFnZVRpdGxlKClcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBmdW5jSXRlbXMucHVzaCh7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBbXFxcIkFMTFxcXCIsIFxcXCLku4Xmlofku7ZcXFwiLCBcXFwi5LuF5paH5Lu25aS5XFxcIl1bc2tpcEZpbGVdLFxcbiAgICAgICA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lsZSA9IFxcXCJtb3ZpZV8yXFxcIjtcXG4gICAgICAgIGZpbHRlclR5cGUucHVzaChcXFwidmlkZW9cXFwiKTtcXG4gICAgICAgIGl0ZW1zLnB1c2goe1xcbiAgICAgICAgICAgIHRpdGxlOiBcXFwi4oCc4oCc4oCd4oCdXFxcIiArIFxcXCLov73liafmqKHlvI/lj6rmmL7npLrmlofku7blpLnlkozop4bpopFcXFwiLnNtYWxsKCkuZm9udGNvbG9yKFxcXCJncmV5XFxcIiksXFxuICAgICAgICAgICAgdXJsOiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCIsXFxuICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2VcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9KTtcXG4gICAgfSBlbHNlIGlmIChzdHlsZSA9PT0gXFxcIueci+WbvlxcXCIpIHtcXG4gICAgICAgIGZvbGRlclN0eWxlID0gXFxcImF2YXRhclxcXCI7XFxuICAgICAgICBmaWxlU3R5bGUgPSBcXFwiY2FyZF9waWNfM1xcXCI7XFxuICAgICAgICBmaWx0ZXJUeXBlLnB1c2goXFxcImltYWdlXFxcIik7XFxuICAgICAgICBpdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuKAnOKAnOKAneKAnVxcXCIgKyBcXFwi55yL5Zu+5qih5byP5Y+q5pi+56S65paH5Lu25aS55ZKM5Zu+54mHXFxcIi5zbWFsbCgpLmZvbnRjb2xvcihcXFwiZ3JleVxcXCIpLFxcbiAgICAgICAgICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgbGluZVZpc2libGU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BmaWxlSWQ6IGZpbGVJdGVtLmZpbGVfaWQsXFxuICAgICAgICAgICAgICAgICAgICBpc0JhY2t1cERyaXZpZCxcXG4gICAgICAgICAgICAgICAgICAgIHBhZ2VUaXRsZTogZmlsZUl0ZW0ubmFtZSxcXG4gICAgICAgICAgICAgICAgICAgIHNoYXJlSW5mbyxcXG4gICAgICAgICAgICAgICAgICAgIG5vUGljOiB0cnVlLFxcbiAgICAgICAgICAgICAgICAgICAgbG9uZ0NsaWNrOiBbe1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi5Yig6Zmk5paH5Lu25aS5XFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICBqczogJC50b1N0cmluZyhkZWxldGVERmlsZSwgZmlsZUl0ZW0uZmlsZV9pZCwgaXNCYWNrdXBEcml2aWQsIGZpbGVJdGVtLm5hbWUpXFxuICAgICAgICAgICAgICAgICAgICB9XVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9IGVsc2UgaWYgKG5vU2tpcEZpbGUpIHtcXG4gICAgICAgICAgICBpZiAoZmlsdGVyVHlwZS5sZW5ndGggPiAwICYmICFmaWx0ZXJUeXBlLmluY2x1ZGVzKGNhdGUpKSB7XFxuICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgc3VidGl0bGUsIGNscywgbG9uZ2MgPSBbe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuWIoOmZpOaWh+S7tlxcXCIsXFxuICAgICAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKGRlbGV0ZURGaWxlLCBmaWxlSXRlbS5maWxlX2lkLCBpc0JhY2t1cERyaXZpZCwgZmlsZUl0ZW0ubmFtZSlcXG4gICAgICAgICAgICB9XTtcXG4gICAgICAgICAgICBsZXQgdGl0bGUgPSBmaWxlSXRlbS5uYW1lO1xcbiAgICAgICAgICAgIGxldCBuYW1lTm90RXh0ID0gZmlsZUl0ZW0ubmFtZS5yZXBsYWNlKCcuJyArIGZpbGVJdGVtLmZpbGVfZXh0ZW5zaW9uLCAnJyk7XFxuICAgICAgICAgICAgaWYgKHN1YkV4dHMuaW5jbHVkZXMoZmlsZUl0ZW0uZmlsZV9leHRlbnNpb24pKSB7XFxuICAgICAgICAgICAgICAgIGxvbmdjLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLmjILovb3lrZfluZVcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKHptKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmFnZTAucHV0TXlWYXIoJ21vdW50emltdScsIHptKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJ3RvYXN0Oi8v5oyC6L295a6M5oiQ77yM5b2T5YmN5a2X5bmV5paH5Lu2OiAnICsgem0ubmFtZSArICcuJyArIHptLmV4dDtcXG4gICAgICAgICAgICAgICAgICAgIH0sIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBleHQ6IGZpbGVJdGVtLmZpbGVfZXh0ZW5zaW9uLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGZpbGVfaWQ6IGZpbGVJdGVtLmZpbGVfaWQsXFxuICAgICAgICAgICAgICAgICAgICAgICAgbmFtZTogbmFtZU5vdEV4dFxcbiAgICAgICAgICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAoY2F0ZSA9PT0gXFxcInZpZGVvXFxcIikge1xcbiAgICAgICAgICAgICAgICBpZiAoemltdWxpc3QubGVuZ3RoKSB7XFxuICAgICAgICAgICAgICAgICAgICBzdWJ0aXRsZSA9IHppbXVsaXN0LmZpbmQodiA9PiB2Lm5hbWUuaW5jbHVkZXMobmFtZU5vdEV4dCkpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGNscyA9IFxcXCJwbGF5bGlzdCB2XFxcIiArIHBhZ2VJZDtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKGZpbGVTdHlsZSA9PT0gXFxcInRleHRfMVxcXCIpIHtcXG4gICAgICAgICAgICAgICAgZGVzYyArPSBcXFwiXFxcXHRcXFxcdFxcXCIgKyBmb3JtYXRTaXplKGZpbGVJdGVtLnNpemUpO1xcbiAgICAgICAgICAgICAgICB0aXRsZSA9IGdldEhlYWQoY2F0ZSwgZmlsZUl0ZW0uZmlsZV9leHRlbnNpb24pICsgdGl0bGU7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChbXFxcInZpZGVvXFxcIiwgXFxcImltYWdlXFxcIl0uaW5jbHVkZXMoY2F0ZSkpIHtcXG4gICAgICAgICAgICAgICAgcGljX3VybCA9IGdldFByZXZpZXdQaWMoZmlsZUl0ZW0pIHx8IHBpY191cmw7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGl0ZW1zLnB1c2goe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogdGl0bGUsXFxuICAgICAgICAgICAgICAgIHVybDogJChcXFwiI25vUHJlI1xcXCIpLmxhenlSdWxlKChmaWxlSWQsIGNhdGUsIGlzQmFja3VwRHJpdmlkLCBzdWJ0aXRsZSkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuICQucmVxdWlyZShcXFwibXlhbGlsYXp5XFxcIikoZmlsZUlkLCBjYXRlLCBpc0JhY2t1cERyaXZpZCwgc3VidGl0bGUpO1xcbiAgICAgICAgICAgICAgICB9LCBmaWxlSXRlbS5maWxlX2lkLCBjYXRlLCBpc0JhY2t1cERyaXZpZCwgc3VidGl0bGUpLFxcbiAgICAgICAgICAgICAgICBkZXNjOiBkZXNjLFxcbiAgICAgICAgICAgICAgICBwaWNfdXJsOiBwaWNfdXJsLFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgaWQ6IGZpbGVJdGVtLmZpbGVfaWQsXFxuICAgICAgICAgICAgICAgICAgICBsb25nQ2xpY2s6IGxvbmdjLFxcbiAgICAgICAgICAgICAgICAgICAgY2xzOiBjbHMsXFxuICAgICAgICAgICAgICAgICAgICAvL2luaGVyaXRUaXRsZTogZmFsc2UsXFxuICAgICAgICAgICAgICAgICAgICBwYWdlVGl0bGU6IGZpbGVJdGVtLm5hbWVcXG4gICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IGZpbGVTdHlsZVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfVxcbiAgICB9XFxuICAgIGlmIChjb250cy5sZW5ndGggPT09IDApIHtcXG4gICAgICAgIGl0ZW1zLnB1c2goe1xcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICAgICAgdXJsOiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCIsXFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLigJzigJzigJ3igJ1cXFwiICsgXFxcIn5+fuS7gOS5iOmDveayoeacieS6huWTpn5+flxcXCIuZm9udGNvbG9yKFxcXCJHcmF5XFxcIiksXFxuICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgbGluZVZpc2libGU6IGZhbHNlLFxcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0pO1xcbiAgICB9XFxufVxcblxcbmxldCBpdGVtcyA9IFtdO1xcbnRyeSB7XFxuICAgIGlmIChNWV9QQUdFID4gMSAmJiAhTVlfUEFSQU1TLm1hcmtlcikge1xcbiAgICAgICAgaXRlbXMucHVzaCh7XFxuICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuKAnOKAnOK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v+i3r1xcbiAgICAgICAgICAgIGxpbmUgPSBsaW5lLnN1YnN0cmluZyhsaW5lLmxhc3RJbmRleE9mKCcvJykgKyAxKTtcXG4gICAgICAgICAgICBsZXQgZiA9IGdldE0zdThDb250ZW50KGdldEFsaVBsYXlVcmwoZmlkLCBsaW5lKSkuc3BsaXQoXFxcIlxcXFxuXFxcIik7XFxuICAgICAgICAgICAgZi5mb3JFYWNoKGl0ID0+IHtcXG4gICAgICAgICAgICAgICAgaWYgKGl0ICYmIGl0LnN0YXJ0c1dpdGgoJy9wcm94eT91cmw9JykpIHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBmdXJsID0gYmFzZTY0RGVjb2RlKGl0LnJlcGxhY2UoJy9wcm94eT91cmw9JywgJycpKTtcXG4gICAgICAgICAgICAgICAgICAgIGlmICh1cmwuc3Vic3RyKHVybC5pbmRleE9mKCcvbWVkaWEtJyksIHVybC5pbmRleE9mKCcudHMnKSkgPT0gZnVybC5zdWJzdHIoZnVybC5pbmRleE9mKCcvbWVkaWEtJyksIGZ1cmwuaW5kZXhPZignLnRzJykpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdXJsID0gZnVybDtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pXFxuXFxuICAgICAgICB9XFxuICAgICAgICByZXR1cm4gdXJsO1xcbiAgICB9XFxuICAgIHRyeSB7XFxuICAgICAgICBsZXQgdXJsID0gYmFzZTY0RGVjb2RlKE1ZX1BBUkFNUy51cmxbMF0pO1xcbiAgICAgICAgaWYgKHVybC5pbmNsdWRlcyhcXFwiLnRzXFxcIikpIHtcXG4gICAgICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkoe1xcbiAgICAgICAgICAgICAgICBzdGF0dXNDb2RlOiAzMDIsXFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJMb2NhdGlvblxcX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sIHt9KTtcXG4gICAgICAgIGlmIChPYmplY3Qua2V5cyhtb3VudHN1YikubGVuZ3RoID4gMCkge1xcbiAgICAgICAgICAgIHppbXUgPSBtb3VudHN1YjtcXG4gICAgICAgIH1cXG4gICAgICAgIGxldCBzdWJ0aXRsZTtcXG4gICAgICAgIGlmIChPYmplY3Qua2V5cyh6aW11IHx8IHt9KS5sZW5ndGggPiAwICYmIHBsYXlMaXN0ICYmIHBsYXlMaXN0LnVybHMgJiYgcGxheUxpc3QudXJscy5sZW5ndGggPiAwKSB7XFxuICAgICAgICAgICAgamF2YS5sYW5nLlRocmVhZC5zbGVlcCgxMDApO1xcbiAgICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgICAgIHZhciB6bXVybCA9IGFsaUFjY2Vzc0FwaS5vcGVuQ2xvdWRGaWxlVG9Eb3duVXJsKHppbXUuZmlsZV9pZCk7XFxuICAgICAgICAgICAgICAgIGxldCBwYXRoID0gJ2hpa2VyOi8vZmlsZXMvY2FjaGUv5LqR55uY5ZCbL3N1Yi4nICsgemltdS5leHQ7XFxuICAgICAgICAgICAgICAgIGRvd25sb2FkRmlsZSh6bXVybCwgcGF0aCwge1xcbiAgICAgICAgICAgICAgICAgICAgJ1JlZmVyZXInOiAnaHR0cHM6Ly93d3cuYWxpeXVuZHJpdmUuY29tLydcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIHN1YnRpdGxlID0gZ2V0UGF0aChwYXRoKTtcXG4gICAgICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgICAgIHRvYXN0KFxcXCLlrZfluZXliqDovb3lpLHotKVcXFwiKTtcXG4gICAgICAgICAgICAgICAgbG9nKGUubWVzc2FnZSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfVxcbiAgICAgICAgbGV0IGRtbGlzdCA9IHN0b3JhZ2UwLmdldE15VmFyKFxcXCJkbWxpc3RcXFwiLCBbXSk7XFxuICAgICAgICBsZXQgZG1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XNoKHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogZXBpc29kZS5lcGlzb2RlVGl0bGUsXFxuICAgICAgICAgICAgICAgICAgICAgICAgdXJsOiAkKGVwaXNvZGUuZXBpc29kZUlkKS5sYXp5UnVsZSgodGl0bGUpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZGFubXUgPSAkLnJlcXVpcmUoXFxcImRhbm11XFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBwYXRoID0gZGFubXUuZ2V0TG9jYWxEYW5NdShpbnB1dCwgdGl0bGUpIHx8IGRhbm11LmRvd25sb2FkRGFuTXUoaW5wdXQsIHRpdGxlKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGRhbm11VGV4dCA9IGZldGNoKHBhdGgpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWRhbm11VGV4dCkgcmV0dXJuIFxcXCJ0b2FzdDovL+i/mOayoeacieW8ueW5leWTn35cXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcGF0aDtcXG4gICAgICAgICAgICAgICAgICAgICAgICB9LCBkbVRpdGxlKSxcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIHJldHVybiBkO1xcbiAgICAgICAgICAgIH0sIGFuaW1lLmVwaXNvZGVzLCBhbmltZS5hbmltZVRpdGxlKSxcXG4gICAgICAgIH0pO1xcblxcbiAgICB9XFxuICAgIHJldHVybiBkO1xcbn1cXG5zZWFyY2goaW5wdXQpXCJ9XSIsImljb24iOiJodHRwczovL2ltZy5hbGljZG4uY29tL2ltZ2V4dHJhL2kyL08xQ04wMURPWWNzNzF2M0I2Yk9lbVZNXyEhNjAwMDAwMDAwNjExNi0yLXRwcy01MTItNTEyLnBuZyIsInByb3h5IjoiIn0=
Add Comment
Please, Sign In to add comment