{
"id": "ssc-mainnet1",
"json": {
"contractName": "contract",
"contractAction": "deploy",
"contractPayload": {
"name": "nftmarket",
"params": "",
"code": "LyogZXNsaW50LWRpc2FibGUgbm8tYXdhaXQtaW4tbG9vcCAqLwovKiBlc2xpbnQtZGlzYWJsZSBtYXgtbGVuICovCi8qIGVzbGludC1kaXNhYmxlIHByZWZlci10ZW1wbGF0ZSAqLwovKiBlc2xpbnQtZGlzYWJsZSBuby11bmRlcnNjb3JlLWRhbmdsZSAqLwovKiBnbG9iYWwgYWN0aW9ucywgYXBpICovCgpjb25zdCBDT05UUkFDVF9OQU1FID0gJ25mdG1hcmtldCc7CgovLyBjYW5ub3QgYnV5IG9yIHNlbGwgbW9yZSB0aGFuIHRoaXMgbnVtYmVyIG9mIE5GVCBpbnN0YW5jZXMgaW4gb25lIGFjdGlvbgpjb25zdCBNQVhfTlVNX1VOSVRTX09QRVJBQkxFID0gNTA7CgphY3Rpb25zLmNyZWF0ZVNTQyA9IGFzeW5jICgpID0+IHsKICAvLyBub3RoaW5nIHRvIGRvIGhlcmUKfTsKCi8vIGNoZWNrIHRoYXQgdG9rZW4gdHJhbnNmZXJzIHN1Y2NlZWRlZApjb25zdCBpc1Rva2VuVHJhbnNmZXJWZXJpZmllZCA9IChyZXN1bHQsIGZyb20sIHRvLCBzeW1ib2wsIHF1YW50aXR5LCBldmVudFN0cikgPT4gewogIGlmIChyZXN1bHQuZXJyb3JzID09PSB1bmRlZmluZWQKICAgICYmIHJlc3VsdC5ldmVudHMgJiYgcmVzdWx0LmV2ZW50cy5maW5kKGVsID0+IGVsLmNvbnRyYWN0ID09PSAndG9rZW5zJyAmJiBlbC5ldmVudCA9PT0gZXZlbnRTdHIKICAgICYmIGVsLmRhdGEuZnJvbSA9PT0gZnJvbSAmJiBlbC5kYXRhLnRvID09PSB0byAmJiBlbC5kYXRhLnF1YW50aXR5ID09PSBxdWFudGl0eSAmJiBlbC5kYXRhLnN5bWJvbCA9PT0gc3ltYm9sKSAhPT0gd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AgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IG9yZGVycy5sZW5ndGg7IGkgKz0gMSkgewogICAgICAgICAgY29uc3Qgb3JkZXIgPSBvcmRlcnNbaV07CiAgICAgICAgICBjb25zdCBvbGRQcmljZSA9IG9yZGVyLnByaWNlOwogICAgICAgICAgb3JkZXIucHJpY2UgPSBmaW5hbFByaWNlOwogICAgICAgICAgb3JkZXIucHJpY2VEZWMgPSB7ICRudW1iZXJEZWNpbWFsOiBmaW5hbFByaWNlIH07CgogICAgICAgICAgYXdhaXQgYXBpLmRiLnVwZGF0ZShtYXJrZXRUYWJsZU5hbWUsIG9yZGVyKTsKCiAgICAgICAgICBhcGkuZW1pdCgnY2hhbmdlUHJpY2UnLCB7CiAgICAgICAgICAgIHN5bWJvbCwKICAgICAgICAgICAgbmZ0SWQ6IG9yZGVyLm5mdElkLAogICAgICAgICAgICBvbGRQcmljZSwKICAgICAgICAgICAgbmV3UHJpY2U6IG9yZGVyLnByaWNlLAogICAgICAgICAgICBwcmljZVN5bWJvbDogb3JkZXIucHJpY2VTeW1ib2wsCiAgICAgICAgICAgIG9yZGVySWQ6IG9yZGVyLl9pZCwKICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgfQogICAgfQogIH0KfTsKCmFjdGlvbnMuY2FuY2VsID0gYXN5bmMgKHBheWxvYWQpID0+IHsKICBjb25zdCB7CiAgICBzeW1ib2wsCiAgICBuZnRzLAogICAgaXNTaWduZWRXaXRoQWN0aXZlS2V5LAogIH0gPSBwYXlsb2FkOwoKICBpZiAoIWFwaS5hc3NlcnQoc3ltYm9sICYmIHR5cGVvZiBzeW1ib2wgPT09ICdzdHJpbmcnLCAnaW52YWxpZCBwYXJhbXMnKSkgewogICAgcmV0dXJuOwogIH0KCiAgY29uc3QgbWFya2V0VGFibGVOYW1lID0gc3ltYm9sICsgJ3NlbGxCb29rJzsKICBjb25zdCB0YWJsZUV4aXN0cyA9IGF3YWl0IGFwaS5kYi50YWJsZUV4aXN0cy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ib2wgPSAnJzsKICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBvcmRlcnMubGVuZ3RoOyBpICs9IDEpIHsKICAgICAgICBjb25zdCBvcmRlciA9IG9yZGVyc1tpXTsKICAgICAgICBpZiAocHJpY2VTeW1ib2wgPT09ICcnKSB7CiAgICAgICAgICAoeyBwcmljZVN5bWJvbCB9ID0gb3JkZXIpOwogICAgICAgIH0KICAgICAgICBpZiAoIWFwaS5hc3NlcnQob3JkZXIuYWNjb3VudCA9PT0gYXBpLnNlbmRlciAmJiBvcmRlci5vd25lZEJ5ID09PSAndScsICdhbGwgb3JkZXJzIG11c3QgYmUgeW91ciBvd24nKQogICAgICAgICAgfHwgIWFwaS5hc3NlcnQocHJpY2VTeW1ib2wgPT09IG9yZGVyLnByaWNlU3ltYm9sLCAnYWxsIG9yZGVycyBtdXN0IGhhdmUgdGhlIHNhbWUgcHJpY2Ugc3ltYm9sJykpIHsKICAgICAgICAgIHJldHVybjsKICAgICAgICB9CiAgICAgICAgaWRzLnB1c2gob3JkZXIubmZ0SWQpOwogICAgICAgIGlkTWFwW29yZGVyLm5mdElkXSA9IG9yZGVyOwogICAgICB9CgogICAgICAvLyBtb3ZlIHRoZSBsb2NrZWQgTkZUcyBiYWNrIHRvIHRoZWlyIG93bmVyCiAgICAgIGNvbnN0IG5mdEFycmF5ID0gW107CiAgICAgIGNvbnN0IHdyYXBwZWROZnRzID0gewogICAgICAgIHN5bWJvbCwKICAgICAgICBpZHMsCiAgICAgIH07CiAgICAgIG5mdEFycmF5LnB1c2god3JhcHBlZE5mdHMpOwogICAgICBjb25zdCByZXMgPSBhd2FpdCBhcGkuZXhlY3V0ZVNtYXJ0Q29udHJhY3QoJ25mdCcsICd0cmFuc2ZlcicsIHsKICAgICAgICBmcm9tVHlwZTogJ2NvbnRyYWN0JywKICAgICAgICB0bzogYXBpLnNlbmRlciwKICAgICAgICB0b1R5cGU6ICd1c2VyJywKICAgICAgICBuZnRzOiBuZnRBcnJheSwKICA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0YW5jZUlkID0gZXYuZGF0YS5pZDsKICAgICAgICAgICAgaWYgKGluc3RhbmNlSWQgaW4gaWRNYXApIHsKICAgICAgICAgICAgICBjb25zdCBvcmRlciA9IGlkTWFwW2luc3RhbmNlSWRdOwoKICAgICAgICAgICAgICBhd2FpdCBhcGkuZGIucmVtb3ZlKG1hcmtldFRhYmxlTmFtZSwgb3JkZXIpOwoKICAgICAgICAgICAgICBhcGkuZW1pdCgnY2FuY2VsT3JkZXInLCB7CiAgICAgICAgICAgICAgICBhY2NvdW50OiBvcmRlci5hY2NvdW50LAogICAgICAgICAgICAgICAgb3duZWRCeTogb3JkZXIub3duZWRCeSwKICAgICAgICAgICAgICAgIHN5bWJvbCwKICAgICAgICAgICAgICAgIG5mdElkOiBvcmRlci5uZnRJZCwKICAgICAgICAgICAgICAgIHRpbWVzdGFtcDogb3JkZXIudGltZXN0YW1wLAogICAgICAgICAgICAgICAgcHJpY2U6IG9yZGVyLnByaWNlLAogICAgICAgICAgICAgICAgcHJpY2VTeW1ib2w6IG9yZGVyLnByaWNlU3ltYm9sLAogICAgICAgICAgICAgICAgZmVlOiBvcmRlci5mZWUsCiAgICAgICAgICAgICAgICBvcmRlcklkOiBvcmRlci5faWQsCiAgICAgICAgICAgICAgfSk7CgogICAgICAgICAgICAgIGNvbnN0IGtleSA9IG1ha2VHcm91cGluZ0tleShvcmRlci5ncm91cGluZywgbmZ0Lmdyb3VwQnkpOwogICAgICAgICAgICAgIGNvbnN0IGdyb3VwSW5mbyA9IGtleSBpbiBncm91cGluZ01hcAogICAgICAgICAgICAgICAgPyBncm91cGluZ01hcFtrZXldCiAgICAgICAgICAgICAgICA6IHsKICAgICAgICAgICAgICAgICAgZ3JvdXBpbmc6IG9yZGVyLmdyb3VwaW5nLAogICAgICAgICAgICAgICAgICBpc0luQ29sbGVjdGlvbjogZmFsc2UsCiAgICAgICAgICAgICAgICAgIGNvdW50OiAwLAogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICBncm91c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JzW2ldOwogICAgICAgICAgaWYgKHByaWNlU3ltYm9sID09PSAnJykgewogICAgICAgICAgICAoeyBwcmljZVN5bWJvbCB9ID0gb3JkZXIpOwogICAgICAgICAgfQogICAgICAgICAgaWYgKCFhcGkuYXNzZXJ0KCEob3JkZXIub3duZWRCeSA9PT0gJ3UnICYmIG9yZGVyLmFjY291bnQgPT09IGFwaS5zZW5kZXIpLCAnY2Fubm90IGZpbGwgeW91ciBvd24gb3JkZXJzJykKICAgICAgICAgICAgfHwgIWFwaS5hc3NlcnQocHJpY2VTeW1ib2wgPT09IG9yZGVyLnByaWNlU3ltYm9sLCAnYWxsIG9yZGVycyBtdXN0IGhhdmUgdGhlIHNhbWUgcHJpY2Ugc3ltYm9sJykpIHsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICAvLyBnZXQgdGhlIHByaWNlIHRva2VuIHBhcmFtcwogICAgICAgIGNvbnN0IHRva2VuID0gYXdhaXQgYXBpLmRiLmZpbmRPbmVJblRhYmxlKCd0b2tlbnMnLCAndG9rZW5zJywgeyBzeW1ib2w6IHByaWNlU3ltYm9sIH0pOwogICAgICAgIGlmICghdG9rZW4pIHsKICAgICAgICAgIHJldHVybjsKICAgICAgICB9CgogICAgICAgIC8vIGNyZWF0ZSBvcmRlciBtYXBzCiAgICAgICAgbGV0IGZlZVRvdGFsID0gYXBpLkJpZ051bWJlcigwKTsKICAgICAgICBsZXQgcGF5bWVudFRvdGFsID0gYXBpLkJpZ051bWJlcigwKTsKICAgICAgICBsZXQgc29sZE5mdHMgPSBbXTsKICAgICAgICBjb25zdCBzZWxsZXJzID0gW107CiAgICAgICAgY29uc3Qgc2VsbGVyTWFwID0ge307CiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBvcmRlcnMubGVuZ3RoOyBpICs9IDEpIHsKICAgICAgICAgIGNvbnN0IG9yZGVyID0gb3JkZXJzW2ldOwogICAgICAgICAgY29uc3QgZmluYWxQcmljZSA9IGFwaS5CaWdOdW1iZXIob3JkZXIucHJpY2UpOwogICAgICAgICAgY29uc3QgZmVlUGVyY2VudCA9IG9yZGVyLmZlZSAvIDEwMDAwOwogICAgICAgICAgbGV0IGZpbmFsRmVlID0gZmluYWxQcmljZS5tdWx0aXBsaWVkQnkoZmVlUGVyY2VudCkuZGVjaW1hbFBsYWNlcyh0b2tlbi5wcmVjaXNpb24pOwogICAgICAgICAgaWYgKGZpbmFsRmVlLmd0KGZpbmFsUHJpY2UpKSB7CiAgICAgICAgICAgIGZpbmFsRmVlID0gZmluYWxQcmljZTsgLy8gdW5saWtlbHkgYnV0IG5lZWQgdG8gYmUgc3VyZQogICAgICAgICAgfQogICAgICAgICAgbGV0IGZpbmFsUGF5bWVudCA9IGZpbmFsUHJpY2UubWludXMoZmluYWxGZWUpLmRlY2ltYWxQbGFjZXModG9rZW4ucHJlY2lzaW9uKTsKICAgICAgICAgIGlmIChmaW5hbFBheW1lbnQubHQoMCkpIHsKICAgICAgICAgICAgZmluYWxQYXltZW50ID0gYXBpLkJpZ051bWJlcigwKTsgLy8gdW5saWtlbHkgYnV0IG5lZWQgdG8gYmUgc3VyZQogICAgICAgICAgfQogICAgICAgICAgcGF5bWVudFRvdGFsID0gcGF5bWVudFRvdGFsLnBsdXMoZmluYWxQYXltZW50KTsKICAgICAgICAgIGZlZVRvdGFsID0gZmVlVG90YWwucGx1cyhmaW5hbEZlZSk7CgogICAgICAgICAgY29uc3Qga2V5ID0gbWFrZU1hcEtleShvcmRlci5hY2NvdW50LCBvcmRlci5vd25lZEJ5KTsKICAgICAgICAgIGNvbnN0IHNlbGxlckluZm8gPSBrZXkgaW4gc2VsbGVyTWFwCiAgICAgICAgICAgID8gc2VsbGVyTWFwW2tleV0KICAgICAgICAgICAgOiB7CiAgICAgICAgICAgICAgYWNjb3VudDogb3JkZXIuYWNjb3VudCwKICAgICAgICAgICAgICBvd25lZEJ5OiBvcmRlci5vd25lZEJ5LAogICAgICAgICAgICAgIG5mdElkczogW10sCiAgICAgICAgICAgICAgcGF5bWVudFRvdGFsOiBhcGkuQmlnTnVtYmVyKDApLAogICAgICAgICAgICB9OwoKICAgICAgICAgIHNlbGxlckluZm8ucGF5bWVudFRvdGFsID0gc2VsbGVySW5mby5wYXltZW50VG90YWwucGx1cyhmaW5hbFBheW1lbnQpOwogICAgICAgICAgc2VsbGVySW5mby5uZnRJZHMucHVzaChvcmRlci5uZnRJZCk7CiAgICAgICAgICBzZWxsZXJNYXBba2V5XSA9IHNlbGxlckluZm87CiAgICAgICAgfQoKICAgICAgICAvLyB2ZXJpZnkgYnV5ZXIgaGFzIGVub3VnaCBmdW5kcyBmb3IgcGF5bWVudAogICAgICAgIGNvbnN0IHJlcXVpcmVkQmFsYW5jZSA9IHBheW1lbnRUb3RhbC5wbHVzKGZlZVRvdGFsKS50b0ZpeGVkKHRva2VuLnByZWNpc2lvbik7CiAgICAgICAgY29uc3QgYnV5ZXJCYWxhbmNlID0gYXdhaXQgYXBpLmRiLmZpbmRPbmVJblRhYmxlKCd0b2tlbnMnLCAnYmFsYW5jZXMnLCB7IGFjY291bnQ6IGFwaS5zZW5kZXIsIHN5bWJvbDogcHJpY2VTeW1ib2wgfSk7CiAgICAgICAgaWYgKCFhcGkuYXNzZXJ0KGJ1eWVyQmFsYW5jZQogICAgICAgICAgJiYgYXBpLkJpZ051bWJlcihidXllckJhbGFuY2UuYmFsYW5jZSkuZ3RlKHJlcXVpcmVkQmFsYW5jZSksICd5b3UgbXVzdCBoYXZlIGVub3VnaCB0b2tlbnMgZm9yIHBheW1lbnQnKSkgewogICAgICAgICAgcmV0dXJuOwogICAgICAgIH0KICAgICAgICBwYXltZW50VG90YWwgPSBwYXltZW50VG90YWwudG9GaXhlZCh0b2tlbi5wcmVjaXNpb24pOwoKICAgICAgICAvLyBzZW5kIGZlZXMgdG8gbWFya2V0IGFjY291bnQKICAgICAgICBpZiAoZmVlVG90YWwuZ3QoMCkpIHsKICAgICAgICAgIGZlZVRvdGFsID0gZm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G9rZW5zJywgY29udHJhY3RBY3Rpb24sIHsKICAgICAgICAgICAgICB0bzogaW5mby5hY2NvdW50LCBzeW1ib2w6IHByaWNlU3ltYm9sLCBxdWFudGl0eTogaW5mby5wYXltZW50VG90YWwsIGlzU2lnbmVkV2l0aEFjdGl2ZUtleSwKICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIGlmIChhcGkuYXNzZXJ0KGlzVG9rZW5UcmFuc2ZlclZlcmlmaWVkKHJlcywgYXBpLnNlbmRlciwgaW5mby5hY2NvdW50LCBwcmljZVN5bWJvbCwgaW5mby5wYXltZW50VG90YWwsIGNvbnRyYWN0QWN0aW9uKSwgYHVuYWJsZSB0byB0cmFuc2ZlciBwYXltZW50IHRvICR7aW5mby5hY2NvdW50fWApKSB7CiAgICAgICAgICAgICAgc29sZE5mdHMgPSBzb2xkTmZ0cy5jb25jYXQoaW5mby5uZnRJZHMpOwogICAgICAgICAgICAgIHNlbGxlcnMucHVzaChpbmZvKTsKICAgICAgICAgICAgfQogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgc29sZE5mdHMgPSBzb2xkTmZ0cy5jb25jYXQoaW5mby5uZnRJZHMpOwogICAgICAgICAgICBzZWxsZXJzLnB1c2goaW5mbyk7CiAgICAgICAgICB9CiAgICAgICAgfQoKICAgICAgICAvLyB0cmFuc2ZlciBzb2xkIE5GVCBpbnN0YW5jZXMgdG8gbmV3IG93bmVyCiAgICAgICAgY29uc3QgbmZ0QXJyYXkgPSBbXTsKICAgICAgICBjb25zdCB3cmFwcGVkTmZ0cyA9IHsKICAgICAgICAgIHN5bWJvbCwKICAgICAgICAgIGlkczogc29sZE5mdHMsCiAgICAgICAgfTsKICAgICAgICBuZnRBcnJheS5wdXNoKHdyYXBwZWROZnRzKTsKICAgICAgICBhd2FpdCBhcGkuZXhlY3V0ZVNtYXJ0Q29udHJhY3QoJ25mdCcsICd0cmFuc2ZlcicsIHsKICAgICAgICAgIGZyb21UeXBlOiAnY29udHJhY3QnLAogICAgICAgICAgdG86IGFwaS5zZW5kZXIsCiAgICAgICAgICB0b1R5cGU6ICd1c2VyJywKICAgICAgICAgIG5mdHM6IG5mdEFycmF5LAogICAgICAgICAgaXNTaWduZWRXaXRoQWN0aXZlS2V5LAogICAgICAgIH0pOwoKICAgICAgICAvLyBkZWxldGUgc29sZCBtYXJrZXQgb3JkZXJzCiAgICAgICAgY29uc3QgZ3JvdXBpbmdNYXAgPSB7fTsKICAgICAgICBjb25zdCBzb2xkU2V0ID0gbmV3IFNldChzb2xkTmZ0cyk7CiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBvcmRlcnMubGVuZ3RoOyBpICs9IDEpIHsKICAgICAgICAgIGNvbnN0IG9yZGVyID0gb3JkZXJzW2ldOwogICAgICAgICAgaWYgKHNvbGRTZXQuaGFzKG9yZGVyLm5mdElkKSkgewogICAgICAgICAgICBhd2FpdCBhcGkuZGIucmVtb3ZlKG1hcmtldFRhYmxlTmFtZSwgb3JkZXIpOwoKICAgICAgICAgICAgY29uc3Qga2V5ID0gbWFrZUdyb3VwaW5nS2V5KG9yZGVyLmdyb3VwaW5nLCBuZnQuZ3JvdXBCeSk7CiAgICAgICAgICAgIGNvbnN0IGdyb3VwSW5mbyA9IGtleSBpbiBncm91cGluZ01hcAogICAgICAgICAgICAgID8gZ3JvdXBpbmdNYXBba2V5XQogICAgICAgICAgICAgIDogewogICAgICAgICAgICAgICAgZ3JvdXBpbmc6IG9yZGVyLmdyb3VwaW5nLAogICAgICAgICAgICAgICAgaXNJbkNvbGxlY3Rpb246IGZhbHNlLAogICAgICAgICAgICAgICAgY291bnQ6IDAsCiAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgZ3JvdXBJbmZvLmNvdW50IC09IDE7CiAgICAgICAgICAgIGdyb3VwaW5nTWFwW2tleV0gPSBncm91cEluZm87CiAgICAgICAgICB9CiAgICAgICAgfQoKICAgICAgICAvLyBhZGQgdGhlIHRyYWRlIHRvIHRoZSBoaXN0b3J5CiA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RhdGlvbgogICAgICAvLyBlcnJvcnMgJiB3aGF0bm90LCBzbyB3ZSBuZWVkIHRvIGxvb3Agb3ZlciB0aGUgdHJhbnNmZXIgcmVzdWx0cyBhbmQKICAgICAgLy8gb25seSBjcmVhdGUgbWFya2V0IG9yZGVycyBmb3IgdGhlIHRyYW5zZmVycyB0aGF0IHN1Y2NlZWRlZAogICAgICBpZiAocmVzLmV2ZW50cykgewogICAgICAgIGNvbnN0IGJsb2NrRGF0ZSA9IG5ldyBEYXRlKGAke2FwaS5zdGVlbUJsb2NrVGltZXN0YW1wfS4wMDBaYCk7CiAgICAgICAgY29uc3QgdGltZXN0YW1wID0gYmxvY2tEYXRlLmdldFRpbWUoKTsKICAgICAgICBjb25zdCBmaW5hbFByaWNlID0gYXBpLkJpZ051bWJlcihwcmljZSkudG9GaXhlZCh0b2tlbi5wcmVjaXNpb24pOwogICAgICAgIGNvbnN0IG5mdEludGVnZXJJZExpc3QgPSBbXTsKICAgICAgICBjb25zdCBvcmRlckRhdGFNYXAgPSB7fTsKCiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCByZXMuZXZlbnRzLmxlbmd0aDsgaSArPSAxKSB7CiAgICAgICAgICBjb25zdCBldiA9IHJlcy5ldmVudHNbaV07CiAgICAgICAgICBpZiAoZXYuY29udHJhY3QgJiYgZXYuZXZlbnQgJiYgZXYuZGF0YQogICAgICAgICAgICAmJiBldi5jb250cmFjdCA9PT0gJ25mdCcKICAgICAgICAgICAgJiYgZXYuZXZlbnQgPT09ICd0cmFuc2ZlcicKICAgICAgICAgICAgJiYgZXYuZGF0YS5mcm9tID09PSBhcGkuc2VuZGVyCiAgICAgICAgICAgICYmIGV2LmRhdGEuZnJvbVR5cGUgPT09ICd1JwogICAgICAgICAgICAmJiBldi5kYXRhLnRvID09PSBDT05UUkFDVF9OQU1FCiAgICAgICAgICAgICYmIGV2LmRhdGEudG9UeXBlID09PSAnYycKICAgICAgICAgICAgJiYgZXYuZGF0YS5zeW1ib2wgPT09IHN5bWJvbCkgewogICAgICAgICAgICAvLyB0cmFuc2ZlciBpcyB2ZXJpZmllZCwgbm93IHdlIGNhbiBhZGQgYSBtYXJrZXQgb3JkZXIKICAgICAgICAgICAgY29uc3QgaW5zdGFuY2VJZCA9IGV2LmRhdGEuaWQ7CgogICAgICAgICAgICBjb25zdCBvcmRlckRhdGEgPSB7CiAgICAgICAgICAgICAgbmZ0SWQ6IGluc3RhbmNlSWQsCiAgICAgICAgICAgICAgZ3JvdXBpbmc6IHt9LAogICAgICAgICAgICAgIGdyb3VwaW5nS2V5OiAnJywKICAgICAgICAgICAgfTsKICAgICAgICAgICAgY29uc3QgaW50ZWdlcklkID0gYXBpLkJpZ051bWJlcihpbnN0YW5jZUlkKS50b051bWJlcigpOwogICAgICAgICAgICBuZnRJbnRlZ2VySWRMaXN0LnB1c2goaW50ZWdlcklkKTsKICAgICAgICAgICAgb3JkZXJEYXRhTWFwW2ludGVnZXJJZF0gPSBvcmRlckRhdGE7CiAgICAgICAgICB9CiAgICAgICAgfQoKICAgICAgICAvLyBxdWVyeSBORlQgaW5zdGFuY2VzIHRvIGNvbnN0cnVjdCB0aGUgZ3JvdXBpbmcKICAgICAgICBjb25zdCBpbnN0YW5jZXMgPSBhd2FpdCBhcGkuZGIuZmluZEluVGFibGUoCiAgICAgICAgICAnbmZ0JywKICAgICAgICAgIGluc3RhbmNlVGFibGVOYW1lLAogICAgICAgICAgewogICAgICAgICAgICBfaWQ6IHsKICAgICAgICAgICAgICAkaW46IG5mdEludGVnZXJJZExpc3QsCiAgICAgICAgICAgIH0sCiAgICAgICAgICB9LAogICAgICAgICAgTUFYX05VTV9VTklUU19PUEVSQUJMRSwKICAgICAgICAgIDAsCiAgICAgICAgICBbeyBpbmRleDogJ19pZCcsIGRlc2NlbmRpbmc6IGZhbHNlIH1dLAogICAgICAgICk7CgogICAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgaW5zdGFuY2VzLmxlbmd0aDsgaiArPSAxKSB7CiAgICAgICAgICBjb25zdCBpbnN0YW5jZSA9IGluc3RhbmNlc1tqXTsKICAgICAgICAgIGNvbnN0IGdyb3VwaW5nID0ge307CiAgICAgICAgICBsZXQgZ3JvdXBpbmdLZXkgPSAnJzsKICAgICAgICAgIG5mdC5ncm91cEJ5LmZvckVhY2goKG5hbWUpID0+IHsKICAgICAgICAgICAgaWYgKGluc3RhbmNlLnByb3BlcnRpZXNbbmFtZV0gIT09IHVuZGVmaW5lZCAmJiBpbnN0YW5jZS5wcm9wZXJ0aWVzW25hbWVdICE9PSBudWxsKSB7CiAgICAgICAgICAgICAgZ3JvdXBpbmdbbmFtZV0gPSBpbnN0YW5jZS5wcm9wZXJ0aWVzW25hbWVdLnRvU3RyaW5nKCk7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgZ3JvdXBpbmdbbmFtZV0gPSAnJzsKICAgICAgICAgICAgfQogICAgICAgICAgICBncm91cGluZ0tleSA9IGdyb3VwaW5nS2V5ICsgJzonICsgbmFtZSArICc6JyArIGdyb3VwaW5nW25hbWVdOwogICAgICAgICAgfSk7CiAgICAgICAgICBvcmRlckRhdGFNYXBbaW5zdGFuY2UuX2lkXS5ncm91cGluZyA9IGdyb3VwaW5nOwogICAgICAgICAgb3JkZXJEYXRhTWFwW2luc3RhbmNlLl9pZF0uZ3JvdXBpbmdLZXkgPSBncm91cGluZ0tleTsKICAgICAgICB9CgogICAgICAgIC8vIGNyZWF0ZSB0aGUgb3JkZXJzCiAgICAgICAgY29uc3QgZ3JvdXBpbmdNYXAgPSB7fTsKICAgICAgICBmb3IgKGxldCBrID0gMDsgayA8IG5mdEludGVnZXJJZExpc3QubGVuZ3RoOyBrICs9IDEpIHsKICAgICAgICAgIGNvbnN0IGludElkID0gbmZ0SW50ZWdlcklkTGlzdFtrXTsKICAgICAgICAgIGNvbnN0IG9yZGVySW5mbyA9IG9yZGVyRGF0YU1hcFtpbnRJZF07CiAgICAgICAgICBjb25zdCBvcmRlciA9IHsKICAgICAgICAgICAgYWNjb3VudDogYXBpLnNlbmRlciwKICAgICAgICAgICAgb3duZWRCeTogJ3UnLAogICAgICAgICAgICBuZnRJZDogb3JkZXJJbmZvLm5mdElkLAogICAgICAgICAgICBncm91cGluZzogb3JkZXJJbmZvLmdyb3VwaW5nLAogICAgICAgICAgICB0aW1lc3RhbXAsCiAgICAgICAgICAgIHByaWNlOiBmaW5hbFByaWNlLAogICAgICAgICAgICBwcmljZURlYzogeyAkbnVtYmVyRGVjaW1hbDogZmluYWxQcmljZSB9LAogICAgICAgICAgICBwcmljZVN5bWJvbCwKICAgICAgICAgICAgZmVlLAogICAgICAgICAgfTsKCiAgICAgICAgICBjb25zdCByZXN1bHQgPSBhd2FpdCBhcGkuZGIuaW5zZXJ0KG1hcmtldFRhYmxlTmFtZSwgb3JkZXIpOwoKICAgICAgICAgIGFwaS5lbWl0KCdzZWxsT3JkZXInLCB7CiAgICAgICAgICAgIGFjY291bnQ6IG9yZGVyLmFjY291bnQsCiAgICAgICAgICAgIG93bmVkQnk6IG9yZGVyLm93bmVkQnksCiAgICAgICAgICAgIHN5bWJvbCwKICAgICAgICAgICAgbmZ0SWQ6IG9yZGVyLm5mdElkLAogICAgICAgICAgICB0aW1lc3RhbXAsCiAgICAgICAgICAgIHByaWNlOiBvcmRlci5wcmljZSwKICAgICAgICAgICAgcHJpY2VTeW1ib2w6IG9yZGVyLnByaWNlU3ltYm9sLAogICAgICAgICAgICBmZWUsCiAgICAgICAgICAgIG9yZGVySWQ6IHJlc3VsdC5faWQsCiAgICAgICAgICB9KTsKCiAgICAgICAgICBjb25zdCBncm91cEluZm8gPSBvcmRlckluZm8uZ3JvdXBpbmdLZXkgaW4gZ3JvdXBpbmdNYXAKICAgICAgICAgICAgPyBncm91cGluZ01hcFtvcmRlckluZm8uZ3JvdXBpbmdLZXldCiAgICAgICAgICAgIDogewogICAgICAgICAgICAgIGdyb3VwaW5nOiBvcmRlckluZm8uZ3JvdXBpbmcsCiAgICAgICAgICAgICAgaXNJbkNvbGxlY3Rpb246IGZhbHNlLAogICAgICAgICAgICAgIGNvdW50OiAwLAogICAgICAgICAgICB9OwogICAgICAgICAgZ3JvdXBJbmZvLmNvdW50ICs9IDE7CiAgICAgICAgICBncm91cGluZ01hcFtvcmRlckluZm8uZ3JvdXBpbmdLZXldID0gZ3JvdXBJbmZvOwogICAgICAgIH0KCiAgICAgICAgLy8gdXBkYXRlIG9wZW4gaW50ZXJlc3QgbWV0cmljcwogICAgICAgIGF3YWl0IHVwZGF0ZU9wZW5JbnRlcmVzdCgnc2VsbCcsIHN5bWJvbCwgcHJpY2VTeW1ib2wsIGdyb3VwaW5nTWFwLCBuZnQuZ3JvdXBCeSk7CiAgICAgIH0KICAgIH0KICB9Cn07Cg=="
}
}
}
Sort: Trending