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nX3VybCArIHBpYzsKfQoKdmFyIHJ1bGUgPSB7CiAgICDnsbvlnos6ICflkKzkuaYnLC8v5b2x6KeGfOWQrOS5pnzmvKvnlLt85bCP6K+0CiAgICB0aXRsZTogJ+iAgeeZveaVheS6i1vlkKxdJywKICAgIGhvc3Q6ICdodHRwczovL2xhZ3Mub3NzLWNuLWhhbmd6aG91LmFsaXl1bmNzLmNvbS8nLAogICAgdXJsOiAnJywKICAgIHNlYXJjaFVybDogJyNmeXBhZ2UnLAogICAgc2VhcmNoYWJsZTogMiwKICAgIHF1aWNrU2VhcmNoOiAwLAogICAgZmlsdGVyYWJsZTogMSwKICAgIGZpbHRlcjogJycsCiAgICBmaWx0ZXJfdXJsOiAnJywKICAgIGhlYWRlcnM6IHsKICAgICAgICAnVXNlci1BZ2VudCc6ICdNT0JJTEVfVUEnLAogICAgfSwKICAgIHRpbWVvdXQ6IDUwMDAsCiAgICBwbGF5X3BhcnNlOiB0cnVlLAogICAg6aKE5aSE55CGOiAkanMudG9TdHJpbmcoKCkgPT4gewogICAgICAgIGRldmljZSA9IGdldEl0ZW0oJ2RldmljZScsICd7fScpOwogICAgICAgIGlmICh0eXBlb2YgZGV2aWNlID09ICJzdHJpbmciKSB7CiAgICAgICAgICAgIGRldmljZSA9IEpTT04ucGFyc2UoZGV2aWNlKTsKICAgICAgICB9CiAgICAgICAgLy8gZGV2aWNlID0gSlNPTi5wYXJzZShkZXZpY2UpOwogICAgICAgIGlmICghZGV2aWNlLmlkKSB7CiAgICAgICAgICAgIGRldmljZSA9IHJhbmREZXZpY2VXaXRoSWQoMzIpOwogICAgICAgICAgICBkZXZpY2UuaWQgPSBkZXZpY2UuaWQudG9Mb3dlckNhc2UoKTsKICAgICAgICAgICAgZGV2aWNlLnVhID0gJ0RhbHZpay8yLjEuMCAoTGludXg7IFU7IEFuZHJvaWQgJyArIGRldmljZS5yZWxlYXNlICsgJzsgJyArIGRldmljZS5tb2RlbCArICcgQnVpbGQvJyArIGRldmljZS5idWlsZElkICsgJyknOwogICAgICAgICAgICBzZXRJdGVtKCdkZXZpY2UnLCBKU09OLnN0cmluZ2lmeShkZXZpY2UpKQogICAgICAgIH0KICAgICAgICAvLyBsb2coJ2RldmljZTonKTsKICAgICAgICAvLyBsb2coZGV2aWNlKTsKICAgICAgICBhcHBVQSA9ICcoTW96aWxsYS81LjAgKExpbnV4OyBBbmRyb2lkICcgKyBkZXZpY2UucmVsZWFzZSArICc7ICcgKyBkZXZpY2UubW9kZWwgKyAnIEJ1aWxkLycgKyBkZXZpY2UuYnVpbGRJZCArICc7IHd2KSBBcHBsZVdlYktpdC81MzcuMzYgKEtIVE1MLCBsaWtlIEdlY2tvKSBWZXJzaW9uLzQuMCBDaHJvbWUvNjguMC4zNDQwLjcwIE1vYmlsZSBTYWZhcmkvNTM3LjM2KSc7CgogICAgICAgIHRyeSB7CiAgICAgICAgICAgIGxldCBodG1sID0gcmVxdWVzdChydWxlLmhvc3QgKyAnLycgKyBhcHBWZXJzaW9uICsgJy5qc29uJyk7CiAgICAgICAgICAgIGxldCBjb250ZW50ID0gSlNPTi5wYXJzZShodG1sKTsKICAgICAgICAgICAgLy8gbG9nKGNvbnRlbnQuZGF0YSk7CiAgICAgICAgICAgIHZhciBkYXRhcyA9IGNvbnRlbnQuZGF0YS5zcGxpdCgnJDZjMWNlZjc4YWU9Jyk7CiAgICAgICAgICAgIHZhciBqc29uID0gJyc7CiAgICAgICAgICAgIGZvciAobGV0IGQgb2YgZGF0YXMpIHsKICAgICAgICAgICAgICAgIC8vIGpzb24gKz0gcGsuZGVjcnlwdFB1YmxpYyhkLCAndXRmOCcpLnJlcGxhY2UoL15ccypcbnxccyokL2dtLCAnJyk7CiAgICAgICAgICAgICAgICBqc29uICs9IHBrLmRlY3J5cHRQdWJsaWMoZCwgJ3V0ZjgnKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBhcHBEYXRhID0gSlNPTi5wYXJzZShqc29uKTsKICAgICAgICAgICAgLy8gbG9nKGFwcERhdGEpOwogICAgICAgICAgICBhcHBVQSA9IGFwcERhdGEudWEgKyAnLycgKyBhcHBWZXJzaW9uICsgYXBwVUE7CiAgICAgICAgICAgIGxvZygnYXBwVUE6JyArIGFwcFVBKTsKICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICBjb25zb2xlLmxvZyhlcnJvcik7CiAgICAgICAgfQogICAgICAgIHJ1bGUuaGVhZGVycyA9IHsKICAgICAgICAgICAgJ1VzZXItQWdlbnQnOiBhcHBVQSwKICAgICAgICAgICAgUmVmZXJlcjogYXBwRGF0YS5odHRwX3JlZmVyZXIsCiAgICAgICAgfQogICAgfSksCiAgICBjbGFzc19wYXJzZTogJGpzLnRvU3RyaW5nKCgpID0+IHsKICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QoYXBwRGF0YS5qc29uX3VybCArICdjYXQvaW5kZXguanNvbicsIHsKICAgICAgICAgICAgaGVhZGVyczogcnVsZS5oZWFkZXJzCiAgICAgICAgfSk7CiAgICAgICAgbGV0IGNvbnRlbnQgPSBKU09OLnBhcnNlKGh0bWwpOwogICAgICAgIGxldCBkYXRhcyA9IGNvbnRlbnQuZGF0YTsKICAgICAgICBsZXQgY2xhc3NlcyA9IFtdOwogICAgICAgIGxldCBmaWx0ZXJPYmogPSB7fTsKICAgICAgICBmb3IgKGxldCBkYXRhIG9mIGRhdGFzKSB7CiAgICAgICAgICAgIGxldCBuYW1lID0gZGF0YS50aXRsZS5yZXBsYWNlKCfliIbnsbsnLCAnJyk7CgogICAgICAgICAgICBsZXQgdHlwZSA9IHsKICAgICAgICAgICAgICAgIGtleTogJ3R5cGUnLAogICAgICAgICAgICAgICAgbmFtZTogJ+exu+WeiycsCiAgICAgICAgICAgIH07CiAgICAgICAgICAgIHZhciBjdmFsdWVzID0gZGF0YS50eXBlcy5yZWR1Y2UoKHJlc3VsdCwgdCkgPT4gewogICAgICAgICAgICAgICAgcmVzdWx0LnB1c2goe246IHQubmFtZSwgdjogdC50eXBlX2lkfSk7CiAgICAgICAgICAgICAgICByZXR1cm4gcmVzdWx0OwogICAgICAgICAgICB9LCBbXSk7CiAgICAgICAgICAgIHR5cGVbJ2luaXQnXSA9IGN2YWx1ZXNbMF1bJ3YnXTsKICAgICAgICAgICAgdHlwZVsndmFsdWUnXSA9IGN2YWx1ZXM7CiAgICAgICAgICAgIGxldCBzb3J0ID0gewogICAgICAgICAgICAgICAga2V5OiAnc29ydCcsCiAgICAgICAgICAgICAgICBuYW1lOiAn5o6S5bqPJywKICAgICAgICAgICAgICAgIGluaXQ6ICdob3QnLAogICAgICAgICAgICB9OwogICAgICAgICAgICBsZXQgc29ydFZhbHVlcyA9IFtdOwogICAgICAgICAgICBzb3J0VmFsdWVzLnB1c2goe246ICfpu5jorqQnLCB2OiAnaW5kZXgnfSk7CiAgICAgICAgICAgIHNvcnRWYWx1ZXMucHVzaCh7bjogJ+eDremXqCcsIHY6ICdob3QnfSk7CiAgICAgICAgICAgIHNvcnRWYWx1ZXMucHVzaCh7bjogJ+i/nui9vScsIHY6ICdzZXJpYWwnfSk7CiAgICAgICAgICAgIHNvcnRWYWx1ZXMucHVzaCh7bjogJ+WujOe7kycsIHY6ICdkb25lJ30pOwogICAgICAgICAgICBzb3J0Wyd2YWx1ZSddID0gc29ydFZhbHVlczsKCiAgICAgICAgICAgIGZpbHRlck9ialt0eXBlWydpbml0J11dID0gW3R5cGUsIHNvcnRdOwogICAgICAgICAgICBjbGFzc2VzLnB1c2goewogICAgICAgICAgICAgICAgdHlwZV9pZDogdHlwZVsnaW5pdCddLAogICAgICAgICAgICAgICAgdHlwZV9uYW1lOiBuYW1lLAogICAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgICAgLy8gbG9nKGNsYXNzZXMpOwogICAgICAgIGlucHV0ID0gY2xhc3NlczsKICAgICAgICBob21lT2JqLmZpbHRlciA9IGZpbHRlck9iajsKCiAgICB9KSwKICAgIOaOqOiNkDogJycsCiAgICDkuIDnuqc6ICRqcy50b1N0cmluZygoKSA9PiB7CiAgICAgICAgVk9EUyA9IFtdOwogICAgICAgIGxldCB0eXBlID0gTVlfRkwudHlwZSB8fCBNWV9DQVRFOwogICAgICAgIGxldCBzb3J0ID0gTVlfRkwuc29ydCB8fCAnaG90JzsKICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QoYXBwRGF0YS5qc29uX3VybCArICdjYXRfbGlzdC8nICsgdHlwZSArICcvJyArIHNvcnQgKyAnLycgKyBNWV9QQUdFICsgJy5qc29uJywge2hlYWRlcnM6IHJ1bGUuaGVhZGVyc30pOwogICAgICAgIGxldCBjb250ZW50ID0gSlNPTi5wYXJzZShodG1sKTsKICAgICAgICBsZXQgZGF0YXMgPSBjb250ZW50LmRhdGE7CiAgICAgICAgbGV0IGJvb2tzID0gW107CiAgICAgICAgZm9yIChsZXQgYm9vayBvZiBkYXRhcy5ib29rcykgewogICAgICAgICAgICBib29rcy5wdXNoKHsKICAgICAgICAgICAgICAgIHZvZF9pZDogYm9vay5ib29rX2lkLAogICAgICAgICAgICAgICAgdm9kX25hbWU6IGJvb2submFtZSwKICAgICAgICAgICAgICAgIHZvZF9waWM6IGltZ1VybChib29rLnBpYyksCiAgICAgICAgICAgICAgICB2b2RfcmVtYXJrczogYm9vay5zdGF0dXMsCiAgICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgICBWT0RTID0gYm9va3M7CiAgICB9KSwKICAgIOS6jOe6pzogJGpzLnRvU3RyaW5nKCgpID0+IHsKICAgICAgICBsZXQgaWRzID0gW29ySWRdOwogICAgICAgIGxldCBib29rcyA9IFtdOwogICAgICAgIGZvciAobGV0IGlkIG9mIGlkcykgewogICAgICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QoYXBwRGF0YS5qc29uX3VybCArICdjb250LycgKyBpZCArICcuanNvbicsIHtoZWFkZXJzOiBydWxlLmhlYWRlcnN9KTsKICAgICAgICAgICAgbGV0IGNvbnRlbnQgPSBKU09OLnBhcnNlKGh0bWwpOwogICAgICAgICAgICBsZXQgZGF0YSA9IGNvbnRlbnQuZGF0YTsKICAgICAgICAgICAgbGV0IGJvb2sgPSB7CiAgICAgICAgICAgICAgICB2b2RfbmFtZTogZGF0YS5uYW1lLAogICAgICAgICAgICAgICAgdm9kX3BpYzogaW1nVXJsKGRhdGEucGljKSwKICAgICAgICAgICAgICAgIHR5cGVfbmFtZTogJycsCiAgICAgICAgICAgICAgICB2b2RfeWVhcjogZGF0YS50aW1lLAogICAgICAgICAgICAgICAgdm9kX2FyZWE6ICcnLAogICAgICAgICAgICAgICAgdm9kX3JlbWFya3M6IGRhdGEuc3RhdHVzLAogICAgICAgICAgICAgICAgdm9kX2FjdG9yOiBkYXRhLnRlbGxlciwKICAgICAgICAgICAgICAgIHZvZF9kaXJlY3RvcjogJycsCiAgICAgICAgICAgICAgICB2b2RfY29udGVudDogZGF0YS5zeW5vcHNpcywKICAgICAgICAgICAgICAgIHZvZF9wbGF5X2Zyb206ICfpgZPplb/lnKjnur8nLAogICAgICAgICAgICB9OwogICAgICAgICAgICAvLyBsb2coYm9vayk7CiAgICAgICAgICAgIGxldCB1cyA9IGRhdGEucGxheV9kYXRhCiAgICAgICAgICAgICAgICAubWFwKGZ1bmN0aW9uIChiKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZvcm1hdFBsYXlVcmwoYm9vay52b2RfbmFtZSwgYi5uYW1lKSArICckJyArIGRhdGEuYm9va19pZCArICctJyArIGIucGxheV9pZDsKICAgICAgICAgICAgICAgIH0pCiAgICAgICAgICAgICAgICAuam9pbignIycpOwogICAgICAgICAgICBib29rLnZvZF9wbGF5X3VybCA9IHVzOwogICAgICAgICAgICBib29rcy5wdXNoKGJvb2spOwogICAgICAgIH0KICAgICAgICBWT0QgPSBib29rcy5sZW5ndGggPiAwID8gYm9va3NbMF0gOiB7fTsKICAgIH0pLAogICAg5pCc57SiOiAkanMudG9TdHJpbmcoKCkgPT4gewogICAgICAgIGxldCB0aW1lID0gTWF0aC5mbG9vcihuZXcgRGF0ZS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SlNPTi5zdHJpbmdpZnkocnVsZS5oZWFkZXJzKSk7CiAgICAgICAgLy8gaGVhZGVyc1snQWNjZXB0J10gPSAnYXBwbGljYXRpb24vanNvbiwgdGV4dC9wbGFpbiwgKi8qJzsKICAgICAgICBoZWFkZXJzWydDb250ZW50LVR5cGUnXSA9ICdhcHBsaWNhdGlvbi94LXd3dy1mb3JtLXVybGVuY29kZWQnOwogICAgICAgIGxldCBodG1sID0gcG9zdChhcHBEYXRhLmFwaV91cmwsIHsKICAgICAgICAgICAgaGVhZGVyczogaGVhZGVycywKICAgICAgICAgICAgLy8gYm9keTogcG9zdF9kYXRhLAogICAgICAgICAgICBkYXRhOiBwb3N0X29iaiwKICAgICAgICB9KTsKICAgICAgICBsZXQgY29udGVudCA9IEpTT04ucGFyc2UoaHRtbCk7CiAgICAgICAgdmFyIGRhdGFzID0gY29udGVudC5kYXRhOwogICAgICAgIGxldCBib29rcyA9IFtdOwogICAgICAgIGZvciAobGV0IGJvb2sgb2YgZGF0YXMuYm9va3MpIHsKICAgICAgICAgICAgYm9va3MucHVzaCh7CiAgICAgICAgICAgICAgICB2b2RfaWQ6IGJvb2suYm9va19pZCwKICAgICAgICAgICAgICAgIHZvZF9uYW1lOiBib29rLm5hbWUsCiAgICAgICAgICAgICAgICB2b2RfcGljOiBpbWdVcmwoYm9vay5waWMpLAogICAgICAgICAgICAgICAgdm9kX3JlbWFya3M6IGJvb2suc3RhdHVzLAogICAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgICAgVk9EUyA9IGJvb2tzOwogICAgfSksCiAgICBsYXp5OiAkanMudG9TdHJpbmcoKCkgPT4gewogICAgICAgIHZhciBpbmZvID0gaW5wdXQuc3BsaXQoJy0nKTsKICAgICAgICBsZXQgdGltZSA9IE1hdGguZmxvb3IobmV3IERhdGUoKS5nZXRUaW1lKCkgLyAxMDAwKTsKICAgICAgICB0aW1lID0gdGltZSAtICh0aW1lICUgNjApOwogICAgICAgIGxldCB0ID0gQ3J5cHRvS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BpX3VybCk7CiAgICAgICAgbGV0IGhlYWRlcnMgPSBKU09OLnBhcnNlKEpTT04uc3RyaW5naWZ5KHJ1bGUuaGVhZGVycykpOwogICAgICAgIC8vIGhlYWRlcnNbJ0FjY2VwdCddID0gJ2FwcGxpY2F0aW9uL2pzb24sIHRleHQvcGxhaW4sICovKic7CiAgICAgICAgaGVhZGVyc1snQ29udGVudC1UeXBlJ10gPSAnYXBwbGljYXRpb24veC13d3ctZm9ybS11cmxlbmNvZGVkJzsKICAgICAgICBsZXQgaHRtbCA9IHBvc3QoYXBwRGF0YS5hcGlfdXJsLCB7CiAgICAgICAgICAgIGhlYWRlcnM6IGhlYWRlcnMsCiAgICAgICAgICAgIC8vIGJvZHk6IHBvc3RfZGF0YSwKICAgICAgICAgICAgZGF0YTogcG9zdF9vYmosCiAgICAgICAgfSk7CiAgICAgICAgbGV0IGNvbnRlbnQgPSBKU09OLnBhcnNlKGh0bWwpOwogICAgICAgIHZhciBkYXRhcyA9IGNvbnRlbnQuZGF0YTsKICAgICAgICBpbnB1dCA9IHsKICAgICAgICAgICAgcGFyc2U6IDAsCiAgICAgICAgICAgIHVybDogZGF0YXMudXJsLAogICAgICAgICAgICBoZWFkZXI6IHsKICAgICAgICAgICAgICAgICdVc2VyLUFnZW50JzogYXBwVUEsCiAgICAgICAgICAgICAgICBSZWZlcmVyOiBhcHBEYXRhLnJlZmVyZXIsCiAgICAgICAgICAgIH0sCiAgICAgICAgfTsKICAgIH0pLAp9 |