xiaomianao666

小程序:腾讯视频

May 23rd, 2024
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 海阔视界规则分享,当前分享的是:小程序¥home_rule_v2¥base64://@腾讯视频@eyJmaXJzdEhlYWRlciI6ImNsYXNzIiwibGFzdF9jaGFwdGVyX3J1bGUiOiJqczpcbi8vbG9nKE1ZX1VSTClcbnZhciBjaWQgPSBNWV9VUkwuc3BsaXQoJyMnKVsxXTtcbnZhciB2aWQgPSBNWV9VUkwuc3BsaXQoJyMnKVsyXTtcbi8vbG9nKGNpZClcbi8vbG9nKHZpZClcbmNvbnN0IGVqVXJsID0gXCJodHRwczovL3BiYWNjZXNzLnZpZGVvLnFxLmNvbS90cnBjLnVuaXZlcnNhbF9iYWNrZW5kX3NlcnZpY2UucGFnZV9zZXJ2ZXJfcnBjLlBhZ2VTZXJ2ZXIvR2V0UGFnZURhdGE/dmlkZW9fYXBwaWQ9MzAwMDAxMCZ2cGxhdGZvcm09MlwiO1xudmFyIGluZm9fZmV0Y2hEYXRhID0gSlNPTi5wYXJzZShmZXRjaFBDKGVqVXJsLCB7XG4gICAgaGVhZGVyczoge1xuICAgICAgICBcIkNvbnRlbnQtVHlwZVwiOiBcImFwcGxpY2F0aW9uL2pzb25cIixcbiAgICAgICAgXCJyZWZlcmVyXCI6IFwiaHR0cHM6Ly92LnFxLmNvbS9cIixcbiAgICAgICAgXCJDb29raWVcIjogXCJ2aWRlb19wbGF0Zm9ybT0yO3Z2ZXJzaW9uX25hbWU9OC4yLjk1XCJcbiAgICB9LFxuICAgIG1ldGhvZDogXCJQT1NUXCIsXG4gICAgYm9keToge1xuICAgICAgICBcInBhZ2VfcGFyYW1zXCI6IHtcbiAgICAgICAgICAgIFwicmVxX2Zyb21cIjogXCJ3ZWJcIixcbiAgICAgICAgICAgIFwiY2lkXCI6IChjaWQgPyBjaWQgOiBcIlwiKSxcbiAgICAgICAgICAgIFwidmlkXCI6IHZpZCxcbiAgICAgICAgICAgIFwibGlk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ICAgICAgICAgICAgY2xlYXJNeVZhcihcInNoZWx2ZXNfTG9hZGluZGV4XCIpO1xuICAgICAgICAgICAgICAgICAgICBjbGVhck15VmFyKFwidmlkZW9fTG9hZGluZGV4XCIpO1xuICAgICAgICAgICAgICAgICAgICBjbGVhck15VmFyKFwiY2hhbm5lbF9maXJzdF9jbGFzc1wiKTtcbiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UodHJ1ZSk7IC8vZmFsc2XliLfmlrDkuI3lm57mu5rliLDpobXpnaLpobbpg6hcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFwiaGlrZXI6Ly9lbXB0eVwiXG4gICAgICAgICAgICAgICAgfSwgbmFtZSwgaXQuY2hhbm5lbF9pZCksXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IFwic2Nyb2xsX2J1dHRvblwiXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgIH0pXG4gICAgZC5wdXNoKHtcbiAgICAgICAgY29sX3R5cGU6IFwiYmxhbmtfYmxvY2tcIlxuICAgIH0pO1xuXG4gICAgdmFyIGhvbWVmZXRjaERhdGEgPSBKU09OLnBhcnNlKGZldGNoUEMoTVsxXSwge1xuICAgICAgICBoZWFkZXJzOiB7XG4gICAgICAgICAgICBcIkNvbnRlbnQtVHlwZVwiOiBcImFwcGxpY2F0aW9uL2pzb25cIixcbiAgICAgICAgICAgIFwicmVmZXJlclwiOiBcImh0dHBzOi8vdi5xcS5jb20vXCIsXG4gICAgICAgICAgICBcIkNvb2tpZVwiOiBcInZpZGVvX3BsYXRmb3JtPTJcIlxuICAgICAgICB9LFxuICAgICAgICBtZXRob2Q6IFwiUE9TVFwiLFxuICAgICAgICBib2R5OiBib2R5XG4gICAgfSkpXG4gICAgLy9sb2coZkRhdGEpXG4gICAgdmFyIGhvbWVDYXJkTGlzdCA9IGhvbWVmZXRjaERhdGEuZGF0YS5DYXJkTGlzdDtcbiAgICB2YXIgaGFzX25leHRfcGFnZSA9IGhv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BsZXQgZGVzID0gXCJcIjtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGl0ZW0ucGFyYW1zLmltZ3RhZykge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKC90YWdfMnx0YWdfMy8udGVzdChpdGVtLnBhcmFtcy5pbWd0YWcpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGltZ3RhZyA9IEpTT04ucGFyc2UoaXRlbS5wYXJhbXMuaW1ndGFnKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvL2xvZyhpbWd0YWcpICAgICAgICAgICAgICAgICAgICAgXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzID0gaW1ndGFnLnRhZ18zLnRleHQgPyBpbWd0YWcudGFnXzMudGV4dCA6IGltZ3RhZy50YWdfMi50ZXh0LnNwbGl0KFwiLVwiKVswXVxuICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXMgPSBpdGVtLnBhcmFtcy5pbWd0YWc7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBkZXMgPSBpdGVtLnBhcmFtcy50aW1lbG9uZyB8fCBpdGVtLnBhcmFtcy5wdWJsaXNoX2RhdGUgfHwgaXRlbS5wYXJhbXMuZXBpc29kZV91cGRhdGVkIHx8IChpdGVtLnBhcmFtcy5kdXJhdGlvbiA/IHNlY29uZHNUb1RpbWUoaXRlbS5wYXJhbXMuZHVyYXRpb24pIDogXCJcIikgfHwgKGl0ZW0ucGFyYW1zLmNtc19pc3ZpcCA9PSAxID8gXCJWSVBcIiA6IFwiXCIpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGxldCBwYXJhbV9jaWQgPSBcIlwiO1xuICAgICAgICAgICAgICAgICAgICBpZiAoaXRlbS5wYXJhbXMuY2lkKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBwYXJhbV9jaWQgPSBpdGVtLnBhcmFtcy5jaWQ7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaXRlbS5wYXJhbXMuYXR0YWNoZWRfaWQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHBhcmFtX2NpZCA9IGl0ZW0ucGFyYW1zLmF0dGFjaGVkX2lkO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIC8vbG9nKGl0ZW0pXG4gICAgICAgICAgICAgICAgICAgIGlmIChleHRyYV9wYXJhbSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGVtcF9saXN0cy5wdXNoKHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogaXRlbS5wYXJhbXMudGl0bGUsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzYzogZGVzLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBpY191cmw6IHBpYyxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1cmw6IFwiaGlrZXI6Ly9wYWdlL2VqX3BhZ2VcIixcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBleHRyYToge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbHM6IGV4dHJhX3BhcmFtLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwaWNVcmw6IHBpYyxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzY3I6IGl0ZW0ucGFyYW1zLmR1cmF0aW9uID8gc2Vjb25kc1RvVGltZShpdGVtLnBhcmFtcy5kdXJhdGlvbikgOiBcIlwiLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1cmw6IFwiaGlrZXI6Ly9lbXB0eSNcIiArIHBhcmFtX2NpZCArIFwiI1wiICsgKGl0ZW0ucGFyYW1zLnZpZCA/IGl0ZW0ucGFyYW1zLnZpZCA6IFwiXCIpICsgXCIjaW1tZXJzaXZlVGhlbWUjXCJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICB9KVxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGVtcF9saXN0cy5wdXNoKHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogaXRlbS5wYXJhbXMudGl0bGUsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzYzogZGVzLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBpY191cmw6IHBpYyxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1cmw6IFwiaGlrZXI6Ly9wYWdlL2VqX3BhZ2VcIixcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBleHRyYToge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwaWNVcmw6IHBpYyxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzY3I6IGl0ZW0ucGFyYW1zLmR1cmF0aW9uID8gc2Vjb25kc1RvVGltZShpdGVtLnBhcmFtcy5kdXJhdGlvbikgOiBcIlwiLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1cmw6IFwiaGlrZXI6Ly9lbXB0eSNcIiArIHBhcmFtX2NpZCArIFwiI1wiICsgKGl0ZW0ucGFyYW1zLnZpZCA/IGl0ZW0ucGFyYW1zLnZpZCA6IFwiXCIpICsgXCIjaW1tZXJzaXZlVGhlbWUjXCJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICB9KVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xuICAgICAgICAgICAgICAgIGxvZyhlLnRvU3RyaW5nKCkpXG4gICAgICAgICAgICAgICAgbG9nKGl0ZW0pXG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgICAgICByZXR1cm4gdGVtcF9saXN0c1xuICAgIH1cblxuICAgIGhvbWVDYXJkTGlzdC5mb3JFYWNoKChpdGVtKSA9PiB7XG4gICAgICAgIC8vbG9nKGl0ZW0udHlwZSlcbiAgICAgICAgLypcbiAgICAgICAgaWYgKC9odHRwLy50ZXN0KGl0ZW0uY2hpbGRyZW5fbGlzdC5saXN0LmNhcmRzWzBdLmlkKSlcbiAgICAgICAgICAgIHJldHVybiovXG4gICAgICAgIGlmIChpdGVtLnR5cGUgPT0gXCJwY19jYXJvdXNlbFwiKSB7XG4gICAgICAgICAgICAvL+a1t+aKpeWIl+ihqFxuICAgICAgICAgICAgLypcbiAgICAgICAgICAgIGxvZyhcIuWKoOi9vea1t+aKpVwiKSAgICAgICBcbiAgICAgICAgICAgIHB1dFZhcihcInBjX2Nhcm91c2VsXCIsIEpTT04uc3RyaW5naWZ5KGl0ZW0uY2hpbGRyZW5fbGlzdC5saXN0LmNhcmRzKSlcbiAgICAgICAgICAgIGQucHVzaCh7XG4gICAgICAgICAgICAgICAgdXJsOiBnZXRQYXRoKCdoaWtlcjovL2ZpbGVzL1R5cmFudEcvcHVibGljL3R4X2Jhbm5lcnMuaHRtbCcpLFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcIng1X3dlYnZpZXdfc2luZ2xlXCIsXG4gICAgICAgICAgICAgICAgZXh0cmE6IHtcbiAgICAgICAgICAgICAgICAgICAgZGVzYzogXCJhdXRvXCJcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KSovXG4gICAgICAgIH0gZWxzZSBpZiAoaXRlbS50eXBlID09IFwicGNfaG90X2ZpbHRlclwiKSB7XG4gICAgICAgICAgICAvL+eDremXqOWIhuexu+aOqOiNkCAgICAgICAgICAgIFxuICAgICAgICAgICAgdmFyIHBjX2hvdF9maWx0ZXIgPSBpdGVtLmNoaWxkcmVuX2xpc3QubGlzdC5jYXJkcztcbiAgICAgICAgICAgIC8vbG9nKHBjX2hvdF9maWx0ZXIpXG4gICAgICAgICAgICBpZiAoaXRlbS5pZCA9PSBcIjQwXzFjNDllXCIpIHtcbiAgICAgICAgICAgICAgICBwY19ob3RfZmlsdGVyLmZvckVhY2goaXQgPT4ge1xuICAgICAgICAgICAgICAgICAgICBsZXQgbmFtZSA9IGl0LnBhcmFtcy5sYWJlbF90aXRsZTtcbiAgICAgICAgICAgICAgICAgICAgZC5wdXNoKHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBnZXRNeVZhcignZnJlZVR5cGUnKSA9PT0gbmFtZSA/ICfigJzigJzigJ3igJ08Yj48Zm9udCBjb2xvcj0jMDBGRkZGPicgKyBuYW1lICsgJzwvZm9udD48L2I+JyA6IG5hbWUsXG4gICAgICAgICAgICAgICAgICAgICAgICB1cmw6ICQoJyNub0xvYWRpbmcjI25vSGlzdG9yeSMnKS5sYXp5UnVsZSgobmFtZSwgZmlsdGVyX3ZhbHVlKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcHV0TXlWYXIoXCJmcmVlVHlwZVwiLCBuYW1lKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwdXRNeVZhcihcImNoYW5uZWxfZmlyc3RfY2xhc3NcIiwgZmlsdGVyX3ZhbHVlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7IC8vZmFsc2XliLfmlrDkuI3lm57mu5rliLDpobXpnaLpobbpg6hcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXCJoaWtlcjovL2VtcHR5XCJcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sIG5hbWUsIGl0LnBhcmFtcy5maWx0ZXJfdmFsdWUpLFxuICAgICAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6IFwic2Nyb2xsX2J1dHRvblwiXG4gICAgICAgICAgICAgICAgICAgIH0pO1xuXG4gICAgICAgICAgICAgICAgfSlcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgcGNfaG90X2ZpbHRlci5mb3JFYWNoKChpdGVtKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgIGQucHVzaCh7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogaXRlbS5wYXJhbXMubGFiZWxfdGl0bGUsXG4gICAgICAgICAgICAgICAgICAgICAgICB1cmw6ICdoaWtlcjovL3BhZ2UvY2hhbm5lbF9saXN0X2ZpbHRlcicsXG4gICAgICAgICAgICAgICAgICAgICAgICBjb2xfdHlwZTogXCJzY3JvbGxfYnV0dG9uXCIsXG4gICAgICAgICAgICAgICAgICAgICAgICBleHRyYToge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVybDogTVsxXSArIFwiIyNmeXBhZ2VcIixcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaWx0ZXJfdmFsdWU6IGl0ZW0ucGFyYW1zLmZpbHRlcl92YWx1ZSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlX2lkOiBpdGVtLnBhcmFtcy5wYWdlX2lkXG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfVxuICAgICAgICB9IGVsc2UgaWYgKGl0ZW0udHlwZSA9PSBcInBjX3NoZWx2ZXNcIikge1xuICAgICAgICAgICAgLy9sb2coaXRlbSlcbiAgICAgICAgICAgIGlmIChnZXRNeVZhcihcInNoZWx2ZXNfTG9hZGluZGV4XCIsIFwiMVwiKSA9PSBcIjFcIikge1xuICAgICAgICAgICAgICAgIC8v56ys5LiA5qyh5Yqg6L29ICAgICAgICAgICAgICBcbiAgICAgICAgICAgICAgICB2YXIgc2hlbHZlc0xpc3QgPSBpdGVtLmNoaWxkcmVuX2xpc3QubGlzdC5jYXJkcztcbiAgICAgICAgICAgICAgICBkLnB1c2goe1xuICAgICAgICAgICAgICAgICAgICB0aXRsZTogaXRlbS5wYXJhbXMuWlRfbGVhZl9oZWFkICsgJ1xcdFxcdFxcdFxcdFxcdFxcdOaNouS4gOaNovCflIEnLFxuICAgICAgICAgICAgICAgICAgICBwaWNfdXJsOiBcImh0dHBzOi8vaGlrZXJmYW5zLmNvbS90dWJpYW8vcS8xMzYucG5nQFJlZmVyZXI9XCIsXG4gICAgICAgICAgICAgICAgICAgIHVybDogJCgpLmxhenlSdWxlKChzaGVsdmVzTGlzdCwgZ2V0UmFuZG9tQXJyYXlWYWx1ZSwgc2Vjb25kc1RvVGltZSwgcHVzaERhdGEpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzaGVMaXN0cyA9IGdldFJhbmRvbUFycmF5VmFsdWUoc2hlbHZlc0xpc3QsIDYpO1xuICAgICAgICAgICAgICAgICAgICAgICAgLy9sb2coZ2V0UmFuZG9tQXJyYXlWYWx1ZS50b1N0cmluZygpKVxuICAgICAgICAgICAgICAgICAgICAgICAgLy9sb2coc2Vjb25kc1RvVGltZS50b1N0cmluZygpKVxuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHNoZXJhbmRvbUxpc3RzID0gcHVzaERhdGEoc2hlTGlzdHMsIHNlY29uZHNUb1RpbWUsIFwic2hlbHZlc0xpc3RzXCIpO1xuICAgICAgICAgICAgICAgICAgICAgICAgLy9sb2coc2hlcmFuZG9tTGlzdHMpICAgICAgICAgICAgICAgICAgIFxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNoZXJhbmRvbUxpc3RzKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVsZXRlSXRlbUJ5Q2xzKCdzaGVsdmVzTGlzdHMnKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhZGRJdGVtQWZ0ZXIoJ1pUX2xlYWZfaGVhZF8xJywgc2hlcmFuZG9tTGlzdHMpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICdoaWtlcjovL2VtcHR5J1xuICAgICAgICAgICAgICAgICAgICB9LCBzaGVsdmVzTGlzdCwgZ2V0UmFuZG9tQXJyYXlWYWx1ZSwgc2Vjb25kc1RvVGltZSwgcHVzaERhdGEpLFxuICAgICAgICAgICAgICAgICAgICBjb2xfdHlwZTogXCJhdmF0YXJcIixcbiAgICAgICAgICAgICAgICAgICAgZXh0cmE6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlkOiBcIlpUX2xlYWZfaGVhZF8xXCJcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIHZhciBzaGVsdmVzRGF0YSA9IGdldFJhbmRvbUFycmF5VmFsdWUoc2hlbHZlc0xpc3QsIDYpO1xuICAgICAgICAgICAgICAgIEFycmF5LnByb3RvdHlwZS5wdXNoLmFwcGx5KGQsIHB1c2hEYXRhKHNoZWx2ZXNEYXRhLCBzZWNvbmRzVG9UaW1lLCBcInNoZWx2ZXNMaXN0c1wiKSk7XG4gICAgICAgICAgICAgICAgcHV0TXlWYXIoXCJzaGVsdmVzX0xvYWRpbmRleFwiLCBcIjJcIilcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgZC5wdXNoKHtcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IGl0ZW0ucGFyYW1zLlpUX2xlYWZfaGVhZCxcbiAgICAgICAgICAgICAgICAgICAgcGljX3VybDogXCJodHRwczovL2hpa2VyZmFucy5jb20vdHViaWFvL21lc3N5LzE2Ny5zdmdAUmVmZXJlcj1cIixcbiAgICAgICAgICAgICAgICAgICAgdXJsOiAkKFwiI25vUmVjb3JkSGlzdG9yeSMjbm9Mb2FkaW5nI1wiKS5sYXp5UnVsZSgoKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJ2hpa2VyOi8vZW1wdHknXG4gICAgICAgICAgICAgICAgICAgIH0pLFxuICAgICAgICAgICAgICAgICAgICBjb2xfdHlwZTogXCJhdmF0YXJcIlxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIHZhciBzaGVsdmVzTGlzdCA9IGl0ZW0uY2hpbGRyZW5fbGlzdC5saXN0LmNhcmRzO1xuICAgICAgICAgICAgICAgIEFycmF5LnByb3RvdHlwZS5wdXNoLmFwcGx5KGQsIHB1c2hEYXRhKHNoZWx2ZXNMaXN0LCBzZWNvbmRzVG9UaW1lKSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSBpZiAoaXRlbS50eXBlID09IFwiY2hhbm5lbF9wbGF5X3NjaGVkdWxlXCIpIHtcbiAgICAgICAgICAgIC8v5Yqo5ryr6L+955Wq5pe26Ze06KGoICAgICAgICAgICBcbiAgICAgICAgICAgIGxldCBjX3Bfc2NoZWR1bGUgPSBpdGVtLmNoaWxkcmVuX2xpc3QubGlzdC5jYXJkcztcbiAgICAgICAgICAgIGxldCBmbGlwX2luZm8gPSBpdGVtLmZsaXBfaW5mb3MudGFiO1xuICAgICAgICAgICAgaWYgKGZsaXBfaW5mbykge1xuICAgICAgICAgICAgICAgIHB1dE15VmFyKFwiZmxpcF9pbmZvXCIsIEpTT04uc3RyaW5naWZ5KGZsaXBfaW5mbykpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgLy9sb2coY19wX3NjaGVkdWxlKVxuICAgICAgICAgICAgdmFyIHNjdGl0bGVBcnIgPSBbXTtcbiAgICAgICAgICAgIGNfcF9zY2hlZHVsZS5mb3JFYWNoKChpdGVtLCBpbmRleCkgPT4ge1xuICAgICAgICAgICAgICAgIGlmIChpbmRleCA8IDcpIHtcbiAgICAgICAgICAgICAgICAgICAgbGV0IHRpdGxlID0gaXRlbS5wYXJhbXMudGl0bGU7XG4gICAgICAgICAgICAgICAgICAgIHNjdGl0bGVBcnIucHVzaCh0aXRsZSk7XG4gICAgICAgICAgICAgICAgICAgIGlmIChpbmRleCA9PSA2KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBwdXRNeVZhcihcInNjdGl0bGVBcnJcIiwgSlNPTi5zdHJpbmdpZnkoc2N0aXRsZUFycikpXG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgLy9sb2coc2N0aXRsZUFycilcbiAgICAgICAgICAgICAgICAgICAgbGV0IGRhdGFfa2V5ID0gaXRlbS5wYXJhbXMuZGF0YV9rZXk7XG4gICAgICAgICAgICAgICAgICAgIGQucHVzaCh7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogZ2V0TXlWYXIoJ3dlZWsnLCBcIuS7iuWkqVwiKSA9PT0gdGl0bGUgPyAn4oCc4oCc4oCd4oCdPGI+PGZvbnQgY29sb3I9I0ZBNzI5OD4nICsgdGl0bGUgKyAnPC9mb250PjwvYj4nIDogdGl0bGUsXG4gICAgICAgICAgICAgICAgICAgICAgICB1cmw6ICQoJyNub0xvYWRpbmcjI25vSGlzdG9yeSMnKS5sYXp5UnVsZSgodGl0bGUsIGRhdGFfa2V5LCBpbmRleCwgcHVzaERhdGEsIHNlY29uZHNUb1RpbWUpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwdXRNeVZhcihcIndlZWtcIiwgdGl0bGUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vcHV0TXlWYXIoXCJkYXRhX2tleVwiLCBkYXRhX2tleSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLy9sb2coZGF0YV9rZXkpICAgICAgICAgICAgICAgICAgICAgICAgICBcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgZGF0YV9rZXlfT2JqID0gbmV3IE9iamVjdCgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBkYXRhX2tleXMgPSBkYXRhX2tleS5zcGxpdChcIiZcIik7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yICh2YXIgaSA9IDA7IGkgPCBkYXRhX2tleXMubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YV9rZXlfT2JqW2RhdGFfa2V5c1tpXS5zcGxpdChcIj1cIilbMF1dID0gdW5lc2NhcGUoZGF0YV9rZXlzW2ldLnNwbGl0KFwiPVwiKVsxXSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vbG9nKGRhdGFfa2V5X09iailcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvL2xvZyhKU09OLnBhcnNlKGdldE15VmFyKFwiZmxpcF9pbmZvXCIpKSlcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgcFVybCA9IFwiaHR0cHM6Ly9wYmFjY2Vzcy52aWRlby5xcS5jb20vdHJwYy52ZWN0b3JfbGF5b3V0LnBhZ2Vfdmlldy5QYWdlU2VydmljZS9nZXRDYXJkP3ZpZGVvX2FwcGlkPTMwMDAwMTBcIjtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgc2NmZXRjaERhdGEgPSBKU09OLnBhcnNlKGZldGNoUEMocFVybCwge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcIkNvbnRlbnQtVHlwZVwiOiBcImFwcGxpY2F0aW9uL2pzb25cIixcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwicmVmZXJlclwiOiBcImh0dHBzOi8vdi5xcS5jb20vXCIsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcIkNvb2tpZVwiOiBcInZpZGVvX3BsYXRmb3JtPTJcIlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtZXRob2Q6IFwiUE9TVFwiLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBib2R5OiB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcInBhZ2VfY29udGV4dFwiOiBudWxsLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXCJwYWdlX3BhcmFtc1wiOiBkYXRhX2tleV9PYmosXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcImZsaXBfaW5mb1wiOiBKU09OLnBhcnNlKGdldE15VmFyKFwiZmxpcF9pbmZvXCIpIHx8IHt9KVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSkpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzY2FyZHMgPSBzY2ZldGNoRGF0YS5kYXRhLmNhcmQuY2hpbGRyZW5fbGlzdC5saXN0LmNhcmRzO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBwb3N0ZXJMaXN0cyA9IHB1c2hEYXRhKHNjYXJkcy5zbGljZSg3KSwgc2Vjb25kc1RvVGltZSwgXCJwb3N0ZXJMaXN0c1wiKTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwb3N0ZXJMaXN0cykge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvL2xvZyhwb3N0ZXJMaXN0cylcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHNjdGl0bGVBcnIgPSBKU09OLnBhcnNlKGdldE15VmFyKFwic2N0aXRsZUFyclwiKSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVwZGF0ZUl0ZW0oXCJ3ZWVrX2lkX1wiICsgZ2V0TXlWYXIoXCJzY3RpdGxlTnVtXCIsIFwiMFwiKSwge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IHNjdGl0bGVBcnJbcGFyc2VJbnQoZ2V0TXlWYXIoXCJzY3RpdGxlTnVtXCIsIFwiMFwiKSldXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVwZGF0ZUl0ZW0oXCJ3ZWVrX2lkX1wiICsgaW5kZXgsIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiAn4oCc4oCc4oCd4oCdPGI+PGZvbnQgY29sb3I9I0ZBNzI5OD4nICsgdGl0bGUgKyAnPC9mb250PjwvYj4nXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHB1dE15VmFyKFwic2N0aXRsZU51bVwiLCBpbmRleCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZUl0ZW1CeUNscygncG9zdGVyTGlzdHMnKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYWRkSXRlbUFmdGVyKCd3ZWVrX2lkXzYnLCBwb3N0ZXJMaXN0cyk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcImhpa2VyOi8vZW1wdHlcIlxuICAgICAgICAgICAgICAgICAgICAgICAgfSwgdGl0bGUsIGRhdGFfa2V5LCBpbmRleCwgcHVzaERhdGEsIHNlY29uZHNUb1RpbWUpLFxuICAgICAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6IFwiZmxleF9idXR0b25cIixcbiAgICAgICAgICAgICAgICAgICAgICAgIGV4dHJhOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWQ6IFwid2Vla19pZF9cIiArIGluZGV4XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pXG4gICAgICAgICAgICBBcnJheS5wcm90b3R5cGUucHVzaC5hcHBseShkLCBwdXNoRGF0YShjX3Bf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gICAgICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IHRpdGxlLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiAkKG9wX3ZhbHVlICsgJyNub0xvYWRpbmcjJykubGF6eVJ1bGUoKHBhcmFtcykgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBuZXdfY2F0ZSA9IFtdXFxuICAgICAgICAgICAgICAgICAgICAgICAgcGFyYW1zLmNhdGVfdGVtcC5mb3JFYWNoKChjYXRlLCBpbmRleCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXdfY2F0ZS5wdXNoKGluZGV4ID09PSAwID8gcGFyYW1zLmtleS50b1N0cmluZygpIDogXFxcIjBcXFwiKVxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcblxcbiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgcGFyYW1zLlNmaWx0ZXJfa2V5Lmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsZWFyTXlWYXIocGFyYW1zLlNmaWx0ZXJfa2V5W2ldKVxcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgICAgICBwdXRNeVZhcignaGVhZGVyLmNhdGVnb3J5JywgSlNPTi5zdHJpbmdpZnkobmV3X2NhdGUpKVxcbiAgICAgICAgICAgICAgICAgICAgICAgIHB1dE15VmFyKHBhcmFtcy5jbGFzc19rZXksIGlucHV0KVxcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vbG9nKGlucHV0KVxcbiAgICAgICAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKHRydWUpXFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIlxcbiAgICAgICAgICAgICAgICAgICAgfSwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNhdGVfdGVtcDogY2F0ZV90ZW1wLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGtleToga2V5LFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGNsYXNzX2tleTogY2xhc3Nfa2V5LFxcbiAgICAgICAgICAgICAgICAgICAgICAgIFNmaWx0ZXJfa2V5OiBTZmlsdGVyX2tleSxcXG4gICAgICAgICAgICAgICAgICAgICAgICBwYWdlOiBwYWdlLFxcbiAgICAgICAgICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgICAgICAgICBjb2xfdHlwZTogJ3Njcm9sbF9idXR0b24nLFxcbiAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIH0pXFxuXFxuICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJibGFua19ibG9ja1xcXCJcXG4gICAgICAgICAgICB9KTtcXG5cXG4gICAgICAgIH0gZWxzZSBpZiAoZm9sZCA9PT0gJzEnKSB7XFxuICAgICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAgICAgc3ViX2NhdGVnb3JpZXMuZm9yRWFjaCgoaXRlbSwga2V5KSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgdGl0bGUgPSBpdGVtLnBhcmFtcy5vcHRpb25fbmFtZTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBvcF92YWx1ZSA9IGl0ZW0ucGFyYW1zLm9wdGlvbl92YWx1ZTtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChnZXRNeVZhcihjbGFzc19rZXkpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGUgPSBnZXRNeVZhcihjbGFzc19rZXkpID09IG9wX3ZhbHVlID8gJ+KAnOKAnOKAneKAnTxiPjxzcGFuIHN0eWxlPVxcXCJjb2xvcjogJyArIOWIhuexu+minOiJsiArICdcXFwiPicgKyB0aXRsZSArICc8L3NwYW4+PC9iPicgOiB0aXRsZTtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGUgPSBrZXkudG9TdHJpbmcoKSA9PT0gY2F0ZV90ZW1wW2luZGV4XSA/ICfigJzigJzigJ3igJ08Yj48c3BhbiBzdHlsZT1cXFwiY29sb3I6ICcgKyDliIbnsbvpopzoibIgKyAnXFxcIj4nICsgdGl0bGUgKyAnPC9zcGFuPjwvYj4nIDogdGl0bGU7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiB0aXRsZSxcXG4gICAgICAgICAgICAgICAgICAgICAgICB1cmw6ICQob3BfdmFsdWUgKyAnI25vTG9hZGluZyMnKS5sYXp5UnVsZSgocGFyYW1zKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhcmFtcy5jYXRlX3RlbXBbcGFyYW1zLmluZGV4XSA9IHBhcmFtcy5rZXkudG9TdHJpbmcoKVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwdXRNeVZhcignaGVhZGVyLmNhdGVnb3J5JywgSlNPTi5zdHJpbmdpZnkocGFyYW1zLmNhdGVfdGVtcCkpXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHB1dE15VmFyKHBhcmFtcy5jbGFzc19rZXksIGlucHV0KVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSh0cnVlKVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiXFxuICAgICAgICAgICAgICAgICAgICAgICAgfSwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXRlX3RlbXA6IGNhdGVfdGVtcCxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaW5kZXg6IGluZGV4LFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBrZXk6IGtleSxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xhc3Nfa2V5OiBjbGFzc19rZXksXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2U6IHBhZ2UsXFxuICAgICAgICAgICAgICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6ICdzY3JvbGxfYnV0dG9uJyxcXG4gICAgICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgICAgICBsb2coc3ViX2NhdGVnb3JpZXMpXFxuICAgICAgICAgICAgICAgIGxvZyhlLnRvU3RyaW5nKCkpXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwiYmxhbmtfYmxvY2tcXFwiXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9XFxuXFxuICAgIH0pXFxufVwifSx7XCJjb2xfdHlwZVwiOlwibW92aWVfM1wiLFwibmFtZVwiOlwi54mH5bqTXCIsXCJwYXRoXCI6XCJjaGFubmVsX2xpc3RfZmlsdGVyXCIsXCJydWxlXCI6XCJqczpcXG5hZGRMaXN0ZW5lcignb25DbG9zZScsICgpID0+IHtcXG4gICAgdmFyIFNmaWx0ZXJfa2V5ID0gSlNPTi5wYXJzZShnZXRNeVZhcihcXFwiU2ZpbHRlcl9rZXlcXFwiKSk7XFxuICAgIGZvciAobGV0IGkgPSAwOyBpIDwgU2ZpbHRlcl9rZXkubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgIGNsZWFyTXlWYXIoU2ZpbHRlcl9rZXlbaV0pXFxuICAgIH1cXG4gICAgY2xlYXJNeVZhcihcXFwiU2ZpbHRlcl9rZXlcXFwiKTtcXG59KVxcbnZhciBkID0gW107XFxuY29uc3QgcGFnZSA9IE1ZX1BBR0U7XFxubGV0IGJhc2VVcm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ICAgICBpZiAoaXRlbS50eXBlID09IFxcXCJjaGFubmVsX2xpc3RfZmlsdGVyXFxcIikge1xcbiAgICAgICAgICAgIGZ1bmN0aW9uIGdyb3VwQnkoYXJyLCBwcm9wKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBhcnIucmVkdWNlKGZ1bmN0aW9uKGdyb3VwcywgaXRlbSkge1xcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgdmFsID0gaXRlbS5wYXJhbXNbcHJvcF1cXG4gICAgICAgICAgICAgICAgICAgIGdyb3Vwc1t2YWxdID0gZ3JvdXBzW3ZhbF0gfHwgW11cXG4gICAgICAgICAgICAgICAgICAgIGdyb3Vwc1t2YWxdLnB1c2goaXRlbSlcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBncm91cHNcXG4gICAgICAgICAgICAgICAgfSwge30pXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHZhciBmaXRlck9iaiA9IGdyb3VwQnkoaXRlbS5jaGlsZHJlbl9saXN0Lmxpc3QuY2FyZHMsIFxcXCJmaWx0ZXJfa2V5XFxcIik7XFxuICAgICAgICAgICAgLy9sb2coZ2JvYmopXFxuICAgICAgICAgICAgdmFyIFNDYXRlcyA9IFtdO1xcbiAgICAgICAgICAgIHZhciBTZmlsdGVyX2tleSA9IFtdO1xcbiAgICAgICAgICAgIGZvciAobGV0IGkgaW4gZml0ZXJPYmopIHtcXG4gICAgICAgICAgICAgICAgU0NhdGVzLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgXFxcImZpbHRlcl9rZXlcXFwiOiBpLFxcbiAgICAgICAgICAgICAgICAgICAgXFxcIml0ZW1zXFxcIjogZml0ZXJPYmpbaV1cXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIFNmaWx0ZXJfa2V5LnB1c2goaSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHB1dE15VmFyKFxcXCJTZmlsdGVyX2tleVxcXCIsIEpTT04u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pYy5zdWJzdHJpbmcoMCwgaW5kZXgpO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgbGV0IGRlcyA9IFxcXCJcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKGl0ZW0ucGFyYW1zLmltZ3RhZykgeyAgXFxuICAgICAgICAgICAgICAgICAgICAgICAgaWYodHlwZW9mKGl0ZW0ucGFyYW1zLmltZ3RhZykgPT09IFxcXCJvYmplY3RcXFwiKXsgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcXG4gICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGltZ3RhZyA9IEpTT04ucGFyc2UoaXRlbS5wYXJhbXMuaW1ndGFnKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgLy9sb2coaW1ndGFnKSAgICAgICAgICAgICAgICAgICAgIFxcbiAgICAgICAgICAgICAgICAgICAgICAgICBkZXMgPSBpbWd0YWcudGFnXzMudGV4dCA/IGltZ3RhZy50YWdfMy50ZXh0IDogaW1ndGFnLnRhZ18yLnRleHQuc3BsaXQoXFxcIi1cXFwiKVswXVxcbiAgICAgICAgICAgICAgICAgICAgICAgICB9ZWxzZXtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlcyA9IGl0ZW0ucGFyYW1zLmltZ3RhZztcXG4gICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgIGRlcyA9IGl0ZW0ucGFyYW1zLnRpbWVsb25nIHx8IGl0ZW0ucGFyYW1zLnB1Ymxpc2hfZGF0ZSB8fCBpdGVtLnBhcmFtcy5lcGlzb2RlX3VwZGF0ZWQgfHwgKGl0ZW0ucGFyYW1zLmR1cmF0aW9uID8gc2Vjb25kc1RvVGltZShpdGVtLnBhcmFtcy5kdXJhdGlvbikgOiBcXFwiXFxcIikgfHwgKGl0ZW0ucGFyYW1zLmNtc19pc3ZpcCA9PSAxID8gXFxcIlZJUFxcXCIgOiBcXFwiXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgbGV0IHBhcmFtX2NpZCA9IFxcXCJcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKGl0ZW0ucGFyYW1zLmNpZCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHBhcmFtX2NpZCA9IGl0ZW0ucGFyYW1zLmNpZDtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaXRlbS5wYXJhbXMuYXR0YWNoZWRfaWQpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBwYXJhbV9jaWQgPSBpdGVtLnBhcmFtcy5hdHRhY2hlZF9pZDtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIC8vbG9nKGl0ZW0pXFxuICAgICAgICAgICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBpdGVtLnBhcmFtcy50aXRsZSxcXG4gICAgICAgICAgICAgICAgICAgICAgICBkZXNjOiBkZXMsXFxuICAgICAgICAgICAgICAgICAgICAgICAgcGljX3VybDogcGljLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHVybDogXFxcImhpa2VyOi8vcGFnZS9lal9wYWdlXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5I1xcXCIgKyBwYXJhbV9jaWQgKyBcXFwiI1xcXCIgKyAoaXRlbS5wYXJhbXMudmlkID8gaXRlbS5wYXJhbXMudmlkIDogXFxcIlxcXCIpICsgXFxcIiNpbW1lcnNpdmVUaGVtZSNcXFwiXFxuICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgfSlcXG4gICA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H566A5LuLIDxzbWFsbD48c21hbGw+PHNwYW4gc3R5bGU9XFxcImNvbG9yOiMxOUI4OURcXFwiPuWxleW8gD48L3NwYW4+PC9zbWFsbD48L3NtYWxsPicsXFxuICAgICAgICAgICAgaW1nOiBcXFwiaHR0cHM6Ly9oaWtlcmZhbnMuY29tL3R1Ymlhby9tb3JlLzE5Ny5wbmdcXFwiLFxcbiAgICAgICAgICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgoY29udGVudF9kZXNjKSA9PiB7XFxuICAgICAgICAgICAgICAgIGlmIChnZXRNeVZhcihcXFwiampfc3RhdGVcXFwiLCBcXFwi5pS26LW3XFxcIikgPT0gXFxcIuaUtui1t1xcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgIHVwZGF0ZUl0ZW0oXFxcImNvbnRlbnRfamppZFxcXCIsIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogJ+W9seeJh+eugOS7iyA8c21hbGw+PHNtYWxsPjxzcGFuIHN0eWxlPVxcXCJjb2xvcjojMTlCODlEXFxcIj7mlLbotbc+PC9zcGFuPjwvc21hbGw+PC9zbWFsbD4nXFxuICAgICAgICAgICAgICAgICAgICB9KVxcblxcbiAgICAgICAgICAgICAgICAgICAgdXBkYXRlSXRlbShcXFwiY29udGVudF9kZWNpZFxcXCIsIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogJzxzcGFuIHN0eWxlPVxcXCJjb2xvcjojODA4MDgwXFxcIj4nICsgY29udGVudF9kZXNjICsgJzwvc3Bhbj4nXFxuICAgICAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgICAgICAgcHV0TXlWYXIoXFxcImpqX3N0YXRlXFxcIiwgXFxcIuWxleW8gFxcXCIpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgdXBkYXRlSXRlbShcXFwiY29udGVudF9qamlkXFxcIiwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiAn5b2x54mH566A5LuLIDxzbWFsbD48c21hbGw+PHNwYW4gc3R5bGU9XFxcImNvbG9yOiMxOUI4OURcXFwiPuWxleW8gD48L3NwYW4+PC9zbWFsbD48L3NtYWxsPidcXG4gICAgICAgICAgICAgICAgICAgIH0pXFxuXFxuICAgICAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKFxcXCJjb250ZW50X2RlY2lkXFxcIiwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiAnPHNwYW4gc3R5bGU9XFxcImNvbG9yOiM4MDgwODBcXFwiPicgKyBjb250ZW50X2Rlc2Muc3Vic3RyKDAsIDUwKSArICcuLi48L3NwYW4+J1xcbiAgICAgICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgICAgIHB1dE15VmFyKFxcXCJqal9zdGF0ZVxcXCIsIFxcXCLmlLbotbdcXFwiKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiXFxuICAgICAgICAgICAgfSwgY29udGVudF9kZXNjKSxcXG4gICAgICAgICAgICBjb2xfdHlwZTogXFxcImF2YXRhclxcXCIsXFxuICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgaWQ6IFxcXCJjb250ZW50X2pqaWRcXFwiXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSk7XFxuICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgIHRpdGxlOiAnPHNwYW4gc3R5bGU9XFxcImNvbG9yOiM4MDgwODBcXFwiPicgKyBjb250ZW50X2Rlc2Muc3Vic3RyKDAsIDUwKSArICcuLi48L3NwYW4+JyxcXG4gICAgICAgICAgICBjb2xfdHlwZTogXFxcInJpY2hfdGV4dFxcXCIsXFxuICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgdGV4dFNpemU6IDE0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G4gICAgICAgICAgICAgICAgICAgICAgICBwaWNfdXJsOiBwaWMsXFxuICAgICAgICAgICAgICAgICAgICAgICAgZGVzYzogc2Vjb25kc1RvVGltZShpdGVtLml0ZW1fcGFyYW1zLmR1cmF0aW9uKSxcXG4gICAgICAgICAgICAgICAgICAgICAgICB1cmw6IFxcXCJodHRwczovL3YucXEuY29tL3gvY292ZXIvXFxcIiArIChpdGVtLml0ZW1fcGFyYW1zLmNpZCA/IChpdGVtLml0ZW1fcGFyYW1zLmNpZCArIFxcXCIvXFxcIikgOiBcXFwiXFxcIikgKyBpdGVtLml0ZW1fcGFyYW1zLnZpZCArIFxcXCIuaHRtbFxcXCIgKyBsYXp5LFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwibW92aWVfMlxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWQ6IGl0ZW0uaXRlbV9wYXJhbXMuY2lkICsgXFxcIi9cXFwiICsgaXRlbS5pdGVtX3BhcmFtcy52aWQsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsczogJ3BsYXlMaXN0J1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICAgICAgICAgIGxvZyhlLnRvU3RyaW5nKCkpXFxuICAgICAgICAgICAgICAgICAgICBsb2coaXRlbSlcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcGljID0gaXRlbS5pdGVtX3BhcmFtcy5pbWFnZV91cmwgPyBpdGVtLml0ZW1fcGFyYW1zLmltYWdlX3VybCA6IGl0ZW0uaXRlbV9wYXJhbXMucGljX25ldztcXG4gICAgICAgICAgICAgICAgICAgIGxldCBpbmRleCA9IHBpYy5sYXN0SW5kZXhPZihcXFwiXFxcXC9cXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIHBpYyA9IHBpYy5zdWJzdHJpbmcoMCwgaW5kZXgpO1xcbiAgICAgICAgICAgICAgICAgICAgcHJlX2xpc3RzLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBpdGVtLml0ZW1fcGFyYW1zLnVuaW9uX3RpdGxlLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHBpY191cmw6IHBpYyxcXG4gICAgICAgICAgICAgICAgICAgICAgICBkZXNjOiBzZWNvbmRzVG9UaW1lKGl0ZW0uaXRlbV9wYXJhbXMuZHVyYXRpb24pLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHVybDogXFxcImh0dHBzOi8vdi5xcS5jb20veC9jb3Zlci9cXFwiICsgKGl0ZW0uaXRlbV9wYXJhbXMuY2lkID8gKGl0ZW0uaXRlbV9wYXJhbXMuY2lkICsgXFxcIi9cXFwiKSA6IFxcXCJcXFwiKSArIGl0ZW0uaXRlbV9wYXJhbXMudmlkICsgXFxcIi5odG1sXFxcIiArIGxhenksXFxuICAgICAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJtb3ZpZV8yXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZDogaXRlbS5pdGVtX3BhcmFtcy5jaWQgKyBcXFwiL1xcXCIgKyBpdGVtLml0ZW1fcGFyYW1zLnZpZCxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xzOiAncGxheUxpc3QnXFxuICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgICAgICAgICAgbG9nKGUudG9TdHJpbmcoKSlcXG4gICAgICAgICAgICAgICAgICAgIGxvZyhpdGVtKVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSlcXG4gICAgICAgIC8qXFxuICAgICAgICBwcmVfbGlzdHMuZmlsdGVyKGl0ID0+IHtcXG4gICAgICAgICAgICBcXG4gICAgICAgIH0pKi9cXG4gICAgICAgIHJldHVyblxcbiAgICAgICAgLy9yZXR1cm4gZXBpc29kZV9saXN0cy5jb25jYXQocHJlX2xpc3RzKVxcbiAgICB9O1xcbiAgICBwdXNoX0xpc3RzKGxpc3RfSnNvbilcXG4gICAgLy9wbGF5X0xpc3RzLnB1c2gocHVzaF9MaXN0cyhsaXN0X0pzb24pKVxcbiAgICAvL2xvZyhoYXNfbmV4dClcXG4gICAgLy9sb2codHlwZW9mKGhhc19uZXh0KSlcXG4gICAgLy9sb2cobmV4dF9wYWdlX2NvbnRleHQpXFxuICAgIHdoaWxlIChoYXNfbmV4dCA9PT0gXFxcInRydWVcXFwiKSB7XFxuICAgICAgICBib2R5LnBhZ2VfcGFyYW1zLnBhZ2VfY29udGV4dCA9IG5leHRfcGFnZV9jb250ZXh0O1xcbiAgICAgICAgcGxheWxpc3RzX2ZldGNoRGF0YSA9IEpTT04ucGFyc2UoZmV0Y2hQQyhlalVybCwge1xcbiAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgXFxcIkNvbnRlbnQtVHlwZVxcXCI6IFxcXCJhcHBsaWNhdGlvbi9qc29uXFxcIixcXG4gICAgICAgICAgICAgICAgXFxcInJlZmVyZXJcXFwiOiBcXFwiaHR0cHM6Ly92LnFxLmNvbS9cXFwiLFxcbiAgICAgICAgICAgICAgICBcXFwiQ29va2llXFxcIjogXFxcInZpZGVvX3BsYXRmb3JtPTI7dnZlcnNpb25fbmFtZT04LjIuOTVcXFwiXFxuICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICBtZXRob2Q6IFxcXCJQT1NUXFxcIixcXG4gICAgICAgICA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+86Ie06aG15pWw5pWw57uE6LaK55WMXFxyXFxuICAgICAgICBub3dQYWdlID0g5pyA5aSn6aG15pWwO1xcclxcbiAgICAgICAgcHV0TXlWYXIoJ+mAiembhue/u+mhtScsICcnICsgbm93UGFnZSk7XFxyXFxuICAgIH1cXHJcXG4gICAgLy9sb2coXFxcIuW9k+WJjemhteaVsDpcXFwiK2dldE15VmFyKCfpgInpm4bnv7vpobUnLCAnMScpKVxcclxcbiAgICBsZXQgc2hvd0xpc3QsIHNob3dMaXN0X2NudDtcXHJcXG4gICAgaWYgKGxpc3RfY250ID4g57+76aG16ZiA5YC8ICYmIGdldE15VmFyKCfpgInpm4bmmL7npLonLCAn5YiG6aG1JykgPT09ICfliIbpobUnKSB7XFxyXFxuICAgICAgICBsZXQgbWF4TnVtID0g5q+P6aG15pWw6YePICogbm93UGFnZTsgLy/nrKzkuIDpobXnmoTor50s5pyA5aSn5pi+56S6NDAqMembhiznrKwy6aG1NDEtODDpm4YgICAgICAgXFxyXFxuICAgICAgICBzaG93TGlzdCA9IHRhYl9MaXN0cy5zbGljZSgoKG5vd1BhZ2UgLSAxKSAqIOavj+mhteaVsOmHjyksIG1heE51bSk7XFxyXFxuICAgICAgICBzaG93TGlzdF9jbnQgPSBzaG93TGlzdC5sZW5ndGhcXHJcXG4gICAgfSBlbHNlIHtcXHJcXG4gICAgICAgIHNob3dMaXN0X2NudCA9IHRhYl9MaXN0cy5sZW5ndGg7XFxyXFxuICAgIH1cXHJcXG5cXHJcXG4gICAgLy9sb2coXFxcInNob3dMaXN0X2NudDpcXFwiK3Nob3dMaXN0X2NudClcXHJcXG4gICAgcHV0TXlWYXIoXFxcInNob3dMaXN0X2NudFxcXCIsIHNob3dMaXN0X2NudCk7XFxyXFxuICAgIHB1dE15VmFyKFxcXCJsaXN0X2NudFxcXCIsIGxpc3RfY250KTtcXHJcXG4gICAgLy/nur/ot69cXHJcXG4gICAgdmFyIGZ1bmNUYWIgPSBmdW5jdGlvbih0YWJzLCB0YWJfdHlwZSkge1xcclxcbiAgICAgICAgLy90YWJz5Li657q/6Lev5pWw57uE77yM6ZyA6KaB5aSE55CG5aW95ZCO5Lyg5YWlLCBlZzogW1xcXCLnur/ot68xXFxcIl1cXG4gICAgICAgIGlmKCF0YWJfdHlwZSl7XFxuICAgICAgICAgICAgdGFiX3R5cGUgPSB0YWJzLmxlbmd0aCA+IDMgPyBcXFwic2Nyb2xsX2J1dHRvblxcXCIgOiBcXFwiZmxleF9idXR0b25cXFwiO1xcbiAgICAgICAgfVxcclxcbiAgICAgICAgbGV0IGQgPSBbXTtcXHJcXG4gICAgICAgIHRhYnMuZm9yRWFjaCgoVGFibmFtZSwgaSkgPT4ge1xcclxcbiAgICAgICAgICAgIGQucHVzaCh7XFxyXFxuICAgICAgICAgICAgICAgIHRpdGxlOiBnZXRNeVZhcihcXFwidGFibnVtXFxcIiwgXFxcIjBcXFwiKSA9PSBpID8gZ2V0SGVhZChUYWJuYW1lKSA6IFRhYm5hbWUsXFxyXFxuICAgICAgICAgICAgICAgIHVybDogJChcXFwiI25vTG9hZGluZyMjbm9IaXN0b3J5I1xcXCIpLmxhenlSdWxlKCh0YWJzLCBnZXRIZWFkLCBpLCBmdW5jTG9hZHBhZ2UpID0+IHtcXHJcXG4gICAgICAgICAgICAgICAgICAgIGlmIChnZXRNeVZhcihcXFwidGFibnVtXFxcIiwgXFxcIjBcXFwiKSAhPSBpKSB7XFxyXFxuICAgICAgICAgICAgICAgICAgICAgICAgdXBkYXRlSXRlbShcXFwidGFiaWRcXFwiICsgZ2V0TXlWYXIoXFxcInRhYm51bVxcXCIsIFxcXCIwXFxcIiksIHtcXHJcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IHRhYnNbcGFyc2VJbnQoZ2V0TXlWYXIoXFxcInRhYm51bVxcXCIsIFxcXCIwXFxcIikpXSxcXHJcXG4gICAgICAgICAgICAgICAgICAgICAgICB9KTtcXHJcXG4gICAgICAgICAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKFxcXCJ0YWJpZFxcXCIgKyBpLCB7XFxyXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBnZXRIZWFkKHRhYnNbaV0pLFxcclxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcclxcbiAgICAgICAgICAgICAgICAgICAgICAgIHB1dE15VmFyKFxcXCJ0YWJudW1cXFwiLCBpKTtcXHJcXG5cXHJcXG4gICAgICAgICAgICAgICAgICAgICAgICAvL2xvZyhcXFwi54K55Ye7OlxcXCIrZ2V0TXlWYXIoXFxcInRhYm51bVxcXCIpKTsgICAgXFxyXFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGQgPSBbXVxcclxcbiAgICAgICAgICAgICAgICAgICAgICAgIGZ1bmNMb2FkcGFnZShkKVxcclxcbiAgICAgICAgICAgICAgICAgICAgfVxcclxcbiAgICAgICAgICAgICAgICAgICAgLy9yZXR1cm4gJ3RvYXN0Oi8v5YiH5o2i5oiQ5YqfISdcXHJcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxyXFxuICAgICAgICAgICAgICAgIH0sIHRhYnMsIGdldEhlYWQsIGksIGZ1bmNMb2FkcGFnZSksXFxyXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiB0YWJfdHlwZSxcXHJcXG4gICAgICAgICAgICAgICAgZXh0cmE6IHtcXHJcXG4gICAgICAgICAgICAgICAgICAgIGlkOiBcXFwidGFiaWRcXFwiICsgaVxcclxcbiAgICAgICAgICAgICAgICB9LFxcclxcbiAgICAgICAgICAgIH0pO1xcclxcbiAgICAgICAgfSk7XFxyXFxuICAgICAgICBkLnB1c2goe1xcclxcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwibGluZVxcXCIsXFxyXFxuICAgICAgICAgICAgZXh0cmE6IHtcXHJcXG4gICAgICAgICAgICAgICAgaWQ6ICd0YWJfU2VwcycgLy8g57uZ57+76aG157uE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cbiAgICAgICAgc2h1dFRpdGxlID0gc21hbGwoc2h1dFRpdGxlKS5yZXBsYWNlKC/igJzigJzigJ3igJ0vZywgJycpO1xcclxcbiAgICAgICAgc2h1dFRpdGxlID0gc2h1dFRpdGxlLnJlcGxhY2UoL+KAnOKAnOKAneKAnS9nLCAnJyk7XFxyXFxuICAgICAgICBsZXQgc2hvd1BpYyA9ICdodHRwczovL2hpa2VyZmFucy5jb20vdHViaWFvL21lc3N5LzU1LnN2Zyc7XFxyXFxuICAgICAgICBsZXQgc2h1dFBpYyA9ICdodHRwczovL2hpa2VyZmFucy5jb20vdHViaWFvL21lc3N5LzYzLnN2Zyc7XFxyXFxuICAgICAgICBsZXQgcGFnZVRpdGxlID0gJyc7XFxyXFxuICAgICAgICBsZXQgcGFnZVBpYyA9ICcnO1xcclxcbiAgICAgICAgaWYgKGdldE15VmFyKCfpgInpm4bmmL7npLonLCAn5YiG6aG1JykgPT09ICfliIbpobUnKSB7XFxyXFxuICAgICAgICAgICAgcGFnZVRpdGxlID0gc2hvd1RpdGxlO1xcclxcbiAgICAgICAgICAgIHBhZ2VQaWMgPSBzaG93UGljO1xcclxcbiAgICAgICAgfSBlbHNlIHtcXHJcXG4gICAgICAgICAgICBwYWdlVGl0bGUgPSBzaHV0VGl0bGU7XFxyXFxuICAgICAgICAgICAgcGFnZVBpYyA9IHNodXRQaWM7XFxyXFxuICAgICAgICB9XFxyXFxuICAgICAgICBsZXQgZCA9IFtdO1xcclxcbiAgICAgICAgZC5wdXNoKHtcXHJcXG4gICAgICAgICAgICB0aXRsZTogcGFnZVRpdGxlLFxcclxcbiAgICAgICAgICAgIGNvbF90eXBlOiBzaG93Q29sLFxcclxcbiAgICAgICAgICAgIHBpY191cmw6IHBhZ2VQaWMsXFxyXFxuICAgICAgICAgICAgdXJsOiAkKCfnoa7orqTliIfmjaLliIbpobXmmL7npLrnirbmgIE/JykuY29uZmlybSgoc2hvd1RpdGxlLCBzaG93UGljLCBzaHV0VGl0bGUsIHNodXRQaWMsIGZ1bmNMb2FkcGFnZSkgPT4ge1xcclxcbiAgICAgICAgICAgICAgICBsZXQgbmV4dE1vZGUgPSBnZXRNeVZhcign6YCJ6ZuG5pi+56S6JywgJ+WIhumhtScpID09PSAn5YiG6aG1JyA/ICflhajpg6gnIDogJ+WIhumhtSc7XFxyXFxuICAgICAgICAgICAgICAgIGxldCBwYWdlVGl0bGUsIHBhZ2VQaWM7XFxyXFxuICAgICAgICAgICAgICAgIGlmIChuZXh0TW9kZSA9PT0gJ+WIhumhtScpIHtcXHJcXG4gICAgICAgICAgICAgICAgICAgIHBhZ2VUaXRsZSA9IHNob3dUaXRsZTtcXHJcXG4gICAgICAgICAgICAgICAgICAgIHBhZ2VQaWMgPSBzaG93UGljO1xcclxcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcclxcbiAgICAgICAgICAgICAgICAgICAgcGFnZVRpdGxlID0gc2h1dFRpdGxlO1xcclxcbiAgICAgICAgICAgICAgICAgICAgcGFnZVBpYyA9IHNodXRQaWM7XFxyXFxuICAgICAgICAgICAgICAgIH1cXHJcXG4gICAgICAgICAgICAgICAgdXBkYXRlSXRlbSgncGFnZVN0YXRlJywge1xcclxcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IHBhZ2VUaXRsZSxcXHJcXG4gICAgICAgICAgICAgICAgICAgIHBpY191cmw6IHBhZ2VQaWNcXHJcXG4gICAgICAgICAgICAgICAgfSk7XFxyXFxuICAgICAgICAgICAgICAgIHB1dE15VmFyKCfpgInpm4bmmL7npLonLCBuZXh0TW9kZSk7XFxyXFxuICAgICAgICAgICAgICAgIGxldCBkID0gW107XFxyXFxuICAgICAgICAgICAgICAgIGZ1bmNMb2FkcGFnZShkKTtcXHJcXG4gICAgICAgICAgICAgICAgcmV0dXJuICdoaWtlcjovL2VtcHR5J1xcclxcbiAgICAgICAgICAgIH0sIHNob3dUaXRsZSwgc2hvd1BpYywgc2h1dFRpdGxlLCBzaHV0UGljLCBmdW5jTG9hZHBhZ2UpLFxcclxcbiAgICAgICAgICAgIGV4dHJhOiB7XFxyXFxuICAgICAgICAgICAgICAgIGlkOiAncGFnZVN0YXRlJyxcXHJcXG4gICAgICAgICAgICAgICAgY2xzOiAnc3RhdGVfY2xzJ1xcclxcbiAgICAgICAgICAgIH1cXHJcXG4gICAgICAgIH0pO1xcclxcbiAgICAgICAgZC5wdXNoKHtcXHJcXG4gICAgICAgICAgICBjb2xfdHlwZTogXFxcImxpbmVcXFwiLFxcclxcbiAgICAgICAgICAgIGV4dHJhOiB7XFxyXFxuICAgICAgICAgICAgICAgIGlkOiAnc3RhdGVfU3BlcycsIC8vIOe7hOS7tuWBmmlk55SoXFxyXFxuICAgICAgICAgICAgICAgIGNsczogJ3N0YXRlX2NscydcXHJcXG4gICAgICAgICAgICB9XFxyXFxuICAgICAgICB9KTtcXHJcXG4gICAgICAgIHJldHVybiBkXFxyXFxuICAgIH07XFxyXFxuICAgIC8v6aG65bqPXFxyXFxuICAgIHZhciBmdW5jT3JkZXIgPSBmdW5jdGlvbiAodGFicykge1xcclxcbiAgICAgICAgdGFicyA9IHRhYnMgfHwgWycnXTtcXHJcXG4gICAgICAgIGxldCBvcmRlcl90eXBlID0gXFxcInRleHRfaWNvblxcXCI7XFxyXFxuICAgICAgICBsZXQgdXBfaWNvbiA9IFxcXCJodHRwczovL2hpa2VyZmFucy5jb20vdHViaWFvL21lc3N5LzE0Ny5zdmdcXFwiO1xcbiAgICAgICAgbGV0IGRvd25faWNvbiA9IFxcXCJodHRwczovL2hpa2VyZmFucy5jb20vdHViaWFvL21lc3N5LzE1MS5zdmdcXFwiOyAgICAgICAgXFxyXFxuICAgICAgICBsZXQgdGl0bGUgPSBjb2xvcihcXFwiJG5vd190YWI6IOmAiembhuWIl+ihqOWFsSBcXFwiLCBcXFwiIzA5OEFDMVxcXCIpICsgY29sb3IoZ2V0TXlWYXIoXFxcImxpc3RfY250XFxcIiksIFxcXCIjZDk2NzE1XFxcIikgKyBjb2xvcihcXFwiIOmbhlxcXCIsIFxcXCIjMDk4QUMxXFxcIik7XFxyXFxuICAgICAgICBsZXQgdGl0bGUyID0gdGl0bGUucmVwbGFjZSgnJG5vd190YWInLCB0YWJzW2dldE15VmFyKFxcXCJ0YWJudW1cXFwiLCBcXFwiMFxcXCIpXSk7XFxyXFxuICAgICAgICBsZXQgZCA9IFtdO1xcclxcbiAgICAgICAgZC5wdXNoKHtcXHJcXG4gICAgICAgICAgICB0aXRsZTogdGl0bGUyLnJlcGxhY2UoL+KAnOKAnOKAneKAnS9nLCBcXFwiXFxcIiksICAgICBcXG4gICAgICAgICAgICBwaWNfdXJsOiBnZXRNeVZhcihcXFwi6aG65bqPXFxcIiwgXFxcIuato+W6j1xcXCIpID09PSBcXFwi6YCG5bqPXFxcIiA/IHVwX2ljb24gOiBkb3duX2ljb24sICAgICBcXHJcXG4gICAgICAgICAgICBjb2xfdHlwZTogb3JkZXJfdHlwZSxcXHJcXG4gICAgICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKHVwX2ljb24sIGRvd25faWNvbiwgZnVuY0xvYWRwYWdlKSA9PiB7XFxyXFxuXFxyXFxuICAgICAgICAgICAgICAgIGlmIChnZXRNeVZhcign6aG65bqPJywgJ+ato+W6jycpID09PSAn6YCG5bqPJykge1xcclxcbiAgICAgICAgICAgICAgICAgICAgcHV0TXlWYXIoJ+mhuuW6jycsICfmraPluo8nKTtcXHJcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXHJcXG4gICAgICAgICAgICAgICAgICAgIHB1dE15VmFyKCfpobrluo8nLCAn6YCG5bqPJyk7XFxyXFxuICAgICAgICAgICAgICAgIH1cXHJcXG4gICAgICAgICAgICAgICAgbGV0IG9yZGVyTm93ID0gZ2V0TXlWYXIoJ+mhuuW6jycsICfmraPluo8nKTsgICAgICAgICAgICAgICAgXFxyXFxuICAgICAgICAgICAgICAgIHVwZGF0ZUl0ZW0oJ29yZGVyaWQnLCB7XFxyXFxuICAgICAgICAgICAgICAgICAgICBwaWNfdXJsOiBvcmRlck5vdyA9PT0gXFxcIumAhuW6j1xcXCIgPyB1cF9pY29uIDogZG93bl9pY29uXFxyXFxuICAgICAgICAgICAgICAgIH0pO1xcclxcbiAgICAgICAgICAgICAgICAvL2xvZyhcXFwi54K55Ye76aG65bqPXFxcIitvcmRlck5vdylcXHJcXG4gICAgICAgICAgICAgICAgaWYgKGdldE15VmFyKFxcXCJsaXN0X2NudFxcXCIpID4gMSkge1xcclxcbiAgICAgICAgICAgICAgICAgICAgbGV0IGQgPSBbXVxcclxcbiAgICAgICAgICAgICAgICAgICAgZnVuY0xvYWRwYWdlKGQpXFxyXFxuICAgICAgICAgICAgICAgIH1cXHJcXG4gICAgICAgICAgICAgICAgcmV0dXJuICd0b2FzdDovL+W3suWIh+aNoumhuuW6j+S4ujonICsgb3JkZXJOb3dcXHJcXG4gICAgICAgICAgICAgICAgLy9yZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcclxcbiAgICAgICAgICAgIH0sIHVwX2ljb24sIGRvd25faWNvbiwgZnVuY0xvYWRwYWdlKSxcXHJcXG4gICAgICAgICAgICBleHRyYToge1xcclxcbiAgICAgICAgICAgICAgICBpZDogXFxcIm9yZGVyaWRcXFwiLFxcclxcbiAgICAgICAgICAgICAgICBjbHM6ICdvcmRlcl9jbHMnLFxcclxcbiAgICAgICAgICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2VcXHJcXG4gICAgICAgICAgICB9LFxcclxcbiAgICAgICAgfSk7XFxyXFxuICAgICAgICBkLnB1c2goe1xcclxcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwiYmxhbmtfYmxvY2tcXFwiLFxcclxcbiAgICAgICAgICAgIGV4dHJhOiB7XFxyXFxuICAgICAgICAgICAgICAgIGlkOiAnb3JkZXJfU3BlcycsIC8vIOe7mee7hOS7tuWBmmlk55SoXFxyXFxuICAgICAgICAgICAgICAgIGNsczogJ29yZGVyX2NscydcXHJcXG4gICAgICAgICAgICB9XFxyXFxuICAgICAgICB9KTtcXHJcXG4gICAgICAgIHJldHVybiBkXFxyXFxuICAgIH07XFxyXFxuICAgIC8vbG9nKFxcXCLlvZPliY3pobrluo/kuLo6LiBcXFwiK2dldE15VmFyKCfpobrluo8nLCAn5q2j5bqPJykpXFxyXFxuICAgIGxldCDliIbpobXmlbDnu4QgPSBbXTtcXHJcXG4gICAgZm9yICh2YXIgaSA9IDE7IGkgPD0g5pyA5aSn6aG15pWwOyBpKyspIHtcXHJcXG4gICAgICAgIHZhciB0b3RhbDEgPSBwYXJzZUludCgoaSAtIDEpICog5q+P6aG15pWw6YePKTtcXHJcXG4gICAgICAgIHZhciB0b3RhbDIgPSBwYXJzZUludChpICog5q+P6aG15pWw6YePKTtcXHJcXG4gICAgICAgIC8vbG9nKFxcXCLliIbpobXmlbDnu4TnlJ/miJDpobXnoIE6IFxcXCIrZ2V0TXlWYXIoJ+mAiembhue/u+mhtScsICcxJykpO1xcclxcbiAgICAgICAgaWYgKGkgPT0gZ2V0TXlWYXIoJ+mAiembhue/u+mhtScsICcxJykpIHtcXHJcXG4gICAgICAgICAgICB0b3RhbDEgPSAn8J+UuycgKyB0b3RhbDFcXHJcXG4gICAgICAgIH1cXHJcXG4gICAgICAgIC8vbG9nKHRvdGFsMSlcXHJcXG4gICAgICAgIGlmIChpID09IHBhcnNlSW50KOacgOWkp+mhteaVsCkpIHtcXHJcXG4gICAgICAgICAgICB0b3RhbDIgPSBsaXN0X2NudDtcXHJcXG4gICAgICAgIH1cXHJcXG4gICAgICAgIOWIhumhteaVsOe7hC5wdXNoKHRvdGFsMSArICctJyArIHRvdGFsMilcXHJcXG4gICAgfTtcXHJcXG4gICAgLy9sb2co5YiG6aG15pWw57uEKVxcclxcbiAgICB2YXIg6aG26YOo5oyJ6ZKuID0gZnVuY3Rpb24oKSB7XFxyXFxuICAgICAgICBsZXQgdG9wQiA9IFtdO1xcclxcbiAgICAgICAgbGV0IOacgOWkp+mhteaVsCA9IGdldE15VmFyKFxcXCLmnIDlpKfpobXmlbBcXFwiKTtcXHJcXG4gICAgICAgIGxldCDmr4/pobXmlbDph48gPSBnZXRNeVZhcihcXFwi5q+P6aG15pWw6YePXFxcIik7XFxyXFxuICAgICAgICAvL2xvZyhcXFwi5pyA5aSn6aG15pWwOiBcXFwiICsg5pyA5aSn6aG15pWwKVxcclxcbiAgICAgICAgLy9sb2coXFxcIuW9k+WJjemhteaVsDpcXFwiICsgZ2V0TXlWYXIoJ+mAiembhue/u+mhtScsICcxJykpXFxyXFxuXFxyXFxuICAgICAgICB0b3BCLnB1c2goe1xcclxcbiAgICAgICAgICAgIHRpdGxlOiAn8J+TkScsXFxyXFxuICAgICAgICAgICAgY29sX3R5cGU6ICdzY3JvbGxfYnV0dG9uJyxcXHJcXG4gICAgICAgICAgICB1cmw6ICdoaWtlcjovL2VtcHR5JyxcXHJcXG4gICAgICAgICAgICBleHRyYToge1xcclxcbiAgICAgICAgICAgICAgICBpZDogJ+WNoOS9jeespicsXFxyXFxuICAgICAgICAgICAgICAgIGNsczogJ3RvcFBhZ2UnXFxyXFxuICAgICAgICAgICAgfVxcclxcbiAgICAgICAgfSk7XFxyXFxuICAgICAgICDliIbpobXmlbDnu4QuZm9yRWFjaCgoaXRlbSwgaSkgPT4ge1xcclxcbiAgICAgICAgICAgIGlmICgv8J+Uuy8udGVzdChpdGVtKSkge1xcclxcbiAgICAgICAgICAgICAgICBpdGVtID0gaXRlbS5yZXBsYWNlKCfwn5S7JywgJycpO1xcclxcbiAgICAgICAgICAgIH1cXHJcXG4gICAgICAgICAgICB0b3BCLnB1c2goe1xcclxcbiAgICAgICAgICAgICAgICB0aXRsZTogKHBhcnNlSW50KGdldE15VmFyKCfpgInpm4bnv7vpobUnLCAnMScpKSAtIDEpID09IGkgPyBnZXRIZWFkKGl0ZW0pIDogaXRlbSxcXHJcXG4gICAgICAgICAgICAgICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nIyNub0hpc3RvcnkjXFxcIikubGF6eVJ1bGUoKGdldEhlYWQsIGdldGJ0bnNDb2xvciwg5YiG6aG15pWw57uELCBpLCBmdW5jTG9hZHBhZ2UpID0+IHtcXHJcXG4gICAgICAgICAgICAgICAgICAgIGlmICgocGFyc2VJbnQoZ2V0TXlWYXIoJ+mAiembhue/u+mhtScsICcxJykpIC0gMSkgIT0gaSkge1xcclxcbiAgICAgICAgICAgICAgICAgICAgICAgIHVwZGF0ZUl0ZW0oXFxcInRvcEJcXFwiICsgKHBhcnNlSW50KGdldE15VmFyKCfpgInpm4bnv7vpobUnLCAnMScpKSAtIDEpLCB7XFxyXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiDliIbpobXmlbDnu4RbKHBhcnNlSW50KGdldE15VmFyKCfpgInpm4bnv7vpobUnLCAnMScpKSAtIDEpXS5yZXBsYWNlKCfwn5S7JywgJycpLFxcclxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcclxcbiAgICAgICAgICAgICAgICAgICAgICAgIHVwZGF0ZUl0ZW0oXFxcInRvcEJcXFwiICsgaSwge1xcclxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogZ2V0SGVhZCjliIbpobXmlbDnu4RbaV0pLnJlcGxhY2UoJ/CflLsnLCAnJyksXFxyXFxuICAgICAgICAgICAgICAgICAgICAgICAgfSk7XFxyXFxuICAgICAgICAgICAgICAgICAgICAgICAgcHV0TXlWYXIoXFxcIumAiembhue/u+mhtVxcXCIsIChpICsgMSkpO1xcclxcbiAgICAgICAgICAgICAgICAgICAgICAgIHVwZGF0ZUl0ZW0oXFxcIuW6leWIhumhtTFcXFwiLCB7XFxyXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBnZXRidG5zQ29sb3IoZ2V0TXlWYXIoJ+mAiembhue/u+mhtScsICcxJykgKyAnIC8gJyArIGdldE15VmFyKFxcXCLmnIDlpKfpobXmlbBcXFwiKSksXFxyXFxuICAgICAgICAgICAgICAgICAgICAgICAgfSk7XFxyXFxuICAgICAgICAgICAgICAgICAgICAgICAgLy9sb2coXFxcIueCueWHu+mAiembhue/u+mhteaVsDogXFxcIiArIGdldE15VmFyKCfpgInpm4bnv7vpobUnLCAnMScpKVxcclxcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vbG9nKHR5cGVvZihmdW5jTG9hZHBhZ2UpKVxcclxcbiAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZUl0ZW1CeUNscygncGxheUxpc3QnKTtcXHJcXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgZCA9IFtdO1xcclxcbiAgICAgICAgICAgICAgICAgICAgICAgIGZ1bmNMb2FkcGFnZShkKTtcXHJcXG4gICAgICAgICAgICAgICAgICAgIH1cXHJcXG4gICAgICAgICAgICAgICAgICAgIC8vcmV0dXJuICd0b2FzdDovL+WIh+aNouaIkOWKnyEnXFxyXFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcclxcbiAgICAgICAgICAgICAgICB9LCBnZXRIZWFkLCBnZXRidG5zQ29sb3IsIOWIhumhteaVsOe7hCwgaSwgZnVuY0xvYWRwYWdlKSxcXHJcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJzY3JvbGxfYnV0dG9uXFxcIixcXHJcXG4gICAgICAgICAgICAgICAgZXh0cmE6IHtcXHJcXG4gICAgICAgICAgICAgICAgICAgIGlkOiAndG9wQicgKyBpLFxcclxcbiAgICAgICAgICAgICAgICAgICAgY2xzOiAndG9wUGFnZSdcXHJcXG4gICAgICAgICAgICAgICAgfVxcclxcbiAgICAgICAgICAgIH0pO1xcclxcbiAgICAgICAgfSlcXHJcXG4gICAgICAgIHRvcEIucHVzaCh7XFxyXFxuICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJsaW5lXFxcIixcXHJcXG4gICAgICAgICAgICBleHRyYToge1xcclxcbiAgICAgICAgICAgICAgICBpZDogJ3RvcF9TcGVzJywgLy8g57uZ57+76aG157uE5Lu25YGaaWTnlKhcXHJcXG4gICAgICAgICAgICAgICAgY2xzOiAndG9wUGFnZSdcXHJcXG4gICAgICAgICAgICB9XFxyXFxuICAgICAgICB9KTtcXHJcXG4gICAgICAgIHJldHVybiB0b3BCXFxyXFxuICAgIH07XFxyXFxuXFxyXFxuICAgIHZhciDlupXpg6jmjInpkq4gPSBmdW5jdGlvbigpIHtcXHJcXG4gICAgICAgIGxldCBidG5zID0gW107XFxyXFxuICAgICAgICBsZXQg5pyA5aSn6aG15pWwID0gZ2V0TXlWYXIoXFxcIuacgOWkp+mhteaVsFxcXCIpO1xcclxcbiAgICAgICAgbGV0IOavj+mhteaVsOmHjyA9IGdldE15VmFyKFxcXCLmr4/pobXmlbDph49cXFwiKTtcXHJcXG4gICAgICAgIGxldCBsaXN0X2NudCA9IGdldE15VmFyKFxcXCJsaXN0X2NudFxcXCIpO1xcclxcbiAgICAgICAgYnRucy5wdXNoKHtcXHJcXG4gICAgICAgICAgICB0aXRsZTogZ2V0YnRuc0NvbG9yKGdldE15VmFyKCfpgInpm4bnv7vpobUnLCAnMScpICsgJyAvICcgKyDmnIDlpKfpobXmlbApLFxcclxcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxyXFxuICAgICAgICAgICAgdXJsOiAkKOWIhumhteaVsOe7hCwgMywgJ+WIhumhteiMg+WbtOmAieaLqScpLnNlbGVjdCgoZ2V0SGVhZCwgZ2V0YnRuc0NvbG9yLCDliIbpobXmlbDnu4QsIOacgOWkp+mhteaVsCwg5q+P6aG15pWw6YePLCBmdW5jTG9hZHBhZ2UpID0+IHtcXHJcXG4gICAgICAgICAgICAgICAgLy9sb2coXFxcImlucHV0OlxcXCIgKyBpbnB1dClcXHJcXG4gICAgICAgICAgICAgICAgbGV0IHRvMiA9IGlucHV0LnNwbGl0KCctJylbMV07XFxyXFxuICAgICAgICAgICAgICAgIGxldCBwYWdlTnVtID0gTWF0aC5jZWlsKHBhcnNlSW50KHRvMikgLyDmr4/pobXmlbDph48pO1xcclxcbiAgICAgICAgICAgICAgICBpZiAoZ2V0TXlWYXIoJ+mAiembhue/u+mhtScsICcxJykgIT0gcGFnZU51bSkge1xcclxcbiAgICAgICAgICAgICAgICAgICAgLy9sb2coXFxcIuiMg+WbtOmAieaLqee/u+mhteaVsDpcXFwiICsgZ2V0TXlWYXIoXFxcIumAiembhue/u+mhtVxcXCIsIFxcXCIxXFxcIikpXFxyXFxuICAgICAgICAgICAgICAgICAgICBwdXRNeVZhcihcXFwi6YCJ6ZuG57+76aG1XFxcIiwgcGFnZU51bSk7XFxyXFxuICAgICAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKFxcXCJ0b3BCXFxcIiArIChwYXJzZUludChnZXRNeVZhcign6YCJ6ZuG57+76aG1JywgJzEnKSkgLSAxKSwge1xcclxcbiAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiDliIbpobXmlbDnu4RbKHBhcnNlSW50KGdldE15VmFyKCfpgInpm4bnv7vpobUnLCAnMScpKSAtIDEpXS5yZXBsYWNlKCfwn5S7JywgJycpLFxcclxcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxyXFxuICAgICAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKFxcXCJ0b3BCXFxcIiArIHBhcnNlSW50KHBhZ2VOdW0pLCB7XFxyXFxuICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IGdldEhlYWQo5YiG6aG15pWw57uEW3BhZ2VOdW1dKS5yZXBsYWNlKCfwn5S7JywgJycpLFxcclxcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxyXFxuICAgICAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKFxcXCLlupXliIbpobUxXFxcIiwge1xcclxcbiAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBnZXRidG5zQ29sb3IocGFnZU51bSArICcgLyAnICsg5pyA5aSn6aG15pWwKSxcXHJcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcclxcbiAgICAgICAgICAgICAgICAgICAgbGV0IGQgPSBbXTtcXHJcXG4gICAgICAgICAgICAgICAgICAgIGZ1bmNMb2FkcGFnZShkKVxcclxcbiAgICAgICAgICAgICAgICB9XFxyXFxuICAgICAgICAgICAgICAgIHJldHVybiAnaGlrZXI6Ly9lbXB0eSdcXHJcXG4gICAgICAgICAgICB9LCBnZXRIZWFkLCBnZXRidG5zQ29sb3IsIOWIhumhteaVsOe7hCwg5pyA5aSn6aG15pWwLCDmr4/pobXmlbDph48sIGZ1bmNMb2FkcGFnZSksXFxyXFxuICAgICAgICAgICAgZXh0cmE6IHtcXHJcXG4gICAgICAgICAgICAgICAgaWQ6ICflupXliIbpobUxJyxcXHJcXG4gICAgICAgICAgICAgICAgY2xzOiAnZm9vdFBhZ2UnLFxcclxcbiAgICAgICAgICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2VcXHJcXG4gICAgICAgICAgICB9XFxyXFxuICAgICAgICB9KTtcXHJcXG4gICAgICAgIGJ0bnMucHVzaCh7XFxyXFxuICAgICAgICAgICAgdGl0bGU6ICfinIjvuI/ot7Ppm4YnLFxcclxcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF81XFxcIixcXHJcXG4gICAgICAgICAgICB1cmw6ICQobGlzdF9jbnQsICfor7fovpPlhaXopoHot7PovazliLDnmoTpm4bmlbAnKS5pbnB1dCgobWF4LCDmr4/pobXmlbDph48sIGZ1bmNMb2FkcGFnZSkgPT4ge1xcclxcbiAgICAgICAgICAgICAgICBpZiAoaXNOYU4ocGFyc2VJbnQoaW5wdXQpKSkge1xcclxcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuICd0b2FzdDovL+i+k+WFpeacieivryzor7fovpPlhaXkuIDkuKoxficgKyBtYXggKyAn55qE5pWw5a2XJ1xcclxcbiAgICAgICAgICAgICAgICB9XFxyXFxuICAgICAgICAgICAgICAgIGxldCB0b051bSA9IHBhcnNlSW50KGlucHV0KTtcXHJcXG4gICAgICAgICAgICAgICAgaWYgKHRvTnVtIDwgMSB8fCB0b051bSA+IG1heCkge1xcclxcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuICd0b2FzdDovL+i+k+WFpeacieivryzor7fovpPlhaXkuIDkuKoxficgKyBtYXggKyAn55qE5pWw5a2XJ1xcclxcbiAgICAgICAgICAgICAgICB9XFxyXFxuICAgICAgICAgICAgICAgIGxldCBub3dQYWdlID0gcGFyc2VJbnQoZ2V0TXlWYXIoJ+mAiembhue/u+mhtScsICcxJykpIHx8IDE7IC8v5b2T5YmN6aG15pWwXFxyXFxuICAgICAgICAgICAgICAgIGxldCB0b1BhZ2UgPSBNYXRoLmNlaWwodG9OdW0gLyDmr4/pobXmlbDph48pO1xcclxcbiAgICAgICAgICAgICAgICBpZiAobm93UGFnZSA9PSB0b1BhZ2UpIHtcXHJcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiAndG9hc3Q6Ly/mnKzpobXlsLHmmK/liJfooajlhYPntKDmiYDlnKjpobUhJztcXHJcXG4gICAgICAgICAgICAgICAgfVxcclxcbiAgICAgICAgICAgICAgICBwdXRNeVZhcign6YCJ6ZuG57+76aG1JywgJycgKyB0b1BhZ2UpO1xcclxcbiAgICAgICAgICAgICAgICBsZXQgZCA9IFtdO1xcclxcbiAgICAgICAgICAgICAgICBmdW5jTG9hZHBhZ2UoZCk7XFxyXFxuICAgICAgICAgICAgICAgIHJldHVybiAndG9hc3Q6Ly/lt7Lot7PliLDliJfooajlhYPntKDnrKwnICsgdG9OdW0gKyAn5Liq5omA5Zyo6aG156CBOicgKyB0b1BhZ2VcXHJcXG4gICAgICAgICAgICB9LCBsaXN0X2NudCwg5q+P6aG15pWw6YePLCBmdW5jTG9hZHBhZ2UpLFxcclxcbiAgICAgICAgICAgIGV4dHJhOiB7XFxyXFxuICAgICAgICAgICAgICAgIGNsczogJ2Zvb3RQYWdlJyxcXHJcXG4gICAgICAgICAgICB9XFxyXFxuICAgICAgICB9KTtcXHJcXG4gICAgICAgIGJ0bnMucHVzaCh7XFxyXFxuICAgICAgICAgICAgdGl0bGU6ICfwn5Sd6Lez6aG1JyxcXHJcXG4gICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfNVxcXCIsXFxyXFxuICAgICAgICAgICAgdXJsOiAkKDEsICfor7fovpPlhaXopoHot7PovazliLDnmoTpobXmlbAnKS5pbnB1dCgo5pyA5aSn6aG15pWwLCDmr4/pobXmlbDph48sIGZ1bmNMb2FkcGFnZSkgPT4ge1xcclxcbiAgICAgICAgICAgICAgICBpZiAoaXNOYU4ocGFyc2VJbnQoaW5wdXQpKSkge1xcclxcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuICd0b2FzdDovL+i+k+WFpeacieivryzor7fovpPlhaXkuIDkuKoxficgKyDmnIDlpKfpobXmlbAgKyAn55qE5pWw5a2XJ1xcclxcbiAgICAgICAgICAgICAgICB9XFxyXFxuICAgICAgICAgICAgICAgIGxldCB0b1BhZ2UgPSBwYXJzZUludChpbnB1dCk7XFxyXFxuICAgICAgICAgICAgICAgIGlmICh0b1BhZ2UgPCAxIHx8IHRvUGFnZSA+IOacgOWkp+mhteaVsCkge1xcclxcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuICd0b2FzdDovL+i+k+WFpeacieivryzor7fovpPlhaXkuIDkuKoxficgKyDmnIDlpKfpobXmlbAgKyAn55qE5pWw5a2XJ1xcclxcbiAgICAgICAgICAgICAgICB9XFxyXFxuICAgICAgICAgICAgICAgIGxldCBub3dQYWdlID0gcGFyc2VJbnQoZ2V0TXlWYXIoJ+mAiembhue/u+mhtScsICcxJykpIHx8IDE7IC8v5b2T5YmN6aG15pWwXFxyXFxuICAgICAgICAgICAgICAgIGlmIChub3dQYWdlID09IHRvUGFnZSkge1xcclxcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuICd0b2FzdDovL+acrOmhteWwseaYr+esrCcgKyB0b1BhZ2UgKyAn6aG1JztcXHJcXG4gICAgICAgICAgICAgICAgfVxcclxcbiAgICAgICAgICAgICAgICBwdXRNeVZhcign6YCJ6ZuG57+76aG1JywgJycgKyB0b1BhZ2UpO1xcclxcbiAgICAgICAgICAgICAgICBsZXQgZCA9IFtdO1xcclxcbiAgICAgICAgICAgICAgICBmdW5jTG9hZHBhZ2UoZCk7XFxyXFxuICAgICAgICAgICAgICAgIHJldHVybiAndG9hc3Q6Ly/lt7Lot7PliLDnrKwnICsgdG9QYWdlICsgJ+mhtSdcXHJcXG4gICAgICAgICAgICB9LCDmnIDlpKfpobXmlbAsIOavj+mhteaVsOmHjywgZnVuY0xvYWRwYWdlKSxcXHJcXG4gICAgICAgICAgICBleHRyYToge1xcclxcbiAgICAgICAgICAgICAgICBjbHM6ICdmb290UGFnZScsXFxyXFxuICAgICAgICAgICAgfVxcclxcbiAgICAgICAgfSk7XFxyXFxuICAgICAgICBidG5zLnB1c2goe1xcclxcbiAgICAgICAgICAgIHRpdGxlOiAn4o+u77iP5LiK6aG1JyxcXHJcXG4gICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfNVxcXCIsXFxyXFxuICAgICAgICAgICAgdXJsOiAkKCcjbm9Mb2FkaW5nIycpLmxhenlSdWxlKCjmr4/pobXmlbDph48sIGZ1bmNMb2FkcGFnZSkgPT4ge1xcclxcbiAgICAgICAgICAgICAgICBsZXQgbm93UGFnZSA9IHBhcnNlSW50KGdldE15VmFyKCfpgInpm4bnv7vpobUnLCAnMScpKSB8fCAxO1xcclxcbiAgICAgICAgICAgICAgICBsZXQgdG9QYWdlID0gbm93UGFnZSAtIDE7XFxyXFxuICAgICAgICAgICAgICAgIGlmICh0b1BhZ2UgPiAwKSB7XFxyXFxuICAgICAgICAgICAgICAgICAgICBwdXRNeVZhcign6YCJ6ZuG57+76aG1JywgJycgKyB0b1BhZ2UpO1xcclxcbiAgICAgICAgICAgICAgICAgICAgbGV0IGQgPSBbXTtcXHJcXG4gICAgICAgICAgICAgICAgICAgIGZ1bmNMb2FkcGFnZShkKTtcXHJcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiAnaGlrZXI6Ly9lbXB0eSdcXHJcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXHJcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiAndG9hc3Q6Ly/lt7Lnu4/msqHmnInkuIrkuIDpobXkuoYhJ1xcclxcbiAgICAgICAgICAgICAgICB9XFxyXFxuICAgICAgICAgICAgfSwg5q+P6aG15pWw6YePLCBmdW5jTG9hZHBhZ2UpLFxcclxcbiAgICAgICAgICAgIGV4dHJhOiB7XFxyXFxuICAgICAgICAgICAgICAgIGNsczogJ2Zvb3RQYWdlJyxcXHJcXG4gICAgICAgICAgICB9XFxyXFxuICAgICAgICB9KTtcXHJcXG4gICAgICAgIGJ0bnMucHVzaCh7XFxyXFxuICAgICAgICAgICAgdGl0bGU6ICfij63vuI/kuIvpobUnLFxcclxcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF81XFxcIixcXHJcXG4gICAgICAgICAgICB1cmw6ICQoJyNub0xvYWRpbmcjJykubGF6eVJ1bGUoKOacgOWkp+mhteaVsCwg5q+P6aG15pWw6YePLCBmdW5jTG9hZHBhZ2UpID0+IHtcXHJcXG4gICAgICAgICAgICAgICAgbGV0IG5vd1BhZ2UgPSBwYXJzZUludChnZXRNeVZhcign6YCJ6ZuG57+76aG1JywgJzEnKSkgfHwgMTtcXHJcXG4gICAgICAgICAgICAgICAgbGV0IHRvUGFnZSA9IG5vd1BhZ2UgKyAxO1xcclxcbiAgICAgICAgICAgICAgICBpZiAodG9QYWdlID4g5pyA5aSn6aG15pWwKSB7XFxyXFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gJ3RvYXN0Oi8v5bey57uP5rKh5pyJ5LiL5LiA6aG15LqGISdcXHJcXG4gICAgICAgICAgICAgICAgfVxcclxcbiAgICAgICAgICAgICAgICBwdXRNeVZhcign6YCJ6ZuG57+76aG1JywgJycgKyB0b1BhZ2UpO1xcclxcbiAgICAgICAgICAgICAgICBsZXQgZCA9IFtdO1xcclxcbiAgICAgICAgICAgICAgICBmdW5jTG9hZHBhZ2UoZCk7XFxyXFxuICAgICAgICAgICAgICAgIHJldHVybiAnaGlrZXI6Ly9lbXB0eSdcXHJcXG4gICAgICAgICAgICB9LCDmnIDlpKfpobXmlbAsIOavj+mhteaVsOmHjywgZnVuY0xvYWRwYWdlKSxcXHJcXG4gICAgICAgICAgICBleHRyYToge1xcclxcbiAgICAgICAgICAgICAgICBjbHM6ICdmb290UGFnZScsXFxyXFxuICAgICAgICAgICAgfVxcclxcbiAgICAgICAgfSk7XFxyXFxuICAgICAgICBidG5zLnB1c2goe1xcclxcbiAgICAgICAgICAgIHRpdGxlOiAn8J+UmuWwvumhtScsXFxyXFxuICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0XzVcXFwiLFxcclxcbiAgICAgICAgICAgIHVybDogJCgnI25vTG9hZGluZyMnKS5sYXp5UnVsZSgo5pyA5aSn6aG15pWwLCDmr4/pobXmlbDph48sIGZ1bmNMb2FkcGFnZSkgPT4ge1xcclxcbiAgICAgICAgICAgICAgICBsZXQgdG9QYWdlID0g5pyA5aSn6aG15pWwO1xcclxcbiAgICAgICAgICAgICAgICBsZXQgbm93UGFnZSA9IHBhcnNlSW50KGdldE15VmFyKCfpgInpm4bnv7vpobUnLCAnMScpKSB8fCAxOyAvL+W9k+WJjemhteaVsFxcclxcbiAgICAgICAgICAgICAgICBpZiAobm93UGFnZSA9PSB0b1BhZ2UpIHtcXHJcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiAndG9hc3Q6Ly/lt7Lnu4/mmK/mnIDlkI7kuIDpobXllaYhJztcXHJcXG4gICAgICAgICAgICAgICAgfVxcclxcbiAgICAgICAgICAgICAgICBwdXRNeVZhcign6YCJ6ZuG57+76aG1JywgJycgKyB0b1BhZ2UpO1xcclxcbiAgICAgICAgICAgICAgICBsZXQgZCA9IFtdO1xcclxcbiAgICAgICAgICAgICAgICBmdW5jTG9hZHBhZ2UoZCk7XFxyXFxuICAgICAgICAgICAgICAgIHJldHVybiAndG9hc3Q6Ly/lt7Lot7PovazliLDnrKwnICsg5pyA5aSn6aG15pWwICsgJ+mhtSdcXHJcXG4gICAgICAgICAgICB9LCDmnIDlpKfpobXmlbAsIOavj+mhteaVsOmHjywgZnVuY0xvYWRwYWdlKSxcXHJcXG4gICAgICAgICAgICBleHRyYToge1xcclxcbiAgICAgICAgICAgICAgICBjbHM6ICdmb290UGFnZScsXFxyXFxuICAgICAgICAgICAgfVxcclxcbiAgICAgICAgfSk7XFxyXFxuICAgICAgICByZXR1cm4gYnRuc1xcclxcbiAgICB9XFxyXFxuICAgIGxldCBzZXBzID0gW107XFxyXFxuICAgIHNlcHMucHVzaCh7XFxyXFxuICAgICAgICBjb2xfdHlwZTogXFxcImxpbmVcXFwiLFxcclxcbiAgICAgICAgZXh0cmE6IHtcXHJcXG4gICAgICAgICAgICBpZDogJ2xpbmVfU3BlcycsIC8vIOe7mee/u+mhtee7hOS7tuWBmmlk55SoXFxyXFxuICAgICAgICAgICAgY2xzOiAncGxheUxpc3QnXFxyXFxuICAgICAgICB9XFxyXFxuICAgIH0pXFxyXFxuICAgIC8v57q/6LevXFxyXFxuICAgIEFycmF5LnByb3RvdHlwZS5wdXNoLmFwcGx5KGQsIGZ1bmNUYWIodGFiLCBcXFwiZmxleF9idXR0b25cXFwiKSk7XFxyXFxuICAgIGxldCBvcmRlcl9idG5zID0gZnVuY09yZGVyKHRhYik7XFxyXFxuICAgIGlmIChsaXN0X2NudCA+IG9iai5zaXplICYmIGdldE15VmFyKCfpgInpm4bmmL7npLonLCAn5YiG6aG1JykgPT0gJ+WIhumhtScpIHtcXHJcXG4gICAgICAgIGlmIChnZXRNeVZhcign6aG65bqPJywgJ+ato+W6jycpID09PSAn6YCG5bqPJykge1xcclxcbiAgICAgICAgICAgIHNob3dMaXN0ID0gc2hvd0xpc3QucmV2ZXJzZSgpO1xcclxcb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hpbmVzZV9udW1iZXI7XFxyXFxuICAgICAgICAgICAgbGVuKys7XFxyXFxuICAgICAgICB9XFxyXFxuICAgICAgICBpZiAobGVuID49IDMgJiYgQ2hpbmVzZU1hcFtjaGluZXNlX251bWJlcltsZW4gLSAxXV0gPCAxMCkge1xcclxcbiAgICAgICAgICAgIGxldCBsYXN0X3NlY29uZF9udW0gPSBDaGluZXNlTWFwW2NoaW5lc2VfbnVtYmVyW2xlbiAtIDJdXTtcXHJcXG4gICAgICAgICAgICBpZiAobGFzdF9zZWNvbmRfbnVtID09PSAxMDAgfHwgbGFzdF9zZWNvbmRfbnVtID09PSAxMDAwIHx8IGxhc3Rfc2Vjb25kX251bSA9PT0gMTAwMDAgfHwgbGFzdF9zZWNvbmRfbnVtID09PSAxMDAwMDAwMDApIHtcXHJcXG4gICAgICAgICAgICAgICAgZm9yIChsZXQga2V5IGluIENoaW5lc2VNYXApIHtcXHJcXG4gICAgICAgICAgICAgICAgICAgIGlmIChDaGluZXNlTWFwW2tleV0gPT09IGxhc3Rfc2Vjb25kX251bSAvIDEwKSB7XFxyXFxuICAgICAgICAgICAgICAgICAgICAgICAgY2hpbmVzZV9udW1iZXIgKz0ga2V5O1xcclxcbiAgICAgICAgICAgICAgICAgICAgICAgIGxlbiArPSBrZXkubGVuZ3RoO1xcclxcbiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xcclxcbiAgICAgICAgICAgICAgICAgICAgfVxcclxcbiAgICAgICAgICAgICAgICB9XFxyXFxuICAgICAgICAgICAgfVxcclxcbiAgICAgICAgfVxcclxcbiAgICAgICAgaWYgKGNoaW5lc2VfbnVtYmVyLm1hdGNoKC/kur8vZykgJiYgY2hpbmVzZV9udW1iZXIubWF0Y2goL+S6vy9nKS5sZW5ndGggPiAxKSByZXR1cm4gLTE7XFxyXFxuICAgICAgICBsZXQgc3BsaXRlZCA9IGNoaW5lc2VfbnVtYmVyLnNwbGl0KFxcXCLkur9cXFwiKTtcXHJcXG4gICAgICAg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xcclxcbiAgICAgICAgICAgIHNpemU6IHNpemVcXHJcXG4gICAgICAgIH07XFxyXFxuICAgICAgICBpZiAoTVlfUEFSQU1TLnRpdGxlKSB7XFxyXFxuICAgICAgICAgICAgT2JqZWN0LmFzc2lnbihmb290X0l0ZW0sIHtcXHJcXG4gICAgICAgICAgICAgICAgdGl0bGU6IE1ZX1BBUkFNUy50aXRsZVxcclxcbiAgICAgICAgICAgIH0pO1xcclxcbiAgICAgICAgfVxcclxcbiAgICAgICAgaWYgKGZvb3RJZGV4ID4gLTEpIHtcXHJcXG4gICAgICAgICAgICBmb290SGlzdG9yeVtmb290SWRleF0gPSBmb290X0l0ZW07XFxyXFxuICAgICAgICB9IGVsc2Uge1xcclxcbiAgICAgICAgICAgIGZvb3RIaXN0b3J5LnB1c2goZm9vdF9JdGVtKTtcXHJcXG4gICAgICAgIH1cXHJcXG4gICAgICAgIHNhdmVGaWxlKCdmb290SGlzdG9yeS5qc29uJywgSlNPTi5zdHJpbmdpZnkoZm9vdEhpc3RvcnkpLCAwKTtcXHJcXG4gICAgICAgIC8vbG9nKCflt7LlgqjlrZjotrPov7k6JyArIEpTT04uc3RyaW5naWZ5KGZvb3RfSXRlbSkpO1xcclxcbiAgICB9O1xcclxcblxcclxcbiAgICBmdW5jdGlvbiDliqDovb3otrPov7koTVlfVVJMLCBzaXplKSB7XFxyXFxuICAgICAgICAvL2xvZyhcXFwi5q2j5Zyo5Yqg6L296Laz6L+5XFxcIik7XFxyXFxuICAgICAgICBzaXplID0gc2l6ZSB8fCBwYXJzZUludChnZXRJdGVtKCfmr4/pobXmlbDph48nLCAnMzAnKSk7IC8v5q+P6aG15pWw6YePXFxyXFxuICAgICAgICBNWV9VUkwgPSBNWV9VUkwucmVwbGFjZSgnaGlrZXI6Ly9lbXB0eSMjJywgJycpO1xcclxcbiAgICAgICAgLy9sb2coXFxcIui/m+ihjOi2s+i/ueWkhOeQhlxcXCIpXFxyXFxuICAgICAgICBsZXQgZm9vdEhpc3Rvcn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ICAgICDlgqjlrZjotrPov7koTVlfVVJMLCDmr4/pobXmlbDph48sIE1ZX1BBUkFNUyk7XFxyXFxuICAgICAgICBjbGVhck15VmFyKFxcXCLliJ3lp4vljJZcXFwiKTtcXHJcXG4gICAgICAgIGNsZWFyTXlWYXIoXFxcIumhuuW6j1xcXCIpO1xcclxcbiAgICAgICAgY2xlYXJNeVZhcihcXFwidGFibnVtXFxcIik7XFxyXFxuICAgICAgICBjbGVhck15VmFyKFxcXCLpgInpm4bnv7vpobVcXFwiKTsgICBcXG4gICAgICAgIGNsZWFyTXlWYXIoXFxcIue/u+mhteeKtuaAgVxcXCIpO1xcclxcbiAgICAgICAgZGVsZXRlRmlsZShcXFwiT2JqZWN0Lmpzb25cXFwiKTtcXHJcXG4gICAgfSwg5YKo5a2Y6Laz6L+5LCBNWV9VUkwsIOavj+mhteaVsOmHjywgTVlfUEFSQU1TIHx8IHt9KSk7XFxyXFxuICAgIHJldHVybiBmdW5jTG9hZHBhZ2UoZCwgb2JqKVxcclxcbn1cIn1dIiwiaWNvbiI6Imh0dHBzOi8vZ2hwcm94eS5jb20vaHR0cHM6Ly9yYXcuZ2l0aHVidXNlcmNvbnRlbnQuY29tL2xzMTI1NzgxMDAzL2xtdHViaWFvL21haW4vbW92aWUvMTIzLnN2ZyIsInByb3h5IjoiIn0=
Add Comment
Please, Sign In to add comment