Medau Therapy Services GmbH | Schloss Hohenfels| 96450 Coburg
Medau Therapy Services GmbH | Schloss Hohenfels| 96450 Coburg

Stellenangebote

Jobs bei der Medau Therapy Services GmbH

Wir suchen Verstärkung für alle MEDAUphysio Praxiseinheiten in Coburg 

Physiotherapeut (m/w/d) in Vollzeit

 

 

Initiativbewerbung

Haben Sie keine passende Stelle gefunden?
Schicken Sie uns Ihre Unterlagen als Initiativbewerbung.
Ihre Bewerbung richten Sie bitte vorzugsweise per Mail an:

MEDAU Therapy Services GmbH
Geschäftsleitung Dr. Peer H. Medau & Christian Jaks
Schloss Hohenfels
96450 Coburg

 

 

OpenStreetMap

Mit dem Laden der Karte akzeptieren Sie die Datenschutzerklärung von OpenStreetMap Foundation.
Mehr erfahren

Karte laden

ICAgICAgICA8ZGl2IAogICAgICAgICAgICBpZD0ibGVhZmxldC1tYXAtMSIgCiAgICAgICAgICAgIGNsYXNzPSJsZWFmbGV0LW1hcCIgCiAgICAgICAgICAgIHN0eWxlPSJoZWlnaHQ6NTAwcHg7IHdpZHRoOjEwMCU7Ij48L2Rpdj4KICAgICAgICA8c2NyaXB0PgogICAgICAgIHdpbmRvdy5XUExlYWZsZXRNYXBQbHVnaW4gPSB3aW5kb3cuV1BMZWFmbGV0TWFwUGx1Z2luIHx8IFtdOwogICAgICAgIHdpbmRvdy5XUExlYWZsZXRNYXBQbHVnaW4ucHVzaChmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgIHZhciBiYXNlVXJsID0gJ2h0dHBzOi8ve3N9LnRpbGUub3BlbnN0cmVldG1hcC5vcmcve3p9L3t4fS97eX0ucG5nJywKICAgICAgICAgICAgICAgIGJhc2UgPSAoIWJhc2VVcmwgJiYgd2luZG93Lk1RKSA/IAogICAgICAgICAgICAgICAgICAgIE1RLm1hcExheWVyKCkgOiBMLnRpbGVMYXllcihiYXNlVXJsLCB7IAogICAgICAgICAgICAgICAgICAgICAgICBzdWJkb21haW5zOiAnYWJjJwogICAgICAgICAgICAgICAgICAgIH0pLAogICAgICAgICAgICAgICAgb3B0aW9ucyA9IEwuVXRpbC5leHRlbmQoe30sIHsKICAgICAgICAgICAgICAgICAgICBtYXhab29tOiAyMCwKICAgICAgICAgICAgICAgICAgICBtaW5ab29tOiAwLAogICAgICAgICAgICAgICAgICAgIGxheWVyczogW2Jhc2VdLAogICAgICAgICAgICAgICAgICAgIHpvb21Db250cm9sOiAxLAogICAgICAgICAgICAgICAgICAgIHNjcm9sbFdoZWVsWm9vbTogMCwKICAgICAgICAgICAgICAgICAgICBkb3VibGVDbGlja1pvb206IDAsCiAgICAgICAgICAgICAgICAgICAgYXR0cmlidXRpb25Db250cm9sOiBmYWxzZQogICAgICAgICAgICAgICAgfSwge30pLAogICAgICAgICAgICAgICAgbWFwID0gTC5tYXAoJ2xlYWZsZXQtbWFwLTEnLCBvcHRpb25zKQogICAgICAgICAgICAgICAgICAgIC5zZXRWaWV3KFs0OS4zNDQ5MzIsMTAuNjUxNTA1XSw3KTsKICAgICAgICAgICAgaWYgKDApIHsKICAgICAgICAgICAgICAgIG1hcC5fc2hvdWxkRml0Qm91bmRzID0gdHJ1ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGF0dENvbnRyb2wgPSBMLmNvbnRyb2wuYXR0cmlidXRpb24oe3ByZWZpeDpmYWxzZX0pLmFkZFRvKG1hcCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF0dENvbnRyb2wuYWRkQXR0cmlidXRpb24oJzxhIGhyZWY9Imh0dHA6Ly9sZWFmbGV0anMuY29tIiB0aXRsZT0iRWluZSBKYXZhc2NyaXB0LUJpYmxpb3RoZWsgZsO8ciBpbnRlcmFrdGl2ZSBLYXJ0ZW4iPkxlYWZsZXQ8L2E+Jyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF0dENvbnRyb2wuYWRkQXR0cmlidXRpb24oJ1xyXG7CqSA8YSBocmVmPSJodHRwOi8vd3d3Lm9wZW5zdHJlZXRtYXAub3JnL2NvcHlyaWdodCI+T3BlblN0cmVldE1hcDwvYT4gTWl0d2lya2VuZGUnKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdpbmRvdy5XUExlYWZsZXRNYXBQbHVnaW4ubWFwcy5wdXNoKG1hcCk7CiAgICAgICAgfSk7IC8vIGVuZCBhZGQKICAgICAgICA8L3NjcmlwdD4gICAgICAgIDxzY3JpcHQ+CiAgICAgICAgd2luZG93LldQTGVhZmxldE1hcFBsdWdpbiA9IHdpbmRvdy5XUExlYWZsZXRNYXBQbHVnaW4gfHwgW107CiAgICAgICAgd2luZG93LldQTGVhZmxldE1hcFBsdWdpbi5wdXNoKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgdmFyIG1hcmtlcl9vcHRpb25zID0gKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgIHZhciBfb3B0aW9ucyA9IHsiaWNvblVybCI6Ilwvd3AtY29udGVudFwvdXBsb2Fkc1wvMjAxN1wvMTBcL21hcmtlci1mbXctcGh5c2lvLnBuZyIsImljb25TaXplIjpbIjUxLDUxIl0sImljb25BbmNob3IiOlsiMjUuNSw1MSJdfTsKICAgICAgICAgICAgICAgIHZhciBpY29uQXJyYXlzID0gWwogICAgICAgICAgICAgICAgICAgICdpY29uU2l6ZScsIAogICAgICAgICAgICAgICAgICAgICdpY29uQW5jaG9yJywgCiAgICAgICAgICAgICAgICAgICAgJ3NoYWRvd1NpemUnLCAKICAgICAgICAgICAgICAgICAgICAnc2hhZG93QW5jaG9yJywKICAgICAgICAgICAgICAgICAgICAncG9wdXBBbmNob3InCiAgICAgICAgICAgICAgICBdOwogICAgICAgICAgICAgICAgdmFyIGRlZmF1bHRfaWNvbiA9IEwuSWNvbi5EZWZhdWx0LnByb3RvdHlwZS5vcHRpb25zOwogICAgICAgICAgICAgICAgaWYgKF9vcHRpb25zLmljb25VcmwpIHsKICAgICAgICAgICAgICAgICAgICAvLyBhcnJheXMgYXJlIHN0cmluZ3MsIHVuZm9ydHVuYXRlbHkuLi4KICAgICAgICAgICAgICAgICAgICBmb3IgKHZhciBpID0gMCwgbGVuID0gaWNvbkFycmF5cy5sZW5ndGg7IGkgPCBsZW47IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgb3B0aW9uX25hbWUgPSBpY29uQXJyYXlzW2ldLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb3B0aW9uID0gX29wdGlvbnNbIG9wdGlvbl9uYW1lIF07CiAgICAgICAgICAgICAgICAgICAgICAgIC8vIGNvbnZlcnQgIjEsMiIgdG8gWzEsIDJdOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAob3B0aW9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgYXJyID0gb3B0aW9uLmpvaW4oJycpLnNwbGl0KCcsJyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBhcnJheS5tYXAgZm9yIGllPDkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAodmFyIGogPSAwLCBsZW5KID0gYXJyLmxlbmd0aDsgaiA8IGxlbko7IGorKykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFycltqXSA9IE51bWJlcihhcnJbal0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgX29wdGlvbnNbIG9wdGlvbl9uYW1lIF0gPSBhcnI7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgLy8gZGVmYXVsdCBwb3B1cEFuY2hvcgogICAgICAgICAgICAgICAgICAgIGlmICghX29wdGlvbnMucG9wdXBBbmNob3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgLy8gc2V0IChyb3VnaGx5KSB0byBzaXplIG9mIGljb24KICAgICAgICAgICAgICAgICAgICAgICAgX29wdGlvbnMucG9wdXBBbmNob3IgPSAoZnVuY3Rpb24gKGlfc2l6ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gY29weSBhcnJheQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaV9zaXplID0gaV9zaXplLnNsaWNlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGludmVyc2UgY29vcmRpbmF0ZXMKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlfc2l6ZVswXSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpX3NpemVbMV0gKj0gLTE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBib3R0b20gcG9zaXRpb24gb24gcG9wdXAgaXMgN3B4CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpX3NpemVbMV0gLT0gMzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpX3NpemU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pKF9vcHRpb25zLmljb25TaXplIHx8IGRlZmF1bHRfaWNvbi5pY29uU2l6ZSk7CiAgICAgICAgICAgICAgICAgICAgfQoKICAgICAgICAgICAgICAgICAgICBfb3B0aW9ucy5pY29uID0gbmV3IEwuSWNvbiggX29wdGlvbnMgKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHJldHVybiBfb3B0aW9uczsKICAgICAgICAgICAgfSkoKTsKICAgICAgICAgICAgdmFyIGRyYWdnYWJsZSA9IG1hcmtlcl9vcHRpb25zLmRyYWdnYWJsZTsKICAgICAgICAgICAgdmFyIG1hcmtlciA9IEwubWFya2VyKAogICAgICAgICAgICAgICAgWzUwLjI1NTAxNywxMC45NjIyMzZdLCAKICAgICAgICAgICAgICAgIG1hcmtlcl9vcHRpb25zCiAgICAgICAgICAgICk7CiAgICAgICAgICAgIHZhciBtYXAgPSB3aW5kb3cuV1BMZWFmbGV0TWFwUGx1Z2luLmdldEN1cnJlbnRNYXAoKTsKICAgICAgICAgICAgdmFyIGlzX2ltYWdlID0gbWFwLmlzX2ltYWdlX21hcDsKICAgICAgICAgICAgdmFyIGdyb3VwID0gd2luZG93LldQTGVhZmxldE1hcFBsdWdpbi5nZXRDdXJyZW50R3JvdXAoKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRyYWdnYWJsZSkgewogICAgICAgICAgICAgICAgbWFya2VyLm9uKCdkcmFnZW5kJywgZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHZhciBsYXRsbmcgPSB0aGlzLmdldExhdExuZygpLAogICAgICAgICAgICAgICAgICAgICAgICBsYXQgPSBsYXRsbmcubGF0LAogICAgICAgICAgICAgICAgICAgICAgICBsbmcgPSBsYXRsbmcubG5nOwogICAgICAgICAgICAgICAgICAgIGlmIChpc19pbWFnZSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zb2xlLmxvZygnbGVhZmxldC1tYXJrZXIgeT0nICsgbGF0ICsgJyB4PScgKyBsbmcpOwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKCdsZWFmbGV0LW1hcmtlciBsYXQ9JyArIGxhdCArICcgbG5nPScgKyBsbmcpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIG1hcmtlci5hZGRUbyggZ3JvdXAgKTsKICAgICAgICAgICAgbWFya2VyLmJpbmRQb3B1cCh3aW5kb3cuV1BMZWFmbGV0TWFwUGx1Z2luLnVuZXNjYXBlKCdNRURBVXBoeXNpbyZsdDticiAvJmd0OyZsdDticiZndDtBaG9ybmVyIFN0cmHDn2UgOCZsdDticiAvJmd0OyZsdDticiZndDs5NjQ1MCBDb2J1cmcmbHQ7YnIgLyZndDsmbHQ7YnImZ3Q7VGVsZWZvbjogMDk1NjEtNzY1OTcmbHQ7YnIgLyZndDsmbHQ7YnImZ3Q7VGVsZWZheDogMDk1NjEtNTExMTU5NSZsdDticiAvJmd0OyZsdDticiZndDsmbHQ7YSBocmVmPVwmcXVvdDttYWlsdG86cHJheGlzLWFuZ2VyQG1lZGF1LXBoeXNpby5kZVwmcXVvdDsmZ3Q7cHJheGlzLWFuZ2VyQG1lZGF1LXBoeXNpby5kZSZsdDsvYSZndDsnKSk7ICAgICAgICAgICAgd2luZG93LldQTGVhZmxldE1hcFBsdWdpbi5tYXJrZXJzLnB1c2goIG1hcmtlciApOwogICAgICAgIH0pOyAvLyBlbmQgYWRkIGZ1bmN0aW9uCiAgICAgICAgPC9zY3JpcHQ+CiAgICAgICAgICAgICAgICA8c2NyaXB0PgogICAgICAgIHdpbmRvdy5XUExlYWZsZXRNYXBQbHVnaW4gPSB3aW5kb3cuV1BMZWFmbGV0TWFwUGx1Z2luIHx8IFtdOwogICAgICAgIHdpbmRvdy5XUExlYWZsZXRNYXBQbHVnaW4ucHVzaChmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgIHZhciBtYXJrZXJfb3B0aW9ucyA9IChmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICB2YXIgX29wdGlvbnMgPSB7Imljb25VcmwiOiJcL3dwLWNvbnRlbnRcL3VwbG9hZHNcLzIwMTdcLzEwXC9tYXJrZXItZm13LXBoeXNpby5wbmciLCJpY29uU2l6ZSI6WyI1MSw1MSJdLCJpY29uQW5jaG9yIjpbIjI1LjUsNTEiXX07CiAgICAgICAgICAgICAgICB2YXIgaWNvbkFycmF5cyA9IFsKICAgICAgICAgICAgICAgICAgICAnaWNvblNpemUnLCAKICAgICAgICAgICAgICAgICAgICAnaWNvbkFuY2hvcicsIAogICAgICAgICAgICAgICAgICAgICdzaGFkb3dTaXplJywgCiAgICAgICAgICAgICAgICAgICAgJ3NoYWRvd0FuY2hvcicsCiAgICAgICAgICAgICAgICAgICAgJ3BvcHVwQW5jaG9yJwogICAgICAgICAgICAgICAgXTsKICAgICAgICAgICAgICAgIHZhciBkZWZhdWx0X2ljb24gPSBMLkljb24uRGVmYXVsdC5wcm90b3R5cGUub3B0aW9uczsKICAgICAgICAgICAgICAgIGlmIChfb3B0aW9ucy5pY29uVXJsKSB7CiAgICAgICAgICAgICAgICAgICAgLy8gYXJyYXlzIGFyZSBzdHJpbmdzLCB1bmZvcnR1bmF0ZWx5Li4uCiAgICAgICAgICAgICAgICAgICAgZm9yICh2YXIgaSA9IDAsIGxlbiA9IGljb25BcnJheXMubGVuZ3RoOyBpIDwgbGVuOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIG9wdGlvbl9uYW1lID0gaWNvbkFycmF5c1tpXSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wdGlvbiA9IF9vcHRpb25zWyBvcHRpb25fbmFtZSBdOwogICAgICAgICAgICAgICAgICAgICAgICAvLyBjb252ZXJ0ICIxLDIiIHRvIFsxLCAyXTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG9wdGlvbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGFyciA9IG9wdGlvbi5qb2luKCcnKS5zcGxpdCgnLCcpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gYXJyYXkubWFwIGZvciBpZTw5CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKHZhciBqID0gMCwgbGVuSiA9IGFyci5sZW5ndGg7IGogPCBsZW5KOyBqKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcnJbal0gPSBOdW1iZXIoYXJyW2pdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9vcHRpb25zWyBvcHRpb25fbmFtZSBdID0gYXJyOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIC8vIGRlZmF1bHQgcG9wdXBBbmNob3IKICAgICAgICAgICAgICAgICAgICBpZiAoIV9vcHRpb25zLnBvcHVwQW5jaG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIC8vIHNldCAocm91Z2hseSkgdG8gc2l6ZSBvZiBpY29uCiAgICAgICAgICAgICAgICAgICAgICAgIF9vcHRpb25zLnBvcHVwQW5jaG9yID0gKGZ1bmN0aW9uIChpX3NpemUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGNvcHkgYXJyYXkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlfc2l6ZSA9IGlfc2l6ZS5zbGljZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBpbnZlcnNlIGNvb3JkaW5hdGVzCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpX3NpemVbMF0gPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaV9zaXplWzFdICo9IC0xOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gYm90dG9tIHBvc2l0aW9uIG9uIHBvcHVwIGlzIDdweAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaV9zaXplWzFdIC09IDM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gaV9zaXplOwogICAgICAgICAgICAgICAgICAgICAgICB9KShfb3B0aW9ucy5pY29uU2l6ZSB8fCBkZWZhdWx0X2ljb24uaWNvblNpemUpOwogICAgICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAgICAgX29wdGlvbnMuaWNvbiA9IG5ldyBMLkljb24oIF9vcHRpb25zICk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICByZXR1cm4gX29wdGlvbnM7CiAgICAgICAgICAgIH0pKCk7CiAgICAgICAgICAgIHZhciBkcmFnZ2FibGUgPSBtYXJrZXJfb3B0aW9ucy5kcmFnZ2FibGU7CiAgICAgICAgICAgIHZhciBtYXJrZXIgPSBMLm1hcmtlcigKICAgICAgICAgICAgICAgIFs1MC4yNDY5MDgsMTAuOTcxMDkzXSwgCiAgICAgICAgICAgICAgICBtYXJrZXJfb3B0aW9ucwogICAgICAgICAgICApOwogICAgICAgICAgICB2YXIgbWFwID0gd2luZG93LldQTGVhZmxldE1hcFBsdWdpbi5nZXRDdXJyZW50TWFwKCk7CiAgICAgICAgICAgIHZhciBpc19pbWFnZSA9IG1hcC5pc19pbWFnZV9tYXA7CiAgICAgICAgICAgIHZhciBncm91cCA9IHdpbmRvdy5XUExlYWZsZXRNYXBQbHVnaW4uZ2V0Q3VycmVudEdyb3VwKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkcmFnZ2FibGUpIHsKICAgICAgICAgICAgICAgIG1hcmtlci5vbignZHJhZ2VuZCcsIGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgbGF0bG5nID0gdGhpcy5nZXRMYXRMbmcoKSwKICAgICAgICAgICAgICAgICAgICAgICAgbGF0ID0gbGF0bG5nLmxhdCwKICAgICAgICAgICAgICAgICAgICAgICAgbG5nID0gbGF0bG5nLmxuZzsKICAgICAgICAgICAgICAgICAgICBpZiAoaXNfaW1hZ2UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc29sZS5sb2coJ2xlYWZsZXQtbWFya2VyIHk9JyArIGxhdCArICcgeD0nICsgbG5nKTsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zb2xlLmxvZygnbGVhZmxldC1tYXJrZXIgbGF0PScgKyBsYXQgKyAnIGxuZz0nICsgbG5nKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgfQogICAgICAgICAgICBtYXJrZXIuYWRkVG8oIGdyb3VwICk7CiAgICAgICAgICAgIG1hcmtlci5iaW5kUG9wdXAod2luZG93LldQTGVhZmxldE1hcFBsdWdpbi51bmVzY2FwZSgnJmx0O3N0cm9uZyZndDtNRURBVXBoeXNpbyZsdDsvc3Ryb25nJmd0OyZsdDticiAvJmd0OyZsd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ICAgdmFyIGljb25BcnJheXMgPSBbCiAgICAgICAgICAgICAgICAgICAgJ2ljb25TaXplJywgCiAgICAgICAgICAgICAgICAgICAgJ2ljb25BbmNob3InLCAKICAgICAgICAgICAgICAgICAgICAnc2hhZG93U2l6ZScsIAogICAgICAgICAgICAgICAgICAgICdzaGFkb3dBbmNob3InLAogICAgICAgICAgICAgICAgICAgICdwb3B1cEFuY2hvcicKICAgICAgICAgICAgICAgIF07CiAgICAgICAgICAgICAgICB2YXIgZGVmYXVsdF9pY29uID0gTC5JY29uLkRlZmF1bHQucHJvdG90eXBlLm9wdGlvbnM7CiAgICAgICAgICAgICAgICBpZiAoX29wdGlvbnMuaWNvblVybCkgewogICAgICAgICAgICAgICAgICAgIC8vIGFycmF5cyBhcmUgc3RyaW5ncywgdW5mb3J0dW5hdGVseS4uLgogICAgICAgICAgICAgICAgICAgIGZvciAodmFyIGkgPSAwLCBsZW4gPSBpY29uQXJyYXlzLmxlbmd0aDsgaSA8IGxlbjsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBvcHRpb25fbmFtZSA9IGljb25BcnJheXNbaV0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcHRpb24gPSBfb3B0aW9uc1sgb3B0aW9uX25hbWUgXTsKICAgICAgICAgICAgICAgICAgICAgICAgLy8gY29udmVydCAiMSwyIiB0byBbMSwgMl07CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChvcHRpb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBhcnIgPSBvcHRpb24uam9pbignJykuc3BsaXQoJywnKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGFycmF5Lm1hcCBmb3IgaWU8OQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yICh2YXIgaiA9IDAsIGxlbkogPSBhcnIubGVuZ3RoOyBqIDwgbGVuSjsgaisrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXJyW2pdID0gTnVtYmVyKGFycltqXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfb3B0aW9uc1sgb3B0aW9uX25hbWUgXSA9IGFycjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAvLyBkZWZhdWx0IHBvcHVwQW5jaG9yCiAgICAgICAgICAgICAgICAgICAgaWYgKCFfb3B0aW9ucy5wb3B1cEFuY2hvcikgewogICAgICAgICAgICAgICAgICAgICAgICAvLyBzZXQgKHJvdWdobHkpIHRvIHNpemUgb2YgaWNvbgogICAgICAgICAgICAgICAgICAgICAgICBfb3B0aW9ucy5wb3B1cEFuY2hvciA9IChmdW5jdGlvbiAoaV9zaXplKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBjb3B5IGFycmF5CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpX3NpemUgPSBpX3NpemUuc2xpY2UoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gaW52ZXJzZSBjb29yZGluYXRlcwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaV9zaXplWzBdID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlfc2l6ZVsxXSAqPSAtMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGJvdHRvbSBwb3NpdGlvbiBvbiBwb3B1cCBpcyA3cHgKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlfc2l6ZVsxXSAtPSAzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGlfc2l6ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfSkoX29wdGlvbnMuaWNvblNpemUgfHwgZGVmYXVsdF9pY29uLmljb25TaXplKTsKICAgICAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgICAgICAgIF9vcHRpb25zLmljb24gPSBuZXcgTC5JY29uKCBfb3B0aW9ucyApOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgcmV0dXJuIF9vcHRpb25zOwogICAgICAgICAgICB9KSgpOwogICAgICAgICAgICB2YXIgZHJhZ2dhYmxlID0gbWFya2VyX29wdGlvbnMuZHJhZ2dhYmxlOwogICAgICAgICAgICB2YXIgbWFya2VyID0gTC5tYXJrZXIoCiAgICAgICAgICAgICAgICBbNTAuMjY2NTE1MDU0MzE5NDEsMTAuOTQ5MjYzNDY2NjU2NDc1XSwgCiAgICAgICAgICAgICAgICBtYXJrZXJfb3B0aW9ucwogICAgICAgICAgICApOwogICAgICAgICAgICB2YXIgbWFwID0gd2luZG93LldQTGVhZmxldE1hcFBsdWdpbi5nZXRDdXJyZW50TWFwKCk7CiAgICAgICAgICAgIHZhciBpc19pbWFnZSA9IG1hcC5pc19pbWFnZV9tYXA7CiAgICAgICAgICAgIHZhciBncm91cCA9IHdpbmRvdy5XUExlYWZsZXRNYXBQbHVnaW4uZ2V0Q3VycmVudEdyb3VwKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkcmFnZ2FibGUpIHsKICAgICAgICAgICAgICAgIG1hcmtlci5vbignZHJhZ2VuZCcsIGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgbGF0bG5nID0gdGhpcy5nZXRMYXRMbmcoKSwKICAgICAgICAgICAgICAgICAgICAgICAgbGF0ID0gbGF0bG5nLmxhdCwKICAgICAgICAgICAgICAgICAgICAgICAgbG5nID0gbGF0bG5nLmxuZzsKICAgICAgICAgICAgICAgICAgICBpZiAoaXNfaW1hZ2UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc29sZS5sb2coJ2xlYWZsZXQtbWFya2VyIHk9JyArIGxhdCArICcgeD0nICsgbG5nKTsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zb2xlLmxvZygnbGVhZmxldC1tYXJrZXIgbGF0PScgKyBsYXQgKyAnIGxuZz0nICsgbG5nKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgfQogICAgICAgICAgICBtYXJrZXIuYWRkVG8oIGdyb3VwICk7CiAgICAgICAgICAgIG1hcmtlci5iaW5kUG9wdXAod2luZG93LldQTGVhZmxldE1hcFBsdWdpbi51bmVzY2FwZSgnTUVEQVVwaHlzaW8gU2NobG9zcyBIb2hlbmZlbHMnKSk7ICAgICAgICAgICAgd2luZG93LldQTGVhZmxldE1hcFBsdWdpbi5tYXJrZXJzLnB1c2goIG1hcmtlciApOwogICAgICAgIH0pOyAvLyBlbmQgYWRkIGZ1bmN0aW9uCiAgICAgICAgPC9zY3JpcHQ+CiAgICAgICAgICAgICAgICA8c2NyaXB0PgogICAgICAgIHdpbmRvdy5XUExlYWZsZXRNYXBQbHVnaW4gPSB3aW5kb3cuV1BMZWFmbGV0TWFwUGx1Z2luIHx8IFtdOwogICAgICAgIHdpbmRvdy5XUExlYWZsZXRNYXBQbHVnaW4ucHVzaChmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgIHZhciBtYXJrZXJfb3B0aW9ucyA9IChmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICB2YXIgX29wdGlvbnMgPSB7Imljb25VcmwiOiJcL3dwLWNvbnRlbnRcL3VwbG9hZHNcLzIwMTdcLzEwXC9tYXJrZXItZm13LXBoeXNpby5wbmciLCJpY29uU2l6ZSI6WyI1MSw1MSJdLCJpY29uQW5jaG9yIjpbIjI1LjUsNTEiXX07CiAgICAgICAgICAgICAgICB2YXIgaWNvbkFycmF5cyA9IFsKICAgICAgICAgICAgICAgICAgICAnaWNvblNpemUnLCAKICAgICAgICAgICAgICAgICAgICAnaWNvbkFuY2hvcicsIAogICAgICAgICAgICAgICAgICAgICdzaGFkb3dTaXplJywgCiAgICAgICAgICAgICAgICAgICAgJ3NoYWRvd0FuY2hvcicsCiAgICAgICAgICAgICAgICAgICAgJ3BvcHVwQW5jaG9yJwogICAgICAgICAgICAgICAgXTsKICAgICAgICAgICAgICAgIHZhciBkZWZhdWx0X2ljb24gPSBMLkljb24uRGVmYXVsdC5wcm90b3R5cGUub3B0aW9uczsKICAgICAgICAgICAgICAgIGlmIChfb3B0aW9ucy5pY29uVXJsKSB7CiAgICAgICAgICAgICAgICAgICAgLy8gYXJyYXlzIGFyZSBzdHJpbmdzLCB1bmZvcnR1bmF0ZWx5Li4uCiAgICAgICAgICAgICAgICAgICAgZm9yICh2YXIgaSA9IDAsIGxlbiA9IGljb25BcnJheXMubGVuZ3RoOyBpIDwgbGVuOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIG9wdGlvbl9uYW1lID0gaWNvbkFycmF5c1tpXSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wdGlvbiA9IF9vcHRpb25zWyBvcHRpb25fbmFtZSBdOwogICAgICAgICAgICAgICAgICAgICAgICAvLyBjb252ZXJ0ICIxLDIiIHRvIFsxLCAyXTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG9wdGlvbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGFyciA9IG9wdGlvbi5qb2luKCcnKS5zcGxpdCgnLCcpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gYXJyYXkubWFwIGZvciBpZTw5CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKHZhciBqID0gMCwgbGVuSiA9IGFyci5sZW5ndGg7IGogPCBsZW5KOyBqKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcnJbal0gPSBOdW1iZXIoYXJyW2pdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9vcHRpb25zWyBvcHRpb25fbmFtZSBdID0gYXJyOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIC8vIGRlZmF1bHQgcG9wdXBBbmNob3IKICAgICAgICAgICAgICAgICAgICBpZiAoIV9vcHRpb25zLnBvcHVwQW5jaG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIC8vIHNldCAocm91Z2hseSkgdG8gc2l6ZSBvZiBpY29uCiAgICAgICAgICAgICAgICAgICAgICAgIF9vcHRpb25zLnBvcHVwQW5jaG9yID0gKGZ1bmN0aW9uIChpX3NpemUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGNvcHkgYXJyYXkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlfc2l6ZSA9IGlfc2l6ZS5zbGljZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBpbnZlcnNlIGNvb3JkaW5hdGVzCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpX3NpemVbMF0gPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaV9zaXplWzFdICo9IC0xOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gYm90dG9tIHBvc2l0aW9uIG9uIHBvcHVwIGlzIDdweAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaV9zaXplWzFdIC09IDM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gaV9zaXplOwogICAgICAgICAgICAgICAgICAgICAgICB9KShfb3B0aW9ucy5pY29uU2l6ZSB8fCBkZWZhdWx0X2ljb24uaWNvblNpemUpOwogICAgICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAgICAgX29wdGlvbnMuaWNvbiA9IG5ldyBMLkljb24oIF9vcHRpb25zICk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICByZXR1cm4gX29wdGlvbnM7CiAgICAgICAgICAgIH0pKCk7CiAgICAgICAgICAgIHZhciBkcmFnZ2FibGUgPSBtYXJrZXJfb3B0aW9ucy5kcmFnZ2FibGU7CiAgICAgICAgICAgIHZhciBtYXJrZXIgPSBMLm1hcmtlcigKICAgICAgICAgICAgICAgIFs1MC4yNDc5NDkyLDEwLjk0NzYxNjg5OTk5OTk1N10sIAogICAgICAgICAgICAgICAgbWFya2VyX29wdGlvbnMKICAgICAgICAgICAgKTsKICAgICAgICAgICAgdmFyIG1hcCA9IHdpbmRvdy5XUExlYWZsZXRNYXBQbHVnaW4uZ2V0Q3VycmVudE1hcCgpOwogICAgICAgICAgICB2YXIgaXNfaW1hZ2UgPSBtYXAuaXNfaW1hZ2VfbWFwOwogICAgICAgICAgICB2YXIgZ3JvdXAgPSB3aW5kb3cuV1BMZWFmbGV0TWFwUGx1Z2luLmdldEN1cnJlbnRHcm91cCgpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZHJhZ2dhYmxlKSB7CiAgICAgICAgICAgICAgICBtYXJrZXIub24oJ2RyYWdlbmQnLCBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIGxhdGxuZyA9IHRoaXMuZ2V0TGF0TG5nKCksCiAgICAgICAgICAgICAgICAgICAgICAgIGxhdCA9IGxhdGxuZy5sYXQsCiAgICAgICAgICAgICAgICAgICAgICAgIGxuZyA9IGxhdGxuZy5sbmc7CiAgICAgICAgICAgICAgICAgICAgaWYgKGlzX2ltYWdlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKCdsZWFmbGV0LW1hcmtlciB5PScgKyBsYXQgKyAnIHg9JyArIGxuZyk7CiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc29sZS5sb2coJ2xlYWZsZXQtbWFya2VyIGxhdD0nICsgbGF0ICsgJyBsbmc9JyArIGxuZyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgbWFya2VyLmFkZFRvKCBncm91cCApOwogICAgICAgICAgICBtYXJrZXIu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ItbWVkYXUtZml0LnBuZyIsImljb25TaXplIjpbIjUxLDU4Il0sImljb25BbmNob3IiOlsiMjUuNSw1OCJdfTsKICAgICAgICAgICAgICAgIHZhciBpY29uQXJyYXlzID0gWwogICAgICAgICAgICAgICAgICAgICdpY29uU2l6ZScsIAogICAgICAgICAgICAgICAgICAgICdpY29uQW5jaG9yJywgCiAgICAgICAgICAgICAgICAgICAgJ3NoYWRvd1NpemUnLCAKICAgICAgICAgICAgICAgICAgICAnc2hhZG93QW5jaG9yJywKICAgICAgICAgICAgICAgICAgICAncG9wdXBBbmNob3InCiAgICAgICAgICAgICAgICBdOwogICAgICAgICAgICAgICAgdmFyIGRlZmF1bHRfaWNvbiA9IEwuSWNvbi5EZWZhdWx0LnByb3RvdHlwZS5vcHRpb25zOwogICAgICAgICAgICAgICAgaWYgKF9vcHRpb25zLmljb25VcmwpIHsKICAgICAgICAgICAgICAgICAgICAvLyBhcnJheXMgYXJlIHN0cmluZ3MsIHVuZm9ydHVuYXRlbHkuLi4KICAgICAgICAgICAgICAgICAgICBmb3IgKHZhciBpID0gMCwgbGVuID0gaWNvbkFycmF5cy5sZW5ndGg7IGkgPCBsZW47IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgb3B0aW9uX25hbWUgPSBpY29uQXJyYXlzW2ldLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb3B0aW9uID0gX29wdGlvbnNbIG9wdGlvbl9uYW1lIF07CiAgICAgICAgICAgICAgICAgICAgICAgIC8vIGNvbnZlcnQgIjEsMiIgdG8gWzEsIDJdOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAob3B0aW9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgYXJyID0gb3B0aW9uLmpvaW4oJycpLnNwbGl0KCcsJyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBhcnJheS5tYXAgZm9yIGllPDkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAodmFyIGogPSAwLCBsZW5KID0gYXJyLmxlbmd0aDsgaiA8IGxlbko7IGorKykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFycltqXSA9IE51bWJlcihhcnJbal0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgX29wdGlvbnNbIG9wdGlvbl9uYW1lIF0gPSBhcnI7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgLy8gZGVmYXVsdCBwb3B1cEFuY2hvcgogICAgICAgICAgICAgICAgICAgIGlmICghX29wdGlvbnMucG9wdXBBbmNob3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgLy8gc2V0IChyb3VnaGx5KSB0byBzaXplIG9mIGljb24KICAgICAgICAgICAgICAgICAgICAgICAgX29wdGlvbnMucG9wdXBBbmNob3IgPSAoZnVuY3Rpb24gKGlfc2l6ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gY29weSBhcnJheQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaV9zaXplID0gaV9zaXplLnNsaWNlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGludmVyc2UgY29vcmRpbmF0ZXMKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlfc2l6ZVswXSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpX3NpemVbMV0gKj0gLTE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBib3R0b20gcG9zaXRpb24gb24gcG9wdXAgaXMgN3B4CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpX3NpemVbMV0gLT0gMzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpX3NpemU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pKF9vcHRpb25zLmljb25TaXplIHx8IGRlZmF1bHRfaWNvbi5pY29uU2l6ZSk7CiAgICAgICAgICAgICAgICAgICAgfQoKICAgICAgICAgICAgICAgICAgICBfb3B0aW9ucy5pY29uID0gbmV3IEwuSWNvbiggX29wdGlvbnMgKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHJldHVybiBfb3B0aW9uczsKICAgICAgICAgICAgfSkoKTsKICAgICAgICAgICAgdmFyIGRyYWdnYWJsZSA9IG1hcmtlcl9vcHRpb25zLmRyYWdnYWJsZTsKICAgICAgICAgICAgdmFyIG1hcmtlciA9IEwubWFya2VyKAogICAgICAgICAgICAgICAgWzUwLjI2NzA5MTEyNzczMTgyLDEwLjk1Mzk4NDE1NDUyMjY4Nl0sIAogICAgICAgICAgICAgICAgbWFya2VyX29wdGlvbnMKICAgICAgICAgICAgKTsKICAgICAgICAgICAgdmFyIG1hcCA9IHdpbmRvdy5XUExlYWZsZXRNYXBQbHVnaW4uZ2V0Q3VycmVudE1hcCgpOwogICAgICAgICAgICB2YXIgaXNfaW1hZ2UgPSBtYXAuaXNfaW1hZ2VfbWFwOwogICAgICAgICAgICB2YXIgZ3JvdXAgPSB3aW5kb3cuV1BMZWFmbGV0TWFwUGx1Z2luLmdldEN1cnJlbnRHcm91cCgpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZHJhZ2dhYmxlKSB7CiAgICAgICAgICAgICAgICBtYXJrZXIub24oJ2RyYWdlbmQnLCBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIGxhdGxuZyA9IHRoaXMuZ2V0TGF0TG5nKCksCiAgICAgICAgICAgICAgICAgICAgICAgIGxhdCA9IGxhdGxuZy5sYXQsCiAgICAgICAgICAgICAgICAgICAgICAgIGxuZyA9IGxhdGxuZy5sbmc7CiAgICAgICAgICAgICAgICAgICAgaWYgKGlzX2ltYWdlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKCdsZWFmbGV0LW1hcmtlciB5PScgKyBsYXQgKyAnIHg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AgIHdpbmRvdy5XUExlYWZsZXRNYXBQbHVnaW4gPSB3aW5kb3cuV1BMZWFmbGV0TWFwUGx1Z2luIHx8IFtdOwogICAgICAgIHdpbmRvdy5XUExlYWZsZXRNYXBQbHVnaW4ucHVzaChmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgIHZhciBtYXJrZXJfb3B0aW9ucyA9IChmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICB2YXIgX29wdGlvbnMgPSB7Imljb25VcmwiOiJcL3dwLWNvbnRlbnRcL3VwbG9hZHNcLzIwMTdcLzA4XC9tYXJrZXIucG5nIiwiaWNvblNpemUiOlsiNTEsNTgiXSwiaWNvbkFuY2hvciI6WyIyNS41LDU4Il19OwogICAgICAgICAgICAgICAgdmFyIGljb25BcnJheXMgPSBbCiAgICAgICAgICAgICAgICAgICAgJ2ljb25TaXplJywgCiAgICAgICAgICAgICAgICAgICAgJ2ljb25BbmNob3InLCAKICAgICAgICAgICAgICAgICAgICAnc2hhZG93U2l6ZScsIAogICAgICAgICAgICAgICAgICAgICdzaGFkb3dBbmNob3InLAogICAgICAgICAgICAgICAgICAgICdwb3B1cEFuY2hvcicKICAgICAgICAgICAgICAgIF07CiAgICAgICAgICAgICAgICB2YXIgZGVmYXVsdF9pY29uID0gTC5JY29uLkRlZmF1bHQucHJvdG90eXBlLm9wdGlvbnM7CiAgICAgICAgICAgICAgICBpZiAoX29wdGlvbnMuaWNvblVybCkgewogICAgICAgICAgICAgICAgICAgIC8vIGFycmF5cyBhcmUgc3RyaW5ncywgdW5mb3J0dW5hdGVseS4uLgogICAgICAgICAgICAgICAgICAgIGZvciAodmFyIGkgPSAwLCBsZW4gPSBpY29uQXJyYXlzLmxlbmd0aDsgaSA8IGxlbjsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBvcHRpb25fbmFtZSA9IGljb25BcnJheXNbaV0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcHRpb24gPSBfb3B0aW9uc1sgb3B0aW9uX25hbWUgXTsKICAgICAgICAgICAgICAgICAgICAgICAgLy8gY29udmVydCAiMSwyIiB0byBbMSwgMl07CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChvcHRpb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBhcnIgPSBvcHRpb24uam9pbignJykuc3BsaXQoJywnKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGFycmF5Lm1hcCBmb3IgaWU8OQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yICh2YXIgaiA9IDAsIGxlbkogPSBhcnIubGVuZ3RoOyBqIDwgbGVuSjsgaisrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXJyW2pdID0gTnVtYmVyKGFycltqXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfb3B0aW9uc1sgb3B0aW9uX25hbWUgXSA9IGFycjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAvLyBkZWZhdWx0IHBvcHVwQW5jaG9yCiAgICAgICAgICAgICAgICAgICAgaWYgKCFfb3B0aW9ucy5wb3B1cEFuY2hvcikgewogICAgICAgICAgICAgICAgICAgICAgICAvLyBzZXQgKHJvdWdobHkpIHRvIHNpemUgb2YgaWNvbgogICAgICAgICAgICAgICAgICAgICAgICBfb3B0aW9ucy5wb3B1cEFuY2hvciA9IChmdW5jdGlvbiAoaV9zaXplKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBjb3B5IGFycmF5CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpX3NpemUgPSBpX3NpemUuc2xpY2UoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gaW52ZXJzZSBjb29yZGluYXRlcwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaV9zaXplWzBdID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlfc2l6ZVsxXSAqPSAtMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGJvdHRvbSBwb3NpdGlvbiBvbiBwb3B1cCBpcyA3cHgKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlfc2l6ZVsxXSAtPSAzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGlfc2l6ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfSkoX29wdGlvbnMuaWNvblNpemUgfHwgZGVmYXVsdF9pY29uLmljb25TaXplKTsKICAgICAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgICAgICAgIF9vcHRpb25zLmljb24gPSBuZXcgTC5JY29uKCBfb3B0aW9ucyApOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgcmV0dXJuIF9vcHRpb25zOwogICAgICAgICAgICB9KSgpOwogICAgICAgICAgICB2YXIgZHJhZ2dhYmxlID0gbWFya2VyX29wdGlvbnMuZHJhZ2dhYmxlOwogICAgICAgICAgICB2YXIgbWFya2VyID0gTC5tYXJrZXIoCiAgICAgICAgICAgICAgICBbNTAuMjY2OTM0NCwxMC45NTA3NzM0OTk5OTk5NjhdLCAKICAgICAgICAgICAgICAgIG1hcmtlcl9vcHRpb25zCiAgICAgICAgICAgICk7CiAgICAgICAgICAgIHZhciBtYXAgPSB3aW5kb3cuV1BMZWFmbGV0TWFwUGx1Z2luLmdldEN1cnJlbnRNYXAoKTsKICAgICAgICAgICAgdmFyIGlzX2ltYWdlID0gbWFwLmlzX2ltYWdlX21hcDsKICAgICAgICAgICAgdmFyIGdyb3VwID0gd2luZG93LldQTGVhZmxldE1hcFBsdWdpbi5nZXRDdXJyZW50R3JvdXAoKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRyYWdnYWJsZSkgewogICAgICAgICAgICAgICAgbWFya2VyLm9uKCdkcmFnZW5kJywgZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHZhciBsYXRsbmcgPSB0aGlzLmdldExhdExuZygpLAogICAgICAgICAgICAgICAgICAgICAgICBsYXQgPSBsYXRsbmcubGF0LAogICAgICAgICAgICAgICAgICAgICAgICBsbmcgPSBsYXRsbmcubG5nOwogICAgICAgICAgICAgICAgICAgIGlmIChpc19pbWFnZSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zb2xlLmxvZygnbGVhZmxldC1tYXJrZXIgeT0nICsgbGF0ICsgJyB4PScgKyBsbmcpOwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKCdsZWFmbGV0LW1hcmtlciBsYXQ9JyArIGxhdCArICcgbG5nPScgKyBsbmcpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIG1hcmtlci5hZGRUbyggZ3JvdXAgKTsKICAgICAgICAgICAgbWFya2VyLmJpbmRQb3B1cCh3aW5kb3cuV1BMZWFmbGV0TWFwUGx1Z2luLnVuZXNjYXBlKCcmbHQ7c3Ryb25nJmd0O01FREFVbG9nbyBTY2hsb3NzIEhvaGVuZmVscyZsdDsvc3Ryb25nJmd0OyZsdDticiAvJmd0OyZsdDticiZndDtTY2hsb8OfIEhvaGVuZmVscyZsdDticiAvJmd0OyZsdDticiZndDs5NjQ1MCBDb2J1cmcmbHQ7YnIgLyZndDsmbHQ7YnImZ3Q7VGVsZWZvbjogJmx0O2EgaHJlZj1cJnF1b3Q7dGVsOjA5NTYxMjM1MTBcJnF1b3Q7Jmd0OzA5NTYxIDIzNTEwJmx0Oy9hJmd0OyZsdDticiAvJmd0OyZsdDticiZndDtGYXg6ICs0OSAoMCk5NTYxIC8gMjM1MS0zNCZsdDticiAvJmd0OyZsdDticiZndDtFLU1haWw6ICZsdDthIGhyZWY9XCZxdW90O21haWx0bzpwcmF4aXMtaG9oZW5mZWxzQG1lZGF1LWxvZ28uZGVcJnF1b3Q7Jmd0O3ByYXhpcy1ob2hlbmZlbHNAbWVkYXUtbG9nby5kZSZsdDsvYSZndDsnKSk7ICAgICAgICAgICAgd2luZG93LldQTGVhZmxldE1hcFBsdWdpbi5tYXJrZXJzLnB1c2goIG1hcmtlciApOwogICAgICAgIH0pOyAvLyBlbmQgYWRkIGZ1bmN0aW9uCiAgICAgICAgPC9zY3JpcHQ+CiAgICAgICAgICAgICAgICA8c2NyaXB0PgogICAgICAgIHdpbmRvdy5XUExlYWZsZXRNYXBQbHVnaW4gPSB3aW5kb3cuV1BMZWFmbGV0TWFwUGx1Z2luIHx8IFtdOwogICAgICAgIHdpbmRvdy5XUExlYWZsZXRNYXBQbHVnaW4ucHVzaChmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgIHZhciBtYXJrZXJfb3B0aW9ucyA9IChmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICB2YXIgX29wdGlvbnMgPSB7Imljb25VcmwiOiJcL3dwLWNvbnRlbnRcL3VwbG9hZHNcLzIwMTdcLzA4XC9tYXJrZXIucG5nIiwiaWNvblNpemUiOlsiNTEsNTgiXSwiaWNvbkFuY2hvciI6WyIyNS41LDU4Il19OwogICAgICAgICAgICAgICAgdmFyIGljb25BcnJheXMgPSBbCiAgICAgICAgICAgICAgICAgICAgJ2ljb25TaXplJywgCiAgICAgICAgICAgICAgICAgICAgJ2ljb25BbmNob3InLCAKICAgICAgICAgICAgICAgICAgICAnc2hhZG93U2l6ZScsIAogICAgICAgICAgICAgICAgICAgICdzaGFkb3dBbmNob3InLAogICAgICAgICAgICAgICAgICAgICdwb3B1cEFuY2hvcicKICAgICAgICAgICAgICAgIF07CiAgICAgICAgICAgICAgICB2YXIgZGVmYXVsdF9pY29uID0gTC5JY29uLkRlZmF1bHQucHJvdG90eXBlLm9wdGlvbnM7CiAgICAgICAgICAgICAgICBpZiAoX29wdGlvbnMuaWNvblVybCkgewogICAgICAgICAgICAgICAgICAgIC8vIGFycmF5cyBhcmUgc3RyaW5ncywgdW5mb3J0dW5hdGVseS4uLgogICAgICAgICAgICAgICAgICAgIGZvciAodmFyIGkgPSAwLCBsZW4gPSBpY29uQXJyYXlzLmxlbmd0aDsgaSA8IGxlbjsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBvcHRpb25fbmFtZSA9IGljb25BcnJheXNbaV0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcHRpb24gPSBfb3B0aW9uc1sgb3B0aW9uX25hbWUgXTsKICAgICAgICAgICAgICAgICAgICAgICAgLy8gY29udmVydCAiMSwyIiB0byBbMSwgMl07CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChvcHRpb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBhcnIgPSBvcHRpb24uam9pbignJykuc3BsaXQoJywnKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGFycmF5Lm1hcCBmb3IgaWU8OQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yICh2YXIgaiA9IDAsIGxlbkogPSBhcnIubGVuZ3RoOyBqIDwgbGVuSjsgaisrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXJyW2pdID0gTnVtYmVyKGFycltqXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfb3B0aW9uc1sgb3B0aW9uX25hbWUgXSA9IGFycjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAvLyBkZWZhdWx0IHBvcHVwQW5jaG9yCiAgICAgICAgICAgICAgICAgICAgaWYgKCFfb3B0aW9ucy5wb3B1cEFuY2hvcikgewogICAgICAgICAgICAgICAgICAgICAgICAvLyBzZXQgKHJvdWdobHkpIHRvIHNpemUgb2YgaWNvbgogICAgICAgICAgICAgICAgICAgICAgICBfb3B0aW9ucy5wb3B1cEFuY2hvciA9IChmdW5jdGlvbiAoaV9zaXplKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBjb3B5IGFycmF5CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpX3NpemUgPSBpX3NpemUuc2xpY2UoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gaW52ZXJzZSBjb29yZGluYXRlcwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaV9zaXplWzBdID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlfc2l6ZVsxXSAqPSAtMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGJvdHRvbSBwb3NpdGlvbiBvbiBwb3B1cCBpcyA3cHgKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlfc2l6ZVsxXSAtPSAzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGlfc2l6ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfSkoX29wdGlvbnMuaWNvblNpemUgfHwgZGVmYXVsdF9pY29uLmljb25TaXplKTsKICAgICAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgICAgICAgIF9vcHRpb25zLmljb24gPSBuZXcgTC5JY29uKCBfb3B0aW9ucyApOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgcmV0dXJuIF9vcHRpb25zOwogICAgICAgICAgICB9KSgpOwogICAgICAgICAgICB2YXIgZHJhZ2dhYmxlID0gbWFya2VyX29wdGlvbnMuZHJhZ2dhYmxlOwogICAgICAgICAgICB2YXIgbWFya2VyID0gTC5tYXJrZXIoCiAgICAgICAgICAgICAgICBbNTAuMTAyNDc3NCwxMS4wMDI5NTcyOTk5OTk5MzVdLCAKICAgICAgICAgICAgICAgIG1hcmtlcl9vcHRpb25zCiAgICAgICAgICAgICk7CiAgICAgICAgICAgIHZhciBtYXAgPSB3aW5kb3cuV1BMZWFmbGV0TWFwUGx1Z2luLmdldEN1cnJlbnRNYXAoKTsKICAgICAgICAgICAgdmFyIGlzX2ltYWdlID0gbWFwLmlzX2ltYWdlX21hcDsKICAgICAgICAgICAgdmFyIGdyb3VwID0gd2luZG93LldQTGVhZmxldE1hcFBsdWdpbi5nZXRDdXJyZW50R3JvdXAoKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRyYWdnYWJsZSkgewogICAgICAgICAgICAgICAgbWFya2VyLm9uKCdkcmFnZW5kJywgZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHZhciBsYXRsbmcgPSB0aGlzLmdldExhdExuZygpLAogICAgICAgICAgICAgICAgICAgICAgICBsYXQgPSBsYXRsbmcubGF0LAogICAgICAgICAgICAgICAgICAgICAgICBsbmcgPSBsYXRsbmcubG5nOwogICAgICAgICAgICAgICAgICAgIGlmIChpc19pbWFnZSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zb2xlLmxvZygnbGVhZmxldC1tYXJrZXIgeT0nICsgbGF0ICsgJyB4PScgKyBsbmcpOwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKCdsZWFmbGV0LW1hcmtlciBsYXQ9JyArIGxhdCArICcgbG5nPScgKyBsbmcpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIG1hcmtlci5hZGRUbyggZ3JvdXAgKTsKICAgICAgICAgICAgbWFya2VyLmJpbmRQb3B1cCh3aW5kb3cuV1BMZWFmbGV0TWFwUGx1Z2luLnVuZXNjYXBlKCcmbHQ7c3Ryb25nJmd0O01FREFVbG9nbyBMaWNodGVuZmVsc2VyIFN0cmHDn2UmbHQ7L3N0cm9uZyZndDsmbHQ7YnIgLyZndDsmbHQ7YnImZ3Q7TGljaHRlbmZlbHNlciBTdHJhw59lIDI2Jmx0O2JyIC8mZ3Q7Jmx0O2J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gICAgICAgICAgICAnc2hhZG93U2l6ZScsIAogICAgICAgICAgICAgICAgICAgICdzaGFkb3dBbmNob3InLAogICAgICAgICAgICAgICAgICAgICdwb3B1cEFuY2hvcicKICAgICAgICAgICAgICAgIF07CiAgICAgICAgICAgICAgICB2YXIgZGVmYXVsdF9pY29uID0gTC5JY29uLkRlZmF1bHQucHJvdG90eXBlLm9wdGlvbnM7CiAgICAgICAgICAgICAgICBpZiAoX29wdGlvbnMuaWNvblVybCkgewogICAgICAgICAgICAgICAgICAgIC8vIGFycmF5cyBhcmUgc3RyaW5ncywgdW5mb3J0dW5hdGVseS4uLgogICAgICAgICAgICAgICAgICAgIGZvciAodmFyIGkgPSAwLCBsZW4gPSBpY29uQXJyYXlzLmxlbmd0aDsgaSA8IGxlbjsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBvcHRpb25fbmFtZSA9IGljb25BcnJheXNbaV0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcHRpb24gPSBfb3B0aW9uc1sgb3B0aW9uX25hbWUgXTsKICAgICAgICAgICAgICAgICAgICAgICAgLy8gY29udmVydCAiMSwyIiB0byBbMSwgMl07CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChvcHRpb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBhcnIgPSBvcHRpb24uam9pbignJykuc3BsaXQoJywnKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGFycmF5Lm1hcCBmb3IgaWU8OQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yICh2YXIgaiA9IDAsIGxlbkogPSBhcnIubGVuZ3RoOyBqIDwgbGVuSjsgaisrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXJyW2pdID0gTnVtYmVyKGFycltqXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfb3B0aW9uc1sgb3B0aW9uX25hbWUgXSA9IGFycjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAvLyBkZWZhdWx0IHBvcHVwQW5jaG9yCiAgICAgICAgICAgICAgICAgICAgaWYgKCFfb3B0aW9ucy5wb3B1cEFuY2hvcikgewogICAgICAgICAgICAgICAgICAgICAgICAvLyBzZXQgKHJvdWdobHkpIHRvIHNpemUgb2YgaWNvbgogICAgICAgICAgICAgICAgICAgICAgICBfb3B0aW9ucy5wb3B1cEFuY2hvciA9IChmdW5jdGlvbiAoaV9zaXplKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBjb3B5IGFycmF5CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpX3NpemUgPSBpX3NpemUuc2xpY2UoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gaW52ZXJzZSBjb29yZGluYXRlcwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaV9zaXplWzBdID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlfc2l6ZVsxXSAqPSAtMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGJvdHRvbSBwb3NpdGlvbiBvbiBwb3B1cCBpcyA3cHgKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlfc2l6ZVsxXSAtPSAzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGlfc2l6ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfSkoX29wdGlvbnMuaWNvblNpemUgfHwgZGVmYXVsdF9pY29uLmljb25TaXplKTsKICAgICAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgICAgICAgIF9vcHRpb25zLmljb24gPSBuZXcgTC5JY29uKCBfb3B0aW9ucyApOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgcmV0dXJuIF9vcHRpb25zOwogICAgICAgICAgICB9KSgpOwogICAgICAgICAgICB2YXIgZHJhZ2dhYmxlID0gbWFya2VyX29wdGlvbnMuZHJhZ2dhYmxlOwogICAgICAgICAgICB2YXIgbWFya2VyID0gTC5tYXJrZXIoCiAgICAgICAgICAgICAgICBbNDguMTI2MzU0MiwxMS41NTE1NzU4MDAwMDAwMjNdLCAKICAgICAgICAgICAgICAgIG1hcmtlcl9vcHRpb25zCiAgICAgICAgICAgICk7CiAgICAgICAgICAgIHZhciBtYXAgPSB3aW5kb3cuV1BMZWFmbGV0TWFwUGx1Z2luLmdldEN1cnJlbnRNYXAoKTsKICAgICAgICAgICAgdmFyIGlzX2ltYWdlID0gbWFwLmlzX2ltYWdlX21hcDsKICAgICAgICAgICAgdmFyIGdyb3VwID0gd2luZG93LldQTGVhZmxldE1hcFBsdWdpbi5nZXRDdXJyZW50R3JvdXAoKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRyYWdnYWJsZSkgewogICAgICAgICAgICAgICAgbWFya2VyLm9uKCdkcmFnZW5kJywgZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHZhciBsYXRsbmcgPSB0aGlzLmdldExhdExuZygpLAogICAgICAgICAgICAgICAgICAgICAgICBsYXQgPSBsYXRsbmcubGF0LAogICAgICAgICAgICAgICAgICAgICAgICBsbmcgPSBsYXRsbmcubG5nOwogICAgICAgICAgICAgICAgICAgIGlmIChpc19pbWFnZSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zb2xlLmxvZygnbGVhZmxldC1tYXJrZXIgeT0nICsgbGF0ICsgJyB4PScgKyBsbmcpOwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKCdsZWFmbGV0LW1hcmtlciBsYXQ9JyArIGxhdCArICcgbG5nPScgKyBsbmcpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIG1hcmtlci5hZGRUby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3VwbG9hZHNcLzIwMTdcLzA4XC9tYXJrZXIucG5nIiwiaWNvblNpemUiOlsiNTEsNTgiXSwiaWNvbkFuY2hvciI6WyIyNS41LDU4Il19OwogICAgICAgICAgICAgICAgdmFyIGljb25BcnJheXMgPSBbCiAgICAgICAgICAgICAgICAgICAgJ2ljb25TaXplJywgCiAgICAgICAgICAgICAgICAgICAgJ2ljb25BbmNob3InLCAKICAgICAgICAgICAgICAgICAgICAnc2hhZG93U2l6ZScsIAogICAgICAgICAgICAgICAgICAgICdzaGFkb3dBbmNob3InLAogICAgICAgICAgICAgICAgICAgICdwb3B1cEFuY2hvcicKICAgICAgICAgICAgICAgIF07CiAgICAgICAgICAgICAgICB2YXIgZGVmYXVsdF9pY29uID0gTC5JY29uLkRlZmF1bHQucHJvdG90eXBlLm9wdGlvbnM7CiAgICAgICAgICAgICAgICBpZiAoX29wdGlvbnMuaWNvblVybCkgewogICAgICAgICAgICAgICAgICAgIC8vIGFycmF5cyBhcmUgc3RyaW5ncywgdW5mb3J0dW5hdGVseS4uLgogICAgICAgICAgICAgICAgICAgIGZvciAodmFyIGkgPSAwLCBsZW4gPSBpY29uQXJyYXlzLmxlbmd0aDsgaSA8IGxlbjsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBvcHRpb25fbmFtZSA9IGljb25BcnJheXNbaV0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcHRpb24gPSBfb3B0aW9uc1sgb3B0aW9uX25hbWUgXTsKICAgICAgICAgICAgICAgICAgICAgICAgLy8gY29udmVydCAiMSwyIiB0byBbMSwgMl07CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChvcHRpb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBhcnIgPSBvcHRpb24uam9pbignJykuc3BsaXQoJywnKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGFycmF5Lm1hcCBmb3IgaWU8OQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yICh2YXIgaiA9IDAsIGxlbkogPSBhcnIubGVuZ3RoOyBqIDwgbGVuSjsgaisrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXJyW2pdID0gTnVtYmVyKGFycltqXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfb3B0aW9uc1sgb3B0aW9uX25hbWUgXSA9IGFycjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAvLyBkZWZhdWx0IHBvcHVwQW5jaG9yCiAgICAgICAgICAgICAgICAgICAgaWYgKCFfb3B0aW9ucy5wb3B1cEFuY2hvcikgewogICAgICAgICAgICAgICAgICAgICAgICAvLyBzZXQgKHJvdWdobHkpIHRvIHNpemUgb2YgaWNvbgogICAgICAgICAgICAgICAgICAgICAgICBfb3B0aW9ucy5wb3B1cEFuY2hvciA9IChmdW5jdGlvbiAoaV9zaXplKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBjb3B5IGFycmF5CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpX3NpemUgPSBpX3NpemUuc2xpY2UoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gaW52ZXJzZSBjb29yZGluYXRlcwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaV9zaXplWzBdID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlfc2l6ZVsxXSAqPSAtMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGJvdHRvbSBwb3NpdGlvbiBvbiBwb3B1cCBpcyA3cHgKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlfc2l6ZVsxXSAtPSAzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGlfc2l6ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfSkoX29wdGlvbnMuaWNvblNpemUgfHwgZGVmYXVsdF9pY29uLmljb25TaXplKTsKICAgICAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgICAgICAgIF9vcHRpb25zLmljb24gPSBuZXcgTC5JY29uKCBfb3B0aW9ucyApOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgcmV0dXJuIF9vcHRpb25zOwogICAgICAgICAgICB9KSgpOwogICAgICAgICAgICB2YXIgZHJhZ2dhYmxlID0gbWFya2VyX29wdGlvbnMuZHJhZ2dhYmxlOwogICAgICAgICAgICB2YXIgbWFya2VyID0gTC5tYXJrZXIoCiAgICAgICAgICAgICAgICBbNDkuNDY4NTYsMTEuMDgxMTA5OTk5OTk5OTY3XSwgCiAgICAgICAgICAgICAgICBtYXJrZXJfb3B0aW9ucwogICAgICAgICAgICApOwogICAgICAgICAgICB2YXIgbWFwID0gd2luZG93LldQTGVhZmxldE1hcFBsdWdpbi5nZXRDdXJyZW50TWFwKCk7CiAgICAgICAgICAgIHZhciBpc19pbWFnZSA9IG1hcC5pc19pbWFnZV9tYXA7CiAgICAgICAgICAgIHZhciBncm91cCA9IHdpbmRvdy5XUExlYWZsZXRNYXBQbHVnaW4uZ2V0Q3VycmVudEdyb3VwKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkcmFnZ2FibGUpIHsKICAgICAgICAgICAgICAgIG1hcmtlci5vbignZHJhZ2VuZCcsIGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgbGF0bG5nID0gdGhpcy5nZXRMYXRMbmcoKSwKICAgICAgICAgICAgICAgICAgICAgICAgbGF0ID0gbGF0bG5nLmxhdCwKICAgICAgICAgICAgICAgICAgICAgICAgbG5nID0gbGF0bG5nLmxuZzsKICAgICAgICAgICAgICAgICAgICBpZiAoaXNfaW1hZ2UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc29sZS5sb2coJ2xlYWZsZXQtbWFya2VyIHk9JyArIGxhdCArICcgeD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gICAgICAgICAgIDxzY3JpcHQ+CiAgICAgICAgd2luZG93LldQTGVhZmxldE1hcFBsdWdpbiA9IHdpbmRvdy5XUExlYWZsZXRNYXBQbHVnaW4gfHwgW107CiAgICAgICAgd2luZG93LldQTGVhZmxldE1hcFBsdWdpbi5wdXNoKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgdmFyIG1hcmtlcl9vcHRpb25zID0gKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgIHZhciBfb3B0aW9ucyA9IHsiaWNvblVybCI6Ilwvd3AtY29udGVudFwvdXBsb2Fkc1wvMjAxN1wvMDhcL21hcmtlci5wbmciLCJpY29uU2l6ZSI6WyI1MSw1OCJdLCJpY29uQW5jaG9yIjpbIjI1LjUsNTgiXX07CiAgICAgICAgICAgICAgICB2YXIgaWNvbkFycmF5cyA9IFsKICAgICAgICAgICAgICAgICAgICAnaWNvblNpemUnLCAKICAgICAgICAgICAgICAgICAgICAnaWNvbkFuY2hvcicsIAogICAgICAgICAgICAgICAgICAgICdzaGFkb3dTaXplJywgCiAgICAgICAgICAgICAgICAgICAgJ3NoYWRvd0FuY2hvcicsCiAgICAgICAgICAgICAgICAgICAgJ3BvcHVwQW5jaG9yJwogICAgICAgICAgICAgICAgXTsKICAgICAgICAgICAgICAgIHZhciBkZWZhdWx0X2ljb24gPSBMLkljb24uRGVmYXVsdC5wcm90b3R5cGUub3B0aW9uczsKICAgICAgICAgICAgICAgIGlmIChfb3B0aW9ucy5pY29uVXJsKSB7CiAgICAgICAgICAgICAgICAgICAgLy8gYXJyYXlzIGFyZSBzdHJpbmdzLCB1bmZvcnR1bmF0ZWx5Li4uCiAgICAgICAgICAgICAgICAgICAgZm9yICh2YXIgaSA9IDAsIGxlbiA9IGljb25BcnJheXMubGVuZ3RoOyBpIDwgbGVuOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIG9wdGlvbl9uYW1lID0gaWNvbkFycmF5c1tpXSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wdGlvbiA9IF9vcHRpb25zWyBvcHRpb25fbmFtZSBdOwogICAgICAgICAgICAgICAgICAgICAgICAvLyBjb252ZXJ0ICIxLDIiIHRvIFsxLCAyXTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG9wdGlvbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGFyciA9IG9wdGlvbi5qb2luKCcnKS5zcGxpdCgnLCcpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gYXJyYXkubWFwIGZvciBpZTw5CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKHZhciBqID0gMCwgbGVuSiA9IGFyci5sZW5ndGg7IGogPCBsZW5KOyBqKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcnJbal0gPSBOdW1iZXIoYXJyW2pdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9vcHRpb25zWyBvcHRpb25fbmFtZSBdID0gYXJyOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIC8vIGRlZmF1bHQgcG9wdXBBbmNob3IKICAgICAgICAgICAgICAgICAgICBpZiAoIV9vcHRpb25zLnBvcHVwQW5jaG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIC8vIHNldCAocm91Z2hseSkgdG8gc2l6ZSBvZiBpY29uCiAgICAgICAgICAgICAgICAgICAgICAgIF9vcHRpb25zLnBvcHVwQW5jaG9yID0gKGZ1bmN0aW9uIChpX3NpemUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGNvcHkgYXJyYXkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlfc2l6ZSA9IGlfc2l6ZS5zbGljZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBpbnZlcnNlIGNvb3JkaW5hdGVzCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpX3NpemVbMF0gPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaV9zaXplWzFdICo9IC0xOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gYm90dG9tIHBvc2l0aW9uIG9uIHBvcHVwIGlzIDdweAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaV9zaXplWzFdIC09IDM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gaV9zaXplOwogICAgICAgICAgICAgICAgICAgICAgICB9KShfb3B0aW9ucy5pY29uU2l6ZSB8fCBkZWZhdWx0X2ljb24uaWNvblNpemUpOwogICAgICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAgICAgX29wdGlvbnMuaWNvbiA9IG5ldyBMLkljb24oIF9vcHRpb25zICk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICByZXR1cm4gX29wdGlvbnM7CiAgICAgICAgICAgIH0pKCk7CiAgICAgICAgICAgIHZhciBkcmFnZ2FibGUgPSBtYXJrZXJfb3B0aW9ucy5kcmFnZ2FibGU7CiAgICAgICAgICAgIHZhciBtYXJrZXIgPSBMLm1hcmtlcigKICAgICAgICAgICAgICAgIFs0OS44OTA4MDExLDEwLjg5MzIwNDQwMDAwMDA1OV0sIAogICAgICAgICAgICAgICAgbWFya2VyX29wdGlvbnMKICAgICAgICAgICAgKTsKICAgICAgICAgICAgdmFyIG1hcCA9IHdpbmRvdy5XUExlYWZsZXRNYXBQbHVnaW4uZ2V0Q3VycmVudE1hcCgpOwogICAgICAgICAgICB2YXIgaXNfaW1hZ2UgPSBtYXAuaXNfaW1hZ2VfbWFwOwogICAgICAgICAgICB2YXIgZ3JvdXAgPSB3aW5kb3cuV1BMZWFmbGV0TWFwUGx1Z2luLmdldEN1cnJlbnRHcm91cCgpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZHJhZ2dhYmxlKSB7CiAg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