xiaomianao666

小程序:DrpyHiker

Jun 22nd, 2024
365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 海阔视界规则分享,当前分享的是:小程序¥home_rule_v2¥base64://@DrpyHiker@eyJsYXN0X2NoYXB0ZXJfcnVsZSI6IiIsInRpdGxlIjoiRHJweUhpa2VyIiwiYXV0aG9yIjoiQExveURnSWsmemV0YWxwaGEiLCJ1cmwiOiJoaWtlcjovL2VtcHR5IyNmeXBhZ2UiLCJ2ZXJzaW9uIjozNCwiY29sX3R5cGUiOiJtb3ZpZV8zIiwiY2xhc3NfbmFtZSI6IiIsInR5cGUiOiJ2aWRlbyIsImNsYXNzX3VybCI6IiIsImFyZWFfbmFtZSI6IiIsImFyZWFfdXJsIjoiIiwic29ydF9uYW1lIjoiIiwieWVhcl9uYW1lIjoiIiwic29ydF91cmwiOiIiLCJ5ZWFyX3VybCI6IiIsImZpbmRfcnVsZSI6ImpzOiQucmVxdWlyZShcIk1pYW5Mb2FkXCIpOyIsInNlYXJjaF91cmwiOiJoaWtlcjovL2VtcHR5P3M9KiomcGFnZT1meXBhZ2UiLCJncm91cCI6Iua1i+ivlSIsInNlYXJjaEZpbmQiOiJqczpcbihmdW5jdGlvbiAoKSB7XG4gIGxldCBzbW9kZSA9IE51bWJlcihnZXRJdGVtKFwic21vZGVcIiwgXCIwXCIpKTtcbiAgbGV0IHRlbXNtb2RlID0gZ2V0TXlWYXIoXCJ0ZW1zbW9kZVwiLCBcIlwiKTtcbiAgaWYgKHRlbXNtb2RlKSB7XG4gICAgc21vZGUgPSBOdW1iZXIodGVtc21vZGUpO1xuICAgIGNsZWFyTXlWYXIoXCJ0ZW1zbW9kZVwiKTtcbiAgfVxuICBpZiAoIWZpbGVFeGlzdChcImhpa2VyOi8vZmlsZXMvZGF0YS9cIiArIE1ZX1JVTEUudGl0bGUgKyBcIi9saWJzX2hpa2VyL2RycHkyLmpzXCIpKSByZXR1cm4gc2V0UmVzdWx0KFt7XG4gICAgdGl0b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gICAgICB0aXRsZTogaXQudm9kX25hbWUsXG4gICAgICAgIGRlc2M6IGl0LnZvZF9yZW1hcmtzICsgXCLCt1wiICsgc291cmNlLm5hbWUsXG4gICAgICAgIGNvbnRlbnQ6IGl0LnZvZF9jb250ZW50LFxuICAgICAgICB1cmw6IFwiaGlrZXI6Ly9wYWdlL2RldGFpbGVkI2ltbWVyc2l2ZVRoZW1lI1wiLFxuICAgICAgICBwaWNfdXJsOiBpdC52b2RfcGljLFxuICAgICAgICBjb2xfdHlwZTogXCJtb3ZpZV8zXCIsXG4gICAgICAgIGV4dHJhOiB7XG4gICAgICAgICAgdm9kSWQ6IFN0cmluZyhpdC52b2RfaWQpLFxuICAgICAgICAgIGltZzogaXQudm9kX3BpYyxcbiAgICAgICAgICBzbmFtZTogc291cmNlLm5hbWUsXG4gICAgICAgICAgc2tleTogc291cmNlLmtleSxcbiAgICAgICAgfVxuICAgICAgfSk7XG4gICAgfVxuICAgIHNldFJlc3VsdChkKTtcbiAgfSBlbHNlIHtcbiAgICBzZXRSZXN1bHQoW3tcbiAgICAgIHRpdGxlOiBcIueCueaIkeW8gOWni+iBmuWQiOaQnOe0olwiICsgTVlfS0VZV09SRCxcbiAgICAgIHVybDogXCJoaWtlcjovL3NlYXJjaD9zPVwiICsgTVlfS0VZV09SRCxcbiAgICAgIGV4dHJhOiB7XG4gICAgICAgIGRlbGVnYXRlT25seVNlYXJjaDogdHJ1ZSxcbiAgICAgICAgcnVsZXM6ICQudG9TdHJpbmcoKCkgPT4ge1xuICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICBsZXQgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcInJ1bnRpbWVDb25maWdcIiwgXCJydW50aW1lQ29uZmlnXCIpO1xuICAgICAgICAgICAgbGV0IHNtb2RlID0gTnVtYmVyKGdldEl0ZW0oXCJzbW9kZVwiLCBcIjBcIikpO1xuICAgICAgICAgICAgbGV0IGxpc3QgPSBydW50aW1lQ29uZmlnLmdldEFsbG93U2VhcmNoU291cmNlKHNtb2RlPT09Mik7XG5cbiAgICAgICAgICAgIGxldCBzb3VyY2UgPSBydW50aW1lQ29uZmlnLmdldEN1cnJlbnRTb3VyY2UoKTtcblxuICAgICAgICAgICAgbGV0IGxpc3RpID0gbGlzdC5maW5kSW5kZXgoeCA9PiB4LmtleSA9PSBzb3VyY2Uua2V5KTtcblxuICAgICAgICAgICAgaWYgKHNvdXJjZS5zZWFyY2hhYmxlICYmIGxpc3RpICE9IC0xKSB7XG4gICAgICAgICAgICAgIGxpc3Quc3BsaWNlKGxpc3QuaW5kZXhPZihzb3VyY2UpLCAxKTtcbiAgICAgICAgICAgICAgbGlzdC51bnNoaWZ0KHNvdXJjZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBsZXQgc2VhcmNoc29ydCA9IE51bWJlcihnZXRJdGVtKFwic2VhcmNoc29ydFwiLCBcIjBcIikpO1xuICAgICAgICAgICAgbGV0IHtcbiAgICAgICAgICAgICAgbmF0dXJhbFNvcnQsXG4gICAgICAgICAgICAgIHVzaW5nU29ydFxuICAgICAgICAgICAgfSA9ICQucmVxdWlyZShcIm1ldGhvZHNcIik7XG5cbiAgICAgICAgICAgIGlmIChzZWFyY2hzb3J0ID4gMCkge1xuICAgICAgICAgICAgICBpZiAoc2VhcmNoc29ydCA9PSAxKSB7XG4gICAgICAgICAgICAgICAgbmF0dXJhbFNvcnQobGlzdCwgXCJuYW1lXCIpO1xuICAgICAgICAgICAgICB9IGVsc2UgaWYgKHNlYXJjaHNvcnQgPT0gMikge1xuICAgICAgICAgICAgICAgIHVzaW5nU29ydC5zZXRrZXkoXCJuYW1lXCIpO1xuICAgICAgICAgICAgICAgIHVzaW5nU29ydC5nZXQobGlzdClcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBsZXQgcnVsZXMgPSBbXTtcbiAgICAgICAgICAgIGZvciAobGV0IGl0IG9mIGxpc3QpIHtcbiAgICAgICAgICAgICAgcnVsZXMucHVzaCh7XG4gICAgICAgICAgICAgICAgdGl0bGU6IGl0Lm5hbWUsXG4gICAgICAgICAgICAgICAgc2VhcmNoX3VybDogXCJoaWtlcjovL2VtcHR5P3BhZ2U9ZnlwYWdlJnNlYXJjaFRlcm1zPSoqXCIsXG4gICAgICAgICAgICAgICAgc2VhcmNoRmluZDogXCJqczpcIiArICQudG9TdHJpbmcoKGl0ZW0pID0+IHtcbiAgICAgICAgICAgICAgICAgIGxldCBkcnB5ID0gR00uZGVmaW5lTW9kdWxlKFwiRHJweU1hbmFnZVwiKS5nZXQoaXRlbS5rZXkpO1xuXG4gICAgICAgICAgICAgICAgICBsZXQgaG9tZUxpc3QgPSBKU09OLnBhcnNlKGRycHkuc2VhcmNoKE1ZX0tFWVdPUkQsIGZhbHNlLCBNWV9QQUdFKSkubGlzdCB8fCBbXTtcbiAgICAgICAgICAgICAgICAgIGxldCBkID0gW107XG4gICAgICAgICAgICAgICAgICBmb3IgKGxldCBpdCBvZiBob21lTGlzdCkge1xuICAgICAgICAgICAgICAgICAgICBkLnB1c2goe1xuICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBpdC52b2RfbmFtZSxcbiAgICAgICAgICAgICAgICAgICAgICBkZXNjOiBpdC52b2RfcmVtYXJrcyxcbiAgICAgICAgICAgICAgICAgICAgICBjb250ZW50OiBpdC52b2RfY29udGVudCxcbiAgICAgICAgICAgICAgICAgICAgICB1cmw6IFwiaGlrZXI6Ly9wYWdlL2RldGFpbGVkI2ltbWVyc2l2ZVRoZW1lI1wiLFxuICAgICAgICAgICAgICAgICAgICAgIHBpY191cmw6IGl0LnZvZF9waWMsXG4gICAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6IFwibW92aWVfM1wiLFxuICAgICAgICAgICAgICAgICAgICAgIGV4dHJhOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICB2b2RJZDogU3RyaW5nKGl0LnZvZF9pZCksXG4gICAgICAgICAgICAgICAgICAgICAgICB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xcIiZkbz1qc1xcXCI7XFxuICAgIH1cXG4gICAgZXZhbChnZXRDcnlwdG9KUygpKTtcXG4gICAgZ2xvYmFsVGhpcy5DcnlwdG9KUyA9IENyeXB0b0pTO1xcblxcbiAgICBsZXQgJHJlcXVlc3QgPSByZXF1ZXN0O1xcbiAgICBsZXQgJHBvc3QgPSBwb3N0O1xcbiAgICBnbG9iYWxUaGlzLnJlcSA9IGZ1bmN0aW9uICh1cmwsIGNvYmopIHtcXG4gICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgbGV0IHJlcyA9IHt9O1xcbiAgICAgICAgICAgIGxldCBvYmogPSBPYmplY3QuYXNzaWduKHt9LCBjb2JqKTtcXG4gICAgICAgICAgICBpZiAob2JqLmRhdGEpIHtcXG4gICAgICAgICAgICAgICAgb2JqLmJvZHkgPSBvYmouZGF0YTtcXG4gICAgICAgICAgICAgICAgZGVsZXRlIG9iai5kYXRhO1xcbiAgICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgICBpZiAob2JqLmhhc093blByb3BlcnR5KFxcXCJyZWRpcmVjdFxcXCIpKSBvYmoucmVkaXJlY3QgPSAhIW9iai5yZWRpcmVjdDtcXG4gICAgICAgICAgICBpZiAob2JqLmJ1ZmZlciA9PT0gMikge1xcbiAgICAgICAgICAgICAgICBvYmoudG9IZXggPSB0cnVlO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBvYmouaGVhZGVycyA9IE9iamVjdC5hc3NpZ24oe1xcbiAgICAgICAgICAgICAgICBDb29raWU6IFxcXCIjbm9Db29raWUjXFxcIlxcbiAgICAgICAgICAgIH0sIG9iai5oZWFkZXJzKTtcXG4gICAgICAgICAgICBpZiAodXJsID09PSBcXFwiaHR0cHM6Ly9hcGkubm4uY2kvb2NyL2I2NC90ZXh0XFxcIiAmJiBvYmouaGVhZGVycykge1xcbiAgICAgICAgICAgICAgICBvYmouaGVhZGVyc1tcXFwiQ29udGVudC1UeXBlXFxcIl0gPSBcXFwidGV4dC9wbGFpblxcXCI7XFxuICAgICAgICAgICAgfVxcblxcbiAgICAgICAgICAgIGlmICh1cmwuc3RhcnRzV2l0aChcXFwiZmlsZTovL1xcXCIpICYmICh1cmwuaW5jbHVkZXMoXFxcIj90eXBlPVxcXCIpIHx8IHVybC5pbmNsdWRlcyhcXFwiP3BhcmFtcz1cXFwiKSkpIHtcXG4gICAgICAgICAgICAgICAgdXJsID0gdXJsLnNsaWNlKDAsIHVybC5sYXN0SW5kZXhPZihcXFwiP1xcXCIpKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgZm9yIChsZXQga2V5IGluIG9iai5oZWFkZXJzKSB7XFxuICAgICAgICAgICAgICAgIGlmICh0eXBlb2Ygb2JqLmhlYWRlcnNba2V5XSAhPT0gXFxcInN0cmluZ1xcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgIG9iai5oZWFkZXJzW2tleV0gPSBTdHJpbmcob2JqLmhlYWRlcnNba2V5XSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IHIgPSBcXFwiXFxcIjtcXG4gICAgICAgICAgICAvKiBpZiAoU3RyaW5nKG9iai5tZXRob2QpLnRvTG93ZXJDYXNlKCkgPT09IFxcXCJwb3N0XFxcIikge1xcbiAgICAgICAgICAgICAgICAgciA9ICRwb3N0KHVybCwgb2JqKTtcXG4gICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgIHIgPSAkcmVxdWVzdCh1cmwsIG9iaik7XFxuICAgICAgICAgICAgIH0qL1xcbiAgICAgICAgICAgIHIgPSAkcmVxdWVzdCh1cmwsIG9iaik7XFxuICAgICAgICAgICAgaWYgKG9iai53aXRoSGVhZGVycykge1xcbiAgICAgICAgICAgICAgICByID0gSlNPTi5wYXJzZShyKTtcXG4gICAgICAgICAgICAgICAgcmVzLmNvbnRlbnQgPSByLmJvZHk7XFxuICAgICAgICAgICAgICAgIHJlcy5oZWFkZXJzID0ge307XFxuICAgICAgICAgICAgICAgIGZvciAobGV0IFtrLCB2XSBvZiBPYmplY3QuZW50cmllcyhyLmhlYWRlcnMgfHwge30pKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXMuaGVhZGVyc1trXSA9IHZbMF07XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICByZXMuY29udGVudCA9IHI7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGlmIChvYmouYnVmZmVyID09PSAyKSB7XFxuICAgICAgICAgICAgICAgIHJlcy5jb250ZW50ID0gQ3J5cHRvVXRpbC5EYXRhLnBhcnNlSGV4KHJlcy5jb250ZW50KS50b0Jhc2U2NChfYmFzZTY0Lk5PX1dSQVApO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gcmVzO1xcbiAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgIGxvZyhcXFwiRXJyb3JcXFwiICsgZS50b1N0cmluZygpKTtcXG4gICAgICAgIH1cXG4gICAgfVxcbiAgICAvKlxcbiAgICBjb25zdCBKaW5KYSA9ICQucmVxdWlyZShcXFwiaHR0cHM6Ly9jZG4uYm9vdGNkbi5uZXQvYWpheC9saWJzL211c3RhY2hlLmpzLzQuMS4wL211c3RhY2hlLmpzXFxcIik7XFxuICBcXG4gICAgY29uc3QgSlAgPSAkLnJlcXVpcmUoXFxcImh0dHBzOi8vanNvbnBhdGgtcGx1cy5naXRodWIuaW8vSlNPTlBhdGgvZGlzdC9pbmRleC1icm93c2VyLXVtZC5janNcXFwiKTtcXG4gICAgZ2xvYmFsVGhpcy5jaGVlcmlvID0ge1xcbiAgICAgICAgamluamEyKHRlbXBsYXRlLCBvYmopIHtcXG4gICAgICAgICAgICBcXG4gICAgICAgICAgICByZXR1cm4gJC5sb2coSmluSmEucmVuZGVyKHRlbXBsYXRlLCBvYmopKTtcXG4gICAgICAgIH0sXFxuICAgICAgICBq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aW5kZXggIT0gLTEpIHtcXG4gICAgICAgIHJldHVybiBqc29uW2luZGV4XS5wYWdlO1xcbiAgICAgIH1cXG4gICAgfVxcbiAgICBsZXQgbWF4Y291bnQgPSBlci7ljoblj7LorrDlvZU7XFxuICAgIGlmIChtb2RlID09IFxcXCJzZXRcXFwiKSB7XFxuICAgICAgaWYgKGpzb24ubGVuZ3RoID49IG1heGNvdW50KSB7XFxuICAgICAgICBqc29uID0ganNvbi5zbGljZSgwLCBtYXhjb3VudCAtIDEpO1xcbiAgICAgIH1cXG4gICAgICBsZXQgaW5kZXggPSBqc29uLmZpbmRJbmRleChvYmogPT4gb2JqLnNrZXkgPT09IHNrZXkgJiYgb2JqLmlkID09PSBpZCk7XFxuICAgICAgaWYgKGluZGV4ICE9IC0xKSB7XFxuICAgICAgICBpZiAoanNvbltpbmRleF0ucGFnZSAhPSB2YWx1ZS5wYWdlKSB7XFxuICAgICAgICAgIGpzb25baW5kZXhdLnBhZ2UgPSB2YWx1ZS5wYWdlO1xcbiAgICAgICAgICBzYXZlRmlsZShuYW1lLCBKU09OLnN0cmluZ2lmeShqc29uKSwgMCk7XFxuICAgICAgICB9O1xcbiAgICAgIH0gZWxzZSB7XFxuICAgICAgICBqc29uLnB1c2goe1xcbiAgICAgICAgICBza2V5OiBza2V5LFxcbiAgICAgICAgICBpZDogaWQsXFxuICAgICAgICAgIHRpdGxlOiB2YWx1ZS50aXRsZSxcXG4gICAgICAgICAgcGFnZTogdmFsdWUucGFnZSxcXG4gICAgICAgIH0pXFxuICAgICAgICBzYXZlRmlsZShuYW1lLCBKU09OLnN0cmluZ2lmeShqc29uKSwgMCk7XFxuICAgICAgfVxcbiAgICB9XFxuICB9XFxuXFxuICAvL+aWueazlVxcbiAgZnVuY3Rpb24gZm9udHN0eWxlKHRleHQsIHBhcmFtcykge1xcbiAgICBwYXJhbXMgPSBwYXJhbXMgfHwgdW5kZWZpbmVkO1xcbiAgICB2YXIgaCA9IHBhcmFtcy5oICE9PSBmYW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kXFxcIik7XFxuICAgICAgICBsZXQgdCA9IGtbMF07XFxuICAgICAgICBsZXQgdWlkID0gKGtbMV0gfHwga1swXSk7XFxuICAgICAgICByZXR1cm4ge1xcbiAgICAgICAgICBzdGl0bGU6IHQsXFxuICAgICAgICAgIHRpdGxlOiBmb250c3R5bGUodCwge1xcbiAgICAgICAgICAgIHRhZ3M6IFxcXCJzbWFsbFxcXCJcXG4gICAgICAgICAgfSksXFxuICAgICAgICAgIHN1cmw6IHVpZCArIFxcXCIjXFxcIiArIGZyb21baV0sXFxuICAgICAgICAgIHVybDogaXNOb3ZlbCA/IFxcXCJoaWtlcjovL3BhZ2Uvbm92ZWwjYXV0b1BhZ2UjI3JlYWRUaGVtZSNcXFwiIDogKHVpZCArIFxcXCIjXFxcIiArIGZyb21baV0gKyBwbGF5TGF6eS5yZXBsYWNlKCdcXFwiaWRcXFwiJywgJ1xcXCInICsgdWlkICsgJ1xcXCInKSksXFxuICAgICAgICAgIGNvbF90eXBlOiBjb2wsXFxuICAgICAgICAgIGltZzogaW1nLFxcbiAgICAgICAgICAvKmV4dHJhOiBPYmplY3QuYXNzaWduKHt9LCBleHRyYSwge1xcbiAgICAgICAgICAgIFxcXCJSZWZlcmVyXFxcIjogZGVjb2RlVVJJQ29tcG9uZW50KGtbMV0pLFxcbiAgICAgICAgICAgIGlkOiBrWzFdLFxcbiAgICAgICAgICAgIC8vbGluZVZpc2libGU6IGZhbHNlLFxcbiAgICAgICAgICAgIHRleHRBbGlnbjogdGV4dGFsaWduLFxcbiAgICAgICAgICAgIGNsczogXFxcInBsYXlsaXN0XFxcIixcXG4gICAgICAgICAgfSkqL1xcbiAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIGZyb206IGZyb21baV0sXFxuICAgICAgICAgICAgc291cmNlOiBzb3VyY2UsXFxuICAgICAgICAgICAgaWQ6IHVpZCxcXG4gICAgICAgICAgICBibG9ja1J1bGVzOiBbJ2JiLioucG5nJywgJy5qcGcnLCBcXFwiaG1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WFyciA9IHBsYXlwLm1hcCgoeCwgaSkgPT4gaSA9PSBwYWdlbnVtID8gJ+KAnOKAnOKAneKAnScgKyB4LmZvbnRjb2xvcihcXFwicmVkXFxcIikgOiB4KTtcXG4gICAgICBhZGRJdGVtQWZ0ZXIoXFxcInBsYXlwYWdlbGluZVxcXCIsIFt7XFxuICAgICAgICB0aXRsZTogJ+S4iuS4gOmhtScsXFxuICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfNFxcXCIsXFxuICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKGxvY2F0aW9uLCBwY291bnQpID0+IHtcXG4gICAgICAgICAgbGV0IHBhZ2VudW0gPSBnZXRNeVZhcihcXFwicGFnZW51bVxcXCIsIFxcXCIwXFxcIik7XFxuICAgICAgICAgIGlmIChwYWdlbnVtID09IDApIHtcXG4gICAgICAgICAgICBwYWdlbnVtID0gcGNvdW50IC0gMTtcXG4gICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBwYWdlbnVtLS07XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgcHV0TXlWYXIoXFxcInBhZ2VudW1cXFwiLCBTdHJpbmcocGFnZW51bSkpO1xcbiAgICAgICAgICBHTS5nZXQoXFxcInJlbm92YXRlTGlzdFxcXCIsICgpID0+IHsgfSkobG9jYXRpb24pO1xcbiAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgfSwgbG9jYXRpb24sIHBjb3VudCksXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICBjbHM6IFxcXCJwbGF5cGFnZVxcXCJcXG4gICAgICAgIH1cXG4gICAgICB9LCB7XFxuICAgICAgICB0aXRsZTogcGxheXBbcGFnZW51bV0sXFxuICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfMlxcXCIsXFxuICAgICAgICB1cmw6ICQocGFnZWFyciwgMykuc2VsZWN0KChsb2NhdGlvbikgPT4ge1xcbiAgICAgICAgICBwdXRNeVZhcihcXFwicGFnZW51bVxcXCIsIFN0cmluZyhNWV9JTkRFWCkpO1xcbiAgICAgICAgICBHTS5nZXQoXFxcInJlbm92YXRlTGlzdFxcXCIsICgpID0+IHsgfSkobG9jYXRpb24pO1xcbiAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiXFxuICAgICAgICB9LCBsb2NhdGlvbiksXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICBjbHM6IFxcXCJwbGF5cGFnZVxcXCJcXG4gICAgICAgIH1cXG4gICAgICB9LCB7XFxuICAgICAgICB0aXRsZTogJ+S4i+S4gOmhtScsXFxuICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfNFxcXCIsXFxuICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKGxvY2F0aW9uLCBwY291bnQpID0+IHtcXG4gICAgICAgICAgbGV0IHBhZ2VudW0gPSBnZXRNeVZhcihcXFwicGFnZW51bVxcXCIsIFxcXCIwXFxcIik7XFxuICAgICAgICAgIGlmIChwYWdlbnVtID49IHBjb3VudCAtIDEpIHtcXG4gICAgICAgICAgICBwYWdlbnVtID0gMDtcXG4gICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBwYWdlbnVtKys7XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgcHV0TXlWYXIoXFxcInBhZ2VudW1cXFwiLCBTdHJpbmcocGFnZW51bSkpO1xcbiAgICAgICAgICBHTS5nZXQoXFxcInJlbm92YXRlTGlzdFxcXCIsICgpID0+IHsgfSkobG9jYXRpb24pO1xcbiAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgfSwgbG9jYXRpb24sIHBjb3VudCksXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICBjbHM6IFxcXCJwbGF5cGFnZVxcXCJcXG4gICAgICAgIH1cXG4gICAgICB9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B7XFxuICAgICAgICBsZXQgaW5kZXhjID0gaW5wdXQuc3BsaXQoLyx877yMLyk7XFxuICAgICAgICBsZXQgaW5kZXhzID0gW107XFxuICAgICAgICBsZXQgbW8gPSBwYXJzZUludChpbmRleGNbMF0pO1xcbiAgICAgICAgaWYgKCEoaW5kZXhjLmxlbmd0aCAhPT0gMCAmJiBtbyA8IDAgJiYgbW8gPiAtNSkpIHtcXG4gICAgICAgICAgICBmb3IgKGxldCBpdCBvZiBpbmRleGMpIHtcXG4gICAgICAgICAgICAgICAgbGV0IG51bSA9IHBhcnNlSW50KGl0KTtcXG4gICAgICAgICAgICAgICAgaWYgKE51bWJlci5pc05hTihudW0pIHx8IG51bSA+PSBsZW5ndGggfHwgbnVtIDwgMCkge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+aVsOWtl+S4jeWQiOazlVxcXCI7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgaW5kZXhzLnB1c2gobnVtKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9XFxuXFxuICAgICAgICByZXR1cm4gJChbXFxcIkhJS0VSXFxcIiwgXFxcIlRYVFxcXCJdLmNvbmNhdChnZXRQYXN0ZXMoKSksIDIsIFxcXCLliIbkuqvmlrnlvI9cXFwiKS5zZWxlY3QoKG1vLCBpbmRleHMsIGV4dCkgPT4ge1xcbiAgICAgICAgICAgIGZ1bmN0aW9uIHVwKHJ1bGVzKSB7XFxuICAgICAgICAgICAgICAgIGxldCBydWxlYjY0ID0gYmFzZTY0RW5jb2RlKEpTT04uc3RyaW5naWZ5KHJ1bGVzKSk7XFxuICAgICAgICAgICAgICAgIGxldCBnZXRQYXNzID0gKGxlbmd0aCwgcnVsZSwgdHlwZSkgPT4gXFxcIua1t+mYlOinhueVjO+8jERSUFnop6PmnpDvvIzlhbHjgIxcXFwiICsgbGVuZ3RoICsgXFxcIuOAjeadoe+8jOWkjeWItuaVtOadoeWPo+S7pOaJk+W8gOi9r+S7tuWwseS8muiHquWKqOWvvOWFpSRcXFwiICsgcnVsZSArIFxcXCIkXFxcIiArIHR5cGUgKyBcXFwiQGltcG9ydD1qczokLnJlcXVpcmUoJ2ltcG9ydD9ydWxlPScrXFxcIiArIEpTT04uc3RyaW5naWZ5KE1ZX1JVTEUudGl0bGUpICsgXFxcIikoaW5wdXQpXFxcIjtcXG4gICAgICAgICAgICAgICAgaWYgKGdldFBhc3RlcygpLmluY2x1ZGVzKGlucHV0KSkge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHUgPSBzaGFyZVBhc3RlKHJ1bGViNjQsIGlucHV0KTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiY29weTovL1xcXCIgKyBnZXRQYXNzKHJ1bGVzLmxlbmd0aCwgdSwgXFxcImJcXFwiKTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBwYXRoID0gXFxcImhpa2VyOi8vZmlsZXMvcnVsZXMvTG95RGdJay9zaGFyZS9kcnB56Kej5p6Q44CMXFxcIiArIHJ1bGVzLmxlbmd0aCArIFxcXCLjgI3mnaEuXFxcIiArIChpbnB1dCA9PT0gXFxcIkhJS0VSXFxcIiA/IFxcXCJoaWtlclxcXCIgOiBcXFwidHh0XFxcIik7XFxuICAgICAgICAgICAgICAgICAgICB3cml0ZUZpbGUocGF0aCwgZ2V0UGFzcyhydWxlcy5sZW5ndGgsIHJ1bGViNjQsIFxcXCJhXFxcIikpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJzaGFyZTovL1xcXCIgKyBwYXRoO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCBydWxlcztcXG4gICAgICAgICAgICBpZiAobW8gPT09IC0xKSB7XFxuICAgICAgICAgICAgICAgIHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAobW8gPT09IC0yKSB7XFxuICAgICAgICAgICAgICAgIHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0VXNlZnVsSnNvbigpO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAobW8gPT09IC0zKSB7XFxuICAgICAgICAgICAgICAgIHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0Rm9yYmlkZGVuSnNvbigpO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpLmZpbHRlcigodiwgaSkgPT4gaW5kZXhzLmluY2x1ZGVzKGkpKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcnVsZXMgPSBydWxlcy5tYXAoKHYpID0+IHtcXG4gICAgICAgICAgICAgICAgdi5mb3JiaWRkZW4gPSB1bmRlZmluZWQ7XFxuICAgICAgICAgICAgICAgIHJldHVybiB2O1xcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIHJldHVybiB1cChydWxlcyk7XFxuICAgICAgICB9LCBtbywgaW5kZXhzLCBpbmRleGNbMV0pO1xcblxcbiAgICB9LCBsZW5ndGgpLFxcbiAgICBjb2xfdHlwZTogXFxcImljb25fc21hbGxfNFxcXCIsXFxuICAgIHBpY191cmw6IFxcXCJoaWtlcjovL2ltYWdlcy9pY29uX3NoYXJlX2dyZWVuXFxcIlxcbn0pO1xcbmQucHVzaCh7XFxuICAgIHRpdGxlOiBcXFwi6YeN572uXFxcIixcXG4gICAgdXJsOiAkKFxcXCLkvaDnoa7lrprph43nva7vvJ9cXFxcbuivpeaTjeS9nOS8muWIoOmZpOeOsOacieino+aekO+8jOaBouWkjeiHquW4puino+aekOOAglxcXCIpLmNvbmZpcm0oKHBhdGgpID0+IHtcXG4gICAgICAg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WxlY3QoKGluZGV4KSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZSA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKVtpbmRleF07XFxuICAgICAgICAgICAgICAgICAgICBydWxlLnVzZXIgPSB1bmRlZmluZWQ7XFxuICAgICAgICAgICAgICAgICAgICBydWxlLmZvcmJpZGRlbiA9IHVuZGVmaW5lZDtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlYjY0ID0gYmFzZTY0RW5jb2RlKEpTT04uc3RyaW5naWZ5KHJ1bGUpKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBnZXRQYXNzID0gKG5hbWUsIHJ1bGUsIHR5cGUpID0+IFxcXCLmtbfpmJTop4bnlYzvvIzjgIxcXFwiICsgbmFtZSArIFxcXCLjgI1EUlBZ6Kej5p6Q77yM5aSN5Yi25pW05p2h5Y+j5Luk5omT5byA6L2v5Lu25bCx5Lya6Ieq5Yqo5a+85YWlJFxcXCIgKyBydWxlICsgXFxcIiRcXFwiICsgdHlwZSArIFxcXCJAaW1wb3J0PWpzOiQucmVxdWlyZSgnaW1wb3J0P3J1bGU9JytcXFwiICsgSlNPTi5zdHJpbmdpZnkoTVlfUlVMRS50aXRsZSkgKyBcXFwiKShpbnB1dClcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKGlucHV0ID09IFxcXCLlrozmlbTlj6Pku6RcXFwiKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJjb3B5Oi8vXFxcIiArIGdldFBhc3MocnVsZS5uYW1lLCBydWxlYjY0LCBcXFwiYVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgdSA9IHNoYXJlUGFzdGUocnVsZWI2NCwgaW5wdXQpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiY29weTovL1xcXCIgKyBnZXRQYXNzKHJ1bGUubmFtZSwgdSwgXFxcImJcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfSwgaW5kZXgpO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoaW5wdXQgPT09IFxcXCLnp7vliqhcXFwiKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiAkKGluZGV4ICsgXFxcIlxcXCIsIFxcXCLovpPlhaXkvY3nva5cXFwiKS5pbnB1dCgoaW5kZXgsIGxlbmd0aCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IG5ld0luZGV4ID0gTnVtYmVyKGlucHV0KTtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChOdW1iZXIuaXNOYU4obmV3SW5kZXgpIHx8IG5ld0luZGV4ID49IGxlbmd0aCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/kuI3lkozop4TnmoTkvY3nva5cXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGUgPSBydWxlcy5zcGxpY2UoaW5kZXgsIDEpWzBdO1xcbiAgICAgICAgICAgICAgICAgICAgcnVsZXMuc3BsaWNlKG5ld0luZGV4LCAwLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgICAgICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLnNhdmVKc29uKHJ1bGVzKTtcXG4gICAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKGZhbHNlKTtcXG4gICAgICAgICAgICAgICAgfSwgaW5kZXgsIGxlbmd0aCk7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChpbnB1dCA9PT0gXFxcIue9rumhtlxcXCIpIHtcXG4gICAgICAgICAgICAgICAgbGV0IG5ld0luZGV4ID0gMDtcXG4gICAgICAgICAgICAgICAgbGV0IHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgICAgICBsZXQgcnVsZSA9IHJ1bGVzLnNwbGljZShpbmRleCwgMSlbMF07XFxuICAgICAgICAgICAgICAgIHJ1bGVzLnNwbGljZShuZXdJbmRleCwgMCwgcnVsZSk7XFxuICAgICAgICAgICAgICAgICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLnNhdmVKc29uKHJ1bGVzKTtcXG4gICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoaW5wdXQgPT09IFxcXCLliKDpmaRcXFwiKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiAkKFxcXCLnoa7orqTliKDpmaTvvJ9cXFwiKS5jb25maXJtKChpbmRleCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGUgPSBydWxlcy5zcGxpY2UoaW5kZXgsIDEpWzBdO1xcbiAgICAgICAgICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuc2F2ZUpzb24ocnVsZXMpO1xcbiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+W3suWIoOmZpFxcXCIgKyBydWxlLm5hbWU7XFxuICAgICAgICAgICAgICAgIH0sIGluZGV4KTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBsZXQgYXJyID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgIC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gICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoZWFkZXJz5qC85byP6ZSZ6K+vOlxcXCIgKyBlLnRvU3RyaW5nKCk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuICQucmVxdWlyZShcXFwidmlkZW9VcmxcXFwiKS5wcmVwYXJlUGFyc2VzKFt7XFxuICAgICAgICAgICAgICAgIG5hbWUsXFxuICAgICAgICAgICAgICAgIHVybCxcXG4gICAgICAgICAgICAgICAgZmxhZyxcXG4gICAgICAgICAgICAgICAgaGVhZGVycyxcXG4gICAgICAgICAgICAgICAgcnVuVHlwZSxcXG4gICAgICAgICAgICAgICAgbWV0aG9kLFxcbiAgICAgICAgICAgICAgICBqc29uUGF0aCxcXG4gICAgICAgICAgICAgICAganNcXG4gICAgICAgICAgICB9XSwgaW5wdXQsbnVsbCwgdHJ1ZSk7XFxuICAgICAgICB9KTtcXG4gICAgfSksXFxuICAgIGNvbF90eXBlOiBcXFwidGV4dF8zXFxcIixcXG59KTtcXG5cXG5kLnB1c2goe1xcbiAgICB0aXRsZTogXFxcIuS/neWtmFxcXCIsXFxuICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgoaW5kZXgsIGlzSW1wb3J0KSA9PiB7XFxuICAgICAgICBsZXQgbmFtZSA9IGdldE15VmFyKFxcXCJwc19uYW1lXFxcIiwgXFxcIlxcXCIpLnRyaW0oKTtcXG4gICAgICAgIGlmICghbmFtZSkge1xcbiAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/lkI3lrZflvpfmnInkuIDkuKrlkKdcXFwiO1xcbiAgICAgICAgfVxcbiAgICAgICAgbGV0IHVybCA9IGdldE15VmFyKFxcXCJwc191cmxcXFwiLCBcXFwiXFxcIikudHJpbSgpO1xcbiAgICAgICAgaWYgKCF1cmwpIHtcXG4gICAgICAgICAgICByZX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iAgICAgICAgbGV0IGpzID0gZ2V0TXlWYXIoXFxcInBzX2pzXFxcIiwgXFxcIlxcXCIpIHx8IHZvaWQgMDtcXG4gICAgICAgIGlmIChydW5UeXBlID09PSBcXFwiSlNPTlxcXCIgJiYgIWpzb25QYXRoKSB7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL0pTT07mqKHlvI/kuIvlv4Xpobvloatqc29uUGF0aFxcXCI7XFxuICAgICAgICB9IGVsc2UgaWYgKHJ1blR5cGUgPT09IFxcXCJKU1xcXCIgJiYgIWpzKSB7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL0pT5qih5byP5LiL5b+F6aG75aGranNcXFwiO1xcbiAgICAgICAgfVxcbiAgICAgICAgbGV0IGFyciA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgIGxldCBvYmoxID0ge1xcbiAgICAgICAgICAgIG5hbWUsXFxuICAgICAgICAgICAgdXJsLFxcbiAgICAgICAgICAgIGZsYWcsXFxuICAgICAgICAgICAgaGVhZGVycyxcXG4gICAgICAgICAgICBydW5UeXBlLFxcbiAgICAgICAgICAgIG1ldGhvZCxcXG4gICAgICAgICAgICBqc29uUGF0aCxcXG4gICAgICAgICAgICBqc1xcbiAgICAgICAgfTtcXG4gICAgICAgIGlmIChpbmRleCA9PT0gdm9pZCgwKSkge1xcbiAgICAgICAgICAgIGlmIChhcnIuc29tZSh2ID0+IHYubmFtZSA9PT0gbmFtZSkpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+W3sue7j+WtmOWcqOivpeino+aekFxcXCI7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGlmIChvYmoxLmdyb3VwKSB7XFxuICAgICAgICAgICAgICAgIGxldCBncm91cCA9IG9iajEuZ3JvdXA7XFxuICAgICAgICAgICAgICAgIGxldCBpbmRleCA9IGFyci5maW5kSW5kZXgodiA9PiB2Lmdyb3VwID09PSBncm91cCk7XFxuICAgICAgICAgICAgICAgIGlmIChpbmRleCA9PT0gLTEpIHtcXG4gICAgICAgICAgICAgICAgICAgIGFyci51bnNoaWZ0KG9iajEpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgYXJyLnNwbGljZShpbmRleCwgMCwgb2JqMSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBpZiAoaXNJbXBvcnQpIHtcXG4gICAgICAgICAgICAgICAgICAgIGFyci5wdXNoKG9iajEpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgYXJyLnVuc2hpZnQob2JqMSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGxldCBuYW1leSA9IGFycltpbmRleF0ubmFtZTtcXG4gICAgICAgICAgICBpZiAobmFtZSAhPT0gbmFtZXkpIHtcXG4gICAgICAgICAgICAgICAgaWYgKGFyci5zb21lKHYgPT4gdi5uYW1lID09PSBuYW1lKSkge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+W3sue7j+WtmOWcqOivpeino+aekFxcXCI7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgb2JqMSA9IE9iamVjdC5hc3NpZ24oYXJyW2luZGV4XSwgb2JqMSk7XFxuICAgICAgICAgICAgYXJyLnNwbGljZShpbmRleCwgMSwgb2JqMSk7XFxuICAgICAgICB9XFxuICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5zYXZlSnNvbihhcnIpO1xcbiAgICAgICAgYmFjayh0cnVlKTtcXG4gICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/kv53lrZjmiJDlip9c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G4gICAgICAgIGZvciAobGV0IHJ1bGUgb2YgcnVsZXMpIHtcXG4gICAgICAgICAgICBsZXQgaW5kZXggPSBhcnIuZmluZEluZGV4KHYgPT4gdi5uYW1lID09PSBydWxlLm5hbWUpO1xcbiAgICAgICAgICAgIGlmIChpbmRleCA+IC0xKSB7XFxuICAgICAgICAgICAgICAgIHJ1bGUgPSBPYmplY3QuYXNzaWduKGFycltpbmRleF0sIHJ1bGUpO1xcbiAgICAgICAgICAgICAgICBhcnIuc3BsaWNlKGluZGV4LCAxLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgaWYgKHJ1bGVzLmxlbmd0aCA9PT0gMSkge1xcbiAgICAgICAgICAgICAgICAgICAgc2F2ZUNhY2hlKHJ1bGUpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3BhZ2UvcnVsZUVkaXQjbm9IaXN0b3J5IyNub1JlY29yZEhpc3RvcnkjP2lzSW1wb3J0PXRydWUmaW5kZXg9XFxcIiArIGluZGV4ICsgXFxcIiZydWxlPVxcXCIgKyBydWxlVGl0bGU7XFxuICAgICAgICAgICAgICAgICAgICAvL3RvYXN0KFxcXCLlt7Lmm7TmlrDop4TliJnvvJpcXFwiICsgcnVsZS5uYW1lKTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIGxvZyhcXFwi5bey5pu05paw6KeE5YiZ77yaXFxcIiArIHJ1bGUubmFtZSlcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIG5ld0krKztcXG4gICAgICAgICAgICAgICAgYXJyLnB1c2gocnVsZSk7XFxuICAgICAgICAgICAgICAgIGlmIChydWxlcy5sZW5ndGggPT09IDEpIHtcXG4gICAgICAgICAgICAgICAgICAgIHNhdmVDYWNoZShydWxlKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wY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0JiZIdG1sXFxcIik7XFxuICAgIFxcbiAgICBsZXQganNvbiA9IEpTT04ucGFyc2UoanNvblRleHQpO1xcbiAgICBsZXQgbGlzdCA9IGpzb24ucGF5bG9hZC50cmVlLml0ZW1zO1xcbiAgICBsZXQgcnVsZXMgPSBbXTtcXG4gICAgbGV0IGNvdW50ID0gMDtcXG4gICAgbGV0IG5hbWVzID0gW107XFxuICAgIGlmIChsaXN0Lmxlbmd0aCA9PT0gMCkgcmV0dXJuIFxcXCJ0b2FzdDovL+WPr+iDveWIoOW6k+S6hlxcXCI7XFxuICAgIGZvciAobGV0IGl0IG9mIGxpc3QpIHtcXG4gICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgbGV0IG5hbWUgPSBpdC5uYW1lO1xcbiAgICAgICAgICAgIGxldCBzcGF0aCA9IGl0LnBhdGg7XFxuICAgICAgICAgICAgaWYgKCFuYW1lLmVuZHNXaXRoKFxcXCIuanNcXFwiKSkgY29udGludWU7XFxuICAgICAgICAgICAgbmFtZSA9IG5hbWUuc2xpY2UoMCwgbmFtZS5sYXN0SW5kZXhPZihcXFwiLlxcXCIpKTtcXG4gICAgICAgICAgICBsZXQgcnVsZSA9IGZldGNoKGBodHRwczovL3Jhdy5naXRtaXJyb3IuY29tLyR7cm9wZX0vbWFzdGVyLyR7c3BhdGh9YCk7XFxuICAgICAgICAgICAgaWYgKCEoKCFydWxlIHx8ICFydWxlLmluY2x1ZGVzKFxcXCJydWxlXFxcIikpICYmICFmaWxlRXhpc3QocGF0aCArIGl0Lm5hbWUpKSkge1xcbiAgICAgICAgICAgICAgICB3cml0ZUZpbGUocGF0aCArIGl0Lm5hbWUsIHJ1bGUpO1xcbiAgICAgICAgICAgICAgICBydWxlcy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgICdrZXknOiBgaGlweV9qc18ke25hbWV9YCxcXG4gICAgICAgICAgICAgICAgICAgICduYW1lJzogYCR7bmFtZX1gLFxcbiAgICAgICAgICAgICAgICAgICAgJ3R5cGUnOiAzLFxcbiAgICAgICAgICAgICAgICAgICAgJ2FwaSc6ICcuLi9saWJzL2RycHkyLmpzJyxcXG4gICAgICAgICAgICAgICAgICAgICdzZWFyY2hhYmxlJzogMSxcXG4gICAgICAgICAgICAgICAgICAgICdxdWlja1NlYXJjaCc6IDEsXFxuICAgICAgICAgICAgICAgICAgICAnZmlsdGVyYWJsZSc6IDEsXFxuICAgICAgICAgICAgICAgICAgICAnZXh0JzogXFxcIi4vXFxcIiArIGl0Lm5hbWUsXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICBjb3VudCsrO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBcXG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICBsb2coZS50b1N0cmluZygpKTtcXG4gICAgICAgIH1cXG4gICAgICAgIG5hbWVzLnB1c2goaXQubmFtZSk7XFxuICAgIH1cXG4gICAgZGVsZXRlbG9zZShuYW1lcywgcGF0aClcXG4gICAgd3JpdGVGaWxlKHBhdGggKyBcXFwiaW5kZXguanNvblxcXCIsIEpTT04uc3RyaW5naWZ5KHtcXG4gICAgICAgIHNpdGVzOiBydWxlc1xcbiAgICB9KSk7XFxuXFxuICAgIHJldHVybiBcXFwidG9hc3Q6Ly/miJDlip/mm7TmlrBcXFwiICsgY291bnQgKyBcXFwi5LiqXFxcIjs7XFxufVxcblxcbmZ1bmN0aW9uIGRlbGV0ZWxvc2UobmFtZXMsIHBhdGgpIHtcXG4gICAgdHJ5IHtcXG4gICAgICAgIGxldCBwYXRoRmlsZSA9IG5ldyBqYXZhLmlvLkZpbGUocGF0aCk7XFxuICAgICAgICBpZiAoIXBhdGhGaWxlLmlzRGlyZWN0b3J5KCkpIHJldHVybjtcXG4gICAgICAgIGZvciAobGV0IGZpbGUgb2YgcGF0aEZpbGUubGlzdEZpbGVzKCkpIHtcXG4gICAgICAgICAgICBsZXQgbmFtZSA9IFN0cmluZyhmaWxlLmdldE5hbW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AgICAgICAgICAgIHJ1bGUgPSByZXF1ZXN0KGl0LmV4dCk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBydWxlID0gcmVxdWVzdChqb2luVXJsKHVybCwgaXQuZXh0KSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgaXQuZXh0ID0gXFxcIi4vXFxcIiArIG5hbWU7XFxuICAgICAgICAgICAgICAgIGlmICghcnVsZSB8fCAhcnVsZS5pbmNsdWRlcyhcXFwicnVsZVxcXCIpKSB7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoIWZpbGVFeGlzdChwYXRoICsgbmFtZSkpXFxuICAgICAgICAgICAgICAgICAgICAgICAgYXJyLnNwbGljZShpLCAxKTtcXG4gICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xcbiAgICAgICAgICAgICAgICB9O1xcbiAgICAgICAgICAgICAgICB3cml0ZUZpbGUocGF0aCArIG5hbWUsIHJ1bGUpO1xcbiAgICAgICAgICAgICAgICBuYW1lcy5wdXNoKG5hbWUpO1xcbiAgICAgICAgICAgICAgICBjb3VudCsrO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICBsb2coZS50b1N0cmluZygpKTtcXG4gICAgICAgIH1cXG4gICAgICAgIGkrKztcXG4gICAgfVxcbiAgICBkZWxldGVsb3NlKG5hbWVzLCBwYXRoKTtcXG4gICAgd3JpdGVGaWxlKHBhdGggKyBcXFwiaW5kZXguanNvblxcXCIsIEpTT04uc3RyaW5naWZ5KGpzb24pKTtcXG4gICAgcmV0dXJuIFxcXCJ0b2FzdDovL+aIkOWKn+abtOaWsFxcXCIgKyBjb3VudCArIFxcXCLkuKpcXFwiO1xcbn1cXG4kLmV4cG9ydHMucGFyc2VVcmwgPSBmdW5jdGlvbiAodXJsLCBwYXRoKSB7XFxuICAgIHBhdGggPSBiYXNlNjREZWNvZGUocGF0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1xcbiAgICAgICAgfVxcbiAgICAgICAgZmlsZSA9IHZvaWQgMDtcXG4gICAgICAgIGxldCBjdXJyZW50U291cmNlLCBzZWFyY2hBbGxvdztcXG4gICAgICAgIGlmIChjb25maWcuY0tleSkge1xcbiAgICAgICAgICAgIGN1cnJlbnRTb3VyY2UgPSBzb3VyY2VMaXN0LmZpbmQodiA9PiB2LmtleSA9PT0gY29uZmlnLmNLZXkpO1xcbiAgICAgICAgICAgIGlmICghY3VycmVudFNvdXJjZSkge1xcbiAgICAgICAgICAgICAgICBjdXJyZW50U291cmNlID0gc291cmNlTGlzdFswXTtcXG4gICAgICAgICAgICAgICAgLy9jdXJyZW50Q29uZmlnLmNLZXkgPSBzb3VyY2VMaXN0WzBdLmtleTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGN1cnJlbnRTb3VyY2UgPSBzb3VyY2VMaXN0WzBdO1xcbiAgICAgICAgICAgIC8vY29uZmlnLmNLZXkgPSBzb3VyY2VMaXN0WzBdLmtleTtcXG4gICAgICAgIH1cXG4gICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgc2VhcmNoQWxsb3cgPSBKU09OLnBhcnNlKGZldGNoKHNlYXJjaEFsbG93UGF0aCkgfHwgXFxcIltdXFxcIik7XFxuICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgZGVsZXRlRmlsZShzZWFyY2hBbGxvd1BhdGgpO1xcbiAgICAgICAgICAgIHNlYXJjaEFsbG93ID0gW107XFxuICAgICAgICB9XFxuICAgICAgICByZXR1cm4ge1xcbiAgICAgICAgICAgIGN1cnJlbnRTb3VyY2UsXFxuICAgICAgICAgICAgc2VhcmNoQWxsb3csXFxuICAgICAgICAgICAgc291cmNlTGlzdFxcbiAgICAgICAgfTtcXG4gICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgbG9nKGUudG9TdHJpbmcoKSk7XFxuICAgIH1cXG4gICAgcmV0dXJuIG51bG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gICBcXFwi56ys5LiA56m6KOWQjeensCk65pa55L6/5LiL5qyh5om+5YiwXFxcIixcXG4gICAgICAgIFxcXCLnrKzkuoznqboo6Lev5b6EKVvloavmnKzlnLDntKLlvJXlnLDlnYBdOumAieaLqUpTT04vVVJM6YCJ6aG577yM54K55Ye75peB6L6555qE6YCJ5oup5Y+v5Lul5rWP6KeI5pys5Zyw5paH5Lu26YCJ5oup5pys5Zyw5YyF55qELmpzb27ntKLlvJXmlofku7bljbPlj6/jgIJcXFxcbijms6jmhI/vvJrkvb/nlKjmraTnp43mlrnlvI/vvIzlnKjmnKzlnLDmlofku7blpLnlhoXmlrDlop7miJbliKDpmaQuanPmupDml7bpnIDopoHoh6rooYzphY3nva4uanNvbuaWh+S7tilcXFwiLFxcbiAgICAgICAgXFxcIuesrOS6jOepuijot6/lvoQpW+Whq+acrOWhq+i/nOeoi+WcsOWdgF0655u05o6l5aGr5YaZ6L+c56iL6ZO+5o6l5Y2z5Y+v5LiA6Iis5piv5LulaHR0cOW8gOWktC5qc29u57uT5bC+77yM5Lmf5Y+v5Y+v5Lul6L6T5YWlZ2l0aHVi5LuT5bqT55qE5paH5Lu25aS55Zyw5Z2A44CC5q2k56eN5pa55byP5Y+v5Lul5L+d5oyB5LiO6L+c56iL6YWN572u6ICF5ZCM5q2l5pu05paw77yM5L2G5LiN5aaC5pys5Zyw5b+r44CCXFxcIixcXG4gICAgICAgIFxcXCLnrKzkuoznqboo6Lev5b6EKVvloavmnKzlnLDmlofku7blpLnlnLDlnYBdOumAieaLqeaWh+S7tuWkuemAiemhue+8jOWPr+S7peebtOaOpei+k+WFpWpz5rqQ5omA5ZyoI+aWh+S7tuWkuSEhISPnmoTot6/lvoTvvIzkuZ/lj6/ku6Xngrnlh7vml4HovrnpgInmi6nmtY/op4jmnKzlnLDot6/lvoTpgInmi6kj5paH5Lu25aS5ISEhI++8jOS9v+eUqOivpeenjeaWueazle+8jOWcqOaWh+S7tuWkueaWsOWinuaIluWIoOmZpOa6kO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gpLnRvTG93ZXJDYXNlKCkuZW5kc1dpdGgoXFxcIi5qc1xcXCIpKSB7XFxuICAgICAgICAgICAgICAgIGpzRmlsZXMucHVzaChmKTtcXG4gICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgaWYgKGRpci5pc0ZpbGUoKSAmJiBmaWxlRXhpc3Qob2JqLnVybCkpIHtcXG4gICAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgICAganNvbiA9IEpTT04ucGFyc2UocmVhZEZpbGUob2JqLnVybCkpO1xcbiAgICAgICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkoanNvbi5zaXRlcykgfHwganNvbi5zaXRlcy5sZW5ndGgpIHtcXG4gICAgICAgICAgICAgICAgY291bnQgPSBmaWx0ZXJPdGhlcihqc29uLnNpdGVzKS5sZW5ndGg7XFxuICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSBjYXRjaCAoZSkgeyB9XFxuICAgICAgICAgICAgY29kZSA9IFxcXCJva1xcXCI7XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgaWYgKGpzRmlsZXMubGVuZ3RoID49IDUpIHtcXG4gICAgICAgICAgICBjb3VudCA9IGpzRmlsZXMubGVuZ3RoO1xcbiAgICAgICAgICAgIGNvZGUgPSBcXFwib2tcXFwiO1xcbiAgICAgICAgICB9XFxuICAgICAgICAgIHJldHVybiB7XFxuICAgICAgICAgICAgdGltZTogKERhdGUubm93KCkgLSBzKSxcXG4gICAgICAgICAgICB1cmw6IG9iai51cmwsXFxuICAgICAgICAgICAgY291bnQ6IGNvdW50LFxcbiAgICAgICAgICAgIGNvZGU6IGNvZGUsXFxuICAgICAgICAgICAgaW5kZXg6IG9iai5pXFxuICAgICAgICAgIH1cXG4gICAgICAgIH1cXG4gICAgICAgIHZhciBqID0gSlNPTi5wYXJzZShmZXRjaChvYmoudXJsLCB7XFxuICAgICAgICAgIHdpdGhIZWFkZXJzOiB0cnVlLFxcbiAgICAgICAgICB0aW1lb3V0OiA1MDAwLFxcbiAgICAgICAgfSkpO1xcbiAgICAgICAgbGV0IGUgPSBEYXRlLm5vdygpO1xcbiAgICAgICAgbGV0IGMgPSBlIC0gcztcXG4gICAgICAgIGlmIChvYmoudXJsLmluY2x1ZGVzKFxcXCJnaXRodWIuY29tXFxcIikgJiYgai5zdGF0dXNDb2RlID09IDIwMCkge1xcbiAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgIHZhciBodG1sID0gai5ib2R5O1xcbiAgICAgICAgICAgIHZhciBqc29uID0gSlNPTi5wYXJzZShwZGZoKGh0bWwsIFxcXCIjcmVwby1jb250ZW50LXBqYXgtY29udGFpbmVyJiZzY3JpcHQmJkh0bWxcXFwiKSk7XFxuICAgICAgICAgICAgbGV0IGxpc3QgPSBqc29uLnBheWxvYWQudHJlZS5pdGVtcztcXG4gICAgICAgICAgICBjb3VudCA9IGxpc3QuZmlsdGVyKHggPT4geC5uYW1lLmVuZHNXaXRoKFxcXCIuanNcXFwiKSkubGVuZ3RoO1xcbiAgICAgICAgICB9IGNhdGNoIHsgfVxcbiAgICAgICAgfVxcbiAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgbGV0IGpzb24gPSBKU09OLnBhcnNlKHRvQ29ycmVjdEpTT05TdHJpbmcoai5ib2R5KSB8fCBcXFwie31cXFwiKTtcXG4gICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkoanNvbi5zaXRlcykgfHwganNvbi5zaXRlcy5sZW5ndGgpIHtcXG4gICAgICAgICAgICBjb3VudCA9IGZpbHRlck90aGVyKGpzb24uc2l0ZXMpLmxlbmd0aDtcXG4gICAgICAgICAgfVxcbiAgICAgICAgfSBjYXRjaCAoZSkgeyB9XFxuXFxuICAgICAgICByZXR1cm4ge1xcbiAgICAgICAgICB0aW1lOiBjLFxcbiAgICAgICAgICB1cmw6IGoudXJsLFxcbiAgICAgICAgICBjb3VudDogY291bnQsXFxuICAgICAgICAgIGNvZGU6IGouc3RhdHVzQ29kZSxcXG4gICAgICAgICAgaW5kZXg6IG9iai5pLFxcbiAgICAgICAgfVxcbiAgICAgIH07XFxuICAgICAgbGV0IHRhc2tzID0gbGlzdC5tYXAoKHgsIGkpID0+IHtcXG4gICAgICAgIGkgPSBpICsgMTtcXG4gICAgICAgIHJldHVybiB7XFxuICAgICAgICAgIGZ1bmM6IHRhc2ssXFxuICAgICAgICAgIHBhcmFtOiB7XFxuICAgICAgICAgICAgdXJsOiB4LFxcbiAgICAgICAgICAgIGk6IGkgLSAxLFxcbiAgICAgICAgICB9LFxcbiAgICAgICAgICBpZDogJ3Rhc2tpZCcgKyBpXFxuICAgICAgICB9XFxuICAgICAgfSk7XFxuICAgICAgdmFyIGNvdW50ID0gc3VjY2VzcyA9IHRhc2tzLmxlbmd0aDtcXG4gICAgICBiZSh0YXNrcywge1xcbiAgICAgICAgZnVuYzogZnVuY3Rpb24gKG9iaiwgaWQsIGVycm9yLCB0YXNrUmVzdWx0KSB7XFxuICAgICAgICAgIG9iai5yZXN1bHRzLnB1c2godGFza1Jlc3VsdClcXG4gICAgICAgICAgY291bnQgPSBjb3VudCAtIDE7XFxuICAgICAgICAgIGlmIChjb3VudCA+IDApIHtcXG4gICAgICAgICAgICBzaG93TG9hZGluZyhcXFwi5qOA5rWL5LitLi4u5Ymp5L2Z5Zyw5Z2A77yaXFxcIiArIGNvdW50KVxcbiAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGhpZGVMb2FkaW5nKCk7XFxuICAgICAgICAgIH1cXG4gICAgICAgIH0sXFxuICAgICAgICBwYXJhbToge1xcbiAgICAgICAgICBoaTogJ2NjYycsXFxuICAgICAgICAgIHJlc3VsdHM6IHJlc3VsdHNcXG4gICAgICAgIH1cXG4gICAgICB9LCBzdWNjZXNzKTtcXG4gICAgICAvL2xvZyhyZXN1bHRzKVxcbiAgICAgIHJlc3VsdHMgPSByZXN1bHRzLmZpbHRlcihmID0+IGYpO1xcbiAgICAgIHJlc3Vsd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ICAgY2xpY2soYSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGlucHV0Qm94LnNldERlZmF1bHRWYWx1ZShcXFwiW1xcXCIgKyBhICsgXFxcIl1cXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICB0aXRsZVZpc2libGU6IHRydWVcXG4gICAgICAgIH0pKSxcXG4gICAgICAgIGxvbmdDbGljayhzLCBpKSB7XFxuICAgICAgICAgICAgc2hvd1NlbGVjdE9wdGlvbnMoe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuWIhuS6q+inhumikea6kFxcXCIsXFxuICAgICAgICAgICAgICAgIG9wdGlvbnM6IFtcXFwiSlPmlofku7bliIbkuqtcXFwiXS5jb25jYXQoZ2V0UGFzdGVzKCkpLFxcbiAgICAgICAgICAgICAgICBjb2w6IDIsXFxuICAgICAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKG5hbWUgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcXFwicnVudGltZUNvbmZpZ1xcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHNvdXJjZXMgPSBydW50aW1lQ29uZmlnLmdldEFsbFNvdXJjZSgpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHNvdXJjZSA9IHNvdXJjZXMuZmluZCh2ID0+IHYubmFtZSA9PSBuYW1lKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBwYXRoID0gcnVudGltZUNvbmZpZy5nZXRBYnNvbHV0ZVBhdGgoc291cmNlLmV4dCk7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcG5hbWUgPSBwYXRoLnNwbGl0KFxcXCIvXFxcIikuYXQoLTEpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGUgPSBmZXRjaChwYXRoKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBlbmNvZGVNb2RlID0gZ2V0SXRlbShcXFwic2hhcmVfZW5jb2RlXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKGVuY29kZU1vZGUgJiYgL3ZhciBydWxlfFtcXFxcdTRFMDAtXFxcXHU5RkE1XSt8ZnVuY3Rpb258bGV0IHx2YXIgfGNvbnN0IHxcXFxcKHxcXFxcKXxcXFwifCcvLnRlc3QocnVsZSkpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoZW5jb2RlTW9kZSA9PT0gXFxcIkd6aXBcXFwiKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBHWklQID0gJC5yZXF1aXJlKFxcXCJHWklQXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJ1bGUgPSBHWklQLnppcChydWxlKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGVuY29kZU1vZGUgPT09IFxcXCJCYXNlNjRcXFwiKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJ1bGUgPSBiYXNlNjRFbmNvZGUocnVsZSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChlbmNvZGVNb2RlID09PSBcXFwiQUVTXFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBDcnlwdG9VdGlsID0gJC5yZXF1aXJlKFxcXCJoaWtlcjovL2Fzc2V0cy9jcnlwdG8tamF2YS5qc1xcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQga2V5ID0gQ3J5cHRvVXRpbC5EYXRhLnBhcnNlSGV4KFxcXCI2ODZBNjQ2ODZFNzgwQTBBMEEwQTBBMEEwQTBBMEEwQVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgaXYgPSBDcnlwdG9VdGlsLkRhdGEucGFyc2VIZXgoXFxcIjY0N0E3OTc5NjQ3MzBBMEEwQTBBMEEwQTBBMEEwQTBBXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCB0ZXh0RGF0YSA9IENyeXB0b1V0aWwuRGF0YS5wYXJzZVVURjgocnVsZSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBlbmNyeXB0ZWQwID0gQ3J5cHRvVXRpbC5BRVMuZW5jcnlwdCh0ZXh0RGF0YSwga2V5LCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtb2RlOiBcXFwiQUVTL0NCQy9QS0NTN1BhZGRpbmdcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaXY6IGl2XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBydWxlID0gZW5jcnlwdGVkMC50b0Jhc2U2NChfYmFzZTY0Lk5PX1dSQVApO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIGlmICghcnVsZSkgcmV0dXJuIFxcXCJ0b2FzdDovL+iOt+WPluWksei0pVxcXCI7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoTVlfSU5ERVggPT09IDApIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB3cml0ZUZpbGUoXFxcImhpa2VyOi8vZmlsZXMvX2NhY2hlL1xcXCIgKyBwbmFtZSwgcnVsZSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJzaGFyZTovL2hpa2VyOi8vZmlsZXMvX2NhY2hlL1xcXCIgKyBwbmFtZTtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHVybCA9IHNoYXJlUGFzdGUoYmFzZTY0RW5jb2RlKHJ1bGUpLCBpbnB1dCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJjb3B5Oi8v5rW36ZiU6KeG55WM77yMRFJQWeinhumikea6kOOAjFxcXCIgKyBuYW1lICsgXFxcIuOAjeWkjeWItuaVtOadoeWPo+S7pOaJk+W8gOi9r+S7tuWwseS8muiHquWKqOWvvOWFpSRcXFwiICsgdXJsICsgXFxcIiRcXFwiICsgcG5hbWUgKyBcXFwiQGltcG9ydD1qczokLnJlcXVpcmUoJ2ltcG9ydD9ydWxlPScrXFxcIiArIEpTT04uc3RyaW5naWZ5KE1ZX1JVTEUudGl0bGUpICsgXFxcIikoaW5wdXQsIHRydWUpXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfSwgcy5yZXBsYWNlKC9b4oCZ4oCYXS9nLCBcXFwiXFxcIikpXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9LFxcbiAgICAgICAgY2xpY2socywgaSwgbWFuYWdlKSB7XFxuICAgICAgICAgICAgcG9wLmRpc21pc3MoKTtcXG4gICAgICAgICAgICBzZXRJdGVtKFxcXCJub19sb2FkaW5nXFxcIiwgXFxcIjFcXFwiKTtcXG4gICAgICAgICAgICAvLyBtYW5hZ2UubGlzdC5mb3JFYWNoKCh2LCBpaSkgPT4gKFxcbiAgICAgICAgICAgIC8vICAgbWFuYWdlLmxpc3RbaWldID0gaSA9PT0gaWkgPyBcXFwi4oCY4oCYXFxcIiArIG5hbWVzW2lpXSArIFxcXCLigJnigJlcXFwiIDogbmFtZXNbaWldLnJlcGxhY2UoL1vigJnigJhdL2csIFxcXCJcXFwiKVxcbiAgICAgICAgICAgIC8vICkpO1xcbiAgICAgICAgICAgIGxldCBuYW1lID0gbWFuYWdlLmxpc3RbaV0ucmVwbGFjZSgvW+KAmeKAmF0vZywgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgIGlmIChuYW1lID09IHNvdXJjZS5uYW1lKSB7XFxuICAgICAgICAgICAgICAgIHJlZ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xcIikgPT0gXFxcIlxcXCIgPyBcXFwi5YWz6ZetXFxcIiA6IFxcXCLlkK/nlKhcXFwiKSwgXFxcIuWIt+aWsOmFjee9rlxcXCIsIFxcXCLliIbkuqvml7bnvJbnoIE6XFxcIiArIGdldEl0ZW0oXFxcInNoYXJlX2VuY29kZVxcXCIsIFxcXCLkuI3nvJbnoIFcXFwiKV0sXFxuICAgICAgICAgICAgICAgIGNvbHVtbnM6IDIsXFxuICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi6K+36YCJ5oupXFxcIixcXG4gICAgICAgICAgICAgICAgY2xpY2socywgaSkge1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKHMgPT0gXFxcIuaUueWPmOagt+W8j1xcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBzcGVuID0gc3BlbiA9PSAzID8gMSA6IChzcGVuID09IDIgPyAzIDogMik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmNoYW5nZUNvbHVtbnMoc3Blbik7XFxuICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHMuaW5jbHVkZXMoXFxcIuWAkuW6j1xcXCIpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QucmV2ZXJzZSgpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIG5hbWVzLnJldmVyc2UoKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHMuaW5jbHVkZXMoXFxcIuiHqueEtuaOkuW6j1xcXCIpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGxpc3QgPSBPYmplY3QuYXNzaWduKFtdLCBtYW5hZ2UubGlzdCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IG5hdHVyYWwgPSBnZXRJdGVtKFxcXCJuYXR1cmFsXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChuYXR1cmFsID09IFxcXCJcXFwiKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0Lmxlbmd0aCA9IDA7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5hdHVyYWxTb3J0KGxpc3QpLmZvckVhY2goeCA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5wdXNoKHgpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0SXRlbShcXFwidXNpbmdzdFxcXCIsIFxcXCJcXFwiKVxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0Lmxlbmd0aCA9IDA7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNuYW1lLmZvckVhY2goeCA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5wdXNoKHgpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgc2V0SXRlbShcXFwibmF0dXJhbFxcXCIsIG5hdHVyYWwgPyBcXFwiXFxcIiA6IFxcXCIxXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHMuaW5jbHVkZXMoXFxcIuS9v+eUqOaOkuW6j1xcXCIpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGxpc3QgPSBPYmplY3QuYXNzaWduKFtdLCBtYW5hZ2UubGlzdCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHVzaW5nc3QgPSBnZXRJdGVtKFxcXCJ1c2luZ3N0XFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh1c2luZ3N0ID09IFxcXCJcXFwiKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0Lmxlbmd0aCA9IDA7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVzaW5nU29ydC5nZXQobGlzdCkuZm9yRWFjaCh4ID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnB1c2goeCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJuYXR1cmFsXFxcIiwgXFxcIlxcXCIpXFxuICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QubGVuZ3RoID0gMDtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc25hbWUuZm9yRWFjaCh4ID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnB1c2goeCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJ1c2luZ3N0XFxcIiwgdXNpbmdzdCA/IFxcXCJcXFwiIDogXFxcIjFcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAocyA9PSBcXFwi5Yi35paw6YWN572uXFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGFycmF5RGlmZmVyZW5jZShhcnIxLCBhcnIyKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG1hcCA9IG5ldyBNYXAoYXJyMi5tYXAoaXRlbSA9PiBbaXRlbS5rZXksIGl0ZW1dKSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBhcnIxLmZpbHRlcihpdGVtID0+ICFtYXAuaGFzKGl0ZW0ua2V5KSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgfVxcblxcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBydW50aW1lQ29uZmlnID0gR00uZGVmaW5lTW9kdWxlKFxcXCJydW50aW1lQ29uZmlnXFxcIiwgXFxcInJ1bnRpbWVDb25maWdcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgbGlzdCA9IHJ1bnRpbWVDb25maWcuZ2V0QWxsU291cmNlKCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IENrZXkgPSBydW50aW1lQ29uZmlnLmdldEN1cnJlbnRTb3VyY2UoKS5rZXk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgLy9sb2coQ2tleSlcXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgY2ZnID0gcnVudGltZUNvbmZpZy5nZXRDdXJyZW50Q29uZmlnKClcXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXRoLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBuYW1lXFxuICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGNmZztcXG4gICAgICAgICAgICAgICAgICAgICAgICBydW50aW1lQ29uZmlnLnNldEN1cnJlbnRDb25maWcoe1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXRoLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBuYW1lLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJ1bnRpbWVDb25maWcuc2V0Q3VycmVudFNvdXJjZShDa2V5KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgbnNvdXJjZXMgPSBydW50aW1lQ29uZmlnLmdldEFsbFNvdXJjZSgpO1xcblxcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBhbGlzdCA9IGFycmF5RGlmZmVyZW5jZShuc291cmNlcywgbGlzdCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGRsaXN0ID0gYXJyYXlEaWZmZXJlbmNlKGxpc3QsIG5zb3VyY2VzKTtcXG5cXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoYWxpc3QubGVuZ3RoID4gMCB8fCBkbGlzdC5sZW5ndGggPiAwKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBtc2cgPSBcXFwiXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFsaXN0Lmxlbmd0aCA+IDApIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFsaXN0LmZvckVhY2goeCA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QucHVzaCh4Lm5hbWUpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvZyhcXFwi5paw5aKeOlxcXCIgKyBhbGlzdC5tYXAoayA9PiBrLm5hbWUpLmpvaW4oXFxcIixcXFwiKSlcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1zZyArPSBcXFwi5paw5aKeXFxcIiArIGFsaXN0Lmxlbmd0aCArIFxcXCLkuKrmupBcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkbGlzdC5sZW5ndGggPiAwKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkbGlzdC5mb3JFYWNoKHggPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnNwbGljZShtYW5hZ2UubGlzdC5pbmRleE9mKHgubmFtZSksIDEpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvZyhcXFwi56e76ZmkOlxcXCIgKyBkbGlzdC5tYXAoayA9PiBrLm5hbWUpLmpvaW4oXFxcIixcXFwiKSlcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1zZyArPSBcXFwiIOenu+mZpFxcXCIgKyBkbGlzdC5sZW5ndGggKyBcXFwi5Liq5rqQXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5zZXRUaXRsZShcXFwi6YCJ5oup6KeG6aKR5rqQIOW9k+WJjeWFsTpcXFwiICsgbWFuYWdlLmxpc3QubGVuZ3RoICsgXFxcIuS4quinhumikea6kFxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0b2FzdChtc2cgKyBcXFwiIOabtOWkmuivpuaDheeci2xvZ1xcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRvYXN0KFxcXCLlt7LliLfmlrBcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHNob3dTZWxlY3RPcHRpb25zKHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLnvJbnoIHnsbvlnotcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcHRpb25zOiBbXFxcIuS4jee8lueggVxcXCIsIFxcXCJHemlwXFxcIiwgXFxcIkJhc2U2NFxcXCIsIFxcXCJBRVNcXFwiXSxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29sOiAxLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBqczogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoTVlfSU5ERVggPT09IDApIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGVhckl0ZW0oXFxcInNoYXJlX2VuY29kZVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJzaGFyZV9lbmNvZGVcXFwiLCBpbnB1dCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8vXFxcIiArIGlucHV0O1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfVxcbiAgICB9KTtcXG59XCJ9LHtcImNvbF90eXBlXCI6XCJtb3ZpZV8zXCIsXCJuYW1lXCI6XCJkcnB5566h55CGXCIsXCJwYXRoXCI6XCJEcnB5TWFuYWdlXCIsXCJydWxlXCI6XCJqczpcXG5jb25zdCBKU0VuZ2luZSA9IGNvbS5leGFtcGxlLmhpa2Vydmlldy5zZXJ2aWNlLnBhcnNlci5KU0VuZ2luZTtcXG5jb25zdCBydW50aW1lQ29uZmlnID0gR00uZGVmaW5lTW9kdWxlKFxcXCJydW50aW1lQ29uZmlnXFxcIik7XFxuY29uc3QgZHJweU1hc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S2V5KCkpO1xcbiAgICAgICAgICAgICAgICBwdXRNeVZhcihcXFwiUHJveHlfVXJsXFxcIiwgcHJveHlVcmwpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcXG5cXG4gICAgICAgIH1cXG4gICAgICAgIHJldHVybiBkcnB5O1xcbiAgICB9LCB0aGlzKS5jYWxsKCk7XFxufVxcbi8vc291cmNlLmV4dOW/hemhu+S4uue7neWvuei3r+W+hFxcbmZ1bmN0aW9uIGdldEJ5U291cmNlKHNvdXJjZSkge1xcbiAgICByZXR1cm4gc3luYygoKSA9PiB7XFxuICAgICAgICBsZXQga2V5ID0gc291cmNlLmtleTtcXG4gICAgICAgIC8vbG9nKGRycHlNYXAuc2l6ZSlcXG4gICAgICAgIGlmIChkcnB5TWFwLmhhcyhrZXkpKSB7XFxuICAgICAgICAgICAgcmV0dXJuIGRycHlNYXAuZ2V0KGtleSk7XFxuICAgICAgICB9XFxuICAgICAgICBpZiAoZHJweU1hcC5zaXplID49IDUpIHtcXG4gICAgICAgICAgICAvL2xvZyhcXFwi6K+35rGCOlxcXCIgKyBrZXkpXFxuICAgICAgICAgICAgZGVsKEFycmF5LmZyb20oZHJweU1hcC5rZXlzKCkpLmF0KDApKTtcXG4gICAgICAgIH1cXG4gICAgICAgIGNyZWF0ZURycHkoa2V5KTtcXG4gICAgICAgIGxldCBkcnB5ID0gZHJweU1hcC5nZXQoa2V5KTtcXG4gICAgICAgIGRycHkuaW5pdChzb3VyY2UuZXh0KTtcXG4gICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgaWYgKGRycHkuZ2V0UnVsZShcXFwicHJveHlfcnVsZVxcXCIpKSB7XFxuICAgICAgICAgICAgICAgIGxldCBQcm94eSA9ICQucmVxdWlyZShcXFwiTG9jYWxQcm94eVxcXCIpO1xcbiAgICAgICAgICAgICAgICBsZXQgcHJveHlVcmwgPSBQcm94eS5zdGFydFByb3h5KE1ZX1JVTEUudGl0bGUsIEdNLmdldFNlbGZLZXkoKSk7XFxuICAgICAgICAgICAgICAgIHB1dE15VmFyKFxcXCJQcm94eV9VcmxcXFwiLCBwcm94eVVybCk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSBjYXRjaCAoZSkge1xcblxcbiAgICAgICAgfVxcbiAgICAgICAgcmV0dXJuIGRycHk7XFxuICAgIH0sIHRoaXMpLmNhbGwoKTtcXG59XFxuXFxuZnVuY3Rpb24gcHV0KGtleSwgZHJweSkge1xcbiAgICBzeW5jKCgpID0+IGRycHlNYXAuc2V0KGtleSwgZHJweSksIHRoaXMpLmNhbGwoKTtcXG59XFxuXFxuZnVuY3Rpb24gcnVuUHJveHkoZHJweSwgYXJncykge1xcbiAgICBpZiAodHlwZW9mIGRycHkucHJveHkgPT09IFxcXCJmdW5jdGlvblxcXCIpIHtcXG4gICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgLy9sZXQgdGltZTEgPSBEYXRlLm5vdygpO1xcbiAgICAgICAgICAgIHByb3h5U2VtYXBob3JlLmFjcXVpcmUoKTtcXG4gICAgICAgICAgICAvL2xldCB0aW1lMiA9IERhdGUubm93KCk7XFxuICAgICAgICAgICAgLy9sb2coXFxcIjHnrYnlvoXml7bpl7Q6XFxcIiArICh0aW1lMiAtIHRpbWUxKSArIFxcXCJtc1xcXCIpO1xcbiAgICAgICAgICAgIGxldCByZXMgPSBkcnB5LnByb3h5LmFwcGx5KGRycHksIGFyZ3MpO1xcbiAgICAgICAgICAgIC8vbGV0IHRpbWUzID0gRGF0ZS5ub3coKTtcXG4gICAgICAgICAgICAvL2xvZyhcXFwiMuaJp+ihjOS7o+eQhuiAl+aXtjpcXFwiICsgKHRpbWUzIC0gdGltZTIpICsgXFxcIm1zXFxcIik7XFxuICAgICAgICAgICAgLy9sb2coXFxcIjPmgLvogJfml7bogJfml7Y6XFxcIiArICh0aW1lMyAtIHRpbWUxKSArIFxcXCJtc1xcXCIpO1xcblxcbiAgICAgICAgICAgIHJldHVybiByZXM7XF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blNlYXJjaFNvdXJjZS5sZW5ndGg7XFxuICAgIH1cXG5cXG4gICAgbGV0IHNlYXJjaEtleSA9IFxcXCJcXFwiO1xcbiAgICBoaWtlclBvcC5zZWxlY3RCb3R0b21SZXMoe1xcbiAgICAgICAgb3B0aW9uczogZ2V0TmFtZXMoKSxcXG4gICAgICAgIGNvbHVtbnM6IHNwZW4sXFxuICAgICAgICB0aXRsZTogXFxcIuWQr+eUqOaQnOe0oua6kDpcXFwiICsgc2VhcmNob25jb3VudCArIFxcXCLkuKog5YWxOlxcXCIgKyBjYW5TZWFyY2hTb3VyY2UubGVuZ3RoICsgXFxcIuS4quaQnOe0oua6kFxcXCIsXFxuICAgICAgICBub0F1dG9EaXNtaXNzOiB0cnVlLFxcbiAgICAgICAgcG9zaXRpb246IDEsXFxuICAgICAgICBoZWlnaHQ6IC45LFxcbiAgICAgICAgZXh0cmFJbnB1dEJveDogbmV3IGhpa2VyUG9wLlJlc0V4dHJhSW5wdXRCb3goe1xcbiAgICAgICAgICAgIGhpbnQ6IFxcXCLmupDlhbPplK7lrZcg5aSa5Liq55SofOmalOW8gFxcXCIsXFxuICAgICAgICAgICAgdGl0bGU6IFxcXCJva1xcXCIsXFxuICAgICAgICAgICAgb25DaGFuZ2UodGV4dCwgbWFuYWdlKSB7XFxuICAgICAgICAgICAgICAgIC8vbG9nKFxcXCJvbkNoYW5nZTpcXFwiK3RleHQpXFxuICAgICAgICAgICAgICAgIHNlYXJjaEtleSA9IHRleHQ7XFxuICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0Lmxlbmd0aCA9IDA7XFxuICAgICAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UubGVuZ3RoID0gMDtcXG4gICAgICAgICAgICAgICAgaWYgKHRleHQpIHtcXG4gICAgICAgICAgICAgICAgICAgIGNhblNlYXJjaFNvdXJjZS5mb3JFYWNoKCh2LCBpKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRleHQuc3BsaXQoL1xcXFx8LykuZmlsdGVyKGYgPT4gZikuc29tZSh4ID0+IHYubmFtZS5pbmNsdWRlcyh4KSkpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZHluYW1pY1NvdXJjZS5wdXNoKHYpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5wdXNoKHNlYXJjaEFsbG93LmluY2x1ZGVzKHYua2V5KSA/IFxcXCLigJzigJzigJ3igJ1cXFwiICsgKHYubmFtZSArIFxcXCJcXFwiKS5mb250Y29sb3IoXFxcIiMwMDk5NjZcXFwiKSA6IHYubmFtZSlcXG4gICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UgPSBjYW5TZWFyY2hTb3VyY2Uuc2xpY2UoKTtcXG4gICAgICAgICAgICAgICAgICAgIE9iamVjdC5hc3NpZ24obWFuYWdlLmxpc3QsIGdldE5hbWVzKCkpO1xcblxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgICB9LFxcbiAgICAgICAgICAgIGRlZmF1bHRWYWx1ZTogXFxcIlxcXCIsXFxuICAgICAgICAgICAgY2xpY2socywgbWFuYWdlKSB7XFxuICAgICAgICAgICAgICAgIC8vdG9hc3Qocyk7XFxuICAgICAgICAgICAgICAgIC8vbG9nKG1hbmFnZS5saXN0KTtcXG4gICAgICAgICAgICB9LFxcbiAgICAgICAgICAgIHRpdGxlVmlzaWJsZTogZmFsc2VcXG4gICAgICAgIH0pLFxcbiAgICAgICAgY2xpY2socywgaSwgbWFuYWdlKSB7XFxuXFxuICAgICAgICAgICAgbGV0IGtleSA9IGR5bmFtaWNTb3VyY2VbaV0ua2V5O1xcbiAgICAgICAgICAgIGxldCBpbmRleCA9IC0xO1xcbiAgICAgICAgICAgIGlmICgoaW5kZXggPSBzZWFyY2hBbGxvdy5pbmRleE9mKGtleSkpICE9PSAtMSkge1xcbiAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdFtpXSA9IGR5bmFtaWNTb3VyY2VbaV0ubmFtZTtcXG4gICAgICAgICAgICAgICAgc2VhcmNoQWxsb3cuc3BsaWNlKGluZGV4LCAxKTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdFtpXSA9IFxcXCLigJzigJzigJ3igJ1cXFwiICsgKGR5bmFtaWNTb3VyY2VbaV0ubmFtZSArIFxcXCJcXFwiKS5mb250Y29sb3IoXFxcIiMwMDk5NjZcXFwiKTtcXG4gICAgICAgICAgICAgICAgc2VhcmNoQWxsb3cucHVzaChrZXkpO1xcbiAgICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgICBydW50aW1lQ29uZmlnLnNldFNlYXJjaEFsbG93KCk7XFxuICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcbiAgICAgICAgfSxcXG4gICAgICAgIG1lbnVDbGljayhtYW5hZ2UpIHtcXG4gICAgICAgICAgICBoaWtlclBvcC5zZWxlY3RDZW50ZXIoe1xcbiAgICAgICAgICAgICAgICBvcHRpb25zOiBbXFxcIuaUueWPmOagt+W8j1xcXCIsIFxcXCLnrZvpgInmupBcXFwiLCBcXFwi6Ieq54S25o6S5bqPXFxcIiwgXFxcIuWAkuW6j1xcXCIsIFxcXCLlhajpgIlcXFwiLCBcXFwi5Y+N6YCJXFxcIl0sXFxuICAgICAgICAgICAgICAgIGNvbHVtbnM6IDIsXFxuICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi6K+36YCJ5oupXFxcIixcXG4gICAgICAgICAgICAgICAgY2xpY2socywgaSkge1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKGkgPT09IDApIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBzcGVuID0gc3BlbiA9PSAzID8gMSA6IChzcGVuID09IDIgPyAzIDogMik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmNoYW5nZUNvbHVtbnMoc3Blbik7XFxuICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGkgPT09IDEpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBoaWtlclBvcC5pbnB1dENvbmZpcm0oe1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250ZW50OiBcXFwi6L6T5YWl5YWz6ZSu5a2XIOepuuaYvuekuuWFqOmDqFxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi562b6YCJ5rqQXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaGludDogXFxcIua6kOWFs+mUruWtlyDlpJrkuKrnlKh86ZqU5byAXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdFZhbHVlOiBzZWFyY2hLZXksXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRleHRhcmVhOiBmYWxzZSwgLy/lpJrooYzmqKHlvI9cXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbWF4VGV4dGFyZWE6IHRydWUsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5vQXV0b1NvZnQ6IGZhbHNlLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvL2hpZGVDYW5jZWw6IHRydWUsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbmZpcm0odGV4dCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VhcmNoS2V5ID0gdGV4dDtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0Lmxlbmd0aCA9IDA7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkeW5hbWljU291cmNlLmxlbmd0aCA9IDA7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGV4dCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhblNlYXJjaFNvdXJjZS5mb3JFYWNoKCh2LCBpKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0ZXh0LnNwbGl0KC9cXFxcfC8pLmZpbHRlcihmID0+IGYpLnNvbWUoeCA9PiB2Lm5hbWUuaW5jbHVkZXMoeCkpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkeW5hbWljU291cmNlLnB1c2godik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5wdXNoKHNlYXJjaEFsbG93LmluY2x1ZGVzKHYua2V5KSA/IFxcXCLigJzigJzigJ3igJ1cXFwiICsgKHYubmFtZSArIFxcXCJcXFwiKS5mb250Y29sb3IoXFxcIiMwMDk5NjZcXFwiKSA6IHYubmFtZSlcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkeW5hbWljU291cmNlID0gY2FuU2VhcmNoU291cmNlLnNsaWNlKCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgT2JqZWN0LmFzc2lnbihtYW5hZ2UubGlzdCwgZ2V0TmFtZXMoKSk7XFxuXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvL3JldHVybiBcXFwidG9hc3Q6Ly/ovpPlhaXkuoZcXFwiICsgdGV4dDtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSxcXG5cXG4gICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaSA9PT0gMikge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBsaXN0ID0gT2JqZWN0LmFzc2lnbihbXSwgbWFuYWdlLmxpc3QpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0Lmxlbmd0aCA9IDA7XFxuXFxuXFxuICAgICAgICAgICAgICAgICAgICAgICAgZHluYW1pY1NvdXJjZS5zb3J0KChhLCBiKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBTdHJpbmcoYS5uYW1lKS5sb2NhbGVDb21wYXJlKFN0cmluZyhiLm5hbWUpLCB1bmRlZmluZWQsIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG51bWVyaWM6IHRydWUsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZW5zaXRpdml0eTogJ2Jhc2UnXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIE9iamVjdC5hc3NpZ24obWFuYWdlLmxpc3QsIGdldE5hbWVzKCkpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaSA9PSAzKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QucmV2ZXJzZSgpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UucmV2ZXJzZSgpO1xcblxcbiAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaSA9PSA0KSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgZHluYW1pY1NvdXJjZS5mb3JFYWNoKHYgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXNlYXJjaEFsbG93LmluY2x1ZGVzKHYpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWFyY2hBbGxvdy5wdXNoKHYua2V5KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIE9iamVjdC5hc3NpZ24obWFuYWdlLmxpc3QsIGdldE5hbWVzKCkpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJ1bnRpbWVDb25maWcuc2V0U2VhcmNoQWxsb3coKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGkgPT0gNSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB0ZW1saXN0ID0gc2VhcmNoQWxsb3cuc2xpY2UoKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBzZWFyY2hBbGxvdy5sZW5ndGggPSAwO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UuZm9yRWFjaCh2ID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRlbWxpc3QuaW5jbHVkZXModi5rZXkpKSByZXR1cm47XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlYXJjaEFsbG93LnB1c2godi5rZXkpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIE9iamVjdC5hc3NpZ24obWFuYWdlLmxpc3QsIGdldE5hbWVzKCkpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJ1bnRpbWVDb25maWcuc2V0U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dGVyX2RlZlxcXCIsIHt9KTtcXG4gICAgICBjbGFzc2lmeS5mb3JFYWNoKCh4LCBpbmRleCkgPT4ge1xcbiAgICAgICAgbGF5b3V0LnB1c2goe1xcbiAgICAgICAgICBjb2xfdHlwZTogJ2JsYW5rX2Jsb2NrJ1xcbiAgICAgICAgfSlcXG4gICAgICAgIHgudmFsdWUuZm9yRWFjaCgoaXQsIGkpID0+IHtcXG4gICAgICAgICAgbGV0IHQgPSBpdC5uO1xcbiAgICAgICAgICBpZiAoY2F0ZV90ZW1wW2luZGV4XSA9PSBpKSB7XFxuICAgICAgICAgICAgdCA9IFxcXCI8Yj48Zm9udCBjb2xvcj1cXFwiICsgY29sb3IgKyBcXFwiPlxcXCIgKyB0ICsgXFxcIjwvZm9udD48L2I+XFxcIjtcXG4gICAgICAgICAgICBmbFt4LmtleV0gPSBpdC52O1xcbiAgICAgICAgICB9XFxuICAgICAgICAgIGlmIChjYXRlX3RlbXBbaW5kZXhdID09IFxcXCItMVxcXCIpIHtcXG4gICAgICAgICAgICBmbFt4LmtleV0gPSBcXFwidW5kZWZpbmVkXFxcIjtcXG4gICAgICAgICAgfVxcbiAgICAgICAgICBpZiAoZm9sZCA9PSAxKSB7XFxuICAgICAgICAgICAgbGF5b3V0LnB1c2goe1xcbiAgICAgICAgICAgICAgdGl0bGU6ICfigJzigJzigJ3igJ0nICsgdCxcXG4gICAgICAgICAgICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgobykgPT4ge1xcbiAgICAgICAgICAgICAgICBsZXQgaSA9IG8uaTtcXG4gICAgICAgICAgICAgICAgc3RvcmFnZTAucHV0TXlWYXIoXFxcImlzX2RlZlxcXCIsIFxcXCIxXFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCBjYXRlX29iaiA9IHN0b3JhZ2UwLmdldE15VmFyKFxcXCJjYXRlX29ialxcXCIsIHt9KTtcXG5cXG4gICAgICAgICAgICAgICAgbGV0IGNhdGVfdGVtcCA9IG8uY2F0ZV90ZW1wO1xcbiAgICAgICAgICAgICAgICBpZiAoY2F0ZV90ZW1wLmNvbnN0cnVjdG9yICE9IEFycmF5KSB7XFxuICAgICAgICAgICAgICAgICAgY2F0ZV90ZW1wID0gW107XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgbGV0IGluZGV4ID0gby5pbmRleDtcXG4gICAgICAgICAgICAgICAgbGV0IGMgPSBjYXRlX3RlbXBbaW5kZXhdIHx8IFxcXCItMVxcXCI7XFxuICAgICAgICAgICAgICAgIC8vbG9nKGMpXFxuICAgICAgICAgICAgICAgIGlmIChjID09IGkpIHtcXG4gICAgICAgICAgICAgICAgICBvLmNhdGVfdGVtcFtpbmRleF0gPSBcXFwiLTFcXFwiO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgIG8uY2F0ZV90ZW1wW2luZGV4XSA9IGkgKyBcXFwiXFxcIjtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBjYXRlX29ialtvLmNhdGVdID0gY2F0ZV90ZW1wO1xcbiAgICAgICAgICAgICAgICAvL2xvZyhjYXRlX3RlbXApXFxuICAgICAgICAgICAgICAgIC8vc3RvcmFnZTAucHV0TXlWYXIoXFxcImNhdGVfdGVtcFxcXCIsIGNhdGVfdGVtcCk7XFxuICAgICAgICAgICAgICAgIHN0b3JhZ2UwLnB1dE15VmFyKFxcXCJjYXRlX29ialxcXCIsIGNhdGVfb2JqKTtcXG4gICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICAgIH0sIHtcXG4gICAgICAgICAgICAgICAgaW5kZXg6IGluZGV4LFxcbiAgICAgICAgICAgICAgICBjYXRlX3RlbXA6IGNhdGVfdGVtcCxcXG4gICAgICAgICAgICAgICAgaTogaSxcXG4gICAgICAgIC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RS50aXRsZSArIFxcXCImcz1cXFwiICsgbmFtZTtcXG4gICAgICAgICAgICAgICAgfSwgbmFtZSk7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChza2lwRXIpIHtcXG4gICAgICAgICAgICAgICAgdXJsID0gJCgpLmxhenlSdWxlKChzb3VyY2UsIGlkKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICB1cmwgPSBpZC5zcGxpdChcXFwiQEBcXFwiKVswXTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiAkLnJlcXVpcmUoXFxcInZpZGVvVXJsXFxcIikucGFyc2UodXJsLCBpZCwgc291cmNlKTtcXG4gICAgICAgICAgICAgICAgfSwgc291cmNlLCBpZCk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBuYW1lLFxcbiAgICAgICAgICAgICAgICBkZXNjOiBpdC52b2RfcmVtYXJrcyxcXG4gICAgICAgICAgICAgICAgdXJsOiB1cmwsXFxuICAgICAgICAgICAgICAgIHBpY191cmw6IGl0LnZvZF9waWMsXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBob21lTGlzdENvbCxcXG4gICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgIGltZzogaXQudm9kX3BpYyxcXG4gICAgICAgICAgICAgICAgICAgIHZvZElkOiBpZCxcXG4gICAgICAgICAgICAgICAgICAgIHNuYW1lOiBzb3VyY2UubmFtZSxcXG4gICAgICAgICAgICAgICAgICAgIHNrZXk6IHNvdXJjZS5rZXksXFxuICAgICAgICAgICAgICAgICAgICBpZDogaWQsXFxuICAgICAgICAgICAgICAgICAgICBsb25nQ2xpY2s6IFt7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLogZrlkIjmkJzntKJcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGpzOiBcXFwicHV0TXlWYXIoJ3RlbXNtb2RlJ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KSk7XFxuICAgIGxldCBmaWxlU2VsZWN0ID0gJC5yZXF1aXJlKFxcXCJodHRwOi8vaGlrZXIubm9raWEucHJlc3MvaGlrZXJ1bGUvcnVsZWxpc3QuanNvbj9pZD01MDk5XFxcIik7XFxuICAgIGxldCB1aW9iaiA9IFtdO1xcblxcblxcbiAgICB1aW9iai5wdXNoKHtcXG4gICAgICAgIGluZGV4OiAwLFxcbiAgICAgICAga2V5OiBcXFwi5o2i5rqQXFxcIixcXG4gICAgICAgIHRpdGxlOiBcXFwi5o2i5rqQXFxcIixcXG4gICAgICAgIGNvbF90eXBlOiB1aV9jb25maWcuY29sLFxcbiAgICAgICAgaW1nOiAnaHR0cHM6Ly9oaWtlcmZhbnMuY29tL3R1Ymlhby9zeXN0ZW0vMTMwLnBuZycsXFxuICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKCkgPT4ge1xcbiAgICAgICAgICAgICQucmVxdWlyZShcXFwiQ2hhbmdlU291cmNlUG9wXFxcIikuc2hvdygpO1xcbiAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICB9KSxcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgY3BhdGg6IGNvbmZpZy5wYXRoLFxcbiAgICAgICAgICAgIGxvbmdDbGljazogW3tcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLmm7TmjaLphY3nva5cXFwiLFxcbiAgICAgICAgICAgICAgICBqczogSlNPTi5zdHJpbmdpZnkoXFxcImhpa2VyOi8vcGFnZS9jcmVhdGVDb25maWcjbm9SZWNvcmRIaXN0b3J5IyNub0hpc3RvcnkjXFxcIilcXG4gICAgICAgICAgICB9LCB7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi6K6/6Zeu572R56uZXFxcIixcXG4gICAgICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bnRpbWVDb25maWcgPSBHTS5kZWZpbmVNb2R1bGUoXFxcInJ1bnRpbWVDb25maWdcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBzb3VyY2UgPSBydW50aW1lQ29uZmlnLmdldEN1cnJlbnRTb3VyY2UoKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBEcnB5TWFuYWdlID0gR00uZGVmaW5lTW9kdWxlKFxcXCJEcnB5TWFuYWdlXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcIndlYjovL1xcXCIgKyBEcnB5TWFuYWdlLmdldChzb3VyY2Uua2V5KS5nZXRSdWxlKFxcXCJob3N0XFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAvL3JlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgfSwge1xcbiAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuWIt+aWsOa6kFxcXCIsXFxuICAgICAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydW50aW1lQ29uZmlnID0gR00uZGVmaW5lTW9kdWxlKFxcXCJydW50aW1lQ29uZmlnXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgc291cmNlID0gcnVudGltZUNvbmZpZy5nZXRDdXJyZW50U291cmNlKCk7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgRHJweU1hbmFnZSA9IEdNLmRlZmluZU1vZHVsZShcXFwiRHJweU1hbmFnZVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgRHJweU1hbmFnZS5nZXQoc291cmNlLmtleSkuaW5pdChydW50aW1lQ29uZmlnLmdldEFic29sdXRlUGF0aChzb3VyY2UuZXh0KSk7XFxuICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIH0sIHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLph43ovb3mupBcXFwiLFxcbiAgICAgICAgICAgICAgICBqczogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcXFwicnVudGltZUNvbmZpZ1xcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHNvdXJjZSA9IHJ1bnRpbWVDb25maWcuZ2V0Q3VycmVudFNvdXJjZSgpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IERycHlNYW5hZ2UgPSBHTS5kZWZpbmVNb2R1bGUoXFxcIkRycHlNYW5hZ2VcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIERycHlNYW5hZ2UuZGVsKHNvdXJjZS5rZXkpO1xcbiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICB9LCB7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi5p+l55yL5rqQ5Luj56CBXFxcIixcXG4gICAgICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bnRpbWVDb25maWcgPSBHTS5kZWZpbmVNb2R1bGUoXFxcInJ1bnRpbWVDb25maWdcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBzb3VyY2UgPSBydW50aW1lQ29uZmlnLmdldEN1cnJlbnRTb3VyY2UoKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBEcnB5TWFuYWdlID0gR00uZGVmaW5lTW9kdWxlKFxcXCJEcnB5TWFuYWdlXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgY29kZSA9IERycHlNYW5hZ2UuZ2V0KHNvdXJjZS5rZXkpLnJ1bk1haW4oXFxcImxldCBtYWluPVxcXCIgKyAkLnRvU3RyaW5nKChleHQpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gKCkgPT4gZ2V0T3JpZ2luYWxKcyhyZXF1ZXN0KGV4dCwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAnbWV0aG9kJzogJ0dFVCdcXG4gICAgICAgICAgICAgICAgICAgICAgICB9KSk7XFxuICAgICAgICAgICAgICAgICAgICB9LCBydW50aW1lQ29uZmlnLmdldEN1cnJlbnRTb3VyY2VQYXRoKCkpKTtcXG5cXG4gICAgICAgICAgICAgICAgICAgIGxldCBwYXRoID0gXFxcImhpa2VyOi8vZmlsZXMvX2NhY2hlL3ZpZXdTb3VyY2VDb2RlLmpzXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIHdyaXRlRmlsZShwYXRoLCBjb2RlKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiZWRpdEZpbGU6Ly9cXFwiICsgcGF0aDtcXG4gICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICB9XS5jb25jYXQoY29uZmlnLnR5cGUgPT09IFxcXCJsb2NhbERpclxcXCIgPyBbe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogXFxcIue8lui+keWPguaVsOaYoOWwhOihqFxcXCIsXFxuICAgICAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKChwYXRoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBwYXRoKz1cXFwiLy5tYXBwaW5nLnR4dFxcXCI7XFxuICAgICAgICAgICAgICAgICAgICBpZihmaWxlRXhpc3QocGF0aCkpe1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiZWRpdEZpbGU6Ly9cXFwiK3BhdGg7XFxuICAgICAgICAgICAgICAgICAgICB9ZWxzZXtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJChcXFwi5LiN5a2Y5Zyo5pig5bCE5paH5Lu25piv5ZCm5Yib5bu677yfXFxcIikuY29uZmlybShwYXRoPT57XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRlRmlsZShwYXRoLFxcXCJcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJlZGl0RmlsZTovL1xcXCIrcGF0aDtcXG4gICAgICAgICAgICAgICAgICAgICAgICB9LCBwYXRoKTtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfSwgY29uZmlnLnBhdGgpXFxuICAgICAgICAgICAgfSx7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi5pys5Zyw566h55CGXFxcIixcXG4gICAgICAgICAgICAgICAganM6IFxcXCInaGlrZXI6Ly9wYWdlL0xvY2FsRGlyI25vUmVjb3JkSGlzdG9yeSMjbm9IaXN0b3J5IydcXFwiXFxuICAgICAgICAgICAgfV0gOiBbXSlcXG4gICAgICAgIH1cXG4gICAgfSk7XFxuXFxuICAgIHVpb2JqLnB1c2goe1xcbiAgICAgICAgaW5kZXg6IDEsXFxuICAgICAgICBrZXk6IFxcXCLmkJzntKLmqKHlvI9cXFwiLFxcbiAgICAgICAgdGl0bGU6IFtcXFwi6YCJ5LitXFxcIiwgXFxcIuiBmuWQiFxcXCIsIGNvbmZpZy5zVGFnIHx8IFxcXCLml6BUQUdcXFwiXVtzbW9kZV0sXFxuICAgICAgICB1cmw6ICQoJyNub0xvYWRpbmcjJykubGF6eVJ1bGUoKCkgPT4ge1xcbiAgICAgICAgICAgIGxldCBzbW9kZSA9IE51bWJlcihnZXRJdGVtKFxcXCJzbW9kZVxcXCIsIFxcXCIwXFxcIikpO1xcbiAgICAgICAgICAgIHJldHVybiAkKFtcXFwi6YCJ5LitXFxcIiwgXFxcIuiBmuWQiFxcXCIsIFxcXCLmjIlUQUdcXFwiXSwgMSwgXFxcIuaQnOe0ouaooeW8j1xcXCIsIHNtb2RlKS5zZWxlY3QoKHQpID0+IHtcXG4gICAgICAgICAgICAgICAgaWYgKE1ZX0lOREVYID09PSAyKSB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcXFwicnVudGltZUNvbmZpZ1xcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHRhZ0NsYXNzZXMgPSBydW50aW1lQ29uZmlnLmdldFRhZ0NsYXNzZXMoKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBzdGFnID0gcnVudGltZUNvbmZpZy5nZXRTZWFyY2hUYWcoKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBpbmRleCA9IDA7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoIXRhZ0NsYXNzZXMubGVuZ3RoKSByZXR1cm4gXFxcInRvYXN0Oi8v5b2T5YmN6YWN572u5rKh5pyJVEFH5ZOm44CCXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChzdGFnKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgaW5kZXggPSB0YWdDbGFzc2VzLmluZGV4T2Yoc3RhZykgKyAxO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgdGFnQ2xhc3Nlcy51bnNoaWZ0KFxcXCJb5pegVEFHXVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuICQodGFnQ2xhc3NlcywgMywgXFxcIuaQnOe0olRBR1tcXFwiICsgdGFnQ2xhc3Nlcy5sZW5ndGggKyBcXFwiXVxcXCIsIGluZGV4KS5zZWxlY3QoKHQpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcXFwicnVudGltZUNvbmZpZ1xcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB0YWcgPSBNWV9JTkRFWCA9PT0gMCA/IFxcXCJcXFwiIDogaW5wdXQ7XFxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJ1bnRpbWVDb25maWcuc2V0U2VhcmNoVGFnKHRhZykpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0SXRlbShcXFwic21vZGVcXFwiLCBcXFwiMlxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKHQgKyBcXFwiQHNlYXJjaF9tb2RlXFxcIiwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IHRhZyB8fCBcXFwi5pegVEFHXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vcmV0dXJuIFxcXCJcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/orr7nva7lpLHotKVcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIH0sIHQpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIHNldEl0ZW0oXFxcInNtb2RlXFxcIiwgXFxcIlxcXCIgKyBNWV9JTkRFWCk7XFxuICAgICAgICAgICAgICAgIHVwZGF0ZUl0ZW0odCArIFxcXCJAc2VhcmNoX21vZGVcXFwiLCB7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogW1xcXCLpgInkuK1cXFwiLCBcXFwi6IGa5ZCIXFxcIl1bTVlfSU5ERVhdLFxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICB9LCBNWV9SVUxFLnRpdGxlKVxcbiAgICAgICAgfSksXFxuICAgICAgICBpbWc6IFxcXCJodHRwczovL2hpa2VyZmFucy5jb20vdHViaWFvL3N5c3RlbS8xNDkucG5nXFxcIixcXG4gICAgICAgIGNvbF90eXBlOiB1aV9jb25maWcuY29sLFxcbiAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICBpZDogTVlfUlVMRS50aXRsZSArIFxcXCJAc2VhcmNoX21vZGVcXFwiLFxcbiAgICAgICAgICAgIGxvbmdDbGljazogW3tcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLmjIflrprmkJzntKLmupBcXFwiLFxcbiAgICAgICAgICAgICAgICBqczogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcIlNlYXJjaEFsbG93UG9wXFxcIikuc2hvdygpO1xcbiAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIH0sIHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLmkJzntKLmjpLluo86XFxcIiArIFtcXFwi5pegXFxcIiwgXFxcIuiHqueEtlxcXCIsIFxcXCLkvb/nlKhcXFwiXVtzZWFyY2hzb3J0XSxcXG4gICAgICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKHNlYXJjaHNvcnQpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiAkKFtcXFwi5LiN5L2/55SoXFxcIiwgXFxcIuiHqueEtuaOkuW6j1xcXCIsIFxcXCLkvb/nlKjmjpLluo9cXFwiXSwgMSwgXFxcIuaQnOe0ouaOkuW6j1xcXCIsIHNlYXJjaHNvcnQpLnNlbGVjdCgoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgc2V0SXRlbShcXFwic2VhcmNoc29ydFxcXCIsIFN0cmluZyhNWV9JTkRFWCkpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgICB9LCBzZWFyY2hzb3J0KVxcbiAgICAgICAgICAgIH1dXFxuICAgICAgICB9XFxuICAgIH0pO1xcblxcbiAgICBsZXQgc2V0dGluZ3MgPSBbXFxcIuino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2FzdDovL1xcXCIgKyAodXNlRGFubXUgPyBcXFwi5bey5YWz6ZetXFxcIiA6IFxcXCLlt7LlvIDlkK9cXFwiKTtcXG4gICAgICAgICAgICAgICAgfSwgdXNlRGFubXUpO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoaW5wdXQuaW5jbHVkZXMoXFxcIuiwg+ivleaXpeW/l1xcXCIpKSB7XFxuICAgICAgICAgICAgICAgIGxldCB1c2VMb2cgPSAhIWdldEl0ZW0oXFxcInVzZUxvZ1xcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuICQoXFxcIuW8gOWQr+aXpeW/l+i+heWKqeiwg+ivle+8jOaZrumAmuS9v+eUqOS4jemcgOimgeW8gOWQr1xcXFxu5b2T5YmNOlxcXCIgKyB1c2VMb2cgKyBcXFwiXFxcXG7ngrnlh7vnoa7lrprljbPlj69cXFwiICsgKHVzZUxvZyA/IFxcXCLlhbPpl61cXFwiIDogXFxcIuW8gOWQr1xcXCIpKS5jb25maXJtKCh1c2VMb2cpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIHNldEl0ZW0oXFxcInVzZUxvZ1xcXCIsIHVzZUxvZyA/IFxcXCJcXFwiIDogXFxcIjFcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydW50aW1lQ29uZmlnID0gR00uZGVmaW5lTW9kdWxlKFxcXCJydW50aW1lQ29uZmlnXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgc291cmNlID0gcnVudGltZUNvbmZpZy5nZXRDdXJyZW50U291cmNlKCk7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoc291cmNlKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IERycHlNYW5hZ2UgPSBHTS5kZWZpbmVNb2R1bGUoXFxcIkRycHlNYW5hZ2VcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBEcnB5TWFuYWdlLmRlbChzb3VyY2Uua2V5KTtcXG4g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PSBob21lTGlzdENvbCA/IGNvbGxpc3QuaW5kZXhPZihob21lTGlzdENvbCkgOiAwO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gJChjb2xsaXN0LCAyLCBcXFwi6YCJ5oup5qC35byPXFxcIiwgaW5kZXgpLnNlbGVjdCgoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoTVlfSU5ERVggPT09IDApIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJob21lTGlzdENvbFxcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgc2V0SXRlbShcXFwiaG9tZUxpc3RDb2xcXFwiLCBpbnB1dCk7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlucHV0ID09PSBcXFwi5pu05o2i6YWN572uXFxcIikge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vcGFnZS9jcmVhdGVDb25maWcjbm9SZWNvcmRIaXN0b3J5IyNub0hpc3RvcnkjXFxcIjtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKFxcXCLmlK/mjIHkvZzogIVcXFwiID09IGlucHV0KSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL0RvbmF0ZS52I25vUmVjb3JkSGlzdG9yeSMjbm9IaXN0b3J5I1xcXCI7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChcXFwiVUnnrqHnkIZcXFwiID09IGlucHV0KSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL1VJTWFuYWdlP21vZGU95LiA57qnI25vUmVjb3JkSGlzdG9yeSMjbm9IaXN0b3J5I1xcXCI7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChcXFwi5YiG5Lqr5a+85YWl6Lev5b6EXFxcIiA9PSBpbnB1dCkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vcGFnZS9zaGFyZWRlZmF1bHRwYXRoI25vUmVjb3JkSGlzdG9yeSMjbm9IaXN0b3J5I1xcXCI7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChpbnB1dC5pbmNsdWRlcyhcXFwi5pCc57Si5qih5byPXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgbGV0IHNtb2RlID0gTnVtYmVyKGdldEl0ZW0oXFxcInNtb2RlXFxcIiwgXFxcIjBcXFwiKSk7XFxuICAgICAgICAgICAgICAgIHJldHVybiAkKFtcXFwi6YCJ5LitXFxcIiwgXFxcIuiBmuWQiFxcXCJdLCAxLCBcXFwi5pCc57Si5qih5byPXFxcIiwgc21vZGUpLnNlbGVjdCgodCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgc2V0SXRlbShcXFwic21vZGVcXFwiLCBcXFwiXFxcIiArIE1ZX0lOREVYKTtcXG4gICAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgICAgICB9LCBNWV9SVUxFLnRpdGxlKVxcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoaW5wdXQgPT0gXFxcIuaQnOe0ouaMh+Wumua6kFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuICQucmVxdWlyZShcXFwiU2VhcmNoQWxsb3dQb3BcXFwiKS5zaG93KCk7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChpbnB1dCA9PSBcXFwi5oiR55qEXFxcIikge1xcbiAgICAgICAgICAgICAgICBsZXQgZmF2aWNvbnMgPSBHTS5nZXQoXFxcImZhdmljb25zXFxcIik7XFxuICAgICAgICAgICAgICAgI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xcIlxcXCIpLFxcbiAgICAgICAgY29sX3R5cGU6IFxcXCJhdmF0YXJcXFwiLFxcbiAgICAgICAgaW1nOiBcXFwiaHR0cHM6Ly9oaWtlcmZhbnMuY29tL3R1Ymlhby9rZS8xNTAucG5nXFxcIixcXG4gICAgICAgIHVybDogXFxcInRvYXN0Oi8v54K55LiK6Z2i5o2i5rqQXFxcIixcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgaWQ6IE1ZX1JVTEUudGl0bGUgKyBcXFwic291cmNlbmFtZVxcXCIsXFxuICAgICAgICB9XFxuICAgIH0pO1xcbiAgICB1aW9iai5wdXNoKHtcXG4gICAgICAgIGluZGV4OiA2LFxcbiAgICAgICAga2V5OiBcXFwi5pCc57SiXFxcIixcXG4gICAgICAgIHRpdGxlOiAn5pCc57SiJyxcXG4gICAgICAgIC8vZGVzYzogJycsXFxuICAgICAgICBkZXNjOiAn6KaB5pCc54K55LuA5LmIJyxcXG4gICAgICAgIHVybDogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgICAgcmV0dXJuICdoaWtlcjovL3NlYXJjaD9ydWxlPScgKyBNWV9SVUxFLnRpdGxlICsgXFxcIiZzPVxcXCIgKyBpbnB1dDtcXG4gICAgICAgIH0pLFxcbiAgICAgICAgY29sX3R5cGU6ICdpbnB1dCcsXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIGRlZmF1bHRWYWx1ZTogZ2V0TXlWYXIoXFxcImtleXdvcmRcXFwiLCBcXFwiXFxcIiksXFxuICAgICAgICAgICAgb25DaGFuZ2U6ICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICBwdXRNeVZhcihcXFwia2V5d29yZFxcXCIsIGlucHV0KVxcbiAgICAgICAgICAgIH0pXFxuICAgICAgICB9XFxuICAgIH0pO1xcbiAgICBzdG9yYWdlMC5wdXRNeVZhcihcXFwidWlvYmpcXFwiLCB1aW9iaik7XFxuXFxuICAgIHN1aW9iaiA9IHVpb2JqLnNsaWNlKCk7XFxuICAgIHVpb2JqID0gcmVvcmRlckFycmF5QnlPcmRlcih1aW9iaiwgdWlfaW5kZXhzKTtcXG4gICAgdWlfaW5kZXhzLm1hcChpdGVtID0+IHtcXG4gICAgICAgIGlmIChpdGVtLmtleSA9PSBcXFwi5o2i5rqQXFxcIiAmJiBpdGVtLmluZGV4ID09IC0xKSB7XFxuICAgICAgICAgICAgbGV0IG9iamkgPSBzdWlvYmouZmluZEluZGV4KHggPT4geC5rZXkgPT0gXFxcIuaNoua6kFxcXCIpO1xcbiAgICAgICAgICAgIGxldCBjb2JqaSA9IHVpb2JqLmZpbmRJbmRleCh4ID0+IHgua2V5ID09IFxcXCLmupDlkI1cXFwiKTtcXG4gICAgICAgICAgICBpZiAob2JqaSAhPSAxICYmIGNvYmppICE9IC0xKSB7XFxuICAgICAgICAgICAgICAgIHVpb2JqW2NvYmppXS51cmwgPSBzdWlvYmpbb2JqaV0udXJsO1xcbiAgICAgICAgICAgICAgICBpZiAoc3Vpb2JqW29iamldLmhhc093blByb3BlcnR5KFxcXCJleHRyYVxcXCIpKSB7XFxuICAgICAgICAgICAgICAgICAgICB1aW9ialtjb2JqaV0uZXh0cmEgPSBzdWlvYmpbb2JqaV0uZXh0cmE7XFxuICAgICAgICAgICAgICAgICAgICB1aW9ialtjb2JqaV0uZXh0cmEuaWQgPSBNWV9SVUxFLnRpdGxlICsgXFxcInNvdXJjZW5hbWVcXFwiO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKGl0ZW0ua2V5ID09IFxcXCLmupDlkI1cXFwiICYmIGl0ZW0uaW5kZXggPT0gLTEpIHtcXG4gICAgICAgICAgICBsZXQgb2JqaSA9IHN1aW9iai5maW5kSW5kZXgoeCA9PiB4LmtleSA9PSBcXFwi5rqQ5ZCNXFxcIik7XFxuICAgICAgICAgICAgbGV0IGNvYmppID0gdWlvYmouZmluZEluZGV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lNES19JTlQgPj0gMzAgJiYgIWFuZHJvaWQub3MuRW52aXJvbm1lbnQuaXNFeHRlcm5hbFN0b3JhZ2VNYW5hZ2VyKCkpIHtcXG4gICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLigJjigJjmj5DnpLrigJnigJlcXFwiLFxcbiAgICAgICAgICAgIGRlc2M6IFxcXCLlvZPliY3msqHmnInmlofku7bnrqHnkIbmnYPpmZDml6Dms5XmraPluLjkvb/nlKjor7fmiZPlvIDmtbfpmJTorr7nva49PuabtOWkmuiuvue9rj0+5YaF6YOo5paH5Lu2566h55CGPT7lj7PkuIrop5JcXFwiLFxcbiAgICAgICAgICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCJcXG4gICAgICAgIH0pO1xcbiAgICB9IGVsc2UgaWYgKCFydW50aW1lQ29uZmlnLmlzUHJlcGFyZWQoKSkge1xcbiAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIui/mOayoeaciemFjee9ruinhumikea6kFxcXCIsXFxuICAgICAgICAgICAgdXJsOiBcXFwiaGlrZXI6Ly9wYWdlL2NyZWF0ZUNvbmZpZyNub1JlY29yZEhpc3RvcnkjI25vSGlzdG9yeSNcXFwiLFxcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICB9KTtcXG4gICAgfSBlbHNlIGlmIChmaWxlRXhpc3QoXFxcImhpa2VyOi8vZmlsZXMvZGF0YS9cXFwiICsgTVlfUlVMRS50aXRsZSArIFxcXCIvbGlic19oaWtlci9kcnB5Mi5qc1xcXCIpKSB7XFxuICAgICAgICBsZXQgc291cmNlID0gcnVudGltZUNvbmZpZy5nZXRDdXJyZW50U291cmNlKCk7XFxuICAgICAgICBpZiAoTVlfUEFHRSA9PT0gMSkge1xcbiAgICAgICAgICAgIGlmIChzb3VyY2UgPT0gdW5kZWZpbmVkKSB7XFxuICAgICAgICAgICAgICAgIHNldEhpZWQoZClcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBzZXRIaWVkKGQsIHNvdXJjZS5uYW1lLCBydW50aW1lQ29uZmlnLmdldEN1cnJlbnRDb25maWcoKSB8fCB7fSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfVxcbiAgICAgICAgLy9sb2coRHJweU1hbmFnZS5nZXQoc291cmNlLmtleSkpXFxuICAgICAgICBsZXQgaGFzSGFlZCA9IGZhbHNlO1xcbiAgICAgICAgaWYgKGdldE15VmFyKFxcXCJsaW5rc1xcXCIsIFxcXCJcXFwiKSA9PSBcXFwiXFxcIikge1xcbiAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiAn5Yqg6L295LitLi4uJyxcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6ICd0ZXh0X2NlbnRlcl8xJyxcXG4gICAgICAgICAgICAgICAgdXJsOiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCIsXFxuICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2UsXFxuICAgICAgICAgICAgICAgICAgICBpZDogTVlfUlVMRS50aXRsZSArIFxcXCJsb2FkXFxcIlxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgc2V0UHJlUmVzdWx0KGQpO1xcbiAgICAgICAgICAgIGQubGVuZ3RoID0gMDtcXG4gICAgICAgICAgICBoYXNIYWVkID0gdHJ1ZTtcXG4gICAgICAgIH1cXG4gICAgICAgIGlmIChzb3VyY2UpIHtcXG4gICAgICAgICAgICBsb2FkKGQsIERycHlNYW5hZ2UuZ2V0KHNvdXJjZS5rZXkpLCBzb3VyY2UsIGhhc0hhZWQpO1xcbiAgICAgICAgfVxcbiAgICB9IGVsc2Uge1xcbiAgICAgICAgc2V0RHJweVBhdGgoZCk7XFxuICAgIH1cXG5cXG59IGNhdGNoIChlKSB7XFxuICAgIGQucHVzaCh7XFxuICAgICAgICB0aXRsZTogXFxcIuKAnOKAnFxcXCIgKyBlLnRvU3RyaW5nKCkgKyBcXFwi4oCd4oCdXFxcIixcXG4gICAgICAgIGRlc2M6IGUubGluZU51bWJlcixcXG4gICAgICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgbG9uZ0NsaWNrOiBbe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogXFxcIua4hemZpHVp6K6+572uXFxcIixcXG4gICAgICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB1aV9jbGVhcixcXG4gICAgICAgICAgICAgICAgICAgIH0gPSAkLnJlcXVpcmUoXFxcIlVJTWFuYWdlXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICB1aV9jbGVhcihcXFwieWlcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgfV1cXG4gICAgICAgIH1cXG4gICAgfSk7XFxuICAgIGQucHVzaCh7XFxuICAgICAgICB0aXRsZTogXFxcIuabtOaNoumFjee9rlxcXCIsXFxuICAgICAgICB1cmw6IFxcXCJoaWtlcjovL3BhZ2UvY3JlYXRlQ29uZmlnI25vUmVjb3JkSGlzdG9yeSMjbm9IaXN0b3J5I1xcXCIsXFxuICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbiAgICAgICAgZXh0cmE6IHtcXG4gICAg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NvbmZpZzoge1xcbiAgICAgICAgaXRlbXM6IGl0ZW1zLFxcbiAgICAgICAgdWM6IHVpX2NvbmZpZyxcXG4gICAgICAgIGRlZjogZGVmLFxcbiAgICAgICAgZGVlcE9iamVjdFByb3BlcnR5KG9iaiwgcGF0aCwgdmFsdWUpIHtcXG4gICAgICAgICAgdmFyIHBhcnRzID0gcGF0aC5zcGxpdCgnLicpO1xcbiAgICAgICAgICB2YXIgY3VycmVudCA9IG9iajtcXG4gICAgICAgICAgZm9yICh2YXIgaSA9IDA7IGkgPCBwYXJ0cy5sZW5ndGggLSAxOyBpKyspIHtcXG4gICAgICAgICAgICB2YXIgcGFydCA9IHBhcnRzW2ldO1xcbiAgICAgICAgICAgIGlmICghY3VycmVudFtwYXJ0XSkge1xcbiAgICAgICAgICAgICAgY3VycmVudFtwYXJ0XSA9IHt9O1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBjdXJyZW50ID0gY3VycmVudFtwYXJ0XTtcXG4gICAgICAgICAgfVxcbiAgICAgICAgICBjdXJyZW50W3BhcnRzW3BhcnRzLmxlbmd0aCAtIDFdXSA9IHZhbHVlO1xcbiAgICAgICAgfSxcXG4gICAgICAgIGdldCgpIHtcXG4gICAgICAgICAgbGV0IHVjID0gc3RvcmFnZTAuZ2V0SXRlbShcXFwidWlfY29uZmlnXFxcIiwgdGhpcy51Yyk7XFxuICAgICAgICAgIGlmIChPYmplY3Qua2V5cyh1YykubGVuZ3RoID09IDApIHtcXG4gICAgICAgICAgICB1YyA9IHRoaXMuZGVmO1xcbiAgICAgICAgICB9XFxuICAgICAgICAgIHJldHVybiB1YztcXG4gICAgICAgIH0sXFxuICAgICAgICBzZXQodmFsdWUsIGtleSkge1xcbiAgICAgICAgICBsZXQgdWMgPSB0aGlzLmdldCgpO1xcbiAgICAgICAgICBpZiAoa2V5KSB7XFxuICAgICAgICAgICAgdGhpcy5kZWVwT2JqZWN0UHJvcGVydHkodWMsIGtleSwgdmFsdWUpO1xcbiAgIC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ICAgICAgICAgIGRlc2M6IGN1cnJlbnQuZGVzYyB8fCBcXFwiXFxcIixcXG4gICAgICAgICAgICAgIGNvbF90eXBlOiBjdXJyZW50LnR5cGUsXFxuICAgICAgICAgICAgICBleHRyYTogT2JqZWN0LmFzc2lnbih7fSwgaXRlbS5leHRyYSwge1xcbiAgICAgICAgICAgICAgICBrZXk6IGN1cnJlbnQuZXh0cmEua2V5LFxcbiAgICAgICAgICAgICAgICBpbmRleDogY3VycmVudC5leHRyYS5pbmRleFxcbiAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB1cGRhdGVJdGVtKGN1cnJlbnQuZXh0cmEuaWQsIHtcXG4gICAgICAgICAgICAgIHRpdGxlOiBpdGVtLnRpdGxlLFxcbiAgICAgICAgICAgICAgcGljOiBpdGVtLnBpYyB8fCBcXFwiXFxcIixcXG4gICAgICAgICAgICAgIGRlc2M6IGl0ZW0uZGVzYyB8fCBcXFwiXFxcIixcXG4gICAgICAgICAgICAgIGNvbF90eXBlOiBpdGVtLnR5cGUsXFxuICAgICAgICAgICAgICBleHRyYTogT2JqZWN0LmFzc2lnbih7fSwgY3VycmVudC5leHRyYSwge1xcbiAgICAgICAgICAgICAgICBrZXk6IGl0ZW0uZXh0cmEua2V5LFxcbiAgICAgICAgICAgICAgICBpbmRleDogaXRlbS5leHRyYS5pbmRleFxcbiAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICB9KTtcXG5cXG4gICAgICAgICAgICBsZXQgbmFyciA9ICQuc3dhcEFycmF5RWxlbWVudHMoaW5kZXhzLCBjdXJyZW50LmV4dHJhLmluZGV4LCBpdGVtLmV4dHJhLmluZGV4KTtcXG5cXG4gICAgICAgICAgICAkLnVpQ29uZmlnLnNldChuYXJyLCBcXFwieWkudWlcXFwiKTtcXG4gICAgICAgICAgICBjbGVhck15VmFyKFxcXCJ1aV9jdXJyZW50XFxcIik7XFxuICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgbGV0IGggPSAn4oCc4oCc4oCd4oCdJztcXG4gICAgICAgICAgICBsZXQgdGl0bGUgPSBpdGVtLnRpdGxlO1xcbiAgICAgICAgICAgIHRvYXN0KFxcXCLpgInmi6nnp7vliqjnmoTnm67moIdcXFwiKTtcXG4gICAgICAgICAgICBpZiAoL3RleHRfaWNvbnxhdmF0YXJ8aWNvbl9zbWFsbF8zLy50ZXN0KGl0ZW0udHlwZSkpIHtcXG4gICAgICAgICAgICAgIGggPSBcXFwiXFxcIjtcXG4gICAgICAgICAgICAgIHRpdGxlID0gdGl0bGUuZm9udGNvbG9yKFxcXCIjZmZmXFxcIik7XFxuICAgICAgICAgICAgfSBlbHNlIGlmICgvaWNvbl8xX3NlYXJjaC8udGVzdChpdGVtLnR5cGUpKSB7XFxuICAgICAgICAgICAgICBoID0gXFxcIlxcXCI7XFxuICAgICAgICAgICAgICB0aXRsZSA9IFxcXCLinqHvuI9cXFwiICsgdGl0bGU7XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgIHRpdGxlID0gdGl0bGUuZm9udGNvbG9yKFxcXCIjZmZmXFxcIik7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHVwZGF0ZUl0ZW0oaXRlbS5leHRyYS5pZCwge1xcbiAgICAgICAgICAgICAgdGl0bGU6IGggKyB0aXRsZSxcXG4gICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIHN0b3JhZ2UwLnB1dE15VmFyKFxcXCJ1aV9jdXJyZW50XFxcIiwgaXRlbSk7XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgIH0sIGkpXFxuICAgICAgICBpdGVtW1xcXCJleHRyYVxcXCJdID0ge1xcbiAgICAgICAgICBrZXk6IGl0ZW0ua2V5LFxcbiAgICAgICAgICBjbHM6IE1ZX1JVTEUudGl0bGUgKyBcXFwiX3VpXFxcIixcXG4gICAgICAgICAgaWQ6IE1ZX1JVTEUudGl0bGUgKyBcXFwiX3VpXFxcIiArIGksXFxuICAgICAgICAgIGluZGV4OiBpdGVtLmluZGV4LFxcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKGl0ZW0ua2V5ICE9IFxcXCLorr7nva5cXFwiKSB7XFxuICAgICAgICAgIGxvbmdjbGlja3MucHVzaCh7XFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLliKDpmaRcXFwiLFxcbiAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKChrZXkpID0+IHtcXG4gICAgICAgICAgICAgIGxldCBpdGVtcyA9ICQudWlDb25maWcuZ2V0SW5kZXhzKCk7XFxuICAgICAgICAgICAgICBsZXQgaSA9IGl0ZW1zLmZpbmRJbmRleCh4ID0+IHgua2V5ID09IGtleSk7XFxuICAgICAgICAgICAgICBpZiAoaSAhPSAtMSkge1xcbiAgICAgICAgICAgICAgICBpdGVtc1tpXVtcXFwiaW5kZXhcXFwiXSA9IC0xO1xcbiAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgJC51aUNvbmZpZy5zZXQoaXRlbXMsIFxcXCJ5aS51aVxcXCIpO1xcbiAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICB9LCBpdGVtLmtleSlcXG4gICAgICAgICAgfSlcXG4gICAgICAgIH1cXG4gICAgICAgIGlmICghL2ljb25fMV9zZWFyY2h8YXZhdGFyLy50ZXN0KGl0ZW0uY29sX3R5cGUpKSB7XFxuICAgICAgICAgIGxvbmdjbGlja3MucHVzaCh7XFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLmm7TmjaLlm77moIdcXFwiLFxcbiAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKChrZXkpID0+IHtcXG4gICAgICAgICAgICAgIHJldHVybiAkKFxcXCJcXFwiKS5pbnB1dCgoa2V5KSA9PiB7XFxuICAgICAgICAgICAgICAgIGxldCBpdGVtcyA9ICQudWlDb25maWcuZ2V0SW5kZXhzKCk7XFxuICAgICAgICAgICAgICAgIGxldCBpID0gaXRlbXMuZmluZEluZGV4KHggPT4geC5rZXkgPT0ga2V5KTtcXG4gICAgICAgICAgICAgICAgaWYgKGkgIT0gLTEpIHtcXG4gICAgICAgICAgICAgICAgICBpdGVtc1tpXVtcXFwiaW1nXFxcIl0gPSBpbnB1dDtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAkLnVpQ29uZmlnLnNldChpdGVtcywgXFxcInlpLnVpXFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCBpZCA9IGZpbmRJdGVtc0J5Q2xzKE1ZX1JVTEUudGl0bGUgKyBcXFwiX3VpXFxcIikuZmlsdGVyKHggPT4geC5leHRyYS5rZXkgPT0ga2V5KVswXS5leHRyYS5pZDtcXG4gICAgICAgICAgICAgICAgdXBkYXRlSXRlbShpZCwgeyBwaWM6IGlucHV0IH0pXFxuICAgICAgICAgICAgICB9LCBrZXkpXFxuICAgICAgICAgICAgfSwgaXRlbS5rZXkpXFxuICAgICAgICAgIH0pXFxuICAgICAgICAgIGlmIChpdGVtLmtleSAhPSBcXFwi5o2i5rqQXFxcIiAmJiBpdGVtLmtleSAhPSBcXFwi5pCc57Si5qih5byPXFxcIikge1xcbiAgICAgICAgICAgIGxvbmdjbGlja3MucHVzaCh7XFxuICAgICAgICAgICAgICB0aXRsZTogXFxcIuS/ruaUueWQjeensFxcXCIsXFxuICAgICAgICAgICAgICBqczogJC50b1N0cmluZygoa2V5KSA9PiB7XFxuICAgICAgICAgICAgICAgIHJldHVybiAkKFxcXCJcXFwiKS5pbnB1dCgoa2V5KSA9PiB7XFxuICAgICAgICAgICAgICAgICAgbGV0IGl0ZW1zID0gJC51aUNvbmZpZy5nZXRJbmRleHMoKTtcXG4gICAgICAgICAgICAgICAgICBsZXQgaSA9IGl0ZW1zLmZpbmRJbmRleCh4ID0+IHgua2V5ID09IGtleSk7XFxuICAgICAgICAgICAgICAgICAgaWYgKGkgIT0gLTEpIHtcXG4gICAgICAgICAgICAgICAgICAgIGl0ZW1zW2ldW1xcXCJ0aXRsZVxcXCJdID0gaW5wdXQ7XFxuICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICQudWlDb25maWcuc2V0KGl0ZW1zLCBcXFwieWkudWlcXFwiKTtcXG4gICAgICAgICAgICAgICAgICBsZXQgaWQgPSBmaW5kSXRlbXNCeUNscyhNWV9SVUxFLnRpdGxlICsgXFxcIl91aVxcXCIpLmZpbHRlcih4ID0+IHguZXh0cmEua2V5ID09IGtleSlbMF0uZXh0cmEuaWQ7XFxuICAgICAgICAgICAgICAgICAgdXBkYXRlSXRlbShpZCwgeyB0aXRsZTogaW5wdXQgfSlcXG4gICAgICAgICAgICAgICAgfSwga2V5KVxcbiAgICAgICAgICAgICAgfSwgaXRlbS5rZXkpXFxuICAgICAgICAgICAgfSlcXG4gICAgICAgICAgfVxcbiAgICAgICAgfVxcbiAgICAgICAgaXRlbS5leHRyYS5Mb25nQ2xpY2sgPSBsb25nY2xpY2tzO1xcbiAgICAgICAgcmV0dXJuIGl0ZW07XFxuICAgICAgfSlcXG4gICAgfSBlbHNlIHtcXG4gICAgICB1aW9iaiA9IHVpb2JqLm1hcCgoaXRlbSwgaSkgPT4ge1xcbiAgICAgICAgaXRlbS5leHRyYSA9IHtcXG4gICAgICAgICAgaWQ6IE1ZX1JVTEUudGl0bGUgKyBcXFwiX3VpXFxcIiArIGksXFxuICAgICAgICAgIGNsczogTVlfUlVMRS50aXRsZSArIFxcXCJfdWlcXFwiXFxuICAgICAgICB9XFxuICAgICAgICByZXR1cm4gaXRlbTtcXG4gICAgICB9KVxcbiAgICB9XFxuICAgIGQgPSBkLmNvbmNhdCh1aW9iaik7XFxuXFxuICAgIGlmIChpbmRleHMuc29tZSh4ID0+IHguaW5kZXggPT0gLTEpICYmIHVpbW9kZSkge1xcbiAgICAgIGQucHVzaCh7XFxuICAgICAgICB0aXRsZTogXFxcIuW3suenu+mZpFxcXCIsXFxuICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfMVxcXCIsXFxuICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgIGxpbmVWaXNpYmxlOiBmYWxzZSxcXG4gICAgICAgIH1cXG4gICAgICB9KVxcbiAgICAgIGluZGV4cy5maWx0ZXIoeCA9PiB4LmluZGV4ID09IC0xKS5mb3JFYWNoKChpdGVtLCBpKSA9PiB7XFxuICAgICAgICBsZXQgbWFwID0gbmV3IE1hcChzdWlvYmoubWFwKG9iaiA9PiBbb2JqLmtleSwgb2JqXSkpO1xcbiAgICAgICAgbGV0IG9iaiA9IG1hcC5nZXQoaXRlbS5rZXkpO1xcbiAgICAgICAgb2JqLnVybCA9ICQoXFxcIlxcXCIpLmxhenlSdWxlKChrZXksIGluZGV4KSA9PiB7XFxuICAgICAgICAgIGxldCBpdGVtcyA9ICQudWlDb25maWcuZ2V0SW5kZXhzKCk7XFxuICAgICAgICAgIGxldCBpID0gaXRlbXMuZmluZEluZGV4KHggPT4geC5rZXkgPT0ga2V5KTtcXG4gICAgICAgICAgaWYgKGkgIT0gLTEpIHtcXG4gICAgICAgICAgICBpdGVtc1tpXVtcXFwiaW5kZXhcXFwiXSA9IGluZGV4O1xcbiAgICAgICAgICB9XFxuICAgICAgICAgICQudWlDb25maWcuc2V0KGl0ZW1zLFxcXCJ5aS51aVxcXCIpO1xcbiAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgfSwgaXRlbS5rZXksIG9iai5pbmRleClcXG4gICAgICAgIG9iai50aXRsZSA9IG9iai5rZXk7XFxuICAgICAgICBpZiAob2JqLmV4dHJhID09IHVuZGVmaW5lZCkge1xcbiAgICAgICAgICBvYmouZXh0cmEgPSB7fTtcXG4gICAgICAgIH1cXG4gICAgICAgIG9iai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gICB9LCB7XFxuICAgICAgdGl0bGU6IFxcXCLov5jljp9cXFwiLFxcbiAgICAgIGNvbF90eXBlOiBcXFwidGV4dF8zXFxcIixcXG4gICAgICB1cmw6ICQoJyNub0xvYWRpbmcjJykubGF6eVJ1bGUoKHVpX2NvbmZpZywgZGVmKSA9PiB7XFxuICAgICAgICByZXR1cm4gJChcXFwi5piv5ZCm5oGi5aSN6K6+572uXFxcIikuY29uZmlybSgodWlfY29uZmlnLCBkZWYpID0+IHtcXG4gICAgICAgICAgdWlfY29uZmlnLnlpID0gZGVmLnlpO1xcbiAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICBzdG9yYWdlMC5zZXRJdGVtKFxcXCJ1aV9jb25maWdcXFwiLCB1aV9jb25maWcpO1xcbiAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v6L+Y5Y6f5a6M5oiQXFxcIjtcXG4gICAgICAgIH0sIHVpX2NvbmZpZywgZGVmKVxcbiAgICAgIH0sIHVpX2NvbmZpZywgZGVmKSxcXG4gICAgfSwge1xcbiAgICAgIHRpdGxlOiBcXFwi56Gu6K6kXFxcIixcXG4gICAgICBjb2xfdHlwZTogXFxcInRleHRfM1xcXCIsXFxuICAgICAgdXJsOiAkKCcjbm9Mb2FkaW5nIycpLmxhenlSdWxlKCgpID0+IHtcXG4gICAgICAgIGJhY2sodHJ1ZSk7XFxuICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiXFxuICAgICAgfSksXFxuICAgICAgZXh0cmE6IHtcXG4gICAgICAgIExvbmdDbGljazogW3tcXG4gICAgICAgICAgdGl0bGU6IFxcXCLlpI3liLZcXFwiLFxcbiAgICAgICAgICBqczogJC50b1N0cmluZygodWlfY29uZmlnKSA9PiB7XFxuICAgICAgICAgICAgY29weShKU09OLnN0cmluZ2lmeSh1aV9jb25maWcueWkpKTtcXG4gICAgICAgICAgfSwgdWlfY29uZmlnKSxcXG4gICAgICAgIH0sIHtcXG4gICAgICAgICAgdGl0bGU6IFxcXCLlr7zlhaVcXFwiLFxcbiAgICAgICAgICBqczogJC50b1N0cmluZygodWlfY29uZmlnKSA9PiB7XFxuICAgICAgICAgICAgdmFyIHVjID0gc3RvcmFnZTAuZ2V0SXRlbShcXFwidWlfY29uZmlnXFxcIiwgdWlfY29uZmlnKTtcXG4gICAgICAgICAgICByZXR1cm4gJChcXFwie3tjbGlwYm9hcmR9fVxcXCIpLmlucHV0KCh1YykgPT4ge1xcbiAgICAgICAgICAgICAgdmFyIHlpID0ge307XFxuICAgICAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgICAgICB5aSA9IEpTT04ucGFyc2UoaW5wdXQpO1xcbiAgICAgICAgICAgICAgICBpZiAoeWkuaGFzT3duUHJvcGVydHkoXFxcInVpXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgICB1Yy55aSA9IHlpO1xcbiAgICAgICAgICAgICAgICAgIHN0b3JhZ2UwLnNldEl0ZW0oXFxcInVpX2NvbmZpZ1xcXCIsIHVjKTtcXG4gICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgICAgIHRvYXN0KFxcXCLmoLzlvI/plJnor69cXFwiKVxcbiAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0sIHVjKVxcbiAgICAgICAgICB9LCB1aV9jb25maWcpXFxuICAgICAgICB9XVxcbiAgICAgIH1cXG4gICAgfSlcXG4gICAgZC5wdXNoKHtcXG4gICAgICB0aXRsZTogXFxcIuWktOmDqOe7hOS7tuagt+W8jzpcXFwiICsgdWlfY29uZmlnLnlpLmNvbCxcXG4gICAgICBjb2xfdHlwZTogXFxcInRleHRfMVxcXCIsXFxuICAgICAgdXJsOiAkKCcjbm9Mb2FkaW5nIycpLmxhenlSdWxlKCh1aV9jb25maWcpID0+IHtcXG4gICAgICAgIHVpX2NvbmZpZyA9I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LFxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICB9KTtcXG4gICAgICAgICAgdWlfY29uZmlnLnlpLmNvbCA9IGlucHV0O1xcbiAgICAgICAgICBzdG9yYWdlMC5zZXRJdGVtKFxcXCJ1aV9jb25maWdcXFwiLCB1aV9jb25maWcpO1xcbiAgICAgICAgICB1cGRhdGVJdGVtKE1ZX1JVTEUudGl0bGUgKyBcXFwiX3lpY29sXFxcIiwge1xcbiAgICAgICAgICAgIHRpdGxlOiBcXFwi5aS06YOo57uE5Lu25qC35byPOlxcXCIgKyB1aV9jb25maWcueWkuY29sXFxuICAgICAgICAgIH0pXFxuICAgICAgICB9LCB1aV9jb25maWcpXFxuICAgICAgfSwgdWlfY29uZmlnKSxcXG4gICAgICBleHRyYToge1xcbiAgICAgICAgbGluZVZpc2libGU6IGZhbHNlLFxcbiAgICAgICAgaWQ6IE1ZX1JVTEUudGl0bGUgKyBcXFwiX3lpY29sXFxcIlxcbiAgICAgIH1cXG4gICAgfSlcXG4gIH1cXG5cXG4gIGlmICh1aV9uYXZpID09IFxcXCLkuoznuqdcXFwiKSB7XFxuICAgIGQucHVzaCh7XFxuICAgICAgdGl0bGU6IFxcXCLmr4/pobXmlbDph49cXFwiLFxcbiAgICAgIGRlc2M6IFxcXCIw5YiZ6KGo56S65LiN5YiG6aG1XFxcIixcXG4gICAgICBjb2xfdHlwZTogXFxcImlucHV0XFxcIixcXG4gICAgICB1cmw6ICQudG9TdHJpbmcoKHVpX2NvbmZpZykgPT4ge1xcbiAgICAgICAgaWYgKFN0cmluZyhpbnB1dCkubGVuZ3RoID4gMykge1xcbiAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v6K+36L6T5YWlM+S9jeaVsOWtl+S7peWGhVxcXCI7XFxuICAgICAgICB9XFxuICAgICAgICBpZiAoU3RyaW5nKGlucHV0KS5sZW5ndGggPCAyICYmIGlucHV0ICE9IDApIHtcXG4gICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDov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BUkFNUywgdGl0bGUpIHtcXG4gICAgICAgIGZ1bmN0aW9uIHRvUGF0aCh2YWx1ZSkge1xcbiAgICAgICAgICAgIGlmICh0eXBlb2YgdmFsdWUgIT09ICdzdHJpbmcnKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBbXTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IHBhdGggPSBbXTtcXG4gICAgICAgICAgICBsZXQgY3VycmVudCA9ICcnO1xcbiAgICAgICAgICAgIGxldCBpbkJyYWNrZXRzID0gZmFsc2U7XFxuICAgICAgICAgICAgbGV0IGVzY2FwZSA9IGZhbHNlO1xcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgdmFsdWUubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgbGV0IGNoYXIgPSB2YWx1ZVtpXTtcXG4gICAgICAgICAgICAgICAgaWYgKGVzY2FwZSkge1xcbiAgICAgICAgICAgICAgICAgICAgY3VycmVudCArPSBjaGFyO1xcbiAgICAgICAgICAgICAgICAgICAgZXNjYXBlID0gZmFsc2U7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoY2hhciA9PT0gJ1xcXFxcXFxcJykge1xcbiAgICAgICAgICAgICAgICAgICAgZXNjYXBlID0gdHJ1ZTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChjaGFyID09PSAnLicgJiYgIWluQnJhY2tldHMpIHtcXG4gICAgICAgICAgICAgICAgICAgIHBhdGgucHVzaChjdXJyZW50KTtcXG4gICAgICAgICAgICAgICAgICAgIGN1cnJlbnQgPSAnJztcXG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChjaGFyID09PSAnWycpIHtcXG4gICAgICAgICAgICAgICAgICAgIGluQnJhY2tldHMgPSB0cnVlO1xcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGNoYXIgPT09ICddJykge1xcbiAgICAgICAgICAgICAgICAgICAgaW5CcmFja2V0cyA9IGZhbHNlO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgY3VycmVudCArPSBjaGFyO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGlmIChjdXJyZW50KSB7XFxuICAgICAgICAgICAgICAgIHBhdGgucHVzaChjdXJyZW50KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIHBhdGg7XFxuICAgICAgICB9XFxuXFxuICAgICAgICBmdW5jdGlvbiBnZXRKc29uKG9iaiwgcGF0aCkge1xcbiAgICAgICAgICAgIGlmICghb2JqIHx8ICFBcnJheS5pc0FycmF5KHBhdGgpKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiB1bmRlZmluZWQ7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGlmIChwYXRoLmxlbmd0aCA9PT0gMCkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gb2JqO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgY3VycmVudCA9IG9iajtcXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHBhdGgubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgbGV0IGtleSA9IHBhdGhbaV07XFxuICAgICAgICAgICAgICAgIGlmIChjdXJyZW50ID09PSBudWxsIHx8IGN1cnJlbnQgPT09IHVuZGVmaW5lZCB8fCB0eXBlb2YgY3VycmVudCAhPT0gJ29iamVjdCcpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB1bmRlZmluZWQ7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgY3VycmVudCA9IGN1cnJlbnRba2V5XTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIGN1cnJlbnQ7XFxuICAgICAgICB9XFxuICAgICAgICB0cnkge1xcbiAgICAgICAgICAgIGxldCBydW5UeXBlID0gTVlfUEFSQU1TLnJ1blR5cGVbMF07XFxuICAgICAgICAgICAgbGV0IHVybCA9IGRlY29kZVVSSUNvbXBvbmVudChiYXNlNjREZWNvZGUoTVlfUEFSQU1TLnVybFswXSkpO1xcbiAgICAgICAgICAgIGlmIChydW5UeXBlID09IFxcXCJKU09OXFxcIikge1xcblxcbiAgICAgICAgICAgICAgICBsZXQgcGFyYW0gPSBKU09OLnBhcnNlKGRlY29kZVVSSUNvbXBvbmVudChiYXNlNjREZWNvZGUoTVlfUEFSQU1TLnBhcmFtWzBdKSkpO1xcbiAgICAgICAgICAgICAgICBsZXQganNvbiA9IEpTT04ucGFyc2UocmVxdWVzdCh1cmwsIHtcXG4gICAgICAgICAgICAgICAgICAgIGhlYWRlcnM6IHBhcmFtLmhlYWRlcnMgfHwge30sXFxuICAgICAgICAgICAgICAgICAgICBtZXRob2Q6IHBhcmFtLm1ldGhvZCB8fCB2b2lkIDBcXG4gICAgICAgICAgICAgICAgfSkpO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkoe1xcbiAgICAgICAgICAgICAgICAgICAgc3RhdHVzQ29kZTogMzAyLFxcbiAgICAgICAgICAgICAgICAgICAgaGVhZGVyczogT2JqZWN0LmFzc2lnbih7fSwgcGFyYW0uaGVhZGVycyB8fCB7fSwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIFxcXCJMb2NhdGlvblxcXCI6IGdldEpzb24oanNvbiwgdG9QYXRoKHBhcmFtLmpzb25QYXRoKSksXFxuICAgICAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKHJ1blR5cGUgPT0gXFxcIkpTXFxcIikge1xcblxcbiAgICAgICAgICAgICAgICBsZXQgcGFyc2U7XFxuICAgICAgICAgICAgICAgIGlmIChNWV9QQVJBTVMuaW5kZXgpIHtcXG4gICAgICAgICAgICAgICAgICAgIHBhcnNlID0gJC5yZXF1aXJlKFxcXCJjb25maWdzP3J1bGU9XFxcIiArIHRpdGxlKS5nZXRKc29uKClbTVlfUEFSQU1TLmluZGV4WzBdXTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIHBhcnNlID0gSlNPTi5wYXJzZShiYXNlNjREZWNvZGUoZGVjb2RlVVJJQ29tcG9uZW50KE1ZX1BBUkFNUy5wYXJhbVswXSkpKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBsZXQgcmVzID0gbmV3IEZ1bmN0aW9uKFxcXCJ1cmxcXFwiLCBcXFwic2VsZlxcXCIsIHBhcnNlLmpzKSh1cmwsIHBhcnNlKTtcXG4gICAgICAgICAgICAgICAgaWYgKHR5cGVvZiByZXMgPT09IFxcXCJzdHJpbmdcXFwiKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkoe1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHN0YXR1c0NvZGU6IDMwMixcXG4gICAgICAgICAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIFxcXCJMb2NhdGlvblxcXCI6IHJlc1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKCQudHlwZShyZXMpID09PSBcXFwib2JqZWN0XFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBzdGF0dXNDb2RlOiAzMDIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgaGVhZGVyczogcmVzXFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICBsb2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pI3pg6jliIbmupDku47mkJzntKLov5vlhaXor6bnu4bpobXmiqXplJnjgIJcXFwiLFxcbiAgICAgICAgXFxcIuKAnOKAnGZpeOKAneKAne+8muS/ruWkjemDqOWIhua6kGxhennov5Tlm57nqbp1cmzml7bmiqXplJnjgIJcXFwiXFxuICAgIF1cXG59LCB7XFxuICAgIHRpdGxlOiBcXFwiMjAyNC8wNi8xNiAgTWF4VmVyc2lvbiAyOVxcXCIsXFxuICAgIHJlY29yZHM6IFtcXG4gICAgICAgIFxcXCLigJzigJxmaXjigJ3igJ3vvJrljYfnuqdkcnB5Lmpz77yM5L+u5aSNZ3ppcOWHveaVsOOAglxcXCJcXG4gICAgXVxcbn0sIHtcXG4gICAgdGl0bGU6IFxcXCIyMDI0LzA2LzE1ICBNYXhWZXJzaW9uIDI4XFxcIixcXG4gICAgcmVjb3JkczogW1xcbiAgICAgICAgXFxcIuKAmOKAmG5ld+KAmeKAme+8muWinuWKoHVp566h55CG44CCXFxcIixcXG4gICAgICAgIFxcXCLigJjigJhuZXfigJnigJnvvJrkuLvpobXlop7liqDot7Pov4flvaLlvI8oKinkuoznuqfpgInpobnjgIJcXFwiLFxcbiAgICAgICAgXFxcIuKAmOKAmG5ld+KAmeKAme+8muino+aekOeuoeeQhuWinuWKoGZsYWfliIbnsbvjgIJcXFwiLFxcbiAgICAgICAgXFxcIm9wdGltaXpl77ya5LyY5LyY5YyW6K6i6ZiF5pu05paw562W55Wl44CCXFxcIixcXG4gICAgXVxcbn0sIHtcXG4gICAgdGl0bGU6IFxcXCIyMDI0LzA2LzEyICBNYXhWZXJzaW9uIDI2XFxcIixcXG4gICAgcmVjb3JkczogW1xcbiAgICAgICAgXFxcIuKAmOKAmG5ld+KAmeKAme+8muWcqOaNoua6kOeVjOmdoueahOiPnOWNleWPr+S7peW8gOWQr+WIhuS6q+aXtuaYr+WQpuS9v+eUqOe8lueggeOAglxcXCIsXFxuICAgICAgICBcXFwib3B0aW1pemXvvJrlnKjpgInmupDnlYzpnaLliLfmlrDphY3nva7lkI7kvJrlkIzmraXmm7TmlrDmlbDph4/mmL7npLrjgIJcXFwiLFxcbiAgICBdXFxufSwge1xcbiAgICB0aXRsZTogXFxcIjIwMjQvMDYvMTAgIE1heFZlcnNpb24gMjVcXFwiLFxcbiAgICByZWNvcmRzOiBbXFxuICAgICAgICBcXFwi4oCY4oCYbmV34oCZ4oCZ77ya5aKe5Yqg5pu05paw5pel5b+X44CCXFxcIixcXG4gICAgICAgIFxcXCLigJjigJhuZXfigJnigJnvvJrpgInmupDplb/mjInoj5zljZXvvIzlop7liqDot7PovaznvZHpobXvvIzmn6XnnIvmupDnoIHjgIJcXFwiLFxcbiAgICAgICAgXFxcIuKAnOKAnGZpeOKAneKAne+8muS/ruWkjee8lui+keino+aekOeVjOmdoua1i+ivlWpz6Kej5p6Q5LiA55u05aSx6LSl44CCXFxcIixcXG4gICAgICAgIFxcXCLigJzigJxmaXjigJ3igJ3vvJrkv67lpI1naXRodWLorqLpmIXvvIzkvJrliKDpmaTlhajpg6jop4TliJnmlofku7bjgIJcXFwiLFxcbiAgICAgICAgXFxcIuKAnOKAnGZpeOKAneKAne+8muS/ruWkjeino+aekOiwg+eUqOWksei0peOAglxcXCIsXFxuICAgICAgICBcXFwi4oCc4oCcZml44oCd4oCd77ya5L+u5aSN5pu05o2i6YWN572u5pe25rKh5pyJ5Y+K5pe25riF56m6ZHJweee8k+WtmOOAglxcXCIsXFxuICAgICAgICBcXFwib3B0aW1pemXvvJrmm7TmlLnorqLpmIXmm7TmlrDnrZbnlaXvvIzkvJrliKDpmaTmnKzlnLDlpLHmlYjmupDjgIJcXFwiLFxcbiAgICAgICAgXFxcIm9wdGltaXpl77ya5pu05pawZHJweTIuanPjgIJcXFwiLFxcbiAgICAgICAgXFxcIm9wdGltaXpl77ya5LyY5YyW6Kej5p6QZmxhZ+WMuemFjeOAglxcXCIsXFxuXFxuICAgIF1cXG59LCB7XFxuICAgIHRpdGxlOiBcXFwiMjAyNC8wNi8wOSBNYXhWZXJzaW9uIDIwXFxcIixcXG4gICAgcmVjb3JkczogW1xcbiAgICAgICAgXFxcIuKAmOKAmG5ld+KAmeKAme+8muaUr+aMgXByb3h5X3J1bGXku6PnkIbjgIJcXFwiLFxcbiAgICAgICAgXFxcIuKAnOKAnGZpeOKAneKAne+8muS/ruWkjeS6keebmOmTvuaOpeS4jeiwg+WPluS6keebmOeugOOAglxcXCIsXFxuICAgICAgICBcXFwi4oCc4oCcZml44oCd4oCd77ya5L+u5aSN5ZOU5ZOp5b2x6KeG5LiN6IO95L2/55So6Kej5p6Q44CCXFxcIixcXG4gICAgXVxcbn1dO1wifV0iLCJpY29uIjoiIiwicHJveHkiOiIifQ==
Add Comment
Please, Sign In to add comment